DayZ
eAI
HairTwoK 17 Aug, 2021 @ 3:44pm
Dynamic Unit Numbers Per Patrol
I made a minor tweak to the example eAI_init.c provided to allow us to customise the number of units per patrol, here it is if anyone is interested...

Inserted this after the loadout setting:
// IMPORTANT: Set the number of units you want in each patrol ref array<int> patrol_units = {3, 7};

and added a dyn_NUMBER_PER_PATROL to the InitDynamicPatrols:
void InitDynamicPatrols() { for (int i = 0; i < patrol_list.Count(); i++) { string loadout = "SoldierLoadout.json"; // default if (i < patrol_loadouts.Count()) loadout = patrol_loadouts[i]; int dyn_NUMBER_PER_PATROL = NUMBER_PER_PATROL; if (i < patrol_units.Count()) dyn_NUMBER_PER_PATROL = patrol_units[i]; autoptr CustomPatrol pat = new CustomPatrol(patrol_list[i][0], patrol_list[i], loadout, dyn_NUMBER_PER_PATROL, MINR, MAXR, DESPAWNR, RESPAWN_SECONDS); patrols.Insert(pat); pat.UpdateTriggers(); } }
Last edited by HairTwoK; 17 Aug, 2021 @ 3:55pm
< >
Showing 1-4 of 4 comments
fentanyl enjoyer 28 Jan, 2022 @ 8:06pm 
Hey would you mind explaining this any further for me ? Im trying to add a single AI in addition to the groups. To add some sort of "boss".
Frenk 29 Apr, 2022 @ 7:17am 
error - it cant find patrol_units
James 4 Oct, 2022 @ 10:20pm 
override void OnUnitSpawn(eAIBase unit) {
// Uncomment this to give the AI unlimited magazines (new one is added on reload)
unit.SetUnlimitedMags(true);

// You can also do anything you would do in the StartingEquipSetup() for players here

// These lines will add attachments the same way you would for a player. However, the AI must have the M4A1 class in the Loadout.json file already for it to work.
//Weapon_Base weapon = Weapon_Base.Cast(unit.GetItemInHands());
//weapon.GetInventory().CreateAttachment("M4_PlasticHndgrd");
//weapon.GetInventory().CreateAttachment("M4_OEBttstck");
//weapon.GetInventory().CreateAttachment("M4_CarryHandleOptic");
}
};

autoptr array<autoptr eAIDynamicPatrol> patrols = {};

// IMPORTANT: Set the number of units you want in each patrol
ref array<int> patrol_units = {3, 2, 3, 2, 3, 2, 3, 3, 3, 3, 3, 2, 3, 3, 2};

void InitDynamicPatrols() {
for (int i = 0; i < patrol_list.Count(); i++) {
string loadout = "SoldierLoadout.json"; // default
if (i < patrol_loadouts.Count()) loadout = patrol_loadouts;
int dyn_NUMBER_PER_PATROL = NUMBER_PER_PATROL;
if (i < patrol_units.Count()) dyn_NUMBER_PER_PATROL = patrol_units;
autoptr CustomPatrol pat = new CustomPatrol(patrol_list[0], patrol_list, loadout, dyn_NUMBER_PER_PATROL, MINR, MAXR, DESPAWNR, RESPAWN_SECONDS);
patrols.Insert(pat);
pat.UpdateTriggers();
}
}


!!!!!!!!!!!!!!!!!!!!!!! I picked it up halfway up the page all the way to the bottom !!!!!!!!!!!!!!!!


{{{{{{{{{ // IMPORTANT: Set the number of units you want in each patrol
ref array<int> patrol_units = {3, 2, 3, 2, 3, 2, 3, 3, 3, 3, 3, 2, 3, 3, 2}; }}}}}}}}}


{3, 2, 3, 2, 3, 2, 3, 3, 3, 3, 3, 2, 3, 3, 2}; this is because i run a deerisland server with 15 routes
So correspond the numbers with the routes
Commander UTKA 9 Feb, 2023 @ 5:47am 
So, did you manage how to make different number of bots? Is it working?
< >
Showing 1-4 of 4 comments
Per page: 1530 50