Jump to content
Sign in to follow this  
Αplion

Vehicles attached to Ship

Recommended Posts

Hello Guys,

I am sorry for digging up a year-old thread but I find it most informative and helpful. It just does not fully suit to my needs. Let's say I have a chooper with walkable ramp and deck (Mi-6 Hook). I would like to drive in a car into a cargo compartment of the heli and lash the car exactly where it stands at the ramp. Could be possible to use things like ie. take position of the heli, take position of the car, compare both positions, and finally store a score/result as a XX, YY, ZZ in Gnat's script? That way we would not have to use memory points. I found a similar idea in cargo management of Mi-26 by mukcep however you can attach only one vehicle to it. I just want to have a possibility to attach a several objects to the chopper. It would be more realistic and flexible in the same time allowing for better cargo management. By objects I mean not only vehicles but also cargo palettes, boxes and small containers. Is there a way to change Gnat or mukcep's solutions to achieve that?

---------- Post added at 12:00 PM ---------- Previous post was at 10:32 AM ----------

Allright, I was able to lash two vehicles inside the chopper using mukcep modified idea, however I can release (unlash) only the first one. The action for the second is visible but do nothing apparently. For sure, there is something I have missed or do not know. Should vehs variables be public to get it working?

config.cpp UserActions

                       class Mi6_loadcargo2
		{
			onlyforplayer = 0;
			displayName = "Lash 2nd cargo";
			position = "zamerny";
			radius = 10;
			showwindow = 0;
			condition = "((vehicle player != this) and (vehicle player != player) and (speed vehicle this < 5))";
			statement = "[this, vehicle player, player] execVM ""\int73_mi6a\scripts\mi6attach2.sqf""";
		};
		class Mi6_unloadcargo2
		{
			onlyforplayer = 0;
			displayName = "Release 2nd cargo";
			position = "zamerny";
			radius = 10;
			showwindow = 0;
			condition = "(vehicle player != this) and (vehicle player != player)";
			statement = "[this, vehicle player, player] execVM ""\int73_mi6a\scripts\mi6detach2.sqf""";
		};
		class Mi6_loadcargo
		{
			onlyforplayer = 0;
			displayName = "Lash 1st cargo";
			position = "zamerny";
			radius = 10;
			showwindow = 0;
			condition = "((vehicle player != this) and (vehicle player != player) and (speed vehicle this < 5))";
			statement = "[this, vehicle player, player] execVM ""\int73_mi6a\scripts\mi6attach1.sqf""";
		};
		class Mi6_unloadcargo
		{
			onlyforplayer = 0;
			displayName = "Release 1st cargo";
			position = "zamerny";
			radius = 10;
			showwindow = 0;
			condition = "(vehicle player != this) and (vehicle player != player)";
			statement = "[this, vehicle player, player] execVM ""\int73_mi6a\scripts\mi6detach1.sqf""";
		};

And four scripts, mi6attach1.sqf:

_plane = _this select 0;
_veh = _this select 1;
_player = _this select 2;
_d = direction _plane;
_dv = direction _veh;
_dv = _dv - _d;


_difx = (cos(_d))*((getpos _veh select 0) - (getpos _plane select 0)) - (sin(_d))*((getpos _veh select 1) - (getpos _plane select 1));
_dify = (cos(_d))*((getpos _veh select 1) - (getpos _plane select 1)) + (sin(_d))*((getpos _veh select 0) - (getpos _plane select 0));


