Hi,
Have you ever wanted to have this logical ingredient in an "undercover" (setCaptive) mission?
You are undercover, but if you start shooting your cover is blown, you can solve that with a simple:
Eventhandler "fired", where _this select 0 setCaptive false.
But what if you fire your weapon inside a deep forest miles away from anyone and 1 hour later enter enemy positions. They then start firing at you, even though they could not possibly know that you had fired your weapon.
My solution also naturally takes into account if you are using silenced weapons, as you will then less likely be detected when firing.
EDIT: You can now set the wanted SIDES, GROUPS or UNITNAMES that you want to be possible spotters.
Still wondering if the radius check could (should) be dynamic.
I think this is the solution:
init.sqf// Set the array parameters to include any side, group or unit, that can spot the firing unit. EXAMPLE: [EAST,RESISTANCE,group3,guy5].
LAGGY_firespotters = [EAST];
Eventhandler "fired"_shooter = _this select 0;
_spotters = nearestObjects [vehicle _shooter, ["AllVehicles"], 50];
sleep 5;
if (count _spotters > 1) then
{
{
if ((side _x in LAGGY_firespotters OR group _x in LAGGY_firespotters OR _x in LAGGY_firespotters) AND (_x knowsAbout _shooter > 0.5) AND (alive _x)) then
{
_shooter setCaptive false; _x doFire _shooter;
};
};
} forEach _spotters;
The "_x doFire _shooter;" is optional, but since ArmA is quite unpredictable regarding how AI sees you at night, I would add that line if the mission is set at night. During day it is not needed at all.
The "sleep 5;" is also optional, but if you kill a small group quickly, they shouldn't be able to "report" that you are an "enemy".
Mission Example included
Edit: attachment lost in crash of November 2009; re-upped in last post - WEK