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--;
220 if (MON_CSLEEP(m_ptr)) (void)set_monster_csleep(i, 0);
221 if (MON_FAST(m_ptr)) (void)set_monster_fast(i, 0);
222 if (MON_SLOW(m_ptr)) (void)set_monster_slow(i, 0);
223 if (MON_STUNNED(m_ptr)) (void)set_monster_stunned(i, 0);
224 if (MON_CONFUSED(m_ptr)) (void)set_monster_confused(i, 0);
225 if (MON_MONFEAR(m_ptr)) (void)set_monster_monfear(i, 0);
226 if (MON_INVULNER(m_ptr)) (void)set_monster_invulner(i, 0, FALSE);
229 /* Hack -- remove target monster */
230 if (i == target_who) target_who = 0;
232 /* Hack -- remove tracked monster */
233 if (i == p_ptr->health_who) health_track(0);
235 if (pet_t_m_idx == i ) pet_t_m_idx = 0;
236 if (riding_t_m_idx == i) riding_t_m_idx = 0;
237 if (p_ptr->riding == i) p_ptr->riding = 0;
239 /* Monster is gone */
240 cave[y][x].m_idx = 0;
244 for (this_o_idx = m_ptr->hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
249 o_ptr = &o_list[this_o_idx];
251 /* Acquire next object */
252 next_o_idx = o_ptr->next_o_idx;
255 * o_ptr->held_m_idx is needed in delete_object_idx()
256 * to prevent calling lite_spot()
259 /* Delete the object */
260 delete_object_idx(this_o_idx);
264 if (is_pet(m_ptr)) check_pets_num_and_align(m_ptr, FALSE);
267 /* Wipe the Monster */
268 (void)WIPE(m_ptr, monster_type);
276 /* Update some things */
277 if (r_ptr->flags7 & (RF7_LITE_MASK | RF7_DARK_MASK))
278 p_ptr->update |= (PU_MON_LITE);
283 * Delete the monster, if any, at a given location
285 void delete_monster(int y, int x)
290 if (!in_bounds(y, x)) return;
295 /* Delete the monster (if any) */
296 if (c_ptr->m_idx) delete_monster_idx(c_ptr->m_idx);
301 * Move an object from index i1 to index i2 in the object list
303 static void compact_monsters_aux(int i1, int i2)
311 s16b this_o_idx, next_o_idx = 0;
315 if (i1 == i2) return;
328 /* Update the cave */
331 /* Repair objects being carried by monster */
332 for (this_o_idx = m_ptr->hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
337 o_ptr = &o_list[this_o_idx];
339 /* Acquire next object */
340 next_o_idx = o_ptr->next_o_idx;
342 /* Reset monster pointer */
343 o_ptr->held_m_idx = i2;
346 /* Hack -- Update the target */
347 if (target_who == i1) target_who = i2;
349 /* Hack -- Update the target */
350 if (pet_t_m_idx == i1) pet_t_m_idx = i2;
351 if (riding_t_m_idx == i1) riding_t_m_idx = i2;
353 /* Hack -- Update the riding */
354 if (p_ptr->riding == i1) p_ptr->riding = i2;
356 /* Hack -- Update the health bar */
357 if (p_ptr->health_who == i1) health_track(i2);
359 /* Hack -- Update parent index */
362 for (i = 1; i < m_max; i++)
364 monster_type *m2_ptr = &m_list[i];
366 if (m2_ptr->parent_m_idx == i1)
367 m2_ptr->parent_m_idx = i2;
372 (void)COPY(&m_list[i2], &m_list[i1], monster_type);
375 (void)WIPE(&m_list[i1], monster_type);
377 for (i = 0; i < MAX_MTIMED; i++)
379 int mproc_idx = get_mproc_idx(i1, i);
380 if (mproc_idx >= 0) mproc_list[i][mproc_idx] = i2;
386 * Compact and Reorder the monster list
388 * This function can be very dangerous, use with caution!
390 * When actually "compacting" monsters, we base the saving throw
391 * on a combination of monster level, distance from player, and
392 * current "desperation".
394 * After "compacting" (if needed), we "reorder" the monsters into a more
395 * compact order, and we reset the allocation info, and the "live" array.
397 void compact_monsters(int size)
400 int cur_lev, cur_dis, chance;
402 /* Message (only if compacting) */
404 if (size) msg_print("¥â¥ó¥¹¥¿¡¼¾ðÊó¤ò°µ½Ì¤·¤Æ¤¤¤Þ¤¹...");
406 if (size) msg_print("Compacting monsters...");
410 /* Compact at least 'size' objects */
411 for (num = 0, cnt = 1; num < size; cnt++)
413 /* Get more vicious each iteration */
416 /* Get closer each iteration */
417 cur_dis = 5 * (20 - cnt);
419 /* Check all the monsters */
420 for (i = 1; i < m_max; i++)
422 monster_type *m_ptr = &m_list[i];
424 monster_race *r_ptr = &r_info[m_ptr->r_idx];
426 /* Paranoia -- skip "dead" monsters */
427 if (!m_ptr->r_idx) continue;
429 /* Hack -- High level monsters start out "immune" */
430 if (r_ptr->level > cur_lev) continue;
432 if (i == p_ptr->riding) continue;
434 /* Ignore nearby monsters */
435 if ((cur_dis > 0) && (m_ptr->cdis < cur_dis)) continue;
437 /* Saving throw chance */
440 /* Only compact "Quest" Monsters in emergencies */
441 if ((r_ptr->flags1 & (RF1_QUESTOR)) && (cnt < 1000)) chance = 100;
443 /* Try not to compact Unique Monsters */
444 if (r_ptr->flags1 & (RF1_UNIQUE)) chance = 100;
446 /* All monsters get a saving throw */
447 if (randint0(100) < chance) continue;
449 if (record_named_pet && is_pet(m_ptr) && m_ptr->nickname)
453 monster_desc(m_name, m_ptr, MD_INDEF_VISIBLE);
454 do_cmd_write_nikki(NIKKI_NAMED_PET, RECORD_NAMED_PET_COMPACT, m_name);
457 /* Delete the monster */
458 delete_monster_idx(i);
460 /* Count the monster */
466 /* Excise dead monsters (backwards!) */
467 for (i = m_max - 1; i >= 1; i--)
469 /* Get the i'th monster */
470 monster_type *m_ptr = &m_list[i];
472 /* Skip real monsters */
473 if (m_ptr->r_idx) continue;
475 /* Move last monster into open hole */
476 compact_monsters_aux(m_max - 1, i);
478 /* Compress "m_max" */
485 * Delete/Remove all the monsters when the player leaves the level
487 * This is an efficient method of simulating multiple calls to the
488 * "delete_monster()" function, with no visual effects.
490 void wipe_m_list(void)
494 /* Hack -- if Banor or Lupart dies, stay another dead */
495 if (!r_info[MON_BANORLUPART].max_num)
497 if (r_info[MON_BANOR].max_num)
499 r_info[MON_BANOR].max_num = 0;
500 r_info[MON_BANOR].r_pkills++;
501 r_info[MON_BANOR].r_akills++;
502 if (r_info[MON_BANOR].r_tkills < MAX_SHORT) r_info[MON_BANOR].r_tkills++;
504 if (r_info[MON_LUPART].max_num)
506 r_info[MON_LUPART].max_num = 0;
507 r_info[MON_LUPART].r_pkills++;
508 r_info[MON_LUPART].r_akills++;
509 if (r_info[MON_LUPART].r_tkills < MAX_SHORT) r_info[MON_LUPART].r_tkills++;
513 /* Delete all the monsters */
514 for (i = m_max - 1; i >= 1; i--)
516 monster_type *m_ptr = &m_list[i];
518 /* Skip dead monsters */
519 if (!m_ptr->r_idx) continue;
521 /* Monster is gone */
522 cave[m_ptr->fy][m_ptr->fx].m_idx = 0;
524 /* Wipe the Monster */
525 (void)WIPE(m_ptr, monster_type);
530 * Wiping racial counters of all monsters and incrementing of racial
531 * counters of monsters in party_mon[] are required to prevent multiple
532 * generation of unique monster who is the minion of player.
535 /* Hack -- Wipe the racial counter of all monster races */
536 for (i = 1; i < max_r_idx; i++) r_info[i].cur_num = 0;
544 /* Reset "mproc_max[]" */
545 for (i = 0; i < MAX_MTIMED; i++) mproc_max[i] = 0;
547 /* Hack -- reset "reproducer" count */
550 /* Hack -- no more target */
555 /* Hack -- no more tracking */
561 * Acquires and returns the index of a "free" monster.
563 * This routine should almost never fail, but it *can* happen.
570 /* Normal allocation */
571 if (m_max < max_m_idx)
573 /* Access the next hole */
576 /* Expand the array */
582 /* Return the index */
587 /* Recycle dead monsters */
588 for (i = 1; i < m_max; i++)
592 /* Acquire monster */
595 /* Skip live monsters */
596 if (m_ptr->r_idx) continue;
601 /* Use this monster */
606 /* Warn the player (except during dungeon creation) */
608 if (character_dungeon) msg_print("¥â¥ó¥¹¥¿¡¼¤¬Â¿¤¹¤®¤ë¡ª");
610 if (character_dungeon) msg_print("Too many monsters!");
614 /* Try not to crash */
622 * Hack -- the "type" of the current "summon specific"
624 static int summon_specific_type = 0;
628 * Hack -- the index of the summoning monster
630 static int summon_specific_who = -1;
633 static bool summon_unique_okay = FALSE;
636 static bool summon_specific_aux(int r_idx)
638 monster_race *r_ptr = &r_info[r_idx];
641 /* Check our requirements */
642 switch (summon_specific_type)
646 okay = (r_ptr->d_char == 'a');
652 okay = (r_ptr->d_char == 'S');
658 okay = ((r_ptr->d_char == 'C') || (r_ptr->d_char == 'Z'));
664 okay = (r_ptr->d_char == 'M');
670 okay = (r_ptr->d_char == 'A' && ((r_ptr->flags3 & RF3_EVIL) || (r_ptr->flags3 & RF3_GOOD)));
676 okay = (r_ptr->flags3 & RF3_DEMON);
682 okay = (r_ptr->flags3 & RF3_UNDEAD);
688 okay = (r_ptr->flags3 & RF3_DRAGON);
692 case SUMMON_HI_UNDEAD:
694 okay = ((r_ptr->d_char == 'L') ||
695 (r_ptr->d_char == 'V') ||
696 (r_ptr->d_char == 'W'));
700 case SUMMON_HI_DRAGON:
702 okay = (r_ptr->d_char == 'D');
706 case SUMMON_HI_DEMON:
708 okay = (((r_ptr->d_char == 'U') ||
709 (r_ptr->d_char == 'H') ||
710 (r_ptr->d_char == 'B')) &&
711 (r_ptr->flags3 & RF3_DEMON)) ? TRUE : FALSE;
715 case SUMMON_AMBERITES:
717 okay = (r_ptr->flags3 & (RF3_AMBERITE)) ? TRUE : FALSE;
723 okay = (r_ptr->flags1 & (RF1_UNIQUE)) ? TRUE : FALSE;
727 case SUMMON_BIZARRE1:
729 okay = (r_ptr->d_char == 'm');
732 case SUMMON_BIZARRE2:
734 okay = (r_ptr->d_char == 'b');
737 case SUMMON_BIZARRE3:
739 okay = (r_ptr->d_char == 'Q');
743 case SUMMON_BIZARRE4:
745 okay = (r_ptr->d_char == 'v');
749 case SUMMON_BIZARRE5:
751 okay = (r_ptr->d_char == '$');
755 case SUMMON_BIZARRE6:
757 okay = ((r_ptr->d_char == '!') ||
758 (r_ptr->d_char == '?') ||
759 (r_ptr->d_char == '=') ||
760 (r_ptr->d_char == '$') ||
761 (r_ptr->d_char == '|'));
767 okay = (r_ptr->d_char == 'g');
773 okay = ((r_ptr->d_char == 'U') &&
774 (r_ptr->flags4 & RF4_ROCKET));
781 okay = ((r_ptr->d_char == summon_kin_type) && (r_idx != MON_HAGURE));
787 okay = (r_idx == MON_DAWN);
793 okay = (r_ptr->flags3 & (RF3_ANIMAL));
797 case SUMMON_ANIMAL_RANGER:
799 okay = ((r_ptr->flags3 & (RF3_ANIMAL)) &&
800 (my_strchr("abcflqrwBCHIJKMRS", r_ptr->d_char)) &&
801 !(r_ptr->flags3 & (RF3_DRAGON)) &&
802 !(r_ptr->flags3 & (RF3_EVIL)) &&
803 !(r_ptr->flags3 & (RF3_UNDEAD)) &&
804 !(r_ptr->flags3 & (RF3_DEMON)) &&
805 !(r_ptr->flags2 & (RF2_MULTIPLY)) &&
806 !(r_ptr->flags4 || r_ptr->flags5 || r_ptr->flags6));
810 case SUMMON_HI_DRAGON_LIVING:
812 okay = ((r_ptr->d_char == 'D') && monster_living(r_ptr));
818 okay = monster_living(r_ptr);
824 okay = (r_idx == MON_PHANTOM_B || r_idx == MON_PHANTOM_W);
828 case SUMMON_BLUE_HORROR:
830 okay = (r_idx == MON_BLUE_HORROR);
834 case SUMMON_ELEMENTAL:
836 okay = (r_ptr->d_char == 'E');
842 okay = (r_ptr->d_char == 'v');
848 okay = (r_ptr->d_char == 'H');
854 okay = (r_ptr->d_char == 'B');
858 case SUMMON_KAMIKAZE:
861 for (i = 0; i < 4; i++)
862 if (r_ptr->blow[i].method == RBM_EXPLODE) okay = TRUE;
866 case SUMMON_KAMIKAZE_LIVING:
870 for (i = 0; i < 4; i++)
871 if (r_ptr->blow[i].method == RBM_EXPLODE) okay = TRUE;
872 okay = (okay && monster_living(r_ptr));
878 okay = (r_idx == MON_MANES);
884 okay = (r_idx == MON_LOUSE);
888 case SUMMON_GUARDIANS:
890 okay = (r_ptr->flags7 & RF7_GUARDIAN);
896 okay = ((r_idx == MON_NOV_PALADIN) ||
897 (r_idx == MON_NOV_PALADIN_G) ||
898 (r_idx == MON_PALADIN) ||
899 (r_idx == MON_W_KNIGHT) ||
900 (r_idx == MON_ULTRA_PALADIN) ||
901 (r_idx == MON_KNI_TEMPLAR));
907 okay = (r_ptr->d_char == 'B' &&
908 (r_ptr->flags8 & RF8_WILD_MOUNTAIN) &&
909 (r_ptr->flags8 & RF8_WILD_ONLY));
913 case SUMMON_PIRANHAS:
915 okay = (r_idx == MON_PIRANHA);
919 case SUMMON_ARMAGE_GOOD:
921 okay = (r_ptr->d_char == 'A' && (r_ptr->flags3 & RF3_GOOD));
925 case SUMMON_ARMAGE_EVIL:
927 okay = ((r_ptr->flags3 & RF3_DEMON) ||
928 (r_ptr->d_char == 'A' && (r_ptr->flags3 & RF3_EVIL)));
934 /* Since okay is int, "return (okay);" is not correct. */
935 return (bool)(okay ? TRUE : FALSE);
939 static int chameleon_change_m_idx = 0;
943 * Some dungeon types restrict the possible monsters.
944 * Return TRUE is the monster is OK and FALSE otherwise
946 static bool restrict_monster_to_dungeon(int r_idx)
948 dungeon_info_type *d_ptr = &d_info[dungeon_type];
949 monster_race *r_ptr = &r_info[r_idx];
952 if (d_ptr->flags1 & DF1_CHAMELEON)
954 if (chameleon_change_m_idx) return TRUE;
956 if (d_ptr->flags1 & DF1_NO_MAGIC)
958 if (r_idx != MON_CHAMELEON &&
960 !(r_ptr->flags4 & RF4_NOMAGIC_MASK) &&
961 !(r_ptr->flags5 & RF5_NOMAGIC_MASK) &&
962 !(r_ptr->flags6 & RF6_NOMAGIC_MASK))
965 if (d_ptr->flags1 & DF1_NO_MELEE)
967 if (r_idx == MON_CHAMELEON) return TRUE;
968 if (!(r_ptr->flags4 & (RF4_BOLT_MASK | RF4_BEAM_MASK | RF4_BALL_MASK)) &&
969 !(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)) &&
970 !(r_ptr->flags6 & (RF6_BOLT_MASK | RF6_BEAM_MASK | RF6_BALL_MASK)))
973 if (d_ptr->flags1 & DF1_BEGINNER)
975 if (r_ptr->level > dun_level)
979 if (d_ptr->special_div >= 64) return TRUE;
980 if (summon_specific_type && !(d_ptr->flags1 & DF1_CHAMELEON)) return TRUE;
984 case DUNGEON_MODE_AND:
987 if ((d_ptr->mflags1 & r_ptr->flags1) != d_ptr->mflags1)
992 if ((d_ptr->mflags2 & r_ptr->flags2) != d_ptr->mflags2)
997 if ((d_ptr->mflags3 & r_ptr->flags3) != d_ptr->mflags3)
1002 if ((d_ptr->mflags4 & r_ptr->flags4) != d_ptr->mflags4)
1007 if ((d_ptr->mflags5 & r_ptr->flags5) != d_ptr->mflags5)
1012 if ((d_ptr->mflags6 & r_ptr->flags6) != d_ptr->mflags6)
1017 if ((d_ptr->mflags7 & r_ptr->flags7) != d_ptr->mflags7)
1022 if ((d_ptr->mflags8 & r_ptr->flags8) != d_ptr->mflags8)
1027 if ((d_ptr->mflags9 & r_ptr->flags9) != d_ptr->mflags9)
1032 if ((d_ptr->mflagsr & r_ptr->flagsr) != d_ptr->mflagsr)
1035 for (a = 0; a < 5; a++)
1036 if (d_ptr->r_char[a] && (d_ptr->r_char[a] != r_ptr->d_char)) return FALSE;
1040 case DUNGEON_MODE_NAND:
1043 if ((d_ptr->mflags1 & r_ptr->flags1) != d_ptr->mflags1)
1048 if ((d_ptr->mflags2 & r_ptr->flags2) != d_ptr->mflags2)
1053 if ((d_ptr->mflags3 & r_ptr->flags3) != d_ptr->mflags3)
1058 if ((d_ptr->mflags4 & r_ptr->flags4) != d_ptr->mflags4)
1063 if ((d_ptr->mflags5 & r_ptr->flags5) != d_ptr->mflags5)
1068 if ((d_ptr->mflags6 & r_ptr->flags6) != d_ptr->mflags6)
1073 if ((d_ptr->mflags7 & r_ptr->flags7) != d_ptr->mflags7)
1078 if ((d_ptr->mflags8 & r_ptr->flags8) != d_ptr->mflags8)
1083 if ((d_ptr->mflags9 & r_ptr->flags9) != d_ptr->mflags9)
1088 if ((d_ptr->mflagsr & r_ptr->flagsr) != d_ptr->mflagsr)
1091 for (a = 0; a < 5; a++)
1092 if (d_ptr->r_char[a] && (d_ptr->r_char[a] != r_ptr->d_char)) return TRUE;
1096 case DUNGEON_MODE_OR:
1097 if (r_ptr->flags1 & d_ptr->mflags1) return TRUE;
1098 if (r_ptr->flags2 & d_ptr->mflags2) return TRUE;
1099 if (r_ptr->flags3 & d_ptr->mflags3) return TRUE;
1100 if (r_ptr->flags4 & d_ptr->mflags4) return TRUE;
1101 if (r_ptr->flags5 & d_ptr->mflags5) return TRUE;
1102 if (r_ptr->flags6 & d_ptr->mflags6) return TRUE;
1103 if (r_ptr->flags7 & d_ptr->mflags7) return TRUE;
1104 if (r_ptr->flags8 & d_ptr->mflags8) return TRUE;
1105 if (r_ptr->flags9 & d_ptr->mflags9) return TRUE;
1106 if (r_ptr->flagsr & d_ptr->mflagsr) return TRUE;
1107 for (a = 0; a < 5; a++)
1108 if (d_ptr->r_char[a] == r_ptr->d_char) return TRUE;
1112 case DUNGEON_MODE_NOR:
1113 if (r_ptr->flags1 & d_ptr->mflags1) return FALSE;
1114 if (r_ptr->flags2 & d_ptr->mflags2) return FALSE;
1115 if (r_ptr->flags3 & d_ptr->mflags3) return FALSE;
1116 if (r_ptr->flags4 & d_ptr->mflags4) return FALSE;
1117 if (r_ptr->flags5 & d_ptr->mflags5) return FALSE;
1118 if (r_ptr->flags6 & d_ptr->mflags6) return FALSE;
1119 if (r_ptr->flags7 & d_ptr->mflags7) return FALSE;
1120 if (r_ptr->flags8 & d_ptr->mflags8) return FALSE;
1121 if (r_ptr->flags9 & d_ptr->mflags9) return FALSE;
1122 if (r_ptr->flagsr & d_ptr->mflagsr) return FALSE;
1123 for (a = 0; a < 5; a++)
1124 if (d_ptr->r_char[a] == r_ptr->d_char) return FALSE;
1133 * Apply a "monster restriction function" to the "monster allocation table"
1135 errr get_mon_num_prep(monster_hook_type monster_hook,
1136 monster_hook_type monster_hook2)
1140 /* Todo: Check the hooks for non-changes */
1142 /* Set the new hooks */
1143 get_mon_num_hook = monster_hook;
1144 get_mon_num2_hook = monster_hook2;
1146 /* Scan the allocation table */
1147 for (i = 0; i < alloc_race_size; i++)
1149 monster_race *r_ptr;
1152 alloc_entry *entry = &alloc_race_table[i];
1155 r_ptr = &r_info[entry->index];
1157 /* Skip monsters which don't pass the restriction */
1158 if ((get_mon_num_hook && !((*get_mon_num_hook)(entry->index))) ||
1159 (get_mon_num2_hook && !((*get_mon_num2_hook)(entry->index))))
1162 if (!p_ptr->inside_battle && !chameleon_change_m_idx &&
1163 summon_specific_type != SUMMON_GUARDIANS)
1165 /* Hack -- don't create questors */
1166 if (r_ptr->flags1 & RF1_QUESTOR)
1169 if (r_ptr->flags7 & RF7_GUARDIAN)
1172 /* Depth Monsters never appear out of depth */
1173 if ((r_ptr->flags1 & (RF1_FORCE_DEPTH)) &&
1174 (r_ptr->level > dun_level))
1178 /* Accept this monster */
1179 entry->prob2 = entry->prob1;
1181 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)
1183 int hoge = entry->prob2 * d_info[dungeon_type].special_div;
1184 entry->prob2 = hoge / 64;
1185 if (randint0(64) < (hoge & 0x3f)) entry->prob2++;
1194 static int mysqrt(int n)
1232 * Choose a monster race that seems "appropriate" to the given level
1234 * This function uses the "prob2" field of the "monster allocation table",
1235 * and various local information, to calculate the "prob3" field of the
1236 * same table, which is then used to choose an "appropriate" monster, in
1237 * a relatively efficient manner.
1239 * Note that "town" monsters will *only* be created in the town, and
1240 * "normal" monsters will *never* be created in the town, unless the
1241 * "level" is "modified", for example, by polymorph or summoning.
1243 * There is a small chance (1/50) of "boosting" the given depth by
1244 * a small amount (up to four levels), except in the town.
1246 * It is (slightly) more likely to acquire a monster of the given level
1247 * than one of a lower level. This is done by choosing several monsters
1248 * appropriate to the given level and keeping the "hardest" one.
1250 * Note that if no monsters are "appropriate", then this function will
1251 * fail, and return zero, but this should *almost* never happen.
1253 s16b get_mon_num(int level)
1258 monster_race *r_ptr;
1259 alloc_entry *table = alloc_race_table;
1261 int pls_kakuritu, pls_level;
1262 int hoge = mysqrt(level*10000L);
1264 if (level > MAX_DEPTH - 1) level = MAX_DEPTH - 1;
1266 pls_kakuritu = MAX(NASTY_MON_MAX, NASTY_MON_BASE - ((dungeon_turn / (TURNS_PER_TICK * 2500L) - hoge / 10)));
1267 pls_level = MIN(NASTY_MON_PLUS_MAX, 3 + dungeon_turn / (TURNS_PER_TICK * 20000L) - hoge / 40 + MIN(5, level / 10)) ;
1269 if (d_info[dungeon_type].flags1 & DF1_MAZE)
1271 pls_kakuritu = MIN(pls_kakuritu / 2, pls_kakuritu - 10);
1272 if (pls_kakuritu < 2) pls_kakuritu = 2;
1277 /* Boost the level */
1278 if (!p_ptr->inside_battle && !(d_info[dungeon_type].flags1 & DF1_BEGINNER))
1280 /* Nightmare mode allows more out-of depth monsters */
1281 if (ironman_nightmare && !randint0(pls_kakuritu))
1283 /* What a bizarre calculation */
1284 level = 1 + (level * MAX_DEPTH / randint1(MAX_DEPTH));
1288 /* Occasional "nasty" monster */
1289 if (!randint0(pls_kakuritu))
1291 /* Pick a level bonus */
1300 /* Process probabilities */
1301 for (i = 0; i < alloc_race_size; i++)
1303 /* Monsters are sorted by depth */
1304 if (table[i].level > level) break;
1309 /* Access the "r_idx" of the chosen monster */
1310 r_idx = table[i].index;
1312 /* Access the actual race */
1313 r_ptr = &r_info[r_idx];
1315 if (!p_ptr->inside_battle && !chameleon_change_m_idx)
1317 /* Hack -- "unique" monsters must be "unique" */
1318 if (((r_ptr->flags1 & (RF1_UNIQUE)) ||
1319 (r_ptr->flags7 & (RF7_NAZGUL))) &&
1320 (r_ptr->cur_num >= r_ptr->max_num))
1325 if ((r_ptr->flags7 & (RF7_UNIQUE2)) &&
1326 (r_ptr->cur_num >= 1))
1331 if (r_idx == MON_BANORLUPART)
1333 if (r_info[MON_BANOR].cur_num > 0) continue;
1334 if (r_info[MON_LUPART].cur_num > 0) continue;
1339 table[i].prob3 = table[i].prob2;
1342 total += table[i].prob3;
1345 /* No legal monsters */
1346 if (total <= 0) return (0);
1348 /* Pick a monster */
1349 value = randint0(total);
1351 /* Find the monster */
1352 for (i = 0; i < alloc_race_size; i++)
1354 /* Found the entry */
1355 if (value < table[i].prob3) break;
1358 value = value - table[i].prob3;
1364 /* Try for a "harder" monster once (50%) or twice (10%) */
1370 /* Pick a monster */
1371 value = randint0(total);
1373 /* Find the monster */
1374 for (i = 0; i < alloc_race_size; i++)
1376 /* Found the entry */
1377 if (value < table[i].prob3) break;
1380 value = value - table[i].prob3;
1383 /* Keep the "best" one */
1384 if (table[i].level < table[j].level) i = j;
1387 /* Try for a "harder" monster twice (10%) */
1393 /* Pick a monster */
1394 value = randint0(total);
1396 /* Find the monster */
1397 for (i = 0; i < alloc_race_size; i++)
1399 /* Found the entry */
1400 if (value < table[i].prob3) break;
1403 value = value - table[i].prob3;
1406 /* Keep the "best" one */
1407 if (table[i].level < table[j].level) i = j;
1411 return (table[i].index);
1419 * Build a string describing a monster in some way.
1421 * We can correctly describe monsters based on their visibility.
1422 * We can force all monsters to be treated as visible or invisible.
1423 * We can build nominatives, objectives, possessives, or reflexives.
1424 * We can selectively pronominalize hidden, visible, or all monsters.
1425 * We can use definite or indefinite descriptions for hidden monsters.
1426 * We can use definite or indefinite descriptions for visible monsters.
1428 * Pronominalization involves the gender whenever possible and allowed,
1429 * so that by cleverly requesting pronominalization / visibility, you
1430 * can get messages like "You hit someone. She screams in agony!".
1432 * Reflexives are acquired by requesting Objective plus Possessive.
1434 * If no m_ptr arg is given (?), the monster is assumed to be hidden,
1435 * unless the "Assume Visible" mode is requested.
1437 * If no r_ptr arg is given, it is extracted from m_ptr and r_info
1438 * If neither m_ptr nor r_ptr is given, the monster is assumed to
1439 * be neuter, singular, and hidden (unless "Assume Visible" is set),
1440 * in which case you may be in trouble... :-)
1442 * I am assuming that no monster name is more than 70 characters long,
1443 * so that "char desc[80];" is sufficiently large for any result.
1446 * MD_OBJECTIVE --> Objective (or Reflexive)
1447 * MD_POSSESSIVE --> Possessive (or Reflexive)
1448 * MD_INDEF_HIDDEN --> Use indefinites for hidden monsters ("something")
1449 * MD_INDEF_VISIBLE --> Use indefinites for visible monsters ("a kobold")
1450 * MD_PRON_HIDDEN --> Pronominalize hidden monsters
1451 * MD_PRON_VISIBLE --> Pronominalize visible monsters
1452 * MD_ASSUME_HIDDEN --> Assume the monster is hidden
1453 * MD_ASSUME_VISIBLE --> Assume the monster is visible
1454 * MD_TRUE_NAME --> Chameleon's true name
1455 * MD_IGNORE_HALLU --> Ignore hallucination, and penetrate shape change
1458 * 0x00 --> Full nominative name ("the kobold") or "it"
1459 * MD_INDEF_HIDDEN --> Full nominative name ("the kobold") or "something"
1460 * MD_ASSUME_VISIBLE --> Genocide resistance name ("the kobold")
1461 * MD_ASSUME_VISIBLE | MD_INDEF_VISIBLE --> Killing name ("a kobold")
1462 * MD_PRON_VISIBLE | MD_POSSESSIVE
1463 * --> Possessive, genderized if visable ("his") or "its"
1464 * MD_PRON_VISIBLE | MD_POSSESSIVE | MD_OBJECTIVE
1465 * --> Reflexive, genderized if visable ("himself") or "itself"
1467 void monster_desc(char *desc, monster_type *m_ptr, int mode)
1470 monster_race *r_ptr;
1474 char silly_name[1024];
1478 r_ptr = &r_info[m_ptr->ap_r_idx];
1480 /* Mode of MD_TRUE_NAME will reveal Chameleon's true name */
1481 if (mode & MD_TRUE_NAME) name = (r_name + real_r_ptr(m_ptr)->name);
1482 else name = (r_name + r_ptr->name);
1484 /* Are we hallucinating? (Idea from Nethack...) */
1485 if (p_ptr->image && !(mode & MD_IGNORE_HALLU))
1490 if (!get_rnd_line("silly_j.txt", m_ptr->r_idx, silly_name))
1492 if (!get_rnd_line("silly.txt", m_ptr->r_idx, silly_name))
1500 monster_race *hallu_race;
1504 hallu_race = &r_info[randint1(max_r_idx - 1)];
1506 while (!hallu_race->name || (hallu_race->flags1 & RF1_UNIQUE));
1508 strcpy(silly_name, (r_name + hallu_race->name));
1511 /* Better not strcpy it, or we could corrupt r_info... */
1515 /* Can we "see" it (exists + forced, or visible + not unforced) */
1516 seen = (m_ptr && ((mode & MD_ASSUME_VISIBLE) || (!(mode & MD_ASSUME_HIDDEN) && m_ptr->ml)));
1518 /* Sexed Pronouns (seen and allowed, or unseen and allowed) */
1519 pron = (m_ptr && ((seen && (mode & MD_PRON_VISIBLE)) || (!seen && (mode & MD_PRON_HIDDEN))));
1522 /* First, try using pronouns, or describing hidden monsters */
1525 /* an encoding of the monster "sex" */
1528 /* Extract the gender (if applicable) */
1529 if (r_ptr->flags1 & (RF1_FEMALE)) kind = 0x20;
1530 else if (r_ptr->flags1 & (RF1_MALE)) kind = 0x10;
1532 /* Ignore the gender (if desired) */
1533 if (!m_ptr || !pron) kind = 0x00;
1536 /* Assume simple result */
1544 /* Brute force: split on the possibilities */
1545 switch (kind + (mode & (MD_INDEF_HIDDEN | MD_POSSESSIVE | MD_OBJECTIVE)))
1547 /* Neuter, or unknown */
1549 case 0x00: res = "²¿¤«"; break;
1550 case 0x00 + (MD_OBJECTIVE): res = "²¿¤«"; break;
1551 case 0x00 + (MD_POSSESSIVE): res = "²¿¤«¤Î"; break;
1552 case 0x00 + (MD_POSSESSIVE | MD_OBJECTIVE): res = "²¿¤«¼«¿È"; break;
1553 case 0x00 + (MD_INDEF_HIDDEN): res = "²¿¤«"; break;
1554 case 0x00 + (MD_INDEF_HIDDEN | MD_OBJECTIVE): res = "²¿¤«"; break;
1555 case 0x00 + (MD_INDEF_HIDDEN | MD_POSSESSIVE): res = "²¿¤«"; break;
1556 case 0x00 + (MD_INDEF_HIDDEN | MD_POSSESSIVE | MD_OBJECTIVE): res = "¤½¤ì¼«¿È"; break;
1558 case 0x00: res = "it"; break;
1559 case 0x00 + (MD_OBJECTIVE): res = "it"; break;
1560 case 0x00 + (MD_POSSESSIVE): res = "its"; break;
1561 case 0x00 + (MD_POSSESSIVE | MD_OBJECTIVE): res = "itself"; break;
1562 case 0x00 + (MD_INDEF_HIDDEN): res = "something"; break;
1563 case 0x00 + (MD_INDEF_HIDDEN | MD_OBJECTIVE): res = "something"; break;
1564 case 0x00 + (MD_INDEF_HIDDEN | MD_POSSESSIVE): res = "something's"; break;
1565 case 0x00 + (MD_INDEF_HIDDEN | MD_POSSESSIVE | MD_OBJECTIVE): res = "itself"; break;
1569 /* Male (assume human if vague) */
1571 case 0x10: res = "Èà"; break;
1572 case 0x10 + (MD_OBJECTIVE): res = "Èà"; break;
1573 case 0x10 + (MD_POSSESSIVE): res = "Èà¤Î"; break;
1574 case 0x10 + (MD_POSSESSIVE | MD_OBJECTIVE): res = "È༫¿È"; break;
1575 case 0x10 + (MD_INDEF_HIDDEN): res = "狼"; break;
1576 case 0x10 + (MD_INDEF_HIDDEN | MD_OBJECTIVE): res = "狼"; break;
1577 case 0x10 + (MD_INDEF_HIDDEN | MD_POSSESSIVE): res = "狼¤Î"; break;
1578 case 0x10 + (MD_INDEF_HIDDEN | MD_POSSESSIVE | MD_OBJECTIVE): res = "È༫¿È"; break;
1580 case 0x10: res = "he"; break;
1581 case 0x10 + (MD_OBJECTIVE): res = "him"; break;
1582 case 0x10 + (MD_POSSESSIVE): res = "his"; break;
1583 case 0x10 + (MD_POSSESSIVE | MD_OBJECTIVE): res = "himself"; break;
1584 case 0x10 + (MD_INDEF_HIDDEN): res = "someone"; break;
1585 case 0x10 + (MD_INDEF_HIDDEN | MD_OBJECTIVE): res = "someone"; break;
1586 case 0x10 + (MD_INDEF_HIDDEN | MD_POSSESSIVE): res = "someone's"; break;
1587 case 0x10 + (MD_INDEF_HIDDEN | MD_POSSESSIVE | MD_OBJECTIVE): res = "himself"; break;
1591 /* Female (assume human if vague) */
1593 case 0x20: res = "Èà½÷"; break;
1594 case 0x20 + (MD_OBJECTIVE): res = "Èà½÷"; break;
1595 case 0x20 + (MD_POSSESSIVE): res = "Èà½÷¤Î"; break;
1596 case 0x20 + (MD_POSSESSIVE | MD_OBJECTIVE): res = "Èà½÷¼«¿È"; break;
1597 case 0x20 + (MD_INDEF_HIDDEN): res = "狼"; break;
1598 case 0x20 + (MD_INDEF_HIDDEN | MD_OBJECTIVE): res = "狼"; break;
1599 case 0x20 + (MD_INDEF_HIDDEN | MD_POSSESSIVE): res = "狼¤Î"; break;
1600 case 0x20 + (MD_INDEF_HIDDEN | MD_POSSESSIVE | MD_OBJECTIVE): res = "Èà½÷¼«¿È"; break;
1602 case 0x20: res = "she"; break;
1603 case 0x20 + (MD_OBJECTIVE): res = "her"; break;
1604 case 0x20 + (MD_POSSESSIVE): res = "her"; break;
1605 case 0x20 + (MD_POSSESSIVE | MD_OBJECTIVE): res = "herself"; break;
1606 case 0x20 + (MD_INDEF_HIDDEN): res = "someone"; break;
1607 case 0x20 + (MD_INDEF_HIDDEN | MD_OBJECTIVE): res = "someone"; break;
1608 case 0x20 + (MD_INDEF_HIDDEN | MD_POSSESSIVE): res = "someone's"; break;
1609 case 0x20 + (MD_INDEF_HIDDEN | MD_POSSESSIVE | MD_OBJECTIVE): res = "herself"; break;
1613 /* Copy the result */
1614 (void)strcpy(desc, res);
1618 /* Handle visible monsters, "reflexive" request */
1619 else if ((mode & (MD_POSSESSIVE | MD_OBJECTIVE)) == (MD_POSSESSIVE | MD_OBJECTIVE))
1621 /* The monster is visible, so use its gender */
1623 if (r_ptr->flags1 & (RF1_FEMALE)) strcpy(desc, "Èà½÷¼«¿È");
1624 else if (r_ptr->flags1 & (RF1_MALE)) strcpy(desc, "È༫¿È");
1625 else strcpy(desc, "¤½¤ì¼«¿È");
1627 if (r_ptr->flags1 & RF1_FEMALE) strcpy(desc, "herself");
1628 else if (r_ptr->flags1 & RF1_MALE) strcpy(desc, "himself");
1629 else strcpy(desc, "itself");
1634 /* Handle all other visible monster requests */
1638 if (is_pet(m_ptr) && !is_original_ap(m_ptr))
1644 while(strncmp(t, "¡Ù", 2) && *t) t++;
1648 (void)sprintf(desc, "%s¡©¡Ù", buf);
1651 (void)sprintf(desc, "%s¡©", name);
1653 (void)sprintf(desc, "%s?", name);
1658 /* It could be a Unique */
1659 if ((r_ptr->flags1 & RF1_UNIQUE) && !(p_ptr->image && !(mode & MD_IGNORE_HALLU)))
1661 /* Start with the name (thus nominative and objective) */
1662 if ((m_ptr->mflag2 & MFLAG2_CHAMELEON) && !(mode & MD_TRUE_NAME))
1668 while (strncmp(t, "¡Ù", 2) && *t) t++;
1672 (void)sprintf(desc, "%s¡©¡Ù", buf);
1675 (void)sprintf(desc, "%s¡©", name);
1677 (void)sprintf(desc, "%s?", name);
1681 /* Inside monster arena, and it is not your mount */
1682 else if (p_ptr->inside_battle &&
1683 !(p_ptr->riding && (&m_list[p_ptr->riding] == m_ptr)))
1685 /* It is a fake unique monster */
1687 (void)sprintf(desc, "%s¤â¤É¤", name);
1689 (void)sprintf(desc, "fake %s", name);
1695 (void)strcpy(desc, name);
1699 /* It could be an indefinite monster */
1700 else if (mode & MD_INDEF_VISIBLE)
1702 /* XXX Check plurality for "some" */
1704 /* Indefinite monsters need an indefinite article */
1706 (void)strcpy(desc, "");
1708 (void)strcpy(desc, is_a_vowel(name[0]) ? "an " : "a ");
1711 (void)strcat(desc, name);
1714 /* It could be a normal, definite, monster */
1717 /* Definite monsters need a definite article */
1720 (void)strcpy(desc, "¤¢¤Ê¤¿¤Î");
1722 (void)strcpy(desc, "your ");
1727 (void)strcpy(desc, "");
1729 (void)strcpy(desc, "the ");
1732 (void)strcat(desc, name);
1735 if (m_ptr->nickname)
1738 sprintf(buf,"¡Ö%s¡×",quark_str(m_ptr->nickname));
1740 sprintf(buf," called %s",quark_str(m_ptr->nickname));
1745 if (p_ptr->riding && (&m_list[p_ptr->riding] == m_ptr))
1748 strcat(desc,"(¾èÇÏÃæ)");
1750 strcat(desc,"(riding)");
1754 if ((mode & MD_IGNORE_HALLU) && (m_ptr->mflag2 & MFLAG2_CHAMELEON))
1756 if (r_ptr->flags1 & RF1_UNIQUE)
1759 strcat(desc,"(¥«¥á¥ì¥ª¥ó¤Î²¦)");
1761 strcat(desc,"(Chameleon Lord)");
1767 strcat(desc,"(¥«¥á¥ì¥ª¥ó)");
1769 strcat(desc,"(Chameleon)");
1774 if ((mode & MD_IGNORE_HALLU) && !is_original_ap(m_ptr))
1776 strcat(desc, format("(%s)", r_name + r_info[m_ptr->r_idx].name));
1779 /* Handle the Possessive as a special afterthought */
1780 if (mode & MD_POSSESSIVE)
1782 /* XXX Check for trailing "s" */
1784 /* Simply append "apostrophe" and "s" */
1786 (void)strcat(desc, "¤Î");
1788 (void)strcat(desc, "'s");
1798 * Learn about a monster (by "probing" it)
1800 * Return the number of new flags learnt. -Mogami-
1802 int lore_do_probe(int r_idx)
1804 monster_race *r_ptr = &r_info[r_idx];
1808 /* Maximal info about awareness */
1809 if (r_ptr->r_wake != MAX_UCHAR) n++;
1810 if (r_ptr->r_ignore != MAX_UCHAR) n++;
1811 r_ptr->r_wake = r_ptr->r_ignore = MAX_UCHAR;
1813 /* Observe "maximal" attacks */
1814 for (i = 0; i < 4; i++)
1816 /* Examine "actual" blows */
1817 if (r_ptr->blow[i].effect || r_ptr->blow[i].method)
1819 /* Maximal observations */
1820 if (r_ptr->r_blows[i] != MAX_UCHAR) n++;
1821 r_ptr->r_blows[i] = MAX_UCHAR;
1827 (((r_ptr->flags1 & RF1_DROP_4D2) ? 8 : 0) +
1828 ((r_ptr->flags1 & RF1_DROP_3D2) ? 6 : 0) +
1829 ((r_ptr->flags1 & RF1_DROP_2D2) ? 4 : 0) +
1830 ((r_ptr->flags1 & RF1_DROP_1D2) ? 2 : 0) +
1831 ((r_ptr->flags1 & RF1_DROP_90) ? 1 : 0) +
1832 ((r_ptr->flags1 & RF1_DROP_60) ? 1 : 0));
1834 /* Only "valid" drops */
1835 if (!(r_ptr->flags1 & RF1_ONLY_GOLD))
1837 if (r_ptr->r_drop_item != tmp_byte) n++;
1838 r_ptr->r_drop_item = tmp_byte;
1840 if (!(r_ptr->flags1 & RF1_ONLY_ITEM))
1842 if (r_ptr->r_drop_gold != tmp_byte) n++;
1843 r_ptr->r_drop_gold = tmp_byte;
1846 /* Observe many spells */
1847 if (r_ptr->r_cast_spell != MAX_UCHAR) n++;
1848 r_ptr->r_cast_spell = MAX_UCHAR;
1850 /* Count unknown flags */
1851 for (i = 0; i < 32; i++)
1853 if (!(r_ptr->r_flags1 & (1L << i)) &&
1854 (r_ptr->flags1 & (1L << i))) n++;
1855 if (!(r_ptr->r_flags2 & (1L << i)) &&
1856 (r_ptr->flags2 & (1L << i))) n++;
1857 if (!(r_ptr->r_flags3 & (1L << i)) &&
1858 (r_ptr->flags3 & (1L << i))) n++;
1859 if (!(r_ptr->r_flags4 & (1L << i)) &&
1860 (r_ptr->flags4 & (1L << i))) n++;
1861 if (!(r_ptr->r_flags5 & (1L << i)) &&
1862 (r_ptr->flags5 & (1L << i))) n++;
1863 if (!(r_ptr->r_flags6 & (1L << i)) &&
1864 (r_ptr->flags6 & (1L << i))) n++;
1865 if (!(r_ptr->r_flagsr & (1L << i)) &&
1866 (r_ptr->flagsr & (1L << i))) n++;
1868 /* r_flags7 is actually unused */
1870 if (!(r_ptr->r_flags7 & (1L << i)) &&
1871 (r_ptr->flags7 & (1L << i))) n++;
1875 /* Know all the flags */
1876 r_ptr->r_flags1 = r_ptr->flags1;
1877 r_ptr->r_flags2 = r_ptr->flags2;
1878 r_ptr->r_flags3 = r_ptr->flags3;
1879 r_ptr->r_flags4 = r_ptr->flags4;
1880 r_ptr->r_flags5 = r_ptr->flags5;
1881 r_ptr->r_flags6 = r_ptr->flags6;
1882 r_ptr->r_flagsr = r_ptr->flagsr;
1884 /* r_flags7 is actually unused */
1885 /* r_ptr->r_flags7 = r_ptr->flags7; */
1887 /* Know about evolution */
1888 if (!(r_ptr->r_xtra1 & MR1_SINKA)) n++;
1889 r_ptr->r_xtra1 |= MR1_SINKA;
1891 /* Update monster recall window */
1892 if (p_ptr->monster_race_idx == r_idx)
1895 p_ptr->window |= (PW_MONSTER);
1898 /* Return the number of new flags learnt */
1904 * Take note that the given monster just dropped some treasure
1906 * Note that learning the "GOOD"/"GREAT" flags gives information
1907 * about the treasure (even when the monster is killed for the first
1908 * time, such as uniques, and the treasure has not been examined yet).
1910 * This "indirect" method is used to prevent the player from learning
1911 * exactly how much treasure a monster can drop from observing only
1912 * a single example of a drop. This method actually observes how much
1913 * gold and items are dropped, and remembers that information to be
1914 * described later by the monster recall code.
1916 void lore_treasure(int m_idx, int num_item, int num_gold)
1918 monster_type *m_ptr = &m_list[m_idx];
1920 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1922 /* If the monster doesn't have original appearance, don't note */
1923 if (!is_original_ap(m_ptr)) return;
1925 /* Note the number of things dropped */
1926 if (num_item > r_ptr->r_drop_item) r_ptr->r_drop_item = num_item;
1927 if (num_gold > r_ptr->r_drop_gold) r_ptr->r_drop_gold = num_gold;
1929 /* Hack -- memorize the good/great flags */
1930 if (r_ptr->flags1 & (RF1_DROP_GOOD)) r_ptr->r_flags1 |= (RF1_DROP_GOOD);
1931 if (r_ptr->flags1 & (RF1_DROP_GREAT)) r_ptr->r_flags1 |= (RF1_DROP_GREAT);
1933 /* Update monster recall window */
1934 if (p_ptr->monster_race_idx == m_ptr->r_idx)
1937 p_ptr->window |= (PW_MONSTER);
1943 void sanity_blast(monster_type *m_ptr, bool necro)
1945 bool happened = FALSE;
1948 if (p_ptr->inside_battle || !character_dungeon) return;
1953 monster_race *r_ptr = &r_info[m_ptr->ap_r_idx];
1955 power = r_ptr->level / 2;
1957 monster_desc(m_name, m_ptr, 0);
1959 if (!(r_ptr->flags1 & RF1_UNIQUE))
1961 if (r_ptr->flags1 & RF1_FRIENDS)
1967 return; /* No effect yet, just loaded... */
1970 return; /* Cannot see it for some reason */
1972 if (!(r_ptr->flags2 & RF2_ELDRITCH_HORROR))
1978 return; /* Pet eldritch horrors are safe most of the time */
1980 if (randint1(100) > power) return;
1982 if (saving_throw(p_ptr->skill_sav - power))
1984 return; /* Save, no adverse effects */
1989 /* Something silly happens... */
1991 msg_format("%s%s¤Î´é¤ò¸«¤Æ¤·¤Þ¤Ã¤¿¡ª",
1992 funny_desc[randint0(MAX_SAN_FUNNY)], m_name);
1994 msg_format("You behold the %s visage of %s!",
1995 funny_desc[randint0(MAX_SAN_FUNNY)], m_name);
2001 msg_print(funny_comments[randint0(MAX_SAN_COMMENT)]);
2002 p_ptr->image = p_ptr->image + randint1(r_ptr->level);
2005 return; /* Never mind; we can't see it clearly enough */
2008 /* Something frightening happens... */
2010 msg_format("%s%s¤Î´é¤ò¸«¤Æ¤·¤Þ¤Ã¤¿¡ª",
2011 horror_desc[randint0(MAX_SAN_HORROR)], m_name);
2013 msg_format("You behold the %s visage of %s!",
2014 horror_desc[randint0(MAX_SAN_HORROR)], m_name);
2017 r_ptr->r_flags2 |= RF2_ELDRITCH_HORROR;
2019 /* Demon characters are unaffected */
2020 if (prace_is_(RACE_IMP) || prace_is_(RACE_DEMON) || (mimic_info[p_ptr->mimic_form].MIMIC_FLAGS & MIMIC_IS_DEMON)) return;
2021 if (p_ptr->wizard) return;
2023 /* Undead characters are 50% likely to be unaffected */
2024 if (prace_is_(RACE_SKELETON) || prace_is_(RACE_ZOMBIE)
2025 || prace_is_(RACE_VAMPIRE) || prace_is_(RACE_SPECTRE) ||
2026 (mimic_info[p_ptr->mimic_form].MIMIC_FLAGS & MIMIC_IS_UNDEAD))
2028 if (saving_throw(25 + p_ptr->lev)) return;
2034 msg_print("¥Í¥¯¥í¥Î¥ß¥³¥ó¤òÆɤó¤ÇÀµµ¤¤ò¼º¤Ã¤¿¡ª");
2036 msg_print("Your sanity is shaken by reading the Necronomicon!");
2041 if (!saving_throw(p_ptr->skill_sav - power)) /* Mind blast */
2043 if (!p_ptr->resist_conf)
2045 (void)set_confused(p_ptr->confused + randint0(4) + 4);
2047 if (!p_ptr->resist_chaos && one_in_(3))
2049 (void)set_image(p_ptr->image + randint0(250) + 150);
2054 if (!saving_throw(p_ptr->skill_sav - power)) /* Lose int & wis */
2061 if (!saving_throw(p_ptr->skill_sav - power)) /* Brain smash */
2063 if (!p_ptr->resist_conf)
2065 (void)set_confused(p_ptr->confused + randint0(4) + 4);
2067 if (!p_ptr->free_act)
2069 (void)set_paralyzed(p_ptr->paralyzed + randint0(4) + 4);
2071 while (randint0(100) > p_ptr->skill_sav)
2072 (void)do_dec_stat(A_INT);
2073 while (randint0(100) > p_ptr->skill_sav)
2074 (void)do_dec_stat(A_WIS);
2075 if (!p_ptr->resist_chaos)
2077 (void)set_image(p_ptr->image + randint0(250) + 150);
2082 if (!saving_throw(p_ptr->skill_sav - power)) /* Amnesia */
2085 if (lose_all_info())
2087 msg_print("¤¢¤Þ¤ê¤Î¶²ÉݤËÁ´¤Æ¤Î¤³¤È¤ò˺¤ì¤Æ¤·¤Þ¤Ã¤¿¡ª");
2089 msg_print("You forget everything in your utmost terror!");
2095 if (saving_throw(p_ptr->skill_sav - power))
2100 /* Else gain permanent insanity */
2101 if ((p_ptr->muta3 & MUT3_MORONIC) && /*(p_ptr->muta2 & MUT2_BERS_RAGE) &&*/
2102 ((p_ptr->muta2 & MUT2_COWARDICE) || (p_ptr->resist_fear)) &&
2103 ((p_ptr->muta2 & MUT2_HALLU) || (p_ptr->resist_chaos)))
2105 /* The poor bastard already has all possible insanities! */
2111 switch (randint1(21))
2114 if (!(p_ptr->muta3 & MUT3_MORONIC) && one_in_(5))
2116 if ((p_ptr->stat_use[A_INT] < 4) && (p_ptr->stat_use[A_WIS] < 4))
2119 msg_print("¤¢¤Ê¤¿¤Ï´°àú¤ÊÇϼ¯¤Ë¤Ê¤Ã¤¿¤è¤¦¤Êµ¤¤¬¤·¤¿¡£¤·¤«¤·¤½¤ì¤Ï¸µ¡¹¤À¤Ã¤¿¡£");
2121 msg_print("You turn into an utter moron!");
2127 msg_print("¤¢¤Ê¤¿¤Ï´°àú¤ÊÇϼ¯¤Ë¤Ê¤Ã¤¿¡ª");
2129 msg_print("You turn into an utter moron!");
2133 if (p_ptr->muta3 & MUT3_HYPER_INT)
2136 msg_print("¤¢¤Ê¤¿¤ÎǾ¤ÏÀ¸ÂÎ¥³¥ó¥Ô¥å¡¼¥¿¤Ç¤Ï¤Ê¤¯¤Ê¤Ã¤¿¡£");
2138 msg_print("Your brain is no longer a living computer.");
2141 p_ptr->muta3 &= ~(MUT3_HYPER_INT);
2143 p_ptr->muta3 |= MUT3_MORONIC;
2157 if (!(p_ptr->muta2 & MUT2_COWARDICE) && !p_ptr->resist_fear)
2160 msg_print("¤¢¤Ê¤¿¤Ï¥Ñ¥é¥Î¥¤¥¢¤Ë¤Ê¤Ã¤¿¡ª");
2162 msg_print("You become paranoid!");
2166 /* Duh, the following should never happen, but anyway... */
2167 if (p_ptr->muta3 & MUT3_FEARLESS)
2170 msg_print("¤¢¤Ê¤¿¤Ï¤â¤¦¶²¤ìÃΤ餺¤Ç¤Ï¤Ê¤¯¤Ê¤Ã¤¿¡£");
2172 msg_print("You are no longer fearless.");
2175 p_ptr->muta3 &= ~(MUT3_FEARLESS);
2178 p_ptr->muta2 |= MUT2_COWARDICE;
2192 if (!(p_ptr->muta2 & MUT2_HALLU) && !p_ptr->resist_chaos)
2195 msg_print("¸¸³Ð¤ò¤Ò¤µ¯¤³¤¹Àº¿ÀºøÍð¤Ë´Ù¤Ã¤¿¡ª");
2197 msg_print("You are afflicted by a hallucinatory insanity!");
2200 p_ptr->muta2 |= MUT2_HALLU;
2205 if (!(p_ptr->muta2 & MUT2_BERS_RAGE))
2208 msg_print("·ãÎõ¤Ê´¶¾ð¤Îȯºî¤Ë¤ª¤½¤ï¤ì¤ë¤è¤¦¤Ë¤Ê¤Ã¤¿¡ª");
2210 msg_print("You become subject to fits of berserk rage!");
2213 p_ptr->muta2 |= MUT2_BERS_RAGE;
2220 p_ptr->update |= PU_BONUS;
2226 * This function updates the monster record of the given monster
2228 * This involves extracting the distance to the player (if requested),
2229 * and then checking for visibility (natural, infravision, see-invis,
2230 * telepathy), updating the monster visibility flag, redrawing (or
2231 * erasing) the monster when its visibility changes, and taking note
2232 * of any interesting monster flags (cold-blooded, invisible, etc).
2234 * Note the new "mflag" field which encodes several monster state flags,
2235 * including "view" for when the monster is currently in line of sight,
2236 * and "mark" for when the monster is currently visible via detection.
2238 * The only monster fields that are changed here are "cdis" (the
2239 * distance from the player), "ml" (visible to the player), and
2240 * "mflag" (to maintain the "MFLAG_VIEW" flag).
2242 * Note the special "update_monsters()" function which can be used to
2243 * call this function once for every monster.
2245 * Note the "full" flag which requests that the "cdis" field be updated,
2246 * this is only needed when the monster (or the player) has moved.
2248 * Every time a monster moves, we must call this function for that
2249 * monster, and update the distance, and the visibility. Every time
2250 * the player moves, we must call this function for every monster, and
2251 * update the distance, and the visibility. Whenever the player "state"
2252 * changes in certain ways ("blindness", "infravision", "telepathy",
2253 * and "see invisible"), we must call this function for every monster,
2254 * and update the visibility.
2256 * Routines that change the "illumination" of a grid must also call this
2257 * function for any monster in that grid, since the "visibility" of some
2258 * monsters may be based on the illumination of their grid.
2260 * Note that this function is called once per monster every time the
2261 * player moves. When the player is running, this function is one
2262 * of the primary bottlenecks, along with "update_view()" and the
2263 * "process_monsters()" code, so efficiency is important.
2265 * Note the optimized "inline" version of the "distance()" function.
2267 * A monster is "visible" to the player if (1) it has been detected
2268 * by the player, (2) it is close to the player and the player has
2269 * telepathy, or (3) it is close to the player, and in line of sight
2270 * of the player, and it is "illuminated" by some combination of
2271 * infravision, torch light, or permanent light (invisible monsters
2272 * are only affected by "light" if the player can see invisible).
2274 * Monsters which are not on the current panel may be "visible" to
2275 * the player, and their descriptions will include an "offscreen"
2276 * reference. Currently, offscreen monsters cannot be targetted
2277 * or viewed directly, but old targets will remain set. XXX XXX
2279 * The player can choose to be disturbed by several things, including
2280 * "disturb_move" (monster which is viewable moves in some way), and
2281 * "disturb_near" (monster which is "easily" viewable moves in some
2282 * way). Note that "moves" includes "appears" and "disappears".
2284 void update_mon(int m_idx, bool full)
2286 monster_type *m_ptr = &m_list[m_idx];
2288 monster_race *r_ptr = &r_info[m_ptr->r_idx];
2290 bool do_disturb = disturb_move;
2294 /* Current location */
2301 /* Seen by vision */
2304 /* Non-Ninja player in the darkness */
2305 bool in_darkness = (d_info[dungeon_type].flags1 & DF1_DARKNESS) && !p_ptr->see_nocto;
2310 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
2312 if (ap_r_ptr->r_tkills && ap_r_ptr->level >= p_ptr->lev)
2316 /* Compute distance */
2319 /* Distance components */
2320 int dy = (py > fy) ? (py - fy) : (fy - py);
2321 int dx = (px > fx) ? (px - fx) : (fx - px);
2323 /* Approximate distance */
2324 d = (dy > dx) ? (dy + (dx>>1)) : (dx + (dy>>1));
2326 /* Restrict distance */
2327 if (d > 255) d = 255;
2331 /* Save the distance */
2335 /* Extract distance */
2338 /* Extract the distance */
2344 if (m_ptr->mflag2 & (MFLAG2_MARK)) flag = TRUE;
2348 if (d <= (in_darkness ? MAX_SIGHT / 2 : MAX_SIGHT))
2350 if (!in_darkness || (d <= MAX_SIGHT / 4))
2352 if (p_ptr->special_defense & KATA_MUSOU)
2357 if (is_original_ap(m_ptr) && !p_ptr->image)
2359 /* Hack -- Memorize mental flags */
2360 if (r_ptr->flags2 & (RF2_SMART)) r_ptr->r_flags2 |= (RF2_SMART);
2361 if (r_ptr->flags2 & (RF2_STUPID)) r_ptr->r_flags2 |= (RF2_STUPID);
2365 /* Basic telepathy */
2366 /* Snipers get telepathy when they concentrate deeper */
2367 else if (p_ptr->telepathy)
2369 /* Empty mind, no telepathy */
2370 if (r_ptr->flags2 & (RF2_EMPTY_MIND))
2372 /* Memorize flags */
2373 if (is_original_ap(m_ptr) && !p_ptr->image) r_ptr->r_flags2 |= (RF2_EMPTY_MIND);
2376 /* Weird mind, occasional telepathy */
2377 else if (r_ptr->flags2 & (RF2_WEIRD_MIND))
2379 /* One in ten individuals are detectable */
2380 if ((m_idx % 10) == 5)
2385 if (is_original_ap(m_ptr) && !p_ptr->image)
2387 /* Memorize flags */
2388 r_ptr->r_flags2 |= (RF2_WEIRD_MIND);
2390 /* Hack -- Memorize mental flags */
2391 if (r_ptr->flags2 & (RF2_SMART)) r_ptr->r_flags2 |= (RF2_SMART);
2392 if (r_ptr->flags2 & (RF2_STUPID)) r_ptr->r_flags2 |= (RF2_STUPID);
2397 /* Normal mind, allow telepathy */
2403 if (is_original_ap(m_ptr) && !p_ptr->image)
2405 /* Hack -- Memorize mental flags */
2406 if (r_ptr->flags2 & (RF2_SMART)) r_ptr->r_flags2 |= (RF2_SMART);
2407 if (r_ptr->flags2 & (RF2_STUPID)) r_ptr->r_flags2 |= (RF2_STUPID);
2412 /* Magical sensing */
2413 if ((p_ptr->esp_animal) && (r_ptr->flags3 & (RF3_ANIMAL)))
2416 if (is_original_ap(m_ptr) && !p_ptr->image) r_ptr->r_flags3 |= (RF3_ANIMAL);
2419 /* Magical sensing */
2420 if ((p_ptr->esp_undead) && (r_ptr->flags3 & (RF3_UNDEAD)))
2423 if (is_original_ap(m_ptr) && !p_ptr->image) r_ptr->r_flags3 |= (RF3_UNDEAD);
2426 /* Magical sensing */
2427 if ((p_ptr->esp_demon) && (r_ptr->flags3 & (RF3_DEMON)))
2430 if (is_original_ap(m_ptr) && !p_ptr->image) r_ptr->r_flags3 |= (RF3_DEMON);
2433 /* Magical sensing */
2434 if ((p_ptr->esp_orc) && (r_ptr->flags3 & (RF3_ORC)))
2437 if (is_original_ap(m_ptr) && !p_ptr->image) r_ptr->r_flags3 |= (RF3_ORC);
2440 /* Magical sensing */
2441 if ((p_ptr->esp_troll) && (r_ptr->flags3 & (RF3_TROLL)))
2444 if (is_original_ap(m_ptr) && !p_ptr->image) r_ptr->r_flags3 |= (RF3_TROLL);
2447 /* Magical sensing */
2448 if ((p_ptr->esp_giant) && (r_ptr->flags3 & (RF3_GIANT)))
2451 if (is_original_ap(m_ptr) && !p_ptr->image) r_ptr->r_flags3 |= (RF3_GIANT);
2454 /* Magical sensing */
2455 if ((p_ptr->esp_dragon) && (r_ptr->flags3 & (RF3_DRAGON)))
2458 if (is_original_ap(m_ptr) && !p_ptr->image) r_ptr->r_flags3 |= (RF3_DRAGON);
2461 /* Magical sensing */
2462 if ((p_ptr->esp_human) && (r_ptr->flags2 & (RF2_HUMAN)))
2465 if (is_original_ap(m_ptr) && !p_ptr->image) r_ptr->r_flags2 |= (RF2_HUMAN);
2468 /* Magical sensing */
2469 if ((p_ptr->esp_evil) && (r_ptr->flags3 & (RF3_EVIL)))
2472 if (is_original_ap(m_ptr) && !p_ptr->image) r_ptr->r_flags3 |= (RF3_EVIL);
2475 /* Magical sensing */
2476 if ((p_ptr->esp_good) && (r_ptr->flags3 & (RF3_GOOD)))
2479 if (is_original_ap(m_ptr) && !p_ptr->image) r_ptr->r_flags3 |= (RF3_GOOD);
2482 /* Magical sensing */
2483 if ((p_ptr->esp_nonliving) &&
2484 ((r_ptr->flags3 & (RF3_DEMON | RF3_UNDEAD | RF3_NONLIVING)) == RF3_NONLIVING))
2487 if (is_original_ap(m_ptr) && !p_ptr->image) r_ptr->r_flags3 |= (RF3_NONLIVING);
2490 /* Magical sensing */
2491 if ((p_ptr->esp_unique) && (r_ptr->flags1 & (RF1_UNIQUE)))
2494 if (is_original_ap(m_ptr) && !p_ptr->image) r_ptr->r_flags1 |= (RF1_UNIQUE);
2498 /* Normal line of sight, and not blind */
2499 if (player_has_los_bold(fy, fx) && !p_ptr->blind)
2501 bool do_invisible = FALSE;
2502 bool do_cold_blood = FALSE;
2504 /* Snipers can see targets in darkness when they concentrate deeper */
2505 if (p_ptr->concent >= CONCENT_RADAR_THRESHOLD)
2511 /* Use "infravision" */
2512 if (d <= p_ptr->see_infra)
2514 /* Handle "cold blooded" monsters */
2515 if ((r_ptr->flags2 & (RF2_COLD_BLOOD | RF2_AURA_FIRE)) == RF2_COLD_BLOOD)
2518 do_cold_blood = TRUE;
2521 /* Handle "warm blooded" monsters */
2529 /* Use "illumination" */
2530 if (player_can_see_bold(fy, fx))
2532 /* Handle "invisible" monsters */
2533 if (r_ptr->flags2 & (RF2_INVISIBLE))
2536 do_invisible = TRUE;
2546 /* Handle "normal" monsters */
2557 if (is_original_ap(m_ptr) && !p_ptr->image)
2559 /* Memorize flags */
2560 if (do_invisible) r_ptr->r_flags2 |= (RF2_INVISIBLE);
2561 if (do_cold_blood) r_ptr->r_flags2 |= (RF2_COLD_BLOOD);
2568 /* The monster is now visible */
2571 /* It was previously unseen */
2574 /* Mark as visible */
2577 /* Draw the monster */
2580 /* Update health bar as needed */
2581 if (p_ptr->health_who == m_idx) p_ptr->redraw |= (PR_HEALTH);
2582 if (p_ptr->riding == m_idx) p_ptr->redraw |= (PR_UHEALTH);
2584 /* Hack -- Count "fresh" sightings */
2587 if ((m_ptr->ap_r_idx == MON_KAGE) && (r_info[MON_KAGE].r_sights < MAX_SHORT))
2588 r_info[MON_KAGE].r_sights++;
2589 else if (is_original_ap(m_ptr) && (r_ptr->r_sights < MAX_SHORT))
2593 /* Eldritch Horror */
2594 if (r_info[m_ptr->ap_r_idx].flags2 & RF2_ELDRITCH_HORROR)
2596 sanity_blast(m_ptr, FALSE);
2599 /* Disturb on appearance */
2600 if (disturb_near && (projectable(m_ptr->fy, m_ptr->fx, py, px) && projectable(py, px, m_ptr->fy, m_ptr->fx)))
2602 if (disturb_pets || is_hostile(m_ptr))
2608 /* The monster is not visible */
2611 /* It was previously seen */
2614 /* Mark as not visible */
2617 /* Erase the monster */
2620 /* Update health bar as needed */
2621 if (p_ptr->health_who == m_idx) p_ptr->redraw |= (PR_HEALTH);
2622 if (p_ptr->riding == m_idx) p_ptr->redraw |= (PR_UHEALTH);
2624 /* Disturb on disappearance */
2627 if (disturb_pets || is_hostile(m_ptr))
2634 /* The monster is now easily visible */
2638 if (!(m_ptr->mflag & (MFLAG_VIEW)))
2640 /* Mark as easily visible */
2641 m_ptr->mflag |= (MFLAG_VIEW);
2643 /* Disturb on appearance */
2646 if (disturb_pets || is_hostile(m_ptr))
2652 /* The monster is not easily visible */
2656 if (m_ptr->mflag & (MFLAG_VIEW))
2658 /* Mark as not easily visible */
2659 m_ptr->mflag &= ~(MFLAG_VIEW);
2661 /* Disturb on disappearance */
2664 if (disturb_pets || is_hostile(m_ptr))
2673 * This function simply updates all the (non-dead) monsters (see above).
2675 void update_monsters(bool full)
2679 /* Update each (live) monster */
2680 for (i = 1; i < m_max; i++)
2682 monster_type *m_ptr = &m_list[i];
2684 /* Skip dead monsters */
2685 if (!m_ptr->r_idx) continue;
2687 /* Update the monster */
2688 update_mon(i, full);
2694 * Hack -- the index of the summoning monster
2696 static bool monster_hook_chameleon_lord(int r_idx)
2698 monster_race *r_ptr = &r_info[r_idx];
2699 monster_type *m_ptr = &m_list[chameleon_change_m_idx];
2700 monster_race *old_r_ptr = &r_info[m_ptr->r_idx];
2702 if (!(r_ptr->flags1 & (RF1_UNIQUE))) return FALSE;
2703 if (r_ptr->flags7 & (RF7_FRIENDLY | RF7_CHAMELEON)) return FALSE;
2705 if (ABS(r_ptr->level - r_info[MON_CHAMELEON_K].level) > 5) return FALSE;
2707 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))
2710 if (!monster_can_cross_terrain(cave[m_ptr->fy][m_ptr->fx].feat, r_ptr, 0)) return FALSE;
2713 if (!(old_r_ptr->flags7 & RF7_CHAMELEON))
2715 if (monster_has_hostile_align(m_ptr, 0, 0, r_ptr)) return FALSE;
2719 else if (summon_specific_who > 0)
2721 if (monster_has_hostile_align(&m_list[summon_specific_who], 0, 0, r_ptr)) return FALSE;
2727 static bool monster_hook_chameleon(int r_idx)
2729 monster_race *r_ptr = &r_info[r_idx];
2730 monster_type *m_ptr = &m_list[chameleon_change_m_idx];
2731 monster_race *old_r_ptr = &r_info[m_ptr->r_idx];
2733 if (r_ptr->flags1 & (RF1_UNIQUE)) return FALSE;
2734 if (r_ptr->flags2 & RF2_MULTIPLY) return FALSE;
2735 if (r_ptr->flags7 & (RF7_FRIENDLY | RF7_CHAMELEON)) return FALSE;
2737 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))
2740 if (!monster_can_cross_terrain(cave[m_ptr->fy][m_ptr->fx].feat, r_ptr, 0)) return FALSE;
2743 if (!(old_r_ptr->flags7 & RF7_CHAMELEON))
2745 if ((old_r_ptr->flags3 & RF3_GOOD) && !(r_ptr->flags3 & RF3_GOOD)) return FALSE;
2746 if ((old_r_ptr->flags3 & RF3_EVIL) && !(r_ptr->flags3 & RF3_EVIL)) return FALSE;
2747 if (!(old_r_ptr->flags3 & (RF3_GOOD | RF3_EVIL)) && (r_ptr->flags3 & (RF3_GOOD | RF3_EVIL))) return FALSE;
2751 else if (summon_specific_who > 0)
2753 if (monster_has_hostile_align(&m_list[summon_specific_who], 0, 0, r_ptr)) return FALSE;
2756 return (*(get_monster_hook()))(r_idx);
2760 void choose_new_monster(int m_idx, bool born, int r_idx)
2763 monster_type *m_ptr = &m_list[m_idx];
2764 monster_race *r_ptr;
2765 char old_m_name[80];
2766 bool old_unique = FALSE;
2767 int old_r_idx = m_ptr->r_idx;
2769 if (r_info[m_ptr->r_idx].flags1 & RF1_UNIQUE)
2771 if (old_unique && (r_idx == MON_CHAMELEON)) r_idx = MON_CHAMELEON_K;
2772 r_ptr = &r_info[r_idx];
2774 monster_desc(old_m_name, m_ptr, 0);
2780 chameleon_change_m_idx = m_idx;
2782 get_mon_num_prep(monster_hook_chameleon_lord, NULL);
2784 get_mon_num_prep(monster_hook_chameleon, NULL);
2787 level = r_info[MON_CHAMELEON_K].level;
2788 else if (!dun_level)
2789 level = wilderness[p_ptr->wilderness_y][p_ptr->wilderness_x].level;
2793 if (d_info[dungeon_type].flags1 & DF1_CHAMELEON) level+= 2+randint1(3);
2795 r_idx = get_mon_num(level);
2796 r_ptr = &r_info[r_idx];
2798 chameleon_change_m_idx = 0;
2804 if (is_pet(m_ptr)) check_pets_num_and_align(m_ptr, FALSE);
2806 m_ptr->r_idx = r_idx;
2807 m_ptr->ap_r_idx = r_idx;
2808 update_mon(m_idx, FALSE);
2809 lite_spot(m_ptr->fy, m_ptr->fx);
2811 if ((r_info[old_r_idx].flags7 & (RF7_LITE_MASK | RF7_DARK_MASK)) ||
2812 (r_ptr->flags7 & (RF7_LITE_MASK | RF7_DARK_MASK)))
2813 p_ptr->update |= (PU_MON_LITE);
2815 if (is_pet(m_ptr)) check_pets_num_and_align(m_ptr, TRUE);
2819 /* Sub-alignment of a chameleon */
2820 if (r_ptr->flags3 & (RF3_EVIL | RF3_GOOD))
2822 m_ptr->sub_align = SUB_ALIGN_NEUTRAL;
2823 if (r_ptr->flags3 & RF3_EVIL) m_ptr->sub_align |= SUB_ALIGN_EVIL;
2824 if (r_ptr->flags3 & RF3_GOOD) m_ptr->sub_align |= SUB_ALIGN_GOOD;
2829 if (m_idx == p_ptr->riding)
2832 monster_desc(m_name, m_ptr, 0);
2834 msg_format("ÆÍÁ³%s¤¬ÊѿȤ·¤¿¡£", old_m_name);
2836 msg_format("Suddenly, %s transforms!", old_m_name);
2838 if (!(r_ptr->flags7 & RF7_RIDING))
2840 if (rakuba(0, TRUE)) msg_print("ÃÏÌ̤ËÍî¤È¤µ¤ì¤¿¡£");
2842 if (rakuba(0, TRUE)) msg_format("You have fallen from %s.", m_name);
2846 /* Extract the monster base speed */
2847 m_ptr->mspeed = get_mspeed(r_ptr);
2849 oldmaxhp = m_ptr->max_maxhp;
2850 /* Assign maximal hitpoints */
2851 if (r_ptr->flags1 & RF1_FORCE_MAXHP)
2853 m_ptr->max_maxhp = maxroll(r_ptr->hdice, r_ptr->hside);
2857 m_ptr->max_maxhp = damroll(r_ptr->hdice, r_ptr->hside);
2860 /* Monsters have double hitpoints in Nightmare mode */
2861 if (ironman_nightmare)
2863 u32b hp = m_ptr->max_maxhp * 2L;
2864 m_ptr->max_maxhp = (s16b)MIN(30000, hp);
2867 m_ptr->maxhp = (long)(m_ptr->maxhp * m_ptr->max_maxhp) / oldmaxhp;
2868 if (m_ptr->maxhp < 1) m_ptr->maxhp = 1;
2869 m_ptr->hp = (long)(m_ptr->hp * m_ptr->max_maxhp) / oldmaxhp;
2871 /* reset dealt_damage */
2872 m_ptr->dealt_damage = 0;
2879 static bool monster_hook_tanuki(int r_idx)
2881 monster_race *r_ptr = &r_info[r_idx];
2883 if (r_ptr->flags1 & (RF1_UNIQUE)) return FALSE;
2884 if (r_ptr->flags2 & RF2_MULTIPLY) return FALSE;
2885 if (r_ptr->flags7 & (RF7_FRIENDLY | RF7_CHAMELEON)) return FALSE;
2886 if (r_ptr->flags7 & RF7_AQUATIC) return FALSE;
2888 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))
2891 return (*(get_monster_hook()))(r_idx);
2896 * Set initial racial appearance of a monster
2898 static int initial_r_appearance(int r_idx)
2900 int attempts = 1000;
2903 int min = MIN(base_level-5, 50);
2905 if (!(r_info[r_idx].flags7 & RF7_TANUKI))
2908 get_mon_num_prep(monster_hook_tanuki, NULL);
2912 ap_r_idx = get_mon_num(base_level + 10);
2913 if (r_info[ap_r_idx].level >= min) return ap_r_idx;
2921 * Get initial monster speed
2923 byte get_mspeed(monster_race *r_ptr)
2925 /* Extract the monster base speed */
2926 int mspeed = r_ptr->speed;
2928 /* Hack -- small racial variety */
2929 if (!(r_ptr->flags1 & RF1_UNIQUE) && !p_ptr->inside_arena)
2931 /* Allow some small variation per monster */
2932 int i = SPEED_TO_ENERGY(r_ptr->speed) / (one_in_(4) ? 3 : 10);
2933 if (i) mspeed += rand_spread(0, i);
2936 if (mspeed > 199) mspeed = 199;
2938 return (byte)mspeed;
2943 * Attempt to place a monster of the given race at the given location.
2945 * To give the player a sporting chance, any monster that appears in
2946 * line-of-sight and is extremely dangerous can be marked as
2947 * "FORCE_SLEEP", which will cause them to be placed with low energy,
2948 * which often (but not always) lets the player move before they do.
2950 * This routine refuses to place out-of-depth "FORCE_DEPTH" monsters.
2952 * XXX XXX XXX Use special "here" and "dead" flags for unique monsters,
2953 * remove old "cur_num" and "max_num" fields.
2955 * XXX XXX XXX Actually, do something similar for artifacts, to simplify
2956 * the "preserve" mode, and to make the "what artifacts" flag more useful.
2958 * This is the only function which may place a monster in the dungeon,
2959 * except for the savefile loading code.
2961 static bool place_monster_one(int who, int y, int x, int r_idx, u32b mode)
2963 /* Access the location */
2964 cave_type *c_ptr = &cave[y][x];
2966 monster_type *m_ptr;
2968 monster_race *r_ptr = &r_info[r_idx];
2970 cptr name = (r_name + r_ptr->name);
2974 /* DO NOT PLACE A MONSTER IN THE SMALL SCALE WILDERNESS !!! */
2975 if (p_ptr->wild_mode) return FALSE;
2977 /* Verify location */
2978 if (!in_bounds(y, x)) return (FALSE);
2981 if (!r_idx) return (FALSE);
2984 if (!r_ptr->name) return (FALSE);
2986 if (!(mode & PM_IGNORE_TERRAIN))
2988 /* Not on the Pattern */
2989 if (pattern_tile(y, x)) return FALSE;
2991 /* Require empty space (if not ghostly) */
2992 if (!monster_can_enter(y, x, r_ptr, 0)) return FALSE;
2995 if (!p_ptr->inside_battle)
2997 /* Hack -- "unique" monsters must be "unique" */
2998 if (((r_ptr->flags1 & (RF1_UNIQUE)) ||
2999 (r_ptr->flags7 & (RF7_NAZGUL))) &&
3000 (r_ptr->cur_num >= r_ptr->max_num))
3006 if ((r_ptr->flags7 & (RF7_UNIQUE2)) &&
3007 (r_ptr->cur_num >= 1))
3012 if (r_idx == MON_BANORLUPART)
3014 if (r_info[MON_BANOR].cur_num > 0) return FALSE;
3015 if (r_info[MON_LUPART].cur_num > 0) return FALSE;
3018 /* Depth monsters may NOT be created out of depth, unless in Nightmare mode */
3019 if ((r_ptr->flags1 & (RF1_FORCE_DEPTH)) && (dun_level < r_ptr->level) &&
3020 (!ironman_nightmare || (r_ptr->flags1 & (RF1_QUESTOR))))
3027 if (quest_number(dun_level))
3029 int hoge = quest_number(dun_level);
3030 if ((quest[hoge].type == QUEST_TYPE_KILL_LEVEL) || (quest[hoge].type == QUEST_TYPE_RANDOM))
3032 if(r_idx == quest[hoge].r_idx)
3034 int number_mon, i2, j2;
3037 /* Count all quest monsters */
3038 for (i2 = 0; i2 < cur_wid; ++i2)
3039 for (j2 = 0; j2 < cur_hgt; j2++)
3040 if (cave[j2][i2].m_idx > 0)
3041 if (m_list[cave[j2][i2].m_idx].r_idx == quest[hoge].r_idx)
3043 if(number_mon + quest[hoge].cur_num >= quest[hoge].max_num)
3049 if (is_glyph_grid(c_ptr))
3051 if (randint1(BREAK_GLYPH) < (r_ptr->level+20))
3053 /* Describe observable breakage */
3054 if (c_ptr->info & CAVE_MARK)
3057 msg_print("¼é¤ê¤Î¥ë¡¼¥ó¤¬²õ¤ì¤¿¡ª");
3059 msg_print("The rune of protection is broken!");
3064 /* Forget the rune */
3065 c_ptr->info &= ~(CAVE_MARK);
3067 /* Break the rune */
3068 c_ptr->info &= ~(CAVE_OBJECT);
3077 /* Powerful monster */
3078 if (r_ptr->level > dun_level)
3080 /* Unique monsters */
3081 if (r_ptr->flags1 & (RF1_UNIQUE))
3083 /* Message for cheaters */
3085 if (cheat_hear) msg_format("¿¼ÁؤΥæ¥Ë¡¼¥¯¡¦¥â¥ó¥¹¥¿¡¼ (%s)¡£", name);
3087 if (cheat_hear) msg_format("Deep Unique (%s).", name);
3091 /* Normal monsters */
3094 /* Message for cheaters */
3096 if (cheat_hear) msg_format("¿¼ÁؤΥâ¥ó¥¹¥¿¡¼ (%s)¡£", name);
3098 if (cheat_hear) msg_format("Deep Monster (%s).", name);
3103 /* Note the monster */
3104 else if (r_ptr->flags1 & (RF1_UNIQUE))
3106 /* Unique monsters induce message */
3108 if (cheat_hear) msg_format("¥æ¥Ë¡¼¥¯¡¦¥â¥ó¥¹¥¿¡¼ (%s)¡£", name);
3110 if (cheat_hear) msg_format("Unique (%s).", name);
3115 if ((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags7 & RF7_NAZGUL) || (r_ptr->level < 10)) mode &= ~PM_KAGE;
3117 /* Make a new monster */
3118 c_ptr->m_idx = m_pop();
3119 hack_m_idx_ii = c_ptr->m_idx;
3121 /* Mega-Hack -- catch "failure" */
3122 if (!c_ptr->m_idx) return (FALSE);
3125 /* Get a new monster record */
3126 m_ptr = &m_list[c_ptr->m_idx];
3129 m_ptr->r_idx = r_idx;
3130 m_ptr->ap_r_idx = initial_r_appearance(r_idx);
3136 /* Hack -- Appearance transfer */
3137 if ((mode & PM_MULTIPLY) && (who > 0) && !is_original_ap(&m_list[who]))
3139 m_ptr->ap_r_idx = m_list[who].ap_r_idx;
3141 /* Hack -- Shadower spawns Shadower */
3142 if (m_list[who].mflag2 & MFLAG2_KAGE) m_ptr->mflag2 |= MFLAG2_KAGE;
3145 /* Sub-alignment of a monster */
3146 if ((who > 0) && !(r_ptr->flags3 & (RF3_EVIL | RF3_GOOD)))
3147 m_ptr->sub_align = m_list[who].sub_align;
3150 m_ptr->sub_align = SUB_ALIGN_NEUTRAL;
3151 if (r_ptr->flags3 & RF3_EVIL) m_ptr->sub_align |= SUB_ALIGN_EVIL;
3152 if (r_ptr->flags3 & RF3_GOOD) m_ptr->sub_align |= SUB_ALIGN_GOOD;
3155 /* Place the monster at the location */
3160 /* No "timed status" yet */
3161 for (cmi = 0; cmi < MAX_MTIMED; cmi++) m_ptr->mtimed[cmi] = 0;
3163 /* Unknown distance */
3166 reset_target(m_ptr);
3168 m_ptr->nickname = 0;
3173 /* Your pet summons its pet. */
3174 if (who > 0 && is_pet(&m_list[who]))
3176 mode |= PM_FORCE_PET;
3177 m_ptr->parent_m_idx = who;
3181 m_ptr->parent_m_idx = 0;
3184 if (r_ptr->flags7 & RF7_CHAMELEON)
3186 choose_new_monster(c_ptr->m_idx, TRUE, 0);
3187 r_ptr = &r_info[m_ptr->r_idx];
3188 m_ptr->mflag2 |= MFLAG2_CHAMELEON;
3190 /* Hack - Set sub_align to neutral when the Chameleon Lord is generated as "GUARDIAN" */
3191 if ((r_ptr->flags1 & RF1_UNIQUE) && (who <= 0))
3192 m_ptr->sub_align = SUB_ALIGN_NEUTRAL;
3194 else if ((mode & PM_KAGE) && !(mode & PM_FORCE_PET))
3196 m_ptr->ap_r_idx = MON_KAGE;
3197 m_ptr->mflag2 |= MFLAG2_KAGE;
3200 if (mode & PM_NO_PET) m_ptr->mflag2 |= MFLAG2_NOPET;
3206 if (mode & PM_FORCE_PET)
3211 else if ((r_ptr->flags7 & RF7_FRIENDLY) ||
3212 (mode & PM_FORCE_FRIENDLY) || is_friendly_idx(who))
3214 if (!monster_has_hostile_align(NULL, 0, -1, r_ptr)) set_friendly(m_ptr);
3217 /* Assume no sleeping */
3218 m_ptr->mtimed[MTIMED_CSLEEP] = 0;
3220 /* Enforce sleeping if needed */
3221 if ((mode & PM_ALLOW_SLEEP) && r_ptr->sleep && !ironman_nightmare)
3223 int val = r_ptr->sleep;
3224 (void)set_monster_csleep(c_ptr->m_idx, (val * 2) + randint1(val * 10));
3227 /* Assign maximal hitpoints */
3228 if (r_ptr->flags1 & RF1_FORCE_MAXHP)
3230 m_ptr->max_maxhp = maxroll(r_ptr->hdice, r_ptr->hside);
3234 m_ptr->max_maxhp = damroll(r_ptr->hdice, r_ptr->hside);
3237 /* Monsters have double hitpoints in Nightmare mode */
3238 if (ironman_nightmare)
3240 u32b hp = m_ptr->max_maxhp * 2L;
3242 m_ptr->max_maxhp = (s16b)MIN(30000, hp);
3245 m_ptr->maxhp = m_ptr->max_maxhp;
3247 /* And start out fully healthy */
3248 if (m_ptr->r_idx == MON_WOUNDED_BEAR)
3249 m_ptr->hp = m_ptr->maxhp / 2;
3250 else m_ptr->hp = m_ptr->maxhp;
3253 /* dealt damage is 0 at initial*/
3254 m_ptr->dealt_damage = 0;
3257 /* Extract the monster base speed */
3258 m_ptr->mspeed = get_mspeed(r_ptr);
3260 if (mode & PM_HASTE) (void)set_monster_fast(c_ptr->m_idx, 100);
3262 /* Give a random starting energy */
3263 if (!ironman_nightmare)
3265 m_ptr->energy_need = ENERGY_NEED() - (s16b)randint0(100);
3269 /* Nightmare monsters are more prepared */
3270 m_ptr->energy_need = ENERGY_NEED() - (s16b)randint0(100) * 2;
3273 /* Force monster to wait for player, unless in Nightmare mode */
3274 if ((r_ptr->flags1 & RF1_FORCE_SLEEP) && !ironman_nightmare)
3276 /* Monster is still being nice */
3277 m_ptr->mflag |= (MFLAG_NICE);
3279 /* Must repair monsters */
3280 repair_monsters = TRUE;
3283 /* Hack -- see "process_monsters()" */
3284 if (c_ptr->m_idx < hack_m_idx)
3286 /* Monster is still being born */
3287 m_ptr->mflag |= (MFLAG_BORN);
3291 if (r_ptr->flags7 & RF7_SELF_LD_MASK)
3292 p_ptr->update |= (PU_MON_LITE);
3293 else if ((r_ptr->flags7 & RF7_HAS_LD_MASK) && !MON_CSLEEP(m_ptr))
3294 p_ptr->update |= (PU_MON_LITE);
3296 /* Update the monster */
3297 update_mon(c_ptr->m_idx, TRUE);
3300 /* Count the monsters on the level */
3301 real_r_ptr(m_ptr)->cur_num++;
3304 * Memorize location of the unique monster in saved floors.
3305 * A unique monster move from old saved floor.
3307 if (character_dungeon &&
3308 ((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags7 & RF7_NAZGUL)))
3309 real_r_ptr(m_ptr)->floor_id = p_ptr->floor_id;
3311 /* Hack -- Count the number of "reproducers" */
3312 if (r_ptr->flags2 & RF2_MULTIPLY) num_repro++;
3314 /* Hack -- Notice new multi-hued monsters */
3316 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
3317 if (ap_r_ptr->flags1 & (RF1_ATTR_MULTI | RF1_SHAPECHANGER))
3318 shimmer_monsters = TRUE;
3321 if (p_ptr->warning && character_dungeon)
3323 if (r_ptr->flags1 & RF1_UNIQUE)
3327 char o_name[MAX_NLEN];
3329 if (r_ptr->level > p_ptr->lev + 30)
3335 else if (r_ptr->level > p_ptr->lev + 15)
3341 else if (r_ptr->level > p_ptr->lev + 5)
3343 color = "¥ë¥Ó¡¼¿§¤Ë";
3347 else if (r_ptr->level > p_ptr->lev - 5)
3353 else if (r_ptr->level > p_ptr->lev - 15)
3355 color = "¥Ô¥ó¥¯¿§¤Ë";
3366 o_ptr = choose_warning_item();
3369 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
3371 msg_format("%s¤Ï%s¸÷¤Ã¤¿¡£", o_name, color);
3373 msg_format("%s glows %s.", o_name, color);
3379 msg_format("%s¸÷¤ëʪ¤¬Æ¬¤ËÉ⤫¤ó¤À¡£", color);
3381 msg_format("An %s image forms in your mind.");
3387 if (is_explosive_rune_grid(c_ptr))
3389 /* Break the ward */
3390 if (randint1(BREAK_MINOR_GLYPH) > r_ptr->level)
3392 /* Describe observable breakage */
3393 if (c_ptr->info & CAVE_MARK)
3396 msg_print("¥ë¡¼¥ó¤¬Çúȯ¤·¤¿¡ª");
3398 msg_print("The rune explodes!");
3401 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);
3407 msg_print("Çúȯ¤Î¥ë¡¼¥ó¤Ï²ò½ü¤µ¤ì¤¿¡£");
3409 msg_print("An explosive rune was disarmed.");
3413 /* Forget the rune */
3414 c_ptr->info &= ~(CAVE_MARK);
3416 /* Break the rune */
3417 c_ptr->info &= ~(CAVE_OBJECT);
3430 * improved version of scatter() for place monster
3433 #define MON_SCAT_MAXD 10
3435 static bool mon_scatter(int r_idx, int *yp, int *xp, int y, int x, int max_dist)
3437 int place_x[MON_SCAT_MAXD];
3438 int place_y[MON_SCAT_MAXD];
3439 int num[MON_SCAT_MAXD];
3443 if (max_dist >= MON_SCAT_MAXD)
3446 for (i = 0; i < MON_SCAT_MAXD; i++)
3449 for (nx = x - max_dist; nx <= x + max_dist; nx++)
3451 for (ny = y - max_dist; ny <= y + max_dist; ny++)
3453 /* Ignore annoying locations */
3454 if (!in_bounds(ny, nx)) continue;
3456 /* Require "line of projection" */
3457 if (!projectable(y, x, ny, nx)) continue;
3461 monster_race *r_ptr = &r_info[r_idx];
3463 /* Require empty space (if not ghostly) */
3464 if (!monster_can_enter(ny, nx, r_ptr, 0))
3469 /* Walls and Monsters block flow */
3470 if (!cave_empty_bold2(ny, nx)) continue;
3472 /* ... nor on the Pattern */
3473 if (pattern_tile(ny, nx)) continue;
3476 i = distance(y, x, ny, nx);
3484 if (one_in_(num[i]))
3493 while (i < MON_SCAT_MAXD && 0 == num[i])
3495 if (i >= MON_SCAT_MAXD)
3506 * Maximum size of a group of monsters
3508 #define GROUP_MAX 32
3512 * Attempt to place a "group" of monsters around the given location
3514 static bool place_monster_group(int who, int y, int x, int r_idx, u32b mode)
3516 monster_race *r_ptr = &r_info[r_idx];
3519 int total = 0, extra = 0;
3523 byte hack_y[GROUP_MAX];
3524 byte hack_x[GROUP_MAX];
3527 /* Pick a group size */
3528 total = randint1(10);
3530 /* Hard monsters, small groups */
3531 if (r_ptr->level > dun_level)
3533 extra = r_ptr->level - dun_level;
3534 extra = 0 - randint1(extra);
3537 /* Easy monsters, large groups */
3538 else if (r_ptr->level < dun_level)
3540 extra = dun_level - r_ptr->level;
3541 extra = randint1(extra);
3544 /* Hack -- limit group reduction */
3545 if (extra > 9) extra = 9;
3547 /* Modify the group size */
3551 if (total < 1) total = 1;
3554 if (total > GROUP_MAX) total = GROUP_MAX;
3557 /* Start on the monster */
3562 /* Puddle monsters, breadth first, up to total */
3563 for (n = 0; (n < hack_n) && (hack_n < total); n++)
3565 /* Grab the location */
3569 /* Check each direction, up to total */
3570 for (i = 0; (i < 8) && (hack_n < total); i++)
3574 scatter(&my, &mx, hy, hx, 4, 0);
3576 /* Walls and Monsters block flow */
3577 if (!cave_empty_bold2(my, mx)) continue;
3579 /* Attempt to place another monster */
3580 if (place_monster_one(who, my, mx, r_idx, mode))
3582 /* Add it to the "hack" set */
3583 hack_y[hack_n] = my;
3584 hack_x[hack_n] = mx;
3597 * Hack -- help pick an escort type
3599 static int place_monster_idx = 0;
3600 static int place_monster_m_idx = 0;
3603 * Hack -- help pick an escort type
3605 static bool place_monster_okay(int r_idx)
3607 monster_race *r_ptr = &r_info[place_monster_idx];
3608 monster_type *m_ptr = &m_list[place_monster_m_idx];
3610 monster_race *z_ptr = &r_info[r_idx];
3612 /* Hack - Escorts have to have the same dungeon flag */
3613 if (mon_hook_dungeon(place_monster_idx) != mon_hook_dungeon(r_idx)) return (FALSE);
3615 /* Require similar "race" */
3616 if (z_ptr->d_char != r_ptr->d_char) return (FALSE);
3618 /* Skip more advanced monsters */
3619 if (z_ptr->level > r_ptr->level) return (FALSE);
3621 /* Skip unique monsters */
3622 if (z_ptr->flags1 & RF1_UNIQUE) return (FALSE);
3624 /* Paranoia -- Skip identical monsters */
3625 if (place_monster_idx == r_idx) return (FALSE);
3627 /* Skip different alignment */
3628 if (monster_has_hostile_align(m_ptr, 0, 0, z_ptr)) return FALSE;
3630 if (r_ptr->flags7 & RF7_FRIENDLY)
3632 if (monster_has_hostile_align(NULL, 1, -1, z_ptr)) return FALSE;
3635 if ((r_ptr->flags7 & RF7_CHAMELEON) && !(z_ptr->flags7 & RF7_CHAMELEON))
3644 * Attempt to place a monster of the given race at the given location
3646 * Note that certain monsters are now marked as requiring "friends".
3647 * These monsters, if successfully placed, and if the "grp" parameter
3648 * is TRUE, will be surrounded by a "group" of identical monsters.
3650 * Note that certain monsters are now marked as requiring an "escort",
3651 * which is a collection of monsters with similar "race" but lower level.
3653 * Some monsters induce a fake "group" flag on their escorts.
3655 * Note the "bizarre" use of non-recursion to prevent annoying output
3656 * when running a code profiler.
3658 * Note the use of the new "monster allocation table" code to restrict
3659 * the "get_mon_num()" function to "legal" escort types.
3661 bool place_monster_aux(int who, int y, int x, int r_idx, u32b mode)
3664 monster_race *r_ptr = &r_info[r_idx];
3666 if (!(mode & PM_NO_KAGE) && one_in_(333))
3669 /* Place one monster, or fail */
3670 if (!place_monster_one(who, y, x, r_idx, mode)) return (FALSE);
3673 /* Require the "group" flag */
3674 if (!(mode & PM_ALLOW_GROUP)) return (TRUE);
3676 place_monster_m_idx = hack_m_idx_ii;
3678 /* Friends for certain monsters */
3679 if (r_ptr->flags1 & (RF1_FRIENDS))
3681 /* Attempt to place a group */
3682 (void)place_monster_group(who, y, x, r_idx, mode);
3686 /* Escorts for certain monsters */
3687 if (r_ptr->flags1 & (RF1_ESCORT))
3689 /* Set the escort index */
3690 place_monster_idx = r_idx;
3692 /* Try to place several "escorts" */
3693 for (i = 0; i < 32; i++)
3695 int nx, ny, z, d = 3;
3697 /* Pick a location */
3698 scatter(&ny, &nx, y, x, d, 0);
3700 /* Require empty grids */
3701 if (!cave_empty_bold2(ny, nx)) continue;
3703 /* Prepare allocation table */
3704 get_mon_num_prep(place_monster_okay, get_monster_hook2(ny, nx));
3706 /* Pick a random race */
3707 z = get_mon_num(r_ptr->level);
3709 /* Handle failure */
3712 /* Place a single escort */
3713 (void)place_monster_one(place_monster_m_idx, ny, nx, z, mode);
3715 /* Place a "group" of escorts if needed */
3716 if ((r_info[z].flags1 & RF1_FRIENDS) ||
3717 (r_ptr->flags1 & RF1_ESCORTS))
3719 /* Place a group of monsters */
3720 (void)place_monster_group(place_monster_m_idx, ny, nx, z, mode);
3731 * Hack -- attempt to place a monster at the given location
3733 * Attempt to find a monster appropriate to the "monster_level"
3735 bool place_monster(int y, int x, u32b mode)
3739 /* Prepare allocation table */
3740 get_mon_num_prep(get_monster_hook(), get_monster_hook2(y, x));
3742 /* Pick a monster */
3743 r_idx = get_mon_num(monster_level);
3745 /* Handle failure */
3746 if (!r_idx) return (FALSE);
3748 /* Attempt to place the monster */
3749 if (place_monster_aux(0, y, x, r_idx, mode)) return (TRUE);
3756 #ifdef MONSTER_HORDES
3758 bool alloc_horde(int y, int x)
3760 monster_race *r_ptr = NULL;
3763 int attempts = 1000;
3767 /* Prepare allocation table */
3768 get_mon_num_prep(get_monster_hook(), get_monster_hook2(y, x));
3772 /* Pick a monster */
3773 r_idx = get_mon_num(monster_level);
3775 /* Handle failure */
3776 if (!r_idx) return (FALSE);
3778 r_ptr = &r_info[r_idx];
3780 if (r_ptr->flags1 & RF1_UNIQUE) continue;
3782 if (r_idx == MON_HAGURE) continue;
3785 if (attempts < 1) return FALSE;
3791 /* Attempt to place the monster */
3792 if (place_monster_aux(0, y, x, r_idx, 0L)) break;
3795 if (attempts < 1) return FALSE;
3797 m_idx = cave[y][x].m_idx;
3799 if (m_list[m_idx].mflag2 & MFLAG2_CHAMELEON) r_ptr = &r_info[m_list[m_idx].r_idx];
3800 summon_kin_type = r_ptr->d_char;
3802 for (attempts = randint1(10) + 5; attempts; attempts--)
3804 scatter(&cy, &cx, y, x, 5, 0);
3806 (void)summon_specific(m_idx, cy, cx, dun_level + 5, SUMMON_KIN, PM_ALLOW_GROUP);
3815 #endif /* MONSTER_HORDES */
3821 bool alloc_guardian(bool def_val)
3823 int guardian = d_info[dungeon_type].final_guardian;
3825 if (guardian && (d_info[dungeon_type].maxdepth == dun_level) && (r_info[guardian].cur_num < r_info[guardian].max_num))
3831 /* Find a good position */
3834 /* Get a random spot */
3835 oy = randint1(cur_hgt - 4) + 2;
3836 ox = randint1(cur_wid - 4) + 2;
3838 /* Is it a good spot ? */
3839 if (cave_empty_bold2(oy, ox) && monster_can_cross_terrain(cave[oy][ox].feat, &r_info[guardian], 0))
3841 /* Place the guardian */
3842 if (place_monster_aux(0, oy, ox, guardian, (PM_ALLOW_GROUP | PM_NO_KAGE | PM_NO_PET))) return TRUE;
3857 * Attempt to allocate a random monster in the dungeon.
3859 * Place the monster at least "dis" distance from the player.
3861 * Use "slp" to choose the initial "sleep" status
3863 * Use "monster_level" for the monster level
3865 bool alloc_monster(int dis, u32b mode)
3868 int attempts_left = 10000;
3870 /* Put the Guardian */
3871 if (alloc_guardian(FALSE)) return TRUE;
3873 /* Find a legal, distant, unoccupied, space */
3874 while (attempts_left--)
3876 /* Pick a location */
3877 y = randint0(cur_hgt);
3878 x = randint0(cur_wid);
3880 /* Require empty floor grid (was "naked") */
3883 if (!cave_empty_bold2(y, x)) continue;
3887 if (!cave_empty_bold(y, x)) continue;
3890 /* Accept far away grids */
3891 if (distance(y, x, py, px) > dis) break;
3896 if (cheat_xtra || cheat_hear)
3899 msg_print("·Ù¹ð¡ª¿·¤¿¤Ê¥â¥ó¥¹¥¿¡¼¤òÇÛÃ֤Ǥ¤Þ¤»¤ó¡£¾®¤µ¤¤³¬¤Ç¤¹¤«¡©");
3901 msg_print("Warning! Could not allocate a new monster. Small level?");
3910 #ifdef MONSTER_HORDES
3911 if (randint1(5000) <= dun_level)
3913 if (alloc_horde(y, x))
3916 if (cheat_hear) msg_format("¥â¥ó¥¹¥¿¡¼¤ÎÂç·²(%c)", summon_kin_type);
3918 if (cheat_hear) msg_format("Monster horde (%c).", summon_kin_type);
3926 #endif /* MONSTER_HORDES */
3928 /* Attempt to place the monster, allow groups */
3929 if (place_monster(y, x, (mode | PM_ALLOW_GROUP))) return (TRUE);
3931 #ifdef MONSTER_HORDES
3933 #endif /* MONSTER_HORDES */
3943 * Hack -- help decide if a monster race is "okay" to summon
3945 static bool summon_specific_okay(int r_idx)
3947 monster_race *r_ptr = &r_info[r_idx];
3949 /* Hack - Only summon dungeon monsters */
3950 if (!mon_hook_dungeon(r_idx)) return (FALSE);
3952 /* Hack -- identify the summoning monster */
3953 if (summon_specific_who > 0)
3955 monster_type *m_ptr = &m_list[summon_specific_who];
3957 /* Do not summon enemies */
3959 /* Friendly vs. opposite aligned normal or pet */
3960 if (monster_has_hostile_align(m_ptr, 0, 0, r_ptr)) return FALSE;
3962 /* Use the player's alignment */
3963 else if (summon_specific_who < 0)
3965 /* Do not summon enemies of the pets */
3966 if (monster_has_hostile_align(NULL, 10, -10, r_ptr))
3968 if (!one_in_(ABS(p_ptr->align) / 2 + 1)) return FALSE;
3972 /* Hack -- no specific type specified */
3973 if (!summon_specific_type) return (TRUE);
3975 if (!summon_unique_okay && ((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags7 & RF7_NAZGUL))) return FALSE;
3977 if ((summon_specific_who < 0) &&
3978 ((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags7 & RF7_NAZGUL)) &&
3979 monster_has_hostile_align(NULL, 10, -10, r_ptr))
3982 if ((r_ptr->flags7 & RF7_CHAMELEON) && (d_info[dungeon_type].flags1 & DF1_CHAMELEON)) return TRUE;
3984 return (summon_specific_aux(r_idx));
3989 * Place a monster (of the specified "type") near the given
3990 * location. Return TRUE if a monster was actually summoned.
3992 * We will attempt to place the monster up to 10 times before giving up.
3994 * Note: SUMMON_UNIQUE and SUMMON_AMBERITES will summon Unique's
3995 * Note: SUMMON_HI_UNDEAD and SUMMON_HI_DRAGON may summon Unique's
3996 * Note: None of the other summon codes will ever summon Unique's.
3998 * This function has been changed. We now take the "monster level"
3999 * of the summoning monster as a parameter, and use that, along with
4000 * the current dungeon level, to help determine the level of the
4001 * desired monster. Note that this is an upper bound, and also
4002 * tends to "prefer" monsters of that level. Currently, we use
4003 * the average of the dungeon and monster levels, and then add
4004 * five to allow slight increases in monster power.
4006 * Note that we use the new "monster allocation table" creation code
4007 * to restrict the "get_mon_num()" function to the set of "legal"
4008 * monsters, making this function much faster and more reliable.
4010 * Note that this function may not succeed, though this is very rare.
4012 bool summon_specific(int who, int y1, int x1, int lev, int type, u32b mode)
4016 if (p_ptr->inside_arena) return (FALSE);
4018 if (!mon_scatter(0, &y, &x, y1, x1, 2)) return FALSE;
4020 /* Save the summoner */
4021 summon_specific_who = who;
4023 /* Save the "summon" type */
4024 summon_specific_type = type;
4026 summon_unique_okay = (mode & PM_ALLOW_UNIQUE) ? TRUE : FALSE;
4028 /* Prepare allocation table */
4029 get_mon_num_prep(summon_specific_okay, get_monster_hook2(y, x));
4031 /* Pick a monster, using the level calculation */
4032 r_idx = get_mon_num((dun_level + lev) / 2 + 5);
4034 /* Handle failure */
4037 summon_specific_type = 0;
4041 if ((type == SUMMON_BLUE_HORROR) || (type == SUMMON_DAWN)) mode |= PM_NO_KAGE;
4043 /* Attempt to place the monster (awake, allow groups) */
4044 if (!place_monster_aux(who, y, x, r_idx, mode))
4046 summon_specific_type = 0;
4050 summon_specific_type = 0;
4055 /* A "dangerous" function, creates a pet of the specified type */
4056 bool summon_named_creature (int who, int oy, int ox, int r_idx, u32b mode)
4061 /* if (!r_idx) return; */
4063 /* Prevent illegal monsters */
4064 if (r_idx >= max_r_idx) return FALSE;
4066 if (p_ptr->inside_arena) return FALSE;
4068 if (!mon_scatter(r_idx, &y, &x, oy, ox, 2)) return FALSE;
4070 /* Place it (allow groups) */
4071 return place_monster_aux(who, y, x, r_idx, (mode | PM_NO_KAGE));
4076 * Let the given monster attempt to reproduce.
4078 * Note that "reproduction" REQUIRES empty space.
4080 bool multiply_monster(int m_idx, bool clone, u32b mode)
4082 monster_type *m_ptr = &m_list[m_idx];
4086 if (!mon_scatter(m_ptr->r_idx, &y, &x, m_ptr->fy, m_ptr->fx, 1))
4089 if (m_ptr->mflag2 & MFLAG2_NOPET) mode |= PM_NO_PET;
4091 /* Create a new monster (awake, no groups) */
4092 if (!place_monster_aux(m_idx, y, x, m_ptr->r_idx, (mode | PM_NO_KAGE | PM_MULTIPLY)))
4095 /* Hack -- Transfer "clone" flag */
4096 if (clone || (m_ptr->smart & SM_CLONED))
4098 m_list[hack_m_idx_ii].smart |= SM_CLONED;
4099 m_list[hack_m_idx_ii].mflag2 |= MFLAG2_NOPET;
4110 * Dump a message describing a monster's reaction to damage
4112 * Technically should attempt to treat "Beholder"'s as jelly's
4114 void message_pain(int m_idx, int dam)
4116 long oldhp, newhp, tmp;
4119 monster_type *m_ptr = &m_list[m_idx];
4120 monster_race *r_ptr = &r_info[m_ptr->r_idx];
4124 /* Get the monster name */
4125 monster_desc(m_name, m_ptr, 0);
4127 if(dam == 0) // Notice non-damage
4130 msg_format("%^s¤Ï¥À¥á¡¼¥¸¤ò¼õ¤±¤Æ¤¤¤Ê¤¤¡£", m_name);
4132 msg_format("%^s is unharmed.", m_name);
4137 /* Note -- subtle fix -CFT */
4138 newhp = (long)(m_ptr->hp);
4139 oldhp = newhp + (long)(dam);
4140 tmp = (newhp * 100L) / oldhp;
4141 percentage = (int)(tmp);
4143 if(my_strchr(",ejmvwQ", r_ptr->d_char)) // Mushrooms, Eyes, Jellies, Molds, Vortices, Worms, Quylthulgs
4146 if(percentage > 95) msg_format("%^s¤Ï¤Û¤È¤ó¤Éµ¤¤Ë¤È¤á¤Æ¤¤¤Ê¤¤¡£", m_name);
4147 else if(percentage > 75) msg_format("%^s¤Ï¤·¤ê¹þ¤ß¤·¤¿¡£", m_name);
4148 else if(percentage > 50) msg_format("%^s¤Ï½Ì¤³¤Þ¤Ã¤¿¡£", m_name);
4149 else if(percentage > 35) msg_format("%^s¤ÏÄˤߤ˿̤¨¤¿¡£", m_name);
4150 else if(percentage > 20) msg_format("%^s¤Ï¿È¤â¤À¤¨¤·¤¿¡£", m_name);
4151 else if(percentage > 10) msg_format("%^s¤Ï¶ìÄˤǿȤâ¤À¤¨¤·¤¿¡£", m_name);
4152 else msg_format("%^s¤Ï¤°¤Ë¤ã¤°¤Ë¤ã¤ÈáÛÚ»¤·¤¿¡£", m_name);
4154 if(percentage > 95) msg_format("%^s barely notices.", m_name);
4155 else if(percentage > 75) msg_format("%^s flinches.", m_name);
4156 else if(percentage > 50) msg_format("%^s squelches.", m_name);
4157 else if(percentage > 35) msg_format("%^s quivers in pain.", m_name);
4158 else if(percentage > 20) msg_format("%^s writhes about.", m_name);
4159 else if(percentage > 10) msg_format("%^s writhes in agony.", m_name);
4160 else msg_format("%^s jerks limply.", m_name);
4164 else if(my_strchr("l", r_ptr->d_char)) // Fish
4167 if(percentage > 95) msg_format("%^s¤Ï¤Û¤È¤ó¤Éµ¤¤Ë¤È¤á¤Æ¤¤¤Ê¤¤¡£", m_name);
4168 else if(percentage > 75) msg_format("%^s¤Ï¤·¤ê¹þ¤ß¤·¤¿¡£", m_name);
4169 else if(percentage > 50) msg_format("%^s¤Ïí´í°¤·¤¿¡£", m_name);
4170 else if(percentage > 35) msg_format("%^s¤ÏÄˤߤ˿̤¨¤¿¡£", m_name);
4171 else if(percentage > 20) msg_format("%^s¤Ï¿È¤â¤À¤¨¤·¤¿¡£", m_name);
4172 else if(percentage > 10) msg_format("%^s¤Ï¶ìÄˤǿȤâ¤À¤¨¤·¤¿¡£", m_name);
4173 else msg_format("%^s¤Ï¤°¤Ë¤ã¤°¤Ë¤ã¤ÈáÛÚ»¤·¤¿¡£", m_name);
4175 if(percentage > 95) msg_format("%^s barely notices.", m_name);
4176 else if(percentage > 75) msg_format("%^s flinches.", m_name);
4177 else if(percentage > 50) msg_format("%^s hesitates.", m_name);
4178 else if(percentage > 35) msg_format("%^s quivers in pain.", m_name);
4179 else if(percentage > 20) msg_format("%^s writhes about.", m_name);
4180 else if(percentage > 10) msg_format("%^s writhes in agony.", m_name);
4181 else msg_format("%^s jerks limply.", m_name);
4185 else if(my_strchr("g#+<>", r_ptr->d_char)) // Golems, Walls, Doors, Stairs
4188 if(percentage > 95) msg_format("%s¤Ï¹¶·â¤òµ¤¤Ë¤È¤á¤Æ¤¤¤Ê¤¤¡£", m_name);
4189 else if(percentage > 75) msg_format("%s¤Ï¹¶·â¤Ë¸ª¤ò¤¹¤¯¤á¤¿¡£", m_name);
4190 else if(percentage > 50) msg_format("%^s¤ÏÍëÌĤΤ褦¤ËËʤ¨¤¿¡£", m_name);
4191 else if(percentage > 35) msg_format("%^s¤Ï¶ì¤·¤²¤ËËʤ¨¤¿¡£", m_name);
4192 else if(percentage > 20) msg_format("%^s¤Ï¤¦¤á¤¤¤¿¡£", m_name);
4193 else if(percentage > 10) msg_format("%^s¤Ïí´í°¤·¤¿¡£", m_name);
4194 else msg_format("%^s¤Ï¤¯¤·¤ã¤¯¤·¤ã¤Ë¤Ê¤Ã¤¿¡£", m_name);
4196 if(percentage > 95) msg_format("%^s ignores the attack.", m_name);
4197 else if(percentage > 75) msg_format("%^s shrugs off the attack.", m_name);
4198 else if(percentage > 50) msg_format("%^s roars thunderously.", m_name);
4199 else if(percentage > 35) msg_format("%^s rumbles.", m_name);
4200 else if(percentage > 20) msg_format("%^s grunts.", m_name);
4201 else if(percentage > 10) msg_format("%^s hesitates.", m_name);
4202 else msg_format("%^s crumples.", m_name);
4206 else if(my_strchr("JMR", r_ptr->d_char) || !isalpha(r_ptr->d_char)) // Snakes, Hydrae, Reptiles, Mimics
4209 if(percentage > 95) msg_format("%^s¤Ï¤Û¤È¤ó¤Éµ¤¤Ë¤È¤á¤Æ¤¤¤Ê¤¤¡£", m_name);
4210 else if(percentage > 75) msg_format("%^s¤Ï¥·¡¼¥Ã¤ÈÌĤ¤¤¿¡£", m_name);
4211 else if(percentage > 50) msg_format("%^s¤ÏÅܤäÆƬ¤ò¾å¤²¤¿¡£", m_name);
4212 else if(percentage > 35) msg_format("%^s¤ÏÌÔÁ³¤È°Ò³Å¤·¤¿¡£", m_name);
4213 else if(percentage > 20) msg_format("%^s¤Ï¿È¤â¤À¤¨¤·¤¿¡£", m_name);
4214 else if(percentage > 10) msg_format("%^s¤Ï¶ìÄˤǿȤâ¤À¤¨¤·¤¿¡£", m_name);
4215 else msg_format("%^s¤Ï¤°¤Ë¤ã¤°¤Ë¤ã¤ÈáÛÚ»¤·¤¿¡£", m_name);
4217 if(percentage > 95) msg_format("%^s barely notices.", m_name);
4218 else if(percentage > 75) msg_format("%^s hisses.", m_name);
4219 else if(percentage > 50) msg_format("%^s rears up in anger.", m_name);
4220 else if(percentage > 35) msg_format("%^s hisses furiously.", m_name);
4221 else if(percentage > 20) msg_format("%^s writhes about.", m_name);
4222 else if(percentage > 10) msg_format("%^s writhes in agony.", m_name);
4223 else msg_format("%^s jerks limply.", m_name);
4227 else if(my_strchr("f", r_ptr->d_char))
4230 if(percentage > 95) msg_format("%s¤Ï¹¶·â¤Ë¸ª¤ò¤¹¤¯¤á¤¿¡£", m_name);
4231 else if(percentage > 75) msg_format("%^s¤ÏËʤ¨¤¿¡£", m_name);
4232 else if(percentage > 50) msg_format("%^s¤ÏÅܤäÆËʤ¨¤¿¡£", m_name);
4233 else if(percentage > 35) msg_format("%^s¤ÏÄˤߤǥ·¡¼¥Ã¤ÈÌĤ¤¤¿¡£", m_name);
4234 else if(percentage > 20) msg_format("%^s¤ÏÄˤߤǼ塹¤·¤¯ÌĤ¤¤¿¡£", m_name);
4235 else if(percentage > 10) msg_format("%^s¤Ï¶ìÄˤˤ¦¤á¤¤¤¿¡£", m_name);
4236 else msg_format("%s¤Ï°¥¤ì¤ÊÌĤÀ¼¤ò½Ð¤·¤¿¡£", m_name);
4238 if(percentage > 95) msg_format("%^s shrugs off the attack.", m_name);
4239 else if(percentage > 75) msg_format("%^s roars.", m_name);
4240 else if(percentage > 50) msg_format("%^s growls angrily.", m_name);
4241 else if(percentage > 35) msg_format("%^s hisses with pain.", m_name);
4242 else if(percentage > 20) msg_format("%^s mewls in pain.", m_name);
4243 else if(percentage > 10) msg_format("%^s hisses in agony.", m_name);
4244 else msg_format("%^s mewls pitifully.", m_name);
4248 else if(my_strchr("acFIKS", r_ptr->d_char)) // Ants, Centipedes, Flies, Insects, Beetles, Spiders
4251 if(percentage > 95) msg_format("%s¤Ï¹¶·â¤òµ¤¤Ë¤È¤á¤Æ¤¤¤Ê¤¤¡£", m_name);
4252 else if(percentage > 75) msg_format("%^s¤Ï¥¡¼¥¡¼ÌĤ¤¤¿¡£", m_name);
4253 else if(percentage > 50) msg_format("%^s¤Ï¥è¥í¥è¥íƨ¤²²ó¤Ã¤¿¡£", m_name);
4254 else if(percentage > 35) msg_format("%^s¤Ï¤¦¤ë¤µ¤¯ÌĤ¤¤¿¡£", m_name);
4255 else if(percentage > 20) msg_format("%^s¤ÏÄˤߤËáÛÚ»¤·¤¿¡£", m_name);
4256 else if(percentage > 10) msg_format("%^s¤Ï¶ìÄˤÇáÛÚ»¤·¤¿¡£", m_name);
4257 else msg_format("%^s¤Ï¥Ô¥¯¥Ô¥¯¤Ò¤¤Ä¤Ã¤¿¡£", m_name);
4259 if(percentage > 95) msg_format("%^s ignores the attack.", m_name);
4260 else if(percentage > 75) msg_format("%^s chitters.", m_name);
4261 else if(percentage > 50) msg_format("%^s scuttles about.", m_name);
4262 else if(percentage > 35) msg_format("%^s twitters.", m_name);
4263 else if(percentage > 20) msg_format("%^s jerks in pain.", m_name);
4264 else if(percentage > 10) msg_format("%^s jerks in agony.", m_name);
4265 else msg_format("%^s twitches.", m_name);
4269 else if(my_strchr("B", r_ptr->d_char)) // Birds
4272 if(percentage > 95) msg_format("%^s¤Ï¤µ¤¨¤º¤Ã¤¿¡£", m_name);
4273 else if(percentage > 75) msg_format("%^s¤Ï¥Ô¡¼¥Ô¡¼ÌĤ¤¤¿¡£", m_name);
4274 else if(percentage > 50) msg_format("%^s¤Ï¥®¥ã¡¼¥®¥ã¡¼ÌĤ¤¤¿¡£", m_name);
4275 else if(percentage > 35) msg_format("%^s¤Ï¥®¥ã¡¼¥®¥ã¡¼ÌĤ¤ï¤á¤¤¤¿¡£", m_name);
4276 else if(percentage > 20) msg_format("%^s¤Ï¶ì¤·¤ó¤À¡£", m_name);
4277 else if(percentage > 10) msg_format("%^s¤Ï¤Î¤¿¤¦¤Á²ó¤Ã¤¿¡£", m_name);
4278 else msg_format("%^s¤Ï¥¡¼¥¡¼¤ÈÌĤ¶«¤ó¤À¡£", m_name);
4280 if(percentage > 95) msg_format("%^s chirps.", m_name);
4281 else if(percentage > 75) msg_format("%^s twitters.", m_name);
4282 else if(percentage > 50) msg_format("%^s squawks.", m_name);
4283 else if(percentage > 35) msg_format("%^s chatters.", m_name);
4284 else if(percentage > 20) msg_format("%^s jeers.", m_name);
4285 else if(percentage > 10) msg_format("%^s flutters about.", m_name);
4286 else msg_format("%^s squeaks.", m_name);
4290 else if(my_strchr("duDLUW", r_ptr->d_char)) // Dragons, Demons, High Undead
4293 if(percentage > 95) msg_format("%s¤Ï¹¶·â¤òµ¤¤Ë¤È¤á¤Æ¤¤¤Ê¤¤¡£", m_name);
4294 else if(percentage > 75) msg_format("%^s¤Ï¤·¤ê¹þ¤ß¤·¤¿¡£", m_name);
4295 else if(percentage > 50) msg_format("%^s¤ÏÄˤߤǥ·¡¼¥Ã¤ÈÌĤ¤¤¿¡£", m_name);
4296 else if(percentage > 35) msg_format("%^s¤ÏÄˤߤǤ¦¤Ê¤Ã¤¿¡£", m_name);
4297 else if(percentage > 20) msg_format("%^s¤ÏÄˤߤËËʤ¨¤¿¡£", m_name);
4298 else if(percentage > 10) msg_format("%^s¤Ï¶ì¤·¤²¤Ë¶«¤ó¤À¡£", m_name);
4299 else msg_format("%^s¤Ï¼å¡¹¤·¤¯¤¦¤Ê¤Ã¤¿¡£", m_name);
4301 if(percentage > 95) msg_format("%^s ignores the attack.", m_name);
4302 else if(percentage > 75) msg_format("%^s flinches.", m_name);
4303 else if(percentage > 50) msg_format("%^s hisses in pain.", m_name);
4304 else if(percentage > 35) msg_format("%^s snarls with pain.", m_name);
4305 else if(percentage > 20) msg_format("%^s roars with pain.", m_name);
4306 else if(percentage > 10) msg_format("%^s gasps.", m_name);
4307 else msg_format("%^s snarls feebly.", m_name);
4311 else if(my_strchr("s", r_ptr->d_char)) // Skeletons
4314 if(percentage > 95) msg_format("%s¤Ï¹¶·â¤òµ¤¤Ë¤È¤á¤Æ¤¤¤Ê¤¤¡£", m_name);
4315 else if(percentage > 75) msg_format("%s¤Ï¹¶·â¤Ë¸ª¤ò¤¹¤¯¤á¤¿¡£", m_name);
4316 else if(percentage > 50) msg_format("%^s¤Ï¥«¥¿¥«¥¿¤È¾Ð¤Ã¤¿¡£", m_name);
4317 else if(percentage > 35) msg_format("%^s¤Ï¤è¤í¤á¤¤¤¿¡£", m_name);
4318 else if(percentage > 20) msg_format("%^s¤Ï¥«¥¿¥«¥¿¸À¤Ã¤¿¡£", m_name);
4319 else if(percentage > 10) msg_format("%^s¤Ï¤è¤í¤á¤¤¤¿¡£", m_name);
4320 else msg_format("%^s¤Ï¥¬¥¿¥¬¥¿¸À¤Ã¤¿¡£", m_name);
4322 if(percentage > 95) msg_format("%^s ignores the attack.", m_name);
4323 else if(percentage > 75) msg_format("%^s shrugs off the attack.", m_name);
4324 else if(percentage > 50) msg_format("%^s rattles.", m_name);
4325 else if(percentage > 35) msg_format("%^s stumbles.", m_name);
4326 else if(percentage > 20) msg_format("%^s rattles.", m_name);
4327 else if(percentage > 10) msg_format("%^s staggers.", m_name);
4328 else msg_format("%^s clatters.", m_name);
4332 else if(my_strchr("z", r_ptr->d_char)) // Zombies
4335 if(percentage > 95) msg_format("%s¤Ï¹¶·â¤òµ¤¤Ë¤È¤á¤Æ¤¤¤Ê¤¤¡£", m_name);
4336 else if(percentage > 75) msg_format("%s¤Ï¹¶·â¤Ë¸ª¤ò¤¹¤¯¤á¤¿¡£", m_name);
4337 else if(percentage > 50) msg_format("%^s¤Ï¤¦¤á¤¤¤¿¡£", m_name);
4338 else if(percentage > 35) msg_format("%s¤Ï¶ì¤·¤²¤Ë¤¦¤á¤¤¤¿¡£", m_name);
4339 else if(percentage > 20) msg_format("%^s¤Ïí´í°¤·¤¿¡£", m_name);
4340 else if(percentage > 10) msg_format("%^s¤Ï¤¦¤Ê¤Ã¤¿¡£", m_name);
4341 else msg_format("%^s¤Ï¤è¤í¤á¤¤¤¿¡£", m_name);
4343 if(percentage > 95) msg_format("%^s ignores the attack.", m_name);
4344 else if(percentage > 75) msg_format("%^s shrugs off the attack.", m_name);
4345 else if(percentage > 50) msg_format("%^s groans.", m_name);
4346 else if(percentage > 35) msg_format("%^s moans.", m_name);
4347 else if(percentage > 20) msg_format("%^s hesitates.", m_name);
4348 else if(percentage > 10) msg_format("%^s grunts.", m_name);
4349 else msg_format("%^s staggers.", m_name);
4353 else if(my_strchr("G", r_ptr->d_char)) // Ghosts
4356 if(percentage > 95) msg_format("%s¤Ï¹¶·â¤òµ¤¤Ë¤È¤á¤Æ¤¤¤Ê¤¤¡£", m_name);
4357 else if(percentage > 75) msg_format("%s¤Ï¹¶·â¤Ë¸ª¤ò¤¹¤¯¤á¤¿¡£", m_name);
4358 else if(percentage > 50) msg_format("%s¤Ï¤¦¤á¤¤¤¿¡£", m_name);
4359 else if(percentage > 35) msg_format("%^s¤Ïµã¤¤ï¤á¤¤¤¿¡£", m_name);
4360 else if(percentage > 20) msg_format("%^s¤ÏËʤ¨¤¿¡£", m_name);
4361 else if(percentage > 10) msg_format("%s¤Ï¼å¡¹¤·¤¯¤¦¤á¤¤¤¿¡£", m_name);
4362 else msg_format("%^s¤Ï¤«¤¹¤«¤Ë¤¦¤á¤¤¤¿¡£", m_name);
4364 if(percentage > 95) msg_format("%^s ignores the attack.", m_name);
4365 else if(percentage > 75) msg_format("%^s shrugs off the attack.", m_name);
4366 else if(percentage > 50) msg_format("%^s moans.", m_name);
4367 else if(percentage > 35) msg_format("%^s wails.", m_name);
4368 else if(percentage > 20) msg_format("%^s howls.", m_name);
4369 else if(percentage > 10) msg_format("%^s moans softly.", m_name);
4370 else msg_format("%^s sighs.", m_name);
4374 else if(my_strchr("CZ", r_ptr->d_char)) // Dogs and Hounds
4377 if(percentage > 95) msg_format("%^s¤Ï¹¶·â¤Ë¸ª¤ò¤¹¤¯¤á¤¿¡£", m_name);
4378 else if(percentage > 75) msg_format("%^s¤ÏÄˤߤǤ¦¤Ê¤Ã¤¿¡£", m_name);
4379 else if(percentage > 50) msg_format("%^s¤ÏÄˤߤǥ¥ã¥ó¥¥ã¥óËʤ¨¤¿¡£", m_name);
4380 else if(percentage > 35) msg_format("%^s¤ÏÄˤߤÇÌĤ¤ï¤á¤¤¤¿¡£", m_name);
4381 else if(percentage > 20) msg_format("%^s¤Ï¶ìÄˤΤ¢¤Þ¤êÌĤ¤ï¤á¤¤¤¿¡£", m_name);
4382 else if(percentage > 10) msg_format("%^s¤Ï¶ìÄˤǤâ¤À¤¨¶ì¤·¤ó¤À¡£", m_name);
4383 else msg_format("%^s¤Ï¼å¡¹¤·¤¯Ëʤ¨¤¿¡£", m_name);
4385 if(percentage > 95) msg_format("%^s shrugs off the attack.", m_name);
4386 else if(percentage > 75) msg_format("%^s snarls with pain.", m_name);
4387 else if(percentage > 50) msg_format("%^s yelps in pain.", m_name);
4388 else if(percentage > 35) msg_format("%^s howls in pain.", m_name);
4389 else if(percentage > 20) msg_format("%^s howls in agony.", m_name);
4390 else if(percentage > 10) msg_format("%^s writhes in agony.", m_name);
4391 else msg_format("%^s yelps feebly.", m_name);
4395 else if(my_strchr("Xbilqrt", r_ptr->d_char)) // One type of creatures (ignore,squeal,shriek)
4398 if(percentage > 95) msg_format("%^s¤Ï¹¶·â¤òµ¤¤Ë¤È¤á¤Æ¤¤¤Ê¤¤¡£", m_name);
4399 else if(percentage > 75) msg_format("%^s¤ÏÄˤߤǤ¦¤Ê¤Ã¤¿¡£", m_name);
4400 else if(percentage > 50) msg_format("%^s¤ÏÄˤߤǶ«¤ó¤À¡£", m_name);
4401 else if(percentage > 35) msg_format("%^s¤ÏÄˤߤÇÀ䶫¤·¤¿¡£", m_name);
4402 else if(percentage > 20) msg_format("%^s¤Ï¶ìÄˤΤ¢¤Þ¤êÀ䶫¤·¤¿¡£", m_name);
4403 else if(percentage > 10) msg_format("%^s¤Ï¶ìÄˤǤâ¤À¤¨¶ì¤·¤ó¤À¡£", m_name);
4404 else msg_format("%^s¤Ï¼å¡¹¤·¤¯¶«¤ó¤À¡£", m_name);
4406 if(percentage > 95) msg_format("%^s ignores the attack.", m_name);
4407 else if(percentage > 75) msg_format("%^s grunts with pain.", m_name);
4408 else if(percentage > 50) msg_format("%^s squeals in pain.", m_name);
4409 else if(percentage > 35) msg_format("%^s shrieks in pain.", m_name);
4410 else if(percentage > 20) msg_format("%^s shrieks in agony.", m_name);
4411 else if(percentage > 10) msg_format("%^s writhes in agony.", m_name);
4412 else msg_format("%^s cries out feebly.", m_name);
4416 else // Another type of creatures (shrug,cry,scream)
4419 if(percentage > 95) msg_format("%^s¤Ï¹¶·â¤Ë¸ª¤ò¤¹¤¯¤á¤¿¡£", m_name);
4420 else if(percentage > 75) msg_format("%^s¤ÏÄˤߤǤ¦¤Ê¤Ã¤¿¡£", m_name);
4421 else if(percentage > 50) msg_format("%^s¤ÏÄˤߤǶ«¤ó¤À¡£", m_name);
4422 else if(percentage > 35) msg_format("%^s¤ÏÄˤߤÇÀ䶫¤·¤¿¡£", m_name);
4423 else if(percentage > 20) msg_format("%^s¤Ï¶ìÄˤΤ¢¤Þ¤êÀ䶫¤·¤¿¡£", m_name);
4424 else if(percentage > 10) msg_format("%^s¤Ï¶ìÄˤǤâ¤À¤¨¶ì¤·¤ó¤À¡£", m_name);
4425 else msg_format("%^s¤Ï¼å¡¹¤·¤¯¶«¤ó¤À¡£", m_name);
4427 if(percentage > 95) msg_format("%^s shrugs off the attack.", m_name);
4428 else if(percentage > 75) msg_format("%^s grunts with pain.", m_name);
4429 else if(percentage > 50) msg_format("%^s cries out in pain.", m_name);
4430 else if(percentage > 35) msg_format("%^s screams in pain.", m_name);
4431 else if(percentage > 20) msg_format("%^s screams in agony.", m_name);
4432 else if(percentage > 10) msg_format("%^s writhes in agony.", m_name);
4433 else msg_format("%^s cries out feebly.", m_name);
4442 * Learn about an "observed" resistance.
4444 void update_smart_learn(int m_idx, int what)
4446 monster_type *m_ptr = &m_list[m_idx];
4448 monster_race *r_ptr = &r_info[m_ptr->r_idx];
4451 /* Not allowed to learn */
4452 if (!smart_learn) return;
4454 /* Too stupid to learn anything */
4455 if (r_ptr->flags2 & (RF2_STUPID)) return;
4457 /* Not intelligent, only learn sometimes */
4458 if (!(r_ptr->flags2 & (RF2_SMART)) && (randint0(100) < 50)) return;
4463 /* Analyze the knowledge */
4467 if (p_ptr->resist_acid) m_ptr->smart |= (SM_RES_ACID);
4468 if (IS_OPPOSE_ACID()) m_ptr->smart |= (SM_OPP_ACID);
4469 if (p_ptr->immune_acid) m_ptr->smart |= (SM_IMM_ACID);
4473 if (p_ptr->resist_elec) m_ptr->smart |= (SM_RES_ELEC);
4474 if (IS_OPPOSE_ELEC()) m_ptr->smart |= (SM_OPP_ELEC);
4475 if (p_ptr->immune_elec) m_ptr->smart |= (SM_IMM_ELEC);
4479 if (p_ptr->resist_fire) m_ptr->smart |= (SM_RES_FIRE);
4480 if (IS_OPPOSE_FIRE()) m_ptr->smart |= (SM_OPP_FIRE);
4481 if (p_ptr->immune_fire) m_ptr->smart |= (SM_IMM_FIRE);
4485 if (p_ptr->resist_cold) m_ptr->smart |= (SM_RES_COLD);
4486 if (IS_OPPOSE_COLD()) m_ptr->smart |= (SM_OPP_COLD);
4487 if (p_ptr->immune_cold) m_ptr->smart |= (SM_IMM_COLD);
4491 if (p_ptr->resist_pois) m_ptr->smart |= (SM_RES_POIS);
4492 if (IS_OPPOSE_POIS()) m_ptr->smart |= (SM_OPP_POIS);
4497 if (p_ptr->resist_neth) m_ptr->smart |= (SM_RES_NETH);
4501 if (p_ptr->resist_lite) m_ptr->smart |= (SM_RES_LITE);
4505 if (p_ptr->resist_dark) m_ptr->smart |= (SM_RES_DARK);
4509 if (p_ptr->resist_fear) m_ptr->smart |= (SM_RES_FEAR);
4513 if (p_ptr->resist_conf) m_ptr->smart |= (SM_RES_CONF);
4517 if (p_ptr->resist_chaos) m_ptr->smart |= (SM_RES_CHAOS);
4521 if (p_ptr->resist_disen) m_ptr->smart |= (SM_RES_DISEN);
4525 if (p_ptr->resist_blind) m_ptr->smart |= (SM_RES_BLIND);
4529 if (p_ptr->resist_nexus) m_ptr->smart |= (SM_RES_NEXUS);
4533 if (p_ptr->resist_sound) m_ptr->smart |= (SM_RES_SOUND);
4537 if (p_ptr->resist_shard) m_ptr->smart |= (SM_RES_SHARD);
4541 if (p_ptr->free_act) m_ptr->smart |= (SM_IMM_FREE);
4545 if (!p_ptr->msp) m_ptr->smart |= (SM_IMM_MANA);
4549 if (p_ptr->reflect) m_ptr-> smart |= (SM_IMM_REFLECT);
4556 * Place the player in the dungeon XXX XXX
4558 bool player_place(int y, int x)
4560 /* Paranoia XXX XXX */
4561 if (cave[y][x].m_idx != 0) return FALSE;
4563 /* Save player location */
4573 * Drop all items carried by a monster
4575 void monster_drop_carried_objects(monster_type *m_ptr)
4577 s16b this_o_idx, next_o_idx = 0;
4583 /* Drop objects being carried */
4584 for (this_o_idx = m_ptr->hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
4586 /* Acquire object */
4587 o_ptr = &o_list[this_o_idx];
4589 /* Acquire next object */
4590 next_o_idx = o_ptr->next_o_idx;
4592 /* Get local object */
4595 /* Copy the object */
4596 object_copy(q_ptr, o_ptr);
4598 /* Forget monster */
4599 q_ptr->held_m_idx = 0;
4601 /* Delete the object */
4602 delete_object_idx(this_o_idx);
4605 (void)drop_near(q_ptr, -1, m_ptr->fy, m_ptr->fx);
4608 /* Forget objects */
4609 m_ptr->hold_o_idx = 0;