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
commit 5bea43910d
6 changed files with 45 additions and 23 deletions

View File

@ -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);

View File

@ -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;
};

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);
};