5.5 Monster AI

In this chapter, a more detailed explanation of the monster's AI, artificial intelligence, is given. That is, it will explain how the monster decide what to do. It will also explain in more detail how monsters act in general. Basically one can say that a monster can do 3 different things; move in some way, attack in some way or stand still in some way.

5.5.1 General information

Just like a player, a monster will always have a specific action which it will be doing. Also, just as players, it must finish the current action before it can chose to do a new action. Some outside events may sometimes force a monster into a new specific action. Such events be the monster being hit and set into hit recover, a Fallen One retreating due to having a companion killed.

As explained in chapter 6, monsters, players and other things in the game are updated in a specific order and once every 0.05 seconds. During the update of each monster it will typically continue with the monster's current action and if it during the update reaches the end of that action it terminates it.

When a monster terminates an action, it will be set into stand mode. Stand mode is basically the monster doing nothing (note delaying is basically standing but for a predetermined time). The first thing that happens when a monster is set to stand mode is that it will check for a target. Thus, a monster always has a target, even if it is not activated and no enemy is in sight. For a description of target selection, see chapter 5.5.6. When a monster is in stand mode it will check for a new action by following a special script specific for the attack type the monster has. Note that a unique monster, and its mob if any, may have its attack type changed, see chapter 5.4, it will then follow the script of the new attack type. For a list of attack type for each monster, see chapter 5.3.3. The script may either end up in the monster being set into a new action type, or remaining in stand mode.

At any time, the game, for each monster, thus has complete knowledge of what target the monster has. It also knows where the target is and will as appropriate, calculate the distance to the target. It also always know what action the monster performed previous to being set to stand mode. In addition, while in stand mode, a special counter will keep track of how long the monster have been in stand mode. All this may often be important when going through the various scripts to decide the next action.

Within the scripts, some common tasks are very often performed either at the start or at the end. One of them is calculate the distance to its target. The game will also check the direction in which the target is located. This is usually used to determine in what direction the monster will walk. This chapter will not deal with path algorithms used, or explain how a monster walk. Many monsters will walk towards the target in the closest possible way, others will (at times depending on the distance to the target) instead walk around the target and so on. This chapter will generally just tell that the monster will chose to walk as its next action. Usually at the end of the script, if the monster is still in stand mode, it will turn around towards it target if necessary.

5.5.2 Activating monsters

All monsters on a new level starts in a non active state (monsters with the Hidden attack type are an exception as they are always active, see chapter 5.5.9 under the Hidden subsection). As soon as a monster is within a players light radius and the view between the monster and the player is not obstructed by walls, the monster will be activated. While not activated, most monsters will not act although some exceptions exists, see chapter 5.5.7. Examples of such exceptions are archers and Succubi still being able to fire at golems or if a monster is attacked in any way. When a monster leaves the light radius of a player, it will continue to act for 12.75 seconds until it is set into non active status again unless it during that time, again enter the light radius of a player or is "activated" again. Some monsters with the capability of following players outside their current view will try to walk around possible obstacles to get to the former target when it get out of the light radius. See chapter 5.3.3 for more information about which monsters have this capability.

5.5.3 About walking

There are several different ways monsters walk in the game. The exact nature of how monster walking is done will not always be described in detail. Some general comments is needed though. Below are given very general description of some common walk behavior. They are given as a general information. Changes and diversions may exists. Also, if while walking the path is blocked, monsters may behave slightly different. Some times it will try alternative paths and other times abort its walk and reconsider its action. Some monsters have very specific walk behavior and those will be described within the actual AI script.

