Simple AI Tutorial (no rMod or DayZ_Factions)

Oh one last thing sorry for all the question, whats the unit_killed.sqf for you dont mention it in your thread i know i have to put it in my scripts tough and can i make AI bodies despawn lets say after 15 - 20 minutes? This is the last things i need to know xD

EDIT

Does NVG, Rangefinder etc... Count as tools?
 
Yeah, where it says _sniperRifle or whatever, do this:

_rndSniperRifle = floor(random 2);
switch (_rndSniper) do {
case 0: {_sniperRifle = "gun1");
case 1:{_sniperRifle = "gun2"};
case 2:{_sniperRifle = "gun3"};
};

I don't know off the top of my head if a random 3 will return 1 2 and 3 or of it will return 0 1 2 3 or 0 1 2, so you might test by doing a: diag_log format ["Sniper Rifle %1 selected",_rndSniper]; so that you can see what the results of the random are. If you can't get it figured out, I will jump to my code and figure it out, but you should be able to get there with this code.

I THINK if you do floor(random 3) it will return 0 1 2 3. So you would need 4 weapons in that case. For 3 weapons do a random 2.

If you want to do a weighted system, you can do random 100, and instead of a case do:
if (_rndSniperRifle <=50} then {
_sniperRifle = "gun1";
} else {
if (_rndSniperRifle <=75) then {
_sniperRifle = "gun 2";
} else {
if (_rndSniperRifle <=90) then {
_sniperRifle = "gun 3";
} else {
_sniperRifle = "gun 4";
};
};
};

If you follow that, gun 1 has 50% chance to spawn, gun 2 has 25% chance, gun 3 has 15% chance, and gun 4 has 10% chance. I don't know how realistic those chances are, but in a perfect world where random is truly random, then that would be the case.

Since you also have to add ammo this wont give them random ammo wont it? Example Sniper with DMR has Nato Rounds
 
Since you also have to add ammo this wont give them random ammo wont it? Example Sniper with DMR has Nato Rounds
Good call, beneath _sniperRifle you will also have to set _sniperAmmo so that you are getting the proper ammo for your rifle. You can do an auto retrieve of the ammo, but that doesn't always give you what you're asking for (eg: m107 ammo with an as50 or SD rounds). You could also set the _sniperAmmoCount in there since different clips are different sizes. Up to you.
 
Good call, beneath _sniperRifle you will also have to set _sniperAmmo so that you are getting the proper ammo for your rifle. You can do an auto retrieve of the ammo, but that doesn't always give you what you're asking for (eg: m107 ammo with an as50 or SD rounds). You could also set the _sniperAmmoCount in there since different clips are different sizes. Up to you.
Ahh okay i just thought if i added multiple ammo it would be random and how about NVG's Rangefinders etc.. how would i add them in tools?
 
The globalFaction report isn't an oddity, it's just a diag_log I forgot to remove. It's just telling you the faction of the npc's you're creating.

Try commenting out the zombie_generate file in your init and see if the zombies come back.
Removing zombie_generate from my init.sqf fixed it, many thanks Sycosis :D
 
Removing zombie_generate from my init.sqf fixed it, many thanks Sycosis :D
So here is what I think the issue is.

The zombie_generate you're using is from the previous version of dayz (it was updated about a week ago).. To fix this, you need to go to your arma 2 oa installation folder, and grab the new zombie_generate file from your dayz_code.pbo and then add the addRating to the bottom of that file instead.

You can leave it how you have it now, but NPCs will not attack zombies.
 
Hello,
Thanks alot for this awesome work Sycosis. I was wondering if you would be kind enough to look at my files here.
I keep getting the "oops something went wrong screen". I thought it might be the skins so i changed them to what
looks to be unbanned in Taviana. That had no effect, still "oops". So i assume its the init.sqf file but im a complete
rookie at this so any help would be greatly appreciated . I am running a dayz.st server and the .com version of Taviana. i included a default mission.pbo for comaprison.
Thank you very much...Del.
 

