Author: Foxhound
Author Website:

Requirements: No addons required

Version: 1.0

Short description: A simple cargo drop script

Date: 2011-06-16 22:44


Comments: (0)
Rating:



 



Cargo drop

by
dmos


Description:
Spent a good part of my evening on this. Didn't find any cargo drop scripts that are to the point so made this.
Hope this helps anyone, check out my sandbox where I'll use this.


Code:
_carrier = _this select 0; // Probably the plane making the drop off
_dropItem = _this select 1; // Item you want to drop
_velFactor = 0.75; // The item being dropped will have a portion of the carrier's speed (but just for a bit; it won't continue flying or anything)

_carrierPos = getPos _carrier;
_dropPoint = +_carrierPos;
_dropPoint set [2, (_dropPoint select 2) - 0.5];
_dropVel = velocity _carrier;
_dropVel = [(_dropVel select 0)  * _velFactor, (_dropVel select 1) * _velFactor, -10];

sleep 0.15;

_parachute = "ParachuteMediumWest" createvehicle _dropPoint;
_dropItem setDir getDir _carrier;
_dropItem setPos _dropPoint;
 _dropItem attachTo [_parachute, [0,0,0]];
 _parachute setpos _dropPoint;
 _parachute setVelocity _dropVel;
 _parachute setDir (getDir _carrier) + 180; 
 
 sleep 2;
 
 // all this mascarade below because if left just like this objects like ammo boxes get burried or something
 waitUntil {sleep 0.4;  ((getPos _dropItem) select 2) <  0.5}; 
 _dropItemPos = getPos _dropItem;
 _dropItemPos set [2,0];
 _dropItem setPos _dropItemPos;
 detach _dropItem;


Usage:
Put this in your mission directory (ex C:\Users\[-username-]\Documents\ArmA 2\missions\[-your mission-].Zargabad\). Name it something smart, give it an .sqf extension (ex: cargoDrop.sqf). You execute the script as follows:
_thisIsAScriptHandle = [name_of_your_plane_or_heli, name_of_item_to_drop] execVm "cargoScript.sqf"
Of course both – the carrier and the cargo – have to exist somewhere on the map when you run the script. TIP: you can put all that execVM stuff above into a waypoint's OnAct field.


Forum topic:
- BI forums




Enable javascript to be able to download from Armaholic please!



Tags: Cargo,   Drop