Walking towards target: This means the monster will generally walk towards the target in the closes possible way. It will typically walk around smaller obstacles. Example of this walk type are The Hiddens and Skeletons.
Walking towards last seen position: Same as walking towards target, but the game will unless the target is within line of sight, walk towards the location where the target was last seen. This is not the same as having the ability to follow the target when it is out of line of sight. A monster will always walk towards the last seen position first before it tries to find a path to a target outside its current line of sight. If there is no such path it will simply walk around the last seen location until it is deactivated due to time. Example of this walk behavior is Balrogs, Gargoyles and Scavengers.
Walk away from target: Will try to walk away from target, this includes walking sideways if the path is blocked directly away from target. It will however not include walking past the target. A good example of this behavior is mages trying to escape from a player. This is also the reason why it is possible to trap monsters in corners. This type of walking is usually used for monsters retreating. Examples of monsters using this walk type is Hidden, Succubi, Archers and Mages.
Walk in circle: Many monsters uses the circling type of walk. It basically means the monster walks in a circular path around the target, often without either increasing nor decreasing the distance. Usually the monster using circular walk will once it has started that type of walking, do it until it has walked a distance equal to twice the current max distance to the target (max distance being the higher of the two distance values x and y in a coordinate system). It will also terminate the circle walk if it enters a new area or the distance to the target is reduced to 1. The direction will typically be chosen with a 50/50 chance for clockwise and counter clockwise. Examples of this walk type is Balrogs, lightning Demons, Spitters, Diablo and Skeleton King.

5.5.4 About charging

If a monster has the possibility to charge and it has been decided that it should charge, the game will check if there is really a path along which to charge that is not blocked by for example lava or a fence. If that is the case, the script will generally continue finding another action to perform as if it was decided to not charge.

5.5.5 About ranged attack

When the game has decided to do a ranged attack, it will check if line of sight is blocked. If that is the case, the script will generally continue finding another action to perform as if it was decided to not do a ranged attack. Note however, that this check many times will not detect all hindrance which may result in the ranged attack being performed but yet hit an obstacle before reaching the target.

5.5.6 Target selection

When a monster is to choose which player character to attack (if there is more than one present in the game) it will generally chose the one that is closest. However, the process of finding out who is the closest is somewhat non intuitive as the game does not calculate the true distance, but separates distances for the 2 main axis of the dungeon. This is most easily explained with an example.

  1. The dungeon is divided into several "squares" of which each square can hold a monster, player, or some dungeon inventory. Call the axis of squares running from the upper left to the lower right X, and the one running from lower left to the upper right Y.
  2. The game will then calculate the distance to each character separately for X and Y direction.
  3. It will then for each character use the largest distance of X and Y.
  4. Comparing the distance got from step 3, it will attack the one with the shortest distance.
  5. If two characters are equally close, the one that has first entered the game will be the target. It is thus wise to have Warriors enter and create a game, then have the Rogues enter it and finally the Sorcerers. If someone leaves the game, the next person to enter the game will take the place of the character that just left, not the last place.

A monster will, of course, only consider those characters, including golems, that are within its current visible range and are not out of sight due to a wall or other obstacle. Golems are only targeted if adjacent to the monster or if the monster is a skeleton archer, goat archer or succubi at any distance.

If the target ever disappears form the sight of the monster, it tends to walk up to the last position the target was seen. If the target is still not visible, it will try to pick a new target. Some monsters, as noted in chapter 5.3.3, have the ability to follow a target even if it is out of sight. In that case, they will not walk up to the last position of the target or stop, but will instead find the closest way to the target if it is not too far away.

5.5.7 Non even distributed random numbers

Diablo and Hellfire uses a pretty good algorithm for random numbers, unfortunately it is at times used improperly which result in somewhat non random results at time. One of those cases exists in the AI scripts of Spitters, Magma Demons, lightning Demons, Bone Demons and Diablo. Contrary to other AI scripts they use Rnd[10000] in some cases. Unfortunately the algorithm for random numbers only use 15 bits to calculate random numbers (it uses 32 bits internally but the random number is based on 15 bits only). This has the side effect that large values used in Rnd[x] will not be evenly distributed. In the case of Rnd[10000] lower values will be more common as there are really only 32 768 possible random integers. This is further complicated by the fact that the game then as a second random number in those AI scripts mentioned above uses a Rnd[100] but still compare the result as if it was a Rnd[10000] meaning the result will always default as if it was a low random number.

