Simple AI Tutorial (no rMod or DayZ_Factions)

In this line:
Code:
_aiunit addMPEventHandler["MPKilled",{null=_this+[aispawnpos,wpradius, ...
I changed to:
Code:
_aiunit addEventHandler["Killed",{null=_this+[(getPosATL (_this Select 0)),wpradius, ...

Occurred kick restriction #80 when used "addMPEventHandler"

Note this example (init.sqf):
Code:
if (isServer) then {
  _factions = [] execVM "scripts\set_unit_faction.sqf";
//CHERNOGORSK
  _aispawn = [[6689.49,2623.59,0],30,5,1,4,1,7,10,0,12] execVM "units\add_unit_server.sqf";
//AIRFIELD
  _aispawn = [[4598.66,10197.7,0],30,5,1,4,1,7,10,0,12] execVM "units\add_unit_server.sqf";
};

Whenever you are in Chernogorsk, and kill the npcs, the respawn
happen as the last line defined in init.sqf.

So I used the "getPosATL (_this Select 0)". And the respawn occurs where the npc is dead.
At the time, I used it because I do not know how to respawn occurs in the place of origin.
** When npc is dead, reappears in this dead place

(I'm from Brazil, my english is bad)
 
Jomine,

I think it is a good solution to the problem, my question is why did you remove all the last parts of the Eventhandler line,

Yours looks like

Code:
_aiunit addEventHandler ["Killed",{null=_this+[(getPosATL (_this Select 0)),wpradius,wpnum,1] execVM "units\unit_killed.sqf";}];
Mine looks like this

Code:
_aiunit addEventHandler["Killed",{null=_this[aispawnpos,wpradius,wpnum,1,1,globalFaction,baseSkill,potentialSkill,gearSet,respawnTime] execVM "scripts\unit_killed.sqf";}];

You don't have the the faction/baseskill/potentialskill etc, wanted to know why?

Obrigado
 
Try giving them the same item as the gunner and see if the error still exists, it seems it may be an issue of Arma2 vs Arma2OA model by a quick look into this error.

Good call man.
Switched militia loadout from G36C to MK48Mod0 and I get no more error.

For what it's worth:
Arma2 Weapons:
MK48 Mod0(in the OP's file)working
G36C(added by me)caused error

BAF Weapons:
AS50(in the OP's file)working
L85A2 AWS(in the OP's file)caused no weapon to be equipped

So I don't know why the hell MK48 works but G36C doesn't. Obviously it's not strictly an Arma2/OA conflict since they're both Arma2 weapons. It just seems as if certain weapons work and others don't.

If anyone is bored and wants to go through the entire list of unbanned weaps and create a list of working ones feel free lol otherwise, just be aware that some weaps will give you errors.
 
Did you copy the all Arma2 Addons folders to your server install upon setup? It's possible you are missing some definitions. I'll try to load those wepons on mine when I get a chance and see. Also I recall having errors on my own client install where I got a lot of "object" not found errors since I had Arma and Arma2 installed separately instead of as Combat Ops, I believe there is a way to convert it in Steam or created a Symlink for it otherwise.
 
Did you copy the all Arma2 Addons folders to your server install upon setup? It's possible you are missing some definitions. I'll try to load those wepons on mine when I get a chance and see. Also I recall having errors on my own client install where I got a lot of "object" not found errors since I had Arma and Arma2 installed separately instead of as Combat Ops, I believe there is a way to convert it in Steam or created a Symlink for it otherwise.
I'm on DayZ.ST but I've edited and worked with the weapons a lot and yes G36C definition is in there for sure.(used it in weapon crates/cust_loadout/etc. all successfully.
 
I have my AI up an running and fixed it so that their bodies do not disappear, however one particular NPC is causing ARMA to become unresponsive when you interact with his body. Here is his loadout...does anyone know why this might happen?

case 2 : {
_sniperSkin = "BAF_Soldier_Sniper_MTP";
_sniperRifle = "BAF_AS50_scoped";
_sniperAmmo = "5Rnd_127x99_as50";
_sniperAmmoCount = 8;
_sniperGear = ["ItemBandage","Soldier1_DZ"];
_sniperWeapons = ["ItemMatchbox","NVGoggles","Binocular_Vector"];
_gunnerSkin = "Worker1";
_gunnerRifle = "Winchester1866";
_gunnerAmmo = "15Rnd_W1866_Slug";
_gunnerAmmoCount = 3;
_gunnerGear = ["ItemBandage"];
_gunnerWeapons = ["ItemMatchbox"];
_militiaSkin = "Villager1";
_militiaRifle = "revolver_EP1";
_militiaAmmo = "6Rnd_45ACP";
_militiaAmmoCount = 3;
_militiaGear = ["ItemBandage"]; // Additional gear (does not include tools or guns)
_militiaWeapons = ["ItemMatchbox"]; //Additional Guns and Tools
};
 
Diz,

I just tried this and it worked fine with the G36C, strange I don't know what it could be that's preventing it from loading, but I run my own dedicated and not DayZ.st so it's hard to say.
 
Aliveman,

Your issue is with this line

_sniperGear = ["ItemBandage","Soldier1_DZ"];

I don't think the sniper can carry a player in his pocket :)
 
Shryguy,

I used your paste right into my file and it worked fine - they had all the items on them - what exactly are you seeing?

Gary,

Can you provide your mission.pbo so I can take a look and see if there is conflict on the respawn.
 
Shryguy,

I used your paste right into my file and it worked fine - they had all the items on them - what exactly are you seeing?

Gary,

Can you provide your mission.pbo so I can take a look and see if there is conflict on the respawn.

attached and thank you! BTW, just found out that they are respawning at the last listed location!
 

Attachments

  • dayz_mission_tavi_new.pbo
    230.9 KB · Views: 5
Shryguy,

I used your paste right into my file and it worked fine - they had all the items on them - what exactly are you seeing?

Gary,

Can you provide your mission.pbo so I can take a look and see if there is conflict on the respawn.
Yeah absolutley I removed Items from alot of them caus it would crash the game when I tried to search their inventory and take the NVG's. Look for the enemies from case 5. I want to add more items to all the enemies so survivors can get supplies from them. Theres a body near the docks area it seems that whenever I search it it crashes?? It says Tactical Driver on the body I go the the body search it and it freezes!?! UPDATE: I think I made a simple error I forgot a " after "ItemGPS" on that class in case 5 I'm gonna try it again. UPDATE: It still crashes when I search the body of the "Tactical Driver"s body:( Idk if its a certain Item I am giving them or if I'm putting them in the wrong spot but one squad is near these coordinates : [[10342.9,1752,0.001]]
 

Attachments

  • dayz_server.pbo
    72.2 KB · Views: 0
  • dayz_mission.pbo
    79.6 KB · Views: 4
Gary,

I have indeed determined what I thought to be true, that all respawns end up inheriting the values of the last _aispawn line in the init.sqf, and while Jomine's fix works for the position of the spawn it does not solve the issue of faction/unittype and gearset, among other things. He uses axeman's scripts which do not pass these variables so I am going to take a look at those and see how I can integrate them to these files. In the mean time to solve the position thing simply use
Code:
(getPosATL (_this Select 0))
In place of aispawnpos in all Eventhandler (only) spots in the add_unit_server.sqf.
 
I have my AI up an running and fixed it so that their bodies do not disappear, however one particular NPC is causing ARMA to become unresponsive when you interact with his body. Here is his loadout...does anyone know why this might happen?

case 2 : {
_sniperSkin = "BAF_Soldier_Sniper_MTP";
_sniperRifle = "BAF_AS50_scoped";
_sniperAmmo = "5Rnd_127x99_as50";
_sniperAmmoCount = 8;
_sniperGear = ["ItemBandage","Soldier1_DZ"];
_sniperWeapons = ["ItemMatchbox","NVGoggles","Binocular_Vector"];
_gunnerSkin = "Worker1";
_gunnerRifle = "Winchester1866";
_gunnerAmmo = "15Rnd_W1866_Slug";
_gunnerAmmoCount = 3;
_gunnerGear = ["ItemBandage"];
_gunnerWeapons = ["ItemMatchbox"];
_militiaSkin = "Villager1";
_militiaRifle = "revolver_EP1";
_militiaAmmo = "6Rnd_45ACP";
_militiaAmmoCount = 3;
_militiaGear = ["ItemBandage"]; // Additional gear (does not include tools or guns)
_militiaWeapons = ["ItemMatchbox"]; //Additional Guns and Tools
};
Yeah my game crahes my hunch is its the NVGs because I can search the inventory of everyother AI in my script except those with nvgs...
 
Right away I see two issues

case 3 : {
_sniperGear = ["ItemBandage","NVGoggles"];
case 5 : {
_sniperGear = ["ItemBandage","NVGoggles","ItemHeatPack"];

NVGoogles should be in weapons section not gear
 
Gary,

I have indeed determined what I thought to be true, that all respawns end up inheriting the values of the last _aispawn line in the init.sqf, and while Jomine's fix works for the position of the spawn it does not solve the issue of faction/unittype and gearset, among other things. He uses axeman's scripts which do not pass these variables so I am going to take a look at those and see how I can integrate them to these files. In the mean time to solve the position thing simply use
Code:
(getPosATL (_this Select 0))
In place of aispawnpos in all Eventhandler (only) spots in the add_unit_server.sqf.
Thanks! Ill give it a try.
 
Hey peeps.

Got a few questions that may, or may not, have been covered. If they have can anyone give me a link to the post (or page number) as I'm finding it a bit tricky seiving through all the posts as there are a lot of suggestions and I'm not sure which is the actual fix for each one.

I'm not stupid by any means, and I have tried the search but upgraded from an @factions and now my players are stressing as that worked and this does not. Ooops.

Tried the obvious (running rmod, tried non banned weapons etc) to no avail

1. For some reason my ai goes invisible when it's killed. I've tried a few suggestions but cant find a definitive fix.
2. Some of my ai seem to be running about with no weapon, could be holding grenade just not throwing it, cant loot to see if they have a weapon on their body as vanish once killed
3. Grenades (gear or weapon)?
4. Ai wont engage unless in a vehicle (set to 0 for both teams on sqf), is this a skill level thing (ie to stupid to see me)
5. Did we ever get a working system to load them into vehicles / helis and doing a bit of a patrol in them?

Pretty sure these bits are covered somewhere in the past 30 pages but if someone can gimme a nudge onto the applicable post I would be very grateful.

On a seperate note, great to see such a good post with active members helping each other. Reps for OP and all the regulars
 
Hey guys my AI didnt spawn after adding random loot can someone please take a look
Code:
_sniperSkin = "BAF_Soldier_MTP"
_rndWeapon = floor(random 5);
switch (_rndWeapon) do {
  case 0: {_sniperRifle="M24";_sniperAmmo="5Rnd_762x51_M24";};
  case 1: {_sniperRifle="SVD_CAMO";_sniperAmmo="10Rnd_762x54_SVD";};
  case 2: {_sniperRifle="DMR";_sniperAmmo="20Rnd_762x51_DMR";};
  case 3: {_sniperRifle="M40A3";_sniperAmmo="5Rnd_762x51_M24";};
};
_sniperAmmoCount = 10;
_sniperGear = ["ItemBandage"];
_sniperWeapons = ["ItemMatchbox"];
_gunnerSkin = "BAF_Soldier_MTP";
_rndWeapon = floor(random 3);
switch (_rndWeapon) do {
  case 0: {_gunnerRifle="Mk_48_DZ";_gunnerAmmo="100Rnd_762x51_M240";};
  case 1: {_gunnerRifle="M240";_gunnerAmmo="100Rnd_762x51_M240";};
  case 2: {_gunnerRifle="M249_DZ";_gunnerAmmo="200Rnd_556x45_M249";};
};
_gunnerAmmoCount = 6;
_gunnerGear = ["ItemBandage"];
_gunnerWeapons = ["ItemMatchbox"];
_militiaSkin = "BAF_Soldier_L_MTP";
_rndWeapon = floor(random 16);
switch (_rndWeapon) do {
  case 0: {_militiaRifle="Sa58V_EP1";_militiaAmmo="30Rnd_762x39_SA58";};
  case 1: {_militiaRifle="BAF_L85A2_RIS_Holo";_militiaAmmo="30Rnd_556x45_Stanag";};
  case 2: {_militiaRifle="G36C";_militiaAmmo="30Rnd_556x45_G36";};
  case 3: {_militiaRifle="M4A1_HWS_GL_camo";_militiaAmmo="30Rnd_556x45_Stanag";};
  case 4: {_militiaRifle="M16A4_ACG";_militiaAmmo="30Rnd_556x45_Stanag";};
  case 5: {_militiaRifle="G36A_camo";_militiaAmmo="30Rnd_556x45_G36";};
  case 6: {_militiaRifle="Sa58P_EP1";_militiaAmmo="30Rnd_762x39_SA58";};
  case 7: {_militiaRifle="Sa58V_CCO_EP1";_militiaAmmo="30Rnd_762x39_SA58";};
  case 8: {_militiaRifle="AK_47_M";_militiaAmmo="30Rnd_762x39_AK47";};
  case 9: {_militiaRifle="M16A2";_militiaAmmo="30Rnd_556x45_Stanag";};
  case 10: {_militiaRifle="FN_FAL";_militiaAmmo="20Rnd_762x51_FNFAL";};
  case 11: {_militiaRifle="M4A1";_militiaAmmo="30Rnd_556x45_Stanag";};
  case 12: {_militiaRifle="M4A1_AIM_SD_camo";_militiaAmmo="30Rnd_556x45_StanagSD";};
  case 13: {_militiaRifle="G36K_camo";_militiaAmmo="30Rnd_556x45_G36";};
  case 14: {_militiaRifle="Sa58V_RCO_EP1";_militiaAmmo="30Rnd_762x39_SA58";};
  case 15: {_militiaRifle="AK_47_S";_militiaAmmo="30Rnd_762x39_AK47";};
};
_militiaAmmoCount = 10;
_militiaGear = ["ItemBandage"]; // Additional gear (does not include tools or guns)
_militiaWeapons = ["ItemMatchbox"]; //Additional Guns and Tools
    };
    case 1 : {
        _sniperSkin = "Citizen3";
        _sniperRifle = "LeeEnfield";
        _sniperAmmo = "10x_303";
        _sniperAmmoCount = 6;
        _sniperGear = ["ItemBandage"];
        _sniperWeapons = ["ItemMatchbox"];
        _gunnerSkin = "Worker1";
        _gunnerRifle = "Winchester1866";
        _gunnerAmmo = "15Rnd_W1866_Slug";
        _gunnerAmmoCount = 6;
        _gunnerGear = ["ItemBandage"];
        _gunnerWeapons = ["ItemMatchbox"];
        _militiaSkin = "Villager1";
        _militiaRifle = "huntingrifle";
        _militiaAmmo = "5x_22_LR_17_HMR";
        _militiaAmmoCount = 7;
        _militiaGear = ["ItemBandage"]; // Additional gear (does not include tools or guns)
        _militiaWeapons = ["ItemMatchbox"]; //Additional Guns and Tools
    };
};
if (_unitType == 0) then {
    _rndLOut=floor(random 2)+1;
    _unitType = _rndLout;

Or take a look

Not sure if you got a reply on this yet mate (scanning through looking for answers to my little niggles)

Noticed a few errors with your syntax. Line one doesnt end with an ; and line 2 refrences random between 5 options but you only have 4 (0->3 = 4 numbers, need another one or drop the floor5 to floor4)

Hope that helps a bit ;)
 
Not sure if you got a reply on this yet mate (scanning through looking for answers to my little niggles)

Noticed a few errors with your syntax. Line one doesnt end with an ; and line 2 refrences random between 5 options but you only have 4 (0->3 = 4 numbers, need another one or drop the floor5 to floor4)

Hope that helps a bit ;)

Thanks for replying your the first one to reply, atm im using axemans and going to sarge now so im not gonna use this thanks anyway
 
No worries mate

You got links to axemans and sarges?

Heard it mentioned before, not sure of the benefits but happy to swap if it sorts out my issues.

Personally I enjoy the challenge of sorting it out but my regulars are starting to bug me about it quite a bit. It just saves a headache if I can get a working solution up asap. Failing that I can fall back to factions, but they're now looking forward to all the additional bits as they play roleplay and have already dreamt up missions I'm meant to be implementing for them.
 
Back
Top