mirror of
https://github.com/EpochModTeam/DayZ-Epoch.git
synced 2025-12-13 19:52:38 +03:00
Update for A2 1.64 GetHit
Replaced vehicle sethit/setvariable method with sethit/gethit and removed setvariable "Hit_" commands for vehicles (hit_partname can now probably be added to the setvariable filters list). Modified object_getHit.sqf return to now provide the selection name in order to reduce redundant config lookups. Returns '[Damage, Part Name]', instead of just 'Damage' Modified vehicle_GetHitpoints.sqf to remove incorrect hipoints from returning. Previously this script would return all hitpoints from any vehicle the current vehicle config inherited from, even if the hitpoint didn't exist in the calling vehicle. this posed a problem since getHit on an invalid part name returns Nil
This commit is contained in:
@@ -30,7 +30,7 @@ _sellVehicle = {
|
||||
_hitpoints = DZE_myVehicle call vehicle_getHitpoints;
|
||||
{
|
||||
if (["Wheel",_x,false] call fnc_inString) then {
|
||||
_damage = [DZE_myVehicle,_x] call object_getHit;
|
||||
_damage = ([DZE_myVehicle,_x] call object_getHit) select 0;
|
||||
_tireDmg = _tireDmg + _damage;
|
||||
_tires = _tires + 1;
|
||||
};
|
||||
|
||||
@@ -34,12 +34,14 @@ if ("ItemToolbox" in items player && (_part in magazines player)) then {
|
||||
// Added Nutrition-Factor for work
|
||||
["Working",0,[20,40,15,0]] call dayz_NutritionSystem;
|
||||
|
||||
_damage = [_vehicle,_hitpoint] call object_getHit;
|
||||
_hits = [_vehicle,_hitpoint] call object_getHit;
|
||||
_damage = _hits select 0;
|
||||
|
||||
_vehicle removeAction _id;
|
||||
//dont waste loot on undamaged parts
|
||||
if (_damage > 0) then {
|
||||
//Fix the part
|
||||
_selection = getText(configFile >> "cfgVehicles" >> _type >> "HitPoints" >> _hitpoint >> "name");
|
||||
_selection = _hits select 1;
|
||||
|
||||
[_vehicle, _selection, 0, true] call fnc_veh_handleRepair;
|
||||
_vehicle setvelocity [0,0,1];
|
||||
|
||||
@@ -8,7 +8,8 @@ _hitpoints = _vehicle call vehicle_getHitpoints;
|
||||
|
||||
{
|
||||
_hitpoint = _x;
|
||||
_damage = [_vehicle,_x] call object_getHit;
|
||||
_hits = [_vehicle,_x] call object_getHit;
|
||||
_damage = _hits select 0;
|
||||
|
||||
_cmpt = toArray (_x);
|
||||
_cmpt set [0,20];
|
||||
|
||||
@@ -31,7 +31,8 @@ if (_hasToolbox) then {
|
||||
["Working",0,[20,40,15,0]] call dayz_NutritionSystem;
|
||||
//Remove melee magazines (BIS_fnc_invAdd fix)
|
||||
false call dz_fn_meleeMagazines;
|
||||
_damage = [_vehicle,_hitpoint] call object_getHit;
|
||||
_hits = [_vehicle,_hitpoint] call object_getHit;
|
||||
_damage = _hits select 0;
|
||||
if (_damage < 1 && {_damage > 0}) then { //Tempfix for issue where certain hitpoints on some vehicles do not get damaged and allow infinite removal
|
||||
_BreakableParts = ["HitGlass1","HitGlass2","HitGlass3","HitGlass4","HitGlass5","HitGlass6","HitLGlass","HitRGlass","HitEngine","HitFuel","HitHRotor"];
|
||||
if (_hitpoint in _BreakableParts) then {
|
||||
@@ -48,7 +49,7 @@ if (_hasToolbox) then {
|
||||
};
|
||||
|
||||
if (_isOK) then {
|
||||
_selection = getText(configFile >> "cfgVehicles" >> _type >> "HitPoints" >> _hitpoint >> "name");
|
||||
_selection = _hits select 1;
|
||||
/*if ((_hitpoint == "HitEngine") or (_hitpoint == "HitFuel")) then {
|
||||
[_vehicle, _selection, 0.89] call fnc_veh_handleDam;
|
||||
} else {*/
|
||||
|
||||
@@ -41,8 +41,8 @@ if (_is6WheelType) then {
|
||||
|
||||
{
|
||||
_hitpoint = _x;
|
||||
_damage = [_vehicle,_x] call object_getHit;
|
||||
|
||||
_hits = [_vehicle,_x] call object_getHit;
|
||||
_damage = _hits select 0;
|
||||
if !(_x in _RemovedPartsArray) then {
|
||||
//if (_x in ["HitFuel","HitEngine"] && _damage >= 0.89) then {_damage = 1;};
|
||||
_cmpt = toArray (_x);
|
||||
|
||||
@@ -154,11 +154,10 @@ if (_finished) then {
|
||||
// total damage
|
||||
_tireDmg = 0;
|
||||
|
||||
_damage = 0;
|
||||
{
|
||||
if(["Wheel",_x,false] call fnc_inString) then {
|
||||
_damage = [_obj,_x] call object_getHit;
|
||||
_tireDmg = _tireDmg + _damage;
|
||||
_tireDmg = _tireDmg + (_damage select 0);
|
||||
_tires = _tires + 1;
|
||||
};
|
||||
} count _hitpoints;
|
||||
|
||||
@@ -128,11 +128,10 @@ if (_qty >= _qty_in) then {
|
||||
// total damage
|
||||
_tireDmg = 0;
|
||||
|
||||
_damage = 0;
|
||||
{
|
||||
if(["Wheel",_x,false] call fnc_inString) then {
|
||||
_damage = [_obj,_x] call object_getHit;
|
||||
_tireDmg = _tireDmg + _damage;
|
||||
_tireDmg = _tireDmg + (_damage select 0);
|
||||
_tires = _tires + 1;
|
||||
};
|
||||
} count _hitpoints;
|
||||
|
||||
@@ -161,11 +161,10 @@ if (_finished) then {
|
||||
// total damage
|
||||
_tireDmg = 0;
|
||||
|
||||
_damage = 0;
|
||||
{
|
||||
if(["Wheel",_x,false] call fnc_inString) then {
|
||||
_damage = [_obj,_x] call object_getHit;
|
||||
_tireDmg = _tireDmg + _damage;
|
||||
_tireDmg = _tireDmg + (_damage select 0);
|
||||
_tires = _tires + 1;
|
||||
};
|
||||
} count _hitpoints;
|
||||
|
||||
@@ -156,11 +156,10 @@ if (_finished) then {
|
||||
// total damage
|
||||
_tireDmg = 0;
|
||||
|
||||
_damage = 0;
|
||||
{
|
||||
if(["Wheel",_x,false] call fnc_inString) then {
|
||||
_damage = [_obj,_x] call object_getHit;
|
||||
_tireDmg = _tireDmg + _damage;
|
||||
_tireDmg = _tireDmg + (_damage select 0);
|
||||
_tires = _tires + 1;
|
||||
};
|
||||
} count _hitpoints;
|
||||
|
||||
@@ -136,11 +136,10 @@ if (_qty >= _qty_in) then {
|
||||
// total damage
|
||||
_tireDmg = 0;
|
||||
|
||||
_damage = 0;
|
||||
{
|
||||
if(["Wheel",_x,false] call fnc_inString) then {
|
||||
_damage = [_obj,_x] call object_getHit;
|
||||
_tireDmg = _tireDmg + _damage;
|
||||
_tireDmg = _tireDmg + (_damage select 0);
|
||||
_tires = _tires + 1;
|
||||
};
|
||||
} count _hitpoints;
|
||||
|
||||
@@ -2,7 +2,6 @@ _unit = _this select 0;
|
||||
_hp = _this select 1;
|
||||
|
||||
_selection = getText (configFile >> "CfgVehicles" >> (typeOf _unit) >> "HitPoints" >> _hp >> "name");
|
||||
_strH = "hit_" + (_selection);
|
||||
_dam = _unit getVariable [_strH,0];
|
||||
_dam = _unit getHit _selection;
|
||||
|
||||
_dam
|
||||
[_dam, _selection];
|
||||
@@ -133,8 +133,7 @@ if (_isVehicle) then {
|
||||
};
|
||||
|
||||
if (_wound in [ "glass1", "glass2", "glass3", "glass4", "glass5", "glass6" ]) then {
|
||||
_strH = "hit_" + (_wound);
|
||||
_dam = _vehicle getVariable [_strH,0];
|
||||
_dam = _vehicle getHit _wound;
|
||||
_total = (_dam + _damage);
|
||||
|
||||
//handle vehicle dmg
|
||||
|
||||
@@ -40,16 +40,13 @@ if (_vehicle != player) then {
|
||||
[_unit,"hit",0,false] call dayz_zombieSpeak;
|
||||
|
||||
if (_wound IN [ "glass1", "glass2", "glass3", "glass4", "glass5", "glass6" ]) then {
|
||||
_strH = "hit_" + (_wound);
|
||||
_dam = _vehicle getVariable [_strH,0];
|
||||
_total = (_dam + _damage);
|
||||
_dam = _vehicle getHit _wound;
|
||||
|
||||
_woundDamage = _unit getVariable ["hit_"+_wound, 0];
|
||||
// we limit how vehicle could be damaged by Z. Above 0.8, the vehicle could explode, which is ridiculous.
|
||||
_damage = (if (_woundDamage < 0.8 OR {(!(_wound IN dayZ_explosiveParts))}) then {0.1} else {0.01});
|
||||
// we limit how _dam could be damaged by Z. Above 0.8, the vehicle could explode, which is ridiculous.
|
||||
_damage = (if (_dam < 0.8 OR {(!(_wound IN dayZ_explosiveParts))}) then {0.1} else {0.01});
|
||||
// Add damage to vehicle. the "sethit" command will be done by the gameengine for which vehicle is local
|
||||
//diag_log(format["%1: Part ""%2"" damaged from vehicle, damage:+%3", __FILE__, _wound, _damage]);
|
||||
_total = [_vehicle, _wound, _woundDamage + _damage, _unit, "zombie", true] call fnc_veh_handleDam;
|
||||
_total = [_vehicle, _wound, _damage, _unit, "zombie", true] call fnc_veh_handleDam;
|
||||
};
|
||||
} else {
|
||||
if ((_unit distance player) <= 3) then {
|
||||
|
||||
@@ -14,19 +14,12 @@ or by zombie_attack
|
||||
- return : updated damage for that part
|
||||
broadcast: boolean. if true, then the request will be sent to all players if the vehicle is not local.
|
||||
************************************************************/
|
||||
private["_unit","_selection","_strH","_total","_damage","_needUpdate","_totalDmg"];
|
||||
private["_unit","_selection","_total","_damage","_needUpdate","_totalDmg"];
|
||||
|
||||
_unit = _this select 0;
|
||||
_selection = _this select 1;
|
||||
_total = _this select 2;
|
||||
|
||||
if (_selection != "") then {
|
||||
_strH = "hit_" + _selection;
|
||||
_totalDmg = false;
|
||||
} else {
|
||||
_strH = "totalDmg";
|
||||
_totalDmg = true;
|
||||
};
|
||||
_totalDmg = if (_selection != "") then {false} else {true};
|
||||
|
||||
if (_total >= 0.98) then {
|
||||
_total = 1.0;
|
||||
@@ -34,9 +27,6 @@ if (_total >= 0.98) then {
|
||||
|
||||
if (local _unit) then {
|
||||
if (_total > 0) then {
|
||||
if (!_totalDmg) then {
|
||||
_unit setVariable [_strH, _total, true];
|
||||
};
|
||||
_unit setHit [_selection, _total];
|
||||
|
||||
PVDZ_veh_Save = [_unit,"damage",false,_totalDmg];
|
||||
|
||||
@@ -25,15 +25,12 @@ _hitpointnames = [];
|
||||
|
||||
if ((isNil "_selection") OR {(!(_selection in _hitpointnames))}) exitWith {_this select 2};
|
||||
|
||||
_SVname = "hit_" + _selection;
|
||||
|
||||
_log = format["%1 vehicle:%2#%3 part:""%4"" current_part_damage:%5", __FILE__,
|
||||
typeOf _unit, _unit getVariable ["ObjectID",""],
|
||||
_selection, _unit getVariable [_SVname, 0] ];
|
||||
_selection, _unit getHit _selection ];
|
||||
|
||||
if (local _unit) then {
|
||||
// only local unit can set the damage of a vehicle part
|
||||
_unit setVariable [_SVname, 0, true];
|
||||
_unit setHit [_selection, 0];
|
||||
_log = format["%1. setH!t[%2,0]", _log, _selection];
|
||||
if (!isServer) then {
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
private["_unit","_selection","_strH","_damage","_total"];
|
||||
private["_unit","_selection","_damage","_total"];
|
||||
_unit = _this select 0;
|
||||
_selection = _this select 1;
|
||||
_damage = _this select 2;
|
||||
|
||||
if (_selection != "" and local _unit) then {
|
||||
_strH = "hit_" + (_selection);
|
||||
_unit setHit[_selection,_damage];
|
||||
//player sidechat str _damage;
|
||||
_unit setVariable [_strH,_damage,true];
|
||||
if (_damage == 0) then {
|
||||
[_unit,"repair"] call server_updateObject;
|
||||
} else {
|
||||
|
||||
@@ -1,25 +1,27 @@
|
||||
private ["_cfgHitPoints", "_hps", "_funcGetHitPoints"];
|
||||
private ["_cfgHitPoints", "_hps"];
|
||||
_cfgHitPoints = configFile >> "CfgVehicles" >> (typeOf _this) >> "HitPoints";
|
||||
_hps = [];
|
||||
|
||||
_funcGetHitPoints =
|
||||
{
|
||||
for "_i" from 0 to ((count _this) - 1) do
|
||||
for "_i" from 0 to ((count (_this select 1)) - 1) do
|
||||
{
|
||||
private ["_hp"];
|
||||
_hp = configName (_this select _i);
|
||||
_hp = configName ((_this select 1) select _i);
|
||||
|
||||
if (!(_hp in _hps)) then
|
||||
{
|
||||
_hps set [count _hps, _hp];
|
||||
_HPCheck = (_this select 0) getHit (getText((_this select 1) >> _hp >> "name"));
|
||||
if (!isNil "_HPCheck") then {
|
||||
_hps set [count _hps, _hp];
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
//Explore inheritance structure fully
|
||||
while {(configName _cfgHitPoints) != ""} do
|
||||
{
|
||||
_cfgHitPoints call _funcGetHitPoints;
|
||||
[_this, _cfgHitPoints] call _funcGetHitPoints;
|
||||
_cfgHitPoints = inheritsFrom _cfgHitPoints;
|
||||
};
|
||||
|
||||
|
||||
@@ -115,24 +115,24 @@ _object_damage = {
|
||||
_damage = damage _object;
|
||||
_array = [];
|
||||
_allFixed = true;
|
||||
|
||||
|
||||
{
|
||||
_hit = [_object,_x] call object_getHit;
|
||||
_selection = getText (configFile >> "CfgVehicles" >> _class >> "HitPoints" >> _x >> "name");
|
||||
if (_hit > 0) then {
|
||||
if ((_hit select 0) > 0) then {
|
||||
|
||||
_allFixed = false;
|
||||
_array set [count _array,[_selection,_hit]];
|
||||
//diag_log format ["Section Part: %1, Dmg: %2",_selection,_hit];
|
||||
_array set [count _array,[(_hit select 1),(_hit select 0)]];
|
||||
//diag_log format ["Section Part: %1, Dmg: %2",(_hit select 1),(_hit select 0)];
|
||||
} else {
|
||||
_array set [count _array,[_selection,0]];
|
||||
_array set [count _array,[(_hit select 1),0]];
|
||||
};
|
||||
} forEach _hitpoints;
|
||||
|
||||
|
||||
if (_allFixed && !_totalDmg) then {_object setDamage 0;};
|
||||
|
||||
if (_forced) then {
|
||||
|
||||
if (_forced) then {
|
||||
if (_object in needUpdate_objects) then {needUpdate_objects = needUpdate_objects - [_object];};
|
||||
_recorddmg = true;
|
||||
_recorddmg = true;
|
||||
} else {
|
||||
//Prevent damage events for the first 10 seconds of the servers live.
|
||||
if (diag_ticktime - _lastUpdate > 10) then {
|
||||
@@ -143,7 +143,7 @@ _object_damage = {
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
if (_recorddmg) then {
|
||||
if (_objectID == "0") then {
|
||||
_key = format["CHILD:306:%1:",_objectUID] + str _array + ":" + str _damage + ":";
|
||||
@@ -153,8 +153,8 @@ _object_damage = {
|
||||
#ifdef OBJECT_DEBUG
|
||||
diag_log ("HIVE: WRITE: "+ str(_key));
|
||||
#endif
|
||||
|
||||
_key call server_hiveWrite;
|
||||
|
||||
_key call server_hiveWrite;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@@ -273,9 +273,7 @@ if ((playersNumber west + playersNumber civilian) == 0) exitWith {
|
||||
{
|
||||
_selection = _x select 0;
|
||||
_dam = if (!_isAir && {_selection in dayZ_explosiveParts}) then {(_x select 1) min 0.8;} else {_x select 1;};
|
||||
_strH = "hit_" + (_selection);
|
||||
_object setHit[_selection,_dam];
|
||||
_object setVariable [_strH,_dam,true];
|
||||
_object setHit [_selection,_dam];
|
||||
} foreach _hitpoints;
|
||||
[_object,"damage"] call server_updateObject;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user