4 * Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke
6 * This software may be copied and distributed for educational, research,
7 * and not for profit purposes provided that this copyright and statement
8 * are included in all such copies. Other copyrights may also apply.
11 /* Purpose: misc code for monsters */
15 #define HORDE_NOGOOD 0x01
16 #define HORDE_NOEVIL 0x02
20 cptr horror_desc[MAX_SAN_HORROR] =
74 cptr funny_desc[MAX_SAN_FUNNY] =
89 "¥Õ¥¡¥ó¥¿¥¹¥Æ¥£¥Ã¥¯¤Ê",
134 cptr funny_comments[MAX_SAN_COMMENT] =
155 * Set the target of counter attack
157 void set_target(monster_type *m_ptr, int y, int x)
165 * Reset the target of counter attack
167 void reset_target(monster_type *m_ptr)
169 set_target(m_ptr, 0, 0);
174 * Extract monster race pointer of a monster's true form
176 monster_race *real_r_ptr(monster_type *m_ptr)
178 monster_race *r_ptr = &r_info[m_ptr->r_idx];
180 /* Extract real race */
181 if (m_ptr->mflag2 & MFLAG2_CHAMELEON)
183 if (r_ptr->flags1 & RF1_UNIQUE)
184 return &r_info[MON_CHAMELEON_K];
186 return &r_info[MON_CHAMELEON];
196 * Delete a monster by index.
198 * When a monster is deleted, all of its objects are deleted.
200 void delete_monster_idx(int i)
204 monster_type *m_ptr = &m_list[i];
206 monster_race *r_ptr = &r_info[m_ptr->r_idx];
208 s16b this_o_idx, next_o_idx = 0;
216 /* Hack -- Reduce the racial counter */
217 real_r_ptr(m_ptr)->cur_num--;
219 /* Hack -- count the number of "reproducers" */
220 if (r_ptr->flags2 & (RF2_MULTIPLY)) num_repro--;
223 /* Hack -- remove target monster */
224 if (i == target_who) target_who = 0;
226 /* Hack -- remove tracked monster */
227 if (i == p_ptr->health_who) health_track(0);
229 if (pet_t_m_idx == i ) pet_t_m_idx = 0;
230 if (riding_t_m_idx == i) riding_t_m_idx = 0;
231 if (p_ptr->riding == i) p_ptr->riding = 0;
233 /* Monster is gone */
234 cave[y][x].m_idx = 0;
238 for (this_o_idx = m_ptr->hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
243 o_ptr = &o_list[this_o_idx];
245 /* Acquire next object */
246 next_o_idx = o_ptr->next_o_idx;
249 * o_ptr->held_m_idx is needed in delete_object_idx()
250 * to prevent calling lite_spot()
253 /* Delete the object */
254 delete_object_idx(this_o_idx);
258 /* Wipe the Monster */
259 (void)WIPE(m_ptr, monster_type);
267 /* Update some things */
268 p_ptr->update |= (PU_MON_LITE);
273 * Delete the monster, if any, at a given location
275 void delete_monster(int y, int x)
280 if (!in_bounds(y, x)) return;
285 /* Delete the monster (if any) */
286 if (c_ptr->m_idx) delete_monster_idx(c_ptr->m_idx);
291 * Move an object from index i1 to index i2 in the object list
293 static void compact_monsters_aux(int i1, int i2)
301 s16b this_o_idx, next_o_idx = 0;
305 if (i1 == i2) return;
318 /* Update the cave */
321 /* Repair objects being carried by monster */
322 for (this_o_idx = m_ptr->hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
327 o_ptr = &o_list[this_o_idx];
329 /* Acquire next object */
330 next_o_idx = o_ptr->next_o_idx;
332 /* Reset monster pointer */
333 o_ptr->held_m_idx = i2;
336 /* Hack -- Update the target */
337 if (target_who == i1) target_who = i2;
339 /* Hack -- Update the target */
340 if (pet_t_m_idx == i1) pet_t_m_idx = i2;
341 if (riding_t_m_idx == i1) riding_t_m_idx = i2;
343 /* Hack -- Update the riding */
344 if (p_ptr->riding == i1) p_ptr->riding = i2;
346 /* Hack -- Update the health bar */
347 if (p_ptr->health_who == i1) health_track(i2);
350 COPY(&m_list[i2], &m_list[i1], monster_type);
353 (void)WIPE(&m_list[i1], monster_type);
359 * Compact and Reorder the monster list
361 * This function can be very dangerous, use with caution!
363 * When actually "compacting" monsters, we base the saving throw
364 * on a combination of monster level, distance from player, and
365 * current "desperation".
367 * After "compacting" (if needed), we "reorder" the monsters into a more
368 * compact order, and we reset the allocation info, and the "live" array.
370 void compact_monsters(int size)
373 int cur_lev, cur_dis, chance;
375 /* Message (only if compacting) */
377 if (size) msg_print("¥â¥ó¥¹¥¿¡¼¾ðÊó¤ò°µ½Ì¤·¤Æ¤¤¤Þ¤¹...");
379 if (size) msg_print("Compacting monsters...");
383 /* Compact at least 'size' objects */
384 for (num = 0, cnt = 1; num < size; cnt++)
386 /* Get more vicious each iteration */
389 /* Get closer each iteration */
390 cur_dis = 5 * (20 - cnt);
392 /* Check all the monsters */
393 for (i = 1; i < m_max; i++)
395 monster_type *m_ptr = &m_list[i];
397 monster_race *r_ptr = &r_info[m_ptr->r_idx];
399 /* Paranoia -- skip "dead" monsters */
400 if (!m_ptr->r_idx) continue;
402 /* Hack -- High level monsters start out "immune" */
403 if (r_ptr->level > cur_lev) continue;
405 if (i == p_ptr->riding) continue;
407 /* Ignore nearby monsters */
408 if ((cur_dis > 0) && (m_ptr->cdis < cur_dis)) continue;
410 /* Saving throw chance */
413 /* Only compact "Quest" Monsters in emergencies */
414 if ((r_ptr->flags1 & (RF1_QUESTOR)) && (cnt < 1000)) chance = 100;
416 /* Try not to compact Unique Monsters */
417 if (r_ptr->flags1 & (RF1_UNIQUE)) chance = 100;
419 /* All monsters get a saving throw */
420 if (randint0(100) < chance) continue;
422 /* Delete the monster */
423 delete_monster_idx(i);
425 /* Count the monster */
431 /* Excise dead monsters (backwards!) */
432 for (i = m_max - 1; i >= 1; i--)
434 /* Get the i'th monster */
435 monster_type *m_ptr = &m_list[i];
437 /* Skip real monsters */
438 if (m_ptr->r_idx) continue;
440 /* Move last monster into open hole */
441 compact_monsters_aux(m_max - 1, i);
443 /* Compress "m_max" */
450 * Delete/Remove all the monsters when the player leaves the level
452 * This is an efficient method of simulating multiple calls to the
453 * "delete_monster()" function, with no visual effects.
455 void wipe_m_list(void)
459 /* Hack -- if Banor or Lupart dies, stay another dead */
460 if (!r_info[MON_BANORLUPART].max_num)
462 if (r_info[MON_BANOR].max_num)
464 r_info[MON_BANOR].max_num = 0;
465 r_info[MON_BANOR].r_pkills++;
466 if (r_info[MON_BANOR].r_tkills < MAX_SHORT) r_info[MON_BANOR].r_tkills++;
468 if (r_info[MON_LUPART].max_num)
470 r_info[MON_LUPART].max_num = 0;
471 r_info[MON_LUPART].r_pkills++;
472 if (r_info[MON_LUPART].r_tkills < MAX_SHORT) r_info[MON_LUPART].r_tkills++;
476 /* Delete all the monsters */
477 for (i = m_max - 1; i >= 1; i--)
479 monster_type *m_ptr = &m_list[i];
481 /* Skip dead monsters */
482 if (!m_ptr->r_idx) continue;
484 /* Monster is gone */
485 cave[m_ptr->fy][m_ptr->fx].m_idx = 0;
487 /* Wipe the Monster */
488 (void)WIPE(m_ptr, monster_type);
493 * Wiping racial counters of all monsters and incrementing of racial
494 * counters of monsters in party_mon[] is required to prevent multiple
495 * generation of unique monster who is the minion of player.
498 /* Hack -- Wipe the racial counter of all monster races */
499 for (i = 1; i < max_r_idx; i++) r_info[i].cur_num = 0;
507 /* Hack -- reset "reproducer" count */
510 /* Hack -- no more target */
515 /* Hack -- no more tracking */
521 * Acquires and returns the index of a "free" monster.
523 * This routine should almost never fail, but it *can* happen.
530 /* Normal allocation */
531 if (m_max < max_m_idx)
533 /* Access the next hole */
536 /* Expand the array */
542 /* Return the index */
547 /* Recycle dead monsters */
548 for (i = 1; i < m_max; i++)
552 /* Acquire monster */
555 /* Skip live monsters */
556 if (m_ptr->r_idx) continue;
561 /* Use this monster */
566 /* Warn the player (except during dungeon creation) */
568 if (character_dungeon) msg_print("¥â¥ó¥¹¥¿¡¼¤¬Â¿¤¹¤®¤ë¡ª");
570 if (character_dungeon) msg_print("Too many monsters!");
574 /* Try not to crash */
582 * Hack -- the "type" of the current "summon specific"
584 static int summon_specific_type = 0;
588 * Hack -- the index of the summoning monster
590 static int summon_specific_who = -1;
594 * Hack -- the hostility of the summoned monster
596 static bool summon_specific_hostile = TRUE;
598 static bool summon_unique_okay = FALSE;
601 static bool summon_specific_aux(int r_idx)
603 monster_race *r_ptr = &r_info[r_idx];
606 /* Check our requirements */
607 switch (summon_specific_type)
611 okay = (r_ptr->d_char == 'a');
617 okay = (r_ptr->d_char == 'S');
623 okay = ((r_ptr->d_char == 'C') || (r_ptr->d_char == 'Z'));
629 okay = (r_ptr->d_char == 'M');
635 okay = (r_ptr->d_char == 'A' && ((r_ptr->flags3 & RF3_EVIL) || (r_ptr->flags3 & RF3_GOOD)));
641 okay = (r_ptr->flags3 & RF3_DEMON);
647 okay = (r_ptr->flags3 & RF3_UNDEAD);
653 okay = (r_ptr->flags3 & RF3_DRAGON);
657 case SUMMON_HI_UNDEAD:
659 okay = ((r_ptr->d_char == 'L') ||
660 (r_ptr->d_char == 'V') ||
661 (r_ptr->d_char == 'W'));
665 case SUMMON_HI_DRAGON:
667 okay = (r_ptr->d_char == 'D');
671 case SUMMON_HI_DEMON:
673 okay = (((r_ptr->d_char == 'U') ||
674 (r_ptr->d_char == 'H') ||
675 (r_ptr->d_char == 'B')) &&
676 (r_ptr->flags3 & RF3_DEMON)) ? TRUE : FALSE;
680 case SUMMON_AMBERITES:
682 okay = (r_ptr->flags3 & (RF3_AMBERITE)) ? TRUE : FALSE;
688 okay = (r_ptr->flags1 & (RF1_UNIQUE)) ? TRUE : FALSE;
692 case SUMMON_BIZARRE1:
694 okay = (r_ptr->d_char == 'm');
697 case SUMMON_BIZARRE2:
699 okay = (r_ptr->d_char == 'b');
702 case SUMMON_BIZARRE3:
704 okay = (r_ptr->d_char == 'Q');
708 case SUMMON_BIZARRE4:
710 okay = (r_ptr->d_char == 'v');
714 case SUMMON_BIZARRE5:
716 okay = (r_ptr->d_char == '$');
720 case SUMMON_BIZARRE6:
722 okay = ((r_ptr->d_char == '!') ||
723 (r_ptr->d_char == '?') ||
724 (r_ptr->d_char == '=') ||
725 (r_ptr->d_char == '$') ||
726 (r_ptr->d_char == '|'));
732 okay = (r_ptr->d_char == 'g');
738 okay = ((r_ptr->d_char == 'U') &&
739 (r_ptr->flags4 & RF4_ROCKET));
746 okay = ((r_ptr->d_char == summon_kin_type) && (r_idx != MON_HAGURE));
752 okay = (r_idx == MON_DAWN);
758 okay = (r_ptr->flags3 & (RF3_ANIMAL));
762 case SUMMON_ANIMAL_RANGER:
764 okay = ((r_ptr->flags3 & (RF3_ANIMAL)) &&
765 (strchr("abcflqrwBCHIJKMRS", r_ptr->d_char)) &&
766 !(r_ptr->flags3 & (RF3_DRAGON)) &&
767 !(r_ptr->flags3 & (RF3_EVIL)) &&
768 !(r_ptr->flags3 & (RF3_UNDEAD)) &&
769 !(r_ptr->flags3 & (RF3_DEMON)) &&
770 !(r_ptr->flags2 & (RF2_MULTIPLY)) &&
771 !(r_ptr->flags4 || r_ptr->flags5 || r_ptr->flags6));
775 case SUMMON_HI_DRAGON_LIVING:
777 okay = ((r_ptr->d_char == 'D') && monster_living(r_ptr));
783 okay = monster_living(r_ptr);
789 okay = (r_idx == MON_PHANTOM_B || r_idx == MON_PHANTOM_W);
793 case SUMMON_BLUE_HORROR:
795 okay = (r_idx == MON_BLUE_HORROR);
799 case SUMMON_ELEMENTAL:
801 okay = (r_ptr->d_char == 'E');
807 okay = (r_ptr->d_char == 'v');
813 okay = (r_ptr->d_char == 'H');
819 okay = (r_ptr->d_char == 'B');
823 case SUMMON_KAMIKAZE:
826 for (i = 0; i < 4; i++)
827 if (r_ptr->blow[i].method == RBM_EXPLODE) okay = TRUE;
831 case SUMMON_KAMIKAZE_LIVING:
835 for (i = 0; i < 4; i++)
836 if (r_ptr->blow[i].method == RBM_EXPLODE) okay = TRUE;
837 okay = (okay && monster_living(r_ptr));
843 okay = (r_idx == MON_MANES);
849 okay = (r_idx == MON_LOUSE);
853 case SUMMON_GUARDIANS:
855 okay = (r_ptr->flags7 & RF7_GUARDIAN);
861 okay = ((r_idx == MON_NOV_PALADIN) ||
862 (r_idx == MON_NOV_PALADIN_G) ||
863 (r_idx == MON_PALADIN) ||
864 (r_idx == MON_W_KNIGHT) ||
865 (r_idx == MON_ULTRA_PALADIN) ||
866 (r_idx == MON_KNI_TEMPLAR));
872 okay = (r_ptr->d_char == 'B' &&
873 (r_ptr->flags8 & RF8_WILD_MOUNTAIN) &&
874 (r_ptr->flags8 & RF8_WILD_ONLY));
878 case SUMMON_PIRANHAS:
880 okay = (r_idx == MON_PIRANHA);
884 case SUMMON_ARMAGE_GOOD:
886 okay = (r_ptr->d_char == 'A' && (r_ptr->flags3 & RF3_GOOD));
890 case SUMMON_ARMAGE_EVIL:
892 okay = ((r_ptr->flags3 & RF3_DEMON) ||
893 (r_ptr->d_char == 'A' && (r_ptr->flags3 & RF3_EVIL)));
899 /* Since okay is int, "return (okay);" is not correct. */
900 return (bool)(okay ? TRUE : FALSE);
904 static int chameleon_change_m_idx = 0;
908 * Some dungeon types restrict the possible monsters.
909 * Return TRUE is the monster is OK and FALSE otherwise
911 static bool restrict_monster_to_dungeon(int r_idx)
913 dungeon_info_type *d_ptr = &d_info[dungeon_type];
914 monster_race *r_ptr = &r_info[r_idx];
917 if (d_ptr->flags1 & DF1_CHAMELEON)
919 if (chameleon_change_m_idx) return TRUE;
921 if (d_ptr->flags1 & DF1_NO_MAGIC)
923 if (r_idx != MON_CHAMELEON &&
925 !(r_ptr->flags4 & RF4_NOMAGIC_MASK) &&
926 !(r_ptr->flags5 & RF5_NOMAGIC_MASK) &&
927 !(r_ptr->flags6 & RF6_NOMAGIC_MASK))
930 if (d_ptr->flags1 & DF1_NO_MELEE)
932 if (r_idx == MON_CHAMELEON) return TRUE;
933 if (!(r_ptr->flags4 & (RF4_BOLT_MASK | RF4_BEAM_MASK | RF4_BALL_MASK)) &&
934 !(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)) &&
935 !(r_ptr->flags6 & (RF6_BOLT_MASK | RF6_BEAM_MASK | RF6_BALL_MASK)))
938 if (d_ptr->flags1 & DF1_BEGINNER)
940 if (r_ptr->level > dun_level)
944 if (d_ptr->special_div >= 64) return TRUE;
945 if (summon_specific_type && !(d_ptr->flags1 & DF1_CHAMELEON)) return TRUE;
949 case DUNGEON_MODE_AND:
952 if ((d_ptr->mflags1 & r_ptr->flags1) != d_ptr->mflags1)
957 if ((d_ptr->mflags2 & r_ptr->flags2) != d_ptr->mflags2)
962 if ((d_ptr->mflags3 & r_ptr->flags3) != d_ptr->mflags3)
967 if ((d_ptr->mflags4 & r_ptr->flags4) != d_ptr->mflags4)
972 if ((d_ptr->mflags5 & r_ptr->flags5) != d_ptr->mflags5)
977 if ((d_ptr->mflags6 & r_ptr->flags6) != d_ptr->mflags6)
982 if ((d_ptr->mflags7 & r_ptr->flags7) != d_ptr->mflags7)
987 if ((d_ptr->mflags8 & r_ptr->flags8) != d_ptr->mflags8)
992 if ((d_ptr->mflags9 & r_ptr->flags9) != d_ptr->mflags9)
997 if ((d_ptr->mflagsr & r_ptr->flagsr) != d_ptr->mflagsr)
1000 for (a = 0; a < 5; a++)
1001 if (d_ptr->r_char[a] && (d_ptr->r_char[a] != r_ptr->d_char)) return FALSE;
1005 case DUNGEON_MODE_NAND:
1008 if ((d_ptr->mflags1 & r_ptr->flags1) != d_ptr->mflags1)
1013 if ((d_ptr->mflags2 & r_ptr->flags2) != d_ptr->mflags2)
1018 if ((d_ptr->mflags3 & r_ptr->flags3) != d_ptr->mflags3)
1023 if ((d_ptr->mflags4 & r_ptr->flags4) != d_ptr->mflags4)
1028 if ((d_ptr->mflags5 & r_ptr->flags5) != d_ptr->mflags5)
1033 if ((d_ptr->mflags6 & r_ptr->flags6) != d_ptr->mflags6)
1038 if ((d_ptr->mflags7 & r_ptr->flags7) != d_ptr->mflags7)
1043 if ((d_ptr->mflags8 & r_ptr->flags8) != d_ptr->mflags8)
1048 if ((d_ptr->mflags9 & r_ptr->flags9) != d_ptr->mflags9)
1053 if ((d_ptr->mflagsr & r_ptr->flagsr) != d_ptr->mflagsr)
1056 for (a = 0; a < 5; a++)
1057 if (d_ptr->r_char[a] && (d_ptr->r_char[a] != r_ptr->d_char)) return TRUE;
1061 case DUNGEON_MODE_OR:
1062 if (r_ptr->flags1 & d_ptr->mflags1) return TRUE;
1063 if (r_ptr->flags2 & d_ptr->mflags2) return TRUE;
1064 if (r_ptr->flags3 & d_ptr->mflags3) return TRUE;
1065 if (r_ptr->flags4 & d_ptr->mflags4) return TRUE;
1066 if (r_ptr->flags5 & d_ptr->mflags5) return TRUE;
1067 if (r_ptr->flags6 & d_ptr->mflags6) return TRUE;
1068 if (r_ptr->flags7 & d_ptr->mflags7) return TRUE;
1069 if (r_ptr->flags8 & d_ptr->mflags8) return TRUE;
1070 if (r_ptr->flags9 & d_ptr->mflags9) return TRUE;
1071 if (r_ptr->flagsr & d_ptr->mflagsr) return TRUE;
1072 for (a = 0; a < 5; a++)
1073 if (d_ptr->r_char[a] == r_ptr->d_char) return TRUE;
1077 case DUNGEON_MODE_NOR:
1078 if (r_ptr->flags1 & d_ptr->mflags1) return FALSE;
1079 if (r_ptr->flags2 & d_ptr->mflags2) return FALSE;
1080 if (r_ptr->flags3 & d_ptr->mflags3) return FALSE;
1081 if (r_ptr->flags4 & d_ptr->mflags4) return FALSE;
1082 if (r_ptr->flags5 & d_ptr->mflags5) return FALSE;
1083 if (r_ptr->flags6 & d_ptr->mflags6) return FALSE;
1084 if (r_ptr->flags7 & d_ptr->mflags7) return FALSE;
1085 if (r_ptr->flags8 & d_ptr->mflags8) return FALSE;
1086 if (r_ptr->flags9 & d_ptr->mflags9) return FALSE;
1087 if (r_ptr->flagsr & d_ptr->mflagsr) return FALSE;
1088 for (a = 0; a < 5; a++)
1089 if (d_ptr->r_char[a] == r_ptr->d_char) return FALSE;
1098 * Apply a "monster restriction function" to the "monster allocation table"
1100 errr get_mon_num_prep(monster_hook_type monster_hook,
1101 monster_hook_type monster_hook2)
1105 /* Todo: Check the hooks for non-changes */
1107 /* Set the new hooks */
1108 get_mon_num_hook = monster_hook;
1109 get_mon_num2_hook = monster_hook2;
1111 /* Scan the allocation table */
1112 for (i = 0; i < alloc_race_size; i++)
1114 monster_race *r_ptr;
1117 alloc_entry *entry = &alloc_race_table[i];
1120 r_ptr = &r_info[entry->index];
1122 /* Skip monsters which don't pass the restriction */
1123 if ((get_mon_num_hook && !((*get_mon_num_hook)(entry->index))) ||
1124 (get_mon_num2_hook && !((*get_mon_num2_hook)(entry->index))))
1127 if (!p_ptr->inside_battle && !chameleon_change_m_idx &&
1128 summon_specific_type != SUMMON_GUARDIANS)
1130 /* Hack -- don't create questors */
1131 if (r_ptr->flags1 & RF1_QUESTOR)
1134 if (r_ptr->flags7 & RF7_GUARDIAN)
1137 /* Depth Monsters never appear out of depth */
1138 if ((r_ptr->flags1 & (RF1_FORCE_DEPTH)) &&
1139 (r_ptr->level > dun_level))
1143 /* Accept this monster */
1144 entry->prob2 = entry->prob1;
1146 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)
1148 int hoge = entry->prob2 * d_info[dungeon_type].special_div;
1149 entry->prob2 = hoge / 64;
1150 if (randint0(64) < (hoge & 0x3f)) entry->prob2++;
1159 static int mysqrt(int n)
1197 * Choose a monster race that seems "appropriate" to the given level
1199 * This function uses the "prob2" field of the "monster allocation table",
1200 * and various local information, to calculate the "prob3" field of the
1201 * same table, which is then used to choose an "appropriate" monster, in
1202 * a relatively efficient manner.
1204 * Note that "town" monsters will *only* be created in the town, and
1205 * "normal" monsters will *never* be created in the town, unless the
1206 * "level" is "modified", for example, by polymorph or summoning.
1208 * There is a small chance (1/50) of "boosting" the given depth by
1209 * a small amount (up to four levels), except in the town.
1211 * It is (slightly) more likely to acquire a monster of the given level
1212 * than one of a lower level. This is done by choosing several monsters
1213 * appropriate to the given level and keeping the "hardest" one.
1215 * Note that if no monsters are "appropriate", then this function will
1216 * fail, and return zero, but this should *almost* never happen.
1218 s16b get_mon_num(int level)
1226 monster_race *r_ptr;
1228 alloc_entry *table = alloc_race_table;
1230 int pls_kakuritu, pls_level;
1231 int hoge=mysqrt(level*10000L);
1233 if (level > MAX_DEPTH - 1) level = MAX_DEPTH - 1;
1235 if ((dungeon_turn > hoge*(TURNS_PER_TICK*500L)) && !level)
1237 pls_kakuritu = MAX(2, NASTY_MON-((dungeon_turn/(TURNS_PER_TICK*2500L)-hoge/10)));
1238 pls_level = MIN(8,3 + dungeon_turn/(TURNS_PER_TICK*20000L)-hoge/40);
1242 pls_kakuritu = NASTY_MON;
1246 if (d_info[dungeon_type].flags1 & DF1_MAZE)
1248 pls_kakuritu = MIN(pls_kakuritu/2, pls_kakuritu-10);
1249 if (pls_kakuritu < 2) pls_kakuritu = 2;
1254 /* Boost the level */
1255 if ((level > 0) && !p_ptr->inside_battle && !(d_info[dungeon_type].flags1 & DF1_BEGINNER))
1257 /* Nightmare mode allows more out-of depth monsters */
1258 if (ironman_nightmare && !randint0(pls_kakuritu))
1260 /* What a bizarre calculation */
1261 level = 1 + (level * MAX_DEPTH / randint1(MAX_DEPTH));
1265 /* Occasional "nasty" monster */
1266 if (!randint0(pls_kakuritu))
1268 /* Pick a level bonus */
1269 int d = MIN(5, level/10) + pls_level;
1271 /* Boost the level */
1275 /* Occasional "nasty" monster */
1276 if (!randint0(pls_kakuritu))
1278 /* Pick a level bonus */
1279 int d = MIN(5, level/10) + pls_level;
1281 /* Boost the level */
1291 /* Process probabilities */
1292 for (i = 0; i < alloc_race_size; i++)
1294 /* Monsters are sorted by depth */
1295 if (table[i].level > level) break;
1300 /* Access the "r_idx" of the chosen monster */
1301 r_idx = table[i].index;
1303 /* Access the actual race */
1304 r_ptr = &r_info[r_idx];
1306 if (!p_ptr->inside_battle && !chameleon_change_m_idx)
1308 /* Hack -- "unique" monsters must be "unique" */
1309 if (((r_ptr->flags1 & (RF1_UNIQUE)) ||
1310 (r_ptr->flags7 & (RF7_NAZGUL))) &&
1311 (r_ptr->cur_num >= r_ptr->max_num))
1316 if ((r_ptr->flags7 & (RF7_UNIQUE2)) &&
1317 (r_ptr->cur_num >= 1))
1322 if (r_idx == MON_BANORLUPART)
1324 if (r_info[MON_BANOR].cur_num > 0) continue;
1325 if (r_info[MON_LUPART].cur_num > 0) continue;
1330 table[i].prob3 = table[i].prob2;
1333 total += table[i].prob3;
1336 /* No legal monsters */
1337 if (total <= 0) return (0);
1340 /* Pick a monster */
1341 value = randint0(total);
1343 /* Find the monster */
1344 for (i = 0; i < alloc_race_size; i++)
1346 /* Found the entry */
1347 if (value < table[i].prob3) break;
1350 value = value - table[i].prob3;
1357 /* Try for a "harder" monster once (50%) or twice (10%) */
1363 /* Pick a monster */
1364 value = randint0(total);
1366 /* Find the monster */
1367 for (i = 0; i < alloc_race_size; i++)
1369 /* Found the entry */
1370 if (value < table[i].prob3) break;
1373 value = value - table[i].prob3;
1376 /* Keep the "best" one */
1377 if (table[i].level < table[j].level) i = j;
1380 /* Try for a "harder" monster twice (10%) */
1386 /* Pick a monster */
1387 value = randint0(total);
1389 /* Find the monster */
1390 for (i = 0; i < alloc_race_size; i++)
1392 /* Found the entry */
1393 if (value < table[i].prob3) break;
1396 value = value - table[i].prob3;
1399 /* Keep the "best" one */
1400 if (table[i].level < table[j].level) i = j;
1404 return (table[i].index);
1412 * Build a string describing a monster in some way.
1414 * We can correctly describe monsters based on their visibility.
1415 * We can force all monsters to be treated as visible or invisible.
1416 * We can build nominatives, objectives, possessives, or reflexives.
1417 * We can selectively pronominalize hidden, visible, or all monsters.
1418 * We can use definite or indefinite descriptions for hidden monsters.
1419 * We can use definite or indefinite descriptions for visible monsters.
1421 * Pronominalization involves the gender whenever possible and allowed,
1422 * so that by cleverly requesting pronominalization / visibility, you
1423 * can get messages like "You hit someone. She screams in agony!".
1425 * Reflexives are acquired by requesting Objective plus Possessive.
1427 * If no m_ptr arg is given (?), the monster is assumed to be hidden,
1428 * unless the "Assume Visible" mode is requested.
1430 * If no r_ptr arg is given, it is extracted from m_ptr and r_info
1431 * If neither m_ptr nor r_ptr is given, the monster is assumed to
1432 * be neuter, singular, and hidden (unless "Assume Visible" is set),
1433 * in which case you may be in trouble... :-)
1435 * I am assuming that no monster name is more than 70 characters long,
1436 * so that "char desc[80];" is sufficiently large for any result.
1439 * MD_OBJECTIVE --> Objective (or Reflexive)
1440 * MD_POSSESSIVE --> Possessive (or Reflexive)
1441 * MD_INDEF_HIDDEN --> Use indefinites for hidden monsters ("something")
1442 * MD_INDEF_VISIBLE --> Use indefinites for visible monsters ("a kobold")
1443 * MD_PRON_HIDDEN --> Pronominalize hidden monsters
1444 * MD_PRON_VISIBLE --> Pronominalize visible monsters
1445 * MD_ASSUME_HIDDEN --> Assume the monster is hidden
1446 * MD_ASSUME_VISIBLE --> Assume the monster is visible
1447 * MD_TRUE_NAME --> Chameleon's true name
1448 * MD_IGNORE_HALLU --> Ignore hallucination, and penetrate shape change
1449 * MD_ASSUME_OUTSIDE --> Assume this monster pet waiting outside the floor
1452 * 0x00 --> Full nominative name ("the kobold") or "it"
1453 * MD_INDEF_HIDDEN --> Full nominative name ("the kobold") or "something"
1454 * MD_ASSUME_VISIBLE --> Genocide resistance name ("the kobold")
1455 * MD_ASSUME_VISIBLE | MD_INDEF_VISIBLE --> Killing name ("a kobold")
1456 * MD_PRON_VISIBLE | MD_POSSESSIVE
1457 * --> Possessive, genderized if visable ("his") or "its"
1458 * MD_PRON_VISIBLE | MD_POSSESSIVE | MD_OBJECTIVE
1459 * --> Reflexive, genderized if visable ("himself") or "itself"
1461 void monster_desc(char *desc, monster_type *m_ptr, int mode)
1464 monster_race *r_ptr;
1468 char silly_name[1024];
1472 r_ptr = &r_info[m_ptr->ap_r_idx];
1474 /* Mode of MD_TRUE_NAME will reveal Chameleon's true name */
1475 if (mode & MD_TRUE_NAME) name = (r_name + real_r_ptr(m_ptr)->name);
1476 else name = (r_name + r_ptr->name);
1478 /* Are we hallucinating? (Idea from Nethack...) */
1479 if (p_ptr->image && !(mode & MD_IGNORE_HALLU))
1484 if (!get_rnd_line("silly_j.txt", m_ptr->r_idx, silly_name))
1486 if (!get_rnd_line("silly.txt", m_ptr->r_idx, silly_name))
1494 monster_race *hallu_race;
1498 hallu_race = &r_info[randint1(max_r_idx - 1)];
1500 while (hallu_race->flags1 & RF1_UNIQUE);
1502 strcpy(silly_name, (r_name + hallu_race->name));
1505 /* Better not strcpy it, or we could corrupt r_info... */
1509 /* Can we "see" it (exists + forced, or visible + not unforced) */
1510 seen = (m_ptr && ((mode & MD_ASSUME_VISIBLE) || (!(mode & MD_ASSUME_HIDDEN) && m_ptr->ml)));
1512 /* Sexed Pronouns (seen and allowed, or unseen and allowed) */
1513 pron = (m_ptr && ((seen && (mode & MD_PRON_VISIBLE)) || (!seen && (mode & MD_PRON_HIDDEN))));
1516 /* First, try using pronouns, or describing hidden monsters */
1519 /* an encoding of the monster "sex" */
1522 /* Extract the gender (if applicable) */
1523 if (r_ptr->flags1 & (RF1_FEMALE)) kind = 0x20;
1524 else if (r_ptr->flags1 & (RF1_MALE)) kind = 0x10;
1526 /* Ignore the gender (if desired) */
1527 if (!m_ptr || !pron) kind = 0x00;
1530 /* Assume simple result */
1538 /* Brute force: split on the possibilities */
1539 switch (kind + (mode & (MD_INDEF_HIDDEN | MD_POSSESSIVE | MD_OBJECTIVE)))
1541 /* Neuter, or unknown */
1543 case 0x00: res = "²¿¤«"; break;
1544 case 0x00 + (MD_OBJECTIVE): res = "²¿¤«"; break;
1545 case 0x00 + (MD_POSSESSIVE): res = "²¿¤«¤Î"; break;
1546 case 0x00 + (MD_POSSESSIVE | MD_OBJECTIVE): res = "²¿¤«¼«¿È"; break;
1547 case 0x00 + (MD_INDEF_HIDDEN): res = "²¿¤«"; break;
1548 case 0x00 + (MD_INDEF_HIDDEN | MD_OBJECTIVE): res = "²¿¤«"; break;
1549 case 0x00 + (MD_INDEF_HIDDEN | MD_POSSESSIVE): res = "²¿¤«"; break;
1550 case 0x00 + (MD_INDEF_HIDDEN | MD_POSSESSIVE | MD_OBJECTIVE): res = "¤½¤ì¼«¿È"; break;
1552 case 0x00: res = "it"; break;
1553 case 0x00 + (MD_OBJECTIVE): res = "it"; break;
1554 case 0x00 + (MD_POSSESSIVE): res = "its"; break;
1555 case 0x00 + (MD_POSSESSIVE | MD_OBJECTIVE): res = "itself"; break;
1556 case 0x00 + (MD_INDEF_HIDDEN): res = "something"; break;
1557 case 0x00 + (MD_INDEF_HIDDEN | MD_OBJECTIVE): res = "something"; break;
1558 case 0x00 + (MD_INDEF_HIDDEN | MD_POSSESSIVE): res = "something's"; break;
1559 case 0x00 + (MD_INDEF_HIDDEN | MD_POSSESSIVE | MD_OBJECTIVE): res = "itself"; break;
1563 /* Male (assume human if vague) */
1565 case 0x10: res = "Èà"; break;
1566 case 0x10 + (MD_OBJECTIVE): res = "Èà"; break;
1567 case 0x10 + (MD_POSSESSIVE): res = "Èà¤Î"; break;
1568 case 0x10 + (MD_POSSESSIVE | MD_OBJECTIVE): res = "È༫¿È"; break;
1569 case 0x10 + (MD_INDEF_HIDDEN): res = "狼"; break;
1570 case 0x10 + (MD_INDEF_HIDDEN | MD_OBJECTIVE): res = "狼"; break;
1571 case 0x10 + (MD_INDEF_HIDDEN | MD_POSSESSIVE): res = "狼¤Î"; break;
1572 case 0x10 + (MD_INDEF_HIDDEN | MD_POSSESSIVE | MD_OBJECTIVE): res = "È༫¿È"; break;
1574 case 0x10: res = "he"; break;
1575 case 0x10 + (MD_OBJECTIVE): res = "him"; break;
1576 case 0x10 + (MD_POSSESSIVE): res = "his"; break;
1577 case 0x10 + (MD_POSSESSIVE | MD_OBJECTIVE): res = "himself"; break;
1578 case 0x10 + (MD_INDEF_HIDDEN): res = "someone"; break;
1579 case 0x10 + (MD_INDEF_HIDDEN | MD_OBJECTIVE): res = "someone"; break;
1580 case 0x10 + (MD_INDEF_HIDDEN | MD_POSSESSIVE): res = "someone's"; break;
1581 case 0x10 + (MD_INDEF_HIDDEN | MD_POSSESSIVE | MD_OBJECTIVE): res = "himself"; break;
1585 /* Female (assume human if vague) */
1587 case 0x20: res = "Èà½÷"; break;
1588 case 0x20 + (MD_OBJECTIVE): res = "Èà½÷"; break;
1589 case 0x20 + (MD_POSSESSIVE): res = "Èà½÷¤Î"; break;
1590 case 0x20 + (MD_POSSESSIVE | MD_OBJECTIVE): res = "Èà½÷¼«¿È"; break;
1591 case 0x20 + (MD_INDEF_HIDDEN): res = "狼"; break;
1592 case 0x20 + (MD_INDEF_HIDDEN | MD_OBJECTIVE): res = "狼"; break;
1593 case 0x20 + (MD_INDEF_HIDDEN | MD_POSSESSIVE): res = "狼¤Î"; break;
1594 case 0x20 + (MD_INDEF_HIDDEN | MD_POSSESSIVE | MD_OBJECTIVE): res = "Èà½÷¼«¿È"; break;
1596 case 0x20: res = "she"; break;
1597 case 0x20 + (MD_OBJECTIVE): res = "her"; break;
1598 case 0x20 + (MD_POSSESSIVE): res = "her"; break;
1599 case 0x20 + (MD_POSSESSIVE | MD_OBJECTIVE): res = "herself"; break;
1600 case 0x20 + (MD_INDEF_HIDDEN): res = "someone"; break;
1601 case 0x20 + (MD_INDEF_HIDDEN | MD_OBJECTIVE): res = "someone"; break;
1602 case 0x20 + (MD_INDEF_HIDDEN | MD_POSSESSIVE): res = "someone's"; break;
1603 case 0x20 + (MD_INDEF_HIDDEN | MD_POSSESSIVE | MD_OBJECTIVE): res = "herself"; break;
1607 /* Copy the result */
1608 (void)strcpy(desc, res);
1612 /* Handle visible monsters, "reflexive" request */
1613 else if ((mode & (MD_POSSESSIVE | MD_OBJECTIVE)) == (MD_POSSESSIVE | MD_OBJECTIVE))
1615 /* The monster is visible, so use its gender */
1617 if (r_ptr->flags1 & (RF1_FEMALE)) strcpy(desc, "Èà½÷¼«¿È");
1618 else if (r_ptr->flags1 & (RF1_MALE)) strcpy(desc, "È༫¿È");
1619 else strcpy(desc, "¤½¤ì¼«¿È");
1621 if (r_ptr->flags1 & RF1_FEMALE) strcpy(desc, "herself");
1622 else if (r_ptr->flags1 & RF1_MALE) strcpy(desc, "himself");
1623 else strcpy(desc, "itself");
1628 /* Handle all other visible monster requests */
1632 if (is_pet(m_ptr) && m_ptr->ap_r_idx != m_ptr->r_idx)
1638 while(strncmp(t, "¡Ù", 2) && *t) t++;
1642 (void)sprintf(desc, "%s¡©¡Ù", buf);
1645 (void)sprintf(desc, "%s¡©", name);
1647 (void)sprintf(desc, "%s?", name);
1652 /* It could be a Unique */
1653 if ((r_ptr->flags1 & RF1_UNIQUE) && !(p_ptr->image && !(mode & MD_IGNORE_HALLU)))
1655 /* Start with the name (thus nominative and objective) */
1656 if ((m_ptr->mflag2 & MFLAG2_CHAMELEON) && !(mode & MD_TRUE_NAME))
1662 while (strncmp(t, "¡Ù", 2) && *t) t++;
1666 (void)sprintf(desc, "%s¡©¡Ù", buf);
1669 (void)sprintf(desc, "%s¡©", name);
1671 (void)sprintf(desc, "%s?", name);
1674 else if ((cave[m_ptr->fy][m_ptr->fx].m_idx == p_ptr->riding) || !p_ptr->inside_battle)
1675 (void)strcpy(desc, name);
1678 (void)sprintf(desc, "%s¤â¤É¤", name);
1680 (void)sprintf(desc, "fake %s", name);
1684 /* It could be an indefinite monster */
1685 else if (mode & MD_INDEF_VISIBLE)
1687 /* XXX Check plurality for "some" */
1689 /* Indefinite monsters need an indefinite article */
1691 (void)strcpy(desc, "");
1693 (void)strcpy(desc, is_a_vowel(name[0]) ? "an " : "a ");
1696 (void)strcat(desc, name);
1699 /* It could be a normal, definite, monster */
1702 /* Definite monsters need a definite article */
1705 (void)strcpy(desc, "¤¢¤Ê¤¿¤Î");
1707 (void)strcpy(desc, "your ");
1712 (void)strcpy(desc, "");
1714 (void)strcpy(desc, "the ");
1717 (void)strcat(desc, name);
1720 if (m_ptr->nickname)
1723 sprintf(buf,"¡Ö%s¡×",quark_str(m_ptr->nickname));
1725 sprintf(buf," called %s",quark_str(m_ptr->nickname));
1730 if (player_bold(m_ptr->fy, m_ptr->fx))
1733 strcat(desc,"(¾èÇÏÃæ)");
1735 strcat(desc,"(riding)");
1739 if ((mode & MD_IGNORE_HALLU) && (m_ptr->mflag2 & MFLAG2_CHAMELEON))
1741 if (r_ptr->flags1 & RF1_UNIQUE)
1744 strcat(desc,"(¥«¥á¥ì¥ª¥ó¤Î²¦)");
1746 strcat(desc,"(Chameleon Lord)");
1752 strcat(desc,"(¥«¥á¥ì¥ª¥ó)");
1754 strcat(desc,"(Chameleon)");
1759 if ((mode & MD_IGNORE_HALLU) && m_ptr->ap_r_idx != m_ptr->r_idx)
1761 strcat(desc, format("(%s)", r_name + r_info[m_ptr->r_idx].name));
1764 if (mode & MD_ASSUME_OUTSIDE)
1767 strcat(desc,"(ÂÔµ¡Ãæ)");
1769 strcat(desc,"(waiting)");
1773 /* Handle the Possessive as a special afterthought */
1774 if (mode & MD_POSSESSIVE)
1776 /* XXX Check for trailing "s" */
1778 /* Simply append "apostrophe" and "s" */
1780 (void)strcat(desc, "¤Î");
1782 (void)strcat(desc, "'s");
1792 * Learn about a monster (by "probing" it)
1794 * Return the number of new flags learnt. -Mogami-
1796 int lore_do_probe(int r_idx)
1798 monster_race *r_ptr = &r_info[r_idx];
1802 /* Maximal info about awareness */
1803 if (r_ptr->r_wake != MAX_UCHAR) n++;
1804 if (r_ptr->r_ignore != MAX_UCHAR) n++;
1805 r_ptr->r_wake = r_ptr->r_ignore = MAX_UCHAR;
1807 /* Observe "maximal" attacks */
1808 for (i = 0; i < 4; i++)
1810 /* Examine "actual" blows */
1811 if (r_ptr->blow[i].effect || r_ptr->blow[i].method)
1813 /* Maximal observations */
1814 if (r_ptr->r_blows[i] != MAX_UCHAR) n++;
1815 r_ptr->r_blows[i] = MAX_UCHAR;
1821 (((r_ptr->flags1 & RF1_DROP_4D2) ? 8 : 0) +
1822 ((r_ptr->flags1 & RF1_DROP_3D2) ? 6 : 0) +
1823 ((r_ptr->flags1 & RF1_DROP_2D2) ? 4 : 0) +
1824 ((r_ptr->flags1 & RF1_DROP_1D2) ? 2 : 0) +
1825 ((r_ptr->flags1 & RF1_DROP_90) ? 1 : 0) +
1826 ((r_ptr->flags1 & RF1_DROP_60) ? 1 : 0));
1828 /* Only "valid" drops */
1829 if (!(r_ptr->flags1 & RF1_ONLY_GOLD))
1831 if (r_ptr->r_drop_item != tmp_byte) n++;
1832 r_ptr->r_drop_item = tmp_byte;
1834 if (!(r_ptr->flags1 & RF1_ONLY_ITEM))
1836 if (r_ptr->r_drop_gold != tmp_byte) n++;
1837 r_ptr->r_drop_gold = tmp_byte;
1840 /* Observe many spells */
1841 if (r_ptr->r_cast_spell != MAX_UCHAR) n++;
1842 r_ptr->r_cast_spell = MAX_UCHAR;
1844 /* Count unknown flags */
1845 for (i = 0; i < 32; i++)
1847 if (!(r_ptr->r_flags1 & (1L << i)) &&
1848 (r_ptr->flags1 & (1L << i))) n++;
1849 if (!(r_ptr->r_flags2 & (1L << i)) &&
1850 (r_ptr->flags2 & (1L << i))) n++;
1851 if (!(r_ptr->r_flags3 & (1L << i)) &&
1852 (r_ptr->flags3 & (1L << i))) n++;
1853 if (!(r_ptr->r_flags4 & (1L << i)) &&
1854 (r_ptr->flags4 & (1L << i))) n++;
1855 if (!(r_ptr->r_flags5 & (1L << i)) &&
1856 (r_ptr->flags5 & (1L << i))) n++;
1857 if (!(r_ptr->r_flags6 & (1L << i)) &&
1858 (r_ptr->flags6 & (1L << i))) n++;
1859 if (!(r_ptr->r_flagsr & (1L << i)) &&
1860 (r_ptr->flagsr & (1L << i))) n++;
1862 /* r_flags7 is actually unused */
1864 if (!(r_ptr->r_flags7 & (1L << i)) &&
1865 (r_ptr->flags7 & (1L << i))) n++;
1869 /* Know all the flags */
1870 r_ptr->r_flags1 = r_ptr->flags1;
1871 r_ptr->r_flags2 = r_ptr->flags2;
1872 r_ptr->r_flags3 = r_ptr->flags3;
1873 r_ptr->r_flags4 = r_ptr->flags4;
1874 r_ptr->r_flags5 = r_ptr->flags5;
1875 r_ptr->r_flags6 = r_ptr->flags6;
1876 r_ptr->r_flagsr = r_ptr->flagsr;
1878 /* r_flags7 is actually unused */
1879 /* r_ptr->r_flags7 = r_ptr->flags7; */
1881 /* Know about evolution */
1882 if (!(r_ptr->r_xtra1 & MR1_SINKA)) n++;
1883 r_ptr->r_xtra1 |= MR1_SINKA;
1885 /* Update monster recall window */
1886 if (p_ptr->monster_race_idx == r_idx)
1889 p_ptr->window |= (PW_MONSTER);
1892 /* Return the number of new flags learnt */
1898 * Take note that the given monster just dropped some treasure
1900 * Note that learning the "GOOD"/"GREAT" flags gives information
1901 * about the treasure (even when the monster is killed for the first
1902 * time, such as uniques, and the treasure has not been examined yet).
1904 * This "indirect" method is used to prevent the player from learning
1905 * exactly how much treasure a monster can drop from observing only
1906 * a single example of a drop. This method actually observes how much
1907 * gold and items are dropped, and remembers that information to be
1908 * described later by the monster recall code.
1910 void lore_treasure(int m_idx, int num_item, int num_gold)
1912 monster_type *m_ptr = &m_list[m_idx];
1914 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1916 /* If the monster doesn't have original appearance, don't note */
1917 if (!is_original_ap(m_ptr)) return;
1919 /* Note the number of things dropped */
1920 if (num_item > r_ptr->r_drop_item) r_ptr->r_drop_item = num_item;
1921 if (num_gold > r_ptr->r_drop_gold) r_ptr->r_drop_gold = num_gold;
1923 /* Hack -- memorize the good/great flags */
1924 if (r_ptr->flags1 & (RF1_DROP_GOOD)) r_ptr->r_flags1 |= (RF1_DROP_GOOD);
1925 if (r_ptr->flags1 & (RF1_DROP_GREAT)) r_ptr->r_flags1 |= (RF1_DROP_GREAT);
1927 /* Update monster recall window */
1928 if (p_ptr->monster_race_idx == m_ptr->r_idx)
1931 p_ptr->window |= (PW_MONSTER);
1937 void sanity_blast(monster_type *m_ptr, bool necro)
1939 bool happened = FALSE;
1942 if (p_ptr->inside_battle || !character_dungeon) return;
1947 monster_race *r_ptr = &r_info[m_ptr->ap_r_idx];
1949 power = r_ptr->level / 2;
1951 monster_desc(m_name, m_ptr, 0);
1953 if (!(r_ptr->flags1 & RF1_UNIQUE))
1955 if (r_ptr->flags1 & RF1_FRIENDS)
1961 return; /* No effect yet, just loaded... */
1964 return; /* Cannot see it for some reason */
1966 if (!(r_ptr->flags2 & RF2_ELDRITCH_HORROR))
1972 return; /* Pet eldritch horrors are safe most of the time */
1974 if (randint1(100) > power) return;
1976 if (saving_throw(p_ptr->skill_sav - power))
1978 return; /* Save, no adverse effects */
1983 /* Something silly happens... */
1985 msg_format("%s%s¤Î´é¤ò¸«¤Æ¤·¤Þ¤Ã¤¿¡ª",
1986 funny_desc[randint0(MAX_SAN_FUNNY)], m_name);
1988 msg_format("You behold the %s visage of %s!",
1989 funny_desc[randint0(MAX_SAN_FUNNY)], m_name);
1995 msg_print(funny_comments[randint0(MAX_SAN_COMMENT)]);
1996 p_ptr->image = p_ptr->image + randint1(r_ptr->level);
1999 return; /* Never mind; we can't see it clearly enough */
2002 /* Something frightening happens... */
2004 msg_format("%s%s¤Î´é¤ò¸«¤Æ¤·¤Þ¤Ã¤¿¡ª",
2005 horror_desc[randint0(MAX_SAN_HORROR)], m_name);
2007 msg_format("You behold the %s visage of %s!",
2008 horror_desc[randint0(MAX_SAN_HORROR)], m_name);
2011 r_ptr->r_flags2 |= RF2_ELDRITCH_HORROR;
2013 /* Demon characters are unaffected */
2014 if (prace_is_(RACE_IMP) || prace_is_(RACE_DEMON) || (mimic_info[p_ptr->mimic_form].MIMIC_FLAGS & MIMIC_IS_DEMON)) return;
2015 if (p_ptr->wizard) return;
2017 /* Undead characters are 50% likely to be unaffected */
2018 if (prace_is_(RACE_SKELETON) || prace_is_(RACE_ZOMBIE)
2019 || prace_is_(RACE_VAMPIRE) || prace_is_(RACE_SPECTRE) ||
2020 (mimic_info[p_ptr->mimic_form].MIMIC_FLAGS & MIMIC_IS_UNDEAD))
2022 if (saving_throw(25 + p_ptr->lev)) return;
2028 msg_print("¥Í¥¯¥í¥Î¥ß¥³¥ó¤òÆɤó¤ÇÀµµ¤¤ò¼º¤Ã¤¿¡ª");
2030 msg_print("Your sanity is shaken by reading the Necronomicon!");
2035 if (!saving_throw(p_ptr->skill_sav - power)) /* Mind blast */
2037 if (!p_ptr->resist_conf)
2039 (void)set_confused(p_ptr->confused + randint0(4) + 4);
2041 if (!p_ptr->resist_chaos && one_in_(3))
2043 (void)set_image(p_ptr->image + randint0(250) + 150);
2048 if (!saving_throw(p_ptr->skill_sav - power)) /* Lose int & wis */
2055 if (!saving_throw(p_ptr->skill_sav - power)) /* Brain smash */
2057 if (!p_ptr->resist_conf)
2059 (void)set_confused(p_ptr->confused + randint0(4) + 4);
2061 if (!p_ptr->free_act)
2063 (void)set_paralyzed(p_ptr->paralyzed + randint0(4) + 4);
2065 while (randint0(100) > p_ptr->skill_sav)
2066 (void)do_dec_stat(A_INT);
2067 while (randint0(100) > p_ptr->skill_sav)
2068 (void)do_dec_stat(A_WIS);
2069 if (!p_ptr->resist_chaos)
2071 (void)set_image(p_ptr->image + randint0(250) + 150);
2076 if (!saving_throw(p_ptr->skill_sav - power)) /* Amnesia */
2079 if (lose_all_info())
2081 msg_print("¤¢¤Þ¤ê¤Î¶²ÉݤËÁ´¤Æ¤Î¤³¤È¤ò˺¤ì¤Æ¤·¤Þ¤Ã¤¿¡ª");
2083 msg_print("You forget everything in your utmost terror!");
2089 if (saving_throw(p_ptr->skill_sav - power))
2094 /* Else gain permanent insanity */
2095 if ((p_ptr->muta3 & MUT3_MORONIC) && /*(p_ptr->muta2 & MUT2_BERS_RAGE) &&*/
2096 ((p_ptr->muta2 & MUT2_COWARDICE) || (p_ptr->resist_fear)) &&
2097 ((p_ptr->muta2 & MUT2_HALLU) || (p_ptr->resist_chaos)))
2099 /* The poor bastard already has all possible insanities! */
2105 switch (randint1(21))
2108 if (!(p_ptr->muta3 & MUT3_MORONIC) && one_in_(5))
2110 if ((p_ptr->stat_use[A_INT] < 4) && (p_ptr->stat_use[A_WIS] < 4))
2113 msg_print("¤¢¤Ê¤¿¤Ï´°àú¤ÊÇϼ¯¤Ë¤Ê¤Ã¤¿¤è¤¦¤Êµ¤¤¬¤·¤¿¡£¤·¤«¤·¤½¤ì¤Ï¸µ¡¹¤À¤Ã¤¿¡£");
2115 msg_print("You turn into an utter moron!");
2121 msg_print("¤¢¤Ê¤¿¤Ï´°àú¤ÊÇϼ¯¤Ë¤Ê¤Ã¤¿¡ª");
2123 msg_print("You turn into an utter moron!");
2127 if (p_ptr->muta3 & MUT3_HYPER_INT)
2130 msg_print("¤¢¤Ê¤¿¤ÎǾ¤ÏÀ¸ÂÎ¥³¥ó¥Ô¥å¡¼¥¿¤Ç¤Ï¤Ê¤¯¤Ê¤Ã¤¿¡£");
2132 msg_print("Your brain is no longer a living computer.");
2135 p_ptr->muta3 &= ~(MUT3_HYPER_INT);
2137 p_ptr->muta3 |= MUT3_MORONIC;
2151 if (!(p_ptr->muta2 & MUT2_COWARDICE) && !p_ptr->resist_fear)
2154 msg_print("¤¢¤Ê¤¿¤Ï¥Ñ¥é¥Î¥¤¥¢¤Ë¤Ê¤Ã¤¿¡ª");
2156 msg_print("You become paranoid!");
2160 /* Duh, the following should never happen, but anyway... */
2161 if (p_ptr->muta3 & MUT3_FEARLESS)
2164 msg_print("¤¢¤Ê¤¿¤Ï¤â¤¦¶²¤ìÃΤ餺¤Ç¤Ï¤Ê¤¯¤Ê¤Ã¤¿¡£");
2166 msg_print("You are no longer fearless.");
2169 p_ptr->muta3 &= ~(MUT3_FEARLESS);
2172 p_ptr->muta2 |= MUT2_COWARDICE;
2186 if (!(p_ptr->muta2 & MUT2_HALLU) && !p_ptr->resist_chaos)
2189 msg_print("¸¸³Ð¤ò¤Ò¤µ¯¤³¤¹Àº¿ÀºøÍð¤Ë´Ù¤Ã¤¿¡ª");
2191 msg_print("You are afflicted by a hallucinatory insanity!");
2194 p_ptr->muta2 |= MUT2_HALLU;
2199 if (!(p_ptr->muta2 & MUT2_BERS_RAGE))
2202 msg_print("·ãÎõ¤Ê´¶¾ð¤Îȯºî¤Ë¤ª¤½¤ï¤ì¤ë¤è¤¦¤Ë¤Ê¤Ã¤¿¡ª");
2204 msg_print("You become subject to fits of berserk rage!");
2207 p_ptr->muta2 |= MUT2_BERS_RAGE;
2214 p_ptr->update |= PU_BONUS;
2220 * This function updates the monster record of the given monster
2222 * This involves extracting the distance to the player (if requested),
2223 * and then checking for visibility (natural, infravision, see-invis,
2224 * telepathy), updating the monster visibility flag, redrawing (or
2225 * erasing) the monster when its visibility changes, and taking note
2226 * of any interesting monster flags (cold-blooded, invisible, etc).
2228 * Note the new "mflag" field which encodes several monster state flags,
2229 * including "view" for when the monster is currently in line of sight,
2230 * and "mark" for when the monster is currently visible via detection.
2232 * The only monster fields that are changed here are "cdis" (the
2233 * distance from the player), "ml" (visible to the player), and
2234 * "mflag" (to maintain the "MFLAG_VIEW" flag).
2236 * Note the special "update_monsters()" function which can be used to
2237 * call this function once for every monster.
2239 * Note the "full" flag which requests that the "cdis" field be updated,
2240 * this is only needed when the monster (or the player) has moved.
2242 * Every time a monster moves, we must call this function for that
2243 * monster, and update the distance, and the visibility. Every time
2244 * the player moves, we must call this function for every monster, and
2245 * update the distance, and the visibility. Whenever the player "state"
2246 * changes in certain ways ("blindness", "infravision", "telepathy",
2247 * and "see invisible"), we must call this function for every monster,
2248 * and update the visibility.
2250 * Routines that change the "illumination" of a grid must also call this
2251 * function for any monster in that grid, since the "visibility" of some
2252 * monsters may be based on the illumination of their grid.
2254 * Note that this function is called once per monster every time the
2255 * player moves. When the player is running, this function is one
2256 * of the primary bottlenecks, along with "update_view()" and the
2257 * "process_monsters()" code, so efficiency is important.
2259 * Note the optimized "inline" version of the "distance()" function.
2261 * A monster is "visible" to the player if (1) it has been detected
2262 * by the player, (2) it is close to the player and the player has
2263 * telepathy, or (3) it is close to the player, and in line of sight
2264 * of the player, and it is "illuminated" by some combination of
2265 * infravision, torch light, or permanent light (invisible monsters
2266 * are only affected by "light" if the player can see invisible).
2268 * Monsters which are not on the current panel may be "visible" to
2269 * the player, and their descriptions will include an "offscreen"
2270 * reference. Currently, offscreen monsters cannot be targetted
2271 * or viewed directly, but old targets will remain set. XXX XXX
2273 * The player can choose to be disturbed by several things, including
2274 * "disturb_move" (monster which is viewable moves in some way), and
2275 * "disturb_near" (monster which is "easily" viewable moves in some
2276 * way). Note that "moves" includes "appears" and "disappears".
2278 void update_mon(int m_idx, bool full)
2280 monster_type *m_ptr = &m_list[m_idx];
2282 monster_race *r_ptr = &r_info[m_ptr->r_idx];
2284 bool do_disturb = disturb_move;
2288 /* Current location */
2295 /* Seen by vision */
2298 /* Non-Ninja player in the darkness */
2299 bool in_darkness = (d_info[dungeon_type].flags1 & DF1_DARKNESS) && !p_ptr->see_nocto;
2304 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
2306 if (ap_r_ptr->r_tkills && ap_r_ptr->level >= p_ptr->lev)
2310 /* Compute distance */
2313 /* Distance components */
2314 int dy = (py > fy) ? (py - fy) : (fy - py);
2315 int dx = (px > fx) ? (px - fx) : (fx - px);
2317 /* Approximate distance */
2318 d = (dy > dx) ? (dy + (dx>>1)) : (dx + (dy>>1));
2320 /* Restrict distance */
2321 if (d > 255) d = 255;
2325 /* Save the distance */
2329 /* Extract distance */
2332 /* Extract the distance */
2338 if (m_ptr->mflag2 & (MFLAG2_MARK)) flag = TRUE;
2342 if (d <= (in_darkness ? MAX_SIGHT / 2 : MAX_SIGHT))
2344 if (!in_darkness || (d <= MAX_SIGHT / 4))
2346 if (p_ptr->special_defense & KATA_MUSOU)
2351 if (is_original_ap(m_ptr))
2353 /* Hack -- Memorize mental flags */
2354 if (r_ptr->flags2 & (RF2_SMART)) r_ptr->r_flags2 |= (RF2_SMART);
2355 if (r_ptr->flags2 & (RF2_STUPID)) r_ptr->r_flags2 |= (RF2_STUPID);
2359 /* Basic telepathy */
2360 else if (p_ptr->telepathy)
2362 /* Empty mind, no telepathy */
2363 if (r_ptr->flags2 & (RF2_EMPTY_MIND))
2365 /* Memorize flags */
2366 if (is_original_ap(m_ptr)) r_ptr->r_flags2 |= (RF2_EMPTY_MIND);
2369 /* Weird mind, occasional telepathy */
2370 else if (r_ptr->flags2 & (RF2_WEIRD_MIND))
2372 /* One in ten individuals are detectable */
2373 if ((m_idx % 10) == 5)
2378 if (is_original_ap(m_ptr))
2380 /* Memorize flags */
2381 r_ptr->r_flags2 |= (RF2_WEIRD_MIND);
2383 /* Hack -- Memorize mental flags */
2384 if (r_ptr->flags2 & (RF2_SMART)) r_ptr->r_flags2 |= (RF2_SMART);
2385 if (r_ptr->flags2 & (RF2_STUPID)) r_ptr->r_flags2 |= (RF2_STUPID);
2390 /* Normal mind, allow telepathy */
2396 if (is_original_ap(m_ptr))
2398 /* Hack -- Memorize mental flags */
2399 if (r_ptr->flags2 & (RF2_SMART)) r_ptr->r_flags2 |= (RF2_SMART);
2400 if (r_ptr->flags2 & (RF2_STUPID)) r_ptr->r_flags2 |= (RF2_STUPID);
2405 /* Magical sensing */
2406 if ((p_ptr->esp_animal) && (r_ptr->flags3 & (RF3_ANIMAL)))
2409 if (is_original_ap(m_ptr)) r_ptr->r_flags3 |= (RF3_ANIMAL);
2412 /* Magical sensing */
2413 if ((p_ptr->esp_undead) && (r_ptr->flags3 & (RF3_UNDEAD)))
2416 if (is_original_ap(m_ptr)) r_ptr->r_flags3 |= (RF3_UNDEAD);
2419 /* Magical sensing */
2420 if ((p_ptr->esp_demon) && (r_ptr->flags3 & (RF3_DEMON)))
2423 if (is_original_ap(m_ptr)) r_ptr->r_flags3 |= (RF3_DEMON);
2426 /* Magical sensing */
2427 if ((p_ptr->esp_orc) && (r_ptr->flags3 & (RF3_ORC)))
2430 if (is_original_ap(m_ptr)) r_ptr->r_flags3 |= (RF3_ORC);
2433 /* Magical sensing */
2434 if ((p_ptr->esp_troll) && (r_ptr->flags3 & (RF3_TROLL)))
2437 if (is_original_ap(m_ptr)) r_ptr->r_flags3 |= (RF3_TROLL);
2440 /* Magical sensing */
2441 if ((p_ptr->esp_giant) && (r_ptr->flags3 & (RF3_GIANT)))
2444 if (is_original_ap(m_ptr)) r_ptr->r_flags3 |= (RF3_GIANT);
2447 /* Magical sensing */
2448 if ((p_ptr->esp_dragon) && (r_ptr->flags3 & (RF3_DRAGON)))
2451 if (is_original_ap(m_ptr)) r_ptr->r_flags3 |= (RF3_DRAGON);
2454 /* Magical sensing */
2455 if ((p_ptr->esp_human) && (r_ptr->flags2 & (RF2_HUMAN)))
2458 if (is_original_ap(m_ptr)) r_ptr->r_flags2 |= (RF2_HUMAN);
2461 /* Magical sensing */
2462 if ((p_ptr->esp_evil) && (r_ptr->flags3 & (RF3_EVIL)))
2465 if (is_original_ap(m_ptr)) r_ptr->r_flags3 |= (RF3_EVIL);
2468 /* Magical sensing */
2469 if ((p_ptr->esp_good) && (r_ptr->flags3 & (RF3_GOOD)))
2472 if (is_original_ap(m_ptr)) r_ptr->r_flags3 |= (RF3_GOOD);
2475 /* Magical sensing */
2476 if ((p_ptr->esp_nonliving) &&
2477 ((r_ptr->flags3 & (RF3_DEMON | RF3_UNDEAD | RF3_NONLIVING)) == RF3_NONLIVING))
2480 if (is_original_ap(m_ptr)) r_ptr->r_flags3 |= (RF3_NONLIVING);
2483 /* Magical sensing */
2484 if ((p_ptr->esp_unique) && (r_ptr->flags1 & (RF1_UNIQUE)))
2487 if (is_original_ap(m_ptr)) r_ptr->r_flags1 |= (RF1_UNIQUE);
2491 /* Normal line of sight, and not blind */
2492 if (player_has_los_bold(fy, fx) && !p_ptr->blind)
2494 bool do_invisible = FALSE;
2495 bool do_cold_blood = FALSE;
2497 /* Use "infravision" */
2498 if (d <= p_ptr->see_infra)
2500 /* Handle "cold blooded" monsters */
2501 if ((r_ptr->flags2 & (RF2_COLD_BLOOD | RF2_AURA_FIRE)) == RF2_COLD_BLOOD)
2504 do_cold_blood = TRUE;
2507 /* Handle "warm blooded" monsters */
2515 /* Use "illumination" */
2516 if (player_can_see_bold(fy, fx))
2518 /* Handle "invisible" monsters */
2519 if (r_ptr->flags2 & (RF2_INVISIBLE))
2522 do_invisible = TRUE;
2532 /* Handle "normal" monsters */
2543 if (is_original_ap(m_ptr))
2545 /* Memorize flags */
2546 if (do_invisible) r_ptr->r_flags2 |= (RF2_INVISIBLE);
2547 if (do_cold_blood) r_ptr->r_flags2 |= (RF2_COLD_BLOOD);
2554 /* The monster is now visible */
2557 /* It was previously unseen */
2560 /* Mark as visible */
2563 /* Draw the monster */
2566 /* Update health bar as needed */
2567 if (p_ptr->health_who == m_idx) p_ptr->redraw |= (PR_HEALTH);
2568 if (p_ptr->riding == m_idx) p_ptr->redraw |= (PR_UHEALTH);
2570 /* Hack -- Count "fresh" sightings */
2571 if ((m_ptr->ap_r_idx == MON_KAGE) && (r_info[MON_KAGE].r_sights < MAX_SHORT))
2572 r_info[MON_KAGE].r_sights++;
2573 else if (m_ptr->ap_r_idx == m_ptr->r_idx &&
2574 r_ptr->r_sights < MAX_SHORT) r_ptr->r_sights++;
2576 /* Eldritch Horror */
2577 if (r_ptr->flags2 & RF2_ELDRITCH_HORROR)
2579 sanity_blast(m_ptr, FALSE);
2582 /* Disturb on appearance */
2583 if (disturb_near && (projectable(m_ptr->fy, m_ptr->fx, py, px) && projectable(py, px, m_ptr->fy, m_ptr->fx)))
2585 if (disturb_pets || is_hostile(m_ptr))
2591 /* The monster is not visible */
2594 /* It was previously seen */
2597 /* Mark as not visible */
2600 /* Erase the monster */
2603 /* Update health bar as needed */
2604 if (p_ptr->health_who == m_idx) p_ptr->redraw |= (PR_HEALTH);
2605 if (p_ptr->riding == m_idx) p_ptr->redraw |= (PR_UHEALTH);
2607 /* Disturb on disappearance */
2610 if (disturb_pets || is_hostile(m_ptr))
2617 /* The monster is now easily visible */
2621 if (!(m_ptr->mflag & (MFLAG_VIEW)))
2623 /* Mark as easily visible */
2624 m_ptr->mflag |= (MFLAG_VIEW);
2626 /* Disturb on appearance */
2629 if (disturb_pets || is_hostile(m_ptr))
2635 /* The monster is not easily visible */
2639 if (m_ptr->mflag & (MFLAG_VIEW))
2641 /* Mark as not easily visible */
2642 m_ptr->mflag &= ~(MFLAG_VIEW);
2644 /* Disturb on disappearance */
2647 if (disturb_pets || is_hostile(m_ptr))
2656 * This function simply updates all the (non-dead) monsters (see above).
2658 void update_monsters(bool full)
2662 /* Update each (live) monster */
2663 for (i = 1; i < m_max; i++)
2665 monster_type *m_ptr = &m_list[i];
2667 /* Skip dead monsters */
2668 if (!m_ptr->r_idx) continue;
2670 /* Update the monster */
2671 update_mon(i, full);
2677 * Hack -- the index of the summoning monster
2679 static bool monster_hook_chameleon_lord(int r_idx)
2681 monster_race *r_ptr = &r_info[r_idx];
2682 monster_type *m_ptr = &m_list[chameleon_change_m_idx];
2683 monster_race *old_r_ptr = &r_info[m_ptr->r_idx];
2685 if (!(r_ptr->flags1 & (RF1_UNIQUE))) return FALSE;
2686 if (r_ptr->flags7 & (RF7_FRIENDLY | RF7_CHAMELEON)) return FALSE;
2688 if (ABS(r_ptr->level - r_info[MON_CHAMELEON_K].level) > 5) return FALSE;
2690 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))
2693 if (!monster_can_cross_terrain(cave[m_ptr->fy][m_ptr->fx].feat, r_ptr)) return FALSE;
2696 if (!(old_r_ptr->flags7 & RF7_CHAMELEON))
2698 if (monster_has_hostile_align(m_ptr, 0, 0, r_ptr)) return FALSE;
2702 else if (summon_specific_who > 0)
2704 if (monster_has_hostile_align(&m_list[summon_specific_who], 0, 0, r_ptr)) return FALSE;
2710 static bool monster_hook_chameleon(int r_idx)
2712 monster_race *r_ptr = &r_info[r_idx];
2713 monster_type *m_ptr = &m_list[chameleon_change_m_idx];
2714 monster_race *old_r_ptr = &r_info[m_ptr->r_idx];
2716 if (r_ptr->flags1 & (RF1_UNIQUE)) return FALSE;
2717 if (r_ptr->flags2 & RF2_MULTIPLY) return FALSE;
2718 if (r_ptr->flags7 & (RF7_FRIENDLY | RF7_CHAMELEON)) return FALSE;
2720 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))
2723 if (!monster_can_cross_terrain(cave[m_ptr->fy][m_ptr->fx].feat, r_ptr)) return FALSE;
2726 if (!(old_r_ptr->flags7 & RF7_CHAMELEON))
2728 if ((old_r_ptr->flags3 & RF3_GOOD) && !(r_ptr->flags3 & RF3_GOOD)) return FALSE;
2729 if ((old_r_ptr->flags3 & RF3_EVIL) && !(r_ptr->flags3 & RF3_EVIL)) return FALSE;
2730 if (!(old_r_ptr->flags3 & (RF3_GOOD | RF3_EVIL)) && (r_ptr->flags3 & (RF3_GOOD | RF3_EVIL))) return FALSE;
2734 else if (summon_specific_who > 0)
2736 if (monster_has_hostile_align(&m_list[summon_specific_who], 0, 0, r_ptr)) return FALSE;
2739 return (*(get_monster_hook()))(r_idx);
2743 void choose_new_monster(int m_idx, bool born, int r_idx)
2746 monster_type *m_ptr = &m_list[m_idx];
2747 monster_race *r_ptr;
2748 char old_m_name[80];
2749 bool old_unique = FALSE;
2751 if (r_info[m_ptr->r_idx].flags1 & RF1_UNIQUE)
2753 if (old_unique && (r_idx == MON_CHAMELEON)) r_idx = MON_CHAMELEON_K;
2754 r_ptr = &r_info[r_idx];
2756 monster_desc(old_m_name, m_ptr, 0);
2762 chameleon_change_m_idx = m_idx;
2764 get_mon_num_prep(monster_hook_chameleon_lord, NULL);
2766 get_mon_num_prep(monster_hook_chameleon, NULL);
2769 level = r_info[MON_CHAMELEON_K].level;
2770 else if (!dun_level)
2771 level = wilderness[p_ptr->wilderness_y][p_ptr->wilderness_x].level;
2775 if (d_info[dungeon_type].flags1 & DF1_CHAMELEON) level+= 2+randint1(3);
2777 r_idx = get_mon_num(level);
2778 r_ptr = &r_info[r_idx];
2780 chameleon_change_m_idx = 0;
2786 m_ptr->r_idx = r_idx;
2787 m_ptr->ap_r_idx = r_idx;
2788 update_mon(m_idx, FALSE);
2789 lite_spot(m_ptr->fy, m_ptr->fx);
2792 /* Sub-alignment of a chameleon */
2793 if (r_ptr->flags3 & (RF3_EVIL | RF3_GOOD))
2795 m_ptr->sub_align = SUB_ALIGN_NEUTRAL;
2796 if (r_ptr->flags3 & RF3_EVIL) m_ptr->sub_align |= SUB_ALIGN_EVIL;
2797 if (r_ptr->flags3 & RF3_GOOD) m_ptr->sub_align |= SUB_ALIGN_GOOD;
2802 if (m_idx == p_ptr->riding)
2805 monster_desc(m_name, m_ptr, 0);
2807 msg_format("ÆÍÁ³%s¤¬ÊѿȤ·¤¿¡£", old_m_name);
2809 msg_format("Suddenly, %s transforms!", old_m_name);
2811 if (!(r_ptr->flags7 & RF7_RIDING))
2813 if (rakuba(0, TRUE)) msg_print("ÃÏÌ̤ËÍî¤È¤µ¤ì¤¿¡£");
2815 if (rakuba(0, TRUE)) msg_format("You have fallen from %s.", m_name);
2819 /* Extract the monster base speed */
2820 m_ptr->mspeed = get_mspeed(r_ptr);
2822 oldmaxhp = m_ptr->max_maxhp;
2823 /* Assign maximal hitpoints */
2824 if (r_ptr->flags1 & RF1_FORCE_MAXHP)
2826 m_ptr->max_maxhp = maxroll(r_ptr->hdice, r_ptr->hside);
2830 m_ptr->max_maxhp = damroll(r_ptr->hdice, r_ptr->hside);
2832 m_ptr->maxhp = (long)(m_ptr->maxhp * m_ptr->max_maxhp) / oldmaxhp;
2833 m_ptr->hp = (long)(m_ptr->hp * m_ptr->max_maxhp) / oldmaxhp;
2840 static bool monster_hook_tanuki(int r_idx)
2842 monster_race *r_ptr = &r_info[r_idx];
2844 if (r_ptr->flags1 & (RF1_UNIQUE)) return FALSE;
2845 if (r_ptr->flags2 & RF2_MULTIPLY) return FALSE;
2846 if (r_ptr->flags7 & (RF7_FRIENDLY | RF7_CHAMELEON)) return FALSE;
2847 if (r_ptr->flags7 & RF7_AQUATIC) return FALSE;
2849 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))
2852 return (*(get_monster_hook()))(r_idx);
2857 * Set initial racial appearance of a monster
2859 static int initial_r_appearance(int r_idx)
2861 int attempts = 1000;
2864 int min = MIN(base_level-5, 50);
2866 if (!(r_info[r_idx].flags7 & RF7_TANUKI))
2869 get_mon_num_prep(monster_hook_tanuki, NULL);
2873 ap_r_idx = get_mon_num(base_level + 10);
2874 if (r_info[ap_r_idx].level >= min) return ap_r_idx;
2882 * Get initial monster speed
2884 byte get_mspeed(monster_race *r_ptr)
2886 /* Extract the monster base speed */
2887 int mspeed = r_ptr->speed;
2889 /* Hack -- small racial variety */
2890 if (!(r_ptr->flags1 & RF1_UNIQUE) && !p_ptr->inside_arena)
2892 /* Allow some small variation per monster */
2893 int i = SPEED_TO_ENERGY(r_ptr->speed) / (one_in_(4) ? 3 : 10);
2894 if (i) mspeed += rand_spread(0, i);
2897 if (mspeed > 199) mspeed = 199;
2899 return (byte)mspeed;
2904 * Attempt to place a monster of the given race at the given location.
2906 * To give the player a sporting chance, any monster that appears in
2907 * line-of-sight and is extremely dangerous can be marked as
2908 * "FORCE_SLEEP", which will cause them to be placed with low energy,
2909 * which often (but not always) lets the player move before they do.
2911 * This routine refuses to place out-of-depth "FORCE_DEPTH" monsters.
2913 * XXX XXX XXX Use special "here" and "dead" flags for unique monsters,
2914 * remove old "cur_num" and "max_num" fields.
2916 * XXX XXX XXX Actually, do something similar for artifacts, to simplify
2917 * the "preserve" mode, and to make the "what artifacts" flag more useful.
2919 * This is the only function which may place a monster in the dungeon,
2920 * except for the savefile loading code.
2922 bool place_monster_one(int who, int y, int x, int r_idx, u32b mode)
2926 monster_type *m_ptr;
2928 monster_race *r_ptr = &r_info[r_idx];
2930 cptr name = (r_name + r_ptr->name);
2932 /* DO NOT PLACE A MONSTER IN THE SMALL SCALE WILDERNESS !!! */
2933 if(p_ptr->wild_mode) return FALSE;
2935 /* Verify location */
2936 if (!in_bounds(y, x)) return (FALSE);
2938 /* Require empty space (if not ghostly) */
2939 if (!(!dun_level && (cave[y][x].feat == FEAT_MOUNTAIN) && ((r_ptr->flags8 & RF8_WILD_MOUNTAIN) || (r_ptr->flags7 & RF7_CAN_FLY))) &&
2940 !(cave_empty_bold2(y, x) || (mode & PM_IGNORE_TERRAIN)) &&
2941 !((r_ptr->flags2 & RF2_PASS_WALL) &&
2942 !(cave_perma_bold(y, x) || cave[y][x].m_idx ||
2943 player_bold(y, x)))) return (FALSE);
2946 if (!r_idx) return (FALSE);
2949 if (!r_ptr->name) return (FALSE);
2951 /* Nor on the Pattern */
2952 if ((cave[y][x].feat >= FEAT_PATTERN_START)
2953 && (cave[y][x].feat <= FEAT_PATTERN_XTRA2))
2956 if (!(mode & PM_IGNORE_TERRAIN) &&
2957 !monster_can_cross_terrain(cave[y][x].feat, r_ptr))
2962 if (!p_ptr->inside_battle)
2964 /* Hack -- "unique" monsters must be "unique" */
2965 if (((r_ptr->flags1 & (RF1_UNIQUE)) ||
2966 (r_ptr->flags7 & (RF7_NAZGUL))) &&
2967 (r_ptr->cur_num >= r_ptr->max_num))
2973 if ((r_ptr->flags7 & (RF7_UNIQUE2)) &&
2974 (r_ptr->cur_num >= 1))
2979 if (r_idx == MON_BANORLUPART)
2981 if (r_info[MON_BANOR].cur_num > 0) return FALSE;
2982 if (r_info[MON_LUPART].cur_num > 0) return FALSE;
2985 /* Depth monsters may NOT be created out of depth, unless in Nightmare mode */
2986 if ((r_ptr->flags1 & (RF1_FORCE_DEPTH)) && (dun_level < r_ptr->level) &&
2987 (!ironman_nightmare || (r_ptr->flags1 & (RF1_QUESTOR))))
2994 if (quest_number(dun_level))
2996 int hoge = quest_number(dun_level);
2997 if ((quest[hoge].type == QUEST_TYPE_KILL_LEVEL) || (quest[hoge].type == QUEST_TYPE_RANDOM))
2999 if(r_idx == quest[hoge].r_idx)
3001 int number_mon, i2, j2;
3004 /* Count all quest monsters */
3005 for (i2 = 0; i2 < cur_wid; ++i2)
3006 for (j2 = 0; j2 < cur_hgt; j2++)
3007 if (cave[j2][i2].m_idx > 0)
3008 if (m_list[cave[j2][i2].m_idx].r_idx == quest[hoge].r_idx)
3010 if(number_mon + quest[hoge].cur_num >= quest[hoge].max_num)
3016 /* Access the location */
3017 c_ptr = &cave[y][x];
3019 if (is_glyph_grid(c_ptr))
3021 if (randint1(BREAK_GLYPH) < (r_ptr->level+20))
3023 /* Describe observable breakage */
3024 if (c_ptr->info & CAVE_MARK)
3027 msg_print("¼é¤ê¤Î¥ë¡¼¥ó¤¬²õ¤ì¤¿¡ª");
3029 msg_print("The rune of protection is broken!");
3034 /* Forget the rune */
3035 c_ptr->info &= ~(CAVE_MARK);
3037 /* Break the rune */
3038 c_ptr->info &= ~(CAVE_OBJECT);
3047 /* Powerful monster */
3048 if (r_ptr->level > dun_level)
3050 /* Unique monsters */
3051 if (r_ptr->flags1 & (RF1_UNIQUE))
3053 /* Message for cheaters */
3055 if (cheat_hear) msg_format("¿¼ÁؤΥæ¥Ë¡¼¥¯¡¦¥â¥ó¥¹¥¿¡¼ (%s)¡£", name);
3057 if (cheat_hear) msg_format("Deep Unique (%s).", name);
3061 /* Boost rating by twice delta-depth */
3062 rating += (r_ptr->level - dun_level) * 2;
3065 /* Normal monsters */
3068 /* Message for cheaters */
3070 if (cheat_hear) msg_format("¿¼ÁؤΥâ¥ó¥¹¥¿¡¼ (%s)¡£", name);
3072 if (cheat_hear) msg_format("Deep Monster (%s).", name);
3076 /* Boost rating by delta-depth */
3077 rating += (r_ptr->level - dun_level);
3081 /* Note the monster */
3082 else if (r_ptr->flags1 & (RF1_UNIQUE))
3084 /* Unique monsters induce message */
3086 if (cheat_hear) msg_format("¥æ¥Ë¡¼¥¯¡¦¥â¥ó¥¹¥¿¡¼ (%s)¡£", name);
3088 if (cheat_hear) msg_format("Unique (%s).", name);
3093 if ((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags7 & RF7_NAZGUL) || (r_ptr->level < 10)) is_kage = FALSE;
3095 /* Make a new monster */
3096 c_ptr->m_idx = m_pop();
3097 hack_m_idx_ii = c_ptr->m_idx;
3099 /* Mega-Hack -- catch "failure" */
3100 if (!c_ptr->m_idx) return (FALSE);
3103 /* Get a new monster record */
3104 m_ptr = &m_list[c_ptr->m_idx];
3107 m_ptr->r_idx = r_idx;
3108 m_ptr->ap_r_idx = initial_r_appearance(r_idx);
3110 /* Sub-alignment of a monster */
3111 if ((who > 0) && !(r_ptr->flags3 & (RF3_EVIL | RF3_GOOD)))
3112 m_ptr->sub_align = m_list[who].sub_align;
3115 m_ptr->sub_align = SUB_ALIGN_NEUTRAL;
3116 if (r_ptr->flags3 & RF3_EVIL) m_ptr->sub_align |= SUB_ALIGN_EVIL;
3117 if (r_ptr->flags3 & RF3_GOOD) m_ptr->sub_align |= SUB_ALIGN_GOOD;
3120 /* Place the monster at the location */
3125 /* No "damage" yet */
3127 m_ptr->confused = 0;
3130 /* Unknown distance */
3133 reset_target(m_ptr);
3135 m_ptr->nickname = 0;
3143 if (r_ptr->flags7 & RF7_CHAMELEON)
3145 choose_new_monster(c_ptr->m_idx, TRUE, 0);
3146 r_ptr = &r_info[m_ptr->r_idx];
3147 m_ptr->mflag2 |= MFLAG2_CHAMELEON;
3150 /* Hack - Set sub_align to neutral when the Chameleon Lord is generated as "GUARDIAN" */
3151 if ((r_ptr->flags1 & RF1_UNIQUE) && (who <= 0))
3152 m_ptr->sub_align = SUB_ALIGN_NEUTRAL;
3156 m_ptr->ap_r_idx = MON_KAGE;
3157 m_ptr->mflag2 |= MFLAG2_KAGE;
3160 if (mode & PM_NO_PET) m_ptr->mflag2 |= MFLAG2_NOPET;
3166 if (mode & PM_FORCE_PET)
3171 else if ((r_ptr->flags7 & RF7_FRIENDLY) ||
3172 (mode & PM_FORCE_FRIENDLY) || is_friendly_idx(who))
3174 if (!monster_has_hostile_align(NULL, 0, -1, r_ptr)) set_friendly(m_ptr);
3177 /* Assume no sleeping */
3180 /* Enforce sleeping if needed */
3181 if ((mode & PM_ALLOW_SLEEP) && r_ptr->sleep && !ironman_nightmare)
3183 int val = r_ptr->sleep;
3184 m_ptr->csleep = ((val * 2) + randint1(val * 10));
3187 /* Assign maximal hitpoints */
3188 if (r_ptr->flags1 & RF1_FORCE_MAXHP)
3190 m_ptr->max_maxhp = maxroll(r_ptr->hdice, r_ptr->hside);
3194 m_ptr->max_maxhp = damroll(r_ptr->hdice, r_ptr->hside);
3197 /* Monsters have double hitpoints in Nightmare mode */
3198 if (ironman_nightmare)
3200 u32b hp = m_ptr->max_maxhp * 2L;
3202 m_ptr->max_maxhp = (s16b)MIN(30000, hp);
3205 m_ptr->maxhp = m_ptr->max_maxhp;
3207 /* And start out fully healthy */
3208 if (m_ptr->r_idx == MON_WOUNDED_BEAR)
3209 m_ptr->hp = m_ptr->maxhp / 2;
3210 else m_ptr->hp = m_ptr->maxhp;
3213 /* Extract the monster base speed */
3214 m_ptr->mspeed = get_mspeed(r_ptr);
3216 if (mode & PM_HASTE) m_ptr->fast = 100;
3218 /* Give a random starting energy */
3219 if (!ironman_nightmare)
3221 m_ptr->energy_need = ENERGY_NEED() - (s16b)randint0(100);
3225 /* Nightmare monsters are more prepared */
3226 m_ptr->energy_need = ENERGY_NEED() - (s16b)randint0(100) * 2;
3229 /* Force monster to wait for player, unless in Nightmare mode */
3230 if ((r_ptr->flags1 & RF1_FORCE_SLEEP) && !ironman_nightmare)
3232 /* Monster is still being nice */
3233 m_ptr->mflag |= (MFLAG_NICE);
3235 /* Must repair monsters */
3236 repair_monsters = TRUE;
3239 /* Hack -- see "process_monsters()" */
3240 if (c_ptr->m_idx < hack_m_idx)
3242 /* Monster is still being born */
3243 m_ptr->mflag |= (MFLAG_BORN);
3247 if (r_ptr->flags7 & RF7_SELF_LD_MASK)
3248 p_ptr->update |= (PU_MON_LITE);
3249 else if ((r_ptr->flags7 & RF7_HAS_LD_MASK) && !m_ptr->csleep)
3250 p_ptr->update |= (PU_MON_LITE);
3252 /* Update the monster */
3253 update_mon(c_ptr->m_idx, TRUE);
3256 /* Count the monsters on the level */
3257 real_r_ptr(m_ptr)->cur_num++;
3260 * Memorize location of the unique monster in saved floors.
3261 * A unique monster move from old saved floor.
3263 if (character_dungeon &&
3264 ((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags7 & RF7_NAZGUL)))
3265 real_r_ptr(m_ptr)->floor_id = p_ptr->floor_id;
3267 /* Hack -- Count the number of "reproducers" */
3268 if (r_ptr->flags2 & RF2_MULTIPLY) num_repro++;
3271 /* Hack -- Notice new multi-hued monsters */
3273 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
3274 if (ap_r_ptr->flags1 & (RF1_ATTR_MULTI | RF1_SHAPECHANGER))
3275 shimmer_monsters = TRUE;
3278 if (p_ptr->warning && character_dungeon)
3280 if (r_ptr->flags1 & RF1_UNIQUE)
3284 char o_name[MAX_NLEN];
3286 if (r_ptr->level > p_ptr->lev + 30)
3292 else if (r_ptr->level > p_ptr->lev + 15)
3298 else if (r_ptr->level > p_ptr->lev + 5)
3300 color = "¥ë¥Ó¡¼¿§¤Ë";
3304 else if (r_ptr->level > p_ptr->lev - 5)
3310 else if (r_ptr->level > p_ptr->lev - 15)
3312 color = "¥Ô¥ó¥¯¿§¤Ë";
3323 o_ptr = choose_warning_item();
3326 object_desc(o_name, o_ptr, FALSE, 0);
3328 msg_format("%s¤Ï%s¸÷¤Ã¤¿¡£", o_name, color);
3330 msg_format("%s glows %s.", o_name, color);
3336 msg_format("s%¸÷¤ëʪ¤¬Æ¬¤ËÉ⤫¤ó¤À¡£", color);
3338 msg_format("An %s image forms in your mind.");
3344 if (is_explosive_rune_grid(c_ptr))
3346 /* Break the ward */
3347 if (randint1(BREAK_MINOR_GLYPH) > r_ptr->level)
3349 /* Describe observable breakage */
3350 if (c_ptr->info & CAVE_MARK)
3353 msg_print("¥ë¡¼¥ó¤¬Çúȯ¤·¤¿¡ª");
3355 msg_print("The rune explodes!");
3358 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);
3364 msg_print("Çúȯ¤Î¥ë¡¼¥ó¤Ï²ò½ü¤µ¤ì¤¿¡£");
3366 msg_print("An explosive rune was disarmed.");
3370 /* Forget the rune */
3371 c_ptr->info &= ~(CAVE_MARK);
3373 /* Break the rune */
3374 c_ptr->info &= ~(CAVE_OBJECT);
3387 * improved version of scatter() for place monster
3390 #define MON_SCAT_MAXD 10
3392 static bool mon_scatter(int *yp, int *xp, int y, int x, int max_dist)
3394 int place_x[MON_SCAT_MAXD];
3395 int place_y[MON_SCAT_MAXD];
3396 int num[MON_SCAT_MAXD];
3400 if (max_dist >= MON_SCAT_MAXD)
3403 for (i = 0; i < MON_SCAT_MAXD; i++)
3406 for (nx = x - max_dist; nx <= x + max_dist; nx++)
3407 for (ny = y - max_dist; ny <= y + max_dist; ny++)
3409 /* Ignore annoying locations */
3410 if (!in_bounds(ny, nx)) continue;
3412 /* Require "line of sight" */
3413 if (!los(y, x, ny, nx)) continue;
3415 /* Walls and Monsters block flow */
3416 if (!cave_empty_bold2(ny, nx)) continue;
3417 if (cave[ny][nx].m_idx) continue;
3418 if (player_bold(ny, nx)) continue;
3420 /* ... nor on the Pattern */
3421 if ((cave[ny][nx].feat >= FEAT_PATTERN_START) &&
3422 (cave[ny][nx].feat <= FEAT_PATTERN_XTRA2))
3425 i = distance(y, x, ny, nx);
3441 while (i < MON_SCAT_MAXD && 0 == num[i])
3443 if (i >= MON_SCAT_MAXD)
3454 * Maximum size of a group of monsters
3456 #define GROUP_MAX 32
3460 * Attempt to place a "group" of monsters around the given location
3462 static bool place_monster_group(int who, int y, int x, int r_idx, u32b mode)
3464 monster_race *r_ptr = &r_info[r_idx];
3467 int total = 0, extra = 0;
3471 byte hack_y[GROUP_MAX];
3472 byte hack_x[GROUP_MAX];
3475 /* Pick a group size */
3476 total = randint1(10);
3478 /* Hard monsters, small groups */
3479 if (r_ptr->level > dun_level)
3481 extra = r_ptr->level - dun_level;
3482 extra = 0 - randint1(extra);
3485 /* Easy monsters, large groups */
3486 else if (r_ptr->level < dun_level)
3488 extra = dun_level - r_ptr->level;
3489 extra = randint1(extra);
3492 /* Hack -- limit group reduction */
3493 if (extra > 9) extra = 9;
3495 /* Modify the group size */
3499 if (total < 1) total = 1;
3502 if (total > GROUP_MAX) total = GROUP_MAX;
3505 /* Save the rating */
3508 /* Start on the monster */
3513 /* Puddle monsters, breadth first, up to total */
3514 for (n = 0; (n < hack_n) && (hack_n < total); n++)
3516 /* Grab the location */
3520 /* Check each direction, up to total */
3521 for (i = 0; (i < 8) && (hack_n < total); i++)
3525 scatter(&my, &mx, hy, hx, 4, 0);
3527 /* Walls and Monsters block flow */
3528 if (!cave_empty_bold2(my, mx)) continue;
3530 /* Attempt to place another monster */
3531 if (place_monster_one(who, my, mx, r_idx, mode))
3533 /* Add it to the "hack" set */
3534 hack_y[hack_n] = my;
3535 hack_x[hack_n] = mx;
3541 /* Hack -- restore the rating */
3551 * Hack -- help pick an escort type
3553 static int place_monster_idx = 0;
3554 static int place_monster_m_idx = 0;
3557 * Hack -- help pick an escort type
3559 static bool place_monster_okay(int r_idx)
3561 monster_race *r_ptr = &r_info[place_monster_idx];
3562 monster_type *m_ptr = &m_list[place_monster_m_idx];
3564 monster_race *z_ptr = &r_info[r_idx];
3566 /* Hack - Escorts have to have the same dungeon flag */
3567 if (mon_hook_dungeon(place_monster_idx) != mon_hook_dungeon(r_idx)) return (FALSE);
3569 /* Require similar "race" */
3570 if (z_ptr->d_char != r_ptr->d_char) return (FALSE);
3572 /* Skip more advanced monsters */
3573 if (z_ptr->level > r_ptr->level) return (FALSE);
3575 /* Skip unique monsters */
3576 if (z_ptr->flags1 & RF1_UNIQUE) return (FALSE);
3578 /* Paranoia -- Skip identical monsters */
3579 if (place_monster_idx == r_idx) return (FALSE);
3581 /* Skip different alignment */
3582 if (monster_has_hostile_align(m_ptr, 0, 0, z_ptr)) return FALSE;
3584 if (r_ptr->flags7 & RF7_FRIENDLY)
3586 if (monster_has_hostile_align(NULL, 1, -1, z_ptr)) return FALSE;
3589 if ((r_ptr->flags7 & RF7_CHAMELEON) && !(z_ptr->flags7 & RF7_CHAMELEON))
3598 * Attempt to place a monster of the given race at the given location
3600 * Note that certain monsters are now marked as requiring "friends".
3601 * These monsters, if successfully placed, and if the "grp" parameter
3602 * is TRUE, will be surrounded by a "group" of identical monsters.
3604 * Note that certain monsters are now marked as requiring an "escort",
3605 * which is a collection of monsters with similar "race" but lower level.
3607 * Some monsters induce a fake "group" flag on their escorts.
3609 * Note the "bizarre" use of non-recursion to prevent annoying output
3610 * when running a code profiler.
3612 * Note the use of the new "monster allocation table" code to restrict
3613 * the "get_mon_num()" function to "legal" escort types.
3615 bool place_monster_aux(int who, int y, int x, int r_idx, u32b mode)
3618 monster_race *r_ptr = &r_info[r_idx];
3620 if (one_in_(333) && !(mode & PM_NO_KAGE) && !(mode & PM_FORCE_PET))
3625 /* Place one monster, or fail */
3626 if (!place_monster_one(who, y, x, r_idx, mode)) return (FALSE);
3629 /* Require the "group" flag */
3630 if (!(mode & PM_ALLOW_GROUP)) return (TRUE);
3632 place_monster_m_idx = hack_m_idx_ii;
3634 /* Friends for certain monsters */
3635 if (r_ptr->flags1 & (RF1_FRIENDS))
3637 /* Attempt to place a group */
3638 (void)place_monster_group(who, y, x, r_idx, mode);
3642 /* Escorts for certain monsters */
3643 if (r_ptr->flags1 & (RF1_ESCORT))
3645 /* Set the escort index */
3646 place_monster_idx = r_idx;
3648 /* Try to place several "escorts" */
3649 for (i = 0; i < 32; i++)
3651 int nx, ny, z, d = 3;
3653 /* Pick a location */
3654 scatter(&ny, &nx, y, x, d, 0);
3656 /* Require empty grids */
3657 if (!cave_empty_bold2(ny, nx)) continue;
3659 /* Prepare allocation table */
3660 get_mon_num_prep(place_monster_okay, get_monster_hook2(ny, nx));
3662 /* Pick a random race */
3663 z = get_mon_num(r_ptr->level);
3665 /* Handle failure */
3668 /* Place a single escort */
3669 (void)place_monster_one(place_monster_m_idx, ny, nx, z, mode);
3671 /* Place a "group" of escorts if needed */
3672 if ((r_info[z].flags1 & RF1_FRIENDS) ||
3673 (r_ptr->flags1 & RF1_ESCORTS))
3675 /* Place a group of monsters */
3676 (void)place_monster_group(place_monster_m_idx, ny, nx, z, mode);
3687 * Hack -- attempt to place a monster at the given location
3689 * Attempt to find a monster appropriate to the "monster_level"
3691 bool place_monster(int y, int x, u32b mode)
3695 /* Prepare allocation table */
3696 get_mon_num_prep(get_monster_hook(), get_monster_hook2(y, x));
3698 /* Pick a monster */
3699 r_idx = get_mon_num(monster_level);
3701 /* Handle failure */
3702 if (!r_idx) return (FALSE);
3704 /* Attempt to place the monster */
3705 if (place_monster_aux(0, y, x, r_idx, mode)) return (TRUE);
3712 #ifdef MONSTER_HORDES
3714 bool alloc_horde(int y, int x)
3716 monster_race *r_ptr = NULL;
3719 int attempts = 1000;
3723 /* Prepare allocation table */
3724 get_mon_num_prep(get_monster_hook(), get_monster_hook2(y, x));
3728 /* Pick a monster */
3729 r_idx = get_mon_num(monster_level);
3731 /* Handle failure */
3732 if (!r_idx) return (FALSE);
3734 r_ptr = &r_info[r_idx];
3736 if (r_ptr->flags1 & RF1_UNIQUE) continue;
3738 if (r_idx == MON_HAGURE) continue;
3741 if (attempts < 1) return FALSE;
3747 /* Attempt to place the monster */
3748 if (place_monster_aux(0, y, x, r_idx, 0L)) break;
3751 if (attempts < 1) return FALSE;
3753 m_idx = cave[y][x].m_idx;
3755 if (m_list[m_idx].mflag2 & MFLAG2_CHAMELEON) r_ptr = &r_info[m_list[m_idx].r_idx];
3756 summon_kin_type = r_ptr->d_char;
3758 for (attempts = randint1(10) + 5; attempts; attempts--)
3760 scatter(&cy, &cx, y, x, 5, 0);
3762 (void)summon_specific(m_idx, cy, cx, dun_level + 5, SUMMON_KIN, PM_ALLOW_GROUP);
3771 #endif /* MONSTER_HORDES */
3777 bool alloc_guardian(void)
3779 int guardian = d_info[dungeon_type].final_guardian;
3781 if (guardian && (d_info[dungeon_type].maxdepth == dun_level) && (r_info[guardian].cur_num < r_info[guardian].max_num))
3787 /* Find a good position */
3790 /* Get a random spot */
3791 oy = randint1(cur_hgt - 4) + 2;
3792 ox = randint1(cur_wid - 4) + 2;
3794 /* Is it a good spot ? */
3795 if (cave_empty_bold2(oy, ox) && monster_can_cross_terrain(cave[oy][ox].feat, &r_info[guardian]))
3797 /* Place the guardian */
3798 if (place_monster_aux(0, oy, ox, guardian, (PM_ALLOW_GROUP | PM_NO_KAGE | PM_NO_PET))) return TRUE;
3811 * Attempt to allocate a random monster in the dungeon.
3813 * Place the monster at least "dis" distance from the player.
3815 * Use "slp" to choose the initial "sleep" status
3817 * Use "monster_level" for the monster level
3819 bool alloc_monster(int dis, u32b mode)
3822 int attempts_left = 10000;
3824 /* Put the Guardian */
3825 if (alloc_guardian()) return TRUE;
3827 /* Find a legal, distant, unoccupied, space */
3828 while (attempts_left--)
3830 /* Pick a location */
3831 y = randint0(cur_hgt);
3832 x = randint0(cur_wid);
3834 /* Require empty floor grid (was "naked") */
3835 if (dun_level || (wilderness[p_ptr->wilderness_y][p_ptr->wilderness_x].terrain != TERRAIN_MOUNTAIN))
3837 if (!cave_empty_bold2(y, x)) continue;
3841 if (!cave_empty_bold2(y, x) && (cave[y][x].feat != FEAT_MOUNTAIN)) continue;
3844 /* Accept far away grids */
3845 if (distance(y, x, py, px) > dis) break;
3850 if (cheat_xtra || cheat_hear)
3853 msg_print("·Ù¹ð¡ª¿·¤¿¤Ê¥â¥ó¥¹¥¿¡¼¤òÇÛÃ֤Ǥ¤Þ¤»¤ó¡£¾®¤µ¤¤³¬¤Ç¤¹¤«¡©");
3855 msg_print("Warning! Could not allocate a new monster. Small level?");
3864 #ifdef MONSTER_HORDES
3865 if (randint1(5000) <= dun_level)
3867 if (alloc_horde(y, x))
3870 if (cheat_hear) msg_format("¥â¥ó¥¹¥¿¡¼¤ÎÂç·²(%c)", summon_kin_type);
3872 if (cheat_hear) msg_format("Monster horde (%c).", summon_kin_type);
3880 #endif /* MONSTER_HORDES */
3882 /* Attempt to place the monster, allow groups */
3883 if (place_monster(y, x, (mode | PM_ALLOW_GROUP))) return (TRUE);
3885 #ifdef MONSTER_HORDES
3887 #endif /* MONSTER_HORDES */
3897 * Hack -- help decide if a monster race is "okay" to summon
3899 static bool summon_specific_okay(int r_idx)
3901 monster_race *r_ptr = &r_info[r_idx];
3903 /* Hack - Only summon dungeon monsters */
3904 if (!mon_hook_dungeon(r_idx)) return (FALSE);
3906 /* Hack -- identify the summoning monster */
3907 if (summon_specific_who > 0)
3909 monster_type *m_ptr = &m_list[summon_specific_who];
3911 /* Do not summon enemies */
3913 /* Friendly vs. opposite aligned normal or pet */
3914 if (monster_has_hostile_align(m_ptr, 0, 0, r_ptr)) return FALSE;
3916 /* Hostile vs. non-hostile */
3917 if (is_hostile(m_ptr) != summon_specific_hostile) return FALSE;
3919 /* Use the player's alignment */
3920 else if (summon_specific_who < 0)
3922 /* Do not summon enemies of the pets */
3923 if (monster_has_hostile_align(NULL, 10, -10, r_ptr))
3925 if (!one_in_(ABS(p_ptr->align) / 2 + 1)) return FALSE;
3929 /* Hack -- no specific type specified */
3930 if (!summon_specific_type) return (TRUE);
3932 if (!summon_unique_okay && ((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags7 & RF7_NAZGUL))) return FALSE;
3934 if ((summon_specific_who < 0) &&
3935 ((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags7 & RF7_NAZGUL)) &&
3936 monster_has_hostile_align(NULL, 10, -10, r_ptr))
3939 if ((r_ptr->flags7 & RF7_CHAMELEON) && (d_info[dungeon_type].flags1 & DF1_CHAMELEON)) return TRUE;
3941 return (summon_specific_aux(r_idx));
3946 * Place a monster (of the specified "type") near the given
3947 * location. Return TRUE if a monster was actually summoned.
3949 * We will attempt to place the monster up to 10 times before giving up.
3951 * Note: SUMMON_UNIQUE and SUMMON_AMBERITES will summon Unique's
3952 * Note: SUMMON_HI_UNDEAD and SUMMON_HI_DRAGON may summon Unique's
3953 * Note: None of the other summon codes will ever summon Unique's.
3955 * This function has been changed. We now take the "monster level"
3956 * of the summoning monster as a parameter, and use that, along with
3957 * the current dungeon level, to help determine the level of the
3958 * desired monster. Note that this is an upper bound, and also
3959 * tends to "prefer" monsters of that level. Currently, we use
3960 * the average of the dungeon and monster levels, and then add
3961 * five to allow slight increases in monster power.
3963 * Note that we use the new "monster allocation table" creation code
3964 * to restrict the "get_mon_num()" function to the set of "legal"
3965 * monsters, making this function much faster and more reliable.
3967 * Note that this function may not succeed, though this is very rare.
3969 bool summon_specific(int who, int y1, int x1, int lev, int type, u32b mode)
3973 if (p_ptr->inside_arena) return (FALSE);
3975 if (!mon_scatter(&y, &x, y1, x1, 2)) return FALSE;
3977 /* Save the summoner */
3978 summon_specific_who = who;
3980 /* Save the "summon" type */
3981 summon_specific_type = type;
3983 summon_unique_okay = (mode & PM_ALLOW_UNIQUE) ? TRUE : FALSE;
3985 /* Save the hostility */
3986 summon_specific_hostile = (!(mode & PM_FORCE_FRIENDLY) && !(is_friendly_idx(who)) && !(mode & PM_FORCE_PET));
3988 /* Prepare allocation table */
3989 get_mon_num_prep(summon_specific_okay, get_monster_hook2(y, x));
3991 /* Pick a monster, using the level calculation */
3992 r_idx = get_mon_num((dun_level + lev) / 2 + 5);
3994 /* Handle failure */
3997 summon_specific_type = 0;
4001 if ((type == SUMMON_BLUE_HORROR) || (type == SUMMON_DAWN)) mode |= PM_NO_KAGE;
4003 /* Attempt to place the monster (awake, allow groups) */
4004 if (!place_monster_aux(who, y, x, r_idx, mode))
4006 summon_specific_type = 0;
4010 summon_specific_type = 0;
4015 /* A "dangerous" function, creates a pet of the specified type */
4016 bool summon_named_creature (int who, int oy, int ox, int r_idx, u32b mode)
4021 /* if (!r_idx) return; */
4023 /* Prevent illegal monsters */
4024 if (r_idx >= max_r_idx) return FALSE;
4026 if (p_ptr->inside_arena) return FALSE;
4028 if (!mon_scatter(&y, &x, oy, ox, 2)) return FALSE;
4030 /* Place it (allow groups) */
4031 return place_monster_aux(who, y, x, r_idx, (mode | PM_NO_KAGE));
4036 * Let the given monster attempt to reproduce.
4038 * Note that "reproduction" REQUIRES empty space.
4040 bool multiply_monster(int m_idx, bool clone, u32b mode)
4042 monster_type *m_ptr = &m_list[m_idx];
4046 if (!mon_scatter(&y, &x, m_ptr->fy, m_ptr->fx, 1))
4049 if (m_ptr->mflag2 & MFLAG2_NOPET) mode |= PM_NO_PET;
4051 /* Create a new monster (awake, no groups) */
4052 if (!place_monster_aux(m_idx, y, x, m_ptr->r_idx, (mode | PM_NO_KAGE)))
4055 /* Hack -- Transfer "clone" flag */
4056 if (clone || (m_ptr->smart & SM_CLONED))
4058 m_list[hack_m_idx_ii].smart |= SM_CLONED;
4059 m_list[hack_m_idx_ii].mflag2 |= MFLAG2_NOPET;
4062 /* Hack -- Shadower spawns Shadower */
4063 if (m_ptr->mflag2 & MFLAG2_KAGE) m_list[hack_m_idx_ii].mflag2 |= MFLAG2_KAGE;
4065 /* Hack -- Appearance transfer */
4066 if (!is_original_ap(m_ptr)) m_list[hack_m_idx_ii].ap_r_idx = m_ptr->ap_r_idx;
4076 * Dump a message describing a monster's reaction to damage
4078 * Technically should attempt to treat "Beholder"'s as jelly's
4080 void message_pain(int m_idx, int dam)
4082 long oldhp, newhp, tmp;
4085 monster_type *m_ptr = &m_list[m_idx];
4086 monster_race *r_ptr = &r_info[m_ptr->r_idx];
4091 /* Get the monster name */
4092 monster_desc(m_name, m_ptr, 0);
4094 /* Notice non-damage */
4098 msg_format("%^s¤Ï¥À¥á¡¼¥¸¤ò¼õ¤±¤Æ¤¤¤Ê¤¤¡£", m_name);
4100 msg_format("%^s is unharmed.", m_name);
4106 /* Note -- subtle fix -CFT */
4107 newhp = (long)(m_ptr->hp);
4108 oldhp = newhp + (long)(dam);
4109 tmp = (newhp * 100L) / oldhp;
4110 percentage = (int)(tmp);
4113 /* Mushrooms, Eyes, Jellies, Molds, Vortices, Worms, Quylthulgs */
4114 if (strchr(",ejmvwQ", r_ptr->d_char))
4117 if (percentage > 95)
4118 msg_format("%^s¤Ï¤Û¤È¤ó¤Éµ¤¤Ë¤È¤á¤Æ¤¤¤Ê¤¤¡£", m_name);
4119 else if (percentage > 75)
4120 msg_format("%^s¤Ï¤·¤ê¹þ¤ß¤·¤¿¡£", m_name);
4121 else if (percentage > 50)
4122 msg_format("%^s¤Ï½Ì¤³¤Þ¤Ã¤¿¡£", m_name);
4123 else if (percentage > 35)
4124 msg_format("%^s¤ÏÄˤߤ˿̤¨¤¿¡£", m_name);
4125 else if (percentage > 20)
4126 msg_format("%^s¤Ï¿È¤â¤À¤¨¤·¤¿¡£", m_name);
4127 else if (percentage > 10)
4128 msg_format("%^s¤Ï¶ìÄˤǿȤâ¤À¤¨¤·¤¿¡£", m_name);
4130 msg_format("%^s¤Ï¤°¤Ë¤ã¤°¤Ë¤ã¤ÈáÛÚ»¤·¤¿¡£", m_name);
4132 if (percentage > 95)
4133 msg_format("%^s barely notices.", m_name);
4134 else if (percentage > 75)
4135 msg_format("%^s flinches.", m_name);
4136 else if (percentage > 50)
4137 msg_format("%^s squelches.", m_name);
4138 else if (percentage > 35)
4139 msg_format("%^s quivers in pain.", m_name);
4140 else if (percentage > 20)
4141 msg_format("%^s writhes about.", m_name);
4142 else if (percentage > 10)
4143 msg_format("%^s writhes in agony.", m_name);
4145 msg_format("%^s jerks limply.", m_name);
4152 else if (strchr("l", r_ptr->d_char))
4154 if (percentage > 95)
4156 msg_format("%^s¤Ï¤Û¤È¤ó¤Éµ¤¤Ë¤È¤á¤Æ¤¤¤Ê¤¤¡£", m_name);
4158 msg_format("%^s barely notices.", m_name);
4160 else if (percentage > 75)
4162 msg_format("%^s¤Ï¤·¤ê¹þ¤ß¤·¤¿¡£", m_name);
4164 msg_format("%^s flinches.", m_name);
4166 else if (percentage > 50)
4168 msg_format("%^s¤Ïí´í°¤·¤¿¡£", m_name);
4170 msg_format("%^s hesitates.", m_name);
4172 else if (percentage > 35)
4174 msg_format("%^s¤ÏÄˤߤ˿̤¨¤¿¡£", m_name);
4176 msg_format("%^s quivers in pain.", m_name);
4178 else if (percentage > 20)
4180 msg_format("%^s¤Ï¿È¤â¤À¤¨¤·¤¿¡£", m_name);
4182 msg_format("%^s writhes about.", m_name);
4184 else if (percentage > 10)
4186 msg_format("%^s¤Ï¶ìÄˤǿȤâ¤À¤¨¤·¤¿¡£", m_name);
4188 msg_format("%^s writhes in agony.", m_name);
4192 msg_format("%^s¤Ï¤°¤Ë¤ã¤°¤Ë¤ã¤ÈáÛÚ»¤·¤¿¡£", m_name);
4194 msg_format("%^s jerks limply.", m_name);
4199 /* Golems, Walls, Doors, Stairs */
4200 else if (strchr("g#+<>", r_ptr->d_char))
4202 if (percentage > 95)
4204 msg_format("%s¤Ï¹¶·â¤òµ¤¤Ë¤È¤á¤Æ¤¤¤Ê¤¤¡£", m_name);
4206 msg_format("%^s ignores the attack.", m_name);
4208 else if (percentage > 75)
4210 msg_format("%s¤Ï¹¶·â¤Ë¸ª¤ò¤¹¤¯¤á¤¿¡£", m_name);
4212 msg_format("%^s shrugs off the attack.", m_name);
4214 else if (percentage > 50)
4216 msg_format("%^s¤ÏÍëÌĤΤ褦¤ËËʤ¨¤¿¡£", m_name);
4218 msg_format("%^s roars thunderously.", m_name);
4220 else if (percentage > 35)
4222 msg_format("%^s¤Ï¶ì¤·¤²¤ËËʤ¨¤¿¡£", m_name);
4224 msg_format("%^s rumbles.", m_name);
4226 else if (percentage > 20)
4228 msg_format("%^s¤Ï¤¦¤á¤¤¤¿¡£", m_name);
4230 msg_format("%^s grunts.", m_name);
4232 else if (percentage > 10)
4234 msg_format("%^s¤Ïí´í°¤·¤¿¡£", m_name);
4236 msg_format("%^s hesitates.", m_name);
4240 msg_format("%^s¤Ï¤¯¤·¤ã¤¯¤·¤ã¤Ë¤Ê¤Ã¤¿¡£", m_name);
4242 msg_format("%^s crumples.", m_name);
4247 /* Snakes, Hydrae, Reptiles, Mimics */
4248 else if (strchr("JMR", r_ptr->d_char) || !isalpha(r_ptr->d_char))
4250 if (percentage > 95)
4252 msg_format("%^s¤Ï¤Û¤È¤ó¤Éµ¤¤Ë¤È¤á¤Æ¤¤¤Ê¤¤¡£", m_name);
4254 msg_format("%^s barely notices.", m_name);
4256 else if (percentage > 75)
4258 msg_format("%^s¤Ï¥·¡¼¥Ã¤ÈÌĤ¤¤¿¡£", m_name);
4260 msg_format("%^s hisses.", m_name);
4262 else if (percentage > 50)
4264 msg_format("%^s¤ÏÅܤäÆƬ¤ò¾å¤²¤¿¡£", m_name);
4266 msg_format("%^s rears up in anger.", m_name);
4268 else if (percentage > 35)
4270 msg_format("%^s¤ÏÌÔÁ³¤È°Ò³Å¤·¤¿¡£", m_name);
4272 msg_format("%^s hisses furiously.", m_name);
4274 else if (percentage > 20)
4276 msg_format("%^s¤Ï¿È¤â¤À¤¨¤·¤¿¡£", m_name);
4278 msg_format("%^s writhes about.", m_name);
4280 else if (percentage > 10)
4282 msg_format("%^s¤Ï¶ìÄˤǿȤâ¤À¤¨¤·¤¿¡£", m_name);
4284 msg_format("%^s writhes in agony.", m_name);
4288 msg_format("%^s¤Ï¤°¤Ë¤ã¤°¤Ë¤ã¤ÈáÛÚ»¤·¤¿¡£", m_name);
4290 msg_format("%^s jerks limply.", m_name);
4296 else if (strchr("f", r_ptr->d_char))
4298 if (percentage > 95)
4300 msg_format("%s¤Ï¹¶·â¤Ë¸ª¤ò¤¹¤¯¤á¤¿¡£", m_name);
4302 msg_format("%^s shrugs off the attack.", m_name);
4304 else if (percentage > 75)
4306 msg_format("%^s¤ÏËʤ¨¤¿¡£", m_name);
4308 msg_format("%^s roars.", m_name);
4310 else if (percentage > 50)
4312 msg_format("%^s¤ÏÅܤäÆËʤ¨¤¿¡£", m_name);
4314 msg_format("%^s growls angrily.", m_name);
4316 else if (percentage > 35)
4318 msg_format("%^s¤ÏÄˤߤǥ·¡¼¥Ã¤ÈÌĤ¤¤¿¡£", m_name);
4320 msg_format("%^s hisses with pain.", m_name);
4322 else if (percentage > 20)
4324 msg_format("%^s¤ÏÄˤߤǼ塹¤·¤¯ÌĤ¤¤¿¡£", m_name);
4326 msg_format("%^s mewls in pain.", m_name);
4328 else if (percentage > 10)
4330 msg_format("%^s¤Ï¶ìÄˤˤ¦¤á¤¤¤¿¡£", m_name);
4332 msg_format("%^s hisses in agony.", m_name);
4336 msg_format("%s¤Ï°¥¤ì¤ÊÌĤÀ¼¤ò½Ð¤·¤¿¡£", m_name);
4338 msg_format("%^s mewls pitifully.", m_name);
4343 /* Ants, Centipedes, Flies, Insects, Beetles, Spiders */
4344 else if (strchr("acFIKS", r_ptr->d_char))
4346 if (percentage > 95)
4348 msg_format("%s¤Ï¹¶·â¤òµ¤¤Ë¤È¤á¤Æ¤¤¤Ê¤¤¡£", m_name);
4350 msg_format("%^s ignores the attack.", m_name);
4352 else if (percentage > 75)
4354 msg_format("%^s¤Ï¥¡¼¥¡¼ÌĤ¤¤¿¡£", m_name);
4356 msg_format("%^s chitters.", m_name);
4359 else if (percentage > 50)
4361 msg_format("%^s¤Ï¥è¥í¥è¥íƨ¤²²ó¤Ã¤¿¡£", m_name);
4363 msg_format("%^s scuttles about.", m_name);
4366 else if (percentage > 35)
4368 msg_format("%^s¤Ï¤¦¤ë¤µ¤¯ÌĤ¤¤¿¡£", m_name);
4370 msg_format("%^s twitters.", m_name);
4373 else if (percentage > 20)
4375 msg_format("%^s¤ÏÄˤߤËáÛÚ»¤·¤¿¡£", m_name);
4377 msg_format("%^s jerks in pain.", m_name);
4380 else if (percentage > 10)
4382 msg_format("%^s¤Ï¶ìÄˤÇáÛÚ»¤·¤¿¡£", m_name);
4384 msg_format("%^s jerks in agony.", m_name);
4389 msg_format("%^s¤Ï¥Ô¥¯¥Ô¥¯¤Ò¤¤Ä¤Ã¤¿¡£", m_name);
4391 msg_format("%^s twitches.", m_name);
4398 else if (strchr("B", r_ptr->d_char))
4400 if (percentage > 95)
4402 msg_format("%^s¤Ï¤µ¤¨¤º¤Ã¤¿¡£", m_name);
4404 msg_format("%^s chirps.", m_name);
4407 else if (percentage > 75)
4409 msg_format("%^s¤Ï¥Ô¡¼¥Ô¡¼ÌĤ¤¤¿¡£", m_name);
4411 msg_format("%^s twitters.", m_name);
4414 else if (percentage > 50)
4416 msg_format("%^s¤Ï¥®¥ã¡¼¥®¥ã¡¼ÌĤ¤¤¿¡£", m_name);
4418 msg_format("%^s squawks.", m_name);
4421 else if (percentage > 35)
4423 msg_format("%^s¤Ï¥®¥ã¡¼¥®¥ã¡¼ÌĤ¤ï¤á¤¤¤¿¡£", m_name);
4425 msg_format("%^s chatters.", m_name);
4428 else if (percentage > 20)
4430 msg_format("%^s¤Ï¶ì¤·¤ó¤À¡£", m_name);
4432 msg_format("%^s jeers.", m_name);
4435 else if (percentage > 10)
4437 msg_format("%^s¤Ï¤Î¤¿¤¦¤Á²ó¤Ã¤¿¡£", m_name);
4439 msg_format("%^s flutters about.", m_name);
4444 msg_format("%^s¤Ï¥¡¼¥¡¼¤ÈÌĤ¶«¤ó¤À¡£", m_name);
4446 msg_format("%^s squeaks.", m_name);
4452 /* Dragons, Demons, High Undead */
4453 else if (strchr("duDLUW", r_ptr->d_char))
4455 if (percentage > 95)
4457 msg_format("%s¤Ï¹¶·â¤òµ¤¤Ë¤È¤á¤Æ¤¤¤Ê¤¤¡£", m_name);
4459 msg_format("%^s ignores the attack.", m_name);
4462 else if (percentage > 75)
4464 msg_format("%^s¤Ï¤·¤ê¹þ¤ß¤·¤¿¡£", m_name);
4466 msg_format("%^s flinches.", m_name);
4469 else if (percentage > 50)
4471 msg_format("%^s¤ÏÄˤߤǥ·¡¼¥Ã¤ÈÌĤ¤¤¿¡£", m_name);
4473 msg_format("%^s hisses in pain.", m_name);
4476 else if (percentage > 35)
4478 msg_format("%^s¤ÏÄˤߤǤ¦¤Ê¤Ã¤¿¡£", m_name);
4480 msg_format("%^s snarls with pain.", m_name);
4483 else if (percentage > 20)
4485 msg_format("%^s¤ÏÄˤߤËËʤ¨¤¿¡£", m_name);
4487 msg_format("%^s roars with pain.", m_name);
4490 else if (percentage > 10)
4492 msg_format("%^s¤Ï¶ì¤·¤²¤Ë¶«¤ó¤À¡£", m_name);
4494 msg_format("%^s gasps.", m_name);
4499 msg_format("%^s¤Ï¼å¡¹¤·¤¯¤¦¤Ê¤Ã¤¿¡£", m_name);
4501 msg_format("%^s snarls feebly.", m_name);
4508 else if (strchr("s", r_ptr->d_char))
4510 if (percentage > 95)
4512 msg_format("%s¤Ï¹¶·â¤òµ¤¤Ë¤È¤á¤Æ¤¤¤Ê¤¤¡£", m_name);
4514 msg_format("%^s ignores the attack.", m_name);
4517 else if (percentage > 75)
4519 msg_format("%s¤Ï¹¶·â¤Ë¸ª¤ò¤¹¤¯¤á¤¿¡£", m_name);
4521 msg_format("%^s shrugs off the attack.", m_name);
4524 else if (percentage > 50)
4526 msg_format("%^s¤Ï¥«¥¿¥«¥¿¤È¾Ð¤Ã¤¿¡£", m_name);
4528 msg_format("%^s rattles.", m_name);
4531 else if (percentage > 35)
4533 msg_format("%^s¤Ï¤è¤í¤á¤¤¤¿¡£", m_name);
4535 msg_format("%^s stumbles.", m_name);
4538 else if (percentage > 20)
4540 msg_format("%^s¤Ï¥«¥¿¥«¥¿¸À¤Ã¤¿¡£", m_name);
4542 msg_format("%^s rattles.", m_name);
4545 else if (percentage > 10)
4547 msg_format("%^s¤Ï¤è¤í¤á¤¤¤¿¡£", m_name);
4549 msg_format("%^s staggers.", m_name);
4554 msg_format("%^s¤Ï¥¬¥¿¥¬¥¿¸À¤Ã¤¿¡£", m_name);
4556 msg_format("%^s clatters.", m_name);
4563 else if (strchr("z", r_ptr->d_char))
4565 if (percentage > 95)
4567 msg_format("%s¤Ï¹¶·â¤òµ¤¤Ë¤È¤á¤Æ¤¤¤Ê¤¤¡£", m_name);
4569 msg_format("%^s ignores the attack.", m_name);
4572 else if (percentage > 75)
4574 msg_format("%s¤Ï¹¶·â¤Ë¸ª¤ò¤¹¤¯¤á¤¿¡£", m_name);
4576 msg_format("%^s shrugs off the attack.", m_name);
4579 else if (percentage > 50)
4581 msg_format("%^s¤Ï¤¦¤á¤¤¤¿¡£", m_name);
4583 msg_format("%^s groans.", m_name);
4586 else if (percentage > 35)
4588 msg_format("%s¤Ï¶ì¤·¤²¤Ë¤¦¤á¤¤¤¿¡£", m_name);
4590 msg_format("%^s moans.", m_name);
4593 else if (percentage > 20)
4595 msg_format("%^s¤Ïí´í°¤·¤¿¡£", m_name);
4597 msg_format("%^s hesitates.", m_name);
4600 else if (percentage > 10)
4602 msg_format("%^s¤Ï¤¦¤Ê¤Ã¤¿¡£", m_name);
4604 msg_format("%^s grunts.", m_name);
4609 msg_format("%^s¤Ï¤è¤í¤á¤¤¤¿¡£", m_name);
4611 msg_format("%^s staggers.", m_name);
4618 else if (strchr("G", r_ptr->d_char))
4621 if (percentage > 95)
4623 msg_format("%s¤Ï¹¶·â¤òµ¤¤Ë¤È¤á¤Æ¤¤¤Ê¤¤¡£", m_name);
4625 msg_format("%^s ignores the attack.", m_name);
4628 else if (percentage > 75)
4630 msg_format("%s¤Ï¹¶·â¤Ë¸ª¤ò¤¹¤¯¤á¤¿¡£", m_name);
4632 msg_format("%^s shrugs off the attack.", m_name);
4635 else if (percentage > 50)
4637 msg_format("%s¤Ï¤¦¤á¤¤¤¿¡£", m_name);
4639 msg_format("%^s moans.", m_name);
4642 else if (percentage > 35)
4644 msg_format("%^s¤Ïµã¤¤ï¤á¤¤¤¿¡£", m_name);
4646 msg_format("%^s wails.", m_name);
4649 else if (percentage > 20)
4651 msg_format("%^s¤ÏËʤ¨¤¿¡£", m_name);
4653 msg_format("%^s howls.", m_name);
4656 else if (percentage > 10)
4658 msg_format("%s¤Ï¼å¡¹¤·¤¯¤¦¤á¤¤¤¿¡£", m_name);
4660 msg_format("%^s moans softly.", m_name);
4665 msg_format("%^s¤Ï¤«¤¹¤«¤Ë¤¦¤á¤¤¤¿¡£", m_name);
4667 msg_format("%^s sighs.", m_name);
4673 /* Dogs and Hounds */
4674 else if (strchr("CZ", r_ptr->d_char))
4677 if (percentage > 95)
4678 msg_format("%^s¤Ï¹¶·â¤Ë¸ª¤ò¤¹¤¯¤á¤¿¡£", m_name);
4679 else if (percentage > 75)
4680 msg_format("%^s¤ÏÄˤߤǤ¦¤Ê¤Ã¤¿¡£", m_name);
4681 else if (percentage > 50)
4682 msg_format("%^s¤ÏÄˤߤǥ¥ã¥ó¥¥ã¥óËʤ¨¤¿¡£", m_name);
4683 else if (percentage > 35)
4684 msg_format("%^s¤ÏÄˤߤÇÌĤ¤ï¤á¤¤¤¿¡£", m_name);
4685 else if (percentage > 20)
4686 msg_format("%^s¤Ï¶ìÄˤΤ¢¤Þ¤êÌĤ¤ï¤á¤¤¤¿¡£", m_name);
4687 else if (percentage > 10)
4688 msg_format("%^s¤Ï¶ìÄˤǤâ¤À¤¨¶ì¤·¤ó¤À¡£", m_name);
4690 msg_format("%^s¤Ï¼å¡¹¤·¤¯Ëʤ¨¤¿¡£", m_name);
4692 if (percentage > 95)
4693 msg_format("%^s shrugs off the attack.", m_name);
4694 else if (percentage > 75)
4695 msg_format("%^s snarls with pain.", m_name);
4696 else if (percentage > 50)
4697 msg_format("%^s yelps in pain.", m_name);
4698 else if (percentage > 35)
4699 msg_format("%^s howls in pain.", m_name);
4700 else if (percentage > 20)
4701 msg_format("%^s howls in agony.", m_name);
4702 else if (percentage > 10)
4703 msg_format("%^s writhes in agony.", m_name);
4705 msg_format("%^s yelps feebly.", m_name);
4710 /* One type of monsters (ignore,squeal,shriek) */
4711 else if (strchr("Xbilqrt", r_ptr->d_char))
4714 if (percentage > 95)
4715 msg_format("%^s¤Ï¹¶·â¤òµ¤¤Ë¤È¤á¤Æ¤¤¤Ê¤¤¡£", m_name);
4716 else if (percentage > 75)
4717 msg_format("%^s¤ÏÄˤߤǤ¦¤Ê¤Ã¤¿¡£", m_name);
4718 else if (percentage > 50)
4719 msg_format("%^s¤ÏÄˤߤǶ«¤ó¤À¡£", m_name);
4720 else if (percentage > 35)
4721 msg_format("%^s¤ÏÄˤߤÇÀ䶫¤·¤¿¡£", m_name);
4722 else if (percentage > 20)
4723 msg_format("%^s¤Ï¶ìÄˤΤ¢¤Þ¤êÀ䶫¤·¤¿¡£", m_name);
4724 else if (percentage > 10)
4725 msg_format("%^s¤Ï¶ìÄˤǤâ¤À¤¨¶ì¤·¤ó¤À¡£", m_name);
4727 msg_format("%^s¤Ï¼å¡¹¤·¤¯¶«¤ó¤À¡£", m_name);
4729 if (percentage > 95)
4730 msg_format("%^s ignores the attack.", m_name);
4731 else if (percentage > 75)
4732 msg_format("%^s grunts with pain.", m_name);
4733 else if (percentage > 50)
4734 msg_format("%^s squeals in pain.", m_name);
4735 else if (percentage > 35)
4736 msg_format("%^s shrieks in pain.", m_name);
4737 else if (percentage > 20)
4738 msg_format("%^s shrieks in agony.", m_name);
4739 else if (percentage > 10)
4740 msg_format("%^s writhes in agony.", m_name);
4742 msg_format("%^s cries out feebly.", m_name);
4747 /* Another type of monsters (shrug,cry,scream) */
4751 if (percentage > 95)
4752 msg_format("%^s¤Ï¹¶·â¤Ë¸ª¤ò¤¹¤¯¤á¤¿¡£", m_name);
4753 else if (percentage > 75)
4754 msg_format("%^s¤ÏÄˤߤǤ¦¤Ê¤Ã¤¿¡£", m_name);
4755 else if (percentage > 50)
4756 msg_format("%^s¤ÏÄˤߤǶ«¤ó¤À¡£", m_name);
4757 else if (percentage > 35)
4758 msg_format("%^s¤ÏÄˤߤÇÀ䶫¤·¤¿¡£", m_name);
4759 else if (percentage > 20)
4760 msg_format("%^s¤Ï¶ìÄˤΤ¢¤Þ¤êÀ䶫¤·¤¿¡£", m_name);
4761 else if (percentage > 10)
4762 msg_format("%^s¤Ï¶ìÄˤǤâ¤À¤¨¶ì¤·¤ó¤À¡£", m_name);
4764 msg_format("%^s¤Ï¼å¡¹¤·¤¯¶«¤ó¤À¡£", m_name);
4766 if (percentage > 95)
4767 msg_format("%^s shrugs off the attack.", m_name);
4768 else if (percentage > 75)
4769 msg_format("%^s grunts with pain.", m_name);
4770 else if (percentage > 50)
4771 msg_format("%^s cries out in pain.", m_name);
4772 else if (percentage > 35)
4773 msg_format("%^s screams in pain.", m_name);
4774 else if (percentage > 20)
4775 msg_format("%^s screams in agony.", m_name);
4776 else if (percentage > 10)
4777 msg_format("%^s writhes in agony.", m_name);
4779 msg_format("%^s cries out feebly.", m_name);
4787 * Learn about an "observed" resistance.
4789 void update_smart_learn(int m_idx, int what)
4791 monster_type *m_ptr = &m_list[m_idx];
4793 monster_race *r_ptr = &r_info[m_ptr->r_idx];
4796 /* Not allowed to learn */
4797 if (!smart_learn) return;
4799 /* Too stupid to learn anything */
4800 if (r_ptr->flags2 & (RF2_STUPID)) return;
4802 /* Not intelligent, only learn sometimes */
4803 if (!(r_ptr->flags2 & (RF2_SMART)) && (randint0(100) < 50)) return;
4808 /* Analyze the knowledge */
4812 if (p_ptr->resist_acid) m_ptr->smart |= (SM_RES_ACID);
4813 if (IS_OPPOSE_ACID()) m_ptr->smart |= (SM_OPP_ACID);
4814 if (p_ptr->immune_acid) m_ptr->smart |= (SM_IMM_ACID);
4818 if (p_ptr->resist_elec) m_ptr->smart |= (SM_RES_ELEC);
4819 if (IS_OPPOSE_ELEC()) m_ptr->smart |= (SM_OPP_ELEC);
4820 if (p_ptr->immune_elec) m_ptr->smart |= (SM_IMM_ELEC);
4824 if (p_ptr->resist_fire) m_ptr->smart |= (SM_RES_FIRE);
4825 if (IS_OPPOSE_FIRE()) m_ptr->smart |= (SM_OPP_FIRE);
4826 if (p_ptr->immune_fire) m_ptr->smart |= (SM_IMM_FIRE);
4830 if (p_ptr->resist_cold) m_ptr->smart |= (SM_RES_COLD);
4831 if (IS_OPPOSE_COLD()) m_ptr->smart |= (SM_OPP_COLD);
4832 if (p_ptr->immune_cold) m_ptr->smart |= (SM_IMM_COLD);
4836 if (p_ptr->resist_pois) m_ptr->smart |= (SM_RES_POIS);
4837 if (IS_OPPOSE_POIS()) m_ptr->smart |= (SM_OPP_POIS);
4842 if (p_ptr->resist_neth) m_ptr->smart |= (SM_RES_NETH);
4846 if (p_ptr->resist_lite) m_ptr->smart |= (SM_RES_LITE);
4850 if (p_ptr->resist_dark) m_ptr->smart |= (SM_RES_DARK);
4854 if (p_ptr->resist_fear) m_ptr->smart |= (SM_RES_FEAR);
4858 if (p_ptr->resist_conf) m_ptr->smart |= (SM_RES_CONF);
4862 if (p_ptr->resist_chaos) m_ptr->smart |= (SM_RES_CHAOS);
4866 if (p_ptr->resist_disen) m_ptr->smart |= (SM_RES_DISEN);
4870 if (p_ptr->resist_blind) m_ptr->smart |= (SM_RES_BLIND);
4874 if (p_ptr->resist_nexus) m_ptr->smart |= (SM_RES_NEXUS);
4878 if (p_ptr->resist_sound) m_ptr->smart |= (SM_RES_SOUND);
4882 if (p_ptr->resist_shard) m_ptr->smart |= (SM_RES_SHARD);
4886 if (p_ptr->free_act) m_ptr->smart |= (SM_IMM_FREE);
4890 if (!p_ptr->msp) m_ptr->smart |= (SM_IMM_MANA);
4894 if (p_ptr->reflect) m_ptr-> smart |= (SM_IMM_REFLECT);
4901 * Place the player in the dungeon XXX XXX
4903 bool player_place(int y, int x)
4905 /* Paranoia XXX XXX */
4906 if (cave[y][x].m_idx != 0) return FALSE;
4908 /* Save player location */
4918 * Drop all items carried by a monster
4920 void monster_drop_carried_objects(monster_type *m_ptr)
4922 s16b this_o_idx, next_o_idx = 0;
4928 /* Drop objects being carried */
4929 for (this_o_idx = m_ptr->hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
4931 /* Acquire object */
4932 o_ptr = &o_list[this_o_idx];
4934 /* Acquire next object */
4935 next_o_idx = o_ptr->next_o_idx;
4937 /* Get local object */
4940 /* Copy the object */
4941 object_copy(q_ptr, o_ptr);
4943 /* Forget monster */
4944 q_ptr->held_m_idx = 0;
4946 /* Delete the object */
4947 delete_object_idx(this_o_idx);
4950 (void)drop_near(q_ptr, -1, m_ptr->fy, m_ptr->fx);
4953 /* Forget objects */
4954 m_ptr->hold_o_idx = 0;