Jump to content
Sign in to follow this  
meatball

Random Extraction Script Help

Recommended Posts

Hey folks, I'm working on an extraction script for my mission. I have a trigger that fires when all the tasks are completed that then runs this script. I need the script to do a bunch of things.

1) Pick one random extraction location from 6 of them already placed on the map. I have already placed Markers (lz_0 - lz_5) and invisible helipads (hp_0 - hp_5).

2) Create a marker on the map for all players showing them the extraction location.

3) Wait for the players to get to the location and when they find a 'radio' buried in some bricks (a trigger around the bricks) call in an Evac helicopter.

4) Spawn the Evac helicopter, fly it in and land, then wait for all players to get on board before taking off and flying to the final location to end the mission.

Here's the actual script I've come up with.

// randomExtraction point script
//  By Meatball
//
//   Script assumes you have 6 invisible markers already on the map named lz_0 through lz_5 and 
//    that you have 6 invisible helippads already on the map named hp_0 through hp_5
//    lz_0 is located next to hp_0, etc.
//
//   Script can be updated to use more helipads/LZ's but updating _randomExtract random check to the proper #.

if (!isServer)exitWith{}; // Exit if not Server

// Define Local Variables
private ["_randomExtract","_lzName","_hpName","_evacH","_evacWP","_evacTrig1","_bricks","_spawnPos","_heli","_heliCrew","_heliGroup"];

// Pick Random extraction location.  
_randomExtract = floor(random 6);// Update the '6' to match the number of extraction points/helipads you've created on the map.

// Create LZ/Helipad variables and then show Extraction point marker on map
_lzName = "lz_" + str _randomExtract;
_hpName = "hp_" + str _randomExtract;

_lzName setMarkerTypeLocal "mil_Pickup";  // For more icon types see http://community.bistudio.com/wiki/cfgMarkers
_lzName setMarkerColorLocal "ColorRed";  // For more Colors see http://community.bistudio.com/wiki/setMarkerColorLocal

// Create the pile of bricks and set a variable that the radio has not been found yet.
_bricks = [markerPos _lzName, random 360, "Land_Bricks_V4_F", CIVILIAN] call BIS_fnc_spawnVehicle;
radFound = 0;  // Set variable that the Radio has not been found yet.


// Create Guardians around extraction point using the AI Script Pack militarize script.
call compile format["nul = [%1,2,(numEnemies*40),true,true,false,0.20,0.05,enemySkill,nil,nil,nil] execVM 'militarize.sqf';",_hpName];

// Create the trigger around the bricks for the 'Radio'
_evacTrig1=createTrigger["EmptyDetector",getMarkerPos _lzName];
_evacTrig1 setTriggerActivation["WEST","PRESENT",false];
_evacTrig1 setTriggerArea[2,2,0,false];
_evacTrig1 setTriggerStatements["this","hint 'After digging through the pile of bricks you find the radio and call in for evac.  The chopper is en route and they tell you to hold out till they arrive!';radFound = 1;",""];
_evacTrig1 setTriggerTimeout[2,2,2,false];

// Wait for players to arrive at the radio trigger and 'find' the radio.
waitUntil {radFound == 1};

// Stop the reinforcement chopper scripts from running.
stopRein = 0;

// Spawn Evac helicopter and fly to Evacuation Point after a short delay.
sleep 15;
hint "DemoTeam two, this is Ghost twelve.  We are inbound and will be there shortly.  Ghost twelve out.";
_evacH = [markerPos "evacSpawn", random 360, "B_Heli_Transport_01_camo_F", west] call BIS_fnc_spawnVehicle;

// Set evacuation helicopter settings.
_heli = _evacH select 0;
_heliCrew = _evacH select 1;
_heliGroup = _evacH select 2;

_heli allowDamage false;  // Would suck to get shot down during evac after finishing the whole mission.

evacHeli = _heli;

// Set Evac helicopter waypoints and move to evacuation LZ.
call compile format["wp0 = _heliGroup addwaypoint [getPos %1, 0];",_hpName];
wp0 setWaypointType "LOAD";
wp0 setWaypointSpeed "NORMAL";
wp0 setWaypointBehaviour "CARELESS";
wp0 setWaypointCombatMode "BLUE";
wp0 setWaypointStatements ["true","doStop evacHeli; evacHeli land 'LAND';hint 'This is Ghost twelve, we're here, get in when we touch down!';"];

// Once chopper is down, wait for all members of demoteam that are alive, but not captive, to get in.
waitUntil {{_x in evacHeli} count units demoteam == {alive _x and !captive _x} count units demoteam};

// Once all members are in, fly to end mission marker/trigger.
wp1 = _heliGroup addwaypoint [getMarkerPos "endMark", 2];
wp1 setwaypointtype "MOVE";
wp1 setWaypointCombatMode "GREEN";

To be honest, the whole just about works. (Though any suggestion on how to clean it up / streamline it are appreciated!) The only problem I'm having is that the players are not getting the marker created by the setMarkerType and setmarkerColor commands, and only the player running the server sees them. I'm sure it's because the first line of the script tells nonservers to exit the script, but I'm not sure how to handle it.

I need the server to pick the random number for the lz_# and hp_# variables before I can use the setMarker commands so I can create the marker in the correct location. Any thoughts?

Share this post


Link to post
Share on other sites

spawnVehicle for a pile of bricks? Not sure what all those call compile formats are for either.

Look into BIS_fnc_MP for how to send messages to all players. A lot of what you're spawning you could put on the map already and simply move to whichever random spot you wanted instead of this. Maybe put the player stuff at the top, then have them bail the script and let the server do the rest.

Share this post


Link to post
Share on other sites

Most of the call compile formats are because no matter what else I did, those commands would error out with the local variables in them directly. The call compile format slaps the actual variable value into the command before the code is parsed and it works.

I could probably the bricks and such out at each location and just give each one a variable name and then point to it. How else would you spawn objects other than spawnVehicle?

Those pieces all actually work already, the main problem is the choosing of the random location. I need the server to do that, otherwise each client will pick a different random location, but I need the random location before I can have the clients make their map markers.

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  

×