Jump to content
Sign in to follow this  
greenygh0st

Dynamic Dive Team Script

Recommended Posts

I am working on a script that will dynamically sent a helicopter team to the players location after he complete an objective. The problem is for some reason the helicopter completes the "TR Unload" waypoint without unloading.

Here is my code so far:

//init  groups
_HeloPilotGroup1 = createGroup east;
_HeloDiveTeam1 = createGroup east;

//helo
_diverHelo1 = createVehicle ["O_Ka60_F", position diverHeloStart_1, [], 0, "NONE"];
_diverHelo1 allowFleeing false;

//pilot
_diverHeloPilot = _HeloPilotGroup1 createUnit ["O_helipilot_F", Position diverHeloStart, [], 0, "FORM"];
_diverHeloPilot moveindriver _diverHelo1;

//dive team
_diverGHelo1 = _HeloDiveTeam1 createUnit ["O_diver_TL_F", Position diverHeloStart, [], 0, "FORM"];
_diverGHelo1 setUnitRank "COLONEL";
_diverGHelo2 = _HeloDiveTeam1 createUnit ["O_diver_F", Position diverHeloStart, [], 0, "FORM"];
_diverGHelo3 = _HeloDiveTeam1 createUnit ["O_diver_F", Position diverHeloStart, [], 0, "FORM"];
_diverGHelo4 = _HeloDiveTeam1 createUnit ["O_diver_F", Position diverHeloStart, [], 0, "FORM"];

//load dive team
{_x moveincargo _diverHelo1} foreach units _HeloDiveTeam1;

//create helo waypoints
wp123_1 = _HeloPilotGroup1 addWaypoint [getpos insertion_1, 0];
wp123_2 = _HeloPilotGroup1 addWaypoint [getpos insertion_1, 0];
wp123_3 = _HeloPilotGroup1 addWaypoint [getpos diverHeloStart_1, 0];
wp123_1 setwaypointtype "MOVE";
wp123_2 setwaypointtype "TR UNLOAD";
wp123_3 setwaypointtype "GETOUT";

//create dive team waypoints
wp456_1 = _HeloDiveTeam1 addWaypoint [getpos insertion_1, 30];
wp456_1 setwaypointtype "GETOUT";
wp456_2 = _HeloDiveTeam1 addWaypoint [getpos insertion_1, 30];
wp456_2 setwaypointtype "MOVE";

wp123_2 synchronizeWaypoint wp456_1;

Any ideas?

Share this post


Link to post
Share on other sites

Why not just place a helicopter on the map waiting on the ground with the divers inside rather than all this scripting? Have the helicopter on a hold waypoint and use a trigger with a switch when your objective is complete. Assign the divers to the helicopter then move them in. Helicopter flys to the position of the player then use an eject script. If you don't forcibly eject the divers and the helicopter is not at 5 meters above the water surface they will not eject.

Share this post


Link to post
Share on other sites
Why not just place a helicopter on the map waiting on the ground with the divers inside rather than all this scripting? Have the helicopter on a hold waypoint and use a trigger with a switch when your objective is complete. Assign the divers to the helicopter then move them in. Helicopter flys to the position of the player then use an eject script. If you don't forcibly eject the divers and the helicopter is not at 5 meters above the water surface they will not eject.

That would be easier. But this is sort of a testing script for another idea I was working on where if a player is detected that a helo team will respond dynamically to the players location. So if this works then I can easily make that work. :)

Share this post


Link to post
Share on other sites

Then you will need to have the helicopter flyinheight to 5 meters at the players position then fire off an eject script, there are a bunch of them out there already. Give this a try.

if (!isServer) exitWith {};

_grp = _this select 0;

sleep (random 3);

{unassignVehicle (_x);(_x) action ["EJECT", vehicle _x]; sleep 0.4} foreach (units _grp);

Edited by cobra4v320

Share this post


Link to post
Share on other sites

Thanks for the ejection snippet. I have done ejection scripts before but yours is very streamlined.

The reason I am trying to work around ejection scripts is because in the alpha only the ka-50 (60?) seems to support ejection.

So i geuss im wondering why would the transport unload waypoint work?

Share this post


Link to post
Share on other sites

Here you go give this a whirl :)

_null = [startposition, player] execVM "diveTeam.sqf"

if (!isServer) exitWith {};

_start = _this select 0;
_target = _this select 1;

//if the target is not on water cancel the mission
if (!surfaceIsWater position _target) exitWith {hint "The target is on dry land."}; //for testing?

//create helicopter
_grp_heli = creategroup East;
_heliSpawn = [position _Start, 180, "O_Ka60_F", _grp_heli] call bis_fnc_spawnvehicle;
_heli = _heliSpawn select 0;

//create dive team
_grp_diver = [Position _start, EAST, (configFile >> "CfgGroups" >> "East" >> "OPF_F" >> "SpecOps" >> "OI_diverTeam")] call BIS_fnc_spawnGroup;
_grpLeader = leader _grp_diver;

//assign dive team to helicopter
{_x assignasCargo _heli; _x moveinCargo _heli} foreach (units _grp_diver);

//create helicopter waypoint to target and behavior
_grp_heli Move position _target;
_grp_heli setSpeedMode "FULL";
_grp_heli setBehaviour "SAFE";
_grp_heli setCombatMode "BLUE";

//wait until helicopter is near target and at 5 meters above sea level
waitUntil {_heli distance _target < 150};
_heli flyinheight 5;
Waituntil {(getPosASLW _heli select 2) < 5};

//eject divers
sleep (random 3);
{unassignVehicle (_x);(_x) action ["EJECT", vehicle _x]; sleep 0.5} foreach (units _grp_diver);
waitUntil {{_x in _heli} count (units _grp_diver) == 0};
sleep 3;

//move helicopter
_heli flyinHeight 40;
_heli doMove (position _start);

//delete helicopter and crew
if (_heli distance _start < 200) then
{
{deleteVehicle _X} forEach (crew _heli)+[_heli];
deleteGroup _grp_heli;
};

//move divers to targets Known position
_grp_diver reveal [_target, 4];
waitUntil {{_x knowsAbout _target > 1} foreach (units _grp_diver)};

while {_grpLeader knowsAbout _target > 1} do
{
sleep 1;

hintsilent format ["Knows About You: %1", _grpLeader knowsAbout _target]; //for testing maybe??

_grp_diver move position _target;
_grp_diver setSpeedMode "FULL";
_grp_diver setbehaviour "AWARE";
_grp_diver setCombatMode "RED";

_depth = (getPosASLW _target select 2);
{_x swimInDepth _depth} foreach (units _grp_diver);
};

if (true) exitWith {};

Edited by cobra4v320

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  

×