From 60270d54153829cdb97f41a30fd355f836edee0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Badano?= Date: Fri, 16 Jan 2015 11:30:49 -0300 Subject: [PATCH 1/6] Change the loop that updates ACE_player from BIS to PFH --- addons/common/XEH_preInit.sqf | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/addons/common/XEH_preInit.sqf b/addons/common/XEH_preInit.sqf index 4dd6b5980e..11b67adf13 100644 --- a/addons/common/XEH_preInit.sqf +++ b/addons/common/XEH_preInit.sqf @@ -162,19 +162,24 @@ PREP(hashListSet); PREP(hashListPush); -// Loop to update the ACE_player variable + ACE_player = player; + if (hasInterface) then { - ["ACE_CheckForPlayerChange", "onEachFrame", { + // PFH to update the ACE_player variable + [{ if !(ACE_player isEqualTo (missionNamespace getVariable ["BIS_fnc_moduleRemoteControl_unit", player])) then { - _this = ACE_player; + _oldPlayer = ACE_player; ACE_player = missionNamespace getVariable ["BIS_fnc_moduleRemoteControl_unit", player]; uiNamespace setVariable ["ACE_player", ACE_player]; - [missionNamespace, "playerChanged", [ACE_player, _this]] call FUNC(callCustomEventHandlers); + // Raise custom event. @todo, remove + [missionNamespace, "playerChanged", [ACE_player, _oldPlayer]] call FUNC(callCustomEventHandlers); + // Raise ACE event + ["playerChanged", [ACE_player, _oldPlayer]]] call FUNC(localEvent); }; - }] call BIS_fnc_addStackedEventHandler; + }, 0, []] call cba_fnc_addPerFrameHandler; }; From 34135ffdd4c7749863236af3a2b6ebd8a44f7377 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Badano?= Date: Fri, 16 Jan 2015 12:14:18 -0300 Subject: [PATCH 2/6] common: ACE local event for playerChanged --- addons/common/XEH_postInit.sqf | 14 ++++++++------ addons/common/XEH_preInit.sqf | 2 +- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/addons/common/XEH_postInit.sqf b/addons/common/XEH_postInit.sqf index 4a7b12a8c5..87c1b0c3b6 100644 --- a/addons/common/XEH_postInit.sqf +++ b/addons/common/XEH_postInit.sqf @@ -63,13 +63,15 @@ call COMPILE_FILE(scripts\KeyInput\initScrollWheel); enableCamShake true; // Set the name for the current player -[missionNamespace, "playerChanged", { - if (alive (_this select 0)) then { - [_this select 0] call FUNC(setName) +["playerChanged", { + EXPLODE_2_PVT(_this,_newPlayer,_oldPlayer); + + if (alive _newPlayer) then { + [_newPlayer] call FUNC(setName) }; - if (alive (_this select 1)) then { - [_this select 1] call FUNC(setName) + if (alive _oldPlayer) then { + [_oldPlayer] call FUNC(setName) }; -}] call FUNC(addCustomEventhandler); +}] call FUNC(addEventhandler); diff --git a/addons/common/XEH_preInit.sqf b/addons/common/XEH_preInit.sqf index 11b67adf13..0384d48a70 100644 --- a/addons/common/XEH_preInit.sqf +++ b/addons/common/XEH_preInit.sqf @@ -177,7 +177,7 @@ if (hasInterface) then { // Raise custom event. @todo, remove [missionNamespace, "playerChanged", [ACE_player, _oldPlayer]] call FUNC(callCustomEventHandlers); // Raise ACE event - ["playerChanged", [ACE_player, _oldPlayer]]] call FUNC(localEvent); + ["playerChanged", [ACE_player, _oldPlayer]] call FUNC(localEvent); }; }, 0, []] call cba_fnc_addPerFrameHandler; }; From e1b1edc961616b9e5c51f64ddd4189f0fb86317c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Badano?= Date: Fri, 16 Jan 2015 12:14:40 -0300 Subject: [PATCH 3/6] noradio: ace local event for playerChanged --- addons/noradio/XEH_post_initClient.sqf | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/addons/noradio/XEH_post_initClient.sqf b/addons/noradio/XEH_post_initClient.sqf index fcdeeec7e3..e192a101f8 100644 --- a/addons/noradio/XEH_post_initClient.sqf +++ b/addons/noradio/XEH_post_initClient.sqf @@ -13,13 +13,19 @@ _setupPlayer = { [_setupPlayer, 0, []] call CBA_fnc_addPerFrameHandler; -[missionNamespace, "playerChanged", { - //On player change, mute old unit and unmute new player - [_this select 0] call EFUNC(common,muteUnit); - (_this select 0) setVariable [QGVAR(isMuted), true, true]; +// Mutes/unmutes units when the player changes +["playerChanged", { + EXPLODE_2_PVT(_this,_newPlayer,_oldPlayer); - if (!((_this select 1) getVariable ["ACE_isUnconscious", false]) && {alive (_this select 1)}) then { //@todo: ACE_isUnconscious??? - [_this select 1] call EFUNC(common,unMuteUnit); + // On player change mute the new player + [_newPlayer] call EFUNC(common,muteUnit); + _newPlayer setVariable [QGVAR(isMuted), true, true]; + + // Unmute the old player + //@todo: sort interaction with medical system + if (!(_oldPlayer getVariable ["ACE_isUnconscious", false]) && {alive _oldPlayer}) then { + [_oldPlayer] call EFUNC(common,unMuteUnit); }; - (_this select 1) setVariable [QGVAR(isMuted), false, true]; -}] call EFUNC(common,addCustomEventHandler); + _oldPlayer setVariable [QGVAR(isMuted), false, true]; + +}] call EFUNC(common,addEventhandler); From bce84d9a2dd41c181ee5c887532053385ee61f5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Badano?= Date: Fri, 16 Jan 2015 12:38:43 -0300 Subject: [PATCH 4/6] respawn: raise "killedByFriendly" ACE event globally --- .../respawn/functions/fnc_showFriendlyFireMessage.sqf | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/addons/respawn/functions/fnc_showFriendlyFireMessage.sqf b/addons/respawn/functions/fnc_showFriendlyFireMessage.sqf index f384b69284..7d1b374252 100644 --- a/addons/respawn/functions/fnc_showFriendlyFireMessage.sqf +++ b/addons/respawn/functions/fnc_showFriendlyFireMessage.sqf @@ -1,16 +1,16 @@ /* Name: ACE_Respawn_fnc_showFriendlyFireMessages - + Author(s): commy2 - + Description: shows a message in system chat of who killed who - + Parameters: 0: OBJECT - unit 1: OBJECT - killer - + Returns: VOID */ @@ -25,5 +25,8 @@ _killer = _this select 1; if (_unit != _killer && side group _unit in [side group ACE_player, civilian] && {side group _killer == side group ACE_player}) then { systemChat format ["%1 was killed by %2", [_unit] call EFUNC(common,getName), [_killer] call EFUNC(common,getName)]; + // Raise custom event. @todo: remove [_unit, "killedByFriendly", [_unit, _killer]] call EFUNC(common,callCustomEventHandlers); + // Raise ACE globalEvent + ["killedByFriendly", [_unit, _killer]] call EFUNC(common,globalEvent); }; From 00e68c4540cf8bdf3f5e8fc316083fdf6ec0916f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Badano?= Date: Fri, 16 Jan 2015 12:42:48 -0300 Subject: [PATCH 5/6] interaction: raise "interactionMenuOpened" ACE event locally --- addons/interaction/functions/fnc_onButtonDownSelf.sqf | 3 +++ 1 file changed, 3 insertions(+) diff --git a/addons/interaction/functions/fnc_onButtonDownSelf.sqf b/addons/interaction/functions/fnc_onButtonDownSelf.sqf index 53f57827e9..7b9abb926e 100644 --- a/addons/interaction/functions/fnc_onButtonDownSelf.sqf +++ b/addons/interaction/functions/fnc_onButtonDownSelf.sqf @@ -12,4 +12,7 @@ if (isNull (findDisplay 1713999)) then { (findDisplay 1713999) closeDisplay 1; }; +// Raise custom event. @todo: remove [_player, "interactionMenuOpened", [_player, GVAR(Target), 1]] call EFUNC(common,callCustomEventHandlers); +// Raise ACE localEvent +["interactionMenuOpened", [_player, GVAR(Target), 1]] call EFUNC(common,localEvent); From 78cca3c539b353d1b26bc325fe7c5e7318fc0d73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Badano?= Date: Fri, 16 Jan 2015 12:45:15 -0300 Subject: [PATCH 6/6] interaction: raise "interactionMenuOpened" ACE event locally 2 --- addons/interaction/functions/fnc_onButtonDown.sqf | 3 +++ 1 file changed, 3 insertions(+) diff --git a/addons/interaction/functions/fnc_onButtonDown.sqf b/addons/interaction/functions/fnc_onButtonDown.sqf index 27b46380e0..63f62ed4a0 100644 --- a/addons/interaction/functions/fnc_onButtonDown.sqf +++ b/addons/interaction/functions/fnc_onButtonDown.sqf @@ -12,4 +12,7 @@ if (isNull (findDisplay 1713999)) then { (findDisplay 1713999) closeDisplay 1; }; +// Raise custom event. @todo: remove [_player, "interactionMenuOpened", [_player, GVAR(Target), 0]] call EFUNC(common,callCustomEventHandlers); +// Raise ACE localEvent +["interactionMenuOpened", [_player, GVAR(Target), 0]] call EFUNC(common,localEvent);