Hard Light Productions Forums

Modding, Mission Design, and Coding => The FRED Workshop => Topic started by: --Steve-O-- on October 01, 2007, 03:38:31 pm

Title: preventing arrival
Post by: --Steve-O-- on October 01, 2007, 03:38:31 pm
here's what i want to happen. the player has to destroy an awacs radar subsystem to prevent the arrival of a destroyer. i cant figure out the SEXPs to make this work though. i need some pointers.
Title: Re: preventing arrival
Post by: Dark Hunter on October 01, 2007, 04:05:47 pm
Maybe something like:

Events Editor:
Code: [Select]
Radar destroyed
       when
             is-subsystem-destroyed-delay      <------- That is an actual SEXP right?
                  AWACS
                     0
             true

Ships Editor:
Arrival Cue
Code: [Select]
is-event-false-delay
      radar destroyed
        0


That way, the destroyer will only arrive if the destruction of the radar is false (ie, the player failed to destroy the radar)
you'd probably want to put the "is-event-false-delay" into an "and" operator so that there's another trigger for the destroyer's arrival: like has-time-elapsed 60, so that the player has some time to blow up the subsystem before the computer immediately calls it "false" and sends in the destroyer.
Title: Re: preventing arrival
Post by: Shade on October 01, 2007, 04:11:15 pm
Actually you can just include the check for the non-destruction of the relevant subsystem in the destroyer's arrival cue instead of messing about with events. Something like this:

-op and
   -op not
      -op is-subsystem-destroyed-delay
         #Awacs
         #Radar
         #0
   -op Other conditions
Title: Re: preventing arrival
Post by: --Steve-O-- on October 01, 2007, 04:50:33 pm
dear god you guys make it look easy. you should have seen this mess i had involving events arrival cues and objectives and a hodge of SEXPs. i'll give that a try!
thanks!
Title: Re: preventing arrival
Post by: karajorma on October 01, 2007, 05:55:40 pm
That way, the destroyer will only arrive if the destruction of the radar is false (ie, the player failed to destroy the radar)

Although Shade posted the better solution you've pointed out a common misconception in the way the is-event-false-delay SEXP works so I really ought to cover this.

In the situation described your solution wouldn't work. is-event-false-delay would evaluate to false so the destroyer would never appear. The mistaken assumption is that is-event-false-delay is the exact opposite of is-event-true-delay. It isn't. There are times when both is-event-true and is-event-false will both return false.

Basically the game works like this. At t=0 every event is in the state event-incomplete. They will stay in that state the entire mission unless they come true or reach a state where they can never become true. It is only at this time that is-event-false will trigger.

In the example you given the event would remain incomplete until the AWACS jumped out or was destroyed (or the subsystem was destroyed of course :D ). Once the destroyer has gone the game will realise that the event can never trigger and will mark it false.

When the mission ends every single SEXP that hasn't triggered is marked false. So these rules don't apply to SEXPs in debriefings.
Title: Re: preventing arrival
Post by: TrashMan on October 02, 2007, 04:53:25 am
In other words (to make it easier for you) when using a NOT statement, ALLWAYS have a another AND condition wiht it..

EXAMPLE:

When
-AND
---has-arrived-delay
---- Alpha1
----300
---not
----is-subsystem-destroyed-delay
-----target ship
-----AWACS
-----0


What will happen is that after 300 seconds (when the destroyer is supposed to arrive) the game will check THEN if the AWACS is still in one peice. If both arguments return true, the destroyer will jump in.

If you just put in:
---not
----is-subsystem-destroyed-delay

It will return true immediately, since one the game starts the subsystems isn't destroyed yet, no? ;7
Title: Re: preventing arrival
Post by: karajorma on October 02, 2007, 05:06:18 am
Yep. That's another common mistake.

You don't always need to use AND but you should always check that the condition won't evaluate to true at the start of the mission because quite often it will.
Title: Re: preventing arrival
Post by: Black Wolf on October 02, 2007, 11:40:30 am
Heh. My initial reaction was "Use a variable!". I've gone full circle. I used to hate them with a passion, now I can't make missions without them :D.
Title: Re: preventing arrival
Post by: --Steve-O-- on October 11, 2007, 10:32:48 am
thanks for the know how guys...now that i have a little time, im going to tinker with all of this.