Skip to content

Commit

Permalink
Dragging - Add new dragging animations (#7950)
Browse files Browse the repository at this point in the history
* New custom animation added

* Adjusted CfgMoves and the script components

* New drop animation and key handler

* CBA settings and new ManActions added

* Adjustments to the drop animation

* Added translations and fixed some stuff

* Update CfgMovesBasic.hpp

* Fix translations

Co-authored-by: Elgin675 <elgin675@hotmail.com>
Co-authored-by: Blutze <37950828+Blutze@users.noreply.github.com>

* Use the same key to drop object

* Update addons/dragging/stringtable.xml

Co-authored-by: Jo David <github@jonathandavid.de>

* Fix French translation

Co-authored-by: Elgin675 <elgin675@hotmail.com>

* Lower the weapon accuracy of the drag animations

* Removed auto-switch to handgun

* Update fnc_startDrag.sqf

 - Holding a launcher breaks the firing animation.
 - Now the unit has to hold either a primary weapon or handgun.

* Handle the unit's current weapon

Co-authored-by: BaerMitUmlaut <BaerMitUmlaut@users.noreply.github.com>

* Update addons/dragging/functions/fnc_handlePlayerWeaponChanged.sqf

Co-authored-by: Filip Maciejewski <veteran29@users.noreply.github.com>

* Update addons/dragging/initSettings.sqf

Co-authored-by: Elgin675 <elgin675@hotmail.com>
Co-authored-by: Blutze <37950828+Blutze@users.noreply.github.com>
Co-authored-by: Jo David <github@jonathandavid.de>
Co-authored-by: BaerMitUmlaut <BaerMitUmlaut@users.noreply.github.com>
Co-authored-by: Filip Maciejewski <veteran29@users.noreply.github.com>
Co-authored-by: jonpas <jonpas33@gmail.com>
  • Loading branch information
7 people committed Apr 20, 2021
1 parent f6cefa7 commit af54808
Show file tree
Hide file tree
Showing 13 changed files with 258 additions and 25 deletions.
48 changes: 48 additions & 0 deletions addons/dragging/CfgMovesBasic.hpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,56 @@
class CfgMovesBasic {
class ManActions {
ACE_dragWithPistol = "ace_dragging";
ACE_dragWithRifle = "AmovPercMstpSlowWrflDnon_AcinPknlMwlkSlowWrflDb_2";
};

class Actions {
class MoveWithInjuredManDragger;
class MoveWithInjuredManDraggerRfl: MoveWithInjuredManDragger {
Up = "amovpercmstpsraswrfldnon";
};

class MoveWithInjuredManDraggerPst;
class ACE_MoveWithInjuredManDraggerPst: MoveWithInjuredManDraggerPst {
Default = "ace_dragging_static";
FastB = "ace_dragging";
FastLB = "ace_dragging";
FastRB = "ace_dragging";
grabDrag = "ace_dragging_static";
grabCarry = "Helper_SwitchToCarrynon_pst";
HandGunOn = "ace_dragging_static";
PlayerSlowB = "ace_dragging";
PlayerSlowLB = "ace_dragging";
PlayerSlowRB = "ace_dragging";
PlayerTactB = "AmovPknlMtacSrasWpstDb";
PlayerTactF = "AmovPknlMtacSrasWpstDf";
PlayerTactL = "AmovPknlMtacSrasWpstDl";
PlayerTactLB = "AmovPknlMtacSrasWpstDbl";
PlayerTactLF = "AmovPknlMtacSrasWpstDfl";
PlayerTactR = "AmovPknlMtacSrasWpstDr";
PlayerTactRB = "AmovPknlMtacSrasWpstDbr";
PlayerTactRF = "AmovPknlMtacSrasWpstDfr";
PlayerWalkB = "ace_dragging";
PlayerWalkLB = "ace_dragging";
PlayerWalkRB = "ace_dragging";
released = "ace_dragging_drop";
SlowB = "ace_dragging";
SlowLB = "ace_dragging";
SlowRB = "ace_dragging";
Stop = "ace_dragging_static";
StopRelaxed = "ace_dragging_static";
TactB = "AmovPknlMtacSrasWpstDb";
TactF = "AmovPknlMtacSrasWpstDf";
TactL = "AmovPknlMtacSrasWpstDl";
TactLB = "AmovPknlMtacSrasWpstDbl";
TactLF = "AmovPknlMtacSrasWpstDfl";
TactR = "AmovPknlMtacSrasWpstDr";
TactRB = "AmovPknlMtacSrasWpstDbr";
TactRF = "AmovPknlMtacSrasWpstDfr";
Up = "ace_dragging_static";
WalkB = "ace_dragging";
WalkLB = "ace_dragging";
WalkRB = "ace_dragging";
};
};
};
118 changes: 116 additions & 2 deletions addons/dragging/CfgMovesMaleSdr.hpp
Original file line number Diff line number Diff line change
@@ -1,13 +1,127 @@
class CfgMovesMaleSdr: CfgMovesBasic {
class InjuredMovedBase;
class AgonyBaseRfl;
class InjuredMovedBase;
class AgonyBaseRfl;
class StandBase;
class AmovPercMstpSlowWrflDnon_AcinPknlMwlkSlowWrflDb_1;
class DraggerBase;

class States {
class AcinPknlMstpSnonWnonDnon_AcinPercMrunSnonWnonDnon: InjuredMovedBase {
speed = -10; // 1/10
};

class AinjPfalMstpSnonWrflDnon_carried_Up: AgonyBaseRfl {
speed = -10; // 1/10
};

class AmovPercMstpSrasWpstDnon: StandBase {
ConnectTo[] = {
"AmovPercMstpSrasWpstDnon",
0.02,
"AovrPercMstpSrasWpstDf",
0.025,
"AmovPercMstpSrasWpstDnon_AidlPercMstpSlowWpstDnon",
0.0099999998,
"PistolMagazineReloadStand",
0.1,
"AmovPercMstpSrasWpstDnon_AmovPercMstpSlowWpstDnon",
0.02,
"AmovPercMstpSrasWpstDnon_AmovPercMstpSrasWrflDnon",
0.02,
"AmovPercMstpSrasWpstDnon_AwopPercMstpSoptWbinDnon",
0.02,
"AmovPercMstpSrasWpstDnon_AmovPercMstpSnonWnonDnon",
0.02,
"AmovPercMstpSrasWpstDnon_SaluteIn",
0.02,
"AwopPercMstpSgthWpstDnon_Part1",
0.1,
"AmovPercMstpSrasWpstDnon_AinvPknlMstpSnonWnonDnon",
0.02,
"AmovPercMstpSrasWpstDnon_AmovPercMstpSrasWlnrDnon",
0.02,
"AmovPercMstpSrasWpstDnon_AadjPercMstpSrasWpstDup",
0.02,
"AmovPercMstpSrasWpstDnon_AadjPercMstpSrasWpstDdown",
0.02,
"AmovPercMstpSrasWpstDnon_AadjPercMstpSrasWpstDleft",
0.02,
"AmovPercMstpSrasWpstDnon_AadjPercMstpSrasWpstDright",
0.02,
"AmovPercMstpSrasWpstDnon_AmovPercMstpSrasWpstDnon_gear",
0.02,
"Acts_starterPistol_in",
0.001,
"Acts_PistolRaisedStand_Default",
1,
"ace_dragging",
0.1
};
};

class AmovPercMstpSlowWrflDnon_AcinPknlMwlkSlowWrflDb_2: AmovPercMstpSlowWrflDnon_AcinPknlMwlkSlowWrflDb_1 {
aiming = "aimingDefault";
aimingBody = "aimingUpDefault";
aimPrecision = 5; // default: 1
};

class ace_dragging: DraggerBase {
actions = "ace_MoveWithInjuredManDraggerPst";
aiming = "aimingPistol";
aimingBody = "aimingPistol";
aimPrecision = 2; // default: 1
canPullTrigger = 1;
canReload = 0;
ConnectTo[] = {
"ace_dragging",
0.1,
"ace_dragging_drop",
0.2
};
disableWeapons = 0;
duty = 0.6;
enableBinocular = 0;
file = QPATHTO_T(anim\ace_dragging.rtm);
InterpolateTo[] = {
"ace_dragging_static",
0.1
};
interpolationSpeed = 5;
limitGunMovement = 0.2;
looped = 1;
showHandGun = 1;
turnSpeed = 0.5;
};

class ace_dragging_static: ace_dragging {
ConnectTo[] = {
"ace_dragging",
0.1,
"ace_dragging_drop",
0.2
};
InterpolateTo[] = {
"ace_dragging",
0.1,
"ace_dragging_drop",
0.2
};
looped = 1;
speed = 0;
};

class ace_dragging_drop: ace_dragging {
ConnectTo[] = {
"AmovPknlMstpSrasWpstDnon",
0.1
};
file = QPATHTO_T(anim\ace_dragging_drop.rtm);
InterpolateTo[] = {
"Unconscious",
0.02
};
interpolationSpeed = 5;
looped = 0;
};
};
};
2 changes: 2 additions & 0 deletions addons/dragging/XEH_preInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@ PREP_RECOMPILE_START;
#include "XEH_PREP.hpp"
PREP_RECOMPILE_END;

#include "initSettings.sqf"

ADDON = true;
Binary file added addons/dragging/anim/ace_dragging.rtm
Binary file not shown.
Binary file added addons/dragging/anim/ace_dragging_drop.rtm
Binary file not shown.
2 changes: 1 addition & 1 deletion addons/dragging/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class CfgPatches {
requiredVersion = REQUIRED_VERSION;
requiredAddons[] = {"ace_interaction"};
author = ECSTRING(common,ACETeam);
authors[] = {"Garth 'L-H' de Wet", "commy2", "PiZZADOX"};
authors[] = {"Garth 'L-H' de Wet", "commy2", "PiZZADOX", "Malbryn"};
url = ECSTRING(main,URL);
VERSION_CONFIG;
};
Expand Down
27 changes: 18 additions & 9 deletions addons/dragging/functions/fnc_dragObject.sqf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "script_component.hpp"
/*
* Author: commy2
* Author: commy2, Malbryn
* Drag an object. Called from ace_dragging_fnc_startDrag
*
* Arguments:
Expand Down Expand Up @@ -43,17 +43,26 @@ _unit setVariable [QGVAR(isDragging), true, true];
_unit setVariable [QGVAR(draggedObject), _target, true];

// add drop action
_unit setVariable [QGVAR(ReleaseActionID), [
_unit, "DefaultAction",
{!isNull ((_this select 0) getVariable [QGVAR(draggedObject), objNull])},
{[_this select 0, (_this select 0) getVariable [QGVAR(draggedObject), objNull]] call FUNC(dropObject)}
] call EFUNC(common,addActionEventHandler)];
GVAR(unit) = _unit;

// add anim changed EH
[_unit, "AnimChanged", FUNC(handleAnimChanged), [_unit]] call CBA_fnc_addBISEventHandler;
GVAR(releaseActionID) = [0xF1, [false, false, false], {
[GVAR(unit), GVAR(unit) getVariable [QGVAR(draggedObject), objNull]] call FUNC(dropObject);
}, "keydown", "", false, 0] call CBA_fnc_addKeyHandler;

// show mouse hint
[localize LSTRING(Drop), ""] call EFUNC(interaction,showMouseHint);
["", localize LSTRING(Drop)] call EFUNC(interaction,showMouseHint);

// block firing
if !(GVAR(dragAndFire)) then {
_unit setVariable [QGVAR(blockFire), [
_unit, "DefaultAction",
{true},
{}
] call EFUNC(common,addActionEventHandler)];
};

// add anim changed EH
[_unit, "AnimChanged", FUNC(handleAnimChanged), [_unit]] call CBA_fnc_addBISEventHandler;

// check everything
[FUNC(dragObjectPFH), 0.5, [_unit, _target, CBA_missionTime]] call CBA_fnc_addPerFrameHandler;
Expand Down
9 changes: 7 additions & 2 deletions addons/dragging/functions/fnc_dropObject.sqf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "script_component.hpp"
/*
* Author: commy2
* Author: commy2, Malbryn
* Drop a dragged object.
*
* Arguments:
Expand All @@ -20,7 +20,12 @@ params ["_unit", "_target"];
TRACE_2("params",_unit,_target);

// remove drop action
[_unit, "DefaultAction", _unit getVariable [QGVAR(ReleaseActionID), -1]] call EFUNC(common,removeActionEventHandler);
[QGVAR(releaseActionID), "keydown"] call CBA_fnc_removeKeyHandler;

// stop blocking
if !(GVAR(dragAndFire)) then {
[_unit, "DefaultAction", _unit getVariable [QGVAR(blockFire), -1]] call EFUNC(common,removeActionEventHandler);
};

private _inBuilding = [_unit] call FUNC(isObjectOnObject);

Expand Down
4 changes: 2 additions & 2 deletions addons/dragging/functions/fnc_handlePlayerWeaponChanged.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ TRACE_2("params",_unit,_weapon);

if (_unit getVariable [QGVAR(isDragging), false]) then {

// drop dragged object when selecting a non-primary weapon
if (_weapon != primaryWeapon _unit) then {
// drop dragged object when changing weapon
if (_weapon != _unit getVariable [QGVAR(currentWeapon), ""]) then {
private _draggedObject = _unit getVariable [QGVAR(draggedObject), objNull];

[_unit, _draggedObject] call FUNC(dropObject);
Expand Down
42 changes: 34 additions & 8 deletions addons/dragging/functions/fnc_startDrag.sqf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "script_component.hpp"
/*
* Author: commy2, PiZZADOX
* Author: commy2, PiZZADOX, Malbryn
* Start the dragging process.
*
* Arguments:
Expand Down Expand Up @@ -28,14 +28,34 @@ if (!GETVAR(_target,GVAR(ignoreWeightDrag),false) && {
[localize LSTRING(UnableToDrag)] call EFUNC(common,displayTextStructured);
};

// add a primary weapon if the unit has none.
// @todo prevent opening inventory when equipped with a fake weapon
if (primaryWeapon _unit isEqualto "") then {
_unit addWeapon "ACE_FakePrimaryWeapon";
// Add a primary weapon if the unit has none
if !(GVAR(dragAndFire)) then {
if (primaryWeapon _unit isEqualto "") then {
_unit addWeapon "ACE_FakePrimaryWeapon";
_unit selectWeapon primaryWeapon _unit;
} else {
_unit selectWeapon primaryWeapon _unit;
};
} else { // Making sure the unit is holding a primary weapon or handgun
if !(currentWeapon _unit in [primaryWeapon _unit, handgunWeapon _unit]) then {
if (primaryWeapon _unit != "") then {
// Use primary if possible
_unit selectWeapon primaryWeapon _unit;
} else {
if (handgunWeapon _unit != "") then {
// Use pistol if unit has no primary
_unit selectWeapon handgunWeapon _unit;
} else {
// Add fake weapon if no weapons besides launcher are available
_unit addWeapon "ACE_FakePrimaryWeapon";
_unit selectWeapon primaryWeapon _unit;
};
};
};
};

// select primary, otherwise the drag animation actions don't work.
_unit selectWeapon primaryWeapon _unit;
// Save the weapon so we can monitor if it changes
_unit setVariable [QGVAR(currentWeapon), currentWeapon _unit];

[_unit, "blockThrow", "ACE_dragging", true] call EFUNC(common,statusEffect_set);

Expand All @@ -45,7 +65,13 @@ _unit selectWeapon primaryWeapon _unit;
// can't play action that depends on weapon if it was added the same frame
if !(_unit call EFUNC(common,isSwimming)) then {
[{
[_this, "grabDrag"] call EFUNC(common,doGesture);
private _unitWeapon = _this getVariable [QGVAR(currentWeapon), ""];

if (_unitWeapon isKindOf ["Pistol", configFile >> "CfgWeapons"]) then {
[_this, "ACE_dragWithPistol"] call EFUNC(common,doGesture);
} else {
[_this, "ACE_dragWithRifle"] call EFUNC(common,doGesture);
};
}, _unit] call CBA_fnc_execNextFrame;
};

Expand Down
8 changes: 8 additions & 0 deletions addons/dragging/initSettings.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[
QGVAR(dragAndFire),
"CHECKBOX",
[LSTRING(DragAndFire_DisplayName), LSTRING(DragAndFire_Description)],
localize LSTRING(SettingsName),
true,
false
] call CBA_fnc_addSetting;
2 changes: 1 addition & 1 deletion addons/dragging/script_component.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@

#include "\z\ace\addons\main\script_macros.hpp"

#define DRAG_ANIMATIONS ["amovpercmstpslowwrfldnon_acinpknlmwlkslowwrfldb_2", "amovpercmstpsraswpstdnon_acinpknlmwlksnonwpstdb_2", "amovpercmstpsnonwnondnon_acinpknlmwlksnonwnondb_2", "acinpknlmstpsraswrfldnon", "acinpknlmstpsnonwpstdnon", "acinpknlmstpsnonwnondnon", "acinpknlmwlksraswrfldb", "acinpknlmwlksnonwnondb"]
#define DRAG_ANIMATIONS ["amovpercmstpslowwrfldnon_acinpknlmwlkslowwrfldb_2", "amovpercmstpsraswpstdnon_acinpknlmwlksnonwpstdb_2", "amovpercmstpsnonwnondnon_acinpknlmwlksnonwnondb_2", "acinpknlmstpsraswrfldnon", "acinpknlmstpsnonwpstdnon", "acinpknlmstpsnonwnondnon", "acinpknlmwlksraswrfldb", "acinpknlmwlksnonwnondb", "ace_dragging", "ace_dragging_static", "ace_dragging_drop"]
#define CARRY_ANIMATIONS ["acinpercmstpsnonwnondnon", "acinpknlmstpsnonwnondnon_acinpercmrunsnonwnondnon"]
21 changes: 21 additions & 0 deletions addons/dragging/stringtable.xml
Original file line number Diff line number Diff line change
Expand Up @@ -104,5 +104,26 @@
<Polish>Wyżej/niżej | (Ctrl + Kółko myszy) obracanie</Polish>
<Turkish>Yükselt/Alçalt | (Ctrl + Tekerlek) Döndür</Turkish>
</Key>
<Key ID="STR_ACE_Dragging_SettingsName">
<English>ACE Dragging</English>
<French>ACE Traînage d'objets et d'unités</French>
<German>ACE Ziehen</German>
<Hungarian>ACE Húzás</Hungarian>
<Russian>ACE Перетаскивание</Russian>
</Key>
<Key ID="STR_ACE_Dragging_DragAndFire_DisplayName">
<English>Allow firing while dragging</English>
<French>Arme utilisable durant le traînage</French>
<German>Schießen während des Ziehens erlauben</German>
<Hungarian>Húzás közbeni tüzelés engedélyezése</Hungarian>
<Russian>Стрельба во время перетаскивания</Russian>
</Key>
<Key ID="STR_ACE_Dragging_DragAndFire_Description">
<English>Allow the player to fire their gun while dragging.</English>
<French>Cette option permet aux joueurs de faire usage de leur arme pendant qu'ils traînent un objet ou une unité.\nL'arme secondaire est utilisée si le joueur en est équipé.</French>
<German>Erlaubt dem Spieler während des Ziehens das Abfeuern der Waffe.</German>
<Hungarian>Húzás közben a játékos elsütheti a fegyverét.</Hungarian>
<Russian>Позволяет игроку стрелять во время перетаскивания</Russian>
</Key>
</Package>
</Project>

0 comments on commit af54808

Please sign in to comment.