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
18 cptr horror_desc[MAX_SAN_HORROR] =
72 cptr funny_desc[MAX_SAN_FUNNY] =
87 "¥Õ¥¡¥ó¥¿¥¹¥Æ¥£¥Ã¥¯¤Ê",
132 cptr funny_comments[MAX_SAN_COMMENT] =
153 * Set the target of counter attack
155 void set_target(monster_type *m_ptr, int y, int x)
163 * Reset the target of counter attack
165 void reset_target(monster_type *m_ptr)
167 set_target(m_ptr, 0, 0);
172 * Extract monster race pointer of a monster's true form
174 monster_race *real_r_ptr(monster_type *m_ptr)
176 monster_race *r_ptr = &r_info[m_ptr->r_idx];
178 /* Extract real race */
179 if (m_ptr->mflag2 & MFLAG2_CHAMELEON)
181 if (r_ptr->flags1 & RF1_UNIQUE)
182 return &r_info[MON_CHAMELEON_K];
184 return &r_info[MON_CHAMELEON];
194 * Delete a monster by index.
196 * When a monster is deleted, all of its objects are deleted.
198 void delete_monster_idx(int i)
202 monster_type *m_ptr = &m_list[i];
204 monster_race *r_ptr = &r_info[m_ptr->r_idx];
206 s16b this_o_idx, next_o_idx = 0;
214 /* Hack -- Reduce the racial counter */
215 real_r_ptr(m_ptr)->cur_num--;
217 /* Hack -- count the number of "reproducers" */
218 if (r_ptr->flags2 & (RF2_MULTIPLY)) num_repro--;
221 /* Hack -- remove target monster */
222 if (i == target_who) target_who = 0;
224 /* Hack -- remove tracked monster */
225 if (i == p_ptr->health_who) health_track(0);
227 if (pet_t_m_idx == i ) pet_t_m_idx = 0;
228 if (riding_t_m_idx == i) riding_t_m_idx = 0;
229 if (p_ptr->riding == i) p_ptr->riding = 0;
231 /* Monster is gone */
232 cave[y][x].m_idx = 0;
236 for (this_o_idx = m_ptr->hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
241 o_ptr = &o_list[this_o_idx];
243 /* Acquire next object */
244 next_o_idx = o_ptr->next_o_idx;
247 * o_ptr->held_m_idx is needed in delete_object_idx()
248 * to prevent calling lite_spot()
251 /* Delete the object */
252 delete_object_idx(this_o_idx);
256 /* Wipe the Monster */
257 (void)WIPE(m_ptr, monster_type);
265 /* Update some things */
266 if (r_ptr->flags7 & (RF7_LITE_MASK | RF7_DARK_MASK))
267 p_ptr->update |= (PU_MON_LITE);
272 * Delete the monster, if any, at a given location
274 void delete_monster(int y, int x)
279 if (!in_bounds(y, x)) return;
284 /* Delete the monster (if any) */
285 if (c_ptr->m_idx) delete_monster_idx(c_ptr->m_idx);
290 * Move an object from index i1 to index i2 in the object list
292 static void compact_monsters_aux(int i1, int i2)
300 s16b this_o_idx, next_o_idx = 0;
304 if (i1 == i2) return;
317 /* Update the cave */
320 /* Repair objects being carried by monster */
321 for (this_o_idx = m_ptr->hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
326 o_ptr = &o_list[this_o_idx];
328 /* Acquire next object */
329 next_o_idx = o_ptr->next_o_idx;
331 /* Reset monster pointer */
332 o_ptr->held_m_idx = i2;
335 /* Hack -- Update the target */
336 if (target_who == i1) target_who = i2;
338 /* Hack -- Update the target */
339 if (pet_t_m_idx == i1) pet_t_m_idx = i2;
340 if (riding_t_m_idx == i1) riding_t_m_idx = i2;
342 /* Hack -- Update the riding */
343 if (p_ptr->riding == i1) p_ptr->riding = i2;
345 /* Hack -- Update the health bar */
346 if (p_ptr->health_who == i1) health_track(i2);
348 /* Hack -- Update parent index */
351 for (i = 1; i < m_max; i++)
353 monster_type *m2_ptr = &m_list[i];
355 if (m2_ptr->parent_m_idx == i1)
356 m2_ptr->parent_m_idx = i2;
361 COPY(&m_list[i2], &m_list[i1], monster_type);
364 (void)WIPE(&m_list[i1], monster_type);
370 * Compact and Reorder the monster list
372 * This function can be very dangerous, use with caution!
374 * When actually "compacting" monsters, we base the saving throw
375 * on a combination of monster level, distance from player, and
376 * current "desperation".
378 * After "compacting" (if needed), we "reorder" the monsters into a more
379 * compact order, and we reset the allocation info, and the "live" array.
381 void compact_monsters(int size)
384 int cur_lev, cur_dis, chance;
386 /* Message (only if compacting) */
388 if (size) msg_print("¥â¥ó¥¹¥¿¡¼¾ðÊó¤ò°µ½Ì¤·¤Æ¤¤¤Þ¤¹...");
390 if (size) msg_print("Compacting monsters...");
394 /* Compact at least 'size' objects */
395 for (num = 0, cnt = 1; num < size; cnt++)
397 /* Get more vicious each iteration */
400 /* Get closer each iteration */
401 cur_dis = 5 * (20 - cnt);
403 /* Check all the monsters */
404 for (i = 1; i < m_max; i++)
406 monster_type *m_ptr = &m_list[i];
408 monster_race *r_ptr = &r_info[m_ptr->r_idx];
410 /* Paranoia -- skip "dead" monsters */
411 if (!m_ptr->r_idx) continue;
413 /* Hack -- High level monsters start out "immune" */
414 if (r_ptr->level > cur_lev) continue;
416 if (i == p_ptr->riding) continue;
418 /* Ignore nearby monsters */
419 if ((cur_dis > 0) && (m_ptr->cdis < cur_dis)) continue;
421 /* Saving throw chance */
424 /* Only compact "Quest" Monsters in emergencies */
425 if ((r_ptr->flags1 & (RF1_QUESTOR)) && (cnt < 1000)) chance = 100;
427 /* Try not to compact Unique Monsters */
428 if (r_ptr->flags1 & (RF1_UNIQUE)) chance = 100;
430 /* All monsters get a saving throw */
431 if (randint0(100) < chance) continue;
433 /* Delete the monster */
434 delete_monster_idx(i);
436 /* Count the monster */
442 /* Excise dead monsters (backwards!) */
443 for (i = m_max - 1; i >= 1; i--)
445 /* Get the i'th monster */
446 monster_type *m_ptr = &m_list[i];
448 /* Skip real monsters */
449 if (m_ptr->r_idx) continue;
451 /* Move last monster into open hole */
452 compact_monsters_aux(m_max - 1, i);
454 /* Compress "m_max" */
461 * Delete/Remove all the monsters when the player leaves the level
463 * This is an efficient method of simulating multiple calls to the
464 * "delete_monster()" function, with no visual effects.
466 void wipe_m_list(void)
470 /* Hack -- if Banor or Lupart dies, stay another dead */
471 if (!r_info[MON_BANORLUPART].max_num)
473 if (r_info[MON_BANOR].max_num)
475 r_info[MON_BANOR].max_num = 0;
476 r_info[MON_BANOR].r_pkills++;
477 if (r_info[MON_BANOR].r_tkills < MAX_SHORT) r_info[MON_BANOR].r_tkills++;
479 if (r_info[MON_LUPART].max_num)
481 r_info[MON_LUPART].max_num = 0;
482 r_info[MON_LUPART].r_pkills++;
483 if (r_info[MON_LUPART].r_tkills < MAX_SHORT) r_info[MON_LUPART].r_tkills++;
487 /* Delete all the monsters */
488 for (i = m_max - 1; i >= 1; i--)
490 monster_type *m_ptr = &m_list[i];
492 /* Skip dead monsters */
493 if (!m_ptr->r_idx) continue;
495 /* Monster is gone */
496 cave[m_ptr->fy][m_ptr->fx].m_idx = 0;
498 /* Wipe the Monster */
499 (void)WIPE(m_ptr, monster_type);
504 * Wiping racial counters of all monsters and incrementing of racial
505 * counters of monsters in party_mon[] is required to prevent multiple
506 * generation of unique monster who is the minion of player.
509 /* Hack -- Wipe the racial counter of all monster races */
510 for (i = 1; i < max_r_idx; i++) r_info[i].cur_num = 0;
518 /* Hack -- reset "reproducer" count */
521 /* Hack -- no more target */
526 /* Hack -- no more tracking */
532 * Acquires and returns the index of a "free" monster.
534 * This routine should almost never fail, but it *can* happen.
541 /* Normal allocation */
542 if (m_max < max_m_idx)
544 /* Access the next hole */
547 /* Expand the array */
553 /* Return the index */
558 /* Recycle dead monsters */
559 for (i = 1; i < m_max; i++)
563 /* Acquire monster */
566 /* Skip live monsters */
567 if (m_ptr->r_idx) continue;
572 /* Use this monster */
577 /* Warn the player (except during dungeon creation) */
579 if (character_dungeon) msg_print("¥â¥ó¥¹¥¿¡¼¤¬Â¿¤¹¤®¤ë¡ª");
581 if (character_dungeon) msg_print("Too many monsters!");
585 /* Try not to crash */
593 * Hack -- the "type" of the current "summon specific"
595 static int summon_specific_type = 0;
599 * Hack -- the index of the summoning monster
601 static int summon_specific_who = -1;
604 static bool summon_unique_okay = FALSE;
607 static bool summon_specific_aux(int r_idx)
609 monster_race *r_ptr = &r_info[r_idx];
612 /* Check our requirements */
613 switch (summon_specific_type)
617 okay = (r_ptr->d_char == 'a');
623 okay = (r_ptr->d_char == 'S');
629 okay = ((r_ptr->d_char == 'C') || (r_ptr->d_char == 'Z'));
635 okay = (r_ptr->d_char == 'M');
641 okay = (r_ptr->d_char == 'A' && ((r_ptr->flags3 & RF3_EVIL) || (r_ptr->flags3 & RF3_GOOD)));
647 okay = (r_ptr->flags3 & RF3_DEMON);
653 okay = (r_ptr->flags3 & RF3_UNDEAD);
659 okay = (r_ptr->flags3 & RF3_DRAGON);
663 case SUMMON_HI_UNDEAD:
665 okay = ((r_ptr->d_char == 'L') ||
666 (r_ptr->d_char == 'V') ||
667 (r_ptr->d_char == 'W'));
671 case SUMMON_HI_DRAGON:
673 okay = (r_ptr->d_char == 'D');
677 case SUMMON_HI_DEMON:
679 okay = (((r_ptr->d_char == 'U') ||
680 (r_ptr->d_char == 'H') ||
681 (r_ptr->d_char == 'B')) &&
682 (r_ptr->flags3 & RF3_DEMON)) ? TRUE : FALSE;
686 case SUMMON_AMBERITES:
688 okay = (r_ptr->flags3 & (RF3_AMBERITE)) ? TRUE : FALSE;
694 okay = (r_ptr->flags1 & (RF1_UNIQUE)) ? TRUE : FALSE;
698 case SUMMON_BIZARRE1:
700 okay = (r_ptr->d_char == 'm');
703 case SUMMON_BIZARRE2:
705 okay = (r_ptr->d_char == 'b');
708 case SUMMON_BIZARRE3:
710 okay = (r_ptr->d_char == 'Q');
714 case SUMMON_BIZARRE4:
716 okay = (r_ptr->d_char == 'v');
720 case SUMMON_BIZARRE5:
722 okay = (r_ptr->d_char == '$');
726 case SUMMON_BIZARRE6:
728 okay = ((r_ptr->d_char == '!') ||
729 (r_ptr->d_char == '?') ||
730 (r_ptr->d_char == '=') ||
731 (r_ptr->d_char == '$') ||
732 (r_ptr->d_char == '|'));
738 okay = (r_ptr->d_char == 'g');
744 okay = ((r_ptr->d_char == 'U') &&
745 (r_ptr->flags4 & RF4_ROCKET));
752 okay = ((r_ptr->d_char == summon_kin_type) && (r_idx != MON_HAGURE));
758 okay = (r_idx == MON_DAWN);
764 okay = (r_ptr->flags3 & (RF3_ANIMAL));
768 case SUMMON_ANIMAL_RANGER:
770 okay = ((r_ptr->flags3 & (RF3_ANIMAL)) &&
771 (strchr("abcflqrwBCHIJKMRS", r_ptr->d_char)) &&
772 !(r_ptr->flags3 & (RF3_DRAGON)) &&
773 !(r_ptr->flags3 & (RF3_EVIL)) &&
774 !(r_ptr->flags3 & (RF3_UNDEAD)) &&
775 !(r_ptr->flags3 & (RF3_DEMON)) &&
776 !(r_ptr->flags2 & (RF2_MULTIPLY)) &&
777 !(r_ptr->flags4 || r_ptr->flags5 || r_ptr->flags6));
781 case SUMMON_HI_DRAGON_LIVING:
783 okay = ((r_ptr->d_char == 'D') && monster_living(r_ptr));
789 okay = monster_living(r_ptr);
795 okay = (r_idx == MON_PHANTOM_B || r_idx == MON_PHANTOM_W);
799 case SUMMON_BLUE_HORROR:
801 okay = (r_idx == MON_BLUE_HORROR);
805 case SUMMON_ELEMENTAL:
807 okay = (r_ptr->d_char == 'E');
813 okay = (r_ptr->d_char == 'v');
819 okay = (r_ptr->d_char == 'H');
825 okay = (r_ptr->d_char == 'B');
829 case SUMMON_KAMIKAZE:
832 for (i = 0; i < 4; i++)
833 if (r_ptr->blow[i].method == RBM_EXPLODE) okay = TRUE;
837 case SUMMON_KAMIKAZE_LIVING:
841 for (i = 0; i < 4; i++)
842 if (r_ptr->blow[i].method == RBM_EXPLODE) okay = TRUE;
843 okay = (okay && monster_living(r_ptr));
849 okay = (r_idx == MON_MANES);
855 okay = (r_idx == MON_LOUSE);
859 case SUMMON_GUARDIANS:
861 okay = (r_ptr->flags7 & RF7_GUARDIAN);
867 okay = ((r_idx == MON_NOV_PALADIN) ||
868 (r_idx == MON_NOV_PALADIN_G) ||
869 (r_idx == MON_PALADIN) ||
870 (r_idx == MON_W_KNIGHT) ||
871 (r_idx == MON_ULTRA_PALADIN) ||
872 (r_idx == MON_KNI_TEMPLAR));
878 okay = (r_ptr->d_char == 'B' &&
879 (r_ptr->flags8 & RF8_WILD_MOUNTAIN) &&
880 (r_ptr->flags8 & RF8_WILD_ONLY));
884 case SUMMON_PIRANHAS:
886 okay = (r_idx == MON_PIRANHA);
890 case SUMMON_ARMAGE_GOOD:
892 okay = (r_ptr->d_char == 'A' && (r_ptr->flags3 & RF3_GOOD));
896 case SUMMON_ARMAGE_EVIL:
898 okay = ((r_ptr->flags3 & RF3_DEMON) ||
899 (r_ptr->d_char == 'A' && (r_ptr->flags3 & RF3_EVIL)));
905 /* Since okay is int, "return (okay);" is not correct. */
906 return (bool)(okay ? TRUE : FALSE);
910 static int chameleon_change_m_idx = 0;
914 * Some dungeon types restrict the possible monsters.
915 * Return TRUE is the monster is OK and FALSE otherwise
917 static bool restrict_monster_to_dungeon(int r_idx)
919 dungeon_info_type *d_ptr = &d_info[dungeon_type];
920 monster_race *r_ptr = &r_info[r_idx];
923 if (d_ptr->flags1 & DF1_CHAMELEON)
925 if (chameleon_change_m_idx) return TRUE;
927 if (d_ptr->flags1 & DF1_NO_MAGIC)
929 if (r_idx != MON_CHAMELEON &&
931 !(r_ptr->flags4 & RF4_NOMAGIC_MASK) &&
932 !(r_ptr->flags5 & RF5_NOMAGIC_MASK) &&
933 !(r_ptr->flags6 & RF6_NOMAGIC_MASK))
936 if (d_ptr->flags1 & DF1_NO_MELEE)
938 if (r_idx == MON_CHAMELEON) return TRUE;
939 if (!(r_ptr->flags4 & (RF4_BOLT_MASK | RF4_BEAM_MASK | RF4_BALL_MASK)) &&
940 !(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)) &&
941 !(r_ptr->flags6 & (RF6_BOLT_MASK | RF6_BEAM_MASK | RF6_BALL_MASK)))
944 if (d_ptr->flags1 & DF1_BEGINNER)
946 if (r_ptr->level > dun_level)
950 if (d_ptr->special_div >= 64) return TRUE;
951 if (summon_specific_type && !(d_ptr->flags1 & DF1_CHAMELEON)) return TRUE;
955 case DUNGEON_MODE_AND:
958 if ((d_ptr->mflags1 & r_ptr->flags1) != d_ptr->mflags1)
963 if ((d_ptr->mflags2 & r_ptr->flags2) != d_ptr->mflags2)
968 if ((d_ptr->mflags3 & r_ptr->flags3) != d_ptr->mflags3)
973 if ((d_ptr->mflags4 & r_ptr->flags4) != d_ptr->mflags4)
978 if ((d_ptr->mflags5 & r_ptr->flags5) != d_ptr->mflags5)
983 if ((d_ptr->mflags6 & r_ptr->flags6) != d_ptr->mflags6)
988 if ((d_ptr->mflags7 & r_ptr->flags7) != d_ptr->mflags7)
993 if ((d_ptr->mflags8 & r_ptr->flags8) != d_ptr->mflags8)
998 if ((d_ptr->mflags9 & r_ptr->flags9) != d_ptr->mflags9)
1003 if ((d_ptr->mflagsr & r_ptr->flagsr) != d_ptr->mflagsr)
1006 for (a = 0; a < 5; a++)
1007 if (d_ptr->r_char[a] && (d_ptr->r_char[a] != r_ptr->d_char)) return FALSE;
1011 case DUNGEON_MODE_NAND:
1014 if ((d_ptr->mflags1 & r_ptr->flags1) != d_ptr->mflags1)
1019 if ((d_ptr->mflags2 & r_ptr->flags2) != d_ptr->mflags2)
1024 if ((d_ptr->mflags3 & r_ptr->flags3) != d_ptr->mflags3)
1029 if ((d_ptr->mflags4 & r_ptr->flags4) != d_ptr->mflags4)
1034 if ((d_ptr->mflags5 & r_ptr->flags5) != d_ptr->mflags5)
1039 if ((d_ptr->mflags6 & r_ptr->flags6) != d_ptr->mflags6)
1044 if ((d_ptr->mflags7 & r_ptr->flags7) != d_ptr->mflags7)
1049 if ((d_ptr->mflags8 & r_ptr->flags8) != d_ptr->mflags8)
1054 if ((d_ptr->mflags9 & r_ptr->flags9) != d_ptr->mflags9)
1059 if ((d_ptr->mflagsr & r_ptr->flagsr) != d_ptr->mflagsr)
1062 for (a = 0; a < 5; a++)
1063 if (d_ptr->r_char[a] && (d_ptr->r_char[a] != r_ptr->d_char)) return TRUE;
1067 case DUNGEON_MODE_OR:
1068 if (r_ptr->flags1 & d_ptr->mflags1) return TRUE;
1069 if (r_ptr->flags2 & d_ptr->mflags2) return TRUE;
1070 if (r_ptr->flags3 & d_ptr->mflags3) return TRUE;
1071 if (r_ptr->flags4 & d_ptr->mflags4) return TRUE;
1072 if (r_ptr->flags5 & d_ptr->mflags5) return TRUE;
1073 if (r_ptr->flags6 & d_ptr->mflags6) return TRUE;
1074 if (r_ptr->flags7 & d_ptr->mflags7) return TRUE;
1075 if (r_ptr->flags8 & d_ptr->mflags8) return TRUE;
1076 if (r_ptr->flags9 & d_ptr->mflags9) return TRUE;
1077 if (r_ptr->flagsr & d_ptr->mflagsr) return TRUE;
1078 for (a = 0; a < 5; a++)
1079 if (d_ptr->r_char[a] == r_ptr->d_char) return TRUE;
1083 case DUNGEON_MODE_NOR:
1084 if (r_ptr->flags1 & d_ptr->mflags1) return FALSE;
1085 if (r_ptr->flags2 & d_ptr->mflags2) return FALSE;
1086 if (r_ptr->flags3 & d_ptr->mflags3) return FALSE;
1087 if (r_ptr->flags4 & d_ptr->mflags4) return FALSE;
1088 if (r_ptr->flags5 & d_ptr->mflags5) return FALSE;
1089 if (r_ptr->flags6 & d_ptr->mflags6) return FALSE;
1090 if (r_ptr->flags7 & d_ptr->mflags7) return FALSE;
1091 if (r_ptr->flags8 & d_ptr->mflags8) return FALSE;
1092 if (r_ptr->flags9 & d_ptr->mflags9) return FALSE;
1093 if (r_ptr->flagsr & d_ptr->mflagsr) return FALSE;
1094 for (a = 0; a < 5; a++)
1095 if (d_ptr->r_char[a] == r_ptr->d_char) return FALSE;
1104 * Apply a "monster restriction function" to the "monster allocation table"
1106 errr get_mon_num_prep(monster_hook_type monster_hook,
1107 monster_hook_type monster_hook2)
1111 /* Todo: Check the hooks for non-changes */
1113 /* Set the new hooks */
1114 get_mon_num_hook = monster_hook;
1115 get_mon_num2_hook = monster_hook2;
1117 /* Scan the allocation table */
1118 for (i = 0; i < alloc_race_size; i++)
1120 monster_race *r_ptr;
1123 alloc_entry *entry = &alloc_race_table[i];
1126 r_ptr = &r_info[entry->index];
1128 /* Skip monsters which don't pass the restriction */
1129 if ((get_mon_num_hook && !((*get_mon_num_hook)(entry->index))) ||
1130 (get_mon_num2_hook && !((*get_mon_num2_hook)(entry->index))))
1133 if (!p_ptr->inside_battle && !chameleon_change_m_idx &&
1134 summon_specific_type != SUMMON_GUARDIANS)
1136 /* Hack -- don't create questors */
1137 if (r_ptr->flags1 & RF1_QUESTOR)
1140 if (r_ptr->flags7 & RF7_GUARDIAN)
1143 /* Depth Monsters never appear out of depth */
1144 if ((r_ptr->flags1 & (RF1_FORCE_DEPTH)) &&
1145 (r_ptr->level > dun_level))
1149 /* Accept this monster */
1150 entry->prob2 = entry->prob1;
1152 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)
1154 int hoge = entry->prob2 * d_info[dungeon_type].special_div;
1155 entry->prob2 = hoge / 64;
1156 if (randint0(64) < (hoge & 0x3f)) entry->prob2++;
1165 static int mysqrt(int n)
1203 * Choose a monster race that seems "appropriate" to the given level
1205 * This function uses the "prob2" field of the "monster allocation table",
1206 * and various local information, to calculate the "prob3" field of the
1207 * same table, which is then used to choose an "appropriate" monster, in
1208 * a relatively efficient manner.
1210 * Note that "town" monsters will *only* be created in the town, and
1211 * "normal" monsters will *never* be created in the town, unless the
1212 * "level" is "modified", for example, by polymorph or summoning.
1214 * There is a small chance (1/50) of "boosting" the given depth by
1215 * a small amount (up to four levels), except in the town.
1217 * It is (slightly) more likely to acquire a monster of the given level
1218 * than one of a lower level. This is done by choosing several monsters
1219 * appropriate to the given level and keeping the "hardest" one.
1221 * Note that if no monsters are "appropriate", then this function will
1222 * fail, and return zero, but this should *almost* never happen.
1224 s16b get_mon_num(int level)
1232 monster_race *r_ptr;
1234 alloc_entry *table = alloc_race_table;
1236 int pls_kakuritu, pls_level;
1237 int hoge=mysqrt(level*10000L);
1239 if (level > MAX_DEPTH - 1) level = MAX_DEPTH - 1;
1241 if ((dungeon_turn > hoge*(TURNS_PER_TICK*500L)) && !level)
1243 pls_kakuritu = MAX(2, NASTY_MON-((dungeon_turn/(TURNS_PER_TICK*2500L)-hoge/10)));
1244 pls_level = MIN(8,3 + dungeon_turn/(TURNS_PER_TICK*20000L)-hoge/40);
1248 pls_kakuritu = NASTY_MON;
1252 if (d_info[dungeon_type].flags1 & DF1_MAZE)
1254 pls_kakuritu = MIN(pls_kakuritu/2, pls_kakuritu-10);
1255 if (pls_kakuritu < 2) pls_kakuritu = 2;
1260 /* Boost the level */
1261 if ((level > 0) && !p_ptr->inside_battle && !(d_info[dungeon_type].flags1 & DF1_BEGINNER))
1263 /* Nightmare mode allows more out-of depth monsters */
1264 if (ironman_nightmare && !randint0(pls_kakuritu))
1266 /* What a bizarre calculation */
1267 level = 1 + (level * MAX_DEPTH / randint1(MAX_DEPTH));
1271 /* Occasional "nasty" monster */
1272 if (!randint0(pls_kakuritu))
1274 /* Pick a level bonus */
1275 int d = MIN(5, level/10) + pls_level;
1277 /* Boost the level */
1281 /* Occasional "nasty" monster */
1282 if (!randint0(pls_kakuritu))
1284 /* Pick a level bonus */
1285 int d = MIN(5, level/10) + pls_level;
1287 /* Boost the level */
1297 /* Process probabilities */
1298 for (i = 0; i < alloc_race_size; i++)
1300 /* Monsters are sorted by depth */
1301 if (table[i].level > level) break;
1306 /* Access the "r_idx" of the chosen monster */
1307 r_idx = table[i].index;
1309 /* Access the actual race */
1310 r_ptr = &r_info[r_idx];
1312 if (!p_ptr->inside_battle && !chameleon_change_m_idx)
1314 /* Hack -- "unique" monsters must be "unique" */
1315 if (((r_ptr->flags1 & (RF1_UNIQUE)) ||
1316 (r_ptr->flags7 & (RF7_NAZGUL))) &&
1317 (r_ptr->cur_num >= r_ptr->max_num))
1322 if ((r_ptr->flags7 & (RF7_UNIQUE2)) &&
1323 (r_ptr->cur_num >= 1))
1328 if (r_idx == MON_BANORLUPART)
1330 if (r_info[MON_BANOR].cur_num > 0) continue;
1331 if (r_info[MON_LUPART].cur_num > 0) continue;
1336 table[i].prob3 = table[i].prob2;
1339 total += table[i].prob3;
1342 /* No legal monsters */
1343 if (total <= 0) return (0);
1346 /* Pick a monster */
1347 value = randint0(total);
1349 /* Find the monster */
1350 for (i = 0; i < alloc_race_size; i++)
1352 /* Found the entry */
1353 if (value < table[i].prob3) break;
1356 value = value - table[i].prob3;
1363 /* Try for a "harder" monster once (50%) or twice (10%) */
1369 /* Pick a monster */
1370 value = randint0(total);
1372 /* Find the monster */
1373 for (i = 0; i < alloc_race_size; i++)
1375 /* Found the entry */
1376 if (value < table[i].prob3) break;
1379 value = value - table[i].prob3;
1382 /* Keep the "best" one */
1383 if (table[i].level < table[j].level) i = j;
1386 /* Try for a "harder" monster twice (10%) */
1392 /* Pick a monster */
1393 value = randint0(total);
1395 /* Find the monster */
1396 for (i = 0; i < alloc_race_size; i++)
1398 /* Found the entry */
1399 if (value < table[i].prob3) break;
1402 value = value - table[i].prob3;
1405 /* Keep the "best" one */
1406 if (table[i].level < table[j].level) i = j;
1410 return (table[i].index);
1418 * Build a string describing a monster in some way.
1420 * We can correctly describe monsters based on their visibility.
1421 * We can force all monsters to be treated as visible or invisible.
1422 * We can build nominatives, objectives, possessives, or reflexives.
1423 * We can selectively pronominalize hidden, visible, or all monsters.
1424 * We can use definite or indefinite descriptions for hidden monsters.
1425 * We can use definite or indefinite descriptions for visible monsters.
1427 * Pronominalization involves the gender whenever possible and allowed,
1428 * so that by cleverly requesting pronominalization / visibility, you
1429 * can get messages like "You hit someone. She screams in agony!".
1431 * Reflexives are acquired by requesting Objective plus Possessive.
1433 * If no m_ptr arg is given (?), the monster is assumed to be hidden,
1434 * unless the "Assume Visible" mode is requested.
1436 * If no r_ptr arg is given, it is extracted from m_ptr and r_info
1437 * If neither m_ptr nor r_ptr is given, the monster is assumed to
1438 * be neuter, singular, and hidden (unless "Assume Visible" is set),
1439 * in which case you may be in trouble... :-)
1441 * I am assuming that no monster name is more than 70 characters long,
1442 * so that "char desc[80];" is sufficiently large for any result.
1445 * MD_OBJECTIVE --> Objective (or Reflexive)
1446 * MD_POSSESSIVE --> Possessive (or Reflexive)
1447 * MD_INDEF_HIDDEN --> Use indefinites for hidden monsters ("something")
1448 * MD_INDEF_VISIBLE --> Use indefinites for visible monsters ("a kobold")
1449 * MD_PRON_HIDDEN --> Pronominalize hidden monsters
1450 * MD_PRON_VISIBLE --> Pronominalize visible monsters
1451 * MD_ASSUME_HIDDEN --> Assume the monster is hidden
1452 * MD_ASSUME_VISIBLE --> Assume the monster is visible
1453 * MD_TRUE_NAME --> Chameleon's true name
1454 * MD_IGNORE_HALLU --> Ignore hallucination, and penetrate shape change
1457 * 0x00 --> Full nominative name ("the kobold") or "it"
1458 * MD_INDEF_HIDDEN --> Full nominative name ("the kobold") or "something"
1459 * MD_ASSUME_VISIBLE --> Genocide resistance name ("the kobold")
1460 * MD_ASSUME_VISIBLE | MD_INDEF_VISIBLE --> Killing name ("a kobold")
1461 * MD_PRON_VISIBLE | MD_POSSESSIVE
1462 * --> Possessive, genderized if visable ("his") or "its"
1463 * MD_PRON_VISIBLE | MD_POSSESSIVE | MD_OBJECTIVE
1464 * --> Reflexive, genderized if visable ("himself") or "itself"
1466 void monster_desc(char *desc, monster_type *m_ptr, int mode)
1469 monster_race *r_ptr;
1473 char silly_name[1024];
1477 r_ptr = &r_info[m_ptr->ap_r_idx];
1479 /* Mode of MD_TRUE_NAME will reveal Chameleon's true name */
1480 if (mode & MD_TRUE_NAME) name = (r_name + real_r_ptr(m_ptr)->name);
1481 else name = (r_name + r_ptr->name);
1483 /* Are we hallucinating? (Idea from Nethack...) */
1484 if (p_ptr->image && !(mode & MD_IGNORE_HALLU))
1489 if (!get_rnd_line("silly_j.txt", m_ptr->r_idx, silly_name))
1491 if (!get_rnd_line("silly.txt", m_ptr->r_idx, silly_name))
1499 monster_race *hallu_race;
1503 hallu_race = &r_info[randint1(max_r_idx - 1)];
1505 while (hallu_race->flags1 & RF1_UNIQUE);
1507 strcpy(silly_name, (r_name + hallu_race->name));
1510 /* Better not strcpy it, or we could corrupt r_info... */
1514 /* Can we "see" it (exists + forced, or visible + not unforced) */
1515 seen = (m_ptr && ((mode & MD_ASSUME_VISIBLE) || (!(mode & MD_ASSUME_HIDDEN) && m_ptr->ml)));
1517 /* Sexed Pronouns (seen and allowed, or unseen and allowed) */
1518 pron = (m_ptr && ((seen && (mode & MD_PRON_VISIBLE)) || (!seen && (mode & MD_PRON_HIDDEN))));
1521 /* First, try using pronouns, or describing hidden monsters */
1524 /* an encoding of the monster "sex" */
1527 /* Extract the gender (if applicable) */
1528 if (r_ptr->flags1 & (RF1_FEMALE)) kind = 0x20;
1529 else if (r_ptr->flags1 & (RF1_MALE)) kind = 0x10;
1531 /* Ignore the gender (if desired) */
1532 if (!m_ptr || !pron) kind = 0x00;
1535 /* Assume simple result */
1543 /* Brute force: split on the possibilities */
1544 switch (kind + (mode & (MD_INDEF_HIDDEN | MD_POSSESSIVE | MD_OBJECTIVE)))
1546 /* Neuter, or unknown */
1548 case 0x00: res = "²¿¤«"; break;
1549 case 0x00 + (MD_OBJECTIVE): res = "²¿¤«"; break;
1550 case 0x00 + (MD_POSSESSIVE): res = "²¿¤«¤Î"; break;
1551 case 0x00 + (MD_POSSESSIVE | MD_OBJECTIVE): res = "²¿¤«¼«¿È"; break;
1552 case 0x00 + (MD_INDEF_HIDDEN): res = "²¿¤«"; break;
1553 case 0x00 + (MD_INDEF_HIDDEN | MD_OBJECTIVE): res = "²¿¤«"; break;
1554 case 0x00 + (MD_INDEF_HIDDEN | MD_POSSESSIVE): res = "²¿¤«"; break;
1555 case 0x00 + (MD_INDEF_HIDDEN | MD_POSSESSIVE | MD_OBJECTIVE): res = "¤½¤ì¼«¿È"; break;
1557 case 0x00: res = "it"; break;
1558 case 0x00 + (MD_OBJECTIVE): res = "it"; break;
1559 case 0x00 + (MD_POSSESSIVE): res = "its"; break;
1560 case 0x00 + (MD_POSSESSIVE | MD_OBJECTIVE): res = "itself"; break;
1561 case 0x00 + (MD_INDEF_HIDDEN): res = "something"; break;
1562 case 0x00 + (MD_INDEF_HIDDEN | MD_OBJECTIVE): res = "something"; break;
1563 case 0x00 + (MD_INDEF_HIDDEN | MD_POSSESSIVE): res = "something's"; break;
1564 case 0x00 + (MD_INDEF_HIDDEN | MD_POSSESSIVE | MD_OBJECTIVE): res = "itself"; break;
1568 /* Male (assume human if vague) */
1570 case 0x10: res = "Èà"; break;
1571 case 0x10 + (MD_OBJECTIVE): res = "Èà"; break;
1572 case 0x10 + (MD_POSSESSIVE): res = "Èà¤Î"; break;
1573 case 0x10 + (MD_POSSESSIVE | MD_OBJECTIVE): res = "È༫¿È"; break;
1574 case 0x10 + (MD_INDEF_HIDDEN): res = "狼"; break;
1575 case 0x10 + (MD_INDEF_HIDDEN | MD_OBJECTIVE): res = "狼"; break;
1576 case 0x10 + (MD_INDEF_HIDDEN | MD_POSSESSIVE): res = "狼¤Î"; break;
1577 case 0x10 + (MD_INDEF_HIDDEN | MD_POSSESSIVE | MD_OBJECTIVE): res = "È༫¿È"; break;
1579 case 0x10: res = "he"; break;
1580 case 0x10 + (MD_OBJECTIVE): res = "him"; break;
1581 case 0x10 + (MD_POSSESSIVE): res = "his"; break;
1582 case 0x10 + (MD_POSSESSIVE | MD_OBJECTIVE): res = "himself"; break;
1583 case 0x10 + (MD_INDEF_HIDDEN): res = "someone"; break;
1584 case 0x10 + (MD_INDEF_HIDDEN | MD_OBJECTIVE): res = "someone"; break;
1585 case 0x10 + (MD_INDEF_HIDDEN | MD_POSSESSIVE): res = "someone's"; break;
1586 case 0x10 + (MD_INDEF_HIDDEN | MD_POSSESSIVE | MD_OBJECTIVE): res = "himself"; break;
1590 /* Female (assume human if vague) */
1592 case 0x20: res = "Èà½÷"; break;
1593 case 0x20 + (MD_OBJECTIVE): res = "Èà½÷"; break;
1594 case 0x20 + (MD_POSSESSIVE): res = "Èà½÷¤Î"; break;
1595 case 0x20 + (MD_POSSESSIVE | MD_OBJECTIVE): res = "Èà½÷¼«¿È"; break;
1596 case 0x20 + (MD_INDEF_HIDDEN): res = "狼"; break;
1597 case 0x20 + (MD_INDEF_HIDDEN | MD_OBJECTIVE): res = "狼"; break;
1598 case 0x20 + (MD_INDEF_HIDDEN | MD_POSSESSIVE): res = "狼¤Î"; break;
1599 case 0x20 + (MD_INDEF_HIDDEN | MD_POSSESSIVE | MD_OBJECTIVE): res = "Èà½÷¼«¿È"; break;
1601 case 0x20: res = "she"; break;
1602 case 0x20 + (MD_OBJECTIVE): res = "her"; break;
1603 case 0x20 + (MD_POSSESSIVE): res = "her"; break;
1604 case 0x20 + (MD_POSSESSIVE | MD_OBJECTIVE): res = "herself"; break;
1605 case 0x20 + (MD_INDEF_HIDDEN): res = "someone"; break;
1606 case 0x20 + (MD_INDEF_HIDDEN | MD_OBJECTIVE): res = "someone"; break;
1607 case 0x20 + (MD_INDEF_HIDDEN | MD_POSSESSIVE): res = "someone's"; break;
1608 case 0x20 + (MD_INDEF_HIDDEN | MD_POSSESSIVE | MD_OBJECTIVE): res = "herself"; break;
1612 /* Copy the result */
1613 (void)strcpy(desc, res);
1617 /* Handle visible monsters, "reflexive" request */
1618 else if ((mode & (MD_POSSESSIVE | MD_OBJECTIVE)) == (MD_POSSESSIVE | MD_OBJECTIVE))
1620 /* The monster is visible, so use its gender */
1622 if (r_ptr->flags1 & (RF1_FEMALE)) strcpy(desc, "Èà½÷¼«¿È");
1623 else if (r_ptr->flags1 & (RF1_MALE)) strcpy(desc, "È༫¿È");
1624 else strcpy(desc, "¤½¤ì¼«¿È");
1626 if (r_ptr->flags1 & RF1_FEMALE) strcpy(desc, "herself");
1627 else if (r_ptr->flags1 & RF1_MALE) strcpy(desc, "himself");
1628 else strcpy(desc, "itself");
1633 /* Handle all other visible monster requests */
1637 if (is_pet(m_ptr) && m_ptr->ap_r_idx != m_ptr->r_idx)
1643 while(strncmp(t, "¡Ù", 2) && *t) t++;
1647 (void)sprintf(desc, "%s¡©¡Ù", buf);
1650 (void)sprintf(desc, "%s¡©", name);
1652 (void)sprintf(desc, "%s?", name);
1657 /* It could be a Unique */
1658 if ((r_ptr->flags1 & RF1_UNIQUE) && !(p_ptr->image && !(mode & MD_IGNORE_HALLU)))
1660 /* Start with the name (thus nominative and objective) */
1661 if ((m_ptr->mflag2 & MFLAG2_CHAMELEON) && !(mode & MD_TRUE_NAME))
1667 while (strncmp(t, "¡Ù", 2) && *t) t++;
1671 (void)sprintf(desc, "%s¡©¡Ù", buf);
1674 (void)sprintf(desc, "%s¡©", name);
1676 (void)sprintf(desc, "%s?", name);
1679 else if ((cave[m_ptr->fy][m_ptr->fx].m_idx == p_ptr->riding) || !p_ptr->inside_battle)
1680 (void)strcpy(desc, name);
1683 (void)sprintf(desc, "%s¤â¤É¤", name);
1685 (void)sprintf(desc, "fake %s", name);
1689 /* It could be an indefinite monster */
1690 else if (mode & MD_INDEF_VISIBLE)
1692 /* XXX Check plurality for "some" */
1694 /* Indefinite monsters need an indefinite article */
1696 (void)strcpy(desc, "");
1698 (void)strcpy(desc, is_a_vowel(name[0]) ? "an " : "a ");
1701 (void)strcat(desc, name);
1704 /* It could be a normal, definite, monster */
1707 /* Definite monsters need a definite article */
1710 (void)strcpy(desc, "¤¢¤Ê¤¿¤Î");
1712 (void)strcpy(desc, "your ");
1717 (void)strcpy(desc, "");
1719 (void)strcpy(desc, "the ");
1722 (void)strcat(desc, name);
1725 if (m_ptr->nickname)
1728 sprintf(buf,"¡Ö%s¡×",quark_str(m_ptr->nickname));
1730 sprintf(buf," called %s",quark_str(m_ptr->nickname));
1735 if (player_bold(m_ptr->fy, m_ptr->fx))
1738 strcat(desc,"(¾èÇÏÃæ)");
1740 strcat(desc,"(riding)");
1744 if ((mode & MD_IGNORE_HALLU) && (m_ptr->mflag2 & MFLAG2_CHAMELEON))
1746 if (r_ptr->flags1 & RF1_UNIQUE)
1749 strcat(desc,"(¥«¥á¥ì¥ª¥ó¤Î²¦)");
1751 strcat(desc,"(Chameleon Lord)");
1757 strcat(desc,"(¥«¥á¥ì¥ª¥ó)");
1759 strcat(desc,"(Chameleon)");
1764 if ((mode & MD_IGNORE_HALLU) && m_ptr->ap_r_idx != m_ptr->r_idx)
1766 strcat(desc, format("(%s)", r_name + r_info[m_ptr->r_idx].name));
1769 /* Handle the Possessive as a special afterthought */
1770 if (mode & MD_POSSESSIVE)
1772 /* XXX Check for trailing "s" */
1774 /* Simply append "apostrophe" and "s" */
1776 (void)strcat(desc, "¤Î");
1778 (void)strcat(desc, "'s");
1788 * Learn about a monster (by "probing" it)
1790 * Return the number of new flags learnt. -Mogami-
1792 int lore_do_probe(int r_idx)
1794 monster_race *r_ptr = &r_info[r_idx];
1798 /* Maximal info about awareness */
1799 if (r_ptr->r_wake != MAX_UCHAR) n++;
1800 if (r_ptr->r_ignore != MAX_UCHAR) n++;
1801 r_ptr->r_wake = r_ptr->r_ignore = MAX_UCHAR;
1803 /* Observe "maximal" attacks */
1804 for (i = 0; i < 4; i++)
1806 /* Examine "actual" blows */
1807 if (r_ptr->blow[i].effect || r_ptr->blow[i].method)
1809 /* Maximal observations */
1810 if (r_ptr->r_blows[i] != MAX_UCHAR) n++;
1811 r_ptr->r_blows[i] = MAX_UCHAR;
1817 (((r_ptr->flags1 & RF1_DROP_4D2) ? 8 : 0) +
1818 ((r_ptr->flags1 & RF1_DROP_3D2) ? 6 : 0) +
1819 ((r_ptr->flags1 & RF1_DROP_2D2) ? 4 : 0) +
1820 ((r_ptr->flags1 & RF1_DROP_1D2) ? 2 : 0) +
1821 ((r_ptr->flags1 & RF1_DROP_90) ? 1 : 0) +
1822 ((r_ptr->flags1 & RF1_DROP_60) ? 1 : 0));
1824 /* Only "valid" drops */
1825 if (!(r_ptr->flags1 & RF1_ONLY_GOLD))
1827 if (r_ptr->r_drop_item != tmp_byte) n++;
1828 r_ptr->r_drop_item = tmp_byte;
1830 if (!(r_ptr->flags1 & RF1_ONLY_ITEM))
1832 if (r_ptr->r_drop_gold != tmp_byte) n++;
1833 r_ptr->r_drop_gold = tmp_byte;
1836 /* Observe many spells */
1837 if (r_ptr->r_cast_spell != MAX_UCHAR) n++;
1838 r_ptr->r_cast_spell = MAX_UCHAR;
1840 /* Count unknown flags */
1841 for (i = 0; i < 32; i++)
1843 if (!(r_ptr->r_flags1 & (1L << i)) &&
1844 (r_ptr->flags1 & (1L << i))) n++;
1845 if (!(r_ptr->r_flags2 & (1L << i)) &&
1846 (r_ptr->flags2 & (1L << i))) n++;
1847 if (!(r_ptr->r_flags3 & (1L << i)) &&
1848 (r_ptr->flags3 & (1L << i))) n++;
1849 if (!(r_ptr->r_flags4 & (1L << i)) &&
1850 (r_ptr->flags4 & (1L << i))) n++;
1851 if (!(r_ptr->r_flags5 & (1L << i)) &&
1852 (r_ptr->flags5 & (1L << i))) n++;
1853 if (!(r_ptr->r_flags6 & (1L << i)) &&
1854 (r_ptr->flags6 & (1L << i))) n++;
1855 if (!(r_ptr->r_flagsr & (1L << i)) &&
1856 (r_ptr->flagsr & (1L << i))) n++;
1858 /* r_flags7 is actually unused */
1860 if (!(r_ptr->r_flags7 & (1L << i)) &&
1861 (r_ptr->flags7 & (1L << i))) n++;
1865 /* Know all the flags */
1866 r_ptr->r_flags1 = r_ptr->flags1;
1867 r_ptr->r_flags2 = r_ptr->flags2;
1868 r_ptr->r_flags3 = r_ptr->flags3;
1869 r_ptr->r_flags4 = r_ptr->flags4;
1870 r_ptr->r_flags5 = r_ptr->flags5;
1871 r_ptr->r_flags6 = r_ptr->flags6;
1872 r_ptr->r_flagsr = r_ptr->flagsr;
1874 /* r_flags7 is actually unused */
1875 /* r_ptr->r_flags7 = r_ptr->flags7; */
1877 /* Know about evolution */
1878 if (!(r_ptr->r_xtra1 & MR1_SINKA)) n++;
1879 r_ptr->r_xtra1 |= MR1_SINKA;
1881 /* Update monster recall window */
1882 if (p_ptr->monster_race_idx == r_idx)
1885 p_ptr->window |= (PW_MONSTER);
1888 /* Return the number of new flags learnt */
1894 * Take note that the given monster just dropped some treasure
1896 * Note that learning the "GOOD"/"GREAT" flags gives information
1897 * about the treasure (even when the monster is killed for the first
1898 * time, such as uniques, and the treasure has not been examined yet).
1900 * This "indirect" method is used to prevent the player from learning
1901 * exactly how much treasure a monster can drop from observing only
1902 * a single example of a drop. This method actually observes how much
1903 * gold and items are dropped, and remembers that information to be
1904 * described later by the monster recall code.
1906 void lore_treasure(int m_idx, int num_item, int num_gold)
1908 monster_type *m_ptr = &m_list[m_idx];
1910 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1912 /* If the monster doesn't have original appearance, don't note */
1913 if (!is_original_ap(m_ptr)) return;
1915 /* Note the number of things dropped */
1916 if (num_item > r_ptr->r_drop_item) r_ptr->r_drop_item = num_item;
1917 if (num_gold > r_ptr->r_drop_gold) r_ptr->r_drop_gold = num_gold;
1919 /* Hack -- memorize the good/great flags */
1920 if (r_ptr->flags1 & (RF1_DROP_GOOD)) r_ptr->r_flags1 |= (RF1_DROP_GOOD);
1921 if (r_ptr->flags1 & (RF1_DROP_GREAT)) r_ptr->r_flags1 |= (RF1_DROP_GREAT);
1923 /* Update monster recall window */
1924 if (p_ptr->monster_race_idx == m_ptr->r_idx)
1927 p_ptr->window |= (PW_MONSTER);
1933 void sanity_blast(monster_type *m_ptr, bool necro)
1935 bool happened = FALSE;
1938 if (p_ptr->inside_battle || !character_dungeon) return;
1943 monster_race *r_ptr = &r_info[m_ptr->ap_r_idx];
1945 power = r_ptr->level / 2;
1947 monster_desc(m_name, m_ptr, 0);
1949 if (!(r_ptr->flags1 & RF1_UNIQUE))
1951 if (r_ptr->flags1 & RF1_FRIENDS)
1957 return; /* No effect yet, just loaded... */
1960 return; /* Cannot see it for some reason */
1962 if (!(r_ptr->flags2 & RF2_ELDRITCH_HORROR))
1968 return; /* Pet eldritch horrors are safe most of the time */
1970 if (randint1(100) > power) return;
1972 if (saving_throw(p_ptr->skill_sav - power))
1974 return; /* Save, no adverse effects */
1979 /* Something silly happens... */
1981 msg_format("%s%s¤Î´é¤ò¸«¤Æ¤·¤Þ¤Ã¤¿¡ª",
1982 funny_desc[randint0(MAX_SAN_FUNNY)], m_name);
1984 msg_format("You behold the %s visage of %s!",
1985 funny_desc[randint0(MAX_SAN_FUNNY)], m_name);
1991 msg_print(funny_comments[randint0(MAX_SAN_COMMENT)]);
1992 p_ptr->image = p_ptr->image + randint1(r_ptr->level);
1995 return; /* Never mind; we can't see it clearly enough */
1998 /* Something frightening happens... */
2000 msg_format("%s%s¤Î´é¤ò¸«¤Æ¤·¤Þ¤Ã¤¿¡ª",
2001 horror_desc[randint0(MAX_SAN_HORROR)], m_name);
2003 msg_format("You behold the %s visage of %s!",
2004 horror_desc[randint0(MAX_SAN_HORROR)], m_name);
2007 r_ptr->r_flags2 |= RF2_ELDRITCH_HORROR;
2009 /* Demon characters are unaffected */
2010 if (prace_is_(RACE_IMP) || prace_is_(RACE_DEMON) || (mimic_info[p_ptr->mimic_form].MIMIC_FLAGS & MIMIC_IS_DEMON)) return;
2011 if (p_ptr->wizard) return;
2013 /* Undead characters are 50% likely to be unaffected */
2014 if (prace_is_(RACE_SKELETON) || prace_is_(RACE_ZOMBIE)
2015 || prace_is_(RACE_VAMPIRE) || prace_is_(RACE_SPECTRE) ||
2016 (mimic_info[p_ptr->mimic_form].MIMIC_FLAGS & MIMIC_IS_UNDEAD))
2018 if (saving_throw(25 + p_ptr->lev)) return;
2024 msg_print("¥Í¥¯¥í¥Î¥ß¥³¥ó¤òÆɤó¤ÇÀµµ¤¤ò¼º¤Ã¤¿¡ª");
2026 msg_print("Your sanity is shaken by reading the Necronomicon!");
2031 if (!saving_throw(p_ptr->skill_sav - power)) /* Mind blast */
2033 if (!p_ptr->resist_conf)
2035 (void)set_confused(p_ptr->confused + randint0(4) + 4);
2037 if (!p_ptr->resist_chaos && one_in_(3))
2039 (void)set_image(p_ptr->image + randint0(250) + 150);
2044 if (!saving_throw(p_ptr->skill_sav - power)) /* Lose int & wis */
2051 if (!saving_throw(p_ptr->skill_sav - power)) /* Brain smash */
2053 if (!p_ptr->resist_conf)
2055 (void)set_confused(p_ptr->confused + randint0(4) + 4);
2057 if (!p_ptr->free_act)
2059 (void)set_paralyzed(p_ptr->paralyzed + randint0(4) + 4);
2061 while (randint0(100) > p_ptr->skill_sav)
2062 (void)do_dec_stat(A_INT);
2063 while (randint0(100) > p_ptr->skill_sav)
2064 (void)do_dec_stat(A_WIS);
2065 if (!p_ptr->resist_chaos)
2067 (void)set_image(p_ptr->image + randint0(250) + 150);
2072 if (!saving_throw(p_ptr->skill_sav - power)) /* Amnesia */
2075 if (lose_all_info())
2077 msg_print("¤¢¤Þ¤ê¤Î¶²ÉݤËÁ´¤Æ¤Î¤³¤È¤ò˺¤ì¤Æ¤·¤Þ¤Ã¤¿¡ª");
2079 msg_print("You forget everything in your utmost terror!");
2085 if (saving_throw(p_ptr->skill_sav - power))
2090 /* Else gain permanent insanity */
2091 if ((p_ptr->muta3 & MUT3_MORONIC) && /*(p_ptr->muta2 & MUT2_BERS_RAGE) &&*/
2092 ((p_ptr->muta2 & MUT2_COWARDICE) || (p_ptr->resist_fear)) &&
2093 ((p_ptr->muta2 & MUT2_HALLU) || (p_ptr->resist_chaos)))
2095 /* The poor bastard already has all possible insanities! */
2101 switch (randint1(21))
2104 if (!(p_ptr->muta3 & MUT3_MORONIC) && one_in_(5))
2106 if ((p_ptr->stat_use[A_INT] < 4) && (p_ptr->stat_use[A_WIS] < 4))
2109 msg_print("¤¢¤Ê¤¿¤Ï´°àú¤ÊÇϼ¯¤Ë¤Ê¤Ã¤¿¤è¤¦¤Êµ¤¤¬¤·¤¿¡£¤·¤«¤·¤½¤ì¤Ï¸µ¡¹¤À¤Ã¤¿¡£");
2111 msg_print("You turn into an utter moron!");
2117 msg_print("¤¢¤Ê¤¿¤Ï´°àú¤ÊÇϼ¯¤Ë¤Ê¤Ã¤¿¡ª");
2119 msg_print("You turn into an utter moron!");
2123 if (p_ptr->muta3 & MUT3_HYPER_INT)
2126 msg_print("¤¢¤Ê¤¿¤ÎǾ¤ÏÀ¸ÂÎ¥³¥ó¥Ô¥å¡¼¥¿¤Ç¤Ï¤Ê¤¯¤Ê¤Ã¤¿¡£");
2128 msg_print("Your brain is no longer a living computer.");
2131 p_ptr->muta3 &= ~(MUT3_HYPER_INT);
2133 p_ptr->muta3 |= MUT3_MORONIC;
2147 if (!(p_ptr->muta2 & MUT2_COWARDICE) && !p_ptr->resist_fear)
2150 msg_print("¤¢¤Ê¤¿¤Ï¥Ñ¥é¥Î¥¤¥¢¤Ë¤Ê¤Ã¤¿¡ª");
2152 msg_print("You become paranoid!");
2156 /* Duh, the following should never happen, but anyway... */
2157 if (p_ptr->muta3 & MUT3_FEARLESS)
2160 msg_print("¤¢¤Ê¤¿¤Ï¤â¤¦¶²¤ìÃΤ餺¤Ç¤Ï¤Ê¤¯¤Ê¤Ã¤¿¡£");
2162 msg_print("You are no longer fearless.");
2165 p_ptr->muta3 &= ~(MUT3_FEARLESS);
2168 p_ptr->muta2 |= MUT2_COWARDICE;
2182 if (!(p_ptr->muta2 & MUT2_HALLU) && !p_ptr->resist_chaos)
2185 msg_print("¸¸³Ð¤ò¤Ò¤µ¯¤³¤¹Àº¿ÀºøÍð¤Ë´Ù¤Ã¤¿¡ª");
2187 msg_print("You are afflicted by a hallucinatory insanity!");
2190 p_ptr->muta2 |= MUT2_HALLU;
2195 if (!(p_ptr->muta2 & MUT2_BERS_RAGE))
2198 msg_print("·ãÎõ¤Ê´¶¾ð¤Îȯºî¤Ë¤ª¤½¤ï¤ì¤ë¤è¤¦¤Ë¤Ê¤Ã¤¿¡ª");
2200 msg_print("You become subject to fits of berserk rage!");
2203 p_ptr->muta2 |= MUT2_BERS_RAGE;
2210 p_ptr->update |= PU_BONUS;
2216 * This function updates the monster record of the given monster
2218 * This involves extracting the distance to the player (if requested),
2219 * and then checking for visibility (natural, infravision, see-invis,
2220 * telepathy), updating the monster visibility flag, redrawing (or
2221 * erasing) the monster when its visibility changes, and taking note
2222 * of any interesting monster flags (cold-blooded, invisible, etc).
2224 * Note the new "mflag" field which encodes several monster state flags,
2225 * including "view" for when the monster is currently in line of sight,
2226 * and "mark" for when the monster is currently visible via detection.
2228 * The only monster fields that are changed here are "cdis" (the
2229 * distance from the player), "ml" (visible to the player), and
2230 * "mflag" (to maintain the "MFLAG_VIEW" flag).
2232 * Note the special "update_monsters()" function which can be used to
2233 * call this function once for every monster.
2235 * Note the "full" flag which requests that the "cdis" field be updated,
2236 * this is only needed when the monster (or the player) has moved.
2238 * Every time a monster moves, we must call this function for that
2239 * monster, and update the distance, and the visibility. Every time
2240 * the player moves, we must call this function for every monster, and
2241 * update the distance, and the visibility. Whenever the player "state"
2242 * changes in certain ways ("blindness", "infravision", "telepathy",
2243 * and "see invisible"), we must call this function for every monster,
2244 * and update the visibility.
2246 * Routines that change the "illumination" of a grid must also call this
2247 * function for any monster in that grid, since the "visibility" of some
2248 * monsters may be based on the illumination of their grid.
2250 * Note that this function is called once per monster every time the
2251 * player moves. When the player is running, this function is one
2252 * of the primary bottlenecks, along with "update_view()" and the
2253 * "process_monsters()" code, so efficiency is important.
2255 * Note the optimized "inline" version of the "distance()" function.
2257 * A monster is "visible" to the player if (1) it has been detected
2258 * by the player, (2) it is close to the player and the player has
2259 * telepathy, or (3) it is close to the player, and in line of sight
2260 * of the player, and it is "illuminated" by some combination of
2261 * infravision, torch light, or permanent light (invisible monsters
2262 * are only affected by "light" if the player can see invisible).
2264 * Monsters which are not on the current panel may be "visible" to
2265 * the player, and their descriptions will include an "offscreen"
2266 * reference. Currently, offscreen monsters cannot be targetted
2267 * or viewed directly, but old targets will remain set. XXX XXX
2269 * The player can choose to be disturbed by several things, including
2270 * "disturb_move" (monster which is viewable moves in some way), and
2271 * "disturb_near" (monster which is "easily" viewable moves in some
2272 * way). Note that "moves" includes "appears" and "disappears".
2274 void update_mon(int m_idx, bool full)
2276 monster_type *m_ptr = &m_list[m_idx];
2278 monster_race *r_ptr = &r_info[m_ptr->r_idx];
2280 bool do_disturb = disturb_move;
2284 /* Current location */
2291 /* Seen by vision */
2294 /* Non-Ninja player in the darkness */
2295 bool in_darkness = (d_info[dungeon_type].flags1 & DF1_DARKNESS) && !p_ptr->see_nocto;
2300 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
2302 if (ap_r_ptr->r_tkills && ap_r_ptr->level >= p_ptr->lev)
2306 /* Compute distance */
2309 /* Distance components */
2310 int dy = (py > fy) ? (py - fy) : (fy - py);
2311 int dx = (px > fx) ? (px - fx) : (fx - px);
2313 /* Approximate distance */
2314 d = (dy > dx) ? (dy + (dx>>1)) : (dx + (dy>>1));
2316 /* Restrict distance */
2317 if (d > 255) d = 255;
2321 /* Save the distance */
2325 /* Extract distance */
2328 /* Extract the distance */
2334 if (m_ptr->mflag2 & (MFLAG2_MARK)) flag = TRUE;
2338 if (d <= (in_darkness ? MAX_SIGHT / 2 : MAX_SIGHT))
2340 if (!in_darkness || (d <= MAX_SIGHT / 4))
2342 if (p_ptr->special_defense & KATA_MUSOU)
2347 if (is_original_ap(m_ptr))
2349 /* Hack -- Memorize mental flags */
2350 if (r_ptr->flags2 & (RF2_SMART)) r_ptr->r_flags2 |= (RF2_SMART);
2351 if (r_ptr->flags2 & (RF2_STUPID)) r_ptr->r_flags2 |= (RF2_STUPID);
2355 /* Basic telepathy */
2356 else if (p_ptr->telepathy)
2358 /* Empty mind, no telepathy */
2359 if (r_ptr->flags2 & (RF2_EMPTY_MIND))
2361 /* Memorize flags */
2362 if (is_original_ap(m_ptr)) r_ptr->r_flags2 |= (RF2_EMPTY_MIND);
2365 /* Weird mind, occasional telepathy */
2366 else if (r_ptr->flags2 & (RF2_WEIRD_MIND))
2368 /* One in ten individuals are detectable */
2369 if ((m_idx % 10) == 5)
2374 if (is_original_ap(m_ptr))
2376 /* Memorize flags */
2377 r_ptr->r_flags2 |= (RF2_WEIRD_MIND);
2379 /* Hack -- Memorize mental flags */
2380 if (r_ptr->flags2 & (RF2_SMART)) r_ptr->r_flags2 |= (RF2_SMART);
2381 if (r_ptr->flags2 & (RF2_STUPID)) r_ptr->r_flags2 |= (RF2_STUPID);
2386 /* Normal mind, allow telepathy */
2392 if (is_original_ap(m_ptr))
2394 /* Hack -- Memorize mental flags */
2395 if (r_ptr->flags2 & (RF2_SMART)) r_ptr->r_flags2 |= (RF2_SMART);
2396 if (r_ptr->flags2 & (RF2_STUPID)) r_ptr->r_flags2 |= (RF2_STUPID);
2401 /* Magical sensing */
2402 if ((p_ptr->esp_animal) && (r_ptr->flags3 & (RF3_ANIMAL)))
2405 if (is_original_ap(m_ptr)) r_ptr->r_flags3 |= (RF3_ANIMAL);
2408 /* Magical sensing */
2409 if ((p_ptr->esp_undead) && (r_ptr->flags3 & (RF3_UNDEAD)))
2412 if (is_original_ap(m_ptr)) r_ptr->r_flags3 |= (RF3_UNDEAD);
2415 /* Magical sensing */
2416 if ((p_ptr->esp_demon) && (r_ptr->flags3 & (RF3_DEMON)))
2419 if (is_original_ap(m_ptr)) r_ptr->r_flags3 |= (RF3_DEMON);
2422 /* Magical sensing */
2423 if ((p_ptr->esp_orc) && (r_ptr->flags3 & (RF3_ORC)))
2426 if (is_original_ap(m_ptr)) r_ptr->r_flags3 |= (RF3_ORC);
2429 /* Magical sensing */
2430 if ((p_ptr->esp_troll) && (r_ptr->flags3 & (RF3_TROLL)))
2433 if (is_original_ap(m_ptr)) r_ptr->r_flags3 |= (RF3_TROLL);
2436 /* Magical sensing */
2437 if ((p_ptr->esp_giant) && (r_ptr->flags3 & (RF3_GIANT)))
2440 if (is_original_ap(m_ptr)) r_ptr->r_flags3 |= (RF3_GIANT);
2443 /* Magical sensing */
2444 if ((p_ptr->esp_dragon) && (r_ptr->flags3 & (RF3_DRAGON)))
2447 if (is_original_ap(m_ptr)) r_ptr->r_flags3 |= (RF3_DRAGON);
2450 /* Magical sensing */
2451 if ((p_ptr->esp_human) && (r_ptr->flags2 & (RF2_HUMAN)))
2454 if (is_original_ap(m_ptr)) r_ptr->r_flags2 |= (RF2_HUMAN);
2457 /* Magical sensing */
2458 if ((p_ptr->esp_evil) && (r_ptr->flags3 & (RF3_EVIL)))
2461 if (is_original_ap(m_ptr)) r_ptr->r_flags3 |= (RF3_EVIL);
2464 /* Magical sensing */
2465 if ((p_ptr->esp_good) && (r_ptr->flags3 & (RF3_GOOD)))
2468 if (is_original_ap(m_ptr)) r_ptr->r_flags3 |= (RF3_GOOD);
2471 /* Magical sensing */
2472 if ((p_ptr->esp_nonliving) &&
2473 ((r_ptr->flags3 & (RF3_DEMON | RF3_UNDEAD | RF3_NONLIVING)) == RF3_NONLIVING))
2476 if (is_original_ap(m_ptr)) r_ptr->r_flags3 |= (RF3_NONLIVING);
2479 /* Magical sensing */
2480 if ((p_ptr->esp_unique) && (r_ptr->flags1 & (RF1_UNIQUE)))
2483 if (is_original_ap(m_ptr)) r_ptr->r_flags1 |= (RF1_UNIQUE);
2487 /* Normal line of sight, and not blind */
2488 if (player_has_los_bold(fy, fx) && !p_ptr->blind)
2490 bool do_invisible = FALSE;
2491 bool do_cold_blood = FALSE;
2493 /* Use "infravision" */
2494 if (d <= p_ptr->see_infra)
2496 /* Handle "cold blooded" monsters */
2497 if ((r_ptr->flags2 & (RF2_COLD_BLOOD | RF2_AURA_FIRE)) == RF2_COLD_BLOOD)
2500 do_cold_blood = TRUE;
2503 /* Handle "warm blooded" monsters */
2511 /* Use "illumination" */
2512 if (player_can_see_bold(fy, fx))
2514 /* Handle "invisible" monsters */
2515 if (r_ptr->flags2 & (RF2_INVISIBLE))
2518 do_invisible = TRUE;
2528 /* Handle "normal" monsters */
2539 if (is_original_ap(m_ptr))
2541 /* Memorize flags */
2542 if (do_invisible) r_ptr->r_flags2 |= (RF2_INVISIBLE);
2543 if (do_cold_blood) r_ptr->r_flags2 |= (RF2_COLD_BLOOD);
2550 /* The monster is now visible */
2553 /* It was previously unseen */
2556 /* Mark as visible */
2559 /* Draw the monster */
2562 /* Update health bar as needed */
2563 if (p_ptr->health_who == m_idx) p_ptr->redraw |= (PR_HEALTH);
2564 if (p_ptr->riding == m_idx) p_ptr->redraw |= (PR_UHEALTH);
2566 /* Hack -- Count "fresh" sightings */
2567 if ((m_ptr->ap_r_idx == MON_KAGE) && (r_info[MON_KAGE].r_sights < MAX_SHORT))
2568 r_info[MON_KAGE].r_sights++;
2569 else if (m_ptr->ap_r_idx == m_ptr->r_idx &&
2570 r_ptr->r_sights < MAX_SHORT) r_ptr->r_sights++;
2572 /* Eldritch Horror */
2573 if (r_ptr->flags2 & RF2_ELDRITCH_HORROR)
2575 sanity_blast(m_ptr, FALSE);
2578 /* Disturb on appearance */
2579 if (disturb_near && (projectable(m_ptr->fy, m_ptr->fx, py, px) && projectable(py, px, m_ptr->fy, m_ptr->fx)))
2581 if (disturb_pets || is_hostile(m_ptr))
2587 /* The monster is not visible */
2590 /* It was previously seen */
2593 /* Mark as not visible */
2596 /* Erase the monster */
2599 /* Update health bar as needed */
2600 if (p_ptr->health_who == m_idx) p_ptr->redraw |= (PR_HEALTH);
2601 if (p_ptr->riding == m_idx) p_ptr->redraw |= (PR_UHEALTH);
2603 /* Disturb on disappearance */
2606 if (disturb_pets || is_hostile(m_ptr))
2613 /* The monster is now easily visible */
2617 if (!(m_ptr->mflag & (MFLAG_VIEW)))
2619 /* Mark as easily visible */
2620 m_ptr->mflag |= (MFLAG_VIEW);
2622 /* Disturb on appearance */
2625 if (disturb_pets || is_hostile(m_ptr))
2631 /* The monster is not easily visible */
2635 if (m_ptr->mflag & (MFLAG_VIEW))
2637 /* Mark as not easily visible */
2638 m_ptr->mflag &= ~(MFLAG_VIEW);
2640 /* Disturb on disappearance */
2643 if (disturb_pets || is_hostile(m_ptr))
2652 * This function simply updates all the (non-dead) monsters (see above).
2654 void update_monsters(bool full)
2658 /* Update each (live) monster */
2659 for (i = 1; i < m_max; i++)
2661 monster_type *m_ptr = &m_list[i];
2663 /* Skip dead monsters */
2664 if (!m_ptr->r_idx) continue;
2666 /* Update the monster */
2667 update_mon(i, full);
2673 * Hack -- the index of the summoning monster
2675 static bool monster_hook_chameleon_lord(int r_idx)
2677 monster_race *r_ptr = &r_info[r_idx];
2678 monster_type *m_ptr = &m_list[chameleon_change_m_idx];
2679 monster_race *old_r_ptr = &r_info[m_ptr->r_idx];
2681 if (!(r_ptr->flags1 & (RF1_UNIQUE))) return FALSE;
2682 if (r_ptr->flags7 & (RF7_FRIENDLY | RF7_CHAMELEON)) return FALSE;
2684 if (ABS(r_ptr->level - r_info[MON_CHAMELEON_K].level) > 5) return FALSE;
2686 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))
2689 if (!monster_can_cross_terrain(cave[m_ptr->fy][m_ptr->fx].feat, r_ptr)) return FALSE;
2692 if (!(old_r_ptr->flags7 & RF7_CHAMELEON))
2694 if (monster_has_hostile_align(m_ptr, 0, 0, r_ptr)) return FALSE;
2698 else if (summon_specific_who > 0)
2700 if (monster_has_hostile_align(&m_list[summon_specific_who], 0, 0, r_ptr)) return FALSE;
2706 static bool monster_hook_chameleon(int r_idx)
2708 monster_race *r_ptr = &r_info[r_idx];
2709 monster_type *m_ptr = &m_list[chameleon_change_m_idx];
2710 monster_race *old_r_ptr = &r_info[m_ptr->r_idx];
2712 if (r_ptr->flags1 & (RF1_UNIQUE)) return FALSE;
2713 if (r_ptr->flags2 & RF2_MULTIPLY) return FALSE;
2714 if (r_ptr->flags7 & (RF7_FRIENDLY | RF7_CHAMELEON)) return FALSE;
2716 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))
2719 if (!monster_can_cross_terrain(cave[m_ptr->fy][m_ptr->fx].feat, r_ptr)) return FALSE;
2722 if (!(old_r_ptr->flags7 & RF7_CHAMELEON))
2724 if ((old_r_ptr->flags3 & RF3_GOOD) && !(r_ptr->flags3 & RF3_GOOD)) return FALSE;
2725 if ((old_r_ptr->flags3 & RF3_EVIL) && !(r_ptr->flags3 & RF3_EVIL)) return FALSE;
2726 if (!(old_r_ptr->flags3 & (RF3_GOOD | RF3_EVIL)) && (r_ptr->flags3 & (RF3_GOOD | RF3_EVIL))) return FALSE;
2730 else if (summon_specific_who > 0)
2732 if (monster_has_hostile_align(&m_list[summon_specific_who], 0, 0, r_ptr)) return FALSE;
2735 return (*(get_monster_hook()))(r_idx);
2739 void choose_new_monster(int m_idx, bool born, int r_idx)
2742 monster_type *m_ptr = &m_list[m_idx];
2743 monster_race *r_ptr;
2744 char old_m_name[80];
2745 bool old_unique = FALSE;
2747 if (r_info[m_ptr->r_idx].flags1 & RF1_UNIQUE)
2749 if (old_unique && (r_idx == MON_CHAMELEON)) r_idx = MON_CHAMELEON_K;
2750 r_ptr = &r_info[r_idx];
2752 monster_desc(old_m_name, m_ptr, 0);
2758 chameleon_change_m_idx = m_idx;
2760 get_mon_num_prep(monster_hook_chameleon_lord, NULL);
2762 get_mon_num_prep(monster_hook_chameleon, NULL);
2765 level = r_info[MON_CHAMELEON_K].level;
2766 else if (!dun_level)
2767 level = wilderness[p_ptr->wilderness_y][p_ptr->wilderness_x].level;
2771 if (d_info[dungeon_type].flags1 & DF1_CHAMELEON) level+= 2+randint1(3);
2773 r_idx = get_mon_num(level);
2774 r_ptr = &r_info[r_idx];
2776 chameleon_change_m_idx = 0;
2782 m_ptr->r_idx = r_idx;
2783 m_ptr->ap_r_idx = r_idx;
2784 update_mon(m_idx, FALSE);
2785 lite_spot(m_ptr->fy, m_ptr->fx);
2788 /* Sub-alignment of a chameleon */
2789 if (r_ptr->flags3 & (RF3_EVIL | RF3_GOOD))
2791 m_ptr->sub_align = SUB_ALIGN_NEUTRAL;
2792 if (r_ptr->flags3 & RF3_EVIL) m_ptr->sub_align |= SUB_ALIGN_EVIL;
2793 if (r_ptr->flags3 & RF3_GOOD) m_ptr->sub_align |= SUB_ALIGN_GOOD;
2798 if (m_idx == p_ptr->riding)
2801 monster_desc(m_name, m_ptr, 0);
2803 msg_format("ÆÍÁ³%s¤¬ÊѿȤ·¤¿¡£", old_m_name);
2805 msg_format("Suddenly, %s transforms!", old_m_name);
2807 if (!(r_ptr->flags7 & RF7_RIDING))
2809 if (rakuba(0, TRUE)) msg_print("ÃÏÌ̤ËÍî¤È¤µ¤ì¤¿¡£");
2811 if (rakuba(0, TRUE)) msg_format("You have fallen from %s.", m_name);
2815 /* Extract the monster base speed */
2816 m_ptr->mspeed = get_mspeed(r_ptr);
2818 oldmaxhp = m_ptr->max_maxhp;
2819 /* Assign maximal hitpoints */
2820 if (r_ptr->flags1 & RF1_FORCE_MAXHP)
2822 m_ptr->max_maxhp = maxroll(r_ptr->hdice, r_ptr->hside);
2826 m_ptr->max_maxhp = damroll(r_ptr->hdice, r_ptr->hside);
2828 m_ptr->maxhp = (long)(m_ptr->maxhp * m_ptr->max_maxhp) / oldmaxhp;
2829 m_ptr->hp = (long)(m_ptr->hp * m_ptr->max_maxhp) / oldmaxhp;
2836 static bool monster_hook_tanuki(int r_idx)
2838 monster_race *r_ptr = &r_info[r_idx];
2840 if (r_ptr->flags1 & (RF1_UNIQUE)) return FALSE;
2841 if (r_ptr->flags2 & RF2_MULTIPLY) return FALSE;
2842 if (r_ptr->flags7 & (RF7_FRIENDLY | RF7_CHAMELEON)) return FALSE;
2843 if (r_ptr->flags7 & RF7_AQUATIC) return FALSE;
2845 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))
2848 return (*(get_monster_hook()))(r_idx);
2853 * Set initial racial appearance of a monster
2855 static int initial_r_appearance(int r_idx)
2857 int attempts = 1000;
2860 int min = MIN(base_level-5, 50);
2862 if (!(r_info[r_idx].flags7 & RF7_TANUKI))
2865 get_mon_num_prep(monster_hook_tanuki, NULL);
2869 ap_r_idx = get_mon_num(base_level + 10);
2870 if (r_info[ap_r_idx].level >= min) return ap_r_idx;
2878 * Get initial monster speed
2880 byte get_mspeed(monster_race *r_ptr)
2882 /* Extract the monster base speed */
2883 int mspeed = r_ptr->speed;
2885 /* Hack -- small racial variety */
2886 if (!(r_ptr->flags1 & RF1_UNIQUE) && !p_ptr->inside_arena)
2888 /* Allow some small variation per monster */
2889 int i = SPEED_TO_ENERGY(r_ptr->speed) / (one_in_(4) ? 3 : 10);
2890 if (i) mspeed += rand_spread(0, i);
2893 if (mspeed > 199) mspeed = 199;
2895 return (byte)mspeed;
2900 * Attempt to place a monster of the given race at the given location.
2902 * To give the player a sporting chance, any monster that appears in
2903 * line-of-sight and is extremely dangerous can be marked as
2904 * "FORCE_SLEEP", which will cause them to be placed with low energy,
2905 * which often (but not always) lets the player move before they do.
2907 * This routine refuses to place out-of-depth "FORCE_DEPTH" monsters.
2909 * XXX XXX XXX Use special "here" and "dead" flags for unique monsters,
2910 * remove old "cur_num" and "max_num" fields.
2912 * XXX XXX XXX Actually, do something similar for artifacts, to simplify
2913 * the "preserve" mode, and to make the "what artifacts" flag more useful.
2915 * This is the only function which may place a monster in the dungeon,
2916 * except for the savefile loading code.
2918 static bool place_monster_one(int who, int y, int x, int r_idx, u32b mode)
2920 /* Access the location */
2921 cave_type *c_ptr = &cave[y][x];
2923 monster_type *m_ptr;
2925 monster_race *r_ptr = &r_info[r_idx];
2927 cptr name = (r_name + r_ptr->name);
2929 /* DO NOT PLACE A MONSTER IN THE SMALL SCALE WILDERNESS !!! */
2930 if(p_ptr->wild_mode) return FALSE;
2932 /* Verify location */
2933 if (!in_bounds(y, x)) return (FALSE);
2935 /* Require empty space (if not ghostly) */
2936 if (!(!dun_level && (c_ptr->feat == FEAT_MOUNTAIN) && ((r_ptr->flags8 & RF8_WILD_MOUNTAIN) || (r_ptr->flags7 & RF7_CAN_FLY))) &&
2937 !(cave_empty_bold2(y, x) || (mode & PM_IGNORE_TERRAIN)) &&
2938 !((r_ptr->flags2 & RF2_PASS_WALL) &&
2939 !(cave_perma_bold(y, x) || c_ptr->m_idx ||
2940 player_bold(y, x)))) return (FALSE);
2943 if (!r_idx) return (FALSE);
2946 if (!r_ptr->name) return (FALSE);
2948 /* Nor on the Pattern */
2949 if ((c_ptr->feat >= FEAT_PATTERN_START)
2950 && (c_ptr->feat <= FEAT_PATTERN_XTRA2))
2953 if (!(mode & PM_IGNORE_TERRAIN) &&
2954 !monster_can_cross_terrain(c_ptr->feat, r_ptr))
2959 if (!p_ptr->inside_battle)
2961 /* Hack -- "unique" monsters must be "unique" */
2962 if (((r_ptr->flags1 & (RF1_UNIQUE)) ||
2963 (r_ptr->flags7 & (RF7_NAZGUL))) &&
2964 (r_ptr->cur_num >= r_ptr->max_num))
2970 if ((r_ptr->flags7 & (RF7_UNIQUE2)) &&
2971 (r_ptr->cur_num >= 1))
2976 if (r_idx == MON_BANORLUPART)
2978 if (r_info[MON_BANOR].cur_num > 0) return FALSE;
2979 if (r_info[MON_LUPART].cur_num > 0) return FALSE;
2982 /* Depth monsters may NOT be created out of depth, unless in Nightmare mode */
2983 if ((r_ptr->flags1 & (RF1_FORCE_DEPTH)) && (dun_level < r_ptr->level) &&
2984 (!ironman_nightmare || (r_ptr->flags1 & (RF1_QUESTOR))))
2991 if (quest_number(dun_level))
2993 int hoge = quest_number(dun_level);
2994 if ((quest[hoge].type == QUEST_TYPE_KILL_LEVEL) || (quest[hoge].type == QUEST_TYPE_RANDOM))
2996 if(r_idx == quest[hoge].r_idx)
2998 int number_mon, i2, j2;
3001 /* Count all quest monsters */
3002 for (i2 = 0; i2 < cur_wid; ++i2)
3003 for (j2 = 0; j2 < cur_hgt; j2++)
3004 if (cave[j2][i2].m_idx > 0)
3005 if (m_list[cave[j2][i2].m_idx].r_idx == quest[hoge].r_idx)
3007 if(number_mon + quest[hoge].cur_num >= quest[hoge].max_num)
3013 if (is_glyph_grid(c_ptr))
3015 if (randint1(BREAK_GLYPH) < (r_ptr->level+20))
3017 /* Describe observable breakage */
3018 if (c_ptr->info & CAVE_MARK)
3021 msg_print("¼é¤ê¤Î¥ë¡¼¥ó¤¬²õ¤ì¤¿¡ª");
3023 msg_print("The rune of protection is broken!");
3028 /* Forget the rune */
3029 c_ptr->info &= ~(CAVE_MARK);
3031 /* Break the rune */
3032 c_ptr->info &= ~(CAVE_OBJECT);
3041 /* Powerful monster */
3042 if (r_ptr->level > dun_level)
3044 /* Unique monsters */
3045 if (r_ptr->flags1 & (RF1_UNIQUE))
3047 /* Message for cheaters */
3049 if (cheat_hear) msg_format("¿¼ÁؤΥæ¥Ë¡¼¥¯¡¦¥â¥ó¥¹¥¿¡¼ (%s)¡£", name);
3051 if (cheat_hear) msg_format("Deep Unique (%s).", name);
3055 /* Boost rating by twice delta-depth */
3056 rating += (r_ptr->level - dun_level) * 2;
3059 /* Normal monsters */
3062 /* Message for cheaters */
3064 if (cheat_hear) msg_format("¿¼ÁؤΥâ¥ó¥¹¥¿¡¼ (%s)¡£", name);
3066 if (cheat_hear) msg_format("Deep Monster (%s).", name);
3070 /* Boost rating by delta-depth */
3071 rating += (r_ptr->level - dun_level);
3075 /* Note the monster */
3076 else if (r_ptr->flags1 & (RF1_UNIQUE))
3078 /* Unique monsters induce message */
3080 if (cheat_hear) msg_format("¥æ¥Ë¡¼¥¯¡¦¥â¥ó¥¹¥¿¡¼ (%s)¡£", name);
3082 if (cheat_hear) msg_format("Unique (%s).", name);
3087 if ((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags7 & RF7_NAZGUL) || (r_ptr->level < 10)) mode &= ~PM_KAGE;
3089 /* Make a new monster */
3090 c_ptr->m_idx = m_pop();
3091 hack_m_idx_ii = c_ptr->m_idx;
3093 /* Mega-Hack -- catch "failure" */
3094 if (!c_ptr->m_idx) return (FALSE);
3097 /* Get a new monster record */
3098 m_ptr = &m_list[c_ptr->m_idx];
3101 m_ptr->r_idx = r_idx;
3102 m_ptr->ap_r_idx = initial_r_appearance(r_idx);
3104 /* Sub-alignment of a monster */
3105 if ((who > 0) && !(r_ptr->flags3 & (RF3_EVIL | RF3_GOOD)))
3106 m_ptr->sub_align = m_list[who].sub_align;
3109 m_ptr->sub_align = SUB_ALIGN_NEUTRAL;
3110 if (r_ptr->flags3 & RF3_EVIL) m_ptr->sub_align |= SUB_ALIGN_EVIL;
3111 if (r_ptr->flags3 & RF3_GOOD) m_ptr->sub_align |= SUB_ALIGN_GOOD;
3114 /* Place the monster at the location */
3119 /* No "damage" yet */
3121 m_ptr->confused = 0;
3124 /* Unknown distance */
3127 reset_target(m_ptr);
3129 m_ptr->nickname = 0;
3138 /* Your pet summons its pet. */
3139 if (who > 0 && is_pet(&m_list[who]))
3141 mode |= PM_FORCE_PET;
3142 m_ptr->parent_m_idx = who;
3146 m_ptr->parent_m_idx = 0;
3149 if (r_ptr->flags7 & RF7_CHAMELEON)
3151 choose_new_monster(c_ptr->m_idx, TRUE, 0);
3152 r_ptr = &r_info[m_ptr->r_idx];
3153 m_ptr->mflag2 |= MFLAG2_CHAMELEON;
3156 /* Hack - Set sub_align to neutral when the Chameleon Lord is generated as "GUARDIAN" */
3157 if ((r_ptr->flags1 & RF1_UNIQUE) && (who <= 0))
3158 m_ptr->sub_align = SUB_ALIGN_NEUTRAL;
3160 else if ((mode & PM_KAGE) && !(mode & PM_FORCE_PET))
3162 m_ptr->ap_r_idx = MON_KAGE;
3163 m_ptr->mflag2 |= MFLAG2_KAGE;
3166 if (mode & PM_NO_PET) m_ptr->mflag2 |= MFLAG2_NOPET;
3172 if (mode & PM_FORCE_PET)
3177 else if ((r_ptr->flags7 & RF7_FRIENDLY) ||
3178 (mode & PM_FORCE_FRIENDLY) || is_friendly_idx(who))
3180 if (!monster_has_hostile_align(NULL, 0, -1, r_ptr)) set_friendly(m_ptr);
3183 /* Assume no sleeping */
3186 /* Enforce sleeping if needed */
3187 if ((mode & PM_ALLOW_SLEEP) && r_ptr->sleep && !ironman_nightmare)
3189 int val = r_ptr->sleep;
3190 m_ptr->csleep = ((val * 2) + randint1(val * 10));
3193 /* Assign maximal hitpoints */
3194 if (r_ptr->flags1 & RF1_FORCE_MAXHP)
3196 m_ptr->max_maxhp = maxroll(r_ptr->hdice, r_ptr->hside);
3200 m_ptr->max_maxhp = damroll(r_ptr->hdice, r_ptr->hside);
3203 /* Monsters have double hitpoints in Nightmare mode */
3204 if (ironman_nightmare)
3206 u32b hp = m_ptr->max_maxhp * 2L;
3208 m_ptr->max_maxhp = (s16b)MIN(30000, hp);
3211 m_ptr->maxhp = m_ptr->max_maxhp;
3213 /* And start out fully healthy */
3214 if (m_ptr->r_idx == MON_WOUNDED_BEAR)
3215 m_ptr->hp = m_ptr->maxhp / 2;
3216 else m_ptr->hp = m_ptr->maxhp;
3219 /* Extract the monster base speed */
3220 m_ptr->mspeed = get_mspeed(r_ptr);
3222 if (mode & PM_HASTE) m_ptr->fast = 100;
3224 /* Give a random starting energy */
3225 if (!ironman_nightmare)
3227 m_ptr->energy_need = ENERGY_NEED() - (s16b)randint0(100);
3231 /* Nightmare monsters are more prepared */
3232 m_ptr->energy_need = ENERGY_NEED() - (s16b)randint0(100) * 2;
3235 /* Force monster to wait for player, unless in Nightmare mode */
3236 if ((r_ptr->flags1 & RF1_FORCE_SLEEP) && !ironman_nightmare)
3238 /* Monster is still being nice */
3239 m_ptr->mflag |= (MFLAG_NICE);
3241 /* Must repair monsters */
3242 repair_monsters = TRUE;
3245 /* Hack -- see "process_monsters()" */
3246 if (c_ptr->m_idx < hack_m_idx)
3248 /* Monster is still being born */
3249 m_ptr->mflag |= (MFLAG_BORN);
3253 if (r_ptr->flags7 & RF7_SELF_LD_MASK)
3254 p_ptr->update |= (PU_MON_LITE);
3255 else if ((r_ptr->flags7 & RF7_HAS_LD_MASK) && !m_ptr->csleep)
3256 p_ptr->update |= (PU_MON_LITE);
3258 /* Update the monster */
3259 update_mon(c_ptr->m_idx, TRUE);
3262 /* Count the monsters on the level */
3263 real_r_ptr(m_ptr)->cur_num++;
3266 * Memorize location of the unique monster in saved floors.
3267 * A unique monster move from old saved floor.
3269 if (character_dungeon &&
3270 ((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags7 & RF7_NAZGUL)))
3271 real_r_ptr(m_ptr)->floor_id = p_ptr->floor_id;
3273 /* Hack -- Count the number of "reproducers" */
3274 if (r_ptr->flags2 & RF2_MULTIPLY) num_repro++;
3277 /* Hack -- Notice new multi-hued monsters */
3279 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
3280 if (ap_r_ptr->flags1 & (RF1_ATTR_MULTI | RF1_SHAPECHANGER))
3281 shimmer_monsters = TRUE;
3284 if (p_ptr->warning && character_dungeon)
3286 if (r_ptr->flags1 & RF1_UNIQUE)
3290 char o_name[MAX_NLEN];
3292 if (r_ptr->level > p_ptr->lev + 30)
3298 else if (r_ptr->level > p_ptr->lev + 15)
3304 else if (r_ptr->level > p_ptr->lev + 5)
3306 color = "¥ë¥Ó¡¼¿§¤Ë";
3310 else if (r_ptr->level > p_ptr->lev - 5)
3316 else if (r_ptr->level > p_ptr->lev - 15)
3318 color = "¥Ô¥ó¥¯¿§¤Ë";
3329 o_ptr = choose_warning_item();
3332 object_desc(o_name, o_ptr, FALSE, 0);
3334 msg_format("%s¤Ï%s¸÷¤Ã¤¿¡£", o_name, color);
3336 msg_format("%s glows %s.", o_name, color);
3342 msg_format("s%¸÷¤ëʪ¤¬Æ¬¤ËÉ⤫¤ó¤À¡£", color);
3344 msg_format("An %s image forms in your mind.");
3350 if (is_explosive_rune_grid(c_ptr))
3352 /* Break the ward */
3353 if (randint1(BREAK_MINOR_GLYPH) > r_ptr->level)
3355 /* Describe observable breakage */
3356 if (c_ptr->info & CAVE_MARK)
3359 msg_print("¥ë¡¼¥ó¤¬Çúȯ¤·¤¿¡ª");
3361 msg_print("The rune explodes!");
3364 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);
3370 msg_print("Çúȯ¤Î¥ë¡¼¥ó¤Ï²ò½ü¤µ¤ì¤¿¡£");
3372 msg_print("An explosive rune was disarmed.");
3376 /* Forget the rune */
3377 c_ptr->info &= ~(CAVE_MARK);
3379 /* Break the rune */
3380 c_ptr->info &= ~(CAVE_OBJECT);
3393 * improved version of scatter() for place monster
3396 #define MON_SCAT_MAXD 10
3398 static bool mon_scatter(int *yp, int *xp, int y, int x, int max_dist)
3400 int place_x[MON_SCAT_MAXD];
3401 int place_y[MON_SCAT_MAXD];
3402 int num[MON_SCAT_MAXD];
3406 if (max_dist >= MON_SCAT_MAXD)
3409 for (i = 0; i < MON_SCAT_MAXD; i++)
3412 for (nx = x - max_dist; nx <= x + max_dist; nx++)
3413 for (ny = y - max_dist; ny <= y + max_dist; ny++)
3415 /* Ignore annoying locations */
3416 if (!in_bounds(ny, nx)) continue;
3418 /* Require "line of sight" */
3419 if (!los(y, x, ny, nx)) continue;
3421 /* Walls and Monsters block flow */
3422 if (!cave_empty_bold2(ny, nx)) continue;
3424 /* ... nor on the Pattern */
3425 if ((cave[ny][nx].feat >= FEAT_PATTERN_START) &&
3426 (cave[ny][nx].feat <= FEAT_PATTERN_XTRA2))
3429 i = distance(y, x, ny, nx);
3445 while (i < MON_SCAT_MAXD && 0 == num[i])
3447 if (i >= MON_SCAT_MAXD)
3458 * Maximum size of a group of monsters
3460 #define GROUP_MAX 32
3464 * Attempt to place a "group" of monsters around the given location
3466 static bool place_monster_group(int who, int y, int x, int r_idx, u32b mode)
3468 monster_race *r_ptr = &r_info[r_idx];
3471 int total = 0, extra = 0;
3475 byte hack_y[GROUP_MAX];
3476 byte hack_x[GROUP_MAX];
3479 /* Pick a group size */
3480 total = randint1(10);
3482 /* Hard monsters, small groups */
3483 if (r_ptr->level > dun_level)
3485 extra = r_ptr->level - dun_level;
3486 extra = 0 - randint1(extra);
3489 /* Easy monsters, large groups */
3490 else if (r_ptr->level < dun_level)
3492 extra = dun_level - r_ptr->level;
3493 extra = randint1(extra);
3496 /* Hack -- limit group reduction */
3497 if (extra > 9) extra = 9;
3499 /* Modify the group size */
3503 if (total < 1) total = 1;
3506 if (total > GROUP_MAX) total = GROUP_MAX;
3509 /* Save the rating */
3512 /* Start on the monster */
3517 /* Puddle monsters, breadth first, up to total */
3518 for (n = 0; (n < hack_n) && (hack_n < total); n++)
3520 /* Grab the location */
3524 /* Check each direction, up to total */
3525 for (i = 0; (i < 8) && (hack_n < total); i++)
3529 scatter(&my, &mx, hy, hx, 4, 0);
3531 /* Walls and Monsters block flow */
3532 if (!cave_empty_bold2(my, mx)) continue;
3534 /* Attempt to place another monster */
3535 if (place_monster_one(who, my, mx, r_idx, mode))
3537 /* Add it to the "hack" set */
3538 hack_y[hack_n] = my;
3539 hack_x[hack_n] = mx;
3545 /* Hack -- restore the rating */
3555 * Hack -- help pick an escort type
3557 static int place_monster_idx = 0;
3558 static int place_monster_m_idx = 0;
3561 * Hack -- help pick an escort type
3563 static bool place_monster_okay(int r_idx)
3565 monster_race *r_ptr = &r_info[place_monster_idx];
3566 monster_type *m_ptr = &m_list[place_monster_m_idx];
3568 monster_race *z_ptr = &r_info[r_idx];
3570 /* Hack - Escorts have to have the same dungeon flag */
3571 if (mon_hook_dungeon(place_monster_idx) != mon_hook_dungeon(r_idx)) return (FALSE);
3573 /* Require similar "race" */
3574 if (z_ptr->d_char != r_ptr->d_char) return (FALSE);
3576 /* Skip more advanced monsters */
3577 if (z_ptr->level > r_ptr->level) return (FALSE);
3579 /* Skip unique monsters */
3580 if (z_ptr->flags1 & RF1_UNIQUE) return (FALSE);
3582 /* Paranoia -- Skip identical monsters */
3583 if (place_monster_idx == r_idx) return (FALSE);
3585 /* Skip different alignment */
3586 if (monster_has_hostile_align(m_ptr, 0, 0, z_ptr)) return FALSE;
3588 if (r_ptr->flags7 & RF7_FRIENDLY)
3590 if (monster_has_hostile_align(NULL, 1, -1, z_ptr)) return FALSE;
3593 if ((r_ptr->flags7 & RF7_CHAMELEON) && !(z_ptr->flags7 & RF7_CHAMELEON))
3602 * Attempt to place a monster of the given race at the given location
3604 * Note that certain monsters are now marked as requiring "friends".
3605 * These monsters, if successfully placed, and if the "grp" parameter
3606 * is TRUE, will be surrounded by a "group" of identical monsters.
3608 * Note that certain monsters are now marked as requiring an "escort",
3609 * which is a collection of monsters with similar "race" but lower level.
3611 * Some monsters induce a fake "group" flag on their escorts.
3613 * Note the "bizarre" use of non-recursion to prevent annoying output
3614 * when running a code profiler.
3616 * Note the use of the new "monster allocation table" code to restrict
3617 * the "get_mon_num()" function to "legal" escort types.
3619 bool place_monster_aux(int who, int y, int x, int r_idx, u32b mode)
3622 monster_race *r_ptr = &r_info[r_idx];
3624 if (!(mode & PM_NO_KAGE) && one_in_(333))
3627 /* Place one monster, or fail */
3628 if (!place_monster_one(who, y, x, r_idx, mode)) return (FALSE);
3631 /* Require the "group" flag */
3632 if (!(mode & PM_ALLOW_GROUP)) return (TRUE);
3634 place_monster_m_idx = hack_m_idx_ii;
3636 /* Friends for certain monsters */
3637 if (r_ptr->flags1 & (RF1_FRIENDS))
3639 /* Attempt to place a group */
3640 (void)place_monster_group(who, y, x, r_idx, mode);
3644 /* Escorts for certain monsters */
3645 if (r_ptr->flags1 & (RF1_ESCORT))
3647 /* Set the escort index */
3648 place_monster_idx = r_idx;
3650 /* Try to place several "escorts" */
3651 for (i = 0; i < 32; i++)
3653 int nx, ny, z, d = 3;
3655 /* Pick a location */
3656 scatter(&ny, &nx, y, x, d, 0);
3658 /* Require empty grids */
3659 if (!cave_empty_bold2(ny, nx)) continue;
3661 /* Prepare allocation table */
3662 get_mon_num_prep(place_monster_okay, get_monster_hook2(ny, nx));
3664 /* Pick a random race */
3665 z = get_mon_num(r_ptr->level);
3667 /* Handle failure */
3670 /* Place a single escort */
3671 (void)place_monster_one(place_monster_m_idx, ny, nx, z, mode);
3673 /* Place a "group" of escorts if needed */
3674 if ((r_info[z].flags1 & RF1_FRIENDS) ||
3675 (r_ptr->flags1 & RF1_ESCORTS))
3677 /* Place a group of monsters */
3678 (void)place_monster_group(place_monster_m_idx, ny, nx, z, mode);
3689 * Hack -- attempt to place a monster at the given location
3691 * Attempt to find a monster appropriate to the "monster_level"
3693 bool place_monster(int y, int x, u32b mode)
3697 /* Prepare allocation table */
3698 get_mon_num_prep(get_monster_hook(), get_monster_hook2(y, x));
3700 /* Pick a monster */
3701 r_idx = get_mon_num(monster_level);
3703 /* Handle failure */
3704 if (!r_idx) return (FALSE);
3706 /* Attempt to place the monster */
3707 if (place_monster_aux(0, y, x, r_idx, mode)) return (TRUE);
3714 #ifdef MONSTER_HORDES
3716 bool alloc_horde(int y, int x)
3718 monster_race *r_ptr = NULL;
3721 int attempts = 1000;
3725 /* Prepare allocation table */
3726 get_mon_num_prep(get_monster_hook(), get_monster_hook2(y, x));
3730 /* Pick a monster */
3731 r_idx = get_mon_num(monster_level);
3733 /* Handle failure */
3734 if (!r_idx) return (FALSE);
3736 r_ptr = &r_info[r_idx];
3738 if (r_ptr->flags1 & RF1_UNIQUE) continue;
3740 if (r_idx == MON_HAGURE) continue;
3743 if (attempts < 1) return FALSE;
3749 /* Attempt to place the monster */
3750 if (place_monster_aux(0, y, x, r_idx, 0L)) break;
3753 if (attempts < 1) return FALSE;
3755 m_idx = cave[y][x].m_idx;
3757 if (m_list[m_idx].mflag2 & MFLAG2_CHAMELEON) r_ptr = &r_info[m_list[m_idx].r_idx];
3758 summon_kin_type = r_ptr->d_char;
3760 for (attempts = randint1(10) + 5; attempts; attempts--)
3762 scatter(&cy, &cx, y, x, 5, 0);
3764 (void)summon_specific(m_idx, cy, cx, dun_level + 5, SUMMON_KIN, PM_ALLOW_GROUP);
3773 #endif /* MONSTER_HORDES */
3779 bool alloc_guardian(void)
3781 int guardian = d_info[dungeon_type].final_guardian;
3783 if (guardian && (d_info[dungeon_type].maxdepth == dun_level) && (r_info[guardian].cur_num < r_info[guardian].max_num))
3789 /* Find a good position */
3792 /* Get a random spot */
3793 oy = randint1(cur_hgt - 4) + 2;
3794 ox = randint1(cur_wid - 4) + 2;
3796 /* Is it a good spot ? */
3797 if (cave_empty_bold2(oy, ox) && monster_can_cross_terrain(cave[oy][ox].feat, &r_info[guardian]))
3799 /* Place the guardian */
3800 if (place_monster_aux(0, oy, ox, guardian, (PM_ALLOW_GROUP | PM_NO_KAGE | PM_NO_PET))) return TRUE;
3813 * Attempt to allocate a random monster in the dungeon.
3815 * Place the monster at least "dis" distance from the player.
3817 * Use "slp" to choose the initial "sleep" status
3819 * Use "monster_level" for the monster level
3821 bool alloc_monster(int dis, u32b mode)
3824 int attempts_left = 10000;
3826 /* Put the Guardian */
3827 if (alloc_guardian()) return TRUE;
3829 /* Find a legal, distant, unoccupied, space */
3830 while (attempts_left--)
3832 /* Pick a location */
3833 y = randint0(cur_hgt);
3834 x = randint0(cur_wid);
3836 /* Require empty floor grid (was "naked") */
3837 if (dun_level || (wilderness[p_ptr->wilderness_y][p_ptr->wilderness_x].terrain != TERRAIN_MOUNTAIN))
3839 if (!cave_empty_bold2(y, x)) continue;
3843 if (!cave_empty_bold2(y, x) && (cave[y][x].feat != FEAT_MOUNTAIN)) continue;
3846 /* Accept far away grids */
3847 if (distance(y, x, py, px) > dis) break;
3852 if (cheat_xtra || cheat_hear)
3855 msg_print("·Ù¹ð¡ª¿·¤¿¤Ê¥â¥ó¥¹¥¿¡¼¤òÇÛÃ֤Ǥ¤Þ¤»¤ó¡£¾®¤µ¤¤³¬¤Ç¤¹¤«¡©");
3857 msg_print("Warning! Could not allocate a new monster. Small level?");
3866 #ifdef MONSTER_HORDES
3867 if (randint1(5000) <= dun_level)
3869 if (alloc_horde(y, x))
3872 if (cheat_hear) msg_format("¥â¥ó¥¹¥¿¡¼¤ÎÂç·²(%c)", summon_kin_type);
3874 if (cheat_hear) msg_format("Monster horde (%c).", summon_kin_type);
3882 #endif /* MONSTER_HORDES */
3884 /* Attempt to place the monster, allow groups */
3885 if (place_monster(y, x, (mode | PM_ALLOW_GROUP))) return (TRUE);
3887 #ifdef MONSTER_HORDES
3889 #endif /* MONSTER_HORDES */
3899 * Hack -- help decide if a monster race is "okay" to summon
3901 static bool summon_specific_okay(int r_idx)
3903 monster_race *r_ptr = &r_info[r_idx];
3905 /* Hack - Only summon dungeon monsters */
3906 if (!mon_hook_dungeon(r_idx)) return (FALSE);
3908 /* Hack -- identify the summoning monster */
3909 if (summon_specific_who > 0)
3911 monster_type *m_ptr = &m_list[summon_specific_who];
3913 /* Do not summon enemies */
3915 /* Friendly vs. opposite aligned normal or pet */
3916 if (monster_has_hostile_align(m_ptr, 0, 0, r_ptr)) return FALSE;
3918 /* Use the player's alignment */
3919 else if (summon_specific_who < 0)
3921 /* Do not summon enemies of the pets */
3922 if (monster_has_hostile_align(NULL, 10, -10, r_ptr))
3924 if (!one_in_(ABS(p_ptr->align) / 2 + 1)) return FALSE;
3928 /* Hack -- no specific type specified */
3929 if (!summon_specific_type) return (TRUE);
3931 if (!summon_unique_okay && ((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags7 & RF7_NAZGUL))) return FALSE;
3933 if ((summon_specific_who < 0) &&
3934 ((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags7 & RF7_NAZGUL)) &&
3935 monster_has_hostile_align(NULL, 10, -10, r_ptr))
3938 if ((r_ptr->flags7 & RF7_CHAMELEON) && (d_info[dungeon_type].flags1 & DF1_CHAMELEON)) return TRUE;
3940 return (summon_specific_aux(r_idx));
3945 * Place a monster (of the specified "type") near the given
3946 * location. Return TRUE if a monster was actually summoned.
3948 * We will attempt to place the monster up to 10 times before giving up.
3950 * Note: SUMMON_UNIQUE and SUMMON_AMBERITES will summon Unique's
3951 * Note: SUMMON_HI_UNDEAD and SUMMON_HI_DRAGON may summon Unique's
3952 * Note: None of the other summon codes will ever summon Unique's.
3954 * This function has been changed. We now take the "monster level"
3955 * of the summoning monster as a parameter, and use that, along with
3956 * the current dungeon level, to help determine the level of the
3957 * desired monster. Note that this is an upper bound, and also
3958 * tends to "prefer" monsters of that level. Currently, we use
3959 * the average of the dungeon and monster levels, and then add
3960 * five to allow slight increases in monster power.
3962 * Note that we use the new "monster allocation table" creation code
3963 * to restrict the "get_mon_num()" function to the set of "legal"
3964 * monsters, making this function much faster and more reliable.
3966 * Note that this function may not succeed, though this is very rare.
3968 bool summon_specific(int who, int y1, int x1, int lev, int type, u32b mode)
3972 if (p_ptr->inside_arena) return (FALSE);
3974 if (!mon_scatter(&y, &x, y1, x1, 2)) return FALSE;
3976 /* Save the summoner */
3977 summon_specific_who = who;
3979 /* Save the "summon" type */
3980 summon_specific_type = type;
3982 summon_unique_okay = (mode & PM_ALLOW_UNIQUE) ? TRUE : FALSE;
3984 /* Prepare allocation table */
3985 get_mon_num_prep(summon_specific_okay, get_monster_hook2(y, x));
3987 /* Pick a monster, using the level calculation */
3988 r_idx = get_mon_num((dun_level + lev) / 2 + 5);
3990 /* Handle failure */
3993 summon_specific_type = 0;
3997 if ((type == SUMMON_BLUE_HORROR) || (type == SUMMON_DAWN)) mode |= PM_NO_KAGE;
3999 /* Attempt to place the monster (awake, allow groups) */
4000 if (!place_monster_aux(who, y, x, r_idx, mode))
4002 summon_specific_type = 0;
4006 summon_specific_type = 0;
4011 /* A "dangerous" function, creates a pet of the specified type */
4012 bool summon_named_creature (int who, int oy, int ox, int r_idx, u32b mode)
4017 /* if (!r_idx) return; */
4019 /* Prevent illegal monsters */
4020 if (r_idx >= max_r_idx) return FALSE;
4022 if (p_ptr->inside_arena) return FALSE;
4024 if (!mon_scatter(&y, &x, oy, ox, 2)) return FALSE;
4026 /* Place it (allow groups) */
4027 return place_monster_aux(who, y, x, r_idx, (mode | PM_NO_KAGE));
4032 * Let the given monster attempt to reproduce.
4034 * Note that "reproduction" REQUIRES empty space.
4036 bool multiply_monster(int m_idx, bool clone, u32b mode)
4038 monster_type *m_ptr = &m_list[m_idx];
4042 if (!mon_scatter(&y, &x, m_ptr->fy, m_ptr->fx, 1))
4045 if (m_ptr->mflag2 & MFLAG2_NOPET) mode |= PM_NO_PET;
4047 /* Create a new monster (awake, no groups) */
4048 if (!place_monster_aux(m_idx, y, x, m_ptr->r_idx, (mode | PM_NO_KAGE)))
4051 /* Hack -- Transfer "clone" flag */
4052 if (clone || (m_ptr->smart & SM_CLONED))
4054 m_list[hack_m_idx_ii].smart |= SM_CLONED;
4055 m_list[hack_m_idx_ii].mflag2 |= MFLAG2_NOPET;
4058 /* Hack -- Shadower spawns Shadower */
4059 if (m_ptr->mflag2 & MFLAG2_KAGE) m_list[hack_m_idx_ii].mflag2 |= MFLAG2_KAGE;
4061 /* Hack -- Appearance transfer */
4062 if (!is_original_ap(m_ptr)) m_list[hack_m_idx_ii].ap_r_idx = m_ptr->ap_r_idx;
4072 * Dump a message describing a monster's reaction to damage
4074 * Technically should attempt to treat "Beholder"'s as jelly's
4076 void message_pain(int m_idx, int dam)
4078 long oldhp, newhp, tmp;
4081 monster_type *m_ptr = &m_list[m_idx];
4082 monster_race *r_ptr = &r_info[m_ptr->r_idx];
4087 /* Get the monster name */
4088 monster_desc(m_name, m_ptr, 0);
4090 /* Notice non-damage */
4094 msg_format("%^s¤Ï¥À¥á¡¼¥¸¤ò¼õ¤±¤Æ¤¤¤Ê¤¤¡£", m_name);
4096 msg_format("%^s is unharmed.", m_name);
4102 /* Note -- subtle fix -CFT */
4103 newhp = (long)(m_ptr->hp);
4104 oldhp = newhp + (long)(dam);
4105 tmp = (newhp * 100L) / oldhp;
4106 percentage = (int)(tmp);
4109 /* Mushrooms, Eyes, Jellies, Molds, Vortices, Worms, Quylthulgs */
4110 if (strchr(",ejmvwQ", r_ptr->d_char))
4113 if (percentage > 95)
4114 msg_format("%^s¤Ï¤Û¤È¤ó¤Éµ¤¤Ë¤È¤á¤Æ¤¤¤Ê¤¤¡£", m_name);
4115 else if (percentage > 75)
4116 msg_format("%^s¤Ï¤·¤ê¹þ¤ß¤·¤¿¡£", m_name);
4117 else if (percentage > 50)
4118 msg_format("%^s¤Ï½Ì¤³¤Þ¤Ã¤¿¡£", m_name);
4119 else if (percentage > 35)
4120 msg_format("%^s¤ÏÄˤߤ˿̤¨¤¿¡£", m_name);
4121 else if (percentage > 20)
4122 msg_format("%^s¤Ï¿È¤â¤À¤¨¤·¤¿¡£", m_name);
4123 else if (percentage > 10)
4124 msg_format("%^s¤Ï¶ìÄˤǿȤâ¤À¤¨¤·¤¿¡£", m_name);
4126 msg_format("%^s¤Ï¤°¤Ë¤ã¤°¤Ë¤ã¤ÈáÛÚ»¤·¤¿¡£", m_name);
4128 if (percentage > 95)
4129 msg_format("%^s barely notices.", m_name);
4130 else if (percentage > 75)
4131 msg_format("%^s flinches.", m_name);
4132 else if (percentage > 50)
4133 msg_format("%^s squelches.", m_name);
4134 else if (percentage > 35)
4135 msg_format("%^s quivers in pain.", m_name);
4136 else if (percentage > 20)
4137 msg_format("%^s writhes about.", m_name);
4138 else if (percentage > 10)
4139 msg_format("%^s writhes in agony.", m_name);
4141 msg_format("%^s jerks limply.", m_name);
4148 else if (strchr("l", r_ptr->d_char))
4150 if (percentage > 95)
4152 msg_format("%^s¤Ï¤Û¤È¤ó¤Éµ¤¤Ë¤È¤á¤Æ¤¤¤Ê¤¤¡£", m_name);
4154 msg_format("%^s barely notices.", m_name);
4156 else if (percentage > 75)
4158 msg_format("%^s¤Ï¤·¤ê¹þ¤ß¤·¤¿¡£", m_name);
4160 msg_format("%^s flinches.", m_name);
4162 else if (percentage > 50)
4164 msg_format("%^s¤Ïí´í°¤·¤¿¡£", m_name);
4166 msg_format("%^s hesitates.", m_name);
4168 else if (percentage > 35)
4170 msg_format("%^s¤ÏÄˤߤ˿̤¨¤¿¡£", m_name);
4172 msg_format("%^s quivers in pain.", m_name);
4174 else if (percentage > 20)
4176 msg_format("%^s¤Ï¿È¤â¤À¤¨¤·¤¿¡£", m_name);
4178 msg_format("%^s writhes about.", m_name);
4180 else if (percentage > 10)
4182 msg_format("%^s¤Ï¶ìÄˤǿȤâ¤À¤¨¤·¤¿¡£", m_name);
4184 msg_format("%^s writhes in agony.", m_name);
4188 msg_format("%^s¤Ï¤°¤Ë¤ã¤°¤Ë¤ã¤ÈáÛÚ»¤·¤¿¡£", m_name);
4190 msg_format("%^s jerks limply.", m_name);
4195 /* Golems, Walls, Doors, Stairs */
4196 else if (strchr("g#+<>", r_ptr->d_char))
4198 if (percentage > 95)
4200 msg_format("%s¤Ï¹¶·â¤òµ¤¤Ë¤È¤á¤Æ¤¤¤Ê¤¤¡£", m_name);
4202 msg_format("%^s ignores the attack.", m_name);
4204 else if (percentage > 75)
4206 msg_format("%s¤Ï¹¶·â¤Ë¸ª¤ò¤¹¤¯¤á¤¿¡£", m_name);
4208 msg_format("%^s shrugs off the attack.", m_name);
4210 else if (percentage > 50)
4212 msg_format("%^s¤ÏÍëÌĤΤ褦¤ËËʤ¨¤¿¡£", m_name);
4214 msg_format("%^s roars thunderously.", m_name);
4216 else if (percentage > 35)
4218 msg_format("%^s¤Ï¶ì¤·¤²¤ËËʤ¨¤¿¡£", m_name);
4220 msg_format("%^s rumbles.", m_name);
4222 else if (percentage > 20)
4224 msg_format("%^s¤Ï¤¦¤á¤¤¤¿¡£", m_name);
4226 msg_format("%^s grunts.", m_name);
4228 else if (percentage > 10)
4230 msg_format("%^s¤Ïí´í°¤·¤¿¡£", m_name);
4232 msg_format("%^s hesitates.", m_name);
4236 msg_format("%^s¤Ï¤¯¤·¤ã¤¯¤·¤ã¤Ë¤Ê¤Ã¤¿¡£", m_name);
4238 msg_format("%^s crumples.", m_name);
4243 /* Snakes, Hydrae, Reptiles, Mimics */
4244 else if (strchr("JMR", r_ptr->d_char) || !isalpha(r_ptr->d_char))
4246 if (percentage > 95)
4248 msg_format("%^s¤Ï¤Û¤È¤ó¤Éµ¤¤Ë¤È¤á¤Æ¤¤¤Ê¤¤¡£", m_name);
4250 msg_format("%^s barely notices.", m_name);
4252 else if (percentage > 75)
4254 msg_format("%^s¤Ï¥·¡¼¥Ã¤ÈÌĤ¤¤¿¡£", m_name);
4256 msg_format("%^s hisses.", m_name);
4258 else if (percentage > 50)
4260 msg_format("%^s¤ÏÅܤäÆƬ¤ò¾å¤²¤¿¡£", m_name);
4262 msg_format("%^s rears up in anger.", m_name);
4264 else if (percentage > 35)
4266 msg_format("%^s¤ÏÌÔÁ³¤È°Ò³Å¤·¤¿¡£", m_name);
4268 msg_format("%^s hisses furiously.", m_name);
4270 else if (percentage > 20)
4272 msg_format("%^s¤Ï¿È¤â¤À¤¨¤·¤¿¡£", m_name);
4274 msg_format("%^s writhes about.", m_name);
4276 else if (percentage > 10)
4278 msg_format("%^s¤Ï¶ìÄˤǿȤâ¤À¤¨¤·¤¿¡£", m_name);
4280 msg_format("%^s writhes in agony.", m_name);
4284 msg_format("%^s¤Ï¤°¤Ë¤ã¤°¤Ë¤ã¤ÈáÛÚ»¤·¤¿¡£", m_name);
4286 msg_format("%^s jerks limply.", m_name);
4292 else if (strchr("f", r_ptr->d_char))
4294 if (percentage > 95)
4296 msg_format("%s¤Ï¹¶·â¤Ë¸ª¤ò¤¹¤¯¤á¤¿¡£", m_name);
4298 msg_format("%^s shrugs off the attack.", m_name);
4300 else if (percentage > 75)
4302 msg_format("%^s¤ÏËʤ¨¤¿¡£", m_name);
4304 msg_format("%^s roars.", m_name);
4306 else if (percentage > 50)
4308 msg_format("%^s¤ÏÅܤäÆËʤ¨¤¿¡£", m_name);
4310 msg_format("%^s growls angrily.", m_name);
4312 else if (percentage > 35)
4314 msg_format("%^s¤ÏÄˤߤǥ·¡¼¥Ã¤ÈÌĤ¤¤¿¡£", m_name);
4316 msg_format("%^s hisses with pain.", m_name);
4318 else if (percentage > 20)
4320 msg_format("%^s¤ÏÄˤߤǼ塹¤·¤¯ÌĤ¤¤¿¡£", m_name);
4322 msg_format("%^s mewls in pain.", m_name);
4324 else if (percentage > 10)
4326 msg_format("%^s¤Ï¶ìÄˤˤ¦¤á¤¤¤¿¡£", m_name);
4328 msg_format("%^s hisses in agony.", m_name);
4332 msg_format("%s¤Ï°¥¤ì¤ÊÌĤÀ¼¤ò½Ð¤·¤¿¡£", m_name);
4334 msg_format("%^s mewls pitifully.", m_name);
4339 /* Ants, Centipedes, Flies, Insects, Beetles, Spiders */
4340 else if (strchr("acFIKS", r_ptr->d_char))
4342 if (percentage > 95)
4344 msg_format("%s¤Ï¹¶·â¤òµ¤¤Ë¤È¤á¤Æ¤¤¤Ê¤¤¡£", m_name);
4346 msg_format("%^s ignores the attack.", m_name);
4348 else if (percentage > 75)
4350 msg_format("%^s¤Ï¥¡¼¥¡¼ÌĤ¤¤¿¡£", m_name);
4352 msg_format("%^s chitters.", m_name);
4355 else if (percentage > 50)
4357 msg_format("%^s¤Ï¥è¥í¥è¥íƨ¤²²ó¤Ã¤¿¡£", m_name);
4359 msg_format("%^s scuttles about.", m_name);
4362 else if (percentage > 35)
4364 msg_format("%^s¤Ï¤¦¤ë¤µ¤¯ÌĤ¤¤¿¡£", m_name);
4366 msg_format("%^s twitters.", m_name);
4369 else if (percentage > 20)
4371 msg_format("%^s¤ÏÄˤߤËáÛÚ»¤·¤¿¡£", m_name);
4373 msg_format("%^s jerks in pain.", m_name);
4376 else if (percentage > 10)
4378 msg_format("%^s¤Ï¶ìÄˤÇáÛÚ»¤·¤¿¡£", m_name);
4380 msg_format("%^s jerks in agony.", m_name);
4385 msg_format("%^s¤Ï¥Ô¥¯¥Ô¥¯¤Ò¤¤Ä¤Ã¤¿¡£", m_name);
4387 msg_format("%^s twitches.", m_name);
4394 else if (strchr("B", r_ptr->d_char))
4396 if (percentage > 95)
4398 msg_format("%^s¤Ï¤µ¤¨¤º¤Ã¤¿¡£", m_name);
4400 msg_format("%^s chirps.", m_name);
4403 else if (percentage > 75)
4405 msg_format("%^s¤Ï¥Ô¡¼¥Ô¡¼ÌĤ¤¤¿¡£", m_name);
4407 msg_format("%^s twitters.", m_name);
4410 else if (percentage > 50)
4412 msg_format("%^s¤Ï¥®¥ã¡¼¥®¥ã¡¼ÌĤ¤¤¿¡£", m_name);
4414 msg_format("%^s squawks.", m_name);
4417 else if (percentage > 35)
4419 msg_format("%^s¤Ï¥®¥ã¡¼¥®¥ã¡¼ÌĤ¤ï¤á¤¤¤¿¡£", m_name);
4421 msg_format("%^s chatters.", m_name);
4424 else if (percentage > 20)
4426 msg_format("%^s¤Ï¶ì¤·¤ó¤À¡£", m_name);
4428 msg_format("%^s jeers.", m_name);
4431 else if (percentage > 10)
4433 msg_format("%^s¤Ï¤Î¤¿¤¦¤Á²ó¤Ã¤¿¡£", m_name);
4435 msg_format("%^s flutters about.", m_name);
4440 msg_format("%^s¤Ï¥¡¼¥¡¼¤ÈÌĤ¶«¤ó¤À¡£", m_name);
4442 msg_format("%^s squeaks.", m_name);
4448 /* Dragons, Demons, High Undead */
4449 else if (strchr("duDLUW", r_ptr->d_char))
4451 if (percentage > 95)
4453 msg_format("%s¤Ï¹¶·â¤òµ¤¤Ë¤È¤á¤Æ¤¤¤Ê¤¤¡£", m_name);
4455 msg_format("%^s ignores the attack.", m_name);
4458 else if (percentage > 75)
4460 msg_format("%^s¤Ï¤·¤ê¹þ¤ß¤·¤¿¡£", m_name);
4462 msg_format("%^s flinches.", m_name);
4465 else if (percentage > 50)
4467 msg_format("%^s¤ÏÄˤߤǥ·¡¼¥Ã¤ÈÌĤ¤¤¿¡£", m_name);
4469 msg_format("%^s hisses in pain.", m_name);
4472 else if (percentage > 35)
4474 msg_format("%^s¤ÏÄˤߤǤ¦¤Ê¤Ã¤¿¡£", m_name);
4476 msg_format("%^s snarls with pain.", m_name);
4479 else if (percentage > 20)
4481 msg_format("%^s¤ÏÄˤߤËËʤ¨¤¿¡£", m_name);
4483 msg_format("%^s roars with pain.", m_name);
4486 else if (percentage > 10)
4488 msg_format("%^s¤Ï¶ì¤·¤²¤Ë¶«¤ó¤À¡£", m_name);
4490 msg_format("%^s gasps.", m_name);
4495 msg_format("%^s¤Ï¼å¡¹¤·¤¯¤¦¤Ê¤Ã¤¿¡£", m_name);
4497 msg_format("%^s snarls feebly.", m_name);
4504 else if (strchr("s", r_ptr->d_char))
4506 if (percentage > 95)
4508 msg_format("%s¤Ï¹¶·â¤òµ¤¤Ë¤È¤á¤Æ¤¤¤Ê¤¤¡£", m_name);
4510 msg_format("%^s ignores the attack.", m_name);
4513 else if (percentage > 75)
4515 msg_format("%s¤Ï¹¶·â¤Ë¸ª¤ò¤¹¤¯¤á¤¿¡£", m_name);
4517 msg_format("%^s shrugs off the attack.", m_name);
4520 else if (percentage > 50)
4522 msg_format("%^s¤Ï¥«¥¿¥«¥¿¤È¾Ð¤Ã¤¿¡£", m_name);
4524 msg_format("%^s rattles.", m_name);
4527 else if (percentage > 35)
4529 msg_format("%^s¤Ï¤è¤í¤á¤¤¤¿¡£", m_name);
4531 msg_format("%^s stumbles.", m_name);
4534 else if (percentage > 20)
4536 msg_format("%^s¤Ï¥«¥¿¥«¥¿¸À¤Ã¤¿¡£", m_name);
4538 msg_format("%^s rattles.", m_name);
4541 else if (percentage > 10)
4543 msg_format("%^s¤Ï¤è¤í¤á¤¤¤¿¡£", m_name);
4545 msg_format("%^s staggers.", m_name);
4550 msg_format("%^s¤Ï¥¬¥¿¥¬¥¿¸À¤Ã¤¿¡£", m_name);
4552 msg_format("%^s clatters.", m_name);
4559 else if (strchr("z", r_ptr->d_char))
4561 if (percentage > 95)
4563 msg_format("%s¤Ï¹¶·â¤òµ¤¤Ë¤È¤á¤Æ¤¤¤Ê¤¤¡£", m_name);
4565 msg_format("%^s ignores the attack.", m_name);
4568 else if (percentage > 75)
4570 msg_format("%s¤Ï¹¶·â¤Ë¸ª¤ò¤¹¤¯¤á¤¿¡£", m_name);
4572 msg_format("%^s shrugs off the attack.", m_name);
4575 else if (percentage > 50)
4577 msg_format("%^s¤Ï¤¦¤á¤¤¤¿¡£", m_name);
4579 msg_format("%^s groans.", m_name);
4582 else if (percentage > 35)
4584 msg_format("%s¤Ï¶ì¤·¤²¤Ë¤¦¤á¤¤¤¿¡£", m_name);
4586 msg_format("%^s moans.", m_name);
4589 else if (percentage > 20)
4591 msg_format("%^s¤Ïí´í°¤·¤¿¡£", m_name);
4593 msg_format("%^s hesitates.", m_name);
4596 else if (percentage > 10)
4598 msg_format("%^s¤Ï¤¦¤Ê¤Ã¤¿¡£", m_name);
4600 msg_format("%^s grunts.", m_name);
4605 msg_format("%^s¤Ï¤è¤í¤á¤¤¤¿¡£", m_name);
4607 msg_format("%^s staggers.", m_name);
4614 else if (strchr("G", r_ptr->d_char))
4617 if (percentage > 95)
4619 msg_format("%s¤Ï¹¶·â¤òµ¤¤Ë¤È¤á¤Æ¤¤¤Ê¤¤¡£", m_name);
4621 msg_format("%^s ignores the attack.", m_name);
4624 else if (percentage > 75)
4626 msg_format("%s¤Ï¹¶·â¤Ë¸ª¤ò¤¹¤¯¤á¤¿¡£", m_name);
4628 msg_format("%^s shrugs off the attack.", m_name);
4631 else if (percentage > 50)
4633 msg_format("%s¤Ï¤¦¤á¤¤¤¿¡£", m_name);
4635 msg_format("%^s moans.", m_name);
4638 else if (percentage > 35)
4640 msg_format("%^s¤Ïµã¤¤ï¤á¤¤¤¿¡£", m_name);
4642 msg_format("%^s wails.", m_name);
4645 else if (percentage > 20)
4647 msg_format("%^s¤ÏËʤ¨¤¿¡£", m_name);
4649 msg_format("%^s howls.", m_name);
4652 else if (percentage > 10)
4654 msg_format("%s¤Ï¼å¡¹¤·¤¯¤¦¤á¤¤¤¿¡£", m_name);
4656 msg_format("%^s moans softly.", m_name);
4661 msg_format("%^s¤Ï¤«¤¹¤«¤Ë¤¦¤á¤¤¤¿¡£", m_name);
4663 msg_format("%^s sighs.", m_name);
4669 /* Dogs and Hounds */
4670 else if (strchr("CZ", r_ptr->d_char))
4673 if (percentage > 95)
4674 msg_format("%^s¤Ï¹¶·â¤Ë¸ª¤ò¤¹¤¯¤á¤¿¡£", m_name);
4675 else if (percentage > 75)
4676 msg_format("%^s¤ÏÄˤߤǤ¦¤Ê¤Ã¤¿¡£", m_name);
4677 else if (percentage > 50)
4678 msg_format("%^s¤ÏÄˤߤǥ¥ã¥ó¥¥ã¥óËʤ¨¤¿¡£", m_name);
4679 else if (percentage > 35)
4680 msg_format("%^s¤ÏÄˤߤÇÌĤ¤ï¤á¤¤¤¿¡£", m_name);
4681 else if (percentage > 20)
4682 msg_format("%^s¤Ï¶ìÄˤΤ¢¤Þ¤êÌĤ¤ï¤á¤¤¤¿¡£", m_name);
4683 else if (percentage > 10)
4684 msg_format("%^s¤Ï¶ìÄˤǤâ¤À¤¨¶ì¤·¤ó¤À¡£", m_name);
4686 msg_format("%^s¤Ï¼å¡¹¤·¤¯Ëʤ¨¤¿¡£", m_name);
4688 if (percentage > 95)
4689 msg_format("%^s shrugs off the attack.", m_name);
4690 else if (percentage > 75)
4691 msg_format("%^s snarls with pain.", m_name);
4692 else if (percentage > 50)
4693 msg_format("%^s yelps in pain.", m_name);
4694 else if (percentage > 35)
4695 msg_format("%^s howls in pain.", m_name);
4696 else if (percentage > 20)
4697 msg_format("%^s howls in agony.", m_name);
4698 else if (percentage > 10)
4699 msg_format("%^s writhes in agony.", m_name);
4701 msg_format("%^s yelps feebly.", m_name);
4706 /* One type of monsters (ignore,squeal,shriek) */
4707 else if (strchr("Xbilqrt", r_ptr->d_char))
4710 if (percentage > 95)
4711 msg_format("%^s¤Ï¹¶·â¤òµ¤¤Ë¤È¤á¤Æ¤¤¤Ê¤¤¡£", m_name);
4712 else if (percentage > 75)
4713 msg_format("%^s¤ÏÄˤߤǤ¦¤Ê¤Ã¤¿¡£", m_name);
4714 else if (percentage > 50)
4715 msg_format("%^s¤ÏÄˤߤǶ«¤ó¤À¡£", m_name);
4716 else if (percentage > 35)
4717 msg_format("%^s¤ÏÄˤߤÇÀ䶫¤·¤¿¡£", m_name);
4718 else if (percentage > 20)
4719 msg_format("%^s¤Ï¶ìÄˤΤ¢¤Þ¤êÀ䶫¤·¤¿¡£", m_name);
4720 else if (percentage > 10)
4721 msg_format("%^s¤Ï¶ìÄˤǤâ¤À¤¨¶ì¤·¤ó¤À¡£", m_name);
4723 msg_format("%^s¤Ï¼å¡¹¤·¤¯¶«¤ó¤À¡£", m_name);
4725 if (percentage > 95)
4726 msg_format("%^s ignores the attack.", m_name);
4727 else if (percentage > 75)
4728 msg_format("%^s grunts with pain.", m_name);
4729 else if (percentage > 50)
4730 msg_format("%^s squeals in pain.", m_name);
4731 else if (percentage > 35)
4732 msg_format("%^s shrieks in pain.", m_name);
4733 else if (percentage > 20)
4734 msg_format("%^s shrieks in agony.", m_name);
4735 else if (percentage > 10)
4736 msg_format("%^s writhes in agony.", m_name);
4738 msg_format("%^s cries out feebly.", m_name);
4743 /* Another type of monsters (shrug,cry,scream) */
4747 if (percentage > 95)
4748 msg_format("%^s¤Ï¹¶·â¤Ë¸ª¤ò¤¹¤¯¤á¤¿¡£", m_name);
4749 else if (percentage > 75)
4750 msg_format("%^s¤ÏÄˤߤǤ¦¤Ê¤Ã¤¿¡£", m_name);
4751 else if (percentage > 50)
4752 msg_format("%^s¤ÏÄˤߤǶ«¤ó¤À¡£", m_name);
4753 else if (percentage > 35)
4754 msg_format("%^s¤ÏÄˤߤÇÀ䶫¤·¤¿¡£", m_name);
4755 else if (percentage > 20)
4756 msg_format("%^s¤Ï¶ìÄˤΤ¢¤Þ¤êÀ䶫¤·¤¿¡£", m_name);
4757 else if (percentage > 10)
4758 msg_format("%^s¤Ï¶ìÄˤǤâ¤À¤¨¶ì¤·¤ó¤À¡£", m_name);
4760 msg_format("%^s¤Ï¼å¡¹¤·¤¯¶«¤ó¤À¡£", m_name);
4762 if (percentage > 95)
4763 msg_format("%^s shrugs off the attack.", m_name);
4764 else if (percentage > 75)
4765 msg_format("%^s grunts with pain.", m_name);
4766 else if (percentage > 50)
4767 msg_format("%^s cries out in pain.", m_name);
4768 else if (percentage > 35)
4769 msg_format("%^s screams in pain.", m_name);
4770 else if (percentage > 20)
4771 msg_format("%^s screams in agony.", m_name);
4772 else if (percentage > 10)
4773 msg_format("%^s writhes in agony.", m_name);
4775 msg_format("%^s cries out feebly.", m_name);
4783 * Learn about an "observed" resistance.
4785 void update_smart_learn(int m_idx, int what)
4787 monster_type *m_ptr = &m_list[m_idx];
4789 monster_race *r_ptr = &r_info[m_ptr->r_idx];
4792 /* Not allowed to learn */
4793 if (!smart_learn) return;
4795 /* Too stupid to learn anything */
4796 if (r_ptr->flags2 & (RF2_STUPID)) return;
4798 /* Not intelligent, only learn sometimes */
4799 if (!(r_ptr->flags2 & (RF2_SMART)) && (randint0(100) < 50)) return;
4804 /* Analyze the knowledge */
4808 if (p_ptr->resist_acid) m_ptr->smart |= (SM_RES_ACID);
4809 if (IS_OPPOSE_ACID()) m_ptr->smart |= (SM_OPP_ACID);
4810 if (p_ptr->immune_acid) m_ptr->smart |= (SM_IMM_ACID);
4814 if (p_ptr->resist_elec) m_ptr->smart |= (SM_RES_ELEC);
4815 if (IS_OPPOSE_ELEC()) m_ptr->smart |= (SM_OPP_ELEC);
4816 if (p_ptr->immune_elec) m_ptr->smart |= (SM_IMM_ELEC);
4820 if (p_ptr->resist_fire) m_ptr->smart |= (SM_RES_FIRE);
4821 if (IS_OPPOSE_FIRE()) m_ptr->smart |= (SM_OPP_FIRE);
4822 if (p_ptr->immune_fire) m_ptr->smart |= (SM_IMM_FIRE);
4826 if (p_ptr->resist_cold) m_ptr->smart |= (SM_RES_COLD);
4827 if (IS_OPPOSE_COLD()) m_ptr->smart |= (SM_OPP_COLD);
4828 if (p_ptr->immune_cold) m_ptr->smart |= (SM_IMM_COLD);
4832 if (p_ptr->resist_pois) m_ptr->smart |= (SM_RES_POIS);
4833 if (IS_OPPOSE_POIS()) m_ptr->smart |= (SM_OPP_POIS);
4838 if (p_ptr->resist_neth) m_ptr->smart |= (SM_RES_NETH);
4842 if (p_ptr->resist_lite) m_ptr->smart |= (SM_RES_LITE);
4846 if (p_ptr->resist_dark) m_ptr->smart |= (SM_RES_DARK);
4850 if (p_ptr->resist_fear) m_ptr->smart |= (SM_RES_FEAR);
4854 if (p_ptr->resist_conf) m_ptr->smart |= (SM_RES_CONF);
4858 if (p_ptr->resist_chaos) m_ptr->smart |= (SM_RES_CHAOS);
4862 if (p_ptr->resist_disen) m_ptr->smart |= (SM_RES_DISEN);
4866 if (p_ptr->resist_blind) m_ptr->smart |= (SM_RES_BLIND);
4870 if (p_ptr->resist_nexus) m_ptr->smart |= (SM_RES_NEXUS);
4874 if (p_ptr->resist_sound) m_ptr->smart |= (SM_RES_SOUND);
4878 if (p_ptr->resist_shard) m_ptr->smart |= (SM_RES_SHARD);
4882 if (p_ptr->free_act) m_ptr->smart |= (SM_IMM_FREE);
4886 if (!p_ptr->msp) m_ptr->smart |= (SM_IMM_MANA);
4890 if (p_ptr->reflect) m_ptr-> smart |= (SM_IMM_REFLECT);
4897 * Place the player in the dungeon XXX XXX
4899 bool player_place(int y, int x)
4901 /* Paranoia XXX XXX */
4902 if (cave[y][x].m_idx != 0) return FALSE;
4904 /* Save player location */
4914 * Drop all items carried by a monster
4916 void monster_drop_carried_objects(monster_type *m_ptr)
4918 s16b this_o_idx, next_o_idx = 0;
4924 /* Drop objects being carried */
4925 for (this_o_idx = m_ptr->hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
4927 /* Acquire object */
4928 o_ptr = &o_list[this_o_idx];
4930 /* Acquire next object */
4931 next_o_idx = o_ptr->next_o_idx;
4933 /* Get local object */
4936 /* Copy the object */
4937 object_copy(q_ptr, o_ptr);
4939 /* Forget monster */
4940 q_ptr->held_m_idx = 0;
4942 /* Delete the object */
4943 delete_object_idx(this_o_idx);
4946 (void)drop_near(q_ptr, -1, m_ptr->fy, m_ptr->fx);
4949 /* Forget objects */
4950 m_ptr->hold_o_idx = 0;