Skip to content

Commit

Permalink
Merge pull request #3092 from acemod/minorSittingCleanup
Browse files Browse the repository at this point in the history
Sitting Cleanup
  • Loading branch information
PabstMirror committed Dec 31, 2015
2 parents 7b077c5 + f11c2af commit 62a9475
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 20 deletions.
17 changes: 12 additions & 5 deletions addons/sitting/XEH_clientInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,16 @@
// Exit on Headless
if (!hasInterface) exitWith {};

// Add interaction menu exception
["isNotSitting", {isNil {(_this select 0) getVariable QGVAR(isSitting)}}] call EFUNC(common,addCanInteractWithCondition);
["SettingsInitialized", {
TRACE_1("SettingInit", GVAR(enable));

//If not enabled, then do not add CanInteractWith Condition or event handlers:
if (!GVAR(enable)) exitWith {};

// Handle interruptions
["medical_onUnconscious", {_this call DFUNC(handleInterrupt)}] call EFUNC(common,addEventhandler);
["SetHandcuffed", {_this call DFUNC(handleInterrupt)}] call EFUNC(common,addEventhandler);
// Add interaction menu exception
["isNotSitting", {isNil {(_this select 0) getVariable QGVAR(isSitting)}}] call EFUNC(common,addCanInteractWithCondition);

// Handle interruptions
["medical_onUnconscious", {_this call DFUNC(handleInterrupt)}] call EFUNC(common,addEventhandler);
["SetHandcuffed", {_this call DFUNC(handleInterrupt)}] call EFUNC(common,addEventhandler);
}] call EFUNC(common,addEventHandler);
15 changes: 12 additions & 3 deletions addons/sitting/functions/fnc_addSitActions.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,28 @@
#include "script_component.hpp"

params ["_seat"];
private ["_type", "_sitAction"];

_type = typeOf _seat;
private _type = typeOf _seat;

// Exit if the object is not specified as a seat
if (getNumber (configFile >> "CfgVehicles" >> _type >> QGVAR(canSit)) != 1) exitWith {};

// only run this after the settings are initialized
if !(EGVAR(common,settingsInitFinished)) exitWith {
EGVAR(common,runAtSettingsInitialized) pushBack [FUNC(addSitActions), _this];
};

//If not enabled, don't add actions:
if (!GVAR(enable)) exitWith {};

// Exit if class already initialized
if (_type in GVAR(initializedClasses)) exitWith {};

GVAR(initializedClasses) pushBack _type;

_sitAction = [
TRACE_1("Adding Sit Action",_type);

private _sitAction = [
QGVAR(Sit),
localize LSTRING(Sit),
QUOTE(PATHTOF(UI\sit_ca.paa)),
Expand Down
4 changes: 1 addition & 3 deletions addons/sitting/functions/fnc_getRandomAnimation.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,8 @@
*/
#include "script_component.hpp"

private "_animations";

// Animations Pool
_animations = [
private _animations = [
QGVAR(HubSittingChairA_idle1),
QGVAR(HubSittingChairA_idle2),
QGVAR(HubSittingChairA_idle3),
Expand Down
12 changes: 5 additions & 7 deletions addons/sitting/functions/fnc_sit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,13 @@
*/
#include "script_component.hpp"

private ["_actionID", "_configFile", "_sitDirection", "_sitPosition", "_seatPosOrig"];

params ["_seat", "_player"];

// 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 addAction [
private _actionID = _player addAction [
format ["<t color='#FFFF00'>%1</t>", localize LSTRING(Stand)],
QUOTE((_this select 0) call FUNC(stand)),
nil,
Expand All @@ -36,9 +34,9 @@ _actionID = _player addAction [
];

// Read config
_configFile = configFile >> "CfgVehicles" >> typeOf _seat;
_sitDirection = (getDir _seat) + getNumber (_configFile >> QGVAR(sitDirection));
_sitPosition = getArray (_configFile >> QGVAR(sitPosition));
private _configFile = configFile >> "CfgVehicles" >> typeOf _seat;
private _sitDirection = (getDir _seat) + getNumber (_configFile >> QGVAR(sitDirection));
private _sitPosition = getArray (_configFile >> QGVAR(sitPosition));

// 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
Expand All @@ -55,7 +53,7 @@ _seat setVariable [QGVAR(seatOccupied), true, true]; // To prevent multiple peop


// Add automatical stand PFH in case of interruptions
_seatPosOrig = getPosASL _seat;
private _seatPosOrig = getPosASL _seat;
[{
params ["_args", "_pfhId"];
_args params ["_player", "_seat", "_seatPosOrig"];
Expand Down
3 changes: 1 addition & 2 deletions addons/sitting/functions/fnc_stand.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,14 @@
#include "script_component.hpp"

params ["_player"];
private ["_animation"];

(_player getVariable QGVAR(isSitting)) params ["_seat", "_actionID"];

// Remove scroll-wheel action
_player removeAction _actionID;

// Restore animation
_animation = switch (currentWeapon _player) do {
private _animation = switch (currentWeapon _player) do {
case "": {"amovpercmstpsnonwnondnon"};
case (primaryWeapon _player): {"amovpercmstpslowwrfldnon"};
case (handgunWeapon _player): {"amovpercmstpslowwpstdnon"};
Expand Down

0 comments on commit 62a9475

Please sign in to comment.