Welcome to The Forum

Register now to gain access to all of our features. Once registered and logged in, you will be able to create topics, post replies and more


Adding AI/NPC tutorial


Recommended Posts

Adding Custom AI to your Survival Server

 

|------All Credit goes to SARGE, Richie, Omer, Wyger, Sabbath-------|

 

Survival Servers do things a bit differently so I'm going to

show you how to incorporate this into your SS.

 

If you have any questions, feel free to add me on Steam and MSG me JDMTeckadmics

 

 

Or if you want to see first hand how it works you can hop on my server and I'll show you

 

 

Download Links and Helpful Links

http://opendayz.net/threads/sarge-ai-framework-public-release.8391/

https://github.com/Swiss-Sarge/SAR_AI

 

Version 1.1.0

 

Changelog:

 

- Moved all the SAR AI configurations into a single cfg file for easier editing - SAR_config.sqf.

- Static and dynamic groups can respawn (configurable), weapon and item loadouts are applied

- Items and Tools loadout for every single AI class

- Health of units can be adjusted - get that nearly undestroyable bandit

- Med action added to friendly leaders

- different actions for groups (patrol, ambush, fortify)

- implemented skill system

- included many more configuration options

 

- FIXED the enemies travelling in the same vehicle issue (that was a badass!)

 

- included a monitor to check for number of groups and warn if too many AI have been spawned

- dynamic spawning can be enabled/disabled

- use of UPSMON can be enabled/disabled

- groups stealing vehicles can be enabled/disabled

 

- rewrote the reammo and refuel scripts

- fixed the AI talking in sidechat when being shot at

 

PLEASE MAKE SURE YOU READ THE README on GITHUB!

 

Version 1.0.3

 

- Fully configurable logging of bandit or survivor AI kills

- Optimized aggro from friendly fire - one hit is now sufficient to aggro the AI

- Reworked AI heli turret issue - you should no longer see the error message with 2 elements expected, 3 given

- Fixed heli spawn bug

- included functions to query cfg files for turrets (not used atm)

- Included hit Eventhandler for heli - this will only work if you do a decent amount of damage, with a normal weapon this EH will not trigger

 

 

Version 1.0.2

 

- Fully configurable humanity sytem implemented. check out SAR_config.sqf for values to configure.

 

- Fixed the AI communicating if under friendly fire - CHECK INSTALL, you need to edit your description.ext!

 

Version 1.0.1 IMPORTANT UPDATE

 

- fixed the bug with AI not respawning after reentering an area. You only need to download the code scripts, configuration files are unchanged.

 

 

Version 1.0.0

Available here: https://github.com/Swiss-Sarge/SAR_AI

Maps covered and configured:

 

Chernarus - Sarge

Taviana - thx a lot to Richie

Namalsk - thx a lot to Omer

Lingor - thx a lot to Wyger

Panthera - thx a lot to Sabbath

 

Maps that are included but need configuration (IF you configure one of these maps (grid & definition for gridsquares), please do me a favour and share it back with me, so i can include it in the framework):

Celle

Fallujah

Takistan

--------------

Features:

 

General

- no addons on the clientside needed

- tested with Dayz 1.7.5.1, should also work with 1.7.6.x

- supported maps: see above

- easy install (dedicated script folder, started by init.sqf)

- optimized for server performance, all AI handled on the server

- highly configurable

- relies on 2 other script packages: UPSMon and SHK_pos (included in the archive)

 

 

Functionality

