Jump to content
Sign in to follow this  
wokstation

Generic, re-usable, ammo/weapons drop-off script

Recommended Posts

Finally made one I thought I'd share (been writing a few "stock" scripts and once I've polished them a bit I'll chuck them out too).

(Updated already: Made it slightly more accurate)

What it does:

Spawns a helicopter which then flies to the designated location and para-drops the selected crate within about 100m of the location, before flying off again and being removed.

Uses no globals, has no dependancies except it requires the Functions module be present.

It'll pick an appropriate helicopter and correctly-teamed crew depending on the side of the player (if the player's EAST, it'll spawn EAST stuff. WEST, it'll spawn WEST, anything else, it spawns civillians - so if you're playing GUER, you'll need to make sure there's at least one civvie on the map).

How to use it:

Call the script somehow, eg, via a radio trigger or at a set point in a mission, giving the target location and selecting a box:

nul = [getpos player, 1] execVm "supplyDrop.sqf";

Replace "1" with one of the following numbers to get that box:

0 = Basic ammo

1 = Basic weapons

2 = Launchers

3 = Ordnance

4 = Special

5 = Vehicle

6 = Local Ammo

7 = Local Weapons

8 = Random.

So the above example would make the helicopter bring a US Basic Weapons box to the player's location if the player is WEST, a RU Basic Weapons for EAST and Local for anyone else.

It also calls the Garbage Module at the end, but if it's not present it doesn't seem to break anything, so it's not required per-say.

Anyway, the script:

supplydrop.sqf

/*
Resupply drop script by Wokstation / esd.
=========================================

nul = [DropPosition, BoxSelection] execvm "resupplyDrop.sqf";

DropPosition:  Location to drop supplies.  Supplies will be delivered to within approximately 120m of that location.
BoxSelection:  The supply to drop, from the list below.
 0 = Basic ammo
 1 = Basic weapons
 2 = Launchers
 3 = Ordnance
 4 = Special
 5 = Vehicle
 6 = Local Ammo
 7 = Local Weapons
 8 = Random.
*/

_DropPos = _this select 0;
_choice1 = _this select 1;
_tSide = side player; // *** This alters the side that spawns.  Can be adjusted here.
_spawnDistance = 2500; // *** How far in meters the helicopter will spawn from the drop location.
_alt1 = 100; // *** Flight altitude.
_CargoSpotA = [_dropPos select 0, _dropPos select 1, _alt1]; // *** Altitude-adjusted destination.
if ((_choice1 < 0) or (_choice1 > 7)) then {_choice1 = floor random 8}; // *** Verify number in bounds and if not, assign random.

// *** Ammo box arrays:
_bluchoicesA1 = ["USBasicAmmunitionBox", "USBasicWeaponsBox", "USLaunchersBox", "USOrdnanceBox", "USSpecialWeaponsBox",  "USVehicleBox", "LocalBasicAmmunitionBox", "LocalBasicWeaponsBox"];
_indchoicesA1 = ["LocalBasicAmmunitionBox", "LocalBasicWeaponsBox", "USLaunchersBox", "USOrdnanceBox", "SpecialWeaponsBox", "USVehicleBox", "LocalBasicAmmunitionBox", "LocalBasicWeaponsBox"];
_OpfChoicesA1 = ["RUBasicAmmunitionBox", "RUBasicWeaponsBox", "RULaunchersBox", "RUOrdnanceBox", "RUSpecialWeaponsBox", "RUVehicleBox", "LocalBasicAmmunitionBox", "LocalBasicWeaponsBox"];

// ****** Default choices:
_c2D = _indchoicesA1 select _choice1; // *** The ammo box to spawn
_vehc1 = "Mi17_Civilian"; // *** Default helicopter
_ChuteT = "ParachuteMediumWest"; // *** Default parachute

// ****** East choices:
if (_tSide == east) then
{
_c2d = _opfChoicesA1 select _choice1;
_vehc1 = "Mi17_rockets_RU";
_ChuteT = "ParachuteMediumEast";
};
// ****** West choices:
if (_tSide == west) then
{
_c2d = _bluChoicesA1 select _choice1;
_vehc1 = "MH60S";
};

