mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Merge pull request #2620 from jonpas/sittingFramework
Sitting Framework
This commit is contained in:
commit
f57eb08ce5
@ -22,12 +22,7 @@ class Extended_Init_EventHandlers {
|
||||
init = QUOTE(_this call DFUNC(initObject));
|
||||
};
|
||||
};
|
||||
class ReammoBox_F {
|
||||
class ADDON {
|
||||
init = QUOTE(_this call DFUNC(initObject));
|
||||
};
|
||||
};
|
||||
class ACE_RepairItem_Base {
|
||||
class ThingX {
|
||||
class ADDON {
|
||||
init = QUOTE(_this call DFUNC(initObject));
|
||||
};
|
||||
|
@ -17,3 +17,12 @@ class Extended_Killed_EventHandlers {
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
// Need initPost or there are problems with setVariable
|
||||
class Extended_InitPost_EventHandlers {
|
||||
class ThingX {
|
||||
class ADDON {
|
||||
init = QUOTE(_this call DFUNC(addSitActions))
|
||||
};
|
||||
};
|
||||
};
|
||||
|
@ -34,79 +34,67 @@ class CfgVehicles {
|
||||
};
|
||||
};
|
||||
|
||||
#define MACRO_SEAT_ACTION \
|
||||
class ACE_Actions { \
|
||||
class ACE_MainActions { \
|
||||
displayName = ECSTRING(interaction,MainAction); \
|
||||
selection = ""; \
|
||||
distance = 1.5; \
|
||||
condition = "true"; \
|
||||
class GVAR(Sit) { \
|
||||
displayName = CSTRING(Sit); \
|
||||
condition = QUOTE(_this call FUNC(canSit)); \
|
||||
statement = QUOTE(_this call FUNC(sit)); \
|
||||
showDisabled = 0; \
|
||||
priority = 0; \
|
||||
icon = PATHTOF(UI\sit_ca.paa); \
|
||||
}; \
|
||||
}; \
|
||||
};
|
||||
|
||||
class ThingX;
|
||||
// Folding Chair
|
||||
class Land_CampingChair_V1_F: ThingX {
|
||||
XEH_ENABLED;
|
||||
MACRO_SEAT_ACTION
|
||||
GVAR(canSit) = 1;
|
||||
GVAR(sitDirection) = 180;
|
||||
GVAR(sitPosition[]) = {0, -0.1, -0.45};
|
||||
GVAR(sitRotation) = 10;
|
||||
EGVAR(dragging,canCarry) = 1;
|
||||
EGVAR(dragging,carryPosition[]) = {0, 0.75, 0.5};
|
||||
EGVAR(dragging,carryDirection) = 180;
|
||||
};
|
||||
// Camping Chair
|
||||
class Land_CampingChair_V2_F: ThingX {
|
||||
XEH_ENABLED;
|
||||
MACRO_SEAT_ACTION
|
||||
GVAR(canSit) = 1;
|
||||
GVAR(sitDirection) = 180;
|
||||
GVAR(sitPosition[]) = {0, -0.1, -0.45};
|
||||
GVAR(sitRotation) = 45;
|
||||
EGVAR(dragging,canCarry) = 1;
|
||||
EGVAR(dragging,carryPosition[]) = {0, 0.75, 0.5};
|
||||
EGVAR(dragging,carryDirection) = 180;
|
||||
};
|
||||
|
||||
class Furniture_base_F;
|
||||
// Chair (Plastic)
|
||||
class Land_ChairPlastic_F: Furniture_base_F {
|
||||
XEH_ENABLED;
|
||||
MACRO_SEAT_ACTION
|
||||
GVAR(canSit) = 1;
|
||||
GVAR(sitDirection) = 90;
|
||||
GVAR(sitPosition[]) = {0, 0, -0.5};
|
||||
GVAR(sitRotation) = 5;
|
||||
EGVAR(dragging,canCarry) = 1;
|
||||
EGVAR(dragging,carryPosition[]) = {0, 0.75, 0.5};
|
||||
EGVAR(dragging,carryDirection) = 270;
|
||||
};
|
||||
// Chair (Wooden)
|
||||
class Land_ChairWood_F: Furniture_base_F {
|
||||
XEH_ENABLED;
|
||||
MACRO_SEAT_ACTION
|
||||
GVAR(canSit) = 1;
|
||||
GVAR(sitDirection) = 180;
|
||||
GVAR(sitPosition[]) = {0, -0.05, 0};
|
||||
GVAR(sitRotation) = 75;
|
||||
EGVAR(dragging,canCarry) = 1;
|
||||
EGVAR(dragging,carryPosition[]) = {0, 0.75, 0.5};
|
||||
EGVAR(dragging,carryDirection) = 180;
|
||||
};
|
||||
// Office Chair
|
||||
class Land_OfficeChair_01_F: Furniture_base_F {
|
||||
XEH_ENABLED;
|
||||
MACRO_SEAT_ACTION
|
||||
GVAR(canSit) = 1;
|
||||
GVAR(sitDirection) = 180;
|
||||
GVAR(sitPosition[]) = {0, 0, -0.6};
|
||||
GVAR(sitRotation) = 15;
|
||||
EGVAR(dragging,canCarry) = 1;
|
||||
EGVAR(dragging,carryPosition[]) = {0, 0.75, 0.5};
|
||||
EGVAR(dragging,carryDirection) = 180;
|
||||
};
|
||||
// Rattan Chair
|
||||
class Land_RattanChair_01_F: Furniture_base_F {
|
||||
XEH_ENABLED;
|
||||
MACRO_SEAT_ACTION
|
||||
GVAR(canSit) = 1;
|
||||
GVAR(sitDirection) = 180;
|
||||
GVAR(sitPosition[]) = {0, -0.1, -1}; // Z must be -1 due to chair's geometry (magic floating seat point)
|
||||
GVAR(sitRotation) = 2;
|
||||
EGVAR(dragging,canCarry) = 1;
|
||||
EGVAR(dragging,carryPosition[]) = {0, 0.75, 0.5};
|
||||
EGVAR(dragging,carryDirection) = 180;
|
||||
};
|
||||
};
|
||||
|
@ -4,7 +4,7 @@
|
||||
if (!hasInterface) exitWith {};
|
||||
|
||||
// Add interaction menu exception
|
||||
["isNotSitting", {!((_this select 0) getVariable [QGVAR(isSitting), false])}] call EFUNC(common,addCanInteractWithCondition);
|
||||
["isNotSitting", {isNil {(_this select 0) getVariable QGVAR(isSitting)}}] call EFUNC(common,addCanInteractWithCondition);
|
||||
|
||||
// Handle interruptions
|
||||
["medical_onUnconscious", {_this call DFUNC(handleInterrupt)}] call EFUNC(common,addEventhandler);
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
ADDON = false;
|
||||
|
||||
PREP(addSitActions);
|
||||
PREP(canSit);
|
||||
PREP(canStand);
|
||||
PREP(getRandomAnimation);
|
||||
@ -10,4 +11,6 @@ PREP(moduleInit);
|
||||
PREP(sit);
|
||||
PREP(stand);
|
||||
|
||||
GVAR(initializedClasses) = [];
|
||||
|
||||
ADDON = true;
|
||||
|
42
addons/sitting/functions/fnc_addSitActions.sqf
Normal file
42
addons/sitting/functions/fnc_addSitActions.sqf
Normal file
@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Author: Jonpas
|
||||
* Adds sit actions.
|
||||
*
|
||||
* Arguments:
|
||||
* 0: Seat <OBJECT>
|
||||
*
|
||||
* Return Value:
|
||||
* None
|
||||
*
|
||||
* Example:
|
||||
* [seat] call ace_sitting_fnc_addSitActions
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
params ["_seat"];
|
||||
private ["_type", "_sitAction"];
|
||||
|
||||
_type = typeOf _seat;
|
||||
|
||||
// Exit if the object is not specified as a seat
|
||||
if (getNumber (configFile >> "CfgVehicles" >> _type >> QGVAR(canSit)) != 1) exitWith {};
|
||||
|
||||
// Exit if class already initialized
|
||||
if (_type in GVAR(initializedClasses)) exitWith {};
|
||||
|
||||
GVAR(initializedClasses) pushBack _type;
|
||||
|
||||
_sitAction = [
|
||||
QGVAR(Sit),
|
||||
localize LSTRING(Sit),
|
||||
QUOTE(PATHTOF(UI\sit_ca.paa)),
|
||||
{_this call FUNC(sit)},
|
||||
{_this call FUNC(canSit)},
|
||||
{},
|
||||
[],
|
||||
[0, 0, 0],
|
||||
1.5
|
||||
] call EFUNC(interact_menu,createAction);
|
||||
[_type, 0, ["ACE_MainActions"], _sitAction] call EFUNC(interact_menu,addActionToClass);
|
@ -4,22 +4,20 @@
|
||||
*
|
||||
* Arguments:
|
||||
* 0: Seat <OBJECT>
|
||||
* 1: Player <OBJECT>
|
||||
*
|
||||
* Return Value:
|
||||
* Can Sit Down <BOOL>
|
||||
*
|
||||
* Example:
|
||||
* [seat, player] call ace_sitting_fnc_canSit
|
||||
* [seat] call ace_sitting_fnc_canSit
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
params ["_seat", "_player"];
|
||||
params ["_seat"];
|
||||
|
||||
// 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}}
|
||||
|
@ -18,4 +18,4 @@
|
||||
params ["_player"];
|
||||
|
||||
// Sitting
|
||||
(_player getVariable [QGVAR(isSitting), false])
|
||||
!isNil {_player getVariable QGVAR(isSitting)}
|
||||
|
@ -17,6 +17,6 @@
|
||||
|
||||
params ["_player"];
|
||||
|
||||
if (_player getVariable [QGVAR(isSitting), false]) then {
|
||||
if (!isNil {_player getVariable QGVAR(isSitting)}) then {
|
||||
_player call FUNC(stand);
|
||||
};
|
||||
|
@ -16,23 +16,14 @@
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_actionID", "_configFile", "_sitDirection", "_sitPosition", "_sitRotation", "_seatPosOrig"];
|
||||
private ["_actionID", "_configFile", "_sitDirection", "_sitPosition", "_seatPosOrig"];
|
||||
|
||||
params ["_seat", "_player"];
|
||||
|
||||
// Set global variable for standing up
|
||||
GVAR(seat) = _seat;
|
||||
|
||||
// Overwrite weird position, because Arma decides to set it differently based on current animation/stance...
|
||||
_player switchMove "amovpknlmstpsraswrfldnon";
|
||||
|
||||
// Add scroll-wheel action to release object
|
||||
_actionID = _player getVariable [QGVAR(StandUpActionID), -1];
|
||||
|
||||
if (_actionID != -1) then {
|
||||
_player removeAction _actionID;
|
||||
};
|
||||
|
||||
_actionID = _player addAction [
|
||||
format ["<t color='#FFFF00'>%1</t>", localize LSTRING(Stand)],
|
||||
QUOTE((_this select 0) call FUNC(stand)),
|
||||
@ -44,13 +35,10 @@ _actionID = _player addAction [
|
||||
QUOTE(_this call FUNC(canStand))
|
||||
];
|
||||
|
||||
_player setVariable [QGVAR(StandUpActionID), _actionID];
|
||||
|
||||
// Read config
|
||||
_configFile = configFile >> "CfgVehicles" >> typeOf _seat;
|
||||
_sitDirection = (getDir _seat) + getNumber (_configFile >> QGVAR(sitDirection));
|
||||
_sitPosition = getArray (_configFile >> QGVAR(sitPosition));
|
||||
_sitRotation = if (isNumber (_configFile >> QGVAR(sitRotation))) then {getNumber (_configFile >> QGVAR(sitRotation))} else {45}; // Apply default if config entry not present
|
||||
|
||||
// Get random animation and perform it (before moving player to ensure correct placement)
|
||||
[_player, call FUNC(getRandomAnimation), 2] call EFUNC(common,doAnimation); // Correctly places when using non-transitional animations
|
||||
@ -61,8 +49,8 @@ _player setDir _sitDirection;
|
||||
//modelToWorld returns AGL
|
||||
_player setPosASL (AGLtoASL (_seat modelToWorld _sitPosition));
|
||||
|
||||
// Set variables
|
||||
_player setVariable [QGVAR(isSitting), true];
|
||||
// Set variables, save seat object on player
|
||||
_player setVariable [QGVAR(isSitting), [_seat, _actionID]];
|
||||
_seat setVariable [QGVAR(seatOccupied), true, true]; // To prevent multiple people sitting on one seat
|
||||
|
||||
|
||||
@ -73,7 +61,7 @@ _seatPosOrig = getPosASL _seat;
|
||||
_args params ["_player", "_seat", "_seatPosOrig"];
|
||||
|
||||
// Remove PFH if not sitting any more
|
||||
if !(_player getVariable [QGVAR(isSitting), false]) exitWith {
|
||||
if (isNil {_player getVariable QGVAR(isSitting)}) exitWith {
|
||||
[_pfhId] call CBA_fnc_removePerFrameHandler;
|
||||
TRACE_1("Remove PFH",_player getVariable [ARR_2(QGVAR(isSitting), false)]);
|
||||
};
|
||||
|
@ -16,12 +16,14 @@
|
||||
#include "script_component.hpp"
|
||||
|
||||
params ["_player"];
|
||||
private ["_animation"];
|
||||
|
||||
// remove scroll wheel action
|
||||
_player removeAction (_player getVariable [QGVAR(StandUpActionID), -1]);
|
||||
(_player getVariable QGVAR(isSitting)) params ["_seat", "_actionID"];
|
||||
|
||||
// Remove scroll-wheel action
|
||||
_player removeAction _actionID;
|
||||
|
||||
// Restore animation
|
||||
private "_animation";
|
||||
_animation = switch (currentWeapon _player) do {
|
||||
case "": {"amovpercmstpsnonwnondnon"};
|
||||
case (primaryWeapon _player): {"amovpercmstpslowwrfldnon"};
|
||||
@ -33,5 +35,5 @@ _animation = switch (currentWeapon _player) do {
|
||||
|
||||
// Set variables to nil
|
||||
_player setVariable [QGVAR(isSitting), nil];
|
||||
GVAR(seat) setVariable [QGVAR(seatOccupied), nil, true];
|
||||
GVAR(seat) = nil;
|
||||
if (isNull _seat) exitWith {};
|
||||
_seat setVariable [QGVAR(seatOccupied), nil, true];
|
||||
|
Loading…
Reference in New Issue
Block a user