I'm still somewhat new to scripting in Arma, and I just wanted to get some opinions on how this script looks to you guys. It's a script that gets called from the serverInit.sqf. The goal is to spawn X number of enemies assaulting a position without spawning 100's of AI at once. I would like to think there's a more efficient way to do this, but I'm not sure what is possible within Arma 3.
*EDIT: Noticed a couple of issues that I fixed. Such as, subtracting from _totalSpawned instead of adding... oops.
// Defines the count of AI that can be in action & how many can ever spawn
_maxActiveAI = 75;
_maxAIToSpawn = 300;
// Group lists
// Squads are MUCH larger. Use them sparingly.
// 10 Tickets per spawn
_squads = [
configfile >> "CfgGroups" >> "East" >> "VN_VC" >> "vn_o_group_men_vc" >> "vn_o_group_men_vc_01",
configfile >> "CfgGroups" >> "East" >> "VN_VC" >> "vn_o_group_men_vc" >> "vn_o_group_men_vc_02"
];
// 4 Tickets per spawn
_teams = [
configfile >> "CfgGroups" >> "East" >> "VN_VC" >> "vn_o_group_men_vc" >> "vn_o_group_men_vc_04",
configfile >> "CfgGroups" >> "East" >> "VN_VC" >> "vn_o_group_men_vc" >> "vn_o_group_men_vc_03"
];
// List of spawn point markers for AI
_spawnMarkers = [
"ai_spawn_1",
"ai_spawn_2",
"ai_spawn_3",
"ai_spawn_4"
];
// List of attack point markers for AI
_attackPoints = [
"ai_attack_1",
"ai_attack_2",
"ai_attack_3",
"ai_attack_4"
];
_totalSpawned = 0;
while {_totalSpawned < _maxAIToSpawn} do
{
while { count units EAST <= _maxActiveAI - 4 && _totalSpawned < _maxAIToSpawn} do
{
_groupToSpawn = objNull;
if( _maxActiveAI - count units EAST >= 10 && random 1 > 0.5) then
{
_groupToSpawn = selectRandom _squads;
_totalSpawned = _totalSpawned + 10;
}
else
{
_groupToSpawn = selectRandom _teams;
_totalSpawned = _totalSpawned + 4;
};
_grp = [getMarkerPos selectRandom _spawnMarkers, EAST, (_groupToSpawn)] call BIS_fnc_spawnGroup;
[_grp, getMarkerPos selectRandom _attackPoints] spawn lambs_wp_fnc_taskAssault;
};
sleep 60;
};