Simple AI Tutorial (no rMod or DayZ_Factions)

Morox!

Thanks for the reply! I did go back and look at the last posts. i added the lines in to get the AI to spawn back where they died and as the correct faction.

Only all this did was first of all only get me a "wait for host" i went back and looked and made a syntax error. fixed that. But then all NPC's stopped spawning completely :S

I have had to roll back where they was just lootable.

I have made a post up now asking for help on the forums to see if i can get someone to do it for me aswell as add clan skins. I grew tired and fed up and close to breaking computers.

Thankyou for the help but now i have some half asses NPCs who you can loot but they respawn in the middle of the map :S

Cheers for the help.

Here are my files if you want to look at them
 

Attachments

  • dayz_mission.pbo
    62.3 KB · Views: 4
Gorri,

In your RPT you should see "Global faction is #" that will tell you if the ai script executed.

Villko,

I will write something up for a bit later, on my mobile right now.
 
Ok,

Major SNAFU on my part folks, my apologies, apparently I did not upload the correct unit_killed.sqf to handle the faction fix that I added to the add_unit_server.sqf. If any of you have been having issues where AI is not respawning after adding the faction fix please replace your unit_killed.sqf with this one.

If some you look at the file you can see the changes, I've added a variable which reads what faction/side the AI is on then feeds the number back to the add_unit_server.sqf instead of the "string" value.

BloodType, this should solve your issue of respawning, on your wait for host issue I cannot speak to it directly but I got the error as well because your mission.sqm had "rmod" as an addon and I don't use it. Also in your add_unit_server.sqf you have "NVGoggles" as gear and it should be in weapons
 

Attachments

  • unit_killed.sqf
    1.6 KB · Views: 5
With this fix, AI will respawn on the correct faction and in the exact spot where they died, however they respawn as the unit type defined in the last _aispawn line and with that gearset. No fix for those yet sadly.
 
Villko,

Add the line

Code:
_aiunit addEventHandler ["Fired", {[(_this Select 0),100,true,(getPosATL (_this Select 0))] execvm "units\NPC_AlertZombies.sqf";}];



right above every line that looks like this

Code:
_aiunit addEventHandler["Killed",{null=_this+[(getPosATL (_this Select 0)),wpradius,wpnum,1,1,(side (group (_this Select 0))),baseSkill,potentialSkill,gearSet,respawnTime] execVM "scripts\unit_killed.sqf";}];


So it looks like this

Code:
_ailoadout=[_sniperRifle,_sniperAmmo];
_sniperSkin createUnit [_unitpos, _aigroup, "_aiunit=this;",1,"Private"];
_aiunit enableAI "TARGET";
_aiunit enableAI "AUTOTARGET";
_aiunit enableAI "MOVE";
_aiunit enableAI "ANIM";
_aiunit enableAI "FSM";
_aiunit allowDammage true;
_aiunit setCombatMode "RED";
_aiunit setBehaviour "COMBAT";
_aiunit addEventHandler ["Fired", {[(_this Select 0),100,true,(getPosATL (_this Select 0))] execvm "units\NPC_AlertZombies.sqf";}];
_aiunit addEventHandler["Killed",{null=_this+[(getPosATL (_this Select 0)),wpradius,wpnum,1,1,(side (group (_this Select 0))),baseSkill,potentialSkill,gearSet,respawnTime] execVM "scripts\unit_killed.sqf";}];
 //clear default weapons / ammo
removeAllWeapons _aiunit;
removeAllItems _aiunit;
//add weapon
_aiwep = _ailoadout select 0;
_aiammo = _ailoadout select 1;
_aiunit addMagazine _aiammo;
_aiunit addweapon _aiwep;

Then create a new directory called units

and place this file inside it.
 

Attachments

  • NPC_AlertZombies.sqf
    756 bytes · Views: 4
Working on this a bit more have fully fixed faction thing and now the unit type is persistent as well, I am currently working on the weapon and item loadout, hopefully have that knocked out in the next couple of hours.
 

