diff --git a/addons/overpressure/CfgEventHandlers.hpp b/addons/overpressure/CfgEventHandlers.hpp index 439270861b..6f8dba89bd 100644 --- a/addons/overpressure/CfgEventHandlers.hpp +++ b/addons/overpressure/CfgEventHandlers.hpp @@ -14,38 +14,38 @@ class Extended_PostInit_EventHandlers { class Extended_FiredBIS_EventHandlers { class CAManBase { class ADDON { - firedBIS = QUOTE(if (local (_this select 0) && {getNumber (configfile >> 'CfgWeapons' >> _this select 1 >> QUOTE(QGVAR(Damage))) > 0}) then {_this call DFUNC(fireLauncherBackblast)}); + firedBIS = QUOTE(if (local (_this select 0)) then {_this call FUNC(firedEHBB);};); }; }; class Tank { class ADDON { - firedBIS = QUOTE(if (local (_this select 0) && {getNumber (configfile >> 'CfgWeapons' >> _this select 1 >> QUOTE(QGVAR(Damage))) > 0}) then {_this call DFUNC(fireOverpressureZone)}); + firedBIS = QUOTE(if (local (_this select 0)) then {_this call FUNC(firedEHOP);};); }; }; class Car { class ADDON { - firedBIS = QUOTE(if (local (_this select 0) && {getNumber (configfile >> 'CfgWeapons' >> _this select 1 >> QUOTE(QGVAR(Damage))) > 0}) then {_this call DFUNC(fireOverpressureZone)}); + firedBIS = QUOTE(if (local (_this select 0)) then {_this call FUNC(firedEHOP);};); }; }; class Helicopter { class ADDON { - firedBIS = QUOTE(if (local (_this select 0) && {getNumber (configfile >> 'CfgWeapons' >> _this select 1 >> QUOTE(QGVAR(Damage))) > 0}) then {_this call DFUNC(fireOverpressureZone)}); + firedBIS = QUOTE(if (local (_this select 0)) then {_this call FUNC(firedEHOP);};); }; }; class Plane { class ADDON { - firedBIS = QUOTE(if (local (_this select 0) && {getNumber (configfile >> 'CfgWeapons' >> _this select 1 >> QUOTE(QGVAR(Damage))) > 0}) then {_this call DFUNC(fireOverpressureZone)}); + firedBIS = QUOTE(if (local (_this select 0)) then {_this call FUNC(firedEHOP);};); }; }; class Ship_F { class ADDON { - firedBIS = QUOTE(if (local (_this select 0) && {getNumber (configfile >> 'CfgWeapons' >> _this select 1 >> QUOTE(QGVAR(Damage))) > 0}) then {_this call DFUNC(fireOverpressureZone)}); + firedBIS = QUOTE(if (local (_this select 0)) then {_this call FUNC(firedEHOP);};); }; }; class StaticWeapon { class ADDON { - firedBIS = QUOTE(if (local (_this select 0) && {getNumber (configfile >> 'CfgWeapons' >> _this select 1 >> QUOTE(QGVAR(Damage))) > 0}) then {_this call DFUNC(fireOverpressureZone)}); + firedBIS = QUOTE(if (local (_this select 0)) then {_this call FUNC(firedEHOP);};); }; }; }; diff --git a/addons/overpressure/CfgWeapons.hpp b/addons/overpressure/CfgWeapons.hpp index e9170a4b2e..a88fa90894 100644 --- a/addons/overpressure/CfgWeapons.hpp +++ b/addons/overpressure/CfgWeapons.hpp @@ -3,6 +3,7 @@ class CfgWeapons { class LauncherCore; class Launcher: LauncherCore { + GVAR(priority) = 1; GVAR(angle) = 60; GVAR(range) = 10; GVAR(damage) = 0.7; @@ -11,6 +12,7 @@ class CfgWeapons { class Launcher_Base_F: Launcher {}; class launch_Titan_base: Launcher_Base_F { + GVAR(priority) = 1; GVAR(angle) = 40; GVAR(range) = 8; GVAR(damage) = 0.5; @@ -18,6 +20,7 @@ class CfgWeapons { class launch_Titan_short_base: launch_Titan_base { // Titan is a soft-launch launcher + GVAR(priority) = 1; GVAR(angle) = 30; GVAR(range) = 2; GVAR(damage) = 0.5; @@ -25,12 +28,14 @@ class CfgWeapons { class launch_NLAW_F: Launcher_Base_F { // NLAW is a soft-launch launcher + GVAR(priority) = 1; GVAR(angle) = 30; GVAR(range) = 2; GVAR(damage) = 0.6; }; class launch_RPG32_F: Launcher_Base_F { + GVAR(priority) = 1; GVAR(angle) = 60; GVAR(range) = 15; GVAR(damage) = 0.7; @@ -38,12 +43,14 @@ class CfgWeapons { class CannonCore; class cannon_120mm: CannonCore { + GVAR(priority) = 1; GVAR(angle) = 90; GVAR(range) = 50; GVAR(damage) = 0.85; }; class mortar_155mm_AMOS: CannonCore { + GVAR(priority) = 1; GVAR(angle) = 90; GVAR(range) = 60; GVAR(damage) = 1; diff --git a/addons/overpressure/XEH_preInit.sqf b/addons/overpressure/XEH_preInit.sqf index 5eefc5eae4..d0ce7cbcf1 100644 --- a/addons/overpressure/XEH_preInit.sqf +++ b/addons/overpressure/XEH_preInit.sqf @@ -6,5 +6,7 @@ PREP(fireLauncherBackblast); PREP(fireOverpressureZone); PREP(getDistance); PREP(overpressureDamage); - +PREP(cacheOverPressureValues); +PREP(firedEHOP); +PREP(firedEHBB); ADDON = true; diff --git a/addons/overpressure/functions/fnc_cacheOverPressureValues.sqf b/addons/overpressure/functions/fnc_cacheOverPressureValues.sqf new file mode 100644 index 0000000000..0717065c43 --- /dev/null +++ b/addons/overpressure/functions/fnc_cacheOverPressureValues.sqf @@ -0,0 +1,76 @@ +/* + * Author: joko // Jonas + * + * Handle fire of local launchers + * + * Argument: + * 0: Weapon + * 1: Magazine + * 2: Ammo + * + * Return value: + * Array: + * 0: Angle + * 1: Range + * 2: Damage + * + */ + #include "script_component.hpp" + +params ["_weapon", "_ammo", "_magazine"]; +TRACE_3("Parameter",_weapon,_magazine,_ammo); + +private ["_array", "_type", "_return", "_config" /*, "_priority"*/]; + +// get Priority Array from Config +_array = [ + getNumber (configFile >> "CfgWeapons" >> QGVAR(priority)), + getNumber (configFile >> "CfgMagazines" >> QGVAR(priority)), + getNumber (configFile >> "CfgAmmo" >> QGVAR(priority)) +]; + +TRACE_1("Proiroity Array",_array); + +/* for CBA Upadte 2.1 +_priority = _array call CBA_fnc_findMax; +_type = if (isNil "_priority") then { + 0 +} else { + _priority select 1 +}; +*/ + +// obsolete as CBA Update 2.1 start +_array params ["_max"]; + +// set Default type +_type = 0; +// get Highest Entry out the the Priority Array +{ + if (_max < _x) then { + _max = _x; + _type = _forEachIndex; + }; +} forEach _array; +// obsolete end + +TRACE_2("Highest Value",_max,_type); +// create the Config entry Point +_config = [ + (configFile >> "CfgWeapons" >> _weapon), + (configFile >> "CfgMagazines" >> _magazine), + (configFile >> "CfgAmmo" >> _ammo) +] select _type; +TRACE_1("ConfigPath",_config); + +// get the Variables out of the Configes and create a array with then +_return = [ + (getNumber (_config >> QGVAR(angle))), + (getNumber (_config >> QGVAR(range))), + (getNumber (_config >> QGVAR(damage))) +]; +TRACE_1("Return",_return); +_varName = format [QGVAR(values%1%2%3), _weapon, _ammo, _magazine]; +missionNameSpace setVariable [format [QGVAR(values%1%2%3), _weapon, _ammo, _magazine], _return]; + +_return diff --git a/addons/overpressure/functions/fnc_fireLauncherBackblast.sqf b/addons/overpressure/functions/fnc_fireLauncherBackblast.sqf index d5c28cca44..14ffdd2db7 100644 --- a/addons/overpressure/functions/fnc_fireLauncherBackblast.sqf +++ b/addons/overpressure/functions/fnc_fireLauncherBackblast.sqf @@ -3,22 +3,22 @@ * * Handle fire of local launchers * - * Argument: - * 0: Unit that fired (Object) - * 1: Weapon fired (String) - * 2: Muzzle (String) - * 3: Mode (String) - * 4: Ammo (String) - * 5: Magazine (String) - * 6: Projectile (Object) + * Arguments: + * 0: Unit that fired + * 1: Weapon fired + * 2: Muzzle + * 3: Mode + * 4: Ammo + * 5: Magazine + * 6: Projectile * * Return value: * None */ -//#define DEBUG_MODE_FULL + #include "script_component.hpp" -EXPLODE_7_PVT(_this,_firer,_weapon,_muzzle,_mode,_ammo,_magazine,_projectile); +params ["_firer", "_weapon", "_muzzle", "_mode", "_ammo", "_magazine", "_projectile"]; // Prevent AI from causing backblast damage if !([_firer] call EFUNC(common,isPlayer)) exitWith {}; @@ -28,11 +28,16 @@ private ["_position", "_direction"]; _position = getPosASL _projectile; _direction = [0, 0, 0] vectorDiff (vectorDir _projectile); -private ["_backblastAngle", "_backblastRange", "_backblastDamage"]; +private ["_var","_varName","_backblastAngle", "_backblastRange", "_backblastDamage"]; +// Bake variable name and check if the variable exists, call the caching function otherwise +_varName = format [QGVAR(values%1%2%3), _weapon, _ammo, _magazine]; +_var = if (isNil _varName) then { + [_weapon, _ammo, _magazine] call FUNC(cacheOverPressureValues); +} else { + missionNameSpace getVariable _varName; +}; +_var params["_backblastAngle","_backblastRange","_backblastDamage"]; -_backblastAngle = getNumber (configFile >> "CfgWeapons" >> _weapon >> QGVAR(angle)) / 2; -_backblastRange = getNumber (configFile >> "CfgWeapons" >> _weapon >> QGVAR(range)); -_backblastDamage = getNumber (configFile >> "CfgWeapons" >> _weapon >> QGVAR(damage)); // Damage to others private "_affected"; diff --git a/addons/overpressure/functions/fnc_fireOverpressureZone.sqf b/addons/overpressure/functions/fnc_fireOverpressureZone.sqf index 4438e4a859..3068928ba4 100644 --- a/addons/overpressure/functions/fnc_fireOverpressureZone.sqf +++ b/addons/overpressure/functions/fnc_fireOverpressureZone.sqf @@ -3,14 +3,14 @@ * * Handle fire of local vehicle weapons creating overpressure zones * - * Argument: - * 0: Unit that fired (Object) - * 1: Weapon fired (String) - * 2: Muzzle (String) - * 3: Mode (String) - * 4: Ammo (String) - * 5: Magazine (String) - * 6: Projectile (Object) + * Arguments: + * 0: Unit that fired + * 1: Weapon fired + * 2: Muzzle + * 3: Mode + * 4: Ammo + * 5: Magazine + * 6: Projectile * * Return value: * None @@ -18,8 +18,7 @@ //#define DEBUG_MODE_FULL #include "script_component.hpp" -EXPLODE_7_PVT(_this,_firer,_weapon,_muzzle,_mode,_ammo,_magazine,_projectile); - +params ["_firer", "_weapon", "_muzzle", "_mode", "_ammo", "_magazine", "_projectile"]; // Prevent AI from causing overpressure damage if !([gunner _firer] call EFUNC(common,isPlayer)) exitWith {}; //@todo non-maingun turrets? @@ -28,18 +27,23 @@ private ["_position", "_direction"]; _position = getPosASL _projectile; _direction = vectorDir _projectile; -private ["_dangerZoneAngle", "_dangerZoneRange", "_dangerZoneDamage"]; +private ["_var", "_varName", "_dangerZoneAngle", "_dangerZoneRange", "_dangerZoneDamage"]; -_dangerZoneAngle = getNumber (configFile >> "CfgWeapons" >> _weapon >> QGVAR(angle)) / 2; -_dangerZoneRange = getNumber (configFile >> "CfgWeapons" >> _weapon >> QGVAR(range)); -_dangerZoneDamage = getNumber (configFile >> "CfgWeapons" >> _weapon >> QGVAR(damage)); +// Bake variable name and check if the variable exists, call the caching function otherwise +_varName = format [QGVAR(values%1%2%3), _weapon, _ammo, _magazine]; +_var = if (isNil _varName) then { + [_weapon, _ammo, _magazine] call FUNC(cacheOverPressureValues); +} else { + missionNameSpace getVariable _varName; +}; +_var params["_dangerZoneAngle","_dangerZoneRange","_dangerZoneDamage"]; // Damage to others private "_affected"; _affected = getPos _projectile nearEntities ["CAManBase", _dangerZoneRange]; // Let each client handle their own affected units -["overpressure", _affected, [_firer, _position, _direction, _weapon]] call EFUNC(common,targetEvent); +["overpressure", _affected, [_firer, _position, _direction, _weapon, _magazine, _ammo]] call EFUNC(common,targetEvent); // Draw debug lines #ifdef DEBUG_MODE_FULL diff --git a/addons/overpressure/functions/fnc_firedEHBB.sqf b/addons/overpressure/functions/fnc_firedEHBB.sqf new file mode 100644 index 0000000000..cf2ac31561 --- /dev/null +++ b/addons/overpressure/functions/fnc_firedEHBB.sqf @@ -0,0 +1,32 @@ +/* + * Author: joko // Jonas + * + * Handle fire of local launchers + * + * Arguments: + * 0: Unit that fired + * 1: Weapon fired + * 2: Muzzle + * 3: Mode + * 4: Ammo + * 5: Magazine + * 6: Projectile + * + * Return value: + * None + */ +#include "script_component.hpp" +private ["_damage","_varName"]; +params ["", "_weapon", "", "", "_ammo", "_magazine", ""]; + +// Bake variable name and check if the variable exists, call the caching function otherwise +_varName = format [QGVAR(values%1%2%3), _weapon, _ammo, _magazine]; +_damage = if (isNil _varName) then { + ([_weapon, _ammo, _magazine] call FUNC(cacheOverPressureValues)) select 2; +} else { + (missionNameSpace getVariable _varName) select 2; +}; + +if (_damage > 0) then { + _this call DFUNC(fireLauncherBackblast) +}; diff --git a/addons/overpressure/functions/fnc_firedEHOP.sqf b/addons/overpressure/functions/fnc_firedEHOP.sqf new file mode 100644 index 0000000000..6cec770deb --- /dev/null +++ b/addons/overpressure/functions/fnc_firedEHOP.sqf @@ -0,0 +1,32 @@ +/* + * Author: joko // Jonas + * + * Handle fire of Other Weapons + * + * Arguments: + * 0: Unit that fired + * 1: Weapon fired + * 2: Muzzle + * 3: Mode + * 4: Ammo + * 5: Magazine + * 6: Projectile + * + * Return value: + * None + */ +#include "script_component.hpp" +private ["_damage","_varName"]; +params ["", "_weapon", "", "", "_ammo", "_magazine", ""]; + +// Bake variable name and check if the variable exists, call the caching function otherwise +_varName = format [QGVAR(values%1%2%3), _weapon, _ammo, _magazine]; +_damage = if (isNil _varName) then { + ([_weapon, _ammo, _magazine] call FUNC(cacheOverPressureValues)) select 2; +} else { + (missionNameSpace getVariable _varName) select 2; +}; + +if (_damage > 0) then { + _this call DFUNC(fireOverpressureZone) +}; diff --git a/addons/overpressure/functions/fnc_getDistance.sqf b/addons/overpressure/functions/fnc_getDistance.sqf index 905ecbd180..3b3103d951 100644 --- a/addons/overpressure/functions/fnc_getDistance.sqf +++ b/addons/overpressure/functions/fnc_getDistance.sqf @@ -3,13 +3,13 @@ * * Calculate the distance to the first intersection of a line * - * Argument: - * 0: Pos ASL of origin (Array) - * 1: Direction (Array) - * 2: Max distance to search (Number) + * Arguments: + * 0: Pos ASL of origin (ARRAY> + * 1: Direction + * 2: Max distance to search * * Return value: - * Distance to intersection (+- 0.1 m) + * Distance to intersection (+- 0.1 m) */ #include "script_component.hpp" diff --git a/addons/overpressure/functions/fnc_overpressureDamage.sqf b/addons/overpressure/functions/fnc_overpressureDamage.sqf index d1280b682f..a24367937b 100644 --- a/addons/overpressure/functions/fnc_overpressureDamage.sqf +++ b/addons/overpressure/functions/fnc_overpressureDamage.sqf @@ -4,23 +4,29 @@ * Calculate and apply backblast damage to potentially affected local units * * Argument: - * 0: Unit that fired (Object) - * 1: Pos ASL of the projectile (Array) - * 2: Direction of the projectile (Array) - * 3: Weapon fired (String) + * 0: Unit that fired + * 1: Pos ASL of the projectile + * 2: Direction of the projectile + * 3: Weapon fired + * 4: Magazine + * 5: Ammo * * Return value: * None */ #include "script_component.hpp" -EXPLODE_4_PVT(_this,_firer,_posASL,_direction,_weapon); +private ["_var","_overpressureAngle", "_overpressureRange", "_overpressureDamage"]; +params ["_firer", "_posASL", "_direction", "_weapon", "_magazine", "_ammo"]; -private ["_overpressureAngle", "_overpressureRange", "_overpressureDamage"]; - -_overpressureAngle = getNumber (configFile >> "CfgWeapons" >> _weapon >> QGVAR(angle)) / 2; -_overpressureRange = getNumber (configFile >> "CfgWeapons" >> _weapon >> QGVAR(range)); -_overpressureDamage = getNumber (configFile >> "CfgWeapons" >> _weapon >> QGVAR(damage)); +// Bake variable name and check if the variable exists, call the caching function otherwise +_varName = format [QGVAR(values%1%2%3), _weapon, _ammo, _magazine]; +_var = if (isNil _varName) then { + [_weapon, _ammo, _magazine] call FUNC(cacheOverPressureValues); +} else { + missionNameSpace getVariable _varName; +}; +_var params["_overpressureAngle","_overpressureRange","_overpressureDamage"]; TRACE_4("Parameters:",_overpressureAngle,_overpressureRange,_overpressureDamage,_weapon); diff --git a/addons/overpressure/script_component.hpp b/addons/overpressure/script_component.hpp index 3a44df1f9b..fbe7cd1238 100644 --- a/addons/overpressure/script_component.hpp +++ b/addons/overpressure/script_component.hpp @@ -9,4 +9,4 @@ #define DEBUG_SETTINGS DEBUG_ENABLED_OVERPRESSURE #endif -#include "\z\ace\addons\main\script_macros.hpp" \ No newline at end of file +#include "\z\ace\addons\main\script_macros.hpp"