Jump to content
J.Larsson

How to deal with the Insane amount of abandon vehicles AI spawns leaves behind? [SOLVED]

Recommended Posts

So I use simple Spawn AI module in Arma 3 editor and the module is doing a good job what I want it to do. However.
the AIs abandons the vehicles the moment it is being flipped or something ells, like broken tires.


so my question for the community, how would you resolve this issue.


I am new to editor and bad with scripts, so please, ad instructions how to ad a script or a solutions.

(I did google this question, but they were very old threads, many were abandon or unclear instructions.)

Share this post


Link to post
Share on other sites

(forgot to ad)
I have already set in that when an vehicle explode/destroyed,  it will automatic be removed from the map, but for some reason Bohemia did not ad a functions for abandon / disable vehicles.

Share this post


Link to post
Share on other sites

The question is: what is an abandoned vehicle?
I suggest, a vehicle which had a crew, then crew disembarked and no one embarks after that (no more crew).
You could run a little code like this (initServer.sqf)

[] spawn {
  while {true} do {
    sleep 5;
    {
      if (_x isKindOf "WeaponHolderSimulated") exitWith {};
      _x spawn {
        params ["_veh","_timer","_abandoned"];
        _veh setVariable ["passedClean", TRUE];
        while {alive _veh} do {
          waitUntil {sleep 2; crew _veh isNotEqualTo []};
          waitUntil {sleep 2; crew _veh isEqualTo []};
          _timer = diag_tickTime;
          _abandoned = TRUE;
          while {diag_tickTime < _timer + 60} do { if (crew _veh isNotEqualTo []) then {_abandoned = FALSE}};
          if (_abandoned) then {deleteVehicle _veh};
        };
      };
    } forEach (vehicles select {isNil {_x getVariable "passedClean"}});
  };
};

If a vehicle is abandoned more than 60 sec. it'll be deleted.

 

For flipped vehicles that are some autoflip codes on forum or you can set allowCrewInImmobile (alternative syntax).

I suggest to add:

_veh allowCrewInImmobile [TRUE,TRUE];
or, in MP: [_veh,[TRUE,TRUE]] remoteExec ["allowCrewInImmobile",_veh];

between the 2 waitUntil in my code.

 

  • Like 2
  • Thanks 1

Share this post


Link to post
Share on other sites
2 hours ago, pierremgi said:

The question is: what is an abandoned vehicle?
I suggest, a vehicle which had a crew, then crew disembarked and no one embarks after that (no more crew).
You could run a little code like this (initServer.sqf)


[] spawn {
  while {true} do {
    sleep 5;
    {
      if (_x isKindOf "WeaponHolderSimulated") exitWith {};
      _x spawn {
        params ["_veh","_timer","_abandoned"];
        _veh setVariable ["passedClean", TRUE];
        while {alive _veh} do {
          waitUntil {sleep 2; crew _veh isNotEqualTo []};
          waitUntil {sleep 2; crew _veh isEqualTo []};
          _timer = diag_tickTime;
          _abandoned = TRUE;
          while {diag_tickTime < _timer + 60} do { if (crew _veh isNotEqualTo []) then {_abandoned = FALSE}};
          if (_abandoned) then {deleteVehicle _veh};
        };
      };
    } forEach (vehicles select {isNil {_x getVariable "passedClean"}});
  };
};

If a vehicle is abandoned more than 60 sec. it'll be deleted.

 

For flipped vehicles that are some autoflip codes on forum or you can set allowCrewInImmobile (alternative syntax).

I suggest to add:

_veh allowCrewInImmobile [TRUE,TRUE];
or, in MP: [_veh,[TRUE,TRUE]] remoteExec ["allowCrewInImmobile",_veh];

between the 2 waitUntil in my code.

 


Thank you Pierremigi

i will put this thread on [solved]


a note for other people who enter this thread.
if you see a AI leave the vehicle, and you decide to jump in yourself into it before it despawns,
you will break the script for that one vehicle, and it will not despawn and has to be removed manually.

Share this post


Link to post
Share on other sites
9 hours ago, J.Larsson said:

... and it will not despawn and has to be removed manually.

No. You just have to wait for another 60 sec. without crew.

Share this post


Link to post
Share on other sites
12 minutes ago, pierremgi said:

No. You just have to wait for another 60 sec. without crew.


did i get hit by a bugg then?
i entered Zeus and played around with bombs, and the script did a good jobb,
but if i did anything like, entering the vehicle and exit again, it would not despawn.

regardless, i am very happy  how it works now.

Share this post


Link to post
Share on other sites
12 hours ago, J.Larsson said:

but if i did anything like, entering the vehicle and exit again, it would not despawn.

 

 

Little tweak:

[] spawn {
  while {true} do {
    {
      if (_x isKindOf "WeaponHolderSimulated") exitWith {};
      _x spawn {
        params ["_veh","_timer","_abandoned"];
        _veh setVariable ["passedClean",TRUE];
        while {alive _veh} do {
          waitUntil {sleep 2; crew _veh isNotEqualTo []};
          waitUntil {sleep 2; crew _veh isEqualTo []};
          _timer = diag_tickTime;
          _abandoned = TRUE;
          while {diag_tickTime < _timer + 60} do { if (crew _veh isNotEqualTo []) exitWith {_abandoned = FALSE}};
          if (_abandoned) then {deleteVehicle _veh};
        };
      };
    } forEach (vehicles select {isNil {_x getVariable "passedClean"}}); 
    sleep 5;
  }; 
};

exiting the timer loop could help...  No other clue. Are you sure the entire crew disembarked? You can check for crew _veh in some hints.

I hope this could help further reader. tks for feedback.

 

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

×