A further problem is the fact that the game reseeds the random number generator before processing the monsters. This is done to keep the game better in synch in multi player. Unfortunately this also cause problems in that monsters will not always act as they are supposed to, cause long streaks of the same result. An example is a monster missing continuously for almost an infinite time when they in fact should hit way more often due to having a auto To Hit for example (see chapter 5.1 under To Hit). This only affect monster behavior though, nothing else like item drops or the behavior of spells.

5.5.8 Reseed bug

In an attempt to keep monsters more in synch between computers in a multi player game, Blizzard has unfortunately used a rather strange and incorrect way of reseeding the random number generator in Diablo right before processing monsters (technically each monster has its own seed used for its behavior and it is the seeds of the monsters that are reseeded). This may cause the familiar result of a monster getting "stuck" with a particular behavior or result both when acting and when attacking. This is unfortunate.

5.5.9 AI scripts

Here each of the different attack types will be described. Many monsters, but not all, have special behavior types of an overreaching nature. Often composed of several actions performed in succession either until completed or aborted for some reason. They will be explained separately at the start of each script. A general section describes things usually performed every time. This includes a monster under an overreaching behavior.

The step by step instructions to follow are divided into several sections depending on the distance to the target. Use the appropriate one. Some times further conditions may also be given. For the specific step by step, you should use them in the following way. Always start at number 1. If at anytime it says goto #, where # is a number, immediately move to that line and continue from there. If it at any time says exit, the script has finished and you should not read any more. If you exit or reach the end without a new action being set, the monster will continue to stand and will check again 0.05 seconds later, that is during the next update, see chapter 6.1for more information about how the game updates monsters and other things.

The scripts will only refer to attack options such as melee attack or ranged attack. For information about what type of ranged attack monsters have, see chapter 4.2.

Finally note that although quite detailed, there might still be many special cases, exceptions and other smaller facts omitted. It is still my belief that it is a comprehensive explanation of each attack type that will cover almost all cases.


Some common abbreviations are used in this chapter:
D Distance to target. A distance of 1 means the target is adjacent ( see chapter 6.1.9 for a description on how to calculate distance to a walking target).
R Usually a random number, the specific script will tell exactly how the random number is achieved.
Intf Intelligence factor, see chapter 5.3.3 and 5.4.
light Refers to the light radius of players.
 
Zombie
General
  1. if out of light, exit
  2. R = Rnd[100]
Distance = 1
  1. if R < 2·Intf + 10, do melee attack, exit
  2. continue to stand still
Distance = 2 to 2·Intf + 3
  1. if R < 2·Intf + 10, walk towards target, exit
  2. continue to stand still
Distance > 2·Intf + 3
  1. if R >= 2·Intf + 10, continue to stand still, exit
  2. calculate new R = Rnd[100]
  3. if R < 2·Intf + 20, walk in random direction (if blocked, continue to stand still), exit
  4. continue to walk in the same direction as last time (if blocked, continue to stand still)
Fallen One
When a monster is killed, any Fallen Ones within 5 squares will be set into retreat mode. Depending on what subtype the monster is the distance it will retreat is as explained in the table below. The distance is the distance it will walk, not necessarily the final distance to the target if the target has moved since the start of the retreat.

Fallen Ones Retreat distance
Fallen One 7
Carver 5
Devil Kin 3
Dark One 2

Occasionally a Fallen One will do a war cry. It is recognized by the monster jumping up and screaming. When that happens any Fallen One within range (see table below), unless using another attack type, will be set into war cry mode. The war cry mode last for a specific time depending on the subtype doing the actual war cry, see table below. During the war cry mode, they will walk straight for the closest target and attack. If adjacent it will continue to attack without pausing until the time runs out for the war cry mode. Unfortunately the war cry mode also ends as soon as any close by monster is killed and the fallen one is set into retreat mode.

Fallen Ones Distance Time (sec)
Fallen One 4 5.25
Carver 5 6.75
Devil Kin 6 8.25
Dark One 7 9.75

When doing a war cry, the monster will gain 2·Intf + 2 hit points. The current hit points will never go above the maximum value though.
 