// ****** Create helicopter:
_rOrig = _DropPos;
_rDir = random 360; 
_rDir2 = _rDir + 180;
if (_rDir2 > 360) then {_rDir2 = _rDir2 - 360};
_rPos = [(_rOrig select 0)+(sin _rDir)*_spawnDistance,(_rOrig select 1)+(cos _rDir)*_spawnDistance, _alt1];
_DropDest = [(_rOrig select 0)+(sin _rDir2)*100,(_rOrig select 1)+(cos _rDir)*100, _alt1]; // Destination, just beyond player.

_HeliCrew = creategroup _tSide;
_HeliP = creategroup _tside;
_Huey = ([_rpos, _rDir2, _vehc1, _HeliCrew] call BIS_fnc_spawnVehicle) select 0;
_Huey setvehiclevarname "_Huey";

// ****** Split the pilot from the gunners, to allow the gunners to fire on targets of opportunity
_tGuy = driver _Huey;
[_tguy] join _HeliP;
_HeliP setCombatMode "blue";
_HeliP setBehaviour "careless";
_HeliCrew setCombatMode "red";
_HeliCrew setBehaviour "combat";

// ****** Give orders and wait for heli to approach dropzone
_tGuy doMove _CargoSpotA;
_Huey flyInHeight _alt1;

_vv1 = 0;
while {(_vv1 == 0)} do
{
sleep random 1;
if ((_Huey distance _CargoSpotA) < 250) then {_vv1 = 2};
if ((fuel _Huey) < 0.2 ) then {_vv1 = 1};
if !(isengineon _Huey) then {_vv1 = 1};
if ((!alive _tguy)) then {_vv1 = 1};
if !(_tguy in _Huey) then {_vv1 = 1};
if (!alive _Huey) then {_vv1 = 1};
};

// ****** Give orders to reduce altitude and wait for arrival at dropzone
_tGuy doMove _dropDest;
_Huey flyInHeight 50;

_vv1 = 0;
while {(_vv1 == 0)} do
{
sleep random 1;
if ((_Huey distance _dropDest) < 100) then {_vv1 = 2};
if ((fuel _Huey) < 0.2 ) then {_vv1 = 1};
if !(isengineon _Huey) then {_vv1 = 1};
if ((!alive _tguy)) then {_vv1 = 1};
if !(_tguy in _Huey) then {_vv1 = 1};
if (!alive _Huey) then {_vv1 = 1};
};

// ****** release parachute:
if (_vv1 == 2) then
{
_DropPos = getpos _Huey;
_Chute1 = _ChuteT createvehicle _DropPos;
_Cargo1 = _C2D createVehicle _dropPos;
_Cargo1 attachTo [_chute1, [0,0,0]];
_chute1 setpos _dropPos;
_tGuy doMove _rpos;
_Huey flyInHeight _alt1;

// ****** Wait for parachute to land and then reset cargo position.
waituntil {!alive _chute1};
detach _Cargo1;
_Cargo1 setpos [getpos _cargo1 select 0, getpos _cargo1 select 1, 0];
"SmokeShellGreen" createVehicle (getpos _Cargo1);
};

// Wait for helicopter to return to spawn, and tidy.
_vv1 = 0;
while {(_vv1 == 0)} do {
sleep random 2;
if ((_Huey distance _rpos) < 200) then {_vv1 = 2};
if ((fuel _Huey) < 0.2 ) then {_vv1 = 1};
if !(isengineon _Huey) then {_vv1 = 1};
if ((!alive _tguy)) then {_vv1 = 1};
if !(_tguy in _Huey) then {_vv1 = 1};
if (!alive _Huey) then {_vv1 = 1};
};

_huey setdamage 1;
[_Huey] call BIS_GC_trashItFunc;
[_tguy] call BIS_GC_trashItFunc;
{
[_x] call BIS_GC_trashItFunc;
} foreach units _HeliCrew;

