mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Prevented sitting on flipped chairs, Stand when chair gets knocked away/otherwise moves
This commit is contained in:
@ -7,6 +7,6 @@ if !(hasInterface) exitWith {};
|
|||||||
["isNotSitting", {!((_this select 0) getVariable [QGVAR(isSitting), false])}] call EFUNC(common,addCanInteractWithCondition);
|
["isNotSitting", {!((_this select 0) getVariable [QGVAR(isSitting), false])}] call EFUNC(common,addCanInteractWithCondition);
|
||||||
|
|
||||||
// Handle interruptions
|
// Handle interruptions
|
||||||
["medical_onUnconscious", {_this call DFUNC(handleInterrupt)}] call EFUNC(common,addEventhandler);
|
["medical_onUnconscious", {_player call DFUNC(handleInterrupt)}] call EFUNC(common,addEventhandler);
|
||||||
["SetHandcuffed", {_this call DFUNC(handleInterrupt)}] call EFUNC(common,addEventhandler);
|
["SetHandcuffed", {_player call DFUNC(handleInterrupt)}] call EFUNC(common,addEventhandler);
|
||||||
["SetSurrendered", {_this call DFUNC(handleInterrupt)}] call EFUNC(common,addEventhandler);
|
["SetSurrendered", {_player call DFUNC(handleInterrupt)}] call EFUNC(common,addEventhandler);
|
||||||
|
@ -6,6 +6,7 @@ PREP(canSit);
|
|||||||
PREP(canStand);
|
PREP(canStand);
|
||||||
PREP(getRandomAnimation);
|
PREP(getRandomAnimation);
|
||||||
PREP(handleInterrupt);
|
PREP(handleInterrupt);
|
||||||
|
PREP(hasChairMoved);
|
||||||
PREP(moduleInit);
|
PREP(moduleInit);
|
||||||
PREP(sit);
|
PREP(sit);
|
||||||
PREP(stand);
|
PREP(stand);
|
||||||
|
@ -14,9 +14,13 @@
|
|||||||
*
|
*
|
||||||
* Public: No
|
* Public: No
|
||||||
*/
|
*/
|
||||||
|
//#define DEBUG_MODE_FULL
|
||||||
#include "script_component.hpp"
|
#include "script_component.hpp"
|
||||||
|
|
||||||
PARAMS_2(_seat,_player);
|
PARAMS_2(_seat,_player);
|
||||||
|
|
||||||
// Sitting enabled, is seat object and not occupied
|
// Sitting enabled, is seat object, not occupied and standing up (or not on a big slope)
|
||||||
(GVAR(enable) && {getNumber (configFile >> "CfgVehicles" >> typeOf _seat >> QGVAR(canSit)) == 1} && {isNil{_seat getVariable QGVAR(seatOccupied)}})
|
GVAR(enable) &&
|
||||||
|
{getNumber (configFile >> "CfgVehicles" >> typeOf _seat >> QGVAR(canSit)) == 1} &&
|
||||||
|
{isNil{_seat getVariable QGVAR(seatOccupied)}} &&
|
||||||
|
{round (vectorUp _seat select 0) == 0 && {round (vectorUp _seat select 1) == 0} && {round (vectorUp _seat select 2) == 1}}
|
||||||
|
@ -3,13 +3,13 @@
|
|||||||
* Handles interruptions of sitting, like killed or unconsciousness.
|
* Handles interruptions of sitting, like killed or unconsciousness.
|
||||||
*
|
*
|
||||||
* Arguments:
|
* Arguments:
|
||||||
* 0: Player <OBJECT>
|
* Player <OBJECT>
|
||||||
*
|
*
|
||||||
* Return Value:
|
* Return Value:
|
||||||
* None
|
* None
|
||||||
*
|
*
|
||||||
* Example:
|
* Example:
|
||||||
* [player] call ace_sitting_fnc_handleInterrupt;
|
* player call ace_sitting_fnc_handleInterrupt;
|
||||||
*
|
*
|
||||||
* Public: No
|
* Public: No
|
||||||
*/
|
*/
|
||||||
@ -18,5 +18,5 @@
|
|||||||
PARAMS_1(_player);
|
PARAMS_1(_player);
|
||||||
|
|
||||||
if (_player getVariable [QGVAR(isSitting), false]) then {
|
if (_player getVariable [QGVAR(isSitting), false]) then {
|
||||||
[_player] call FUNC(stand);
|
_player call FUNC(stand);
|
||||||
};
|
};
|
||||||
|
27
addons/sitting/functions/fnc_hasChairMoved.sqf
Normal file
27
addons/sitting/functions/fnc_hasChairMoved.sqf
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
/*
|
||||||
|
* 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
|
||||||
|
*/
|
||||||
|
//#define DEBUG_MODE_FULL
|
||||||
|
#include "script_component.hpp"
|
||||||
|
|
||||||
|
PARAMS_2(_seat,_seatPosOrig);
|
||||||
|
|
||||||
|
TRACE_2("Chair position",_seatPosOrig,getPosASL _seat);
|
||||||
|
|
||||||
|
// Check each coordinate due to possibility of tiny movements in simulation
|
||||||
|
(getPosASL _seat) select 0 < (_seatPosOrig select 0) - 0.01 || {(getPosASL _seat) select 0 > (_seatPosOrig select 0) + 0.01} ||
|
||||||
|
{(getPosASL _seat) select 1 < (_seatPosOrig select 1) - 0.01 || {(getPosASL _seat) select 1 > (_seatPosOrig select 1) + 0.01}} ||
|
||||||
|
{(getPosASL _seat) select 2 < (_seatPosOrig select 2) - 0.01 || {(getPosASL _seat) select 2 > (_seatPosOrig select 2) + 0.01}}
|
@ -14,6 +14,7 @@
|
|||||||
*
|
*
|
||||||
* Public: No
|
* Public: No
|
||||||
*/
|
*/
|
||||||
|
//#define DEBUG_MODE_FULL
|
||||||
#include "script_component.hpp"
|
#include "script_component.hpp"
|
||||||
|
|
||||||
private ["_configFile", "_sitDirection", "_sitPosition", "_sitRotation", "_sitDirectionVisual"];
|
private ["_configFile", "_sitDirection", "_sitPosition", "_sitRotation", "_sitDirectionVisual"];
|
||||||
@ -46,12 +47,20 @@ _seat setVariable [QGVAR(seatOccupied), true, true]; // To prevent multiple peop
|
|||||||
|
|
||||||
// Add rotation control PFH
|
// Add rotation control PFH
|
||||||
_sitDirectionVisual = getDirVisual _player; // Needed for precision and issues with using above directly
|
_sitDirectionVisual = getDirVisual _player; // Needed for precision and issues with using above directly
|
||||||
|
_seatPosOrig = getPosASL _seat;
|
||||||
[{
|
[{
|
||||||
EXPLODE_3_PVT(_this select 0,_player,_sitDirectionVisual,_sitRotation);
|
EXPLODE_5_PVT(_this select 0,_player,_sitDirectionVisual,_sitRotation,_seat,_seatPosOrig);
|
||||||
|
|
||||||
// Remove PFH if not sitting any more
|
// Remove PFH if not sitting any more
|
||||||
if !(_player getVariable [QGVAR(isSitting), false]) exitWith {
|
if !(_player getVariable [QGVAR(isSitting), false]) exitWith {
|
||||||
[_this select 1] call cba_fnc_removePerFrameHandler;
|
[_this select 1] call cba_fnc_removePerFrameHandler;
|
||||||
|
TRACE_1("Remove PFH",_player getVariable [ARR_2(QGVAR(isSitting),false)]);
|
||||||
|
};
|
||||||
|
|
||||||
|
// Stand up if chair moves
|
||||||
|
if ([_seat, _seatPosOrig] call FUNC(hasChairMoved)) exitWith {
|
||||||
|
_player call FUNC(stand);
|
||||||
|
TRACE_2("Chair moved",getPosASL _seat,_seatPosOrig);
|
||||||
};
|
};
|
||||||
|
|
||||||
// Set direction to boundary when passing it
|
// Set direction to boundary when passing it
|
||||||
@ -61,4 +70,4 @@ _sitDirectionVisual = getDirVisual _player; // Needed for precision and issues w
|
|||||||
if (getDir _player < _sitDirectionVisual - _sitRotation) exitWith {
|
if (getDir _player < _sitDirectionVisual - _sitRotation) exitWith {
|
||||||
_player setDir (_sitDirectionVisual - _sitRotation);
|
_player setDir (_sitDirectionVisual - _sitRotation);
|
||||||
};
|
};
|
||||||
}, 0, [_player, _sitDirectionVisual, _sitRotation]] call cba_fnc_addPerFrameHandler;
|
}, 0, [_player, _sitDirectionVisual, _sitRotation, _seat, _seatPosOrig]] call cba_fnc_addPerFrameHandler;
|
||||||
|
Reference in New Issue
Block a user