dayZ NPC (AI) Units / Troops | Add to Server.

is there anyway you can get these guards to respawn after a certain ammount of time? been at this all day, got the NPC's working, just they die then never respawn. any help would be much appreciated.
 
Code:
 private["_aiunit","_xpos","_ypos","_unitpos","_aiGroup","_wppos","_wpradius","_wpnum","_numunits","_rndLOut","_ailoadout","_aiwep","_aiammo","_wp","_aispawnpos"];
    _aiunit = objNull;
    _aiGroup = createGroup resistance;
    _aispawnpos =_this select 0;
    _wpradius = _this select 1;
    _wpnum = _this select 2;
    _numunits = _this select 3;
 
    _xpos = _aispawnpos select 0;
    _ypos = _aispawnpos select 1;
 
    diag_log format ["AIUNIT: Spawn initiated: Centre:%1 | Radius in m:%2 | Waypoint number:%3",_aispawnpos,_wpradius,_wpnum];
 
    for [{ x=1 },{ x < _numunits+1 },{ x = x + 1; }] do {
    _unitpos = [_xpos+x,_ypos+x,0];
 
    _rndLOut=floor(random 3);
    _ailoadout=
    switch (_rndLOut) do
    {
      case 0: {["AK_47_M","30Rnd_762x39_AK47"]};
      case 1: {["M4A1_AIM_SD_camo","30Rnd_556x45_StanagSD"]};
      case 2: {["Remington870_lamp","8Rnd_B_Beneli_74Slug"]};
    };
 
    "BAF_Soldier_L_DDPM" createUnit [_unitpos, _aiGroup, "_aiunit=this;",0.6,"Private"];
 
    diag_log format ["AIUNIT: Creating BAF_Soldier_L_DDPM by %1 at %2. Result:%3 | Loadout:%4 / Num:%5",player,_unitpos,_aiunit,_ailoadout,_rndLOut];
 
    _aiunit enableAI "TARGET";
    _aiunit enableAI "AUTOTARGET";
    _aiunit enableAI "MOVE";
    _aiunit enableAI "ANIM";
    _aiunit enableAI "FSM";
    _aiunit allowDammage true;
 
    _aiunit setCombatMode "RED";
    _aiunit setBehaviour "COMBAT";
 
    //clear default weapons / ammo
    removeAllWeapons _aiunit;
    //add random selection
    _aiwep = _ailoadout select 0;
    _aiammo = _ailoadout select 1;
    _aiunit addweapon _aiwep;
    _aiunit addMagazine _aiammo;
    _aiunit addMagazine _aiammo;
    _aiunit addMagazine _aiammo;
    _aiunit addMagazine _aiammo;
    _aiunit addMagazine _aiammo;
    _aiunit addMagazine _aiammo;
    _aiunit addMagazine _aiammo;
    _aiunit addMagazine _aiammo;
 
    //set skills
    _aiunit setSkill ["aimingAccuracy",1];
    _aiunit setSkill ["aimingShake",1];
    _aiunit setSkill ["aimingSpeed",1];
    _aiunit setSkill ["endurance",1];
    _aiunit setSkill ["spotDistance",1];
    _aiunit setSkill ["spotTime",1];
    _aiunit setSkill ["courage",1];
    _aiunit setSkill ["reloadSpeed",1];
    _aiunit setSkill ["commanding",1];
    _aiunit setSkill ["general",1];
    //sleep 0.5;
    } ;
 
    //generate waypoints
    for [{ x=1 },{ x < _wpnum },{ x = x + 1; }] do {
    _wppos = [_xpos+(x*20),_ypos+(x*20),_wpradius];
    _wp = _aiGroup addWaypoint [_wppos, _wpradius];
    _wp setWaypointType "MOVE";
    };
    _wp = _aiGroup addWaypoint [[_xpos,_ypos,0], _wpradius];
    _wp setWaypointType "CYCLE";
 
    diag_log format ["AIUNIT: Last Waypoint %1 at %2",_wp,_wppos];

Do i have to change anything there? I have already changed waypoints and spawns and guns in the dayz_ai_npc_units.pbo ! Do i have to change anything more???
 
