mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Merge pull request #1806 from jonpas/sittingFixes
Akward Sitting Fixes Part 2
This commit is contained in:
commit
3514f07d31
@ -9,4 +9,3 @@ if !(hasInterface) exitWith {};
|
||||
// Handle interruptions
|
||||
["medical_onUnconscious", {_this call DFUNC(handleInterrupt)}] call EFUNC(common,addEventhandler);
|
||||
["SetHandcuffed", {_this call DFUNC(handleInterrupt)}] call EFUNC(common,addEventhandler);
|
||||
["SetSurrendered", {_this call DFUNC(handleInterrupt)}] call EFUNC(common,addEventhandler);
|
||||
|
@ -6,6 +6,7 @@ PREP(canSit);
|
||||
PREP(canStand);
|
||||
PREP(getRandomAnimation);
|
||||
PREP(handleInterrupt);
|
||||
PREP(hasChairMoved);
|
||||
PREP(moduleInit);
|
||||
PREP(sit);
|
||||
PREP(stand);
|
||||
|
@ -14,9 +14,13 @@
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
//#define DEBUG_MODE_FULL
|
||||
#include "script_component.hpp"
|
||||
|
||||
PARAMS_2(_seat,_player);
|
||||
|
||||
// Sitting enabled, is seat object and not occupied
|
||||
(GVAR(enable) && {getNumber (configFile >> "CfgVehicles" >> typeOf _seat >> QGVAR(canSit)) == 1} && {isNil{_seat getVariable QGVAR(seatOccupied)}})
|
||||
// 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)}} &&
|
||||
{round (vectorUp _seat select 0) == 0 && {round (vectorUp _seat select 1) == 0} && {round (vectorUp _seat select 2) == 1}}
|
||||
|
@ -9,7 +9,7 @@
|
||||
* None
|
||||
*
|
||||
* Example:
|
||||
* [player] call ace_sitting_fnc_handleInterrupt;
|
||||
* player call ace_sitting_fnc_handleInterrupt;
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
@ -18,5 +18,5 @@
|
||||
PARAMS_1(_player);
|
||||
|
||||
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
|
||||
*/
|
||||
//#define DEBUG_MODE_FULL
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_configFile", "_sitDirection", "_sitPosition", "_sitRotation", "_sitDirectionVisual"];
|
||||
@ -37,7 +38,8 @@ _sitRotation = if (isNumber (_configFile >> QGVAR(sitRotation))) then {getNumber
|
||||
|
||||
// Set direction and position
|
||||
_player setDir _sitDirection;
|
||||
_player setPosASL (_seat modelToWorld _sitPosition) call EFUNC(common,positionToASL);
|
||||
// No need for ATL/ASL as modelToWorld returns in format position
|
||||
_player setPos (_seat modelToWorld _sitPosition);
|
||||
|
||||
// Set variables
|
||||
_player setVariable [QGVAR(isSitting), true];
|
||||
@ -45,12 +47,20 @@ _seat setVariable [QGVAR(seatOccupied), true, true]; // To prevent multiple peop
|
||||
|
||||
// Add rotation control PFH
|
||||
_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
|
||||
if !(_player getVariable [QGVAR(isSitting), false]) exitWith {
|
||||
[_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
|
||||
@ -60,4 +70,4 @@ _sitDirectionVisual = getDirVisual _player; // Needed for precision and issues w
|
||||
if (getDir _player < _sitDirectionVisual - _sitRotation) exitWith {
|
||||
_player setDir (_sitDirectionVisual - _sitRotation);
|
||||
};
|
||||
}, 0, [_player, _sitDirectionVisual, _sitRotation]] call cba_fnc_addPerFrameHandler;
|
||||
}, 0, [_player, _sitDirectionVisual, _sitRotation, _seat, _seatPosOrig]] call cba_fnc_addPerFrameHandler;
|
||||
|
Loading…
Reference in New Issue
Block a user