Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Overpressure - Fix backblast originating at projectile #8985

Merged
merged 8 commits into from
Aug 1, 2022
20 changes: 20 additions & 0 deletions addons/overpressure/CfgWeapons.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ class CfgWeapons {
GVAR(angle) = 60;
GVAR(range) = 10;
GVAR(damage) = 0.7;
GVAR(offset) = 1;
};

class Launcher_Base_F: Launcher {};
Expand All @@ -16,6 +17,7 @@ class CfgWeapons {
GVAR(angle) = 40;
GVAR(range) = 8;
GVAR(damage) = 0.5;
GVAR(offset) = 1;
};

class launch_Titan_short_base: launch_Titan_base {
Expand All @@ -24,6 +26,7 @@ class CfgWeapons {
GVAR(angle) = 30;
GVAR(range) = 2;
GVAR(damage) = 0.5;
GVAR(offset) = 0.85;
};

class launch_NLAW_F: Launcher_Base_F {
Expand All @@ -32,13 +35,30 @@ class CfgWeapons {
GVAR(angle) = 30;
GVAR(range) = 2;
GVAR(damage) = 0.6;
GVAR(offset) = 1.05;
};

class launch_RPG32_F: Launcher_Base_F {
GVAR(priority) = 1;
GVAR(angle) = 60;
GVAR(range) = 15;
GVAR(damage) = 0.7;
GVAR(offset) = 1.2;
};

class launch_MRAWS_base_F: Launcher_Base_F {
GVAR(range) = 15;
GVAR(offset) = 1.05;
};

class launch_Vorona_base_F: Launcher_Base_F {
GVAR(angle) = 50;
GVAR(offset) = 0.88;
};

class launch_RPG7_F: Launcher_Base_F {
GVAR(angle) = 40;
GVAR(offset) = 0.9;
};

class CannonCore;
Expand Down
3 changes: 1 addition & 2 deletions addons/overpressure/XEH_PREP.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@

PREP(getDistance);
PREP(overpressureDamage);
PREP(cacheOverPressureValues);
PREP(getOverPressureValues);
PREP(firedEHOP);
PREP(firedEHBB);
2 changes: 2 additions & 0 deletions addons/overpressure/XEH_postInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,6 @@
// Register fire event handler
["ace_firedPlayer", LINKFUNC(firedEHBB)] call CBA_fnc_addEventHandler;
["ace_firedPlayerVehicle", LINKFUNC(firedEHOP)] call CBA_fnc_addEventHandler;

GVAR(cacheHash) = createHashMap;
}] call CBA_fnc_addEventHandler;
16 changes: 6 additions & 10 deletions addons/overpressure/functions/fnc_firedEHBB.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,16 @@
//IGNORE_PRIVATE_WARNING ["_unit", "_weapon", "_muzzle", "_mode", "_ammo", "_magazine", "_projectile", "_vehicle", "_gunner", "_turret"];
TRACE_10("firedEH:",_unit, _weapon, _muzzle, _mode, _ammo, _magazine, _projectile, _vehicle, _gunner, _turret);

// Bake variable name and check if the variable exists, call the caching function otherwise
private _varName = format [QGVAR(values%1%2%3), _weapon, _ammo, _magazine];
private _var = if (isNil _varName) then {
[_weapon, _ammo, _magazine] call FUNC(cacheOverPressureValues);
} else {
missionNameSpace getVariable _varName;
};
_var params ["_backblastAngle","_backblastRange","_backblastDamage"];
TRACE_3("cache",_backblastAngle,_backblastRange,_backblastDamage);
// Retrieve backblast values
private _bbValues = [_weapon, _ammo, _magazine] call FUNC(getOverPressureValues);

_bbValues params ["_backblastAngle", "_backblastRange", "_backblastDamage", "_offset"];
TRACE_4("cache",_backblastAngle,_backblastRange,_backblastDamage,_offset);

