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

Why does this not work, they only spawn with primary weapon
Code:
    _rndLOut=floor(random 28);
    _ailoadout=
    switch (_rndLOut) do
    {
      case 0: {["DMR","20Rnd_762x51_DMR"]};
      case 1: {["M24","5Rnd_762x51_M24"]};
      case 2: {["SVD_CAMO","10Rnd_762x54_SVD"]};
      case 3: {["M40A3","5Rnd_762x51_M24"]};
      case 4: {["M249_DZ","200Rnd_556x45_M249"]};
      case 5: {["M240","100Rnd_762x51_M240"]};
      case 6: {["Mk_48_DZ","100Rnd_762x51_M240"]};
      case 7: {["Sa58V_EP1","30Rnd_762x39_SA58"]};
      case 8: {["BAF_L85A2_RIS_Holo","30Rnd_556x45_Stanag"]};
      case 9: {["G36C","30Rnd_556x45_G36"]};
      case 10: {["M4A1_HWS_GL_camo","30Rnd_556x45_Stanag"]};
      case 11: {["M16A4_ACG","30Rnd_556x45_Stanag"]};
      case 12: {["G36A_camo","30Rnd_556x45_G36"]};
      case 13: {["AK_47_M","30Rnd_762x39_AK47"]};
      case 14: {["M16A2","30Rnd_556x45_Stanag"]};
      case 15: {["FN_FAL","20Rnd_762x51_FNFAL"]};
      case 16: {["M4A1","30Rnd_556x45_Stanag"]};
      case 17: {["M4A1_AIM_SD_camo","30Rnd_556x45_StanagSD"]};
      case 18: {["G36K_camo","30Rnd_556x45_G36"]};
      case 19: {["AK_47_S","30Rnd_762x39_AK47"]};
      case 20: {["VSS_Vintorez","20Rnd_9x39_SP5_VSS"]};
      case 21: {["RPK_74","75Rnd_545x39_RPK"]};
      case 22: {["PK","100Rnd_762x54_PK"]};
      case 23: {["SVD","10Rnd_762x54_SVD"]};
      case 24: {["AK_107_Kobra","30Rnd_545x39_AK"]};
      case 25: {["ksvk","5Rnd_127x108_KSVK"]};
      case 26: {["BAF_LRR_scoped_W","5Rnd_86x70_L115A1"]};
      case 27: {["M4SPR","30Rnd_556x45_Stanag"]};
     
      default {["ItemMap"]};
    };
 
    //Generate what the sidearm and ammo will be
    _rndLOut=floor(random 3);
    _aiside=
    switch (_rndLOut) do
    {
      case 0: {["UZI_EP1","15Rnd_9x19_M9"]};
      case 1: {["MakarovSD","8Rnd_9x18_MakarovSD"]};
      case 2: {["UZI_SD_EP1","30Rnd_9x19_UZI_SD"]};
    };
 
    //Generate what the equipment will be - it's likely to be antibiotics, but maybe.... :)
    _rndLOut=floor(random 17);
    _aiequipspawn=
    switch (_rndLOut) do
    {
      case 0: {["Binocular_Vector"]};
      case 1: {["ItemGPS"]};
      case 2: {["NVGoggles"]};
      case 3: {["Binocular"]};
    };
You are using _rndLOut over and over, in that code you are not assigning anything before doing the next random.. The last one is a random of 17 with 4 options ?
 
Could someone take a look at my file and see what i have done incorrectly I would greatly appreciate it. I have been trying for 3 days now
 

Attachments

  • dayz_1.Chernarus.pbo
    61.7 KB · Views: 9
Could someone take a look at my file and see what i have done incorrectly I would greatly appreciate it. I have been trying for 3 days now
Better off giving us some info. and errors from your .rpt file. Is difficult to recreate the exact scenario that you are running that .pbo under..
 
here is a copy of my .rpt
and thank you for taking the time to help a fellow survivor
 

Attachments

  • arma server rpt.txt
    182.8 KB · Views: 5
Hi axe,

just wanting to share:

the loadout for sidearms will lead to issues. There's a known bug in the Arma AI, that IF they switch to sidearms while fighting a player (e.g. player gets very close), all AI behaviour gets stuck. They will neither shoot nor move.

No fix for that available, just fyi if ppl complain about unresponsive AI.

cheers, Sarge
 
here is a copy of my .rpt
You did not declare a variable "_ailoadout" in add_unit_server.sqf
And yet, you need to make more use of debug messages.
IF they switch to sidearms while fighting a player (e.g. player gets very close), all AI behaviour gets stuck.
You can use "_aiunit selectWeapon "Winchester1866""
then they will not change during the fight. More useful if the weapon is not taken in hand at the loaded bots.

Sorry for interfering with the topic.
 
