Heal / Revive - Usage of HandleDamage EH

This commit is contained in:
He-Man 2019-04-04 21:14:56 +02:00
parent 7648181ac4
commit 23c464970b
7 changed files with 96 additions and 5 deletions

View File

@ -0,0 +1,61 @@
/*
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 {
switch _projectile do {
case "B_EnergyPack": {
if (_source distance _unit > 10) exitwith {};
if (missionnamespace getvariable ["EPOCH_OldRevive",false]) exitwith {};
if ((missionnamespace getvariable ["EPOCH_HandleDamageTimeOut",diag_ticktime]) > diag_ticktime) exitwith {}; // prevent multiple actions here
EPOCH_HandleDamageTimeOut = diag_ticktime + 0.1;
_attachments = handgunItems _source;
if ("Heal_EPOCH" in _attachments) then {
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;
};
}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];
};
};
};
if ("Defib_EPOCH" in _attachments) then {
if !(alive _unit) then {
EPOCH_HandleDamageTimeOut = diag_ticktime + 1;
[_unit,_source,Epoch_personalToken] remoteExec ["EPOCH_server_revivePlayer",2];
};
};
};
case "B_KnockOut": {
_unit setUnconscious true;
};
};
};
_damage

View File

@ -41,6 +41,7 @@ switch true do {
_attachments = handgunItems player;
_heal = false;
if (_cursorTarget isKindOf "Man") then {
if !(missionnamespace getvariable ["EPOCH_OldRevive",false]) exitwith {};
if ("Heal_EPOCH" in _attachments) then {
_heal = true;
};

View File

@ -0,0 +1,21 @@
/*
Author: He-Man - EpochMod.com
Contributors:
Description:
Custom A3 Epoch HandleDamage Eventhandler
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/custom/EPOCH_custom_EH_HandleDamage.sqf
*/
params ["_unit", "_selection", "_damage", "_source", "_projectile", "_hitIndex", "_instigator", "_hitPoint"];
_damage

View File

@ -89,6 +89,9 @@ EPOCH_maxBuildingHeight = ["CfgEpochClient", "maxBuildingHeight", 100] call EPOC
EPOCH_MaxBuildingTilt = ["CfgEpochClient", "MaxBuildingTilt", 180] call EPOCH_fnc_returnConfigEntryV2;
Epoch_NuisanceMulti = ["CfgEpochClient", "NuisanceMulti", 0.5] call EPOCH_fnc_returnConfigEntryV2;
// Use Eventhandler "Fired" on Reviver instead of Eventhandler "HandeDamage" on Client to be revived for Heal / Revive Player
EPOCH_OldRevive = ["CfgEpochClient", "UseOldRevive", false] call EPOCH_fnc_returnConfigEntryV2;
//ON INIT and RESPAWN
call EPOCH_clientInit;

View File

@ -101,6 +101,7 @@ class CfgClientFunctions
{
class getInMan {};
class getOutMan {};
class HandleDamage {};
class InventoryClosed {};
class InventoryOpened {};
};
@ -232,6 +233,7 @@ class CfgClientFunctions
class custom_EH_FiredNear {};
class custom_EH_GetInMan {};
class custom_EH_GetOutMan {};
class custom_EH_HandleDamage {};
class custom_EH_Hit {};
class custom_EH_InventoryClosed {};
class custom_EH_InventoryOpened {};

View File

@ -18,6 +18,8 @@ class CfgEpochClient
ArmAVersion = 176;
debug = "true"; // true = enable extra rpt debug lines, false to disable
UseOldRevive = "false"; // Revive / Heal Player has been changed to use "HandleDamage" Eventhandler. If scripts are breaking it for you, set it to true (not recommended!)
antagonistRngChance = 100; // increase number to reduce chances and reduce to increase. Default 100
NuisanceMulti = 0.5; // Multi for Nuisance increase on shooting - higher Nuisance effect at least antagonist spawn change. (0-1, default 0.5)
@ -199,7 +201,7 @@ class CfgEpochClient
displayAddEventHandler[] = {"keyDown","keyUp"};
keyDown = "(_this call EPOCH_KeyDown)";
keyUp = "(_this call EPOCH_KeyUp)";
addEventHandler[] = {"Respawn","Put","Take","InventoryClosed","InventoryOpened","FiredMan","Killed","HandleRating","HandleScore","GetInMan","GetOutMan","Hit","SeatSwitchedMan","FiredNear"};
addEventHandler[] = {"Respawn","Put","Take","InventoryClosed","InventoryOpened","FiredMan","Killed","HandleRating","HandleScore","HandleDamage","GetInMan","GetOutMan","Hit","SeatSwitchedMan","FiredNear"};
Respawn = "(_this select 0) call EPOCH_clientRespawn";
Put = "(_this select 1) call EPOCH_interact;_this call EPOCH_PutHandler;_this call Epoch_custom_EH_Put";
Take = "(_this select 1) call EPOCH_interact;_this call EPOCH_UnisexCheck;_this call Epoch_custom_EH_Take";
@ -209,7 +211,7 @@ class CfgEpochClient
Killed = "_this call EPOCH_fnc_playerDeath;_this call Epoch_custom_EH_Killed";
HandleRating = "0";
HandleScore = "";
HandleDamage = "";
HandleDamage = "_this call EPOCH_HandleDamage;_this call EPOCH_custom_EH_HandleDamage";
HandleHeal = "";
Dammaged = "";
Hit = "_this call EPOCH_custom_EH_Hit";

View File

@ -13,12 +13,13 @@
https://github.com/EpochModTeam/Epoch/tree/release/Sources/epoch_server/compile/epoch_player/EPOCH_server_revivePlayer.sqf
*/
//[[[cog import generate_private_arrays ]]]
private ["_loadabs","_loadout","_CorpseCrypto","_PlayerCrypto","_attachments","_cIndex","_class","_currwh","_deleteprimary","_deletesecondary","_dir","_droppedPrimary","_droppedSecondary","_droppedWeapons","_equipped","_group","_garbage","_location","_newPlyr","_playerGroup","_playerUID","_token","_type","_vars","_wMags","_wMagsArray","_weapon","_wh","_kIndex","_reviver","_reviverCStats","_reviverKarma","_reviverKarmaAdj"];
private ["_caller","_loadabs","_loadout","_CorpseCrypto","_PlayerCrypto","_attachments","_cIndex","_class","_currwh","_deleteprimary","_deletesecondary","_dir","_droppedPrimary","_droppedSecondary","_droppedWeapons","_equipped","_group","_garbage","_location","_newPlyr","_playerGroup","_playerUID","_token","_type","_vars","_wMags","_wMagsArray","_weapon","_wh","_kIndex","_reviver","_reviverCStats","_reviverKarma","_reviverKarmaAdj"];
//[[[end]]]
params ["_player","_reviver",["_token","",[""]] ];
if !([_reviver, _token] call EPOCH_server_getPToken) exitWith{};
_caller = if (remoteExecutedOwner == (owner _reviver)) then {_reviver} else {_player};
if !([_caller, _token] call EPOCH_server_getPToken) exitWith{};
if (isNull _player) exitWith{};
if !(isplayer _reviver) exitWith{};
if (_player distance _reviver > 20) exitWith{};
if (!local _player) then {