Hard Light Productions Forums

Modding, Mission Design, and Coding => The FRED Workshop => Topic started by: HLD_Prophecy on May 12, 2017, 09:39:26 am

Title: Have a ship jump in facing the player?
Post by: HLD_Prophecy on May 12, 2017, 09:39:26 am
Hey all!

So in the second mission in Vassago's Dirge (counting the prelude) where you have to escort a Cretheus, Axem had
Spoiler:
the Vassago jump in from below the player, IIRC. Wherever the player was, the Vassago would jump in from below and facing you. Don't look down. :P Am I recalling correctly and is that what was going on?

I'd like to know how this was done. Any tips?
Title: Re: Have a ship jump in facing the player?
Post by: Axem on May 12, 2017, 10:17:05 am
No real magic there. Just luring the player to be in the right place at the right time. You could go off in a different direction and completely miss out on that.

That said there are a few arrival cue anchors that might be what you're looking for. One of them is 'In Front Of Ship' that will make the ship arrive some-what in front and facing the ship. Only works on the front vector though. Near Ship would just be a random vector around the ship, no way to restrict vectors. (And using set-object-position to alter the ship's position before it arrives doesn't work either).

Hope that helps in what you might be trying to accomplish!
Title: Re: Have a ship jump in facing the player?
Post by: JSRNerdo on May 12, 2017, 10:23:06 am
You can use some clever hacks with FRED set position and in-front-of-ship to get ships that warp in directly above/below/behind etc a ship. Set an invisible dummy ship's location to be, say, left of a ship, and SEXP it to directly face the player. Then have the Vassago warp in in-front-of-ship to the dummy ship, and the Vassago will arrive to the right of the player every time.
Title: Re: Have a ship jump in facing the player?
Post by: Axem on May 12, 2017, 10:27:29 am
Oh yeah, that'd probably work. Might need some tweaking and stuff to get it just right. In Front Of Ship isn't like, directly in front, but within some random cone or something. But yeah, you could adjust the entry angle like that.

*Hands FRED Crown to JSRNerdo*
Title: Re: Have a ship jump in facing the player?
Post by: HLD_Prophecy on May 12, 2017, 10:34:48 am
Hey, thanks for the tip guys!

Spoiler:
Funny, I was totally under the impression that you'd worked some arcane FRED magic. :P

So, just to be clear, in-front-of-ship will pick a random vector that's within the player's frontal view cone? So the incoming ship might sort of be facing the player, but slewed to one side?

Hmm.

What I really wanted was to make the incoming ship dead-on facing the player, but I'll work with what I've got.
Title: Re: Have a ship jump in facing the player?
Post by: General Battuta on May 12, 2017, 12:57:18 pm
As soon as the ship arrives, teleport it directly in front of the player, cloak it, spawn a fake warp effect, decloak it as it comes through. olololo
Title: Re: Have a ship jump in facing the player?
Post by: Mito [PL] on May 12, 2017, 04:03:43 pm
Or spawn the warp effect a tiny moment before the ship arrives, and teleport the vessel right away when it arrives (i suppose...).
Title: Re: Have a ship jump in facing the player?
Post by: Axem on May 12, 2017, 04:25:53 pm
Might work for fighters, but less so on larger ships (especially capital ships), unless you're going to mess around with set-ship-speed (it works on a per-frame basis, so you'd need 0 repeat delays).
Title: Re: Have a ship jump in facing the player?
Post by: HLD_Prophecy on May 13, 2017, 07:50:25 am
Might work for fighters, but less so on larger ships (especially capital ships), unless you're going to mess around with set-ship-speed (it works on a per-frame basis, so you'd need 0 repeat delays).

Yeah, we're talking about a capital ship here. Potentially a massive one. Why exactly wouldn't it work?

Still haven't tested "in-front-of-ship". Will report here when that's done.
Title: Re: Have a ship jump in facing the player?
Post by: Axem on May 13, 2017, 08:33:21 am
As soon as the ship arrives, teleport it directly in front of the player, cloak it, spawn a fake warp effect, decloak it as it comes through. olololo

Or spawn the warp effect a tiny moment before the ship arrives, and teleport the vessel right away when it arrives (i suppose...).

Actually I'm mistaken, this does work (you don't need to cloak or spawn the warp effect a tiny moment though). It's a little tricky, you'll need to spawn the warp effect basically at the nose of where the ship would be arriving and do your own warp duration and radius. The ship still does its transitional plane clip in, so the rear end of the ship won't appear suddenly. You just need to make its initial position far far away so you don't see that.
Title: Re: Have a ship jump in facing the player?
Post by: HLD_Prophecy on May 14, 2017, 04:35:06 pm
So I tried in-front-of-ship. It's permissible, I suppose, for what I want to do, although smack in front of the player every time would be better.

