Replaced hasChairMoved with isEqualTo, fixed missing variable

This commit is contained in:
jonpas 2015-09-11 17:25:46 +02:00
parent c5f9f85d27
commit d49798144c
3 changed files with 7 additions and 35 deletions

View File

@ -6,7 +6,6 @@ PREP(canSit);
PREP(canStand);
PREP(getRandomAnimation);
PREP(handleInterrupt);
PREP(hasChairMoved);
PREP(moduleInit);
PREP(sit);
PREP(stand);

View File

@ -1,30 +0,0 @@
/*
* Author: Jonpas
* Checks if chair moved from original position.
*
* Arguments:
* 0: Seat <OBJECT>
* 1: Seat Position <ARRAY>
*
* 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

View File

@ -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);
};