object_setFixServer -> fnc_veh_setFixServer

Fnc_veh_handleRepair is a new version of fnc_veh_setFixServer with extra
handling. It is used in salvage and some other scripts, but not
server_monitor.
This commit is contained in:
ebaydayz
2016-03-22 16:34:08 -04:00
parent cc64d2e7fb
commit debb714277
10 changed files with 227 additions and 259 deletions

View File

@@ -1,37 +1,29 @@
private ["_attacked","_chance","_near","_targeted","_localtargets","_remotetargets","_forcedSpeed"];
private ["_attacked","_chance","_near","_targeted","_localtargets","_remotetargets","_forcedSpeed","_vehicle","_refObj",
"_multiplier","_isAir","_hearingThreshold","_sightThreshold","_type","_dist","_attackDist",
"_targetedBySight","_targetedBySound","_targets","_last","_entHeight","_pHeight","_delta","_attackResult","_cantSee","_tPos","_zPos",
"_targetAngle","_inAngle","_lowBlood"];
_vehicle = vehicle player;
_isVehicle = (_vehicle != player);
_speed = speed (vehicle player);
_refObj = (driver _vehicle);
_listTalk = (getPosATL _refObj) nearEntities ["Zed_Base", 100];
_attacked = false; // at least 1 Z attacked the player
_refObj = driver _vehicle;
_attacked = false; // at least one Z attacked the player
_near = false;
//_multiplier = 1;
_inVehicle = (vehicle player != player);
_isAir = vehicle player iskindof "Air";
_isLand = vehicle player iskindof "Land";
_isSea = vehicle player iskindof "Sea";
if (_isLand) then { } else { };
if (_isAir) then { } else { };
if (_isSea) then { } else { };
_isAir = _vehicle isKindOf "Air";
{
_forcedSpeed = getNumber (configFile >> "CfgVehicles" >> (typeOf _x) >> "forcedSpeed");
//_hearingThreshold = getNumber (configFile >> "CfgVehicles" >> (typeOf _x) >> "hearingThreshold");
//_sightThreshold = getNumber (configFile >> "CfgVehicles" >> (typeOf _x) >> "sightThreshold");
if (!(typeof _x == "swarm_newBase")) then {
if !(typeOf _x == "swarm_newBase") then {
_type = "zombie";
if (alive _x) then {
private["_dist","_attackDist"];
_dist = (_x distance _refObj);
private ["_dist","_attackDist"];
_dist = _x distance _refObj;
_group = _x;
_chance = 1; //0 / dayz_monitorPeriod; // Z verbosity
_targetedBySight = false;
_targetedBySound = false;
_localtargets = _group getVariable ["localtargets",[]];
_remotetargets = _group getVariable ["remotetargets",[]];
_targets = _localtargets + _remotetargets;
@@ -44,24 +36,25 @@ if (_isSea) then { } else { };
};
};
if (_x distance _refObj >= 3.3) then {
_x setVariable ["speedLimit", _forcedSpeed, false];
};
if (_x distance _refObj >= 3.3) then {_x setVariable ["speedLimit",_forcedSpeed,false];};
//if (!local _x) then {
if (_refObj in _targets) then {
_last = _x getVariable["lastAttack", 0];
_last = _x getVariable ["lastAttack", 0];
_entHeight = (getPosATL _x) select 2;
_pHeight = (getPosATL _refObj) select 2;
_delta = _pHeight - _entHeight;
_x setVariable ["speedLimit", 0, false];
if (_x distance _refObj <= 3.3) then {
//Force Ai to Stand
if (_x distance _refObj <= 3) then {
//Force AI to Stand
_x setUnitPos "UP";
if (!(animationState _x == "ZombieFeed")) then {
if (((diag_tickTime - _last) > 1.5) and ((_delta < 1.5) and (_delta > -1.5))) then {
_attackResult = [_x, _type] call player_zombieAttack;
_x setVariable["lastAttack", diag_tickTime];
if !(animationState _x == "ZombieFeed") then {
if (((diag_tickTime - _last) > 1.5) && ((_delta < 1.5) && (_delta > -1.5))) then {
_cantSee = [_x,_refObj] call dayz_losCheck;
if (!_cantSee) then {
_attackResult = [_x, _type] spawn player_zombieAttack;
_x setVariable ["lastAttack", diag_tickTime];
};
};
};
} else {
@@ -75,9 +68,8 @@ if (_isSea) then { } else { };
//Block all target atteps while in a vehicle
if (!_isAir) then {
if (!(_refObj in _targets)) then {
//Noise Activation
//zed is within players audial projection
if !(_refObj in _targets) then {
//Noise Activation (zed is within players audial projection)
if (_dist < DAYZ_disAudial) then {
if (DAYZ_disAudial > 80) then {
_targetedBySound = true;
@@ -91,9 +83,7 @@ if (_isSea) then { } else { };
if (!_cantSee) then {
_targetedBySound = true;
} else {
if (_dist < (DAYZ_disAudial / 2)) then {
_targetedBySound = true;
};
if (_dist < (DAYZ_disAudial / 2)) then {_targetedBySound = true;};
};
};
//};
@@ -104,15 +94,13 @@ if (_isSea) then { } else { };
if (_dist < DAYZ_disVisual ) then {
_chance = [_x,_dist,DAYZ_disVisual] call dayz_losChance;
if ((random 1) < _chance) then {
_tPos = (getPosASL (vehicle player));
_zPos = (getPosASL _x);
_tPos = getPosASL _vehicle;
_zPos = getPosASL _x;
_targetAngle = 30;
_inAngle = [_zPos,(direction _x),_targetAngle,_tPos] call fnc_inAngleSector;
if (_inAngle) then {
_cantSee = [_refObj,_x] call dayz_losCheck;
if (!_cantSee) then {
_targetedBySight = true;
};
if (!_cantSee) then {_targetedBySight = true;};
};
};
};
@@ -121,7 +109,6 @@ if (_isSea) then { } else { };
if (_targetedBySight or _targetedBySound) then {
[_x, "spotted", 0, false] call dayz_zombieSpeak;
diag_log format["Zombie: %1, Distance: %2, Target Reason: Sight-%3,%5/Sound-%4,%6",(typeof _x),_dist,_targetedBySight,_targetedBySound,DAYZ_disVisual,DAYZ_disAudial];
switch (local _x) do {
@@ -137,7 +124,7 @@ if (_isSea) then { } else { };
};
};
};
} forEach _listTalk;
} forEach ((getPosATL _refObj) nearEntities ["Zed_Base",100]);
if (_attacked) then {
if (r_player_unconscious) then {
@@ -152,4 +139,4 @@ if (_attacked) then {
};
// return true if attacked or near. if so, player_monitor will perform its ridiculous 'while true' loop faster.
(_attacked OR _near)
(_attacked OR _near)