Jump to content
Sign in to follow this  
dmos

[DONE] Cargo drop simple script

Recommended Posts

Spent a good part of my evening on this. Didn't find any cargo drop scripts that are to the point so made this.

_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;

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.

Hope this helps anyone, check out my sandbox where I'll use this

Cheers

-dmos

Edited by dmos

Share this post


Link to post
Share on other sites

Thank's ,a smart script on the hand is good!!

Share this post


Link to post
Share on other sites

Quick question...

How do you use this??? :confused:

I presume by looking at the script this is obviously a script uses to drop vehicles or ammo from a passing plane.

It would be awesome if you put a brief explanation on how to use this awesome script!!! I've been looking for something like this, especially a cargo script in which AI can do this.

-Bigshot

Share this post


Link to post
Share on other sites

oh crap you're right, i didn't put in an explanation :) I'm updating the first post now

Share this post


Link to post
Share on other sites

Thanks for the explanation! Can't wait to try it out!

I would also guess that this would work for a Plane that is spawned in using the spawn function.

As long as the vehicle is spawned in and it's given a name correct?

-Bigshot

Share this post


Link to post
Share on other sites

As long as you can reference the plane right, it doesn't matter how you got it :) by the way if youre talking about spawnVehicle function, keep in mind it outputs an array – not a vehicle name (i think vehicle name is the first element of the array though). Look it up on biki

Share this post


Link to post
Share on other sites

Hey i just tried out your script for the cargo drop, and it worked great!

But i stumbled upon a problem...

When the cargo lands in the parachute it simply dosent work when i try to equip or take some of the gear.

I tried to place the crate right infront of me, and i could take and drop gear. But as soon as the cargo ends up in the parachute and lands, it simply wont allow me to take the gear.

I can look into it and the rearm option is even there, but nothing happens with the "take" button.

Sorry for replying to such an old thread.

Looking forward for an answer, in the mean time ill play around with it!

Share this post


Link to post
Share on other sites

I've seen this problem before it does seem there is some sort of bug. The work around is to spawn the dropped item and delete the old object

Add these lines to the end of the script should fix it

_realItem = createVehicle [typeof  _dropItem,_dropItemPos,[], 0, "can_collide"] ; 
_realItem  setDir getDir  _dropItem;
deletevehicle  _dropItem;

Share this post


Link to post
Share on other sites
I've seen this problem before it does seem there is some sort of bug. The work around is to spawn the dropped item and delete the old object

Add these lines to the end of the script should fix it

_realItem = createVehicle [typeof  _dropItem,_dropItemPos,[], 0, "can_collide"] ; 
_realItem  setDir getDir  _dropItem;
deletevehicle  _dropItem;

Great it worked!

Thanks, finally we will be able to call down the cargo with an actually usable cargo hehe.

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  

×