mute implementation in noradio, handle post init on remote units

This commit is contained in:
commy2 2015-04-12 11:17:58 +02:00
parent 54f29d75f5
commit e87f491470
6 changed files with 32 additions and 23 deletions

View File

@ -26,6 +26,9 @@ class Extended_InitPost_EventHandlers {
class GVAR(forceWalk) {
init = QUOTE(if (local (_this select 0)) then {_this call FUNC(applyForceWalkStatus);};);
};
class GVAR(muteUnit) {
init = QUOTE(_this call FUNC(muteUnitHandleInitPost));
};
};
};

View File

@ -124,6 +124,7 @@ PREP(moduleCheckPBOs);
PREP(moduleLSDVehicles);
PREP(moveToTempGroup);
PREP(muteUnit);
PREP(muteUnitHandleInitPost);
PREP(muteUnitHandleRespawn);
PREP(numberToDigits);
PREP(numberToDigitsString);

View File

@ -33,6 +33,6 @@ _speaker = speaker _unit;
if (_speaker == "ACE_NoVoice") exitWith {};
["setSpeaker", _unit, [_unit, "ACE_NoVoice"]] call FUNC(targetEvent);
["setSpeaker", [_unit, "ACE_NoVoice"]] call FUNC(globalEvent);
_unit setVariable ["ACE_OriginalSpeaker", _speaker, true];

View File

@ -0,0 +1,11 @@
// by commy2
#include "script_component.hpp"
private "_unit";
_unit = _this select 0;
// setSpeaker gets overwritten after init on remote units; if unit is muted, setSpeaker again
if (count (_unit getVariable [QGVAR(muteUnitReasons), []]) > 0) then {
["setSpeaker", [_unit, "ACE_NoVoice"]] call FUNC(localEvent);
};

View File

@ -1,31 +1,29 @@
// by commy2
#include "script_component.hpp"
/*
_setupPlayer = {
if (!isNull ACE_player) then {
[(_this select 1)] call cba_fnc_removePerFrameHandler;
[ACE_player] call EFUNC(common,muteUnit);
ACE_player setVariable [QGVAR(isMuted), true, true];
[ACE_player, "isPlayer"] call EFUNC(common,muteUnit);
};
};
[_setupPlayer, 0, []] call CBA_fnc_addPerFrameHandler;
*/
if (!hasInterface) exitWith {};
// Mutes/unmutes units when the player changes
["playerChanged", {
EXPLODE_2_PVT(_this,_newPlayer,_oldPlayer);
// On player change mute the new player
[_newPlayer] call EFUNC(common,muteUnit);
_newPlayer setVariable [QGVAR(isMuted), true, true];
[_newPlayer, "isPlayer"] call EFUNC(common,muteUnit);
// Unmute the old player
//@todo: sort interaction with medical system
if (!(_oldPlayer getVariable ["ACE_isUnconscious", false]) && {alive _oldPlayer}) then {
[_oldPlayer] call EFUNC(common,unMuteUnit);
if (alive _oldPlayer) then {
[_oldPlayer, "isPlayer"] call EFUNC(common,unmuteUnit);
};
_oldPlayer setVariable [QGVAR(isMuted), false, true];
}] call EFUNC(common,addEventhandler);

View File

@ -1,10 +1,6 @@
// by commy2
#include "script_component.hpp"
addMissionEventHandler ["HandleDisconnect", {
if !((_this select 0) getVariable ["ACE_isUnconscious", false]) then { //@ToDo: ai waking up will be silent?
_this call EFUNC(common,unMuteUnit);
};
(_this select 0) setVariable [QGVAR(isMuted), false, true];
[_this select 0, "isPlayer"] call EFUNC(common,unmuteUnit);
}];