Hard Light Productions Forums

Modding, Mission Design, and Coding => The FRED Workshop => Topic started by: Starman01 on June 11, 2005, 01:41:50 pm

Title: Choosing/ignoring an event
Post by: Starman01 on June 11, 2005, 01:41:50 pm
Hello,

I have a small problem (again :) ) and honestly, I'm to lazy to figure it out in hours of painful trying (I always have to play 10 minutes before I reach the part where I need to test).

That's the situation :

I have a training exercise where the player is told to attack a bigger ship. He wins, when he reduces the enemies hitpoints to 95 %, but he looses when he has his own shield-strength reduced to more than 50%.

Player wins plays Event/Message A, Player looses plays Event/Message B.

Now my problem is, that I very often get the situation that I fire the enemy down to 95% and the winning-messages is played, and while that happens the last laserbolt that is still flying towards me, hit my shields and I "loose" ( because I reached the 50% shieldstrength in that very moment). It is interesting how often this happens (in either one way or the other).

So my question is, how can I script it in a simple way that once one condition is met, the other will be completly ignored ? I suppose it has something to do with the "not" condition (that's what Goober told me a while back), but sofar it isn't working the way I want it.

I would appreciate any advice :)

Starman©
Title: Choosing/ignoring an event
Post by: Hippo on June 11, 2005, 01:49:04 pm
have event one (the win one) be true ONLY if event 2 (the lose one) is incomplete. Then do the same for the other, but swapped. That way, only one can possibly become true.
Title: Choosing/ignoring an event
Post by: TopAce on June 11, 2005, 01:49:46 pm
and
-[event]
-not
--is-event-true
---[event2]
Title: Choosing/ignoring an event
Post by: Hippo on June 11, 2005, 01:59:46 pm
that won't work, because its incomplete untill it is true or false, which will trigger immediately...
use:

Code: [Select]

Win event:
and
-[win condition]
-is-event-incomplete
--[lose event]

Lose event:
and
-[lose condition]
-is-event-incomplete
--[win event]
Title: Choosing/ignoring an event
Post by: karajorma on June 11, 2005, 02:22:42 pm
An incomplete event would register as not being true but it still has to wait for the other trigger SEXP to occur so TopAce's suggestion should work.

I prefer the way Hippo did it though (In fact I gave out an almost identical solution to a different problem yesterday).

But it does have an inherent danger in it though which you should watch out for.

If you do
Code: [Select]
Win event:
and
-[win condition]
-is-event-incomplete
--[lose event]

Lose event:
and
-[lose condition]
-is-event-incomplete
--[win event]


Then you have to be careful that neither event can ever be false. If that happens then neither event can come true (This may be exactly what you want though).

You should be fine using it here but if the events depend on a  certain ship being alive in one case and not in the other then you have an inherent danger in the fact that the destruction of the ship would prevent both events from working.

TopAce's suggestion doesn't carry the same danger.
Title: Choosing/ignoring an event
Post by: Hippo on June 11, 2005, 02:31:07 pm
*re reads*

Hm... I read TopAce's one wrong the first time :p... Mine won't work though, if theres a way for either event to become false...

EDIT: Heh... Nice edit timing kara... ;)
Title: Choosing/ignoring an event
Post by: karajorma on June 11, 2005, 02:34:56 pm
Yeah. :) And then I made a second edit and made it look I edited it after you :D
Title: Choosing/ignoring an event
Post by: Goober5000 on June 11, 2005, 02:55:18 pm
TopAce's solution is best.  It covers all possibilities. :)
Title: Choosing/ignoring an event
Post by: Hippo on June 11, 2005, 02:58:19 pm
Well, either works, thugh they both behave slightly differently, so it depends on what the nescessity is. :nod:
Title: Choosing/ignoring an event
Post by: Starman01 on June 11, 2005, 03:25:27 pm
Hm, thanks for the comments guys, but I'm still not sure I got it (maybe it's already to late for me :) ) I have to write that a little more detailed.

1) Event (Victory)

true
___hitpoints left
___corvette
___95


2) Event (loose)

true
__shield quad low
__alpha 1
__50

( I made a "corvette invincible" in this event before, two avoid the error at least in one way)

3) New Event (according to Topace's suggestion)

and
-[Event(Victory)]
-not
--is-event-true
---[Event(loose)]
------send message
------Message 1 (Victory)

4) Another new Event according to Topace, but this time for the opposite effect

and
-[Event(loose)]
-not
--is-event-true
---[Event(victory)]
------send message
------Message 2 (loose)


Is that the way you want to explain here ? (Btw, there is not a danger of the corvette getting destroyed, so if that's any problem...)
Title: Choosing/ignoring an event
Post by: karajorma on June 11, 2005, 05:18:39 pm
No need to have 4 events. You can do this in 2.

Victory
-when
--and
---hitpoints left
----corvette
----95
---not
----is-event-true-delay
----lose
----0

and


Lose
-when
--and
---Shield quad low
----alpha 1
----50
---not
----is-event-true-delay
----Victory
----0
Title: Choosing/ignoring an event
Post by: Hippo on June 11, 2005, 05:36:06 pm
you know... not that its hard or anything, but i just realised that its even easier to build the event in fred, and copy it from the file... (easier as in, you're not going to forget a part of the event (like a number))... Meh... :p
Title: Choosing/ignoring an event
Post by: Starman01 on June 12, 2005, 01:49:31 pm
O.K, now I did it this way :

(http://www.starman.ag5.de/pics/fred5.jpg)

I have to test it now of course, I hope I can reproduce the situation where both actions (win and loose) come true the same time, that's not so easy.

However, I still don't see why this kind of event will prevent the second event from executing just by using the "not" command. Is it really prevented for all time then? What happens when the flying laserbolt hit me 1 second after the win-event is true, and I loose. Must they be chained or something ?
Title: Choosing/ignoring an event
Post by: Goober5000 on June 12, 2005, 03:32:36 pm
It's really prevented.  There's absolutely no way both events can come true.

They shouldn't be chained... chaining makes it not work.
Title: Choosing/ignoring an event
Post by: Starman01 on June 12, 2005, 03:36:20 pm
o.K. Btw, sofar the test-results look good too. :)

Thanks again for your help friends.
Title: Choosing/ignoring an event
Post by: karajorma on June 12, 2005, 03:49:25 pm
Quote
Originally posted by Starman01
However, I still don't see why this kind of event will prevent the second event from executing just by using the "not" command. Is it really prevented for all time then? What happens when the flying laserbolt hit me 1 second after the win-event is true, and I loose. Must they be chained or something ?


The game is only ever checking one event at a time. As soon as one of those two events becomes true the other one never can.

If both events come true in precisely the same millisecond then it is possible that either one can play but even then only one of them will occur because when the computer then tries to evaluate the second one it will find that it no longer evaluates to true.

The game checks the list of SEXPs more than 20-30 times a second though so even that is an unlikely possibility.
Title: Choosing/ignoring an event
Post by: Hippo on June 12, 2005, 03:53:09 pm
unless they were triggered by the same thing...
Title: Choosing/ignoring an event
Post by: karajorma on June 12, 2005, 03:58:18 pm
I've never actually run a test to see which event would trigger first if two events have the same trigger. :) If I get bored later I might give it a try :)

I suspect that you would always see the first one on the list trigger but it depends on how the game processes the events list.