Skip to content
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

Merged
merged 26 commits into from
Jun 26, 2015
Merged

Sitting #1541

Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
c3c2fd0
Initial Sitting commit
jonpas Jun 7, 2015
78c9991
Added Polish stringtable
jonpas Jun 7, 2015
eb0541d
Added icons
jonpas Jun 7, 2015
4cea9bd
Added Sitting README.md
jonpas Jun 7, 2015
2104e5b
Optimized condition functions, Removed redundant toLower for animatio…
jonpas Jun 8, 2015
c6b5c70
Added Sitting Settings and Module
jonpas Jun 8, 2015
95ec2ea
Added isNotSitting exception, Renamed sitting QGVAR
jonpas Jun 8, 2015
f9d292e
Missing privates
jonpas Jun 9, 2015
951f9d3
Allow interaction menu while sitting
jonpas Jun 9, 2015
332afb2
Allow certain self-interactions while sitting
jonpas Jun 9, 2015
3e0d4d1
Fixed Rattan Chair position, doAnimation before moving player
jonpas Jun 9, 2015
36d4d01
Adjusted Chair (Plastic) sitting position
jonpas Jun 9, 2015
f1f9ee1
Added module icon, removed comment
jonpas Jun 9, 2015
3a4cd99
Changed setPos to setPosASL for reliability, Fixed module icon name
jonpas Jun 9, 2015
5bfa242
Git hates me
jonpas Jun 9, 2015
51e83ba
Handle kileld and disconnect while sitting
jonpas Jun 9, 2015
4602025
Fixed typo
jonpas Jun 11, 2015
0a71bd6
Restricted sitting rotation
jonpas Jun 11, 2015
491e2a4
Handle handcuffing
jonpas Jun 11, 2015
b974a63
Lowercased function, comment
jonpas Jun 11, 2015
29ce8f6
Merge branch 'master' into sitting
jonpas Jun 13, 2015
254b386
Allowed Kestrel4500 Inside and Sitting
jonpas Jun 13, 2015
1eeca28
Enabled DAGR, Kestrel4500, Laser switching, Mag Repack, Markers, Micr…
jonpas Jun 13, 2015
083d34b
Removed redundant GVAR
jonpas Jun 17, 2015
922e88d
Fixed handcuffing not breaking sitting animation
jonpas Jun 22, 2015
c8c1f76
Macro usage, privates fix
jonpas Jun 26, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions addons/sitting/$PBOPREFIX$
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
z\ace\addons\sitting
5 changes: 5 additions & 0 deletions addons/sitting/CfgEventHandlers.hpp
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));
};
};
99 changes: 99 additions & 0 deletions addons/sitting/CfgVehicles.hpp
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 {
Copy link
Contributor

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?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am willing to!

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};
};
};
11 changes: 11 additions & 0 deletions addons/sitting/XEH_preInit.sqf
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;
16 changes: 16 additions & 0 deletions addons/sitting/config.cpp
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"
27 changes: 27 additions & 0 deletions addons/sitting/functions/fnc_canSit.sqf
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 &&
Copy link
Contributor

Choose a reason for hiding this comment

The 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
22 changes: 22 additions & 0 deletions addons/sitting/functions/fnc_canStand.sqf
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};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above, no need for an if statement.


// Default
false
55 changes: 55 additions & 0 deletions addons/sitting/functions/fnc_getRandomAnimation.sqf
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"

Copy link
Contributor

Choose a reason for hiding this comment

The 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);
Copy link
Contributor

Choose a reason for hiding this comment

The 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.

Copy link
Member Author

Choose a reason for hiding this comment

The 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)));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use

_animations select (floor (random (count _animations)));

For the return

Copy link
Member

Choose a reason for hiding this comment

The 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
_animations select (random (count _animations));

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will change, thank you!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The floor is necessary for even distribution


_animation
41 changes: 41 additions & 0 deletions addons/sitting/functions/fnc_sit.sqf
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));
Copy link
Contributor

Choose a reason for hiding this comment

The 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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will setPos work in this context in a building with multiple stories?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will test, stil better to use setPosATL anyways, will change.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would recommend the following:

_player setPosASL (_seat modelToWorld _sitPosition) call EFUNC(common,positionToASL);

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just tried, setPos works fine above terrain level as well since it uses modelToWorld. Is it worth calling positionToASL with setPosASL if it works?

I did notice it doesn't apply bitch and bank though, will do that. Scratch that, not working properly with player object (at least not from my quick test), plus it's not reliable, if the seat would be upside-down you could end up hurting yourself below the terrain. 😁

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just tried, setPos works fine above terrain level as well since it uses modelToWorld. Is it worth calling positionToASL with setPosASL if it works?

IMO it's better not to use getPos / setPos. I think the code above by @ulteq is the most reliable.

Copy link
Member Author

Choose a reason for hiding this comment

The 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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The above two lines can be combined into one. _animation is not used anywhere else, so might as well not store it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You mean combined into one I guess, will do.

Copy link
Contributor

Choose a reason for hiding this comment

The 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
23 changes: 23 additions & 0 deletions addons/sitting/functions/fnc_stand.sqf
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];
1 change: 1 addition & 0 deletions addons/sitting/functions/script_component.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include "\z\ace\addons\sitting\script_component.hpp"
12 changes: 12 additions & 0 deletions 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"
11 changes: 11 additions & 0 deletions addons/sitting/stringtable.xml
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>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

< Polish>Usiądź</Polish>

<Key ID="STR_ACE_Sitting_Stand">
<English>Stand Up</English>
</Key>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

< Polish>Wstań</Polish> - can you add?

</Package>
</Project>