Jump to content
Sign in to follow this  
evil_brownie

Help with Lifting Script

Recommended Posts

Hello everyone. I'm working on this script and i'm kinda running out of ideas to get it to work as i intend.

I admit, it is an expansion of the BTC lift script (as my scripting skills aren't that great and all i wanted is to expand it a bit, since it was simple and very good, to fit my needs)

Given that, this is my work so far on it:

lift = 1;

lifted = 0;

while {true} do {

if (!(vehicle player == player)) then {

_chopper = vehicle player;

_chopperpos = getpos _chopper;

_chopperx = _chopperpos select 0;

_choppery = _chopperpos select 1;

_chopperz = _chopperpos select 2;

_cargo = nearestObject [_chopper,"landvehicle"];

if ((_chopperz < 12) && (_chopperz > 7) && (_chopper distance _cargo < 12) && driver _chopper == player) then

{

if (lifted == 1) then {_chopper removeAction liftActionId;};

_cargopos = getpos _cargo;

_cargox = _cargopos select 0;

_cargoy = _cargopos select 1;

if ((lifted == 0) && ((_chopperx <= (_cargox + 10)) && (_chopperx >= (_cargox - 10))) && ((_choppery <= (_cargoy + 10)) && (_choppery >= (_cargoy - 10))) && (lift == 1)) then

{

if (_chopper isKindOf "UH1H_TK_EP1" or _chopper iskindof "uh1y" or _chopper iskindof "mv22" or _chopper iskindof "UH1H_TK_GUE_EP1" or _chopper isKindOf "UH60M_EP1" or _chopper isKindOf "BAF_Merlin_HC3_D" or _chopper iskindof "mh60s") then {

if (_cargo isKindOf "Motorcycle" or _cargo isKindOf "Car" or _cargo iskindof "staticcannon" or _cargo iskindof "rubberboat") then {

liftActionId = _chopper addAction ["Lift vehicle","=BTC=Lift\attachCargo.sqf"];

lift = 0;

};

};

if (_chopper isKindOf "mi17_cdf" or _chopper isKindOf "mi17_ins" or _chopper isKindOf "mi17_medevac_ru" or _chopper isKindOf "Mi171Sh_CZ_EP1" or _chopper isKindOf "Mi17_TK_EP1") then {

if (_cargo isKindOf "Motorcycle" or _cargo isKindOf "Car" or _cargo iskindof "staticcannon") then {

liftActionId = _chopper addAction ["Lift vehicle","=BTC=Lift\attachCargo.sqf"];

lift = 0;

};

};

if (_chopper isKindOf "CH_47F_EP1" or _chopper isKindOf "CH_47F_BAF") then {

if (_cargo isKindOf "motorcycle" or _cargo iskindof "car" or _cargo iskindof "staticcannon" or _cargo iskindof "truck" or _cargo iskindof "lav25_base") then {

liftActionId = _chopper addAction ["Lift vehicle","=BTC=Lift\attachCargo.sqf"];

lift = 0;

};

};

};

}

else

{

if ((_chopper isKindOf "Helicopter" or _chopper iskindof "mv22" && (lift == 0)) && ((_chopperz > 7) or (_chopper distance _cargo > 5))) then {

_chopper removeAction liftActionId;

lift = 1;

};

};

};

sleep 0.1;

};

if(true) exitWith {};

Now what i want to add is the ability for the given aircraft (plus the ones i still have to add) to airlift boats (namely RHIBs and CRRCs) and some static objects, like containers, to give it a true VERTREP feel.

Adding a "gravity system" to bring stuff to the helicopters relative AGL level 0 would be nice (so one could put stuff on top of a building, instead of going through it :D) (this obviously only for static things like the artillery / objects, as vehicles tend to fall automatically (but not objects, thanks BIS for your flawed logic :D)

Reason why i'm doing this (completely pointless to whoever reads this):

RAV's Lifter doesn't work with GLTs MOAB for some unknown reason (confirmed)

and well..., it f'ed up the flight controls of the RAF_chinook addon (have no idea why but not entirely a problem)

Share this post


Link to post
Share on other sites

Oh my script :)

I've an update :)...

If someone knows how to add the gravity let me know an i can fix it...I've not much time in this period :(

Here we go!

LiftInit.sqf

if (isDedicated) exitwith {};
if (typeof player != "US_Soldier_Pilot_EP1") exitwith {};
lift = 1;
lifted = 0;
_cargo       = objNull;
cargo_lifted = objNull;
while {true} do 
{
waitUntil {vehicle player != player && vehicle player iskindof "Helicopter";};
   if (!(vehicle player == player)) then 
{
       _chopper = vehicle player;
    _chopperpos = getpos _chopper;
    _chopperx = _chopperpos select 0;
    	_choppery = _chopperpos select 1;
   	_chopperz = _chopperpos select 2;
	_cargo_array = nearestObjects [_chopper, ["LandVehicle","Air"], 50];
	if (count _cargo_array > 1) then {_cargo = _cargo_array select 1;} else {_cargo = objNull;};
	//_cargo = nearestObject [_chopper, "LandVehicle"];
	// or _cargo isKindOf "StaticMGWeapon" or _cargo isKindOf "StaticATWeapon" or _cargo isKindOf "StaticAAWeapon" or _cargo isKindOf "StaticGrenadeLauncher" or _cargo isKindOf "StaticMortar" or _cargo isKindOf "StaticSEARCHLight"
	// or _cargo isKindOf "StaticWeapon" 
	if ((_cargo isKindOf "LandVehicle" || _cargo isKindOf "Air") && (_chopperz < 12) && (_chopperz > 7) && (_chopper distance _cargo < 12) && (driver _chopper == player)) then
	{
		cargo_lifted = _cargo;
		if (lifted == 1) then {_chopper removeAction liftActionId;};
		_cargopos = getpos _cargo;
		_cargox = _cargopos select 0;
		_cargoy = _cargopos select 1;
		if ((lifted == 0) && ((_chopperx <= (_cargox + 10)) && (_chopperx >= (_cargox - 10))) && ((_choppery <= (_cargoy + 10)) && (_choppery >= (_cargoy - 10))) && (lift == 1)) then
		{
		    if (_chopper isKindOf "MH6J_EP1") then 
			{
				if (_cargo isKindOf "Motorcycle") then 
				{
					liftActionId = _chopper addAction ["Lift vehicle","=BTC=Lift\attachCargo.sqf"];
					lift = 0;
				};
			};
			if (_chopper isKindOf "UH1H_TK_EP1") then 
			{
				if (_cargo isKindOf "Motorcycle" || _cargo isKindOf "Car") then 
				{
					liftActionId = _chopper addAction ["Lift vehicle","=BTC=Lift\attachCargo.sqf"];
					lift = 0;
				};
			};	
		    if (_chopper isKindOf "UH60M_EP1" || _chopper isKindOf "BAF_Merlin_HC3_D" || _chopper isKindOf "MH60S") then 
			{
				if (_cargo isKindOf "Motorcycle" || _cargo isKindOf "Car" || _cargo isKindOf "Truck" || _cargo isKindOf "Wheeled_APC" || _cargo isKindOf "Tracked_APC" || (_cargo isKindOf "Air" && getdammage _cargo == 1)) then 
				{
					liftActionId = _chopper addAction ["Lift vehicle","=BTC=Lift\attachCargo.sqf"];
					lift = 0;
				};
			};
		    if (_chopper isKindOf "CH_47F_EP1" || _chopper isKindOf "Mi171Sh_CZ_EP1" || _chopper isKindOf "Mi17_TK_EP1" || _chopper isKindOf "CH_47F_BAF") then {
				if (_cargo isKindOf "LandVehicle" || (_cargo isKindOf "Air" && getdammage _cargo == 1)) then 
				{
					liftActionId = _chopper addAction ["Lift vehicle","=BTC=Lift\attachCargo.sqf"];
					lift = 0;
				};
			};
		};
	}
	else 
	{
		if ((_chopper isKindOf "Helicopter" && (lift == 0)) && ((_chopperz > 7) or (_chopper distance _cargo > 5))) then 
		{
			_chopper removeAction liftActionId;
			lift = 1;
		};
	};
};
sleep 0.1;
};

if(true) exitWith {}; 

DetachCargo.sqf

lifted = 0;
_chopper = vehicle player;
_chopper removeAction SganciaActionId;
detach cargo_lifted;
vehicle player vehicleChat "Vehicle dropped";
if(true) exitWith {}; 

AttachCargo.sqf

_chopper = vehicle player;
_chopper removeAction liftActionId;
lifted = 1;
dropcargo = 0;
cargo_lifted attachTo [_chopper, [0,0,-9]];
vehicle player vehicleChat "Vehicle lifted";
SganciaActionId = _chopper addAction ["Drop Cargo","=BTC=Lift\detachCargo.sqf"];
if(true) exitWith {}; 

To add boats u have to modify this line:

_cargo_array = nearestObjects [_chopper, ["LandVehicle","Air","Ship"], 50];

And obiuvsly u have to add the class in the chopper line, for example:

		    if (_chopper isKindOf "UH60M_EP1" || _chopper isKindOf "BAF_Merlin_HC3_D" || _chopper isKindOf "MH60S") then 
			{
				if (_cargo isKindOf "Motorcycle" || _cargo isKindOf "Car" || _cargo isKindOf "Truck" || _cargo isKindOf "Wheeled_APC" || _cargo isKindOf "Tracked_APC" ||  _cargo isKindOf "Ship" || (_cargo isKindOf "Air" && getdammage _cargo == 1)) then 
				{
					liftActionId = _chopper addAction ["Lift vehicle","=BTC=Lift\attachCargo.sqf"];
					lift = 0;
				};
			};

Edited by Giallustio

Share this post


Link to post
Share on other sites

Thanks for the quick reply :D

Said lifter mod has a sort of gravity system to it, but asking the author for help will be tricky, as he's gone, no contact available, only checking out the contents of it.

:D 69th post :D

Share this post


Link to post
Share on other sites

I did play around with adding a bit of gravity before but never got around to making a lift script.

I just put the two together, it sort of works.

I also tried lifting a cargo container but it has strange effect and bounces a lot.

http://www.sendspace.com/file/t4izhi

Share this post


Link to post
Share on other sites

i tried out that mission, but because of that invisible gravity object, objects, when dropped, flip and when they land, well...they blow up : P

You only need gravity for static things, since they're not programmed to fall :/ but i think using getpos of the object when released and put it to 0 height should work well, but only for objects.

this way it probably will work well.

Share this post


Link to post
Share on other sites

Yes it was done more for fun than anything.

You could replace the invisible object with something that won't blow up but still fall although the chukar has about the best effects.

I guess to delete the chukar below a certain height and replace with a less effective object.

maybe not nothing else seems to work right.

Setpos will work but it will need to reduce the height and increase speed as it falls, Setpos usually looks jerky though.

Some objects will respond to the velocity command.

Edited by F2k Sel

Share this post


Link to post
Share on other sites

here is something to work with when making a false gravity.

change the _drop number up or down to get desired effect, test is name of static, heli is name of heli in the air.

add code to a radio trigger and it will attachTo the heli and then release it and it will "fall" until its on the ground.

_null = test spawn {
_this attachTo [heli,[0,0,-3]];
sleep 3;
detach _this;
sleep 1;

_drop = 0;
_dropit = true;
while {_dropit} do {
_drop = _drop + 0.005;
_this setPos [getPos _this select 0, getPos _this select 1, (getPos _this select 2) - _drop];
sleep 0.01;
if ((getPos _this select 2) < 1) then {
	_dropit = false;
	_this setPos [getPos _this select 0, getPos _this select 1, 0];
};
};
hint "its landed on ground";

};

Share this post


Link to post
Share on other sites

Good one! When i'll have much time i'll add this to the script...it could be nice if you can drop the object on the building's roof, i've to work on it.

Share this post


Link to post
Share on other sites

Well, after receiving some rather unfortunate news :(

I finally managed to make an easy gravity system only for static cannons (like the M119, but pretty sure it'll work on the rest, i'll test it out later today and then edit my post here) (Rest of vehicles still fall normally). Also it's instant fall to ground and unfortunately goes through buildings, but it's a start at least to make me happy.

DetachCargo.sqf

lifted = 0;
_chopper = vehicle player;
_chopper removeAction SganciaActionId;
detach cargo_lifted;
sleep 0.01;
if (cargo_lifted iskindof "staticcannon") then {
cargo_lifted setPos [getPos cargo_lifted select 0, getPos cargo_lifted select 1, 0];	
vehicle player vehicleChat "Vehicle dropped";
};

I'll probably have a look at the Lifter coding for ideas on how it works for keeping stuff on top of others, rather than going through them, but only when i get some free time.

Edit: Nope, it doesn't work with containers.

Edited by Evil_Brownie

Share this post


Link to post
Share on other sites

replace:

if (cargo_lifted iskindof "staticcannon") then {

with:

if (({cargo_lifted iskindof _x} count ["StaticWeapon","Static"]) != 0) then {

Share this post


Link to post
Share on other sites

I had tried out something only using || to select the different classes, the only problem was that i forgot to add the static class to one of the lines, efectively disabling the ability to lift those objects. I fixed it already and i can now lift all of the objects i wanted :)

Last two things that this needs to be completly awesome is a working gravity system (next on my to do list ;))and maybe putting it somewhere so you wouldn't have to put it on all missions, sort of like an addon, but that's another matter.

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  

×