mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Hearing - Reset earplugs on respawn, addItem setting
Fix #2835 - readd item on respawn Fix #2837 - setVariable false on respawn
This commit is contained in:
parent
845909f8af
commit
87b9ff9785
@ -25,4 +25,10 @@ class ACE_Settings {
|
||||
displayName = CSTRING(enabledForZeusUnits_DisplayName);
|
||||
description = CSTRING(enabledForZeusUnits_Description);
|
||||
};
|
||||
class GVAR(autoAddEarplugsToUnits) {
|
||||
value = 1;
|
||||
typeName = "BOOL";
|
||||
displayName = CSTRING(autoAddEarplugsToUnits_DisplayName);
|
||||
description = CSTRING(autoAddEarplugsToUnits_Description);
|
||||
};
|
||||
};
|
||||
|
@ -13,7 +13,7 @@ class Extended_PostInit_EventHandlers {
|
||||
class Extended_Init_EventHandlers {
|
||||
class CAManBase {
|
||||
class GVAR(AddEarPlugs) {
|
||||
init = QUOTE( if (local (_this select 0)) then {_this call FUNC(addEarPlugs)}; );
|
||||
serverInit = QUOTE( _this call FUNC(addEarPlugs) );
|
||||
};
|
||||
};
|
||||
};
|
||||
@ -33,3 +33,11 @@ class Extended_Explosion_EventHandlers {
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
class Extended_Respawn_EventHandlers {
|
||||
class CAManBase {
|
||||
class ADDON {
|
||||
respawn = QUOTE(_this call FUNC(handleRespawn));
|
||||
};
|
||||
};
|
||||
};
|
||||
|
@ -136,6 +136,12 @@ class CfgVehicles {
|
||||
typeName = "BOOL";
|
||||
defaultValue = 1;
|
||||
};
|
||||
class autoAddEarplugsToUnits {
|
||||
displayName = CSTRING(autoAddEarplugsToUnits_DisplayName);
|
||||
description = CSTRING(autoAddEarplugsToUnits_Description);
|
||||
typeName = "BOOL";
|
||||
defaultValue = 1;
|
||||
};
|
||||
};
|
||||
class ModuleDescription {
|
||||
description = CSTRING(Module_Description);
|
||||
|
@ -6,6 +6,7 @@ PREP(addEarPlugs);
|
||||
PREP(earRinging);
|
||||
PREP(explosionNear);
|
||||
PREP(firedNear);
|
||||
PREP(handleRespawn);
|
||||
PREP(hasEarPlugsIn);
|
||||
PREP(moduleHearing);
|
||||
PREP(putInEarPlugs);
|
||||
|
@ -16,12 +16,19 @@
|
||||
#include "script_component.hpp"
|
||||
|
||||
params ["_unit"];
|
||||
TRACE_2("params",_unit,typeOf _unit);
|
||||
|
||||
// Exit if hearing is disabled or soldier has earplugs already in (persistence scenarios)
|
||||
if (!GVAR(enableCombatDeafness) || {[_unit] call FUNC(hasEarPlugsIn)}) exitWith {};
|
||||
// only run this after the settings are initialized
|
||||
if !(EGVAR(common,settingsInitFinished)) exitWith {
|
||||
EGVAR(common,runAtSettingsInitialized) pushBack [FUNC(addEarPlugs), _this];
|
||||
};
|
||||
|
||||
// Exit if hearing is disabled OR autoAdd is disabled OR soldier has earplugs already in (persistence scenarios)
|
||||
if (!GVAR(enableCombatDeafness) || {!GVAR(autoAddEarplugsToUnits)} || {[_unit] call FUNC(hasEarPlugsIn)}) exitWith {};
|
||||
|
||||
// add earplugs if the soldier has a rocket launcher
|
||||
if ((secondaryWeapon _unit) != "") exitWith {
|
||||
TRACE_1("has launcher - adding",_unit);
|
||||
_unit addItem "ACE_EarPlugs";
|
||||
};
|
||||
|
||||
@ -48,6 +55,9 @@ local _loudness = (_caliber ^ 1.25 / 10) * (_initspeed / 1000) / 5;
|
||||
//If unit has a machine gun boost effective loudness 50%
|
||||
if (_count >= 50) then {_loudness = _loudness * 1.5};
|
||||
|
||||
TRACE_2("primaryWeapon",_unit,_loudness);
|
||||
|
||||
if (_loudness > 0.2) then {
|
||||
TRACE_1("loud gun - adding",_unit);
|
||||
_unit addItem "ACE_EarPlugs";
|
||||
};
|
||||
|
35
addons/hearing/functions/fnc_handleRespawn.sqf
Normal file
35
addons/hearing/functions/fnc_handleRespawn.sqf
Normal file
@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Author: PabstMirror
|
||||
* Reset earplugs on respawn, and then re-add if appropriate
|
||||
*
|
||||
* Arguments:
|
||||
* 0: Unit <OBJECT>
|
||||
*
|
||||
* Return Value:
|
||||
* Nothing
|
||||
*
|
||||
* Example:
|
||||
* [player] call ACE_hearing_fnc_handleRespawn;
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
params ["_unit"];
|
||||
TRACE_2("params",_unit,typeOf _unit);
|
||||
|
||||
if (!local _unit) exitWith {}; //XEH should only be called on local units
|
||||
|
||||
local _respawn = [0] call BIS_fnc_missionRespawnType;
|
||||
|
||||
//if respawn is not Group or side:
|
||||
if (_respawn <= 3) then {
|
||||
//Remove earplugs if they have them:
|
||||
if (_unit getVariable ["ACE_hasEarPlugsin", false]) then {
|
||||
TRACE_1("had EarPlugs in - removing",_unit);
|
||||
_unit setVariable ["ACE_hasEarPlugsin", false, true];
|
||||
};
|
||||
};
|
||||
|
||||
//Re-add if they need them:
|
||||
[_unit] call FUNC(addEarPlugs);
|
@ -20,4 +20,5 @@ if ((_logic getVariable "DisableEarRinging") != -1) then {
|
||||
};
|
||||
|
||||
[_logic, QGVAR(enabledForZeusUnits), "enabledForZeusUnits"] call EFUNC(common,readSettingFromModule);
|
||||
[_logic, QGVAR(autoAddEarplugsToUnits), "autoAddEarplugsToUnits"] call EFUNC(common,readSettingFromModule);
|
||||
ACE_LOGINFO("Hearing Module Initialized.");
|
||||
|
@ -165,5 +165,11 @@
|
||||
<Portuguese>Permite que unidades remotamente controladas pelo Zeus sejam atingidas por danos auditivos.</Portuguese>
|
||||
<Spanish>Permitir a las unidades por control remoto de zeus que puedan tener daños auditivos.</Spanish>
|
||||
</Key>
|
||||
<Key ID="STR_ACE_Hearing_autoAddEarplugsToUnits_DisplayName">
|
||||
<English>Add earplugs to units</English>
|
||||
</Key>
|
||||
<Key ID="STR_ACE_Hearing_autoAddEarplugsToUnits_Description">
|
||||
<English>Add the `ACE_EarPlugs` item to all units that have loud weapons. Can disable if using custom loadouts.</English>
|
||||
</Key>
|
||||
</Package>
|
||||
</Project>
|
Loading…
Reference in New Issue
Block a user