DSB/Monster AI

From DmWiki
Revision as of 19:26, 16 August 2008 by Gilles (talk | contribs) (New page: Most of the AI code is found in <i>base/monster_ai.lua</i>. A lot of what is done on a monster's turn is also found in <i>base/monster.lua</i>. When it's a monster's turn to act, DSB call...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

Most of the AI code is found in base/monster_ai.lua. A lot of what is done on a monster's turn is also found in base/monster.lua.

When it's a monster's turn to act, DSB calls sysaifar if the monster is "out of range", and sysainear if the monster is "in range." This range calculation is made from the result of syscalcsight. Monsters on a different level are automatically assumed to be out of range.

(more later)

One easy way to communicate with the Monster AI is via dsbai messages.

Here is a list of messages that can be sent, using a syntax such as: dsbai(monsterid, aimsg, argument)

  • AI_MOVE - Tells the monster to move in a direction. An optional second parameter can specify which way the monster should face.
  • AI_TURN - Tells the monster to turn in a direction
  • AI_TARGET (takes two parameters) - Sets where the monster wants to go
  • AI_HAZARD - Tells the monster is it in a bad location and needs to move
  • AI_FEAR - Makes the monster afraid and run away
  • AI_STUN - Disorients the monster
  • AI_DELAY_ACTION - Makes the monster pause for the number of ticks specified
  • AI_TIMER - Sets the monster's movement timer directly
  • AI_WALL_BELIEF - Tells the monster what to think about fake walls
  • AI_SEE_PARTY - Tells the monster that it sees the party
  • AI_MOVE_NOW - Gives the monster a turn immediately (used when trying to fuse Lord Chaos, for example)