Hengband  2.2.1
関数 | 変数
monster-process.c ファイル

モンスターの特殊技能と移動処理/ 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"
monster-process.c の依存先関係図:

関数

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 POSITIONdist_offsets_y [10]
 
static POSITIONdist_offsets_x [10]
 

詳解

モンスターの特殊技能と移動処理/ Monster spells and movement

日付
2014/01/17
著者
Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke
This software may be copied and distributed for educational, research,
and not for profit purposes provided that this copyright and statement
are included in all such copies. Other copyrights may also apply.
2014 Deskull rearranged comment for Doxygen.

This file has several additions to it by Keldon Jones (keldo.nosp@m.n@um.nosp@m.r.edu) to improve the general quality of the AI (version 0.1.1).

関数詳解

◆ check_hp_for_feat_destruction()

static bool check_hp_for_feat_destruction ( feature_type f_ptr,
monster_type m_ptr 
)
static
被呼び出し関係図:

◆ find_hiding()

static bool find_hiding ( MONSTER_IDX  m_idx,
POSITION yp,
POSITION xp 
)
static

モンスターが隠れ潜める地点を返す / Choose a good hiding place near a monster for it to run toward.

引数
m_idxモンスターの参照ID
yp移動先のマスのY座標を返す参照ポインタ
xp移動先のマスのX座標を返す参照ポインタ
戻り値
有効なマスがあった場合TRUEを返す

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.

呼び出し関係図:
被呼び出し関係図:

◆ find_safety()

static bool find_safety ( MONSTER_IDX  m_idx,
POSITION yp,
POSITION xp 
)
static

モンスターが逃げ込める安全な地点を返す / Choose a "safe" location near a monster for it to run toward.

引数
m_idxモンスターの参照ID
yp移動先のマスのY座標を返す参照ポインタ
xp移動先のマスのX座標を返す参照ポインタ
戻り値
有効なマスがあった場合TRUEを返す

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.

呼び出し関係図:
被呼び出し関係図:

◆ get_enemy_dir()

static bool get_enemy_dir ( MONSTER_IDX  m_idx,
int *  mm 
)
static

モンスターが敵に接近するための方向を決める / Calculate the direction to the next enemy

引数
m_idxモンスターの参照ID
mm移動するべき方角IDを返す参照ポインタ
戻り値
方向が確定した場合TRUE、接近する敵がそもそもいない場合FALSEを返す
呼び出し関係図:
被呼び出し関係図:

◆ get_fear_moves_aux()

static bool get_fear_moves_aux ( MONSTER_IDX  m_idx,
POSITION yp,
POSITION xp 
)
static

モンスターがプレイヤーから逃走することが可能なマスを走査する / Provide a location to flee to, but give the player a wide berth.

引数
m_idxモンスターの参照ID
yp移動先のマスのY座標を返す参照ポインタ
xp移動先のマスのX座標を返す参照ポインタ
戻り値
有効なマスがあった場合TRUEを返す

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.

呼び出し関係図:
被呼び出し関係図:

◆ get_moves()

static bool get_moves ( MONSTER_IDX  m_idx,
DIRECTION mm 
)
static

モンスターの移動方向を返す / Choose "logical" directions for monster movement

引数
m_idxモンスターの参照ID
mm移動方向を返す方向IDの参照ポインタ
戻り値
有効方向があった場合TRUEを返す
呼び出し関係図:
被呼び出し関係図:

◆ get_moves_aux()

static bool get_moves_aux ( MONSTER_IDX  m_idx,
POSITION yp,
POSITION xp,
bool  no_flow 
)
static

モンスターがプレイヤーに向けて接近することが可能なマスを走査する / Choose the "best" direction for "flowing"

引数
m_idxモンスターの参照ID
yp移動先のマスのY座標を返す参照ポインタ
xp移動先のマスのX座標を返す参照ポインタ
no_flowモンスターにFLOWフラグが経っていない状態でTRUE
戻り値
有効なマスがあった場合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.

呼び出し関係図:
被呼び出し関係図:

◆ get_moves_aux2()

static bool get_moves_aux2 ( MONSTER_IDX  m_idx,
POSITION yp,
POSITION xp 
)
static

モンスターがプレイヤーに向けて遠距離攻撃を行うことが可能なマスを走査する / Search spell castable grid

引数
m_idxモンスターの参照ID
yp適したマスのY座標を返す参照ポインタ
xp適したマスのX座標を返す参照ポインタ
戻り値
有効なマスがあった場合TRUEを返す
呼び出し関係図:
被呼び出し関係図:

◆ mon_will_run()

static bool mon_will_run ( MONSTER_IDX  m_idx)
static

モンスターがプレイヤーから逃走するかどうかを返す / Returns whether a given monster will try to run from the player.

引数
m_idx逃走するモンスターの参照ID
戻り値
モンスターがプレイヤーから逃走するならばTRUEを返す。

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...

被呼び出し関係図:

◆ process_monster()

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".

呼び出し関係図:

◆ process_monsters()

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.

呼び出し関係図:

変数詳解

◆ d_off_x_0

POSITION d_off_x_0[] = { 0 }
static

◆ d_off_x_1

POSITION d_off_x_1[] = { -1, 0, 1, -1, 1, -1, 0, 1, 0 }
static

◆ d_off_x_2

POSITION d_off_x_2[] = { -2, 2, -1, 0, 1, -2, 2, -2, 2, -1, 0, 1, 0 }
static

◆ d_off_x_3

POSITION d_off_x_3[] = { -3, 3, -2, 2, -1, 0, 1, -3, 3, -3, 3, -2, 2, -1, 0, 1, 0 }
static

◆ d_off_x_4

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

◆ d_off_x_5

