mirror of
https://github.com/EpochModTeam/DayZ-Epoch.git
synced 2026-02-04 15:22:53 +03:00
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:
@@ -2,24 +2,24 @@
|
||||
Created exclusively for ArmA2:OA - DayZMod.
|
||||
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"];
|
||||
//_start = diag_tickTime;
|
||||
private ["_rnd","_move","_wound","_cnt","_index","_damage","_total","_movePlayer","_start","_unit","_type","_vehicle","_speed",
|
||||
"_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;
|
||||
_type = _this select 1;
|
||||
|
||||
_vehicle = (vehicle player);
|
||||
_vehicle = vehicle player;
|
||||
_speed = speed player;
|
||||
//_nextPlayerPos = player call dayz_futurePos;
|
||||
_distance = [_unit, player] call BIS_fnc_distance2D;
|
||||
//_viralZeds = typeOf _unit in DayZ_ViralZeds;
|
||||
_isVehicle = (_vehicle != player);
|
||||
//_agentPos = getPosATL _unit;
|
||||
|
||||
_playerDodged = false;
|
||||
|
||||
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
|
||||
_rnd = 0;
|
||||
@@ -33,11 +33,11 @@ switch true do {
|
||||
_rnd = ceil(random 4); //9
|
||||
_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;
|
||||
_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;
|
||||
_move = "ZombieStandingAttack" + str(_rnd);
|
||||
};
|
||||
@@ -76,21 +76,25 @@ _dir = [_unit,player] call BIS_Fnc_dirTo;
|
||||
_unit setDir _dir;
|
||||
|
||||
// let's animate the Z
|
||||
/*
|
||||
if (local _unit) then {
|
||||
_unit PlayMove _move;
|
||||
_unit switchMove _move;
|
||||
} 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
|
||||
_timeout = diag_tickTime + 0.3;
|
||||
waitUntil { diag_tickTime >= _timeout; };
|
||||
//_timeout = diag_tickTime + 0.3;
|
||||
//waitUntil { diag_tickTime >= _timeout; };
|
||||
|
||||
_deg = [player, _unit] call BIS_fnc_relativeDirTo;
|
||||
_lastDodge = _unit getVariable ["lastDodge", 0];
|
||||
//1 in 5 shots
|
||||
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"];
|
||||
if ((animationState _vehicle) in _dodgeAnimations) then {
|
||||
if (dayz_dodge) exitwith {
|
||||
@@ -107,8 +111,8 @@ if (_playerDodged) exitwith {
|
||||
_lastDodge = _unit setVariable ["lastDodge", diag_tickTime];
|
||||
};
|
||||
|
||||
_tPos = (getPosASL _vehicle);
|
||||
_zPos = (getPosASL _unit);
|
||||
_tPos = getPosASL _vehicle;
|
||||
_zPos = getPosASL _unit;
|
||||
// compute damage for vehicle and/or the player
|
||||
if (_isVehicle) then {
|
||||
if ((_unit distance player) < (3.3 * 2)) then {
|
||||
@@ -127,14 +131,13 @@ if (_isVehicle) then {
|
||||
} 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);
|
||||
_dam = _vehicle getVariable [_strH,0];
|
||||
_total = (_dam + _damage);
|
||||
|
||||
//handle vehicle dmg
|
||||
[_vehicle, _wound, _total, _unit, "zombie", true] call fnc_veh_handleDam;
|
||||
|
||||
//diag_log ("Hitpoints " +str(_wound) +str(_total));
|
||||
|
||||
//handle player dmg
|
||||
@@ -166,13 +169,14 @@ if (_isVehicle) then {
|
||||
};
|
||||
} else {
|
||||
// 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.
|
||||
_damage = 0.2 + random (1.2);
|
||||
|
||||
//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 (r_player_blood < (r_player_bloodTotal * 0.8)) then {
|
||||
_cnt = count (DAYZ_woundHit select 1);
|
||||
@@ -186,146 +190,138 @@ if (_isVehicle) then {
|
||||
_wound = (DAYZ_woundHit_ok select 0) select _index;
|
||||
};
|
||||
|
||||
//Stop the Zed
|
||||
_unit setVariable ["speedLimit", 0, false];
|
||||
|
||||
//_attackanimations = ["zombiestandingattack1","zombiestandingattack2","zombiestandingattack3","zombiestandingattack4","zombiestandingattack5","zombiestandingattack6","zombiestandingattack7","zombiestandingattack8","zombiestandingattack9","zombiestandingattack10","zombiefeed1","zombiefeed2","zombiefeed3","zombiefeed4","zombiefeed5"];
|
||||
_unit setVariable ["speedLimit", 0, false]; //Stop the Zed
|
||||
//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"];
|
||||
|
||||
//diag_log ((animationState _unit));
|
||||
|
||||
//if ((animationState _unit) in _attackanimations) then {
|
||||
if ((animationState _unit) in _attackanimations) then {
|
||||
if (alive _unit) then {
|
||||
//Damage the player
|
||||
[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
|
||||
if (unitPos _unit != "UP") then {
|
||||
_unit setUnitPos "UP";
|
||||
if (unitPos _unit != "UP") then {_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
|
||||
_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;
|
||||
};
|
||||
|
||||
// player may fall if hit...
|
||||
_deg = [player, _unit] call BIS_fnc_relativeDirTo;
|
||||
_lastTackle = player getVariable ["lastTackle", 0];
|
||||
_movePlayer = "";
|
||||
|
||||
//head hit, Legs, pushed from back
|
||||
_knockdown = ["head_hit","legs"];
|
||||
//diag_log ("ZombieAttack: "+str(_wound));
|
||||
//_isHeadHit = (_wound == "head_hit");
|
||||
if (_wound in _knockdown) then {
|
||||
if (((diag_tickTime - _lastTackle) > 7) and (_speed >= 5.62)) then {
|
||||
switch true do {
|
||||
/*
|
||||
//Removed for now
|
||||
// front
|
||||
case (((_deg > 315) and (_deg <= 360)) or ((_deg > 0) and (_deg < 45))) : {
|
||||
//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;
|
||||
};
|
||||
// player may fall if hit
|
||||
_deg = [player, _unit] call BIS_fnc_relativeDirTo;
|
||||
_lastTackle = player getVariable ["lastTackle", 0];
|
||||
_movePlayer = "";
|
||||
|
||||
//head hit, legs, pushed from back
|
||||
_knockdown = ["head_hit","legs"];
|
||||
if (_wound in _knockdown) then {
|
||||
if (((diag_tickTime - _lastTackle) > 7) && (_speed >= 5.62)) then {
|
||||
switch true do {
|
||||
/*
|
||||
//Removed for now
|
||||
// front
|
||||
case (((_deg > 315) && (_deg <= 360)) or ((_deg > 0) && (_deg < 45))) : {
|
||||
//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;};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
// make player dive
|
||||
_movePlayer = switch (toArray(animationState player) select 17) do {
|
||||
case 114 : {"ActsPercMrunSlowWrflDf_TumbleOver"}; // rifle
|
||||
case 112 : {"AmovPercMsprSlowWpstDf_AmovPpneMstpSrasWpstDnon"}; // pistol
|
||||
default {"ActsPercMrunSlowWrflDf_TumbleOver"};
|
||||
};
|
||||
};
|
||||
// right
|
||||
case (((_deg > 45) and (_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) 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;
|
||||
*/
|
||||
// left
|
||||
case (((_deg > 225) && (_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;
|
||||
};
|
||||
};
|
||||
|
||||
if (_doRE) then {
|
||||
[nil, player, rSWITCHMOVE, ""] call RE;
|
||||
} else {
|
||||
player switchMove "";
|
||||
// make player dive
|
||||
_movePlayer = switch (toArray(animationState player) select 17) do {
|
||||
case 114 : {"ActsPercMrunSlowWrflDf_TumbleOver"}; // rifle
|
||||
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 ]);
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user