Skip to content

Commit

Permalink
Recoil code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
johnb432 committed Jul 26, 2024
1 parent b85150e commit a6aad26
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 18 deletions.
2 changes: 1 addition & 1 deletion addons/recoil/$PBOPREFIX$
Original file line number Diff line number Diff line change
@@ -1 +1 @@
z\ace\addons\recoil
z\ace\addons\recoil
1 change: 0 additions & 1 deletion addons/recoil/CfgEventHandlers.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

class Extended_PreStart_EventHandlers {
class ADDON {
init = QUOTE(call COMPILE_SCRIPT(XEH_preStart));
Expand Down
1 change: 0 additions & 1 deletion addons/recoil/CfgMoves.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

// Completely disable BI's camshake on fire.
#define ACE_CAMSHAKEFIRE_BASE 0
#define ACE_CAMSHAKEFIRE_LESS 0
Expand Down
1 change: 0 additions & 1 deletion addons/recoil/CfgRecoils.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

#define KICKBACK 1.4

#define MUZZLETEMP 1.2
Expand Down
1 change: 0 additions & 1 deletion addons/recoil/XEH_PREP.hpp
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@

PREP(camshake);
2 changes: 2 additions & 0 deletions addons/recoil/XEH_preInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@ PREP_RECOMPILE_START;
#include "XEH_PREP.hpp"
PREP_RECOMPILE_END;

GVAR(recoilCache) = createHashMap;

ADDON = true;
25 changes: 12 additions & 13 deletions addons/recoil/functions/fnc_camshake.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* None
*
* Example:
* [player, (currentWeapon player), (currentMuzzle player)] call ace_recoil_fnc_camshake;
* [player, currentWeapon player, currentMuzzle player] call ace_recoil_fnc_camshake
*
* Public: No
*/
Expand All @@ -28,20 +28,19 @@ if (toLowerANSI _weapon in ["throw", "put"]) exitWith {};

private _powerMod = ([0, -0.1, -0.1, 0, -0.2] select (["STAND", "CROUCH", "PRONE", "UNDEFINED", ""] find stance _unit)) + ([0, -1, 0, -1] select (["INTERNAL", "EXTERNAL", "GUNNER", "GROUP"] find cameraView));

// to get camshake read kickback
private _recoil = missionNamespace getVariable format [QGVAR(%1-%2), _weapon, _muzzle];

if (isNil "_recoil") then {
// Get camshake read kickback
private _recoil = GVAR(recoilCache) getOrDefaultCall [_weapon + _muzzle, {
private _config = configFile >> "CfgWeapons" >> _weapon;

if (_muzzle == _weapon) then {
_recoil = getText (_config >> "recoil")
private _recoil = if (_muzzle == _weapon) then {
getText (_config >> "recoil")
} else {
_recoil = getText (_config >> _muzzle >> "recoil")
getText (_config >> _muzzle >> "recoil")
};

if (isClass (configFile >> "CfgRecoils" >> _recoil)) then {
_recoil = getArray (configFile >> "CfgRecoils" >> _recoil >> "kickBack");

if (count _recoil < 2) then {
_recoil = [0, 0];
};
Expand All @@ -51,12 +50,12 @@ if (isNil "_recoil") then {

TRACE_3("Caching Recoil config",_weapon,_muzzle,_recoil);

// parse numbers
_recoil set [0, call compile format ["%1", _recoil select 0]];
_recoil set [1, call compile format ["%1", _recoil select 1]];
// Ensure format is correct
_recoil resize [2, 0];

missionNamespace setVariable [format [QGVAR(%1-%2), _weapon, _muzzle], _recoil];
};
// Parse numbers
_recoil apply {call compile format ["%1", _x]} // return
}, true];

private _powerCoef = RECOIL_COEF * linearConversion [0, 1, random 1, _recoil select 0, _recoil select 1, false];

Expand Down

0 comments on commit a6aad26

Please sign in to comment.