4 * Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke
6 * This software may be copied and distributed for educational, research,
7 * and not for profit purposes provided that this copyright and statement
8 * are included in all such copies. Other copyrights may also apply.
11 /* Purpose: misc code for monsters */
15 #define HORDE_NOGOOD 0x01
16 #define HORDE_NOEVIL 0x02
20 cptr horror_desc[MAX_SAN_HORROR] =
74 cptr funny_desc[MAX_SAN_FUNNY] =
89 "¥Õ¥¡¥ó¥¿¥¹¥Æ¥£¥Ã¥¯¤Ê",
134 cptr funny_comments[MAX_SAN_COMMENT] =
155 * Set the target of counter attack
157 void set_target(monster_type *m_ptr, int y, int x)
165 * Reset the target of counter attack
167 void reset_target(monster_type *m_ptr)
169 set_target(m_ptr, 0, 0);
174 * Extract monster race pointer of a monster's true form
176 monster_race *real_r_ptr(monster_type *m_ptr)
178 monster_race *r_ptr = &r_info[m_ptr->r_idx];
180 /* Extract real race */
181 if (m_ptr->mflag2 & MFLAG2_CHAMELEON)
183 if (r_ptr->flags1 & RF1_UNIQUE)
184 return &r_info[MON_CHAMELEON_K];
186 return &r_info[MON_CHAMELEON];
196 * Delete a monster by index.
198 * When a monster is deleted, all of its objects are deleted.
200 void delete_monster_idx(int i)
204 monster_type *m_ptr = &m_list[i];
206 monster_race *r_ptr = &r_info[m_ptr->r_idx];
208 s16b this_o_idx, next_o_idx = 0;
216 /* Hack -- Reduce the racial counter */
217 real_r_ptr(m_ptr)->cur_num--;
219 /* Hack -- count the number of "reproducers" */
220 if (r_ptr->flags2 & (RF2_MULTIPLY)) num_repro--;
223 /* Hack -- remove target monster */
224 if (i == target_who) target_who = 0;
226 /* Hack -- remove tracked monster */
227 if (i == p_ptr->health_who) health_track(0);
229 if (pet_t_m_idx == i ) pet_t_m_idx = 0;
230 if (riding_t_m_idx == i) riding_t_m_idx = 0;
231 if (p_ptr->riding == i) p_ptr->riding = 0;
233 /* Monster is gone */
234 cave[y][x].m_idx = 0;
238 for (this_o_idx = m_ptr->hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
243 o_ptr = &o_list[this_o_idx];
245 /* Acquire next object */
246 next_o_idx = o_ptr->next_o_idx;
248 /* Hack -- efficiency */
249 o_ptr->held_m_idx = 0;
251 /* Delete the object */
252 delete_object_idx(this_o_idx);
256 /* Wipe the Monster */
257 (void)WIPE(m_ptr, monster_type);
265 /* Update some things */
266 p_ptr->update |= (PU_MON_LITE);
271 * Delete the monster, if any, at a given location
273 void delete_monster(int y, int x)
278 if (!in_bounds(y, x)) return;
283 /* Delete the monster (if any) */
284 if (c_ptr->m_idx) delete_monster_idx(c_ptr->m_idx);
289 * Move an object from index i1 to index i2 in the object list
291 static void compact_monsters_aux(int i1, int i2)
299 s16b this_o_idx, next_o_idx = 0;
303 if (i1 == i2) return;
316 /* Update the cave */
319 /* Repair objects being carried by monster */
320 for (this_o_idx = m_ptr->hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
325 o_ptr = &o_list[this_o_idx];
327 /* Acquire next object */
328 next_o_idx = o_ptr->next_o_idx;
330 /* Reset monster pointer */
331 o_ptr->held_m_idx = i2;
334 /* Hack -- Update the target */
335 if (target_who == i1) target_who = i2;
337 /* Hack -- Update the target */
338 if (pet_t_m_idx == i1) pet_t_m_idx = i2;
339 if (riding_t_m_idx == i1) riding_t_m_idx = i2;
341 /* Hack -- Update the riding */
342 if (p_ptr->riding == i1) p_ptr->riding = i2;
344 /* Hack -- Update the health bar */
345 if (p_ptr->health_who == i1) health_track(i2);
348 COPY(&m_list[i2], &m_list[i1], monster_type);
351 (void)WIPE(&m_list[i1], monster_type);
357 * Compact and Reorder the monster list
359 * This function can be very dangerous, use with caution!
361 * When actually "compacting" monsters, we base the saving throw
362 * on a combination of monster level, distance from player, and
363 * current "desperation".
365 * After "compacting" (if needed), we "reorder" the monsters into a more
366 * compact order, and we reset the allocation info, and the "live" array.
368 void compact_monsters(int size)
371 int cur_lev, cur_dis, chance;
373 /* Message (only if compacting) */
375 if (size) msg_print("¥â¥ó¥¹¥¿¡¼¾ðÊó¤ò°µ½Ì¤·¤Æ¤¤¤Þ¤¹...");
377 if (size) msg_print("Compacting monsters...");
381 /* Compact at least 'size' objects */
382 for (num = 0, cnt = 1; num < size; cnt++)
384 /* Get more vicious each iteration */
387 /* Get closer each iteration */
388 cur_dis = 5 * (20 - cnt);
390 /* Check all the monsters */
391 for (i = 1; i < m_max; i++)
393 monster_type *m_ptr = &m_list[i];
395 monster_race *r_ptr = &r_info[m_ptr->r_idx];
397 /* Paranoia -- skip "dead" monsters */
398 if (!m_ptr->r_idx) continue;
400 /* Hack -- High level monsters start out "immune" */
401 if (r_ptr->level > cur_lev) continue;
403 if (i == p_ptr->riding) continue;
405 /* Ignore nearby monsters */
406 if ((cur_dis > 0) && (m_ptr->cdis < cur_dis)) continue;
408 /* Saving throw chance */
411 /* Only compact "Quest" Monsters in emergencies */
412 if ((r_ptr->flags1 & (RF1_QUESTOR)) && (cnt < 1000)) chance = 100;
414 /* Try not to compact Unique Monsters */
415 if (r_ptr->flags1 & (RF1_UNIQUE)) chance = 100;
417 /* All monsters get a saving throw */
418 if (randint0(100) < chance) continue;
420 /* Delete the monster */
421 delete_monster_idx(i);
423 /* Count the monster */
429 /* Excise dead monsters (backwards!) */
430 for (i = m_max - 1; i >= 1; i--)
432 /* Get the i'th monster */
433 monster_type *m_ptr = &m_list[i];
435 /* Skip real monsters */
436 if (m_ptr->r_idx) continue;
438 /* Move last monster into open hole */
439 compact_monsters_aux(m_max - 1, i);
441 /* Compress "m_max" */
448 * Pre-calculate the racial counters of preserved pets
449 * To prevent multiple generation of unique monster who is the minion of player
451 void precalc_cur_num_of_pet(void)
455 int max_num = p_ptr->wild_mode ? 1 : MAX_PARTY_MON;
457 for (i = 0; i < max_num; i++)
459 m_ptr = &party_mon[i];
461 /* Skip empty monsters */
462 if (!m_ptr->r_idx) continue;
464 /* Hack -- Increase the racial counter */
465 real_r_ptr(m_ptr)->cur_num++;
471 * Delete/Remove all the monsters when the player leaves the level
473 * This is an efficient method of simulating multiple calls to the
474 * "delete_monster()" function, with no visual effects.
476 void wipe_m_list(void)
480 /* Hack -- if Banor or Lupart dies, stay another dead */
481 if (!r_info[MON_BANORLUPART].max_num)
483 if (r_info[MON_BANOR].max_num)
485 r_info[MON_BANOR].max_num = 0;
486 r_info[MON_BANOR].r_pkills++;
487 if (r_info[MON_BANOR].r_tkills < MAX_SHORT) r_info[MON_BANOR].r_tkills++;
489 if (r_info[MON_LUPART].max_num)
491 r_info[MON_LUPART].max_num = 0;
492 r_info[MON_LUPART].r_pkills++;
493 if (r_info[MON_LUPART].r_tkills < MAX_SHORT) r_info[MON_LUPART].r_tkills++;
497 /* Delete all the monsters */
498 for (i = m_max - 1; i >= 1; i--)
500 monster_type *m_ptr = &m_list[i];
502 /* Skip dead monsters */
503 if (!m_ptr->r_idx) continue;
505 /* Monster is gone */
506 cave[m_ptr->fy][m_ptr->fx].m_idx = 0;
508 /* Wipe the Monster */
509 (void)WIPE(m_ptr, monster_type);
514 * Wiping racial counters of all monsters and incrementing of racial
515 * counters of monsters in party_mon[] is required to prevent multiple
516 * generation of unique monster who is the minion of player.
519 /* Hack -- Wipe the racial counter of all monster races */
520 for (i = 1; i < max_r_idx; i++) r_info[i].cur_num = 0;
522 /* Hack -- Increase the racial counters of pets */
523 precalc_cur_num_of_pet();
531 /* Hack -- reset "reproducer" count */
534 /* Hack -- no more target */
539 /* Hack -- no more tracking */
545 * Acquires and returns the index of a "free" monster.
547 * This routine should almost never fail, but it *can* happen.
554 /* Normal allocation */
555 if (m_max < max_m_idx)
557 /* Access the next hole */
560 /* Expand the array */
566 /* Return the index */
571 /* Recycle dead monsters */
572 for (i = 1; i < m_max; i++)
576 /* Acquire monster */
579 /* Skip live monsters */
580 if (m_ptr->r_idx) continue;
585 /* Use this monster */
590 /* Warn the player (except during dungeon creation) */
592 if (character_dungeon) msg_print("¥â¥ó¥¹¥¿¡¼¤¬Â¿¤¹¤®¤ë¡ª");
594 if (character_dungeon) msg_print("Too many monsters!");
598 /* Try not to crash */
606 * Hack -- the "type" of the current "summon specific"
608 static int summon_specific_type = 0;
612 * Hack -- the index of the summoning monster
614 static int summon_specific_who = -1;
618 * Hack -- the hostility of the summoned monster
620 static bool summon_specific_hostile = TRUE;
622 static bool summon_unique_okay = FALSE;
625 static bool summon_specific_aux(int r_idx)
627 monster_race *r_ptr = &r_info[r_idx];
630 /* Check our requirements */
631 switch (summon_specific_type)
635 okay = (r_ptr->d_char == 'a');
641 okay = (r_ptr->d_char == 'S');
647 okay = ((r_ptr->d_char == 'C') || (r_ptr->d_char == 'Z'));
653 okay = (r_ptr->d_char == 'M');
659 okay = (r_ptr->d_char == 'A' && ((r_ptr->flags3 & RF3_EVIL) || (r_ptr->flags3 & RF3_GOOD)));
665 okay = (r_ptr->flags3 & RF3_DEMON);
671 okay = (r_ptr->flags3 & RF3_UNDEAD);
677 okay = (r_ptr->flags3 & RF3_DRAGON);
681 case SUMMON_HI_UNDEAD:
683 okay = ((r_ptr->d_char == 'L') ||
684 (r_ptr->d_char == 'V') ||
685 (r_ptr->d_char == 'W'));
689 case SUMMON_HI_DRAGON:
691 okay = (r_ptr->d_char == 'D');
695 case SUMMON_HI_DEMON:
697 okay = (((r_ptr->d_char == 'U') ||
698 (r_ptr->d_char == 'H') ||
699 (r_ptr->d_char == 'B')) &&
700 (r_ptr->flags3 & RF3_DEMON)) ? TRUE : FALSE;
704 case SUMMON_AMBERITES:
706 okay = (r_ptr->flags3 & (RF3_AMBERITE)) ? TRUE : FALSE;
712 okay = (r_ptr->flags1 & (RF1_UNIQUE)) ? TRUE : FALSE;
716 case SUMMON_BIZARRE1:
718 okay = (r_ptr->d_char == 'm');
721 case SUMMON_BIZARRE2:
723 okay = (r_ptr->d_char == 'b');
726 case SUMMON_BIZARRE3:
728 okay = (r_ptr->d_char == 'Q');
732 case SUMMON_BIZARRE4:
734 okay = (r_ptr->d_char == 'v');
738 case SUMMON_BIZARRE5:
740 okay = (r_ptr->d_char == '$');
744 case SUMMON_BIZARRE6:
746 okay = ((r_ptr->d_char == '!') ||
747 (r_ptr->d_char == '?') ||
748 (r_ptr->d_char == '=') ||
749 (r_ptr->d_char == '$') ||
750 (r_ptr->d_char == '|'));
756 okay = (r_ptr->d_char == 'g');
762 okay = ((r_ptr->d_char == 'U') &&
763 (r_ptr->flags4 & RF4_ROCKET));
770 okay = ((r_ptr->d_char == summon_kin_type) && (r_idx != MON_HAGURE));
776 okay = (r_idx == MON_DAWN);
782 okay = (r_ptr->flags3 & (RF3_ANIMAL));
786 case SUMMON_ANIMAL_RANGER:
788 okay = ((r_ptr->flags3 & (RF3_ANIMAL)) &&
789 (strchr("abcflqrwBCHIJKMRS", r_ptr->d_char)) &&
790 !(r_ptr->flags3 & (RF3_DRAGON)) &&
791 !(r_ptr->flags3 & (RF3_EVIL)) &&
792 !(r_ptr->flags3 & (RF3_UNDEAD)) &&
793 !(r_ptr->flags3 & (RF3_DEMON)) &&
794 !(r_ptr->flags2 & (RF2_MULTIPLY)) &&
795 !(r_ptr->flags4 || r_ptr->flags5 || r_ptr->flags6));
799 case SUMMON_HI_DRAGON_LIVING:
801 okay = ((r_ptr->d_char == 'D') &&
802 !(r_ptr->flags3 & (RF3_DEMON | RF3_UNDEAD | RF3_NONLIVING)));
808 okay = (!(r_ptr->flags3 & (RF3_DEMON | RF3_UNDEAD | RF3_NONLIVING)));
814 okay = (r_idx == MON_PHANTOM_B || r_idx == MON_PHANTOM_W);
818 case SUMMON_BLUE_HORROR:
820 okay = (r_idx == MON_BLUE_HORROR);
824 case SUMMON_ELEMENTAL:
826 okay = (r_ptr->d_char == 'E');
832 okay = (r_ptr->d_char == 'v');
838 okay = (r_ptr->d_char == 'H');
844 okay = (r_ptr->d_char == 'B');
848 case SUMMON_KAMIKAZE:
851 for (i = 0; i < 4; i++)
852 if (r_ptr->blow[i].method == RBM_EXPLODE) okay = TRUE;
856 case SUMMON_KAMIKAZE_LIVING:
860 for (i = 0; i < 4; i++)
861 if (r_ptr->blow[i].method == RBM_EXPLODE) okay = TRUE;
862 okay = (okay && (!(r_ptr->flags3 & (RF3_DEMON | RF3_UNDEAD | RF3_NONLIVING))));
868 okay = (r_idx == MON_MANES);
874 okay = (r_idx == MON_LOUSE);
878 case SUMMON_GUARDIANS:
880 okay = (r_ptr->flags7 & RF7_GUARDIAN);
886 okay = ((r_idx == MON_NOV_PALADIN) ||
887 (r_idx == MON_NOV_PALADIN_G) ||
888 (r_idx == MON_PALADIN) ||
889 (r_idx == MON_W_KNIGHT) ||
890 (r_idx == MON_ULTRA_PALADIN) ||
891 (r_idx == MON_KNI_TEMPLAR));
897 okay = (r_ptr->d_char == 'B' &&
898 (r_ptr->flags8 & RF8_WILD_MOUNTAIN) &&
899 (r_ptr->flags8 & RF8_WILD_ONLY));
903 case SUMMON_PIRANHAS:
905 okay = (r_idx == MON_PIRANHA);
909 case SUMMON_ARMAGE_GOOD:
911 okay = (r_ptr->d_char == 'A' && (r_ptr->flags3 & RF3_GOOD));
915 case SUMMON_ARMAGE_EVIL:
917 okay = ((r_ptr->flags3 & RF3_DEMON) ||
918 (r_ptr->d_char == 'A' && (r_ptr->flags3 & RF3_EVIL)));
924 /* Since okay is int, "return (okay);" is not correct. */
925 return (bool)(okay ? TRUE : FALSE);
929 static int chameleon_change_m_idx = 0;
933 * Some dungeon types restrict the possible monsters.
934 * Return TRUE is the monster is OK and FALSE otherwise
936 static bool restrict_monster_to_dungeon(int r_idx)
938 dungeon_info_type *d_ptr = &d_info[dungeon_type];
939 monster_race *r_ptr = &r_info[r_idx];
942 if (d_ptr->flags1 & DF1_CHAMELEON)
944 if (chameleon_change_m_idx) return TRUE;
946 if (d_ptr->flags1 & DF1_NO_MAGIC)
948 if (r_idx != MON_CHAMELEON &&
950 !(r_ptr->flags4 & RF4_NOMAGIC_MASK) &&
951 !(r_ptr->flags5 & RF5_NOMAGIC_MASK) &&
952 !(r_ptr->flags6 & RF6_NOMAGIC_MASK))
955 if (d_ptr->flags1 & DF1_NO_MELEE)
957 if (r_idx == MON_CHAMELEON) return TRUE;
958 if (!(r_ptr->flags4 & (RF4_BOLT_MASK | RF4_BEAM_MASK | RF4_BALL_MASK)) &&
959 !(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)) &&
960 !(r_ptr->flags6 & (RF6_BOLT_MASK | RF6_BEAM_MASK | RF6_BALL_MASK)))
963 if (d_ptr->flags1 & DF1_BEGINNER)
965 if (r_ptr->level > dun_level)
969 if (d_ptr->special_div == 64) return TRUE;
970 if (summon_specific_type && !(d_ptr->flags1 & DF1_CHAMELEON)) return TRUE;
972 if(d_ptr->mode == DUNGEON_MODE_AND)
976 if((d_ptr->mflags1 & r_ptr->flags1) != d_ptr->mflags1)
981 if((d_ptr->mflags2 & r_ptr->flags2) != d_ptr->mflags2)
986 if((d_ptr->mflags3 & r_ptr->flags3) != d_ptr->mflags3)
991 if((d_ptr->mflags4 & r_ptr->flags4) != d_ptr->mflags4)
996 if((d_ptr->mflags5 & r_ptr->flags5) != d_ptr->mflags5)
1001 if((d_ptr->mflags6 & r_ptr->flags6) != d_ptr->mflags6)
1006 if((d_ptr->mflags7 & r_ptr->flags7) != d_ptr->mflags7)
1011 if((d_ptr->mflags8 & r_ptr->flags8) != d_ptr->mflags8)
1016 if((d_ptr->mflags9 & r_ptr->flags9) != d_ptr->mflags9)
1019 for(a = 0; a < 5; a++)
1020 if(d_ptr->r_char[a] && (d_ptr->r_char[a] != r_ptr->d_char)) return FALSE;
1022 else if(d_ptr->mode == DUNGEON_MODE_NAND)
1024 byte ok[9 + 5], i = 0, j = 0;
1029 if(d_ptr->mflags1 & r_ptr->flags1)
1035 if(d_ptr->mflags2 & r_ptr->flags2)
1041 if(d_ptr->mflags3 & r_ptr->flags3)
1047 if(d_ptr->mflags4 & r_ptr->flags4)
1053 if(d_ptr->mflags5 & r_ptr->flags5)
1059 if(d_ptr->mflags6 & r_ptr->flags6)
1065 if(d_ptr->mflags7 & r_ptr->flags7)
1071 if(d_ptr->mflags8 & r_ptr->flags8)
1077 if(d_ptr->mflags9 & r_ptr->flags9)
1081 for(a = 0; a < 5; a++)
1083 if(d_ptr->r_char[a])
1086 if (d_ptr->r_char[a] != r_ptr->d_char) ok[9 + a] = 1;
1090 j = ok[0] + ok[1] + ok[2] + ok[3] + ok[4] + ok[5] + ok[6] + ok[7] + ok[8] + ok[9] + ok[10] + ok[11] + ok[12] + ok[13];
1092 if(i == j) return FALSE;
1094 else if(d_ptr->mode == DUNGEON_MODE_OR)
1099 for(i = 0; i < 32; i++)
1101 flag = d_ptr->mflags1 & (1 << i);
1102 if(r_ptr->flags1 & flag) ok = TRUE;
1104 flag = d_ptr->mflags2 & (1 << i);
1105 if(r_ptr->flags2 & flag) ok = TRUE;
1107 flag = d_ptr->mflags3 & (1 << i);
1108 if(r_ptr->flags3 & flag) ok = TRUE;
1110 flag = d_ptr->mflags4 & (1 << i);
1111 if(r_ptr->flags4 & flag) ok = TRUE;
1113 flag = d_ptr->mflags5 & (1 << i);
1114 if(r_ptr->flags5 & flag) ok = TRUE;
1116 flag = d_ptr->mflags6 & (1 << i);
1117 if(r_ptr->flags6 & flag) ok = TRUE;
1119 flag = d_ptr->mflags7 & (1 << i);
1120 if(r_ptr->flags7 & flag) ok = TRUE;
1122 flag = d_ptr->mflags8 & (1 << i);
1123 if(r_ptr->flags8 & flag) ok = TRUE;
1125 flag = d_ptr->mflags9 & (1 << i);
1126 if(r_ptr->flags9 & flag) ok = TRUE;
1128 for(a = 0; a < 5; a++)
1129 if(d_ptr->r_char[a] == r_ptr->d_char) ok = TRUE;
1133 else if(d_ptr->mode == DUNGEON_MODE_NOR)
1138 for(i = 0; i < 32; i++)
1140 flag = d_ptr->mflags1 & (1 << i);
1141 if(r_ptr->flags1 & flag) ok = FALSE;
1143 flag = d_ptr->mflags2 & (1 << i);
1144 if(r_ptr->flags2 & flag) ok = FALSE;
1146 flag = d_ptr->mflags3 & (1 << i);
1147 if(r_ptr->flags3 & flag) ok = FALSE;
1149 flag = d_ptr->mflags4 & (1 << i);
1150 if(r_ptr->flags4 & flag) ok = FALSE;
1152 flag = d_ptr->mflags5 & (1 << i);
1153 if(r_ptr->flags5 & flag) ok = FALSE;
1155 flag = d_ptr->mflags6 & (1 << i);
1156 if(r_ptr->flags6 & flag) ok = FALSE;
1158 flag = d_ptr->mflags7 & (1 << i);
1159 if(r_ptr->flags7 & flag) ok = FALSE;
1161 flag = d_ptr->mflags8 & (1 << i);
1162 if(r_ptr->flags8 & flag) ok = FALSE;
1164 flag = d_ptr->mflags9 & (1 << i);
1165 if(r_ptr->flags9 & flag) ok = FALSE;
1167 for(a = 0; a < 5; a++)
1168 if(d_ptr->r_char[a] == r_ptr->d_char) ok = FALSE;
1176 * Apply a "monster restriction function" to the "monster allocation table"
1178 errr get_mon_num_prep(monster_hook_type monster_hook,
1179 monster_hook_type monster_hook2)
1183 /* Todo: Check the hooks for non-changes */
1185 /* Set the new hooks */
1186 get_mon_num_hook = monster_hook;
1187 get_mon_num2_hook = monster_hook2;
1189 /* Scan the allocation table */
1190 for (i = 0; i < alloc_race_size; i++)
1192 monster_race *r_ptr;
1195 alloc_entry *entry = &alloc_race_table[i];
1198 r_ptr = &r_info[entry->index];
1200 /* Skip monsters which don't pass the restriction */
1201 if ((get_mon_num_hook && !((*get_mon_num_hook)(entry->index))) ||
1202 (get_mon_num2_hook && !((*get_mon_num2_hook)(entry->index))))
1205 if (!p_ptr->inside_battle && !chameleon_change_m_idx &&
1206 summon_specific_type != SUMMON_GUARDIANS)
1208 /* Hack -- don't create questors */
1209 if (r_ptr->flags1 & RF1_QUESTOR)
1212 if (r_ptr->flags7 & RF7_GUARDIAN)
1215 /* Depth Monsters never appear out of depth */
1216 if ((r_ptr->flags1 & (RF1_FORCE_DEPTH)) &&
1217 (r_ptr->level > dun_level))
1221 /* Accept this monster */
1222 entry->prob2 = entry->prob1;
1224 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)
1226 int hoge = entry->prob2 * d_info[dungeon_type].special_div;
1227 entry->prob2 = hoge / 64;
1228 if (randint0(64) < (hoge & 0x3f)) entry->prob2++;
1237 static int mysqrt(int n)
1275 * Choose a monster race that seems "appropriate" to the given level
1277 * This function uses the "prob2" field of the "monster allocation table",
1278 * and various local information, to calculate the "prob3" field of the
1279 * same table, which is then used to choose an "appropriate" monster, in
1280 * a relatively efficient manner.
1282 * Note that "town" monsters will *only* be created in the town, and
1283 * "normal" monsters will *never* be created in the town, unless the
1284 * "level" is "modified", for example, by polymorph or summoning.
1286 * There is a small chance (1/50) of "boosting" the given depth by
1287 * a small amount (up to four levels), except in the town.
1289 * It is (slightly) more likely to acquire a monster of the given level
1290 * than one of a lower level. This is done by choosing several monsters
1291 * appropriate to the given level and keeping the "hardest" one.
1293 * Note that if no monsters are "appropriate", then this function will
1294 * fail, and return zero, but this should *almost* never happen.
1296 s16b get_mon_num(int level)
1304 monster_race *r_ptr;
1306 alloc_entry *table = alloc_race_table;
1308 int pls_kakuritu, pls_level;
1309 int hoge=mysqrt(level*10000L);
1311 if (level > MAX_DEPTH - 1) level = MAX_DEPTH - 1;
1313 if ((dungeon_turn > hoge*(TURNS_PER_TICK*500L)) && !level)
1315 pls_kakuritu = MAX(2, NASTY_MON-((dungeon_turn/(TURNS_PER_TICK*2500L)-hoge/10)));
1316 pls_level = MIN(8,3 + dungeon_turn/(TURNS_PER_TICK*20000L)-hoge/40);
1320 pls_kakuritu = NASTY_MON;
1324 if (d_info[dungeon_type].flags1 & DF1_MAZE)
1326 pls_kakuritu = MIN(pls_kakuritu/2, pls_kakuritu-10);
1327 if (pls_kakuritu < 2) pls_kakuritu = 2;
1332 /* Boost the level */
1333 if ((level > 0) && !p_ptr->inside_battle && !(d_info[dungeon_type].flags1 & DF1_BEGINNER))
1335 /* Nightmare mode allows more out-of depth monsters */
1336 if (ironman_nightmare && !randint0(pls_kakuritu))
1338 /* What a bizarre calculation */
1339 level = 1 + (level * MAX_DEPTH / randint1(MAX_DEPTH));
1343 /* Occasional "nasty" monster */
1344 if (!randint0(pls_kakuritu))
1346 /* Pick a level bonus */
1347 int d = MIN(5, level/10) + pls_level;
1349 /* Boost the level */
1353 /* Occasional "nasty" monster */
1354 if (!randint0(pls_kakuritu))
1356 /* Pick a level bonus */
1357 int d = MIN(5, level/10) + pls_level;
1359 /* Boost the level */
1369 /* Process probabilities */
1370 for (i = 0; i < alloc_race_size; i++)
1372 /* Monsters are sorted by depth */
1373 if (table[i].level > level) break;
1378 /* Access the "r_idx" of the chosen monster */
1379 r_idx = table[i].index;
1381 /* Access the actual race */
1382 r_ptr = &r_info[r_idx];
1384 if (!p_ptr->inside_battle && !chameleon_change_m_idx)
1386 /* Hack -- "unique" monsters must be "unique" */
1387 if (((r_ptr->flags1 & (RF1_UNIQUE)) ||
1388 (r_ptr->flags7 & (RF7_UNIQUE_7))) &&
1389 (r_ptr->cur_num >= r_ptr->max_num))
1394 if ((r_ptr->flags7 & (RF7_UNIQUE2)) &&
1395 (r_ptr->cur_num >= 1))
1400 if (r_idx == MON_BANORLUPART)
1402 if (r_info[MON_BANOR].cur_num > 0) continue;
1403 if (r_info[MON_LUPART].cur_num > 0) continue;
1408 table[i].prob3 = table[i].prob2;
1411 total += table[i].prob3;
1414 /* No legal monsters */
1415 if (total <= 0) return (0);
1418 /* Pick a monster */
1419 value = randint0(total);
1421 /* Find the monster */
1422 for (i = 0; i < alloc_race_size; i++)
1424 /* Found the entry */
1425 if (value < table[i].prob3) break;
1428 value = value - table[i].prob3;
1435 /* Try for a "harder" monster once (50%) or twice (10%) */
1441 /* Pick a monster */
1442 value = randint0(total);
1444 /* Find the monster */
1445 for (i = 0; i < alloc_race_size; i++)
1447 /* Found the entry */
1448 if (value < table[i].prob3) break;
1451 value = value - table[i].prob3;
1454 /* Keep the "best" one */
1455 if (table[i].level < table[j].level) i = j;
1458 /* Try for a "harder" monster twice (10%) */
1464 /* Pick a monster */
1465 value = randint0(total);
1467 /* Find the monster */
1468 for (i = 0; i < alloc_race_size; i++)
1470 /* Found the entry */
1471 if (value < table[i].prob3) break;
1474 value = value - table[i].prob3;
1477 /* Keep the "best" one */
1478 if (table[i].level < table[j].level) i = j;
1482 return (table[i].index);
1490 * Build a string describing a monster in some way.
1492 * We can correctly describe monsters based on their visibility.
1493 * We can force all monsters to be treated as visible or invisible.
1494 * We can build nominatives, objectives, possessives, or reflexives.
1495 * We can selectively pronominalize hidden, visible, or all monsters.
1496 * We can use definite or indefinite descriptions for hidden monsters.
1497 * We can use definite or indefinite descriptions for visible monsters.
1499 * Pronominalization involves the gender whenever possible and allowed,
1500 * so that by cleverly requesting pronominalization / visibility, you
1501 * can get messages like "You hit someone. She screams in agony!".
1503 * Reflexives are acquired by requesting Objective plus Possessive.
1505 * If no m_ptr arg is given (?), the monster is assumed to be hidden,
1506 * unless the "Assume Visible" mode is requested.
1508 * If no r_ptr arg is given, it is extracted from m_ptr and r_info
1509 * If neither m_ptr nor r_ptr is given, the monster is assumed to
1510 * be neuter, singular, and hidden (unless "Assume Visible" is set),
1511 * in which case you may be in trouble... :-)
1513 * I am assuming that no monster name is more than 70 characters long,
1514 * so that "char desc[80];" is sufficiently large for any result.
1517 * MD_OBJECTIVE --> Objective (or Reflexive)
1518 * MD_POSSESSIVE --> Possessive (or Reflexive)
1519 * MD_INDEF_HIDDEN --> Use indefinites for hidden monsters ("something")
1520 * MD_INDEF_VISIBLE --> Use indefinites for visible monsters ("a kobold")
1521 * MD_PRON_HIDDEN --> Pronominalize hidden monsters
1522 * MD_PRON_VISIBLE --> Pronominalize visible monsters
1523 * MD_ASSUME_HIDDEN --> Assume the monster is hidden
1524 * MD_ASSUME_VISIBLE --> Assume the monster is visible
1525 * MD_TRUE_NAME --> Chameleon's true name
1526 * MD_IGNORE_HALLU --> Ignore hallucination, and penetrate shape change
1527 * MD_ASSUME_OUTSIDE --> Assume this monster pet waiting outside the floor
1530 * 0x00 --> Full nominative name ("the kobold") or "it"
1531 * MD_INDEF_HIDDEN --> Full nominative name ("the kobold") or "something"
1532 * MD_ASSUME_VISIBLE --> Genocide resistance name ("the kobold")
1533 * MD_ASSUME_VISIBLE | MD_INDEF_VISIBLE --> Killing name ("a kobold")
1534 * MD_PRON_VISIBLE | MD_POSSESSIVE
1535 * --> Possessive, genderized if visable ("his") or "its"
1536 * MD_PRON_VISIBLE | MD_POSSESSIVE | MD_OBJECTIVE
1537 * --> Reflexive, genderized if visable ("himself") or "itself"
1539 void monster_desc(char *desc, monster_type *m_ptr, int mode)
1542 monster_race *r_ptr;
1546 char silly_name[1024];
1550 r_ptr = &r_info[m_ptr->ap_r_idx];
1552 /* Mode of MD_TRUE_NAME will reveal Chameleon's true name */
1553 if (mode & MD_TRUE_NAME) name = (r_name + real_r_ptr(m_ptr)->name);
1554 else name = (r_name + r_ptr->name);
1556 /* Are we hallucinating? (Idea from Nethack...) */
1557 if (p_ptr->image && !(mode & MD_IGNORE_HALLU))
1562 if (!get_rnd_line("silly_j.txt", m_ptr->r_idx, silly_name))
1564 if (!get_rnd_line("silly.txt", m_ptr->r_idx, silly_name))
1572 monster_race *hallu_race;
1576 hallu_race = &r_info[randint1(max_r_idx - 1)];
1578 while (hallu_race->flags1 & RF1_UNIQUE);
1580 strcpy(silly_name, (r_name + hallu_race->name));
1583 /* Better not strcpy it, or we could corrupt r_info... */
1587 /* Can we "see" it (exists + forced, or visible + not unforced) */
1588 seen = (m_ptr && ((mode & MD_ASSUME_VISIBLE) || (!(mode & MD_ASSUME_HIDDEN) && m_ptr->ml)));
1590 /* Sexed Pronouns (seen and allowed, or unseen and allowed) */
1591 pron = (m_ptr && ((seen && (mode & MD_PRON_VISIBLE)) || (!seen && (mode & MD_PRON_HIDDEN))));
1594 /* First, try using pronouns, or describing hidden monsters */
1597 /* an encoding of the monster "sex" */
1600 /* Extract the gender (if applicable) */
1601 if (r_ptr->flags1 & (RF1_FEMALE)) kind = 0x20;
1602 else if (r_ptr->flags1 & (RF1_MALE)) kind = 0x10;
1604 /* Ignore the gender (if desired) */
1605 if (!m_ptr || !pron) kind = 0x00;
1608 /* Assume simple result */
1616 /* Brute force: split on the possibilities */
1617 switch (kind + (mode & (MD_INDEF_HIDDEN | MD_POSSESSIVE | MD_OBJECTIVE)))
1619 /* Neuter, or unknown */
1621 case 0x00: res = "²¿¤«"; break;
1622 case 0x00 + (MD_OBJECTIVE): res = "²¿¤«"; break;
1623 case 0x00 + (MD_POSSESSIVE): res = "²¿¤«¤Î"; break;
1624 case 0x00 + (MD_POSSESSIVE | MD_OBJECTIVE): res = "²¿¤«¼«¿È"; break;
1625 case 0x00 + (MD_INDEF_HIDDEN): res = "²¿¤«"; break;
1626 case 0x00 + (MD_INDEF_HIDDEN | MD_OBJECTIVE): res = "²¿¤«"; break;
1627 case 0x00 + (MD_INDEF_HIDDEN | MD_POSSESSIVE): res = "²¿¤«"; break;
1628 case 0x00 + (MD_INDEF_HIDDEN | MD_POSSESSIVE | MD_OBJECTIVE): res = "¤½¤ì¼«¿È"; break;
1630 case 0x00: res = "it"; break;
1631 case 0x00 + (MD_OBJECTIVE): res = "it"; break;
1632 case 0x00 + (MD_POSSESSIVE): res = "its"; break;
1633 case 0x00 + (MD_POSSESSIVE | MD_OBJECTIVE): res = "itself"; break;
1634 case 0x00 + (MD_INDEF_HIDDEN): res = "something"; break;
1635 case 0x00 + (MD_INDEF_HIDDEN | MD_OBJECTIVE): res = "something"; break;
1636 case 0x00 + (MD_INDEF_HIDDEN | MD_POSSESSIVE): res = "something's"; break;
1637 case 0x00 + (MD_INDEF_HIDDEN | MD_POSSESSIVE | MD_OBJECTIVE): res = "itself"; break;
1641 /* Male (assume human if vague) */
1643 case 0x10: res = "Èà"; break;
1644 case 0x10 + (MD_OBJECTIVE): res = "Èà"; break;
1645 case 0x10 + (MD_POSSESSIVE): res = "Èà¤Î"; break;
1646 case 0x10 + (MD_POSSESSIVE | MD_OBJECTIVE): res = "È༫¿È"; break;
1647 case 0x10 + (MD_INDEF_HIDDEN): res = "狼"; break;
1648 case 0x10 + (MD_INDEF_HIDDEN | MD_OBJECTIVE): res = "狼"; break;
1649 case 0x10 + (MD_INDEF_HIDDEN | MD_POSSESSIVE): res = "狼¤Î"; break;
1650 case 0x10 + (MD_INDEF_HIDDEN | MD_POSSESSIVE | MD_OBJECTIVE): res = "È༫¿È"; break;
1652 case 0x10: res = "he"; break;
1653 case 0x10 + (MD_OBJECTIVE): res = "him"; break;
1654 case 0x10 + (MD_POSSESSIVE): res = "his"; break;
1655 case 0x10 + (MD_POSSESSIVE | MD_OBJECTIVE): res = "himself"; break;
1656 case 0x10 + (MD_INDEF_HIDDEN): res = "someone"; break;
1657 case 0x10 + (MD_INDEF_HIDDEN | MD_OBJECTIVE): res = "someone"; break;
1658 case 0x10 + (MD_INDEF_HIDDEN | MD_POSSESSIVE): res = "someone's"; break;
1659 case 0x10 + (MD_INDEF_HIDDEN | MD_POSSESSIVE | MD_OBJECTIVE): res = "himself"; break;
1663 /* Female (assume human if vague) */
1665 case 0x20: res = "Èà½÷"; break;
1666 case 0x20 + (MD_OBJECTIVE): res = "Èà½÷"; break;
1667 case 0x20 + (MD_POSSESSIVE): res = "Èà½÷¤Î"; break;
1668 case 0x20 + (MD_POSSESSIVE | MD_OBJECTIVE): res = "Èà½÷¼«¿È"; break;
1669 case 0x20 + (MD_INDEF_HIDDEN): res = "狼"; break;
1670 case 0x20 + (MD_INDEF_HIDDEN | MD_OBJECTIVE): res = "狼"; break;
1671 case 0x20 + (MD_INDEF_HIDDEN | MD_POSSESSIVE): res = "狼¤Î"; break;
1672 case 0x20 + (MD_INDEF_HIDDEN | MD_POSSESSIVE | MD_OBJECTIVE): res = "Èà½÷¼«¿È"; break;
1674 case 0x20: res = "she"; break;
1675 case 0x20 + (MD_OBJECTIVE): res = "her"; break;
1676 case 0x20 + (MD_POSSESSIVE): res = "her"; break;
1677 case 0x20 + (MD_POSSESSIVE | MD_OBJECTIVE): res = "herself"; break;
1678 case 0x20 + (MD_INDEF_HIDDEN): res = "someone"; break;
1679 case 0x20 + (MD_INDEF_HIDDEN | MD_OBJECTIVE): res = "someone"; break;
1680 case 0x20 + (MD_INDEF_HIDDEN | MD_POSSESSIVE): res = "someone's"; break;
1681 case 0x20 + (MD_INDEF_HIDDEN | MD_POSSESSIVE | MD_OBJECTIVE): res = "herself"; break;
1685 /* Copy the result */
1686 (void)strcpy(desc, res);
1690 /* Handle visible monsters, "reflexive" request */
1691 else if (!(~mode & (MD_POSSESSIVE | MD_OBJECTIVE)))
1693 /* The monster is visible, so use its gender */
1695 if (r_ptr->flags1 & (RF1_FEMALE)) strcpy(desc, "Èà½÷¼«¿È");
1696 else if (r_ptr->flags1 & (RF1_MALE)) strcpy(desc, "È༫¿È");
1697 else strcpy(desc, "¤½¤ì¼«¿È");
1699 if (r_ptr->flags1 & RF1_FEMALE) strcpy(desc, "herself");
1700 else if (r_ptr->flags1 & RF1_MALE) strcpy(desc, "himself");
1701 else strcpy(desc, "itself");
1706 /* Handle all other visible monster requests */
1710 if (is_pet(m_ptr) && m_ptr->ap_r_idx != m_ptr->r_idx)
1716 while(strncmp(t, "¡Ù", 2) && *t) t++;
1720 (void)sprintf(desc, "%s¡©¡Ù", buf);
1723 (void)sprintf(desc, "%s¡©", name);
1725 (void)sprintf(desc, "%s?", name);
1730 /* It could be a Unique */
1731 if ((r_ptr->flags1 & RF1_UNIQUE) && !(p_ptr->image && !(mode & MD_IGNORE_HALLU)))
1733 /* Start with the name (thus nominative and objective) */
1734 if ((m_ptr->mflag2 & MFLAG2_CHAMELEON) && !(mode & MD_TRUE_NAME))
1740 while (strncmp(t, "¡Ù", 2) && *t) t++;
1744 (void)sprintf(desc, "%s¡©¡Ù", buf);
1747 (void)sprintf(desc, "%s¡©", name);
1749 (void)sprintf(desc, "%s?", name);
1752 else if ((cave[m_ptr->fy][m_ptr->fx].m_idx == p_ptr->riding) || !p_ptr->inside_battle)
1753 (void)strcpy(desc, name);
1756 (void)sprintf(desc, "%s¤â¤É¤", name);
1758 (void)sprintf(desc, "fake %s", name);
1762 /* It could be an indefinite monster */
1763 else if (mode & MD_INDEF_VISIBLE)
1765 /* XXX Check plurality for "some" */
1767 /* Indefinite monsters need an indefinite article */
1769 (void)strcpy(desc, "");
1771 (void)strcpy(desc, is_a_vowel(name[0]) ? "an " : "a ");
1774 (void)strcat(desc, name);
1777 /* It could be a normal, definite, monster */
1780 /* Definite monsters need a definite article */
1783 (void)strcpy(desc, "¤¢¤Ê¤¿¤Î");
1785 (void)strcpy(desc, "your ");
1790 (void)strcpy(desc, "");
1792 (void)strcpy(desc, "the ");
1795 (void)strcat(desc, name);
1798 if (m_ptr->nickname)
1801 sprintf(buf,"¡Ö%s¡×",quark_str(m_ptr->nickname));
1803 sprintf(buf," called %s",quark_str(m_ptr->nickname));
1808 if (player_bold(m_ptr->fy, m_ptr->fx))
1811 strcat(desc,"(¾èÇÏÃæ)");
1813 strcat(desc,"(riding)");
1817 if ((mode & MD_IGNORE_HALLU) && (m_ptr->mflag2 & MFLAG2_CHAMELEON))
1819 if (r_ptr->flags1 & RF1_UNIQUE)
1822 strcat(desc,"(¥«¥á¥ì¥ª¥ó¤Î²¦)");
1824 strcat(desc,"(Chameleon Lord)");
1830 strcat(desc,"(¥«¥á¥ì¥ª¥ó)");
1832 strcat(desc,"(Chameleon)");
1837 if ((mode & MD_IGNORE_HALLU) && m_ptr->ap_r_idx != m_ptr->r_idx)
1839 strcat(desc, format("(%s)", r_name + r_info[m_ptr->r_idx].name));
1842 if (mode & MD_ASSUME_OUTSIDE)
1845 strcat(desc,"(ÂÔµ¡Ãæ)");
1847 strcat(desc,"(waiting)");
1851 /* Handle the Possessive as a special afterthought */
1852 if (mode & MD_POSSESSIVE)
1854 /* XXX Check for trailing "s" */
1856 /* Simply append "apostrophe" and "s" */
1858 (void)strcat(desc, "¤Î");
1860 (void)strcat(desc, "'s");
1870 * Learn about a monster (by "probing" it)
1872 * Return the number of new flags learnt. -Mogami-
1874 int lore_do_probe(int r_idx)
1876 monster_race *r_ptr = &r_info[r_idx];
1880 /* Maximal info about awareness */
1881 if (r_ptr->r_wake != MAX_UCHAR) n++;
1882 if (r_ptr->r_ignore != MAX_UCHAR) n++;
1883 r_ptr->r_wake = r_ptr->r_ignore = MAX_UCHAR;
1885 /* Observe "maximal" attacks */
1886 for (i = 0; i < 4; i++)
1888 /* Examine "actual" blows */
1889 if (r_ptr->blow[i].effect || r_ptr->blow[i].method)
1891 /* Maximal observations */
1892 if (r_ptr->r_blows[i] != MAX_UCHAR) n++;
1893 r_ptr->r_blows[i] = MAX_UCHAR;
1899 (((r_ptr->flags1 & RF1_DROP_4D2) ? 8 : 0) +
1900 ((r_ptr->flags1 & RF1_DROP_3D2) ? 6 : 0) +
1901 ((r_ptr->flags1 & RF1_DROP_2D2) ? 4 : 0) +
1902 ((r_ptr->flags1 & RF1_DROP_1D2) ? 2 : 0) +
1903 ((r_ptr->flags1 & RF1_DROP_90) ? 1 : 0) +
1904 ((r_ptr->flags1 & RF1_DROP_60) ? 1 : 0));
1906 /* Only "valid" drops */
1907 if (!(r_ptr->flags1 & RF1_ONLY_GOLD))
1909 if (r_ptr->r_drop_item != tmp_byte) n++;
1910 r_ptr->r_drop_item = tmp_byte;
1912 if (!(r_ptr->flags1 & RF1_ONLY_ITEM))
1914 if (r_ptr->r_drop_gold != tmp_byte) n++;
1915 r_ptr->r_drop_gold = tmp_byte;
1918 /* Observe many spells */
1919 if (r_ptr->r_cast_spell != MAX_UCHAR) n++;
1920 r_ptr->r_cast_spell = MAX_UCHAR;
1922 /* Count unknown flags */
1923 for (i = 0; i < 32; i++)
1925 if (!(r_ptr->r_flags1 & (1L << i)) &&
1926 (r_ptr->flags1 & (1L << i))) n++;
1927 if (!(r_ptr->r_flags2 & (1L << i)) &&
1928 (r_ptr->flags2 & (1L << i))) n++;
1929 if (!(r_ptr->r_flags3 & (1L << i)) &&
1930 (r_ptr->flags3 & (1L << i))) n++;
1931 if (!(r_ptr->r_flags4 & (1L << i)) &&
1932 (r_ptr->flags4 & (1L << i))) n++;
1933 if (!(r_ptr->r_flags5 & (1L << i)) &&
1934 (r_ptr->flags5 & (1L << i))) n++;
1935 if (!(r_ptr->r_flags6 & (1L << i)) &&
1936 (r_ptr->flags6 & (1L << i))) n++;
1938 /* r_flags7 is actually unused */
1940 if (!(r_ptr->r_flags7 & (1L << i)) &&
1941 (r_ptr->flags7 & (1L << i))) n++;
1945 /* Know all the flags */
1946 r_ptr->r_flags1 = r_ptr->flags1;
1947 r_ptr->r_flags2 = r_ptr->flags2;
1948 r_ptr->r_flags3 = r_ptr->flags3;
1949 r_ptr->r_flags4 = r_ptr->flags4;
1950 r_ptr->r_flags5 = r_ptr->flags5;
1951 r_ptr->r_flags6 = r_ptr->flags6;
1953 /* r_flags7 is actually unused */
1954 /* r_ptr->r_flags7 = r_ptr->flags7; */
1956 /* Know about evolution */
1957 if (!(r_ptr->r_xtra1 & MR1_SINKA)) n++;
1958 r_ptr->r_xtra1 |= MR1_SINKA;
1960 /* Update monster recall window */
1961 if (p_ptr->monster_race_idx == r_idx)
1964 p_ptr->window |= (PW_MONSTER);
1967 /* Return the number of new flags learnt */
1973 * Take note that the given monster just dropped some treasure
1975 * Note that learning the "GOOD"/"GREAT" flags gives information
1976 * about the treasure (even when the monster is killed for the first
1977 * time, such as uniques, and the treasure has not been examined yet).
1979 * This "indirect" method is used to prevent the player from learning
1980 * exactly how much treasure a monster can drop from observing only
1981 * a single example of a drop. This method actually observes how much
1982 * gold and items are dropped, and remembers that information to be
1983 * described later by the monster recall code.
1985 void lore_treasure(int m_idx, int num_item, int num_gold)
1987 monster_type *m_ptr = &m_list[m_idx];
1989 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1991 /* Note the number of things dropped */
1992 if (num_item > r_ptr->r_drop_item) r_ptr->r_drop_item = num_item;
1993 if (num_gold > r_ptr->r_drop_gold) r_ptr->r_drop_gold = num_gold;
1995 /* Hack -- memorize the good/great flags */
1996 if (r_ptr->flags1 & (RF1_DROP_GOOD)) r_ptr->r_flags1 |= (RF1_DROP_GOOD);
1997 if (r_ptr->flags1 & (RF1_DROP_GREAT)) r_ptr->r_flags1 |= (RF1_DROP_GREAT);
1999 /* Update monster recall window */
2000 if (p_ptr->monster_race_idx == m_ptr->r_idx)
2003 p_ptr->window |= (PW_MONSTER);
2009 void sanity_blast(monster_type *m_ptr, bool necro)
2011 bool happened = FALSE;
2014 if (p_ptr->inside_battle || !character_dungeon) return;
2019 monster_race *r_ptr = &r_info[m_ptr->r_idx];
2021 power = r_ptr->level / 2;
2023 monster_desc(m_name, m_ptr, 0);
2025 if (!(r_ptr->flags1 & RF1_UNIQUE))
2027 if (r_ptr->flags1 & RF1_FRIENDS)
2033 return; /* No effect yet, just loaded... */
2036 return; /* Cannot see it for some reason */
2038 if (!(r_ptr->flags2 & RF2_ELDRITCH_HORROR))
2044 return; /* Pet eldritch horrors are safe most of the time */
2046 if (randint1(100) > power) return;
2048 if (saving_throw(p_ptr->skill_sav - power))
2050 return; /* Save, no adverse effects */
2055 /* Something silly happens... */
2057 msg_format("%s%s¤Î´é¤ò¸«¤Æ¤·¤Þ¤Ã¤¿¡ª",
2058 funny_desc[randint0(MAX_SAN_FUNNY)], m_name);
2060 msg_format("You behold the %s visage of %s!",
2061 funny_desc[randint0(MAX_SAN_FUNNY)], m_name);
2067 msg_print(funny_comments[randint0(MAX_SAN_COMMENT)]);
2068 p_ptr->image = p_ptr->image + randint1(r_ptr->level);
2071 return; /* Never mind; we can't see it clearly enough */
2074 /* Something frightening happens... */
2076 msg_format("%s%s¤Î´é¤ò¸«¤Æ¤·¤Þ¤Ã¤¿¡ª",
2077 horror_desc[randint0(MAX_SAN_HORROR)], m_name);
2079 msg_format("You behold the %s visage of %s!",
2080 horror_desc[randint0(MAX_SAN_HORROR)], m_name);
2083 r_ptr->r_flags2 |= RF2_ELDRITCH_HORROR;
2085 /* Demon characters are unaffected */
2086 if (prace_is_(RACE_IMP) || prace_is_(RACE_DEMON) || (mimic_info[p_ptr->mimic_form].MIMIC_FLAGS & MIMIC_IS_DEMON)) return;
2087 if (p_ptr->wizard) return;
2089 /* Undead characters are 50% likely to be unaffected */
2090 if (prace_is_(RACE_SKELETON) || prace_is_(RACE_ZOMBIE)
2091 || prace_is_(RACE_VAMPIRE) || prace_is_(RACE_SPECTRE) ||
2092 (mimic_info[p_ptr->mimic_form].MIMIC_FLAGS & MIMIC_IS_UNDEAD))
2094 if (saving_throw(25 + p_ptr->lev)) return;
2100 msg_print("¥Í¥¯¥í¥Î¥ß¥³¥ó¤òÆɤó¤ÇÀµµ¤¤ò¼º¤Ã¤¿¡ª");
2102 msg_print("Your sanity is shaken by reading the Necronomicon!");
2107 if (!saving_throw(p_ptr->skill_sav - power)) /* Mind blast */
2109 if (!p_ptr->resist_conf)
2111 (void)set_confused(p_ptr->confused + randint0(4) + 4);
2113 if (!p_ptr->resist_chaos && one_in_(3))
2115 (void)set_image(p_ptr->image + randint0(250) + 150);
2120 if (!saving_throw(p_ptr->skill_sav - power)) /* Lose int & wis */
2127 if (!saving_throw(p_ptr->skill_sav - power)) /* Brain smash */
2129 if (!p_ptr->resist_conf)
2131 (void)set_confused(p_ptr->confused + randint0(4) + 4);
2133 if (!p_ptr->free_act)
2135 (void)set_paralyzed(p_ptr->paralyzed + randint0(4) + 4);
2137 while (randint0(100) > p_ptr->skill_sav)
2138 (void)do_dec_stat(A_INT);
2139 while (randint0(100) > p_ptr->skill_sav)
2140 (void)do_dec_stat(A_WIS);
2141 if (!p_ptr->resist_chaos)
2143 (void)set_image(p_ptr->image + randint0(250) + 150);
2148 if (!saving_throw(p_ptr->skill_sav - power)) /* Amnesia */
2151 if (lose_all_info())
2153 msg_print("¤¢¤Þ¤ê¤Î¶²ÉݤËÁ´¤Æ¤Î¤³¤È¤ò˺¤ì¤Æ¤·¤Þ¤Ã¤¿¡ª");
2155 msg_print("You forget everything in your utmost terror!");
2161 if (saving_throw(p_ptr->skill_sav - power))
2166 /* Else gain permanent insanity */
2167 if ((p_ptr->muta3 & MUT3_MORONIC) && /*(p_ptr->muta2 & MUT2_BERS_RAGE) &&*/
2168 ((p_ptr->muta2 & MUT2_COWARDICE) || (p_ptr->resist_fear)) &&
2169 ((p_ptr->muta2 & MUT2_HALLU) || (p_ptr->resist_chaos)))
2171 /* The poor bastard already has all possible insanities! */
2177 switch (randint1(21))
2180 if (!(p_ptr->muta3 & MUT3_MORONIC) && one_in_(5))
2182 if ((p_ptr->stat_use[A_INT] < 4) && (p_ptr->stat_use[A_WIS] < 4))
2185 msg_print("¤¢¤Ê¤¿¤Ï´°àú¤ÊÇϼ¯¤Ë¤Ê¤Ã¤¿¤è¤¦¤Êµ¤¤¬¤·¤¿¡£¤·¤«¤·¤½¤ì¤Ï¸µ¡¹¤À¤Ã¤¿¡£");
2187 msg_print("You turn into an utter moron!");
2193 msg_print("¤¢¤Ê¤¿¤Ï´°àú¤ÊÇϼ¯¤Ë¤Ê¤Ã¤¿¡ª");
2195 msg_print("You turn into an utter moron!");
2199 if (p_ptr->muta3 & MUT3_HYPER_INT)
2202 msg_print("¤¢¤Ê¤¿¤ÎǾ¤ÏÀ¸ÂÎ¥³¥ó¥Ô¥å¡¼¥¿¤Ç¤Ï¤Ê¤¯¤Ê¤Ã¤¿¡£");
2204 msg_print("Your brain is no longer a living computer.");
2207 p_ptr->muta3 &= ~(MUT3_HYPER_INT);
2209 p_ptr->muta3 |= MUT3_MORONIC;
2223 if (!(p_ptr->muta2 & MUT2_COWARDICE) && !p_ptr->resist_fear)
2226 msg_print("¤¢¤Ê¤¿¤Ï¥Ñ¥é¥Î¥¤¥¢¤Ë¤Ê¤Ã¤¿¡ª");
2228 msg_print("You become paranoid!");
2232 /* Duh, the following should never happen, but anyway... */
2233 if (p_ptr->muta3 & MUT3_FEARLESS)
2236 msg_print("¤¢¤Ê¤¿¤Ï¤â¤¦¶²¤ìÃΤ餺¤Ç¤Ï¤Ê¤¯¤Ê¤Ã¤¿¡£");
2238 msg_print("You are no longer fearless.");
2241 p_ptr->muta3 &= ~(MUT3_FEARLESS);
2244 p_ptr->muta2 |= MUT2_COWARDICE;
2258 if (!(p_ptr->muta2 & MUT2_HALLU) && !p_ptr->resist_chaos)
2261 msg_print("¸¸³Ð¤ò¤Ò¤µ¯¤³¤¹Àº¿ÀºøÍð¤Ë´Ù¤Ã¤¿¡ª");
2263 msg_print("You are afflicted by a hallucinatory insanity!");
2266 p_ptr->muta2 |= MUT2_HALLU;
2271 if (!(p_ptr->muta2 & MUT2_BERS_RAGE))
2274 msg_print("·ãÎõ¤Ê´¶¾ð¤Îȯºî¤Ë¤ª¤½¤ï¤ì¤ë¤è¤¦¤Ë¤Ê¤Ã¤¿¡ª");
2276 msg_print("You become subject to fits of berserk rage!");
2279 p_ptr->muta2 |= MUT2_BERS_RAGE;
2286 p_ptr->update |= PU_BONUS;
2292 * This function updates the monster record of the given monster
2294 * This involves extracting the distance to the player (if requested),
2295 * and then checking for visibility (natural, infravision, see-invis,
2296 * telepathy), updating the monster visibility flag, redrawing (or
2297 * erasing) the monster when its visibility changes, and taking note
2298 * of any interesting monster flags (cold-blooded, invisible, etc).
2300 * Note the new "mflag" field which encodes several monster state flags,
2301 * including "view" for when the monster is currently in line of sight,
2302 * and "mark" for when the monster is currently visible via detection.
2304 * The only monster fields that are changed here are "cdis" (the
2305 * distance from the player), "ml" (visible to the player), and
2306 * "mflag" (to maintain the "MFLAG_VIEW" flag).
2308 * Note the special "update_monsters()" function which can be used to
2309 * call this function once for every monster.
2311 * Note the "full" flag which requests that the "cdis" field be updated,
2312 * this is only needed when the monster (or the player) has moved.
2314 * Every time a monster moves, we must call this function for that
2315 * monster, and update the distance, and the visibility. Every time
2316 * the player moves, we must call this function for every monster, and
2317 * update the distance, and the visibility. Whenever the player "state"
2318 * changes in certain ways ("blindness", "infravision", "telepathy",
2319 * and "see invisible"), we must call this function for every monster,
2320 * and update the visibility.
2322 * Routines that change the "illumination" of a grid must also call this
2323 * function for any monster in that grid, since the "visibility" of some
2324 * monsters may be based on the illumination of their grid.
2326 * Note that this function is called once per monster every time the
2327 * player moves. When the player is running, this function is one
2328 * of the primary bottlenecks, along with "update_view()" and the
2329 * "process_monsters()" code, so efficiency is important.
2331 * Note the optimized "inline" version of the "distance()" function.
2333 * A monster is "visible" to the player if (1) it has been detected
2334 * by the player, (2) it is close to the player and the player has
2335 * telepathy, or (3) it is close to the player, and in line of sight
2336 * of the player, and it is "illuminated" by some combination of
2337 * infravision, torch light, or permanent light (invisible monsters
2338 * are only affected by "light" if the player can see invisible).
2340 * Monsters which are not on the current panel may be "visible" to
2341 * the player, and their descriptions will include an "offscreen"
2342 * reference. Currently, offscreen monsters cannot be targetted
2343 * or viewed directly, but old targets will remain set. XXX XXX
2345 * The player can choose to be disturbed by several things, including
2346 * "disturb_move" (monster which is viewable moves in some way), and
2347 * "disturb_near" (monster which is "easily" viewable moves in some
2348 * way). Note that "moves" includes "appears" and "disappears".
2350 void update_mon(int m_idx, bool full)
2352 monster_type *m_ptr = &m_list[m_idx];
2354 monster_race *r_ptr = &r_info[m_ptr->r_idx];
2356 bool do_disturb = disturb_move;
2360 /* Current location */
2367 /* Seen by vision */
2373 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
2375 if (ap_r_ptr->r_tkills && ap_r_ptr->level >= p_ptr->lev)
2379 /* Compute distance */
2382 /* Distance components */
2383 int dy = (py > fy) ? (py - fy) : (fy - py);
2384 int dx = (px > fx) ? (px - fx) : (fx - px);
2386 /* Approximate distance */
2387 d = (dy > dx) ? (dy + (dx>>1)) : (dx + (dy>>1));
2389 /* Restrict distance */
2390 if (d > 255) d = 255;
2394 /* Save the distance */
2398 /* Extract distance */
2401 /* Extract the distance */
2407 if (m_ptr->mflag2 & (MFLAG2_MARK)) flag = TRUE;
2411 if (d <= ((d_info[dungeon_type].flags1 & DF1_DARKNESS) ? MAX_SIGHT / 2 : MAX_SIGHT))
2413 if (!(d_info[dungeon_type].flags1 & DF1_DARKNESS) || (d <= MAX_SIGHT / 4))
2415 if (p_ptr->special_defense & KATA_MUSOU)
2420 /* Hack -- Memorize mental flags */
2421 if (r_ptr->flags2 & (RF2_SMART)) r_ptr->r_flags2 |= (RF2_SMART);
2422 if (r_ptr->flags2 & (RF2_STUPID)) r_ptr->r_flags2 |= (RF2_STUPID);
2425 /* Basic telepathy */
2426 else if (p_ptr->telepathy)
2428 /* Empty mind, no telepathy */
2429 if (r_ptr->flags2 & (RF2_EMPTY_MIND))
2431 /* Memorize flags */
2432 r_ptr->r_flags2 |= (RF2_EMPTY_MIND);
2435 /* Weird mind, occasional telepathy */
2436 else if (r_ptr->flags2 & (RF2_WEIRD_MIND))
2438 /* One in ten individuals are detectable */
2439 if ((m_idx % 10) == 5)
2444 /* Memorize flags */
2445 r_ptr->r_flags2 |= (RF2_WEIRD_MIND);
2447 /* Hack -- Memorize mental flags */
2448 if (r_ptr->flags2 & (RF2_SMART)) r_ptr->r_flags2 |= (RF2_SMART);
2449 if (r_ptr->flags2 & (RF2_STUPID)) r_ptr->r_flags2 |= (RF2_STUPID);
2453 /* Normal mind, allow telepathy */
2459 /* Hack -- Memorize mental flags */
2460 if (r_ptr->flags2 & (RF2_SMART)) r_ptr->r_flags2 |= (RF2_SMART);
2461 if (r_ptr->flags2 & (RF2_STUPID)) r_ptr->r_flags2 |= (RF2_STUPID);
2465 /* Magical sensing */
2466 if ((p_ptr->esp_animal) && (r_ptr->flags3 & (RF3_ANIMAL)))
2469 r_ptr->r_flags3 |= (RF3_ANIMAL);
2473 /* Magical sensing */
2474 if ((p_ptr->esp_undead) && (r_ptr->flags3 & (RF3_UNDEAD)))
2477 r_ptr->r_flags3 |= (RF3_UNDEAD);
2481 /* Magical sensing */
2482 if ((p_ptr->esp_demon) && (r_ptr->flags3 & (RF3_DEMON)))
2485 r_ptr->r_flags3 |= (RF3_DEMON);
2489 /* Magical sensing */
2490 if ((p_ptr->esp_orc) && (r_ptr->flags3 & (RF3_ORC)))
2493 r_ptr->r_flags3 |= (RF3_ORC);
2497 /* Magical sensing */
2498 if ((p_ptr->esp_troll) && (r_ptr->flags3 & (RF3_TROLL)))
2501 r_ptr->r_flags3 |= (RF3_TROLL);
2505 /* Magical sensing */
2506 if ((p_ptr->esp_giant) && (r_ptr->flags3 & (RF3_GIANT)))
2509 r_ptr->r_flags3 |= (RF3_GIANT);
2513 /* Magical sensing */
2514 if ((p_ptr->esp_dragon) && (r_ptr->flags3 & (RF3_DRAGON)))
2517 r_ptr->r_flags3 |= (RF3_DRAGON);
2521 /* Magical sensing */
2522 if ((p_ptr->esp_human) && (r_ptr->flags2 & (RF2_HUMAN)))
2525 r_ptr->r_flags2 |= (RF2_HUMAN);
2529 /* Magical sensing */
2530 if ((p_ptr->esp_evil) && (r_ptr->flags3 & (RF3_EVIL)))
2533 r_ptr->r_flags3 |= (RF3_EVIL);
2537 /* Magical sensing */
2538 if ((p_ptr->esp_good) && (r_ptr->flags3 & (RF3_GOOD)))
2541 r_ptr->r_flags3 |= (RF3_GOOD);
2545 /* Magical sensing */
2546 if ((p_ptr->esp_nonliving) &&
2547 (r_ptr->flags3 & (RF3_NONLIVING)) &&
2548 !(r_ptr->flags3 & (RF3_DEMON)) &&
2549 !(r_ptr->flags3 & (RF3_UNDEAD)))
2552 r_ptr->r_flags3 |= (RF3_NONLIVING);
2556 /* Magical sensing */
2557 if ((p_ptr->esp_unique) && (r_ptr->flags1 & (RF1_UNIQUE)))
2560 r_ptr->r_flags1 |= (RF1_UNIQUE);
2565 /* Normal line of sight, and not blind */
2566 if (player_has_los_bold(fy, fx) && !p_ptr->blind)
2568 bool do_invisible = FALSE;
2569 bool do_cold_blood = FALSE;
2571 /* Use "infravision" */
2572 if (d <= p_ptr->see_infra)
2574 /* Handle "cold blooded" monsters */
2575 if (r_ptr->flags2 & (RF2_COLD_BLOOD))
2578 do_cold_blood = TRUE;
2581 /* Handle "warm blooded" monsters */
2589 /* Use "illumination" */
2590 if (player_can_see_bold(fy, fx))
2592 /* Handle "invisible" monsters */
2593 if (r_ptr->flags2 & (RF2_INVISIBLE))
2596 do_invisible = TRUE;
2606 /* Handle "normal" monsters */
2617 /* Memorize flags */
2618 if (do_invisible) r_ptr->r_flags2 |= (RF2_INVISIBLE);
2619 if (do_cold_blood) r_ptr->r_flags2 |= (RF2_COLD_BLOOD);
2625 /* The monster is now visible */
2628 /* It was previously unseen */
2631 /* Mark as visible */
2634 /* Draw the monster */
2637 /* Update health bar as needed */
2638 if (p_ptr->health_who == m_idx) p_ptr->redraw |= (PR_HEALTH);
2639 if (p_ptr->riding == m_idx) p_ptr->redraw |= (PR_UHEALTH);
2641 /* Hack -- Count "fresh" sightings */
2642 if ((m_ptr->ap_r_idx == MON_KAGE) && (r_info[MON_KAGE].r_sights < MAX_SHORT))
2643 r_info[MON_KAGE].r_sights++;
2644 else if (m_ptr->ap_r_idx == m_ptr->r_idx &&
2645 r_ptr->r_sights < MAX_SHORT) r_ptr->r_sights++;
2647 /* Eldritch Horror */
2648 if (r_ptr->flags2 & RF2_ELDRITCH_HORROR)
2650 sanity_blast(m_ptr, FALSE);
2653 /* Disturb on appearance */
2654 if (disturb_near && (projectable(m_ptr->fy, m_ptr->fx, py, px) && projectable(py, px, m_ptr->fy, m_ptr->fx)))
2656 if (disturb_pets || is_hostile(m_ptr))
2662 /* The monster is not visible */
2665 /* It was previously seen */
2668 /* Mark as not visible */
2671 /* Erase the monster */
2674 /* Update health bar as needed */
2675 if (p_ptr->health_who == m_idx) p_ptr->redraw |= (PR_HEALTH);
2676 if (p_ptr->riding == m_idx) p_ptr->redraw |= (PR_UHEALTH);
2678 /* Disturb on disappearance */
2681 if (disturb_pets || is_hostile(m_ptr))
2688 /* The monster is now easily visible */
2692 if (!(m_ptr->mflag & (MFLAG_VIEW)))
2694 /* Mark as easily visible */
2695 m_ptr->mflag |= (MFLAG_VIEW);
2697 /* Disturb on appearance */
2700 if (disturb_pets || is_hostile(m_ptr))
2706 /* The monster is not easily visible */
2710 if (m_ptr->mflag & (MFLAG_VIEW))
2712 /* Mark as not easily visible */
2713 m_ptr->mflag &= ~(MFLAG_VIEW);
2715 /* Disturb on disappearance */
2718 if (disturb_pets || is_hostile(m_ptr))
2727 * This function simply updates all the (non-dead) monsters (see above).
2729 void update_monsters(bool full)
2733 /* Update each (live) monster */
2734 for (i = 1; i < m_max; i++)
2736 monster_type *m_ptr = &m_list[i];
2738 /* Skip dead monsters */
2739 if (!m_ptr->r_idx) continue;
2741 /* Update the monster */
2742 update_mon(i, full);
2748 * Hack -- the index of the summoning monster
2750 static bool monster_hook_chameleon_lord(int r_idx)
2752 monster_race *r_ptr = &r_info[r_idx];
2753 monster_type *m_ptr = &m_list[chameleon_change_m_idx];
2754 monster_race *old_r_ptr = &r_info[m_ptr->r_idx];
2756 if (!(r_ptr->flags1 & (RF1_UNIQUE))) return FALSE;
2757 if (r_ptr->flags7 & (RF7_FRIENDLY | RF7_CHAMELEON)) return FALSE;
2759 if (ABS(r_ptr->level - r_info[MON_CHAMELEON_K].level) > 5) return FALSE;
2761 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))
2764 if (!monster_can_cross_terrain(cave[m_ptr->fy][m_ptr->fx].feat, r_ptr)) return FALSE;
2767 if (!(old_r_ptr->flags7 & RF7_CHAMELEON))
2769 if ((m_ptr->sub_align & SUB_ALIGN_EVIL) && (r_ptr->flags3 & RF3_GOOD)) return FALSE;
2770 if ((m_ptr->sub_align & SUB_ALIGN_GOOD) && (r_ptr->flags3 & RF3_EVIL)) return FALSE;
2774 else if (summon_specific_who > 0)
2776 monster_type *sm_ptr = &m_list[summon_specific_who];
2778 if ((sm_ptr->sub_align & SUB_ALIGN_EVIL) && (r_ptr->flags3 & RF3_GOOD)) return FALSE;
2779 if ((sm_ptr->sub_align & SUB_ALIGN_GOOD) && (r_ptr->flags3 & RF3_EVIL)) return FALSE;
2785 static bool monster_hook_chameleon(int r_idx)
2787 monster_race *r_ptr = &r_info[r_idx];
2788 monster_type *m_ptr = &m_list[chameleon_change_m_idx];
2789 monster_race *old_r_ptr = &r_info[m_ptr->r_idx];
2791 if (r_ptr->flags1 & (RF1_UNIQUE)) return FALSE;
2792 if (r_ptr->flags2 & RF2_MULTIPLY) return FALSE;
2793 if (r_ptr->flags7 & (RF7_FRIENDLY | RF7_CHAMELEON)) return FALSE;
2795 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))
2798 if (!monster_can_cross_terrain(cave[m_ptr->fy][m_ptr->fx].feat, r_ptr)) return FALSE;
2801 if (!(old_r_ptr->flags7 & RF7_CHAMELEON))
2803 if ((old_r_ptr->flags3 & RF3_GOOD) && !(r_ptr->flags3 & RF3_GOOD)) return FALSE;
2804 if ((old_r_ptr->flags3 & RF3_EVIL) && !(r_ptr->flags3 & RF3_EVIL)) return FALSE;
2805 if (!(old_r_ptr->flags3 & (RF3_GOOD | RF3_EVIL)) && (r_ptr->flags3 & (RF3_GOOD | RF3_EVIL))) return FALSE;
2809 else if (summon_specific_who > 0)
2811 monster_type *sm_ptr = &m_list[summon_specific_who];
2813 if ((sm_ptr->sub_align & SUB_ALIGN_EVIL) && (r_ptr->flags3 & RF3_GOOD)) return FALSE;
2814 if ((sm_ptr->sub_align & SUB_ALIGN_GOOD) && (r_ptr->flags3 & RF3_EVIL)) return FALSE;
2817 return (*(get_monster_hook()))(r_idx);
2821 void choose_new_monster(int m_idx, bool born, int r_idx)
2824 monster_type *m_ptr = &m_list[m_idx];
2825 monster_race *r_ptr;
2826 char old_m_name[80];
2827 bool old_unique = FALSE;
2829 if (r_info[m_ptr->r_idx].flags1 & RF1_UNIQUE)
2831 if (old_unique && (r_idx == MON_CHAMELEON)) r_idx = MON_CHAMELEON_K;
2832 r_ptr = &r_info[r_idx];
2834 monster_desc(old_m_name, m_ptr, 0);
2840 chameleon_change_m_idx = m_idx;
2842 get_mon_num_prep(monster_hook_chameleon_lord, NULL);
2844 get_mon_num_prep(monster_hook_chameleon, NULL);
2847 level = r_info[MON_CHAMELEON_K].level;
2848 else if (!dun_level)
2849 level = wilderness[p_ptr->wilderness_y][p_ptr->wilderness_x].level;
2853 if (d_info[dungeon_type].flags1 & DF1_CHAMELEON) level+= 2+randint1(3);
2855 r_idx = get_mon_num(level);
2856 r_ptr = &r_info[r_idx];
2858 chameleon_change_m_idx = 0;
2864 m_ptr->r_idx = r_idx;
2865 m_ptr->ap_r_idx = r_idx;
2866 update_mon(m_idx, FALSE);
2867 lite_spot(m_ptr->fy, m_ptr->fx);
2870 /* Sub-alignment of a chameleon */
2871 if (r_ptr->flags3 & (RF3_EVIL | RF3_GOOD))
2873 m_ptr->sub_align = SUB_ALIGN_NEUTRAL;
2874 if (r_ptr->flags3 & RF3_EVIL) m_ptr->sub_align |= SUB_ALIGN_EVIL;
2875 if (r_ptr->flags3 & RF3_GOOD) m_ptr->sub_align |= SUB_ALIGN_GOOD;
2880 if (m_idx == p_ptr->riding)
2883 monster_desc(m_name, m_ptr, 0);
2885 msg_format("ÆÍÁ³%s¤¬ÊѿȤ·¤¿¡£", old_m_name);
2887 msg_format("Suddenly, %s transforms!", old_m_name);
2889 if (!(r_ptr->flags7 & RF7_RIDING))
2891 if (rakuba(0, TRUE)) msg_print("ÃÏÌ̤ËÍî¤È¤µ¤ì¤¿¡£");
2893 if (rakuba(0, TRUE)) msg_format("You have fallen from %s.", m_name);
2897 /* Extract the monster base speed */
2898 m_ptr->mspeed = get_mspeed(r_ptr);
2900 oldmaxhp = m_ptr->max_maxhp;
2901 /* Assign maximal hitpoints */
2902 if (r_ptr->flags1 & RF1_FORCE_MAXHP)
2904 m_ptr->max_maxhp = maxroll(r_ptr->hdice, r_ptr->hside);
2908 m_ptr->max_maxhp = damroll(r_ptr->hdice, r_ptr->hside);
2910 m_ptr->maxhp = (long)(m_ptr->maxhp * m_ptr->max_maxhp) / oldmaxhp;
2911 m_ptr->hp = (long)(m_ptr->hp * m_ptr->max_maxhp) / oldmaxhp;
2918 static bool monster_hook_tanuki(int r_idx)
2920 monster_race *r_ptr = &r_info[r_idx];
2922 if (r_ptr->flags1 & (RF1_UNIQUE)) return FALSE;
2923 if (r_ptr->flags2 & RF2_MULTIPLY) return FALSE;
2924 if (r_ptr->flags7 & (RF7_FRIENDLY | RF7_CHAMELEON)) return FALSE;
2925 if (r_ptr->flags7 & RF7_AQUATIC) return FALSE;
2927 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))
2930 return (*(get_monster_hook()))(r_idx);
2935 * Set initial racial appearance of a monster
2937 static int initial_r_appearance(int r_idx)
2939 int attempts = 1000;
2942 int min = MIN(base_level-5, 50);
2944 if (!(r_info[r_idx].flags7 & RF7_TANUKI))
2947 get_mon_num_prep(monster_hook_tanuki, NULL);
2951 ap_r_idx = get_mon_num(base_level + 10);
2952 if (r_info[ap_r_idx].level >= min) return ap_r_idx;
2960 * Get initial monster speed
2962 byte get_mspeed(monster_race *r_ptr)
2964 /* Extract the monster base speed */
2965 int mspeed = r_ptr->speed;
2967 /* Hack -- small racial variety */
2968 if (!(r_ptr->flags1 & RF1_UNIQUE) && !p_ptr->inside_arena)
2970 /* Allow some small variation per monster */
2971 int i = SPEED_TO_ENERGY(r_ptr->speed) / (one_in_(4) ? 3 : 10);
2972 if (i) mspeed += rand_spread(0, i);
2975 if (mspeed > 199) mspeed = 199;
2977 return (byte)mspeed;
2982 * Attempt to place a monster of the given race at the given location.
2984 * To give the player a sporting chance, any monster that appears in
2985 * line-of-sight and is extremely dangerous can be marked as
2986 * "FORCE_SLEEP", which will cause them to be placed with low energy,
2987 * which often (but not always) lets the player move before they do.
2989 * This routine refuses to place out-of-depth "FORCE_DEPTH" monsters.
2991 * XXX XXX XXX Use special "here" and "dead" flags for unique monsters,
2992 * remove old "cur_num" and "max_num" fields.
2994 * XXX XXX XXX Actually, do something similar for artifacts, to simplify
2995 * the "preserve" mode, and to make the "what artifacts" flag more useful.
2997 * This is the only function which may place a monster in the dungeon,
2998 * except for the savefile loading code.
3000 bool place_monster_one(int who, int y, int x, int r_idx, u32b mode)
3004 monster_type *m_ptr;
3006 monster_race *r_ptr = &r_info[r_idx];
3008 cptr name = (r_name + r_ptr->name);
3010 /* DO NOT PLACE A MONSTER IN THE SMALL SCALE WILDERNESS !!! */
3011 if(p_ptr->wild_mode) return FALSE;
3013 /* Verify location */
3014 if (!in_bounds(y, x)) return (FALSE);
3016 /* Require empty space (if not ghostly) */
3017 if (!(!dun_level && (cave[y][x].feat == FEAT_MOUNTAIN) && ((r_ptr->flags8 & RF8_WILD_MOUNTAIN) || (r_ptr->flags7 & RF7_CAN_FLY))) &&
3018 !(cave_empty_bold2(y, x) || (mode & PM_IGNORE_TERRAIN)) &&
3019 !((r_ptr->flags2 & RF2_PASS_WALL) &&
3020 !(cave_perma_bold(y, x) || cave[y][x].m_idx ||
3021 player_bold(y, x)))) return (FALSE);
3024 if (!r_idx) return (FALSE);
3027 if (!r_ptr->name) return (FALSE);
3029 /* Nor on the Pattern */
3030 if ((cave[y][x].feat >= FEAT_PATTERN_START)
3031 && (cave[y][x].feat <= FEAT_PATTERN_XTRA2))
3034 if (!(mode & PM_IGNORE_TERRAIN) &&
3035 !monster_can_cross_terrain(cave[y][x].feat, r_ptr))
3040 if (!p_ptr->inside_battle)
3042 /* Hack -- "unique" monsters must be "unique" */
3043 if (((r_ptr->flags1 & (RF1_UNIQUE)) ||
3044 (r_ptr->flags7 & (RF7_UNIQUE_7))) &&
3045 (r_ptr->cur_num >= r_ptr->max_num))
3051 if ((r_ptr->flags7 & (RF7_UNIQUE2)) &&
3052 (r_ptr->cur_num >= 1))
3057 if (r_idx == MON_BANORLUPART)
3059 if (r_info[MON_BANOR].cur_num > 0) return FALSE;
3060 if (r_info[MON_LUPART].cur_num > 0) return FALSE;
3063 /* Depth monsters may NOT be created out of depth, unless in Nightmare mode */
3064 if ((r_ptr->flags1 & (RF1_FORCE_DEPTH)) && (dun_level < r_ptr->level) &&
3065 (!ironman_nightmare || (r_ptr->flags1 & (RF1_QUESTOR))))
3072 if(quest_number(dun_level))
3074 int hoge = quest_number(dun_level);
3075 if((quest[hoge].type == QUEST_TYPE_KILL_LEVEL) || (quest[hoge].type == QUEST_TYPE_RANDOM))
3077 if(r_idx == quest[hoge].r_idx)
3079 int number_mon, i2, j2;
3082 /* Count all quest monsters */
3083 for (i2 = 0; i2 < cur_wid; ++i2)
3084 for (j2 = 0; j2 < cur_hgt; j2++)
3085 if (cave[j2][i2].m_idx > 0)
3086 if (m_list[cave[j2][i2].m_idx].r_idx == quest[hoge].r_idx)
3088 if(number_mon + quest[hoge].cur_num >= quest[hoge].max_num)
3094 /* Access the location */
3095 c_ptr = &cave[y][x];
3097 if (is_glyph_grid(c_ptr))
3099 if (randint1(BREAK_GLYPH) < (r_ptr->level+20))
3101 /* Describe observable breakage */
3102 if (c_ptr->info & CAVE_MARK)
3105 msg_print("¼é¤ê¤Î¥ë¡¼¥ó¤¬²õ¤ì¤¿¡ª");
3107 msg_print("The rune of protection is broken!");
3112 /* Forget the rune */
3113 c_ptr->info &= ~(CAVE_MARK);
3115 /* Break the rune */
3116 c_ptr->info &= ~(CAVE_OBJECT);
3125 /* Powerful monster */
3126 if (r_ptr->level > dun_level)
3128 /* Unique monsters */
3129 if (r_ptr->flags1 & (RF1_UNIQUE))
3131 /* Message for cheaters */
3133 if (cheat_hear) msg_format("¿¼ÁؤΥæ¥Ë¡¼¥¯¡¦¥â¥ó¥¹¥¿¡¼ (%s)¡£", name);
3135 if (cheat_hear) msg_format("Deep Unique (%s).", name);
3139 /* Boost rating by twice delta-depth */
3140 rating += (r_ptr->level - dun_level) * 2;
3143 /* Normal monsters */
3146 /* Message for cheaters */
3148 if (cheat_hear) msg_format("¿¼ÁؤΥâ¥ó¥¹¥¿¡¼ (%s)¡£", name);
3150 if (cheat_hear) msg_format("Deep Monster (%s).", name);
3154 /* Boost rating by delta-depth */
3155 rating += (r_ptr->level - dun_level);
3159 /* Note the monster */
3160 else if (r_ptr->flags1 & (RF1_UNIQUE))
3162 /* Unique monsters induce message */
3164 if (cheat_hear) msg_format("¥æ¥Ë¡¼¥¯¡¦¥â¥ó¥¹¥¿¡¼ (%s)¡£", name);
3166 if (cheat_hear) msg_format("Unique (%s).", name);
3171 if ((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags7 & RF7_UNIQUE_7) || (r_ptr->level < 10)) is_kage = FALSE;
3173 /* Make a new monster */
3174 c_ptr->m_idx = m_pop();
3175 hack_m_idx_ii = c_ptr->m_idx;
3177 /* Mega-Hack -- catch "failure" */
3178 if (!c_ptr->m_idx) return (FALSE);
3181 /* Get a new monster record */
3182 m_ptr = &m_list[c_ptr->m_idx];
3185 m_ptr->r_idx = r_idx;
3186 m_ptr->ap_r_idx = initial_r_appearance(r_idx);
3188 /* Sub-alignment of a monster */
3189 if ((who > 0) && !(r_ptr->flags3 & (RF3_EVIL | RF3_GOOD)))
3190 m_ptr->sub_align = m_list[who].sub_align;
3193 m_ptr->sub_align = SUB_ALIGN_NEUTRAL;
3194 if (r_ptr->flags3 & RF3_EVIL) m_ptr->sub_align |= SUB_ALIGN_EVIL;
3195 if (r_ptr->flags3 & RF3_GOOD) m_ptr->sub_align |= SUB_ALIGN_GOOD;
3198 /* Place the monster at the location */
3203 /* No "damage" yet */
3205 m_ptr->confused = 0;
3208 /* Unknown distance */
3211 reset_target(m_ptr);
3213 m_ptr->nickname = 0;
3221 if (r_ptr->flags7 & RF7_CHAMELEON)
3223 choose_new_monster(c_ptr->m_idx, TRUE, 0);
3224 r_ptr = &r_info[m_ptr->r_idx];
3225 m_ptr->mflag2 |= MFLAG2_CHAMELEON;
3228 /* Hack - Set sub_align to neutral when the Chameleon Lord is generated as "GUARDIAN" */
3229 if ((r_ptr->flags1 & RF1_UNIQUE) && (who <= 0))
3230 m_ptr->sub_align = SUB_ALIGN_NEUTRAL;
3234 m_ptr->ap_r_idx = MON_KAGE;
3235 m_ptr->mflag2 |= MFLAG2_KAGE;
3238 if (mode & PM_NO_PET) m_ptr->mflag2 |= MFLAG2_NOPET;
3244 if (mode & PM_FORCE_PET)
3249 else if ((r_ptr->flags7 & RF7_FRIENDLY) ||
3250 (mode & PM_FORCE_FRIENDLY) || is_friendly_idx(who))
3252 if (!(p_ptr->align >= 0 && (r_ptr->flags3 & RF3_EVIL)) &&
3253 !(p_ptr->align < 0 && (r_ptr->flags3 & RF3_GOOD)))
3255 set_friendly(m_ptr);
3259 /* Assume no sleeping */
3262 /* Enforce sleeping if needed */
3263 if ((mode & PM_ALLOW_SLEEP) && r_ptr->sleep && !ironman_nightmare)
3265 int val = r_ptr->sleep;
3266 m_ptr->csleep = ((val * 2) + randint1(val * 10));
3269 /* Assign maximal hitpoints */
3270 if (r_ptr->flags1 & RF1_FORCE_MAXHP)
3272 m_ptr->max_maxhp = maxroll(r_ptr->hdice, r_ptr->hside);
3276 m_ptr->max_maxhp = damroll(r_ptr->hdice, r_ptr->hside);
3279 /* Monsters have double hitpoints in Nightmare mode */
3280 if (ironman_nightmare)
3282 u32b hp = m_ptr->max_maxhp * 2L;
3284 m_ptr->max_maxhp = (s16b)MIN(30000, hp);
3287 m_ptr->maxhp = m_ptr->max_maxhp;
3289 /* And start out fully healthy */
3290 if (m_ptr->r_idx == MON_WOUNDED_BEAR)
3291 m_ptr->hp = m_ptr->maxhp / 2;
3292 else m_ptr->hp = m_ptr->maxhp;
3295 /* Extract the monster base speed */
3296 m_ptr->mspeed = get_mspeed(r_ptr);
3298 if (mode & PM_HASTE) m_ptr->fast = 100;
3300 /* Give a random starting energy */
3301 if (!ironman_nightmare)
3303 m_ptr->energy_need = ENERGY_NEED() - (s16b)randint0(100);
3307 /* Nightmare monsters are more prepared */
3308 m_ptr->energy_need = ENERGY_NEED() - (s16b)randint0(100) * 2;
3311 /* Force monster to wait for player, unless in Nightmare mode */
3312 if ((r_ptr->flags1 & RF1_FORCE_SLEEP) && !ironman_nightmare)
3314 /* Monster is still being nice */
3315 m_ptr->mflag |= (MFLAG_NICE);
3317 /* Must repair monsters */
3318 repair_monsters = TRUE;
3321 /* Hack -- see "process_monsters()" */
3322 if (c_ptr->m_idx < hack_m_idx)
3324 /* Monster is still being born */
3325 m_ptr->mflag |= (MFLAG_BORN);
3329 if (r_ptr->flags7 & (RF7_SELF_LITE_1 | RF7_SELF_LITE_2))
3330 p_ptr->update |= (PU_MON_LITE);
3331 else if ((r_ptr->flags7 & (RF7_HAS_LITE_1 | RF7_HAS_LITE_2)) && !m_ptr->csleep)
3332 p_ptr->update |= (PU_MON_LITE);
3334 /* Update the monster */
3335 update_mon(c_ptr->m_idx, TRUE);
3338 /* Count the monsters on the level */
3339 real_r_ptr(m_ptr)->cur_num++;
3342 * Memorize location of the unique monster in saved floors.
3343 * A unique monster move from old saved floor.
3345 if (character_dungeon &&
3346 ((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags7 & RF7_UNIQUE_7)))
3347 real_r_ptr(m_ptr)->floor_id = p_ptr->floor_id;
3349 /* Hack -- Count the number of "reproducers" */
3350 if (r_ptr->flags2 & RF2_MULTIPLY) num_repro++;
3353 /* Hack -- Notice new multi-hued monsters */
3355 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
3356 if (ap_r_ptr->flags1 & (RF1_ATTR_MULTI | RF1_SHAPECHANGER))
3357 shimmer_monsters = TRUE;
3360 if (p_ptr->warning && character_dungeon)
3362 if (r_ptr->flags1 & RF1_UNIQUE)
3366 char o_name[MAX_NLEN];
3368 if (r_ptr->level > p_ptr->lev + 30)
3374 else if (r_ptr->level > p_ptr->lev + 15)
3380 else if (r_ptr->level > p_ptr->lev + 5)
3382 color = "¥ë¥Ó¡¼¿§¤Ë";
3386 else if (r_ptr->level > p_ptr->lev - 5)
3392 else if (r_ptr->level > p_ptr->lev - 15)
3394 color = "¥Ô¥ó¥¯¿§¤Ë";
3405 o_ptr = choose_warning_item();
3406 object_desc(o_name, o_ptr, FALSE, 0);
3408 msg_format("%s¤Ï%s¸÷¤Ã¤¿¡£",o_name, color);
3410 msg_format("%s glows %s.",o_name, color);
3415 if (is_explosive_rune_grid(c_ptr))
3417 /* Break the ward */
3418 if (randint1(BREAK_MINOR_GLYPH) > r_ptr->level)
3420 /* Describe observable breakage */
3421 if (c_ptr->info & CAVE_MARK)
3424 msg_print("¥ë¡¼¥ó¤¬Çúȯ¤·¤¿¡ª");
3426 msg_print("The rune explodes!");
3429 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);
3435 msg_print("Çúȯ¤Î¥ë¡¼¥ó¤Ï²ò½ü¤µ¤ì¤¿¡£");
3437 msg_print("An explosive rune was disarmed.");
3441 /* Forget the rune */
3442 c_ptr->info &= ~(CAVE_MARK);
3444 /* Break the rune */
3445 c_ptr->info &= ~(CAVE_OBJECT);
3458 * improved version of scatter() for place monster
3461 #define MON_SCAT_MAXD 10
3463 static bool mon_scatter(int *yp, int *xp, int y, int x, int max_dist)
3465 int place_x[MON_SCAT_MAXD];
3466 int place_y[MON_SCAT_MAXD];
3467 int num[MON_SCAT_MAXD];
3471 if (max_dist >= MON_SCAT_MAXD)
3474 for (i = 0; i < MON_SCAT_MAXD; i++)
3477 for (nx = x - max_dist; nx <= x + max_dist; nx++)
3478 for (ny = y - max_dist; ny <= y + max_dist; ny++)
3480 /* Ignore annoying locations */
3481 if (!in_bounds(ny, nx)) continue;
3483 /* Require "line of sight" */
3484 if (!los(y, x, ny, nx)) continue;
3486 /* Walls and Monsters block flow */
3487 if (!cave_empty_bold2(ny, nx)) continue;
3488 if (cave[ny][nx].m_idx) continue;
3489 if (player_bold(ny, nx)) continue;
3491 /* ... nor on the Pattern */
3492 if ((cave[ny][nx].feat >= FEAT_PATTERN_START) &&
3493 (cave[ny][nx].feat <= FEAT_PATTERN_XTRA2))
3496 i = distance(y, x, ny, nx);
3512 while (i < MON_SCAT_MAXD && 0 == num[i])
3514 if (i >= MON_SCAT_MAXD)
3525 * Maximum size of a group of monsters
3527 #define GROUP_MAX 32
3531 * Attempt to place a "group" of monsters around the given location
3533 static bool place_monster_group(int who, int y, int x, int r_idx, u32b mode)
3535 monster_race *r_ptr = &r_info[r_idx];
3538 int total = 0, extra = 0;
3542 byte hack_y[GROUP_MAX];
3543 byte hack_x[GROUP_MAX];
3546 /* Pick a group size */
3547 total = randint1(10);
3549 /* Hard monsters, small groups */
3550 if (r_ptr->level > dun_level)
3552 extra = r_ptr->level - dun_level;
3553 extra = 0 - randint1(extra);
3556 /* Easy monsters, large groups */
3557 else if (r_ptr->level < dun_level)
3559 extra = dun_level - r_ptr->level;
3560 extra = randint1(extra);
3563 /* Hack -- limit group reduction */
3564 if (extra > 9) extra = 9;
3566 /* Modify the group size */
3570 if (total < 1) total = 1;
3573 if (total > GROUP_MAX) total = GROUP_MAX;
3576 /* Save the rating */
3579 /* Start on the monster */
3584 /* Puddle monsters, breadth first, up to total */
3585 for (n = 0; (n < hack_n) && (hack_n < total); n++)
3587 /* Grab the location */
3591 /* Check each direction, up to total */
3592 for (i = 0; (i < 8) && (hack_n < total); i++)
3596 scatter(&my, &mx, hy, hx, 4, 0);
3598 /* Walls and Monsters block flow */
3599 if (!cave_empty_bold2(my, mx)) continue;
3601 /* Attempt to place another monster */
3602 if (place_monster_one(who, my, mx, r_idx, mode))
3604 /* Add it to the "hack" set */
3605 hack_y[hack_n] = my;
3606 hack_x[hack_n] = mx;
3612 /* Hack -- restore the rating */
3622 * Hack -- help pick an escort type
3624 static int place_monster_idx = 0;
3625 static int place_monster_m_idx = 0;
3628 * Hack -- help pick an escort type
3630 static bool place_monster_okay(int r_idx)
3632 monster_race *r_ptr = &r_info[place_monster_idx];
3633 monster_type *m_ptr = &m_list[place_monster_m_idx];
3635 monster_race *z_ptr = &r_info[r_idx];
3637 /* Hack - Escorts have to have the same dungeon flag */
3638 if (monster_dungeon(place_monster_idx) != monster_dungeon(r_idx)) return (FALSE);
3640 /* Require similar "race" */
3641 if (z_ptr->d_char != r_ptr->d_char) return (FALSE);
3643 /* Skip more advanced monsters */
3644 if (z_ptr->level > r_ptr->level) return (FALSE);
3646 /* Skip unique monsters */
3647 if (z_ptr->flags1 & RF1_UNIQUE) return (FALSE);
3649 /* Paranoia -- Skip identical monsters */
3650 if (place_monster_idx == r_idx) return (FALSE);
3652 /* Skip different alignment */
3653 if (((m_ptr->sub_align & SUB_ALIGN_EVIL) && (z_ptr->flags3 & RF3_GOOD)) ||
3654 ((m_ptr->sub_align & SUB_ALIGN_GOOD) && (z_ptr->flags3 & RF3_EVIL)))
3657 if (r_ptr->flags7 & RF7_FRIENDLY)
3659 if (((p_ptr->align < 0) && (z_ptr->flags3 & RF3_GOOD)) ||
3660 ((p_ptr->align > 0) && (z_ptr->flags3 & RF3_EVIL)))
3664 if ((r_ptr->flags7 & RF7_CHAMELEON) && !(z_ptr->flags7 & RF7_CHAMELEON))
3673 * Attempt to place a monster of the given race at the given location
3675 * Note that certain monsters are now marked as requiring "friends".
3676 * These monsters, if successfully placed, and if the "grp" parameter
3677 * is TRUE, will be surrounded by a "group" of identical monsters.
3679 * Note that certain monsters are now marked as requiring an "escort",
3680 * which is a collection of monsters with similar "race" but lower level.
3682 * Some monsters induce a fake "group" flag on their escorts.
3684 * Note the "bizarre" use of non-recursion to prevent annoying output
3685 * when running a code profiler.
3687 * Note the use of the new "monster allocation table" code to restrict
3688 * the "get_mon_num()" function to "legal" escort types.
3690 bool place_monster_aux(int who, int y, int x, int r_idx, u32b mode)
3693 monster_race *r_ptr = &r_info[r_idx];
3695 if (one_in_(333) && !(mode & PM_NO_KAGE) && !(mode & PM_FORCE_PET))
3700 /* Place one monster, or fail */
3701 if (!place_monster_one(who, y, x, r_idx, mode)) return (FALSE);
3704 /* Require the "group" flag */
3705 if (!(mode & PM_ALLOW_GROUP)) return (TRUE);
3707 place_monster_m_idx = hack_m_idx_ii;
3709 /* Friends for certain monsters */
3710 if (r_ptr->flags1 & (RF1_FRIENDS))
3712 /* Attempt to place a group */
3713 (void)place_monster_group(who, y, x, r_idx, mode);
3717 /* Escorts for certain monsters */
3718 if (r_ptr->flags1 & (RF1_ESCORT))
3720 /* Set the escort index */
3721 place_monster_idx = r_idx;
3723 /* Try to place several "escorts" */
3724 for (i = 0; i < 32; i++)
3726 int nx, ny, z, d = 3;
3728 /* Pick a location */
3729 scatter(&ny, &nx, y, x, d, 0);
3731 /* Require empty grids */
3732 if (!cave_empty_bold2(ny, nx)) continue;
3734 /* Prepare allocation table */
3735 get_mon_num_prep(place_monster_okay, get_monster_hook2(ny, nx));
3737 /* Pick a random race */
3738 z = get_mon_num(r_ptr->level);
3740 /* Handle failure */
3743 /* Place a single escort */
3744 (void)place_monster_one(place_monster_m_idx, ny, nx, z, mode);
3746 /* Place a "group" of escorts if needed */
3747 if ((r_info[z].flags1 & RF1_FRIENDS) ||
3748 (r_ptr->flags1 & RF1_ESCORTS))
3750 /* Place a group of monsters */
3751 (void)place_monster_group(place_monster_m_idx, ny, nx, z, mode);
3762 * Hack -- attempt to place a monster at the given location
3764 * Attempt to find a monster appropriate to the "monster_level"
3766 bool place_monster(int y, int x, u32b mode)
3770 /* Prepare allocation table */
3771 get_mon_num_prep(get_monster_hook(), get_monster_hook2(y, x));
3773 /* Pick a monster */
3774 r_idx = get_mon_num(monster_level);
3776 /* Handle failure */
3777 if (!r_idx) return (FALSE);
3779 /* Attempt to place the monster */
3780 if (place_monster_aux(0, y, x, r_idx, mode)) return (TRUE);
3787 #ifdef MONSTER_HORDES
3789 bool alloc_horde(int y, int x)
3791 monster_race *r_ptr = NULL;
3794 int attempts = 1000;
3798 /* Prepare allocation table */
3799 get_mon_num_prep(get_monster_hook(), get_monster_hook2(y, x));
3803 /* Pick a monster */
3804 r_idx = get_mon_num(monster_level);
3806 /* Handle failure */
3807 if (!r_idx) return (FALSE);
3809 r_ptr = &r_info[r_idx];
3811 if (r_ptr->flags1 & RF1_UNIQUE) continue;
3813 if (r_idx == MON_HAGURE) continue;
3816 if (attempts < 1) return FALSE;
3822 /* Attempt to place the monster */
3823 if (place_monster_aux(0, y, x, r_idx, 0L)) break;
3826 if (attempts < 1) return FALSE;
3828 m_idx = cave[y][x].m_idx;
3830 if (m_list[m_idx].mflag2 & MFLAG2_CHAMELEON) r_ptr = &r_info[m_list[m_idx].r_idx];
3831 summon_kin_type = r_ptr->d_char;
3833 for (attempts = randint1(10) + 5; attempts; attempts--)
3835 scatter(&cy, &cx, y, x, 5, 0);
3837 (void)summon_specific(m_idx, cy, cx, dun_level + 5, SUMMON_KIN, PM_ALLOW_GROUP);
3846 #endif /* MONSTER_HORDES */
3851 * Attempt to allocate a random monster in the dungeon.
3853 * Place the monster at least "dis" distance from the player.
3855 * Use "slp" to choose the initial "sleep" status
3857 * Use "monster_level" for the monster level
3859 bool alloc_monster(int dis, u32b mode)
3862 int attempts_left = 10000;
3863 int guardian = d_info[dungeon_type].final_guardian;
3865 /* Put an Guardian */
3866 if(guardian && d_info[dungeon_type].maxdepth == dun_level && r_info[guardian].cur_num < r_info[guardian].max_num )
3872 /* Find a good position */
3875 /* Get a random spot */
3876 oy = randint1(cur_hgt - 4) + 2;
3877 ox = randint1(cur_wid - 4) + 2;
3879 /* Is it a good spot ? */
3880 if (cave_empty_bold2(oy, ox) && monster_can_cross_terrain(cave[oy][ox].feat, &r_info[guardian]))
3882 /* Place the guardian */
3883 if (place_monster_aux(0, oy, ox, guardian, (PM_ALLOW_GROUP | PM_NO_KAGE | PM_NO_PET))) break;
3891 /* Find a legal, distant, unoccupied, space */
3892 while (attempts_left--)
3894 /* Pick a location */
3895 y = randint0(cur_hgt);
3896 x = randint0(cur_wid);
3898 /* Require empty floor grid (was "naked") */
3899 if (dun_level || (wilderness[p_ptr->wilderness_y][p_ptr->wilderness_x].terrain != TERRAIN_MOUNTAIN))
3901 if (!cave_empty_bold2(y, x)) continue;
3905 if (!cave_empty_bold2(y, x) && (cave[y][x].feat != FEAT_MOUNTAIN)) continue;
3908 /* Accept far away grids */
3909 if (distance(y, x, py, px) > dis) break;
3914 if (cheat_xtra || cheat_hear)
3917 msg_print("·Ù¹ð¡ª¿·¤¿¤Ê¥â¥ó¥¹¥¿¡¼¤òÇÛÃ֤Ǥ¤Þ¤»¤ó¡£¾®¤µ¤¤³¬¤Ç¤¹¤«¡©");
3919 msg_print("Warning! Could not allocate a new monster. Small level?");
3928 #ifdef MONSTER_HORDES
3929 if (randint1(5000) <= dun_level)
3931 if (alloc_horde(y, x))
3934 if (cheat_hear) msg_format("¥â¥ó¥¹¥¿¡¼¤ÎÂç·²(%c)", summon_kin_type);
3936 if (cheat_hear) msg_format("Monster horde (%c).", summon_kin_type);
3944 #endif /* MONSTER_HORDES */
3946 /* Attempt to place the monster, allow groups */
3947 if (place_monster(y, x, (mode | PM_ALLOW_GROUP))) return (TRUE);
3949 #ifdef MONSTER_HORDES
3951 #endif /* MONSTER_HORDES */
3961 * Hack -- help decide if a monster race is "okay" to summon
3963 static bool summon_specific_okay(int r_idx)
3965 monster_race *r_ptr = &r_info[r_idx];
3967 /* Hack - Only summon dungeon monsters */
3968 if (!monster_dungeon(r_idx)) return (FALSE);
3970 /* Hack -- identify the summoning monster */
3971 if (summon_specific_who > 0)
3973 monster_type *m_ptr = &m_list[summon_specific_who];
3975 /* Do not summon enemies */
3977 /* Friendly vs. opposite aligned normal or pet */
3978 if (((r_ptr->flags3 & RF3_EVIL) &&
3979 (m_ptr->sub_align & SUB_ALIGN_GOOD)) ||
3980 ((r_ptr->flags3 & RF3_GOOD) &&
3981 (m_ptr->sub_align & SUB_ALIGN_EVIL)))
3986 /* Hostile vs. non-hostile */
3987 if (is_hostile(m_ptr) != summon_specific_hostile)
3992 /* Use the player's alignment */
3993 else if (summon_specific_who < 0)
3995 /* Do not summon enemies of the pets */
3996 if ((p_ptr->align < -9) && (r_ptr->flags3 & RF3_GOOD))
3998 if (!one_in_((0-p_ptr->align)/2+1)) return FALSE;
4000 else if ((p_ptr->align > 9) && (r_ptr->flags3 & RF3_EVIL))
4002 if (!one_in_(p_ptr->align/2+1)) return FALSE;
4006 /* Hack -- no specific type specified */
4007 if (!summon_specific_type) return (TRUE);
4009 if (!summon_unique_okay && ((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags7 & RF7_UNIQUE_7))) return FALSE;
4011 if ((summon_specific_who < 0) &&
4012 ((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags7 & RF7_UNIQUE_7)) &&
4013 (((p_ptr->align > 9) && (r_ptr->flags3 & RF3_EVIL)) ||
4014 ((p_ptr->align < -9) && (r_ptr->flags3 & RF3_GOOD))))
4017 if ((r_ptr->flags7 & RF7_CHAMELEON) && (d_info[dungeon_type].flags1 & DF1_CHAMELEON)) return TRUE;
4019 return (summon_specific_aux(r_idx));
4024 * Place a monster (of the specified "type") near the given
4025 * location. Return TRUE if a monster was actually summoned.
4027 * We will attempt to place the monster up to 10 times before giving up.
4029 * Note: SUMMON_UNIQUE and SUMMON_AMBERITES will summon Unique's
4030 * Note: SUMMON_HI_UNDEAD and SUMMON_HI_DRAGON may summon Unique's
4031 * Note: None of the other summon codes will ever summon Unique's.
4033 * This function has been changed. We now take the "monster level"
4034 * of the summoning monster as a parameter, and use that, along with
4035 * the current dungeon level, to help determine the level of the
4036 * desired monster. Note that this is an upper bound, and also
4037 * tends to "prefer" monsters of that level. Currently, we use
4038 * the average of the dungeon and monster levels, and then add
4039 * five to allow slight increases in monster power.
4041 * Note that we use the new "monster allocation table" creation code
4042 * to restrict the "get_mon_num()" function to the set of "legal"
4043 * monsters, making this function much faster and more reliable.
4045 * Note that this function may not succeed, though this is very rare.
4047 bool summon_specific(int who, int y1, int x1, int lev, int type, u32b mode)
4051 if (p_ptr->inside_arena) return (FALSE);
4053 if (!mon_scatter(&y, &x, y1, x1, 2)) return FALSE;
4055 /* Save the summoner */
4056 summon_specific_who = who;
4058 /* Save the "summon" type */
4059 summon_specific_type = type;
4061 summon_unique_okay = (mode & PM_ALLOW_UNIQUE) ? TRUE : FALSE;
4063 /* Save the hostility */
4064 summon_specific_hostile = (!(mode & PM_FORCE_FRIENDLY) && !(is_friendly_idx(who)) && !(mode & PM_FORCE_PET));
4066 /* Prepare allocation table */
4067 get_mon_num_prep(summon_specific_okay, get_monster_hook2(y, x));
4069 /* Pick a monster, using the level calculation */
4070 r_idx = get_mon_num((dun_level + lev) / 2 + 5);
4072 /* Handle failure */
4075 summon_specific_type = 0;
4079 if ((type == SUMMON_BLUE_HORROR) || (type == SUMMON_DAWN)) mode |= PM_NO_KAGE;
4081 /* Attempt to place the monster (awake, allow groups) */
4082 if (!place_monster_aux(who, y, x, r_idx, mode))
4084 summon_specific_type = 0;
4088 summon_specific_type = 0;
4093 /* A "dangerous" function, creates a pet of the specified type */
4094 bool summon_named_creature (int who, int oy, int ox, int r_idx, u32b mode)
4099 /* if (!r_idx) return; */
4101 /* Prevent illegal monsters */
4102 if (r_idx >= max_r_idx) return FALSE;
4104 if (p_ptr->inside_arena) return FALSE;
4106 if (!mon_scatter(&y, &x, oy, ox, 2)) return FALSE;
4108 /* Place it (allow groups) */
4109 return place_monster_aux(who, y, x, r_idx, (mode | PM_NO_KAGE));
4114 * Let the given monster attempt to reproduce.
4116 * Note that "reproduction" REQUIRES empty space.
4118 bool multiply_monster(int m_idx, bool clone, u32b mode)
4120 monster_type *m_ptr = &m_list[m_idx];
4124 if (!mon_scatter(&y, &x, m_ptr->fy, m_ptr->fx, 1))
4127 if (m_ptr->mflag2 & MFLAG2_NOPET) mode |= PM_NO_PET;
4129 /* Create a new monster (awake, no groups) */
4130 if (!place_monster_aux(m_idx, y, x, m_ptr->r_idx, (mode | PM_NO_KAGE)))
4135 m_list[hack_m_idx_ii].smart |= SM_CLONED;
4136 m_list[hack_m_idx_ii].mflag2 |= MFLAG2_NOPET;
4147 * Dump a message describing a monster's reaction to damage
4149 * Technically should attempt to treat "Beholder"'s as jelly's
4151 void message_pain(int m_idx, int dam)
4153 long oldhp, newhp, tmp;
4156 monster_type *m_ptr = &m_list[m_idx];
4157 monster_race *r_ptr = &r_info[m_ptr->r_idx];
4162 /* Get the monster name */
4163 monster_desc(m_name, m_ptr, 0);
4165 /* Notice non-damage */
4169 msg_format("%^s¤Ï¥À¥á¡¼¥¸¤ò¼õ¤±¤Æ¤¤¤Ê¤¤¡£", m_name);
4171 msg_format("%^s is unharmed.", m_name);
4177 /* Note -- subtle fix -CFT */
4178 newhp = (long)(m_ptr->hp);
4179 oldhp = newhp + (long)(dam);
4180 tmp = (newhp * 100L) / oldhp;
4181 percentage = (int)(tmp);
4184 /* Mushrooms, Eyes, Jellies, Molds, Vortices, Worms, Quylthulgs */
4185 if (strchr(",ejmvwQ", r_ptr->d_char))
4188 if (percentage > 95)
4189 msg_format("%^s¤Ï¤Û¤È¤ó¤Éµ¤¤Ë¤È¤á¤Æ¤¤¤Ê¤¤¡£", m_name);
4190 else if (percentage > 75)
4191 msg_format("%^s¤Ï¤·¤ê¹þ¤ß¤·¤¿¡£", m_name);
4192 else if (percentage > 50)
4193 msg_format("%^s¤Ï½Ì¤³¤Þ¤Ã¤¿¡£", m_name);
4194 else if (percentage > 35)
4195 msg_format("%^s¤ÏÄˤߤ˿̤¨¤¿¡£", m_name);
4196 else if (percentage > 20)
4197 msg_format("%^s¤Ï¿È¤â¤À¤¨¤·¤¿¡£", m_name);
4198 else if (percentage > 10)
4199 msg_format("%^s¤Ï¶ìÄˤǿȤâ¤À¤¨¤·¤¿¡£", m_name);
4201 msg_format("%^s¤Ï¤°¤Ë¤ã¤°¤Ë¤ã¤ÈáÛÚ»¤·¤¿¡£", m_name);
4203 if (percentage > 95)
4204 msg_format("%^s barely notices.", m_name);
4205 else if (percentage > 75)
4206 msg_format("%^s flinches.", m_name);
4207 else if (percentage > 50)
4208 msg_format("%^s squelches.", m_name);
4209 else if (percentage > 35)
4210 msg_format("%^s quivers in pain.", m_name);
4211 else if (percentage > 20)
4212 msg_format("%^s writhes about.", m_name);
4213 else if (percentage > 10)
4214 msg_format("%^s writhes in agony.", m_name);
4216 msg_format("%^s jerks limply.", m_name);
4223 else if (strchr("l", r_ptr->d_char))
4225 if (percentage > 95)
4227 msg_format("%^s¤Ï¤Û¤È¤ó¤Éµ¤¤Ë¤È¤á¤Æ¤¤¤Ê¤¤¡£", m_name);
4229 msg_format("%^s barely notices.", m_name);
4231 else if (percentage > 75)
4233 msg_format("%^s¤Ï¤·¤ê¹þ¤ß¤·¤¿¡£", m_name);
4235 msg_format("%^s flinches.", m_name);
4237 else if (percentage > 50)
4239 msg_format("%^s¤Ïí´í°¤·¤¿¡£", m_name);
4241 msg_format("%^s hesitates.", m_name);
4243 else if (percentage > 35)
4245 msg_format("%^s¤ÏÄˤߤ˿̤¨¤¿¡£", m_name);
4247 msg_format("%^s quivers in pain.", m_name);
4249 else if (percentage > 20)
4251 msg_format("%^s¤Ï¿È¤â¤À¤¨¤·¤¿¡£", m_name);
4253 msg_format("%^s writhes about.", m_name);
4255 else if (percentage > 10)
4257 msg_format("%^s¤Ï¶ìÄˤǿȤâ¤À¤¨¤·¤¿¡£", m_name);
4259 msg_format("%^s writhes in agony.", m_name);
4263 msg_format("%^s¤Ï¤°¤Ë¤ã¤°¤Ë¤ã¤ÈáÛÚ»¤·¤¿¡£", m_name);
4265 msg_format("%^s jerks limply.", m_name);
4270 /* Golems, Walls, Doors, Stairs */
4271 else if (strchr("g#+<>", r_ptr->d_char))
4273 if (percentage > 95)
4275 msg_format("%s¤Ï¹¶·â¤òµ¤¤Ë¤È¤á¤Æ¤¤¤Ê¤¤¡£", m_name);
4277 msg_format("%^s ignores the attack.", m_name);
4279 else if (percentage > 75)
4281 msg_format("%s¤Ï¹¶·â¤Ë¸ª¤ò¤¹¤¯¤á¤¿¡£", m_name);
4283 msg_format("%^s shrugs off the attack.", m_name);
4285 else if (percentage > 50)
4287 msg_format("%^s¤ÏÍëÌĤΤ褦¤ËËʤ¨¤¿¡£", m_name);
4289 msg_format("%^s roars thunderously.", m_name);
4291 else if (percentage > 35)
4293 msg_format("%^s¤Ï¶ì¤·¤²¤ËËʤ¨¤¿¡£", m_name);
4295 msg_format("%^s rumbles.", m_name);
4297 else if (percentage > 20)
4299 msg_format("%^s¤Ï¤¦¤á¤¤¤¿¡£", m_name);
4301 msg_format("%^s grunts.", m_name);
4303 else if (percentage > 10)
4305 msg_format("%^s¤Ïí´í°¤·¤¿¡£", m_name);
4307 msg_format("%^s hesitates.", m_name);
4311 msg_format("%^s¤Ï¤¯¤·¤ã¤¯¤·¤ã¤Ë¤Ê¤Ã¤¿¡£", m_name);
4313 msg_format("%^s crumples.", m_name);
4318 /* Snakes, Hydrae, Reptiles, Mimics */
4319 else if (strchr("JMR", r_ptr->d_char) || !isalpha(r_ptr->d_char))
4321 if (percentage > 95)
4323 msg_format("%^s¤Ï¤Û¤È¤ó¤Éµ¤¤Ë¤È¤á¤Æ¤¤¤Ê¤¤¡£", m_name);
4325 msg_format("%^s barely notices.", m_name);
4327 else if (percentage > 75)
4329 msg_format("%^s¤Ï¥·¡¼¥Ã¤ÈÌĤ¤¤¿¡£", m_name);
4331 msg_format("%^s hisses.", m_name);
4333 else if (percentage > 50)
4335 msg_format("%^s¤ÏÅܤäÆƬ¤ò¾å¤²¤¿¡£", m_name);
4337 msg_format("%^s rears up in anger.", m_name);
4339 else if (percentage > 35)
4341 msg_format("%^s¤ÏÌÔÁ³¤È°Ò³Å¤·¤¿¡£", m_name);
4343 msg_format("%^s hisses furiously.", m_name);
4345 else if (percentage > 20)
4347 msg_format("%^s¤Ï¿È¤â¤À¤¨¤·¤¿¡£", m_name);
4349 msg_format("%^s writhes about.", m_name);
4351 else if (percentage > 10)
4353 msg_format("%^s¤Ï¶ìÄˤǿȤâ¤À¤¨¤·¤¿¡£", m_name);
4355 msg_format("%^s writhes in agony.", m_name);
4359 msg_format("%^s¤Ï¤°¤Ë¤ã¤°¤Ë¤ã¤ÈáÛÚ»¤·¤¿¡£", m_name);
4361 msg_format("%^s jerks limply.", m_name);
4367 else if (strchr("f", r_ptr->d_char))
4369 if (percentage > 95)
4371 msg_format("%s¤Ï¹¶·â¤Ë¸ª¤ò¤¹¤¯¤á¤¿¡£", m_name);
4373 msg_format("%^s shrugs off the attack.", m_name);
4375 else if (percentage > 75)
4377 msg_format("%^s¤ÏËʤ¨¤¿¡£", m_name);
4379 msg_format("%^s roars.", m_name);
4381 else if (percentage > 50)
4383 msg_format("%^s¤ÏÅܤäÆËʤ¨¤¿¡£", m_name);
4385 msg_format("%^s growls angrily.", m_name);
4387 else if (percentage > 35)
4389 msg_format("%^s¤ÏÄˤߤǥ·¡¼¥Ã¤ÈÌĤ¤¤¿¡£", m_name);
4391 msg_format("%^s hisses with pain.", m_name);
4393 else if (percentage > 20)
4395 msg_format("%^s¤ÏÄˤߤǼ塹¤·¤¯ÌĤ¤¤¿¡£", m_name);
4397 msg_format("%^s mewls in pain.", m_name);
4399 else if (percentage > 10)
4401 msg_format("%^s¤Ï¶ìÄˤˤ¦¤á¤¤¤¿¡£", m_name);
4403 msg_format("%^s hisses in agony.", m_name);
4407 msg_format("%s¤Ï°¥¤ì¤ÊÌĤÀ¼¤ò½Ð¤·¤¿¡£", m_name);
4409 msg_format("%^s mewls pitifully.", m_name);
4414 /* Ants, Centipedes, Flies, Insects, Beetles, Spiders */
4415 else if (strchr("acFIKS", r_ptr->d_char))
4417 if (percentage > 95)
4419 msg_format("%s¤Ï¹¶·â¤òµ¤¤Ë¤È¤á¤Æ¤¤¤Ê¤¤¡£", m_name);
4421 msg_format("%^s ignores the attack.", m_name);
4423 else if (percentage > 75)
4425 msg_format("%^s¤Ï¥¡¼¥¡¼ÌĤ¤¤¿¡£", m_name);
4427 msg_format("%^s chitters.", m_name);
4430 else if (percentage > 50)
4432 msg_format("%^s¤Ï¥è¥í¥è¥íƨ¤²²ó¤Ã¤¿¡£", m_name);
4434 msg_format("%^s scuttles about.", m_name);
4437 else if (percentage > 35)
4439 msg_format("%^s¤Ï¤¦¤ë¤µ¤¯ÌĤ¤¤¿¡£", m_name);
4441 msg_format("%^s twitters.", m_name);
4444 else if (percentage > 20)
4446 msg_format("%^s¤ÏÄˤߤËáÛÚ»¤·¤¿¡£", m_name);
4448 msg_format("%^s jerks in pain.", m_name);
4451 else if (percentage > 10)
4453 msg_format("%^s¤Ï¶ìÄˤÇáÛÚ»¤·¤¿¡£", m_name);
4455 msg_format("%^s jerks in agony.", m_name);
4460 msg_format("%^s¤Ï¥Ô¥¯¥Ô¥¯¤Ò¤¤Ä¤Ã¤¿¡£", m_name);
4462 msg_format("%^s twitches.", m_name);
4469 else if (strchr("B", r_ptr->d_char))
4471 if (percentage > 95)
4473 msg_format("%^s¤Ï¤µ¤¨¤º¤Ã¤¿¡£", m_name);
4475 msg_format("%^s chirps.", m_name);
4478 else if (percentage > 75)
4480 msg_format("%^s¤Ï¥Ô¡¼¥Ô¡¼ÌĤ¤¤¿¡£", m_name);
4482 msg_format("%^s twitters.", m_name);
4485 else if (percentage > 50)
4487 msg_format("%^s¤Ï¥®¥ã¡¼¥®¥ã¡¼ÌĤ¤¤¿¡£", m_name);
4489 msg_format("%^s squawks.", m_name);
4492 else if (percentage > 35)
4494 msg_format("%^s¤Ï¥®¥ã¡¼¥®¥ã¡¼ÌĤ¤ï¤á¤¤¤¿¡£", m_name);
4496 msg_format("%^s chatters.", m_name);
4499 else if (percentage > 20)
4501 msg_format("%^s¤Ï¶ì¤·¤ó¤À¡£", m_name);
4503 msg_format("%^s jeers.", m_name);
4506 else if (percentage > 10)
4508 msg_format("%^s¤Ï¤Î¤¿¤¦¤Á²ó¤Ã¤¿¡£", m_name);
4510 msg_format("%^s flutters about.", m_name);
4515 msg_format("%^s¤Ï¥¡¼¥¡¼¤ÈÌĤ¶«¤ó¤À¡£", m_name);
4517 msg_format("%^s squeaks.", m_name);
4523 /* Dragons, Demons, High Undead */
4524 else if (strchr("duDLUW", r_ptr->d_char))
4526 if (percentage > 95)
4528 msg_format("%s¤Ï¹¶·â¤òµ¤¤Ë¤È¤á¤Æ¤¤¤Ê¤¤¡£", m_name);
4530 msg_format("%^s ignores the attack.", m_name);
4533 else if (percentage > 75)
4535 msg_format("%^s¤Ï¤·¤ê¹þ¤ß¤·¤¿¡£", m_name);
4537 msg_format("%^s flinches.", m_name);
4540 else if (percentage > 50)
4542 msg_format("%^s¤ÏÄˤߤǥ·¡¼¥Ã¤ÈÌĤ¤¤¿¡£", m_name);
4544 msg_format("%^s hisses in pain.", m_name);
4547 else if (percentage > 35)
4549 msg_format("%^s¤ÏÄˤߤǤ¦¤Ê¤Ã¤¿¡£", m_name);
4551 msg_format("%^s snarls with pain.", m_name);
4554 else if (percentage > 20)
4556 msg_format("%^s¤ÏÄˤߤËËʤ¨¤¿¡£", m_name);
4558 msg_format("%^s roars with pain.", m_name);
4561 else if (percentage > 10)
4563 msg_format("%^s¤Ï¶ì¤·¤²¤Ë¶«¤ó¤À¡£", m_name);
4565 msg_format("%^s gasps.", m_name);
4570 msg_format("%^s¤Ï¼å¡¹¤·¤¯¤¦¤Ê¤Ã¤¿¡£", m_name);
4572 msg_format("%^s snarls feebly.", m_name);
4579 else if (strchr("s", r_ptr->d_char))
4581 if (percentage > 95)
4583 msg_format("%s¤Ï¹¶·â¤òµ¤¤Ë¤È¤á¤Æ¤¤¤Ê¤¤¡£", m_name);
4585 msg_format("%^s ignores the attack.", m_name);
4588 else if (percentage > 75)
4590 msg_format("%s¤Ï¹¶·â¤Ë¸ª¤ò¤¹¤¯¤á¤¿¡£", m_name);
4592 msg_format("%^s shrugs off the attack.", m_name);
4595 else if (percentage > 50)
4597 msg_format("%^s¤Ï¥«¥¿¥«¥¿¤È¾Ð¤Ã¤¿¡£", m_name);
4599 msg_format("%^s rattles.", m_name);
4602 else if (percentage > 35)
4604 msg_format("%^s¤Ï¤è¤í¤á¤¤¤¿¡£", m_name);
4606 msg_format("%^s stumbles.", m_name);
4609 else if (percentage > 20)
4611 msg_format("%^s¤Ï¥«¥¿¥«¥¿¸À¤Ã¤¿¡£", m_name);
4613 msg_format("%^s rattles.", m_name);
4616 else if (percentage > 10)
4618 msg_format("%^s¤Ï¤è¤í¤á¤¤¤¿¡£", m_name);
4620 msg_format("%^s staggers.", m_name);
4625 msg_format("%^s¤Ï¥¬¥¿¥¬¥¿¸À¤Ã¤¿¡£", m_name);
4627 msg_format("%^s clatters.", m_name);
4634 else if (strchr("z", r_ptr->d_char))
4636 if (percentage > 95)
4638 msg_format("%s¤Ï¹¶·â¤òµ¤¤Ë¤È¤á¤Æ¤¤¤Ê¤¤¡£", m_name);
4640 msg_format("%^s ignores the attack.", m_name);
4643 else if (percentage > 75)
4645 msg_format("%s¤Ï¹¶·â¤Ë¸ª¤ò¤¹¤¯¤á¤¿¡£", m_name);
4647 msg_format("%^s shrugs off the attack.", m_name);
4650 else if (percentage > 50)
4652 msg_format("%^s¤Ï¤¦¤á¤¤¤¿¡£", m_name);
4654 msg_format("%^s groans.", m_name);
4657 else if (percentage > 35)
4659 msg_format("%s¤Ï¶ì¤·¤²¤Ë¤¦¤á¤¤¤¿¡£", m_name);
4661 msg_format("%^s moans.", m_name);
4664 else if (percentage > 20)
4666 msg_format("%^s¤Ïí´í°¤·¤¿¡£", m_name);
4668 msg_format("%^s hesitates.", m_name);
4671 else if (percentage > 10)
4673 msg_format("%^s¤Ï¤¦¤Ê¤Ã¤¿¡£", m_name);
4675 msg_format("%^s grunts.", m_name);
4680 msg_format("%^s¤Ï¤è¤í¤á¤¤¤¿¡£", m_name);
4682 msg_format("%^s staggers.", m_name);
4689 else if (strchr("G", r_ptr->d_char))
4692 if (percentage > 95)
4694 msg_format("%s¤Ï¹¶·â¤òµ¤¤Ë¤È¤á¤Æ¤¤¤Ê¤¤¡£", m_name);
4696 msg_format("%^s ignores the attack.", m_name);
4699 else if (percentage > 75)
4701 msg_format("%s¤Ï¹¶·â¤Ë¸ª¤ò¤¹¤¯¤á¤¿¡£", m_name);
4703 msg_format("%^s shrugs off the attack.", m_name);
4706 else if (percentage > 50)
4708 msg_format("%s¤Ï¤¦¤á¤¤¤¿¡£", m_name);
4710 msg_format("%^s moans.", m_name);
4713 else if (percentage > 35)
4715 msg_format("%^s¤Ïµã¤¤ï¤á¤¤¤¿¡£", m_name);
4717 msg_format("%^s wails.", m_name);
4720 else if (percentage > 20)
4722 msg_format("%^s¤ÏËʤ¨¤¿¡£", m_name);
4724 msg_format("%^s howls.", m_name);
4727 else if (percentage > 10)
4729 msg_format("%s¤Ï¼å¡¹¤·¤¯¤¦¤á¤¤¤¿¡£", m_name);
4731 msg_format("%^s moans softly.", m_name);
4736 msg_format("%^s¤Ï¤«¤¹¤«¤Ë¤¦¤á¤¤¤¿¡£", m_name);
4738 msg_format("%^s sighs.", m_name);
4744 /* Dogs and Hounds */
4745 else if (strchr("CZ", r_ptr->d_char))
4748 if (percentage > 95)
4749 msg_format("%^s¤Ï¹¶·â¤Ë¸ª¤ò¤¹¤¯¤á¤¿¡£", m_name);
4750 else if (percentage > 75)
4751 msg_format("%^s¤ÏÄˤߤǤ¦¤Ê¤Ã¤¿¡£", m_name);
4752 else if (percentage > 50)
4753 msg_format("%^s¤ÏÄˤߤǥ¥ã¥ó¥¥ã¥óËʤ¨¤¿¡£", m_name);
4754 else if (percentage > 35)
4755 msg_format("%^s¤ÏÄˤߤÇÌĤ¤ï¤á¤¤¤¿¡£", m_name);
4756 else if (percentage > 20)
4757 msg_format("%^s¤Ï¶ìÄˤΤ¢¤Þ¤êÌĤ¤ï¤á¤¤¤¿¡£", m_name);
4758 else if (percentage > 10)
4759 msg_format("%^s¤Ï¶ìÄˤǤâ¤À¤¨¶ì¤·¤ó¤À¡£", m_name);
4761 msg_format("%^s¤Ï¼å¡¹¤·¤¯Ëʤ¨¤¿¡£", m_name);
4763 if (percentage > 95)
4764 msg_format("%^s shrugs off the attack.", m_name);
4765 else if (percentage > 75)
4766 msg_format("%^s snarls with pain.", m_name);
4767 else if (percentage > 50)
4768 msg_format("%^s yelps in pain.", m_name);
4769 else if (percentage > 35)
4770 msg_format("%^s howls in pain.", m_name);
4771 else if (percentage > 20)
4772 msg_format("%^s howls in agony.", m_name);
4773 else if (percentage > 10)
4774 msg_format("%^s writhes in agony.", m_name);
4776 msg_format("%^s yelps feebly.", m_name);
4781 /* One type of monsters (ignore,squeal,shriek) */
4782 else if (strchr("Xbilqrt", r_ptr->d_char))
4785 if (percentage > 95)
4786 msg_format("%^s¤Ï¹¶·â¤òµ¤¤Ë¤È¤á¤Æ¤¤¤Ê¤¤¡£", m_name);
4787 else if (percentage > 75)
4788 msg_format("%^s¤ÏÄˤߤǤ¦¤Ê¤Ã¤¿¡£", m_name);
4789 else if (percentage > 50)
4790 msg_format("%^s¤ÏÄˤߤǶ«¤ó¤À¡£", m_name);
4791 else if (percentage > 35)
4792 msg_format("%^s¤ÏÄˤߤÇÀ䶫¤·¤¿¡£", m_name);
4793 else if (percentage > 20)
4794 msg_format("%^s¤Ï¶ìÄˤΤ¢¤Þ¤êÀ䶫¤·¤¿¡£", m_name);
4795 else if (percentage > 10)
4796 msg_format("%^s¤Ï¶ìÄˤǤâ¤À¤¨¶ì¤·¤ó¤À¡£", m_name);
4798 msg_format("%^s¤Ï¼å¡¹¤·¤¯¶«¤ó¤À¡£", m_name);
4800 if (percentage > 95)
4801 msg_format("%^s ignores the attack.", m_name);
4802 else if (percentage > 75)
4803 msg_format("%^s grunts with pain.", m_name);
4804 else if (percentage > 50)
4805 msg_format("%^s squeals in pain.", m_name);
4806 else if (percentage > 35)
4807 msg_format("%^s shrieks in pain.", m_name);
4808 else if (percentage > 20)
4809 msg_format("%^s shrieks in agony.", m_name);
4810 else if (percentage > 10)
4811 msg_format("%^s writhes in agony.", m_name);
4813 msg_format("%^s cries out feebly.", m_name);
4818 /* Another type of monsters (shrug,cry,scream) */
4822 if (percentage > 95)
4823 msg_format("%^s¤Ï¹¶·â¤Ë¸ª¤ò¤¹¤¯¤á¤¿¡£", m_name);
4824 else if (percentage > 75)
4825 msg_format("%^s¤ÏÄˤߤǤ¦¤Ê¤Ã¤¿¡£", m_name);
4826 else if (percentage > 50)
4827 msg_format("%^s¤ÏÄˤߤǶ«¤ó¤À¡£", m_name);
4828 else if (percentage > 35)
4829 msg_format("%^s¤ÏÄˤߤÇÀ䶫¤·¤¿¡£", m_name);
4830 else if (percentage > 20)
4831 msg_format("%^s¤Ï¶ìÄˤΤ¢¤Þ¤êÀ䶫¤·¤¿¡£", m_name);
4832 else if (percentage > 10)
4833 msg_format("%^s¤Ï¶ìÄˤǤâ¤À¤¨¶ì¤·¤ó¤À¡£", m_name);
4835 msg_format("%^s¤Ï¼å¡¹¤·¤¯¶«¤ó¤À¡£", m_name);
4837 if (percentage > 95)
4838 msg_format("%^s shrugs off the attack.", m_name);
4839 else if (percentage > 75)
4840 msg_format("%^s grunts with pain.", m_name);
4841 else if (percentage > 50)
4842 msg_format("%^s cries out in pain.", m_name);
4843 else if (percentage > 35)
4844 msg_format("%^s screams in pain.", m_name);
4845 else if (percentage > 20)
4846 msg_format("%^s screams in agony.", m_name);
4847 else if (percentage > 10)
4848 msg_format("%^s writhes in agony.", m_name);
4850 msg_format("%^s cries out feebly.", m_name);
4858 * Learn about an "observed" resistance.
4860 void update_smart_learn(int m_idx, int what)
4862 #ifdef DRS_SMART_OPTIONS
4864 monster_type *m_ptr = &m_list[m_idx];
4866 monster_race *r_ptr = &r_info[m_ptr->r_idx];
4869 /* Not allowed to learn */
4870 if (!smart_learn) return;
4872 /* Too stupid to learn anything */
4873 if (r_ptr->flags2 & (RF2_STUPID)) return;
4875 /* Not intelligent, only learn sometimes */
4876 if (!(r_ptr->flags2 & (RF2_SMART)) && (randint0(100) < 50)) return;
4881 /* Analyze the knowledge */
4885 if (p_ptr->resist_acid) m_ptr->smart |= (SM_RES_ACID);
4886 if (IS_OPPOSE_ACID()) m_ptr->smart |= (SM_OPP_ACID);
4887 if (p_ptr->immune_acid) m_ptr->smart |= (SM_IMM_ACID);
4891 if (p_ptr->resist_elec) m_ptr->smart |= (SM_RES_ELEC);
4892 if (IS_OPPOSE_ELEC()) m_ptr->smart |= (SM_OPP_ELEC);
4893 if (p_ptr->immune_elec) m_ptr->smart |= (SM_IMM_ELEC);
4897 if (p_ptr->resist_fire) m_ptr->smart |= (SM_RES_FIRE);
4898 if (IS_OPPOSE_FIRE()) m_ptr->smart |= (SM_OPP_FIRE);
4899 if (p_ptr->immune_fire) m_ptr->smart |= (SM_IMM_FIRE);
4903 if (p_ptr->resist_cold) m_ptr->smart |= (SM_RES_COLD);
4904 if (IS_OPPOSE_COLD()) m_ptr->smart |= (SM_OPP_COLD);
4905 if (p_ptr->immune_cold) m_ptr->smart |= (SM_IMM_COLD);
4909 if (p_ptr->resist_pois) m_ptr->smart |= (SM_RES_POIS);
4910 if (IS_OPPOSE_POIS()) m_ptr->smart |= (SM_OPP_POIS);
4915 if (p_ptr->resist_neth) m_ptr->smart |= (SM_RES_NETH);
4919 if (p_ptr->resist_lite) m_ptr->smart |= (SM_RES_LITE);
4923 if (p_ptr->resist_dark) m_ptr->smart |= (SM_RES_DARK);
4927 if (p_ptr->resist_fear) m_ptr->smart |= (SM_RES_FEAR);
4931 if (p_ptr->resist_conf) m_ptr->smart |= (SM_RES_CONF);
4935 if (p_ptr->resist_chaos) m_ptr->smart |= (SM_RES_CHAOS);
4939 if (p_ptr->resist_disen) m_ptr->smart |= (SM_RES_DISEN);
4943 if (p_ptr->resist_blind) m_ptr->smart |= (SM_RES_BLIND);
4947 if (p_ptr->resist_nexus) m_ptr->smart |= (SM_RES_NEXUS);
4951 if (p_ptr->resist_sound) m_ptr->smart |= (SM_RES_SOUND);
4955 if (p_ptr->resist_shard) m_ptr->smart |= (SM_RES_SHARD);
4959 if (p_ptr->free_act) m_ptr->smart |= (SM_IMM_FREE);
4963 if (!p_ptr->msp) m_ptr->smart |= (SM_IMM_MANA);
4967 if (p_ptr->reflect) m_ptr-> smart |= (SM_IMM_REFLECT);
4971 #endif /* DRS_SMART_OPTIONS */
4977 * Place the player in the dungeon XXX XXX
4979 bool player_place(int y, int x)
4981 /* Paranoia XXX XXX */
4982 if (cave[y][x].m_idx != 0) return FALSE;
4984 /* Save player location */
4994 * Drop all items carried by a monster
4996 void monster_drop_carried_objects(monster_type *m_ptr)
4998 s16b this_o_idx, next_o_idx = 0;
5004 /* Drop objects being carried */
5005 for (this_o_idx = m_ptr->hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
5007 /* Acquire object */
5008 o_ptr = &o_list[this_o_idx];
5010 /* Acquire next object */
5011 next_o_idx = o_ptr->next_o_idx;
5014 o_ptr->held_m_idx = 0;
5016 /* Get local object */
5019 /* Copy the object */
5020 object_copy(q_ptr, o_ptr);
5022 /* Delete the object */
5023 delete_object_idx(this_o_idx);
5026 (void)drop_near(q_ptr, -1, m_ptr->fy, m_ptr->fx);
5029 /* Forget objects */
5030 m_ptr->hold_o_idx = 0;