X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=src%2Fmonster-process.c;h=5b4dc21fa0d8c5bb9a50cb9965302b74efcd81fa;hb=beabcca1b1ddcb03302e220f0e2fb170ccd5c8cb;hp=2e1122219b17f07d0d7407a93d2b82bff5d6885d;hpb=4b1c8c76a81038fc42938b2276e6ee72473b2a2a;p=hengband%2Fhengband.git diff --git a/src/monster-process.c b/src/monster-process.c index 2e1122219..5b4dc21fa 100644 --- a/src/monster-process.c +++ b/src/monster-process.c @@ -15,6 +15,11 @@ #include "angband.h" #include "cmd-pet.h" +#include "monsterrace-hook.h" +#include "melee.h" +#include "projection.h" +#include "spells-summon.h" +#include "quest.h" /*! @@ -34,7 +39,6 @@ static bool get_enemy_dir(MONSTER_IDX m_idx, int *mm) monster_type *m_ptr = &m_list[m_idx]; monster_race *r_ptr = &r_info[m_ptr->r_idx]; - monster_type *t_ptr; if (riding_t_m_idx && player_bold(m_ptr->fy, m_ptr->fx)) @@ -84,8 +88,7 @@ static bool get_enemy_dir(MONSTER_IDX m_idx, int *mm) } } /* Hack -- no fighting away from player */ - else if ((m_ptr->cdis < t_ptr->cdis) && - (t_ptr->cdis > p_ptr->pet_follow_distance)) + else if ((m_ptr->cdis < t_ptr->cdis) && (t_ptr->cdis > p_ptr->pet_follow_distance)) { continue; } @@ -187,16 +190,17 @@ static bool get_enemy_dir(MONSTER_IDX m_idx, int *mm) * Hack, based on mon_take_hit... perhaps all monster attacks on other monsters should use this? * @param m_idx 目標となるモンスターの参照ID * @param dam ダメージ量 - * @param fear 目標となるモンスターの恐慌状態を返す参照ポインタ + * @param dead 目標となったモンスターの死亡状態を返す参照ポインタ + * @param fear 目標となったモンスターの恐慌状態を返す参照ポインタ * @param note 目標モンスターが死亡した場合の特別メッセージ(NULLならば標準表示を行う) * @param who 打撃を行ったモンスターの参照ID * @return なし */ -void mon_take_hit_mon(MONSTER_IDX m_idx, HIT_POINT dam, bool *fear, cptr note, IDX who) +void mon_take_hit_mon(MONSTER_IDX m_idx, HIT_POINT dam, bool *dead, bool *fear, concptr note, IDX who) { monster_type *m_ptr = &m_list[m_idx]; monster_race *r_ptr = &r_info[m_ptr->r_idx]; - char m_name[160]; + GAME_TEXT m_name[160]; bool seen = is_seen(m_ptr); /* Can the player be aware of this attack? */ @@ -212,10 +216,9 @@ void mon_take_hit_mon(MONSTER_IDX m_idx, HIT_POINT dam, bool *fear, cptr note, I if (p_ptr->riding == m_idx) p_ptr->redraw |= (PR_UHEALTH); } - /* Wake it up */ (void)set_monster_csleep(m_idx, 0); - if (p_ptr->riding && (m_idx == p_ptr->riding)) disturb(1, 1); + if (p_ptr->riding && (m_idx == p_ptr->riding)) disturb(TRUE, TRUE); if (MON_INVULNER(m_ptr) && randint0(PENETRATE_INVULNERABILITY)) { @@ -223,7 +226,6 @@ void mon_take_hit_mon(MONSTER_IDX m_idx, HIT_POINT dam, bool *fear, cptr note, I { msg_format(_("%^sはダメージを受けない。", "%^s is unharmed."), m_name); } - return; } @@ -245,7 +247,7 @@ void mon_take_hit_mon(MONSTER_IDX m_idx, HIT_POINT dam, bool *fear, cptr note, I } /* Hurt it */ - m_ptr->hp -= (s16b)dam; + m_ptr->hp -= dam; /* It is dead now... or is it? */ if (m_ptr->hp < 0) @@ -259,7 +261,7 @@ void mon_take_hit_mon(MONSTER_IDX m_idx, HIT_POINT dam, bool *fear, cptr note, I else { /* Make a sound */ - if (!monster_living(r_ptr)) + if (!monster_living(m_ptr->r_idx)) { sound(SOUND_N_KILL); } @@ -268,6 +270,8 @@ void mon_take_hit_mon(MONSTER_IDX m_idx, HIT_POINT dam, bool *fear, cptr note, I sound(SOUND_KILL); } + *dead = TRUE; + if (known) { monster_desc(m_name, m_ptr, MD_TRUE_NAME); @@ -282,7 +286,7 @@ void mon_take_hit_mon(MONSTER_IDX m_idx, HIT_POINT dam, bool *fear, cptr note, I msg_format(_("%^s%s", "%^s%s"), m_name, note); } /* Death by normal attack -- nonliving monster */ - else if (!monster_living(r_ptr)) + else if (!monster_living(m_ptr->r_idx)) { msg_format(_("%^sは破壊された。", "%^s is destroyed."), m_name); } @@ -294,11 +298,7 @@ void mon_take_hit_mon(MONSTER_IDX m_idx, HIT_POINT dam, bool *fear, cptr note, I } monster_gain_exp(who, m_ptr->r_idx); - - /* Generate treasure */ monster_death(m_idx, FALSE); - - /* Delete the monster */ delete_monster_idx(m_idx); /* Not afraid */ @@ -309,6 +309,8 @@ void mon_take_hit_mon(MONSTER_IDX m_idx, HIT_POINT dam, bool *fear, cptr note, I } } + *dead = FALSE; + #ifdef ALLOW_FEAR /* Mega-Hack -- Pain cancels fear */ @@ -338,7 +340,7 @@ void mon_take_hit_mon(MONSTER_IDX m_idx, HIT_POINT dam, bool *fear, cptr note, I /* Hack -- note fear */ (*fear) = TRUE; - /* XXX XXX XXX Hack -- Add some timed fear */ + /* Hack -- Add some timed fear */ (void)set_monster_monfear(m_idx, (randint1(10) + (((dam >= m_ptr->hp) && (percentage > 7)) ? 20 : ((11 - percentage) * 5)))); @@ -396,7 +398,8 @@ static bool mon_will_run(MONSTER_IDX m_idx) monster_race *r_ptr = &r_info[m_ptr->r_idx]; - u16b p_lev, m_lev; + PLAYER_LEVEL p_lev; + DEPTH m_lev; HIT_POINT p_chp, p_mhp; HIT_POINT m_chp, m_mhp; u32b p_val, m_val; @@ -496,7 +499,6 @@ static bool get_moves_aux2(MONSTER_IDX m_idx, POSITION *yp, POSITION *xp) { int cost; - /* Get the location */ y = y1 + ddy_ddd[i]; x = x1 + ddx_ddd[i]; @@ -630,7 +632,6 @@ static bool get_moves_aux(MONSTER_IDX m_idx, POSITION *yp, POSITION *xp, bool no /* Check nearby grids, diagonals first */ for (i = 7; i >= 0; i--) { - /* Get the location */ y = y1 + ddy_ddd[i]; x = x1 + ddx_ddd[i]; @@ -707,9 +708,8 @@ static bool get_fear_moves_aux(MONSTER_IDX m_idx, POSITION *yp, POSITION *xp) /* Check nearby grids, diagonals first */ for (i = 7; i >= 0; i--) { - int dis, s; + POSITION dis, s; - /* Get the location */ y = fy + ddy_ddd[i]; x = fx + ddx_ddd[i]; @@ -764,122 +764,99 @@ static bool get_fear_moves_aux(MONSTER_IDX m_idx, POSITION *yp, POSITION *xp) * It is probably better to replace these arrays with code to compute * the relevant arrays, even if the storage is pre-allocated in hard * coded sizes. At the very least, code should be included which is - * able to generate and dump these arrays (ala "los()"). XXX XXX XXX + * able to generate and dump these arrays (ala "los()"). * - * Also, the storage needs could be halved by using bytes. XXX XXX XXX + * Also, the storage needs could be halved by using bytes. * * These arrays could be combined into two big arrays, using sub-arrays * to hold the offsets and lengths of each portion of the sub-arrays, and - * this could perhaps also be used somehow in the "look" code. XXX XXX XXX + * this could perhaps also be used somehow in the "look" code. */ -static sint d_off_y_0[] = -{ 0 }; - -static sint d_off_x_0[] = -{ 0 }; - - -static sint d_off_y_1[] = -{ -1, -1, -1, 0, 0, 1, 1, 1, 0 }; - -static sint d_off_x_1[] = -{ -1, 0, 1, -1, 1, -1, 0, 1, 0 }; +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 sint d_off_y_2[] = -{ -1, -1, -2, -2, -2, 0, 0, 1, 1, 2, 2, 2, 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 sint 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 sint d_off_y_3[] = -{ -1, -1, -2, -2, -3, -3, -3, 0, 0, 1, 1, 2, 2, - 3, 3, 3, 0 }; -static sint d_off_x_3[] = -{ -3, 3, -2, 2, -1, 0, 1, -3, 3, -3, 3, -2, 2, - -1, 0, 1, 0 }; - - -static sint 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 sint 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 sint d_off_y_5[] = +static POSITION d_off_y_5[] = { -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 }; -static sint d_off_x_5[] = +static POSITION d_off_x_5[] = { -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 }; -static sint d_off_y_6[] = +static POSITION d_off_y_6[] = { -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 }; -static sint d_off_x_6[] = +static POSITION d_off_x_6[] = { -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 }; -static sint d_off_y_7[] = +static POSITION d_off_y_7[] = { -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 }; -static sint d_off_x_7[] = +static POSITION d_off_x_7[] = { -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 }; -static sint d_off_y_8[] = +static POSITION d_off_y_8[] = { -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 }; -static sint d_off_x_8[] = +static POSITION d_off_x_8[] = { -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 }; -static sint d_off_y_9[] = +static POSITION d_off_y_9[] = { -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 }; -static sint d_off_x_9[] = +static POSITION d_off_x_9[] = { -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 }; -static sint *dist_offsets_y[10] = +static POSITION *dist_offsets_y[10] = { d_off_y_0, d_off_y_1, d_off_y_2, d_off_y_3, d_off_y_4, d_off_y_5, d_off_y_6, d_off_y_7, d_off_y_8, d_off_y_9 }; -static sint *dist_offsets_x[10] = +static POSITION *dist_offsets_x[10] = { d_off_x_0, d_off_x_1, d_off_x_2, d_off_x_3, d_off_x_4, d_off_x_5, d_off_x_6, d_off_x_7, d_off_x_8, d_off_x_9 @@ -913,8 +890,8 @@ static bool find_safety(MONSTER_IDX m_idx, POSITION *yp, POSITION *xp) POSITION y, x, dy, dx, d, dis, i; POSITION gy = 0, gx = 0, gdis = 0; - sint *y_offsets; - sint *x_offsets; + POSITION *y_offsets; + POSITION *x_offsets; cave_type *c_ptr; @@ -1008,7 +985,7 @@ static bool find_hiding(MONSTER_IDX m_idx, POSITION *yp, POSITION *xp) POSITION y, x, dy, dx, d, dis, i; POSITION gy = 0, gx = 0, gdis = 999; - sint *y_offsets, *x_offsets; + POSITION *y_offsets, *x_offsets; /* Start with adjacent locations, spread further */ for (d = 1; d < 10; d++) @@ -1071,7 +1048,7 @@ static bool find_hiding(MONSTER_IDX m_idx, POSITION *yp, POSITION *xp) * @param mm 移動方向を返す方向IDの参照ポインタ * @return 有効方向があった場合TRUEを返す */ -static bool get_moves(MONSTER_IDX m_idx, int *mm) +static bool get_moves(MONSTER_IDX m_idx, DIRECTION *mm) { monster_type *m_ptr = &m_list[m_idx]; monster_race *r_ptr = &r_info[m_ptr->r_idx]; @@ -1181,7 +1158,6 @@ static bool get_moves(MONSTER_IDX m_idx, int *mm) y = m_ptr->fy - y2; x = m_ptr->fx - x2; - /* Done */ done = TRUE; } } @@ -1406,7 +1382,7 @@ static bool get_moves(MONSTER_IDX m_idx, int *mm) * @param stun 攻撃側モンスターが朦朧状態ならTRUEを返す * @return 命中ならばTRUEを返す */ -static int check_hit2(int power, int level, int ac, int stun) +static int check_hit2(int power, DEPTH level, ARMOUR_CLASS ac, int stun) { int i, k; @@ -1441,7 +1417,7 @@ static int check_hit2(int power, int level, int ac, int stun) * @param t_idx 目標側モンスターの参照ID * @return 実際に打撃処理が行われた場合TRUEを返す */ -static bool monst_attack_monst(MONSTER_IDX m_idx, IDX t_idx) +static bool monst_attack_monst(MONSTER_IDX m_idx, MONSTER_IDX t_idx) { monster_type *m_ptr = &m_list[m_idx]; monster_type *t_ptr = &m_list[t_idx]; @@ -1449,14 +1425,16 @@ static bool monst_attack_monst(MONSTER_IDX m_idx, IDX t_idx) monster_race *r_ptr = &r_info[m_ptr->r_idx]; monster_race *tr_ptr = &r_info[t_ptr->r_idx]; - int ap_cnt; - int ac, rlev, pt; - char m_name[80], t_name[80]; + ARMOUR_CLASS ap_cnt; + ARMOUR_CLASS ac; + DEPTH rlev; + int pt; + GAME_TEXT m_name[MAX_NLEN], t_name[MAX_NLEN]; char temp[MAX_NLEN]; bool blinked; - bool explode = FALSE, touched = FALSE, fear = FALSE; - int y_saver = t_ptr->fy; - int x_saver = t_ptr->fx; + bool explode = FALSE, touched = FALSE, fear = FALSE, dead = FALSE; + POSITION y_saver = t_ptr->fy; + POSITION x_saver = t_ptr->fx; int effect_type; bool see_m = is_seen(m_ptr); @@ -1481,10 +1459,7 @@ static bool monst_attack_monst(MONSTER_IDX m_idx, IDX t_idx) /* Extract the effective monster level */ rlev = ((r_ptr->level >= 1) ? r_ptr->level : 1); - /* Get the monster name (or "it") */ monster_desc(m_name, m_ptr, 0); - - /* Get the monster name (or "it") */ monster_desc(t_name, t_ptr, 0); /* Assume no blink */ @@ -1495,7 +1470,7 @@ static bool monst_attack_monst(MONSTER_IDX m_idx, IDX t_idx) mon_fight = TRUE; } - if (p_ptr->riding && (m_idx == p_ptr->riding)) disturb(1, 1); + if (p_ptr->riding && (m_idx == p_ptr->riding)) disturb(TRUE, TRUE); /* Scan through all four blows */ for (ap_cnt = 0; ap_cnt < 4; ap_cnt++) @@ -1505,7 +1480,7 @@ static bool monst_attack_monst(MONSTER_IDX m_idx, IDX t_idx) HIT_POINT power = 0; HIT_POINT damage = 0; - cptr act = NULL; + concptr act = NULL; /* Extract the attack infomation */ int effect = r_ptr->blow[ap_cnt].effect; @@ -1530,7 +1505,6 @@ static bool monst_attack_monst(MONSTER_IDX m_idx, IDX t_idx) /* Monster hits */ if (!effect || check_hit2(power, rlev, ac, MON_STUNNED(m_ptr))) { - /* Wake it up */ (void)set_monster_csleep(t_idx, 0); if (t_ptr->ml) @@ -1649,7 +1623,7 @@ static bool monst_attack_monst(MONSTER_IDX m_idx, IDX t_idx) case RBM_EXPLODE: { - if (see_either) disturb(1, 1); + if (see_either) disturb(TRUE, TRUE); act = _("爆発した。", "explodes."); explode = TRUE; touched = FALSE; @@ -1713,7 +1687,6 @@ static bool monst_attack_monst(MONSTER_IDX m_idx, IDX t_idx) } } - /* Message */ if (act && see_either) { #ifdef JP @@ -1875,7 +1848,7 @@ static bool monst_attack_monst(MONSTER_IDX m_idx, IDX t_idx) break; case BLOW_EFFECT_TYPE_HEAL: - if ((monster_living(tr_ptr)) && (damage > 2)) + if ((monster_living(m_idx)) && (damage > 2)) { bool did_heal = FALSE; @@ -1985,15 +1958,13 @@ static bool monst_attack_monst(MONSTER_IDX m_idx, IDX t_idx) case RBM_ENGULF: case RBM_CHARGE: { - /* Wake it up */ (void)set_monster_csleep(t_idx, 0); /* Visible monsters */ if (see_m) { - /* Message */ #ifdef JP - msg_format("%sは%^sの攻撃をかわした。", t_name,m_name); + msg_format("%sは%^sの攻撃をかわした。", t_name, m_name); #else msg_format("%^s misses %s.", m_name, t_name); #endif @@ -2026,7 +1997,7 @@ static bool monst_attack_monst(MONSTER_IDX m_idx, IDX t_idx) /* Cancel Invulnerability */ (void)set_monster_invulner(m_idx, 0, FALSE); - mon_take_hit_mon(m_idx, m_ptr->hp + 1, &fear, _("は爆発して粉々になった。", " explodes into tiny shreds."), m_idx); + mon_take_hit_mon(m_idx, m_ptr->hp + 1, &dead, &fear, _("は爆発して粉々になった。", " explodes into tiny shreds."), m_idx); blinked = FALSE; } @@ -2066,8 +2037,8 @@ static bool monst_attack_monst(MONSTER_IDX m_idx, IDX t_idx) static bool check_hp_for_feat_destruction(feature_type *f_ptr, monster_type *m_ptr) { return !have_flag(f_ptr->flags, FF_GLASS) || - (r_info[m_ptr->r_idx].flags2 & RF2_STUPID) || - (m_ptr->hp >= MAX(m_ptr->maxhp / 3, 200)); + (r_info[m_ptr->r_idx].flags2 & RF2_STUPID) || + (m_ptr->hp >= MAX(m_ptr->maxhp / 3, 200)); } @@ -2092,7 +2063,7 @@ static bool check_hp_for_feat_destruction(feature_type *f_ptr, monster_type *m_p * fixate on opening a door even if they cannot open it. Actually,\n * the same thing happens to normal monsters when they hit a door\n *\n - * XXX XXX XXX In addition, monsters which *cannot* open or bash\n + * In addition, monsters which *cannot* open or bash\n * down a door will still stand there trying to open it...\n *\n * XXX Technically, need to check for monster in the way\n @@ -2106,10 +2077,10 @@ void process_monster(MONSTER_IDX m_idx) monster_race *r_ptr = &r_info[m_ptr->r_idx]; monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx]; - int i, d; - POSITION oy, ox, ny, nx; + int i, d; + POSITION oy, ox, ny, nx; - int mm[8]; + DIRECTION mm[8]; cave_type *c_ptr; feature_type *f_ptr; @@ -2132,11 +2103,9 @@ void process_monster(MONSTER_IDX m_idx) bool can_cross; bool aware = TRUE; - bool fear; - - bool is_riding_mon = (m_idx == p_ptr->riding); - - bool see_m = is_seen(m_ptr); + bool fear, dead; + bool is_riding_mon = (m_idx == p_ptr->riding); + bool see_m = is_seen(m_ptr); if (is_riding_mon && !(r_ptr->flags7 & RF7_RIDING)) { @@ -2145,7 +2114,7 @@ void process_monster(MONSTER_IDX m_idx) #ifdef JP msg_print("地面に落とされた。"); #else - char m_name[80]; + GAME_TEXT m_name[MAX_NLEN]; monster_desc(m_name, &m_list[p_ptr->riding], 0); msg_format("You have fallen from %s.", m_name); #endif @@ -2164,7 +2133,7 @@ void process_monster(MONSTER_IDX m_idx) int tmp = p_ptr->lev*6+(p_ptr->skill_stl+10)*4; if (p_ptr->monlite) tmp /= 3; if (p_ptr->cursed & TRC_AGGRAVATE) tmp /= 2; - if (r_ptr->level > (p_ptr->lev*p_ptr->lev/20+10)) tmp /= 3; + if (r_ptr->level > (p_ptr->lev * p_ptr->lev / 20 + 10)) tmp /= 3; /* Low-level monsters will find it difficult to locate the player. */ if (randint0(tmp) > (r_ptr->level+20)) aware = FALSE; } @@ -2176,22 +2145,18 @@ void process_monster(MONSTER_IDX m_idx) if (see_m) { - char m_name[80]; - - /* Acquire the monster name */ + GAME_TEXT m_name[MAX_NLEN]; monster_desc(m_name, m_ptr, 0); msg_format(_("%sは消え去った!", "%^s disappears!"), m_name); } if (record_named_pet && is_pet(m_ptr) && m_ptr->nickname) { - char m_name[80]; - + GAME_TEXT m_name[MAX_NLEN]; monster_desc(m_name, m_ptr, MD_INDEF_VISIBLE); do_cmd_write_nikki(NIKKI_NAMED_PET, RECORD_NAMED_PET_LOSE_PARENT, m_name); } - /* Delete the monster */ delete_monster_idx(m_idx); return; @@ -2208,26 +2173,20 @@ void process_monster(MONSTER_IDX m_idx) { bool sad = FALSE; - if (is_pet(m_ptr) && !(m_ptr->ml)) - sad = TRUE; + if (is_pet(m_ptr) && !(m_ptr->ml)) sad = TRUE; if (see_m) { - char m_name[80]; - - /* Acquire the monster name */ + GAME_TEXT m_name[MAX_NLEN]; monster_desc(m_name, m_ptr, 0); - /* Oops */ msg_format(_("%sは消え去った!", "%^s disappears!"), m_name); } /* Generate treasure, etc */ monster_death(m_idx, FALSE); - /* Delete the monster */ delete_monster_idx(m_idx); - if (sad) { msg_print(_("少しの間悲しい気分になった。", "You feel sad for a moment.")); @@ -2239,7 +2198,8 @@ void process_monster(MONSTER_IDX m_idx) if (m_ptr->r_idx == MON_SHURYUUDAN) { - mon_take_hit_mon(m_idx, 1, &fear, _("は爆発して粉々になった。", " explodes into tiny shreds."), m_idx); + mon_take_hit_mon(m_idx, 1, &dead, &fear, _("は爆発して粉々になった。", " explodes into tiny shreds."), m_idx); + if(dead) return; } if ((is_pet(m_ptr) || is_friendly(m_ptr)) && ((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags7 & RF7_NAZGUL)) && !p_ptr->inside_battle) @@ -2248,7 +2208,7 @@ void process_monster(MONSTER_IDX m_idx) if (m_ptr->hp < m_ptr->maxhp/3) { - char m_name[80]; + GAME_TEXT m_name[MAX_NLEN]; monster_desc(m_name, m_ptr, 0); if (is_riding_mon && riding_pinch < 2) @@ -2256,7 +2216,7 @@ void process_monster(MONSTER_IDX m_idx) msg_format(_("%sは傷の痛さの余りあなたの束縛から逃れようとしている。", "%^s seems to be in so much pain, and trying to escape from your restriction."), m_name); riding_pinch++; - disturb(1, 1); + disturb(TRUE, TRUE); } else { @@ -2306,20 +2266,14 @@ void process_monster(MONSTER_IDX m_idx) /* Handle non-aggravation - Still sleeping */ if (!(p_ptr->cursed & TRC_AGGRAVATE)) return; - /* Handle aggravation */ - /* Reset sleep counter */ (void)set_monster_csleep(m_idx, 0); /* Notice the "waking up" */ if (m_ptr->ml) { - char m_name[80]; - - /* Acquire the monster name */ + GAME_TEXT m_name[MAX_NLEN]; monster_desc(m_name, m_ptr, 0); - - /* Dump a message */ msg_format(_("%^sが目を覚ました。", "%^s wakes up."), m_name); } @@ -2347,8 +2301,7 @@ void process_monster(MONSTER_IDX m_idx) gets_angry = TRUE; /* Paranoia... no pet uniques outside wizard mode -- TY */ - if (is_pet(m_ptr) && - ((((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags7 & RF7_NAZGUL)) && + if (is_pet(m_ptr) && ((((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags7 & RF7_NAZGUL)) && monster_has_hostile_align(NULL, 10, -10, r_ptr)) || (r_ptr->flagsr & RFR_RES_ALL))) { @@ -2361,7 +2314,7 @@ void process_monster(MONSTER_IDX m_idx) { if (is_pet(m_ptr) || see_m) { - char m_name[80]; + GAME_TEXT m_name[MAX_NLEN]; monster_desc(m_name, m_ptr, is_pet(m_ptr) ? MD_ASSUME_VISIBLE : 0); msg_format(_("%^sは突然敵にまわった!", "%^s suddenly becomes hostile!"), m_name); } @@ -2373,11 +2326,11 @@ void process_monster(MONSTER_IDX m_idx) oy = m_ptr->fy; ox = m_ptr->fx; - /* Attempt to "multiply" if able and allowed */ if ((r_ptr->flags2 & RF2_MULTIPLY) && (num_repro < MAX_REPRO)) { - int k, y, x; + int k; + POSITION y, x; /* Count the adjacent monsters */ for (k = 0, y = oy - 1; y <= oy + 1; y++) @@ -2386,7 +2339,6 @@ void process_monster(MONSTER_IDX m_idx) { /* Ignore locations off of edge */ if (!in_bounds2(y, x)) continue; - if (cave[y][x].m_idx) k++; } } @@ -2412,7 +2364,6 @@ void process_monster(MONSTER_IDX m_idx) } } - if (r_ptr->a_ability_flags2 & RF6_SPECIAL) { /* Hack -- Ohmu scatters molds! */ @@ -2422,13 +2373,13 @@ void process_monster(MONSTER_IDX m_idx) { if (r_ptr->freq_spell && (randint1(100) <= r_ptr->freq_spell)) { - int k, count = 0; - int rlev = ((r_ptr->level >= 1) ? r_ptr->level : 1); - u32b p_mode = is_pet(m_ptr) ? PM_FORCE_PET : 0L; + int k, count = 0; + DEPTH rlev = ((r_ptr->level >= 1) ? r_ptr->level : 1); + BIT_FLAGS p_mode = is_pet(m_ptr) ? PM_FORCE_PET : 0L; - for (k = 0; k < 6; k++) + for (k = 0; k < A_MAX; k++) { - if (summon_specific(m_idx, m_ptr->fy, m_ptr->fx, rlev, SUMMON_MOLD, (PM_ALLOW_GROUP | p_mode))) + if (summon_specific(m_idx, m_ptr->fy, m_ptr->fx, rlev, SUMMON_MOLD, (PM_ALLOW_GROUP | p_mode), '\0')) { if (m_list[hack_m_idx_ii].ml) count++; } @@ -2440,7 +2391,6 @@ void process_monster(MONSTER_IDX m_idx) } } - if (!p_ptr->inside_battle) { /* Hack! "Cyber" monster makes noise... */ @@ -2458,9 +2408,9 @@ void process_monster(MONSTER_IDX m_idx) player_has_los_bold(oy, ox) && projectable(oy, ox, p_ptr->y, p_ptr->x)) { - char m_name[80]; + GAME_TEXT m_name[MAX_NLEN]; char monmessage[1024]; - cptr filename; + concptr filename; /* Acquire the monster name/poss */ if (m_ptr->ml) @@ -2494,11 +2444,10 @@ void process_monster(MONSTER_IDX m_idx) /* Give priority to counter attack? */ if (m_ptr->target_y) { - int t_m_idx = cave[m_ptr->target_y][m_ptr->target_x].m_idx; + MONSTER_IDX t_m_idx = cave[m_ptr->target_y][m_ptr->target_x].m_idx; /* The monster must be an enemy, and projectable */ - if (t_m_idx && - are_enemies(m_ptr, &m_list[t_m_idx]) && + if (t_m_idx && are_enemies(m_ptr, &m_list[t_m_idx]) && projectable(m_ptr->fy, m_ptr->fx, m_ptr->target_y, m_ptr->target_x)) { counterattack = TRUE; @@ -2586,8 +2535,7 @@ void process_monster(MONSTER_IDX m_idx) else if (is_pet(m_ptr)) { /* Are we trying to avoid the player? */ - bool avoid = ((p_ptr->pet_follow_distance < 0) && - (m_ptr->cdis <= (0 - p_ptr->pet_follow_distance))); + bool avoid = ((p_ptr->pet_follow_distance < 0) && (m_ptr->cdis <= (0 - p_ptr->pet_follow_distance))); /* Do we want to find the player? */ bool lonely = (!avoid && (m_ptr->cdis > p_ptr->pet_follow_distance)); @@ -2605,7 +2553,7 @@ void process_monster(MONSTER_IDX m_idx) if (avoid || lonely || distant) { /* Remember the leash length */ - int dis = p_ptr->pet_follow_distance; + POSITION dis = p_ptr->pet_follow_distance; /* Hack -- adjust follow distance temporarily */ if (p_ptr->pet_follow_distance > PET_SEEK_DIST) @@ -2653,7 +2601,6 @@ void process_monster(MONSTER_IDX m_idx) did_pass_wall = FALSE; did_kill_wall = FALSE; - /* Take a zero-terminated array of "directions" */ for (i = 0; mm[i]; i++) { @@ -2740,14 +2687,13 @@ void process_monster(MONSTER_IDX m_idx) /* Do not bash the door */ may_bash = FALSE; - /* Take a turn */ do_turn = TRUE; } /* Locked doors (not jammed) */ else { - /* Try to unlock it XXX XXX XXX */ + /* Try to unlock it */ if (randint0(m_ptr->hp / 10) > f_ptr->power) { /* Unlock the door */ @@ -2756,7 +2702,6 @@ void process_monster(MONSTER_IDX m_idx) /* Do not bash the door */ may_bash = FALSE; - /* Take a turn */ do_turn = TRUE; } } @@ -2766,17 +2711,16 @@ void process_monster(MONSTER_IDX m_idx) if (may_bash && (r_ptr->flags2 & RF2_BASH_DOOR) && have_flag(f_ptr->flags, FF_BASH) && (!is_pet(m_ptr) || (p_ptr->pet_extra_flags & PF_OPEN_DOORS))) { - /* Attempt to Bash XXX XXX XXX */ + /* Attempt to Bash */ if (check_hp_for_feat_destruction(f_ptr, m_ptr) && (randint0(m_ptr->hp / 10) > f_ptr->power)) { - /* Message */ if (have_flag(f_ptr->flags, FF_GLASS)) msg_print(_("ガラスが砕ける音がした!", "You hear a glass was crashed!")); else msg_print(_("ドアを叩き開ける音がした!", "You hear a door burst open!")); /* Disturb (sometimes) */ - if (disturb_minor) disturb(0, 0); + if (disturb_minor) disturb(FALSE, FALSE); /* The door was bashed open */ did_bash_door = TRUE; @@ -2846,7 +2790,6 @@ void process_monster(MONSTER_IDX m_idx) /* Allow movement */ do_move = TRUE; - /* Notice */ note_spot(ny, nx); } } @@ -2988,7 +2931,7 @@ void process_monster(MONSTER_IDX m_idx) /* Wake up the moved monster */ (void)set_monster_csleep(c_ptr->m_idx, 0); - /* XXX XXX XXX Message */ + /* Message */ } } @@ -3023,8 +2966,6 @@ void process_monster(MONSTER_IDX m_idx) /* Note changes to viewable region */ do_view = TRUE; - - /* Take a turn */ do_turn = TRUE; } @@ -3062,7 +3003,6 @@ void process_monster(MONSTER_IDX m_idx) /* Creature has been allowed move */ if (do_move) { - /* Take a turn */ do_turn = TRUE; if (have_flag(f_ptr->flags, FF_TREE)) @@ -3086,23 +3026,18 @@ void process_monster(MONSTER_IDX m_idx) y_ptr->fx = ox; /* Update the old monster */ - update_mon(c_ptr->m_idx, TRUE); + update_monster(c_ptr->m_idx, TRUE); } /* Hack -- Update the new location */ - c_ptr->m_idx = (s16b)m_idx; + c_ptr->m_idx = m_idx; /* Move the monster */ m_ptr->fy = ny; m_ptr->fx = nx; + update_monster(m_idx, TRUE); - /* Update the monster */ - update_mon(m_idx, TRUE); - - /* Redraw the old grid */ lite_spot(oy, ox); - - /* Redraw the new grid */ lite_spot(ny, nx); } else @@ -3119,25 +3054,22 @@ void process_monster(MONSTER_IDX m_idx) (disturb_near && (m_ptr->mflag & MFLAG_VIEW) && projectable(p_ptr->y, p_ptr->x, m_ptr->fy, m_ptr->fx)) || (disturb_high && ap_r_ptr->r_tkills && ap_r_ptr->level >= p_ptr->lev))) { - /* Disturb */ if (is_hostile(m_ptr)) - disturb(0, 1); + disturb(FALSE, TRUE); } /* Take or Kill objects on the floor */ if (c_ptr->o_idx && (r_ptr->flags2 & (RF2_TAKE_ITEM | RF2_KILL_ITEM)) && (!is_pet(m_ptr) || ((p_ptr->pet_extra_flags & PF_PICKUP_ITEMS) && (r_ptr->flags2 & RF2_TAKE_ITEM)))) { - s16b this_o_idx, next_o_idx; + OBJECT_IDX this_o_idx, next_o_idx; bool do_take = (r_ptr->flags2 & RF2_TAKE_ITEM) ? TRUE : FALSE; /* Scan all objects in the grid */ for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx) { - u32b flgs[TR_FLAG_SIZE], flg2 = 0L, flg3 = 0L, flgr = 0L; - char m_name[80], o_name[MAX_NLEN]; - - /* Acquire object */ + BIT_FLAGS flgs[TR_FLAG_SIZE], flg2 = 0L, flg3 = 0L, flgr = 0L; + GAME_TEXT m_name[MAX_NLEN], o_name[MAX_NLEN]; object_type *o_ptr = &o_list[this_o_idx]; /* Acquire next object */ @@ -3162,8 +3094,6 @@ void process_monster(MONSTER_IDX m_idx) /* Acquire the object name */ object_desc(o_name, o_ptr, 0); - - /* Acquire the monster name */ monster_desc(m_name, m_ptr, MD_INDEF_HIDDEN); /* React to objects that hurt the monster */ @@ -3198,13 +3128,11 @@ void process_monster(MONSTER_IDX m_idx) /* Only give a message for "take_item" */ if (do_take && (r_ptr->flags2 & RF2_STUPID)) { - /* Take note */ did_take_item = TRUE; /* Describe observable situations */ if (m_ptr->ml && player_can_see_bold(ny, nx)) { - /* Dump a message */ msg_format(_("%^sは%sを拾おうとしたが、だめだった。", "%^s tries to pick up %s, but fails."), m_name, o_name); } } @@ -3213,13 +3141,11 @@ void process_monster(MONSTER_IDX m_idx) /* Pick up the item */ else if (do_take) { - /* Take note */ did_take_item = TRUE; /* Describe observable situations */ if (player_can_see_bold(ny, nx)) { - /* Dump a message */ msg_format(_("%^sが%sを拾った。", "%^s picks up %s."), m_name, o_name); } @@ -3233,7 +3159,7 @@ void process_monster(MONSTER_IDX m_idx) o_ptr->iy = o_ptr->ix = 0; /* Memorize monster */ - o_ptr->held_m_idx = (s16b)m_idx; + o_ptr->held_m_idx = m_idx; /* Build a stack */ o_ptr->next_o_idx = m_ptr->hold_o_idx; @@ -3245,17 +3171,14 @@ void process_monster(MONSTER_IDX m_idx) /* Destroy the item if not a pet */ else if (!is_pet(m_ptr)) { - /* Take note */ did_kill_item = TRUE; /* Describe observable situations */ if (player_has_los_bold(ny, nx)) { - /* Dump a message */ msg_format(_("%^sが%sを破壊した。", "%^s destroys %s."), m_name, o_name); } - /* Delete the object */ delete_object_idx(this_o_idx); } } @@ -3287,10 +3210,7 @@ void process_monster(MONSTER_IDX m_idx) /* Notice changes in view */ if (do_view) { - /* Update some things */ p_ptr->update |= (PU_FLOW); - - /* Window stuff */ p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON); } @@ -3337,18 +3257,14 @@ void process_monster(MONSTER_IDX m_idx) /* Message if seen */ if (see_m) { - char m_name[80]; - - /* Acquire the monster name */ + GAME_TEXT m_name[MAX_NLEN]; monster_desc(m_name, m_ptr, 0); - - /* Dump a message */ msg_format(_("%^sは戦いを決意した!", "%^s turns to fight!"), m_name); } if (m_ptr->ml) chg_virtue(V_COMPASSION, -1); - /* XXX XXX XXX Actually do something now (?) */ + /* Actually do something now (?) */ } } @@ -3396,24 +3312,24 @@ void process_monsters(void) monster_type *m_ptr; monster_race *r_ptr; - int old_monster_race_idx; + MONRACE_IDX old_monster_race_idx; - u32b old_r_flags1 = 0L; - u32b old_r_flags2 = 0L; - u32b old_r_flags3 = 0L; - u32b old_r_flags4 = 0L; - u32b old_r_flags5 = 0L; - u32b old_r_flags6 = 0L; - u32b old_r_flagsr = 0L; + BIT_FLAGS old_r_flags1 = 0L; + BIT_FLAGS old_r_flags2 = 0L; + BIT_FLAGS old_r_flags3 = 0L; + BIT_FLAGS old_r_flags4 = 0L; + BIT_FLAGS old_r_flags5 = 0L; + BIT_FLAGS old_r_flags6 = 0L; + BIT_FLAGS old_r_flagsr = 0L; - byte old_r_blows0 = 0; - byte old_r_blows1 = 0; - byte old_r_blows2 = 0; - byte old_r_blows3 = 0; + byte old_r_blows0 = 0; + byte old_r_blows1 = 0; + byte old_r_blows2 = 0; + byte old_r_blows3 = 0; - byte old_r_cast_spell = 0; + byte old_r_cast_spell = 0; - int speed; + SPEED speed; /* Clear monster fighting indicator */ mon_fight = FALSE; @@ -3590,7 +3506,6 @@ void process_monsters(void) (old_r_blows3 != r_ptr->r_blows[3]) || (old_r_cast_spell != r_ptr->r_cast_spell)) { - /* Window stuff */ p_ptr->window |= (PW_MONSTER); } }