From 95ec952acf467017b14747a558a9f550a2772c04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Badano?= Date: Wed, 14 Jan 2015 01:15:58 -0300 Subject: [PATCH] backblast: initial port --- addons/backblast/$PBOPREFIX$ | 1 + addons/backblast/CfgEventHandlers.hpp | 17 ++++ addons/backblast/CfgWeapons.hpp | 44 ++++++++++ addons/backblast/XEH_preInit.sqf | 5 ++ addons/backblast/config.cpp | 87 +++---------------- addons/backblast/functions/fn_getDistance.sqf | 1 + .../functions/fn_launcherBackblast.sqf | 27 +++--- .../backblast/functions/fn_tankDangerZone.sqf | 19 ++-- .../backblast/functions/script_component.hpp | 1 + addons/backblast/script_component.hpp | 12 +++ 10 files changed, 120 insertions(+), 94 deletions(-) create mode 100644 addons/backblast/$PBOPREFIX$ create mode 100644 addons/backblast/CfgEventHandlers.hpp create mode 100644 addons/backblast/CfgWeapons.hpp create mode 100644 addons/backblast/XEH_preInit.sqf create mode 100644 addons/backblast/functions/script_component.hpp create mode 100644 addons/backblast/script_component.hpp diff --git a/addons/backblast/$PBOPREFIX$ b/addons/backblast/$PBOPREFIX$ new file mode 100644 index 0000000000..c5ed230994 --- /dev/null +++ b/addons/backblast/$PBOPREFIX$ @@ -0,0 +1 @@ +z\ace\addons\backblast \ No newline at end of file diff --git a/addons/backblast/CfgEventHandlers.hpp b/addons/backblast/CfgEventHandlers.hpp new file mode 100644 index 0000000000..3b3fb83842 --- /dev/null +++ b/addons/backblast/CfgEventHandlers.hpp @@ -0,0 +1,17 @@ + +class Extended_PreInit_EventHandlers { + class ADDON { + init = QUOTE(call COMPILE_FILE(XEH_preInit) ); + }; +}; + +class Extended_FiredNear_EventHandlers { + class CAManBase { + class GVAR(LauncherBackblast) { + FiredNear = QUOTE( if (local (_this select 0) && {getNumber (configfile >> 'CfgWeapons' >> _this select 3 >> 'AGM_Backblast_Damage') > 0}) then {_this call FUNC(launcherBackblast)} ); + }; + class GVAR(TankDangerZone) { + FiredNear = QUOTE( if (local (_this select 0) && {getNumber (configfile >> 'CfgWeapons' >> _this select 3 >> 'AGM_DangerZone_Damage') > 0}) then {_this call FUNC(tankDangerZone)} ); + }; + }; +}; diff --git a/addons/backblast/CfgWeapons.hpp b/addons/backblast/CfgWeapons.hpp new file mode 100644 index 0000000000..f913ede4a7 --- /dev/null +++ b/addons/backblast/CfgWeapons.hpp @@ -0,0 +1,44 @@ +class CfgWeapons { + + class LauncherCore; + class Launcher: LauncherCore { + AGM_Backblast_Angle = 60; + AGM_Backblast_Range = 10; + AGM_Backblast_Damage = 0.7; + }; + class Launcher_Base_F: Launcher {}; + + class launch_Titan_base: Launcher_Base_F { + AGM_Backblast_Angle = 40; + AGM_Backblast_Range = 8; + AGM_Backblast_Damage = 0.5; + }; + class launch_Titan_short_base: launch_Titan_base { + AGM_Backblast_Angle = 40; + AGM_Backblast_Range = 8; + AGM_Backblast_Damage = 0.5; + }; + + class launch_NLAW_F: Launcher_Base_F { + AGM_Backblast_Angle = 40; + AGM_Backblast_Range = 5; + AGM_Backblast_Damage = 0.6; + }; + class launch_RPG32_F: Launcher_Base_F { + AGM_Backblast_Angle = 60; + AGM_Backblast_Range = 15; + AGM_Backblast_Damage = 0.7; + }; + + class CannonCore; + class cannon_120mm: CannonCore { + AGM_DangerZone_Angle = 90; + AGM_DangerZone_Range = 50; + AGM_DangerZone_Damage = 0.85; + }; + class mortar_155mm_AMOS: CannonCore { + AGM_DangerZone_Angle = 90; + AGM_DangerZone_Range = 60; + AGM_DangerZone_Damage = 1; + }; +}; diff --git a/addons/backblast/XEH_preInit.sqf b/addons/backblast/XEH_preInit.sqf new file mode 100644 index 0000000000..1becf28c05 --- /dev/null +++ b/addons/backblast/XEH_preInit.sqf @@ -0,0 +1,5 @@ +#include "script_component.hpp" + +PREP(getDistance); +PREP(launcherBackblast); +PREP(tankDangerZone); diff --git a/addons/backblast/config.cpp b/addons/backblast/config.cpp index 9bac3035a6..88de936cf9 100644 --- a/addons/backblast/config.cpp +++ b/addons/backblast/config.cpp @@ -1,80 +1,17 @@ +#include "script_component.hpp" + class CfgPatches { - class AGM_Backblast { - units[] = {}; - weapons[] = {}; - requiredVersion = 0.60; - requiredAddons[] = {AGM_Core}; - version = "0.95"; - versionStr = "0.95"; - versionAr[] = {0,95,0}; - author[] = {"commy2", "KoffeinFlummi"}; - authorUrl = "https://github.com/commy2/"; - }; -}; - -class CfgFunctions { - class AGM_Backblast { - class AGM_Backblast { - file = "\AGM_Backblast\functions"; - class getDistance; - class launcherBackblast; - class tankDangerZone; + class ADDON { + units[] = {}; + weapons[] = {}; + requiredVersion = REQUIRED_VERSION; + requiredAddons[] = {"ace_common"}; + author[] = {"commy2", "KoffeinFlummi"}; + authorUrl = "https://github.com/commy2/"; + VERSION_CONFIG; }; - }; }; -class Extended_FiredNear_EventHandlers { - class CAManBase { - class AGM_FiredNear_LauncherBackblast { - FiredNear = "if (local (_this select 0) && {getNumber (configfile >> 'CfgWeapons' >> _this select 3 >> 'AGM_Backblast_Damage') > 0}) then {_this call AGM_Backblast_fnc_launcherBackblast}"; - }; - class AGM_FiredNear_TankDangerZone { - FiredNear = "if (local (_this select 0) && {getNumber (configfile >> 'CfgWeapons' >> _this select 3 >> 'AGM_DangerZone_Damage') > 0}) then {_this call AGM_Backblast_fnc_tankDangerZone}"; - }; - }; -}; +#include "CfgEventHandlers.hpp" -class CfgWeapons { - - class LauncherCore; - class Launcher: LauncherCore { - AGM_Backblast_Angle = 60; - AGM_Backblast_Range = 10; - AGM_Backblast_Damage = 0.7; - }; - class Launcher_Base_F: Launcher {}; - - class launch_Titan_base: Launcher_Base_F { - AGM_Backblast_Angle = 40; - AGM_Backblast_Range = 8; - AGM_Backblast_Damage = 0.5; - }; - class launch_Titan_short_base: launch_Titan_base { - AGM_Backblast_Angle = 40; - AGM_Backblast_Range = 8; - AGM_Backblast_Damage = 0.5; - }; - - class launch_NLAW_F: Launcher_Base_F { - AGM_Backblast_Angle = 40; - AGM_Backblast_Range = 5; - AGM_Backblast_Damage = 0.6; - }; - class launch_RPG32_F: Launcher_Base_F { - AGM_Backblast_Angle = 60; - AGM_Backblast_Range = 15; - AGM_Backblast_Damage = 0.7; - }; - - class CannonCore; - class cannon_120mm: CannonCore { - AGM_DangerZone_Angle = 90; - AGM_DangerZone_Range = 50; - AGM_DangerZone_Damage = 0.85; - }; - class mortar_155mm_AMOS: CannonCore { - AGM_DangerZone_Angle = 90; - AGM_DangerZone_Range = 60; - AGM_DangerZone_Damage = 1; - }; -}; +#include "CfgWeapons.hpp" diff --git a/addons/backblast/functions/fn_getDistance.sqf b/addons/backblast/functions/fn_getDistance.sqf index 41f79a010a..83b290e2b0 100644 --- a/addons/backblast/functions/fn_getDistance.sqf +++ b/addons/backblast/functions/fn_getDistance.sqf @@ -1,4 +1,5 @@ // by commy2 +#include "script_component.hpp" private ["_position", "_direction", "_maxDistance", "_distance", "_iteration", "_laser", "_line"]; diff --git a/addons/backblast/functions/fn_launcherBackblast.sqf b/addons/backblast/functions/fn_launcherBackblast.sqf index c4e8b8b662..079d3dcbf1 100644 --- a/addons/backblast/functions/fn_launcherBackblast.sqf +++ b/addons/backblast/functions/fn_launcherBackblast.sqf @@ -1,21 +1,22 @@ // by commy2 +#include "script_component.hpp" _unit = _this select 0; _firer = _this select 1; _distance = _this select 2; _weapon = _this select 3; -if (vehicle _unit != _unit || {!([_firer] call AGM_Core_fnc_isPlayer)}) exitWith {}; +if (vehicle _unit != _unit || {!([_firer] call EFUNC(common,isPlayer))}) exitWith {}; -_backblastAngle = getNumber (configFile >> "CfgWeapons" >> _weapon >> "AGM_Backblast_Angle") / 2; -_backblastRange = getNumber (configFile >> "CfgWeapons" >> _weapon >> "AGM_Backblast_Range"); -_backblastDamage = getNumber (configFile >> "CfgWeapons" >> _weapon >> "AGM_Backblast_Damage"); +_backblastAngle = getNumber (configFile >> "CfgWeapons" >> _weapon >> "ACE_Backblast_Angle") / 2; +_backblastRange = getNumber (configFile >> "CfgWeapons" >> _weapon >> "ACE_Backblast_Range"); +_backblastDamage = getNumber (configFile >> "CfgWeapons" >> _weapon >> "ACE_Backblast_Damage"); _position = eyePos _firer; _direction = _firer weaponDirection currentWeapon _firer; if (_unit == _firer) then { - _distance = [_position, _direction, _backblastRange] call AGM_Backblast_fnc_getDistance; + _distance = [_position, _direction, _backblastRange] call FUNC(getDistance); if (_distance < _backblastRange) then { _alpha = sqrt (1 - _distance / _backblastRange); @@ -24,11 +25,13 @@ if (_unit == _firer) then { _damage = 2 * _alpha * _beta * _backblastDamage; [_damage * 100] call BIS_fnc_bloodEffect; - if (isClass (configFile >> "CfgPatches" >> "AGM_Medical")) then { - [_unit, "HitBody", ([_unit, "", ((_unit getHitPointDamage "HitBody") + _damage), objNull, objNull] call AGM_Medical_fnc_handleDamage)] call AGM_Medical_fnc_setHitPointDamage; + // TODO: Sort this interaction with medical + if (isClass (configFile >> "CfgPatches" >> "ACE_Medical")) then { + [_unit, "HitBody", ([_unit, "", ((_unit getHitPointDamage "HitBody") + _damage), objNull, objNull] call EFUNC(medical,handleDamage))] call EFUNC(medical,setHitPointDamage); } else { _unit setDamage (damage _unit + _damage); }; + }; } else { _direction = [0, 0, 0] vectorDiff _direction; @@ -52,16 +55,18 @@ if (_unit == _firer) then { _beta = sqrt (1 - _angle / _backblastAngle); _damage = 2 * _alpha * _beta * _backblastDamage; - if (_unit == AGM_player) then {[_damage * 100] call BIS_fnc_bloodEffect}; + if (_unit == ACE_player) then {[_damage * 100] call BIS_fnc_bloodEffect}; - if (isClass (configFile >> "CfgPatches" >> "AGM_Medical")) then { - [_unit, "HitBody", ([_unit, "", ((_unit getHitPointDamage "HitBody") + _damage), objNull, objNull] call AGM_Medical_fnc_handleDamage)] call AGM_Medical_fnc_setHitPointDamage; + // TODO: Sort this interaction with medical + if (isClass (configFile >> "CfgPatches" >> "ACE_Medical")) then { + [_unit, "HitBody", ([_unit, "", ((_unit getHitPointDamage "HitBody") + _damage), objNull, objNull] call EFUNC(medical,handleDamage))] call EFUNC(medical,setHitPointDamage); _unit spawn { sleep 0.5; - [_this, "", 0, objNull, objNull] call AGM_Medical_fnc_handleDamage; + [_this, "", 0, objNull, objNull] call EFUNC(medical,handleDamage); }; } else { _unit setDamage (damage _unit + _damage); }; + }; }; diff --git a/addons/backblast/functions/fn_tankDangerZone.sqf b/addons/backblast/functions/fn_tankDangerZone.sqf index a85fbc4928..0371ec9620 100644 --- a/addons/backblast/functions/fn_tankDangerZone.sqf +++ b/addons/backblast/functions/fn_tankDangerZone.sqf @@ -1,4 +1,5 @@ // by commy2 +#include "script_component.hpp" #define BARREL_MUZZLE "usti hlavne" @@ -7,11 +8,11 @@ _vehicle = vehicle (_this select 1); _distance = _this select 2; _weapon = _this select 3; -if (vehicle _unit != _unit || {!([gunner _firer] call AGM_Core_fnc_isPlayer)}) exitWith {}; +if (vehicle _unit != _unit || {!([gunner _firer] call EFUNC(common,isPlayer))}) exitWith {}; -_dangerZoneAngle = getNumber (configFile >> "CfgWeapons" >> _weapon >> "AGM_DangerZone_Angle") / 2; -_dangerZoneRange = getNumber (configFile >> "CfgWeapons" >> _weapon >> "AGM_DangerZone_Range"); -_dangerZoneDamage = getNumber (configFile >> "CfgWeapons" >> _weapon >> "AGM_DangerZone_Damage"); +_dangerZoneAngle = getNumber (configFile >> "CfgWeapons" >> _weapon >> "ACE_DangerZone_Angle") / 2; +_dangerZoneRange = getNumber (configFile >> "CfgWeapons" >> _weapon >> "ACE_DangerZone_Range"); +_dangerZoneDamage = getNumber (configFile >> "CfgWeapons" >> _weapon >> "ACE_DangerZone_Damage"); _position = ATLToASL (_vehicle modelToWorld (_vehicle selectionPosition BARREL_MUZZLE)); _direction = _vehicle weaponDirection _weapon; @@ -36,16 +37,18 @@ if (_unit != _vehicle) then { _beta = sqrt (1 - _angle / _dangerZoneAngle); _damage = 2 * _alpha * _beta * _dangerZoneDamage; - if (_unit == AGM_player) then {[_damage * 100] call BIS_fnc_bloodEffect}; + if (_unit == ACE_player) then {[_damage * 100] call BIS_fnc_bloodEffect}; - if (isClass (configFile >> "CfgPatches" >> "AGM_Medical")) then { - [_unit, "HitBody", ([_unit, "", ((_unit getHitPointDamage "HitBody") + _damage), objNull, objNull] call AGM_Medical_fnc_handleDamage)] call AGM_Medical_fnc_setHitPointDamage; + // TODO: Sort this interaction with medical + if (isClass (configFile >> "CfgPatches" >> "ACE_Medical")) then { + [_unit, "HitBody", ([_unit, "", ((_unit getHitPointDamage "HitBody") + _damage), objNull, objNull] call EFUNC(medical,handleDamage))] call EFUNC(medical,setHitPointDamage); _unit spawn { sleep 0.5; - [_this, "", 0, objNull, objNull] call AGM_Medical_fnc_handleDamage; + [_this, "", 0, objNull, objNull] call EFUNC(medical,handleDamage); }; } else { _unit setDamage (damage _unit + _damage); }; + }; }; diff --git a/addons/backblast/functions/script_component.hpp b/addons/backblast/functions/script_component.hpp new file mode 100644 index 0000000000..817131570f --- /dev/null +++ b/addons/backblast/functions/script_component.hpp @@ -0,0 +1 @@ +#include "\z\ace\addons\backblast\script_component.hpp" \ No newline at end of file diff --git a/addons/backblast/script_component.hpp b/addons/backblast/script_component.hpp new file mode 100644 index 0000000000..9f2a71f2d5 --- /dev/null +++ b/addons/backblast/script_component.hpp @@ -0,0 +1,12 @@ +#define COMPONENT backblast +#include "\z\ace\Addons\main\script_mod.hpp" + +#ifdef DEBUG_ENABLED_BACKBLAST + #define DEBUG_MODE_FULL +#endif + +#ifdef DEBUG_SETTINGS_BACKBLAST + #define DEBUG_SETTINGS DEBUG_SETTINGS_BACKBLAST +#endif + +#include "\z\ace\Addons\main\script_macros.hpp" \ No newline at end of file