Author Topic: Have a ship jump in facing the player?  (Read 2604 times)

0 Members and 1 Guest are viewing this topic.

Offline wookieejedi

  • 29
  • Intensify Forward Firepower
Re: Have a ship jump in facing the player?
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".
« Last Edit: June 09, 2017, 03:24:37 pm by wookieejedi »

 

Offline AdmiralRalwood

  • 211
  • The Cthulhu programmer himself!
    • Skype
    • Steam
    • Twitter
Re: Have a ship jump in facing the player?
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).
Ph'nglui mglw'nafh Codethulhu GitHub wgah'nagl fhtagn.

schrödinbug (noun) - a bug that manifests itself in running software after a programmer notices that the code should never have worked in the first place.

When you gaze long into BMPMAN, BMPMAN also gazes into you.

"I am one of the best FREDders on Earth" -General Battuta

<Aesaar> literary criticism is vladimir putin

<MageKing17> "There's probably a reason the code is the way it is" is a very dangerous line of thought. :P
<MageKing17> Because the "reason" often turns out to be "nobody noticed it was wrong".
(the very next day)
<MageKing17> this ****ing code did it to me again
<MageKing17> "That doesn't really make sense to me, but I'll assume it was being done for a reason."
<MageKing17> **** ME
<MageKing17> THE REASON IS PEOPLE ARE STUPID
<MageKing17> ESPECIALLY ME

<MageKing17> God damn, I do not understand how this is breaking.
<MageKing17> Everything points to "this should work fine", and yet it's clearly not working.
<MjnMixael> 2 hours later... "God damn, how did this ever work at all?!"
(...)
<MageKing17> so
<MageKing17> more than two hours
<MageKing17> but once again we have reached the inevitable conclusion
<MageKing17> How did this code ever work in the first place!?

<@The_E> Welcome to OpenGL, where standards compliance is optional, and error reporting inconsistent

<MageKing17> It was all working perfectly until I actually tried it on an actual mission.

<IronWorks> I am useful for FSO stuff again. This is a red-letter day!
* z64555 erases "Thursday" and rewrites it in red ink

<MageKing17> TIL the entire homing code is held up by shoestrings and duct tape, basically.

 

Offline wookieejedi

  • 29
  • Intensify Forward Firepower
Re: Have a ship jump in facing the player?
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