War cry
  1. if D = 1, do melee attack, exit
  2. walk towards target
Retreating
  1. Walk away from target until distance achieved
General
  1. if not active, exit
  2. if the monster has been standing for an even multiple of 0.55 seconds (0.60 if using a sword) and Rnd[4] = 0, do war cry, exit
  3. if not active, exit
  4. R = Rnd[100]
Distance = 1
  1. if last action was delay, do melee attack, exit
  2. if R < 2·Intf + 20, do melee attack, exit
  3. do delay for (Rnd[10] + 10 - 2·Intf)/20 seconds
Distance > 1
  1. if last action was delay, walk towards last seen position of target, exit
  2. if R < 4·Intf + 65, walk towards last seen position of target, exit
  3. do delay for (Rnd[10] + 15 - 2·Intf)/20 seconds
Skeleton
General
  1. if not active, exit
  2. R = Rnd[100]
Distance = 1
  1. if last action was delay, do melee attack, exit
  2. if R < 2·Intf + 20, do melee attack, exit
  3. do delay for (Rnd[10] + 10 - 2·Intf)/20 seconds
Distance > 1
  1. if last action was delay, walk towards last seen position of target, exit
  2. if R < 4·Intf + 65, walk towards last seen position of target, exit
  3. do delay for (Rnd[10] + 15 - 2·Intf)/20 seconds
Skeleton Archer
General
  1. if not active, exit
  2. R = Rnd[100]
Distance = 1 to 3
  1. if last action was walking and standtime is 0 and R < 2·Intf + 63, walk away from target, exit
  2. if standtime is greater than 1 second and R < 2·Intf + 13, walk away from target, exit
Distance > 3
  1. if R < 2·Intf + 3, do ranged attack
Scavenger
The Scavenger AI has a special eating/digging mode activated when their HP reaches a low enough value. It will then seek the closes carcass of a dead monster within sight and walk up to it to eat/dig. While eating/digging, it will generate HP faster than normally, see chapter 5.1 under Hit Points for more information.
Eating/Digging
  1. if monster is part of a unique monsters mob, remove it from mob
  2. if at carcass, go into eat/dig mode, exit
  3. walk towards closest carcass
General
  1. if curHP < maxHP/2, set eating/digging mode, exit
  2. if not active, exit
  3. R = Rnd[100]
Distance = 1
  1. if last action was delay, do melee attack, exit
  2. if R < 2·Intf + 20, do melee attack, exit
  3. do delay for (Rnd[10] + 10 - 2·Intf)/20 seconds
Distance > 1
  1. if last action was delay, walk towards last seen position of target, exit
  2. if R < 4·Intf + 65, walk towards last seen position of target, exit
  3. do delay for (Rnd[10] + 15 - 2·Intf)/20 seconds
Winged Fiends
The Winged Fiend AI has a special retreat mode activated after having done a melee attack. It consists of walking away from the target on location and then walking into new adjacent location of the target. The result is a sort of V shaped walk.
Retreat
  1. if last volunteer action, except walk, was not attack, exit from Retreat mode
  2. if last walk was away from target, randomly walk either to the right or the left of target, exit
  3. walk away from target
General
  1. if not active, exit
  2. R = Rnd[100]
Distance = 1
  1. if R < 4·Intf + 8, do melee attack
  2. if R < 4·Intf + 8 and the monster is a familiar, spawn lightning bolt attack
Distance = 2 to 3
  1. if last action was walking and standtime is 0 and R < Intf + 63, walk towards target, exit
  2. if standtime is greater than 1 second and R < Intf + 13, walk towards target
Distance > 3
  1. if R < 4·Intf + 33 and the monster is a Gloom, do charge
  2. if last action was walking and standtime is 0 and R < Intf + 63, walk towards target, exit
  3. if standtime is greater than 1 second and R < Intf + 13, walk towards target