So, let me get this suggestion straight:

1. Make incoming ship arrive far away (no warp effect)
2. Spawn warp effect (now how do I make the effect spawn in front of the player :confused:)
3. Teleport incoming ship behind the warp effect (and how do I make it face the right way :confused:)

I'm not sure I want to go to all that work, though. I could just stick with in-front-of-ship.
Title: Re: Have a ship jump in facing the player?
Post by: Axem on May 14, 2017, 05:24:54 pm
It sounds like a lot of work, but it's not that bad. You've divided up the task in good manageable chunks. Just a few notes to help you get going.

1. If you select no warp effect, you won't get the high speed entrance, so it'd probably be quite anti-climatic. So just have your default position like... really far away or something.

2. I'd read up on this part (http://www.hard-light.net/wiki/index.php/Tutorial_-_In-Mission_Jumps#warp-effect_and_Relative_Coordinates) of a tutorial to understand how you can get a position of something directly in front or something else.

3. And as for moving and pointing, well there's sexps for that. :) (Coordinate manipulation category!!)
Title: Re: Have a ship jump in facing the player?
Post by: HLD_Prophecy on May 16, 2017, 04:15:50 pm

2. I'd read up on this part (http://www.hard-light.net/wiki/index.php/Tutorial_-_In-Mission_Jumps#warp-effect_and_Relative_Coordinates) of a tutorial to understand how you can get a position of something directly in front or something else.

3. And as for moving and pointing, well there's sexps for that. :) (Coordinate manipulation category!!)

2. Thanks! A bit much information to digest, but I get what I have to do.

3. So... set-object-facing-object?

But if that happens after the incoming ship has been teleported... won't the player see the ship pop in behind the warp effect before it turns to face them? Unless a 1-millisecond turn time negates that problem...
Title: Re: Have a ship jump in facing the player?
Post by: JSRNerdo on May 16, 2017, 05:27:06 pm
A turn time/move time  of 0 means it just sets the position/facing instantly
Title: Re: Have a ship jump in facing the player?
Post by: Axem on May 16, 2017, 05:30:01 pm
3. Yep, that's the sexp. If you just use it with the 2 parameters, it will face the object in a single frame.

So roughly how you would do it is, once the ship arrives is...

Make warp effect appear
Move ship so it is half a ship length "behind" the portal
Point ship at target

So in essence, you place the ship so that its nose its pretty much at where you create the portal. You'll probably need to do a bit of trail and error before you get it bang on, so try it out in a test mission before you try it in your real mission.
Title: Re: Have a ship jump in facing the player?
Post by: HLD_Prophecy on May 16, 2017, 06:14:25 pm
Right.

How do I teleport a ship again? I can't quite figure it out... I tried just creating a ship behind the warp effect, but I can't set-object-facing-object on a ship that "doesn't exist."
Title: Re: Have a ship jump in facing the player?
Post by: Axem on May 16, 2017, 06:29:56 pm
set-object-position let's you "teleport" a ship anywhere. Do the event with a has-arrived-delay with a 0 delay.
Title: Re: Have a ship jump in facing the player?
Post by: HLD_Prophecy on May 17, 2017, 12:05:21 pm
set-object-position let's you "teleport" a ship anywhere. Do the event with a has-arrived-delay with a 0 delay.

Right. Thanks!
Title: Re: Have a ship jump in facing the player?
Post by: wookieejedi on June 07, 2017, 02:04:54 pm
If you are still interested in responses I can show you what I have done for my missions. Currently I have my SEXPs set up so that multiple ships will warp in, all in the same orientation, but at semi-random locations. Could be scripted for right in front of the player like Axem mentioned, too.
Title: Re: Have a ship jump in facing the player?
Post by: xenocartographer on June 08, 2017, 08:09:59 am
I'd be interested.
Title: Re: Have a ship jump in facing the player?
Post by: wookieejedi on June 09, 2017, 03:18:28 pm
Cool. Though I should note that I am using the warp-out effect like in the Star Wars movies, not the glowing warp out effect FS2 uses by default. As such, you might have to swap out a few pieces and change the entry speed.

Here is the raw code. I also have two ships named "Enemy Ship 1" and "Enemy Ship 2". I also have waypoints named and placed, though the placement of these doesn't matter since the SEXP places them for me :) Also for both ships the 'no warp effect' box is checked.

Executive Summary of what these SEXPs do (more for someone who is not as experienced and just browsing this thread).

