Jump to content
Sign in to follow this  
clock_x

Script errors with findBody script

Recommended Posts

9 minutes ago, f2k sel said:

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

Nice! I changed it.

Share this post


Link to post
Share on other sites

Soo I had this happening:

flymuch7nkom.png

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

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

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

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

 

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

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

 

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

 

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

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

Share this post


Link to post
Share on other sites

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

 

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

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

 

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

Share this post


Link to post
Share on other sites
7 minutes ago, f2k sel said:

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

 

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

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

 

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

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

 

So basically I could change this line:

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

to this:

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

 

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

Share this post


Link to post
Share on other sites

 

BIS use vehicle in a odd way  it returns what vehicle the unit is in or the unit if it's on foot.

 

so _deadguy in a chopper named  heli  would look like this

 

hint str (vehicle _deadguy ) ;// would return heli name  

you can also use

 

if (vehicle _deadguy == _deadguy) then {hint "deadguy not in vehicle};

or

if (vehicle _deadguy != _deadguy) then {hint "deadguy is in a vehicle}

or

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

 

I did miss read you post a little,  _deadguy isKindOf "Air" ect are not needed .

 

 

 

Share this post


Link to post
Share on other sites

Alright, I changed it. Here is an update:

 

Spoiler

_deadguy = _this select 0;
_killer  = _this select 1;
_remove  = [];
_finders = [];
_spotters = [];
_finder  = objnull;
_prealarm = false;
_deadguypos = getpos _deadguy;
_shout1 = nil;
_return = false; 
_agnt = []; //agent removal

if (alarm) exitWith {};

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

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

if (side _deadguy == side _killer OR side _killer == civilian) exitwith {if (mein_debug>0) then { player globalChat format ["FindBody.sqf - _killer:%1 is same side or CIV as _deadguy:%2", _killer, _deadguy]; };};// side check

if (_deadguy in FBList) exitWith {
sleep 1;
detected = true; 
{_x setbehaviour "COMBAT";
sleep 5;
_x reveal [player, 0.6];
} foreach FBlist;
if (mein_debug>0) then {player globalChat format ["FindBody.sqf - deadguy:%1 in FeruzAbad.", _deadguy];};
};





while { (!_preAlarm  AND !isnull _deadguy) } do
 { _finders  = [];// clear array for refreshing
   _agnt = []; //agent removal
 
 { _agnt set [count _agnt, agent _x]; } foreach agents; //agent removal
 

     {// foreach nearobjects          
   
       if (alive _x and  canstand _x and !(_x isKindOf "ANIMAL")) then {_finders set [count _finders,_x]};// build array of alive units excluding busy unit
       }  foreach ( nearestObjects [_deadguypos, ["Man"], 100]-[eagle1,eagle2,_agnt,sleeper_1,N6_3]);// look through units and remove unwanted elements 
	   
	      if (mein_debug>0) then { player globalChat format ["FindBody.sqf - corpse:%1 _finders:%2", _deadguy, _finders]; };
    
     {// foreach finders
          //
          
           if (random 15 > 10) then {_x lookat _deadguy;sleep 2;_x lookat objnull;_x setformdir random 360};// forces _x to look in body direction
    
           sleep 0.1;// needs this or error undefined variable
           _return = [_deadguy,_x] call i_see;// returns true if finder _x can see deadguy
          
           _finder_free = _x getvariable ["free",objnull];// check if assigned
		   
		    if (typeof _deadguy == "Pastor" and  (isnull _finder_free)) exitwith  //removed and (typeof _x != "pastor")
																			{
																			_x setvariable ["free",_deadguy];// assigned to deadguy                
                                                                            _x  domove _deadguypos;// _deadguypos;
                                                                            _finder = _x;
																			};//exitwith  ends loop

          if (_return and (isnull _finder_free)) exitWith { //removed and (typeof _x != "pastor")
                                                                            _x setvariable ["free",_deadguy];// assigned to deadguy                
                                                                             _x  domove _deadguypos;// _deadguypos;
                                                                              _finder = _x;
																if (mein_debug>0) then {player sideChat format ["FindBody.sqf - _finder:%1 detected corpse:%2", _finder, _deadguy]; };
                                                                                 //_shout1 = [leader (group _finder), _killer] execVM "scripts\ShoutSound.sqf";
                                                                                 //_shout1 spawn {sleep 1; terminate _this};
                                                                                 //group _finder setVariable ["endscript",true];     
                                                                   };//exitwith  ends loop when finds first guy has line of side                                                   
     } foreach _finders;

    if (!isnull _finder or !alive _finder)  then {waituntil{;sleep 1;!alive _finder or _finder distance _deadguypos <4 or isnull _deadguy};};// checks finder status
        
    if (!isnull _deadguy and alive _finder) then {
			_shout1 = [leader (group _finder), _killer] execVM "scripts\ShoutSound.sqf";
             _finder setunitpos "middle";
               _finder disableAI "MOVE";
                _finder reveal [player, 1]; //NEW WIP                 
                 _finder setvariable ["free",objnull];// reset as unassigned
                  _preAlarm = true;
				  if (mein_debug>0) then {player sideChat format ["FindBody.sqf - _preAlarm:%1 for corpse:%2", _preAlarm, _deadguy]; };
                  };// changes stance if body found                
     sleep 4;
	 
     if (!alive _finder) then {_finder setvariable ["free",objnull]};// reset as unassigned

     };// end while

      _finder enableAI "MOVE";


	 
	 
	 if (!isNil "_finder") then {

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


if (_preAlarm) then {

      {
       if (alive _x) then {_spotters set [count _spotters,_x]};// build array of alive units
       }  foreach ( nearestObjects [_deadguypos, ["Man"], 50]-[eagle1,eagle2,_agnt]);// look through units
   
   //_spotters = _spotters - [eagle1,eagle2,_agnt];// remove elements,

     _preAlarm = false;
	if (mein_debug>0) then {player sideChat format ["FindBody.sqf - _preAlarm:%1 for corpse:%2", _preAlarm, _deadguy]; };


    if (_finder in EHlistBerg) then 
    {

	
// --------------------------------AA_CAMP---------------------------------------------------------	
	if (_finder in NA7list) then {
   
	if (genOff) then { sleep 30; };
	
									};
// -------------------------------------------------------------------------------------------- 
					
         if (!radioObj) then {sleep (30 + (random 30));} else {sleep (70 + (random 120));};

    } else {
	
	if (mein_debug>0) then {player globalChat format ["FindBody.sqf - _finder:%1 not in EHlistBerg - debug sleep", _finder];};
	if (!radioObj) then {sleep (30 + (random 30));} else {sleep (70 + (random 120));};
	
	};


           {
              if ((alive _x) AND (side _x == EAST)) then
              {
                 detected = true;
				 _x setBehaviour "COMBAT"; //NEW
				 
				if (_finder distance player < 120 && _finder hasWeapon "ItemRadio") then {
				 
				_answer = ["s0", "s01", "s02", "s03", "s04"] call BIS_fnc_selectRandom;
				_finder say3d _answer;			 
				 
																						};
																					

if (!action) then {
		KRON_UPS_reinforcement3 = true;
		
if (group _finder == tksf2_G OR group _finder == tksf3_G OR group _finder ==  shktrp) then 
{
			KRON_UPS_reinforcement3_pos = getPos player;
		    if (mein_debug>0) then { player globalChat format ["FindBody.sqf - KRON_UPS_reinforcement3_pos - player"];};
} else 
{
		if (mein_debug>0) then { player globalChat format ["FindBody.sqf - KRON_UPS_reinforcement3_pos - deadguy:%1", _deadguy];};
		KRON_UPS_reinforcement3_pos = _deadguypos;		
};
		
					};

												

         if (radioObj) then {

		KRON_UPS_reinforcement0 = true; 
		KRON_UPS_reinforcement0_pos = _deadguypos;

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


		sleep 60;
        _x setBehaviour "AWARE"; //NEW

		if (!isNull _deadguy) then {

				hidebody _deadguy; sleep 5; deletevehicle _deadguy;
				
				                if (mein_debug>0) then {player globalChat "FindBody.sqf - Deleting Body after detected";};
				
									};

              } else {if (mein_debug>0) then {player globalChat format ["FindBody.sqf - deadguy:%1 - all spotters:%2 dead", _deadguy, _spotters];};};
           } forEach _spotters;
		   
                   } else {
				   
				   sleep 120; 
				   
				   if (!isNull _deadguy) then { 
				   
				   hidebody _deadguy; sleep 5; deletevehicle _deadguy;			   
				   if (mein_debug>0) then {player globalChat "FindBody.sqf - Deleting Body after !preAlarm";};
				   
											};
				   
							};		
} else {

				   sleep 120;
				   
				   if (!isNull _deadguy) then { 
				   
				  hidebody _deadguy; sleep 5; deletevehicle _deadguy;		   
				   if (mein_debug>0) then {player globalChat "FindBody.sqf - Deleting Body after isNil _finder";};
				   
											};
											
		};					
				
                if (mein_debug>0) then {player globalChat "FindBody.sqf - END of script";};
				sleep 5;
                if (!isNil "_shout1") then {terminate _shout1;group _finder setVariable ["endscript",true];};      

 

 

Share this post


Link to post
Share on other sites

Well if you can live with that's great, I did mess about for a while but results were sketchy.

 

 

Share this post


Link to post
Share on other sites

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

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

 

!(chopper in thislist) -> whole AO

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

 

So this triggers if the choppers damage is 1.

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

 

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

Share this post


Link to post
Share on other sites

I find with vehicles you usually have to have a back up plan as you can't rely an AI doing what they should.

 

What I tried to do with FindBody.sqf  was run it once just for one  member of the crew, that works.

It needs a delay to allow it to hit the ground, that bit's  not so simple they get stuck on things.

Then as I think you said it spawns crows (only once now) but they don't end.

That's because units are in the vehicle  and can't be deleted  (not strictly true) you can setpos them out then delete but not always.

That's the  sketchy bit.

 

Even if the game removes them such as in some heli crashes they don't seem to be deleted and you can't force them to become deleted that's why crows keeps running.

What I found was after a set period of time they stop being objects and become something else.

I struggled to find an answer but eventually I found a work around,  if you use

hint str (name _deadguy);//   to get the default name of the unit that  still works as it should

but after 20-30 seconds it changes to    error:no unit (at least in the Grad with 2 crew)

I found I could trap the error and use that to end crows and the main while loop,

 

name _deadguy == "error:no unit";// add that to while loop check line and crows waituntil it seemes to work and they get deleted

 

After all that a Finder is rarely sent to the chopper the Grad is a little better, which makes sense they are harder to see and may not even exist although you can see them still there in the case of the Grad (one of them)

So like I said probably not worth the trouble.

 

 

 

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  

×