mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Use SlotItemChanged
This commit is contained in:
parent
be9797d11d
commit
e99e8ee8eb
@ -67,10 +67,16 @@ GVAR(lastPlayerVehicle) = objNull;
|
|||||||
private _firedEH = _oldPlayer getVariable [QGVAR(firedEH), -1];
|
private _firedEH = _oldPlayer getVariable [QGVAR(firedEH), -1];
|
||||||
_oldPlayer removeEventHandler ["FiredNear", _firedEH];
|
_oldPlayer removeEventHandler ["FiredNear", _firedEH];
|
||||||
_oldPlayer setVariable [QGVAR(firedEH), nil];
|
_oldPlayer setVariable [QGVAR(firedEH), nil];
|
||||||
|
|
||||||
private _explosionEH = _oldPlayer getVariable [QGVAR(explosionEH), -1];
|
private _explosionEH = _oldPlayer getVariable [QGVAR(explosionEH), -1];
|
||||||
_oldPlayer removeEventHandler ["Explosion", _explosionEH];
|
_oldPlayer removeEventHandler ["Explosion", _explosionEH];
|
||||||
_oldPlayer setVariable [QGVAR(explosionEH), nil];
|
_oldPlayer setVariable [QGVAR(explosionEH), nil];
|
||||||
TRACE_3("removed unit eh",_oldPlayer,_firedEH,_explosionEH);
|
|
||||||
|
private _slotItemChangedEH = _oldPlayer getVariable [QGVAR(slotItemChangedEH), -1];
|
||||||
|
_oldPlayer removeEventHandler ["SlotItemChanged", _slotItemChangedEH];
|
||||||
|
_oldPlayer setVariable [QGVAR(slotItemChangedEH), nil];
|
||||||
|
|
||||||
|
TRACE_4("removed unit eh",_oldPlayer,_firedEH,_explosionEH,_slotItemChangedEH);
|
||||||
};
|
};
|
||||||
// Don't add a new EH if the unit respawned
|
// Don't add a new EH if the unit respawned
|
||||||
if ((_player getVariable [QGVAR(firedEH), -1]) == -1) then {
|
if ((_player getVariable [QGVAR(firedEH), -1]) == -1) then {
|
||||||
@ -79,17 +85,20 @@ GVAR(lastPlayerVehicle) = objNull;
|
|||||||
};
|
};
|
||||||
private _firedEH = _player addEventHandler ["FiredNear", {call FUNC(firedNear)}];
|
private _firedEH = _player addEventHandler ["FiredNear", {call FUNC(firedNear)}];
|
||||||
_player setVariable [QGVAR(firedEH), _firedEH];
|
_player setVariable [QGVAR(firedEH), _firedEH];
|
||||||
|
|
||||||
private _explosionEH = _player addEventHandler ["Explosion", {call FUNC(explosionNear)}];
|
private _explosionEH = _player addEventHandler ["Explosion", {call FUNC(explosionNear)}];
|
||||||
_player setVariable [QGVAR(explosionEH), _explosionEH];
|
_player setVariable [QGVAR(explosionEH), _explosionEH];
|
||||||
TRACE_3("added unit eh",_player,_firedEH,_explosionEH);
|
|
||||||
|
// Update protection on possible helmet change
|
||||||
|
private _slotItemChangedEH = _player addEventHandler ["SlotItemChanged", {(_this select 2) call FUNC(updateHearingProtection)}];
|
||||||
|
_player setVariable [QGVAR(slotItemChangedEH), _slotItemChangedEH];
|
||||||
|
|
||||||
|
TRACE_4("added unit eh",_player,_firedEH,_explosionEH,_slotItemChangedEH);
|
||||||
};
|
};
|
||||||
|
|
||||||
GVAR(deafnessDV) = 0;
|
GVAR(deafnessDV) = 0;
|
||||||
GVAR(deafnessPrior) = 0;
|
GVAR(deafnessPrior) = 0;
|
||||||
GVAR(time3) = 0;
|
GVAR(time3) = 0;
|
||||||
[] call FUNC(updateHearingProtection);
|
UPDATE_HEARING_EARPLUGS call FUNC(updateHearingProtection);
|
||||||
}, true] call CBA_fnc_addPlayerEventHandler;
|
}, true] call CBA_fnc_addPlayerEventHandler;
|
||||||
|
|
||||||
// Update protection on possible helmet change
|
|
||||||
["loadout", LINKFUNC(updateHearingProtection), false] call CBA_fnc_addPlayerEventHandler;
|
|
||||||
}] call CBA_fnc_addEventHandler;
|
}] call CBA_fnc_addEventHandler;
|
||||||
|
@ -35,4 +35,4 @@ if (_displayHint) then {
|
|||||||
// No Earplugs in inventory, telling user
|
// No Earplugs in inventory, telling user
|
||||||
//[localize LSTRING(NoPlugs)] call EFUNC(common,displayTextStructured);
|
//[localize LSTRING(NoPlugs)] call EFUNC(common,displayTextStructured);
|
||||||
|
|
||||||
[] call FUNC(updateHearingProtection);
|
UPDATE_HEARING_EARPLUGS call FUNC(updateHearingProtection);
|
||||||
|
@ -36,4 +36,4 @@ if (_displayHint) then {
|
|||||||
//Force an immediate fast volume update:
|
//Force an immediate fast volume update:
|
||||||
[[true]] call FUNC(updateVolume);
|
[[true]] call FUNC(updateVolume);
|
||||||
|
|
||||||
[] call FUNC(updateHearingProtection);
|
UPDATE_HEARING_EARPLUGS call FUNC(updateHearingProtection);
|
||||||
|
@ -4,24 +4,27 @@
|
|||||||
* Updates the hearing protection and volume attenuation for player on earbuds/helmet change
|
* Updates the hearing protection and volume attenuation for player on earbuds/helmet change
|
||||||
*
|
*
|
||||||
* Arguments:
|
* Arguments:
|
||||||
* None
|
* 0: Slot <NUMBER>
|
||||||
*
|
*
|
||||||
* Return Value:
|
* Return Value:
|
||||||
* None
|
* None
|
||||||
*
|
*
|
||||||
* Example:
|
* Example:
|
||||||
* [] call ace_hearing_fnc_updateHearingProtection
|
* UPDATE_HEARING_EARPLUGS call ace_hearing_fnc_updateHearingProtection
|
||||||
*
|
*
|
||||||
* Public: No
|
* Public: No
|
||||||
*/
|
*/
|
||||||
|
|
||||||
TRACE_1("params",_this);
|
|
||||||
|
|
||||||
if (isNull ACE_player) exitWith {
|
if (isNull ACE_player) exitWith {
|
||||||
GVAR(damageCoefficent) = 0;
|
GVAR(damageCoefficent) = 0;
|
||||||
GVAR(volumeAttenuation) = 1;
|
GVAR(volumeAttenuation) = 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
params ["_slot"];
|
||||||
|
TRACE_1("",_slot);
|
||||||
|
|
||||||
|
if !(_slot in [UPDATE_HEARING_EARPLUGS, TYPE_GOGGLE, TYPE_HEADGEAR]) exitWith {};
|
||||||
|
|
||||||
// Handle Earplugs
|
// Handle Earplugs
|
||||||
private _hasEarPlugsIn = [ACE_player] call FUNC(hasEarPlugsIn);
|
private _hasEarPlugsIn = [ACE_player] call FUNC(hasEarPlugsIn);
|
||||||
GVAR(damageCoefficent) = [1, 0.25] select _hasEarPlugsIn;
|
GVAR(damageCoefficent) = [1, 0.25] select _hasEarPlugsIn;
|
||||||
|
@ -16,3 +16,5 @@
|
|||||||
|
|
||||||
#include "\z\ace\addons\main\script_macros.hpp"
|
#include "\z\ace\addons\main\script_macros.hpp"
|
||||||
#include "\z\ace\addons\hearing\script_macros_hearingProtection.hpp"
|
#include "\z\ace\addons\hearing\script_macros_hearingProtection.hpp"
|
||||||
|
|
||||||
|
#defined UPDATE_HEARING_EARPLUGS -1
|
||||||
|
Loading…
Reference in New Issue
Block a user