Jump to content
Sign in to follow this  
Blitzen88

Need Help with Adding Spawned Units to Sector Tactics

Recommended Posts

Im using a modified (ie simplified) version of Iceman77's helicopter reinforcement script.  The script works great but I wanted the infantry group to attack and defend sectors instead of the default seek and destroy.  Here is what I got:

 

/*==========================================================================================

				Arma III Helicopter Transport/Reinforcement Script

===========================================================================================

Parameter(s):

1. Side - East, West, Resistance (Select 0)

2. Spawn Marker - Spawn position of the helicopter (Select 1)

3. Landing Zone Marker - Landing zone for the helicopter (Select 2)

4. Search & Destroy Mode - Whether or not the infantry group should initiate search and destory (true) or patrol (false)

5. Cylce Mode - Whether or not the script should run continously (True) or only once (False) (Select 4)

6. Minimum Sleep Time - Minimum amount of time the script should wait before running again.  Only applies to cycle mode (Select 5)

7. Maximum Sleep Time - Maximum amount of time the script should wait before running again.  Only applies to cycle mode (Select 6)

Example:

_nul = [SIDE, "Spawn Position (Marker)", "Landing Position (Marker)", Search & Destroy Mode, Cycle Mode, Min Sleep Time, Max Sleep Time] spawn TAG_fnc_reinforcements
 
_nul = [WEST, "Obj_NatoHeli", "Obj_Nato", True, True, 300, 600] spawn TAG_fnc_reinforcements


===========================================================================================*/


TAG_fnc_reinforcements = {
 
if (!isServer) exitWith {};
 
//Define Variables/Definitions:
_side = _this select 0;
_spawnMrk = _this select 1;
_LZMrk = _this select 2;
_sadMode = _this select 3;
_cycleMode = _this select 4;
_time1 = _this select 5;
_time2 = _this select 6;

_heloCrew = createGroup _side;  

//Set the scope of local variables that are defined in other scope(s), so they can be used over the entire script
private ["_ranGrp","_helo","_infgrp"];


//**SPAWNS** Spawn helicopter and infantry groups based off of the "side" input

Switch (_side) do {
    	
//West Helicopter and Infantry Group
//----------------------------------------------------
	case WEST : {
        _ranGrp = ["BUS_InfSquad","BUS_InfSquad_Weapons"] call BIS_fnc_selectRandom;
        _helo = [getMarkerPos _spawnMrk, markerDir _spawnMrk, "B_Heli_Transport_01_F", WEST] call BIS_FNC_spawnVehicle;
        _infgrp = [getMarkerPos _spawnMrk, WEST, (configFile >> "CfgGroups" >> "West" >> "BLU_F" >> "Infantry" >> _ranGrp)] call BIS_fnc_spawnGroup;
	};
	
//East Helicopter and Infantry Group
//----------------------------------------------------
	case EAST : {
        _ranGrp = ["OIA_InfSquad","OIA_InfSquad_Weapons"] call BIS_fnc_selectRandom;
        _helo = [getMarkerPos _spawnMrk, markerDir _spawnMrk, "O_Heli_Light_02_F", EAST] call BIS_FNC_spawnVehicle;
        _infgrp = [getMarkerPos _spawnMrk, EAST, (configFile >> "CfgGroups" >> "East" >> "OPF_F" >> "Infantry" >> _ranGrp)] call BIS_fnc_spawnGroup;
	};
	

//Resistance Helicopter and Infantry Group
//----------------------------------------------------
	case RESISTANCE : {
        _ranGrp = ["HAF_InfSquad","HAF_InfSquad_Weapons"] call BIS_fnc_selectRandom;
        _helo = [getMarkerPos _spawnMrk, markerDir _spawnMrk, "I_Heli_Transport_02_F", RESISTANCE] call BIS_FNC_spawnVehicle;
        _infgrp = [getMarkerPos _spawnMrk, RESISTANCE, (configFile >> "CfgGroups" >> "Indep" >> "IND_F" >> "Infantry" >> _ranGrp)] call BIS_fnc_spawnGroup;
	};
};

//Assign the crew to a group & assign cargo to the helo
{[_x] joinSilent _heloCrew;} forEach crew (_helo select 0);	
{_x assignAsCargo (_helo select 0); _x moveInCargo (_helo select 0);} forEach units _infgrp;


//Find a flat position around the LZ marker & create an HPad there.
_flatPos = [getMarkerPos _LZMrk , 0, 400, 10, 0, 0.3, 0] call BIS_fnc_findSafePos;
_hPad = createVehicle ["Land_HelipadEmpty_F", _flatPos, [], 0, "NONE"];


//Give the helicopter an unload waypoint onto the hpad

    _heloWp = _heloCrew addWaypoint [_hPad, 0];
    _heloWp setWaypointType "TR UNLOAD";
    _heloWp setWaypointBehaviour "CARELESS";
    _heloWp setWaypointCombatMode "BLUE";
    _heloWp setWaypointSpeed "FULL";
    _heloWp setWaypointStatements ["true", "(vehicle this) LAND 'LAND';"];
	
//Wait until the helicopter is touching the ground before ejecting the cargo	
WaitUntil {isTouchingGround (_helo select 0) || {!canMove (_helo select 0)}};

//Eject the Infantry	
{unAssignVehicle _x; _x action ["eject", vehicle _x]; sleep 0.5;} forEach units _infgrp; //Eject the cargo

//Wait Until the infantry group is no longer in the helicopter before assigning a new WP to the helicopter
WaitUntil {{!alive _x || !(_x in (_helo select 0))} count (units _infGrp) == count (units _infGrp)};

_leader = (leader _infgrp);

sleep 2;

_leader synchronizeObjectsAdd [SecTactic];

//Delete the helipad
{deletevehicle _hPad};

    _heloWp = _heloCrew addWaypoint [getmarkerpos _spawnMrk, 0];
    _heloWp setWaypointType "MOVE";
    _heloWp setWaypointBehaviour "AWARE";
    _heloWp setWaypointCombatMode "BLUE";
    _heloWp setWaypointSpeed "FULL";
    _heloWp setWaypointStatements ["true", "{deleteVehicle _x;} forEach crew (vehicle this) + [vehicle this];"];





//Cycle Mode
//----------------------------------------------------

// IF _cycleMode is passed as true, then re-run the function (this function!), else do nothing.

if (_cycleMode) then {
	sleep _time1 + (random _time2);
	[_side, _spawnMrk, _LZMrk, _sadMode, _cyclemode, _time1, _time2] spawn TAG_fnc_reinforcements;
		     };




// Function End
};

From my understanding, you can add units to the sector tactics by synching them to it.  My thought was to do that via the sychronizeobjectsadd command but it doesnt seem to work

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  

×