if (_backblastDamage <= 0) exitWith {};

private _position = getPosASL _projectile;
private _direction = [0, 0, 0] vectorDiff (vectorDir _projectile);
private _position = ((getPosASL _projectile) vectorAdd (_direction vectorMultiply _offset));

// Damage to others
private _affected = (ASLtoAGL _position) nearEntities ["CAManBase", _backblastRange];
Expand Down
14 changes: 4 additions & 10 deletions addons/overpressure/functions/fnc_firedEHOP.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,14 @@
//IGNORE_PRIVATE_WARNING ["_unit", "_weapon", "_muzzle", "_mode", "_ammo", "_magazine", "_projectile", "_vehicle", "_gunner", "_turret"];
TRACE_10("firedEH:",_unit, _weapon, _muzzle, _mode, _ammo, _magazine, _projectile, _vehicle, _gunner, _turret);

// Bake variable name and check if the variable exists, call the caching function otherwise
private _varName = format [QGVAR(values%1%2%3), _weapon, _ammo, _magazine];
private _var = if (isNil _varName) then {
[_weapon, _ammo, _magazine] call FUNC(cacheOverPressureValues);
} else {
missionNameSpace getVariable _varName;
};
_var params ["_dangerZoneAngle","_dangerZoneRange","_dangerZoneDamage"];
// Retrieve overpressure values
private _opValues = [_weapon, _ammo, _magazine] call FUNC(getOverPressureValues);

_opValues params ["_dangerZoneAngle", "_dangerZoneRange", "_dangerZoneDamage"];
TRACE_3("cache",_dangerZoneAngle,_dangerZoneRange,_dangerZoneDamage);

if (_dangerZoneDamage <= 0) exitWith {};



// The weapon produces overpressure, calculate
private _position = getPosASL _projectile;
private _direction = vectorDir _projectile;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,24 @@
* 0: Angle <Number>
* 1: Range <Number>
* 2: Damage <Number>
* 3: Offset <Number>
*
* Example:
* ["cannon_125mm","Sh_125mm_APFSDS_T_Green","24Rnd_125mm_APFSDS_T_Green"] call ace_overpressure_fnc_cacheOverPressureValues
* ["cannon_125mm","Sh_125mm_APFSDS_T_Green","24Rnd_125mm_APFSDS_T_Green"] call ace_overpressure_fnc_getOverPressureValues
*
* Public: No
*/

params ["_weapon", "_ammo", "_magazine"];
TRACE_3("Parameter",_weapon,_magazine,_ammo);

// Check cache for weapon/ammo/mag combo
private _return = GVAR(cacheHash) get _this;
if (!isNil "_return") exitWith {
TRACE_3("CacheHit",_weapon,_magazine,_ammo);
_return
};

