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 * 0x01 --> Objective (or Reflexive)
1518 * 0x02 --> Possessive (or Reflexive)
1519 * 0x04 --> Use indefinites for hidden monsters ("something")
1520 * 0x08 --> Use indefinites for visible monsters ("a kobold")
1521 * 0x10 --> Pronominalize hidden monsters
1522 * 0x20 --> Pronominalize visible monsters
1523 * 0x40 --> Assume the monster is hidden
1524 * 0x80 --> Assume the monster is visible
1525 * 0x100 --> Chameleon's true name
1526 * 0x200 --> Ignore hallucination, and penetrate shape change
1527 * 0x400 --> Assume this monster pet waiting outside the floor
1530 * 0x00 --> Full nominative name ("the kobold") or "it"
1531 * 0x04 --> Full nominative name ("the kobold") or "something"
1532 * 0x80 --> Genocide resistance name ("the kobold")
1533 * 0x88 --> Killing name ("a kobold")
1534 * 0x22 --> Possessive, genderized if visable ("his") or "its"
1535 * 0x23 --> Reflexive, genderized if visable ("himself") or "itself"
1537 void monster_desc(char *desc, monster_type *m_ptr, int mode)
1540 monster_race *r_ptr;
1544 char silly_name[1024];
1548 r_ptr = &r_info[m_ptr->ap_r_idx];
1550 /* Mode of 0x100 will reveal Chameleon's true name */
1551 if (mode & 0x100) name = (r_name + real_r_ptr(m_ptr)->name);
1552 else name = (r_name + r_ptr->name);
1554 /* Are we hallucinating? (Idea from Nethack...) */
1555 if (p_ptr->image && !(mode & 0x200))
1560 if (!get_rnd_line("silly_j.txt", m_ptr->r_idx, silly_name))
1562 if (!get_rnd_line("silly.txt", m_ptr->r_idx, silly_name))
1570 monster_race *hallu_race;
1574 hallu_race = &r_info[randint1(max_r_idx - 1)];
1576 while (hallu_race->flags1 & RF1_UNIQUE);
1578 strcpy(silly_name, (r_name + hallu_race->name));
1581 /* Better not strcpy it, or we could corrupt r_info... */
1585 /* Can we "see" it (exists + forced, or visible + not unforced) */
1586 seen = (m_ptr && ((mode & 0x80) || (!(mode & 0x40) && m_ptr->ml)));
1588 /* Sexed Pronouns (seen and allowed, or unseen and allowed) */
1589 pron = (m_ptr && ((seen && (mode & 0x20)) || (!seen && (mode & 0x10))));
1592 /* First, try using pronouns, or describing hidden monsters */
1595 /* an encoding of the monster "sex" */
1598 /* Extract the gender (if applicable) */
1599 if (r_ptr->flags1 & (RF1_FEMALE)) kind = 0x20;
1600 else if (r_ptr->flags1 & (RF1_MALE)) kind = 0x10;
1602 /* Ignore the gender (if desired) */
1603 if (!m_ptr || !pron) kind = 0x00;
1606 /* Assume simple result */
1614 /* Brute force: split on the possibilities */
1615 switch (kind + (mode & 0x07))
1617 /* Neuter, or unknown */
1619 case 0x00: res = "²¿¤«"; break;
1620 case 0x01: res = "²¿¤«"; break;
1621 case 0x02: res = "²¿¤«¤Î"; break;
1622 case 0x03: res = "²¿¤«¼«¿È"; break;
1623 case 0x04: res = "²¿¤«"; break;
1624 case 0x05: res = "²¿¤«"; break;
1625 case 0x06: res = "²¿¤«"; break;
1626 case 0x07: res = "¤½¤ì¼«¿È"; break;
1628 case 0x00: res = "it"; break;
1629 case 0x01: res = "it"; break;
1630 case 0x02: res = "its"; break;
1631 case 0x03: res = "itself"; break;
1632 case 0x04: res = "something"; break;
1633 case 0x05: res = "something"; break;
1634 case 0x06: res = "something's"; break;
1635 case 0x07: res = "itself"; break;
1639 /* Male (assume human if vague) */
1641 case 0x10: res = "Èà"; break;
1642 case 0x11: res = "Èà"; break;
1643 case 0x12: res = "Èà¤Î"; break;
1644 case 0x13: res = "È༫¿È"; break;
1645 case 0x14: res = "狼"; break;
1646 case 0x15: res = "狼"; break;
1647 case 0x16: res = "狼¤Î"; break;
1648 case 0x17: res = "È༫¿È"; break;
1650 case 0x10: res = "he"; break;
1651 case 0x11: res = "him"; break;
1652 case 0x12: res = "his"; break;
1653 case 0x13: res = "himself"; break;
1654 case 0x14: res = "someone"; break;
1655 case 0x15: res = "someone"; break;
1656 case 0x16: res = "someone's"; break;
1657 case 0x17: res = "himself"; break;
1661 /* Female (assume human if vague) */
1663 case 0x20: res = "Èà½÷"; break;
1664 case 0x21: res = "Èà½÷"; break;
1665 case 0x22: res = "Èà½÷¤Î"; break;
1666 case 0x23: res = "Èà½÷¼«¿È"; break;
1667 case 0x24: res = "狼"; break;
1668 case 0x25: res = "狼"; break;
1669 case 0x26: res = "狼¤Î"; break;
1670 case 0x27: res = "Èà½÷¼«¿È"; break;
1672 case 0x20: res = "she"; break;
1673 case 0x21: res = "her"; break;
1674 case 0x22: res = "her"; break;
1675 case 0x23: res = "herself"; break;
1676 case 0x24: res = "someone"; break;
1677 case 0x25: res = "someone"; break;
1678 case 0x26: res = "someone's"; break;
1679 case 0x27: res = "herself"; break;
1684 /* Copy the result */
1685 (void)strcpy(desc, res);
1689 /* Handle visible monsters, "reflexive" request */
1690 else if ((mode & 0x02) && (mode & 0x01))
1692 /* The monster is visible, so use its gender */
1694 if (r_ptr->flags1 & (RF1_FEMALE)) strcpy(desc, "Èà½÷¼«¿È");
1695 else if (r_ptr->flags1 & (RF1_MALE)) strcpy(desc, "È༫¿È");
1696 else strcpy(desc, "¤½¤ì¼«¿È");
1698 if (r_ptr->flags1 & RF1_FEMALE) strcpy(desc, "herself");
1699 else if (r_ptr->flags1 & RF1_MALE) strcpy(desc, "himself");
1700 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 & 0x200)))
1733 /* Start with the name (thus nominative and objective) */
1734 if ((m_ptr->mflag2 & MFLAG2_CHAMELEON) && !(mode & 0x100))
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 & 0x08)
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 ((m_ptr->fy == py) && (m_ptr->fx == px))
1811 strcat(desc,"(¾èÇÏÃæ)");
1813 strcat(desc,"(riding)");
1817 if ((mode & 0x200) && (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 & 0x200) && m_ptr->ap_r_idx != m_ptr->r_idx)
1839 strcat(desc, format("(%s)", r_name + r_info[m_ptr->r_idx].name));
1845 strcat(desc,"(ÂÔµ¡Ãæ)");
1847 strcat(desc,"(waiting)");
1851 /* Handle the Possessive as a special afterthought */
1854 /* XXX Check for trailing "s" */
1856 /* Simply append "apostrophe" and "s" */
1858 (void)strcat(desc, "¤Î");
1860 (void)strcat(desc, "'s");
1871 * Learn about a monster (by "probing" it)
1873 * Return the number of new flags learnt. -Mogami-
1875 int lore_do_probe(int r_idx)
1877 monster_race *r_ptr = &r_info[r_idx];
1881 /* Maximal info about awareness */
1882 if (r_ptr->r_wake != MAX_UCHAR) n++;
1883 if (r_ptr->r_ignore != MAX_UCHAR) n++;
1884 r_ptr->r_wake = r_ptr->r_ignore = MAX_UCHAR;
1886 /* Observe "maximal" attacks */
1887 for (i = 0; i < 4; i++)
1889 /* Examine "actual" blows */
1890 if (r_ptr->blow[i].effect || r_ptr->blow[i].method)
1892 /* Maximal observations */
1893 if (r_ptr->r_blows[i] != MAX_UCHAR) n++;
1894 r_ptr->r_blows[i] = MAX_UCHAR;
1900 (((r_ptr->flags1 & RF1_DROP_4D2) ? 8 : 0) +
1901 ((r_ptr->flags1 & RF1_DROP_3D2) ? 6 : 0) +
1902 ((r_ptr->flags1 & RF1_DROP_2D2) ? 4 : 0) +
1903 ((r_ptr->flags1 & RF1_DROP_1D2) ? 2 : 0) +
1904 ((r_ptr->flags1 & RF1_DROP_90) ? 1 : 0) +
1905 ((r_ptr->flags1 & RF1_DROP_60) ? 1 : 0));
1907 /* Only "valid" drops */
1908 if (!(r_ptr->flags1 & RF1_ONLY_GOLD))
1910 if (r_ptr->r_drop_item != tmp_byte) n++;
1911 r_ptr->r_drop_item = tmp_byte;
1913 if (!(r_ptr->flags1 & RF1_ONLY_ITEM))
1915 if (r_ptr->r_drop_gold != tmp_byte) n++;
1916 r_ptr->r_drop_gold = tmp_byte;
1919 /* Observe many spells */
1920 if (r_ptr->r_cast_spell != MAX_UCHAR) n++;
1921 r_ptr->r_cast_spell = MAX_UCHAR;
1923 /* Count unknown flags */
1924 for (i = 0; i < 32; i++)
1926 if (!(r_ptr->r_flags1 & (1L << i)) &&
1927 (r_ptr->flags1 & (1L << i))) n++;
1928 if (!(r_ptr->r_flags2 & (1L << i)) &&
1929 (r_ptr->flags2 & (1L << i))) n++;
1930 if (!(r_ptr->r_flags3 & (1L << i)) &&
1931 (r_ptr->flags3 & (1L << i))) n++;
1932 if (!(r_ptr->r_flags4 & (1L << i)) &&
1933 (r_ptr->flags4 & (1L << i))) n++;
1934 if (!(r_ptr->r_flags5 & (1L << i)) &&
1935 (r_ptr->flags5 & (1L << i))) n++;
1936 if (!(r_ptr->r_flags6 & (1L << i)) &&
1937 (r_ptr->flags6 & (1L << i))) n++;
1939 /* r_flags7 is actually unused */
1941 if (!(r_ptr->r_flags7 & (1L << i)) &&
1942 (r_ptr->flags7 & (1L << i))) n++;
1946 /* Know all the flags */
1947 r_ptr->r_flags1 = r_ptr->flags1;
1948 r_ptr->r_flags2 = r_ptr->flags2;
1949 r_ptr->r_flags3 = r_ptr->flags3;
1950 r_ptr->r_flags4 = r_ptr->flags4;
1951 r_ptr->r_flags5 = r_ptr->flags5;
1952 r_ptr->r_flags6 = r_ptr->flags6;
1954 /* r_flags7 is actually unused */
1955 /* r_ptr->r_flags7 = r_ptr->flags7; */
1957 /* Know about evolution */
1958 if (!(r_ptr->r_xtra1 & MR1_SINKA)) n++;
1959 r_ptr->r_xtra1 |= MR1_SINKA;
1961 /* Update monster recall window */
1962 if (p_ptr->monster_race_idx == r_idx)
1965 p_ptr->window |= (PW_MONSTER);
1968 /* Return the number of new flags learnt */
1974 * Take note that the given monster just dropped some treasure
1976 * Note that learning the "GOOD"/"GREAT" flags gives information
1977 * about the treasure (even when the monster is killed for the first
1978 * time, such as uniques, and the treasure has not been examined yet).
1980 * This "indirect" method is used to prevent the player from learning
1981 * exactly how much treasure a monster can drop from observing only
1982 * a single example of a drop. This method actually observes how much
1983 * gold and items are dropped, and remembers that information to be
1984 * described later by the monster recall code.
1986 void lore_treasure(int m_idx, int num_item, int num_gold)
1988 monster_type *m_ptr = &m_list[m_idx];
1990 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1992 /* Note the number of things dropped */
1993 if (num_item > r_ptr->r_drop_item) r_ptr->r_drop_item = num_item;
1994 if (num_gold > r_ptr->r_drop_gold) r_ptr->r_drop_gold = num_gold;
1996 /* Hack -- memorize the good/great flags */
1997 if (r_ptr->flags1 & (RF1_DROP_GOOD)) r_ptr->r_flags1 |= (RF1_DROP_GOOD);
1998 if (r_ptr->flags1 & (RF1_DROP_GREAT)) r_ptr->r_flags1 |= (RF1_DROP_GREAT);
2000 /* Update monster recall window */
2001 if (p_ptr->monster_race_idx == m_ptr->r_idx)
2004 p_ptr->window |= (PW_MONSTER);
2010 void sanity_blast(monster_type *m_ptr, bool necro)
2012 bool happened = FALSE;
2015 if (p_ptr->inside_battle || !character_dungeon) return;
2020 monster_race *r_ptr = &r_info[m_ptr->r_idx];
2022 power = r_ptr->level / 2;
2024 monster_desc(m_name, m_ptr, 0);
2026 if (!(r_ptr->flags1 & RF1_UNIQUE))
2028 if (r_ptr->flags1 & RF1_FRIENDS)
2034 return; /* No effect yet, just loaded... */
2037 return; /* Cannot see it for some reason */
2039 if (!(r_ptr->flags2 & RF2_ELDRITCH_HORROR))
2045 return; /* Pet eldritch horrors are safe most of the time */
2047 if (randint1(100) > power) return;
2049 if (saving_throw(p_ptr->skill_sav - power))
2051 return; /* Save, no adverse effects */
2056 /* Something silly happens... */
2058 msg_format("%s%s¤Î´é¤ò¸«¤Æ¤·¤Þ¤Ã¤¿¡ª",
2059 funny_desc[randint0(MAX_SAN_FUNNY)], m_name);
2061 msg_format("You behold the %s visage of %s!",
2062 funny_desc[randint0(MAX_SAN_FUNNY)], m_name);
2068 msg_print(funny_comments[randint0(MAX_SAN_COMMENT)]);
2069 p_ptr->image = p_ptr->image + randint1(r_ptr->level);
2072 return; /* Never mind; we can't see it clearly enough */
2075 /* Something frightening happens... */
2077 msg_format("%s%s¤Î´é¤ò¸«¤Æ¤·¤Þ¤Ã¤¿¡ª",
2078 horror_desc[randint0(MAX_SAN_HORROR)], m_name);
2080 msg_format("You behold the %s visage of %s!",
2081 horror_desc[randint0(MAX_SAN_HORROR)], m_name);
2084 r_ptr->r_flags2 |= RF2_ELDRITCH_HORROR;
2086 /* Demon characters are unaffected */
2087 if (prace_is_(RACE_IMP) || prace_is_(RACE_DEMON) || (mimic_info[p_ptr->mimic_form].MIMIC_FLAGS & MIMIC_IS_DEMON)) return;
2088 if (p_ptr->wizard) return;
2090 /* Undead characters are 50% likely to be unaffected */
2091 if (prace_is_(RACE_SKELETON) || prace_is_(RACE_ZOMBIE)
2092 || prace_is_(RACE_VAMPIRE) || prace_is_(RACE_SPECTRE) ||
2093 (mimic_info[p_ptr->mimic_form].MIMIC_FLAGS & MIMIC_IS_UNDEAD))
2095 if (saving_throw(25 + p_ptr->lev)) return;
2101 msg_print("¥Í¥¯¥í¥Î¥ß¥³¥ó¤òÆɤó¤ÇÀµµ¤¤ò¼º¤Ã¤¿¡ª");
2103 msg_print("Your sanity is shaken by reading the Necronomicon!");
2108 if (!saving_throw(p_ptr->skill_sav - power)) /* Mind blast */
2110 if (!p_ptr->resist_conf)
2112 (void)set_confused(p_ptr->confused + randint0(4) + 4);
2114 if (!p_ptr->resist_chaos && one_in_(3))
2116 (void)set_image(p_ptr->image + randint0(250) + 150);
2121 if (!saving_throw(p_ptr->skill_sav - power)) /* Lose int & wis */
2128 if (!saving_throw(p_ptr->skill_sav - power)) /* Brain smash */
2130 if (!p_ptr->resist_conf)
2132 (void)set_confused(p_ptr->confused + randint0(4) + 4);
2134 if (!p_ptr->free_act)
2136 (void)set_paralyzed(p_ptr->paralyzed + randint0(4) + 4);
2138 while (randint0(100) > p_ptr->skill_sav)
2139 (void)do_dec_stat(A_INT);
2140 while (randint0(100) > p_ptr->skill_sav)
2141 (void)do_dec_stat(A_WIS);
2142 if (!p_ptr->resist_chaos)
2144 (void)set_image(p_ptr->image + randint0(250) + 150);
2149 if (!saving_throw(p_ptr->skill_sav - power)) /* Amnesia */
2152 if (lose_all_info())
2154 msg_print("¤¢¤Þ¤ê¤Î¶²ÉݤËÁ´¤Æ¤Î¤³¤È¤ò˺¤ì¤Æ¤·¤Þ¤Ã¤¿¡ª");
2156 msg_print("You forget everything in your utmost terror!");
2162 if (saving_throw(p_ptr->skill_sav - power))
2167 /* Else gain permanent insanity */
2168 if ((p_ptr->muta3 & MUT3_MORONIC) && /*(p_ptr->muta2 & MUT2_BERS_RAGE) &&*/
2169 ((p_ptr->muta2 & MUT2_COWARDICE) || (p_ptr->resist_fear)) &&
2170 ((p_ptr->muta2 & MUT2_HALLU) || (p_ptr->resist_chaos)))
2172 /* The poor bastard already has all possible insanities! */
2178 switch (randint1(21))
2181 if (!(p_ptr->muta3 & MUT3_MORONIC) && one_in_(5))
2183 if ((p_ptr->stat_use[A_INT] < 4) && (p_ptr->stat_use[A_WIS] < 4))
2186 msg_print("¤¢¤Ê¤¿¤Ï´°àú¤ÊÇϼ¯¤Ë¤Ê¤Ã¤¿¤è¤¦¤Êµ¤¤¬¤·¤¿¡£¤·¤«¤·¤½¤ì¤Ï¸µ¡¹¤À¤Ã¤¿¡£");
2188 msg_print("You turn into an utter moron!");
2194 msg_print("¤¢¤Ê¤¿¤Ï´°àú¤ÊÇϼ¯¤Ë¤Ê¤Ã¤¿¡ª");
2196 msg_print("You turn into an utter moron!");
2200 if (p_ptr->muta3 & MUT3_HYPER_INT)
2203 msg_print("¤¢¤Ê¤¿¤ÎǾ¤ÏÀ¸ÂÎ¥³¥ó¥Ô¥å¡¼¥¿¤Ç¤Ï¤Ê¤¯¤Ê¤Ã¤¿¡£");
2205 msg_print("Your brain is no longer a living computer.");
2208 p_ptr->muta3 &= ~(MUT3_HYPER_INT);
2210 p_ptr->muta3 |= MUT3_MORONIC;
2224 if (!(p_ptr->muta2 & MUT2_COWARDICE) && !p_ptr->resist_fear)
2227 msg_print("¤¢¤Ê¤¿¤Ï¥Ñ¥é¥Î¥¤¥¢¤Ë¤Ê¤Ã¤¿¡ª");
2229 msg_print("You become paranoid!");
2233 /* Duh, the following should never happen, but anyway... */
2234 if (p_ptr->muta3 & MUT3_FEARLESS)
2237 msg_print("¤¢¤Ê¤¿¤Ï¤â¤¦¶²¤ìÃΤ餺¤Ç¤Ï¤Ê¤¯¤Ê¤Ã¤¿¡£");
2239 msg_print("You are no longer fearless.");
2242 p_ptr->muta3 &= ~(MUT3_FEARLESS);
2245 p_ptr->muta2 |= MUT2_COWARDICE;
2259 if (!(p_ptr->muta2 & MUT2_HALLU) && !p_ptr->resist_chaos)
2262 msg_print("¸¸³Ð¤ò¤Ò¤µ¯¤³¤¹Àº¿ÀºøÍð¤Ë´Ù¤Ã¤¿¡ª");
2264 msg_print("You are afflicted by a hallucinatory insanity!");
2267 p_ptr->muta2 |= MUT2_HALLU;
2272 if (!(p_ptr->muta2 & MUT2_BERS_RAGE))
2275 msg_print("·ãÎõ¤Ê´¶¾ð¤Îȯºî¤Ë¤ª¤½¤ï¤ì¤ë¤è¤¦¤Ë¤Ê¤Ã¤¿¡ª");
2277 msg_print("You become subject to fits of berserk rage!");
2280 p_ptr->muta2 |= MUT2_BERS_RAGE;
2287 p_ptr->update |= PU_BONUS;
2293 * This function updates the monster record of the given monster
2295 * This involves extracting the distance to the player (if requested),
2296 * and then checking for visibility (natural, infravision, see-invis,
2297 * telepathy), updating the monster visibility flag, redrawing (or
2298 * erasing) the monster when its visibility changes, and taking note
2299 * of any interesting monster flags (cold-blooded, invisible, etc).
2301 * Note the new "mflag" field which encodes several monster state flags,
2302 * including "view" for when the monster is currently in line of sight,
2303 * and "mark" for when the monster is currently visible via detection.
2305 * The only monster fields that are changed here are "cdis" (the
2306 * distance from the player), "ml" (visible to the player), and
2307 * "mflag" (to maintain the "MFLAG_VIEW" flag).
2309 * Note the special "update_monsters()" function which can be used to
2310 * call this function once for every monster.
2312 * Note the "full" flag which requests that the "cdis" field be updated,
2313 * this is only needed when the monster (or the player) has moved.
2315 * Every time a monster moves, we must call this function for that
2316 * monster, and update the distance, and the visibility. Every time
2317 * the player moves, we must call this function for every monster, and
2318 * update the distance, and the visibility. Whenever the player "state"
2319 * changes in certain ways ("blindness", "infravision", "telepathy",
2320 * and "see invisible"), we must call this function for every monster,
2321 * and update the visibility.
2323 * Routines that change the "illumination" of a grid must also call this
2324 * function for any monster in that grid, since the "visibility" of some
2325 * monsters may be based on the illumination of their grid.
2327 * Note that this function is called once per monster every time the
2328 * player moves. When the player is running, this function is one
2329 * of the primary bottlenecks, along with "update_view()" and the
2330 * "process_monsters()" code, so efficiency is important.
2332 * Note the optimized "inline" version of the "distance()" function.
2334 * A monster is "visible" to the player if (1) it has been detected
2335 * by the player, (2) it is close to the player and the player has
2336 * telepathy, or (3) it is close to the player, and in line of sight
2337 * of the player, and it is "illuminated" by some combination of
2338 * infravision, torch light, or permanent light (invisible monsters
2339 * are only affected by "light" if the player can see invisible).
2341 * Monsters which are not on the current panel may be "visible" to
2342 * the player, and their descriptions will include an "offscreen"
2343 * reference. Currently, offscreen monsters cannot be targetted
2344 * or viewed directly, but old targets will remain set. XXX XXX
2346 * The player can choose to be disturbed by several things, including
2347 * "disturb_move" (monster which is viewable moves in some way), and
2348 * "disturb_near" (monster which is "easily" viewable moves in some
2349 * way). Note that "moves" includes "appears" and "disappears".
2351 void update_mon(int m_idx, bool full)
2353 monster_type *m_ptr = &m_list[m_idx];
2355 monster_race *r_ptr = &r_info[m_ptr->r_idx];
2357 bool do_disturb = disturb_move;
2361 /* Current location */
2368 /* Seen by vision */
2374 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
2376 if (ap_r_ptr->r_tkills && ap_r_ptr->level >= p_ptr->lev)
2380 /* Compute distance */
2383 /* Distance components */
2384 int dy = (py > fy) ? (py - fy) : (fy - py);
2385 int dx = (px > fx) ? (px - fx) : (fx - px);
2387 /* Approximate distance */
2388 d = (dy > dx) ? (dy + (dx>>1)) : (dx + (dy>>1));
2390 /* Restrict distance */
2391 if (d > 255) d = 255;
2395 /* Save the distance */
2399 /* Extract distance */
2402 /* Extract the distance */
2408 if (m_ptr->mflag2 & (MFLAG2_MARK)) flag = TRUE;
2412 if (d <= ((d_info[dungeon_type].flags1 & DF1_DARKNESS) ? MAX_SIGHT / 2 : MAX_SIGHT))
2414 if (!(d_info[dungeon_type].flags1 & DF1_DARKNESS) || (d <= MAX_SIGHT / 4))
2416 if (p_ptr->special_defense & KATA_MUSOU)
2421 /* Hack -- Memorize mental flags */
2422 if (r_ptr->flags2 & (RF2_SMART)) r_ptr->r_flags2 |= (RF2_SMART);
2423 if (r_ptr->flags2 & (RF2_STUPID)) r_ptr->r_flags2 |= (RF2_STUPID);
2426 /* Basic telepathy */
2427 else if (p_ptr->telepathy)
2429 /* Empty mind, no telepathy */
2430 if (r_ptr->flags2 & (RF2_EMPTY_MIND))
2432 /* Memorize flags */
2433 r_ptr->r_flags2 |= (RF2_EMPTY_MIND);
2436 /* Weird mind, occasional telepathy */
2437 else if (r_ptr->flags2 & (RF2_WEIRD_MIND))
2439 /* One in ten individuals are detectable */
2440 if ((m_idx % 10) == 5)
2445 /* Memorize flags */
2446 r_ptr->r_flags2 |= (RF2_WEIRD_MIND);
2448 /* Hack -- Memorize mental flags */
2449 if (r_ptr->flags2 & (RF2_SMART)) r_ptr->r_flags2 |= (RF2_SMART);
2450 if (r_ptr->flags2 & (RF2_STUPID)) r_ptr->r_flags2 |= (RF2_STUPID);
2454 /* Normal mind, allow telepathy */
2460 /* Hack -- Memorize mental flags */
2461 if (r_ptr->flags2 & (RF2_SMART)) r_ptr->r_flags2 |= (RF2_SMART);
2462 if (r_ptr->flags2 & (RF2_STUPID)) r_ptr->r_flags2 |= (RF2_STUPID);
2466 /* Magical sensing */
2467 if ((p_ptr->esp_animal) && (r_ptr->flags3 & (RF3_ANIMAL)))
2470 r_ptr->r_flags3 |= (RF3_ANIMAL);
2474 /* Magical sensing */
2475 if ((p_ptr->esp_undead) && (r_ptr->flags3 & (RF3_UNDEAD)))
2478 r_ptr->r_flags3 |= (RF3_UNDEAD);
2482 /* Magical sensing */
2483 if ((p_ptr->esp_demon) && (r_ptr->flags3 & (RF3_DEMON)))
2486 r_ptr->r_flags3 |= (RF3_DEMON);
2490 /* Magical sensing */
2491 if ((p_ptr->esp_orc) && (r_ptr->flags3 & (RF3_ORC)))
2494 r_ptr->r_flags3 |= (RF3_ORC);
2498 /* Magical sensing */
2499 if ((p_ptr->esp_troll) && (r_ptr->flags3 & (RF3_TROLL)))
2502 r_ptr->r_flags3 |= (RF3_TROLL);
2506 /* Magical sensing */
2507 if ((p_ptr->esp_giant) && (r_ptr->flags3 & (RF3_GIANT)))
2510 r_ptr->r_flags3 |= (RF3_GIANT);
2514 /* Magical sensing */
2515 if ((p_ptr->esp_dragon) && (r_ptr->flags3 & (RF3_DRAGON)))
2518 r_ptr->r_flags3 |= (RF3_DRAGON);
2522 /* Magical sensing */
2523 if ((p_ptr->esp_human) && (r_ptr->flags2 & (RF2_HUMAN)))
2526 r_ptr->r_flags2 |= (RF2_HUMAN);
2530 /* Magical sensing */
2531 if ((p_ptr->esp_evil) && (r_ptr->flags3 & (RF3_EVIL)))
2534 r_ptr->r_flags3 |= (RF3_EVIL);
2538 /* Magical sensing */
2539 if ((p_ptr->esp_good) && (r_ptr->flags3 & (RF3_GOOD)))
2542 r_ptr->r_flags3 |= (RF3_GOOD);
2546 /* Magical sensing */
2547 if ((p_ptr->esp_nonliving) &&
2548 (r_ptr->flags3 & (RF3_NONLIVING)) &&
2549 !(r_ptr->flags3 & (RF3_DEMON)) &&
2550 !(r_ptr->flags3 & (RF3_UNDEAD)))
2553 r_ptr->r_flags3 |= (RF3_NONLIVING);
2557 /* Magical sensing */
2558 if ((p_ptr->esp_unique) && (r_ptr->flags1 & (RF1_UNIQUE)))
2561 r_ptr->r_flags1 |= (RF1_UNIQUE);
2566 /* Normal line of sight, and not blind */
2567 if (player_has_los_bold(fy, fx) && !p_ptr->blind)
2569 bool do_invisible = FALSE;
2570 bool do_cold_blood = FALSE;
2572 /* Use "infravision" */
2573 if (d <= p_ptr->see_infra)
2575 /* Handle "cold blooded" monsters */
2576 if (r_ptr->flags2 & (RF2_COLD_BLOOD))
2579 do_cold_blood = TRUE;
2582 /* Handle "warm blooded" monsters */
2590 /* Use "illumination" */
2591 if (player_can_see_bold(fy, fx))
2593 /* Handle "invisible" monsters */
2594 if (r_ptr->flags2 & (RF2_INVISIBLE))
2597 do_invisible = TRUE;
2607 /* Handle "normal" monsters */
2618 /* Memorize flags */
2619 if (do_invisible) r_ptr->r_flags2 |= (RF2_INVISIBLE);
2620 if (do_cold_blood) r_ptr->r_flags2 |= (RF2_COLD_BLOOD);
2626 /* The monster is now visible */
2629 /* It was previously unseen */
2632 /* Mark as visible */
2635 /* Draw the monster */
2638 /* Update health bar as needed */
2639 if (p_ptr->health_who == m_idx) p_ptr->redraw |= (PR_HEALTH);
2640 if (p_ptr->riding == m_idx) p_ptr->redraw |= (PR_UHEALTH);
2642 /* Hack -- Count "fresh" sightings */
2643 if ((m_ptr->ap_r_idx == MON_KAGE) && (r_info[MON_KAGE].r_sights < MAX_SHORT))
2644 r_info[MON_KAGE].r_sights++;
2645 else if (m_ptr->ap_r_idx == m_ptr->r_idx &&
2646 r_ptr->r_sights < MAX_SHORT) r_ptr->r_sights++;
2648 /* Eldritch Horror */
2649 if (r_ptr->flags2 & RF2_ELDRITCH_HORROR)
2651 sanity_blast(m_ptr, FALSE);
2654 /* Disturb on appearance */
2655 if (disturb_near && (projectable(m_ptr->fy, m_ptr->fx, py, px) && projectable(py, px, m_ptr->fy, m_ptr->fx)))
2657 if (disturb_pets || is_hostile(m_ptr))
2663 /* The monster is not visible */
2666 /* It was previously seen */
2669 /* Mark as not visible */
2672 /* Erase the monster */
2675 /* Update health bar as needed */
2676 if (p_ptr->health_who == m_idx) p_ptr->redraw |= (PR_HEALTH);
2677 if (p_ptr->riding == m_idx) p_ptr->redraw |= (PR_UHEALTH);
2679 /* Disturb on disappearance */
2682 if (disturb_pets || is_hostile(m_ptr))
2689 /* The monster is now easily visible */
2693 if (!(m_ptr->mflag & (MFLAG_VIEW)))
2695 /* Mark as easily visible */
2696 m_ptr->mflag |= (MFLAG_VIEW);
2698 /* Disturb on appearance */
2701 if (disturb_pets || is_hostile(m_ptr))
2707 /* The monster is not easily visible */
2711 if (m_ptr->mflag & (MFLAG_VIEW))
2713 /* Mark as not easily visible */
2714 m_ptr->mflag &= ~(MFLAG_VIEW);
2716 /* Disturb on disappearance */
2719 if (disturb_pets || is_hostile(m_ptr))
2728 * This function simply updates all the (non-dead) monsters (see above).
2730 void update_monsters(bool full)
2734 /* Update each (live) monster */
2735 for (i = 1; i < m_max; i++)
2737 monster_type *m_ptr = &m_list[i];
2739 /* Skip dead monsters */
2740 if (!m_ptr->r_idx) continue;
2742 /* Update the monster */
2743 update_mon(i, full);
2749 * Hack -- the index of the summoning monster
2751 static bool monster_hook_chameleon_lord(int r_idx)
2753 monster_race *r_ptr = &r_info[r_idx];
2754 monster_type *m_ptr = &m_list[chameleon_change_m_idx];
2755 monster_race *old_r_ptr = &r_info[m_ptr->r_idx];
2757 if (!(r_ptr->flags1 & (RF1_UNIQUE))) return FALSE;
2758 if (r_ptr->flags7 & (RF7_FRIENDLY | RF7_CHAMELEON)) return FALSE;
2760 if (ABS(r_ptr->level - r_info[MON_CHAMELEON_K].level) > 5) return FALSE;
2762 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))
2765 if (!monster_can_cross_terrain(cave[m_ptr->fy][m_ptr->fx].feat, r_ptr)) return FALSE;
2768 if (!(old_r_ptr->flags7 & RF7_CHAMELEON))
2770 if ((m_ptr->sub_align & SUB_ALIGN_EVIL) && (r_ptr->flags3 & RF3_GOOD)) return FALSE;
2771 if ((m_ptr->sub_align & SUB_ALIGN_GOOD) && (r_ptr->flags3 & RF3_EVIL)) return FALSE;
2775 else if (summon_specific_who > 0)
2777 monster_type *sm_ptr = &m_list[summon_specific_who];
2779 if ((sm_ptr->sub_align & SUB_ALIGN_EVIL) && (r_ptr->flags3 & RF3_GOOD)) return FALSE;
2780 if ((sm_ptr->sub_align & SUB_ALIGN_GOOD) && (r_ptr->flags3 & RF3_EVIL)) return FALSE;
2786 static bool monster_hook_chameleon(int r_idx)
2788 monster_race *r_ptr = &r_info[r_idx];
2789 monster_type *m_ptr = &m_list[chameleon_change_m_idx];
2790 monster_race *old_r_ptr = &r_info[m_ptr->r_idx];
2792 if (r_ptr->flags1 & (RF1_UNIQUE)) return FALSE;
2793 if (r_ptr->flags2 & RF2_MULTIPLY) return FALSE;
2794 if (r_ptr->flags7 & (RF7_FRIENDLY | RF7_CHAMELEON)) return FALSE;
2796 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))
2799 if (!monster_can_cross_terrain(cave[m_ptr->fy][m_ptr->fx].feat, r_ptr)) return FALSE;
2802 if (!(old_r_ptr->flags7 & RF7_CHAMELEON))
2804 if ((old_r_ptr->flags3 & RF3_GOOD) && !(r_ptr->flags3 & RF3_GOOD)) return FALSE;
2805 if ((old_r_ptr->flags3 & RF3_EVIL) && !(r_ptr->flags3 & RF3_EVIL)) return FALSE;
2806 if (!(old_r_ptr->flags3 & (RF3_GOOD | RF3_EVIL)) && (r_ptr->flags3 & (RF3_GOOD | RF3_EVIL))) return FALSE;
2810 else if (summon_specific_who > 0)
2812 monster_type *sm_ptr = &m_list[summon_specific_who];
2814 if ((sm_ptr->sub_align & SUB_ALIGN_EVIL) && (r_ptr->flags3 & RF3_GOOD)) return FALSE;
2815 if ((sm_ptr->sub_align & SUB_ALIGN_GOOD) && (r_ptr->flags3 & RF3_EVIL)) return FALSE;
2818 return (*(get_monster_hook()))(r_idx);
2822 void choose_new_monster(int m_idx, bool born, int r_idx)
2825 monster_type *m_ptr = &m_list[m_idx];
2826 monster_race *r_ptr;
2827 char old_m_name[80];
2828 bool old_unique = FALSE;
2830 if (r_info[m_ptr->r_idx].flags1 & RF1_UNIQUE)
2832 if (old_unique && (r_idx == MON_CHAMELEON)) r_idx = MON_CHAMELEON_K;
2833 r_ptr = &r_info[r_idx];
2835 monster_desc(old_m_name, m_ptr, 0);
2841 chameleon_change_m_idx = m_idx;
2843 get_mon_num_prep(monster_hook_chameleon_lord, NULL);
2845 get_mon_num_prep(monster_hook_chameleon, NULL);
2848 level = r_info[MON_CHAMELEON_K].level;
2849 else if (!dun_level)
2850 level = wilderness[p_ptr->wilderness_y][p_ptr->wilderness_x].level;
2854 if (d_info[dungeon_type].flags1 & DF1_CHAMELEON) level+= 2+randint1(3);
2856 r_idx = get_mon_num(level);
2857 r_ptr = &r_info[r_idx];
2859 chameleon_change_m_idx = 0;
2865 m_ptr->r_idx = r_idx;
2866 m_ptr->ap_r_idx = r_idx;
2867 update_mon(m_idx, FALSE);
2868 lite_spot(m_ptr->fy, m_ptr->fx);
2871 /* Sub-alignment of a chameleon */
2872 if (r_ptr->flags3 & (RF3_EVIL | RF3_GOOD))
2874 m_ptr->sub_align = SUB_ALIGN_NEUTRAL;
2875 if (r_ptr->flags3 & RF3_EVIL) m_ptr->sub_align |= SUB_ALIGN_EVIL;
2876 if (r_ptr->flags3 & RF3_GOOD) m_ptr->sub_align |= SUB_ALIGN_GOOD;
2881 if (m_idx == p_ptr->riding)
2884 monster_desc(m_name, m_ptr, 0);
2886 msg_format("ÆÍÁ³%s¤¬ÊѿȤ·¤¿¡£", old_m_name);
2888 msg_format("Suddenly, %s transforms!", old_m_name);
2890 if (!(r_ptr->flags7 & RF7_RIDING))
2892 if (rakuba(0, TRUE)) msg_print("ÃÏÌ̤ËÍî¤È¤µ¤ì¤¿¡£");
2894 if (rakuba(0, TRUE)) msg_format("You have fallen from %s.", m_name);
2898 /* Extract the monster base speed */
2899 m_ptr->mspeed = get_mspeed(r_ptr);
2901 oldmaxhp = m_ptr->max_maxhp;
2902 /* Assign maximal hitpoints */
2903 if (r_ptr->flags1 & RF1_FORCE_MAXHP)
2905 m_ptr->max_maxhp = maxroll(r_ptr->hdice, r_ptr->hside);
2909 m_ptr->max_maxhp = damroll(r_ptr->hdice, r_ptr->hside);
2911 m_ptr->maxhp = (long)(m_ptr->maxhp * m_ptr->max_maxhp) / oldmaxhp;
2912 m_ptr->hp = (long)(m_ptr->hp * m_ptr->max_maxhp) / oldmaxhp;
2919 static bool monster_hook_tanuki(int r_idx)
2921 monster_race *r_ptr = &r_info[r_idx];
2923 if (r_ptr->flags1 & (RF1_UNIQUE)) return FALSE;
2924 if (r_ptr->flags2 & RF2_MULTIPLY) return FALSE;
2925 if (r_ptr->flags7 & (RF7_FRIENDLY | RF7_CHAMELEON)) return FALSE;
2926 if (r_ptr->flags7 & RF7_AQUATIC) return FALSE;
2928 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))
2931 return (*(get_monster_hook()))(r_idx);
2936 * Set initial racial appearance of a monster
2938 static int initial_r_appearance(int r_idx)
2940 int attempts = 1000;
2943 int min = MIN(base_level-5, 50);
2945 if (!(r_info[r_idx].flags7 & RF7_TANUKI))
2948 get_mon_num_prep(monster_hook_tanuki, NULL);
2952 ap_r_idx = get_mon_num(base_level + 10);
2953 if (r_info[ap_r_idx].level >= min) return ap_r_idx;
2961 * Get initial monster speed
2963 byte get_mspeed(monster_race *r_ptr)
2965 /* Extract the monster base speed */
2966 int mspeed = r_ptr->speed;
2968 /* Hack -- small racial variety */
2969 if (!(r_ptr->flags1 & RF1_UNIQUE) && !p_ptr->inside_arena)
2971 /* Allow some small variation per monster */
2972 int i = SPEED_TO_ENERGY(r_ptr->speed) / (one_in_(4) ? 3 : 10);
2973 if (i) mspeed += rand_spread(0, i);
2976 if (mspeed > 199) mspeed = 199;
2978 return (byte)mspeed;
2983 * Attempt to place a monster of the given race at the given location.
2985 * To give the player a sporting chance, any monster that appears in
2986 * line-of-sight and is extremely dangerous can be marked as
2987 * "FORCE_SLEEP", which will cause them to be placed with low energy,
2988 * which often (but not always) lets the player move before they do.
2990 * This routine refuses to place out-of-depth "FORCE_DEPTH" monsters.
2992 * XXX XXX XXX Use special "here" and "dead" flags for unique monsters,
2993 * remove old "cur_num" and "max_num" fields.
2995 * XXX XXX XXX Actually, do something similar for artifacts, to simplify
2996 * the "preserve" mode, and to make the "what artifacts" flag more useful.
2998 * This is the only function which may place a monster in the dungeon,
2999 * except for the savefile loading code.
3001 bool place_monster_one(int who, int y, int x, int r_idx, u32b mode)
3005 monster_type *m_ptr;
3007 monster_race *r_ptr = &r_info[r_idx];
3009 cptr name = (r_name + r_ptr->name);
3011 /* DO NOT PLACE A MONSTER IN THE SMALL SCALE WILDERNESS !!! */
3012 if(p_ptr->wild_mode) return FALSE;
3014 /* Verify location */
3015 if (!in_bounds(y, x)) return (FALSE);
3017 /* Require empty space (if not ghostly) */
3018 if (!(!dun_level && (cave[y][x].feat == FEAT_MOUNTAIN) && ((r_ptr->flags8 & RF8_WILD_MOUNTAIN) || (r_ptr->flags7 & RF7_CAN_FLY))) &&
3019 !(cave_empty_bold2(y, x) || (mode & PM_IGNORE_TERRAIN)) &&
3020 !((r_ptr->flags2 & RF2_PASS_WALL) &&
3021 !(cave_perma_bold(y, x) || cave[y][x].m_idx ||
3022 ((y == py) && (x == px))))) return (FALSE);
3025 if (!r_idx) return (FALSE);
3028 if (!r_ptr->name) return (FALSE);
3030 /* Nor on the Pattern */
3031 if ((cave[y][x].feat >= FEAT_PATTERN_START)
3032 && (cave[y][x].feat <= FEAT_PATTERN_XTRA2))
3035 if (!(mode & PM_IGNORE_TERRAIN) &&
3036 !monster_can_cross_terrain(cave[y][x].feat, r_ptr))
3041 if (!p_ptr->inside_battle)
3043 /* Hack -- "unique" monsters must be "unique" */
3044 if (((r_ptr->flags1 & (RF1_UNIQUE)) ||
3045 (r_ptr->flags7 & (RF7_UNIQUE_7))) &&
3046 (r_ptr->cur_num >= r_ptr->max_num))
3052 if ((r_ptr->flags7 & (RF7_UNIQUE2)) &&
3053 (r_ptr->cur_num >= 1))
3058 if (r_idx == MON_BANORLUPART)
3060 if (r_info[MON_BANOR].cur_num > 0) return FALSE;
3061 if (r_info[MON_LUPART].cur_num > 0) return FALSE;
3064 /* Depth monsters may NOT be created out of depth, unless in Nightmare mode */
3065 if ((r_ptr->flags1 & (RF1_FORCE_DEPTH)) && (dun_level < r_ptr->level) &&
3066 (!ironman_nightmare || (r_ptr->flags1 & (RF1_QUESTOR))))
3073 if(quest_number(dun_level))
3075 int hoge = quest_number(dun_level);
3076 if((quest[hoge].type == QUEST_TYPE_KILL_LEVEL) || (quest[hoge].type == QUEST_TYPE_RANDOM))
3078 if(r_idx == quest[hoge].r_idx)
3080 int number_mon, i2, j2;
3083 /* Count all quest monsters */
3084 for (i2 = 0; i2 < cur_wid; ++i2)
3085 for (j2 = 0; j2 < cur_hgt; j2++)
3086 if (cave[j2][i2].m_idx > 0)
3087 if (m_list[cave[j2][i2].m_idx].r_idx == quest[hoge].r_idx)
3089 if(number_mon + quest[hoge].cur_num >= quest[hoge].max_num)
3095 /* Access the location */
3096 c_ptr = &cave[y][x];
3098 if (is_glyph_grid(c_ptr))
3100 if (randint1(BREAK_GLYPH) < (r_ptr->level+20))
3102 /* Describe observable breakage */
3103 if (c_ptr->info & CAVE_MARK)
3106 msg_print("¼é¤ê¤Î¥ë¡¼¥ó¤¬²õ¤ì¤¿¡ª");
3108 msg_print("The rune of protection is broken!");
3113 /* Forget the rune */
3114 c_ptr->info &= ~(CAVE_MARK);
3116 /* Break the rune */
3117 c_ptr->info &= ~(CAVE_OBJECT);
3126 /* Powerful monster */
3127 if (r_ptr->level > dun_level)
3129 /* Unique monsters */
3130 if (r_ptr->flags1 & (RF1_UNIQUE))
3132 /* Message for cheaters */
3134 if (cheat_hear) msg_format("¿¼ÁؤΥæ¥Ë¡¼¥¯¡¦¥â¥ó¥¹¥¿¡¼ (%s)¡£", name);
3136 if (cheat_hear) msg_format("Deep Unique (%s).", name);
3140 /* Boost rating by twice delta-depth */
3141 rating += (r_ptr->level - dun_level) * 2;
3144 /* Normal monsters */
3147 /* Message for cheaters */
3149 if (cheat_hear) msg_format("¿¼ÁؤΥâ¥ó¥¹¥¿¡¼ (%s)¡£", name);
3151 if (cheat_hear) msg_format("Deep Monster (%s).", name);
3155 /* Boost rating by delta-depth */
3156 rating += (r_ptr->level - dun_level);
3160 /* Note the monster */
3161 else if (r_ptr->flags1 & (RF1_UNIQUE))
3163 /* Unique monsters induce message */
3165 if (cheat_hear) msg_format("¥æ¥Ë¡¼¥¯¡¦¥â¥ó¥¹¥¿¡¼ (%s)¡£", name);
3167 if (cheat_hear) msg_format("Unique (%s).", name);
3172 if ((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags7 & RF7_UNIQUE_7) || (r_ptr->level < 10)) is_kage = FALSE;
3174 /* Make a new monster */
3175 c_ptr->m_idx = m_pop();
3176 hack_m_idx_ii = c_ptr->m_idx;
3178 /* Mega-Hack -- catch "failure" */
3179 if (!c_ptr->m_idx) return (FALSE);
3182 /* Get a new monster record */
3183 m_ptr = &m_list[c_ptr->m_idx];
3186 m_ptr->r_idx = r_idx;
3187 m_ptr->ap_r_idx = initial_r_appearance(r_idx);
3189 /* Sub-alignment of a monster */
3190 if ((who > 0) && !(r_ptr->flags3 & (RF3_EVIL | RF3_GOOD)))
3191 m_ptr->sub_align = m_list[who].sub_align;
3194 m_ptr->sub_align = SUB_ALIGN_NEUTRAL;
3195 if (r_ptr->flags3 & RF3_EVIL) m_ptr->sub_align |= SUB_ALIGN_EVIL;
3196 if (r_ptr->flags3 & RF3_GOOD) m_ptr->sub_align |= SUB_ALIGN_GOOD;
3199 /* Place the monster at the location */
3204 /* No "damage" yet */
3206 m_ptr->confused = 0;
3209 /* Unknown distance */
3212 reset_target(m_ptr);
3214 m_ptr->nickname = 0;
3222 if (r_ptr->flags7 & RF7_CHAMELEON)
3224 choose_new_monster(c_ptr->m_idx, TRUE, 0);
3225 r_ptr = &r_info[m_ptr->r_idx];
3226 m_ptr->mflag2 |= MFLAG2_CHAMELEON;
3229 /* Hack - Set sub_align to neutral when the Chameleon Lord is generated as "GUARDIAN" */
3230 if ((r_ptr->flags1 & RF1_UNIQUE) && (who <= 0))
3231 m_ptr->sub_align = SUB_ALIGN_NEUTRAL;
3235 m_ptr->ap_r_idx = MON_KAGE;
3236 m_ptr->mflag2 |= MFLAG2_KAGE;
3239 if (mode & PM_NO_PET) m_ptr->mflag2 |= MFLAG2_NOPET;
3245 if (mode & PM_FORCE_PET)
3250 else if ((r_ptr->flags7 & RF7_FRIENDLY) ||
3251 (mode & PM_FORCE_FRIENDLY) || is_friendly_idx(who))
3253 if (!(p_ptr->align >= 0 && (r_ptr->flags3 & RF3_EVIL)) &&
3254 !(p_ptr->align < 0 && (r_ptr->flags3 & RF3_GOOD)))
3256 set_friendly(m_ptr);
3260 /* Assume no sleeping */
3263 /* Enforce sleeping if needed */
3264 if ((mode & PM_ALLOW_SLEEP) && r_ptr->sleep && !ironman_nightmare)
3266 int val = r_ptr->sleep;
3267 m_ptr->csleep = ((val * 2) + randint1(val * 10));
3270 /* Assign maximal hitpoints */
3271 if (r_ptr->flags1 & RF1_FORCE_MAXHP)
3273 m_ptr->max_maxhp = maxroll(r_ptr->hdice, r_ptr->hside);
3277 m_ptr->max_maxhp = damroll(r_ptr->hdice, r_ptr->hside);
3280 /* Monsters have double hitpoints in Nightmare mode */
3281 if (ironman_nightmare)
3283 u32b hp = m_ptr->max_maxhp * 2L;
3285 m_ptr->max_maxhp = (s16b)MIN(30000, hp);
3288 m_ptr->maxhp = m_ptr->max_maxhp;
3290 /* And start out fully healthy */
3291 if (m_ptr->r_idx == MON_WOUNDED_BEAR)
3292 m_ptr->hp = m_ptr->maxhp / 2;
3293 else m_ptr->hp = m_ptr->maxhp;
3296 /* Extract the monster base speed */
3297 m_ptr->mspeed = get_mspeed(r_ptr);
3299 if (mode & PM_HASTE) m_ptr->fast = 100;
3301 /* Give a random starting energy */
3302 if (!ironman_nightmare)
3304 m_ptr->energy_need = ENERGY_NEED() - (s16b)randint0(100);
3308 /* Nightmare monsters are more prepared */
3309 m_ptr->energy_need = ENERGY_NEED() - (s16b)randint0(100) * 2;
3312 /* Force monster to wait for player, unless in Nightmare mode */
3313 if ((r_ptr->flags1 & RF1_FORCE_SLEEP) && !ironman_nightmare)
3315 /* Monster is still being nice */
3316 m_ptr->mflag |= (MFLAG_NICE);
3318 /* Must repair monsters */
3319 repair_monsters = TRUE;
3322 /* Hack -- see "process_monsters()" */
3323 if (c_ptr->m_idx < hack_m_idx)
3325 /* Monster is still being born */
3326 m_ptr->mflag |= (MFLAG_BORN);
3330 if (r_ptr->flags7 & (RF7_SELF_LITE_1 | RF7_SELF_LITE_2))
3331 p_ptr->update |= (PU_MON_LITE);
3332 else if ((r_ptr->flags7 & (RF7_HAS_LITE_1 | RF7_HAS_LITE_2)) && !m_ptr->csleep)
3333 p_ptr->update |= (PU_MON_LITE);
3335 /* Update the monster */
3336 update_mon(c_ptr->m_idx, TRUE);
3339 /* Count the monsters on the level */
3340 real_r_ptr(m_ptr)->cur_num++;
3343 * Memorize location of the unique monster in saved floors.
3344 * A unique monster move from old saved floor.
3346 if (character_dungeon &&
3347 ((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags7 & RF7_UNIQUE_7)))
3348 real_r_ptr(m_ptr)->floor_id = p_ptr->floor_id;
3350 /* Hack -- Count the number of "reproducers" */
3351 if (r_ptr->flags2 & RF2_MULTIPLY) num_repro++;
3354 /* Hack -- Notice new multi-hued monsters */
3356 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
3357 if (ap_r_ptr->flags1 & (RF1_ATTR_MULTI | RF1_SHAPECHANGER))
3358 shimmer_monsters = TRUE;
3361 if (p_ptr->warning && character_dungeon)
3363 if (r_ptr->flags1 & RF1_UNIQUE)
3367 char o_name[MAX_NLEN];
3369 if (r_ptr->level > p_ptr->lev + 30)
3375 else if (r_ptr->level > p_ptr->lev + 15)
3381 else if (r_ptr->level > p_ptr->lev + 5)
3383 color = "¥ë¥Ó¡¼¿§¤Ë";
3387 else if (r_ptr->level > p_ptr->lev - 5)
3393 else if (r_ptr->level > p_ptr->lev - 15)
3395 color = "¥Ô¥ó¥¯¿§¤Ë";
3406 o_ptr = choose_warning_item();
3407 object_desc(o_name, o_ptr, FALSE, 0);
3409 msg_format("%s¤Ï%s¸÷¤Ã¤¿¡£",o_name, color);
3411 msg_format("%s glows %s.",o_name, color);
3416 if (is_explosive_rune_grid(c_ptr))
3418 /* Break the ward */
3419 if (randint1(BREAK_MINOR_GLYPH) > r_ptr->level)
3421 /* Describe observable breakage */
3422 if (c_ptr->info & CAVE_MARK)
3425 msg_print("¥ë¡¼¥ó¤¬Çúȯ¤·¤¿¡ª");
3427 msg_print("The rune explodes!");
3430 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);
3436 msg_print("Çúȯ¤Î¥ë¡¼¥ó¤Ï²ò½ü¤µ¤ì¤¿¡£");
3438 msg_print("An explosive rune was disarmed.");
3442 /* Forget the rune */
3443 c_ptr->info &= ~(CAVE_MARK);
3445 /* Break the rune */
3446 c_ptr->info &= ~(CAVE_OBJECT);
3459 * improved version of scatter() for place monster
3462 #define MON_SCAT_MAXD 10
3464 static bool mon_scatter(int *yp, int *xp, int y, int x, int max_dist)
3466 int place_x[MON_SCAT_MAXD];
3467 int place_y[MON_SCAT_MAXD];
3468 int num[MON_SCAT_MAXD];
3472 if (max_dist >= MON_SCAT_MAXD)
3475 for (i = 0; i < MON_SCAT_MAXD; i++)
3478 for (nx = x - max_dist; nx <= x + max_dist; nx++)
3479 for (ny = y - max_dist; ny <= y + max_dist; ny++)
3481 /* Ignore annoying locations */
3482 if (!in_bounds(ny, nx)) continue;
3484 /* Require "line of sight" */
3485 if (!los(y, x, ny, nx)) continue;
3487 /* Walls and Monsters block flow */
3488 if (!cave_empty_bold2(ny, nx)) continue;
3489 if (cave[ny][nx].m_idx) continue;
3490 if ((ny == py) && (nx == px)) continue;
3492 /* ... nor on the Pattern */
3493 if ((cave[ny][nx].feat >= FEAT_PATTERN_START) &&
3494 (cave[ny][nx].feat <= FEAT_PATTERN_XTRA2))
3497 i = distance(y, x, ny, nx);
3514 while (i < MON_SCAT_MAXD && 0 == num[i])
3516 if (i >= MON_SCAT_MAXD)
3527 * Maximum size of a group of monsters
3529 #define GROUP_MAX 32
3533 * Attempt to place a "group" of monsters around the given location
3535 static bool place_monster_group(int who, int y, int x, int r_idx, u32b mode)
3537 monster_race *r_ptr = &r_info[r_idx];
3540 int total = 0, extra = 0;
3544 byte hack_y[GROUP_MAX];
3545 byte hack_x[GROUP_MAX];
3548 /* Pick a group size */
3549 total = randint1(10);
3551 /* Hard monsters, small groups */
3552 if (r_ptr->level > dun_level)
3554 extra = r_ptr->level - dun_level;
3555 extra = 0 - randint1(extra);
3558 /* Easy monsters, large groups */
3559 else if (r_ptr->level < dun_level)
3561 extra = dun_level - r_ptr->level;
3562 extra = randint1(extra);
3565 /* Hack -- limit group reduction */
3566 if (extra > 9) extra = 9;
3568 /* Modify the group size */
3572 if (total < 1) total = 1;
3575 if (total > GROUP_MAX) total = GROUP_MAX;
3578 /* Save the rating */
3581 /* Start on the monster */
3586 /* Puddle monsters, breadth first, up to total */
3587 for (n = 0; (n < hack_n) && (hack_n < total); n++)
3589 /* Grab the location */
3593 /* Check each direction, up to total */
3594 for (i = 0; (i < 8) && (hack_n < total); i++)
3598 scatter(&my, &mx, hy, hx, 4, 0);
3600 /* Walls and Monsters block flow */
3601 if (!cave_empty_bold2(my, mx)) continue;
3603 /* Attempt to place another monster */
3604 if (place_monster_one(who, my, mx, r_idx, mode))
3606 /* Add it to the "hack" set */
3607 hack_y[hack_n] = my;
3608 hack_x[hack_n] = mx;
3614 /* Hack -- restore the rating */
3624 * Hack -- help pick an escort type
3626 static int place_monster_idx = 0;
3627 static int place_monster_m_idx = 0;
3630 * Hack -- help pick an escort type
3632 static bool place_monster_okay(int r_idx)
3634 monster_race *r_ptr = &r_info[place_monster_idx];
3635 monster_type *m_ptr = &m_list[place_monster_m_idx];
3637 monster_race *z_ptr = &r_info[r_idx];
3639 /* Hack - Escorts have to have the same dungeon flag */
3640 if (monster_dungeon(place_monster_idx) != monster_dungeon(r_idx)) return (FALSE);
3642 /* Require similar "race" */
3643 if (z_ptr->d_char != r_ptr->d_char) return (FALSE);
3645 /* Skip more advanced monsters */
3646 if (z_ptr->level > r_ptr->level) return (FALSE);
3648 /* Skip unique monsters */
3649 if (z_ptr->flags1 & RF1_UNIQUE) return (FALSE);
3651 /* Paranoia -- Skip identical monsters */
3652 if (place_monster_idx == r_idx) return (FALSE);
3654 /* Skip different alignment */
3655 if (((m_ptr->sub_align & SUB_ALIGN_EVIL) && (z_ptr->flags3 & RF3_GOOD)) ||
3656 ((m_ptr->sub_align & SUB_ALIGN_GOOD) && (z_ptr->flags3 & RF3_EVIL)))
3659 if (r_ptr->flags7 & RF7_FRIENDLY)
3661 if (((p_ptr->align < 0) && (z_ptr->flags3 & RF3_GOOD)) ||
3662 ((p_ptr->align > 0) && (z_ptr->flags3 & RF3_EVIL)))
3666 if ((r_ptr->flags7 & RF7_CHAMELEON) && !(z_ptr->flags7 & RF7_CHAMELEON))
3675 * Attempt to place a monster of the given race at the given location
3677 * Note that certain monsters are now marked as requiring "friends".
3678 * These monsters, if successfully placed, and if the "grp" parameter
3679 * is TRUE, will be surrounded by a "group" of identical monsters.
3681 * Note that certain monsters are now marked as requiring an "escort",
3682 * which is a collection of monsters with similar "race" but lower level.
3684 * Some monsters induce a fake "group" flag on their escorts.
3686 * Note the "bizarre" use of non-recursion to prevent annoying output
3687 * when running a code profiler.
3689 * Note the use of the new "monster allocation table" code to restrict
3690 * the "get_mon_num()" function to "legal" escort types.
3692 bool place_monster_aux(int who, int y, int x, int r_idx, u32b mode)
3695 monster_race *r_ptr = &r_info[r_idx];
3697 if (one_in_(333) && !(mode & PM_NO_KAGE) && !(mode & PM_FORCE_PET))
3702 /* Place one monster, or fail */
3703 if (!place_monster_one(who, y, x, r_idx, mode)) return (FALSE);
3706 /* Require the "group" flag */
3707 if (!(mode & PM_ALLOW_GROUP)) return (TRUE);
3709 place_monster_m_idx = hack_m_idx_ii;
3711 /* Friends for certain monsters */
3712 if (r_ptr->flags1 & (RF1_FRIENDS))
3714 /* Attempt to place a group */
3715 (void)place_monster_group(who, y, x, r_idx, mode);
3719 /* Escorts for certain monsters */
3720 if (r_ptr->flags1 & (RF1_ESCORT))
3722 /* Set the escort index */
3723 place_monster_idx = r_idx;
3725 /* Try to place several "escorts" */
3726 for (i = 0; i < 32; i++)
3728 int nx, ny, z, d = 3;
3730 /* Pick a location */
3731 scatter(&ny, &nx, y, x, d, 0);
3733 /* Require empty grids */
3734 if (!cave_empty_bold2(ny, nx)) continue;
3736 /* Prepare allocation table */
3737 get_mon_num_prep(place_monster_okay, get_monster_hook2(ny, nx));
3739 /* Pick a random race */
3740 z = get_mon_num(r_ptr->level);
3742 /* Handle failure */
3745 /* Place a single escort */
3746 (void)place_monster_one(place_monster_m_idx, ny, nx, z, mode);
3748 /* Place a "group" of escorts if needed */
3749 if ((r_info[z].flags1 & RF1_FRIENDS) ||
3750 (r_ptr->flags1 & RF1_ESCORTS))
3752 /* Place a group of monsters */
3753 (void)place_monster_group(place_monster_m_idx, ny, nx, z, mode);
3764 * Hack -- attempt to place a monster at the given location
3766 * Attempt to find a monster appropriate to the "monster_level"
3768 bool place_monster(int y, int x, u32b mode)
3772 /* Prepare allocation table */
3773 get_mon_num_prep(get_monster_hook(), get_monster_hook2(y, x));
3775 /* Pick a monster */
3776 r_idx = get_mon_num(monster_level);
3778 /* Handle failure */
3779 if (!r_idx) return (FALSE);
3781 /* Attempt to place the monster */
3782 if (place_monster_aux(0, y, x, r_idx, mode)) return (TRUE);
3789 #ifdef MONSTER_HORDES
3791 bool alloc_horde(int y, int x)
3793 monster_race *r_ptr = NULL;
3796 int attempts = 1000;
3800 /* Prepare allocation table */
3801 get_mon_num_prep(get_monster_hook(), get_monster_hook2(y, x));
3805 /* Pick a monster */
3806 r_idx = get_mon_num(monster_level);
3808 /* Handle failure */
3809 if (!r_idx) return (FALSE);
3811 r_ptr = &r_info[r_idx];
3813 if (r_ptr->flags1 & RF1_UNIQUE) continue;
3815 if (r_idx == MON_HAGURE) continue;
3818 if (attempts < 1) return FALSE;
3824 /* Attempt to place the monster */
3825 if (place_monster_aux(0, y, x, r_idx, 0L)) break;
3828 if (attempts < 1) return FALSE;
3830 m_idx = cave[y][x].m_idx;
3832 if (m_list[m_idx].mflag2 & MFLAG2_CHAMELEON) r_ptr = &r_info[m_list[m_idx].r_idx];
3833 summon_kin_type = r_ptr->d_char;
3835 for (attempts = randint1(10) + 5; attempts; attempts--)
3837 scatter(&cy, &cx, y, x, 5, 0);
3839 (void)summon_specific(m_idx, cy, cx, dun_level + 5, SUMMON_KIN, PM_ALLOW_GROUP);
3848 #endif /* MONSTER_HORDES */
3853 * Attempt to allocate a random monster in the dungeon.
3855 * Place the monster at least "dis" distance from the player.
3857 * Use "slp" to choose the initial "sleep" status
3859 * Use "monster_level" for the monster level
3861 bool alloc_monster(int dis, u32b mode)
3864 int attempts_left = 10000;
3865 int guardian = d_info[dungeon_type].final_guardian;
3867 /* Put an Guardian */
3868 if(guardian && d_info[dungeon_type].maxdepth == dun_level && r_info[guardian].cur_num < r_info[guardian].max_num )
3874 /* Find a good position */
3877 /* Get a random spot */
3878 oy = randint1(cur_hgt - 4) + 2;
3879 ox = randint1(cur_wid - 4) + 2;
3881 /* Is it a good spot ? */
3882 if (cave_empty_bold2(oy, ox) && monster_can_cross_terrain(cave[oy][ox].feat, &r_info[guardian]))
3884 /* Place the guardian */
3885 if (place_monster_aux(0, oy, ox, guardian, (PM_ALLOW_GROUP | PM_NO_KAGE | PM_NO_PET))) break;
3893 /* Find a legal, distant, unoccupied, space */
3894 while (attempts_left--)
3896 /* Pick a location */
3897 y = randint0(cur_hgt);
3898 x = randint0(cur_wid);
3900 /* Require empty floor grid (was "naked") */
3901 if (dun_level || (wilderness[p_ptr->wilderness_y][p_ptr->wilderness_x].terrain != TERRAIN_MOUNTAIN))
3903 if (!cave_empty_bold2(y, x)) continue;
3907 if (!cave_empty_bold2(y, x) && (cave[y][x].feat != FEAT_MOUNTAIN)) continue;
3910 /* Accept far away grids */
3911 if (distance(y, x, py, px) > dis) break;
3916 if (cheat_xtra || cheat_hear)
3919 msg_print("·Ù¹ð¡ª¿·¤¿¤Ê¥â¥ó¥¹¥¿¡¼¤òÇÛÃ֤Ǥ¤Þ¤»¤ó¡£¾®¤µ¤¤³¬¤Ç¤¹¤«¡©");
3921 msg_print("Warning! Could not allocate a new monster. Small level?");
3930 #ifdef MONSTER_HORDES
3931 if (randint1(5000) <= dun_level)
3933 if (alloc_horde(y, x))
3936 if (cheat_hear) msg_format("¥â¥ó¥¹¥¿¡¼¤ÎÂç·²(%c)", summon_kin_type);
3938 if (cheat_hear) msg_format("Monster horde (%c).", summon_kin_type);
3946 #endif /* MONSTER_HORDES */
3948 /* Attempt to place the monster, allow groups */
3949 if (place_monster(y, x, (mode | PM_ALLOW_GROUP))) return (TRUE);
3951 #ifdef MONSTER_HORDES
3953 #endif /* MONSTER_HORDES */
3963 * Hack -- help decide if a monster race is "okay" to summon
3965 static bool summon_specific_okay(int r_idx)
3967 monster_race *r_ptr = &r_info[r_idx];
3969 /* Hack - Only summon dungeon monsters */
3970 if (!monster_dungeon(r_idx)) return (FALSE);
3972 /* Hack -- identify the summoning monster */
3973 if (summon_specific_who > 0)
3975 monster_type *m_ptr = &m_list[summon_specific_who];
3977 /* Do not summon enemies */
3979 /* Friendly vs. opposite aligned normal or pet */
3980 if (((r_ptr->flags3 & RF3_EVIL) &&
3981 (m_ptr->sub_align & SUB_ALIGN_GOOD)) ||
3982 ((r_ptr->flags3 & RF3_GOOD) &&
3983 (m_ptr->sub_align & SUB_ALIGN_EVIL)))
3988 /* Hostile vs. non-hostile */
3989 if (is_hostile(m_ptr) != summon_specific_hostile)
3994 /* Use the player's alignment */
3995 else if (summon_specific_who < 0)
3997 /* Do not summon enemies of the pets */
3998 if ((p_ptr->align < -9) && (r_ptr->flags3 & RF3_GOOD))
4000 if (!one_in_((0-p_ptr->align)/2+1)) return FALSE;
4002 else if ((p_ptr->align > 9) && (r_ptr->flags3 & RF3_EVIL))
4004 if (!one_in_(p_ptr->align/2+1)) return FALSE;
4008 /* Hack -- no specific type specified */
4009 if (!summon_specific_type) return (TRUE);
4011 if (!summon_unique_okay && ((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags7 & RF7_UNIQUE_7))) return FALSE;
4013 if ((summon_specific_who < 0) &&
4014 ((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags7 & RF7_UNIQUE_7)) &&
4015 (((p_ptr->align > 9) && (r_ptr->flags3 & RF3_EVIL)) ||
4016 ((p_ptr->align < -9) && (r_ptr->flags3 & RF3_GOOD))))
4019 if ((r_ptr->flags7 & RF7_CHAMELEON) && (d_info[dungeon_type].flags1 & DF1_CHAMELEON)) return TRUE;
4021 return (summon_specific_aux(r_idx));
4026 * Place a monster (of the specified "type") near the given
4027 * location. Return TRUE if a monster was actually summoned.
4029 * We will attempt to place the monster up to 10 times before giving up.
4031 * Note: SUMMON_UNIQUE and SUMMON_AMBERITES will summon Unique's
4032 * Note: SUMMON_HI_UNDEAD and SUMMON_HI_DRAGON may summon Unique's
4033 * Note: None of the other summon codes will ever summon Unique's.
4035 * This function has been changed. We now take the "monster level"
4036 * of the summoning monster as a parameter, and use that, along with
4037 * the current dungeon level, to help determine the level of the
4038 * desired monster. Note that this is an upper bound, and also
4039 * tends to "prefer" monsters of that level. Currently, we use
4040 * the average of the dungeon and monster levels, and then add
4041 * five to allow slight increases in monster power.
4043 * Note that we use the new "monster allocation table" creation code
4044 * to restrict the "get_mon_num()" function to the set of "legal"
4045 * monsters, making this function much faster and more reliable.
4047 * Note that this function may not succeed, though this is very rare.
4049 bool summon_specific(int who, int y1, int x1, int lev, int type, u32b mode)
4053 if (p_ptr->inside_arena) return (FALSE);
4055 if (!mon_scatter(&y, &x, y1, x1, 2)) return FALSE;
4057 /* Save the summoner */
4058 summon_specific_who = who;
4060 /* Save the "summon" type */
4061 summon_specific_type = type;
4063 summon_unique_okay = (mode & PM_ALLOW_UNIQUE) ? TRUE : FALSE;
4065 /* Save the hostility */
4066 summon_specific_hostile = (!(mode & PM_FORCE_FRIENDLY) && !(is_friendly_idx(who)) && !(mode & PM_FORCE_PET));
4068 /* Prepare allocation table */
4069 get_mon_num_prep(summon_specific_okay, get_monster_hook2(y, x));
4071 /* Pick a monster, using the level calculation */
4072 r_idx = get_mon_num((dun_level + lev) / 2 + 5);
4074 /* Handle failure */
4077 summon_specific_type = 0;
4081 if ((type == SUMMON_BLUE_HORROR) || (type == SUMMON_DAWN)) mode |= PM_NO_KAGE;
4083 /* Attempt to place the monster (awake, allow groups) */
4084 if (!place_monster_aux(who, y, x, r_idx, mode))
4086 summon_specific_type = 0;
4090 summon_specific_type = 0;
4095 /* A "dangerous" function, creates a pet of the specified type */
4096 bool summon_named_creature (int who, int oy, int ox, int r_idx, u32b mode)
4101 /* if (!r_idx) return; */
4103 /* Prevent illegal monsters */
4104 if (r_idx >= max_r_idx) return FALSE;
4106 if (p_ptr->inside_arena) return FALSE;
4108 if (!mon_scatter(&y, &x, oy, ox, 2)) return FALSE;
4110 /* Place it (allow groups) */
4111 return place_monster_aux(who, y, x, r_idx, (mode | PM_NO_KAGE));
4116 * Let the given monster attempt to reproduce.
4118 * Note that "reproduction" REQUIRES empty space.
4120 bool multiply_monster(int m_idx, bool clone, u32b mode)
4122 monster_type *m_ptr = &m_list[m_idx];
4126 if (!mon_scatter(&y, &x, m_ptr->fy, m_ptr->fx, 1))
4129 if (m_ptr->mflag2 & MFLAG2_NOPET) mode |= PM_NO_PET;
4131 /* Create a new monster (awake, no groups) */
4132 if (!place_monster_aux(m_idx, y, x, m_ptr->r_idx, (mode | PM_NO_KAGE)))
4137 m_list[hack_m_idx_ii].smart |= SM_CLONED;
4138 m_list[hack_m_idx_ii].mflag2 |= MFLAG2_NOPET;
4149 * Dump a message describing a monster's reaction to damage
4151 * Technically should attempt to treat "Beholder"'s as jelly's
4153 void message_pain(int m_idx, int dam)
4155 long oldhp, newhp, tmp;
4158 monster_type *m_ptr = &m_list[m_idx];
4159 monster_race *r_ptr = &r_info[m_ptr->r_idx];
4164 /* Get the monster name */
4165 monster_desc(m_name, m_ptr, 0);
4167 /* Notice non-damage */
4171 msg_format("%^s¤Ï¥À¥á¡¼¥¸¤ò¼õ¤±¤Æ¤¤¤Ê¤¤¡£", m_name);
4173 msg_format("%^s is unharmed.", m_name);
4179 /* Note -- subtle fix -CFT */
4180 newhp = (long)(m_ptr->hp);
4181 oldhp = newhp + (long)(dam);
4182 tmp = (newhp * 100L) / oldhp;
4183 percentage = (int)(tmp);
4186 /* Mushrooms, Eyes, Jellies, Molds, Vortices, Worms, Quylthulgs */
4187 if (strchr(",ejmvwQ", r_ptr->d_char))
4190 if (percentage > 95)
4191 msg_format("%^s¤Ï¤Û¤È¤ó¤Éµ¤¤Ë¤È¤á¤Æ¤¤¤Ê¤¤¡£", m_name);
4192 else if (percentage > 75)
4193 msg_format("%^s¤Ï¤·¤ê¹þ¤ß¤·¤¿¡£", m_name);
4194 else if (percentage > 50)
4195 msg_format("%^s¤Ï½Ì¤³¤Þ¤Ã¤¿¡£", m_name);
4196 else if (percentage > 35)
4197 msg_format("%^s¤ÏÄˤߤ˿̤¨¤¿¡£", m_name);
4198 else if (percentage > 20)
4199 msg_format("%^s¤Ï¿È¤â¤À¤¨¤·¤¿¡£", m_name);
4200 else if (percentage > 10)
4201 msg_format("%^s¤Ï¶ìÄˤǿȤâ¤À¤¨¤·¤¿¡£", m_name);
4203 msg_format("%^s¤Ï¤°¤Ë¤ã¤°¤Ë¤ã¤ÈáÛÚ»¤·¤¿¡£", m_name);
4205 if (percentage > 95)
4206 msg_format("%^s barely notices.", m_name);
4207 else if (percentage > 75)
4208 msg_format("%^s flinches.", m_name);
4209 else if (percentage > 50)
4210 msg_format("%^s squelches.", m_name);
4211 else if (percentage > 35)
4212 msg_format("%^s quivers in pain.", m_name);
4213 else if (percentage > 20)
4214 msg_format("%^s writhes about.", m_name);
4215 else if (percentage > 10)
4216 msg_format("%^s writhes in agony.", m_name);
4218 msg_format("%^s jerks limply.", m_name);
4225 else if (strchr("l", r_ptr->d_char))
4227 if (percentage > 95)
4229 msg_format("%^s¤Ï¤Û¤È¤ó¤Éµ¤¤Ë¤È¤á¤Æ¤¤¤Ê¤¤¡£", m_name);
4231 msg_format("%^s barely notices.", m_name);
4233 else if (percentage > 75)
4235 msg_format("%^s¤Ï¤·¤ê¹þ¤ß¤·¤¿¡£", m_name);
4237 msg_format("%^s flinches.", m_name);
4239 else if (percentage > 50)
4241 msg_format("%^s¤Ïí´í°¤·¤¿¡£", m_name);
4243 msg_format("%^s hesitates.", m_name);
4245 else if (percentage > 35)
4247 msg_format("%^s¤ÏÄˤߤ˿̤¨¤¿¡£", m_name);
4249 msg_format("%^s quivers in pain.", m_name);
4251 else if (percentage > 20)
4253 msg_format("%^s¤Ï¿È¤â¤À¤¨¤·¤¿¡£", m_name);
4255 msg_format("%^s writhes about.", m_name);
4257 else if (percentage > 10)
4259 msg_format("%^s¤Ï¶ìÄˤǿȤâ¤À¤¨¤·¤¿¡£", m_name);
4261 msg_format("%^s writhes in agony.", m_name);
4265 msg_format("%^s¤Ï¤°¤Ë¤ã¤°¤Ë¤ã¤ÈáÛÚ»¤·¤¿¡£", m_name);
4267 msg_format("%^s jerks limply.", m_name);
4272 /* Golems, Walls, Doors, Stairs */
4273 else if (strchr("g#+<>", r_ptr->d_char))
4275 if (percentage > 95)
4277 msg_format("%s¤Ï¹¶·â¤òµ¤¤Ë¤È¤á¤Æ¤¤¤Ê¤¤¡£", m_name);
4279 msg_format("%^s ignores the attack.", m_name);
4281 else if (percentage > 75)
4283 msg_format("%s¤Ï¹¶·â¤Ë¸ª¤ò¤¹¤¯¤á¤¿¡£", m_name);
4285 msg_format("%^s shrugs off the attack.", m_name);
4287 else if (percentage > 50)
4289 msg_format("%^s¤ÏÍëÌĤΤ褦¤ËËʤ¨¤¿¡£", m_name);
4291 msg_format("%^s roars thunderously.", m_name);
4293 else if (percentage > 35)
4295 msg_format("%^s¤Ï¶ì¤·¤²¤ËËʤ¨¤¿¡£", m_name);
4297 msg_format("%^s rumbles.", m_name);
4299 else if (percentage > 20)
4301 msg_format("%^s¤Ï¤¦¤á¤¤¤¿¡£", m_name);
4303 msg_format("%^s grunts.", m_name);
4305 else if (percentage > 10)
4307 msg_format("%^s¤Ïí´í°¤·¤¿¡£", m_name);
4309 msg_format("%^s hesitates.", m_name);
4313 msg_format("%^s¤Ï¤¯¤·¤ã¤¯¤·¤ã¤Ë¤Ê¤Ã¤¿¡£", m_name);
4315 msg_format("%^s crumples.", m_name);
4320 /* Snakes, Hydrae, Reptiles, Mimics */
4321 else if (strchr("JMR", r_ptr->d_char) || !isalpha(r_ptr->d_char))
4323 if (percentage > 95)
4325 msg_format("%^s¤Ï¤Û¤È¤ó¤Éµ¤¤Ë¤È¤á¤Æ¤¤¤Ê¤¤¡£", m_name);
4327 msg_format("%^s barely notices.", m_name);
4329 else if (percentage > 75)
4331 msg_format("%^s¤Ï¥·¡¼¥Ã¤ÈÌĤ¤¤¿¡£", m_name);
4333 msg_format("%^s hisses.", m_name);
4335 else if (percentage > 50)
4337 msg_format("%^s¤ÏÅܤäÆƬ¤ò¾å¤²¤¿¡£", m_name);
4339 msg_format("%^s rears up in anger.", m_name);
4341 else if (percentage > 35)
4343 msg_format("%^s¤ÏÌÔÁ³¤È°Ò³Å¤·¤¿¡£", m_name);
4345 msg_format("%^s hisses furiously.", m_name);
4347 else if (percentage > 20)
4349 msg_format("%^s¤Ï¿È¤â¤À¤¨¤·¤¿¡£", m_name);
4351 msg_format("%^s writhes about.", m_name);
4353 else if (percentage > 10)
4355 msg_format("%^s¤Ï¶ìÄˤǿȤâ¤À¤¨¤·¤¿¡£", m_name);
4357 msg_format("%^s writhes in agony.", m_name);
4361 msg_format("%^s¤Ï¤°¤Ë¤ã¤°¤Ë¤ã¤ÈáÛÚ»¤·¤¿¡£", m_name);
4363 msg_format("%^s jerks limply.", m_name);
4369 else if (strchr("f", r_ptr->d_char))
4371 if (percentage > 95)
4373 msg_format("%s¤Ï¹¶·â¤Ë¸ª¤ò¤¹¤¯¤á¤¿¡£", m_name);
4375 msg_format("%^s shrugs off the attack.", m_name);
4377 else if (percentage > 75)
4379 msg_format("%^s¤ÏËʤ¨¤¿¡£", m_name);
4381 msg_format("%^s roars.", m_name);
4383 else if (percentage > 50)
4385 msg_format("%^s¤ÏÅܤäÆËʤ¨¤¿¡£", m_name);
4387 msg_format("%^s growls angrily.", m_name);
4389 else if (percentage > 35)
4391 msg_format("%^s¤ÏÄˤߤǥ·¡¼¥Ã¤ÈÌĤ¤¤¿¡£", m_name);
4393 msg_format("%^s hisses with pain.", m_name);
4395 else if (percentage > 20)
4397 msg_format("%^s¤ÏÄˤߤǼ塹¤·¤¯ÌĤ¤¤¿¡£", m_name);
4399 msg_format("%^s mewls in pain.", m_name);
4401 else if (percentage > 10)
4403 msg_format("%^s¤Ï¶ìÄˤˤ¦¤á¤¤¤¿¡£", m_name);
4405 msg_format("%^s hisses in agony.", m_name);
4409 msg_format("%s¤Ï°¥¤ì¤ÊÌĤÀ¼¤ò½Ð¤·¤¿¡£", m_name);
4411 msg_format("%^s mewls pitifully.", m_name);
4416 /* Ants, Centipedes, Flies, Insects, Beetles, Spiders */
4417 else if (strchr("acFIKS", r_ptr->d_char))
4419 if (percentage > 95)
4421 msg_format("%s¤Ï¹¶·â¤òµ¤¤Ë¤È¤á¤Æ¤¤¤Ê¤¤¡£", m_name);
4423 msg_format("%^s ignores the attack.", m_name);
4425 else if (percentage > 75)
4427 msg_format("%^s¤Ï¥¡¼¥¡¼ÌĤ¤¤¿¡£", m_name);
4429 msg_format("%^s chitters.", m_name);
4432 else if (percentage > 50)
4434 msg_format("%^s¤Ï¥è¥í¥è¥íƨ¤²²ó¤Ã¤¿¡£", m_name);
4436 msg_format("%^s scuttles about.", m_name);
4439 else if (percentage > 35)
4441 msg_format("%^s¤Ï¤¦¤ë¤µ¤¯ÌĤ¤¤¿¡£", m_name);
4443 msg_format("%^s twitters.", m_name);
4446 else if (percentage > 20)
4448 msg_format("%^s¤ÏÄˤߤËáÛÚ»¤·¤¿¡£", m_name);
4450 msg_format("%^s jerks in pain.", m_name);
4453 else if (percentage > 10)
4455 msg_format("%^s¤Ï¶ìÄˤÇáÛÚ»¤·¤¿¡£", m_name);
4457 msg_format("%^s jerks in agony.", m_name);
4462 msg_format("%^s¤Ï¥Ô¥¯¥Ô¥¯¤Ò¤¤Ä¤Ã¤¿¡£", m_name);
4464 msg_format("%^s twitches.", m_name);
4471 else if (strchr("B", r_ptr->d_char))
4473 if (percentage > 95)
4475 msg_format("%^s¤Ï¤µ¤¨¤º¤Ã¤¿¡£", m_name);
4477 msg_format("%^s chirps.", m_name);
4480 else if (percentage > 75)
4482 msg_format("%^s¤Ï¥Ô¡¼¥Ô¡¼ÌĤ¤¤¿¡£", m_name);
4484 msg_format("%^s twitters.", m_name);
4487 else if (percentage > 50)
4489 msg_format("%^s¤Ï¥®¥ã¡¼¥®¥ã¡¼ÌĤ¤¤¿¡£", m_name);
4491 msg_format("%^s squawks.", m_name);
4494 else if (percentage > 35)
4496 msg_format("%^s¤Ï¥®¥ã¡¼¥®¥ã¡¼ÌĤ¤ï¤á¤¤¤¿¡£", m_name);
4498 msg_format("%^s chatters.", m_name);
4501 else if (percentage > 20)
4503 msg_format("%^s¤Ï¶ì¤·¤ó¤À¡£", m_name);
4505 msg_format("%^s jeers.", m_name);
4508 else if (percentage > 10)
4510 msg_format("%^s¤Ï¤Î¤¿¤¦¤Á²ó¤Ã¤¿¡£", m_name);
4512 msg_format("%^s flutters about.", m_name);
4517 msg_format("%^s¤Ï¥¡¼¥¡¼¤ÈÌĤ¶«¤ó¤À¡£", m_name);
4519 msg_format("%^s squeaks.", m_name);
4525 /* Dragons, Demons, High Undead */
4526 else if (strchr("duDLUW", r_ptr->d_char))
4528 if (percentage > 95)
4530 msg_format("%s¤Ï¹¶·â¤òµ¤¤Ë¤È¤á¤Æ¤¤¤Ê¤¤¡£", m_name);
4532 msg_format("%^s ignores the attack.", m_name);
4535 else if (percentage > 75)
4537 msg_format("%^s¤Ï¤·¤ê¹þ¤ß¤·¤¿¡£", m_name);
4539 msg_format("%^s flinches.", m_name);
4542 else if (percentage > 50)
4544 msg_format("%^s¤ÏÄˤߤǥ·¡¼¥Ã¤ÈÌĤ¤¤¿¡£", m_name);
4546 msg_format("%^s hisses in pain.", m_name);
4549 else if (percentage > 35)
4551 msg_format("%^s¤ÏÄˤߤǤ¦¤Ê¤Ã¤¿¡£", m_name);
4553 msg_format("%^s snarls with pain.", m_name);
4556 else if (percentage > 20)
4558 msg_format("%^s¤ÏÄˤߤËËʤ¨¤¿¡£", m_name);
4560 msg_format("%^s roars with pain.", m_name);
4563 else if (percentage > 10)
4565 msg_format("%^s¤Ï¶ì¤·¤²¤Ë¶«¤ó¤À¡£", m_name);
4567 msg_format("%^s gasps.", m_name);
4572 msg_format("%^s¤Ï¼å¡¹¤·¤¯¤¦¤Ê¤Ã¤¿¡£", m_name);
4574 msg_format("%^s snarls feebly.", m_name);
4581 else if (strchr("s", r_ptr->d_char))
4583 if (percentage > 95)
4585 msg_format("%s¤Ï¹¶·â¤òµ¤¤Ë¤È¤á¤Æ¤¤¤Ê¤¤¡£", m_name);
4587 msg_format("%^s ignores the attack.", m_name);
4590 else if (percentage > 75)
4592 msg_format("%s¤Ï¹¶·â¤Ë¸ª¤ò¤¹¤¯¤á¤¿¡£", m_name);
4594 msg_format("%^s shrugs off the attack.", m_name);
4597 else if (percentage > 50)
4599 msg_format("%^s¤Ï¥«¥¿¥«¥¿¤È¾Ð¤Ã¤¿¡£", m_name);
4601 msg_format("%^s rattles.", m_name);
4604 else if (percentage > 35)
4606 msg_format("%^s¤Ï¤è¤í¤á¤¤¤¿¡£", m_name);
4608 msg_format("%^s stumbles.", m_name);
4611 else if (percentage > 20)
4613 msg_format("%^s¤Ï¥«¥¿¥«¥¿¸À¤Ã¤¿¡£", m_name);
4615 msg_format("%^s rattles.", m_name);
4618 else if (percentage > 10)
4620 msg_format("%^s¤Ï¤è¤í¤á¤¤¤¿¡£", m_name);
4622 msg_format("%^s staggers.", m_name);
4627 msg_format("%^s¤Ï¥¬¥¿¥¬¥¿¸À¤Ã¤¿¡£", m_name);
4629 msg_format("%^s clatters.", m_name);
4636 else if (strchr("z", r_ptr->d_char))
4638 if (percentage > 95)
4640 msg_format("%s¤Ï¹¶·â¤òµ¤¤Ë¤È¤á¤Æ¤¤¤Ê¤¤¡£", m_name);
4642 msg_format("%^s ignores the attack.", m_name);
4645 else if (percentage > 75)
4647 msg_format("%s¤Ï¹¶·â¤Ë¸ª¤ò¤¹¤¯¤á¤¿¡£", m_name);
4649 msg_format("%^s shrugs off the attack.", m_name);
4652 else if (percentage > 50)
4654 msg_format("%^s¤Ï¤¦¤á¤¤¤¿¡£", m_name);
4656 msg_format("%^s groans.", m_name);
4659 else if (percentage > 35)
4661 msg_format("%s¤Ï¶ì¤·¤²¤Ë¤¦¤á¤¤¤¿¡£", m_name);
4663 msg_format("%^s moans.", m_name);
4666 else if (percentage > 20)
4668 msg_format("%^s¤Ïí´í°¤·¤¿¡£", m_name);
4670 msg_format("%^s hesitates.", m_name);
4673 else if (percentage > 10)
4675 msg_format("%^s¤Ï¤¦¤Ê¤Ã¤¿¡£", m_name);
4677 msg_format("%^s grunts.", m_name);
4682 msg_format("%^s¤Ï¤è¤í¤á¤¤¤¿¡£", m_name);
4684 msg_format("%^s staggers.", m_name);
4691 else if (strchr("G", r_ptr->d_char))
4694 if (percentage > 95)
4696 msg_format("%s¤Ï¹¶·â¤òµ¤¤Ë¤È¤á¤Æ¤¤¤Ê¤¤¡£", m_name);
4698 msg_format("%^s ignores the attack.", m_name);
4701 else if (percentage > 75)
4703 msg_format("%s¤Ï¹¶·â¤Ë¸ª¤ò¤¹¤¯¤á¤¿¡£", m_name);
4705 msg_format("%^s shrugs off the attack.", m_name);
4708 else if (percentage > 50)
4710 msg_format("%s¤Ï¤¦¤á¤¤¤¿¡£", m_name);
4712 msg_format("%^s moans.", m_name);
4715 else if (percentage > 35)
4717 msg_format("%^s¤Ïµã¤¤ï¤á¤¤¤¿¡£", m_name);
4719 msg_format("%^s wails.", m_name);
4722 else if (percentage > 20)
4724 msg_format("%^s¤ÏËʤ¨¤¿¡£", m_name);
4726 msg_format("%^s howls.", m_name);
4729 else if (percentage > 10)
4731 msg_format("%s¤Ï¼å¡¹¤·¤¯¤¦¤á¤¤¤¿¡£", m_name);
4733 msg_format("%^s moans softly.", m_name);
4738 msg_format("%^s¤Ï¤«¤¹¤«¤Ë¤¦¤á¤¤¤¿¡£", m_name);
4740 msg_format("%^s sighs.", m_name);
4746 /* Dogs and Hounds */
4747 else if (strchr("CZ", r_ptr->d_char))
4750 if (percentage > 95)
4751 msg_format("%^s¤Ï¹¶·â¤Ë¸ª¤ò¤¹¤¯¤á¤¿¡£", m_name);
4752 else if (percentage > 75)
4753 msg_format("%^s¤ÏÄˤߤǤ¦¤Ê¤Ã¤¿¡£", m_name);
4754 else if (percentage > 50)
4755 msg_format("%^s¤ÏÄˤߤǥ¥ã¥ó¥¥ã¥óËʤ¨¤¿¡£", m_name);
4756 else if (percentage > 35)
4757 msg_format("%^s¤ÏÄˤߤÇÌĤ¤ï¤á¤¤¤¿¡£", m_name);
4758 else if (percentage > 20)
4759 msg_format("%^s¤Ï¶ìÄˤΤ¢¤Þ¤êÌĤ¤ï¤á¤¤¤¿¡£", m_name);
4760 else if (percentage > 10)
4761 msg_format("%^s¤Ï¶ìÄˤǤâ¤À¤¨¶ì¤·¤ó¤À¡£", m_name);
4763 msg_format("%^s¤Ï¼å¡¹¤·¤¯Ëʤ¨¤¿¡£", m_name);
4765 if (percentage > 95)
4766 msg_format("%^s shrugs off the attack.", m_name);
4767 else if (percentage > 75)
4768 msg_format("%^s snarls with pain.", m_name);
4769 else if (percentage > 50)
4770 msg_format("%^s yelps in pain.", m_name);
4771 else if (percentage > 35)
4772 msg_format("%^s howls in pain.", m_name);
4773 else if (percentage > 20)
4774 msg_format("%^s howls in agony.", m_name);
4775 else if (percentage > 10)
4776 msg_format("%^s writhes in agony.", m_name);
4778 msg_format("%^s yelps feebly.", m_name);
4783 /* One type of monsters (ignore,squeal,shriek) */
4784 else if (strchr("Xbilqrt", r_ptr->d_char))
4787 if (percentage > 95)
4788 msg_format("%^s¤Ï¹¶·â¤òµ¤¤Ë¤È¤á¤Æ¤¤¤Ê¤¤¡£", m_name);
4789 else if (percentage > 75)
4790 msg_format("%^s¤ÏÄˤߤǤ¦¤Ê¤Ã¤¿¡£", m_name);
4791 else if (percentage > 50)
4792 msg_format("%^s¤ÏÄˤߤǶ«¤ó¤À¡£", m_name);
4793 else if (percentage > 35)
4794 msg_format("%^s¤ÏÄˤߤÇÀ䶫¤·¤¿¡£", m_name);
4795 else if (percentage > 20)
4796 msg_format("%^s¤Ï¶ìÄˤΤ¢¤Þ¤êÀ䶫¤·¤¿¡£", m_name);
4797 else if (percentage > 10)
4798 msg_format("%^s¤Ï¶ìÄˤǤâ¤À¤¨¶ì¤·¤ó¤À¡£", m_name);
4800 msg_format("%^s¤Ï¼å¡¹¤·¤¯¶«¤ó¤À¡£", m_name);
4802 if (percentage > 95)
4803 msg_format("%^s ignores the attack.", m_name);
4804 else if (percentage > 75)
4805 msg_format("%^s grunts with pain.", m_name);
4806 else if (percentage > 50)
4807 msg_format("%^s squeals in pain.", m_name);
4808 else if (percentage > 35)
4809 msg_format("%^s shrieks in pain.", m_name);
4810 else if (percentage > 20)
4811 msg_format("%^s shrieks in agony.", m_name);
4812 else if (percentage > 10)
4813 msg_format("%^s writhes in agony.", m_name);
4815 msg_format("%^s cries out feebly.", m_name);
4820 /* Another type of monsters (shrug,cry,scream) */
4824 if (percentage > 95)
4825 msg_format("%^s¤Ï¹¶·â¤Ë¸ª¤ò¤¹¤¯¤á¤¿¡£", m_name);
4826 else if (percentage > 75)
4827 msg_format("%^s¤ÏÄˤߤǤ¦¤Ê¤Ã¤¿¡£", m_name);
4828 else if (percentage > 50)
4829 msg_format("%^s¤ÏÄˤߤǶ«¤ó¤À¡£", m_name);
4830 else if (percentage > 35)
4831 msg_format("%^s¤ÏÄˤߤÇÀ䶫¤·¤¿¡£", m_name);
4832 else if (percentage > 20)
4833 msg_format("%^s¤Ï¶ìÄˤΤ¢¤Þ¤êÀ䶫¤·¤¿¡£", m_name);
4834 else if (percentage > 10)
4835 msg_format("%^s¤Ï¶ìÄˤǤâ¤À¤¨¶ì¤·¤ó¤À¡£", m_name);
4837 msg_format("%^s¤Ï¼å¡¹¤·¤¯¶«¤ó¤À¡£", m_name);
4839 if (percentage > 95)
4840 msg_format("%^s shrugs off the attack.", m_name);
4841 else if (percentage > 75)
4842 msg_format("%^s grunts with pain.", m_name);
4843 else if (percentage > 50)
4844 msg_format("%^s cries out in pain.", m_name);
4845 else if (percentage > 35)
4846 msg_format("%^s screams in pain.", m_name);
4847 else if (percentage > 20)
4848 msg_format("%^s screams in agony.", m_name);
4849 else if (percentage > 10)
4850 msg_format("%^s writhes in agony.", m_name);
4852 msg_format("%^s cries out feebly.", m_name);
4860 * Learn about an "observed" resistance.
4862 void update_smart_learn(int m_idx, int what)
4864 #ifdef DRS_SMART_OPTIONS
4866 monster_type *m_ptr = &m_list[m_idx];
4868 monster_race *r_ptr = &r_info[m_ptr->r_idx];
4871 /* Not allowed to learn */
4872 if (!smart_learn) return;
4874 /* Too stupid to learn anything */
4875 if (r_ptr->flags2 & (RF2_STUPID)) return;
4877 /* Not intelligent, only learn sometimes */
4878 if (!(r_ptr->flags2 & (RF2_SMART)) && (randint0(100) < 50)) return;
4883 /* Analyze the knowledge */
4887 if (p_ptr->resist_acid) m_ptr->smart |= (SM_RES_ACID);
4888 if (IS_OPPOSE_ACID()) m_ptr->smart |= (SM_OPP_ACID);
4889 if (p_ptr->immune_acid) m_ptr->smart |= (SM_IMM_ACID);
4893 if (p_ptr->resist_elec) m_ptr->smart |= (SM_RES_ELEC);
4894 if (IS_OPPOSE_ELEC()) m_ptr->smart |= (SM_OPP_ELEC);
4895 if (p_ptr->immune_elec) m_ptr->smart |= (SM_IMM_ELEC);
4899 if (p_ptr->resist_fire) m_ptr->smart |= (SM_RES_FIRE);
4900 if (IS_OPPOSE_FIRE()) m_ptr->smart |= (SM_OPP_FIRE);
4901 if (p_ptr->immune_fire) m_ptr->smart |= (SM_IMM_FIRE);
4905 if (p_ptr->resist_cold) m_ptr->smart |= (SM_RES_COLD);
4906 if (IS_OPPOSE_COLD()) m_ptr->smart |= (SM_OPP_COLD);
4907 if (p_ptr->immune_cold) m_ptr->smart |= (SM_IMM_COLD);
4911 if (p_ptr->resist_pois) m_ptr->smart |= (SM_RES_POIS);
4912 if (IS_OPPOSE_POIS()) m_ptr->smart |= (SM_OPP_POIS);
4917 if (p_ptr->resist_neth) m_ptr->smart |= (SM_RES_NETH);
4921 if (p_ptr->resist_lite) m_ptr->smart |= (SM_RES_LITE);
4925 if (p_ptr->resist_dark) m_ptr->smart |= (SM_RES_DARK);
4929 if (p_ptr->resist_fear) m_ptr->smart |= (SM_RES_FEAR);
4933 if (p_ptr->resist_conf) m_ptr->smart |= (SM_RES_CONF);
4937 if (p_ptr->resist_chaos) m_ptr->smart |= (SM_RES_CHAOS);
4941 if (p_ptr->resist_disen) m_ptr->smart |= (SM_RES_DISEN);
4945 if (p_ptr->resist_blind) m_ptr->smart |= (SM_RES_BLIND);
4949 if (p_ptr->resist_nexus) m_ptr->smart |= (SM_RES_NEXUS);
4953 if (p_ptr->resist_sound) m_ptr->smart |= (SM_RES_SOUND);
4957 if (p_ptr->resist_shard) m_ptr->smart |= (SM_RES_SHARD);
4961 if (p_ptr->free_act) m_ptr->smart |= (SM_IMM_FREE);
4965 if (!p_ptr->msp) m_ptr->smart |= (SM_IMM_MANA);
4969 if (p_ptr->reflect) m_ptr-> smart |= (SM_IMM_REFLECT);
4973 #endif /* DRS_SMART_OPTIONS */
4979 * Place the player in the dungeon XXX XXX
4981 bool player_place(int y, int x)
4983 /* Paranoia XXX XXX */
4984 if (cave[y][x].m_idx != 0) return FALSE;
4986 /* Save player location */
4996 * Drop all items carried by a monster
4998 void monster_drop_carried_objects(monster_type *m_ptr)
5000 s16b this_o_idx, next_o_idx = 0;
5006 /* Drop objects being carried */
5007 for (this_o_idx = m_ptr->hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
5009 /* Acquire object */
5010 o_ptr = &o_list[this_o_idx];
5012 /* Acquire next object */
5013 next_o_idx = o_ptr->next_o_idx;
5016 o_ptr->held_m_idx = 0;
5018 /* Get local object */
5021 /* Copy the object */
5022 object_copy(q_ptr, o_ptr);
5024 /* Delete the object */
5025 delete_object_idx(this_o_idx);
5028 (void)drop_near(q_ptr, -1, m_ptr->fy, m_ptr->fx);
5031 /* Forget objects */
5032 m_ptr->hold_o_idx = 0;