(Or if you're lazy, download it instead of copy/pasting).

Example mission (by request) here.

It's heavily commented, so if anyone wants to take it to pieces to use chunks, or re-write it, whatever, feel free. I hope someone finds it useful, anyway...

(At the end where I re-position the cargo-box when the 'chute is destroyed, I've been thinking about replacing it so instead of getting it's own position and just setting the Z to 0, it gets the 'chute's Z and gives that to the crate, in case it lands on a building. Would this work properly? The parachute is dead at that point...)

Edited by Wokstation

Share this post


Link to post
Share on other sites

Wokstation Thanks for the awesome work.

---------- Post added at 11:10 PM ---------- Previous post was at 10:59 PM ----------

Wokstation Please can extend the distance At delete vehicle

Share this post


Link to post
Share on other sites
Wokstation Please can extend the distance At delete vehicle

If you mean delete it while further from the exit-spot, just change the last one of these:

 if ((_Huey distance _rpos) < 200) then {_vv1 = 2};

and increase 200 to something else.

If you want it to spawn further away, just change this: _spawnDistance = 500;

(I thought I had it bigger, but it appears the testing distance made it through)

Share this post


Link to post
Share on other sites
If you mean delete it while further from the exit-spot, just change the last one of these:

 if ((_Huey distance _rpos) < 200) then {_vv1 = 2};

and increase 200 to something else.

If you want it to spawn further away, just change this: _spawnDistance = 500;

(I thought I had it bigger, but it appears the testing distance made it through)

Yes, that's what I'd meant.

Wokstation it's really appreciated your effort.

Share this post


Link to post
Share on other sites

Very neat script.

I added this in a WIP mission and it works great. Just what I needed.

Ty.

:)

Share this post


Link to post
Share on other sites

I didnt get it to work at all... =(

---------- Post added at 02:48 AM ---------- Previous post was at 02:43 AM ----------

how can you set up an addAction comand using the getpos and all that? what would it look like?

like this: this addAction ["Resupply", [getpos player,1] execVm "resupplyDrop.sqf"] ???

**Update**

didnt work and I cant figure out how to make it have an action menu option??? I took everythig out and put the addAction command just like above with a 1 and 0 and it didnt work... the plane still flew over and dropped the cargo, but it did it on its own as soon as the mission started... and it also didnt give me an option in the action scroll down menu...? any ideas?

Edited by HeAvY TrAnCe

Share this post


Link to post
Share on other sites

Nice script.

I removed this section from the bottom of your script, as I feel deleting the helo and crew is better than just blowng them up to remove them.

_huey setdamage 1;
[_Huey] call BIS_GC_trashItFunc;
[_tguy] call BIS_GC_trashItFunc;
{
[_x] call BIS_GC_trashItFunc;
} foreach units _HeliCrew;

replace with

{deleteVehicle _x} foreach units _tguy;deletevehicle _Huey;

Share this post


Link to post
Share on other sites
Nice script.

I removed this section from the bottom of your script, as I feel deleting the helo and crew is better than just blowng them up to remove them.

_huey setdamage 1;
[_Huey] call BIS_GC_trashItFunc;
[_tguy] call BIS_GC_trashItFunc;
{
[_x] call BIS_GC_trashItFunc;
} foreach units _HeliCrew;

replace with

{deleteVehicle _x} foreach units _tguy;deletevehicle _Huey;

{deleteVehicle _x} foreach units _tguy;deletevehicle _Huey;

{deleteVehicle _x} foreach units _HeliCrew;

I added that to get rid of the crew that just seem to appear in mid air after the heli has disapperad :)

But I'm having issues with selecting the type of supplys dropped and the fly in distance and altitude, all so I noticed that some times there is no drop just a hovering helocopter any ideas fellas?

Ohh allso there is sometimes a mid air collision between drops and chopper wich results in the worlds biggest para flare :D

Edited by Pom

Share this post


Link to post
Share on other sites

Awesome stuff just what I needed! Thanks Wokstation! Gonna make use of a small bit of that on the Invasion 1944 mission Free Fall so I can drop some much needed supplies to the front lines!

  • Like 1

Share this post


Link to post
Share on other sites
I noticed that some times there is no drop just a hovering helocopter any ideas fellas?

This was my experience as well. From my experience, it was at least half the time, heli comes in and just hovers over our heads, and that's it, doesn't drop or leave.

Share this post


Link to post
Share on other sites

just change the classnames in the arrays to mod it for i44, plan to drop it from the gyrocopter? :D

I was also having problems with it not dropping the boxes, just hovering; here is how I fixed it:

_DropPos = getpos player;
_choice1 = 0;

//_DropPos = _this select 0;
//_choice1 = _this select 1;

_tSide = side player; // *** This alters the side that spawns.  Can be adjusted here.
_spawnDistance = 1000; // *** How far in meters the helicopter will spawn from the drop location.
_alt1 = 100; // *** Flight altitude.
_CargoSpotA = [_dropPos select 0, _dropPos select 1, _alt1]; // *** Altitude-adjusted destination.
if ((_choice1 < 0) or (_choice1 > 7)) then {_choice1 = floor random 8}; // *** Verify number in bounds and if not, assign random.

// *** Ammo box arrays:
_bluchoicesA1 = ["USBasicAmmunitionBox", "USBasicWeaponsBox", "USLaunchersBox", "USOrdnanceBox", "USSpecialWeaponsBox",  "USVehicleBox", "LocalBasicAmmunitionBox", "LocalBasicWeaponsBox"];
_indchoicesA1 = ["LocalBasicAmmunitionBox", "LocalBasicWeaponsBox", "USLaunchersBox", "USOrdnanceBox", "SpecialWeaponsBox", "USVehicleBox", "LocalBasicAmmunitionBox", "LocalBasicWeaponsBox"];
_OpfChoicesA1 = ["RUBasicAmmunitionBox", "RUBasicWeaponsBox", "RULaunchersBox", "RUOrdnanceBox", "RUSpecialWeaponsBox", "RUVehicleBox", "LocalBasicAmmunitionBox", "LocalBasicWeaponsBox"];

// ****** Default choices:
_c2D = _indchoicesA1 select _choice1; // *** The ammo box to spawn
_vehc1 = "Mi17_Civilian"; // *** Default helicopter
_ChuteT = "ParachuteMediumWest"; // *** Default parachute

// ****** East choices:
if (_tSide == east) then
{
_c2d = _opfChoicesA1 select _choice1;
_vehc1 = "Mi17_rockets_RU";
_ChuteT = "ParachuteMediumEast";
};
// ****** West choices:
if (_tSide == west) then
{
_c2d = _bluChoicesA1 select _choice1;
_vehc1 = "MH60S";
};

// ****** Create helicopter:
_rOrig = _DropPos;
_rDir = random 360; 
_rDir2 = _rDir + 180;
if (_rDir2 > 360) then {_rDir2 = _rDir2 - 360};
_rPos = [(_rOrig select 0)+(sin _rDir)*_spawnDistance,(_rOrig select 1)+(cos _rDir)*_spawnDistance, _alt1];
_DropDest = [(_rOrig select 0)+(sin _rDir2)*100,(_rOrig select 1)+(cos _rDir)*100, _alt1]; // Destination, just beyond player.

_HeliCrew = creategroup _tSide;
_HeliP = creategroup _tside;
_Huey = ([_rpos, _rDir2, _vehc1, _HeliCrew] call BIS_fnc_spawnVehicle) select 0;
_Huey setvehiclevarname "_Huey";

// ****** Split the pilot from the gunners, to allow the gunners to fire on targets of opportunity
_tGuy = driver _Huey;
[_tguy] join _HeliP;
_HeliP setCombatMode "blue";
_HeliP setBehaviour "careless";
_HeliCrew setCombatMode "red";
_HeliCrew setBehaviour "combat";

// ****** Give orders and wait for heli to approach dropzone
_tGuy doMove _CargoSpotA;
_Huey flyInHeight _alt1;

_vv1 = 0;
while {(_vv1 == 0)} do
{
//hint "vv1 is zero";
sleep random 1;
if ((_Huey distance _CargoSpotA) < 250) then {_vv1 = 1};
if ((fuel _Huey) < 0.2 ) then {_vv1 = 1};
if !(isengineon _Huey) then {_vv1 = 1};
if ((!alive _tguy)) then {_vv1 = 1};
if !(_tguy in _Huey) then {_vv1 = 1};
if (!alive _Huey) then {_vv1 = 1};	
};

_vv1 = 1;
//hint "moving to 25 and drop destination...........";
// ****** Give orders to reduce altitude and wait for arrival at dropzone
_tGuy doMove _dropDest;
_Huey flyInHeight 35;
sleep 6;

// ****** release parachute:
if (_vv1 == 1) then
{
//hint "vv1 is two";
_DropPos = getpos _Huey;
_Chute1 = _ChuteT createvehicle _DropPos;
_Cargo1 = _C2D createVehicle _dropPos;
_Cargo1 attachTo [_chute1, [0,0,0]];
_chute1 setpos _dropPos;
_tGuy doMove _rpos;
_Huey flyInHeight _alt1;

// ****** Wait for parachute to land and then reset cargo position.
waituntil {!alive _chute1};
detach _Cargo1;
_Cargo1 setpos [getpos _cargo1 select 0, getpos _cargo1 select 1, 0];
"SmokeShellGreen" createVehicle (getpos _Cargo1);
};

// Wait for helicopter to return to spawn, and tidy.
_vv1 = 0;
while {(_vv1 == 0)} do {
sleep random 2;
if ((_Huey distance _rpos) < 1000) then {_vv1 = 2};
if ((fuel _Huey) < 0.2 ) then {_vv1 = 1};
if !(isengineon _Huey) then {_vv1 = 1};
if ((!alive _tguy)) then {_vv1 = 1};
if !(_tguy in _Huey) then {_vv1 = 1};
if (!alive _Huey) then {_vv1 = 1};
};

{deleteVehicle _x} foreach units _tguy;deletevehicle _Huey;
{deleteVehicle _x} foreach units _HeliCrew;

Edited by Chekevic

Share this post


Link to post
Share on other sites

Chekevic Thanks for the updated version, I was finding ammo/heli would explode and hover doing nothing, your updated version fixed this, very useful. I use a small civ plane which works really well (drugs package drop) :)

