Jump to content
Sign in to follow this  
clock_x

Script errors with findBody script

Recommended Posts

I just tried deleting body and get the same but it's not really an error it's just telling you the state of _deadguy it no longer exists.

 

Share this post


Link to post
Share on other sites
1 hour ago, f2k sel said:

I just tried deleting body and get the same but it's not really an error it's just telling you the state of _deadguy it no longer exists.

 

Yes I think there was a different reason why I got detected.

I did a few more test runs and this time it really worked very good.

I just need to test more and then decide what I'm gonna use.

Still getting an agent from time to time though. 😀

 

Something else happening is, pretty often the _deadguy returns null for a while and even gets added vultures, atleast thge debug line tells me that, didn't actually see a null unit get vultures.

Share this post


Link to post
Share on other sites

The only problem with the lookat line is it's being executed every four seconds.

 

OK  tried it another way  fist was to just move the  forced look inside the  and remove original forced look to stop spamming the code.

 

 {// foreach finders
          //
          
           if (random 15 > 10) then {_x lookat _deadguy;hint "looking";sleep 3;_x lookat objnull;_x setformdir random 360};// adjust random to look more or less often

 

another way was to replace knowsabout with an actual line of sight check which seems to be working so units who can't see the dead guy won't be sent to body.

You do get less bodies found but it's more realistic but it still needs more testing as I had one error that I can't replicate.

 

 

 

 

 

 

Share this post


Link to post
Share on other sites
if (random 15 > 10) then {_x lookat _deadguy;hint "looking";sleep 3;_x lookat objnull;_x setformdir random 360};// adjust random to look more or less often

I tested this, it definitely seems to help the AI finding them.

 

I was wondering if I can move

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

inside the loop, since the agents who do appear in the array seem to be added after the script started.

Share this post


Link to post
Share on other sites

it should be fine.

I did notice another issue the following line will never exit if _deadguy is deleted before finder reaches it.

 

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

change to

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

 

I've also noticed an issue where the closest unit is sent to a _deadguy but if a secondu unit is killed it will be sent to the second _deadguy ignoring  first.

I thought about setvariable  but it doesn't really work if two units die at about same time  setvariable isn't up and running so checking for it doesn't work if that makes sense.

 

 

 

 

Share this post


Link to post
Share on other sites
Quote

it should be fine.

I rarely get agents now. I think I only got one since I changed it.

 

Quote

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

I added this.

 

I did some more test runs. Most of the time the AI do detect/know about the dead AI at some point, sometimes from 50-100m range.

But then very often nothing else happens because they don't manage to come in range.

 

Quote

I've also noticed an issue where the closest unit is sent to a _deadguy but if a secondu unit is killed it will be sent to the second _deadguy ignoring  first.

I need to pay more attention to this, never saw it happening. I guess it's not a big issue if the dead guys are next to each other, rather if they are on max range.

In my tests I kill AI next to each other most of the time, need to do some tests with more spacing.

 

My 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;
agnt = []; //test


_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 = agnt +  [agent _x] } foreach agents; //test

     {// foreach nearobjects
       if (alive _x) then {_finders = _finders + [_x]};// build array of alive units
       }  foreach ( nearestObjects [_deadguypos, ["Man"], 100]);// look through units
   
   _finders = _finders - [eagle1,eagle2,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 <4 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;
		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];};      

 

 

Share this post


Link to post
Share on other sites

In my tests agent was being removed form array but if _deadguy  was an agent it would still display agent as it isn't checked for.

 

hint str (nearestobject [_deadguy,"man"]);// will let you know if deadguy is an agent

 

Or 

 

hint str (name (nearestobject [_deadguy,"man"]));// instead of it showing as agent it will report the default character name.

 

or

 

if (mein_debug>0) then {player globalChat format ["FindBody.sqf - deadguy:%1 in FeruzAbad.", name _deadguy];};

 

 

Share this post


Link to post
Share on other sites

I'm pretty sure I the agent from _finders, but it doesn't really matter, it was a 1 in 50 time.

 

The only thing that bothers me right now is if the AI doesn't execute the whole thing around a campfire.

Doesn't look very realistic!

If knowsabout fails in this situation I thought about doing something with my trigger areas.

!alive unit x AND x in campfire list AND campfire inflamed

then reveal x 0.5

Or something like that.

 

Don't really know what to do if the distance check fails.

Going to do more tests on this to see what is happening though.

 

//EDIT:

I've got one situation where a AI is sleeping - then waking up with disableAI "MOVE" because if he moves he clips through the chopper wreck he slept in.

And if it triggers for him as finder nothing happens, because he can't move.

 

About the agents in finder:

agentdijos.png

Can I add name to an array like _finders too?

In this situation only dead units were around.

Share this post


Link to post
Share on other sites

I'm not at PC right now but there is this  https://community.bistudio.com/wiki/canMove

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


