From d49798144c2c34b66d4bcd859b8c8236209a4085 Mon Sep 17 00:00:00 2001 From: jonpas Date: Fri, 11 Sep 2015 17:25:46 +0200 Subject: [PATCH] Replaced hasChairMoved with isEqualTo, fixed missing variable --- addons/sitting/XEH_preInit.sqf | 1 - .../sitting/functions/fnc_hasChairMoved.sqf | 30 ------------------- addons/sitting/functions/fnc_sit.sqf | 11 ++++--- 3 files changed, 7 insertions(+), 35 deletions(-) delete mode 100644 addons/sitting/functions/fnc_hasChairMoved.sqf diff --git a/addons/sitting/XEH_preInit.sqf b/addons/sitting/XEH_preInit.sqf index 1649aaba2b..86912ada6b 100644 --- a/addons/sitting/XEH_preInit.sqf +++ b/addons/sitting/XEH_preInit.sqf @@ -6,7 +6,6 @@ PREP(canSit); PREP(canStand); PREP(getRandomAnimation); PREP(handleInterrupt); -PREP(hasChairMoved); PREP(moduleInit); PREP(sit); PREP(stand); diff --git a/addons/sitting/functions/fnc_hasChairMoved.sqf b/addons/sitting/functions/fnc_hasChairMoved.sqf deleted file mode 100644 index de3a38e0ce..0000000000 --- a/addons/sitting/functions/fnc_hasChairMoved.sqf +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Author: Jonpas - * Checks if chair moved from original position. - * - * Arguments: - * 0: Seat - * 1: Seat Position - * - * Return Value: - * None - * - * Example: - * [seat, seatPos] call ace_sitting_fnc_hasChairMoved - * - * Public: No - */ -#include "script_component.hpp" - -params ["_seat", "_seatPosOrig"]; - -TRACE_2("Chair position",_seatPosOrig,getPosASL _seat); - -(getPosASL _seat) params ["_seatX", "_seatY", "_seatZ"]; -_seatPosOrig params ["_seatOrigX", "_seatOrigY", "_seatOrigZ"]; - -// Check each coordinate due to possibility of tiny movements in simulation -if (abs (_seatX - _seatOrigX) > 0.01) exitWith {true}; -if (abs (_seatY - _seatOrigY) > 0.01) exitWith {true}; -if (abs (_seatZ - _seatOrigZ) > 0.01) exitWith {true}; -false diff --git a/addons/sitting/functions/fnc_sit.sqf b/addons/sitting/functions/fnc_sit.sqf index 42ed774bd0..81b2c82698 100644 --- a/addons/sitting/functions/fnc_sit.sqf +++ b/addons/sitting/functions/fnc_sit.sqf @@ -14,9 +14,10 @@ * * Public: No */ +#define DEBUG_MODE_FULL #include "script_component.hpp" -private ["_actionID", "_configFile", "_sitDirection", "_sitPosition", "_sitRotation", "_sitDirectionVisual"]; +private ["_actionID", "_configFile", "_sitDirection", "_sitPosition", "_sitRotation", "_seatPosOrig"]; params ["_seat", "_player"]; @@ -26,7 +27,7 @@ GVAR(seat) = _seat; // Overwrite weird position, because Arma decides to set it differently based on current animation/stance... _player switchMove "amovpknlmstpsraswrfldnon"; -// add scrollwheel action to release object +// Add scroll-wheel action to release object _actionID = _player getVariable [QGVAR(StandUpActionID), -1]; if (_actionID != -1) then { @@ -65,7 +66,9 @@ _player setPos (_seat modelToWorld _sitPosition); _player setVariable [QGVAR(isSitting), true]; _seat setVariable [QGVAR(seatOccupied), true, true]; // To prevent multiple people sitting on one seat + // Add PFH to automatically stand up if the chair has moved +_seatPosOrig = getPosASL _seat; [{ params ["_args", "_pfhId"]; _args params ["_player", "_seat", "_seatPosOrig"]; @@ -76,8 +79,8 @@ _seat setVariable [QGVAR(seatOccupied), true, true]; // To prevent multiple peop TRACE_1("Remove PFH",_player getVariable [ARR_2(QGVAR(isSitting), false)]); }; - // Stand up if chair moves - if ([_seat, _seatPosOrig] call FUNC(hasChairMoved)) exitWith { + // Stand up if chair moves or gets deleted (getPosASL returns [0,0,0] in that case) + if !((getPosASL _seat) isEqualTo _seatPosOrig) exitWith { _player call FUNC(stand); TRACE_2("Chair moved",getPosASL _seat,_seatPosOrig); };