Hard Light Productions Forums

Modding, Mission Design, and Coding => The FRED Workshop => Topic started by: Ace on September 05, 2008, 03:38:37 am

Title: Transfering ship speed and facing
Post by: Ace on September 05, 2008, 03:38:37 am
Here's a tricky one:
The idea is swapping out a ship with a new one. Keeping the same location, speed, and heading as the original ship.

For location, that's simple by using the old ship's position when creating the new one. For storing speed, that should be doable through a variable.

However, storing a ship's heading (facing) seems to be trickier, thus the question here.
Title: Re: Transfering ship speed and facing
Post by: King Zelch on September 05, 2008, 06:49:01 am
Is there any reason why you can't just use Change-ship-class?  :confused:
Title: Re: Transfering ship speed and facing
Post by: Ace on September 05, 2008, 01:00:14 pm
Because I need the replacement ship to warp out, with the original ship then re-appearing. This convoluted sequence is because the warp-effect SEXP doesn't work with the FTL effect being used.

To explicate: this is for a mis-jumping effect for Btrl. Since warp-effect doesn't properly work, the solution would be a dummy ship but position, facing, and speed all need to be transferred.
Title: Re: Transfering ship speed and facing
Post by: Colonol Dekker on September 05, 2008, 01:38:48 pm
Why not use one of the "make a warp effect" sexps using "get ship xyz" i think the warpy one is under cinematics or special effects. I've not Fredded properly in a good six weeks so forgive the vagueness.
Title: Re: Transfering ship speed and facing
Post by: Ace on September 05, 2008, 04:40:46 pm
Because the warp-effect SEXP isn't compatible with this FTL effect.
Title: Re: Transfering ship speed and facing
Post by: Colonol Dekker on September 05, 2008, 07:41:56 pm
Feature request?
"because you're worth it"
Title: Re: Transfering ship speed and facing
Post by: FUBAR-BDHR on September 05, 2008, 07:50:14 pm
Are you talking cap ship?  Is the ship doing any sort of waypoints?
Title: Re: Transfering ship speed and facing
Post by: karajorma on September 06, 2008, 01:17:41 am
Feature request?

I seem to remember trying something similar 3-4 years ago. At the time I decided I'd need a new SEXP to make it work.

Since then I haven't tried it again though so there may be some way of getting it to work using the various object manipulation SEXPs. I'm pretty sure there wasn't back then though.
Title: Re: Transfering ship speed and facing
Post by: Ace on September 11, 2008, 08:41:43 pm
With the coordinate manipulation SEXPs, it could be possible with a "get-object-speed X, Y, Z" type command. (set that to variables, use the variables for the coordinate manip)

Similarly  a "get-object-facing X, Y, Z" under coordinate manipulation would make this fully work.

