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

No luck for me so far. Okay.

They are spawning (from your .rpt file)
Code:
16:51:29 "AIUNIT: Spawn initiated: Centre:[10917.6,363.666,0] | Radius in m:180 | Waypoint number:3"
16:51:29 "AIUNIT: Creating BAF_Soldier_L_DDPM by <NULL-object> at [10918.6,364.666,0]. Result:R 1-1-E:1 | Loadout:["Remington870_lamp","8Rnd_B_Beneli_74Slug"] / Num:2"
16:51:29 "AIUNIT: Creating BAF_Soldier_L_DDPM by <NULL-object> at [10919.6,365.666,0]. Result:R 1-1-E:2 | Loadout:["Remington870_lamp","8Rnd_B_Beneli_74Slug"] / Num:2"
16:51:29 "AIUNIT: Creating BAF_Soldier_L_DDPM by <NULL-object> at [10920.6,366.666,0]. Result:R 1-1-E:3 | Loadout:["Remington870_lamp","8Rnd_B_Beneli_74Slug"] / Num:2"
16:51:29 "AIUNIT: Last Waypoint [R 1-1-E,3] at [10957.6,403.666,180]"

Go to one of the worldspace locations and look for them in game. If you spawn at a default spawn point then the worldspace is invalid, try it twice to be sure..

Just thought, are those soldiers allowed on Taviana ?
 
The NPC's spawning without problems, it's just the scrip restriction i get
SR started when they started shooting at me, actually killed me.
 
Right, the BE script error #8 relates (haven't tested) to line #10
Code:
5 addWaypoint !"\"addWaypoint\","
Either change the 5 at the start to a 1, so it logs or change it to this
Code:
5 addWaypoint !"\"addWaypoint\"," !"units\add_unit_server.sqf"
That should fix it. I think this may be either for custom maps or dayz.st, not having this problem on my server.

EDIT: There's more, if you are getting the above SR then you will also get #114 addWeapon and #118 addMagazine.

In which case, add:
Code:
 !"units\add_unit_server.sqf"
to the end of both lines or change the 5 (at the start of the line) to a 1 (one)
 
Any way to change the BAF soldiers to bandit skins?

Applied the updates and Joined the Server...I get a something went wrong message when I copy and paste everything...
 
So i've got them spawning where I want, and they are using the right guns, and aren't attacking survivors (as intended), but the problem is that they still aren't attacking zeds.
 
If you get this working for me like you did the streetlights, i'm pretty much obligated to donate to you axeman, you've been awesome today.
 
So i've got them spawning where I want, and they are using the right guns, and aren't attacking survivors (as intended), but the problem is that they still aren't attacking zeds.

Code:
waitUntil{initialized};
//0Day
createCenter east;
createCenter resistance;
//Survivors
WEST setFriend [RESISTANCE,1];
WEST setFriend [EAST,0];
//Bandits
EAST setFriend [RESISTANCE,0];
EAST setFriend [WEST,0];
//AI Units
RESISTANCE setFriend [WEST,1];
RESISTANCE setFriend [EAST,0];
RESISTANCE setFriend [CIVILIAN,0];//AI Units attack zeds
 
//CIVILIAN setFriend [RESISTANCE,0];//Testing Zeds attack AI units, doesn't seem to help..

I'm just using the standard init

Code:
if (isServer) then {
    _dayzFactions = [] execVM "scripts\set_unit_faction.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 = [[5063.1245, 5141.3208, 0],300,10,20] execVM "scripts\add_unit_server.sqf";//Camp De Dunes
};

This is the code in my mission init.. Those directories are the correct directories (i put everything in a scripts folder for simplicity.)

The spawns dont appear to be patrolling either. Just sitting there.
 
So they started patrolling after a little while. They never started attacking zeds. After I killed 3 of them, they finally started attacking me.

I changed them to attack survivors and it worked. They still aren't attacking zeds though. lol
 
This is really just a hackfix that happens to work - you'll need to add a line to your init.sqf:

Code:
zombie_generate = compile preprocessFileLineNumbers "scripts\compile\zombie_generate.sqf";

In the directory quoted above, insert an extracted copy of your zombie_generate.sqf from dayz.pbo and insert this line at the bottom of the sqf file:

Code:
{ _x addRating -20000; } forEach allMissionObjects "zZombie_Base";

This will cause all AI to become hostile to zombies as they spawn. Note that this means that the AI will continuously engage zombies on sight, so you'll end up with piles of dead corpses lying around and possibly continuous gunfire if there are enough zombies being spawned.
Used this fix from a different thread and it worked in combination with what you posted.
 
The bandits section is from Factions, I don't think it has any effect on this script, didn't want to take it out, just in case.

The only way to get bandits in on that would be with Factions or Wastelandz, all in development I believe..

The AI do attack zeds with this script if you install it correctly, tho tested on very latest Reality build.

I am wondering about the order that I run the script in, am thinking of swapping the unit creation with the waypoint creation and testing. This is related to them picking up their waypoints, IE. not just standing there.

Have been trying to get a pair of AI units to drive around the map and this came up. Am learning this and posting it for all to see, hack away and post your improvements back ;)
 
Hey, ive been testing this for as bit now with different settings, and i have found they for some reason go all out on wrecks nearby, they will kill the odd zombie as you said but i cant seem to get the zombie to attack them the squad moves around alot as zombies kinda just doddle in between them, but then they started shooting at zombies at a crash site about 100-200m away, making me think as you mentioned it was the spotDistance but testing a few setting so far and no change everytime i log in, they all seem just fire like maniacs at the start at the burnt out wrecks in the fields and then start their patrolling.

