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

Alright I've done as you have explained, so between these 2 changes will have AI and zombies attacking each other, and AI attacking players?

I noticed in the other thread you were looking into a way for the AI to differentiate Bandits, survivors and heroes... That would tie in perfectly with having custom bases that only people of appropriate humanity level could enter. If you manage to figure it out, hope you share.
zombies wont attack AI, but AI will attack zombies.. they are classified as civilian, so if civilian is hostile to you, then you can't do things like open boxes and loot bodies.. im trying to get a fix working that makes them east or guer instead of civilians, which would solve this, but currently zombies will only attack you.
 
Alright I've done as you have explained, so between these 2 changes will have AI and zombies attacking each other, and AI attacking players?

I noticed in the other thread you were looking into a way for the AI to differentiate Bandits, survivors and heroes... That would tie in perfectly with having custom bases that only people of appropriate humanity level could enter. If you manage to figure it out, hope you share.

Yea this is a great community. I like how everyone shares and helps each other out.
 
I am currently trying to add a trigger to an AI unit, or a vehicle (that the AI are driving). I have a bus that is doing the rounds on the coast road on my server, and being driven by AI using waypoints. I want the driver to beep the horn at bus stops and him and his buddy to react to the bus being attacked or taken over.

I am trying to add the triggers with code so I can attach them to the bus and deal with them dynamically, rather than putting them in my mission.sqm. Will update with further progress.

Am quite pleased with the bus, it drives the whole length of the coast and back, then starts it's route again. Need to add fuel stops, as I am sure it will be out of fuel before the server restarts. A welcome message, as the survivor gets on the bus. And even toying with the idea of some basic chat AI, see if I can fool a player into thinking that the drivers mate is a real person :)
 
I am currently trying to add a trigger to an AI unit, or a vehicle (that the AI are driving). I have a bus that is doing the rounds on the coast road on my server, and being driven by AI using waypoints. I want the driver to beep the horn at bus stops and him and his buddy to react to the bus being attacked or taken over.

I am trying to add the triggers with code so I can attach them to the bus and deal with them dynamically, rather than putting them in my mission.sqm. Will update with further progress.

Am quite pleased with the bus, it drives the whole length of the coast and back, then starts it's route again. Need to add fuel stops, as I am sure it will be out of fuel before the server restarts. A welcome message, as the survivor gets on the bus. And even toying with the idea of some basic chat AI, see if I can fool a player into thinking that the drivers mate is a real person :)
oh my god that is epic.. lol. i can't wait till you get it nailed down and release the code..
 
Think I might be missing something.. I'm adding this to my init.sq:

Code:
_aispawn = [[6891.6777,394.36661,0],100,6,6] execVM "units\add_unit_server.sqf";//Devils Castle

and I'm seeing this in my report file:

Code:
 2:05:21 "AIUNIT: Creating BAF_Soldier_L_DDPM by <NULL-object> at [6895.68,398.367,0]. Result:R 1-1-G:4 | Loadout:["M4A1_AIM_SD_camo","30Rnd_556x45_StanagSD","30Rnd_556x45_StanagSD","30Rnd_556x45_StanagSD"] / Num:1"

But I can't find the AI's anywhere.. I'm even spawning myself to the exact world space lol..
Sometimes if the unit is banned, they just won't appear, even if they are created. Which map are you on?
 
Just wondering if anyone knows how to make these AI less stupid. I've got 4 of these guys at my base at Devils Castle. They start off fine, but then reach a corner of the castle and just keep repeating the same movements, prone, kneel, stand , repeat.. etc.. I also set them to careless earlier, but they just stand there doing nothing.?? LOL
 
Just wondering if anyone knows how to make these AI less stupid. I've got 4 of these guys at my base at Devils Castle. They start off fine, but then reach a corner of the castle and just keep repeating the same movements, prone, kneel, stand , repeat.. etc.. I also set them to careless earlier, but they just stand there doing nothing.?? LOL
It has something to do with how they move between waypoints. I haven't looked but i'm sure there is a "sleep" somewhere in the code between waypoints, and when they get to that point they just stand around like tards doing the same movements until its time to move to the next waypoint.
 