POSITION d_off_x_5[]
static
初期値:
=
{ -5, 5, -4, 4, -4, 4, -2, -3, 2, 3, -1, 0, 1,
-5, 5, -5, 5, -4, 4, -4, 4, -2, -3, 2, 3, -1,
0, 1, 0 }

◆ d_off_x_6

POSITION d_off_x_6[]
static
初期値:
=
{ -6, 6, -5, 5, -5, 5, -4, 4, -2, -3, 2, 3, -1,
0, 1, -6, 6, -6, 6, -5, 5, -5, 5, -4, 4, -2,
-3, 2, 3, -1, 0, 1, 0 }

◆ d_off_x_7

POSITION d_off_x_7[]
static
初期値:
=
{ -7, 7, -6, 6, -6, 6, -5, 5, -4, -5, 4, 5, -2,
-3, 2, 3, -1, 0, 1, -7, 7, -7, 7, -6, 6, -6,
6, -5, 5, -4, -5, 4, 5, -2, -3, 2, 3, -1, 0,
1, 0 }

◆ d_off_x_8

POSITION d_off_x_8[]
static
初期値:
=
{ -8, 8, -7, 7, -7, 7, -6, 6, -6, 6, -4, -5, 4,
5, -2, -3, 2, 3, -1, 0, 1, -8, 8, -8, 8, -7,
7, -7, 7, -6, 6, -6, 6, -4, -5, 4, 5, -2, -3,
2, 3, -1, 0, 1, 0 }

◆ d_off_x_9

POSITION d_off_x_9[]
static
初期値:
=
{ -9, 9, -8, 8, -8, 8, -7, 7, -7, 7, -6, 6, -4,
-5, 4, 5, -2, -3, 2, 3, -1, 0, 1, -9, 9, -9,
9, -8, 8, -8, 8, -7, 7, -7, 7, -6, 6, -4, -5,
4, 5, -2, -3, 2, 3, -1, 0, 1, 0 }

◆ d_off_y_0

POSITION d_off_y_0[] = { 0 }
static

◆ d_off_y_1

POSITION d_off_y_1[] = { -1, -1, -1, 0, 0, 1, 1, 1, 0 }
static

◆ d_off_y_2

POSITION d_off_y_2[] = { -1, -1, -2, -2, -2, 0, 0, 1, 1, 2, 2, 2, 0 }
static

◆ d_off_y_3

POSITION d_off_y_3[] = { -1, -1, -2, -2, -3, -3, -3, 0, 0, 1, 1, 2, 2, 3, 3, 3, 0 }
static

◆ d_off_y_4

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

◆ d_off_y_5

POSITION d_off_y_5[]
static
初期値:
=
{ -1, -1, -2, -2, -3, -3, -4, -4, -4, -4, -5, -5,
-5, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 4, 4, 5, 5,
5, 0 }

◆ d_off_y_6

POSITION d_off_y_6[]
static
初期値:
=
{ -1, -1, -2, -2, -3, -3, -4, -4, -5, -5, -5, -5,
-6, -6, -6, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5,
5, 5, 6, 6, 6, 0 }

◆ d_off_y_7

POSITION d_off_y_7[]
static
初期値:
=
{ -1, -1, -2, -2, -3, -3, -4, -4, -5, -5, -5, -5,
-6, -6, -6, -6, -7, -7, -7, 0, 0, 1, 1, 2, 2, 3,
3, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 0 }

◆ d_off_y_8

POSITION d_off_y_8[]
static
初期値:
=
{ -1, -1, -2, -2, -3, -3, -4, -4, -5, -5, -6, -6,
-6, -6, -7, -7, -7, -7, -8, -8, -8, 0, 0, 1, 1,
2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7,
8, 8, 8, 0 }

◆ d_off_y_9

POSITION d_off_y_9[]
static
初期値:
=
{ -1, -1, -2, -2, -3, -3, -4, -4, -5, -5, -6, -6,
-7, -7, -7, -7, -8, -8, -8, -8, -9, -9, -9, 0,
0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 7,
7, 8, 8, 8, 8, 9, 9, 9, 0 }

◆ dist_offsets_x

POSITION* dist_offsets_x[10]
static
初期値:
=
{
}
static POSITION d_off_x_0[]
Definition: monster-process.c:606
static POSITION d_off_x_9[]
Definition: monster-process.c:674
static POSITION d_off_x_8[]
Definition: monster-process.c:661
static POSITION d_off_x_2[]
Definition: monster-process.c:612
static POSITION d_off_x_1[]
Definition: monster-process.c:609
static POSITION d_off_x_5[]
Definition: monster-process.c:626
static POSITION d_off_x_6[]
Definition: monster-process.c:637
static POSITION d_off_x_3[]
Definition: monster-process.c:615
static POSITION d_off_x_4[]
Definition: monster-process.c:618
static POSITION d_off_x_7[]
Definition: monster-process.c:648

◆ dist_offsets_y

POSITION* dist_offsets_y[10]
static
初期値:
=
{
}
static POSITION d_off_y_6[]
Definition: monster-process.c:632
static POSITION d_off_y_0[]
Definition: monster-process.c:605
static POSITION d_off_y_2[]
Definition: monster-process.c:611
static POSITION d_off_y_3[]
Definition: monster-process.c:614
static POSITION d_off_y_9[]
Definition: monster-process.c:668
static POSITION d_off_y_4[]
Definition: monster-process.c:617
static POSITION d_off_y_8[]
Definition: monster-process.c:655
static POSITION d_off_y_7[]
Definition: monster-process.c:643
static POSITION d_off_y_1[]
Definition: monster-process.c:608
static POSITION d_off_y_5[]
Definition: monster-process.c:621