Minor code clean up

This commit is contained in:
Thomas Kooi 2015-01-17 13:54:44 +01:00
parent eaa44fce6f
commit 7345cf91cf
5 changed files with 42 additions and 61 deletions

View File

@ -10,8 +10,4 @@
#include "script_component.hpp"
private ["_unit","_to"];
_to = _this select 0;
_unit = _this select 1;
([_to] call FUNC(getCarriedBy) == [_unit] call FUNC(getCarriedBy));
([(_this select 0)] call FUNC(getCarriedBy) == [(_this select 1)] call FUNC(getCarriedBy));

View File

@ -12,9 +12,10 @@ private ["_object", "_return", "_val", "_category"];
_object = _this select 0;
_category = if (count _this > 1) then { _this select 1 } else { "" };
if (isnil QGVAR(OBJECT_VARIABLES_STORAGE)) then {
GVAR(OBJECT_VARIABLES_STORAGE) = [];
if (isnil QGVAR(OBJECT_VARIABLES_STORAGE)) exitwith {
[];
};
_return = [];
{
_val = _object getvariable (_x select 0);

View File

@ -11,23 +11,28 @@
private ["_unit", "_curAnim", "_animation", "_cfg","_unitAnimation", "_animationState"];
_unit = _this select 0;
_animation = "";
_animationState = (animationState _unit);
_unitAnimation = (configFile >> "CfgMovesMaleSdr" >> "States" >> _animationState);
if (isText (_unitAnimation >> "actions")) then {
if ((vehicle _unit) != _unit) then {
_cfg = (configFile >> "CfgMovesMaleSdr" >> "States" >> _animationState);
if (isArray (_cfg >> "interpolateTo")) then {
_animation = getArray (_cfg >> "interpolateTo") select 0;
};
} else {
_cfg = (configFile >> "CfgMovesBasic" >> "Actions" >> (getText (_unitAnimation >> "actions")) >> "die");
if (isText _cfg) then {
_animation = getText _cfg;
if (vehicle _unit != _unit) exitwith {
_animation = "";
_animationState = (animationState _unit);
_unitAnimation = (configFile >> "CfgMovesMaleSdr" >> "States" >> _animationState);
if (isText (_unitAnimation >> "actions")) then {
if ((vehicle _unit) != _unit) then {
_cfg = (configFile >> "CfgMovesMaleSdr" >> "States" >> _animationState);
if (isArray (_cfg >> "interpolateTo")) then {
_animation = getArray (_cfg >> "interpolateTo") select 0;
};
} else {
_cfg = (configFile >> "CfgMovesBasic" >> "Actions" >> (getText (_unitAnimation >> "actions")) >> "die");
if (isText _cfg) then {
_animation = getText _cfg;
};
};
};
if (isnil "_animation") then {
_animation = "";
};
_animation;
};
if (isnil "_animation") then {
_animation = "";
};
_animation
"Unconscious";

View File

@ -11,17 +11,7 @@
#include "script_component.hpp"
private ["_unit","_oldUnit","_sets"];
_unit = [_this, 0, objNull, [objNull]] call BIS_fnc_param;
_oldUnit = [_this, 1, objNull, [objNull]] call BIS_fnc_param;
//_unit setvariable[QGVAR(unconscious_non_captive_f),nil];
if (missionNamespace getvariable [QGVAR(unconscious_non_captive_f),false]) then {
_unit setCaptive false;
missionNamespace setvariable[QGVAR(unconscious_non_captive_f),nil];
[format["Detected unit as a non captive but in captive state. RESETTING"]] call FUNC(debug);
} else {
[format["didn't trigger but unit is: %1 - %2", captive _unit, (missionNamespace getvariable [QGVAR(unconscious_non_captive_f),false])]] call FUNC(debug);
};
_unit = _this select 0;
_unit setvariable [QGVAR(isDead),nil,true];
_unit setvariable [QGVAR(stateUnconscious), nil, true];
@ -31,23 +21,19 @@ if (isPlayer _unit) then {
[false] call FUNC(disableKeyInput_f);
[false] call EFUNC(GUI,effectBlackOut);
[player, -1] call FUNC(limitSpeed);
if (isnil QGVAR(DISABLE_USER_INPUT_COLLECTION_F)) then {
GVAR(DISABLE_USER_INPUT_COLLECTION_F) = [];
if !(isnil QGVAR(DISABLE_USER_INPUT_COLLECTION_F)) then {
// clear all disable user input
{
[_X, false] call FUNC(disableUserInput_f);
}foreach GVAR(DISABLE_USER_INPUT_COLLECTION_F);
};
{
[_X, false] call FUNC(disableUserInput_f);
}foreach GVAR(DISABLE_USER_INPUT_COLLECTION_F);
};
_sets = [_unit] call FUNC(getAllDefinedSetVariables);
[format["defaults for %1 : %2",_unit,_sets]] call FUNC(debug);
if ((count _sets) > 0) then {
{
if (!(_x select 4)) then {
_unit setvariable [(_x select 0),nil,_x select 3];
[format["RESETTING: %1",[(_x select 0),_unit, _x select 1, (_unit getvariable (_x select 0))]]] call FUNC(debug);
};
}foreach _sets;
} else {
["No defaults have been set"] call FUNC(debug);
};
{
if (!(_x select 4)) then {
_unit setvariable [(_x select 0),nil,_x select 3];
};
}foreach ([_unit] call FUNC(getAllDefinedSetVariables));
[[_unit],"resetToDefaults"] call FUNC(raiseScriptedEvent_f);

View File

@ -20,20 +20,13 @@ if (_setCaptive) then {
if (captive _unit) then {
_captiveSwitch = false;
} else {
if (player == _unit) then {
missionNamespace setvariable[QGVAR(unconscious_non_captive_f),true];
};
_unit setCaptive true;
[format["USED SETCAPTIVE",_unit]] call FUNC(debug);
};
} else {
if (alive _unit) then {
if (captive _unit) then {
_unit setCaptive false;
if (!isnil QGVAR(unconscious_non_captive_f)) then {
missionNamespace setvariable[QGVAR(unconscious_non_captive_f),nil];
};
} else {
_unit setCaptive false;
_captiveSwitch = false;
};
};