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 * Move an object from index i1 to index i2 in the object list
317 static void compact_monsters_aux(int i1, int i2)
325 s16b this_o_idx, next_o_idx = 0;
329 if (i1 == i2) return;
342 /* Update the cave */
345 /* Repair objects being carried by monster */
346 for (this_o_idx = m_ptr->hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
351 o_ptr = &o_list[this_o_idx];
353 /* Acquire next object */
354 next_o_idx = o_ptr->next_o_idx;
356 /* Reset monster pointer */
357 o_ptr->held_m_idx = i2;
360 /* Hack -- Update the target */
361 if (target_who == i1) target_who = i2;
363 /* Hack -- Update the target */
364 if (pet_t_m_idx == i1) pet_t_m_idx = i2;
365 if (riding_t_m_idx == i1) riding_t_m_idx = i2;
367 /* Hack -- Update the riding */
368 if (p_ptr->riding == i1) p_ptr->riding = i2;
370 /* Hack -- Update the health bar */
371 if (p_ptr->health_who == i1) health_track(i2);
373 /* Hack -- Update parent index */
376 for (i = 1; i < m_max; i++)
378 monster_type *m2_ptr = &m_list[i];
380 if (m2_ptr->parent_m_idx == i1)
381 m2_ptr->parent_m_idx = i2;
386 (void)COPY(&m_list[i2], &m_list[i1], monster_type);
389 (void)WIPE(&m_list[i1], monster_type);
391 for (i = 0; i < MAX_MTIMED; i++)
393 int mproc_idx = get_mproc_idx(i1, i);
394 if (mproc_idx >= 0) mproc_list[i][mproc_idx] = i2;
400 * Compact and Reorder the monster list
402 * This function can be very dangerous, use with caution!
404 * When actually "compacting" monsters, we base the saving throw
405 * on a combination of monster level, distance from player, and
406 * current "desperation".
408 * After "compacting" (if needed), we "reorder" the monsters into a more
409 * compact order, and we reset the allocation info, and the "live" array.
411 void compact_monsters(int size)
414 int cur_lev, cur_dis, chance;
416 /* Message (only if compacting) */
417 if (size) msg_print(_("モンスター情報を圧縮しています...", "Compacting monsters..."));
420 /* Compact at least 'size' objects */
421 for (num = 0, cnt = 1; num < size; cnt++)
423 /* Get more vicious each iteration */
426 /* Get closer each iteration */
427 cur_dis = 5 * (20 - cnt);
429 /* Check all the monsters */
430 for (i = 1; i < m_max; i++)
432 monster_type *m_ptr = &m_list[i];
434 monster_race *r_ptr = &r_info[m_ptr->r_idx];
436 /* Paranoia -- skip "dead" monsters */
437 if (!m_ptr->r_idx) continue;
439 /* Hack -- High level monsters start out "immune" */
440 if (r_ptr->level > cur_lev) continue;
442 if (i == p_ptr->riding) continue;
444 /* Ignore nearby monsters */
445 if ((cur_dis > 0) && (m_ptr->cdis < cur_dis)) continue;
447 /* Saving throw chance */
450 /* Only compact "Quest" Monsters in emergencies */
451 if ((r_ptr->flags1 & (RF1_QUESTOR)) && (cnt < 1000)) chance = 100;
453 /* Try not to compact Unique Monsters */
454 if (r_ptr->flags1 & (RF1_UNIQUE)) chance = 100;
456 /* All monsters get a saving throw */
457 if (randint0(100) < chance) continue;
459 if (record_named_pet && is_pet(m_ptr) && m_ptr->nickname)
463 monster_desc(m_name, m_ptr, MD_INDEF_VISIBLE);
464 do_cmd_write_nikki(NIKKI_NAMED_PET, RECORD_NAMED_PET_COMPACT, m_name);
467 /* Delete the monster */
468 delete_monster_idx(i);
470 /* Count the monster */
476 /* Excise dead monsters (backwards!) */
477 for (i = m_max - 1; i >= 1; i--)
479 /* Get the i'th monster */
480 monster_type *m_ptr = &m_list[i];
482 /* Skip real monsters */
483 if (m_ptr->r_idx) continue;
485 /* Move last monster into open hole */
486 compact_monsters_aux(m_max - 1, i);
488 /* Compress "m_max" */
495 * Delete/Remove all the monsters when the player leaves the level
497 * This is an efficient method of simulating multiple calls to the
498 * "delete_monster()" function, with no visual effects.
500 void wipe_m_list(void)
504 /* Hack -- if Banor or Lupart dies, stay another dead */
505 if (!r_info[MON_BANORLUPART].max_num)
507 if (r_info[MON_BANOR].max_num)
509 r_info[MON_BANOR].max_num = 0;
510 r_info[MON_BANOR].r_pkills++;
511 r_info[MON_BANOR].r_akills++;
512 if (r_info[MON_BANOR].r_tkills < MAX_SHORT) r_info[MON_BANOR].r_tkills++;
514 if (r_info[MON_LUPART].max_num)
516 r_info[MON_LUPART].max_num = 0;
517 r_info[MON_LUPART].r_pkills++;
518 r_info[MON_LUPART].r_akills++;
519 if (r_info[MON_LUPART].r_tkills < MAX_SHORT) r_info[MON_LUPART].r_tkills++;
523 /* Delete all the monsters */
524 for (i = m_max - 1; i >= 1; i--)
526 monster_type *m_ptr = &m_list[i];
528 /* Skip dead monsters */
529 if (!m_ptr->r_idx) continue;
531 /* Monster is gone */
532 cave[m_ptr->fy][m_ptr->fx].m_idx = 0;
534 /* Wipe the Monster */
535 (void)WIPE(m_ptr, monster_type);
540 * Wiping racial counters of all monsters and incrementing of racial
541 * counters of monsters in party_mon[] are required to prevent multiple
542 * generation of unique monster who is the minion of player.
545 /* Hack -- Wipe the racial counter of all monster races */
546 for (i = 1; i < max_r_idx; i++) r_info[i].cur_num = 0;
554 /* Reset "mproc_max[]" */
555 for (i = 0; i < MAX_MTIMED; i++) mproc_max[i] = 0;
557 /* Hack -- reset "reproducer" count */
560 /* Hack -- no more target */
565 /* Hack -- no more tracking */
571 * Acquires and returns the index of a "free" monster.
573 * This routine should almost never fail, but it *can* happen.
580 /* Normal allocation */
581 if (m_max < max_m_idx)
583 /* Access the next hole */
586 /* Expand the array */
592 /* Return the index */
597 /* Recycle dead monsters */
598 for (i = 1; i < m_max; i++)
602 /* Acquire monster */
605 /* Skip live monsters */
606 if (m_ptr->r_idx) continue;
611 /* Use this monster */
616 /* Warn the player (except during dungeon creation) */
617 if (character_dungeon) msg_print(_("モンスターが多すぎる!", "Too many monsters!"));
619 /* Try not to crash */
627 * Hack -- the "type" of the current "summon specific"
629 static int summon_specific_type = 0;
633 * Hack -- the index of the summoning monster
635 static int summon_specific_who = -1;
638 static bool summon_unique_okay = FALSE;
641 static bool summon_specific_aux(int r_idx)
643 monster_race *r_ptr = &r_info[r_idx];
646 /* Check our requirements */
647 switch (summon_specific_type)
651 okay = (r_ptr->d_char == 'a');
657 okay = (r_ptr->d_char == 'S');
663 okay = ((r_ptr->d_char == 'C') || (r_ptr->d_char == 'Z'));
669 okay = (r_ptr->d_char == 'M');
675 okay = (r_ptr->d_char == 'A' && ((r_ptr->flags3 & RF3_EVIL) || (r_ptr->flags3 & RF3_GOOD)));
681 okay = (r_ptr->flags3 & RF3_DEMON);
687 okay = (r_ptr->flags3 & RF3_UNDEAD);
693 okay = (r_ptr->flags3 & RF3_DRAGON);
697 case SUMMON_HI_UNDEAD:
699 okay = ((r_ptr->d_char == 'L') ||
700 (r_ptr->d_char == 'V') ||
701 (r_ptr->d_char == 'W'));
705 case SUMMON_HI_DRAGON:
707 okay = (r_ptr->d_char == 'D');
711 case SUMMON_HI_DEMON:
713 okay = (((r_ptr->d_char == 'U') ||
714 (r_ptr->d_char == 'H') ||
715 (r_ptr->d_char == 'B')) &&
716 (r_ptr->flags3 & RF3_DEMON)) ? TRUE : FALSE;
720 case SUMMON_AMBERITES:
722 okay = (r_ptr->flags3 & (RF3_AMBERITE)) ? TRUE : FALSE;
728 okay = (r_ptr->flags1 & (RF1_UNIQUE)) ? TRUE : FALSE;
732 case SUMMON_BIZARRE1:
734 okay = (r_ptr->d_char == 'm');
737 case SUMMON_BIZARRE2:
739 okay = (r_ptr->d_char == 'b');
742 case SUMMON_BIZARRE3:
744 okay = (r_ptr->d_char == 'Q');
748 case SUMMON_BIZARRE4:
750 okay = (r_ptr->d_char == 'v');
754 case SUMMON_BIZARRE5:
756 okay = (r_ptr->d_char == '$');
760 case SUMMON_BIZARRE6:
762 okay = ((r_ptr->d_char == '!') ||
763 (r_ptr->d_char == '?') ||
764 (r_ptr->d_char == '=') ||
765 (r_ptr->d_char == '$') ||
766 (r_ptr->d_char == '|'));
772 okay = (r_ptr->d_char == 'g');
778 okay = ((r_ptr->d_char == 'U') &&
779 (r_ptr->flags4 & RF4_ROCKET));
786 okay = ((r_ptr->d_char == summon_kin_type) && (r_idx != MON_HAGURE));
792 okay = (r_idx == MON_DAWN);
798 okay = (r_ptr->flags3 & (RF3_ANIMAL));
802 case SUMMON_ANIMAL_RANGER:
804 okay = ((r_ptr->flags3 & (RF3_ANIMAL)) &&
805 (my_strchr("abcflqrwBCHIJKMRS", r_ptr->d_char)) &&
806 !(r_ptr->flags3 & (RF3_DRAGON)) &&
807 !(r_ptr->flags3 & (RF3_EVIL)) &&
808 !(r_ptr->flags3 & (RF3_UNDEAD)) &&
809 !(r_ptr->flags3 & (RF3_DEMON)) &&
810 !(r_ptr->flags2 & (RF2_MULTIPLY)) &&
811 !(r_ptr->flags4 || r_ptr->flags5 || r_ptr->flags6));
815 case SUMMON_HI_DRAGON_LIVING:
817 okay = ((r_ptr->d_char == 'D') && monster_living(r_ptr));
823 okay = monster_living(r_ptr);
829 okay = (r_idx == MON_PHANTOM_B || r_idx == MON_PHANTOM_W);
833 case SUMMON_BLUE_HORROR:
835 okay = (r_idx == MON_BLUE_HORROR);
839 case SUMMON_ELEMENTAL:
841 okay = (r_ptr->d_char == 'E');
847 okay = (r_ptr->d_char == 'v');
853 okay = (r_ptr->d_char == 'H');
859 okay = (r_ptr->d_char == 'B');
863 case SUMMON_KAMIKAZE:
866 for (i = 0; i < 4; i++)
867 if (r_ptr->blow[i].method == RBM_EXPLODE) okay = TRUE;
871 case SUMMON_KAMIKAZE_LIVING:
875 for (i = 0; i < 4; i++)
876 if (r_ptr->blow[i].method == RBM_EXPLODE) okay = TRUE;
877 okay = (okay && monster_living(r_ptr));
883 okay = (r_idx == MON_MANES);
889 okay = (r_idx == MON_LOUSE);
893 case SUMMON_GUARDIANS:
895 okay = (r_ptr->flags7 & RF7_GUARDIAN);
901 okay = ((r_idx == MON_NOV_PALADIN) ||
902 (r_idx == MON_NOV_PALADIN_G) ||
903 (r_idx == MON_PALADIN) ||
904 (r_idx == MON_W_KNIGHT) ||
905 (r_idx == MON_ULTRA_PALADIN) ||
906 (r_idx == MON_KNI_TEMPLAR));
912 okay = (r_ptr->d_char == 'B' &&
913 (r_ptr->flags8 & RF8_WILD_MOUNTAIN) &&
914 (r_ptr->flags8 & RF8_WILD_ONLY));
918 case SUMMON_PIRANHAS:
920 okay = (r_idx == MON_PIRANHA);
924 case SUMMON_ARMAGE_GOOD:
926 okay = (r_ptr->d_char == 'A' && (r_ptr->flags3 & RF3_GOOD));
930 case SUMMON_ARMAGE_EVIL:
932 okay = ((r_ptr->flags3 & RF3_DEMON) ||
933 (r_ptr->d_char == 'A' && (r_ptr->flags3 & RF3_EVIL)));
939 /* Since okay is int, "return (okay);" is not correct. */
940 return (bool)(okay ? TRUE : FALSE);
944 static int chameleon_change_m_idx = 0;
948 * Some dungeon types restrict the possible monsters.
949 * Return TRUE is the monster is OK and FALSE otherwise
951 static bool restrict_monster_to_dungeon(int r_idx)
953 dungeon_info_type *d_ptr = &d_info[dungeon_type];
954 monster_race *r_ptr = &r_info[r_idx];
957 if (d_ptr->flags1 & DF1_CHAMELEON)
959 if (chameleon_change_m_idx) return TRUE;
961 if (d_ptr->flags1 & DF1_NO_MAGIC)
963 if (r_idx != MON_CHAMELEON &&
965 !(r_ptr->flags4 & RF4_NOMAGIC_MASK) &&
966 !(r_ptr->flags5 & RF5_NOMAGIC_MASK) &&
967 !(r_ptr->flags6 & RF6_NOMAGIC_MASK))
970 if (d_ptr->flags1 & DF1_NO_MELEE)
972 if (r_idx == MON_CHAMELEON) return TRUE;
973 if (!(r_ptr->flags4 & (RF4_BOLT_MASK | RF4_BEAM_MASK | RF4_BALL_MASK)) &&
974 !(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)) &&
975 !(r_ptr->flags6 & (RF6_BOLT_MASK | RF6_BEAM_MASK | RF6_BALL_MASK)))
978 if (d_ptr->flags1 & DF1_BEGINNER)
980 if (r_ptr->level > dun_level)
984 if (d_ptr->special_div >= 64) return TRUE;
985 if (summon_specific_type && !(d_ptr->flags1 & DF1_CHAMELEON)) return TRUE;
989 case DUNGEON_MODE_AND:
992 if ((d_ptr->mflags1 & r_ptr->flags1) != d_ptr->mflags1)
997 if ((d_ptr->mflags2 & r_ptr->flags2) != d_ptr->mflags2)
1002 if ((d_ptr->mflags3 & r_ptr->flags3) != d_ptr->mflags3)
1007 if ((d_ptr->mflags4 & r_ptr->flags4) != d_ptr->mflags4)
1012 if ((d_ptr->mflags5 & r_ptr->flags5) != d_ptr->mflags5)
1017 if ((d_ptr->mflags6 & r_ptr->flags6) != d_ptr->mflags6)
1022 if ((d_ptr->mflags7 & r_ptr->flags7) != d_ptr->mflags7)
1027 if ((d_ptr->mflags8 & r_ptr->flags8) != d_ptr->mflags8)
1032 if ((d_ptr->mflags9 & r_ptr->flags9) != d_ptr->mflags9)
1037 if ((d_ptr->mflagsr & r_ptr->flagsr) != d_ptr->mflagsr)
1040 for (a = 0; a < 5; a++)
1041 if (d_ptr->r_char[a] && (d_ptr->r_char[a] != r_ptr->d_char)) return FALSE;
1045 case DUNGEON_MODE_NAND:
1048 if ((d_ptr->mflags1 & r_ptr->flags1) != d_ptr->mflags1)
1053 if ((d_ptr->mflags2 & r_ptr->flags2) != d_ptr->mflags2)
1058 if ((d_ptr->mflags3 & r_ptr->flags3) != d_ptr->mflags3)
1063 if ((d_ptr->mflags4 & r_ptr->flags4) != d_ptr->mflags4)
1068 if ((d_ptr->mflags5 & r_ptr->flags5) != d_ptr->mflags5)
1073 if ((d_ptr->mflags6 & r_ptr->flags6) != d_ptr->mflags6)
1078 if ((d_ptr->mflags7 & r_ptr->flags7) != d_ptr->mflags7)
1083 if ((d_ptr->mflags8 & r_ptr->flags8) != d_ptr->mflags8)
1088 if ((d_ptr->mflags9 & r_ptr->flags9) != d_ptr->mflags9)
1093 if ((d_ptr->mflagsr & r_ptr->flagsr) != d_ptr->mflagsr)
1096 for (a = 0; a < 5; a++)
1097 if (d_ptr->r_char[a] && (d_ptr->r_char[a] != r_ptr->d_char)) return TRUE;
1101 case DUNGEON_MODE_OR:
1102 if (r_ptr->flags1 & d_ptr->mflags1) return TRUE;
1103 if (r_ptr->flags2 & d_ptr->mflags2) return TRUE;
1104 if (r_ptr->flags3 & d_ptr->mflags3) return TRUE;
1105 if (r_ptr->flags4 & d_ptr->mflags4) return TRUE;
1106 if (r_ptr->flags5 & d_ptr->mflags5) return TRUE;
1107 if (r_ptr->flags6 & d_ptr->mflags6) return TRUE;
1108 if (r_ptr->flags7 & d_ptr->mflags7) return TRUE;
1109 if (r_ptr->flags8 & d_ptr->mflags8) return TRUE;
1110 if (r_ptr->flags9 & d_ptr->mflags9) return TRUE;
1111 if (r_ptr->flagsr & d_ptr->mflagsr) return TRUE;
1112 for (a = 0; a < 5; a++)
1113 if (d_ptr->r_char[a] == r_ptr->d_char) return TRUE;
1117 case DUNGEON_MODE_NOR:
1118 if (r_ptr->flags1 & d_ptr->mflags1) return FALSE;
1119 if (r_ptr->flags2 & d_ptr->mflags2) return FALSE;
1120 if (r_ptr->flags3 & d_ptr->mflags3) return FALSE;
1121 if (r_ptr->flags4 & d_ptr->mflags4) return FALSE;
1122 if (r_ptr->flags5 & d_ptr->mflags5) return FALSE;
1123 if (r_ptr->flags6 & d_ptr->mflags6) return FALSE;
1124 if (r_ptr->flags7 & d_ptr->mflags7) return FALSE;
1125 if (r_ptr->flags8 & d_ptr->mflags8) return FALSE;
1126 if (r_ptr->flags9 & d_ptr->mflags9) return FALSE;
1127 if (r_ptr->flagsr & d_ptr->mflagsr) return FALSE;
1128 for (a = 0; a < 5; a++)
1129 if (d_ptr->r_char[a] == r_ptr->d_char) return FALSE;
1138 * Apply a "monster restriction function" to the "monster allocation table"
1140 errr get_mon_num_prep(monster_hook_type monster_hook,
1141 monster_hook_type monster_hook2)
1145 /* Todo: Check the hooks for non-changes */
1147 /* Set the new hooks */
1148 get_mon_num_hook = monster_hook;
1149 get_mon_num2_hook = monster_hook2;
1151 /* Scan the allocation table */
1152 for (i = 0; i < alloc_race_size; i++)
1154 monster_race *r_ptr;
1157 alloc_entry *entry = &alloc_race_table[i];
1160 r_ptr = &r_info[entry->index];
1162 /* Skip monsters which don't pass the restriction */
1163 if ((get_mon_num_hook && !((*get_mon_num_hook)(entry->index))) ||
1164 (get_mon_num2_hook && !((*get_mon_num2_hook)(entry->index))))
1167 if (!p_ptr->inside_battle && !chameleon_change_m_idx &&
1168 summon_specific_type != SUMMON_GUARDIANS)
1170 /* Hack -- don't create questors */
1171 if (r_ptr->flags1 & RF1_QUESTOR)
1174 if (r_ptr->flags7 & RF7_GUARDIAN)
1177 /* Depth Monsters never appear out of depth */
1178 if ((r_ptr->flags1 & (RF1_FORCE_DEPTH)) &&
1179 (r_ptr->level > dun_level))
1183 /* Accept this monster */
1184 entry->prob2 = entry->prob1;
1186 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)
1188 int hoge = entry->prob2 * d_info[dungeon_type].special_div;
1189 entry->prob2 = hoge / 64;
1190 if (randint0(64) < (hoge & 0x3f)) entry->prob2++;
1199 static int mysqrt(int n)
1237 * Choose a monster race that seems "appropriate" to the given level
1239 * This function uses the "prob2" field of the "monster allocation table",
1240 * and various local information, to calculate the "prob3" field of the
1241 * same table, which is then used to choose an "appropriate" monster, in
1242 * a relatively efficient manner.
1244 * Note that "town" monsters will *only* be created in the town, and
1245 * "normal" monsters will *never* be created in the town, unless the
1246 * "level" is "modified", for example, by polymorph or summoning.
1248 * There is a small chance (1/50) of "boosting" the given depth by
1249 * a small amount (up to four levels), except in the town.
1251 * It is (slightly) more likely to acquire a monster of the given level
1252 * than one of a lower level. This is done by choosing several monsters
1253 * appropriate to the given level and keeping the "hardest" one.
1255 * Note that if no monsters are "appropriate", then this function will
1256 * fail, and return zero, but this should *almost* never happen.
1258 s16b get_mon_num(int level)
1263 monster_race *r_ptr;
1264 alloc_entry *table = alloc_race_table;
1266 int pls_kakuritu, pls_level;
1267 int hoge = mysqrt(level*10000L);
1269 if (level > MAX_DEPTH - 1) level = MAX_DEPTH - 1;
1271 pls_kakuritu = MAX(NASTY_MON_MAX, NASTY_MON_BASE - ((dungeon_turn / (TURNS_PER_TICK * 2500L) - hoge / 10)));
1272 pls_level = MIN(NASTY_MON_PLUS_MAX, 3 + dungeon_turn / (TURNS_PER_TICK * 20000L) - hoge / 40 + MIN(5, level / 10)) ;
1274 if (d_info[dungeon_type].flags1 & DF1_MAZE)
1276 pls_kakuritu = MIN(pls_kakuritu / 2, pls_kakuritu - 10);
1277 if (pls_kakuritu < 2) pls_kakuritu = 2;
1282 /* Boost the level */
1283 if (!p_ptr->inside_battle && !(d_info[dungeon_type].flags1 & DF1_BEGINNER))
1285 /* Nightmare mode allows more out-of depth monsters */
1286 if (ironman_nightmare && !randint0(pls_kakuritu))
1288 /* What a bizarre calculation */
1289 level = 1 + (level * MAX_DEPTH / randint1(MAX_DEPTH));
1293 /* Occasional "nasty" monster */
1294 if (!randint0(pls_kakuritu))
1296 /* Pick a level bonus */
1305 /* Process probabilities */
1306 for (i = 0; i < alloc_race_size; i++)
1308 /* Monsters are sorted by depth */
1309 if (table[i].level > level) break;
1314 /* Access the "r_idx" of the chosen monster */
1315 r_idx = table[i].index;
1317 /* Access the actual race */
1318 r_ptr = &r_info[r_idx];
1320 if (!p_ptr->inside_battle && !chameleon_change_m_idx)
1322 /* Hack -- "unique" monsters must be "unique" */
1323 if (((r_ptr->flags1 & (RF1_UNIQUE)) ||
1324 (r_ptr->flags7 & (RF7_NAZGUL))) &&
1325 (r_ptr->cur_num >= r_ptr->max_num))
1330 if ((r_ptr->flags7 & (RF7_UNIQUE2)) &&
1331 (r_ptr->cur_num >= 1))
1336 if (r_idx == MON_BANORLUPART)
1338 if (r_info[MON_BANOR].cur_num > 0) continue;
1339 if (r_info[MON_LUPART].cur_num > 0) continue;
1344 table[i].prob3 = table[i].prob2;
1347 total += table[i].prob3;
1350 /* No legal monsters */
1351 if (total <= 0) return (0);
1353 /* Pick a monster */
1354 value = randint0(total);
1356 /* Find the monster */
1357 for (i = 0; i < alloc_race_size; i++)
1359 /* Found the entry */
1360 if (value < table[i].prob3) break;
1363 value = value - table[i].prob3;
1369 /* Try for a "harder" monster once (50%) or twice (10%) */
1375 /* Pick a monster */
1376 value = randint0(total);
1378 /* Find the monster */
1379 for (i = 0; i < alloc_race_size; i++)
1381 /* Found the entry */
1382 if (value < table[i].prob3) break;
1385 value = value - table[i].prob3;
1388 /* Keep the "best" one */
1389 if (table[i].level < table[j].level) i = j;
1392 /* Try for a "harder" monster twice (10%) */
1398 /* Pick a monster */
1399 value = randint0(total);
1401 /* Find the monster */
1402 for (i = 0; i < alloc_race_size; i++)
1404 /* Found the entry */
1405 if (value < table[i].prob3) break;
1408 value = value - table[i].prob3;
1411 /* Keep the "best" one */
1412 if (table[i].level < table[j].level) i = j;
1416 return (table[i].index);
1424 * Build a string describing a monster in some way.
1426 * We can correctly describe monsters based on their visibility.
1427 * We can force all monsters to be treated as visible or invisible.
1428 * We can build nominatives, objectives, possessives, or reflexives.
1429 * We can selectively pronominalize hidden, visible, or all monsters.
1430 * We can use definite or indefinite descriptions for hidden monsters.
1431 * We can use definite or indefinite descriptions for visible monsters.
1433 * Pronominalization involves the gender whenever possible and allowed,
1434 * so that by cleverly requesting pronominalization / visibility, you
1435 * can get messages like "You hit someone. She screams in agony!".
1437 * Reflexives are acquired by requesting Objective plus Possessive.
1439 * If no m_ptr arg is given (?), the monster is assumed to be hidden,
1440 * unless the "Assume Visible" mode is requested.
1442 * If no r_ptr arg is given, it is extracted from m_ptr and r_info
1443 * If neither m_ptr nor r_ptr is given, the monster is assumed to
1444 * be neuter, singular, and hidden (unless "Assume Visible" is set),
1445 * in which case you may be in trouble... :-)
1447 * I am assuming that no monster name is more than 70 characters long,
1448 * so that "char desc[80];" is sufficiently large for any result.
1451 * MD_OBJECTIVE --> Objective (or Reflexive)
1452 * MD_POSSESSIVE --> Possessive (or Reflexive)
1453 * MD_INDEF_HIDDEN --> Use indefinites for hidden monsters ("something")
1454 * MD_INDEF_VISIBLE --> Use indefinites for visible monsters ("a kobold")
1455 * MD_PRON_HIDDEN --> Pronominalize hidden monsters
1456 * MD_PRON_VISIBLE --> Pronominalize visible monsters
1457 * MD_ASSUME_HIDDEN --> Assume the monster is hidden
1458 * MD_ASSUME_VISIBLE --> Assume the monster is visible
1459 * MD_TRUE_NAME --> Chameleon's true name
1460 * MD_IGNORE_HALLU --> Ignore hallucination, and penetrate shape change
1463 * 0x00 --> Full nominative name ("the kobold") or "it"
1464 * MD_INDEF_HIDDEN --> Full nominative name ("the kobold") or "something"
1465 * MD_ASSUME_VISIBLE --> Genocide resistance name ("the kobold")
1466 * MD_ASSUME_VISIBLE | MD_INDEF_VISIBLE --> Killing name ("a kobold")
1467 * MD_PRON_VISIBLE | MD_POSSESSIVE
1468 * --> Possessive, genderized if visable ("his") or "its"
1469 * MD_PRON_VISIBLE | MD_POSSESSIVE | MD_OBJECTIVE
1470 * --> Reflexive, genderized if visable ("himself") or "itself"
1472 void monster_desc(char *desc, monster_type *m_ptr, int mode)
1475 monster_race *r_ptr;
1479 char silly_name[1024];
1483 r_ptr = &r_info[m_ptr->ap_r_idx];
1485 /* Mode of MD_TRUE_NAME will reveal Chameleon's true name */
1486 if (mode & MD_TRUE_NAME) name = (r_name + real_r_ptr(m_ptr)->name);
1487 else name = (r_name + r_ptr->name);
1489 /* Are we hallucinating? (Idea from Nethack...) */
1490 if (p_ptr->image && !(mode & MD_IGNORE_HALLU))
1494 if (!get_rnd_line(_("silly_j.txt", "silly.txt"), m_ptr->r_idx, silly_name))
1500 monster_race *hallu_race;
1504 hallu_race = &r_info[randint1(max_r_idx - 1)];
1506 while (!hallu_race->name || (hallu_race->flags1 & RF1_UNIQUE));
1508 strcpy(silly_name, (r_name + hallu_race->name));
1511 /* Better not strcpy it, or we could corrupt r_info... */
1515 /* Can we "see" it (exists + forced, or visible + not unforced) */
1516 seen = (m_ptr && ((mode & MD_ASSUME_VISIBLE) || (!(mode & MD_ASSUME_HIDDEN) && m_ptr->ml)));
1518 /* Sexed Pronouns (seen and allowed, or unseen and allowed) */
1519 pron = (m_ptr && ((seen && (mode & MD_PRON_VISIBLE)) || (!seen && (mode & MD_PRON_HIDDEN))));
1522 /* First, try using pronouns, or describing hidden monsters */
1525 /* an encoding of the monster "sex" */
1528 /* Extract the gender (if applicable) */
1529 if (r_ptr->flags1 & (RF1_FEMALE)) kind = 0x20;
1530 else if (r_ptr->flags1 & (RF1_MALE)) kind = 0x10;
1532 /* Ignore the gender (if desired) */
1533 if (!m_ptr || !pron) kind = 0x00;
1536 /* Assume simple result */
1537 res = _("何か", "it");
1539 /* Brute force: split on the possibilities */
1540 switch (kind + (mode & (MD_INDEF_HIDDEN | MD_POSSESSIVE | MD_OBJECTIVE)))
1542 /* Neuter, or unknown */
1544 case 0x00: res = "何か"; break;
1545 case 0x00 + (MD_OBJECTIVE): res = "何か"; break;
1546 case 0x00 + (MD_POSSESSIVE): res = "何かの"; break;
1547 case 0x00 + (MD_POSSESSIVE | MD_OBJECTIVE): res = "何か自身"; break;
1548 case 0x00 + (MD_INDEF_HIDDEN): res = "何か"; break;
1549 case 0x00 + (MD_INDEF_HIDDEN | MD_OBJECTIVE): res = "何か"; break;
1550 case 0x00 + (MD_INDEF_HIDDEN | MD_POSSESSIVE): res = "何か"; break;
1551 case 0x00 + (MD_INDEF_HIDDEN | MD_POSSESSIVE | MD_OBJECTIVE): res = "それ自身"; break;
1553 case 0x00: res = "it"; break;
1554 case 0x00 + (MD_OBJECTIVE): res = "it"; break;
1555 case 0x00 + (MD_POSSESSIVE): res = "its"; break;
1556 case 0x00 + (MD_POSSESSIVE | MD_OBJECTIVE): res = "itself"; break;
1557 case 0x00 + (MD_INDEF_HIDDEN): res = "something"; break;
1558 case 0x00 + (MD_INDEF_HIDDEN | MD_OBJECTIVE): res = "something"; break;
1559 case 0x00 + (MD_INDEF_HIDDEN | MD_POSSESSIVE): res = "something's"; break;
1560 case 0x00 + (MD_INDEF_HIDDEN | MD_POSSESSIVE | MD_OBJECTIVE): res = "itself"; break;
1564 /* Male (assume human if vague) */
1566 case 0x10: res = "彼"; break;
1567 case 0x10 + (MD_OBJECTIVE): res = "彼"; break;
1568 case 0x10 + (MD_POSSESSIVE): res = "彼の"; break;
1569 case 0x10 + (MD_POSSESSIVE | MD_OBJECTIVE): res = "彼自身"; break;
1570 case 0x10 + (MD_INDEF_HIDDEN): res = "誰か"; break;
1571 case 0x10 + (MD_INDEF_HIDDEN | MD_OBJECTIVE): res = "誰か"; break;
1572 case 0x10 + (MD_INDEF_HIDDEN | MD_POSSESSIVE): res = "誰かの"; break;
1573 case 0x10 + (MD_INDEF_HIDDEN | MD_POSSESSIVE | MD_OBJECTIVE): res = "彼自身"; break;
1575 case 0x10: res = "he"; break;
1576 case 0x10 + (MD_OBJECTIVE): res = "him"; break;
1577 case 0x10 + (MD_POSSESSIVE): res = "his"; break;
1578 case 0x10 + (MD_POSSESSIVE | MD_OBJECTIVE): res = "himself"; break;
1579 case 0x10 + (MD_INDEF_HIDDEN): res = "someone"; break;
1580 case 0x10 + (MD_INDEF_HIDDEN | MD_OBJECTIVE): res = "someone"; break;
1581 case 0x10 + (MD_INDEF_HIDDEN | MD_POSSESSIVE): res = "someone's"; break;
1582 case 0x10 + (MD_INDEF_HIDDEN | MD_POSSESSIVE | MD_OBJECTIVE): res = "himself"; break;
1586 /* Female (assume human if vague) */
1588 case 0x20: res = "彼女"; break;
1589 case 0x20 + (MD_OBJECTIVE): res = "彼女"; break;
1590 case 0x20 + (MD_POSSESSIVE): res = "彼女の"; break;
1591 case 0x20 + (MD_POSSESSIVE | MD_OBJECTIVE): res = "彼女自身"; break;
1592 case 0x20 + (MD_INDEF_HIDDEN): res = "誰か"; break;
1593 case 0x20 + (MD_INDEF_HIDDEN | MD_OBJECTIVE): res = "誰か"; break;
1594 case 0x20 + (MD_INDEF_HIDDEN | MD_POSSESSIVE): res = "誰かの"; break;
1595 case 0x20 + (MD_INDEF_HIDDEN | MD_POSSESSIVE | MD_OBJECTIVE): res = "彼女自身"; break;
1597 case 0x20: res = "she"; break;
1598 case 0x20 + (MD_OBJECTIVE): res = "her"; break;
1599 case 0x20 + (MD_POSSESSIVE): res = "her"; break;
1600 case 0x20 + (MD_POSSESSIVE | MD_OBJECTIVE): res = "herself"; break;
1601 case 0x20 + (MD_INDEF_HIDDEN): res = "someone"; break;
1602 case 0x20 + (MD_INDEF_HIDDEN | MD_OBJECTIVE): res = "someone"; break;
1603 case 0x20 + (MD_INDEF_HIDDEN | MD_POSSESSIVE): res = "someone's"; break;
1604 case 0x20 + (MD_INDEF_HIDDEN | MD_POSSESSIVE | MD_OBJECTIVE): res = "herself"; break;
1608 /* Copy the result */
1609 (void)strcpy(desc, res);
1613 /* Handle visible monsters, "reflexive" request */
1614 else if ((mode & (MD_POSSESSIVE | MD_OBJECTIVE)) == (MD_POSSESSIVE | MD_OBJECTIVE))
1616 /* The monster is visible, so use its gender */
1618 if (r_ptr->flags1 & (RF1_FEMALE)) strcpy(desc, "彼女自身");
1619 else if (r_ptr->flags1 & (RF1_MALE)) strcpy(desc, "彼自身");
1620 else strcpy(desc, "それ自身");
1622 if (r_ptr->flags1 & RF1_FEMALE) strcpy(desc, "herself");
1623 else if (r_ptr->flags1 & RF1_MALE) strcpy(desc, "himself");
1624 else strcpy(desc, "itself");
1629 /* Handle all other visible monster requests */
1633 if (is_pet(m_ptr) && !is_original_ap(m_ptr))
1639 while(strncmp(t, "』", 2) && *t) t++;
1643 (void)sprintf(desc, "%s?』", buf);
1646 (void)sprintf(desc, "%s?", name);
1648 (void)sprintf(desc, "%s?", name);
1653 /* It could be a Unique */
1654 if ((r_ptr->flags1 & RF1_UNIQUE) && !(p_ptr->image && !(mode & MD_IGNORE_HALLU)))
1656 /* Start with the name (thus nominative and objective) */
1657 if ((m_ptr->mflag2 & MFLAG2_CHAMELEON) && !(mode & MD_TRUE_NAME))
1663 while (strncmp(t, "』", 2) && *t) t++;
1667 (void)sprintf(desc, "%s?』", buf);
1670 (void)sprintf(desc, "%s?", name);
1672 (void)sprintf(desc, "%s?", name);
1676 /* Inside monster arena, and it is not your mount */
1677 else if (p_ptr->inside_battle &&
1678 !(p_ptr->riding && (&m_list[p_ptr->riding] == m_ptr)))
1680 /* It is a fake unique monster */
1681 (void)sprintf(desc, _("%sもどき", "fake %s"), name);
1686 (void)strcpy(desc, name);
1690 /* It could be an indefinite monster */
1691 else if (mode & MD_INDEF_VISIBLE)
1693 /* XXX Check plurality for "some" */
1695 /* Indefinite monsters need an indefinite article */
1697 (void)strcpy(desc, "");
1699 (void)strcpy(desc, is_a_vowel(name[0]) ? "an " : "a ");
1702 (void)strcat(desc, name);
1705 /* It could be a normal, definite, monster */
1708 /* Definite monsters need a definite article */
1710 (void)strcpy(desc, _("あなたの", "your "));
1712 (void)strcpy(desc, _("", "the "));
1714 (void)strcat(desc, name);
1717 if (m_ptr->nickname)
1719 sprintf(buf,_("「%s」", " called %s"),quark_str(m_ptr->nickname));
1723 if (p_ptr->riding && (&m_list[p_ptr->riding] == m_ptr))
1725 strcat(desc,_("(乗馬中)", "(riding)"));
1728 if ((mode & MD_IGNORE_HALLU) && (m_ptr->mflag2 & MFLAG2_CHAMELEON))
1730 if (r_ptr->flags1 & RF1_UNIQUE)
1732 strcat(desc,_("(カメレオンの王)", "(Chameleon Lord)"));
1736 strcat(desc,_("(カメレオン)", "(Chameleon)"));
1740 if ((mode & MD_IGNORE_HALLU) && !is_original_ap(m_ptr))
1742 strcat(desc, format("(%s)", r_name + r_info[m_ptr->r_idx].name));
1745 /* Handle the Possessive as a special afterthought */
1746 if (mode & MD_POSSESSIVE)
1748 /* XXX Check for trailing "s" */
1750 /* Simply append "apostrophe" and "s" */
1751 (void)strcat(desc, _("の", "'s"));
1760 * Learn about a monster (by "probing" it)
1762 * Return the number of new flags learnt. -Mogami-
1764 int lore_do_probe(int r_idx)
1766 monster_race *r_ptr = &r_info[r_idx];
1770 /* Maximal info about awareness */
1771 if (r_ptr->r_wake != MAX_UCHAR) n++;
1772 if (r_ptr->r_ignore != MAX_UCHAR) n++;
1773 r_ptr->r_wake = r_ptr->r_ignore = MAX_UCHAR;
1775 /* Observe "maximal" attacks */
1776 for (i = 0; i < 4; i++)
1778 /* Examine "actual" blows */
1779 if (r_ptr->blow[i].effect || r_ptr->blow[i].method)
1781 /* Maximal observations */
1782 if (r_ptr->r_blows[i] != MAX_UCHAR) n++;
1783 r_ptr->r_blows[i] = MAX_UCHAR;
1789 (((r_ptr->flags1 & RF1_DROP_4D2) ? 8 : 0) +
1790 ((r_ptr->flags1 & RF1_DROP_3D2) ? 6 : 0) +
1791 ((r_ptr->flags1 & RF1_DROP_2D2) ? 4 : 0) +
1792 ((r_ptr->flags1 & RF1_DROP_1D2) ? 2 : 0) +
1793 ((r_ptr->flags1 & RF1_DROP_90) ? 1 : 0) +
1794 ((r_ptr->flags1 & RF1_DROP_60) ? 1 : 0));
1796 /* Only "valid" drops */
1797 if (!(r_ptr->flags1 & RF1_ONLY_GOLD))
1799 if (r_ptr->r_drop_item != tmp_byte) n++;
1800 r_ptr->r_drop_item = tmp_byte;
1802 if (!(r_ptr->flags1 & RF1_ONLY_ITEM))
1804 if (r_ptr->r_drop_gold != tmp_byte) n++;
1805 r_ptr->r_drop_gold = tmp_byte;
1808 /* Observe many spells */
1809 if (r_ptr->r_cast_spell != MAX_UCHAR) n++;
1810 r_ptr->r_cast_spell = MAX_UCHAR;
1812 /* Count unknown flags */
1813 for (i = 0; i < 32; i++)
1815 if (!(r_ptr->r_flags1 & (1L << i)) &&
1816 (r_ptr->flags1 & (1L << i))) n++;
1817 if (!(r_ptr->r_flags2 & (1L << i)) &&
1818 (r_ptr->flags2 & (1L << i))) n++;
1819 if (!(r_ptr->r_flags3 & (1L << i)) &&
1820 (r_ptr->flags3 & (1L << i))) n++;
1821 if (!(r_ptr->r_flags4 & (1L << i)) &&
1822 (r_ptr->flags4 & (1L << i))) n++;
1823 if (!(r_ptr->r_flags5 & (1L << i)) &&
1824 (r_ptr->flags5 & (1L << i))) n++;
1825 if (!(r_ptr->r_flags6 & (1L << i)) &&
1826 (r_ptr->flags6 & (1L << i))) n++;
1827 if (!(r_ptr->r_flagsr & (1L << i)) &&
1828 (r_ptr->flagsr & (1L << i))) n++;
1830 /* r_flags7 is actually unused */
1832 if (!(r_ptr->r_flags7 & (1L << i)) &&
1833 (r_ptr->flags7 & (1L << i))) n++;
1837 /* Know all the flags */
1838 r_ptr->r_flags1 = r_ptr->flags1;
1839 r_ptr->r_flags2 = r_ptr->flags2;
1840 r_ptr->r_flags3 = r_ptr->flags3;
1841 r_ptr->r_flags4 = r_ptr->flags4;
1842 r_ptr->r_flags5 = r_ptr->flags5;
1843 r_ptr->r_flags6 = r_ptr->flags6;
1844 r_ptr->r_flagsr = r_ptr->flagsr;
1846 /* r_flags7 is actually unused */
1847 /* r_ptr->r_flags7 = r_ptr->flags7; */
1849 /* Know about evolution */
1850 if (!(r_ptr->r_xtra1 & MR1_SINKA)) n++;
1851 r_ptr->r_xtra1 |= MR1_SINKA;
1853 /* Update monster recall window */
1854 if (p_ptr->monster_race_idx == r_idx)
1857 p_ptr->window |= (PW_MONSTER);
1860 /* Return the number of new flags learnt */
1866 * Take note that the given monster just dropped some treasure
1868 * Note that learning the "GOOD"/"GREAT" flags gives information
1869 * about the treasure (even when the monster is killed for the first
1870 * time, such as uniques, and the treasure has not been examined yet).
1872 * This "indirect" method is used to prevent the player from learning
1873 * exactly how much treasure a monster can drop from observing only
1874 * a single example of a drop. This method actually observes how much
1875 * gold and items are dropped, and remembers that information to be
1876 * described later by the monster recall code.
1878 void lore_treasure(int m_idx, int num_item, int num_gold)
1880 monster_type *m_ptr = &m_list[m_idx];
1882 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1884 /* If the monster doesn't have original appearance, don't note */
1885 if (!is_original_ap(m_ptr)) return;
1887 /* Note the number of things dropped */
1888 if (num_item > r_ptr->r_drop_item) r_ptr->r_drop_item = num_item;
1889 if (num_gold > r_ptr->r_drop_gold) r_ptr->r_drop_gold = num_gold;
1891 /* Hack -- memorize the good/great flags */
1892 if (r_ptr->flags1 & (RF1_DROP_GOOD)) r_ptr->r_flags1 |= (RF1_DROP_GOOD);
1893 if (r_ptr->flags1 & (RF1_DROP_GREAT)) r_ptr->r_flags1 |= (RF1_DROP_GREAT);
1895 /* Update monster recall window */
1896 if (p_ptr->monster_race_idx == m_ptr->r_idx)
1899 p_ptr->window |= (PW_MONSTER);
1905 void sanity_blast(monster_type *m_ptr, bool necro)
1907 bool happened = FALSE;
1910 if (p_ptr->inside_battle || !character_dungeon) return;
1915 monster_race *r_ptr = &r_info[m_ptr->ap_r_idx];
1917 power = r_ptr->level / 2;
1919 monster_desc(m_name, m_ptr, 0);
1921 if (!(r_ptr->flags1 & RF1_UNIQUE))
1923 if (r_ptr->flags1 & RF1_FRIENDS)
1929 return; /* No effect yet, just loaded... */
1932 return; /* Cannot see it for some reason */
1934 if (!(r_ptr->flags2 & RF2_ELDRITCH_HORROR))
1940 return; /* Pet eldritch horrors are safe most of the time */
1942 if (randint1(100) > power) return;
1944 if (saving_throw(p_ptr->skill_sav - power))
1946 return; /* Save, no adverse effects */
1951 /* Something silly happens... */
1953 msg_format("%s%sの顔を見てしまった!",
1954 funny_desc[randint0(MAX_SAN_FUNNY)], m_name);
1956 msg_format("You behold the %s visage of %s!",
1957 funny_desc[randint0(MAX_SAN_FUNNY)], m_name);
1963 msg_print(funny_comments[randint0(MAX_SAN_COMMENT)]);
1964 p_ptr->image = p_ptr->image + randint1(r_ptr->level);
1967 return; /* Never mind; we can't see it clearly enough */
1970 /* Something frightening happens... */
1972 msg_format("%s%sの顔を見てしまった!",
1973 horror_desc[randint0(MAX_SAN_HORROR)], m_name);
1975 msg_format("You behold the %s visage of %s!",
1976 horror_desc[randint0(MAX_SAN_HORROR)], m_name);
1979 r_ptr->r_flags2 |= RF2_ELDRITCH_HORROR;
1981 /* Demon characters are unaffected */
1982 if (prace_is_(RACE_IMP) || prace_is_(RACE_DEMON) || (mimic_info[p_ptr->mimic_form].MIMIC_FLAGS & MIMIC_IS_DEMON)) return;
1983 if (p_ptr->wizard) return;
1985 /* Undead characters are 50% likely to be unaffected */
1986 if (prace_is_(RACE_SKELETON) || prace_is_(RACE_ZOMBIE)
1987 || prace_is_(RACE_VAMPIRE) || prace_is_(RACE_SPECTRE) ||
1988 (mimic_info[p_ptr->mimic_form].MIMIC_FLAGS & MIMIC_IS_UNDEAD))
1990 if (saving_throw(25 + p_ptr->lev)) return;
1995 msg_print(_("ネクロノミコンを読んで正気を失った!", "Your sanity is shaken by reading the Necronomicon!"));
1998 if (!saving_throw(p_ptr->skill_sav - power)) /* Mind blast */
2000 if (!p_ptr->resist_conf)
2002 (void)set_confused(p_ptr->confused + randint0(4) + 4);
2004 if (!p_ptr->resist_chaos && one_in_(3))
2006 (void)set_image(p_ptr->image + randint0(250) + 150);
2011 if (!saving_throw(p_ptr->skill_sav - power)) /* Lose int & wis */
2018 if (!saving_throw(p_ptr->skill_sav - power)) /* Brain smash */
2020 if (!p_ptr->resist_conf)
2022 (void)set_confused(p_ptr->confused + randint0(4) + 4);
2024 if (!p_ptr->free_act)
2026 (void)set_paralyzed(p_ptr->paralyzed + randint0(4) + 4);
2028 while (randint0(100) > p_ptr->skill_sav)
2029 (void)do_dec_stat(A_INT);
2030 while (randint0(100) > p_ptr->skill_sav)
2031 (void)do_dec_stat(A_WIS);
2032 if (!p_ptr->resist_chaos)
2034 (void)set_image(p_ptr->image + randint0(250) + 150);
2039 if (!saving_throw(p_ptr->skill_sav - power)) /* Amnesia */
2042 if (lose_all_info())
2043 msg_print(_("あまりの恐怖に全てのことを忘れてしまった!", "You forget everything in your utmost terror!"));
2048 if (saving_throw(p_ptr->skill_sav - power))
2053 /* Else gain permanent insanity */
2054 if ((p_ptr->muta3 & MUT3_MORONIC) && /*(p_ptr->muta2 & MUT2_BERS_RAGE) &&*/
2055 ((p_ptr->muta2 & MUT2_COWARDICE) || (p_ptr->resist_fear)) &&
2056 ((p_ptr->muta2 & MUT2_HALLU) || (p_ptr->resist_chaos)))
2058 /* The poor bastard already has all possible insanities! */
2064 switch (randint1(21))
2067 if (!(p_ptr->muta3 & MUT3_MORONIC) && one_in_(5))
2069 if ((p_ptr->stat_use[A_INT] < 4) && (p_ptr->stat_use[A_WIS] < 4))
2071 msg_print(_("あなたは完璧な馬鹿になったような気がした。しかしそれは元々だった。", "You turn into an utter moron!"));
2075 msg_print(_("あなたは完璧な馬鹿になった!", "You turn into an utter moron!"));
2078 if (p_ptr->muta3 & MUT3_HYPER_INT)
2080 msg_print(_("あなたの脳は生体コンピュータではなくなった。", "Your brain is no longer a living computer."));
2081 p_ptr->muta3 &= ~(MUT3_HYPER_INT);
2083 p_ptr->muta3 |= MUT3_MORONIC;
2097 if (!(p_ptr->muta2 & MUT2_COWARDICE) && !p_ptr->resist_fear)
2099 msg_print(_("あなたはパラノイアになった!", "You become paranoid!"));
2101 /* Duh, the following should never happen, but anyway... */
2102 if (p_ptr->muta3 & MUT3_FEARLESS)
2104 msg_print(_("あなたはもう恐れ知らずではなくなった。", "You are no longer fearless."));
2105 p_ptr->muta3 &= ~(MUT3_FEARLESS);
2108 p_ptr->muta2 |= MUT2_COWARDICE;
2122 if (!(p_ptr->muta2 & MUT2_HALLU) && !p_ptr->resist_chaos)
2124 msg_print(_("幻覚をひき起こす精神錯乱に陥った!", "You are afflicted by a hallucinatory insanity!"));
2125 p_ptr->muta2 |= MUT2_HALLU;
2130 if (!(p_ptr->muta2 & MUT2_BERS_RAGE))
2132 msg_print(_("激烈な感情の発作におそわれるようになった!", "You become subject to fits of berserk rage!"));
2133 p_ptr->muta2 |= MUT2_BERS_RAGE;
2140 p_ptr->update |= PU_BONUS;
2146 * This function updates the monster record of the given monster
2148 * This involves extracting the distance to the player (if requested),
2149 * and then checking for visibility (natural, infravision, see-invis,
2150 * telepathy), updating the monster visibility flag, redrawing (or
2151 * erasing) the monster when its visibility changes, and taking note
2152 * of any interesting monster flags (cold-blooded, invisible, etc).
2154 * Note the new "mflag" field which encodes several monster state flags,
2155 * including "view" for when the monster is currently in line of sight,
2156 * and "mark" for when the monster is currently visible via detection.
2158 * The only monster fields that are changed here are "cdis" (the
2159 * distance from the player), "ml" (visible to the player), and
2160 * "mflag" (to maintain the "MFLAG_VIEW" flag).
2162 * Note the special "update_monsters()" function which can be used to
2163 * call this function once for every monster.
2165 * Note the "full" flag which requests that the "cdis" field be updated,
2166 * this is only needed when the monster (or the player) has moved.
2168 * Every time a monster moves, we must call this function for that
2169 * monster, and update the distance, and the visibility. Every time
2170 * the player moves, we must call this function for every monster, and
2171 * update the distance, and the visibility. Whenever the player "state"
2172 * changes in certain ways ("blindness", "infravision", "telepathy",
2173 * and "see invisible"), we must call this function for every monster,
2174 * and update the visibility.
2176 * Routines that change the "illumination" of a grid must also call this
2177 * function for any monster in that grid, since the "visibility" of some
2178 * monsters may be based on the illumination of their grid.
2180 * Note that this function is called once per monster every time the
2181 * player moves. When the player is running, this function is one
2182 * of the primary bottlenecks, along with "update_view()" and the
2183 * "process_monsters()" code, so efficiency is important.
2185 * Note the optimized "inline" version of the "distance()" function.
2187 * A monster is "visible" to the player if (1) it has been detected
2188 * by the player, (2) it is close to the player and the player has
2189 * telepathy, or (3) it is close to the player, and in line of sight
2190 * of the player, and it is "illuminated" by some combination of
2191 * infravision, torch light, or permanent light (invisible monsters
2192 * are only affected by "light" if the player can see invisible).
2194 * Monsters which are not on the current panel may be "visible" to
2195 * the player, and their descriptions will include an "offscreen"
2196 * reference. Currently, offscreen monsters cannot be targetted
2197 * or viewed directly, but old targets will remain set. XXX XXX
2199 * The player can choose to be disturbed by several things, including
2200 * "disturb_move" (monster which is viewable moves in some way), and
2201 * "disturb_near" (monster which is "easily" viewable moves in some
2202 * way). Note that "moves" includes "appears" and "disappears".
2204 void update_mon(int m_idx, bool full)
2206 monster_type *m_ptr = &m_list[m_idx];
2208 monster_race *r_ptr = &r_info[m_ptr->r_idx];
2210 bool do_disturb = disturb_move;
2214 /* Current location */
2221 /* Seen by vision */
2224 /* Non-Ninja player in the darkness */
2225 bool in_darkness = (d_info[dungeon_type].flags1 & DF1_DARKNESS) && !p_ptr->see_nocto;
2230 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
2232 if (ap_r_ptr->r_tkills && ap_r_ptr->level >= p_ptr->lev)
2236 /* Compute distance */
2239 /* Distance components */
2240 int dy = (py > fy) ? (py - fy) : (fy - py);
2241 int dx = (px > fx) ? (px - fx) : (fx - px);
2243 /* Approximate distance */
2244 d = (dy > dx) ? (dy + (dx>>1)) : (dx + (dy>>1));
2246 /* Restrict distance */
2247 if (d > 255) d = 255;
2251 /* Save the distance */
2255 /* Extract distance */
2258 /* Extract the distance */
2264 if (m_ptr->mflag2 & (MFLAG2_MARK)) flag = TRUE;
2268 if (d <= (in_darkness ? MAX_SIGHT / 2 : MAX_SIGHT))
2270 if (!in_darkness || (d <= MAX_SIGHT / 4))
2272 if (p_ptr->special_defense & KATA_MUSOU)
2277 if (is_original_ap(m_ptr) && !p_ptr->image)
2279 /* Hack -- Memorize mental flags */
2280 if (r_ptr->flags2 & (RF2_SMART)) r_ptr->r_flags2 |= (RF2_SMART);
2281 if (r_ptr->flags2 & (RF2_STUPID)) r_ptr->r_flags2 |= (RF2_STUPID);
2285 /* Basic telepathy */
2286 /* Snipers get telepathy when they concentrate deeper */
2287 else if (p_ptr->telepathy)
2289 /* Empty mind, no telepathy */
2290 if (r_ptr->flags2 & (RF2_EMPTY_MIND))
2292 /* Memorize flags */
2293 if (is_original_ap(m_ptr) && !p_ptr->image) r_ptr->r_flags2 |= (RF2_EMPTY_MIND);
2296 /* Weird mind, occasional telepathy */
2297 else if (r_ptr->flags2 & (RF2_WEIRD_MIND))
2299 /* One in ten individuals are detectable */
2300 if ((m_idx % 10) == 5)
2305 if (is_original_ap(m_ptr) && !p_ptr->image)
2307 /* Memorize flags */
2308 r_ptr->r_flags2 |= (RF2_WEIRD_MIND);
2310 /* Hack -- Memorize mental flags */
2311 if (r_ptr->flags2 & (RF2_SMART)) r_ptr->r_flags2 |= (RF2_SMART);
2312 if (r_ptr->flags2 & (RF2_STUPID)) r_ptr->r_flags2 |= (RF2_STUPID);
2317 /* Normal mind, allow telepathy */
2323 if (is_original_ap(m_ptr) && !p_ptr->image)
2325 /* Hack -- Memorize mental flags */
2326 if (r_ptr->flags2 & (RF2_SMART)) r_ptr->r_flags2 |= (RF2_SMART);
2327 if (r_ptr->flags2 & (RF2_STUPID)) r_ptr->r_flags2 |= (RF2_STUPID);
2332 /* Magical sensing */
2333 if ((p_ptr->esp_animal) && (r_ptr->flags3 & (RF3_ANIMAL)))
2336 if (is_original_ap(m_ptr) && !p_ptr->image) r_ptr->r_flags3 |= (RF3_ANIMAL);
2339 /* Magical sensing */
2340 if ((p_ptr->esp_undead) && (r_ptr->flags3 & (RF3_UNDEAD)))
2343 if (is_original_ap(m_ptr) && !p_ptr->image) r_ptr->r_flags3 |= (RF3_UNDEAD);
2346 /* Magical sensing */
2347 if ((p_ptr->esp_demon) && (r_ptr->flags3 & (RF3_DEMON)))
2350 if (is_original_ap(m_ptr) && !p_ptr->image) r_ptr->r_flags3 |= (RF3_DEMON);
2353 /* Magical sensing */
2354 if ((p_ptr->esp_orc) && (r_ptr->flags3 & (RF3_ORC)))
2357 if (is_original_ap(m_ptr) && !p_ptr->image) r_ptr->r_flags3 |= (RF3_ORC);
2360 /* Magical sensing */
2361 if ((p_ptr->esp_troll) && (r_ptr->flags3 & (RF3_TROLL)))
2364 if (is_original_ap(m_ptr) && !p_ptr->image) r_ptr->r_flags3 |= (RF3_TROLL);
2367 /* Magical sensing */
2368 if ((p_ptr->esp_giant) && (r_ptr->flags3 & (RF3_GIANT)))
2371 if (is_original_ap(m_ptr) && !p_ptr->image) r_ptr->r_flags3 |= (RF3_GIANT);
2374 /* Magical sensing */
2375 if ((p_ptr->esp_dragon) && (r_ptr->flags3 & (RF3_DRAGON)))
2378 if (is_original_ap(m_ptr) && !p_ptr->image) r_ptr->r_flags3 |= (RF3_DRAGON);
2381 /* Magical sensing */
2382 if ((p_ptr->esp_human) && (r_ptr->flags2 & (RF2_HUMAN)))
2385 if (is_original_ap(m_ptr) && !p_ptr->image) r_ptr->r_flags2 |= (RF2_HUMAN);
2388 /* Magical sensing */
2389 if ((p_ptr->esp_evil) && (r_ptr->flags3 & (RF3_EVIL)))
2392 if (is_original_ap(m_ptr) && !p_ptr->image) r_ptr->r_flags3 |= (RF3_EVIL);
2395 /* Magical sensing */
2396 if ((p_ptr->esp_good) && (r_ptr->flags3 & (RF3_GOOD)))
2399 if (is_original_ap(m_ptr) && !p_ptr->image) r_ptr->r_flags3 |= (RF3_GOOD);
2402 /* Magical sensing */
2403 if ((p_ptr->esp_nonliving) &&
2404 ((r_ptr->flags3 & (RF3_DEMON | RF3_UNDEAD | RF3_NONLIVING)) == RF3_NONLIVING))
2407 if (is_original_ap(m_ptr) && !p_ptr->image) r_ptr->r_flags3 |= (RF3_NONLIVING);
2410 /* Magical sensing */
2411 if ((p_ptr->esp_unique) && (r_ptr->flags1 & (RF1_UNIQUE)))
2414 if (is_original_ap(m_ptr) && !p_ptr->image) r_ptr->r_flags1 |= (RF1_UNIQUE);
2418 /* Normal line of sight, and not blind */
2419 if (player_has_los_bold(fy, fx) && !p_ptr->blind)
2421 bool do_invisible = FALSE;
2422 bool do_cold_blood = FALSE;
2424 /* Snipers can see targets in darkness when they concentrate deeper */
2425 if (p_ptr->concent >= CONCENT_RADAR_THRESHOLD)
2431 /* Use "infravision" */
2432 if (d <= p_ptr->see_infra)
2434 /* Handle "cold blooded" monsters */
2435 if ((r_ptr->flags2 & (RF2_COLD_BLOOD | RF2_AURA_FIRE)) == RF2_COLD_BLOOD)
2438 do_cold_blood = TRUE;
2441 /* Handle "warm blooded" monsters */
2449 /* Use "illumination" */
2450 if (player_can_see_bold(fy, fx))
2452 /* Handle "invisible" monsters */
2453 if (r_ptr->flags2 & (RF2_INVISIBLE))
2456 do_invisible = TRUE;
2466 /* Handle "normal" monsters */
2477 if (is_original_ap(m_ptr) && !p_ptr->image)
2479 /* Memorize flags */
2480 if (do_invisible) r_ptr->r_flags2 |= (RF2_INVISIBLE);
2481 if (do_cold_blood) r_ptr->r_flags2 |= (RF2_COLD_BLOOD);
2488 /* The monster is now visible */
2491 /* It was previously unseen */
2494 /* Mark as visible */
2497 /* Draw the monster */
2500 /* Update health bar as needed */
2501 if (p_ptr->health_who == m_idx) p_ptr->redraw |= (PR_HEALTH);
2502 if (p_ptr->riding == m_idx) p_ptr->redraw |= (PR_UHEALTH);
2504 /* Hack -- Count "fresh" sightings */
2507 if ((m_ptr->ap_r_idx == MON_KAGE) && (r_info[MON_KAGE].r_sights < MAX_SHORT))
2508 r_info[MON_KAGE].r_sights++;
2509 else if (is_original_ap(m_ptr) && (r_ptr->r_sights < MAX_SHORT))
2513 /* Eldritch Horror */
2514 if (r_info[m_ptr->ap_r_idx].flags2 & RF2_ELDRITCH_HORROR)
2516 sanity_blast(m_ptr, FALSE);
2519 /* Disturb on appearance */
2520 if (disturb_near && (projectable(m_ptr->fy, m_ptr->fx, py, px) && projectable(py, px, m_ptr->fy, m_ptr->fx)))
2522 if (disturb_pets || is_hostile(m_ptr))
2528 /* The monster is not visible */
2531 /* It was previously seen */
2534 /* Mark as not visible */
2537 /* Erase the monster */
2540 /* Update health bar as needed */
2541 if (p_ptr->health_who == m_idx) p_ptr->redraw |= (PR_HEALTH);
2542 if (p_ptr->riding == m_idx) p_ptr->redraw |= (PR_UHEALTH);
2544 /* Disturb on disappearance */
2547 if (disturb_pets || is_hostile(m_ptr))
2554 /* The monster is now easily visible */
2558 if (!(m_ptr->mflag & (MFLAG_VIEW)))
2560 /* Mark as easily visible */
2561 m_ptr->mflag |= (MFLAG_VIEW);
2563 /* Disturb on appearance */
2566 if (disturb_pets || is_hostile(m_ptr))
2572 /* The monster is not easily visible */
2576 if (m_ptr->mflag & (MFLAG_VIEW))
2578 /* Mark as not easily visible */
2579 m_ptr->mflag &= ~(MFLAG_VIEW);
2581 /* Disturb on disappearance */
2584 if (disturb_pets || is_hostile(m_ptr))
2593 * This function simply updates all the (non-dead) monsters (see above).
2595 void update_monsters(bool full)
2599 /* Update each (live) monster */
2600 for (i = 1; i < m_max; i++)
2602 monster_type *m_ptr = &m_list[i];
2604 /* Skip dead monsters */
2605 if (!m_ptr->r_idx) continue;
2607 /* Update the monster */
2608 update_mon(i, full);
2614 * Hack -- the index of the summoning monster
2616 static bool monster_hook_chameleon_lord(int r_idx)
2618 monster_race *r_ptr = &r_info[r_idx];
2619 monster_type *m_ptr = &m_list[chameleon_change_m_idx];
2620 monster_race *old_r_ptr = &r_info[m_ptr->r_idx];
2622 if (!(r_ptr->flags1 & (RF1_UNIQUE))) return FALSE;
2623 if (r_ptr->flags7 & (RF7_FRIENDLY | RF7_CHAMELEON)) return FALSE;
2625 if (ABS(r_ptr->level - r_info[MON_CHAMELEON_K].level) > 5) return FALSE;
2627 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))
2630 if (!monster_can_cross_terrain(cave[m_ptr->fy][m_ptr->fx].feat, r_ptr, 0)) return FALSE;
2633 if (!(old_r_ptr->flags7 & RF7_CHAMELEON))
2635 if (monster_has_hostile_align(m_ptr, 0, 0, r_ptr)) return FALSE;
2639 else if (summon_specific_who > 0)
2641 if (monster_has_hostile_align(&m_list[summon_specific_who], 0, 0, r_ptr)) return FALSE;
2647 static bool monster_hook_chameleon(int r_idx)
2649 monster_race *r_ptr = &r_info[r_idx];
2650 monster_type *m_ptr = &m_list[chameleon_change_m_idx];
2651 monster_race *old_r_ptr = &r_info[m_ptr->r_idx];
2653 if (r_ptr->flags1 & (RF1_UNIQUE)) return FALSE;
2654 if (r_ptr->flags2 & RF2_MULTIPLY) return FALSE;
2655 if (r_ptr->flags7 & (RF7_FRIENDLY | RF7_CHAMELEON)) return FALSE;
2657 if ((r_ptr->blow[0].method == RBM_EXPLODE) || (r_ptr->blow[1].method == RBM_EXPLODE) || (r_ptr->blow[2].method == RBM_EXPLODE) || (r_ptr->blow[3].method == RBM_EXPLODE))
2660 if (!monster_can_cross_terrain(cave[m_ptr->fy][m_ptr->fx].feat, r_ptr, 0)) return FALSE;
2663 if (!(old_r_ptr->flags7 & RF7_CHAMELEON))
2665 if ((old_r_ptr->flags3 & RF3_GOOD) && !(r_ptr->flags3 & RF3_GOOD)) return FALSE;
2666 if ((old_r_ptr->flags3 & RF3_EVIL) && !(r_ptr->flags3 & RF3_EVIL)) return FALSE;
2667 if (!(old_r_ptr->flags3 & (RF3_GOOD | RF3_EVIL)) && (r_ptr->flags3 & (RF3_GOOD | RF3_EVIL))) return FALSE;
2671 else if (summon_specific_who > 0)
2673 if (monster_has_hostile_align(&m_list[summon_specific_who], 0, 0, r_ptr)) return FALSE;
2676 return (*(get_monster_hook()))(r_idx);
2680 void choose_new_monster(int m_idx, bool born, int r_idx)
2683 monster_type *m_ptr = &m_list[m_idx];
2684 monster_race *r_ptr;
2685 char old_m_name[80];
2686 bool old_unique = FALSE;
2687 int old_r_idx = m_ptr->r_idx;
2689 if (r_info[m_ptr->r_idx].flags1 & RF1_UNIQUE)
2691 if (old_unique && (r_idx == MON_CHAMELEON)) r_idx = MON_CHAMELEON_K;
2692 r_ptr = &r_info[r_idx];
2694 monster_desc(old_m_name, m_ptr, 0);
2700 chameleon_change_m_idx = m_idx;
2702 get_mon_num_prep(monster_hook_chameleon_lord, NULL);
2704 get_mon_num_prep(monster_hook_chameleon, NULL);
2707 level = r_info[MON_CHAMELEON_K].level;
2708 else if (!dun_level)
2709 level = wilderness[p_ptr->wilderness_y][p_ptr->wilderness_x].level;
2713 if (d_info[dungeon_type].flags1 & DF1_CHAMELEON) level+= 2+randint1(3);
2715 r_idx = get_mon_num(level);
2716 r_ptr = &r_info[r_idx];
2718 chameleon_change_m_idx = 0;
2724 if (is_pet(m_ptr)) check_pets_num_and_align(m_ptr, FALSE);
2726 m_ptr->r_idx = r_idx;
2727 m_ptr->ap_r_idx = r_idx;
2728 update_mon(m_idx, FALSE);
2729 lite_spot(m_ptr->fy, m_ptr->fx);
2731 if ((r_info[old_r_idx].flags7 & (RF7_LITE_MASK | RF7_DARK_MASK)) ||
2732 (r_ptr->flags7 & (RF7_LITE_MASK | RF7_DARK_MASK)))
2733 p_ptr->update |= (PU_MON_LITE);
2735 if (is_pet(m_ptr)) check_pets_num_and_align(m_ptr, TRUE);
2739 /* Sub-alignment of a chameleon */
2740 if (r_ptr->flags3 & (RF3_EVIL | RF3_GOOD))
2742 m_ptr->sub_align = SUB_ALIGN_NEUTRAL;
2743 if (r_ptr->flags3 & RF3_EVIL) m_ptr->sub_align |= SUB_ALIGN_EVIL;
2744 if (r_ptr->flags3 & RF3_GOOD) m_ptr->sub_align |= SUB_ALIGN_GOOD;
2749 if (m_idx == p_ptr->riding)
2752 monster_desc(m_name, m_ptr, 0);
2753 msg_format(_("突然%sが変身した。", "Suddenly, %s transforms!"), old_m_name);
2754 if (!(r_ptr->flags7 & RF7_RIDING))
2755 if (rakuba(0, TRUE)) msg_format(_("地面に落とされた。", "You have fallen from %s."), m_name);
2758 /* Extract the monster base speed */
2759 m_ptr->mspeed = get_mspeed(r_ptr);
2761 oldmaxhp = m_ptr->max_maxhp;
2762 /* Assign maximal hitpoints */
2763 if (r_ptr->flags1 & RF1_FORCE_MAXHP)
2765 m_ptr->max_maxhp = maxroll(r_ptr->hdice, r_ptr->hside);
2769 m_ptr->max_maxhp = damroll(r_ptr->hdice, r_ptr->hside);
2772 /* Monsters have double hitpoints in Nightmare mode */
2773 if (ironman_nightmare)
2775 u32b hp = m_ptr->max_maxhp * 2L;
2776 m_ptr->max_maxhp = (s16b)MIN(30000, hp);
2779 m_ptr->maxhp = (long)(m_ptr->maxhp * m_ptr->max_maxhp) / oldmaxhp;
2780 if (m_ptr->maxhp < 1) m_ptr->maxhp = 1;
2781 m_ptr->hp = (long)(m_ptr->hp * m_ptr->max_maxhp) / oldmaxhp;
2783 /* reset dealt_damage */
2784 m_ptr->dealt_damage = 0;
2791 static bool monster_hook_tanuki(int r_idx)
2793 monster_race *r_ptr = &r_info[r_idx];
2795 if (r_ptr->flags1 & (RF1_UNIQUE)) return FALSE;
2796 if (r_ptr->flags2 & RF2_MULTIPLY) return FALSE;
2797 if (r_ptr->flags7 & (RF7_FRIENDLY | RF7_CHAMELEON)) return FALSE;
2798 if (r_ptr->flags7 & RF7_AQUATIC) return FALSE;
2800 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))
2803 return (*(get_monster_hook()))(r_idx);
2808 * Set initial racial appearance of a monster
2810 static int initial_r_appearance(int r_idx)
2812 int attempts = 1000;
2815 int min = MIN(base_level-5, 50);
2817 if (!(r_info[r_idx].flags7 & RF7_TANUKI))
2820 get_mon_num_prep(monster_hook_tanuki, NULL);
2824 ap_r_idx = get_mon_num(base_level + 10);
2825 if (r_info[ap_r_idx].level >= min) return ap_r_idx;
2833 * Get initial monster speed
2835 byte get_mspeed(monster_race *r_ptr)
2837 /* Extract the monster base speed */
2838 int mspeed = r_ptr->speed;
2840 /* Hack -- small racial variety */
2841 if (!(r_ptr->flags1 & RF1_UNIQUE) && !p_ptr->inside_arena)
2843 /* Allow some small variation per monster */
2844 int i = SPEED_TO_ENERGY(r_ptr->speed) / (one_in_(4) ? 3 : 10);
2845 if (i) mspeed += rand_spread(0, i);
2848 if (mspeed > 199) mspeed = 199;
2850 return (byte)mspeed;
2855 * Attempt to place a monster of the given race at the given location.
2857 * To give the player a sporting chance, any monster that appears in
2858 * line-of-sight and is extremely dangerous can be marked as
2859 * "FORCE_SLEEP", which will cause them to be placed with low energy,
2860 * which often (but not always) lets the player move before they do.
2862 * This routine refuses to place out-of-depth "FORCE_DEPTH" monsters.
2864 * XXX XXX XXX Use special "here" and "dead" flags for unique monsters,
2865 * remove old "cur_num" and "max_num" fields.
2867 * XXX XXX XXX Actually, do something similar for artifacts, to simplify
2868 * the "preserve" mode, and to make the "what artifacts" flag more useful.
2870 * This is the only function which may place a monster in the dungeon,
2871 * except for the savefile loading code.
2873 static bool place_monster_one(int who, int y, int x, int r_idx, u32b mode)
2875 /* Access the location */
2876 cave_type *c_ptr = &cave[y][x];
2878 monster_type *m_ptr;
2880 monster_race *r_ptr = &r_info[r_idx];
2882 cptr name = (r_name + r_ptr->name);
2886 /* DO NOT PLACE A MONSTER IN THE SMALL SCALE WILDERNESS !!! */
2887 if (p_ptr->wild_mode) return FALSE;
2889 /* Verify location */
2890 if (!in_bounds(y, x)) return (FALSE);
2893 if (!r_idx) return (FALSE);
2896 if (!r_ptr->name) return (FALSE);
2898 if (!(mode & PM_IGNORE_TERRAIN))
2900 /* Not on the Pattern */
2901 if (pattern_tile(y, x)) return FALSE;
2903 /* Require empty space (if not ghostly) */
2904 if (!monster_can_enter(y, x, r_ptr, 0)) return FALSE;
2907 if (!p_ptr->inside_battle)
2909 /* Hack -- "unique" monsters must be "unique" */
2910 if (((r_ptr->flags1 & (RF1_UNIQUE)) ||
2911 (r_ptr->flags7 & (RF7_NAZGUL))) &&
2912 (r_ptr->cur_num >= r_ptr->max_num))
2918 if ((r_ptr->flags7 & (RF7_UNIQUE2)) &&
2919 (r_ptr->cur_num >= 1))
2924 if (r_idx == MON_BANORLUPART)
2926 if (r_info[MON_BANOR].cur_num > 0) return FALSE;
2927 if (r_info[MON_LUPART].cur_num > 0) return FALSE;
2930 /* Depth monsters may NOT be created out of depth, unless in Nightmare mode */
2931 if ((r_ptr->flags1 & (RF1_FORCE_DEPTH)) && (dun_level < r_ptr->level) &&
2932 (!ironman_nightmare || (r_ptr->flags1 & (RF1_QUESTOR))))
2939 if (quest_number(dun_level))
2941 int hoge = quest_number(dun_level);
2942 if ((quest[hoge].type == QUEST_TYPE_KILL_LEVEL) || (quest[hoge].type == QUEST_TYPE_RANDOM))
2944 if(r_idx == quest[hoge].r_idx)
2946 int number_mon, i2, j2;
2949 /* Count all quest monsters */
2950 for (i2 = 0; i2 < cur_wid; ++i2)
2951 for (j2 = 0; j2 < cur_hgt; j2++)
2952 if (cave[j2][i2].m_idx > 0)
2953 if (m_list[cave[j2][i2].m_idx].r_idx == quest[hoge].r_idx)
2955 if(number_mon + quest[hoge].cur_num >= quest[hoge].max_num)
2961 if (is_glyph_grid(c_ptr))
2963 if (randint1(BREAK_GLYPH) < (r_ptr->level+20))
2965 /* Describe observable breakage */
2966 if (c_ptr->info & CAVE_MARK)
2968 msg_print(_("守りのルーンが壊れた!", "The rune of protection is broken!"));
2971 /* Forget the rune */
2972 c_ptr->info &= ~(CAVE_MARK);
2974 /* Break the rune */
2975 c_ptr->info &= ~(CAVE_OBJECT);
2984 /* Powerful monster */
2985 if (r_ptr->level > dun_level)
2987 /* Unique monsters */
2988 if (r_ptr->flags1 & (RF1_UNIQUE))
2990 /* Message for cheaters */
2991 if (cheat_hear) msg_format(_("深層のユニーク・モンスター (%s)。", "Deep Unique (%s)."), name);
2994 /* Normal monsters */
2997 /* Message for cheaters */
2998 if (cheat_hear) msg_format(_("深層のモンスター (%s)。", "Deep Monster (%s)."), name);
3002 /* Note the monster */
3003 else if (r_ptr->flags1 & (RF1_UNIQUE))
3005 /* Unique monsters induce message */
3006 if (cheat_hear) msg_format(_("ユニーク・モンスター (%s)。", "Unique (%s)."), name);
3009 if ((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags7 & RF7_NAZGUL) || (r_ptr->level < 10)) mode &= ~PM_KAGE;
3011 /* Make a new monster */
3012 c_ptr->m_idx = m_pop();
3013 hack_m_idx_ii = c_ptr->m_idx;
3015 /* Mega-Hack -- catch "failure" */
3016 if (!c_ptr->m_idx) return (FALSE);
3019 /* Get a new monster record */
3020 m_ptr = &m_list[c_ptr->m_idx];
3023 m_ptr->r_idx = r_idx;
3024 m_ptr->ap_r_idx = initial_r_appearance(r_idx);
3030 /* Hack -- Appearance transfer */
3031 if ((mode & PM_MULTIPLY) && (who > 0) && !is_original_ap(&m_list[who]))
3033 m_ptr->ap_r_idx = m_list[who].ap_r_idx;
3035 /* Hack -- Shadower spawns Shadower */
3036 if (m_list[who].mflag2 & MFLAG2_KAGE) m_ptr->mflag2 |= MFLAG2_KAGE;
3039 /* Sub-alignment of a monster */
3040 if ((who > 0) && !(r_ptr->flags3 & (RF3_EVIL | RF3_GOOD)))
3041 m_ptr->sub_align = m_list[who].sub_align;
3044 m_ptr->sub_align = SUB_ALIGN_NEUTRAL;
3045 if (r_ptr->flags3 & RF3_EVIL) m_ptr->sub_align |= SUB_ALIGN_EVIL;
3046 if (r_ptr->flags3 & RF3_GOOD) m_ptr->sub_align |= SUB_ALIGN_GOOD;
3049 /* Place the monster at the location */
3054 /* No "timed status" yet */
3055 for (cmi = 0; cmi < MAX_MTIMED; cmi++) m_ptr->mtimed[cmi] = 0;
3057 /* Unknown distance */
3060 reset_target(m_ptr);
3062 m_ptr->nickname = 0;
3067 /* Your pet summons its pet. */
3068 if (who > 0 && is_pet(&m_list[who]))
3070 mode |= PM_FORCE_PET;
3071 m_ptr->parent_m_idx = who;
3075 m_ptr->parent_m_idx = 0;
3078 if (r_ptr->flags7 & RF7_CHAMELEON)
3080 choose_new_monster(c_ptr->m_idx, TRUE, 0);
3081 r_ptr = &r_info[m_ptr->r_idx];
3082 m_ptr->mflag2 |= MFLAG2_CHAMELEON;
3084 /* Hack - Set sub_align to neutral when the Chameleon Lord is generated as "GUARDIAN" */
3085 if ((r_ptr->flags1 & RF1_UNIQUE) && (who <= 0))
3086 m_ptr->sub_align = SUB_ALIGN_NEUTRAL;
3088 else if ((mode & PM_KAGE) && !(mode & PM_FORCE_PET))
3090 m_ptr->ap_r_idx = MON_KAGE;
3091 m_ptr->mflag2 |= MFLAG2_KAGE;
3094 if (mode & PM_NO_PET) m_ptr->mflag2 |= MFLAG2_NOPET;
3100 if (mode & PM_FORCE_PET)
3105 else if ((r_ptr->flags7 & RF7_FRIENDLY) ||
3106 (mode & PM_FORCE_FRIENDLY) || is_friendly_idx(who))
3108 if (!monster_has_hostile_align(NULL, 0, -1, r_ptr)) set_friendly(m_ptr);
3111 /* Assume no sleeping */
3112 m_ptr->mtimed[MTIMED_CSLEEP] = 0;
3114 /* Enforce sleeping if needed */
3115 if ((mode & PM_ALLOW_SLEEP) && r_ptr->sleep && !ironman_nightmare)
3117 int val = r_ptr->sleep;
3118 (void)set_monster_csleep(c_ptr->m_idx, (val * 2) + randint1(val * 10));
3121 /* Assign maximal hitpoints */
3122 if (r_ptr->flags1 & RF1_FORCE_MAXHP)
3124 m_ptr->max_maxhp = maxroll(r_ptr->hdice, r_ptr->hside);
3128 m_ptr->max_maxhp = damroll(r_ptr->hdice, r_ptr->hside);
3131 /* Monsters have double hitpoints in Nightmare mode */
3132 if (ironman_nightmare)
3134 u32b hp = m_ptr->max_maxhp * 2L;
3136 m_ptr->max_maxhp = (s16b)MIN(30000, hp);
3139 m_ptr->maxhp = m_ptr->max_maxhp;
3141 /* And start out fully healthy */
3142 if (m_ptr->r_idx == MON_WOUNDED_BEAR)
3143 m_ptr->hp = m_ptr->maxhp / 2;
3144 else m_ptr->hp = m_ptr->maxhp;
3147 /* dealt damage is 0 at initial*/
3148 m_ptr->dealt_damage = 0;
3151 /* Extract the monster base speed */
3152 m_ptr->mspeed = get_mspeed(r_ptr);
3154 if (mode & PM_HASTE) (void)set_monster_fast(c_ptr->m_idx, 100);
3156 /* Give a random starting energy */
3157 if (!ironman_nightmare)
3159 m_ptr->energy_need = ENERGY_NEED() - (s16b)randint0(100);
3163 /* Nightmare monsters are more prepared */
3164 m_ptr->energy_need = ENERGY_NEED() - (s16b)randint0(100) * 2;
3167 /* Force monster to wait for player, unless in Nightmare mode */
3168 if ((r_ptr->flags1 & RF1_FORCE_SLEEP) && !ironman_nightmare)
3170 /* Monster is still being nice */
3171 m_ptr->mflag |= (MFLAG_NICE);
3173 /* Must repair monsters */
3174 repair_monsters = TRUE;
3177 /* Hack -- see "process_monsters()" */
3178 if (c_ptr->m_idx < hack_m_idx)
3180 /* Monster is still being born */
3181 m_ptr->mflag |= (MFLAG_BORN);
3185 if (r_ptr->flags7 & RF7_SELF_LD_MASK)
3186 p_ptr->update |= (PU_MON_LITE);
3187 else if ((r_ptr->flags7 & RF7_HAS_LD_MASK) && !MON_CSLEEP(m_ptr))
3188 p_ptr->update |= (PU_MON_LITE);
3190 /* Update the monster */
3191 update_mon(c_ptr->m_idx, TRUE);
3194 /* Count the monsters on the level */
3195 real_r_ptr(m_ptr)->cur_num++;
3198 * Memorize location of the unique monster in saved floors.
3199 * A unique monster move from old saved floor.
3201 if (character_dungeon &&
3202 ((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags7 & RF7_NAZGUL)))
3203 real_r_ptr(m_ptr)->floor_id = p_ptr->floor_id;
3205 /* Hack -- Count the number of "reproducers" */
3206 if (r_ptr->flags2 & RF2_MULTIPLY) num_repro++;
3208 /* Hack -- Notice new multi-hued monsters */
3210 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
3211 if (ap_r_ptr->flags1 & (RF1_ATTR_MULTI | RF1_SHAPECHANGER))
3212 shimmer_monsters = TRUE;
3215 if (p_ptr->warning && character_dungeon)
3217 if (r_ptr->flags1 & RF1_UNIQUE)
3221 char o_name[MAX_NLEN];
3223 if (r_ptr->level > p_ptr->lev + 30)
3224 color = _("黒く", "black");
3225 else if (r_ptr->level > p_ptr->lev + 15)
3226 color = _("紫色に", "purple");
3227 else if (r_ptr->level > p_ptr->lev + 5)
3228 color = _("ルビー色に", "deep red");
3229 else if (r_ptr->level > p_ptr->lev - 5)
3230 color = _("赤く", "red");
3231 else if (r_ptr->level > p_ptr->lev - 15)
3232 color = _("ピンク色に", "pink");
3234 color = _("白く", "white");
3236 o_ptr = choose_warning_item();
3239 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
3240 msg_format(_("%sは%s光った。", "%s glows %s."), o_name, color);
3244 msg_format(_("%s光る物が頭に浮かんだ。", "An %s image forms in your mind."), color);
3249 if (is_explosive_rune_grid(c_ptr))
3251 /* Break the ward */
3252 if (randint1(BREAK_MINOR_GLYPH) > r_ptr->level)
3254 /* Describe observable breakage */
3255 if (c_ptr->info & CAVE_MARK)
3257 msg_print(_("ルーンが爆発した!", "The rune explodes!"));
3258 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);
3263 msg_print(_("爆発のルーンは解除された。", "An explosive rune was disarmed."));
3266 /* Forget the rune */
3267 c_ptr->info &= ~(CAVE_MARK);
3269 /* Break the rune */
3270 c_ptr->info &= ~(CAVE_OBJECT);
3283 * improved version of scatter() for place monster
3286 #define MON_SCAT_MAXD 10
3288 static bool mon_scatter(int r_idx, int *yp, int *xp, int y, int x, int max_dist)
3290 int place_x[MON_SCAT_MAXD];
3291 int place_y[MON_SCAT_MAXD];
3292 int num[MON_SCAT_MAXD];
3296 if (max_dist >= MON_SCAT_MAXD)
3299 for (i = 0; i < MON_SCAT_MAXD; i++)
3302 for (nx = x - max_dist; nx <= x + max_dist; nx++)
3304 for (ny = y - max_dist; ny <= y + max_dist; ny++)
3306 /* Ignore annoying locations */
3307 if (!in_bounds(ny, nx)) continue;
3309 /* Require "line of projection" */
3310 if (!projectable(y, x, ny, nx)) continue;
3314 monster_race *r_ptr = &r_info[r_idx];
3316 /* Require empty space (if not ghostly) */
3317 if (!monster_can_enter(ny, nx, r_ptr, 0))
3322 /* Walls and Monsters block flow */
3323 if (!cave_empty_bold2(ny, nx)) continue;
3325 /* ... nor on the Pattern */
3326 if (pattern_tile(ny, nx)) continue;
3329 i = distance(y, x, ny, nx);
3337 if (one_in_(num[i]))
3346 while (i < MON_SCAT_MAXD && 0 == num[i])
3348 if (i >= MON_SCAT_MAXD)
3359 * Maximum size of a group of monsters
3361 #define GROUP_MAX 32
3365 * Attempt to place a "group" of monsters around the given location
3367 static bool place_monster_group(int who, int y, int x, int r_idx, u32b mode)
3369 monster_race *r_ptr = &r_info[r_idx];
3372 int total = 0, extra = 0;
3376 byte hack_y[GROUP_MAX];
3377 byte hack_x[GROUP_MAX];
3380 /* Pick a group size */
3381 total = randint1(10);
3383 /* Hard monsters, small groups */
3384 if (r_ptr->level > dun_level)
3386 extra = r_ptr->level - dun_level;
3387 extra = 0 - randint1(extra);
3390 /* Easy monsters, large groups */
3391 else if (r_ptr->level < dun_level)
3393 extra = dun_level - r_ptr->level;
3394 extra = randint1(extra);
3397 /* Hack -- limit group reduction */
3398 if (extra > 9) extra = 9;
3400 /* Modify the group size */
3404 if (total < 1) total = 1;
3407 if (total > GROUP_MAX) total = GROUP_MAX;
3410 /* Start on the monster */
3415 /* Puddle monsters, breadth first, up to total */
3416 for (n = 0; (n < hack_n) && (hack_n < total); n++)
3418 /* Grab the location */
3422 /* Check each direction, up to total */
3423 for (i = 0; (i < 8) && (hack_n < total); i++)
3427 scatter(&my, &mx, hy, hx, 4, 0);
3429 /* Walls and Monsters block flow */
3430 if (!cave_empty_bold2(my, mx)) continue;
3432 /* Attempt to place another monster */
3433 if (place_monster_one(who, my, mx, r_idx, mode))
3435 /* Add it to the "hack" set */
3436 hack_y[hack_n] = my;
3437 hack_x[hack_n] = mx;
3450 * Hack -- help pick an escort type
3452 static int place_monster_idx = 0;
3453 static int place_monster_m_idx = 0;
3456 * Hack -- help pick an escort type
3458 static bool place_monster_okay(int r_idx)
3460 monster_race *r_ptr = &r_info[place_monster_idx];
3461 monster_type *m_ptr = &m_list[place_monster_m_idx];
3463 monster_race *z_ptr = &r_info[r_idx];
3465 /* Hack - Escorts have to have the same dungeon flag */
3466 if (mon_hook_dungeon(place_monster_idx) != mon_hook_dungeon(r_idx)) return (FALSE);
3468 /* Require similar "race" */
3469 if (z_ptr->d_char != r_ptr->d_char) return (FALSE);
3471 /* Skip more advanced monsters */
3472 if (z_ptr->level > r_ptr->level) return (FALSE);
3474 /* Skip unique monsters */
3475 if (z_ptr->flags1 & RF1_UNIQUE) return (FALSE);
3477 /* Paranoia -- Skip identical monsters */
3478 if (place_monster_idx == r_idx) return (FALSE);
3480 /* Skip different alignment */
3481 if (monster_has_hostile_align(m_ptr, 0, 0, z_ptr)) return FALSE;
3483 if (r_ptr->flags7 & RF7_FRIENDLY)
3485 if (monster_has_hostile_align(NULL, 1, -1, z_ptr)) return FALSE;
3488 if ((r_ptr->flags7 & RF7_CHAMELEON) && !(z_ptr->flags7 & RF7_CHAMELEON))
3497 * Attempt to place a monster of the given race at the given location
3499 * Note that certain monsters are now marked as requiring "friends".
3500 * These monsters, if successfully placed, and if the "grp" parameter
3501 * is TRUE, will be surrounded by a "group" of identical monsters.
3503 * Note that certain monsters are now marked as requiring an "escort",
3504 * which is a collection of monsters with similar "race" but lower level.
3506 * Some monsters induce a fake "group" flag on their escorts.
3508 * Note the "bizarre" use of non-recursion to prevent annoying output
3509 * when running a code profiler.
3511 * Note the use of the new "monster allocation table" code to restrict
3512 * the "get_mon_num()" function to "legal" escort types.
3514 bool place_monster_aux(int who, int y, int x, int r_idx, u32b mode)
3517 monster_race *r_ptr = &r_info[r_idx];
3519 if (!(mode & PM_NO_KAGE) && one_in_(333))
3522 /* Place one monster, or fail */
3523 if (!place_monster_one(who, y, x, r_idx, mode)) return (FALSE);
3525 /* Require the "group" flag */
3526 if (!(mode & PM_ALLOW_GROUP)) return (TRUE);
3528 place_monster_m_idx = hack_m_idx_ii;
3531 for(i = 0; i < 6; i++)
3533 if(!r_ptr->reinforce_id[i]) break;
3534 n = damroll(r_ptr->reinforce_dd[i], r_ptr->reinforce_ds[i]);
3535 for(j = 0; j < n; j++)
3538 scatter(&ny, &nx, y, x, d, 0);
3539 (void)place_monster_one(place_monster_m_idx, ny, nx, r_ptr->reinforce_id[i], mode);
3543 /* Friends for certain monsters */
3544 if (r_ptr->flags1 & (RF1_FRIENDS))
3546 /* Attempt to place a group */
3547 (void)place_monster_group(who, y, x, r_idx, mode);
3550 /* Escorts for certain monsters */
3551 if (r_ptr->flags1 & (RF1_ESCORT))
3553 /* Set the escort index */
3554 place_monster_idx = r_idx;
3556 /* Try to place several "escorts" */
3557 for (i = 0; i < 32; i++)
3559 int nx, ny, z, d = 3;
3561 /* Pick a location */
3562 scatter(&ny, &nx, y, x, d, 0);
3564 /* Require empty grids */
3565 if (!cave_empty_bold2(ny, nx)) continue;
3567 /* Prepare allocation table */
3568 get_mon_num_prep(place_monster_okay, get_monster_hook2(ny, nx));
3570 /* Pick a random race */
3571 z = get_mon_num(r_ptr->level);
3573 /* Handle failure */
3576 /* Place a single escort */
3577 (void)place_monster_one(place_monster_m_idx, ny, nx, z, mode);
3579 /* Place a "group" of escorts if needed */
3580 if ((r_info[z].flags1 & RF1_FRIENDS) ||
3581 (r_ptr->flags1 & RF1_ESCORTS))
3583 /* Place a group of monsters */
3584 (void)place_monster_group(place_monster_m_idx, ny, nx, z, mode);
3595 * Hack -- attempt to place a monster at the given location
3597 * Attempt to find a monster appropriate to the "monster_level"
3599 bool place_monster(int y, int x, u32b mode)
3603 /* Prepare allocation table */
3604 get_mon_num_prep(get_monster_hook(), get_monster_hook2(y, x));
3606 /* Pick a monster */
3607 r_idx = get_mon_num(monster_level);
3609 /* Handle failure */
3610 if (!r_idx) return (FALSE);
3612 /* Attempt to place the monster */
3613 if (place_monster_aux(0, y, x, r_idx, mode)) return (TRUE);
3620 #ifdef MONSTER_HORDES
3622 bool alloc_horde(int y, int x)
3624 monster_race *r_ptr = NULL;
3627 int attempts = 1000;
3631 /* Prepare allocation table */
3632 get_mon_num_prep(get_monster_hook(), get_monster_hook2(y, x));
3636 /* Pick a monster */
3637 r_idx = get_mon_num(monster_level);
3639 /* Handle failure */
3640 if (!r_idx) return (FALSE);
3642 r_ptr = &r_info[r_idx];
3644 if (r_ptr->flags1 & RF1_UNIQUE) continue;
3646 if (r_idx == MON_HAGURE) continue;
3649 if (attempts < 1) return FALSE;
3655 /* Attempt to place the monster */
3656 if (place_monster_aux(0, y, x, r_idx, 0L)) break;
3659 if (attempts < 1) return FALSE;
3661 m_idx = cave[y][x].m_idx;
3663 if (m_list[m_idx].mflag2 & MFLAG2_CHAMELEON) r_ptr = &r_info[m_list[m_idx].r_idx];
3664 summon_kin_type = r_ptr->d_char;
3666 for (attempts = randint1(10) + 5; attempts; attempts--)
3668 scatter(&cy, &cx, y, x, 5, 0);
3670 (void)summon_specific(m_idx, cy, cx, dun_level + 5, SUMMON_KIN, PM_ALLOW_GROUP);
3679 #endif /* MONSTER_HORDES */
3685 bool alloc_guardian(bool def_val)
3687 int guardian = d_info[dungeon_type].final_guardian;
3689 if (guardian && (d_info[dungeon_type].maxdepth == dun_level) && (r_info[guardian].cur_num < r_info[guardian].max_num))
3693 int try_count = 4000;
3695 /* Find a good position */
3698 /* Get a random spot */
3699 oy = randint1(cur_hgt - 4) + 2;
3700 ox = randint1(cur_wid - 4) + 2;
3702 /* Is it a good spot ? */
3703 if (cave_empty_bold2(oy, ox) && monster_can_cross_terrain(cave[oy][ox].feat, &r_info[guardian], 0))
3705 /* Place the guardian */
3706 if (place_monster_aux(0, oy, ox, guardian, (PM_ALLOW_GROUP | PM_NO_KAGE | PM_NO_PET))) return TRUE;
3709 /* One less try count */
3721 * Attempt to allocate a random monster in the dungeon.
3723 * Place the monster at least "dis" distance from the player.
3725 * Use "slp" to choose the initial "sleep" status
3727 * Use "monster_level" for the monster level
3729 bool alloc_monster(int dis, u32b mode)
3732 int attempts_left = 10000;
3734 /* Put the Guardian */
3735 if (alloc_guardian(FALSE)) return TRUE;
3737 /* Find a legal, distant, unoccupied, space */
3738 while (attempts_left--)
3740 /* Pick a location */
3741 y = randint0(cur_hgt);
3742 x = randint0(cur_wid);
3744 /* Require empty floor grid (was "naked") */
3747 if (!cave_empty_bold2(y, x)) continue;
3751 if (!cave_empty_bold(y, x)) continue;
3754 /* Accept far away grids */
3755 if (distance(y, x, py, px) > dis) break;
3760 if (cheat_xtra || cheat_hear)
3762 msg_print(_("警告!新たなモンスターを配置できません。小さい階ですか?", "Warning! Could not allocate a new monster. Small level?"));
3769 #ifdef MONSTER_HORDES
3770 if (randint1(5000) <= dun_level)
3772 if (alloc_horde(y, x))
3774 if (cheat_hear) msg_format(_("モンスターの大群(%c)", "Monster horde (%c)."), summon_kin_type);
3780 #endif /* MONSTER_HORDES */
3782 /* Attempt to place the monster, allow groups */
3783 if (place_monster(y, x, (mode | PM_ALLOW_GROUP))) return (TRUE);
3785 #ifdef MONSTER_HORDES
3787 #endif /* MONSTER_HORDES */
3797 * Hack -- help decide if a monster race is "okay" to summon
3799 static bool summon_specific_okay(int r_idx)
3801 monster_race *r_ptr = &r_info[r_idx];
3803 /* Hack - Only summon dungeon monsters */
3804 if (!mon_hook_dungeon(r_idx)) return (FALSE);
3806 /* Hack -- identify the summoning monster */
3807 if (summon_specific_who > 0)
3809 monster_type *m_ptr = &m_list[summon_specific_who];
3811 /* Do not summon enemies */
3813 /* Friendly vs. opposite aligned normal or pet */
3814 if (monster_has_hostile_align(m_ptr, 0, 0, r_ptr)) return FALSE;
3816 /* Use the player's alignment */
3817 else if (summon_specific_who < 0)
3819 /* Do not summon enemies of the pets */
3820 if (monster_has_hostile_align(NULL, 10, -10, r_ptr))
3822 if (!one_in_(ABS(p_ptr->align) / 2 + 1)) return FALSE;
3826 /* Hack -- no specific type specified */
3827 if (!summon_specific_type) return (TRUE);
3829 if (!summon_unique_okay && ((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags7 & RF7_NAZGUL))) return FALSE;
3831 if ((summon_specific_who < 0) &&
3832 ((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags7 & RF7_NAZGUL)) &&
3833 monster_has_hostile_align(NULL, 10, -10, r_ptr))
3836 if ((r_ptr->flags7 & RF7_CHAMELEON) && (d_info[dungeon_type].flags1 & DF1_CHAMELEON)) return TRUE;
3838 return (summon_specific_aux(r_idx));
3843 * Place a monster (of the specified "type") near the given
3844 * location. Return TRUE if a monster was actually summoned.
3846 * We will attempt to place the monster up to 10 times before giving up.
3848 * Note: SUMMON_UNIQUE and SUMMON_AMBERITES will summon Unique's
3849 * Note: SUMMON_HI_UNDEAD and SUMMON_HI_DRAGON may summon Unique's
3850 * Note: None of the other summon codes will ever summon Unique's.
3852 * This function has been changed. We now take the "monster level"
3853 * of the summoning monster as a parameter, and use that, along with
3854 * the current dungeon level, to help determine the level of the
3855 * desired monster. Note that this is an upper bound, and also
3856 * tends to "prefer" monsters of that level. Currently, we use
3857 * the average of the dungeon and monster levels, and then add
3858 * five to allow slight increases in monster power.
3860 * Note that we use the new "monster allocation table" creation code
3861 * to restrict the "get_mon_num()" function to the set of "legal"
3862 * monsters, making this function much faster and more reliable.
3864 * Note that this function may not succeed, though this is very rare.
3866 bool summon_specific(int who, int y1, int x1, int lev, int type, u32b mode)
3870 if (p_ptr->inside_arena) return (FALSE);
3872 if (!mon_scatter(0, &y, &x, y1, x1, 2)) return FALSE;
3874 /* Save the summoner */
3875 summon_specific_who = who;
3877 /* Save the "summon" type */
3878 summon_specific_type = type;
3880 summon_unique_okay = (mode & PM_ALLOW_UNIQUE) ? TRUE : FALSE;
3882 /* Prepare allocation table */
3883 get_mon_num_prep(summon_specific_okay, get_monster_hook2(y, x));
3885 /* Pick a monster, using the level calculation */
3886 r_idx = get_mon_num((dun_level + lev) / 2 + 5);
3888 /* Handle failure */
3891 summon_specific_type = 0;
3895 if ((type == SUMMON_BLUE_HORROR) || (type == SUMMON_DAWN)) mode |= PM_NO_KAGE;
3897 /* Attempt to place the monster (awake, allow groups) */
3898 if (!place_monster_aux(who, y, x, r_idx, mode))
3900 summon_specific_type = 0;
3904 summon_specific_type = 0;
3909 /* A "dangerous" function, creates a pet of the specified type */
3910 bool summon_named_creature (int who, int oy, int ox, int r_idx, u32b mode)
3915 /* if (!r_idx) return; */
3917 /* Prevent illegal monsters */
3918 if (r_idx >= max_r_idx) return FALSE;
3920 if (p_ptr->inside_arena) return FALSE;
3922 if (!mon_scatter(r_idx, &y, &x, oy, ox, 2)) return FALSE;
3924 /* Place it (allow groups) */
3925 return place_monster_aux(who, y, x, r_idx, (mode | PM_NO_KAGE));
3930 * Let the given monster attempt to reproduce.
3932 * Note that "reproduction" REQUIRES empty space.
3934 bool multiply_monster(int m_idx, bool clone, u32b mode)
3936 monster_type *m_ptr = &m_list[m_idx];
3940 if (!mon_scatter(m_ptr->r_idx, &y, &x, m_ptr->fy, m_ptr->fx, 1))
3943 if (m_ptr->mflag2 & MFLAG2_NOPET) mode |= PM_NO_PET;
3945 /* Create a new monster (awake, no groups) */
3946 if (!place_monster_aux(m_idx, y, x, m_ptr->r_idx, (mode | PM_NO_KAGE | PM_MULTIPLY)))
3949 /* Hack -- Transfer "clone" flag */
3950 if (clone || (m_ptr->smart & SM_CLONED))
3952 m_list[hack_m_idx_ii].smart |= SM_CLONED;
3953 m_list[hack_m_idx_ii].mflag2 |= MFLAG2_NOPET;
3964 * Dump a message describing a monster's reaction to damage
3966 * Technically should attempt to treat "Beholder"'s as jelly's
3968 void message_pain(int m_idx, int dam)
3970 long oldhp, newhp, tmp;
3973 monster_type *m_ptr = &m_list[m_idx];
3974 monster_race *r_ptr = &r_info[m_ptr->r_idx];
3978 /* Get the monster name */
3979 monster_desc(m_name, m_ptr, 0);
3981 if(dam == 0) // Notice non-damage
3983 msg_format(_("%^sはダメージを受けていない。", "%^s is unharmed."), m_name);
3987 /* Note -- subtle fix -CFT */
3988 newhp = (long)(m_ptr->hp);
3989 oldhp = newhp + (long)(dam);
3990 tmp = (newhp * 100L) / oldhp;
3991 percentage = (int)(tmp);
3993 if(my_strchr(",ejmvwQ", r_ptr->d_char)) // Mushrooms, Eyes, Jellies, Molds, Vortices, Worms, Quylthulgs
3996 if(percentage > 95) msg_format("%^sはほとんど気にとめていない。", m_name);
3997 else if(percentage > 75) msg_format("%^sはしり込みした。", m_name);
3998 else if(percentage > 50) msg_format("%^sは縮こまった。", m_name);
3999 else if(percentage > 35) msg_format("%^sは痛みに震えた。", m_name);
4000 else if(percentage > 20) msg_format("%^sは身もだえした。", m_name);
4001 else if(percentage > 10) msg_format("%^sは苦痛で身もだえした。", m_name);
4002 else msg_format("%^sはぐにゃぐにゃと痙攣した。", m_name);
4004 if(percentage > 95) msg_format("%^s barely notices.", m_name);
4005 else if(percentage > 75) msg_format("%^s flinches.", m_name);
4006 else if(percentage > 50) msg_format("%^s squelches.", m_name);
4007 else if(percentage > 35) msg_format("%^s quivers in pain.", m_name);
4008 else if(percentage > 20) msg_format("%^s writhes about.", m_name);
4009 else if(percentage > 10) msg_format("%^s writhes in agony.", m_name);
4010 else msg_format("%^s jerks limply.", m_name);
4014 else if(my_strchr("l", r_ptr->d_char)) // Fish
4017 if(percentage > 95) msg_format("%^sはほとんど気にとめていない。", m_name);
4018 else if(percentage > 75) msg_format("%^sはしり込みした。", m_name);
4019 else if(percentage > 50) msg_format("%^sは躊躇した。", m_name);
4020 else if(percentage > 35) msg_format("%^sは痛みに震えた。", m_name);
4021 else if(percentage > 20) msg_format("%^sは身もだえした。", m_name);
4022 else if(percentage > 10) msg_format("%^sは苦痛で身もだえした。", m_name);
4023 else msg_format("%^sはぐにゃぐにゃと痙攣した。", m_name);
4025 if(percentage > 95) msg_format("%^s barely notices.", m_name);
4026 else if(percentage > 75) msg_format("%^s flinches.", m_name);
4027 else if(percentage > 50) msg_format("%^s hesitates.", m_name);
4028 else if(percentage > 35) msg_format("%^s quivers in pain.", m_name);
4029 else if(percentage > 20) msg_format("%^s writhes about.", m_name);
4030 else if(percentage > 10) msg_format("%^s writhes in agony.", m_name);
4031 else msg_format("%^s jerks limply.", m_name);
4035 else if(my_strchr("g#+<>", r_ptr->d_char)) // Golems, Walls, Doors, Stairs
4038 if(percentage > 95) msg_format("%sは攻撃を気にとめていない。", m_name);
4039 else if(percentage > 75) msg_format("%sは攻撃に肩をすくめた。", m_name);
4040 else if(percentage > 50) msg_format("%^sは雷鳴のように吠えた。", m_name);
4041 else if(percentage > 35) msg_format("%^sは苦しげに吠えた。", m_name);
4042 else if(percentage > 20) msg_format("%^sはうめいた。", m_name);
4043 else if(percentage > 10) msg_format("%^sは躊躇した。", m_name);
4044 else msg_format("%^sはくしゃくしゃになった。", m_name);
4046 if(percentage > 95) msg_format("%^s ignores the attack.", m_name);
4047 else if(percentage > 75) msg_format("%^s shrugs off the attack.", m_name);
4048 else if(percentage > 50) msg_format("%^s roars thunderously.", m_name);
4049 else if(percentage > 35) msg_format("%^s rumbles.", m_name);
4050 else if(percentage > 20) msg_format("%^s grunts.", m_name);
4051 else if(percentage > 10) msg_format("%^s hesitates.", m_name);
4052 else msg_format("%^s crumples.", m_name);
4056 else if(my_strchr("JMR", r_ptr->d_char) || !isalpha(r_ptr->d_char)) // Snakes, Hydrae, Reptiles, Mimics
4059 if(percentage > 95) msg_format("%^sはほとんど気にとめていない。", m_name);
4060 else if(percentage > 75) msg_format("%^sはシーッと鳴いた。", m_name);
4061 else if(percentage > 50) msg_format("%^sは怒って頭を上げた。", m_name);
4062 else if(percentage > 35) msg_format("%^sは猛然と威嚇した。", m_name);
4063 else if(percentage > 20) msg_format("%^sは身もだえした。", m_name);
4064 else if(percentage > 10) msg_format("%^sは苦痛で身もだえした。", m_name);
4065 else msg_format("%^sはぐにゃぐにゃと痙攣した。", m_name);
4067 if(percentage > 95) msg_format("%^s barely notices.", m_name);
4068 else if(percentage > 75) msg_format("%^s hisses.", m_name);
4069 else if(percentage > 50) msg_format("%^s rears up in anger.", m_name);
4070 else if(percentage > 35) msg_format("%^s hisses furiously.", m_name);
4071 else if(percentage > 20) msg_format("%^s writhes about.", m_name);
4072 else if(percentage > 10) msg_format("%^s writhes in agony.", m_name);
4073 else msg_format("%^s jerks limply.", m_name);
4077 else if(my_strchr("f", r_ptr->d_char))
4080 if(percentage > 95) msg_format("%sは攻撃に肩をすくめた。", m_name);
4081 else if(percentage > 75) msg_format("%^sは吠えた。", m_name);
4082 else if(percentage > 50) msg_format("%^sは怒って吠えた。", m_name);
4083 else if(percentage > 35) msg_format("%^sは痛みでシーッと鳴いた。", m_name);
4084 else if(percentage > 20) msg_format("%^sは痛みで弱々しく鳴いた。", m_name);
4085 else if(percentage > 10) msg_format("%^sは苦痛にうめいた。", m_name);
4086 else msg_format("%sは哀れな鳴き声を出した。", m_name);
4088 if(percentage > 95) msg_format("%^s shrugs off the attack.", m_name);
4089 else if(percentage > 75) msg_format("%^s roars.", m_name);
4090 else if(percentage > 50) msg_format("%^s growls angrily.", m_name);
4091 else if(percentage > 35) msg_format("%^s hisses with pain.", m_name);
4092 else if(percentage > 20) msg_format("%^s mewls in pain.", m_name);
4093 else if(percentage > 10) msg_format("%^s hisses in agony.", m_name);
4094 else msg_format("%^s mewls pitifully.", m_name);
4098 else if(my_strchr("acFIKS", r_ptr->d_char)) // Ants, Centipedes, Flies, Insects, Beetles, Spiders
4101 if(percentage > 95) msg_format("%sは攻撃を気にとめていない。", m_name);
4102 else if(percentage > 75) msg_format("%^sはキーキー鳴いた。", m_name);
4103 else if(percentage > 50) msg_format("%^sはヨロヨロ逃げ回った。", m_name);
4104 else if(percentage > 35) msg_format("%^sはうるさく鳴いた。", m_name);
4105 else if(percentage > 20) msg_format("%^sは痛みに痙攣した。", m_name);
4106 else if(percentage > 10) msg_format("%^sは苦痛で痙攣した。", m_name);
4107 else msg_format("%^sはピクピクひきつった。", m_name);
4109 if(percentage > 95) msg_format("%^s ignores the attack.", m_name);
4110 else if(percentage > 75) msg_format("%^s chitters.", m_name);
4111 else if(percentage > 50) msg_format("%^s scuttles about.", m_name);
4112 else if(percentage > 35) msg_format("%^s twitters.", m_name);
4113 else if(percentage > 20) msg_format("%^s jerks in pain.", m_name);
4114 else if(percentage > 10) msg_format("%^s jerks in agony.", m_name);
4115 else msg_format("%^s twitches.", m_name);
4119 else if(my_strchr("B", r_ptr->d_char)) // Birds
4122 if(percentage > 95) msg_format("%^sはさえずった。", m_name);
4123 else if(percentage > 75) msg_format("%^sはピーピー鳴いた。", m_name);
4124 else if(percentage > 50) msg_format("%^sはギャーギャー鳴いた。", m_name);
4125 else if(percentage > 35) msg_format("%^sはギャーギャー鳴きわめいた。", m_name);
4126 else if(percentage > 20) msg_format("%^sは苦しんだ。", m_name);
4127 else if(percentage > 10) msg_format("%^sはのたうち回った。", m_name);
4128 else msg_format("%^sはキーキーと鳴き叫んだ。", m_name);
4130 if(percentage > 95) msg_format("%^s chirps.", m_name);
4131 else if(percentage > 75) msg_format("%^s twitters.", m_name);
4132 else if(percentage > 50) msg_format("%^s squawks.", m_name);
4133 else if(percentage > 35) msg_format("%^s chatters.", m_name);
4134 else if(percentage > 20) msg_format("%^s jeers.", m_name);
4135 else if(percentage > 10) msg_format("%^s flutters about.", m_name);
4136 else msg_format("%^s squeaks.", m_name);
4140 else if(my_strchr("duDLUW", r_ptr->d_char)) // Dragons, Demons, High Undead
4143 if(percentage > 95) msg_format("%sは攻撃を気にとめていない。", m_name);
4144 else if(percentage > 75) msg_format("%^sはしり込みした。", m_name);
4145 else if(percentage > 50) msg_format("%^sは痛みでシーッと鳴いた。", m_name);
4146 else if(percentage > 35) msg_format("%^sは痛みでうなった。", m_name);
4147 else if(percentage > 20) msg_format("%^sは痛みに吠えた。", m_name);
4148 else if(percentage > 10) msg_format("%^sは苦しげに叫んだ。", m_name);
4149 else msg_format("%^sは弱々しくうなった。", m_name);
4151 if(percentage > 95) msg_format("%^s ignores the attack.", m_name);
4152 else if(percentage > 75) msg_format("%^s flinches.", m_name);
4153 else if(percentage > 50) msg_format("%^s hisses in pain.", m_name);
4154 else if(percentage > 35) msg_format("%^s snarls with pain.", m_name);
4155 else if(percentage > 20) msg_format("%^s roars with pain.", m_name);
4156 else if(percentage > 10) msg_format("%^s gasps.", m_name);
4157 else msg_format("%^s snarls feebly.", m_name);
4161 else if(my_strchr("s", r_ptr->d_char)) // Skeletons
4164 if(percentage > 95) msg_format("%sは攻撃を気にとめていない。", m_name);
4165 else if(percentage > 75) msg_format("%sは攻撃に肩をすくめた。", m_name);
4166 else if(percentage > 50) msg_format("%^sはカタカタと笑った。", m_name);
4167 else if(percentage > 35) msg_format("%^sはよろめいた。", m_name);
4168 else if(percentage > 20) msg_format("%^sはカタカタ言った。", m_name);
4169 else if(percentage > 10) msg_format("%^sはよろめいた。", m_name);
4170 else msg_format("%^sはガタガタ言った。", m_name);
4172 if(percentage > 95) msg_format("%^s ignores the attack.", m_name);
4173 else if(percentage > 75) msg_format("%^s shrugs off the attack.", m_name);
4174 else if(percentage > 50) msg_format("%^s rattles.", m_name);
4175 else if(percentage > 35) msg_format("%^s stumbles.", m_name);
4176 else if(percentage > 20) msg_format("%^s rattles.", m_name);
4177 else if(percentage > 10) msg_format("%^s staggers.", m_name);
4178 else msg_format("%^s clatters.", m_name);
4182 else if(my_strchr("z", r_ptr->d_char)) // Zombies
4185 if(percentage > 95) msg_format("%sは攻撃を気にとめていない。", m_name);
4186 else if(percentage > 75) msg_format("%sは攻撃に肩をすくめた。", m_name);
4187 else if(percentage > 50) msg_format("%^sはうめいた。", m_name);
4188 else if(percentage > 35) msg_format("%sは苦しげにうめいた。", m_name);
4189 else if(percentage > 20) msg_format("%^sは躊躇した。", m_name);
4190 else if(percentage > 10) msg_format("%^sはうなった。", m_name);
4191 else msg_format("%^sはよろめいた。", m_name);
4193 if(percentage > 95) msg_format("%^s ignores the attack.", m_name);
4194 else if(percentage > 75) msg_format("%^s shrugs off the attack.", m_name);
4195 else if(percentage > 50) msg_format("%^s groans.", m_name);
4196 else if(percentage > 35) msg_format("%^s moans.", m_name);
4197 else if(percentage > 20) msg_format("%^s hesitates.", m_name);
4198 else if(percentage > 10) msg_format("%^s grunts.", m_name);
4199 else msg_format("%^s staggers.", m_name);
4203 else if(my_strchr("G", r_ptr->d_char)) // Ghosts
4206 if(percentage > 95) msg_format("%sは攻撃を気にとめていない。", m_name);
4207 else if(percentage > 75) msg_format("%sは攻撃に肩をすくめた。", m_name);
4208 else if(percentage > 50) msg_format("%sはうめいた。", m_name);
4209 else if(percentage > 35) msg_format("%^sは泣きわめいた。", m_name);
4210 else if(percentage > 20) msg_format("%^sは吠えた。", m_name);
4211 else if(percentage > 10) msg_format("%sは弱々しくうめいた。", m_name);
4212 else msg_format("%^sはかすかにうめいた。", m_name);
4214 if(percentage > 95) msg_format("%^s ignores the attack.", m_name);
4215 else if(percentage > 75) msg_format("%^s shrugs off the attack.", m_name);
4216 else if(percentage > 50) msg_format("%^s moans.", m_name);
4217 else if(percentage > 35) msg_format("%^s wails.", m_name);
4218 else if(percentage > 20) msg_format("%^s howls.", m_name);
4219 else if(percentage > 10) msg_format("%^s moans softly.", m_name);
4220 else msg_format("%^s sighs.", m_name);
4224 else if(my_strchr("CZ", r_ptr->d_char)) // Dogs and Hounds
4227 if(percentage > 95) msg_format("%^sは攻撃に肩をすくめた。", m_name);
4228 else if(percentage > 75) msg_format("%^sは痛みでうなった。", m_name);
4229 else if(percentage > 50) msg_format("%^sは痛みでキャンキャン吠えた。", m_name);
4230 else if(percentage > 35) msg_format("%^sは痛みで鳴きわめいた。", m_name);
4231 else if(percentage > 20) msg_format("%^sは苦痛のあまり鳴きわめいた。", m_name);
4232 else if(percentage > 10) msg_format("%^sは苦痛でもだえ苦しんだ。", m_name);
4233 else msg_format("%^sは弱々しく吠えた。", m_name);
4235 if(percentage > 95) msg_format("%^s shrugs off the attack.", m_name);
4236 else if(percentage > 75) msg_format("%^s snarls with pain.", m_name);
4237 else if(percentage > 50) msg_format("%^s yelps in pain.", m_name);
4238 else if(percentage > 35) msg_format("%^s howls in pain.", m_name);
4239 else if(percentage > 20) msg_format("%^s howls in agony.", m_name);
4240 else if(percentage > 10) msg_format("%^s writhes in agony.", m_name);
4241 else msg_format("%^s yelps feebly.", m_name);
4245 else if(my_strchr("Xbilqrt", r_ptr->d_char)) // One type of creatures (ignore,squeal,shriek)
4248 if(percentage > 95) msg_format("%^sは攻撃を気にとめていない。", m_name);
4249 else if(percentage > 75) msg_format("%^sは痛みでうなった。", m_name);
4250 else if(percentage > 50) msg_format("%^sは痛みで叫んだ。", m_name);
4251 else if(percentage > 35) msg_format("%^sは痛みで絶叫した。", m_name);
4252 else if(percentage > 20) msg_format("%^sは苦痛のあまり絶叫した。", m_name);
4253 else if(percentage > 10) msg_format("%^sは苦痛でもだえ苦しんだ。", m_name);
4254 else msg_format("%^sは弱々しく叫んだ。", m_name);
4256 if(percentage > 95) msg_format("%^s ignores the attack.", m_name);
4257 else if(percentage > 75) msg_format("%^s grunts with pain.", m_name);
4258 else if(percentage > 50) msg_format("%^s squeals in pain.", m_name);
4259 else if(percentage > 35) msg_format("%^s shrieks in pain.", m_name);
4260 else if(percentage > 20) msg_format("%^s shrieks in agony.", m_name);
4261 else if(percentage > 10) msg_format("%^s writhes in agony.", m_name);
4262 else msg_format("%^s cries out feebly.", m_name);
4266 else // Another type of creatures (shrug,cry,scream)
4269 if(percentage > 95) msg_format("%^sは攻撃に肩をすくめた。", m_name);
4270 else if(percentage > 75) msg_format("%^sは痛みでうなった。", m_name);
4271 else if(percentage > 50) msg_format("%^sは痛みで叫んだ。", m_name);
4272 else if(percentage > 35) msg_format("%^sは痛みで絶叫した。", m_name);
4273 else if(percentage > 20) msg_format("%^sは苦痛のあまり絶叫した。", m_name);
4274 else if(percentage > 10) msg_format("%^sは苦痛でもだえ苦しんだ。", m_name);
4275 else msg_format("%^sは弱々しく叫んだ。", m_name);
4277 if(percentage > 95) msg_format("%^s shrugs off the attack.", m_name);
4278 else if(percentage > 75) msg_format("%^s grunts with pain.", m_name);
4279 else if(percentage > 50) msg_format("%^s cries out in pain.", m_name);
4280 else if(percentage > 35) msg_format("%^s screams in pain.", m_name);
4281 else if(percentage > 20) msg_format("%^s screams in agony.", m_name);
4282 else if(percentage > 10) msg_format("%^s writhes in agony.", m_name);
4283 else msg_format("%^s cries out feebly.", m_name);
4292 * Learn about an "observed" resistance.
4294 void update_smart_learn(int m_idx, int what)
4296 monster_type *m_ptr = &m_list[m_idx];
4298 monster_race *r_ptr = &r_info[m_ptr->r_idx];
4301 /* Not allowed to learn */
4302 if (!smart_learn) return;
4304 /* Too stupid to learn anything */
4305 if (r_ptr->flags2 & (RF2_STUPID)) return;
4307 /* Not intelligent, only learn sometimes */
4308 if (!(r_ptr->flags2 & (RF2_SMART)) && (randint0(100) < 50)) return;
4313 /* Analyze the knowledge */
4317 if (p_ptr->resist_acid) m_ptr->smart |= (SM_RES_ACID);
4318 if (IS_OPPOSE_ACID()) m_ptr->smart |= (SM_OPP_ACID);
4319 if (p_ptr->immune_acid) m_ptr->smart |= (SM_IMM_ACID);
4323 if (p_ptr->resist_elec) m_ptr->smart |= (SM_RES_ELEC);
4324 if (IS_OPPOSE_ELEC()) m_ptr->smart |= (SM_OPP_ELEC);
4325 if (p_ptr->immune_elec) m_ptr->smart |= (SM_IMM_ELEC);
4329 if (p_ptr->resist_fire) m_ptr->smart |= (SM_RES_FIRE);
4330 if (IS_OPPOSE_FIRE()) m_ptr->smart |= (SM_OPP_FIRE);
4331 if (p_ptr->immune_fire) m_ptr->smart |= (SM_IMM_FIRE);
4335 if (p_ptr->resist_cold) m_ptr->smart |= (SM_RES_COLD);
4336 if (IS_OPPOSE_COLD()) m_ptr->smart |= (SM_OPP_COLD);
4337 if (p_ptr->immune_cold) m_ptr->smart |= (SM_IMM_COLD);
4341 if (p_ptr->resist_pois) m_ptr->smart |= (SM_RES_POIS);
4342 if (IS_OPPOSE_POIS()) m_ptr->smart |= (SM_OPP_POIS);
4347 if (p_ptr->resist_neth) m_ptr->smart |= (SM_RES_NETH);
4351 if (p_ptr->resist_lite) m_ptr->smart |= (SM_RES_LITE);
4355 if (p_ptr->resist_dark) m_ptr->smart |= (SM_RES_DARK);
4359 if (p_ptr->resist_fear) m_ptr->smart |= (SM_RES_FEAR);
4363 if (p_ptr->resist_conf) m_ptr->smart |= (SM_RES_CONF);
4367 if (p_ptr->resist_chaos) m_ptr->smart |= (SM_RES_CHAOS);
4371 if (p_ptr->resist_disen) m_ptr->smart |= (SM_RES_DISEN);
4375 if (p_ptr->resist_blind) m_ptr->smart |= (SM_RES_BLIND);
4379 if (p_ptr->resist_nexus) m_ptr->smart |= (SM_RES_NEXUS);
4383 if (p_ptr->resist_sound) m_ptr->smart |= (SM_RES_SOUND);
4387 if (p_ptr->resist_shard) m_ptr->smart |= (SM_RES_SHARD);
4391 if (p_ptr->free_act) m_ptr->smart |= (SM_IMM_FREE);
4395 if (!p_ptr->msp) m_ptr->smart |= (SM_IMM_MANA);
4399 if (p_ptr->reflect) m_ptr-> smart |= (SM_IMM_REFLECT);
4406 * Place the player in the dungeon XXX XXX
4408 bool player_place(int y, int x)
4410 /* Paranoia XXX XXX */
4411 if (cave[y][x].m_idx != 0) return FALSE;
4413 /* Save player location */
4423 * Drop all items carried by a monster
4425 void monster_drop_carried_objects(monster_type *m_ptr)
4427 s16b this_o_idx, next_o_idx = 0;
4433 /* Drop objects being carried */
4434 for (this_o_idx = m_ptr->hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
4436 /* Acquire object */
4437 o_ptr = &o_list[this_o_idx];
4439 /* Acquire next object */
4440 next_o_idx = o_ptr->next_o_idx;
4442 /* Get local object */
4445 /* Copy the object */
4446 object_copy(q_ptr, o_ptr);
4448 /* Forget monster */
4449 q_ptr->held_m_idx = 0;
4451 /* Delete the object */
4452 delete_object_idx(this_o_idx);
4455 (void)drop_near(q_ptr, -1, m_ptr->fy, m_ptr->fx);
4458 /* Forget objects */
4459 m_ptr->hold_o_idx = 0;