while { (!_preAlarm  AND !isnull _deadguy) } do
 { _finders  = [];// clear array for refreshing
 agnt = []; // clear array for refreshing
 
 { 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

 

 

I'm not really following with the array think but I don't think you can use the actual name to address unit's

 

As it's only really a display issue then doing this should work.

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

 

it will only look for the default  name  if it hasn't been named when created.

 

 

 

Share this post


Link to post
Share on other sites
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. 😀

Share this post


Link to post
Share on other sites

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.

 

it will work in  here

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

 

You could easily add any units you want to an exclusion  list and remove it from  the _finders array.

 

just make local  _agnt  no need for global variable. 

 

 

 

 

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

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.

 

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 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.

 

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.

 

 

 

 

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

Ok looks like I sorted the multiple script problem and it seem to work quite well in my script which lacking a lot of your extras.

I've also made this version detect only things the unit can really see although it should be easy to switch that back to knowsabout.

This is using cut down version and uses short time delays for testing, also not using agents so no reference in script.

Test on blank map or rename if you want to try it, there is a second script (function) that does the line of sight check.

 

make sure you mod the init.sqf by adding

         i_see =  compile preprocessFile "FNC_line.sqf";

Spoiler

 

_deadguy = _this select 0;
_killer  = _this select 1;

_remove  = [];
_finders = [];
_finder  = objnull;
_deadguypos = getpos _deadguy;
_prealarm = false;
_return = false;

_deadguy spawn { sleep 3; _Body_Vultures = [_this] execVM "scripts\crows\BodyVultures.sqf";sleep 40;hidebody _this;sleep 4;deletevehicle _this };// default effect

if (side _deadguy == side _killer) exitwith {hint "sides same"};// side check

while { (!_preAlarm  AND !isnull _deadguy) } do
 { _finders  = [];// clear array for refreshing

     {// 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]);// look through units and remove unwanted elements 
    
     {// 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];// assined to deadguy                
                                                                             _x  domove _deadguypos;// _deadguypos;
                                                                              _finder = _x;
                                                                               if (mein_debug>0) then {player globalChat "FindBody.sqf - AI detected body";};
                                                                                _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 that knows >0.4                                                     
     } 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;

     };// end while
     //_finder setVariable ["endscript",false];
      _finder enableAI "MOVE";
      
     player sidechat "done "

 

 

 

 

 

save as fnc_line.sqf
 

Spoiler

 

   private ["_looker","_targ","_dirTo","_eyeD","_eyePb","_eyePa","_eyeDV"];

_return=false;

_looker  = _this select 0;

_targ = _this select 1;

_eyeDV = eyeDirection _targ;
_eyeD = ((_eyeDV select 0) atan2 (_eyeDV select 1));
if (_eyeD < 0) then {_eyeD = 360 + _eyeD};
sleep 1;
_dirTo = [_targ, _looker] call BIS_fnc_dirTo;

_eyePb = eyePos _targ;
_eyePa = eyePos _looker;

if ((abs(_dirTo - _eyeD) >= 90 && (abs(_dirTo - _eyeD) <= 270)) || (lineIntersects [_eyePb, _eyePa]) ||(terrainIntersectASL [_eyePb, _eyePa])) then {
        _return= false; //;hintsilent "NOT IN SIGHT";
} else {_return = true;// hintsilent "IN SIGHT";
};

_return;

 

 

Tested with vehicles and the script does ignore them and only units that can see a body will be sent to it.

If one unit sees two bodies close together it may get sent to both because there are no other units available  which looks quite realistic to me.

 

Also changed how the array is built using set is about 10x faster than +[] also moving    -[eagle1,eagle2]  to the nearesobjects is more efficient.

 

 

 

 

 

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

Not at PC so nothing tested.

 

_shout1 spawn {sleep 1; terminate _this};

group _finder setVariable ["endscript",true];

To be honest I can't remember why it's being spawned or uses a sleep so try it and see which works best.
 

Quote

 

Here is what happens:

Unit A dies.

Unit B detects unit A and triggers shout.

Unit B dies.

Unit C is in _finders and is shouting but doesn't get as far as _finder/detecting.

 

 

 

 

So when A dies B becomes _finder for A but gets killed when moving  and next living unit won't move to either?

Is that's correct ?, if so it's probably due to  _finder setvariable ["free",objnull];// reset as unassigned  not being reset as it depends on _finder being alive.

try moving it to just after the sleep 4;
 

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

or leave as is  (don't remove previous setvariable ["free")  and just add an alive check

Sleep 4;
if (!alive _finder) then {_finder setvariable ["free",objnull]};// reset as unassigned

That may be better as it won't create unnecessary  variables

.

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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

 

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.

 

 

 

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
8 minutes ago, clock_x said:

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

 

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

How do you want them to function in the  code, as _finder or excluded from it.

I've not messed with dogs a  long time so I need to look at that.

 

 

 

Share this post


Link to post
Share on other sites

Well if it's too much hustle I'm fine with them beeing excluded. That's how it worked originally.

Share this post


Link to post
Share on other sites

I can try both maybe have it as an option but a bit pressed for time today.

 

You better post your current findbody script and I'll try and work from that otherwise we'll keep having to convert from mine to yours and run the risk of more errors creeping back in.

Share this post


Link to post
Share on other sites

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
//----------------------------------------------------------------------------------------------------------	

 

 

Share this post


Link to post
Share on other sites

The dog is a little tricky to deal with, you can't really control him as the other script keeps taking over.

I can exclude him by using typeof  so he doesn't get assigned to _deadguy

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

 

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 did change detected to _detected as that would be picked up over multiple scripts.
 

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
_detected = false;// made local was global

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  set [count _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) 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;
                  };// changes stance if body found                
     sleep 4;
    
     if (!alive _finder) then {_finder setvariable ["free",objnull]};// reset as unassigned

     };// end while
 
     hint "all done finding";


 if (!isNil "_finder") then {

if (!isnull(_finder) && {alive _finder} ) then {_finder setunitpos "UP";_finder enableAI "MOVE";_finder setbehaviour "SAFE"; hint "up up and away"};// you had this "!alive finder"
                        


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 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];};     

 

if (_return and (isnull _finder_free) and (typeof _x != "pastor")) exitWith {

 

that is were I added the exclusion for the dog, if you use other dog types then you will need to adjust that line.

It shouldn't be sending message but it will show in arrays with that funny number, I don't think his naming of the dog is working correctly it should be K9 with a random number .

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×