Jump to content
Sign in to follow this  
Profanwolf

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 =
   [
"spawn1_1",
"spawn1_2", 
"spawn1_3",
"spawn1_4",
"spawn1_5",
       "spawn1_6",
"spawn1_7", 
"spawn1_8",
"spawn1_9",
"spawn1_10",
"spawn1_11",
"spawn1_12", 
"spawn1_13",
"spawn1_14",
"spawn1_15",
       "spawn1_16",
"spawn1_17", 
"spawn1_18",
"spawn1_19",
"spawn1_20",
"spawn1_21",
"spawn1_22", 
"spawn1_23",
"spawn1_24",
"spawn1_25",
       "spawn1_26",
"spawn1_27", 
"spawn1_28",
"spawn1_29",
"spawn1_30",
"spawn1_31",
"spawn1_32",
       "spawn1_33",
"spawn1_34", 
"spawn1_35",
"spawn1_36",
"spawn1_37"
   ];

   InfUnitArray =
   [
"Profiteer1",
"Rocker1", 
"Villager1",
"Woodlander1",
"Worker3",
       "Worker4",
"Priest", 
"Policeman",
"Pilot",
"Functionary1",
"TK_CIV_Takistani03_EP1",
"TK_CIV_Takistani05_EP1",
"TK_CIV_Worker01_EP1",
"TK_CIV_Takistani05_EP1"
   ];

   lightVehArray =
   [
"Ikarus_TK_CIV_EP1",
"Lada1_TK_CIV_EP1", 
"UAZ_Unarmed_TK_CIV_EP1",
"VolhaLimo_TK_CIV_EP1",
"S1203_TK_CIV_EP1",
"Old_bike_TK_CIV_EP1",
"Lada1_TK_CIV_EP1"
   ];

   startWave = true;
   publicVariable "startWave";

};

   execVM "td_scripts\begin.sqf";

Heres my begin.sqf code.

lastInf = "spawn1_1";
curMoney = 0;

waituntil{startWave};
//begin wave 1.

if(isServer)
then{
 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.

random_lightveh.sqf


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

 while{lastInf == _SpawnPos}
  do{
    _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  

×