Hard Light Productions Forums

Modding, Mission Design, and Coding => The FRED Workshop => Topic started by: ReeNoiP on June 27, 2009, 12:07:00 pm

Title: More sexp trouble
Post by: ReeNoiP on June 27, 2009, 12:07:00 pm
I am trying to script the following: When the player enters a jumpnode he gets a training message telling him he is in range. The player now has the option to press 1 which will immobilize his ship for 20 sec (a directive with help text should explain this). If the player leaves the node without pressing 1, the training message should reappear once he reenter the node, but if he pressed one it should not appear again.

What I have tried is using three events.
event 1 repeat 999999
when
 -and
 --is event incomplete event 2
 --<
 ---distance alpha 1- waypoint 1
 ---300
 -training message

event 2 chained to event 1 and contains the directive
when
 -key pressed
 --1
 -player use ai
 -ad goal
 --ai play dead - Alpha 1

event 3 chained to event 2
when
-is event true delay
 --event 2
 --20
-player not use ai
-training msg

The message telling me I am in the right place appear as it should, and when I press 1 the directive becomes complete. The ai never takes over (or it is for such a short while that I is not noticed), and I get the message from the last event. After this the message from event 1 still appear when I am in the node.

It seems like the 20 sec. delay is not working and event 2 is not marked as complete, but I can't figure out why.
Title: Re: More sexp trouble
Post by: karajorma on June 27, 2009, 12:18:28 pm
I don't have time for a full answer but the solution to this is to use variables rather than checking the state of events or using chains. You should never make a chained event repeat unless you know exactly what you are expecting it to do, cause the behaviour is rather unexpected.
Title: Re: More sexp trouble
Post by: ReeNoiP on July 08, 2009, 08:32:19 am
Thanks for the tip of using variables. I got it working now, and the method solved a number of other problems I was having. The only thing I could not fix, was that the play dead sexp activates as soon as the player gets within range if he presses 1 before entering the node. Of cause this come from the key-pressed condition being true, but I don't really see a way around it.
Title: Re: More sexp trouble
Post by: General Battuta on July 08, 2009, 08:48:06 am
Use key-reset right before the player enters range?