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

@@ -8,7 +8,7 @@
- Journal is now functional for displaying stats - Journal is now functional for displaying stats
- ItemFish, Shotgun ammo and several other item classnames changed. See SQL\1.0.6_Updates - ItemFish, Shotgun ammo and several other item classnames changed. See SQL\1.0.6_Updates
- Dupicate functions have been renamed: - Dupicate functions have been renamed:
- object_setFixServer --> fnc_veh_handleRepair - object_setFixServer --> fnc_veh_setFixServer
- vehicle_handleDamage --> fnc_veh_handleDam - vehicle_handleDamage --> fnc_veh_handleDam
- vehicle_handleKilled --> fnc_veh_handleKilled - vehicle_handleKilled --> fnc_veh_handleKilled
- Duplicate global variables have been renamed: - Duplicate global variables have been renamed:

View File

@@ -5,7 +5,7 @@ _unit = _obj select 0;
_ammo = _obj select 4; _ammo = _obj select 4;
_projectile = _obj select 6; _projectile = _obj select 6;
waituntil {!isnil "dayz_sunRise"}; waituntil {!isNil "dayz_sunRise"};
_projectile = nearestObject [_unit,_ammo]; _projectile = nearestObject [_unit,_ammo];
_endPos = getPosATL _projectile; _endPos = getPosATL _projectile;
@@ -13,7 +13,7 @@ _endPos = getPosATL _projectile;
_doWait = true; _doWait = true;
while {_doWait} do { while {_doWait} do {
_vel = (velocity _projectile) distance [0,0,0]; _vel = (velocity _projectile) distance [0,0,0];
if (!(alive _projectile)) then {_doWait = false}; if !(alive _projectile) then {_doWait = false};
if (_vel < 0.1) then {_doWait = false}; if (_vel < 0.1) then {_doWait = false};
_endPos = getPosATL _projectile; _endPos = getPosATL _projectile;
uiSleep 0.01; uiSleep 0.01;
@@ -25,11 +25,7 @@ if (_ammo isKindOf "ChemLight") then {
_distance = 10; _distance = 10;
}; };
if (_ammo isKindOf "RoadFlare") then { if (_ammo isKindOf "RoadFlare") then {
if ((daytime < (24 - dayz_sunRise)) and (daytime > dayz_sunRise)) then { _distance = if ((daytime < (24 - dayz_sunRise)) && (daytime > dayz_sunRise)) then {30} else {60};
_distance = 30;
} else {
_distance = 60;
};
}; };
[_unit,_distance,false,_endPos] call player_alertZombies; [_unit,_distance,false,_endPos] call player_alertZombies;

View File

@@ -1,41 +1,40 @@
//[unit, weapon, muzzle, mode, ammo, magazine, projectile] //[unit, weapon, muzzle, mode, ammo, magazine, projectile]
private ["_unit","_evType","_recordable","_inVehicle","_isPlayer","_isRocket","_dmgDistance","_isBallistic","_handled","_id","_firer","_distance","_weapon","_ammo","_killerID","_arc","_turretDir","_weaponDir","_pos1","_pos2","_facing","_firingArc","_isInFront","_isInRear"]; private ["_handled"];
//Init //Init
//[unit, firer, distance, weapon, muzzle, mode, ammo] //[unit, firer, distance, weapon, muzzle, mode, ammo]
_unit = _this select 0; _unit = _this select 0;
_firer = _this select 1; _firer = _this select 1;
_distance = _this select 2; _distance = _this select 2;
_weapon = _this select 3; _weapon = _this select 3;
_ammo = _this select 6; _ammo = _this select 6;
_killerID = _firer getVariable["MemberID",0]; //_killerID = _firer getVariable["MemberID",0];
_handled = false; _handled = false;
_arc = 60; _arc = 60;
_isBallistic = (getNumber (configfile >> "CfgAmmo" >> _ammo >> "whistleOnFire") > 0); _isBallistic = (getNumber (configfile >> "CfgAmmo" >> _ammo >> "whistleOnFire") > 0);
_dmgDistance = getNumber (configfile >> "CfgAmmo" >> _ammo >> "whistleDist"); _dmgDistance = getNumber (configfile >> "CfgAmmo" >> _ammo >> "whistleDist");
_isRocket = ((_ammo isKindOf "RocketBase") && (_firer isKindOf "Man")); _isRocket = ((_ammo isKindOf "RocketBase") && (_firer isKindOf "Man"));
_isPlayer = (_unit == player); _isPlayer = (_unit == player);
_inVehicle = (vehicle _unit != _unit); _inVehicle = (vehicle _unit != _unit);
_evType = ""; //_evType = "";
_recordable = false; //_recordable = false;
// Both the firer && those nearby (<=8m) go into "combat" to prevent ALT-F4 // Both the firer and those nearby (<=8m) go into "combat" to prevent ALT-F4
//diag_log ("DEBUG: AMMO TYPE: " +str(_ammo)); //diag_log ("DEBUG: AMMO TYPE: " +str(_ammo));
_firer setVariable["startcombattimer", 1]; _firer setVariable["startcombattimer", 1];
if (_distance <= 8) then { if (_distance <= 8) then {
_unit setVariable["startcombattimer", 1]; _unit setVariable["startcombattimer", 1];
}; };
if (_inVehicle) exitWith {};
if (_inVehicle) exitWith{}; if (_firer == player) exitWith {};
if (_firer == player) exitWith{};
//Is in danger angle? //Is in danger angle?
_turretDir = _firer weaponDirection _weapon; _turretDir = _firer weaponDirection _weapon;
_weaponDir = ((_turretDir select 0) atan2 (_turretDir select 1)); _weaponDir = ((_turretDir select 0) atan2 (_turretDir select 1));
_pos1 = getposATL _unit; _pos1 = getPosATL _unit;
_pos2 = getposATL _firer; _pos2 = getPosATL _firer;
_facing = ((_pos1 Select 0) - (_pos2 Select 0)) ATan2 ((_pos1 Select 1) - (_pos2 Select 1)); _facing = ((_pos1 select 0) - (_pos2 select 0)) atan2 ((_pos1 select 1) - (_pos2 select 1));
_firingArc = (_weaponDir - _facing); _firingArc = (_weaponDir - _facing);
_firingArc = (-_firingArc) max (_firingArc); _firingArc = (-_firingArc) max (_firingArc);
@@ -53,10 +52,11 @@ private ["_unit","_evType","_recordable","_inVehicle","_isPlayer","_isRocket","_
//serious ballistic damage //serious ballistic damage
if (_isPlayer) then { if (_isPlayer) then {
[_unit, "head_hit", 1.51, _firer, _ammo] call fnc_usec_damageHandler; [_unit, "head_hit", 1.51, _firer, _ammo] call fnc_usec_damageHandler;
// head damage > 1.5 ---> log + death
}; };
[_unit,4] call fnc_usec_damageUnconscious; [_unit,4] call fnc_usec_damageUnconscious;
} else {; } else {
//Just Knocked out //Just Knocked out
[_unit,0.5] call fnc_usec_damageUnconscious; [_unit,0.5] call fnc_usec_damageUnconscious;
}; };
@@ -68,13 +68,14 @@ private ["_unit","_evType","_recordable","_inVehicle","_isPlayer","_isRocket","_
}; };
}; };
} else { } else {
if (_isRocket && (_isInFront || _isInRear)) then { if (_isRocket && (_isInFront or _isInRear)) then {
if ((_distance < 5) && !_handled) then { if ((_distance < 5) && !_handled) then {
1 call fnc_usec_bulletHit; 1 call fnc_usec_bulletHit;
[20,45] call fnc_usec_pitchWhine; //Visual , Sound [20,45] call fnc_usec_pitchWhine; //Visual , Sound
// Dead // Dead
if (_isPlayer) then { if (_isPlayer) then {
[_unit, "head_hit", 1.51, _firer, _ammo] call fnc_usec_damageHandler; [_unit, "head_hit", 1.51, _firer, _ammo] call fnc_usec_damageHandler;
// head damage > 1.5 ---> log + death
}; };
[_unit,2] call fnc_usec_damageUnconscious; [_unit,2] call fnc_usec_damageUnconscious;
}; };

View File

@@ -2,24 +2,24 @@
Created exclusively for ArmA2:OA - DayZMod. Created exclusively for ArmA2:OA - DayZMod.
Please request permission to use/alter/distribute from project leader (R4Z0R49) AND the author (facoptere@gmail.com) Please request permission to use/alter/distribute from project leader (R4Z0R49) AND the author (facoptere@gmail.com)
*/ */
private ["_rnd","_move","_wound","_cnt","_index","_damage","_total","_movePlayer"]; private ["_rnd","_move","_wound","_cnt","_index","_damage","_total","_movePlayer","_start","_unit","_type","_vehicle","_speed",
//_start = diag_tickTime; "_nextPlayerPos","_distance","_viralZeds","_isVehicle","_agentPos","_playerDodged","_areaAffect","_dist","_dir","_timeout","_deg",
"_lastDodge","_dodgeAnimations","_tPos","_zPos","_hpList","_hp","_chance","_openVehicles","_strH","_dam","_cantSee","_attackanimations",
"_lastTackle","_knockdown","_vel","_t","_step","_i","_doRE","_stop"];
_unit = _this select 0; _unit = _this select 0;
_type = _this select 1; _type = _this select 1;
_vehicle = vehicle player;
_vehicle = (vehicle player);
_speed = speed player; _speed = speed player;
//_nextPlayerPos = player call dayz_futurePos; //_nextPlayerPos = player call dayz_futurePos;
_distance = [_unit, player] call BIS_fnc_distance2D; _distance = [_unit, player] call BIS_fnc_distance2D;
//_viralZeds = typeOf _unit in DayZ_ViralZeds; //_viralZeds = typeOf _unit in DayZ_ViralZeds;
_isVehicle = (_vehicle != player); _isVehicle = (_vehicle != player);
//_agentPos = getPosATL _unit; //_agentPos = getPosATL _unit;
_playerDodged = false; _playerDodged = false;
if (_type != "zombie") exitWith { diag_log ("not a zombie"); }; // we deal only with zombies in this function if (_type != "zombie") exitWith { diag_log ("not a zombie"); }; // we deal only with zombies in this function
if (_unit distance _vehicle > 3.6) exitWith { }; // distance too far according to any logic dealt here //+str(_unit distance _nextPlayerPos)+"/"+str(_areaAffect) if (_unit distance _vehicle > 3) exitWith {}; // distance too far according to any logic dealt here //+str(_unit distance _nextPlayerPos)+"/"+str(_areaAffect)
// compute the animation move // compute the animation move
_rnd = 0; _rnd = 0;
@@ -33,11 +33,11 @@ switch true do {
_rnd = ceil(random 4); //9 _rnd = ceil(random 4); //9
_move = "ZombieFeed" + str(_rnd); _move = "ZombieFeed" + str(_rnd);
}; };
case ((_isVehicle) AND (_distance < 3.6)) : { // enable attack if Z is between 2.2 and 3.5. Other cases are handled in "default" case ((_isVehicle) && (_distance < 3.6)) : { // enable attack if Z is between 2.2 and 3.5. Other cases are handled in "default"
_rnd = 8; _rnd = 8;
_move = "ZombieStandingAttack" + str(_rnd); _move = "ZombieStandingAttack" + str(_rnd);
}; };
case (((_speed >= 5) or (_speed <= -5)) and (_distance < 2.3)) : { case (((_speed >= 5) or (_speed <= -5)) && (_distance < 2.3)) : {
_rnd = 8; _rnd = 8;
_move = "ZombieStandingAttack" + str(_rnd); _move = "ZombieStandingAttack" + str(_rnd);
}; };
@@ -76,21 +76,25 @@ _dir = [_unit,player] call BIS_Fnc_dirTo;
_unit setDir _dir; _unit setDir _dir;
// let's animate the Z // let's animate the Z
/*
if (local _unit) then { if (local _unit) then {
_unit PlayMove _move; _unit switchMove _move;
} else { } else {
[objNull, _unit, rPlayMove, _move] call RE; [objNull, _unit, rswitchMove, _move] call RE;
}; };
*/
[objNull, _unit, rplaymove, _move] call RE;
uiSleep 0.5;
//slow it down make sure the animation isnt running after the damage //slow it down make sure the animation isnt running after the damage
_timeout = diag_tickTime + 0.3; //_timeout = diag_tickTime + 0.3;
waitUntil { diag_tickTime >= _timeout; }; //waitUntil { diag_tickTime >= _timeout; };
_deg = [player, _unit] call BIS_fnc_relativeDirTo; _deg = [player, _unit] call BIS_fnc_relativeDirTo;
_lastDodge = _unit getVariable ["lastDodge", 0]; _lastDodge = _unit getVariable ["lastDodge", 0];
//1 in 5 shots //1 in 5 shots
if (((diag_tickTime - _lastDodge) == 0) or ((diag_tickTime - _lastDodge) > 10)) then { if (((diag_tickTime - _lastDodge) == 0) or ((diag_tickTime - _lastDodge) > 10)) then {
if (((_deg > 295) and (_deg < 360)) or ((_deg > 0) and (_deg < 65))) then { if (((_deg > 295) && (_deg < 360)) or ((_deg > 0) && (_deg < 65))) then {
_dodgeAnimations = ["amovpknlmstpsraswrfldnon"]; _dodgeAnimations = ["amovpknlmstpsraswrfldnon"];
if ((animationState _vehicle) in _dodgeAnimations) then { if ((animationState _vehicle) in _dodgeAnimations) then {
if (dayz_dodge) exitwith { if (dayz_dodge) exitwith {
@@ -107,8 +111,8 @@ if (_playerDodged) exitwith {
_lastDodge = _unit setVariable ["lastDodge", diag_tickTime]; _lastDodge = _unit setVariable ["lastDodge", diag_tickTime];
}; };
_tPos = (getPosASL _vehicle); _tPos = getPosASL _vehicle;
_zPos = (getPosASL _unit); _zPos = getPosASL _unit;
// compute damage for vehicle and/or the player // compute damage for vehicle and/or the player
if (_isVehicle) then { if (_isVehicle) then {
if ((_unit distance player) < (3.3 * 2)) then { if ((_unit distance player) < (3.3 * 2)) then {
@@ -127,14 +131,13 @@ if (_isVehicle) then {
} count _openVehicles; } count _openVehicles;
}; };
if (_wound IN [ "glass1", "glass2", "glass3", "glass4", "glass5", "glass6" ]) then { if (_wound in [ "glass1", "glass2", "glass3", "glass4", "glass5", "glass6" ]) then {
_strH = "hit_" + (_wound); _strH = "hit_" + (_wound);
_dam = _vehicle getVariable [_strH,0]; _dam = _vehicle getVariable [_strH,0];
_total = (_dam + _damage); _total = (_dam + _damage);
//handle vehicle dmg //handle vehicle dmg
[_vehicle, _wound, _total, _unit, "zombie", true] call fnc_veh_handleDam; [_vehicle, _wound, _total, _unit, "zombie", true] call fnc_veh_handleDam;
//diag_log ("Hitpoints " +str(_wound) +str(_total)); //diag_log ("Hitpoints " +str(_wound) +str(_total));
//handle player dmg //handle player dmg
@@ -166,13 +169,14 @@ if (_isVehicle) then {
}; };
} else { } else {
// player by foot // player by foot
if ((_unit distance player) <= 3.3) then { if ((_unit distance player) <= 3) then {
//Make sure sure evrything is processed as we attack. //Make sure sure evrything is processed as we attack.
_damage = 0.2 + random (1.2); _damage = 0.2 + random (1.2);
//LOS check //LOS check
_cantSee = [_vehicle,_unit] call dayz_losCheck; //Zed eye to player (opersite way around).
_cantSee = [_unit,_vehicle] call dayz_losCheck;
if (!_cantSee) then { if (!_cantSee) then {
if (r_player_blood < (r_player_bloodTotal * 0.8)) then { if (r_player_blood < (r_player_bloodTotal * 0.8)) then {
_cnt = count (DAYZ_woundHit select 1); _cnt = count (DAYZ_woundHit select 1);
@@ -186,146 +190,138 @@ if (_isVehicle) then {
_wound = (DAYZ_woundHit_ok select 0) select _index; _wound = (DAYZ_woundHit_ok select 0) select _index;
}; };
//Stop the Zed _unit setVariable ["speedLimit", 0, false]; //Stop the Zed
_unit setVariable ["speedLimit", 0, false]; //systemChat format["ZA Start Damage Check - %1",(_unit distance player)];
_attackanimations = ["zombiestandingattack1","zombiestandingattack2","zombiestandingattack3","zombiestandingattack4","zombiestandingattack5","zombiestandingattack6","zombiestandingattack7","zombiestandingattack8","zombiestandingattack9","zombiestandingattack10","zombiefeed1","zombiefeed2","zombiefeed3","zombiefeed4","zombiefeed5"];
//_attackanimations = ["zombiestandingattack1","zombiestandingattack2","zombiestandingattack3","zombiestandingattack4","zombiestandingattack5","zombiestandingattack6","zombiestandingattack7","zombiestandingattack8","zombiestandingattack9","zombiestandingattack10","zombiefeed1","zombiefeed2","zombiefeed3","zombiefeed4","zombiefeed5"];
//diag_log ((animationState _unit)); if ((animationState _unit) in _attackanimations) then {
//if ((animationState _unit) in _attackanimations) then {
if (alive _unit) then { if (alive _unit) then {
//Damage the player //Damage the player
[player, _wound, _damage, _unit, "zombie"] call fnc_usec_damageHandler; [player, _wound, _damage, _unit, "zombie"] call fnc_usec_damageHandler;
// check Z stance. Stand up Z if it prones/kneels. make sure zed stays standing after its frist attak // check Z stance. Stand up Z if it prones/kneels. make sure zed stays standing after its frist attak
if (unitPos _unit != "UP") then { if (unitPos _unit != "UP") then {_unit setUnitPos "UP";};
_unit setUnitPos "UP";
// broadcast hit noise
_pos = getPosATL player;
if ({isPlayer _x} count (_pos nearEntities ["CAManBase",40]) > 1) then {
[_unit,"hit",0,false] call dayz_zombieSpeak;
} else {
[_unit,"hit",0,true] call dayz_zombieSpeak;
}; };
//};
// broadcast hit noise // player may fall if hit
_pos = getPosATL player; _deg = [player, _unit] call BIS_fnc_relativeDirTo;
if ({isPlayer _x} count (_pos nearEntities ["CAManBase",40]) > 1) then { _lastTackle = player getVariable ["lastTackle", 0];
[_unit,"hit",0,false] call dayz_zombieSpeak; _movePlayer = "";
} else {
[_unit,"hit",0,true] call dayz_zombieSpeak; //head hit, legs, pushed from back
}; _knockdown = ["head_hit","legs"];
if (_wound in _knockdown) then {
// player may fall if hit... if (((diag_tickTime - _lastTackle) > 7) && (_speed >= 5.62)) then {
_deg = [player, _unit] call BIS_fnc_relativeDirTo; switch true do {
_lastTackle = player getVariable ["lastTackle", 0]; /*
_movePlayer = ""; //Removed for now
// front
//head hit, Legs, pushed from back case (((_deg > 315) && (_deg <= 360)) or ((_deg > 0) && (_deg < 45))) : {
_knockdown = ["head_hit","legs"]; //player setVelocity [(velocity player select 0) + 5 * sin direction _unit, (velocity player select 1) + 5 * cos direction _unit, (velocity player select 2) + 1];
//diag_log ("ZombieAttack: "+str(_wound)); // stop player
//_isHeadHit = (_wound == "head_hit"); _vel = velocity player;
if (_wound in _knockdown) then { player setVelocity [-(_vel select 0), -(_vel select 1), 0];
if (((diag_tickTime - _lastTackle) > 7) and (_speed >= 5.62)) then { disableUserInput true;
switch true do {
/* [diag_tickTime] call {
//Removed for now _t = _this select 0;
// front while {true} do {
case (((_deg > 315) and (_deg <= 360)) or ((_deg > 0) and (_deg < 45))) : { if (diag_tickTime - _t > 1) exitWith {disableUserInput false;};
//player setVelocity [(velocity player select 0) + 5 * sin direction _unit, (velocity player select 1) + 5 * cos direction _unit, (velocity player select 2) + 1]; };
// stop player };
_vel = velocity player;
player setVelocity [-(_vel select 0), -(_vel select 1), 0];
disableUserInput true;
[diag_tickTime] call {
_t = _this select 0;
while { true } do {
if (diag_tickTime - _t > 1) exitWith {disableUserInput false;};
};
};
};
*/
// left
case (((_deg > 225) and (_deg < 315))) : {
// rotate player 'smoothly'
[_deg] spawn {
private["_step","_i"];
_step = 90 / 5;
_i = 0;
while { _i < 5 } do {
player setDir ((getDir player) + _step);
_i = _i + 1;
uiSleep 0.01;
};
}; };
*/
// make player dive // left
_movePlayer = switch (toArray(animationState player) select 17) do { case (((_deg > 225) && (_deg < 315))) : {
case 114 : {"ActsPercMrunSlowWrflDf_TumbleOver"}; // rifle // rotate player 'smoothly'
case 112 : {"AmovPercMsprSlowWpstDf_AmovPpneMstpSrasWpstDnon"}; // pistol [_deg] spawn {
default {"ActsPercMrunSlowWrflDf_TumbleOver"}; private["_step","_i"];
}; _step = 90 / 5;
}; _i = 0;
// right while {_i < 5} do {
case (((_deg > 45) and (_deg < 135))) : { player setDir ((getDir player) + _step);
[_deg] spawn { _i = _i + 1;
private["_step","_i"]; uiSleep 0.01;
_step = 90 / 5; };
_i = 0;
while { _i < 5 } do {
player setDir ((getDir player) - _step);
_i = _i + 1;
uiSleep 0.01;
};
};
// make player dive
_movePlayer = switch (toArray(animationState player) select 17) do {
case 114 : {"ActsPercMrunSlowWrflDf_TumbleOver"}; // rifle
case 112 : {"AmovPercMsprSlowWpstDf_AmovPpneMstpSrasWpstDnon"}; // pistol
default {"ActsPercMrunSlowWrflDf_TumbleOver"};
};
};
// rear
case (((_deg > 135) and (_deg < 225))) : {
_movePlayer = switch (toArray(animationState player) select 17) do {
case 114 : {"ActsPercMrunSlowWrflDf_TumbleOver"}; // rifle
case 112 : {"AmovPercMsprSlowWpstDf_AmovPpneMstpSrasWpstDnon"}; // pistol
default {"ActsPercMrunSlowWrflDf_TumbleOver"};
};
};
};
// make player dive After making sure the zed can see you.
if (_movePlayer != "") then {
player setVariable ["lastTackle", diag_tickTime];
_doRE = ({isPlayer _x} count (player nearEntities ["AllVehicles",100]) > 1);
if (_doRE) then {
[nil, player, rSWITCHMOVE, _movePlayer] call RE;
} else {
player switchMove _movePlayer;
};
if (_movePlayer == "ActsPercMrunSlowWrflDf_TumbleOver") then {
[_movePlayer, _doRE] spawn {
private ["_movePlayer","_doRE"];
_movePlayer = _this select 0;
_doRE = _this select 1;
waitUntil { animationState player == _movePlayer }; // just in case
while { animationState player == _movePlayer } do {
if (speed player < 4) exitWith { /* break from loop to fix animation lockup */ };
uiSleep 0.1;
}; };
if (_doRE) then { // make player dive
[nil, player, rSWITCHMOVE, ""] call RE; _movePlayer = switch (toArray(animationState player) select 17) do {
} else { case 114 : {"ActsPercMrunSlowWrflDf_TumbleOver"}; // rifle
player switchMove ""; case 112 : {"AmovPercMsprSlowWpstDf_AmovPpneMstpSrasWpstDnon"}; // pistol
default {"ActsPercMrunSlowWrflDf_TumbleOver"};
};
};
// right
case (((_deg > 45) && (_deg < 135))) : {
[_deg] spawn {
private["_step","_i"];
_step = 90 / 5;
_i = 0;
while {_i < 5} do {
player setDir ((getDir player) - _step);
_i = _i + 1;
uiSleep 0.01;
};
};
// make player dive
_movePlayer = switch (toArray(animationState player) select 17) do {
case 114 : {"ActsPercMrunSlowWrflDf_TumbleOver"}; // rifle
case 112 : {"AmovPercMsprSlowWpstDf_AmovPpneMstpSrasWpstDnon"}; // pistol
default {"ActsPercMrunSlowWrflDf_TumbleOver"};
};
};
// rear
case (((_deg > 135) && (_deg < 225))) : {
_movePlayer = switch (toArray(animationState player) select 17) do {
case 114 : {"ActsPercMrunSlowWrflDf_TumbleOver"}; // rifle
case 112 : {"AmovPercMsprSlowWpstDf_AmovPpneMstpSrasWpstDnon"}; // pistol
default {"ActsPercMrunSlowWrflDf_TumbleOver"};
}; };
}; };
}; };
//diag_log(format["%1 player tackled. Weapons: cur:""%2"" anim.state:%6 (%7)--> move: %3. Angle:%4 Delta-time:%5", __FILE__, currentWeapon player, _move, _deg, time - _lastTackle, animationState player, toArray(animationState player) select 17 ]);
// Make player dive after making sure the zed can see you.
if (_movePlayer != "") then {
player setVariable ["lastTackle", diag_tickTime];
_doRE = ({isPlayer _x} count (player nearEntities ["AllVehicles",100]) > 1);
if (_doRE) then {
[nil, player, rSWITCHMOVE, _movePlayer] call RE;
} else {
player switchMove _movePlayer;
};
if (_movePlayer == "ActsPercMrunSlowWrflDf_TumbleOver") then {
[_movePlayer, _doRE] spawn {
private ["_movePlayer","_doRE"];
_movePlayer = _this select 0;
_doRE = _this select 1;
waitUntil {animationState player == _movePlayer}; // just in case
while {animationState player == _movePlayer} do {
if (speed player < 4) exitWith { /* break from loop to fix animation lockup */ };
uiSleep 0.1;
};
if (_doRE) then {
[nil, player, rSWITCHMOVE, ""] call RE;
} else {
player switchMove "";
};
};
};
//diag_log(format["%1 player tackled. Weapons: cur:""%2"" anim.state:%6 (%7)--> move: %3. Angle:%4 Delta-time:%5", __FILE__, currentWeapon player, _move, _deg, time - _lastTackle, animationState player, toArray(animationState player) select 17 ]);
};
}; };
}; };
}; };

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

View File

@@ -6,7 +6,10 @@ _parent = findDisplay 106;
_itemData = gearSlotData _control; _itemData = gearSlotData _control;
if (carryClick) then {carryClick = false;}; if (carryClick) then {carryClick = false;};
// No right click option on bloodbags if DZE_SelfTransfuse = false;
if (!DZE_SelfTransfuse && {(_itemData == "ItemBloodbag") or (_itemData in DZE_typedBags)}) exitWith {}; if (!DZE_SelfTransfuse && {(_itemData == "ItemBloodbag") or (_itemData in DZE_typedBags)}) exitWith {};
if (_button == 1) then { if (_button == 1) then {
private ["_conf","_name","_compile","_height","_item"]; private ["_conf","_name","_compile","_height","_item"];
_group = _parent displayCtrl 6902; _group = _parent displayCtrl 6902;

View File

@@ -13,12 +13,10 @@ or by action/repair.sqf
- return : 0 :) - return : 0 :)
broadcast: boolean. if true, then the request will be sent to all players if the vehicle is not local. broadcast: boolean. if true, then the request will be sent to all players if the vehicle is not local.
************************************************************/ ************************************************************/
private ["_hitpointnames","_log","_damage","_action"]; private ["_hitpointnames","_log"];
_unit = _this select 0; _unit = _this select 0;
_selection = _this select 1; _selection = _this select 1;
_damage = _this select 2;
_action = if (_damage == 0) then {"repair"} else {"damage"};
_hitpointnames = []; _hitpointnames = [];
{ {
@@ -35,19 +33,19 @@ _selection, _unit getVariable [_SVname, 0] ];
if (local _unit) then { if (local _unit) then {
// only local unit can set the damage of a vehicle part // only local unit can set the damage of a vehicle part
_unit setVariable [_SVname, _damage, true]; _unit setVariable [_SVname, 0, true];
_unit setHit [_selection, _damage]; _unit setHit [_selection, 0];
_log = format["%1. setH!t[%2,0]", _log, _selection]; _log = format["%1. setH!t[%2,0]", _log, _selection];
if (!isServer) then { if (!isServer) then {
PVDZ_obj_Save = [_unit, _action]; PVDZ_veh_Save = [_unit, "repair"];
publicVariableServer "PVDZ_obj_Save"; publicVariableServer "PVDZ_veh_Save";
_log = _log + ". Requesting server hive write"; _log = _log + ". Requesting server hive write";
} else { } else {
[_unit, _action] call server_updateObject; [_unit, "repair"] call server_updateObject;
_log = _log + ". Writing to hive"; _log = _log + ". Writing to hive";
}; };
} else { }
else {
if ((count _this > 3) && {(_this select 3)}) then { if ((count _this > 3) && {(_this select 3)}) then {
// vehicle is not local to this client, ask the client which vehicle is local to set damage // vehicle is not local to this client, ask the client which vehicle is local to set damage
_this resize 3; // delete "broadcast" boolean _this resize 3; // delete "broadcast" boolean

View File

@@ -1,6 +1,8 @@
#include "\z\addons\dayz_code\loot\Loot.hpp" #include "\z\addons\dayz_code\loot\Loot.hpp"
private ["_bypass","_position","_unitTypes","_radius","_method","_agent","_maxlocalspawned","_doLoiter","_wildspawns","_maxControlledZombies","_cantSee","_isok","_zPos","__FILE__","_fov","_safeDistance","_farDistance","_xasl","_eye","_ed","_deg","_skipFOV","_wildSpawns","_tooClose","_type","_loot","_array","_rnd","_lootType","_index","_weights","_loot_count","_favStance"]; private ["_bypass","_position","_unitTypes","_radius","_method","_agent","_maxlocalspawned","_doLoiter","_wildspawns","_maxControlledZombies",
"_cantSee","_isOk","_zPos","__FILE__","_fov","_safeDistance","_farDistance","_xasl","_eye","_ed","_deg","_skipFOV","_wildSpawns","_tooClose",
"_type","_loot","_array","_rnd","_lootType","_index","_weights","_loot_count","_favStance","_lootGroup"];
_position = _this select 0; _position = _this select 0;
_doLoiter = _this select 1; // wonder around _doLoiter = _this select 1; // wonder around
@@ -8,7 +10,6 @@ _unitTypes = _this select 2; // class of wanted models
//_wildspawns = _this select 3; //_wildspawns = _this select 3;
_bypass = _this select 3; _bypass = _this select 3;
_maxlocalspawned = round(dayz_spawnZombies); _maxlocalspawned = round(dayz_spawnZombies);
//Lets check if we need to divide the amount of zeds //Lets check if we need to divide the amount of zeds
if (r_player_divideinvehicle > 0) then { if (r_player_divideinvehicle > 0) then {
@@ -18,9 +19,9 @@ if (r_player_divideinvehicle > 0) then {
_maxControlledZombies = round(dayz_maxLocalZombies); _maxControlledZombies = round(dayz_maxLocalZombies);
_cantSee = { _cantSee = {
private ["_isok"]; private "_isOk";
_isok = true; _isOk = true;
_zPos = +(_this select 0); _zPos = +(_this select 0);
if (count _zPos < 3) exitWith { if (count _zPos < 3) exitWith {
diag_log format["%1::_cantSee illegal pos %2", __FILE__, _zPos]; diag_log format["%1::_cantSee illegal pos %2", __FILE__, _zPos];
@@ -35,7 +36,7 @@ _cantSee = {
_xasl = getPosASL _x; _xasl = getPosASL _x;
if (_xasl distance _zPos < _farDistance) then { if (_xasl distance _zPos < _farDistance) then {
if (_xasl distance _zPos < _safeDistance) then { if (_xasl distance _zPos < _safeDistance) then {
_isok = false; _isOk = false;
} else { } else {
_eye = eyePos _x; // ASL _eye = eyePos _x; // ASL
_ed = eyeDirection _x; _ed = eyeDirection _x;
@@ -43,25 +44,24 @@ _cantSee = {
_deg = [_xasl, _zPos] call BIS_fnc_dirTo; _deg = [_xasl, _zPos] call BIS_fnc_dirTo;
_deg = (_deg - _ed + 720) % 360; _deg = (_deg - _ed + 720) % 360;
if (_deg > 180) then { _deg = _deg - 360; }; if (_deg > 180) then { _deg = _deg - 360; };
if ((abs(_deg) < _fov) AND {( // in right angle sector? if ((abs(_deg) < _fov) && {( // in right angle sector?
(!(terrainIntersectASL [_zPos, _eye]) // no terrain between? (!(terrainIntersectASL [_zPos, _eye]) // no terrain between?
AND {(!(lineIntersects [_zPos, _eye]))}) // and no object between? && {(!(lineIntersects [_zPos, _eye]))}) // and no object between?
)}) then { )}) then {
_isok = false; _isOk = false;
}; };
}; };
}; };
if (!_isok) exitWith {false}; if (!_isOk) exitWith {false};
uiSleep 0.001; uiSleep 0.001;
} forEach playableUnits; } forEach playableUnits;
_isok _isOk
}; };
_skipFOV = false; _skipFOV = false;
if ((_maxlocalspawned < _maxControlledZombies) and (dayz_CurrentNearByZombies < dayz_maxNearByZombies) and (dayz_currentGlobalZombies < dayz_maxGlobalZeds)) then { if ((_maxlocalspawned < _maxControlledZombies) && (dayz_CurrentNearByZombies < dayz_maxNearByZombies) && (dayz_currentGlobalZombies < dayz_maxGlobalZeds)) then {
//if (_wildSpawns) then { //if (_wildSpawns) then {
// _skipFOV = true; // _skipFOV = true;
// _position = [_position,150,200] call dayz_RandomLocation; // _position = [_position,150,200] call dayz_RandomLocation;
@@ -71,26 +71,21 @@ if ((_maxlocalspawned < _maxControlledZombies) and (dayz_CurrentNearByZombies <
_position = [_position,3,20,1] call fn_selectRandomLocation; _position = [_position,3,20,1] call fn_selectRandomLocation;
}; };
if (surfaceIsWater _position) exitwith { Diag_log ("Location is in Water Abort"); }; if (surfaceIsWater _position) exitWith { diag_log "Location is in Water Abort"; };
if ((_skipFOV) or {([_position, 15, 10, 70] call _cantSee)}) then { if ((_skipFOV) or {([_position, 15, 10, 70] call _cantSee)}) then {
_tooClose = {isPlayer _x} count (_position nearEntities ["CAManBase",30]) > 0; _tooClose = {isPlayer _x} count (_position nearEntities ["CAManBase",30]) > 0;
if (_tooClose) exitwith { diag_log ("Zombie_Generate: was too close to player."); }; if (_tooClose) exitwith { diag_log "Zombie_Generate: was too close to player."; };
if (count _unitTypes == 0) then if (count _unitTypes == 0) then {
{
_unitTypes = getArray (configFile >> "CfgLoot" >> "Buildings" >> "Default" >> "zombieClass"); _unitTypes = getArray (configFile >> "CfgLoot" >> "Buildings" >> "Default" >> "zombieClass");
}; };
// lets create an agent // lets create an agent
_type = _unitTypes call BIS_fnc_selectRandom; _type = _unitTypes call BIS_fnc_selectRandom;
_radius = 5; _radius = 5;
_method = "NONE"; //_method = if (_doLoiter) then {"CAN_COLLIDE"} else {"NONE"};
if (_doLoiter) then { _agent = createAgent [_type, _position, [], _radius, "CAN_COLLIDE"];
_method = "CAN_COLLIDE";
};
_agent = createAgent [_type, _position, [], _radius, _method];
uiSleep 0.03; uiSleep 0.03;
//add to global counter //add to global counter
@@ -99,14 +94,9 @@ if ((_maxlocalspawned < _maxControlledZombies) and (dayz_CurrentNearByZombies <
dayz_currentGlobalZombies = dayz_currentGlobalZombies + 1; dayz_currentGlobalZombies = dayz_currentGlobalZombies + 1;
//Add some loot //Add some loot
//_loot = ""; if (0.3 > random 1) then {
//_array = [];
//_rnd = random 1;
if (0.7 > random 1) then
{
_lootGroup = configFile >> "CfgVehicles" >> _type >> "zombieLoot"; _lootGroup = configFile >> "CfgVehicles" >> _type >> "zombieLoot";
if (isText _lootGroup) then if (isText _lootGroup) then {
{
//_lootGroup = dayz_lootGroups find getText (_lootGroup); //_lootGroup = dayz_lootGroups find getText (_lootGroup);
_lootGroup = Loot_GetGroup(getText _lootGroup); _lootGroup = Loot_GetGroup(getText _lootGroup);
//[_agent, _lootGroup, 1] call loot_insert; //[_agent, _lootGroup, 1] call loot_insert;
@@ -114,13 +104,11 @@ if ((_maxlocalspawned < _maxControlledZombies) and (dayz_CurrentNearByZombies <
}; };
}; };
_agent setVariable["agentObject",_agent]; _agent setVariable["agentObject",_agent];
if (!isNull _agent) then { if (!isNull _agent) then {
_agent setDir random 360; _agent setDir random 360;
uiSleep 0.03; uiSleep 0.03;
_position = getPosATL _agent; _position = getPosATL _agent;
_favStance = ( _favStance = (
@@ -131,7 +119,6 @@ if ((_maxlocalspawned < _maxControlledZombies) and (dayz_CurrentNearByZombies <
} }
); );
_agent setUnitPos _favStance; _agent setUnitPos _favStance;
_agent setVariable ["stance", _favStance]; _agent setVariable ["stance", _favStance];
_agent setVariable ["BaseLocation", _position]; _agent setVariable ["BaseLocation", _position];
_agent setVariable ["doLoiter", _doLoiter]; // true: Z will be wandering, false: stay still _agent setVariable ["doLoiter", _doLoiter]; // true: Z will be wandering, false: stay still
@@ -141,8 +128,8 @@ if ((_maxlocalspawned < _maxControlledZombies) and (dayz_CurrentNearByZombies <
}; };
//Disable simulation //Disable simulation
PVDZ_Server_Simulation = [_agent, false]; //PVDZ_Server_Simulation = [_agent, false];
publicVariableServer "PVDZ_Server_Simulation"; //publicVariableServer "PVDZ_Server_Simulation";
//Start behavior //Start behavior
_id = [_position,_agent] execFSM "\z\AddOns\dayz_code\system\zombie_agent.fsm"; _id = [_position,_agent] execFSM "\z\AddOns\dayz_code\system\zombie_agent.fsm";

View File

@@ -103,7 +103,7 @@ PVDZE_serverObjectMonitor set [count PVDZE_serverObjectMonitor,_object];
_selection = _x select 0; _selection = _x select 0;
_dam = _x select 1; _dam = _x select 1;
if (_selection in dayZ_explosiveParts && _dam > 0.8) then {_dam = 0.8}; if (_selection in dayZ_explosiveParts && _dam > 0.8) then {_dam = 0.8};
[_object,_selection,_dam] call fnc_veh_handleRepair; [_object,_selection,_dam] call fnc_veh_setFixServer;
} count _array; } count _array;
_object setFuel _fuel; _object setFuel _fuel;

View File

@@ -263,7 +263,7 @@ if (isServer && isNil "sm_done") then {
_selection = _x select 0; _selection = _x select 0;
_dam = _x select 1; _dam = _x select 1;
if (_selection in dayZ_explosiveParts && _dam > 0.8) then {_dam = 0.8}; if (_selection in dayZ_explosiveParts && _dam > 0.8) then {_dam = 0.8};
[_object,_selection,_dam] call fnc_veh_handleRepair; [_object,_selection,_dam] call fnc_veh_setFixServer;
} count _hitpoints; } count _hitpoints;
_object setFuel _fuel; _object setFuel _fuel;