From c783e6854bdc78d84530c1904332b3f8d3574ee0 Mon Sep 17 00:00:00 2001 From: "DESKTOP-UH65DCE\\MusTanG" Date: Fri, 4 Aug 2017 13:44:03 -0500 Subject: [PATCH] update killed EH if killer is unit exit handler --- .../epoch_code/compile/EPOCH_unitSpawn.sqf | 28 +++++-------------- .../compile/EPOCH_unit_onKilledEH.sqf | 25 +++++++++++++++++ .../Configs/CfgClientFunctions.hpp | 1 + 3 files changed, 33 insertions(+), 21 deletions(-) create mode 100644 Sources/epoch_code/compile/EPOCH_unit_onKilledEH.sqf diff --git a/Sources/epoch_code/compile/EPOCH_unitSpawn.sqf b/Sources/epoch_code/compile/EPOCH_unitSpawn.sqf index 20b8fe52..b5174377 100644 --- a/Sources/epoch_code/compile/EPOCH_unitSpawn.sqf +++ b/Sources/epoch_code/compile/EPOCH_unitSpawn.sqf @@ -57,9 +57,7 @@ switch _unitClass do { _units pushBack _unit; _unit call _disableAI; [_unit,_trgt] execFSM "\x\addons\a3_epoch_code\System\cloak.fsm"; - _unit addEventHandler ["Killed", { - [player, _this select 1, "AntagonistKills", 1, true, Epoch_personalToken] remoteExec ["EPOCH_fnc_updatePlayerStats",2]; - }]; + _unit addEventHandler ["Killed", {[_this, "AntagonistKills", 1, true] call Epoch_unit_onKilledEH;}]; }; }; case "GreatWhite_F": { @@ -70,9 +68,7 @@ switch _unitClass do { _units pushBack _unit; _unit call _disableAI; [_unit] execFSM "\x\addons\a3_epoch_code\System\Shark_Brain.fsm"; - _unit addEventHandler ["Killed", { - [player, _this select 1, "AntagonistKills", 1, true, Epoch_personalToken] remoteExec ["EPOCH_fnc_updatePlayerStats",2]; - }]; + _unit addEventHandler ["Killed", {[_this, "AntagonistKills", 1, true] call Epoch_unit_onKilledEH;}]; }; }; }; @@ -96,9 +92,7 @@ switch _unitClass do { _unit setVariable ["sapperHndl",_sapperHndl]; _unit addEventHandler ["FiredNear", format ["%1 setFSMVariable [""_sFiredNear"",[_this select 1, _this select 2]];",_sapperHndl]]; _unit addEventHandler ["Hit", format ["%1 setFSMVariable [""_sHit"",[_this select 1, _this select 2]];",_sapperHndl]]; - _unit addEventHandler ["Killed", { - [player, _this select 1, "AntagonistKills", 1, true, Epoch_personalToken] remoteExec ["EPOCH_fnc_updatePlayerStats",2]; - }]; + _unit addEventHandler ["Killed", {[_this, "AntagonistKills", 1, true] call Epoch_unit_onKilledEH;}]; }; }; }; @@ -113,9 +107,7 @@ switch _unitClass do { _unit setVariable ["sapperHndl",_sapperHndl]; _unit addEventHandler ["FiredNear", format ["%1 setFSMVariable [""_sFiredNear"",[_this select 1, _this select 2]];",_sapperHndl]]; _unit addEventHandler ["Hit", format ["%1 setFSMVariable [""_sHit"",[_this select 1, _this select 2]];",_sapperHndl]]; - _unit addEventHandler ["Killed", { - [player, _this select 1, "AntagonistKills", 1, true, Epoch_personalToken] remoteExec ["EPOCH_fnc_updatePlayerStats",2]; - }]; + _unit addEventHandler ["Killed", {[_this, "AntagonistKills", 1, true] call Epoch_unit_onKilledEH;}]; }; }; case "Epoch_SapperB_F": { @@ -129,9 +121,7 @@ switch _unitClass do { _unit setVariable ["sapperHndl",_sapperHndl]; _unit addEventHandler ["FiredNear", format ["%1 setFSMVariable [""_sFiredNear"",[_this select 1, _this select 2]];",_sapperHndl]]; _unit addEventHandler ["Hit", format ["%1 setFSMVariable [""_sHit"",[_this select 1, _this select 2]];",_sapperHndl]]; - _unit addEventHandler ["Killed", { - [player, _this select 1, "AntagonistKills", 1, true, Epoch_personalToken] remoteExec ["EPOCH_fnc_updatePlayerStats",2]; - }]; + _unit addEventHandler ["Killed", {[_this, "AntagonistKills", 1, true] call Epoch_unit_onKilledEH;}]; }; }; case "I_UAV_01_F": { @@ -147,9 +137,7 @@ switch _unitClass do { _driver = _grp createUnit["I_UAV_AI", position _unit, [], 0, "CAN_COLLIDE"]; _driver moveInAny _unit; [_unit, _trgt] execFSM "\x\addons\a3_epoch_code\System\Copter_brain.fsm"; - _unit addEventHandler ["Killed", { - [player, _this select 1, "AIKills", 1, true, Epoch_personalToken] remoteExec ["EPOCH_fnc_updatePlayerStats",2]; - }]; + _unit addEventHandler ["Killed", {[_this, "AIKills", 1, true] call Epoch_unit_onKilledEH;}]; }; }; case "PHANTOM": { @@ -198,9 +186,7 @@ switch _unitClass do { _unit enableAI "MOVE"; _unit enableAI "ANIM"; _unit disableAI "FSM"; - _unit addEventHandler ["Killed", { - [player, _this select 1, "AIKills", 1, true, Epoch_personalToken] remoteExec ["EPOCH_fnc_updatePlayerStats",2]; - }]; + _unit addEventHandler ["Killed", {[_this, "AIKills", 1, true] call Epoch_unit_onKilledEH;}]; // randomize skill for "_i" from 0 to ((count _arrSkills)-1) do { _aiskill = floor random (_arrVals select _i); diff --git a/Sources/epoch_code/compile/EPOCH_unit_onKilledEH.sqf b/Sources/epoch_code/compile/EPOCH_unit_onKilledEH.sqf new file mode 100644 index 00000000..5a7df725 --- /dev/null +++ b/Sources/epoch_code/compile/EPOCH_unit_onKilledEH.sqf @@ -0,0 +1,25 @@ +/* + Author: DirtySanchez - EpochMod.com + + Contributors: + + Description: + Antagonist killed event handler + + Licence: + Arma Public License Share Alike (APL-SA) - https://www.bistudio.com/community/licenses/arma-public-license-share-alike + + Github: + https://github.com/EpochModTeam/Epoch/tree/release/Sources/epoch_code/compile/EPOCH_unit_onKilledEH.sqf +*/ +params [ ["_killedEH",[]], ["_statType","AIKills"], ["_adjust", 0], ["_toClient", false] ]; +if(_killedEH isEqualTo [])exitWith{diag_log "EPOCHDebug: unit_onKilledEH -1- EH sent empty array";}; +if(_statType isEqualTo "")exitWith{diag_log "EPOCHDebug: unit_onKilledEH -2- stat Type is empty string";}; +if(_adjust isEqualTo 0)exitWith{diag_log "EPOCHDebug: unit_onKilledEH -3- stat adjustment is 0";}; + +_unit = _killedEH select 0; +_killer = _killedEH select 1; +if(_unit isEqualTo _killer)exitWith{ + //diag_log "EPOCHDebug: unit_onKilledEH -4- unit is killer"; +}; +[player, _killer, _statType, _adjust, _toClient, Epoch_personalToken] remoteExec ["EPOCH_fnc_updatePlayerStats",2]; \ No newline at end of file diff --git a/Sources/epoch_config/Configs/CfgClientFunctions.hpp b/Sources/epoch_config/Configs/CfgClientFunctions.hpp index d6429996..4c4eea13 100644 --- a/Sources/epoch_config/Configs/CfgClientFunctions.hpp +++ b/Sources/epoch_config/Configs/CfgClientFunctions.hpp @@ -43,6 +43,7 @@ class CfgClientFunctions class zombieSpawn {}; class makeMarker {}; class removeMarker {}; + class unit_onKilledEH {}; }; class building {