Jump to content
Casio91Fin

Need vehicle group AI for

Recommended Posts

_MaxActiveAI = 40; 
_MaxAiTeams = 150; 
_TotalSpawned = 0; 
 
TeamLeaders = ["rhs_msv_officer", "rhs_msv_sergeant","rhs_msv_efreitor","rhs_msv_junior_sergeant"]; 
Infantry = ["rhs_msv_rifleman","rhs_msv_grenadier","rhs_msv_LAT","rhs_msv_RShG2","rhs_msv_medic","rhs_msv_machinegunner","rhs_msv_grenadier_rpg","rhs_msv_engineer","rhs_msv_arifleman_rpk","rhs_msv_at","rhs_msv_arifleman"];
LightVeh = ["rhsgref_BRDM2_msv","O_G_Offroad_01_armed_F"];
MedVeh = ["rhs_btr60_msv","rhs_btr70_msv","rhs_btr80_msv","rhs_bmp2k_tv"];
HeavyVeh = ["rhs_t72ba_tv","rhs_t80","rhs_t80a"];
 
while {_TotalSpawned < _MaxAiTeams} do 
{ 
 while {count units east <= _MaxActiveAI - 1 && _TotalSpawned < _MaxAiTeams} do  
 {  
  if (_MaxActiveAI - count units east >= 20) then 
  { 
   for "_x" from 0 to 1 do  
   { 
    New_AI_Team = createGroup [east, true]; 
    AI_Team_Spawn_Pos = [Pos_1, 150, 200, 2, 0, 1] call BIS_fnc_findSafePos; 
    Team_Leader = New_AI_Team createUnit [TeamLeaders select floor (random count TeamLeaders), AI_Team_Spawn_Pos, [], 0, "NONE"];  
    Team_Leader allowFleeing 0; 
    Team_Leader setSkill (0.75 + random 0.25); 
    Team_leader disableAI "AUTOTARGET"; 
    Team_leader disableAI "MINEDETECTION"; 
    sleep .5; 
    for "_x" from 0 to (2 + (floor random 3 + 2)) do  
    { 
     New_Soldier = New_AI_Team createUnit [Infantry select floor (random count Infantry), AI_Team_Spawn_Pos, [], 0 ,"NONE"]; 
     New_Soldier allowFleeing 0.05; 
     New_Soldier setSkill (0.45 + random 0.35); 
     New_Soldier disableAI "AUTOTARGET"; 
     New_Soldier disableAI "MINEDETECTION"; 
    }; 
    sleep .5; 
    New_AI_Team setBehaviour "COMBAT"; 
    New_AI_Team setCombatMode "RED"; 
    _task = round (random 2); 
    switch (_task) do  
    { 
     case 0: {[New_AI_Team, getposATL Pos_1] call BIS_fnc_taskAttack;}; 
     case 1: {createGuardedPoint [east, Pos_1, -1, objNull]; _wp1 = New_AI_Team addWaypoint [Pos_1, random 120 + 80]; _wp1 setWaypointType "GUARD"; _wp1 setWaypointCompletionRadius 10;};
     default {[New_AI_Team, getposATL Pos_1] call BIS_fnc_taskAttack;}; 
    };     
    _TotalSpawned = _TotalSpawned + 1;  
   }; 
   hintSilent format ["Enemy Team Spawned: %1 / %2", _TotalSpawned, _MaxAiTeams]; 
  }; 
  if (_TotalSpawned >= _MaxAiTeams) then  
  { 
   hint "The last enemy team was born. Find and destroy them. No survivors!"; 
   playmusic "leadtrack02_f_epb"; 
   waitUntil {{alive _x && (side _x) == east} count allUnits == 0}; 
   sleep 1; 
   playSound "Beep"; 
   sleep 1.5; 
   playSound "Beep"; 
   sleep 1.5; 
   playSound "Beep"; 
   sleep 1.5; 
   playSound "Beep"; 
   sleep 1.5; 
   "END1" call BIS_fnc_endMission; 
  };   
 }; 
 sleep 60; 
};

