Fire Detection – Undercover Team

Militantsausage on the BIS forums wanted a method of detecting if under cover units fired their weapons or left an area.

Here’s a demo mission. Try driving out of the compound; shooting someone; having your AI shoot someone; having an AI walk out of the compound.

Three triggers are needed.  The group is named uct.

First trigger covers the compound, Anybody Present Repeatedly, named compound.


{vehicle _x in thislist} count units uct < count units uct

No onAct needed.

Second trigger, no size or settings.


triggerActivated compound


{_x setCaptive false;} forEach units uct;

Third trigger just assigns the eventHandlers, this could do in an init or init.sqf or wherever really.




{_x addEventHandler ["fired", "{_x setCaptive false;} forEach units uct;"]} forEach units uct;

That’s what checks if any of your guys fired and drops their captive state if they do.

  1. #1 by Katdog5 on September 17, 2010 - 5:47 PM

    Fantastic. Testing has been a blast with this.

  2. #2 by Sabre=TE= on October 5, 2010 - 8:56 AM

    I want to use a version of this where my undercover squad are setCaptive true so they aren’t detected until a helicopter is blown up at which point I want them to be setCaptive false. How would I amend it would I just change “fired” to “! Alive hel” or something similar? Would that work?

    • #3 by kylania on October 5, 2010 - 10:55 AM

      Did you want them able to fire without being detected? The easiest way to do what you want is to change the “triggerActivated compound” condition to “!alive hel”.

      That way you keep the “if they fire they get detected” aspect, and you don’t have to change much code to get the effect you’re after. Only thing you lose is the trigger for when you leave the area, but sounds like you don’t need that.

      • #4 by Sabre=TE= on October 5, 2010 - 4:17 PM

        Thanks again sounds just what I want I’ll give it a go. Appreciate your help, cheers.

      • #5 by Sabre=TE= on October 6, 2010 - 8:38 AM

        Tried this last night and it works a charm so thanks again. If I can impose on you a little more I’m trying to develop my mission slightly further around these scripts. Can I use the first script on a couple of different compounds?

        I’m trying to set up the mission where the undercover team have to blow up the heli (which works) but I’d like to set up a couple of areas nearby where if the undercover team enter them the setCaptive status changes. Can I just change the first trigger to be blufor present and if I wanted multiple areas would I have to make multiple triggers but say names compound1, compound 2 etc

        Sorry if this doesn’t make sense and apologies for all the questions.

        • #6 by Shinobi_EBDA on December 17, 2010 - 9:09 AM

          As long as your units are on “setCaptive true”, they won’t trigger any Blufor Present triggers.
          If you create the trigger in the editor, then group it with your unit (F2 drag a line between them), then you can get the trigger to react only to that unit or any members of his group and so on.

          Hope that helps!

  3. #7 by REN on October 29, 2010 - 8:27 PM

    i tryed this with my mission but i lose all my task for the mission what can i do to get the task to show up wile captured mode

  4. #8 by WallyJas on November 3, 2010 - 11:17 PM

    Hey Ky,

    What about if I run one of the enemy soldiers over with a car (or I guess just kill them in any other way other than firing at them) can we add a trigger that takes that into account?

    • #9 by kylania on November 23, 2010 - 6:11 PM

      I’m not sure how to detect if an AI is killed by a vehicle running them over actually. I guess you could test for an unknown death then see if the player is in a vehicle nearby or something. Probably better to just test if anyone dies then the players are revealed to keep it simple. 🙂

  5. #10 by Shinobi_EBDA on November 23, 2010 - 7:57 AM

    I love the event handler script, but I’m having a slight problem with it. Not really a biggy, but I’m trying to make it more realistic.

    The problem is, that with this event handler active, your character can fire his gun in the middle of nowhere, and then when he approaches an enemy on the other side of the map his captive status is already false – even though that enemy would never have heard him fire his weapon. Basically, if you make a larger mission where the players have to get to the target before doing anything else, and they accidently discharge their weapon in base, the mission is screwed.

    I’ve been trying to figure this out, and also get some help figuring it out, but can’t get it to work so that they only lose their captive status if they are close enough to an enemy for it to seem plausible.
    Any ideas?

    • #11 by kylania on November 23, 2010 - 6:11 PM

      Best way would be to just not create the triggers until the players are in the area/situation where you wanted to check for that.

      • #12 by Shinobi_EBDA on November 30, 2010 - 8:10 AM

        So that would be using the createTrigger command?
        I’m not very good with scripting… ^^

  6. #13 by Shinobi_EBDA on December 17, 2010 - 9:06 AM

    Ok, so I’ve used the createTrigger command to create and event handler after my units reach a certain area.

    I now have another question, that I’m finding hard to understand from the Biki.

    Is it possible to set the “fired” event handler to only change the units’ status if they fire with a certain weapon? ie, if they fire their suppressed pistols, they remain captive, but if they fire their unsuppressed rifles, they become non-captives?

Comments are closed.