if (ABS(_difx)>6) then
{
   hint ("The vehicle is not lined properly!");
if (true) exitWith {};
}
else
{
_player setfuel 0;
_player action ["GetOut", vehicle _player];
player disableAI "ANIM";  
_veh disableAI "ANIM"; 
_veh disableAI "MOVE"; 
_veh setfuel 0;
sleep 0.01;
_difz = (getpos _plane select 2) - (getpos _veh select 2) + 6.0;
_veh allowDamage false;
_player enableSimulation false;
hint format ["X1: %1 Y1: %2 Z1: %3", _difx, _dify, _difz];
_veh attachTo [_plane,[_difx,_dify,_difz]]; 
_veh setfuel 0;
sleep 0.01;
_difz = (getpos _plane select 2) - (getpos _veh select 2) + 6.0;
_veh allowDamage false;
hint format ["X2: %1 Y2: %2 Z2: %3", _difx, _dify, _difz];
_veh attachTo [_plane,[_difx,_dify,_difz]]; 
_veh setDir _dv;
_veh setfuel 0;
sleep 2;
_veh enableSimulation false;
_player enableSimulation true;
if (true) exitWith {};
};

mi6detach1.sqf:

_plane = _this select 0;
_veh = _this select 1;
_player = _this select 2;
_null = objNull;


detach _player;
detach _veh;
_veh attachTo [_null,[0,0,0]];
_player attachTo [_null,[0,0,0]];
_veh setfuel 1;
_veh enableSimulation true;
_veh allowDamage true;

if (true) exitWith {};

mi6attach2.sqf:

_plane2 = _this select 0;
_veh2 = _this select 1;
_player = _this select 2;
_d2 = direction _plane2;
_dv2 = direction _veh2;
_dv3 = _dv2 - _d2;


_difx2 = (cos(_d2))*((getpos _veh2 select 0) - (getpos _plane2 select 0)) - (sin(_d2))*((getpos _veh2 select 1) - (getpos _plane2 select 1));
_dify2 = (cos(_d2))*((getpos _veh2 select 1) - (getpos _plane2 select 1)) + (sin(_d2))*((getpos _veh2 select 0) - (getpos _plane2 select 0));


if (ABS(_difx2)>6) then
{
   hint (localize "STR_AN225_OP");
if (true) exitWith {};
}
else
{
_player setfuel 0;
_player action ["GetOut", vehicle _player];
player disableAI "ANIM";  
_veh2 disableAI "ANIM"; 
_veh2 disableAI "MOVE"; 
_veh2 setfuel 0;
sleep 0.01;
_difz2 = (getpos _plane2 select 2) - (getpos _veh2 select 2) + 6.0;
_veh2 allowDamage false;
_player enableSimulation false;
hint format ["X1: %1 Y1: %2 Z1: %3", _difx2, _dify2, _difz2];
_veh2 attachTo [_plane2,[_difx2,_dify2,_difz2]]; 
_veh2 setfuel 0;
sleep 0.01;
_difz2 = (getpos _plane2 select 2) - (getpos _veh2 select 2) + 6.0;
_veh2 allowDamage false;
hint format ["X2: %1 Y2: %2 Z2: %3", _difx2, _dify2, _difz2];
_veh2 attachTo [_plane2,[_difx2,_dify2,_difz2]]; 
_veh2 setDir _dv2;
_veh2 setfuel 0;
sleep 2;
_veh2 enableSimulation false;
_player enableSimulation true;
if (true) exitWith {};
};

and finally mi6detach2.sqf:

_plane2 = _this select 0;
_veh2 = _this select 1;
_player = _this select 2;
_null = objNull;


detach _player;
detach _veh2;
_veh2 attachTo [_null,[0,0,0]];
_player attachTo [_null,[0,0,0]];
_veh2 setfuel 1;
_veh2 enableSimulation true;
_veh2 allowDamage true;

if (true) exitWith {};

Share this post


Link to post
Share on other sites

@NightIntruder ... try this below ...

Into your config use just one time the "mi6attach" and "mi6detach" scripts

Config.cpp

class Mi6_loadcargo
		{
			onlyforplayer = 0;
			displayName = "Lash 1st cargo";
			position = "zamerny";
			radius = 10;
			showwindow = 0;
			condition = "((vehicle player != this) and (vehicle player != player) and (speed vehicle this < 5))";
			statement = "[this, vehicle player, player] execVM ""\int73_mi6a\scripts\mi6attach.sqf""";
		};
		class Mi6_unloadcargo
		{
			onlyforplayer = 0;
			displayName = "Release 1st cargo";
			position = "zamerny";
			radius = 10;
			showwindow = 0;
			condition = "(vehicle player != this) and (vehicle player != player)";
			statement = "[this, vehicle player, player] execVM ""\int73_mi6a\scripts\mi6detach.sqf""";
		};