They work)
"TK_INS_Soldier_EP1"
"GUE_Soldier_Medic"
"CZ_Soldier_medik_DES_EP1"
"GER_Soldier_Medic_EP1"
"US_Soldier_Medic_EP1"
"Ins_Soldier_Pilot"
"US_Pilot_Light_EP1"
"CZ_Soldier_DES_EP1"
"US_Soldier_EP1"
"BAF_Soldier_MTP"
"BAF_Soldier_Officer_DDPM"
"BAF_Soldier_Officer_MTP"
"BAF_Soldier_L_DDPM"
"BAF_Soldier_L_MTP"
"CZ_Soldier_Light_DES_EP1"
"CDF_Soldier_Light"
"CDF_Commander"
"RU_Commander"
"Ins_Soldier_Base"
 
Axeman or anybody, i have this problem that only on ai spawns with no gear? and start humping the ground. Also is their no way of making their spot distance longer? here isa par of my add_unit_server.sqf
Code:
private["_aiunit","_xpos","_ypos","_unitpos","_aiGroup","_wppos","_wpradius","_wpnum","_numunits","_rndLOut","_ailoadout","_aiwep","_aiammo","_wp","_aispawnpos"];
    private["_aiunit","_xpos","_ypos","_unitpos","_aiGroup","_wppos","_wpradius","_wpnum","_numunits","_rndLOut","_ailoadout","_aiwep","_aiammo","_wp","_aispawnpos"];
    _aiunit = objNull;
    _aiGroup = createGroup EAST;  // <----THIS MAKES THEM HATE PLAYERS!
    _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];
 
 
    //Generate what the main weapon and ammo will be
    _rndLOut=floor(random 27);
    _ailoadout=
    switch (_rndLOut) do
    {
      case 0: {["DMR","20Rnd_762x51_DMR"]};
      case 1: {["M24","5Rnd_762x51_M24"]};
      case 2: {["SVD_CAMO","10Rnd_762x54_SVD"]};
      case 3: {["M40A3","5Rnd_762x51_M24"]};
      case 4: {["M249_DZ","200Rnd_556x45_M249"]};
      case 5: {["M240","100Rnd_762x51_M240"]};
      case 6: {["Mk_48_DZ","100Rnd_762x51_M240"]};
      case 7: {["Sa58V_EP1","30Rnd_762x39_SA58"]};
      case 8: {["BAF_L85A2_RIS_Holo","30Rnd_556x45_Stanag"]};
      case 9: {["G36C","30Rnd_556x45_G36"]};
      case 10: {["M4A1_HWS_GL_camo","30Rnd_556x45_Stanag"]};
      case 11: {["M16A4_ACG","30Rnd_556x45_Stanag"]};
      case 12: {["G36A_camo","30Rnd_556x45_G36"]};
      case 13: {["AK_47_M","30Rnd_762x39_AK47"]};
      case 14: {["M16A2","30Rnd_556x45_Stanag"]};
      case 15: {["FN_FAL","20Rnd_762x51_FNFAL"]};
      case 16: {["M4A1","30Rnd_556x45_Stanag"]};
      case 17: {["M4A1_AIM_SD_camo","30Rnd_556x45_StanagSD"]};
      case 18: {["G36K_camo","30Rnd_556x45_G36"]};
      case 19: {["AK_47_S","30Rnd_762x39_AK47"]};
      case 20: {["VSS_Vintorez","20Rnd_9x39_SP5_VSS"]};
      case 21: {["RPK_74","75Rnd_545x39_RPK"]};
      case 22: {["PK","100Rnd_762x54_PK"]};
      case 23: {["SVD","10Rnd_762x54_SVD"]};
      case 24: {["AK_107_Kobra","30Rnd_545x39_AK"]};
      case 25: {["ksvk","5Rnd_127x108_KSVK"]};
      case 26: {["M4SPR","30Rnd_556x45_Stanag"]};
 
      default {["ItemMap"]};
    };
 
    //Generate what the sidearm and ammo will be
    _rndLOut=floor(random 3);
    _aiside=
    switch (_rndLOut) do
    {
      case 0: {["UZI_EP1","30Rnd_9x19_UZI"]};
      case 1: {["MakarovSD","8Rnd_9x18_MakarovSD"]};
      case 2: {["UZI_SD_EP1","30Rnd_9x19_UZI_SD"]};
    };
 
    //Generate what the equipment will be - it's likely to be antibiotics, but maybe.... :)
    _rndLOut=floor(random 30);
    _aiequipspawn=
    switch (_rndLOut) do
    {
 
      case 0: {["Binocular_Vector"]};
      case 1: {["ItemGPS"]};
      case 2: {["ItemCompass"]};
      case 3: {["NVGoggles"]};
      case 4: {["Binocular"]};
 
 
    };
 
 
    "GUE_Soldier_Medic" createUnit [_unitpos, _aiGroup, "_aiunit=this;",0.6,"Private"];
 
    diag_log format ["AIUNIT: Creating GUE_Soldier_Medic 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;
    removeAllItems  _aiunit;
 
    //add random selection
    _aiwep = _ailoadout select 0;  //Main Weapon
    _aiammo = _ailoadout select 1;    // Main Weap Ammo
 
    _aisidearm = _aiside select 0;  //Sidearm
    _aisidearmammo = _aiside select 1;    //Sideaerm Ammo
 
    _aigear = _aiequipspawn select 0;    //Equipment
 
    _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;
 
 
    // Add sidearm and mags
    _aiunit addweapon _aisidearm;
    _aiunit addMagazine _aisidearmammo;
    _aiunit addMagazine _aisidearmammo;
    _aiunit addMagazine _aisidearmammo;
 
    // add gear
    _aiunit addWeapon _aigear;
    //_aiunit addMagazine _aigear;
 
    //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;
    } ;
 