Hidden
As soon as a monster having the Hidden attack type, even if it is not a The Hiddens monster type, is stunned, it will retreat. Usually away from the player but the Unseen will instead move diagonally away. The distance it will retreat is explained in the table below. If the current target is a monster, away is defined as away form the controlling player.

Intelligence factor Retreat distance
0 8
1 7
2 6
3 5

Hiddens are always active, that is, they move around regardless if you have activated them or not.
Retreat
  1. if the monster is an Unseen, retreat diagonally randomly to the right or left, away from the target, exit
  2. retreat straight away from target
General
  1. R = Rnd[100]
  2. if D < 5 - Intf and not visible, fade in, exit
  3. if D > 5 - Intf and visible, fade out, exit
Distance = 1
  1. if R < 4·Intf + 10, do melee attack
Distance > 1
  1. if last action was walking and standtime is 0 and R < Intf + 64, walk towards target, exit
  2. if standtime is greater than 1 second and R < Intf + 14, walk towards target
Goat Man
When finishing a circle walk, a monster using the Goat Man attack type will start walking towards the last seen position of the target.
General
  1. if not active, exit
  2. R = Rnd[100]
Distance = 1
  1. if R >= 2·Intf + 23, exit
  2. if curHP >= maxHP/2, do melee attack, exit
  3. if Rnd[2] = 0, do melee attack, exit
  4. do special spin attack
Distance > 1, out of light
  1. if last action was walking and standtime is 0 and R < 2·Intf + 78, walk towards last seen position of target, exit
  2. if standtime is greater than 1 second and R < 2·Intf + 28, walk towards last seen position of target
Distance = 1 to 3, in light
  1. if target is in another area, use out of light AI
  2. if last action was walking and standtime is 0 and R < 2·Intf + 78, walk towards last seen position of target, exit
  3. if standtime is greater than 1 second and R < 2·Intf + 28, walk towards last seen position of target
Distance > 3, in light
  1. if target is in another area, use out of light AI
  2. if D > 3 and Rnd[4] = 0, start circle walk, exit
  3. if last action was walking and standtime is 0 and R < 2·Intf + 78, walk towards last seen position of target, exit
  4. if standtime is greater than 1 second and R < 2·Intf + 28, walk towards last seen position of target
Overlord
General
  1. if not active, exit
  2. R = Rnd[100]
Distance = 1
  1. if R < 4·Intf + 15, do melee attack, exit
  2. if R < 4·Intf + 20, do second melee attack
Distance > 1
  1. if last action was walking and standtime is 0 and R < Intf + 70, walk towards target, exit
  2. if standtime is greater than 1 second and R < Intf + 20, walk towards target
Gargoyle
By stone state is meant when in actual stone form. By stone mode is meant both when in stone state and while moving away from a target due to low HP. While in stone state, Gargoyles will heal faster than usual, see chapter 5.1.
When finishing a circle walk, a monster using the Gargoyle attack type will start walking towards the last seen position of the target.
Stone mode
  1. if D < Intf + 2, mark as not in stone mode
  2. if curHP >= maxHP/2, mark as not in stone mode
  3. if D >= Intf + 2, go into stone state, exit
  4. walk away from target
General
  1. if not active, exit
  2. R = Rnd[100]
  3. if curHP < maxHP/2, go into stone mode
Distance = 1
  1. if R >= 2·Intf + 23, exit
  2. do melee attack
Distance > 1, out of light
  1. if last action was walking and standtime is 0 and R < 2·Intf + 78, walk towards last seen position of target, exit
  2. if standtime is greater than 1 second and R < 2·Intf + 28, walk towards last seen position of target
Distance 1 to 3, in light
  1. if target is in another are, use out of light AI
  2. if last action was walking and standtime is 0 and R < 2·Intf + 78, walk towards last seen position of target, exit
  3. if standtime is greater than 1 second and R < 2·Intf + 28, walk towards last seen position of target
Distance > 1, in light
  1. if target is in another are, use out of light AI
  2. if D > 3 and Rnd[4] = 0, start circle walk, exit
  3. if last action was walking and standtime is 0 and R < 2·Intf + 78, walk towards last seen position of target, exit
  4. if standtime is greater than 1 second and R < 2·Intf + 28, walk towards last seen position of target
