use a function to do gestures

This commit is contained in:
commy2 2016-07-12 16:16:01 +02:00
parent de612d9613
commit 8a4514f8e7
26 changed files with 69 additions and 37 deletions

View File

@ -32,6 +32,7 @@ PREP(displayText);
PREP(displayTextPicture); PREP(displayTextPicture);
PREP(displayTextStructured); PREP(displayTextStructured);
PREP(doAnimation); PREP(doAnimation);
PREP(doGesture);
PREP(dropBackpack); PREP(dropBackpack);
PREP(endRadioTransmission); PREP(endRadioTransmission);
PREP(eraseCache); PREP(eraseCache);

View File

@ -118,6 +118,8 @@ if (isServer) then {
[QGVAR(setVelocity), {(_this select 0) setVelocity (_this select 1)}] call CBA_fnc_addEventHandler; [QGVAR(setVelocity), {(_this select 0) setVelocity (_this select 1)}] call CBA_fnc_addEventHandler;
[QGVAR(playMove), {(_this select 0) playMove (_this select 1)}] call CBA_fnc_addEventHandler; [QGVAR(playMove), {(_this select 0) playMove (_this select 1)}] call CBA_fnc_addEventHandler;
[QGVAR(playMoveNow), {(_this select 0) playMoveNow (_this select 1)}] call CBA_fnc_addEventHandler; [QGVAR(playMoveNow), {(_this select 0) playMoveNow (_this select 1)}] call CBA_fnc_addEventHandler;
[QGVAR(playAction), {(_this select 0) playAction (_this select 1)}] call CBA_fnc_addEventHandler;
[QGVAR(playActionNow), {(_this select 0) playActionNow (_this select 1)}] call CBA_fnc_addEventHandler;
[QGVAR(switchMove), {(_this select 0) switchMove (_this select 1)}] call CBA_fnc_addEventHandler; [QGVAR(switchMove), {(_this select 0) switchMove (_this select 1)}] call CBA_fnc_addEventHandler;
[QGVAR(setVectorDirAndUp), {(_this select 0) setVectorDirAndUp (_this select 1)}] call CBA_fnc_addEventHandler; [QGVAR(setVectorDirAndUp), {(_this select 0) setVectorDirAndUp (_this select 1)}] call CBA_fnc_addEventHandler;
[QGVAR(setVanillaHitPointDamage), {(_this select 0) setHitPointDamage (_this select 1)}] call CBA_fnc_addEventHandler; [QGVAR(setVanillaHitPointDamage), {(_this select 0) setHitPointDamage (_this select 1)}] call CBA_fnc_addEventHandler;
@ -406,8 +408,6 @@ GVAR(OldIsCamera) = false;
GVAR(isReloading) = false; GVAR(isReloading) = false;
["isNotReloading", {!GVAR(isReloading)}] call FUNC(addCanInteractWithCondition);
["keyDown", { ["keyDown", {
if ((_this select 1) in actionKeys "ReloadMagazine" && {alive ACE_player}) then { if ((_this select 1) in actionKeys "ReloadMagazine" && {alive ACE_player}) then {
private _weapon = currentWeapon ACE_player; private _weapon = currentWeapon ACE_player;

View File

@ -0,0 +1,24 @@
/*
* Author: commy2
* Play a gesture.
*
* Arguments:
* 0: Unit <OBJECT>
* 1: Animation <STRING>
*
* Return Value:
* None
*
* Example:
* [player, "gestureGo"] call ace_common_fnc_doGesture
*
* Public: No
*/
#include "script_component.hpp"
params ["_unit", "_animation"];
TRACE_4("params",_unit,_animation);
if (!GVAR(isReloading)) then {
[QGVAR(playActionNow), [_unit, _animation], _unit] call CBA_fnc_targetEvent;
};

View File

@ -26,7 +26,7 @@ private _inBuilding = [_unit] call FUNC(isObjectOnObject);
if !(_unit getVariable ["ACE_isUnconscious", false]) then { if !(_unit getVariable ["ACE_isUnconscious", false]) then {
// play release animation // play release animation
_unit playAction "released"; [_unit, "released"] call EFUNC(common,doGesture);
}; };
// prevent collision damage // prevent collision damage

View File

@ -39,7 +39,9 @@ _unit selectWeapon primaryWeapon _unit;
[_unit, _target, true] call EFUNC(common,claim); [_unit, _target, true] call EFUNC(common,claim);
// can't play action that depends on weapon if it was added the same frame // can't play action that depends on weapon if it was added the same frame
[{_this playActionNow "grabDrag";}, _unit] call CBA_fnc_execNextFrame; [{
[_this, "grabDrag"] call EFUNC(common,doGesture);
}, _unit] call CBA_fnc_execNextFrame;
// move a bit closer and adjust direction when trying to pick up a person // move a bit closer and adjust direction when trying to pick up a person
if (_target isKindOf "CAManBase") then { if (_target isKindOf "CAManBase") then {

View File

@ -27,7 +27,7 @@ TRACE_7("params",_unit,_pos,_dir,_magazineClass,_triggerConfig,_triggerSpecificV
private ["_ammo", "_explosive", "_attachedTo", "_magazineTrigger", "_pitch", "_digDistance", "_canDigDown", "_soundEnviron", "_surfaceType"]; private ["_ammo", "_explosive", "_attachedTo", "_magazineTrigger", "_pitch", "_digDistance", "_canDigDown", "_soundEnviron", "_surfaceType"];
_unit playActionNow "PutDown"; [_unit, "PutDown"] call EFUNC(common,doGesture);
_attachedTo = objNull; _attachedTo = objNull;
if (!isNull _setupPlaceholderObject) then { if (!isNull _setupPlaceholderObject) then {

View File

@ -185,7 +185,7 @@ GVAR(TweakedAngle) = 0;
_expSetupVehicle setVariable [QGVAR(Direction), _placeAngle, true]; _expSetupVehicle setVariable [QGVAR(Direction), _placeAngle, true];
_unit removeMagazine _magClassname; _unit removeMagazine _magClassname;
_unit playActionNow "PutDown"; [_unit, "PutDown"] call EFUNC(common,doGesture);
_unit setVariable [QGVAR(PlantingExplosive), true]; _unit setVariable [QGVAR(PlantingExplosive), true];
[{_this setVariable [QGVAR(PlantingExplosive), false]}, _unit, 1.5] call CBA_fnc_waitAndExecute; [{_this setVariable [QGVAR(PlantingExplosive), false]}, _unit, 1.5] call CBA_fnc_waitAndExecute;

View File

@ -46,7 +46,7 @@ if (ACE_player != _unit) then {
if (isPlayer _unit) then { if (isPlayer _unit) then {
[QGVAR(startDefuse), [_unit, _target], _unit] call CBA_fnc_targetEvent; [QGVAR(startDefuse), [_unit, _target], _unit] call CBA_fnc_targetEvent;
} else { } else {
_unit playActionNow _actionToPlay; [_unit, _actionToPlay] call EFUNC(common,doGesture);
_unit disableAI "MOVE"; _unit disableAI "MOVE";
_unit disableAI "TARGET"; _unit disableAI "TARGET";
_defuseTime = [[_unit] call EFUNC(Common,isEOD), _target] call _fnc_DefuseTime; _defuseTime = [[_unit] call EFUNC(Common,isEOD), _target] call _fnc_DefuseTime;
@ -59,7 +59,7 @@ if (ACE_player != _unit) then {
}, [_unit, _target], _defuseTime] call CBA_fnc_waitAndExecute; }, [_unit, _target], _defuseTime] call CBA_fnc_waitAndExecute;
}; };
} else { } else {
_unit playActionNow _actionToPlay; [_unit, _actionToPlay] call EFUNC(common,doGesture);
_isEOD = [_unit] call EFUNC(Common,isEOD); _isEOD = [_unit] call EFUNC(Common,isEOD);
_defuseTime = [_isEOD, _target] call _fnc_DefuseTime; _defuseTime = [_isEOD, _target] call _fnc_DefuseTime;
if (_isEOD || {!GVAR(RequireSpecialist)}) then { if (_isEOD || {!GVAR(RequireSpecialist)}) then {

View File

@ -60,6 +60,6 @@ TRACE_1("sending finger to",_sendFingerToPlayers);
[QGVAR(fingered), [ACE_player, _fingerPosASL, _originASL vectorDistance _fingerPosASL], _sendFingerToPlayers] call CBA_fnc_targetEvent; [QGVAR(fingered), [ACE_player, _fingerPosASL, _originASL vectorDistance _fingerPosASL], _sendFingerToPlayers] call CBA_fnc_targetEvent;
ACE_player playActionNow "GestureGo"; [ACE_player, "GestureGo"] call EFUNC(common,doGesture);
true true

View File

@ -14,42 +14,42 @@ class CfgVehicles {
class GVAR(Advance) { class GVAR(Advance) {
displayName = CSTRING(Advance); displayName = CSTRING(Advance);
condition = QUOTE(true); condition = QUOTE(true);
statement = QUOTE(_target playActionNow 'gestureAdvance';); statement = QUOTE([ARR_2(_target,'gestureAdvance')] call EFUNC(common,doGesture););
showDisabled = 1; showDisabled = 1;
priority = 1.9; priority = 1.9;
}; };
class GVAR(Go) { class GVAR(Go) {
displayName = CSTRING(Go); displayName = CSTRING(Go);
condition = QUOTE(true); condition = QUOTE(true);
statement = QUOTE(_target playActionNow ([ARR_2('gestureGo','gestureGoB')] select floor random 2);); statement = QUOTE([ARR_2(_target,selectRandom [ARR_2('gestureGo','gestureGoB')])] call EFUNC(common,doGesture););
showDisabled = 1; showDisabled = 1;
priority = 1.8; priority = 1.8;
}; };
class GVAR(Follow) { class GVAR(Follow) {
displayName = CSTRING(Follow); displayName = CSTRING(Follow);
condition = QUOTE(true); condition = QUOTE(true);
statement = QUOTE(_target playActionNow 'gestureFollow';); statement = QUOTE([ARR_2(_target,'gestureFollow')] call EFUNC(common,doGesture););
showDisabled = 1; showDisabled = 1;
priority = 1.7; priority = 1.7;
}; };
class GVAR(Up) { class GVAR(Up) {
displayName = CSTRING(Up); displayName = CSTRING(Up);
condition = QUOTE(true); condition = QUOTE(true);
statement = QUOTE(_target playActionNow 'gestureUp';); statement = QUOTE([ARR_2(_target,'gestureUp')] call EFUNC(common,doGesture););
showDisabled = 1; showDisabled = 1;
priority = 1.5; priority = 1.5;
}; };
class GVAR(CeaseFire) { class GVAR(CeaseFire) {
displayName = CSTRING(CeaseFire); displayName = CSTRING(CeaseFire);
condition = QUOTE(true); condition = QUOTE(true);
statement = QUOTE(_target playActionNow 'gestureCeaseFire';); statement = QUOTE([ARR_2(_target,'gestureCeaseFire')] call EFUNC(common,doGesture););
showDisabled = 1; showDisabled = 1;
priority = 1.3; priority = 1.3;
}; };
class GVAR(Stop) { class GVAR(Stop) {
displayName = CSTRING(Stop); displayName = CSTRING(Stop);
condition = QUOTE(true); condition = QUOTE(true);
statement = QUOTE(_target playActionNow 'gestureFreeze';); // BI animation - is actualls "stop" in all stances but prone statement = QUOTE([ARR_2(_target,'gestureFreeze')] call EFUNC(common,doGesture);); // BI animation - is actualls "stop" in all stances but prone
showDisabled = 1; showDisabled = 1;
priority = 1.2; priority = 1.2;
}; };

View File

@ -17,7 +17,6 @@
TRACE_1("params",_this); TRACE_1("params",_this);
if (EGVAR(common,isReloading)) exitWith {false};
if (GVAR(showOnInteractionMenu) == 0) exitWith {false}; if (GVAR(showOnInteractionMenu) == 0) exitWith {false};
if !([ACE_player, objNull, []] call EFUNC(common,canInteractWith)) exitWith {false}; if !([ACE_player, objNull, []] call EFUNC(common,canInteractWith)) exitWith {false};
@ -34,5 +33,5 @@ private _gesture = if ((_this select [0,2]) == "BI") then {
}; };
TRACE_1("playing gesture",_gesture); TRACE_1("playing gesture",_gesture);
ACE_player playAction _gesture; [ACE_player, _gesture] call EFUNC(common,doGesture);
true true

View File

@ -27,7 +27,7 @@ _effects set [BROKEN, _broken];
SETGLASSES(_unit,_effects); SETGLASSES(_unit,_effects);
if ((stance _unit != "PRONE") && {primaryWeapon _unit != ""} && {currentWeapon _unit == primaryWeapon _unit}) then { if ((stance _unit != "PRONE") && {primaryWeapon _unit != ""} && {currentWeapon _unit == primaryWeapon _unit}) then {
_unit playActionNow "gestureWipeFace"; [_unit, "gestureWipeFace"] call EFUNC(common,doGesture);
}; };
[{ [{

View File

@ -20,7 +20,7 @@
params ["_unit", "_target"]; params ["_unit", "_target"];
_unit playActionNow "GestureGo"; [_unit, "GestureGo"] call EFUNC(common,doGesture);
private "_chance"; private "_chance";
_chance = [0.5, 0.8] select (count weapons _unit > 0); _chance = [0.5, 0.8] select (count weapons _unit > 0);

View File

@ -45,7 +45,7 @@ _player removeMagazines _magToPassClassName;
}; };
} foreach _filteredMags; } foreach _filteredMags;
_player playActionNow "PutDown"; [_player, "PutDown"] call EFUNC(common,doGesture);
_target addMagazine [_magToPassClassName, _magToPassAmmoCount]; _target addMagazine [_magToPassClassName, _magToPassAmmoCount];

View File

@ -20,7 +20,7 @@
params ["_unit"]; params ["_unit"];
_unit playActionNow "GestureGo"; [_unit, "GestureGo"] call EFUNC(common,doGesture);
private "_chance"; private "_chance";
_chance = [0.5, 0.8] select (count weapons _unit > 0); _chance = [0.5, 0.8] select (count weapons _unit > 0);

View File

@ -23,6 +23,6 @@ if (_unit == ACE_player) then {
addCamShake [4, 0.5, 5]; addCamShake [4, 0.5, 5];
}; };
_unit playActionNow "PutDown"; [_unit, "PutDown"] call EFUNC(common,doGesture);
[QGVAR(tapShoulder), [_target, _shoulderNum], [_target]] call CBA_fnc_targetEvent; [QGVAR(tapShoulder), [_target, _shoulderNum], [_target]] call CBA_fnc_targetEvent;

View File

@ -28,7 +28,7 @@ if (_assistant isEqualTo _gunner) then {
_action = "Gear"; _action = "Gear";
}; };
}; };
_assistant playActionNow _action; [_assistant, _action] call EFUNC(common,doGesture);
// Waits a sec before displaying the temperature // Waits a sec before displaying the temperature
[FUNC(displayTemperature), [_gunner, _weapon], 1.0] call CBA_fnc_waitAndExecute; [FUNC(displayTemperature), [_gunner, _weapon], 1.0] call CBA_fnc_waitAndExecute;

View File

@ -32,7 +32,7 @@ if (_weapon in _jammedWeapons) then {
_clearJamAction = getText (configFile >> "CfgWeapons" >> _weapon >> "reloadAction"); _clearJamAction = getText (configFile >> "CfgWeapons" >> _weapon >> "reloadAction");
}; };
_unit playActionNow _clearJamAction; [_unit, _clearJamAction] call EFUNC(common,doGesture);
if (_weapon == primaryWeapon _unit) then { if (_weapon == primaryWeapon _unit) then {
playSound QGVAR(fixing_rifle); playSound QGVAR(fixing_rifle);
} else { } else {

View File

@ -26,7 +26,7 @@ if (stance _gunner != "PRONE") then {
}; };
// Barrel dismount gesture // Barrel dismount gesture
_gunner playActionNow QGVAR(GestureDismountMuzzle); [_gunner, QGVAR(GestureDismountMuzzle)] call EFUNC(common,doGesture);
playSound "ACE_BarrelSwap"; playSound "ACE_BarrelSwap";
private _duration = 3.0; private _duration = 3.0;

View File

@ -23,7 +23,7 @@ TRACE_3("params",_assistant,_gunner,_weapon);
if (_assistant isEqualTo _gunner) then { if (_assistant isEqualTo _gunner) then {
// Barrel mount gesture // Barrel mount gesture
_gunner playAction QGVAR(GestureMountMuzzle); [_gunner, QGVAR(GestureMountMuzzle)] call EFUNC(common,doGesture);
playSound "ACE_BarrelSwap"; playSound "ACE_BarrelSwap";
}; };

View File

@ -14,14 +14,20 @@
* Public: No * Public: No
*/ */
#include "script_component.hpp" #include "script_component.hpp"
private["_unit"];
_unit = _this select 0; params ["_unit"];
GVAR(PFH) = false; GVAR(PFH) = false;
[_unit, "AmovPercMevaSrasWrflDf_AmovPknlMstpSrasWrflDnon", 2] call EFUNC(common,doAnimation); [_unit, "AmovPercMevaSrasWrflDf_AmovPknlMstpSrasWrflDnon", 2] call EFUNC(common,doAnimation);
_unit setVariable [QGVAR(chuteIsCut), false, true]; _unit setVariable [QGVAR(chuteIsCut), false, true];
[{ [{
if (CBA_missionTime >= ((_this select 0) select 0) + 1) then { (_this select 0) params ["_time", "_unit"];
((_this select 0) select 1) playActionNow "Crouch";
[(_this select 1)] call CALLSTACK(CBA_fnc_removePerFrameHandler); if (CBA_missionTime > _time + 1) then {
[_unit, "Crouch"] call EFUNC(common,doGesture);
[_this select 1] call CALLSTACK(CBA_fnc_removePerFrameHandler);
}; };
}, 1, [CBA_missionTime,_unit]] call CALLSTACK(CBA_fnc_addPerFrameHandler); }, 1, [CBA_missionTime, _unit]] call CALLSTACK(CBA_fnc_addPerFrameHandler);

View File

@ -31,7 +31,7 @@ if (count _this > 1) then {
}; };
if (_unit == _target) then { if (_unit == _target) then {
_unit playActionNow "Gear"; [_unit, "Gear"] call EFUNC(common,doGesture);
}; };
[FUNC(displayAmmo), [_target], 1, 0.1] call CBA_fnc_waitAndExecute; [FUNC(displayAmmo), [_target], 1, 0.1] call CBA_fnc_waitAndExecute;

View File

@ -57,7 +57,7 @@ private _onFailure = {
_player addMagazine _magazine; _player addMagazine _magazine;
}; };
_player playActionNow "PutDown"; [_player, "PutDown"] call EFUNC(common,doGesture);
// Remove the magazine with maximum remaining ammo // Remove the magazine with maximum remaining ammo
[_player, _magazineType, _maxAmmo] call EFUNC(common,removeSpecificMagazine); [_player, _magazineType, _maxAmmo] call EFUNC(common,removeSpecificMagazine);

View File

@ -53,6 +53,6 @@ call EFUNC(interaction,hideMouseHint);
[_unit, "DefaultAction", _unit getVariable [QGVAR(Deploy), -1]] call EFUNC(common,removeActionEventHandler); [_unit, "DefaultAction", _unit getVariable [QGVAR(Deploy), -1]] call EFUNC(common,removeActionEventHandler);
// play animation // play animation
_unit playActionNow "PutDown"; [_unit, "PutDown"] call EFUNC(common,doGesture);
_unit setVariable [QGVAR(isDeploying), false, true]; _unit setVariable [QGVAR(isDeploying), false, true];

View File

@ -18,7 +18,7 @@
params ["_unit", "_sandbag"]; params ["_unit", "_sandbag"];
_unit playActionNow "PutDown"; [_unit, "PutDown"] call EFUNC(common,doGesture);
_unit setVariable [QGVAR(isUsingSandbag), true]; _unit setVariable [QGVAR(isUsingSandbag), true];

View File

@ -105,7 +105,7 @@ if ( !([ 0.5*TAG_SIZE, 0.5*TAG_SIZE] call _fnc_isOk) ||
private _vectorDirAndUp = [_surfaceNormal vectorMultiply -1, _v3]; private _vectorDirAndUp = [_surfaceNormal vectorMultiply -1, _v3];
// Everything ok, make the unit create the tag // Everything ok, make the unit create the tag
_unit playActionNow "PutDown"; [_unit, "PutDown"] call EFUNC(common,doGesture);
[{ [{
params ["", "", "", "", "_unit"]; params ["", "", "", "", "_unit"];