Since create-ship doesn't seem to allow for waypoints, the hack of making a waypoint a few meters in front of you for a reference spot doesn't seem to work. (this doesn't really solve the speed issue as you need coordinates in three axes to properly do the speed with the coordinate manipulation SEXP)

For the time being I have a solution by slowing your ship down to a halt when doing the effect. However, these SEXPs appear to be necessary to do this effect with a moving object.

With those two SEXPs added plenty of interesting things could be possible, such as the "multiple ships sharing one jump vortex" idea. No warp effect ships arrive after the main ship, use the get-object-facing and get-object-speed SEXPs on the jumping ship with the set-object-facing and set-object-speed SEXPs on the "riders" and it should have them move at the same speed as the main ship as long as the events are repeating. In the end, this would allow the other ships to mimic the same deceleration from the vortex.
Title: Re: Transfering ship speed and facing
Post by: karajorma on September 12, 2008, 01:41:18 am
I tend to bounce between thinking we need a pair of get and set rotations SEXPs and being convinced we already have at last one of the two.

Either way this is probably one of the SEXPs I'm least suited to add myself since I've only got the vaguest idea how to do vector maths these days (I learned for my A levels and then promptly forgot it all).
Title: Re: Transfering ship speed and facing
Post by: Trivial Psychic on September 15, 2008, 12:24:32 am
How about sexps less complicated for the FREDder?

transfer-co-ordinates
-<source ship which is leaving>
-<ship to transfer co-ordinates to>
-optional additional ships receiving co-ordinates

-transfer-vector

(does same as previous except it transfers the direction the first ship was pointing in 3D space)

-transfer-attitude

(does same as previous except it transfers essentially the ship's angle of bank)

Is this useful, or would it be WAY to difficult to code in?

With those two SEXPs added plenty of interesting things could be possible, such as the "multiple ships sharing one jump vortex" idea. No warp effect ships arrive after the main ship, use the get-object-facing and get-object-speed SEXPs on the jumping ship with the set-object-facing and set-object-speed SEXPs on the "riders" and it should have them move at the same speed as the main ship as long as the events are repeating. In the end, this would allow the other ships to mimic the same deceleration from the vortex.

I'd been pushing for an option in the ships (and wings) arrival and departure cues editor, which would include a "preserve warping motions" checkbox.  This would be greyed-out by default, until the "disable warp effect" checkbox is ticked.  The new checkbox would allow you to retain a ship's warping speed and accelleration/deceleration rate without having a warp vortex.  Then, if you want ships to appear to arrive or depart from the same group vortex, all you need to do is get them all to point the same direction (ie, head towards a distant waypoint) for departures, or simply place them properly for arrivals, use the "generate-warp-vortex sexp, and have all the ships warp without their own vortexes, but retaining the speeds and accel/decel rates, and presto... you have the desired effect.
Title: Re: Transfering ship speed and facing
Post by: Goober5000 on September 15, 2008, 12:43:18 am
How about sexps less complicated for the FREDder?

transfer-co-ordinates
-<source ship which is leaving>
-<ship to transfer co-ordinates to>
-optional additional ships receiving co-ordinates

-transfer-vector

(does same as previous except it transfers the direction the first ship was pointing in 3D space)

-transfer-attitude

(does same as previous except it transfers essentially the ship's angle of bank)

Is this useful, or would it be WAY to difficult to code in?
We already have ship-copy-damage.  These sexps you suggest would be not only useful, but just as easy and straightforward to add as ship-copy-damage.  I would imagine they could benefit a lot of situations not related to warping.

Remind me about these after the code freeze is over.  These would be high priority features.


Quote
I'd been pushing for an option in the ships (and wings) arrival and departure cues editor, which would include a "preserve warping motions" checkbox.  This would be greyed-out by default, until the "disable warp effect" checkbox is ticked.  The new checkbox would allow you to retain a ship's warping speed and accelleration/deceleration rate without having a warp vortex.  Then, if you want ships to appear to arrive or depart from the same group vortex, all you need to do is get them all to point the same direction (ie, head towards a distant waypoint) for departures, or simply place them properly for arrivals, use the "generate-warp-vortex sexp, and have all the ships warp without their own vortexes, but retaining the speeds and accel/decel rates, and presto... you have the desired effect.
Very interesting.  I hadn't thought about it quite like that before.  That might be worth investigating.
Title: Re: Transfering ship speed and facing
Post by: karajorma on September 15, 2008, 02:19:25 am
We already have ship-copy-damage.  These sexps you suggest would be not only useful, but just as easy and straightforward to add as ship-copy-damage.  I would imagine they could benefit a lot of situations not related to warping.

Remind me about these after the code freeze is over.  These would be high priority features.

To be honest I don't think they'd be as useful as get and set. I only use get-object-position together with the set SEXPs about half of the time. I find it just as useful for the explosion-effect, ship-create, weapon-create etc SEXPs.

Having get and set allows me to do stuff like having a ship appear in front of the player whatever he's looking at, etc.

Now if we were to have both those SEXPs and get and set I'd be happy. :)
Title: Re: Transfering ship speed and facing
Post by: Ace on September 16, 2008, 12:34:12 am
Awesome Goob :)

I'm with Kara on get and set being more powerful, but if for some reason ship-copy would be easier to implement it'd work for the purposes I'm thinking of.