Goat Archer
General
  1. if not active, exit
  2. if out of sight of target and it is a player, walk towards last seen position of target, exit
  3. R = Rnd[100]
  4. if last action was a ranged attack, de delay for Rnd[20]/20 seconds, exit
Distance = 1 to 3
  1. if R < 10·Intf + 70, walk away from target, exit
Distance > 3
  1. do ranged attack
Fast Spit
General
  1. if not active, exit
  2. if out of sight of target and it is a player, walk towards last seen position of target, exit
  3. R = Rnd[100]
Distance = 1 to 3
  1. if R < 10·Intf + 70, walk away from target, exit
Distance > 3
  1. do ranged attack
Magma Demon
When finishing a circle walk, a monster using the Magma Demon attack type will start walking towards the last seen position of the target.
Circle Walk
  1. If R < 100·(5·Intf + 5), do ranged attack, exit (after this ranged attack, the monster will resume circle walk)
  2. continue with circle walk
General
  1. if not active, exit
  2. R = Rnd[10000]
Distance = 1
  1. if R < 100·(5·Intf + 5), do ranged attack, exit
  2. if R < 100·(10·Intf + 60), do attack, exit
  3. do delay for (Rnd[10] + 5)/20 seconds
Distance > 1, out of light
  1. calculate new R = Rnd[100]
  2. if R < 100·(10·Intf + 50), walk towards last seen position of target, exit
  3. if last action was walking and standtime is 0 and R < 100·(10·Intf + 80), walk towards last seen position of target, exit
  4. do delay for (Rnd[10] + 5)/20 seconds
Distance = 2, in light
  1. if target is in another area, use out of light AI
  2. if R < 100·(5·Intf + 5), do ranged attack, exit
  3. calculate new R = Rnd[100]
  4. if R < 100·(10·Intf + 50), walk towards last seen position of target, exit
  5. if last action was walking and standtime is 0 and R < 100·(10·Intf + 80), walk towards last seen position of target, exit
  6. do delay for (Rnd[10] + 5)/20 seconds
Distance > 2, in light
  1. if target is in another area, use out of light AI
  2. if Rnd[4] = 0, start circle walk, exit
  3. if R < 100·(5·Intf + 10), do ranged attack, exit
  4. calculate new R = Rnd[100]
  5. if R < 100·(10·Intf + 50), walk towards last seen position of target, exit
  6. if last action was walking and standtime is 0 and R < 100·(10·Intf + 80), walk towards last seen position of target, exit
  7. do delay for (Rnd[10] + 5)/20 seconds
Due to using Rnd[10000], the random number will not be evenly distributed, see chapter 5.5.7. In the steps where a new R = Rnd[100] is calculated, it is not a typo of mine, but most likely a bug and should have read R = Rnd[10000]
Viper
Monsters with the Viper attack type will not walk straight towards the location of the monster as most other monsters. Instead, it will use a sort of winding walk. It will go through a cycle and the walk direction it aims for is slightly of either clockwise or counterclockwise (if the correct direction is north, it will aim for a direction either northwest or northeast). If the monster is then not facing this new direction, it will turn one step towards it and walk in that direction. The table below summarize how the cycle of aimed direction is done.

Cycle step change of direction New aimed direction
N NE E SE S SW W NW
1 counterclockwise NW N NE E SE S SW W
2 counterclockwise NW N NE E SE S SW W
3 none N NE E SE S SW W NW
4 clockwise NE E SE S SW W NW N
5 clockwise NE E SE S SW W NW N
6 none N NE E SE S SW W NW

General
  1. if not active, exit
  2. R = Rnd[100]
Distance = 1
  1. if last action was delay or charge, do attack, exit
  2. if R < Intf + 20, do attack, exit
  3. do delay for (Rnd[10] + 10 - Intf)/20 seconds
Distance = 2
  1. if last action was charge, act as distance > 2
  2. if charge is not possible, act as distance > 2
  3. do charge
