-
Notifications
You must be signed in to change notification settings - Fork 739
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sitting #1541
Sitting #1541
Changes from 1 commit
c3c2fd0
78c9991
eb0541d
4cea9bd
2104e5b
c6b5c70
95ec2ea
f9d292e
951f9d3
332afb2
3e0d4d1
36d4d01
f1f9ee1
3a4cd99
5bfa242
51e83ba
4602025
0a71bd6
491e2a4
b974a63
29ce8f6
254b386
1eeca28
083d34b
922e88d
c8c1f76
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
z\ace\addons\sitting |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class Extended_PreInit_EventHandlers { | ||
class ADDON { | ||
init = QUOTE(call COMPILE_FILE(XEH_preInit)); | ||
}; | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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}; | ||
}; | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#include "script_component.hpp" | ||
|
||
ADDON = false; | ||
|
||
PREP(canSit); | ||
PREP(canStand); | ||
PREP(getRandomAnimation); | ||
PREP(sit); | ||
PREP(stand); | ||
|
||
ADDON = true; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 && | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No need for an if statement here, just do: (getNumber (configFile >> "CfgVehicles" >> typeOf _seat >> QGVAR(canSit)) == 1 && {isNil{_seat getVariable QGVAR(seatOccupied)}}) |
||
{isNil{_seat getVariable QGVAR(seatOccupied)}} | ||
) exitWith {true}; | ||
|
||
// Default | ||
false |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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}; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as above, no need for an if statement. |
||
|
||
// Default | ||
false |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You are missing privates in this function |
||
// 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); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do the animation names need to be lower case and if so, why loop over them here all the time? Just convert them to lower case once and use that in the script instead. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That is left from the addAction version of the script, can't even remember why anymore. Will remove. |
||
} forEach _animPool; | ||
|
||
// Select random animation | ||
_animation = _animations select (floor (random (count _animations))); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can use _animations select (floor (random (count _animations))); For the return There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. and you dont need to use floor because select can work with that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will change, thank you! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
|
||
_animation |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing privates |
||
_sitPosition = getArray (configFile >> "CfgVehicles" >> typeOf _seat >> QGVAR(sitPosition)); | ||
|
||
// Set direction and position | ||
_player setDir ((getDir _seat) + _sitDirection); | ||
_player setPos (_seat modelToWorld _sitPosition); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I will test, stil better to use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would recommend the following:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just tried,
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
IMO it's better not to use getPos / setPos. I think the code above by @ulteq is the most reliable. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I will change then. |
||
|
||
// Get random animation and perform it | ||
_animation = call FUNC(getRandomAnimation); | ||
[_player, _animation, 2] call EFUNC(common,doAnimation); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The above two lines can be combined into one. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You mean combined into one I guess, will do. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You are right - it was a typo. I've adjusted it. |
||
|
||
// Set variables | ||
_player setVariable [QGVAR(sitting), true]; | ||
_seat setVariable [QGVAR(seatOccupied), true, true]; // To prevent multiple people sitting on one seat |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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]; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
#include "\z\ace\addons\sitting\script_component.hpp" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
<Key ID="STR_ACE_Sitting_Stand"> | ||
<English>Stand Up</English> | ||
</Key> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
</Package> | ||
</Project> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we add
ACE_ToiletPaper
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am willing to!