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

From FreeSpace Wiki
Jump to: navigation, search
(clarification)
m (Related links)
 
(5 intermediate revisions by 3 users not shown)
Line 1: Line 1:
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:
+
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 allow 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.
 
Make a variable called Mission_Time and initialize it to 0, then set up the events as follows.
  
Stealth Event:
+
'''Stealth Event:'''
  
  -op every-time-argument
+
  - <span style="color:red">op</span> every-time-argument
  -op any-of
+
    - <span style="color:red">op</span> any-of
    - <list of ships to be regularly untargeted>
+
        # <list of ships to be regularly untargeted>
  - op targeted
+
    - <span style="color:red">op</span> targeted
    - <argument>
+
        # <argument>
    - 2
+
        # 2
  - op ship-stealthy
+
    - <span style="color:red">op</span> ship-stealthy
    - <argument>
+
        # <argument>
  - op modify-variable
+
    - <span style="color:red">op</span> modify-variable
    - Mission_Time(0)
+
        <span style="color:red">#</span> Mission_Time(0)
    - op mission-time
+
        <span style="color:red">op</span> mission-time
  
  
Unstealth Event:
+
'''Unstealth Event:'''
  
  -op every-time-argument
+
  - <span style="color:red">op</span> every-time-argument
  -op any-of
+
    - <span style="color:red">op</span> any-of
    - <list of ships to be regularly untargeted>
+
        # <list of ships to be regularly untargeted>
  - op and
+
    - <span style="color:red">op</span> and
    - op is-ship-stealthy
+
      - <span style="color:red">op</span> is-ship-stealthy
      - <argument>
+
            # <argument>
    - op <
+
      - <span style="color:red">op</span> <
      - op +
+
          - <span style="color:red">op</span> +
        - Mission_Time(0)
+
              <span style="color:red">#</span> Mission_Time(0)
        - 2
+
              # 2
      - op mission-time
+
          - <span style="color:red">op</span> mission-time
  - op ship-unstealthy
+
    - <span style="color:red">op</span> ship-unstealthy
    - <argument>
+
        # <argument>
  
 
And here's how it works:
 
And here's how it works:
Line 43: Line 43:
  
 
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.
 
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.
 +
 +
==See also==
 +
*[[FreeSpace 2 Tactical#Stealth Missions|Stealth missions]]
 +
*[[Sensor degradation with range or facing|Stealth degradation]]
 +
  
 
[[Category:FRED Examples]]
 
[[Category:FRED Examples]]

Latest revision as of 16:47, 3 October 2011

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 allow 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.

See also