Optimized condition functions, Removed redundant toLower for animation names

This commit is contained in:
jonpas
2015-06-08 17:52:33 +02:00
parent 4cea9bd1bc
commit 2104e5b45f
5 changed files with 12 additions and 24 deletions

View File

@ -19,9 +19,4 @@
PARAMS_2(_seat,_player); PARAMS_2(_seat,_player);
// If seat object and not occupied // If seat object and not occupied
if (getNumber (configFile >> "CfgVehicles" >> typeOf _seat >> QGVAR(canSit)) == 1 && (getNumber (configFile >> "CfgVehicles" >> typeOf _seat >> QGVAR(canSit)) == 1 && {isNil{_seat getVariable QGVAR(seatOccupied)}})
{isNil{_seat getVariable QGVAR(seatOccupied)}}
) exitWith {true};
// Default
false

View File

@ -15,8 +15,7 @@
*/ */
#include "script_component.hpp" #include "script_component.hpp"
// If sitting PARAMS_1(_player);
if (_this getVariable [QGVAR(sitting),false]) exitWith {true};
// Default // If sitting
false (_player getVariable [QGVAR(sitting),false])

View File

@ -16,7 +16,7 @@
#include "script_component.hpp" #include "script_component.hpp"
// Animations Pool // Animations Pool
_animPool = [ _animations = [
"HubSittingChairUA_idle1", "HubSittingChairUA_idle1",
"HubSittingChairUA_idle2", "HubSittingChairUA_idle2",
"HubSittingChairUA_idle3", "HubSittingChairUA_idle3",
@ -43,13 +43,5 @@ _animPool = [
"HubSittingChairC_move1" "HubSittingChairC_move1"
]; ];
// Set all animation names to lower-case
_animations = [];
{
_animations pushBack (toLower _x);
} forEach _animPool;
// Select random animation // Select random animation
_animation = _animations select (floor (random (count _animations))); (_animations select (floor (random (count _animations))))
_animation

View File

@ -33,8 +33,7 @@ _player setDir ((getDir _seat) + _sitDirection);
_player setPos (_seat modelToWorld _sitPosition); _player setPos (_seat modelToWorld _sitPosition);
// Get random animation and perform it // Get random animation and perform it
_animation = call FUNC(getRandomAnimation); [_player, call FUNC(getRandomAnimation), 2] call EFUNC(common,doAnimation);
[_player, _animation, 2] call EFUNC(common,doAnimation);
// Set variables // Set variables
_player setVariable [QGVAR(sitting), true]; _player setVariable [QGVAR(sitting), true];

View File

@ -15,9 +15,12 @@
*/ */
#include "script_component.hpp" #include "script_component.hpp"
PARAMS_1(_player);
// Restore animation // Restore animation
[_this, "", 2] call EFUNC(common,doAnimation); [_player, "", 2] call EFUNC(common,doAnimation);
// Set variables to nil // Set variables to nil
_this setVariable [QGVAR(sitting), nil]; _player setVariable [QGVAR(sitting), nil];
GVAR(seat) setVariable [QGVAR(seatOccupied), nil, true]; GVAR(seat) setVariable [QGVAR(seatOccupied), nil, true];
GVAR(seat) = nil;