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 "monster-hook.h"
16 #include "monster-status.h"
18 #define HORDE_NOGOOD 0x01 /*!< (未実装フラグ)HORDE生成でGOODなモンスターの生成を禁止する? */
19 #define HORDE_NOEVIL 0x02 /*!< (未実装フラグ)HORDE生成でEVILなモンスターの生成を禁止する? */
24 * @brief ELDRITCH HORROR効果時のモンスターの形容メッセージ(通常時)
26 cptr horror_desc[MAX_SAN_HORROR] =
82 * @brief ELDRITCH HORROR効果時のモンスターの形容メッセージ(幻覚状態時)
84 cptr funny_desc[MAX_SAN_FUNNY] =
145 * @var funny_comments
146 * @brief ELDRITCH HORROR効果時の幻覚時間延長を示す錯乱表現
148 cptr funny_comments[MAX_SAN_COMMENT] =
169 * @brief モンスターの目標地点をセットする / Set the target of counter attack
170 * @param m_ptr モンスターの参照ポインタ
175 void set_target(monster_type *m_ptr, POSITION y, POSITION x)
183 * @brief モンスターの目標地点をリセットする / Reset the target of counter attack
184 * @param m_ptr モンスターの参照ポインタ
187 void reset_target(monster_type *m_ptr)
189 set_target(m_ptr, 0, 0);
194 * @brief モンスターの真の種族を返す / Extract monster race pointer of a monster's true form
195 * @param m_ptr モンスターの参照ポインタ
196 * @return 本当のモンスター種族参照ポインタ
198 monster_race *real_r_ptr(monster_type *m_ptr)
200 monster_race *r_ptr = &r_info[m_ptr->r_idx];
202 /* Extract real race */
203 if (m_ptr->mflag2 & MFLAG2_CHAMELEON)
205 if (r_ptr->flags1 & RF1_UNIQUE)
206 return &r_info[MON_CHAMELEON_K];
208 return &r_info[MON_CHAMELEON];
218 * @brief モンスター配列からモンスターを消去する / Delete a monster by index.
219 * @param i 消去するモンスターのID
222 * モンスターを削除するとそのモンスターが拾っていたアイテムも同時に削除される。 /
223 * When a monster is deleted, all of its objects are deleted.
225 void delete_monster_idx(MONSTER_IDX i)
228 monster_type *m_ptr = &m_list[i];
229 monster_race *r_ptr = &r_info[m_ptr->r_idx];
230 OBJECT_IDX this_o_idx, next_o_idx = 0;
236 /* Hack -- Reduce the racial counter */
237 real_r_ptr(m_ptr)->cur_num--;
239 /* Hack -- count the number of "reproducers" */
240 if (r_ptr->flags2 & (RF2_MULTIPLY)) num_repro--;
242 if (MON_CSLEEP(m_ptr)) (void)set_monster_csleep(i, 0);
243 if (MON_FAST(m_ptr)) (void)set_monster_fast(i, 0);
244 if (MON_SLOW(m_ptr)) (void)set_monster_slow(i, 0);
245 if (MON_STUNNED(m_ptr)) (void)set_monster_stunned(i, 0);
246 if (MON_CONFUSED(m_ptr)) (void)set_monster_confused(i, 0);
247 if (MON_MONFEAR(m_ptr)) (void)set_monster_monfear(i, 0);
248 if (MON_INVULNER(m_ptr)) (void)set_monster_invulner(i, 0, FALSE);
251 /* Hack -- remove target monster */
252 if (i == target_who) target_who = 0;
254 /* Hack -- remove tracked monster */
255 if (i == p_ptr->health_who) health_track(0);
257 if (pet_t_m_idx == i ) pet_t_m_idx = 0;
258 if (riding_t_m_idx == i) riding_t_m_idx = 0;
259 if (p_ptr->riding == i) p_ptr->riding = 0;
261 /* Monster is gone */
262 cave[y][x].m_idx = 0;
266 for (this_o_idx = m_ptr->hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
271 o_ptr = &o_list[this_o_idx];
273 /* Acquire next object */
274 next_o_idx = o_ptr->next_o_idx;
277 * o_ptr->held_m_idx is needed in delete_object_idx()
278 * to prevent calling lite_spot()
281 /* Delete the object */
282 delete_object_idx(this_o_idx);
286 if (is_pet(m_ptr)) check_pets_num_and_align(m_ptr, FALSE);
289 /* Wipe the Monster */
290 (void)WIPE(m_ptr, monster_type);
298 /* Update some things */
299 if (r_ptr->flags7 & (RF7_LITE_MASK | RF7_DARK_MASK))
300 p_ptr->update |= (PU_MON_LITE);
305 * @brief 指定位置に存在するモンスターを削除する / Delete the monster, if any, at a given location
310 void delete_monster(POSITION y, POSITION x)
315 if (!in_bounds(y, x)) return;
320 /* Delete the monster (if any) */
321 if (c_ptr->m_idx) delete_monster_idx(c_ptr->m_idx);
326 * @brief モンスター情報を配列内移動する / Move an object from index i1 to index i2 in the object list
331 static void compact_monsters_aux(IDX i1, IDX i2)
337 OBJECT_IDX this_o_idx, next_o_idx = 0;
340 if (i1 == i2) return;
351 /* Update the cave */
354 /* Repair objects being carried by monster */
355 for (this_o_idx = m_ptr->hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
360 o_ptr = &o_list[this_o_idx];
362 /* Acquire next object */
363 next_o_idx = o_ptr->next_o_idx;
365 /* Reset monster pointer */
366 o_ptr->held_m_idx = i2;
369 /* Hack -- Update the target */
370 if (target_who == i1) target_who = i2;
372 /* Hack -- Update the target */
373 if (pet_t_m_idx == i1) pet_t_m_idx = i2;
374 if (riding_t_m_idx == i1) riding_t_m_idx = i2;
376 /* Hack -- Update the riding */
377 if (p_ptr->riding == i1) p_ptr->riding = i2;
379 /* Hack -- Update the health bar */
380 if (p_ptr->health_who == i1) health_track(i2);
382 /* Hack -- Update parent index */
385 for (i = 1; i < m_max; i++)
387 monster_type *m2_ptr = &m_list[i];
389 if (m2_ptr->parent_m_idx == i1)
390 m2_ptr->parent_m_idx = i2;
395 (void)COPY(&m_list[i2], &m_list[i1], monster_type);
398 (void)WIPE(&m_list[i1], monster_type);
400 for (i = 0; i < MAX_MTIMED; i++)
402 int mproc_idx = get_mproc_idx(i1, i);
403 if (mproc_idx >= 0) mproc_list[i][mproc_idx] = i2;
409 * @brief モンスター情報配列を圧縮する / Compact and Reorder the monster list
410 * @param size 圧縮後のモンスター件数目標
413 * This function can be very dangerous, use with caution!
415 * When actually "compacting" monsters, we base the saving throw
416 * on a combination of monster level, distance from player, and
417 * current "desperation".
419 * After "compacting" (if needed), we "reorder" the monsters into a more
420 * compact order, and we reset the allocation info, and the "live" array.
422 void compact_monsters(int size)
426 int cur_lev, cur_dis, chance;
428 /* Message (only if compacting) */
429 if (size) msg_print(_("モンスター情報を圧縮しています...", "Compacting monsters..."));
432 /* Compact at least 'size' objects */
433 for (num = 0, cnt = 1; num < size; cnt++)
435 /* Get more vicious each iteration */
438 /* Get closer each iteration */
439 cur_dis = 5 * (20 - cnt);
441 /* Check all the monsters */
442 for (i = 1; i < m_max; i++)
444 monster_type *m_ptr = &m_list[i];
446 monster_race *r_ptr = &r_info[m_ptr->r_idx];
448 /* Paranoia -- skip "dead" monsters */
449 if (!m_ptr->r_idx) continue;
451 /* Hack -- High level monsters start out "immune" */
452 if (r_ptr->level > cur_lev) continue;
454 if (i == p_ptr->riding) continue;
456 /* Ignore nearby monsters */
457 if ((cur_dis > 0) && (m_ptr->cdis < cur_dis)) continue;
459 /* Saving throw chance */
462 /* Only compact "Quest" Monsters in emergencies */
463 if ((r_ptr->flags1 & (RF1_QUESTOR)) && (cnt < 1000)) chance = 100;
465 /* Try not to compact Unique Monsters */
466 if (r_ptr->flags1 & (RF1_UNIQUE)) chance = 100;
468 /* All monsters get a saving throw */
469 if (randint0(100) < chance) continue;
471 if (record_named_pet && is_pet(m_ptr) && m_ptr->nickname)
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 the monster */
480 delete_monster_idx(i);
482 /* Count the monster */
488 /* Excise dead monsters (backwards!) */
489 for (i = m_max - 1; i >= 1; i--)
491 /* Get the i'th monster */
492 monster_type *m_ptr = &m_list[i];
494 /* Skip real monsters */
495 if (m_ptr->r_idx) continue;
497 /* Move last monster into open hole */
498 compact_monsters_aux(m_max - 1, i);
500 /* Compress "m_max" */
507 * @brief プレイヤーのフロア離脱に伴う全モンスター配列の消去 / Delete/Remove all the monsters when the player leaves the level
510 * This is an efficient method of simulating multiple calls to the
511 * "delete_monster()" function, with no visual effects.
513 void wipe_m_list(void)
517 /* Hack -- if Banor or Lupart dies, stay another dead */
518 if (!r_info[MON_BANORLUPART].max_num)
520 if (r_info[MON_BANOR].max_num)
522 r_info[MON_BANOR].max_num = 0;
523 r_info[MON_BANOR].r_pkills++;
524 r_info[MON_BANOR].r_akills++;
525 if (r_info[MON_BANOR].r_tkills < MAX_SHORT) r_info[MON_BANOR].r_tkills++;
527 if (r_info[MON_LUPART].max_num)
529 r_info[MON_LUPART].max_num = 0;
530 r_info[MON_LUPART].r_pkills++;
531 r_info[MON_LUPART].r_akills++;
532 if (r_info[MON_LUPART].r_tkills < MAX_SHORT) r_info[MON_LUPART].r_tkills++;
536 /* Delete all the monsters */
537 for (i = m_max - 1; i >= 1; i--)
539 monster_type *m_ptr = &m_list[i];
541 /* Skip dead monsters */
542 if (!m_ptr->r_idx) continue;
544 /* Monster is gone */
545 cave[m_ptr->fy][m_ptr->fx].m_idx = 0;
547 /* Wipe the Monster */
548 (void)WIPE(m_ptr, monster_type);
553 * Wiping racial counters of all monsters and incrementing of racial
554 * counters of monsters in party_mon[] are required to prevent multiple
555 * generation of unique monster who is the minion of player.
558 /* Hack -- Wipe the racial counter of all monster races */
559 for (i = 1; i < max_r_idx; i++) r_info[i].cur_num = 0;
567 /* Reset "mproc_max[]" */
568 for (i = 0; i < MAX_MTIMED; i++) mproc_max[i] = 0;
570 /* Hack -- reset "reproducer" count */
573 /* Hack -- no more target */
578 /* Hack -- no more tracking */
584 * @brief モンスター配列の空きを探す / Acquires and returns the index of a "free" monster.
585 * @return 利用可能なモンスター配列の添字
587 * This routine should almost never fail, but it *can* happen.
589 MONSTER_IDX m_pop(void)
594 /* Normal allocation */
595 if (m_max < max_m_idx)
597 /* Access the next hole */
600 /* Expand the array */
606 /* Return the index */
611 /* Recycle dead monsters */
612 for (i = 1; i < m_max; i++)
616 /* Acquire monster */
619 /* Skip live monsters */
620 if (m_ptr->r_idx) continue;
625 /* Use this monster */
630 /* Warn the player (except during dungeon creation) */
631 if (character_dungeon) msg_print(_("モンスターが多すぎる!", "Too many monsters!"));
633 /* Try not to crash */
641 * @var summon_specific_type
642 * @brief 召喚条件を指定するグローバル変数 / Hack -- the "type" of the current "summon specific"
643 * @todo summon_specific_typeグローバル変数の除去と関数引数への代替を行う
645 static int summon_specific_type = 0;
649 * @var summon_specific_who
650 * @brief 召喚を行ったプレイヤーあるいはモンスターのIDを示すグローバル変数 / Hack -- the index of the summoning monster
651 * @todo summon_specific_who グローバル変数の除去と関数引数への代替を行う
653 static int summon_specific_who = -1;
656 * @var summon_unique_okay
657 * @brief 召喚対象にユニークを含めるかを示すグローバル変数 / summoning unique enable
658 * @todo summon_unique_okay グローバル変数の除去と関数引数への代替を行う
660 static bool summon_unique_okay = FALSE;
663 * @brief 指定されたモンスター種族がsummon_specific_typeで指定された召喚条件に合うかどうかを返す
664 * @return 召喚条件が一致するならtrue
667 static bool summon_specific_aux(MONRACE_IDX r_idx)
669 monster_race *r_ptr = &r_info[r_idx];
672 /* Check our requirements */
673 switch (summon_specific_type)
677 okay = (r_ptr->d_char == 'a');
683 okay = (r_ptr->d_char == 'S');
689 okay = ((r_ptr->d_char == 'C') || (r_ptr->d_char == 'Z'));
695 okay = (r_ptr->d_char == 'M');
701 okay = (r_ptr->d_char == 'A' && ((r_ptr->flags3 & RF3_EVIL) || (r_ptr->flags3 & RF3_GOOD)));
707 okay = (r_ptr->flags3 & RF3_DEMON);
713 okay = (r_ptr->flags3 & RF3_UNDEAD);
719 okay = (r_ptr->flags3 & RF3_DRAGON);
723 case SUMMON_HI_UNDEAD:
725 okay = ((r_ptr->d_char == 'L') ||
726 (r_ptr->d_char == 'V') ||
727 (r_ptr->d_char == 'W'));
731 case SUMMON_HI_DRAGON:
733 okay = (r_ptr->d_char == 'D');
737 case SUMMON_HI_DEMON:
739 okay = (((r_ptr->d_char == 'U') ||
740 (r_ptr->d_char == 'H') ||
741 (r_ptr->d_char == 'B')) &&
742 (r_ptr->flags3 & RF3_DEMON)) ? TRUE : FALSE;
746 case SUMMON_AMBERITES:
748 okay = (r_ptr->flags3 & (RF3_AMBERITE)) ? TRUE : FALSE;
754 okay = (r_ptr->flags1 & (RF1_UNIQUE)) ? TRUE : FALSE;
760 okay = (r_ptr->d_char == 'm');
765 okay = (r_ptr->d_char == 'b');
768 case SUMMON_QUYLTHULG:
770 okay = (r_ptr->d_char == 'Q');
774 case SUMMON_COIN_MIMIC:
776 okay = (r_ptr->d_char == '$');
782 okay = ((r_ptr->d_char == '!') ||
783 (r_ptr->d_char == '?') ||
784 (r_ptr->d_char == '=') ||
785 (r_ptr->d_char == '$') ||
786 (r_ptr->d_char == '|'));
792 okay = (r_ptr->d_char == 'g');
798 okay = ((r_ptr->d_char == 'U') &&
799 (r_ptr->flags4 & RF4_ROCKET));
806 okay = ((r_ptr->d_char == summon_kin_type) && (r_idx != MON_HAGURE));
812 okay = (r_idx == MON_DAWN);
818 okay = (r_ptr->flags3 & (RF3_ANIMAL));
822 case SUMMON_ANIMAL_RANGER:
824 okay = ((r_ptr->flags3 & (RF3_ANIMAL)) &&
825 (my_strchr("abcflqrwBCHIJKMRS", r_ptr->d_char)) &&
826 !(r_ptr->flags3 & (RF3_DRAGON)) &&
827 !(r_ptr->flags3 & (RF3_EVIL)) &&
828 !(r_ptr->flags3 & (RF3_UNDEAD)) &&
829 !(r_ptr->flags3 & (RF3_DEMON)) &&
830 !(r_ptr->flags2 & (RF2_MULTIPLY)) &&
831 !(r_ptr->flags4 || r_ptr->a_ability_flags1 || r_ptr->a_ability_flags2));
835 case SUMMON_HI_DRAGON_LIVING:
837 okay = ((r_ptr->d_char == 'D') && monster_living(r_ptr));
843 okay = monster_living(r_ptr);
849 okay = (r_idx == MON_PHANTOM_B || r_idx == MON_PHANTOM_W);
853 case SUMMON_BLUE_HORROR:
855 okay = (r_idx == MON_BLUE_HORROR);
859 case SUMMON_ELEMENTAL:
861 okay = (r_ptr->d_char == 'E');
867 okay = (r_ptr->d_char == 'v');
873 okay = (r_ptr->d_char == 'H');
879 okay = (r_ptr->d_char == 'B');
883 case SUMMON_KAMIKAZE:
886 for (i = 0; i < 4; i++)
887 if (r_ptr->blow[i].method == RBM_EXPLODE) okay = TRUE;
891 case SUMMON_KAMIKAZE_LIVING:
895 for (i = 0; i < 4; i++)
896 if (r_ptr->blow[i].method == RBM_EXPLODE) okay = TRUE;
897 okay = (okay && monster_living(r_ptr));
903 okay = (r_idx == MON_MANES);
909 okay = (r_idx == MON_LOUSE);
913 case SUMMON_GUARDIANS:
915 okay = (r_ptr->flags7 & RF7_GUARDIAN);
921 okay = ((r_idx == MON_NOV_PALADIN) ||
922 (r_idx == MON_NOV_PALADIN_G) ||
923 (r_idx == MON_PALADIN) ||
924 (r_idx == MON_W_KNIGHT) ||
925 (r_idx == MON_ULTRA_PALADIN) ||
926 (r_idx == MON_KNI_TEMPLAR));
932 okay = (r_ptr->d_char == 'B' &&
933 (r_ptr->flags8 & RF8_WILD_MOUNTAIN) &&
934 (r_ptr->flags8 & RF8_WILD_ONLY));
938 case SUMMON_PIRANHAS:
940 okay = (r_idx == MON_PIRANHA);
944 case SUMMON_ARMAGE_GOOD:
946 okay = (r_ptr->d_char == 'A' && (r_ptr->flags3 & RF3_GOOD));
950 case SUMMON_ARMAGE_EVIL:
952 okay = ((r_ptr->flags3 & RF3_DEMON) ||
953 (r_ptr->d_char == 'A' && (r_ptr->flags3 & RF3_EVIL)));
959 /* Since okay is int, "return (okay);" is not correct. */
960 return (bool)(okay ? TRUE : FALSE);
964 * @var chameleon_change_m_idx
965 * @brief カメレオンの変身先モンスターIDを受け渡すためのグローバル変数
966 * @todo 変数渡しの問題などもあるができればchameleon_change_m_idxのグローバル変数を除去し、関数引き渡しに移行すること
968 static int chameleon_change_m_idx = 0;
972 * @brief 指定されたモンスター種族がダンジョンの制限にかかるかどうかをチェックする / Some dungeon types restrict the possible monsters.
973 * @param r_idx チェックするモンスター種族ID
974 * @return 召喚条件が一致するならtrue / Return TRUE is the monster is OK and FALSE otherwise
976 static bool restrict_monster_to_dungeon(MONRACE_IDX r_idx)
978 dungeon_info_type *d_ptr = &d_info[dungeon_type];
979 monster_race *r_ptr = &r_info[r_idx];
982 if (d_ptr->flags1 & DF1_CHAMELEON)
984 if (chameleon_change_m_idx) return TRUE;
986 if (d_ptr->flags1 & DF1_NO_MAGIC)
988 if (r_idx != MON_CHAMELEON &&
990 !(r_ptr->flags4 & RF4_NOMAGIC_MASK) &&
991 !(r_ptr->a_ability_flags1 & RF5_NOMAGIC_MASK) &&
992 !(r_ptr->a_ability_flags2 & RF6_NOMAGIC_MASK))
995 if (d_ptr->flags1 & DF1_NO_MELEE)
997 if (r_idx == MON_CHAMELEON) return TRUE;
998 if (!(r_ptr->flags4 & (RF4_BOLT_MASK | RF4_BEAM_MASK | RF4_BALL_MASK)) &&
999 !(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)) &&
1000 !(r_ptr->a_ability_flags2 & (RF6_BOLT_MASK | RF6_BEAM_MASK | RF6_BALL_MASK)))
1003 if (d_ptr->flags1 & DF1_BEGINNER)
1005 if (r_ptr->level > dun_level)
1009 if (d_ptr->special_div >= 64) return TRUE;
1010 if (summon_specific_type && !(d_ptr->flags1 & DF1_CHAMELEON)) return TRUE;
1012 switch (d_ptr->mode)
1014 case DUNGEON_MODE_AND:
1017 if ((d_ptr->mflags1 & r_ptr->flags1) != d_ptr->mflags1)
1022 if ((d_ptr->mflags2 & r_ptr->flags2) != d_ptr->mflags2)
1027 if ((d_ptr->mflags3 & r_ptr->flags3) != d_ptr->mflags3)
1032 if ((d_ptr->mflags4 & r_ptr->flags4) != d_ptr->mflags4)
1035 if (d_ptr->m_a_ability_flags1)
1037 if ((d_ptr->m_a_ability_flags1 & r_ptr->a_ability_flags1) != d_ptr->m_a_ability_flags1)
1040 if (d_ptr->m_a_ability_flags2)
1042 if ((d_ptr->m_a_ability_flags2 & r_ptr->a_ability_flags2) != d_ptr->m_a_ability_flags2)
1047 if ((d_ptr->mflags7 & r_ptr->flags7) != d_ptr->mflags7)
1052 if ((d_ptr->mflags8 & r_ptr->flags8) != d_ptr->mflags8)
1057 if ((d_ptr->mflags9 & r_ptr->flags9) != d_ptr->mflags9)
1062 if ((d_ptr->mflagsr & r_ptr->flagsr) != d_ptr->mflagsr)
1065 for (a = 0; a < 5; a++)
1066 if (d_ptr->r_char[a] && (d_ptr->r_char[a] != r_ptr->d_char)) return FALSE;
1070 case DUNGEON_MODE_NAND:
1073 if ((d_ptr->mflags1 & r_ptr->flags1) != d_ptr->mflags1)
1078 if ((d_ptr->mflags2 & r_ptr->flags2) != d_ptr->mflags2)
1083 if ((d_ptr->mflags3 & r_ptr->flags3) != d_ptr->mflags3)
1088 if ((d_ptr->mflags4 & r_ptr->flags4) != d_ptr->mflags4)
1091 if (d_ptr->m_a_ability_flags1)
1093 if ((d_ptr->m_a_ability_flags1 & r_ptr->a_ability_flags1) != d_ptr->m_a_ability_flags1)
1096 if (d_ptr->m_a_ability_flags2)
1098 if ((d_ptr->m_a_ability_flags2 & r_ptr->a_ability_flags2) != d_ptr->m_a_ability_flags2)
1103 if ((d_ptr->mflags7 & r_ptr->flags7) != d_ptr->mflags7)
1108 if ((d_ptr->mflags8 & r_ptr->flags8) != d_ptr->mflags8)
1113 if ((d_ptr->mflags9 & r_ptr->flags9) != d_ptr->mflags9)
1118 if ((d_ptr->mflagsr & r_ptr->flagsr) != d_ptr->mflagsr)
1121 for (a = 0; a < 5; a++)
1122 if (d_ptr->r_char[a] && (d_ptr->r_char[a] != r_ptr->d_char)) return TRUE;
1126 case DUNGEON_MODE_OR:
1127 if (r_ptr->flags1 & d_ptr->mflags1) return TRUE;
1128 if (r_ptr->flags2 & d_ptr->mflags2) return TRUE;
1129 if (r_ptr->flags3 & d_ptr->mflags3) return TRUE;
1130 if (r_ptr->flags4 & d_ptr->mflags4) return TRUE;
1131 if (r_ptr->a_ability_flags1 & d_ptr->m_a_ability_flags1) return TRUE;
1132 if (r_ptr->a_ability_flags2 & d_ptr->m_a_ability_flags2) return TRUE;
1133 if (r_ptr->flags7 & d_ptr->mflags7) return TRUE;
1134 if (r_ptr->flags8 & d_ptr->mflags8) return TRUE;
1135 if (r_ptr->flags9 & d_ptr->mflags9) return TRUE;
1136 if (r_ptr->flagsr & d_ptr->mflagsr) return TRUE;
1137 for (a = 0; a < 5; a++)
1138 if (d_ptr->r_char[a] == r_ptr->d_char) return TRUE;
1142 case DUNGEON_MODE_NOR:
1143 if (r_ptr->flags1 & d_ptr->mflags1) return FALSE;
1144 if (r_ptr->flags2 & d_ptr->mflags2) return FALSE;
1145 if (r_ptr->flags3 & d_ptr->mflags3) return FALSE;
1146 if (r_ptr->flags4 & d_ptr->mflags4) return FALSE;
1147 if (r_ptr->a_ability_flags1 & d_ptr->m_a_ability_flags1) return FALSE;
1148 if (r_ptr->a_ability_flags2 & d_ptr->m_a_ability_flags2) return FALSE;
1149 if (r_ptr->flags7 & d_ptr->mflags7) return FALSE;
1150 if (r_ptr->flags8 & d_ptr->mflags8) return FALSE;
1151 if (r_ptr->flags9 & d_ptr->mflags9) return FALSE;
1152 if (r_ptr->flagsr & d_ptr->mflagsr) return FALSE;
1153 for (a = 0; a < 5; a++)
1154 if (d_ptr->r_char[a] == r_ptr->d_char) return FALSE;
1163 * @brief モンスター生成制限関数最大2つから / Apply a "monster restriction function" to the "monster allocation table"
1164 * @param monster_hook 制限関数1
1165 * @param monster_hook2 制限関数2
1168 errr get_mon_num_prep(monster_hook_type monster_hook,
1169 monster_hook_type monster_hook2)
1173 /* Todo: Check the hooks for non-changes */
1175 /* Set the new hooks */
1176 get_mon_num_hook = monster_hook;
1177 get_mon_num2_hook = monster_hook2;
1179 /* Scan the allocation table */
1180 for (i = 0; i < alloc_race_size; i++)
1182 monster_race *r_ptr;
1185 alloc_entry *entry = &alloc_race_table[i];
1188 r_ptr = &r_info[entry->index];
1190 /* Skip monsters which don't pass the restriction */
1191 if ((get_mon_num_hook && !((*get_mon_num_hook)(entry->index))) ||
1192 (get_mon_num2_hook && !((*get_mon_num2_hook)(entry->index))))
1195 if (!p_ptr->inside_battle && !chameleon_change_m_idx &&
1196 summon_specific_type != SUMMON_GUARDIANS)
1198 /* Hack -- don't create questors */
1199 if (r_ptr->flags1 & RF1_QUESTOR)
1202 if (r_ptr->flags7 & RF7_GUARDIAN)
1205 /* Depth Monsters never appear out of depth */
1206 if ((r_ptr->flags1 & (RF1_FORCE_DEPTH)) &&
1207 (r_ptr->level > dun_level))
1211 /* Accept this monster */
1212 entry->prob2 = entry->prob1;
1214 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)
1216 int hoge = entry->prob2 * d_info[dungeon_type].special_div;
1217 entry->prob2 = hoge / 64;
1218 if (randint0(64) < (hoge & 0x3f)) entry->prob2++;
1227 * @brief 平方根を切り捨て整数で返す
1231 static int mysqrt(int n)
1269 * @brief 生成モンスター種族を1種生成テーブルから選択する
1271 * @return 選択されたモンスター生成種族
1273 * Choose a monster race that seems "appropriate" to the given level
1275 * This function uses the "prob2" field of the "monster allocation table",
1276 * and various local information, to calculate the "prob3" field of the
1277 * same table, which is then used to choose an "appropriate" monster, in
1278 * a relatively efficient manner.
1280 * Note that "town" monsters will *only* be created in the town, and
1281 * "normal" monsters will *never* be created in the town, unless the
1282 * "level" is "modified", for example, by polymorph or summoning.
1284 * There is a small chance (1/50) of "boosting" the given depth by
1285 * a small amount (up to four levels), except in the town.
1287 * It is (slightly) more likely to acquire a monster of the given level
1288 * than one of a lower level. This is done by choosing several monsters
1289 * appropriate to the given level and keeping the "hardest" one.
1291 * Note that if no monsters are "appropriate", then this function will
1292 * fail, and return zero, but this should *almost* never happen.
1294 MONRACE_IDX get_mon_num(DEPTH level)
1299 monster_race *r_ptr;
1300 alloc_entry *table = alloc_race_table;
1302 int pls_kakuritu, pls_level;
1303 int delay = mysqrt(level * 10000L) + 400L;
1305 if (level > MAX_DEPTH - 1) level = MAX_DEPTH - 1;
1307 pls_kakuritu = MAX(NASTY_MON_MAX, NASTY_MON_BASE - ((dungeon_turn / (TURNS_PER_TICK * 5000L) - delay / 10)));
1308 pls_level = MIN(NASTY_MON_PLUS_MAX, 3 + dungeon_turn / (TURNS_PER_TICK * 40000L) - delay / 40 + MIN(5, level / 10)) ;
1310 if (d_info[dungeon_type].flags1 & DF1_MAZE)
1312 pls_kakuritu = MIN(pls_kakuritu / 2, pls_kakuritu - 10);
1313 if (pls_kakuritu < 2) pls_kakuritu = 2;
1318 /* Boost the level */
1319 if (!p_ptr->inside_battle && !(d_info[dungeon_type].flags1 & DF1_BEGINNER))
1321 /* Nightmare mode allows more out-of depth monsters */
1322 if (ironman_nightmare && !randint0(pls_kakuritu))
1324 /* What a bizarre calculation */
1325 level = 1 + (level * MAX_DEPTH / randint1(MAX_DEPTH));
1329 /* Occasional "nasty" monster */
1330 if (!randint0(pls_kakuritu))
1332 /* Pick a level bonus */
1341 /* Process probabilities */
1342 for (i = 0; i < alloc_race_size; i++)
1344 /* Monsters are sorted by depth */
1345 if (table[i].level > level) break;
1350 /* Access the "r_idx" of the chosen monster */
1351 r_idx = table[i].index;
1353 /* Access the actual race */
1354 r_ptr = &r_info[r_idx];
1356 if (!p_ptr->inside_battle && !chameleon_change_m_idx)
1358 /* Hack -- "unique" monsters must be "unique" */
1359 if (((r_ptr->flags1 & (RF1_UNIQUE)) ||
1360 (r_ptr->flags7 & (RF7_NAZGUL))) &&
1361 (r_ptr->cur_num >= r_ptr->max_num))
1366 if ((r_ptr->flags7 & (RF7_UNIQUE2)) &&
1367 (r_ptr->cur_num >= 1))
1372 if (r_idx == MON_BANORLUPART)
1374 if (r_info[MON_BANOR].cur_num > 0) continue;
1375 if (r_info[MON_LUPART].cur_num > 0) continue;
1380 table[i].prob3 = table[i].prob2;
1383 total += table[i].prob3;
1386 /* No legal monsters */
1387 if (total <= 0) return (0);
1389 /* Pick a monster */
1390 value = randint0(total);
1392 /* Find the monster */
1393 for (i = 0; i < alloc_race_size; i++)
1395 /* Found the entry */
1396 if (value < table[i].prob3) break;
1399 value = value - table[i].prob3;
1405 /* Try for a "harder" monster once (50%) or twice (10%) */
1411 /* Pick a monster */
1412 value = randint0(total);
1414 /* Find the monster */
1415 for (i = 0; i < alloc_race_size; i++)
1417 /* Found the entry */
1418 if (value < table[i].prob3) break;
1421 value = value - table[i].prob3;
1424 /* Keep the "best" one */
1425 if (table[i].level < table[j].level) i = j;
1428 /* Try for a "harder" monster twice (10%) */
1434 /* Pick a monster */
1435 value = randint0(total);
1437 /* Find the monster */
1438 for (i = 0; i < alloc_race_size; i++)
1440 /* Found the entry */
1441 if (value < table[i].prob3) break;
1444 value = value - table[i].prob3;
1447 /* Keep the "best" one */
1448 if (table[i].level < table[j].level) i = j;
1452 return (table[i].index);
1457 * @brief モンスターの呼称を作成する / Build a string describing a monster in some way.
1458 * @param desc 記述出力先の文字列参照ポインタ
1459 * @param m_ptr モンスターの参照ポインタ
1460 * @param mode 呼称オプション
1463 * We can correctly describe monsters based on their visibility.
1464 * We can force all monsters to be treated as visible or invisible.
1465 * We can build nominatives, objectives, possessives, or reflexives.
1466 * We can selectively pronominalize hidden, visible, or all monsters.
1467 * We can use definite or indefinite descriptions for hidden monsters.
1468 * We can use definite or indefinite descriptions for visible monsters.
1470 * Pronominalization involves the gender whenever possible and allowed,
1471 * so that by cleverly requesting pronominalization / visibility, you
1472 * can get messages like "You hit someone. She screams in agony!".
1474 * Reflexives are acquired by requesting Objective plus Possessive.
1476 * If no m_ptr arg is given (?), the monster is assumed to be hidden,
1477 * unless the "Assume Visible" mode is requested.
1479 * If no r_ptr arg is given, it is extracted from m_ptr and r_info
1480 * If neither m_ptr nor r_ptr is given, the monster is assumed to
1481 * be neuter, singular, and hidden (unless "Assume Visible" is set),
1482 * in which case you may be in trouble... :-)
1484 * I am assuming that no monster name is more than 70 characters long,
1485 * so that "char desc[80];" is sufficiently large for any result.
1488 * MD_OBJECTIVE --> Objective (or Reflexive)
1489 * MD_POSSESSIVE --> Possessive (or Reflexive)
1490 * MD_INDEF_HIDDEN --> Use indefinites for hidden monsters ("something")
1491 * MD_INDEF_VISIBLE --> Use indefinites for visible monsters ("a kobold")
1492 * MD_PRON_HIDDEN --> Pronominalize hidden monsters
1493 * MD_PRON_VISIBLE --> Pronominalize visible monsters
1494 * MD_ASSUME_HIDDEN --> Assume the monster is hidden
1495 * MD_ASSUME_VISIBLE --> Assume the monster is visible
1496 * MD_TRUE_NAME --> Chameleon's true name
1497 * MD_IGNORE_HALLU --> Ignore hallucination, and penetrate shape change
1500 * 0x00 --> Full nominative name ("the kobold") or "it"
1501 * MD_INDEF_HIDDEN --> Full nominative name ("the kobold") or "something"
1502 * MD_ASSUME_VISIBLE --> Genocide resistance name ("the kobold")
1503 * MD_ASSUME_VISIBLE | MD_INDEF_VISIBLE --> Killing name ("a kobold")
1504 * MD_PRON_VISIBLE | MD_POSSESSIVE
1505 * --> Possessive, genderized if visable ("his") or "its"
1506 * MD_PRON_VISIBLE | MD_POSSESSIVE | MD_OBJECTIVE
1507 * --> Reflexive, genderized if visable ("himself") or "itself"
1509 void monster_desc(char *desc, monster_type *m_ptr, BIT_FLAGS mode)
1512 monster_race *r_ptr;
1516 char silly_name[1024];
1520 r_ptr = &r_info[m_ptr->ap_r_idx];
1522 /* Mode of MD_TRUE_NAME will reveal Chameleon's true name */
1523 if (mode & MD_TRUE_NAME) name = (r_name + real_r_ptr(m_ptr)->name);
1524 else name = (r_name + r_ptr->name);
1526 /* Are we hallucinating? (Idea from Nethack...) */
1527 if (p_ptr->image && !(mode & MD_IGNORE_HALLU))
1531 if (!get_rnd_line(_("silly_j.txt", "silly.txt"), m_ptr->r_idx, silly_name))
1537 monster_race *hallu_race;
1541 hallu_race = &r_info[randint1(max_r_idx - 1)];
1543 while (!hallu_race->name || (hallu_race->flags1 & RF1_UNIQUE));
1545 strcpy(silly_name, (r_name + hallu_race->name));
1548 /* Better not strcpy it, or we could corrupt r_info... */
1552 /* Can we "see" it (exists + forced, or visible + not unforced) */
1553 seen = (m_ptr && ((mode & MD_ASSUME_VISIBLE) || (!(mode & MD_ASSUME_HIDDEN) && m_ptr->ml)));
1555 /* Sexed Pronouns (seen and allowed, or unseen and allowed) */
1556 pron = (m_ptr && ((seen && (mode & MD_PRON_VISIBLE)) || (!seen && (mode & MD_PRON_HIDDEN))));
1559 /* First, try using pronouns, or describing hidden monsters */
1562 /* an encoding of the monster "sex" */
1565 /* Extract the gender (if applicable) */
1566 if (r_ptr->flags1 & (RF1_FEMALE)) kind = 0x20;
1567 else if (r_ptr->flags1 & (RF1_MALE)) kind = 0x10;
1569 /* Ignore the gender (if desired) */
1570 if (!m_ptr || !pron) kind = 0x00;
1573 /* Assume simple result */
1574 res = _("何か", "it");
1576 /* Brute force: split on the possibilities */
1577 switch (kind + (mode & (MD_INDEF_HIDDEN | MD_POSSESSIVE | MD_OBJECTIVE)))
1579 /* Neuter, or unknown */
1581 case 0x00: res = "何か"; break;
1582 case 0x00 + (MD_OBJECTIVE): res = "何か"; break;
1583 case 0x00 + (MD_POSSESSIVE): res = "何かの"; break;
1584 case 0x00 + (MD_POSSESSIVE | MD_OBJECTIVE): res = "何か自身"; break;
1585 case 0x00 + (MD_INDEF_HIDDEN): res = "何か"; break;
1586 case 0x00 + (MD_INDEF_HIDDEN | MD_OBJECTIVE): res = "何か"; break;
1587 case 0x00 + (MD_INDEF_HIDDEN | MD_POSSESSIVE): res = "何か"; break;
1588 case 0x00 + (MD_INDEF_HIDDEN | MD_POSSESSIVE | MD_OBJECTIVE): res = "それ自身"; break;
1590 case 0x00: res = "it"; break;
1591 case 0x00 + (MD_OBJECTIVE): res = "it"; break;
1592 case 0x00 + (MD_POSSESSIVE): res = "its"; break;
1593 case 0x00 + (MD_POSSESSIVE | MD_OBJECTIVE): res = "itself"; break;
1594 case 0x00 + (MD_INDEF_HIDDEN): res = "something"; break;
1595 case 0x00 + (MD_INDEF_HIDDEN | MD_OBJECTIVE): res = "something"; break;
1596 case 0x00 + (MD_INDEF_HIDDEN | MD_POSSESSIVE): res = "something's"; break;
1597 case 0x00 + (MD_INDEF_HIDDEN | MD_POSSESSIVE | MD_OBJECTIVE): res = "itself"; break;
1601 /* Male (assume human if vague) */
1603 case 0x10: res = "彼"; break;
1604 case 0x10 + (MD_OBJECTIVE): res = "彼"; break;
1605 case 0x10 + (MD_POSSESSIVE): res = "彼の"; break;
1606 case 0x10 + (MD_POSSESSIVE | MD_OBJECTIVE): res = "彼自身"; break;
1607 case 0x10 + (MD_INDEF_HIDDEN): res = "誰か"; break;
1608 case 0x10 + (MD_INDEF_HIDDEN | MD_OBJECTIVE): res = "誰か"; break;
1609 case 0x10 + (MD_INDEF_HIDDEN | MD_POSSESSIVE): res = "誰かの"; break;
1610 case 0x10 + (MD_INDEF_HIDDEN | MD_POSSESSIVE | MD_OBJECTIVE): res = "彼自身"; break;
1612 case 0x10: res = "he"; break;
1613 case 0x10 + (MD_OBJECTIVE): res = "him"; break;
1614 case 0x10 + (MD_POSSESSIVE): res = "his"; break;
1615 case 0x10 + (MD_POSSESSIVE | MD_OBJECTIVE): res = "himself"; break;
1616 case 0x10 + (MD_INDEF_HIDDEN): res = "someone"; break;
1617 case 0x10 + (MD_INDEF_HIDDEN | MD_OBJECTIVE): res = "someone"; break;
1618 case 0x10 + (MD_INDEF_HIDDEN | MD_POSSESSIVE): res = "someone's"; break;
1619 case 0x10 + (MD_INDEF_HIDDEN | MD_POSSESSIVE | MD_OBJECTIVE): res = "himself"; break;
1623 /* Female (assume human if vague) */
1625 case 0x20: res = "彼女"; break;
1626 case 0x20 + (MD_OBJECTIVE): res = "彼女"; break;
1627 case 0x20 + (MD_POSSESSIVE): res = "彼女の"; break;
1628 case 0x20 + (MD_POSSESSIVE | MD_OBJECTIVE): res = "彼女自身"; break;
1629 case 0x20 + (MD_INDEF_HIDDEN): res = "誰か"; break;
1630 case 0x20 + (MD_INDEF_HIDDEN | MD_OBJECTIVE): res = "誰か"; break;
1631 case 0x20 + (MD_INDEF_HIDDEN | MD_POSSESSIVE): res = "誰かの"; break;
1632 case 0x20 + (MD_INDEF_HIDDEN | MD_POSSESSIVE | MD_OBJECTIVE): res = "彼女自身"; break;
1634 case 0x20: res = "she"; break;
1635 case 0x20 + (MD_OBJECTIVE): res = "her"; break;
1636 case 0x20 + (MD_POSSESSIVE): res = "her"; break;
1637 case 0x20 + (MD_POSSESSIVE | MD_OBJECTIVE): res = "herself"; break;
1638 case 0x20 + (MD_INDEF_HIDDEN): res = "someone"; break;
1639 case 0x20 + (MD_INDEF_HIDDEN | MD_OBJECTIVE): res = "someone"; break;
1640 case 0x20 + (MD_INDEF_HIDDEN | MD_POSSESSIVE): res = "someone's"; break;
1641 case 0x20 + (MD_INDEF_HIDDEN | MD_POSSESSIVE | MD_OBJECTIVE): res = "herself"; break;
1645 /* Copy the result */
1646 (void)strcpy(desc, res);
1650 /* Handle visible monsters, "reflexive" request */
1651 else if ((mode & (MD_POSSESSIVE | MD_OBJECTIVE)) == (MD_POSSESSIVE | MD_OBJECTIVE))
1653 /* The monster is visible, so use its gender */
1655 if (r_ptr->flags1 & (RF1_FEMALE)) strcpy(desc, "彼女自身");
1656 else if (r_ptr->flags1 & (RF1_MALE)) strcpy(desc, "彼自身");
1657 else strcpy(desc, "それ自身");
1659 if (r_ptr->flags1 & RF1_FEMALE) strcpy(desc, "herself");
1660 else if (r_ptr->flags1 & RF1_MALE) strcpy(desc, "himself");
1661 else strcpy(desc, "itself");
1666 /* Handle all other visible monster requests */
1670 if (is_pet(m_ptr) && !is_original_ap(m_ptr))
1676 while(strncmp(t, "』", 2) && *t) t++;
1680 (void)sprintf(desc, "%s?』", buf);
1683 (void)sprintf(desc, "%s?", name);
1685 (void)sprintf(desc, "%s?", name);
1690 /* It could be a Unique */
1691 if ((r_ptr->flags1 & RF1_UNIQUE) && !(p_ptr->image && !(mode & MD_IGNORE_HALLU)))
1693 /* Start with the name (thus nominative and objective) */
1694 if ((m_ptr->mflag2 & MFLAG2_CHAMELEON) && !(mode & MD_TRUE_NAME))
1700 while (strncmp(t, "』", 2) && *t) t++;
1704 (void)sprintf(desc, "%s?』", buf);
1707 (void)sprintf(desc, "%s?", name);
1709 (void)sprintf(desc, "%s?", name);
1713 /* Inside monster arena, and it is not your mount */
1714 else if (p_ptr->inside_battle &&
1715 !(p_ptr->riding && (&m_list[p_ptr->riding] == m_ptr)))
1717 /* It is a fake unique monster */
1718 (void)sprintf(desc, _("%sもどき", "fake %s"), name);
1723 (void)strcpy(desc, name);
1727 /* It could be an indefinite monster */
1728 else if (mode & MD_INDEF_VISIBLE)
1730 /* XXX Check plurality for "some" */
1732 /* Indefinite monsters need an indefinite article */
1734 (void)strcpy(desc, "");
1736 (void)strcpy(desc, is_a_vowel(name[0]) ? "an " : "a ");
1739 (void)strcat(desc, name);
1742 /* It could be a normal, definite, monster */
1745 /* Definite monsters need a definite article */
1747 (void)strcpy(desc, _("あなたの", "your "));
1749 (void)strcpy(desc, _("", "the "));
1751 (void)strcat(desc, name);
1754 if (m_ptr->nickname)
1756 sprintf(buf,_("「%s」", " called %s"),quark_str(m_ptr->nickname));
1760 if (p_ptr->riding && (&m_list[p_ptr->riding] == m_ptr))
1762 strcat(desc,_("(乗馬中)", "(riding)"));
1765 if ((mode & MD_IGNORE_HALLU) && (m_ptr->mflag2 & MFLAG2_CHAMELEON))
1767 if (r_ptr->flags1 & RF1_UNIQUE)
1769 strcat(desc,_("(カメレオンの王)", "(Chameleon Lord)"));
1773 strcat(desc,_("(カメレオン)", "(Chameleon)"));
1777 if ((mode & MD_IGNORE_HALLU) && !is_original_ap(m_ptr))
1779 strcat(desc, format("(%s)", r_name + r_info[m_ptr->r_idx].name));
1782 /* Handle the Possessive as a special afterthought */
1783 if (mode & MD_POSSESSIVE)
1785 /* XXX Check for trailing "s" */
1787 /* Simply append "apostrophe" and "s" */
1788 (void)strcat(desc, _("の", "'s"));
1796 * @brief モンスターの調査による思い出補完処理 / Learn about a monster (by "probing" it)
1797 * @param r_idx 補完されるモンスター種族ID
1798 * @return 明らかになった情報の度数
1800 * Return the number of new flags learnt. -Mogami-
1802 int lore_do_probe(MONRACE_IDX r_idx)
1804 monster_race *r_ptr = &r_info[r_idx];
1808 /* Maximal info about awareness */
1809 if (r_ptr->r_wake != MAX_UCHAR) n++;
1810 if (r_ptr->r_ignore != MAX_UCHAR) n++;
1811 r_ptr->r_wake = r_ptr->r_ignore = MAX_UCHAR;
1813 /* Observe "maximal" attacks */
1814 for (i = 0; i < 4; i++)
1816 /* Examine "actual" blows */
1817 if (r_ptr->blow[i].effect || r_ptr->blow[i].method)
1819 /* Maximal observations */
1820 if (r_ptr->r_blows[i] != MAX_UCHAR) n++;
1821 r_ptr->r_blows[i] = MAX_UCHAR;
1827 (((r_ptr->flags1 & RF1_DROP_4D2) ? 8 : 0) +
1828 ((r_ptr->flags1 & RF1_DROP_3D2) ? 6 : 0) +
1829 ((r_ptr->flags1 & RF1_DROP_2D2) ? 4 : 0) +
1830 ((r_ptr->flags1 & RF1_DROP_1D2) ? 2 : 0) +
1831 ((r_ptr->flags1 & RF1_DROP_90) ? 1 : 0) +
1832 ((r_ptr->flags1 & RF1_DROP_60) ? 1 : 0));
1834 /* Only "valid" drops */
1835 if (!(r_ptr->flags1 & RF1_ONLY_GOLD))
1837 if (r_ptr->r_drop_item != tmp_byte) n++;
1838 r_ptr->r_drop_item = tmp_byte;
1840 if (!(r_ptr->flags1 & RF1_ONLY_ITEM))
1842 if (r_ptr->r_drop_gold != tmp_byte) n++;
1843 r_ptr->r_drop_gold = tmp_byte;
1846 /* Observe many spells */
1847 if (r_ptr->r_cast_spell != MAX_UCHAR) n++;
1848 r_ptr->r_cast_spell = MAX_UCHAR;
1850 /* Count unknown flags */
1851 for (i = 0; i < 32; i++)
1853 if (!(r_ptr->r_flags1 & (1L << i)) &&
1854 (r_ptr->flags1 & (1L << i))) n++;
1855 if (!(r_ptr->r_flags2 & (1L << i)) &&
1856 (r_ptr->flags2 & (1L << i))) n++;
1857 if (!(r_ptr->r_flags3 & (1L << i)) &&
1858 (r_ptr->flags3 & (1L << i))) n++;
1859 if (!(r_ptr->r_flags4 & (1L << i)) &&
1860 (r_ptr->flags4 & (1L << i))) n++;
1861 if (!(r_ptr->r_flags5 & (1L << i)) &&
1862 (r_ptr->a_ability_flags1 & (1L << i))) n++;
1863 if (!(r_ptr->r_flags6 & (1L << i)) &&
1864 (r_ptr->a_ability_flags2 & (1L << i))) n++;
1865 if (!(r_ptr->r_flagsr & (1L << i)) &&
1866 (r_ptr->flagsr & (1L << i))) n++;
1868 /* r_flags7 is actually unused */
1870 if (!(r_ptr->r_flags7 & (1L << i)) &&
1871 (r_ptr->flags7 & (1L << i))) n++;
1875 /* Know all the flags */
1876 r_ptr->r_flags1 = r_ptr->flags1;
1877 r_ptr->r_flags2 = r_ptr->flags2;
1878 r_ptr->r_flags3 = r_ptr->flags3;
1879 r_ptr->r_flags4 = r_ptr->flags4;
1880 r_ptr->r_flags5 = r_ptr->a_ability_flags1;
1881 r_ptr->r_flags6 = r_ptr->a_ability_flags2;
1882 r_ptr->r_flagsr = r_ptr->flagsr;
1884 /* r_flags7 is actually unused */
1885 /* r_ptr->r_flags7 = r_ptr->flags7; */
1887 /* Know about evolution */
1888 if (!(r_ptr->r_xtra1 & MR1_SINKA)) n++;
1889 r_ptr->r_xtra1 |= MR1_SINKA;
1891 /* Update monster recall window */
1892 if (p_ptr->monster_race_idx == r_idx)
1895 p_ptr->window |= (PW_MONSTER);
1898 /* Return the number of new flags learnt */
1904 * @brief モンスターの撃破に伴うドロップ情報の保管処理 / Take note that the given monster just dropped some treasure
1905 * @param m_idx モンスター情報のID
1906 * @param num_item 手に入れたアイテム数
1907 * @param num_gold 手に入れた財宝の単位数
1910 * Note that learning the "GOOD"/"GREAT" flags gives information
1911 * about the treasure (even when the monster is killed for the first
1912 * time, such as uniques, and the treasure has not been examined yet).
1914 * This "indirect" method is used to prevent the player from learning
1915 * exactly how much treasure a monster can drop from observing only
1916 * a single example of a drop. This method actually observes how much
1917 * gold and items are dropped, and remembers that information to be
1918 * described later by the monster recall code.
1920 void lore_treasure(MONSTER_IDX m_idx, ITEM_NUMBER num_item, ITEM_NUMBER num_gold)
1922 monster_type *m_ptr = &m_list[m_idx];
1924 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1926 /* If the monster doesn't have original appearance, don't note */
1927 if (!is_original_ap(m_ptr)) return;
1929 /* Note the number of things dropped */
1930 if (num_item > r_ptr->r_drop_item) r_ptr->r_drop_item = num_item;
1931 if (num_gold > r_ptr->r_drop_gold) r_ptr->r_drop_gold = num_gold;
1933 /* Hack -- memorize the good/great flags */
1934 if (r_ptr->flags1 & (RF1_DROP_GOOD)) r_ptr->r_flags1 |= (RF1_DROP_GOOD);
1935 if (r_ptr->flags1 & (RF1_DROP_GREAT)) r_ptr->r_flags1 |= (RF1_DROP_GREAT);
1937 /* Update monster recall window */
1938 if (p_ptr->monster_race_idx == m_ptr->r_idx)
1941 p_ptr->window |= (PW_MONSTER);
1947 * @brief ELDRITCH_HORRORによるプレイヤーの精神破壊処理
1948 * @param m_ptr ELDRITCH_HORRORを引き起こしたモンスターの参照ポインタ
1949 * @param necro 暗黒領域魔法の詠唱失敗によるものならばTRUEを返す
1952 void sanity_blast(monster_type *m_ptr, bool necro)
1956 if (p_ptr->inside_battle || !character_dungeon) return;
1958 if (!necro && m_ptr)
1961 monster_race *r_ptr = &r_info[m_ptr->ap_r_idx];
1963 power = r_ptr->level / 2;
1965 monster_desc(m_name, m_ptr, 0);
1967 if (!(r_ptr->flags1 & RF1_UNIQUE))
1969 if (r_ptr->flags1 & RF1_FRIENDS)
1974 if (!is_loading_now)
1975 return; /* No effect yet, just loaded... */
1978 return; /* Cannot see it for some reason */
1980 if (!(r_ptr->flags2 & RF2_ELDRITCH_HORROR))
1984 return; /* Pet eldritch horrors are safe most of the time */
1986 if (randint1(100) > power) return;
1988 if (saving_throw(p_ptr->skill_sav - power))
1990 return; /* Save, no adverse effects */
1995 /* Something silly happens... */
1997 msg_format("%s%sの顔を見てしまった!",
1998 funny_desc[randint0(MAX_SAN_FUNNY)], m_name);
2000 msg_format("You behold the %s visage of %s!",
2001 funny_desc[randint0(MAX_SAN_FUNNY)], m_name);
2006 msg_print(funny_comments[randint0(MAX_SAN_COMMENT)]);
2007 p_ptr->image = p_ptr->image + randint1(r_ptr->level);
2010 return; /* Never mind; we can't see it clearly enough */
2013 /* Something frightening happens... */
2015 msg_format("%s%sの顔を見てしまった!",
2016 horror_desc[randint0(MAX_SAN_HORROR)], m_name);
2018 msg_format("You behold the %s visage of %s!",
2019 horror_desc[randint0(MAX_SAN_HORROR)], m_name);
2022 r_ptr->r_flags2 |= RF2_ELDRITCH_HORROR;
2024 /* Demon characters are unaffected */
2025 if (prace_is_(RACE_IMP) || prace_is_(RACE_DEMON) || (mimic_info[p_ptr->mimic_form].MIMIC_FLAGS & MIMIC_IS_DEMON)) return;
2026 if (p_ptr->wizard) return;
2028 /* Undead characters are 50% likely to be unaffected */
2029 if (prace_is_(RACE_SKELETON) || prace_is_(RACE_ZOMBIE)
2030 || prace_is_(RACE_VAMPIRE) || prace_is_(RACE_SPECTRE) ||
2031 (mimic_info[p_ptr->mimic_form].MIMIC_FLAGS & MIMIC_IS_UNDEAD))
2033 if (saving_throw(25 + p_ptr->lev)) return;
2038 monster_race *r_ptr;
2042 get_mon_num_prep(get_nightmare, NULL);
2044 r_ptr = &r_info[get_mon_num(MAX_DEPTH)];
2045 power = r_ptr->level + 10;
2046 desc = r_name + r_ptr->name;
2048 get_mon_num_prep(NULL, NULL);
2052 if (!(r_ptr->flags1 & RF1_UNIQUE))
2053 sprintf(m_name, "%s %s", (is_a_vowel(desc[0]) ? "an" : "a"), desc);
2056 sprintf(m_name, "%s", desc);
2058 if (!(r_ptr->flags1 & RF1_UNIQUE))
2060 if (r_ptr->flags1 & RF1_FRIENDS) power /= 2;
2064 if (saving_throw(p_ptr->skill_sav * 100 / power))
2066 msg_format(_("夢の中で%sに追いかけられた。", "%^s chases you through your dreams."), m_name);
2073 /* Something silly happens... */
2074 msg_format(_("%s%sの顔を見てしまった!", "You behold the %s visage of %s!"),
2075 funny_desc[randint0(MAX_SAN_FUNNY)], m_name);
2079 msg_print(funny_comments[randint0(MAX_SAN_COMMENT)]);
2080 p_ptr->image = p_ptr->image + randint1(r_ptr->level);
2083 /* Never mind; we can't see it clearly enough */
2087 /* Something frightening happens... */
2088 msg_format(_("%s%sの顔を見てしまった!", "You behold the %s visage of %s!"),
2089 horror_desc[randint0(MAX_SAN_HORROR)], desc);
2091 r_ptr->r_flags2 |= RF2_ELDRITCH_HORROR;
2093 if (!p_ptr->mimic_form)
2095 switch (p_ptr->prace)
2097 /* Demons may make a saving throw */
2100 if (saving_throw(20 + p_ptr->lev)) return;
2102 /* Undead may make a saving throw */
2107 if (saving_throw(10 + p_ptr->lev)) return;
2113 /* Demons may make a saving throw */
2114 if (mimic_info[p_ptr->mimic_form].MIMIC_FLAGS & MIMIC_IS_DEMON)
2116 if (saving_throw(20 + p_ptr->lev)) return;
2118 /* Undead may make a saving throw */
2119 else if (mimic_info[p_ptr->mimic_form].MIMIC_FLAGS & MIMIC_IS_UNDEAD)
2121 if (saving_throw(10 + p_ptr->lev)) return;
2127 msg_print(_("ネクロノミコンを読んで正気を失った!", "Your sanity is shaken by reading the Necronomicon!"));
2130 if (saving_throw(p_ptr->skill_sav - power))
2136 (void)do_dec_stat(A_INT);
2137 } while (randint0(100) > p_ptr->skill_sav && one_in_(2));
2140 (void)do_dec_stat(A_WIS);
2141 } while (randint0(100) > p_ptr->skill_sav && one_in_(2));
2143 switch (randint1(21))
2146 if (!(p_ptr->muta3 & MUT3_MORONIC) && one_in_(5))
2148 if ((p_ptr->stat_use[A_INT] < 4) && (p_ptr->stat_use[A_WIS] < 4))
2150 msg_print(_("あなたは完璧な馬鹿になったような気がした。しかしそれは元々だった。", "You turn into an utter moron!"));
2154 msg_print(_("あなたは完璧な馬鹿になった!", "You turn into an utter moron!"));
2157 if (p_ptr->muta3 & MUT3_HYPER_INT)
2159 msg_print(_("あなたの脳は生体コンピュータではなくなった。", "Your brain is no longer a living computer."));
2160 p_ptr->muta3 &= ~(MUT3_HYPER_INT);
2162 p_ptr->muta3 |= MUT3_MORONIC;
2168 if (!(p_ptr->muta2 & MUT2_COWARDICE) && !p_ptr->resist_fear)
2170 msg_print(_("あなたはパラノイアになった!", "You become paranoid!"));
2172 /* Duh, the following should never happen, but anyway... */
2173 if (p_ptr->muta3 & MUT3_FEARLESS)
2175 msg_print(_("あなたはもう恐れ知らずではなくなった。", "You are no longer fearless."));
2176 p_ptr->muta3 &= ~(MUT3_FEARLESS);
2179 p_ptr->muta2 |= MUT2_COWARDICE;
2185 if (!(p_ptr->muta2 & MUT2_HALLU) && !p_ptr->resist_chaos)
2187 msg_print(_("幻覚をひき起こす精神錯乱に陥った!", "You are afflicted by a hallucinatory insanity!"));
2188 p_ptr->muta2 |= MUT2_HALLU;
2194 if (!(p_ptr->muta2 & MUT2_BERS_RAGE))
2196 msg_print(_("激烈な感情の発作におそわれるようになった!", "You become subject to fits of berserk rage!"));
2197 p_ptr->muta2 |= MUT2_BERS_RAGE;
2207 if (!p_ptr->resist_conf)
2209 (void)set_confused(p_ptr->confused + randint0(4) + 4);
2211 if (!p_ptr->free_act)
2213 (void)set_paralyzed(p_ptr->paralyzed + randint0(4) + 4);
2215 if (!p_ptr->resist_chaos)
2217 (void)set_image(p_ptr->image + randint0(250) + 150);
2226 if (lose_all_info())
2227 msg_print(_("あまりの恐怖に全てのことを忘れてしまった!", "You forget everything in your utmost terror!"));
2231 p_ptr->update |= PU_BONUS;
2236 * @brief モンスターの各情報を更新する / This function updates the monster record of the given monster
2237 * @param m_idx 更新するモンスター情報のID
2238 * @param full プレイヤーとの距離更新を行うならばtrue
2241 * This involves extracting the distance to the player (if requested),
2242 * and then checking for visibility (natural, infravision, see-invis,
2243 * telepathy), updating the monster visibility flag, redrawing (or
2244 * erasing) the monster when its visibility changes, and taking note
2245 * of any interesting monster flags (cold-blooded, invisible, etc).
2247 * Note the new "mflag" field which encodes several monster state flags,
2248 * including "view" for when the monster is currently in line of sight,
2249 * and "mark" for when the monster is currently visible via detection.
2251 * The only monster fields that are changed here are "cdis" (the
2252 * distance from the player), "ml" (visible to the player), and
2253 * "mflag" (to maintain the "MFLAG_VIEW" flag).
2255 * Note the special "update_monsters()" function which can be used to
2256 * call this function once for every monster.
2258 * Note the "full" flag which requests that the "cdis" field be updated,
2259 * this is only needed when the monster (or the player) has moved.
2261 * Every time a monster moves, we must call this function for that
2262 * monster, and update the distance, and the visibility. Every time
2263 * the player moves, we must call this function for every monster, and
2264 * update the distance, and the visibility. Whenever the player "state"
2265 * changes in certain ways ("blindness", "infravision", "telepathy",
2266 * and "see invisible"), we must call this function for every monster,
2267 * and update the visibility.
2269 * Routines that change the "illumination" of a grid must also call this
2270 * function for any monster in that grid, since the "visibility" of some
2271 * monsters may be based on the illumination of their grid.
2273 * Note that this function is called once per monster every time the
2274 * player moves. When the player is running, this function is one
2275 * of the primary bottlenecks, along with "update_view()" and the
2276 * "process_monsters()" code, so efficiency is important.
2278 * Note the optimized "inline" version of the "distance()" function.
2280 * A monster is "visible" to the player if (1) it has been detected
2281 * by the player, (2) it is close to the player and the player has
2282 * telepathy, or (3) it is close to the player, and in line of sight
2283 * of the player, and it is "illuminated" by some combination of
2284 * infravision, torch light, or permanent light (invisible monsters
2285 * are only affected by "light" if the player can see invisible).
2287 * Monsters which are not on the current panel may be "visible" to
2288 * the player, and their descriptions will include an "offscreen"
2289 * reference. Currently, offscreen monsters cannot be targetted
2290 * or viewed directly, but old targets will remain set. XXX XXX
2292 * The player can choose to be disturbed by several things, including
2293 * "disturb_move" (monster which is viewable moves in some way), and
2294 * "disturb_near" (monster which is "easily" viewable moves in some
2295 * way). Note that "moves" includes "appears" and "disappears".
2297 void update_mon(MONSTER_IDX m_idx, bool full)
2299 monster_type *m_ptr = &m_list[m_idx];
2301 monster_race *r_ptr = &r_info[m_ptr->r_idx];
2303 bool do_disturb = disturb_move;
2307 /* Current location */
2314 /* Seen by vision */
2317 /* Non-Ninja player in the darkness */
2318 bool in_darkness = (d_info[dungeon_type].flags1 & DF1_DARKNESS) && !p_ptr->see_nocto;
2323 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
2325 if (ap_r_ptr->r_tkills && ap_r_ptr->level >= p_ptr->lev)
2329 /* Compute distance */
2332 /* Distance components */
2333 int dy = (p_ptr->y > fy) ? (p_ptr->y - fy) : (fy - p_ptr->y);
2334 int dx = (p_ptr->x > fx) ? (p_ptr->x - fx) : (fx - p_ptr->x);
2336 /* Approximate distance */
2337 d = (dy > dx) ? (dy + (dx>>1)) : (dx + (dy>>1));
2339 /* Restrict distance */
2340 if (d > 255) d = 255;
2344 /* Save the distance */
2348 /* Extract distance */
2351 /* Extract the distance */
2357 if (m_ptr->mflag2 & (MFLAG2_MARK)) flag = TRUE;
2361 if (d <= (in_darkness ? MAX_SIGHT / 2 : MAX_SIGHT))
2363 if (!in_darkness || (d <= MAX_SIGHT / 4))
2365 if (p_ptr->special_defense & KATA_MUSOU)
2370 if (is_original_ap(m_ptr) && !p_ptr->image)
2372 /* Hack -- Memorize mental flags */
2373 if (r_ptr->flags2 & (RF2_SMART)) r_ptr->r_flags2 |= (RF2_SMART);
2374 if (r_ptr->flags2 & (RF2_STUPID)) r_ptr->r_flags2 |= (RF2_STUPID);
2378 /* Basic telepathy */
2379 /* Snipers get telepathy when they concentrate deeper */
2380 else if (p_ptr->telepathy)
2382 /* Empty mind, no telepathy */
2383 if (r_ptr->flags2 & (RF2_EMPTY_MIND))
2385 /* Memorize flags */
2386 if (is_original_ap(m_ptr) && !p_ptr->image) r_ptr->r_flags2 |= (RF2_EMPTY_MIND);
2389 /* Weird mind, occasional telepathy */
2390 else if (r_ptr->flags2 & (RF2_WEIRD_MIND))
2392 /* One in ten individuals are detectable */
2393 if ((m_idx % 10) == 5)
2398 if (is_original_ap(m_ptr) && !p_ptr->image)
2400 /* Memorize flags */
2401 r_ptr->r_flags2 |= (RF2_WEIRD_MIND);
2403 /* Hack -- Memorize mental flags */
2404 if (r_ptr->flags2 & (RF2_SMART)) r_ptr->r_flags2 |= (RF2_SMART);
2405 if (r_ptr->flags2 & (RF2_STUPID)) r_ptr->r_flags2 |= (RF2_STUPID);
2410 /* Normal mind, allow telepathy */
2416 if (is_original_ap(m_ptr) && !p_ptr->image)
2418 /* Hack -- Memorize mental flags */
2419 if (r_ptr->flags2 & (RF2_SMART)) r_ptr->r_flags2 |= (RF2_SMART);
2420 if (r_ptr->flags2 & (RF2_STUPID)) r_ptr->r_flags2 |= (RF2_STUPID);
2425 /* Magical sensing */
2426 if ((p_ptr->esp_animal) && (r_ptr->flags3 & (RF3_ANIMAL)))
2429 if (is_original_ap(m_ptr) && !p_ptr->image) r_ptr->r_flags3 |= (RF3_ANIMAL);
2432 /* Magical sensing */
2433 if ((p_ptr->esp_undead) && (r_ptr->flags3 & (RF3_UNDEAD)))
2436 if (is_original_ap(m_ptr) && !p_ptr->image) r_ptr->r_flags3 |= (RF3_UNDEAD);
2439 /* Magical sensing */
2440 if ((p_ptr->esp_demon) && (r_ptr->flags3 & (RF3_DEMON)))
2443 if (is_original_ap(m_ptr) && !p_ptr->image) r_ptr->r_flags3 |= (RF3_DEMON);
2446 /* Magical sensing */
2447 if ((p_ptr->esp_orc) && (r_ptr->flags3 & (RF3_ORC)))
2450 if (is_original_ap(m_ptr) && !p_ptr->image) r_ptr->r_flags3 |= (RF3_ORC);
2453 /* Magical sensing */
2454 if ((p_ptr->esp_troll) && (r_ptr->flags3 & (RF3_TROLL)))
2457 if (is_original_ap(m_ptr) && !p_ptr->image) r_ptr->r_flags3 |= (RF3_TROLL);
2460 /* Magical sensing */
2461 if ((p_ptr->esp_giant) && (r_ptr->flags3 & (RF3_GIANT)))
2464 if (is_original_ap(m_ptr) && !p_ptr->image) r_ptr->r_flags3 |= (RF3_GIANT);
2467 /* Magical sensing */
2468 if ((p_ptr->esp_dragon) && (r_ptr->flags3 & (RF3_DRAGON)))
2471 if (is_original_ap(m_ptr) && !p_ptr->image) r_ptr->r_flags3 |= (RF3_DRAGON);
2474 /* Magical sensing */
2475 if ((p_ptr->esp_human) && (r_ptr->flags2 & (RF2_HUMAN)))
2478 if (is_original_ap(m_ptr) && !p_ptr->image) r_ptr->r_flags2 |= (RF2_HUMAN);
2481 /* Magical sensing */
2482 if ((p_ptr->esp_evil) && (r_ptr->flags3 & (RF3_EVIL)))
2485 if (is_original_ap(m_ptr) && !p_ptr->image) r_ptr->r_flags3 |= (RF3_EVIL);
2488 /* Magical sensing */
2489 if ((p_ptr->esp_good) && (r_ptr->flags3 & (RF3_GOOD)))
2492 if (is_original_ap(m_ptr) && !p_ptr->image) r_ptr->r_flags3 |= (RF3_GOOD);
2495 /* Magical sensing */
2496 if ((p_ptr->esp_nonliving) &&
2497 ((r_ptr->flags3 & (RF3_DEMON | RF3_UNDEAD | RF3_NONLIVING)) == RF3_NONLIVING))
2500 if (is_original_ap(m_ptr) && !p_ptr->image) r_ptr->r_flags3 |= (RF3_NONLIVING);
2503 /* Magical sensing */
2504 if ((p_ptr->esp_unique) && (r_ptr->flags1 & (RF1_UNIQUE)))
2507 if (is_original_ap(m_ptr) && !p_ptr->image) r_ptr->r_flags1 |= (RF1_UNIQUE);
2511 /* Normal line of sight, and not blind */
2512 if (player_has_los_bold(fy, fx) && !p_ptr->blind)
2514 bool do_invisible = FALSE;
2515 bool do_cold_blood = FALSE;
2517 /* Snipers can see targets in darkness when they concentrate deeper */
2518 if (p_ptr->concent >= CONCENT_RADAR_THRESHOLD)
2524 /* Use "infravision" */
2525 if (d <= p_ptr->see_infra)
2527 /* Handle "cold blooded" monsters */
2528 if ((r_ptr->flags2 & (RF2_COLD_BLOOD | RF2_AURA_FIRE)) == RF2_COLD_BLOOD)
2531 do_cold_blood = TRUE;
2534 /* Handle "warm blooded" monsters */
2542 /* Use "illumination" */
2543 if (player_can_see_bold(fy, fx))
2545 /* Handle "invisible" monsters */
2546 if (r_ptr->flags2 & (RF2_INVISIBLE))
2549 do_invisible = TRUE;
2559 /* Handle "normal" monsters */
2570 if (is_original_ap(m_ptr) && !p_ptr->image)
2572 /* Memorize flags */
2573 if (do_invisible) r_ptr->r_flags2 |= (RF2_INVISIBLE);
2574 if (do_cold_blood) r_ptr->r_flags2 |= (RF2_COLD_BLOOD);
2581 /* The monster is now visible */
2584 /* It was previously unseen */
2587 /* Mark as visible */
2590 /* Draw the monster */
2593 /* Update health bar as needed */
2594 if (p_ptr->health_who == m_idx) p_ptr->redraw |= (PR_HEALTH);
2595 if (p_ptr->riding == m_idx) p_ptr->redraw |= (PR_UHEALTH);
2597 /* Hack -- Count "fresh" sightings */
2600 if ((m_ptr->ap_r_idx == MON_KAGE) && (r_info[MON_KAGE].r_sights < MAX_SHORT))
2601 r_info[MON_KAGE].r_sights++;
2602 else if (is_original_ap(m_ptr) && (r_ptr->r_sights < MAX_SHORT))
2606 /* Eldritch Horror */
2607 if (r_info[m_ptr->ap_r_idx].flags2 & RF2_ELDRITCH_HORROR)
2609 sanity_blast(m_ptr, FALSE);
2612 /* Disturb on appearance */
2613 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)))
2615 if (disturb_pets || is_hostile(m_ptr))
2621 /* The monster is not visible */
2624 /* It was previously seen */
2627 /* Mark as not visible */
2630 /* Erase the monster */
2633 /* Update health bar as needed */
2634 if (p_ptr->health_who == m_idx) p_ptr->redraw |= (PR_HEALTH);
2635 if (p_ptr->riding == m_idx) p_ptr->redraw |= (PR_UHEALTH);
2637 /* Disturb on disappearance */
2640 if (disturb_pets || is_hostile(m_ptr))
2647 /* The monster is now easily visible */
2651 if (!(m_ptr->mflag & (MFLAG_VIEW)))
2653 /* Mark as easily visible */
2654 m_ptr->mflag |= (MFLAG_VIEW);
2656 /* Disturb on appearance */
2659 if (disturb_pets || is_hostile(m_ptr))
2665 /* The monster is not easily visible */
2669 if (m_ptr->mflag & (MFLAG_VIEW))
2671 /* Mark as not easily visible */
2672 m_ptr->mflag &= ~(MFLAG_VIEW);
2674 /* Disturb on disappearance */
2677 if (disturb_pets || is_hostile(m_ptr))
2686 * @brief 単純に生存している全モンスターの更新処理を行う / This function simply updates all the (non-dead) monsters (see above).
2687 * @param full 距離更新を行うならtrue
2690 void update_monsters(bool full)
2694 /* Update each (live) monster */
2695 for (i = 1; i < m_max; i++)
2697 monster_type *m_ptr = &m_list[i];
2699 /* Skip dead monsters */
2700 if (!m_ptr->r_idx) continue;
2702 /* Update the monster */
2703 update_mon(i, full);
2709 * @brief カメレオンの王の変身対象となるモンスターかどうか判定する / Hack -- the index of the summoning monster
2710 * @param r_idx モンスター種族ID
2711 * @return 対象にできるならtrueを返す
2713 static bool monster_hook_chameleon_lord(MONRACE_IDX r_idx)
2715 monster_race *r_ptr = &r_info[r_idx];
2716 monster_type *m_ptr = &m_list[chameleon_change_m_idx];
2717 monster_race *old_r_ptr = &r_info[m_ptr->r_idx];
2719 if (!(r_ptr->flags1 & (RF1_UNIQUE))) return FALSE;
2720 if (r_ptr->flags7 & (RF7_FRIENDLY | RF7_CHAMELEON)) return FALSE;
2722 if (ABS(r_ptr->level - r_info[MON_CHAMELEON_K].level) > 5) return FALSE;
2724 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))
2727 if (!monster_can_cross_terrain(cave[m_ptr->fy][m_ptr->fx].feat, r_ptr, 0)) return FALSE;
2730 if (!(old_r_ptr->flags7 & RF7_CHAMELEON))
2732 if (monster_has_hostile_align(m_ptr, 0, 0, r_ptr)) return FALSE;
2736 else if (summon_specific_who > 0)
2738 if (monster_has_hostile_align(&m_list[summon_specific_who], 0, 0, r_ptr)) return FALSE;
2745 * @brief カメレオンの変身対象となるモンスターかどうか判定する / Hack -- the index of the summoning monster
2746 * @param r_idx モンスター種族ID
2747 * @return 対象にできるならtrueを返す
2749 static bool monster_hook_chameleon(MONRACE_IDX r_idx)
2751 monster_race *r_ptr = &r_info[r_idx];
2752 monster_type *m_ptr = &m_list[chameleon_change_m_idx];
2753 monster_race *old_r_ptr = &r_info[m_ptr->r_idx];
2755 if (r_ptr->flags1 & (RF1_UNIQUE)) return FALSE;
2756 if (r_ptr->flags2 & RF2_MULTIPLY) return FALSE;
2757 if (r_ptr->flags7 & (RF7_FRIENDLY | RF7_CHAMELEON)) return FALSE;
2759 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))
2762 if (!monster_can_cross_terrain(cave[m_ptr->fy][m_ptr->fx].feat, r_ptr, 0)) return FALSE;
2765 if (!(old_r_ptr->flags7 & RF7_CHAMELEON))
2767 if ((old_r_ptr->flags3 & RF3_GOOD) && !(r_ptr->flags3 & RF3_GOOD)) return FALSE;
2768 if ((old_r_ptr->flags3 & RF3_EVIL) && !(r_ptr->flags3 & RF3_EVIL)) return FALSE;
2769 if (!(old_r_ptr->flags3 & (RF3_GOOD | RF3_EVIL)) && (r_ptr->flags3 & (RF3_GOOD | RF3_EVIL))) return FALSE;
2773 else if (summon_specific_who > 0)
2775 if (monster_has_hostile_align(&m_list[summon_specific_who], 0, 0, r_ptr)) return FALSE;
2778 return (*(get_monster_hook()))(r_idx);
2783 * @param m_idx 変身処理を受けるモンスター情報のID
2784 * @param born 生成時の初変身先指定ならばtrue
2785 * @param r_idx 旧モンスター種族のID
2788 void choose_new_monster(MONSTER_IDX m_idx, bool born, MONRACE_IDX r_idx)
2791 monster_type *m_ptr = &m_list[m_idx];
2792 monster_race *r_ptr;
2793 char old_m_name[80];
2794 bool old_unique = FALSE;
2795 int old_r_idx = m_ptr->r_idx;
2797 if (r_info[m_ptr->r_idx].flags1 & RF1_UNIQUE)
2799 if (old_unique && (r_idx == MON_CHAMELEON)) r_idx = MON_CHAMELEON_K;
2800 r_ptr = &r_info[r_idx];
2802 monster_desc(old_m_name, m_ptr, 0);
2808 chameleon_change_m_idx = m_idx;
2810 get_mon_num_prep(monster_hook_chameleon_lord, NULL);
2812 get_mon_num_prep(monster_hook_chameleon, NULL);
2815 level = r_info[MON_CHAMELEON_K].level;
2816 else if (!dun_level)
2817 level = wilderness[p_ptr->wilderness_y][p_ptr->wilderness_x].level;
2821 if (d_info[dungeon_type].flags1 & DF1_CHAMELEON) level+= 2+randint1(3);
2823 r_idx = get_mon_num(level);
2824 r_ptr = &r_info[r_idx];
2826 chameleon_change_m_idx = 0;
2832 if (is_pet(m_ptr)) check_pets_num_and_align(m_ptr, FALSE);
2834 m_ptr->r_idx = r_idx;
2835 m_ptr->ap_r_idx = r_idx;
2836 update_mon(m_idx, FALSE);
2837 lite_spot(m_ptr->fy, m_ptr->fx);
2839 if ((r_info[old_r_idx].flags7 & (RF7_LITE_MASK | RF7_DARK_MASK)) ||
2840 (r_ptr->flags7 & (RF7_LITE_MASK | RF7_DARK_MASK)))
2841 p_ptr->update |= (PU_MON_LITE);
2843 if (is_pet(m_ptr)) check_pets_num_and_align(m_ptr, TRUE);
2847 /* Sub-alignment of a chameleon */
2848 if (r_ptr->flags3 & (RF3_EVIL | RF3_GOOD))
2850 m_ptr->sub_align = SUB_ALIGN_NEUTRAL;
2851 if (r_ptr->flags3 & RF3_EVIL) m_ptr->sub_align |= SUB_ALIGN_EVIL;
2852 if (r_ptr->flags3 & RF3_GOOD) m_ptr->sub_align |= SUB_ALIGN_GOOD;
2857 if (m_idx == p_ptr->riding)
2860 monster_desc(m_name, m_ptr, 0);
2861 msg_format(_("突然%sが変身した。", "Suddenly, %s transforms!"), old_m_name);
2862 if (!(r_ptr->flags7 & RF7_RIDING))
2863 if (rakuba(0, TRUE)) msg_format(_("地面に落とされた。", "You have fallen from %s."), m_name);
2866 /* Extract the monster base speed */
2867 m_ptr->mspeed = get_mspeed(r_ptr);
2869 oldmaxhp = m_ptr->max_maxhp;
2870 /* Assign maximal hitpoints */
2871 if (r_ptr->flags1 & RF1_FORCE_MAXHP)
2873 m_ptr->max_maxhp = maxroll(r_ptr->hdice, r_ptr->hside);
2877 m_ptr->max_maxhp = damroll(r_ptr->hdice, r_ptr->hside);
2880 /* Monsters have double hitpoints in Nightmare mode */
2881 if (ironman_nightmare)
2883 u32b hp = m_ptr->max_maxhp * 2L;
2884 m_ptr->max_maxhp = (HIT_POINT)MIN(30000, hp);
2887 m_ptr->maxhp = (long)(m_ptr->maxhp * m_ptr->max_maxhp) / oldmaxhp;
2888 if (m_ptr->maxhp < 1) m_ptr->maxhp = 1;
2889 m_ptr->hp = (long)(m_ptr->hp * m_ptr->max_maxhp) / oldmaxhp;
2891 /* reset dealt_damage */
2892 m_ptr->dealt_damage = 0;
2897 * @brief たぬきの変身対象となるモンスターかどうか判定する / Hook for Tanuki
2898 * @param r_idx モンスター種族ID
2899 * @return 対象にできるならtrueを返す
2901 static bool monster_hook_tanuki(MONRACE_IDX r_idx)
2903 monster_race *r_ptr = &r_info[r_idx];
2905 if (r_ptr->flags1 & (RF1_UNIQUE)) return FALSE;
2906 if (r_ptr->flags2 & RF2_MULTIPLY) return FALSE;
2907 if (r_ptr->flags7 & (RF7_FRIENDLY | RF7_CHAMELEON)) return FALSE;
2908 if (r_ptr->flags7 & RF7_AQUATIC) return FALSE;
2910 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))
2913 return (*(get_monster_hook()))(r_idx);
2918 * @brief モンスターの表層IDを設定する / Set initial racial appearance of a monster
2919 * @param r_idx モンスター種族ID
2920 * @return モンスター種族の表層ID
2922 static IDX initial_r_appearance(MONRACE_IDX r_idx)
2924 int attempts = 1000;
2927 DEPTH min = MIN(base_level-5, 50);
2929 if (!(r_info[r_idx].flags7 & RF7_TANUKI))
2932 get_mon_num_prep(monster_hook_tanuki, NULL);
2936 ap_r_idx = get_mon_num(base_level + 10);
2937 if (r_info[ap_r_idx].level >= min) return ap_r_idx;
2945 * @brief モンスターの個体加速を設定する / Get initial monster speed
2946 * @param r_ptr モンスター種族の参照ポインタ
2949 byte get_mspeed(monster_race *r_ptr)
2951 /* Extract the monster base speed */
2952 int mspeed = r_ptr->speed;
2954 /* Hack -- small racial variety */
2955 if (!(r_ptr->flags1 & RF1_UNIQUE) && !p_ptr->inside_arena)
2957 /* Allow some small variation per monster */
2958 int i = SPEED_TO_ENERGY(r_ptr->speed) / (one_in_(4) ? 3 : 10);
2959 if (i) mspeed += rand_spread(0, i);
2962 if (mspeed > 199) mspeed = 199;
2964 return (byte)mspeed;
2969 * @brief モンスターを一体生成する / Attempt to place a monster of the given race at the given location.
2970 * @param who 召喚を行ったモンスターID
2973 * @param r_idx 生成モンスター種族
2974 * @param mode 生成オプション
2977 * To give the player a sporting chance, any monster that appears in
2978 * line-of-sight and is extremely dangerous can be marked as
2979 * "FORCE_SLEEP", which will cause them to be placed with low energy,
2980 * which often (but not always) lets the player move before they do.
2982 * This routine refuses to place out-of-depth "FORCE_DEPTH" monsters.
2984 * XXX XXX XXX Use special "here" and "dead" flags for unique monsters,
2985 * remove old "cur_num" and "max_num" fields.
2987 * XXX XXX XXX Actually, do something similar for artifacts, to simplify
2988 * the "preserve" mode, and to make the "what artifacts" flag more useful.
2990 * This is the only function which may place a monster in the dungeon,
2991 * except for the savefile loading code.
2993 static bool place_monster_one(MONSTER_IDX who, POSITION y, POSITION x, MONRACE_IDX r_idx, BIT_FLAGS mode)
2995 /* Access the location */
2996 cave_type *c_ptr = &cave[y][x];
2997 monster_type *m_ptr;
2998 monster_race *r_ptr = &r_info[r_idx];
2999 cptr name = (r_name + r_ptr->name);
3003 /* DO NOT PLACE A MONSTER IN THE SMALL SCALE WILDERNESS !!! */
3004 if (p_ptr->wild_mode) return FALSE;
3006 /* Verify location */
3007 if (!in_bounds(y, x)) return (FALSE);
3010 if (!r_idx) return (FALSE);
3013 if (!r_ptr->name) return (FALSE);
3015 if (!(mode & PM_IGNORE_TERRAIN))
3017 /* Not on the Pattern */
3018 if (pattern_tile(y, x)) return FALSE;
3020 /* Require empty space (if not ghostly) */
3021 if (!monster_can_enter(y, x, r_ptr, 0)) return FALSE;
3024 if (!p_ptr->inside_battle)
3026 /* Hack -- "unique" monsters must be "unique" */
3027 if (((r_ptr->flags1 & (RF1_UNIQUE)) ||
3028 (r_ptr->flags7 & (RF7_NAZGUL))) &&
3029 (r_ptr->cur_num >= r_ptr->max_num))
3035 if ((r_ptr->flags7 & (RF7_UNIQUE2)) &&
3036 (r_ptr->cur_num >= 1))
3041 if (r_idx == MON_BANORLUPART)
3043 if (r_info[MON_BANOR].cur_num > 0) return FALSE;
3044 if (r_info[MON_LUPART].cur_num > 0) return FALSE;
3047 /* Depth monsters may NOT be created out of depth, unless in Nightmare mode */
3048 if ((r_ptr->flags1 & (RF1_FORCE_DEPTH)) && (dun_level < r_ptr->level) &&
3049 (!ironman_nightmare || (r_ptr->flags1 & (RF1_QUESTOR))))
3056 if (quest_number(dun_level))
3058 int hoge = quest_number(dun_level);
3059 if ((quest[hoge].type == QUEST_TYPE_KILL_LEVEL) || (quest[hoge].type == QUEST_TYPE_RANDOM))
3061 if(r_idx == quest[hoge].r_idx)
3063 int number_mon, i2, j2;
3066 /* Count all quest monsters */
3067 for (i2 = 0; i2 < cur_wid; ++i2)
3068 for (j2 = 0; j2 < cur_hgt; j2++)
3069 if (cave[j2][i2].m_idx > 0)
3070 if (m_list[cave[j2][i2].m_idx].r_idx == quest[hoge].r_idx)
3072 if(number_mon + quest[hoge].cur_num >= quest[hoge].max_num)
3078 if (is_glyph_grid(c_ptr))
3080 if (randint1(BREAK_GLYPH) < (r_ptr->level+20))
3082 /* Describe observable breakage */
3083 if (c_ptr->info & CAVE_MARK)
3085 msg_print(_("守りのルーンが壊れた!", "The rune of protection is broken!"));
3088 /* Forget the rune */
3089 c_ptr->info &= ~(CAVE_MARK);
3091 /* Break the rune */
3092 c_ptr->info &= ~(CAVE_OBJECT);
3101 msg_format_wizard(CHEAT_MONSTER, _("%s(Lv%d)を生成しました。", "%s(Lv%d) was generated."), name, r_ptr->level);
3103 if ((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags7 & RF7_NAZGUL) || (r_ptr->level < 10)) mode &= ~PM_KAGE;
3105 /* Make a new monster */
3106 c_ptr->m_idx = m_pop();
3107 hack_m_idx_ii = c_ptr->m_idx;
3109 /* Mega-Hack -- catch "failure" */
3110 if (!c_ptr->m_idx) return (FALSE);
3113 /* Get a new monster record */
3114 m_ptr = &m_list[c_ptr->m_idx];
3117 m_ptr->r_idx = r_idx;
3118 m_ptr->ap_r_idx = initial_r_appearance(r_idx);
3124 /* Hack -- Appearance transfer */
3125 if ((mode & PM_MULTIPLY) && (who > 0) && !is_original_ap(&m_list[who]))
3127 m_ptr->ap_r_idx = m_list[who].ap_r_idx;
3129 /* Hack -- Shadower spawns Shadower */
3130 if (m_list[who].mflag2 & MFLAG2_KAGE) m_ptr->mflag2 |= MFLAG2_KAGE;
3133 /* Sub-alignment of a monster */
3134 if ((who > 0) && !(r_ptr->flags3 & (RF3_EVIL | RF3_GOOD)))
3135 m_ptr->sub_align = m_list[who].sub_align;
3138 m_ptr->sub_align = SUB_ALIGN_NEUTRAL;
3139 if (r_ptr->flags3 & RF3_EVIL) m_ptr->sub_align |= SUB_ALIGN_EVIL;
3140 if (r_ptr->flags3 & RF3_GOOD) m_ptr->sub_align |= SUB_ALIGN_GOOD;
3143 /* Place the monster at the location */
3148 /* No "timed status" yet */
3149 for (cmi = 0; cmi < MAX_MTIMED; cmi++) m_ptr->mtimed[cmi] = 0;
3151 /* Unknown distance */
3154 reset_target(m_ptr);
3156 m_ptr->nickname = 0;
3161 /* Your pet summons its pet. */
3162 if (who > 0 && is_pet(&m_list[who]))
3164 mode |= PM_FORCE_PET;
3165 m_ptr->parent_m_idx = who;
3169 m_ptr->parent_m_idx = 0;
3172 if (r_ptr->flags7 & RF7_CHAMELEON)
3174 choose_new_monster(c_ptr->m_idx, TRUE, 0);
3175 r_ptr = &r_info[m_ptr->r_idx];
3176 m_ptr->mflag2 |= MFLAG2_CHAMELEON;
3178 /* Hack - Set sub_align to neutral when the Chameleon Lord is generated as "GUARDIAN" */
3179 if ((r_ptr->flags1 & RF1_UNIQUE) && (who <= 0))
3180 m_ptr->sub_align = SUB_ALIGN_NEUTRAL;
3182 else if ((mode & PM_KAGE) && !(mode & PM_FORCE_PET))
3184 m_ptr->ap_r_idx = MON_KAGE;
3185 m_ptr->mflag2 |= MFLAG2_KAGE;
3188 if (mode & PM_NO_PET) m_ptr->mflag2 |= MFLAG2_NOPET;
3194 if (mode & PM_FORCE_PET)
3199 else if ((r_ptr->flags7 & RF7_FRIENDLY) ||
3200 (mode & PM_FORCE_FRIENDLY) || is_friendly_idx(who))
3202 if (!monster_has_hostile_align(NULL, 0, -1, r_ptr)) set_friendly(m_ptr);
3205 /* Assume no sleeping */
3206 m_ptr->mtimed[MTIMED_CSLEEP] = 0;
3208 /* Enforce sleeping if needed */
3209 if ((mode & PM_ALLOW_SLEEP) && r_ptr->sleep && !ironman_nightmare)
3211 int val = r_ptr->sleep;
3212 (void)set_monster_csleep(c_ptr->m_idx, (val * 2) + randint1(val * 10));
3215 /* Assign maximal hitpoints */
3216 if (r_ptr->flags1 & RF1_FORCE_MAXHP)
3218 m_ptr->max_maxhp = maxroll(r_ptr->hdice, r_ptr->hside);
3222 m_ptr->max_maxhp = damroll(r_ptr->hdice, r_ptr->hside);
3225 /* Monsters have double hitpoints in Nightmare mode */
3226 if (ironman_nightmare)
3228 u32b hp = m_ptr->max_maxhp * 2L;
3230 m_ptr->max_maxhp = (HIT_POINT)MIN(30000, hp);
3233 m_ptr->maxhp = m_ptr->max_maxhp;
3235 /* And start out fully healthy */
3236 if (m_ptr->r_idx == MON_WOUNDED_BEAR)
3237 m_ptr->hp = m_ptr->maxhp / 2;
3238 else m_ptr->hp = m_ptr->maxhp;
3241 /* dealt damage is 0 at initial*/
3242 m_ptr->dealt_damage = 0;
3245 /* Extract the monster base speed */
3246 m_ptr->mspeed = get_mspeed(r_ptr);
3248 if (mode & PM_HASTE) (void)set_monster_fast(c_ptr->m_idx, 100);
3250 /* Give a random starting energy */
3251 if (!ironman_nightmare)
3253 m_ptr->energy_need = ENERGY_NEED() - (s16b)randint0(100);
3257 /* Nightmare monsters are more prepared */
3258 m_ptr->energy_need = ENERGY_NEED() - (s16b)randint0(100) * 2;
3261 /* Force monster to wait for player, unless in Nightmare mode */
3262 if ((r_ptr->flags1 & RF1_FORCE_SLEEP) && !ironman_nightmare)
3264 /* Monster is still being nice */
3265 m_ptr->mflag |= (MFLAG_NICE);
3267 /* Must repair monsters */
3268 repair_monsters = TRUE;
3271 /* Hack -- see "process_monsters()" */
3272 if (c_ptr->m_idx < hack_m_idx)
3274 /* Monster is still being born */
3275 m_ptr->mflag |= (MFLAG_BORN);
3279 if (r_ptr->flags7 & RF7_SELF_LD_MASK)
3280 p_ptr->update |= (PU_MON_LITE);
3281 else if ((r_ptr->flags7 & RF7_HAS_LD_MASK) && !MON_CSLEEP(m_ptr))
3282 p_ptr->update |= (PU_MON_LITE);
3284 /* Update the monster */
3285 update_mon(c_ptr->m_idx, TRUE);
3288 /* Count the monsters on the level */
3289 real_r_ptr(m_ptr)->cur_num++;
3292 * Memorize location of the unique monster in saved floors.
3293 * A unique monster move from old saved floor.
3295 if (character_dungeon &&
3296 ((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags7 & RF7_NAZGUL)))
3297 real_r_ptr(m_ptr)->floor_id = p_ptr->floor_id;
3299 /* Hack -- Count the number of "reproducers" */
3300 if (r_ptr->flags2 & RF2_MULTIPLY) num_repro++;
3302 /* Hack -- Notice new multi-hued monsters */
3304 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
3305 if (ap_r_ptr->flags1 & (RF1_ATTR_MULTI | RF1_SHAPECHANGER))
3306 shimmer_monsters = TRUE;
3309 if (p_ptr->warning && character_dungeon)
3311 if (r_ptr->flags1 & RF1_UNIQUE)
3315 char o_name[MAX_NLEN];
3317 if (r_ptr->level > p_ptr->lev + 30)
3318 color = _("黒く", "black");
3319 else if (r_ptr->level > p_ptr->lev + 15)
3320 color = _("紫色に", "purple");
3321 else if (r_ptr->level > p_ptr->lev + 5)
3322 color = _("ルビー色に", "deep red");
3323 else if (r_ptr->level > p_ptr->lev - 5)
3324 color = _("赤く", "red");
3325 else if (r_ptr->level > p_ptr->lev - 15)
3326 color = _("ピンク色に", "pink");
3328 color = _("白く", "white");
3330 o_ptr = choose_warning_item();
3333 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
3334 msg_format(_("%sは%s光った。", "%s glows %s."), o_name, color);
3338 msg_format(_("%s光る物が頭に浮かんだ。", "An %s image forms in your mind."), color);
3343 if (is_explosive_rune_grid(c_ptr))
3345 /* Break the ward */
3346 if (randint1(BREAK_MINOR_GLYPH) > r_ptr->level)
3348 /* Describe observable breakage */
3349 if (c_ptr->info & CAVE_MARK)
3351 msg_print(_("ルーンが爆発した!", "The rune explodes!"));
3352 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);
3357 msg_print(_("爆発のルーンは解除された。", "An explosive rune was disarmed."));
3360 /* Forget the rune */
3361 c_ptr->info &= ~(CAVE_MARK);
3363 /* Break the rune */
3364 c_ptr->info &= ~(CAVE_OBJECT);
3377 #define MON_SCAT_MAXD 10 /*!< mon_scatter()関数によるモンスター配置で許される中心からの最大距離 */
3380 * @brief モンスター1体を目標地点に可能ながり近い位置に生成する / improved version of scatter() for place monster
3381 * @param r_idx 生成モンスター種族
3382 * @param yp 結果生成位置y座標
3383 * @param xp 結果生成位置x座標
3384 * @param y 中心生成位置y座標
3385 * @param x 中心生成位置x座標
3386 * @param max_dist 生成位置の最大半径
3390 static bool mon_scatter(MONRACE_IDX r_idx, POSITION *yp, POSITION *xp, POSITION y, POSITION x, POSITION max_dist)
3392 int place_x[MON_SCAT_MAXD];
3393 int place_y[MON_SCAT_MAXD];
3394 int num[MON_SCAT_MAXD];
3398 if (max_dist >= MON_SCAT_MAXD)
3401 for (i = 0; i < MON_SCAT_MAXD; i++)
3404 for (nx = x - max_dist; nx <= x + max_dist; nx++)
3406 for (ny = y - max_dist; ny <= y + max_dist; ny++)
3408 /* Ignore annoying locations */
3409 if (!in_bounds(ny, nx)) continue;
3411 /* Require "line of projection" */
3412 if (!projectable(y, x, ny, nx)) continue;
3416 monster_race *r_ptr = &r_info[r_idx];
3418 /* Require empty space (if not ghostly) */
3419 if (!monster_can_enter(ny, nx, r_ptr, 0))
3424 /* Walls and Monsters block flow */
3425 if (!cave_empty_bold2(ny, nx)) continue;
3427 /* ... nor on the Pattern */
3428 if (pattern_tile(ny, nx)) continue;
3431 i = distance(y, x, ny, nx);
3439 if (one_in_(num[i]))
3448 while (i < MON_SCAT_MAXD && 0 == num[i])
3450 if (i >= MON_SCAT_MAXD)
3460 * @brief モンスターを目標地点に集団生成する / Attempt to place a "group" of monsters around the given location
3461 * @param who 召喚主のモンスター情報ID
3462 * @param y 中心生成位置y座標
3463 * @param x 中心生成位置x座標
3464 * @param r_idx 生成モンスター種族
3465 * @param mode 生成オプション
3468 static bool place_monster_group(IDX who, POSITION y, POSITION x, MONRACE_IDX r_idx, BIT_FLAGS mode)
3470 monster_race *r_ptr = &r_info[r_idx];
3473 int total = 0, extra = 0;
3477 POSITION hack_y[GROUP_MAX];
3478 POSITION hack_x[GROUP_MAX];
3481 /* Pick a group size */
3482 total = randint1(10);
3484 /* Hard monsters, small groups */
3485 if (r_ptr->level > dun_level)
3487 extra = r_ptr->level - dun_level;
3488 extra = 0 - randint1(extra);
3491 /* Easy monsters, large groups */
3492 else if (r_ptr->level < dun_level)
3494 extra = dun_level - r_ptr->level;
3495 extra = randint1(extra);
3498 /* Hack -- limit group reduction */
3499 if (extra > 9) extra = 9;
3501 /* Modify the group size */
3505 if (total < 1) total = 1;
3508 if (total > GROUP_MAX) total = GROUP_MAX;
3511 /* Start on the monster */
3516 /* Puddle monsters, breadth first, up to total */
3517 for (n = 0; (n < hack_n) && (hack_n < total); n++)
3519 /* Grab the location */
3520 POSITION hx = hack_x[n];
3521 POSITION hy = hack_y[n];
3523 /* Check each direction, up to total */
3524 for (i = 0; (i < 8) && (hack_n < total); i++)
3528 scatter(&my, &mx, hy, hx, 4, 0);
3530 /* Walls and Monsters block flow */
3531 if (!cave_empty_bold2(my, mx)) continue;
3533 /* Attempt to place another monster */
3534 if (place_monster_one(who, my, mx, r_idx, mode))
3536 /* Add it to the "hack" set */
3537 hack_y[hack_n] = my;
3538 hack_x[hack_n] = mx;
3550 * @var place_monster_idx
3551 * @brief 護衛対象となるモンスター種族IDを渡すグローバル変数 / Hack -- help pick an escort type
3552 * @todo 関数ポインタの都合を配慮しながら、グローバル変数place_monster_idxを除去し、関数引数化する
3554 static IDX place_monster_idx = 0;
3557 * @var place_monster_m_idx
3558 * @brief 護衛対象となるモンスターIDを渡すグローバル変数 / Hack -- help pick an escort type
3559 * @todo 関数ポインタの都合を配慮しながら、グローバル変数place_monster_m_idxを除去し、関数引数化する
3561 static IDX place_monster_m_idx = 0;
3564 * @brief モンスター種族が召喚主の護衛となれるかどうかをチェックする / Hack -- help pick an escort type
3565 * @param r_idx チェックするモンスター種族のID
3566 * @return 護衛にできるならばtrue
3568 static bool place_monster_can_escort(MONRACE_IDX r_idx)
3570 monster_race *r_ptr = &r_info[place_monster_idx];
3571 monster_type *m_ptr = &m_list[place_monster_m_idx];
3573 monster_race *z_ptr = &r_info[r_idx];
3575 /* Hack - Escorts have to have the same dungeon flag */
3576 if (mon_hook_dungeon(place_monster_idx) != mon_hook_dungeon(r_idx)) return (FALSE);
3578 /* Require similar "race" */
3579 if (z_ptr->d_char != r_ptr->d_char) return (FALSE);
3581 /* Skip more advanced monsters */
3582 if (z_ptr->level > r_ptr->level) return (FALSE);
3584 /* Skip unique monsters */
3585 if (z_ptr->flags1 & RF1_UNIQUE) return (FALSE);
3587 /* Paranoia -- Skip identical monsters */
3588 if (place_monster_idx == r_idx) return (FALSE);
3590 /* Skip different alignment */
3591 if (monster_has_hostile_align(m_ptr, 0, 0, z_ptr)) return FALSE;
3593 if (r_ptr->flags7 & RF7_FRIENDLY)
3595 if (monster_has_hostile_align(NULL, 1, -1, z_ptr)) return FALSE;
3598 if ((r_ptr->flags7 & RF7_CHAMELEON) && !(z_ptr->flags7 & RF7_CHAMELEON))
3607 * @brief 一般的なモンスター生成処理のサブルーチン / Attempt to place a monster of the given race at the given location
3608 * @param who 召喚主のモンスター情報ID
3611 * @param r_idx 生成するモンスターの種族ID
3612 * @param mode 生成オプション
3613 * @return 生成に成功したらtrue
3615 * Note that certain monsters are now marked as requiring "friends".
3616 * These monsters, if successfully placed, and if the "grp" parameter
3617 * is TRUE, will be surrounded by a "group" of identical monsters.
3619 * Note that certain monsters are now marked as requiring an "escort",
3620 * which is a collection of monsters with similar "race" but lower level.
3622 * Some monsters induce a fake "group" flag on their escorts.
3624 * Note the "bizarre" use of non-recursion to prevent annoying output
3625 * when running a code profiler.
3627 * Note the use of the new "monster allocation table" code to restrict
3628 * the "get_mon_num()" function to "legal" escort types.
3630 bool place_monster_aux(MONSTER_IDX who, POSITION y, POSITION x, MONRACE_IDX r_idx, BIT_FLAGS mode)
3633 monster_race *r_ptr = &r_info[r_idx];
3635 if (!(mode & PM_NO_KAGE) && one_in_(333))
3638 /* Place one monster, or fail */
3639 if (!place_monster_one(who, y, x, r_idx, mode)) return (FALSE);
3641 /* Require the "group" flag */
3642 if (!(mode & PM_ALLOW_GROUP)) return (TRUE);
3644 place_monster_m_idx = hack_m_idx_ii;
3647 for(i = 0; i < 6; i++)
3649 if(!r_ptr->reinforce_id[i]) break;
3650 n = damroll(r_ptr->reinforce_dd[i], r_ptr->reinforce_ds[i]);
3651 for(j = 0; j < n; j++)
3653 POSITION nx, ny, d = 7;
3654 scatter(&ny, &nx, y, x, d, 0);
3655 (void)place_monster_one(place_monster_m_idx, ny, nx, r_ptr->reinforce_id[i], mode);
3659 /* Friends for certain monsters */
3660 if (r_ptr->flags1 & (RF1_FRIENDS))
3662 /* Attempt to place a group */
3663 (void)place_monster_group(who, y, x, r_idx, mode);
3666 /* Escorts for certain monsters */
3667 if (r_ptr->flags1 & (RF1_ESCORT))
3669 /* Set the escort index */
3670 place_monster_idx = r_idx;
3672 /* Try to place several "escorts" */
3673 for (i = 0; i < 32; i++)
3675 POSITION nx, ny, d = 3;
3678 /* Pick a location */
3679 scatter(&ny, &nx, y, x, d, 0);
3681 /* Require empty grids */
3682 if (!cave_empty_bold2(ny, nx)) continue;
3684 /* Prepare allocation table */
3685 get_mon_num_prep(place_monster_can_escort, get_monster_hook2(ny, nx));
3687 /* Pick a random race */
3688 z = get_mon_num(r_ptr->level);
3690 /* Handle failure */
3693 /* Place a single escort */
3694 (void)place_monster_one(place_monster_m_idx, ny, nx, z, mode);
3696 /* Place a "group" of escorts if needed */
3697 if ((r_info[z].flags1 & RF1_FRIENDS) ||
3698 (r_ptr->flags1 & RF1_ESCORTS))
3700 /* Place a group of monsters */
3701 (void)place_monster_group(place_monster_m_idx, ny, nx, z, mode);
3711 * @brief 一般的なモンスター生成処理のメインルーチン / Attempt to place a monster of the given race at the given location
3714 * @param mode 生成オプション
3715 * @return 生成に成功したらtrue
3717 bool place_monster(POSITION y, POSITION x, BIT_FLAGS mode)
3721 /* Prepare allocation table */
3722 get_mon_num_prep(get_monster_hook(), get_monster_hook2(y, x));
3724 /* Pick a monster */
3725 r_idx = get_mon_num(monster_level);
3727 /* Handle failure */
3728 if (!r_idx) return (FALSE);
3730 /* Attempt to place the monster */
3731 if (place_monster_aux(0, y, x, r_idx, mode)) return (TRUE);
3738 #ifdef MONSTER_HORDES
3741 * @brief 指定地点に1種類のモンスター種族による群れを生成する
3744 * @return 生成に成功したらtrue
3746 bool alloc_horde(POSITION y, POSITION x)
3748 monster_race *r_ptr = NULL;
3749 MONRACE_IDX r_idx = 0;
3751 int attempts = 1000;
3755 /* Prepare allocation table */
3756 get_mon_num_prep(get_monster_hook(), get_monster_hook2(y, x));
3760 /* Pick a monster */
3761 r_idx = get_mon_num(monster_level);
3763 /* Handle failure */
3764 if (!r_idx) return (FALSE);
3766 r_ptr = &r_info[r_idx];
3768 if (r_ptr->flags1 & RF1_UNIQUE) continue;
3770 if (r_idx == MON_HAGURE) continue;
3773 if (attempts < 1) return FALSE;
3779 /* Attempt to place the monster */
3780 if (place_monster_aux(0, y, x, r_idx, 0L)) break;
3783 if (attempts < 1) return FALSE;
3785 m_idx = cave[y][x].m_idx;
3787 if (m_list[m_idx].mflag2 & MFLAG2_CHAMELEON) r_ptr = &r_info[m_list[m_idx].r_idx];
3788 summon_kin_type = r_ptr->d_char;
3790 for (attempts = randint1(10) + 5; attempts; attempts--)
3792 scatter(&cy, &cx, y, x, 5, 0);
3794 (void)summon_specific(m_idx, cy, cx, dun_level + 5, SUMMON_KIN, PM_ALLOW_GROUP);
3803 #endif /* MONSTER_HORDES */
3807 * @brief ダンジョンの主生成を試みる / Put the Guardian
3808 * @param def_val 現在の主の生成状態
3809 * @return 生成に成功したらtrue
3811 bool alloc_guardian(bool def_val)
3813 MONRACE_IDX guardian = d_info[dungeon_type].final_guardian;
3815 if (guardian && (d_info[dungeon_type].maxdepth == dun_level) && (r_info[guardian].cur_num < r_info[guardian].max_num))
3819 int try_count = 4000;
3821 /* Find a good position */
3824 /* Get a random spot */
3825 oy = randint1(cur_hgt - 4) + 2;
3826 ox = randint1(cur_wid - 4) + 2;
3828 /* Is it a good spot ? */
3829 if (cave_empty_bold2(oy, ox) && monster_can_cross_terrain(cave[oy][ox].feat, &r_info[guardian], 0))
3831 /* Place the guardian */
3832 if (place_monster_aux(0, oy, ox, guardian, (PM_ALLOW_GROUP | PM_NO_KAGE | PM_NO_PET))) return TRUE;
3835 /* One less try count */
3847 * @brief ダンジョンの初期配置モンスターを生成1回生成する / Attempt to allocate a random monster in the dungeon.
3848 * @param dis プレイヤーから離れるべき最低距離
3849 * @param mode 生成オプション
3850 * @return 生成に成功したらtrue
3852 * Place the monster at least "dis" distance from the player.
3853 * Use "slp" to choose the initial "sleep" status
3854 * Use "monster_level" for the monster level
3856 bool alloc_monster(POSITION dis, BIT_FLAGS mode)
3859 int attempts_left = 10000;
3861 /* Put the Guardian */
3862 if (alloc_guardian(FALSE)) return TRUE;
3864 /* Find a legal, distant, unoccupied, space */
3865 while (attempts_left--)
3867 /* Pick a location */
3868 y = randint0(cur_hgt);
3869 x = randint0(cur_wid);
3871 /* Require empty floor grid (was "naked") */
3874 if (!cave_empty_bold2(y, x)) continue;
3878 if (!cave_empty_bold(y, x)) continue;
3881 /* Accept far away grids */
3882 if (distance(y, x, p_ptr->y, p_ptr->x) > dis) break;
3887 if (cheat_xtra || cheat_hear)
3889 msg_print(_("警告!新たなモンスターを配置できません。小さい階ですか?", "Warning! Could not allocate a new monster. Small level?"));
3896 #ifdef MONSTER_HORDES
3897 if (randint1(5000) <= dun_level)
3899 if (alloc_horde(y, x))
3901 if (cheat_hear) msg_format(_("モンスターの大群(%c)", "Monster horde (%c)."), summon_kin_type);
3907 #endif /* MONSTER_HORDES */
3909 /* Attempt to place the monster, allow groups */
3910 if (place_monster(y, x, (mode | PM_ALLOW_GROUP))) return (TRUE);
3912 #ifdef MONSTER_HORDES
3914 #endif /* MONSTER_HORDES */
3922 * @brief モンスターが召喚の基本条件に合っているかをチェックする / Hack -- help decide if a monster race is "okay" to summon
3923 * @param r_idx チェックするモンスター種族ID
3924 * @return 召喚対象にできるならばTRUE
3926 static bool summon_specific_okay(MONRACE_IDX r_idx)
3928 monster_race *r_ptr = &r_info[r_idx];
3930 /* Hack - Only summon dungeon monsters */
3931 if (!mon_hook_dungeon(r_idx)) return (FALSE);
3933 /* Hack -- identify the summoning monster */
3934 if (summon_specific_who > 0)
3936 monster_type *m_ptr = &m_list[summon_specific_who];
3938 /* Do not summon enemies */
3940 /* Friendly vs. opposite aligned normal or pet */
3941 if (monster_has_hostile_align(m_ptr, 0, 0, r_ptr)) return FALSE;
3943 /* Use the player's alignment */
3944 else if (summon_specific_who < 0)
3946 /* Do not summon enemies of the pets */
3947 if (monster_has_hostile_align(NULL, 10, -10, r_ptr))
3949 if (!one_in_(ABS(p_ptr->align) / 2 + 1)) return FALSE;
3953 if (!summon_unique_okay && ((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags7 & RF7_NAZGUL))) return FALSE;
3955 /* Hack -- no specific type specified */
3956 if (!summon_specific_type) return (TRUE);
3958 if ((summon_specific_who < 0) &&
3959 ((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags7 & RF7_NAZGUL)) &&
3960 monster_has_hostile_align(NULL, 10, -10, r_ptr))
3963 if ((r_ptr->flags7 & RF7_CHAMELEON) && (d_info[dungeon_type].flags1 & DF1_CHAMELEON)) return TRUE;
3965 return (summon_specific_aux(r_idx));
3970 * @brief モンスターを召喚により配置する / Place a monster (of the specified "type") near the given location. Return TRUE if a monster was actually summoned.
3971 * @param who 召喚主のモンスター情報ID
3976 * @param mode 生成オプション
3977 * @return 召喚できたらtrueを返す
3980 * We will attempt to place the monster up to 10 times before giving up.
3982 * Note: SUMMON_UNIQUE and SUMMON_AMBERITES will summon Unique's
3983 * Note: SUMMON_HI_UNDEAD and SUMMON_HI_DRAGON may summon Unique's
3984 * Note: None of the other summon codes will ever summon Unique's.
3986 * This function has been changed. We now take the "monster level"
3987 * of the summoning monster as a parameter, and use that, along with
3988 * the current dungeon level, to help determine the level of the
3989 * desired monster. Note that this is an upper bound, and also
3990 * tends to "prefer" monsters of that level. Currently, we use
3991 * the average of the dungeon and monster levels, and then add
3992 * five to allow slight increases in monster power.
3994 * Note that we use the new "monster allocation table" creation code
3995 * to restrict the "get_mon_num()" function to the set of "legal"
3996 * monsters, making this function much faster and more reliable.
3998 * Note that this function may not succeed, though this is very rare.
4000 bool summon_specific(MONSTER_IDX who, POSITION y1, POSITION x1, DEPTH lev, int type, BIT_FLAGS mode)
4005 if (p_ptr->inside_arena) return (FALSE);
4007 if (!mon_scatter(0, &y, &x, y1, x1, 2)) return FALSE;
4009 /* Save the summoner */
4010 summon_specific_who = who;
4012 /* Save the "summon" type */
4013 summon_specific_type = type;
4015 summon_unique_okay = (mode & PM_ALLOW_UNIQUE) ? TRUE : FALSE;
4017 /* Prepare allocation table */
4018 get_mon_num_prep(summon_specific_okay, get_monster_hook2(y, x));
4020 /* Pick a monster, using the level calculation */
4021 r_idx = get_mon_num((dun_level + lev) / 2 + 5);
4023 /* Handle failure */
4026 summon_specific_type = 0;
4030 if ((type == SUMMON_BLUE_HORROR) || (type == SUMMON_DAWN)) mode |= PM_NO_KAGE;
4032 /* Attempt to place the monster (awake, allow groups) */
4033 if (!place_monster_aux(who, y, x, r_idx, mode))
4035 summon_specific_type = 0;
4039 summon_specific_type = 0;
4041 sound(SOUND_SUMMON);
4047 * @brief 特定モンスター種族を召喚により生成する / A "dangerous" function, creates a pet of the specified type
4048 * @param who 召喚主のモンスター情報ID
4051 * @param r_idx 生成するモンスター種族ID
4052 * @param mode 生成オプション
4053 * @return 召喚できたらtrueを返す
4055 bool summon_named_creature (MONSTER_IDX who, POSITION oy, POSITION ox, MONRACE_IDX r_idx, BIT_FLAGS mode)
4060 /* if (!r_idx) return; */
4062 /* Prevent illegal monsters */
4063 if (r_idx >= max_r_idx) return FALSE;
4065 if (p_ptr->inside_arena) return FALSE;
4067 if (!mon_scatter(r_idx, &y, &x, oy, ox, 2)) return FALSE;
4069 /* Place it (allow groups) */
4070 return place_monster_aux(who, y, x, r_idx, (mode | PM_NO_KAGE));
4075 * @brief モンスターを増殖生成する / Let the given monster attempt to reproduce.
4076 * @param m_idx 増殖するモンスター情報ID
4077 * @param clone クローン・モンスター処理ならばtrue
4078 * @param mode 生成オプション
4079 * @return 生成できたらtrueを返す
4081 * Note that "reproduction" REQUIRES empty space.
4083 bool multiply_monster(MONSTER_IDX m_idx, bool clone, BIT_FLAGS mode)
4085 monster_type *m_ptr = &m_list[m_idx];
4089 if (!mon_scatter(m_ptr->r_idx, &y, &x, m_ptr->fy, m_ptr->fx, 1))
4092 if (m_ptr->mflag2 & MFLAG2_NOPET) mode |= PM_NO_PET;
4094 /* Create a new monster (awake, no groups) */
4095 if (!place_monster_aux(m_idx, y, x, m_ptr->r_idx, (mode | PM_NO_KAGE | PM_MULTIPLY)))
4098 /* Hack -- Transfer "clone" flag */
4099 if (clone || (m_ptr->smart & SM_CLONED))
4101 m_list[hack_m_idx_ii].smart |= SM_CLONED;
4102 m_list[hack_m_idx_ii].mflag2 |= MFLAG2_NOPET;
4111 * @brief ダメージを受けたモンスターの様子を記述する / Dump a message describing a monster's reaction to damage
4112 * @param m_idx モンスター情報ID
4113 * @param dam 与えたダメージ
4116 * Technically should attempt to treat "Beholder"'s as jelly's
4118 void message_pain(MONSTER_IDX m_idx, HIT_POINT dam)
4120 long oldhp, newhp, tmp;
4123 monster_type *m_ptr = &m_list[m_idx];
4124 monster_race *r_ptr = &r_info[m_ptr->r_idx];
4128 /* Get the monster name */
4129 monster_desc(m_name, m_ptr, 0);
4131 if(dam == 0) // Notice non-damage
4133 msg_format(_("%^sはダメージを受けていない。", "%^s is unharmed."), m_name);
4137 /* Note -- subtle fix -CFT */
4138 newhp = (long)(m_ptr->hp);
4139 oldhp = newhp + (long)(dam);
4140 tmp = (newhp * 100L) / oldhp;
4141 percentage = (int)(tmp);
4143 if(my_strchr(",ejmvwQ", r_ptr->d_char)) // Mushrooms, Eyes, Jellies, Molds, Vortices, Worms, Quylthulgs
4146 if(percentage > 95) msg_format("%^sはほとんど気にとめていない。", m_name);
4147 else if(percentage > 75) msg_format("%^sはしり込みした。", m_name);
4148 else if(percentage > 50) msg_format("%^sは縮こまった。", m_name);
4149 else if(percentage > 35) msg_format("%^sは痛みに震えた。", m_name);
4150 else if(percentage > 20) msg_format("%^sは身もだえした。", m_name);
4151 else if(percentage > 10) msg_format("%^sは苦痛で身もだえした。", m_name);
4152 else msg_format("%^sはぐにゃぐにゃと痙攣した。", m_name);
4154 if(percentage > 95) msg_format("%^s barely notices.", m_name);
4155 else if(percentage > 75) msg_format("%^s flinches.", m_name);
4156 else if(percentage > 50) msg_format("%^s squelches.", m_name);
4157 else if(percentage > 35) msg_format("%^s quivers in pain.", m_name);
4158 else if(percentage > 20) msg_format("%^s writhes about.", m_name);
4159 else if(percentage > 10) msg_format("%^s writhes in agony.", m_name);
4160 else msg_format("%^s jerks limply.", m_name);
4164 else if(my_strchr("l", r_ptr->d_char)) // Fish
4167 if(percentage > 95) msg_format("%^sはほとんど気にとめていない。", m_name);
4168 else if(percentage > 75) msg_format("%^sはしり込みした。", m_name);
4169 else if(percentage > 50) msg_format("%^sは躊躇した。", m_name);
4170 else if(percentage > 35) msg_format("%^sは痛みに震えた。", m_name);
4171 else if(percentage > 20) msg_format("%^sは身もだえした。", m_name);
4172 else if(percentage > 10) msg_format("%^sは苦痛で身もだえした。", m_name);
4173 else msg_format("%^sはぐにゃぐにゃと痙攣した。", m_name);
4175 if(percentage > 95) msg_format("%^s barely notices.", m_name);
4176 else if(percentage > 75) msg_format("%^s flinches.", m_name);
4177 else if(percentage > 50) msg_format("%^s hesitates.", m_name);
4178 else if(percentage > 35) msg_format("%^s quivers in pain.", m_name);
4179 else if(percentage > 20) msg_format("%^s writhes about.", m_name);
4180 else if(percentage > 10) msg_format("%^s writhes in agony.", m_name);
4181 else msg_format("%^s jerks limply.", m_name);
4185 else if(my_strchr("g#+<>", r_ptr->d_char)) // Golems, Walls, Doors, Stairs
4188 if(percentage > 95) msg_format("%sは攻撃を気にとめていない。", m_name);
4189 else if(percentage > 75) msg_format("%sは攻撃に肩をすくめた。", m_name);
4190 else if(percentage > 50) msg_format("%^sは雷鳴のように吠えた。", m_name);
4191 else if(percentage > 35) msg_format("%^sは苦しげに吠えた。", m_name);
4192 else if(percentage > 20) msg_format("%^sはうめいた。", m_name);
4193 else if(percentage > 10) msg_format("%^sは躊躇した。", m_name);
4194 else msg_format("%^sはくしゃくしゃになった。", m_name);
4196 if(percentage > 95) msg_format("%^s ignores the attack.", m_name);
4197 else if(percentage > 75) msg_format("%^s shrugs off the attack.", m_name);
4198 else if(percentage > 50) msg_format("%^s roars thunderously.", m_name);
4199 else if(percentage > 35) msg_format("%^s rumbles.", m_name);
4200 else if(percentage > 20) msg_format("%^s grunts.", m_name);
4201 else if(percentage > 10) msg_format("%^s hesitates.", m_name);
4202 else msg_format("%^s crumples.", m_name);
4206 else if(my_strchr("JMR", r_ptr->d_char) || !isalpha(r_ptr->d_char)) // Snakes, Hydrae, Reptiles, Mimics
4209 if(percentage > 95) msg_format("%^sはほとんど気にとめていない。", m_name);
4210 else if(percentage > 75) msg_format("%^sはシーッと鳴いた。", m_name);
4211 else if(percentage > 50) msg_format("%^sは怒って頭を上げた。", m_name);
4212 else if(percentage > 35) msg_format("%^sは猛然と威嚇した。", m_name);
4213 else if(percentage > 20) msg_format("%^sは身もだえした。", m_name);
4214 else if(percentage > 10) msg_format("%^sは苦痛で身もだえした。", m_name);
4215 else msg_format("%^sはぐにゃぐにゃと痙攣した。", m_name);
4217 if(percentage > 95) msg_format("%^s barely notices.", m_name);
4218 else if(percentage > 75) msg_format("%^s hisses.", m_name);
4219 else if(percentage > 50) msg_format("%^s rears up in anger.", m_name);
4220 else if(percentage > 35) msg_format("%^s hisses furiously.", m_name);
4221 else if(percentage > 20) msg_format("%^s writhes about.", m_name);
4222 else if(percentage > 10) msg_format("%^s writhes in agony.", m_name);
4223 else msg_format("%^s jerks limply.", m_name);
4227 else if(my_strchr("f", r_ptr->d_char))
4230 if(percentage > 95) msg_format("%sは攻撃に肩をすくめた。", m_name);
4231 else if(percentage > 75) msg_format("%^sは吠えた。", m_name);
4232 else if(percentage > 50) msg_format("%^sは怒って吠えた。", m_name);
4233 else if(percentage > 35) msg_format("%^sは痛みでシーッと鳴いた。", m_name);
4234 else if(percentage > 20) msg_format("%^sは痛みで弱々しく鳴いた。", m_name);
4235 else if(percentage > 10) msg_format("%^sは苦痛にうめいた。", m_name);
4236 else msg_format("%sは哀れな鳴き声を出した。", m_name);
4238 if(percentage > 95) msg_format("%^s shrugs off the attack.", m_name);
4239 else if(percentage > 75) msg_format("%^s roars.", m_name);
4240 else if(percentage > 50) msg_format("%^s growls angrily.", m_name);
4241 else if(percentage > 35) msg_format("%^s hisses with pain.", m_name);
4242 else if(percentage > 20) msg_format("%^s mewls in pain.", m_name);
4243 else if(percentage > 10) msg_format("%^s hisses in agony.", m_name);
4244 else msg_format("%^s mewls pitifully.", m_name);
4248 else if(my_strchr("acFIKS", r_ptr->d_char)) // Ants, Centipedes, Flies, Insects, Beetles, Spiders
4251 if(percentage > 95) msg_format("%sは攻撃を気にとめていない。", m_name);
4252 else if(percentage > 75) msg_format("%^sはキーキー鳴いた。", m_name);
4253 else if(percentage > 50) msg_format("%^sはヨロヨロ逃げ回った。", m_name);
4254 else if(percentage > 35) msg_format("%^sはうるさく鳴いた。", m_name);
4255 else if(percentage > 20) msg_format("%^sは痛みに痙攣した。", m_name);
4256 else if(percentage > 10) msg_format("%^sは苦痛で痙攣した。", m_name);
4257 else msg_format("%^sはピクピクひきつった。", m_name);
4259 if(percentage > 95) msg_format("%^s ignores the attack.", m_name);
4260 else if(percentage > 75) msg_format("%^s chitters.", m_name);
4261 else if(percentage > 50) msg_format("%^s scuttles about.", m_name);
4262 else if(percentage > 35) msg_format("%^s twitters.", m_name);
4263 else if(percentage > 20) msg_format("%^s jerks in pain.", m_name);
4264 else if(percentage > 10) msg_format("%^s jerks in agony.", m_name);
4265 else msg_format("%^s twitches.", m_name);
4269 else if(my_strchr("B", r_ptr->d_char)) // Birds
4272 if(percentage > 95) msg_format("%^sはさえずった。", m_name);
4273 else if(percentage > 75) msg_format("%^sはピーピー鳴いた。", m_name);
4274 else if(percentage > 50) msg_format("%^sはギャーギャー鳴いた。", m_name);
4275 else if(percentage > 35) msg_format("%^sはギャーギャー鳴きわめいた。", m_name);
4276 else if(percentage > 20) msg_format("%^sは苦しんだ。", m_name);
4277 else if(percentage > 10) msg_format("%^sはのたうち回った。", m_name);
4278 else msg_format("%^sはキーキーと鳴き叫んだ。", m_name);
4280 if(percentage > 95) msg_format("%^s chirps.", m_name);
4281 else if(percentage > 75) msg_format("%^s twitters.", m_name);
4282 else if(percentage > 50) msg_format("%^s squawks.", m_name);
4283 else if(percentage > 35) msg_format("%^s chatters.", m_name);
4284 else if(percentage > 20) msg_format("%^s jeers.", m_name);
4285 else if(percentage > 10) msg_format("%^s flutters about.", m_name);
4286 else msg_format("%^s squeaks.", m_name);
4290 else if(my_strchr("duDLUW", r_ptr->d_char)) // Dragons, Demons, High Undead
4293 if(percentage > 95) msg_format("%sは攻撃を気にとめていない。", m_name);
4294 else if(percentage > 75) msg_format("%^sはしり込みした。", m_name);
4295 else if(percentage > 50) msg_format("%^sは痛みでシーッと鳴いた。", m_name);
4296 else if(percentage > 35) msg_format("%^sは痛みでうなった。", m_name);
4297 else if(percentage > 20) msg_format("%^sは痛みに吠えた。", m_name);
4298 else if(percentage > 10) msg_format("%^sは苦しげに叫んだ。", m_name);
4299 else msg_format("%^sは弱々しくうなった。", m_name);
4301 if(percentage > 95) msg_format("%^s ignores the attack.", m_name);
4302 else if(percentage > 75) msg_format("%^s flinches.", m_name);
4303 else if(percentage > 50) msg_format("%^s hisses in pain.", m_name);
4304 else if(percentage > 35) msg_format("%^s snarls with pain.", m_name);
4305 else if(percentage > 20) msg_format("%^s roars with pain.", m_name);
4306 else if(percentage > 10) msg_format("%^s gasps.", m_name);
4307 else msg_format("%^s snarls feebly.", m_name);
4311 else if(my_strchr("s", r_ptr->d_char)) // Skeletons
4314 if(percentage > 95) msg_format("%sは攻撃を気にとめていない。", m_name);
4315 else if(percentage > 75) msg_format("%sは攻撃に肩をすくめた。", m_name);
4316 else if(percentage > 50) msg_format("%^sはカタカタと笑った。", m_name);
4317 else if(percentage > 35) msg_format("%^sはよろめいた。", m_name);
4318 else if(percentage > 20) msg_format("%^sはカタカタ言った。", m_name);
4319 else if(percentage > 10) msg_format("%^sはよろめいた。", m_name);
4320 else msg_format("%^sはガタガタ言った。", m_name);
4322 if(percentage > 95) msg_format("%^s ignores the attack.", m_name);
4323 else if(percentage > 75) msg_format("%^s shrugs off the attack.", m_name);
4324 else if(percentage > 50) msg_format("%^s rattles.", m_name);
4325 else if(percentage > 35) msg_format("%^s stumbles.", m_name);
4326 else if(percentage > 20) msg_format("%^s rattles.", m_name);
4327 else if(percentage > 10) msg_format("%^s staggers.", m_name);
4328 else msg_format("%^s clatters.", m_name);
4332 else if(my_strchr("z", r_ptr->d_char)) // Zombies
4335 if(percentage > 95) msg_format("%sは攻撃を気にとめていない。", m_name);
4336 else if(percentage > 75) msg_format("%sは攻撃に肩をすくめた。", m_name);
4337 else if(percentage > 50) msg_format("%^sはうめいた。", m_name);
4338 else if(percentage > 35) msg_format("%sは苦しげにうめいた。", m_name);
4339 else if(percentage > 20) msg_format("%^sは躊躇した。", m_name);
4340 else if(percentage > 10) msg_format("%^sはうなった。", m_name);
4341 else msg_format("%^sはよろめいた。", m_name);
4343 if(percentage > 95) msg_format("%^s ignores the attack.", m_name);
4344 else if(percentage > 75) msg_format("%^s shrugs off the attack.", m_name);
4345 else if(percentage > 50) msg_format("%^s groans.", m_name);
4346 else if(percentage > 35) msg_format("%^s moans.", m_name);
4347 else if(percentage > 20) msg_format("%^s hesitates.", m_name);
4348 else if(percentage > 10) msg_format("%^s grunts.", m_name);
4349 else msg_format("%^s staggers.", m_name);
4353 else if(my_strchr("G", r_ptr->d_char)) // Ghosts
4356 if(percentage > 95) msg_format("%sは攻撃を気にとめていない。", m_name);
4357 else if(percentage > 75) msg_format("%sは攻撃に肩をすくめた。", m_name);
4358 else if(percentage > 50) msg_format("%sはうめいた。", m_name);
4359 else if(percentage > 35) msg_format("%^sは泣きわめいた。", m_name);
4360 else if(percentage > 20) msg_format("%^sは吠えた。", m_name);
4361 else if(percentage > 10) msg_format("%sは弱々しくうめいた。", m_name);
4362 else msg_format("%^sはかすかにうめいた。", m_name);
4364 if(percentage > 95) msg_format("%^s ignores the attack.", m_name);
4365 else if(percentage > 75) msg_format("%^s shrugs off the attack.", m_name);
4366 else if(percentage > 50) msg_format("%^s moans.", m_name);
4367 else if(percentage > 35) msg_format("%^s wails.", m_name);
4368 else if(percentage > 20) msg_format("%^s howls.", m_name);
4369 else if(percentage > 10) msg_format("%^s moans softly.", m_name);
4370 else msg_format("%^s sighs.", m_name);
4374 else if(my_strchr("CZ", r_ptr->d_char)) // Dogs and Hounds
4377 if(percentage > 95) msg_format("%^sは攻撃に肩をすくめた。", m_name);
4378 else if(percentage > 75) msg_format("%^sは痛みでうなった。", m_name);
4379 else if(percentage > 50) msg_format("%^sは痛みでキャンキャン吠えた。", m_name);
4380 else if(percentage > 35) msg_format("%^sは痛みで鳴きわめいた。", m_name);
4381 else if(percentage > 20) msg_format("%^sは苦痛のあまり鳴きわめいた。", m_name);
4382 else if(percentage > 10) msg_format("%^sは苦痛でもだえ苦しんだ。", m_name);
4383 else msg_format("%^sは弱々しく吠えた。", m_name);
4385 if(percentage > 95) msg_format("%^s shrugs off the attack.", m_name);
4386 else if(percentage > 75) msg_format("%^s snarls with pain.", m_name);
4387 else if(percentage > 50) msg_format("%^s yelps in pain.", m_name);
4388 else if(percentage > 35) msg_format("%^s howls in pain.", m_name);
4389 else if(percentage > 20) msg_format("%^s howls in agony.", m_name);
4390 else if(percentage > 10) msg_format("%^s writhes in agony.", m_name);
4391 else msg_format("%^s yelps feebly.", m_name);
4395 else if(my_strchr("Xbilqrt", r_ptr->d_char)) // One type of creatures (ignore,squeal,shriek)
4398 if(percentage > 95) msg_format("%^sは攻撃を気にとめていない。", m_name);
4399 else if(percentage > 75) msg_format("%^sは痛みでうなった。", m_name);
4400 else if(percentage > 50) msg_format("%^sは痛みで叫んだ。", m_name);
4401 else if(percentage > 35) msg_format("%^sは痛みで絶叫した。", m_name);
4402 else if(percentage > 20) msg_format("%^sは苦痛のあまり絶叫した。", m_name);
4403 else if(percentage > 10) msg_format("%^sは苦痛でもだえ苦しんだ。", m_name);
4404 else msg_format("%^sは弱々しく叫んだ。", m_name);
4406 if(percentage > 95) msg_format("%^s ignores the attack.", m_name);
4407 else if(percentage > 75) msg_format("%^s grunts with pain.", m_name);
4408 else if(percentage > 50) msg_format("%^s squeals in pain.", m_name);
4409 else if(percentage > 35) msg_format("%^s shrieks in pain.", m_name);
4410 else if(percentage > 20) msg_format("%^s shrieks in agony.", m_name);
4411 else if(percentage > 10) msg_format("%^s writhes in agony.", m_name);
4412 else msg_format("%^s cries out feebly.", m_name);
4416 else // Another type of creatures (shrug,cry,scream)
4419 if(percentage > 95) msg_format("%^sは攻撃に肩をすくめた。", m_name);
4420 else if(percentage > 75) msg_format("%^sは痛みでうなった。", m_name);
4421 else if(percentage > 50) msg_format("%^sは痛みで叫んだ。", m_name);
4422 else if(percentage > 35) msg_format("%^sは痛みで絶叫した。", m_name);
4423 else if(percentage > 20) msg_format("%^sは苦痛のあまり絶叫した。", m_name);
4424 else if(percentage > 10) msg_format("%^sは苦痛でもだえ苦しんだ。", m_name);
4425 else msg_format("%^sは弱々しく叫んだ。", m_name);
4427 if(percentage > 95) msg_format("%^s shrugs off the attack.", m_name);
4428 else if(percentage > 75) msg_format("%^s grunts with pain.", m_name);
4429 else if(percentage > 50) msg_format("%^s cries out in pain.", m_name);
4430 else if(percentage > 35) msg_format("%^s screams in pain.", m_name);
4431 else if(percentage > 20) msg_format("%^s screams in agony.", m_name);
4432 else if(percentage > 10) msg_format("%^s writhes in agony.", m_name);
4433 else msg_format("%^s cries out feebly.", m_name);
4441 * @brief SMART(適格に攻撃を行う)モンスターの学習状況を更新する / Learn about an "observed" resistance.
4442 * @param m_idx 更新を行う「モンスター情報ID
4443 * @param what 学習対象ID
4446 void update_smart_learn(MONSTER_IDX m_idx, int what)
4448 monster_type *m_ptr = &m_list[m_idx];
4450 monster_race *r_ptr = &r_info[m_ptr->r_idx];
4453 /* Not allowed to learn */
4454 if (!smart_learn) return;
4456 /* Too stupid to learn anything */
4457 if (r_ptr->flags2 & (RF2_STUPID)) return;
4459 /* Not intelligent, only learn sometimes */
4460 if (!(r_ptr->flags2 & (RF2_SMART)) && (randint0(100) < 50)) return;
4465 /* Analyze the knowledge */
4469 if (p_ptr->resist_acid) m_ptr->smart |= (SM_RES_ACID);
4470 if (IS_OPPOSE_ACID()) m_ptr->smart |= (SM_OPP_ACID);
4471 if (p_ptr->immune_acid) m_ptr->smart |= (SM_IMM_ACID);
4475 if (p_ptr->resist_elec) m_ptr->smart |= (SM_RES_ELEC);
4476 if (IS_OPPOSE_ELEC()) m_ptr->smart |= (SM_OPP_ELEC);
4477 if (p_ptr->immune_elec) m_ptr->smart |= (SM_IMM_ELEC);
4481 if (p_ptr->resist_fire) m_ptr->smart |= (SM_RES_FIRE);
4482 if (IS_OPPOSE_FIRE()) m_ptr->smart |= (SM_OPP_FIRE);
4483 if (p_ptr->immune_fire) m_ptr->smart |= (SM_IMM_FIRE);
4487 if (p_ptr->resist_cold) m_ptr->smart |= (SM_RES_COLD);
4488 if (IS_OPPOSE_COLD()) m_ptr->smart |= (SM_OPP_COLD);
4489 if (p_ptr->immune_cold) m_ptr->smart |= (SM_IMM_COLD);
4493 if (p_ptr->resist_pois) m_ptr->smart |= (SM_RES_POIS);
4494 if (IS_OPPOSE_POIS()) m_ptr->smart |= (SM_OPP_POIS);
4499 if (p_ptr->resist_neth) m_ptr->smart |= (SM_RES_NETH);
4503 if (p_ptr->resist_lite) m_ptr->smart |= (SM_RES_LITE);
4507 if (p_ptr->resist_dark) m_ptr->smart |= (SM_RES_DARK);
4511 if (p_ptr->resist_fear) m_ptr->smart |= (SM_RES_FEAR);
4515 if (p_ptr->resist_conf) m_ptr->smart |= (SM_RES_CONF);
4519 if (p_ptr->resist_chaos) m_ptr->smart |= (SM_RES_CHAOS);
4523 if (p_ptr->resist_disen) m_ptr->smart |= (SM_RES_DISEN);
4527 if (p_ptr->resist_blind) m_ptr->smart |= (SM_RES_BLIND);
4531 if (p_ptr->resist_nexus) m_ptr->smart |= (SM_RES_NEXUS);
4535 if (p_ptr->resist_sound) m_ptr->smart |= (SM_RES_SOUND);
4539 if (p_ptr->resist_shard) m_ptr->smart |= (SM_RES_SHARD);
4543 if (p_ptr->free_act) m_ptr->smart |= (SM_IMM_FREE);
4547 if (!p_ptr->msp) m_ptr->smart |= (SM_IMM_MANA);
4551 if (p_ptr->reflect) m_ptr-> smart |= (SM_IMM_REFLECT);
4558 * @brief プレイヤーを指定座標に配置する / Place the player in the dungeon XXX XXX
4561 * @return 配置に成功したらTRUE
4563 bool player_place(POSITION y, POSITION x)
4565 /* Paranoia XXX XXX */
4566 if (cave[y][x].m_idx != 0) return FALSE;
4568 /* Save player location */
4578 * @brief モンスターが盗みや拾いで確保していたアイテムを全てドロップさせる / Drop all items carried by a monster
4579 * @param m_ptr モンスター参照ポインタ
4582 void monster_drop_carried_objects(monster_type *m_ptr)
4584 OBJECT_IDX this_o_idx, next_o_idx = 0;
4590 /* Drop objects being carried */
4591 for (this_o_idx = m_ptr->hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
4593 /* Acquire object */
4594 o_ptr = &o_list[this_o_idx];
4596 /* Acquire next object */
4597 next_o_idx = o_ptr->next_o_idx;
4599 /* Get local object */
4602 /* Copy the object */
4603 object_copy(q_ptr, o_ptr);
4605 /* Forget monster */
4606 q_ptr->held_m_idx = 0;
4608 /* Delete the object */
4609 delete_object_idx(this_o_idx);
4612 (void)drop_near(q_ptr, -1, m_ptr->fy, m_ptr->fx);
4615 /* Forget objects */
4616 m_ptr->hold_o_idx = 0;