Hard Light Productions Forums
Modding, Mission Design, and Coding => The FRED Workshop => Topic started by: SF-Junky on November 25, 2012, 06:29:46 am
-
Hey there.
I have the following situation: The player must escort a vessel and is supposed to stay within 2500 meters. Now if the player moves away from said vessel more than 2500 meters AND another event (let's call it "free to go") has not tbeen triggered, I want the game to always send a single warning message. If the player doesn't return to a distance smaller than 2500 meters within 10 seconds, the end-mission SEXP shall be triggered.
How do I do that?
-
You'll probably need to use a variable with mission-time sexp. You shouldn't need every-time for this. Just a when with a high trigger count.
EDIT: Ok, now I've got time to sit and think about this. Here's probably what you want. (Note: not tested, just whipped up off the top of my head.)
Create a variable, I'm calling it TIMEVARIABLE here. Give it a really high numeric value.
when (high trigger count, delay=1)
-and
-->
---distance (alpha-escort)
---2500
--not
---is-event-true-delay
----free to go
--is-event-true-delay
---start escort
-send-random-message (or whatever you want to do)
--"Get back here in 10 seconds or the world ends!"
-set-variable
---TIMEVARIABLE = mission-time
when (high trigger count, delay=1)
-and
-->
---distance (alpha-escort)
---2500
--not
---is-event-true-delay
----free to go
--is-event-true-delay
---start escort
-->=
---mission-time
---TIMEVARIABLE + 10
-end-mission
I think that will do it... but I've got a splitting headache and I haven't tested it.
-
That's gonna send a 'get back here!' message every ten seconds, but that should be easy to prevent.
-
This is working. But Battuta is right, the message is sent every second. Guess I gonna need a third SEXP there.
-
Not at all. You'll just need to get a little fancy with this one. :) I've got to run to work but remind me to give you some pointers.
-
I already found a solution: I replaced the command message with a notification by the board computer (training msg) which makes sense to be displayed all the time. :p
-
That works. Personally, I think training messages are ugly and that learning is good. Bonus points if you can create a flashing HUD gauge instead. (Though you'll need a third SEXP to disable it when the player moves back within range.)
As for getting the event to not run continually (again, for learning), you could possibly use another variable to keep track of where you are in the event chain. Something like this, perhaps. Actually, this would still need a third event, so perhaps Battuta's solution is better.
TRACKVARIABLE = is innitialized to 0
when (high trigger count, delay=1)
-and
-->
---distance (alpha-escort)
---2500
--not
---is-event-true-delay
----free to go
--is-event-true-delay
---start escort
--==
---TRACKVARIABLE
---0
-send-random-message (or whatever you want to do)
--"Get back here in 10 seconds or the world ends!"
-set-variable
---TIMEVARIABLE = mission-time
-set-variable
---TRACKVARIABLE = 1
when (high trigger count, delay=1)
-and
-->
---distance (alpha-escort)
---2500
--==
---TRACKVARIABLE
---1
--not
---is-event-true-delay
----free to go
--is-event-true-delay
---start escort
-->=
---mission-time
---TIMEVARIABLE + 10
-end-mission
when (high trigger count, delay=1)
-and
--<
---distance (alpha-escort)
---2500
--not
---is-event-true-delay
----free to go
--is-event-true-delay
---start escort
--==
---TRACKVARIABLE
---1
-set-variable
---TRACKVARIABLE = 0