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

This is the bit I'm stuck on.. I don't understand how it works.. What do I change to spawn both bandits and survivors and how do I ensure only bandits spawn at NWA and survivors at Cherno for example? Sorry for the dumb question, it's just at the moment I'm not sure whether its spawning all bandits or a mixture, I mean is it just random?

Oh and when you've got the bus script working, I'll gladly make a small donation if you share it ;)

I have good guys and bad guys - with TK skins and BAF skins (and different weapons and skill levels). They all shoot zombies. This is how I hacked it together (and it can be imporoved, but I was trying to just go for basic function testing).

Add this line to your init.sqf under factions:


Code:
waitUntil{initialized};
//0Day 
createCenter east;
createCenter resistance;
 
//Survivors
WEST setFriend [RESISTANCE,0];
WEST setFriend [EAST,0];
 
//Bandits
EAST setFriend [RESISTANCE,0];
EAST setFriend [WEST,0];
 
 
//AI Units
RESISTANCE setFriend [WEST,0.6];
RESISTANCE setFriend [EAST,0];
 
RESISTANCE setFriend [CIVILIAN,0];//AI Units attack zeds
 
EAST setFriend [CIVILIAN,0];//AI Units attack zeds // <---- THIS LINE FOR BANDITS TO ATTACK ZEDS
 
CIVILIAN setFriend [RESISTANCE,0];//Zeds attack Hero units
CIVILIAN setFriend [EAST,0];//Zeds attack Bandit units



Then, you can either modify your add_unit_server to accept a bandit/hero parameter to change the center, or just (like I did for testing) duplicate it.

Code:
//add_unit_server_bandit.sqf
    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 8);
    _ailoadout=
    switch (_rndLOut) do
    {
      case 0: {["LeeEnfield","10x_303"]};
      case 1: {["AKS_74U","30Rnd_545x39_AK"]};
      case 2: {["AK_74","30Rnd_545x39_AK"]}; 
      case 3: {["AKS_74_kobra","30Rnd_545x39_AK"]};
      case 4: {["AK_47_M","30Rnd_762x39_AK47"]};
      case 5: {["Winchester1866","15Rnd_W1866_Slug"]};
      case 6: {["MP5A5","30Rnd_9x19_MP5"]};
      case 7: {["huntingrifle","5x_22_LR_17_HMR"]};
    };
 
    //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: {["Makarov","8Rnd_9x18_Makarov"]};
      case 2: {["revolver_EP1","6Rnd_45ACP"]};
    };
 
    //Generate what the equipment will be - it's likely to be antibiotics, but maybe.... :)
    _rndLOut=floor(random 7);
    _aiequipspawn=
    switch (_rndLOut) do
    {
   
      case 0: {["Binocular_Vector"]};
      case 1: {["ItemGPS"]};
      case 2: {["ItemMap"]};
      case 3: {["ItemCompass"]};
      case 4: {["ItemWatch"]};
      case 5: {["NVGoggles"]};
      case 6: {["Binocular"]};
   
 
    };
 
 
    "TK_INS_Soldier_EP1" createUnit [_unitpos, _aiGroup, "_aiunit=this;",0.6,"Private"];
 
    diag_log format ["AIUNIT: Creating TK_INS_Soldier_EP1 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",0.25];
    _aiunit setSkill ["aimingShake",0.25];
    _aiunit setSkill ["aimingSpeed",0.25];
    _aiunit setSkill ["endurance",0.25];
    _aiunit setSkill ["spotDistance",0.24];
    _aiunit setSkill ["spotTime",0.3];
    _aiunit setSkill ["courage",0.3];
    _aiunit setSkill ["reloadSpeed",0.25];
    _aiunit setSkill ["commanding",0.25];
    _aiunit setSkill ["general",0.25];
    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];


Now, call them from your chernarus mission init.sqf the same way, and choose if you want to spawn a bandit or soldier.
Code:
_aispawn = [[4780.92,2500.74,0.001],20,1,5] execVM "units\add_unit_server.sqf";//Balota
_aispawn = [[4703.12,2525.5,0.001],20,1,5] execVM "units\add_unit_server_Bandit.sqf";//Balota

I still need to change the equipment loadout - those items are addWeapons, but I think medical supplies and blood bags are addMagazine. I was fucking around with them until like 5AM.