is there anyway you can get these guards to respawn after a certain ammount of time? been at this all day, got the NPC's working, just they die then never respawn. any help would be much appreciated.
I would add an eventhandler to each, on killed, then check if any of the group still live, if not call another spawn command..
 
is there anyway you can get these guards to respawn after a certain ammount of time? been at this all day, got the NPC's working, just they die then never respawn. any help would be much appreciated.

You can do this:

add_unit_server.sqf:
Code:
_aiunit enableAI "TARGET";
_aiunit enableAI "AUTOTARGET";
_aiunit enableAI "MOVE";
_aiunit enableAI "ANIM";
_aiunit enableAI "FSM";
_aiunit allowDammage true;
_aiunit setCombatMode "RED";
_aiunit setBehaviour "COMBAT";
//When npc is dead, reappears in this dead place
_aiunit addEventHandler ["Killed",{null=_this+[(getPosATL (_this Select 0)),wpradius,wpnum,1] execVM "units\unit_killed.sqf";}];

unit_killed.sqf:
Code:
private ["_player","_killer","_aispawnpos","_wpradius","_wpnum","_numUnits","_banditKills","_humanity"];
_player = _this select 0;
_killer = _this select 1;
_aispawnpos = _this select 2;
_wpradius = _this select 3;
_wpnum = _this select 4;
_numUnits = _this select 5;
_banditKills = 0;
_humanity = 0;
 
//AI kill counter & humanity
//I play with npc bandit
_banditKills = _killer getVariable["banditKills",0];
_killer setVariable["banditKills",_banditKills+1,true];
_humanity = _killer getVariable["humanity",0];
_killer setVariable["humanity",_humanity+100,true];
 
sleep 12;//12 seconds test
 
aispawnpos = _aispawnpos;
wpradius = _wpradius;
wpnum = _wpnum;
numUnits = _numUnits;
 
//_player hideObject true;
_aispawn = [aispawnpos,wpradius,wpnum,numUnits] execVM "units\add_unit_server.sqf";
 
So thing is, u download the deafult misson pbo, open init.sqf and put the
if (isServer) then {
_dayzFactions = [] execVM "Dayz_Factions\init.sqf";
//diag_log format["Dayz Factions executed: %1",_dayzFactions];
//Array to pass to .sqf: [[<worldspace>],radius of waypoints (in metres),number of waypoints,number of ai units]
_aispawn = [[6689.49,2623.59,0],160,8,4] execVM "units\add_unit_server.sqf";//Chernogorsk
_aispawn = [[7622.51,7912.7,0],5000,20,6] execVM "units\add_unit_server.sqf";//Chernaurs (Whole map)
_aispawn = [[7625.51,7915.7,0],5000,20,6] execVM "units\add_unit_server.sqf";//Chernaurs (Whole map)
_aispawn = [[4598.66,10197.7,0],650,12,4] execVM "units\add_unit_server.sqf";//NW Airfield
_aispawn = [[10447.5,2246.96,0],180,3,3] execVM "units\add_unit_server.sqf";//Electrozavodsk
_aispawn = [[13253.3,6406.53,0],180,4,3] execVM "units\add_unit_server.sqf";//Solnichniy
};

Anywhere in the file? am i right?
 
Check your .rpt file for an error.. if nothing make sure all files are where they should be. Zeroday is a separate issue, are you using another ai mod ?

I fixed it, but now its says something went wrong, disconnect and try again...
Yes i used the one that you linked below yours
 
Can anybody make a for dummies way of making this, like a step by step? I know bare minimum about coding, took one class in high school. >.> You guys are speaking a different language.
 
I have got a problem adding this to Taviana, can anybody help me? I just bought a new Taviana server and the init is much diffrent from chernarus
 
So long as the init.sqf entries go in the isServer bit:
Code:
if (isServer) then {
<IN HERE>
};
it should run. Not sure how it works on Tavi, am sure people here will have some experience..
 
I just get a loading screen, do i add the code including this if (isServer) then { or just below it? Because i just added it below it and it didnt work
 
Is the tutorial on page one of this post up to date? i think i am following it.... :/ maybe i'll back up my files before i try this.. :)
 
I just get a loading screen, do i add the code including this if (isServer) then { or just below it? Because i just added it below it and it didnt work
Have you changed the worldspace entries for tavi ? Locations are different..
 
Back
Top