Update compiles - 2 more files to do

fn_selfActions.sqf
player_updateGui.sqf
This commit is contained in:
icomrade
2016-02-29 00:26:12 -05:00
parent a83909b918
commit b96cd2d971
67 changed files with 3886 additions and 1212 deletions

View File

@@ -1,110 +1,155 @@
private ["_listTalk","_eyeDir","_attacked","_continue","_type","_chance","_last","_refObj","_inAngle","_tPos","_zPos","_cantSee","_entHeight","_delta","_targets","_pHeight","_lowBlood","_dist"];
_refObj = vehicle player;
_listTalk = ([_refObj] call FNC_GetPos) nearEntities ["zZombie_Base",80];
_pHeight = (getPosATL _refObj) select 2;
_attacked = false;
private ["_attacked","_chance","_near","_targeted","_localtargets","_remotetargets","_forcedSpeed"];
_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
_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 { };
{
_continue = true;
_type = "zombie";
if (alive _x && _continue) then {
_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 {
_type = "zombie";
if (alive _x) then {
private["_dist","_attackDist"];
_dist = (_x distance _refObj);
_group = _x;
_chance = 1; //0 / dayz_monitorPeriod; // Z verbosity
_targetedBySight = false;
_targetedBySound = false;
_dist = (_x distance _refObj);
_localtargets = _group getVariable ["localtargets",[]];
_remotetargets = _group getVariable ["remotetargets",[]];
_targets = _localtargets + _remotetargets;
_chance = 1;
if ((_dist < dayz_areaAffect) && !(animationState _x == "ZombieFeed")) then {
//diag_log ("within attack range: " + str(_x));
[_x,"attack",(_chance),true] call dayz_zombieSpeak;
//perform an attack
_last = _x getVariable["lastAttack",0];
_entHeight = (getPosATL _x) select 2;
_delta = _pHeight - _entHeight;
if ( ((time - _last) > 1) && ((_delta < 1.5) && (_delta > -1.5)) ) then
{
//diag_log ("perform attack: " + str(_x));
[_x, _type] spawn player_zombieAttack;
_x setVariable["lastAttack",time];
};
_attacked = true;
} else {
if (speed _x < 4) then {
[_x,"idle",(_chance + 4),true] call dayz_zombieSpeak;
//diag_log ("idle: " + str((_chance + 4)));
} else {
[_x,"chase",(_chance + 3),true] call dayz_zombieSpeak;
//diag_log ("chase: " + str((_chance + 3)));
};
};
//Noise Activation
_targets = _x getVariable ["targets",[]];
if (!(_refObj in _targets) && !isNull _refObj) then {
if (_dist < DAYZ_disAudial) then {
if (DAYZ_disAudial > 80) then {
_targets set [count _targets, (driver _refObj)];
_x setVariable ["targets",_targets,true];
//diag_log ("45: " + str(_targets));
if (_x distance player >= (dayz_areaAffect*2)) then {
if (speed _x < 4) then {
[_x,"idle",(_chance + 4),true] call dayz_zombieSpeak;
} else {
_cantSee = [_x,_refObj] call dayz_losCheck;
if (!_cantSee) then
{
_targets set [count _targets,(driver _refObj)];
_x setVariable ["targets",_targets,true];
//diag_log ("54: " + str(_targets));
}
else
{
if (_dist < (DAYZ_disAudial / 2)) then
{
_targets set [count _targets,(driver _refObj)];
//diag_log ("61: " + str(_targets));
_x setVariable ["targets",_targets,true];
[_x,"chase",(_chance + 3),true] call dayz_zombieSpeak;
};
};
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];
_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
_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];
};
};
} else {
_x setVariable ["speedLimit", _forcedSpeed, false];
};
_attacked = true;
} else {
_x setVariable ["speedLimit", _forcedSpeed, false];
};
//};
//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 (_dist < DAYZ_disAudial) then {
if (DAYZ_disAudial > 80) then {
_targetedBySound = true;
} else {
//if (DAYZ_disAudial > 6) then {
_chance = [_x,_dist,DAYZ_disAudial] call dayz_losChance;
//diag_log ("Visual Detection: " + str([_x,_dist]) + " " + str(_chance));
if ((random 1) < _chance) then {
//make sure the player isnt behind a building or wall if target is in the open always target if player is making too much noise
_cantSee = [_refObj,_x] call dayz_losCheck;
if (!_cantSee) then {
_targetedBySound = true;
} else {
if (_dist < (DAYZ_disAudial / 2)) then {
_targetedBySound = true;
};
};
};
//};
};
};
//Sight Activation
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);
_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;
};
};
};
};
};
};
};
//Sight Activation
_targets = _x getVariable ["targets",[]];
if (!(_refObj in _targets) && !isNull _refObj) then {
if (_dist < DAYZ_disVisual) then {
_tPos = (getPosASL _refObj);
_zPos = (getPosASL _x);
//_eyeDir = _x call dayz_eyeDir;
_eyeDir = direction _x;
_inAngle = [_zPos,_eyeDir,30,_tPos] call fnc_inAngleSector;
//diag_log ("Angle Check: " + str(_inAngle));
if (_inAngle) then {
//LOS check
_cantSee = [_x,_refObj] call dayz_losCheck;
//diag_log ("LOS Check: " + str(_cantSee));
if (!_cantSee) then {
//diag_log ("Within LOS! Target");
_targets set [count _targets,(driver _refObj)];
_x setVariable ["targets",_targets,true];
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 {
case false: {
_remotetargets set [count _remotetargets,_refObj];
_x setVariable ["remotetargets",_remotetargets,true];
};
case true: {
_localtargets set [count _localtargets,_refObj];
_x setVariable ["localtargets",_localtargets,false];
};
};
};
};
};
} count _listTalk;
} forEach _listTalk;
if (_attacked) then {
if (r_player_unconscious) then {
[_refObj,"scream",3,false] call dayz_zombieSpeak;
[_refObj, "scream", 6, false] call dayz_zombieSpeak;
} else {
_lowBlood = (r_player_blood / r_player_bloodTotal) < 0.5;
if (_lowBlood) then {
dayz_panicCooldown = time;
[_refObj,"panic",3,false] call dayz_zombieSpeak;
dayz_panicCooldown = diag_ticktime;
[_refObj, "panic", 6, false] call dayz_zombieSpeak;
};
};
};
};
// return true if attacked or near. if so, player_monitor will perform its ridiculous 'while true' loop faster.
(_attacked OR _near)