Hard Light Productions Forums

Modding, Mission Design, and Coding => FS2 Open Coding - The Source Code Project (SCP) => Topic started by: Dragon on March 18, 2012, 07:16:17 am

Title: [Feature request]: Force glide on all ships, in AI profiles.
Post by: Dragon on March 18, 2012, 07:16:17 am
I've recently returned to playing around with Newtonian flight model in FS, and made an amazing discovery: The glide mode, when set up properly, essentially gives a full Newtonian flight model. Not only that, AI handles it pretty well and it's partially independent from "normal" speed and acceleration values, making the same ship capable of semi-realistic atmospheric flight.
That means the only thing a fully Newtonian mod would need is to simply force glide on every ship, in every space mission, along with adjusting tables to make it playable.
Unfortunately, "Force glide" SEXP is a rather tedious way to do that, since you essentially need to list every small ship in mission, and maybe also capships (I haven't yet figured out how well capships handle gliding). So, I'm asking to include a "Force Glide" setting in AI Profiles. This shouldn't be too difficult, as all functionality is already there, I'm just asking for an additional place to toggle it from.
Title: Re: [Feature request]: Force glide on all ships, in AI profiles.
Post by: zookeeper on March 18, 2012, 09:12:41 am
How about a force_glide-sct.tbm?

Code: [Select]
#Conditional Hooks

$Application: FS2_Open

$On Mission Start: [

    num = #mn.Ships
   
    for i=1,num do
        mn.runSEXP("force-glide !" .. mn.Ships[i].Name .. "! !true!")
    end

]

#End
Title: Re: [Feature request]: Force glide on all ships, in AI profiles.
Post by: m!m on March 18, 2012, 09:22:57 am
Or even better run in in the "On Frame"-Hook so new ships also get glide enabled.
Title: Re: [Feature request]: Force glide on all ships, in AI profiles.
Post by: Dragon on March 18, 2012, 09:29:29 am
Wouldn't it crash if a ship doesn't have glide defined?
Also, I need to be able to make it work the opposite way (force glide off) for atmospheric missions.
Title: Re: [Feature request]: Force glide on all ships, in AI profiles.
Post by: zookeeper on March 19, 2012, 04:41:57 am
Or even better run in in the "On Frame"-Hook so new ships also get glide enabled.

Yeah, I'm not completely sure how comprehensively my method works. I think it works just fine for ships which haven't yet arrived at mission start, but it won't work for ships created with ship-create, and I have no idea about whether it'd work correctly on waves.

Wouldn't it crash if a ship doesn't have glide defined?

Doesn't look like it.

Also, I need to be able to make it work the opposite way (force glide off) for atmospheric missions.

Well, then you can have this:

Code: [Select]
#Conditional Hooks

$Application: FS2_Open

$On Mission Start: [

    force_glide = false
    forced_glide_status = false

    if mn.Events["force glide on"]:isValid() then
        force_glide = true
        forced_glide_status = true
    end
   
    if mn.Events["force glide off"]:isValid() then
        force_glide = true
        forced_glide_status = false
    end
       
    if force_glide then
        num = #mn.Ships
       
        for i=1,num do
            mn.runSEXP("force-glide !" .. mn.Ships[i].Name .. "! !" .. forced_glide_status .. "!")
        end
    end

]

#End

If the mission has an event called "force glide on", then glide will be forced on, and off if it has an event called "force glide off". Also, as per m!m's suggestion, you might want to split the last if into a separate $On Frame hook.
Title: Re: [Feature request]: Force glide on all ships, in AI profiles.
Post by: m!m on March 19, 2012, 08:21:41 am
Yeah, I'm not completely sure how comprehensively my method works. I think it works just fine for ships which haven't yet arrived at mission start, but it won't work for ships created with ship-create, and I have no idea about whether it'd work correctly on waves.
mn.Ships includes all ships specified in the mission file? Cool, I didn't know that.

I guess you could also query the gliding status for every ship and set it to glide when it isn't gliding (or the other way round).
Title: Re: [Feature request]: Force glide on all ships, in AI profiles.
Post by: Dragon on March 21, 2012, 05:37:11 pm
Yeah, it seems it could work. Though I'd still like an AIP option. But it'll do for now.
Title: Re: [Feature request]: Force glide on all ships, in AI profiles.
Post by: Zacam on March 24, 2012, 06:46:47 pm
Considering that (for Retail ships at least) you'd still need to define Glide values for the ships, just setting an AIP with ships that don't have any Glide values would produce nothing.
Title: Re: [Feature request]: Force glide on all ships, in AI profiles.
Post by: Dragon on March 24, 2012, 07:00:04 pm
Why do you think it's intended for use with retail ships? It was never the idea, though I could make something like that in the future. That would warrant a full re-FREDing of the campaign for the new flight model though.