that is my spawn points
PHP:
    _aispawn = [[11900,9100,0],100,5,2,0] execVM "troops\add_unit_server.sqf";//Berezino center
    _aispawn = [[12200,9500,0],100,5,2,1] execVM "troops\add_unit_server.sqf";//Berezino nord
    _aispawn = [[10500,2300,0],100,5,2,0] execVM "troops\add_unit_server.sqf";//Electrozavodsk east
    _aispawn = [[10000,1900,0],100,5,2,0] execVM "troops\add_unit_server.sqf";//Electrozavodsk west
    _aispawn = [[6700,2700,0],100,5,2,0] execVM "troops\add_unit_server.sqf";//Chernogorsk east
    _aispawn = [[6400,2400,0],100,5,2,0] execVM "troops\add_unit_server.sqf";//Chernogorsk west
    _aispawn = [[2700,5300,0],200,6,2,0] execVM "troops\add_unit_server.sqf";//Zelenogorsk center
    _aispawn = [[6100,7700,0],300,8,2,0] execVM "troops\add_unit_server.sqf";//Stary Sobor center
    _aispawn = [[6800,11400,0],400,10,2,0] execVM "troops\add_unit_server.sqf";//Evil Castle center
    _aispawn = [[11000,12300,0],300,10,2,0] execVM "troops\add_unit_server.sqf";//Krasnostav center sity
    _aispawn = [[12000,12600,0],400,10,2,0] execVM "troops\add_unit_server.sqf";//Krasnostar center aero
    _aispawn = [[4900,9500,0],300,10,5,1] execVM "troops\add_unit_server.sqf";//NW Aero south baracs
    _aispawn = [[4700,10500,0],300,10,5,1] execVM "troops\add_unit_server.sqf";//NW Aero center baracs
 
The weapons are chosen at random, for each unit, from three options, if you look at lines #21-#23
Code:
 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"]};
    };
You can change the weapon and the ammo in there. If you want to give them more ammo (grenades for example) just add another addMagazine line further down (with the rest)
Code:
_aiunit addMagazine "<magazine class name in here>";

Unit Skill: Currently the units' skill is set to 1 for everything, these should probably be edited, try these
Code:
 _aiunit setSkill ["aimingAccuracy",1];
    _aiunit setSkill ["aimingShake",0.9];
    _aiunit setSkill ["aimingSpeed",1];
    _aiunit setSkill ["endurance",1];
    _aiunit setSkill ["spotDistance",0.6];
    _aiunit setSkill ["spotTime",0.8];
    _aiunit setSkill ["courage",0.9];
    _aiunit setSkill ["reloadSpeed",1];
    _aiunit setSkill ["commanding",1];
    _aiunit setSkill ["general",1];
and experiment. Also the setBehaviour will be important, have been considering setting that to CARELESS info combatModes and setBehaviour

Friend or Foe: As kain6699 has found you can get the units to shoot at survivors by changing the setFriend values in the Dayz_Factions\init.sqf. Any value below 0.6 will be an enemy so you could probably make it that and they won't pursue your survivors as much as the zeds, again worth experimenting with: setFriend

As for getting them to re-spawn after death I would think that some form of eventhandler will need attaching to the unit that triggers a new .sqf when he dies. Could carry all the info across so a clone of the unit was respawned. Will have a look into it later.


For some reason, my dudes are occasionally opening up on zeds that are a good distance away, but if I train a bunch of zeds through a group of them, they completely ignore them (and the zeds ignore the soldiers).
 