1. Places the enemy ships at the 'spawn' way point, which is very far away from the current battle.
2. Orients the ships towards the player (which in my case is a way point that updates to the player's location called 'Enemy Jump In-In Battle'), then randomly moves the ship so it will have a different x,y, and z position then the next incoming ship. Note the incoming ships will still have the same orientation. The SEXP does this one ship at a time using a when-argument.
^Steps 1 and 2 are done in a single frame.

3. Moves the ships to the battle really quickly to mimic a hyperspace exit.


You would probably just have to change step 3 to make a fake FS2 warp out effect.

I hope this is useful and I would be happy to further explain or send screenshots of the event editor! :)

Code: [Select]
$Formula: ( when-argument
   ( any-of
      "Enemy Ship 1"
      "Enemy Ship 2"
   )
   ( has-arrived-delay 0 "<argument>" )
   ( set-object-position
      "<argument>"
      ( get-object-x
         "Enemy Jump In-Spawn:1"
      )
      ( get-object-y
         "Enemy Jump In-Spawn:1"
      )
      ( get-object-z
         "Enemy Jump In-Spawn:1"
      )
   )
   ( set-object-facing-object
      "<argument>"
      "Enemy Jump In-In Battle:1"
      0
   )
   ( set-object-position
      "<argument>"
      ( +
         ( get-object-x "<argument>" )
         ( rand-multiple -2500 2500 )
      )
      ( +
         ( get-object-y "<argument>" )
         ( rand-multiple -2500 2500 )
      )
      ( +
         ( get-object-z "<argument>" )
         ( rand-multiple -2500 2500 )
      )
   )
   ( set-subsystem-strength
      "<argument>"
      "Simulated Hull"
      90
   )
   ( invalidate-argument "<argument>" )
)
+Name: Enemy Jump In - Start Enter
+Repeat Count: -1
+Trigger Count: 2
+Interval: 0

$Formula: ( when
   ( true )
   ( set-object-position
      "Enemy Jump In-Spawn:1"
      ( +
         ( get-object-x "Battle Center:1" )
         2000
      )
      ( +
         ( get-object-y "Battle Center:1" )
         0
      )
      ( +
         ( get-object-z "Battle Center:1" )
         25000
      )
   )
)
+Name: Enemy Jump In - Set Spawn
+Repeat Count: 1
+Interval: 1

$Formula: ( when-argument
   ( any-of
      "Enemy Ship 1"
      "Enemy Ship 2"
   )
   ( and
      ( <=
         ( distance
            "Enemy Ship 1"
            "Enemy Jump In-In Battle:1"
         )
         10000
      )
      ( = ( sim-hits-left "<argument>" ) 90 )
   )
   ( play-sound-from-file
      "exithyperspace.wav"
   )
   ( invalidate-argument "<argument>" )
)
+Name: Play Exit Sound
+Repeat Count: -1
+Trigger Count: 3
+Interval: 0

$Formula: ( when-argument
   ( any-of
      "Enemy Ship 1"
      "Enemy Ship 2"
   )
   ( and
      ( = ( sim-hits-left "<argument>" ) 90 )
      ( >=
         ( distance
            "<argument>"
            "Enemy Jump In-In Battle:1"
         )
         10000
      )
   )
   ( set-object-speed-z
      "<argument>"
      45000
      ( true )
   )
)
+Name: Enemy Jump In - End Enter
+Repeat Count: -1
+Trigger Count: 99999
+Interval: 0

Edit: Just noticed there is a repeat count of -1 for some reason on some events, not sure why since in FRED it says just "1" not "-1".
Title: Re: Have a ship jump in facing the player?
Post by: AdmiralRalwood on June 09, 2017, 03:39:35 pm
Edit: Just noticed there is a repeat count of -1 for some reason on some events, not sure why since in FRED it says just "1" not "-1".
Whenever a trigger count is specified and repeat count is left on the default of 1, FRED saves the mission with a repeat count of -1, meaning "infinite", because otherwise the event would still only trigger once (which would be counter-intuitive to most FREDers).
Title: Re: Have a ship jump in facing the player?
Post by: wookieejedi on June 09, 2017, 09:43:51 pm
Edit: Just noticed there is a repeat count of -1 for some reason on some events, not sure why since in FRED it says just "1" not "-1".
Whenever a trigger count is specified and repeat count is left on the default of 1, FRED saves the mission with a repeat count of -1, meaning "infinite", because otherwise the event would still only trigger once (which would be counter-intuitive to most FREDers).

Ah that makes sense. Thanks for clarifying! Just when I think I have FRED half-way understood haha