From f100d563e0aeae78f723f0a9902142b2b266427a Mon Sep 17 00:00:00 2001 From: Thomas Kooi Date: Mon, 12 Jan 2015 23:28:45 +0100 Subject: [PATCH] Added cse_sys_launchers source - backblast module --- .../sys_launchers/backblast/CfgFunctions.h | 8 + .../cse/sys_launchers/backblast/CfgVehicles.h | 45 ++++++ .../cse/sys_launchers/backblast/CfgWeapons.h | 9 ++ .../backblast/Combat_Space_Enhancement.h | 13 ++ .../cse/sys_launchers/backblast/config.cpp | 25 +++ .../functions/fn_handleBackblast_BB.sqf | 153 ++++++++++++++++++ .../backblast/init_sys_backblast.sqf | 21 +++ .../sys_launchers/backblast/stringtable.xml | 7 + 8 files changed, 281 insertions(+) create mode 100644 TO_MERGE/cse/sys_launchers/backblast/CfgFunctions.h create mode 100644 TO_MERGE/cse/sys_launchers/backblast/CfgVehicles.h create mode 100644 TO_MERGE/cse/sys_launchers/backblast/CfgWeapons.h create mode 100644 TO_MERGE/cse/sys_launchers/backblast/Combat_Space_Enhancement.h create mode 100644 TO_MERGE/cse/sys_launchers/backblast/config.cpp create mode 100644 TO_MERGE/cse/sys_launchers/backblast/functions/fn_handleBackblast_BB.sqf create mode 100644 TO_MERGE/cse/sys_launchers/backblast/init_sys_backblast.sqf create mode 100644 TO_MERGE/cse/sys_launchers/backblast/stringtable.xml diff --git a/TO_MERGE/cse/sys_launchers/backblast/CfgFunctions.h b/TO_MERGE/cse/sys_launchers/backblast/CfgFunctions.h new file mode 100644 index 0000000000..d63428835d --- /dev/null +++ b/TO_MERGE/cse/sys_launchers/backblast/CfgFunctions.h @@ -0,0 +1,8 @@ +class CfgFunctions { + class CSE { + class Backblast { + file = "cse\cse_sys_launchers\backblast\functions"; + class handleBackBlast_BB { recompile = 1; }; + }; + }; +}; \ No newline at end of file diff --git a/TO_MERGE/cse/sys_launchers/backblast/CfgVehicles.h b/TO_MERGE/cse/sys_launchers/backblast/CfgVehicles.h new file mode 100644 index 0000000000..115bcf8b6f --- /dev/null +++ b/TO_MERGE/cse/sys_launchers/backblast/CfgVehicles.h @@ -0,0 +1,45 @@ +class CfgVehicles { + class Logic; + class Module_F: Logic { + class ArgumentsBaseUnits { + }; + }; + class cse_sys_backblast: Module_F { + scope = 2; + displayName = "Backblast [CSE]"; + icon = "\cse\cse_main\data\cse_backblast_module.paa"; + category = "cse_equipment"; + function = "cse_fnc_initalizeModule_F"; + functionPriority = 1; + isGlobal = 1; + isTriggerActivated = 0; + class Arguments { + class inBuilding { + displayName = "Affect Buildings"; + description = "Should backblast be affected by structures"; + typeName = "BOOL"; + }; + class forAI { + displayName = "Enable for AI"; + description = "Should backblast be enabled for AI"; + typeName = "BOOL"; + }; + class damageModifier { + displayName = "Damage modifier"; + description = "Select the aggressiveness of the backblast damage"; + typeName = "NUMBER"; + class values { + class recruit { name = "Recruit"; value = 0.5; }; + class regular { name = "Regular"; value = 1.0; default = 1; }; + class veteran { name = "Veteran"; value = 1.2; }; + class expert { name = "Expert"; value = 1.4; }; + }; + }; + class advanced { + displayName = "Advanced Backblast"; + description = "Should enviroment and walls have an effect on backblast?"; + typeName = "BOOL"; + }; + }; + }; +}; diff --git a/TO_MERGE/cse/sys_launchers/backblast/CfgWeapons.h b/TO_MERGE/cse/sys_launchers/backblast/CfgWeapons.h new file mode 100644 index 0000000000..9194336d8f --- /dev/null +++ b/TO_MERGE/cse/sys_launchers/backblast/CfgWeapons.h @@ -0,0 +1,9 @@ +class CfgWeapons { + class Launcher; + class Launcher_Base_F: Launcher { + cse_backblastAngle = 75; + cse_backblastDamage = 1; + cse_backblast_maxDistance = 5; + cse_backblast_noObjectDistance = 5; + }; +}; \ No newline at end of file diff --git a/TO_MERGE/cse/sys_launchers/backblast/Combat_Space_Enhancement.h b/TO_MERGE/cse/sys_launchers/backblast/Combat_Space_Enhancement.h new file mode 100644 index 0000000000..387fa6b562 --- /dev/null +++ b/TO_MERGE/cse/sys_launchers/backblast/Combat_Space_Enhancement.h @@ -0,0 +1,13 @@ +class Combat_Space_Enhancement { + class cfgModules { + class cse_sys_backblast { + init = "call compile preprocessFile 'cse\cse_sys_launchers\backblast\init_sys_backblast.sqf';"; + name = "Backblast"; + class EventHandlers { + class CAManBase { + FiredNear = "_this call cse_fnc_handleBackBlast_BB;"; + }; + }; + }; + }; +}; \ No newline at end of file diff --git a/TO_MERGE/cse/sys_launchers/backblast/config.cpp b/TO_MERGE/cse/sys_launchers/backblast/config.cpp new file mode 100644 index 0000000000..48ad7fe65e --- /dev/null +++ b/TO_MERGE/cse/sys_launchers/backblast/config.cpp @@ -0,0 +1,25 @@ +class CfgPatches { + class cse_sys_backblast { + units[] = {}; + weapons[] = {}; + requiredVersion = 0.1; + requiredAddons[] = {"cse_f_eh","cse_main"}; + versionDesc = "CSE Backblast"; + version = "0.10.0_rc"; + author[] = {"Combat Space Enhancement"}; + authorUrl = "http://csemod.com"; + }; +}; + +class cse_sys_weaponrest { + class PreloadAddons { + class cse_sys_backblast { + list[] = {"cse_sys_backblast"}; + }; + }; +}; + +#include "CfgVehicles.h" +#include "CfgWeapons.h" +#include "CfgFunctions.h" +#include "Combat_Space_Enhancement.h" \ No newline at end of file diff --git a/TO_MERGE/cse/sys_launchers/backblast/functions/fn_handleBackblast_BB.sqf b/TO_MERGE/cse/sys_launchers/backblast/functions/fn_handleBackblast_BB.sqf new file mode 100644 index 0000000000..68e723075f --- /dev/null +++ b/TO_MERGE/cse/sys_launchers/backblast/functions/fn_handleBackblast_BB.sqf @@ -0,0 +1,153 @@ +/** + * fn_handleBackblast_BB.sqf + * @Descr: N/A + * @Author: Glowbal + * + * @Arguments: [] + * @Return: + * @PublicAPI: false + */ + +private ["_unit","_unitFired","_firedDistance","_weaponFired","_backblastAngle","_backblastRange","_backblastDamage","_direction","_distance","_relativePosition","_relativeDirection","_relativeAzimuth","_relativeInclination","_return","_handle","_percentage","_doDamage", "_weaponDir", "_positionEndLauncher", "_positionBehindMax", "_positionBehindNoObj"]; + +_unit = _this select 0; +if (!local _unit) exitwith {}; +_unitFired = _this select 1; +_firedDistance = _this select 2; +_weaponFired = _this select 3; + +if (!CSE_BACKBLAST_EFFECT_AI_BB && !(IsPlayer _unit)) exitwith {}; +if (vehicle _unit != _unit) exitWith {}; + +_return = false; + +_backblastDamage = getNumber (configFile >> "CfgWeapons" >> _weaponFired >> "cse_backblastDamage"); +if (_backblastDamage == 0) exitwith {}; +if (_unit != _unitFired) then { + _noObjectDistance = getNumber (configFile >> "CfgWeapons" >> _weaponFired >> "cse_backblast_noObjectDistance"); + _backblastDistance = (getNumber (configFile >> "CfgWeapons" >> _weaponFired >> "cse_backblast_maxDistance")); + if ((_noObjectDistance + _backblastDistance) < _firedDistance) exitwith {}; + + _doDamage = _backblastDamage; + if (_firedDistance > _noObjectDistance ) then { + _percentage = (_firedDistance / _backblastDistance); + if (_percentage < 1) then { + _doDamage = _backblastDamage * _percentage; + }; + }; + // _doDamage = _backblastDamage / (_backblastDistance-(_firedDistance^(1/2))); + + _doDamage = _doDamage * CSE_BACKBLAST_DAMAGE_MODIFIER_BB; + + _weaponDir = _unitFired weaponDirection currentWeapon _unitFired; + _positionEndLauncher = ATLtoASL ((_unitFired modelToWorld (_unitFired selectionPosition "RightHand")) vectorAdd (_weaponDir vectorMultiply (0.5))); + _positionBehindNoObj = _positionEndLauncher vectorAdd (_weaponDir vectorMultiply _noObjectDistance); + _positionBehindMax = _positionEndLauncher vectorAdd (_weaponDir vectorMultiply (_noObjectDistance + _backblastDistance)); + + + _direction = direction _unitFired; + + _backblastAngle = getNumber (configFile >> "CfgWeapons" >> _weaponFired >> "cse_backblastAngle"); + if ([position _unitFired,_direction - 180,_backblastAngle / 2,position _unit] call BIS_fnc_inAngleSector) then { + + _line = [_positionEndLauncher, eyePos _unit, _unit, _unitFired]; + if ((!lineIntersects _line) /*&& {!terrainIntersect [_positionEndLauncher, getPosASL _unit]}*/) then { + _return = true; + + if (["cse_sys_medical"] call cse_fnc_isModuleEnabled_F) then { + if (random(1)>0.5) then { + [_unit,"body",(damage _unit + (random(_doDamage))),_unitFired,_weaponFired,"backblast"] spawn cse_fnc_handleDamage_CMS; + }; + if (random(1)>0.5) then { + [_unit,"head",(damage _unit + (random(_doDamage))),_unitFired,_weaponFired,"backblast"] spawn cse_fnc_handleDamage_CMS; + }; + if (random(1)>0.5) then { + [_unit,"legs",(damage _unit + (random(_doDamage))),_unitFired,_weaponFired,"backblast"] spawn cse_fnc_handleDamage_CMS; + }; + if (random(1)>0.5) then { + [_unit,"arms",(damage _unit + (random(_doDamage))),_unitFired,_weaponFired,"backblast"] spawn cse_fnc_handleDamage_CMS; + }; + [_unit, _backblastDamage, 0] call cse_fnc_increasePain_CMS; + + if (random(1)>0.1) then { + [_unit] call cse_fnc_setProne; + [_unit] call cse_fnc_setUnconsciousState; + } else { + [_unit,_doDamage] call cse_fnc_reactionToHit_CMS; + }; + } else { + _unit setDamage (damage _unit + _doDamage) min 0.95; + if (random(1)>0.1) then { + [_unit] call cse_fnc_setProne; + }; + }; + + if (isPlayer _unit) then { + playSound "combat_deafness"; + [_doDamage] call BIS_fnc_bloodEffect; + [_unit,0.5] call BIS_fnc_dirtEffect; + }; + }; + }; +} else { + _noObjectDistance = getNumber (configFile >> "CfgWeapons" >> _weaponFired >> "cse_backblast_noObjectDistance"); + if (CSE_BACKBLAST_AFFECTS_INBUILDING_BB || CSE_BACKBLAST_AFFECTS_ADVANCED_BB) then { + if ([_unitFired] call cse_fnc_isInBuilding || CSE_BACKBLAST_AFFECTS_ADVANCED_BB) then { + private ["_eyePos","_buildingBehind","_obj"]; + _eyePos = eyePos _unit; + _buildingBehind = false; + + _weaponDir = _unitFired weaponDirection currentWeapon _unitFired; + _positionEndLauncher = ATLtoASL ((_unitFired modelToWorld (_unitFired selectionPosition "RightHand")) vectorAdd (_weaponDir vectorMultiply (0.5))); + _positionBehindNoObj = _positionEndLauncher vectorAdd (_weaponDir vectorMultiply _noObjectDistance); + _positionBehindMax = _positionEndLauncher vectorAdd (_weaponDir vectorMultiply (_noObjectDistance + _backblastDistance)); + + + _obj = (lineIntersectsWith [_positionEndLauncher, _positionBehindNoObj, _unit]); + _buildingBehind = ({(_x isKindOf "Building")}count _obj) > 0; + + if (CSE_BACKBLAST_AFFECTS_ADVANCED_BB) then { + if (!_buildingBehind) then { + _buildingBehind = (terrainIntersect [_positionEndLauncher, _positionBehindNoObj]); + }; + }; + + if (_buildingBehind) then { + _return = true; + //_backblastDamage = _backblastDamage * CSE_BACKBLAST_DAMAGE_MODIFIER_BB; + if (["cse_sys_medical"] call cse_fnc_isModuleEnabled_F) then { + if (random(1)>0.5) then { + _handle = [_unit,"body",(damage _unit + (random(_backblastDamage))),_unitFired,_weaponFired,"backblast"] spawn cse_fnc_handleDamage_CMS; + }; + if (random(1)>0.5) then { + _handle = [_unit,"head",(damage _unit + (random(_backblastDamage))),_unitFired,_weaponFired,"backblast"] spawn cse_fnc_handleDamage_CMS; + }; + if (random(1)>0.5) then { + _handle = [_unit,"legs",(damage _unit + (random(_backblastDamage))),_unitFired,_weaponFired,"backblast"] spawn cse_fnc_handleDamage_CMS; + }; + if (random(1)>0.5) then { + _handle = [_unit,"arms",(damage _unit + (random(_backblastDamage))),_unitFired,_weaponFired,"backblast"] spawn cse_fnc_handleDamage_CMS; + }; + [_unit,_backblastDamage,0] call cse_fnc_increasePain_CMS; + + if (random(1)>0.1) then { + [_unit] call cse_fnc_setUnconsciousState; + } else { + [_unit,_backblastDamage] call cse_fnc_reactionToHit_CMS; + }; + } else { + _unit setDamage (damage _unit + 0.2); + if (random(1)>0.1) then { + [_unit] call cse_fnc_setProne; + }; + }; + if (isPlayer _unit) then { + playSound "combat_deafness"; + [_backblastDamage] call BIS_fnc_bloodEffect; + [_unit,0.5] call BIS_fnc_dirtEffect; + }; + }; + }; + }; +}; +_return \ No newline at end of file diff --git a/TO_MERGE/cse/sys_launchers/backblast/init_sys_backblast.sqf b/TO_MERGE/cse/sys_launchers/backblast/init_sys_backblast.sqf new file mode 100644 index 0000000000..4ad04eb716 --- /dev/null +++ b/TO_MERGE/cse/sys_launchers/backblast/init_sys_backblast.sqf @@ -0,0 +1,21 @@ +CSE_BACKBLAST_AFFECTS_INBUILDING_BB = false; +CSE_BACKBLAST_EFFECT_AI_BB = false; +CSE_BACKBLAST_AFFECTS_ADVANCED_BB = false; +CSE_BACKBLAST_DAMAGE_MODIFIER_BB = 0.5; +private ["_args"]; +_args = _this; + +{ + if (_x select 0 == "inBuilding") then { + CSE_BACKBLAST_AFFECTS_INBUILDING_BB = _x select 1; + }; + if (_x select 0 == "forAI") then { + CSE_BACKBLAST_EFFECT_AI_BB = _x select 1; + }; + if (_x select 0 == "damageModifier") then { + CSE_BACKBLAST_DAMAGE_MODIFIER_BB = _x select 1; + }; + if (_x select 0 == "advanced") then { + CSE_BACKBLAST_AFFECTS_ADVANCED_BB = _x select 1; + }; +}foreach _args; \ No newline at end of file diff --git a/TO_MERGE/cse/sys_launchers/backblast/stringtable.xml b/TO_MERGE/cse/sys_launchers/backblast/stringtable.xml new file mode 100644 index 0000000000..a1df2063e2 --- /dev/null +++ b/TO_MERGE/cse/sys_launchers/backblast/stringtable.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file