Merge pull request #38 from KoffeinFlummi/aceEvents

Replace some AGM custom events by ACE events
This commit is contained in:
Nicolás Badano
2015-01-16 14:20:39 -03:00
6 changed files with 45 additions and 23 deletions

View File

@ -63,13 +63,15 @@ call COMPILE_FILE(scripts\KeyInput\initScrollWheel);
enableCamShake true; enableCamShake true;
// Set the name for the current player // Set the name for the current player
[missionNamespace, "playerChanged", { ["playerChanged", {
if (alive (_this select 0)) then { EXPLODE_2_PVT(_this,_newPlayer,_oldPlayer);
[_this select 0] call FUNC(setName)
if (alive _newPlayer) then {
[_newPlayer] call FUNC(setName)
}; };
if (alive (_this select 1)) then { if (alive _oldPlayer) then {
[_this select 1] call FUNC(setName) [_oldPlayer] call FUNC(setName)
}; };
}] call FUNC(addCustomEventhandler); }] call FUNC(addEventhandler);

View File

@ -162,19 +162,24 @@ PREP(hashListSet);
PREP(hashListPush); PREP(hashListPush);
// Loop to update the ACE_player variable
ACE_player = player; ACE_player = player;
if (hasInterface) then { 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 { 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]; ACE_player = missionNamespace getVariable ["BIS_fnc_moduleRemoteControl_unit", player];
uiNamespace setVariable ["ACE_player", ACE_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;
}; };

View File

@ -12,4 +12,7 @@ if (isNull (findDisplay 1713999)) then {
(findDisplay 1713999) closeDisplay 1; (findDisplay 1713999) closeDisplay 1;
}; };
// Raise custom event. @todo: remove
[_player, "interactionMenuOpened", [_player, GVAR(Target), 0]] call EFUNC(common,callCustomEventHandlers); [_player, "interactionMenuOpened", [_player, GVAR(Target), 0]] call EFUNC(common,callCustomEventHandlers);
// Raise ACE localEvent
["interactionMenuOpened", [_player, GVAR(Target), 0]] call EFUNC(common,localEvent);

View File

@ -12,4 +12,7 @@ if (isNull (findDisplay 1713999)) then {
(findDisplay 1713999) closeDisplay 1; (findDisplay 1713999) closeDisplay 1;
}; };
// Raise custom event. @todo: remove
[_player, "interactionMenuOpened", [_player, GVAR(Target), 1]] call EFUNC(common,callCustomEventHandlers); [_player, "interactionMenuOpened", [_player, GVAR(Target), 1]] call EFUNC(common,callCustomEventHandlers);
// Raise ACE localEvent
["interactionMenuOpened", [_player, GVAR(Target), 1]] call EFUNC(common,localEvent);

View File

@ -13,13 +13,19 @@ _setupPlayer = {
[_setupPlayer, 0, []] call CBA_fnc_addPerFrameHandler; [_setupPlayer, 0, []] call CBA_fnc_addPerFrameHandler;
[missionNamespace, "playerChanged", { // Mutes/unmutes units when the player changes
//On player change, mute old unit and unmute new player ["playerChanged", {
[_this select 0] call EFUNC(common,muteUnit); EXPLODE_2_PVT(_this,_newPlayer,_oldPlayer);
(_this select 0) setVariable [QGVAR(isMuted), true, true];
if (!((_this select 1) getVariable ["ACE_isUnconscious", false]) && {alive (_this select 1)}) then { //@todo: ACE_isUnconscious??? // On player change mute the new player
[_this select 1] call EFUNC(common,unMuteUnit); [_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]; _oldPlayer setVariable [QGVAR(isMuted), false, true];
}] call EFUNC(common,addCustomEventHandler);
}] call EFUNC(common,addEventhandler);

View File

@ -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 { 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)]; 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); [_unit, "killedByFriendly", [_unit, _killer]] call EFUNC(common,callCustomEventHandlers);
// Raise ACE globalEvent
["killedByFriendly", [_unit, _killer]] call EFUNC(common,globalEvent);
}; };