Welcome, Guest Thursday 17th April 2014, 11:40:24
   Home   Help Search Login Register  

OFPEC Forum

Author Topic: Helo's Direction on landing?  (Read 198 times)
0 Members and 1 Guest are viewing this topic.
Bingoz
*
Offline Offline


« on: 09 Feb 2011, 23:46:02 »

CODE]
_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]

lol I donít even know if it works any more, But I will work on it and post something here if I can do anything more.

I know of one in the missions folder called "heliLanding.sqf"  I am going to analyze that one bit, until can find an alternative.

any help welcome :)

Here is a simple version of that file. I removed things not really needed for such a simple landing.

It allows the user to set the direction at landing, as well as other settings.
Usage is as follows:

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

Action Menu:
Code:
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:
_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.

Code:
_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 actio
Code:
Null = [Helo_Name, Duration_of landing, End_Pos [x,y,z] Direction_end, velocity_end] ExecVM "scriptname.sqf";

Action Menu:
Code:
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:
_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 » Logged
Pages: [1]   Go Up
  Send this topicPrint  
 
Jump to: