DSB/Monster AI: Difference between revisions

From DmWiki
Jump to navigationJump to search
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...
 
Kaypy (talk | contribs)
Current versions no longer support AI_TARGET
 
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
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>.
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 calls <b>sys''ai''far</b> if the monster is "out of range", and <b>sys''ai''near</b> if the monster is "in range." This range calculation is made from the result of <b>sys''calc''sight</b>. Monsters on a different level are automatically assumed to be out of range.
When it's a monster's turn to act, DSB calls <b>sys_ai_far</b> if the monster is "out of range", and <b>sys_ai_near</b> if the monster is "in range." This range calculation is made from the result of <b>sys_calc_sight</b>. Monsters on a different level are automatically assumed to be out of range.


(more later)
(more later)


One easy way to communicate with the Monster AI is via <b>dsb''ai</b> messages.
One easy way to communicate with the Monster AI is via <b>dsb_ai</b> messages.


Here is a list of messages that can be sent, using a syntax such as: <code>dsb''ai(monster''id, ai''msg, argument)</code>
Here is a list of messages that can be sent, using a syntax such as: <code>dsb_ai(monster_id, ai_msg, argument)</code>


* AI_MOVE - Tells the monster to move in a direction. An optional second parameter can specify which way the monster should face.
* 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_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_HAZARD - Tells the monster is it in a bad location and needs to move
Line 25: Line 24:


* AI_MOVE_NOW - Gives the monster a turn immediately (used when trying to fuse Lord Chaos, for example)
* AI_MOVE_NOW - Gives the monster a turn immediately (used when trying to fuse Lord Chaos, for example)
* AI_ATTACK_BMP - Specify the index in the array of attack animations that the monster should use.  See the mutli-vexirx attack in the demo
No longer supported:
* AI_TARGET - Use add_monster_target(id, ttl, x, y) instead


[[Category:DSB|Monster AI]]
[[Category:DSB|Monster AI]]

Latest revision as of 08:26, 1 October 2016

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 sys_ai_far if the monster is "out of range", and sys_ai_near if the monster is "in range." This range calculation is made from the result of sys_calc_sight. 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 dsb_ai messages.

Here is a list of messages that can be sent, using a syntax such as: dsb_ai(monster_id, ai_msg, 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_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)
  • AI_ATTACK_BMP - Specify the index in the array of attack animations that the monster should use. See the mutli-vexirx attack in the demo

No longer supported:

  • AI_TARGET - Use add_monster_target(id, ttl, x, y) instead