From 2d290017d0f26706f36e24650e5475eca22caedb Mon Sep 17 00:00:00 2001 From: sethduda Date: Wed, 24 Aug 2016 22:57:49 -0400 Subject: [PATCH] Adding more improvements --- .../functions/fn_advancedRappellingInit.sqf | 133 ++++++++++++------ 1 file changed, 87 insertions(+), 46 deletions(-) diff --git a/addons/AR_AdvancedRappelling/functions/fn_advancedRappellingInit.sqf b/addons/AR_AdvancedRappelling/functions/fn_advancedRappellingInit.sqf index ff18260..5e2c6cf 100644 --- a/addons/AR_AdvancedRappelling/functions/fn_advancedRappellingInit.sqf +++ b/addons/AR_AdvancedRappelling/functions/fn_advancedRappellingInit.sqf @@ -294,7 +294,7 @@ AR_Get_Heli_Rappel_Points = { _validRappelPoints = []; { - if(count _x > 0) then { + if(count _x > 0 && count _validRappelPoints < missionNamespace getVariable ["AR_MAX_RAPPEL_POINTS_OVERRIDE",6]) then { _validRappelPoints pushBack _x; }; } forEach _rappelPoints; @@ -375,13 +375,12 @@ AR_Client_Rappel_From_Heli = { [[_player,_rappelDevice,_anchor],"AR_Play_Rappelling_Sounds_Global"] call AR_RemoteExecServer; - _rope2 = ropeCreate [_rappelDevice, [-0.15,0,0], 60]; - _rope2 allowDamage false; - _rope1 = ropeCreate [_rappelDevice, [0,0.15,0], _anchor, [0, 0, 0], 3]; - _rope1 allowDamage false; - - _player setVariable ["AR_Rappel_Rope_Top",_rope1]; - _player setVariable ["AR_Rappel_Rope_Bottom",_rope2]; + _bottomRopeLength = 60; + _bottomRope = ropeCreate [_rappelDevice, [-0.15,0,0], _bottomRopeLength]; + _bottomRope allowDamage false; + _topRopeLength = 3; + _topRope = ropeCreate [_rappelDevice, [0,0.15,0], _anchor, [0, 0, 0], _topRopeLength]; + _topRope allowDamage false; [_player] spawn AR_Enable_Rappelling_Animation_Client; @@ -393,29 +392,44 @@ AR_Client_Rappel_From_Heli = { _dir = (random 360) + (_lookDirFreedom / 2); _dirSpinFactor = (((random 10) - 5) / 5) max 0.1; - _decendRopeKeyDownHandler = -1; - if(_player == player) then { - _decendRopeKeyDownHandler = (findDisplay 46) displayAddEventHandler ["KeyDown", { - private ["_topRope","_bottomRope"]; + _ropeKeyDownHandler = -1; + _ropeKeyUpHandler = -1; + if(_player == player) then { + + _player setVariable ["AR_DECEND_PRESSED",false]; + _player setVariable ["AR_FAST_DECEND_PRESSED",false]; + _player setVariable ["AR_RANDOM_DECEND_SPEED_ADJUSTMENT",0]; + + _ropeKeyDownHandler = (findDisplay 46) displayAddEventHandler ["KeyDown", { if(_this select 1 in (actionKeys "MoveBack")) then { - _topRope = player getVariable ["AR_Rappel_Rope_Top",nil]; - if(!isNil "_topRope") then { - ropeUnwind [ _topRope, 3, (ropeLength _topRope) + 0.5]; - }; - _bottomRope = player getVariable ["AR_Rappel_Rope_Bottom",nil]; - if(!isNil "_bottomRope") then { - ropeUnwind [ _bottomRope, 3, (ropeLength _bottomRope) - 0.5]; - }; + player setVariable ["AR_DECEND_PRESSED",true]; + }; + if(_this select 1 in (actionKeys "Turbo")) then { + player setVariable ["AR_FAST_DECEND_PRESSED",true]; + }; + }]; + + _ropeKeyUpHandler = (findDisplay 46) displayAddEventHandler ["KeyUp", { + if(_this select 1 in (actionKeys "MoveBack")) then { + player setVariable ["AR_DECEND_PRESSED",false]; + }; + if(_this select 1 in (actionKeys "Turbo")) then { + player setVariable ["AR_FAST_DECEND_PRESSED",false]; }; }]; + } else { - [_rope1,_rope2] spawn { - params ["_rope1","_rope2"]; + + _player setVariable ["AR_DECEND_PRESSED",false]; + _player setVariable ["AR_FAST_DECEND_PRESSED",false]; + _player setVariable ["AR_RANDOM_DECEND_SPEED_ADJUSTMENT",(random 2) - 1]; + + [_player] spawn { + params ["_player"]; sleep 2; - _randomSpeedFactor = ((random 10) - 5) / 10; - ropeUnwind [ _rope1, 3 + _randomSpeedFactor, ropeLength _rope2]; - ropeUnwind [ _rope2, 3 + _randomSpeedFactor, ropeLength _rope1]; + _player setVariable ["AR_DECEND_PRESSED",true]; }; + }; // Cause player to fall from rope if heli is moving too fast @@ -432,6 +446,8 @@ AR_Client_Rappel_From_Heli = { }; }; + + while {true} do { _currentTime = diag_tickTime; @@ -453,8 +469,8 @@ AR_Client_Rappel_From_Heli = { _heliPos = AGLtoASL (_heli modelToWorldVisual _rappelPoint); - if(_newPosition distance _heliPos > ((ropeLength _rope1) + 1)) then { - _newPosition = (_heliPos) vectorAdd (( vectorNormalized ( (_heliPos) vectorFromTo _newPosition )) vectorMultiply ((ropeLength _rope1) + 1)); + if(_newPosition distance _heliPos > _topRopeLength) then { + _newPosition = (_heliPos) vectorAdd (( vectorNormalized ( (_heliPos) vectorFromTo _newPosition )) vectorMultiply _topRopeLength); _surfaceVector = ( vectorNormalized ( _newPosition vectorFromTo (_heliPos) )); _velocityVec = _velocityVec vectorAdd (( _surfaceVector vectorMultiply (_velocityVec vectorDotProduct _surfaceVector)) vectorMultiply -1); }; @@ -465,6 +481,19 @@ AR_Client_Rappel_From_Heli = { _player setPosWorld [_newPosition select 0, _newPosition select 1, (_newPosition select 2)-0.6]; _player setVelocity [0,0,0]; + // Handle rappelling down rope + if(_player getVariable ["AR_DECEND_PRESSED",false]) then { + _decendSpeedMetersPerSecond = 3.5; + if(_player getVariable ["AR_FAST_DECEND_PRESSED",false]) then { + _decendSpeedMetersPerSecond = 5; + }; + _decendSpeedMetersPerSecond = _decendSpeedMetersPerSecond + (_player getVariable ["AR_RANDOM_DECEND_SPEED_ADJUSTMENT",0]); + _bottomRopeLength = _bottomRopeLength - (_timeSinceLastUpdate * _decendSpeedMetersPerSecond); + _topRopeLength = _topRopeLength + (_timeSinceLastUpdate * _decendSpeedMetersPerSecond); + ropeUnwind [_topRope, _decendSpeedMetersPerSecond, _topRopeLength - 0.5]; + ropeUnwind [_bottomRope, _decendSpeedMetersPerSecond, _bottomRopeLength]; + }; + // Fix player direction _dir = _dir + ((360/1000) * _dirSpinFactor); if(isPlayer _player) then { @@ -491,6 +520,8 @@ AR_Client_Rappel_From_Heli = { } else { _player setDir _maxDir; }; + } else { + _player setDir (_currentDir + ((360/1000) * _dirSpinFactor)); }; } else { _player setDir _dir; @@ -498,12 +529,12 @@ AR_Client_Rappel_From_Heli = { _lastPosition = _newPosition; - if((getPos _player) select 2 < 1 || !alive _player || vehicle _player != _player || ropeLength _rope2 <= 1 || _player getVariable ["AR_Detach_Rope",false] ) exitWith {}; + if((getPos _player) select 2 < 1 || !alive _player || vehicle _player != _player || _bottomRopeLength <= 1 || _player getVariable ["AR_Detach_Rope",false] ) exitWith {}; sleep 0.01; }; - if(ropeLength _rope2 > 1 && alive _player && vehicle _player == _player) then { + if(_bottomRopeLength > 1 && alive _player && vehicle _player == _player) then { _playerStartASLIntersect = getPosASL _player; _playerEndASLIntersect = [_playerStartASLIntersect select 0, _playerStartASLIntersect select 1, (_playerStartASLIntersect select 2) - 5]; @@ -539,19 +570,21 @@ AR_Client_Rappel_From_Heli = { }; - ropeDestroy _rope1; - ropeDestroy _rope2; + ropeDestroy _topRope; + ropeDestroy _bottomRope; deleteVehicle _anchor; deleteVehicle _rappelDevice; _player setVariable ["AR_Is_Rappelling",nil,true]; _player setVariable ["AR_Rappelling_Vehicle", nil, true]; - _player setVariable ["AR_Rappel_Rope_Top",nil]; - _player setVariable ["AR_Rappel_Rope_Bottom",nil]; _player setVariable ["AR_Detach_Rope",nil]; - if(_decendRopeKeyDownHandler != -1) then { - (findDisplay 46) displayRemoveEventHandler ["KeyDown", _decendRopeKeyDownHandler]; + if(_ropeKeyDownHandler != -1) then { + (findDisplay 46) displayRemoveEventHandler ["KeyDown", _ropeKeyDownHandler]; + }; + + if(_ropeKeyUpHandler != -1) then { + (findDisplay 46) displayRemoveEventHandler ["KeyUp", _ropeKeyUpHandler]; }; sleep 2; @@ -593,14 +626,22 @@ AR_Enable_Rappelling_Animation_Client = { if(call AR_Has_Addon_Animations_Installed) then { if([_player] call AR_Current_Weapon_Type_Selected == "HANDGUN") then { if(local _player) then { - _player switchMove "AR_01_Idle_Pistol"; + if(missionNamespace getVariable ["AR_DISABLE_SHOOTING_OVERRIDE",false]) then { + _player switchMove "AR_01_Idle_Pistol_No_Actions"; + } else { + _player switchMove "AR_01_Idle_Pistol"; + }; _player setVariable ["AR_Animation_Move","AR_01_Idle_Pistol_No_Actions",true]; } else { _player setVariable ["AR_Animation_Move","AR_01_Idle_Pistol_No_Actions"]; }; } else { if(local _player) then { - _player switchMove "AR_01_Idle"; + if(missionNamespace getVariable ["AR_DISABLE_SHOOTING_OVERRIDE",false]) then { + _player switchMove "AR_01_Idle_No_Actions"; + } else { + _player switchMove "AR_01_Idle"; + }; _player setVariable ["AR_Animation_Move","AR_01_Idle_No_Actions",true]; } else { _player setVariable ["AR_Animation_Move","AR_01_Idle_No_Actions"]; @@ -608,13 +649,13 @@ AR_Enable_Rappelling_Animation_Client = { }; if!(local _player) then { // Temp work around to avoid seeing other player as standing - _player switchMove "AR_01_Idle_No_Actions"; + _player switchMove (_player getVariable ["AR_Animation_Move","HubSittingChairC_idle1"]); sleep 1; - _player switchMove "AR_01_Idle_No_Actions"; + _player switchMove (_player getVariable ["AR_Animation_Move","HubSittingChairC_idle1"]); sleep 1; - _player switchMove "AR_01_Idle_No_Actions"; + _player switchMove (_player getVariable ["AR_Animation_Move","HubSittingChairC_idle1"]); sleep 1; - _player switchMove "AR_01_Idle_No_Actions"; + _player switchMove (_player getVariable ["AR_Animation_Move","HubSittingChairC_idle1"]); }; } else { if(local _player) then { @@ -630,7 +671,7 @@ AR_Enable_Rappelling_Animation_Client = { _animationEventHandler = _player addEventHandler ["AnimChanged",{ params ["_player","_animation"]; if(call AR_Has_Addon_Animations_Installed) then { - if((toLower _animation) find "aur_" < 0) then { + if((toLower _animation) find "ar_" < 0) then { if([_player] call AR_Current_Weapon_Type_Selected == "HANDGUN") then { _player switchMove "AR_01_Aim_Pistol"; _player setVariable ["AR_Animation_Move","AR_01_Aim_Pistol_No_Actions",true]; @@ -639,16 +680,16 @@ AR_Enable_Rappelling_Animation_Client = { _player setVariable ["AR_Animation_Move","AR_01_Aim_No_Actions",true]; }; } else { - if(toLower _animation == "aur_01_aim") then { + if(toLower _animation == "ar_01_aim") then { _player setVariable ["AR_Animation_Move","AR_01_Aim_No_Actions",true]; }; - if(toLower _animation == "aur_01_idle") then { + if(toLower _animation == "ar_01_idle") then { _player setVariable ["AR_Animation_Move","AR_01_Idle_No_Actions",true]; }; - if(toLower _animation == "aur_01_aim_pistol") then { + if(toLower _animation == "ar_01_aim_pistol") then { _player setVariable ["AR_Animation_Move","AR_01_Aim_Pistol_No_Actions",true]; }; - if(toLower _animation == "aur_01_idle_pistol") then { + if(toLower _animation == "ar_01_idle_pistol") then { _player setVariable ["AR_Animation_Move","AR_01_Idle_Pistol_No_Actions",true]; }; };