Also, the select case is no good; I want to have like a ran(100) and have it select a map if the output is > 10, select compass if > 25... all the way up to NVGs/GPS/Rangefinders if like > 95 - just to make sure that they're still kind of rare. Haven't figured out how to do that in this scripting language yet :) Now that I've slept a few hours though....
 
When I was self hosting, I had an MPmissions folder full of pbo's. Inside the init.sqf (in my servers root folder) there was a line that look liked this "dayz_instance=48" , it was that number that corresponded to the pbo being used, so in this case it was dayz_48.Chernarus . I don't know if this will help, but I had similar issues and realising that my instance ID was always wrong, helped me out :)

Yep, Mine is just the folder for now, it doesn't seem to like the folder so I think I'm going to pack it into a .pbo and point it to it.

Right now it is just hanging on Host Identity Created, and won't continue....
 
That's a brilliant solution, actually works for me. Thanks for the code :)

I have good guys and bad guys - with TK skins and BAF skins (and different weapons and skill levels). They all shoot zombies. This is how I hacked it together (and it can be imporoved, but I was trying to just go for basic function testing).

Add this line to your init.sqf under factions:


Code:
waitUntil{initialized};
//0Day
createCenter east;
createCenter resistance;
 
//Survivors
WEST setFriend [RESISTANCE,0];
WEST setFriend [EAST,0];
 
//Bandits
EAST setFriend [RESISTANCE,0];
EAST setFriend [WEST,0];
 
 
//AI Units
RESISTANCE setFriend [WEST,0.6];
RESISTANCE setFriend [EAST,0];
 
RESISTANCE setFriend [CIVILIAN,0];//AI Units attack zeds
 
EAST setFriend [CIVILIAN,0];//AI Units attack zeds // <---- THIS LINE FOR BANDITS TO ATTACK ZEDS
 
CIVILIAN setFriend [RESISTANCE,0];//Zeds attack Hero units
CIVILIAN setFriend [EAST,0];//Zeds attack Bandit units



Then, you can either modify your add_unit_server to accept a bandit/hero parameter to change the center, or just (like I did for testing) duplicate it.

Code:
//add_unit_server_bandit.sqf
    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 8);
    _ailoadout=
    switch (_rndLOut) do
    {
      case 0: {["LeeEnfield","10x_303"]};
      case 1: {["AKS_74U","30Rnd_545x39_AK"]};
      case 2: {["AK_74","30Rnd_545x39_AK"]};
      case 3: {["AKS_74_kobra","30Rnd_545x39_AK"]};
      case 4: {["AK_47_M","30Rnd_762x39_AK47"]};
      case 5: {["Winchester1866","15Rnd_W1866_Slug"]};
      case 6: {["MP5A5","30Rnd_9x19_MP5"]};
      case 7: {["huntingrifle","5x_22_LR_17_HMR"]};
    };
 
    //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: {["Makarov","8Rnd_9x18_Makarov"]};
      case 2: {["revolver_EP1","6Rnd_45ACP"]};
    };
 
    //Generate what the equipment will be - it's likely to be antibiotics, but maybe.... :)
    _rndLOut=floor(random 7);
    _aiequipspawn=
    switch (_rndLOut) do
    {
 
      case 0: {["Binocular_Vector"]};
      case 1: {["ItemGPS"]};
      case 2: {["ItemMap"]};
      case 3: {["ItemCompass"]};
      case 4: {["ItemWatch"]};
      case 5: {["NVGoggles"]};
      case 6: {["Binocular"]};
 
 
    };
 
 
    "TK_INS_Soldier_EP1" createUnit [_unitpos, _aiGroup, "_aiunit=this;",0.6,"Private"];
 
    diag_log format ["AIUNIT: Creating TK_INS_Soldier_EP1 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",0.25];
    _aiunit setSkill ["aimingShake",0.25];
    _aiunit setSkill ["aimingSpeed",0.25];
    _aiunit setSkill ["endurance",0.25];
    _aiunit setSkill ["spotDistance",0.24];
    _aiunit setSkill ["spotTime",0.3];
    _aiunit setSkill ["courage",0.3];
    _aiunit setSkill ["reloadSpeed",0.25];
    _aiunit setSkill ["commanding",0.25];
    _aiunit setSkill ["general",0.25];
    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];


