Overpressure - Fix backblast originating at projectile (#8985)

* Overpressure - Fix backblast originating at the projectile

* RHSUSF - Improve backblast for shoulder launchers

* RHSAFRF - Improve backblast for shoulder launchers

* RHSGREF - Improve backblast for shoulder launchers

* RHSSAF - Improve backblast for shoulder launchers

* Overpressure - Simplify projectile offset and cache lookups

* Overpressure - Remove parentheses and use array as hash key

* Overpressure - Rename caching function and move lookup
This commit is contained in:
Whigital 2022-08-01 19:32:02 +02:00 committed by GitHub
parent cd9372a8e1
commit fc17697ef7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 131 additions and 51 deletions

View File

@ -7,6 +7,7 @@ class CfgWeapons {
GVAR(angle) = 60; GVAR(angle) = 60;
GVAR(range) = 10; GVAR(range) = 10;
GVAR(damage) = 0.7; GVAR(damage) = 0.7;
GVAR(offset) = 1;
}; };
class Launcher_Base_F: Launcher {}; class Launcher_Base_F: Launcher {};
@ -16,6 +17,7 @@ class CfgWeapons {
GVAR(angle) = 40; GVAR(angle) = 40;
GVAR(range) = 8; GVAR(range) = 8;
GVAR(damage) = 0.5; GVAR(damage) = 0.5;
GVAR(offset) = 1;
}; };
class launch_Titan_short_base: launch_Titan_base { class launch_Titan_short_base: launch_Titan_base {
@ -24,6 +26,7 @@ class CfgWeapons {
GVAR(angle) = 30; GVAR(angle) = 30;
GVAR(range) = 2; GVAR(range) = 2;
GVAR(damage) = 0.5; GVAR(damage) = 0.5;
GVAR(offset) = 0.85;
}; };
class launch_NLAW_F: Launcher_Base_F { class launch_NLAW_F: Launcher_Base_F {
@ -32,6 +35,7 @@ class CfgWeapons {
GVAR(angle) = 30; GVAR(angle) = 30;
GVAR(range) = 2; GVAR(range) = 2;
GVAR(damage) = 0.6; GVAR(damage) = 0.6;
GVAR(offset) = 1.05;
}; };
class launch_RPG32_F: Launcher_Base_F { class launch_RPG32_F: Launcher_Base_F {
@ -39,6 +43,22 @@ class CfgWeapons {
GVAR(angle) = 60; GVAR(angle) = 60;
GVAR(range) = 15; GVAR(range) = 15;
GVAR(damage) = 0.7; 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; class CannonCore;

View File

@ -1,6 +1,5 @@
PREP(getDistance); PREP(getDistance);
PREP(overpressureDamage); PREP(overpressureDamage);
PREP(cacheOverPressureValues); PREP(getOverPressureValues);
PREP(firedEHOP); PREP(firedEHOP);
PREP(firedEHBB); PREP(firedEHBB);

View File

@ -9,4 +9,6 @@
// Register fire event handler // Register fire event handler
["ace_firedPlayer", LINKFUNC(firedEHBB)] call CBA_fnc_addEventHandler; ["ace_firedPlayer", LINKFUNC(firedEHBB)] call CBA_fnc_addEventHandler;
["ace_firedPlayerVehicle", LINKFUNC(firedEHOP)] call CBA_fnc_addEventHandler; ["ace_firedPlayerVehicle", LINKFUNC(firedEHOP)] call CBA_fnc_addEventHandler;
GVAR(cacheHash) = createHashMap;
}] call CBA_fnc_addEventHandler; }] call CBA_fnc_addEventHandler;

View File

@ -18,20 +18,16 @@
//IGNORE_PRIVATE_WARNING ["_unit", "_weapon", "_muzzle", "_mode", "_ammo", "_magazine", "_projectile", "_vehicle", "_gunner", "_turret"]; //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); 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 // Retrieve backblast values
private _varName = format [QGVAR(values%1%2%3), _weapon, _ammo, _magazine]; private _bbValues = [_weapon, _ammo, _magazine] call FUNC(getOverPressureValues);
private _var = if (isNil _varName) then {
[_weapon, _ammo, _magazine] call FUNC(cacheOverPressureValues); _bbValues params ["_backblastAngle", "_backblastRange", "_backblastDamage", "_offset"];
} else { TRACE_4("cache",_backblastAngle,_backblastRange,_backblastDamage,_offset);
missionNameSpace getVariable _varName;
};
_var params ["_backblastAngle","_backblastRange","_backblastDamage"];
TRACE_3("cache",_backblastAngle,_backblastRange,_backblastDamage);
if (_backblastDamage <= 0) exitWith {}; if (_backblastDamage <= 0) exitWith {};
private _position = getPosASL _projectile;
private _direction = [0, 0, 0] vectorDiff (vectorDir _projectile); private _direction = [0, 0, 0] vectorDiff (vectorDir _projectile);
private _position = ((getPosASL _projectile) vectorAdd (_direction vectorMultiply _offset));
// Damage to others // Damage to others
private _affected = (ASLtoAGL _position) nearEntities ["CAManBase", _backblastRange]; private _affected = (ASLtoAGL _position) nearEntities ["CAManBase", _backblastRange];

View File

@ -18,20 +18,14 @@
//IGNORE_PRIVATE_WARNING ["_unit", "_weapon", "_muzzle", "_mode", "_ammo", "_magazine", "_projectile", "_vehicle", "_gunner", "_turret"]; //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); 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 // Retrieve overpressure values
private _varName = format [QGVAR(values%1%2%3), _weapon, _ammo, _magazine]; private _opValues = [_weapon, _ammo, _magazine] call FUNC(getOverPressureValues);
private _var = if (isNil _varName) then {
[_weapon, _ammo, _magazine] call FUNC(cacheOverPressureValues); _opValues params ["_dangerZoneAngle", "_dangerZoneRange", "_dangerZoneDamage"];
} else {
missionNameSpace getVariable _varName;
};
_var params ["_dangerZoneAngle","_dangerZoneRange","_dangerZoneDamage"];
TRACE_3("cache",_dangerZoneAngle,_dangerZoneRange,_dangerZoneDamage); TRACE_3("cache",_dangerZoneAngle,_dangerZoneRange,_dangerZoneDamage);
if (_dangerZoneDamage <= 0) exitWith {}; if (_dangerZoneDamage <= 0) exitWith {};
// The weapon produces overpressure, calculate // The weapon produces overpressure, calculate
private _position = getPosASL _projectile; private _position = getPosASL _projectile;
private _direction = vectorDir _projectile; private _direction = vectorDir _projectile;

View File

@ -14,9 +14,10 @@
* 0: Angle <Number> * 0: Angle <Number>
* 1: Range <Number> * 1: Range <Number>
* 2: Damage <Number> * 2: Damage <Number>
* 3: Offset <Number>
* *
* Example: * 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 * Public: No
*/ */
@ -24,6 +25,13 @@
params ["_weapon", "_ammo", "_magazine"]; params ["_weapon", "_ammo", "_magazine"];
TRACE_3("Parameter",_weapon,_magazine,_ammo); 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 // get Priority Array from Config
private _array = [ private _array = [
getNumber (configFile >> "CfgWeapons" >> _weapon >> QGVAR(priority)), getNumber (configFile >> "CfgWeapons" >> _weapon >> QGVAR(priority)),
@ -43,15 +51,15 @@ private _config = [
] select _indexOfMaxPriority; ] select _indexOfMaxPriority;
TRACE_1("ConfigPath",_config); TRACE_1("ConfigPath",_config);
// get the Variables out of the Configes and create a array with then // get the Variables out of the Configs and populate return array with them
private _return = [ _return = [
(getNumber (_config >> QGVAR(angle))), (getNumber (_config >> QGVAR(angle))),
(getNumber (_config >> QGVAR(range))) * GVAR(distanceCoefficient), (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]; GVAR(cacheHash) set [_this, _return];
missionNameSpace setVariable [_varName, _return]; TRACE_2("Return",_this,_return);
TRACE_2("Return",_varName,_return);
_return _return

View File

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

View File

@ -49,6 +49,7 @@ ace_recoil_shakemultiplier
ace_overpressure_angle ace_overpressure_angle
ace_overpressure_range ace_overpressure_range
ace_overpressure_damage ace_overpressure_damage
ace_overpressure_offset
ace_overheating_closedbolt ace_overheating_closedbolt
ace_overheating_dispersion ace_overheating_dispersion
ace_overheating_slowdownfactor ace_overheating_slowdownfactor

View File

@ -22,6 +22,7 @@ class CfgWeapons {
ace_overpressure_angle = 60; // Cone in which the damage is applied (in degrees from the back end of the launcher) 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_range = 15; // Range in meters in which the damage is applied
ace_overpressure_damage = 0.7; // Damage multiplier ace_overpressure_damage = 0.7; // Damage multiplier
ace_overpressure_offset = 1; // Offset from the projectile, where the backblast originates
}; };
}; };
``` ```

View File

@ -117,12 +117,35 @@ class CfgWeapons {
}; };
}; };
}; };
class Launcher; class Launcher;
class Launcher_Base_F: Launcher { class Launcher_Base_F: Launcher {
class WeaponSlotsInfo; 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 { 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; #define HEARING_PROTECTION_VICCREW EGVAR(hearing,protection) = 0.85; EGVAR(hearing,lowerVolume) = 0.6;

View File

@ -122,6 +122,18 @@ class CfgWeapons {
class Launcher_Base_F: Launcher { class Launcher_Base_F: Launcher {
class WeaponSlotsInfo; 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 GVAR(dshkm_carry): Launcher_Base_F {
class ACE_CSW { class ACE_CSW {
type = "weapon"; type = "weapon";

View File

@ -71,4 +71,13 @@ class CfgWeapons {
class rhssaf_uniform_heli_pilot: Uniform_Base { class rhssaf_uniform_heli_pilot: Uniform_Base {
ACE_GForceCoef = 0.8; 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;
};
}; };

View File

@ -14,7 +14,6 @@ class CfgWeapons {
class Pistol_Base_F; class Pistol_Base_F;
class Rifle_Base_F; class Rifle_Base_F;
class rhs_weap_m14ebrri_base; class rhs_weap_m14ebrri_base;
class launch_O_Titan_F;
class GM6_base_F; class GM6_base_F;
class rhs_weap_M107_Base_F: GM6_base_F { class rhs_weap_M107_Base_F: GM6_base_F {
ACE_barrelTwist = 381.0; ACE_barrelTwist = 381.0;
@ -309,9 +308,12 @@ class CfgWeapons {
}; };
}; };
}; };
// RHS lauchers // RHS lauchers
class launch_O_Titan_F;
class rhs_weap_fgm148: 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"; weaponInfoType = "ACE_RscOptics_javelin";
modelOptics = "\z\ace\addons\javelin\data\reticle_titan.p3d"; modelOptics = "\z\ace\addons\javelin\data\reticle_titan.p3d";
canLock = 0; canLock = 0;
@ -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;
class Launcher_Base_F: Launcher { class Launcher_Base_F: Launcher {
class WeaponSlotsInfo; class WeaponSlotsInfo;
}; };
class rhs_weap_smaw: Launcher_Base_F { class rhs_weap_smaw: Launcher_Base_F {
ace_reloadlaunchers_enabled = 1; EGVAR(reloadlaunchers,enabled) = 1;
ace_overpressure_angle = 45; EGVAR(overpressure,angle) = 45;
EGVAR(overpressure,offset) = 1.3;
}; };
class rhs_weap_maaws: Launcher_Base_F { class rhs_weap_maaws: Launcher_Base_F {
ace_reloadlaunchers_enabled = 1; EGVAR(reloadlaunchers,enabled) = 1;
ace_overpressure_range = 15; EGVAR(overpressure,range) = 15;
ace_overpressure_angle = 70; EGVAR(overpressure,angle) = 70;
ace_overpressure_damage = 0.75; 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; #define HEARING_PROTECTION_OPEN EGVAR(hearing,protection) = 0; EGVAR(hearing,lowerVolume) = 0;