Skip to content

Commit

Permalink
Add add plate gesture animation (#80)
Browse files Browse the repository at this point in the history
* Add add plate gesture

Special thanks to WebKnight for allowing its usage!

* remove rogue char

* prepare sound, add missing gesture config

* fix first sound playing regardless of letting go of key

* add sounds
  • Loading branch information
diwako authored May 30, 2022
1 parent f19dd61 commit 1c3d763
Show file tree
Hide file tree
Showing 24 changed files with 197 additions and 46 deletions.
40 changes: 40 additions & 0 deletions addons/main/ACE_Medical_Injuries.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
class ACE_Medical_Injuries {
class damageTypes {
class woundHandlers;
class bullet {
class woundHandlers: woundHandlers {
ADDON = QFUNC(aceDamageHandler);
};
};
class grenade {
class woundHandlers: woundHandlers {
ADDON = QFUNC(aceDamageHandler);
};
};
class explosive {
class woundHandlers: woundHandlers {
ADDON = QFUNC(aceDamageHandler);
};
};
class shell {
class woundHandlers: woundHandlers {
ADDON = QFUNC(aceDamageHandler);
};
};
class stab {
class woundHandlers: woundHandlers {
ADDON = QFUNC(aceDamageHandler);
};
};
class punch {
class woundHandlers: woundHandlers {
ADDON = QFUNC(aceDamageHandler);
};
};
class unknown {
class woundHandlers: woundHandlers {
ADDON = QFUNC(aceDamageHandler);
};
};
};
};
93 changes: 93 additions & 0 deletions addons/main/CfgGesturesMale.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
class CfgMovesBasic {
class ManActions {
GVAR(addPlate_base)= QGVAR(addPlate_base);
GVAR(addPlate_2)= QGVAR(addPlate_2);
GVAR(addPlate_3)= QGVAR(addPlate_3);
GVAR(addPlate_4)= QGVAR(addPlate_4);
GVAR(addPlate_5)= QGVAR(addPlate_5);
GVAR(addPlate_6)= QGVAR(addPlate_6);
GVAR(addPlate_7)= QGVAR(addPlate_7);
GVAR(addPlate_8)= QGVAR(addPlate_8);
GVAR(addPlate_9)= QGVAR(addPlate_9);
GVAR(addPlate_10)= QGVAR(addPlate_10);
GVAR(addPlate_11)= QGVAR(addPlate_11);
GVAR(addPlate_12)= QGVAR(addPlate_12);
GVAR(addPlate_13)= QGVAR(addPlate_13);
GVAR(addPlate_14)= QGVAR(addPlate_14);
GVAR(addPlate_15)= QGVAR(addPlate_15);
GVAR(addPlate_16)= QGVAR(addPlate_16);
GVAR(stopGesture) = QGVAR(stopGesture);
};
class Actions {
class Default;
class NoActions: ManActions {
GVAR(addPlate_base)[]= {QGVAR(addPlate_base), "Gesture"};
GVAR(addPlate_2)[]= {QGVAR(addPlate_2), "Gesture"};
GVAR(addPlate_3)[]= {QGVAR(addPlate_3), "Gesture"};
GVAR(addPlate_4)[]= {QGVAR(addPlate_4), "Gesture"};
GVAR(addPlate_5)[]= {QGVAR(addPlate_5), "Gesture"};
GVAR(addPlate_6)[]= {QGVAR(addPlate_6), "Gesture"};
GVAR(addPlate_7)[]= {QGVAR(addPlate_7), "Gesture"};
GVAR(addPlate_8)[]= {QGVAR(addPlate_8), "Gesture"};
GVAR(addPlate_9)[]= {QGVAR(addPlate_9), "Gesture"};
GVAR(addPlate_10)[]= {QGVAR(addPlate_10), "Gesture"};
GVAR(addPlate_11)[]= {QGVAR(addPlate_11), "Gesture"};
GVAR(addPlate_12)[]= {QGVAR(addPlate_12), "Gesture"};
GVAR(addPlate_13)[]= {QGVAR(addPlate_13), "Gesture"};
GVAR(addPlate_14)[]= {QGVAR(addPlate_14), "Gesture"};
GVAR(addPlate_15)[]= {QGVAR(addPlate_15), "Gesture"};
GVAR(addPlate_16)[]= {QGVAR(addPlate_16), "Gesture"};
GVAR(stopGesture)[] = {QGVAR(stopGesture), "Gesture"};
};
};
};

#define ADDPLATE(SECONDS) \
class TRIPLES(ADDON,addPlate,SECONDS): GVAR(addPlate_base) { \
speed = QUOTE(-SECONDS + 0.5); \
}

class CfgGesturesMale {
class Default;
class States {
class GVAR(addPlate_base): Default {
speed = 0;
looped = 0;
file = QPATHTOF(anims\add_plate.rtm);
mask = "handsWeapon";
headBobStrength = -1;
headBobMode = 4;
disableWeapons = 1;
interpolationRestart = 2;
leftHandIKCurve[] = {0.01,1,0.1,0,0.94,0,0.98,1};
rightHandIKBeg = 1;
leftHandIKEnd = 1;
rightHandIKCurve[] = {1};
weaponIK = 1;
canReload = 0;
};
ADDPLATE(2);
ADDPLATE(3);
ADDPLATE(4);
ADDPLATE(5);
ADDPLATE(6);
ADDPLATE(7);
ADDPLATE(8);
ADDPLATE(9);
ADDPLATE(10);
ADDPLATE(11);
ADDPLATE(12);
ADDPLATE(13);
ADDPLATE(14);
ADDPLATE(15);
ADDPLATE(16);
class GestureNod;
class GVAR(stopGesture): GestureNod {
file = "a3\anims_f\data\anim\sdr\gst\gestureEmpty.rtm";
disableWeapons = 0;
disableWeaponsLong = 0;
enableOptics = 1;
mask = "empty";
};
};
};
1 change: 1 addition & 0 deletions addons/main/XEH_PREP.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ PREP(canAddPlate);
PREP(canPressKey);
PREP(createProgressBar);
PREP(deleteProgressBar);
PREP(doGesture);
PREP(fillVestWithPlates);
PREP(handleArmorDamage);
PREP(initAIUnit);
Expand Down
3 changes: 3 additions & 0 deletions addons/main/XEH_postInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -457,12 +457,15 @@ if (_aceInteractLoaded) then {
"\a3\ui_f\data\gui\rsc\rscdisplayarsenal\vest_ca.paa", {
params ["", "_player"];
GVAR(addingPlate) = true;
[_player] call FUNC(doGesture);
[GVAR(timeToAddPlate), [_player], {
param [0] params ["_player"];
[_player] call FUNC(addPlate);
GVAR(addingPlate) = false;
}, {
param [0] params ["_player"];
GVAR(addingPlate) = false;
[_player, false] call FUNC(doGesture);
}, LLSTRING(addPlateToVest), {
param [0] params ["_player"];
(stance _player) != "PRONE" && {
Expand Down
Binary file added addons/main/anims/add_plate.rtm
Binary file not shown.
43 changes: 2 additions & 41 deletions addons/main/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,44 +21,5 @@ class CfgPatches {
#include "CfgVehicles.hpp"
#include "CfgWeapons.hpp"
#include "CfgFunctions.hpp"

class ACE_Medical_Injuries {
class damageTypes {
class woundHandlers;
class bullet {
class woundHandlers: woundHandlers {
ADDON = QFUNC(aceDamageHandler);
};
};
class grenade {
class woundHandlers: woundHandlers {
ADDON = QFUNC(aceDamageHandler);
};
};
class explosive {
class woundHandlers: woundHandlers {
ADDON = QFUNC(aceDamageHandler);
};
};
class shell {
class woundHandlers: woundHandlers {
ADDON = QFUNC(aceDamageHandler);
};
};
class stab {
class woundHandlers: woundHandlers {
ADDON = QFUNC(aceDamageHandler);
};
};
class punch {
class woundHandlers: woundHandlers {
ADDON = QFUNC(aceDamageHandler);
};
};
class unknown {
class woundHandlers: woundHandlers {
ADDON = QFUNC(aceDamageHandler);
};
};
};
};
#include "CfgGesturesMale.hpp"
#include "ACE_Medical_Injuries.hpp"
14 changes: 11 additions & 3 deletions addons/main/functions/fnc_aceDamageHandler.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,16 @@ private _copy = +_allDamages;

if ((_copy select 0 select 0) > 0) then {
(_copy select 0) params ["_damage", "_bodyPart"];
if (_damage isEqualTo 0 || {_bodyPart == "#structural"}) then {continue};
private _parentShooter = _shooter;
if (GVAR(disallowFriendfire) &&
{!isNull _parentShooter && {
_parentShooter isNotEqualTo _unit && {
(side group _unit) isEqualTo (side group _parentShooter)}}}) exitWith {
_copy = [];
};
if (_damage isEqualTo 0 || {_bodyPart == "#structural"}) exitWith {};
private _isTorso = _bodyPart isEqualTo "Body";
if (GVAR(protectOnlyTorso) && {!_isTorso}) then {continue};
if (GVAR(protectOnlyTorso) && {!_isTorso}) exitWith {};

// _aceSelection is HitBody, HitLegs etc
private _aceSelection = format ["Hit%1", _bodyPart];
Expand All @@ -23,9 +30,10 @@ if ((_copy select 0 select 0) > 0) then {
};

// _shooter and _ammo exist in the scope above
private _damageLeft = [_unit, _damage, _actualDamage, _shooter, _ammo, _isTorso] call FUNC(receiveDamageACE);
private _damageLeft = [_unit, _damage, _actualDamage, _parentShooter, _ammo, _isTorso] call FUNC(receiveDamageACE);
(_copy select 0) set [0, _damageLeft];
};

// if you want to do nothing, just exitWith {_this}. if you return nil or [] it will block further handling
if (_copy isEqualTo []) exitWith {[]};
[_unit, _copy, _typeOfDamage] //return
2 changes: 2 additions & 0 deletions addons/main/functions/fnc_addPlateKeyPress.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ _player setVariable [QGVAR(wasSprintingAllowed), isSprintAllowed _player];
_player allowSprint false;
_player setVariable [QGVAR(wasForceWalked), isForcedWalk _player];
_player forceWalk true;
[_player] call FUNC(doGesture);

[{
params ["_player", "_ctrl"];
Expand All @@ -21,6 +22,7 @@ _player forceWalk true;
_player allowSprint (_player getVariable [QGVAR(wasSprintingAllowed), true]);
_player forceWalk (_player getVariable [QGVAR(wasForceWalked), true]);
call FUNC(deleteProgressBar);
[_player, false] call FUNC(doGesture);

if (GVAR(addPlateKeyUp) || {
(stance _player) == "PRONE" || {
Expand Down
42 changes: 42 additions & 0 deletions addons/main/functions/fnc_doGesture.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#include "script_component.hpp"
params ["_player", ["_add", true]];

// easier editing when adding new gesture speeds
#define MIN 2
#define MAX 16

// prevent gesture eating your current mag when reloading
if (missionNamespace getVariable ["ace_common_isReloading", false]) exitWith {};
if (_add) then {
private _seconds = (floor GVAR(timeToAddPlate)) min MAX;
if (_seconds < MIN) exitWith {};
_player playActionNow (format [QGVAR(addPlate_%1), _seconds]);

// prevent button spam for sound
_player setVariable [QGVAR(gestureStart), cba_missionTime];
if ((_player getVariable [QGVAR(nextGestureSound), -1]) < cba_missionTime) then {
_player setVariable [QGVAR(nextGestureSound), cba_missionTime + (_seconds * 0.15) + 1];
[{
params ["_player", "_gestureTime"];
if ((_player getVariable [QGVAR(gestureStart), -1]) isNotEqualTo _gestureTime) exitWith {};
playSound3D [format [QPATHTO_R(sounds\platesOpen%1.ogg), floor random 4], _player, false, getPosASL _player, 0.75, 1, 7];
}, [_player, cba_missionTime], _seconds * 0.15] call CBA_fnc_waitAndExecute;
};

if (_seconds > 3) then {
[{
params ["_player", "_gestureTime"];
if ((_player getVariable [QGVAR(gestureStart), -1]) isNotEqualTo _gestureTime) exitWith {};
playSound3D [format [QPATHTO_R(sounds\platesMid%1.ogg), floor random 4], _player, false, getPosASL _player, 1, 1, 7];
}, [_player, cba_missionTime], _seconds * 0.55] call CBA_fnc_waitAndExecute;
};

[{
params ["_player", "_gestureTime"];
if ((_player getVariable [QGVAR(gestureStart), -1]) isNotEqualTo _gestureTime) exitWith {};
playSound3D [format [QPATHTO_R(sounds\platesClose%1.ogg), floor random 4], _player, false, getPosASL _player, 0.75, 1, 7];
}, [_player, cba_missionTime], _seconds * 0.75] call CBA_fnc_waitAndExecute;
} else {
_player playActionNow QGVAR(stopGesture);
_player setVariable [QGVAR(gestureStart), nil];
};
3 changes: 1 addition & 2 deletions addons/main/script_mod.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@
#define VERSION_AR MAJOR,MINOR,PATCHLVL,BUILD
#define VERSION_PLUGIN MAJOR.MINOR.PATCHLVL.BUILD

#define REQUIRED_VERSION 2.04
#define REQUIRED_VERSION 2.08

#ifdef COMPONENT_BEAUTIFIED
#define COMPONENT_NAME QUOTE(Armor Plates System - COMPONENT_BEAUTIFIED)
#else
#define COMPONENT_NAME QUOTE(Armor Plates System - COMPONENT)
#endif

Binary file added addons/main/sounds/platesClose0.ogg
Binary file not shown.
Binary file added addons/main/sounds/platesClose1.ogg
Binary file not shown.
Binary file added addons/main/sounds/platesClose2.ogg
Binary file not shown.
Binary file added addons/main/sounds/platesClose3.ogg
Binary file not shown.
Binary file added addons/main/sounds/platesMid0.ogg
Binary file not shown.
Binary file added addons/main/sounds/platesMid1.ogg
Binary file not shown.
Binary file added addons/main/sounds/platesMid2.ogg
Binary file not shown.
Binary file added addons/main/sounds/platesMid3.ogg
Binary file not shown.
Binary file added addons/main/sounds/platesOpen0.ogg
Binary file not shown.
Binary file added addons/main/sounds/platesOpen1.ogg
Binary file not shown.
Binary file added addons/main/sounds/platesOpen2.ogg
Binary file not shown.
Binary file added addons/main/sounds/platesOpen3.ogg
Binary file not shown.
1 change: 1 addition & 0 deletions authors.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ Contributors:
audiocustoms
Alacrritas
Alien314
WebKnight
1 change: 1 addition & 0 deletions hemtt.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ files = [
"*.paa",
"LICENSE",
"readme.txt",
"authors.txt",
"readme.md"
]
include = ["./include"]
Expand Down

0 comments on commit 1c3d763

Please sign in to comment.