orcthrasher
Well-Known Member
If somebody wants to take a stab at having zombies attack AI, then by all means pitch in - i'm currently looking through all of the dayz_code.pbo and I have some ideas, but I haven't implemented it yet.
Here's a first step though - have the zeds go after your ai gunfire like they would a player.
Add this code in your add_unit_server.sqf (I have mulitple copies of this file to generate different unit types).
It should be within the "for [{ x=1 },{ x < _numunits+1 },{ x = x + 1; }] do " loop near the top.
Then put this sqf file in your units\ directory:
That's pretty much the same code that alerts the zombies to a player gunshot, but the dayz code passes some ranges based upon the fired weapon, which I'm sure could be added pretty easily - baby steps
Here's a first step though - have the zeds go after your ai gunfire like they would a player.
Add this code in your add_unit_server.sqf (I have mulitple copies of this file to generate different unit types).
Code:
// Alert zombies if a weapon is fired
_aiunit addEventHandler ["Fired", {[(_this Select 0),100,true,(getPosATL (_this Select 0))] execvm "units\NPC_AlertZombies.sqf";}];
//_aiunit addEventHandler ["Fired", {diag_log format ["AIUNIT: Alert - unit is shooting shit - %1",_this];}]; // for testing eventhandler
diag_log format ["AIUNIT: Creating MPEvent Handler for %1 ",_aiunit];
It should be within the "for [{ x=1 },{ x < _numunits+1 },{ x = x + 1; }] do " loop near the top.
Then put this sqf file in your units\ directory:
Code:
//NPC_AlertZombies.sqf
private["_unit","_distance","_i","_listTalk","_zombie","_targets","_pos"];
//Alert Zed's to noise of shot
_unit =_this select 0;
_distance = _this select 1;
_doRun =_this select 2;
_pos =_this select 3;
_listTalk = _pos nearEntities ["zZombie_Base",_distance * 2];
// post to the RPT file if an npc alerts a zed
diag_log format ["NPC_AlertZombies: %1, %2, %3, %4",_unit,_distance,_dorun,_pos];
//hint str(_listTalk);
{
_zombie = _x;
if (_doRun) then {
_targets = _zombie getVariable ["targets",[]];
if (!(_unit in _targets)) then {
_targets set [count _targets,_unit];
_zombie setVariable ["targets",_targets,true];
};
} else {
_zombie setVariable ["myDest",_pos,true];
};
} forEach _listTalk;
That's pretty much the same code that alerts the zombies to a player gunshot, but the dayz code passes some ranges based upon the fired weapon, which I'm sure could be added pretty easily - baby steps