diff --git a/.hemtt/launch.toml b/.hemtt/launch.toml index 662ac1232..e4591d7a0 100644 --- a/.hemtt/launch.toml +++ b/.hemtt/launch.toml @@ -3,4 +3,6 @@ workshop = [ "450814997", # CBA_A3's Workshop ID "463939057", # ACE3's Workshop ID "2369477168", # Advanced Developer Tools's Workshop ID -] \ No newline at end of file + "1645973522", #Intercept's Workshop ID + "1652506957" # ASP Workshop ID +] diff --git a/addons/chemical/CfgAmmo.hpp b/addons/chemical/CfgAmmo.hpp index 3d40ed641..cec60e938 100644 --- a/addons/chemical/CfgAmmo.hpp +++ b/addons/chemical/CfgAmmo.hpp @@ -1,17 +1,16 @@ -class CfgAmmo -{ +class CfgAmmo { + class SmokeShellArty; - class KAT_SmokeShellArty: SmokeShellArty{ + class KAT_SmokeShellArty: SmokeShellArty { smokeColor[] = {0,0,0,0}; }; class Smoke_82mm_AMOS_White; - class Sh_82mm_AMOS_Type0: Smoke_82mm_AMOS_White - { + class Sh_82mm_AMOS_Type0: Smoke_82mm_AMOS_White { KAT_projectile = 1; KAT_lifetime = 90; KAT_radius = 10; - KAT_toxicLvL = 0; + KAT_toxicLvL = 1; soundFakeFall[] = {"soundFakeFall0",0.25,"soundFakeFall1",0.25,"soundFakeFall2",0.25,"soundFakeFall3",0.25}; soundFakeFall0[] = {"a3\Sounds_F\weapons\falling_bomb\fall_01",3.16228,1,1000}; soundFakeFall1[] = {"a3\Sounds_F\weapons\falling_bomb\fall_02",3.16228,1,1000}; @@ -21,17 +20,16 @@ class CfgAmmo whistleOnFire = 2; submunitionAmmo = "KAT_SmokeShellArty"; }; - class Sh_82mm_AMOS_TypeCS: Sh_82mm_AMOS_Type0 - { + + class Sh_82mm_AMOS_TypeCS: Sh_82mm_AMOS_Type0 { KAT_projectile = 1; KAT_lifetime = 60; KAT_radius = 10; - KAT_toxicLvL = 1; //cs + KAT_toxicLvL = 0; //cs }; class SmokeShell; - class KAT_G_M7A3: SmokeShell - { + class KAT_G_M7A3: SmokeShell { KAT_csGas = 1; model = QPATHTOF(ui\m7a3_throw.p3d); dangerRadiusHit = -1; @@ -58,7 +56,7 @@ class CfgAmmo indirectHit = 0; indirectHitRange = 0; soundHit[] = {"A3\Sounds_F\weapons\smokeshell\smoke_3",1.25893,1,100}; - explosionEffects = "KAT_GASTripEffect"; + explosionEffects = "KAT_TripWireGasEffect"; CraterEffects = ""; soundTrigger[] = {"",1,1}; class CamShakeExplode { @@ -115,9 +113,8 @@ class CfgAmmo frequency = 5; distance = 250; }; - - }; + class Mo_cluster_Bomb_01_F; class KAT_CAS_M43_Ammo_sub: Mo_cluster_Bomb_01_F { hit = 0; diff --git a/addons/chemical/CfgCloudlets.hpp b/addons/chemical/CfgCloudlets.hpp index b7ad16364..1fac4e64c 100644 --- a/addons/chemical/CfgCloudlets.hpp +++ b/addons/chemical/CfgCloudlets.hpp @@ -1,16 +1,16 @@ class CfgCloudlets { class Default; - class ACE_GasTrip: Default { + class KAT_TripWireGas: Default { lifeTime = 0; beforeDestroyScript = QPATHTOF(functions\fnc_GasTripEffect.sqf); }; - class CAS_GAS_Explosion_FX_Script: Default { + class KAT_CAS_GAS_Explosion_FX_Script: Default { lifeTime = 0; beforeDestroyScript = QPATHTOF(functions\fnc_CASCreateGas.sqf); }; - class CAS_GAS_Explosion_FX: Default { + class KAT_CAS_GAS_Explosion_FX: Default { interval = 0.03; circleRadius = 0; circleVelocity[] = {0,0,0}; @@ -63,7 +63,7 @@ class CfgCloudlets { position[] = {0,0,0}; }; - class CAS_GAS_FX: Default { + class KAT_CAS_GAS_FX: Default { interval = 0.03; circleRadius = 0; circleVelocity[] = {0,0,0}; @@ -113,10 +113,10 @@ class CfgCloudlets { }; }; -class KAT_GASTripEffect { +class KAT_TripWireGasEffect { class spawnGAS { simulation = "particles"; - type = "ACE_GasTrip"; + type = "KAT_TripWireGas"; position = "explosionPos"; }; }; @@ -124,21 +124,21 @@ class KAT_GASTripEffect { class KAT_GAS_ClusterExplosion { class ExplosionEffect { simulation = "particles"; - type = "CAS_GAS_Explosion_FX"; + type = "KAT_CAS_GAS_Explosion_FX"; position = "explosionPos"; lifeTime = 2; particleFSLoop = 1; }; class CAS_GAS_Effect { simulation = "particles"; - type = "CAS_GAS_FX"; + type = "KAT_CAS_GAS_FX"; position = "explosionPos"; lifeTime = 240; particleFSLoop = 1; }; class GAS_Script { simulation = "particles"; - type = "CAS_GAS_Explosion_FX_Script"; + type = "KAT_CAS_GAS_Explosion_FX_Script"; position = "explosionPos"; }; }; @@ -146,14 +146,14 @@ class KAT_GAS_ClusterExplosion { class KAT_CAS_R_HYDRA_Explosion { class CAS_R_GAS_Effect { simulation = "particles"; - type = "CAS_GAS_FX"; + type = "KAT_CAS_GAS_FX"; position = "explosionPos"; lifeTime = 240; particleFSLoop = 1; }; class R_GAS_Script { simulation = "particles"; - type = "CAS_GAS_Explosion_FX_Script"; + type = "KAT_CAS_GAS_Explosion_FX_Script"; position = "explosionPos"; }; }; diff --git a/addons/chemical/CfgGlasses.hpp b/addons/chemical/CfgGlasses.hpp index 24b7626a2..17e002c4b 100644 --- a/addons/chemical/CfgGlasses.hpp +++ b/addons/chemical/CfgGlasses.hpp @@ -1,4 +1,4 @@ -class cfgGlasses +class CfgGlasses { class G_RegulatorMask_F; class kat_mask_M50: G_RegulatorMask_F @@ -11,7 +11,7 @@ class cfgGlasses mass = 4; }; - + class kat_mask_M04: kat_mask_M50 { author = "Assaultboy"; @@ -19,4 +19,4 @@ class cfgGlasses model = QPATHTOF(models\kat_mask_m04.p3d); picture = QPATHTOF(ui\maskM04.paa); }; -}; \ No newline at end of file +}; diff --git a/addons/chemical/CfgMagazines.hpp b/addons/chemical/CfgMagazines.hpp index 4355d6b66..498ca3691 100644 --- a/addons/chemical/CfgMagazines.hpp +++ b/addons/chemical/CfgMagazines.hpp @@ -1,4 +1,4 @@ -class cfgMagazines +class CfgMagazines { class ACE_1Rnd_82mm_Mo_HE; class KAT_1Rnd_82mm_Mo_Type0: ACE_1Rnd_82mm_Mo_HE @@ -14,7 +14,7 @@ class cfgMagazines scope = 1; count = 5; }; - class KAT_1Rnd_82mm_Mo_TypeCS: ACE_1Rnd_82mm_Mo_HE + class KAT_1Rnd_82mm_Mo_TypeCS: ACE_1Rnd_82mm_Mo_HE { author="DiGii"; ammo="Sh_82mm_AMOS_TypeCS"; @@ -22,7 +22,7 @@ class cfgMagazines displayNameShort= CSTRING(CSGas_MFDNAME); displayName= CSTRING(CSGas_DisplayName); }; - class KAT_3Rnd_82mm_Mo_TypeCS_AI: KAT_1Rnd_82mm_Mo_TypeCS + class KAT_3Rnd_82mm_Mo_TypeCS_AI: KAT_1Rnd_82mm_Mo_TypeCS { scope = 1; count = 3; @@ -36,7 +36,7 @@ class cfgMagazines descriptionShort = CSTRING(M7A3_DcsShort); displayNameShort = CSTRING(M7A3_CSGrenade_ShortName); model = QPATHTOF(ui\m7a3.p3d); - picture = QPATHTOF(ui\KAT_m7a3_ca.paa); + picture = QPATHTOF(ui\KAT_m7a3_ca.paa); ammo = "KAT_G_M7A3"; mass = 4; }; @@ -69,7 +69,7 @@ class cfgMagazines pylonWeapon = "KAT_CAS_M43_Bomb"; }; - class KAT_CAS_M43_Mag_x2 : PylonRack_Bomb_GBU12_x2 + class KAT_CAS_M43_Mag_x2 : PylonRack_Bomb_GBU12_x2 { ammo = "KAT_CAS_M43_Ammo"; author = "DiGii"; @@ -82,7 +82,7 @@ class cfgMagazines mass = 200; pylonWeapon = "KAT_CAS_M43_Bomb"; }; - + class PylonRack_19Rnd_Rocket_Skyfire; class KAT_CAS_R_80mm_GAS_MAG: PylonRack_19Rnd_Rocket_Skyfire { ammo = "KAT_CAS_R_80mm_GAS_AMMO"; @@ -93,4 +93,4 @@ class cfgMagazines pylonWeapon = "KAT_CAS_R_80mm_GAS_POD"; hardpoints[] = {"RHS_HP_UPK23_KA52","RHS_HP_9m120_Mi28","RHS_HP_KH55SM_INT","RHS_HP_TU95MS6_INT","RHS_HP_FFAR_ARMY","RHS_HP_MELB","O_MISSILE_PYLON","O_SKYFIRE","B_MISSILE_PYLON","DAGR","DAR","B_SHIEKER","CUP_PylonPod_19Rnd_Rocket_FFAR_plane_M","CUP_NATO_HELO_ROCKETS","CUP_19Rnd_FFAR","B_AH_99_PYLON","CUP_SUPER_PYLON","CUP_32Rnd_S5","pook_RPOD","RHS_HP_FFAR_USMC", "RHS_HP_INGWE", "RHS_HP_MELB_R", "RHS_HP_MELB","RHS_HP_UB32","pook_HELI_BMB","pook_HELI_MISSILERACK"}; }; -}; \ No newline at end of file +}; diff --git a/addons/chemical/CfgVehicles.hpp b/addons/chemical/CfgVehicles.hpp index 3dfc8842c..591b873d2 100644 --- a/addons/chemical/CfgVehicles.hpp +++ b/addons/chemical/CfgVehicles.hpp @@ -19,19 +19,21 @@ class CfgVehicles { showDisabled = 0; icon = QPATHTOF(ui\gasmaskfilter_ca.paa); }; - class KAT_MuteChemDetector { - displayName = CSTRING(ChemDetector_Mute); - condition = QUOTE([ARR_2(_player,true)] call FUNC(getChemDetectorState)); - statement = QUOTE(_player setVariable [ARR_3(QQGVAR(chemDetectorState),false,true)]); + class KAT_PutOnGasMask { + displayName = "Put on Gas Mask"; + condition = QUOTE([_player] call FUNC(canPutOnGasMask)); + exceptions[] = {"isNotSwimming", "isNotInside", "isNotSitting"}; + statement = QUOTE([_player] call FUNC(putOnGasMask)); showDisabled = 0; - icon = QPATHTOF(ui\ChemDetectorIcon.paa); + icon = QPATHTOF(ui\Gasmask_icon.paa); }; - class KAT_UnmuteChemDetector { - displayName = CSTRING(ChemDetector_Unmute); - condition = QUOTE([ARR_2(_player,false)] call FUNC(getChemDetectorState)); - statement = QUOTE(_player setVariable [ARR_3(QQGVAR(chemDetectorState),true,true)]); + class KAT_TakeOffGasMask { + displayName = "Take off Gas Mask"; + condition = QUOTE([_player] call FUNC(canTakeOffGasMask)); + exceptions[] = {"isNotSwimming", "isNotInside", "isNotSitting"}; + statement = QUOTE([_player] call FUNC(takeOffGasMask)); showDisabled = 0; - icon = QPATHTOF(ui\ChemDetectorIcon.paa); + icon = QPATHTOF(ui\Gasmask_icon.paa); }; }; }; @@ -96,32 +98,25 @@ class CfgVehicles { function = QFUNC(gasmodule); isTriggerActivated = 0; functionPriority = 1; - isGlobal = 1; + isGlobal = 0; class Arguments: AttributesBase { - class Radius_Max + class Radius { displayName = CSTRING(UI_max_range); tooltip = CSTRING(GasModule_min_radius_dcs); typeName = "NUMBER"; defaultValue = 20; }; - class Radius_Min - { - displayName = CSTRING(UI_min_range); - tooltip = CSTRING(GasModule_max_radius_dcs); - typeName = "NUMBER"; - defaultValue = 10; - }; class GAS_Type { displayName = CSTRING(UI_gasType); typeName = "NUMBER"; class values { - class toxicgas { + class ToxicGas { name = CSTRING(LvL1_Gas); - value = 0; + value = 1; default = 1; }; /* class csgas { @@ -160,10 +155,11 @@ class CfgVehicles { curatorCanAttach = 1; displayName = CSTRING(GasModule_Displayname); category = QEGVAR(zeus,KAM); + function = QACEFUNC(common,dummy); curatorInfoType = QGVAR(kat_RscGasModul); isTriggerActivated = 0; functionPriority = 1; - isGlobal = 1; + isGlobal = 0; }; @@ -214,4 +210,11 @@ class CfgVehicles { ammo = "KAT_Gas_TripWireMine_Ammo"; displayName = CSTRING(TriWire_Gas_Name); }; + + + class Static; + class GVAR(logic): Static { + scope = 1; + displayName = ""; + }; }; diff --git a/addons/chemical/XEH_PREP.hpp b/addons/chemical/XEH_PREP.hpp index 6ec1136ba..0decbf75b 100644 --- a/addons/chemical/XEH_PREP.hpp +++ b/addons/chemical/XEH_PREP.hpp @@ -1,29 +1,23 @@ -PREP(afterWait); PREP(AttributeRadius); PREP(breathing); PREP(canPutGasMask); +PREP(canPutOnGasMask); PREP(canReplaceFilter); +PREP(canTakeOffGasMask); PREP(CASCreateGas); PREP(changeGasMaskFilter); PREP(checkGasMaskDur); -PREP(chemDetector); -PREP(coughing); PREP(createSealAction); -PREP(createZone); PREP(csGrenade); PREP(displayGasMaskDur); PREP(fullHealLocal); -PREP(gasAI); -PREP(gasCheck); -PREP(gasCheckLocal); +PREP(gasManagerPFH); PREP(gasmodule); PREP(GasTripEffect); -PREP(getChemDetectorState); PREP(getList); PREP(giveUnitGasMask); PREP(gui_updateBodyImage); PREP(gui_updateInjuryListGeneral); -PREP(handleCSGas); PREP(handleFired); PREP(handleGasMaskDur); PREP(handleRespawn); @@ -32,8 +26,11 @@ PREP(hasGasMaskON); PREP(hideChemDetector); PREP(init); PREP(initModule); +PREP(poison); +PREP(putOnGasMask); PREP(showChemDetector); PREP(spawnSmoke); +PREP(takeOffGasMask); PREP(throwGrenade); PREP(treatmentAdvanced_AtropineLocal); PREP(ui_gasModule); diff --git a/addons/chemical/XEH_postInit.sqf b/addons/chemical/XEH_postInit.sqf index 8d1202fb7..fe535ba4e 100644 --- a/addons/chemical/XEH_postInit.sqf +++ b/addons/chemical/XEH_postInit.sqf @@ -1,13 +1,10 @@ #include "script_component.hpp" //Events -[QGVAR(gasCheck), LINKFUNC(gasCheck)] call CBA_fnc_addEventHandler; -[QGVAR(gasPlayer), LINKFUNC(gasCheckLocal)] call CBA_fnc_addEventHandler; -[QGVAR(gasAI), LINKFUNC(gasAI)] call CBA_fnc_addEventHandler; -[QGVAR(afterWait), LINKFUNC(afterWait)] call CBA_fnc_addEventHandler; -[QGVAR(enteredZone), LINKFUNC(chemDetector)] call CBA_fnc_addEventHandler; -[QGVAR(createZoneGlobal), LINKFUNC(createZone)] call CBA_fnc_addEventHandler; -[QGVAR(createSealActionGlobal), LINKFUNC(createSealAction)] call CBA_fnc_addEventHandler; +["ace_glassesChanged", LINKFUNC(breathing)] call CBA_fnc_addEventHandler; +[QGVAR(poison), LINKFUNC(poison)] call CBA_fnc_addEventHandler; +[QGVAR(handleGasMaskDur), LINKFUNC(handleGasMaskDur)] call CBA_fnc_addEventHandler; +[QGVAR(addSealAction), LINKFUNC(createSealAction)] call CBA_fnc_addEventHandler; // ACE Events [QACEGVAR(medical_gui,updateInjuryListGeneral), LINKFUNC(gui_updateInjuryListGeneral)] call CBA_fnc_addEventHandler; @@ -27,19 +24,6 @@ KAT_ProjectileCache = ("([_x, 'KAT_projectile', 0] call BIS_fnc_returnConfigEntr ["ace_firedPlayerNonLocal", LINKFUNC(throwGrenade)] call CBA_fnc_addEventHandler; ["ace_firedNonPlayer", LINKFUNC(throwGrenade)] call CBA_fnc_addEventHandler; -if (hasInterface) then { - ppBlur_priority = 399; - [{ - ppBlur_priority = ppBlur_priority + 1; - ppBlur = ppEffectCreate ["DynamicBlur", ppBlur_priority]; - ppBlur != -1 - }, { - ppBlur ppEffectEnable false; - ppBlurAmount = 0; - ppBluring = false; - }] call CBA_fnc_waitUntilAndExecute; -}; - private _items = missionNamespace getVariable [QGVAR(availGasmask), "'G_AirPurifyingRespirator_01_F'"]; private _array = [_items, "CfgGlasses"] call FUNC(getList); missionNamespace setVariable [QGVAR(availGasmaskList), _array, true]; @@ -56,3 +40,79 @@ missionNamespace setVariable [QGVAR(availGasmaskList), _array, true]; true }, { false }, [24, [false, false, false]], false] call CBA_fnc_addKeybind; + +if (!isServer) exitWith {}; + +GVAR(gasSources) = createHashMap; + +[QGVAR(addGasSource), { + params [ + ["_source", objNull, [objNull, []]], + ["_radius", 0, [0]], + ["_gasLevel", 0, [0]], + ["_key", ""], + ["_condition", {true}, [{}]], + ["_conditionArgs", []], + ["_isSealable", false] + ]; + + private _isObject = _source isEqualType objNull; + + // Check if the source is valid + if !(_isObject || {_source isEqualTypeParams [0, 0, 0]}) exitWith {}; + + if (_isObject && {isNull _source}) exitWith {}; + if (_radius == 0) exitWith {}; + if (_key isEqualTo "") exitWith {}; // key can be many types + + // hashValue supports more types than hashmaps do by default, but not all (e.g. locations) + private _hashedKey = hashValue _key; + + if (isNil "_hashedKey") exitWith { + ERROR_2("Unsupported key type used: %1 - %2",_key,typeName _key); + }; + + // If a position is passed, create a static object at said position + private _sourcePos = if (_isObject) then { + getPosATL _source + } else { + ASLToATL _source + }; + + private _gasLogic = createVehicle [QGVAR(logic), _sourcePos, [], 0, "CAN_COLLIDE"]; + + // If an object was passed, attach logic to the object + if (_isObject) then { + _gasLogic attachTo [_source]; + }; + + // To avoid issues, remove existing entries first before overwriting + if (_hashedKey in GVAR(gasSources)) then { + [QGVAR(removeGasSource), _key] call CBA_fnc_localEvent; + }; + + if (_isSealable) then { + private _jipID = [QGVAR(addSealAction), [_source, _gasLogic, _key]] call CBA_fnc_globalEventJIP; + [_jipID, _source] call CBA_fnc_removeGlobalEventJIP; + _source setVariable [QGVAR(sealable), true, true]; + }; + + GVAR(gasSources) set [_hashedKey, [_gasLogic, _radius, _gasLevel, _condition, _conditionArgs]]; +}] call CBA_fnc_addEventHandler; + +[QGVAR(removeGasSource), { + params ["_key"]; + private _hashedKey = hashValue _key; + + if (isNil "_hashedKey") exitWith { + ERROR_2("Unsupported key type used: %1 - %2",_key,typeName _key); + }; + + (GVAR(gasSources) deleteAt _hashedKey) params [["_gasLogic", objNull]]; + + detach _gasLogic; + deleteVehicle _gasLogic; +}] call CBA_fnc_addEventHandler; + +[LINKFUNC(gasManagerPFH), GAS_MANAGER_PFH_DELAY, []] call CBA_fnc_addPerFrameHandler; + diff --git a/addons/chemical/XEH_preInit.sqf b/addons/chemical/XEH_preInit.sqf index 065630bd0..c786cc786 100644 --- a/addons/chemical/XEH_preInit.sqf +++ b/addons/chemical/XEH_preInit.sqf @@ -22,7 +22,6 @@ PREP_RECOMPILE_END; true ] call CBA_Settings_fnc_init; - [ QGVAR(gasmask_durability), "TIME", @@ -32,24 +31,27 @@ PREP_RECOMPILE_END; true ] call CBA_Settings_fnc_init; +// Sets sound volume of gas mask breathing [ - QGVAR(infectionTime), - "TIME", - [LLSTRING(SETTING_infection_time),LLSTRING(SETTING_infection_time_disc)], + QGVAR(gasMaskSoundVolume), + "SLIDER", + [LLSTRING(SETTING_stethoscopeSoundVolume), LLSTRING(SETTING_stethoscopeSoundVolume_DESC)], CBA_SETTINGS_CHEM, - [1, 600, 60], - true + [0, 2, 1, 1], + 2, + { + player setVariable [QGVAR(gasMaskSoundVolume), _this, true]; + }, + false ] call CBA_Settings_fnc_init; +// Chance of weapon drop by tear gas [ - QGVAR(affectAI), - "CHECKBOX", - [LLSTRING(SETTING_affectAI),LLSTRING(SETTING_affectAI_disc)], + QGVAR(tearGasDropChance), + "SLIDER", + [LLSTRING(SETTING_dropWeaponChance), LLSTRING(SETTING_dropWeaponChance_DESC)], CBA_SETTINGS_CHEM, - false, - true, - {}, + [0, 1, 0, 2, true], true ] call CBA_Settings_fnc_init; - ADDON = true; diff --git a/addons/chemical/config.cpp b/addons/chemical/config.cpp index a8c873fb0..aac13d177 100644 --- a/addons/chemical/config.cpp +++ b/addons/chemical/config.cpp @@ -20,7 +20,7 @@ class CfgPatches { }; ammo[] = { "KAT_Gas_TripWireMine_Ammo", - "KAT_GASTripEffect", + "KAT_TripWireGasEffect", "KAT_GASTrip_SmokeEffect", "KAT_CAS_M43_Ammo", "KAT_CAS_M43_Ammo_sub", diff --git a/addons/chemical/functions/fnc_AttributeRadius.sqf b/addons/chemical/functions/fnc_AttributeRadius.sqf index b7d2f8f3e..9accdfccc 100644 --- a/addons/chemical/functions/fnc_AttributeRadius.sqf +++ b/addons/chemical/functions/fnc_AttributeRadius.sqf @@ -27,7 +27,6 @@ private _placeText = _display displayCtrl 1616; if !(isNull attachedTo _logic) then { _sealCheckBox ctrlShow true; _sealText ctrlShow true; - _placeText ctrlSetText LLSTRING(GasModule_createContaminatedObject); } else { _sealCheckBox ctrlShow false; @@ -37,18 +36,14 @@ if !(isNull attachedTo _logic) then { private _gasTypeCombo = _display displayCtrl 1615; private _maxEdit = _control controlsGroupCtrl 1611; -private _minEdit = _control controlsGroupCtrl 1612; _maxEdit ctrlSetText "100"; -_minEdit ctrlSetText "50"; private _fnc_onKeyUp = { params ["_display"]; private _maxEdit = _display displayCtrl 1611; - private _minEdit = _display displayCtrl 1612; private _maxradius = parseNumber (ctrlText _maxEdit); - private _minradius = parseNumber (ctrlText _minEdit); // Handle invalid radius (non-numerical input) if (_maxradius == 0) then { @@ -57,21 +52,7 @@ private _fnc_onKeyUp = { } else { _maxEdit ctrlSetTooltip ""; _maxEdit ctrlSetTextColor [1,1,1,1]; - _display setVariable [QGVAR(ui_radiusMax),_maxradius]; - }; - - if (_minradius == 0) then { - _minEdit ctrlSetTooltip (ACELSTRING(Zeus,AttributeRadiusInvalid)); - _minEdit ctrlSetTextColor [1,0,0,1]; - } else { - if(_minradius > _maxradius) then { - _minEdit ctrlSetTooltip (ACELSTRING(Zeus,AttributeRadiusInvalid)); - _minEdit ctrlSetTextColor [1,0,0,1]; - } else { - _minEdit ctrlSetTooltip ""; - _minEdit ctrlSetTextColor [1,1,1,1]; - _display setVariable [QGVAR(ui_radiusMin),_minradius]; - }; + _display setVariable [QGVAR(ui_radius),_maxradius]; }; }; @@ -86,7 +67,7 @@ private _fnc_onLBSelChange = { params ["_gasTypeCombo"]; _display = ctrlParent _gasTypeCombo; private _gastype = lbCurSel _gasTypeCombo; - _display setVariable [QGVAR(ui_gastype),_gastype]; + _display setVariable [QGVAR(ui_gastype), _gastype]; }; [_display] call _fnc_onKeyUp; diff --git a/addons/chemical/functions/fnc_CASCreateGas.sqf b/addons/chemical/functions/fnc_CASCreateGas.sqf index e9ac1fca8..903c5845b 100644 --- a/addons/chemical/functions/fnc_CASCreateGas.sqf +++ b/addons/chemical/functions/fnc_CASCreateGas.sqf @@ -18,4 +18,21 @@ params ["_posX", "_posY", "_posZ"]; -[QGVAR(createZoneGlobal), [[_posX, _posY, _posZ], 240, 15, 0]] call CBA_fnc_globalEventJIP; +private _projectile = QGVAR(logic) createVehicle [_posX,_posY,_posZ]; + +if (isServer) then { + private _radius = 15; + private _timeToLive = 240; + private _gasLevel = 1; + + [QGVAR(addGasSource), [_projectile, _radius, _gasLevel, _projectile, { + params ["_endTime", "_projectile"]; + + // If projectile no longer exists, exit + if (isNull _projectile) exitWith { + false // return + }; + + CBA_missionTime < _endTime // return + }, [CBA_missionTime + _timeToLive, _projectile]]] call CBA_fnc_serverEvent; +}; diff --git a/addons/chemical/functions/fnc_GasTripEffect.sqf b/addons/chemical/functions/fnc_GasTripEffect.sqf index 0a3a4ea80..0afe374f9 100644 --- a/addons/chemical/functions/fnc_GasTripEffect.sqf +++ b/addons/chemical/functions/fnc_GasTripEffect.sqf @@ -17,4 +17,4 @@ * Cant be called manualy! */ -[FUNC(spawnSmoke), _this] call CBA_fnc_directcall; +[FUNC(spawnSmoke), _this] call CBA_fnc_directCall; diff --git a/addons/chemical/functions/fnc_afterWait.sqf b/addons/chemical/functions/fnc_afterWait.sqf deleted file mode 100644 index a3fe41732..000000000 --- a/addons/chemical/functions/fnc_afterWait.sqf +++ /dev/null @@ -1,95 +0,0 @@ -#include "..\script_component.hpp" -/* -* Author: DiGii -* This cant be called manualy! -* Handles the Gas effect for the player -* -* Arguments: -* 0: Unit -* 1: Module -* 2: Gastype -* 3: Max_radius -* -* Return Value: -* NONE -* -* Example: -* [player, logic, 0, 50] call kat_chemical_fnc_afterWait; -* -* Public: No -*/ - -params ["_unit", "_logic", "_gastype", "_radius_max"]; - -if (!isDamageAllowed _unit) exitWith { - [_unit] call FUNC(fullHealLocal); -}; - -if ((goggles _unit) in (missionNamespace getVariable [QGVAR(availGasmaskList), []])) then { - private _isinGas = true; - [ - { - params ["_args", "_pfhHandler"]; - _args params["_unit", "_logic", "_gastype", "_radius_max", "_isinGas"]; - - if !(_isinGas) exitWith { - [_pfhHandler] call CBA_fnc_removePerFrameHandler; - }; - - private _timeleft = _unit getVariable [QGVAR(gasmask_durability), 10]; - _pos = _logic getVariable [QGVAR(gas_position), [0, 0, 0]]; - if (_unit distance _pos > _radius_max || !(_logic getVariable[QGVAR(gas_active), false]) || isNull _logic) exitWith { - _unit setVariable [QGVAR(enteredPoison), false, true]; - _isinGas = false; - }; - - if !((goggles _unit) in (missionNamespace getVariable [QGVAR(availGasmaskList), []]) && _timeleft > 0) then { - _unit setVariable [QGVAR(poisonType), _gastype, true]; - switch (_gastype) do { - case 1: { - _unit setVariable [QGVAR(CS), true, true]; - [_unit, _logic, _radius_max] call FUNC(handleCSGas); - }; - case 0: { - _unit setVariable [QGVAR(airPoisoning), true, true]; - }; - }; - _isinGas = false; - }; - - if (_timeleft <= 0 && _unit getVariable [QGVAR(enteredPoison), false]) then { - _unit setVariable [QGVAR(poisonType), _gastype, true]; - switch (_gastype) do { - case 1: { - _unit setVariable [QGVAR(CS), true, true]; - [_unit, _logic, _radius_max] call FUNC(handleCSGas); - }; - case 0: { - _unit setVariable [QGVAR(airPoisoning), true, true]; - }; - }; - _isinGas = false; - }; - - if (!(_unit getVariable [QGVAR(enteredPoison), false]) || !(_logic getVariable [QGVAR(gas_active), false])) then { - _isinGas = false; - _unit setVariable [QGVAR(enteredPoison), false]; - }; - }, - 1, - [_unit, _logic, _gastype, _radius_max, _isinGas] - ] call CBA_fnc_addPerFrameHandler; -} else { - if (_unit getVariable [QGVAR(enteredPoison), false]) then { - _unit setVariable [QGVAR(poisonType), _gastype, true]; - switch (_gastype) do { - case 1: { - _unit setVariable [QGVAR(CS), true, true]; - [_unit, _logic, _radius_max] call FUNC(handleCSGas); - }; - case 0: { - _unit setVariable [QGVAR(airPoisoning), true, true]; - }; - }; - }; -}; diff --git a/addons/chemical/functions/fnc_breathing.sqf b/addons/chemical/functions/fnc_breathing.sqf index f4ab4b46d..60c7150c8 100644 --- a/addons/chemical/functions/fnc_breathing.sqf +++ b/addons/chemical/functions/fnc_breathing.sqf @@ -2,47 +2,53 @@ /* * Author: DiGii * +* Handles the breathing sound for gasMasks +* * Arguments: * 0: Unit +* 1: Glasses Class * * Return Value: * NONE * * Example: -* [player] call kat_chemical_fnc_breathing; +* [player, "kat_mask_M50"] call kat_chemical_fnc_breathing; * * Public: No * -* Handles the breathing sound for gasMasks */ -params ["_unit"]; +params ["_unit", "_glassesClass"]; + +if !(_glassesClass in (missionNamespace getVariable [QGVAR(availGasmaskList), []])) exitWith {}; +GVAR(soundPlaying) = false; [ { - params ["_unit"]; - (goggles _unit) in (missionNamespace getVariable [QGVAR(availGasmaskList), []]) - }, - { - params ["_unit"]; - [ - { - params["_args", "_handler"]; - _args params ["_unit"]; - if (!(goggles _unit in (missionNamespace getVariable [QGVAR(availGasmaskList), []])) || !(alive _unit) || _unit getVariable [QACEGVAR(medical,heartrate), 80] <= 0) then { - [_handler] call CBA_fnc_removePerFrameHandler; - [_unit] call FUNC(breathing); + params["_args", "_handler"]; + _args params ["_unit", "_volume"]; + if (!(goggles _unit in (missionNamespace getVariable [QGVAR(availGasmaskList), []])) || !(alive _unit) || (_unit getVariable [QACEGVAR(medical,inCardiacArrest), false])) then { + [_handler] call CBA_fnc_removePerFrameHandler; + } else { + if (!GVAR(soundPlaying)) then { + if ((GET_PAIN_PERCEIVED(_unit) >= 0.4) || (_unit getVariable [QACEGVAR(medical,heartrate), 80] >= 105)) then { + playSoundUI [QPATHTOF(audio\heavyBreath.ogg), GVAR(gasMaskSoundVolume), 1]; + GVAR(soundPlaying) = true; } else { - if (GET_PAIN_PERCEIVED(_unit) >= 0.4) || (_unit getVariable[QACEGVAR(medical,heartrate), 80] >= 105) then { - _unit say3D QGVAR(mask_breath_heavy); + if (round random 1 >= 0.5) then { + playSoundUI [QPATHTOF(audio\breath1.ogg), GVAR(gasMaskSoundVolume), 1]; + GVAR(soundPlaying) = true; } else { - private _random = selectRandom[QGVAR(mask_breath_1), QGVAR(mask_breath_2)]; - _unit say3D _random; + playSoundUI [QPATHTOF(audio\breath2.ogg), GVAR(gasMaskSoundVolume), 1]; + GVAR(soundPlaying) = true; }; }; - }, - 5, - [_unit] - ] call CBA_fnc_addPerFrameHandler; + [{ + GVAR(soundPlaying) = false; + }, [], 4] call CBA_fnc_waitAndExecute; + }; + }; }, + 0, [_unit] -] call CBA_fnc_waitUntilAndExecute; +] call CBA_fnc_addPerFrameHandler; + diff --git a/addons/chemical/functions/fnc_canPutOnGasMask.sqf b/addons/chemical/functions/fnc_canPutOnGasMask.sqf new file mode 100644 index 000000000..5688a31de --- /dev/null +++ b/addons/chemical/functions/fnc_canPutOnGasMask.sqf @@ -0,0 +1,6 @@ +#include "..\script_component.hpp" + +params ["_player"]; + +(((_player call ACEFUNC(common,uniqueItems)) findAny GVAR(availGasmaskList)) != -1) && +(!((goggles _player) in GVAR(availGasmaskList))) diff --git a/addons/chemical/functions/fnc_canTakeOffGasMask.sqf b/addons/chemical/functions/fnc_canTakeOffGasMask.sqf new file mode 100644 index 000000000..67e9e48b4 --- /dev/null +++ b/addons/chemical/functions/fnc_canTakeOffGasMask.sqf @@ -0,0 +1,5 @@ +#include "..\script_component.hpp" + +params ["_player"]; + +((goggles _player) in GVAR(availGasmaskList)) diff --git a/addons/chemical/functions/fnc_changeGasMaskFilter.sqf b/addons/chemical/functions/fnc_changeGasMaskFilter.sqf index 40e73a42c..7ea103422 100644 --- a/addons/chemical/functions/fnc_changeGasMaskFilter.sqf +++ b/addons/chemical/functions/fnc_changeGasMaskFilter.sqf @@ -19,6 +19,4 @@ params ["_target"]; [_target, "AinvPknlMstpSlayWlnrDnon_medicOther"] call ACEFUNC(common,doAnimation); _target removeItem "kat_gasmaskFilter"; -_target setVariable [QGVAR(gasmask_durability),10,true]; - -_target setVariable [QGVAR(gasmask_durability_reset), true, true]; +_target setVariable [QGVAR(gasmask_durability), 10, true]; diff --git a/addons/chemical/functions/fnc_chemDetector.sqf b/addons/chemical/functions/fnc_chemDetector.sqf deleted file mode 100644 index 64d37996d..000000000 --- a/addons/chemical/functions/fnc_chemDetector.sqf +++ /dev/null @@ -1,60 +0,0 @@ -#include "..\script_component.hpp" -/* - * Author: DiGii - * - * Arguments: - * 0: Unit - * - * Return Value: - * NONE - * - * Example: - * [player] call kat_chemical_fnc_chemDetector; - * - * Public: No -*/ -params ["_unit"]; - - -[ -{ - params["_args", "_pfhHandler"]; - _args params ["_unit"]; - - "KAT_CHEM_DETECTOR" cutRsc ["RscWeaponChemicalDetector", "PLAIN", 1, false]; - private _ui = GETUVAR(RscWeaponChemicalDetector,displayNull); - private _obj = _ui displayCtrl 101; - - if ("ChemicalDetector_01_watch_F" in (assignedItems _unit)) then - { - private _percent = _unit getVariable [QGVAR(gasPercentage),0]; - private _thread = parseNumber (_percent toFixed 1); - if (_thread < 0) then { _thread = 0}; - if (_thread > 1) then { _thread = 1}; - _obj ctrlAnimateModel ["Threat_Level_Source", _thread, true]; - }; - - if (!(_unit getVariable[QGVAR(enteredPoison),false])) exitWith { - - _obj ctrlAnimateModel ["Threat_Level_Source", 0, true]; - - [_pfhHandler] call CBA_fnc_removePerFrameHandler; - }; -}, -1, [_unit]] call CBA_fnc_addPerFramehandler; - -[ -{ - params["_args", "_pfhHandler"]; - _args params ["_unit"]; - - if (_unit getVariable [QGVAR(chemDetectorState), false] && _unit getVariable [QGVAR(gasPercentage), 0] >= 0.1 && "ChemicalDetector_01_watch_F" in (assignedItems _unit)) then { - playSound3D [QPATHTOF(audio\chemDetector.ogg), _unit, false, getPosASL _unit, 4, 1, 10]; - }; - - if (!(_unit getVariable[QGVAR(enteredPoison),false])) exitWith { - [_pfhHandler] call CBA_fnc_removePerFrameHandler; - }; - -}, -6, [_unit]] call CBA_fnc_addPerFramehandler; diff --git a/addons/chemical/functions/fnc_coughing.sqf b/addons/chemical/functions/fnc_coughing.sqf deleted file mode 100644 index a841b8a36..000000000 --- a/addons/chemical/functions/fnc_coughing.sqf +++ /dev/null @@ -1,69 +0,0 @@ -#include "..\script_component.hpp" -/* - * Author: DiGii - * - * Arguments: - * 0: Unit - * - * Return Value: - * NONE - * - * Example: - * [player] call kat_chemical_fnc_coughing; - * - * Public: No -*/ -params ["_unit"]; - -[ - { - params["_unit"]; - _unit getVariable [QGVAR(airPoisoning), false] - }, - { - params["_unit"]; - private _lastcought = CBA_missionTime; - [ - { - params ["_args", "_pfhID"]; - _args params ["_unit", "_lastcought"]; - if (_unit getVariable ["ACE_isUnconscious", false] || !(alive _unit) || !(_unit getVariable [QGVAR(airPoisoning), false])) exitWith { - [_pfhID] call CBA_fnc_removePerFrameHandler; - [_unit] call FUNC(coughing); - }; - private _nextcought = random [20,50,80]; - [ - { - params["_unit","_lastcought","_nextcought"]; - (CBA_missionTime - (_unit getVariable [QGVAR(lastCought), 0])) > _nextcought - }, - { - params["_unit"]; - if (_unit getVariable [QGVAR(airPoisoning),false]) then { - _unit say3D QGVAR(cough_1); - addCamShake [3, 4, 0]; - - _unit setVariable [QGVAR(lastCought), CBA_missionTime, true]; - - private _effect = ppEffectCreate ["ChromAberration",2005]; - KAT_PAIN_EFFECT = _effect; - _unit setVariable [QGVAR(painEffect), KAT_PAIN_EFFECT, true]; - KAT_PAIN_EFFECT ppEffectAdjust [0, 0, false]; - KAT_PAIN_EFFECT ppEffectCommit 0; - KAT_PAIN_EFFECT ppEffectEnable true; - private _intensity = linearConversion [0, 1, 0.5, 0, 0.06, true]; - private _initialAdjust = [_intensity, _intensity, true]; - private _delayedAdjust = [_intensity * 0.15, _intensity * 0.15, true]; - KAT_PAIN_EFFECT ppEffectAdjust _initialAdjust; - KAT_PAIN_EFFECT ppEffectCommit 0.3; - - [{ - params ["_adjust"]; - KAT_PAIN_EFFECT ppEffectAdjust _adjust; - KAT_PAIN_EFFECT ppEffectCommit 0.7; - }, [_delayedAdjust], 3] call CBA_fnc_waitAndExecute; - }; - }, - [_unit,_lastcought,_nextcought]] call CBA_fnc_waitUntilAndExecute; - }, 1, [_unit, _lastcought]] call CBA_fnc_addPerFrameHandler; - }, [_unit]] call CBA_fnc_waitUntilAndExecute; diff --git a/addons/chemical/functions/fnc_createSealAction.sqf b/addons/chemical/functions/fnc_createSealAction.sqf index f7df5adb5..a7451dfed 100644 --- a/addons/chemical/functions/fnc_createSealAction.sqf +++ b/addons/chemical/functions/fnc_createSealAction.sqf @@ -1,6 +1,6 @@ #include "..\script_component.hpp" /* - * Author: DiGii + * Author: DiGii, MiszczuZPolski * * Arguments: * 0: Target @@ -13,7 +13,9 @@ * * Public: No */ -params ["_target", "_logic"]; +params ["_target", "_logic", "_key"]; + +[_target, 0, ["ACE_MainActions", QGVAR(sealLeak)]] call ACEFUNC(interact_menu,removeActionFromObject); private _action = [ QGVAR(sealLeak), @@ -21,20 +23,21 @@ private _action = [ "", { params ["_target", "_player", "_params"]; - _params params ["_logic"]; + _params params ["_key"]; [_player, "Acts_carFixingWheel"] call ACEFUNC(common,doAnimation); //add time to addon options [ - 20, - [_target,_player, _logic], + 5, + [_target, _player, _key], { - params["_args"]; - _args params ["_target","_player", "_logic"]; - _logic setVariable [QGVAR(gas_active), false, true]; - [_target, 0, ["ACE_MainActions", QGVAR(sealLeak)]] call ACEFUNC(interact_menu,removeActionFromObject); + params ["_args"]; + _args params ["_target","_player", "_key"]; [_player, "kat_sealant"] call ACEFUNC(common,useItem); + [QGVAR(removeGasSource), _key] call CBA_fnc_serverEvent; + _target setVariable [QGVAR(sealable), false, true]; + [_target, 0, ["ACE_MainActions", QGVAR(sealLeak)]] call ACEFUNC(interact_menu,removeActionFromObject); }, { params["_args"]; @@ -47,13 +50,18 @@ private _action = [ ] call ace_common_fnc_progressBar; }, { - params["_target","_player"]; + params ["_target","_player"]; - [_player, _target] call ACEFUNC(common,canInteractWith); - [_player, _player, ["kat_sealant"]] call ACEFUNC(medical_treatment,hasItem); + ([_player, _target] call ACEFUNC(common,canInteractWith)) && + ([_player, _player, ["kat_sealant"]] call ACEFUNC(medical_treatment,hasItem)) && + (_target getVariable [QGVAR(sealable), false]) }, {}, - [_logic] + [_key] ] call ACEFUNC(interact_menu,createAction); + [_target, 0, ["ACE_MainActions"], _action] call ACEFUNC(interact_menu,addActionToObject); + + + diff --git a/addons/chemical/functions/fnc_createZone.sqf b/addons/chemical/functions/fnc_createZone.sqf deleted file mode 100644 index bb62c4bbd..000000000 --- a/addons/chemical/functions/fnc_createZone.sqf +++ /dev/null @@ -1,36 +0,0 @@ -#include "..\script_component.hpp" -/* - * Author: DiGii - * - * Arguments: - * 0: Position (position) - * 1: Lifetime (number) - * 2: Radius (number) - * 3: GasLevel (int of gas) - * - * Return Value: - * NONE - * - * Example: - * [pos player, 60, 100, 0] call kat_chemical_fnc_createZone; - * - * Public: No - * -*/ -params ["_position", "_lifetime", "_radius", "_gasType"]; - -private _logic = "ACE_LogicDummy" createVehicle _position; - -[_logic, _position, _radius, 0, _gasType] call FUNC(gasCheck); -private _currentTime = CBA_missionTime; - -[{ - params ["_logic","_lifetime","_currentTime"]; - - (CBA_missionTime - (_currentTime)) > _lifetime -}, -{ - params ["_logic"]; - _logic setVariable [QGVAR(gas_active), false, true]; - deleteVehicle _logic; -}, [_logic, _lifetime, _currentTime]] call CBA_fnc_waitUntilAndExecute; diff --git a/addons/chemical/functions/fnc_csGrenade.sqf b/addons/chemical/functions/fnc_csGrenade.sqf index 88478a636..55657d0cb 100644 --- a/addons/chemical/functions/fnc_csGrenade.sqf +++ b/addons/chemical/functions/fnc_csGrenade.sqf @@ -1,6 +1,6 @@ #include "..\script_component.hpp" /* - * Author: DiGii + * Author: DiGii, MiszczuPolski * Spawns Patricles for the Gas zone * * Arguments: @@ -39,25 +39,12 @@ params ["_projectile", "_timeToLive", "_center"]; private _position = position _projectile; -[QGVAR(createZoneGlobal), [_position, _timeToLive, 6, 1]] call CBA_fnc_globalEventJIP; - -// --- AI -private _nearLocalEnemies = []; - -{ - { - if (local _x && {[_center, side _x] call BIS_fnc_sideIsEnemy}) then { // WE WANT THE OBJECTS SIDE HERE! - _nearLocalEnemies pushBackUnique _x; - }; - } forEach crew _x; -} forEach (_position nearObjects ALERT_NEAR_ENEMY_RANGE); - +// Alert nearby hostile AI { - if (behaviour _x in ["SAFE", "AWARE"]) then { + if (local _x && {[_center, side group _x] call BIS_fnc_sideIsEnemy} && {behaviour _x in ["SAFE", "AWARE"]}) then { // WE WANT THE OBJECT'S SIDE HERE! _x setBehaviour "COMBAT"; }; -} forEach _nearLocalEnemies; - +} forEach ([_position, ALERT_NEAR_ENEMY_RANGE, ALERT_NEAR_ENEMY_RANGE, 0, false] nearEntities [["CAManBase"], false, true, true]); private _particleSource = "#particlesource" createVehicleLocal _position; @@ -87,4 +74,23 @@ _particleSource setParticleParams [ _particleSource setParticleRandom [PARTICLE_SMOKE_LIFE_TIME / 2, [0.5 * EFFECT_SIZE, 0.5 * EFFECT_SIZE, 0.2 * EFFECT_SIZE], [0.3,0.3,0.5], 1, 0, [0,0,0,0.06], 0, 0]; _particleSource setDropInterval (1 / PARTICLE_SMOKE_DENSITY); +if (isServer) then { + private _radius = 6; + private _gasLevel = 0; + + [QGVAR(addGasSource), [_projectile, _radius, _gasLevel, _projectile, { + params ["_endTime", "_projectile"]; + + // If incendiary no longer exists, exit + if (isNull _projectile) exitWith { + false // return + }; + + // Need to get the position every time, as grenade might have been moved + private _position = position _projectile; + + CBA_missionTime < _endTime // return + }, [CBA_missionTime + _timeToLive, _projectile]]] call CBA_fnc_serverEvent; +}; + [{deleteVehicle _this}, _particleSource, _timeToLive] call CBA_fnc_waitAndExecute; diff --git a/addons/chemical/functions/fnc_fullHealLocal.sqf b/addons/chemical/functions/fnc_fullHealLocal.sqf index e0cd29a97..e749952a0 100644 --- a/addons/chemical/functions/fnc_fullHealLocal.sqf +++ b/addons/chemical/functions/fnc_fullHealLocal.sqf @@ -18,12 +18,6 @@ params ["_patient"]; TRACE_1("fullHealLocal kat chemical",_patient); -_patient setVariable [QGVAR(enteredPoison), false, true]; -_patient setVariable [QGVAR(timeleft), missionNamespace getVariable [QGVAR(infectionTime),60], true]; -_patient setVariable [QGVAR(poisonType), "", true]; -_patient setVariable [QGVAR(airPoisoning), false, true]; -_patient setVariable [QGVAR(CS), false, true]; _patient setVariable [QGVAR(gasmask_durability), 10, true]; -if (_patient getVariable [QGVAR(painEffect),0] != 0) then { - KAT_PAIN_EFFECT ppEffectEnable false; -}; +_patient setVariable [QGVAR(CSGas), 0, true]; +_patient setVariable [QGVAR(airPoisoning), false, true]; diff --git a/addons/chemical/functions/fnc_gasAI.sqf b/addons/chemical/functions/fnc_gasAI.sqf deleted file mode 100644 index 499890608..000000000 --- a/addons/chemical/functions/fnc_gasAI.sqf +++ /dev/null @@ -1,113 +0,0 @@ -#include "..\script_component.hpp" -/* - * Author: DiGii - * This cant be called manualy! - * Handles the Gas effect for the AI - * - * Arguments: - * 0: Target - * 1: Module - * 2: Position - * 3: Radius - * 4: GasType - * - * Return Value: - * NONE - * - * Example: - * [player, logic, getPos player, 50, 0] call kat_chemical_fnc_gasAI; - * - * Public: No -*/ - -params ["_unit", "_logic", "_pos", "_radius_max", "_gastype"]; - -if (!isDamageAllowed _unit) exitWith { - [_unit] call FUNC(fullHealLocal); -}; - -[ - { - params["_args","_handler"]; - _args params ["_logic","_unit"]; - if (!(_logic getVariable [QGVAR(gas_active),false]) || !(alive _unit) || isNull _unit) then { - _unit setVariable [QGVAR(enteredPoison), false, true]; - [_handler] call CBA_fnc_removePerFrameHandler; - }; - }, - 3, - [_logic,_unit] -] call CBA_fnc_addPerFrameHandler; - -[ - { - params["_args","_handler"]; - _args params ["_unit", "_logic", "_pos", "_radius_max", "_gastype"]; - - if (!(_logic getVariable [QGVAR(gas_active), false]) || isNull _logic || !(alive _unit) || _unit getVariable ["ACE_isUnconscious", false]) exitWith { - [_handler] call CBA_fnc_removePerFrameHandler; - }; - - if ((_unit distance _pos) <= _radius_max && !(_unit getVariable [QGVAR(enteredPoison), false])) then { - _unit setVariable [QGVAR(enteredPoison), true, true]; - private _skill = _unit skill "aimingAccuracy"; - private _fnc_afterwait = { - params ["_unit", "_gastype", "_pos", "_skill"]; - - if !((goggles _unit) in (missionNamespace getVariable [QGVAR(availGasmaskList), []])) exitWith { - if (_gastype isEqualTo 1) then { - if (_unit distance _pos < 10 && _unit getVariable [QGVAR(enteredPoison), false]) then { - _unit say3D QGVAR(cough_1); - _unit setSkill ["aimingAccuracy", 0.001]; - [ - { - params["_unit", "_skill"]; - _unit setSkill ["aimingAccuracy", _skill]; - }, - [_unit, _skill], - 30 - ] call CBA_fnc_waitAndExecute; - }; - } else { - if (ACEGVAR(medical_statemachine,AIUnconsciousness)) then { - for "_i" from 0 to 10 step 1 do { - [ - { - params["_unit"]; - [_unit, "PoisenBP", 300, 30, -10, 0, -10] call ACEFUNC(medical_status,addMedicationAdjustment); - }, - [_unit], - 5 - ] call CBA_fnc_waitAndExecute; - }; - } else { - [{ - private _unit = _this select 0; - _unit setDamage 1; - }, [_unit], 20]call CBA_fnc_waitAndExecute; - }; - }; - }; - }; - private _timeleft = 30; - for "_i" from 0 to 1 step 0 do { - _timeleft = _timeleft - 1; - if (_timeleft <= 0) exitWith { - [_unit, _gastype, _pos, _skill] call _fnc_afterwait; - _i = 2; - }; - if (_gastype isEqualTo 1) exitWith { - [_unit, _gastype, _pos, _skill] call _fnc_afterwait; - _i = 2; - }; - _pos = _logic getVariable [QGVAR(gas_position), [0, 0, 0]]; - if (_unit distance _pos > _radius_max || !(_logic getVariable [QGVAR(gas_active), false]) || isNull _logic) exitWith { - _unit setVariable [QGVAR(enteredPoison), false, true]; - _i = 2; - }; - }; - }; - }, - 5, - [_unit,_logic,_pos,_radius_max,_gastype] -] call CBA_fnc_addPerFrameHandler; diff --git a/addons/chemical/functions/fnc_gasCheck.sqf b/addons/chemical/functions/fnc_gasCheck.sqf deleted file mode 100644 index f08c7d5e9..000000000 --- a/addons/chemical/functions/fnc_gasCheck.sqf +++ /dev/null @@ -1,96 +0,0 @@ -#include "..\script_component.hpp" -/* - * Author: DiGii - * This cannot be called manually! - * - * Arguments: - * 0: Module - * 1: Position - * 2: Max_Radius - * 3: Min_Radius - * 4: GasType - * - * Return Value: - * NONE - * - * Example: - * [logic, getPos player, 50, 20, 1] call kat_chemical_fnc_gasCheck; - * - * Public: No - */ - -params ["_logic", "_position", "_radius_max", "_radius_min", "_gasType"]; - -// Set default values if needed -_radius_min = if (_radius_min isEqualTo 0) then {_radius_max / 2} else {_radius_min}; - -_logic setVariable [QGVAR(gas_active), true, true]; -_logic setVariable [QGVAR(gas_playerArr), [], true]; -_logic setVariable [QGVAR(gas_position), _position, true]; -_logic setVariable [QGVAR(gas_radius), _radius_max, true]; - -// Function to check players within the gas zone -private _checkPlayers = { - params ["_args"]; - _args params ["_logic", "_position", "_radius_max", "_radius_min", "_gasType"]; - private _playerArr = _logic getVariable [QGVAR(gas_playerArr), []]; - private _allUnits = if (missionNamespace getVariable [QGVAR(affectAI), false]) then {allUnits} else {allPlayers}; - - - { - if (!isDamageAllowed _x) then { - [_x] call FUNC(fullHealLocal); - continue; - }; - - _position = if ((toString (_position) != toString (getPos _logic))) then {getPos _logic} else {_position}; - _logic setVariable [QGVAR(gas_position), _position, true]; - - private _distance = _x distance _position; - - if (isPlayer _x) then { - if (_x getVariable [QGVAR(isTreated), false]) then { - _x setVariable [QGVAR(isTreated), false, true]; - - _playerArr deleteAt (_playerArr find _x); - _logic setVariable [QGVAR(gas_playerArr), _playerArr, true]; - }; - - if (!(_x in _playerArr) && _distance < _radius_max) then { - _playerArr pushBack _x; - - _logic setVariable [QGVAR(gas_playerArr), _playerArr, true]; - [QGVAR(gasPlayer), [_x, _logic, _position, _radius_max, _radius_min, _gasType], _x] call CBA_fnc_targetEvent; - } else { - if (_x in _playerArr && _distance > _radius_max) then { - - _playerArr deleteAt (_playerArr find _x); - _logic setVariable [QGVAR(gas_playerArr), _playerArr, true]; - }; - }; - } else { - if (_distance < _radius_max && alive _x && !(_x getVariable [QGVAR(enteredPoison), false])) then { - [QGVAR(gasAI), [_x, _logic, _position, _radius_max, _gasType], _x] call CBA_fnc_targetEvent; - }; - }; - } forEach _allUnits; -}; - -// Add per frame handler to check players -private _handle = [_checkPlayers, 3, [_logic, _position, _radius_max, _radius_min, _gasType]] call CBA_fnc_addPerFrameHandler; - -// Remove handler when logic is no longer valid -[ - { - params ["_args", "_pfhHandle"]; - _args params ["_logic", "_handle"]; - - if (isNull _logic || !alive _logic || !(_logic getVariable [QGVAR(gas_active), false])) exitWith { - _logic setVariable [QGVAR(gas_active), false, true]; - [_handle] call CBA_fnc_removePerFrameHandler; - [_pfhHandle] call CBA_fnc_removePerFrameHandler; - }; - }, - 0, - [_logic, _handle] -] call CBA_fnc_addPerFrameHandler; diff --git a/addons/chemical/functions/fnc_gasCheckLocal.sqf b/addons/chemical/functions/fnc_gasCheckLocal.sqf deleted file mode 100644 index 769499f66..000000000 --- a/addons/chemical/functions/fnc_gasCheckLocal.sqf +++ /dev/null @@ -1,92 +0,0 @@ -#include "..\script_component.hpp" -/* -* Author: DiGii -* This cannot be called manually! -* Handles the Gas effect for the player -* -* Arguments: -* 0: Target -* 1: Module -* 2: Position -* 3: Max_radius -* 4: Min_radius -* 5: Gastype -* -* Return Value: -* NONE -* -* Example: -* [player, logic, getPos player, 50, 20, 0] call kat_chemical_fnc_gasChecklocal; -* -* Public: No -*/ - -params ["_unit", "_logic", "_position", "_radius_max", "_radius_min", "_gasType"]; - -if (!isDamageAllowed _unit) exitWith { - [_unit] call FUNC(fullHealLocal); -}; - -private _timeEntered = CBA_MissionTime; - -// Function to handle the per-frame logic for gas effects - -[{ - params ["_args", "_handler"]; - _args params ["_logic", "_unit", "_position"]; - - if (_unit getVariable [QGVAR(isTreated), false] || !(_logic getVariable [QGVAR(gas_active), false])) exitWith { - _unit setVariable [QGVAR(enteredPoison), false, true]; - [_handler] call CBA_fnc_removePerFrameHandler; - }; - -}, 3, [_logic, _unit, _position]] call CBA_fnc_addPerFrameHandler; - -[{ - params ["_args", "_handler"]; - _args params ["_unit", "_logic", "_position", "_radius_max", "_radius_min", "_gasType", "_timeEntered"]; - - if (!(_logic getVariable [QGVAR(gas_active), false]) || isNull _logic || _unit getVariable [QGVAR(isTreated), false]) exitWith { - [_handler] call CBA_fnc_removePerFrameHandler; - }; - - _position = _logic getVariable [QGVAR(gas_position), [0, 0, 0]]; - private _distance = _unit distance _position; - private _min_to_max = _radius_max - _radius_min; - private _dis_to_min = _distance - _radius_min; - private _percent = 0; - - if (_distance > _radius_min) then { - _percent = _dis_to_min / _min_to_max; - }; - - private _timeLeft = _unit getVariable [QGVAR(timeleft), 0]; - if (_timeLeft <= 0) exitWith - { - [_handler] call CBA_fnc_removePerFrameHandler; - [QGVAR(afterWait), [_unit, _logic, _gastype, _radius_max], _unit] call CBA_fnc_targetEvent; - _unit setVariable [QGVAR(timeleft), 0]; - }; - - if (_distance < _radius_max) then { - if !(_unit getVariable [QGVAR(enteredPoison), false]) then { - _unit setVariable [QGVAR(enteredPoison), true, true]; - [QGVAR(enteredZone), [_unit], _unit] call CBA_fnc_targetEvent; - _unit setVariable [QGVAR(Poisen_logic), _logic, true]; - }; - - _timeLeft = (missionNamespace getVariable [QGVAR(infectionTime),60]) - (CBA_MissionTime - _timeEntered); - _unit setVariable [QGVAR(timeleft), _timeLeft]; - }; - - if (_distance > _radius_max || !(_logic getVariable [QGVAR(gas_active), false]) || isNull _logic) then { - _unit setVariable [QGVAR(enteredPoison), false, true]; - [_handler] call CBA_fnc_removePerFrameHandler; - }; - - if (_gasType isEqualTo 1) then { - [_handler] call CBA_fnc_removePerFrameHandler; - [QGVAR(afterWait), [_unit, _logic, _gasType, _radius_max], _unit] call CBA_fnc_targetEvent; - }; - -}, 2, [_unit, _logic, _position, _radius_max, _radius_min, _gasType, _timeEntered]] call CBA_fnc_addPerFrameHandler; diff --git a/addons/chemical/functions/fnc_gasManagerPFH.sqf b/addons/chemical/functions/fnc_gasManagerPFH.sqf new file mode 100644 index 000000000..f4fb22083 --- /dev/null +++ b/addons/chemical/functions/fnc_gasManagerPFH.sqf @@ -0,0 +1,52 @@ +#include "..\script_component.hpp" +/* + * Author: tcvm, johnb43 + * Modified by: MiszczuZPolski + * Handles various objects on gas and determines if units close to objects deserve to get poisoned + * + * Arguments: + * None + * + * Return Value: + * None + * + * Example: + * kat_chemical_fnc_gasManagerPFH call CBA_fnc_addPerFrameHandler + * + * Public: No + */ + +{ + _y params ["_gasLogic", "_radius", "_gasLevel", "_condition", "_conditionArgs", "_isSealable"]; + TRACE_2("gasManagerPFH loop",_x,_y); + + // Remove when condition is no longer valid + if !(_conditionArgs call _condition) then { + TRACE_2("condition no longer valid, deleting",_x,_y); + + detach _gasLogic; + deleteVehicle _gasLogic; + + GVAR(gasSources) deleteAt _x; + + continue; + }; + + // Poison units (alive or dead) close to the gas source + { + + // Get the distance of the unit from the center of the sphere (_gasLogic) + private _distance = _x distance _gasLogic; + + // Ensure the distance does not exceed the radius (prevents going beyond the sphere) + _distance = _distance min _radius; + + // Calculate the intensity as a normalized value (1 at center, 0 at the edge) + private _intensity = 1 - (_distance / _radius); + + _x setVariable [QGVAR(areaIntensity), _intensity, true]; + + [QGVAR(poison), [_x, _gasLevel], _x] call CBA_fnc_targetEvent; + + } forEach nearestObjects [_gasLogic, ["CAManBase"], _radius]; +} forEach GVAR(gasSources); diff --git a/addons/chemical/functions/fnc_gasmodule.sqf b/addons/chemical/functions/fnc_gasmodule.sqf index ad0f34dd4..f80c2fe21 100644 --- a/addons/chemical/functions/fnc_gasmodule.sqf +++ b/addons/chemical/functions/fnc_gasmodule.sqf @@ -1,6 +1,6 @@ #include "..\script_component.hpp" /* -* Author: DiGii +* Author: DiGii, MiszczuZPolski * This cant be called manualy! * * Arguments: @@ -16,23 +16,32 @@ * * Public: No */ +params ["_logic", "_units", "_activated"]; -private _logic = param [0, objNull, [objNull]]; -private _activated = param [2, true, [true]]; -private _radius_max = _logic getVariable ["Radius_Max", 20]; -private _radius_min = _logic getVariable ["Radius_Min", 10]; -private _gastype = _logic getVariable ["GAS_type", 0]; +private _radius = _logic getVariable ["Radius", 20]; +private _gasLevel = _logic getVariable ["GAS_type", 0]; private _isSealable = _logic getVariable ["IsSealable", false]; -if (_activated) then { - if (count synchronizedObjects _logic > 0) then { - private _object = (synchronizedObjects _logic) select 0; - if (_isSealable) then { - [QGVAR(createSealActionGlobal), [_object, _logic]] call CBA_fnc_globalEventJIP; - }; - - [_object, getPos _object, _radius_max, _radius_min, _gastype] call FUNC(gasCheck); - } else { - [_logic, getPos _logic, _radius_max, _radius_min, _gastype] call FUNC(gasCheck); - }; +if (!_activated) exitWith {}; +if (isServer) then { + + [{ + params ["_logic", "_radius", "_gasLevel", "_isSealable", "_units"]; + + { + [QGVAR(addGasSource), [_x, _radius, _gasLevel, _x, { + params ["_endTime", "_logic"]; + + // If logic no longer exists, exit + if (isNull _logic) exitWith { + false // returns + }; + + CBA_missionTime < _endTime // return + }, [CBA_missionTime + 1e10, _logic], _isSealable]] call CBA_fnc_serverEvent; + + } forEach _units; + + }, [_logic, _radius, _gasLevel, _isSealable, _units], 1] call CBA_fnc_waitAndExecute; + }; diff --git a/addons/chemical/functions/fnc_getChemDetectorState.sqf b/addons/chemical/functions/fnc_getChemDetectorState.sqf deleted file mode 100644 index 528657971..000000000 --- a/addons/chemical/functions/fnc_getChemDetectorState.sqf +++ /dev/null @@ -1,21 +0,0 @@ -#include "..\script_component.hpp" -/* - * Author: DiGii - * - * Arguments: - * 0: Unit - * 1: Is On/Off - * - * Return Value: - * NONE - * - * Example: - * [] call kat_chemical_fnc_getChemDetectorState; - * - * Public: No -*/ -params ["_unit", "_isOnOff"]; - -private _currentState = _unit getVariable [QGVAR(chemDetectorState), false]; - -[false, true] select ("ChemicalDetector_01_watch_F" in (assignedItems _unit) && _currentState == _isOnOff); \ No newline at end of file diff --git a/addons/chemical/functions/fnc_handleCSGas.sqf b/addons/chemical/functions/fnc_handleCSGas.sqf deleted file mode 100644 index 3a4e01174..000000000 --- a/addons/chemical/functions/fnc_handleCSGas.sqf +++ /dev/null @@ -1,64 +0,0 @@ -#include "..\script_component.hpp" -/* - * Author: DiGii - * - * Arguments: - * 0: Logic - * 1: Radius - * - * Return Value: - * NONE - * - * Example: - * [player, logic, 10] call kat_chemical_fnc_handleCSGas; - * - * Public: No -*/ -params ["_unit", "_logic", "_radius"]; - -[{ - params["_args","_handler"]; - _args params ["_unit"]; - - if (!isDamageAllowed _unit) exitWith { - [_unit] call FUNC(fullHealLocal); - }; - - if (_unit getVariable [QGVAR(enteredPoison), false]) then { - if (_unit getVariable [QACEGVAR(medical,pain), 0] < 0.25) then {_unit setVariable [QACEGVAR(medical,pain), 0.41]}; - if ((goggles _unit) in (missionNamespace getVariable [QGVAR(availGasmaskList), []])) then {_unit setVariable[QGVAR(enteredPoison), false, true]}; - _unit setVariable [QGVAR(CS), true, true]; - _unit say3D QGVAR(cough_1); - if (hasInterface) then { - private _rndBlur = selectRandom [5, 6, 7, 8]; - ppBlur ppEffectAdjust [_rndBlur]; - ppBlur ppEffectEnable true; - ppBlur ppEffectCommit 5; - }; - } else { - if (hasInterface) then { - ppBlur ppEffectAdjust [0]; - ppBlur ppEffectEnable true; - ppBlur ppEffectCommit 20; - }; - _unit setVariable [QGVAR(CS), false, true]; - [_handler] call CBA_fnc_removePerFrameHandler; - - }; -}, 5, [_unit]] call CBA_fnc_addPerFrameHandler; - -//Position Check -[{ - params ["_param","_handler"]; - _param params ["_logic", "_radius", "_unit"]; - - if (!isDamageAllowed _unit) exitWith { - [_unit] call FUNC(fullHealLocal); - }; - - private _position = _logic getVariable [QGVAR(gas_position), [0,0,0]]; - if ( _unit distance _position > _radius || !(_logic getVariable[QGVAR(gas_active),false]) || isNull _logic ) exitWith { - _unit setVariable [QGVAR(enteredPoison), false, true]; - [_handler] call CBA_fnc_removePerFrameHandler; - }; -}, 2, [_logic, _radius, _unit]] call CBA_fnc_addPerFrameHandler; diff --git a/addons/chemical/functions/fnc_handleFired.sqf b/addons/chemical/functions/fnc_handleFired.sqf index a531b1cb5..03b934ec0 100644 --- a/addons/chemical/functions/fnc_handleFired.sqf +++ b/addons/chemical/functions/fnc_handleFired.sqf @@ -33,18 +33,21 @@ private _configClass = (configFile >> "CfgAmmo" >> _ammo); private _lifetime = [_configClass, "KAT_lifetime", 60] call BIS_fnc_returnConfigEntry; private _radius = [_configClass, "KAT_radius", 10] call BIS_fnc_returnConfigEntry; -private _gasLvL = [_configClass, "KAT_toxicLvL", 1] call BIS_fnc_returnConfigEntry; +private _gasLevel = [_configClass, "KAT_toxicLvL", 1] call BIS_fnc_returnConfigEntry; [{ params ["_args", "_handler"]; - _args params ["_projectile", "_posArr", "_gasInfo"]; - _gasInfo params ["_lifetime", "_radius", "_gasLvL"]; + _args params ["_projectile", "_gasInfo"]; + _gasInfo params ["_lifetime", "_radius", "_gasLeveL"]; - if (!isNull _projectile) exitWith { - _args set [1, getPos _projectile]; + if (isNull _projectile || {!alive _projectile}) exitWith { + [_handler] call CBA_fnc_removePerFrameHandler; }; - [QGVAR(createZoneGlobal), [_posArr, _lifetime, _radius, _gasLvL]] call CBA_fnc_globalEventJIP; + [QGVAR(addGasSource), [_projectile, _radius, _gasLevel, _projectile, { + params ["_endTime"]; - [_handler] call CBA_fnc_removePerFrameHandler; -}, 0, [_projectile, [0, 0, 0], [_lifetime, _radius, _gasLvL]]] call CBA_fnc_addPerFrameHandler; + CBA_missionTime < _endTime // return + }, [CBA_missionTime + _lifetime]]] call CBA_fnc_serverEvent; + +}, 0, [_projectile, [_lifetime, _radius, _gasLevel]]] call CBA_fnc_addPerFrameHandler; diff --git a/addons/chemical/functions/fnc_handleGasMaskDur.sqf b/addons/chemical/functions/fnc_handleGasMaskDur.sqf index 133fbfd2e..1b0d62ca6 100644 --- a/addons/chemical/functions/fnc_handleGasMaskDur.sqf +++ b/addons/chemical/functions/fnc_handleGasMaskDur.sqf @@ -1,6 +1,6 @@ #include "..\script_component.hpp" /* - * Author: DiGii + * Author: MiszczuZPolski * * Arguments: * 0: Unit @@ -9,66 +9,42 @@ * NONE * * Example: - * [player] call kat_chemical_fnc_handleGasMAskDur; + * [player] call kat_chemical_fnc_handleGasMaskDur; * * Public: No */ params ["_unit"]; -[ - { - params["_unit"]; - !(missionNamespace getVariable [QGVAR(availGasmaskList), []] isEqualTo []) && _unit getVariable [QGVAR(enteredPoison), false] - }, - { - params["_unit"]; - if (_unit getVariable [QGVAR(enteredPoison), false] && (goggles _unit) in (missionNamespace getVariable [QGVAR(availGasmaskList), []])) then { - private _timeEntered = CBA_missionTime; - private _maxTime = missionNamespace getVariable [QGVAR(gasmask_durability), 900]; - private _currentDurability = _unit getVariable [QGVAR(gasmask_durability), 10]; - [{ - params ["_args","_handler"]; - _args params ["_unit","_timeEntered","_maxTime","_currentDurability"]; - private _currentDurability = _unit getVariable [QGVAR(gasmask_durability), 10]; +if !(goggles _unit in (missionNamespace getVariable [QGVAR(availGasmaskList), []])) exitWith {}; - if (_unit getVariable [QGVAR(gasmask_durability_reset), false]) then { - _unit setVariable [QGVAR(gasmask_durability_reset), false, true]; - [_handler] call CBA_fnc_removePerFrameHandler; - [_unit] call FUNC(handleGasMaskDur); - }; +// Get the maximum time the gas mask filter can last (from settings) +private _maxTime = missionNamespace getVariable [QGVAR(gasmask_durability), 60]; // Max durability in seconds - private _timeLeft = _maxTime - (CBA_missionTime - _timeEntered); - private _percent = round ((10/_maxTime) * _timeLeft); +// Get the current health (0-10) of the gas mask filter for this unit +private _currentHealth = _unit getVariable [QGVAR(gasmask_durability), 10]; // Default to full health (10) if not set - if (_currentDurability != _percent) then { - _unit setVariable [QGVAR(gasmask_durability), _percent, true]; - }; +// Scale the current health (0-10) to the actual time left based on maxTime +private _timeLeft = (_currentHealth / 10) * _maxTime; // Convert 0-10 health scale to time left - if (_currentDurability <= 0 || _percent <= 0 || !(alive _unit)) exitWith { - [_handler] call CBA_fnc_removePerFrameHandler; - _unit setVariable [QGVAR(gasmask_durability), 0, true]; - [_unit] call FUNC(handleGasMaskDur); - }; +// Reduce the time left by 1 seconds (each tick reduces by 1 seconds) +_timeLeft = _timeLeft - 1; - if !(_unit getVariable [QGVAR(enteredPoison), false]) exitWith{ - [_handler] call CBA_fnc_removePerFrameHandler; - [_unit] call FUNC(handleGasMaskDur); - }; +// Prevent negative durability +_timeLeft = _timeLeft max 0; - },1,[_unit,_timeEntered,_maxTime,_currentDurability]] call CBA_fnc_addPerFrameHandler; - } else { - [ - { - params ["_unit"]; - _unit getVariable [QGVAR(enteredPoison), false] || (goggles _unit) in (missionNamespace getVariable [QGVAR(availGasmaskList), []]) - }, - { - [_unit] call FUNC(handleGasMaskDur); - }, - [_unit] - ] call CBA_fnc_waitUntilAndExecute; - }; - }, - [_unit] -] call CBA_fnc_waitUntilAndExecute; +// Convert the remaining time back to the 0-10 health scale +private _newHealth = (_timeLeft / _maxTime) * 10; + +// Calculate percentage of health remaining +private _percent = (_newHealth / 10) * 100; + +// Exit if the gas mask health reaches 0 or the unit is dead +if (_newHealth <= 0) exitWith { + _unit setVariable [QGVAR(gasmask_durability), 0, true]; +}; + +// Update the gas mask health if it has changed +if (_currentHealth != _newHealth) then { + _unit setVariable [QGVAR(gasmask_durability), _newHealth, true]; +}; diff --git a/addons/chemical/functions/fnc_handleRespawn.sqf b/addons/chemical/functions/fnc_handleRespawn.sqf index c52862d13..5eb95a8a5 100644 --- a/addons/chemical/functions/fnc_handleRespawn.sqf +++ b/addons/chemical/functions/fnc_handleRespawn.sqf @@ -11,7 +11,7 @@ * None * * Example: - * [alive, body] call kat_misc_fnc_handleRespawn; + * [alive, body] call kat_chemical_fnc_handleRespawn; * * Public: No */ @@ -29,3 +29,5 @@ params ["_unit"]; private _ui = uiNamespace getVariable "RscWeaponChemicalDetector"; private _obj = _ui displayCtrl 101; _obj ctrlAnimateModel ["Threat_Level_Source", 0, true]; + +_unit setVariable [QGVAR(lastSoundTime), CBA_missionTime, true]; diff --git a/addons/chemical/functions/fnc_init.sqf b/addons/chemical/functions/fnc_init.sqf index f5905b8df..d38a0f3d7 100644 --- a/addons/chemical/functions/fnc_init.sqf +++ b/addons/chemical/functions/fnc_init.sqf @@ -19,22 +19,4 @@ if (!local _unit) exitWith {}; [_unit] call FUNC(fullHealLocal); -[_unit] call FUNC(coughing); -[_unit] call FUNC(handleGasMaskDur); -[_unit] call FUNC(breathing); - -[{ - params ["_args", "_pfhID"]; - _args params ["_unit"]; - private _playertime = _unit getVariable [QGVAR(timeleft), 60]; - private _maxtime = missionNamespace getVariable [QGVAR(infectionTime), 60]; - if (!(_unit getVariable [QGVAR(enteredPoison), false])) then { - if (_playertime < missionNamespace getVariable [QGVAR(infectionTime), 60]) then { - _playertime = _playertime + 1; - if (_playertime >= _maxtime) then { - _playertime = _maxtime; - }; - _unit setVariable[QGVAR(timeleft), _playertime, true]; - }; - }; -}, 2, _unit]call CBA_fnc_addPerFrameHandler; +_unit setVariable [QGVAR(lastSoundTime), CBA_missionTime, true]; diff --git a/addons/chemical/functions/fnc_poison.sqf b/addons/chemical/functions/fnc_poison.sqf new file mode 100644 index 000000000..e5719029c --- /dev/null +++ b/addons/chemical/functions/fnc_poison.sqf @@ -0,0 +1,51 @@ +#include "..\script_component.hpp" +/* + * Author: MiszczuZPolski + * Handles various objects on fire and determines if units close to objects deserve to get burned. + * + * Arguments: + * None + * + * Return Value: + * None + * + * Example: + * ace_fire_fnc_fireManagerPFH call CBA_fnc_addPerFrameHandler + * + * Public: No + */ + +params ["_unit", "_gasLevel"]; + +// Check if unit is remote (objNull is remote) +if (!local _unit) exitWith { + TRACE_1("unit is null or not local",_unit); +}; + +// Check if the unit can poison (takes care of spectators and curators) +if (getNumber (configOf _unit >> "isPlayableLogic") == 1 || {!(_unit isKindOf "CAManBase")}) exitWith { + TRACE_1("unit is virtual or not a man",_unit); +}; + +// If unit is invulnerable, don't poison the unit +if !(isDamageAllowed _unit && {_unit getVariable [QACEGVAR(medical,allowDamage), true]}) exitWith { + TRACE_1("unit is invulnerable",_unit); +}; + +if ((goggles _unit in (missionNamespace getVariable [QGVAR(availGasmaskList), []])) && {_unit getVariable [QGVAR(gasmask_durability), 10] > 0}) exitWith { + TRACE_1("unit has gas mask",_unit); + [QGVAR(handleGasMaskDur), _unit, _unit] call CBA_fnc_targetEvent; +}; + +switch (_gasLevel) do { + case 0: { + _unit setVariable [QGVAR(CSGas), 30, true]; + if (random 1 <= GVAR(tearGasDropChance)) then { + [QACEGVAR(hitreactions,dropWeapon), _unit, _unit] call CBA_fnc_targetEvent; + }; + }; + case 1: { + _unit setVariable [QGVAR(airPoisoning), true, true]; + }; + default {}; +}; diff --git a/addons/chemical/functions/fnc_putOnGasMask.sqf b/addons/chemical/functions/fnc_putOnGasMask.sqf new file mode 100644 index 000000000..878ba9f62 --- /dev/null +++ b/addons/chemical/functions/fnc_putOnGasMask.sqf @@ -0,0 +1,13 @@ +#include "..\script_component.hpp" + +params ["_player"]; + +private _itemList = _player call ACEFUNC(common,uniqueItems); + +{ + if (_x in GVAR(availGasmaskList)) then { + _player assignItem _x; + break; + }; + +} forEach _itemList; diff --git a/addons/chemical/functions/fnc_showChemDetector.sqf b/addons/chemical/functions/fnc_showChemDetector.sqf index 6b0e51908..8905a6f9a 100644 --- a/addons/chemical/functions/fnc_showChemDetector.sqf +++ b/addons/chemical/functions/fnc_showChemDetector.sqf @@ -50,17 +50,26 @@ private _exposure = _display displayCtrl 18805; private _hour = floor dayTime; private _minute = floor ((dayTime - _hour) * 60); - _time ctrlSetText (format ["%1:%2", [_hour, 2] call CBA_fnc_formatNumber, [_minute, 2] call CBA_fnc_formatNumber]); + _time ctrlSetText (format ["%1:%2", [_hour, 2] call CBA_fnc_formatNumber, [_minute, 2] call CBA_fnc_formatNumber]); - private _gas = nearestObjects [_unit, ["kat_module_zeus_gas"], 2000]; + private _intensity = _unit getVariable [QGVAR(areaIntensity), 0]; - if ((count _gas) > 0) then { - private _distance = _unit distance (_gas select 0); - private _radius = (_gas select 0) getVariable [QGVAR(gas_radius), 0]; + _exposure ctrlSetText (_intensity toFixed 2); - _exposure ctrlSetText ((linearConversion[0, _radius, _distance, 1, 0, true]) toFixed 2); + if (_intensity > 0.1) then { + private _lastSoundTime = _unit getVariable QGVAR(lastSoundTime); + + if (isNil "_lastSoundTime") then { + TRACE_1("undefined lastSoundTime: setting to current time",_lastSoundTime); + _unit setVariable [QGVAR(lastSoundTime), CBA_missionTime]; + }; + + if (CBA_missionTime - _lastSoundTime > 6) exitWith { + playSound3D [QPATHTOF(audio\chemDetector.ogg), _unit, false, getPosASL _unit, 4, 1, 10]; + _unit setVariable [QGVAR(lastSoundTime), CBA_missionTime]; + }; } else { - _exposure ctrlSetText str (0); + _unit setVariable [QGVAR(areaIntensity), 0, true]; }; }, 1, [ diff --git a/addons/chemical/functions/fnc_spawnSmoke.sqf b/addons/chemical/functions/fnc_spawnSmoke.sqf index de25e2343..67cb83127 100644 --- a/addons/chemical/functions/fnc_spawnSmoke.sqf +++ b/addons/chemical/functions/fnc_spawnSmoke.sqf @@ -23,6 +23,20 @@ private _smoke = "KAT_GASTrip_SmokeEffect" createVehicle [_posX,_posY,_posZ]; hideObjectGlobal _smoke; [_smoke, 0, ["ACE_MainActions", "ACTION"]] call ACEFUNC(interact_menu,removeActionFromObject); -private _pos = [_posX,_posY,_posZ]; +if (isServer) then { + private _timeToLive = 10; + private _radius = 10; + private _gasLevel = 1; + + [QGVAR(addGasSource), [_smoke, _radius, _gasLevel, _smoke, { + params ["_endTime", "_smoke"]; + + // If smoke no longer exists, exit + if (isNull _smoke) exitWith { + false // return + }; + + CBA_missionTime < _endTime // return + }, [CBA_missionTime + _timeToLive, _smoke]]] call CBA_fnc_serverEvent; +}; -[QGVAR(createZoneGlobal), [_pos, 240, 5, 0]] call CBA_fnc_globalEventJIP; diff --git a/addons/chemical/functions/fnc_takeOffGasMask.sqf b/addons/chemical/functions/fnc_takeOffGasMask.sqf new file mode 100644 index 000000000..0d64c4bce --- /dev/null +++ b/addons/chemical/functions/fnc_takeOffGasMask.sqf @@ -0,0 +1,5 @@ +#include "..\script_component.hpp" + +params ["_player"]; + +_player unassignItem (goggles _player); diff --git a/addons/chemical/functions/fnc_treatmentAdvanced_AtropineLocal.sqf b/addons/chemical/functions/fnc_treatmentAdvanced_AtropineLocal.sqf index ede9e02ae..fd15874e9 100644 --- a/addons/chemical/functions/fnc_treatmentAdvanced_AtropineLocal.sqf +++ b/addons/chemical/functions/fnc_treatmentAdvanced_AtropineLocal.sqf @@ -18,9 +18,3 @@ params ["_patient"]; _patient setVariable [QGVAR(airPoisoning), false, true]; -_patient setVariable [QGVAR(isTreated), true, true]; -_patient setVariable [QGVAR(enteredPoison), false, true]; -_patient setVariable [QGVAR(timeleft), missionNamespace getVariable [QGVAR(infectionTime), 60], true]; -if (_patient getVariable [QGVAR(painEffect),0] != 0) then { - KAT_PAIN_EFFECT ppEffectEnable false; -}; diff --git a/addons/chemical/functions/fnc_ui_gasModule.sqf b/addons/chemical/functions/fnc_ui_gasModule.sqf index 167f12e33..c359f333a 100644 --- a/addons/chemical/functions/fnc_ui_gasModule.sqf +++ b/addons/chemical/functions/fnc_ui_gasModule.sqf @@ -1,6 +1,6 @@ #include "..\script_component.hpp" /* - * Author: DiGii + * Author: DiGii, MiszczuZPolski * Creates the UI for the Zeus Module * * Arguments: @@ -48,6 +48,8 @@ if !(isNull attachedTo _logic) then { default {}; }; +} else { + [LLSTRING(OnlyObject)] call _fnc_errorAndClose; }; private _fnc_onUnload = { @@ -55,11 +57,9 @@ private _fnc_onUnload = { if (isNull _logic) exitWith {}; if !(_display getVariable [QGVAR(Confirmed), false]) then { - if !(isNull attachedTo _logic) then - { + if !(isNull attachedTo _logic) then { deleteVehicle _logic; - } else - { + } else { detach (attachedTo _logic); deleteVehicle _logic; }; @@ -75,31 +75,23 @@ private _fnc_onConfirm = { private _logic = GETMVAR(BIS_fnc_initCuratorAttributes_target,objNull); if (isNull _logic) exitWith {}; - private _gasType = _display getVariable [QGVAR(ui_gastype),0]; + private _gasLevel = _display getVariable [QGVAR(ui_gastype), 0]; + private _radius = _display getVariable [QGVAR(ui_radius), 20]; + private _isSealable = _display getVariable [QGVAR(ui_sealable), false]; - private _radius_max = _display getVariable [QGVAR(ui_radiusMax), 20]; - private _radius_min = _display getVariable [QGVAR(ui_radiusMin), 10]; - if (_radius_min > _radius_max) then { - [CSTRING(GasModule_Needbigger)] call ACEFUNC(zeus,showMessage); - } else { - private _logic = GETMVAR(BIS_fnc_initCuratorAttributes_target,objNull); - if (isNull _logic) exitWith {}; - - if !(isNull attachedTo _logic) then { - private _object = attachedTo _logic; + [QGVAR(addGasSource), [attachedTo _logic, _radius, _gasLevel, _logic, { + params ["_endTime", "_logic"]; - [_logic, getPos _object, _radius_max, _radius_min, _gasType] call FUNC(gasCheck); + // If logic no longer exists, exit + if (isNull _logic) exitWith { + false // return + }; - if (_display getVariable [QGVAR(ui_sealable), false]) then { - [QGVAR(createSealActionGlobal), [_object, _logic]] call CBA_fnc_globalEventJIP; - }; + CBA_missionTime < _endTime // return + }, [CBA_missionTime + 1e10, _logic], _isSealable]] call CBA_fnc_serverEvent; - } else { - [_logic, getPos _logic, _radius_max, _radius_min, _gasType] call FUNC(gasCheck); - }; + _display setVariable [QGVAR(Confirmed), true]; - _display setVariable [QGVAR(Confirmed), true]; - }; }; _display displayAddEventHandler ["Unload", _fnc_onUnload]; diff --git a/addons/chemical/script_component.hpp b/addons/chemical/script_component.hpp index 0a66b8add..0260cd9e2 100644 --- a/addons/chemical/script_component.hpp +++ b/addons/chemical/script_component.hpp @@ -3,8 +3,8 @@ #include "\x\kat\addons\main\script_mod.hpp" #include "\x\kat\addons\gui\gui_defines.hpp" -// #define DEBUG_MODE_FULL -// #define DISABLE_COMPILE_CACHE +//#define DEBUG_MODE_FULL +#define DISABLE_COMPILE_CACHE // #define ENABLE_PERFORMANCE_COUNTERS #ifdef DEBUG_ENABLED_CHEMICAL @@ -25,3 +25,4 @@ #define X_PART(num) (W_PART(num) + (safeZoneX + (safeZoneW - SIZEX) / 2)) #define Y_PART(num) (H_PART(num) + (safeZoneY + (safeZoneH - SIZEY) / 2)) +#define GAS_MANAGER_PFH_DELAY 0.25 diff --git a/addons/chemical/stringtable.xml b/addons/chemical/stringtable.xml index 7b61fed95..577d47856 100644 --- a/addons/chemical/stringtable.xml +++ b/addons/chemical/stringtable.xml @@ -307,21 +307,6 @@ Радиус вокруг модуля, заполненного газом. Radius om de module dat gevuld is met gas. - - The Minimal Range describes the area around the module where the gas is most lethal - El rango minimo describe el area alrededor del modulo en el cual el gas sera mas letal - Die minimale Reichweite beschreibt den Bereich im Umkreis des Moduls, in dem das Gas am tödlichsten wirkt. - Le rayon minimal décrit la zone autour du module ou le gaz est le plus létal - 最小範囲は、ガスが最も致死的であるモジュールの周辺を表します。 - 최소 범위는 가스가 가장 치명적으로 작동하는 모듈 주변 영역을 나타냅니다. - Il raggio minimo descrive l'area attorno al modulo dove il gas è più letale - O Alcance Mínimo descreve a área ao redor do módulo onde o gás é mais letal - Minimalny zasięg określa obszar wokół modułu, gdzie gaz jest bardziej śmiertelny - Minimální vzdálenost vyjadřuje oblast kolem modulu kde je plyn nejvíce smrtící - Minimialue kuvaa moduulia ympäröivän alueen, jossa kaasu on tappavin - Минимальный радиус, описывающий область вокруг модели, в которой газ является наиболее смертоносным - Het minimale bereik beschrijft het gebied om de module waar het gas het dodelijkst is - The Maximum Range is a range around the Minimal Range where the gas is less lethal and you have a longer chance of survival.(distance from module to outer ring) El rango maximo es el rango alrededor del rango minimo en el cual el gas es menos letal y tienes mas posibilidades de sobrevivir (distancia desde el modulo al anillo exterior) @@ -412,21 +397,6 @@ Герметизация утечки Dicht lek - - Minimal Range need to be less than Maximum Range! - ¡El rango minimo tiene que ser menor al rango maximo! - Minimale Reichweite muss kleiner als maximale Reichweite sein! - Le rayon minimal a besoin d'être plus petit que le rayon maximal ! - 最小範囲は最大範囲よりも小さくする必要があります! - 최소 범위는 반드시 최대 범위보다 작아야 합니다! - Il raggio minimo deve essere minore del raggio massimo! - O Alcance Mínimo precisa ser menor que o Alcance Máximo! - Minimalny zasięg musi być mniejszy niż maksymalny zasięg - Minimální vzdálenost musí být menší než Maximální vzdálenost! - Vähimmäisalueen on oltava pienempi kuin enimmäisetäisyys - Минимальный радиус должен быть меньше максимального радиуса ! - Het minimale bereik moet kleiner zijn dan het maximale bereik! - Intoxication Intoxicación @@ -741,21 +711,6 @@ Максимальная дальность действия. Maximaal bereik. - - Minimal Range. - Rango minimo - Minimale Reichweite. - Portée minimale - 最小範囲 - 최소 범위. - Raggio minimo. - Alcance Mínimo - Minimalny zasięg - Minimální vzdálenost. - Vähimmäisalue - Минимальный радиус действия. - Minimaal bereik. - Is sealable? ¿Es sellable? @@ -816,5 +771,14 @@ Тип газа: Gas type: + + Gas Mask Sound Volume + + + Determines how loud the breathing sounds are when using the gas mask + + + Must be placed on object + diff --git a/addons/chemical/ui/RscAttributes.hpp b/addons/chemical/ui/RscAttributes.hpp index ba9271f2c..3ad810ea9 100644 --- a/addons/chemical/ui/RscAttributes.hpp +++ b/addons/chemical/ui/RscAttributes.hpp @@ -49,16 +49,6 @@ class GVAR(kat_RscAtributeRadius): RscControlsGroupNoScrollbars { w = QUOTE(W_PART(15.9)); h = QUOTE(H_PART(1)); }; - class Title2: Title1 { - idc = 16108; - text = CSTRING(UI_min_range); - toolTip = CSTRING(GasModule_min_radius_dcs); - y = QUOTE(H_PART(1.1)); - }; - class radius_min: radius_max { - idc = 1612; - y = QUOTE(H_PART(1.1)); - }; class Title3: Title1 { idc = 1614; text = CSTRING(UI_sealable); diff --git a/addons/feedback/XEH_PREP.hpp b/addons/feedback/XEH_PREP.hpp index 42df1399d..9af508f92 100644 --- a/addons/feedback/XEH_PREP.hpp +++ b/addons/feedback/XEH_PREP.hpp @@ -1,4 +1,6 @@ +PREP(effectCoughing); PREP(effectLowSpO2); PREP(effectOpioid); +PREP(effectTearHaze); PREP(handleEffects); -PREP(initEffects); \ No newline at end of file +PREP(initEffects); diff --git a/addons/feedback/functions/fnc_effectCoughing.sqf b/addons/feedback/functions/fnc_effectCoughing.sqf new file mode 100644 index 000000000..2a19cbf38 --- /dev/null +++ b/addons/feedback/functions/fnc_effectCoughing.sqf @@ -0,0 +1,47 @@ +#include "..\script_component.hpp" +/* + * Author: MiszczuZPolski & Digii + * Triggers the coughing effect. + * + * Arguments: + * 0: Enable + * 1: Intensity + * + * Return Value: + * None + * + * Example: + * [true, 0.5] call kat_feedback_fnc_effectCoughing; + * + * Public: No + */ + +params ["_enable", "_poisoned"]; +if (!_enable || !_poisoned) exitWith { + if (GVAR(airPoisoning) != -1) then { GVAR(airPoisoning) ppEffectEnable false; }; +}; +if (GVAR(airPoisoning) != -1) then { GVAR(airPoisoning) ppEffectEnable true; }; + +// Trigger effect every 2s +private _showNextTick = missionNamespace getVariable [QGVAR(showCoughNextTick), true]; +GVAR(showCoughNextTick) = !_showNextTick; +if (_showNextTick) exitWith {}; + +_unit say3D QEGVAR(chemical,cough_1); +addCamShake [3, 4, 0]; + +private _initialAdjust = []; +private _delayedAdjust = []; + +private _intensity = linearConversion [0, 1, 0.5, 0, 0.06, true]; +_initialAdjust = [_intensity, _intensity, true]; +_delayedAdjust = [_intensity * 0.15, _intensity * 0.15, true]; + +GVAR(airPoisoning) ppEffectAdjust _initialAdjust; +GVAR(airPoisoning) ppEffectCommit FX_COUGH_FADE_IN; + +[{ + params ["_adjust"]; + GVAR(airPoisoning) ppEffectAdjust _adjust; + GVAR(airPoisoning) ppEffectCommit FX_COUGH_FADE_OUT; +}, [_delayedAdjust], 3] call CBA_fnc_waitAndExecute; diff --git a/addons/feedback/functions/fnc_effectTearHaze.sqf b/addons/feedback/functions/fnc_effectTearHaze.sqf new file mode 100644 index 000000000..b58d3e165 --- /dev/null +++ b/addons/feedback/functions/fnc_effectTearHaze.sqf @@ -0,0 +1,26 @@ +#include "..\script_component.hpp" +/* + * Author: MiszczuZPolski & Digii + * Triggers the coughing effect. + * + * Arguments: + * 0: Enable + * 1: Intensity + * + * Return Value: + * None + * + * Example: + * [true, 0.5] call kat_feedback_fnc_effectCoughing; + * + * Public: No + */ + +params ["_enable", "_tear"]; +if (!_enable || _tear == 0) exitWith { + if (GVAR(tearHaze) != -1) then { GVAR(tearHaze) ppEffectEnable false; }; +}; +if (GVAR(tearHaze) != -1) then { GVAR(tearHaze) ppEffectEnable true; }; + +GVAR(tearHaze) ppEffectAdjust [1.5,0.3,0.3,1.02,1.02,1.02,1.02,0.05,0.01,0.05,0.01,0.1,0.1,0.2,0.2]; +GVAR(tearHaze) ppEffectCommit 0; diff --git a/addons/feedback/functions/fnc_handleEffects.sqf b/addons/feedback/functions/fnc_handleEffects.sqf index feea1febc..53feac724 100644 --- a/addons/feedback/functions/fnc_handleEffects.sqf +++ b/addons/feedback/functions/fnc_handleEffects.sqf @@ -27,6 +27,8 @@ BEGIN_COUNTER(handleEffects); private _opioid = GET_PP(ACE_player); private _spO2 = GET_KAT_SPO2(ACE_player); private _unconscious = IS_UNCONSCIOUS(ACE_player); +private _poisoned = IS_AIRPOISONED(ACE_player); +private _tear = IN_TEARGAS(ACE_player); // - Visual effects ----------------------------------------------------------- @@ -37,5 +39,8 @@ private _unconscious = IS_UNCONSCIOUS(ACE_player); linearConversion [GVAR(effectLowSpO2), EGVAR(breathing,SpO2_dieValue), _spO2, 0, 1, true] ] call FUNC(effectLowSpO2); +[!_unconscious, _poisoned] call FUNC(effectCoughing); +[!_unconscious, _tear] call FUNC(effectTearHaze); + END_COUNTER(handleEffects); diff --git a/addons/feedback/functions/fnc_initEffects.sqf b/addons/feedback/functions/fnc_initEffects.sqf index ff0cbe28b..906106192 100644 --- a/addons/feedback/functions/fnc_initEffects.sqf +++ b/addons/feedback/functions/fnc_initEffects.sqf @@ -42,6 +42,22 @@ GVAR(opioidEffect) = [ // - Low SpO2 ----------------------------------------------------------- GVAR(lowSpO2) = [ "ColorCorrections", - 21370, + 213702, [1, 1, 0, [0, 0, 0, 0], [0, 0, 0, 1], [0.33, 0.33, 0.33, 0], [0.55, 0.5, 0, 0, 0, 0, 4]] ] call _fnc_createEffect; + +GVAR(airPoisoning) = [ + "ChromAberration", + 213703, + [0, 0, true] +] call _fnc_createEffect; + +GVAR(tearHaze) = [ + "WetDistortion", + 213704, + [1, + 1, 1, + 4.10, 3.70, 2.50, 1.85, + 0.0054, 0.0041, 0.0090, 0.0070, + 0.5, 0.3, 10.0, 6.0] +] call _fnc_createEffect; diff --git a/addons/feedback/script_component.hpp b/addons/feedback/script_component.hpp index 334ceebe7..900f27db0 100644 --- a/addons/feedback/script_component.hpp +++ b/addons/feedback/script_component.hpp @@ -3,7 +3,7 @@ #include "\x\kat\addons\main\script_mod.hpp" // #define DEBUG_MODE_FULL -// #define DISABLE_COMPILE_CACHE +#define DISABLE_COMPILE_CACHE // #define ENABLE_PERFORMANCE_COUNTERS #ifdef DEBUG_ENABLED_FEEDBACK @@ -20,4 +20,7 @@ #define FX_OPIOD_FADE_OUT 0.7 #define FX_SPO2_FADE_IN 0.7 -#define FX_SPO2_FADE_OUT 1.6 \ No newline at end of file +#define FX_SPO2_FADE_OUT 1.6 + +#define FX_COUGH_FADE_IN 0.3 +#define FX_COUGH_FADE_OUT 0.7 diff --git a/addons/main/script_macros.hpp b/addons/main/script_macros.hpp index 7007174ec..a0396d871 100644 --- a/addons/main/script_macros.hpp +++ b/addons/main/script_macros.hpp @@ -186,7 +186,7 @@ #undef GET_SM_STATE #define GET_SM_STATE(_unit) ([_unit, ACEGVAR(medical,STATE_MACHINE)] call CBA_statemachine_fnc_getCurrentState) -#undef GET_BLOOD_VOLUME +#undef GET_BLOOD_VOLUME #define GET_OPIOID_FACTOR(unit) (unit getVariable [QEGVAR(pharma,opioidFactor), 0]) #define GET_PAIN_PERCEIVED(unit) (0 max ((GET_PAIN(unit) - GET_PAIN_SUPPRESS(unit)) min 1)) @@ -340,3 +340,6 @@ //Feedback #define VAR_PP QEGVAR(feedback,ppEffect) #define GET_PP(unit) (unit getVariable [VAR_PP, 0]) + +#define IS_AIRPOISONED(unit) (unit getVariable [QEGVAR(chemical,airPoisoning), false]) +#define IN_TEARGAS(unit) (unit getVariable [QEGVAR(chemical,CSGas), 0]) diff --git a/addons/vitals/XEH_PREP.hpp b/addons/vitals/XEH_PREP.hpp index 9295e7f53..f05f9c7b0 100644 --- a/addons/vitals/XEH_PREP.hpp +++ b/addons/vitals/XEH_PREP.hpp @@ -6,7 +6,8 @@ PREP(handleCardiacFunction); PREP(handleTemperatureFunction); PREP(handleRespawn); PREP(handleOxygenFunction); +PREP(handlePoisoning); PREP(hasStableVitals); PREP(init); PREP(updateOpioidEffect); -PREP(updateOpioidRelief); \ No newline at end of file +PREP(updateOpioidRelief); diff --git a/addons/vitals/functions/fnc_handlePoisoning.sqf b/addons/vitals/functions/fnc_handlePoisoning.sqf new file mode 100644 index 000000000..25607fd3f --- /dev/null +++ b/addons/vitals/functions/fnc_handlePoisoning.sqf @@ -0,0 +1,25 @@ +#include "..\script_component.hpp" +/* + * Author: MiszczuZPolski + * Update poisoning + + * Arguments: + * 0: The Unit + * 1: Poison Adjustments + * 2: Time since last update + * 3: Sync value? + * + * ReturnValue: + * None + * + * Example: + * [player, 1, 1, false] call kat_vitals_handlePoisoning; + * + * Public: No + */ + +params ["_unit", "_poisonAdjustment", "_deltaT", "_syncValue"]; + +private _currentCS = _unit getVariable [QEGVAR(chemical,CSGas), 0]; + +_unit setVariable [QEGVAR(chemical,CSGas), (_currentCS - (_poisonAdjustment * _deltaT)) max 0, _syncValue]; diff --git a/addons/vitals/functions/fnc_handleUnitVitals.sqf b/addons/vitals/functions/fnc_handleUnitVitals.sqf index fe3295591..133a24314 100644 --- a/addons/vitals/functions/fnc_handleUnitVitals.sqf +++ b/addons/vitals/functions/fnc_handleUnitVitals.sqf @@ -122,6 +122,7 @@ if !(_adjustments isEqualTo []) then { [_unit, _peripheralResistanceAdjustment, _deltaT, _syncValues] call ACEFUNC(medical_vitals,updatePeripheralResistance); [_unit, _opioidAdjustment, _deltaT, _syncValues] call FUNC(updateOpioidRelief); [_unit, _opioidEffectAdjustment, _deltaT, _syncValues] call FUNC(updateOpioidEffect); +[_unit, POISON_DECREASE, _deltaT, _syncValues] call FUNC(handlePoisoning); private _heartRate = [_unit, _hrTargetAdjustment, 0, _bloodVolume, _deltaT, _syncValues] call FUNC(handleCardiacFunction); diff --git a/addons/vitals/script_component.hpp b/addons/vitals/script_component.hpp index 2fbccf669..162080431 100644 --- a/addons/vitals/script_component.hpp +++ b/addons/vitals/script_component.hpp @@ -15,3 +15,5 @@ #endif #include "\x\kat\addons\main\script_macros.hpp" + +#define POISON_DECREASE 1