Adding basic pve support

Around 50% of all servers are pve servers. This commit adds a basic support and prevent the player vs. player damage. Also if pve is enabled and DZE_BackpackAntiTheft too, the backpack anti theft is active for the whole server.
This commit is contained in:
A Man
2019-11-11 10:00:47 +01:00
parent 6699d8d746
commit e7dbc5dd4c
4 changed files with 98 additions and 87 deletions

View File

@@ -6,6 +6,7 @@
[NEW] Added new waterbottles from DayZ Mod. Icons made by @DeVloek. Fully functional with all actions. @AirwavesMan [NEW] Added new waterbottles from DayZ Mod. Icons made by @DeVloek. Fully functional with all actions. @AirwavesMan
[NEW] All fuel containers can be emptied now. (276615a) @AirwavesMan [NEW] All fuel containers can be emptied now. (276615a) @AirwavesMan
[NEW] Different boxes of matches can be combined now. (bc75ad8) @AirwavesMan [NEW] Different boxes of matches can be combined now. (bc75ad8) @AirwavesMan
[NEW] Adding a basic support for PVE Servers. This disables the PvP damage on the server. Disabled by default, configVariables.sqf/DZE_PVE_Mode @AirwavesMan
[FIXED] Some more occurrences of zero_building interiors misaligned or at the wrong terrain height (eaaedf2, 048caa5) @ebayShopper [FIXED] Some more occurrences of zero_building interiors misaligned or at the wrong terrain height (eaaedf2, 048caa5) @ebayShopper
[FIXED] Player could switch into gunner's seat of ArmoredSUV while the hatch was being closed (e89eebc) #2009 @TheFirstNoob [FIXED] Player could switch into gunner's seat of ArmoredSUV while the hatch was being closed (e89eebc) #2009 @TheFirstNoob

View File