player triggered AI (same concept as Dayz's zombie spawn, this prevents "unused" AI on the map)

- 3 AI factions:

AI survivors (shoot Zeds and player bandits)

AI bandits (shoot Zeds and player bandits/player survivors)

AI soldiers (shoot Zeds, AI bandits and player bandits)

Dynamic "enemy" handling - only units near players will be made "unfriendly" towards Zeds / Bandits etc.

Randomized gear/skins and group setups(leader/sniper/riflemen)

Randomized patrol waypoints around the player

preconfigurable sizes of groups, number of groups and probability of groups spawning close to player

 

static AI configureable (e.g. put a group of bandits in Devils Castle, let 30 soldiers protect your camp, etc.)

static Heli patrols predefined (Chernarus south coast, east coast, airfields). custom patrols configurable.

automatic despawn if no players present anymore in the area

killed AI bodies get deleted after a short amount of time (reduce server lag)

 

 

 

 

 

 

 

 

|------All Credit goes to SARGE, Richie, Omer, Wyger, Sabbath-------|

-------------------------------------------------------------------------------

-----------------------------INSTALL-----------------------------------------

 

!*Please follow the instructions carefully and do your research. I'm not responsible for messing your server up. Please make copies of original files before editing them*!

 

Installation Pre Steps:

 

1.Download SARGES AI files from one of the links at the top of the page

 

2.Make sure you have Notepad++

 

3.You need to un-pbo your missions folder. (if you dont know how to do this, please google/youtube and learn, in that case this framework is not really intended for you) but truthfully it's not that hard. But you will need to install the pbo tool. Once again just google it and download it from one of the Arma Sites.

 

4.Where do i find my mission PBO? It's in File Manager > MPMissions and it will be a file named

dayz_(yourservernumber).(yourmap).pbo for example dayz_1656.chernarus.pbo

 

5.*!Download it to your computer and make 2 copies 1 to edit and one as a backup!*

6.*!Don't mess with any other files in the folder besides your own, these belong to other people!*

 

Installation:

 

1.In your missions folder, create a folder called "addons".

2.Add the content of the archive (the folders SARGE, UPSMON and SHKPOS)

3.edit your init.sqf file from your missions folder

4.add the following lines at the end of the init.sqf :

 

call compile preprocessFileLineNumbers "addons\UPSMON\scripts\Init_UPSMON.sqf";

 

call compile preprocessFileLineNumbers "addons\SHK_pos\shk_pos_init.sqf";

 

[] execVM "addons\SARGE\SAR_AI_init.sqf";

 

5.add the following line at the end of the description.ext :

 

#include "addons\SARGE\SAR_define.hpp"

 

6.You can also customize just about everything about the AI from guns they have, what they do, behavior, what to shoot at, how many etc. For a better understanding see the ReadMe inside Sarges AI folder or check the links above.

7.Re-PBO your mission and don't for get to add a CheckSum Key by clicking the lock

8.Upload it to File Manager > MPMissions.

9.Start your Server back up (may take a bit longer to join and start your server, mine takes about 1 minute)

10. Enjoy, If you get kicked as soon as you get in the game don't be shocked

11. You need to go into battleye under File Manger > Bliss > Battleye > Scripts.txt and then edit these while you server is off

 

Locate this

 

1 setFuel !"\"setFuel\"," !"z\addons\dayz_code\compile\local_setFuel.sqf" !"\"dayzSetFuel\"" !"if (_fuel >= 1.0) then { _fuel = 1.0; };\n\n_target setFuel _fuel;" !

 

and change it to this

 

1 setFuel !"\"setFuel\"," !"z\addons\dayz_code\compile\local_setFuel.sqf" !"\"dayzSetFuel\"" !"if (_fuel >= 1.0) then { _fuel = 1.0; };\n\n_target setFuel _fuel;" !"_vehicle setFuel 1;\nif (SAR_EXTREME_DEBUG) then {diag_log "SAR_EXTREME_DEBUG: Vehicle refueled";};"

 

Also Locate this

 

5 setVehicleAmmo !"\"setVehicleAmmo\","

 

and change it to this

 

5 setVehicleAmmo !"\"setVehicleAmmo\"," !"_vehicle setVehicleAmmo 1;\nif (SAR_EXTREME_DEBUG) then {diag_log "SAR EXTREME DEBUG: Vehicle new ammo";};"

 

12. That's all I had to do to get AI on my survival server. It took me maybe 30 mins to go through and set it all up. Then I added Heli patrols and a ton more AI spawns that took about 2 hours but well worth it.

 

 

 

Here's some of the 45+ AI Soldiers and Survivors I have watching after my base...

 

arma2oa2013042800261978.jpg

 

arma2oa2013042800263453.jpg

 

arma2oa2013042800265150.jpg

 

arma2oa2013042800273010.jpg

Share this post


Link to post
Share on other sites

Can't seem to find the guide or area to modify AI spawns. For protecting bases, trader cities, ect.

You want static spawn points for this :) They are located in SAR_cfg_grps_YOUR_MAP.sqf