Attachments

  • add_unit_server.sqf
    13.1 KB · Views: 9
  • unit_killed.sqf
    1.6 KB · Views: 7
Going to test out he fixes now, they was working with Rmod at first, then i made it so people could loot them, and they still worked then i try ed to fix their spawns and they stopped spawning completely, i need Rmod for the clan skins :S Thanks so much for the help! ill upload my files for you if you could look at them it would be great? cheers!!
*****EDIT***** It seems the NPCs are back in. My players can't loot the sniper, if they try they get disconnected, I will look back in this forum to see if this problem has occur d. Also at this point it seems only the snipers are spawning back in where they should. I have a group of 6 in the NWAF. 2 Snip, 2 Gunn, 2 Malit. also is there any way of making the Loot a chance on drop? my players are getting decked out really fast haha*******EDIT*******
I think i got the code right? I have been glued to these pages for hours following step by step :p
 

Attachments

  • init.sqf
    4.3 KB · Views: 3
  • NPC_AlertZombies.sqf
    756 bytes · Views: 2
  • add_unit_server.sqf
    14.7 KB · Views: 2
  • set_unit_faction.sqf
    298 bytes · Views: 2
  • unit_killed.sqf
    1.6 KB · Views: 2
  • zombie_generate.sqf
    2.8 KB · Views: 2
  • dayz_mission.pbo
    64.3 KB · Views: 5
Bloodtype,
Spotted your issues, I posted an update to the add_unit_server.sqf and unit_killed.sqf that you didn't apply also the looting of the sniper problem is related to the "NVGoggles" you have them in the wrong spot they belong in Weapon not Gear. I have updated both with your loadout's here. Let me know.
 

Attachments

  • add_unit_server-bloodtype.sqf
    14.7 KB · Views: 2
  • unit_killed-bloodtype.sqf
    1.6 KB · Views: 2
i need help , i followed the guide step by step but when loading in , i just get stuck on loading and then it says something is wrong disconnect adn try again? any one wanna teamvierwer me and help? please
 
Thanks alot! up loading them now! Do you know a way of setting % of items to drop? at the moment my players are getting 11 clips for every wep? or do i just need to lower the amount they are carrying?
 
@Morox sure - take a look :)
 

Attachments

  • init.sqf
    3.6 KB · Views: 2
  • add_unit_server.sqf
    13 KB · Views: 6
  • set_unit_faction.sqf
    298 bytes · Views: 1
  • zombie_generate.sqf
    3 KB · Views: 1
  • unit_killed.sqf
    1.4 KB · Views: 1
  • dayz_aitest.chernarus.pbo
    725.8 KB · Views: 3
Bloodtype,

Yeah at the moment the only way is to lower the amount they start with, you could do some coding in the the unit_killed.sqf to handle percent drops.
 
RoyalCuppa,

By quick look I would say don't add rotation to the _aispawn line in the init.sqf. Try this one, I have not gone through all the other files, not on my machine with tools to extract PBO, I'll check out in a bit if this does not work.
 

Attachments

  • init.sqf
    3.6 KB · Views: 2
@Morox
so far so good! all seems well! going to lower the mags they carry best i can do myself atm. Thank you so much for the help! Do you take donations for doing this for everyone?? i would be happy to send! Also and i know its cheeky ass its not part of this thread. but do you know how to set clan skins? its the last thing we want on our server, I would happily pay for your services. If not then Thanks again you are the best!
 
RoyalCuppa,

Sorry missed a ] in my edit, give this one a go
 

Attachments

  • init.sqf
    3.6 KB · Views: 6
right there spawning in and they are respawning but when they get killed they dissapare :(


also they do not attack me even though ive got there hate set to 7 towards West and east , there indepents
 
zombies spawn when you're 300m away from a settlement (spawn zone). is there a way to make the game recognize the AI as real entities so zombies will spawn when they get in range?
 
Back
Top