OFPEC Forum

Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: Mad Monk on 23 Jan 2005, 01:13:35

Title: Specific Unit Death
Post by: Mad Monk on 23 Jan 2005, 01:13:35
Hello,

I'm making a semi-living military base. Whenever you walk by the soldiers guarding the Majors office, they salute to you and then return to being at attention. Unfortunately, when you kill them they die but continue to remain at attention. I know that if I use switchmove "null" then they will die, but I don't know how to tell the trigger that they are dead. Can I say something like "guard1's health is zero so activate trigger stop salute"? Also, how do I make a trigger initialize by default in the beginning of the game?

I've never used scripts before, so if I need a script to do this could you explain a little bit about how to execute and use scripts?

Thanks a lot,

Mad Monk


Title: Re:Specific Unit Death
Post by: macguba on 23 Jan 2005, 01:21:16
1)  To make a trigger fire when the mission starts:

Condition:   true

Except as a rule don't bother, just put the line of code you want executed in your init.sqs.


2)   Trigger
Condition:   not alive loon1
On Activation:   loon1 switchMove "null"

Alternatively, group the trigger to the unit to get new options in the Activation box.


3)   If the number of units in question is relatively small, then doing it like this will triggers will be fine.   If it is large, then a script might be better.     The time honoured way to learn scripting is to read snYpir's A Friendly Intro to Code Snippets;  Johan Gustafsson's Scripting Guide and both the online and unofficial versions of the command reference.     There are simple working scripts in the Tutorial Mission.    All in the Ed Depot.


Syntax not guaranteed.   Oh, and

Welcome to the forum!

Title: Re:Specific Unit Death
Post by: Mad Monk on 23 Jan 2005, 03:09:51
Thanks for the help!

One last question...

So now I have soldiers that salute when I near them and go back to attention when I am far away, but if I kill them and then return to the trigger activation zone they pop back into attention despite that they're dead. Is there a command to turn off or disable a trigger after a different trigger has been activated?

Title: Re:Specific Unit Death
Post by: Homefry31464 on 23 Jan 2005, 04:39:52
Make the condition in the saluting trigger a variable, in this example we shall call the variable variablename.  In the init.sqs file, put:

variablename = true

In the other trigger (the one detecting the guard's death), also place in the activation line (seperated with an ;):
variablename = false

Obviously, change variablename to whatever you wish...

Hope this helps.
Title: Re:Specific Unit Death
Post by: Mad Monk on 23 Jan 2005, 07:05:08
Is there anyway to set a trigger to false or delete a trigger in an on activation line?
Title: Re:Specific Unit Death
Post by: Mad Monk on 23 Jan 2005, 09:13:21
I figured out an easy way to delete triggers. You can delete them with the deletevehicle command. Thanks for everyones replies!
Title: Re:Specific Unit Death
Post by: THobson on 23 Jan 2005, 12:01:46
On how they behave when they are dead if there are a lot of them you might find it better to give each of them a "killed" event handler rather than a trigger.   Triggers use comuting power.