Monster behaviour

So, I think it would be an interesting read if I explained how monster behaviour is configured in DoC.  Apologies if not.

I would not call my monster behaviour routine ‘AI’ because for me ‘intelligence’ would entail that the entity would either make an attempt to define winning vs. loosing behaviour and make preferential choices, or (far beyond that) observe and understand the rules that a fight follows and define experimental strategies.  Computer enemies in most games do neither of these two.  Mine is no exception.

That is simply because half-arsed AI is not impressive or enjoyable at all.  Predictable but unique monster behaviours is however.  You learn how a monster behaves and adapt, preferably as a required step to actually beat it.

So here is how monsters behave in DoC (as at 1.6.4.  Maybe I will expand this later):

Each monster has a starting number of spell points, and a certain extent of ability to regenerate them. For some this is relevant, other monsters don’t use spell points at all.

Each monster then has a unique set of actions (between 2 and 12 is normal), each consisting of:

– the minimum and maximum distance to the closest player, as a condition to determine if an action is considered when it is the monsters turn.

– required pre-condition.  this is also checked to see if the action is ‘available’.  The boss spider for example has an action that spawns a brawler spider, but only if the precondition ‘50% hp’ is met.  So essentially the boss spider spawns an ally when it lost half its hit points. a really good trigger mechanism that most games use for boss monsters for example, makes the fight tougher after initially looking to work out or the player.  ‘placetomove’ is another common precondition used for the ‘advance’ action.  most actions have ‘none’ though.

– spell points required. zero for most actions, but spell casters obviously have spells that manifest themselves as actions, and they can run out of spell points to use these.  There is also a monster action called ‘blood ritual’ which has a negative spell points requirement, effectively meaning that the monster recharges its spell points.

– ‘recharge needed’ and ‘recharge counter at start’ combined are a very important parameter. walking or hitting or shooting takes time, but those basic actions do not have a recharge counter.  any special ability does though.  for example an orc may call for help, effectively spawning another orc or two at the fight arenas edge.  This ability has a ‘recharge needed’ of 700, which equates to about 7 turns.  The ‘counter at start’ is 400 so at the start of the fight the orc is 3 turns away from having this action available to him.  Setting ‘counter’ to 1000001 and ‘at start’ to 1000000 effectively means a monster does something ONCE but never again, and very early in the fight.

– ‘chance if possible’ is the next parameter.  this is very important.  if an action has all its preretirements met (distance, spell points, recharge counter) it is included in the list of available actions at the monster’s turn.  Out of those actions, each has a chance of being chosen, proportionate to its ‘chance’ parameter against all the others. So if I really wanted that skill with a 1000001 recharge counter to be used ONCE and at the very first turn, I would give it a high chance as well.  The “50% HP” action from the boss spider is such an example, when it is available I want it to be used as an absolute priority.

– ‘time required’.  Once the action takes effect, this is a timer to determine when it is again the monsters turn.

The above determines the behaviour in terms of choosing actions.  Actions include:

– moving towards players

– moving away from players

– hitting a target close by

– shooting from a distance (min distance would usually be 2 and max distance would be the range of the attack)

– ‘shooting’ an area effect spell

– blast: hit everyone in a set distance from the caster

– spawn someone, either close to caster, at edge of arena, or close to players

– heal himself or others

– buff himself or allies

– debuff players (cursing)

– write a message to the fight log

– dying

In combination, you can create really unique behaviour. For example in Chapter2, an enemy will summon a lava orb next to the player that explodes a short time after.

The lava orb is a monster with the following actions:

1) message “The strange ball starts to vibrate…” – super high chance to be used, super high recharge with counter filled up (=so not used more than once), so this will be the first action.  time it takes = 100 so the next action is 100 ticks later.

2) blast: fire damage to all <2 away.  super high chance to be used, super high recharge with counter 99 ticks away from being full.  so this 2nd action taken effectively after the message above.  time it takes = zero.  so the orb does another action right after.

3) die.  recharge = 99 ticks away from being used but super low chance to be picked.  only picked because it is the only action left available.

So the above is how a bomb behaves.

More normal monsters are easier to model of course, such as an orc:

– ‘advance’ with 500 chance to move forward a step. used when min distance to next player is 2.

– ‘melee’ if in range 1.

– ‘buff’ to use a rage skill every 400 ticks (recharge).  any such effects has many more parameters of course (what is buffed: accuracy, evasion, damage etc.) and a timer how long it lasts.

I hoped that provided some interesting insight how monster behaviour is created.  Feel free to comment or suggest improvements.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s