Simple AI Tutorial (no rMod or DayZ_Factions)

Hi all, great community and great thread!

I was wondering if someone might be able to help us add this to our server? Any help you can provide is much appreciated!

- Dayz Trauma
 
Royal Cuppa,

.5 and down would be hate above .6 is like. On the disappear thing I talk about this in various posts, look for AI vanish and you should find the fix, I am not at my server with files right now so I can't attach the file with the fix, it's in the add_unit_server.sqf

Bolbies,

I have not looked into this, I will see how difficult it would be to code.

Gorri,

Right now this AI does not interact with vehicles, you way want to look at Sarge's AI pack which has heli-patrols. At the moment I am focused on the AI itself and have not started to work with them in vehicles yet so I can't give you an ETA on when I will have a chance to look into this


Hey Morox. Have you looked into the AI spawning zombies thing yet?
 
Governer,

Are you having issues? Have you tried implementing this yet?

Bolbies,

Sorry no I have not, I am working on the Alpha release I spoke of which fixes all the issues with this mod and then I will begin working on the requests and enhancements.
 
any chance any know now how to fix it when you loot them and get kicked , when they first spawn i can loot them etc but when they respawn some of them i can loot and some of them makes me get kicked from the server also every now and then some of them dont respawn with ammo
 
RoyalCuppa,

In your add_unit_server.sqf you have an error in your units there is a line that you have which says

Code:
_aiammo = _ailoadout select 0;

it should read

Code:
_aiammo = _ailoadout select 1;

It is correct for your squad section but not the individual section this is causing the kicks and the them not having ammo, upon respawn, as they respawn as individual units.
 
306091_438623342891312_712908924_n.jpg


This is my AI spawn point.
and when start the server it's work fine (yesterday)
and today ai not spawn on the point that i mark
like this
spacer.gif
548547_438807732872873_1511610664_n.jpg


How fix this?
namalsk map
 
By battle eye? Or something else?

EDIT

Also did you change all the spots of _aiammo in your files there should have been 3 instances.
 
yep i changed it from a 0 to a 1 like you said , also it dosnt saying anything but before when i changed them from a 0 to a 1 it kicked for corrputed data

EDIT - just changed a few from 0 to 1 , gonna re test
 
ive done it , gonna test them also my heli copter crash sites arnt spawning in , i know its not realated to this thread but was wondering if you could help me out with that via a PM Morox?
 
Ok,

So I have completed my code changes and I think have debugged it enough to pass out to folks for testing. I'll try to explain briefly what I have done here. Note that all the instructions in the OP are still the same as far as BattleEye and how to extract the needed files etc. These files should simply be used in place of Sycosis's otherwise his instructions are still the same.

add_unit_server.sqf

This has been greatly modified to solve the issue of the variables being overwritten with multiple _aispawn lines - sadly the only way to track some of the variables was to attach them to a global variable that is maintained, I have tried to keep this as small as possible as to not affect performance. I have not changed anything in regards to the gearset section so you should be able to use anything you have already created and call it the same way from the init.sqf. Most of the code that has been added has been done to handle whether the script call is initial or a respawn - depending on which it is there are different things done.

There are two concepts for respawning AI's gear - By default the one that is active is using the initial gearset that the AI had when they were spawned. The other option that is available is to spawn the AI with whatever they had on them when they died. As AI will pick up weapons and ammo this may be a desired option, the notes in both the add_unit_server.sqf and unit_killed.sqf hopefully will explain how to make this change. At the moment this is a global change that affects all AI not on a per AI basis.

I have also added ORCTHRASERS NPC_AlertZZombie mod from page 3 so that Zeds are alerted when NPC's fire, however at the moment the Zeds will not attack the NPC's but they will run up to them. If you choose that you do not want this feature simply comment the eventhandler line for the "Fired" action.

unit_killed.sqf

This file was also greatly modified to collect all the data on the dead AI unit and pass it back to the add_unit_server.sqf to respawn the unit properly. As noted before there is a section here where you also need to change if you want to change the AI gear respawn mentioned above.

The other option you have in this file is to determine where the AI unit respawns, the two choices are where they died or within 10 m of the original spawn point. The default is near the original spawn point. Simply comment out the one you don't want and you can change this easily.

set_unit_faction.sqf


Has no change.

zombie_generate.sqf

While I have not changed the Zombie_generate.sqf from the Sycosis change, I have pulled another file out of the dayz_code.pbo which is wild_SpawnZombies.sqf and added the same "rating" line to this file as well. This was to ensure that all Zeds spawned would be enemies to the AI, as I encountered some Zeds that the AI would not attack outside of cities.

init.sqf


There are not many changes to the init.sqf other than to add in the use of the wild_spawnZombies.sqf and the use of an initial variable that keeps track of the AI.

For the wild_spawnZombies.sqf simply add the line underneath the zombie_generate like so
Code:
zombie_generate = compile preprocessFileLineNumbers "scripts\zombie_generate.sqf";
wild_spawnZombies = compile preprocessFileLineNumbers "scripts\wild_spawnZombies.sqf";

For the other addition place it above the first _aispawn line like so

Code:
if (isServer) then {
 
_serverMonitor =[] execVM "\z\addons\dayz_code\system\server_monitor.sqf";
// For settings involving the factions, go to scripts\add_unit_server.sqf and adjust the settings at the top of the file
    _factions = [] execVM "scripts\set_unit_faction.sqf";
//_aispawnpos - Worldspace location
//_wpradius - Distance you want units to be able to travel
//_wpnum - Number of waypoints to place withing that distance. The higher the number, the more extensively the units will travel
//_numunits - Number of units to place. Keep in mind that squads will be placed in multiples of this number
//_unitType - Type of unit to place. 0: Random, 1: Sniper, 2: Gunner, 3: Militia, 4: Squad of the previous 3 types
//_faction - The type of faction you want this unit to adhere to. 0: RESISTANCE, 1: EAST, 2: WEST. Factions loyalties are set in scripts\set_unit_faction.sqf
//_baseSkill - Lowest possible skill that the units can posess from 1 to 10
//_potentialSkill - Highes possible skill that the units can posess from 1 to 10
//_gearSet - Which set of gear your units will use. To set the types of gear, edit the variables at the top of scripts\add_units_server.sqf
//_respawnTime - How long to wait until NPCs respawn (in seconds)
spawncnt = 0;
    _aispawn = [[7189.85,7682.39,0.001],50,5,1,0,0,8,10,0,1400] execVM "scripts\add_unit_server.sqf";//Chernaurs
 
};

You can see it here as "spawncnt = 0;"

Thanks to Sycosis for the original mod and all the folks on this forum for you thoughts. Please note that this is very Alpha code and I cannot guarantee that it will work on every map or with any other mods. Please let me know any bugs you encounter and I will do my best to address them.

Morox
 

Attachments

  • add_unit_server.sqf
    16.5 KB · Views: 14
  • npc_alertzombies.sqf
    758 bytes · Views: 11
  • set_unit_faction.sqf
    298 bytes · Views: 12
  • unit_killed.sqf
    3.7 KB · Views: 14
  • wild_spawnZombies.sqf
    2 KB · Views: 13
  • zombie_generate.sqf
    3.3 KB · Views: 13
Which version of the MOD are you using, the one I just posted or the the original? Most of the time for people it's because the use of MPKilled and MPEventHandler instead of Killed and EventHandler.
 
Everything Installed Correctly and everything works, but every time i kill an AI then check his Gear the game crashes. Any idea why this would happen?
 
Back
Top