For some reason, my dudes are occasionally opening up on zeds that are a good distance away, but if I train a bunch of zeds through a group of them, hey completely ignore them (and the zeds ignore the soldiers).
That's a problem currently with the non-DayZ_Factions AI. They base their targets on their targets target. Which makes no sense, but it's how it works. If the zombie isn't targeting you then its an enemy, but if it's targeting you, then its a WEST. Your only hope is to keep going in circles, and when the zombie tries to reacquire target, that the AI looks at them again and then attacks. It's weird.
 
hmmm weird if i use axemans code the ai spawns in fine but if I use iport3s code I get the :
"AIUNIT: Creating BAF_Soldier_L_DDPM by <NULL-object> at [6895.68,398.367,0]. Result:R 1-1-G:4 | Loadout:["M4A1_AIM_SD_camo","30Rnd_556x45_StanagSD","30Rnd_556x45_StanagSD","30Rnd_556x45_StanagSD"] / Num:1"
lines everyone else seems to be getting.
 
Look at this code spawn. It has one additional parameter
0 - for the urban bots with ordinary weapons
1 - for the military bots with hi weapons
PHP:
    _aispawn = [[11900,9100,0],100,5,2,0] execVM "troops\add_unit_server.sqf";//Berezino center
    _aispawn = [[12200,9500,0],100,5,2,0] execVM "troops\add_unit_server.sqf";//Berezino nord
    _aispawn = [[10500,2300,0],100,5,2,0] execVM "troops\add_unit_server.sqf";//Electrozavodsk east
    _aispawn = [[10000,1900,0],100,5,2,0] execVM "troops\add_unit_server.sqf";//Electrozavodsk west
    _aispawn = [[6700,2700,0],100,5,2,0] execVM "troops\add_unit_server.sqf";//Chernogorsk east
    _aispawn = [[6400,2400,0],100,5,2,0] execVM "troops\add_unit_server.sqf";//Chernogorsk west
    _aispawn = [[2700,5300,0],200,6,2,0] execVM "troops\add_unit_server.sqf";//Zelenogorsk center
    _aispawn = [[6100,7700,0],300,8,2,0] execVM "troops\add_unit_server.sqf";//Stary Sobor center
    _aispawn = [[6800,11400,0],400,10,2,0] execVM "troops\add_unit_server.sqf";//Evil Castle center
    _aispawn = [[11000,12300,0],300,10,2,0] execVM "troops\add_unit_server.sqf";//Krasnostav center sity
    _aispawn = [[12000,12600,0],400,10,2,0] execVM "troops\add_unit_server.sqf";//Krasnostar center aero
    _aispawn = [[4900,9500,0],300,10,5,1] execVM "troops\add_unit_server.sqf";//NW Aero south baracs
    _aispawn = [[4700,10500,0],300,10,5,1] execVM "troops\add_unit_server.sqf";//NW Aero center baracs
