Hard Light Productions Forums
Modding, Mission Design, and Coding => The FRED Workshop => Topic started by: killface on April 05, 2009, 08:04:33 pm
-
Hey all,
So I'm trying to create a mission where an event occurs each time you make a kill. Is there any SEXP or a SEXP method for evaluating the player's number of kills, and then acting each time that number increases by one?
Thanks
killface
-
I guess another way to ask this question is, is there any to link a variable to the number of player kills? Or perhaps is there any such variable already in existence?
-
Yes there is a sexp for this in 3.6.10. num-kills. It's in status. Just make a repeating event that stores the value to a variable and fires again when it increases.
-
Sounds good, but what is "triggering" the repeated event? Each new kill? What sexp do I use to make that happen? I guess I'm looking for an example.
-
Nevermind, think I got it...
[attachment deleted by evil Tolwyn]
-
Looks like you do but every-time might be a bit much. Go with when and the repeat 9999999 and a delay of 1. Should be more then enough.
-
I've always had a problem distinguishing between when to use every-time and when to use when + the 99999 repeat. What is the exact difference?
-
Every-time only needs to be used in special circumstances. A repeating when is usually the way to go even if you have to do a 0 for the delay. It's less to process for one thing and unlike a repeating when it will never be true or false. I'm sure Kara will chime in with more detailed reasons.
-
The difference between every-time and when relates to SEXPs that evaluate internally to SEXP_ALWAYS_TRUE, SEXP_ALWAYS_FALSE or SEXP_NAN_FOREVER (NAN = Not A Number).
Suppose I have a mission like this.
Event 1
when (high repeat count, delay 0)
- <
--Distance
---Alpha 1
---Cancer 1
-do something
Event 2
when
-something
-self-destruct
--Cancer 1
Event 3
when
-something else
-ship-create
--Cancer 1
Using the when SEXP event 1 will trigger until event 2 becomes true. At this point the Distance SEXP will be marked NAN_FOREVER (Cancer 1 is dead so FS2 thinks that there is no point in ever checking that SEXP again) Problem is when you respawn Cancer 1 using the ship-create SEXP you may want the distance check to work again. But it never will because the game has marked the SEXP as impossible.
Every-time doesn't mark the distance SEXP in this way. Next time the SEXP is called Distance will be evaluated again.
-
It's worth noting that spawning a new ship with the same name as an old one carries its own set of problems... ;)