DSB/Monster AI
From DmWiki
Jump to navigationJump to searchMost 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_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)
- 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