Jump to content
Sign in to follow this  
keimosabe

proper syntax to check to see if several people are alive...

Recommended Posts

In my mission, I have a large city where the players are going into to kill bad guys, but they have to be careful not to kill civilians. I cannot find a script that checks for CIVILIANS being killed so I have decided to just name a bunch of them and then have a trigger check to see if the named ones are alive.

I know how to code the "!alive" for a single entity, but how would you script that to check for SEVERAL entities being alive?

Can you even do that with a single trigger of will I have to make a seperate trigger for each one?

Lastly, is there a piece of code that if the above trigger's condition is met, in the ON ACTivation block, I can make the offending player LOSE a life (using Norrin's revive script) or if that is not possible, just KILL him?

As usual thanks in advance guys.:rolleyes:

Share this post


Link to post
Share on other sites

Well, the easiest way would be to add a killed eventhandler to each civilian, which "kills" the player each time he kills a civilian.

Put a big trigger covering all civilians, activated by civilian side, once, with the following line in the on activation line :

{_x addeventhandler ["killed", "(_this select 1) setdammage 1"]} foreach thislist

To answer your question about the "not alive" checked on several units, it's easy with the "count" command. For example :

{alive _x} count [civilian1,civilian2,civilian3] < 3

will check if one or more of the three civilian is dead.

Share this post


Link to post
Share on other sites

ahhhhhh, excellent man. Thanks alot. I'm assuming that the names in your second code "civilian1, civilian2...etc" are just the NAMES you are assigning to each civilian and I could replace that with whatever names I am using for them correct?

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×