Now, call them from your chernarus mission init.sqf the same way, and choose if you want to spawn a bandit or soldier.
Code:
_aispawn = [[4780.92,2500.74,0.001],20,1,5] execVM "units\add_unit_server.sqf";//Balota
_aispawn = [[4703.12,2525.5,0.001],20,1,5] execVM "units\add_unit_server_Bandit.sqf";//Balota

I still need to change the equipment loadout - those items are addWeapons, but I think medical supplies and blood bags are addMagazine. I was fucking around with them until like 5AM.

Also, the select case is no good; I want to have like a ran(100) and have it select a map if the output is > 10, select compass if > 25... all the way up to NVGs/GPS/Rangefinders if like > 95 - just to make sure that they're still kind of rare. Haven't figured out how to do that in this scripting language yet :) Now that I've slept a few hours though....
 
Hmm, so I got it all running now, problem is my crew gets the,
Something went wrong please try again, they can hear sound but then it kicks them, nothing seem out of the ordinary on the rpt file :/
 
Hmm, so I got it all running now, problem is my crew gets the,
Something went wrong please try again, they can hear sound but then it kicks them, nothing seem out of the ordinary on the rpt file :/
You can look at the guide I did for an example of how to do dual AIs. I'm currently trying to change it so that bandits take over the additional AI, but for now AI has control of east and resistance on mine. It's just a modified version of axemans code. Almost exactly axemans code for the most part, ive been learning from him
 
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]"

I like this a lot - I'm going to incorporate it.
 
You can look at the guide I did for an example of how to do dual AIs. I'm currently trying to change it so that bandits take over the additional AI, but for now AI has control of east and resistance on mine. It's just a modified version of axemans code. Almost exactly axemans code for the most part, ive been learning from him

Was this meant for me? I'm not doing Dual AIs, lol I just want to get one AI running lol. I'm currently running Iport3s stuff and axemans. I've got the @dayz_factions added into my Arma II OA folder because I figured that was the issue. But it's not...I'm wondering if it has to do with the fact that I'm running a DayZ+ server :/

I'm now thinking the reason this isn't working is because I'm running a DayZ+ server and not just DayZ
 
Was this meant for me? I'm not doing Dual AIs, lol I just want to get one AI running lol. I'm currently running Iport3s stuff and axemans. I've got the @dayz_factions added into my Arma II OA folder because I figured that was the issue. But it's not...I'm wondering if it has to do with the fact that I'm running a DayZ+ server :/

I'm now thinking the reason this isn't working is because I'm running a DayZ+ server and not just DayZ
It was meant for the guy asking about running 2 AI's.. I had no lick with iports stuff. I ended up just modifying axemans with his help. Theres a guide for it if you want to try it. I helped like 5 people use it this morning. Pretty straight forward.

It's just copy and pasted axeman code basically lol.. ButtFace helped me change 1 part that wasn't working with mine.
 
Yea, I think I have figured this out.

Since I'm not running a Dayz.St server, I don't have a .pbo file

I've got a DayZ_1.Chernarus folder, my server finds this folder and runs stuff from it.

So I've added and edited files, my guys can get on now, but it is telling them something went wrong, and disconnects them. I've disabled BE to make sure it wasn't script restrictions.

Still working with it.

Your mission should work fine with just the folder structure, I test it like that all the time (on localhost). I may be wrong, but I would guess that Dayz.st probably have had the idea that supporting people when all they need to do is package their .pbo, and all the stuff that goes with it, is just too time consuming. Not knocking them, so far I have heard nothing but good reports from their support, they actually seem keen to support custom mods etc.

The only advantage of the .pbo, that I can see, is that it is easier to download a single 'zip' file to the client than a whole folder / file structure, though the game engine will do it if required..

I would bet that packaging your mission.pbo with the same name as the mission folder will work fine and should, technically, add some reliability and quicker loading time for players..
 
@Orcthrasher, nice work. Am pretty sure that most items can be added with addMagazine, not tested anything apart from ammo but have seen grenades added with this.
 
OK - Here's how to add some variety to your soldiers, without flooding your server with rare items. As an example:

