Jump to content
Sign in to follow this  
Gunter Severloh

How to AI Paradrop on trigger?

Recommended Posts

Hey guys,

I have a mission I built for MP, and what I want to do is have an area trigger go off when the enemy in it

are not present basically dead, apon not being present an enemy chopper is created and brings in a new

enemy squad and paradrop them into the area, then fly away and be deleted, kinda of what you see in Evolution Blue.


- trigger triggered,

- enemy not present

- chopper created with enemy squad

- chopper follows waypoint and

- paradrops the squad into the trigger area again,

- flys away and is deleted,

thats basically it.

Now I know how to do triggers and waypoints, but I have no clue on how to create

a script that will create a chopper based on a trigger to paradrop the squad, and be deleted

and then repeated a number of times.

How do I do this and what do I do?

Any help would be really appreciated.

Share this post

Link to post
Share on other sites

54 views and no responses?!

Hmm are you guys trying to help or you just reading for entertainment?

Let me break this down then:

* how do you create a chopper with a squad inside that isn't on the island?

*once created move to location via waypoint and paradrop the squad inside at the final desitnation?

* then fly away and be deleted?

* How do you connect a trigger to a waypoint of a chooper that hasn't been created yet, or isn't there?

When enemy in the trigger isn't present then a chopper is created with enemy squad to fly to the trigger

area and paradrop them.

I know how to make triggers, waypoints but creating a chopper from thin air with a squad I'm assuming there

has to be a chopper

and a squad maybe on the ground in the distance somewhere with a code in their init line to tell them to be

created then move via wayoint once triggered.

I'd assume the trigger would be set to repeatedly.

So I need :

- create unit

- Paradrop

- a definition or something that defines how many times I want this to happen

- then delete unit

I got an idea on all these but have no idea on how to put it together in a script to make it happen.

If I had some example scripts that used a mission for its example like how its setup in the trigger

I could get a good idea on how to implement it into a mission.

Any help would be appreciated, not asking for one to solve the whole equation,

even parts of the list would start something.

Share this post

Link to post
Share on other sites

Create the human units and use createUnit's init parameter to move them into the chopper. For that you will need a handler to the chopper. One way is to use createVehicle when you create the chopper.

You create both, the chopper, and the units, already in the air, using the z part of the position when you call the create functions.

Once you got the chopper flying and loaded, use addWaypoint to make it move over the drop area. In the drop area create a trigger to identify the incoming chopper (depending on the rest of the mission this could be as ease as to check for the kind chopper and side East, or you may need to think something else). Use EAST PRESENT for the trigger condition. The trigger must execute an EJECT order on every cargo position of the vehicle.

It's not hard at all. You just need to deal with the details.

Share this post

Link to post
Share on other sites

saw this post while browsing the forum hunting treasures.

In case you havent already found a solution to this here is my workin (at least in SP editor and self MP) script, i assume it works on dedicated server, but no guarantees, have not yet tested it on dedi.

detailed info in helplines throughout the entire script:

Adapt it to suit your needs, i used it with upsmon.

using editor placed markers but you can make the script create the markers if you rather want that, also i have an extra unneccesary set of markers for the waypoint of the drop heli, since i made it for a mission on fallujah, where i ran into trouble with using patrol markers.. unsure why.

Everytime i tried to

"emptymarkername" setMarkerPos getMarkerPos "bigger_rectangle_marker_for_upsmon_patrol";

emptymarker ended up in lowest left side of map, indicating out of bounds or something.. dunno really, new version fallujah comming soon, will check then if i can delete extra set of WPMarkers.

Anyways it works as it is on fallujah, and any other map, though wp set markers may not be needed for other islands, and can be removed and script modified.. ive just been lazy and not modified it :)

script called from a trigger


// Spawn random group (with random units) and spawn drop heli to go to marker to paradrop and set group on upsmon patrol and send heli back and delete it.
// execute with _null = ["patrolmarker","heliWPmarker"] execVM "spawns\parareinf.sqf";

// name of script:   parareinf.sqf placed in scripts folder in mission folder

