Hengband
2.2.1
|
モンスターの特殊技能と移動処理/ Monster spells and movement [詳解]
#include "angband.h"
#include "util.h"
#include "cmd-dump.h"
#include "cmd-pet.h"
#include "creature.h"
#include "melee.h"
#include "spells.h"
#include "spells-floor.h"
#include "spells-summon.h"
#include "quest.h"
#include "avatar.h"
#include "realm-hex.h"
#include "object-flavor.h"
#include "object-hook.h"
#include "feature.h"
#include "grid.h"
#include "player-move.h"
#include "monster-status.h"
#include "monster-spell.h"
#include "monster-process.h"
#include "monsterrace-hook.h"
#include "dungeon.h"
#include "floor.h"
#include "files.h"
#include "view-mainwindow.h"
関数 | |
static bool | get_enemy_dir (MONSTER_IDX m_idx, int *mm) |
モンスターが敵に接近するための方向を決める / Calculate the direction to the next enemy [詳解] | |
static bool | mon_will_run (MONSTER_IDX m_idx) |
モンスターがプレイヤーから逃走するかどうかを返す / Returns whether a given monster will try to run from the player. [詳解] | |
static bool | get_moves_aux2 (MONSTER_IDX m_idx, POSITION *yp, POSITION *xp) |
モンスターがプレイヤーに向けて遠距離攻撃を行うことが可能なマスを走査する / Search spell castable grid [詳解] | |
static bool | get_moves_aux (MONSTER_IDX m_idx, POSITION *yp, POSITION *xp, bool no_flow) |
モンスターがプレイヤーに向けて接近することが可能なマスを走査する / Choose the "best" direction for "flowing" [詳解] | |
static bool | get_fear_moves_aux (MONSTER_IDX m_idx, POSITION *yp, POSITION *xp) |
モンスターがプレイヤーから逃走することが可能なマスを走査する / Provide a location to flee to, but give the player a wide berth. [詳解] | |
static bool | find_safety (MONSTER_IDX m_idx, POSITION *yp, POSITION *xp) |
モンスターが逃げ込める安全な地点を返す / Choose a "safe" location near a monster for it to run toward. [詳解] | |
static bool | find_hiding (MONSTER_IDX m_idx, POSITION *yp, POSITION *xp) |
モンスターが隠れ潜める地点を返す / Choose a good hiding place near a monster for it to run toward. [詳解] | |
static bool | get_moves (MONSTER_IDX m_idx, DIRECTION *mm) |
モンスターの移動方向を返す / Choose "logical" directions for monster movement [詳解] | |
static bool | check_hp_for_feat_destruction (feature_type *f_ptr, monster_type *m_ptr) |
void | process_monster (MONSTER_IDX m_idx) |
モンスター単体の1ターン行動処理メインルーチン / Process a monster [詳解] | |
void | process_monsters (void) |
全モンスターのターン管理メインルーチン / Process all the "live" monsters, once per game turn. [詳解] | |
変数 | |
static POSITION | d_off_y_0 [] = { 0 } |
static POSITION | d_off_x_0 [] = { 0 } |
static POSITION | d_off_y_1 [] = { -1, -1, -1, 0, 0, 1, 1, 1, 0 } |
static POSITION | d_off_x_1 [] = { -1, 0, 1, -1, 1, -1, 0, 1, 0 } |
static POSITION | d_off_y_2 [] = { -1, -1, -2, -2, -2, 0, 0, 1, 1, 2, 2, 2, 0 } |
static POSITION | d_off_x_2 [] = { -2, 2, -1, 0, 1, -2, 2, -2, 2, -1, 0, 1, 0 } |
static POSITION | d_off_y_3 [] = { -1, -1, -2, -2, -3, -3, -3, 0, 0, 1, 1, 2, 2, 3, 3, 3, 0 } |
static POSITION | d_off_x_3 [] = { -3, 3, -2, 2, -1, 0, 1, -3, 3, -3, 3, -2, 2, -1, 0, 1, 0 } |
static POSITION | d_off_y_4 [] = { -1, -1, -2, -2, -3, -3, -3, -3, -4, -4, -4, 0, 0, 1, 1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 0 } |
static POSITION | d_off_x_4 [] = { -4, 4, -3, 3, -2, -3, 2, 3, -1, 0, 1, -4, 4, -4, 4, -3, 3, -2, -3, 2, 3, -1, 0, 1, 0 } |
static POSITION | d_off_y_5 [] |
static POSITION | d_off_x_5 [] |
static POSITION | d_off_y_6 [] |
static POSITION | d_off_x_6 [] |
static POSITION | d_off_y_7 [] |
static POSITION | d_off_x_7 [] |
static POSITION | d_off_y_8 [] |
static POSITION | d_off_x_8 [] |
static POSITION | d_off_y_9 [] |
static POSITION | d_off_x_9 [] |
static POSITION * | dist_offsets_y [10] |
static POSITION * | dist_offsets_x [10] |
モンスターの特殊技能と移動処理/ Monster spells and movement
This file has several additions to it by Keldon Jones (keldo) to improve the general quality of the AI (version 0.1.1). n@um r.edu
|
static |
|
static |
モンスターが隠れ潜める地点を返す / Choose a good hiding place near a monster for it to run toward.
m_idx | モンスターの参照ID |
yp | 移動先のマスのY座標を返す参照ポインタ |
xp | 移動先のマスのX座標を返す参照ポインタ |
Pack monsters will use this to "ambush" the player and lure him out
of corridors into open space so they can swarm him.
Return TRUE if a good location is available.
|
static |
モンスターが逃げ込める安全な地点を返す / Choose a "safe" location near a monster for it to run toward.
m_idx | モンスターの参照ID |
yp | 移動先のマスのY座標を返す参照ポインタ |
xp | 移動先のマスのX座標を返す参照ポインタ |
A location is "safe" if it can be reached quickly and the player
is not able to fire into it (it isn't a "clean shot"). So, this will
cause monsters to "duck" behind walls. Hopefully, monsters will also
try to run towards corridor openings if they are in a room.
This function may take lots of CPU time if lots of monsters are
fleeing.
Return TRUE if a safe location is available.
|
static |
モンスターが敵に接近するための方向を決める / Calculate the direction to the next enemy
m_idx | モンスターの参照ID |
mm | 移動するべき方角IDを返す参照ポインタ |
|
static |
モンスターがプレイヤーから逃走することが可能なマスを走査する / Provide a location to flee to, but give the player a wide berth.
m_idx | モンスターの参照ID |
yp | 移動先のマスのY座標を返す参照ポインタ |
xp | 移動先のマスのX座標を返す参照ポインタ |
A monster may wish to flee to a location that is behind the player,
but instead of heading directly for it, the monster should "swerve"
around the player so that he has a smaller chance of getting hit.
|
static |
モンスターの移動方向を返す / Choose "logical" directions for monster movement
m_idx | モンスターの参照ID |
mm | 移動方向を返す方向IDの参照ポインタ |
|
static |
モンスターがプレイヤーに向けて接近することが可能なマスを走査する / Choose the "best" direction for "flowing"
m_idx | モンスターの参照ID |
yp | 移動先のマスのY座標を返す参照ポインタ |
xp | 移動先のマスのX座標を返す参照ポインタ |
no_flow | モンスターにFLOWフラグが経っていない状態でTRUE |
Note that ghosts and rock-eaters are never allowed to "flow",
since they should move directly towards the player.
Prefer "non-diagonal" directions, but twiddle them a little
to angle slightly towards the player's actual location.
Allow very perceptive monsters to track old "spoor" left by
previous locations occupied by the player. This will tend
to have monsters end up either near the player or on a grid
recently occupied by the player (and left via "teleport").
Note that if "smell" is turned on, all monsters get vicious.
Also note that teleporting away from a location will cause
the monsters who were chasing you to converge on that location
as long as you are still near enough to "annoy" them without
being close enough to chase directly. I have no idea what will
happen if you combine "smell" with low "aaf" values.
|
static |
モンスターがプレイヤーに向けて遠距離攻撃を行うことが可能なマスを走査する / Search spell castable grid
m_idx | モンスターの参照ID |
yp | 適したマスのY座標を返す参照ポインタ |
xp | 適したマスのX座標を返す参照ポインタ |
|
static |
モンスターがプレイヤーから逃走するかどうかを返す / Returns whether a given monster will try to run from the player.
m_idx | 逃走するモンスターの参照ID |
Monsters will attempt to avoid very powerful players. See below.
Because this function is called so often, little details are important
for efficiency. Like not using "mod" or "div" when possible. And
attempting to check the conditions in an optimal order. Note that
"(x << 2) == (x * 4)" if "x" has enough bits to hold the result.
Note that this function is responsible for about one to five percent
of the processor use in normal conditions...
void process_monster | ( | MONSTER_IDX | m_idx | ) |
モンスター単体の1ターン行動処理メインルーチン / Process a monster
m_idx | 行動モンスターの参照ID |
The monster is known to be within 100 grids of the player
In several cases, we directly update the monster lore
Note that a monster is only allowed to "reproduce" if there
are a limited number of "reproducing" monsters on the current
level. This should prevent the level from being "swamped" by
reproducing monsters. It also allows a large mass of mice to
prevent a louse from multiplying, but this is a small price to
pay for a simple multiplication method.
XXX Monster fear is slightly odd, in particular, monsters will
fixate on opening a door even if they cannot open it. Actually,
the same thing happens to normal monsters when they hit a door
In addition, monsters which cannot open or bash
down a door will still stand there trying to open it...
XXX Technically, need to check for monster in the way
combined with that monster being in a wall (or door?)
A "direction" of "5" means "pick a random direction".
void process_monsters | ( | void | ) |
全モンスターのターン管理メインルーチン / Process all the "live" monsters, once per game turn.
During each game current game turn, we scan through the list of all the "live" monsters,
(backwards, so we can excise any "freshly dead" monsters), energizing each
monster, and allowing fully energized monsters to move, attack, pass, etc.
Note that monsters can never move in the monster array (except when the
"compact_monsters()" function is called by "dungeon()" or "save_player()").
This function is responsible for at least half of the processor time
on a normal system with a "normal" amount of monsters and a player doing
normal things.
When the player is resting, virtually 90% of the processor time is spent
in this function, and its children, "process_monster()" and "make_move()".
Most of the rest of the time is spent in "update_view()" and "lite_spot()",
especially when the player is running.
Note the special "MFLAG_BORN" flag, which allows us to ignore "fresh"
monsters while they are still being "born". A monster is "fresh" only
during the game turn in which it is created, and we use the "hack_m_idx" to
determine if the monster is yet to be processed during the game turn.
Note the special "MFLAG_NICE" flag, which allows the player to get one
move before any "nasty" monsters get to use their spell attacks.
Note that when the "knowledge" about the currently tracked monster
changes (flags, attacks, spells), we induce a redraw of the monster
recall window.
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |