Source of the script : http://forums.bistudio.com/showthread.php?157045-script-apply-wind-to-Helicopters
Script used : (some features are not used in order to allow aircraft to fly)
while {true} do
{
waitUntil{vehicle player isKindOf "Air" && (driver vehicle player == player)};
_unit = vehicle player;
enableCamShake true;
//to change the wind:
//10-20 seems to work good, lower _windstrength number to make wind stronger, warning if the wind is to strong you might have trouble flying in certain circumstances.
_windstrength = 30;
while{driver _unit == player && (!(isTouchingGround (_unit))) && ((getPosATL(_unit) select 2) > 1) }do
{
_starttime = time;
/*----------------------WIND--------------------- */
_unitvelocity = velocity _unit;
_unitxv = _unitvelocity select 0;
_unityv = _unitvelocity select 1;
_unitzv = _unitvelocity select 2;
_wind_unitvelocity = wind;
_windxv = _wind_unitvelocity select 0;
_windyv = _wind_unitvelocity select 1;
_windzv = _wind_unitvelocity select 2;
_unit setVelocity [(_unitXV + (_windXV/_windstrength)),(_unitYV + (_windYV/_windstrength)),(_unitZV + (_windZV/_windstrength))];
/*----------------------SETTLING WITH POWER / VOTEX RING EFFECT---------------------*/
if(isEngineOn _unit)then
{
_unitvelocity = velocity _unit;
_unitxv = _unitvelocity select 0;
_unityv = _unitvelocity select 1;
_unitzv = _unitvelocity select 2;
_unitxyv = (sqrt((_unitxv ^ 2)+(_unityv ^ 2)));
_unitxyzv = (sqrt((_unitxv ^ 2)+(_unityv ^ 2)+(_unitzv ^ 2)));
if(_unitxyzv != 0)then
{
/*------ _unitAoD = (acos( _unitxyv / _unitxyzv));
if((_unitzv <= -7.5) && (_unitAoD >= 31) && (_unitAoD <= 90))then
{
addCamShake [5, 0.5, 4];
_unit setVelocity [(_unitxv),(_unityv),(_unitzv + (_unitzv/30) - 1.5)];
}; ---*/
};
};
/*----------------------UP/DOWN DRAFTS NEAR STEEP SLOPES--------------------- */
_height1 = getTerrainHeightASL (position _unit);
sleep 0.1;
_height2 = getTerrainHeightASL (position _unit);
if((_height2 >= (_height1 + 1.2)) || (_height2 <= (_height1 - 1.2)))then
{
_unitvelocity = velocity _unit;
_unitxv = _unitvelocity select 0;
_unityv = _unitvelocity select 1;
_unitzv = _unitvelocity select 2;
_unit setVelocity [(_unitxv),(_unityv),(_unitzv + ((floor(random 3)) - 1))];
};
/*----------------------AUTOROTATION--------------------- */
if(!isEngineOn _unit)then
{
_unitvelocity = velocity _unit;
_unitxv = _unitvelocity select 0;
_unityv = _unitvelocity select 1;
_unitzv = _unitvelocity select 2;
_vectorup = vectorUp _unit;
_unitxu = _vectorup select 0;
_unityu = _vectorup select 1;
_unitzu = _vectorup select 2;
_velvec = (sqrt ( _unitxv ^ 2 + _unityv ^ 2 + _unitzv ^ 2 ));
_div1 = ((_velvec)+sqrt(_unitxu^2+_unityu^2+_unitzu^2));
_unitvelocityduxy = ((_unitxv*_unitxu + _unityv*_unityu + _unitzv*_unitzu)/_div1);
_unitvelocityduz = (sin(acos _unitvelocityduxy));
_deltatime = (time - _starttime);
_zconv = (0.5 * _deltatime);
_xyconv = (0.02 * _deltatime);
_convvvar = (((-_unitvelocityduxy)*_zconv + (abs _unitvelocityduz)*_xyconv)*_velvec);
_autowind = ((((_windxv/_windstrength) * _unitxu) + ((_windyv/_windstrength) * _unityu))*0.75);
_unitxyzv = ([(_unitxv + _unitxu*_convvvar),(_unityv + _unityu*_convvvar),((_unitzv + _unitzu*_convvvar) + _autowind)]);
_unit setVelocity _unitxyzv;
};
};
};
};