Scroll down past the grids and the heli patrols until you find :

//---------------------------------------------------------------------------------
// Static, predefined infantry patrols in defined areas with configurable units
//---------------------------------------------------------------------------------

Share this post


Link to post
Share on other sites

Try this but skip to the last 2 minutes or so...

He does a pretty good job of explaining how the static ai spawn

 

 

I was able to spawn about 50 of them my base with no lag. I used patrol so they move around a bit, fortify they just stay in the same place all the time.... Also after every server restart they switch guns. Also be warned, they do take vehicles and they will take guns out of custom spawned creates. Especially the ai that spawns in towns... ive found a group of soldiers that took a Hmmwv_m2 (tan one with the 50.) From Elektro to Balota airfield. I followed them the whole time, very weird...but cool

Share this post


Link to post
Share on other sites

Awesome, knew I was missing something. Guess I should have looked harder to find the file. Wish there was a way to make the AI protect you only from everyone else. That way they really guard your base against players. Right now it is just a little extra security against random zombies or bandit AI.

Share this post


Link to post
Share on other sites

Does anyone have any ideas as to why there is nothing in my MPMissions\dayz_****.chernarus.pbo file? :) My server is working fine and there are definitely objects in some of my other .pbo files so i think im unpacking them fine. Thanks

Share this post


Link to post
Share on other sites

File Manager > MP missions > mission.pbo

 

Use pbo manager to unpack it and all the files should be there. If they aren't then it is impossible for your server to be running. Think of a pbo as a zip file but requires a different tool to unpack it.

 

Also for those who want to code individual grids....i did the dirty work. If you look at the image in the original zip file the grid starts 0_0 to 5_0.

// Grid00, 0 bandit groups, 1 soldier groups, 1 survivor groups - spawn probability ba,so,su - maximum group members ba,so,su
_check = [["max_grps","rnd_grps","max_p_grp"],[[0,1,1],[0,45,45],[0,2,2]],"SAR_area_0_0"] call SAR_AI_mon_upd;

// Grid01, 1 bandit groups, 1 soldier groups, 1 survivor groups - spawn probability ba,so,su - maximum group members ba,so,su
_check = [["max_grps","rnd_grps","max_p_grp"],[[1,1,1],[25,25,25],[2,2,2]],"SAR_area_0_1"] call SAR_AI_mon_upd;

// Grid02, 1 bandit groups, 1 soldier groups, 1 survivor groups - spawn probability ba,so,su - maximum group members ba,so,su
_check = [["max_grps","rnd_grps","max_p_grp"],[[1,1,1],[25,25,25],[2,2,2]],"SAR_area_0_2"] call SAR_AI_mon_upd;

// Grid03, 1 bandit groups, 1 soldier groups, 1 survivor groups - spawn probability ba,so,su - maximum group members ba,so,su
_check = [["max_grps","rnd_grps","max_p_grp"],[[1,1,1],[25,25,25],[2,2,2]],"SAR_area_0_3"] call SAR_AI_mon_upd;

// Grid04, 1 bandit groups, 1 soldier groups, 1 survivor groups - spawn probability ba,so,su - maximum group members ba,so,su
_check = [["max_grps","rnd_grps","max_p_grp"],[[1,1,1],[25,25,25],[2,2,2]],"SAR_area_0_4"] call SAR_AI_mon_upd;

