mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Added cse_sys_combatdeaf source
This commit is contained in:
parent
2c276ecf50
commit
abf2e534c8
18
TO_MERGE/cse/sys_combatdeaf/CfgFunctions.h
Normal file
18
TO_MERGE/cse/sys_combatdeaf/CfgFunctions.h
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
class CfgFunctions {
|
||||||
|
class CSE {
|
||||||
|
class combatdeaf {
|
||||||
|
file = "cse\cse_sys_combatdeaf\functions";
|
||||||
|
class handleFiredNear_DEAF { recompile = 1; };
|
||||||
|
class handleFired_DEAF { recompile = 1; };
|
||||||
|
class getAttenuation_DEAF { recompile = 1; };
|
||||||
|
class applyEletronicEarProtection_DEAF { recompile = 1; };
|
||||||
|
class explosion_DEAF { recompile = 1; };
|
||||||
|
class handlePressureWave_DEAF { recompile = 1; };
|
||||||
|
class getIn_DEAF { recompile = 1; };
|
||||||
|
class getOut_DEAF { recompile = 1; };
|
||||||
|
class register_ear_protection_actions_DEAF { recompile = 1; };
|
||||||
|
class getMuzzleAccessory_DEAF { recompile = 1; };
|
||||||
|
class hasMuzzleAccessory_DEAF { recompile = 1; };
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
9
TO_MERGE/cse/sys_combatdeaf/CfgSounds.h
Normal file
9
TO_MERGE/cse/sys_combatdeaf/CfgSounds.h
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
class CfgSounds
|
||||||
|
{
|
||||||
|
class cse_combatdeaf_ear_ringing
|
||||||
|
{
|
||||||
|
name="cse_combatdeaf_ear_ringing";
|
||||||
|
sound[]={"\cse\cse_sys_combatdeaf\sound\ear_ringing.ogg",1,1};
|
||||||
|
titles[]={};
|
||||||
|
};
|
||||||
|
};
|
85
TO_MERGE/cse/sys_combatdeaf/CfgVehicles.h
Normal file
85
TO_MERGE/cse/sys_combatdeaf/CfgVehicles.h
Normal file
@ -0,0 +1,85 @@
|
|||||||
|
class CfgVehicles {
|
||||||
|
class Logic;
|
||||||
|
class Module_F: Logic {
|
||||||
|
class ArgumentsBaseUnits {
|
||||||
|
};
|
||||||
|
};
|
||||||
|
class cse_sys_combatdeaf: Module_F {
|
||||||
|
scope = 2;
|
||||||
|
displayName = "Combat Deafness [CSE]";
|
||||||
|
icon = "\cse\cse_main\data\cse_earmuffs_module.paa";
|
||||||
|
category = "cseModules";
|
||||||
|
function = "cse_fnc_initalizeModule_F";
|
||||||
|
functionPriority = 1;
|
||||||
|
isGlobal = 1;
|
||||||
|
isTriggerActivated = 0;
|
||||||
|
class Arguments {
|
||||||
|
class DEAFNESS_EFFECT_INTENSITY {
|
||||||
|
displayName = "Deafness effect intensity";
|
||||||
|
description = "Allows to tune down the deafness effect (2.0 - dual intensity, 1.0 - default intensity, 0.5 - half intensity)";
|
||||||
|
typeName = "NUMBER";
|
||||||
|
defaultValue = 1;
|
||||||
|
};
|
||||||
|
class DISABLE_EAR_RINGING {
|
||||||
|
displayName = "Disable ear ringing";
|
||||||
|
description = "Disables the ear ringing effect";
|
||||||
|
typeName = "BOOL";
|
||||||
|
defaultValue = 0;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
class ModuleDescription {
|
||||||
|
description = "Combat deafness";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
class Item_Base_F;
|
||||||
|
class cse_earplugsItem: Item_Base_F
|
||||||
|
{
|
||||||
|
scope = 2;
|
||||||
|
scopeCurator = 2;
|
||||||
|
displayName = "Earplugs";
|
||||||
|
author = "Combat Space Enhancement";
|
||||||
|
vehicleClass = "Items";
|
||||||
|
class TransportItems
|
||||||
|
{
|
||||||
|
class cse_earplugs
|
||||||
|
{
|
||||||
|
name = "cse_earplugs";
|
||||||
|
count = 1;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
class cse_earplugs_electronicItem: cse_earplugsItem
|
||||||
|
{
|
||||||
|
class TransportItems
|
||||||
|
{
|
||||||
|
class cse_earplugs_electronic
|
||||||
|
{
|
||||||
|
name = "cse_earplugs_electronic";
|
||||||
|
count = 1;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
class NATO_Box_Base;
|
||||||
|
class cse_crateCombatDeafness: NATO_Box_Base
|
||||||
|
{
|
||||||
|
scope = 2;
|
||||||
|
displayName = "Earplugs Crate [CSE]";
|
||||||
|
author = "Combat Space Enhancement";
|
||||||
|
model = "\A3\weapons_F\AmmoBoxes\AmmoBox_F";
|
||||||
|
class TransportWeapons
|
||||||
|
{
|
||||||
|
class _xx_cse_earplugs
|
||||||
|
{
|
||||||
|
weapon="cse_earplugs";
|
||||||
|
count=50;
|
||||||
|
};
|
||||||
|
class _xx_cse_earplugs_electronic
|
||||||
|
{
|
||||||
|
weapon="cse_earplugs_electronic";
|
||||||
|
count=10;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
27
TO_MERGE/cse/sys_combatdeaf/CfgWeapons.h
Normal file
27
TO_MERGE/cse/sys_combatdeaf/CfgWeapons.h
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
class CfgWeapons {
|
||||||
|
class ItemCore;
|
||||||
|
class InventoryItem_Base_F;
|
||||||
|
class cse_earplugs: ItemCore
|
||||||
|
{
|
||||||
|
scope=2;
|
||||||
|
value = 1;
|
||||||
|
count = 1;
|
||||||
|
type = 16;
|
||||||
|
displayName="Earplugs";
|
||||||
|
model="\cse\cse_sys_combatdeaf\equipment\earplugs_simple.p3d";
|
||||||
|
picture="\cse\cse_sys_combatdeaf\equipment\icons\earplugs_simple_icon.paa";
|
||||||
|
descriptionShort="Earplugs";
|
||||||
|
class ItemInfo: InventoryItem_Base_F
|
||||||
|
{
|
||||||
|
mass=0.01;
|
||||||
|
type=201;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
class cse_earplugs_electronic: cse_earplugs
|
||||||
|
{
|
||||||
|
displayName="Electronic earplugs";
|
||||||
|
model="\cse\cse_sys_combatdeaf\equipment\earplugs_electronic.p3d";
|
||||||
|
picture="\cse\cse_sys_combatdeaf\equipment\icons\earplugs_electronic_icon.paa";
|
||||||
|
descriptionShort="Eletronic earplugs";
|
||||||
|
};
|
||||||
|
};
|
14
TO_MERGE/cse/sys_combatdeaf/Combat_Space_Enhancement.h
Normal file
14
TO_MERGE/cse/sys_combatdeaf/Combat_Space_Enhancement.h
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
class Combat_Space_Enhancement {
|
||||||
|
class CfgModules {
|
||||||
|
class cse_sys_combatdeaf {
|
||||||
|
init = "call compile preprocessFile 'cse\cse_sys_combatdeaf\init_sys_combatdeaf.sqf';";
|
||||||
|
name = "Combat Deafness";
|
||||||
|
class EventHandlers {
|
||||||
|
class AllVehicles {
|
||||||
|
GetIn = "call cse_fnc_getIn_DEAF; false";
|
||||||
|
GetOut = "call cse_fnc_getOut_DEAF; false";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
26
TO_MERGE/cse/sys_combatdeaf/config.cpp
Normal file
26
TO_MERGE/cse/sys_combatdeaf/config.cpp
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
class CfgPatches {
|
||||||
|
class cse_sys_combatdeaf {
|
||||||
|
units[] = {"cse_crateCombatDeafness", "cse_earplugsItem", "cse_earplugs_electronicItem"};
|
||||||
|
weapons[] = {};
|
||||||
|
requiredVersion = 1.0;
|
||||||
|
requiredAddons[] = {"cse_f_eh","cse_main"};
|
||||||
|
versionDesc = "CSE Combat Deafness";
|
||||||
|
version = "0.10.0_rc";
|
||||||
|
author[] = {"Combat Space Enhancement"};
|
||||||
|
authorUrl = "http://csemod.com";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
class cse_sys_combatdeaf {
|
||||||
|
class PreloadAddons {
|
||||||
|
class cse_sys_combatdeaf {
|
||||||
|
list[] = {"cse_sys_combatdeaf"};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
#include "CfgVehicles.h"
|
||||||
|
#include "CfgWeapons.h"
|
||||||
|
#include "CfgSounds.h"
|
||||||
|
#include "CfgFunctions.h"
|
||||||
|
#include "Combat_Space_Enhancement.h"
|
BIN
TO_MERGE/cse/sys_combatdeaf/data/cse_combatdeaf_deafness.paa
Normal file
BIN
TO_MERGE/cse/sys_combatdeaf/data/cse_combatdeaf_deafness.paa
Normal file
Binary file not shown.
@ -0,0 +1,92 @@
|
|||||||
|
ambient[]={1.000000,1.000000,1.000000,1.000000};
|
||||||
|
diffuse[]={1.000000,1.000000,1.000000,1.000000};
|
||||||
|
forcedDiffuse[]={0.000000,0.000000,0.000000,0.000000};
|
||||||
|
emmisive[]={0.000000,0.000000,0.000000,1.000000};
|
||||||
|
specular[]={0.703999,0.703999,0.703999,0.000000};
|
||||||
|
specularPower=70.000000;
|
||||||
|
PixelShaderID="Super";
|
||||||
|
VertexShaderID="Super";
|
||||||
|
class Stage1
|
||||||
|
{
|
||||||
|
texture="cse\cse_sys_combatdeaf\equipment\data\earplugs_electronic_nohq.paa";
|
||||||
|
uvSource="tex";
|
||||||
|
class uvTransform
|
||||||
|
{
|
||||||
|
aside[]={1.000000,0.000000,0.000000};
|
||||||
|
up[]={0.000000,1.000000,0.000000};
|
||||||
|
dir[]={0.000000,0.000000,0.000000};
|
||||||
|
pos[]={0.000000,0.000000,0.000000};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
class Stage2
|
||||||
|
{
|
||||||
|
texture="#(argb,8,8,3)color(0.5,0.5,0.5,1,DT)";
|
||||||
|
uvSource="tex";
|
||||||
|
class uvTransform
|
||||||
|
{
|
||||||
|
aside[]={1.000000,0.000000,0.000000};
|
||||||
|
up[]={0.000000,1.000000,0.000000};
|
||||||
|
dir[]={0.000000,0.000000,0.000000};
|
||||||
|
pos[]={0.000000,0.000000,0.000000};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
class Stage3
|
||||||
|
{
|
||||||
|
texture="#(argb,8,8,3)color(0,0,0,0,MC)";
|
||||||
|
uvSource="tex";
|
||||||
|
class uvTransform
|
||||||
|
{
|
||||||
|
aside[]={1.000000,0.000000,0.000000};
|
||||||
|
up[]={0.000000,1.000000,0.000000};
|
||||||
|
dir[]={0.000000,0.000000,0.000000};
|
||||||
|
pos[]={0.000000,0.000000,0.000000};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
class Stage4
|
||||||
|
{
|
||||||
|
texture="#(argb,8,8,3)color(1,1,1,1,AS)";
|
||||||
|
uvSource="tex";
|
||||||
|
class uvTransform
|
||||||
|
{
|
||||||
|
aside[]={1.000000,0.000000,0.000000};
|
||||||
|
up[]={0.000000,1.000000,0.000000};
|
||||||
|
dir[]={0.000000,0.000000,0.000000};
|
||||||
|
pos[]={0.000000,0.000000,0.000000};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
class Stage5
|
||||||
|
{
|
||||||
|
texture="#(argb,8,8,3)color(0,0.05,1,1,SMDI)";
|
||||||
|
uvSource="tex";
|
||||||
|
class uvTransform
|
||||||
|
{
|
||||||
|
aside[]={1.000000,0.000000,0.000000};
|
||||||
|
up[]={0.000000,1.000000,0.000000};
|
||||||
|
dir[]={0.000000,0.000000,0.000000};
|
||||||
|
pos[]={0.000000,0.000000,0.000000};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
class Stage6
|
||||||
|
{
|
||||||
|
texture="#(ai,32,128,1)fresnel(0.98,1.02)";
|
||||||
|
uvSource="tex";
|
||||||
|
class uvTransform
|
||||||
|
{
|
||||||
|
aside[]={1.000000,0.000000,0.000000};
|
||||||
|
up[]={0.000000,1.000000,0.000000};
|
||||||
|
dir[]={0.000000,0.000000,0.000000};
|
||||||
|
pos[]={0.000000,0.000000,0.000000};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
class Stage7
|
||||||
|
{
|
||||||
|
texture="cse\cse_sys_medical\equipment\data\env_co.tga";
|
||||||
|
uvSource="tex";
|
||||||
|
class uvTransform
|
||||||
|
{
|
||||||
|
aside[]={1.000000,0.000000,0.000000};
|
||||||
|
up[]={0.000000,1.000000,0.000000};
|
||||||
|
dir[]={0.000000,0.000000,0.000000};
|
||||||
|
pos[]={0.000000,0.000000,0.000000};
|
||||||
|
};
|
||||||
|
};
|
Binary file not shown.
Binary file not shown.
@ -0,0 +1,92 @@
|
|||||||
|
ambient[]={1.000000,1.000000,1.000000,1.000000};
|
||||||
|
diffuse[]={1.000000,1.000000,1.000000,1.000000};
|
||||||
|
forcedDiffuse[]={0.000000,0.000000,0.000000,0.000000};
|
||||||
|
emmisive[]={0.000000,0.000000,0.000000,1.000000};
|
||||||
|
specular[]={0.703999,0.703999,0.703999,0.000000};
|
||||||
|
specularPower=70.000000;
|
||||||
|
PixelShaderID="Super";
|
||||||
|
VertexShaderID="Super";
|
||||||
|
class Stage1
|
||||||
|
{
|
||||||
|
texture="cse\cse_sys_combatdeaf\equipment\data\earplugs_simple_nohq.paa";
|
||||||
|
uvSource="tex";
|
||||||
|
class uvTransform
|
||||||
|
{
|
||||||
|
aside[]={1.000000,0.000000,0.000000};
|
||||||
|
up[]={0.000000,1.000000,0.000000};
|
||||||
|
dir[]={0.000000,0.000000,0.000000};
|
||||||
|
pos[]={0.000000,0.000000,0.000000};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
class Stage2
|
||||||
|
{
|
||||||
|
texture="#(argb,8,8,3)color(0.5,0.5,0.5,1,DT)";
|
||||||
|
uvSource="tex";
|
||||||
|
class uvTransform
|
||||||
|
{
|
||||||
|
aside[]={1.000000,0.000000,0.000000};
|
||||||
|
up[]={0.000000,1.000000,0.000000};
|
||||||
|
dir[]={0.000000,0.000000,0.000000};
|
||||||
|
pos[]={0.000000,0.000000,0.000000};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
class Stage3
|
||||||
|
{
|
||||||
|
texture="#(argb,8,8,3)color(0,0,0,0,MC)";
|
||||||
|
uvSource="tex";
|
||||||
|
class uvTransform
|
||||||
|
{
|
||||||
|
aside[]={1.000000,0.000000,0.000000};
|
||||||
|
up[]={0.000000,1.000000,0.000000};
|
||||||
|
dir[]={0.000000,0.000000,0.000000};
|
||||||
|
pos[]={0.000000,0.000000,0.000000};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
class Stage4
|
||||||
|
{
|
||||||
|
texture="#(argb,8,8,3)color(1,1,1,1,AS)";
|
||||||
|
uvSource="tex";
|
||||||
|
class uvTransform
|
||||||
|
{
|
||||||
|
aside[]={1.000000,0.000000,0.000000};
|
||||||
|
up[]={0.000000,1.000000,0.000000};
|
||||||
|
dir[]={0.000000,0.000000,0.000000};
|
||||||
|
pos[]={0.000000,0.000000,0.000000};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
class Stage5
|
||||||
|
{
|
||||||
|
texture="#(argb,8,8,3)color(0,0.05,1,1,SMDI)";
|
||||||
|
uvSource="tex";
|
||||||
|
class uvTransform
|
||||||
|
{
|
||||||
|
aside[]={1.000000,0.000000,0.000000};
|
||||||
|
up[]={0.000000,1.000000,0.000000};
|
||||||
|
dir[]={0.000000,0.000000,0.000000};
|
||||||
|
pos[]={0.000000,0.000000,0.000000};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
class Stage6
|
||||||
|
{
|
||||||
|
texture="#(ai,32,128,1)fresnel(0.98,1.02)";
|
||||||
|
uvSource="tex";
|
||||||
|
class uvTransform
|
||||||
|
{
|
||||||
|
aside[]={1.000000,0.000000,0.000000};
|
||||||
|
up[]={0.000000,1.000000,0.000000};
|
||||||
|
dir[]={0.000000,0.000000,0.000000};
|
||||||
|
pos[]={0.000000,0.000000,0.000000};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
class Stage7
|
||||||
|
{
|
||||||
|
texture="cse\cse_sys_medical\equipment\data\env_co.tga";
|
||||||
|
uvSource="tex";
|
||||||
|
class uvTransform
|
||||||
|
{
|
||||||
|
aside[]={1.000000,0.000000,0.000000};
|
||||||
|
up[]={0.000000,1.000000,0.000000};
|
||||||
|
dir[]={0.000000,0.000000,0.000000};
|
||||||
|
pos[]={0.000000,0.000000,0.000000};
|
||||||
|
};
|
||||||
|
};
|
Binary file not shown.
Binary file not shown.
BIN
TO_MERGE/cse/sys_combatdeaf/equipment/earplugs_electronic.p3d
Normal file
BIN
TO_MERGE/cse/sys_combatdeaf/equipment/earplugs_electronic.p3d
Normal file
Binary file not shown.
BIN
TO_MERGE/cse/sys_combatdeaf/equipment/earplugs_simple.p3d
Normal file
BIN
TO_MERGE/cse/sys_combatdeaf/equipment/earplugs_simple.p3d
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
4
TO_MERGE/cse/sys_combatdeaf/functions/defines.h
Normal file
4
TO_MERGE/cse/sys_combatdeaf/functions/defines.h
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
#define EARPLUGS_ID 18312
|
||||||
|
#define NO_EARPLUGS 0
|
||||||
|
#define STANDARD_EARPLUGS 1
|
||||||
|
#define ELECTRONIC_EARPLUGS 2
|
@ -0,0 +1,34 @@
|
|||||||
|
#include "defines.h"
|
||||||
|
|
||||||
|
private ["_audibleFire", "_attenuation", "_totalAttenuation", "_ID"];
|
||||||
|
_audibleFire = _this;
|
||||||
|
|
||||||
|
if (_audibleFire < 1) exitWith {};
|
||||||
|
|
||||||
|
_totalAttenuation = 1;
|
||||||
|
|
||||||
|
if (_audibleFire > 1) then {
|
||||||
|
// TODO: Use a headgear config entry instead
|
||||||
|
if (headgear player == "H_Cap_headphones") then {
|
||||||
|
_attenuation = 0.25 max (1 / _audibleFire) min 1; // max. -20 dB
|
||||||
|
_totalAttenuation = _totalAttenuation * _attenuation;
|
||||||
|
_audibleFire = _audibleFire * _attenuation;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
if (_audibleFire > 1) then {
|
||||||
|
if (player getVariable ["cse_combatdeaf_earplugs", NO_EARPLUGS] == ELECTRONIC_EARPLUGS) then {
|
||||||
|
_attenuation = 0.125 max (1 / _audibleFire) min 1; // max. -30 dB
|
||||||
|
_totalAttenuation = _totalAttenuation * _attenuation;
|
||||||
|
_audibleFire = _audibleFire * _attenuation;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
if (_totalAttenuation < 1) then {
|
||||||
|
_ID = floor(random 1000000);
|
||||||
|
[format["electronicHearingProtection_%1", _ID], _totalAttenuation, true] call cse_fnc_setHearingCapability;
|
||||||
|
_ID spawn {
|
||||||
|
sleep 2;
|
||||||
|
[format["electronicHearingProtection_%1", _this], 1, false] call cse_fnc_setHearingCapability;
|
||||||
|
};
|
||||||
|
};
|
@ -0,0 +1,8 @@
|
|||||||
|
private ["_unit", "_damage", "_attenuation", "_sp"];
|
||||||
|
_unit = _this select 0;
|
||||||
|
_damage = _this select 1;
|
||||||
|
|
||||||
|
_attenuation = player call cse_fnc_getAttenuation_DEAF;
|
||||||
|
|
||||||
|
_sp = _attenuation * _damage * 500;
|
||||||
|
_sp call cse_fnc_handlePressureWave_DEAF;
|
@ -0,0 +1,16 @@
|
|||||||
|
#include "defines.h"
|
||||||
|
|
||||||
|
private ["_unit", "_attenuation"];
|
||||||
|
_unit = _this;
|
||||||
|
|
||||||
|
_attenuation = 1;
|
||||||
|
|
||||||
|
if (player getVariable ["cse_combatdeaf_earplugs", NO_EARPLUGS] != NO_EARPLUGS) then {
|
||||||
|
_attenuation = _attenuation * 0.125; // -30 dB
|
||||||
|
};
|
||||||
|
// TODO: Use a headgear config entry instead
|
||||||
|
if (headgear player == "H_Cap_headphones") then {
|
||||||
|
_attenuation = _attenuation * 0.25; // -20 dB
|
||||||
|
};
|
||||||
|
|
||||||
|
_attenuation
|
9
TO_MERGE/cse/sys_combatdeaf/functions/fn_getIn_DEAF.sqf
Normal file
9
TO_MERGE/cse/sys_combatdeaf/functions/fn_getIn_DEAF.sqf
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
private ["_vehicle", "_position", "_unit", "_handle"];
|
||||||
|
_vehicle = _this select 0;
|
||||||
|
_position = _this select 1;
|
||||||
|
_unit = _this select 2;
|
||||||
|
|
||||||
|
if (_unit != player) exitWith {};
|
||||||
|
_handle = _vehicle addEventHandler ["Fired", {_this call cse_fnc_handleFired_DEAF}];
|
||||||
|
|
||||||
|
_vehicle setVariable ["cse_combat_deaf_fired_event_handler", _handle];
|
@ -0,0 +1,20 @@
|
|||||||
|
/**
|
||||||
|
* fn_getMuzzleAccessory_DEAF.sqf
|
||||||
|
* @Descr: N/A Throws exception NO_WEAPON_UNIT
|
||||||
|
* @Author: Glowbal
|
||||||
|
*
|
||||||
|
* @Arguments: [unit OBJECT]
|
||||||
|
* @Return: STRING classname. Empty string if no assescory for Muzzle
|
||||||
|
* @PublicAPI: false
|
||||||
|
*/
|
||||||
|
|
||||||
|
private ["_unit"];
|
||||||
|
_unit = _this select 0;
|
||||||
|
_accessories = [_unit] call cse_fnc_getWeaponItems_F;
|
||||||
|
_items = switch (currentWeapon _unit) do {
|
||||||
|
case (primaryWeapon _unit): { _accessories select 0 };
|
||||||
|
case (secondaryWeapon _unit): { _accessories select 1 };
|
||||||
|
case (handgunWeapon _unit): { _accessories select 2 };
|
||||||
|
default { throw "NO_WEAPON_UNIT"; };
|
||||||
|
};
|
||||||
|
(_items select 0);
|
12
TO_MERGE/cse/sys_combatdeaf/functions/fn_getOut_DEAF.sqf
Normal file
12
TO_MERGE/cse/sys_combatdeaf/functions/fn_getOut_DEAF.sqf
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
private ["_vehicle", "_position", "_unit", "_handle"];
|
||||||
|
_vehicle = _this select 0;
|
||||||
|
_position = _this select 1;
|
||||||
|
_unit = _this select 2;
|
||||||
|
|
||||||
|
if (_unit != player) exitWith {};
|
||||||
|
_handle = _vehicle getVariable "cse_combat_deaf_fired_event_handler";
|
||||||
|
|
||||||
|
if (!isNil "_handle") then {
|
||||||
|
_vehicle removeEventHandler ["Fired", _handle];
|
||||||
|
_vehicle setVariable ["cse_combat_deaf_fired_event_handler", nil];
|
||||||
|
};
|
@ -0,0 +1,85 @@
|
|||||||
|
/**
|
||||||
|
* fn_handleFiredNear_DEAF.sqf
|
||||||
|
* @Descr: N/A
|
||||||
|
* @Author: Ruthberg
|
||||||
|
*
|
||||||
|
* @Arguments: []
|
||||||
|
* @Return:
|
||||||
|
* @PublicAPI: false
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define MAX_DISTANCE 10
|
||||||
|
#define BLUR_DELAY 0.1
|
||||||
|
#define SPEED_OF_SOUND 340.29
|
||||||
|
|
||||||
|
private ["_unit", "_firer", "_distance", "_weapon", "_ammo", "_pressureRatio", "_audibleFire", "_audibleFireToSPL", "_audibleFireDistanceCorrected", "_accessoryConfig", "_sp"];
|
||||||
|
_unit = _this select 0;
|
||||||
|
_firer = _this select 1;
|
||||||
|
_distance = _this select 2;
|
||||||
|
_weapon = _this select 3;
|
||||||
|
_ammo = _this select 6;
|
||||||
|
|
||||||
|
if (_distance > MAX_DISTANCE) exitWith {};
|
||||||
|
if (_weapon in ["Throw", "Put"]) exitWith {};
|
||||||
|
if (getNumber (configFile >> "CfgWeapons" >> _weapon >> "type") == 0) exitWith {
|
||||||
|
[format["Weapon type was 0. Exiting (%1)", _weapon]] call cse_fnc_debug;
|
||||||
|
};
|
||||||
|
|
||||||
|
_pressureRatio = 1 / 3;
|
||||||
|
if ([_unit] call cse_fnc_isInBuilding && [_firer] call cse_fnc_isInBuilding) then {
|
||||||
|
_pressureRatio = 1.0;
|
||||||
|
} else {
|
||||||
|
if (_unit != _firer) then {
|
||||||
|
// calculate direction deviation (shotdirection - (firer -> unit direction))
|
||||||
|
_shotDirection = _firer weaponDirection currentWeapon _firer;
|
||||||
|
_hearerDirection = (getPosASL _firer) vectorFromTo (getPosASL _unit);
|
||||||
|
_cosOfAngle = _shotDirection vectorCos _hearerDirection; // -1 .. +1
|
||||||
|
_pressureRatio = (1 / 3) * (2 + _cosOfAngle); // 0.333 .. 1
|
||||||
|
if (lineIntersects [eyePos _firer, eyePos _unit, _firer, _unit]) then {
|
||||||
|
_pressureRatio = _pressureRatio / 2;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
try {
|
||||||
|
_audibleFire = getNumber(configFile >> "CfgAmmo" >> _ammo >> "audibleFire");
|
||||||
|
_accessoryConfig = (configFile >> "CfgWeapons" >> ([_firer] call cse_fnc_getMuzzleAccessory_DEAF));
|
||||||
|
if (isClass _accessoryConfig) then {
|
||||||
|
_audibleFire = (getNumber (_accessoryConfig >> "ItemInfo" >> "AmmoCoef" >> "audibleFire")) * _audibleFire;
|
||||||
|
};
|
||||||
|
|
||||||
|
_distance = 1 max _distance;
|
||||||
|
_audibleFireToSPL = abs(10 * log(1 / (4 * PI * _distance^2)));
|
||||||
|
_audibleFireDistanceCorrected = 0 max (_audibleFire / 2^(_audibleFireToSPL / 10));
|
||||||
|
_sp = _pressureRatio * (_unit call cse_fnc_getAttenuation_DEAF) * _audibleFireDistanceCorrected / 3;
|
||||||
|
hintSilent format["%1, %2, %3, %4, %5, %6", _distance, _pressureRatio, (_unit call cse_fnc_getAttenuation_DEAF), _sp, _audibleFire, _audibleFireDistanceCorrected];
|
||||||
|
|
||||||
|
_sp call cse_fnc_handlePressureWave_DEAF;
|
||||||
|
_audibleFireDistanceCorrected call cse_fnc_applyEletronicEarProtection_DEAF;
|
||||||
|
|
||||||
|
if (_sp > 1 && goggles _unit == "" && _unit != _firer) then {
|
||||||
|
[_distance, _sp] spawn {
|
||||||
|
private ["_distance", "_blur"];
|
||||||
|
_distance = _this select 0;
|
||||||
|
_blur = (sqrt(_this select 1) / 5) min 2;
|
||||||
|
sleep (_distance / SPEED_OF_SOUND);
|
||||||
|
cse_sys_combatdeaf_blurEffect ppEffectEnable true;
|
||||||
|
cse_sys_combatdeaf_blurEffect ppEffectAdjust [_blur / (_distance^2)];
|
||||||
|
cse_sys_combatdeaf_blurEffect ppEffectCommit BLUR_DELAY;
|
||||||
|
sleep BLUR_DELAY;
|
||||||
|
for "_i" from floor(_distance) to MAX_DISTANCE do {
|
||||||
|
cse_sys_combatdeaf_blurEffect ppEffectAdjust [_blur * (MAX_DISTANCE - _i)];
|
||||||
|
cse_sys_combatdeaf_blurEffect ppEffectCommit (_blur * (BLUR_DELAY / 2));
|
||||||
|
sleep (_blur * (BLUR_DELAY / 2));
|
||||||
|
};
|
||||||
|
cse_sys_combatdeaf_blurEffect ppEffectEnable false;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}catch {
|
||||||
|
// This should never happen.
|
||||||
|
if (_exception == "NO_WEAPON_UNIT") then {
|
||||||
|
[format["Unit (%1) that fired has no weapon. Cannot retrieve silencer accessory", _firer]] call cse_fnc_debug;
|
||||||
|
} else {
|
||||||
|
[_exception] call cse_fnc_debug;
|
||||||
|
};
|
||||||
|
};
|
@ -0,0 +1,8 @@
|
|||||||
|
private ["_unit", "_weapon", "_muzzle", "_mode", "_ammo"];
|
||||||
|
_unit = _this select 0;
|
||||||
|
_weapon = _this select 1;
|
||||||
|
_muzzle = _this select 2;
|
||||||
|
_mode = _this select 3;
|
||||||
|
_ammo = _this select 4;
|
||||||
|
|
||||||
|
[_unit, _unit, 0, _weapon, _muzzle, _mode, _ammo] call cse_fnc_handleFiredNear_DEAF;
|
@ -0,0 +1,46 @@
|
|||||||
|
#define PAIN_THRESHOLD 5
|
||||||
|
#define DAMAGE_THRESHOLD 40
|
||||||
|
#define HEARING_CAPABILITY_MAP_ID 1713
|
||||||
|
|
||||||
|
private ["_sp", "_deafness"];
|
||||||
|
_sp = _this;
|
||||||
|
|
||||||
|
if !(alive player) exitWith {};
|
||||||
|
|
||||||
|
if (_sp > 0.5 && cse_DeafnessIntensity > 0.0) then {
|
||||||
|
_deafness = ((player getVariable ["cse_combatdeaf_deafness", 0]) + _sp) min (DAMAGE_THRESHOLD / cse_DeafnessIntensity);
|
||||||
|
player setVariable ["cse_combatdeaf_deafness", _deafness, false];
|
||||||
|
|
||||||
|
if (!cse_sys_combatdeaf_deafness_running) then {
|
||||||
|
[] spawn {
|
||||||
|
private ["_deafness", "_ringing", "_ringingStart", "_img", "_volume"];
|
||||||
|
cse_sys_combatdeaf_deafness_running = true;
|
||||||
|
_deafness = player getVariable ["cse_combatdeaf_deafness", 0];
|
||||||
|
_ringing = false;
|
||||||
|
_ringingStart = time - 120;
|
||||||
|
while {alive player && _deafness > 0.01} do {
|
||||||
|
if (_deafness > DAMAGE_THRESHOLD / cse_DeafnessIntensity) then {
|
||||||
|
["cse_sys_combatdeaf_deafIcon", true, "cse\cse_sys_combatdeaf\data\cse_combatdeaf_deafness.paa", [1,1,1,1]] call cse_fnc_gui_displayIcon;
|
||||||
|
} else {
|
||||||
|
["cse_sys_combatdeaf_deafIcon", false, "", [1,1,1,1]] call cse_fnc_gui_displayIcon;
|
||||||
|
if (!cse_DisableEarRinging && _deafness > PAIN_THRESHOLD / cse_DeafnessIntensity) then {
|
||||||
|
if (!_ringing || time - _ringingStart > 120) then {
|
||||||
|
playSound "cse_combatdeaf_ear_ringing";
|
||||||
|
_ringingStart = time;
|
||||||
|
_ringing = true;
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
_ringing = false;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
_deafness = player getVariable ["cse_combatdeaf_deafness", 0];
|
||||||
|
_volume = 0 max (1 - (_deafness / (DAMAGE_THRESHOLD / cse_DeafnessIntensity)));
|
||||||
|
[format["hearingCapability_%1", HEARING_CAPABILITY_MAP_ID], _volume, true] call cse_fnc_setHearingCapability;
|
||||||
|
player setVariable ["cse_combatdeaf_deafness", 0 max (_deafness - 0.5 / (1 max _deafness min (DAMAGE_THRESHOLD / cse_DeafnessIntensity))), false];
|
||||||
|
sleep 1;
|
||||||
|
};
|
||||||
|
cse_sys_combatdeaf_deafness_running = false;
|
||||||
|
[format["hearingCapability_%1", HEARING_CAPABILITY_MAP_ID], 1, false] call cse_fnc_setHearingCapability;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
@ -0,0 +1,20 @@
|
|||||||
|
/**
|
||||||
|
* fn_hasMuzzleAccessory_DEAF.sqf
|
||||||
|
* @Descr: N/A
|
||||||
|
* @Author: Glowbal
|
||||||
|
*
|
||||||
|
* @Arguments: []
|
||||||
|
* @Return:
|
||||||
|
* @PublicAPI: false
|
||||||
|
*/
|
||||||
|
|
||||||
|
private ["_unit"];
|
||||||
|
_unit = _this select 0;
|
||||||
|
_accessories = [_unit] call cse_fnc_getWeaponItems_F;
|
||||||
|
_items = switch (currentWeapon _unit) do {
|
||||||
|
case (primaryWeapon _unit): { _accessories select 0 };
|
||||||
|
case (secondaryWeapon _unit): { _accessories select 1 };
|
||||||
|
case (handgunWeapon _unit): { _accessories select 2 };
|
||||||
|
default { throw "NO_WEAPON_UNIT"; };
|
||||||
|
};
|
||||||
|
(_items select 0) != "";
|
@ -0,0 +1,60 @@
|
|||||||
|
#include "defines.h"
|
||||||
|
|
||||||
|
if (isDedicated) exitwith{};
|
||||||
|
CSE_ICON_PATH = "cse\cse_gui\radialmenu\data\icons\";
|
||||||
|
|
||||||
|
cse_hearingProtectionDisplaySubMenu = {
|
||||||
|
[_this] call cse_fnc_Debug;
|
||||||
|
|
||||||
|
private ["_subMenus"];
|
||||||
|
_subMenus = [];
|
||||||
|
|
||||||
|
// Put on standard earplugs
|
||||||
|
if (player getVariable ["cse_combatdeaf_earplugs", NO_EARPLUGS] == NO_EARPLUGS && [player, "cse_earplugs"] call cse_fnc_hasItem) then {
|
||||||
|
_subMenus pushBack ["Use earplugs", CSE_ICON_PATH + "icon_earplugs_standard.paa", {
|
||||||
|
closeDialog 0;
|
||||||
|
player setVariable ["cse_combatdeaf_earplugs", STANDARD_EARPLUGS, false];
|
||||||
|
player removeItem "cse_earplugs";
|
||||||
|
[format["earplugsAttenuation_ID_%1", EARPLUGS_ID], 0.125] call cse_fnc_setHearingCapability;
|
||||||
|
}, true, "Use standard earplugs"];
|
||||||
|
};
|
||||||
|
|
||||||
|
// Put on electronic earplugs
|
||||||
|
if (player getVariable ["cse_combatdeaf_earplugs", NO_EARPLUGS] == NO_EARPLUGS && [player, "cse_earplugs_electronic"] call cse_fnc_hasItem) then {
|
||||||
|
_subMenus pushBack ["Use earplugs", CSE_ICON_PATH + "icon_earplugs_electronic.paa", {
|
||||||
|
closeDialog 0;
|
||||||
|
player setVariable ["cse_combatdeaf_earplugs", ELECTRONIC_EARPLUGS, false];
|
||||||
|
player removeItem "cse_earplugs_electronic";
|
||||||
|
}, true, "Use electronic earplugs"];
|
||||||
|
};
|
||||||
|
|
||||||
|
// Remove earplugs
|
||||||
|
if (player getVariable ["cse_combatdeaf_earplugs", NO_EARPLUGS] != NO_EARPLUGS) then {
|
||||||
|
switch (player getVariable ["cse_combatdeaf_earplugs", NO_EARPLUGS]) do {
|
||||||
|
case STANDARD_EARPLUGS: {
|
||||||
|
_subMenus pushBack ["Earplugs out", CSE_ICON_PATH + "icon_earplugs_remove.paa", {
|
||||||
|
closeDialog 0;
|
||||||
|
player setVariable ["cse_combatdeaf_earplugs", NO_EARPLUGS, false];
|
||||||
|
player addItem "cse_earplugs";
|
||||||
|
[format["earplugsAttenuation_ID_%1", EARPLUGS_ID], 1, false] call cse_fnc_setHearingCapability;
|
||||||
|
}, true, "Remove standard earplugs"];
|
||||||
|
};
|
||||||
|
case ELECTRONIC_EARPLUGS: {
|
||||||
|
_subMenus pushBack ["Earplugs out", CSE_ICON_PATH + "icon_earplugs_remove.paa", {
|
||||||
|
closeDialog 0;
|
||||||
|
player setVariable ["cse_combatdeaf_earplugs", NO_EARPLUGS, false];
|
||||||
|
player addItem "cse_earplugs_electronic";
|
||||||
|
}, true, "Remove electronic earplugs"];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
[_this select 3, _subMenus, _this select 1, CSE_SELECTED_RADIAL_OPTION_N_GUI, true] call cse_fnc_openRadialSecondRing_GUI;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
_entries = [
|
||||||
|
["Hearing", {((player getVariable ["cse_combatdeaf_earplugs", NO_EARPLUGS] != NO_EARPLUGS) || (([player, "cse_earplugs_electronic"] call cse_fnc_hasItem) || ([player, "cse_earplugs"] call cse_fnc_hasItem)))}, CSE_ICON_PATH + "icon_ear_protection.paa", cse_hearingProtectionDisplaySubMenu, "Show available hearing protections"]
|
||||||
|
];
|
||||||
|
["ActionMenu","equipment", _entries ] call cse_fnc_addMultipleEntriesToRadialCategory_F;
|
||||||
|
|
29
TO_MERGE/cse/sys_combatdeaf/init_sys_combatdeaf.sqf
Normal file
29
TO_MERGE/cse/sys_combatdeaf/init_sys_combatdeaf.sqf
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
#include "functions\defines.h"
|
||||||
|
|
||||||
|
if (!hasInterface) exitwith {};
|
||||||
|
waituntil{!isnil "cse_gui" && !isnil "cse_main"};
|
||||||
|
|
||||||
|
waitUntil {!isNull player};
|
||||||
|
|
||||||
|
private ["_args"];
|
||||||
|
_args = _this;
|
||||||
|
{
|
||||||
|
_varName = "cse_"+(_x select 0);
|
||||||
|
missionNamespace setVariable[_varName, _x select 1];
|
||||||
|
} forEach _args;
|
||||||
|
|
||||||
|
if (isNil "cse_DeafnessIntensity") then { cse_DeafnessIntensity = cse_DEAFNESS_EFFECT_INTENSITY };
|
||||||
|
if (isNil "cse_DisableEarRinging") then { cse_DisableEarRinging = cse_DISABLE_EAR_RINGING };
|
||||||
|
|
||||||
|
["cse_combatdeaf_deafness", 0, false, "cd"] call cse_fnc_defineVariable;
|
||||||
|
["cse_combatdeaf_earplugs", NO_EARPLUGS, false, "cd"] call cse_fnc_defineVariable;
|
||||||
|
|
||||||
|
call cse_fnc_register_ear_protection_actions_DEAF;
|
||||||
|
|
||||||
|
player addEventHandler ["FiredNear", {_this call cse_fnc_handleFiredNear_DEAF}];
|
||||||
|
player addEventHandler ["Explosion", {_this call cse_fnc_explosion_DEAF}];
|
||||||
|
|
||||||
|
cse_sys_combatdeaf_blurEffect = ppEffectCreate ["dynamicBlur", -11723];
|
||||||
|
cse_sys_combatdeaf_deafness_running = false;
|
||||||
|
|
||||||
|
cse_sys_combatdeaf = true;
|
BIN
TO_MERGE/cse/sys_combatdeaf/sound/ear_ringing.ogg
Normal file
BIN
TO_MERGE/cse/sys_combatdeaf/sound/ear_ringing.ogg
Normal file
Binary file not shown.
7
TO_MERGE/cse/sys_combatdeaf/stringtable.xml
Normal file
7
TO_MERGE/cse/sys_combatdeaf/stringtable.xml
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<Project name="Combat Space Enhancement">
|
||||||
|
<Package name="cse_sys_combatdeaf">
|
||||||
|
<Container ID="CombatDeaf">
|
||||||
|
</Container>
|
||||||
|
</Package>
|
||||||
|
</Project>
|
Loading…
Reference in New Issue
Block a user