_units = [];                         // empty array ready for random troops.
_side = east;                        // side of units spawned.
_headtocity = "centercity";          // editor placed marker to have heli fly into city first then go to paradrop wp ( flyby ;) )
_headtocityrange = 3000;             // set how far away from city center marker flyby will be done at.
_grppatrolmarker = _this select 0;   // marker the paras should patrol
_paradropmarker = _this select 1;    // marker in editor which is wp of heli to drop paras. 
_spawnmarker = "spawnhill";          // editor placed enemy spawning marker far off side in map in editor.
_emergency = 0;                      // if 1 high rate of eject on paras, if 0 then normal

_random = floor(random 11);          // create a random number 0 - 11

// select random start location for drophelo from editor placed empty markers. 0 is always first number
_spawn = ["spawn1", "spawn2", "spawn3", "spawn4", "spawn5", "spawn6", "spawn7", "spawn8", "spawn9", "spawn10", "spawn11"] select _random;

waituntil {!isnil "bis_fnc_init"};   //is function module active?, if not wait for function module to be activated.

// create a group with random members from selected case
if (isServer) then {
   _group = floor(random 4); 

   switch (_group) do {
       case 0: {_units = ["TK_INS_Soldier_AA_EP1", "TK_INS_Soldier_AR_EP1", "TK_INS_Bonesetter_EP1", "TK_INS_Soldier_MG_EP1", "TK_INS_Soldier_2_EP1", "TK_INS_Soldier_EP1", "TK_INS_Soldier_4_EP1", "TK_INS_Soldier_3_EP1", "TK_INS_Soldier_AAT_EP1", "TK_INS_Soldier_AT_EP1", "TK_INS_Soldier_Sniper_EP1", "TK_INS_Soldier_TL_EP1", "TK_INS_Warlord_EP1"];};
       case 1: {_units = ["TK_INS_Soldier_AA_EP1", "TK_INS_Soldier_AR_EP1", "TK_INS_Bonesetter_EP1", "TK_INS_Soldier_MG_EP1", "TK_INS_Soldier_2_EP1", "TK_INS_Soldier_EP1", "TK_INS_Soldier_4_EP1", "TK_INS_Soldier_3_EP1", "TK_INS_Soldier_AAT_EP1", "TK_INS_Soldier_AT_EP1", "TK_INS_Soldier_Sniper_EP1", "TK_INS_Soldier_TL_EP1", "TK_INS_Warlord_EP1"];};
       case 2: {_units = ["TK_INS_Soldier_AA_EP1", "TK_INS_Soldier_AR_EP1", "TK_INS_Bonesetter_EP1", "TK_INS_Soldier_MG_EP1", "TK_INS_Soldier_2_EP1", "TK_INS_Soldier_EP1", "TK_INS_Soldier_4_EP1", "TK_INS_Soldier_3_EP1", "TK_INS_Soldier_AAT_EP1", "TK_INS_Soldier_AT_EP1", "TK_INS_Soldier_Sniper_EP1", "TK_INS_Soldier_TL_EP1", "TK_INS_Warlord_EP1"];};
       case 3: {_units = ["TK_INS_Soldier_AA_EP1", "TK_INS_Soldier_AR_EP1", "TK_INS_Bonesetter_EP1", "TK_INS_Soldier_MG_EP1", "TK_INS_Soldier_2_EP1", "TK_INS_Soldier_EP1", "TK_INS_Soldier_4_EP1", "TK_INS_Soldier_3_EP1", "TK_INS_Soldier_AAT_EP1", "TK_INS_Soldier_AT_EP1", "TK_INS_Soldier_Sniper_EP1", "TK_INS_Soldier_TL_EP1", "TK_INS_Warlord_EP1"];};
   // spawn group - [1,0.45] 1=minimum 1 unit in group - 0.45=45% chance for all others in same case line to be in group
   _spawngroup = [getMarkerpos _spawnmarker, _side, _units, [],[],[0.5,0.8],[],[1,0.45]] call BIS_fnc_spawnGroup;

   // create drophelo with full crew at 100 altitude, setting heli to spawn at high altitude only causes nosedive to fiery death when alot of scripts are running, works fine if not. set 100 to 0 if issues arise in your mission
   _sv = [[getMarkerPos _spawn select 0, getMarkerPos _spawn select 1, 100], random 360, "Mi17_TK_EP1", _side] call BIS_fnc_spawnVehicle;

   // Name the vehicle and group
   _drophelo = _sv select 0;  // vehicle spawned.
   _drophelogrp = _sv select 2;  // group of vehicle so waypoints work.

   // Repair and refuel since heli will slam into ground if alot of scripts are active.
   _drophelo setDammage 0;  // repair
   _drophelo setFuel 1;  // refuel

   // move spawned inf grp in dropheli and let heli know they are cargo.
   {_x assignAsCargo _drophelo} forEach Units _spawngroup; {_x moveInCargo _drophelo} forEach Units _spawngroup;

   // set what height drophelo will fly in: this seems to fix the crash when spawned at altitude
   _drophelo flyInHeight 100;

   // set random skill for all crew _drophelo
   {_x setSkill 0.1 + (random 0.9)} forEach Units _drophelogrp;
   sleep 0.5;  // thinking time.

   _helopilot = (driver _drophelo);  // get pilot of drophelo
   _helopilot setSkill 1;  // set high skill on pilot.

   // for TESTING, player unit enter drop helo for a ridealong, player moveInCargo didnt work, so player testunit is named ridealong in editor
   //ridealong moveInCargo _drophelo;

   //sleep 30;  // pause to allow heli to touch ground and get repaired and refueled, set at 30 for extra buffer incase heavy scriptload. maybe not needed

   // if engineoff and pilot alive, start problems then turn engine on.
   if (!isEngineOn _drophelo AND alive _helopilot) then {
    if (!canMove _drophelo) then {
	    // if damaged repair/refuel
	    _drophelo setDammage 0;  // repair
	    _drophelo setFuel 1;  // refuel
	    sleep 1;
    _helopilot action ["engineOn", vehicle _helopilot];
    //hint "engine is turned on";  // for debug
   //hint "engine was on";  //for debug
   // go to random Position 3000m from center of city marker, flyby..
   _wp0 = _drophelogrp addWaypoint [getMarkerPos _headtocity, _headtocityrange];
   _wp0 setWaypointType "MOVE";
   _wp0 setWaypointSpeed "FULL";
   _wp0 setWaypointBehaviour "AWARE";  // set to "CARELESS" if trouble with enemys distracting heli.
   _wp0 setWaypointFormation "LINE";
   [_drophelogrp,0] setWaypointStatements ["true", ""];

   // activate first move for pilot since damage at spawn together with repair/refuel stops 1st wp to be executed somehow
   _helopilot doMove (getWPPos _wp0);

   // check if helo is within 1000 of 1st wp OR if it can move OR if pilot is not alive OR if number of crew is same as 0.
   waitUntil {_drophelo distance (getWPPos _wp0) < 1000 OR !canMove _drophelo OR !alive _helopilot OR {alive _x} count crew _drophelo == 0};  //new check with alive.
   //hint "1st wp done moving to next";  //for debugging.

   // go to random pos 200m from paradrop marker and run the paradrop script.
   _wp1 = _drophelogrp addWaypoint [getMarkerPos _paradropmarker, 200];
   _wp1 setWaypointType "MOVE";
   _wp1 setWaypointSpeed "NORMAL";
   _wp1 setWaypointBehaviour "AWARE";  // set to "CARELESS" if trouble with enemys distracting heli.
   [_drophelogrp,1] setWaypointStatements ["true", ""];

   // check if helo is within 500 of 2nd wp OR if it can move OR if pilot is not alive OR if number of crew is same as 0.
   // once _drophelo is ready and within set distance of 2nd waypoint, start script for para dropping
   waitUntil {_drophelo distance (getWPPos _wp1) < 500 OR !canMove _drophelo OR !alive _helopilot OR {alive _x} count crew _drophelo == 0};  //new check with alive.
   //hint "2nd wp done, dropping paras moving to last";  // for debug

   // if heli is damaged or unable to operate, crew heli joinsilent paragroup and paragroup activate emergency eject.
   if (!canMove _drophelo OR !alive _helopilot) then {
    _emergency = 1;
    {[_x] joinSilent _spawngroup} foreach Units _drophelogrp;

   _drophelo flyInHeight 150;  // increase flying height to avoid nosedive and slamming paradroppers into the ground

   sleep 1;  // ZZZZzzzz getting a little altitude

   // run paradrop script on group inside helo, not the crew, but the cargo group, if emergency was acivated before: alive crew has joined paragroup.
   nul=[_spawngroup,_grppatrolmarker,_emergency] execVM "spawns\groupEject.sqf";

   // headback to start position and delete crew and heli when there if no emergency.
   if (_emergency == 0) then {
    _wp2 = _drophelogrp addWaypoint [getMarkerpos _spawn, 1];
    _wp2 setWaypointType "MOVE";
    _wp2 setWaypointSpeed "FULL";
    _wp2 setWaypointBehaviour "COMBAT";  // set to combat mode to evade enemys and return safe
    _wp2 setWaypointStatements ["true", "deletevehicle (vehicle this); {deleteVehicle _x} forEach units group this;"];
    //hint "still alive, heading back to be deleted";  // for debug
   // while distance to last wp(delete crew and heli wp)
   _stillalive = true;
   while {_stillalive} do {
    if (!alive _helopilot AND {alive _x} count crew _drophelo == 0) then {
	    //hint "exiting while loop, all dead";  // for debug
	    _stillalive = false;  // set to false so while loop stops and script terminates

    if (!canMove _drophelo AND {alive _x} count crew _drophelo != 0) then {
	    //hint "heli disabled, crew alive, ejecting and commencing patrol on last paradrop area"; // for debug
	    nul=[_drophelogrp,_grppatrolmarker,1] execVM "spawns\groupEject.sqf";
	    _stillalive = false;  // set to false so while loop stops and script terminates

    if (_drophelo distance (getWPPos _wp2) < 2000) then {
	    //hint "last wp almost reached deleting crew and heli and end wp, while loop exits";  // for debug
	    _stillalive = false;  // set to false so while loop stops and script terminates
    //hint "still while looping";  // for debug
    sleep 3;
   //hint "exiting script";  // for debug
// END


//script to make units paradrop from a vehicle at a given wp or trigger.
//execute with:          nul = [group,"marker",0] execVM "groupEject.sqf";

// name of script:   groupEject.sqf placed in scripts folder in mission folder

_grp = _this select 0;              // get name of group, param transferred by parareinf.sqf
_grppatrolmarker = _this select 1;  // get name of area marker_paradropmarker, param transferred by parareinf.sqf
_emergency = _this select 2;        //if emergency 1 then fast eject, if 0 then normal eject
_rndnr = 0.9;                       //defeault eject rate in seconds if not emergency
if (isServer) then {
if (_emergency == 1) then {
	_rndnr = 0.5;           //set eject rate to faster if emergency
_leader = leader _grp;        //get leader of group.

nul=[_leader,_grppatrolmarker,"spawned","move","reinforcement"] execvm "scripts\UPSMON.sqf";  // start upsmon for leader _grp (whole grp)

sleep (random 3);

	unassignVehicle (_x);   //start of paradrop routine, with 0.9 second between every man ejecting.
	(_x) action ["EJECT", vehicle _x];
	sleep _rndnr;
} foreach units _grp;

Edit1: im new to MP scripting and no expert so code may be abit primitive....

Edit2: This above in spoiler was my original personalised beta version, ive released an Updated V1 here: http://forums.bistudio.com/showthread.php?t=111311

Edited by Demonized

Share this post

Link to post
Share on other sites

Thanks for your help Demonized.

This thread is for Arma, but I'm mostly building mp missions for Arma2, so I will set it up in Arma2.

What I had in mind based on a mission that I have built and completed but still to be updated with details.

On this particular mission there are multiple objectives, each base if you will has view objectives like destroy enemy radar,

eliminate enemy presence, destroy hq, ect.,

Basd on my mission I would like to have a trigger where when enemy objective not present, for example like when

we the radar is destroyed then a trigger would go off calling for a squad of enemy inf to be paradropped.

Or even an area trigger where if bluefor is present then a enemy chopper would fly in and paradrop an enemy Ai squad.

Im going to setup the script and test it out.

Edited by Gnter Severloh

Share this post

Link to post
Share on other sites

np, i didnt realise it was for arma. well script was made for arma2 with OA units.

Converting it to only arma 2 requires you to just replace the group spawn units with arma 2 classnames, and heli with a arma2 heli. fairly simple.

I think all the script should work in arma2, not sure but remember to put a functions module on map.

Share this post

Link to post
Share on other sites

His script worked np, but its not exactly what i want to do for the mission I had in mind, I will keep it and use it for future missions definatley.

Share this post

Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in

Sign In Now
Sign in to follow this