[Server Hosting] How to create AI Patrols - salutesh/DayZ-Expansion-Scripts GitHub Wiki
Overview of most recent changes
Expansion 1.9.0 (2024-07-25)
- Added
"Persist"
option Jump To(#Persist) - Added new possible value
"RANDOM"
for"Faction"
option Jump To(#Faction) - Added new possible value
"ROAMING"
for"Behaviour"
option Jump To(#Behaviour) - Changed
"UnlimitedReload"
to a bitmask to allow different behavior per target type Jump To(#UnlimitedReload)
1) Finding AIPatrolSettings.json
Inside your mpmissions/dayzoffline.mapname/expansion/settings/
you will find the AIPatrolSettings.json
2) Adding a new Patrol
Each patrol will have the follow config:
{
"Name": "USA Soldiers Sector A",
"Persist": 0,
"Faction": "West",
"Formation": "RANDOM",
"FormationLooseness": 2.0,
"Loadout": "MyLoadout",
"Units": [],
"NumberOfAI": 4,
"Behaviour": "ALTERNATE",
"Speed": "WALK",
"UnderThreatSpeed": "SPRINT",
"CanBeLooted": 1,
"UnlimitedReload": 0,
"SniperProneDistanceThreshold": 500,
"AccuracyMin": -1.0,
"AccuracyMax": -1.0,
"ThreatDistanceLimit": -1.0,
"DamageMultiplier": -1.0,
"MinDistRadius": -2.0,
"MaxDistRadius": -2.0,
"DespawnRadius": -2.0,
"MinSpreadRadius": 1.0,
"MaxSpreadRadius": 100.0,
"Chance": 1.0,
"WaypointInterpolation": "",
"DespawnTime": -1.0,
"RespawnTime": -2.0,
"UseRandomWaypointAsStartPoint": 1,
"Waypoints": [
[
X,
Y,
Z
],
[
X,
Y,
Z
] <=== without a comma if it's the last waypoint
]
} <=== without a comma if it's the last patrol
Name
Allow you to give a name for each patrol so you know what is what. It is also used as the group name in logs.
Persist
If Name
is given and unique, alive patrol members will be saved when despawning (also at server restarts) and restored with all their gear at the last position when respawning. Note this is only supported for Patrols
, not ObjectPatrols
.
Faction
This setting allows you to specify what faction this patrol will be in. You can currently choose between these factions:
- West -> Friendly toward Civilian and West
- East -> Friendly toward Civilian and East
- Raiders -> Hostile toward everyone, including other Raiders (unless they are part of the same group)
- Mercenaries -> Hostile toward everyone except other Mercenaries
- Civilian -> Friendly toward any faction that is not hostile to them (so by default, West, East, Civilian, Passive and Guards)
- Passive -> Completely passive, will not even look at other entities.
- Guards -> Always friendly toward other guards, friendly toward other AI and players as long as they don't raise their weapon
- InvincibleGuards -> Like guards, but can't be killed.
- Shamans -> Friendly towards other shamans, won't attack or be attacked by Zs and animals
- Observers -> Will only look at other entities, but not engage in combat.
- InvincibleObservers -> Like observers, but can't be killed.
- YeetBrigade -> Same as guard faction but won't pick up weapons and has insanely strong melee (one-shots bears with their fists) that send their victim flying. More of a showcase for faction abilities than something you should actually use.
- InvincibleYeetBrigade -> Like YeetBrigade, but can't be killed.
- Brawlers -> Friendly toward Civilian and Brawlers. Very strong melee (not as strong as YeetBrigade) that can one-shot Infected with fists.
- RANDOM -> Chooses one of the above factions that are not invincible, observer or passive and don't have special melee abilities.
Formation
Formation of the group. Valid values Column
, File
, Vee
, Wall
or RANDOM
.
FormationLooseness
How much spread apart the AI will be between each others. In meters.
Loadout
The name of your loadout.json containing the weapons, outfit and gear they will carry with them. For example "HumanLoadout"
Units
If you want specific AI to spawn, enter the eAI classnames here, else leave empty. Note that it will pick classnames randomly from the list UNLESS you set NumberOfAI
(see below) to EXACTLY the number of classnames you enter here (in which case it will spawn the exact set you entered).
Example:
"Units": [
"eAI_SurvivorF_Eva",
"eAI_SurvivorM_Mirek",
"eAI_SurvivorF_Judy",
"eAI_SurvivorM_Guo"
],
NumberOfAI
How many AI will be in this patrol.
If you set this setting to a negative number, the system will spawn a random amount of AI between 1 and the specified number with the sign removed.
For example -6 will tell the game to spawn between 1 and 6 AI.
Behaviour
Desired behaviour of your patrol.
- HALT -> The patrol won't move
- LOOP -> The patrol will follow the waypoints from start to finish, then return to start and repeat. Should only be used if the last waypoint is close to the first waypoint, as the AI will just go in a more or less straight line from finish back to start.
- ALTERNATE -> The patrol will follow the waypoints from start to finish, then from finish to start and repeat
- HALT_OR_ALTERNATE -> The patrol will spawn with a random behaviour of either HALT or ALTERNATE
- HALT_OR_LOOP -> The patrol will spawn with a random behaviour of either HALT or LOOP
- ROAMING -> Only the starting waypoint will be used, then the AI will go off and pick destination locations on its own and also loot more items (i.e. clothing) than just weapons.
Speed
Maximum speed allowed for the AI when not in combat.
- STATIC
- WALK
- JOG
- SPRINT
- RANDOM -> will give a result between STATIC and SPRINT
- RANDOM_NONSTATIC -> will give a result between WALK and SPRINT
UnderThreatSpeed
Maximum speed allowed for the AI when in combat.
- STATIC
- WALK
- JOG
- SPRINT
- RANDOM -> will give a result between STATIC and SPRINT
- RANDOM_NONSTATIC -> will give a result between WALK and SPRINT
CanBeLooted
If set to 1, AI can be looted once dead. If set to 0, they cannot be looted (the item in their hand can still be taken as it will drop to the ground)
UnlimitedReload
Bitmask. If set to any non-zero value (see below), AI will be able to reload infinitely if they have a spare mag or ammo in their inventory (mags will refill automagically).
- 0 -> Off
- 1 -> All targets
- 2 -> Animals
- 4 -> Infected
- 8 -> Players
- 16 -> Vehicles
Values other than 1 can be added together to combine them. E.g. a value of 6
means only allow unlimited reload if current AI target is an animal or Infected.
SniperProneDistanceThreshold
Minimum distance in meters before an AI holding a bolt action rifle will go prone to engage a target. If the target is closer, AI won't go prone. Setting to 0 disables prone completely.
AccuracyMin
Minimum accuracy of this patrol (0.0-1.0)
- If set to -1 will use the AccuracyMin setting used on the top of the config file.
AccuracyMax
Maximum accuracy of this patrol (0.0-1.0)
- If set to -1 will use the AccuracyMax setting used on the top of the config file.
ThreatDistanceLimit
Distance in meters when the target will start be considered a potential threat
- If set to -2 will use the setting used on the top of the config file.
DamageMultiplier
Damage multiplier from the AI (0.1-2.0). Base damage they will deal multiplied by this value.
- If set to -2 will use the setting used on the top of the config file.
DespawnRadius
The required distance from a player to despawn. If a player is closer than DespawnRadius meters, then the patrol won't despawn.
- If set to -2 will use the DespawnRadius setting used on the top of the config file.
MinDistRadius
The required minimum distance from a player to spawn. If a player is closer than MinDistRadius meters, then the patrol won't spawn
- If set to -2 will use the MinDistRadius setting used on the top of the config file.
MaxDistRadius
The required maxium distance from a player to spawn. If a player is further away than MaxDistRadius meters, then the patrol won't spawn
- If set to -2 will use the MinDistRadius setting used on the top of the config file.
MinSpreadRadius/MaxSpreadRadius
This setting allows you to make each of your waypoints randomized in a radius defined by min/max spread. If you want your waypoints to be accurate, keep this setting at 0.
Chance
Spawn chance for this patrol as a value between 0.0 (0%) and 1.0 (100%).
DespawnTime
How long will it take for the patrol to despawn if no players are in MaxDistRadius.
- If set to -1 will use the DespawnTime setting used on the top of the config file.
RespawnTime
How long until this patrol can respawn?
- If set to -1 they won't respawn
- If set to -2 will use the RespawnTime setting used on the top of the config file.
WaypointInterpolation
If any interpolation should be used on the given waypoints to smooth out the path at turns. Valid values CatmullRom
, NaturalCubic
, UniformCubic
or empty string (no interpolation).
To illustrate the difference using four waypoints arranged in a zig-zag pattern, look at the following image (image is more exaggerated than the result you will get, as we have an angle threshold of 5 degrees and a distance threshold of 4.5 meters to limit the number of generated points):
Waypoints
A list of positions the patrols will have to go to.
This is how it should look like once configured
{
"Name": "BDU Group inland",
"Persist": 0,
"Faction": "West",
"Loadout": "BDUSoldierLoadout",
"NumberOfAI": 4,
"Behaviour": "ALTERNATE",
"Speed": "WALK",
"UnderThreatSpeed": "SPRINT",
"CanBeLooted": 1,
"UnlimitedReload": 0,
"SniperProneDistanceThreshold": 0.0,
"AccuracyMin": -1.0,
"AccuracyMax": -1.0,
"ThreatDistanceLimit": -1.0,
"DamageMultiplier": -1.0,
"MinDistRadius": -2.0,
"MaxDistRadius": -2.0,
"DespawnRadius": -2.200000047683716,
"MinSpreadRadius": 1.0,
"MaxSpreadRadius": 100.0,
"Chance": 1.0,
"WaypointInterpolation": "CatmullRom",
"DespawnTime": -1.0,
"RespawnTime": -2.0,
"UseRandomWaypointAsStartPoint": 1,
"Waypoints": [
[
4211.22265625,
109.02338409423828,
6382.064453125
],
[
4151.66259765625,
105.45065307617188,
6080.29443359375
],
[
4160.9716796875,
105.41259765625,
6035.10302734375
],
[
4160.69921875,
106.25148010253906,
5906.830078125
],
[
4107.86279296875,
108.93052673339844,
5898.48291015625
],
[
4057.258056640625,
114.17473602294922,
5584.595703125
],
[
4084.56005859375,
113.232421875,
5494.5400390625
],
[
4079.30810546875,
113.80116271972656,
5435.953125
],
[
4081.73583984375,
113.40250396728516,
5385.576171875
],
[
4067.26611328125,
109.78838348388672,
4904.5087890625
],
[
4126.5048828125,
107.37117767333985,
4647.12890625
]
]
}