// Grid05, 1 bandit groups, 1 soldier groups, 1 survivor groups - spawn probability ba,so,su - maximum group members ba,so,su
_check = [["max_grps","rnd_grps","max_p_grp"],[[1,1,1],[25,25,25],[2,2,2]],"SAR_area_0_5"] call SAR_AI_mon_upd;

// Grid1_0, 2 bandit groups, 2 soldier groups, 2 survivor groups - spawn probability ba,so,su - maximum group members ba,so,su
_check = [["max_grps","rnd_grps","max_p_grp"],[[2,2,2],[50,50,50],[3,5,3]],"SAR_area_1_0"] call SAR_AI_mon_upd;

// Grid1_1, 1 bandit groups, 1 soldier groups, 1 survivor groups - spawn probability ba,so,su - maximum group members ba,so,su
_check = [["max_grps","rnd_grps","max_p_grp"],[[1,1,1],[25,25,25],[2,2,2]],"SAR_area_1_1"] call SAR_AI_mon_upd;

// Grid1_2, 1 bandit groups, 1 soldier groups, 1 survivor groups - spawn probability ba,so,su - maximum group members ba,so,su
_check = [["max_grps","rnd_grps","max_p_grp"],[[1,1,1],[25,25,25],[2,2,2]],"SAR_area_1_2"] call SAR_AI_mon_upd;

// Grid1_3, 1 bandit groups, 1 soldier groups, 1 survivor groups - spawn probability ba,so,su - maximum group members ba,so,su
_check = [["max_grps","rnd_grps","max_p_grp"],[[1,1,1],[50,50,50],[2,4,2]],"SAR_area_1_3"] call SAR_AI_mon_upd;

// Grid1_4, 2 bandit groups, 2 soldier groups, 2 survivor groups - spawn probability ba,so,su - maximum group members ba,so,su
_check = [["max_grps","rnd_grps","max_p_grp"],[[2,2,2],[50,50,50],[3,5,3]],"SAR_area_1_4"] call SAR_AI_mon_upd;

// Grid1_5, 1 bandit groups, 1 soldier groups, 1 survivor groups - spawn probability ba,so,su - maximum group members ba,so,su
_check = [["max_grps","rnd_grps","max_p_grp"],[[1,1,1],[25,25,25],[2,2,2]],"SAR_area_1_5"] call SAR_AI_mon_upd;

// Grid2_0, 5 bandit groups, 2 soldier groups, 2 survivor groups - spawn probability ba,so,su - maximum group members ba,so,su
_check = [["max_grps","rnd_grps","max_p_grp"],[[5,2,2],[50,50,50],[1,4,2]],"SAR_area_2_0"] call SAR_AI_mon_upd;

// Grid2_1, 1 bandit groups, 1 soldier groups, 1 survivor groups - spawn probability ba,so,su - maximum group members ba,so,su
_check = [["max_grps","rnd_grps","max_p_grp"],[[1,1,1],[25,25,25],[2,2,2]],"SAR_area_2_1"] call SAR_AI_mon_upd;

// Grid2_2, 2 bandit groups, 1 soldier groups, 1 survivor groups - spawn probability ba,so,su - maximum group members ba,so,su
_check = [["max_grps","rnd_grps","max_p_grp"],[[2,1,1],[40,25,25],[4,2,2]],"SAR_area_2_2"] call SAR_AI_mon_upd;

// Grid2_3, 2 bandit groups, 1 soldier groups, 1 survivor groups - spawn probability ba,so,su - maximum group members ba,so,su
_check = [["max_grps","rnd_grps","max_p_grp"],[[2,1,1],[40,25,25],[4,2,2]],"SAR_area_2_2"] call SAR_AI_mon_upd;

// Grid2_4, 3 bandit groups, 1 soldier groups, 1 survivor groups - spawn probability ba,so,su - maximum group members ba,so,su
_check = [["max_grps","rnd_grps","max_p_grp"],[[3,1,1],[50,50,25],[4,5,2]],"SAR_area_2_4"] call SAR_AI_mon_upd;

