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 #include "player-move.h"
26 #define HORDE_NOGOOD 0x01 /*!< (未実装フラグ)HORDE生成でGOODなモンスターの生成を禁止する? */
27 #define HORDE_NOEVIL 0x02 /*!< (未実装フラグ)HORDE生成でEVILなモンスターの生成を禁止する? */
32 * @brief ELDRITCH HORROR効果時のモンスターの形容メッセージ(通常時)
34 concptr horror_desc[MAX_SAN_HORROR] =
90 * @brief ELDRITCH HORROR効果時のモンスターの形容メッセージ(幻覚状態時)
92 concptr funny_desc[MAX_SAN_FUNNY] =
153 * @var funny_comments
154 * @brief ELDRITCH HORROR効果時の幻覚時間延長を示す錯乱表現
156 concptr funny_comments[MAX_SAN_COMMENT] =
177 * @brief モンスターの目標地点をセットする / Set the target of counter attack
178 * @param m_ptr モンスターの参照ポインタ
183 void set_target(monster_type *m_ptr, POSITION y, POSITION x)
191 * @brief モンスターの目標地点をリセットする / Reset the target of counter attack
192 * @param m_ptr モンスターの参照ポインタ
195 void reset_target(monster_type *m_ptr)
197 set_target(m_ptr, 0, 0);
202 * @brief モンスターの真の種族を返す / Extract monster race pointer of a monster's true form
203 * @param m_ptr モンスターの参照ポインタ
204 * @return 本当のモンスター種族参照ポインタ
206 monster_race *real_r_ptr(monster_type *m_ptr)
208 return &r_info[real_r_idx(m_ptr)];
211 MONRACE_IDX real_r_idx(monster_type *m_ptr)
213 monster_race *r_ptr = &r_info[m_ptr->r_idx];
215 /* Extract real race */
216 if (m_ptr->mflag2 & MFLAG2_CHAMELEON)
218 if (r_ptr->flags1 & RF1_UNIQUE)
219 return MON_CHAMELEON_K;
221 return MON_CHAMELEON;
231 * @brief モンスター配列からモンスターを消去する / Delete a monster by index.
232 * @param i 消去するモンスターのID
235 * モンスターを削除するとそのモンスターが拾っていたアイテムも同時に削除される。 /
236 * When a monster is deleted, all of its objects are deleted.
238 void delete_monster_idx(MONSTER_IDX i)
241 monster_type *m_ptr = ¤t_floor_ptr->m_list[i];
242 monster_race *r_ptr = &r_info[m_ptr->r_idx];
243 OBJECT_IDX this_o_idx, next_o_idx = 0;
248 /* Hack -- Reduce the racial counter */
249 real_r_ptr(m_ptr)->cur_num--;
251 /* Hack -- count the number of "reproducers" */
252 if (r_ptr->flags2 & (RF2_MULTIPLY)) current_floor_ptr->num_repro--;
254 if (MON_CSLEEP(m_ptr)) (void)set_monster_csleep(i, 0);
255 if (MON_FAST(m_ptr)) (void)set_monster_fast(i, 0);
256 if (MON_SLOW(m_ptr)) (void)set_monster_slow(i, 0);
257 if (MON_STUNNED(m_ptr)) (void)set_monster_stunned(i, 0);
258 if (MON_CONFUSED(m_ptr)) (void)set_monster_confused(i, 0);
259 if (MON_MONFEAR(m_ptr)) (void)set_monster_monfear(i, 0);
260 if (MON_INVULNER(m_ptr)) (void)set_monster_invulner(i, 0, FALSE);
262 /* Hack -- remove target monster */
263 if (i == target_who) target_who = 0;
265 /* Hack -- remove tracked monster */
266 if (i == p_ptr->health_who) health_track(0);
268 if (pet_t_m_idx == i ) pet_t_m_idx = 0;
269 if (riding_t_m_idx == i) riding_t_m_idx = 0;
270 if (p_ptr->riding == i) p_ptr->riding = 0;
272 /* Monster is gone */
273 current_floor_ptr->grid_array[y][x].m_idx = 0;
275 for (this_o_idx = m_ptr->hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
278 o_ptr = ¤t_floor_ptr->o_list[this_o_idx];
279 next_o_idx = o_ptr->next_o_idx;
282 * o_ptr->held_m_idx is needed in delete_object_idx()
283 * to prevent calling lite_spot()
286 delete_object_idx(this_o_idx);
289 if (is_pet(m_ptr)) check_pets_num_and_align(m_ptr, FALSE);
291 (void)WIPE(m_ptr, monster_type);
299 /* Update some things */
300 if (r_ptr->flags7 & (RF7_LITE_MASK | RF7_DARK_MASK))
301 p_ptr->update |= (PU_MON_LITE);
306 * @brief 指定位置に存在するモンスターを削除する / Delete the monster, if any, at a given location
311 void delete_monster(POSITION y, POSITION x)
316 if (!in_bounds(y, x)) return;
319 g_ptr = ¤t_floor_ptr->grid_array[y][x];
321 /* Delete the monster (if any) */
322 if (g_ptr->m_idx) delete_monster_idx(g_ptr->m_idx);
327 * @brief モンスター情報を配列内移動する / Move an object from index i1 to index i2 in the object list
332 static void compact_monsters_aux(IDX i1, IDX i2)
338 OBJECT_IDX this_o_idx, next_o_idx = 0;
341 if (i1 == i2) return;
344 m_ptr = ¤t_floor_ptr->m_list[i1];
350 g_ptr = ¤t_floor_ptr->grid_array[y][x];
352 /* Update the current_floor_ptr->grid_array */
355 /* Repair objects being carried by monster */
356 for (this_o_idx = m_ptr->hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
359 o_ptr = ¤t_floor_ptr->o_list[this_o_idx];
360 next_o_idx = o_ptr->next_o_idx;
362 /* Reset monster pointer */
363 o_ptr->held_m_idx = i2;
366 /* Hack -- Update the target */
367 if (target_who == i1) target_who = i2;
369 /* Hack -- Update the target */
370 if (pet_t_m_idx == i1) pet_t_m_idx = i2;
371 if (riding_t_m_idx == i1) riding_t_m_idx = i2;
373 /* Hack -- Update the riding */
374 if (p_ptr->riding == i1) p_ptr->riding = i2;
376 /* Hack -- Update the health bar */
377 if (p_ptr->health_who == i1) health_track(i2);
379 /* Hack -- Update parent index */
382 for (i = 1; i < m_max; i++)
384 monster_type *m2_ptr = ¤t_floor_ptr->m_list[i];
386 if (m2_ptr->parent_m_idx == i1)
387 m2_ptr->parent_m_idx = i2;
392 (void)COPY(¤t_floor_ptr->m_list[i2], ¤t_floor_ptr->m_list[i1], monster_type);
395 (void)WIPE(¤t_floor_ptr->m_list[i1], monster_type);
397 for (i = 0; i < MAX_MTIMED; i++)
399 int mproc_idx = get_mproc_idx(i1, i);
400 if (mproc_idx >= 0) current_floor_ptr->mproc_list[i][mproc_idx] = i2;
406 * @brief モンスター情報配列を圧縮する / Compact and Reorder the monster list
407 * @param size 圧縮後のモンスター件数目標
410 * This function can be very dangerous, use with caution!
412 * When actually "compacting" monsters, we base the saving throw
413 * on a combination of monster level, distance from player, and
414 * current "desperation".
416 * After "compacting" (if needed), we "reorder" the monsters into a more
417 * compact order, and we reset the allocation info, and the "live" array.
419 void compact_monsters(int size)
423 int cur_lev, cur_dis, chance;
425 /* Message (only if compacting) */
426 if (size) msg_print(_("モンスター情報を圧縮しています...", "Compacting monsters..."));
429 /* Compact at least 'size' objects */
430 for (num = 0, cnt = 1; num < size; cnt++)
432 /* Get more vicious each iteration */
435 /* Get closer each iteration */
436 cur_dis = 5 * (20 - cnt);
438 /* Check all the monsters */
439 for (i = 1; i < m_max; i++)
441 monster_type *m_ptr = ¤t_floor_ptr->m_list[i];
443 monster_race *r_ptr = &r_info[m_ptr->r_idx];
445 /* Paranoia -- skip "dead" monsters */
446 if (!m_ptr->r_idx) continue;
448 /* Hack -- High level monsters start out "immune" */
449 if (r_ptr->level > cur_lev) continue;
451 if (i == p_ptr->riding) continue;
453 /* Ignore nearby monsters */
454 if ((cur_dis > 0) && (m_ptr->cdis < cur_dis)) continue;
456 /* Saving throw chance */
459 /* Only compact "Quest" Monsters in emergencies */
460 if ((r_ptr->flags1 & (RF1_QUESTOR)) && (cnt < 1000)) chance = 100;
462 /* Try not to compact Unique Monsters */
463 if (r_ptr->flags1 & (RF1_UNIQUE)) chance = 100;
465 /* All monsters get a saving throw */
466 if (randint0(100) < chance) continue;
468 if (record_named_pet && is_pet(m_ptr) && m_ptr->nickname)
470 GAME_TEXT m_name[MAX_NLEN];
471 monster_desc(m_name, m_ptr, MD_INDEF_VISIBLE);
472 do_cmd_write_nikki(NIKKI_NAMED_PET, RECORD_NAMED_PET_COMPACT, m_name);
475 delete_monster_idx(i);
477 /* Count the monster */
483 /* Excise dead monsters (backwards!) */
484 for (i = m_max - 1; i >= 1; i--)
486 /* Get the i'th monster */
487 monster_type *m_ptr = ¤t_floor_ptr->m_list[i];
489 /* Skip real monsters */
490 if (m_ptr->r_idx) continue;
492 /* Move last monster into open hole */
493 compact_monsters_aux(m_max - 1, i);
495 /* Compress "m_max" */
502 * @brief プレイヤーのフロア離脱に伴う全モンスター配列の消去 / Delete/Remove all the monsters when the player leaves the level
505 * This is an efficient method of simulating multiple calls to the
506 * "delete_monster()" function, with no visual effects.
508 void wipe_m_list(void)
512 /* Hack -- if Banor or Lupart dies, stay another dead */
513 if (!r_info[MON_BANORLUPART].max_num)
515 if (r_info[MON_BANOR].max_num)
517 r_info[MON_BANOR].max_num = 0;
518 r_info[MON_BANOR].r_pkills++;
519 r_info[MON_BANOR].r_akills++;
520 if (r_info[MON_BANOR].r_tkills < MAX_SHORT) r_info[MON_BANOR].r_tkills++;
522 if (r_info[MON_LUPART].max_num)
524 r_info[MON_LUPART].max_num = 0;
525 r_info[MON_LUPART].r_pkills++;
526 r_info[MON_LUPART].r_akills++;
527 if (r_info[MON_LUPART].r_tkills < MAX_SHORT) r_info[MON_LUPART].r_tkills++;
531 /* Delete all the monsters */
532 for (i = m_max - 1; i >= 1; i--)
534 monster_type *m_ptr = ¤t_floor_ptr->m_list[i];
536 /* Skip dead monsters */
537 if (!m_ptr->r_idx) continue;
539 /* Monster is gone */
540 current_floor_ptr->grid_array[m_ptr->fy][m_ptr->fx].m_idx = 0;
542 (void)WIPE(m_ptr, monster_type);
547 * Wiping racial counters of all monsters and incrementing of racial
548 * counters of monsters in party_mon[] are required to prevent multiple
549 * generation of unique monster who is the minion of player.
552 /* Hack -- Wipe the racial counter of all monster races */
553 for (i = 1; i < max_r_idx; i++) r_info[i].cur_num = 0;
561 /* Reset "current_floor_ptr->mproc_max[]" */
562 for (i = 0; i < MAX_MTIMED; i++) current_floor_ptr->mproc_max[i] = 0;
564 /* Hack -- reset "reproducer" count */
565 current_floor_ptr->num_repro = 0;
567 /* Hack -- no more target */
572 /* Hack -- no more tracking */
578 * @brief モンスター配列の空きを探す / Acquires and returns the index of a "free" monster.
579 * @return 利用可能なモンスター配列の添字
581 * This routine should almost never fail, but it *can* happen.
583 MONSTER_IDX m_pop(void)
587 /* Normal allocation */
588 if (m_max < current_floor_ptr->max_m_idx)
590 /* Access the next hole */
593 /* Expand the array */
599 /* Return the index */
603 /* Recycle dead monsters */
604 for (i = 1; i < m_max; i++)
608 /* Acquire monster */
609 m_ptr = ¤t_floor_ptr->m_list[i];
611 /* Skip live monsters */
612 if (m_ptr->r_idx) continue;
617 /* Use this monster */
621 /* Warn the player (except during dungeon creation) */
622 if (character_dungeon) msg_print(_("モンスターが多すぎる!", "Too many monsters!"));
624 /* Try not to crash */
632 * @var summon_specific_type
633 * @brief 召喚条件を指定するグローバル変数 / Hack -- the "type" of the current "summon specific"
634 * @todo summon_specific_typeグローバル変数の除去と関数引数への代替を行う
636 static int summon_specific_type = 0;
640 * @var summon_specific_who
641 * @brief 召喚を行ったプレイヤーあるいはモンスターのIDを示すグローバル変数 / Hack -- the index of the summoning monster
642 * @todo summon_specific_who グローバル変数の除去と関数引数への代替を行う
644 static int summon_specific_who = -1;
647 * @var summon_unique_okay
648 * @brief 召喚対象にユニークを含めるかを示すグローバル変数 / summoning unique enable
649 * @todo summon_unique_okay グローバル変数の除去と関数引数への代替を行う
651 static bool summon_unique_okay = FALSE;
654 * @brief 指定されたモンスター種族がsummon_specific_typeで指定された召喚条件に合うかどうかを返す
655 * @return 召喚条件が一致するならtrue
658 static bool summon_specific_aux(MONRACE_IDX r_idx)
660 monster_race *r_ptr = &r_info[r_idx];
663 /* Check our requirements */
664 switch (summon_specific_type)
668 okay = (r_ptr->d_char == 'a');
674 okay = (r_ptr->d_char == 'S');
680 okay = ((r_ptr->d_char == 'C') || (r_ptr->d_char == 'Z'));
686 okay = (r_ptr->d_char == 'M');
692 okay = (r_ptr->d_char == 'A' && ((r_ptr->flags3 & RF3_EVIL) || (r_ptr->flags3 & RF3_GOOD)));
698 okay = (r_ptr->flags3 & RF3_DEMON);
704 okay = (r_ptr->flags3 & RF3_UNDEAD);
710 okay = (r_ptr->flags3 & RF3_DRAGON);
714 case SUMMON_HI_UNDEAD:
716 okay = ((r_ptr->d_char == 'L') ||
717 (r_ptr->d_char == 'V') ||
718 (r_ptr->d_char == 'W'));
722 case SUMMON_HI_DRAGON:
724 okay = (r_ptr->d_char == 'D');
728 case SUMMON_HI_DEMON:
730 okay = (((r_ptr->d_char == 'U') ||
731 (r_ptr->d_char == 'H') ||
732 (r_ptr->d_char == 'B')) &&
733 (r_ptr->flags3 & RF3_DEMON)) ? TRUE : FALSE;
737 case SUMMON_AMBERITES:
739 okay = (r_ptr->flags3 & (RF3_AMBERITE)) ? TRUE : FALSE;
745 okay = (r_ptr->flags1 & (RF1_UNIQUE)) ? TRUE : FALSE;
751 okay = (r_ptr->d_char == 'm');
756 okay = (r_ptr->d_char == 'b');
759 case SUMMON_QUYLTHULG:
761 okay = (r_ptr->d_char == 'Q');
765 case SUMMON_COIN_MIMIC:
767 okay = (r_ptr->d_char == '$');
773 okay = ((r_ptr->d_char == '!') ||
774 (r_ptr->d_char == '?') ||
775 (r_ptr->d_char == '=') ||
776 (r_ptr->d_char == '$') ||
777 (r_ptr->d_char == '|'));
783 okay = (r_ptr->d_char == 'g');
789 okay = ((r_ptr->d_char == 'U') &&
790 (r_ptr->flags4 & RF4_ROCKET));
796 okay = ((r_ptr->d_char == summon_kin_type) && (r_idx != MON_HAGURE));
802 okay = (r_idx == MON_DAWN);
808 okay = (r_ptr->flags3 & (RF3_ANIMAL));
812 case SUMMON_ANIMAL_RANGER:
814 okay = ((r_ptr->flags3 & (RF3_ANIMAL)) &&
815 (my_strchr("abcflqrwBCHIJKMRS", r_ptr->d_char)) &&
816 !(r_ptr->flags3 & (RF3_DRAGON)) &&
817 !(r_ptr->flags3 & (RF3_EVIL)) &&
818 !(r_ptr->flags3 & (RF3_UNDEAD)) &&
819 !(r_ptr->flags3 & (RF3_DEMON)) &&
820 !(r_ptr->flags2 & (RF2_MULTIPLY)) &&
821 !(r_ptr->flags4 || r_ptr->a_ability_flags1 || r_ptr->a_ability_flags2));
825 case SUMMON_HI_DRAGON_LIVING:
827 okay = ((r_ptr->d_char == 'D') && monster_living(r_idx));
833 okay = monster_living(r_idx);
839 okay = (r_idx == MON_PHANTOM_B || r_idx == MON_PHANTOM_W);
843 case SUMMON_BLUE_HORROR:
845 okay = (r_idx == MON_BLUE_HORROR);
849 case SUMMON_ELEMENTAL:
851 okay = (r_ptr->d_char == 'E');
857 okay = (r_ptr->d_char == 'v');
863 okay = (r_ptr->d_char == 'H');
869 okay = (r_ptr->d_char == 'B');
873 case SUMMON_KAMIKAZE:
876 for (i = 0; i < 4; i++)
877 if (r_ptr->blow[i].method == RBM_EXPLODE) okay = TRUE;
881 case SUMMON_KAMIKAZE_LIVING:
885 for (i = 0; i < 4; i++)
886 if (r_ptr->blow[i].method == RBM_EXPLODE) okay = TRUE;
887 okay = (okay && monster_living(r_idx));
893 okay = (r_idx == MON_MANES);
899 okay = (r_idx == MON_LOUSE);
903 case SUMMON_GUARDIANS:
905 okay = (r_ptr->flags7 & RF7_GUARDIAN);
911 okay = ((r_idx == MON_NOV_PALADIN) ||
912 (r_idx == MON_NOV_PALADIN_G) ||
913 (r_idx == MON_PALADIN) ||
914 (r_idx == MON_W_KNIGHT) ||
915 (r_idx == MON_ULTRA_PALADIN) ||
916 (r_idx == MON_KNI_TEMPLAR));
922 okay = (r_ptr->d_char == 'B' &&
923 (r_ptr->flags8 & RF8_WILD_MOUNTAIN) &&
924 (r_ptr->flags8 & RF8_WILD_ONLY));
928 case SUMMON_PIRANHAS:
930 okay = (r_idx == MON_PIRANHA);
934 case SUMMON_ARMAGE_GOOD:
936 okay = (r_ptr->d_char == 'A' && (r_ptr->flags3 & RF3_GOOD));
940 case SUMMON_ARMAGE_EVIL:
942 okay = ((r_ptr->flags3 & RF3_DEMON) ||
943 (r_ptr->d_char == 'A' && (r_ptr->flags3 & RF3_EVIL)));
947 /* Since okay is int, "return (okay);" is not correct. */
948 return (bool)(okay ? TRUE : FALSE);
952 * @var chameleon_change_m_idx
953 * @brief カメレオンの変身先モンスターIDを受け渡すためのグローバル変数
954 * @todo 変数渡しの問題などもあるができればchameleon_change_m_idxのグローバル変数を除去し、関数引き渡しに移行すること
956 static int chameleon_change_m_idx = 0;
960 * @brief 指定されたモンスター種族がダンジョンの制限にかかるかどうかをチェックする / Some dungeon types restrict the possible monsters.
961 * @param r_idx チェックするモンスター種族ID
962 * @return 召喚条件が一致するならtrue / Return TRUE is the monster is OK and FALSE otherwise
964 static bool restrict_monster_to_dungeon(MONRACE_IDX r_idx)
966 dungeon_type *d_ptr = &d_info[p_ptr->dungeon_idx];
967 monster_race *r_ptr = &r_info[r_idx];
970 if (d_ptr->flags1 & DF1_CHAMELEON)
972 if (chameleon_change_m_idx) return TRUE;
974 if (d_ptr->flags1 & DF1_NO_MAGIC)
976 if (r_idx != MON_CHAMELEON &&
978 !(r_ptr->flags4 & RF4_NOMAGIC_MASK) &&
979 !(r_ptr->a_ability_flags1 & RF5_NOMAGIC_MASK) &&
980 !(r_ptr->a_ability_flags2 & RF6_NOMAGIC_MASK))
983 if (d_ptr->flags1 & DF1_NO_MELEE)
985 if (r_idx == MON_CHAMELEON) return TRUE;
986 if (!(r_ptr->flags4 & (RF4_BOLT_MASK | RF4_BEAM_MASK | RF4_BALL_MASK)) &&
987 !(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)) &&
988 !(r_ptr->a_ability_flags2 & (RF6_BOLT_MASK | RF6_BEAM_MASK | RF6_BALL_MASK)))
991 if (d_ptr->flags1 & DF1_BEGINNER)
993 if (r_ptr->level > current_floor_ptr->dun_level)
997 if (d_ptr->special_div >= 64) return TRUE;
998 if (summon_specific_type && !(d_ptr->flags1 & DF1_CHAMELEON)) return TRUE;
1000 switch (d_ptr->mode)
1002 case DUNGEON_MODE_AND:
1005 if ((d_ptr->mflags1 & r_ptr->flags1) != d_ptr->mflags1)
1010 if ((d_ptr->mflags2 & r_ptr->flags2) != d_ptr->mflags2)
1015 if ((d_ptr->mflags3 & r_ptr->flags3) != d_ptr->mflags3)
1020 if ((d_ptr->mflags4 & r_ptr->flags4) != d_ptr->mflags4)
1023 if (d_ptr->m_a_ability_flags1)
1025 if ((d_ptr->m_a_ability_flags1 & r_ptr->a_ability_flags1) != d_ptr->m_a_ability_flags1)
1028 if (d_ptr->m_a_ability_flags2)
1030 if ((d_ptr->m_a_ability_flags2 & r_ptr->a_ability_flags2) != d_ptr->m_a_ability_flags2)
1035 if ((d_ptr->mflags7 & r_ptr->flags7) != d_ptr->mflags7)
1040 if ((d_ptr->mflags8 & r_ptr->flags8) != d_ptr->mflags8)
1045 if ((d_ptr->mflags9 & r_ptr->flags9) != d_ptr->mflags9)
1050 if ((d_ptr->mflagsr & r_ptr->flagsr) != d_ptr->mflagsr)
1053 for (a = 0; a < 5; a++)
1054 if (d_ptr->r_char[a] && (d_ptr->r_char[a] != r_ptr->d_char)) return FALSE;
1058 case DUNGEON_MODE_NAND:
1061 if ((d_ptr->mflags1 & r_ptr->flags1) != d_ptr->mflags1)
1066 if ((d_ptr->mflags2 & r_ptr->flags2) != d_ptr->mflags2)
1071 if ((d_ptr->mflags3 & r_ptr->flags3) != d_ptr->mflags3)
1076 if ((d_ptr->mflags4 & r_ptr->flags4) != d_ptr->mflags4)
1079 if (d_ptr->m_a_ability_flags1)
1081 if ((d_ptr->m_a_ability_flags1 & r_ptr->a_ability_flags1) != d_ptr->m_a_ability_flags1)
1084 if (d_ptr->m_a_ability_flags2)
1086 if ((d_ptr->m_a_ability_flags2 & r_ptr->a_ability_flags2) != d_ptr->m_a_ability_flags2)
1091 if ((d_ptr->mflags7 & r_ptr->flags7) != d_ptr->mflags7)
1096 if ((d_ptr->mflags8 & r_ptr->flags8) != d_ptr->mflags8)
1101 if ((d_ptr->mflags9 & r_ptr->flags9) != d_ptr->mflags9)
1106 if ((d_ptr->mflagsr & r_ptr->flagsr) != d_ptr->mflagsr)
1109 for (a = 0; a < 5; a++)
1110 if (d_ptr->r_char[a] && (d_ptr->r_char[a] != r_ptr->d_char)) return TRUE;
1114 case DUNGEON_MODE_OR:
1115 if (r_ptr->flags1 & d_ptr->mflags1) return TRUE;
1116 if (r_ptr->flags2 & d_ptr->mflags2) return TRUE;
1117 if (r_ptr->flags3 & d_ptr->mflags3) return TRUE;
1118 if (r_ptr->flags4 & d_ptr->mflags4) return TRUE;
1119 if (r_ptr->a_ability_flags1 & d_ptr->m_a_ability_flags1) return TRUE;
1120 if (r_ptr->a_ability_flags2 & d_ptr->m_a_ability_flags2) return TRUE;
1121 if (r_ptr->flags7 & d_ptr->mflags7) return TRUE;
1122 if (r_ptr->flags8 & d_ptr->mflags8) return TRUE;
1123 if (r_ptr->flags9 & d_ptr->mflags9) return TRUE;
1124 if (r_ptr->flagsr & d_ptr->mflagsr) return TRUE;
1125 for (a = 0; a < 5; a++)
1126 if (d_ptr->r_char[a] == r_ptr->d_char) return TRUE;
1130 case DUNGEON_MODE_NOR:
1131 if (r_ptr->flags1 & d_ptr->mflags1) return FALSE;
1132 if (r_ptr->flags2 & d_ptr->mflags2) return FALSE;
1133 if (r_ptr->flags3 & d_ptr->mflags3) return FALSE;
1134 if (r_ptr->flags4 & d_ptr->mflags4) return FALSE;
1135 if (r_ptr->a_ability_flags1 & d_ptr->m_a_ability_flags1) return FALSE;
1136 if (r_ptr->a_ability_flags2 & d_ptr->m_a_ability_flags2) return FALSE;
1137 if (r_ptr->flags7 & d_ptr->mflags7) return FALSE;
1138 if (r_ptr->flags8 & d_ptr->mflags8) return FALSE;
1139 if (r_ptr->flags9 & d_ptr->mflags9) return FALSE;
1140 if (r_ptr->flagsr & d_ptr->mflagsr) return FALSE;
1141 for (a = 0; a < 5; a++)
1142 if (d_ptr->r_char[a] == r_ptr->d_char) return FALSE;
1151 * @brief モンスター生成制限関数最大2つから / Apply a "monster restriction function" to the "monster allocation table"
1152 * @param monster_hook 制限関数1
1153 * @param monster_hook2 制限関数2
1156 errr get_mon_num_prep(monsterrace_hook_type monster_hook,
1157 monsterrace_hook_type monster_hook2)
1161 /* Todo: Check the hooks for non-changes */
1163 /* Set the new hooks */
1164 get_mon_num_hook = monster_hook;
1165 get_mon_num2_hook = monster_hook2;
1167 /* Scan the allocation table */
1168 for (i = 0; i < alloc_race_size; i++)
1170 monster_race *r_ptr;
1173 alloc_entry *entry = &alloc_race_table[i];
1176 r_ptr = &r_info[entry->index];
1178 /* Skip monsters which don't pass the restriction */
1179 if ((get_mon_num_hook && !((*get_mon_num_hook)(entry->index))) ||
1180 (get_mon_num2_hook && !((*get_mon_num2_hook)(entry->index))))
1183 if (!p_ptr->inside_battle && !chameleon_change_m_idx &&
1184 summon_specific_type != SUMMON_GUARDIANS)
1186 /* Hack -- don't create questors */
1187 if (r_ptr->flags1 & RF1_QUESTOR)
1190 if (r_ptr->flags7 & RF7_GUARDIAN)
1193 /* Depth Monsters never appear out of depth */
1194 if ((r_ptr->flags1 & (RF1_FORCE_DEPTH)) &&
1195 (r_ptr->level > current_floor_ptr->dun_level))
1199 /* Accept this monster */
1200 entry->prob2 = entry->prob1;
1202 if (current_floor_ptr->dun_level && (!p_ptr->inside_quest || is_fixed_quest_idx(p_ptr->inside_quest)) && !restrict_monster_to_dungeon(entry->index) && !p_ptr->inside_battle)
1204 int hoge = entry->prob2 * d_info[p_ptr->dungeon_idx].special_div;
1205 entry->prob2 = hoge / 64;
1206 if (randint0(64) < (hoge & 0x3f)) entry->prob2++;
1216 * @brief 生成モンスター種族を1種生成テーブルから選択する
1218 * @return 選択されたモンスター生成種族
1220 * Choose a monster race that seems "appropriate" to the given level
1222 * This function uses the "prob2" field of the "monster allocation table",
1223 * and various local information, to calculate the "prob3" field of the
1224 * same table, which is then used to choose an "appropriate" monster, in
1225 * a relatively efficient manner.
1227 * Note that "town" monsters will *only* be created in the town, and
1228 * "normal" monsters will *never* be created in the town, unless the
1229 * "level" is "modified", for example, by polymorph or summoning.
1231 * There is a small chance (1/50) of "boosting" the given depth by
1232 * a small amount (up to four levels), except in the town.
1234 * It is (slightly) more likely to acquire a monster of the given level
1235 * than one of a lower level. This is done by choosing several monsters
1236 * appropriate to the given level and keeping the "hardest" one.
1238 * Note that if no monsters are "appropriate", then this function will
1239 * fail, and return zero, but this should *almost* never happen.
1241 MONRACE_IDX get_mon_num(DEPTH level)
1246 monster_race *r_ptr;
1247 alloc_entry *table = alloc_race_table;
1249 int pls_kakuritu, pls_level;
1250 int delay = mysqrt(level * 10000L) + 400L;
1252 pls_kakuritu = MAX(NASTY_MON_MAX, NASTY_MON_BASE - ((current_world_ptr->dungeon_turn / (TURNS_PER_TICK * 5000L) - delay / 10)));
1253 pls_level = MIN(NASTY_MON_PLUS_MAX, 3 + current_world_ptr->dungeon_turn / (TURNS_PER_TICK * 40000L) - delay / 40 + MIN(5, level / 10)) ;
1255 if (d_info[p_ptr->dungeon_idx].flags1 & DF1_MAZE)
1257 pls_kakuritu = MIN(pls_kakuritu / 2, pls_kakuritu - 10);
1258 if (pls_kakuritu < 2) pls_kakuritu = 2;
1263 /* Boost the level */
1264 if (!p_ptr->inside_battle && !(d_info[p_ptr->dungeon_idx].flags1 & DF1_BEGINNER))
1266 /* Nightmare mode allows more out-of depth monsters */
1267 if (ironman_nightmare && !randint0(pls_kakuritu))
1269 /* What a bizarre calculation */
1270 level = 1 + (level * MAX_DEPTH / randint1(MAX_DEPTH));
1274 /* Occasional "nasty" monster */
1275 if (!randint0(pls_kakuritu))
1277 /* Pick a level bonus */
1283 if (level > MAX_DEPTH - 1) level = MAX_DEPTH - 1;
1284 if (level < 0) level = 0;
1289 /* Process probabilities */
1290 for (i = 0; i < alloc_race_size; i++)
1292 /* Monsters are sorted by depth */
1293 if (table[i].level > level) break;
1298 /* Access the "r_idx" of the chosen monster */
1299 r_idx = table[i].index;
1301 /* Access the actual race */
1302 r_ptr = &r_info[r_idx];
1304 if (!p_ptr->inside_battle && !chameleon_change_m_idx)
1306 /* Hack -- "unique" monsters must be "unique" */
1307 if (((r_ptr->flags1 & (RF1_UNIQUE)) ||
1308 (r_ptr->flags7 & (RF7_NAZGUL))) &&
1309 (r_ptr->cur_num >= r_ptr->max_num))
1314 if ((r_ptr->flags7 & (RF7_UNIQUE2)) &&
1315 (r_ptr->cur_num >= 1))
1320 if (r_idx == MON_BANORLUPART)
1322 if (r_info[MON_BANOR].cur_num > 0) continue;
1323 if (r_info[MON_LUPART].cur_num > 0) continue;
1328 table[i].prob3 = table[i].prob2;
1331 total += table[i].prob3;
1334 /* No legal monsters */
1335 if (total <= 0) return (0);
1337 /* Pick a monster */
1338 value = randint0(total);
1340 /* Find the monster */
1341 for (i = 0; i < alloc_race_size; i++)
1343 /* Found the entry */
1344 if (value < table[i].prob3) break;
1347 value = value - table[i].prob3;
1353 /* Try for a "harder" monster once (50%) or twice (10%) */
1359 /* Pick a monster */
1360 value = randint0(total);
1362 /* Find the monster */
1363 for (i = 0; i < alloc_race_size; i++)
1365 /* Found the entry */
1366 if (value < table[i].prob3) break;
1369 value = value - table[i].prob3;
1372 /* Keep the "best" one */
1373 if (table[i].level < table[j].level) i = j;
1376 /* Try for a "harder" monster twice (10%) */
1382 /* Pick a monster */
1383 value = randint0(total);
1385 /* Find the monster */
1386 for (i = 0; i < alloc_race_size; i++)
1388 /* Found the entry */
1389 if (value < table[i].prob3) break;
1392 value = value - table[i].prob3;
1395 /* Keep the "best" one */
1396 if (table[i].level < table[j].level) i = j;
1398 return (table[i].index);
1403 * @brief モンスターの呼称を作成する / Build a string describing a monster in some way.
1404 * @param desc 記述出力先の文字列参照ポインタ
1405 * @param m_ptr モンスターの参照ポインタ
1406 * @param mode 呼称オプション
1409 * We can correctly describe monsters based on their visibility.
1410 * We can force all monsters to be treated as visible or invisible.
1411 * We can build nominatives, objectives, possessives, or reflexives.
1412 * We can selectively pronominalize hidden, visible, or all monsters.
1413 * We can use definite or indefinite descriptions for hidden monsters.
1414 * We can use definite or indefinite descriptions for visible monsters.
1416 * Pronominalization involves the gender whenever possible and allowed,
1417 * so that by cleverly requesting pronominalization / visibility, you
1418 * can get messages like "You hit someone. She screams in agony!".
1420 * Reflexives are acquired by requesting Objective plus Possessive.
1422 * If no m_ptr arg is given (?), the monster is assumed to be hidden,
1423 * unless the "Assume Visible" mode is requested.
1425 * If no r_ptr arg is given, it is extracted from m_ptr and r_info
1426 * If neither m_ptr nor r_ptr is given, the monster is assumed to
1427 * be neuter, singular, and hidden (unless "Assume Visible" is set),
1428 * in which case you may be in trouble... :-)
1430 * I am assuming that no monster name is more than 70 characters long,
1431 * so that "char desc[80];" is sufficiently large for any result.
1434 * MD_OBJECTIVE --> Objective (or Reflexive)
1435 * MD_POSSESSIVE --> Possessive (or Reflexive)
1436 * MD_INDEF_HIDDEN --> Use indefinites for hidden monsters ("something")
1437 * MD_INDEF_VISIBLE --> Use indefinites for visible monsters ("a kobold")
1438 * MD_PRON_HIDDEN --> Pronominalize hidden monsters
1439 * MD_PRON_VISIBLE --> Pronominalize visible monsters
1440 * MD_ASSUME_HIDDEN --> Assume the monster is hidden
1441 * MD_ASSUME_VISIBLE --> Assume the monster is visible
1442 * MD_TRUE_NAME --> Chameleon's true name
1443 * MD_IGNORE_HALLU --> Ignore hallucination, and penetrate shape change
1446 * 0x00 --> Full nominative name ("the kobold") or "it"
1447 * MD_INDEF_HIDDEN --> Full nominative name ("the kobold") or "something"
1448 * MD_ASSUME_VISIBLE --> Genocide resistance name ("the kobold")
1449 * MD_ASSUME_VISIBLE | MD_INDEF_VISIBLE --> Killing name ("a kobold")
1450 * MD_PRON_VISIBLE | MD_POSSESSIVE
1451 * --> Possessive, genderized if visable ("his") or "its"
1452 * MD_PRON_VISIBLE | MD_POSSESSIVE | MD_OBJECTIVE
1453 * --> Reflexive, genderized if visable ("himself") or "itself"
1455 void monster_desc(char *desc, monster_type *m_ptr, BIT_FLAGS mode)
1458 monster_race *r_ptr;
1462 GAME_TEXT silly_name[1024];
1466 r_ptr = &r_info[m_ptr->ap_r_idx];
1468 /* Mode of MD_TRUE_NAME will reveal Chameleon's true name */
1469 if (mode & MD_TRUE_NAME) name = (r_name + real_r_ptr(m_ptr)->name);
1470 else name = (r_name + r_ptr->name);
1472 /* Are we hallucinating? (Idea from Nethack...) */
1473 if (p_ptr->image && !(mode & MD_IGNORE_HALLU))
1477 if (!get_rnd_line(_("silly_j.txt", "silly.txt"), m_ptr->r_idx, silly_name))
1483 monster_race *hallu_race;
1487 hallu_race = &r_info[randint1(max_r_idx - 1)];
1489 while (!hallu_race->name || (hallu_race->flags1 & RF1_UNIQUE));
1491 strcpy(silly_name, (r_name + hallu_race->name));
1494 /* Better not strcpy it, or we could corrupt r_info... */
1498 /* Can we "see" it (exists + forced, or visible + not unforced) */
1499 seen = (m_ptr && ((mode & MD_ASSUME_VISIBLE) || (!(mode & MD_ASSUME_HIDDEN) && m_ptr->ml)));
1501 /* Sexed Pronouns (seen and allowed, or unseen and allowed) */
1502 pron = (m_ptr && ((seen && (mode & MD_PRON_VISIBLE)) || (!seen && (mode & MD_PRON_HIDDEN))));
1505 /* First, try using pronouns, or describing hidden monsters */
1508 /* an encoding of the monster "sex" */
1511 /* Extract the gender (if applicable) */
1512 if (r_ptr->flags1 & (RF1_FEMALE)) kind = 0x20;
1513 else if (r_ptr->flags1 & (RF1_MALE)) kind = 0x10;
1515 /* Ignore the gender (if desired) */
1516 if (!m_ptr || !pron) kind = 0x00;
1519 /* Assume simple result */
1520 res = _("何か", "it");
1522 /* Brute force: split on the possibilities */
1523 switch (kind + (mode & (MD_INDEF_HIDDEN | MD_POSSESSIVE | MD_OBJECTIVE)))
1525 /* Neuter, or unknown */
1527 case 0x00: res = "何か"; break;
1528 case 0x00 + (MD_OBJECTIVE): res = "何か"; break;
1529 case 0x00 + (MD_POSSESSIVE): res = "何かの"; break;
1530 case 0x00 + (MD_POSSESSIVE | MD_OBJECTIVE): res = "何か自身"; break;
1531 case 0x00 + (MD_INDEF_HIDDEN): res = "何か"; break;
1532 case 0x00 + (MD_INDEF_HIDDEN | MD_OBJECTIVE): res = "何か"; break;
1533 case 0x00 + (MD_INDEF_HIDDEN | MD_POSSESSIVE): res = "何か"; break;
1534 case 0x00 + (MD_INDEF_HIDDEN | MD_POSSESSIVE | MD_OBJECTIVE): res = "それ自身"; break;
1536 case 0x00: res = "it"; break;
1537 case 0x00 + (MD_OBJECTIVE): res = "it"; break;
1538 case 0x00 + (MD_POSSESSIVE): res = "its"; break;
1539 case 0x00 + (MD_POSSESSIVE | MD_OBJECTIVE): res = "itself"; break;
1540 case 0x00 + (MD_INDEF_HIDDEN): res = "something"; break;
1541 case 0x00 + (MD_INDEF_HIDDEN | MD_OBJECTIVE): res = "something"; break;
1542 case 0x00 + (MD_INDEF_HIDDEN | MD_POSSESSIVE): res = "something's"; break;
1543 case 0x00 + (MD_INDEF_HIDDEN | MD_POSSESSIVE | MD_OBJECTIVE): res = "itself"; break;
1547 /* Male (assume human if vague) */
1549 case 0x10: res = "彼"; break;
1550 case 0x10 + (MD_OBJECTIVE): res = "彼"; break;
1551 case 0x10 + (MD_POSSESSIVE): res = "彼の"; break;
1552 case 0x10 + (MD_POSSESSIVE | MD_OBJECTIVE): res = "彼自身"; break;
1553 case 0x10 + (MD_INDEF_HIDDEN): res = "誰か"; break;
1554 case 0x10 + (MD_INDEF_HIDDEN | MD_OBJECTIVE): res = "誰か"; break;
1555 case 0x10 + (MD_INDEF_HIDDEN | MD_POSSESSIVE): res = "誰かの"; break;
1556 case 0x10 + (MD_INDEF_HIDDEN | MD_POSSESSIVE | MD_OBJECTIVE): res = "彼自身"; break;
1558 case 0x10: res = "he"; break;
1559 case 0x10 + (MD_OBJECTIVE): res = "him"; break;
1560 case 0x10 + (MD_POSSESSIVE): res = "his"; break;
1561 case 0x10 + (MD_POSSESSIVE | MD_OBJECTIVE): res = "himself"; break;
1562 case 0x10 + (MD_INDEF_HIDDEN): res = "someone"; break;
1563 case 0x10 + (MD_INDEF_HIDDEN | MD_OBJECTIVE): res = "someone"; break;
1564 case 0x10 + (MD_INDEF_HIDDEN | MD_POSSESSIVE): res = "someone's"; break;
1565 case 0x10 + (MD_INDEF_HIDDEN | MD_POSSESSIVE | MD_OBJECTIVE): res = "himself"; break;
1569 /* Female (assume human if vague) */
1571 case 0x20: res = "彼女"; break;
1572 case 0x20 + (MD_OBJECTIVE): res = "彼女"; break;
1573 case 0x20 + (MD_POSSESSIVE): res = "彼女の"; break;
1574 case 0x20 + (MD_POSSESSIVE | MD_OBJECTIVE): res = "彼女自身"; break;
1575 case 0x20 + (MD_INDEF_HIDDEN): res = "誰か"; break;
1576 case 0x20 + (MD_INDEF_HIDDEN | MD_OBJECTIVE): res = "誰か"; break;
1577 case 0x20 + (MD_INDEF_HIDDEN | MD_POSSESSIVE): res = "誰かの"; break;
1578 case 0x20 + (MD_INDEF_HIDDEN | MD_POSSESSIVE | MD_OBJECTIVE): res = "彼女自身"; break;
1580 case 0x20: res = "she"; break;
1581 case 0x20 + (MD_OBJECTIVE): res = "her"; break;
1582 case 0x20 + (MD_POSSESSIVE): res = "her"; break;
1583 case 0x20 + (MD_POSSESSIVE | MD_OBJECTIVE): res = "herself"; break;
1584 case 0x20 + (MD_INDEF_HIDDEN): res = "someone"; break;
1585 case 0x20 + (MD_INDEF_HIDDEN | MD_OBJECTIVE): res = "someone"; break;
1586 case 0x20 + (MD_INDEF_HIDDEN | MD_POSSESSIVE): res = "someone's"; break;
1587 case 0x20 + (MD_INDEF_HIDDEN | MD_POSSESSIVE | MD_OBJECTIVE): res = "herself"; break;
1591 /* Copy the result */
1592 (void)strcpy(desc, res);
1596 /* Handle visible monsters, "reflexive" request */
1597 else if ((mode & (MD_POSSESSIVE | MD_OBJECTIVE)) == (MD_POSSESSIVE | MD_OBJECTIVE))
1599 /* The monster is visible, so use its gender */
1601 if (r_ptr->flags1 & (RF1_FEMALE)) strcpy(desc, "彼女自身");
1602 else if (r_ptr->flags1 & (RF1_MALE)) strcpy(desc, "彼自身");
1603 else strcpy(desc, "それ自身");
1605 if (r_ptr->flags1 & RF1_FEMALE) strcpy(desc, "herself");
1606 else if (r_ptr->flags1 & RF1_MALE) strcpy(desc, "himself");
1607 else strcpy(desc, "itself");
1612 /* Handle all other visible monster requests */
1616 if (is_pet(m_ptr) && !is_original_ap(m_ptr))
1622 while(strncmp(t, "』", 2) && *t) t++;
1626 (void)sprintf(desc, "%s?』", buf);
1629 (void)sprintf(desc, "%s?", name);
1631 (void)sprintf(desc, "%s?", name);
1636 /* It could be a Unique */
1637 if ((r_ptr->flags1 & RF1_UNIQUE) && !(p_ptr->image && !(mode & MD_IGNORE_HALLU)))
1639 /* Start with the name (thus nominative and objective) */
1640 if ((m_ptr->mflag2 & MFLAG2_CHAMELEON) && !(mode & MD_TRUE_NAME))
1646 while (strncmp(t, "』", 2) && *t) t++;
1650 (void)sprintf(desc, "%s?』", buf);
1653 (void)sprintf(desc, "%s?", name);
1655 (void)sprintf(desc, "%s?", name);
1659 /* Inside monster arena, and it is not your mount */
1660 else if (p_ptr->inside_battle &&
1661 !(p_ptr->riding && (¤t_floor_ptr->m_list[p_ptr->riding] == m_ptr)))
1663 /* It is a fake unique monster */
1664 (void)sprintf(desc, _("%sもどき", "fake %s"), name);
1669 (void)strcpy(desc, name);
1673 /* It could be an indefinite monster */
1674 else if (mode & MD_INDEF_VISIBLE)
1676 /* XXX Check plurality for "some" */
1678 /* Indefinite monsters need an indefinite article */
1680 (void)strcpy(desc, "");
1682 (void)strcpy(desc, is_a_vowel(name[0]) ? "an " : "a ");
1685 (void)strcat(desc, name);
1688 /* It could be a normal, definite, monster */
1691 /* Definite monsters need a definite article */
1693 (void)strcpy(desc, _("あなたの", "your "));
1695 (void)strcpy(desc, _("", "the "));
1697 (void)strcat(desc, name);
1700 if (m_ptr->nickname)
1702 sprintf(buf,_("「%s」", " called %s"),quark_str(m_ptr->nickname));
1706 if (p_ptr->riding && (¤t_floor_ptr->m_list[p_ptr->riding] == m_ptr))
1708 strcat(desc,_("(乗馬中)", "(riding)"));
1711 if ((mode & MD_IGNORE_HALLU) && (m_ptr->mflag2 & MFLAG2_CHAMELEON))
1713 if (r_ptr->flags1 & RF1_UNIQUE)
1715 strcat(desc,_("(カメレオンの王)", "(Chameleon Lord)"));
1719 strcat(desc,_("(カメレオン)", "(Chameleon)"));
1723 if ((mode & MD_IGNORE_HALLU) && !is_original_ap(m_ptr))
1725 strcat(desc, format("(%s)", r_name + r_info[m_ptr->r_idx].name));
1728 /* Handle the Possessive as a special afterthought */
1729 if (mode & MD_POSSESSIVE)
1731 /* XXX Check for trailing "s" */
1733 /* Simply append "apostrophe" and "s" */
1734 (void)strcat(desc, _("の", "'s"));
1742 * @brief モンスターの調査による思い出補完処理 / Learn about a monster (by "probing" it)
1743 * @param r_idx 補完されるモンスター種族ID
1744 * @return 明らかになった情報の度数
1746 * Return the number of new flags learnt. -Mogami-
1748 int lore_do_probe(MONRACE_IDX r_idx)
1750 monster_race *r_ptr = &r_info[r_idx];
1754 /* Maximal info about awareness */
1755 if (r_ptr->r_wake != MAX_UCHAR) n++;
1756 if (r_ptr->r_ignore != MAX_UCHAR) n++;
1757 r_ptr->r_wake = r_ptr->r_ignore = MAX_UCHAR;
1759 /* Observe "maximal" attacks */
1760 for (i = 0; i < 4; i++)
1762 /* Examine "actual" blows */
1763 if (r_ptr->blow[i].effect || r_ptr->blow[i].method)
1765 /* Maximal observations */
1766 if (r_ptr->r_blows[i] != MAX_UCHAR) n++;
1767 r_ptr->r_blows[i] = MAX_UCHAR;
1773 (((r_ptr->flags1 & RF1_DROP_4D2) ? 8 : 0) +
1774 ((r_ptr->flags1 & RF1_DROP_3D2) ? 6 : 0) +
1775 ((r_ptr->flags1 & RF1_DROP_2D2) ? 4 : 0) +
1776 ((r_ptr->flags1 & RF1_DROP_1D2) ? 2 : 0) +
1777 ((r_ptr->flags1 & RF1_DROP_90) ? 1 : 0) +
1778 ((r_ptr->flags1 & RF1_DROP_60) ? 1 : 0));
1780 /* Only "valid" drops */
1781 if (!(r_ptr->flags1 & RF1_ONLY_GOLD))
1783 if (r_ptr->r_drop_item != tmp_byte) n++;
1784 r_ptr->r_drop_item = tmp_byte;
1786 if (!(r_ptr->flags1 & RF1_ONLY_ITEM))
1788 if (r_ptr->r_drop_gold != tmp_byte) n++;
1789 r_ptr->r_drop_gold = tmp_byte;
1792 /* Observe many spells */
1793 if (r_ptr->r_cast_spell != MAX_UCHAR) n++;
1794 r_ptr->r_cast_spell = MAX_UCHAR;
1796 /* Count unknown flags */
1797 for (i = 0; i < 32; i++)
1799 if (!(r_ptr->r_flags1 & (1L << i)) &&
1800 (r_ptr->flags1 & (1L << i))) n++;
1801 if (!(r_ptr->r_flags2 & (1L << i)) &&
1802 (r_ptr->flags2 & (1L << i))) n++;
1803 if (!(r_ptr->r_flags3 & (1L << i)) &&
1804 (r_ptr->flags3 & (1L << i))) n++;
1805 if (!(r_ptr->r_flags4 & (1L << i)) &&
1806 (r_ptr->flags4 & (1L << i))) n++;
1807 if (!(r_ptr->r_flags5 & (1L << i)) &&
1808 (r_ptr->a_ability_flags1 & (1L << i))) n++;
1809 if (!(r_ptr->r_flags6 & (1L << i)) &&
1810 (r_ptr->a_ability_flags2 & (1L << i))) n++;
1811 if (!(r_ptr->r_flagsr & (1L << i)) &&
1812 (r_ptr->flagsr & (1L << i))) n++;
1814 /* r_flags7 is actually unused */
1816 if (!(r_ptr->r_flags7 & (1L << i)) &&
1817 (r_ptr->flags7 & (1L << i))) n++;
1821 /* Know all the flags */
1822 r_ptr->r_flags1 = r_ptr->flags1;
1823 r_ptr->r_flags2 = r_ptr->flags2;
1824 r_ptr->r_flags3 = r_ptr->flags3;
1825 r_ptr->r_flags4 = r_ptr->flags4;
1826 r_ptr->r_flags5 = r_ptr->a_ability_flags1;
1827 r_ptr->r_flags6 = r_ptr->a_ability_flags2;
1828 r_ptr->r_flagsr = r_ptr->flagsr;
1830 /* r_flags7 is actually unused */
1831 /* r_ptr->r_flags7 = r_ptr->flags7; */
1833 /* Know about evolution */
1834 if (!(r_ptr->r_xtra1 & MR1_SINKA)) n++;
1835 r_ptr->r_xtra1 |= MR1_SINKA;
1837 /* Update monster recall window */
1838 if (p_ptr->monster_race_idx == r_idx)
1840 p_ptr->window |= (PW_MONSTER);
1843 /* Return the number of new flags learnt */
1849 * @brief モンスターの撃破に伴うドロップ情報の保管処理 / Take note that the given monster just dropped some treasure
1850 * @param m_idx モンスター情報のID
1851 * @param num_item 手に入れたアイテム数
1852 * @param num_gold 手に入れた財宝の単位数
1855 * Note that learning the "GOOD"/"GREAT" flags gives information
1856 * about the treasure (even when the monster is killed for the first
1857 * time, such as uniques, and the treasure has not been examined yet).
1859 * This "indirect" method is used to prevent the player from learning
1860 * exactly how much treasure a monster can drop from observing only
1861 * a single example of a drop. This method actually observes how much
1862 * gold and items are dropped, and remembers that information to be
1863 * described later by the monster recall code.
1865 void lore_treasure(MONSTER_IDX m_idx, ITEM_NUMBER num_item, ITEM_NUMBER num_gold)
1867 monster_type *m_ptr = ¤t_floor_ptr->m_list[m_idx];
1869 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1871 /* If the monster doesn't have original appearance, don't note */
1872 if (!is_original_ap(m_ptr)) return;
1874 /* Note the number of things dropped */
1875 if (num_item > r_ptr->r_drop_item) r_ptr->r_drop_item = num_item;
1876 if (num_gold > r_ptr->r_drop_gold) r_ptr->r_drop_gold = num_gold;
1878 /* Hack -- memorize the good/great flags */
1879 if (r_ptr->flags1 & (RF1_DROP_GOOD)) r_ptr->r_flags1 |= (RF1_DROP_GOOD);
1880 if (r_ptr->flags1 & (RF1_DROP_GREAT)) r_ptr->r_flags1 |= (RF1_DROP_GREAT);
1882 /* Update monster recall window */
1883 if (p_ptr->monster_race_idx == m_ptr->r_idx)
1885 p_ptr->window |= (PW_MONSTER);
1891 * @brief ELDRITCH_HORRORによるプレイヤーの精神破壊処理
1892 * @param m_ptr ELDRITCH_HORRORを引き起こしたモンスターの参照ポインタ
1893 * @param necro 暗黒領域魔法の詠唱失敗によるものならばTRUEを返す
1896 void sanity_blast(monster_type *m_ptr, bool necro)
1900 if (p_ptr->inside_battle || !character_dungeon) return;
1902 if (!necro && m_ptr)
1904 GAME_TEXT m_name[MAX_NLEN];
1905 monster_race *r_ptr = &r_info[m_ptr->ap_r_idx];
1907 power = r_ptr->level / 2;
1909 monster_desc(m_name, m_ptr, 0);
1911 if (!(r_ptr->flags1 & RF1_UNIQUE))
1913 if (r_ptr->flags1 & RF1_FRIENDS)
1918 if (!is_loading_now)
1919 return; /* No effect yet, just loaded... */
1922 return; /* Cannot see it for some reason */
1924 if (!(r_ptr->flags2 & RF2_ELDRITCH_HORROR))
1928 return; /* Pet eldritch horrors are safe most of the time */
1930 if (randint1(100) > power) return;
1932 if (saving_throw(p_ptr->skill_sav - power))
1934 return; /* Save, no adverse effects */
1939 /* Something silly happens... */
1940 msg_format(_("%s%sの顔を見てしまった!", "You behold the %s visage of %s!"),
1941 funny_desc[randint0(MAX_SAN_FUNNY)], m_name);
1945 msg_print(funny_comments[randint0(MAX_SAN_COMMENT)]);
1946 p_ptr->image = p_ptr->image + randint1(r_ptr->level);
1949 return; /* Never mind; we can't see it clearly enough */
1952 /* Something frightening happens... */
1953 msg_format(_("%s%sの顔を見てしまった!", "You behold the %s visage of %s!"),
1954 horror_desc[randint0(MAX_SAN_HORROR)], m_name);
1956 r_ptr->r_flags2 |= RF2_ELDRITCH_HORROR;
1958 /* Demon characters are unaffected */
1959 if (prace_is_(RACE_IMP) || prace_is_(RACE_DEMON) || (mimic_info[p_ptr->mimic_form].MIMIC_FLAGS & MIMIC_IS_DEMON)) return;
1960 if (p_ptr->wizard) return;
1962 /* Undead characters are 50% likely to be unaffected */
1963 if (prace_is_(RACE_SKELETON) || prace_is_(RACE_ZOMBIE)
1964 || prace_is_(RACE_VAMPIRE) || prace_is_(RACE_SPECTRE) ||
1965 (mimic_info[p_ptr->mimic_form].MIMIC_FLAGS & MIMIC_IS_UNDEAD))
1967 if (saving_throw(25 + p_ptr->lev)) return;
1972 monster_race *r_ptr;
1973 GAME_TEXT m_name[MAX_NLEN];
1976 get_mon_num_prep(get_nightmare, NULL);
1978 r_ptr = &r_info[get_mon_num(MAX_DEPTH)];
1979 power = r_ptr->level + 10;
1980 desc = r_name + r_ptr->name;
1982 get_mon_num_prep(NULL, NULL);
1985 if (!(r_ptr->flags1 & RF1_UNIQUE))
1986 sprintf(m_name, "%s %s", (is_a_vowel(desc[0]) ? "an" : "a"), desc);
1989 sprintf(m_name, "%s", desc);
1991 if (!(r_ptr->flags1 & RF1_UNIQUE))
1993 if (r_ptr->flags1 & RF1_FRIENDS) power /= 2;
1997 if (saving_throw(p_ptr->skill_sav * 100 / power))
1999 msg_format(_("夢の中で%sに追いかけられた。", "%^s chases you through your dreams."), m_name);
2006 /* Something silly happens... */
2007 msg_format(_("%s%sの顔を見てしまった!", "You behold the %s visage of %s!"),
2008 funny_desc[randint0(MAX_SAN_FUNNY)], m_name);
2012 msg_print(funny_comments[randint0(MAX_SAN_COMMENT)]);
2013 p_ptr->image = p_ptr->image + randint1(r_ptr->level);
2016 /* Never mind; we can't see it clearly enough */
2020 /* Something frightening happens... */
2021 msg_format(_("%s%sの顔を見てしまった!", "You behold the %s visage of %s!"),
2022 horror_desc[randint0(MAX_SAN_HORROR)], desc);
2024 r_ptr->r_flags2 |= RF2_ELDRITCH_HORROR;
2026 if (!p_ptr->mimic_form)
2028 switch (p_ptr->prace)
2030 /* Demons may make a saving throw */
2033 if (saving_throw(20 + p_ptr->lev)) return;
2035 /* Undead may make a saving throw */
2040 if (saving_throw(10 + p_ptr->lev)) return;
2046 /* Demons may make a saving throw */
2047 if (mimic_info[p_ptr->mimic_form].MIMIC_FLAGS & MIMIC_IS_DEMON)
2049 if (saving_throw(20 + p_ptr->lev)) return;
2051 /* Undead may make a saving throw */
2052 else if (mimic_info[p_ptr->mimic_form].MIMIC_FLAGS & MIMIC_IS_UNDEAD)
2054 if (saving_throw(10 + p_ptr->lev)) return;
2060 msg_print(_("ネクロノミコンを読んで正気を失った!", "Your sanity is shaken by reading the Necronomicon!"));
2063 if (saving_throw(p_ptr->skill_sav - power))
2069 (void)do_dec_stat(A_INT);
2070 } while (randint0(100) > p_ptr->skill_sav && one_in_(2));
2073 (void)do_dec_stat(A_WIS);
2074 } while (randint0(100) > p_ptr->skill_sav && one_in_(2));
2076 switch (randint1(21))
2079 if (!(p_ptr->muta3 & MUT3_MORONIC) && one_in_(5))
2081 if ((p_ptr->stat_use[A_INT] < 4) && (p_ptr->stat_use[A_WIS] < 4))
2083 msg_print(_("あなたは完璧な馬鹿になったような気がした。しかしそれは元々だった。", "You current_world_ptr->game_turn into an utter moron!"));
2087 msg_print(_("あなたは完璧な馬鹿になった!", "You current_world_ptr->game_turn into an utter moron!"));
2090 if (p_ptr->muta3 & MUT3_HYPER_INT)
2092 msg_print(_("あなたの脳は生体コンピュータではなくなった。", "Your brain is no longer a living computer."));
2093 p_ptr->muta3 &= ~(MUT3_HYPER_INT);
2095 p_ptr->muta3 |= MUT3_MORONIC;
2101 if (!(p_ptr->muta2 & MUT2_COWARDICE) && !p_ptr->resist_fear)
2103 msg_print(_("あなたはパラノイアになった!", "You become paranoid!"));
2105 /* Duh, the following should never happen, but anyway... */
2106 if (p_ptr->muta3 & MUT3_FEARLESS)
2108 msg_print(_("あなたはもう恐れ知らずではなくなった。", "You are no longer fearless."));
2109 p_ptr->muta3 &= ~(MUT3_FEARLESS);
2112 p_ptr->muta2 |= MUT2_COWARDICE;
2118 if (!(p_ptr->muta2 & MUT2_HALLU) && !p_ptr->resist_chaos)
2120 msg_print(_("幻覚をひき起こす精神錯乱に陥った!", "You are afflicted by a hallucinatory insanity!"));
2121 p_ptr->muta2 |= MUT2_HALLU;
2127 if (!(p_ptr->muta2 & MUT2_BERS_RAGE))
2129 msg_print(_("激烈な感情の発作におそわれるようになった!", "You become subject to fits of berserk rage!"));
2130 p_ptr->muta2 |= MUT2_BERS_RAGE;
2140 if (!p_ptr->resist_conf)
2142 (void)set_confused(p_ptr->confused + randint0(4) + 4);
2144 if (!p_ptr->free_act)
2146 (void)set_paralyzed(p_ptr->paralyzed + randint0(4) + 4);
2148 if (!p_ptr->resist_chaos)
2150 (void)set_image(p_ptr->image + randint0(250) + 150);
2159 if (lose_all_info())
2160 msg_print(_("あまりの恐怖に全てのことを忘れてしまった!", "You forget everything in your utmost terror!"));
2164 p_ptr->update |= PU_BONUS;
2169 * @brief モンスターの各情報を更新する / This function updates the monster record of the given monster
2170 * @param m_idx 更新するモンスター情報のID
2171 * @param full プレイヤーとの距離更新を行うならばtrue
2174 * This involves extracting the distance to the player (if requested),
2175 * and then checking for visibility (natural, infravision, see-invis,
2176 * telepathy), updating the monster visibility flag, redrawing (or
2177 * erasing) the monster when its visibility changes, and taking note
2178 * of any interesting monster flags (cold-blooded, invisible, etc).
2180 * Note the new "mflag" field which encodes several monster state flags,
2181 * including "view" for when the monster is currently in line of sight,
2182 * and "mark" for when the monster is currently visible via detection.
2184 * The only monster fields that are changed here are "cdis" (the
2185 * distance from the player), "ml" (visible to the player), and
2186 * "mflag" (to maintain the "MFLAG_VIEW" flag).
2188 * Note the special "update_monsters()" function which can be used to
2189 * call this function once for every monster.
2191 * Note the "full" flag which requests that the "cdis" field be updated,
2192 * this is only needed when the monster (or the player) has moved.
2194 * Every time a monster moves, we must call this function for that
2195 * monster, and update the distance, and the visibility. Every time
2196 * the player moves, we must call this function for every monster, and
2197 * update the distance, and the visibility. Whenever the player "state"
2198 * changes in certain ways ("blindness", "infravision", "telepathy",
2199 * and "see invisible"), we must call this function for every monster,
2200 * and update the visibility.
2202 * Routines that change the "illumination" of a grid must also call this
2203 * function for any monster in that grid, since the "visibility" of some
2204 * monsters may be based on the illumination of their grid.
2206 * Note that this function is called once per monster every time the
2207 * player moves. When the player is running, this function is one
2208 * of the primary bottlenecks, along with "update_view()" and the
2209 * "process_monsters()" code, so efficiency is important.
2211 * Note the optimized "inline" version of the "distance()" function.
2213 * A monster is "visible" to the player if (1) it has been detected
2214 * by the player, (2) it is close to the player and the player has
2215 * telepathy, or (3) it is close to the player, and in line of sight
2216 * of the player, and it is "illuminated" by some combination of
2217 * infravision, torch light, or permanent light (invisible monsters
2218 * are only affected by "light" if the player can see invisible).
2220 * Monsters which are not on the current panel may be "visible" to
2221 * the player, and their descriptions will include an "offscreen"
2222 * reference. Currently, offscreen monsters cannot be targetted
2223 * or viewed directly, but old targets will remain set. XXX XXX
2225 * The player can choose to be disturbed by several things, including
2226 * "disturb_move" (monster which is viewable moves in some way), and
2227 * "disturb_near" (monster which is "easily" viewable moves in some
2228 * way). Note that "moves" includes "appears" and "disappears".
2230 void update_monster(MONSTER_IDX m_idx, bool full)
2232 monster_type *m_ptr = ¤t_floor_ptr->m_list[m_idx];
2234 monster_race *r_ptr = &r_info[m_ptr->r_idx];
2236 bool do_disturb = disturb_move;
2240 /* Current location */
2247 /* Seen by vision */
2250 /* Non-Ninja player in the darkness */
2251 bool in_darkness = (d_info[p_ptr->dungeon_idx].flags1 & DF1_DARKNESS) && !p_ptr->see_nocto;
2256 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
2258 if (ap_r_ptr->r_tkills && ap_r_ptr->level >= p_ptr->lev)
2262 /* Compute distance */
2265 /* Distance components */
2266 int dy = (p_ptr->y > fy) ? (p_ptr->y - fy) : (fy - p_ptr->y);
2267 int dx = (p_ptr->x > fx) ? (p_ptr->x - fx) : (fx - p_ptr->x);
2269 /* Approximate distance */
2270 d = (dy > dx) ? (dy + (dx>>1)) : (dx + (dy>>1));
2272 /* Restrict distance */
2273 if (d > 255) d = 255;
2277 /* Save the distance */
2281 /* Extract distance */
2284 /* Extract the distance */
2290 if (m_ptr->mflag2 & (MFLAG2_MARK)) flag = TRUE;
2294 if (d <= (in_darkness ? MAX_SIGHT / 2 : MAX_SIGHT))
2296 if (!in_darkness || (d <= MAX_SIGHT / 4))
2298 if (p_ptr->special_defense & KATA_MUSOU)
2303 if (is_original_ap(m_ptr) && !p_ptr->image)
2305 /* Hack -- Memorize mental flags */
2306 if (r_ptr->flags2 & (RF2_SMART)) r_ptr->r_flags2 |= (RF2_SMART);
2307 if (r_ptr->flags2 & (RF2_STUPID)) r_ptr->r_flags2 |= (RF2_STUPID);
2311 /* Basic telepathy */
2312 /* Snipers get telepathy when they concentrate deeper */
2313 else if (p_ptr->telepathy)
2315 /* Empty mind, no telepathy */
2316 if (r_ptr->flags2 & (RF2_EMPTY_MIND))
2318 /* Memorize flags */
2319 if (is_original_ap(m_ptr) && !p_ptr->image) r_ptr->r_flags2 |= (RF2_EMPTY_MIND);
2322 /* Weird mind, occasional telepathy */
2323 else if (r_ptr->flags2 & (RF2_WEIRD_MIND))
2325 /* One in ten individuals are detectable */
2326 if ((m_idx % 10) == 5)
2331 if (is_original_ap(m_ptr) && !p_ptr->image)
2333 /* Memorize flags */
2334 r_ptr->r_flags2 |= (RF2_WEIRD_MIND);
2336 /* Hack -- Memorize mental flags */
2337 if (r_ptr->flags2 & (RF2_SMART)) r_ptr->r_flags2 |= (RF2_SMART);
2338 if (r_ptr->flags2 & (RF2_STUPID)) r_ptr->r_flags2 |= (RF2_STUPID);
2343 /* Normal mind, allow telepathy */
2349 if (is_original_ap(m_ptr) && !p_ptr->image)
2351 /* Hack -- Memorize mental flags */
2352 if (r_ptr->flags2 & (RF2_SMART)) r_ptr->r_flags2 |= (RF2_SMART);
2353 if (r_ptr->flags2 & (RF2_STUPID)) r_ptr->r_flags2 |= (RF2_STUPID);
2358 /* Magical sensing */
2359 if ((p_ptr->esp_animal) && (r_ptr->flags3 & (RF3_ANIMAL)))
2362 if (is_original_ap(m_ptr) && !p_ptr->image) r_ptr->r_flags3 |= (RF3_ANIMAL);
2365 /* Magical sensing */
2366 if ((p_ptr->esp_undead) && (r_ptr->flags3 & (RF3_UNDEAD)))
2369 if (is_original_ap(m_ptr) && !p_ptr->image) r_ptr->r_flags3 |= (RF3_UNDEAD);
2372 /* Magical sensing */
2373 if ((p_ptr->esp_demon) && (r_ptr->flags3 & (RF3_DEMON)))
2376 if (is_original_ap(m_ptr) && !p_ptr->image) r_ptr->r_flags3 |= (RF3_DEMON);
2379 /* Magical sensing */
2380 if ((p_ptr->esp_orc) && (r_ptr->flags3 & (RF3_ORC)))
2383 if (is_original_ap(m_ptr) && !p_ptr->image) r_ptr->r_flags3 |= (RF3_ORC);
2386 /* Magical sensing */
2387 if ((p_ptr->esp_troll) && (r_ptr->flags3 & (RF3_TROLL)))
2390 if (is_original_ap(m_ptr) && !p_ptr->image) r_ptr->r_flags3 |= (RF3_TROLL);
2393 /* Magical sensing */
2394 if ((p_ptr->esp_giant) && (r_ptr->flags3 & (RF3_GIANT)))
2397 if (is_original_ap(m_ptr) && !p_ptr->image) r_ptr->r_flags3 |= (RF3_GIANT);
2400 /* Magical sensing */
2401 if ((p_ptr->esp_dragon) && (r_ptr->flags3 & (RF3_DRAGON)))
2404 if (is_original_ap(m_ptr) && !p_ptr->image) r_ptr->r_flags3 |= (RF3_DRAGON);
2407 /* Magical sensing */
2408 if ((p_ptr->esp_human) && (r_ptr->flags2 & (RF2_HUMAN)))
2411 if (is_original_ap(m_ptr) && !p_ptr->image) r_ptr->r_flags2 |= (RF2_HUMAN);
2414 /* Magical sensing */
2415 if ((p_ptr->esp_evil) && (r_ptr->flags3 & (RF3_EVIL)))
2418 if (is_original_ap(m_ptr) && !p_ptr->image) r_ptr->r_flags3 |= (RF3_EVIL);
2421 /* Magical sensing */
2422 if ((p_ptr->esp_good) && (r_ptr->flags3 & (RF3_GOOD)))
2425 if (is_original_ap(m_ptr) && !p_ptr->image) r_ptr->r_flags3 |= (RF3_GOOD);
2428 /* Magical sensing */
2429 if ((p_ptr->esp_nonliving) &&
2430 ((r_ptr->flags3 & (RF3_DEMON | RF3_UNDEAD | RF3_NONLIVING)) == RF3_NONLIVING))
2433 if (is_original_ap(m_ptr) && !p_ptr->image) r_ptr->r_flags3 |= (RF3_NONLIVING);
2436 /* Magical sensing */
2437 if ((p_ptr->esp_unique) && (r_ptr->flags1 & (RF1_UNIQUE)))
2440 if (is_original_ap(m_ptr) && !p_ptr->image) r_ptr->r_flags1 |= (RF1_UNIQUE);
2444 /* Normal line of sight, and not blind */
2445 if (player_has_los_bold(fy, fx) && !p_ptr->blind)
2447 bool do_invisible = FALSE;
2448 bool do_cold_blood = FALSE;
2450 /* Snipers can see targets in darkness when they concentrate deeper */
2451 if (p_ptr->concent >= CONCENT_RADAR_THRESHOLD)
2457 /* Use "infravision" */
2458 if (d <= p_ptr->see_infra)
2460 /* Handle "cold blooded" monsters */
2461 if ((r_ptr->flags2 & (RF2_COLD_BLOOD | RF2_AURA_FIRE)) == RF2_COLD_BLOOD)
2463 do_cold_blood = TRUE;
2466 /* Handle "warm blooded" monsters */
2474 /* Use "illumination" */
2475 if (player_can_see_bold(fy, fx))
2477 /* Handle "invisible" monsters */
2478 if (r_ptr->flags2 & (RF2_INVISIBLE))
2480 do_invisible = TRUE;
2490 /* Handle "normal" monsters */
2501 if (is_original_ap(m_ptr) && !p_ptr->image)
2503 /* Memorize flags */
2504 if (do_invisible) r_ptr->r_flags2 |= (RF2_INVISIBLE);
2505 if (do_cold_blood) r_ptr->r_flags2 |= (RF2_COLD_BLOOD);
2512 /* The monster is now visible */
2515 /* It was previously unseen */
2518 /* Mark as visible */
2521 /* Draw the monster */
2524 /* Update health bar as needed */
2525 if (p_ptr->health_who == m_idx) p_ptr->redraw |= (PR_HEALTH);
2526 if (p_ptr->riding == m_idx) p_ptr->redraw |= (PR_UHEALTH);
2528 /* Hack -- Count "fresh" sightings */
2531 if ((m_ptr->ap_r_idx == MON_KAGE) && (r_info[MON_KAGE].r_sights < MAX_SHORT))
2532 r_info[MON_KAGE].r_sights++;
2533 else if (is_original_ap(m_ptr) && (r_ptr->r_sights < MAX_SHORT))
2537 /* Eldritch Horror */
2538 if (r_info[m_ptr->ap_r_idx].flags2 & RF2_ELDRITCH_HORROR)
2540 sanity_blast(m_ptr, FALSE);
2543 /* Disturb on appearance */
2544 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)))
2546 if (disturb_pets || is_hostile(m_ptr))
2547 disturb(TRUE, TRUE);
2552 /* The monster is not visible */
2555 /* It was previously seen */
2558 /* Mark as not visible */
2561 /* Erase the monster */
2564 /* Update health bar as needed */
2565 if (p_ptr->health_who == m_idx) p_ptr->redraw |= (PR_HEALTH);
2566 if (p_ptr->riding == m_idx) p_ptr->redraw |= (PR_UHEALTH);
2568 /* Disturb on disappearance */
2571 if (disturb_pets || is_hostile(m_ptr))
2572 disturb(TRUE, TRUE);
2578 /* The monster is now easily visible */
2582 if (!(m_ptr->mflag & (MFLAG_VIEW)))
2584 /* Mark as easily visible */
2585 m_ptr->mflag |= (MFLAG_VIEW);
2587 /* Disturb on appearance */
2590 if (disturb_pets || is_hostile(m_ptr))
2591 disturb(TRUE, TRUE);
2596 /* The monster is not easily visible */
2600 if (m_ptr->mflag & (MFLAG_VIEW))
2602 /* Mark as not easily visible */
2603 m_ptr->mflag &= ~(MFLAG_VIEW);
2605 /* Disturb on disappearance */
2608 if (disturb_pets || is_hostile(m_ptr))
2609 disturb(TRUE, TRUE);
2617 * @brief 単純に生存している全モンスターの更新処理を行う / This function simply updates all the (non-dead) monsters (see above).
2618 * @param full 距離更新を行うならtrue
2621 void update_monsters(bool full)
2625 /* Update each (live) monster */
2626 for (i = 1; i < m_max; i++)
2628 monster_type *m_ptr = ¤t_floor_ptr->m_list[i];
2630 /* Skip dead monsters */
2631 if (!m_ptr->r_idx) continue;
2632 update_monster(i, full);
2638 * @brief カメレオンの王の変身対象となるモンスターかどうか判定する / Hack -- the index of the summoning monster
2639 * @param r_idx モンスター種族ID
2640 * @return 対象にできるならtrueを返す
2642 static bool monster_hook_chameleon_lord(MONRACE_IDX r_idx)
2644 monster_race *r_ptr = &r_info[r_idx];
2645 monster_type *m_ptr = ¤t_floor_ptr->m_list[chameleon_change_m_idx];
2646 monster_race *old_r_ptr = &r_info[m_ptr->r_idx];
2648 if (!(r_ptr->flags1 & (RF1_UNIQUE))) return FALSE;
2649 if (r_ptr->flags7 & (RF7_FRIENDLY | RF7_CHAMELEON)) return FALSE;
2651 if (ABS(r_ptr->level - r_info[MON_CHAMELEON_K].level) > 5) return FALSE;
2653 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))
2656 if (!monster_can_cross_terrain(current_floor_ptr->grid_array[m_ptr->fy][m_ptr->fx].feat, r_ptr, 0)) return FALSE;
2659 if (!(old_r_ptr->flags7 & RF7_CHAMELEON))
2661 if (monster_has_hostile_align(m_ptr, 0, 0, r_ptr)) return FALSE;
2665 else if (summon_specific_who > 0)
2667 if (monster_has_hostile_align(¤t_floor_ptr->m_list[summon_specific_who], 0, 0, r_ptr)) return FALSE;
2674 * @brief カメレオンの変身対象となるモンスターかどうか判定する / Hack -- the index of the summoning monster
2675 * @param r_idx モンスター種族ID
2676 * @return 対象にできるならtrueを返す
2678 static bool monster_hook_chameleon(MONRACE_IDX r_idx)
2680 monster_race *r_ptr = &r_info[r_idx];
2681 monster_type *m_ptr = ¤t_floor_ptr->m_list[chameleon_change_m_idx];
2682 monster_race *old_r_ptr = &r_info[m_ptr->r_idx];
2684 if (r_ptr->flags1 & (RF1_UNIQUE)) return FALSE;
2685 if (r_ptr->flags2 & RF2_MULTIPLY) return FALSE;
2686 if (r_ptr->flags7 & (RF7_FRIENDLY | RF7_CHAMELEON)) return FALSE;
2688 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))
2691 if (!monster_can_cross_terrain(current_floor_ptr->grid_array[m_ptr->fy][m_ptr->fx].feat, r_ptr, 0)) return FALSE;
2694 if (!(old_r_ptr->flags7 & RF7_CHAMELEON))
2696 if ((old_r_ptr->flags3 & RF3_GOOD) && !(r_ptr->flags3 & RF3_GOOD)) return FALSE;
2697 if ((old_r_ptr->flags3 & RF3_EVIL) && !(r_ptr->flags3 & RF3_EVIL)) return FALSE;
2698 if (!(old_r_ptr->flags3 & (RF3_GOOD | RF3_EVIL)) && (r_ptr->flags3 & (RF3_GOOD | RF3_EVIL))) return FALSE;
2702 else if (summon_specific_who > 0)
2704 if (monster_has_hostile_align(¤t_floor_ptr->m_list[summon_specific_who], 0, 0, r_ptr)) return FALSE;
2707 return (*(get_monster_hook()))(r_idx);
2712 * @param m_idx 変身処理を受けるモンスター情報のID
2713 * @param born 生成時の初変身先指定ならばtrue
2714 * @param r_idx 旧モンスター種族のID
2717 void choose_new_monster(MONSTER_IDX m_idx, bool born, MONRACE_IDX r_idx)
2720 monster_type *m_ptr = ¤t_floor_ptr->m_list[m_idx];
2721 monster_race *r_ptr;
2722 char old_m_name[MAX_NLEN];
2723 bool old_unique = FALSE;
2724 int old_r_idx = m_ptr->r_idx;
2726 if (r_info[m_ptr->r_idx].flags1 & RF1_UNIQUE)
2728 if (old_unique && (r_idx == MON_CHAMELEON)) r_idx = MON_CHAMELEON_K;
2729 r_ptr = &r_info[r_idx];
2731 monster_desc(old_m_name, m_ptr, 0);
2737 chameleon_change_m_idx = m_idx;
2739 get_mon_num_prep(monster_hook_chameleon_lord, NULL);
2741 get_mon_num_prep(monster_hook_chameleon, NULL);
2744 level = r_info[MON_CHAMELEON_K].level;
2745 else if (!current_floor_ptr->dun_level)
2746 level = wilderness[p_ptr->wilderness_y][p_ptr->wilderness_x].level;
2748 level = current_floor_ptr->dun_level;
2750 if (d_info[p_ptr->dungeon_idx].flags1 & DF1_CHAMELEON) level+= 2+randint1(3);
2752 r_idx = get_mon_num(level);
2753 r_ptr = &r_info[r_idx];
2755 chameleon_change_m_idx = 0;
2761 if (is_pet(m_ptr)) check_pets_num_and_align(m_ptr, FALSE);
2763 m_ptr->r_idx = r_idx;
2764 m_ptr->ap_r_idx = r_idx;
2765 update_monster(m_idx, FALSE);
2766 lite_spot(m_ptr->fy, m_ptr->fx);
2768 if ((r_info[old_r_idx].flags7 & (RF7_LITE_MASK | RF7_DARK_MASK)) ||
2769 (r_ptr->flags7 & (RF7_LITE_MASK | RF7_DARK_MASK)))
2770 p_ptr->update |= (PU_MON_LITE);
2772 if (is_pet(m_ptr)) check_pets_num_and_align(m_ptr, TRUE);
2776 /* Sub-alignment of a chameleon */
2777 if (r_ptr->flags3 & (RF3_EVIL | RF3_GOOD))
2779 m_ptr->sub_align = SUB_ALIGN_NEUTRAL;
2780 if (r_ptr->flags3 & RF3_EVIL) m_ptr->sub_align |= SUB_ALIGN_EVIL;
2781 if (r_ptr->flags3 & RF3_GOOD) m_ptr->sub_align |= SUB_ALIGN_GOOD;
2786 if (m_idx == p_ptr->riding)
2788 GAME_TEXT m_name[MAX_NLEN];
2789 monster_desc(m_name, m_ptr, 0);
2790 msg_format(_("突然%sが変身した。", "Suddenly, %s transforms!"), old_m_name);
2791 if (!(r_ptr->flags7 & RF7_RIDING))
2792 if (rakuba(0, TRUE)) msg_format(_("地面に落とされた。", "You have fallen from %s."), m_name);
2795 /* Extract the monster base speed */
2796 m_ptr->mspeed = get_mspeed(r_ptr);
2798 oldmaxhp = m_ptr->max_maxhp;
2799 /* Assign maximal hitpoints */
2800 if (r_ptr->flags1 & RF1_FORCE_MAXHP)
2802 m_ptr->max_maxhp = maxroll(r_ptr->hdice, r_ptr->hside);
2806 m_ptr->max_maxhp = damroll(r_ptr->hdice, r_ptr->hside);
2809 /* Monsters have double hitpoints in Nightmare mode */
2810 if (ironman_nightmare)
2812 u32b hp = m_ptr->max_maxhp * 2L;
2813 m_ptr->max_maxhp = (HIT_POINT)MIN(30000, hp);
2816 m_ptr->maxhp = (long)(m_ptr->maxhp * m_ptr->max_maxhp) / oldmaxhp;
2817 if (m_ptr->maxhp < 1) m_ptr->maxhp = 1;
2818 m_ptr->hp = (long)(m_ptr->hp * m_ptr->max_maxhp) / oldmaxhp;
2820 /* reset dealt_damage */
2821 m_ptr->dealt_damage = 0;
2826 * @brief たぬきの変身対象となるモンスターかどうか判定する / Hook for Tanuki
2827 * @param r_idx モンスター種族ID
2828 * @return 対象にできるならtrueを返す
2830 static bool monster_hook_tanuki(MONRACE_IDX r_idx)
2832 monster_race *r_ptr = &r_info[r_idx];
2834 if (r_ptr->flags1 & (RF1_UNIQUE)) return FALSE;
2835 if (r_ptr->flags2 & RF2_MULTIPLY) return FALSE;
2836 if (r_ptr->flags7 & (RF7_FRIENDLY | RF7_CHAMELEON)) return FALSE;
2837 if (r_ptr->flags7 & RF7_AQUATIC) return FALSE;
2839 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))
2842 return (*(get_monster_hook()))(r_idx);
2847 * @brief モンスターの表層IDを設定する / Set initial racial appearance of a monster
2848 * @param r_idx モンスター種族ID
2849 * @return モンスター種族の表層ID
2851 static IDX initial_r_appearance(MONRACE_IDX r_idx)
2853 int attempts = 1000;
2855 DEPTH min = MIN(current_floor_ptr->base_level-5, 50);
2857 if (p_ptr->pseikaku == SEIKAKU_CHARGEMAN)
2859 if (current_floor_ptr->base_level == 0 || one_in_(5)) return MON_ALIEN_JURAL;
2862 if (!(r_info[r_idx].flags7 & RF7_TANUKI))
2865 get_mon_num_prep(monster_hook_tanuki, NULL);
2869 ap_r_idx = get_mon_num(current_floor_ptr->base_level + 10);
2870 if (r_info[ap_r_idx].level >= min) return ap_r_idx;
2878 * @brief モンスターの個体加速を設定する / Get initial monster speed
2879 * @param r_ptr モンスター種族の参照ポインタ
2882 byte get_mspeed(monster_race *r_ptr)
2884 /* Extract the monster base speed */
2885 int mspeed = r_ptr->speed;
2887 /* Hack -- small racial variety */
2888 if (!(r_ptr->flags1 & RF1_UNIQUE) && !p_ptr->inside_arena)
2890 /* Allow some small variation per monster */
2891 int i = SPEED_TO_ENERGY(r_ptr->speed) / (one_in_(4) ? 3 : 10);
2892 if (i) mspeed += rand_spread(0, i);
2895 if (mspeed > 199) mspeed = 199;
2897 return (byte)mspeed;
2902 * @brief モンスターを一体生成する / Attempt to place a monster of the given race at the given location.
2903 * @param who 召喚を行ったモンスターID
2906 * @param r_idx 生成モンスター種族
2907 * @param mode 生成オプション
2910 * To give the player a sporting chance, any monster that appears in
2911 * line-of-sight and is extremely dangerous can be marked as
2912 * "FORCE_SLEEP", which will cause them to be placed with low energy,
2913 * which often (but not always) lets the player move before they do.
2915 * This routine refuses to place out-of-depth "FORCE_DEPTH" monsters.
2917 * Use special "here" and "dead" flags for unique monsters,
2918 * remove old "cur_num" and "max_num" fields.
2920 * Actually, do something similar for artifacts, to simplify
2921 * the "preserve" mode, and to make the "what artifacts" flag more useful.
2923 * This is the only function which may place a monster in the dungeon,
2924 * except for the savefile loading code.
2926 static bool place_monster_one(MONSTER_IDX who, POSITION y, POSITION x, MONRACE_IDX r_idx, BIT_FLAGS mode)
2928 /* Access the location */
2929 grid_type *g_ptr = ¤t_floor_ptr->grid_array[y][x];
2930 monster_type *m_ptr;
2931 monster_race *r_ptr = &r_info[r_idx];
2932 concptr name = (r_name + r_ptr->name);
2936 /* DO NOT PLACE A MONSTER IN THE SMALL SCALE WILDERNESS !!! */
2937 if (p_ptr->wild_mode) return FALSE;
2939 /* Verify location */
2940 if (!in_bounds(y, x)) return (FALSE);
2943 if (!r_idx) return (FALSE);
2946 if (!r_ptr->name) return (FALSE);
2948 if (!(mode & PM_IGNORE_TERRAIN))
2950 /* Not on the Pattern */
2951 if (pattern_tile(y, x)) return FALSE;
2953 /* Require empty space (if not ghostly) */
2954 if (!monster_can_enter(y, x, r_ptr, 0)) return FALSE;
2957 if (!p_ptr->inside_battle)
2959 /* Hack -- "unique" monsters must be "unique" */
2960 if (((r_ptr->flags1 & (RF1_UNIQUE)) ||
2961 (r_ptr->flags7 & (RF7_NAZGUL))) &&
2962 (r_ptr->cur_num >= r_ptr->max_num))
2968 if ((r_ptr->flags7 & (RF7_UNIQUE2)) &&
2969 (r_ptr->cur_num >= 1))
2974 if (r_idx == MON_BANORLUPART)
2976 if (r_info[MON_BANOR].cur_num > 0) return FALSE;
2977 if (r_info[MON_LUPART].cur_num > 0) return FALSE;
2980 /* Depth monsters may NOT be created out of depth, unless in Nightmare mode */
2981 if ((r_ptr->flags1 & (RF1_FORCE_DEPTH)) && (current_floor_ptr->dun_level < r_ptr->level) &&
2982 (!ironman_nightmare || (r_ptr->flags1 & (RF1_QUESTOR))))
2989 if (quest_number(current_floor_ptr->dun_level))
2991 int hoge = quest_number(current_floor_ptr->dun_level);
2992 if ((quest[hoge].type == QUEST_TYPE_KILL_LEVEL) || (quest[hoge].type == QUEST_TYPE_RANDOM))
2994 if(r_idx == quest[hoge].r_idx)
2996 int number_mon, i2, j2;
2999 /* Count all quest monsters */
3000 for (i2 = 0; i2 < current_floor_ptr->width; ++i2)
3001 for (j2 = 0; j2 < current_floor_ptr->height; j2++)
3002 if (current_floor_ptr->grid_array[j2][i2].m_idx > 0)
3003 if (current_floor_ptr->m_list[current_floor_ptr->grid_array[j2][i2].m_idx].r_idx == quest[hoge].r_idx)
3005 if(number_mon + quest[hoge].cur_num >= quest[hoge].max_num)
3011 if (is_glyph_grid(g_ptr))
3013 if (randint1(BREAK_GLYPH) < (r_ptr->level+20))
3015 /* Describe observable breakage */
3016 if (g_ptr->info & CAVE_MARK)
3018 msg_print(_("守りのルーンが壊れた!", "The rune of protection is broken!"));
3021 /* Forget the rune */
3022 g_ptr->info &= ~(CAVE_MARK);
3024 /* Break the rune */
3025 g_ptr->info &= ~(CAVE_OBJECT);
3033 msg_format_wizard(CHEAT_MONSTER, _("%s(Lv%d)を生成しました。", "%s(Lv%d) was generated."), name, r_ptr->level);
3035 if ((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags7 & RF7_NAZGUL) || (r_ptr->level < 10)) mode &= ~PM_KAGE;
3037 /* Make a new monster */
3038 g_ptr->m_idx = m_pop();
3039 hack_m_idx_ii = g_ptr->m_idx;
3041 /* Mega-Hack -- catch "failure" */
3042 if (!g_ptr->m_idx) return (FALSE);
3045 /* Get a new monster record */
3046 m_ptr = ¤t_floor_ptr->m_list[g_ptr->m_idx];
3049 m_ptr->r_idx = r_idx;
3050 m_ptr->ap_r_idx = initial_r_appearance(r_idx);
3056 /* Hack -- Appearance transfer */
3057 if ((mode & PM_MULTIPLY) && (who > 0) && !is_original_ap(¤t_floor_ptr->m_list[who]))
3059 m_ptr->ap_r_idx = current_floor_ptr->m_list[who].ap_r_idx;
3061 /* Hack -- Shadower spawns Shadower */
3062 if (current_floor_ptr->m_list[who].mflag2 & MFLAG2_KAGE) m_ptr->mflag2 |= MFLAG2_KAGE;
3065 /* Sub-alignment of a monster */
3066 if ((who > 0) && !(r_ptr->flags3 & (RF3_EVIL | RF3_GOOD)))
3067 m_ptr->sub_align = current_floor_ptr->m_list[who].sub_align;
3070 m_ptr->sub_align = SUB_ALIGN_NEUTRAL;
3071 if (r_ptr->flags3 & RF3_EVIL) m_ptr->sub_align |= SUB_ALIGN_EVIL;
3072 if (r_ptr->flags3 & RF3_GOOD) m_ptr->sub_align |= SUB_ALIGN_GOOD;
3075 /* Place the monster at the location */
3080 /* No "timed status" yet */
3081 for (cmi = 0; cmi < MAX_MTIMED; cmi++) m_ptr->mtimed[cmi] = 0;
3083 /* Unknown distance */
3086 reset_target(m_ptr);
3088 m_ptr->nickname = 0;
3093 /* Your pet summons its pet. */
3094 if (who > 0 && is_pet(¤t_floor_ptr->m_list[who]))
3096 mode |= PM_FORCE_PET;
3097 m_ptr->parent_m_idx = who;
3101 m_ptr->parent_m_idx = 0;
3104 if (r_ptr->flags7 & RF7_CHAMELEON)
3106 choose_new_monster(g_ptr->m_idx, TRUE, 0);
3107 r_ptr = &r_info[m_ptr->r_idx];
3108 m_ptr->mflag2 |= MFLAG2_CHAMELEON;
3110 /* Hack - Set sub_align to neutral when the Chameleon Lord is generated as "GUARDIAN" */
3111 if ((r_ptr->flags1 & RF1_UNIQUE) && (who <= 0))
3112 m_ptr->sub_align = SUB_ALIGN_NEUTRAL;
3114 else if ((mode & PM_KAGE) && !(mode & PM_FORCE_PET))
3116 m_ptr->ap_r_idx = MON_KAGE;
3117 m_ptr->mflag2 |= MFLAG2_KAGE;
3120 if (mode & PM_NO_PET) m_ptr->mflag2 |= MFLAG2_NOPET;
3126 if (mode & PM_FORCE_PET)
3131 else if ((r_ptr->flags7 & RF7_FRIENDLY) ||
3132 (mode & PM_FORCE_FRIENDLY) || is_friendly_idx(who))
3134 if (!monster_has_hostile_align(NULL, 0, -1, r_ptr)) set_friendly(m_ptr);
3137 /* Assume no sleeping */
3138 m_ptr->mtimed[MTIMED_CSLEEP] = 0;
3140 /* Enforce sleeping if needed */
3141 if ((mode & PM_ALLOW_SLEEP) && r_ptr->sleep && !ironman_nightmare)
3143 int val = r_ptr->sleep;
3144 (void)set_monster_csleep(g_ptr->m_idx, (val * 2) + randint1(val * 10));
3147 /* Assign maximal hitpoints */
3148 if (r_ptr->flags1 & RF1_FORCE_MAXHP)
3150 m_ptr->max_maxhp = maxroll(r_ptr->hdice, r_ptr->hside);
3154 m_ptr->max_maxhp = damroll(r_ptr->hdice, r_ptr->hside);
3157 /* Monsters have double hitpoints in Nightmare mode */
3158 if (ironman_nightmare)
3160 u32b hp = m_ptr->max_maxhp * 2L;
3162 m_ptr->max_maxhp = (HIT_POINT)MIN(30000, hp);
3165 m_ptr->maxhp = m_ptr->max_maxhp;
3167 /* And start out fully healthy */
3168 if (m_ptr->r_idx == MON_WOUNDED_BEAR)
3169 m_ptr->hp = m_ptr->maxhp / 2;
3170 else m_ptr->hp = m_ptr->maxhp;
3173 /* dealt damage is 0 at initial*/
3174 m_ptr->dealt_damage = 0;
3177 /* Extract the monster base speed */
3178 m_ptr->mspeed = get_mspeed(r_ptr);
3180 if (mode & PM_HASTE) (void)set_monster_fast(g_ptr->m_idx, 100);
3182 /* Give a random starting energy */
3183 if (!ironman_nightmare)
3185 m_ptr->energy_need = ENERGY_NEED() - (s16b)randint0(100);
3189 /* Nightmare monsters are more prepared */
3190 m_ptr->energy_need = ENERGY_NEED() - (s16b)randint0(100) * 2;
3193 /* Force monster to wait for player, unless in Nightmare mode */
3194 if ((r_ptr->flags1 & RF1_FORCE_SLEEP) && !ironman_nightmare)
3196 /* Monster is still being nice */
3197 m_ptr->mflag |= (MFLAG_NICE);
3199 /* Must repair monsters */
3200 repair_monsters = TRUE;
3203 /* Hack -- see "process_monsters()" */
3204 if (g_ptr->m_idx < hack_m_idx)
3206 /* Monster is still being born */
3207 m_ptr->mflag |= (MFLAG_BORN);
3211 if (r_ptr->flags7 & RF7_SELF_LD_MASK)
3212 p_ptr->update |= (PU_MON_LITE);
3213 else if ((r_ptr->flags7 & RF7_HAS_LD_MASK) && !MON_CSLEEP(m_ptr))
3214 p_ptr->update |= (PU_MON_LITE);
3215 update_monster(g_ptr->m_idx, TRUE);
3218 /* Count the monsters on the level */
3219 real_r_ptr(m_ptr)->cur_num++;
3222 * Memorize location of the unique monster in saved floors.
3223 * A unique monster move from old saved floor.
3225 if (character_dungeon &&
3226 ((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags7 & RF7_NAZGUL)))
3227 real_r_ptr(m_ptr)->floor_id = p_ptr->floor_id;
3229 /* Hack -- Count the number of "reproducers" */
3230 if (r_ptr->flags2 & RF2_MULTIPLY) current_floor_ptr->num_repro++;
3232 /* Hack -- Notice new multi-hued monsters */
3234 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
3235 if (ap_r_ptr->flags1 & (RF1_ATTR_MULTI | RF1_SHAPECHANGER))
3236 shimmer_monsters = TRUE;
3239 if (p_ptr->warning && character_dungeon)
3241 if (r_ptr->flags1 & RF1_UNIQUE)
3245 GAME_TEXT o_name[MAX_NLEN];
3247 if (r_ptr->level > p_ptr->lev + 30)
3248 color = _("黒く", "black");
3249 else if (r_ptr->level > p_ptr->lev + 15)
3250 color = _("紫色に", "purple");
3251 else if (r_ptr->level > p_ptr->lev + 5)
3252 color = _("ルビー色に", "deep red");
3253 else if (r_ptr->level > p_ptr->lev - 5)
3254 color = _("赤く", "red");
3255 else if (r_ptr->level > p_ptr->lev - 15)
3256 color = _("ピンク色に", "pink");
3258 color = _("白く", "white");
3260 o_ptr = choose_warning_item();
3263 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
3264 msg_format(_("%sは%s光った。", "%s glows %s."), o_name, color);
3268 msg_format(_("%s光る物が頭に浮かんだ。", "An %s image forms in your mind."), color);
3273 if (is_explosive_rune_grid(g_ptr))
3275 /* Break the ward */
3276 if (randint1(BREAK_MINOR_GLYPH) > r_ptr->level)
3278 /* Describe observable breakage */
3279 if (g_ptr->info & CAVE_MARK)
3281 msg_print(_("ルーンが爆発した!", "The rune explodes!"));
3282 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);
3287 msg_print(_("爆発のルーンは解除された。", "An explosive rune was disarmed."));
3290 /* Forget the rune */
3291 g_ptr->info &= ~(CAVE_MARK);
3293 /* Break the rune */
3294 g_ptr->info &= ~(CAVE_OBJECT);
3307 #define MON_SCAT_MAXD 10 /*!< mon_scatter()関数によるモンスター配置で許される中心からの最大距離 */
3310 * @brief モンスター1体を目標地点に可能な限り近い位置に生成する / improved version of scatter() for place monster
3311 * @param r_idx 生成モンスター種族
3312 * @param yp 結果生成位置y座標
3313 * @param xp 結果生成位置x座標
3314 * @param y 中心生成位置y座標
3315 * @param x 中心生成位置x座標
3316 * @param max_dist 生成位置の最大半径
3320 static bool mon_scatter(MONRACE_IDX r_idx, POSITION *yp, POSITION *xp, POSITION y, POSITION x, POSITION max_dist)
3322 POSITION place_x[MON_SCAT_MAXD];
3323 POSITION place_y[MON_SCAT_MAXD];
3324 int num[MON_SCAT_MAXD];
3328 if (max_dist >= MON_SCAT_MAXD)
3331 for (i = 0; i < MON_SCAT_MAXD; i++)
3334 for (nx = x - max_dist; nx <= x + max_dist; nx++)
3336 for (ny = y - max_dist; ny <= y + max_dist; ny++)
3338 /* Ignore annoying locations */
3339 if (!in_bounds(ny, nx)) continue;
3341 /* Require "line of projection" */
3342 if (!projectable(y, x, ny, nx)) continue;
3346 monster_race *r_ptr = &r_info[r_idx];
3348 /* Require empty space (if not ghostly) */
3349 if (!monster_can_enter(ny, nx, r_ptr, 0))
3354 /* Walls and Monsters block flow */
3355 if (!cave_empty_bold2(ny, nx)) continue;
3357 /* ... nor on the Pattern */
3358 if (pattern_tile(ny, nx)) continue;
3361 i = distance(y, x, ny, nx);
3369 if (one_in_(num[i]))
3378 while (i < MON_SCAT_MAXD && 0 == num[i])
3380 if (i >= MON_SCAT_MAXD)
3390 * @brief モンスターを目標地点に集団生成する / Attempt to place a "group" of monsters around the given location
3391 * @param who 召喚主のモンスター情報ID
3392 * @param y 中心生成位置y座標
3393 * @param x 中心生成位置x座標
3394 * @param r_idx 生成モンスター種族
3395 * @param mode 生成オプション
3398 static bool place_monster_group(MONSTER_IDX who, POSITION y, POSITION x, MONRACE_IDX r_idx, BIT_FLAGS mode)
3400 monster_race *r_ptr = &r_info[r_idx];
3403 int total = 0, extra = 0;
3407 POSITION hack_y[GROUP_MAX];
3408 POSITION hack_x[GROUP_MAX];
3411 /* Pick a group size */
3412 total = randint1(10);
3414 /* Hard monsters, small groups */
3415 if (r_ptr->level > current_floor_ptr->dun_level)
3417 extra = r_ptr->level - current_floor_ptr->dun_level;
3418 extra = 0 - randint1(extra);
3421 /* Easy monsters, large groups */
3422 else if (r_ptr->level < current_floor_ptr->dun_level)
3424 extra = current_floor_ptr->dun_level - r_ptr->level;
3425 extra = randint1(extra);
3428 /* Hack -- limit group reduction */
3429 if (extra > 9) extra = 9;
3431 /* Modify the group size */
3435 if (total < 1) total = 1;
3438 if (total > GROUP_MAX) total = GROUP_MAX;
3441 /* Start on the monster */
3446 /* Puddle monsters, breadth first, up to total */
3447 for (n = 0; (n < hack_n) && (hack_n < total); n++)
3449 /* Grab the location */
3450 POSITION hx = hack_x[n];
3451 POSITION hy = hack_y[n];
3453 /* Check each direction, up to total */
3454 for (i = 0; (i < 8) && (hack_n < total); i++)
3458 scatter(&my, &mx, hy, hx, 4, 0);
3460 /* Walls and Monsters block flow */
3461 if (!cave_empty_bold2(my, mx)) continue;
3463 /* Attempt to place another monster */
3464 if (place_monster_one(who, my, mx, r_idx, mode))
3466 /* Add it to the "hack" set */
3467 hack_y[hack_n] = my;
3468 hack_x[hack_n] = mx;
3480 * @var place_monster_idx
3481 * @brief 護衛対象となるモンスター種族IDを渡すグローバル変数 / Hack -- help pick an escort type
3482 * @todo 関数ポインタの都合を配慮しながら、グローバル変数place_monster_idxを除去し、関数引数化する
3484 static MONSTER_IDX place_monster_idx = 0;
3487 * @var place_monster_m_idx
3488 * @brief 護衛対象となるモンスターIDを渡すグローバル変数 / Hack -- help pick an escort type
3489 * @todo 関数ポインタの都合を配慮しながら、グローバル変数place_monster_m_idxを除去し、関数引数化する
3491 static MONSTER_IDX place_monster_m_idx = 0;
3494 * @brief モンスター種族が召喚主の護衛となれるかどうかをチェックする / Hack -- help pick an escort type
3495 * @param r_idx チェックするモンスター種族のID
3496 * @return 護衛にできるならばtrue
3498 static bool place_monster_can_escort(MONRACE_IDX r_idx)
3500 monster_race *r_ptr = &r_info[place_monster_idx];
3501 monster_type *m_ptr = ¤t_floor_ptr->m_list[place_monster_m_idx];
3503 monster_race *z_ptr = &r_info[r_idx];
3505 /* Hack - Escorts have to have the same dungeon flag */
3506 if (mon_hook_dungeon(place_monster_idx) != mon_hook_dungeon(r_idx)) return (FALSE);
3508 /* Require similar "race" */
3509 if (z_ptr->d_char != r_ptr->d_char) return (FALSE);
3511 /* Skip more advanced monsters */
3512 if (z_ptr->level > r_ptr->level) return (FALSE);
3514 /* Skip unique monsters */
3515 if (z_ptr->flags1 & RF1_UNIQUE) return (FALSE);
3517 /* Paranoia -- Skip identical monsters */
3518 if (place_monster_idx == r_idx) return (FALSE);
3520 /* Skip different alignment */
3521 if (monster_has_hostile_align(m_ptr, 0, 0, z_ptr)) return FALSE;
3523 if (r_ptr->flags7 & RF7_FRIENDLY)
3525 if (monster_has_hostile_align(NULL, 1, -1, z_ptr)) return FALSE;
3528 if ((r_ptr->flags7 & RF7_CHAMELEON) && !(z_ptr->flags7 & RF7_CHAMELEON))
3536 * @brief 一般的なモンスター生成処理のサブルーチン / Attempt to place a monster of the given race at the given location
3537 * @param who 召喚主のモンスター情報ID
3540 * @param r_idx 生成するモンスターの種族ID
3541 * @param mode 生成オプション
3542 * @return 生成に成功したらtrue
3544 * Note that certain monsters are now marked as requiring "friends".
3545 * These monsters, if successfully placed, and if the "grp" parameter
3546 * is TRUE, will be surrounded by a "group" of identical monsters.
3548 * Note that certain monsters are now marked as requiring an "escort",
3549 * which is a collection of monsters with similar "race" but lower level.
3551 * Some monsters induce a fake "group" flag on their escorts.
3553 * Note the "bizarre" use of non-recursion to prevent annoying output
3554 * when running a code profiler.
3556 * Note the use of the new "monster allocation table" code to restrict
3557 * the "get_mon_num()" function to "legal" escort types.
3559 bool place_monster_aux(MONSTER_IDX who, POSITION y, POSITION x, MONRACE_IDX r_idx, BIT_FLAGS mode)
3562 monster_race *r_ptr = &r_info[r_idx];
3564 if (!(mode & PM_NO_KAGE) && one_in_(333))
3567 /* Place one monster, or fail */
3568 if (!place_monster_one(who, y, x, r_idx, mode)) return (FALSE);
3570 /* Require the "group" flag */
3571 if (!(mode & PM_ALLOW_GROUP)) return (TRUE);
3573 place_monster_m_idx = hack_m_idx_ii;
3576 for(i = 0; i < 6; i++)
3578 if(!r_ptr->reinforce_id[i]) break;
3579 n = damroll(r_ptr->reinforce_dd[i], r_ptr->reinforce_ds[i]);
3580 for(j = 0; j < n; j++)
3582 POSITION nx, ny, d = 7;
3583 scatter(&ny, &nx, y, x, d, 0);
3584 (void)place_monster_one(place_monster_m_idx, ny, nx, r_ptr->reinforce_id[i], mode);
3588 /* Friends for certain monsters */
3589 if (r_ptr->flags1 & (RF1_FRIENDS))
3591 /* Attempt to place a group */
3592 (void)place_monster_group(who, y, x, r_idx, mode);
3595 /* Escorts for certain monsters */
3596 if (r_ptr->flags1 & (RF1_ESCORT))
3598 /* Set the escort index */
3599 place_monster_idx = r_idx;
3601 /* Try to place several "escorts" */
3602 for (i = 0; i < 32; i++)
3604 POSITION nx, ny, d = 3;
3607 /* Pick a location */
3608 scatter(&ny, &nx, y, x, d, 0);
3610 /* Require empty grids */
3611 if (!cave_empty_bold2(ny, nx)) continue;
3612 get_mon_num_prep(place_monster_can_escort, get_monster_hook2(ny, nx));
3614 /* Pick a random race */
3615 z = get_mon_num(r_ptr->level);
3617 /* Handle failure */
3620 /* Place a single escort */
3621 (void)place_monster_one(place_monster_m_idx, ny, nx, z, mode);
3623 /* Place a "group" of escorts if needed */
3624 if ((r_info[z].flags1 & RF1_FRIENDS) ||
3625 (r_ptr->flags1 & RF1_ESCORTS))
3627 /* Place a group of monsters */
3628 (void)place_monster_group(place_monster_m_idx, ny, nx, z, mode);
3638 * @brief 一般的なモンスター生成処理のメインルーチン / Attempt to place a monster of the given race at the given location
3641 * @param mode 生成オプション
3642 * @return 生成に成功したらtrue
3644 bool place_monster(POSITION y, POSITION x, BIT_FLAGS mode)
3647 get_mon_num_prep(get_monster_hook(), get_monster_hook2(y, x));
3649 /* Pick a monster */
3650 r_idx = get_mon_num(current_floor_ptr->monster_level);
3652 /* Handle failure */
3653 if (!r_idx) return (FALSE);
3655 /* Attempt to place the monster */
3656 if (place_monster_aux(0, y, x, r_idx, mode)) return (TRUE);
3662 * @brief 指定地点に1種類のモンスター種族による群れを生成する
3665 * @return 生成に成功したらtrue
3667 bool alloc_horde(POSITION y, POSITION x)
3669 monster_race *r_ptr = NULL;
3670 MONRACE_IDX r_idx = 0;
3672 int attempts = 1000;
3675 get_mon_num_prep(get_monster_hook(), get_monster_hook2(y, x));
3679 /* Pick a monster */
3680 r_idx = get_mon_num(current_floor_ptr->monster_level);
3682 /* Handle failure */
3683 if (!r_idx) return (FALSE);
3685 r_ptr = &r_info[r_idx];
3687 if (r_ptr->flags1 & RF1_UNIQUE) continue;
3689 if (r_idx == MON_HAGURE) continue;
3692 if (attempts < 1) return FALSE;
3698 /* Attempt to place the monster */
3699 if (place_monster_aux(0, y, x, r_idx, 0L)) break;
3702 if (attempts < 1) return FALSE;
3704 m_idx = current_floor_ptr->grid_array[y][x].m_idx;
3706 if (current_floor_ptr->m_list[m_idx].mflag2 & MFLAG2_CHAMELEON) r_ptr = &r_info[current_floor_ptr->m_list[m_idx].r_idx];
3708 for (attempts = randint1(10) + 5; attempts; attempts--)
3710 scatter(&cy, &cx, y, x, 5, 0);
3712 (void)summon_specific(m_idx, cy, cx, current_floor_ptr->dun_level + 5, SUMMON_KIN, PM_ALLOW_GROUP, r_ptr->d_char);
3718 if (cheat_hear) msg_format(_("モンスターの大群(%c)", "Monster horde (%c)."), r_ptr->d_char);
3723 * @brief ダンジョンの主生成を試みる / Put the Guardian
3724 * @param def_val 現在の主の生成状態
3725 * @return 生成に成功したらtrue
3727 bool alloc_guardian(bool def_val)
3729 MONRACE_IDX guardian = d_info[p_ptr->dungeon_idx].final_guardian;
3731 if (guardian && (d_info[p_ptr->dungeon_idx].maxdepth == current_floor_ptr->dun_level) && (r_info[guardian].cur_num < r_info[guardian].max_num))
3735 int try_count = 4000;
3737 /* Find a good position */
3740 /* Get a random spot */
3741 oy = randint1(current_floor_ptr->height - 4) + 2;
3742 ox = randint1(current_floor_ptr->width - 4) + 2;
3744 /* Is it a good spot ? */
3745 if (cave_empty_bold2(oy, ox) && monster_can_cross_terrain(current_floor_ptr->grid_array[oy][ox].feat, &r_info[guardian], 0))
3747 /* Place the guardian */
3748 if (place_monster_aux(0, oy, ox, guardian, (PM_ALLOW_GROUP | PM_NO_KAGE | PM_NO_PET))) return TRUE;
3751 /* One less try count */
3763 * @brief ダンジョンの初期配置モンスターを生成1回生成する / Attempt to allocate a random monster in the dungeon.
3764 * @param dis プレイヤーから離れるべき最低距離
3765 * @param mode 生成オプション
3766 * @return 生成に成功したらtrue
3768 * Place the monster at least "dis" distance from the player.
3769 * Use "slp" to choose the initial "sleep" status
3770 * Use "current_floor_ptr->monster_level" for the monster level
3772 bool alloc_monster(POSITION dis, BIT_FLAGS mode)
3774 POSITION y = 0, x = 0;
3775 int attempts_left = 10000;
3777 /* Put the Guardian */
3778 if (alloc_guardian(FALSE)) return TRUE;
3780 /* Find a legal, distant, unoccupied, space */
3781 while (attempts_left--)
3783 /* Pick a location */
3784 y = randint0(current_floor_ptr->height);
3785 x = randint0(current_floor_ptr->width);
3787 /* Require empty floor grid (was "naked") */
3788 if (current_floor_ptr->dun_level)
3790 if (!cave_empty_bold2(y, x)) continue;
3794 if (!cave_empty_bold(y, x)) continue;
3797 /* Accept far away grids */
3798 if (distance(y, x, p_ptr->y, p_ptr->x) > dis) break;
3803 if (cheat_xtra || cheat_hear)
3805 msg_print(_("警告!新たなモンスターを配置できません。小さい階ですか?", "Warning! Could not allocate a new monster. Small level?"));
3812 if (randint1(5000) <= current_floor_ptr->dun_level)
3814 if (alloc_horde(y, x))
3821 /* Attempt to place the monster, allow groups */
3822 if (place_monster(y, x, (mode | PM_ALLOW_GROUP))) return (TRUE);
3830 * @brief モンスターが召喚の基本条件に合っているかをチェックする / Hack -- help decide if a monster race is "okay" to summon
3831 * @param r_idx チェックするモンスター種族ID
3832 * @return 召喚対象にできるならばTRUE
3834 static bool summon_specific_okay(MONRACE_IDX r_idx)
3836 monster_race *r_ptr = &r_info[r_idx];
3838 /* Hack - Only summon dungeon monsters */
3839 if (!mon_hook_dungeon(r_idx)) return (FALSE);
3841 /* Hack -- identify the summoning monster */
3842 if (summon_specific_who > 0)
3844 monster_type *m_ptr = ¤t_floor_ptr->m_list[summon_specific_who];
3846 /* Do not summon enemies */
3848 /* Friendly vs. opposite aligned normal or pet */
3849 if (monster_has_hostile_align(m_ptr, 0, 0, r_ptr)) return FALSE;
3851 /* Use the player's alignment */
3852 else if (summon_specific_who < 0)
3854 /* Do not summon enemies of the pets */
3855 if (monster_has_hostile_align(NULL, 10, -10, r_ptr))
3857 if (!one_in_(ABS(p_ptr->align) / 2 + 1)) return FALSE;
3861 if (!summon_unique_okay && ((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags7 & RF7_NAZGUL))) return FALSE;
3863 /* Hack -- no specific type specified */
3864 if (!summon_specific_type) return (TRUE);
3866 if ((summon_specific_who < 0) &&
3867 ((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags7 & RF7_NAZGUL)) &&
3868 monster_has_hostile_align(NULL, 10, -10, r_ptr))
3871 if ((r_ptr->flags7 & RF7_CHAMELEON) && (d_info[p_ptr->dungeon_idx].flags1 & DF1_CHAMELEON)) return TRUE;
3873 return (summon_specific_aux(r_idx));
3878 * @brief モンスターを召喚により配置する / Place a monster (of the specified "type") near the given location. Return TRUE if a monster was actually summoned.
3879 * @param who 召喚主のモンスター情報ID
3884 * @param mode 生成オプション
3885 * @return 召喚できたらtrueを返す
3888 * We will attempt to place the monster up to 10 times before giving up.
3890 * Note: SUMMON_UNIQUE and SUMMON_AMBERITES will summon Unique's
3891 * Note: SUMMON_HI_UNDEAD and SUMMON_HI_DRAGON may summon Unique's
3892 * Note: None of the other summon codes will ever summon Unique's.
3894 * This function has been changed. We now take the "monster level"
3895 * of the summoning monster as a parameter, and use that, along with
3896 * the current dungeon level, to help determine the level of the
3897 * desired monster. Note that this is an upper bound, and also
3898 * tends to "prefer" monsters of that level. Currently, we use
3899 * the average of the dungeon and monster levels, and then add
3900 * five to allow slight increases in monster power.
3902 * Note that we use the new "monster allocation table" creation code
3903 * to restrict the "get_mon_num()" function to the set of "legal"
3904 * monsters, making this function much faster and more reliable.
3906 * Note that this function may not succeed, though this is very rare.
3908 bool summon_specific(MONSTER_IDX who, POSITION y1, POSITION x1, DEPTH lev, int type, BIT_FLAGS mode, SYMBOL_CODE symbol)
3913 if (p_ptr->inside_arena) return (FALSE);
3915 if (!mon_scatter(0, &y, &x, y1, x1, 2)) return FALSE;
3917 /* Save the summoner */
3918 summon_specific_who = who;
3920 /* Save the "summon" type */
3921 summon_specific_type = type;
3923 summon_kin_type = symbol;
3925 summon_unique_okay = (mode & PM_ALLOW_UNIQUE) ? TRUE : FALSE;
3926 get_mon_num_prep(summon_specific_okay, get_monster_hook2(y, x));
3928 /* Pick a monster, using the level calculation */
3929 r_idx = get_mon_num((current_floor_ptr->dun_level + lev) / 2 + 5);
3931 /* Handle failure */
3934 summon_specific_type = 0;
3938 if ((type == SUMMON_BLUE_HORROR) || (type == SUMMON_DAWN)) mode |= PM_NO_KAGE;
3940 /* Attempt to place the monster (awake, allow groups) */
3941 if (!place_monster_aux(who, y, x, r_idx, mode))
3943 summon_specific_type = 0;
3947 summon_specific_type = 0;
3949 sound(SOUND_SUMMON);
3955 * @brief 特定モンスター種族を召喚により生成する / A "dangerous" function, creates a pet of the specified type
3956 * @param who 召喚主のモンスター情報ID
3959 * @param r_idx 生成するモンスター種族ID
3960 * @param mode 生成オプション
3961 * @return 召喚できたらtrueを返す
3963 bool summon_named_creature(MONSTER_IDX who, POSITION oy, POSITION ox, MONRACE_IDX r_idx, BIT_FLAGS mode)
3968 /* if (!r_idx) return; */
3970 /* Prevent illegal monsters */
3971 if (r_idx >= max_r_idx) return FALSE;
3973 if (p_ptr->inside_arena) return FALSE;
3975 if (!mon_scatter(r_idx, &y, &x, oy, ox, 2)) return FALSE;
3977 /* Place it (allow groups) */
3978 return place_monster_aux(who, y, x, r_idx, (mode | PM_NO_KAGE));
3983 * @brief モンスターを増殖生成する / Let the given monster attempt to reproduce.
3984 * @param m_idx 増殖するモンスター情報ID
3985 * @param clone クローン・モンスター処理ならばtrue
3986 * @param mode 生成オプション
3987 * @return 生成できたらtrueを返す
3989 * Note that "reproduction" REQUIRES empty space.
3991 bool multiply_monster(MONSTER_IDX m_idx, bool clone, BIT_FLAGS mode)
3993 monster_type *m_ptr = ¤t_floor_ptr->m_list[m_idx];
3996 if (!mon_scatter(m_ptr->r_idx, &y, &x, m_ptr->fy, m_ptr->fx, 1))
3999 if (m_ptr->mflag2 & MFLAG2_NOPET) mode |= PM_NO_PET;
4001 /* Create a new monster (awake, no groups) */
4002 if (!place_monster_aux(m_idx, y, x, m_ptr->r_idx, (mode | PM_NO_KAGE | PM_MULTIPLY)))
4005 /* Hack -- Transfer "clone" flag */
4006 if (clone || (m_ptr->smart & SM_CLONED))
4008 current_floor_ptr->m_list[hack_m_idx_ii].smart |= SM_CLONED;
4009 current_floor_ptr->m_list[hack_m_idx_ii].mflag2 |= MFLAG2_NOPET;
4018 * @brief ダメージを受けたモンスターの様子を記述する / Dump a message describing a monster's reaction to damage
4019 * @param m_idx モンスター情報ID
4020 * @param dam 与えたダメージ
4023 * Technically should attempt to treat "Beholder"'s as jelly's
4025 void message_pain(MONSTER_IDX m_idx, HIT_POINT dam)
4027 HIT_POINT oldhp, newhp;
4029 PERCENTAGE percentage;
4031 monster_type *m_ptr = ¤t_floor_ptr->m_list[m_idx];
4032 monster_race *r_ptr = &r_info[m_ptr->r_idx];
4034 GAME_TEXT m_name[MAX_NLEN];
4036 monster_desc(m_name, m_ptr, 0);
4038 if(dam == 0) // Notice non-damage
4040 msg_format(_("%^sはダメージを受けていない。", "%^s is unharmed."), m_name);
4044 /* Note -- subtle fix -CFT */
4046 oldhp = newhp + dam;
4047 tmp = (newhp * 100L) / oldhp;
4050 if(my_strchr(",ejmvwQ", r_ptr->d_char)) // Mushrooms, Eyes, Jellies, Molds, Vortices, Worms, Quylthulgs
4053 if(percentage > 95) msg_format("%^sはほとんど気にとめていない。", m_name);
4054 else if(percentage > 75) msg_format("%^sはしり込みした。", m_name);
4055 else if(percentage > 50) msg_format("%^sは縮こまった。", m_name);
4056 else if(percentage > 35) msg_format("%^sは痛みに震えた。", m_name);
4057 else if(percentage > 20) msg_format("%^sは身もだえした。", m_name);
4058 else if(percentage > 10) msg_format("%^sは苦痛で身もだえした。", m_name);
4059 else msg_format("%^sはぐにゃぐにゃと痙攣した。", m_name);
4061 if(percentage > 95) msg_format("%^s barely notices.", m_name);
4062 else if(percentage > 75) msg_format("%^s flinches.", m_name);
4063 else if(percentage > 50) msg_format("%^s squelches.", m_name);
4064 else if(percentage > 35) msg_format("%^s quivers in pain.", m_name);
4065 else if(percentage > 20) msg_format("%^s writhes about.", m_name);
4066 else if(percentage > 10) msg_format("%^s writhes in agony.", m_name);
4067 else msg_format("%^s jerks limply.", m_name);
4071 else if(my_strchr("l", r_ptr->d_char)) // Fish
4074 if(percentage > 95) msg_format("%^sはほとんど気にとめていない。", m_name);
4075 else if(percentage > 75) msg_format("%^sはしり込みした。", m_name);
4076 else if(percentage > 50) msg_format("%^sは躊躇した。", m_name);
4077 else if(percentage > 35) msg_format("%^sは痛みに震えた。", m_name);
4078 else if(percentage > 20) msg_format("%^sは身もだえした。", m_name);
4079 else if(percentage > 10) msg_format("%^sは苦痛で身もだえした。", m_name);
4080 else msg_format("%^sはぐにゃぐにゃと痙攣した。", m_name);
4082 if(percentage > 95) msg_format("%^s barely notices.", m_name);
4083 else if(percentage > 75) msg_format("%^s flinches.", m_name);
4084 else if(percentage > 50) msg_format("%^s hesitates.", m_name);
4085 else if(percentage > 35) msg_format("%^s quivers in pain.", m_name);
4086 else if(percentage > 20) msg_format("%^s writhes about.", m_name);
4087 else if(percentage > 10) msg_format("%^s writhes in agony.", m_name);
4088 else msg_format("%^s jerks limply.", m_name);
4092 else if(my_strchr("g#+<>", r_ptr->d_char)) // Golems, Walls, Doors, Stairs
4095 if(percentage > 95) msg_format("%sは攻撃を気にとめていない。", m_name);
4096 else if(percentage > 75) msg_format("%sは攻撃に肩をすくめた。", m_name);
4097 else if(percentage > 50) msg_format("%^sは雷鳴のように吠えた。", m_name);
4098 else if(percentage > 35) msg_format("%^sは苦しげに吠えた。", m_name);
4099 else if(percentage > 20) msg_format("%^sはうめいた。", m_name);
4100 else if(percentage > 10) msg_format("%^sは躊躇した。", m_name);
4101 else msg_format("%^sはくしゃくしゃになった。", m_name);
4103 if(percentage > 95) msg_format("%^s ignores the attack.", m_name);
4104 else if(percentage > 75) msg_format("%^s shrugs off the attack.", m_name);
4105 else if(percentage > 50) msg_format("%^s roars thunderously.", m_name);
4106 else if(percentage > 35) msg_format("%^s rumbles.", m_name);
4107 else if(percentage > 20) msg_format("%^s grunts.", m_name);
4108 else if(percentage > 10) msg_format("%^s hesitates.", m_name);
4109 else msg_format("%^s crumples.", m_name);
4113 else if(my_strchr("JMR", r_ptr->d_char) || !isalpha(r_ptr->d_char)) // Snakes, Hydrae, Reptiles, Mimics
4116 if(percentage > 95) msg_format("%^sはほとんど気にとめていない。", m_name);
4117 else if(percentage > 75) msg_format("%^sはシーッと鳴いた。", m_name);
4118 else if(percentage > 50) msg_format("%^sは怒って頭を上げた。", m_name);
4119 else if(percentage > 35) msg_format("%^sは猛然と威嚇した。", m_name);
4120 else if(percentage > 20) msg_format("%^sは身もだえした。", m_name);
4121 else if(percentage > 10) msg_format("%^sは苦痛で身もだえした。", m_name);
4122 else msg_format("%^sはぐにゃぐにゃと痙攣した。", m_name);
4124 if(percentage > 95) msg_format("%^s barely notices.", m_name);
4125 else if(percentage > 75) msg_format("%^s hisses.", m_name);
4126 else if(percentage > 50) msg_format("%^s rears up in anger.", m_name);
4127 else if(percentage > 35) msg_format("%^s hisses furiously.", m_name);
4128 else if(percentage > 20) msg_format("%^s writhes about.", m_name);
4129 else if(percentage > 10) msg_format("%^s writhes in agony.", m_name);
4130 else msg_format("%^s jerks limply.", m_name);
4134 else if(my_strchr("f", r_ptr->d_char))
4137 if(percentage > 95) msg_format("%sは攻撃に肩をすくめた。", m_name);
4138 else if(percentage > 75) msg_format("%^sは吠えた。", m_name);
4139 else if(percentage > 50) msg_format("%^sは怒って吠えた。", m_name);
4140 else if(percentage > 35) msg_format("%^sは痛みでシーッと鳴いた。", m_name);
4141 else if(percentage > 20) msg_format("%^sは痛みで弱々しく鳴いた。", m_name);
4142 else if(percentage > 10) msg_format("%^sは苦痛にうめいた。", m_name);
4143 else msg_format("%sは哀れな鳴き声を出した。", m_name);
4145 if(percentage > 95) msg_format("%^s shrugs off the attack.", m_name);
4146 else if(percentage > 75) msg_format("%^s roars.", m_name);
4147 else if(percentage > 50) msg_format("%^s growls angrily.", m_name);
4148 else if(percentage > 35) msg_format("%^s hisses with pain.", m_name);
4149 else if(percentage > 20) msg_format("%^s mewls in pain.", m_name);
4150 else if(percentage > 10) msg_format("%^s hisses in agony.", m_name);
4151 else msg_format("%^s mewls pitifully.", m_name);
4155 else if(my_strchr("acFIKS", r_ptr->d_char)) // Ants, Centipedes, Flies, Insects, Beetles, Spiders
4158 if(percentage > 95) msg_format("%sは攻撃を気にとめていない。", m_name);
4159 else if(percentage > 75) msg_format("%^sはキーキー鳴いた。", m_name);
4160 else if(percentage > 50) msg_format("%^sはヨロヨロ逃げ回った。", m_name);
4161 else if(percentage > 35) msg_format("%^sはうるさく鳴いた。", m_name);
4162 else if(percentage > 20) msg_format("%^sは痛みに痙攣した。", m_name);
4163 else if(percentage > 10) msg_format("%^sは苦痛で痙攣した。", m_name);
4164 else msg_format("%^sはピクピクひきつった。", m_name);
4166 if(percentage > 95) msg_format("%^s ignores the attack.", m_name);
4167 else if(percentage > 75) msg_format("%^s chitters.", m_name);
4168 else if(percentage > 50) msg_format("%^s scuttles about.", m_name);
4169 else if(percentage > 35) msg_format("%^s twitters.", m_name);
4170 else if(percentage > 20) msg_format("%^s jerks in pain.", m_name);
4171 else if(percentage > 10) msg_format("%^s jerks in agony.", m_name);
4172 else msg_format("%^s twitches.", m_name);
4176 else if(my_strchr("B", r_ptr->d_char)) // Birds
4179 if(percentage > 95) msg_format("%^sはさえずった。", m_name);
4180 else if(percentage > 75) msg_format("%^sはピーピー鳴いた。", m_name);
4181 else if(percentage > 50) msg_format("%^sはギャーギャー鳴いた。", m_name);
4182 else if(percentage > 35) msg_format("%^sはギャーギャー鳴きわめいた。", m_name);
4183 else if(percentage > 20) msg_format("%^sは苦しんだ。", m_name);
4184 else if(percentage > 10) msg_format("%^sはのたうち回った。", m_name);
4185 else msg_format("%^sはキーキーと鳴き叫んだ。", m_name);
4187 if(percentage > 95) msg_format("%^s chirps.", m_name);
4188 else if(percentage > 75) msg_format("%^s twitters.", m_name);
4189 else if(percentage > 50) msg_format("%^s squawks.", m_name);
4190 else if(percentage > 35) msg_format("%^s chatters.", m_name);
4191 else if(percentage > 20) msg_format("%^s jeers.", m_name);
4192 else if(percentage > 10) msg_format("%^s flutters about.", m_name);
4193 else msg_format("%^s squeaks.", m_name);
4197 else if(my_strchr("duDLUW", r_ptr->d_char)) // Dragons, Demons, High Undead
4200 if(percentage > 95) msg_format("%sは攻撃を気にとめていない。", m_name);
4201 else if(percentage > 75) msg_format("%^sはしり込みした。", m_name);
4202 else if(percentage > 50) msg_format("%^sは痛みでシーッと鳴いた。", m_name);
4203 else if(percentage > 35) msg_format("%^sは痛みでうなった。", m_name);
4204 else if(percentage > 20) msg_format("%^sは痛みに吠えた。", m_name);
4205 else if(percentage > 10) msg_format("%^sは苦しげに叫んだ。", m_name);
4206 else msg_format("%^sは弱々しくうなった。", m_name);
4208 if(percentage > 95) msg_format("%^s ignores the attack.", m_name);
4209 else if(percentage > 75) msg_format("%^s flinches.", m_name);
4210 else if(percentage > 50) msg_format("%^s hisses in pain.", m_name);
4211 else if(percentage > 35) msg_format("%^s snarls with pain.", m_name);
4212 else if(percentage > 20) msg_format("%^s roars with pain.", m_name);
4213 else if(percentage > 10) msg_format("%^s gasps.", m_name);
4214 else msg_format("%^s snarls feebly.", m_name);
4218 else if(my_strchr("s", r_ptr->d_char)) // Skeletons
4221 if(percentage > 95) msg_format("%sは攻撃を気にとめていない。", m_name);
4222 else if(percentage > 75) msg_format("%sは攻撃に肩をすくめた。", m_name);
4223 else if(percentage > 50) msg_format("%^sはカタカタと笑った。", m_name);
4224 else if(percentage > 35) msg_format("%^sはよろめいた。", m_name);
4225 else if(percentage > 20) msg_format("%^sはカタカタ言った。", m_name);
4226 else if(percentage > 10) msg_format("%^sはよろめいた。", m_name);
4227 else msg_format("%^sはガタガタ言った。", m_name);
4229 if(percentage > 95) msg_format("%^s ignores the attack.", m_name);
4230 else if(percentage > 75) msg_format("%^s shrugs off the attack.", m_name);
4231 else if(percentage > 50) msg_format("%^s rattles.", m_name);
4232 else if(percentage > 35) msg_format("%^s stumbles.", m_name);
4233 else if(percentage > 20) msg_format("%^s rattles.", m_name);
4234 else if(percentage > 10) msg_format("%^s staggers.", m_name);
4235 else msg_format("%^s clatters.", m_name);
4239 else if(my_strchr("z", r_ptr->d_char)) // Zombies
4242 if(percentage > 95) msg_format("%sは攻撃を気にとめていない。", m_name);
4243 else if(percentage > 75) msg_format("%sは攻撃に肩をすくめた。", m_name);
4244 else if(percentage > 50) msg_format("%^sはうめいた。", m_name);
4245 else if(percentage > 35) msg_format("%sは苦しげにうめいた。", m_name);
4246 else if(percentage > 20) msg_format("%^sは躊躇した。", m_name);
4247 else if(percentage > 10) msg_format("%^sはうなった。", m_name);
4248 else msg_format("%^sはよろめいた。", m_name);
4250 if(percentage > 95) msg_format("%^s ignores the attack.", m_name);
4251 else if(percentage > 75) msg_format("%^s shrugs off the attack.", m_name);
4252 else if(percentage > 50) msg_format("%^s groans.", m_name);
4253 else if(percentage > 35) msg_format("%^s moans.", m_name);
4254 else if(percentage > 20) msg_format("%^s hesitates.", m_name);
4255 else if(percentage > 10) msg_format("%^s grunts.", m_name);
4256 else msg_format("%^s staggers.", m_name);
4260 else if(my_strchr("G", r_ptr->d_char)) // Ghosts
4263 if(percentage > 95) msg_format("%sは攻撃を気にとめていない。", m_name);
4264 else if(percentage > 75) msg_format("%sは攻撃に肩をすくめた。", m_name);
4265 else if(percentage > 50) msg_format("%sはうめいた。", m_name);
4266 else if(percentage > 35) msg_format("%^sは泣きわめいた。", m_name);
4267 else if(percentage > 20) msg_format("%^sは吠えた。", m_name);
4268 else if(percentage > 10) msg_format("%sは弱々しくうめいた。", m_name);
4269 else msg_format("%^sはかすかにうめいた。", m_name);
4271 if(percentage > 95) msg_format("%^s ignores the attack.", m_name);
4272 else if(percentage > 75) msg_format("%^s shrugs off the attack.", m_name);
4273 else if(percentage > 50) msg_format("%^s moans.", m_name);
4274 else if(percentage > 35) msg_format("%^s wails.", m_name);
4275 else if(percentage > 20) msg_format("%^s howls.", m_name);
4276 else if(percentage > 10) msg_format("%^s moans softly.", m_name);
4277 else msg_format("%^s sighs.", m_name);
4281 else if(my_strchr("CZ", r_ptr->d_char)) // Dogs and Hounds
4284 if(percentage > 95) msg_format("%^sは攻撃に肩をすくめた。", m_name);
4285 else if(percentage > 75) msg_format("%^sは痛みでうなった。", m_name);
4286 else if(percentage > 50) msg_format("%^sは痛みでキャンキャン吠えた。", m_name);
4287 else if(percentage > 35) msg_format("%^sは痛みで鳴きわめいた。", m_name);
4288 else if(percentage > 20) msg_format("%^sは苦痛のあまり鳴きわめいた。", m_name);
4289 else if(percentage > 10) msg_format("%^sは苦痛でもだえ苦しんだ。", m_name);
4290 else msg_format("%^sは弱々しく吠えた。", m_name);
4292 if(percentage > 95) msg_format("%^s shrugs off the attack.", m_name);
4293 else if(percentage > 75) msg_format("%^s snarls with pain.", m_name);
4294 else if(percentage > 50) msg_format("%^s yelps in pain.", m_name);
4295 else if(percentage > 35) msg_format("%^s howls in pain.", m_name);
4296 else if(percentage > 20) msg_format("%^s howls in agony.", m_name);
4297 else if(percentage > 10) msg_format("%^s writhes in agony.", m_name);
4298 else msg_format("%^s yelps feebly.", m_name);
4302 else if(my_strchr("Xbilqrt", r_ptr->d_char)) // One type of creatures (ignore,squeal,shriek)
4305 if(percentage > 95) msg_format("%^sは攻撃を気にとめていない。", m_name);
4306 else if(percentage > 75) msg_format("%^sは痛みでうなった。", m_name);
4307 else if(percentage > 50) msg_format("%^sは痛みで叫んだ。", m_name);
4308 else if(percentage > 35) msg_format("%^sは痛みで絶叫した。", m_name);
4309 else if(percentage > 20) msg_format("%^sは苦痛のあまり絶叫した。", m_name);
4310 else if(percentage > 10) msg_format("%^sは苦痛でもだえ苦しんだ。", m_name);
4311 else msg_format("%^sは弱々しく叫んだ。", m_name);
4313 if(percentage > 95) msg_format("%^s ignores the attack.", m_name);
4314 else if(percentage > 75) msg_format("%^s grunts with pain.", m_name);
4315 else if(percentage > 50) msg_format("%^s squeals in pain.", m_name);
4316 else if(percentage > 35) msg_format("%^s shrieks in pain.", m_name);
4317 else if(percentage > 20) msg_format("%^s shrieks in agony.", m_name);
4318 else if(percentage > 10) msg_format("%^s writhes in agony.", m_name);
4319 else msg_format("%^s cries out feebly.", m_name);
4323 else // Another type of creatures (shrug,cry,scream)
4326 if(percentage > 95) msg_format("%^sは攻撃に肩をすくめた。", m_name);
4327 else if(percentage > 75) msg_format("%^sは痛みでうなった。", m_name);
4328 else if(percentage > 50) msg_format("%^sは痛みで叫んだ。", m_name);
4329 else if(percentage > 35) msg_format("%^sは痛みで絶叫した。", m_name);
4330 else if(percentage > 20) msg_format("%^sは苦痛のあまり絶叫した。", m_name);
4331 else if(percentage > 10) msg_format("%^sは苦痛でもだえ苦しんだ。", m_name);
4332 else msg_format("%^sは弱々しく叫んだ。", m_name);
4334 if(percentage > 95) msg_format("%^s shrugs off the attack.", m_name);
4335 else if(percentage > 75) msg_format("%^s grunts with pain.", m_name);
4336 else if(percentage > 50) msg_format("%^s cries out in pain.", m_name);
4337 else if(percentage > 35) msg_format("%^s screams in pain.", m_name);
4338 else if(percentage > 20) msg_format("%^s screams in agony.", m_name);
4339 else if(percentage > 10) msg_format("%^s writhes in agony.", m_name);
4340 else msg_format("%^s cries out feebly.", m_name);
4348 * @brief SMART(適格に攻撃を行う)モンスターの学習状況を更新する / Learn about an "observed" resistance.
4349 * @param m_idx 更新を行う「モンスター情報ID
4350 * @param what 学習対象ID
4353 void update_smart_learn(MONSTER_IDX m_idx, int what)
4355 monster_type *m_ptr = ¤t_floor_ptr->m_list[m_idx];
4356 monster_race *r_ptr = &r_info[m_ptr->r_idx];
4358 /* Not allowed to learn */
4359 if (!smart_learn) return;
4361 /* Too stupid to learn anything */
4362 if (r_ptr->flags2 & (RF2_STUPID)) return;
4364 /* Not intelligent, only learn sometimes */
4365 if (!(r_ptr->flags2 & (RF2_SMART)) && (randint0(100) < 50)) return;
4367 /* Analyze the knowledge */
4371 if (p_ptr->resist_acid) m_ptr->smart |= (SM_RES_ACID);
4372 if (IS_OPPOSE_ACID()) m_ptr->smart |= (SM_OPP_ACID);
4373 if (p_ptr->immune_acid) m_ptr->smart |= (SM_IMM_ACID);
4377 if (p_ptr->resist_elec) m_ptr->smart |= (SM_RES_ELEC);
4378 if (IS_OPPOSE_ELEC()) m_ptr->smart |= (SM_OPP_ELEC);
4379 if (p_ptr->immune_elec) m_ptr->smart |= (SM_IMM_ELEC);
4383 if (p_ptr->resist_fire) m_ptr->smart |= (SM_RES_FIRE);
4384 if (IS_OPPOSE_FIRE()) m_ptr->smart |= (SM_OPP_FIRE);
4385 if (p_ptr->immune_fire) m_ptr->smart |= (SM_IMM_FIRE);
4389 if (p_ptr->resist_cold) m_ptr->smart |= (SM_RES_COLD);
4390 if (IS_OPPOSE_COLD()) m_ptr->smart |= (SM_OPP_COLD);
4391 if (p_ptr->immune_cold) m_ptr->smart |= (SM_IMM_COLD);
4395 if (p_ptr->resist_pois) m_ptr->smart |= (SM_RES_POIS);
4396 if (IS_OPPOSE_POIS()) m_ptr->smart |= (SM_OPP_POIS);
4401 if (p_ptr->resist_neth) m_ptr->smart |= (SM_RES_NETH);
4405 if (p_ptr->resist_lite) m_ptr->smart |= (SM_RES_LITE);
4409 if (p_ptr->resist_dark) m_ptr->smart |= (SM_RES_DARK);
4413 if (p_ptr->resist_fear) m_ptr->smart |= (SM_RES_FEAR);
4417 if (p_ptr->resist_conf) m_ptr->smart |= (SM_RES_CONF);
4421 if (p_ptr->resist_chaos) m_ptr->smart |= (SM_RES_CHAOS);
4425 if (p_ptr->resist_disen) m_ptr->smart |= (SM_RES_DISEN);
4429 if (p_ptr->resist_blind) m_ptr->smart |= (SM_RES_BLIND);
4433 if (p_ptr->resist_nexus) m_ptr->smart |= (SM_RES_NEXUS);
4437 if (p_ptr->resist_sound) m_ptr->smart |= (SM_RES_SOUND);
4441 if (p_ptr->resist_shard) m_ptr->smart |= (SM_RES_SHARD);
4445 if (p_ptr->free_act) m_ptr->smart |= (SM_IMM_FREE);
4449 if (!p_ptr->msp) m_ptr->smart |= (SM_IMM_MANA);
4453 if (p_ptr->reflect) m_ptr-> smart |= (SM_IMM_REFLECT);
4460 * @brief モンスターが盗みや拾いで確保していたアイテムを全てドロップさせる / Drop all items carried by a monster
4461 * @param m_ptr モンスター参照ポインタ
4464 void monster_drop_carried_objects(monster_type *m_ptr)
4466 OBJECT_IDX this_o_idx, next_o_idx = 0;
4472 /* Drop objects being carried */
4473 for (this_o_idx = m_ptr->hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
4475 o_ptr = ¤t_floor_ptr->o_list[this_o_idx];
4476 next_o_idx = o_ptr->next_o_idx;
4479 /* Copy the object */
4480 object_copy(q_ptr, o_ptr);
4482 /* Forget monster */
4483 q_ptr->held_m_idx = 0;
4485 delete_object_idx(this_o_idx);
4488 (void)drop_near(q_ptr, -1, m_ptr->fy, m_ptr->fx);
4491 /* Forget objects */
4492 m_ptr->hold_o_idx = 0;