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 #define HORDE_NOGOOD 0x01
16 #define HORDE_NOEVIL 0x02
18 cptr horror_desc[MAX_SAN_HORROR] =
72 cptr funny_desc[MAX_SAN_FUNNY] =
132 cptr funny_comments[MAX_SAN_COMMENT] =
153 * @brief モンスターの目標地点をセットする / Set the target of counter attack
154 * @param m_ptr モンスターの参照ポインタ
159 void set_target(monster_type *m_ptr, int y, int x)
167 * @brief モンスターの目標地点をリセットする / Reset the target of counter attack
168 * @param m_ptr モンスターの参照ポインタ
171 void reset_target(monster_type *m_ptr)
173 set_target(m_ptr, 0, 0);
178 * @brief モンスターの真の種族を返す / Extract monster race pointer of a monster's true form
179 * @param m_ptr モンスターの参照ポインタ
180 * @return 本当のモンスター種族参照ポインタ
182 monster_race *real_r_ptr(monster_type *m_ptr)
184 monster_race *r_ptr = &r_info[m_ptr->r_idx];
186 /* Extract real race */
187 if (m_ptr->mflag2 & MFLAG2_CHAMELEON)
189 if (r_ptr->flags1 & RF1_UNIQUE)
190 return &r_info[MON_CHAMELEON_K];
192 return &r_info[MON_CHAMELEON];
202 * @brief モンスター配列からモンスターを消去する / Delete a monster by index.
203 * @param i 消去するモンスターのID
206 * モンスターを削除するとそのモンスターが拾っていたアイテムも同時に削除される。 /
207 * When a monster is deleted, all of its objects are deleted.
209 void delete_monster_idx(int i)
213 monster_type *m_ptr = &m_list[i];
215 monster_race *r_ptr = &r_info[m_ptr->r_idx];
217 s16b this_o_idx, next_o_idx = 0;
225 /* Hack -- Reduce the racial counter */
226 real_r_ptr(m_ptr)->cur_num--;
228 /* Hack -- count the number of "reproducers" */
229 if (r_ptr->flags2 & (RF2_MULTIPLY)) num_repro--;
231 if (MON_CSLEEP(m_ptr)) (void)set_monster_csleep(i, 0);
232 if (MON_FAST(m_ptr)) (void)set_monster_fast(i, 0);
233 if (MON_SLOW(m_ptr)) (void)set_monster_slow(i, 0);
234 if (MON_STUNNED(m_ptr)) (void)set_monster_stunned(i, 0);
235 if (MON_CONFUSED(m_ptr)) (void)set_monster_confused(i, 0);
236 if (MON_MONFEAR(m_ptr)) (void)set_monster_monfear(i, 0);
237 if (MON_INVULNER(m_ptr)) (void)set_monster_invulner(i, 0, FALSE);
240 /* Hack -- remove target monster */
241 if (i == target_who) target_who = 0;
243 /* Hack -- remove tracked monster */
244 if (i == p_ptr->health_who) health_track(0);
246 if (pet_t_m_idx == i ) pet_t_m_idx = 0;
247 if (riding_t_m_idx == i) riding_t_m_idx = 0;
248 if (p_ptr->riding == i) p_ptr->riding = 0;
250 /* Monster is gone */
251 cave[y][x].m_idx = 0;
255 for (this_o_idx = m_ptr->hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
260 o_ptr = &o_list[this_o_idx];
262 /* Acquire next object */
263 next_o_idx = o_ptr->next_o_idx;
266 * o_ptr->held_m_idx is needed in delete_object_idx()
267 * to prevent calling lite_spot()
270 /* Delete the object */
271 delete_object_idx(this_o_idx);
275 if (is_pet(m_ptr)) check_pets_num_and_align(m_ptr, FALSE);
278 /* Wipe the Monster */
279 (void)WIPE(m_ptr, monster_type);
287 /* Update some things */
288 if (r_ptr->flags7 & (RF7_LITE_MASK | RF7_DARK_MASK))
289 p_ptr->update |= (PU_MON_LITE);
294 * @brief 指定位置に存在するモンスターを削除する / Delete the monster, if any, at a given location
299 void delete_monster(int y, int x)
304 if (!in_bounds(y, x)) return;
309 /* Delete the monster (if any) */
310 if (c_ptr->m_idx) delete_monster_idx(c_ptr->m_idx);
315 * @brief モンスター情報を配列内移動する / Move an object from index i1 to index i2 in the object list
320 static void compact_monsters_aux(int i1, int i2)
328 s16b this_o_idx, next_o_idx = 0;
332 if (i1 == i2) return;
345 /* Update the cave */
348 /* Repair objects being carried by monster */
349 for (this_o_idx = m_ptr->hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
354 o_ptr = &o_list[this_o_idx];
356 /* Acquire next object */
357 next_o_idx = o_ptr->next_o_idx;
359 /* Reset monster pointer */
360 o_ptr->held_m_idx = i2;
363 /* Hack -- Update the target */
364 if (target_who == i1) target_who = i2;
366 /* Hack -- Update the target */
367 if (pet_t_m_idx == i1) pet_t_m_idx = i2;
368 if (riding_t_m_idx == i1) riding_t_m_idx = i2;
370 /* Hack -- Update the riding */
371 if (p_ptr->riding == i1) p_ptr->riding = i2;
373 /* Hack -- Update the health bar */
374 if (p_ptr->health_who == i1) health_track(i2);
376 /* Hack -- Update parent index */
379 for (i = 1; i < m_max; i++)
381 monster_type *m2_ptr = &m_list[i];
383 if (m2_ptr->parent_m_idx == i1)
384 m2_ptr->parent_m_idx = i2;
389 (void)COPY(&m_list[i2], &m_list[i1], monster_type);
392 (void)WIPE(&m_list[i1], monster_type);
394 for (i = 0; i < MAX_MTIMED; i++)
396 int mproc_idx = get_mproc_idx(i1, i);
397 if (mproc_idx >= 0) mproc_list[i][mproc_idx] = i2;
403 * @brief モンスター情報配列を圧縮する / Compact and Reorder the monster list
404 * @param size 圧縮後のモンスター件数目標
407 * This function can be very dangerous, use with caution!
409 * When actually "compacting" monsters, we base the saving throw
410 * on a combination of monster level, distance from player, and
411 * current "desperation".
413 * After "compacting" (if needed), we "reorder" the monsters into a more
414 * compact order, and we reset the allocation info, and the "live" array.
416 void compact_monsters(int size)
419 int cur_lev, cur_dis, chance;
421 /* Message (only if compacting) */
422 if (size) msg_print(_("モンスター情報を圧縮しています...", "Compacting monsters..."));
425 /* Compact at least 'size' objects */
426 for (num = 0, cnt = 1; num < size; cnt++)
428 /* Get more vicious each iteration */
431 /* Get closer each iteration */
432 cur_dis = 5 * (20 - cnt);
434 /* Check all the monsters */
435 for (i = 1; i < m_max; i++)
437 monster_type *m_ptr = &m_list[i];
439 monster_race *r_ptr = &r_info[m_ptr->r_idx];
441 /* Paranoia -- skip "dead" monsters */
442 if (!m_ptr->r_idx) continue;
444 /* Hack -- High level monsters start out "immune" */
445 if (r_ptr->level > cur_lev) continue;
447 if (i == p_ptr->riding) continue;
449 /* Ignore nearby monsters */
450 if ((cur_dis > 0) && (m_ptr->cdis < cur_dis)) continue;
452 /* Saving throw chance */
455 /* Only compact "Quest" Monsters in emergencies */
456 if ((r_ptr->flags1 & (RF1_QUESTOR)) && (cnt < 1000)) chance = 100;
458 /* Try not to compact Unique Monsters */
459 if (r_ptr->flags1 & (RF1_UNIQUE)) chance = 100;
461 /* All monsters get a saving throw */
462 if (randint0(100) < chance) continue;
464 if (record_named_pet && is_pet(m_ptr) && m_ptr->nickname)
468 monster_desc(m_name, m_ptr, MD_INDEF_VISIBLE);
469 do_cmd_write_nikki(NIKKI_NAMED_PET, RECORD_NAMED_PET_COMPACT, m_name);
472 /* Delete the monster */
473 delete_monster_idx(i);
475 /* Count the monster */
481 /* Excise dead monsters (backwards!) */
482 for (i = m_max - 1; i >= 1; i--)
484 /* Get the i'th monster */
485 monster_type *m_ptr = &m_list[i];
487 /* Skip real monsters */
488 if (m_ptr->r_idx) continue;
490 /* Move last monster into open hole */
491 compact_monsters_aux(m_max - 1, i);
493 /* Compress "m_max" */
500 * @brief プレイヤーのフロア離脱に伴う全モンスター配列の消去 / Delete/Remove all the monsters when the player leaves the level
503 * This is an efficient method of simulating multiple calls to the
504 * "delete_monster()" function, with no visual effects.
506 void wipe_m_list(void)
510 /* Hack -- if Banor or Lupart dies, stay another dead */
511 if (!r_info[MON_BANORLUPART].max_num)
513 if (r_info[MON_BANOR].max_num)
515 r_info[MON_BANOR].max_num = 0;
516 r_info[MON_BANOR].r_pkills++;
517 r_info[MON_BANOR].r_akills++;
518 if (r_info[MON_BANOR].r_tkills < MAX_SHORT) r_info[MON_BANOR].r_tkills++;
520 if (r_info[MON_LUPART].max_num)
522 r_info[MON_LUPART].max_num = 0;
523 r_info[MON_LUPART].r_pkills++;
524 r_info[MON_LUPART].r_akills++;
525 if (r_info[MON_LUPART].r_tkills < MAX_SHORT) r_info[MON_LUPART].r_tkills++;
529 /* Delete all the monsters */
530 for (i = m_max - 1; i >= 1; i--)
532 monster_type *m_ptr = &m_list[i];
534 /* Skip dead monsters */
535 if (!m_ptr->r_idx) continue;
537 /* Monster is gone */
538 cave[m_ptr->fy][m_ptr->fx].m_idx = 0;
540 /* Wipe the Monster */
541 (void)WIPE(m_ptr, monster_type);
546 * Wiping racial counters of all monsters and incrementing of racial
547 * counters of monsters in party_mon[] are required to prevent multiple
548 * generation of unique monster who is the minion of player.
551 /* Hack -- Wipe the racial counter of all monster races */
552 for (i = 1; i < max_r_idx; i++) r_info[i].cur_num = 0;
560 /* Reset "mproc_max[]" */
561 for (i = 0; i < MAX_MTIMED; i++) mproc_max[i] = 0;
563 /* Hack -- reset "reproducer" count */
566 /* Hack -- no more target */
571 /* Hack -- no more tracking */
577 * @brief モンスター配列の空きを探す / Acquires and returns the index of a "free" monster.
578 * @return 利用可能なモンスター配列の添字
580 * This routine should almost never fail, but it *can* happen.
587 /* Normal allocation */
588 if (m_max < max_m_idx)
590 /* Access the next hole */
593 /* Expand the array */
599 /* Return the index */
604 /* Recycle dead monsters */
605 for (i = 1; i < m_max; i++)
609 /* Acquire monster */
612 /* Skip live monsters */
613 if (m_ptr->r_idx) continue;
618 /* Use this monster */
623 /* Warn the player (except during dungeon creation) */
624 if (character_dungeon) msg_print(_("モンスターが多すぎる!", "Too many monsters!"));
626 /* Try not to crash */
634 * Hack -- the "type" of the current "summon specific"
636 static int summon_specific_type = 0;
640 * Hack -- the index of the summoning monster
642 static int summon_specific_who = -1;
645 static bool summon_unique_okay = FALSE;
649 * @brief 指定されたモンスター種族がsummon_specific_typeで指定された召喚条件に合うかどうかを返す
650 * @return 召喚条件が一致するならtrue
653 static bool summon_specific_aux(int r_idx)
655 monster_race *r_ptr = &r_info[r_idx];
658 /* Check our requirements */
659 switch (summon_specific_type)
663 okay = (r_ptr->d_char == 'a');
669 okay = (r_ptr->d_char == 'S');
675 okay = ((r_ptr->d_char == 'C') || (r_ptr->d_char == 'Z'));
681 okay = (r_ptr->d_char == 'M');
687 okay = (r_ptr->d_char == 'A' && ((r_ptr->flags3 & RF3_EVIL) || (r_ptr->flags3 & RF3_GOOD)));
693 okay = (r_ptr->flags3 & RF3_DEMON);
699 okay = (r_ptr->flags3 & RF3_UNDEAD);
705 okay = (r_ptr->flags3 & RF3_DRAGON);
709 case SUMMON_HI_UNDEAD:
711 okay = ((r_ptr->d_char == 'L') ||
712 (r_ptr->d_char == 'V') ||
713 (r_ptr->d_char == 'W'));
717 case SUMMON_HI_DRAGON:
719 okay = (r_ptr->d_char == 'D');
723 case SUMMON_HI_DEMON:
725 okay = (((r_ptr->d_char == 'U') ||
726 (r_ptr->d_char == 'H') ||
727 (r_ptr->d_char == 'B')) &&
728 (r_ptr->flags3 & RF3_DEMON)) ? TRUE : FALSE;
732 case SUMMON_AMBERITES:
734 okay = (r_ptr->flags3 & (RF3_AMBERITE)) ? TRUE : FALSE;
740 okay = (r_ptr->flags1 & (RF1_UNIQUE)) ? TRUE : FALSE;
744 case SUMMON_BIZARRE1:
746 okay = (r_ptr->d_char == 'm');
749 case SUMMON_BIZARRE2:
751 okay = (r_ptr->d_char == 'b');
754 case SUMMON_BIZARRE3:
756 okay = (r_ptr->d_char == 'Q');
760 case SUMMON_BIZARRE4:
762 okay = (r_ptr->d_char == 'v');
766 case SUMMON_BIZARRE5:
768 okay = (r_ptr->d_char == '$');
772 case SUMMON_BIZARRE6:
774 okay = ((r_ptr->d_char == '!') ||
775 (r_ptr->d_char == '?') ||
776 (r_ptr->d_char == '=') ||
777 (r_ptr->d_char == '$') ||
778 (r_ptr->d_char == '|'));
784 okay = (r_ptr->d_char == 'g');
790 okay = ((r_ptr->d_char == 'U') &&
791 (r_ptr->flags4 & RF4_ROCKET));
798 okay = ((r_ptr->d_char == summon_kin_type) && (r_idx != MON_HAGURE));
804 okay = (r_idx == MON_DAWN);
810 okay = (r_ptr->flags3 & (RF3_ANIMAL));
814 case SUMMON_ANIMAL_RANGER:
816 okay = ((r_ptr->flags3 & (RF3_ANIMAL)) &&
817 (my_strchr("abcflqrwBCHIJKMRS", r_ptr->d_char)) &&
818 !(r_ptr->flags3 & (RF3_DRAGON)) &&
819 !(r_ptr->flags3 & (RF3_EVIL)) &&
820 !(r_ptr->flags3 & (RF3_UNDEAD)) &&
821 !(r_ptr->flags3 & (RF3_DEMON)) &&
822 !(r_ptr->flags2 & (RF2_MULTIPLY)) &&
823 !(r_ptr->flags4 || r_ptr->flags5 || r_ptr->flags6));
827 case SUMMON_HI_DRAGON_LIVING:
829 okay = ((r_ptr->d_char == 'D') && monster_living(r_ptr));
835 okay = monster_living(r_ptr);
841 okay = (r_idx == MON_PHANTOM_B || r_idx == MON_PHANTOM_W);
845 case SUMMON_BLUE_HORROR:
847 okay = (r_idx == MON_BLUE_HORROR);
851 case SUMMON_ELEMENTAL:
853 okay = (r_ptr->d_char == 'E');
859 okay = (r_ptr->d_char == 'v');
865 okay = (r_ptr->d_char == 'H');
871 okay = (r_ptr->d_char == 'B');
875 case SUMMON_KAMIKAZE:
878 for (i = 0; i < 4; i++)
879 if (r_ptr->blow[i].method == RBM_EXPLODE) okay = TRUE;
883 case SUMMON_KAMIKAZE_LIVING:
887 for (i = 0; i < 4; i++)
888 if (r_ptr->blow[i].method == RBM_EXPLODE) okay = TRUE;
889 okay = (okay && monster_living(r_ptr));
895 okay = (r_idx == MON_MANES);
901 okay = (r_idx == MON_LOUSE);
905 case SUMMON_GUARDIANS:
907 okay = (r_ptr->flags7 & RF7_GUARDIAN);
913 okay = ((r_idx == MON_NOV_PALADIN) ||
914 (r_idx == MON_NOV_PALADIN_G) ||
915 (r_idx == MON_PALADIN) ||
916 (r_idx == MON_W_KNIGHT) ||
917 (r_idx == MON_ULTRA_PALADIN) ||
918 (r_idx == MON_KNI_TEMPLAR));
924 okay = (r_ptr->d_char == 'B' &&
925 (r_ptr->flags8 & RF8_WILD_MOUNTAIN) &&
926 (r_ptr->flags8 & RF8_WILD_ONLY));
930 case SUMMON_PIRANHAS:
932 okay = (r_idx == MON_PIRANHA);
936 case SUMMON_ARMAGE_GOOD:
938 okay = (r_ptr->d_char == 'A' && (r_ptr->flags3 & RF3_GOOD));
942 case SUMMON_ARMAGE_EVIL:
944 okay = ((r_ptr->flags3 & RF3_DEMON) ||
945 (r_ptr->d_char == 'A' && (r_ptr->flags3 & RF3_EVIL)));
951 /* Since okay is int, "return (okay);" is not correct. */
952 return (bool)(okay ? TRUE : FALSE);
956 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(int r_idx)
966 dungeon_info_type *d_ptr = &d_info[dungeon_type];
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->flags5 & RF5_NOMAGIC_MASK) &&
980 !(r_ptr->flags6 & 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->flags5 & (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->flags6 & (RF6_BOLT_MASK | RF6_BEAM_MASK | RF6_BALL_MASK)))
991 if (d_ptr->flags1 & DF1_BEGINNER)
993 if (r_ptr->level > 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)
1025 if ((d_ptr->mflags5 & r_ptr->flags5) != d_ptr->mflags5)
1030 if ((d_ptr->mflags6 & r_ptr->flags6) != d_ptr->mflags6)
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)
1081 if ((d_ptr->mflags5 & r_ptr->flags5) != d_ptr->mflags5)
1086 if ((d_ptr->mflags6 & r_ptr->flags6) != d_ptr->mflags6)
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->flags5 & d_ptr->mflags5) return TRUE;
1120 if (r_ptr->flags6 & d_ptr->mflags6) 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->flags5 & d_ptr->mflags5) return FALSE;
1136 if (r_ptr->flags6 & d_ptr->mflags6) 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 monnster_hook 制限関数1
1153 * @param monnster_hook2 制限関数2
1156 errr get_mon_num_prep(monster_hook_type monster_hook,
1157 monster_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 > dun_level))
1199 /* Accept this monster */
1200 entry->prob2 = entry->prob1;
1202 if (dun_level && (!p_ptr->inside_quest || is_fixed_quest_idx(p_ptr->inside_quest)) && !restrict_monster_to_dungeon(entry->index) && !p_ptr->inside_battle)
1204 int hoge = entry->prob2 * d_info[dungeon_type].special_div;
1205 entry->prob2 = hoge / 64;
1206 if (randint0(64) < (hoge & 0x3f)) entry->prob2++;
1215 * @brief 平方根を切り捨て整数で返す
1219 static int mysqrt(int n)
1257 * @brief 生成モンスター種族を1種生成テーブルから選択する
1259 * @return 選択されたモンスター生成種族
1261 * Choose a monster race that seems "appropriate" to the given level
1263 * This function uses the "prob2" field of the "monster allocation table",
1264 * and various local information, to calculate the "prob3" field of the
1265 * same table, which is then used to choose an "appropriate" monster, in
1266 * a relatively efficient manner.
1268 * Note that "town" monsters will *only* be created in the town, and
1269 * "normal" monsters will *never* be created in the town, unless the
1270 * "level" is "modified", for example, by polymorph or summoning.
1272 * There is a small chance (1/50) of "boosting" the given depth by
1273 * a small amount (up to four levels), except in the town.
1275 * It is (slightly) more likely to acquire a monster of the given level
1276 * than one of a lower level. This is done by choosing several monsters
1277 * appropriate to the given level and keeping the "hardest" one.
1279 * Note that if no monsters are "appropriate", then this function will
1280 * fail, and return zero, but this should *almost* never happen.
1282 s16b get_mon_num(int level)
1287 monster_race *r_ptr;
1288 alloc_entry *table = alloc_race_table;
1290 int pls_kakuritu, pls_level;
1291 int hoge = mysqrt(level*10000L);
1293 if (level > MAX_DEPTH - 1) level = MAX_DEPTH - 1;
1295 pls_kakuritu = MAX(NASTY_MON_MAX, NASTY_MON_BASE - ((dungeon_turn / (TURNS_PER_TICK * 2500L) - hoge / 10)));
1296 pls_level = MIN(NASTY_MON_PLUS_MAX, 3 + dungeon_turn / (TURNS_PER_TICK * 20000L) - hoge / 40 + MIN(5, level / 10)) ;
1298 if (d_info[dungeon_type].flags1 & DF1_MAZE)
1300 pls_kakuritu = MIN(pls_kakuritu / 2, pls_kakuritu - 10);
1301 if (pls_kakuritu < 2) pls_kakuritu = 2;
1306 /* Boost the level */
1307 if (!p_ptr->inside_battle && !(d_info[dungeon_type].flags1 & DF1_BEGINNER))
1309 /* Nightmare mode allows more out-of depth monsters */
1310 if (ironman_nightmare && !randint0(pls_kakuritu))
1312 /* What a bizarre calculation */
1313 level = 1 + (level * MAX_DEPTH / randint1(MAX_DEPTH));
1317 /* Occasional "nasty" monster */
1318 if (!randint0(pls_kakuritu))
1320 /* Pick a level bonus */
1329 /* Process probabilities */
1330 for (i = 0; i < alloc_race_size; i++)
1332 /* Monsters are sorted by depth */
1333 if (table[i].level > level) break;
1338 /* Access the "r_idx" of the chosen monster */
1339 r_idx = table[i].index;
1341 /* Access the actual race */
1342 r_ptr = &r_info[r_idx];
1344 if (!p_ptr->inside_battle && !chameleon_change_m_idx)
1346 /* Hack -- "unique" monsters must be "unique" */
1347 if (((r_ptr->flags1 & (RF1_UNIQUE)) ||
1348 (r_ptr->flags7 & (RF7_NAZGUL))) &&
1349 (r_ptr->cur_num >= r_ptr->max_num))
1354 if ((r_ptr->flags7 & (RF7_UNIQUE2)) &&
1355 (r_ptr->cur_num >= 1))
1360 if (r_idx == MON_BANORLUPART)
1362 if (r_info[MON_BANOR].cur_num > 0) continue;
1363 if (r_info[MON_LUPART].cur_num > 0) continue;
1368 table[i].prob3 = table[i].prob2;
1371 total += table[i].prob3;
1374 /* No legal monsters */
1375 if (total <= 0) return (0);
1377 /* Pick a monster */
1378 value = randint0(total);
1380 /* Find the monster */
1381 for (i = 0; i < alloc_race_size; i++)
1383 /* Found the entry */
1384 if (value < table[i].prob3) break;
1387 value = value - table[i].prob3;
1393 /* Try for a "harder" monster once (50%) or twice (10%) */
1399 /* Pick a monster */
1400 value = randint0(total);
1402 /* Find the monster */
1403 for (i = 0; i < alloc_race_size; i++)
1405 /* Found the entry */
1406 if (value < table[i].prob3) break;
1409 value = value - table[i].prob3;
1412 /* Keep the "best" one */
1413 if (table[i].level < table[j].level) i = j;
1416 /* Try for a "harder" monster twice (10%) */
1422 /* Pick a monster */
1423 value = randint0(total);
1425 /* Find the monster */
1426 for (i = 0; i < alloc_race_size; i++)
1428 /* Found the entry */
1429 if (value < table[i].prob3) break;
1432 value = value - table[i].prob3;
1435 /* Keep the "best" one */
1436 if (table[i].level < table[j].level) i = j;
1440 return (table[i].index);
1445 * @brief モンスターの呼称を作成する / Build a string describing a monster in some way.
1446 * @param desc 記述出力先の文字列参照ポインタ
1447 * @param m_ptr モンスターの参照ポインタ
1448 * @param mode 呼称オプション
1451 * We can correctly describe monsters based on their visibility.
1452 * We can force all monsters to be treated as visible or invisible.
1453 * We can build nominatives, objectives, possessives, or reflexives.
1454 * We can selectively pronominalize hidden, visible, or all monsters.
1455 * We can use definite or indefinite descriptions for hidden monsters.
1456 * We can use definite or indefinite descriptions for visible monsters.
1458 * Pronominalization involves the gender whenever possible and allowed,
1459 * so that by cleverly requesting pronominalization / visibility, you
1460 * can get messages like "You hit someone. She screams in agony!".
1462 * Reflexives are acquired by requesting Objective plus Possessive.
1464 * If no m_ptr arg is given (?), the monster is assumed to be hidden,
1465 * unless the "Assume Visible" mode is requested.
1467 * If no r_ptr arg is given, it is extracted from m_ptr and r_info
1468 * If neither m_ptr nor r_ptr is given, the monster is assumed to
1469 * be neuter, singular, and hidden (unless "Assume Visible" is set),
1470 * in which case you may be in trouble... :-)
1472 * I am assuming that no monster name is more than 70 characters long,
1473 * so that "char desc[80];" is sufficiently large for any result.
1476 * MD_OBJECTIVE --> Objective (or Reflexive)
1477 * MD_POSSESSIVE --> Possessive (or Reflexive)
1478 * MD_INDEF_HIDDEN --> Use indefinites for hidden monsters ("something")
1479 * MD_INDEF_VISIBLE --> Use indefinites for visible monsters ("a kobold")
1480 * MD_PRON_HIDDEN --> Pronominalize hidden monsters
1481 * MD_PRON_VISIBLE --> Pronominalize visible monsters
1482 * MD_ASSUME_HIDDEN --> Assume the monster is hidden
1483 * MD_ASSUME_VISIBLE --> Assume the monster is visible
1484 * MD_TRUE_NAME --> Chameleon's true name
1485 * MD_IGNORE_HALLU --> Ignore hallucination, and penetrate shape change
1488 * 0x00 --> Full nominative name ("the kobold") or "it"
1489 * MD_INDEF_HIDDEN --> Full nominative name ("the kobold") or "something"
1490 * MD_ASSUME_VISIBLE --> Genocide resistance name ("the kobold")
1491 * MD_ASSUME_VISIBLE | MD_INDEF_VISIBLE --> Killing name ("a kobold")
1492 * MD_PRON_VISIBLE | MD_POSSESSIVE
1493 * --> Possessive, genderized if visable ("his") or "its"
1494 * MD_PRON_VISIBLE | MD_POSSESSIVE | MD_OBJECTIVE
1495 * --> Reflexive, genderized if visable ("himself") or "itself"
1497 void monster_desc(char *desc, monster_type *m_ptr, int mode)
1500 monster_race *r_ptr;
1504 char silly_name[1024];
1508 r_ptr = &r_info[m_ptr->ap_r_idx];
1510 /* Mode of MD_TRUE_NAME will reveal Chameleon's true name */
1511 if (mode & MD_TRUE_NAME) name = (r_name + real_r_ptr(m_ptr)->name);
1512 else name = (r_name + r_ptr->name);
1514 /* Are we hallucinating? (Idea from Nethack...) */
1515 if (p_ptr->image && !(mode & MD_IGNORE_HALLU))
1519 if (!get_rnd_line(_("silly_j.txt", "silly.txt"), m_ptr->r_idx, silly_name))
1525 monster_race *hallu_race;
1529 hallu_race = &r_info[randint1(max_r_idx - 1)];
1531 while (!hallu_race->name || (hallu_race->flags1 & RF1_UNIQUE));
1533 strcpy(silly_name, (r_name + hallu_race->name));
1536 /* Better not strcpy it, or we could corrupt r_info... */
1540 /* Can we "see" it (exists + forced, or visible + not unforced) */
1541 seen = (m_ptr && ((mode & MD_ASSUME_VISIBLE) || (!(mode & MD_ASSUME_HIDDEN) && m_ptr->ml)));
1543 /* Sexed Pronouns (seen and allowed, or unseen and allowed) */
1544 pron = (m_ptr && ((seen && (mode & MD_PRON_VISIBLE)) || (!seen && (mode & MD_PRON_HIDDEN))));
1547 /* First, try using pronouns, or describing hidden monsters */
1550 /* an encoding of the monster "sex" */
1553 /* Extract the gender (if applicable) */
1554 if (r_ptr->flags1 & (RF1_FEMALE)) kind = 0x20;
1555 else if (r_ptr->flags1 & (RF1_MALE)) kind = 0x10;
1557 /* Ignore the gender (if desired) */
1558 if (!m_ptr || !pron) kind = 0x00;
1561 /* Assume simple result */
1562 res = _("何か", "it");
1564 /* Brute force: split on the possibilities */
1565 switch (kind + (mode & (MD_INDEF_HIDDEN | MD_POSSESSIVE | MD_OBJECTIVE)))
1567 /* Neuter, or unknown */
1569 case 0x00: res = "何か"; break;
1570 case 0x00 + (MD_OBJECTIVE): res = "何か"; break;
1571 case 0x00 + (MD_POSSESSIVE): res = "何かの"; break;
1572 case 0x00 + (MD_POSSESSIVE | MD_OBJECTIVE): res = "何か自身"; break;
1573 case 0x00 + (MD_INDEF_HIDDEN): res = "何か"; break;
1574 case 0x00 + (MD_INDEF_HIDDEN | MD_OBJECTIVE): res = "何か"; break;
1575 case 0x00 + (MD_INDEF_HIDDEN | MD_POSSESSIVE): res = "何か"; break;
1576 case 0x00 + (MD_INDEF_HIDDEN | MD_POSSESSIVE | MD_OBJECTIVE): res = "それ自身"; break;
1578 case 0x00: res = "it"; break;
1579 case 0x00 + (MD_OBJECTIVE): res = "it"; break;
1580 case 0x00 + (MD_POSSESSIVE): res = "its"; break;
1581 case 0x00 + (MD_POSSESSIVE | MD_OBJECTIVE): res = "itself"; break;
1582 case 0x00 + (MD_INDEF_HIDDEN): res = "something"; break;
1583 case 0x00 + (MD_INDEF_HIDDEN | MD_OBJECTIVE): res = "something"; break;
1584 case 0x00 + (MD_INDEF_HIDDEN | MD_POSSESSIVE): res = "something's"; break;
1585 case 0x00 + (MD_INDEF_HIDDEN | MD_POSSESSIVE | MD_OBJECTIVE): res = "itself"; break;
1589 /* Male (assume human if vague) */
1591 case 0x10: res = "彼"; break;
1592 case 0x10 + (MD_OBJECTIVE): res = "彼"; break;
1593 case 0x10 + (MD_POSSESSIVE): res = "彼の"; break;
1594 case 0x10 + (MD_POSSESSIVE | MD_OBJECTIVE): res = "彼自身"; break;
1595 case 0x10 + (MD_INDEF_HIDDEN): res = "誰か"; break;
1596 case 0x10 + (MD_INDEF_HIDDEN | MD_OBJECTIVE): res = "誰か"; break;
1597 case 0x10 + (MD_INDEF_HIDDEN | MD_POSSESSIVE): res = "誰かの"; break;
1598 case 0x10 + (MD_INDEF_HIDDEN | MD_POSSESSIVE | MD_OBJECTIVE): res = "彼自身"; break;
1600 case 0x10: res = "he"; break;
1601 case 0x10 + (MD_OBJECTIVE): res = "him"; break;
1602 case 0x10 + (MD_POSSESSIVE): res = "his"; break;
1603 case 0x10 + (MD_POSSESSIVE | MD_OBJECTIVE): res = "himself"; break;
1604 case 0x10 + (MD_INDEF_HIDDEN): res = "someone"; break;
1605 case 0x10 + (MD_INDEF_HIDDEN | MD_OBJECTIVE): res = "someone"; break;
1606 case 0x10 + (MD_INDEF_HIDDEN | MD_POSSESSIVE): res = "someone's"; break;
1607 case 0x10 + (MD_INDEF_HIDDEN | MD_POSSESSIVE | MD_OBJECTIVE): res = "himself"; break;
1611 /* Female (assume human if vague) */
1613 case 0x20: res = "彼女"; break;
1614 case 0x20 + (MD_OBJECTIVE): res = "彼女"; break;
1615 case 0x20 + (MD_POSSESSIVE): res = "彼女の"; break;
1616 case 0x20 + (MD_POSSESSIVE | MD_OBJECTIVE): res = "彼女自身"; break;
1617 case 0x20 + (MD_INDEF_HIDDEN): res = "誰か"; break;
1618 case 0x20 + (MD_INDEF_HIDDEN | MD_OBJECTIVE): res = "誰か"; break;
1619 case 0x20 + (MD_INDEF_HIDDEN | MD_POSSESSIVE): res = "誰かの"; break;
1620 case 0x20 + (MD_INDEF_HIDDEN | MD_POSSESSIVE | MD_OBJECTIVE): res = "彼女自身"; break;
1622 case 0x20: res = "she"; break;
1623 case 0x20 + (MD_OBJECTIVE): res = "her"; break;
1624 case 0x20 + (MD_POSSESSIVE): res = "her"; break;
1625 case 0x20 + (MD_POSSESSIVE | MD_OBJECTIVE): res = "herself"; break;
1626 case 0x20 + (MD_INDEF_HIDDEN): res = "someone"; break;
1627 case 0x20 + (MD_INDEF_HIDDEN | MD_OBJECTIVE): res = "someone"; break;
1628 case 0x20 + (MD_INDEF_HIDDEN | MD_POSSESSIVE): res = "someone's"; break;
1629 case 0x20 + (MD_INDEF_HIDDEN | MD_POSSESSIVE | MD_OBJECTIVE): res = "herself"; break;
1633 /* Copy the result */
1634 (void)strcpy(desc, res);
1638 /* Handle visible monsters, "reflexive" request */
1639 else if ((mode & (MD_POSSESSIVE | MD_OBJECTIVE)) == (MD_POSSESSIVE | MD_OBJECTIVE))
1641 /* The monster is visible, so use its gender */
1643 if (r_ptr->flags1 & (RF1_FEMALE)) strcpy(desc, "彼女自身");
1644 else if (r_ptr->flags1 & (RF1_MALE)) strcpy(desc, "彼自身");
1645 else strcpy(desc, "それ自身");
1647 if (r_ptr->flags1 & RF1_FEMALE) strcpy(desc, "herself");
1648 else if (r_ptr->flags1 & RF1_MALE) strcpy(desc, "himself");
1649 else strcpy(desc, "itself");
1654 /* Handle all other visible monster requests */
1658 if (is_pet(m_ptr) && !is_original_ap(m_ptr))
1664 while(strncmp(t, "』", 2) && *t) t++;
1668 (void)sprintf(desc, "%s?』", buf);
1671 (void)sprintf(desc, "%s?", name);
1673 (void)sprintf(desc, "%s?", name);
1678 /* It could be a Unique */
1679 if ((r_ptr->flags1 & RF1_UNIQUE) && !(p_ptr->image && !(mode & MD_IGNORE_HALLU)))
1681 /* Start with the name (thus nominative and objective) */
1682 if ((m_ptr->mflag2 & MFLAG2_CHAMELEON) && !(mode & MD_TRUE_NAME))
1688 while (strncmp(t, "』", 2) && *t) t++;
1692 (void)sprintf(desc, "%s?』", buf);
1695 (void)sprintf(desc, "%s?", name);
1697 (void)sprintf(desc, "%s?", name);
1701 /* Inside monster arena, and it is not your mount */
1702 else if (p_ptr->inside_battle &&
1703 !(p_ptr->riding && (&m_list[p_ptr->riding] == m_ptr)))
1705 /* It is a fake unique monster */
1706 (void)sprintf(desc, _("%sもどき", "fake %s"), name);
1711 (void)strcpy(desc, name);
1715 /* It could be an indefinite monster */
1716 else if (mode & MD_INDEF_VISIBLE)
1718 /* XXX Check plurality for "some" */
1720 /* Indefinite monsters need an indefinite article */
1722 (void)strcpy(desc, "");
1724 (void)strcpy(desc, is_a_vowel(name[0]) ? "an " : "a ");
1727 (void)strcat(desc, name);
1730 /* It could be a normal, definite, monster */
1733 /* Definite monsters need a definite article */
1735 (void)strcpy(desc, _("あなたの", "your "));
1737 (void)strcpy(desc, _("", "the "));
1739 (void)strcat(desc, name);
1742 if (m_ptr->nickname)
1744 sprintf(buf,_("「%s」", " called %s"),quark_str(m_ptr->nickname));
1748 if (p_ptr->riding && (&m_list[p_ptr->riding] == m_ptr))
1750 strcat(desc,_("(乗馬中)", "(riding)"));
1753 if ((mode & MD_IGNORE_HALLU) && (m_ptr->mflag2 & MFLAG2_CHAMELEON))
1755 if (r_ptr->flags1 & RF1_UNIQUE)
1757 strcat(desc,_("(カメレオンの王)", "(Chameleon Lord)"));
1761 strcat(desc,_("(カメレオン)", "(Chameleon)"));
1765 if ((mode & MD_IGNORE_HALLU) && !is_original_ap(m_ptr))
1767 strcat(desc, format("(%s)", r_name + r_info[m_ptr->r_idx].name));
1770 /* Handle the Possessive as a special afterthought */
1771 if (mode & MD_POSSESSIVE)
1773 /* XXX Check for trailing "s" */
1775 /* Simply append "apostrophe" and "s" */
1776 (void)strcat(desc, _("の", "'s"));
1784 * @brief モンスターの調査による思い出補完処理 / Learn about a monster (by "probing" it)
1785 * @param r_idx 補完されるモンスター種族ID
1786 * @return 明らかになった情報の度数
1788 * Return the number of new flags learnt. -Mogami-
1790 int lore_do_probe(int r_idx)
1792 monster_race *r_ptr = &r_info[r_idx];
1796 /* Maximal info about awareness */
1797 if (r_ptr->r_wake != MAX_UCHAR) n++;
1798 if (r_ptr->r_ignore != MAX_UCHAR) n++;
1799 r_ptr->r_wake = r_ptr->r_ignore = MAX_UCHAR;
1801 /* Observe "maximal" attacks */
1802 for (i = 0; i < 4; i++)
1804 /* Examine "actual" blows */
1805 if (r_ptr->blow[i].effect || r_ptr->blow[i].method)
1807 /* Maximal observations */
1808 if (r_ptr->r_blows[i] != MAX_UCHAR) n++;
1809 r_ptr->r_blows[i] = MAX_UCHAR;
1815 (((r_ptr->flags1 & RF1_DROP_4D2) ? 8 : 0) +
1816 ((r_ptr->flags1 & RF1_DROP_3D2) ? 6 : 0) +
1817 ((r_ptr->flags1 & RF1_DROP_2D2) ? 4 : 0) +
1818 ((r_ptr->flags1 & RF1_DROP_1D2) ? 2 : 0) +
1819 ((r_ptr->flags1 & RF1_DROP_90) ? 1 : 0) +
1820 ((r_ptr->flags1 & RF1_DROP_60) ? 1 : 0));
1822 /* Only "valid" drops */
1823 if (!(r_ptr->flags1 & RF1_ONLY_GOLD))
1825 if (r_ptr->r_drop_item != tmp_byte) n++;
1826 r_ptr->r_drop_item = tmp_byte;
1828 if (!(r_ptr->flags1 & RF1_ONLY_ITEM))
1830 if (r_ptr->r_drop_gold != tmp_byte) n++;
1831 r_ptr->r_drop_gold = tmp_byte;
1834 /* Observe many spells */
1835 if (r_ptr->r_cast_spell != MAX_UCHAR) n++;
1836 r_ptr->r_cast_spell = MAX_UCHAR;
1838 /* Count unknown flags */
1839 for (i = 0; i < 32; i++)
1841 if (!(r_ptr->r_flags1 & (1L << i)) &&
1842 (r_ptr->flags1 & (1L << i))) n++;
1843 if (!(r_ptr->r_flags2 & (1L << i)) &&
1844 (r_ptr->flags2 & (1L << i))) n++;
1845 if (!(r_ptr->r_flags3 & (1L << i)) &&
1846 (r_ptr->flags3 & (1L << i))) n++;
1847 if (!(r_ptr->r_flags4 & (1L << i)) &&
1848 (r_ptr->flags4 & (1L << i))) n++;
1849 if (!(r_ptr->r_flags5 & (1L << i)) &&
1850 (r_ptr->flags5 & (1L << i))) n++;
1851 if (!(r_ptr->r_flags6 & (1L << i)) &&
1852 (r_ptr->flags6 & (1L << i))) n++;
1853 if (!(r_ptr->r_flagsr & (1L << i)) &&
1854 (r_ptr->flagsr & (1L << i))) n++;
1856 /* r_flags7 is actually unused */
1858 if (!(r_ptr->r_flags7 & (1L << i)) &&
1859 (r_ptr->flags7 & (1L << i))) n++;
1863 /* Know all the flags */
1864 r_ptr->r_flags1 = r_ptr->flags1;
1865 r_ptr->r_flags2 = r_ptr->flags2;
1866 r_ptr->r_flags3 = r_ptr->flags3;
1867 r_ptr->r_flags4 = r_ptr->flags4;
1868 r_ptr->r_flags5 = r_ptr->flags5;
1869 r_ptr->r_flags6 = r_ptr->flags6;
1870 r_ptr->r_flagsr = r_ptr->flagsr;
1872 /* r_flags7 is actually unused */
1873 /* r_ptr->r_flags7 = r_ptr->flags7; */
1875 /* Know about evolution */
1876 if (!(r_ptr->r_xtra1 & MR1_SINKA)) n++;
1877 r_ptr->r_xtra1 |= MR1_SINKA;
1879 /* Update monster recall window */
1880 if (p_ptr->monster_race_idx == r_idx)
1883 p_ptr->window |= (PW_MONSTER);
1886 /* Return the number of new flags learnt */
1892 * @brief モンスターの撃破に伴うドロップ情報の保管処理 / Take note that the given monster just dropped some treasure
1893 * @param m_idx モンスター情報のID
1894 * @param num_item 手に入れたアイテム数
1895 * @param num_gold 手に入れた財宝の単位数
1898 * Note that learning the "GOOD"/"GREAT" flags gives information
1899 * about the treasure (even when the monster is killed for the first
1900 * time, such as uniques, and the treasure has not been examined yet).
1902 * This "indirect" method is used to prevent the player from learning
1903 * exactly how much treasure a monster can drop from observing only
1904 * a single example of a drop. This method actually observes how much
1905 * gold and items are dropped, and remembers that information to be
1906 * described later by the monster recall code.
1908 void lore_treasure(int m_idx, int num_item, int num_gold)
1910 monster_type *m_ptr = &m_list[m_idx];
1912 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1914 /* If the monster doesn't have original appearance, don't note */
1915 if (!is_original_ap(m_ptr)) return;
1917 /* Note the number of things dropped */
1918 if (num_item > r_ptr->r_drop_item) r_ptr->r_drop_item = num_item;
1919 if (num_gold > r_ptr->r_drop_gold) r_ptr->r_drop_gold = num_gold;
1921 /* Hack -- memorize the good/great flags */
1922 if (r_ptr->flags1 & (RF1_DROP_GOOD)) r_ptr->r_flags1 |= (RF1_DROP_GOOD);
1923 if (r_ptr->flags1 & (RF1_DROP_GREAT)) r_ptr->r_flags1 |= (RF1_DROP_GREAT);
1925 /* Update monster recall window */
1926 if (p_ptr->monster_race_idx == m_ptr->r_idx)
1929 p_ptr->window |= (PW_MONSTER);
1935 * @brief ELDRITCH_HORRORによるプレイヤーの精神破壊処理
1936 * @param m_ptr ELDRITCH_HORRORを引き起こしたモンスターの参照ポインタ
1937 * @param necro 暗黒領域魔法の詠唱失敗によるものならばTRUEを返す
1940 void sanity_blast(monster_type *m_ptr, bool necro)
1942 bool happened = FALSE;
1945 if (p_ptr->inside_battle || !character_dungeon) return;
1950 monster_race *r_ptr = &r_info[m_ptr->ap_r_idx];
1952 power = r_ptr->level / 2;
1954 monster_desc(m_name, m_ptr, 0);
1956 if (!(r_ptr->flags1 & RF1_UNIQUE))
1958 if (r_ptr->flags1 & RF1_FRIENDS)
1964 return; /* No effect yet, just loaded... */
1967 return; /* Cannot see it for some reason */
1969 if (!(r_ptr->flags2 & RF2_ELDRITCH_HORROR))
1975 return; /* Pet eldritch horrors are safe most of the time */
1977 if (randint1(100) > power) return;
1979 if (saving_throw(p_ptr->skill_sav - power))
1981 return; /* Save, no adverse effects */
1986 /* Something silly happens... */
1988 msg_format("%s%sの顔を見てしまった!",
1989 funny_desc[randint0(MAX_SAN_FUNNY)], m_name);
1991 msg_format("You behold the %s visage of %s!",
1992 funny_desc[randint0(MAX_SAN_FUNNY)], m_name);
1998 msg_print(funny_comments[randint0(MAX_SAN_COMMENT)]);
1999 p_ptr->image = p_ptr->image + randint1(r_ptr->level);
2002 return; /* Never mind; we can't see it clearly enough */
2005 /* Something frightening happens... */
2007 msg_format("%s%sの顔を見てしまった!",
2008 horror_desc[randint0(MAX_SAN_HORROR)], m_name);
2010 msg_format("You behold the %s visage of %s!",
2011 horror_desc[randint0(MAX_SAN_HORROR)], m_name);
2014 r_ptr->r_flags2 |= RF2_ELDRITCH_HORROR;
2016 /* Demon characters are unaffected */
2017 if (prace_is_(RACE_IMP) || prace_is_(RACE_DEMON) || (mimic_info[p_ptr->mimic_form].MIMIC_FLAGS & MIMIC_IS_DEMON)) return;
2018 if (p_ptr->wizard) return;
2020 /* Undead characters are 50% likely to be unaffected */
2021 if (prace_is_(RACE_SKELETON) || prace_is_(RACE_ZOMBIE)
2022 || prace_is_(RACE_VAMPIRE) || prace_is_(RACE_SPECTRE) ||
2023 (mimic_info[p_ptr->mimic_form].MIMIC_FLAGS & MIMIC_IS_UNDEAD))
2025 if (saving_throw(25 + p_ptr->lev)) return;
2030 msg_print(_("ネクロノミコンを読んで正気を失った!", "Your sanity is shaken by reading the Necronomicon!"));
2033 if (!saving_throw(p_ptr->skill_sav - power)) /* Mind blast */
2035 if (!p_ptr->resist_conf)
2037 (void)set_confused(p_ptr->confused + randint0(4) + 4);
2039 if (!p_ptr->resist_chaos && one_in_(3))
2041 (void)set_image(p_ptr->image + randint0(250) + 150);
2046 if (!saving_throw(p_ptr->skill_sav - power)) /* Lose int & wis */
2053 if (!saving_throw(p_ptr->skill_sav - power)) /* Brain smash */
2055 if (!p_ptr->resist_conf)
2057 (void)set_confused(p_ptr->confused + randint0(4) + 4);
2059 if (!p_ptr->free_act)
2061 (void)set_paralyzed(p_ptr->paralyzed + randint0(4) + 4);
2063 while (randint0(100) > p_ptr->skill_sav)
2064 (void)do_dec_stat(A_INT);
2065 while (randint0(100) > p_ptr->skill_sav)
2066 (void)do_dec_stat(A_WIS);
2067 if (!p_ptr->resist_chaos)
2069 (void)set_image(p_ptr->image + randint0(250) + 150);
2074 if (!saving_throw(p_ptr->skill_sav - power)) /* Amnesia */
2077 if (lose_all_info())
2078 msg_print(_("あまりの恐怖に全てのことを忘れてしまった!", "You forget everything in your utmost terror!"));
2083 if (saving_throw(p_ptr->skill_sav - power))
2088 /* Else gain permanent insanity */
2089 if ((p_ptr->muta3 & MUT3_MORONIC) && /*(p_ptr->muta2 & MUT2_BERS_RAGE) &&*/
2090 ((p_ptr->muta2 & MUT2_COWARDICE) || (p_ptr->resist_fear)) &&
2091 ((p_ptr->muta2 & MUT2_HALLU) || (p_ptr->resist_chaos)))
2093 /* The poor bastard already has all possible insanities! */
2099 switch (randint1(21))
2102 if (!(p_ptr->muta3 & MUT3_MORONIC) && one_in_(5))
2104 if ((p_ptr->stat_use[A_INT] < 4) && (p_ptr->stat_use[A_WIS] < 4))
2106 msg_print(_("あなたは完璧な馬鹿になったような気がした。しかしそれは元々だった。", "You turn into an utter moron!"));
2110 msg_print(_("あなたは完璧な馬鹿になった!", "You turn into an utter moron!"));
2113 if (p_ptr->muta3 & MUT3_HYPER_INT)
2115 msg_print(_("あなたの脳は生体コンピュータではなくなった。", "Your brain is no longer a living computer."));
2116 p_ptr->muta3 &= ~(MUT3_HYPER_INT);
2118 p_ptr->muta3 |= MUT3_MORONIC;
2132 if (!(p_ptr->muta2 & MUT2_COWARDICE) && !p_ptr->resist_fear)
2134 msg_print(_("あなたはパラノイアになった!", "You become paranoid!"));
2136 /* Duh, the following should never happen, but anyway... */
2137 if (p_ptr->muta3 & MUT3_FEARLESS)
2139 msg_print(_("あなたはもう恐れ知らずではなくなった。", "You are no longer fearless."));
2140 p_ptr->muta3 &= ~(MUT3_FEARLESS);
2143 p_ptr->muta2 |= MUT2_COWARDICE;
2157 if (!(p_ptr->muta2 & MUT2_HALLU) && !p_ptr->resist_chaos)
2159 msg_print(_("幻覚をひき起こす精神錯乱に陥った!", "You are afflicted by a hallucinatory insanity!"));
2160 p_ptr->muta2 |= MUT2_HALLU;
2165 if (!(p_ptr->muta2 & MUT2_BERS_RAGE))
2167 msg_print(_("激烈な感情の発作におそわれるようになった!", "You become subject to fits of berserk rage!"));
2168 p_ptr->muta2 |= MUT2_BERS_RAGE;
2175 p_ptr->update |= PU_BONUS;
2180 * @brief モンスターの各情報を更新する / This function updates the monster record of the given monster
2181 * @param m_idx 更新するモンスター情報のID
2182 * @param full プレイヤーとの距離更新を行うならばtrue
2185 * This involves extracting the distance to the player (if requested),
2186 * and then checking for visibility (natural, infravision, see-invis,
2187 * telepathy), updating the monster visibility flag, redrawing (or
2188 * erasing) the monster when its visibility changes, and taking note
2189 * of any interesting monster flags (cold-blooded, invisible, etc).
2191 * Note the new "mflag" field which encodes several monster state flags,
2192 * including "view" for when the monster is currently in line of sight,
2193 * and "mark" for when the monster is currently visible via detection.
2195 * The only monster fields that are changed here are "cdis" (the
2196 * distance from the player), "ml" (visible to the player), and
2197 * "mflag" (to maintain the "MFLAG_VIEW" flag).
2199 * Note the special "update_monsters()" function which can be used to
2200 * call this function once for every monster.
2202 * Note the "full" flag which requests that the "cdis" field be updated,
2203 * this is only needed when the monster (or the player) has moved.
2205 * Every time a monster moves, we must call this function for that
2206 * monster, and update the distance, and the visibility. Every time
2207 * the player moves, we must call this function for every monster, and
2208 * update the distance, and the visibility. Whenever the player "state"
2209 * changes in certain ways ("blindness", "infravision", "telepathy",
2210 * and "see invisible"), we must call this function for every monster,
2211 * and update the visibility.
2213 * Routines that change the "illumination" of a grid must also call this
2214 * function for any monster in that grid, since the "visibility" of some
2215 * monsters may be based on the illumination of their grid.
2217 * Note that this function is called once per monster every time the
2218 * player moves. When the player is running, this function is one
2219 * of the primary bottlenecks, along with "update_view()" and the
2220 * "process_monsters()" code, so efficiency is important.
2222 * Note the optimized "inline" version of the "distance()" function.
2224 * A monster is "visible" to the player if (1) it has been detected
2225 * by the player, (2) it is close to the player and the player has
2226 * telepathy, or (3) it is close to the player, and in line of sight
2227 * of the player, and it is "illuminated" by some combination of
2228 * infravision, torch light, or permanent light (invisible monsters
2229 * are only affected by "light" if the player can see invisible).
2231 * Monsters which are not on the current panel may be "visible" to
2232 * the player, and their descriptions will include an "offscreen"
2233 * reference. Currently, offscreen monsters cannot be targetted
2234 * or viewed directly, but old targets will remain set. XXX XXX
2236 * The player can choose to be disturbed by several things, including
2237 * "disturb_move" (monster which is viewable moves in some way), and
2238 * "disturb_near" (monster which is "easily" viewable moves in some
2239 * way). Note that "moves" includes "appears" and "disappears".
2241 void update_mon(int m_idx, bool full)
2243 monster_type *m_ptr = &m_list[m_idx];
2245 monster_race *r_ptr = &r_info[m_ptr->r_idx];
2247 bool do_disturb = disturb_move;
2251 /* Current location */
2258 /* Seen by vision */
2261 /* Non-Ninja player in the darkness */
2262 bool in_darkness = (d_info[dungeon_type].flags1 & DF1_DARKNESS) && !p_ptr->see_nocto;
2267 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
2269 if (ap_r_ptr->r_tkills && ap_r_ptr->level >= p_ptr->lev)
2273 /* Compute distance */
2276 /* Distance components */
2277 int dy = (py > fy) ? (py - fy) : (fy - py);
2278 int dx = (px > fx) ? (px - fx) : (fx - px);
2280 /* Approximate distance */
2281 d = (dy > dx) ? (dy + (dx>>1)) : (dx + (dy>>1));
2283 /* Restrict distance */
2284 if (d > 255) d = 255;
2288 /* Save the distance */
2292 /* Extract distance */
2295 /* Extract the distance */
2301 if (m_ptr->mflag2 & (MFLAG2_MARK)) flag = TRUE;
2305 if (d <= (in_darkness ? MAX_SIGHT / 2 : MAX_SIGHT))
2307 if (!in_darkness || (d <= MAX_SIGHT / 4))
2309 if (p_ptr->special_defense & KATA_MUSOU)
2314 if (is_original_ap(m_ptr) && !p_ptr->image)
2316 /* Hack -- Memorize mental flags */
2317 if (r_ptr->flags2 & (RF2_SMART)) r_ptr->r_flags2 |= (RF2_SMART);
2318 if (r_ptr->flags2 & (RF2_STUPID)) r_ptr->r_flags2 |= (RF2_STUPID);
2322 /* Basic telepathy */
2323 /* Snipers get telepathy when they concentrate deeper */
2324 else if (p_ptr->telepathy)
2326 /* Empty mind, no telepathy */
2327 if (r_ptr->flags2 & (RF2_EMPTY_MIND))
2329 /* Memorize flags */
2330 if (is_original_ap(m_ptr) && !p_ptr->image) r_ptr->r_flags2 |= (RF2_EMPTY_MIND);
2333 /* Weird mind, occasional telepathy */
2334 else if (r_ptr->flags2 & (RF2_WEIRD_MIND))
2336 /* One in ten individuals are detectable */
2337 if ((m_idx % 10) == 5)
2342 if (is_original_ap(m_ptr) && !p_ptr->image)
2344 /* Memorize flags */
2345 r_ptr->r_flags2 |= (RF2_WEIRD_MIND);
2347 /* Hack -- Memorize mental flags */
2348 if (r_ptr->flags2 & (RF2_SMART)) r_ptr->r_flags2 |= (RF2_SMART);
2349 if (r_ptr->flags2 & (RF2_STUPID)) r_ptr->r_flags2 |= (RF2_STUPID);
2354 /* Normal mind, allow telepathy */
2360 if (is_original_ap(m_ptr) && !p_ptr->image)
2362 /* Hack -- Memorize mental flags */
2363 if (r_ptr->flags2 & (RF2_SMART)) r_ptr->r_flags2 |= (RF2_SMART);
2364 if (r_ptr->flags2 & (RF2_STUPID)) r_ptr->r_flags2 |= (RF2_STUPID);
2369 /* Magical sensing */
2370 if ((p_ptr->esp_animal) && (r_ptr->flags3 & (RF3_ANIMAL)))
2373 if (is_original_ap(m_ptr) && !p_ptr->image) r_ptr->r_flags3 |= (RF3_ANIMAL);
2376 /* Magical sensing */
2377 if ((p_ptr->esp_undead) && (r_ptr->flags3 & (RF3_UNDEAD)))
2380 if (is_original_ap(m_ptr) && !p_ptr->image) r_ptr->r_flags3 |= (RF3_UNDEAD);
2383 /* Magical sensing */
2384 if ((p_ptr->esp_demon) && (r_ptr->flags3 & (RF3_DEMON)))
2387 if (is_original_ap(m_ptr) && !p_ptr->image) r_ptr->r_flags3 |= (RF3_DEMON);
2390 /* Magical sensing */
2391 if ((p_ptr->esp_orc) && (r_ptr->flags3 & (RF3_ORC)))
2394 if (is_original_ap(m_ptr) && !p_ptr->image) r_ptr->r_flags3 |= (RF3_ORC);
2397 /* Magical sensing */
2398 if ((p_ptr->esp_troll) && (r_ptr->flags3 & (RF3_TROLL)))
2401 if (is_original_ap(m_ptr) && !p_ptr->image) r_ptr->r_flags3 |= (RF3_TROLL);
2404 /* Magical sensing */
2405 if ((p_ptr->esp_giant) && (r_ptr->flags3 & (RF3_GIANT)))
2408 if (is_original_ap(m_ptr) && !p_ptr->image) r_ptr->r_flags3 |= (RF3_GIANT);
2411 /* Magical sensing */
2412 if ((p_ptr->esp_dragon) && (r_ptr->flags3 & (RF3_DRAGON)))
2415 if (is_original_ap(m_ptr) && !p_ptr->image) r_ptr->r_flags3 |= (RF3_DRAGON);
2418 /* Magical sensing */
2419 if ((p_ptr->esp_human) && (r_ptr->flags2 & (RF2_HUMAN)))
2422 if (is_original_ap(m_ptr) && !p_ptr->image) r_ptr->r_flags2 |= (RF2_HUMAN);
2425 /* Magical sensing */
2426 if ((p_ptr->esp_evil) && (r_ptr->flags3 & (RF3_EVIL)))
2429 if (is_original_ap(m_ptr) && !p_ptr->image) r_ptr->r_flags3 |= (RF3_EVIL);
2432 /* Magical sensing */
2433 if ((p_ptr->esp_good) && (r_ptr->flags3 & (RF3_GOOD)))
2436 if (is_original_ap(m_ptr) && !p_ptr->image) r_ptr->r_flags3 |= (RF3_GOOD);
2439 /* Magical sensing */
2440 if ((p_ptr->esp_nonliving) &&
2441 ((r_ptr->flags3 & (RF3_DEMON | RF3_UNDEAD | RF3_NONLIVING)) == RF3_NONLIVING))
2444 if (is_original_ap(m_ptr) && !p_ptr->image) r_ptr->r_flags3 |= (RF3_NONLIVING);
2447 /* Magical sensing */
2448 if ((p_ptr->esp_unique) && (r_ptr->flags1 & (RF1_UNIQUE)))
2451 if (is_original_ap(m_ptr) && !p_ptr->image) r_ptr->r_flags1 |= (RF1_UNIQUE);
2455 /* Normal line of sight, and not blind */
2456 if (player_has_los_bold(fy, fx) && !p_ptr->blind)
2458 bool do_invisible = FALSE;
2459 bool do_cold_blood = FALSE;
2461 /* Snipers can see targets in darkness when they concentrate deeper */
2462 if (p_ptr->concent >= CONCENT_RADAR_THRESHOLD)
2468 /* Use "infravision" */
2469 if (d <= p_ptr->see_infra)
2471 /* Handle "cold blooded" monsters */
2472 if ((r_ptr->flags2 & (RF2_COLD_BLOOD | RF2_AURA_FIRE)) == RF2_COLD_BLOOD)
2475 do_cold_blood = TRUE;
2478 /* Handle "warm blooded" monsters */
2486 /* Use "illumination" */
2487 if (player_can_see_bold(fy, fx))
2489 /* Handle "invisible" monsters */
2490 if (r_ptr->flags2 & (RF2_INVISIBLE))
2493 do_invisible = TRUE;
2503 /* Handle "normal" monsters */
2514 if (is_original_ap(m_ptr) && !p_ptr->image)
2516 /* Memorize flags */
2517 if (do_invisible) r_ptr->r_flags2 |= (RF2_INVISIBLE);
2518 if (do_cold_blood) r_ptr->r_flags2 |= (RF2_COLD_BLOOD);
2525 /* The monster is now visible */
2528 /* It was previously unseen */
2531 /* Mark as visible */
2534 /* Draw the monster */
2537 /* Update health bar as needed */
2538 if (p_ptr->health_who == m_idx) p_ptr->redraw |= (PR_HEALTH);
2539 if (p_ptr->riding == m_idx) p_ptr->redraw |= (PR_UHEALTH);
2541 /* Hack -- Count "fresh" sightings */
2544 if ((m_ptr->ap_r_idx == MON_KAGE) && (r_info[MON_KAGE].r_sights < MAX_SHORT))
2545 r_info[MON_KAGE].r_sights++;
2546 else if (is_original_ap(m_ptr) && (r_ptr->r_sights < MAX_SHORT))
2550 /* Eldritch Horror */
2551 if (r_info[m_ptr->ap_r_idx].flags2 & RF2_ELDRITCH_HORROR)
2553 sanity_blast(m_ptr, FALSE);
2556 /* Disturb on appearance */
2557 if (disturb_near && (projectable(m_ptr->fy, m_ptr->fx, py, px) && projectable(py, px, m_ptr->fy, m_ptr->fx)))
2559 if (disturb_pets || is_hostile(m_ptr))
2565 /* The monster is not visible */
2568 /* It was previously seen */
2571 /* Mark as not visible */
2574 /* Erase the monster */
2577 /* Update health bar as needed */
2578 if (p_ptr->health_who == m_idx) p_ptr->redraw |= (PR_HEALTH);
2579 if (p_ptr->riding == m_idx) p_ptr->redraw |= (PR_UHEALTH);
2581 /* Disturb on disappearance */
2584 if (disturb_pets || is_hostile(m_ptr))
2591 /* The monster is now easily visible */
2595 if (!(m_ptr->mflag & (MFLAG_VIEW)))
2597 /* Mark as easily visible */
2598 m_ptr->mflag |= (MFLAG_VIEW);
2600 /* Disturb on appearance */
2603 if (disturb_pets || is_hostile(m_ptr))
2609 /* The monster is not easily visible */
2613 if (m_ptr->mflag & (MFLAG_VIEW))
2615 /* Mark as not easily visible */
2616 m_ptr->mflag &= ~(MFLAG_VIEW);
2618 /* Disturb on disappearance */
2621 if (disturb_pets || is_hostile(m_ptr))
2630 * @brief 単純に生存している全モンスターの更新処理を行う / This function simply updates all the (non-dead) monsters (see above).
2631 * @param full 距離更新を行うならtrue
2634 void update_monsters(bool full)
2638 /* Update each (live) monster */
2639 for (i = 1; i < m_max; i++)
2641 monster_type *m_ptr = &m_list[i];
2643 /* Skip dead monsters */
2644 if (!m_ptr->r_idx) continue;
2646 /* Update the monster */
2647 update_mon(i, full);
2653 * @brief カメレオンの王の変身対象となるモンスターかどうか判定する / Hack -- the index of the summoning monster
2654 * @param r_idx モンスター種族ID
2655 * @return 対象にできるならtrueを返す
2657 static bool monster_hook_chameleon_lord(int r_idx)
2659 monster_race *r_ptr = &r_info[r_idx];
2660 monster_type *m_ptr = &m_list[chameleon_change_m_idx];
2661 monster_race *old_r_ptr = &r_info[m_ptr->r_idx];
2663 if (!(r_ptr->flags1 & (RF1_UNIQUE))) return FALSE;
2664 if (r_ptr->flags7 & (RF7_FRIENDLY | RF7_CHAMELEON)) return FALSE;
2666 if (ABS(r_ptr->level - r_info[MON_CHAMELEON_K].level) > 5) return FALSE;
2668 if ((r_ptr->blow[0].method == RBM_EXPLODE) || (r_ptr->blow[1].method == RBM_EXPLODE) || (r_ptr->blow[2].method == RBM_EXPLODE) || (r_ptr->blow[3].method == RBM_EXPLODE))
2671 if (!monster_can_cross_terrain(cave[m_ptr->fy][m_ptr->fx].feat, r_ptr, 0)) return FALSE;
2674 if (!(old_r_ptr->flags7 & RF7_CHAMELEON))
2676 if (monster_has_hostile_align(m_ptr, 0, 0, r_ptr)) return FALSE;
2680 else if (summon_specific_who > 0)
2682 if (monster_has_hostile_align(&m_list[summon_specific_who], 0, 0, r_ptr)) return FALSE;
2689 * @brief カメレオンの変身対象となるモンスターかどうか判定する / Hack -- the index of the summoning monster
2690 * @param r_idx モンスター種族ID
2691 * @return 対象にできるならtrueを返す
2693 static bool monster_hook_chameleon(int r_idx)
2695 monster_race *r_ptr = &r_info[r_idx];
2696 monster_type *m_ptr = &m_list[chameleon_change_m_idx];
2697 monster_race *old_r_ptr = &r_info[m_ptr->r_idx];
2699 if (r_ptr->flags1 & (RF1_UNIQUE)) return FALSE;
2700 if (r_ptr->flags2 & RF2_MULTIPLY) return FALSE;
2701 if (r_ptr->flags7 & (RF7_FRIENDLY | RF7_CHAMELEON)) return FALSE;
2703 if ((r_ptr->blow[0].method == RBM_EXPLODE) || (r_ptr->blow[1].method == RBM_EXPLODE) || (r_ptr->blow[2].method == RBM_EXPLODE) || (r_ptr->blow[3].method == RBM_EXPLODE))
2706 if (!monster_can_cross_terrain(cave[m_ptr->fy][m_ptr->fx].feat, r_ptr, 0)) return FALSE;
2709 if (!(old_r_ptr->flags7 & RF7_CHAMELEON))
2711 if ((old_r_ptr->flags3 & RF3_GOOD) && !(r_ptr->flags3 & RF3_GOOD)) return FALSE;
2712 if ((old_r_ptr->flags3 & RF3_EVIL) && !(r_ptr->flags3 & RF3_EVIL)) return FALSE;
2713 if (!(old_r_ptr->flags3 & (RF3_GOOD | RF3_EVIL)) && (r_ptr->flags3 & (RF3_GOOD | RF3_EVIL))) return FALSE;
2717 else if (summon_specific_who > 0)
2719 if (monster_has_hostile_align(&m_list[summon_specific_who], 0, 0, r_ptr)) return FALSE;
2722 return (*(get_monster_hook()))(r_idx);
2727 * @param m_idx 変身処理を受けるモンスター情報のID
2728 * @param born 生成時の初変身先指定ならばtrue
2729 * @param r_idx 旧モンスター種族のID
2732 void choose_new_monster(int m_idx, bool born, int r_idx)
2735 monster_type *m_ptr = &m_list[m_idx];
2736 monster_race *r_ptr;
2737 char old_m_name[80];
2738 bool old_unique = FALSE;
2739 int old_r_idx = m_ptr->r_idx;
2741 if (r_info[m_ptr->r_idx].flags1 & RF1_UNIQUE)
2743 if (old_unique && (r_idx == MON_CHAMELEON)) r_idx = MON_CHAMELEON_K;
2744 r_ptr = &r_info[r_idx];
2746 monster_desc(old_m_name, m_ptr, 0);
2752 chameleon_change_m_idx = m_idx;
2754 get_mon_num_prep(monster_hook_chameleon_lord, NULL);
2756 get_mon_num_prep(monster_hook_chameleon, NULL);
2759 level = r_info[MON_CHAMELEON_K].level;
2760 else if (!dun_level)
2761 level = wilderness[p_ptr->wilderness_y][p_ptr->wilderness_x].level;
2765 if (d_info[dungeon_type].flags1 & DF1_CHAMELEON) level+= 2+randint1(3);
2767 r_idx = get_mon_num(level);
2768 r_ptr = &r_info[r_idx];
2770 chameleon_change_m_idx = 0;
2776 if (is_pet(m_ptr)) check_pets_num_and_align(m_ptr, FALSE);
2778 m_ptr->r_idx = r_idx;
2779 m_ptr->ap_r_idx = r_idx;
2780 update_mon(m_idx, FALSE);
2781 lite_spot(m_ptr->fy, m_ptr->fx);
2783 if ((r_info[old_r_idx].flags7 & (RF7_LITE_MASK | RF7_DARK_MASK)) ||
2784 (r_ptr->flags7 & (RF7_LITE_MASK | RF7_DARK_MASK)))
2785 p_ptr->update |= (PU_MON_LITE);
2787 if (is_pet(m_ptr)) check_pets_num_and_align(m_ptr, TRUE);
2791 /* Sub-alignment of a chameleon */
2792 if (r_ptr->flags3 & (RF3_EVIL | RF3_GOOD))
2794 m_ptr->sub_align = SUB_ALIGN_NEUTRAL;
2795 if (r_ptr->flags3 & RF3_EVIL) m_ptr->sub_align |= SUB_ALIGN_EVIL;
2796 if (r_ptr->flags3 & RF3_GOOD) m_ptr->sub_align |= SUB_ALIGN_GOOD;
2801 if (m_idx == p_ptr->riding)
2804 monster_desc(m_name, m_ptr, 0);
2805 msg_format(_("突然%sが変身した。", "Suddenly, %s transforms!"), old_m_name);
2806 if (!(r_ptr->flags7 & RF7_RIDING))
2807 if (rakuba(0, TRUE)) msg_format(_("地面に落とされた。", "You have fallen from %s."), m_name);
2810 /* Extract the monster base speed */
2811 m_ptr->mspeed = get_mspeed(r_ptr);
2813 oldmaxhp = m_ptr->max_maxhp;
2814 /* Assign maximal hitpoints */
2815 if (r_ptr->flags1 & RF1_FORCE_MAXHP)
2817 m_ptr->max_maxhp = maxroll(r_ptr->hdice, r_ptr->hside);
2821 m_ptr->max_maxhp = damroll(r_ptr->hdice, r_ptr->hside);
2824 /* Monsters have double hitpoints in Nightmare mode */
2825 if (ironman_nightmare)
2827 u32b hp = m_ptr->max_maxhp * 2L;
2828 m_ptr->max_maxhp = (s16b)MIN(30000, hp);
2831 m_ptr->maxhp = (long)(m_ptr->maxhp * m_ptr->max_maxhp) / oldmaxhp;
2832 if (m_ptr->maxhp < 1) m_ptr->maxhp = 1;
2833 m_ptr->hp = (long)(m_ptr->hp * m_ptr->max_maxhp) / oldmaxhp;
2835 /* reset dealt_damage */
2836 m_ptr->dealt_damage = 0;
2841 * @brief たぬきの変身対象となるモンスターかどうか判定する / Hook for Tanuki
2842 * @param r_idx モンスター種族ID
2843 * @return 対象にできるならtrueを返す
2845 static bool monster_hook_tanuki(int r_idx)
2847 monster_race *r_ptr = &r_info[r_idx];
2849 if (r_ptr->flags1 & (RF1_UNIQUE)) return FALSE;
2850 if (r_ptr->flags2 & RF2_MULTIPLY) return FALSE;
2851 if (r_ptr->flags7 & (RF7_FRIENDLY | RF7_CHAMELEON)) return FALSE;
2852 if (r_ptr->flags7 & RF7_AQUATIC) return FALSE;
2854 if ((r_ptr->blow[0].method == RBM_EXPLODE) || (r_ptr->blow[1].method == RBM_EXPLODE) || (r_ptr->blow[2].method == RBM_EXPLODE) || (r_ptr->blow[3].method == RBM_EXPLODE))
2857 return (*(get_monster_hook()))(r_idx);
2862 * @brief モンスターの表層IDを設定する / Set initial racial appearance of a monster
2863 * @param r_idx モンスター種族ID
2864 * @return モンスター種族の表層ID
2866 static int initial_r_appearance(int r_idx)
2868 int attempts = 1000;
2871 int min = MIN(base_level-5, 50);
2873 if (!(r_info[r_idx].flags7 & RF7_TANUKI))
2876 get_mon_num_prep(monster_hook_tanuki, NULL);
2880 ap_r_idx = get_mon_num(base_level + 10);
2881 if (r_info[ap_r_idx].level >= min) return ap_r_idx;
2889 * @brief モンスターの個体加速を設定する / Get initial monster spee\d
2890 * @param r_ptr モンスター種族の参照ポインタ
2893 byte get_mspeed(monster_race *r_ptr)
2895 /* Extract the monster base speed */
2896 int mspeed = r_ptr->speed;
2898 /* Hack -- small racial variety */
2899 if (!(r_ptr->flags1 & RF1_UNIQUE) && !p_ptr->inside_arena)
2901 /* Allow some small variation per monster */
2902 int i = SPEED_TO_ENERGY(r_ptr->speed) / (one_in_(4) ? 3 : 10);
2903 if (i) mspeed += rand_spread(0, i);
2906 if (mspeed > 199) mspeed = 199;
2908 return (byte)mspeed;
2913 * @brief モンスターを一体生成する / Attempt to place a monster of the given race at the given location.
2914 * @param who 召喚を行ったモンスターID
2917 * @param r_idx 生成モンスター種族
2918 * @param mode 生成オプション
2921 * To give the player a sporting chance, any monster that appears in
2922 * line-of-sight and is extremely dangerous can be marked as
2923 * "FORCE_SLEEP", which will cause them to be placed with low energy,
2924 * which often (but not always) lets the player move before they do.
2926 * This routine refuses to place out-of-depth "FORCE_DEPTH" monsters.
2928 * XXX XXX XXX Use special "here" and "dead" flags for unique monsters,
2929 * remove old "cur_num" and "max_num" fields.
2931 * XXX XXX XXX Actually, do something similar for artifacts, to simplify
2932 * the "preserve" mode, and to make the "what artifacts" flag more useful.
2934 * This is the only function which may place a monster in the dungeon,
2935 * except for the savefile loading code.
2937 static bool place_monster_one(int who, int y, int x, int r_idx, u32b mode)
2939 /* Access the location */
2940 cave_type *c_ptr = &cave[y][x];
2942 monster_type *m_ptr;
2944 monster_race *r_ptr = &r_info[r_idx];
2946 cptr name = (r_name + r_ptr->name);
2950 /* DO NOT PLACE A MONSTER IN THE SMALL SCALE WILDERNESS !!! */
2951 if (p_ptr->wild_mode) return FALSE;
2953 /* Verify location */
2954 if (!in_bounds(y, x)) return (FALSE);
2957 if (!r_idx) return (FALSE);
2960 if (!r_ptr->name) return (FALSE);
2962 if (!(mode & PM_IGNORE_TERRAIN))
2964 /* Not on the Pattern */
2965 if (pattern_tile(y, x)) return FALSE;
2967 /* Require empty space (if not ghostly) */
2968 if (!monster_can_enter(y, x, r_ptr, 0)) return FALSE;
2971 if (!p_ptr->inside_battle)
2973 /* Hack -- "unique" monsters must be "unique" */
2974 if (((r_ptr->flags1 & (RF1_UNIQUE)) ||
2975 (r_ptr->flags7 & (RF7_NAZGUL))) &&
2976 (r_ptr->cur_num >= r_ptr->max_num))
2982 if ((r_ptr->flags7 & (RF7_UNIQUE2)) &&
2983 (r_ptr->cur_num >= 1))
2988 if (r_idx == MON_BANORLUPART)
2990 if (r_info[MON_BANOR].cur_num > 0) return FALSE;
2991 if (r_info[MON_LUPART].cur_num > 0) return FALSE;
2994 /* Depth monsters may NOT be created out of depth, unless in Nightmare mode */
2995 if ((r_ptr->flags1 & (RF1_FORCE_DEPTH)) && (dun_level < r_ptr->level) &&
2996 (!ironman_nightmare || (r_ptr->flags1 & (RF1_QUESTOR))))
3003 if (quest_number(dun_level))
3005 int hoge = quest_number(dun_level);
3006 if ((quest[hoge].type == QUEST_TYPE_KILL_LEVEL) || (quest[hoge].type == QUEST_TYPE_RANDOM))
3008 if(r_idx == quest[hoge].r_idx)
3010 int number_mon, i2, j2;
3013 /* Count all quest monsters */
3014 for (i2 = 0; i2 < cur_wid; ++i2)
3015 for (j2 = 0; j2 < cur_hgt; j2++)
3016 if (cave[j2][i2].m_idx > 0)
3017 if (m_list[cave[j2][i2].m_idx].r_idx == quest[hoge].r_idx)
3019 if(number_mon + quest[hoge].cur_num >= quest[hoge].max_num)
3025 if (is_glyph_grid(c_ptr))
3027 if (randint1(BREAK_GLYPH) < (r_ptr->level+20))
3029 /* Describe observable breakage */
3030 if (c_ptr->info & CAVE_MARK)
3032 msg_print(_("守りのルーンが壊れた!", "The rune of protection is broken!"));
3035 /* Forget the rune */
3036 c_ptr->info &= ~(CAVE_MARK);
3038 /* Break the rune */
3039 c_ptr->info &= ~(CAVE_OBJECT);
3048 /* Powerful monster */
3049 if (r_ptr->level > dun_level)
3051 /* Unique monsters */
3052 if (r_ptr->flags1 & (RF1_UNIQUE))
3054 /* Message for cheaters */
3055 if (cheat_hear) msg_format(_("深層のユニーク・モンスター (%s)。", "Deep Unique (%s)."), name);
3058 /* Normal monsters */
3061 /* Message for cheaters */
3062 if (cheat_hear) msg_format(_("深層のモンスター (%s)。", "Deep Monster (%s)."), name);
3066 /* Note the monster */
3067 else if (r_ptr->flags1 & (RF1_UNIQUE))
3069 /* Unique monsters induce message */
3070 if (cheat_hear) msg_format(_("ユニーク・モンスター (%s)。", "Unique (%s)."), name);
3073 if ((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags7 & RF7_NAZGUL) || (r_ptr->level < 10)) mode &= ~PM_KAGE;
3075 /* Make a new monster */
3076 c_ptr->m_idx = m_pop();
3077 hack_m_idx_ii = c_ptr->m_idx;
3079 /* Mega-Hack -- catch "failure" */
3080 if (!c_ptr->m_idx) return (FALSE);
3083 /* Get a new monster record */
3084 m_ptr = &m_list[c_ptr->m_idx];
3087 m_ptr->r_idx = r_idx;
3088 m_ptr->ap_r_idx = initial_r_appearance(r_idx);
3094 /* Hack -- Appearance transfer */
3095 if ((mode & PM_MULTIPLY) && (who > 0) && !is_original_ap(&m_list[who]))
3097 m_ptr->ap_r_idx = m_list[who].ap_r_idx;
3099 /* Hack -- Shadower spawns Shadower */
3100 if (m_list[who].mflag2 & MFLAG2_KAGE) m_ptr->mflag2 |= MFLAG2_KAGE;
3103 /* Sub-alignment of a monster */
3104 if ((who > 0) && !(r_ptr->flags3 & (RF3_EVIL | RF3_GOOD)))
3105 m_ptr->sub_align = m_list[who].sub_align;
3108 m_ptr->sub_align = SUB_ALIGN_NEUTRAL;
3109 if (r_ptr->flags3 & RF3_EVIL) m_ptr->sub_align |= SUB_ALIGN_EVIL;
3110 if (r_ptr->flags3 & RF3_GOOD) m_ptr->sub_align |= SUB_ALIGN_GOOD;
3113 /* Place the monster at the location */
3118 /* No "timed status" yet */
3119 for (cmi = 0; cmi < MAX_MTIMED; cmi++) m_ptr->mtimed[cmi] = 0;
3121 /* Unknown distance */
3124 reset_target(m_ptr);
3126 m_ptr->nickname = 0;
3131 /* Your pet summons its pet. */
3132 if (who > 0 && is_pet(&m_list[who]))
3134 mode |= PM_FORCE_PET;
3135 m_ptr->parent_m_idx = who;
3139 m_ptr->parent_m_idx = 0;
3142 if (r_ptr->flags7 & RF7_CHAMELEON)
3144 choose_new_monster(c_ptr->m_idx, TRUE, 0);
3145 r_ptr = &r_info[m_ptr->r_idx];
3146 m_ptr->mflag2 |= MFLAG2_CHAMELEON;
3148 /* Hack - Set sub_align to neutral when the Chameleon Lord is generated as "GUARDIAN" */
3149 if ((r_ptr->flags1 & RF1_UNIQUE) && (who <= 0))
3150 m_ptr->sub_align = SUB_ALIGN_NEUTRAL;
3152 else if ((mode & PM_KAGE) && !(mode & PM_FORCE_PET))
3154 m_ptr->ap_r_idx = MON_KAGE;
3155 m_ptr->mflag2 |= MFLAG2_KAGE;
3158 if (mode & PM_NO_PET) m_ptr->mflag2 |= MFLAG2_NOPET;
3164 if (mode & PM_FORCE_PET)
3169 else if ((r_ptr->flags7 & RF7_FRIENDLY) ||
3170 (mode & PM_FORCE_FRIENDLY) || is_friendly_idx(who))
3172 if (!monster_has_hostile_align(NULL, 0, -1, r_ptr)) set_friendly(m_ptr);
3175 /* Assume no sleeping */
3176 m_ptr->mtimed[MTIMED_CSLEEP] = 0;
3178 /* Enforce sleeping if needed */
3179 if ((mode & PM_ALLOW_SLEEP) && r_ptr->sleep && !ironman_nightmare)
3181 int val = r_ptr->sleep;
3182 (void)set_monster_csleep(c_ptr->m_idx, (val * 2) + randint1(val * 10));
3185 /* Assign maximal hitpoints */
3186 if (r_ptr->flags1 & RF1_FORCE_MAXHP)
3188 m_ptr->max_maxhp = maxroll(r_ptr->hdice, r_ptr->hside);
3192 m_ptr->max_maxhp = damroll(r_ptr->hdice, r_ptr->hside);
3195 /* Monsters have double hitpoints in Nightmare mode */
3196 if (ironman_nightmare)
3198 u32b hp = m_ptr->max_maxhp * 2L;
3200 m_ptr->max_maxhp = (s16b)MIN(30000, hp);
3203 m_ptr->maxhp = m_ptr->max_maxhp;
3205 /* And start out fully healthy */
3206 if (m_ptr->r_idx == MON_WOUNDED_BEAR)
3207 m_ptr->hp = m_ptr->maxhp / 2;
3208 else m_ptr->hp = m_ptr->maxhp;
3211 /* dealt damage is 0 at initial*/
3212 m_ptr->dealt_damage = 0;
3215 /* Extract the monster base speed */
3216 m_ptr->mspeed = get_mspeed(r_ptr);
3218 if (mode & PM_HASTE) (void)set_monster_fast(c_ptr->m_idx, 100);
3220 /* Give a random starting energy */
3221 if (!ironman_nightmare)
3223 m_ptr->energy_need = ENERGY_NEED() - (s16b)randint0(100);
3227 /* Nightmare monsters are more prepared */
3228 m_ptr->energy_need = ENERGY_NEED() - (s16b)randint0(100) * 2;
3231 /* Force monster to wait for player, unless in Nightmare mode */
3232 if ((r_ptr->flags1 & RF1_FORCE_SLEEP) && !ironman_nightmare)
3234 /* Monster is still being nice */
3235 m_ptr->mflag |= (MFLAG_NICE);
3237 /* Must repair monsters */
3238 repair_monsters = TRUE;
3241 /* Hack -- see "process_monsters()" */
3242 if (c_ptr->m_idx < hack_m_idx)
3244 /* Monster is still being born */
3245 m_ptr->mflag |= (MFLAG_BORN);
3249 if (r_ptr->flags7 & RF7_SELF_LD_MASK)
3250 p_ptr->update |= (PU_MON_LITE);
3251 else if ((r_ptr->flags7 & RF7_HAS_LD_MASK) && !MON_CSLEEP(m_ptr))
3252 p_ptr->update |= (PU_MON_LITE);
3254 /* Update the monster */
3255 update_mon(c_ptr->m_idx, TRUE);
3258 /* Count the monsters on the level */
3259 real_r_ptr(m_ptr)->cur_num++;
3262 * Memorize location of the unique monster in saved floors.
3263 * A unique monster move from old saved floor.
3265 if (character_dungeon &&
3266 ((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags7 & RF7_NAZGUL)))
3267 real_r_ptr(m_ptr)->floor_id = p_ptr->floor_id;
3269 /* Hack -- Count the number of "reproducers" */
3270 if (r_ptr->flags2 & RF2_MULTIPLY) num_repro++;
3272 /* Hack -- Notice new multi-hued monsters */
3274 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
3275 if (ap_r_ptr->flags1 & (RF1_ATTR_MULTI | RF1_SHAPECHANGER))
3276 shimmer_monsters = TRUE;
3279 if (p_ptr->warning && character_dungeon)
3281 if (r_ptr->flags1 & RF1_UNIQUE)
3285 char o_name[MAX_NLEN];
3287 if (r_ptr->level > p_ptr->lev + 30)
3288 color = _("黒く", "black");
3289 else if (r_ptr->level > p_ptr->lev + 15)
3290 color = _("紫色に", "purple");
3291 else if (r_ptr->level > p_ptr->lev + 5)
3292 color = _("ルビー色に", "deep red");
3293 else if (r_ptr->level > p_ptr->lev - 5)
3294 color = _("赤く", "red");
3295 else if (r_ptr->level > p_ptr->lev - 15)
3296 color = _("ピンク色に", "pink");
3298 color = _("白く", "white");
3300 o_ptr = choose_warning_item();
3303 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
3304 msg_format(_("%sは%s光った。", "%s glows %s."), o_name, color);
3308 msg_format(_("%s光る物が頭に浮かんだ。", "An %s image forms in your mind."), color);
3313 if (is_explosive_rune_grid(c_ptr))
3315 /* Break the ward */
3316 if (randint1(BREAK_MINOR_GLYPH) > r_ptr->level)
3318 /* Describe observable breakage */
3319 if (c_ptr->info & CAVE_MARK)
3321 msg_print(_("ルーンが爆発した!", "The rune explodes!"));
3322 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);
3327 msg_print(_("爆発のルーンは解除された。", "An explosive rune was disarmed."));
3330 /* Forget the rune */
3331 c_ptr->info &= ~(CAVE_MARK);
3333 /* Break the rune */
3334 c_ptr->info &= ~(CAVE_OBJECT);
3347 #define MON_SCAT_MAXD 10
3350 * @brief モンスター1体を目標地点に可能ながり近い位置に生成する / improved version of scatter() for place monster
3351 * @param r_idx 生成モンスター種族
3352 * @param yp 結果生成位置y座標
3353 * @param xp 結果生成位置x座標
3354 * @param y 中心生成位置y座標
3355 * @param x 中心生成位置x座標
3356 * @param max_dist 生成位置の最大半径
3360 static bool mon_scatter(int r_idx, int *yp, int *xp, int y, int x, int max_dist)
3362 int place_x[MON_SCAT_MAXD];
3363 int place_y[MON_SCAT_MAXD];
3364 int num[MON_SCAT_MAXD];
3368 if (max_dist >= MON_SCAT_MAXD)
3371 for (i = 0; i < MON_SCAT_MAXD; i++)
3374 for (nx = x - max_dist; nx <= x + max_dist; nx++)
3376 for (ny = y - max_dist; ny <= y + max_dist; ny++)
3378 /* Ignore annoying locations */
3379 if (!in_bounds(ny, nx)) continue;
3381 /* Require "line of projection" */
3382 if (!projectable(y, x, ny, nx)) continue;
3386 monster_race *r_ptr = &r_info[r_idx];
3388 /* Require empty space (if not ghostly) */
3389 if (!monster_can_enter(ny, nx, r_ptr, 0))
3394 /* Walls and Monsters block flow */
3395 if (!cave_empty_bold2(ny, nx)) continue;
3397 /* ... nor on the Pattern */
3398 if (pattern_tile(ny, nx)) continue;
3401 i = distance(y, x, ny, nx);
3409 if (one_in_(num[i]))
3418 while (i < MON_SCAT_MAXD && 0 == num[i])
3420 if (i >= MON_SCAT_MAXD)
3431 * Maximum size of a group of monsters
3433 #define GROUP_MAX 32
3436 * @brief モンスターを目標地点に集団生成する / Attempt to place a "group" of monsters around the given location
3437 * @param who 召喚主のモンスター情報ID
3438 * @param y 中心生成位置y座標
3439 * @param x 中心生成位置x座標
3440 * @param r_idx 生成モンスター種族
3441 * @param mode 生成オプション
3444 static bool place_monster_group(int who, int y, int x, int r_idx, u32b mode)
3446 monster_race *r_ptr = &r_info[r_idx];
3449 int total = 0, extra = 0;
3453 byte hack_y[GROUP_MAX];
3454 byte hack_x[GROUP_MAX];
3457 /* Pick a group size */
3458 total = randint1(10);
3460 /* Hard monsters, small groups */
3461 if (r_ptr->level > dun_level)
3463 extra = r_ptr->level - dun_level;
3464 extra = 0 - randint1(extra);
3467 /* Easy monsters, large groups */
3468 else if (r_ptr->level < dun_level)
3470 extra = dun_level - r_ptr->level;
3471 extra = randint1(extra);
3474 /* Hack -- limit group reduction */
3475 if (extra > 9) extra = 9;
3477 /* Modify the group size */
3481 if (total < 1) total = 1;
3484 if (total > GROUP_MAX) total = GROUP_MAX;
3487 /* Start on the monster */
3492 /* Puddle monsters, breadth first, up to total */
3493 for (n = 0; (n < hack_n) && (hack_n < total); n++)
3495 /* Grab the location */
3499 /* Check each direction, up to total */
3500 for (i = 0; (i < 8) && (hack_n < total); i++)
3504 scatter(&my, &mx, hy, hx, 4, 0);
3506 /* Walls and Monsters block flow */
3507 if (!cave_empty_bold2(my, mx)) continue;
3509 /* Attempt to place another monster */
3510 if (place_monster_one(who, my, mx, r_idx, mode))
3512 /* Add it to the "hack" set */
3513 hack_y[hack_n] = my;
3514 hack_x[hack_n] = mx;
3527 * Hack -- help pick an escort type
3529 static int place_monster_idx = 0;
3530 static int place_monster_m_idx = 0;
3533 * @brief モンスター種族が召喚主の護衛となれるかどうかをチェックする / Hack -- help pick an escort type
3534 * @param r_idx チェックするモンスター種族のID
3535 * @return 護衛にできるならばtrue
3537 static bool place_monster_okay(int r_idx)
3539 monster_race *r_ptr = &r_info[place_monster_idx];
3540 monster_type *m_ptr = &m_list[place_monster_m_idx];
3542 monster_race *z_ptr = &r_info[r_idx];
3544 /* Hack - Escorts have to have the same dungeon flag */
3545 if (mon_hook_dungeon(place_monster_idx) != mon_hook_dungeon(r_idx)) return (FALSE);
3547 /* Require similar "race" */
3548 if (z_ptr->d_char != r_ptr->d_char) return (FALSE);
3550 /* Skip more advanced monsters */
3551 if (z_ptr->level > r_ptr->level) return (FALSE);
3553 /* Skip unique monsters */
3554 if (z_ptr->flags1 & RF1_UNIQUE) return (FALSE);
3556 /* Paranoia -- Skip identical monsters */
3557 if (place_monster_idx == r_idx) return (FALSE);
3559 /* Skip different alignment */
3560 if (monster_has_hostile_align(m_ptr, 0, 0, z_ptr)) return FALSE;
3562 if (r_ptr->flags7 & RF7_FRIENDLY)
3564 if (monster_has_hostile_align(NULL, 1, -1, z_ptr)) return FALSE;
3567 if ((r_ptr->flags7 & RF7_CHAMELEON) && !(z_ptr->flags7 & RF7_CHAMELEON))
3576 * @brief 一般的なモンスター生成処理のサブルーチン / Attempt to place a monster of the given race at the given location
3577 * @param who 召喚主のモンスター情報ID
3580 * @param r_idx 生成するモンスターの種族ID
3581 * @param mode 生成オプション
3582 * @return 生成に成功したらtrue
3584 * Note that certain monsters are now marked as requiring "friends".
3585 * These monsters, if successfully placed, and if the "grp" parameter
3586 * is TRUE, will be surrounded by a "group" of identical monsters.
3588 * Note that certain monsters are now marked as requiring an "escort",
3589 * which is a collection of monsters with similar "race" but lower level.
3591 * Some monsters induce a fake "group" flag on their escorts.
3593 * Note the "bizarre" use of non-recursion to prevent annoying output
3594 * when running a code profiler.
3596 * Note the use of the new "monster allocation table" code to restrict
3597 * the "get_mon_num()" function to "legal" escort types.
3599 bool place_monster_aux(int who, int y, int x, int r_idx, u32b mode)
3602 monster_race *r_ptr = &r_info[r_idx];
3604 if (!(mode & PM_NO_KAGE) && one_in_(333))
3607 /* Place one monster, or fail */
3608 if (!place_monster_one(who, y, x, r_idx, mode)) return (FALSE);
3610 /* Require the "group" flag */
3611 if (!(mode & PM_ALLOW_GROUP)) return (TRUE);
3613 place_monster_m_idx = hack_m_idx_ii;
3616 for(i = 0; i < 6; i++)
3618 if(!r_ptr->reinforce_id[i]) break;
3619 n = damroll(r_ptr->reinforce_dd[i], r_ptr->reinforce_ds[i]);
3620 for(j = 0; j < n; j++)
3623 scatter(&ny, &nx, y, x, d, 0);
3624 (void)place_monster_one(place_monster_m_idx, ny, nx, r_ptr->reinforce_id[i], mode);
3628 /* Friends for certain monsters */
3629 if (r_ptr->flags1 & (RF1_FRIENDS))
3631 /* Attempt to place a group */
3632 (void)place_monster_group(who, y, x, r_idx, mode);
3635 /* Escorts for certain monsters */
3636 if (r_ptr->flags1 & (RF1_ESCORT))
3638 /* Set the escort index */
3639 place_monster_idx = r_idx;
3641 /* Try to place several "escorts" */
3642 for (i = 0; i < 32; i++)
3644 int nx, ny, z, d = 3;
3646 /* Pick a location */
3647 scatter(&ny, &nx, y, x, d, 0);
3649 /* Require empty grids */
3650 if (!cave_empty_bold2(ny, nx)) continue;
3652 /* Prepare allocation table */
3653 get_mon_num_prep(place_monster_okay, get_monster_hook2(ny, nx));
3655 /* Pick a random race */
3656 z = get_mon_num(r_ptr->level);
3658 /* Handle failure */
3661 /* Place a single escort */
3662 (void)place_monster_one(place_monster_m_idx, ny, nx, z, mode);
3664 /* Place a "group" of escorts if needed */
3665 if ((r_info[z].flags1 & RF1_FRIENDS) ||
3666 (r_ptr->flags1 & RF1_ESCORTS))
3668 /* Place a group of monsters */
3669 (void)place_monster_group(place_monster_m_idx, ny, nx, z, mode);
3679 * @brief 一般的なモンスター生成処理のメインルーチン / Attempt to place a monster of the given race at the given location
3682 * @param mode 生成オプション
3683 * @return 生成に成功したらtrue
3685 bool place_monster(int y, int x, u32b mode)
3689 /* Prepare allocation table */
3690 get_mon_num_prep(get_monster_hook(), get_monster_hook2(y, x));
3692 /* Pick a monster */
3693 r_idx = get_mon_num(monster_level);
3695 /* Handle failure */
3696 if (!r_idx) return (FALSE);
3698 /* Attempt to place the monster */
3699 if (place_monster_aux(0, y, x, r_idx, mode)) return (TRUE);
3706 #ifdef MONSTER_HORDES
3708 bool alloc_horde(int y, int x)
3710 monster_race *r_ptr = NULL;
3713 int attempts = 1000;
3717 /* Prepare allocation table */
3718 get_mon_num_prep(get_monster_hook(), get_monster_hook2(y, x));
3722 /* Pick a monster */
3723 r_idx = get_mon_num(monster_level);
3725 /* Handle failure */
3726 if (!r_idx) return (FALSE);
3728 r_ptr = &r_info[r_idx];
3730 if (r_ptr->flags1 & RF1_UNIQUE) continue;
3732 if (r_idx == MON_HAGURE) continue;
3735 if (attempts < 1) return FALSE;
3741 /* Attempt to place the monster */
3742 if (place_monster_aux(0, y, x, r_idx, 0L)) break;
3745 if (attempts < 1) return FALSE;
3747 m_idx = cave[y][x].m_idx;
3749 if (m_list[m_idx].mflag2 & MFLAG2_CHAMELEON) r_ptr = &r_info[m_list[m_idx].r_idx];
3750 summon_kin_type = r_ptr->d_char;
3752 for (attempts = randint1(10) + 5; attempts; attempts--)
3754 scatter(&cy, &cx, y, x, 5, 0);
3756 (void)summon_specific(m_idx, cy, cx, dun_level + 5, SUMMON_KIN, PM_ALLOW_GROUP);
3765 #endif /* MONSTER_HORDES */
3771 bool alloc_guardian(bool def_val)
3773 int guardian = d_info[dungeon_type].final_guardian;
3775 if (guardian && (d_info[dungeon_type].maxdepth == dun_level) && (r_info[guardian].cur_num < r_info[guardian].max_num))
3779 int try_count = 4000;
3781 /* Find a good position */
3784 /* Get a random spot */
3785 oy = randint1(cur_hgt - 4) + 2;
3786 ox = randint1(cur_wid - 4) + 2;
3788 /* Is it a good spot ? */
3789 if (cave_empty_bold2(oy, ox) && monster_can_cross_terrain(cave[oy][ox].feat, &r_info[guardian], 0))
3791 /* Place the guardian */
3792 if (place_monster_aux(0, oy, ox, guardian, (PM_ALLOW_GROUP | PM_NO_KAGE | PM_NO_PET))) return TRUE;
3795 /* One less try count */
3807 * Attempt to allocate a random monster in the dungeon.
3809 * Place the monster at least "dis" distance from the player.
3811 * Use "slp" to choose the initial "sleep" status
3813 * Use "monster_level" for the monster level
3815 bool alloc_monster(int dis, u32b mode)
3818 int attempts_left = 10000;
3820 /* Put the Guardian */
3821 if (alloc_guardian(FALSE)) return TRUE;
3823 /* Find a legal, distant, unoccupied, space */
3824 while (attempts_left--)
3826 /* Pick a location */
3827 y = randint0(cur_hgt);
3828 x = randint0(cur_wid);
3830 /* Require empty floor grid (was "naked") */
3833 if (!cave_empty_bold2(y, x)) continue;
3837 if (!cave_empty_bold(y, x)) continue;
3840 /* Accept far away grids */
3841 if (distance(y, x, py, px) > dis) break;
3846 if (cheat_xtra || cheat_hear)
3848 msg_print(_("警告!新たなモンスターを配置できません。小さい階ですか?", "Warning! Could not allocate a new monster. Small level?"));
3855 #ifdef MONSTER_HORDES
3856 if (randint1(5000) <= dun_level)
3858 if (alloc_horde(y, x))
3860 if (cheat_hear) msg_format(_("モンスターの大群(%c)", "Monster horde (%c)."), summon_kin_type);
3866 #endif /* MONSTER_HORDES */
3868 /* Attempt to place the monster, allow groups */
3869 if (place_monster(y, x, (mode | PM_ALLOW_GROUP))) return (TRUE);
3871 #ifdef MONSTER_HORDES
3873 #endif /* MONSTER_HORDES */
3883 * Hack -- help decide if a monster race is "okay" to summon
3885 static bool summon_specific_okay(int r_idx)
3887 monster_race *r_ptr = &r_info[r_idx];
3889 /* Hack - Only summon dungeon monsters */
3890 if (!mon_hook_dungeon(r_idx)) return (FALSE);
3892 /* Hack -- identify the summoning monster */
3893 if (summon_specific_who > 0)
3895 monster_type *m_ptr = &m_list[summon_specific_who];
3897 /* Do not summon enemies */
3899 /* Friendly vs. opposite aligned normal or pet */
3900 if (monster_has_hostile_align(m_ptr, 0, 0, r_ptr)) return FALSE;
3902 /* Use the player's alignment */
3903 else if (summon_specific_who < 0)
3905 /* Do not summon enemies of the pets */
3906 if (monster_has_hostile_align(NULL, 10, -10, r_ptr))
3908 if (!one_in_(ABS(p_ptr->align) / 2 + 1)) return FALSE;
3912 /* Hack -- no specific type specified */
3913 if (!summon_specific_type) return (TRUE);
3915 if (!summon_unique_okay && ((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags7 & RF7_NAZGUL))) return FALSE;
3917 if ((summon_specific_who < 0) &&
3918 ((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags7 & RF7_NAZGUL)) &&
3919 monster_has_hostile_align(NULL, 10, -10, r_ptr))
3922 if ((r_ptr->flags7 & RF7_CHAMELEON) && (d_info[dungeon_type].flags1 & DF1_CHAMELEON)) return TRUE;
3924 return (summon_specific_aux(r_idx));
3929 * Place a monster (of the specified "type") near the given
3930 * location. Return TRUE if a monster was actually summoned.
3932 * We will attempt to place the monster up to 10 times before giving up.
3934 * Note: SUMMON_UNIQUE and SUMMON_AMBERITES will summon Unique's
3935 * Note: SUMMON_HI_UNDEAD and SUMMON_HI_DRAGON may summon Unique's
3936 * Note: None of the other summon codes will ever summon Unique's.
3938 * This function has been changed. We now take the "monster level"
3939 * of the summoning monster as a parameter, and use that, along with
3940 * the current dungeon level, to help determine the level of the
3941 * desired monster. Note that this is an upper bound, and also
3942 * tends to "prefer" monsters of that level. Currently, we use
3943 * the average of the dungeon and monster levels, and then add
3944 * five to allow slight increases in monster power.
3946 * Note that we use the new "monster allocation table" creation code
3947 * to restrict the "get_mon_num()" function to the set of "legal"
3948 * monsters, making this function much faster and more reliable.
3950 * Note that this function may not succeed, though this is very rare.
3952 bool summon_specific(int who, int y1, int x1, int lev, int type, u32b mode)
3956 if (p_ptr->inside_arena) return (FALSE);
3958 if (!mon_scatter(0, &y, &x, y1, x1, 2)) return FALSE;
3960 /* Save the summoner */
3961 summon_specific_who = who;
3963 /* Save the "summon" type */
3964 summon_specific_type = type;
3966 summon_unique_okay = (mode & PM_ALLOW_UNIQUE) ? TRUE : FALSE;
3968 /* Prepare allocation table */
3969 get_mon_num_prep(summon_specific_okay, get_monster_hook2(y, x));
3971 /* Pick a monster, using the level calculation */
3972 r_idx = get_mon_num((dun_level + lev) / 2 + 5);
3974 /* Handle failure */
3977 summon_specific_type = 0;
3981 if ((type == SUMMON_BLUE_HORROR) || (type == SUMMON_DAWN)) mode |= PM_NO_KAGE;
3983 /* Attempt to place the monster (awake, allow groups) */
3984 if (!place_monster_aux(who, y, x, r_idx, mode))
3986 summon_specific_type = 0;
3990 summon_specific_type = 0;
3995 /* A "dangerous" function, creates a pet of the specified type */
3996 bool summon_named_creature (int who, int oy, int ox, int r_idx, u32b mode)
4001 /* if (!r_idx) return; */
4003 /* Prevent illegal monsters */
4004 if (r_idx >= max_r_idx) return FALSE;
4006 if (p_ptr->inside_arena) return FALSE;
4008 if (!mon_scatter(r_idx, &y, &x, oy, ox, 2)) return FALSE;
4010 /* Place it (allow groups) */
4011 return place_monster_aux(who, y, x, r_idx, (mode | PM_NO_KAGE));
4016 * Let the given monster attempt to reproduce.
4018 * Note that "reproduction" REQUIRES empty space.
4020 bool multiply_monster(int m_idx, bool clone, u32b mode)
4022 monster_type *m_ptr = &m_list[m_idx];
4026 if (!mon_scatter(m_ptr->r_idx, &y, &x, m_ptr->fy, m_ptr->fx, 1))
4029 if (m_ptr->mflag2 & MFLAG2_NOPET) mode |= PM_NO_PET;
4031 /* Create a new monster (awake, no groups) */
4032 if (!place_monster_aux(m_idx, y, x, m_ptr->r_idx, (mode | PM_NO_KAGE | PM_MULTIPLY)))
4035 /* Hack -- Transfer "clone" flag */
4036 if (clone || (m_ptr->smart & SM_CLONED))
4038 m_list[hack_m_idx_ii].smart |= SM_CLONED;
4039 m_list[hack_m_idx_ii].mflag2 |= MFLAG2_NOPET;
4050 * Dump a message describing a monster's reaction to damage
4052 * Technically should attempt to treat "Beholder"'s as jelly's
4054 void message_pain(int m_idx, int dam)
4056 long oldhp, newhp, tmp;
4059 monster_type *m_ptr = &m_list[m_idx];
4060 monster_race *r_ptr = &r_info[m_ptr->r_idx];
4064 /* Get the monster name */
4065 monster_desc(m_name, m_ptr, 0);
4067 if(dam == 0) // Notice non-damage
4069 msg_format(_("%^sはダメージを受けていない。", "%^s is unharmed."), m_name);
4073 /* Note -- subtle fix -CFT */
4074 newhp = (long)(m_ptr->hp);
4075 oldhp = newhp + (long)(dam);
4076 tmp = (newhp * 100L) / oldhp;
4077 percentage = (int)(tmp);
4079 if(my_strchr(",ejmvwQ", r_ptr->d_char)) // Mushrooms, Eyes, Jellies, Molds, Vortices, Worms, Quylthulgs
4082 if(percentage > 95) msg_format("%^sはほとんど気にとめていない。", m_name);
4083 else if(percentage > 75) msg_format("%^sはしり込みした。", m_name);
4084 else if(percentage > 50) msg_format("%^sは縮こまった。", m_name);
4085 else if(percentage > 35) msg_format("%^sは痛みに震えた。", m_name);
4086 else if(percentage > 20) msg_format("%^sは身もだえした。", m_name);
4087 else if(percentage > 10) msg_format("%^sは苦痛で身もだえした。", m_name);
4088 else msg_format("%^sはぐにゃぐにゃと痙攣した。", m_name);
4090 if(percentage > 95) msg_format("%^s barely notices.", m_name);
4091 else if(percentage > 75) msg_format("%^s flinches.", m_name);
4092 else if(percentage > 50) msg_format("%^s squelches.", m_name);
4093 else if(percentage > 35) msg_format("%^s quivers in pain.", m_name);
4094 else if(percentage > 20) msg_format("%^s writhes about.", m_name);
4095 else if(percentage > 10) msg_format("%^s writhes in agony.", m_name);
4096 else msg_format("%^s jerks limply.", m_name);
4100 else if(my_strchr("l", r_ptr->d_char)) // Fish
4103 if(percentage > 95) msg_format("%^sはほとんど気にとめていない。", m_name);
4104 else if(percentage > 75) msg_format("%^sはしり込みした。", m_name);
4105 else if(percentage > 50) msg_format("%^sは躊躇した。", m_name);
4106 else if(percentage > 35) msg_format("%^sは痛みに震えた。", m_name);
4107 else if(percentage > 20) msg_format("%^sは身もだえした。", m_name);
4108 else if(percentage > 10) msg_format("%^sは苦痛で身もだえした。", m_name);
4109 else msg_format("%^sはぐにゃぐにゃと痙攣した。", m_name);
4111 if(percentage > 95) msg_format("%^s barely notices.", m_name);
4112 else if(percentage > 75) msg_format("%^s flinches.", m_name);
4113 else if(percentage > 50) msg_format("%^s hesitates.", m_name);
4114 else if(percentage > 35) msg_format("%^s quivers in pain.", m_name);
4115 else if(percentage > 20) msg_format("%^s writhes about.", m_name);
4116 else if(percentage > 10) msg_format("%^s writhes in agony.", m_name);
4117 else msg_format("%^s jerks limply.", m_name);
4121 else if(my_strchr("g#+<>", r_ptr->d_char)) // Golems, Walls, Doors, Stairs
4124 if(percentage > 95) msg_format("%sは攻撃を気にとめていない。", m_name);
4125 else if(percentage > 75) msg_format("%sは攻撃に肩をすくめた。", m_name);
4126 else if(percentage > 50) msg_format("%^sは雷鳴のように吠えた。", m_name);
4127 else if(percentage > 35) msg_format("%^sは苦しげに吠えた。", m_name);
4128 else if(percentage > 20) msg_format("%^sはうめいた。", m_name);
4129 else if(percentage > 10) msg_format("%^sは躊躇した。", m_name);
4130 else msg_format("%^sはくしゃくしゃになった。", m_name);
4132 if(percentage > 95) msg_format("%^s ignores the attack.", m_name);
4133 else if(percentage > 75) msg_format("%^s shrugs off the attack.", m_name);
4134 else if(percentage > 50) msg_format("%^s roars thunderously.", m_name);
4135 else if(percentage > 35) msg_format("%^s rumbles.", m_name);
4136 else if(percentage > 20) msg_format("%^s grunts.", m_name);
4137 else if(percentage > 10) msg_format("%^s hesitates.", m_name);
4138 else msg_format("%^s crumples.", m_name);
4142 else if(my_strchr("JMR", r_ptr->d_char) || !isalpha(r_ptr->d_char)) // Snakes, Hydrae, Reptiles, Mimics
4145 if(percentage > 95) msg_format("%^sはほとんど気にとめていない。", m_name);
4146 else if(percentage > 75) msg_format("%^sはシーッと鳴いた。", m_name);
4147 else if(percentage > 50) msg_format("%^sは怒って頭を上げた。", m_name);
4148 else if(percentage > 35) msg_format("%^sは猛然と威嚇した。", m_name);
4149 else if(percentage > 20) msg_format("%^sは身もだえした。", m_name);
4150 else if(percentage > 10) msg_format("%^sは苦痛で身もだえした。", m_name);
4151 else msg_format("%^sはぐにゃぐにゃと痙攣した。", m_name);
4153 if(percentage > 95) msg_format("%^s barely notices.", m_name);
4154 else if(percentage > 75) msg_format("%^s hisses.", m_name);
4155 else if(percentage > 50) msg_format("%^s rears up in anger.", m_name);
4156 else if(percentage > 35) msg_format("%^s hisses furiously.", m_name);
4157 else if(percentage > 20) msg_format("%^s writhes about.", m_name);
4158 else if(percentage > 10) msg_format("%^s writhes in agony.", m_name);
4159 else msg_format("%^s jerks limply.", m_name);
4163 else if(my_strchr("f", r_ptr->d_char))
4166 if(percentage > 95) msg_format("%sは攻撃に肩をすくめた。", m_name);
4167 else if(percentage > 75) msg_format("%^sは吠えた。", m_name);
4168 else if(percentage > 50) msg_format("%^sは怒って吠えた。", m_name);
4169 else if(percentage > 35) msg_format("%^sは痛みでシーッと鳴いた。", m_name);
4170 else if(percentage > 20) msg_format("%^sは痛みで弱々しく鳴いた。", m_name);
4171 else if(percentage > 10) msg_format("%^sは苦痛にうめいた。", m_name);
4172 else msg_format("%sは哀れな鳴き声を出した。", m_name);
4174 if(percentage > 95) msg_format("%^s shrugs off the attack.", m_name);
4175 else if(percentage > 75) msg_format("%^s roars.", m_name);
4176 else if(percentage > 50) msg_format("%^s growls angrily.", m_name);
4177 else if(percentage > 35) msg_format("%^s hisses with pain.", m_name);
4178 else if(percentage > 20) msg_format("%^s mewls in pain.", m_name);
4179 else if(percentage > 10) msg_format("%^s hisses in agony.", m_name);
4180 else msg_format("%^s mewls pitifully.", m_name);
4184 else if(my_strchr("acFIKS", r_ptr->d_char)) // Ants, Centipedes, Flies, Insects, Beetles, Spiders
4187 if(percentage > 95) msg_format("%sは攻撃を気にとめていない。", m_name);
4188 else if(percentage > 75) msg_format("%^sはキーキー鳴いた。", m_name);
4189 else if(percentage > 50) msg_format("%^sはヨロヨロ逃げ回った。", m_name);
4190 else if(percentage > 35) msg_format("%^sはうるさく鳴いた。", m_name);
4191 else if(percentage > 20) msg_format("%^sは痛みに痙攣した。", m_name);
4192 else if(percentage > 10) msg_format("%^sは苦痛で痙攣した。", m_name);
4193 else msg_format("%^sはピクピクひきつった。", m_name);
4195 if(percentage > 95) msg_format("%^s ignores the attack.", m_name);
4196 else if(percentage > 75) msg_format("%^s chitters.", m_name);
4197 else if(percentage > 50) msg_format("%^s scuttles about.", m_name);
4198 else if(percentage > 35) msg_format("%^s twitters.", m_name);
4199 else if(percentage > 20) msg_format("%^s jerks in pain.", m_name);
4200 else if(percentage > 10) msg_format("%^s jerks in agony.", m_name);
4201 else msg_format("%^s twitches.", m_name);
4205 else if(my_strchr("B", r_ptr->d_char)) // Birds
4208 if(percentage > 95) msg_format("%^sはさえずった。", m_name);
4209 else if(percentage > 75) msg_format("%^sはピーピー鳴いた。", m_name);
4210 else if(percentage > 50) msg_format("%^sはギャーギャー鳴いた。", m_name);
4211 else if(percentage > 35) msg_format("%^sはギャーギャー鳴きわめいた。", m_name);
4212 else if(percentage > 20) msg_format("%^sは苦しんだ。", m_name);
4213 else if(percentage > 10) msg_format("%^sはのたうち回った。", m_name);
4214 else msg_format("%^sはキーキーと鳴き叫んだ。", m_name);
4216 if(percentage > 95) msg_format("%^s chirps.", m_name);
4217 else if(percentage > 75) msg_format("%^s twitters.", m_name);
4218 else if(percentage > 50) msg_format("%^s squawks.", m_name);
4219 else if(percentage > 35) msg_format("%^s chatters.", m_name);
4220 else if(percentage > 20) msg_format("%^s jeers.", m_name);
4221 else if(percentage > 10) msg_format("%^s flutters about.", m_name);
4222 else msg_format("%^s squeaks.", m_name);
4226 else if(my_strchr("duDLUW", r_ptr->d_char)) // Dragons, Demons, High Undead
4229 if(percentage > 95) msg_format("%sは攻撃を気にとめていない。", m_name);
4230 else if(percentage > 75) msg_format("%^sはしり込みした。", m_name);
4231 else if(percentage > 50) msg_format("%^sは痛みでシーッと鳴いた。", m_name);
4232 else if(percentage > 35) msg_format("%^sは痛みでうなった。", m_name);
4233 else if(percentage > 20) msg_format("%^sは痛みに吠えた。", m_name);
4234 else if(percentage > 10) msg_format("%^sは苦しげに叫んだ。", m_name);
4235 else msg_format("%^sは弱々しくうなった。", m_name);
4237 if(percentage > 95) msg_format("%^s ignores the attack.", m_name);
4238 else if(percentage > 75) msg_format("%^s flinches.", m_name);
4239 else if(percentage > 50) msg_format("%^s hisses in pain.", m_name);
4240 else if(percentage > 35) msg_format("%^s snarls with pain.", m_name);
4241 else if(percentage > 20) msg_format("%^s roars with pain.", m_name);
4242 else if(percentage > 10) msg_format("%^s gasps.", m_name);
4243 else msg_format("%^s snarls feebly.", m_name);
4247 else if(my_strchr("s", r_ptr->d_char)) // Skeletons
4250 if(percentage > 95) msg_format("%sは攻撃を気にとめていない。", m_name);
4251 else if(percentage > 75) msg_format("%sは攻撃に肩をすくめた。", m_name);
4252 else if(percentage > 50) msg_format("%^sはカタカタと笑った。", m_name);
4253 else if(percentage > 35) msg_format("%^sはよろめいた。", m_name);
4254 else if(percentage > 20) msg_format("%^sはカタカタ言った。", m_name);
4255 else if(percentage > 10) msg_format("%^sはよろめいた。", m_name);
4256 else msg_format("%^sはガタガタ言った。", m_name);
4258 if(percentage > 95) msg_format("%^s ignores the attack.", m_name);
4259 else if(percentage > 75) msg_format("%^s shrugs off the attack.", m_name);
4260 else if(percentage > 50) msg_format("%^s rattles.", m_name);
4261 else if(percentage > 35) msg_format("%^s stumbles.", m_name);
4262 else if(percentage > 20) msg_format("%^s rattles.", m_name);
4263 else if(percentage > 10) msg_format("%^s staggers.", m_name);
4264 else msg_format("%^s clatters.", m_name);
4268 else if(my_strchr("z", r_ptr->d_char)) // Zombies
4271 if(percentage > 95) msg_format("%sは攻撃を気にとめていない。", m_name);
4272 else if(percentage > 75) msg_format("%sは攻撃に肩をすくめた。", m_name);
4273 else if(percentage > 50) msg_format("%^sはうめいた。", m_name);
4274 else if(percentage > 35) msg_format("%sは苦しげにうめいた。", m_name);
4275 else if(percentage > 20) msg_format("%^sは躊躇した。", m_name);
4276 else if(percentage > 10) msg_format("%^sはうなった。", m_name);
4277 else msg_format("%^sはよろめいた。", m_name);
4279 if(percentage > 95) msg_format("%^s ignores the attack.", m_name);
4280 else if(percentage > 75) msg_format("%^s shrugs off the attack.", m_name);
4281 else if(percentage > 50) msg_format("%^s groans.", m_name);
4282 else if(percentage > 35) msg_format("%^s moans.", m_name);
4283 else if(percentage > 20) msg_format("%^s hesitates.", m_name);
4284 else if(percentage > 10) msg_format("%^s grunts.", m_name);
4285 else msg_format("%^s staggers.", m_name);
4289 else if(my_strchr("G", r_ptr->d_char)) // Ghosts
4292 if(percentage > 95) msg_format("%sは攻撃を気にとめていない。", m_name);
4293 else if(percentage > 75) msg_format("%sは攻撃に肩をすくめた。", m_name);
4294 else if(percentage > 50) msg_format("%sはうめいた。", m_name);
4295 else if(percentage > 35) msg_format("%^sは泣きわめいた。", m_name);
4296 else if(percentage > 20) msg_format("%^sは吠えた。", m_name);
4297 else if(percentage > 10) msg_format("%sは弱々しくうめいた。", m_name);
4298 else msg_format("%^sはかすかにうめいた。", m_name);
4300 if(percentage > 95) msg_format("%^s ignores the attack.", m_name);
4301 else if(percentage > 75) msg_format("%^s shrugs off the attack.", m_name);
4302 else if(percentage > 50) msg_format("%^s moans.", m_name);
4303 else if(percentage > 35) msg_format("%^s wails.", m_name);
4304 else if(percentage > 20) msg_format("%^s howls.", m_name);
4305 else if(percentage > 10) msg_format("%^s moans softly.", m_name);
4306 else msg_format("%^s sighs.", m_name);
4310 else if(my_strchr("CZ", r_ptr->d_char)) // Dogs and Hounds
4313 if(percentage > 95) msg_format("%^sは攻撃に肩をすくめた。", m_name);
4314 else if(percentage > 75) msg_format("%^sは痛みでうなった。", m_name);
4315 else if(percentage > 50) msg_format("%^sは痛みでキャンキャン吠えた。", m_name);
4316 else if(percentage > 35) msg_format("%^sは痛みで鳴きわめいた。", m_name);
4317 else if(percentage > 20) msg_format("%^sは苦痛のあまり鳴きわめいた。", m_name);
4318 else if(percentage > 10) msg_format("%^sは苦痛でもだえ苦しんだ。", m_name);
4319 else msg_format("%^sは弱々しく吠えた。", m_name);
4321 if(percentage > 95) msg_format("%^s shrugs off the attack.", m_name);
4322 else if(percentage > 75) msg_format("%^s snarls with pain.", m_name);
4323 else if(percentage > 50) msg_format("%^s yelps in pain.", m_name);
4324 else if(percentage > 35) msg_format("%^s howls in pain.", m_name);
4325 else if(percentage > 20) msg_format("%^s howls in agony.", m_name);
4326 else if(percentage > 10) msg_format("%^s writhes in agony.", m_name);
4327 else msg_format("%^s yelps feebly.", m_name);
4331 else if(my_strchr("Xbilqrt", r_ptr->d_char)) // One type of creatures (ignore,squeal,shriek)
4334 if(percentage > 95) msg_format("%^sは攻撃を気にとめていない。", m_name);
4335 else if(percentage > 75) msg_format("%^sは痛みでうなった。", m_name);
4336 else if(percentage > 50) msg_format("%^sは痛みで叫んだ。", m_name);
4337 else if(percentage > 35) msg_format("%^sは痛みで絶叫した。", m_name);
4338 else if(percentage > 20) msg_format("%^sは苦痛のあまり絶叫した。", m_name);
4339 else if(percentage > 10) msg_format("%^sは苦痛でもだえ苦しんだ。", m_name);
4340 else msg_format("%^sは弱々しく叫んだ。", m_name);
4342 if(percentage > 95) msg_format("%^s ignores the attack.", m_name);
4343 else if(percentage > 75) msg_format("%^s grunts with pain.", m_name);
4344 else if(percentage > 50) msg_format("%^s squeals in pain.", m_name);
4345 else if(percentage > 35) msg_format("%^s shrieks in pain.", m_name);
4346 else if(percentage > 20) msg_format("%^s shrieks in agony.", m_name);
4347 else if(percentage > 10) msg_format("%^s writhes in agony.", m_name);
4348 else msg_format("%^s cries out feebly.", m_name);
4352 else // Another type of creatures (shrug,cry,scream)
4355 if(percentage > 95) msg_format("%^sは攻撃に肩をすくめた。", m_name);
4356 else if(percentage > 75) msg_format("%^sは痛みでうなった。", m_name);
4357 else if(percentage > 50) msg_format("%^sは痛みで叫んだ。", m_name);
4358 else if(percentage > 35) msg_format("%^sは痛みで絶叫した。", m_name);
4359 else if(percentage > 20) msg_format("%^sは苦痛のあまり絶叫した。", m_name);
4360 else if(percentage > 10) msg_format("%^sは苦痛でもだえ苦しんだ。", m_name);
4361 else msg_format("%^sは弱々しく叫んだ。", m_name);
4363 if(percentage > 95) msg_format("%^s shrugs off the attack.", m_name);
4364 else if(percentage > 75) msg_format("%^s grunts with pain.", m_name);
4365 else if(percentage > 50) msg_format("%^s cries out in pain.", m_name);
4366 else if(percentage > 35) msg_format("%^s screams in pain.", m_name);
4367 else if(percentage > 20) msg_format("%^s screams in agony.", m_name);
4368 else if(percentage > 10) msg_format("%^s writhes in agony.", m_name);
4369 else msg_format("%^s cries out feebly.", m_name);
4378 * Learn about an "observed" resistance.
4380 void update_smart_learn(int m_idx, int what)
4382 monster_type *m_ptr = &m_list[m_idx];
4384 monster_race *r_ptr = &r_info[m_ptr->r_idx];
4387 /* Not allowed to learn */
4388 if (!smart_learn) return;
4390 /* Too stupid to learn anything */
4391 if (r_ptr->flags2 & (RF2_STUPID)) return;
4393 /* Not intelligent, only learn sometimes */
4394 if (!(r_ptr->flags2 & (RF2_SMART)) && (randint0(100) < 50)) return;
4399 /* Analyze the knowledge */
4403 if (p_ptr->resist_acid) m_ptr->smart |= (SM_RES_ACID);
4404 if (IS_OPPOSE_ACID()) m_ptr->smart |= (SM_OPP_ACID);
4405 if (p_ptr->immune_acid) m_ptr->smart |= (SM_IMM_ACID);
4409 if (p_ptr->resist_elec) m_ptr->smart |= (SM_RES_ELEC);
4410 if (IS_OPPOSE_ELEC()) m_ptr->smart |= (SM_OPP_ELEC);
4411 if (p_ptr->immune_elec) m_ptr->smart |= (SM_IMM_ELEC);
4415 if (p_ptr->resist_fire) m_ptr->smart |= (SM_RES_FIRE);
4416 if (IS_OPPOSE_FIRE()) m_ptr->smart |= (SM_OPP_FIRE);
4417 if (p_ptr->immune_fire) m_ptr->smart |= (SM_IMM_FIRE);
4421 if (p_ptr->resist_cold) m_ptr->smart |= (SM_RES_COLD);
4422 if (IS_OPPOSE_COLD()) m_ptr->smart |= (SM_OPP_COLD);
4423 if (p_ptr->immune_cold) m_ptr->smart |= (SM_IMM_COLD);
4427 if (p_ptr->resist_pois) m_ptr->smart |= (SM_RES_POIS);
4428 if (IS_OPPOSE_POIS()) m_ptr->smart |= (SM_OPP_POIS);
4433 if (p_ptr->resist_neth) m_ptr->smart |= (SM_RES_NETH);
4437 if (p_ptr->resist_lite) m_ptr->smart |= (SM_RES_LITE);
4441 if (p_ptr->resist_dark) m_ptr->smart |= (SM_RES_DARK);
4445 if (p_ptr->resist_fear) m_ptr->smart |= (SM_RES_FEAR);
4449 if (p_ptr->resist_conf) m_ptr->smart |= (SM_RES_CONF);
4453 if (p_ptr->resist_chaos) m_ptr->smart |= (SM_RES_CHAOS);
4457 if (p_ptr->resist_disen) m_ptr->smart |= (SM_RES_DISEN);
4461 if (p_ptr->resist_blind) m_ptr->smart |= (SM_RES_BLIND);
4465 if (p_ptr->resist_nexus) m_ptr->smart |= (SM_RES_NEXUS);
4469 if (p_ptr->resist_sound) m_ptr->smart |= (SM_RES_SOUND);
4473 if (p_ptr->resist_shard) m_ptr->smart |= (SM_RES_SHARD);
4477 if (p_ptr->free_act) m_ptr->smart |= (SM_IMM_FREE);
4481 if (!p_ptr->msp) m_ptr->smart |= (SM_IMM_MANA);
4485 if (p_ptr->reflect) m_ptr-> smart |= (SM_IMM_REFLECT);
4492 * Place the player in the dungeon XXX XXX
4494 bool player_place(int y, int x)
4496 /* Paranoia XXX XXX */
4497 if (cave[y][x].m_idx != 0) return FALSE;
4499 /* Save player location */
4509 * Drop all items carried by a monster
4511 void monster_drop_carried_objects(monster_type *m_ptr)
4513 s16b this_o_idx, next_o_idx = 0;
4519 /* Drop objects being carried */
4520 for (this_o_idx = m_ptr->hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
4522 /* Acquire object */
4523 o_ptr = &o_list[this_o_idx];
4525 /* Acquire next object */
4526 next_o_idx = o_ptr->next_o_idx;
4528 /* Get local object */
4531 /* Copy the object */
4532 object_copy(q_ptr, o_ptr);
4534 /* Forget monster */
4535 q_ptr->held_m_idx = 0;
4537 /* Delete the object */
4538 delete_object_idx(this_o_idx);
4541 (void)drop_near(q_ptr, -1, m_ptr->fy, m_ptr->fx);
4544 /* Forget objects */
4545 m_ptr->hold_o_idx = 0;