// Grid2_5, 1 bandit groups, 1 soldier groups, 1 survivor groups - spawn probability ba,so,su - maximum group members ba,so,su
_check = [["max_grps","rnd_grps","max_p_grp"],[[1,1,1],[25,25,25],[2,2,2]],"SAR_area_2_5"] call SAR_AI_mon_upd;

// Grid3_0, 0 bandit groups, 1 soldier groups, 1 survivor groups - spawn probability ba,so,su - maximum group members ba,so,su
_check = [["max_grps","rnd_grps","max_p_grp"],[[0,1,1],[0,45,45],[0,2,2]],"SAR_area_3_0"] call SAR_AI_mon_upd;

// Grid3_1, 1 bandit groups, 1 soldier groups, 1 survivor groups - spawn probability ba,so,su - maximum group members ba,so,su
_check = [["max_grps","rnd_grps","max_p_grp"],[[1,1,1],[25,25,25],[2,2,2]],"SAR_area_3_1"] call SAR_AI_mon_upd;

// Grid3_2, 1 bandit groups, 1 soldier groups, 1 survivor groups - spawn probability ba,so,su - maximum group members ba,so,su
_check = [["max_grps","rnd_grps","max_p_grp"],[[1,1,1],[25,25,25],[2,2,2]],"SAR_area_3_2"] call SAR_AI_mon_upd;

// Grid3_4, 1 bandit groups, 1 soldier groups, 1 survivor groups - spawn probability ba,so,su - maximum group members ba,so,su
_check = [["max_grps","rnd_grps","max_p_grp"],[[1,1,1],[25,25,25],[2,2,2]],"SAR_area_3_4"] call SAR_AI_mon_upd;

// Grid3_5, 1 bandit groups, 1 soldier groups, 1 survivor groups - spawn probability ba,so,su - maximum group members ba,so,su
_check = [["max_grps","rnd_grps","max_p_grp"],[[1,1,1],[25,25,25],[2,2,2]],"SAR_area_3_5"] call SAR_AI_mon_upd;

// Grid4_0, 2 bandit groups, 1 soldier groups, 1 survivor groups - spawn probability ba,so,su - maximum group members ba,so,su
_check = [["max_grps","rnd_grps","max_p_grp"],[[2,1,1],[50,50,50],[2,4,3]],"SAR_area_4_0"] call SAR_AI_mon_upd;

// Grid4_1, 1 bandit groups, 1 soldier groups, 1 survivor groups - spawn probability ba,so,su - maximum group members ba,so,su
_check = [["max_grps","rnd_grps","max_p_grp"],[[1,1,1],[25,25,25],[2,2,2]],"SAR_area_4_1"] call SAR_AI_mon_upd;

// Grid4_2, 1 bandit groups, 1 soldier groups, 1 survivor groups - spawn probability ba,so,su - maximum group members ba,so,su
_check = [["max_grps","rnd_grps","max_p_grp"],[[1,1,1],[25,25,25],[2,2,2]],"SAR_area_4_1"] call SAR_AI_mon_upd;

// Grid4_3, 1 bandit groups, 1 soldier groups, 1 survivor groups - spawn probability ba,so,su - maximum group members ba,so,su
_check = [["max_grps","rnd_grps","max_p_grp"],[[1,1,1],[25,25,25],[2,2,2]],"SAR_area_4_3"] call SAR_AI_mon_upd;

// Grid4_4, 1 bandit groups, 1 soldier groups, 1 survivor groups - spawn probability ba,so,su - maximum group members ba,so,su
_check = [["max_grps","rnd_grps","max_p_grp"],[[1,1,1],[45,45,45],[2,2,2]],"SAR_area_4_4"] call SAR_AI_mon_upd;

// Grid4_5, 1 bandit groups, 1 soldier groups, 1 survivor groups - spawn probability ba,so,su - maximum group members ba,so,su
_check = [["max_grps","rnd_grps","max_p_grp"],[[1,1,1],[25,25,25],[2,2,2]],"SAR_area_4_5"] call SAR_AI_mon_upd;