Code:
//Generate what the equipment will be - it's likely to be a map, but maybe.... :)
_rndLOut=floor(random 100);
_aiequipspawn=
switch (_rndLOut) do 
{ 
 case 0: {["Binocular_Vector"]};
 case 1: {["ItemGPS"]};
 case 2: {["ItemCompass"]};
 case 3: {["NVGoggles"]};
 case 4: {["Binocular"]};
 
 default {["ItemMap"]};
};

I wanted to make them more proportional, using if statements, but so far this is working
 
@Orcthrasher, nice work. Am pretty sure that most items can be added with addMagazine, not tested anything apart from ammo but have seen grenades added with this.

Thanks man! Your script opened up grand visas of possibilities to me. I sat here screwing around with it from about 3PM to 4:30AM, and I got up at 8 because I couldn't sleep, thinking about the stuff I wanted to try!

You're the wind beneath my wings!
 
Your mission should work fine with just the folder structure, I test it like that all the time (on localhost). I may be wrong, but I would guess that Dayz.st probably have had the idea that supporting people when all they need to do is package their .pbo, and all the stuff that goes with it, is just too time consuming. Not knocking them, so far I have heard nothing but good reports from their support, they actually seem keen to support custom mods etc.

The only advantage of the .pbo, that I can see, is that it is easier to download a single 'zip' file to the client than a whole folder / file structure, though the game engine will do it if required..

I would bet that packaging your mission.pbo with the same name as the mission folder will work fine and should, technically, add some reliability and quicker loading time for players..

I've started to pack it into a .pbo...It's really just a 2 second deal.

I've gone back to the basics, just adding in your code and nothing else, I'm really really starting to think this won't work with DayZ+

:(
 
Has anyone figured out how to change players sides, or make them hated?

I've been trying all day just to come to the realization that most commands are for units and objects..
 
Just wanted to say @orchthrasher that your edited scripts, worked great. I now have good guys at my base and bad guys at the airfield. A couple of questions though , that I can't answer on my own because I've not had chance to test it properly..

1. If I'm the in presence of the Survivors (good guys) and another player shoots me, will the Survivors turn on them? or do they only turn on you if you killed another AI in their group (I've set the SetFriend to 0.6)..

2. Do Survivors AI attack the Bandits AI, because I went to the airfield and found dead bandits everywhere , but no other player on the server yet. I also had 4 Survivor AI's on the airfield at the time..

And once again to everyone getting involved with making this script what it is, thanks a million. I can't tell you how long I've waited for this on my server :)
 
Just wanted to say that your edited scripts, worked great. I now have good guys at my base and bad guys at the airfield. A couple of questions though , that I can't answer on my own because I've not had chance to test it properly..

1. If I'm the in presence of the Survivors (good guys) and another player shoots me, will the Survivors turn on them? or do they only turn on you if you killed another AI in their group (I've set the SetFriend to 0.6)..

2. Do Survivors AI attack the Bandits AI, because I went to the airfield and found dead bandits everywhere , but no other player on the server yet. I also had 4 Survivor AI's on the airfield at the time..

And once again to everyone getting involved with making this script what it is, thanks a million. I can't tell you how long I've waited for this on my server :)
1) unfortunately i havent been able to make them detect bandits (players) yet. they will only attack someone if they shoot one of them first. i can't give players negative rating or their own faction sadly.

2) survivors ai do attack bandits ai.

if you were talking to me anyway.. a bit vain of me to assume.. lol
 
so for addMagazine i'm building an array of gear.. and then trying to add the gear dynamically.. is this the correct syntax?

Code:
                        for ({_z = 0},{_z = count _resistanceRandomGear},{_z = _z + 1}) do {
                            _currentItem = _resistanceRandomGear select _z;
                            _aiunit addMagazine _currentItem;
                        };
Code:
_resistanceRandomGear=[];
 
Gah! I'm trying to spawn two on the tower of the devils castle, but even when i use the exact worldspace (with height variable) , they aren't there when I restart.. Anyone got any tips ?
 
Gah! I'm trying to spawn two on the tower of the devils castle, but even when i use the exact worldspace (with height variable) , they aren't there when I restart.. Anyone got any tips ?
I haven't attempted that yet. Spent the last 12 or so hours trying to figure out how to make players change sides to no avail. I will give it a shot in a bit.
 
Back
Top