Added cse_sys_launchers source - backblast module

This commit is contained in:
Thomas Kooi 2015-01-12 23:28:45 +01:00
parent 91c77cdb7b
commit f100d563e0
8 changed files with 281 additions and 0 deletions

View File

@ -0,0 +1,8 @@
class CfgFunctions {
class CSE {
class Backblast {
file = "cse\cse_sys_launchers\backblast\functions";
class handleBackBlast_BB { recompile = 1; };
};
};
};

View File

@ -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";
};
};
};
};

View File

@ -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;
};
};

View File

@ -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;";
};
};
};
};
};

View File

@ -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"

View File

@ -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

View File

@ -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;

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8" ?>
<Project name="Combat Space Enhancement">
<Package name="cse_sys_backblast">
<Container ID="Backblast">
</Container>
</Package>
</Project>