How to add a vehicle by choosing one of three different vehicle types at random

Share this post


Link to post
Share on other sites

Honestly it would help you if explained it a bit more what do you need help with.
 

1 hour ago, Casio91Fin said:

How to add a vehicle by choosing one of three different vehicle types at random 

If i understand this correctly it you want to choose random type of vehicle then from there you want to choose random vehicle  if so it should go something like this:
 

LightVeh = ["rhsgref_BRDM2_msv","O_G_Offroad_01_armed_F"];
MedVeh = ["rhs_btr60_msv","rhs_btr70_msv","rhs_btr80_msv","rhs_bmp2k_tv"];
HeavyVeh = ["rhs_t72ba_tv","rhs_t80","rhs_t80a"];

private _randomNumber = (floor random 3);

switch (_randomNumber) do {
	case 1: {
		private _randomLightVeh = selectRandom LightVeh;
		private _lightVeh = createVehicle[_randomLightVeh,position player,[],0,"None"];
	};
	case 2: {
		private _randomMedVeh = selectRandom MedVeh;
		private _MedtVeh = createVehicle[_randomMedVeh,position player,[],0,"None"];
	};
	case 3: {
		private _randomHeavytVeh = selectRandom HeavyVeh;
		private _HeavytVeh = createVehicle[_randomHeavytVeh,position player,[],0,"None"];
	};
	default {systemChat "testing!";};
};

 

Share this post


Link to post
Share on other sites

true i want to choose random vehicles to AI  

Share this post


Link to post
Share on other sites
11 hours ago, Stormmy1950 said:

Honestly it would help you if explained it a bit more what do you need help with.
 

If i understand this correctly it you want to choose random type of vehicle then from there you want to choose random vehicle  if so it should go something like this:
 


LightVeh = ["rhsgref_BRDM2_msv","O_G_Offroad_01_armed_F"];
MedVeh = ["rhs_btr60_msv","rhs_btr70_msv","rhs_btr80_msv","rhs_bmp2k_tv"];
HeavyVeh = ["rhs_t72ba_tv","rhs_t80","rhs_t80a"];

private _randomNumber = (floor random 3);

switch (_randomNumber) do {
	case 1: {
		private _randomLightVeh = selectRandom LightVeh;
		private _lightVeh = createVehicle[_randomLightVeh,position player,[],0,"None"];
	};
	case 2: {
		private _randomMedVeh = selectRandom MedVeh;
		private _MedtVeh = createVehicle[_randomMedVeh,position player,[],0,"None"];
	};
	case 3: {
		private _randomHeavytVeh = selectRandom HeavyVeh;
		private _HeavytVeh = createVehicle[_randomHeavytVeh,position player,[],0,"None"];
	};
	default {systemChat "testing!";};
};

 

 

No need to do that floor random and that switch thing here. This will do the same:

LightVeh = ["rhsgref_BRDM2_msv","O_G_Offroad_01_armed_F"];
MedVeh = ["rhs_btr60_msv","rhs_btr70_msv","rhs_btr80_msv","rhs_bmp2k_tv"];
HeavyVeh = ["rhs_t72ba_tv","rhs_t80","rhs_t80a"];

private _VehCats = [LightVeh, MedVeh, HeavyVeh];

private _randomVeh = selectRandom (selectRandom _VehCats);
private _Veh = createVehicle [_randomVeh, position player, [], 0, "None"];

 

@Casio91Fin But Idk what that categories are for. One could also put all vehicles in one single array:

CasiosVehicles =
[
	"rhsgref_BRDM2_msv","O_G_Offroad_01_armed_F", 
	"rhs_btr60_msv","rhs_btr70_msv","rhs_btr80_msv","rhs_bmp2k_tv",
	"rhs_t72ba_tv","rhs_t80","rhs_t80a"
];

private _randomVeh = selectRandom CasiosVehicles;
private _Veh = createVehicle [_randomVeh, position player, [], 0, "None"];

 

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

×