Jump to content
Sign in to follow this  
Cougar69

Attach vehicle to BH

Recommended Posts

Hello all,

I've been searching for a script to help me attach vehicle for transportation but I havent been able to find one for Arma. I've found 2 for ofp but since I can't open the mission itself I can't see how it's been made as I don't know much about scripting. I recall playing a mp mission in Arma some time ago that someone included the option to hook a vehicle to the chopper but I can't recall what the name was.

If anyone know where I can put my paw on one let me know it would be really appreciated.

Thank You

Cougar

Share this post


Link to post
Share on other sites

runAirliftingCars.sqf:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> _a = _this select 0;

_b = _this select 1;

//_vehicleforlift = _a;

//hint "Debug: Use of airlift action detected...";

//sleep 2;

if ((player == driver _a) AND ("SoldierWPilot" == typeOf player))

then {

[_a] execVM "airLiftingCars.sqf";

hint "Attaching, get ready to take off!";

} else {

if (NOT("SoldierWPilot" == typeOf player)

) then {

hint "Only pilots flying BH can airlift!";

} else {

hint "You are not the driver of the chopper!";

};

};

airliftingCars.sqf:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">private ["_carrier,_cycle","_airliftedobj","_attached"];

_carrier = _this select 0;

_cycle = 0.01;

_attached = false;

_airliftedobj = nearestObject [_carrier, "Car"];

//hint "Debug: Airlifting script started..";

//sleep 3;

if ( (_airliftedobj distance _carrier) < 30 ) then

{

hint format ["%1 is going to be airlifted - take your chopper up to somewhere between 20 and 25 meters", typeOf _airliftedobj];

waitUntil { ((_airliftedobj distance _carrier) <= 30) && ( ((getPos _carrier select 2) >= 20) && ((getPos _carrier select 2) <= 25) ) };

_x = (getPos _carrier select 0);

_y = (getPos _carrier select 1);

_z = (getPos _carrier select 2);

_airliftedobj setpos [_x,_y,_z - 7];

hint format ["%1 attached - to release it, put the %1 less than 1m above the ground.", typeOf _airliftedobj];

_attached = true;

player groupChat "loop starting";

for [{_airloop=2}, {_airloop>=1}, {_airloop=getPos _airliftedobj select 2}] do

{

_x = (getPos _carrier select 0);

_y = (getPos _carrier select 1);

_z = (getPos _carrier select 2);

_airliftedobj setpos [_x,_y,_z - 7];

sleep _cycle;

};

player groupchat "loop ending";

if ( _attached && (getPos _airliftedobj select 2) < 1 ) then

{

_attached = false;

hint "Detached";

};

} else

{

hint "No vehicles in range detected...";

sleep 3;

};

Put this in each choppers init:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">this addAction ["Airlift vehicle", "runAirliftingCars.sqf"];

This works in MP on both dedicated or hosted, but be warned:

