mirror of
https://github.com/EpochModTeam/DayZ-Epoch.git
synced 2025-12-14 04:02:37 +03:00
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.
253 lines
6.9 KiB
Plaintext
253 lines
6.9 KiB
Plaintext
|
|
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","_isBandit"];
|
|
_unit = _this select 0;
|
|
_hit = _this select 1;
|
|
_damage = _this select 2;
|
|
_unconscious = _unit getVariable ["NORRN_unconscious", false];
|
|
_isPZombie = player isKindOf "PZombie_VB";
|
|
_source = _this select 3;
|
|
_ammo = _this select 4;
|
|
_type = [_damage,_ammo] call fnc_usec_damageType;
|
|
|
|
if (_type == 3) then {
|
|
_damage = _damage * 0.024;
|
|
};
|
|
|
|
_isMinor = (_hit in USEC_MinorWounds);
|
|
_isHeadHit = (_hit == "head_hit");
|
|
//_evType = "";
|
|
//_recordable = false;
|
|
_isPlayer = (isPlayer _source);
|
|
_humanityHit = 0;
|
|
_myKills = 0;
|
|
_unitIsPlayer = _unit == player;
|
|
|
|
//Publish Damage
|
|
//player sidechat format["Processed damage for %1",_unit];
|
|
//USEC_SystemMessage = format["CLIENT: %1 damaged for %2 (in vehicle: %5)",_unit,_damage,_isMinor,_isHeadHit,_inVehicle];
|
|
//PublicVariable "USEC_SystemMessage";
|
|
|
|
/*
|
|
if (_isPlayer) then {
|
|
if (_damage > 0.1) then {
|
|
dayz_canDisconnect = false;
|
|
//["PVDZE_plr_DiscAdd",getPlayerUID player] call callRpcProcedure;
|
|
PVDZE_plr_DiscAdd = getPlayerUID player;
|
|
publicVariableServer "PVDZE_plr_DiscAdd";
|
|
|
|
dayz_damageCounter = time;
|
|
|
|
//Ensure Control is visible
|
|
_display = uiNamespace getVariable 'DAYZ_GUI_display';
|
|
_control = _display displayCtrl 1204;
|
|
_control ctrlShow true;
|
|
};
|
|
};
|
|
*/
|
|
|
|
if (_unitIsPlayer) then {
|
|
if (_hit == "") then {
|
|
if ((_source != player) and _isPlayer) then {
|
|
//Enable aggressor Actions
|
|
if (_source isKindOf "CAManBase") then {
|
|
_source setVariable["startcombattimer",1];
|
|
};
|
|
_canHitFree = player getVariable ["freeTarget",false];
|
|
_isBandit = (player getVariable["humanity",0]) <= -5000;
|
|
_isPZombie = player isKindOf "PZombie_VB";
|
|
|
|
if (!_canHitFree and !_isBandit and !_isPZombie) then {
|
|
//Process Morality Hit
|
|
_myKills = 0 max (1 - (player getVariable ["humanKills",0]) / 5);
|
|
_humanityHit = -100 * _myKills * _damage;
|
|
|
|
//["PVDZE_plr_HumanityChange",[_source,_humanityHit,30]] call broadcastRpcCallAll;
|
|
if (_humanityHit != 0) then {
|
|
PVDZE_plr_HumanityChange = [_source,_humanityHit,30];
|
|
publicVariable "PVDZE_plr_HumanityChange";
|
|
};
|
|
};
|
|
};
|
|
};
|
|
};
|
|
|
|
//PVP Damage
|
|
_scale = 200;
|
|
if (_damage > 0.4) then {
|
|
if (_ammo != "zombie") then {
|
|
_scale = _scale + 50;
|
|
};
|
|
if (_isHeadHit) then {
|
|
_scale = _scale + 500;
|
|
};
|
|
if ((isPlayer _source) and !(player == _source)) then {
|
|
_scale = _scale + 800;
|
|
if (_isHeadHit) then {
|
|
_scale = _scale + 500;
|
|
};
|
|
};
|
|
switch (_type) do {
|
|
case 1: {_scale = _scale + 200};
|
|
case 2: {_scale = _scale + 200};
|
|
};
|
|
if (_unitIsPlayer) then {
|
|
//Cause blood loss
|
|
//Log Damage
|
|
diag_log ("DAMAGE: player hit by " + typeOf _source + " in " + _hit + " with " + _ammo + " for " + str(_damage) + " scaled " + str(_damage * _scale));
|
|
r_player_blood = r_player_blood - (_damage * _scale);
|
|
};
|
|
};
|
|
|
|
//Record Damage to Minor parts (legs, arms)
|
|
if (_hit in USEC_MinorWounds) then {
|
|
if (_ammo == "zombie") then {
|
|
if (_hit == "legs") then {
|
|
[_unit,_hit,(_damage / 6)] call object_processHit;
|
|
} else {
|
|
[_unit,_hit,(_damage / 4)] call object_processHit;
|
|
};
|
|
} else {
|
|
[_unit,_hit,(_damage / 2)] call object_processHit;
|
|
};
|
|
if (_ammo == "") then {
|
|
[_unit,_hit,_damage] call object_processHit;
|
|
};
|
|
};
|
|
|
|
|
|
if (_unitIsPlayer) then {
|
|
//incombat
|
|
_unit setVariable["startcombattimer", 1, false];
|
|
};
|
|
|
|
if (_damage > 0.1) then {
|
|
if (_unitIsPlayer) then {
|
|
//shake the cam, frighten them!
|
|
//player sidechat format["Processed bullet hit for %1 (should only be for me!)",_unit];
|
|
1 call fnc_usec_bulletHit;
|
|
};
|
|
if (local _unit) then {
|
|
_unit setVariable["medForceUpdate",true,true];
|
|
};
|
|
};
|
|
if (_damage > 0.4) then { //0.25
|
|
/*
|
|
BLEEDING
|
|
*/
|
|
_wound = _hit call fnc_usec_damageGetWound;
|
|
_isHit = _unit getVariable[_wound,false];
|
|
if (_unitIsPlayer) then {
|
|
_rndPain = (random 10);
|
|
_rndInfection = (random 500);
|
|
_hitPain = (_rndPain < _damage);
|
|
if ((_isHeadHit) or (_damage > 1.2 and _hitPain)) then {
|
|
_hitPain = true;
|
|
};
|
|
_hitInfection = (_rndInfection < 1);
|
|
//player sidechat format["HitPain: %1, HitInfection %2 (Damage: %3)",_rndPain,_rndInfection,_damage]; //r_player_infected
|
|
if (_isHit) then {
|
|
//Make hit worse
|
|
if (_unitIsPlayer) then {
|
|
r_player_blood = r_player_blood - 50;
|
|
};
|
|
};
|
|
if (_hitInfection) then {
|
|
//Set Infection if not already
|
|
if (_unitIsPlayer and !_isPZombie) then {
|
|
r_player_infected = true;
|
|
player setVariable["USEC_infected",true,true];
|
|
};
|
|
|
|
};
|
|
if (_hitPain) then {
|
|
//Set Pain if not already
|
|
if (_unitIsPlayer) then {
|
|
r_player_inpain = true;
|
|
player setVariable["USEC_inPain",true,true];
|
|
};
|
|
};
|
|
if ((_damage > 1.5) and _isHeadHit) then {
|
|
[_source,"shothead"] spawn player_death;
|
|
};
|
|
};
|
|
if(!_isHit) then {
|
|
|
|
if(!_isPZombie) then {
|
|
//Create Wound
|
|
_unit setVariable[_wound,true,true];
|
|
[_unit,_wound,_hit] spawn fnc_usec_damageBleed;
|
|
usecBleed = [_unit,_wound,_hit];
|
|
publicVariable "usecBleed";
|
|
|
|
//Set Injured if not already
|
|
_isInjured = _unit getVariable["USEC_injured",false];
|
|
if (!_isInjured) then {
|
|
_unit setVariable["USEC_injured",true,true];
|
|
if ((_unitIsPlayer) and (_ammo != "zombie")) then {
|
|
dayz_sourceBleeding = _source;
|
|
};
|
|
};
|
|
//Set ability to give blood
|
|
_lowBlood = _unit getVariable["USEC_lowBlood",false];
|
|
if (!_lowBlood) then {
|
|
_unit setVariable["USEC_lowBlood",true,true];
|
|
};
|
|
if (_unitIsPlayer) then {
|
|
r_player_injured = true;
|
|
};
|
|
};
|
|
};
|
|
};
|
|
if (_type == 1) then {
|
|
/*
|
|
BALISTIC DAMAGE
|
|
*/
|
|
if ((_damage > 0.01) and (_unitIsPlayer)) then {
|
|
//affect the player
|
|
[20,45] call fnc_usec_pitchWhine; //Visual , Sound
|
|
};
|
|
if (_damage > 4) then {
|
|
//serious ballistic damage
|
|
if (_unitIsPlayer) then {
|
|
[_source,"explosion"] spawn player_death;
|
|
};
|
|
} else {
|
|
if (_damage > 2) then {
|
|
_isCardiac = _unit getVariable["USEC_isCardiac",false];
|
|
if (!_isCardiac) then {
|
|
_unit setVariable["USEC_isCardiac",true,true];
|
|
r_player_cardiac = true;
|
|
};
|
|
};
|
|
};
|
|
};
|
|
if (_type == 2) then {
|
|
/*
|
|
HIGH CALIBRE
|
|
*/
|
|
if (_damage > 4) then {
|
|
//serious ballistic damage
|
|
if (_unitIsPlayer) then {
|
|
[_source,"shotheavy"] spawn player_death;
|
|
};
|
|
} else {
|
|
if (_damage > 2) then {
|
|
_isCardiac = _unit getVariable["USEC_isCardiac",false];
|
|
if (!_isCardiac) then {
|
|
_unit setVariable["USEC_isCardiac",true,true];
|
|
r_player_cardiac = true;
|
|
};
|
|
};
|
|
};
|
|
};
|
|
|
|
if (!_unconscious and !_isMinor and ((_damage > 2) or ((_damage > 0.5) and _isHeadHit))) then {
|
|
//set unconsious
|
|
[_unit,_damage] call fnc_usec_damageUnconscious;
|
|
}; |