Then try these ...

mi6attach.sqf script

_plane = _this select 0;
_veh = _this select 1;
_player = _this select 2;
_d = direction _plane;
_dv = direction _veh;
_dv = _dv - _d;


_difx = (cos(_d))*((getpos _veh select 0) - (getpos _plane select 0)) - (sin(_d))*((getpos _veh select 1) - (getpos _plane select 1));
_dify = (cos(_d))*((getpos _veh select 1) - (getpos _plane select 1)) + (sin(_d))*((getpos _veh select 0) - (getpos _plane select 0));


if (ABS(_difx)>6) then
{
   hint ("The vehicle is not lined properly!");
if (true) exitWith {};
}
else
{
//_player setfuel 0;
_player action ["GetOut", vehicle _player];
_player disableAI "ANIM";  
_veh disableAI "ANIM"; 
_veh disableAI "MOVE"; 
//_veh setfuel 0;
sleep 0.01;
_difz = (getpos _plane select 2) - (getpos _veh select 2) + 6.0;
_veh allowDamage false;
//_player enableSimulation false;
hint format ["X1: %1 Y1: %2 Z1: %3", _difx, _dify, _difz];
_veh attachTo [_plane,[_difx,_dify,_difz]]; 
_veh setfuel 0;
sleep 0.01;
_difz = (getpos _plane select 2) - (getpos _veh select 2) + 6.0;
_veh allowDamage false;
//hint format ["X2: %1 Y2: %2 Z2: %3", _difx, _dify, _difz];
_veh attachTo [_plane,[_difx,_dify,_difz]]; 
_veh setDir _dv;
//_veh setfuel 0;
sleep 2;
//_veh enableSimulation false;
//_player enableSimulation true;
if (true) exitWith {};
};

mi6detach.sqf script

_plane = _this select 0;
_veh = _this select 1;
_player = _this select 2;
_null = objNull;

//detach _player;
detach _veh;
_veh attachTo [_null,[0,0,0]];
_player attachTo [_null,[0,0,0]];
_veh setfuel 1;
//_veh enableSimulation true;
_veh allowDamage true;

if (true) exitWith {};

By this way it is working fine on me.

Let me know if it also works for you.

Share this post


Link to post
Share on other sites

I am sorry, I have not checked it carrefully. For the second vehicle I had to jump into a passanger seat to see action for release. Obviously, IT DOES WORK! Also I made bigger radius (20m). Thanks a lot Aplion for help :)

Edited by NightIntruder
Solved

Share this post


Link to post
Share on other sites
It does not work, I am affraid. Actually, it perfectly does for the first vehicle, but the second one even does not have the action of releasing cargo now. No matter at which seat I jumped into there is no action to release the second vehicle. I will try to make a radius bigger and we'll see, perhaps that's the problem. Anyway, thanks for input Aplion, I appreciate it really.

Have a look on that mate ...

I've been used these scripts as I told you above ..

Plus something more that came to me now ... in your config the useraction searches about a memory point or selection into the model which called "zamerny" ... are you sure that the model has such point or selection ?

Share this post


Link to post
Share on other sites

While you were writing these post I was editing my previous one :) Of course, your script works like a charm! Sometimes it needed from player to look at side to see an action but still it is far better then I did. All credits go to mukcep and you for this work. Again, big THANK YOU, you helped me a lot :)

Share this post


Link to post
Share on other sites

If the action memory point is right beside some Geometry lod structure it usually assists making the action appear quicker to the player.

Share this post


Link to post
Share on other sites

You mean that I should copy&paste memory points responsible for action right into GeoLOD, close to some part of the model? Or just move them inside memory LOD near some GeoLOD's parts?

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  

×