// get Priority Array from Config
private _array = [
getNumber (configFile >> "CfgWeapons" >> _weapon >> QGVAR(priority)),
Expand All @@ -43,15 +51,15 @@ private _config = [
] select _indexOfMaxPriority;
TRACE_1("ConfigPath",_config);

// get the Variables out of the Configes and create a array with then
private _return = [
// get the Variables out of the Configs and populate return array with them
_return = [
(getNumber (_config >> QGVAR(angle))),
(getNumber (_config >> QGVAR(range))) * GVAR(distanceCoefficient),
(getNumber (_config >> QGVAR(damage)))
(getNumber (_config >> QGVAR(damage))),
(getNumber (_config >> QGVAR(offset)))
];

private _varName = format [QGVAR(values%1%2%3), _weapon, _ammo, _magazine];
missionNameSpace setVariable [_varName, _return];
TRACE_2("Return",_varName,_return);
GVAR(cacheHash) set [_this, _return];
TRACE_2("Return",_this,_return);

_return
12 changes: 4 additions & 8 deletions addons/overpressure/functions/fnc_overpressureDamage.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,10 @@

params ["_firer", "_posASL", "_direction", "_weapon", "_magazine", "_ammo"];

// Bake variable name and check if the variable exists, call the caching function otherwise
private _varName = format [QGVAR(values%1%2%3), _weapon, _ammo, _magazine];
private _var = if (isNil _varName) then {
[_weapon, _ammo, _magazine] call FUNC(cacheOverPressureValues);
} else {
missionNameSpace getVariable _varName;
};
_var params ["_overpressureAngle","_overpressureRange","_overpressureDamage"];
// Retrieve overpressure values
private _opValues = [_weapon, _ammo, _magazine] call FUNC(getOverPressureValues);

_opValues params ["_overpressureAngle", "_overpressureRange", "_overpressureDamage"];
TRACE_3("cache",_overpressureAngle,_overpressureRange,_overpressureDamage);

{
Expand Down
1 change: 1 addition & 0 deletions docs/wiki/development/ace3-config-entries.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ ace_recoil_shakemultiplier
ace_overpressure_angle
ace_overpressure_range
ace_overpressure_damage
ace_overpressure_offset
ace_overheating_closedbolt
ace_overheating_dispersion
ace_overheating_slowdownfactor
Expand Down
11 changes: 6 additions & 5 deletions docs/wiki/framework/overpressure-framework.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ version:
```cpp
class CfgWeapons {
class MyLauncher {
ace_overpressure_angle = 60; // Cone in which the damage is applied (in degrees from the back end of the launcher)
ace_overpressure_range = 15; // Range in meters in which the damage is applied
ace_overpressure_angle = 60; // Cone in which the damage is applied (in degrees from the back end of the launcher)
ace_overpressure_range = 15; // Range in meters in which the damage is applied
ace_overpressure_damage = 0.7; // Damage multiplier
ace_overpressure_offset = 1; // Offset from the projectile, where the backblast originates
};
};
```
Expand All @@ -31,9 +32,9 @@ class CfgWeapons {
```cpp
class CfgWeapons {
class MyBananaCannon {
ace_overpressure_angle = 90; // Cone in which the damage is applied (in degrees from the muzzle of the cannon)
ace_overpressure_range = 50; // Range in meters in which the damage is applied
ace_overpressure_damage = 0.85; // Damage multiplier
ace_overpressure_angle = 90; // Cone in which the damage is applied (in degrees from the muzzle of the cannon)
ace_overpressure_range = 50; // Range in meters in which the damage is applied
ace_overpressure_damage = 0.85; // Damage multiplier
};
};
```
Expand Down
25 changes: 24 additions & 1 deletion optionals/compat_rhs_afrf3/CfgWeapons.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,35 @@ class CfgWeapons {
};
};
};

class Launcher;
class Launcher_Base_F: Launcher {
class WeaponSlotsInfo;
};

class rhs_weap_strela;
class rhs_weap_igla: rhs_weap_strela {
EGVAR(overpressure,range) = 6;
EGVAR(overpressure,angle) = 40;
EGVAR(overpressure,damage) = 0.6;
EGVAR(overpressure,offset) = 1.65;
};

class rhs_weap_rpg7: Launcher_Base_F {
ace_reloadlaunchers_enabled = 1;
EGVAR(reloadlaunchers,enabled) = 1;
EGVAR(overpressure,angle) = 40;
EGVAR(overpressure,offset) = 0.9;
};

class rhs_weap_rpg26: Launcher_Base_F {
EGVAR(overpressure,range) = 10;
EGVAR(overpressure,angle) = 50;
EGVAR(overpressure,offset) = 0.65;
};

class rhs_weap_rpg18: rhs_weap_rpg26 {
EGVAR(overpressure,angle) = 45;
EGVAR(overpressure,offset) = 1;
};

#define HEARING_PROTECTION_VICCREW EGVAR(hearing,protection) = 0.85; EGVAR(hearing,lowerVolume) = 0.6;
Expand Down
12 changes: 12 additions & 0 deletions optionals/compat_rhs_gref3/CfgWeapons.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,18 @@ class CfgWeapons {
class Launcher_Base_F: Launcher {
class WeaponSlotsInfo;
};

class rhs_weap_panzerfaust60: Launcher_Base_F {
EGVAR(overpressure,range) = 6;
EGVAR(overpressure,angle) = 30;
EGVAR(overpressure,damage) = 0.4;
};

class rhs_weap_rpg75: Launcher_Base_F {
EGVAR(overpressure,angle) = 40;
EGVAR(overpressure,offset) = 0.9;
};

class GVAR(dshkm_carry): Launcher_Base_F {
class ACE_CSW {
type = "weapon";
Expand Down
9 changes: 9 additions & 0 deletions optionals/compat_rhs_saf3/CfgWeapons.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,13 @@ class CfgWeapons {
class rhssaf_uniform_heli_pilot: Uniform_Base {
ACE_GForceCoef = 0.8;
};

// Launchers
class Launcher_Base_F;
class rhs_weap_m80: Launcher_Base_F {
EGVAR(overpressure,range) = 8;
EGVAR(overpressure,angle) = 40;
EGVAR(overpressure,damage) = 0.7;
EGVAR(overpressure,offset) = 1.15;
};
};
35 changes: 27 additions & 8 deletions optionals/compat_rhs_usf3/CfgWeapons.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ class CfgWeapons {
class Pistol_Base_F;
class Rifle_Base_F;
class rhs_weap_m14ebrri_base;
class launch_O_Titan_F;
class GM6_base_F;
class rhs_weap_M107_Base_F: GM6_base_F {
ACE_barrelTwist = 381.0;
Expand Down Expand Up @@ -309,9 +308,12 @@ class CfgWeapons {
};
};
};

// RHS lauchers
class launch_O_Titan_F;
class rhs_weap_fgm148: launch_O_Titan_F {
ace_javelin_enabled = 1;
EGVAR(javelin,enabled) = 1;
EGVAR(overpressure,offset) = 1.1;
weaponInfoType = "ACE_RscOptics_javelin";
modelOptics = "\z\ace\addons\javelin\data\reticle_titan.p3d";
canLock = 0;
Expand All @@ -326,19 +328,36 @@ class CfgWeapons {
};
};

class rhs_weap_fim92: launch_O_Titan_F {
EGVAR(overpressure,range) = 6;
EGVAR(overpressure,angle) = 40;
EGVAR(overpressure,damage) = 0.6;
EGVAR(overpressure,offset) = 1.45;
};

class Launcher;
class Launcher_Base_F: Launcher {
class WeaponSlotsInfo;
};

class rhs_weap_smaw: Launcher_Base_F {
ace_reloadlaunchers_enabled = 1;
ace_overpressure_angle = 45;
EGVAR(reloadlaunchers,enabled) = 1;
EGVAR(overpressure,angle) = 45;
EGVAR(overpressure,offset) = 1.3;
};

class rhs_weap_maaws: Launcher_Base_F {
ace_reloadlaunchers_enabled = 1;
ace_overpressure_range = 15;
ace_overpressure_angle = 70;
ace_overpressure_damage = 0.75;
EGVAR(reloadlaunchers,enabled) = 1;
EGVAR(overpressure,range) = 15;
EGVAR(overpressure,angle) = 70;
EGVAR(overpressure,damage) = 0.75;
EGVAR(overpressure,offset) = 0.95;
};

class rhs_weap_M136: Launcher_Base_F {
EGVAR(overpressure,range) = 10;
EGVAR(overpressure,angle) = 50;
EGVAR(overpressure,offset) = 0.9;
};

#define HEARING_PROTECTION_OPEN EGVAR(hearing,protection) = 0; EGVAR(hearing,lowerVolume) = 0;
Expand Down