diff --git a/CHANGE LOG 1.0.6.txt b/CHANGE LOG 1.0.6.txt index f6f530a3b..66a24f244 100644 --- a/CHANGE LOG 1.0.6.txt +++ b/CHANGE LOG 1.0.6.txt @@ -8,7 +8,7 @@ - Journal is now functional for displaying stats - ItemFish, Shotgun ammo and several other item classnames changed. See SQL\1.0.6_Updates - Dupicate functions have been renamed: - - object_setFixServer --> fnc_veh_handleRepair + - object_setFixServer --> fnc_veh_setFixServer - vehicle_handleDamage --> fnc_veh_handleDam - vehicle_handleKilled --> fnc_veh_handleKilled - Duplicate global variables have been renamed: diff --git a/SQF/dayz_code/compile/player_throwObject.sqf b/SQF/dayz_code/compile/player_throwObject.sqf index be811a580..b2083864c 100644 --- a/SQF/dayz_code/compile/player_throwObject.sqf +++ b/SQF/dayz_code/compile/player_throwObject.sqf @@ -5,7 +5,7 @@ _unit = _obj select 0; _ammo = _obj select 4; _projectile = _obj select 6; -waituntil {!isnil "dayz_sunRise"}; +waituntil {!isNil "dayz_sunRise"}; _projectile = nearestObject [_unit,_ammo]; _endPos = getPosATL _projectile; @@ -13,7 +13,7 @@ _endPos = getPosATL _projectile; _doWait = true; while {_doWait} do { _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}; _endPos = getPosATL _projectile; uiSleep 0.01; @@ -25,11 +25,7 @@ if (_ammo isKindOf "ChemLight") then { _distance = 10; }; if (_ammo isKindOf "RoadFlare") then { - if ((daytime < (24 - dayz_sunRise)) and (daytime > dayz_sunRise)) then { - _distance = 30; - } else { - _distance = 60; - }; + _distance = if ((daytime < (24 - dayz_sunRise)) && (daytime > dayz_sunRise)) then {30} else {60}; }; [_unit,_distance,false,_endPos] call player_alertZombies; \ No newline at end of file diff --git a/SQF/dayz_code/compile/player_weaponFiredNear.sqf b/SQF/dayz_code/compile/player_weaponFiredNear.sqf index 733681825..2d806233e 100644 --- a/SQF/dayz_code/compile/player_weaponFiredNear.sqf +++ b/SQF/dayz_code/compile/player_weaponFiredNear.sqf @@ -1,41 +1,40 @@ //[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 //[unit, firer, distance, weapon, muzzle, mode, ammo] - _unit = _this select 0; - _firer = _this select 1; + _unit = _this select 0; + _firer = _this select 1; _distance = _this select 2; - _weapon = _this select 3; - _ammo = _this select 6; - _killerID = _firer getVariable["MemberID",0]; + _weapon = _this select 3; + _ammo = _this select 6; + //_killerID = _firer getVariable["MemberID",0]; - _handled = false; + _handled = false; _arc = 60; _isBallistic = (getNumber (configfile >> "CfgAmmo" >> _ammo >> "whistleOnFire") > 0); _dmgDistance = getNumber (configfile >> "CfgAmmo" >> _ammo >> "whistleDist"); _isRocket = ((_ammo isKindOf "RocketBase") && (_firer isKindOf "Man")); _isPlayer = (_unit == player); _inVehicle = (vehicle _unit != _unit); - _evType = ""; - _recordable = false; + //_evType = ""; + //_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)); _firer setVariable["startcombattimer", 1]; if (_distance <= 8) then { _unit setVariable["startcombattimer", 1]; }; - - if (_inVehicle) exitWith{}; - if (_firer == player) exitWith{}; + if (_inVehicle) exitWith {}; + if (_firer == player) exitWith {}; //Is in danger angle? _turretDir = _firer weaponDirection _weapon; _weaponDir = ((_turretDir select 0) atan2 (_turretDir select 1)); - _pos1 = getposATL _unit; - _pos2 = getposATL _firer; - _facing = ((_pos1 Select 0) - (_pos2 Select 0)) ATan2 ((_pos1 Select 1) - (_pos2 Select 1)); + _pos1 = getPosATL _unit; + _pos2 = getPosATL _firer; + _facing = ((_pos1 select 0) - (_pos2 select 0)) atan2 ((_pos1 select 1) - (_pos2 select 1)); _firingArc = (_weaponDir - _facing); _firingArc = (-_firingArc) max (_firingArc); @@ -53,10 +52,11 @@ private ["_unit","_evType","_recordable","_inVehicle","_isPlayer","_isRocket","_ //serious ballistic damage if (_isPlayer) then { [_unit, "head_hit", 1.51, _firer, _ammo] call fnc_usec_damageHandler; + // head damage > 1.5 ---> log + death }; [_unit,4] call fnc_usec_damageUnconscious; - } else {; + } else { //Just Knocked out [_unit,0.5] call fnc_usec_damageUnconscious; }; @@ -68,13 +68,14 @@ private ["_unit","_evType","_recordable","_inVehicle","_isPlayer","_isRocket","_ }; }; } else { - if (_isRocket && (_isInFront || _isInRear)) then { + if (_isRocket && (_isInFront or _isInRear)) then { if ((_distance < 5) && !_handled) then { 1 call fnc_usec_bulletHit; [20,45] call fnc_usec_pitchWhine; //Visual , Sound // Dead if (_isPlayer) then { [_unit, "head_hit", 1.51, _firer, _ammo] call fnc_usec_damageHandler; + // head damage > 1.5 ---> log + death }; [_unit,2] call fnc_usec_damageUnconscious; }; diff --git a/SQF/dayz_code/compile/player_zombieAttack.sqf b/SQF/dayz_code/compile/player_zombieAttack.sqf index bb5357c60..51c4afddf 100644 --- a/SQF/dayz_code/compile/player_zombieAttack.sqf +++ b/SQF/dayz_code/compile/player_zombieAttack.sqf @@ -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 ]); + }; }; }; }; diff --git a/SQF/dayz_code/compile/player_zombieCheck.sqf b/SQF/dayz_code/compile/player_zombieCheck.sqf index 652e4d75a..841861e91 100644 --- a/SQF/dayz_code/compile/player_zombieCheck.sqf +++ b/SQF/dayz_code/compile/player_zombieCheck.sqf @@ -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) \ No newline at end of file diff --git a/SQF/dayz_code/compile/ui_selectSlot.sqf b/SQF/dayz_code/compile/ui_selectSlot.sqf index 40f212b9f..fd96b7ac2 100644 --- a/SQF/dayz_code/compile/ui_selectSlot.sqf +++ b/SQF/dayz_code/compile/ui_selectSlot.sqf @@ -6,7 +6,10 @@ _parent = findDisplay 106; _itemData = gearSlotData _control; 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 (_button == 1) then { private ["_conf","_name","_compile","_height","_item"]; _group = _parent displayCtrl 6902; diff --git a/SQF/dayz_code/compile/veh_handleRepair.sqf b/SQF/dayz_code/compile/veh_handleRepair.sqf index 447dc0944..c359e0e74 100644 --- a/SQF/dayz_code/compile/veh_handleRepair.sqf +++ b/SQF/dayz_code/compile/veh_handleRepair.sqf @@ -13,12 +13,10 @@ or by action/repair.sqf - return : 0 :) 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; _selection = _this select 1; -_damage = _this select 2; -_action = if (_damage == 0) then {"repair"} else {"damage"}; _hitpointnames = []; { @@ -35,19 +33,19 @@ _selection, _unit getVariable [_SVname, 0] ]; if (local _unit) then { // only local unit can set the damage of a vehicle part - _unit setVariable [_SVname, _damage, true]; - _unit setHit [_selection, _damage]; + _unit setVariable [_SVname, 0, true]; + _unit setHit [_selection, 0]; _log = format["%1. setH!t[%2,0]", _log, _selection]; - if (!isServer) then { - PVDZ_obj_Save = [_unit, _action]; - publicVariableServer "PVDZ_obj_Save"; + PVDZ_veh_Save = [_unit, "repair"]; + publicVariableServer "PVDZ_veh_Save"; _log = _log + ". Requesting server hive write"; } else { - [_unit, _action] call server_updateObject; + [_unit, "repair"] call server_updateObject; _log = _log + ". Writing to hive"; }; -} else { +} +else { 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 _this resize 3; // delete "broadcast" boolean diff --git a/SQF/dayz_code/compile/zombie_generate.sqf b/SQF/dayz_code/compile/zombie_generate.sqf index d189d1dee..77215b2a9 100644 --- a/SQF/dayz_code/compile/zombie_generate.sqf +++ b/SQF/dayz_code/compile/zombie_generate.sqf @@ -1,6 +1,8 @@ #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; _doLoiter = _this select 1; // wonder around @@ -8,7 +10,6 @@ _unitTypes = _this select 2; // class of wanted models //_wildspawns = _this select 3; _bypass = _this select 3; - _maxlocalspawned = round(dayz_spawnZombies); //Lets check if we need to divide the amount of zeds if (r_player_divideinvehicle > 0) then { @@ -18,9 +19,9 @@ if (r_player_divideinvehicle > 0) then { _maxControlledZombies = round(dayz_maxLocalZombies); _cantSee = { - private ["_isok"]; + private "_isOk"; - _isok = true; + _isOk = true; _zPos = +(_this select 0); if (count _zPos < 3) exitWith { diag_log format["%1::_cantSee illegal pos %2", __FILE__, _zPos]; @@ -35,7 +36,7 @@ _cantSee = { _xasl = getPosASL _x; if (_xasl distance _zPos < _farDistance) then { if (_xasl distance _zPos < _safeDistance) then { - _isok = false; + _isOk = false; } else { _eye = eyePos _x; // ASL _ed = eyeDirection _x; @@ -43,25 +44,24 @@ _cantSee = { _deg = [_xasl, _zPos] call BIS_fnc_dirTo; _deg = (_deg - _ed + 720) % 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? - AND {(!(lineIntersects [_zPos, _eye]))}) // and no object between? + && {(!(lineIntersects [_zPos, _eye]))}) // and no object between? )}) then { - _isok = false; + _isOk = false; }; }; }; - if (!_isok) exitWith {false}; + if (!_isOk) exitWith {false}; uiSleep 0.001; } forEach playableUnits; - _isok + _isOk }; _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 { // _skipFOV = true; // _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; }; - 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 { _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"); }; // lets create an agent _type = _unitTypes call BIS_fnc_selectRandom; _radius = 5; - _method = "NONE"; - if (_doLoiter) then { - _method = "CAN_COLLIDE"; - }; - - _agent = createAgent [_type, _position, [], _radius, _method]; + //_method = if (_doLoiter) then {"CAN_COLLIDE"} else {"NONE"}; + _agent = createAgent [_type, _position, [], _radius, "CAN_COLLIDE"]; uiSleep 0.03; //add to global counter @@ -99,14 +94,9 @@ if ((_maxlocalspawned < _maxControlledZombies) and (dayz_CurrentNearByZombies < dayz_currentGlobalZombies = dayz_currentGlobalZombies + 1; //Add some loot - //_loot = ""; - //_array = []; - //_rnd = random 1; - if (0.7 > random 1) then - { + if (0.3 > random 1) then { _lootGroup = configFile >> "CfgVehicles" >> _type >> "zombieLoot"; - if (isText _lootGroup) then - { + if (isText _lootGroup) then { //_lootGroup = dayz_lootGroups find getText (_lootGroup); _lootGroup = Loot_GetGroup(getText _lootGroup); //[_agent, _lootGroup, 1] call loot_insert; @@ -114,13 +104,11 @@ if ((_maxlocalspawned < _maxControlledZombies) and (dayz_CurrentNearByZombies < }; }; - _agent setVariable["agentObject",_agent]; if (!isNull _agent) then { _agent setDir random 360; uiSleep 0.03; - _position = getPosATL _agent; _favStance = ( @@ -131,7 +119,6 @@ if ((_maxlocalspawned < _maxControlledZombies) and (dayz_CurrentNearByZombies < } ); _agent setUnitPos _favStance; - _agent setVariable ["stance", _favStance]; _agent setVariable ["BaseLocation", _position]; _agent setVariable ["doLoiter", _doLoiter]; // true: Z will be wandering, false: stay still @@ -141,8 +128,8 @@ if ((_maxlocalspawned < _maxControlledZombies) and (dayz_CurrentNearByZombies < }; //Disable simulation - PVDZ_Server_Simulation = [_agent, false]; - publicVariableServer "PVDZ_Server_Simulation"; + //PVDZ_Server_Simulation = [_agent, false]; + //publicVariableServer "PVDZ_Server_Simulation"; //Start behavior _id = [_position,_agent] execFSM "\z\AddOns\dayz_code\system\zombie_agent.fsm"; diff --git a/SQF/dayz_server/compile/server_publishVehicle.sqf b/SQF/dayz_server/compile/server_publishVehicle.sqf index 056c19a03..45a2899d8 100644 --- a/SQF/dayz_server/compile/server_publishVehicle.sqf +++ b/SQF/dayz_server/compile/server_publishVehicle.sqf @@ -103,7 +103,7 @@ PVDZE_serverObjectMonitor set [count PVDZE_serverObjectMonitor,_object]; _selection = _x select 0; _dam = _x select 1; 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; _object setFuel _fuel; diff --git a/SQF/dayz_server/system/server_monitor.sqf b/SQF/dayz_server/system/server_monitor.sqf index 29dea470f..a7a885252 100644 --- a/SQF/dayz_server/system/server_monitor.sqf +++ b/SQF/dayz_server/system/server_monitor.sqf @@ -263,7 +263,7 @@ if (isServer && isNil "sm_done") then { _selection = _x select 0; _dam = _x select 1; 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; _object setFuel _fuel;