Distance > 2
  1. if last action was delay, walk, exit
  2. if R < 2·Intf + 65, walk, exit
  3. do delay for (Rnd[10] + 15 - Intf)/20 seconds
Spit
When finishing a circle walk, a monster using the Spit attack type will start walking towards the last seen position of the target.
Circle Walk
  1. If R < 100·(5·Intf + 5)/2, do ranged attack, exit (after this ranged attack, the monster will resume circle walk)
  2. continue with circle walk
General
  1. if not active, exit
  2. R = Rnd[10000]
Distance = 1
  1. if R < 100·(5·Intf + 5)/2, do ranged attack, exit
  2. if R < 100·(10·Intf + 60), do attack, exit
  3. do delay for (Rnd[10] + 5)/20 seconds
Distance > 1, out of light
  1. calculate new R = Rnd[100]
  2. if R < 100·(10·Intf + 50), walk towards last seen position of target, exit
  3. if last action was walking and standtime is 0 and R < 100·(10·Intf + 80), walk towards last seen position of target, exit
  4. do delay for (Rnd[10] + 5)/20 seconds
Distance = 2, in light
  1. if target is in another area, use out of light AI
  2. if R < 100·(5·Intf + 5)/2, do ranged attack, exit
  3. calculate new R = Rnd[100]
  4. if R < 100·(10·Intf + 50), walk towards last seen position of target, exit
  5. if last action was walking and standtime is 0 and R < 100·(10·Intf + 80), walk towards last seen position of target, exit
  6. do delay for (Rnd[10] + 5)/20 seconds
Distance > 2, in light
  1. if target is in another area, use out of light AI
  2. if Rnd[8] = 0, start circle walk, exit
  3. if R < 100·(5·Intf + 10)/2, do ranged attack, exit
  4. calculate new R = Rnd[100]
  5. if R < 100·(10·Intf + 50), walk towards last seen position of target, exit
  6. if last action was walking and standtime is 0 and R < 100·(10·Intf + 80), walk towards last seen position of target, exit
  7. do delay for (Rnd[10] + 5)/20 seconds
Due to using Rnd[10000], the random number will not be evenly distributed, see chapter 5.5.7. In the steps where a new R = Rnd[100] is calculated, it is not a typo of mine, but most likely a bug and should have read R = Rnd[10000]
Butcher
  1. if not active, exit
  2. if D =1, attack, exit
  3. walk towards target
Balrog
When finishing a circle walk, a monster using the Balrog attack type will start walking towards the last seen position of the target.
General
  1. if not active, exit
  2. if D > 4, continue with skeleton AI, exit
  3. R = Rnd[10000]
Distance = 1
  1. if R < 5·Intf + 5, do spell attack, exit
  2. calculate new R = Rnd[100]
  3. if R >= 10·Intf + 40, do delay for (Rnd[10] + 5)/20 seconds, exit
  4. if Rnd[2] = 0, do spell attack, exit
  5. do melee attack
Distance > 1, out of light
  1. if R < 10·Intf + 50, walk towards last seen position of target, exit
  2. if last action was walk and R < 10·Intf + 80, walk towards last seen position of target, exit
  3. do delay for (Rnd[10] + 5)/20 seconds
Distance = 2, in light
  1. if last action was circle walk, do spell attack, exit
  2. if R < 5·Intf + 5, do spell attack, exit
  3. calculate new R = Rnd[100]
  4. if R < (10·Intf + 50), walk towards last seen position of target, exit
  5. if last action was not walk, walk towards last seen position of target, exit
  6. do delay for (Rnd[10] + 5)/20 seconds
Distance > 2, in light
  1. if target is in same area, start circle walk, exit
  2. if last action was circle walk, do spell attack, exit
  3. if R < 5·Intf + 10, do spell attack, exit
  4. calculate new R = Rnd[100]
  5. if R < (10·Intf + 50), walk towards last seen position of target, exit
  6. if last action was not walk, walk towards last seen position of target, exit
  7. do delay for (Rnd[10] + 5)/20 seconds
