3 * @brief モンスター処理 / misc code for monsters
6 * Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke
7 * This software may be copied and distributed for educational, research,
8 * and not for profit purposes provided that this copyright and statement
9 * are included in all such copies. Other copyrights may also apply.
10 * 2014 Deskull rearranged comment for Doxygen.
15 #include "monsterrace-hook.h"
16 #include "monster-status.h"
17 #include "projection.h"
19 #define HORDE_NOGOOD 0x01 /*!< (未実装フラグ)HORDE生成でGOODなモンスターの生成を禁止する? */
20 #define HORDE_NOEVIL 0x02 /*!< (未実装フラグ)HORDE生成でEVILなモンスターの生成を禁止する? */
25 * @brief ELDRITCH HORROR効果時のモンスターの形容メッセージ(通常時)
27 concptr horror_desc[MAX_SAN_HORROR] =
83 * @brief ELDRITCH HORROR効果時のモンスターの形容メッセージ(幻覚状態時)
85 concptr funny_desc[MAX_SAN_FUNNY] =
146 * @var funny_comments
147 * @brief ELDRITCH HORROR効果時の幻覚時間延長を示す錯乱表現
149 concptr funny_comments[MAX_SAN_COMMENT] =
170 * @brief モンスターの目標地点をセットする / Set the target of counter attack
171 * @param m_ptr モンスターの参照ポインタ
176 void set_target(monster_type *m_ptr, POSITION y, POSITION x)
184 * @brief モンスターの目標地点をリセットする / Reset the target of counter attack
185 * @param m_ptr モンスターの参照ポインタ
188 void reset_target(monster_type *m_ptr)
190 set_target(m_ptr, 0, 0);
195 * @brief モンスターの真の種族を返す / Extract monster race pointer of a monster's true form
196 * @param m_ptr モンスターの参照ポインタ
197 * @return 本当のモンスター種族参照ポインタ
199 monster_race *real_r_ptr(monster_type *m_ptr)
201 return &r_info[real_r_idx(m_ptr)];
204 MONRACE_IDX real_r_idx(monster_type *m_ptr)
206 monster_race *r_ptr = &r_info[m_ptr->r_idx];
208 /* Extract real race */
209 if (m_ptr->mflag2 & MFLAG2_CHAMELEON)
211 if (r_ptr->flags1 & RF1_UNIQUE)
212 return MON_CHAMELEON_K;
214 return MON_CHAMELEON;
224 * @brief モンスター配列からモンスターを消去する / Delete a monster by index.
225 * @param i 消去するモンスターのID
228 * モンスターを削除するとそのモンスターが拾っていたアイテムも同時に削除される。 /
229 * When a monster is deleted, all of its objects are deleted.
231 void delete_monster_idx(MONSTER_IDX i)
234 monster_type *m_ptr = &m_list[i];
235 monster_race *r_ptr = &r_info[m_ptr->r_idx];
236 OBJECT_IDX this_o_idx, next_o_idx = 0;
241 /* Hack -- Reduce the racial counter */
242 real_r_ptr(m_ptr)->cur_num--;
244 /* Hack -- count the number of "reproducers" */
245 if (r_ptr->flags2 & (RF2_MULTIPLY)) num_repro--;
247 if (MON_CSLEEP(m_ptr)) (void)set_monster_csleep(i, 0);
248 if (MON_FAST(m_ptr)) (void)set_monster_fast(i, 0);
249 if (MON_SLOW(m_ptr)) (void)set_monster_slow(i, 0);
250 if (MON_STUNNED(m_ptr)) (void)set_monster_stunned(i, 0);
251 if (MON_CONFUSED(m_ptr)) (void)set_monster_confused(i, 0);
252 if (MON_MONFEAR(m_ptr)) (void)set_monster_monfear(i, 0);
253 if (MON_INVULNER(m_ptr)) (void)set_monster_invulner(i, 0, FALSE);
255 /* Hack -- remove target monster */
256 if (i == target_who) target_who = 0;
258 /* Hack -- remove tracked monster */
259 if (i == p_ptr->health_who) health_track(0);
261 if (pet_t_m_idx == i ) pet_t_m_idx = 0;
262 if (riding_t_m_idx == i) riding_t_m_idx = 0;
263 if (p_ptr->riding == i) p_ptr->riding = 0;
265 /* Monster is gone */
266 cave[y][x].m_idx = 0;
270 for (this_o_idx = m_ptr->hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
273 o_ptr = &o_list[this_o_idx];
275 /* Acquire next object */
276 next_o_idx = o_ptr->next_o_idx;
279 * o_ptr->held_m_idx is needed in delete_object_idx()
280 * to prevent calling lite_spot()
283 delete_object_idx(this_o_idx);
287 if (is_pet(m_ptr)) check_pets_num_and_align(m_ptr, FALSE);
290 /* Wipe the Monster */
291 (void)WIPE(m_ptr, monster_type);
299 /* Update some things */
300 if (r_ptr->flags7 & (RF7_LITE_MASK | RF7_DARK_MASK))
301 p_ptr->update |= (PU_MON_LITE);
306 * @brief 指定位置に存在するモンスターを削除する / Delete the monster, if any, at a given location
311 void delete_monster(POSITION y, POSITION x)
316 if (!in_bounds(y, x)) return;
321 /* Delete the monster (if any) */
322 if (c_ptr->m_idx) delete_monster_idx(c_ptr->m_idx);
327 * @brief モンスター情報を配列内移動する / Move an object from index i1 to index i2 in the object list
332 static void compact_monsters_aux(IDX i1, IDX i2)
338 OBJECT_IDX this_o_idx, next_o_idx = 0;
341 if (i1 == i2) return;
352 /* Update the cave */
355 /* Repair objects being carried by monster */
356 for (this_o_idx = m_ptr->hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
359 o_ptr = &o_list[this_o_idx];
361 /* Acquire next object */
362 next_o_idx = o_ptr->next_o_idx;
364 /* Reset monster pointer */
365 o_ptr->held_m_idx = i2;
368 /* Hack -- Update the target */
369 if (target_who == i1) target_who = i2;
371 /* Hack -- Update the target */
372 if (pet_t_m_idx == i1) pet_t_m_idx = i2;
373 if (riding_t_m_idx == i1) riding_t_m_idx = i2;
375 /* Hack -- Update the riding */
376 if (p_ptr->riding == i1) p_ptr->riding = i2;
378 /* Hack -- Update the health bar */
379 if (p_ptr->health_who == i1) health_track(i2);
381 /* Hack -- Update parent index */
384 for (i = 1; i < m_max; i++)
386 monster_type *m2_ptr = &m_list[i];
388 if (m2_ptr->parent_m_idx == i1)
389 m2_ptr->parent_m_idx = i2;
394 (void)COPY(&m_list[i2], &m_list[i1], monster_type);
397 (void)WIPE(&m_list[i1], monster_type);
399 for (i = 0; i < MAX_MTIMED; i++)
401 int mproc_idx = get_mproc_idx(i1, i);
402 if (mproc_idx >= 0) mproc_list[i][mproc_idx] = i2;
408 * @brief モンスター情報配列を圧縮する / Compact and Reorder the monster list
409 * @param size 圧縮後のモンスター件数目標
412 * This function can be very dangerous, use with caution!
414 * When actually "compacting" monsters, we base the saving throw
415 * on a combination of monster level, distance from player, and
416 * current "desperation".
418 * After "compacting" (if needed), we "reorder" the monsters into a more
419 * compact order, and we reset the allocation info, and the "live" array.
421 void compact_monsters(int size)
425 int cur_lev, cur_dis, chance;
427 /* Message (only if compacting) */
428 if (size) msg_print(_("モンスター情報を圧縮しています...", "Compacting monsters..."));
431 /* Compact at least 'size' objects */
432 for (num = 0, cnt = 1; num < size; cnt++)
434 /* Get more vicious each iteration */
437 /* Get closer each iteration */
438 cur_dis = 5 * (20 - cnt);
440 /* Check all the monsters */
441 for (i = 1; i < m_max; i++)
443 monster_type *m_ptr = &m_list[i];
445 monster_race *r_ptr = &r_info[m_ptr->r_idx];
447 /* Paranoia -- skip "dead" monsters */
448 if (!m_ptr->r_idx) continue;
450 /* Hack -- High level monsters start out "immune" */
451 if (r_ptr->level > cur_lev) continue;
453 if (i == p_ptr->riding) continue;
455 /* Ignore nearby monsters */
456 if ((cur_dis > 0) && (m_ptr->cdis < cur_dis)) continue;
458 /* Saving throw chance */
461 /* Only compact "Quest" Monsters in emergencies */
462 if ((r_ptr->flags1 & (RF1_QUESTOR)) && (cnt < 1000)) chance = 100;
464 /* Try not to compact Unique Monsters */
465 if (r_ptr->flags1 & (RF1_UNIQUE)) chance = 100;
467 /* All monsters get a saving throw */
468 if (randint0(100) < chance) continue;
470 if (record_named_pet && is_pet(m_ptr) && m_ptr->nickname)
472 GAME_TEXT m_name[MAX_NLEN];
473 monster_desc(m_name, m_ptr, MD_INDEF_VISIBLE);
474 do_cmd_write_nikki(NIKKI_NAMED_PET, RECORD_NAMED_PET_COMPACT, m_name);
477 delete_monster_idx(i);
479 /* Count the monster */
485 /* Excise dead monsters (backwards!) */
486 for (i = m_max - 1; i >= 1; i--)
488 /* Get the i'th monster */
489 monster_type *m_ptr = &m_list[i];
491 /* Skip real monsters */
492 if (m_ptr->r_idx) continue;
494 /* Move last monster into open hole */
495 compact_monsters_aux(m_max - 1, i);
497 /* Compress "m_max" */
504 * @brief プレイヤーのフロア離脱に伴う全モンスター配列の消去 / Delete/Remove all the monsters when the player leaves the level
507 * This is an efficient method of simulating multiple calls to the
508 * "delete_monster()" function, with no visual effects.
510 void wipe_m_list(void)
514 /* Hack -- if Banor or Lupart dies, stay another dead */
515 if (!r_info[MON_BANORLUPART].max_num)
517 if (r_info[MON_BANOR].max_num)
519 r_info[MON_BANOR].max_num = 0;
520 r_info[MON_BANOR].r_pkills++;
521 r_info[MON_BANOR].r_akills++;
522 if (r_info[MON_BANOR].r_tkills < MAX_SHORT) r_info[MON_BANOR].r_tkills++;
524 if (r_info[MON_LUPART].max_num)
526 r_info[MON_LUPART].max_num = 0;
527 r_info[MON_LUPART].r_pkills++;
528 r_info[MON_LUPART].r_akills++;
529 if (r_info[MON_LUPART].r_tkills < MAX_SHORT) r_info[MON_LUPART].r_tkills++;
533 /* Delete all the monsters */
534 for (i = m_max - 1; i >= 1; i--)
536 monster_type *m_ptr = &m_list[i];
538 /* Skip dead monsters */
539 if (!m_ptr->r_idx) continue;
541 /* Monster is gone */
542 cave[m_ptr->fy][m_ptr->fx].m_idx = 0;
544 /* Wipe the Monster */
545 (void)WIPE(m_ptr, monster_type);
550 * Wiping racial counters of all monsters and incrementing of racial
551 * counters of monsters in party_mon[] are required to prevent multiple
552 * generation of unique monster who is the minion of player.
555 /* Hack -- Wipe the racial counter of all monster races */
556 for (i = 1; i < max_r_idx; i++) r_info[i].cur_num = 0;
564 /* Reset "mproc_max[]" */
565 for (i = 0; i < MAX_MTIMED; i++) mproc_max[i] = 0;
567 /* Hack -- reset "reproducer" count */
570 /* Hack -- no more target */
575 /* Hack -- no more tracking */
581 * @brief モンスター配列の空きを探す / Acquires and returns the index of a "free" monster.
582 * @return 利用可能なモンスター配列の添字
584 * This routine should almost never fail, but it *can* happen.
586 MONSTER_IDX m_pop(void)
590 /* Normal allocation */
591 if (m_max < max_m_idx)
593 /* Access the next hole */
596 /* Expand the array */
602 /* Return the index */
606 /* Recycle dead monsters */
607 for (i = 1; i < m_max; i++)
611 /* Acquire monster */
614 /* Skip live monsters */
615 if (m_ptr->r_idx) continue;
620 /* Use this monster */
624 /* Warn the player (except during dungeon creation) */
625 if (character_dungeon) msg_print(_("モンスターが多すぎる!", "Too many monsters!"));
627 /* Try not to crash */
635 * @var summon_specific_type
636 * @brief 召喚条件を指定するグローバル変数 / Hack -- the "type" of the current "summon specific"
637 * @todo summon_specific_typeグローバル変数の除去と関数引数への代替を行う
639 static int summon_specific_type = 0;
643 * @var summon_specific_who
644 * @brief 召喚を行ったプレイヤーあるいはモンスターのIDを示すグローバル変数 / Hack -- the index of the summoning monster
645 * @todo summon_specific_who グローバル変数の除去と関数引数への代替を行う
647 static int summon_specific_who = -1;
650 * @var summon_unique_okay
651 * @brief 召喚対象にユニークを含めるかを示すグローバル変数 / summoning unique enable
652 * @todo summon_unique_okay グローバル変数の除去と関数引数への代替を行う
654 static bool summon_unique_okay = FALSE;
657 * @brief 指定されたモンスター種族がsummon_specific_typeで指定された召喚条件に合うかどうかを返す
658 * @return 召喚条件が一致するならtrue
661 static bool summon_specific_aux(MONRACE_IDX r_idx)
663 monster_race *r_ptr = &r_info[r_idx];
666 /* Check our requirements */
667 switch (summon_specific_type)
671 okay = (r_ptr->d_char == 'a');
677 okay = (r_ptr->d_char == 'S');
683 okay = ((r_ptr->d_char == 'C') || (r_ptr->d_char == 'Z'));
689 okay = (r_ptr->d_char == 'M');
695 okay = (r_ptr->d_char == 'A' && ((r_ptr->flags3 & RF3_EVIL) || (r_ptr->flags3 & RF3_GOOD)));
701 okay = (r_ptr->flags3 & RF3_DEMON);
707 okay = (r_ptr->flags3 & RF3_UNDEAD);
713 okay = (r_ptr->flags3 & RF3_DRAGON);
717 case SUMMON_HI_UNDEAD:
719 okay = ((r_ptr->d_char == 'L') ||
720 (r_ptr->d_char == 'V') ||
721 (r_ptr->d_char == 'W'));
725 case SUMMON_HI_DRAGON:
727 okay = (r_ptr->d_char == 'D');
731 case SUMMON_HI_DEMON:
733 okay = (((r_ptr->d_char == 'U') ||
734 (r_ptr->d_char == 'H') ||
735 (r_ptr->d_char == 'B')) &&
736 (r_ptr->flags3 & RF3_DEMON)) ? TRUE : FALSE;
740 case SUMMON_AMBERITES:
742 okay = (r_ptr->flags3 & (RF3_AMBERITE)) ? TRUE : FALSE;
748 okay = (r_ptr->flags1 & (RF1_UNIQUE)) ? TRUE : FALSE;
754 okay = (r_ptr->d_char == 'm');
759 okay = (r_ptr->d_char == 'b');
762 case SUMMON_QUYLTHULG:
764 okay = (r_ptr->d_char == 'Q');
768 case SUMMON_COIN_MIMIC:
770 okay = (r_ptr->d_char == '$');
776 okay = ((r_ptr->d_char == '!') ||
777 (r_ptr->d_char == '?') ||
778 (r_ptr->d_char == '=') ||
779 (r_ptr->d_char == '$') ||
780 (r_ptr->d_char == '|'));
786 okay = (r_ptr->d_char == 'g');
792 okay = ((r_ptr->d_char == 'U') &&
793 (r_ptr->flags4 & RF4_ROCKET));
799 okay = ((r_ptr->d_char == summon_kin_type) && (r_idx != MON_HAGURE));
805 okay = (r_idx == MON_DAWN);
811 okay = (r_ptr->flags3 & (RF3_ANIMAL));
815 case SUMMON_ANIMAL_RANGER:
817 okay = ((r_ptr->flags3 & (RF3_ANIMAL)) &&
818 (my_strchr("abcflqrwBCHIJKMRS", r_ptr->d_char)) &&
819 !(r_ptr->flags3 & (RF3_DRAGON)) &&
820 !(r_ptr->flags3 & (RF3_EVIL)) &&
821 !(r_ptr->flags3 & (RF3_UNDEAD)) &&
822 !(r_ptr->flags3 & (RF3_DEMON)) &&
823 !(r_ptr->flags2 & (RF2_MULTIPLY)) &&
824 !(r_ptr->flags4 || r_ptr->a_ability_flags1 || r_ptr->a_ability_flags2));
828 case SUMMON_HI_DRAGON_LIVING:
830 okay = ((r_ptr->d_char == 'D') && monster_living(r_idx));
836 okay = monster_living(r_idx);
842 okay = (r_idx == MON_PHANTOM_B || r_idx == MON_PHANTOM_W);
846 case SUMMON_BLUE_HORROR:
848 okay = (r_idx == MON_BLUE_HORROR);
852 case SUMMON_ELEMENTAL:
854 okay = (r_ptr->d_char == 'E');
860 okay = (r_ptr->d_char == 'v');
866 okay = (r_ptr->d_char == 'H');
872 okay = (r_ptr->d_char == 'B');
876 case SUMMON_KAMIKAZE:
879 for (i = 0; i < 4; i++)
880 if (r_ptr->blow[i].method == RBM_EXPLODE) okay = TRUE;
884 case SUMMON_KAMIKAZE_LIVING:
888 for (i = 0; i < 4; i++)
889 if (r_ptr->blow[i].method == RBM_EXPLODE) okay = TRUE;
890 okay = (okay && monster_living(r_idx));
896 okay = (r_idx == MON_MANES);
902 okay = (r_idx == MON_LOUSE);
906 case SUMMON_GUARDIANS:
908 okay = (r_ptr->flags7 & RF7_GUARDIAN);
914 okay = ((r_idx == MON_NOV_PALADIN) ||
915 (r_idx == MON_NOV_PALADIN_G) ||
916 (r_idx == MON_PALADIN) ||
917 (r_idx == MON_W_KNIGHT) ||
918 (r_idx == MON_ULTRA_PALADIN) ||
919 (r_idx == MON_KNI_TEMPLAR));
925 okay = (r_ptr->d_char == 'B' &&
926 (r_ptr->flags8 & RF8_WILD_MOUNTAIN) &&
927 (r_ptr->flags8 & RF8_WILD_ONLY));
931 case SUMMON_PIRANHAS:
933 okay = (r_idx == MON_PIRANHA);
937 case SUMMON_ARMAGE_GOOD:
939 okay = (r_ptr->d_char == 'A' && (r_ptr->flags3 & RF3_GOOD));
943 case SUMMON_ARMAGE_EVIL:
945 okay = ((r_ptr->flags3 & RF3_DEMON) ||
946 (r_ptr->d_char == 'A' && (r_ptr->flags3 & RF3_EVIL)));
950 /* Since okay is int, "return (okay);" is not correct. */
951 return (bool)(okay ? TRUE : FALSE);
955 * @var chameleon_change_m_idx
956 * @brief カメレオンの変身先モンスターIDを受け渡すためのグローバル変数
957 * @todo 変数渡しの問題などもあるができればchameleon_change_m_idxのグローバル変数を除去し、関数引き渡しに移行すること
959 static int chameleon_change_m_idx = 0;
963 * @brief 指定されたモンスター種族がダンジョンの制限にかかるかどうかをチェックする / Some dungeon types restrict the possible monsters.
964 * @param r_idx チェックするモンスター種族ID
965 * @return 召喚条件が一致するならtrue / Return TRUE is the monster is OK and FALSE otherwise
967 static bool restrict_monster_to_dungeon(MONRACE_IDX r_idx)
969 dungeon_info_type *d_ptr = &d_info[dungeon_type];
970 monster_race *r_ptr = &r_info[r_idx];
973 if (d_ptr->flags1 & DF1_CHAMELEON)
975 if (chameleon_change_m_idx) return TRUE;
977 if (d_ptr->flags1 & DF1_NO_MAGIC)
979 if (r_idx != MON_CHAMELEON &&
981 !(r_ptr->flags4 & RF4_NOMAGIC_MASK) &&
982 !(r_ptr->a_ability_flags1 & RF5_NOMAGIC_MASK) &&
983 !(r_ptr->a_ability_flags2 & RF6_NOMAGIC_MASK))
986 if (d_ptr->flags1 & DF1_NO_MELEE)
988 if (r_idx == MON_CHAMELEON) return TRUE;
989 if (!(r_ptr->flags4 & (RF4_BOLT_MASK | RF4_BEAM_MASK | RF4_BALL_MASK)) &&
990 !(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)) &&
991 !(r_ptr->a_ability_flags2 & (RF6_BOLT_MASK | RF6_BEAM_MASK | RF6_BALL_MASK)))
994 if (d_ptr->flags1 & DF1_BEGINNER)
996 if (r_ptr->level > dun_level)
1000 if (d_ptr->special_div >= 64) return TRUE;
1001 if (summon_specific_type && !(d_ptr->flags1 & DF1_CHAMELEON)) return TRUE;
1003 switch (d_ptr->mode)
1005 case DUNGEON_MODE_AND:
1008 if ((d_ptr->mflags1 & r_ptr->flags1) != d_ptr->mflags1)
1013 if ((d_ptr->mflags2 & r_ptr->flags2) != d_ptr->mflags2)
1018 if ((d_ptr->mflags3 & r_ptr->flags3) != d_ptr->mflags3)
1023 if ((d_ptr->mflags4 & r_ptr->flags4) != d_ptr->mflags4)
1026 if (d_ptr->m_a_ability_flags1)
1028 if ((d_ptr->m_a_ability_flags1 & r_ptr->a_ability_flags1) != d_ptr->m_a_ability_flags1)
1031 if (d_ptr->m_a_ability_flags2)
1033 if ((d_ptr->m_a_ability_flags2 & r_ptr->a_ability_flags2) != d_ptr->m_a_ability_flags2)
1038 if ((d_ptr->mflags7 & r_ptr->flags7) != d_ptr->mflags7)
1043 if ((d_ptr->mflags8 & r_ptr->flags8) != d_ptr->mflags8)
1048 if ((d_ptr->mflags9 & r_ptr->flags9) != d_ptr->mflags9)
1053 if ((d_ptr->mflagsr & r_ptr->flagsr) != d_ptr->mflagsr)
1056 for (a = 0; a < 5; a++)
1057 if (d_ptr->r_char[a] && (d_ptr->r_char[a] != r_ptr->d_char)) return FALSE;
1061 case DUNGEON_MODE_NAND:
1064 if ((d_ptr->mflags1 & r_ptr->flags1) != d_ptr->mflags1)
1069 if ((d_ptr->mflags2 & r_ptr->flags2) != d_ptr->mflags2)
1074 if ((d_ptr->mflags3 & r_ptr->flags3) != d_ptr->mflags3)
1079 if ((d_ptr->mflags4 & r_ptr->flags4) != d_ptr->mflags4)
1082 if (d_ptr->m_a_ability_flags1)
1084 if ((d_ptr->m_a_ability_flags1 & r_ptr->a_ability_flags1) != d_ptr->m_a_ability_flags1)
1087 if (d_ptr->m_a_ability_flags2)
1089 if ((d_ptr->m_a_ability_flags2 & r_ptr->a_ability_flags2) != d_ptr->m_a_ability_flags2)
1094 if ((d_ptr->mflags7 & r_ptr->flags7) != d_ptr->mflags7)
1099 if ((d_ptr->mflags8 & r_ptr->flags8) != d_ptr->mflags8)
1104 if ((d_ptr->mflags9 & r_ptr->flags9) != d_ptr->mflags9)
1109 if ((d_ptr->mflagsr & r_ptr->flagsr) != d_ptr->mflagsr)
1112 for (a = 0; a < 5; a++)
1113 if (d_ptr->r_char[a] && (d_ptr->r_char[a] != r_ptr->d_char)) return TRUE;
1117 case DUNGEON_MODE_OR:
1118 if (r_ptr->flags1 & d_ptr->mflags1) return TRUE;
1119 if (r_ptr->flags2 & d_ptr->mflags2) return TRUE;
1120 if (r_ptr->flags3 & d_ptr->mflags3) return TRUE;
1121 if (r_ptr->flags4 & d_ptr->mflags4) return TRUE;
1122 if (r_ptr->a_ability_flags1 & d_ptr->m_a_ability_flags1) return TRUE;
1123 if (r_ptr->a_ability_flags2 & d_ptr->m_a_ability_flags2) return TRUE;
1124 if (r_ptr->flags7 & d_ptr->mflags7) return TRUE;
1125 if (r_ptr->flags8 & d_ptr->mflags8) return TRUE;
1126 if (r_ptr->flags9 & d_ptr->mflags9) return TRUE;
1127 if (r_ptr->flagsr & d_ptr->mflagsr) return TRUE;
1128 for (a = 0; a < 5; a++)
1129 if (d_ptr->r_char[a] == r_ptr->d_char) return TRUE;
1133 case DUNGEON_MODE_NOR:
1134 if (r_ptr->flags1 & d_ptr->mflags1) return FALSE;
1135 if (r_ptr->flags2 & d_ptr->mflags2) return FALSE;
1136 if (r_ptr->flags3 & d_ptr->mflags3) return FALSE;
1137 if (r_ptr->flags4 & d_ptr->mflags4) return FALSE;
1138 if (r_ptr->a_ability_flags1 & d_ptr->m_a_ability_flags1) return FALSE;
1139 if (r_ptr->a_ability_flags2 & d_ptr->m_a_ability_flags2) return FALSE;
1140 if (r_ptr->flags7 & d_ptr->mflags7) return FALSE;
1141 if (r_ptr->flags8 & d_ptr->mflags8) return FALSE;
1142 if (r_ptr->flags9 & d_ptr->mflags9) return FALSE;
1143 if (r_ptr->flagsr & d_ptr->mflagsr) return FALSE;
1144 for (a = 0; a < 5; a++)
1145 if (d_ptr->r_char[a] == r_ptr->d_char) return FALSE;
1154 * @brief モンスター生成制限関数最大2つから / Apply a "monster restriction function" to the "monster allocation table"
1155 * @param monster_hook 制限関数1
1156 * @param monster_hook2 制限関数2
1159 errr get_mon_num_prep(monsterrace_hook_type monster_hook,
1160 monsterrace_hook_type monster_hook2)
1164 /* Todo: Check the hooks for non-changes */
1166 /* Set the new hooks */
1167 get_mon_num_hook = monster_hook;
1168 get_mon_num2_hook = monster_hook2;
1170 /* Scan the allocation table */
1171 for (i = 0; i < alloc_race_size; i++)
1173 monster_race *r_ptr;
1176 alloc_entry *entry = &alloc_race_table[i];
1179 r_ptr = &r_info[entry->index];
1181 /* Skip monsters which don't pass the restriction */
1182 if ((get_mon_num_hook && !((*get_mon_num_hook)(entry->index))) ||
1183 (get_mon_num2_hook && !((*get_mon_num2_hook)(entry->index))))
1186 if (!p_ptr->inside_battle && !chameleon_change_m_idx &&
1187 summon_specific_type != SUMMON_GUARDIANS)
1189 /* Hack -- don't create questors */
1190 if (r_ptr->flags1 & RF1_QUESTOR)
1193 if (r_ptr->flags7 & RF7_GUARDIAN)
1196 /* Depth Monsters never appear out of depth */
1197 if ((r_ptr->flags1 & (RF1_FORCE_DEPTH)) &&
1198 (r_ptr->level > dun_level))
1202 /* Accept this monster */
1203 entry->prob2 = entry->prob1;
1205 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)
1207 int hoge = entry->prob2 * d_info[dungeon_type].special_div;
1208 entry->prob2 = hoge / 64;
1209 if (randint0(64) < (hoge & 0x3f)) entry->prob2++;
1219 * @brief 生成モンスター種族を1種生成テーブルから選択する
1221 * @return 選択されたモンスター生成種族
1223 * Choose a monster race that seems "appropriate" to the given level
1225 * This function uses the "prob2" field of the "monster allocation table",
1226 * and various local information, to calculate the "prob3" field of the
1227 * same table, which is then used to choose an "appropriate" monster, in
1228 * a relatively efficient manner.
1230 * Note that "town" monsters will *only* be created in the town, and
1231 * "normal" monsters will *never* be created in the town, unless the
1232 * "level" is "modified", for example, by polymorph or summoning.
1234 * There is a small chance (1/50) of "boosting" the given depth by
1235 * a small amount (up to four levels), except in the town.
1237 * It is (slightly) more likely to acquire a monster of the given level
1238 * than one of a lower level. This is done by choosing several monsters
1239 * appropriate to the given level and keeping the "hardest" one.
1241 * Note that if no monsters are "appropriate", then this function will
1242 * fail, and return zero, but this should *almost* never happen.
1244 MONRACE_IDX get_mon_num(DEPTH level)
1249 monster_race *r_ptr;
1250 alloc_entry *table = alloc_race_table;
1252 int pls_kakuritu, pls_level;
1253 int delay = mysqrt(level * 10000L) + 400L;
1255 pls_kakuritu = MAX(NASTY_MON_MAX, NASTY_MON_BASE - ((dungeon_turn / (TURNS_PER_TICK * 5000L) - delay / 10)));
1256 pls_level = MIN(NASTY_MON_PLUS_MAX, 3 + dungeon_turn / (TURNS_PER_TICK * 40000L) - delay / 40 + MIN(5, level / 10)) ;
1258 if (d_info[dungeon_type].flags1 & DF1_MAZE)
1260 pls_kakuritu = MIN(pls_kakuritu / 2, pls_kakuritu - 10);
1261 if (pls_kakuritu < 2) pls_kakuritu = 2;
1266 /* Boost the level */
1267 if (!p_ptr->inside_battle && !(d_info[dungeon_type].flags1 & DF1_BEGINNER))
1269 /* Nightmare mode allows more out-of depth monsters */
1270 if (ironman_nightmare && !randint0(pls_kakuritu))
1272 /* What a bizarre calculation */
1273 level = 1 + (level * MAX_DEPTH / randint1(MAX_DEPTH));
1277 /* Occasional "nasty" monster */
1278 if (!randint0(pls_kakuritu))
1280 /* Pick a level bonus */
1286 if (level > MAX_DEPTH - 1) level = MAX_DEPTH - 1;
1287 if (level < 0) level = 0;
1292 /* Process probabilities */
1293 for (i = 0; i < alloc_race_size; i++)
1295 /* Monsters are sorted by depth */
1296 if (table[i].level > level) break;
1301 /* Access the "r_idx" of the chosen monster */
1302 r_idx = table[i].index;
1304 /* Access the actual race */
1305 r_ptr = &r_info[r_idx];
1307 if (!p_ptr->inside_battle && !chameleon_change_m_idx)
1309 /* Hack -- "unique" monsters must be "unique" */
1310 if (((r_ptr->flags1 & (RF1_UNIQUE)) ||
1311 (r_ptr->flags7 & (RF7_NAZGUL))) &&
1312 (r_ptr->cur_num >= r_ptr->max_num))
1317 if ((r_ptr->flags7 & (RF7_UNIQUE2)) &&
1318 (r_ptr->cur_num >= 1))
1323 if (r_idx == MON_BANORLUPART)
1325 if (r_info[MON_BANOR].cur_num > 0) continue;
1326 if (r_info[MON_LUPART].cur_num > 0) continue;
1331 table[i].prob3 = table[i].prob2;
1334 total += table[i].prob3;
1337 /* No legal monsters */
1338 if (total <= 0) return (0);
1340 /* Pick a monster */
1341 value = randint0(total);
1343 /* Find the monster */
1344 for (i = 0; i < alloc_race_size; i++)
1346 /* Found the entry */
1347 if (value < table[i].prob3) break;
1350 value = value - table[i].prob3;
1356 /* Try for a "harder" monster once (50%) or twice (10%) */
1362 /* Pick a monster */
1363 value = randint0(total);
1365 /* Find the monster */
1366 for (i = 0; i < alloc_race_size; i++)
1368 /* Found the entry */
1369 if (value < table[i].prob3) break;
1372 value = value - table[i].prob3;
1375 /* Keep the "best" one */
1376 if (table[i].level < table[j].level) i = j;
1379 /* Try for a "harder" monster twice (10%) */
1385 /* Pick a monster */
1386 value = randint0(total);
1388 /* Find the monster */
1389 for (i = 0; i < alloc_race_size; i++)
1391 /* Found the entry */
1392 if (value < table[i].prob3) break;
1395 value = value - table[i].prob3;
1398 /* Keep the "best" one */
1399 if (table[i].level < table[j].level) i = j;
1401 return (table[i].index);
1406 * @brief モンスターの呼称を作成する / Build a string describing a monster in some way.
1407 * @param desc 記述出力先の文字列参照ポインタ
1408 * @param m_ptr モンスターの参照ポインタ
1409 * @param mode 呼称オプション
1412 * We can correctly describe monsters based on their visibility.
1413 * We can force all monsters to be treated as visible or invisible.
1414 * We can build nominatives, objectives, possessives, or reflexives.
1415 * We can selectively pronominalize hidden, visible, or all monsters.
1416 * We can use definite or indefinite descriptions for hidden monsters.
1417 * We can use definite or indefinite descriptions for visible monsters.
1419 * Pronominalization involves the gender whenever possible and allowed,
1420 * so that by cleverly requesting pronominalization / visibility, you
1421 * can get messages like "You hit someone. She screams in agony!".
1423 * Reflexives are acquired by requesting Objective plus Possessive.
1425 * If no m_ptr arg is given (?), the monster is assumed to be hidden,
1426 * unless the "Assume Visible" mode is requested.
1428 * If no r_ptr arg is given, it is extracted from m_ptr and r_info
1429 * If neither m_ptr nor r_ptr is given, the monster is assumed to
1430 * be neuter, singular, and hidden (unless "Assume Visible" is set),
1431 * in which case you may be in trouble... :-)
1433 * I am assuming that no monster name is more than 70 characters long,
1434 * so that "char desc[80];" is sufficiently large for any result.
1437 * MD_OBJECTIVE --> Objective (or Reflexive)
1438 * MD_POSSESSIVE --> Possessive (or Reflexive)
1439 * MD_INDEF_HIDDEN --> Use indefinites for hidden monsters ("something")
1440 * MD_INDEF_VISIBLE --> Use indefinites for visible monsters ("a kobold")
1441 * MD_PRON_HIDDEN --> Pronominalize hidden monsters
1442 * MD_PRON_VISIBLE --> Pronominalize visible monsters
1443 * MD_ASSUME_HIDDEN --> Assume the monster is hidden
1444 * MD_ASSUME_VISIBLE --> Assume the monster is visible
1445 * MD_TRUE_NAME --> Chameleon's true name
1446 * MD_IGNORE_HALLU --> Ignore hallucination, and penetrate shape change
1449 * 0x00 --> Full nominative name ("the kobold") or "it"
1450 * MD_INDEF_HIDDEN --> Full nominative name ("the kobold") or "something"
1451 * MD_ASSUME_VISIBLE --> Genocide resistance name ("the kobold")
1452 * MD_ASSUME_VISIBLE | MD_INDEF_VISIBLE --> Killing name ("a kobold")
1453 * MD_PRON_VISIBLE | MD_POSSESSIVE
1454 * --> Possessive, genderized if visable ("his") or "its"
1455 * MD_PRON_VISIBLE | MD_POSSESSIVE | MD_OBJECTIVE
1456 * --> Reflexive, genderized if visable ("himself") or "itself"
1458 void monster_desc(char *desc, monster_type *m_ptr, BIT_FLAGS mode)
1461 monster_race *r_ptr;
1465 GAME_TEXT silly_name[1024];
1469 r_ptr = &r_info[m_ptr->ap_r_idx];
1471 /* Mode of MD_TRUE_NAME will reveal Chameleon's true name */
1472 if (mode & MD_TRUE_NAME) name = (r_name + real_r_ptr(m_ptr)->name);
1473 else name = (r_name + r_ptr->name);
1475 /* Are we hallucinating? (Idea from Nethack...) */
1476 if (p_ptr->image && !(mode & MD_IGNORE_HALLU))
1480 if (!get_rnd_line(_("silly_j.txt", "silly.txt"), m_ptr->r_idx, silly_name))
1486 monster_race *hallu_race;
1490 hallu_race = &r_info[randint1(max_r_idx - 1)];
1492 while (!hallu_race->name || (hallu_race->flags1 & RF1_UNIQUE));
1494 strcpy(silly_name, (r_name + hallu_race->name));
1497 /* Better not strcpy it, or we could corrupt r_info... */
1501 /* Can we "see" it (exists + forced, or visible + not unforced) */
1502 seen = (m_ptr && ((mode & MD_ASSUME_VISIBLE) || (!(mode & MD_ASSUME_HIDDEN) && m_ptr->ml)));
1504 /* Sexed Pronouns (seen and allowed, or unseen and allowed) */
1505 pron = (m_ptr && ((seen && (mode & MD_PRON_VISIBLE)) || (!seen && (mode & MD_PRON_HIDDEN))));
1508 /* First, try using pronouns, or describing hidden monsters */
1511 /* an encoding of the monster "sex" */
1514 /* Extract the gender (if applicable) */
1515 if (r_ptr->flags1 & (RF1_FEMALE)) kind = 0x20;
1516 else if (r_ptr->flags1 & (RF1_MALE)) kind = 0x10;
1518 /* Ignore the gender (if desired) */
1519 if (!m_ptr || !pron) kind = 0x00;
1522 /* Assume simple result */
1523 res = _("何か", "it");
1525 /* Brute force: split on the possibilities */
1526 switch (kind + (mode & (MD_INDEF_HIDDEN | MD_POSSESSIVE | MD_OBJECTIVE)))
1528 /* Neuter, or unknown */
1530 case 0x00: res = "何か"; break;
1531 case 0x00 + (MD_OBJECTIVE): res = "何か"; break;
1532 case 0x00 + (MD_POSSESSIVE): res = "何かの"; break;
1533 case 0x00 + (MD_POSSESSIVE | MD_OBJECTIVE): res = "何か自身"; break;
1534 case 0x00 + (MD_INDEF_HIDDEN): res = "何か"; break;
1535 case 0x00 + (MD_INDEF_HIDDEN | MD_OBJECTIVE): res = "何か"; break;
1536 case 0x00 + (MD_INDEF_HIDDEN | MD_POSSESSIVE): res = "何か"; break;
1537 case 0x00 + (MD_INDEF_HIDDEN | MD_POSSESSIVE | MD_OBJECTIVE): res = "それ自身"; break;
1539 case 0x00: res = "it"; break;
1540 case 0x00 + (MD_OBJECTIVE): res = "it"; break;
1541 case 0x00 + (MD_POSSESSIVE): res = "its"; break;
1542 case 0x00 + (MD_POSSESSIVE | MD_OBJECTIVE): res = "itself"; break;
1543 case 0x00 + (MD_INDEF_HIDDEN): res = "something"; break;
1544 case 0x00 + (MD_INDEF_HIDDEN | MD_OBJECTIVE): res = "something"; break;
1545 case 0x00 + (MD_INDEF_HIDDEN | MD_POSSESSIVE): res = "something's"; break;
1546 case 0x00 + (MD_INDEF_HIDDEN | MD_POSSESSIVE | MD_OBJECTIVE): res = "itself"; break;
1550 /* Male (assume human if vague) */
1552 case 0x10: res = "彼"; break;
1553 case 0x10 + (MD_OBJECTIVE): res = "彼"; break;
1554 case 0x10 + (MD_POSSESSIVE): res = "彼の"; break;
1555 case 0x10 + (MD_POSSESSIVE | MD_OBJECTIVE): res = "彼自身"; break;
1556 case 0x10 + (MD_INDEF_HIDDEN): res = "誰か"; break;
1557 case 0x10 + (MD_INDEF_HIDDEN | MD_OBJECTIVE): res = "誰か"; break;
1558 case 0x10 + (MD_INDEF_HIDDEN | MD_POSSESSIVE): res = "誰かの"; break;
1559 case 0x10 + (MD_INDEF_HIDDEN | MD_POSSESSIVE | MD_OBJECTIVE): res = "彼自身"; break;
1561 case 0x10: res = "he"; break;
1562 case 0x10 + (MD_OBJECTIVE): res = "him"; break;
1563 case 0x10 + (MD_POSSESSIVE): res = "his"; break;
1564 case 0x10 + (MD_POSSESSIVE | MD_OBJECTIVE): res = "himself"; break;
1565 case 0x10 + (MD_INDEF_HIDDEN): res = "someone"; break;
1566 case 0x10 + (MD_INDEF_HIDDEN | MD_OBJECTIVE): res = "someone"; break;
1567 case 0x10 + (MD_INDEF_HIDDEN | MD_POSSESSIVE): res = "someone's"; break;
1568 case 0x10 + (MD_INDEF_HIDDEN | MD_POSSESSIVE | MD_OBJECTIVE): res = "himself"; break;
1572 /* Female (assume human if vague) */
1574 case 0x20: res = "彼女"; break;
1575 case 0x20 + (MD_OBJECTIVE): res = "彼女"; break;
1576 case 0x20 + (MD_POSSESSIVE): res = "彼女の"; break;
1577 case 0x20 + (MD_POSSESSIVE | MD_OBJECTIVE): res = "彼女自身"; break;
1578 case 0x20 + (MD_INDEF_HIDDEN): res = "誰か"; break;
1579 case 0x20 + (MD_INDEF_HIDDEN | MD_OBJECTIVE): res = "誰か"; break;
1580 case 0x20 + (MD_INDEF_HIDDEN | MD_POSSESSIVE): res = "誰かの"; break;
1581 case 0x20 + (MD_INDEF_HIDDEN | MD_POSSESSIVE | MD_OBJECTIVE): res = "彼女自身"; break;
1583 case 0x20: res = "she"; break;
1584 case 0x20 + (MD_OBJECTIVE): res = "her"; break;
1585 case 0x20 + (MD_POSSESSIVE): res = "her"; break;
1586 case 0x20 + (MD_POSSESSIVE | MD_OBJECTIVE): res = "herself"; break;
1587 case 0x20 + (MD_INDEF_HIDDEN): res = "someone"; break;
1588 case 0x20 + (MD_INDEF_HIDDEN | MD_OBJECTIVE): res = "someone"; break;
1589 case 0x20 + (MD_INDEF_HIDDEN | MD_POSSESSIVE): res = "someone's"; break;
1590 case 0x20 + (MD_INDEF_HIDDEN | MD_POSSESSIVE | MD_OBJECTIVE): res = "herself"; break;
1594 /* Copy the result */
1595 (void)strcpy(desc, res);
1599 /* Handle visible monsters, "reflexive" request */
1600 else if ((mode & (MD_POSSESSIVE | MD_OBJECTIVE)) == (MD_POSSESSIVE | MD_OBJECTIVE))
1602 /* The monster is visible, so use its gender */
1604 if (r_ptr->flags1 & (RF1_FEMALE)) strcpy(desc, "彼女自身");
1605 else if (r_ptr->flags1 & (RF1_MALE)) strcpy(desc, "彼自身");
1606 else strcpy(desc, "それ自身");
1608 if (r_ptr->flags1 & RF1_FEMALE) strcpy(desc, "herself");
1609 else if (r_ptr->flags1 & RF1_MALE) strcpy(desc, "himself");
1610 else strcpy(desc, "itself");
1615 /* Handle all other visible monster requests */
1619 if (is_pet(m_ptr) && !is_original_ap(m_ptr))
1625 while(strncmp(t, "』", 2) && *t) t++;
1629 (void)sprintf(desc, "%s?』", buf);
1632 (void)sprintf(desc, "%s?", name);
1634 (void)sprintf(desc, "%s?", name);
1639 /* It could be a Unique */
1640 if ((r_ptr->flags1 & RF1_UNIQUE) && !(p_ptr->image && !(mode & MD_IGNORE_HALLU)))
1642 /* Start with the name (thus nominative and objective) */
1643 if ((m_ptr->mflag2 & MFLAG2_CHAMELEON) && !(mode & MD_TRUE_NAME))
1649 while (strncmp(t, "』", 2) && *t) t++;
1653 (void)sprintf(desc, "%s?』", buf);
1656 (void)sprintf(desc, "%s?", name);
1658 (void)sprintf(desc, "%s?", name);
1662 /* Inside monster arena, and it is not your mount */
1663 else if (p_ptr->inside_battle &&
1664 !(p_ptr->riding && (&m_list[p_ptr->riding] == m_ptr)))
1666 /* It is a fake unique monster */
1667 (void)sprintf(desc, _("%sもどき", "fake %s"), name);
1672 (void)strcpy(desc, name);
1676 /* It could be an indefinite monster */
1677 else if (mode & MD_INDEF_VISIBLE)
1679 /* XXX Check plurality for "some" */
1681 /* Indefinite monsters need an indefinite article */
1683 (void)strcpy(desc, "");
1685 (void)strcpy(desc, is_a_vowel(name[0]) ? "an " : "a ");
1688 (void)strcat(desc, name);
1691 /* It could be a normal, definite, monster */
1694 /* Definite monsters need a definite article */
1696 (void)strcpy(desc, _("あなたの", "your "));
1698 (void)strcpy(desc, _("", "the "));
1700 (void)strcat(desc, name);
1703 if (m_ptr->nickname)
1705 sprintf(buf,_("「%s」", " called %s"),quark_str(m_ptr->nickname));
1709 if (p_ptr->riding && (&m_list[p_ptr->riding] == m_ptr))
1711 strcat(desc,_("(乗馬中)", "(riding)"));
1714 if ((mode & MD_IGNORE_HALLU) && (m_ptr->mflag2 & MFLAG2_CHAMELEON))
1716 if (r_ptr->flags1 & RF1_UNIQUE)
1718 strcat(desc,_("(カメレオンの王)", "(Chameleon Lord)"));
1722 strcat(desc,_("(カメレオン)", "(Chameleon)"));
1726 if ((mode & MD_IGNORE_HALLU) && !is_original_ap(m_ptr))
1728 strcat(desc, format("(%s)", r_name + r_info[m_ptr->r_idx].name));
1731 /* Handle the Possessive as a special afterthought */
1732 if (mode & MD_POSSESSIVE)
1734 /* XXX Check for trailing "s" */
1736 /* Simply append "apostrophe" and "s" */
1737 (void)strcat(desc, _("の", "'s"));
1745 * @brief モンスターの調査による思い出補完処理 / Learn about a monster (by "probing" it)
1746 * @param r_idx 補完されるモンスター種族ID
1747 * @return 明らかになった情報の度数
1749 * Return the number of new flags learnt. -Mogami-
1751 int lore_do_probe(MONRACE_IDX r_idx)
1753 monster_race *r_ptr = &r_info[r_idx];
1757 /* Maximal info about awareness */
1758 if (r_ptr->r_wake != MAX_UCHAR) n++;
1759 if (r_ptr->r_ignore != MAX_UCHAR) n++;
1760 r_ptr->r_wake = r_ptr->r_ignore = MAX_UCHAR;
1762 /* Observe "maximal" attacks */
1763 for (i = 0; i < 4; i++)
1765 /* Examine "actual" blows */
1766 if (r_ptr->blow[i].effect || r_ptr->blow[i].method)
1768 /* Maximal observations */
1769 if (r_ptr->r_blows[i] != MAX_UCHAR) n++;
1770 r_ptr->r_blows[i] = MAX_UCHAR;
1776 (((r_ptr->flags1 & RF1_DROP_4D2) ? 8 : 0) +
1777 ((r_ptr->flags1 & RF1_DROP_3D2) ? 6 : 0) +
1778 ((r_ptr->flags1 & RF1_DROP_2D2) ? 4 : 0) +
1779 ((r_ptr->flags1 & RF1_DROP_1D2) ? 2 : 0) +
1780 ((r_ptr->flags1 & RF1_DROP_90) ? 1 : 0) +
1781 ((r_ptr->flags1 & RF1_DROP_60) ? 1 : 0));
1783 /* Only "valid" drops */
1784 if (!(r_ptr->flags1 & RF1_ONLY_GOLD))
1786 if (r_ptr->r_drop_item != tmp_byte) n++;
1787 r_ptr->r_drop_item = tmp_byte;
1789 if (!(r_ptr->flags1 & RF1_ONLY_ITEM))
1791 if (r_ptr->r_drop_gold != tmp_byte) n++;
1792 r_ptr->r_drop_gold = tmp_byte;
1795 /* Observe many spells */
1796 if (r_ptr->r_cast_spell != MAX_UCHAR) n++;
1797 r_ptr->r_cast_spell = MAX_UCHAR;
1799 /* Count unknown flags */
1800 for (i = 0; i < 32; i++)
1802 if (!(r_ptr->r_flags1 & (1L << i)) &&
1803 (r_ptr->flags1 & (1L << i))) n++;
1804 if (!(r_ptr->r_flags2 & (1L << i)) &&
1805 (r_ptr->flags2 & (1L << i))) n++;
1806 if (!(r_ptr->r_flags3 & (1L << i)) &&
1807 (r_ptr->flags3 & (1L << i))) n++;
1808 if (!(r_ptr->r_flags4 & (1L << i)) &&
1809 (r_ptr->flags4 & (1L << i))) n++;
1810 if (!(r_ptr->r_flags5 & (1L << i)) &&
1811 (r_ptr->a_ability_flags1 & (1L << i))) n++;
1812 if (!(r_ptr->r_flags6 & (1L << i)) &&
1813 (r_ptr->a_ability_flags2 & (1L << i))) n++;
1814 if (!(r_ptr->r_flagsr & (1L << i)) &&
1815 (r_ptr->flagsr & (1L << i))) n++;
1817 /* r_flags7 is actually unused */
1819 if (!(r_ptr->r_flags7 & (1L << i)) &&
1820 (r_ptr->flags7 & (1L << i))) n++;
1824 /* Know all the flags */
1825 r_ptr->r_flags1 = r_ptr->flags1;
1826 r_ptr->r_flags2 = r_ptr->flags2;
1827 r_ptr->r_flags3 = r_ptr->flags3;
1828 r_ptr->r_flags4 = r_ptr->flags4;
1829 r_ptr->r_flags5 = r_ptr->a_ability_flags1;
1830 r_ptr->r_flags6 = r_ptr->a_ability_flags2;
1831 r_ptr->r_flagsr = r_ptr->flagsr;
1833 /* r_flags7 is actually unused */
1834 /* r_ptr->r_flags7 = r_ptr->flags7; */
1836 /* Know about evolution */
1837 if (!(r_ptr->r_xtra1 & MR1_SINKA)) n++;
1838 r_ptr->r_xtra1 |= MR1_SINKA;
1840 /* Update monster recall window */
1841 if (p_ptr->monster_race_idx == r_idx)
1843 p_ptr->window |= (PW_MONSTER);
1846 /* Return the number of new flags learnt */
1852 * @brief モンスターの撃破に伴うドロップ情報の保管処理 / Take note that the given monster just dropped some treasure
1853 * @param m_idx モンスター情報のID
1854 * @param num_item 手に入れたアイテム数
1855 * @param num_gold 手に入れた財宝の単位数
1858 * Note that learning the "GOOD"/"GREAT" flags gives information
1859 * about the treasure (even when the monster is killed for the first
1860 * time, such as uniques, and the treasure has not been examined yet).
1862 * This "indirect" method is used to prevent the player from learning
1863 * exactly how much treasure a monster can drop from observing only
1864 * a single example of a drop. This method actually observes how much
1865 * gold and items are dropped, and remembers that information to be
1866 * described later by the monster recall code.
1868 void lore_treasure(MONSTER_IDX m_idx, ITEM_NUMBER num_item, ITEM_NUMBER num_gold)
1870 monster_type *m_ptr = &m_list[m_idx];
1872 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1874 /* If the monster doesn't have original appearance, don't note */
1875 if (!is_original_ap(m_ptr)) return;
1877 /* Note the number of things dropped */
1878 if (num_item > r_ptr->r_drop_item) r_ptr->r_drop_item = num_item;
1879 if (num_gold > r_ptr->r_drop_gold) r_ptr->r_drop_gold = num_gold;
1881 /* Hack -- memorize the good/great flags */
1882 if (r_ptr->flags1 & (RF1_DROP_GOOD)) r_ptr->r_flags1 |= (RF1_DROP_GOOD);
1883 if (r_ptr->flags1 & (RF1_DROP_GREAT)) r_ptr->r_flags1 |= (RF1_DROP_GREAT);
1885 /* Update monster recall window */
1886 if (p_ptr->monster_race_idx == m_ptr->r_idx)
1888 p_ptr->window |= (PW_MONSTER);
1894 * @brief ELDRITCH_HORRORによるプレイヤーの精神破壊処理
1895 * @param m_ptr ELDRITCH_HORRORを引き起こしたモンスターの参照ポインタ
1896 * @param necro 暗黒領域魔法の詠唱失敗によるものならばTRUEを返す
1899 void sanity_blast(monster_type *m_ptr, bool necro)
1903 if (p_ptr->inside_battle || !character_dungeon) return;
1905 if (!necro && m_ptr)
1907 GAME_TEXT m_name[MAX_NLEN];
1908 monster_race *r_ptr = &r_info[m_ptr->ap_r_idx];
1910 power = r_ptr->level / 2;
1912 monster_desc(m_name, m_ptr, 0);
1914 if (!(r_ptr->flags1 & RF1_UNIQUE))
1916 if (r_ptr->flags1 & RF1_FRIENDS)
1921 if (!is_loading_now)
1922 return; /* No effect yet, just loaded... */
1925 return; /* Cannot see it for some reason */
1927 if (!(r_ptr->flags2 & RF2_ELDRITCH_HORROR))
1931 return; /* Pet eldritch horrors are safe most of the time */
1933 if (randint1(100) > power) return;
1935 if (saving_throw(p_ptr->skill_sav - power))
1937 return; /* Save, no adverse effects */
1942 /* Something silly happens... */
1944 msg_format("%s%sの顔を見てしまった!",
1945 funny_desc[randint0(MAX_SAN_FUNNY)], m_name);
1947 msg_format("You behold the %s visage of %s!",
1948 funny_desc[randint0(MAX_SAN_FUNNY)], m_name);
1953 msg_print(funny_comments[randint0(MAX_SAN_COMMENT)]);
1954 p_ptr->image = p_ptr->image + randint1(r_ptr->level);
1957 return; /* Never mind; we can't see it clearly enough */
1960 /* Something frightening happens... */
1962 msg_format("%s%sの顔を見てしまった!",
1963 horror_desc[randint0(MAX_SAN_HORROR)], m_name);
1965 msg_format("You behold the %s visage of %s!",
1966 horror_desc[randint0(MAX_SAN_HORROR)], m_name);
1969 r_ptr->r_flags2 |= RF2_ELDRITCH_HORROR;
1971 /* Demon characters are unaffected */
1972 if (prace_is_(RACE_IMP) || prace_is_(RACE_DEMON) || (mimic_info[p_ptr->mimic_form].MIMIC_FLAGS & MIMIC_IS_DEMON)) return;
1973 if (p_ptr->wizard) return;
1975 /* Undead characters are 50% likely to be unaffected */
1976 if (prace_is_(RACE_SKELETON) || prace_is_(RACE_ZOMBIE)
1977 || prace_is_(RACE_VAMPIRE) || prace_is_(RACE_SPECTRE) ||
1978 (mimic_info[p_ptr->mimic_form].MIMIC_FLAGS & MIMIC_IS_UNDEAD))
1980 if (saving_throw(25 + p_ptr->lev)) return;
1985 monster_race *r_ptr;
1986 GAME_TEXT m_name[MAX_NLEN];
1989 get_mon_num_prep(get_nightmare, NULL);
1991 r_ptr = &r_info[get_mon_num(MAX_DEPTH)];
1992 power = r_ptr->level + 10;
1993 desc = r_name + r_ptr->name;
1995 get_mon_num_prep(NULL, NULL);
1998 if (!(r_ptr->flags1 & RF1_UNIQUE))
1999 sprintf(m_name, "%s %s", (is_a_vowel(desc[0]) ? "an" : "a"), desc);
2002 sprintf(m_name, "%s", desc);
2004 if (!(r_ptr->flags1 & RF1_UNIQUE))
2006 if (r_ptr->flags1 & RF1_FRIENDS) power /= 2;
2010 if (saving_throw(p_ptr->skill_sav * 100 / power))
2012 msg_format(_("夢の中で%sに追いかけられた。", "%^s chases you through your dreams."), m_name);
2019 /* Something silly happens... */
2020 msg_format(_("%s%sの顔を見てしまった!", "You behold the %s visage of %s!"),
2021 funny_desc[randint0(MAX_SAN_FUNNY)], m_name);
2025 msg_print(funny_comments[randint0(MAX_SAN_COMMENT)]);
2026 p_ptr->image = p_ptr->image + randint1(r_ptr->level);
2029 /* Never mind; we can't see it clearly enough */
2033 /* Something frightening happens... */
2034 msg_format(_("%s%sの顔を見てしまった!", "You behold the %s visage of %s!"),
2035 horror_desc[randint0(MAX_SAN_HORROR)], desc);
2037 r_ptr->r_flags2 |= RF2_ELDRITCH_HORROR;
2039 if (!p_ptr->mimic_form)
2041 switch (p_ptr->prace)
2043 /* Demons may make a saving throw */
2046 if (saving_throw(20 + p_ptr->lev)) return;
2048 /* Undead may make a saving throw */
2053 if (saving_throw(10 + p_ptr->lev)) return;
2059 /* Demons may make a saving throw */
2060 if (mimic_info[p_ptr->mimic_form].MIMIC_FLAGS & MIMIC_IS_DEMON)
2062 if (saving_throw(20 + p_ptr->lev)) return;
2064 /* Undead may make a saving throw */
2065 else if (mimic_info[p_ptr->mimic_form].MIMIC_FLAGS & MIMIC_IS_UNDEAD)
2067 if (saving_throw(10 + p_ptr->lev)) return;
2073 msg_print(_("ネクロノミコンを読んで正気を失った!", "Your sanity is shaken by reading the Necronomicon!"));
2076 if (saving_throw(p_ptr->skill_sav - power))
2082 (void)do_dec_stat(A_INT);
2083 } while (randint0(100) > p_ptr->skill_sav && one_in_(2));
2086 (void)do_dec_stat(A_WIS);
2087 } while (randint0(100) > p_ptr->skill_sav && one_in_(2));
2089 switch (randint1(21))
2092 if (!(p_ptr->muta3 & MUT3_MORONIC) && one_in_(5))
2094 if ((p_ptr->stat_use[A_INT] < 4) && (p_ptr->stat_use[A_WIS] < 4))
2096 msg_print(_("あなたは完璧な馬鹿になったような気がした。しかしそれは元々だった。", "You turn into an utter moron!"));
2100 msg_print(_("あなたは完璧な馬鹿になった!", "You turn into an utter moron!"));
2103 if (p_ptr->muta3 & MUT3_HYPER_INT)
2105 msg_print(_("あなたの脳は生体コンピュータではなくなった。", "Your brain is no longer a living computer."));
2106 p_ptr->muta3 &= ~(MUT3_HYPER_INT);
2108 p_ptr->muta3 |= MUT3_MORONIC;
2114 if (!(p_ptr->muta2 & MUT2_COWARDICE) && !p_ptr->resist_fear)
2116 msg_print(_("あなたはパラノイアになった!", "You become paranoid!"));
2118 /* Duh, the following should never happen, but anyway... */
2119 if (p_ptr->muta3 & MUT3_FEARLESS)
2121 msg_print(_("あなたはもう恐れ知らずではなくなった。", "You are no longer fearless."));
2122 p_ptr->muta3 &= ~(MUT3_FEARLESS);
2125 p_ptr->muta2 |= MUT2_COWARDICE;
2131 if (!(p_ptr->muta2 & MUT2_HALLU) && !p_ptr->resist_chaos)
2133 msg_print(_("幻覚をひき起こす精神錯乱に陥った!", "You are afflicted by a hallucinatory insanity!"));
2134 p_ptr->muta2 |= MUT2_HALLU;
2140 if (!(p_ptr->muta2 & MUT2_BERS_RAGE))
2142 msg_print(_("激烈な感情の発作におそわれるようになった!", "You become subject to fits of berserk rage!"));
2143 p_ptr->muta2 |= MUT2_BERS_RAGE;
2153 if (!p_ptr->resist_conf)
2155 (void)set_confused(p_ptr->confused + randint0(4) + 4);
2157 if (!p_ptr->free_act)
2159 (void)set_paralyzed(p_ptr->paralyzed + randint0(4) + 4);
2161 if (!p_ptr->resist_chaos)
2163 (void)set_image(p_ptr->image + randint0(250) + 150);
2172 if (lose_all_info())
2173 msg_print(_("あまりの恐怖に全てのことを忘れてしまった!", "You forget everything in your utmost terror!"));
2177 p_ptr->update |= PU_BONUS;
2182 * @brief モンスターの各情報を更新する / This function updates the monster record of the given monster
2183 * @param m_idx 更新するモンスター情報のID
2184 * @param full プレイヤーとの距離更新を行うならばtrue
2187 * This involves extracting the distance to the player (if requested),
2188 * and then checking for visibility (natural, infravision, see-invis,
2189 * telepathy), updating the monster visibility flag, redrawing (or
2190 * erasing) the monster when its visibility changes, and taking note
2191 * of any interesting monster flags (cold-blooded, invisible, etc).
2193 * Note the new "mflag" field which encodes several monster state flags,
2194 * including "view" for when the monster is currently in line of sight,
2195 * and "mark" for when the monster is currently visible via detection.
2197 * The only monster fields that are changed here are "cdis" (the
2198 * distance from the player), "ml" (visible to the player), and
2199 * "mflag" (to maintain the "MFLAG_VIEW" flag).
2201 * Note the special "update_monsters()" function which can be used to
2202 * call this function once for every monster.
2204 * Note the "full" flag which requests that the "cdis" field be updated,
2205 * this is only needed when the monster (or the player) has moved.
2207 * Every time a monster moves, we must call this function for that
2208 * monster, and update the distance, and the visibility. Every time
2209 * the player moves, we must call this function for every monster, and
2210 * update the distance, and the visibility. Whenever the player "state"
2211 * changes in certain ways ("blindness", "infravision", "telepathy",
2212 * and "see invisible"), we must call this function for every monster,
2213 * and update the visibility.
2215 * Routines that change the "illumination" of a grid must also call this
2216 * function for any monster in that grid, since the "visibility" of some
2217 * monsters may be based on the illumination of their grid.
2219 * Note that this function is called once per monster every time the
2220 * player moves. When the player is running, this function is one
2221 * of the primary bottlenecks, along with "update_view()" and the
2222 * "process_monsters()" code, so efficiency is important.
2224 * Note the optimized "inline" version of the "distance()" function.
2226 * A monster is "visible" to the player if (1) it has been detected
2227 * by the player, (2) it is close to the player and the player has
2228 * telepathy, or (3) it is close to the player, and in line of sight
2229 * of the player, and it is "illuminated" by some combination of
2230 * infravision, torch light, or permanent light (invisible monsters
2231 * are only affected by "light" if the player can see invisible).
2233 * Monsters which are not on the current panel may be "visible" to
2234 * the player, and their descriptions will include an "offscreen"
2235 * reference. Currently, offscreen monsters cannot be targetted
2236 * or viewed directly, but old targets will remain set. XXX XXX
2238 * The player can choose to be disturbed by several things, including
2239 * "disturb_move" (monster which is viewable moves in some way), and
2240 * "disturb_near" (monster which is "easily" viewable moves in some
2241 * way). Note that "moves" includes "appears" and "disappears".
2243 void update_monster(MONSTER_IDX m_idx, bool full)
2245 monster_type *m_ptr = &m_list[m_idx];
2247 monster_race *r_ptr = &r_info[m_ptr->r_idx];
2249 bool do_disturb = disturb_move;
2253 /* Current location */
2260 /* Seen by vision */
2263 /* Non-Ninja player in the darkness */
2264 bool in_darkness = (d_info[dungeon_type].flags1 & DF1_DARKNESS) && !p_ptr->see_nocto;
2269 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
2271 if (ap_r_ptr->r_tkills && ap_r_ptr->level >= p_ptr->lev)
2275 /* Compute distance */
2278 /* Distance components */
2279 int dy = (p_ptr->y > fy) ? (p_ptr->y - fy) : (fy - p_ptr->y);
2280 int dx = (p_ptr->x > fx) ? (p_ptr->x - fx) : (fx - p_ptr->x);
2282 /* Approximate distance */
2283 d = (dy > dx) ? (dy + (dx>>1)) : (dx + (dy>>1));
2285 /* Restrict distance */
2286 if (d > 255) d = 255;
2290 /* Save the distance */
2294 /* Extract distance */
2297 /* Extract the distance */
2303 if (m_ptr->mflag2 & (MFLAG2_MARK)) flag = TRUE;
2307 if (d <= (in_darkness ? MAX_SIGHT / 2 : MAX_SIGHT))
2309 if (!in_darkness || (d <= MAX_SIGHT / 4))
2311 if (p_ptr->special_defense & KATA_MUSOU)
2316 if (is_original_ap(m_ptr) && !p_ptr->image)
2318 /* Hack -- Memorize mental flags */
2319 if (r_ptr->flags2 & (RF2_SMART)) r_ptr->r_flags2 |= (RF2_SMART);
2320 if (r_ptr->flags2 & (RF2_STUPID)) r_ptr->r_flags2 |= (RF2_STUPID);
2324 /* Basic telepathy */
2325 /* Snipers get telepathy when they concentrate deeper */
2326 else if (p_ptr->telepathy)
2328 /* Empty mind, no telepathy */
2329 if (r_ptr->flags2 & (RF2_EMPTY_MIND))
2331 /* Memorize flags */
2332 if (is_original_ap(m_ptr) && !p_ptr->image) r_ptr->r_flags2 |= (RF2_EMPTY_MIND);
2335 /* Weird mind, occasional telepathy */
2336 else if (r_ptr->flags2 & (RF2_WEIRD_MIND))
2338 /* One in ten individuals are detectable */
2339 if ((m_idx % 10) == 5)
2344 if (is_original_ap(m_ptr) && !p_ptr->image)
2346 /* Memorize flags */
2347 r_ptr->r_flags2 |= (RF2_WEIRD_MIND);
2349 /* Hack -- Memorize mental flags */
2350 if (r_ptr->flags2 & (RF2_SMART)) r_ptr->r_flags2 |= (RF2_SMART);
2351 if (r_ptr->flags2 & (RF2_STUPID)) r_ptr->r_flags2 |= (RF2_STUPID);
2356 /* Normal mind, allow telepathy */
2362 if (is_original_ap(m_ptr) && !p_ptr->image)
2364 /* Hack -- Memorize mental flags */
2365 if (r_ptr->flags2 & (RF2_SMART)) r_ptr->r_flags2 |= (RF2_SMART);
2366 if (r_ptr->flags2 & (RF2_STUPID)) r_ptr->r_flags2 |= (RF2_STUPID);
2371 /* Magical sensing */
2372 if ((p_ptr->esp_animal) && (r_ptr->flags3 & (RF3_ANIMAL)))
2375 if (is_original_ap(m_ptr) && !p_ptr->image) r_ptr->r_flags3 |= (RF3_ANIMAL);
2378 /* Magical sensing */
2379 if ((p_ptr->esp_undead) && (r_ptr->flags3 & (RF3_UNDEAD)))
2382 if (is_original_ap(m_ptr) && !p_ptr->image) r_ptr->r_flags3 |= (RF3_UNDEAD);
2385 /* Magical sensing */
2386 if ((p_ptr->esp_demon) && (r_ptr->flags3 & (RF3_DEMON)))
2389 if (is_original_ap(m_ptr) && !p_ptr->image) r_ptr->r_flags3 |= (RF3_DEMON);
2392 /* Magical sensing */
2393 if ((p_ptr->esp_orc) && (r_ptr->flags3 & (RF3_ORC)))
2396 if (is_original_ap(m_ptr) && !p_ptr->image) r_ptr->r_flags3 |= (RF3_ORC);
2399 /* Magical sensing */
2400 if ((p_ptr->esp_troll) && (r_ptr->flags3 & (RF3_TROLL)))
2403 if (is_original_ap(m_ptr) && !p_ptr->image) r_ptr->r_flags3 |= (RF3_TROLL);
2406 /* Magical sensing */
2407 if ((p_ptr->esp_giant) && (r_ptr->flags3 & (RF3_GIANT)))
2410 if (is_original_ap(m_ptr) && !p_ptr->image) r_ptr->r_flags3 |= (RF3_GIANT);
2413 /* Magical sensing */
2414 if ((p_ptr->esp_dragon) && (r_ptr->flags3 & (RF3_DRAGON)))
2417 if (is_original_ap(m_ptr) && !p_ptr->image) r_ptr->r_flags3 |= (RF3_DRAGON);
2420 /* Magical sensing */
2421 if ((p_ptr->esp_human) && (r_ptr->flags2 & (RF2_HUMAN)))
2424 if (is_original_ap(m_ptr) && !p_ptr->image) r_ptr->r_flags2 |= (RF2_HUMAN);
2427 /* Magical sensing */
2428 if ((p_ptr->esp_evil) && (r_ptr->flags3 & (RF3_EVIL)))
2431 if (is_original_ap(m_ptr) && !p_ptr->image) r_ptr->r_flags3 |= (RF3_EVIL);
2434 /* Magical sensing */
2435 if ((p_ptr->esp_good) && (r_ptr->flags3 & (RF3_GOOD)))
2438 if (is_original_ap(m_ptr) && !p_ptr->image) r_ptr->r_flags3 |= (RF3_GOOD);
2441 /* Magical sensing */
2442 if ((p_ptr->esp_nonliving) &&
2443 ((r_ptr->flags3 & (RF3_DEMON | RF3_UNDEAD | RF3_NONLIVING)) == RF3_NONLIVING))
2446 if (is_original_ap(m_ptr) && !p_ptr->image) r_ptr->r_flags3 |= (RF3_NONLIVING);
2449 /* Magical sensing */
2450 if ((p_ptr->esp_unique) && (r_ptr->flags1 & (RF1_UNIQUE)))
2453 if (is_original_ap(m_ptr) && !p_ptr->image) r_ptr->r_flags1 |= (RF1_UNIQUE);
2457 /* Normal line of sight, and not blind */
2458 if (player_has_los_bold(fy, fx) && !p_ptr->blind)
2460 bool do_invisible = FALSE;
2461 bool do_cold_blood = FALSE;
2463 /* Snipers can see targets in darkness when they concentrate deeper */
2464 if (p_ptr->concent >= CONCENT_RADAR_THRESHOLD)
2470 /* Use "infravision" */
2471 if (d <= p_ptr->see_infra)
2473 /* Handle "cold blooded" monsters */
2474 if ((r_ptr->flags2 & (RF2_COLD_BLOOD | RF2_AURA_FIRE)) == RF2_COLD_BLOOD)
2476 do_cold_blood = TRUE;
2479 /* Handle "warm blooded" monsters */
2487 /* Use "illumination" */
2488 if (player_can_see_bold(fy, fx))
2490 /* Handle "invisible" monsters */
2491 if (r_ptr->flags2 & (RF2_INVISIBLE))
2493 do_invisible = TRUE;
2503 /* Handle "normal" monsters */
2514 if (is_original_ap(m_ptr) && !p_ptr->image)
2516 /* Memorize flags */
2517 if (do_invisible) r_ptr->r_flags2 |= (RF2_INVISIBLE);
2518 if (do_cold_blood) r_ptr->r_flags2 |= (RF2_COLD_BLOOD);
2525 /* The monster is now visible */
2528 /* It was previously unseen */
2531 /* Mark as visible */
2534 /* Draw the monster */
2537 /* Update health bar as needed */
2538 if (p_ptr->health_who == m_idx) p_ptr->redraw |= (PR_HEALTH);
2539 if (p_ptr->riding == m_idx) p_ptr->redraw |= (PR_UHEALTH);
2541 /* Hack -- Count "fresh" sightings */
2544 if ((m_ptr->ap_r_idx == MON_KAGE) && (r_info[MON_KAGE].r_sights < MAX_SHORT))
2545 r_info[MON_KAGE].r_sights++;
2546 else if (is_original_ap(m_ptr) && (r_ptr->r_sights < MAX_SHORT))
2550 /* Eldritch Horror */
2551 if (r_info[m_ptr->ap_r_idx].flags2 & RF2_ELDRITCH_HORROR)
2553 sanity_blast(m_ptr, FALSE);
2556 /* Disturb on appearance */
2557 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)))
2559 if (disturb_pets || is_hostile(m_ptr))
2560 disturb(TRUE, TRUE);
2565 /* The monster is not visible */
2568 /* It was previously seen */
2571 /* Mark as not visible */
2574 /* Erase the monster */
2577 /* Update health bar as needed */
2578 if (p_ptr->health_who == m_idx) p_ptr->redraw |= (PR_HEALTH);
2579 if (p_ptr->riding == m_idx) p_ptr->redraw |= (PR_UHEALTH);
2581 /* Disturb on disappearance */
2584 if (disturb_pets || is_hostile(m_ptr))
2585 disturb(TRUE, TRUE);
2591 /* The monster is now easily visible */
2595 if (!(m_ptr->mflag & (MFLAG_VIEW)))
2597 /* Mark as easily visible */
2598 m_ptr->mflag |= (MFLAG_VIEW);
2600 /* Disturb on appearance */
2603 if (disturb_pets || is_hostile(m_ptr))
2604 disturb(TRUE, TRUE);
2609 /* The monster is not easily visible */
2613 if (m_ptr->mflag & (MFLAG_VIEW))
2615 /* Mark as not easily visible */
2616 m_ptr->mflag &= ~(MFLAG_VIEW);
2618 /* Disturb on disappearance */
2621 if (disturb_pets || is_hostile(m_ptr))
2622 disturb(TRUE, TRUE);
2630 * @brief 単純に生存している全モンスターの更新処理を行う / This function simply updates all the (non-dead) monsters (see above).
2631 * @param full 距離更新を行うならtrue
2634 void update_monsters(bool full)
2638 /* Update each (live) monster */
2639 for (i = 1; i < m_max; i++)
2641 monster_type *m_ptr = &m_list[i];
2643 /* Skip dead monsters */
2644 if (!m_ptr->r_idx) continue;
2645 update_monster(i, full);
2651 * @brief カメレオンの王の変身対象となるモンスターかどうか判定する / Hack -- the index of the summoning monster
2652 * @param r_idx モンスター種族ID
2653 * @return 対象にできるならtrueを返す
2655 static bool monster_hook_chameleon_lord(MONRACE_IDX r_idx)
2657 monster_race *r_ptr = &r_info[r_idx];
2658 monster_type *m_ptr = &m_list[chameleon_change_m_idx];
2659 monster_race *old_r_ptr = &r_info[m_ptr->r_idx];
2661 if (!(r_ptr->flags1 & (RF1_UNIQUE))) return FALSE;
2662 if (r_ptr->flags7 & (RF7_FRIENDLY | RF7_CHAMELEON)) return FALSE;
2664 if (ABS(r_ptr->level - r_info[MON_CHAMELEON_K].level) > 5) return FALSE;
2666 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))
2669 if (!monster_can_cross_terrain(cave[m_ptr->fy][m_ptr->fx].feat, r_ptr, 0)) return FALSE;
2672 if (!(old_r_ptr->flags7 & RF7_CHAMELEON))
2674 if (monster_has_hostile_align(m_ptr, 0, 0, r_ptr)) return FALSE;
2678 else if (summon_specific_who > 0)
2680 if (monster_has_hostile_align(&m_list[summon_specific_who], 0, 0, r_ptr)) return FALSE;
2687 * @brief カメレオンの変身対象となるモンスターかどうか判定する / Hack -- the index of the summoning monster
2688 * @param r_idx モンスター種族ID
2689 * @return 対象にできるならtrueを返す
2691 static bool monster_hook_chameleon(MONRACE_IDX r_idx)
2693 monster_race *r_ptr = &r_info[r_idx];
2694 monster_type *m_ptr = &m_list[chameleon_change_m_idx];
2695 monster_race *old_r_ptr = &r_info[m_ptr->r_idx];
2697 if (r_ptr->flags1 & (RF1_UNIQUE)) return FALSE;
2698 if (r_ptr->flags2 & RF2_MULTIPLY) return FALSE;
2699 if (r_ptr->flags7 & (RF7_FRIENDLY | RF7_CHAMELEON)) return FALSE;
2701 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))
2704 if (!monster_can_cross_terrain(cave[m_ptr->fy][m_ptr->fx].feat, r_ptr, 0)) return FALSE;
2707 if (!(old_r_ptr->flags7 & RF7_CHAMELEON))
2709 if ((old_r_ptr->flags3 & RF3_GOOD) && !(r_ptr->flags3 & RF3_GOOD)) return FALSE;
2710 if ((old_r_ptr->flags3 & RF3_EVIL) && !(r_ptr->flags3 & RF3_EVIL)) return FALSE;
2711 if (!(old_r_ptr->flags3 & (RF3_GOOD | RF3_EVIL)) && (r_ptr->flags3 & (RF3_GOOD | RF3_EVIL))) return FALSE;
2715 else if (summon_specific_who > 0)
2717 if (monster_has_hostile_align(&m_list[summon_specific_who], 0, 0, r_ptr)) return FALSE;
2720 return (*(get_monster_hook()))(r_idx);
2725 * @param m_idx 変身処理を受けるモンスター情報のID
2726 * @param born 生成時の初変身先指定ならばtrue
2727 * @param r_idx 旧モンスター種族のID
2730 void choose_new_monster(MONSTER_IDX m_idx, bool born, MONRACE_IDX r_idx)
2733 monster_type *m_ptr = &m_list[m_idx];
2734 monster_race *r_ptr;
2735 char old_m_name[MAX_NLEN];
2736 bool old_unique = FALSE;
2737 int old_r_idx = m_ptr->r_idx;
2739 if (r_info[m_ptr->r_idx].flags1 & RF1_UNIQUE)
2741 if (old_unique && (r_idx == MON_CHAMELEON)) r_idx = MON_CHAMELEON_K;
2742 r_ptr = &r_info[r_idx];
2744 monster_desc(old_m_name, m_ptr, 0);
2750 chameleon_change_m_idx = m_idx;
2752 get_mon_num_prep(monster_hook_chameleon_lord, NULL);
2754 get_mon_num_prep(monster_hook_chameleon, NULL);
2757 level = r_info[MON_CHAMELEON_K].level;
2758 else if (!dun_level)
2759 level = wilderness[p_ptr->wilderness_y][p_ptr->wilderness_x].level;
2763 if (d_info[dungeon_type].flags1 & DF1_CHAMELEON) level+= 2+randint1(3);
2765 r_idx = get_mon_num(level);
2766 r_ptr = &r_info[r_idx];
2768 chameleon_change_m_idx = 0;
2774 if (is_pet(m_ptr)) check_pets_num_and_align(m_ptr, FALSE);
2776 m_ptr->r_idx = r_idx;
2777 m_ptr->ap_r_idx = r_idx;
2778 update_monster(m_idx, FALSE);
2779 lite_spot(m_ptr->fy, m_ptr->fx);
2781 if ((r_info[old_r_idx].flags7 & (RF7_LITE_MASK | RF7_DARK_MASK)) ||
2782 (r_ptr->flags7 & (RF7_LITE_MASK | RF7_DARK_MASK)))
2783 p_ptr->update |= (PU_MON_LITE);
2785 if (is_pet(m_ptr)) check_pets_num_and_align(m_ptr, TRUE);
2789 /* Sub-alignment of a chameleon */
2790 if (r_ptr->flags3 & (RF3_EVIL | RF3_GOOD))
2792 m_ptr->sub_align = SUB_ALIGN_NEUTRAL;
2793 if (r_ptr->flags3 & RF3_EVIL) m_ptr->sub_align |= SUB_ALIGN_EVIL;
2794 if (r_ptr->flags3 & RF3_GOOD) m_ptr->sub_align |= SUB_ALIGN_GOOD;
2799 if (m_idx == p_ptr->riding)
2801 GAME_TEXT m_name[MAX_NLEN];
2802 monster_desc(m_name, m_ptr, 0);
2803 msg_format(_("突然%sが変身した。", "Suddenly, %s transforms!"), old_m_name);
2804 if (!(r_ptr->flags7 & RF7_RIDING))
2805 if (rakuba(0, TRUE)) msg_format(_("地面に落とされた。", "You have fallen from %s."), m_name);
2808 /* Extract the monster base speed */
2809 m_ptr->mspeed = get_mspeed(r_ptr);
2811 oldmaxhp = m_ptr->max_maxhp;
2812 /* Assign maximal hitpoints */
2813 if (r_ptr->flags1 & RF1_FORCE_MAXHP)
2815 m_ptr->max_maxhp = maxroll(r_ptr->hdice, r_ptr->hside);
2819 m_ptr->max_maxhp = damroll(r_ptr->hdice, r_ptr->hside);
2822 /* Monsters have double hitpoints in Nightmare mode */
2823 if (ironman_nightmare)
2825 u32b hp = m_ptr->max_maxhp * 2L;
2826 m_ptr->max_maxhp = (HIT_POINT)MIN(30000, hp);
2829 m_ptr->maxhp = (long)(m_ptr->maxhp * m_ptr->max_maxhp) / oldmaxhp;
2830 if (m_ptr->maxhp < 1) m_ptr->maxhp = 1;
2831 m_ptr->hp = (long)(m_ptr->hp * m_ptr->max_maxhp) / oldmaxhp;
2833 /* reset dealt_damage */
2834 m_ptr->dealt_damage = 0;
2839 * @brief たぬきの変身対象となるモンスターかどうか判定する / Hook for Tanuki
2840 * @param r_idx モンスター種族ID
2841 * @return 対象にできるならtrueを返す
2843 static bool monster_hook_tanuki(MONRACE_IDX r_idx)
2845 monster_race *r_ptr = &r_info[r_idx];
2847 if (r_ptr->flags1 & (RF1_UNIQUE)) return FALSE;
2848 if (r_ptr->flags2 & RF2_MULTIPLY) return FALSE;
2849 if (r_ptr->flags7 & (RF7_FRIENDLY | RF7_CHAMELEON)) return FALSE;
2850 if (r_ptr->flags7 & RF7_AQUATIC) return FALSE;
2852 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))
2855 return (*(get_monster_hook()))(r_idx);
2860 * @brief モンスターの表層IDを設定する / Set initial racial appearance of a monster
2861 * @param r_idx モンスター種族ID
2862 * @return モンスター種族の表層ID
2864 static IDX initial_r_appearance(MONRACE_IDX r_idx)
2866 int attempts = 1000;
2868 DEPTH min = MIN(base_level-5, 50);
2870 if (p_ptr->pseikaku == SEIKAKU_CHARGEMAN)
2872 if (base_level == 0 || one_in_(5)) return MON_ALIEN_JURAL;
2875 if (!(r_info[r_idx].flags7 & RF7_TANUKI))
2878 get_mon_num_prep(monster_hook_tanuki, NULL);
2882 ap_r_idx = get_mon_num(base_level + 10);
2883 if (r_info[ap_r_idx].level >= min) return ap_r_idx;
2891 * @brief モンスターの個体加速を設定する / Get initial monster speed
2892 * @param r_ptr モンスター種族の参照ポインタ
2895 byte get_mspeed(monster_race *r_ptr)
2897 /* Extract the monster base speed */
2898 int mspeed = r_ptr->speed;
2900 /* Hack -- small racial variety */
2901 if (!(r_ptr->flags1 & RF1_UNIQUE) && !p_ptr->inside_arena)
2903 /* Allow some small variation per monster */
2904 int i = SPEED_TO_ENERGY(r_ptr->speed) / (one_in_(4) ? 3 : 10);
2905 if (i) mspeed += rand_spread(0, i);
2908 if (mspeed > 199) mspeed = 199;
2910 return (byte)mspeed;
2915 * @brief モンスターを一体生成する / Attempt to place a monster of the given race at the given location.
2916 * @param who 召喚を行ったモンスターID
2919 * @param r_idx 生成モンスター種族
2920 * @param mode 生成オプション
2923 * To give the player a sporting chance, any monster that appears in
2924 * line-of-sight and is extremely dangerous can be marked as
2925 * "FORCE_SLEEP", which will cause them to be placed with low energy,
2926 * which often (but not always) lets the player move before they do.
2928 * This routine refuses to place out-of-depth "FORCE_DEPTH" monsters.
2930 * Use special "here" and "dead" flags for unique monsters,
2931 * remove old "cur_num" and "max_num" fields.
2933 * Actually, do something similar for artifacts, to simplify
2934 * the "preserve" mode, and to make the "what artifacts" flag more useful.
2936 * This is the only function which may place a monster in the dungeon,
2937 * except for the savefile loading code.
2939 static bool place_monster_one(MONSTER_IDX who, POSITION y, POSITION x, MONRACE_IDX r_idx, BIT_FLAGS mode)
2941 /* Access the location */
2942 cave_type *c_ptr = &cave[y][x];
2943 monster_type *m_ptr;
2944 monster_race *r_ptr = &r_info[r_idx];
2945 concptr name = (r_name + r_ptr->name);
2949 /* DO NOT PLACE A MONSTER IN THE SMALL SCALE WILDERNESS !!! */
2950 if (p_ptr->wild_mode) return FALSE;
2952 /* Verify location */
2953 if (!in_bounds(y, x)) return (FALSE);
2956 if (!r_idx) return (FALSE);
2959 if (!r_ptr->name) return (FALSE);
2961 if (!(mode & PM_IGNORE_TERRAIN))
2963 /* Not on the Pattern */
2964 if (pattern_tile(y, x)) return FALSE;
2966 /* Require empty space (if not ghostly) */
2967 if (!monster_can_enter(y, x, r_ptr, 0)) return FALSE;
2970 if (!p_ptr->inside_battle)
2972 /* Hack -- "unique" monsters must be "unique" */
2973 if (((r_ptr->flags1 & (RF1_UNIQUE)) ||
2974 (r_ptr->flags7 & (RF7_NAZGUL))) &&
2975 (r_ptr->cur_num >= r_ptr->max_num))
2981 if ((r_ptr->flags7 & (RF7_UNIQUE2)) &&
2982 (r_ptr->cur_num >= 1))
2987 if (r_idx == MON_BANORLUPART)
2989 if (r_info[MON_BANOR].cur_num > 0) return FALSE;
2990 if (r_info[MON_LUPART].cur_num > 0) return FALSE;
2993 /* Depth monsters may NOT be created out of depth, unless in Nightmare mode */
2994 if ((r_ptr->flags1 & (RF1_FORCE_DEPTH)) && (dun_level < r_ptr->level) &&
2995 (!ironman_nightmare || (r_ptr->flags1 & (RF1_QUESTOR))))
3002 if (quest_number(dun_level))
3004 int hoge = quest_number(dun_level);
3005 if ((quest[hoge].type == QUEST_TYPE_KILL_LEVEL) || (quest[hoge].type == QUEST_TYPE_RANDOM))
3007 if(r_idx == quest[hoge].r_idx)
3009 int number_mon, i2, j2;
3012 /* Count all quest monsters */
3013 for (i2 = 0; i2 < cur_wid; ++i2)
3014 for (j2 = 0; j2 < cur_hgt; j2++)
3015 if (cave[j2][i2].m_idx > 0)
3016 if (m_list[cave[j2][i2].m_idx].r_idx == quest[hoge].r_idx)
3018 if(number_mon + quest[hoge].cur_num >= quest[hoge].max_num)
3024 if (is_glyph_grid(c_ptr))
3026 if (randint1(BREAK_GLYPH) < (r_ptr->level+20))
3028 /* Describe observable breakage */
3029 if (c_ptr->info & CAVE_MARK)
3031 msg_print(_("守りのルーンが壊れた!", "The rune of protection is broken!"));
3034 /* Forget the rune */
3035 c_ptr->info &= ~(CAVE_MARK);
3037 /* Break the rune */
3038 c_ptr->info &= ~(CAVE_OBJECT);
3046 msg_format_wizard(CHEAT_MONSTER, _("%s(Lv%d)を生成しました。", "%s(Lv%d) was generated."), name, r_ptr->level);
3048 if ((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags7 & RF7_NAZGUL) || (r_ptr->level < 10)) mode &= ~PM_KAGE;
3050 /* Make a new monster */
3051 c_ptr->m_idx = m_pop();
3052 hack_m_idx_ii = c_ptr->m_idx;
3054 /* Mega-Hack -- catch "failure" */
3055 if (!c_ptr->m_idx) return (FALSE);
3058 /* Get a new monster record */
3059 m_ptr = &m_list[c_ptr->m_idx];
3062 m_ptr->r_idx = r_idx;
3063 m_ptr->ap_r_idx = initial_r_appearance(r_idx);
3069 /* Hack -- Appearance transfer */
3070 if ((mode & PM_MULTIPLY) && (who > 0) && !is_original_ap(&m_list[who]))
3072 m_ptr->ap_r_idx = m_list[who].ap_r_idx;
3074 /* Hack -- Shadower spawns Shadower */
3075 if (m_list[who].mflag2 & MFLAG2_KAGE) m_ptr->mflag2 |= MFLAG2_KAGE;
3078 /* Sub-alignment of a monster */
3079 if ((who > 0) && !(r_ptr->flags3 & (RF3_EVIL | RF3_GOOD)))
3080 m_ptr->sub_align = m_list[who].sub_align;
3083 m_ptr->sub_align = SUB_ALIGN_NEUTRAL;
3084 if (r_ptr->flags3 & RF3_EVIL) m_ptr->sub_align |= SUB_ALIGN_EVIL;
3085 if (r_ptr->flags3 & RF3_GOOD) m_ptr->sub_align |= SUB_ALIGN_GOOD;
3088 /* Place the monster at the location */
3093 /* No "timed status" yet */
3094 for (cmi = 0; cmi < MAX_MTIMED; cmi++) m_ptr->mtimed[cmi] = 0;
3096 /* Unknown distance */
3099 reset_target(m_ptr);
3101 m_ptr->nickname = 0;
3106 /* Your pet summons its pet. */
3107 if (who > 0 && is_pet(&m_list[who]))
3109 mode |= PM_FORCE_PET;
3110 m_ptr->parent_m_idx = who;
3114 m_ptr->parent_m_idx = 0;
3117 if (r_ptr->flags7 & RF7_CHAMELEON)
3119 choose_new_monster(c_ptr->m_idx, TRUE, 0);
3120 r_ptr = &r_info[m_ptr->r_idx];
3121 m_ptr->mflag2 |= MFLAG2_CHAMELEON;
3123 /* Hack - Set sub_align to neutral when the Chameleon Lord is generated as "GUARDIAN" */
3124 if ((r_ptr->flags1 & RF1_UNIQUE) && (who <= 0))
3125 m_ptr->sub_align = SUB_ALIGN_NEUTRAL;
3127 else if ((mode & PM_KAGE) && !(mode & PM_FORCE_PET))
3129 m_ptr->ap_r_idx = MON_KAGE;
3130 m_ptr->mflag2 |= MFLAG2_KAGE;
3133 if (mode & PM_NO_PET) m_ptr->mflag2 |= MFLAG2_NOPET;
3139 if (mode & PM_FORCE_PET)
3144 else if ((r_ptr->flags7 & RF7_FRIENDLY) ||
3145 (mode & PM_FORCE_FRIENDLY) || is_friendly_idx(who))
3147 if (!monster_has_hostile_align(NULL, 0, -1, r_ptr)) set_friendly(m_ptr);
3150 /* Assume no sleeping */
3151 m_ptr->mtimed[MTIMED_CSLEEP] = 0;
3153 /* Enforce sleeping if needed */
3154 if ((mode & PM_ALLOW_SLEEP) && r_ptr->sleep && !ironman_nightmare)
3156 int val = r_ptr->sleep;
3157 (void)set_monster_csleep(c_ptr->m_idx, (val * 2) + randint1(val * 10));
3160 /* Assign maximal hitpoints */
3161 if (r_ptr->flags1 & RF1_FORCE_MAXHP)
3163 m_ptr->max_maxhp = maxroll(r_ptr->hdice, r_ptr->hside);
3167 m_ptr->max_maxhp = damroll(r_ptr->hdice, r_ptr->hside);
3170 /* Monsters have double hitpoints in Nightmare mode */
3171 if (ironman_nightmare)
3173 u32b hp = m_ptr->max_maxhp * 2L;
3175 m_ptr->max_maxhp = (HIT_POINT)MIN(30000, hp);
3178 m_ptr->maxhp = m_ptr->max_maxhp;
3180 /* And start out fully healthy */
3181 if (m_ptr->r_idx == MON_WOUNDED_BEAR)
3182 m_ptr->hp = m_ptr->maxhp / 2;
3183 else m_ptr->hp = m_ptr->maxhp;
3186 /* dealt damage is 0 at initial*/
3187 m_ptr->dealt_damage = 0;
3190 /* Extract the monster base speed */
3191 m_ptr->mspeed = get_mspeed(r_ptr);
3193 if (mode & PM_HASTE) (void)set_monster_fast(c_ptr->m_idx, 100);
3195 /* Give a random starting energy */
3196 if (!ironman_nightmare)
3198 m_ptr->energy_need = ENERGY_NEED() - (s16b)randint0(100);
3202 /* Nightmare monsters are more prepared */
3203 m_ptr->energy_need = ENERGY_NEED() - (s16b)randint0(100) * 2;
3206 /* Force monster to wait for player, unless in Nightmare mode */
3207 if ((r_ptr->flags1 & RF1_FORCE_SLEEP) && !ironman_nightmare)
3209 /* Monster is still being nice */
3210 m_ptr->mflag |= (MFLAG_NICE);
3212 /* Must repair monsters */
3213 repair_monsters = TRUE;
3216 /* Hack -- see "process_monsters()" */
3217 if (c_ptr->m_idx < hack_m_idx)
3219 /* Monster is still being born */
3220 m_ptr->mflag |= (MFLAG_BORN);
3224 if (r_ptr->flags7 & RF7_SELF_LD_MASK)
3225 p_ptr->update |= (PU_MON_LITE);
3226 else if ((r_ptr->flags7 & RF7_HAS_LD_MASK) && !MON_CSLEEP(m_ptr))
3227 p_ptr->update |= (PU_MON_LITE);
3228 update_monster(c_ptr->m_idx, TRUE);
3231 /* Count the monsters on the level */
3232 real_r_ptr(m_ptr)->cur_num++;
3235 * Memorize location of the unique monster in saved floors.
3236 * A unique monster move from old saved floor.
3238 if (character_dungeon &&
3239 ((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags7 & RF7_NAZGUL)))
3240 real_r_ptr(m_ptr)->floor_id = p_ptr->floor_id;
3242 /* Hack -- Count the number of "reproducers" */
3243 if (r_ptr->flags2 & RF2_MULTIPLY) num_repro++;
3245 /* Hack -- Notice new multi-hued monsters */
3247 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
3248 if (ap_r_ptr->flags1 & (RF1_ATTR_MULTI | RF1_SHAPECHANGER))
3249 shimmer_monsters = TRUE;
3252 if (p_ptr->warning && character_dungeon)
3254 if (r_ptr->flags1 & RF1_UNIQUE)
3258 GAME_TEXT o_name[MAX_NLEN];
3260 if (r_ptr->level > p_ptr->lev + 30)
3261 color = _("黒く", "black");
3262 else if (r_ptr->level > p_ptr->lev + 15)
3263 color = _("紫色に", "purple");
3264 else if (r_ptr->level > p_ptr->lev + 5)
3265 color = _("ルビー色に", "deep red");
3266 else if (r_ptr->level > p_ptr->lev - 5)
3267 color = _("赤く", "red");
3268 else if (r_ptr->level > p_ptr->lev - 15)
3269 color = _("ピンク色に", "pink");
3271 color = _("白く", "white");
3273 o_ptr = choose_warning_item();
3276 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
3277 msg_format(_("%sは%s光った。", "%s glows %s."), o_name, color);
3281 msg_format(_("%s光る物が頭に浮かんだ。", "An %s image forms in your mind."), color);
3286 if (is_explosive_rune_grid(c_ptr))
3288 /* Break the ward */
3289 if (randint1(BREAK_MINOR_GLYPH) > r_ptr->level)
3291 /* Describe observable breakage */
3292 if (c_ptr->info & CAVE_MARK)
3294 msg_print(_("ルーンが爆発した!", "The rune explodes!"));
3295 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);
3300 msg_print(_("爆発のルーンは解除された。", "An explosive rune was disarmed."));
3303 /* Forget the rune */
3304 c_ptr->info &= ~(CAVE_MARK);
3306 /* Break the rune */
3307 c_ptr->info &= ~(CAVE_OBJECT);
3320 #define MON_SCAT_MAXD 10 /*!< mon_scatter()関数によるモンスター配置で許される中心からの最大距離 */
3323 * @brief モンスター1体を目標地点に可能ながり近い位置に生成する / improved version of scatter() for place monster
3324 * @param r_idx 生成モンスター種族
3325 * @param yp 結果生成位置y座標
3326 * @param xp 結果生成位置x座標
3327 * @param y 中心生成位置y座標
3328 * @param x 中心生成位置x座標
3329 * @param max_dist 生成位置の最大半径
3333 static bool mon_scatter(MONRACE_IDX r_idx, POSITION *yp, POSITION *xp, POSITION y, POSITION x, POSITION max_dist)
3335 int place_x[MON_SCAT_MAXD];
3336 int place_y[MON_SCAT_MAXD];
3337 int num[MON_SCAT_MAXD];
3341 if (max_dist >= MON_SCAT_MAXD)
3344 for (i = 0; i < MON_SCAT_MAXD; i++)
3347 for (nx = x - max_dist; nx <= x + max_dist; nx++)
3349 for (ny = y - max_dist; ny <= y + max_dist; ny++)
3351 /* Ignore annoying locations */
3352 if (!in_bounds(ny, nx)) continue;
3354 /* Require "line of projection" */
3355 if (!projectable(y, x, ny, nx)) continue;
3359 monster_race *r_ptr = &r_info[r_idx];
3361 /* Require empty space (if not ghostly) */
3362 if (!monster_can_enter(ny, nx, r_ptr, 0))
3367 /* Walls and Monsters block flow */
3368 if (!cave_empty_bold2(ny, nx)) continue;
3370 /* ... nor on the Pattern */
3371 if (pattern_tile(ny, nx)) continue;
3374 i = distance(y, x, ny, nx);
3382 if (one_in_(num[i]))
3391 while (i < MON_SCAT_MAXD && 0 == num[i])
3393 if (i >= MON_SCAT_MAXD)
3403 * @brief モンスターを目標地点に集団生成する / Attempt to place a "group" of monsters around the given location
3404 * @param who 召喚主のモンスター情報ID
3405 * @param y 中心生成位置y座標
3406 * @param x 中心生成位置x座標
3407 * @param r_idx 生成モンスター種族
3408 * @param mode 生成オプション
3411 static bool place_monster_group(MONSTER_IDX who, POSITION y, POSITION x, MONRACE_IDX r_idx, BIT_FLAGS mode)
3413 monster_race *r_ptr = &r_info[r_idx];
3416 int total = 0, extra = 0;
3420 POSITION hack_y[GROUP_MAX];
3421 POSITION hack_x[GROUP_MAX];
3424 /* Pick a group size */
3425 total = randint1(10);
3427 /* Hard monsters, small groups */
3428 if (r_ptr->level > dun_level)
3430 extra = r_ptr->level - dun_level;
3431 extra = 0 - randint1(extra);
3434 /* Easy monsters, large groups */
3435 else if (r_ptr->level < dun_level)
3437 extra = dun_level - r_ptr->level;
3438 extra = randint1(extra);
3441 /* Hack -- limit group reduction */
3442 if (extra > 9) extra = 9;
3444 /* Modify the group size */
3448 if (total < 1) total = 1;
3451 if (total > GROUP_MAX) total = GROUP_MAX;
3454 /* Start on the monster */
3459 /* Puddle monsters, breadth first, up to total */
3460 for (n = 0; (n < hack_n) && (hack_n < total); n++)
3462 /* Grab the location */
3463 POSITION hx = hack_x[n];
3464 POSITION hy = hack_y[n];
3466 /* Check each direction, up to total */
3467 for (i = 0; (i < 8) && (hack_n < total); i++)
3471 scatter(&my, &mx, hy, hx, 4, 0);
3473 /* Walls and Monsters block flow */
3474 if (!cave_empty_bold2(my, mx)) continue;
3476 /* Attempt to place another monster */
3477 if (place_monster_one(who, my, mx, r_idx, mode))
3479 /* Add it to the "hack" set */
3480 hack_y[hack_n] = my;
3481 hack_x[hack_n] = mx;
3493 * @var place_monster_idx
3494 * @brief 護衛対象となるモンスター種族IDを渡すグローバル変数 / Hack -- help pick an escort type
3495 * @todo 関数ポインタの都合を配慮しながら、グローバル変数place_monster_idxを除去し、関数引数化する
3497 static MONSTER_IDX place_monster_idx = 0;
3500 * @var place_monster_m_idx
3501 * @brief 護衛対象となるモンスターIDを渡すグローバル変数 / Hack -- help pick an escort type
3502 * @todo 関数ポインタの都合を配慮しながら、グローバル変数place_monster_m_idxを除去し、関数引数化する
3504 static MONSTER_IDX place_monster_m_idx = 0;
3507 * @brief モンスター種族が召喚主の護衛となれるかどうかをチェックする / Hack -- help pick an escort type
3508 * @param r_idx チェックするモンスター種族のID
3509 * @return 護衛にできるならばtrue
3511 static bool place_monster_can_escort(MONRACE_IDX r_idx)
3513 monster_race *r_ptr = &r_info[place_monster_idx];
3514 monster_type *m_ptr = &m_list[place_monster_m_idx];
3516 monster_race *z_ptr = &r_info[r_idx];
3518 /* Hack - Escorts have to have the same dungeon flag */
3519 if (mon_hook_dungeon(place_monster_idx) != mon_hook_dungeon(r_idx)) return (FALSE);
3521 /* Require similar "race" */
3522 if (z_ptr->d_char != r_ptr->d_char) return (FALSE);
3524 /* Skip more advanced monsters */
3525 if (z_ptr->level > r_ptr->level) return (FALSE);
3527 /* Skip unique monsters */
3528 if (z_ptr->flags1 & RF1_UNIQUE) return (FALSE);
3530 /* Paranoia -- Skip identical monsters */
3531 if (place_monster_idx == r_idx) return (FALSE);
3533 /* Skip different alignment */
3534 if (monster_has_hostile_align(m_ptr, 0, 0, z_ptr)) return FALSE;
3536 if (r_ptr->flags7 & RF7_FRIENDLY)
3538 if (monster_has_hostile_align(NULL, 1, -1, z_ptr)) return FALSE;
3541 if ((r_ptr->flags7 & RF7_CHAMELEON) && !(z_ptr->flags7 & RF7_CHAMELEON))
3549 * @brief 一般的なモンスター生成処理のサブルーチン / Attempt to place a monster of the given race at the given location
3550 * @param who 召喚主のモンスター情報ID
3553 * @param r_idx 生成するモンスターの種族ID
3554 * @param mode 生成オプション
3555 * @return 生成に成功したらtrue
3557 * Note that certain monsters are now marked as requiring "friends".
3558 * These monsters, if successfully placed, and if the "grp" parameter
3559 * is TRUE, will be surrounded by a "group" of identical monsters.
3561 * Note that certain monsters are now marked as requiring an "escort",
3562 * which is a collection of monsters with similar "race" but lower level.
3564 * Some monsters induce a fake "group" flag on their escorts.
3566 * Note the "bizarre" use of non-recursion to prevent annoying output
3567 * when running a code profiler.
3569 * Note the use of the new "monster allocation table" code to restrict
3570 * the "get_mon_num()" function to "legal" escort types.
3572 bool place_monster_aux(MONSTER_IDX who, POSITION y, POSITION x, MONRACE_IDX r_idx, BIT_FLAGS mode)
3575 monster_race *r_ptr = &r_info[r_idx];
3577 if (!(mode & PM_NO_KAGE) && one_in_(333))
3580 /* Place one monster, or fail */
3581 if (!place_monster_one(who, y, x, r_idx, mode)) return (FALSE);
3583 /* Require the "group" flag */
3584 if (!(mode & PM_ALLOW_GROUP)) return (TRUE);
3586 place_monster_m_idx = hack_m_idx_ii;
3589 for(i = 0; i < A_MAX; i++)
3591 if(!r_ptr->reinforce_id[i]) break;
3592 n = damroll(r_ptr->reinforce_dd[i], r_ptr->reinforce_ds[i]);
3593 for(j = 0; j < n; j++)
3595 POSITION nx, ny, d = 7;
3596 scatter(&ny, &nx, y, x, d, 0);
3597 (void)place_monster_one(place_monster_m_idx, ny, nx, r_ptr->reinforce_id[i], mode);
3601 /* Friends for certain monsters */
3602 if (r_ptr->flags1 & (RF1_FRIENDS))
3604 /* Attempt to place a group */
3605 (void)place_monster_group(who, y, x, r_idx, mode);
3608 /* Escorts for certain monsters */
3609 if (r_ptr->flags1 & (RF1_ESCORT))
3611 /* Set the escort index */
3612 place_monster_idx = r_idx;
3614 /* Try to place several "escorts" */
3615 for (i = 0; i < 32; i++)
3617 POSITION nx, ny, d = 3;
3620 /* Pick a location */
3621 scatter(&ny, &nx, y, x, d, 0);
3623 /* Require empty grids */
3624 if (!cave_empty_bold2(ny, nx)) continue;
3625 get_mon_num_prep(place_monster_can_escort, get_monster_hook2(ny, nx));
3627 /* Pick a random race */
3628 z = get_mon_num(r_ptr->level);
3630 /* Handle failure */
3633 /* Place a single escort */
3634 (void)place_monster_one(place_monster_m_idx, ny, nx, z, mode);
3636 /* Place a "group" of escorts if needed */
3637 if ((r_info[z].flags1 & RF1_FRIENDS) ||
3638 (r_ptr->flags1 & RF1_ESCORTS))
3640 /* Place a group of monsters */
3641 (void)place_monster_group(place_monster_m_idx, ny, nx, z, mode);
3651 * @brief 一般的なモンスター生成処理のメインルーチン / Attempt to place a monster of the given race at the given location
3654 * @param mode 生成オプション
3655 * @return 生成に成功したらtrue
3657 bool place_monster(POSITION y, POSITION x, BIT_FLAGS mode)
3660 get_mon_num_prep(get_monster_hook(), get_monster_hook2(y, x));
3662 /* Pick a monster */
3663 r_idx = get_mon_num(monster_level);
3665 /* Handle failure */
3666 if (!r_idx) return (FALSE);
3668 /* Attempt to place the monster */
3669 if (place_monster_aux(0, y, x, r_idx, mode)) return (TRUE);
3675 * @brief 指定地点に1種類のモンスター種族による群れを生成する
3678 * @return 生成に成功したらtrue
3680 bool alloc_horde(POSITION y, POSITION x)
3682 monster_race *r_ptr = NULL;
3683 MONRACE_IDX r_idx = 0;
3685 int attempts = 1000;
3688 get_mon_num_prep(get_monster_hook(), get_monster_hook2(y, x));
3692 /* Pick a monster */
3693 r_idx = get_mon_num(monster_level);
3695 /* Handle failure */
3696 if (!r_idx) return (FALSE);
3698 r_ptr = &r_info[r_idx];
3700 if (r_ptr->flags1 & RF1_UNIQUE) continue;
3702 if (r_idx == MON_HAGURE) continue;
3705 if (attempts < 1) return FALSE;
3711 /* Attempt to place the monster */
3712 if (place_monster_aux(0, y, x, r_idx, 0L)) break;
3715 if (attempts < 1) return FALSE;
3717 m_idx = cave[y][x].m_idx;
3719 if (m_list[m_idx].mflag2 & MFLAG2_CHAMELEON) r_ptr = &r_info[m_list[m_idx].r_idx];
3721 for (attempts = randint1(10) + 5; attempts; attempts--)
3723 scatter(&cy, &cx, y, x, 5, 0);
3725 (void)summon_specific(m_idx, cy, cx, dun_level + 5, SUMMON_KIN, PM_ALLOW_GROUP, r_ptr->d_char);
3731 if (cheat_hear) msg_format(_("モンスターの大群(%c)", "Monster horde (%c)."), r_ptr->d_char);
3736 * @brief ダンジョンの主生成を試みる / Put the Guardian
3737 * @param def_val 現在の主の生成状態
3738 * @return 生成に成功したらtrue
3740 bool alloc_guardian(bool def_val)
3742 MONRACE_IDX guardian = d_info[dungeon_type].final_guardian;
3744 if (guardian && (d_info[dungeon_type].maxdepth == dun_level) && (r_info[guardian].cur_num < r_info[guardian].max_num))
3748 int try_count = 4000;
3750 /* Find a good position */
3753 /* Get a random spot */
3754 oy = randint1(cur_hgt - 4) + 2;
3755 ox = randint1(cur_wid - 4) + 2;
3757 /* Is it a good spot ? */
3758 if (cave_empty_bold2(oy, ox) && monster_can_cross_terrain(cave[oy][ox].feat, &r_info[guardian], 0))
3760 /* Place the guardian */
3761 if (place_monster_aux(0, oy, ox, guardian, (PM_ALLOW_GROUP | PM_NO_KAGE | PM_NO_PET))) return TRUE;
3764 /* One less try count */
3776 * @brief ダンジョンの初期配置モンスターを生成1回生成する / Attempt to allocate a random monster in the dungeon.
3777 * @param dis プレイヤーから離れるべき最低距離
3778 * @param mode 生成オプション
3779 * @return 生成に成功したらtrue
3781 * Place the monster at least "dis" distance from the player.
3782 * Use "slp" to choose the initial "sleep" status
3783 * Use "monster_level" for the monster level
3785 bool alloc_monster(POSITION dis, BIT_FLAGS mode)
3788 int attempts_left = 10000;
3790 /* Put the Guardian */
3791 if (alloc_guardian(FALSE)) return TRUE;
3793 /* Find a legal, distant, unoccupied, space */
3794 while (attempts_left--)
3796 /* Pick a location */
3797 y = randint0(cur_hgt);
3798 x = randint0(cur_wid);
3800 /* Require empty floor grid (was "naked") */
3803 if (!cave_empty_bold2(y, x)) continue;
3807 if (!cave_empty_bold(y, x)) continue;
3810 /* Accept far away grids */
3811 if (distance(y, x, p_ptr->y, p_ptr->x) > dis) break;
3816 if (cheat_xtra || cheat_hear)
3818 msg_print(_("警告!新たなモンスターを配置できません。小さい階ですか?", "Warning! Could not allocate a new monster. Small level?"));
3825 if (randint1(5000) <= dun_level)
3827 if (alloc_horde(y, x))
3834 /* Attempt to place the monster, allow groups */
3835 if (place_monster(y, x, (mode | PM_ALLOW_GROUP))) return (TRUE);
3843 * @brief モンスターが召喚の基本条件に合っているかをチェックする / Hack -- help decide if a monster race is "okay" to summon
3844 * @param r_idx チェックするモンスター種族ID
3845 * @return 召喚対象にできるならばTRUE
3847 static bool summon_specific_okay(MONRACE_IDX r_idx)
3849 monster_race *r_ptr = &r_info[r_idx];
3851 /* Hack - Only summon dungeon monsters */
3852 if (!mon_hook_dungeon(r_idx)) return (FALSE);
3854 /* Hack -- identify the summoning monster */
3855 if (summon_specific_who > 0)
3857 monster_type *m_ptr = &m_list[summon_specific_who];
3859 /* Do not summon enemies */
3861 /* Friendly vs. opposite aligned normal or pet */
3862 if (monster_has_hostile_align(m_ptr, 0, 0, r_ptr)) return FALSE;
3864 /* Use the player's alignment */
3865 else if (summon_specific_who < 0)
3867 /* Do not summon enemies of the pets */
3868 if (monster_has_hostile_align(NULL, 10, -10, r_ptr))
3870 if (!one_in_(ABS(p_ptr->align) / 2 + 1)) return FALSE;
3874 if (!summon_unique_okay && ((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags7 & RF7_NAZGUL))) return FALSE;
3876 /* Hack -- no specific type specified */
3877 if (!summon_specific_type) return (TRUE);
3879 if ((summon_specific_who < 0) &&
3880 ((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags7 & RF7_NAZGUL)) &&
3881 monster_has_hostile_align(NULL, 10, -10, r_ptr))
3884 if ((r_ptr->flags7 & RF7_CHAMELEON) && (d_info[dungeon_type].flags1 & DF1_CHAMELEON)) return TRUE;
3886 return (summon_specific_aux(r_idx));
3891 * @brief モンスターを召喚により配置する / Place a monster (of the specified "type") near the given location. Return TRUE if a monster was actually summoned.
3892 * @param who 召喚主のモンスター情報ID
3897 * @param mode 生成オプション
3898 * @return 召喚できたらtrueを返す
3901 * We will attempt to place the monster up to 10 times before giving up.
3903 * Note: SUMMON_UNIQUE and SUMMON_AMBERITES will summon Unique's
3904 * Note: SUMMON_HI_UNDEAD and SUMMON_HI_DRAGON may summon Unique's
3905 * Note: None of the other summon codes will ever summon Unique's.
3907 * This function has been changed. We now take the "monster level"
3908 * of the summoning monster as a parameter, and use that, along with
3909 * the current dungeon level, to help determine the level of the
3910 * desired monster. Note that this is an upper bound, and also
3911 * tends to "prefer" monsters of that level. Currently, we use
3912 * the average of the dungeon and monster levels, and then add
3913 * five to allow slight increases in monster power.
3915 * Note that we use the new "monster allocation table" creation code
3916 * to restrict the "get_mon_num()" function to the set of "legal"
3917 * monsters, making this function much faster and more reliable.
3919 * Note that this function may not succeed, though this is very rare.
3921 bool summon_specific(MONSTER_IDX who, POSITION y1, POSITION x1, DEPTH lev, int type, BIT_FLAGS mode, SYMBOL_CODE symbol)
3926 if (p_ptr->inside_arena) return (FALSE);
3928 if (!mon_scatter(0, &y, &x, y1, x1, 2)) return FALSE;
3930 /* Save the summoner */
3931 summon_specific_who = who;
3933 /* Save the "summon" type */
3934 summon_specific_type = type;
3936 summon_kin_type = symbol;
3938 summon_unique_okay = (mode & PM_ALLOW_UNIQUE) ? TRUE : FALSE;
3939 get_mon_num_prep(summon_specific_okay, get_monster_hook2(y, x));
3941 /* Pick a monster, using the level calculation */
3942 r_idx = get_mon_num((dun_level + lev) / 2 + 5);
3944 /* Handle failure */
3947 summon_specific_type = 0;
3951 if ((type == SUMMON_BLUE_HORROR) || (type == SUMMON_DAWN)) mode |= PM_NO_KAGE;
3953 /* Attempt to place the monster (awake, allow groups) */
3954 if (!place_monster_aux(who, y, x, r_idx, mode))
3956 summon_specific_type = 0;
3960 summon_specific_type = 0;
3962 sound(SOUND_SUMMON);
3968 * @brief 特定モンスター種族を召喚により生成する / A "dangerous" function, creates a pet of the specified type
3969 * @param who 召喚主のモンスター情報ID
3972 * @param r_idx 生成するモンスター種族ID
3973 * @param mode 生成オプション
3974 * @return 召喚できたらtrueを返す
3976 bool summon_named_creature(MONSTER_IDX who, POSITION oy, POSITION ox, MONRACE_IDX r_idx, BIT_FLAGS mode)
3981 /* if (!r_idx) return; */
3983 /* Prevent illegal monsters */
3984 if (r_idx >= max_r_idx) return FALSE;
3986 if (p_ptr->inside_arena) return FALSE;
3988 if (!mon_scatter(r_idx, &y, &x, oy, ox, 2)) return FALSE;
3990 /* Place it (allow groups) */
3991 return place_monster_aux(who, y, x, r_idx, (mode | PM_NO_KAGE));
3996 * @brief モンスターを増殖生成する / Let the given monster attempt to reproduce.
3997 * @param m_idx 増殖するモンスター情報ID
3998 * @param clone クローン・モンスター処理ならばtrue
3999 * @param mode 生成オプション
4000 * @return 生成できたらtrueを返す
4002 * Note that "reproduction" REQUIRES empty space.
4004 bool multiply_monster(MONSTER_IDX m_idx, bool clone, BIT_FLAGS mode)
4006 monster_type *m_ptr = &m_list[m_idx];
4010 if (!mon_scatter(m_ptr->r_idx, &y, &x, m_ptr->fy, m_ptr->fx, 1))
4013 if (m_ptr->mflag2 & MFLAG2_NOPET) mode |= PM_NO_PET;
4015 /* Create a new monster (awake, no groups) */
4016 if (!place_monster_aux(m_idx, y, x, m_ptr->r_idx, (mode | PM_NO_KAGE | PM_MULTIPLY)))
4019 /* Hack -- Transfer "clone" flag */
4020 if (clone || (m_ptr->smart & SM_CLONED))
4022 m_list[hack_m_idx_ii].smart |= SM_CLONED;
4023 m_list[hack_m_idx_ii].mflag2 |= MFLAG2_NOPET;
4032 * @brief ダメージを受けたモンスターの様子を記述する / Dump a message describing a monster's reaction to damage
4033 * @param m_idx モンスター情報ID
4034 * @param dam 与えたダメージ
4037 * Technically should attempt to treat "Beholder"'s as jelly's
4039 void message_pain(MONSTER_IDX m_idx, HIT_POINT dam)
4041 HIT_POINT oldhp, newhp;
4043 PERCENTAGE percentage;
4045 monster_type *m_ptr = &m_list[m_idx];
4046 monster_race *r_ptr = &r_info[m_ptr->r_idx];
4048 GAME_TEXT m_name[MAX_NLEN];
4050 monster_desc(m_name, m_ptr, 0);
4052 if(dam == 0) // Notice non-damage
4054 msg_format(_("%^sはダメージを受けていない。", "%^s is unharmed."), m_name);
4058 /* Note -- subtle fix -CFT */
4060 oldhp = newhp + dam;
4061 tmp = (newhp * 100L) / oldhp;
4064 if(my_strchr(",ejmvwQ", r_ptr->d_char)) // Mushrooms, Eyes, Jellies, Molds, Vortices, Worms, Quylthulgs
4067 if(percentage > 95) msg_format("%^sはほとんど気にとめていない。", m_name);
4068 else if(percentage > 75) msg_format("%^sはしり込みした。", m_name);
4069 else if(percentage > 50) msg_format("%^sは縮こまった。", m_name);
4070 else if(percentage > 35) msg_format("%^sは痛みに震えた。", m_name);
4071 else if(percentage > 20) msg_format("%^sは身もだえした。", m_name);
4072 else if(percentage > 10) msg_format("%^sは苦痛で身もだえした。", m_name);
4073 else msg_format("%^sはぐにゃぐにゃと痙攣した。", m_name);
4075 if(percentage > 95) msg_format("%^s barely notices.", m_name);
4076 else if(percentage > 75) msg_format("%^s flinches.", m_name);
4077 else if(percentage > 50) msg_format("%^s squelches.", m_name);
4078 else if(percentage > 35) msg_format("%^s quivers in pain.", m_name);
4079 else if(percentage > 20) msg_format("%^s writhes about.", m_name);
4080 else if(percentage > 10) msg_format("%^s writhes in agony.", m_name);
4081 else msg_format("%^s jerks limply.", m_name);
4085 else if(my_strchr("l", r_ptr->d_char)) // Fish
4088 if(percentage > 95) msg_format("%^sはほとんど気にとめていない。", m_name);
4089 else if(percentage > 75) msg_format("%^sはしり込みした。", m_name);
4090 else if(percentage > 50) msg_format("%^sは躊躇した。", m_name);
4091 else if(percentage > 35) msg_format("%^sは痛みに震えた。", m_name);
4092 else if(percentage > 20) msg_format("%^sは身もだえした。", m_name);
4093 else if(percentage > 10) msg_format("%^sは苦痛で身もだえした。", m_name);
4094 else msg_format("%^sはぐにゃぐにゃと痙攣した。", m_name);
4096 if(percentage > 95) msg_format("%^s barely notices.", m_name);
4097 else if(percentage > 75) msg_format("%^s flinches.", m_name);
4098 else if(percentage > 50) msg_format("%^s hesitates.", m_name);
4099 else if(percentage > 35) msg_format("%^s quivers in pain.", m_name);
4100 else if(percentage > 20) msg_format("%^s writhes about.", m_name);
4101 else if(percentage > 10) msg_format("%^s writhes in agony.", m_name);
4102 else msg_format("%^s jerks limply.", m_name);
4106 else if(my_strchr("g#+<>", r_ptr->d_char)) // Golems, Walls, Doors, Stairs
4109 if(percentage > 95) msg_format("%sは攻撃を気にとめていない。", m_name);
4110 else if(percentage > 75) msg_format("%sは攻撃に肩をすくめた。", m_name);
4111 else if(percentage > 50) msg_format("%^sは雷鳴のように吠えた。", m_name);
4112 else if(percentage > 35) msg_format("%^sは苦しげに吠えた。", m_name);
4113 else if(percentage > 20) msg_format("%^sはうめいた。", m_name);
4114 else if(percentage > 10) msg_format("%^sは躊躇した。", m_name);
4115 else msg_format("%^sはくしゃくしゃになった。", m_name);
4117 if(percentage > 95) msg_format("%^s ignores the attack.", m_name);
4118 else if(percentage > 75) msg_format("%^s shrugs off the attack.", m_name);
4119 else if(percentage > 50) msg_format("%^s roars thunderously.", m_name);
4120 else if(percentage > 35) msg_format("%^s rumbles.", m_name);
4121 else if(percentage > 20) msg_format("%^s grunts.", m_name);
4122 else if(percentage > 10) msg_format("%^s hesitates.", m_name);
4123 else msg_format("%^s crumples.", m_name);
4127 else if(my_strchr("JMR", r_ptr->d_char) || !isalpha(r_ptr->d_char)) // Snakes, Hydrae, Reptiles, Mimics
4130 if(percentage > 95) msg_format("%^sはほとんど気にとめていない。", m_name);
4131 else if(percentage > 75) msg_format("%^sはシーッと鳴いた。", m_name);
4132 else if(percentage > 50) msg_format("%^sは怒って頭を上げた。", m_name);
4133 else if(percentage > 35) msg_format("%^sは猛然と威嚇した。", m_name);
4134 else if(percentage > 20) msg_format("%^sは身もだえした。", m_name);
4135 else if(percentage > 10) msg_format("%^sは苦痛で身もだえした。", m_name);
4136 else msg_format("%^sはぐにゃぐにゃと痙攣した。", m_name);
4138 if(percentage > 95) msg_format("%^s barely notices.", m_name);
4139 else if(percentage > 75) msg_format("%^s hisses.", m_name);
4140 else if(percentage > 50) msg_format("%^s rears up in anger.", m_name);
4141 else if(percentage > 35) msg_format("%^s hisses furiously.", m_name);
4142 else if(percentage > 20) msg_format("%^s writhes about.", m_name);
4143 else if(percentage > 10) msg_format("%^s writhes in agony.", m_name);
4144 else msg_format("%^s jerks limply.", m_name);
4148 else if(my_strchr("f", r_ptr->d_char))
4151 if(percentage > 95) msg_format("%sは攻撃に肩をすくめた。", m_name);
4152 else if(percentage > 75) msg_format("%^sは吠えた。", m_name);
4153 else if(percentage > 50) msg_format("%^sは怒って吠えた。", m_name);
4154 else if(percentage > 35) msg_format("%^sは痛みでシーッと鳴いた。", m_name);
4155 else if(percentage > 20) msg_format("%^sは痛みで弱々しく鳴いた。", m_name);
4156 else if(percentage > 10) msg_format("%^sは苦痛にうめいた。", m_name);
4157 else msg_format("%sは哀れな鳴き声を出した。", m_name);
4159 if(percentage > 95) msg_format("%^s shrugs off the attack.", m_name);
4160 else if(percentage > 75) msg_format("%^s roars.", m_name);
4161 else if(percentage > 50) msg_format("%^s growls angrily.", m_name);
4162 else if(percentage > 35) msg_format("%^s hisses with pain.", m_name);
4163 else if(percentage > 20) msg_format("%^s mewls in pain.", m_name);
4164 else if(percentage > 10) msg_format("%^s hisses in agony.", m_name);
4165 else msg_format("%^s mewls pitifully.", m_name);
4169 else if(my_strchr("acFIKS", r_ptr->d_char)) // Ants, Centipedes, Flies, Insects, Beetles, Spiders
4172 if(percentage > 95) msg_format("%sは攻撃を気にとめていない。", m_name);
4173 else if(percentage > 75) msg_format("%^sはキーキー鳴いた。", m_name);
4174 else if(percentage > 50) msg_format("%^sはヨロヨロ逃げ回った。", m_name);
4175 else if(percentage > 35) msg_format("%^sはうるさく鳴いた。", m_name);
4176 else if(percentage > 20) msg_format("%^sは痛みに痙攣した。", m_name);
4177 else if(percentage > 10) msg_format("%^sは苦痛で痙攣した。", m_name);
4178 else msg_format("%^sはピクピクひきつった。", m_name);
4180 if(percentage > 95) msg_format("%^s ignores the attack.", m_name);
4181 else if(percentage > 75) msg_format("%^s chitters.", m_name);
4182 else if(percentage > 50) msg_format("%^s scuttles about.", m_name);
4183 else if(percentage > 35) msg_format("%^s twitters.", m_name);
4184 else if(percentage > 20) msg_format("%^s jerks in pain.", m_name);
4185 else if(percentage > 10) msg_format("%^s jerks in agony.", m_name);
4186 else msg_format("%^s twitches.", m_name);
4190 else if(my_strchr("B", r_ptr->d_char)) // Birds
4193 if(percentage > 95) msg_format("%^sはさえずった。", m_name);
4194 else if(percentage > 75) msg_format("%^sはピーピー鳴いた。", m_name);
4195 else if(percentage > 50) msg_format("%^sはギャーギャー鳴いた。", m_name);
4196 else if(percentage > 35) msg_format("%^sはギャーギャー鳴きわめいた。", m_name);
4197 else if(percentage > 20) msg_format("%^sは苦しんだ。", m_name);
4198 else if(percentage > 10) msg_format("%^sはのたうち回った。", m_name);
4199 else msg_format("%^sはキーキーと鳴き叫んだ。", m_name);
4201 if(percentage > 95) msg_format("%^s chirps.", m_name);
4202 else if(percentage > 75) msg_format("%^s twitters.", m_name);
4203 else if(percentage > 50) msg_format("%^s squawks.", m_name);
4204 else if(percentage > 35) msg_format("%^s chatters.", m_name);
4205 else if(percentage > 20) msg_format("%^s jeers.", m_name);
4206 else if(percentage > 10) msg_format("%^s flutters about.", m_name);
4207 else msg_format("%^s squeaks.", m_name);
4211 else if(my_strchr("duDLUW", r_ptr->d_char)) // Dragons, Demons, High Undead
4214 if(percentage > 95) msg_format("%sは攻撃を気にとめていない。", m_name);
4215 else if(percentage > 75) msg_format("%^sはしり込みした。", m_name);
4216 else if(percentage > 50) msg_format("%^sは痛みでシーッと鳴いた。", m_name);
4217 else if(percentage > 35) msg_format("%^sは痛みでうなった。", m_name);
4218 else if(percentage > 20) msg_format("%^sは痛みに吠えた。", m_name);
4219 else if(percentage > 10) msg_format("%^sは苦しげに叫んだ。", m_name);
4220 else msg_format("%^sは弱々しくうなった。", m_name);
4222 if(percentage > 95) msg_format("%^s ignores the attack.", m_name);
4223 else if(percentage > 75) msg_format("%^s flinches.", m_name);
4224 else if(percentage > 50) msg_format("%^s hisses in pain.", m_name);
4225 else if(percentage > 35) msg_format("%^s snarls with pain.", m_name);
4226 else if(percentage > 20) msg_format("%^s roars with pain.", m_name);
4227 else if(percentage > 10) msg_format("%^s gasps.", m_name);
4228 else msg_format("%^s snarls feebly.", m_name);
4232 else if(my_strchr("s", r_ptr->d_char)) // Skeletons
4235 if(percentage > 95) msg_format("%sは攻撃を気にとめていない。", m_name);
4236 else if(percentage > 75) msg_format("%sは攻撃に肩をすくめた。", m_name);
4237 else if(percentage > 50) msg_format("%^sはカタカタと笑った。", m_name);
4238 else if(percentage > 35) msg_format("%^sはよろめいた。", m_name);
4239 else if(percentage > 20) msg_format("%^sはカタカタ言った。", m_name);
4240 else if(percentage > 10) msg_format("%^sはよろめいた。", m_name);
4241 else msg_format("%^sはガタガタ言った。", m_name);
4243 if(percentage > 95) msg_format("%^s ignores the attack.", m_name);
4244 else if(percentage > 75) msg_format("%^s shrugs off the attack.", m_name);
4245 else if(percentage > 50) msg_format("%^s rattles.", m_name);
4246 else if(percentage > 35) msg_format("%^s stumbles.", m_name);
4247 else if(percentage > 20) msg_format("%^s rattles.", m_name);
4248 else if(percentage > 10) msg_format("%^s staggers.", m_name);
4249 else msg_format("%^s clatters.", m_name);
4253 else if(my_strchr("z", r_ptr->d_char)) // Zombies
4256 if(percentage > 95) msg_format("%sは攻撃を気にとめていない。", m_name);
4257 else if(percentage > 75) msg_format("%sは攻撃に肩をすくめた。", m_name);
4258 else if(percentage > 50) msg_format("%^sはうめいた。", m_name);
4259 else if(percentage > 35) msg_format("%sは苦しげにうめいた。", m_name);
4260 else if(percentage > 20) msg_format("%^sは躊躇した。", m_name);
4261 else if(percentage > 10) msg_format("%^sはうなった。", m_name);
4262 else msg_format("%^sはよろめいた。", m_name);
4264 if(percentage > 95) msg_format("%^s ignores the attack.", m_name);
4265 else if(percentage > 75) msg_format("%^s shrugs off the attack.", m_name);
4266 else if(percentage > 50) msg_format("%^s groans.", m_name);
4267 else if(percentage > 35) msg_format("%^s moans.", m_name);
4268 else if(percentage > 20) msg_format("%^s hesitates.", m_name);
4269 else if(percentage > 10) msg_format("%^s grunts.", m_name);
4270 else msg_format("%^s staggers.", m_name);
4274 else if(my_strchr("G", r_ptr->d_char)) // Ghosts
4277 if(percentage > 95) msg_format("%sは攻撃を気にとめていない。", m_name);
4278 else if(percentage > 75) msg_format("%sは攻撃に肩をすくめた。", m_name);
4279 else if(percentage > 50) msg_format("%sはうめいた。", m_name);
4280 else if(percentage > 35) msg_format("%^sは泣きわめいた。", m_name);
4281 else if(percentage > 20) msg_format("%^sは吠えた。", m_name);
4282 else if(percentage > 10) msg_format("%sは弱々しくうめいた。", m_name);
4283 else msg_format("%^sはかすかにうめいた。", m_name);
4285 if(percentage > 95) msg_format("%^s ignores the attack.", m_name);
4286 else if(percentage > 75) msg_format("%^s shrugs off the attack.", m_name);
4287 else if(percentage > 50) msg_format("%^s moans.", m_name);
4288 else if(percentage > 35) msg_format("%^s wails.", m_name);
4289 else if(percentage > 20) msg_format("%^s howls.", m_name);
4290 else if(percentage > 10) msg_format("%^s moans softly.", m_name);
4291 else msg_format("%^s sighs.", m_name);
4295 else if(my_strchr("CZ", r_ptr->d_char)) // Dogs and Hounds
4298 if(percentage > 95) msg_format("%^sは攻撃に肩をすくめた。", m_name);
4299 else if(percentage > 75) msg_format("%^sは痛みでうなった。", m_name);
4300 else if(percentage > 50) msg_format("%^sは痛みでキャンキャン吠えた。", m_name);
4301 else if(percentage > 35) msg_format("%^sは痛みで鳴きわめいた。", m_name);
4302 else if(percentage > 20) msg_format("%^sは苦痛のあまり鳴きわめいた。", m_name);
4303 else if(percentage > 10) msg_format("%^sは苦痛でもだえ苦しんだ。", m_name);
4304 else msg_format("%^sは弱々しく吠えた。", m_name);
4306 if(percentage > 95) msg_format("%^s shrugs off the attack.", m_name);
4307 else if(percentage > 75) msg_format("%^s snarls with pain.", m_name);
4308 else if(percentage > 50) msg_format("%^s yelps in pain.", m_name);
4309 else if(percentage > 35) msg_format("%^s howls in pain.", m_name);
4310 else if(percentage > 20) msg_format("%^s howls in agony.", m_name);
4311 else if(percentage > 10) msg_format("%^s writhes in agony.", m_name);
4312 else msg_format("%^s yelps feebly.", m_name);
4316 else if(my_strchr("Xbilqrt", r_ptr->d_char)) // One type of creatures (ignore,squeal,shriek)
4319 if(percentage > 95) msg_format("%^sは攻撃を気にとめていない。", m_name);
4320 else if(percentage > 75) msg_format("%^sは痛みでうなった。", m_name);
4321 else if(percentage > 50) msg_format("%^sは痛みで叫んだ。", m_name);
4322 else if(percentage > 35) msg_format("%^sは痛みで絶叫した。", m_name);
4323 else if(percentage > 20) msg_format("%^sは苦痛のあまり絶叫した。", m_name);
4324 else if(percentage > 10) msg_format("%^sは苦痛でもだえ苦しんだ。", m_name);
4325 else msg_format("%^sは弱々しく叫んだ。", m_name);
4327 if(percentage > 95) msg_format("%^s ignores the attack.", m_name);
4328 else if(percentage > 75) msg_format("%^s grunts with pain.", m_name);
4329 else if(percentage > 50) msg_format("%^s squeals in pain.", m_name);
4330 else if(percentage > 35) msg_format("%^s shrieks in pain.", m_name);
4331 else if(percentage > 20) msg_format("%^s shrieks in agony.", m_name);
4332 else if(percentage > 10) msg_format("%^s writhes in agony.", m_name);
4333 else msg_format("%^s cries out feebly.", m_name);
4337 else // Another type of creatures (shrug,cry,scream)
4340 if(percentage > 95) msg_format("%^sは攻撃に肩をすくめた。", m_name);
4341 else if(percentage > 75) msg_format("%^sは痛みでうなった。", m_name);
4342 else if(percentage > 50) msg_format("%^sは痛みで叫んだ。", m_name);
4343 else if(percentage > 35) msg_format("%^sは痛みで絶叫した。", m_name);
4344 else if(percentage > 20) msg_format("%^sは苦痛のあまり絶叫した。", m_name);
4345 else if(percentage > 10) msg_format("%^sは苦痛でもだえ苦しんだ。", m_name);
4346 else msg_format("%^sは弱々しく叫んだ。", m_name);
4348 if(percentage > 95) msg_format("%^s shrugs off the attack.", m_name);
4349 else if(percentage > 75) msg_format("%^s grunts with pain.", m_name);
4350 else if(percentage > 50) msg_format("%^s cries out in pain.", m_name);
4351 else if(percentage > 35) msg_format("%^s screams in pain.", m_name);
4352 else if(percentage > 20) msg_format("%^s screams in agony.", m_name);
4353 else if(percentage > 10) msg_format("%^s writhes in agony.", m_name);
4354 else msg_format("%^s cries out feebly.", m_name);
4362 * @brief SMART(適格に攻撃を行う)モンスターの学習状況を更新する / Learn about an "observed" resistance.
4363 * @param m_idx 更新を行う「モンスター情報ID
4364 * @param what 学習対象ID
4367 void update_smart_learn(MONSTER_IDX m_idx, int what)
4369 monster_type *m_ptr = &m_list[m_idx];
4370 monster_race *r_ptr = &r_info[m_ptr->r_idx];
4372 /* Not allowed to learn */
4373 if (!smart_learn) return;
4375 /* Too stupid to learn anything */
4376 if (r_ptr->flags2 & (RF2_STUPID)) return;
4378 /* Not intelligent, only learn sometimes */
4379 if (!(r_ptr->flags2 & (RF2_SMART)) && (randint0(100) < 50)) return;
4381 /* Analyze the knowledge */
4385 if (p_ptr->resist_acid) m_ptr->smart |= (SM_RES_ACID);
4386 if (IS_OPPOSE_ACID()) m_ptr->smart |= (SM_OPP_ACID);
4387 if (p_ptr->immune_acid) m_ptr->smart |= (SM_IMM_ACID);
4391 if (p_ptr->resist_elec) m_ptr->smart |= (SM_RES_ELEC);
4392 if (IS_OPPOSE_ELEC()) m_ptr->smart |= (SM_OPP_ELEC);
4393 if (p_ptr->immune_elec) m_ptr->smart |= (SM_IMM_ELEC);
4397 if (p_ptr->resist_fire) m_ptr->smart |= (SM_RES_FIRE);
4398 if (IS_OPPOSE_FIRE()) m_ptr->smart |= (SM_OPP_FIRE);
4399 if (p_ptr->immune_fire) m_ptr->smart |= (SM_IMM_FIRE);
4403 if (p_ptr->resist_cold) m_ptr->smart |= (SM_RES_COLD);
4404 if (IS_OPPOSE_COLD()) m_ptr->smart |= (SM_OPP_COLD);
4405 if (p_ptr->immune_cold) m_ptr->smart |= (SM_IMM_COLD);
4409 if (p_ptr->resist_pois) m_ptr->smart |= (SM_RES_POIS);
4410 if (IS_OPPOSE_POIS()) m_ptr->smart |= (SM_OPP_POIS);
4415 if (p_ptr->resist_neth) m_ptr->smart |= (SM_RES_NETH);
4419 if (p_ptr->resist_lite) m_ptr->smart |= (SM_RES_LITE);
4423 if (p_ptr->resist_dark) m_ptr->smart |= (SM_RES_DARK);
4427 if (p_ptr->resist_fear) m_ptr->smart |= (SM_RES_FEAR);
4431 if (p_ptr->resist_conf) m_ptr->smart |= (SM_RES_CONF);
4435 if (p_ptr->resist_chaos) m_ptr->smart |= (SM_RES_CHAOS);
4439 if (p_ptr->resist_disen) m_ptr->smart |= (SM_RES_DISEN);
4443 if (p_ptr->resist_blind) m_ptr->smart |= (SM_RES_BLIND);
4447 if (p_ptr->resist_nexus) m_ptr->smart |= (SM_RES_NEXUS);
4451 if (p_ptr->resist_sound) m_ptr->smart |= (SM_RES_SOUND);
4455 if (p_ptr->resist_shard) m_ptr->smart |= (SM_RES_SHARD);
4459 if (p_ptr->free_act) m_ptr->smart |= (SM_IMM_FREE);
4463 if (!p_ptr->msp) m_ptr->smart |= (SM_IMM_MANA);
4467 if (p_ptr->reflect) m_ptr-> smart |= (SM_IMM_REFLECT);
4474 * @brief プレイヤーを指定座標に配置する / Place the player in the dungeon XXX XXX
4477 * @return 配置に成功したらTRUE
4479 bool player_place(POSITION y, POSITION x)
4481 /* Paranoia XXX XXX */
4482 if (cave[y][x].m_idx != 0) return FALSE;
4484 /* Save player location */
4494 * @brief モンスターが盗みや拾いで確保していたアイテムを全てドロップさせる / Drop all items carried by a monster
4495 * @param m_ptr モンスター参照ポインタ
4498 void monster_drop_carried_objects(monster_type *m_ptr)
4500 OBJECT_IDX this_o_idx, next_o_idx = 0;
4506 /* Drop objects being carried */
4507 for (this_o_idx = m_ptr->hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
4509 o_ptr = &o_list[this_o_idx];
4511 /* Acquire next object */
4512 next_o_idx = o_ptr->next_o_idx;
4515 /* Copy the object */
4516 object_copy(q_ptr, o_ptr);
4518 /* Forget monster */
4519 q_ptr->held_m_idx = 0;
4521 delete_object_idx(this_o_idx);
4524 (void)drop_near(q_ptr, -1, m_ptr->fy, m_ptr->fx);
4527 /* Forget objects */
4528 m_ptr->hold_o_idx = 0;