Epoch/Sources/epoch_code/compile/event_handlers/EPOCH_HandleDamage.sqf

85 lines
3.1 KiB
Plaintext
Raw Normal View History

/*
Author: He-Man - EpochMod.com
Contributors:
Description:
HandleDamage Eventhandler for A3 Epoch
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_HandleDamage.sqf
*/
params ["_unit", "_selection", "_damage", "_source", "_projectile", "_hitIndex", "_instigator", "_hitPoint"];
if !(_source isEqualTo _unit) then {
2019-04-04 20:12:52 +00:00
if ((missionnamespace getvariable ["EPOCH_HandleDamageTimeOut",diag_ticktime]) > diag_ticktime) exitwith {}; // prevent multiple actions here
2019-09-13 12:59:01 +00:00
EPOCH_HandleDamageTimeOut = diag_ticktime + 0.1;
switch _projectile do {
case "B_EnergyPack": {
2019-09-13 12:53:47 +00:00
if (_source distance _unit > 10) exitwith {};
if !(missionnamespace getvariable ["EPOCH_OldRevive",false]) then {
_attachments = handgunItems _source;
2019-09-13 12:59:01 +00:00
if ("Heal_EPOCH" in _attachments) exitwith {
2019-09-13 12:53:47 +00:00
if (lifeState _unit == "INCAPACITATED") exitwith {
EPOCH_HandleDamageTimeOut = diag_ticktime + 1;
_unit setUnconscious false;
_unit playMoveNow 'AmovPercMstpSnonWnonDnon';
};
_highestDMG = 0;
_currentHIT = -1;
_currentDMG = 0;
{
_currentDMG = _x;
if (_currentDMG > _highestDMG) then{
_highestDMG = _currentDMG;
_currentHIT = _forEachIndex;
2019-07-21 14:45:23 +00:00
};
2019-09-13 12:53:47 +00:00
}forEach((getAllHitPointsDamage _unit) param[2,[]]);
if (_highestDMG > 0) then {
_newDMG = 0;
[_unit,[[_currentHIT,_newDMG]]] call EPOCH_client_repairVehicle;
} else {
if ((damage _unit) > 0) then {
[_unit,["ALL",0],player,Epoch_personalToken] remoteExec ["EPOCH_server_repairVehicle",2];
2019-07-21 14:45:23 +00:00
};
};
2019-09-13 12:53:47 +00:00
};
2019-09-13 12:59:01 +00:00
if ("Defib_EPOCH" in _attachments) exitwith {
2019-09-13 12:53:47 +00:00
if !(alive _unit) then {
EPOCH_HandleDamageTimeOut = diag_ticktime + 1;
[_unit,_source,Epoch_personalToken] remoteExec ["EPOCH_server_revivePlayer",2];
};
};
};
};
2019-09-13 12:53:47 +00:00
case "shell_12g_bb";
case "bbag_pvc";
case "xbow_tranq";
case "tranq_dart": {
2019-04-04 19:24:27 +00:00
if !(lifeState _unit == "INCAPACITATED") then {
EPOCH_HandleDamageTimeOut = diag_ticktime + 1;
_unit setUnconscious true;
2019-09-13 12:53:47 +00:00
(["CfgEpochClient", "UnconsciousTime", [60,180]] call EPOCH_fnc_returnConfigEntryV2) params [["_mintime",60],["_maxtime",180]];
EPOCH_UnconsciousTime = diag_ticktime + _mintime + (random (_maxtime - _mintime));
2019-07-21 14:45:23 +00:00
["You are Knocked out for a while...",5] call Epoch_Message;
2019-04-04 19:24:27 +00:00
};
};
2019-09-13 12:53:47 +00:00
case "B_Swing";
case "B_Stick";
case "B_Hatchet": {
if !(lifeState _unit == "INCAPACITATED") then {
if ((random 100) < (["CfgEpochClient", "UnconsciousChance", 30] call EPOCH_fnc_returnConfigEntryV2)) then {
EPOCH_HandleDamageTimeOut = diag_ticktime + 1;
_unit setUnconscious true;
(["CfgEpochClient", "UnconsciousTime", [60,180]] call EPOCH_fnc_returnConfigEntryV2) params [["_mintime",60],["_maxtime",180]];
EPOCH_UnconsciousTime = diag_ticktime + _mintime + (random (_maxtime - _mintime));
["You are Knocked out for a while...",5] call Epoch_Message;
};
};
};
};
};
_damage