Calling a function from a trigger in Arma 3 can be very tricky, this is how I managed to do it.
commanderDead = { ['task2','SUCCEEDED'] call BIS_fnc_taskSetState; { _x setMarkerPos getPos house1; } forEach ["hqMarker", "hqCircle"]; [player, player, opfor, ["LOP_AFR_OPF_Infantry_IED","LOP_AFR_OPF_Infantry_Corpsman","LOP_AFR_OPF_Infantry_GL","LOP_AFR_OPF_Infantry_Rifleman_4","LOP_AFR_OPF_Infantry_Rifleman_4","LOP_AFR_OPF_Infantry_AR_Asst_2","LOP_AFR_OPF_Infantry_AT","LOP_AFR_OPF_Infantry_Rifleman_8","LOP_AFR_OPF_Infantry_Rifleman_5"], 16, 120] spawn BIS_fnc_spawnEnemy; private _attack = [] spawn KER_fnc_attackers; }; man2 = createTrigger ["EmptyDetector", Loc]; man2 setTriggerArea [20, 20, 0, false]; man2 settriggerText ""; man2 setTriggerActivation ["NONE", "PRESENT", false]; man2 setTriggerStatements ["!alive commandant","thistrigger call commanderDead;",""]; |
This calls a function when the commander in the HQ is dead.
This is the fn_attackers function that is called by the [] spawn KER_fnc_attackers statement.
#define ASSUALTERS "rhsgref_group_chdkz_infantry_aa","rhsgref_group_chdkz_infantry_at","rhsgref_group_chdkz_infantry_mg","rhsgref_group_chdkz_infantry_patrol","rhsgref_group_chdkz_insurgents_squad" _enemiesArray = [grpNull]; for "_x" from 1 to 5 do { _patrolGroup = createGroup east; _randomPosInf = [Loc, 1, 900, 3, 0, 8, 0] call BIS_fnc_findSafePos; _patrolGroup = [_randomPosInf, EAST, (configfile >> "CfgGroups" >> "East" >> "rhsgref_faction_chdkz" >> "rhsgref_group_chdkz_insurgents_infantry" >> [ASSUALTERS] call BIS_fnc_selectRandom)] call BIS_fnc_spawnGroup; [_patrolGroup, 5, true] call BIS_fnc_EXP_camp_balanceGroup; [_patrolGroup, [getPos house1, 200, 200, 0, false]] call CBA_fnc_taskSearchArea; _enemiesArray = _enemiesArray + [_patrolGroup]; _patrolGroup enableDynamicSimulation true; }; |
Calling a function in the commanderDead inline function with spawn instead of call is the key. This runs a function from a function and allows spawning enemies when something happens in the mission. The fn_attackers function selects a random type of enemy squad and sends them to attack the HQ.
How to wait until 3 triggers are activated.
waitUntil { sleep 3; ((triggeractivated adt) && (triggeractivated tower2) && (triggeractivated man2)) }; |
The code above will wait until 3 triggers have activated before continuing on and running more code. This would be very useful for a scripted mission.