Jump to content
avibird 1

Need help to setup a trigger or any other way to delete a vehicle if that vechicle has no movement for a set time period.

Recommended Posts

I am using GAIA as my AI HQ to order around 50% of the enemy units in this mission as well as JEBUS for my respawing needs in the mission. I am using  tanoa as a  map. 

 

GAIA gives the units random waypoints with a set zone and will call in for reinforcements from other units from the same zone or other zones if desired. The issue I'm having is sometimes on Tonka vehicles will get stuck on Bridges or the vehicle group will get a waypoint out of its reach inside a forest or unreachable elevation for a vehicle. 

 

Is there a way I can setup a trigger to delete a vehicle if it is not moving for a set time period like 2 minutes. 

 

Once the vehicle get stuck I would like that vehicle to be deleted. The vechicle will then respawn in and giving random waypoints again in it's set zone . I just don't know how to delete a vehicle if there is no movement from that vehicle in a set time..

Share this post


Link to post
Share on other sites

something like this?

 

if (isServer) then {
  private _coolDown = 20;
  _coolDown spawn {
   params [["_coolDown",10],"_allVehicles"];
   while {true} do {
     _allVehicles = vehicles select {isNil {_x getVariable "vehiclepassed"} && _x isKindOf "landVehicle"};
     {
       [_x,_coolDown] spawn {
         params ["_veh","_coolDown","_pos"];
          while {alive _veh} do {
           waitUntil {uiSleep 2; _pos = getpos _veh; speed _veh < 1};
           uiSleep _coolDown;
           if (speed _veh < 1 && _veh distanceSqr _pos < 25 && !isPlayer driver _veh && currentCommand _veh != "") exitwith {
             {_veh deleteVehicleCrew _x} count crew _veh;
             deleteVehicle _veh;
           };
         };
       };
       _x setVariable ["vehiclePassed",true];
     } forEach _allVehicles;
   };
 };
};

You will not delete empty vehicle, crew just stopped (so waiting for a move order), vehicle driven by player.

 

  • Like 1

Share this post


Link to post
Share on other sites

@pierremgi ty you for you help and the code above but I need it only for cars/Jeeps  not for armor and ACP's 

 

The armor and ACP in the mission use set waypoint patterns and or sentry+ guard waypoints the Jeeps use the GAIA random waypoints that will get stuck at times in the  forests and  high elevations within the zones.

 

I just want it for Jeeps (vechicle) or can it be set for particular vehicles with variable names. That will be the best if I can have it setup to delete vehicles with variable names that get stuck.

Share this post


Link to post
Share on other sites

You can replace _x isKindOf "landVehicle" by _x isKindOf "car"

or

if (isServer) then {
  private _coolDown = 20;
  {
    [_x,_coolDown] spawn {
      params ["_veh","_coolDown","_pos"];
      while {alive _veh} do {
          waitUntil {uiSleep 2; _pos = getpos _veh; speed _veh < 1};
        uiSleep _coolDown;
        if (speed _veh < 1 && _veh distanceSqr _pos < 25 && !isPlayer driver _veh && currentCommand _veh != "") exitwith {
          {_veh deleteVehicleCrew _x} count crew _veh;
          deleteVehicle _veh;
        };
      };
    };
  } forEach [car1,car2,car3];
};

for car1, car2, car3.

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites

@pierremgi you are the man!

thank you again for the help brother. One  question?

Where do I put the code/script in to call it during the mission.

Trigger 

Game logic

Server.init 

ECT.

Share this post


Link to post
Share on other sites

@pierremgi getting a undefined variable error with the code.  I can't get the code to work. I placed it in a trigger game logic and a server.init. 

 

The car type I am using is the Qilin (minigun) with a drive and a Gunner crew and a fire team of 4 that will jump out when the vechicle engages units. 

 

Issues I for see is

 

if the fire team jumps out to engage units the Jeep and crew may hold position and if the time reaches the two minute mark the script will delete the group! 

 

Jebus will delete units at start of mission then respawn them into the mission. when this happens the variable name and custom call sign of the vehicle if you gave one will be deleted.

 