@@ -5,7 +5,7 @@ scriptName "Functions\misc\fn_damageHandler.sqf";
- Function - Function
- [unit, selectionName, damage, source, projectile] call fnc_usec_damageHandler; - [unit, selectionName, damage, source, projectile] call fnc_usec_damageHandler;
************************************************************/ ************************************************************/
private ["_end","_unit","_hit","_damage","_unconscious","_source","_ammo","_isMinor","_isHeadHit","_isPlayer","_isBandit","_punishment","_humanityHit","_myKills","_wpst","_sourceDist","_sourceWeap","_scale","_type","_rndPain","_hitPain","_wound","_isHit","_isbleeding","_rndBleed","_hitBleed","_isInjured","_lowBlood","_isCardiac","_chance","_falling","_model","_isZombieHit","_sourceType","_sourceVehicleType","_isMan","_isVehicle","_isLocal","_inVehicle"]; private ["_end","_unit","_hit","_damage","_unconscious","_source","_ammo","_isMinor","_isHeadHit","_isPlayer","_isBandit","_punishment","_humanityHit","_myKills","_wpst","_sourceDist","_sourceWeap","_scale","_type","_rndPain","_hitPain","_wound","_isHit","_isbleeding","_rndBleed","_hitBleed","_isInjured","_lowBlood","_isCardiac","_chance","_falling","_model","_isZombieHit","_sourceType","_sourceVehicleType","_isMan","_isVehicle","_isLocal","_inVehicle","_vehicleArray","_isPZombie","_isScratched","_rndBleedChance"];
_unit = _this select 0; _unit = _this select 0;
_hit = _this select 1; _hit = _this select 1;
_damage = _this select 2; _damage = _this select 2;
@@ -49,12 +49,12 @@ _falling = (((_hit == "legs") AND {(_source==_unit)}) AND {((_ammo=="") AND {(Da
_end = false; _end = false;
if (!_falling) then { if (!_falling) then {
if (_ammo == "" && _hit == "" && _inVehicle) then {_ammo = "Crash";}; if (_ammo == "" && {_hit == ""} && {_inVehicle}) then {_ammo = "Crash";};
//No _ammo type exit, indirect/physics damage. //No _ammo type exit, indirect/physics damage.
if (_ammo == "") exitwith { _end = true; }; if (_ammo == "") exitwith { _end = true; };
//If _source contains no object exit. But lets not exit if the unit returns player. Maybe its his own fault. //If _source contains no object exit. But lets not exit if the unit returns player. Maybe its his own fault.
if (isNull _source && !(_ammo in ["Dragged","RunOver"])) then { if (isNull _source && {!(_ammo in ["Dragged","RunOver"])}) then {
_vehicleArray = nearestObjects [([vehicle _unit] call fnc_getPos),["Air","LandVehicle","Ship","TrapTripwireGrenade"],25]; _vehicleArray = nearestObjects [([vehicle _unit] call fnc_getPos),["Air","LandVehicle","Ship","TrapTripwireGrenade"],25];
//Don't exit if a drivable vehicle (or drivable vehicle wreck) is nearby, because vehicle explosions register as a null source //Don't exit if a drivable vehicle (or drivable vehicle wreck) is nearby, because vehicle explosions register as a null source
if (({typeOf _x != "ParachuteWest"} count _vehicleArray) == 0) then { if (({typeOf _x != "ParachuteWest"} count _vehicleArray) == 0) then {
@@ -81,6 +81,8 @@ _isPZombie = _model isKindOf "PZombie_VB";
_isMan = _sourceType isKindOf "CAManBase"; _isMan = _sourceType isKindOf "CAManBase";
_isPlayer = (isPlayer _source); _isPlayer = (isPlayer _source);
if (DZE_PVE_Mode && {_isPlayer} && {!_falling}) exitWith {};
if (_unit == player) then { if (_unit == player) then {
//Set player in combat //Set player in combat
_unit setVariable["startcombattimer", 1]; _unit setVariable["startcombattimer", 1];
@@ -88,15 +90,15 @@ if (_unit == player) then {
_unit setVariable["inCombat",true,true]; _unit setVariable["inCombat",true,true];
}; };
if (_hit == "" && _ammo != "Crash") exitWith //Ignore none part dmg. Exit after processing humanity hit. Don't punish driver for damaging passenger in crash if (_hit == "" && {_ammo != "Crash"}) exitWith //Ignore none part dmg. Exit after processing humanity hit. Don't punish driver for damaging passenger in crash
{ {
if (!_isLocal && _isPlayer && alive player && !_isPZombie) then //Do not punish for shooting a player zombie if (!_isLocal && {_isPlayer} && {alive player} && {!_isPZombie}) then //Do not punish for shooting a player zombie
{ {
_isBandit = (player getVariable["humanity",0]) <= -5000; _isBandit = (player getVariable["humanity",0]) <= -5000;
//_isBandit = (_model in ["Bandit1_DZ","BanditW1_DZ"]); //_isBandit = (_model in ["Bandit1_DZ","BanditW1_DZ"]);
//if player is not free to shoot at inform server that _source shot at player //if player is not free to shoot at inform server that _source shot at player
if (!_isBandit && !(player getVariable ["OpenTarget",false])) then if (!_isBandit && {!(player getVariable ["OpenTarget",false])}) then
{ {
PVDZ_send = [(effectiveCommander vehicle _source),"OpenTarget",[]]; PVDZ_send = [(effectiveCommander vehicle _source),"OpenTarget",[]];
publicVariableServer "PVDZ_send"; publicVariableServer "PVDZ_send";
@@ -139,6 +141,8 @@ if (_unit == player) then {
if (_ammo == "tranquiliser_bolt") then { if (_ammo == "tranquiliser_bolt") then {
r_player_timeout = 20 + round(random 60); r_player_timeout = 20 + round(random 60);
[_unit] spawn { [_unit] spawn {
private "_unit";
_unit = _this select 0; _unit = _this select 0;
localize "str_player_tranquilized" call dayz_rollingMessages; localize "str_player_tranquilized" call dayz_rollingMessages;
[_unit,0.01] call fnc_usec_damageUnconscious; [_unit,0.01] call fnc_usec_damageUnconscious;
@@ -149,9 +153,11 @@ if (_unit == player) then {
if (_damage > 0.4) then { if (_damage > 0.4) then {
//Melee knockout system //Melee knockout system
if ((_isHeadHit) && (_ammo in ["Crowbar_Swing_Ammo","Bat_Swing_Ammo","Sledge_Swing_Ammo"])) then { if ((_isHeadHit) && {_ammo in ["Crowbar_Swing_Ammo","Bat_Swing_Ammo","Sledge_Swing_Ammo"]}) then {
r_player_timeout = 20 + round(random 60); r_player_timeout = 20 + round(random 60);
[_unit] spawn { [_unit] spawn {
private "_unit";
_unit = _this select 0; _unit = _this select 0;
localize "str_actions_medical_knocked_out" call dayz_rollingMessages; localize "str_actions_medical_knocked_out" call dayz_rollingMessages;
[_unit,0.01] call fnc_usec_damageUnconscious; [_unit,0.01] call fnc_usec_damageUnconscious;
@@ -170,46 +176,46 @@ if (_unit == player) then {
_wpst = weaponState _source; _wpst = weaponState _source;
_source setVariable ["lastloghit",diag_ticktime]; _source setVariable ["lastloghit",diag_ticktime];
_sourceDist = round(_unit distance _source); _sourceDist = round(_unit distance _source);
_sourceWeap = switch (true) do { _sourceWeap = call {
case (_ammo in ["PipeBomb","Mine","MineE"]): { format["with %1",_ammo] }; if (_ammo in ["PipeBomb","Mine","MineE"]) exitwith { format["with %1",_ammo] };
case (_isVehicle) : { format ["with %1",_sourceVehicleType] }; if (_isVehicle) exitwith { format ["with %1",_sourceVehicleType] };
case (_ammo in MeleeAmmo) : { format ["with %2%1",_wpst select 0, if (_sourceDist>6) then {"suspicious weapon "} else {""}] }; if (_ammo in MeleeAmmo) exitwith { format ["with %2%1",_wpst select 0, if (_sourceDist>6) then {"suspicious weapon "} else {""}] };
case (_wpst select 0 == "Throw") : { format ["with %1 thrown", _wpst select 3] }; if (_wpst select 0 == "Throw") exitwith { format ["with %1 thrown", _wpst select 3] };
case (["Horn",currentWeapon _source] call fnc_inString) : { format ["with %1 suspicious", currentWeapon _source]}; if (["Horn",currentWeapon _source] call fnc_inString) exitwith { format ["with %1 suspicious", currentWeapon _source]};
case ((_wpst select 0 == "") AND {_wpst select 4 == 0}) : { format ["with %1/%2 suspicious", primaryWeapon _source, _ammo] }; if ((_wpst select 0 == "") AND {_wpst select 4 == 0}) exitwith { format ["with %1/%2 suspicious", primaryWeapon _source, _ammo] };
case (_wpst select 0 != "") : { format ["with %1/%2 <ammo left:%3>", _wpst select 0, _ammo, _wpst select 4] }; if (_wpst select 0 != "") exitwith { format ["with %1/%2 <ammo left:%3>", _wpst select 0, _ammo, _wpst select 4] };
default { "with suspicious weapon" }; "with suspicious weapon";
}; };
PVDZ_sec_atp = [_unit, _source, _sourceWeap, _sourceDist, _hit, (_damage min 999999)]; PVDZ_sec_atp = [_unit, _source, _sourceWeap, _sourceDist, _hit, (_damage min 999999)];
publicVariableServer "PVDZ_sec_atp"; publicVariableServer "PVDZ_sec_atp";
}; };
dayz_lastDamageSource = switch (true) do { dayz_lastDamageSource = call {
case (_falling): {"fall"}; if (_falling) exitwith {"fall"};
case (_isZombieHit): {"zombie"}; if (_isZombieHit) exitwith {"zombie"};
case (_ammo == "Crash"): {"crash"}; if (_ammo == "Crash") exitwith {"crash"};
case (_ammo == "RunOver"): {"runover"}; if (_ammo == "RunOver") exitwith {"runover"};
case (_ammo == "Dragged"): {"eject"}; if (_ammo == "Dragged") exitwith {"eject"};
case (_ammo in MeleeAmmo): {"melee"}; if (_ammo in MeleeAmmo) exitwith {"melee"};
case (!_isLocal && {(_isMan && !(currentWeapon _source in ["","Throw"])) or _isVehicle}): {"shot"}; if (!_isLocal && {(_isMan && !(currentWeapon _source in ["","Throw"])) or _isVehicle}) exitwith {"shot"};
default {"none"}; "none";
}; };
if (dayz_lastDamageSource != "none") then {dayz_lastDamageTime = diag_tickTime;}; if (dayz_lastDamageSource != "none") then {dayz_lastDamageTime = diag_tickTime;};
}; };
//Ignore none part dmg. Exit after processing humanity hit //Ignore none part dmg. Exit after processing humanity hit
if (_hit == "" && _ammo != "Crash") exitWith { 0 }; if (_hit == "" && {_ammo != "Crash"}) exitWith { 0 };
//Ammo Type Setup //Ammo Type Setup
_type = switch true do { _type = call {
case ({_ammo isKindOf _x} count ["Grenade","ShellBase","TimeBombCore","BombCore","MissileCore","RocketCore","FuelExplosion","GrenadeBase"] > 0): { 1 }; if ({_ammo isKindOf _x} count ["Grenade","ShellBase","TimeBombCore","BombCore","MissileCore","RocketCore","FuelExplosion","GrenadeBase"] > 0) exitwith { 1 };
case ((_ammo isKindof "B_127x107_Ball") or (_ammo isKindof "B_127x99_Ball")): { 2 }; if ((_ammo isKindof "B_127x107_Ball") or (_ammo isKindof "B_127x99_Ball")) exitwith { 2 };
case (_isZombieHit): { 3 }; if (_isZombieHit) exitwith { 3 };
case (_ammo == "RunOver"): { 4 }; if (_ammo == "RunOver") exitwith { 4 };
case (_ammo == "Dragged"): { 5 }; if (_ammo == "Dragged") exitwith { 5 };
case (_ammo == "Crash"): { 6 }; if (_ammo == "Crash") exitwith { 6 };
default { 0 }; 0;
}; };
//Shake the cam, frighten them! //Shake the cam, frighten them!
@@ -234,7 +240,7 @@ if (_damage > 0.4) then {
//End body part scale //End body part scale
//??????????? //???????????
if (!(player == _source) && (_isPlayer or (_isMan && !_isZombieHit))) then { //Scale shots from AI units the same as shots from players if (!(player == _source) && {_isPlayer or (_isMan && {!_isZombieHit})}) then { //Scale shots from AI units the same as shots from players
dayz_sourceBleeding = _source; //Used in player_death dayz_sourceBleeding = _source; //Used in player_death
_scale = _scale + 800; _scale = _scale + 800;
if (_isHeadHit) then { if (_isHeadHit) then {
@@ -247,19 +253,19 @@ if (_damage > 0.4) then {
}; };
//Modify base scale based on the types, Allows us to modify specific types of damage if needed. //Modify base scale based on the types, Allows us to modify specific types of damage if needed.
switch (_type) do { call {
//Explosions //Explosions
case 1: {_scale = _scale + 300}; if (_type == 1) exitwith {_scale = _scale + 300};
//Bullet types //Bullet types
case 2: {_scale = _scale + 150}; if (_type == 2) exitwith {_scale = _scale + 150};
//Zombies //Zombies
case 3: {_scale = getNumber (configFile >> "CfgVehicles" >> _sourceType >> "damageScale"); if (dayz_DamageMultiplier > 1) then {_scale = _scale * dayz_DamageMultiplier;};}; if (_type == 3) exitwith {_scale = getNumber (configFile >> "CfgVehicles" >> _sourceType >> "damageScale"); if (dayz_DamageMultiplier > 1) then {_scale = _scale * dayz_DamageMultiplier;};};
//RunOver //RunOver
case 4: {_scale = 10}; //Based on 12k blood for run over with SUV at 70km/h if (_type == 4) exitwith {_scale = 10}; //Based on 12k blood for run over with SUV at 70km/h
//Dragged //Dragged
case 5: {_scale = 25}; if (_type == 5) exitwith {_scale = 25};
//Crash //Crash
case 6: {_scale = 400}; if (_type == 6) exitwith {_scale = 400};
}; };
//Display some info in the players log file. //Display some info in the players log file.
@@ -271,7 +277,7 @@ if (_damage > 0.4) then {
_rndPain = floor(random 10); _rndPain = floor(random 10);
_hitPain = (_rndPain < _damage); _hitPain = (_rndPain < _damage);
if ((_isHeadHit) or (_hitPain)) then { if ((_isHeadHit) || {_hitPain}) then {
_hitPain = true; _hitPain = true;
}; };
@@ -297,7 +303,7 @@ if (_damage > 0.4) then {
}; };
if (_type == 3) then { if (_type == 3) then {
if (!_isHit && _isbleeding && !_isPZombie) then { if (!_isHit && {_isbleeding} && {!_isPZombie}) then {
//Create Wound //Create Wound
_unit setVariable["hit_"+_wound,true,true]; _unit setVariable["hit_"+_wound,true,true];
@@ -326,8 +332,10 @@ if (_damage > 0.4) then {
}; };
//HitInfection from zombies //HitInfection from zombies
if ((!r_player_infected) and !(r_player_Sepsis select 0)) then { if ((!r_player_infected) && {!(r_player_Sepsis select 0)}) then {
if (_type == 3) then { if (_type == 3) then {
private ["_rndSepsis", "_sepsisChance"];
_rndSepsis = floor(random 100); _rndSepsis = floor(random 100);
_sepsisChance = getNumber (configFile >> "CfgVehicles" >> _sourceType >> "sepsisChance"); _sepsisChance = getNumber (configFile >> "CfgVehicles" >> _sourceType >> "sepsisChance");
@@ -350,7 +358,7 @@ if (_damage > 0.4) then {
_isInjured = _unit getVariable["USEC_injured",false]; _isInjured = _unit getVariable["USEC_injured",false];
if (!_isInjured) then { if (!_isInjured) then {
_unit setVariable["USEC_injured",true,true]; _unit setVariable["USEC_injured",true,true];
if ((_unit == player) and (!_isZombieHit)) then { if ((_unit == player) && {!_isZombieHit}) then {
dayz_sourceBleeding = _source; dayz_sourceBleeding = _source;
}; };
}; };
@@ -376,6 +384,8 @@ if (_hit in USEC_MinorWounds) then {
}; };
} else { } else {
if (_falling) then { if (_falling) then {
private ["_nrj2", "_gravity"];
_gravity = 9.81 min (2*(Dayz_freefall select 1)/((0.00001 + (Dayz_freefall select 2))^2)); _gravity = 9.81 min (2*(Dayz_freefall select 1)/((0.00001 + (Dayz_freefall select 2))^2));
_nrj2 = _gravity * (Dayz_freefall select 1); _nrj2 = _gravity * (Dayz_freefall select 1);
if (random(_nrj2 / (5 * 9.81)) > 0.5) then { // freefall from 5m => 1/2 chance to get hit legs registered if (random(_nrj2 / (5 * 9.81)) > 0.5) then { // freefall from 5m => 1/2 chance to get hit legs registered
@@ -399,7 +409,7 @@ if (_type == 1) then {
/* /*
BALISTIC DAMAGE BALISTIC DAMAGE
*/ */
if ((_damage > 0.01) and (_unit == player)) then { if ((_damage > 0.01) && {_unit == player}) then {
//affect the player //affect the player
[20,45] call fnc_usec_pitchWhine; //Visual , Sound [20,45] call fnc_usec_pitchWhine; //Visual , Sound
}; };
@@ -440,14 +450,14 @@ if (_type == 2) then {
}; };
if (_type == 3) then { if (_type == 3) then {
if (!_unconscious and !_isMinor and _isHeadHit) then { if (!_unconscious && {!_isMinor} && {_isHeadHit}) then {
_chance = random 1; _chance = random 1;
if ((_damage > 0.8) and (_chance < 0.5)) then { if ((_damage > 0.8) && {_chance < 0.5}) then {
[_unit,_damage] call fnc_usec_damageUnconscious; [_unit,_damage] call fnc_usec_damageUnconscious;
}; };
}; };
} else { } else {
if (!_unconscious and !_isMinor and ((_damage > 2) or ((_damage > 0.5) and _isHeadHit))) then { if (!_unconscious && {!_isMinor} && {(_damage > 2) || {(_damage > 0.5) && {_isHeadHit}}}) then {
//set unconsious //set unconsious
[_unit,_damage] call fnc_usec_damageUnconscious; [_unit,_damage] call fnc_usec_damageUnconscious;
}; };
@@ -455,4 +465,3 @@ if (_type == 3) then {
// all "HandleDamage event" functions should return the effective damage that the engine will record // all "HandleDamage event" functions should return the effective damage that the engine will record
0 0

View File

@@ -1,13 +1,13 @@
setMousePosition [0.5, 0.5]; setMousePosition [0.5, 0.5];
private ["_exit","_nearestObjects","_rID","_display","_cTarget","_dis","_friendlyTo","_lastSave","_startTime"]; private ["_exit","_nearestObjects","_rID","_display","_cTarget","_dis","_friendlyTo","_lastSave","_startTime","_vehType","_gearSelection","_supplyPositionWorld","_ctType"];
// players inside vehicle can always access its gear // players inside vehicle can always access its gear
if ((vehicle player) == player) then { if ((vehicle player) == player) then {
disableSerialization; disableSerialization;
_display = _this select 0; _display = _this select 0;
_cTarget = cursorTarget; _cTarget = cursorTarget;
_dis = if (_cTarget isKindOf "USEC_ch53_E" || _cTarget isKindOf "MV22") then {25} else {12}; _dis = [12,25] select (_cTarget isKindOf "USEC_ch53_E" || {_cTarget isKindOf "MV22"});
_exit = false; _exit = false;
if (!DZE_GearCheckBypass) then { if (!DZE_GearCheckBypass) then {
@@ -33,7 +33,7 @@ if ((vehicle player) == player) then {
if (DZE_BackpackAntiTheft) then { if (DZE_BackpackAntiTheft) then {
_friendlyTo = player getvariable ["friendlyTo",[]]; _friendlyTo = player getvariable ["friendlyTo",[]];
_rID = if (DZE_permanentPlot) then { getPlayerUID _cTarget } else { _cTarget getVariable ["CharacterID","0"] }; _rID = if (DZE_permanentPlot) then { getPlayerUID _cTarget } else { _cTarget getVariable ["CharacterID","0"] };
if ((!canbuild or isInTraderCity) && {alive _cTarget} && {isPlayer _cTarget} && {!(_rID in _friendlyTo) && !(_cTarget in (units group player))} && {(player distance _cTarget) < 12}) then { if ((isInTraderCity || {DZE_PVE_Mode} || {!canbuild}) && {alive _cTarget} && {isPlayer _cTarget} && {!(_rID in _friendlyTo) && !(_cTarget in (units group player))} && {(player distance _cTarget) < 12}) then {
localize "STR_EPOCH_PLAYER_316" call dayz_rollingMessages; localize "STR_EPOCH_PLAYER_316" call dayz_rollingMessages;
_display closeDisplay 2; _display closeDisplay 2;
}; };

View File

@@ -35,6 +35,7 @@ DZE_NutritionDivisor = [1, 1, 1, 1]; //array of DIVISORS that regulate the rate
DZE_ZombieSpeed = [0,0]; //Default agro speed is 6 per zombie config, set array elements 0 and 1 the same for non-variable speed, set to 0 to disable. array format = [min, max]; Ex: [2, 6]; results in a range of speed between 2 and 6 (2 is the old DZE_slowZombies hard-coded speed) DZE_ZombieSpeed = [0,0]; //Default agro speed is 6 per zombie config, set array elements 0 and 1 the same for non-variable speed, set to 0 to disable. array format = [min, max]; Ex: [2, 6]; results in a range of speed between 2 and 6 (2 is the old DZE_slowZombies hard-coded speed)
DZE_lockablesHarderPenalty = true; // Enforce an exponential wait on attempts between unlocking a safe/lockbox from a failed code. DZE_lockablesHarderPenalty = true; // Enforce an exponential wait on attempts between unlocking a safe/lockbox from a failed code.
DZE_Hide_Body = true; //Enable hide dead bodies. Hiding a dead body removes the corpse marker from the map too. Default = true DZE_Hide_Body = true; //Enable hide dead bodies. Hiding a dead body removes the corpse marker from the map too. Default = true
DZE_PVE_Mode = false; //Disable the PvP damage on the server. If DZE_BackpackAntiTheft = true, the backpack anti theft is active on the whle server. This is just a basic support for PVE Servers. Default = false
// SafeZone // SafeZone
DZE_SafeZoneZombieLoot = false; // Enable spawning of Zombies and loot in positions listed in DZE_SafeZonePosArray? DZE_SafeZoneZombieLoot = false; // Enable spawning of Zombies and loot in positions listed in DZE_SafeZonePosArray?