Jump to content
Sign in to follow this  
clock_x

Script errors with findBody script

Recommended Posts

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?

 

Share this post


Link to post
Share on other sites

       I added an extra line so that it will display correctly and an _  to make it a little clearer
 

Spoiler

 

        _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 setVehicleVarName _NombrePerro;
            
        [_perro,_unidad] spawn {
        
        _perro = _this select 0;


        _unidad = _this select 1;

 

Quote

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

 

No it won't find the dog but that's because the Line of sight seems to ignore Dogs  for some reason, I also checked Knowsabout and that shows 0 for dogs so that won't work either.

 

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

_perror addeventhandler  ect,

 

and then in findbody  between the old script add the bold  lines, it will simply send any close unit to the dog, there are no line of sight checks or knowsabout it's just forcing a unit to move to it.

 

   _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 {

 

 

 

 

 

 

 

 

  • Like 1

Share this post


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

Share this post


Link to post
Share on other sites

Strange as I don't get that error, the only difference seems to be you dropped setvariable down a line,you also had this error

 

Quote

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

 

Quote

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

 

I don't get that either. _finder_free has to be objnull or _deadguy

 

 

I din't know how your adding the eventhandler I don't have that bit of script.  There's another odd line in dogpatrol that makes no sense.

 

{if ((side _perro)getFriend (side _x) <0.6) then {_HumanosVivos = _HumanosVivos + [_x];_perro knowsabout _x; _unidad knowsabout _x;}}forEach _HumanosCerca;

Unless I'm missing something  they should be reveals  as it's should be revealing the human threats to the dog, I need to check that.

Share this post


Link to post
Share on other sites
Quote

I din't know how your adding the eventhandler I don't have that bit of script.

It's just a trigger.

OPFOR present (all untis are inside trigger area)

this

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

Share this post


Link to post
Share on other sites

Maybe I need to test using that, right now I'm just forcing the script to run as it's quicker than having to shoot the units.

 

 

Share this post


Link to post
Share on other sites

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?

 

Share this post


Link to post
Share on other sites

Short answer no but  this should work  (!isnull _this)

I knew they were some sort of animal you may be able to filter them  out using typeof like We do for "pastor" somehow.

It may be better to search the string for the letters AGENT I did it in the past but I'd rather not as it's quite slow.

 

Just thought aren't they Civillian? 

 

Names are not correct just an example of what may work it will need correct filetypes.

if (typeof  _deadguy in ["sheep","hen","cow","goat","ect"]) exitwith {hint "dead animals"};

Share this post


Link to post
Share on other sites
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"};

Share this post


Link to post
Share on other sites

If "ANIMAL" works all well and good, I didn't look at that as they are also being found as "MAN" , it may just be an issue with nesarestobjects that allows it show as "MAN"

 

Also you will need to check if dog still works.

Share this post


Link to post
Share on other sites

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?

Share this post


Link to post
Share on other sites

Excellent I'll take a look later.

Share this post


Link to post
Share on other sites

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?

Share this post


Link to post
Share on other sites

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.

 

Share this post


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

Share this post


Link to post
Share on other sites

Buildings a re a whole new problem,.

The AI don't know they're in a building unless they happen to be using buildingpos for their location.

LOS won't work even if both units are in the building.

 

Share this post


Link to post
Share on other sites

Well let's just ignore houses then. 😀

I'm pretty happy about how it works now anyway.

Thanks again for all your help, really improved that part of my mission by a huge deal.

Share this post


Link to post
Share on other sites

No problem, sometimes I just get interested in a script and like the problem solving side of the game.

As it happens I just found a code that seems to show when a unit is in a building the problem  is deciding when to send a unit to investigate as LOS won't cut it.

 

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.

 

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?

 

 

Share this post


Link to post
Share on other sites
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];};      

 

 

Share this post


Link to post
Share on other sites

Something really odd at my end, all the units close to deadguy suddenly can't see the body only those far away can.

Both my old and new code,  I even replaced the function with a fresh copy and still fails.

 

Oddly though just before script died the odd finder was moving in to a house to body without any code change.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

I think I see an issue, it seems that if a body falls in a certain direct  relative to _finder it can't be seen even though it's only a few meters away. It's as if there's a blind spot.

 

Well it looks like we may be able to adjust the sensitivity  of the function I just need to go back to school and study maths.

Share this post


Link to post
Share on other sites

Try his later version of the los function


 

Spoiler

private ["_a","_b","_dirTo","_eyeD","_eyePb","_eyePa","_eyeDV","_abs","_boolean","_range"];

//who to see or not
_a = _this select 0;

//AI to see or not
_b = _this select 1;

_eyeDV = eyeDirection _a;// WAS SET TO _b
_eyeD = ((_eyeDV select 0) atan2 (_eyeDV select 1));
if (_eyeD < 0) then {_eyeD = 360 + _eyeD};
_dirTo = [_b, vehicle _a] call BIS_fnc_dirTo;
_eyePb = eyePos _b;
_eyePa = if (vehicle _a == _a) then {eyePos _a} else {[getposATL _a select 0,getposATL _a select 1,2]};
_abs = abs(_dirTo - _eyeD);
_range = if (vehicle _a distance _b < 20) then {_abs >= 90 && _abs <= 270} else {_abs >= 60 && _abs <= 240};
if (_range || (lineIntersects [_eyePb, _eyePa]) || (terrainIntersectASL [_eyePb, _eyePa])) then {

_boolean = false;//hintsilent "NOT IN SIGHT";
} else {
_boolean = true;//hintsilent "IN SIGHT";
};
_boolean

 

It seems to work better for me now, I also had to change eyedirection from _b to _a

_a = unit looking

_b = target

 

according to wiki  Returns the direction object is watching (eyes, or a vehicle primary observer).

I can't see why you need to know the direction the targets eyes are pointing so I swapped them

 

Share this post


Link to post
Share on other sites

I found the issue with LOS  

 

 _return = [_x,_deadguy ] call i_see;// returns true if finder _x can see deadguy

change  above to this in findbody

 _return = [_deadguy,_x] call i_see;// returns true if finder _x can see deadguy

 

and in los function change  _a back to _b make it like this

_eyeDV = eyeDirection _b;// WAS SET TO _b

 

It seems to fix the blind spot and unit will go into buildings  easier.

 

 

 

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  

×