From 0e77c788094aad52e3a0c7206838b5d1ab5f44f4 Mon Sep 17 00:00:00 2001 From: Armifer Date: Fri, 8 Nov 2013 20:26:12 -0500 Subject: [PATCH] Humanity fix for shooting player zeds and bandits Prevents loss of humanity from shooting player zombies and bandits. Adds a cap to humanity loss per shot depending on the players murders, where the cap is zero. This preventing the shooter from getting positive humanity, which could be exploited to farm humanity using 2 players. --- SQF/dayz_code/compile/fn_damageHandler.sqf | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/SQF/dayz_code/compile/fn_damageHandler.sqf b/SQF/dayz_code/compile/fn_damageHandler.sqf index 96c1a7a0c..ad506fa55 100644 --- a/SQF/dayz_code/compile/fn_damageHandler.sqf +++ b/SQF/dayz_code/compile/fn_damageHandler.sqf @@ -1,11 +1,11 @@ - + scriptName "Functions\misc\fn_damageHandler.sqf"; /*********************************************************** PROCESS DAMAGE TO A UNIT - Function - [unit, selectionName, damage, source, projectile] call fnc_usec_damageHandler; ************************************************************/ -private ["_unit","_humanityHit","_myKills","_hit","_damage","_isPlayer","_unconscious","_wound","_isHit","_isInjured","_type","_hitPain","_isCardiac","_isHeadHit","_isMinor","_scale","_canHitFree","_rndPain","_rndInfection","_hitInfection","_lowBlood","_isPZombie","_source","_ammo","_unitIsPlayer"]; +private ["_unit","_humanityHit","_myKills","_hit","_damage","_isPlayer","_unconscious","_wound","_isHit","_isInjured","_type","_hitPain","_isCardiac","_isHeadHit","_isMinor","_scale","_canHitFree","_rndPain","_rndInfection","_hitInfection","_lowBlood","_isPZombie","_source","_ammo","_unitIsPlayer","_isBandit"]; _unit = _this select 0; _hit = _this select 1; _damage = _this select 2; @@ -59,14 +59,19 @@ if (_unitIsPlayer) then { _source setVariable["startcombattimer",1]; }; _canHitFree = player getVariable ["freeTarget",false]; + _isBandit = (player getVariable["humanity",0]) <= -5000; + _isPZombie = player isKindOf "PZombie_VB"; - if (!_canHitFree) then { - _myKills = 200 - (((player getVariable ["humanKills",0]) / 30) * 100); + if (!_canHitFree and !_isBandit and !_isPZombie) then { //Process Morality Hit - _humanityHit = -(_myKills * _damage); + _myKills = 0 max (1 - (player getVariable ["humanKills",0]) / 5); + _humanityHit = -100 * _myKills * _damage; + //["PVDZE_plr_HumanityChange",[_source,_humanityHit,30]] call broadcastRpcCallAll; - PVDZE_plr_HumanityChange = [_source,_humanityHit,30]; - publicVariable "PVDZE_plr_HumanityChange"; + if (_humanityHit != 0) then { + PVDZE_plr_HumanityChange = [_source,_humanityHit,30]; + publicVariable "PVDZE_plr_HumanityChange"; + }; }; }; };