If you are lagging just a little bit, or you have high ping, the car may detatch itself no matter the altitude. So only use it when you have a good connection. As it is now, it only works for western pilots - you can change SoldierWPilot to SoldierEPilot for eastern chopper (I think). You can airlift any vehicle of type "car" (hummers, sedans and trucks (the latter is very dangerous, as it can collide with the BHs tail rotor if you pull the nose up).

Replacing <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> [_a] execVM "airLiftingCars.sqf"; with <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">airL=[_a] spawn scr_airLiftingCars; may give better performance. If you do use spawn, remember to put<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">scr_airLiftingCars=compile preprocessfile "airLiftingCars.sqf"

Btw... There are tools that let you 'open' the missions - like cpbo.

Share this post


Link to post
Share on other sites

In SP it works alot better inferno! In MP the airlifted vehicle often looks like it will fall down any second, but in SP it keeps in 1 position.

Share this post


Link to post
Share on other sites

Unicorn, I wrote a similar script for some of my C&H missions and in order to get around some of the MP lag, I have it delete the original vehicle and recreate it so the vehicle is local to the person using the action. Then it doesn't lag nearly as much.

Also, I put in a check for count crew > 0 so it won't pick up vehicles with crew. Otherwise it'll lag worse.

Just an FYI for optimization.

Share this post


Link to post
Share on other sites

Ooh, smart! But... You'd need a lot of checks for fuel, ammo and stuff, yes (to prevent cheating)? And what about ammo and weapons stored in the cargo compartment?

Maybe moving the original vehicle away and replace it with a clone would be a simpler way to do it.

Share this post


Link to post
Share on other sites

Well thats exactly what I was looking for and I thank you for helping me out! yay.gif

Share this post


Link to post
Share on other sites
Unicorn, I wrote a similar script for some of my C&H missions and in order to get around some of the MP lag, I have it delete the original vehicle and recreate it so the vehicle is local to the person using the action.  Then it doesn't lag nearly as much.

Also, I put in a check for count crew > 0 so it won't pick up vehicles with crew.  Otherwise it'll lag worse.

Just an FYI for optimization.

How do I add that check into the script? Is it easy or it's alot of coding?

Thank You

Share this post


Link to post
Share on other sites

greate, That really I am look for too.

Frankly, I am a newbie to make mission and create script.

Could you have any sample mission?

Share this post


Link to post
Share on other sites
greate, That really I am look for too.

Frankly, I am a newbie to make mission and create script.

Could you have any sample mission?

Here a really basic mission 1 humvee 50cal with a blackhawk and a pilot. If u change the pilot to something else you wont be able to attach a vehicle.

Download here

Hope it helps

Share this post


Link to post
Share on other sites

I get following forbidden error message, when I try to download your mission sad_o.gif

------------------------------------------------

Forbidden

Remote Host: [202.232.87.165, 10.133.24.251]

You do not have permission to access http://nosquad.i8.com/Airliftingdemo.zip

Data files must be stored on the same site they are linked from.

--------------------------------------------------

Share this post


Link to post
Share on other sites

tryed the scripe out works great .

but is there any way to get ai to just pilot a chopper and drop the vehicle at a drop off point .

i would rather be leading my sect than piloting(im a crap pilot)to be truthfull about it.

tryed acouple of ofp scripes but to no end all i managed to do wass drag a car a bout the island

bk1276

Share this post


Link to post
Share on other sites

Unicorn, yes, that would be the simplest solution. But if a person wanted to get complex, they could also get all those variables and pass them to the towed vehicle.

In this case I'd prefer to move the vehicle to [0,0,0] -- it should stay above the water when it's moved like that, but I'm not sure. Of course you could always put a spot somewhere on the map to relocate it.

Share this post


Link to post
Share on other sites

The basic idea can be found in OFPEC,

I modified some part of the original script in order to create parachute after drop.

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

; script by David Berka (David.Berka@nmi.at)

; 2006/08/29 quick fix cosmetic repairs by Mr.Peanut

; 2007/3/14  modified by i73

; [chopper, cargo] exec "helidrop.sqs"

; on ACT of waypoint "release1 = 1"

_heli = _this select 0

_car = _this select 1

#Update

;obtain the position of helicopter

_heliPos = getPos _heli

_heliPosX = _heliPos select 0

_heliPosY = _heliPos select 1

_heliPosZ = _heliPos select 2

;set the position of car under the helicopter

_car setPos [_heliPosX, _heliPosY, _heliPosZ - 3]

_car setVelocity velocity _heli

_heading = getDir _heli

_car setDir _heading

~0.01

? (release1 == 1) : goto "Drop"

goto "Update"

#Drop

;create the parachute in the position of car

_chute = "parachute" createvehicle getpos _heli

_chute setDir _heading

~0.01

_carPos = getPos _car

_carPosX = _carPos select 0

_carPosY = _carPos select 1

_carPosZ = _carPos select 2

_chute setPos [_carPosX, _carPosY, _heliPosZ - 5]

#DropUpdate

_chutePos = getPos _chute

_chutePosX = _chutePos select 0

_chutePosY = _chutePos select 1

_chutePosZ = _chutePos select 2

_car setPos [_chutePosX, _chutePosY, _chutePosZ - 3]

_car setVelocity velocity _chute

~0.01

? (_chutePosZ > 3) : goto "DropUpdate"

Share this post


Link to post
Share on other sites

Salute inferno7312,

please help me with my demo on this script. I read the script like a puzzle and I know I have not done it correctly since it does not work. I not not great with scripting, still learning.

Is it possible if you can correct the demo I send here for me and send it back. I will really like to use this script for a mission I make now and for the future. Thankyou.

Demo mission download link

Share this post


Link to post
Share on other sites
I can not open your file because this size of your file is 0KB  banghead.gif

BTW, I am a beginner too.  biggrin_o.gif

Thankyou for telling me abot the filebeing zero.

I have updated the link:

New link.

Sorry for bugging you though on this. I tried to do it once more but still missing something.

Share this post


Link to post
Share on other sites

DecimusAquila

i had a wee look at your mission file iwill see if i can say how i got it to go .

1. place any chopper and name it   _heli (the underscore is any letter you want i used a ).

2. place any empty transport and name it  _car  (the underscore is any letter you want i used a ).

3. put a trigger down covering the units and set actovatied by bluefor and set it to once.

4. in the trigger on activation box place

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">[aheli,aCar] exec "helidrop.sqs"

5.put your way points down for your chopper and when you want it to drop the cargo put

a waypoint at that location and in the on act box place

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">"release1 = 1"

and you dont nead to place a parachute down it will create one via the script

hope this helps to set it up for you

bk1276

Share this post


Link to post
Share on other sites

bk 1276 is right.

I don't need say anything more. biggrin_o.gif

Bug should be metioned;

if you execute "helidrop.sqs" in the init field of a chopper, the chopper fails to take off "sometimes" . So  execute "helidrop.sqs" in waypoint will be recommended.

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  

×