3 * @brief モンスター処理 / misc code for monsters
6 * Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke
7 * This software may be copied and distributed for educational, research,
8 * and not for profit purposes provided that this copyright and statement
9 * are included in all such copies. Other copyrights may also apply.
10 * 2014 Deskull rearranged comment for Doxygen.
15 #include "monsterrace-hook.h"
16 #include "monster-status.h"
17 #include "projection.h"
19 #include "spells-summon.h"
21 #define HORDE_NOGOOD 0x01 /*!< (未実装フラグ)HORDE生成でGOODなモンスターの生成を禁止する? */
22 #define HORDE_NOEVIL 0x02 /*!< (未実装フラグ)HORDE生成でEVILなモンスターの生成を禁止する? */
27 * @brief ELDRITCH HORROR効果時のモンスターの形容メッセージ(通常時)
29 concptr horror_desc[MAX_SAN_HORROR] =
85 * @brief ELDRITCH HORROR効果時のモンスターの形容メッセージ(幻覚状態時)
87 concptr funny_desc[MAX_SAN_FUNNY] =
148 * @var funny_comments
149 * @brief ELDRITCH HORROR効果時の幻覚時間延長を示す錯乱表現
151 concptr funny_comments[MAX_SAN_COMMENT] =
172 * @brief モンスターの目標地点をセットする / Set the target of counter attack
173 * @param m_ptr モンスターの参照ポインタ
178 void set_target(monster_type *m_ptr, POSITION y, POSITION x)
186 * @brief モンスターの目標地点をリセットする / Reset the target of counter attack
187 * @param m_ptr モンスターの参照ポインタ
190 void reset_target(monster_type *m_ptr)
192 set_target(m_ptr, 0, 0);
197 * @brief モンスターの真の種族を返す / Extract monster race pointer of a monster's true form
198 * @param m_ptr モンスターの参照ポインタ
199 * @return 本当のモンスター種族参照ポインタ
201 monster_race *real_r_ptr(monster_type *m_ptr)
203 return &r_info[real_r_idx(m_ptr)];
206 MONRACE_IDX real_r_idx(monster_type *m_ptr)
208 monster_race *r_ptr = &r_info[m_ptr->r_idx];
210 /* Extract real race */
211 if (m_ptr->mflag2 & MFLAG2_CHAMELEON)
213 if (r_ptr->flags1 & RF1_UNIQUE)
214 return MON_CHAMELEON_K;
216 return MON_CHAMELEON;
226 * @brief モンスター配列からモンスターを消去する / Delete a monster by index.
227 * @param i 消去するモンスターのID
230 * モンスターを削除するとそのモンスターが拾っていたアイテムも同時に削除される。 /
231 * When a monster is deleted, all of its objects are deleted.
233 void delete_monster_idx(MONSTER_IDX i)
236 monster_type *m_ptr = &m_list[i];
237 monster_race *r_ptr = &r_info[m_ptr->r_idx];
238 OBJECT_IDX this_o_idx, next_o_idx = 0;
243 /* Hack -- Reduce the racial counter */
244 real_r_ptr(m_ptr)->cur_num--;
246 /* Hack -- count the number of "reproducers" */
247 if (r_ptr->flags2 & (RF2_MULTIPLY)) num_repro--;
249 if (MON_CSLEEP(m_ptr)) (void)set_monster_csleep(i, 0);
250 if (MON_FAST(m_ptr)) (void)set_monster_fast(i, 0);
251 if (MON_SLOW(m_ptr)) (void)set_monster_slow(i, 0);
252 if (MON_STUNNED(m_ptr)) (void)set_monster_stunned(i, 0);
253 if (MON_CONFUSED(m_ptr)) (void)set_monster_confused(i, 0);
254 if (MON_MONFEAR(m_ptr)) (void)set_monster_monfear(i, 0);
255 if (MON_INVULNER(m_ptr)) (void)set_monster_invulner(i, 0, FALSE);
257 /* Hack -- remove target monster */
258 if (i == target_who) target_who = 0;
260 /* Hack -- remove tracked monster */
261 if (i == p_ptr->health_who) health_track(0);
263 if (pet_t_m_idx == i ) pet_t_m_idx = 0;
264 if (riding_t_m_idx == i) riding_t_m_idx = 0;
265 if (p_ptr->riding == i) p_ptr->riding = 0;
267 /* Monster is gone */
268 cave[y][x].m_idx = 0;
272 for (this_o_idx = m_ptr->hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
275 o_ptr = &o_list[this_o_idx];
277 /* Acquire next object */
278 next_o_idx = o_ptr->next_o_idx;
281 * o_ptr->held_m_idx is needed in delete_object_idx()
282 * to prevent calling lite_spot()
285 delete_object_idx(this_o_idx);
289 if (is_pet(m_ptr)) check_pets_num_and_align(m_ptr, FALSE);
292 /* Wipe the Monster */
293 (void)WIPE(m_ptr, monster_type);
301 /* Update some things */
302 if (r_ptr->flags7 & (RF7_LITE_MASK | RF7_DARK_MASK))
303 p_ptr->update |= (PU_MON_LITE);
308 * @brief 指定位置に存在するモンスターを削除する / Delete the monster, if any, at a given location
313 void delete_monster(POSITION y, POSITION x)
318 if (!in_bounds(y, x)) return;
323 /* Delete the monster (if any) */
324 if (c_ptr->m_idx) delete_monster_idx(c_ptr->m_idx);
329 * @brief モンスター情報を配列内移動する / Move an object from index i1 to index i2 in the object list
334 static void compact_monsters_aux(IDX i1, IDX i2)
340 OBJECT_IDX this_o_idx, next_o_idx = 0;
343 if (i1 == i2) return;
354 /* Update the cave */
357 /* Repair objects being carried by monster */
358 for (this_o_idx = m_ptr->hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
361 o_ptr = &o_list[this_o_idx];
363 /* Acquire next object */
364 next_o_idx = o_ptr->next_o_idx;
366 /* Reset monster pointer */
367 o_ptr->held_m_idx = i2;
370 /* Hack -- Update the target */
371 if (target_who == i1) target_who = i2;
373 /* Hack -- Update the target */
374 if (pet_t_m_idx == i1) pet_t_m_idx = i2;
375 if (riding_t_m_idx == i1) riding_t_m_idx = i2;
377 /* Hack -- Update the riding */
378 if (p_ptr->riding == i1) p_ptr->riding = i2;
380 /* Hack -- Update the health bar */
381 if (p_ptr->health_who == i1) health_track(i2);
383 /* Hack -- Update parent index */
386 for (i = 1; i < m_max; i++)
388 monster_type *m2_ptr = &m_list[i];
390 if (m2_ptr->parent_m_idx == i1)
391 m2_ptr->parent_m_idx = i2;
396 (void)COPY(&m_list[i2], &m_list[i1], monster_type);
399 (void)WIPE(&m_list[i1], monster_type);
401 for (i = 0; i < MAX_MTIMED; i++)
403 int mproc_idx = get_mproc_idx(i1, i);
404 if (mproc_idx >= 0) mproc_list[i][mproc_idx] = i2;
410 * @brief モンスター情報配列を圧縮する / Compact and Reorder the monster list
411 * @param size 圧縮後のモンスター件数目標
414 * This function can be very dangerous, use with caution!
416 * When actually "compacting" monsters, we base the saving throw
417 * on a combination of monster level, distance from player, and
418 * current "desperation".
420 * After "compacting" (if needed), we "reorder" the monsters into a more
421 * compact order, and we reset the allocation info, and the "live" array.
423 void compact_monsters(int size)
427 int cur_lev, cur_dis, chance;
429 /* Message (only if compacting) */
430 if (size) msg_print(_("モンスター情報を圧縮しています...", "Compacting monsters..."));
433 /* Compact at least 'size' objects */
434 for (num = 0, cnt = 1; num < size; cnt++)
436 /* Get more vicious each iteration */
439 /* Get closer each iteration */
440 cur_dis = 5 * (20 - cnt);
442 /* Check all the monsters */
443 for (i = 1; i < m_max; i++)
445 monster_type *m_ptr = &m_list[i];
447 monster_race *r_ptr = &r_info[m_ptr->r_idx];
449 /* Paranoia -- skip "dead" monsters */
450 if (!m_ptr->r_idx) continue;
452 /* Hack -- High level monsters start out "immune" */
453 if (r_ptr->level > cur_lev) continue;
455 if (i == p_ptr->riding) continue;
457 /* Ignore nearby monsters */
458 if ((cur_dis > 0) && (m_ptr->cdis < cur_dis)) continue;
460 /* Saving throw chance */
463 /* Only compact "Quest" Monsters in emergencies */
464 if ((r_ptr->flags1 & (RF1_QUESTOR)) && (cnt < 1000)) chance = 100;
466 /* Try not to compact Unique Monsters */
467 if (r_ptr->flags1 & (RF1_UNIQUE)) chance = 100;
469 /* All monsters get a saving throw */
470 if (randint0(100) < chance) continue;
472 if (record_named_pet && is_pet(m_ptr) && m_ptr->nickname)
474 GAME_TEXT m_name[MAX_NLEN];
475 monster_desc(m_name, m_ptr, MD_INDEF_VISIBLE);
476 do_cmd_write_nikki(NIKKI_NAMED_PET, RECORD_NAMED_PET_COMPACT, m_name);
479 delete_monster_idx(i);
481 /* Count the monster */
487 /* Excise dead monsters (backwards!) */
488 for (i = m_max - 1; i >= 1; i--)
490 /* Get the i'th monster */
491 monster_type *m_ptr = &m_list[i];
493 /* Skip real monsters */
494 if (m_ptr->r_idx) continue;
496 /* Move last monster into open hole */
497 compact_monsters_aux(m_max - 1, i);
499 /* Compress "m_max" */
506 * @brief プレイヤーのフロア離脱に伴う全モンスター配列の消去 / Delete/Remove all the monsters when the player leaves the level
509 * This is an efficient method of simulating multiple calls to the
510 * "delete_monster()" function, with no visual effects.
512 void wipe_m_list(void)
516 /* Hack -- if Banor or Lupart dies, stay another dead */
517 if (!r_info[MON_BANORLUPART].max_num)
519 if (r_info[MON_BANOR].max_num)
521 r_info[MON_BANOR].max_num = 0;
522 r_info[MON_BANOR].r_pkills++;
523 r_info[MON_BANOR].r_akills++;
524 if (r_info[MON_BANOR].r_tkills < MAX_SHORT) r_info[MON_BANOR].r_tkills++;
526 if (r_info[MON_LUPART].max_num)
528 r_info[MON_LUPART].max_num = 0;
529 r_info[MON_LUPART].r_pkills++;
530 r_info[MON_LUPART].r_akills++;
531 if (r_info[MON_LUPART].r_tkills < MAX_SHORT) r_info[MON_LUPART].r_tkills++;
535 /* Delete all the monsters */
536 for (i = m_max - 1; i >= 1; i--)
538 monster_type *m_ptr = &m_list[i];
540 /* Skip dead monsters */
541 if (!m_ptr->r_idx) continue;
543 /* Monster is gone */
544 cave[m_ptr->fy][m_ptr->fx].m_idx = 0;
546 /* Wipe the Monster */
547 (void)WIPE(m_ptr, monster_type);
552 * Wiping racial counters of all monsters and incrementing of racial
553 * counters of monsters in party_mon[] are required to prevent multiple
554 * generation of unique monster who is the minion of player.
557 /* Hack -- Wipe the racial counter of all monster races */
558 for (i = 1; i < max_r_idx; i++) r_info[i].cur_num = 0;
566 /* Reset "mproc_max[]" */
567 for (i = 0; i < MAX_MTIMED; i++) mproc_max[i] = 0;
569 /* Hack -- reset "reproducer" count */
572 /* Hack -- no more target */
577 /* Hack -- no more tracking */
583 * @brief モンスター配列の空きを探す / Acquires and returns the index of a "free" monster.
584 * @return 利用可能なモンスター配列の添字
586 * This routine should almost never fail, but it *can* happen.
588 MONSTER_IDX m_pop(void)
592 /* Normal allocation */
593 if (m_max < max_m_idx)
595 /* Access the next hole */
598 /* Expand the array */
604 /* Return the index */
608 /* Recycle dead monsters */
609 for (i = 1; i < m_max; i++)
613 /* Acquire monster */
616 /* Skip live monsters */
617 if (m_ptr->r_idx) continue;
622 /* Use this monster */
626 /* Warn the player (except during dungeon creation) */
627 if (character_dungeon) msg_print(_("モンスターが多すぎる!", "Too many monsters!"));
629 /* Try not to crash */
637 * @var summon_specific_type
638 * @brief 召喚条件を指定するグローバル変数 / Hack -- the "type" of the current "summon specific"
639 * @todo summon_specific_typeグローバル変数の除去と関数引数への代替を行う
641 static int summon_specific_type = 0;
645 * @var summon_specific_who
646 * @brief 召喚を行ったプレイヤーあるいはモンスターのIDを示すグローバル変数 / Hack -- the index of the summoning monster
647 * @todo summon_specific_who グローバル変数の除去と関数引数への代替を行う
649 static int summon_specific_who = -1;
652 * @var summon_unique_okay
653 * @brief 召喚対象にユニークを含めるかを示すグローバル変数 / summoning unique enable
654 * @todo summon_unique_okay グローバル変数の除去と関数引数への代替を行う
656 static bool summon_unique_okay = FALSE;
659 * @brief 指定されたモンスター種族がsummon_specific_typeで指定された召喚条件に合うかどうかを返す
660 * @return 召喚条件が一致するならtrue
663 static bool summon_specific_aux(MONRACE_IDX r_idx)
665 monster_race *r_ptr = &r_info[r_idx];
668 /* Check our requirements */
669 switch (summon_specific_type)
673 okay = (r_ptr->d_char == 'a');
679 okay = (r_ptr->d_char == 'S');
685 okay = ((r_ptr->d_char == 'C') || (r_ptr->d_char == 'Z'));
691 okay = (r_ptr->d_char == 'M');
697 okay = (r_ptr->d_char == 'A' && ((r_ptr->flags3 & RF3_EVIL) || (r_ptr->flags3 & RF3_GOOD)));
703 okay = (r_ptr->flags3 & RF3_DEMON);
709 okay = (r_ptr->flags3 & RF3_UNDEAD);
715 okay = (r_ptr->flags3 & RF3_DRAGON);
719 case SUMMON_HI_UNDEAD:
721 okay = ((r_ptr->d_char == 'L') ||
722 (r_ptr->d_char == 'V') ||
723 (r_ptr->d_char == 'W'));
727 case SUMMON_HI_DRAGON:
729 okay = (r_ptr->d_char == 'D');
733 case SUMMON_HI_DEMON:
735 okay = (((r_ptr->d_char == 'U') ||
736 (r_ptr->d_char == 'H') ||
737 (r_ptr->d_char == 'B')) &&
738 (r_ptr->flags3 & RF3_DEMON)) ? TRUE : FALSE;
742 case SUMMON_AMBERITES:
744 okay = (r_ptr->flags3 & (RF3_AMBERITE)) ? TRUE : FALSE;
750 okay = (r_ptr->flags1 & (RF1_UNIQUE)) ? TRUE : FALSE;
756 okay = (r_ptr->d_char == 'm');
761 okay = (r_ptr->d_char == 'b');
764 case SUMMON_QUYLTHULG:
766 okay = (r_ptr->d_char == 'Q');
770 case SUMMON_COIN_MIMIC:
772 okay = (r_ptr->d_char == '$');
778 okay = ((r_ptr->d_char == '!') ||
779 (r_ptr->d_char == '?') ||
780 (r_ptr->d_char == '=') ||
781 (r_ptr->d_char == '$') ||
782 (r_ptr->d_char == '|'));
788 okay = (r_ptr->d_char == 'g');
794 okay = ((r_ptr->d_char == 'U') &&
795 (r_ptr->flags4 & RF4_ROCKET));
801 okay = ((r_ptr->d_char == summon_kin_type) && (r_idx != MON_HAGURE));
807 okay = (r_idx == MON_DAWN);
813 okay = (r_ptr->flags3 & (RF3_ANIMAL));
817 case SUMMON_ANIMAL_RANGER:
819 okay = ((r_ptr->flags3 & (RF3_ANIMAL)) &&
820 (my_strchr("abcflqrwBCHIJKMRS", r_ptr->d_char)) &&
821 !(r_ptr->flags3 & (RF3_DRAGON)) &&
822 !(r_ptr->flags3 & (RF3_EVIL)) &&
823 !(r_ptr->flags3 & (RF3_UNDEAD)) &&
824 !(r_ptr->flags3 & (RF3_DEMON)) &&
825 !(r_ptr->flags2 & (RF2_MULTIPLY)) &&
826 !(r_ptr->flags4 || r_ptr->a_ability_flags1 || r_ptr->a_ability_flags2));
830 case SUMMON_HI_DRAGON_LIVING:
832 okay = ((r_ptr->d_char == 'D') && monster_living(r_idx));
838 okay = monster_living(r_idx);
844 okay = (r_idx == MON_PHANTOM_B || r_idx == MON_PHANTOM_W);
848 case SUMMON_BLUE_HORROR:
850 okay = (r_idx == MON_BLUE_HORROR);
854 case SUMMON_ELEMENTAL:
856 okay = (r_ptr->d_char == 'E');
862 okay = (r_ptr->d_char == 'v');
868 okay = (r_ptr->d_char == 'H');
874 okay = (r_ptr->d_char == 'B');
878 case SUMMON_KAMIKAZE:
881 for (i = 0; i < 4; i++)
882 if (r_ptr->blow[i].method == RBM_EXPLODE) okay = TRUE;
886 case SUMMON_KAMIKAZE_LIVING:
890 for (i = 0; i < 4; i++)
891 if (r_ptr->blow[i].method == RBM_EXPLODE) okay = TRUE;
892 okay = (okay && monster_living(r_idx));
898 okay = (r_idx == MON_MANES);
904 okay = (r_idx == MON_LOUSE);
908 case SUMMON_GUARDIANS:
910 okay = (r_ptr->flags7 & RF7_GUARDIAN);
916 okay = ((r_idx == MON_NOV_PALADIN) ||
917 (r_idx == MON_NOV_PALADIN_G) ||
918 (r_idx == MON_PALADIN) ||
919 (r_idx == MON_W_KNIGHT) ||
920 (r_idx == MON_ULTRA_PALADIN) ||
921 (r_idx == MON_KNI_TEMPLAR));
927 okay = (r_ptr->d_char == 'B' &&
928 (r_ptr->flags8 & RF8_WILD_MOUNTAIN) &&
929 (r_ptr->flags8 & RF8_WILD_ONLY));
933 case SUMMON_PIRANHAS:
935 okay = (r_idx == MON_PIRANHA);
939 case SUMMON_ARMAGE_GOOD:
941 okay = (r_ptr->d_char == 'A' && (r_ptr->flags3 & RF3_GOOD));
945 case SUMMON_ARMAGE_EVIL:
947 okay = ((r_ptr->flags3 & RF3_DEMON) ||
948 (r_ptr->d_char == 'A' && (r_ptr->flags3 & RF3_EVIL)));
952 /* Since okay is int, "return (okay);" is not correct. */
953 return (bool)(okay ? TRUE : FALSE);
957 * @var chameleon_change_m_idx
958 * @brief カメレオンの変身先モンスターIDを受け渡すためのグローバル変数
959 * @todo 変数渡しの問題などもあるができればchameleon_change_m_idxのグローバル変数を除去し、関数引き渡しに移行すること
961 static int chameleon_change_m_idx = 0;
965 * @brief 指定されたモンスター種族がダンジョンの制限にかかるかどうかをチェックする / Some dungeon types restrict the possible monsters.
966 * @param r_idx チェックするモンスター種族ID
967 * @return 召喚条件が一致するならtrue / Return TRUE is the monster is OK and FALSE otherwise
969 static bool restrict_monster_to_dungeon(MONRACE_IDX r_idx)
971 dungeon_info_type *d_ptr = &d_info[dungeon_type];
972 monster_race *r_ptr = &r_info[r_idx];
975 if (d_ptr->flags1 & DF1_CHAMELEON)
977 if (chameleon_change_m_idx) return TRUE;
979 if (d_ptr->flags1 & DF1_NO_MAGIC)
981 if (r_idx != MON_CHAMELEON &&
983 !(r_ptr->flags4 & RF4_NOMAGIC_MASK) &&
984 !(r_ptr->a_ability_flags1 & RF5_NOMAGIC_MASK) &&
985 !(r_ptr->a_ability_flags2 & RF6_NOMAGIC_MASK))
988 if (d_ptr->flags1 & DF1_NO_MELEE)
990 if (r_idx == MON_CHAMELEON) return TRUE;
991 if (!(r_ptr->flags4 & (RF4_BOLT_MASK | RF4_BEAM_MASK | RF4_BALL_MASK)) &&
992 !(r_ptr->a_ability_flags1 & (RF5_BOLT_MASK | RF5_BEAM_MASK | RF5_BALL_MASK | RF5_CAUSE_1 | RF5_CAUSE_2 | RF5_CAUSE_3 | RF5_CAUSE_4 | RF5_MIND_BLAST | RF5_BRAIN_SMASH)) &&
993 !(r_ptr->a_ability_flags2 & (RF6_BOLT_MASK | RF6_BEAM_MASK | RF6_BALL_MASK)))
996 if (d_ptr->flags1 & DF1_BEGINNER)
998 if (r_ptr->level > dun_level)
1002 if (d_ptr->special_div >= 64) return TRUE;
1003 if (summon_specific_type && !(d_ptr->flags1 & DF1_CHAMELEON)) return TRUE;
1005 switch (d_ptr->mode)
1007 case DUNGEON_MODE_AND:
1010 if ((d_ptr->mflags1 & r_ptr->flags1) != d_ptr->mflags1)
1015 if ((d_ptr->mflags2 & r_ptr->flags2) != d_ptr->mflags2)
1020 if ((d_ptr->mflags3 & r_ptr->flags3) != d_ptr->mflags3)
1025 if ((d_ptr->mflags4 & r_ptr->flags4) != d_ptr->mflags4)
1028 if (d_ptr->m_a_ability_flags1)
1030 if ((d_ptr->m_a_ability_flags1 & r_ptr->a_ability_flags1) != d_ptr->m_a_ability_flags1)
1033 if (d_ptr->m_a_ability_flags2)
1035 if ((d_ptr->m_a_ability_flags2 & r_ptr->a_ability_flags2) != d_ptr->m_a_ability_flags2)
1040 if ((d_ptr->mflags7 & r_ptr->flags7) != d_ptr->mflags7)
1045 if ((d_ptr->mflags8 & r_ptr->flags8) != d_ptr->mflags8)
1050 if ((d_ptr->mflags9 & r_ptr->flags9) != d_ptr->mflags9)
1055 if ((d_ptr->mflagsr & r_ptr->flagsr) != d_ptr->mflagsr)
1058 for (a = 0; a < 5; a++)
1059 if (d_ptr->r_char[a] && (d_ptr->r_char[a] != r_ptr->d_char)) return FALSE;
1063 case DUNGEON_MODE_NAND:
1066 if ((d_ptr->mflags1 & r_ptr->flags1) != d_ptr->mflags1)
1071 if ((d_ptr->mflags2 & r_ptr->flags2) != d_ptr->mflags2)
1076 if ((d_ptr->mflags3 & r_ptr->flags3) != d_ptr->mflags3)
1081 if ((d_ptr->mflags4 & r_ptr->flags4) != d_ptr->mflags4)
1084 if (d_ptr->m_a_ability_flags1)
1086 if ((d_ptr->m_a_ability_flags1 & r_ptr->a_ability_flags1) != d_ptr->m_a_ability_flags1)
1089 if (d_ptr->m_a_ability_flags2)
1091 if ((d_ptr->m_a_ability_flags2 & r_ptr->a_ability_flags2) != d_ptr->m_a_ability_flags2)
1096 if ((d_ptr->mflags7 & r_ptr->flags7) != d_ptr->mflags7)
1101 if ((d_ptr->mflags8 & r_ptr->flags8) != d_ptr->mflags8)
1106 if ((d_ptr->mflags9 & r_ptr->flags9) != d_ptr->mflags9)
1111 if ((d_ptr->mflagsr & r_ptr->flagsr) != d_ptr->mflagsr)
1114 for (a = 0; a < 5; a++)
1115 if (d_ptr->r_char[a] && (d_ptr->r_char[a] != r_ptr->d_char)) return TRUE;
1119 case DUNGEON_MODE_OR:
1120 if (r_ptr->flags1 & d_ptr->mflags1) return TRUE;
1121 if (r_ptr->flags2 & d_ptr->mflags2) return TRUE;
1122 if (r_ptr->flags3 & d_ptr->mflags3) return TRUE;
1123 if (r_ptr->flags4 & d_ptr->mflags4) return TRUE;
1124 if (r_ptr->a_ability_flags1 & d_ptr->m_a_ability_flags1) return TRUE;
1125 if (r_ptr->a_ability_flags2 & d_ptr->m_a_ability_flags2) return TRUE;
1126 if (r_ptr->flags7 & d_ptr->mflags7) return TRUE;
1127 if (r_ptr->flags8 & d_ptr->mflags8) return TRUE;
1128 if (r_ptr->flags9 & d_ptr->mflags9) return TRUE;
1129 if (r_ptr->flagsr & d_ptr->mflagsr) return TRUE;
1130 for (a = 0; a < 5; a++)
1131 if (d_ptr->r_char[a] == r_ptr->d_char) return TRUE;
1135 case DUNGEON_MODE_NOR:
1136 if (r_ptr->flags1 & d_ptr->mflags1) return FALSE;
1137 if (r_ptr->flags2 & d_ptr->mflags2) return FALSE;
1138 if (r_ptr->flags3 & d_ptr->mflags3) return FALSE;
1139 if (r_ptr->flags4 & d_ptr->mflags4) return FALSE;
1140 if (r_ptr->a_ability_flags1 & d_ptr->m_a_ability_flags1) return FALSE;
1141 if (r_ptr->a_ability_flags2 & d_ptr->m_a_ability_flags2) return FALSE;
1142 if (r_ptr->flags7 & d_ptr->mflags7) return FALSE;
1143 if (r_ptr->flags8 & d_ptr->mflags8) return FALSE;
1144 if (r_ptr->flags9 & d_ptr->mflags9) return FALSE;
1145 if (r_ptr->flagsr & d_ptr->mflagsr) return FALSE;
1146 for (a = 0; a < 5; a++)
1147 if (d_ptr->r_char[a] == r_ptr->d_char) return FALSE;
1156 * @brief モンスター生成制限関数最大2つから / Apply a "monster restriction function" to the "monster allocation table"
1157 * @param monster_hook 制限関数1
1158 * @param monster_hook2 制限関数2
1161 errr get_mon_num_prep(monsterrace_hook_type monster_hook,
1162 monsterrace_hook_type monster_hook2)
1166 /* Todo: Check the hooks for non-changes */
1168 /* Set the new hooks */
1169 get_mon_num_hook = monster_hook;
1170 get_mon_num2_hook = monster_hook2;
1172 /* Scan the allocation table */
1173 for (i = 0; i < alloc_race_size; i++)
1175 monster_race *r_ptr;
1178 alloc_entry *entry = &alloc_race_table[i];
1181 r_ptr = &r_info[entry->index];
1183 /* Skip monsters which don't pass the restriction */
1184 if ((get_mon_num_hook && !((*get_mon_num_hook)(entry->index))) ||
1185 (get_mon_num2_hook && !((*get_mon_num2_hook)(entry->index))))
1188 if (!p_ptr->inside_battle && !chameleon_change_m_idx &&
1189 summon_specific_type != SUMMON_GUARDIANS)
1191 /* Hack -- don't create questors */
1192 if (r_ptr->flags1 & RF1_QUESTOR)
1195 if (r_ptr->flags7 & RF7_GUARDIAN)
1198 /* Depth Monsters never appear out of depth */
1199 if ((r_ptr->flags1 & (RF1_FORCE_DEPTH)) &&
1200 (r_ptr->level > dun_level))
1204 /* Accept this monster */
1205 entry->prob2 = entry->prob1;
1207 if (dun_level && (!p_ptr->inside_quest || is_fixed_quest_idx(p_ptr->inside_quest)) && !restrict_monster_to_dungeon(entry->index) && !p_ptr->inside_battle)
1209 int hoge = entry->prob2 * d_info[dungeon_type].special_div;
1210 entry->prob2 = hoge / 64;
1211 if (randint0(64) < (hoge & 0x3f)) entry->prob2++;
1221 * @brief 生成モンスター種族を1種生成テーブルから選択する
1223 * @return 選択されたモンスター生成種族
1225 * Choose a monster race that seems "appropriate" to the given level
1227 * This function uses the "prob2" field of the "monster allocation table",
1228 * and various local information, to calculate the "prob3" field of the
1229 * same table, which is then used to choose an "appropriate" monster, in
1230 * a relatively efficient manner.
1232 * Note that "town" monsters will *only* be created in the town, and
1233 * "normal" monsters will *never* be created in the town, unless the
1234 * "level" is "modified", for example, by polymorph or summoning.
1236 * There is a small chance (1/50) of "boosting" the given depth by
1237 * a small amount (up to four levels), except in the town.
1239 * It is (slightly) more likely to acquire a monster of the given level
1240 * than one of a lower level. This is done by choosing several monsters
1241 * appropriate to the given level and keeping the "hardest" one.
1243 * Note that if no monsters are "appropriate", then this function will
1244 * fail, and return zero, but this should *almost* never happen.
1246 MONRACE_IDX get_mon_num(DEPTH level)
1251 monster_race *r_ptr;
1252 alloc_entry *table = alloc_race_table;
1254 int pls_kakuritu, pls_level;
1255 int delay = mysqrt(level * 10000L) + 400L;
1257 pls_kakuritu = MAX(NASTY_MON_MAX, NASTY_MON_BASE - ((dungeon_turn / (TURNS_PER_TICK * 5000L) - delay / 10)));
1258 pls_level = MIN(NASTY_MON_PLUS_MAX, 3 + dungeon_turn / (TURNS_PER_TICK * 40000L) - delay / 40 + MIN(5, level / 10)) ;
1260 if (d_info[dungeon_type].flags1 & DF1_MAZE)
1262 pls_kakuritu = MIN(pls_kakuritu / 2, pls_kakuritu - 10);
1263 if (pls_kakuritu < 2) pls_kakuritu = 2;
1268 /* Boost the level */
1269 if (!p_ptr->inside_battle && !(d_info[dungeon_type].flags1 & DF1_BEGINNER))
1271 /* Nightmare mode allows more out-of depth monsters */
1272 if (ironman_nightmare && !randint0(pls_kakuritu))
1274 /* What a bizarre calculation */
1275 level = 1 + (level * MAX_DEPTH / randint1(MAX_DEPTH));
1279 /* Occasional "nasty" monster */
1280 if (!randint0(pls_kakuritu))
1282 /* Pick a level bonus */
1288 if (level > MAX_DEPTH - 1) level = MAX_DEPTH - 1;
1289 if (level < 0) level = 0;
1294 /* Process probabilities */
1295 for (i = 0; i < alloc_race_size; i++)
1297 /* Monsters are sorted by depth */
1298 if (table[i].level > level) break;
1303 /* Access the "r_idx" of the chosen monster */
1304 r_idx = table[i].index;
1306 /* Access the actual race */
1307 r_ptr = &r_info[r_idx];
1309 if (!p_ptr->inside_battle && !chameleon_change_m_idx)
1311 /* Hack -- "unique" monsters must be "unique" */
1312 if (((r_ptr->flags1 & (RF1_UNIQUE)) ||
1313 (r_ptr->flags7 & (RF7_NAZGUL))) &&
1314 (r_ptr->cur_num >= r_ptr->max_num))
1319 if ((r_ptr->flags7 & (RF7_UNIQUE2)) &&
1320 (r_ptr->cur_num >= 1))
1325 if (r_idx == MON_BANORLUPART)
1327 if (r_info[MON_BANOR].cur_num > 0) continue;
1328 if (r_info[MON_LUPART].cur_num > 0) continue;
1333 table[i].prob3 = table[i].prob2;
1336 total += table[i].prob3;
1339 /* No legal monsters */
1340 if (total <= 0) return (0);
1342 /* Pick a monster */
1343 value = randint0(total);
1345 /* Find the monster */
1346 for (i = 0; i < alloc_race_size; i++)
1348 /* Found the entry */
1349 if (value < table[i].prob3) break;
1352 value = value - table[i].prob3;
1358 /* Try for a "harder" monster once (50%) or twice (10%) */
1364 /* Pick a monster */
1365 value = randint0(total);
1367 /* Find the monster */
1368 for (i = 0; i < alloc_race_size; i++)
1370 /* Found the entry */
1371 if (value < table[i].prob3) break;
1374 value = value - table[i].prob3;
1377 /* Keep the "best" one */
1378 if (table[i].level < table[j].level) i = j;
1381 /* Try for a "harder" monster twice (10%) */
1387 /* Pick a monster */
1388 value = randint0(total);
1390 /* Find the monster */
1391 for (i = 0; i < alloc_race_size; i++)
1393 /* Found the entry */
1394 if (value < table[i].prob3) break;
1397 value = value - table[i].prob3;
1400 /* Keep the "best" one */
1401 if (table[i].level < table[j].level) i = j;
1403 return (table[i].index);
1408 * @brief モンスターの呼称を作成する / Build a string describing a monster in some way.
1409 * @param desc 記述出力先の文字列参照ポインタ
1410 * @param m_ptr モンスターの参照ポインタ
1411 * @param mode 呼称オプション
1414 * We can correctly describe monsters based on their visibility.
1415 * We can force all monsters to be treated as visible or invisible.
1416 * We can build nominatives, objectives, possessives, or reflexives.
1417 * We can selectively pronominalize hidden, visible, or all monsters.
1418 * We can use definite or indefinite descriptions for hidden monsters.
1419 * We can use definite or indefinite descriptions for visible monsters.
1421 * Pronominalization involves the gender whenever possible and allowed,
1422 * so that by cleverly requesting pronominalization / visibility, you
1423 * can get messages like "You hit someone. She screams in agony!".
1425 * Reflexives are acquired by requesting Objective plus Possessive.
1427 * If no m_ptr arg is given (?), the monster is assumed to be hidden,
1428 * unless the "Assume Visible" mode is requested.
1430 * If no r_ptr arg is given, it is extracted from m_ptr and r_info
1431 * If neither m_ptr nor r_ptr is given, the monster is assumed to
1432 * be neuter, singular, and hidden (unless "Assume Visible" is set),
1433 * in which case you may be in trouble... :-)
1435 * I am assuming that no monster name is more than 70 characters long,
1436 * so that "char desc[80];" is sufficiently large for any result.
1439 * MD_OBJECTIVE --> Objective (or Reflexive)
1440 * MD_POSSESSIVE --> Possessive (or Reflexive)
1441 * MD_INDEF_HIDDEN --> Use indefinites for hidden monsters ("something")
1442 * MD_INDEF_VISIBLE --> Use indefinites for visible monsters ("a kobold")
1443 * MD_PRON_HIDDEN --> Pronominalize hidden monsters
1444 * MD_PRON_VISIBLE --> Pronominalize visible monsters
1445 * MD_ASSUME_HIDDEN --> Assume the monster is hidden
1446 * MD_ASSUME_VISIBLE --> Assume the monster is visible
1447 * MD_TRUE_NAME --> Chameleon's true name
1448 * MD_IGNORE_HALLU --> Ignore hallucination, and penetrate shape change
1451 * 0x00 --> Full nominative name ("the kobold") or "it"
1452 * MD_INDEF_HIDDEN --> Full nominative name ("the kobold") or "something"
1453 * MD_ASSUME_VISIBLE --> Genocide resistance name ("the kobold")
1454 * MD_ASSUME_VISIBLE | MD_INDEF_VISIBLE --> Killing name ("a kobold")
1455 * MD_PRON_VISIBLE | MD_POSSESSIVE
1456 * --> Possessive, genderized if visable ("his") or "its"
1457 * MD_PRON_VISIBLE | MD_POSSESSIVE | MD_OBJECTIVE
1458 * --> Reflexive, genderized if visable ("himself") or "itself"
1460 void monster_desc(char *desc, monster_type *m_ptr, BIT_FLAGS mode)
1463 monster_race *r_ptr;
1467 GAME_TEXT silly_name[1024];
1471 r_ptr = &r_info[m_ptr->ap_r_idx];
1473 /* Mode of MD_TRUE_NAME will reveal Chameleon's true name */
1474 if (mode & MD_TRUE_NAME) name = (r_name + real_r_ptr(m_ptr)->name);
1475 else name = (r_name + r_ptr->name);
1477 /* Are we hallucinating? (Idea from Nethack...) */
1478 if (p_ptr->image && !(mode & MD_IGNORE_HALLU))
1482 if (!get_rnd_line(_("silly_j.txt", "silly.txt"), m_ptr->r_idx, silly_name))
1488 monster_race *hallu_race;
1492 hallu_race = &r_info[randint1(max_r_idx - 1)];
1494 while (!hallu_race->name || (hallu_race->flags1 & RF1_UNIQUE));
1496 strcpy(silly_name, (r_name + hallu_race->name));
1499 /* Better not strcpy it, or we could corrupt r_info... */
1503 /* Can we "see" it (exists + forced, or visible + not unforced) */
1504 seen = (m_ptr && ((mode & MD_ASSUME_VISIBLE) || (!(mode & MD_ASSUME_HIDDEN) && m_ptr->ml)));
1506 /* Sexed Pronouns (seen and allowed, or unseen and allowed) */
1507 pron = (m_ptr && ((seen && (mode & MD_PRON_VISIBLE)) || (!seen && (mode & MD_PRON_HIDDEN))));
1510 /* First, try using pronouns, or describing hidden monsters */
1513 /* an encoding of the monster "sex" */
1516 /* Extract the gender (if applicable) */
1517 if (r_ptr->flags1 & (RF1_FEMALE)) kind = 0x20;
1518 else if (r_ptr->flags1 & (RF1_MALE)) kind = 0x10;
1520 /* Ignore the gender (if desired) */
1521 if (!m_ptr || !pron) kind = 0x00;
1524 /* Assume simple result */
1525 res = _("何か", "it");
1527 /* Brute force: split on the possibilities */
1528 switch (kind + (mode & (MD_INDEF_HIDDEN | MD_POSSESSIVE | MD_OBJECTIVE)))
1530 /* Neuter, or unknown */
1532 case 0x00: res = "何か"; break;
1533 case 0x00 + (MD_OBJECTIVE): res = "何か"; break;
1534 case 0x00 + (MD_POSSESSIVE): res = "何かの"; break;
1535 case 0x00 + (MD_POSSESSIVE | MD_OBJECTIVE): res = "何か自身"; break;
1536 case 0x00 + (MD_INDEF_HIDDEN): res = "何か"; break;
1537 case 0x00 + (MD_INDEF_HIDDEN | MD_OBJECTIVE): res = "何か"; break;
1538 case 0x00 + (MD_INDEF_HIDDEN | MD_POSSESSIVE): res = "何か"; break;
1539 case 0x00 + (MD_INDEF_HIDDEN | MD_POSSESSIVE | MD_OBJECTIVE): res = "それ自身"; break;
1541 case 0x00: res = "it"; break;
1542 case 0x00 + (MD_OBJECTIVE): res = "it"; break;
1543 case 0x00 + (MD_POSSESSIVE): res = "its"; break;
1544 case 0x00 + (MD_POSSESSIVE | MD_OBJECTIVE): res = "itself"; break;
1545 case 0x00 + (MD_INDEF_HIDDEN): res = "something"; break;
1546 case 0x00 + (MD_INDEF_HIDDEN | MD_OBJECTIVE): res = "something"; break;
1547 case 0x00 + (MD_INDEF_HIDDEN | MD_POSSESSIVE): res = "something's"; break;
1548 case 0x00 + (MD_INDEF_HIDDEN | MD_POSSESSIVE | MD_OBJECTIVE): res = "itself"; break;
1552 /* Male (assume human if vague) */
1554 case 0x10: res = "彼"; break;
1555 case 0x10 + (MD_OBJECTIVE): res = "彼"; break;
1556 case 0x10 + (MD_POSSESSIVE): res = "彼の"; break;
1557 case 0x10 + (MD_POSSESSIVE | MD_OBJECTIVE): res = "彼自身"; break;
1558 case 0x10 + (MD_INDEF_HIDDEN): res = "誰か"; break;
1559 case 0x10 + (MD_INDEF_HIDDEN | MD_OBJECTIVE): res = "誰か"; break;
1560 case 0x10 + (MD_INDEF_HIDDEN | MD_POSSESSIVE): res = "誰かの"; break;
1561 case 0x10 + (MD_INDEF_HIDDEN | MD_POSSESSIVE | MD_OBJECTIVE): res = "彼自身"; break;
1563 case 0x10: res = "he"; break;
1564 case 0x10 + (MD_OBJECTIVE): res = "him"; break;
1565 case 0x10 + (MD_POSSESSIVE): res = "his"; break;
1566 case 0x10 + (MD_POSSESSIVE | MD_OBJECTIVE): res = "himself"; break;
1567 case 0x10 + (MD_INDEF_HIDDEN): res = "someone"; break;
1568 case 0x10 + (MD_INDEF_HIDDEN | MD_OBJECTIVE): res = "someone"; break;
1569 case 0x10 + (MD_INDEF_HIDDEN | MD_POSSESSIVE): res = "someone's"; break;
1570 case 0x10 + (MD_INDEF_HIDDEN | MD_POSSESSIVE | MD_OBJECTIVE): res = "himself"; break;
1574 /* Female (assume human if vague) */
1576 case 0x20: res = "彼女"; break;
1577 case 0x20 + (MD_OBJECTIVE): res = "彼女"; break;
1578 case 0x20 + (MD_POSSESSIVE): res = "彼女の"; break;
1579 case 0x20 + (MD_POSSESSIVE | MD_OBJECTIVE): res = "彼女自身"; break;
1580 case 0x20 + (MD_INDEF_HIDDEN): res = "誰か"; break;
1581 case 0x20 + (MD_INDEF_HIDDEN | MD_OBJECTIVE): res = "誰か"; break;
1582 case 0x20 + (MD_INDEF_HIDDEN | MD_POSSESSIVE): res = "誰かの"; break;
1583 case 0x20 + (MD_INDEF_HIDDEN | MD_POSSESSIVE | MD_OBJECTIVE): res = "彼女自身"; break;
1585 case 0x20: res = "she"; break;
1586 case 0x20 + (MD_OBJECTIVE): res = "her"; break;
1587 case 0x20 + (MD_POSSESSIVE): res = "her"; break;
1588 case 0x20 + (MD_POSSESSIVE | MD_OBJECTIVE): res = "herself"; break;
1589 case 0x20 + (MD_INDEF_HIDDEN): res = "someone"; break;
1590 case 0x20 + (MD_INDEF_HIDDEN | MD_OBJECTIVE): res = "someone"; break;
1591 case 0x20 + (MD_INDEF_HIDDEN | MD_POSSESSIVE): res = "someone's"; break;
1592 case 0x20 + (MD_INDEF_HIDDEN | MD_POSSESSIVE | MD_OBJECTIVE): res = "herself"; break;
1596 /* Copy the result */
1597 (void)strcpy(desc, res);
1601 /* Handle visible monsters, "reflexive" request */
1602 else if ((mode & (MD_POSSESSIVE | MD_OBJECTIVE)) == (MD_POSSESSIVE | MD_OBJECTIVE))
1604 /* The monster is visible, so use its gender */
1606 if (r_ptr->flags1 & (RF1_FEMALE)) strcpy(desc, "彼女自身");
1607 else if (r_ptr->flags1 & (RF1_MALE)) strcpy(desc, "彼自身");
1608 else strcpy(desc, "それ自身");
1610 if (r_ptr->flags1 & RF1_FEMALE) strcpy(desc, "herself");
1611 else if (r_ptr->flags1 & RF1_MALE) strcpy(desc, "himself");
1612 else strcpy(desc, "itself");
1617 /* Handle all other visible monster requests */
1621 if (is_pet(m_ptr) && !is_original_ap(m_ptr))
1627 while(strncmp(t, "』", 2) && *t) t++;
1631 (void)sprintf(desc, "%s?』", buf);
1634 (void)sprintf(desc, "%s?", name);
1636 (void)sprintf(desc, "%s?", name);
1641 /* It could be a Unique */
1642 if ((r_ptr->flags1 & RF1_UNIQUE) && !(p_ptr->image && !(mode & MD_IGNORE_HALLU)))
1644 /* Start with the name (thus nominative and objective) */
1645 if ((m_ptr->mflag2 & MFLAG2_CHAMELEON) && !(mode & MD_TRUE_NAME))
1651 while (strncmp(t, "』", 2) && *t) t++;
1655 (void)sprintf(desc, "%s?』", buf);
1658 (void)sprintf(desc, "%s?", name);
1660 (void)sprintf(desc, "%s?", name);
1664 /* Inside monster arena, and it is not your mount */
1665 else if (p_ptr->inside_battle &&
1666 !(p_ptr->riding && (&m_list[p_ptr->riding] == m_ptr)))
1668 /* It is a fake unique monster */
1669 (void)sprintf(desc, _("%sもどき", "fake %s"), name);
1674 (void)strcpy(desc, name);
1678 /* It could be an indefinite monster */
1679 else if (mode & MD_INDEF_VISIBLE)
1681 /* XXX Check plurality for "some" */
1683 /* Indefinite monsters need an indefinite article */
1685 (void)strcpy(desc, "");
1687 (void)strcpy(desc, is_a_vowel(name[0]) ? "an " : "a ");
1690 (void)strcat(desc, name);
1693 /* It could be a normal, definite, monster */
1696 /* Definite monsters need a definite article */
1698 (void)strcpy(desc, _("あなたの", "your "));
1700 (void)strcpy(desc, _("", "the "));
1702 (void)strcat(desc, name);
1705 if (m_ptr->nickname)
1707 sprintf(buf,_("「%s」", " called %s"),quark_str(m_ptr->nickname));
1711 if (p_ptr->riding && (&m_list[p_ptr->riding] == m_ptr))
1713 strcat(desc,_("(乗馬中)", "(riding)"));
1716 if ((mode & MD_IGNORE_HALLU) && (m_ptr->mflag2 & MFLAG2_CHAMELEON))
1718 if (r_ptr->flags1 & RF1_UNIQUE)
1720 strcat(desc,_("(カメレオンの王)", "(Chameleon Lord)"));
1724 strcat(desc,_("(カメレオン)", "(Chameleon)"));
1728 if ((mode & MD_IGNORE_HALLU) && !is_original_ap(m_ptr))
1730 strcat(desc, format("(%s)", r_name + r_info[m_ptr->r_idx].name));
1733 /* Handle the Possessive as a special afterthought */
1734 if (mode & MD_POSSESSIVE)
1736 /* XXX Check for trailing "s" */
1738 /* Simply append "apostrophe" and "s" */
1739 (void)strcat(desc, _("の", "'s"));
1747 * @brief モンスターの調査による思い出補完処理 / Learn about a monster (by "probing" it)
1748 * @param r_idx 補完されるモンスター種族ID
1749 * @return 明らかになった情報の度数
1751 * Return the number of new flags learnt. -Mogami-
1753 int lore_do_probe(MONRACE_IDX r_idx)
1755 monster_race *r_ptr = &r_info[r_idx];
1759 /* Maximal info about awareness */
1760 if (r_ptr->r_wake != MAX_UCHAR) n++;
1761 if (r_ptr->r_ignore != MAX_UCHAR) n++;
1762 r_ptr->r_wake = r_ptr->r_ignore = MAX_UCHAR;
1764 /* Observe "maximal" attacks */
1765 for (i = 0; i < 4; i++)
1767 /* Examine "actual" blows */
1768 if (r_ptr->blow[i].effect || r_ptr->blow[i].method)
1770 /* Maximal observations */
1771 if (r_ptr->r_blows[i] != MAX_UCHAR) n++;
1772 r_ptr->r_blows[i] = MAX_UCHAR;
1778 (((r_ptr->flags1 & RF1_DROP_4D2) ? 8 : 0) +
1779 ((r_ptr->flags1 & RF1_DROP_3D2) ? 6 : 0) +
1780 ((r_ptr->flags1 & RF1_DROP_2D2) ? 4 : 0) +
1781 ((r_ptr->flags1 & RF1_DROP_1D2) ? 2 : 0) +
1782 ((r_ptr->flags1 & RF1_DROP_90) ? 1 : 0) +
1783 ((r_ptr->flags1 & RF1_DROP_60) ? 1 : 0));
1785 /* Only "valid" drops */
1786 if (!(r_ptr->flags1 & RF1_ONLY_GOLD))
1788 if (r_ptr->r_drop_item != tmp_byte) n++;
1789 r_ptr->r_drop_item = tmp_byte;
1791 if (!(r_ptr->flags1 & RF1_ONLY_ITEM))
1793 if (r_ptr->r_drop_gold != tmp_byte) n++;
1794 r_ptr->r_drop_gold = tmp_byte;
1797 /* Observe many spells */
1798 if (r_ptr->r_cast_spell != MAX_UCHAR) n++;
1799 r_ptr->r_cast_spell = MAX_UCHAR;
1801 /* Count unknown flags */
1802 for (i = 0; i < 32; i++)
1804 if (!(r_ptr->r_flags1 & (1L << i)) &&
1805 (r_ptr->flags1 & (1L << i))) n++;
1806 if (!(r_ptr->r_flags2 & (1L << i)) &&
1807 (r_ptr->flags2 & (1L << i))) n++;
1808 if (!(r_ptr->r_flags3 & (1L << i)) &&
1809 (r_ptr->flags3 & (1L << i))) n++;
1810 if (!(r_ptr->r_flags4 & (1L << i)) &&
1811 (r_ptr->flags4 & (1L << i))) n++;
1812 if (!(r_ptr->r_flags5 & (1L << i)) &&
1813 (r_ptr->a_ability_flags1 & (1L << i))) n++;
1814 if (!(r_ptr->r_flags6 & (1L << i)) &&
1815 (r_ptr->a_ability_flags2 & (1L << i))) n++;
1816 if (!(r_ptr->r_flagsr & (1L << i)) &&
1817 (r_ptr->flagsr & (1L << i))) n++;
1819 /* r_flags7 is actually unused */
1821 if (!(r_ptr->r_flags7 & (1L << i)) &&
1822 (r_ptr->flags7 & (1L << i))) n++;
1826 /* Know all the flags */
1827 r_ptr->r_flags1 = r_ptr->flags1;
1828 r_ptr->r_flags2 = r_ptr->flags2;
1829 r_ptr->r_flags3 = r_ptr->flags3;
1830 r_ptr->r_flags4 = r_ptr->flags4;
1831 r_ptr->r_flags5 = r_ptr->a_ability_flags1;
1832 r_ptr->r_flags6 = r_ptr->a_ability_flags2;
1833 r_ptr->r_flagsr = r_ptr->flagsr;
1835 /* r_flags7 is actually unused */
1836 /* r_ptr->r_flags7 = r_ptr->flags7; */
1838 /* Know about evolution */
1839 if (!(r_ptr->r_xtra1 & MR1_SINKA)) n++;
1840 r_ptr->r_xtra1 |= MR1_SINKA;
1842 /* Update monster recall window */
1843 if (p_ptr->monster_race_idx == r_idx)
1845 p_ptr->window |= (PW_MONSTER);
1848 /* Return the number of new flags learnt */
1854 * @brief モンスターの撃破に伴うドロップ情報の保管処理 / Take note that the given monster just dropped some treasure
1855 * @param m_idx モンスター情報のID
1856 * @param num_item 手に入れたアイテム数
1857 * @param num_gold 手に入れた財宝の単位数
1860 * Note that learning the "GOOD"/"GREAT" flags gives information
1861 * about the treasure (even when the monster is killed for the first
1862 * time, such as uniques, and the treasure has not been examined yet).
1864 * This "indirect" method is used to prevent the player from learning
1865 * exactly how much treasure a monster can drop from observing only
1866 * a single example of a drop. This method actually observes how much
1867 * gold and items are dropped, and remembers that information to be
1868 * described later by the monster recall code.
1870 void lore_treasure(MONSTER_IDX m_idx, ITEM_NUMBER num_item, ITEM_NUMBER num_gold)
1872 monster_type *m_ptr = &m_list[m_idx];
1874 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1876 /* If the monster doesn't have original appearance, don't note */
1877 if (!is_original_ap(m_ptr)) return;
1879 /* Note the number of things dropped */
1880 if (num_item > r_ptr->r_drop_item) r_ptr->r_drop_item = num_item;
1881 if (num_gold > r_ptr->r_drop_gold) r_ptr->r_drop_gold = num_gold;
1883 /* Hack -- memorize the good/great flags */
1884 if (r_ptr->flags1 & (RF1_DROP_GOOD)) r_ptr->r_flags1 |= (RF1_DROP_GOOD);
1885 if (r_ptr->flags1 & (RF1_DROP_GREAT)) r_ptr->r_flags1 |= (RF1_DROP_GREAT);
1887 /* Update monster recall window */
1888 if (p_ptr->monster_race_idx == m_ptr->r_idx)
1890 p_ptr->window |= (PW_MONSTER);
1896 * @brief ELDRITCH_HORRORによるプレイヤーの精神破壊処理
1897 * @param m_ptr ELDRITCH_HORRORを引き起こしたモンスターの参照ポインタ
1898 * @param necro 暗黒領域魔法の詠唱失敗によるものならばTRUEを返す
1901 void sanity_blast(monster_type *m_ptr, bool necro)
1905 if (p_ptr->inside_battle || !character_dungeon) return;
1907 if (!necro && m_ptr)
1909 GAME_TEXT m_name[MAX_NLEN];
1910 monster_race *r_ptr = &r_info[m_ptr->ap_r_idx];
1912 power = r_ptr->level / 2;
1914 monster_desc(m_name, m_ptr, 0);
1916 if (!(r_ptr->flags1 & RF1_UNIQUE))
1918 if (r_ptr->flags1 & RF1_FRIENDS)
1923 if (!is_loading_now)
1924 return; /* No effect yet, just loaded... */
1927 return; /* Cannot see it for some reason */
1929 if (!(r_ptr->flags2 & RF2_ELDRITCH_HORROR))
1933 return; /* Pet eldritch horrors are safe most of the time */
1935 if (randint1(100) > power) return;
1937 if (saving_throw(p_ptr->skill_sav - power))
1939 return; /* Save, no adverse effects */
1944 /* Something silly happens... */
1946 msg_format("%s%sの顔を見てしまった!",
1947 funny_desc[randint0(MAX_SAN_FUNNY)], m_name);
1949 msg_format("You behold the %s visage of %s!",
1950 funny_desc[randint0(MAX_SAN_FUNNY)], m_name);
1955 msg_print(funny_comments[randint0(MAX_SAN_COMMENT)]);
1956 p_ptr->image = p_ptr->image + randint1(r_ptr->level);
1959 return; /* Never mind; we can't see it clearly enough */
1962 /* Something frightening happens... */
1964 msg_format("%s%sの顔を見てしまった!",
1965 horror_desc[randint0(MAX_SAN_HORROR)], m_name);
1967 msg_format("You behold the %s visage of %s!",
1968 horror_desc[randint0(MAX_SAN_HORROR)], m_name);
1971 r_ptr->r_flags2 |= RF2_ELDRITCH_HORROR;
1973 /* Demon characters are unaffected */
1974 if (prace_is_(RACE_IMP) || prace_is_(RACE_DEMON) || (mimic_info[p_ptr->mimic_form].MIMIC_FLAGS & MIMIC_IS_DEMON)) return;
1975 if (p_ptr->wizard) return;
1977 /* Undead characters are 50% likely to be unaffected */
1978 if (prace_is_(RACE_SKELETON) || prace_is_(RACE_ZOMBIE)
1979 || prace_is_(RACE_VAMPIRE) || prace_is_(RACE_SPECTRE) ||
1980 (mimic_info[p_ptr->mimic_form].MIMIC_FLAGS & MIMIC_IS_UNDEAD))
1982 if (saving_throw(25 + p_ptr->lev)) return;
1987 monster_race *r_ptr;
1988 GAME_TEXT m_name[MAX_NLEN];
1991 get_mon_num_prep(get_nightmare, NULL);
1993 r_ptr = &r_info[get_mon_num(MAX_DEPTH)];
1994 power = r_ptr->level + 10;
1995 desc = r_name + r_ptr->name;
1997 get_mon_num_prep(NULL, NULL);
2000 if (!(r_ptr->flags1 & RF1_UNIQUE))
2001 sprintf(m_name, "%s %s", (is_a_vowel(desc[0]) ? "an" : "a"), desc);
2004 sprintf(m_name, "%s", desc);
2006 if (!(r_ptr->flags1 & RF1_UNIQUE))
2008 if (r_ptr->flags1 & RF1_FRIENDS) power /= 2;
2012 if (saving_throw(p_ptr->skill_sav * 100 / power))
2014 msg_format(_("夢の中で%sに追いかけられた。", "%^s chases you through your dreams."), m_name);
2021 /* Something silly happens... */
2022 msg_format(_("%s%sの顔を見てしまった!", "You behold the %s visage of %s!"),
2023 funny_desc[randint0(MAX_SAN_FUNNY)], m_name);
2027 msg_print(funny_comments[randint0(MAX_SAN_COMMENT)]);
2028 p_ptr->image = p_ptr->image + randint1(r_ptr->level);
2031 /* Never mind; we can't see it clearly enough */
2035 /* Something frightening happens... */
2036 msg_format(_("%s%sの顔を見てしまった!", "You behold the %s visage of %s!"),
2037 horror_desc[randint0(MAX_SAN_HORROR)], desc);
2039 r_ptr->r_flags2 |= RF2_ELDRITCH_HORROR;
2041 if (!p_ptr->mimic_form)
2043 switch (p_ptr->prace)
2045 /* Demons may make a saving throw */
2048 if (saving_throw(20 + p_ptr->lev)) return;
2050 /* Undead may make a saving throw */
2055 if (saving_throw(10 + p_ptr->lev)) return;
2061 /* Demons may make a saving throw */
2062 if (mimic_info[p_ptr->mimic_form].MIMIC_FLAGS & MIMIC_IS_DEMON)
2064 if (saving_throw(20 + p_ptr->lev)) return;
2066 /* Undead may make a saving throw */
2067 else if (mimic_info[p_ptr->mimic_form].MIMIC_FLAGS & MIMIC_IS_UNDEAD)
2069 if (saving_throw(10 + p_ptr->lev)) return;
2075 msg_print(_("ネクロノミコンを読んで正気を失った!", "Your sanity is shaken by reading the Necronomicon!"));
2078 if (saving_throw(p_ptr->skill_sav - power))
2084 (void)do_dec_stat(A_INT);
2085 } while (randint0(100) > p_ptr->skill_sav && one_in_(2));
2088 (void)do_dec_stat(A_WIS);
2089 } while (randint0(100) > p_ptr->skill_sav && one_in_(2));
2091 switch (randint1(21))
2094 if (!(p_ptr->muta3 & MUT3_MORONIC) && one_in_(5))
2096 if ((p_ptr->stat_use[A_INT] < 4) && (p_ptr->stat_use[A_WIS] < 4))
2098 msg_print(_("あなたは完璧な馬鹿になったような気がした。しかしそれは元々だった。", "You turn into an utter moron!"));
2102 msg_print(_("あなたは完璧な馬鹿になった!", "You turn into an utter moron!"));
2105 if (p_ptr->muta3 & MUT3_HYPER_INT)
2107 msg_print(_("あなたの脳は生体コンピュータではなくなった。", "Your brain is no longer a living computer."));
2108 p_ptr->muta3 &= ~(MUT3_HYPER_INT);
2110 p_ptr->muta3 |= MUT3_MORONIC;
2116 if (!(p_ptr->muta2 & MUT2_COWARDICE) && !p_ptr->resist_fear)
2118 msg_print(_("あなたはパラノイアになった!", "You become paranoid!"));
2120 /* Duh, the following should never happen, but anyway... */
2121 if (p_ptr->muta3 & MUT3_FEARLESS)
2123 msg_print(_("あなたはもう恐れ知らずではなくなった。", "You are no longer fearless."));
2124 p_ptr->muta3 &= ~(MUT3_FEARLESS);
2127 p_ptr->muta2 |= MUT2_COWARDICE;
2133 if (!(p_ptr->muta2 & MUT2_HALLU) && !p_ptr->resist_chaos)
2135 msg_print(_("幻覚をひき起こす精神錯乱に陥った!", "You are afflicted by a hallucinatory insanity!"));
2136 p_ptr->muta2 |= MUT2_HALLU;
2142 if (!(p_ptr->muta2 & MUT2_BERS_RAGE))
2144 msg_print(_("激烈な感情の発作におそわれるようになった!", "You become subject to fits of berserk rage!"));
2145 p_ptr->muta2 |= MUT2_BERS_RAGE;
2155 if (!p_ptr->resist_conf)
2157 (void)set_confused(p_ptr->confused + randint0(4) + 4);
2159 if (!p_ptr->free_act)
2161 (void)set_paralyzed(p_ptr->paralyzed + randint0(4) + 4);
2163 if (!p_ptr->resist_chaos)
2165 (void)set_image(p_ptr->image + randint0(250) + 150);
2174 if (lose_all_info())
2175 msg_print(_("あまりの恐怖に全てのことを忘れてしまった!", "You forget everything in your utmost terror!"));
2179 p_ptr->update |= PU_BONUS;
2184 * @brief モンスターの各情報を更新する / This function updates the monster record of the given monster
2185 * @param m_idx 更新するモンスター情報のID
2186 * @param full プレイヤーとの距離更新を行うならばtrue
2189 * This involves extracting the distance to the player (if requested),
2190 * and then checking for visibility (natural, infravision, see-invis,
2191 * telepathy), updating the monster visibility flag, redrawing (or
2192 * erasing) the monster when its visibility changes, and taking note
2193 * of any interesting monster flags (cold-blooded, invisible, etc).
2195 * Note the new "mflag" field which encodes several monster state flags,
2196 * including "view" for when the monster is currently in line of sight,
2197 * and "mark" for when the monster is currently visible via detection.
2199 * The only monster fields that are changed here are "cdis" (the
2200 * distance from the player), "ml" (visible to the player), and
2201 * "mflag" (to maintain the "MFLAG_VIEW" flag).
2203 * Note the special "update_monsters()" function which can be used to
2204 * call this function once for every monster.
2206 * Note the "full" flag which requests that the "cdis" field be updated,
2207 * this is only needed when the monster (or the player) has moved.
2209 * Every time a monster moves, we must call this function for that
2210 * monster, and update the distance, and the visibility. Every time
2211 * the player moves, we must call this function for every monster, and
2212 * update the distance, and the visibility. Whenever the player "state"
2213 * changes in certain ways ("blindness", "infravision", "telepathy",
2214 * and "see invisible"), we must call this function for every monster,
2215 * and update the visibility.
2217 * Routines that change the "illumination" of a grid must also call this
2218 * function for any monster in that grid, since the "visibility" of some
2219 * monsters may be based on the illumination of their grid.
2221 * Note that this function is called once per monster every time the
2222 * player moves. When the player is running, this function is one
2223 * of the primary bottlenecks, along with "update_view()" and the
2224 * "process_monsters()" code, so efficiency is important.
2226 * Note the optimized "inline" version of the "distance()" function.
2228 * A monster is "visible" to the player if (1) it has been detected
2229 * by the player, (2) it is close to the player and the player has
2230 * telepathy, or (3) it is close to the player, and in line of sight
2231 * of the player, and it is "illuminated" by some combination of
2232 * infravision, torch light, or permanent light (invisible monsters
2233 * are only affected by "light" if the player can see invisible).
2235 * Monsters which are not on the current panel may be "visible" to
2236 * the player, and their descriptions will include an "offscreen"
2237 * reference. Currently, offscreen monsters cannot be targetted
2238 * or viewed directly, but old targets will remain set. XXX XXX
2240 * The player can choose to be disturbed by several things, including
2241 * "disturb_move" (monster which is viewable moves in some way), and
2242 * "disturb_near" (monster which is "easily" viewable moves in some
2243 * way). Note that "moves" includes "appears" and "disappears".
2245 void update_monster(MONSTER_IDX m_idx, bool full)
2247 monster_type *m_ptr = &m_list[m_idx];
2249 monster_race *r_ptr = &r_info[m_ptr->r_idx];
2251 bool do_disturb = disturb_move;
2255 /* Current location */
2262 /* Seen by vision */
2265 /* Non-Ninja player in the darkness */
2266 bool in_darkness = (d_info[dungeon_type].flags1 & DF1_DARKNESS) && !p_ptr->see_nocto;
2271 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
2273 if (ap_r_ptr->r_tkills && ap_r_ptr->level >= p_ptr->lev)
2277 /* Compute distance */
2280 /* Distance components */
2281 int dy = (p_ptr->y > fy) ? (p_ptr->y - fy) : (fy - p_ptr->y);
2282 int dx = (p_ptr->x > fx) ? (p_ptr->x - fx) : (fx - p_ptr->x);
2284 /* Approximate distance */
2285 d = (dy > dx) ? (dy + (dx>>1)) : (dx + (dy>>1));
2287 /* Restrict distance */
2288 if (d > 255) d = 255;
2292 /* Save the distance */
2296 /* Extract distance */
2299 /* Extract the distance */
2305 if (m_ptr->mflag2 & (MFLAG2_MARK)) flag = TRUE;
2309 if (d <= (in_darkness ? MAX_SIGHT / 2 : MAX_SIGHT))
2311 if (!in_darkness || (d <= MAX_SIGHT / 4))
2313 if (p_ptr->special_defense & KATA_MUSOU)
2318 if (is_original_ap(m_ptr) && !p_ptr->image)
2320 /* Hack -- Memorize mental flags */
2321 if (r_ptr->flags2 & (RF2_SMART)) r_ptr->r_flags2 |= (RF2_SMART);
2322 if (r_ptr->flags2 & (RF2_STUPID)) r_ptr->r_flags2 |= (RF2_STUPID);
2326 /* Basic telepathy */
2327 /* Snipers get telepathy when they concentrate deeper */
2328 else if (p_ptr->telepathy)
2330 /* Empty mind, no telepathy */
2331 if (r_ptr->flags2 & (RF2_EMPTY_MIND))
2333 /* Memorize flags */
2334 if (is_original_ap(m_ptr) && !p_ptr->image) r_ptr->r_flags2 |= (RF2_EMPTY_MIND);
2337 /* Weird mind, occasional telepathy */
2338 else if (r_ptr->flags2 & (RF2_WEIRD_MIND))
2340 /* One in ten individuals are detectable */
2341 if ((m_idx % 10) == 5)
2346 if (is_original_ap(m_ptr) && !p_ptr->image)
2348 /* Memorize flags */
2349 r_ptr->r_flags2 |= (RF2_WEIRD_MIND);
2351 /* Hack -- Memorize mental flags */
2352 if (r_ptr->flags2 & (RF2_SMART)) r_ptr->r_flags2 |= (RF2_SMART);
2353 if (r_ptr->flags2 & (RF2_STUPID)) r_ptr->r_flags2 |= (RF2_STUPID);
2358 /* Normal mind, allow telepathy */
2364 if (is_original_ap(m_ptr) && !p_ptr->image)
2366 /* Hack -- Memorize mental flags */
2367 if (r_ptr->flags2 & (RF2_SMART)) r_ptr->r_flags2 |= (RF2_SMART);
2368 if (r_ptr->flags2 & (RF2_STUPID)) r_ptr->r_flags2 |= (RF2_STUPID);
2373 /* Magical sensing */
2374 if ((p_ptr->esp_animal) && (r_ptr->flags3 & (RF3_ANIMAL)))
2377 if (is_original_ap(m_ptr) && !p_ptr->image) r_ptr->r_flags3 |= (RF3_ANIMAL);
2380 /* Magical sensing */
2381 if ((p_ptr->esp_undead) && (r_ptr->flags3 & (RF3_UNDEAD)))
2384 if (is_original_ap(m_ptr) && !p_ptr->image) r_ptr->r_flags3 |= (RF3_UNDEAD);
2387 /* Magical sensing */
2388 if ((p_ptr->esp_demon) && (r_ptr->flags3 & (RF3_DEMON)))
2391 if (is_original_ap(m_ptr) && !p_ptr->image) r_ptr->r_flags3 |= (RF3_DEMON);
2394 /* Magical sensing */
2395 if ((p_ptr->esp_orc) && (r_ptr->flags3 & (RF3_ORC)))
2398 if (is_original_ap(m_ptr) && !p_ptr->image) r_ptr->r_flags3 |= (RF3_ORC);
2401 /* Magical sensing */
2402 if ((p_ptr->esp_troll) && (r_ptr->flags3 & (RF3_TROLL)))
2405 if (is_original_ap(m_ptr) && !p_ptr->image) r_ptr->r_flags3 |= (RF3_TROLL);
2408 /* Magical sensing */
2409 if ((p_ptr->esp_giant) && (r_ptr->flags3 & (RF3_GIANT)))
2412 if (is_original_ap(m_ptr) && !p_ptr->image) r_ptr->r_flags3 |= (RF3_GIANT);
2415 /* Magical sensing */
2416 if ((p_ptr->esp_dragon) && (r_ptr->flags3 & (RF3_DRAGON)))
2419 if (is_original_ap(m_ptr) && !p_ptr->image) r_ptr->r_flags3 |= (RF3_DRAGON);
2422 /* Magical sensing */
2423 if ((p_ptr->esp_human) && (r_ptr->flags2 & (RF2_HUMAN)))
2426 if (is_original_ap(m_ptr) && !p_ptr->image) r_ptr->r_flags2 |= (RF2_HUMAN);
2429 /* Magical sensing */
2430 if ((p_ptr->esp_evil) && (r_ptr->flags3 & (RF3_EVIL)))
2433 if (is_original_ap(m_ptr) && !p_ptr->image) r_ptr->r_flags3 |= (RF3_EVIL);
2436 /* Magical sensing */
2437 if ((p_ptr->esp_good) && (r_ptr->flags3 & (RF3_GOOD)))
2440 if (is_original_ap(m_ptr) && !p_ptr->image) r_ptr->r_flags3 |= (RF3_GOOD);
2443 /* Magical sensing */
2444 if ((p_ptr->esp_nonliving) &&
2445 ((r_ptr->flags3 & (RF3_DEMON | RF3_UNDEAD | RF3_NONLIVING)) == RF3_NONLIVING))
2448 if (is_original_ap(m_ptr) && !p_ptr->image) r_ptr->r_flags3 |= (RF3_NONLIVING);
2451 /* Magical sensing */
2452 if ((p_ptr->esp_unique) && (r_ptr->flags1 & (RF1_UNIQUE)))
2455 if (is_original_ap(m_ptr) && !p_ptr->image) r_ptr->r_flags1 |= (RF1_UNIQUE);
2459 /* Normal line of sight, and not blind */
2460 if (player_has_los_bold(fy, fx) && !p_ptr->blind)
2462 bool do_invisible = FALSE;
2463 bool do_cold_blood = FALSE;
2465 /* Snipers can see targets in darkness when they concentrate deeper */
2466 if (p_ptr->concent >= CONCENT_RADAR_THRESHOLD)
2472 /* Use "infravision" */
2473 if (d <= p_ptr->see_infra)
2475 /* Handle "cold blooded" monsters */
2476 if ((r_ptr->flags2 & (RF2_COLD_BLOOD | RF2_AURA_FIRE)) == RF2_COLD_BLOOD)
2478 do_cold_blood = TRUE;
2481 /* Handle "warm blooded" monsters */
2489 /* Use "illumination" */
2490 if (player_can_see_bold(fy, fx))
2492 /* Handle "invisible" monsters */
2493 if (r_ptr->flags2 & (RF2_INVISIBLE))
2495 do_invisible = TRUE;
2505 /* Handle "normal" monsters */
2516 if (is_original_ap(m_ptr) && !p_ptr->image)
2518 /* Memorize flags */
2519 if (do_invisible) r_ptr->r_flags2 |= (RF2_INVISIBLE);
2520 if (do_cold_blood) r_ptr->r_flags2 |= (RF2_COLD_BLOOD);
2527 /* The monster is now visible */
2530 /* It was previously unseen */
2533 /* Mark as visible */
2536 /* Draw the monster */
2539 /* Update health bar as needed */
2540 if (p_ptr->health_who == m_idx) p_ptr->redraw |= (PR_HEALTH);
2541 if (p_ptr->riding == m_idx) p_ptr->redraw |= (PR_UHEALTH);
2543 /* Hack -- Count "fresh" sightings */
2546 if ((m_ptr->ap_r_idx == MON_KAGE) && (r_info[MON_KAGE].r_sights < MAX_SHORT))
2547 r_info[MON_KAGE].r_sights++;
2548 else if (is_original_ap(m_ptr) && (r_ptr->r_sights < MAX_SHORT))
2552 /* Eldritch Horror */
2553 if (r_info[m_ptr->ap_r_idx].flags2 & RF2_ELDRITCH_HORROR)
2555 sanity_blast(m_ptr, FALSE);
2558 /* Disturb on appearance */
2559 if (disturb_near && (projectable(m_ptr->fy, m_ptr->fx, p_ptr->y, p_ptr->x) && projectable(p_ptr->y, p_ptr->x, m_ptr->fy, m_ptr->fx)))
2561 if (disturb_pets || is_hostile(m_ptr))
2562 disturb(TRUE, TRUE);
2567 /* The monster is not visible */
2570 /* It was previously seen */
2573 /* Mark as not visible */
2576 /* Erase the monster */
2579 /* Update health bar as needed */
2580 if (p_ptr->health_who == m_idx) p_ptr->redraw |= (PR_HEALTH);
2581 if (p_ptr->riding == m_idx) p_ptr->redraw |= (PR_UHEALTH);
2583 /* Disturb on disappearance */
2586 if (disturb_pets || is_hostile(m_ptr))
2587 disturb(TRUE, TRUE);
2593 /* The monster is now easily visible */
2597 if (!(m_ptr->mflag & (MFLAG_VIEW)))
2599 /* Mark as easily visible */
2600 m_ptr->mflag |= (MFLAG_VIEW);
2602 /* Disturb on appearance */
2605 if (disturb_pets || is_hostile(m_ptr))
2606 disturb(TRUE, TRUE);
2611 /* The monster is not easily visible */
2615 if (m_ptr->mflag & (MFLAG_VIEW))
2617 /* Mark as not easily visible */
2618 m_ptr->mflag &= ~(MFLAG_VIEW);
2620 /* Disturb on disappearance */
2623 if (disturb_pets || is_hostile(m_ptr))
2624 disturb(TRUE, TRUE);
2632 * @brief 単純に生存している全モンスターの更新処理を行う / This function simply updates all the (non-dead) monsters (see above).
2633 * @param full 距離更新を行うならtrue
2636 void update_monsters(bool full)
2640 /* Update each (live) monster */
2641 for (i = 1; i < m_max; i++)
2643 monster_type *m_ptr = &m_list[i];
2645 /* Skip dead monsters */
2646 if (!m_ptr->r_idx) continue;
2647 update_monster(i, full);
2653 * @brief カメレオンの王の変身対象となるモンスターかどうか判定する / Hack -- the index of the summoning monster
2654 * @param r_idx モンスター種族ID
2655 * @return 対象にできるならtrueを返す
2657 static bool monster_hook_chameleon_lord(MONRACE_IDX r_idx)
2659 monster_race *r_ptr = &r_info[r_idx];
2660 monster_type *m_ptr = &m_list[chameleon_change_m_idx];
2661 monster_race *old_r_ptr = &r_info[m_ptr->r_idx];
2663 if (!(r_ptr->flags1 & (RF1_UNIQUE))) return FALSE;
2664 if (r_ptr->flags7 & (RF7_FRIENDLY | RF7_CHAMELEON)) return FALSE;
2666 if (ABS(r_ptr->level - r_info[MON_CHAMELEON_K].level) > 5) return FALSE;
2668 if ((r_ptr->blow[0].method == RBM_EXPLODE) || (r_ptr->blow[1].method == RBM_EXPLODE) || (r_ptr->blow[2].method == RBM_EXPLODE) || (r_ptr->blow[3].method == RBM_EXPLODE))
2671 if (!monster_can_cross_terrain(cave[m_ptr->fy][m_ptr->fx].feat, r_ptr, 0)) return FALSE;
2674 if (!(old_r_ptr->flags7 & RF7_CHAMELEON))
2676 if (monster_has_hostile_align(m_ptr, 0, 0, r_ptr)) return FALSE;
2680 else if (summon_specific_who > 0)
2682 if (monster_has_hostile_align(&m_list[summon_specific_who], 0, 0, r_ptr)) return FALSE;
2689 * @brief カメレオンの変身対象となるモンスターかどうか判定する / Hack -- the index of the summoning monster
2690 * @param r_idx モンスター種族ID
2691 * @return 対象にできるならtrueを返す
2693 static bool monster_hook_chameleon(MONRACE_IDX r_idx)
2695 monster_race *r_ptr = &r_info[r_idx];
2696 monster_type *m_ptr = &m_list[chameleon_change_m_idx];
2697 monster_race *old_r_ptr = &r_info[m_ptr->r_idx];
2699 if (r_ptr->flags1 & (RF1_UNIQUE)) return FALSE;
2700 if (r_ptr->flags2 & RF2_MULTIPLY) return FALSE;
2701 if (r_ptr->flags7 & (RF7_FRIENDLY | RF7_CHAMELEON)) return FALSE;
2703 if ((r_ptr->blow[0].method == RBM_EXPLODE) || (r_ptr->blow[1].method == RBM_EXPLODE) || (r_ptr->blow[2].method == RBM_EXPLODE) || (r_ptr->blow[3].method == RBM_EXPLODE))
2706 if (!monster_can_cross_terrain(cave[m_ptr->fy][m_ptr->fx].feat, r_ptr, 0)) return FALSE;
2709 if (!(old_r_ptr->flags7 & RF7_CHAMELEON))
2711 if ((old_r_ptr->flags3 & RF3_GOOD) && !(r_ptr->flags3 & RF3_GOOD)) return FALSE;
2712 if ((old_r_ptr->flags3 & RF3_EVIL) && !(r_ptr->flags3 & RF3_EVIL)) return FALSE;
2713 if (!(old_r_ptr->flags3 & (RF3_GOOD | RF3_EVIL)) && (r_ptr->flags3 & (RF3_GOOD | RF3_EVIL))) return FALSE;
2717 else if (summon_specific_who > 0)
2719 if (monster_has_hostile_align(&m_list[summon_specific_who], 0, 0, r_ptr)) return FALSE;
2722 return (*(get_monster_hook()))(r_idx);
2727 * @param m_idx 変身処理を受けるモンスター情報のID
2728 * @param born 生成時の初変身先指定ならばtrue
2729 * @param r_idx 旧モンスター種族のID
2732 void choose_new_monster(MONSTER_IDX m_idx, bool born, MONRACE_IDX r_idx)
2735 monster_type *m_ptr = &m_list[m_idx];
2736 monster_race *r_ptr;
2737 char old_m_name[MAX_NLEN];
2738 bool old_unique = FALSE;
2739 int old_r_idx = m_ptr->r_idx;
2741 if (r_info[m_ptr->r_idx].flags1 & RF1_UNIQUE)
2743 if (old_unique && (r_idx == MON_CHAMELEON)) r_idx = MON_CHAMELEON_K;
2744 r_ptr = &r_info[r_idx];
2746 monster_desc(old_m_name, m_ptr, 0);
2752 chameleon_change_m_idx = m_idx;
2754 get_mon_num_prep(monster_hook_chameleon_lord, NULL);
2756 get_mon_num_prep(monster_hook_chameleon, NULL);
2759 level = r_info[MON_CHAMELEON_K].level;
2760 else if (!dun_level)
2761 level = wilderness[p_ptr->wilderness_y][p_ptr->wilderness_x].level;
2765 if (d_info[dungeon_type].flags1 & DF1_CHAMELEON) level+= 2+randint1(3);
2767 r_idx = get_mon_num(level);
2768 r_ptr = &r_info[r_idx];
2770 chameleon_change_m_idx = 0;
2776 if (is_pet(m_ptr)) check_pets_num_and_align(m_ptr, FALSE);
2778 m_ptr->r_idx = r_idx;
2779 m_ptr->ap_r_idx = r_idx;
2780 update_monster(m_idx, FALSE);
2781 lite_spot(m_ptr->fy, m_ptr->fx);
2783 if ((r_info[old_r_idx].flags7 & (RF7_LITE_MASK | RF7_DARK_MASK)) ||
2784 (r_ptr->flags7 & (RF7_LITE_MASK | RF7_DARK_MASK)))
2785 p_ptr->update |= (PU_MON_LITE);
2787 if (is_pet(m_ptr)) check_pets_num_and_align(m_ptr, TRUE);
2791 /* Sub-alignment of a chameleon */
2792 if (r_ptr->flags3 & (RF3_EVIL | RF3_GOOD))
2794 m_ptr->sub_align = SUB_ALIGN_NEUTRAL;
2795 if (r_ptr->flags3 & RF3_EVIL) m_ptr->sub_align |= SUB_ALIGN_EVIL;
2796 if (r_ptr->flags3 & RF3_GOOD) m_ptr->sub_align |= SUB_ALIGN_GOOD;
2801 if (m_idx == p_ptr->riding)
2803 GAME_TEXT m_name[MAX_NLEN];
2804 monster_desc(m_name, m_ptr, 0);
2805 msg_format(_("突然%sが変身した。", "Suddenly, %s transforms!"), old_m_name);
2806 if (!(r_ptr->flags7 & RF7_RIDING))
2807 if (rakuba(0, TRUE)) msg_format(_("地面に落とされた。", "You have fallen from %s."), m_name);
2810 /* Extract the monster base speed */
2811 m_ptr->mspeed = get_mspeed(r_ptr);
2813 oldmaxhp = m_ptr->max_maxhp;
2814 /* Assign maximal hitpoints */
2815 if (r_ptr->flags1 & RF1_FORCE_MAXHP)
2817 m_ptr->max_maxhp = maxroll(r_ptr->hdice, r_ptr->hside);
2821 m_ptr->max_maxhp = damroll(r_ptr->hdice, r_ptr->hside);
2824 /* Monsters have double hitpoints in Nightmare mode */
2825 if (ironman_nightmare)
2827 u32b hp = m_ptr->max_maxhp * 2L;
2828 m_ptr->max_maxhp = (HIT_POINT)MIN(30000, hp);
2831 m_ptr->maxhp = (long)(m_ptr->maxhp * m_ptr->max_maxhp) / oldmaxhp;
2832 if (m_ptr->maxhp < 1) m_ptr->maxhp = 1;
2833 m_ptr->hp = (long)(m_ptr->hp * m_ptr->max_maxhp) / oldmaxhp;
2835 /* reset dealt_damage */
2836 m_ptr->dealt_damage = 0;
2841 * @brief たぬきの変身対象となるモンスターかどうか判定する / Hook for Tanuki
2842 * @param r_idx モンスター種族ID
2843 * @return 対象にできるならtrueを返す
2845 static bool monster_hook_tanuki(MONRACE_IDX r_idx)
2847 monster_race *r_ptr = &r_info[r_idx];
2849 if (r_ptr->flags1 & (RF1_UNIQUE)) return FALSE;
2850 if (r_ptr->flags2 & RF2_MULTIPLY) return FALSE;
2851 if (r_ptr->flags7 & (RF7_FRIENDLY | RF7_CHAMELEON)) return FALSE;
2852 if (r_ptr->flags7 & RF7_AQUATIC) return FALSE;
2854 if ((r_ptr->blow[0].method == RBM_EXPLODE) || (r_ptr->blow[1].method == RBM_EXPLODE) || (r_ptr->blow[2].method == RBM_EXPLODE) || (r_ptr->blow[3].method == RBM_EXPLODE))
2857 return (*(get_monster_hook()))(r_idx);
2862 * @brief モンスターの表層IDを設定する / Set initial racial appearance of a monster
2863 * @param r_idx モンスター種族ID
2864 * @return モンスター種族の表層ID
2866 static IDX initial_r_appearance(MONRACE_IDX r_idx)
2868 int attempts = 1000;
2870 DEPTH min = MIN(base_level-5, 50);
2872 if (p_ptr->pseikaku == SEIKAKU_CHARGEMAN)
2874 if (base_level == 0 || one_in_(5)) return MON_ALIEN_JURAL;
2877 if (!(r_info[r_idx].flags7 & RF7_TANUKI))
2880 get_mon_num_prep(monster_hook_tanuki, NULL);
2884 ap_r_idx = get_mon_num(base_level + 10);
2885 if (r_info[ap_r_idx].level >= min) return ap_r_idx;
2893 * @brief モンスターの個体加速を設定する / Get initial monster speed
2894 * @param r_ptr モンスター種族の参照ポインタ
2897 byte get_mspeed(monster_race *r_ptr)
2899 /* Extract the monster base speed */
2900 int mspeed = r_ptr->speed;
2902 /* Hack -- small racial variety */
2903 if (!(r_ptr->flags1 & RF1_UNIQUE) && !p_ptr->inside_arena)
2905 /* Allow some small variation per monster */
2906 int i = SPEED_TO_ENERGY(r_ptr->speed) / (one_in_(4) ? 3 : 10);
2907 if (i) mspeed += rand_spread(0, i);
2910 if (mspeed > 199) mspeed = 199;
2912 return (byte)mspeed;
2917 * @brief モンスターを一体生成する / Attempt to place a monster of the given race at the given location.
2918 * @param who 召喚を行ったモンスターID
2921 * @param r_idx 生成モンスター種族
2922 * @param mode 生成オプション
2925 * To give the player a sporting chance, any monster that appears in
2926 * line-of-sight and is extremely dangerous can be marked as
2927 * "FORCE_SLEEP", which will cause them to be placed with low energy,
2928 * which often (but not always) lets the player move before they do.
2930 * This routine refuses to place out-of-depth "FORCE_DEPTH" monsters.
2932 * Use special "here" and "dead" flags for unique monsters,
2933 * remove old "cur_num" and "max_num" fields.
2935 * Actually, do something similar for artifacts, to simplify
2936 * the "preserve" mode, and to make the "what artifacts" flag more useful.
2938 * This is the only function which may place a monster in the dungeon,
2939 * except for the savefile loading code.
2941 static bool place_monster_one(MONSTER_IDX who, POSITION y, POSITION x, MONRACE_IDX r_idx, BIT_FLAGS mode)
2943 /* Access the location */
2944 cave_type *c_ptr = &cave[y][x];
2945 monster_type *m_ptr;
2946 monster_race *r_ptr = &r_info[r_idx];
2947 concptr name = (r_name + r_ptr->name);
2951 /* DO NOT PLACE A MONSTER IN THE SMALL SCALE WILDERNESS !!! */
2952 if (p_ptr->wild_mode) return FALSE;
2954 /* Verify location */
2955 if (!in_bounds(y, x)) return (FALSE);
2958 if (!r_idx) return (FALSE);
2961 if (!r_ptr->name) return (FALSE);
2963 if (!(mode & PM_IGNORE_TERRAIN))
2965 /* Not on the Pattern */
2966 if (pattern_tile(y, x)) return FALSE;
2968 /* Require empty space (if not ghostly) */
2969 if (!monster_can_enter(y, x, r_ptr, 0)) return FALSE;
2972 if (!p_ptr->inside_battle)
2974 /* Hack -- "unique" monsters must be "unique" */
2975 if (((r_ptr->flags1 & (RF1_UNIQUE)) ||
2976 (r_ptr->flags7 & (RF7_NAZGUL))) &&
2977 (r_ptr->cur_num >= r_ptr->max_num))
2983 if ((r_ptr->flags7 & (RF7_UNIQUE2)) &&
2984 (r_ptr->cur_num >= 1))
2989 if (r_idx == MON_BANORLUPART)
2991 if (r_info[MON_BANOR].cur_num > 0) return FALSE;
2992 if (r_info[MON_LUPART].cur_num > 0) return FALSE;
2995 /* Depth monsters may NOT be created out of depth, unless in Nightmare mode */
2996 if ((r_ptr->flags1 & (RF1_FORCE_DEPTH)) && (dun_level < r_ptr->level) &&
2997 (!ironman_nightmare || (r_ptr->flags1 & (RF1_QUESTOR))))
3004 if (quest_number(dun_level))
3006 int hoge = quest_number(dun_level);
3007 if ((quest[hoge].type == QUEST_TYPE_KILL_LEVEL) || (quest[hoge].type == QUEST_TYPE_RANDOM))
3009 if(r_idx == quest[hoge].r_idx)
3011 int number_mon, i2, j2;
3014 /* Count all quest monsters */
3015 for (i2 = 0; i2 < cur_wid; ++i2)
3016 for (j2 = 0; j2 < cur_hgt; j2++)
3017 if (cave[j2][i2].m_idx > 0)
3018 if (m_list[cave[j2][i2].m_idx].r_idx == quest[hoge].r_idx)
3020 if(number_mon + quest[hoge].cur_num >= quest[hoge].max_num)
3026 if (is_glyph_grid(c_ptr))
3028 if (randint1(BREAK_GLYPH) < (r_ptr->level+20))
3030 /* Describe observable breakage */
3031 if (c_ptr->info & CAVE_MARK)
3033 msg_print(_("守りのルーンが壊れた!", "The rune of protection is broken!"));
3036 /* Forget the rune */
3037 c_ptr->info &= ~(CAVE_MARK);
3039 /* Break the rune */
3040 c_ptr->info &= ~(CAVE_OBJECT);
3048 msg_format_wizard(CHEAT_MONSTER, _("%s(Lv%d)を生成しました。", "%s(Lv%d) was generated."), name, r_ptr->level);
3050 if ((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags7 & RF7_NAZGUL) || (r_ptr->level < 10)) mode &= ~PM_KAGE;
3052 /* Make a new monster */
3053 c_ptr->m_idx = m_pop();
3054 hack_m_idx_ii = c_ptr->m_idx;
3056 /* Mega-Hack -- catch "failure" */
3057 if (!c_ptr->m_idx) return (FALSE);
3060 /* Get a new monster record */
3061 m_ptr = &m_list[c_ptr->m_idx];
3064 m_ptr->r_idx = r_idx;
3065 m_ptr->ap_r_idx = initial_r_appearance(r_idx);
3071 /* Hack -- Appearance transfer */
3072 if ((mode & PM_MULTIPLY) && (who > 0) && !is_original_ap(&m_list[who]))
3074 m_ptr->ap_r_idx = m_list[who].ap_r_idx;
3076 /* Hack -- Shadower spawns Shadower */
3077 if (m_list[who].mflag2 & MFLAG2_KAGE) m_ptr->mflag2 |= MFLAG2_KAGE;
3080 /* Sub-alignment of a monster */
3081 if ((who > 0) && !(r_ptr->flags3 & (RF3_EVIL | RF3_GOOD)))
3082 m_ptr->sub_align = m_list[who].sub_align;
3085 m_ptr->sub_align = SUB_ALIGN_NEUTRAL;
3086 if (r_ptr->flags3 & RF3_EVIL) m_ptr->sub_align |= SUB_ALIGN_EVIL;
3087 if (r_ptr->flags3 & RF3_GOOD) m_ptr->sub_align |= SUB_ALIGN_GOOD;
3090 /* Place the monster at the location */
3095 /* No "timed status" yet */
3096 for (cmi = 0; cmi < MAX_MTIMED; cmi++) m_ptr->mtimed[cmi] = 0;
3098 /* Unknown distance */
3101 reset_target(m_ptr);
3103 m_ptr->nickname = 0;
3108 /* Your pet summons its pet. */
3109 if (who > 0 && is_pet(&m_list[who]))
3111 mode |= PM_FORCE_PET;
3112 m_ptr->parent_m_idx = who;
3116 m_ptr->parent_m_idx = 0;
3119 if (r_ptr->flags7 & RF7_CHAMELEON)
3121 choose_new_monster(c_ptr->m_idx, TRUE, 0);
3122 r_ptr = &r_info[m_ptr->r_idx];
3123 m_ptr->mflag2 |= MFLAG2_CHAMELEON;
3125 /* Hack - Set sub_align to neutral when the Chameleon Lord is generated as "GUARDIAN" */
3126 if ((r_ptr->flags1 & RF1_UNIQUE) && (who <= 0))
3127 m_ptr->sub_align = SUB_ALIGN_NEUTRAL;
3129 else if ((mode & PM_KAGE) && !(mode & PM_FORCE_PET))
3131 m_ptr->ap_r_idx = MON_KAGE;
3132 m_ptr->mflag2 |= MFLAG2_KAGE;
3135 if (mode & PM_NO_PET) m_ptr->mflag2 |= MFLAG2_NOPET;
3141 if (mode & PM_FORCE_PET)
3146 else if ((r_ptr->flags7 & RF7_FRIENDLY) ||
3147 (mode & PM_FORCE_FRIENDLY) || is_friendly_idx(who))
3149 if (!monster_has_hostile_align(NULL, 0, -1, r_ptr)) set_friendly(m_ptr);
3152 /* Assume no sleeping */
3153 m_ptr->mtimed[MTIMED_CSLEEP] = 0;
3155 /* Enforce sleeping if needed */
3156 if ((mode & PM_ALLOW_SLEEP) && r_ptr->sleep && !ironman_nightmare)
3158 int val = r_ptr->sleep;
3159 (void)set_monster_csleep(c_ptr->m_idx, (val * 2) + randint1(val * 10));
3162 /* Assign maximal hitpoints */
3163 if (r_ptr->flags1 & RF1_FORCE_MAXHP)
3165 m_ptr->max_maxhp = maxroll(r_ptr->hdice, r_ptr->hside);
3169 m_ptr->max_maxhp = damroll(r_ptr->hdice, r_ptr->hside);
3172 /* Monsters have double hitpoints in Nightmare mode */
3173 if (ironman_nightmare)
3175 u32b hp = m_ptr->max_maxhp * 2L;
3177 m_ptr->max_maxhp = (HIT_POINT)MIN(30000, hp);
3180 m_ptr->maxhp = m_ptr->max_maxhp;
3182 /* And start out fully healthy */
3183 if (m_ptr->r_idx == MON_WOUNDED_BEAR)
3184 m_ptr->hp = m_ptr->maxhp / 2;
3185 else m_ptr->hp = m_ptr->maxhp;
3188 /* dealt damage is 0 at initial*/
3189 m_ptr->dealt_damage = 0;
3192 /* Extract the monster base speed */
3193 m_ptr->mspeed = get_mspeed(r_ptr);
3195 if (mode & PM_HASTE) (void)set_monster_fast(c_ptr->m_idx, 100);
3197 /* Give a random starting energy */
3198 if (!ironman_nightmare)
3200 m_ptr->energy_need = ENERGY_NEED() - (s16b)randint0(100);
3204 /* Nightmare monsters are more prepared */
3205 m_ptr->energy_need = ENERGY_NEED() - (s16b)randint0(100) * 2;
3208 /* Force monster to wait for player, unless in Nightmare mode */
3209 if ((r_ptr->flags1 & RF1_FORCE_SLEEP) && !ironman_nightmare)
3211 /* Monster is still being nice */
3212 m_ptr->mflag |= (MFLAG_NICE);
3214 /* Must repair monsters */
3215 repair_monsters = TRUE;
3218 /* Hack -- see "process_monsters()" */
3219 if (c_ptr->m_idx < hack_m_idx)
3221 /* Monster is still being born */
3222 m_ptr->mflag |= (MFLAG_BORN);
3226 if (r_ptr->flags7 & RF7_SELF_LD_MASK)
3227 p_ptr->update |= (PU_MON_LITE);
3228 else if ((r_ptr->flags7 & RF7_HAS_LD_MASK) && !MON_CSLEEP(m_ptr))
3229 p_ptr->update |= (PU_MON_LITE);
3230 update_monster(c_ptr->m_idx, TRUE);
3233 /* Count the monsters on the level */
3234 real_r_ptr(m_ptr)->cur_num++;
3237 * Memorize location of the unique monster in saved floors.
3238 * A unique monster move from old saved floor.
3240 if (character_dungeon &&
3241 ((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags7 & RF7_NAZGUL)))
3242 real_r_ptr(m_ptr)->floor_id = p_ptr->floor_id;
3244 /* Hack -- Count the number of "reproducers" */
3245 if (r_ptr->flags2 & RF2_MULTIPLY) num_repro++;
3247 /* Hack -- Notice new multi-hued monsters */
3249 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
3250 if (ap_r_ptr->flags1 & (RF1_ATTR_MULTI | RF1_SHAPECHANGER))
3251 shimmer_monsters = TRUE;
3254 if (p_ptr->warning && character_dungeon)
3256 if (r_ptr->flags1 & RF1_UNIQUE)
3260 GAME_TEXT o_name[MAX_NLEN];
3262 if (r_ptr->level > p_ptr->lev + 30)
3263 color = _("黒く", "black");
3264 else if (r_ptr->level > p_ptr->lev + 15)
3265 color = _("紫色に", "purple");
3266 else if (r_ptr->level > p_ptr->lev + 5)
3267 color = _("ルビー色に", "deep red");
3268 else if (r_ptr->level > p_ptr->lev - 5)
3269 color = _("赤く", "red");
3270 else if (r_ptr->level > p_ptr->lev - 15)
3271 color = _("ピンク色に", "pink");
3273 color = _("白く", "white");
3275 o_ptr = choose_warning_item();
3278 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
3279 msg_format(_("%sは%s光った。", "%s glows %s."), o_name, color);
3283 msg_format(_("%s光る物が頭に浮かんだ。", "An %s image forms in your mind."), color);
3288 if (is_explosive_rune_grid(c_ptr))
3290 /* Break the ward */
3291 if (randint1(BREAK_MINOR_GLYPH) > r_ptr->level)
3293 /* Describe observable breakage */
3294 if (c_ptr->info & CAVE_MARK)
3296 msg_print(_("ルーンが爆発した!", "The rune explodes!"));
3297 project(0, 2, y, x, 2 * (p_ptr->lev + damroll(7, 7)), GF_MANA, (PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL | PROJECT_JUMP | PROJECT_NO_HANGEKI), -1);
3302 msg_print(_("爆発のルーンは解除された。", "An explosive rune was disarmed."));
3305 /* Forget the rune */
3306 c_ptr->info &= ~(CAVE_MARK);
3308 /* Break the rune */
3309 c_ptr->info &= ~(CAVE_OBJECT);
3322 #define MON_SCAT_MAXD 10 /*!< mon_scatter()関数によるモンスター配置で許される中心からの最大距離 */
3325 * @brief モンスター1体を目標地点に可能ながり近い位置に生成する / improved version of scatter() for place monster
3326 * @param r_idx 生成モンスター種族
3327 * @param yp 結果生成位置y座標
3328 * @param xp 結果生成位置x座標
3329 * @param y 中心生成位置y座標
3330 * @param x 中心生成位置x座標
3331 * @param max_dist 生成位置の最大半径
3335 static bool mon_scatter(MONRACE_IDX r_idx, POSITION *yp, POSITION *xp, POSITION y, POSITION x, POSITION max_dist)
3337 int place_x[MON_SCAT_MAXD];
3338 int place_y[MON_SCAT_MAXD];
3339 int num[MON_SCAT_MAXD];
3343 if (max_dist >= MON_SCAT_MAXD)
3346 for (i = 0; i < MON_SCAT_MAXD; i++)
3349 for (nx = x - max_dist; nx <= x + max_dist; nx++)
3351 for (ny = y - max_dist; ny <= y + max_dist; ny++)
3353 /* Ignore annoying locations */
3354 if (!in_bounds(ny, nx)) continue;
3356 /* Require "line of projection" */
3357 if (!projectable(y, x, ny, nx)) continue;
3361 monster_race *r_ptr = &r_info[r_idx];
3363 /* Require empty space (if not ghostly) */
3364 if (!monster_can_enter(ny, nx, r_ptr, 0))
3369 /* Walls and Monsters block flow */
3370 if (!cave_empty_bold2(ny, nx)) continue;
3372 /* ... nor on the Pattern */
3373 if (pattern_tile(ny, nx)) continue;
3376 i = distance(y, x, ny, nx);
3384 if (one_in_(num[i]))
3393 while (i < MON_SCAT_MAXD && 0 == num[i])
3395 if (i >= MON_SCAT_MAXD)
3405 * @brief モンスターを目標地点に集団生成する / Attempt to place a "group" of monsters around the given location
3406 * @param who 召喚主のモンスター情報ID
3407 * @param y 中心生成位置y座標
3408 * @param x 中心生成位置x座標
3409 * @param r_idx 生成モンスター種族
3410 * @param mode 生成オプション
3413 static bool place_monster_group(MONSTER_IDX who, POSITION y, POSITION x, MONRACE_IDX r_idx, BIT_FLAGS mode)
3415 monster_race *r_ptr = &r_info[r_idx];
3418 int total = 0, extra = 0;
3422 POSITION hack_y[GROUP_MAX];
3423 POSITION hack_x[GROUP_MAX];
3426 /* Pick a group size */
3427 total = randint1(10);
3429 /* Hard monsters, small groups */
3430 if (r_ptr->level > dun_level)
3432 extra = r_ptr->level - dun_level;
3433 extra = 0 - randint1(extra);
3436 /* Easy monsters, large groups */
3437 else if (r_ptr->level < dun_level)
3439 extra = dun_level - r_ptr->level;
3440 extra = randint1(extra);
3443 /* Hack -- limit group reduction */
3444 if (extra > 9) extra = 9;
3446 /* Modify the group size */
3450 if (total < 1) total = 1;
3453 if (total > GROUP_MAX) total = GROUP_MAX;
3456 /* Start on the monster */
3461 /* Puddle monsters, breadth first, up to total */
3462 for (n = 0; (n < hack_n) && (hack_n < total); n++)
3464 /* Grab the location */
3465 POSITION hx = hack_x[n];
3466 POSITION hy = hack_y[n];
3468 /* Check each direction, up to total */
3469 for (i = 0; (i < 8) && (hack_n < total); i++)
3473 scatter(&my, &mx, hy, hx, 4, 0);
3475 /* Walls and Monsters block flow */
3476 if (!cave_empty_bold2(my, mx)) continue;
3478 /* Attempt to place another monster */
3479 if (place_monster_one(who, my, mx, r_idx, mode))
3481 /* Add it to the "hack" set */
3482 hack_y[hack_n] = my;
3483 hack_x[hack_n] = mx;
3495 * @var place_monster_idx
3496 * @brief 護衛対象となるモンスター種族IDを渡すグローバル変数 / Hack -- help pick an escort type
3497 * @todo 関数ポインタの都合を配慮しながら、グローバル変数place_monster_idxを除去し、関数引数化する
3499 static MONSTER_IDX place_monster_idx = 0;
3502 * @var place_monster_m_idx
3503 * @brief 護衛対象となるモンスターIDを渡すグローバル変数 / Hack -- help pick an escort type
3504 * @todo 関数ポインタの都合を配慮しながら、グローバル変数place_monster_m_idxを除去し、関数引数化する
3506 static MONSTER_IDX place_monster_m_idx = 0;
3509 * @brief モンスター種族が召喚主の護衛となれるかどうかをチェックする / Hack -- help pick an escort type
3510 * @param r_idx チェックするモンスター種族のID
3511 * @return 護衛にできるならばtrue
3513 static bool place_monster_can_escort(MONRACE_IDX r_idx)
3515 monster_race *r_ptr = &r_info[place_monster_idx];
3516 monster_type *m_ptr = &m_list[place_monster_m_idx];
3518 monster_race *z_ptr = &r_info[r_idx];
3520 /* Hack - Escorts have to have the same dungeon flag */
3521 if (mon_hook_dungeon(place_monster_idx) != mon_hook_dungeon(r_idx)) return (FALSE);
3523 /* Require similar "race" */
3524 if (z_ptr->d_char != r_ptr->d_char) return (FALSE);
3526 /* Skip more advanced monsters */
3527 if (z_ptr->level > r_ptr->level) return (FALSE);
3529 /* Skip unique monsters */
3530 if (z_ptr->flags1 & RF1_UNIQUE) return (FALSE);
3532 /* Paranoia -- Skip identical monsters */
3533 if (place_monster_idx == r_idx) return (FALSE);
3535 /* Skip different alignment */
3536 if (monster_has_hostile_align(m_ptr, 0, 0, z_ptr)) return FALSE;
3538 if (r_ptr->flags7 & RF7_FRIENDLY)
3540 if (monster_has_hostile_align(NULL, 1, -1, z_ptr)) return FALSE;
3543 if ((r_ptr->flags7 & RF7_CHAMELEON) && !(z_ptr->flags7 & RF7_CHAMELEON))
3551 * @brief 一般的なモンスター生成処理のサブルーチン / Attempt to place a monster of the given race at the given location
3552 * @param who 召喚主のモンスター情報ID
3555 * @param r_idx 生成するモンスターの種族ID
3556 * @param mode 生成オプション
3557 * @return 生成に成功したらtrue
3559 * Note that certain monsters are now marked as requiring "friends".
3560 * These monsters, if successfully placed, and if the "grp" parameter
3561 * is TRUE, will be surrounded by a "group" of identical monsters.
3563 * Note that certain monsters are now marked as requiring an "escort",
3564 * which is a collection of monsters with similar "race" but lower level.
3566 * Some monsters induce a fake "group" flag on their escorts.
3568 * Note the "bizarre" use of non-recursion to prevent annoying output
3569 * when running a code profiler.
3571 * Note the use of the new "monster allocation table" code to restrict
3572 * the "get_mon_num()" function to "legal" escort types.
3574 bool place_monster_aux(MONSTER_IDX who, POSITION y, POSITION x, MONRACE_IDX r_idx, BIT_FLAGS mode)
3577 monster_race *r_ptr = &r_info[r_idx];
3579 if (!(mode & PM_NO_KAGE) && one_in_(333))
3582 /* Place one monster, or fail */
3583 if (!place_monster_one(who, y, x, r_idx, mode)) return (FALSE);
3585 /* Require the "group" flag */
3586 if (!(mode & PM_ALLOW_GROUP)) return (TRUE);
3588 place_monster_m_idx = hack_m_idx_ii;
3591 for(i = 0; i < A_MAX; i++)
3593 if(!r_ptr->reinforce_id[i]) break;
3594 n = damroll(r_ptr->reinforce_dd[i], r_ptr->reinforce_ds[i]);
3595 for(j = 0; j < n; j++)
3597 POSITION nx, ny, d = 7;
3598 scatter(&ny, &nx, y, x, d, 0);
3599 (void)place_monster_one(place_monster_m_idx, ny, nx, r_ptr->reinforce_id[i], mode);
3603 /* Friends for certain monsters */
3604 if (r_ptr->flags1 & (RF1_FRIENDS))
3606 /* Attempt to place a group */
3607 (void)place_monster_group(who, y, x, r_idx, mode);
3610 /* Escorts for certain monsters */
3611 if (r_ptr->flags1 & (RF1_ESCORT))
3613 /* Set the escort index */
3614 place_monster_idx = r_idx;
3616 /* Try to place several "escorts" */
3617 for (i = 0; i < 32; i++)
3619 POSITION nx, ny, d = 3;
3622 /* Pick a location */
3623 scatter(&ny, &nx, y, x, d, 0);
3625 /* Require empty grids */
3626 if (!cave_empty_bold2(ny, nx)) continue;
3627 get_mon_num_prep(place_monster_can_escort, get_monster_hook2(ny, nx));
3629 /* Pick a random race */
3630 z = get_mon_num(r_ptr->level);
3632 /* Handle failure */
3635 /* Place a single escort */
3636 (void)place_monster_one(place_monster_m_idx, ny, nx, z, mode);
3638 /* Place a "group" of escorts if needed */
3639 if ((r_info[z].flags1 & RF1_FRIENDS) ||
3640 (r_ptr->flags1 & RF1_ESCORTS))
3642 /* Place a group of monsters */
3643 (void)place_monster_group(place_monster_m_idx, ny, nx, z, mode);
3653 * @brief 一般的なモンスター生成処理のメインルーチン / Attempt to place a monster of the given race at the given location
3656 * @param mode 生成オプション
3657 * @return 生成に成功したらtrue
3659 bool place_monster(POSITION y, POSITION x, BIT_FLAGS mode)
3662 get_mon_num_prep(get_monster_hook(), get_monster_hook2(y, x));
3664 /* Pick a monster */
3665 r_idx = get_mon_num(monster_level);
3667 /* Handle failure */
3668 if (!r_idx) return (FALSE);
3670 /* Attempt to place the monster */
3671 if (place_monster_aux(0, y, x, r_idx, mode)) return (TRUE);
3677 * @brief 指定地点に1種類のモンスター種族による群れを生成する
3680 * @return 生成に成功したらtrue
3682 bool alloc_horde(POSITION y, POSITION x)
3684 monster_race *r_ptr = NULL;
3685 MONRACE_IDX r_idx = 0;
3687 int attempts = 1000;
3690 get_mon_num_prep(get_monster_hook(), get_monster_hook2(y, x));
3694 /* Pick a monster */
3695 r_idx = get_mon_num(monster_level);
3697 /* Handle failure */
3698 if (!r_idx) return (FALSE);
3700 r_ptr = &r_info[r_idx];
3702 if (r_ptr->flags1 & RF1_UNIQUE) continue;
3704 if (r_idx == MON_HAGURE) continue;
3707 if (attempts < 1) return FALSE;
3713 /* Attempt to place the monster */
3714 if (place_monster_aux(0, y, x, r_idx, 0L)) break;
3717 if (attempts < 1) return FALSE;
3719 m_idx = cave[y][x].m_idx;
3721 if (m_list[m_idx].mflag2 & MFLAG2_CHAMELEON) r_ptr = &r_info[m_list[m_idx].r_idx];
3723 for (attempts = randint1(10) + 5; attempts; attempts--)
3725 scatter(&cy, &cx, y, x, 5, 0);
3727 (void)summon_specific(m_idx, cy, cx, dun_level + 5, SUMMON_KIN, PM_ALLOW_GROUP, r_ptr->d_char);
3733 if (cheat_hear) msg_format(_("モンスターの大群(%c)", "Monster horde (%c)."), r_ptr->d_char);
3738 * @brief ダンジョンの主生成を試みる / Put the Guardian
3739 * @param def_val 現在の主の生成状態
3740 * @return 生成に成功したらtrue
3742 bool alloc_guardian(bool def_val)
3744 MONRACE_IDX guardian = d_info[dungeon_type].final_guardian;
3746 if (guardian && (d_info[dungeon_type].maxdepth == dun_level) && (r_info[guardian].cur_num < r_info[guardian].max_num))
3750 int try_count = 4000;
3752 /* Find a good position */
3755 /* Get a random spot */
3756 oy = randint1(cur_hgt - 4) + 2;
3757 ox = randint1(cur_wid - 4) + 2;
3759 /* Is it a good spot ? */
3760 if (cave_empty_bold2(oy, ox) && monster_can_cross_terrain(cave[oy][ox].feat, &r_info[guardian], 0))
3762 /* Place the guardian */
3763 if (place_monster_aux(0, oy, ox, guardian, (PM_ALLOW_GROUP | PM_NO_KAGE | PM_NO_PET))) return TRUE;
3766 /* One less try count */
3778 * @brief ダンジョンの初期配置モンスターを生成1回生成する / Attempt to allocate a random monster in the dungeon.
3779 * @param dis プレイヤーから離れるべき最低距離
3780 * @param mode 生成オプション
3781 * @return 生成に成功したらtrue
3783 * Place the monster at least "dis" distance from the player.
3784 * Use "slp" to choose the initial "sleep" status
3785 * Use "monster_level" for the monster level
3787 bool alloc_monster(POSITION dis, BIT_FLAGS mode)
3790 int attempts_left = 10000;
3792 /* Put the Guardian */
3793 if (alloc_guardian(FALSE)) return TRUE;
3795 /* Find a legal, distant, unoccupied, space */
3796 while (attempts_left--)
3798 /* Pick a location */
3799 y = randint0(cur_hgt);
3800 x = randint0(cur_wid);
3802 /* Require empty floor grid (was "naked") */
3805 if (!cave_empty_bold2(y, x)) continue;
3809 if (!cave_empty_bold(y, x)) continue;
3812 /* Accept far away grids */
3813 if (distance(y, x, p_ptr->y, p_ptr->x) > dis) break;
3818 if (cheat_xtra || cheat_hear)
3820 msg_print(_("警告!新たなモンスターを配置できません。小さい階ですか?", "Warning! Could not allocate a new monster. Small level?"));
3827 if (randint1(5000) <= dun_level)
3829 if (alloc_horde(y, x))
3836 /* Attempt to place the monster, allow groups */
3837 if (place_monster(y, x, (mode | PM_ALLOW_GROUP))) return (TRUE);
3845 * @brief モンスターが召喚の基本条件に合っているかをチェックする / Hack -- help decide if a monster race is "okay" to summon
3846 * @param r_idx チェックするモンスター種族ID
3847 * @return 召喚対象にできるならばTRUE
3849 static bool summon_specific_okay(MONRACE_IDX r_idx)
3851 monster_race *r_ptr = &r_info[r_idx];
3853 /* Hack - Only summon dungeon monsters */
3854 if (!mon_hook_dungeon(r_idx)) return (FALSE);
3856 /* Hack -- identify the summoning monster */
3857 if (summon_specific_who > 0)
3859 monster_type *m_ptr = &m_list[summon_specific_who];
3861 /* Do not summon enemies */
3863 /* Friendly vs. opposite aligned normal or pet */
3864 if (monster_has_hostile_align(m_ptr, 0, 0, r_ptr)) return FALSE;
3866 /* Use the player's alignment */
3867 else if (summon_specific_who < 0)
3869 /* Do not summon enemies of the pets */
3870 if (monster_has_hostile_align(NULL, 10, -10, r_ptr))
3872 if (!one_in_(ABS(p_ptr->align) / 2 + 1)) return FALSE;
3876 if (!summon_unique_okay && ((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags7 & RF7_NAZGUL))) return FALSE;
3878 /* Hack -- no specific type specified */
3879 if (!summon_specific_type) return (TRUE);
3881 if ((summon_specific_who < 0) &&
3882 ((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags7 & RF7_NAZGUL)) &&
3883 monster_has_hostile_align(NULL, 10, -10, r_ptr))
3886 if ((r_ptr->flags7 & RF7_CHAMELEON) && (d_info[dungeon_type].flags1 & DF1_CHAMELEON)) return TRUE;
3888 return (summon_specific_aux(r_idx));
3893 * @brief モンスターを召喚により配置する / Place a monster (of the specified "type") near the given location. Return TRUE if a monster was actually summoned.
3894 * @param who 召喚主のモンスター情報ID
3899 * @param mode 生成オプション
3900 * @return 召喚できたらtrueを返す
3903 * We will attempt to place the monster up to 10 times before giving up.
3905 * Note: SUMMON_UNIQUE and SUMMON_AMBERITES will summon Unique's
3906 * Note: SUMMON_HI_UNDEAD and SUMMON_HI_DRAGON may summon Unique's
3907 * Note: None of the other summon codes will ever summon Unique's.
3909 * This function has been changed. We now take the "monster level"
3910 * of the summoning monster as a parameter, and use that, along with
3911 * the current dungeon level, to help determine the level of the
3912 * desired monster. Note that this is an upper bound, and also
3913 * tends to "prefer" monsters of that level. Currently, we use
3914 * the average of the dungeon and monster levels, and then add
3915 * five to allow slight increases in monster power.
3917 * Note that we use the new "monster allocation table" creation code
3918 * to restrict the "get_mon_num()" function to the set of "legal"
3919 * monsters, making this function much faster and more reliable.
3921 * Note that this function may not succeed, though this is very rare.
3923 bool summon_specific(MONSTER_IDX who, POSITION y1, POSITION x1, DEPTH lev, int type, BIT_FLAGS mode, SYMBOL_CODE symbol)
3928 if (p_ptr->inside_arena) return (FALSE);
3930 if (!mon_scatter(0, &y, &x, y1, x1, 2)) return FALSE;
3932 /* Save the summoner */
3933 summon_specific_who = who;
3935 /* Save the "summon" type */
3936 summon_specific_type = type;
3938 summon_kin_type = symbol;
3940 summon_unique_okay = (mode & PM_ALLOW_UNIQUE) ? TRUE : FALSE;
3941 get_mon_num_prep(summon_specific_okay, get_monster_hook2(y, x));
3943 /* Pick a monster, using the level calculation */
3944 r_idx = get_mon_num((dun_level + lev) / 2 + 5);
3946 /* Handle failure */
3949 summon_specific_type = 0;
3953 if ((type == SUMMON_BLUE_HORROR) || (type == SUMMON_DAWN)) mode |= PM_NO_KAGE;
3955 /* Attempt to place the monster (awake, allow groups) */
3956 if (!place_monster_aux(who, y, x, r_idx, mode))
3958 summon_specific_type = 0;
3962 summon_specific_type = 0;
3964 sound(SOUND_SUMMON);
3970 * @brief 特定モンスター種族を召喚により生成する / A "dangerous" function, creates a pet of the specified type
3971 * @param who 召喚主のモンスター情報ID
3974 * @param r_idx 生成するモンスター種族ID
3975 * @param mode 生成オプション
3976 * @return 召喚できたらtrueを返す
3978 bool summon_named_creature(MONSTER_IDX who, POSITION oy, POSITION ox, MONRACE_IDX r_idx, BIT_FLAGS mode)
3983 /* if (!r_idx) return; */
3985 /* Prevent illegal monsters */
3986 if (r_idx >= max_r_idx) return FALSE;
3988 if (p_ptr->inside_arena) return FALSE;
3990 if (!mon_scatter(r_idx, &y, &x, oy, ox, 2)) return FALSE;
3992 /* Place it (allow groups) */
3993 return place_monster_aux(who, y, x, r_idx, (mode | PM_NO_KAGE));
3998 * @brief モンスターを増殖生成する / Let the given monster attempt to reproduce.
3999 * @param m_idx 増殖するモンスター情報ID
4000 * @param clone クローン・モンスター処理ならばtrue
4001 * @param mode 生成オプション
4002 * @return 生成できたらtrueを返す
4004 * Note that "reproduction" REQUIRES empty space.
4006 bool multiply_monster(MONSTER_IDX m_idx, bool clone, BIT_FLAGS mode)
4008 monster_type *m_ptr = &m_list[m_idx];
4012 if (!mon_scatter(m_ptr->r_idx, &y, &x, m_ptr->fy, m_ptr->fx, 1))
4015 if (m_ptr->mflag2 & MFLAG2_NOPET) mode |= PM_NO_PET;
4017 /* Create a new monster (awake, no groups) */
4018 if (!place_monster_aux(m_idx, y, x, m_ptr->r_idx, (mode | PM_NO_KAGE | PM_MULTIPLY)))
4021 /* Hack -- Transfer "clone" flag */
4022 if (clone || (m_ptr->smart & SM_CLONED))
4024 m_list[hack_m_idx_ii].smart |= SM_CLONED;
4025 m_list[hack_m_idx_ii].mflag2 |= MFLAG2_NOPET;
4034 * @brief ダメージを受けたモンスターの様子を記述する / Dump a message describing a monster's reaction to damage
4035 * @param m_idx モンスター情報ID
4036 * @param dam 与えたダメージ
4039 * Technically should attempt to treat "Beholder"'s as jelly's
4041 void message_pain(MONSTER_IDX m_idx, HIT_POINT dam)
4043 HIT_POINT oldhp, newhp;
4045 PERCENTAGE percentage;
4047 monster_type *m_ptr = &m_list[m_idx];
4048 monster_race *r_ptr = &r_info[m_ptr->r_idx];
4050 GAME_TEXT m_name[MAX_NLEN];
4052 monster_desc(m_name, m_ptr, 0);
4054 if(dam == 0) // Notice non-damage
4056 msg_format(_("%^sはダメージを受けていない。", "%^s is unharmed."), m_name);
4060 /* Note -- subtle fix -CFT */
4062 oldhp = newhp + dam;
4063 tmp = (newhp * 100L) / oldhp;
4066 if(my_strchr(",ejmvwQ", r_ptr->d_char)) // Mushrooms, Eyes, Jellies, Molds, Vortices, Worms, Quylthulgs
4069 if(percentage > 95) msg_format("%^sはほとんど気にとめていない。", m_name);
4070 else if(percentage > 75) msg_format("%^sはしり込みした。", m_name);
4071 else if(percentage > 50) msg_format("%^sは縮こまった。", m_name);
4072 else if(percentage > 35) msg_format("%^sは痛みに震えた。", m_name);
4073 else if(percentage > 20) msg_format("%^sは身もだえした。", m_name);
4074 else if(percentage > 10) msg_format("%^sは苦痛で身もだえした。", m_name);
4075 else msg_format("%^sはぐにゃぐにゃと痙攣した。", m_name);
4077 if(percentage > 95) msg_format("%^s barely notices.", m_name);
4078 else if(percentage > 75) msg_format("%^s flinches.", m_name);
4079 else if(percentage > 50) msg_format("%^s squelches.", m_name);
4080 else if(percentage > 35) msg_format("%^s quivers in pain.", m_name);
4081 else if(percentage > 20) msg_format("%^s writhes about.", m_name);
4082 else if(percentage > 10) msg_format("%^s writhes in agony.", m_name);
4083 else msg_format("%^s jerks limply.", m_name);
4087 else if(my_strchr("l", r_ptr->d_char)) // Fish
4090 if(percentage > 95) msg_format("%^sはほとんど気にとめていない。", m_name);
4091 else if(percentage > 75) msg_format("%^sはしり込みした。", m_name);
4092 else if(percentage > 50) msg_format("%^sは躊躇した。", m_name);
4093 else if(percentage > 35) msg_format("%^sは痛みに震えた。", m_name);
4094 else if(percentage > 20) msg_format("%^sは身もだえした。", m_name);
4095 else if(percentage > 10) msg_format("%^sは苦痛で身もだえした。", m_name);
4096 else msg_format("%^sはぐにゃぐにゃと痙攣した。", m_name);
4098 if(percentage > 95) msg_format("%^s barely notices.", m_name);
4099 else if(percentage > 75) msg_format("%^s flinches.", m_name);
4100 else if(percentage > 50) msg_format("%^s hesitates.", m_name);
4101 else if(percentage > 35) msg_format("%^s quivers in pain.", m_name);
4102 else if(percentage > 20) msg_format("%^s writhes about.", m_name);
4103 else if(percentage > 10) msg_format("%^s writhes in agony.", m_name);
4104 else msg_format("%^s jerks limply.", m_name);
4108 else if(my_strchr("g#+<>", r_ptr->d_char)) // Golems, Walls, Doors, Stairs
4111 if(percentage > 95) msg_format("%sは攻撃を気にとめていない。", m_name);
4112 else if(percentage > 75) msg_format("%sは攻撃に肩をすくめた。", m_name);
4113 else if(percentage > 50) msg_format("%^sは雷鳴のように吠えた。", m_name);
4114 else if(percentage > 35) msg_format("%^sは苦しげに吠えた。", m_name);
4115 else if(percentage > 20) msg_format("%^sはうめいた。", m_name);
4116 else if(percentage > 10) msg_format("%^sは躊躇した。", m_name);
4117 else msg_format("%^sはくしゃくしゃになった。", m_name);
4119 if(percentage > 95) msg_format("%^s ignores the attack.", m_name);
4120 else if(percentage > 75) msg_format("%^s shrugs off the attack.", m_name);
4121 else if(percentage > 50) msg_format("%^s roars thunderously.", m_name);
4122 else if(percentage > 35) msg_format("%^s rumbles.", m_name);
4123 else if(percentage > 20) msg_format("%^s grunts.", m_name);
4124 else if(percentage > 10) msg_format("%^s hesitates.", m_name);
4125 else msg_format("%^s crumples.", m_name);
4129 else if(my_strchr("JMR", r_ptr->d_char) || !isalpha(r_ptr->d_char)) // Snakes, Hydrae, Reptiles, Mimics
4132 if(percentage > 95) msg_format("%^sはほとんど気にとめていない。", m_name);
4133 else if(percentage > 75) msg_format("%^sはシーッと鳴いた。", m_name);
4134 else if(percentage > 50) msg_format("%^sは怒って頭を上げた。", m_name);
4135 else if(percentage > 35) msg_format("%^sは猛然と威嚇した。", m_name);
4136 else if(percentage > 20) msg_format("%^sは身もだえした。", m_name);
4137 else if(percentage > 10) msg_format("%^sは苦痛で身もだえした。", m_name);
4138 else msg_format("%^sはぐにゃぐにゃと痙攣した。", m_name);
4140 if(percentage > 95) msg_format("%^s barely notices.", m_name);
4141 else if(percentage > 75) msg_format("%^s hisses.", m_name);
4142 else if(percentage > 50) msg_format("%^s rears up in anger.", m_name);
4143 else if(percentage > 35) msg_format("%^s hisses furiously.", m_name);
4144 else if(percentage > 20) msg_format("%^s writhes about.", m_name);
4145 else if(percentage > 10) msg_format("%^s writhes in agony.", m_name);
4146 else msg_format("%^s jerks limply.", m_name);
4150 else if(my_strchr("f", r_ptr->d_char))
4153 if(percentage > 95) msg_format("%sは攻撃に肩をすくめた。", m_name);
4154 else if(percentage > 75) msg_format("%^sは吠えた。", m_name);
4155 else if(percentage > 50) msg_format("%^sは怒って吠えた。", m_name);
4156 else if(percentage > 35) msg_format("%^sは痛みでシーッと鳴いた。", m_name);
4157 else if(percentage > 20) msg_format("%^sは痛みで弱々しく鳴いた。", m_name);
4158 else if(percentage > 10) msg_format("%^sは苦痛にうめいた。", m_name);
4159 else msg_format("%sは哀れな鳴き声を出した。", m_name);
4161 if(percentage > 95) msg_format("%^s shrugs off the attack.", m_name);
4162 else if(percentage > 75) msg_format("%^s roars.", m_name);
4163 else if(percentage > 50) msg_format("%^s growls angrily.", m_name);
4164 else if(percentage > 35) msg_format("%^s hisses with pain.", m_name);
4165 else if(percentage > 20) msg_format("%^s mewls in pain.", m_name);
4166 else if(percentage > 10) msg_format("%^s hisses in agony.", m_name);
4167 else msg_format("%^s mewls pitifully.", m_name);
4171 else if(my_strchr("acFIKS", r_ptr->d_char)) // Ants, Centipedes, Flies, Insects, Beetles, Spiders
4174 if(percentage > 95) msg_format("%sは攻撃を気にとめていない。", m_name);
4175 else if(percentage > 75) msg_format("%^sはキーキー鳴いた。", m_name);
4176 else if(percentage > 50) msg_format("%^sはヨロヨロ逃げ回った。", m_name);
4177 else if(percentage > 35) msg_format("%^sはうるさく鳴いた。", m_name);
4178 else if(percentage > 20) msg_format("%^sは痛みに痙攣した。", m_name);
4179 else if(percentage > 10) msg_format("%^sは苦痛で痙攣した。", m_name);
4180 else msg_format("%^sはピクピクひきつった。", m_name);
4182 if(percentage > 95) msg_format("%^s ignores the attack.", m_name);
4183 else if(percentage > 75) msg_format("%^s chitters.", m_name);
4184 else if(percentage > 50) msg_format("%^s scuttles about.", m_name);
4185 else if(percentage > 35) msg_format("%^s twitters.", m_name);
4186 else if(percentage > 20) msg_format("%^s jerks in pain.", m_name);
4187 else if(percentage > 10) msg_format("%^s jerks in agony.", m_name);
4188 else msg_format("%^s twitches.", m_name);
4192 else if(my_strchr("B", r_ptr->d_char)) // Birds
4195 if(percentage > 95) msg_format("%^sはさえずった。", m_name);
4196 else if(percentage > 75) msg_format("%^sはピーピー鳴いた。", m_name);
4197 else if(percentage > 50) msg_format("%^sはギャーギャー鳴いた。", m_name);
4198 else if(percentage > 35) msg_format("%^sはギャーギャー鳴きわめいた。", m_name);
4199 else if(percentage > 20) msg_format("%^sは苦しんだ。", m_name);
4200 else if(percentage > 10) msg_format("%^sはのたうち回った。", m_name);
4201 else msg_format("%^sはキーキーと鳴き叫んだ。", m_name);
4203 if(percentage > 95) msg_format("%^s chirps.", m_name);
4204 else if(percentage > 75) msg_format("%^s twitters.", m_name);
4205 else if(percentage > 50) msg_format("%^s squawks.", m_name);
4206 else if(percentage > 35) msg_format("%^s chatters.", m_name);
4207 else if(percentage > 20) msg_format("%^s jeers.", m_name);
4208 else if(percentage > 10) msg_format("%^s flutters about.", m_name);
4209 else msg_format("%^s squeaks.", m_name);
4213 else if(my_strchr("duDLUW", r_ptr->d_char)) // Dragons, Demons, High Undead
4216 if(percentage > 95) msg_format("%sは攻撃を気にとめていない。", m_name);
4217 else if(percentage > 75) msg_format("%^sはしり込みした。", m_name);
4218 else if(percentage > 50) msg_format("%^sは痛みでシーッと鳴いた。", m_name);
4219 else if(percentage > 35) msg_format("%^sは痛みでうなった。", m_name);
4220 else if(percentage > 20) msg_format("%^sは痛みに吠えた。", m_name);
4221 else if(percentage > 10) msg_format("%^sは苦しげに叫んだ。", m_name);
4222 else msg_format("%^sは弱々しくうなった。", m_name);
4224 if(percentage > 95) msg_format("%^s ignores the attack.", m_name);
4225 else if(percentage > 75) msg_format("%^s flinches.", m_name);
4226 else if(percentage > 50) msg_format("%^s hisses in pain.", m_name);
4227 else if(percentage > 35) msg_format("%^s snarls with pain.", m_name);
4228 else if(percentage > 20) msg_format("%^s roars with pain.", m_name);
4229 else if(percentage > 10) msg_format("%^s gasps.", m_name);
4230 else msg_format("%^s snarls feebly.", m_name);
4234 else if(my_strchr("s", r_ptr->d_char)) // Skeletons
4237 if(percentage > 95) msg_format("%sは攻撃を気にとめていない。", m_name);
4238 else if(percentage > 75) msg_format("%sは攻撃に肩をすくめた。", m_name);
4239 else if(percentage > 50) msg_format("%^sはカタカタと笑った。", m_name);
4240 else if(percentage > 35) msg_format("%^sはよろめいた。", m_name);
4241 else if(percentage > 20) msg_format("%^sはカタカタ言った。", m_name);
4242 else if(percentage > 10) msg_format("%^sはよろめいた。", m_name);
4243 else msg_format("%^sはガタガタ言った。", m_name);
4245 if(percentage > 95) msg_format("%^s ignores the attack.", m_name);
4246 else if(percentage > 75) msg_format("%^s shrugs off the attack.", m_name);
4247 else if(percentage > 50) msg_format("%^s rattles.", m_name);
4248 else if(percentage > 35) msg_format("%^s stumbles.", m_name);
4249 else if(percentage > 20) msg_format("%^s rattles.", m_name);
4250 else if(percentage > 10) msg_format("%^s staggers.", m_name);
4251 else msg_format("%^s clatters.", m_name);
4255 else if(my_strchr("z", r_ptr->d_char)) // Zombies
4258 if(percentage > 95) msg_format("%sは攻撃を気にとめていない。", m_name);
4259 else if(percentage > 75) msg_format("%sは攻撃に肩をすくめた。", m_name);
4260 else if(percentage > 50) msg_format("%^sはうめいた。", m_name);
4261 else if(percentage > 35) msg_format("%sは苦しげにうめいた。", m_name);
4262 else if(percentage > 20) msg_format("%^sは躊躇した。", m_name);
4263 else if(percentage > 10) msg_format("%^sはうなった。", m_name);
4264 else msg_format("%^sはよろめいた。", m_name);
4266 if(percentage > 95) msg_format("%^s ignores the attack.", m_name);
4267 else if(percentage > 75) msg_format("%^s shrugs off the attack.", m_name);
4268 else if(percentage > 50) msg_format("%^s groans.", m_name);
4269 else if(percentage > 35) msg_format("%^s moans.", m_name);
4270 else if(percentage > 20) msg_format("%^s hesitates.", m_name);
4271 else if(percentage > 10) msg_format("%^s grunts.", m_name);
4272 else msg_format("%^s staggers.", m_name);
4276 else if(my_strchr("G", r_ptr->d_char)) // Ghosts
4279 if(percentage > 95) msg_format("%sは攻撃を気にとめていない。", m_name);
4280 else if(percentage > 75) msg_format("%sは攻撃に肩をすくめた。", m_name);
4281 else if(percentage > 50) msg_format("%sはうめいた。", m_name);
4282 else if(percentage > 35) msg_format("%^sは泣きわめいた。", m_name);
4283 else if(percentage > 20) msg_format("%^sは吠えた。", m_name);
4284 else if(percentage > 10) msg_format("%sは弱々しくうめいた。", m_name);
4285 else msg_format("%^sはかすかにうめいた。", m_name);
4287 if(percentage > 95) msg_format("%^s ignores the attack.", m_name);
4288 else if(percentage > 75) msg_format("%^s shrugs off the attack.", m_name);
4289 else if(percentage > 50) msg_format("%^s moans.", m_name);
4290 else if(percentage > 35) msg_format("%^s wails.", m_name);
4291 else if(percentage > 20) msg_format("%^s howls.", m_name);
4292 else if(percentage > 10) msg_format("%^s moans softly.", m_name);
4293 else msg_format("%^s sighs.", m_name);
4297 else if(my_strchr("CZ", r_ptr->d_char)) // Dogs and Hounds
4300 if(percentage > 95) msg_format("%^sは攻撃に肩をすくめた。", m_name);
4301 else if(percentage > 75) msg_format("%^sは痛みでうなった。", m_name);
4302 else if(percentage > 50) msg_format("%^sは痛みでキャンキャン吠えた。", m_name);
4303 else if(percentage > 35) msg_format("%^sは痛みで鳴きわめいた。", m_name);
4304 else if(percentage > 20) msg_format("%^sは苦痛のあまり鳴きわめいた。", m_name);
4305 else if(percentage > 10) msg_format("%^sは苦痛でもだえ苦しんだ。", m_name);
4306 else msg_format("%^sは弱々しく吠えた。", m_name);
4308 if(percentage > 95) msg_format("%^s shrugs off the attack.", m_name);
4309 else if(percentage > 75) msg_format("%^s snarls with pain.", m_name);
4310 else if(percentage > 50) msg_format("%^s yelps in pain.", m_name);
4311 else if(percentage > 35) msg_format("%^s howls in pain.", m_name);
4312 else if(percentage > 20) msg_format("%^s howls in agony.", m_name);
4313 else if(percentage > 10) msg_format("%^s writhes in agony.", m_name);
4314 else msg_format("%^s yelps feebly.", m_name);
4318 else if(my_strchr("Xbilqrt", r_ptr->d_char)) // One type of creatures (ignore,squeal,shriek)
4321 if(percentage > 95) msg_format("%^sは攻撃を気にとめていない。", m_name);
4322 else if(percentage > 75) msg_format("%^sは痛みでうなった。", m_name);
4323 else if(percentage > 50) msg_format("%^sは痛みで叫んだ。", m_name);
4324 else if(percentage > 35) msg_format("%^sは痛みで絶叫した。", m_name);
4325 else if(percentage > 20) msg_format("%^sは苦痛のあまり絶叫した。", m_name);
4326 else if(percentage > 10) msg_format("%^sは苦痛でもだえ苦しんだ。", m_name);
4327 else msg_format("%^sは弱々しく叫んだ。", m_name);
4329 if(percentage > 95) msg_format("%^s ignores the attack.", m_name);
4330 else if(percentage > 75) msg_format("%^s grunts with pain.", m_name);
4331 else if(percentage > 50) msg_format("%^s squeals in pain.", m_name);
4332 else if(percentage > 35) msg_format("%^s shrieks in pain.", m_name);
4333 else if(percentage > 20) msg_format("%^s shrieks in agony.", m_name);
4334 else if(percentage > 10) msg_format("%^s writhes in agony.", m_name);
4335 else msg_format("%^s cries out feebly.", m_name);
4339 else // Another type of creatures (shrug,cry,scream)
4342 if(percentage > 95) msg_format("%^sは攻撃に肩をすくめた。", m_name);
4343 else if(percentage > 75) msg_format("%^sは痛みでうなった。", m_name);
4344 else if(percentage > 50) msg_format("%^sは痛みで叫んだ。", m_name);
4345 else if(percentage > 35) msg_format("%^sは痛みで絶叫した。", m_name);
4346 else if(percentage > 20) msg_format("%^sは苦痛のあまり絶叫した。", m_name);
4347 else if(percentage > 10) msg_format("%^sは苦痛でもだえ苦しんだ。", m_name);
4348 else msg_format("%^sは弱々しく叫んだ。", m_name);
4350 if(percentage > 95) msg_format("%^s shrugs off the attack.", m_name);
4351 else if(percentage > 75) msg_format("%^s grunts with pain.", m_name);
4352 else if(percentage > 50) msg_format("%^s cries out in pain.", m_name);
4353 else if(percentage > 35) msg_format("%^s screams in pain.", m_name);
4354 else if(percentage > 20) msg_format("%^s screams in agony.", m_name);
4355 else if(percentage > 10) msg_format("%^s writhes in agony.", m_name);
4356 else msg_format("%^s cries out feebly.", m_name);
4364 * @brief SMART(適格に攻撃を行う)モンスターの学習状況を更新する / Learn about an "observed" resistance.
4365 * @param m_idx 更新を行う「モンスター情報ID
4366 * @param what 学習対象ID
4369 void update_smart_learn(MONSTER_IDX m_idx, int what)
4371 monster_type *m_ptr = &m_list[m_idx];
4372 monster_race *r_ptr = &r_info[m_ptr->r_idx];
4374 /* Not allowed to learn */
4375 if (!smart_learn) return;
4377 /* Too stupid to learn anything */
4378 if (r_ptr->flags2 & (RF2_STUPID)) return;
4380 /* Not intelligent, only learn sometimes */
4381 if (!(r_ptr->flags2 & (RF2_SMART)) && (randint0(100) < 50)) return;
4383 /* Analyze the knowledge */
4387 if (p_ptr->resist_acid) m_ptr->smart |= (SM_RES_ACID);
4388 if (IS_OPPOSE_ACID()) m_ptr->smart |= (SM_OPP_ACID);
4389 if (p_ptr->immune_acid) m_ptr->smart |= (SM_IMM_ACID);
4393 if (p_ptr->resist_elec) m_ptr->smart |= (SM_RES_ELEC);
4394 if (IS_OPPOSE_ELEC()) m_ptr->smart |= (SM_OPP_ELEC);
4395 if (p_ptr->immune_elec) m_ptr->smart |= (SM_IMM_ELEC);
4399 if (p_ptr->resist_fire) m_ptr->smart |= (SM_RES_FIRE);
4400 if (IS_OPPOSE_FIRE()) m_ptr->smart |= (SM_OPP_FIRE);
4401 if (p_ptr->immune_fire) m_ptr->smart |= (SM_IMM_FIRE);
4405 if (p_ptr->resist_cold) m_ptr->smart |= (SM_RES_COLD);
4406 if (IS_OPPOSE_COLD()) m_ptr->smart |= (SM_OPP_COLD);
4407 if (p_ptr->immune_cold) m_ptr->smart |= (SM_IMM_COLD);
4411 if (p_ptr->resist_pois) m_ptr->smart |= (SM_RES_POIS);
4412 if (IS_OPPOSE_POIS()) m_ptr->smart |= (SM_OPP_POIS);
4417 if (p_ptr->resist_neth) m_ptr->smart |= (SM_RES_NETH);
4421 if (p_ptr->resist_lite) m_ptr->smart |= (SM_RES_LITE);
4425 if (p_ptr->resist_dark) m_ptr->smart |= (SM_RES_DARK);
4429 if (p_ptr->resist_fear) m_ptr->smart |= (SM_RES_FEAR);
4433 if (p_ptr->resist_conf) m_ptr->smart |= (SM_RES_CONF);
4437 if (p_ptr->resist_chaos) m_ptr->smart |= (SM_RES_CHAOS);
4441 if (p_ptr->resist_disen) m_ptr->smart |= (SM_RES_DISEN);
4445 if (p_ptr->resist_blind) m_ptr->smart |= (SM_RES_BLIND);
4449 if (p_ptr->resist_nexus) m_ptr->smart |= (SM_RES_NEXUS);
4453 if (p_ptr->resist_sound) m_ptr->smart |= (SM_RES_SOUND);
4457 if (p_ptr->resist_shard) m_ptr->smart |= (SM_RES_SHARD);
4461 if (p_ptr->free_act) m_ptr->smart |= (SM_IMM_FREE);
4465 if (!p_ptr->msp) m_ptr->smart |= (SM_IMM_MANA);
4469 if (p_ptr->reflect) m_ptr-> smart |= (SM_IMM_REFLECT);
4476 * @brief プレイヤーを指定座標に配置する / Place the player in the dungeon XXX XXX
4479 * @return 配置に成功したらTRUE
4481 bool player_place(POSITION y, POSITION x)
4483 /* Paranoia XXX XXX */
4484 if (cave[y][x].m_idx != 0) return FALSE;
4486 /* Save player location */
4496 * @brief モンスターが盗みや拾いで確保していたアイテムを全てドロップさせる / Drop all items carried by a monster
4497 * @param m_ptr モンスター参照ポインタ
4500 void monster_drop_carried_objects(monster_type *m_ptr)
4502 OBJECT_IDX this_o_idx, next_o_idx = 0;
4508 /* Drop objects being carried */
4509 for (this_o_idx = m_ptr->hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
4511 o_ptr = &o_list[this_o_idx];
4513 /* Acquire next object */
4514 next_o_idx = o_ptr->next_o_idx;
4517 /* Copy the object */
4518 object_copy(q_ptr, o_ptr);
4520 /* Forget monster */
4521 q_ptr->held_m_idx = 0;
4523 delete_object_idx(this_o_idx);
4526 (void)drop_near(q_ptr, -1, m_ptr->fy, m_ptr->fx);
4529 /* Forget objects */
4530 m_ptr->hold_o_idx = 0;