// Grid5_0, 0 bandit groups, 1 soldier groups, 1 survivor groups - spawn probability ba,so,su - maximum group members ba,so,su
_check = [["max_grps","rnd_grps","max_p_grp"],[[0,1,1],[0,45,45],[0,2,2]],"SAR_area_0_0"] call SAR_AI_mon_upd;

// Grid5_1, 1 bandit groups, 1 soldier groups, 1 survivor groups - spawn probability ba,so,su - maximum group members ba,so,su
_check = [["max_grps","rnd_grps","max_p_grp"],[[1,1,1],[25,25,25],[2,2,2]],"SAR_area_5_1"] call SAR_AI_mon_upd;

// Grid5_2, 1 bandit groups, 1 soldier groups, 1 survivor groups - spawn probability ba,so,su - maximum group members ba,so,su
_check = [["max_grps","rnd_grps","max_p_grp"],[[1,1,1],[25,25,25],[2,2,2]],"SAR_area_5_2"] call SAR_AI_mon_upd;

// Grid5_3, 2 bandit groups, 1 soldier groups, 1 survivor groups - spawn probability ba,so,su - maximum group members ba,so,su
_check = [["max_grps","rnd_grps","max_p_grp"],[[2,1,1],[50,50,50],[2,4,3]],"SAR_area_5_3"] call SAR_AI_mon_upd;

// Grid5_4, 1 bandit groups, 1 soldier groups, 1 survivor groups - spawn probability ba,so,su - maximum group members ba,so,su
_check = [["max_grps","rnd_grps","max_p_grp"],[[1,1,1],[25,25,25],[2,2,2]],"SAR_area_5_4"] call SAR_AI_mon_upd;

// Grid5_5, 2 bandit groups, 2 soldier groups, 2 survivor groups - spawn probability ba,so,su - maximum group members ba,so,su
_check = [["max_grps","rnd_grps","max_p_grp"],[[2,2,2],[50,50,50],[3,5,3]],"SAR_area_5_5"] call SAR_AI_mon_upd;


Share this post


Link to post
Share on other sites

  • 8 months later...

Im only getting friendly AI no hostile... Also the chopper at the airfield, if i get it to land by shooting them, it disappears after 5 seconds of being on the ground and instantly respawns.

Share this post


Link to post
Share on other sites

Im only getting friendly AI no hostile... Also the chopper at the airfield, if i get it to land by shooting them, it disappears after 5 seconds of being on the ground and instantly respawns.

Share this post


Link to post
Share on other sites

  • 2 months later...

Hello All,

I realize this post is almost a year old, but we tried to implement SARGE AI per the instructions posted and have been unsuccessful. Would anyone happen to have any updated procedures for getting SARGE AI up and running on our new SS?

 

thanks

Share this post


Link to post
Share on other sites

Hello All,

I realize this post is almost a year old, but we tried to implement SARGE AI per the instructions posted and have been unsuccessful. Would anyone happen to have any updated procedures for getting SARGE AI up and running on our new SS?

 

thanks

Share this post


Link to post
Share on other sites

  • 1 month later...

hey everyone, so when i got my server SS installed sarge for me, the entire sar_config was missing, sarge still actually worked without it, but i decided to put the config file in my self, that worked perfect, apart from one thing, i have set the gun spawns for them in the config and they are still spawning with as50s even though i took them out, can seem to find any oher file other than the config that references ai or static spawned ai weapons, anyone got any idea why this would be happening?

Share this post


Link to post
Share on other sites

hey everyone, so when i got my server SS installed sarge for me, the entire sar_config was missing, sarge still actually worked without it, but i decided to put the config file in my self, that worked perfect, apart from one thing, i have set the gun spawns for them in the config and they are still spawning with as50s even though i took them out, can seem to find any oher file other than the config that references ai or static spawned ai weapons, anyone got any idea why this would be happening?

Share this post


Link to post
Share on other sites

  • 3 months later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...