Forum Jump :

Author Message

Posts: 1589

Level: Member

Country: pf
Location: Tahiti
Occupation: too many Arma
Age: 60
In-game name: Kobayashi Maru

#178408 Posted at 2015-04-02 00:04        
It would help if you spawn units as long as they dies. And yes, you can run a script with a on act. trigger:
Just put in on act: 0= [] execVm "my_script.sqf"
0 is a handle you don't need to care. [] is empty array parameter but you could use to introduce variables in the script.
execVm means you're writing an sqf (not old sqs) and you "spawn" it. That means this script will run in parallel with others. It's the best thing to do with heavy scenarios.

So, you need to write & add your my_file.sqf in the mission folder (where the mission.sqm is) (or precise path but that doesn't improve anything).
In you sqf file, you can write the same things than in a on act.trigger, and more... Because, you're now in a scheduled script, you can use the waitUntil conditions for example.

First, when you manage triggers in editor and variables in scripts, choose global variables (available for all scripts/triggers/anything) during your mission. A simple rule is: use local variables (beginning with underscore like _my_unit) only in a same script (for a current task with no idea to throw it into another script).

Second, when you write a condition in a trigger. For example !alive JohnDoe && triggerActivated first_trig;
you create an implicit loop checking for this occurrence twice per second. Sometime it's sufficient and it's save FPS, sometime it's far too slow and you can miss a firing of trigger due to other script load. In an sqf, you must write your loop to check an event.

Little script to spawn an opfor group in your map and move it to crash site:
- place 4 (empty or else) markers on map.
- name them spwnred1... spwnred4 (or change names both on map & following script)

in my_script.sqf, write:
_counter = 0;
while {_counter < 10} do {
sleep 2;
scopeName "incoming_bad_guys";
waituntil {{side _x == east && (_x distance (getPosATL helo) < 1200)} count allUnits < 4};
_placered = ["spwnred1", "spwnred2", "spwnred3", "spwnred4"];
_redmen = ["O_Soldier_F","O_Soldier_AR_F","O_recon_M_F","O_soldierU_exp_F","O_Soldier_GL_F","O_recon_exp_F","O_soldierU_exp_F","O_recon_medic_F","O_sniper_F"];
_spwnplacered = _placered select floor (random 4);
_redteam = [getMarkerPos _spwnplacered, east, ["O_Soldier_TL_F",_redmen select 7,_redmen select 8,_redmen select 6,_redmen select floor random 5, _redmen select floor random 5,_redmen select floor random 5,_redmen select floor random 5], [], [], [], [], [], 0] call BIS_fnc_spawnGroup;
_redteam setCombatMode "RED";
_redteam setSpeedMode "FULL";
_redteam allowFleeing 0;
_wp1R1 = _redteam addWaypoint [getPosAtl helo,0];
_wp1R1 setWaypointType "SAD";
_wp1R1 setWaypointBehaviour "AWARE";
_wp1R1 setWaypointCombatMode "RED";
_counter = _counter +1;
breakTo "incoming_bad_guys";

- choose a definite number of spawning teams (10 in this script) or infinite loop with while {true} instead of while {_counter < 10}
- in this script, you spawn a 8 man team each time enemies are less than 4 in 1200 m radius of helo's position. Feel free to add more teams at the same time (copy/paste) and/or spawn them earlier, changing the remaining alive opfor units.
- i randomized some of kinds for my red units. You can simplify. see

If you're interested in heavy paradroped assets and increasing threat, try this mission: Surfing Jaws:

Code goes between code tags......

This post was edited by Foxhound (2015-04-02 20:26, ago)