i messed around with a bunch of different settings in the setfriend aswell i still cant seem to get zombies to attack them, i dont know if its to due with what skin is being used, as i think my problem once i had a TK_CIV_Takistani05_EP1 i think it was, but was msot likely clasifying it as CIVILIAN, but not sure. right now its a CZ_Soldier1_EP1 i think atm and still the same deal.

None the less, excellent work Axeman and Xyberviri for putting this together!
 
If you set a trigger with a sleep timer it should spawn new NPC's, yes? I'm totally new at this so if someone could check my syntax and whatnot I'd appreciate it. Also, this is for Namalsk, hence the land bridge / coords.

Code:
   class Sensors
{
items=3;
class Item0
{
position[]={6486.6685,5.200983,8547.5273};
a=500;
b=900;
angle=125;
activationBy="WEST";
repeating=1;
timeoutMin=1;
timeoutMid=2;
timeoutMax=3;
interruptable=1;
age="UNKNOWN";
expActiv="hint ""Hostile forces have taken the land bridge!""; _aispawn = [[6486.6685,8547.5273,0],120,8,6] execVM ""units\add_unit_server.sqf""; sleep 7200;";
class Effects
{
};
};

Edit to add:

When adding more weapons to the random AI loadout, do you need to change
Code:
_rndLOut=floor(random 3);

to reflect the number of cases?

Edit again to add:

How would I change the skin for each group of NPC's?

Another edit:

I got the trigger working, but it lags the server out and keeps spawning AI. Anyone have an example waitUntil script that will run on player detected in area then sleep for an hour?
 
@axeman

Do you think there's any gain to adding this to the server pbo?
I won't answer for axeman, but I added this to Oring yesterday, and had AI take control of the middle island, and added a few small perks to controlling that area (primarily because the AI used elite weapons which you could loot from them), and the people on my server absolutely loved it. There were groups of survivors working together to kill the AI, which is rare from my perspective to see survivors openly working together. My note would be that you need to change their attributes based on the area, because initially I had some sniper AI that were lighting people up from 500 yards in 1 shot.

Code:
    //set skills
    _aiunit setSkill ["aimingAccuracy",.7];
    _aiunit setSkill ["aimingShake",0.9];
    _aiunit setSkill ["aimingSpeed",.6];
    _aiunit setSkill ["endurance",1];
    _aiunit setSkill ["spotDistance",0.6];
    _aiunit setSkill ["spotTime",0.6];
    _aiunit setSkill ["courage",1];
    _aiunit setSkill ["reloadSpeed",1];
    _aiunit setSkill ["commanding",1];
    _aiunit setSkill ["general",1];

We finished with this, which ended up being just right for a group of 4 to take them out. I spawn 35 troops over 7 locations inside of an semi-small area (roughly the size of a small town) and it took 4 of us with snipers from a vantage point about 15 minutes to kill them all, and they still killed 2 of us.
 
[quote="Sycosis, post: 21279, member: 2843] "My note would be that you need to change their attributes based on the area, because initially I had some sniper AI that were lighting people up from 500 yards in 1 shot.[/quote]

Lol yea I've got two islands (a airports and a naval port) I wanted only controlled by ai and no Zeds. So the survivors would go there to get good guns but it would be a bigger risk in doing so.
So you added this to the server pbo file or the mission file?
Cause I added it to my dayz server pbo and it does work although you have to change the file paths. I was just wondering if it makes a difference.m

Edit-lol I messed up the reply box
 
My note would be that you need to change their attributes based on the area, because initially I had some sniper AI that were lighting people up from 500 yards in 1 shot.

Lol yea I've got two islands (a airports and a naval port) I wanted only controlled by ai and no Zeds. So the survivors would go there to get good guns but it would be a bigger risk in doing so.
So you added this to the server pbo file or the mission file?
Cause I added it to my dayz server pbo and it does work although you have to change the file paths. I was just wondering if it makes a difference.
Mine is all in the mission pbo. I don't really know what the difference would be.
 
This is my little modification. There are two types of armament troops.
init spawn groups
PHP:
    _aispawn = [[6689.49,2623.59,0],500,10,4,0] execVM "troops\add_unit_server.sqf";//Chernogorsk
    _aispawn = [[4598.66,10197.7,0],600,10,6,1] execVM "troops\add_unit_server.sqf";//NW Airfield
    _aispawn = [[10446.5,2246.96,0], 400,10,2,0] execVM "troops \ add_unit_server.sqf" ;// Electrozavodsk_1
    _aispawn = [[10496.5,2296.96,0], 400,10,2,0] execVM "troops \ add_unit_server.sqf" ;// Electrozavodsk_2
add unit code
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_sityes troops
        {
            if ((x == 1) || (x == 3) || (x == 5)) then //troop 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 3);
                _ailoadout=
                switch (_rndLOut) do
                {
                  case 0: {["LeeEnfield","10x_303","Makarov","8Rnd_9x18_Makarov"]};
                  case 1: {["Huntingrifle","5x_22_LR_17_HMR","Makarov","8Rnd_9x18_Makarov"]};
                  case 2: {["M14_EP1","20Rnd_762x51_DMR","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;
      //add some garbage
        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",0.9];
        _aiunit setSkill ["aimingShake",0.9];
        _aiunit setSkill ["aimingSpeed",0.9];
        _aiunit setSkill ["endurance",0.9];
        _aiunit setSkill ["spotDistance",1];
        _aiunit setSkill ["spotTime",0.9];
        _aiunit setSkill ["courage",0.9];
        _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];
 
Back
Top