From c3c2fd007491efae6587fe80d980469249e578e3 Mon Sep 17 00:00:00 2001 From: jonpas Date: Sun, 7 Jun 2015 22:00:43 +0200 Subject: [PATCH] Initial Sitting commit --- addons/sitting/$PBOPREFIX$ | 1 + addons/sitting/CfgEventHandlers.hpp | 5 + addons/sitting/CfgVehicles.hpp | 99 +++++++++++++++++++ addons/sitting/XEH_preInit.sqf | 11 +++ addons/sitting/config.cpp | 16 +++ addons/sitting/functions/fnc_canSit.sqf | 27 +++++ addons/sitting/functions/fnc_canStand.sqf | 22 +++++ .../functions/fnc_getRandomAnimation.sqf | 55 +++++++++++ addons/sitting/functions/fnc_sit.sqf | 41 ++++++++ addons/sitting/functions/fnc_stand.sqf | 23 +++++ addons/sitting/functions/script_component.hpp | 1 + addons/sitting/script_component.hpp | 12 +++ addons/sitting/stringtable.xml | 11 +++ 13 files changed, 324 insertions(+) create mode 100644 addons/sitting/$PBOPREFIX$ create mode 100644 addons/sitting/CfgEventHandlers.hpp create mode 100644 addons/sitting/CfgVehicles.hpp create mode 100644 addons/sitting/XEH_preInit.sqf create mode 100644 addons/sitting/config.cpp create mode 100644 addons/sitting/functions/fnc_canSit.sqf create mode 100644 addons/sitting/functions/fnc_canStand.sqf create mode 100644 addons/sitting/functions/fnc_getRandomAnimation.sqf create mode 100644 addons/sitting/functions/fnc_sit.sqf create mode 100644 addons/sitting/functions/fnc_stand.sqf create mode 100644 addons/sitting/functions/script_component.hpp create mode 100644 addons/sitting/script_component.hpp create mode 100644 addons/sitting/stringtable.xml diff --git a/addons/sitting/$PBOPREFIX$ b/addons/sitting/$PBOPREFIX$ new file mode 100644 index 0000000000..419bf892be --- /dev/null +++ b/addons/sitting/$PBOPREFIX$ @@ -0,0 +1 @@ +z\ace\addons\sitting \ No newline at end of file diff --git a/addons/sitting/CfgEventHandlers.hpp b/addons/sitting/CfgEventHandlers.hpp new file mode 100644 index 0000000000..b928bc2de6 --- /dev/null +++ b/addons/sitting/CfgEventHandlers.hpp @@ -0,0 +1,5 @@ +class Extended_PreInit_EventHandlers { + class ADDON { + init = QUOTE(call COMPILE_FILE(XEH_preInit)); + }; +}; diff --git a/addons/sitting/CfgVehicles.hpp b/addons/sitting/CfgVehicles.hpp new file mode 100644 index 0000000000..a02647da14 --- /dev/null +++ b/addons/sitting/CfgVehicles.hpp @@ -0,0 +1,99 @@ +#define MACRO_SEAT_ACTION \ + class ACE_Actions { \ + class ACE_MainActions { \ + displayName = ECSTRING(interaction,MainAction); \ + selection = ""; \ + distance = 1.25; \ + 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 CfgVehicles { + class Man; + class CAManBase: Man { + class ACE_SelfActions { + class GVAR(Stand) { + displayName = CSTRING(Stand); + condition = QUOTE(_player call FUNC(canStand)); + statement = QUOTE(_player call FUNC(stand)); + priority = 0; + //icon = PATHTOF(UI\sit_ca.paa); + //add exception isNotSitting to everything that shouldn't be available (eg. medical) + }; + }; + }; + + 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}; + }; + // 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}; + }; + // Chair (Plastic) + class Land_ChairPlastic_F: ThingX { + XEH_ENABLED; + MACRO_SEAT_ACTION + GVAR(canSit) = 1; + GVAR(sitDirection) = 90; + GVAR(sitPosition[]) = {-0.1, 0, -0.2}; + }; + // Chair (Wooden) + class Land_ChairWood_F: ThingX { + XEH_ENABLED; + MACRO_SEAT_ACTION + GVAR(canSit) = 1; + GVAR(sitDirection) = 180; + GVAR(sitPosition[]) = {0, 0, 0}; + }; + // Office Chair + class Land_OfficeChair_01_F: ThingX { + XEH_ENABLED; + MACRO_SEAT_ACTION + GVAR(canSit) = 1; + GVAR(sitDirection) = 180; + GVAR(sitPosition[]) = {0, 0, -0.6}; + }; + // Rattan Chair + class Land_RattanChair_01_F: ThingX { + XEH_ENABLED; + MACRO_SEAT_ACTION + GVAR(canSit) = 1; + GVAR(sitDirection) = 180; + GVAR(sitPosition[]) = {0.07, 0.17, 1}; + }; + // Field Toilet + class Land_FieldToilet_F: ThingX { + XEH_ENABLED; + MACRO_SEAT_ACTION + GVAR(canSit) = 1; + GVAR(sitDirection) = 180; + GVAR(sitPosition[]) = {0, 0.75, -1.1}; + }; + // Toiletbox + class Land_ToiletBox_F: ThingX { + XEH_ENABLED; + MACRO_SEAT_ACTION + GVAR(canSit) = 1; + GVAR(sitDirection) = 180; + GVAR(sitPosition[]) = {0, 0.75, -1.1}; + }; +}; diff --git a/addons/sitting/XEH_preInit.sqf b/addons/sitting/XEH_preInit.sqf new file mode 100644 index 0000000000..1c8e8ce8ad --- /dev/null +++ b/addons/sitting/XEH_preInit.sqf @@ -0,0 +1,11 @@ +#include "script_component.hpp" + +ADDON = false; + +PREP(canSit); +PREP(canStand); +PREP(getRandomAnimation); +PREP(sit); +PREP(stand); + +ADDON = true; diff --git a/addons/sitting/config.cpp b/addons/sitting/config.cpp new file mode 100644 index 0000000000..9412666aaf --- /dev/null +++ b/addons/sitting/config.cpp @@ -0,0 +1,16 @@ +#include "script_component.hpp" + +class CfgPatches { + class ADDON { + units[] = {}; + weapons[] = {}; + requiredVersion = REQUIRED_VERSION; + requiredAddons[] = {"ace_common"}; + author[] = {"Jonpas"}; + authorUrl = "https://github.com/jonpas"; + VERSION_CONFIG; + }; +}; + +#include "CfgEventHandlers.hpp" +#include "CfgVehicles.hpp" diff --git a/addons/sitting/functions/fnc_canSit.sqf b/addons/sitting/functions/fnc_canSit.sqf new file mode 100644 index 0000000000..1c00e79cd8 --- /dev/null +++ b/addons/sitting/functions/fnc_canSit.sqf @@ -0,0 +1,27 @@ +/* + * Author: Jonpas + * Check if the player can sit down. + * + * Arguments: + * 0: Seat + * 1: Player + * + * Return Value: + * Can Sit Down + * + * Example: + * [seat, player] call ace_sitting_fnc_canSit; + * + * Public: No + */ +#include "script_component.hpp" + +PARAMS_2(_seat,_player); + +// If seat object and not occupied +if (getNumber (configFile >> "CfgVehicles" >> typeOf _seat >> QGVAR(canSit)) == 1 && + {isNil{_seat getVariable QGVAR(seatOccupied)}} +) exitWith {true}; + +// Default +false diff --git a/addons/sitting/functions/fnc_canStand.sqf b/addons/sitting/functions/fnc_canStand.sqf new file mode 100644 index 0000000000..853eadc3d1 --- /dev/null +++ b/addons/sitting/functions/fnc_canStand.sqf @@ -0,0 +1,22 @@ +/* + * Author: Jonpas + * Check if the player can stand up (is in sitting position). + * + * Arguments: + * Player + * + * Return Value: + * Can Stand Up + * + * Example: + * player call ace_sitting_fnc_canStand; + * + * Public: No + */ +#include "script_component.hpp" + +// If sitting +if (_this getVariable [QGVAR(sitting),false]) exitWith {true}; + +// Default +false diff --git a/addons/sitting/functions/fnc_getRandomAnimation.sqf b/addons/sitting/functions/fnc_getRandomAnimation.sqf new file mode 100644 index 0000000000..79b8c5628f --- /dev/null +++ b/addons/sitting/functions/fnc_getRandomAnimation.sqf @@ -0,0 +1,55 @@ +/* + * Author: Jonpas + * Gets a random animations from the list. + * + * Arguments: + * None + * + * Return Value: + * Random Animation + * + * Example: + * _animation = call ace_sitting_fnc_getRandomAnimation; + * + * Public: No + */ +#include "script_component.hpp" + +// Animations Pool +_animPool = [ + "HubSittingChairUA_idle1", + "HubSittingChairUA_idle2", + "HubSittingChairUA_idle3", + "HubSittingChairUA_move1", + "HubSittingChairUB_idle1", + "HubSittingChairUB_idle2", + "HubSittingChairUB_idle3", + "HubSittingChairUB_move1", + "HubSittingChairUC_idle1", + "HubSittingChairUC_idle2", + "HubSittingChairUC_idle3", + "HubSittingChairUC_move1", + "HubSittingChairA_idle1", + "HubSittingChairA_idle2", + "HubSittingChairA_idle3", + "HubSittingChairA_move1", + "HubSittingChairB_idle1", + "HubSittingChairB_idle2", + "HubSittingChairB_idle3", + "HubSittingChairB_move1", + "HubSittingChairC_idle1", + "HubSittingChairC_idle2", + "HubSittingChairC_idle3", + "HubSittingChairC_move1" +]; + +// Set all animation names to lower-case +_animations = []; +{ + _animations pushBack (toLower _x); +} forEach _animPool; + +// Select random animation +_animation = _animations select (floor (random (count _animations))); + +_animation diff --git a/addons/sitting/functions/fnc_sit.sqf b/addons/sitting/functions/fnc_sit.sqf new file mode 100644 index 0000000000..07026c6e35 --- /dev/null +++ b/addons/sitting/functions/fnc_sit.sqf @@ -0,0 +1,41 @@ +/* + * Author: Jonpas + * Sits down the player. + * + * Arguments: + * 0: Seat + * 1: Player + * + * Return Value: + * None + * + * Example: + * [seat, player] call ace_sitting_fnc_sit; + * + * Public: No + */ +#include "script_component.hpp" + +PARAMS_2(_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"; + +// Read config +_sitDirection = getNumber (configFile >> "CfgVehicles" >> typeOf _seat >> QGVAR(sitDirection)); +_sitPosition = getArray (configFile >> "CfgVehicles" >> typeOf _seat >> QGVAR(sitPosition)); + +// Set direction and position +_player setDir ((getDir _seat) + _sitDirection); +_player setPos (_seat modelToWorld _sitPosition); + +// Get random animation and perform it +_animation = call FUNC(getRandomAnimation); +[_player, _animation, 2] call EFUNC(common,doAnimation); + +// Set variables +_player setVariable [QGVAR(sitting), true]; +_seat setVariable [QGVAR(seatOccupied), true, true]; // To prevent multiple people sitting on one seat diff --git a/addons/sitting/functions/fnc_stand.sqf b/addons/sitting/functions/fnc_stand.sqf new file mode 100644 index 0000000000..5474720b47 --- /dev/null +++ b/addons/sitting/functions/fnc_stand.sqf @@ -0,0 +1,23 @@ +/* + * Author: Jonpas + * Stands up the player. + * + * Arguments: + * Player + * + * Return Value: + * None + * + * Example: + * player call ace_sitting_fnc_stand; + * + * Public: No + */ +#include "script_component.hpp" + +// Restore animation +[_this, "", 2] call EFUNC(common,doAnimation); + +// Set variables to nil +_this setVariable [QGVAR(sitting), nil]; +GVAR(seat) setVariable [QGVAR(seatOccupied), nil, true]; diff --git a/addons/sitting/functions/script_component.hpp b/addons/sitting/functions/script_component.hpp new file mode 100644 index 0000000000..1360c56284 --- /dev/null +++ b/addons/sitting/functions/script_component.hpp @@ -0,0 +1 @@ +#include "\z\ace\addons\sitting\script_component.hpp" \ No newline at end of file diff --git a/addons/sitting/script_component.hpp b/addons/sitting/script_component.hpp new file mode 100644 index 0000000000..cbc8800cd2 --- /dev/null +++ b/addons/sitting/script_component.hpp @@ -0,0 +1,12 @@ +#define COMPONENT sitting +#include "\z\ace\addons\main\script_mod.hpp" + +#ifdef DEBUG_ENABLED_SITTING + #define DEBUG_MODE_FULL +#endif + +#ifdef DEBUG_SETTINGS_SITTING + #define DEBUG_SETTINGS DEBUG_SETTINGS_SITTING +#endif + +#include "\z\ace\addons\main\script_macros.hpp" \ No newline at end of file diff --git a/addons/sitting/stringtable.xml b/addons/sitting/stringtable.xml new file mode 100644 index 0000000000..f58883c4c0 --- /dev/null +++ b/addons/sitting/stringtable.xml @@ -0,0 +1,11 @@ + + + + + Sit Down + + + Stand Up + + + \ No newline at end of file