Attachments

  • Del's_ai.pbo
    66.9 KB · Views: 6
  • dayz_mission.pbo
    49.4 KB · Views: 0
I used pbo manager 1.4 ...would that make a difference?

Sorry for bieng such a rookie here but which one should i use, PBOview or PBOManager 1.4?
 
ya i belive the worldspace is correct..checked and im standing close by and its similar .
here ya go..sorry for the the delay...kids and typing shhesh
 

Attachments

  • arma2oaserver.RPT.txt
    283.2 KB · Views: 1
  • add_unit_server.sqf
    13 KB · Views: 1
So here is what I think the issue is.

The zombie_generate you're using is from the previous version of dayz (it was updated about a week ago).. To fix this, you need to go to your arma 2 oa installation folder, and grab the new zombie_generate file from your dayz_code.pbo and then add the addRating to the bottom of that file instead.

You can leave it how you have it now, but NPCs will not attack zombies.
I'm using Taviana 2.0 and the Dayz code makes no difference so i never bothered updating, Now it makes sense :)
When or if Tavi 3.0 drops i'll use the new code.

Thanks again Sycosis
 
ya i belive the worldspace is correct..checked and im standing close by and its similar .
here ya go..sorry for the the delay...kids and typing shhesh
The only thing I can see is that the skins you're using might be banned.. try using "BAF_Soldier_MTP"

If that works, then you know your problem.

I don't know about this gun either:
BAF_L85A2_RIS_Holo
 
i have noticed today that ..yes i do have respawning ai...however one set of ai in diff location do not respawn and in another location they respawn as fast as we can shoot em
 
Hey everything is working sorta... The AI only spawns with the first weapon for example my snipers only spawn with M24

Code:
    case 0 : {
        _sniperSkin = "BAF_Soldier_Sniper_MTP";
        _sniperRifle = "M24","SVD_CAMO","DMR","M40A3";
        _sniperAmmo = "5Rnd_762x51_M24","10Rnd_762x54_SVD","20Rnd_762x51_DMR","5Rnd_762x51_M24";
        _sniperAmmoCount = 10;
        _sniperGear = ["ItemBandage"];
        _sniperWeapons = ["ItemMatchbox"];
        _gunnerSkin = "BAF_Soldier_MTP";
        _gunnerRifle = "Mk_48_DZ","M240","M249_DZ";
        _gunnerAmmo = "100Rnd_762x51_M240","100Rnd_762x51_M240","200Rnd_556x45_M249";
        _gunnerAmmoCount = 6;
        _gunnerGear = ["ItemBandage"];
        _gunnerWeapons = ["ItemMatchbox"];
        _militiaSkin = "BAF_Soldier_L_MTP";
        _militiaRifle = "Sa58V_EP1","BAF_L85A2_RIS_Holo","G36C","M4A1_HWS_GL","G36A_camo","M16A4_ACG";
        _militiaAmmo = "30Rnd_762x39_SA58","30Rnd_556x45_Stanag","30Rnd_556x45_G36","30Rnd_556x45_Stanag","30Rnd_556x45_G36","30Rnd_556x45_Stanag";
        _militiaAmmoCount = 10;
        _militiaGear = ["ItemBandage"]; // Additional gear (does not include tools or guns)
        _militiaWeapons = ["ItemMatchbox"]; //Additional Guns and Tools
 
roger...
thanks for the help man..ill give it another go.
Are the available (unbanned) skins the ones marked like this ..//class CDF_Soldier: Banned {};..
in the config.cpp file for whatever map your using?
 
roger...
thanks for the help man..ill give it another go.
Are the available (unbanned) skins the ones marked like this ..//class CDF_Soldier: Banned {};..
in the config.cpp file for whatever map your using?
There's a list of them on page 1 that are like that, but not all of them are unbanned. I'm not sure how to find all of the unbanned ones.
 
Back
Top