Home   Help Search Login Register  

Author Topic: Helo's Direction on landing?  (Read 2628 times)

0 Members and 1 Guest are viewing this topic.

Offline Bingoz

  • Members
  • *
Helo's Direction on landing?
« on: 09 Feb 2011, 23:46:02 »
Code: [Select]
_heli = _this select 0;
_duration = _this select 1;
_dirEnd = _this select 2;
_Heliz = _This Select 3;
_Helip = GetPos _Heli Select 2;
_dirSTart = direction _heli;
_dirDiff = (_dirStart - _dirEnd) / _duration;

dOsTOP _heli;
Sleep 5;

_timeNow = time;
_timeFinal = _timeNow + _duration;

while {(time) <= _timeFinal} do {

_i = (time) - _timeNow;

_heli setdir (_dirStart - _dirDiff * _i);

hint str [_i,_dirDiff];

sleep 0.01; //--- Wait for next frame

while {_Helip > _Heliz} do {_Helip = _Helip -1; _Heli Flyinheight _Helip;};

};



Sleep 2;  // -- Enabeling Timer will stop the helo befor Decent Or Remove for a rolling landing (More Relistic.).


while {_Helip > _Heliz} do {_Helip = _Helip -1; _Heli Flyinheight _Helip;};

waitUntil {position _heli _Helip == _Heliz};

_Heli action ["engineOff", _Heli];

exit
Code: [Select]
Null = [Helo_Name, Duration_of landing, End_Pos [x,y,z] Direction_end, velocity_end] ExecVM "scriptname.sqf";

Action Menu:
Code: [Select]
Menuname = player addAction ["Land", "scriptname.sqf", [Helo_Name, Duration_of landing, End_Pos [x,y,z] Direction_end, velocity_end],1];

And the Simple script
 
Code: [Select]
_heli = _this select 0;
_duration = _this select 1;
_posEnd = _this select 2;

_dirEnd = if (count _this > 3) then {_this select 3} else {direction _heli};
_velEnd = if (count _this > 4) then {_this select 4} else {velocity _heli};

_timeNow = time;
_timeFinal = _timeNow + _duration;

//--- Start
_posStart = getposasl _heli;
_posStartX = _posStart select 0;
_posStartY = _posStart select 1;
_posStartZ = _posStart select 2;

_posEndX = _posEnd select 0;
_posEndY = _posEnd select 1;
_posEndZ = _posEnd select 2;


_dirSTart = direction _heli;

_velStart = velocity _heli;
_velStartX = _velStart select 0;
_velStartY = _velStart select 1;
_velStartZ = _velStart select 2;

_velEndX = _velEnd select 0;
_velEndY = _velEnd select 1;
_velEndZ = _velEnd select 2;

//--- Difference
_posDiffX = (_posEndX - _posStartX) / _duration;
_posDiffY = (_posEndY - _posStartY) / _duration;
_posDiffZ = (_posEndZ - _posStartZ) / _duration;

_dirDiff = (_dirStart - _dirEnd) / _duration;

_velDiffX = (_velStartX - _velEndX) / _duration;
_velDiffY = (_velStartY - _velEndY) / _duration;
_velDiffZ = (_velStartZ - _velEndZ) / _duration;

while {(time) <= _timeFinal} do {
_i = (time) - _timeNow;

_heli setposASL [
_posStartX + _posDiffX * _i,
_posStartY + _posDiffY * _i,
_posStartZ + _posDiffZ * _i
];
/*
_heli setvelocity [
_posStartX - _posDiffX * _i,
_posStartY - _posDiffY * _i,
_posStartZ - _posDiffZ * _i
];
*/
_heli setdir (_dirStart - _dirDiff * _i);
};

exit;

Worked for me.

« Last Edit: 10 Feb 2011, 04:44:46 by Bingoz »