example - _aispawn = [[11000,12300,0],300,10,2,0] execVM "troops\add_unit_server.sqf";//Berezino center
In spawn code this parameter called - _levelnum
PHP:
    private["_aiunit","_xpos","_ypos","_unitpos","_aiGroup","_wppos","_wpradius","_wpnum","_levelnum","_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;
    _levelnum = _this select 4;
 
    _xpos = _aispawnpos select 0;
    _ypos = _aispawnpos select 1;
 
    diag_log format ["AIUNIT: Spawn initiated: Centre:%1 | Radius in m:%2 | Waypoint number:%3 | WeaponLevel:%4",_aispawnpos,_wpradius,_wpnum,_levelnum];
 
    for [{ x=1 },{ x < _numunits+1 },{ x = x + 1; }] do
    {
        _unitpos = [_xpos+x,_ypos+x,0];
 
        if (_levelnum==0) then // in_sities troops
        {
            if ((x == 1) || (x == 3) || (x == 5)) then //troops soldiers
            {
                "BAF_Soldier_L_DDPM" createUnit [_unitpos, _aiGroup, "_aiunit=this;",1,"PRIVATE"];
                _rndLOut=floor(random 4);
                _ailoadout=
                switch (_rndLOut) do
                {
                  case 0: {["M1014","8Rnd_B_Beneli_74Slug","revolver_EP1","6Rnd_45ACP"]};
                  case 1: {["M1014","8Rnd_B_Beneli_Pellets","revolver_EP1","6Rnd_45ACP"]};
                  case 2: {["Remington870_lamp","8Rnd_B_Beneli_74Slug","Colt1911","7Rnd_45ACP_1911"]};
                  case 3: {["Remington870_lamp","8Rnd_B_Beneli_Pellets","Colt1911","7Rnd_45ACP_1911"]};
                };
            };
            if ((x == 2) || (x == 4) || (x >= 6)) then //troops snipers
            {
                "BAF_Soldier_Sniper_MTP" createUnit [_unitpos, _aiGroup, "_aiunit=this;",1,"PRIVATE"];
                _rndLOut=floor(random 1);
                _ailoadout=
                switch (_rndLOut) do
                {
                  case 0: {["LeeEnfield","10x_303","Makarov","8Rnd_9x18_Makarov"]};
                };
            };
        };
        if (_levelnum==1) then //in_military troops
        {
            if (x == 1) then //one troops comander
            {
                "BAF_Soldier_Officer_DDPM" createUnit [_unitpos, _aiGroup, "_aiunit=this;",1,"LIEUTENANT"];
                _rndLOut=floor(random 7);
                _ailoadout=
                switch (_rndLOut) do
                {
                  case 0: {["AK_47_M","30Rnd_762x39_AK47","UZI_SD_EP1","15Rnd_9x19_M9SD"]};
                  case 1: {["AK_47_S","30Rnd_762x39_AK47","M9SD","15Rnd_9x19_M9SD"]};
                  case 2: {["Sa58P_EP1","30Rnd_762x39_SA58","UZI_SD_EP1","15Rnd_9x19_M9SD"]};
                  case 3: {["Sa58V_CCO_EP1","30Rnd_762x39_SA58","M9SD","15Rnd_9x19_M9SD"]};
                  case 4: {["Sa58V_EP1","30Rnd_762x39_SA58","UZI_SD_EP1","15Rnd_9x19_M9SD"]};
                  case 5: {["FN_FAL","20Rnd_762x51_FNFAL","M9SD","15Rnd_9x19_M9SD"]};
                  case 6: {["FN_FAL_ANPVS4","20Rnd_762x51_FNFAL","UZI_SD_EP1","15Rnd_9x19_M9SD"]};
                };
            };
            if ((x == 2) || (x == 3)) then //troops sergeant
            {
                "BAF_Soldier_L_DDPM" createUnit [_unitpos, _aiGroup, "_aiunit=this;",1,"SERGEANT"];
                _rndLOut=floor(random 3);
                _ailoadout=
                switch (_rndLOut) do
                {
                  case 0: {["M240","100Rnd_762x51_M240","glock17_EP1","17Rnd_9x19_glock17"]};
                  case 1: {["Mk_48","100Rnd_762x51_M240","Colt1911","7Rnd_45ACP_1911"]};
                  case 2: {["M249_EP1","100Rnd_556x45_M249","M9","15Rnd_9x19_M9"]};
                };
            };
            if (x > 3) then //troops soldiers
            {
                "BAF_Soldier_Sniper_MTP" createUnit [_unitpos, _aiGroup, "_aiunit=this;",1,"CORPORAL"];
       
                _rndLOut=floor(random 4);
                _ailoadout=
                switch (_rndLOut) do
                {
                  case 0: {["SVD_NSPU_EP1","10Rnd_762x54_SVD","Sa61_EP1","20Rnd_B_765x17_Ball"]};
                  case 1: {["M24","5Rnd_762x51_M24","Sa61_EP1","20Rnd_B_765x17_Ball"]};
                  case 2: {["DMR","20Rnd_762x51_DMR","Sa61_EP1","20Rnd_B_765x17_Ball"]};
                  case 3: {["M40A3","5Rnd_762x51_M24","Sa61_EP1","20Rnd_B_765x17_Ball"]};
                };
            };
        };
        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
        _aiwep1 = _ailoadout select 0;
        _aiammo1 = _ailoadout select 1;
        _aiwep2 = _ailoadout select 2;
        _aiammo2 = _ailoadout select 3;
        _aiunit addweapon _aiwep1;
        _aiunit addMagazine _aiammo1;
        _aiunit addMagazine _aiammo1;
        _aiunit addMagazine _aiammo1;
        _aiunit addweapon _aiwep2;
        _aiunit addMagazine _aiammo2;
        _aiunit addMagazine _aiammo2;
 
        if (x == 1) then {
        _aiunit addMagazine "SmokeShellGreen";
        _aiunit addMagazine "HandGrenade_West";
        _aiunit addMagazine "FoodCanBakedBeans";
        _aiunit addMagazine "ItemSodaCoke";
        _aiunit addMagazine "ItemPainkiller";
        _aiunit addMagazine "ItemHeatPack";
        _aiunit addMagazine "ItemEpinephrine";
        _aiunit addMagazine "ItemMorphine";
        };
        if (x == 2) then {
        _aiunit addMagazine "ItemHeatPack";
        _aiunit addMagazine "ItemPainkiller";
        _aiunit addMagazine "ItemEpinephrine";
        _aiunit addMagazine "ItemMorphine";
        };
        if (x >= 3) then {
        _aiunit addMagazine "ItemHeatPack";
        _aiunit addMagazine "ItemBandage";
        };
 
        //set skills
        _aiunit setSkill ["aimingAccuracy",1];
        _aiunit setSkill ["aimingShake",0.9];
        _aiunit setSkill ["aimingSpeed",0.9];
        _aiunit setSkill ["endurance",0.9];
        _aiunit setSkill ["spotDistance",0.6];
        _aiunit setSkill ["spotTime",0.9];
        _aiunit setSkill ["courage",0.8];
        _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];
This log look like
12:41:41 "AIUNIT: Spawn initiated: Centre:[2700,5300,0] | Radius in m:200 | Waypoint number:6 | WeaponLevel:0"
12:41:41 "AIUNIT: Creating BAF_Soldier_L_DDPM by <NULL-object> at [2701,5301,0]. Result:R 1-1-C:1 | Loadout:["M1014","8Rnd_B_Beneli_74Slug","revolver_EP1","6Rnd_45ACP"] / Num:0"
12:41:41 "AIUNIT: Creating BAF_Soldier_L_DDPM by <NULL-object> at [2702,5302,0]. Result:R 1-1-C:2 | Loadout:["LeeEnfield","10x_303","Makarov","8Rnd_9x18_Makarov"] / Num:0"
12:41:41 "AIUNIT: Last Waypoint [R 1-1-C,6] at [2800,5400,200]"
12:41:41 "AIUNIT: Last Waypoint [R 1-1-B,5] at [11980,9180,100]"
 
That's a problem currently with the non-DayZ_Factions AI. They base their targets on their targets target. Which makes no sense, but it's how it works. If the zombie isn't targeting you then its an enemy, but if it's targeting you, then its a WEST. Your only hope is to keep going in circles, and when the zombie tries to reacquire target, that the AI looks at them again and then attacks. It's weird.
Yeah, the odd part is that if I make them bandits; hating everybody; they'll just blaze at me when I show up. Still ignoring the zombies though :(
 
Yeah, the odd part is that if I make them bandits; hating everybody; they'll just blaze at me when I show up. Still ignoring the zombies though :(
For that one, it's a matter of priority I found. If I had myself set at 0 then they would attack me first, but when I moved myself to .6 they didn't. You may not have the same results, but this is what I got. It gives the AI a distraction when zombies are around that gives my players an advantage.
 
Back
Top