Skeleton King
When finishing a circle walk, a monster using the Skeleton King attack type will start walking towards the last seen position of the target.
General
  1. if not active, exit
  2. R = Rnd[10000]
Distance = 1
  1. in single player, if R < 5, then do revive skeleton, exit
  2. if R < Intf + 20, do melee attack
Distance > 1, out of liight
  1. if last action was walking and standtime is 0 and R < Intf + 75, walk towards last seen position of target, exit
  2. if standtime is greater than 1 second and R < Intf + 25, walk towards last seen position of target, exit
  3. do delay for (Rnd[10] + 10)/20 seconds
Distance = 2, in light
  1. in single player, if R < 5, then do revive skeleton, exit
  2. if last action was walking and standtime is 0 and R < Intf + 75, walk towards last seen position of target, exit
  3. if standtime is greater than 1 second and R < Intf + 25, walk towards last seen position of target, exit
  4. do delay for (Rnd[10] + 10)/20 seconds
Distance > 2, in light
  1. if target is in another area, use out of light AI
  2. if Rnd[4] = 0, start circle walk, exit
  3. in single player, if 4·Intf + 35, then do revive skeleton, exit
  4. if last action was walking and standtime is 0 and R < Intf + 75, walk towards last seen position of target, exit
  5. if standtime is greater than 1 second and R < Intf + 25, walk towards last seen position of target, exit
  6. do delay for (Rnd[10] + 10)/20 seconds
Horned Demon
When finishing a circle walk, a monster using the Horned Demon attack type will start acting normally but will not pick circle walk as its next action.
General
  1. if not active, exit
  2. R = Rnd[10000]
Distance = 1
  1. if R < 2·Intf + 28, do melee attack, exit
Distance = 2 to 4
  1. if last action was walking and standtime is 0 and R < 2·Intf + 33, walk towards last seen position of target, exit
  2. if standtime is greater than 1 second and R < 2·Intf + 83, walk towards last seen position of target
  3. do delay for (Rnd[10] + 10)/20 seconds
Distance > 4
  1. if target is in same area Rnd[4] > 0 then start circle walk
  2. if R < 2·Intf + 43 and the line of sight is clear, do charge attack, exit
  3. if last action was walking and standtime is 0 and R < 2·Intf + 33, walk towards last seen position of target, exit
  4. if standtime is greater than 1 second and R < 2·Intf + 83, walk towards last seen position of target
  5. do delay for (Rnd[10] + 10)/20 seconds
Mage
Mages have the ability to disappear (phase in and phase out), much like The Hiddens. They will phase out whenever they initiate any walking (including circle walk). When the walking is over, even if it is in the same location as they started the walk, they will phase in. Thus one can say that they are non visible while walking.
When finishing a circle walk, a monster using the Mage attack type will start walking towards the last seen position of the target.
Retreat mode
  1. if D < 3, walk away from target
General
  1. if not active, exit
  2. R = Rnd[10000]
Distance = 1
  1. if curHP < maxHP/2, go into retreat mode
  2. if last action was a delay, do flash attack, exit
  3. if R < 2·Intf + 20, do flash attack, exit
  4. do delay for (Rnd[10] + 10 - 2·Intf)/20 seconds
Distance > 1
  1. if in light and R < 5·Intf + 50, do ranged attack, exit
  2. calculate new R = Rnd[100]
  3. if R < 30, enter circle walk, exit
  4. do delay for (Rnd[10] + 10 - 2·Intf)/20 seconds
Special
Special AI scripts are used for most quest monsters. For those not mentioned specifically previously, the only difference from a normal AI script of that monster type is quest related things such as talking. The actual AI behavior when you fight those monsters are identical to the normal AI and is summarized in the table below.

Unique monster AI script to use
Snotspill Fallen One
Gharbad the Weak Goat Man
Blackjade Succubi
Red Vex Succubi
Warlord of Blood Skeleton
Lachdanan n/a
Zhar the Mad Mage
Arch-Bishop Lazarus Mage