Jump to content
Sign in to follow this  

Keeping AI from dismounting?

Recommended Posts

Alright, so i'm making a silly mission where the players fend off a horde of approaching ai units, but these ai units won't attack, only move towards the player "perimeter", so for each unit you kill you get about 100 points that you can use to buy weapons and vehicles to better defend the area, with each wave there are more enemies and more vehicles, and eventually heavier vehicles.

Only major problem i have right now is, keeping the ai units from dismounting from the vehicle they are put in.

Heres my init.sqf

if !(isServer) then {waitUntil {!isNull(player)}};

if (isServer) then
   startWave = false;
   publicVariable "startWave";

   SpawnPosArray =

   InfUnitArray =

   lightVehArray =

   startWave = true;
   publicVariable "startWave";


   execVM "td_scripts\begin.sqf";

Heres my begin.sqf code.

lastInf = "spawn1_1";
curMoney = 0;

//begin wave 1.

 for "_x" from 0 to 20 do{
  execVM "td_scripts\random_inf.sqf";
  execVM "td_scripts\random_lightveh.sqf";


The wave system will be made functional, i'm just trying to make so the units dont dismount first.


_SpawnPos = SpawnPosArray call BIS_fnc_selectRandom;
_Unit = InfUnitArray call BIS_fnc_selectRandom;
_lightVeh = lightVehArray call BIS_fnc_selectRandom;

 while{lastInf == _SpawnPos}
    _SpawnPos = SpawnPosArray call BIS_fnc_selectRandom;

 _pos = getMarkerPos _SpawnPos;
 lastInf = _SpawnPos;

  _infgroup = createGroup resistance;

  _lightCar = createVehicle [_lightVeh, [(_pos) select 0,(_pos) select 1,0], [], 0, "FLY"];

  _inf = _infgroup createUnit [_Unit,_pos,[], 0, "CAN_COLLIDE"];  
  _inf setBehaviour "CARELESS"; 

  _inf moveInDriver _lightCar;
    _lightCar lock true;
    _lightCar setVehicleLock "LOCKED";
    _lightCar lockDriver true;

 _index1 = _inf addMPEventHandler ["mpkilled", {Null = _this execVM "td_scripts\inf_killed.sqf";}]; 
 _index2 = _lightCar addMPEventHandler ["mpkilled", {Null = _this execVM "td_scripts\lightveh_killed.sqf";}]; 

  _wp = _infgroup addWaypoint [getmarkerpos "target", 0];
   _wp setWaypointSpeed "FULL";
    _wp setWaypointType "MOVE";
     _wp setWaypointBehaviour "CARELESS";

      waitUntil{_inf distance target < 50};
      endGame = true;
      publicVariable "endGame";
      hint format["Endgame: %1",curMoney];

Also the troubles of the ai lying down when shot at, a way to fix this would also be nice.

Anyone had any experience with this?

Because the ai spawn in the car, then they dismount when shot at, but can't get back in

Well that was a bit silly, it was part of the hardcoded civilian ai apparently, so changing the unit to a soldier fixed the problem.

Edited by Profanwolf

Share this post

Link to post
Share on other sites

It is annoying when you want to use civs and they keep jumping out of vehicles.

I have fount that if you place this in the units init it should stay in the vehicle.

For the driver already in a car

this addEventHandler ["GETOUT",{_this select 2 moveindriver (_this select 0)} ]

For cargo

this moveInCargo cart;this addEventHandler ["GETOUT",{_this select 2 moveincargo (_this select 0)} ]

cart being the name of the vehicle.

I did a little testing today and this allowfleeing 1 seems to keep a civillian standing even in a fire fight.

Edited by F2k Sel

Share this post

Link to post
Share on other sites

Didn't work, sticking with using military units for now.

Share this post

Link to post
Share on other sites

Strange works every time for me.

Share this post

Link to post
Share on other sites
this addEventHandler ["GETOUT",{_this select 2 moveindriver (_this select 0)} ]

Your solution is the only one that worked for me and I was looking for hours!

Share this post

Link to post
Share on other sites

civilians react differently (FSM in game scripts) than soldiers when fight is near them, so...

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