3 * @brief モンスター処理 / misc code for monsters
6 * Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke
7 * This software may be copied and distributed for educational, research,
8 * and not for profit purposes provided that this copyright and statement
9 * are included in all such copies. Other copyrights may also apply.
10 * 2014 Deskull rearranged comment for Doxygen.
15 #include "monsterrace-hook.h"
16 #include "monster-status.h"
17 #include "projection.h"
19 #include "spells-summon.h"
22 #define HORDE_NOGOOD 0x01 /*!< (未実装フラグ)HORDE生成でGOODなモンスターの生成を禁止する? */
23 #define HORDE_NOEVIL 0x02 /*!< (未実装フラグ)HORDE生成でEVILなモンスターの生成を禁止する? */
28 * @brief ELDRITCH HORROR効果時のモンスターの形容メッセージ(通常時)
30 concptr horror_desc[MAX_SAN_HORROR] =
86 * @brief ELDRITCH HORROR効果時のモンスターの形容メッセージ(幻覚状態時)
88 concptr funny_desc[MAX_SAN_FUNNY] =
149 * @var funny_comments
150 * @brief ELDRITCH HORROR効果時の幻覚時間延長を示す錯乱表現
152 concptr funny_comments[MAX_SAN_COMMENT] =
173 * @brief モンスターの目標地点をセットする / Set the target of counter attack
174 * @param m_ptr モンスターの参照ポインタ
179 void set_target(monster_type *m_ptr, POSITION y, POSITION x)
187 * @brief モンスターの目標地点をリセットする / Reset the target of counter attack
188 * @param m_ptr モンスターの参照ポインタ
191 void reset_target(monster_type *m_ptr)
193 set_target(m_ptr, 0, 0);
198 * @brief モンスターの真の種族を返す / Extract monster race pointer of a monster's true form
199 * @param m_ptr モンスターの参照ポインタ
200 * @return 本当のモンスター種族参照ポインタ
202 monster_race *real_r_ptr(monster_type *m_ptr)
204 return &r_info[real_r_idx(m_ptr)];
207 MONRACE_IDX real_r_idx(monster_type *m_ptr)
209 monster_race *r_ptr = &r_info[m_ptr->r_idx];
211 /* Extract real race */
212 if (m_ptr->mflag2 & MFLAG2_CHAMELEON)
214 if (r_ptr->flags1 & RF1_UNIQUE)
215 return MON_CHAMELEON_K;
217 return MON_CHAMELEON;
227 * @brief モンスター配列からモンスターを消去する / Delete a monster by index.
228 * @param i 消去するモンスターのID
231 * モンスターを削除するとそのモンスターが拾っていたアイテムも同時に削除される。 /
232 * When a monster is deleted, all of its objects are deleted.
234 void delete_monster_idx(MONSTER_IDX i)
237 monster_type *m_ptr = &m_list[i];
238 monster_race *r_ptr = &r_info[m_ptr->r_idx];
239 OBJECT_IDX this_o_idx, next_o_idx = 0;
244 /* Hack -- Reduce the racial counter */
245 real_r_ptr(m_ptr)->cur_num--;
247 /* Hack -- count the number of "reproducers" */
248 if (r_ptr->flags2 & (RF2_MULTIPLY)) num_repro--;
250 if (MON_CSLEEP(m_ptr)) (void)set_monster_csleep(i, 0);
251 if (MON_FAST(m_ptr)) (void)set_monster_fast(i, 0);
252 if (MON_SLOW(m_ptr)) (void)set_monster_slow(i, 0);
253 if (MON_STUNNED(m_ptr)) (void)set_monster_stunned(i, 0);
254 if (MON_CONFUSED(m_ptr)) (void)set_monster_confused(i, 0);
255 if (MON_MONFEAR(m_ptr)) (void)set_monster_monfear(i, 0);
256 if (MON_INVULNER(m_ptr)) (void)set_monster_invulner(i, 0, FALSE);
258 /* Hack -- remove target monster */
259 if (i == target_who) target_who = 0;
261 /* Hack -- remove tracked monster */
262 if (i == p_ptr->health_who) health_track(0);
264 if (pet_t_m_idx == i ) pet_t_m_idx = 0;
265 if (riding_t_m_idx == i) riding_t_m_idx = 0;
266 if (p_ptr->riding == i) p_ptr->riding = 0;
268 /* Monster is gone */
269 grid_array[y][x].m_idx = 0;
271 for (this_o_idx = m_ptr->hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
274 o_ptr = &o_list[this_o_idx];
276 /* Acquire next object */
277 next_o_idx = o_ptr->next_o_idx;
280 * o_ptr->held_m_idx is needed in delete_object_idx()
281 * to prevent calling lite_spot()
284 delete_object_idx(this_o_idx);
288 if (is_pet(m_ptr)) check_pets_num_and_align(m_ptr, FALSE);
291 /* Wipe the Monster */
292 (void)WIPE(m_ptr, monster_type);
300 /* Update some things */
301 if (r_ptr->flags7 & (RF7_LITE_MASK | RF7_DARK_MASK))
302 p_ptr->update |= (PU_MON_LITE);
307 * @brief 指定位置に存在するモンスターを削除する / Delete the monster, if any, at a given location
312 void delete_monster(POSITION y, POSITION x)
317 if (!in_bounds(y, x)) return;
320 g_ptr = &grid_array[y][x];
322 /* Delete the monster (if any) */
323 if (g_ptr->m_idx) delete_monster_idx(g_ptr->m_idx);
328 * @brief モンスター情報を配列内移動する / Move an object from index i1 to index i2 in the object list
333 static void compact_monsters_aux(IDX i1, IDX i2)
339 OBJECT_IDX this_o_idx, next_o_idx = 0;
342 if (i1 == i2) return;
351 g_ptr = &grid_array[y][x];
353 /* Update the grid_array */
356 /* Repair objects being carried by monster */
357 for (this_o_idx = m_ptr->hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
360 o_ptr = &o_list[this_o_idx];
362 /* Acquire next object */
363 next_o_idx = o_ptr->next_o_idx;
365 /* Reset monster pointer */
366 o_ptr->held_m_idx = i2;
369 /* Hack -- Update the target */
370 if (target_who == i1) target_who = i2;
372 /* Hack -- Update the target */
373 if (pet_t_m_idx == i1) pet_t_m_idx = i2;
374 if (riding_t_m_idx == i1) riding_t_m_idx = i2;
376 /* Hack -- Update the riding */
377 if (p_ptr->riding == i1) p_ptr->riding = i2;
379 /* Hack -- Update the health bar */
380 if (p_ptr->health_who == i1) health_track(i2);
382 /* Hack -- Update parent index */
385 for (i = 1; i < m_max; i++)
387 monster_type *m2_ptr = &m_list[i];
389 if (m2_ptr->parent_m_idx == i1)
390 m2_ptr->parent_m_idx = i2;
395 (void)COPY(&m_list[i2], &m_list[i1], monster_type);
398 (void)WIPE(&m_list[i1], monster_type);
400 for (i = 0; i < MAX_MTIMED; i++)
402 int mproc_idx = get_mproc_idx(i1, i);
403 if (mproc_idx >= 0) mproc_list[i][mproc_idx] = i2;
409 * @brief モンスター情報配列を圧縮する / Compact and Reorder the monster list
410 * @param size 圧縮後のモンスター件数目標
413 * This function can be very dangerous, use with caution!
415 * When actually "compacting" monsters, we base the saving throw
416 * on a combination of monster level, distance from player, and
417 * current "desperation".
419 * After "compacting" (if needed), we "reorder" the monsters into a more
420 * compact order, and we reset the allocation info, and the "live" array.
422 void compact_monsters(int size)
426 int cur_lev, cur_dis, chance;
428 /* Message (only if compacting) */
429 if (size) msg_print(_("モンスター情報を圧縮しています...", "Compacting monsters..."));
432 /* Compact at least 'size' objects */
433 for (num = 0, cnt = 1; num < size; cnt++)
435 /* Get more vicious each iteration */
438 /* Get closer each iteration */
439 cur_dis = 5 * (20 - cnt);
441 /* Check all the monsters */
442 for (i = 1; i < m_max; i++)
444 monster_type *m_ptr = &m_list[i];
446 monster_race *r_ptr = &r_info[m_ptr->r_idx];
448 /* Paranoia -- skip "dead" monsters */
449 if (!m_ptr->r_idx) continue;
451 /* Hack -- High level monsters start out "immune" */
452 if (r_ptr->level > cur_lev) continue;
454 if (i == p_ptr->riding) continue;
456 /* Ignore nearby monsters */
457 if ((cur_dis > 0) && (m_ptr->cdis < cur_dis)) continue;
459 /* Saving throw chance */
462 /* Only compact "Quest" Monsters in emergencies */
463 if ((r_ptr->flags1 & (RF1_QUESTOR)) && (cnt < 1000)) chance = 100;
465 /* Try not to compact Unique Monsters */
466 if (r_ptr->flags1 & (RF1_UNIQUE)) chance = 100;
468 /* All monsters get a saving throw */
469 if (randint0(100) < chance) continue;
471 if (record_named_pet && is_pet(m_ptr) && m_ptr->nickname)
473 GAME_TEXT m_name[MAX_NLEN];
474 monster_desc(m_name, m_ptr, MD_INDEF_VISIBLE);
475 do_cmd_write_nikki(NIKKI_NAMED_PET, RECORD_NAMED_PET_COMPACT, m_name);
478 delete_monster_idx(i);
480 /* Count the monster */
486 /* Excise dead monsters (backwards!) */
487 for (i = m_max - 1; i >= 1; i--)
489 /* Get the i'th monster */
490 monster_type *m_ptr = &m_list[i];
492 /* Skip real monsters */
493 if (m_ptr->r_idx) continue;
495 /* Move last monster into open hole */
496 compact_monsters_aux(m_max - 1, i);
498 /* Compress "m_max" */
505 * @brief プレイヤーのフロア離脱に伴う全モンスター配列の消去 / Delete/Remove all the monsters when the player leaves the level
508 * This is an efficient method of simulating multiple calls to the
509 * "delete_monster()" function, with no visual effects.
511 void wipe_m_list(void)
515 /* Hack -- if Banor or Lupart dies, stay another dead */
516 if (!r_info[MON_BANORLUPART].max_num)
518 if (r_info[MON_BANOR].max_num)
520 r_info[MON_BANOR].max_num = 0;
521 r_info[MON_BANOR].r_pkills++;
522 r_info[MON_BANOR].r_akills++;
523 if (r_info[MON_BANOR].r_tkills < MAX_SHORT) r_info[MON_BANOR].r_tkills++;
525 if (r_info[MON_LUPART].max_num)
527 r_info[MON_LUPART].max_num = 0;
528 r_info[MON_LUPART].r_pkills++;
529 r_info[MON_LUPART].r_akills++;
530 if (r_info[MON_LUPART].r_tkills < MAX_SHORT) r_info[MON_LUPART].r_tkills++;
534 /* Delete all the monsters */
535 for (i = m_max - 1; i >= 1; i--)
537 monster_type *m_ptr = &m_list[i];
539 /* Skip dead monsters */
540 if (!m_ptr->r_idx) continue;
542 /* Monster is gone */
543 grid_array[m_ptr->fy][m_ptr->fx].m_idx = 0;
545 /* Wipe the Monster */
546 (void)WIPE(m_ptr, monster_type);
551 * Wiping racial counters of all monsters and incrementing of racial
552 * counters of monsters in party_mon[] are required to prevent multiple
553 * generation of unique monster who is the minion of player.
556 /* Hack -- Wipe the racial counter of all monster races */
557 for (i = 1; i < max_r_idx; i++) r_info[i].cur_num = 0;
565 /* Reset "mproc_max[]" */
566 for (i = 0; i < MAX_MTIMED; i++) mproc_max[i] = 0;
568 /* Hack -- reset "reproducer" count */
571 /* Hack -- no more target */
576 /* Hack -- no more tracking */
582 * @brief モンスター配列の空きを探す / Acquires and returns the index of a "free" monster.
583 * @return 利用可能なモンスター配列の添字
585 * This routine should almost never fail, but it *can* happen.
587 MONSTER_IDX m_pop(void)
591 /* Normal allocation */
592 if (m_max < max_m_idx)
594 /* Access the next hole */
597 /* Expand the array */
603 /* Return the index */
607 /* Recycle dead monsters */
608 for (i = 1; i < m_max; i++)
612 /* Acquire monster */
615 /* Skip live monsters */
616 if (m_ptr->r_idx) continue;
621 /* Use this monster */
625 /* Warn the player (except during dungeon creation) */
626 if (character_dungeon) msg_print(_("モンスターが多すぎる!", "Too many monsters!"));
628 /* Try not to crash */
636 * @var summon_specific_type
637 * @brief 召喚条件を指定するグローバル変数 / Hack -- the "type" of the current "summon specific"
638 * @todo summon_specific_typeグローバル変数の除去と関数引数への代替を行う
640 static int summon_specific_type = 0;
644 * @var summon_specific_who
645 * @brief 召喚を行ったプレイヤーあるいはモンスターのIDを示すグローバル変数 / Hack -- the index of the summoning monster
646 * @todo summon_specific_who グローバル変数の除去と関数引数への代替を行う
648 static int summon_specific_who = -1;
651 * @var summon_unique_okay
652 * @brief 召喚対象にユニークを含めるかを示すグローバル変数 / summoning unique enable
653 * @todo summon_unique_okay グローバル変数の除去と関数引数への代替を行う
655 static bool summon_unique_okay = FALSE;
658 * @brief 指定されたモンスター種族がsummon_specific_typeで指定された召喚条件に合うかどうかを返す
659 * @return 召喚条件が一致するならtrue
662 static bool summon_specific_aux(MONRACE_IDX r_idx)
664 monster_race *r_ptr = &r_info[r_idx];
667 /* Check our requirements */
668 switch (summon_specific_type)
672 okay = (r_ptr->d_char == 'a');
678 okay = (r_ptr->d_char == 'S');
684 okay = ((r_ptr->d_char == 'C') || (r_ptr->d_char == 'Z'));
690 okay = (r_ptr->d_char == 'M');
696 okay = (r_ptr->d_char == 'A' && ((r_ptr->flags3 & RF3_EVIL) || (r_ptr->flags3 & RF3_GOOD)));
702 okay = (r_ptr->flags3 & RF3_DEMON);
708 okay = (r_ptr->flags3 & RF3_UNDEAD);
714 okay = (r_ptr->flags3 & RF3_DRAGON);
718 case SUMMON_HI_UNDEAD:
720 okay = ((r_ptr->d_char == 'L') ||
721 (r_ptr->d_char == 'V') ||
722 (r_ptr->d_char == 'W'));
726 case SUMMON_HI_DRAGON:
728 okay = (r_ptr->d_char == 'D');
732 case SUMMON_HI_DEMON:
734 okay = (((r_ptr->d_char == 'U') ||
735 (r_ptr->d_char == 'H') ||
736 (r_ptr->d_char == 'B')) &&
737 (r_ptr->flags3 & RF3_DEMON)) ? TRUE : FALSE;
741 case SUMMON_AMBERITES:
743 okay = (r_ptr->flags3 & (RF3_AMBERITE)) ? TRUE : FALSE;
749 okay = (r_ptr->flags1 & (RF1_UNIQUE)) ? TRUE : FALSE;
755 okay = (r_ptr->d_char == 'm');
760 okay = (r_ptr->d_char == 'b');
763 case SUMMON_QUYLTHULG:
765 okay = (r_ptr->d_char == 'Q');
769 case SUMMON_COIN_MIMIC:
771 okay = (r_ptr->d_char == '$');
777 okay = ((r_ptr->d_char == '!') ||
778 (r_ptr->d_char == '?') ||
779 (r_ptr->d_char == '=') ||
780 (r_ptr->d_char == '$') ||
781 (r_ptr->d_char == '|'));
787 okay = (r_ptr->d_char == 'g');
793 okay = ((r_ptr->d_char == 'U') &&
794 (r_ptr->flags4 & RF4_ROCKET));
800 okay = ((r_ptr->d_char == summon_kin_type) && (r_idx != MON_HAGURE));
806 okay = (r_idx == MON_DAWN);
812 okay = (r_ptr->flags3 & (RF3_ANIMAL));
816 case SUMMON_ANIMAL_RANGER:
818 okay = ((r_ptr->flags3 & (RF3_ANIMAL)) &&
819 (my_strchr("abcflqrwBCHIJKMRS", r_ptr->d_char)) &&
820 !(r_ptr->flags3 & (RF3_DRAGON)) &&
821 !(r_ptr->flags3 & (RF3_EVIL)) &&
822 !(r_ptr->flags3 & (RF3_UNDEAD)) &&
823 !(r_ptr->flags3 & (RF3_DEMON)) &&
824 !(r_ptr->flags2 & (RF2_MULTIPLY)) &&
825 !(r_ptr->flags4 || r_ptr->a_ability_flags1 || r_ptr->a_ability_flags2));
829 case SUMMON_HI_DRAGON_LIVING:
831 okay = ((r_ptr->d_char == 'D') && monster_living(r_idx));
837 okay = monster_living(r_idx);
843 okay = (r_idx == MON_PHANTOM_B || r_idx == MON_PHANTOM_W);
847 case SUMMON_BLUE_HORROR:
849 okay = (r_idx == MON_BLUE_HORROR);
853 case SUMMON_ELEMENTAL:
855 okay = (r_ptr->d_char == 'E');
861 okay = (r_ptr->d_char == 'v');
867 okay = (r_ptr->d_char == 'H');
873 okay = (r_ptr->d_char == 'B');
877 case SUMMON_KAMIKAZE:
880 for (i = 0; i < 4; i++)
881 if (r_ptr->blow[i].method == RBM_EXPLODE) okay = TRUE;
885 case SUMMON_KAMIKAZE_LIVING:
889 for (i = 0; i < 4; i++)
890 if (r_ptr->blow[i].method == RBM_EXPLODE) okay = TRUE;
891 okay = (okay && monster_living(r_idx));
897 okay = (r_idx == MON_MANES);
903 okay = (r_idx == MON_LOUSE);
907 case SUMMON_GUARDIANS:
909 okay = (r_ptr->flags7 & RF7_GUARDIAN);
915 okay = ((r_idx == MON_NOV_PALADIN) ||
916 (r_idx == MON_NOV_PALADIN_G) ||
917 (r_idx == MON_PALADIN) ||
918 (r_idx == MON_W_KNIGHT) ||
919 (r_idx == MON_ULTRA_PALADIN) ||
920 (r_idx == MON_KNI_TEMPLAR));
926 okay = (r_ptr->d_char == 'B' &&
927 (r_ptr->flags8 & RF8_WILD_MOUNTAIN) &&
928 (r_ptr->flags8 & RF8_WILD_ONLY));
932 case SUMMON_PIRANHAS:
934 okay = (r_idx == MON_PIRANHA);
938 case SUMMON_ARMAGE_GOOD:
940 okay = (r_ptr->d_char == 'A' && (r_ptr->flags3 & RF3_GOOD));
944 case SUMMON_ARMAGE_EVIL:
946 okay = ((r_ptr->flags3 & RF3_DEMON) ||
947 (r_ptr->d_char == 'A' && (r_ptr->flags3 & RF3_EVIL)));
951 /* Since okay is int, "return (okay);" is not correct. */
952 return (bool)(okay ? TRUE : FALSE);
956 * @var chameleon_change_m_idx
957 * @brief カメレオンの変身先モンスターIDを受け渡すためのグローバル変数
958 * @todo 変数渡しの問題などもあるができればchameleon_change_m_idxのグローバル変数を除去し、関数引き渡しに移行すること
960 static int chameleon_change_m_idx = 0;
964 * @brief 指定されたモンスター種族がダンジョンの制限にかかるかどうかをチェックする / Some dungeon types restrict the possible monsters.
965 * @param r_idx チェックするモンスター種族ID
966 * @return 召喚条件が一致するならtrue / Return TRUE is the monster is OK and FALSE otherwise
968 static bool restrict_monster_to_dungeon(MONRACE_IDX r_idx)
970 dungeon_type *d_ptr = &d_info[p_ptr->dungeon_idx];
971 monster_race *r_ptr = &r_info[r_idx];
974 if (d_ptr->flags1 & DF1_CHAMELEON)
976 if (chameleon_change_m_idx) return TRUE;
978 if (d_ptr->flags1 & DF1_NO_MAGIC)
980 if (r_idx != MON_CHAMELEON &&
982 !(r_ptr->flags4 & RF4_NOMAGIC_MASK) &&
983 !(r_ptr->a_ability_flags1 & RF5_NOMAGIC_MASK) &&
984 !(r_ptr->a_ability_flags2 & RF6_NOMAGIC_MASK))
987 if (d_ptr->flags1 & DF1_NO_MELEE)
989 if (r_idx == MON_CHAMELEON) return TRUE;
990 if (!(r_ptr->flags4 & (RF4_BOLT_MASK | RF4_BEAM_MASK | RF4_BALL_MASK)) &&
991 !(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)) &&
992 !(r_ptr->a_ability_flags2 & (RF6_BOLT_MASK | RF6_BEAM_MASK | RF6_BALL_MASK)))
995 if (d_ptr->flags1 & DF1_BEGINNER)
997 if (r_ptr->level > dun_level)
1001 if (d_ptr->special_div >= 64) return TRUE;
1002 if (summon_specific_type && !(d_ptr->flags1 & DF1_CHAMELEON)) return TRUE;
1004 switch (d_ptr->mode)
1006 case DUNGEON_MODE_AND:
1009 if ((d_ptr->mflags1 & r_ptr->flags1) != d_ptr->mflags1)
1014 if ((d_ptr->mflags2 & r_ptr->flags2) != d_ptr->mflags2)
1019 if ((d_ptr->mflags3 & r_ptr->flags3) != d_ptr->mflags3)
1024 if ((d_ptr->mflags4 & r_ptr->flags4) != d_ptr->mflags4)
1027 if (d_ptr->m_a_ability_flags1)
1029 if ((d_ptr->m_a_ability_flags1 & r_ptr->a_ability_flags1) != d_ptr->m_a_ability_flags1)
1032 if (d_ptr->m_a_ability_flags2)
1034 if ((d_ptr->m_a_ability_flags2 & r_ptr->a_ability_flags2) != d_ptr->m_a_ability_flags2)
1039 if ((d_ptr->mflags7 & r_ptr->flags7) != d_ptr->mflags7)
1044 if ((d_ptr->mflags8 & r_ptr->flags8) != d_ptr->mflags8)
1049 if ((d_ptr->mflags9 & r_ptr->flags9) != d_ptr->mflags9)
1054 if ((d_ptr->mflagsr & r_ptr->flagsr) != d_ptr->mflagsr)
1057 for (a = 0; a < 5; a++)
1058 if (d_ptr->r_char[a] && (d_ptr->r_char[a] != r_ptr->d_char)) return FALSE;
1062 case DUNGEON_MODE_NAND:
1065 if ((d_ptr->mflags1 & r_ptr->flags1) != d_ptr->mflags1)
1070 if ((d_ptr->mflags2 & r_ptr->flags2) != d_ptr->mflags2)
1075 if ((d_ptr->mflags3 & r_ptr->flags3) != d_ptr->mflags3)
1080 if ((d_ptr->mflags4 & r_ptr->flags4) != d_ptr->mflags4)
1083 if (d_ptr->m_a_ability_flags1)
1085 if ((d_ptr->m_a_ability_flags1 & r_ptr->a_ability_flags1) != d_ptr->m_a_ability_flags1)
1088 if (d_ptr->m_a_ability_flags2)
1090 if ((d_ptr->m_a_ability_flags2 & r_ptr->a_ability_flags2) != d_ptr->m_a_ability_flags2)
1095 if ((d_ptr->mflags7 & r_ptr->flags7) != d_ptr->mflags7)
1100 if ((d_ptr->mflags8 & r_ptr->flags8) != d_ptr->mflags8)
1105 if ((d_ptr->mflags9 & r_ptr->flags9) != d_ptr->mflags9)
1110 if ((d_ptr->mflagsr & r_ptr->flagsr) != d_ptr->mflagsr)
1113 for (a = 0; a < 5; a++)
1114 if (d_ptr->r_char[a] && (d_ptr->r_char[a] != r_ptr->d_char)) return TRUE;
1118 case DUNGEON_MODE_OR:
1119 if (r_ptr->flags1 & d_ptr->mflags1) return TRUE;
1120 if (r_ptr->flags2 & d_ptr->mflags2) return TRUE;
1121 if (r_ptr->flags3 & d_ptr->mflags3) return TRUE;
1122 if (r_ptr->flags4 & d_ptr->mflags4) return TRUE;
1123 if (r_ptr->a_ability_flags1 & d_ptr->m_a_ability_flags1) return TRUE;
1124 if (r_ptr->a_ability_flags2 & d_ptr->m_a_ability_flags2) return TRUE;
1125 if (r_ptr->flags7 & d_ptr->mflags7) return TRUE;
1126 if (r_ptr->flags8 & d_ptr->mflags8) return TRUE;
1127 if (r_ptr->flags9 & d_ptr->mflags9) return TRUE;
1128 if (r_ptr->flagsr & d_ptr->mflagsr) return TRUE;
1129 for (a = 0; a < 5; a++)
1130 if (d_ptr->r_char[a] == r_ptr->d_char) return TRUE;
1134 case DUNGEON_MODE_NOR:
1135 if (r_ptr->flags1 & d_ptr->mflags1) return FALSE;
1136 if (r_ptr->flags2 & d_ptr->mflags2) return FALSE;
1137 if (r_ptr->flags3 & d_ptr->mflags3) return FALSE;
1138 if (r_ptr->flags4 & d_ptr->mflags4) return FALSE;
1139 if (r_ptr->a_ability_flags1 & d_ptr->m_a_ability_flags1) return FALSE;
1140 if (r_ptr->a_ability_flags2 & d_ptr->m_a_ability_flags2) return FALSE;
1141 if (r_ptr->flags7 & d_ptr->mflags7) return FALSE;
1142 if (r_ptr->flags8 & d_ptr->mflags8) return FALSE;
1143 if (r_ptr->flags9 & d_ptr->mflags9) return FALSE;
1144 if (r_ptr->flagsr & d_ptr->mflagsr) return FALSE;
1145 for (a = 0; a < 5; a++)
1146 if (d_ptr->r_char[a] == r_ptr->d_char) return FALSE;
1155 * @brief モンスター生成制限関数最大2つから / Apply a "monster restriction function" to the "monster allocation table"
1156 * @param monster_hook 制限関数1
1157 * @param monster_hook2 制限関数2
1160 errr get_mon_num_prep(monsterrace_hook_type monster_hook,
1161 monsterrace_hook_type monster_hook2)
1165 /* Todo: Check the hooks for non-changes */
1167 /* Set the new hooks */
1168 get_mon_num_hook = monster_hook;
1169 get_mon_num2_hook = monster_hook2;
1171 /* Scan the allocation table */
1172 for (i = 0; i < alloc_race_size; i++)
1174 monster_race *r_ptr;
1177 alloc_entry *entry = &alloc_race_table[i];
1180 r_ptr = &r_info[entry->index];
1182 /* Skip monsters which don't pass the restriction */
1183 if ((get_mon_num_hook && !((*get_mon_num_hook)(entry->index))) ||
1184 (get_mon_num2_hook && !((*get_mon_num2_hook)(entry->index))))
1187 if (!p_ptr->inside_battle && !chameleon_change_m_idx &&
1188 summon_specific_type != SUMMON_GUARDIANS)
1190 /* Hack -- don't create questors */
1191 if (r_ptr->flags1 & RF1_QUESTOR)
1194 if (r_ptr->flags7 & RF7_GUARDIAN)
1197 /* Depth Monsters never appear out of depth */
1198 if ((r_ptr->flags1 & (RF1_FORCE_DEPTH)) &&
1199 (r_ptr->level > dun_level))
1203 /* Accept this monster */
1204 entry->prob2 = entry->prob1;
1206 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)
1208 int hoge = entry->prob2 * d_info[p_ptr->dungeon_idx].special_div;
1209 entry->prob2 = hoge / 64;
1210 if (randint0(64) < (hoge & 0x3f)) entry->prob2++;
1220 * @brief 生成モンスター種族を1種生成テーブルから選択する
1222 * @return 選択されたモンスター生成種族
1224 * Choose a monster race that seems "appropriate" to the given level
1226 * This function uses the "prob2" field of the "monster allocation table",
1227 * and various local information, to calculate the "prob3" field of the
1228 * same table, which is then used to choose an "appropriate" monster, in
1229 * a relatively efficient manner.
1231 * Note that "town" monsters will *only* be created in the town, and
1232 * "normal" monsters will *never* be created in the town, unless the
1233 * "level" is "modified", for example, by polymorph or summoning.
1235 * There is a small chance (1/50) of "boosting" the given depth by
1236 * a small amount (up to four levels), except in the town.
1238 * It is (slightly) more likely to acquire a monster of the given level
1239 * than one of a lower level. This is done by choosing several monsters
1240 * appropriate to the given level and keeping the "hardest" one.
1242 * Note that if no monsters are "appropriate", then this function will
1243 * fail, and return zero, but this should *almost* never happen.
1245 MONRACE_IDX get_mon_num(DEPTH level)
1250 monster_race *r_ptr;
1251 alloc_entry *table = alloc_race_table;
1253 int pls_kakuritu, pls_level;
1254 int delay = mysqrt(level * 10000L) + 400L;
1256 pls_kakuritu = MAX(NASTY_MON_MAX, NASTY_MON_BASE - ((dungeon_turn / (TURNS_PER_TICK * 5000L) - delay / 10)));
1257 pls_level = MIN(NASTY_MON_PLUS_MAX, 3 + dungeon_turn / (TURNS_PER_TICK * 40000L) - delay / 40 + MIN(5, level / 10)) ;
1259 if (d_info[p_ptr->dungeon_idx].flags1 & DF1_MAZE)
1261 pls_kakuritu = MIN(pls_kakuritu / 2, pls_kakuritu - 10);
1262 if (pls_kakuritu < 2) pls_kakuritu = 2;
1267 /* Boost the level */
1268 if (!p_ptr->inside_battle && !(d_info[p_ptr->dungeon_idx].flags1 & DF1_BEGINNER))
1270 /* Nightmare mode allows more out-of depth monsters */
1271 if (ironman_nightmare && !randint0(pls_kakuritu))
1273 /* What a bizarre calculation */
1274 level = 1 + (level * MAX_DEPTH / randint1(MAX_DEPTH));
1278 /* Occasional "nasty" monster */
1279 if (!randint0(pls_kakuritu))
1281 /* Pick a level bonus */
1287 if (level > MAX_DEPTH - 1) level = MAX_DEPTH - 1;
1288 if (level < 0) level = 0;
1293 /* Process probabilities */
1294 for (i = 0; i < alloc_race_size; i++)
1296 /* Monsters are sorted by depth */
1297 if (table[i].level > level) break;
1302 /* Access the "r_idx" of the chosen monster */
1303 r_idx = table[i].index;
1305 /* Access the actual race */
1306 r_ptr = &r_info[r_idx];
1308 if (!p_ptr->inside_battle && !chameleon_change_m_idx)
1310 /* Hack -- "unique" monsters must be "unique" */
1311 if (((r_ptr->flags1 & (RF1_UNIQUE)) ||
1312 (r_ptr->flags7 & (RF7_NAZGUL))) &&
1313 (r_ptr->cur_num >= r_ptr->max_num))
1318 if ((r_ptr->flags7 & (RF7_UNIQUE2)) &&
1319 (r_ptr->cur_num >= 1))
1324 if (r_idx == MON_BANORLUPART)
1326 if (r_info[MON_BANOR].cur_num > 0) continue;
1327 if (r_info[MON_LUPART].cur_num > 0) continue;
1332 table[i].prob3 = table[i].prob2;
1335 total += table[i].prob3;
1338 /* No legal monsters */
1339 if (total <= 0) return (0);
1341 /* Pick a monster */
1342 value = randint0(total);
1344 /* Find the monster */
1345 for (i = 0; i < alloc_race_size; i++)
1347 /* Found the entry */
1348 if (value < table[i].prob3) break;
1351 value = value - table[i].prob3;
1357 /* Try for a "harder" monster once (50%) or twice (10%) */
1363 /* Pick a monster */
1364 value = randint0(total);
1366 /* Find the monster */
1367 for (i = 0; i < alloc_race_size; i++)
1369 /* Found the entry */
1370 if (value < table[i].prob3) break;
1373 value = value - table[i].prob3;
1376 /* Keep the "best" one */
1377 if (table[i].level < table[j].level) i = j;
1380 /* Try for a "harder" monster twice (10%) */
1386 /* Pick a monster */
1387 value = randint0(total);
1389 /* Find the monster */
1390 for (i = 0; i < alloc_race_size; i++)
1392 /* Found the entry */
1393 if (value < table[i].prob3) break;
1396 value = value - table[i].prob3;
1399 /* Keep the "best" one */
1400 if (table[i].level < table[j].level) i = j;
1402 return (table[i].index);
1407 * @brief モンスターの呼称を作成する / Build a string describing a monster in some way.
1408 * @param desc 記述出力先の文字列参照ポインタ
1409 * @param m_ptr モンスターの参照ポインタ
1410 * @param mode 呼称オプション
1413 * We can correctly describe monsters based on their visibility.
1414 * We can force all monsters to be treated as visible or invisible.
1415 * We can build nominatives, objectives, possessives, or reflexives.
1416 * We can selectively pronominalize hidden, visible, or all monsters.
1417 * We can use definite or indefinite descriptions for hidden monsters.
1418 * We can use definite or indefinite descriptions for visible monsters.
1420 * Pronominalization involves the gender whenever possible and allowed,
1421 * so that by cleverly requesting pronominalization / visibility, you
1422 * can get messages like "You hit someone. She screams in agony!".
1424 * Reflexives are acquired by requesting Objective plus Possessive.
1426 * If no m_ptr arg is given (?), the monster is assumed to be hidden,
1427 * unless the "Assume Visible" mode is requested.
1429 * If no r_ptr arg is given, it is extracted from m_ptr and r_info
1430 * If neither m_ptr nor r_ptr is given, the monster is assumed to
1431 * be neuter, singular, and hidden (unless "Assume Visible" is set),
1432 * in which case you may be in trouble... :-)
1434 * I am assuming that no monster name is more than 70 characters long,
1435 * so that "char desc[80];" is sufficiently large for any result.
1438 * MD_OBJECTIVE --> Objective (or Reflexive)
1439 * MD_POSSESSIVE --> Possessive (or Reflexive)
1440 * MD_INDEF_HIDDEN --> Use indefinites for hidden monsters ("something")
1441 * MD_INDEF_VISIBLE --> Use indefinites for visible monsters ("a kobold")
1442 * MD_PRON_HIDDEN --> Pronominalize hidden monsters
1443 * MD_PRON_VISIBLE --> Pronominalize visible monsters
1444 * MD_ASSUME_HIDDEN --> Assume the monster is hidden
1445 * MD_ASSUME_VISIBLE --> Assume the monster is visible
1446 * MD_TRUE_NAME --> Chameleon's true name
1447 * MD_IGNORE_HALLU --> Ignore hallucination, and penetrate shape change
1450 * 0x00 --> Full nominative name ("the kobold") or "it"
1451 * MD_INDEF_HIDDEN --> Full nominative name ("the kobold") or "something"
1452 * MD_ASSUME_VISIBLE --> Genocide resistance name ("the kobold")
1453 * MD_ASSUME_VISIBLE | MD_INDEF_VISIBLE --> Killing name ("a kobold")
1454 * MD_PRON_VISIBLE | MD_POSSESSIVE
1455 * --> Possessive, genderized if visable ("his") or "its"
1456 * MD_PRON_VISIBLE | MD_POSSESSIVE | MD_OBJECTIVE
1457 * --> Reflexive, genderized if visable ("himself") or "itself"
1459 void monster_desc(char *desc, monster_type *m_ptr, BIT_FLAGS mode)
1462 monster_race *r_ptr;
1466 GAME_TEXT silly_name[1024];
1470 r_ptr = &r_info[m_ptr->ap_r_idx];
1472 /* Mode of MD_TRUE_NAME will reveal Chameleon's true name */
1473 if (mode & MD_TRUE_NAME) name = (r_name + real_r_ptr(m_ptr)->name);
1474 else name = (r_name + r_ptr->name);
1476 /* Are we hallucinating? (Idea from Nethack...) */
1477 if (p_ptr->image && !(mode & MD_IGNORE_HALLU))
1481 if (!get_rnd_line(_("silly_j.txt", "silly.txt"), m_ptr->r_idx, silly_name))
1487 monster_race *hallu_race;
1491 hallu_race = &r_info[randint1(max_r_idx - 1)];
1493 while (!hallu_race->name || (hallu_race->flags1 & RF1_UNIQUE));
1495 strcpy(silly_name, (r_name + hallu_race->name));
1498 /* Better not strcpy it, or we could corrupt r_info... */
1502 /* Can we "see" it (exists + forced, or visible + not unforced) */
1503 seen = (m_ptr && ((mode & MD_ASSUME_VISIBLE) || (!(mode & MD_ASSUME_HIDDEN) && m_ptr->ml)));
1505 /* Sexed Pronouns (seen and allowed, or unseen and allowed) */
1506 pron = (m_ptr && ((seen && (mode & MD_PRON_VISIBLE)) || (!seen && (mode & MD_PRON_HIDDEN))));
1509 /* First, try using pronouns, or describing hidden monsters */
1512 /* an encoding of the monster "sex" */
1515 /* Extract the gender (if applicable) */
1516 if (r_ptr->flags1 & (RF1_FEMALE)) kind = 0x20;
1517 else if (r_ptr->flags1 & (RF1_MALE)) kind = 0x10;
1519 /* Ignore the gender (if desired) */
1520 if (!m_ptr || !pron) kind = 0x00;
1523 /* Assume simple result */
1524 res = _("何か", "it");
1526 /* Brute force: split on the possibilities */
1527 switch (kind + (mode & (MD_INDEF_HIDDEN | MD_POSSESSIVE | MD_OBJECTIVE)))
1529 /* Neuter, or unknown */
1531 case 0x00: res = "何か"; break;
1532 case 0x00 + (MD_OBJECTIVE): res = "何か"; break;
1533 case 0x00 + (MD_POSSESSIVE): res = "何かの"; break;
1534 case 0x00 + (MD_POSSESSIVE | MD_OBJECTIVE): res = "何か自身"; break;
1535 case 0x00 + (MD_INDEF_HIDDEN): res = "何か"; break;
1536 case 0x00 + (MD_INDEF_HIDDEN | MD_OBJECTIVE): res = "何か"; break;
1537 case 0x00 + (MD_INDEF_HIDDEN | MD_POSSESSIVE): res = "何か"; break;
1538 case 0x00 + (MD_INDEF_HIDDEN | MD_POSSESSIVE | MD_OBJECTIVE): res = "それ自身"; break;
1540 case 0x00: res = "it"; break;
1541 case 0x00 + (MD_OBJECTIVE): res = "it"; break;
1542 case 0x00 + (MD_POSSESSIVE): res = "its"; break;
1543 case 0x00 + (MD_POSSESSIVE | MD_OBJECTIVE): res = "itself"; break;
1544 case 0x00 + (MD_INDEF_HIDDEN): res = "something"; break;
1545 case 0x00 + (MD_INDEF_HIDDEN | MD_OBJECTIVE): res = "something"; break;
1546 case 0x00 + (MD_INDEF_HIDDEN | MD_POSSESSIVE): res = "something's"; break;
1547 case 0x00 + (MD_INDEF_HIDDEN | MD_POSSESSIVE | MD_OBJECTIVE): res = "itself"; break;
1551 /* Male (assume human if vague) */
1553 case 0x10: res = "彼"; break;
1554 case 0x10 + (MD_OBJECTIVE): res = "彼"; break;
1555 case 0x10 + (MD_POSSESSIVE): res = "彼の"; break;
1556 case 0x10 + (MD_POSSESSIVE | MD_OBJECTIVE): res = "彼自身"; break;
1557 case 0x10 + (MD_INDEF_HIDDEN): res = "誰か"; break;
1558 case 0x10 + (MD_INDEF_HIDDEN | MD_OBJECTIVE): res = "誰か"; break;
1559 case 0x10 + (MD_INDEF_HIDDEN | MD_POSSESSIVE): res = "誰かの"; break;
1560 case 0x10 + (MD_INDEF_HIDDEN | MD_POSSESSIVE | MD_OBJECTIVE): res = "彼自身"; break;
1562 case 0x10: res = "he"; break;
1563 case 0x10 + (MD_OBJECTIVE): res = "him"; break;
1564 case 0x10 + (MD_POSSESSIVE): res = "his"; break;
1565 case 0x10 + (MD_POSSESSIVE | MD_OBJECTIVE): res = "himself"; break;
1566 case 0x10 + (MD_INDEF_HIDDEN): res = "someone"; break;
1567 case 0x10 + (MD_INDEF_HIDDEN | MD_OBJECTIVE): res = "someone"; break;
1568 case 0x10 + (MD_INDEF_HIDDEN | MD_POSSESSIVE): res = "someone's"; break;
1569 case 0x10 + (MD_INDEF_HIDDEN | MD_POSSESSIVE | MD_OBJECTIVE): res = "himself"; break;
1573 /* Female (assume human if vague) */
1575 case 0x20: res = "彼女"; break;
1576 case 0x20 + (MD_OBJECTIVE): res = "彼女"; break;
1577 case 0x20 + (MD_POSSESSIVE): res = "彼女の"; break;
1578 case 0x20 + (MD_POSSESSIVE | MD_OBJECTIVE): res = "彼女自身"; break;
1579 case 0x20 + (MD_INDEF_HIDDEN): res = "誰か"; break;
1580 case 0x20 + (MD_INDEF_HIDDEN | MD_OBJECTIVE): res = "誰か"; break;
1581 case 0x20 + (MD_INDEF_HIDDEN | MD_POSSESSIVE): res = "誰かの"; break;
1582 case 0x20 + (MD_INDEF_HIDDEN | MD_POSSESSIVE | MD_OBJECTIVE): res = "彼女自身"; break;
1584 case 0x20: res = "she"; break;
1585 case 0x20 + (MD_OBJECTIVE): res = "her"; break;
1586 case 0x20 + (MD_POSSESSIVE): res = "her"; break;
1587 case 0x20 + (MD_POSSESSIVE | MD_OBJECTIVE): res = "herself"; break;
1588 case 0x20 + (MD_INDEF_HIDDEN): res = "someone"; break;
1589 case 0x20 + (MD_INDEF_HIDDEN | MD_OBJECTIVE): res = "someone"; break;
1590 case 0x20 + (MD_INDEF_HIDDEN | MD_POSSESSIVE): res = "someone's"; break;
1591 case 0x20 + (MD_INDEF_HIDDEN | MD_POSSESSIVE | MD_OBJECTIVE): res = "herself"; break;
1595 /* Copy the result */
1596 (void)strcpy(desc, res);
1600 /* Handle visible monsters, "reflexive" request */
1601 else if ((mode & (MD_POSSESSIVE | MD_OBJECTIVE)) == (MD_POSSESSIVE | MD_OBJECTIVE))
1603 /* The monster is visible, so use its gender */
1605 if (r_ptr->flags1 & (RF1_FEMALE)) strcpy(desc, "彼女自身");
1606 else if (r_ptr->flags1 & (RF1_MALE)) strcpy(desc, "彼自身");
1607 else strcpy(desc, "それ自身");
1609 if (r_ptr->flags1 & RF1_FEMALE) strcpy(desc, "herself");
1610 else if (r_ptr->flags1 & RF1_MALE) strcpy(desc, "himself");
1611 else strcpy(desc, "itself");
1616 /* Handle all other visible monster requests */
1620 if (is_pet(m_ptr) && !is_original_ap(m_ptr))
1626 while(strncmp(t, "』", 2) && *t) t++;
1630 (void)sprintf(desc, "%s?』", buf);
1633 (void)sprintf(desc, "%s?", name);
1635 (void)sprintf(desc, "%s?", name);
1640 /* It could be a Unique */
1641 if ((r_ptr->flags1 & RF1_UNIQUE) && !(p_ptr->image && !(mode & MD_IGNORE_HALLU)))
1643 /* Start with the name (thus nominative and objective) */
1644 if ((m_ptr->mflag2 & MFLAG2_CHAMELEON) && !(mode & MD_TRUE_NAME))
1650 while (strncmp(t, "』", 2) && *t) t++;
1654 (void)sprintf(desc, "%s?』", buf);
1657 (void)sprintf(desc, "%s?", name);
1659 (void)sprintf(desc, "%s?", name);
1663 /* Inside monster arena, and it is not your mount */
1664 else if (p_ptr->inside_battle &&
1665 !(p_ptr->riding && (&m_list[p_ptr->riding] == m_ptr)))
1667 /* It is a fake unique monster */
1668 (void)sprintf(desc, _("%sもどき", "fake %s"), name);
1673 (void)strcpy(desc, name);
1677 /* It could be an indefinite monster */
1678 else if (mode & MD_INDEF_VISIBLE)
1680 /* XXX Check plurality for "some" */
1682 /* Indefinite monsters need an indefinite article */
1684 (void)strcpy(desc, "");
1686 (void)strcpy(desc, is_a_vowel(name[0]) ? "an " : "a ");
1689 (void)strcat(desc, name);
1692 /* It could be a normal, definite, monster */
1695 /* Definite monsters need a definite article */
1697 (void)strcpy(desc, _("あなたの", "your "));
1699 (void)strcpy(desc, _("", "the "));
1701 (void)strcat(desc, name);
1704 if (m_ptr->nickname)
1706 sprintf(buf,_("「%s」", " called %s"),quark_str(m_ptr->nickname));
1710 if (p_ptr->riding && (&m_list[p_ptr->riding] == m_ptr))
1712 strcat(desc,_("(乗馬中)", "(riding)"));
1715 if ((mode & MD_IGNORE_HALLU) && (m_ptr->mflag2 & MFLAG2_CHAMELEON))
1717 if (r_ptr->flags1 & RF1_UNIQUE)
1719 strcat(desc,_("(カメレオンの王)", "(Chameleon Lord)"));
1723 strcat(desc,_("(カメレオン)", "(Chameleon)"));
1727 if ((mode & MD_IGNORE_HALLU) && !is_original_ap(m_ptr))
1729 strcat(desc, format("(%s)", r_name + r_info[m_ptr->r_idx].name));
1732 /* Handle the Possessive as a special afterthought */
1733 if (mode & MD_POSSESSIVE)
1735 /* XXX Check for trailing "s" */
1737 /* Simply append "apostrophe" and "s" */
1738 (void)strcat(desc, _("の", "'s"));
1746 * @brief モンスターの調査による思い出補完処理 / Learn about a monster (by "probing" it)
1747 * @param r_idx 補完されるモンスター種族ID
1748 * @return 明らかになった情報の度数
1750 * Return the number of new flags learnt. -Mogami-
1752 int lore_do_probe(MONRACE_IDX r_idx)
1754 monster_race *r_ptr = &r_info[r_idx];
1758 /* Maximal info about awareness */
1759 if (r_ptr->r_wake != MAX_UCHAR) n++;
1760 if (r_ptr->r_ignore != MAX_UCHAR) n++;
1761 r_ptr->r_wake = r_ptr->r_ignore = MAX_UCHAR;
1763 /* Observe "maximal" attacks */
1764 for (i = 0; i < 4; i++)
1766 /* Examine "actual" blows */
1767 if (r_ptr->blow[i].effect || r_ptr->blow[i].method)
1769 /* Maximal observations */
1770 if (r_ptr->r_blows[i] != MAX_UCHAR) n++;
1771 r_ptr->r_blows[i] = MAX_UCHAR;
1777 (((r_ptr->flags1 & RF1_DROP_4D2) ? 8 : 0) +
1778 ((r_ptr->flags1 & RF1_DROP_3D2) ? 6 : 0) +
1779 ((r_ptr->flags1 & RF1_DROP_2D2) ? 4 : 0) +
1780 ((r_ptr->flags1 & RF1_DROP_1D2) ? 2 : 0) +
1781 ((r_ptr->flags1 & RF1_DROP_90) ? 1 : 0) +
1782 ((r_ptr->flags1 & RF1_DROP_60) ? 1 : 0));
1784 /* Only "valid" drops */
1785 if (!(r_ptr->flags1 & RF1_ONLY_GOLD))
1787 if (r_ptr->r_drop_item != tmp_byte) n++;
1788 r_ptr->r_drop_item = tmp_byte;
1790 if (!(r_ptr->flags1 & RF1_ONLY_ITEM))
1792 if (r_ptr->r_drop_gold != tmp_byte) n++;
1793 r_ptr->r_drop_gold = tmp_byte;
1796 /* Observe many spells */
1797 if (r_ptr->r_cast_spell != MAX_UCHAR) n++;
1798 r_ptr->r_cast_spell = MAX_UCHAR;
1800 /* Count unknown flags */
1801 for (i = 0; i < 32; i++)
1803 if (!(r_ptr->r_flags1 & (1L << i)) &&
1804 (r_ptr->flags1 & (1L << i))) n++;
1805 if (!(r_ptr->r_flags2 & (1L << i)) &&
1806 (r_ptr->flags2 & (1L << i))) n++;
1807 if (!(r_ptr->r_flags3 & (1L << i)) &&
1808 (r_ptr->flags3 & (1L << i))) n++;
1809 if (!(r_ptr->r_flags4 & (1L << i)) &&
1810 (r_ptr->flags4 & (1L << i))) n++;
1811 if (!(r_ptr->r_flags5 & (1L << i)) &&
1812 (r_ptr->a_ability_flags1 & (1L << i))) n++;
1813 if (!(r_ptr->r_flags6 & (1L << i)) &&
1814 (r_ptr->a_ability_flags2 & (1L << i))) n++;
1815 if (!(r_ptr->r_flagsr & (1L << i)) &&
1816 (r_ptr->flagsr & (1L << i))) n++;
1818 /* r_flags7 is actually unused */
1820 if (!(r_ptr->r_flags7 & (1L << i)) &&
1821 (r_ptr->flags7 & (1L << i))) n++;
1825 /* Know all the flags */
1826 r_ptr->r_flags1 = r_ptr->flags1;
1827 r_ptr->r_flags2 = r_ptr->flags2;
1828 r_ptr->r_flags3 = r_ptr->flags3;
1829 r_ptr->r_flags4 = r_ptr->flags4;
1830 r_ptr->r_flags5 = r_ptr->a_ability_flags1;
1831 r_ptr->r_flags6 = r_ptr->a_ability_flags2;
1832 r_ptr->r_flagsr = r_ptr->flagsr;
1834 /* r_flags7 is actually unused */
1835 /* r_ptr->r_flags7 = r_ptr->flags7; */
1837 /* Know about evolution */
1838 if (!(r_ptr->r_xtra1 & MR1_SINKA)) n++;
1839 r_ptr->r_xtra1 |= MR1_SINKA;
1841 /* Update monster recall window */
1842 if (p_ptr->monster_race_idx == r_idx)
1844 p_ptr->window |= (PW_MONSTER);
1847 /* Return the number of new flags learnt */
1853 * @brief モンスターの撃破に伴うドロップ情報の保管処理 / Take note that the given monster just dropped some treasure
1854 * @param m_idx モンスター情報のID
1855 * @param num_item 手に入れたアイテム数
1856 * @param num_gold 手に入れた財宝の単位数
1859 * Note that learning the "GOOD"/"GREAT" flags gives information
1860 * about the treasure (even when the monster is killed for the first
1861 * time, such as uniques, and the treasure has not been examined yet).
1863 * This "indirect" method is used to prevent the player from learning
1864 * exactly how much treasure a monster can drop from observing only
1865 * a single example of a drop. This method actually observes how much
1866 * gold and items are dropped, and remembers that information to be
1867 * described later by the monster recall code.
1869 void lore_treasure(MONSTER_IDX m_idx, ITEM_NUMBER num_item, ITEM_NUMBER num_gold)
1871 monster_type *m_ptr = &m_list[m_idx];
1873 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1875 /* If the monster doesn't have original appearance, don't note */
1876 if (!is_original_ap(m_ptr)) return;
1878 /* Note the number of things dropped */
1879 if (num_item > r_ptr->r_drop_item) r_ptr->r_drop_item = num_item;
1880 if (num_gold > r_ptr->r_drop_gold) r_ptr->r_drop_gold = num_gold;
1882 /* Hack -- memorize the good/great flags */
1883 if (r_ptr->flags1 & (RF1_DROP_GOOD)) r_ptr->r_flags1 |= (RF1_DROP_GOOD);
1884 if (r_ptr->flags1 & (RF1_DROP_GREAT)) r_ptr->r_flags1 |= (RF1_DROP_GREAT);
1886 /* Update monster recall window */
1887 if (p_ptr->monster_race_idx == m_ptr->r_idx)
1889 p_ptr->window |= (PW_MONSTER);
1895 * @brief ELDRITCH_HORRORによるプレイヤーの精神破壊処理
1896 * @param m_ptr ELDRITCH_HORRORを引き起こしたモンスターの参照ポインタ
1897 * @param necro 暗黒領域魔法の詠唱失敗によるものならばTRUEを返す
1900 void sanity_blast(monster_type *m_ptr, bool necro)
1904 if (p_ptr->inside_battle || !character_dungeon) return;
1906 if (!necro && m_ptr)
1908 GAME_TEXT m_name[MAX_NLEN];
1909 monster_race *r_ptr = &r_info[m_ptr->ap_r_idx];
1911 power = r_ptr->level / 2;
1913 monster_desc(m_name, m_ptr, 0);
1915 if (!(r_ptr->flags1 & RF1_UNIQUE))
1917 if (r_ptr->flags1 & RF1_FRIENDS)
1922 if (!is_loading_now)
1923 return; /* No effect yet, just loaded... */
1926 return; /* Cannot see it for some reason */
1928 if (!(r_ptr->flags2 & RF2_ELDRITCH_HORROR))
1932 return; /* Pet eldritch horrors are safe most of the time */
1934 if (randint1(100) > power) return;
1936 if (saving_throw(p_ptr->skill_sav - power))
1938 return; /* Save, no adverse effects */
1943 /* Something silly happens... */
1944 msg_format(_("%s%sの顔を見てしまった!", "You behold the %s visage of %s!"),
1945 funny_desc[randint0(MAX_SAN_FUNNY)], m_name);
1949 msg_print(funny_comments[randint0(MAX_SAN_COMMENT)]);
1950 p_ptr->image = p_ptr->image + randint1(r_ptr->level);
1953 return; /* Never mind; we can't see it clearly enough */
1956 /* Something frightening happens... */
1957 msg_format(_("%s%sの顔を見てしまった!", "You behold the %s visage of %s!"),
1958 horror_desc[randint0(MAX_SAN_HORROR)], m_name);
1960 r_ptr->r_flags2 |= RF2_ELDRITCH_HORROR;
1962 /* Demon characters are unaffected */
1963 if (prace_is_(RACE_IMP) || prace_is_(RACE_DEMON) || (mimic_info[p_ptr->mimic_form].MIMIC_FLAGS & MIMIC_IS_DEMON)) return;
1964 if (p_ptr->wizard) return;
1966 /* Undead characters are 50% likely to be unaffected */
1967 if (prace_is_(RACE_SKELETON) || prace_is_(RACE_ZOMBIE)
1968 || prace_is_(RACE_VAMPIRE) || prace_is_(RACE_SPECTRE) ||
1969 (mimic_info[p_ptr->mimic_form].MIMIC_FLAGS & MIMIC_IS_UNDEAD))
1971 if (saving_throw(25 + p_ptr->lev)) return;
1976 monster_race *r_ptr;
1977 GAME_TEXT m_name[MAX_NLEN];
1980 get_mon_num_prep(get_nightmare, NULL);
1982 r_ptr = &r_info[get_mon_num(MAX_DEPTH)];
1983 power = r_ptr->level + 10;
1984 desc = r_name + r_ptr->name;
1986 get_mon_num_prep(NULL, NULL);
1989 if (!(r_ptr->flags1 & RF1_UNIQUE))
1990 sprintf(m_name, "%s %s", (is_a_vowel(desc[0]) ? "an" : "a"), desc);
1993 sprintf(m_name, "%s", desc);
1995 if (!(r_ptr->flags1 & RF1_UNIQUE))
1997 if (r_ptr->flags1 & RF1_FRIENDS) power /= 2;
2001 if (saving_throw(p_ptr->skill_sav * 100 / power))
2003 msg_format(_("夢の中で%sに追いかけられた。", "%^s chases you through your dreams."), m_name);
2010 /* Something silly happens... */
2011 msg_format(_("%s%sの顔を見てしまった!", "You behold the %s visage of %s!"),
2012 funny_desc[randint0(MAX_SAN_FUNNY)], m_name);
2016 msg_print(funny_comments[randint0(MAX_SAN_COMMENT)]);
2017 p_ptr->image = p_ptr->image + randint1(r_ptr->level);
2020 /* Never mind; we can't see it clearly enough */
2024 /* Something frightening happens... */
2025 msg_format(_("%s%sの顔を見てしまった!", "You behold the %s visage of %s!"),
2026 horror_desc[randint0(MAX_SAN_HORROR)], desc);
2028 r_ptr->r_flags2 |= RF2_ELDRITCH_HORROR;
2030 if (!p_ptr->mimic_form)
2032 switch (p_ptr->prace)
2034 /* Demons may make a saving throw */
2037 if (saving_throw(20 + p_ptr->lev)) return;
2039 /* Undead may make a saving throw */
2044 if (saving_throw(10 + p_ptr->lev)) return;
2050 /* Demons may make a saving throw */
2051 if (mimic_info[p_ptr->mimic_form].MIMIC_FLAGS & MIMIC_IS_DEMON)
2053 if (saving_throw(20 + p_ptr->lev)) return;
2055 /* Undead may make a saving throw */
2056 else if (mimic_info[p_ptr->mimic_form].MIMIC_FLAGS & MIMIC_IS_UNDEAD)
2058 if (saving_throw(10 + p_ptr->lev)) return;
2064 msg_print(_("ネクロノミコンを読んで正気を失った!", "Your sanity is shaken by reading the Necronomicon!"));
2067 if (saving_throw(p_ptr->skill_sav - power))
2073 (void)do_dec_stat(A_INT);
2074 } while (randint0(100) > p_ptr->skill_sav && one_in_(2));
2077 (void)do_dec_stat(A_WIS);
2078 } while (randint0(100) > p_ptr->skill_sav && one_in_(2));
2080 switch (randint1(21))
2083 if (!(p_ptr->muta3 & MUT3_MORONIC) && one_in_(5))
2085 if ((p_ptr->stat_use[A_INT] < 4) && (p_ptr->stat_use[A_WIS] < 4))
2087 msg_print(_("あなたは完璧な馬鹿になったような気がした。しかしそれは元々だった。", "You turn into an utter moron!"));
2091 msg_print(_("あなたは完璧な馬鹿になった!", "You turn into an utter moron!"));
2094 if (p_ptr->muta3 & MUT3_HYPER_INT)
2096 msg_print(_("あなたの脳は生体コンピュータではなくなった。", "Your brain is no longer a living computer."));
2097 p_ptr->muta3 &= ~(MUT3_HYPER_INT);
2099 p_ptr->muta3 |= MUT3_MORONIC;
2105 if (!(p_ptr->muta2 & MUT2_COWARDICE) && !p_ptr->resist_fear)
2107 msg_print(_("あなたはパラノイアになった!", "You become paranoid!"));
2109 /* Duh, the following should never happen, but anyway... */
2110 if (p_ptr->muta3 & MUT3_FEARLESS)
2112 msg_print(_("あなたはもう恐れ知らずではなくなった。", "You are no longer fearless."));
2113 p_ptr->muta3 &= ~(MUT3_FEARLESS);
2116 p_ptr->muta2 |= MUT2_COWARDICE;
2122 if (!(p_ptr->muta2 & MUT2_HALLU) && !p_ptr->resist_chaos)
2124 msg_print(_("幻覚をひき起こす精神錯乱に陥った!", "You are afflicted by a hallucinatory insanity!"));
2125 p_ptr->muta2 |= MUT2_HALLU;
2131 if (!(p_ptr->muta2 & MUT2_BERS_RAGE))
2133 msg_print(_("激烈な感情の発作におそわれるようになった!", "You become subject to fits of berserk rage!"));
2134 p_ptr->muta2 |= MUT2_BERS_RAGE;
2144 if (!p_ptr->resist_conf)
2146 (void)set_confused(p_ptr->confused + randint0(4) + 4);
2148 if (!p_ptr->free_act)
2150 (void)set_paralyzed(p_ptr->paralyzed + randint0(4) + 4);
2152 if (!p_ptr->resist_chaos)
2154 (void)set_image(p_ptr->image + randint0(250) + 150);
2163 if (lose_all_info())
2164 msg_print(_("あまりの恐怖に全てのことを忘れてしまった!", "You forget everything in your utmost terror!"));
2168 p_ptr->update |= PU_BONUS;
2173 * @brief モンスターの各情報を更新する / This function updates the monster record of the given monster
2174 * @param m_idx 更新するモンスター情報のID
2175 * @param full プレイヤーとの距離更新を行うならばtrue
2178 * This involves extracting the distance to the player (if requested),
2179 * and then checking for visibility (natural, infravision, see-invis,
2180 * telepathy), updating the monster visibility flag, redrawing (or
2181 * erasing) the monster when its visibility changes, and taking note
2182 * of any interesting monster flags (cold-blooded, invisible, etc).
2184 * Note the new "mflag" field which encodes several monster state flags,
2185 * including "view" for when the monster is currently in line of sight,
2186 * and "mark" for when the monster is currently visible via detection.
2188 * The only monster fields that are changed here are "cdis" (the
2189 * distance from the player), "ml" (visible to the player), and
2190 * "mflag" (to maintain the "MFLAG_VIEW" flag).
2192 * Note the special "update_monsters()" function which can be used to
2193 * call this function once for every monster.
2195 * Note the "full" flag which requests that the "cdis" field be updated,
2196 * this is only needed when the monster (or the player) has moved.
2198 * Every time a monster moves, we must call this function for that
2199 * monster, and update the distance, and the visibility. Every time
2200 * the player moves, we must call this function for every monster, and
2201 * update the distance, and the visibility. Whenever the player "state"
2202 * changes in certain ways ("blindness", "infravision", "telepathy",
2203 * and "see invisible"), we must call this function for every monster,
2204 * and update the visibility.
2206 * Routines that change the "illumination" of a grid must also call this
2207 * function for any monster in that grid, since the "visibility" of some
2208 * monsters may be based on the illumination of their grid.
2210 * Note that this function is called once per monster every time the
2211 * player moves. When the player is running, this function is one
2212 * of the primary bottlenecks, along with "update_view()" and the
2213 * "process_monsters()" code, so efficiency is important.
2215 * Note the optimized "inline" version of the "distance()" function.
2217 * A monster is "visible" to the player if (1) it has been detected
2218 * by the player, (2) it is close to the player and the player has
2219 * telepathy, or (3) it is close to the player, and in line of sight
2220 * of the player, and it is "illuminated" by some combination of
2221 * infravision, torch light, or permanent light (invisible monsters
2222 * are only affected by "light" if the player can see invisible).
2224 * Monsters which are not on the current panel may be "visible" to
2225 * the player, and their descriptions will include an "offscreen"
2226 * reference. Currently, offscreen monsters cannot be targetted
2227 * or viewed directly, but old targets will remain set. XXX XXX
2229 * The player can choose to be disturbed by several things, including
2230 * "disturb_move" (monster which is viewable moves in some way), and
2231 * "disturb_near" (monster which is "easily" viewable moves in some
2232 * way). Note that "moves" includes "appears" and "disappears".
2234 void update_monster(MONSTER_IDX m_idx, bool full)
2236 monster_type *m_ptr = &m_list[m_idx];
2238 monster_race *r_ptr = &r_info[m_ptr->r_idx];
2240 bool do_disturb = disturb_move;
2244 /* Current location */
2251 /* Seen by vision */
2254 /* Non-Ninja player in the darkness */
2255 bool in_darkness = (d_info[p_ptr->dungeon_idx].flags1 & DF1_DARKNESS) && !p_ptr->see_nocto;
2260 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
2262 if (ap_r_ptr->r_tkills && ap_r_ptr->level >= p_ptr->lev)
2266 /* Compute distance */
2269 /* Distance components */
2270 int dy = (p_ptr->y > fy) ? (p_ptr->y - fy) : (fy - p_ptr->y);
2271 int dx = (p_ptr->x > fx) ? (p_ptr->x - fx) : (fx - p_ptr->x);
2273 /* Approximate distance */
2274 d = (dy > dx) ? (dy + (dx>>1)) : (dx + (dy>>1));
2276 /* Restrict distance */
2277 if (d > 255) d = 255;
2281 /* Save the distance */
2285 /* Extract distance */
2288 /* Extract the distance */
2294 if (m_ptr->mflag2 & (MFLAG2_MARK)) flag = TRUE;
2298 if (d <= (in_darkness ? MAX_SIGHT / 2 : MAX_SIGHT))
2300 if (!in_darkness || (d <= MAX_SIGHT / 4))
2302 if (p_ptr->special_defense & KATA_MUSOU)
2307 if (is_original_ap(m_ptr) && !p_ptr->image)
2309 /* Hack -- Memorize mental flags */
2310 if (r_ptr->flags2 & (RF2_SMART)) r_ptr->r_flags2 |= (RF2_SMART);
2311 if (r_ptr->flags2 & (RF2_STUPID)) r_ptr->r_flags2 |= (RF2_STUPID);
2315 /* Basic telepathy */
2316 /* Snipers get telepathy when they concentrate deeper */
2317 else if (p_ptr->telepathy)
2319 /* Empty mind, no telepathy */
2320 if (r_ptr->flags2 & (RF2_EMPTY_MIND))
2322 /* Memorize flags */
2323 if (is_original_ap(m_ptr) && !p_ptr->image) r_ptr->r_flags2 |= (RF2_EMPTY_MIND);
2326 /* Weird mind, occasional telepathy */
2327 else if (r_ptr->flags2 & (RF2_WEIRD_MIND))
2329 /* One in ten individuals are detectable */
2330 if ((m_idx % 10) == 5)
2335 if (is_original_ap(m_ptr) && !p_ptr->image)
2337 /* Memorize flags */
2338 r_ptr->r_flags2 |= (RF2_WEIRD_MIND);
2340 /* Hack -- Memorize mental flags */
2341 if (r_ptr->flags2 & (RF2_SMART)) r_ptr->r_flags2 |= (RF2_SMART);
2342 if (r_ptr->flags2 & (RF2_STUPID)) r_ptr->r_flags2 |= (RF2_STUPID);
2347 /* Normal mind, allow telepathy */
2353 if (is_original_ap(m_ptr) && !p_ptr->image)
2355 /* Hack -- Memorize mental flags */
2356 if (r_ptr->flags2 & (RF2_SMART)) r_ptr->r_flags2 |= (RF2_SMART);
2357 if (r_ptr->flags2 & (RF2_STUPID)) r_ptr->r_flags2 |= (RF2_STUPID);
2362 /* Magical sensing */
2363 if ((p_ptr->esp_animal) && (r_ptr->flags3 & (RF3_ANIMAL)))
2366 if (is_original_ap(m_ptr) && !p_ptr->image) r_ptr->r_flags3 |= (RF3_ANIMAL);
2369 /* Magical sensing */
2370 if ((p_ptr->esp_undead) && (r_ptr->flags3 & (RF3_UNDEAD)))
2373 if (is_original_ap(m_ptr) && !p_ptr->image) r_ptr->r_flags3 |= (RF3_UNDEAD);
2376 /* Magical sensing */
2377 if ((p_ptr->esp_demon) && (r_ptr->flags3 & (RF3_DEMON)))
2380 if (is_original_ap(m_ptr) && !p_ptr->image) r_ptr->r_flags3 |= (RF3_DEMON);
2383 /* Magical sensing */
2384 if ((p_ptr->esp_orc) && (r_ptr->flags3 & (RF3_ORC)))
2387 if (is_original_ap(m_ptr) && !p_ptr->image) r_ptr->r_flags3 |= (RF3_ORC);
2390 /* Magical sensing */
2391 if ((p_ptr->esp_troll) && (r_ptr->flags3 & (RF3_TROLL)))
2394 if (is_original_ap(m_ptr) && !p_ptr->image) r_ptr->r_flags3 |= (RF3_TROLL);
2397 /* Magical sensing */
2398 if ((p_ptr->esp_giant) && (r_ptr->flags3 & (RF3_GIANT)))
2401 if (is_original_ap(m_ptr) && !p_ptr->image) r_ptr->r_flags3 |= (RF3_GIANT);
2404 /* Magical sensing */
2405 if ((p_ptr->esp_dragon) && (r_ptr->flags3 & (RF3_DRAGON)))
2408 if (is_original_ap(m_ptr) && !p_ptr->image) r_ptr->r_flags3 |= (RF3_DRAGON);
2411 /* Magical sensing */
2412 if ((p_ptr->esp_human) && (r_ptr->flags2 & (RF2_HUMAN)))
2415 if (is_original_ap(m_ptr) && !p_ptr->image) r_ptr->r_flags2 |= (RF2_HUMAN);
2418 /* Magical sensing */
2419 if ((p_ptr->esp_evil) && (r_ptr->flags3 & (RF3_EVIL)))
2422 if (is_original_ap(m_ptr) && !p_ptr->image) r_ptr->r_flags3 |= (RF3_EVIL);
2425 /* Magical sensing */
2426 if ((p_ptr->esp_good) && (r_ptr->flags3 & (RF3_GOOD)))
2429 if (is_original_ap(m_ptr) && !p_ptr->image) r_ptr->r_flags3 |= (RF3_GOOD);
2432 /* Magical sensing */
2433 if ((p_ptr->esp_nonliving) &&
2434 ((r_ptr->flags3 & (RF3_DEMON | RF3_UNDEAD | RF3_NONLIVING)) == RF3_NONLIVING))
2437 if (is_original_ap(m_ptr) && !p_ptr->image) r_ptr->r_flags3 |= (RF3_NONLIVING);
2440 /* Magical sensing */
2441 if ((p_ptr->esp_unique) && (r_ptr->flags1 & (RF1_UNIQUE)))
2444 if (is_original_ap(m_ptr) && !p_ptr->image) r_ptr->r_flags1 |= (RF1_UNIQUE);
2448 /* Normal line of sight, and not blind */
2449 if (player_has_los_bold(fy, fx) && !p_ptr->blind)
2451 bool do_invisible = FALSE;
2452 bool do_cold_blood = FALSE;
2454 /* Snipers can see targets in darkness when they concentrate deeper */
2455 if (p_ptr->concent >= CONCENT_RADAR_THRESHOLD)
2461 /* Use "infravision" */
2462 if (d <= p_ptr->see_infra)
2464 /* Handle "cold blooded" monsters */
2465 if ((r_ptr->flags2 & (RF2_COLD_BLOOD | RF2_AURA_FIRE)) == RF2_COLD_BLOOD)
2467 do_cold_blood = TRUE;
2470 /* Handle "warm blooded" monsters */
2478 /* Use "illumination" */
2479 if (player_can_see_bold(fy, fx))
2481 /* Handle "invisible" monsters */
2482 if (r_ptr->flags2 & (RF2_INVISIBLE))
2484 do_invisible = TRUE;
2494 /* Handle "normal" monsters */
2505 if (is_original_ap(m_ptr) && !p_ptr->image)
2507 /* Memorize flags */
2508 if (do_invisible) r_ptr->r_flags2 |= (RF2_INVISIBLE);
2509 if (do_cold_blood) r_ptr->r_flags2 |= (RF2_COLD_BLOOD);
2516 /* The monster is now visible */
2519 /* It was previously unseen */
2522 /* Mark as visible */
2525 /* Draw the monster */
2528 /* Update health bar as needed */
2529 if (p_ptr->health_who == m_idx) p_ptr->redraw |= (PR_HEALTH);
2530 if (p_ptr->riding == m_idx) p_ptr->redraw |= (PR_UHEALTH);
2532 /* Hack -- Count "fresh" sightings */
2535 if ((m_ptr->ap_r_idx == MON_KAGE) && (r_info[MON_KAGE].r_sights < MAX_SHORT))
2536 r_info[MON_KAGE].r_sights++;
2537 else if (is_original_ap(m_ptr) && (r_ptr->r_sights < MAX_SHORT))
2541 /* Eldritch Horror */
2542 if (r_info[m_ptr->ap_r_idx].flags2 & RF2_ELDRITCH_HORROR)
2544 sanity_blast(m_ptr, FALSE);
2547 /* Disturb on appearance */
2548 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)))
2550 if (disturb_pets || is_hostile(m_ptr))
2551 disturb(TRUE, TRUE);
2556 /* The monster is not visible */
2559 /* It was previously seen */
2562 /* Mark as not visible */
2565 /* Erase the monster */
2568 /* Update health bar as needed */
2569 if (p_ptr->health_who == m_idx) p_ptr->redraw |= (PR_HEALTH);
2570 if (p_ptr->riding == m_idx) p_ptr->redraw |= (PR_UHEALTH);
2572 /* Disturb on disappearance */
2575 if (disturb_pets || is_hostile(m_ptr))
2576 disturb(TRUE, TRUE);
2582 /* The monster is now easily visible */
2586 if (!(m_ptr->mflag & (MFLAG_VIEW)))
2588 /* Mark as easily visible */
2589 m_ptr->mflag |= (MFLAG_VIEW);
2591 /* Disturb on appearance */
2594 if (disturb_pets || is_hostile(m_ptr))
2595 disturb(TRUE, TRUE);
2600 /* The monster is not easily visible */
2604 if (m_ptr->mflag & (MFLAG_VIEW))
2606 /* Mark as not easily visible */
2607 m_ptr->mflag &= ~(MFLAG_VIEW);
2609 /* Disturb on disappearance */
2612 if (disturb_pets || is_hostile(m_ptr))
2613 disturb(TRUE, TRUE);
2621 * @brief 単純に生存している全モンスターの更新処理を行う / This function simply updates all the (non-dead) monsters (see above).
2622 * @param full 距離更新を行うならtrue
2625 void update_monsters(bool full)
2629 /* Update each (live) monster */
2630 for (i = 1; i < m_max; i++)
2632 monster_type *m_ptr = &m_list[i];
2634 /* Skip dead monsters */
2635 if (!m_ptr->r_idx) continue;
2636 update_monster(i, full);
2642 * @brief カメレオンの王の変身対象となるモンスターかどうか判定する / Hack -- the index of the summoning monster
2643 * @param r_idx モンスター種族ID
2644 * @return 対象にできるならtrueを返す
2646 static bool monster_hook_chameleon_lord(MONRACE_IDX r_idx)
2648 monster_race *r_ptr = &r_info[r_idx];
2649 monster_type *m_ptr = &m_list[chameleon_change_m_idx];
2650 monster_race *old_r_ptr = &r_info[m_ptr->r_idx];
2652 if (!(r_ptr->flags1 & (RF1_UNIQUE))) return FALSE;
2653 if (r_ptr->flags7 & (RF7_FRIENDLY | RF7_CHAMELEON)) return FALSE;
2655 if (ABS(r_ptr->level - r_info[MON_CHAMELEON_K].level) > 5) return FALSE;
2657 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))
2660 if (!monster_can_cross_terrain(grid_array[m_ptr->fy][m_ptr->fx].feat, r_ptr, 0)) return FALSE;
2663 if (!(old_r_ptr->flags7 & RF7_CHAMELEON))
2665 if (monster_has_hostile_align(m_ptr, 0, 0, r_ptr)) return FALSE;
2669 else if (summon_specific_who > 0)
2671 if (monster_has_hostile_align(&m_list[summon_specific_who], 0, 0, r_ptr)) return FALSE;
2678 * @brief カメレオンの変身対象となるモンスターかどうか判定する / Hack -- the index of the summoning monster
2679 * @param r_idx モンスター種族ID
2680 * @return 対象にできるならtrueを返す
2682 static bool monster_hook_chameleon(MONRACE_IDX r_idx)
2684 monster_race *r_ptr = &r_info[r_idx];
2685 monster_type *m_ptr = &m_list[chameleon_change_m_idx];
2686 monster_race *old_r_ptr = &r_info[m_ptr->r_idx];
2688 if (r_ptr->flags1 & (RF1_UNIQUE)) return FALSE;
2689 if (r_ptr->flags2 & RF2_MULTIPLY) return FALSE;
2690 if (r_ptr->flags7 & (RF7_FRIENDLY | RF7_CHAMELEON)) return FALSE;
2692 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))
2695 if (!monster_can_cross_terrain(grid_array[m_ptr->fy][m_ptr->fx].feat, r_ptr, 0)) return FALSE;
2698 if (!(old_r_ptr->flags7 & RF7_CHAMELEON))
2700 if ((old_r_ptr->flags3 & RF3_GOOD) && !(r_ptr->flags3 & RF3_GOOD)) return FALSE;
2701 if ((old_r_ptr->flags3 & RF3_EVIL) && !(r_ptr->flags3 & RF3_EVIL)) return FALSE;
2702 if (!(old_r_ptr->flags3 & (RF3_GOOD | RF3_EVIL)) && (r_ptr->flags3 & (RF3_GOOD | RF3_EVIL))) return FALSE;
2706 else if (summon_specific_who > 0)
2708 if (monster_has_hostile_align(&m_list[summon_specific_who], 0, 0, r_ptr)) return FALSE;
2711 return (*(get_monster_hook()))(r_idx);
2716 * @param m_idx 変身処理を受けるモンスター情報のID
2717 * @param born 生成時の初変身先指定ならばtrue
2718 * @param r_idx 旧モンスター種族のID
2721 void choose_new_monster(MONSTER_IDX m_idx, bool born, MONRACE_IDX r_idx)
2724 monster_type *m_ptr = &m_list[m_idx];
2725 monster_race *r_ptr;
2726 char old_m_name[MAX_NLEN];
2727 bool old_unique = FALSE;
2728 int old_r_idx = m_ptr->r_idx;
2730 if (r_info[m_ptr->r_idx].flags1 & RF1_UNIQUE)
2732 if (old_unique && (r_idx == MON_CHAMELEON)) r_idx = MON_CHAMELEON_K;
2733 r_ptr = &r_info[r_idx];
2735 monster_desc(old_m_name, m_ptr, 0);
2741 chameleon_change_m_idx = m_idx;
2743 get_mon_num_prep(monster_hook_chameleon_lord, NULL);
2745 get_mon_num_prep(monster_hook_chameleon, NULL);
2748 level = r_info[MON_CHAMELEON_K].level;
2749 else if (!dun_level)
2750 level = wilderness[p_ptr->wilderness_y][p_ptr->wilderness_x].level;
2754 if (d_info[p_ptr->dungeon_idx].flags1 & DF1_CHAMELEON) level+= 2+randint1(3);
2756 r_idx = get_mon_num(level);
2757 r_ptr = &r_info[r_idx];
2759 chameleon_change_m_idx = 0;
2765 if (is_pet(m_ptr)) check_pets_num_and_align(m_ptr, FALSE);
2767 m_ptr->r_idx = r_idx;
2768 m_ptr->ap_r_idx = r_idx;
2769 update_monster(m_idx, FALSE);
2770 lite_spot(m_ptr->fy, m_ptr->fx);
2772 if ((r_info[old_r_idx].flags7 & (RF7_LITE_MASK | RF7_DARK_MASK)) ||
2773 (r_ptr->flags7 & (RF7_LITE_MASK | RF7_DARK_MASK)))
2774 p_ptr->update |= (PU_MON_LITE);
2776 if (is_pet(m_ptr)) check_pets_num_and_align(m_ptr, TRUE);
2780 /* Sub-alignment of a chameleon */
2781 if (r_ptr->flags3 & (RF3_EVIL | RF3_GOOD))
2783 m_ptr->sub_align = SUB_ALIGN_NEUTRAL;
2784 if (r_ptr->flags3 & RF3_EVIL) m_ptr->sub_align |= SUB_ALIGN_EVIL;
2785 if (r_ptr->flags3 & RF3_GOOD) m_ptr->sub_align |= SUB_ALIGN_GOOD;
2790 if (m_idx == p_ptr->riding)
2792 GAME_TEXT m_name[MAX_NLEN];
2793 monster_desc(m_name, m_ptr, 0);
2794 msg_format(_("突然%sが変身した。", "Suddenly, %s transforms!"), old_m_name);
2795 if (!(r_ptr->flags7 & RF7_RIDING))
2796 if (rakuba(0, TRUE)) msg_format(_("地面に落とされた。", "You have fallen from %s."), m_name);
2799 /* Extract the monster base speed */
2800 m_ptr->mspeed = get_mspeed(r_ptr);
2802 oldmaxhp = m_ptr->max_maxhp;
2803 /* Assign maximal hitpoints */
2804 if (r_ptr->flags1 & RF1_FORCE_MAXHP)
2806 m_ptr->max_maxhp = maxroll(r_ptr->hdice, r_ptr->hside);
2810 m_ptr->max_maxhp = damroll(r_ptr->hdice, r_ptr->hside);
2813 /* Monsters have double hitpoints in Nightmare mode */
2814 if (ironman_nightmare)
2816 u32b hp = m_ptr->max_maxhp * 2L;
2817 m_ptr->max_maxhp = (HIT_POINT)MIN(30000, hp);
2820 m_ptr->maxhp = (long)(m_ptr->maxhp * m_ptr->max_maxhp) / oldmaxhp;
2821 if (m_ptr->maxhp < 1) m_ptr->maxhp = 1;
2822 m_ptr->hp = (long)(m_ptr->hp * m_ptr->max_maxhp) / oldmaxhp;
2824 /* reset dealt_damage */
2825 m_ptr->dealt_damage = 0;
2830 * @brief たぬきの変身対象となるモンスターかどうか判定する / Hook for Tanuki
2831 * @param r_idx モンスター種族ID
2832 * @return 対象にできるならtrueを返す
2834 static bool monster_hook_tanuki(MONRACE_IDX r_idx)
2836 monster_race *r_ptr = &r_info[r_idx];
2838 if (r_ptr->flags1 & (RF1_UNIQUE)) return FALSE;
2839 if (r_ptr->flags2 & RF2_MULTIPLY) return FALSE;
2840 if (r_ptr->flags7 & (RF7_FRIENDLY | RF7_CHAMELEON)) return FALSE;
2841 if (r_ptr->flags7 & RF7_AQUATIC) return FALSE;
2843 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))
2846 return (*(get_monster_hook()))(r_idx);
2851 * @brief モンスターの表層IDを設定する / Set initial racial appearance of a monster
2852 * @param r_idx モンスター種族ID
2853 * @return モンスター種族の表層ID
2855 static IDX initial_r_appearance(MONRACE_IDX r_idx)
2857 int attempts = 1000;
2859 DEPTH min = MIN(base_level-5, 50);
2861 if (p_ptr->pseikaku == SEIKAKU_CHARGEMAN)
2863 if (base_level == 0 || one_in_(5)) return MON_ALIEN_JURAL;
2866 if (!(r_info[r_idx].flags7 & RF7_TANUKI))
2869 get_mon_num_prep(monster_hook_tanuki, NULL);
2873 ap_r_idx = get_mon_num(base_level + 10);
2874 if (r_info[ap_r_idx].level >= min) return ap_r_idx;
2882 * @brief モンスターの個体加速を設定する / Get initial monster speed
2883 * @param r_ptr モンスター種族の参照ポインタ
2886 byte get_mspeed(monster_race *r_ptr)
2888 /* Extract the monster base speed */
2889 int mspeed = r_ptr->speed;
2891 /* Hack -- small racial variety */
2892 if (!(r_ptr->flags1 & RF1_UNIQUE) && !p_ptr->inside_arena)
2894 /* Allow some small variation per monster */
2895 int i = SPEED_TO_ENERGY(r_ptr->speed) / (one_in_(4) ? 3 : 10);
2896 if (i) mspeed += rand_spread(0, i);
2899 if (mspeed > 199) mspeed = 199;
2901 return (byte)mspeed;
2906 * @brief モンスターを一体生成する / Attempt to place a monster of the given race at the given location.
2907 * @param who 召喚を行ったモンスターID
2910 * @param r_idx 生成モンスター種族
2911 * @param mode 生成オプション
2914 * To give the player a sporting chance, any monster that appears in
2915 * line-of-sight and is extremely dangerous can be marked as
2916 * "FORCE_SLEEP", which will cause them to be placed with low energy,
2917 * which often (but not always) lets the player move before they do.
2919 * This routine refuses to place out-of-depth "FORCE_DEPTH" monsters.
2921 * Use special "here" and "dead" flags for unique monsters,
2922 * remove old "cur_num" and "max_num" fields.
2924 * Actually, do something similar for artifacts, to simplify
2925 * the "preserve" mode, and to make the "what artifacts" flag more useful.
2927 * This is the only function which may place a monster in the dungeon,
2928 * except for the savefile loading code.
2930 static bool place_monster_one(MONSTER_IDX who, POSITION y, POSITION x, MONRACE_IDX r_idx, BIT_FLAGS mode)
2932 /* Access the location */
2933 grid_type *g_ptr = &grid_array[y][x];
2934 monster_type *m_ptr;
2935 monster_race *r_ptr = &r_info[r_idx];
2936 concptr name = (r_name + r_ptr->name);
2940 /* DO NOT PLACE A MONSTER IN THE SMALL SCALE WILDERNESS !!! */
2941 if (p_ptr->wild_mode) return FALSE;
2943 /* Verify location */
2944 if (!in_bounds(y, x)) return (FALSE);
2947 if (!r_idx) return (FALSE);
2950 if (!r_ptr->name) return (FALSE);
2952 if (!(mode & PM_IGNORE_TERRAIN))
2954 /* Not on the Pattern */
2955 if (pattern_tile(y, x)) return FALSE;
2957 /* Require empty space (if not ghostly) */
2958 if (!monster_can_enter(y, x, r_ptr, 0)) return FALSE;
2961 if (!p_ptr->inside_battle)
2963 /* Hack -- "unique" monsters must be "unique" */
2964 if (((r_ptr->flags1 & (RF1_UNIQUE)) ||
2965 (r_ptr->flags7 & (RF7_NAZGUL))) &&
2966 (r_ptr->cur_num >= r_ptr->max_num))
2972 if ((r_ptr->flags7 & (RF7_UNIQUE2)) &&
2973 (r_ptr->cur_num >= 1))
2978 if (r_idx == MON_BANORLUPART)
2980 if (r_info[MON_BANOR].cur_num > 0) return FALSE;
2981 if (r_info[MON_LUPART].cur_num > 0) return FALSE;
2984 /* Depth monsters may NOT be created out of depth, unless in Nightmare mode */
2985 if ((r_ptr->flags1 & (RF1_FORCE_DEPTH)) && (dun_level < r_ptr->level) &&
2986 (!ironman_nightmare || (r_ptr->flags1 & (RF1_QUESTOR))))
2993 if (quest_number(dun_level))
2995 int hoge = quest_number(dun_level);
2996 if ((quest[hoge].type == QUEST_TYPE_KILL_LEVEL) || (quest[hoge].type == QUEST_TYPE_RANDOM))
2998 if(r_idx == quest[hoge].r_idx)
3000 int number_mon, i2, j2;
3003 /* Count all quest monsters */
3004 for (i2 = 0; i2 < cur_wid; ++i2)
3005 for (j2 = 0; j2 < cur_hgt; j2++)
3006 if (grid_array[j2][i2].m_idx > 0)
3007 if (m_list[grid_array[j2][i2].m_idx].r_idx == quest[hoge].r_idx)
3009 if(number_mon + quest[hoge].cur_num >= quest[hoge].max_num)
3015 if (is_glyph_grid(g_ptr))
3017 if (randint1(BREAK_GLYPH) < (r_ptr->level+20))
3019 /* Describe observable breakage */
3020 if (g_ptr->info & CAVE_MARK)
3022 msg_print(_("守りのルーンが壊れた!", "The rune of protection is broken!"));
3025 /* Forget the rune */
3026 g_ptr->info &= ~(CAVE_MARK);
3028 /* Break the rune */
3029 g_ptr->info &= ~(CAVE_OBJECT);
3037 msg_format_wizard(CHEAT_MONSTER, _("%s(Lv%d)を生成しました。", "%s(Lv%d) was generated."), name, r_ptr->level);
3039 if ((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags7 & RF7_NAZGUL) || (r_ptr->level < 10)) mode &= ~PM_KAGE;
3041 /* Make a new monster */
3042 g_ptr->m_idx = m_pop();
3043 hack_m_idx_ii = g_ptr->m_idx;
3045 /* Mega-Hack -- catch "failure" */
3046 if (!g_ptr->m_idx) return (FALSE);
3049 /* Get a new monster record */
3050 m_ptr = &m_list[g_ptr->m_idx];
3053 m_ptr->r_idx = r_idx;
3054 m_ptr->ap_r_idx = initial_r_appearance(r_idx);
3060 /* Hack -- Appearance transfer */
3061 if ((mode & PM_MULTIPLY) && (who > 0) && !is_original_ap(&m_list[who]))
3063 m_ptr->ap_r_idx = m_list[who].ap_r_idx;
3065 /* Hack -- Shadower spawns Shadower */
3066 if (m_list[who].mflag2 & MFLAG2_KAGE) m_ptr->mflag2 |= MFLAG2_KAGE;
3069 /* Sub-alignment of a monster */
3070 if ((who > 0) && !(r_ptr->flags3 & (RF3_EVIL | RF3_GOOD)))
3071 m_ptr->sub_align = m_list[who].sub_align;
3074 m_ptr->sub_align = SUB_ALIGN_NEUTRAL;
3075 if (r_ptr->flags3 & RF3_EVIL) m_ptr->sub_align |= SUB_ALIGN_EVIL;
3076 if (r_ptr->flags3 & RF3_GOOD) m_ptr->sub_align |= SUB_ALIGN_GOOD;
3079 /* Place the monster at the location */
3084 /* No "timed status" yet */
3085 for (cmi = 0; cmi < MAX_MTIMED; cmi++) m_ptr->mtimed[cmi] = 0;
3087 /* Unknown distance */
3090 reset_target(m_ptr);
3092 m_ptr->nickname = 0;
3097 /* Your pet summons its pet. */
3098 if (who > 0 && is_pet(&m_list[who]))
3100 mode |= PM_FORCE_PET;
3101 m_ptr->parent_m_idx = who;
3105 m_ptr->parent_m_idx = 0;
3108 if (r_ptr->flags7 & RF7_CHAMELEON)
3110 choose_new_monster(g_ptr->m_idx, TRUE, 0);
3111 r_ptr = &r_info[m_ptr->r_idx];
3112 m_ptr->mflag2 |= MFLAG2_CHAMELEON;
3114 /* Hack - Set sub_align to neutral when the Chameleon Lord is generated as "GUARDIAN" */
3115 if ((r_ptr->flags1 & RF1_UNIQUE) && (who <= 0))
3116 m_ptr->sub_align = SUB_ALIGN_NEUTRAL;
3118 else if ((mode & PM_KAGE) && !(mode & PM_FORCE_PET))
3120 m_ptr->ap_r_idx = MON_KAGE;
3121 m_ptr->mflag2 |= MFLAG2_KAGE;
3124 if (mode & PM_NO_PET) m_ptr->mflag2 |= MFLAG2_NOPET;
3130 if (mode & PM_FORCE_PET)
3135 else if ((r_ptr->flags7 & RF7_FRIENDLY) ||
3136 (mode & PM_FORCE_FRIENDLY) || is_friendly_idx(who))
3138 if (!monster_has_hostile_align(NULL, 0, -1, r_ptr)) set_friendly(m_ptr);
3141 /* Assume no sleeping */
3142 m_ptr->mtimed[MTIMED_CSLEEP] = 0;
3144 /* Enforce sleeping if needed */
3145 if ((mode & PM_ALLOW_SLEEP) && r_ptr->sleep && !ironman_nightmare)
3147 int val = r_ptr->sleep;
3148 (void)set_monster_csleep(g_ptr->m_idx, (val * 2) + randint1(val * 10));
3151 /* Assign maximal hitpoints */
3152 if (r_ptr->flags1 & RF1_FORCE_MAXHP)
3154 m_ptr->max_maxhp = maxroll(r_ptr->hdice, r_ptr->hside);
3158 m_ptr->max_maxhp = damroll(r_ptr->hdice, r_ptr->hside);
3161 /* Monsters have double hitpoints in Nightmare mode */
3162 if (ironman_nightmare)
3164 u32b hp = m_ptr->max_maxhp * 2L;
3166 m_ptr->max_maxhp = (HIT_POINT)MIN(30000, hp);
3169 m_ptr->maxhp = m_ptr->max_maxhp;
3171 /* And start out fully healthy */
3172 if (m_ptr->r_idx == MON_WOUNDED_BEAR)
3173 m_ptr->hp = m_ptr->maxhp / 2;
3174 else m_ptr->hp = m_ptr->maxhp;
3177 /* dealt damage is 0 at initial*/
3178 m_ptr->dealt_damage = 0;
3181 /* Extract the monster base speed */
3182 m_ptr->mspeed = get_mspeed(r_ptr);
3184 if (mode & PM_HASTE) (void)set_monster_fast(g_ptr->m_idx, 100);
3186 /* Give a random starting energy */
3187 if (!ironman_nightmare)
3189 m_ptr->energy_need = ENERGY_NEED() - (s16b)randint0(100);
3193 /* Nightmare monsters are more prepared */
3194 m_ptr->energy_need = ENERGY_NEED() - (s16b)randint0(100) * 2;
3197 /* Force monster to wait for player, unless in Nightmare mode */
3198 if ((r_ptr->flags1 & RF1_FORCE_SLEEP) && !ironman_nightmare)
3200 /* Monster is still being nice */
3201 m_ptr->mflag |= (MFLAG_NICE);
3203 /* Must repair monsters */
3204 repair_monsters = TRUE;
3207 /* Hack -- see "process_monsters()" */
3208 if (g_ptr->m_idx < hack_m_idx)
3210 /* Monster is still being born */
3211 m_ptr->mflag |= (MFLAG_BORN);
3215 if (r_ptr->flags7 & RF7_SELF_LD_MASK)
3216 p_ptr->update |= (PU_MON_LITE);
3217 else if ((r_ptr->flags7 & RF7_HAS_LD_MASK) && !MON_CSLEEP(m_ptr))
3218 p_ptr->update |= (PU_MON_LITE);
3219 update_monster(g_ptr->m_idx, TRUE);
3222 /* Count the monsters on the level */
3223 real_r_ptr(m_ptr)->cur_num++;
3226 * Memorize location of the unique monster in saved floors.
3227 * A unique monster move from old saved floor.
3229 if (character_dungeon &&
3230 ((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags7 & RF7_NAZGUL)))
3231 real_r_ptr(m_ptr)->floor_id = p_ptr->floor_id;
3233 /* Hack -- Count the number of "reproducers" */
3234 if (r_ptr->flags2 & RF2_MULTIPLY) num_repro++;
3236 /* Hack -- Notice new multi-hued monsters */
3238 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
3239 if (ap_r_ptr->flags1 & (RF1_ATTR_MULTI | RF1_SHAPECHANGER))
3240 shimmer_monsters = TRUE;
3243 if (p_ptr->warning && character_dungeon)
3245 if (r_ptr->flags1 & RF1_UNIQUE)
3249 GAME_TEXT o_name[MAX_NLEN];
3251 if (r_ptr->level > p_ptr->lev + 30)
3252 color = _("黒く", "black");
3253 else if (r_ptr->level > p_ptr->lev + 15)
3254 color = _("紫色に", "purple");
3255 else if (r_ptr->level > p_ptr->lev + 5)
3256 color = _("ルビー色に", "deep red");
3257 else if (r_ptr->level > p_ptr->lev - 5)
3258 color = _("赤く", "red");
3259 else if (r_ptr->level > p_ptr->lev - 15)
3260 color = _("ピンク色に", "pink");
3262 color = _("白く", "white");
3264 o_ptr = choose_warning_item();
3267 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
3268 msg_format(_("%sは%s光った。", "%s glows %s."), o_name, color);
3272 msg_format(_("%s光る物が頭に浮かんだ。", "An %s image forms in your mind."), color);
3277 if (is_explosive_rune_grid(g_ptr))
3279 /* Break the ward */
3280 if (randint1(BREAK_MINOR_GLYPH) > r_ptr->level)
3282 /* Describe observable breakage */
3283 if (g_ptr->info & CAVE_MARK)
3285 msg_print(_("ルーンが爆発した!", "The rune explodes!"));
3286 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);
3291 msg_print(_("爆発のルーンは解除された。", "An explosive rune was disarmed."));
3294 /* Forget the rune */
3295 g_ptr->info &= ~(CAVE_MARK);
3297 /* Break the rune */
3298 g_ptr->info &= ~(CAVE_OBJECT);
3311 #define MON_SCAT_MAXD 10 /*!< mon_scatter()関数によるモンスター配置で許される中心からの最大距離 */
3314 * @brief モンスター1体を目標地点に可能な限り近い位置に生成する / improved version of scatter() for place monster
3315 * @param r_idx 生成モンスター種族
3316 * @param yp 結果生成位置y座標
3317 * @param xp 結果生成位置x座標
3318 * @param y 中心生成位置y座標
3319 * @param x 中心生成位置x座標
3320 * @param max_dist 生成位置の最大半径
3324 static bool mon_scatter(MONRACE_IDX r_idx, POSITION *yp, POSITION *xp, POSITION y, POSITION x, POSITION max_dist)
3326 POSITION place_x[MON_SCAT_MAXD];
3327 POSITION place_y[MON_SCAT_MAXD];
3328 int num[MON_SCAT_MAXD];
3332 if (max_dist >= MON_SCAT_MAXD)
3335 for (i = 0; i < MON_SCAT_MAXD; i++)
3338 for (nx = x - max_dist; nx <= x + max_dist; nx++)
3340 for (ny = y - max_dist; ny <= y + max_dist; ny++)
3342 /* Ignore annoying locations */
3343 if (!in_bounds(ny, nx)) continue;
3345 /* Require "line of projection" */
3346 if (!projectable(y, x, ny, nx)) continue;
3350 monster_race *r_ptr = &r_info[r_idx];
3352 /* Require empty space (if not ghostly) */
3353 if (!monster_can_enter(ny, nx, r_ptr, 0))
3358 /* Walls and Monsters block flow */
3359 if (!cave_empty_bold2(ny, nx)) continue;
3361 /* ... nor on the Pattern */
3362 if (pattern_tile(ny, nx)) continue;
3365 i = distance(y, x, ny, nx);
3373 if (one_in_(num[i]))
3382 while (i < MON_SCAT_MAXD && 0 == num[i])
3384 if (i >= MON_SCAT_MAXD)
3394 * @brief モンスターを目標地点に集団生成する / Attempt to place a "group" of monsters around the given location
3395 * @param who 召喚主のモンスター情報ID
3396 * @param y 中心生成位置y座標
3397 * @param x 中心生成位置x座標
3398 * @param r_idx 生成モンスター種族
3399 * @param mode 生成オプション
3402 static bool place_monster_group(MONSTER_IDX who, POSITION y, POSITION x, MONRACE_IDX r_idx, BIT_FLAGS mode)
3404 monster_race *r_ptr = &r_info[r_idx];
3407 int total = 0, extra = 0;
3411 POSITION hack_y[GROUP_MAX];
3412 POSITION hack_x[GROUP_MAX];
3415 /* Pick a group size */
3416 total = randint1(10);
3418 /* Hard monsters, small groups */
3419 if (r_ptr->level > dun_level)
3421 extra = r_ptr->level - dun_level;
3422 extra = 0 - randint1(extra);
3425 /* Easy monsters, large groups */
3426 else if (r_ptr->level < dun_level)
3428 extra = dun_level - r_ptr->level;
3429 extra = randint1(extra);
3432 /* Hack -- limit group reduction */
3433 if (extra > 9) extra = 9;
3435 /* Modify the group size */
3439 if (total < 1) total = 1;
3442 if (total > GROUP_MAX) total = GROUP_MAX;
3445 /* Start on the monster */
3450 /* Puddle monsters, breadth first, up to total */
3451 for (n = 0; (n < hack_n) && (hack_n < total); n++)
3453 /* Grab the location */
3454 POSITION hx = hack_x[n];
3455 POSITION hy = hack_y[n];
3457 /* Check each direction, up to total */
3458 for (i = 0; (i < 8) && (hack_n < total); i++)
3462 scatter(&my, &mx, hy, hx, 4, 0);
3464 /* Walls and Monsters block flow */
3465 if (!cave_empty_bold2(my, mx)) continue;
3467 /* Attempt to place another monster */
3468 if (place_monster_one(who, my, mx, r_idx, mode))
3470 /* Add it to the "hack" set */
3471 hack_y[hack_n] = my;
3472 hack_x[hack_n] = mx;
3484 * @var place_monster_idx
3485 * @brief 護衛対象となるモンスター種族IDを渡すグローバル変数 / Hack -- help pick an escort type
3486 * @todo 関数ポインタの都合を配慮しながら、グローバル変数place_monster_idxを除去し、関数引数化する
3488 static MONSTER_IDX place_monster_idx = 0;
3491 * @var place_monster_m_idx
3492 * @brief 護衛対象となるモンスターIDを渡すグローバル変数 / Hack -- help pick an escort type
3493 * @todo 関数ポインタの都合を配慮しながら、グローバル変数place_monster_m_idxを除去し、関数引数化する
3495 static MONSTER_IDX place_monster_m_idx = 0;
3498 * @brief モンスター種族が召喚主の護衛となれるかどうかをチェックする / Hack -- help pick an escort type
3499 * @param r_idx チェックするモンスター種族のID
3500 * @return 護衛にできるならばtrue
3502 static bool place_monster_can_escort(MONRACE_IDX r_idx)
3504 monster_race *r_ptr = &r_info[place_monster_idx];
3505 monster_type *m_ptr = &m_list[place_monster_m_idx];
3507 monster_race *z_ptr = &r_info[r_idx];
3509 /* Hack - Escorts have to have the same dungeon flag */
3510 if (mon_hook_dungeon(place_monster_idx) != mon_hook_dungeon(r_idx)) return (FALSE);
3512 /* Require similar "race" */
3513 if (z_ptr->d_char != r_ptr->d_char) return (FALSE);
3515 /* Skip more advanced monsters */
3516 if (z_ptr->level > r_ptr->level) return (FALSE);
3518 /* Skip unique monsters */
3519 if (z_ptr->flags1 & RF1_UNIQUE) return (FALSE);
3521 /* Paranoia -- Skip identical monsters */
3522 if (place_monster_idx == r_idx) return (FALSE);
3524 /* Skip different alignment */
3525 if (monster_has_hostile_align(m_ptr, 0, 0, z_ptr)) return FALSE;
3527 if (r_ptr->flags7 & RF7_FRIENDLY)
3529 if (monster_has_hostile_align(NULL, 1, -1, z_ptr)) return FALSE;
3532 if ((r_ptr->flags7 & RF7_CHAMELEON) && !(z_ptr->flags7 & RF7_CHAMELEON))
3540 * @brief 一般的なモンスター生成処理のサブルーチン / Attempt to place a monster of the given race at the given location
3541 * @param who 召喚主のモンスター情報ID
3544 * @param r_idx 生成するモンスターの種族ID
3545 * @param mode 生成オプション
3546 * @return 生成に成功したらtrue
3548 * Note that certain monsters are now marked as requiring "friends".
3549 * These monsters, if successfully placed, and if the "grp" parameter
3550 * is TRUE, will be surrounded by a "group" of identical monsters.
3552 * Note that certain monsters are now marked as requiring an "escort",
3553 * which is a collection of monsters with similar "race" but lower level.
3555 * Some monsters induce a fake "group" flag on their escorts.
3557 * Note the "bizarre" use of non-recursion to prevent annoying output
3558 * when running a code profiler.
3560 * Note the use of the new "monster allocation table" code to restrict
3561 * the "get_mon_num()" function to "legal" escort types.
3563 bool place_monster_aux(MONSTER_IDX who, POSITION y, POSITION x, MONRACE_IDX r_idx, BIT_FLAGS mode)
3566 monster_race *r_ptr = &r_info[r_idx];
3568 if (!(mode & PM_NO_KAGE) && one_in_(333))
3571 /* Place one monster, or fail */
3572 if (!place_monster_one(who, y, x, r_idx, mode)) return (FALSE);
3574 /* Require the "group" flag */
3575 if (!(mode & PM_ALLOW_GROUP)) return (TRUE);
3577 place_monster_m_idx = hack_m_idx_ii;
3580 for(i = 0; i < 6; i++)
3582 if(!r_ptr->reinforce_id[i]) break;
3583 n = damroll(r_ptr->reinforce_dd[i], r_ptr->reinforce_ds[i]);
3584 for(j = 0; j < n; j++)
3586 POSITION nx, ny, d = 7;
3587 scatter(&ny, &nx, y, x, d, 0);
3588 (void)place_monster_one(place_monster_m_idx, ny, nx, r_ptr->reinforce_id[i], mode);
3592 /* Friends for certain monsters */
3593 if (r_ptr->flags1 & (RF1_FRIENDS))
3595 /* Attempt to place a group */
3596 (void)place_monster_group(who, y, x, r_idx, mode);
3599 /* Escorts for certain monsters */
3600 if (r_ptr->flags1 & (RF1_ESCORT))
3602 /* Set the escort index */
3603 place_monster_idx = r_idx;
3605 /* Try to place several "escorts" */
3606 for (i = 0; i < 32; i++)
3608 POSITION nx, ny, d = 3;
3611 /* Pick a location */
3612 scatter(&ny, &nx, y, x, d, 0);
3614 /* Require empty grids */
3615 if (!cave_empty_bold2(ny, nx)) continue;
3616 get_mon_num_prep(place_monster_can_escort, get_monster_hook2(ny, nx));
3618 /* Pick a random race */
3619 z = get_mon_num(r_ptr->level);
3621 /* Handle failure */
3624 /* Place a single escort */
3625 (void)place_monster_one(place_monster_m_idx, ny, nx, z, mode);
3627 /* Place a "group" of escorts if needed */
3628 if ((r_info[z].flags1 & RF1_FRIENDS) ||
3629 (r_ptr->flags1 & RF1_ESCORTS))
3631 /* Place a group of monsters */
3632 (void)place_monster_group(place_monster_m_idx, ny, nx, z, mode);
3642 * @brief 一般的なモンスター生成処理のメインルーチン / Attempt to place a monster of the given race at the given location
3645 * @param mode 生成オプション
3646 * @return 生成に成功したらtrue
3648 bool place_monster(POSITION y, POSITION x, BIT_FLAGS mode)
3651 get_mon_num_prep(get_monster_hook(), get_monster_hook2(y, x));
3653 /* Pick a monster */
3654 r_idx = get_mon_num(monster_level);
3656 /* Handle failure */
3657 if (!r_idx) return (FALSE);
3659 /* Attempt to place the monster */
3660 if (place_monster_aux(0, y, x, r_idx, mode)) return (TRUE);
3666 * @brief 指定地点に1種類のモンスター種族による群れを生成する
3669 * @return 生成に成功したらtrue
3671 bool alloc_horde(POSITION y, POSITION x)
3673 monster_race *r_ptr = NULL;
3674 MONRACE_IDX r_idx = 0;
3676 int attempts = 1000;
3679 get_mon_num_prep(get_monster_hook(), get_monster_hook2(y, x));
3683 /* Pick a monster */
3684 r_idx = get_mon_num(monster_level);
3686 /* Handle failure */
3687 if (!r_idx) return (FALSE);
3689 r_ptr = &r_info[r_idx];
3691 if (r_ptr->flags1 & RF1_UNIQUE) continue;
3693 if (r_idx == MON_HAGURE) continue;
3696 if (attempts < 1) return FALSE;
3702 /* Attempt to place the monster */
3703 if (place_monster_aux(0, y, x, r_idx, 0L)) break;
3706 if (attempts < 1) return FALSE;
3708 m_idx = grid_array[y][x].m_idx;
3710 if (m_list[m_idx].mflag2 & MFLAG2_CHAMELEON) r_ptr = &r_info[m_list[m_idx].r_idx];
3712 for (attempts = randint1(10) + 5; attempts; attempts--)
3714 scatter(&cy, &cx, y, x, 5, 0);
3716 (void)summon_specific(m_idx, cy, cx, dun_level + 5, SUMMON_KIN, PM_ALLOW_GROUP, r_ptr->d_char);
3722 if (cheat_hear) msg_format(_("モンスターの大群(%c)", "Monster horde (%c)."), r_ptr->d_char);
3727 * @brief ダンジョンの主生成を試みる / Put the Guardian
3728 * @param def_val 現在の主の生成状態
3729 * @return 生成に成功したらtrue
3731 bool alloc_guardian(bool def_val)
3733 MONRACE_IDX guardian = d_info[p_ptr->dungeon_idx].final_guardian;
3735 if (guardian && (d_info[p_ptr->dungeon_idx].maxdepth == dun_level) && (r_info[guardian].cur_num < r_info[guardian].max_num))
3739 int try_count = 4000;
3741 /* Find a good position */
3744 /* Get a random spot */
3745 oy = randint1(cur_hgt - 4) + 2;
3746 ox = randint1(cur_wid - 4) + 2;
3748 /* Is it a good spot ? */
3749 if (cave_empty_bold2(oy, ox) && monster_can_cross_terrain(grid_array[oy][ox].feat, &r_info[guardian], 0))
3751 /* Place the guardian */
3752 if (place_monster_aux(0, oy, ox, guardian, (PM_ALLOW_GROUP | PM_NO_KAGE | PM_NO_PET))) return TRUE;
3755 /* One less try count */
3767 * @brief ダンジョンの初期配置モンスターを生成1回生成する / Attempt to allocate a random monster in the dungeon.
3768 * @param dis プレイヤーから離れるべき最低距離
3769 * @param mode 生成オプション
3770 * @return 生成に成功したらtrue
3772 * Place the monster at least "dis" distance from the player.
3773 * Use "slp" to choose the initial "sleep" status
3774 * Use "monster_level" for the monster level
3776 bool alloc_monster(POSITION dis, BIT_FLAGS mode)
3778 POSITION y = 0, x = 0;
3779 int attempts_left = 10000;
3781 /* Put the Guardian */
3782 if (alloc_guardian(FALSE)) return TRUE;
3784 /* Find a legal, distant, unoccupied, space */
3785 while (attempts_left--)
3787 /* Pick a location */
3788 y = randint0(cur_hgt);
3789 x = randint0(cur_wid);
3791 /* Require empty floor grid (was "naked") */
3794 if (!cave_empty_bold2(y, x)) continue;
3798 if (!cave_empty_bold(y, x)) continue;
3801 /* Accept far away grids */
3802 if (distance(y, x, p_ptr->y, p_ptr->x) > dis) break;
3807 if (cheat_xtra || cheat_hear)
3809 msg_print(_("警告!新たなモンスターを配置できません。小さい階ですか?", "Warning! Could not allocate a new monster. Small level?"));
3816 if (randint1(5000) <= dun_level)
3818 if (alloc_horde(y, x))
3825 /* Attempt to place the monster, allow groups */
3826 if (place_monster(y, x, (mode | PM_ALLOW_GROUP))) return (TRUE);
3834 * @brief モンスターが召喚の基本条件に合っているかをチェックする / Hack -- help decide if a monster race is "okay" to summon
3835 * @param r_idx チェックするモンスター種族ID
3836 * @return 召喚対象にできるならばTRUE
3838 static bool summon_specific_okay(MONRACE_IDX r_idx)
3840 monster_race *r_ptr = &r_info[r_idx];
3842 /* Hack - Only summon dungeon monsters */
3843 if (!mon_hook_dungeon(r_idx)) return (FALSE);
3845 /* Hack -- identify the summoning monster */
3846 if (summon_specific_who > 0)
3848 monster_type *m_ptr = &m_list[summon_specific_who];
3850 /* Do not summon enemies */
3852 /* Friendly vs. opposite aligned normal or pet */
3853 if (monster_has_hostile_align(m_ptr, 0, 0, r_ptr)) return FALSE;
3855 /* Use the player's alignment */
3856 else if (summon_specific_who < 0)
3858 /* Do not summon enemies of the pets */
3859 if (monster_has_hostile_align(NULL, 10, -10, r_ptr))
3861 if (!one_in_(ABS(p_ptr->align) / 2 + 1)) return FALSE;
3865 if (!summon_unique_okay && ((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags7 & RF7_NAZGUL))) return FALSE;
3867 /* Hack -- no specific type specified */
3868 if (!summon_specific_type) return (TRUE);
3870 if ((summon_specific_who < 0) &&
3871 ((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags7 & RF7_NAZGUL)) &&
3872 monster_has_hostile_align(NULL, 10, -10, r_ptr))
3875 if ((r_ptr->flags7 & RF7_CHAMELEON) && (d_info[p_ptr->dungeon_idx].flags1 & DF1_CHAMELEON)) return TRUE;
3877 return (summon_specific_aux(r_idx));
3882 * @brief モンスターを召喚により配置する / Place a monster (of the specified "type") near the given location. Return TRUE if a monster was actually summoned.
3883 * @param who 召喚主のモンスター情報ID
3888 * @param mode 生成オプション
3889 * @return 召喚できたらtrueを返す
3892 * We will attempt to place the monster up to 10 times before giving up.
3894 * Note: SUMMON_UNIQUE and SUMMON_AMBERITES will summon Unique's
3895 * Note: SUMMON_HI_UNDEAD and SUMMON_HI_DRAGON may summon Unique's
3896 * Note: None of the other summon codes will ever summon Unique's.
3898 * This function has been changed. We now take the "monster level"
3899 * of the summoning monster as a parameter, and use that, along with
3900 * the current dungeon level, to help determine the level of the
3901 * desired monster. Note that this is an upper bound, and also
3902 * tends to "prefer" monsters of that level. Currently, we use
3903 * the average of the dungeon and monster levels, and then add
3904 * five to allow slight increases in monster power.
3906 * Note that we use the new "monster allocation table" creation code
3907 * to restrict the "get_mon_num()" function to the set of "legal"
3908 * monsters, making this function much faster and more reliable.
3910 * Note that this function may not succeed, though this is very rare.
3912 bool summon_specific(MONSTER_IDX who, POSITION y1, POSITION x1, DEPTH lev, int type, BIT_FLAGS mode, SYMBOL_CODE symbol)
3917 if (p_ptr->inside_arena) return (FALSE);
3919 if (!mon_scatter(0, &y, &x, y1, x1, 2)) return FALSE;
3921 /* Save the summoner */
3922 summon_specific_who = who;
3924 /* Save the "summon" type */
3925 summon_specific_type = type;
3927 summon_kin_type = symbol;
3929 summon_unique_okay = (mode & PM_ALLOW_UNIQUE) ? TRUE : FALSE;
3930 get_mon_num_prep(summon_specific_okay, get_monster_hook2(y, x));
3932 /* Pick a monster, using the level calculation */
3933 r_idx = get_mon_num((dun_level + lev) / 2 + 5);
3935 /* Handle failure */
3938 summon_specific_type = 0;
3942 if ((type == SUMMON_BLUE_HORROR) || (type == SUMMON_DAWN)) mode |= PM_NO_KAGE;
3944 /* Attempt to place the monster (awake, allow groups) */
3945 if (!place_monster_aux(who, y, x, r_idx, mode))
3947 summon_specific_type = 0;
3951 summon_specific_type = 0;
3953 sound(SOUND_SUMMON);
3959 * @brief 特定モンスター種族を召喚により生成する / A "dangerous" function, creates a pet of the specified type
3960 * @param who 召喚主のモンスター情報ID
3963 * @param r_idx 生成するモンスター種族ID
3964 * @param mode 生成オプション
3965 * @return 召喚できたらtrueを返す
3967 bool summon_named_creature(MONSTER_IDX who, POSITION oy, POSITION ox, MONRACE_IDX r_idx, BIT_FLAGS mode)
3972 /* if (!r_idx) return; */
3974 /* Prevent illegal monsters */
3975 if (r_idx >= max_r_idx) return FALSE;
3977 if (p_ptr->inside_arena) return FALSE;
3979 if (!mon_scatter(r_idx, &y, &x, oy, ox, 2)) return FALSE;
3981 /* Place it (allow groups) */
3982 return place_monster_aux(who, y, x, r_idx, (mode | PM_NO_KAGE));
3987 * @brief モンスターを増殖生成する / Let the given monster attempt to reproduce.
3988 * @param m_idx 増殖するモンスター情報ID
3989 * @param clone クローン・モンスター処理ならばtrue
3990 * @param mode 生成オプション
3991 * @return 生成できたらtrueを返す
3993 * Note that "reproduction" REQUIRES empty space.
3995 bool multiply_monster(MONSTER_IDX m_idx, bool clone, BIT_FLAGS mode)
3997 monster_type *m_ptr = &m_list[m_idx];
4001 if (!mon_scatter(m_ptr->r_idx, &y, &x, m_ptr->fy, m_ptr->fx, 1))
4004 if (m_ptr->mflag2 & MFLAG2_NOPET) mode |= PM_NO_PET;
4006 /* Create a new monster (awake, no groups) */
4007 if (!place_monster_aux(m_idx, y, x, m_ptr->r_idx, (mode | PM_NO_KAGE | PM_MULTIPLY)))
4010 /* Hack -- Transfer "clone" flag */
4011 if (clone || (m_ptr->smart & SM_CLONED))
4013 m_list[hack_m_idx_ii].smart |= SM_CLONED;
4014 m_list[hack_m_idx_ii].mflag2 |= MFLAG2_NOPET;
4023 * @brief ダメージを受けたモンスターの様子を記述する / Dump a message describing a monster's reaction to damage
4024 * @param m_idx モンスター情報ID
4025 * @param dam 与えたダメージ
4028 * Technically should attempt to treat "Beholder"'s as jelly's
4030 void message_pain(MONSTER_IDX m_idx, HIT_POINT dam)
4032 HIT_POINT oldhp, newhp;
4034 PERCENTAGE percentage;
4036 monster_type *m_ptr = &m_list[m_idx];
4037 monster_race *r_ptr = &r_info[m_ptr->r_idx];
4039 GAME_TEXT m_name[MAX_NLEN];
4041 monster_desc(m_name, m_ptr, 0);
4043 if(dam == 0) // Notice non-damage
4045 msg_format(_("%^sはダメージを受けていない。", "%^s is unharmed."), m_name);
4049 /* Note -- subtle fix -CFT */
4051 oldhp = newhp + dam;
4052 tmp = (newhp * 100L) / oldhp;
4055 if(my_strchr(",ejmvwQ", r_ptr->d_char)) // Mushrooms, Eyes, Jellies, Molds, Vortices, Worms, Quylthulgs
4058 if(percentage > 95) msg_format("%^sはほとんど気にとめていない。", m_name);
4059 else if(percentage > 75) msg_format("%^sはしり込みした。", m_name);
4060 else if(percentage > 50) msg_format("%^sは縮こまった。", m_name);
4061 else if(percentage > 35) msg_format("%^sは痛みに震えた。", m_name);
4062 else if(percentage > 20) msg_format("%^sは身もだえした。", m_name);
4063 else if(percentage > 10) msg_format("%^sは苦痛で身もだえした。", m_name);
4064 else msg_format("%^sはぐにゃぐにゃと痙攣した。", m_name);
4066 if(percentage > 95) msg_format("%^s barely notices.", m_name);
4067 else if(percentage > 75) msg_format("%^s flinches.", m_name);
4068 else if(percentage > 50) msg_format("%^s squelches.", m_name);
4069 else if(percentage > 35) msg_format("%^s quivers in pain.", m_name);
4070 else if(percentage > 20) msg_format("%^s writhes about.", m_name);
4071 else if(percentage > 10) msg_format("%^s writhes in agony.", m_name);
4072 else msg_format("%^s jerks limply.", m_name);
4076 else if(my_strchr("l", r_ptr->d_char)) // Fish
4079 if(percentage > 95) msg_format("%^sはほとんど気にとめていない。", m_name);
4080 else if(percentage > 75) msg_format("%^sはしり込みした。", m_name);
4081 else if(percentage > 50) msg_format("%^sは躊躇した。", m_name);
4082 else if(percentage > 35) msg_format("%^sは痛みに震えた。", m_name);
4083 else if(percentage > 20) msg_format("%^sは身もだえした。", m_name);
4084 else if(percentage > 10) msg_format("%^sは苦痛で身もだえした。", m_name);
4085 else msg_format("%^sはぐにゃぐにゃと痙攣した。", m_name);
4087 if(percentage > 95) msg_format("%^s barely notices.", m_name);
4088 else if(percentage > 75) msg_format("%^s flinches.", m_name);
4089 else if(percentage > 50) msg_format("%^s hesitates.", m_name);
4090 else if(percentage > 35) msg_format("%^s quivers in pain.", m_name);
4091 else if(percentage > 20) msg_format("%^s writhes about.", m_name);
4092 else if(percentage > 10) msg_format("%^s writhes in agony.", m_name);
4093 else msg_format("%^s jerks limply.", m_name);
4097 else if(my_strchr("g#+<>", r_ptr->d_char)) // Golems, Walls, Doors, Stairs
4100 if(percentage > 95) msg_format("%sは攻撃を気にとめていない。", m_name);
4101 else if(percentage > 75) msg_format("%sは攻撃に肩をすくめた。", m_name);
4102 else if(percentage > 50) msg_format("%^sは雷鳴のように吠えた。", m_name);
4103 else if(percentage > 35) msg_format("%^sは苦しげに吠えた。", m_name);
4104 else if(percentage > 20) msg_format("%^sはうめいた。", m_name);
4105 else if(percentage > 10) msg_format("%^sは躊躇した。", m_name);
4106 else msg_format("%^sはくしゃくしゃになった。", m_name);
4108 if(percentage > 95) msg_format("%^s ignores the attack.", m_name);
4109 else if(percentage > 75) msg_format("%^s shrugs off the attack.", m_name);
4110 else if(percentage > 50) msg_format("%^s roars thunderously.", m_name);
4111 else if(percentage > 35) msg_format("%^s rumbles.", m_name);
4112 else if(percentage > 20) msg_format("%^s grunts.", m_name);
4113 else if(percentage > 10) msg_format("%^s hesitates.", m_name);
4114 else msg_format("%^s crumples.", m_name);
4118 else if(my_strchr("JMR", r_ptr->d_char) || !isalpha(r_ptr->d_char)) // Snakes, Hydrae, Reptiles, Mimics
4121 if(percentage > 95) msg_format("%^sはほとんど気にとめていない。", m_name);
4122 else if(percentage > 75) msg_format("%^sはシーッと鳴いた。", m_name);
4123 else if(percentage > 50) msg_format("%^sは怒って頭を上げた。", m_name);
4124 else if(percentage > 35) msg_format("%^sは猛然と威嚇した。", m_name);
4125 else if(percentage > 20) msg_format("%^sは身もだえした。", m_name);
4126 else if(percentage > 10) msg_format("%^sは苦痛で身もだえした。", m_name);
4127 else msg_format("%^sはぐにゃぐにゃと痙攣した。", m_name);
4129 if(percentage > 95) msg_format("%^s barely notices.", m_name);
4130 else if(percentage > 75) msg_format("%^s hisses.", m_name);
4131 else if(percentage > 50) msg_format("%^s rears up in anger.", m_name);
4132 else if(percentage > 35) msg_format("%^s hisses furiously.", m_name);
4133 else if(percentage > 20) msg_format("%^s writhes about.", m_name);
4134 else if(percentage > 10) msg_format("%^s writhes in agony.", m_name);
4135 else msg_format("%^s jerks limply.", m_name);
4139 else if(my_strchr("f", r_ptr->d_char))
4142 if(percentage > 95) msg_format("%sは攻撃に肩をすくめた。", m_name);
4143 else if(percentage > 75) msg_format("%^sは吠えた。", m_name);
4144 else if(percentage > 50) msg_format("%^sは怒って吠えた。", m_name);
4145 else if(percentage > 35) msg_format("%^sは痛みでシーッと鳴いた。", m_name);
4146 else if(percentage > 20) msg_format("%^sは痛みで弱々しく鳴いた。", m_name);
4147 else if(percentage > 10) msg_format("%^sは苦痛にうめいた。", m_name);
4148 else msg_format("%sは哀れな鳴き声を出した。", m_name);
4150 if(percentage > 95) msg_format("%^s shrugs off the attack.", m_name);
4151 else if(percentage > 75) msg_format("%^s roars.", m_name);
4152 else if(percentage > 50) msg_format("%^s growls angrily.", m_name);
4153 else if(percentage > 35) msg_format("%^s hisses with pain.", m_name);
4154 else if(percentage > 20) msg_format("%^s mewls in pain.", m_name);
4155 else if(percentage > 10) msg_format("%^s hisses in agony.", m_name);
4156 else msg_format("%^s mewls pitifully.", m_name);
4160 else if(my_strchr("acFIKS", r_ptr->d_char)) // Ants, Centipedes, Flies, Insects, Beetles, Spiders
4163 if(percentage > 95) msg_format("%sは攻撃を気にとめていない。", m_name);
4164 else if(percentage > 75) msg_format("%^sはキーキー鳴いた。", m_name);
4165 else if(percentage > 50) msg_format("%^sはヨロヨロ逃げ回った。", m_name);
4166 else if(percentage > 35) msg_format("%^sはうるさく鳴いた。", m_name);
4167 else if(percentage > 20) msg_format("%^sは痛みに痙攣した。", m_name);
4168 else if(percentage > 10) msg_format("%^sは苦痛で痙攣した。", m_name);
4169 else msg_format("%^sはピクピクひきつった。", m_name);
4171 if(percentage > 95) msg_format("%^s ignores the attack.", m_name);
4172 else if(percentage > 75) msg_format("%^s chitters.", m_name);
4173 else if(percentage > 50) msg_format("%^s scuttles about.", m_name);
4174 else if(percentage > 35) msg_format("%^s twitters.", m_name);
4175 else if(percentage > 20) msg_format("%^s jerks in pain.", m_name);
4176 else if(percentage > 10) msg_format("%^s jerks in agony.", m_name);
4177 else msg_format("%^s twitches.", m_name);
4181 else if(my_strchr("B", r_ptr->d_char)) // Birds
4184 if(percentage > 95) msg_format("%^sはさえずった。", m_name);
4185 else if(percentage > 75) msg_format("%^sはピーピー鳴いた。", m_name);
4186 else if(percentage > 50) msg_format("%^sはギャーギャー鳴いた。", m_name);
4187 else if(percentage > 35) msg_format("%^sはギャーギャー鳴きわめいた。", m_name);
4188 else if(percentage > 20) msg_format("%^sは苦しんだ。", m_name);
4189 else if(percentage > 10) msg_format("%^sはのたうち回った。", m_name);
4190 else msg_format("%^sはキーキーと鳴き叫んだ。", m_name);
4192 if(percentage > 95) msg_format("%^s chirps.", m_name);
4193 else if(percentage > 75) msg_format("%^s twitters.", m_name);
4194 else if(percentage > 50) msg_format("%^s squawks.", m_name);
4195 else if(percentage > 35) msg_format("%^s chatters.", m_name);
4196 else if(percentage > 20) msg_format("%^s jeers.", m_name);
4197 else if(percentage > 10) msg_format("%^s flutters about.", m_name);
4198 else msg_format("%^s squeaks.", m_name);
4202 else if(my_strchr("duDLUW", r_ptr->d_char)) // Dragons, Demons, High Undead
4205 if(percentage > 95) msg_format("%sは攻撃を気にとめていない。", m_name);
4206 else if(percentage > 75) msg_format("%^sはしり込みした。", m_name);
4207 else if(percentage > 50) msg_format("%^sは痛みでシーッと鳴いた。", m_name);
4208 else if(percentage > 35) msg_format("%^sは痛みでうなった。", m_name);
4209 else if(percentage > 20) msg_format("%^sは痛みに吠えた。", m_name);
4210 else if(percentage > 10) msg_format("%^sは苦しげに叫んだ。", m_name);
4211 else msg_format("%^sは弱々しくうなった。", m_name);
4213 if(percentage > 95) msg_format("%^s ignores the attack.", m_name);
4214 else if(percentage > 75) msg_format("%^s flinches.", m_name);
4215 else if(percentage > 50) msg_format("%^s hisses in pain.", m_name);
4216 else if(percentage > 35) msg_format("%^s snarls with pain.", m_name);
4217 else if(percentage > 20) msg_format("%^s roars with pain.", m_name);
4218 else if(percentage > 10) msg_format("%^s gasps.", m_name);
4219 else msg_format("%^s snarls feebly.", m_name);
4223 else if(my_strchr("s", r_ptr->d_char)) // Skeletons
4226 if(percentage > 95) msg_format("%sは攻撃を気にとめていない。", m_name);
4227 else if(percentage > 75) msg_format("%sは攻撃に肩をすくめた。", m_name);
4228 else if(percentage > 50) msg_format("%^sはカタカタと笑った。", m_name);
4229 else if(percentage > 35) msg_format("%^sはよろめいた。", m_name);
4230 else if(percentage > 20) msg_format("%^sはカタカタ言った。", m_name);
4231 else if(percentage > 10) msg_format("%^sはよろめいた。", m_name);
4232 else msg_format("%^sはガタガタ言った。", m_name);
4234 if(percentage > 95) msg_format("%^s ignores the attack.", m_name);
4235 else if(percentage > 75) msg_format("%^s shrugs off the attack.", m_name);
4236 else if(percentage > 50) msg_format("%^s rattles.", m_name);
4237 else if(percentage > 35) msg_format("%^s stumbles.", m_name);
4238 else if(percentage > 20) msg_format("%^s rattles.", m_name);
4239 else if(percentage > 10) msg_format("%^s staggers.", m_name);
4240 else msg_format("%^s clatters.", m_name);
4244 else if(my_strchr("z", r_ptr->d_char)) // Zombies
4247 if(percentage > 95) msg_format("%sは攻撃を気にとめていない。", m_name);
4248 else if(percentage > 75) msg_format("%sは攻撃に肩をすくめた。", m_name);
4249 else if(percentage > 50) msg_format("%^sはうめいた。", m_name);
4250 else if(percentage > 35) msg_format("%sは苦しげにうめいた。", m_name);
4251 else if(percentage > 20) msg_format("%^sは躊躇した。", m_name);
4252 else if(percentage > 10) msg_format("%^sはうなった。", m_name);
4253 else msg_format("%^sはよろめいた。", m_name);
4255 if(percentage > 95) msg_format("%^s ignores the attack.", m_name);
4256 else if(percentage > 75) msg_format("%^s shrugs off the attack.", m_name);
4257 else if(percentage > 50) msg_format("%^s groans.", m_name);
4258 else if(percentage > 35) msg_format("%^s moans.", m_name);
4259 else if(percentage > 20) msg_format("%^s hesitates.", m_name);
4260 else if(percentage > 10) msg_format("%^s grunts.", m_name);
4261 else msg_format("%^s staggers.", m_name);
4265 else if(my_strchr("G", r_ptr->d_char)) // Ghosts
4268 if(percentage > 95) msg_format("%sは攻撃を気にとめていない。", m_name);
4269 else if(percentage > 75) msg_format("%sは攻撃に肩をすくめた。", m_name);
4270 else if(percentage > 50) msg_format("%sはうめいた。", m_name);
4271 else if(percentage > 35) msg_format("%^sは泣きわめいた。", m_name);
4272 else if(percentage > 20) msg_format("%^sは吠えた。", m_name);
4273 else if(percentage > 10) msg_format("%sは弱々しくうめいた。", m_name);
4274 else msg_format("%^sはかすかにうめいた。", m_name);
4276 if(percentage > 95) msg_format("%^s ignores the attack.", m_name);
4277 else if(percentage > 75) msg_format("%^s shrugs off the attack.", m_name);
4278 else if(percentage > 50) msg_format("%^s moans.", m_name);
4279 else if(percentage > 35) msg_format("%^s wails.", m_name);
4280 else if(percentage > 20) msg_format("%^s howls.", m_name);
4281 else if(percentage > 10) msg_format("%^s moans softly.", m_name);
4282 else msg_format("%^s sighs.", m_name);
4286 else if(my_strchr("CZ", r_ptr->d_char)) // Dogs and Hounds
4289 if(percentage > 95) msg_format("%^sは攻撃に肩をすくめた。", m_name);
4290 else if(percentage > 75) msg_format("%^sは痛みでうなった。", m_name);
4291 else if(percentage > 50) msg_format("%^sは痛みでキャンキャン吠えた。", m_name);
4292 else if(percentage > 35) msg_format("%^sは痛みで鳴きわめいた。", m_name);
4293 else if(percentage > 20) msg_format("%^sは苦痛のあまり鳴きわめいた。", m_name);
4294 else if(percentage > 10) msg_format("%^sは苦痛でもだえ苦しんだ。", m_name);
4295 else msg_format("%^sは弱々しく吠えた。", m_name);
4297 if(percentage > 95) msg_format("%^s shrugs off the attack.", m_name);
4298 else if(percentage > 75) msg_format("%^s snarls with pain.", m_name);
4299 else if(percentage > 50) msg_format("%^s yelps in pain.", m_name);
4300 else if(percentage > 35) msg_format("%^s howls in pain.", m_name);
4301 else if(percentage > 20) msg_format("%^s howls in agony.", m_name);
4302 else if(percentage > 10) msg_format("%^s writhes in agony.", m_name);
4303 else msg_format("%^s yelps feebly.", m_name);
4307 else if(my_strchr("Xbilqrt", r_ptr->d_char)) // One type of creatures (ignore,squeal,shriek)
4310 if(percentage > 95) msg_format("%^sは攻撃を気にとめていない。", m_name);
4311 else if(percentage > 75) msg_format("%^sは痛みでうなった。", m_name);
4312 else if(percentage > 50) msg_format("%^sは痛みで叫んだ。", m_name);
4313 else if(percentage > 35) msg_format("%^sは痛みで絶叫した。", m_name);
4314 else if(percentage > 20) msg_format("%^sは苦痛のあまり絶叫した。", m_name);
4315 else if(percentage > 10) msg_format("%^sは苦痛でもだえ苦しんだ。", m_name);
4316 else msg_format("%^sは弱々しく叫んだ。", m_name);
4318 if(percentage > 95) msg_format("%^s ignores the attack.", m_name);
4319 else if(percentage > 75) msg_format("%^s grunts with pain.", m_name);
4320 else if(percentage > 50) msg_format("%^s squeals in pain.", m_name);
4321 else if(percentage > 35) msg_format("%^s shrieks in pain.", m_name);
4322 else if(percentage > 20) msg_format("%^s shrieks in agony.", m_name);
4323 else if(percentage > 10) msg_format("%^s writhes in agony.", m_name);
4324 else msg_format("%^s cries out feebly.", m_name);
4328 else // Another type of creatures (shrug,cry,scream)
4331 if(percentage > 95) msg_format("%^sは攻撃に肩をすくめた。", m_name);
4332 else if(percentage > 75) msg_format("%^sは痛みでうなった。", m_name);
4333 else if(percentage > 50) msg_format("%^sは痛みで叫んだ。", m_name);
4334 else if(percentage > 35) msg_format("%^sは痛みで絶叫した。", m_name);
4335 else if(percentage > 20) msg_format("%^sは苦痛のあまり絶叫した。", m_name);
4336 else if(percentage > 10) msg_format("%^sは苦痛でもだえ苦しんだ。", m_name);
4337 else msg_format("%^sは弱々しく叫んだ。", m_name);
4339 if(percentage > 95) msg_format("%^s shrugs off the attack.", m_name);
4340 else if(percentage > 75) msg_format("%^s grunts with pain.", m_name);
4341 else if(percentage > 50) msg_format("%^s cries out in pain.", m_name);
4342 else if(percentage > 35) msg_format("%^s screams in pain.", m_name);
4343 else if(percentage > 20) msg_format("%^s screams in agony.", m_name);
4344 else if(percentage > 10) msg_format("%^s writhes in agony.", m_name);
4345 else msg_format("%^s cries out feebly.", m_name);
4353 * @brief SMART(適格に攻撃を行う)モンスターの学習状況を更新する / Learn about an "observed" resistance.
4354 * @param m_idx 更新を行う「モンスター情報ID
4355 * @param what 学習対象ID
4358 void update_smart_learn(MONSTER_IDX m_idx, int what)
4360 monster_type *m_ptr = &m_list[m_idx];
4361 monster_race *r_ptr = &r_info[m_ptr->r_idx];
4363 /* Not allowed to learn */
4364 if (!smart_learn) return;
4366 /* Too stupid to learn anything */
4367 if (r_ptr->flags2 & (RF2_STUPID)) return;
4369 /* Not intelligent, only learn sometimes */
4370 if (!(r_ptr->flags2 & (RF2_SMART)) && (randint0(100) < 50)) return;
4372 /* Analyze the knowledge */
4376 if (p_ptr->resist_acid) m_ptr->smart |= (SM_RES_ACID);
4377 if (IS_OPPOSE_ACID()) m_ptr->smart |= (SM_OPP_ACID);
4378 if (p_ptr->immune_acid) m_ptr->smart |= (SM_IMM_ACID);
4382 if (p_ptr->resist_elec) m_ptr->smart |= (SM_RES_ELEC);
4383 if (IS_OPPOSE_ELEC()) m_ptr->smart |= (SM_OPP_ELEC);
4384 if (p_ptr->immune_elec) m_ptr->smart |= (SM_IMM_ELEC);
4388 if (p_ptr->resist_fire) m_ptr->smart |= (SM_RES_FIRE);
4389 if (IS_OPPOSE_FIRE()) m_ptr->smart |= (SM_OPP_FIRE);
4390 if (p_ptr->immune_fire) m_ptr->smart |= (SM_IMM_FIRE);
4394 if (p_ptr->resist_cold) m_ptr->smart |= (SM_RES_COLD);
4395 if (IS_OPPOSE_COLD()) m_ptr->smart |= (SM_OPP_COLD);
4396 if (p_ptr->immune_cold) m_ptr->smart |= (SM_IMM_COLD);
4400 if (p_ptr->resist_pois) m_ptr->smart |= (SM_RES_POIS);
4401 if (IS_OPPOSE_POIS()) m_ptr->smart |= (SM_OPP_POIS);
4406 if (p_ptr->resist_neth) m_ptr->smart |= (SM_RES_NETH);
4410 if (p_ptr->resist_lite) m_ptr->smart |= (SM_RES_LITE);
4414 if (p_ptr->resist_dark) m_ptr->smart |= (SM_RES_DARK);
4418 if (p_ptr->resist_fear) m_ptr->smart |= (SM_RES_FEAR);
4422 if (p_ptr->resist_conf) m_ptr->smart |= (SM_RES_CONF);
4426 if (p_ptr->resist_chaos) m_ptr->smart |= (SM_RES_CHAOS);
4430 if (p_ptr->resist_disen) m_ptr->smart |= (SM_RES_DISEN);
4434 if (p_ptr->resist_blind) m_ptr->smart |= (SM_RES_BLIND);
4438 if (p_ptr->resist_nexus) m_ptr->smart |= (SM_RES_NEXUS);
4442 if (p_ptr->resist_sound) m_ptr->smart |= (SM_RES_SOUND);
4446 if (p_ptr->resist_shard) m_ptr->smart |= (SM_RES_SHARD);
4450 if (p_ptr->free_act) m_ptr->smart |= (SM_IMM_FREE);
4454 if (!p_ptr->msp) m_ptr->smart |= (SM_IMM_MANA);
4458 if (p_ptr->reflect) m_ptr-> smart |= (SM_IMM_REFLECT);
4465 * @brief プレイヤーを指定座標に配置する / Place the player in the dungeon XXX XXX
4468 * @return 配置に成功したらTRUE
4470 bool player_place(POSITION y, POSITION x)
4472 /* Paranoia XXX XXX */
4473 if (grid_array[y][x].m_idx != 0) return FALSE;
4475 /* Save player location */
4485 * @brief モンスターが盗みや拾いで確保していたアイテムを全てドロップさせる / Drop all items carried by a monster
4486 * @param m_ptr モンスター参照ポインタ
4489 void monster_drop_carried_objects(monster_type *m_ptr)
4491 OBJECT_IDX this_o_idx, next_o_idx = 0;
4497 /* Drop objects being carried */
4498 for (this_o_idx = m_ptr->hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
4500 o_ptr = &o_list[this_o_idx];
4502 /* Acquire next object */
4503 next_o_idx = o_ptr->next_o_idx;
4506 /* Copy the object */
4507 object_copy(q_ptr, o_ptr);
4509 /* Forget monster */
4510 q_ptr->held_m_idx = 0;
4512 delete_object_idx(this_o_idx);
4515 (void)drop_near(q_ptr, -1, m_ptr->fy, m_ptr->fx);
4518 /* Forget objects */
4519 m_ptr->hold_o_idx = 0;