Ice_Rhino 3 Posted September 30, 2014 Hi All, Me again with my next stupid question(s). I have a number of civilians placed on my map that walk random paths. Also in my mission I have a number of OPFOR also walking on random paths within the same town. What I want to do is, when a civilian is near gun fire, or within a certain range of a dead enemy soldier, I would like them to run into the nearest house and preferably de-spawn. I don't really want to kill them via script though, hence de-spawn idea. Currently I am using a script for the BluFor team for which I am providing Overwatch that tells me if they are under fire; this addEventHandler ["FiredNear", {(_this select 0) sideChat "We are under fire, requesting assistance!"; } ]; This obviously only provides side chat messages if the team is within 69 meters of gunfire, I was wondering though if I could modify it to do what I wanted to do. Or at least use it in conjunction with whatever you genius' come up with :) Thanks in Advance Share this post Link to post Share on other sites
kovvalsky 13 Posted September 30, 2014 to do that you need to play with FSM: FSM wiki FSM tools my zombie test FSM Share this post Link to post Share on other sites
dreadedentity 278 Posted September 30, 2014 (edited) to do that you need to play with FSM I see no reason why this cannot be done with some simple code this addEventHandler ["FiredNear", { (_this select 0) allowFleeing 0; //dis-allow fleeing _positions = [nearestBuilding (_this select 0)] call BIS_fnc_buildingPositions; //get positions in closest building _move = _positions select (floor random (count _positions)); //select random position _waypoint = (group (_this select 0)) addWaypoint [_move, 0]; //create waypoint at position _waypoint setWaypointType "MOVE"; //order unit to move to position _waypoints = waypoints (group (_this select 0)); //get array of waypoints [] spawn { waitUntil {(count _waypoints) != (count (waypoints (group (_this select 0))))}; //this checks to see if the unit has reached their waypoint deleteVehicle (_this select 0); //delete unit }; }]; This should work (for editor-placed units) EDIT: added a line of code that will prevent the civs from fleeing, if I remember correctly civs always flee because they have no weapons, this will prevent them from ever reaching their waypoint and de-spawning. Use caution, because of the nature of urban combat and the extremely close distance something must be for the "FiredNear" EH to flag, civs might run directly in front of your guns. While you're shooting. Edited September 30, 2014 by DreadedEntity Share this post Link to post Share on other sites
Ice_Rhino 3 Posted September 30, 2014 Thank you for your suggestions. I looked at FSM and did not understand it. I am going to try the code suggested above. Thanks to all T Share this post Link to post Share on other sites