Blender, this bit
Code:
    //Generate what the equipment will be - it's likely to be antibiotics, but maybe.... :)
    _rndLOut=floor(random 30);
    _aiequipspawn=
    switch (_rndLOut) do
    {
 
      case 0: {["Binocular_Vector"]};
      case 1: {["ItemGPS"]};
      case 2: {["ItemCompass"]};
      case 3: {["NVGoggles"]};
      case 4: {["Binocular"]};
 
 
    };
you have a random number out of 30 but only 5 items, don't know why they are humping the ground, lol, probably frustrated at having no gear..
 
Blender, this bit
Code:
    //Generate what the equipment will be - it's likely to be antibiotics, but maybe.... :)
    _rndLOut=floor(random 30);
    _aiequipspawn=
    switch (_rndLOut) do
    {
 
      case 0: {["Binocular_Vector"]};
      case 1: {["ItemGPS"]};
      case 2: {["ItemCompass"]};
      case 3: {["NVGoggles"]};
      case 4: {["Binocular"]};
 
 
    };
you have a random number out of 30 but only 5 items, don't know why they are humping the ground, lol, probably frustrated at having no gear..

Well i thougt i wanted to make that gear abit rare, but i guess you cant. Anyways thanks for the reply
 
Am not entirely sure that will cause problems, I haven't tested it, I would expect at least a Default would be required: http://community.bistudio.com/wiki/switch

The AI 'Humping the Ground', are they swimming ? In which case have the been spawned elsewhere (in water) and moved to their location..

View distance, I don't believe you can get higher than 1 in the AI setSkill, they are pretty hardcore with everything set to 1..
 
Can some one help me please?

I followed the steps in Sycosis's tutorial for the AI, but I can't get them to spawn. I have gone over my files several times and can;'t seem to get it working.

Would you mind taking a look my PBO and see if you can find where I went wrong?

I am on a dayz.st server btw.

Thanks!
 

Attachments

  • dayz_mission.pbo
    64.6 KB · Views: 4
So, I noticed that when I tried to arm my NPCs with multiple pieces of equipment (main weapon, sidearm, and gear), nobody would spawn. I'd like to know if there is a way to get multiple random pieces of gear using this code. I understand I could always give them certain things as default, but I'd really like to know how to set it up to get three random things. Any help would be appreciated.
 
Can some one help me please?

I followed the steps in Sycosis's tutorial for the AI, but I can't get them to spawn. I have gone over my files several times and can;'t seem to get it working.

Would you mind taking a look my PBO and see if you can find where I went wrong?

I am on a dayz.st server btw.

Thanks!
You are missing the units folder with all of the code in it.. The files are in the scripts directory. Have changed the AI spawn entries, in your init.sqf, to this
Code:
    _aispawn = [[6689.49,2623.59,0],160,8,4] execVM "scripts\add_unit_server.sqf";//Chernogorsk
    _aispawn = [[7622.51,7912.7,0],5000,20,6] execVM "scripts\add_unit_server.sqf";//Chernaurs (Whole map)
    _aispawn = [[7625.51,7915.7,0],5000,20,6] execVM "scripts\add_unit_server.sqf";//Chernaurs (Whole map)
    _aispawn = [[4598.66,10197.7,0],650,12,4] execVM "scripts\add_unit_server.sqf";//NW Airfield
    _aispawn = [[10447.5,2246.96,0],180,3,3] execVM "scripts\add_unit_server.sqf";//Electrozavodsk
    _aispawn = [[13253.3,6406.53,0],180,4,3] execVM "scripts\add_unit_server.sqf";//Solnichniy
    _aispawn = [[6143.6167,7721.5176,0],5000,20,6] execVM "scripts\add_unit_server.sqf";//Stary

There are some additions to the add_unit_server.sqf, so have left that as is.
 

Attachments

  • dayz_mission.pbo
    64.6 KB · Views: 22
So, I noticed that when I tried to arm my NPCs with multiple pieces of equipment (main weapon, sidearm, and gear), nobody would spawn. I'd like to know if there is a way to get multiple random pieces of gear using this code. I understand I could always give them certain things as default, but I'd really like to know how to set it up to get three random things. Any help would be appreciated.
There are a few posts dealing with random gear, weapons ammo etc. If nobody is apwaning that is a different issue. The AI are spawned server side so should not effect player spawning unless something is drastically wrong with your init.sqf, Post it up, will have a look..
 
Back
Top