Adds a "firedNear" eventHandler to all civilians in mission to flee into a random nearby house and also play a random frightened animation. (Check example on how to make it work for spawned civilians)

VIDEO:   FEATURES: Supports a few maps by default:
-Zargabad Adding support for other maps is easy Civilians will flee into a random nearby house when they hear a gunshot Upon hearing the gunshot, civilians will play random frightened animation   TO DO LIST: Improve efficiency Add ArmA 1 maps from CUP:Terrains Delete civilian's waypoints before ordering them to move Possibly replace doMove with addWaypoint command   KNOWN BUGS: Sometimes the civilian can't get into the house Sometimes the civilian can walk through objects/structures Civilian may continue to next waypoint if he already has one, after running to a nearby house   INSTALLATION: NOTE: Demo mission requires CUP:Terrains & TalibanFighters, the script is standalone and does not require any scripts to use
  Copy & Paste "init.sqf" from demo mission to your mission, if you only want the civilians already placed in the mission to be effected Done! (OPTIONAL) If you want spawned civilians to be effected, do the following:
1-1. Also copy & paste this code into your "init.sqf", in addition to the rest of the above example: civFlee={_this select 0 addEventHandler["FiredNear",{ _civ=_this select 0;  switch(round(random 2))do{   case 0:{_civ switchMove "ApanPercMstpSnonWnonDnon_G01";_civ setSpeedMode "FULL";};   case 1:{_civ playMoveNow "ApanPknlMstpSnonWnonDnon_G01";_civ setSpeedMode "FULL";};   case 2:{_civ playMoveNow "ApanPpneMstpSnonWnonDnon_G01";_civ setSpeedMode "FULL";};   default{_civ playMoveNow "ApanPknlMstpSnonWnonDnon_G01";_civ setSpeedMode "FULL";};}; //nearestObjects[ PositionOrTarget, ["List","Of","Classnames","To","Look","For"], MaxDistanceToSearchAroundTarget ]; _nH=nearestObjects[_civ,nH_List,100]; _H=selectRandom _nH;//Pick an object found in the above nearestObjects array _HP=_H buildingPos -1;//Finds list of all available building positions in the selected building _HP=selectRandom _HP;//Picks a building position from the list of building positions _civ doMove _HP;//Orders the civilian to move to the building position //Remove the eventHandler to prevent spamming _civ removeAllEventHandlers "FiredNear";}];};
1-2. In your civ spawning script, right after the civ is created (Example: _unit=createVehicle["C_Man_01",_pos,[],0,""];) paste this after:   [_unit]call civFlee;
1-3. Done!   v0.1 (Jan 1, 2017)
DOWNLOAD LINK - (Google Drive) DOWNLOAD LINK - (Armaholic)

(2017.1.1) Initial Release