So I don't think it will work using jebus however I still want to get it to work not using jebus only editor placed waypoints so I can make sure most of the waypoints will be in reachable sections of the map however I'm using Tanoa and vehicle sometimes gets stuck on the bridges and can't move to the next waypoint. I would still like to have it work for that reason alone.

 

 

 

 

 

 

Share this post


Link to post
Share on other sites
34 minutes ago, avibird 1 said:

@pierremgi getting a undefined variable error with the code.  I can't get the code to work. I placed it in a trigger game logic and a server.init. 

That' because I gave you an example with car1, car2, car3 which MUST exist. You have to adapt the code to your existing cars (or use my first solution with isKindOf "car")

 

34 minutes ago, avibird 1 said:

The car type I am using is the Qilin (minigun) with a drive and a Gunner crew and a fire team of 4 that will jump out when the vechicle engages units. 

That doesn't matter but if your crew jump out of car, the car is abandoned, not stuck, so out of my script scope.

 

34 minutes ago, avibird 1 said:

Issues I for see is

 

if the fire team jumps out to engage units the Jeep and crew may hold position and if the time reaches the two minute mark the script will delete the group! 

I don't understand

 

34 minutes ago, avibird 1 said:

Jebus will delete units at start of mission then respawn them into the mission. when this happens the variable name and custom call sign of the vehicle if you gave one will be deleted.

That's the Jebus problem but there is some code/script to avoid that. I made and shared my own respawn vehicle script, spent a lot of time on it. As said above, the first solution applies, even with spawned vehicles.

 

 

  • Thanks 1

Share this post


Link to post
Share on other sites

Yes I did name all the Jeeps car1 car2 car3 and took out jebus because of the variable names do not carry over once the units gets spawn into the mission at start. I will look into your respawn script but the reason why I use jebus cuz it has GAIA Incorporated into it and I use that for one of the AI Behavior and reinforcement control in the AO zones.

Share this post


Link to post
Share on other sites

@pierremgi hey brother thank you for the help but it's not adequate for my needs. The general pathfinding and AI driving skills especially on Tanko with the wood bridges are very problematic to say the least. I am just using editor place waypoints for the Jeeps to Ensure a patrol area of the AO with Jeeps. Using random waypoint's just gives more issues then benefits of having random waypoint's generated for this mission. 

 

 

Share this post


Link to post
Share on other sites

For the majority of my missions I use  editor place waypoints and GAIA 

 

https://mccsandbox.fandom.com/wiki/GAIA

Random patrol waypoints and reinforcements set to units under fire.

 

So yes a good bulk of my AI units use random waypoint's generated from Gaia.

 

What do you use for the AI command system for your missions.

Alive DAC EOS ect...

Share this post


Link to post
Share on other sites
24 minutes ago, avibird 1 said:

What do you use for the AI command system for your missions.

Alive DAC EOS ect...

 

Just mine. I'm fond of less mod as possible. Some of them are great: CUP, UNSUNG above all as they come with map + units. IFA3_AIO also.
I created a bunch of modules for helping mission builders, but my scenario don't need this mod.

 

Did you try:

if (isServer) then {
  private _coolDown = 20;
  _coolDown spawn {
    params [["_coolDown",10],"_allVehicles"];
    while {true} do {
      _allVehicles = vehicles select {isNil {_x getVariable "vehiclepassed"} && _x isKindOf "car"};
      {
        [_x,_coolDown] spawn {
          params ["_veh","_coolDown","_pos"];
          while {alive _veh} do {
            waitUntil {uiSleep 2; _pos = getpos _veh; speed _veh < 1};
            uiSleep _coolDown;
            if (speed _veh < 1 && _veh distanceSqr _pos < 25 && !isPlayer driver _veh && currentCommand _veh != "") exitwith {
              {_veh deleteVehicleCrew _x} count crew _veh; deleteVehicle _veh;
            };
          };
        };
        _x setVariable ["vehiclePassed",true];
      } forEach _allVehicles;
    };
  };
};

 

This work for any car (only), edited or spawned. Perhaps you should decrease _cooldown (here 20) for faster deletion.
If not, I'm not sure to understand your parameters, but there is (most of the time), a solution.


 

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

×