Tutorial - Directive-value SEXP
Note: This tutorial was written for the directive-is-variable sexp. Both sexps pretty much do the same thing, but directive-value lets you directly plug in any number that can be returned. This tutorial still applies and the writer would like to not have to retake so many pictures!
Have you ever had one of those days?
One of those days where you want to disable some beam cannons on a ship, and you want a number by the directive to show the player how many are left?
Yeah, we've all had bad days. Maybe not as bad as this guys. But still bad.
Well never fear, new additions to the SCP will allow you to turn this can-don't, into can-probably-do!
The OLD and BUSTED way
If you wanted to keep track of how many beam cannons are left, you'd probably go about by using the is-destroyed-delay sexp and a bunch of dummy objects.
This is from mission 2 from Vassago's Dirge. Basically I set up these containers what would self destruct if you destroyed the right turret (or the ship). Then the actual directive is depending if you destroyed the containers, which you kind of do indirectly.
This can be a little complicated and convoluted at times, but do not fear. There is a better way!
The NEW and HOTNESS way
Oh noes! The Arcadia installation... Smarcadia has fallen under attack by the Ravana-class destroyer the... Smassago... And only Alpha 1 is on scene with 5 trebs! What will you do?!
Kill the beam turrets of course. Has Blue Planet taught you NOTHING?! First lets set it up.
Pretty simple initial event setup. Okay, let's make a directive for killing the beam turrets.
Oh right, that number doesn't show up. And I'm supposed to be showing you a way to make the number appear...
Let's make a variable. Call it SmassagoBeamsLeft and set the initial value to 4. (As it has 4 beam cannons)
Next make a new event, Track Smassago Beams. Set up the event like below. Trigger count for 4. (As we have 4 beam cannons) You would fill the argument list with names of turrets that are beam cannons.
Simply, when any of the specified turrets are destroyed, we decrease SmassagoBeamsLeft by one, then we remove that turret from consideration. Because we don't want to count a destroy turret twice of course!
Now we go back up to Destroy Beam Turrets and tack on this magical sexp.
directive-value always returns true, so to use it you would have "and (your normal conditions) (directive-value variable(X))"
Let's see this in game.
Want to see some more fun we can have with this?
I'm going to assume you said yes. If you said no, close your browser right now!
The variable doesn't just have to go down. It can go up too! Or be updated every second! Here's some quick uses for it.
General Destroy/Protect Directives
If you ever had a lot of fighters to kill in a mission, you might have tried to stick them all in a general "Destroy Fighters" directive. Well if you tried that you would have noticed that the directive only actually appears after all the fighters have arrived. Bummer.
But we can change that behavior with this!
Note that we're using destroyed-or-departed-delay, since using is-destroyed-delay will hold the effect of not showing the directive until all wings are present.
So now you could have Aquarius and Gemini arrive first, and then Leo, Cancer and Virgo afterwards and you could use the same directive for everything! When new fighters pop in, the number goes up!
The only caveat is that the directive will appear right away, even if no one is there. So chain your directives correctly. Also if there are no fighters around, the directive won't complete, it just won't have a number.
Let's see it in action!
You can also use this for protect directives. Just don't use has-departed-delay or else the directive will fail as soon as someone dies and the number will vanish. Instead, we can do this...
This directive will only complete when Omega 1, 2 and 3 have either been destroyed or have left, and atleast 1 of them has left the mission. So you can lose 2 and still complete the directive. You can adjust the percent-ships-destroyed to your own desires.
We don't even need to tie this to ships you know! We can make it into a timer!
Complete all the directives before time is out! Note the extra true on the is-event-true-delay. This allows that sexp to directly be used in a directive.
Well that's all for tonight sports fans. Have fun and explore the other things you can do with this sexp!