Difference between revisions of "Stealthing ships to force target loss"

From FreeSpace Wiki
Jump to: navigation, search
(new page)
 
(clarification)
Line 41: Line 41:
  
 
In the second event, you will notice there are several conditions for it to occur, both the <tt>is-ship-stealthy</tt> check against the argument list, and a check against Mission_Time + 2 being less than the current mission time. This last one is important, as stealthing and unstealthing a ship ''in the same frame'' will not make the player lose that target. There has to be a small delay between stealthing and unstealthing for it to work. Finally, we make the stealthed ship unstealthy again so the player can reacquire it if needed, in which case the whole process will repeat.
 
In the second event, you will notice there are several conditions for it to occur, both the <tt>is-ship-stealthy</tt> check against the argument list, and a check against Mission_Time + 2 being less than the current mission time. This last one is important, as stealthing and unstealthing a ship ''in the same frame'' will not make the player lose that target. There has to be a small delay between stealthing and unstealthing for it to work. Finally, we make the stealthed ship unstealthy again so the player can reacquire it if needed, in which case the whole process will repeat.
 +
 +
Note that we do not invalidate arguments after they have been used, as otherwise this process could only happen once per ship. Whereas we want it to happen every time a ship on the argument list is targeted, even if it is the same one twice.
  
 
[[Category:FRED Examples]]
 
[[Category:FRED Examples]]

Revision as of 19:38, 27 April 2006

Stealth can be used for more than as just a simple state for a ship to be in when you want it untargetable. As it can be toggled in-mission through sexps, one example of a different use is to force the player to lose his target at regular intervals but still aloow it to be reacquired, similar to EMP storms but without all the other effects. Here's how to do it:

Make a variable called Mission_Time and initialize it to 0, then set up the events as follows.

Stealth Event:

-op every-time-argument
  -op any-of
    - <list of ships to be regularly untargeted>
  - op targeted
    - <argument>
    - 2
  - op ship-stealthy
    - <argument>
  - op modify-variable
    - Mission_Time(0)
    - op mission-time


Unstealth Event:

-op every-time-argument
  -op any-of
    - <list of ships to be regularly untargeted>
  - op and
    - op is-ship-stealthy
      - <argument>
    - op <
      - op +
        - Mission_Time(0)
        - 2
      - op mission-time
  - op ship-unstealthy
    - <argument>

And here's how it works:

Using the every-time-argument/any-of combination of SEXPs allows us to apply the event to a whole list of ships instead of just one, and allows it to repeat itself indefinitely as long as the condition is true. We also set up a variable called Mission_Time, which I will get to in a moment.

In the first event, we use the training SEXP targeted to check whether a ship in the argument list is targeted by the player, with a small delay so he/she can at least turn towards it before losing the target again, and make that ship stealthy once the delay has passed. Finally, the last thing we do in this event is to set the Mission_Time variable to the current mission time. We have to do this to be able to time the second event as there is no is-ship-stealthy-delay status SEXP, just is-ship-stealthy.

In the second event, you will notice there are several conditions for it to occur, both the is-ship-stealthy check against the argument list, and a check against Mission_Time + 2 being less than the current mission time. This last one is important, as stealthing and unstealthing a ship in the same frame will not make the player lose that target. There has to be a small delay between stealthing and unstealthing for it to work. Finally, we make the stealthed ship unstealthy again so the player can reacquire it if needed, in which case the whole process will repeat.

Note that we do not invalidate arguments after they have been used, as otherwise this process could only happen once per ship. Whereas we want it to happen every time a ship on the argument list is targeted, even if it is the same one twice.