Initial Sitting commit

This commit is contained in:
jonpas 2015-06-07 22:00:43 +02:00
parent be68284911
commit c3c2fd0074
13 changed files with 324 additions and 0 deletions

View File

@ -0,0 +1 @@
z\ace\addons\sitting

View File

@ -0,0 +1,5 @@
class Extended_PreInit_EventHandlers {
class ADDON {
init = QUOTE(call COMPILE_FILE(XEH_preInit));
};
};

View File

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

View File

@ -0,0 +1,11 @@
#include "script_component.hpp"
ADDON = false;
PREP(canSit);
PREP(canStand);
PREP(getRandomAnimation);
PREP(sit);
PREP(stand);
ADDON = true;

16
addons/sitting/config.cpp Normal file
View File

@ -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"

View File

@ -0,0 +1,27 @@
/*
* Author: Jonpas
* Check if the player can sit down.
*
* Arguments:
* 0: Seat <OBJECT>
* 1: Player <OBJECT>
*
* Return Value:
* Can Sit Down <BOOL>
*
* 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

View File

@ -0,0 +1,22 @@
/*
* Author: Jonpas
* Check if the player can stand up (is in sitting position).
*
* Arguments:
* Player <OBJECT>
*
* Return Value:
* Can Stand Up <BOOL>
*
* 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

View File

@ -0,0 +1,55 @@
/*
* Author: Jonpas
* Gets a random animations from the list.
*
* Arguments:
* None
*
* Return Value:
* Random Animation <STRING>
*
* 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

View File

@ -0,0 +1,41 @@
/*
* Author: Jonpas
* Sits down the player.
*
* Arguments:
* 0: Seat <OBJECT>
* 1: Player <OBJECT>
*
* 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

View File

@ -0,0 +1,23 @@
/*
* Author: Jonpas
* Stands up the player.
*
* Arguments:
* Player <OBJECT>
*
* 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];

View File

@ -0,0 +1 @@
#include "\z\ace\addons\sitting\script_component.hpp"

View File

@ -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"

View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<Project name="ACE">
<Package name="Sitting">
<Key ID="STR_ACE_Sitting_Sit">
<English>Sit Down</English>
</Key>
<Key ID="STR_ACE_Sitting_Stand">
<English>Stand Up</English>
</Key>
</Package>
</Project>