/*
TB_Onslaught
By TwoBad
Attack and Defend a location with AI replacements spawning as required
Param: 0. Attack marker
Param: 1. Array, attacker spawn markers
Param: 2. Array, attcking troops
Array Param: 0. Max number of attackers for attack duration
Array Param: 1. Max number of attackers attacking at any one time
Param: 3. Array, attacking side and units
Param: 4. Array, defender spawn markers
Param: 5. Array, defending troops
Array Param: 0. Max number of defenders for attack duration
Array Param: 1. Max number of defenders defending at any one time
Param: 6. Array, defending side and units
Sides are:
1 = West
2 = East
3 = Resistance
Example call
0 = ["mkrAttack",["Amkr1","Amkr2","Amkr3"],[100,25],[2,1],["Dmkr1","Dmkr2"],[50,10],[1,4],[300,15]] execVM "TB_Onslaught.sqf";
"mkrAttack" - Marker attacking troops head for
["Amkr1","Amkr2","Amkr3"] - Array of attcking side spawn loactions
[100,25] - Array of attacking troop numbers. [Max troop who will spawn during the attack,Troops attacking at any one time]
[2,1] - Array for attacking side and troop type. [Attacking Side,Troop Type]
["Dmkr1","Dmkr2"] - Array of defending side spawn loactions
[50,10] - Array of defending troop numbers. [Max troops who will spawn during the attack,Troops defending at any one time]
[1,4] - Array for defending side and troop type. [Defending Side,Troop Type]
[60,15] - Timings array. [Duration,Delay] Duration is max time the attack will last for. Delay is time between the trigger (or whatever) starting the script and the Defenders spawning,
and then the attack starting. This will give time ig players are on the defending side to get set up
The attack will end when either the attackers have no more troops left of the timer has run out
*/
if (!isServer) exitWith {};
private ["menArray","a","d","westTroops","eastTroops","resTroops","attackingSide","defendingSide","Aside","Dside","Atype","Dtype","westArray","eastArray","attackArray","DmenArray","AmilGroup","DmilGroup"];
Tmarkerpos = getMarkerPos (this select 0);
_Amarkerpos = _this select 1;
_Attackers = _this select 2;
_AmenOptions = _this select 3;
_Dmarkerpos = _this select 4;
_Defenders = _this select 5;
_DmenOptions = _this select 6;
_timings = _this select 7;
_AttackersTotal = _Attackers select 0;
_Attacking = _Attackers select 1;
_Aside = _AmenOptions select 0;
_Atype = _AmenOptions select 1;
_DefendersTotal = _Defenders select 0;
_Defending = _Defenders select 1;
_Dside = _DmenOptions select 0;
_Dtype = _DmenOptions select 1;
_duration = _timings select 0;
_delay = _timings select 1;
// _Of = Officer
// _R = Rifleman
// _Ot = Other (Grenadier, Medic, Sapper, Marksman, Machinegunner, etc)
// *** WEST ***
// MACV-SOG
_MACV_Of = ["vn_b_men_sog_01","vn_b_men_sog_13","vn_b_men_sog_04"];
_MACV_Ot = ["vn_b_men_sog_02","vn_b_men_sog_03","vn_b_men_sog_14","vn_b_men_sog_15","vn_b_men_sog_05","vn_b_men_sog_06","vn_b_men_sog_07","vn_b_men_sog_08","vn_b_men_sog_09","vn_b_men_sog_10","vn_b_men_sog_11","vn_b_men_sog_12","vn_b_men_sog_16","vn_b_men_sog_17","vn_b_men_sog_18","vn_b_men_sog_19","vn_b_men_sog_20","vn_b_men_sog_21"];
// US SF
_USSF_Of = ["vn_b_men_sf_01"];
_USSF_R = ["vn_b_men_sf_11"];
_USSF_Ot = ["vn_b_men_sf_21"];
// LRRP
_LRRP_Of = ["vn_b_men_lrrp_01","vn_b_men_lrrp_02"];
_LRRP_Ot = ["vn_b_men_lrrp_03","vn_b_men_lrrp_04","vn_b_men_lrrp_05","vn_b_men_lrrp_06"];
// US Army
_USArmy_Of = ["vn_b_men_army_01","vn_b_men_army_02"];
_USArmy_Ot = ["vn_b_men_army_03","vn_b_men_army_04","vn_b_men_army_05","vn_b_men_army_06","vn_b_men_army_07","vn_b_men_army_08","vn_b_men_army_09","vn_b_men_army_10","vn_b_men_army_11","vn_b_men_army_12"];
_USArmy_R = ["vn_b_men_army_15","vn_b_men_army_16","vn_b_men_army_17","vn_b_men_army_18","vn_b_men_army_19","vn_b_men_army_20","vn_b_men_army_21"];
// ************
// *** EAST ***
// PAVN - NVA Infantry
_NVA_Inf_Of = ["vn_o_men_nva_01"];
_NVA_Inf_R = ["vn_o_men_nva_02","vn_o_men_nva_03","vn_o_men_nva_04","vn_o_men_nva_05","vn_o_men_nva_06"];
_NVA_Inf_Ot = ["vn_o_men_nva_07","vn_o_men_nva_08","vn_o_men_nva_09","vn_o_men_nva_10","vn_o_men_nva_11","vn_o_men_nva_12","vn_o_men_nva_13","vn_o_men_nva_14"];
// PAVN - NVA Infantry Field
_NVA_Inf_F_Of = ["vn_o_men_nva_15"];
_NVA_Inf_F_R = ["vn_o_men_nva_16","vn_o_men_nva_17","vn_o_men_nva_18","vn_o_men_nva_19","vn_o_men_nva_20"];
_NVA_Inf_F_Ot = ["vn_o_men_nva_21","vn_o_men_nva_22","vn_o_men_nva_23","vn_o_men_nva_24","vn_o_men_nva_25","vn_o_men_nva_26","vn_o_men_nva_27","vn_o_men_nva_28"];
// PAVN - NVA Dac Cong
_NVA_Dac_Of = ["vn_o_men_nva_dc_01"];
_NVA_Dac_R = ["vn_o_men_nva_dc_02","vn_o_men_nva_dc_03","vn_o_men_nva_dc_04","vn_o_men_nva_dc_05","vn_o_men_nva_dc_06"];
_NVA_Dac_Ot = ["vn_o_men_nva_dc_07","vn_o_men_nva_dc_08","vn_o_men_nva_dc_09","vn_o_men_nva_dc_10","vn_o_men_nva_dc_11","vn_o_men_nva_dc_12","vn_o_men_nva_dc_13","vn_o_men_nva_dc_14"];
// PAVN - NVA Infantry 65
_NVA_Inf_65_Of = ["vn_o_men_nva_65_01"];
_NVA_Inf_65_R = ["vn_o_men_nva_65_02","vn_o_men_nva_65_03","vn_o_men_nva_65_04","vn_o_men_nva_65_05","vn_o_men_nva_65_06"];
_NVA_Inf_65_Ot = ["vn_o_men_nva_65_07","vn_o_men_nva_65_08","vn_o_men_nva_65_09","vn_o_men_nva_65_10","vn_o_men_nva_65_11","vn_o_men_nva_65_12","vn_o_men_nva_65_13","vn_o_men_nva_65_14"];
// PAVN - NVA Infantry 65 Field
_NVA_Inf_65_F_Of = ["vn_o_men_nva_65_15"];
_NVA_Inf_65_F_R = ["vn_o_men_nva_65_16","vn_o_men_nva_65_17","vn_o_men_nva_65_18","vn_o_men_nva_65_19","vn_o_men_nva_65_20"];
_NVA_Inf_65_F_Ot = ["vn_o_men_nva_65_21","vn_o_men_nva_65_22","vn_o_men_nva_65_23","vn_o_men_nva_65_24","vn_o_men_nva_65_25","vn_o_men_nva_65_26","vn_o_men_nva_65_27","vn_o_men_nva_65_28"];
// PAVN - NVA Navy
_NVA_N_Of = ["vn_o_men_nva_navy_01"];
_NVA_N_R = ["vn_o_men_nva_navy_02","vn_o_men_nva_navy_03","vn_o_men_nva_navy_04","vn_o_men_nva_navy_05","vn_o_men_nva_navy_06"];
_NVA_N_Ot = ["vn_o_men_nva_navy_07","vn_o_men_nva_navy_08","vn_o_men_nva_navy_09","vn_o_men_nva_navy_10","vn_o_men_nva_navy_11","vn_o_men_nva_navy_12","vn_o_men_nva_navy_13","vn_o_men_nva_navy_14"];
// PAVN - NVA Marines
_NVA_M_Of = ["vn_o_men_nva_marine_01"];
_NVA_M_R = ["vn_o_men_nva_marine_02","vn_o_men_nva_marine_03","vn_o_men_nva_marine_04","vn_o_men_nva_marine_05","vn_o_men_nva_marine_06"];
_NVA_M_Ot = ["vn_o_men_nva_marine_07","vn_o_men_nva_marine_08","vn_o_men_nva_marine_09","vn_o_men_nva_marine_10","vn_o_men_nva_marine_11","vn_o_men_nva_marine_12","vn_o_men_nva_marine_13","vn_o_men_nva_marine_14"];
// Viet Cong - VC Main Force
_VC_M_Of = ["vn_o_men_vc_01"];
_VC_M_R = ["vn_o_men_vc_02","vn_o_men_vc_03","vn_o_men_vc_04","vn_o_men_vc_05","vn_o_men_vc_06"];
_VC_M_Ot = ["vn_o_men_vc_07","vn_o_men_vc_08","vn_o_men_vc_09","vn_o_men_vc_10","vn_o_men_vc_11","vn_o_men_vc_12","vn_o_men_vc_13","vn_o_men_vc_14"];
// Viet Cong - VC Local 1
_VC_L1_Of = ["vn_o_men_vc_local_01"];
_VC_L1_R = ["vn_o_men_vc_local_02","vn_o_men_vc_local_03","vn_o_men_vc_local_04","vn_o_men_vc_local_05","vn_o_men_vc_local_06"];
_VC_L1_Ot = ["vn_o_men_vc_local_07","vn_o_men_vc_local_08","vn_o_men_vc_local_09","vn_o_men_vc_local_10","vn_o_men_vc_local_11","vn_o_men_vc_local_12","vn_o_men_vc_local_13","vn_o_men_vc_local_14"];
// Viet Cong - VC Local 2
_VC_L2_Of = ["vn_o_men_vc_local_15"];
_VC_L2_R = ["vn_o_men_vc_local_16","vn_o_men_vc_local_17","vn_o_men_vc_local_18","vn_o_men_vc_local_19","vn_o_men_vc_local_20"];
_VC_L2_Ot = ["vn_o_men_vc_local_21","vn_o_men_vc_local_22","vn_o_men_vc_local_23","vn_o_men_vc_local_24","vn_o_men_vc_local_25","vn_o_men_vc_local_26","vn_o_men_vc_local_27","vn_o_men_vc_local_28","vn_o_men_vc_local_29","vn_o_men_vc_local_30","vn_o_men_vc_local_31","vn_o_men_vc_local_32"];
// Viet Cong - VC Regional Force
_VC_R_Of = ["vn_o_men_vc_regional_01"];
_VC_R_R = ["vn_o_men_vc_regional_02","vn_o_men_vc_regional_03","vn_o_men_vc_regional_04","vn_o_men_vc_regional_05","vn_o_men_vc_regional_06"];
_VC_R_Ot = ["vn_o_men_vc_regional_07","vn_o_men_vc_regional_08","vn_o_men_vc_regional_09","vn_o_men_vc_regional_10","vn_o_men_vc_regional_11","vn_o_men_vc_regional_12","vn_o_men_vc_regional_13","vn_o_men_vc_regional_14"];
// ************
switch (_Aside) do {
case 1: {
_westTroops = _Atype;
};
case 2: {
_eastTroops = _Atype;
_attackingSide = "east";
};
case 3: {
_resTroops = Atype;
};
};
switch (Dside) do {
case 1: {
_westTroops = _Dtype;
};
case 2: {
_eastTroops = _Dtype;
};
case 3: {
_resTroops = _Dtype;
};
};
// Select Side and Unit Type
// West
switch (_westTroops) do {
case 1: {
// MACV-SOG
_westArray = _MACV_Ot + _MACV_Of;
};
case 2: {
// US SF
_westArray = _USSF_R + _USSF_R + _USSF_Ot + _USSF_Of;
};
case 3: {
// LRRP
_westArray = _LRRP_Ot + _LRRP_Of;
};
case 4: {
// US Army
_westArray = _USArmy_R + _USArmy_R + _USArmy_Ot + _USArmy_Of;
};
};
// East
switch (_eastTroops) do {
case 1: {
// PAVN - NVA Infantry
_eastArray = _NVA_Inf_R + _NVA_Inf_R + _NVA_Inf_Ot + _NVA_Inf_Of;
};
case 2: {
// PAVN - NVA Infantry Field
_eastArray = _NVA_Inf_F_R + _NVA_Inf_F_R + _NVA_Inf_F_Ot + _NVA_Inf_F_Of;
};
case 3: {
// PAVN - NVA Dac Cong
_eastArray = _NVA_Dac_R + _NVA_Dac_R + _NVA_Dac_Ot + _NVA_Dac_Of;
};
case 4: {
// PAVN - NVA Infantry 65
_eastArray = _NVA_Inf_65_R + _NVA_Inf_65_R + _NVA_Inf_65_Ot + _NVA_Inf_65_Of;
};
case 5: {
// PAVN - NVA Infantry 65 Field
_eastArray = _NVA_Inf_65_F_R + _NVA_Inf_65_F_R + _NVA_Inf_65_F_Ot + _NVA_Inf_65_F_Of;
};
case 6: {
// PAVN - NVA Navy
_eastArray = _NVA_N_R + _NVA_N_R + _NVA_N_Ot + _NVA_N_Of;
};
case 7: {
// PAVN - NVA Marines
_eastArray = _NVA_M_R + _NVA_M_R + _NVA_M_Ot + _NVA_M_Of;
};
case 8: {
// Viet Cong - VC Main Force
_eastArray = _VC_M_R + _VC_M_R + _VC_M_Ot + _VC_M_Of;
};
case 9: {
// Viet Cong - VC Local
_eastArray = _VC_L1_R + _VC_L1_R + _VC_L1_Ot + _VC_L1_Of;
};
case 10: {
// Viet Cong - VC Local
_eastArray = _VC_L2_R + _VC_L2_R + _VC_L2_Ot + _VC_L2_Of;
};
case 11: {
// Viet Cong - VC Regional Force
_eastArray = _VC_R_R + _VC_R_R + _VC_R_Ot + _VC_R_Of;
}
};
/*
// Resistance
switch (_resTroops) do {
};
*/
// Select Attackers and Defenders
switch (_Aside) do {
case 1: {
_attackArray = _westArray;
_AmilGroup = createGroup west; // Create new attacking unit group
};
case 2: {
_attackArray = _eastArray;
_AmilGroup = createGroup east; // Create new attacking unit group
};
case 3: {
};
};
switch (_Dside) do {
case 1: {
_DmenArray = _westArray;
_DmilGroup = createGroup west; // Create new defending unit group
};
case 2: {
_DmenArray = _eastArray;
_DmilGroup = createGroup east; // Create new defending unit group
};
case 3: {
};
};
_a = 0;
_d = 0;
// Spawn the required defending units
for "_i" from 0 to _Defending do {
_unitType = _DmenArray select (floor(random(count _DmenArray)));
unitSpawn = getMarkerPos (Dmarkerpos select (floor(random(count _Dmarkerpos))));
_unit = DmilGroup createUnit [unitType, _unitSpawn, [], 12, "NONE"];
unit setDir (unit getDir getMarkerPos (_Amarkerpos select (floor(random(count _Amarkerpos)))));
doStop _unit;
_unit setskill ["courage", 1];
_d = _d + 1;
};
// Wait for attack to start
sleep _delay;
// Set attack end time
_timeOut = time + _duration;
// Spawn the required attacking units
for "_i" from 0 to _Attacking do {
_unitType = _attackArray select (floor(random(count _attackArray)));
unitSpawn = getMarkerPos (Amarkerpos select (floor(random(count _Amarkerpos))));
_unit = AmilGroup createUnit [unitType, _unitSpawn, [], 0, "NONE"];
_unit doMove _Tmarkerpos;
_unit setskill ["courage", 1];
_unit setskill ["endurance", 1];
_a = _a + 1;
};
// Run the attack and replace units as required
while { (_a < _AttackersTotal) && (time < _timeOut) } do {
// Do we need any attacker replacements
if (({alive _x} count (units _AmilGroup)) < _Attacking) then {
_unitType = _attackArray select (floor(random(count _attackArray)));
_unitSpawn = getMarkerPos (_Amarkerpos select (floor(random(count _Amarkerpos))));
_unit = _AmilGroup createUnit [_unitType, _unitSpawn, [], 0, "NONE"];
_unit doMove _Tmarkerpos;
_unit setskill ["courage", 1];
_unit setskill ["endurance", 1];
_a = _a + 1;
};
// Do we need any defender replacements
if ((({alive _x} count (units _DmilGroup)) < _Defending) && ( _d < _DefendersTotal)) then {
_unitType = _DmenArray select (floor(random(count _DmenArray)));
_unitSpawn = getMarkerPos (_Dmarkerpos select (floor(random(count _Dmarkerpos))));
_unit = _DmilGroup createUnit [_unitType, _unitSpawn, [], 5, "NONE"];
_d = _d + 1;
_unit setskill ["courage", 1];
};
Sleep 0.2;
};