BTW for anyone using ACE2 I had a night mission where I wanted this to do a package drop, so I worked out how to use ace to attach a NV Strobe to the box when dropped which helps searching at night. This will spawn with package strobing when released from vehicle and permanent on ground (which is easier to locate with smoke as this lights up too with NV).

This is obviously ACE required, if anyone has a version to add a strobe that works similar thats non ace it would be good.

// ****** release parachute:
if (_vv1 == 1) then
{
   //hint "vv1 is two";
   _DropPos = getpos _Huey;
   _Chute1 = _ChuteT createvehicle _DropPos;
   _Cargo1 = _C2D createVehicle _dropPos;
   _Cargo1 attachTo [_chute1, [0,0,0]];
   _chute1 setpos _dropPos;
   _tGuy doMove _rpos;
   _Huey flyInHeight _alt1;
   [b][i][color=DarkRed]["ace_sys_irstrobe_aradd", [_Cargo1]] call CBA_fnc_globalEvent;[/color][/i]
  [/b]
   // ****** Wait for parachute to land and then reset cargo position.
   waituntil {!alive _chute1};
   detach _Cargo1;
   _Cargo1 setpos [getpos _cargo1 select 0, getpos _cargo1 select 1, 0];
   "SmokeShellRed" createVehicle (getpos _Cargo1);

};

Edited by mrcash2009

Share this post


Link to post
Share on other sites

This is a fantastic script! Is there anyway this script can be expanded to add vehicles for paradropping?

I suppose you can replace the Ammo Box Class names with vehicle class names, but there maybe a problem with the vehicle colliding with the chopper, not to mention I have to change the parachute as well.

If anyone can let me know that would be great!

-Bigshot

  • Like 1

Share this post


Link to post
Share on other sites

[color="Red"] _DropPos = getpos _Huey;[/color]
_Chute1 = _ChuteT createvehicle _DropPos;
_Cargo1 = _C2D createVehicle _dropPos;
_Cargo1 attachTo [_chute1, [0,0,0]];
_chute1 setpos _dropPos;
_tGuy doMove _rpos;
_Huey flyInHeight _alt1;

Make the _droppos just slightly lower than the helicopter to allow for a vehicle drop.

_DropPos = [getPos _huey select 0, getPos _huey select 1, (getPos _huey select 2) -10];

Then obviously change the ammocrate classnames to vehicles. Maybe change the aircraft to something bigger.

  • Like 1

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  

×