Jump to content

clock_x

Member
  • Content Count

    88
  • Joined

  • Last visited

  • Medals

Posts posted by clock_x


  1. I found the problem I had with the disappearing chopper/crew.

    I have a debug trigger because UPSMON sometimes bugged out and just sent the chopper in a random direction getting stuck(pretty rare after my fixes) to delete the chopper and his crew:

     

    !(chopper in thislist) -> whole AO

    { deleteVehicle _x } forEach (crew chopper ); deleteVehicle chopper;

     

    So this triggers if the choppers damage is 1.

    Gonna try to find a workaround or just delete the debug triggers.

     

    I added && alive chopper and it stopped doing it now.


  2. Alright, I changed it. Here is an update:

     

    Spoiler
    
    _deadguy = _this select 0;
    _killer  = _this select 1;
    _remove  = [];
    _finders = [];
    _spotters = [];
    _finder  = objnull;
    _prealarm = false;
    _deadguypos = getpos _deadguy;
    _shout1 = nil;
    _return = false; 
    _agnt = []; //agent removal
    
    if (alarm) exitWith {};
    
    if (vehicle _deadguy isKindOf "LandVehicle" OR vehicle _deadguy isKindOf "Air") exitWith {};
    
    _deadguy spawn { sleep 120; if (!isnull _this) then{_Body_Vultures = [_this] execVM "scripts\crows\BodyVultures.sqf";};sleep 400;hidebody _this;sleep 4;deletevehicle _this };// default effect
    
    if (side _deadguy == side _killer OR side _killer == civilian) exitwith {if (mein_debug>0) then { player globalChat format ["FindBody.sqf - _killer:%1 is same side or CIV as _deadguy:%2", _killer, _deadguy]; };};// side check
    
    if (_deadguy in FBList) exitWith {
    sleep 1;
    detected = true; 
    {_x setbehaviour "COMBAT";
    sleep 5;
    _x reveal [player, 0.6];
    } foreach FBlist;
    if (mein_debug>0) then {player globalChat format ["FindBody.sqf - deadguy:%1 in FeruzAbad.", _deadguy];};
    };
    
    
    
    
    
    while { (!_preAlarm  AND !isnull _deadguy) } do
     { _finders  = [];// clear array for refreshing
       _agnt = []; //agent removal
     
     { _agnt set [count _agnt, agent _x]; } foreach agents; //agent removal
     
    
         {// foreach nearobjects          
       
           if (alive _x and  canstand _x and !(_x isKindOf "ANIMAL")) then {_finders set [count _finders,_x]};// build array of alive units excluding busy unit
           }  foreach ( nearestObjects [_deadguypos, ["Man"], 100]-[eagle1,eagle2,_agnt,sleeper_1,N6_3]);// look through units and remove unwanted elements 
    	   
    	      if (mein_debug>0) then { player globalChat format ["FindBody.sqf - corpse:%1 _finders:%2", _deadguy, _finders]; };
        
         {// foreach finders
              //
              
               if (random 15 > 10) then {_x lookat _deadguy;sleep 2;_x lookat objnull;_x setformdir random 360};// forces _x to look in body direction
        
               sleep 0.1;// needs this or error undefined variable
               _return = [_deadguy,_x] call i_see;// returns true if finder _x can see deadguy
              
               _finder_free = _x getvariable ["free",objnull];// check if assigned
    		   
    		    if (typeof _deadguy == "Pastor" and  (isnull _finder_free)) exitwith  //removed and (typeof _x != "pastor")
    																			{
    																			_x setvariable ["free",_deadguy];// assigned to deadguy                
                                                                                _x  domove _deadguypos;// _deadguypos;
                                                                                _finder = _x;
    																			};//exitwith  ends loop
    
              if (_return and (isnull _finder_free)) exitWith { //removed and (typeof _x != "pastor")
                                                                                _x setvariable ["free",_deadguy];// assigned to deadguy                
                                                                                 _x  domove _deadguypos;// _deadguypos;
                                                                                  _finder = _x;
    																if (mein_debug>0) then {player sideChat format ["FindBody.sqf - _finder:%1 detected corpse:%2", _finder, _deadguy]; };
                                                                                     //_shout1 = [leader (group _finder), _killer] execVM "scripts\ShoutSound.sqf";
                                                                                     //_shout1 spawn {sleep 1; terminate _this};
                                                                                     //group _finder setVariable ["endscript",true];     
                                                                       };//exitwith  ends loop when finds first guy has line of side                                                   
         } foreach _finders;
    
        if (!isnull _finder or !alive _finder)  then {waituntil{;sleep 1;!alive _finder or _finder distance _deadguypos <4 or isnull _deadguy};};// checks finder status
            
        if (!isnull _deadguy and alive _finder) then {
    			_shout1 = [leader (group _finder), _killer] execVM "scripts\ShoutSound.sqf";
                 _finder setunitpos "middle";
                   _finder disableAI "MOVE";
                    _finder reveal [player, 1]; //NEW WIP                 
                     _finder setvariable ["free",objnull];// reset as unassigned
                      _preAlarm = true;
    				  if (mein_debug>0) then {player sideChat format ["FindBody.sqf - _preAlarm:%1 for corpse:%2", _preAlarm, _deadguy]; };
                      };// changes stance if body found                
         sleep 4;
    	 
         if (!alive _finder) then {_finder setvariable ["free",objnull]};// reset as unassigned
    
         };// end while
    
          _finder enableAI "MOVE";
    
    
    	 
    	 
    	 if (!isNil "_finder") then {
    
    if (!isnull(_finder) && {alive _finder} ) then {_finder setunitpos "UP";_finder enableAI "MOVE";};	
    						
    
    
    if (_preAlarm) then {
    
          {
           if (alive _x) then {_spotters set [count _spotters,_x]};// build array of alive units
           }  foreach ( nearestObjects [_deadguypos, ["Man"], 50]-[eagle1,eagle2,_agnt]);// look through units
       
       //_spotters = _spotters - [eagle1,eagle2,_agnt];// remove elements,
    
         _preAlarm = false;
    	if (mein_debug>0) then {player sideChat format ["FindBody.sqf - _preAlarm:%1 for corpse:%2", _preAlarm, _deadguy]; };
    
    
        if (_finder in EHlistBerg) then 
        {
    
    	
    // --------------------------------AA_CAMP---------------------------------------------------------	
    	if (_finder in NA7list) then {
       
    	if (genOff) then { sleep 30; };
    	
    									};
    // -------------------------------------------------------------------------------------------- 
    					
             if (!radioObj) then {sleep (30 + (random 30));} else {sleep (70 + (random 120));};
    
        } else {
    	
    	if (mein_debug>0) then {player globalChat format ["FindBody.sqf - _finder:%1 not in EHlistBerg - debug sleep", _finder];};
    	if (!radioObj) then {sleep (30 + (random 30));} else {sleep (70 + (random 120));};
    	
    	};
    
    
               {
                  if ((alive _x) AND (side _x == EAST)) then
                  {
                     detected = true;
    				 _x setBehaviour "COMBAT"; //NEW
    				 
    				if (_finder distance player < 120 && _finder hasWeapon "ItemRadio") then {
    				 
    				_answer = ["s0", "s01", "s02", "s03", "s04"] call BIS_fnc_selectRandom;
    				_finder say3d _answer;			 
    				 
    																						};
    																					
    
    if (!action) then {
    		KRON_UPS_reinforcement3 = true;
    		
    if (group _finder == tksf2_G OR group _finder == tksf3_G OR group _finder ==  shktrp) then 
    {
    			KRON_UPS_reinforcement3_pos = getPos player;
    		    if (mein_debug>0) then { player globalChat format ["FindBody.sqf - KRON_UPS_reinforcement3_pos - player"];};
    } else 
    {
    		if (mein_debug>0) then { player globalChat format ["FindBody.sqf - KRON_UPS_reinforcement3_pos - deadguy:%1", _deadguy];};
    		KRON_UPS_reinforcement3_pos = _deadguypos;		
    };
    		
    					};
    
    												
    
             if (radioObj) then {
    
    		KRON_UPS_reinforcement0 = true; 
    		KRON_UPS_reinforcement0_pos = _deadguypos;
    
    							if (mein_debug>0) then { 
      player globalChat format ["FindBody.sqf - KRON_UPS_reinforcement0_pos - deadguy:%1", _deadguy];
    												};
    			     };
    
    
    		sleep 60;
            _x setBehaviour "AWARE"; //NEW
    
    		if (!isNull _deadguy) then {
    
    				hidebody _deadguy; sleep 5; deletevehicle _deadguy;
    				
    				                if (mein_debug>0) then {player globalChat "FindBody.sqf - Deleting Body after detected";};
    				
    									};
    
                  } else {if (mein_debug>0) then {player globalChat format ["FindBody.sqf - deadguy:%1 - all spotters:%2 dead", _deadguy, _spotters];};};
               } forEach _spotters;
    		   
                       } else {
    				   
    				   sleep 120; 
    				   
    				   if (!isNull _deadguy) then { 
    				   
    				   hidebody _deadguy; sleep 5; deletevehicle _deadguy;			   
    				   if (mein_debug>0) then {player globalChat "FindBody.sqf - Deleting Body after !preAlarm";};
    				   
    											};
    				   
    							};		
    } else {
    
    				   sleep 120;
    				   
    				   if (!isNull _deadguy) then { 
    				   
    				  hidebody _deadguy; sleep 5; deletevehicle _deadguy;		   
    				   if (mein_debug>0) then {player globalChat "FindBody.sqf - Deleting Body after isNil _finder";};
    				   
    											};
    											
    		};					
    				
                    if (mein_debug>0) then {player globalChat "FindBody.sqf - END of script";};
    				sleep 5;
                    if (!isNil "_shout1") then {terminate _shout1;group _finder setVariable ["endscript",true];};      

     

     


  3. 7 minutes ago, f2k sel said:

    OK I don't have a perfect fix yet but I think I see the issue, the bodies are still in the vehicle and due to the game engine you can't delete units while they are inside a vehicle.

     

    You could add a check at start of findbody.sqf, this will just exit the whole script.

    if (Vehicle _deadguy isKindOf "Air") exitWith {};

     

    However I suspect this will happen with all vehicle types so a better solution is needed.

    Mhh .. what I forgot to mention is that the helicopter vanished too.

     

    So basically I could change this line:

    if (_deadguy isKindOf "LandVehicle" OR _deadguy isKindOf "Air") exitWith {};

    to this:

    if (vehicle _deadguy isKindOf "Air" OR _deadguy isKindOf "LandVehicle" OR _deadguy isKindOf "Air") exitWith {};

     

    Is '_deadguy isKindOf "Air"' still needed in this case?


  4. Soo I had this happening:

    flymuch7nkom.png

    I blew up a chopper with reinforcements since I gotta test all sorts of stuff.

    Most of the corpses dissapeared into thin air and still a bunch of flies and crows spawned at the same spot and the findBody script was running for everyone.

    Dunno if explosions gets rid of corpses or if they just spawned under the ground or something.

    I checked if I get the hidebody action for any invisible guys but I did not.

     

    I waited for them to get deleted so that the flies/crows get deleted too but none of it happened!

    Whats interesting too is that the debug lines return the same corpse 2 times in the same second, which should mean that the script is running for the same guy twice?

     

    //EDIT: After reverting the game it actually realized all of them were gone and deleted all the vultures and stopped running the script.

     

    The script running for the same guy twice is actually happening more often, I had the suspicion for a bit longer but now I'm pretty sure.

    Just now I had a test were a single dead guy got detected 2 times by the same unit a few seconds apart. The time difference could be the random sleeps, dunno.


  5. Mhh sounds strange.

    I've had really strange things happening with other stuff too, like magic lightsources suddenly appearing at the same spot without any reason.

    Reloading the game fixed that for me at least. Sometimes arma feels a bit haunted. 😀

     

    I think the AI sometimes went into houses too on my end, but very rarely and most of the time AI which was placed in the house, left it and then entered it again.


  6. 1 hour ago, f2k sel said:

    Basically is skips the LOS and moves the unit directly to body even if it can't see it.

    I could make it a random thing where it may or may not look for the body.

    That would be fine, the units coming to the houses are reinforcements most of the time anyway, which only come after first contact.

    The random chance would make it a bit more balanced.


     

    Quote

     

    I notice your still using this line

    if (!isnull(_finder) && {!alive _finder} ) then {_finder setunitpos "UP";_finder enableAI "MOVE";};   

    How can it stand up if it's not alive?

     

    Damn I thought I fixed that. Sometimes I fix files in old mission versions by accident. That's a pain!

     

    Updated version:

    Spoiler
    
    _deadguy = _this select 0;
    _killer  = _this select 1;
    _remove  = [];
    _finders = [];
    _spotters = [];
    _finder  = objnull;
    _prealarm = false;
    _deadguypos = getpos _deadguy;
    _shout1 = nil;
    _return = false; 
    _agnt = []; //agent removal
    
    if (alarm) exitWith {};
    
    if (_deadguy isKindOf "LandVehicle" OR _deadguy isKindOf "Air") exitWith {};
    
    _deadguy spawn { sleep 120; if (!isnull _this) then{_Body_Vultures = [_this] execVM "scripts\crows\BodyVultures.sqf";};sleep 400;hidebody _this;sleep 4;deletevehicle _this };// default effect
    
    if (side _deadguy == side _killer OR side _killer == civilian) exitwith {if (mein_debug>0) then { player globalChat format ["FindBody.sqf - _killer:%1 is same side or CIV as _deadguy:%2", _killer, _deadguy]; };};// side check
    
    if (_deadguy in FBList) exitWith {
    sleep 1;
    detected = true; 
    {_x setbehaviour "COMBAT";
    sleep 5;
    _x reveal [player, 0.5];
    } foreach FBlist;
    if (mein_debug>0) then {player globalChat format ["FindBody.sqf - deadguy:%1 in FeruzAbad.", _deadguy];};
    };
    
    
    
    
    
    while { (!_preAlarm  AND !isnull _deadguy) } do
     { _finders  = [];// clear array for refreshing
       _agnt = []; //agent removal
     
     { _agnt set [count _agnt, agent _x]; } foreach agents; //agent removal
     
    
         {// foreach nearobjects          
       
           if (alive _x and  canstand _x and !(_x isKindOf "ANIMAL")) then {_finders set [count _finders,_x]};// build array of alive units excluding busy unit
           }  foreach ( nearestObjects [_deadguypos, ["Man"], 100]-[eagle1,eagle2,_agnt,sleeper_1]);// look through units and remove unwanted elements 
    	   
    	      if (mein_debug>0) then { player globalChat format ["FindBody.sqf - corpse:%1 _finders:%2", _deadguy, _finders]; };
        
         {// foreach finders
              //
              
               if (random 15 > 10) then {_x lookat _deadguy;sleep 2;_x lookat objnull;_x setformdir random 360};// forces _x to look in body direction
        
               sleep 0.1;// needs this or error undefined variable
              _return = [_x,_deadguy] call i_see;// returns true if finder _x can see deadguy
              
               _finder_free = _x getvariable ["free",objnull];// check if assigned
    		   
    		    if (typeof _deadguy == "Pastor" and  (isnull _finder_free) and (typeof _x != "pastor")) exitwith  
    																			{
    																			_x setvariable ["free",_deadguy];// assigned to deadguy                
                                                                                _x  domove _deadguypos;// _deadguypos;
                                                                                _finder = _x;
    																			};//exitwith  ends loop
    
              if (_return and (isnull _finder_free) and (typeof _x != "pastor")) exitWith {
                                                                                _x setvariable ["free",_deadguy];// assigned to deadguy                
                                                                                 _x  domove _deadguypos;// _deadguypos;
                                                                                  _finder = _x;
    																if (mein_debug>0) then {player globalChat format ["FindBody.sqf - _finder:%1 detected corpse:%2", _finder, _deadguy]; };
                                                                                     //_shout1 = [leader (group _finder), _killer] execVM "scripts\ShoutSound.sqf";
                                                                                     //_shout1 spawn {sleep 1; terminate _this};
                                                                                     //group _finder setVariable ["endscript",true];     
                                                                       };//exitwith  ends loop when finds first guy has line of side                                                   
         } foreach _finders;
    
        if (!isnull _finder or !alive _finder)  then {waituntil{;sleep 1;!alive _finder or _finder distance _deadguypos <4 or isnull _deadguy};};// checks finder status
            
        if (!isnull _deadguy and alive _finder) then {
    			_shout1 = [leader (group _finder), _killer] execVM "scripts\ShoutSound.sqf";
                 _finder setunitpos "middle";
                   _finder disableAI "MOVE";
                    _finder reveal [player, 1]; //NEW WIP                 
                     _finder setvariable ["free",objnull];// reset as unassigned
                      _preAlarm = true;
    				  if (mein_debug>0) then {player sideChat format ["FindBody.sqf - _preAlarm:%1 for corpse:%2", _preAlarm, _deadguy]; };
                      };// changes stance if body found                
         sleep 4;
    	 
         if (!alive _finder) then {_finder setvariable ["free",objnull]};// reset as unassigned
    
         };// end while
    
          _finder enableAI "MOVE";
    
    
    	 
    	 
    	 if (!isNil "_finder") then {
    
    if (!isnull(_finder) && {alive _finder} ) then {_finder setunitpos "UP";_finder enableAI "MOVE";};	
    						
    
    
    if (_preAlarm) then {
    
          {
           if (alive _x) then {_spotters set [count _spotters,_x]};// build array of alive units
           }  foreach ( nearestObjects [_deadguypos, ["Man"], 50]-[eagle1,eagle2,_agnt]);// look through units
       
       //_spotters = _spotters - [eagle1,eagle2,_agnt];// remove elements,
    
         _preAlarm = false;
    	if (mein_debug>0) then {player sideChat format ["FindBody.sqf - _preAlarm:%1 for corpse:%2", _preAlarm, _deadguy]; };
    
    
        if (_finder in EHlistBerg) then 
        {
    
    	
    // --------------------------------AA_CAMP---------------------------------------------------------	
    	if (_finder in NA7list) then {
       
    	if (genOff) then { sleep 30; };
    	
    									};
    // -------------------------------------------------------------------------------------------- 
    					
             if (!radioObj) then {sleep (30 + (random 30));} else {sleep (70 + (random 120));};
    
        } else {
    	
    	if (mein_debug>0) then {player globalChat format ["FindBody.sqf - _finder:%1 not in EHlistBerg - debug sleep", _finder];};
    	if (!radioObj) then {sleep (30 + (random 30));} else {sleep (70 + (random 120));};
    	
    	};
    
    
               {
                  if ((alive _x) AND (side _x == EAST)) then
                  {
                     detected = true;
    				 _x setBehaviour "COMBAT"; //NEW
    				 
    				if (_finder distance player < 120 && _finder hasWeapon "ItemRadio") then {
    				 
    				_answer = ["s0", "s01", "s02", "s03", "s04"] call BIS_fnc_selectRandom;
    				_finder say3d _answer;			 
    				 
    																						};
    																					
    
    if (!action) then {
    		KRON_UPS_reinforcement3 = true;
    		
    if (group _finder == tksf2_G OR group _finder == tksf3_G OR group _finder ==  shktrp) then 
    {
    			KRON_UPS_reinforcement3_pos = getPos player;
    		    if (mein_debug>0) then { player globalChat format ["FindBody.sqf - KRON_UPS_reinforcement3_pos - player"];};
    } else 
    {
    		if (mein_debug>0) then { player globalChat format ["FindBody.sqf - KRON_UPS_reinforcement3_pos - deadguy:%1", _deadguy];};
    		KRON_UPS_reinforcement3_pos = _deadguypos;		
    };
    		
    					};
    
    												
    
             if (radioObj) then {
    
    		KRON_UPS_reinforcement0 = true; 
    		KRON_UPS_reinforcement0_pos = _deadguypos;
    
    							if (mein_debug>0) then { 
      player globalChat format ["FindBody.sqf - KRON_UPS_reinforcement0_pos - deadguy:%1", _deadguy];
    												};
    			     };
    
    
    		sleep 60;
            _x setBehaviour "AWARE"; //NEW
    
    		if (!isNull _deadguy) then {
    
    				hidebody _deadguy; sleep 5; deletevehicle _deadguy;
    				
    				                if (mein_debug>0) then {player globalChat "FindBody.sqf - Deleting Body after detected";};
    				
    									};
    
                  } else {if (mein_debug>0) then {player globalChat format ["FindBody.sqf - deadguy:%1 - all spotters:%2 dead", _deadguy, _spotters];};};
               } forEach _spotters;
    		   
                       } else {
    				   
    				   sleep 120; 
    				   
    				   if (!isNull _deadguy) then { 
    				   
    				   hidebody _deadguy; sleep 5; deletevehicle _deadguy;			   
    				   if (mein_debug>0) then {player globalChat "FindBody.sqf - Deleting Body after !preAlarm";};
    				   
    											};
    				   
    							};		
    } else {
    
    				   sleep 120;
    				   
    				   if (!isNull _deadguy) then { 
    				   
    				  hidebody _deadguy; sleep 5; deletevehicle _deadguy;		   
    				   if (mein_debug>0) then {player globalChat "FindBody.sqf - Deleting Body after isNil _finder";};
    				   
    											};
    											
    		};					
    				
                    if (mein_debug>0) then {player globalChat "FindBody.sqf - END of script";};
    				sleep 5;
                    if (!isNil "_shout1") then {terminate _shout1;group _finder setVariable ["endscript",true];};      

     

     


  7. 8 minutes ago, f2k sel said:

    I suspect the trigger is not adding the  EVH to units in vehicles,  you may need to add the EVH to the crew

    Also need to see if nearestobjects can find units in the vehicle or again we need to find the vehicles and find their crew.

    I can't test anything right now I may have some time later.

     

    I changed the on act. of the trigger:

    {_x addEventHandler ["killed",{_this execVM "scripts\alarm\FindBody.sqf";}]} forEach EHlist; {{_x addEventHandler ["killed",{_this execVM "scripts\alarm\FindBody.sqf";}]} forEach (crew _x);} forEach EHlist;

    It works now. And nearestobjects finds the dead guys inside vehicles just fine, the AI can see them too.

     

    I think it's almost perfect.

    The last thing, which I don't know if it's possible, is if the AI can enter/search houses to find dead guys.

    The doMove line doesn't work with houses. The Ai stays in front of the houses and looks in the direction of the dead guys inside but can't see them, which is fine. But the _finders won't enter the house.

    (I have created houses in the AO, dunno if that makes a difference, didn't test it with not spawned houses.)


  8. I had a small issue.

    The script was adding the vultures to a static weapon and deleting it after that.

    I added this at the beginning:

    if (_deadguy isKindOf "StaticWeapon") exitWith {};

     

    //EDIT: Need to fix a bit more than that, it's adding to cars too, I guess all vehicles.

     

    if (_deadguy isKindOf "LandVehicle" OR _deadguy isKindOf "Air") exitWith {};

    This should do the trick.

     

    Another thing I've noticed is, units who die/spawn inside vehicles are not triggering the script.

    Changed the trigger On Act.:

    {_x addEventHandler ["killed",{_this execVM "scripts\alarm\FindBody.sqf";}]} forEach EHlist;
    
    {{_x addEventHandler ["killed",{_this execVM "scripts\alarm\FindBody.sqf";}]} forEach (crew _x);} forEach EHlist;

    Now it works. Is that ok or is it a bad way of doing it?


  9. Yes I checked it, dogs are not in _finders anymore but do appear as _deadguy and the script does everything it's supposed to do.

     {// foreach nearobjects          
       
           if (alive _x and  canstand _x and !(_x isKindOf "ANIMAL")) then {_finders set [count _finders,_x]};// build array of alive units excluding busy unit
           }  foreach ( nearestObjects [_deadguypos, ["Man"], 100]-[eagle1,eagle2,_agnt,sleeper_1]);// look through units and remove unwanted elements

    Here is the script up to date:

     

    Spoiler
    
    _deadguy = _this select 0;
    _killer  = _this select 1;
    _remove  = [];
    _finders = [];
    _spotters = [];
    _finder  = objnull;
    _prealarm = false;
    _deadguypos = getpos _deadguy;
    _shout1 = nil;
    _return = false; 
    _agnt = []; //agent removal
    
    if (alarm) exitWith {};
    
    _deadguy spawn { sleep 120; if (!isnull _this) then{_Body_Vultures = [_this] execVM "scripts\crows\BodyVultures.sqf";};sleep 400;hidebody _this;sleep 4;deletevehicle _this };// default effect
    
    if (side _deadguy == side _killer OR side _killer == civilian) exitwith {if (mein_debug>0) then { player globalChat format ["FindBody.sqf - _killer:%1 is same side or CIV as _deadguy:%2", _killer, _deadguy]; };};// side check
    
    if (_deadguy in FBList) exitWith {
    sleep 1;
    detected = true; 
    {_x setbehaviour "COMBAT";
    sleep 5;
    _x reveal [player, 0.5];
    } foreach FBlist;
    if (mein_debug>0) then {player globalChat format ["FindBody.sqf - deadguy:%1 in FeruzAbad.", _deadguy];};
    };
    
    
    
    
    
    while { (!_preAlarm  AND !isnull _deadguy) } do
     { _finders  = [];// clear array for refreshing
       _agnt = []; //agent removal
     
     { _agnt set [count _agnt, agent _x]; } foreach agents; //agent removal
     
    
         {// foreach nearobjects          
       
           if (alive _x and  canstand _x and !(_x isKindOf "ANIMAL")) then {_finders set [count _finders,_x]};// build array of alive units excluding busy unit
           }  foreach ( nearestObjects [_deadguypos, ["Man"], 100]-[eagle1,eagle2,_agnt,sleeper_1]);// look through units and remove unwanted elements 
    	   
    	      if (mein_debug>0) then { player globalChat format ["FindBody.sqf - corpse:%1 _finders:%2", _deadguy, _finders]; };
        
         {// foreach finders
              //
              
               if (random 15 > 10) then {_x lookat _deadguy;sleep 2;_x lookat objnull;_x setformdir random 360};// forces _x to look in body direction
        
               sleep 0.1;// needs this or error undefined variable
              _return = [_x,_deadguy] call i_see;// returns true if finder _x can see deadguy
              
               _finder_free = _x getvariable ["free",objnull];// check if assigned
    		   
    		    if (typeof _deadguy == "Pastor" and  (isnull _finder_free) and (typeof _x != "pastor")) exitwith  
    																			{
    																			_x setvariable ["free",_deadguy];// assigned to deadguy                
                                                                                _x  domove _deadguypos;// _deadguypos;
                                                                                _finder = _x;
    																			};//exitwith  ends loop
    
              if (_return and (isnull _finder_free) and (typeof _x != "pastor")) exitWith {
                                                                                _x setvariable ["free",_deadguy];// assigned to deadguy                
                                                                                 _x  domove _deadguypos;// _deadguypos;
                                                                                  _finder = _x;
    																if (mein_debug>0) then {player globalChat format ["FindBody.sqf - _finder:%1 detected corpse:%2", _finder, _deadguy]; };
                                                                                    _shout1 = [leader (group _finder), _killer] execVM "scripts\ShoutSound.sqf";
                                                                                     //_shout1 spawn {sleep 1; terminate _this};
                                                                                     //group _finder setVariable ["endscript",true];     
                                                                       };//exitwith  ends loop when finds first guy has line of side                                                   
         } foreach _finders;
    
        if (!isnull _finder or !alive _finder)  then {waituntil{;sleep 1;!alive _finder or _finder distance _deadguypos <4 or isnull _deadguy};};// checks finder status
            
        if (!isnull _deadguy and alive _finder) then {
                 _finder setunitpos "middle";
                   _finder disableAI "MOVE";
                    _finder reveal [player, 1]; //NEW WIP                 
                     _finder setvariable ["free",objnull];// reset as unassigned
                      _preAlarm = true;
    				  if (mein_debug>0) then {player sideChat format ["FindBody.sqf - _preAlarm:%1 for corpse:%2", _preAlarm, _deadguy]; };
                      };// changes stance if body found                
         sleep 4;
    	 
         if (!alive _finder) then {_finder setvariable ["free",objnull]};// reset as unassigned
    
         };// end while
    
          _finder enableAI "MOVE";
    
    
    	 
    	 
    	 if (!isNil "_finder") then {
    
    if (!isnull(_finder) && {!alive _finder} ) then {_finder setunitpos "UP";_finder enableAI "MOVE";};	
    						
    
    
    if (_preAlarm) then {
    
          {
           if (alive _x) then {_spotters set [count _spotters,_x]};// build array of alive units
           }  foreach ( nearestObjects [_deadguypos, ["Man"], 50]-[eagle1,eagle2,_agnt]);// look through units
       
       //_spotters = _spotters - [eagle1,eagle2,_agnt];// remove elements,
    
         _preAlarm = false;
    	if (mein_debug>0) then {player sideChat format ["FindBody.sqf - _preAlarm:%1 for corpse:%2", _preAlarm, _deadguy]; };
    
    
        if (_finder in EHlistBerg) then 
        {
    
    	
    // --------------------------------AA_CAMP---------------------------------------------------------	
    	if (_finder in (list Nighttime7_1)) then {
       
    	if (genOff) then { sleep 30; };
    	
    									};
    // -------------------------------------------------------------------------------------------- 
    					
             if (!radioObj) then {sleep (30 + (random 30));} else {sleep (70 + (random 120));};
    
        } else {
    	
    	if (mein_debug>0) then {player globalChat format ["FindBody.sqf - _finder:%1 not in EHlistBerg - debug sleep", _finder];};
    	if (!radioObj) then {sleep (30 + (random 30));} else {sleep (70 + (random 120));};
    	
    	};
    
    
               {
                  if ((alive _x) AND (side _x == EAST)) then
                  {
                     detected = true;
    				 _x setBehaviour "COMBAT"; //NEW
    				 
    				if (_finder distance player < 120 && _finder hasWeapon "ItemRadio") then {
    				 
    				_answer = ["s0", "s01", "s02", "s03", "s04"] call BIS_fnc_selectRandom;
    				_finder say3d _answer;			 
    				 
    																						};
    																					
    
    if (!action) then {
    		KRON_UPS_reinforcement3 = true;
    		
    if (group _finder == tksf2_G OR group _finder == tksf3_G OR group _finder ==  shktrp) then 
    {
    			KRON_UPS_reinforcement3_pos = getPos player;
    		    if (mein_debug>0) then { player globalChat format ["FindBody.sqf - KRON_UPS_reinforcement3_pos - player"];};
    } else 
    {
    		if (mein_debug>0) then { player globalChat format ["FindBody.sqf - KRON_UPS_reinforcement3_pos - deadguy:%1", _deadguy];};
    		KRON_UPS_reinforcement3_pos = _deadguypos;		
    };
    		
    					};
    
    												
    
             if (radioObj) then {
    
    		KRON_UPS_reinforcement0 = true; 
    		KRON_UPS_reinforcement0_pos = _deadguypos;
    
    							if (mein_debug>0) then { 
      player globalChat format ["FindBody.sqf - KRON_UPS_reinforcement0_pos - deadguy:%1", _deadguy];
    												};
    			     };
    
    
    		sleep 60;
            _x setBehaviour "AWARE"; //NEW
    
    		if (!isNull _deadguy) then {
    
    				hidebody _deadguy; sleep 5; deletevehicle _deadguy;
    				
    				                if (mein_debug>0) then {player globalChat "FindBody.sqf - Deleting Body after detected";};
    				
    									};
    
                  } else {if (mein_debug>0) then {player globalChat format ["FindBody.sqf - deadguy:%1 - all spotters:%2 dead", _deadguy, _spotters];};};
               } forEach _spotters;
    		   
                       } else {
    				   
    				   sleep 120; 
    				   
    				   if (!isNull _deadguy) then { 
    				   
    				   hidebody _deadguy; sleep 5; deletevehicle _deadguy;			   
    				   if (mein_debug>0) then {player globalChat "FindBody.sqf - Deleting Body after !preAlarm";};
    				   
    											};
    				   
    							};		
    } else {
    
    				   sleep 120;
    				   
    				   if (!isNull _deadguy) then { 
    				   
    				  hidebody _deadguy; sleep 5; deletevehicle _deadguy;		   
    				   if (mein_debug>0) then {player globalChat "FindBody.sqf - Deleting Body after isNil _finder";};
    				   
    											};
    											
    		};					
    				
                    if (mein_debug>0) then {player globalChat "FindBody.sqf - END of script";};
    				sleep 5;
                    if (!isNil "_shout1") then {terminate _shout1;group _finder setVariable ["endscript",true];};      

     

     

    Haven't gotten the undefined error for a while, maybe it was connected to the animal agents?


  10. Quote

    Just thought aren't they Civillian? 

    Could be but I'm using a few civs grouped with militia as OPFOR, I think the class still returns civ.

     

    Is !(_x isKindOf "ANIMAL") for nearestObjects not a good way to do it?

    It got rid of them in my tests.

     

    With typeof it would be all those I think:

    if (typeof  _deadguy in ["Cow01","Cow02","Cow03","Cow04","Goat","Hen","Cock","Pastor","Rabbit","Sheep","WildBoar"]) exitwith {hint "dead animals"};


  11. Can I put !isNull in the spawn like this:

    _deadguy spawn { sleep 120; if (!isnull _deadguy) then { _Body_Vultures = [_this] execVM "scripts\crows\BodyVultures.sqf";};sleep 400;hidebody _this;sleep 4;deletevehicle _this };// default effect

     

    Because  I always get <NULL> from the deadguy/victim in BodyVultures.sqf after I hid/deleted the deadguy from this debug line:

    player globalChat format ["BodyVultures.sqf - victim:%1 - spawning vultures", _victim];

     

    One other thing, I think I figured out who the agents who are displayed are, definitely not flies/crows as far as I can see. Because i get the agents before crows/flies are spawned.

    I've been chasing a bunny away from the dead guys in one situation where I reverted a few times and the agent disappeared. Sneaky bunnies!

    I do use the ambient animals module.


    //EDIT: Now it was 2 sheeps, which I killed and the two agents were gone.

    ANIMAL seem to be a subcategory of MAN:

    AllVehicles->Land->Man->Animal->CAAnimalBase->Cow/Hen/Sheep/Rabbit etc.

     

    I think I removed them  for good😀:

     

     {// foreach nearobjects          
       
           if (alive _x and  canstand _x and !(_x isKindOf "ANIMAL")) then {_finders set [count _finders,_x]};// build array of alive units excluding busy unit
           }  foreach ( nearestObjects [_deadguypos, ["Man"], 100]-[eagle1,eagle2,_agnt,sleeper_1]);// look through units and remove unwanted elements

     

    The dog is removed from _finders too.

    Is and (typeof _x != "pastor") obsolete now?

     


  12. Quote

    You can try adding your eventhandler to the dog just after     _perro setVehicleVarName _NombrePerro

    The killedEH? I think the dog already has it because everytime I kill the dog he is instantly recognized as _deadguy.

     

    I'm getting an error and I don't understand why, the code seems totally fine.

     

              if (typeof _deadguy == "Pastor" and  (isnull _finder_free) and (typeof _x != "pastor")) exitwith  {_x setvariable ["free",_deadguy];// assigned to deadguy                
                                                                                 _x  domove _deadguypos;// _deadguypos;
                                                                                  _finder = _x;
                                                                                  };//exitwith  ends loop

     

    Error in expression

    <d  (isnull _finder_free) and (typeof _x ! = "pastor")) exitwith {_x setvariabl>

    Error position:

    <! = "pastor")) exitwith {_x setvariabl>
      Error Missing )
    FindBody.sqf, line 57

     

    //EDIT:

    I just changed the layout and now it works 🙄

     

                if (typeof _deadguy == "Pastor" and  (isnull _finder_free) and (typeof _x != "pastor")) exitwith  
                                                                                {
                                                                                _x setvariable ["free",_deadguy];// assigned to deadguy                
                                                                                _x  domove _deadguypos;// _deadguypos;
                                                                                _finder = _x;
                                                                                };//exitwith  ends loop


  13. Nice, thanks I will test it tomorrow.

    Quote

    I did change detected to _detected as that would be picked up over multiple scripts.

    That's supposed to be like that, if detected=true and the target is close to the AO the mission fails.

    All the alarm scripts are pretty much for that purpose..and for reinforcements.

     

    Quote

    I don't seem to get any of the other errors in my testing but I don't have all the other scripts messing things up.

    I only got it like two times, I'm gonna try to figure out why.

     

    I was wondering what this..

    _NombrePerro = format ["k9%1",round (random 1000)];

    is about. 😀

     

    Quote

    The dog owner can find the body as is but if you don't want that just add his name to the exclusion array like you did for  sleeper_1

    Can the dog owner find the dog, even though the dog is excluded with typeof?

     


  14. Here it is:

    Spoiler
    
    _deadguy = _this select 0;
    _killer  = _this select 1;
    _remove  = [];
    _finders = [];
    _spotters = [];
    _finder  = objnull;
    _prealarm = false;
    _deadguypos = getpos _deadguy;
    _shout1 = nil;
    _return = false; 
    _agnt = []; //agent removal
    
    if (alarm) exitWith {};
    
    _deadguy spawn { sleep 120; _Body_Vultures = [_this] execVM "scripts\crows\BodyVultures.sqf";sleep 400;hidebody _this;sleep 4;deletevehicle _this };// default effect
    
    if (side _deadguy == side _killer OR side _killer == civilian) exitwith {if (mein_debug>0) then { player globalChat format ["FindBody.sqf - _killer:%1 is same side or CIV as _deadguy:%2", _killer, _deadguy]; };};// side check
    
    if (_deadguy in FBList) exitWith {
    sleep 1;
    detected = true; 
    {_x setbehaviour "COMBAT";
    sleep 5;
    _x reveal [player, 0.5];
    } foreach FBlist;
    if (mein_debug>0) then {player globalChat format ["FindBody.sqf - deadguy:%1 in FeruzAbad.", _deadguy];};
    };
    
    
    
    
    
    while { (!_preAlarm  AND !isnull _deadguy) } do
     { _finders  = [];// clear array for refreshing
       _agnt = []; //agent removal
     
     { _agnt = _agnt +  [agent _x] } foreach agents; //agent removal
     
    
         {// foreach nearobjects          
       
           if (alive _x and  canstand _x) then {_finders set [count _finders,_x]};// build array of alive units excluding busy unit
           }  foreach ( nearestObjects [_deadguypos, ["Man"], 100]-[eagle1,eagle2,_agnt,sleeper_1]);// look through units and remove unwanted elements 
    	   
    	      if (mein_debug>0) then { player globalChat format ["FindBody.sqf - corpse:%1 _finders:%2", _deadguy, _finders]; };
        
         {// foreach finders
              //
              
               if (random 15 > 10) then {_x lookat _deadguy;sleep 2;_x lookat objnull;_x setformdir random 360};// forces _x to look in body direction
        
               sleep 0.1;// needs this or error undefined variable
              _return = [_x,_deadguy] call i_see;// returns true if finder _x can see deadguy
              
               _finder_free = _x getvariable ["free",objnull];// check if assigned
    
              if (_return and (isnull _finder_free)) exitWith {
                                                                                _x setvariable ["free",_deadguy];// assigned to deadguy                
                                                                                 _x  domove _deadguypos;// _deadguypos;
                                                                                  _finder = _x;
    																if (mein_debug>0) then {player globalChat format ["FindBody.sqf - _finder:%1 detected corpse:%2", _finder, _deadguy]; };
                                                                                    _shout1 = [leader (group _finder), _killer] execVM "scripts\ShoutSound.sqf";
                                                                                     //_shout1 spawn {sleep 1; terminate _this};
                                                                                     //group _finder setVariable ["endscript",true];     
                                                                       };//exitwith  ends loop when finds first guy has line of side                                                   
         } foreach _finders;
    
        if (!isnull _finder or !alive _finder)  then {waituntil{;sleep 1;!alive _finder or _finder distance _deadguypos <4 or isnull _deadguy};};// checks finder status
            
        if (!isnull _deadguy and alive _finder) then {
                 _finder setunitpos "middle";
                   _finder disableAI "MOVE";
                    _finder reveal [player, 1]; //NEW WIP                 
                     //_finder setvariable ["free",objnull];// reset as unassigned
                      _preAlarm = true;
                      };// changes stance if body found                
         sleep 4;
    	 
    	 _finder setvariable ["free",objnull];// reset as unassigned
    
         };// end while
    
          _finder enableAI "MOVE";
    
    
    	 
    	 
    	 if (!isNil "_finder") then {
    
    if (!isnull(_finder) && {!alive _finder} ) then {_finder setunitpos "UP";_finder enableAI "MOVE";};	
    						
    
    
    if (_preAlarm) then {
    
    	  {
           if (alive _x) then {_spotters = _spotters + [_x]};// build array of alive units
           }  foreach ( nearestObjects [_deadguypos, ["Man"], 50]);// look through units
       
       _spotters = _spotters - [eagle1,eagle2,_agnt];// remove elements,
    
         _preAlarm = false;
    	if (mein_debug>0) then {player globalChat format ["FindBody.sqf - _preAlarm:%1 for corpse:%2", _preAlarm, _deadguy]; };
    
    
        if (_finder in EHlistBerg) then 
        {
    
    	
    // --------------------------------AA_CAMP---------------------------------------------------------	
    	if (_finder in (list Nighttime7_1)) then {
       
    	if (genOff) then { sleep 30; };
    	
    									};
    // -------------------------------------------------------------------------------------------- 
    					
             if (!radioObj) then {sleep (30 + (random 30));} else {sleep (70 + (random 120));};
    
        } else {if (mein_debug>0) then {player globalChat format ["FindBody.sqf - _finder:%1 not in EHlistBerg", _finder];};sleep 20;};
    
    
               {
                  if ((alive _x) AND (side _x == EAST)) then
                  {
                     detected = true;
    				 _x setBehaviour "COMBAT"; //NEW
    				 
    				if (_finder distance player < 120 && _finder hasWeapon "ItemRadio") then {
    				 
    				_answer = ["s0", "s01", "s02", "s03", "s04"] call BIS_fnc_selectRandom;
    				_finder say3d _answer;			 
    				 
    																						};
    																					
    
    if (!action) then {
    		KRON_UPS_reinforcement3 = true;
    		
    if (group _finder == tksf2_G OR group _finder == tksf3_G OR group _finder ==  shktrp) then 
    {
    			KRON_UPS_reinforcement3_pos = getPos player;
    		    if (mein_debug>0) then { player globalChat format ["FindBody.sqf - KRON_UPS_reinforcement3_pos - player"];};
    } else 
    {
    		if (mein_debug>0) then { player globalChat format ["FindBody.sqf - KRON_UPS_reinforcement3_pos - deadguy:%1", _deadguy];};
    		KRON_UPS_reinforcement3_pos = _deadguypos;		
    };
    		
    					};
    
    												
    
             if (radioObj) then {
    
    		KRON_UPS_reinforcement0 = true; 
    		KRON_UPS_reinforcement0_pos = _deadguypos;
    
    							if (mein_debug>0) then { 
      player globalChat format ["FindBody.sqf - KRON_UPS_reinforcement0_pos - deadguy:%1", _deadguy];
    												};
    			     };
    
    
    		sleep 60;
            _x setBehaviour "AWARE"; //NEW
    
    		if (!isNull _deadguy) then {
    
    				hidebody _deadguy; sleep 5; deletevehicle _deadguy;
    				
    				                if (mein_debug>0) then {player globalChat "FindBody.sqf - Deleting Body after detected";};
    				
    									};
    
                  } else {if (mein_debug>0) then {player globalChat format ["FindBody.sqf - deadguy:%1 - all spotters:%2 dead", _deadguy, _spotters];};};
               } forEach _spotters;
    		   
                       } else {
    				   
    				   sleep 120; 
    				   
    				   if (!isNull _deadguy) then { 
    				   
    				   hidebody _deadguy; sleep 5; deletevehicle _deadguy;			   
    				   if (mein_debug>0) then {player globalChat "FindBody.sqf - Deleting Body after !preAlarm";};
    				   
    											};
    				   
    							};		
    } else {
    
    				   sleep 120;
    				   
    				   if (!isNull _deadguy) then { 
    				   
    				  hidebody _deadguy; sleep 5; deletevehicle _deadguy;		   
    				   if (mein_debug>0) then {player globalChat "FindBody.sqf - Deleting Body after isNil _finder";};
    				   
    											};
    											
    		};					
    				
                    if (mein_debug>0) then {player globalChat "FindBody.sqf - END of script";};
    				sleep 5;
                    if (!isNil "_shout1") then {terminate _shout1;group _finder setVariable ["endscript",true];};      

     

     

    The dog should definitely be excluded from _finders, don't want him making radio calls. 😀

    Just did a test and killed everything around the dog, he was in _finders but didn't trigger anything else.

    But it would be nice if he can be a functioning _deadguy who gets detected.

     

    Here is the dog script wthout the CBA lines:

     

    Spoiler
    
    //----------------------------------------------------------------------------------------------------------
    //  Patrulla Perruna | Dog Patrol
    //  Version: 0.0.3
    //  Autor: Monovdd | Carlos Alberto Arango Schutz (monovdd@hotmail.com) 
    //	Creditos: Team Condor | CLA
    //----------------------------------------------------------------------------------------------------------
    //  Notes: This Script is inspired by two other existing scripts, in fact part of the work is taken
    // of the authors of these scripts. Script blitzy (Limitations for multiplayer) and EODD Dog li-
    // mitations in terms of playability.
    //
    // Description: Script that allows you to add a dog to a unit to form a patrol with a dog that
    // Detect and attack nearby enemy soldiers and play sounds of a real dog.
    //----------------------------------------------------------------------------------------------------------
    // Use: Place the following in the init of the soldier dog master:
    //			_nul = [this, "PASTOR",1] execvm "scripts\patrullaperruna.sqf";
    //----------------------------------------------------------------------------------------------------------
    //PROCESS OF INITIALIZATION OF THE SCRIPT. VARIABLES ARE DEFINED
    //----------------------------------------------------------------------------------------------------------
    
    if (Isserver) then {
    
    	_unidad = _this select 0; //unit
    	
    	_RazaDeseada = _this select 1; //gewünschte rasse
    	
    	_cantidad = _this select 2; //menge
    	
    	_bando = side _unidad;
    	
    	_grupo = creategroup _bando;
    	
    	//player globalChat format ["unit:%1 dog:%2 number:%3", _unidad, _RazaDeseada, _cantidad];	//not working-> ANY
    	
    	for "_i" from 1 to _cantidad do {
    
    		_raza = "Pastor";
    
    		switch (_RazaDeseada) do {
    		
    			case "PASTOR":
    			
    			{
    				_raza = "Pastor";
    			};
    		
    			case "FIN":
    			
    			{
    			
    				_raza = "Fin";
    				
    			};
    			
    			default 
    				
    			{ 
    			
    				_raza = "Pastor";
    				
    			};
    
    		};		
    		
    //----------------------------------------------------------------------------------------------------------
    //THE NEW UNIT IS CREATED IN THE GROUP OF THE AMO UNIT. IT IS GIVEN FORMAT.
    //----------------------------------------------------------------------------------------------------------
    		
    		_NombrePerro = format ["k9%1",round (random 1000)];
    		
    		call compile format ['"%2" createUnit [getpos _unidad, _grupo,"%1=this; this setSpeedMode ""NORMAL""; this setbehaviour ""SAFE""",1]',_NombrePerro,_raza];
    		
    		_perro = call compile format ["%1",_NombrePerro];
    			
    		[_perro,_unidad] spawn {
    		
    		_perro = _this select 0;
    		
    		_unidad = _this select 1;
    		
    //----------------------------------------------------------------------------------------------------------
    //THE NEW UNIT IS CREATED IN THE GROUP OF THE AMO UNIT. IT IS GIVEN FORMAT.
    //----------------------------------------------------------------------------------------------------------
    								
    		while {alive _perro} do
    		
    		{	
    		
    //----------------------------------------------------------------------------------------------------------
    //VERIFICATION OF NEARBY ENTITIES
    //----------------------------------------------------------------------------------------------------------		
    
    			_HumanosCerca = [];
    			
    			_HumanosVivos = [];
    			
    			_distancia = 1000;
    			
    			_cercano = objNull;
    					
    			_HumanosCerca = nearestObjects [position _perro, ["man"], 150];
    					
    			{if ((side _perro)getFriend (side _x) <0.6) then {_HumanosVivos = _HumanosVivos + [_x];_perro knowsabout _x; _unidad knowsabout _x;}}forEach _HumanosCerca;					
    
    //----------------------------------------------------------------------------------------------------------
    //ENEMIES NEAR TO BE PERSECUTED. SITUATION MOVEMENT
    //----------------------------------------------------------------------------------------------------------	
    					
    				  		if (count _HumanosVivos >0)  then {							
    
    							_HumanoCercano = _HumanosVivos select 0;	
    														
    							_distancia = (position _perro) distance (_HumanoCercano);
    							
    							_perro setspeedmode "FULL";
    						
    							if ((_distancia > 125) && (_distancia < 150)) then {
    							
    								_perro dowatch _HumanoCercano;	
    								
    								_TipoLadrido = round(random 3);
    	
    								switch (_TipoLadrido) do {
    								
    								case 0:
    							
    								{
    		
    								//[_perro, "ladrido1"] call CBA_fnc_globalSay3d;
    								_perro say3D "ladrido1";
    								
    								};
    								
    								case 1:
    							
    								{
    								
    								//[_perro, "ladrido2"] call CBA_fnc_globalSay3d;
    								_perro say3D "ladrido2";
    								
    								};
    								
    								case 2:
    							
    								{
    								
    								//[_perro, "ladrido3"] call CBA_fnc_globalSay3d;
    								_perro say3D "ladrido3";
    								
    								};
    								
    								case 3:
    							
    								{
    								
    								//[_perro, "ladrido4"] call CBA_fnc_globalSay3d;
    								_perro say3D "ladrido4";
    								
    								};
    								
    								};																																			
    								
    							};							
    							
    							if ((_distancia > 50) && (_distancia < 125)) then {
    							
    								_perro domove position _HumanoCercano;
    								_unidad domove position _perro;
    								_unidad setBehaviour "AWARE";
    								
    								_TipoLadrido = round(random 3);
    	
    								switch (_TipoLadrido) do {
    								
    								case 0:
    							
    								{
    		
    								//[_perro, "ladrido1"] call CBA_fnc_globalSay3d;
    								_perro say3D "ladrido1";
    								
    								};
    								
    								case 1:
    							
    								{
    								
    								//[_perro, "ladrido2"] call CBA_fnc_globalSay3d;
    								_perro say3D "ladrido2";
    								
    								};
    								
    								case 2:
    							
    								{
    								
    								//[_perro, "ladrido3"] call CBA_fnc_globalSay3d;
    								_perro say3D "ladrido3";
    								
    								};
    				
    								case 3:
    							
    								{
    								
    								//[_perro, "ladrido4"] call CBA_fnc_globalSay3d;
    								_perro say3D "ladrido4";
    								};
    								
    								};	
    
    							};
    
    							if ((_distancia > 25) && (_distancia < 50)) then {
    								
    								_perro domove position _HumanoCercano;
    								_unidad domove position _perro;
    								_unidad setBehaviour "COMBAT";
    								
    			//if (mein_debug>0) then {player globalChat format ["patrullaperruna.sqf - %1's dog moving to %2. COMBAT!", _unidad, _HumanoCercano];};
    								
    								_TipoLadrido = round(random 3);
    	
    								switch (_TipoLadrido) do {
    								
    								case 0:
    							
    								{
    		
    								//[_perro, "ladrido1"] call CBA_fnc_globalSay3d;
    								_perro say3D "ladrido1";
    								
    								};
    								
    								case 1:
    							
    								{
    								
    								//[_perro, "ladrido2"] call CBA_fnc_globalSay3d;
    								_perro say3D "ladrido2";
    								
    								};
    								
    								case 2:
    							
    								{
    								
    								//[_perro, "ladrido3"] call CBA_fnc_globalSay3d;
    								_perro say3D "ladrido3";
    								
    								};
    								
    								case 3:
    							
    								{
    								
    								//[_perro, "ladrido4"] call CBA_fnc_globalSay3d;
    								_perro say3D "ladrido4";
    								
    								};
    								
    								};	
    
    							};
    
    							if ((_distancia > 15) && (_distancia < 25)) then {					
    
    								_perro domove position _HumanoCercano;
    								_unidad domove position _perro;
    								_unidad setBehaviour "COMBAT";
    								//_unidad doWatch _HumanoCercano;
    								_unidad reveal [_HumanoCercano, 1.6];
    			//if (mein_debug>0) then {player globalChat format ["patrullaperruna.sqf - %1's dog moving to %2. COMBAT and REVEAL!", _unidad, _HumanoCercano];};
    
    								
    								_TipoLadrido = round(random 3);
    	
    								switch (_TipoLadrido) do {
    								
    								case 0:
    							
    								{
    		
    								//[_perro, "ladrido1"] call CBA_fnc_globalSay3d;
    								_perro say3D "ladrido1";
    								
    								};
    								
    								case 1:
    							
    								{
    								
    								//[_perro, "ladrido2"] call CBA_fnc_globalSay3d;
    								_perro say3D "ladrido2";
    								
    								};
    								
    								case 2:
    							
    								{
    								
    								//[_perro, "ladrido3"] call CBA_fnc_globalSay3d;
    								_perro say3D "ladrido3";
    								
    								};
    								
    								case 3:
    							
    								{
    								
    								//[_perro, "ladrido4"] call CBA_fnc_globalSay3d;
    								_perro say3D "ladrido4";
    								
    								};
    								
    								};	
    
    							};
    							
    							if ((_distancia > 5) && (_distancia < 15)) then {
    
    								_TipoLadrido = round(random 2);
    	
    								switch (_TipoLadrido) do {
    								
    								case 0:
    							
    								{
    		
    								//[_perro, "ladrido1"] call CBA_fnc_globalSay3d;
    								_perro say3D "ladrido1";
    								
    								};
    								
    								case 1:
    							
    								{
    								
    								//[_perro, "ronroneo1"] call CBA_fnc_globalSay3d;
    								_perro say3D "ronroneo1";
    								
    								};
    							
    								case 2:
    							
    								{
    								
    								//[_perro, "ronroneo2"] call CBA_fnc_globalSay3d;
    								_perro say3D "ronroneo2";
    								
    								};
    								
    							
    								};	
    
    								_perro domove position _HumanoCercano;
    								_unidad domove position _perro;
    
    
    							};
    							
    							if ((_distancia > 2) && (_distancia < 5)) then {
    
    								_TipoLadrido = round(random 2);
    	
    								switch (_TipoLadrido) do {
    								
    								case 0:
    							
    								{
    		
    								//[_perro, "ladrido4"] call CBA_fnc_globalSay3d;
    								_perro say3D "ladrido4";
    								
    								};
    								
    								case 1:
    							
    								{
    								
    								//[_perro, "ronroneo1"] call CBA_fnc_globalSay3d;
    								_perro say3D "ronroneo1";
    								
    								};
    								
    								case 2:
    							
    								{
    								
    								//[_perro, "ronroneo2"] call CBA_fnc_globalSay3d;
    								_perro say3D "ronroneo2";
    								
    								};
    								
    							
    								};	
    
    								_perro domove position _HumanoCercano;
    								_unidad domove position _perro;
    								_unidad setBehaviour "AWARE";
    								(group _unidad) setSpeedMode "FULL"; 
    
    							};
    
    							if (_distancia < 2) then {
    							
    									_perro domove position _HumanoCercano;
    									_unidad domove position _perro;
    
    
    								
    								
    //----------------------------------------------------------------------------------------------------------
    //ATTACK SITUATION. DAMAGE IS DEFINED AND THE PROCESS OF DAMAGE
    //----------------------------------------------------------------------------------------------------------
    								
    								if (vehicle _HumanoCercano isKindOf "CAManBase") then { 
    														
    									_ComprobarDanoHumano = getDammage _HumanoCercano;	
    																											
    									_DanoMordisco = _ComprobarDanoHumano + 0.3;
    
    									//[_perro, "mordisco"] call CBA_fnc_globalSay3d;
    									_perro say3D "mordisco";
    									
    										
    									_HumanoCercano setdamage _DanoMordisco;
    
    									_HumanoCercano switchMove "AdthPercMstpSlowWrflDnon_8";
    									
    									//[_HumanoCercano, "grito"] call CBA_fnc_globalSay3d;
    									_perro say3D "grito";
    									
    									sleep 5;
    									
    									_DanoMordisco = "";
    									
    									_HumanoCercano switchMove "";
    									
    									_unidad domove position _perro;
    									_unidad reveal [_HumanoCercano, 4];
    									_unidad doTarget _HumanoCercano;
    								
    									sleep 0.5;
    						
    								};
    								
    //----------------------------------------------------------------------------------------------------------
    //END OF THE ATTACK SITUATION. THE OTHER PROCESSES ARE CLOSED
    //----------------------------------------------------------------------------------------------------------	
    																
    							};
    	
    						};
    						
    				//if (5 > random 10) then {sleep 1;} else {sleep 0.5;};
    				sleep 0.5;
    				
    				
    						
    										   
    //----------------------------------------------------------------------------------------------------------
    //DROPED SITUATION IN THE ATTACK. A GAME LOGIC IS DEFINED TO REPRODUCE SOUNDS
    //----------------------------------------------------------------------------------------------------------	
    
    				if (not alive _perro) then {
    						
    					//Se crea el grupo en el sidelogic para crear el game logic debido a que el comando say no se ejecuta en unidades muertas.
    
    					_GrupoSideLogic = createGroup sideLogic;
    
    
    					//Se crea la unidad en el grupo sidelogic, en este caso la unidad es un gamelogic
    
    
    					_PerroMuerto = _GrupoSideLogic createUnit ["logic", position _perro, [], 0, "none"];
    
    
    					//[_PerroMuerto, "llanto"] call CBA_fnc_globalSay3d; /// OLD
    					
    													_TipoLadrido = round(random 2);
    	
    								switch (_TipoLadrido) do {
    								
    								case 0:
    							
    								{
    		
    								//[_PerroMuerto, "llanto"] call CBA_fnc_globalSay3d;
    								_PerroMuerto say3D "llanto";
    																	
    								};
    								
    								case 1:
    							
    								{
    								
    								//[_PerroMuerto, "llanto1"] call CBA_fnc_globalSay3d;
    								_PerroMuerto say3D "llanto1";
    								};
    								
    								case 2:
    							
    								{
    								
    								//[_PerroMuerto, "llanto2"] call CBA_fnc_globalSay3d;
    								_PerroMuerto say3D "llanto2";
    								};
    								
    							
    								};	
    
    													
    					sleep 5;
    					
    					//Se borra el gamelogic
    
    					deleteVehicle _PerroMuerto
    				};
    								
    //----------------------------------------------------------------------------------------------------------
    //SITUATION MOVEMENT WITH AND TOWARDS THE MASTER. THE POSITION TO WHICH THE DOG WILL MOVE IS MATHEMATICALLY DEFINED
    //----------------------------------------------------------------------------------------------------------	
    
    				_perro domove [(getpos _unidad select 0) - ((random(10)+30)*sin(getdir _unidad - 180)), (getpos _unidad select 1) - ((random(10)+30)*cos(getdir _unidad - 180))];
    
    				_perro setspeedmode "NORMAL";
    				
    			};
    
    //----------------------------------------------------------------------------------------------------------
    //ALL FUNCTIONS, VARIABLES, PROCESSES AND SENTENCES ARE CLOSED.
    //----------------------------------------------------------------------------------------------------------	
    
    			};
    
    		};
    
    	};
    	
    //};	//needed?!
    
    //----------------------------------------------------------------------------------------------------------
    //FIN DEL SCRIPT
    //----------------------------------------------------------------------------------------------------------	

     

     


  15. Quote

    I can only guess about dogs,  they won't be picked up by nearestobjects  as it using "MAN"  they are "ANIMAL"

    I'm not sure they count as animals, since they do appear in the _finders array.

     

    Quote

    Not sure about the error, if you can find out when it happens,  no units or dogs around ect. It's odd because it was defined a line or two before.

    I'm gonna do some more tests later and see if I get it again.


  16. I changed it and it definitely works better now.

     

    Sometimes it fails with this line though:

        if (!isnull _finder or !alive _finder)  then {waituntil{;sleep 1;!alive _finder or _finder distance _deadguypos <4 or isnull _deadguy};};// checks finder status

    The _finder just doesn't get in range after detecting the dead unit.

     

    And I got another problem with my dog patrols.

    In my old scripts the dogs weren't getting detected by the script, which wasn't very realistic.

    Now they are but it gets stuck at the _finders loop.

    What is strange is that they change name in the process, at first something like O 3-1-L:1 and then the name of the object:

    dogpat5fkj7.png

     

    The killedEH is added via trigger w/o sleep, I always thought the dogs are not added because they are spawned, I guess that's not the case.

    Maybe they aren't east but the killedEH is only added for OPFOR units.

    Dogpat script:

    Spoiler
    
    //----------------------------------------------------------------------------------------------------------
    //  Patrulla Perruna | Dog Patrol
    //  Version: 0.0.3
    //  Autor: Monovdd | Carlos Alberto Arango Schutz (monovdd@hotmail.com) 
    //	Creditos: Team Condor | CLA
    //----------------------------------------------------------------------------------------------------------
    //  Notes: This Script is inspired by two other existing scripts, in fact part of the work is taken
    // of the authors of these scripts. Script blitzy (Limitations for multiplayer) and EODD Dog li-
    // mitations in terms of playability.
    //
    // Description: Script that allows you to add a dog to a unit to form a patrol with a dog that
    // Detect and attack nearby enemy soldiers and play sounds of a real dog.
    //----------------------------------------------------------------------------------------------------------
    // Use: Place the following in the init of the soldier dog master:
    //			_nul = [this, "PASTOR",1] execvm "scripts\patrullaperruna.sqf";
    //----------------------------------------------------------------------------------------------------------
    //PROCESS OF INITIALIZATION OF THE SCRIPT. VARIABLES ARE DEFINED
    //----------------------------------------------------------------------------------------------------------
    
    if (Isserver) then {
    
    	_unidad = _this select 0; //unit
    	
    	_RazaDeseada = _this select 1; //gewünschte rasse
    	
    	_cantidad = _this select 2; //menge
    	
    	_bando = side _unidad;
    	
    	_grupo = creategroup _bando;
    	
    	//player globalChat format ["unit:%1 dog:%2 number:%3", _unidad, _RazaDeseada, _cantidad];	//not working-> ANY
    	
    	for "_i" from 1 to _cantidad do {
    
    		_raza = "Pastor";
    
    		switch (_RazaDeseada) do {
    		
    			case "PASTOR":
    			
    			{
    				_raza = "Pastor";
    			};
    		
    			case "FIN":
    			
    			{
    			
    				_raza = "Fin";
    				
    			};
    			
    			default 
    				
    			{ 
    			
    				_raza = "Pastor";
    				
    			};
    
    		};		
    		
    //----------------------------------------------------------------------------------------------------------
    //THE NEW UNIT IS CREATED IN THE GROUP OF THE AMO UNIT. IT IS GIVEN FORMAT.
    //----------------------------------------------------------------------------------------------------------
    		
    		_NombrePerro = format ["k9%1",round (random 1000)];
    		
    		call compile format ['"%2" createUnit [getpos _unidad, _grupo,"%1=this; this setSpeedMode ""NORMAL""; this setbehaviour ""SAFE""",1]',_NombrePerro,_raza];
    		
    		_perro = call compile format ["%1",_NombrePerro];
    			
    		[_perro,_unidad] spawn {
    		
    		_perro = _this select 0;
    		
    		_unidad = _this select 1;
    		
    //----------------------------------------------------------------------------------------------------------
    //THE NEW UNIT IS CREATED IN THE GROUP OF THE AMO UNIT. IT IS GIVEN FORMAT.
    //----------------------------------------------------------------------------------------------------------
    								
    		while {alive _perro} do
    		
    		{	
    		
    //----------------------------------------------------------------------------------------------------------
    //VERIFICATION OF NEARBY ENTITIES
    //----------------------------------------------------------------------------------------------------------		
    
    			_HumanosCerca = [];
    			
    			_HumanosVivos = [];
    			
    			_distancia = 1000;
    			
    			_cercano = objNull;
    					
    			_HumanosCerca = nearestObjects [position _perro, ["man"], 150];
    					
    			{if ((side _perro)getFriend (side _x) <0.6) then {_HumanosVivos = _HumanosVivos + [_x];_perro knowsabout _x; _unidad knowsabout _x;}}forEach _HumanosCerca;					
    
    //----------------------------------------------------------------------------------------------------------
    //ENEMIES NEAR TO BE PERSECUTED. SITUATION MOVEMENT
    //----------------------------------------------------------------------------------------------------------	
    					
    				  		if (count _HumanosVivos >0)  then {							
    
    							_HumanoCercano = _HumanosVivos select 0;	
    														
    							_distancia = (position _perro) distance (_HumanoCercano);
    							
    							_perro setspeedmode "FULL";
    						
    							if ((_distancia > 125) && (_distancia < 150)) then {
    							
    								_perro dowatch _HumanoCercano;	
    								
    								_TipoLadrido = round(random 3);
    	
    								switch (_TipoLadrido) do {
    								
    								case 0:
    							
    								{
    		
    								[_perro, "ladrido1"] call CBA_fnc_globalSay3d;
    								
    								};
    								
    								case 1:
    							
    								{
    								
    								[_perro, "ladrido2"] call CBA_fnc_globalSay3d;
    								
    								};
    								
    								case 2:
    							
    								{
    								
    								[_perro, "ladrido3"] call CBA_fnc_globalSay3d;
    								
    								};
    								
    								case 3:
    							
    								{
    								
    								[_perro, "ladrido4"] call CBA_fnc_globalSay3d;
    								
    								};
    								
    								};																																			
    								
    							};							
    							
    							if ((_distancia > 50) && (_distancia < 125)) then {
    							
    								_perro domove position _HumanoCercano;
    								_unidad domove position _perro;
    								_unidad setBehaviour "AWARE";
    								
    								_TipoLadrido = round(random 3);
    	
    								switch (_TipoLadrido) do {
    								
    								case 0:
    							
    								{
    		
    								[_perro, "ladrido1"] call CBA_fnc_globalSay3d;
    								
    								};
    								
    								case 1:
    							
    								{
    								
    								[_perro, "ladrido2"] call CBA_fnc_globalSay3d;
    								
    								};
    								
    								case 2:
    							
    								{
    								
    								[_perro, "ladrido3"] call CBA_fnc_globalSay3d;
    								
    								};
    				
    								case 3:
    							
    								{
    								
    								[_perro, "ladrido4"] call CBA_fnc_globalSay3d;
    								
    								};
    								
    								};	
    
    							};
    
    							if ((_distancia > 25) && (_distancia < 50)) then {
    								
    								_perro domove position _HumanoCercano;
    								_unidad domove position _perro;
    								_unidad setBehaviour "COMBAT";
    								
    			//if (mein_debug>0) then {player globalChat format ["patrullaperruna.sqf - %1's dog moving to %2. COMBAT!", _unidad, _HumanoCercano];};
    								
    								_TipoLadrido = round(random 3);
    	
    								switch (_TipoLadrido) do {
    								
    								case 0:
    							
    								{
    		
    								[_perro, "ladrido1"] call CBA_fnc_globalSay3d;
    								
    								};
    								
    								case 1:
    							
    								{
    								
    								[_perro, "ladrido2"] call CBA_fnc_globalSay3d;
    								
    								};
    								
    								case 2:
    							
    								{
    								
    								[_perro, "ladrido3"] call CBA_fnc_globalSay3d;
    								
    								};
    								
    								case 3:
    							
    								{
    								
    								[_perro, "ladrido4"] call CBA_fnc_globalSay3d;
    								
    								};
    								
    								};	
    
    							};
    
    							if ((_distancia > 15) && (_distancia < 25)) then {					
    
    								_perro domove position _HumanoCercano;
    								_unidad domove position _perro;
    								_unidad setBehaviour "COMBAT";
    								//_unidad doWatch _HumanoCercano;
    								_unidad reveal [_HumanoCercano, 1.6];
    			//if (mein_debug>0) then {player globalChat format ["patrullaperruna.sqf - %1's dog moving to %2. COMBAT and REVEAL!", _unidad, _HumanoCercano];};
    
    								
    								_TipoLadrido = round(random 3);
    	
    								switch (_TipoLadrido) do {
    								
    								case 0:
    							
    								{
    		
    								[_perro, "ladrido1"] call CBA_fnc_globalSay3d;
    								
    								};
    								
    								case 1:
    							
    								{
    								
    								[_perro, "ladrido2"] call CBA_fnc_globalSay3d;
    								
    								};
    								
    								case 2:
    							
    								{
    								
    								[_perro, "ladrido3"] call CBA_fnc_globalSay3d;
    								
    								};
    								
    								case 3:
    							
    								{
    								
    								[_perro, "ladrido4"] call CBA_fnc_globalSay3d;
    								
    								};
    								
    								};	
    
    							};
    							
    							if ((_distancia > 5) && (_distancia < 15)) then {
    
    								_TipoLadrido = round(random 2);
    	
    								switch (_TipoLadrido) do {
    								
    								case 0:
    							
    								{
    		
    								[_perro, "ladrido1"] call CBA_fnc_globalSay3d;
    								
    								};
    								
    								case 1:
    							
    								{
    								
    								[_perro, "ronroneo1"] call CBA_fnc_globalSay3d;
    								
    								};
    							
    								case 2:
    							
    								{
    								
    								[_perro, "ronroneo2"] call CBA_fnc_globalSay3d;
    								
    								};
    								
    							
    								};	
    
    								_perro domove position _HumanoCercano;
    								_unidad domove position _perro;
    
    
    							};
    							
    							if ((_distancia > 2) && (_distancia < 5)) then {
    
    								_TipoLadrido = round(random 2);
    	
    								switch (_TipoLadrido) do {
    								
    								case 0:
    							
    								{
    		
    								[_perro, "ladrido4"] call CBA_fnc_globalSay3d;
    								
    								};
    								
    								case 1:
    							
    								{
    								
    								[_perro, "ronroneo1"] call CBA_fnc_globalSay3d;
    								
    								};
    								
    								case 2:
    							
    								{
    								
    								[_perro, "ronroneo2"] call CBA_fnc_globalSay3d;
    								
    								};
    								
    							
    								};	
    
    								_perro domove position _HumanoCercano;
    								_unidad domove position _perro;
    								_unidad setBehaviour "AWARE";
    								(group _unidad) setSpeedMode "FULL"; 
    
    							};
    
    							if (_distancia < 2) then {
    							
    									_perro domove position _HumanoCercano;
    									_unidad domove position _perro;
    
    
    								
    								
    //----------------------------------------------------------------------------------------------------------
    //ATTACK SITUATION. DAMAGE IS DEFINED AND THE PROCESS OF DAMAGE
    //----------------------------------------------------------------------------------------------------------
    								
    								if (vehicle _HumanoCercano isKindOf "CAManBase") then { 
    														
    									_ComprobarDanoHumano = getDammage _HumanoCercano;	
    																											
    									_DanoMordisco = _ComprobarDanoHumano + 0.3;
    
    									[_perro, "mordisco"] call CBA_fnc_globalSay3d;		
    										
    									_HumanoCercano setdamage _DanoMordisco;
    
    									_HumanoCercano switchMove "AdthPercMstpSlowWrflDnon_8";
    									
    									[_HumanoCercano, "grito"] call CBA_fnc_globalSay3d;
    
    									sleep 5;
    									
    									_DanoMordisco = "";
    									
    									_HumanoCercano switchMove "";
    									
    									_unidad domove position _perro;
    									_unidad reveal [_HumanoCercano, 4];
    									_unidad doTarget _HumanoCercano;
    								
    									sleep 0.5;
    						
    								};
    								
    //----------------------------------------------------------------------------------------------------------
    //END OF THE ATTACK SITUATION. THE OTHER PROCESSES ARE CLOSED
    //----------------------------------------------------------------------------------------------------------	
    																
    							};
    	
    						};
    						
    				//if (5 > random 10) then {sleep 1;} else {sleep 0.5;};
    				sleep 0.5;
    				
    				
    						
    										   
    //----------------------------------------------------------------------------------------------------------
    //DROPED SITUATION IN THE ATTACK. A GAME LOGIC IS DEFINED TO REPRODUCE SOUNDS
    //----------------------------------------------------------------------------------------------------------	
    
    				if (not alive _perro) then {
    						
    					//Se crea el grupo en el sidelogic para crear el game logic debido a que el comando say no se ejecuta en unidades muertas.
    
    					_GrupoSideLogic = createGroup sideLogic;
    
    
    					//Se crea la unidad en el grupo sidelogic, en este caso la unidad es un gamelogic
    
    
    					_PerroMuerto = _GrupoSideLogic createUnit ["logic", position _perro, [], 0, "none"];
    
    
    					//[_PerroMuerto, "llanto"] call CBA_fnc_globalSay3d; /// OLD
    					
    													_TipoLadrido = round(random 2);
    	
    								switch (_TipoLadrido) do {
    								
    								case 0:
    							
    								{
    		
    								[_PerroMuerto, "llanto"] call CBA_fnc_globalSay3d;
    								
    								};
    								
    								case 1:
    							
    								{
    								
    								[_PerroMuerto, "llanto1"] call CBA_fnc_globalSay3d;
    								
    								};
    								
    								case 2:
    							
    								{
    								
    								[_PerroMuerto, "llanto2"] call CBA_fnc_globalSay3d;
    								
    								};
    								
    							
    								};	
    
    													
    					sleep 5;
    					
    					//Se borra el gamelogic
    
    					deleteVehicle _PerroMuerto
    				};
    								
    //----------------------------------------------------------------------------------------------------------
    //SITUATION MOVEMENT WITH AND TOWARDS THE MASTER. THE POSITION TO WHICH THE DOG WILL MOVE IS MATHEMATICALLY DEFINED
    //----------------------------------------------------------------------------------------------------------	
    
    				_perro domove [(getpos _unidad select 0) - ((random(10)+30)*sin(getdir _unidad - 180)), (getpos _unidad select 1) - ((random(10)+30)*cos(getdir _unidad - 180))];
    
    				_perro setspeedmode "NORMAL";
    				
    			};
    
    //----------------------------------------------------------------------------------------------------------
    //ALL FUNCTIONS, VARIABLES, PROCESSES AND SENTENCES ARE CLOSED.
    //----------------------------------------------------------------------------------------------------------	
    
    			};
    
    		};
    
    	};
    	
    //};	//needed?!
    
    //----------------------------------------------------------------------------------------------------------
    //FIN DEL SCRIPT
    //----------------------------------------------------------------------------------------------------------	

     

    It needs CBA but I think only because it uses call CBA_fnc_globalSay3d; instead of say3d.

     

     

    //EDIT: I got this randomly while testing other stuff and killing units in the process:

    Error in expression

    <ree",objnull];if (_return and (isnull _finder_free)) exitWith {_x setvariable>
      Error position:

    <_finder_free)) exitWith {_x setvariable>
      Error Undefined variable in expression: _finder_free
    File D:\Eigene Dateien\Documents\ArmA 2\missions\OP%20GECKOHUNT%20v3%2e1%2e3%20Final.Takistan\scripts\alarm\FindBody.sqf, line 57


  17. I set everything up but I get:

     

    Error in expression

    <0};sleep 0.1;_return = [_x,_deadguy] call i_see;_finder_free = _x getvariab>
      Error position:

    <call i_see;_finder_free = _x getvariab>
      Error call: Type Script, expected code
    File D:\Eigene Dateien\Documents\ArmA 2\missions\OP%20GECKOHUNT%20v3%2e1%2e3%20Final.Takistan\scripts\alarm\FindBody.sqf, line 53

     

    //EDIT: Nevermind I forgot ; after   i_see =  compile preprocessFile "FNC_line.sqf";

     

     

    And about this part:

     _shout1 spawn {sleep 1; terminate _this};
    group _finder setVariable ["endscript",true]; 

    Do I need to change the sleep? And shouldn't be setVariable inside the spawn?

    Looks like it terminates it after one second even though it should run for a while.

     

    At the end of findBody I've had this to terminate it:

    if (!isNil "_shout1") then {terminate _shout1;group _finder setVariable ["endscript",true];}; 

    Which was working good because it terminates it after the player got detected or not detected and not after x time.

     

    //EDIT:

    I removed the shout lines and it works like before.

    In my first tests the new version seems to work very good.

    But I think there is something wrong when I kill more than one.

    The AI detects the corpse, shout starts but then nothing more happens.

     

    Here is what happens:

    Unit A dies.

    Unit B detects unit A and triggers shout.

    Unit B dies.

    Unit C detects unit A.

    Script only continues with unit B and unit C is in _finders for B instead of beeing the _finder for A and finishing it.

     

    After that the unit runs away most of the time, out of range and I get _finders=[].

    One time a different pat finished the script and not unit C which was 100m far away watching the area still shouting.


  18. Quote

    I agree about the name I don't often use it myself although I thought if you give it a name it uses that instead of default name.

    Sadly not - I have pretty much all units given a name in the editor.

    I think the name returned would be the one set in 'setIdentity' in the description.ext.

     

    Quote

    What happens if a unit is in a vehicle, does it drive to it or is it ignored by script I haven't checked.

    I never checked that because, thank god, I don't have any units in vehicles, except UPSMON reinforcement choppers.

    I had the suspicion that it makes the choppers stuck in rare occasions, but I think that was an UPSMON error, which I fixed.

     

    Quote

    I never really got used to Notepad++ I know it's up to date but I've been using ArmaEdit for so long I end up going back to it.

    It's awesome, you can set it up to work with sqf's and arma stuff.

     

    Quote

    I'm still trying to stop multiple scripts from running and selecting the same unit, if that happens the  first script stalls out as the unit is redirected to another _deadguy, I think it gets stuck in the waituntil and then just exits when _deadguy is hidden after it times out.

    That could in fact be the problem I am having with nothing happening in some situations.


  19. Quote

    sorry missed that one  _finders is an array so it won't work, you could examine the array using foreach)and then display each unit one by one or make an array of names and use that instead of _finders but is it really needed as it all has an impact on speed.

    Nah I'm just gonna leave it as it is.
     

    Quote

    it will work in  here

    if (mein_debug>0) then {player globalChat format ["FindBody.sqf - _finder:%1 detected corpse:%2",name  _finder,name  _deadguy]; };

    Yeah....but I prefer getting the names from the editor than Khairullah Noori, for debugging reasons.

    And I never get an agent from _deadguy or _finder, just from _finders but it's allright they don't seem to do any harm.

    Quote

    just make local  _agnt  no need for global variable. 

    Man I love Notepad++, two clicks and it's changed in all files. 😀

     

    Update:

    Spoiler
    
    _deadguy = _this select 0;
    _killer  = _this select 1;
    
    _remove  = [];
    _finders = [];
    _spotters = [];
    _finder  = objnull;
    _prealarm = false;
    _deadguypos = getpos _deadguy;
    _shout1 = nil;
    
    if (alarm) exitWith {};
    
    _deadguy spawn { sleep 120; _Body_Vultures = [_this] execVM "scripts\crows\BodyVultures.sqf";sleep 400;hidebody _this;sleep 4;deletevehicle _this };// default effect
    
    if (side _deadguy == side _killer OR side _killer == civilian) exitwith {if (mein_debug>0) then { player globalChat format ["FindBody.sqf - _killer:%1 is same side or CIV as _deadguy:%2", _killer, _deadguy]; };};// side check
    
    if (_deadguy in FBList) exitWith {
    sleep 1;
    detected = true; 
    {_x setbehaviour "COMBAT";
    sleep 5;
    _x reveal [player, 0.5];
    } foreach FBlist;
    if (mein_debug>0) then {player globalChat format ["FindBody.sqf - deadguy:%1 in FeruzAbad.", _deadguy];};
    };
    
    while { (!_preAlarm  AND !isnull _deadguy) } do
     { 
     _finders  = [];// clear array for refreshing
     _agnt = []; //test
     
     { _agnt = _agnt +  [agent _x] } foreach agents; //test
    
         {// foreach nearobjects
           if (alive _x AND canmove _x) then {_finders = _finders + [_x]};// build array of alive units
           }  foreach ( nearestObjects [_deadguypos, ["Man"], 100]);// look through units
       
       _finders = _finders - [eagle1,eagle2,sleeper_1,_agnt];// remove elements
       
       if (mein_debug>0) then { player globalChat format ["FindBody.sqf - corpse:%1 _finders:%2", _deadguy, _finders]; };
       
         {// foreach )_finders
    	 
    	 if (random 15 > 10) then {_x lookat _deadguy;sleep 3;_x lookat objnull;_x setformdir random 360};// adjust random to look more or less often
    	 
              if (_x knowsAbout vehicle _deadguy > 0.4) exitWith {
                                                                _x domove _deadguypos;
                                                                  _finder = _x;
    
    																if (mein_debug>0) then {player globalChat format ["FindBody.sqf - _finder:%1 detected corpse:%2", _finder, _deadguy]; };
                                                                     _shout1 = [leader (group _finder), _killer] execVM "scripts\ShoutSound.sqf";    
                                                                };//exitwith  ends loop when finds first guy that knows >0.4
         } foreach _finders;// end foreach _finders
        
    
        if (!isnull _finder or !alive _finder)  then {waituntil{sleep 1;!alive _finder or _finder distance _deadguypos <5 or isnull _deadguy}};// checks finder status
       
        if (!isnull _deadguy and alive _finder) then {  // examine body
    
                 _finder setunitpos "middle";
                   _finder disableAI "MOVE";
                    _finder reveal [player, 1];
                      _preAlarm = true;
    					   if (mein_debug>0) then {player globalChat format ["FindBody.sqf - _preAlarm:%1 for corpse:%2", _preAlarm,  _deadguy]; };
                      };// changes stance if body found  
         sleep 4;
    
         };// end while
        
         // rest of code
    	 
    	 
    	 
    	 if (!isNil "_finder") then {
    
    if (!isnull(_finder) && {!alive _finder} ) then {_finder setunitpos "UP";_finder enableAI "MOVE";};	
    						
    
    
    if (_preAlarm) then {
    /*
    {
    
    if (!isnull(_x) && {!alive _x}) then { _remove = _remove + [_x,Eagle1,Eagle2] };
    
    }  foreach ( nearestObjects [_deadguypos, ["Man"], 50]);
    
    _spotters = nearestObjects [_deadguypos, ["Man"], 50] - _remove;
    */
    	  {
           if (alive _x) then {_spotters = _spotters + [_x]};// build array of alive units
           }  foreach ( nearestObjects [_deadguypos, ["Man"], 50]);// look through units
       
       _spotters = _spotters - [eagle1,eagle2,_agnt];// remove elements,
    
         _preAlarm = false;
    	if (mein_debug>0) then {player globalChat format ["FindBody.sqf - _preAlarm:%1 for corpse:%2", _preAlarm, _deadguy]; };
    
    
        if (_finder in EHlistBerg) then 
        {
    
    	
    // --------------------------------AA_CAMP---------------------------------------------------------	
    	if (_finder in (list Nighttime7_1)) then {
       
    	if (genOff) then { sleep 30; };
    	
    									};
    // -------------------------------------------------------------------------------------------- 
    					
             if (!radioObj) then {sleep (30 + (random 30));} else {sleep (70 + (random 120));};
    
        } else {if (mein_debug>0) then {player globalChat format ["FindBody.sqf - _finder:%1 not in EHlistBerg", _finder];};sleep 20;};
    
    
               {
                  if ((alive _x) AND (side _x == EAST)) then
                  {
                     detected = true;
    				 _x setBehaviour "COMBAT"; //NEW
    				 
    				if (_finder distance player < 120 && _finder hasWeapon "ItemRadio") then {
    				 
    				_answer = ["s0", "s01", "s02", "s03", "s04"] call BIS_fnc_selectRandom;
    				_finder say3d _answer;			 
    				 
    																						};
    																					
    
    if (!action) then {
    		KRON_UPS_reinforcement3 = true;
    		//if (group _finder == tksf2_G OR group _finder == tksf3_G OR group _finder ==  shktrp) //MAYBE ADD THIS
    		KRON_UPS_reinforcement3_pos = _deadguypos;
    					};
    		
    									
      if (mein_debug>0) then { player globalChat format ["FindBody.sqf - KRON_UPS_reinforcement3_pos - deadguy:%1", _deadguy];};
    												
    
             if (radioObj) then {
    
    		KRON_UPS_reinforcement0 = true; 
    		KRON_UPS_reinforcement0_pos = _deadguypos;
    
    							if (mein_debug>0) then { 
      player globalChat format ["FindBody.sqf - KRON_UPS_reinforcement0_pos - deadguy:%1", _deadguy];
    												};
    			     };
    
    
    		sleep 60;
            _x setBehaviour "AWARE"; //NEW
    
    		if !(isNull _deadguy) then {
    
    				hidebody _deadguy; sleep 5; deletevehicle _deadguy;
    				
    				                if (mein_debug>0) then {player globalChat "FindBody.sqf - Deleting Body after detected";};
    				
    									};
    
                  } else {if (mein_debug>0) then {player globalChat format ["FindBody.sqf - deadguy:%1 - all spotters:%2 dead", _deadguy, _spotters];};};
               } forEach _spotters;
    		   
                       } else {
    				   
    				   sleep 120; 
    				   
    				   if (!isNull _deadguy) then { 
    				   
    				   hidebody _deadguy; sleep 5; deletevehicle _deadguy;			   
    				   if (mein_debug>0) then {player globalChat "FindBody.sqf - Deleting Body after !preAlarm";};
    				   
    											};
    				   
    							};		
    } else {
    
    				   sleep 120;
    				   
    				   if (!isNull _deadguy) then { 
    				   
    				  hidebody _deadguy; sleep 5; deletevehicle _deadguy;		   
    				   if (mein_debug>0) then {player globalChat "FindBody.sqf - Deleting Body after isNil _finder";};
    				   
    											};
    											
    		};					
    				
                    if (mein_debug>0) then {player globalChat "FindBody.sqf - END of script";};
    				sleep 5;
                    if (!isNil "_shout1") then {terminate _shout1;group _finder setVariable ["endscript",true];};      

     

    I added the unit which has  move disabled to the remove array, it's sleeper_1.

    Since that was the camp I did most of the tests, it works much better around there now.


  20. Quote

    Although I don't know off hand if it works with DisableAI, you may also need a health check canstand _x other wise you could assign an injured unit

     

    If it does work  then you will either have to add it to the the array pre check condition   or  enableAI "move" before issuing  the  domove, also bring agnt = []; //test  or I think the array will keep expanding every loop

     

    It doesn't work, I tested it with a few triggers in a clean mission file.

    Maybe I'm just gonna remove this unit from the array, since it's the only one and the clipping really looks ugly.

     

    I didn't think about injured units, good idea!

     

    I updated the script in I will test soon.

    Spoiler
    
    _deadguy = _this select 0;
    _killer  = _this select 1;
    
    _remove  = [];
    _finders = [];
    _spotters = [];
    _finder  = objnull;
    _prealarm = false;
    _deadguypos = getpos _deadguy;
    _shout1 = nil;
    
    if (alarm) exitWith {};
    
    _deadguy spawn { sleep 120; _Body_Vultures = [_this] execVM "scripts\crows\BodyVultures.sqf";sleep 400;hidebody _this;sleep 4;deletevehicle _this };// default effect
    
    if (side _deadguy == side _killer OR side _killer == civilian) exitwith {if (mein_debug>0) then { player globalChat format ["FindBody.sqf - _killer:%1 is same side or CIV as _deadguy:%2", _killer, _deadguy]; };};// side check
    
    if (_deadguy in FBList) exitWith {
    sleep 1;
    detected = true; 
    {_x setbehaviour "COMBAT";
    sleep 5;
    _x reveal [player, 0.5];
    } foreach FBlist;
    if (mein_debug>0) then {player globalChat format ["FindBody.sqf - deadguy:%1 in FeruzAbad.", name _deadguy];};
    };
    
    while { (!_preAlarm  AND !isnull _deadguy) } do
     { 
     _finders  = [];// clear array for refreshing
     agnt = []; //test
     
     { agnt = agnt +  [agent _x] } foreach agents; //test
    
         {// foreach nearobjects
           if (alive _x AND canmove _x) then {_finders = _finders + [_x]};// build array of alive units
           }  foreach ( nearestObjects [_deadguypos, ["Man"], 100]);// look through units
       
       _finders = _finders - [eagle1,eagle2,sleeper_1,agnt];// remove elements
       
       if (mein_debug>0) then { player globalChat format ["FindBody.sqf - corpse:%1 _finders:%2", name _deadguy, name _finders]; };
       
         {// foreach )_finders
    	 
    	 if (random 15 > 10) then {_x lookat _deadguy;sleep 3;_x lookat objnull;_x setformdir random 360};// adjust random to look more or less often
    	 
              if (_x knowsAbout vehicle _deadguy > 0.4) exitWith {
                                                                _x domove _deadguypos;
                                                                  _finder = _x;
    
    																if (mein_debug>0) then {player globalChat format ["FindBody.sqf - _finder:%1 detected corpse:%2", name _finder, name _deadguy]; };
                                                                     _shout1 = [leader (group _finder), _killer] execVM "scripts\ShoutSound.sqf";    
                                                                };//exitwith  ends loop when finds first guy that knows >0.4
         } foreach _finders;// end foreach _finders
        
    
        if (!isnull _finder or !alive _finder)  then {waituntil{sleep 1;!alive _finder or _finder distance _deadguypos <5 or isnull _deadguy}};// checks finder status
       
        if (!isnull _deadguy and alive _finder) then {  // examine body
    
                 _finder setunitpos "middle";
                   _finder disableAI "MOVE";
                    _finder reveal [player, 1];
                      _preAlarm = true;
    					   if (mein_debug>0) then {player globalChat format ["FindBody.sqf - _preAlarm:%1 for corpse:%2", _preAlarm,  _deadguy]; };
                      };// changes stance if body found  
         sleep 4;
    
         };// end while
        
         // rest of code
    	 
    	 
    	 
    	 if (!isNil "_finder") then {
    
    if (!isnull(_finder) && {!alive _finder} ) then {_finder setunitpos "UP";_finder enableAI "MOVE";};	
    						
    
    
    if (_preAlarm) then {
    /*
    {
    
    if (!isnull(_x) && {!alive _x}) then { _remove = _remove + [_x,Eagle1,Eagle2] };
    
    }  foreach ( nearestObjects [_deadguypos, ["Man"], 50]);
    
    _spotters = nearestObjects [_deadguypos, ["Man"], 50] - _remove;
    */
    	  {
           if (alive _x) then {_spotters = _spotters + [_x]};// build array of alive units
           }  foreach ( nearestObjects [_deadguypos, ["Man"], 50]);// look through units
       
       _spotters = _spotters - [eagle1,eagle2,agnt];// remove elements,
    
         _preAlarm = false;
    	if (mein_debug>0) then {player globalChat format ["FindBody.sqf - _preAlarm:%1 for corpse:%2", _preAlarm, _deadguy]; };
    
    
        if (_finder in EHlistBerg) then 
        {
    
    	
    // --------------------------------AA_CAMP---------------------------------------------------------	
    	if (_finder in (list Nighttime7_1)) then {
       
    	if (genOff) then { sleep 30; };
    	
    									};
    // -------------------------------------------------------------------------------------------- 
    					
             if (!radioObj) then {sleep (30 + (random 30));} else {sleep (70 + (random 120));};
    
        } else {if (mein_debug>0) then {player globalChat format ["FindBody.sqf - _finder:%1 not in EHlistBerg", _finder];};sleep 20;};
    
    
               {
                  if ((alive _x) AND (side _x == EAST)) then
                  {
                     detected = true;
    				 _x setBehaviour "COMBAT"; //NEW
    				 
    				if (_finder distance player < 120 && _finder hasWeapon "ItemRadio") then {
    				 
    				_answer = ["s0", "s01", "s02", "s03", "s04"] call BIS_fnc_selectRandom;
    				_finder say3d _answer;			 
    				 
    																						};
    																					
    
    if (!action) then {
    		KRON_UPS_reinforcement3 = true;
    		//if (group _finder == tksf2_G OR group _finder == tksf3_G OR group _finder ==  shktrp) //MAYBE ADD THIS
    		KRON_UPS_reinforcement3_pos = _deadguypos;
    					};
    		
    									
      if (mein_debug>0) then { player globalChat format ["FindBody.sqf - KRON_UPS_reinforcement3_pos - deadguy:%1", _deadguy];};
    												
    
             if (radioObj) then {
    
    		KRON_UPS_reinforcement0 = true; 
    		KRON_UPS_reinforcement0_pos = _deadguypos;
    
    							if (mein_debug>0) then { 
      player globalChat format ["FindBody.sqf - KRON_UPS_reinforcement0_pos - deadguy:%1", _deadguy];
    												};
    			     };
    
    
    		sleep 60;
            _x setBehaviour "AWARE"; //NEW
    
    		if !(isNull _deadguy) then {
    
    				hidebody _deadguy; sleep 5; deletevehicle _deadguy;
    				
    				                if (mein_debug>0) then {player globalChat "FindBody.sqf - Deleting Body after detected";};
    				
    									};
    
                  } else {if (mein_debug>0) then {player globalChat format ["FindBody.sqf - deadguy:%1 - all spotters:%2 dead", _deadguy, _spotters];};};
               } forEach _spotters;
    		   
                       } else {
    				   
    				   sleep 120; 
    				   
    				   if (!isNull _deadguy) then { 
    				   
    				   hidebody _deadguy; sleep 5; deletevehicle _deadguy;			   
    				   if (mein_debug>0) then {player globalChat "FindBody.sqf - Deleting Body after !preAlarm";};
    				   
    											};
    				   
    							};		
    } else {
    
    				   sleep 120;
    				   
    				   if (!isNull _deadguy) then { 
    				   
    				  hidebody _deadguy; sleep 5; deletevehicle _deadguy;		   
    				   if (mein_debug>0) then {player globalChat "FindBody.sqf - Deleting Body after isNil _finder";};
    				   
    											};
    											
    		};					
    				
                    if (mein_debug>0) then {player globalChat "FindBody.sqf - END of script";};
    				sleep 5;
                    if (!isNil "_shout1") then {terminate _shout1;group _finder setVariable ["endscript",true];};      

     

     

    One other thing ... I do use

     agnt = []; //test
      agnt = agnt +  [agent _x] } foreach agents; //test

    in two of my other scripts where I use nearestobjects too:

    WestFiredEH - triggers for close units to detect fired shoots (silenced and non silenced).

    bDetect_alarm - bullet hit detection.

     

    Can that be a problem since agnt is a global variable?

     

    //EDIT: I get this for the name thing:

    Error in expression

    < corpse:%1 _finders:%2", name _deadguy, name _finders]; };{if (random 15 > 1>
      Error position:

    <name _finders]; };{if (random 15 > 1>
      Error name: Type Array, expected Object,Location
    File D:\Eigene Dateien\Documents\ArmA 2\missions\OP%20GECKOHUNT%20v3%2e1%2e2%20Final.Takistan\scripts\alarm\FindBody.sqf, line 41

     

    And to get names like Khairullah Noori is not really good for debugging. 😀

×