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 || p_ptr->inside_quest < MIN_RANDOM_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
1529 * 0x00 --> Full nominative name ("the kobold") or "it"
1530 * 0x04 --> Full nominative name ("the kobold") or "something"
1531 * 0x80 --> Genocide resistance name ("the kobold")
1532 * 0x88 --> Killing name ("a kobold")
1533 * 0x22 --> Possessive, genderized if visable ("his") or "its"
1534 * 0x23 --> Reflexive, genderized if visable ("himself") or "itself"
1536 void monster_desc(char *desc, monster_type *m_ptr, int mode)
1539 monster_race *r_ptr;
1543 char silly_name[1024];
1547 r_ptr = &r_info[m_ptr->ap_r_idx];
1549 /* Mode of 0x100 will reveal Chameleon's true name */
1550 if (mode & 0x100) name = (r_name + real_r_ptr(m_ptr)->name);
1551 else name = (r_name + r_ptr->name);
1553 /* Are we hallucinating? (Idea from Nethack...) */
1554 if (p_ptr->image && !(mode & 0x200))
1559 if (!get_rnd_line("silly_j.txt", m_ptr->r_idx, silly_name))
1561 if (!get_rnd_line("silly.txt", m_ptr->r_idx, silly_name))
1569 monster_race *hallu_race;
1573 hallu_race = &r_info[randint1(max_r_idx - 1)];
1575 while (hallu_race->flags1 & RF1_UNIQUE);
1577 strcpy(silly_name, (r_name + hallu_race->name));
1580 /* Better not strcpy it, or we could corrupt r_info... */
1584 /* Can we "see" it (exists + forced, or visible + not unforced) */
1585 seen = (m_ptr && ((mode & 0x80) || (!(mode & 0x40) && m_ptr->ml)));
1587 /* Sexed Pronouns (seen and allowed, or unseen and allowed) */
1588 pron = (m_ptr && ((seen && (mode & 0x20)) || (!seen && (mode & 0x10))));
1591 /* First, try using pronouns, or describing hidden monsters */
1594 /* an encoding of the monster "sex" */
1597 /* Extract the gender (if applicable) */
1598 if (r_ptr->flags1 & (RF1_FEMALE)) kind = 0x20;
1599 else if (r_ptr->flags1 & (RF1_MALE)) kind = 0x10;
1601 /* Ignore the gender (if desired) */
1602 if (!m_ptr || !pron) kind = 0x00;
1605 /* Assume simple result */
1613 /* Brute force: split on the possibilities */
1614 switch (kind + (mode & 0x07))
1616 /* Neuter, or unknown */
1618 case 0x00: res = "²¿¤«"; break;
1619 case 0x01: res = "²¿¤«"; break;
1620 case 0x02: res = "²¿¤«¤Î"; break;
1621 case 0x03: res = "²¿¤«¼«¿È"; break;
1622 case 0x04: res = "²¿¤«"; break;
1623 case 0x05: res = "²¿¤«"; break;
1624 case 0x06: res = "²¿¤«"; break;
1625 case 0x07: res = "¤½¤ì¼«¿È"; break;
1627 case 0x00: res = "it"; break;
1628 case 0x01: res = "it"; break;
1629 case 0x02: res = "its"; break;
1630 case 0x03: res = "itself"; break;
1631 case 0x04: res = "something"; break;
1632 case 0x05: res = "something"; break;
1633 case 0x06: res = "something's"; break;
1634 case 0x07: res = "itself"; break;
1638 /* Male (assume human if vague) */
1640 case 0x10: res = "Èà"; break;
1641 case 0x11: res = "Èà"; break;
1642 case 0x12: res = "Èà¤Î"; break;
1643 case 0x13: res = "È༫¿È"; break;
1644 case 0x14: res = "狼"; break;
1645 case 0x15: res = "狼"; break;
1646 case 0x16: res = "狼¤Î"; break;
1647 case 0x17: res = "È༫¿È"; break;
1649 case 0x10: res = "he"; break;
1650 case 0x11: res = "him"; break;
1651 case 0x12: res = "his"; break;
1652 case 0x13: res = "himself"; break;
1653 case 0x14: res = "someone"; break;
1654 case 0x15: res = "someone"; break;
1655 case 0x16: res = "someone's"; break;
1656 case 0x17: res = "himself"; break;
1660 /* Female (assume human if vague) */
1662 case 0x20: res = "Èà½÷"; break;
1663 case 0x21: res = "Èà½÷"; break;
1664 case 0x22: res = "Èà½÷¤Î"; break;
1665 case 0x23: res = "Èà½÷¼«¿È"; break;
1666 case 0x24: res = "狼"; break;
1667 case 0x25: res = "狼"; break;
1668 case 0x26: res = "狼¤Î"; break;
1669 case 0x27: res = "Èà½÷¼«¿È"; break;
1671 case 0x20: res = "she"; break;
1672 case 0x21: res = "her"; break;
1673 case 0x22: res = "her"; break;
1674 case 0x23: res = "herself"; break;
1675 case 0x24: res = "someone"; break;
1676 case 0x25: res = "someone"; break;
1677 case 0x26: res = "someone's"; break;
1678 case 0x27: res = "herself"; break;
1683 /* Copy the result */
1684 (void)strcpy(desc, res);
1688 /* Handle visible monsters, "reflexive" request */
1689 else if ((mode & 0x02) && (mode & 0x01))
1691 /* The monster is visible, so use its gender */
1693 if (r_ptr->flags1 & (RF1_FEMALE)) strcpy(desc, "Èà½÷¼«¿È");
1694 else if (r_ptr->flags1 & (RF1_MALE)) strcpy(desc, "È༫¿È");
1695 else strcpy(desc, "¤½¤ì¼«¿È");
1697 if (r_ptr->flags1 & RF1_FEMALE) strcpy(desc, "herself");
1698 else if (r_ptr->flags1 & RF1_MALE) strcpy(desc, "himself");
1699 else strcpy(desc, "itself");
1705 /* Handle all other visible monster requests */
1709 if (is_pet(m_ptr) && m_ptr->ap_r_idx != m_ptr->r_idx)
1715 while(strncmp(t, "¡Ù", 2) && *t) t++;
1719 (void)sprintf(desc, "%s¡©¡Ù", buf);
1722 (void)sprintf(desc, "%s¡©", name);
1724 (void)sprintf(desc, "%s?", name);
1729 /* It could be a Unique */
1730 if ((r_ptr->flags1 & RF1_UNIQUE) && !(p_ptr->image && !(mode & 0x200)))
1732 /* Start with the name (thus nominative and objective) */
1733 if ((m_ptr->mflag2 & MFLAG2_CHAMELEON) && !(mode & 0x100))
1739 while(strncmp(t, "¡Ù", 2) && *t) t++;
1743 (void)sprintf(desc, "%s¡©¡Ù", buf);
1746 (void)sprintf(desc, "%s¡©", name);
1748 (void)sprintf(desc, "%s?", name);
1751 else if ((cave[m_ptr->fy][m_ptr->fx].m_idx == p_ptr->riding) || !p_ptr->inside_battle)
1752 (void)strcpy(desc, name);
1755 (void)sprintf(desc, "%s¤â¤É¤", name);
1757 (void)sprintf(desc, "fake %s", name);
1761 /* It could be an indefinite monster */
1762 else if (mode & 0x08)
1764 /* XXX Check plurality for "some" */
1766 /* Indefinite monsters need an indefinite article */
1768 (void)strcpy(desc, "");
1770 (void)strcpy(desc, is_a_vowel(name[0]) ? "an " : "a ");
1773 (void)strcat(desc, name);
1776 /* It could be a normal, definite, monster */
1779 /* Definite monsters need a definite article */
1782 (void)strcpy(desc, "¤¢¤Ê¤¿¤Î");
1784 (void)strcpy(desc, "your ");
1789 (void)strcpy(desc, "");
1791 (void)strcpy(desc, "the ");
1794 (void)strcat(desc, name);
1797 if (m_ptr->nickname)
1800 sprintf(buf,"¡Ö%s¡×",quark_str(m_ptr->nickname));
1802 sprintf(buf," called %s",quark_str(m_ptr->nickname));
1807 if ((m_ptr->fy == py) && (m_ptr->fx == px))
1810 strcat(desc,"(¾èÇÏÃæ)");
1812 strcat(desc,"(riding)");
1816 if ((mode & 0x200) && (m_ptr->mflag2 & MFLAG2_CHAMELEON))
1818 if (r_ptr->flags1 & RF1_UNIQUE)
1821 strcat(desc,"(¥«¥á¥ì¥ª¥ó¤Î²¦)");
1823 strcat(desc,"(Chameleon Lord)");
1829 strcat(desc,"(¥«¥á¥ì¥ª¥ó)");
1831 strcat(desc,"(Chameleon)");
1836 if ((mode & 0x200) && m_ptr->ap_r_idx != m_ptr->r_idx)
1838 strcat(desc, format("(%s)", r_name + r_info[m_ptr->r_idx].name));
1841 /* Handle the Possessive as a special afterthought */
1844 /* XXX Check for trailing "s" */
1846 /* Simply append "apostrophe" and "s" */
1848 (void)strcat(desc, "¤Î");
1850 (void)strcat(desc, "'s");
1861 * Learn about a monster (by "probing" it)
1863 * Return the number of new flags learnt. -Mogami-
1865 int lore_do_probe(int r_idx)
1867 monster_race *r_ptr = &r_info[r_idx];
1871 /* Maximal info about awareness */
1872 if (r_ptr->r_wake != MAX_UCHAR) n++;
1873 if (r_ptr->r_ignore != MAX_UCHAR) n++;
1874 r_ptr->r_wake = r_ptr->r_ignore = MAX_UCHAR;
1876 /* Observe "maximal" attacks */
1877 for (i = 0; i < 4; i++)
1879 /* Examine "actual" blows */
1880 if (r_ptr->blow[i].effect || r_ptr->blow[i].method)
1882 /* Maximal observations */
1883 if (r_ptr->r_blows[i] != MAX_UCHAR) n++;
1884 r_ptr->r_blows[i] = MAX_UCHAR;
1890 (((r_ptr->flags1 & RF1_DROP_4D2) ? 8 : 0) +
1891 ((r_ptr->flags1 & RF1_DROP_3D2) ? 6 : 0) +
1892 ((r_ptr->flags1 & RF1_DROP_2D2) ? 4 : 0) +
1893 ((r_ptr->flags1 & RF1_DROP_1D2) ? 2 : 0) +
1894 ((r_ptr->flags1 & RF1_DROP_90) ? 1 : 0) +
1895 ((r_ptr->flags1 & RF1_DROP_60) ? 1 : 0));
1897 /* Only "valid" drops */
1898 if (!(r_ptr->flags1 & RF1_ONLY_GOLD))
1900 if (r_ptr->r_drop_item != tmp_byte) n++;
1901 r_ptr->r_drop_item = tmp_byte;
1903 if (!(r_ptr->flags1 & RF1_ONLY_ITEM))
1905 if (r_ptr->r_drop_gold != tmp_byte) n++;
1906 r_ptr->r_drop_gold = tmp_byte;
1909 /* Observe many spells */
1910 if (r_ptr->r_cast_spell != MAX_UCHAR) n++;
1911 r_ptr->r_cast_spell = MAX_UCHAR;
1913 /* Count unknown flags */
1914 for (i = 0; i < 32; i++)
1916 if (!(r_ptr->r_flags1 & (1L << i)) &&
1917 (r_ptr->flags1 & (1L << i))) n++;
1918 if (!(r_ptr->r_flags2 & (1L << i)) &&
1919 (r_ptr->flags2 & (1L << i))) n++;
1920 if (!(r_ptr->r_flags3 & (1L << i)) &&
1921 (r_ptr->flags3 & (1L << i))) n++;
1922 if (!(r_ptr->r_flags4 & (1L << i)) &&
1923 (r_ptr->flags4 & (1L << i))) n++;
1924 if (!(r_ptr->r_flags5 & (1L << i)) &&
1925 (r_ptr->flags5 & (1L << i))) n++;
1926 if (!(r_ptr->r_flags6 & (1L << i)) &&
1927 (r_ptr->flags6 & (1L << i))) n++;
1929 /* r_flags7 is actually unused */
1931 if (!(r_ptr->r_flags7 & (1L << i)) &&
1932 (r_ptr->flags7 & (1L << i))) n++;
1936 /* Know all the flags */
1937 r_ptr->r_flags1 = r_ptr->flags1;
1938 r_ptr->r_flags2 = r_ptr->flags2;
1939 r_ptr->r_flags3 = r_ptr->flags3;
1940 r_ptr->r_flags4 = r_ptr->flags4;
1941 r_ptr->r_flags5 = r_ptr->flags5;
1942 r_ptr->r_flags6 = r_ptr->flags6;
1944 /* r_flags7 is actually unused */
1945 /* r_ptr->r_flags7 = r_ptr->flags7; */
1947 /* Know about evolution */
1948 if (!(r_ptr->r_xtra1 & MR1_SINKA)) n++;
1949 r_ptr->r_xtra1 |= MR1_SINKA;
1951 /* Update monster recall window */
1952 if (p_ptr->monster_race_idx == r_idx)
1955 p_ptr->window |= (PW_MONSTER);
1958 /* Return the number of new flags learnt */
1964 * Take note that the given monster just dropped some treasure
1966 * Note that learning the "GOOD"/"GREAT" flags gives information
1967 * about the treasure (even when the monster is killed for the first
1968 * time, such as uniques, and the treasure has not been examined yet).
1970 * This "indirect" method is used to prevent the player from learning
1971 * exactly how much treasure a monster can drop from observing only
1972 * a single example of a drop. This method actually observes how much
1973 * gold and items are dropped, and remembers that information to be
1974 * described later by the monster recall code.
1976 void lore_treasure(int m_idx, int num_item, int num_gold)
1978 monster_type *m_ptr = &m_list[m_idx];
1980 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1982 /* Note the number of things dropped */
1983 if (num_item > r_ptr->r_drop_item) r_ptr->r_drop_item = num_item;
1984 if (num_gold > r_ptr->r_drop_gold) r_ptr->r_drop_gold = num_gold;
1986 /* Hack -- memorize the good/great flags */
1987 if (r_ptr->flags1 & (RF1_DROP_GOOD)) r_ptr->r_flags1 |= (RF1_DROP_GOOD);
1988 if (r_ptr->flags1 & (RF1_DROP_GREAT)) r_ptr->r_flags1 |= (RF1_DROP_GREAT);
1990 /* Update monster recall window */
1991 if (p_ptr->monster_race_idx == m_ptr->r_idx)
1994 p_ptr->window |= (PW_MONSTER);
2000 void sanity_blast(monster_type *m_ptr, bool necro)
2002 bool happened = FALSE;
2005 if (p_ptr->inside_battle || !character_dungeon) return;
2010 monster_race *r_ptr = &r_info[m_ptr->r_idx];
2012 power = r_ptr->level / 2;
2014 monster_desc(m_name, m_ptr, 0);
2016 if (!(r_ptr->flags1 & RF1_UNIQUE))
2018 if (r_ptr->flags1 & RF1_FRIENDS)
2024 return; /* No effect yet, just loaded... */
2027 return; /* Cannot see it for some reason */
2029 if (!(r_ptr->flags2 & RF2_ELDRITCH_HORROR))
2035 return; /* Pet eldritch horrors are safe most of the time */
2037 if (randint1(100) > power) return;
2039 if (saving_throw(p_ptr->skill_sav - power))
2041 return; /* Save, no adverse effects */
2046 /* Something silly happens... */
2048 msg_format("%s%s¤Î´é¤ò¸«¤Æ¤·¤Þ¤Ã¤¿¡ª",
2049 funny_desc[randint0(MAX_SAN_FUNNY)], m_name);
2051 msg_format("You behold the %s visage of %s!",
2052 funny_desc[randint0(MAX_SAN_FUNNY)], m_name);
2058 msg_print(funny_comments[randint0(MAX_SAN_COMMENT)]);
2059 p_ptr->image = p_ptr->image + randint1(r_ptr->level);
2062 return; /* Never mind; we can't see it clearly enough */
2065 /* Something frightening happens... */
2067 msg_format("%s%s¤Î´é¤ò¸«¤Æ¤·¤Þ¤Ã¤¿¡ª",
2068 horror_desc[randint0(MAX_SAN_HORROR)], m_name);
2070 msg_format("You behold the %s visage of %s!",
2071 horror_desc[randint0(MAX_SAN_HORROR)], m_name);
2074 r_ptr->r_flags2 |= RF2_ELDRITCH_HORROR;
2076 /* Demon characters are unaffected */
2077 if (prace_is_(RACE_IMP) || prace_is_(RACE_DEMON) || (mimic_info[p_ptr->mimic_form].MIMIC_FLAGS & MIMIC_IS_DEMON)) return;
2078 if (p_ptr->wizard) return;
2080 /* Undead characters are 50% likely to be unaffected */
2081 if (prace_is_(RACE_SKELETON) || prace_is_(RACE_ZOMBIE)
2082 || prace_is_(RACE_VAMPIRE) || prace_is_(RACE_SPECTRE) ||
2083 (mimic_info[p_ptr->mimic_form].MIMIC_FLAGS & MIMIC_IS_UNDEAD))
2085 if (saving_throw(25 + p_ptr->lev)) return;
2091 msg_print("¥Í¥¯¥í¥Î¥ß¥³¥ó¤òÆɤó¤ÇÀµµ¤¤ò¼º¤Ã¤¿¡ª");
2093 msg_print("Your sanity is shaken by reading the Necronomicon!");
2098 if (!saving_throw(p_ptr->skill_sav - power)) /* Mind blast */
2100 if (!p_ptr->resist_conf)
2102 (void)set_confused(p_ptr->confused + randint0(4) + 4);
2104 if (!p_ptr->resist_chaos && one_in_(3))
2106 (void)set_image(p_ptr->image + randint0(250) + 150);
2111 if (!saving_throw(p_ptr->skill_sav - power)) /* Lose int & wis */
2118 if (!saving_throw(p_ptr->skill_sav - power)) /* Brain smash */
2120 if (!p_ptr->resist_conf)
2122 (void)set_confused(p_ptr->confused + randint0(4) + 4);
2124 if (!p_ptr->free_act)
2126 (void)set_paralyzed(p_ptr->paralyzed + randint0(4) + 4);
2128 while (randint0(100) > p_ptr->skill_sav)
2129 (void)do_dec_stat(A_INT);
2130 while (randint0(100) > p_ptr->skill_sav)
2131 (void)do_dec_stat(A_WIS);
2132 if (!p_ptr->resist_chaos)
2134 (void)set_image(p_ptr->image + randint0(250) + 150);
2139 if (!saving_throw(p_ptr->skill_sav - power)) /* Amnesia */
2142 if (lose_all_info())
2144 msg_print("¤¢¤Þ¤ê¤Î¶²ÉݤËÁ´¤Æ¤Î¤³¤È¤ò˺¤ì¤Æ¤·¤Þ¤Ã¤¿¡ª");
2146 msg_print("You forget everything in your utmost terror!");
2152 if (saving_throw(p_ptr->skill_sav - power))
2157 /* Else gain permanent insanity */
2158 if ((p_ptr->muta3 & MUT3_MORONIC) && /*(p_ptr->muta2 & MUT2_BERS_RAGE) &&*/
2159 ((p_ptr->muta2 & MUT2_COWARDICE) || (p_ptr->resist_fear)) &&
2160 ((p_ptr->muta2 & MUT2_HALLU) || (p_ptr->resist_chaos)))
2162 /* The poor bastard already has all possible insanities! */
2168 switch (randint1(21))
2171 if (!(p_ptr->muta3 & MUT3_MORONIC) && one_in_(5))
2173 if ((p_ptr->stat_use[A_INT] < 4) && (p_ptr->stat_use[A_WIS] < 4))
2176 msg_print("¤¢¤Ê¤¿¤Ï´°àú¤ÊÇϼ¯¤Ë¤Ê¤Ã¤¿¤è¤¦¤Êµ¤¤¬¤·¤¿¡£¤·¤«¤·¤½¤ì¤Ï¸µ¡¹¤À¤Ã¤¿¡£");
2178 msg_print("You turn into an utter moron!");
2184 msg_print("¤¢¤Ê¤¿¤Ï´°àú¤ÊÇϼ¯¤Ë¤Ê¤Ã¤¿¡ª");
2186 msg_print("You turn into an utter moron!");
2190 if (p_ptr->muta3 & MUT3_HYPER_INT)
2193 msg_print("¤¢¤Ê¤¿¤ÎǾ¤ÏÀ¸ÂÎ¥³¥ó¥Ô¥å¡¼¥¿¤Ç¤Ï¤Ê¤¯¤Ê¤Ã¤¿¡£");
2195 msg_print("Your brain is no longer a living computer.");
2198 p_ptr->muta3 &= ~(MUT3_HYPER_INT);
2200 p_ptr->muta3 |= MUT3_MORONIC;
2214 if (!(p_ptr->muta2 & MUT2_COWARDICE) && !p_ptr->resist_fear)
2217 msg_print("¤¢¤Ê¤¿¤Ï¥Ñ¥é¥Î¥¤¥¢¤Ë¤Ê¤Ã¤¿¡ª");
2219 msg_print("You become paranoid!");
2223 /* Duh, the following should never happen, but anyway... */
2224 if (p_ptr->muta3 & MUT3_FEARLESS)
2227 msg_print("¤¢¤Ê¤¿¤Ï¤â¤¦¶²¤ìÃΤ餺¤Ç¤Ï¤Ê¤¯¤Ê¤Ã¤¿¡£");
2229 msg_print("You are no longer fearless.");
2232 p_ptr->muta3 &= ~(MUT3_FEARLESS);
2235 p_ptr->muta2 |= MUT2_COWARDICE;
2249 if (!(p_ptr->muta2 & MUT2_HALLU) && !p_ptr->resist_chaos)
2252 msg_print("¸¸³Ð¤ò¤Ò¤µ¯¤³¤¹Àº¿ÀºøÍð¤Ë´Ù¤Ã¤¿¡ª");
2254 msg_print("You are afflicted by a hallucinatory insanity!");
2257 p_ptr->muta2 |= MUT2_HALLU;
2262 if (!(p_ptr->muta2 & MUT2_BERS_RAGE))
2265 msg_print("·ãÎõ¤Ê´¶¾ð¤Îȯºî¤Ë¤ª¤½¤ï¤ì¤ë¤è¤¦¤Ë¤Ê¤Ã¤¿¡ª");
2267 msg_print("You become subject to fits of berserk rage!");
2270 p_ptr->muta2 |= MUT2_BERS_RAGE;
2277 p_ptr->update |= PU_BONUS;
2283 * This function updates the monster record of the given monster
2285 * This involves extracting the distance to the player (if requested),
2286 * and then checking for visibility (natural, infravision, see-invis,
2287 * telepathy), updating the monster visibility flag, redrawing (or
2288 * erasing) the monster when its visibility changes, and taking note
2289 * of any interesting monster flags (cold-blooded, invisible, etc).
2291 * Note the new "mflag" field which encodes several monster state flags,
2292 * including "view" for when the monster is currently in line of sight,
2293 * and "mark" for when the monster is currently visible via detection.
2295 * The only monster fields that are changed here are "cdis" (the
2296 * distance from the player), "ml" (visible to the player), and
2297 * "mflag" (to maintain the "MFLAG_VIEW" flag).
2299 * Note the special "update_monsters()" function which can be used to
2300 * call this function once for every monster.
2302 * Note the "full" flag which requests that the "cdis" field be updated,
2303 * this is only needed when the monster (or the player) has moved.
2305 * Every time a monster moves, we must call this function for that
2306 * monster, and update the distance, and the visibility. Every time
2307 * the player moves, we must call this function for every monster, and
2308 * update the distance, and the visibility. Whenever the player "state"
2309 * changes in certain ways ("blindness", "infravision", "telepathy",
2310 * and "see invisible"), we must call this function for every monster,
2311 * and update the visibility.
2313 * Routines that change the "illumination" of a grid must also call this
2314 * function for any monster in that grid, since the "visibility" of some
2315 * monsters may be based on the illumination of their grid.
2317 * Note that this function is called once per monster every time the
2318 * player moves. When the player is running, this function is one
2319 * of the primary bottlenecks, along with "update_view()" and the
2320 * "process_monsters()" code, so efficiency is important.
2322 * Note the optimized "inline" version of the "distance()" function.
2324 * A monster is "visible" to the player if (1) it has been detected
2325 * by the player, (2) it is close to the player and the player has
2326 * telepathy, or (3) it is close to the player, and in line of sight
2327 * of the player, and it is "illuminated" by some combination of
2328 * infravision, torch light, or permanent light (invisible monsters
2329 * are only affected by "light" if the player can see invisible).
2331 * Monsters which are not on the current panel may be "visible" to
2332 * the player, and their descriptions will include an "offscreen"
2333 * reference. Currently, offscreen monsters cannot be targetted
2334 * or viewed directly, but old targets will remain set. XXX XXX
2336 * The player can choose to be disturbed by several things, including
2337 * "disturb_move" (monster which is viewable moves in some way), and
2338 * "disturb_near" (monster which is "easily" viewable moves in some
2339 * way). Note that "moves" includes "appears" and "disappears".
2341 void update_mon(int m_idx, bool full)
2343 monster_type *m_ptr = &m_list[m_idx];
2345 monster_race *r_ptr = &r_info[m_ptr->r_idx];
2347 bool do_disturb = disturb_move;
2351 /* Current location */
2358 /* Seen by vision */
2364 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
2366 if (ap_r_ptr->r_tkills && ap_r_ptr->level >= p_ptr->lev)
2370 /* Compute distance */
2373 /* Distance components */
2374 int dy = (py > fy) ? (py - fy) : (fy - py);
2375 int dx = (px > fx) ? (px - fx) : (fx - px);
2377 /* Approximate distance */
2378 d = (dy > dx) ? (dy + (dx>>1)) : (dx + (dy>>1));
2380 /* Restrict distance */
2381 if (d > 255) d = 255;
2385 /* Save the distance */
2389 /* Extract distance */
2392 /* Extract the distance */
2398 if (m_ptr->mflag2 & (MFLAG2_MARK)) flag = TRUE;
2402 if (d <= ((d_info[dungeon_type].flags1 & DF1_DARKNESS) ? MAX_SIGHT / 2 : MAX_SIGHT))
2404 if (!(d_info[dungeon_type].flags1 & DF1_DARKNESS) || (d <= MAX_SIGHT / 4))
2406 if (p_ptr->special_defense & KATA_MUSOU)
2411 /* Hack -- Memorize mental flags */
2412 if (r_ptr->flags2 & (RF2_SMART)) r_ptr->r_flags2 |= (RF2_SMART);
2413 if (r_ptr->flags2 & (RF2_STUPID)) r_ptr->r_flags2 |= (RF2_STUPID);
2416 /* Basic telepathy */
2417 else if (p_ptr->telepathy)
2419 /* Empty mind, no telepathy */
2420 if (r_ptr->flags2 & (RF2_EMPTY_MIND))
2422 /* Memorize flags */
2423 r_ptr->r_flags2 |= (RF2_EMPTY_MIND);
2426 /* Weird mind, occasional telepathy */
2427 else if (r_ptr->flags2 & (RF2_WEIRD_MIND))
2429 /* One in ten individuals are detectable */
2430 if ((m_idx % 10) == 5)
2435 /* Memorize flags */
2436 r_ptr->r_flags2 |= (RF2_WEIRD_MIND);
2438 /* Hack -- Memorize mental flags */
2439 if (r_ptr->flags2 & (RF2_SMART)) r_ptr->r_flags2 |= (RF2_SMART);
2440 if (r_ptr->flags2 & (RF2_STUPID)) r_ptr->r_flags2 |= (RF2_STUPID);
2444 /* Normal mind, allow telepathy */
2450 /* Hack -- Memorize mental flags */
2451 if (r_ptr->flags2 & (RF2_SMART)) r_ptr->r_flags2 |= (RF2_SMART);
2452 if (r_ptr->flags2 & (RF2_STUPID)) r_ptr->r_flags2 |= (RF2_STUPID);
2456 /* Magical sensing */
2457 if ((p_ptr->esp_animal) && (r_ptr->flags3 & (RF3_ANIMAL)))
2460 r_ptr->r_flags3 |= (RF3_ANIMAL);
2464 /* Magical sensing */
2465 if ((p_ptr->esp_undead) && (r_ptr->flags3 & (RF3_UNDEAD)))
2468 r_ptr->r_flags3 |= (RF3_UNDEAD);
2472 /* Magical sensing */
2473 if ((p_ptr->esp_demon) && (r_ptr->flags3 & (RF3_DEMON)))
2476 r_ptr->r_flags3 |= (RF3_DEMON);
2480 /* Magical sensing */
2481 if ((p_ptr->esp_orc) && (r_ptr->flags3 & (RF3_ORC)))
2484 r_ptr->r_flags3 |= (RF3_ORC);
2488 /* Magical sensing */
2489 if ((p_ptr->esp_troll) && (r_ptr->flags3 & (RF3_TROLL)))
2492 r_ptr->r_flags3 |= (RF3_TROLL);
2496 /* Magical sensing */
2497 if ((p_ptr->esp_giant) && (r_ptr->flags3 & (RF3_GIANT)))
2500 r_ptr->r_flags3 |= (RF3_GIANT);
2504 /* Magical sensing */
2505 if ((p_ptr->esp_dragon) && (r_ptr->flags3 & (RF3_DRAGON)))
2508 r_ptr->r_flags3 |= (RF3_DRAGON);
2512 /* Magical sensing */
2513 if ((p_ptr->esp_human) && (r_ptr->flags2 & (RF2_HUMAN)))
2516 r_ptr->r_flags2 |= (RF2_HUMAN);
2520 /* Magical sensing */
2521 if ((p_ptr->esp_evil) && (r_ptr->flags3 & (RF3_EVIL)))
2524 r_ptr->r_flags3 |= (RF3_EVIL);
2528 /* Magical sensing */
2529 if ((p_ptr->esp_good) && (r_ptr->flags3 & (RF3_GOOD)))
2532 r_ptr->r_flags3 |= (RF3_GOOD);
2536 /* Magical sensing */
2537 if ((p_ptr->esp_nonliving) &&
2538 (r_ptr->flags3 & (RF3_NONLIVING)) &&
2539 !(r_ptr->flags3 & (RF3_DEMON)) &&
2540 !(r_ptr->flags3 & (RF3_UNDEAD)))
2543 r_ptr->r_flags3 |= (RF3_NONLIVING);
2547 /* Magical sensing */
2548 if ((p_ptr->esp_unique) && (r_ptr->flags1 & (RF1_UNIQUE)))
2551 r_ptr->r_flags1 |= (RF1_UNIQUE);
2556 /* Normal line of sight, and not blind */
2557 if (player_has_los_bold(fy, fx) && !p_ptr->blind)
2559 bool do_invisible = FALSE;
2560 bool do_cold_blood = FALSE;
2562 /* Use "infravision" */
2563 if (d <= p_ptr->see_infra)
2565 /* Handle "cold blooded" monsters */
2566 if (r_ptr->flags2 & (RF2_COLD_BLOOD))
2569 do_cold_blood = TRUE;
2572 /* Handle "warm blooded" monsters */
2580 /* Use "illumination" */
2581 if (player_can_see_bold(fy, fx))
2583 /* Handle "invisible" monsters */
2584 if (r_ptr->flags2 & (RF2_INVISIBLE))
2587 do_invisible = TRUE;
2597 /* Handle "normal" monsters */
2608 /* Memorize flags */
2609 if (do_invisible) r_ptr->r_flags2 |= (RF2_INVISIBLE);
2610 if (do_cold_blood) r_ptr->r_flags2 |= (RF2_COLD_BLOOD);
2616 /* The monster is now visible */
2619 /* It was previously unseen */
2622 /* Mark as visible */
2625 /* Draw the monster */
2628 /* Update health bar as needed */
2629 if (p_ptr->health_who == m_idx) p_ptr->redraw |= (PR_HEALTH);
2630 if (p_ptr->riding == m_idx) p_ptr->redraw |= (PR_UHEALTH);
2632 /* Hack -- Count "fresh" sightings */
2633 if ((m_ptr->ap_r_idx == MON_KAGE) && (r_info[MON_KAGE].r_sights < MAX_SHORT))
2634 r_info[MON_KAGE].r_sights++;
2635 else if (m_ptr->ap_r_idx == m_ptr->r_idx &&
2636 r_ptr->r_sights < MAX_SHORT) r_ptr->r_sights++;
2638 /* Eldritch Horror */
2639 if (r_ptr->flags2 & RF2_ELDRITCH_HORROR)
2641 sanity_blast(m_ptr, FALSE);
2644 /* Disturb on appearance */
2645 if (disturb_near && (projectable(m_ptr->fy, m_ptr->fx, py, px) && projectable(py, px, m_ptr->fy, m_ptr->fx)))
2647 if (disturb_pets || is_hostile(m_ptr))
2653 /* The monster is not visible */
2656 /* It was previously seen */
2659 /* Mark as not visible */
2662 /* Erase the monster */
2665 /* Update health bar as needed */
2666 if (p_ptr->health_who == m_idx) p_ptr->redraw |= (PR_HEALTH);
2667 if (p_ptr->riding == m_idx) p_ptr->redraw |= (PR_UHEALTH);
2669 /* Disturb on disappearance */
2672 if (disturb_pets || is_hostile(m_ptr))
2679 /* The monster is now easily visible */
2683 if (!(m_ptr->mflag & (MFLAG_VIEW)))
2685 /* Mark as easily visible */
2686 m_ptr->mflag |= (MFLAG_VIEW);
2688 /* Disturb on appearance */
2691 if (disturb_pets || is_hostile(m_ptr))
2697 /* The monster is not easily visible */
2701 if (m_ptr->mflag & (MFLAG_VIEW))
2703 /* Mark as not easily visible */
2704 m_ptr->mflag &= ~(MFLAG_VIEW);
2706 /* Disturb on disappearance */
2709 if (disturb_pets || is_hostile(m_ptr))
2718 * This function simply updates all the (non-dead) monsters (see above).
2720 void update_monsters(bool full)
2724 /* Update each (live) monster */
2725 for (i = 1; i < m_max; i++)
2727 monster_type *m_ptr = &m_list[i];
2729 /* Skip dead monsters */
2730 if (!m_ptr->r_idx) continue;
2732 /* Update the monster */
2733 update_mon(i, full);
2739 * Hack -- the index of the summoning monster
2741 static bool monster_hook_chameleon_lord(int r_idx)
2743 monster_race *r_ptr = &r_info[r_idx];
2744 monster_type *m_ptr = &m_list[chameleon_change_m_idx];
2745 monster_race *old_r_ptr = &r_info[m_ptr->r_idx];
2747 if (!(r_ptr->flags1 & (RF1_UNIQUE))) return FALSE;
2748 if (r_ptr->flags7 & (RF7_FRIENDLY | RF7_CHAMELEON)) return FALSE;
2750 if (ABS(r_ptr->level - r_info[MON_CHAMELEON_K].level) > 5) return FALSE;
2752 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))
2755 if (!monster_can_cross_terrain(cave[m_ptr->fy][m_ptr->fx].feat, r_ptr)) return FALSE;
2758 if (!(old_r_ptr->flags7 & RF7_CHAMELEON))
2760 if ((m_ptr->sub_align & SUB_ALIGN_EVIL) && (r_ptr->flags3 & RF3_GOOD)) return FALSE;
2761 if ((m_ptr->sub_align & SUB_ALIGN_GOOD) && (r_ptr->flags3 & RF3_EVIL)) return FALSE;
2765 else if (summon_specific_who > 0)
2767 monster_type *sm_ptr = &m_list[summon_specific_who];
2769 if ((sm_ptr->sub_align & SUB_ALIGN_EVIL) && (r_ptr->flags3 & RF3_GOOD)) return FALSE;
2770 if ((sm_ptr->sub_align & SUB_ALIGN_GOOD) && (r_ptr->flags3 & RF3_EVIL)) return FALSE;
2776 static bool monster_hook_chameleon(int r_idx)
2778 monster_race *r_ptr = &r_info[r_idx];
2779 monster_type *m_ptr = &m_list[chameleon_change_m_idx];
2780 monster_race *old_r_ptr = &r_info[m_ptr->r_idx];
2782 if (r_ptr->flags1 & (RF1_UNIQUE)) return FALSE;
2783 if (r_ptr->flags2 & RF2_MULTIPLY) return FALSE;
2784 if (r_ptr->flags7 & (RF7_FRIENDLY | RF7_CHAMELEON)) return FALSE;
2786 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))
2789 if (!monster_can_cross_terrain(cave[m_ptr->fy][m_ptr->fx].feat, r_ptr)) return FALSE;
2792 if (!(old_r_ptr->flags7 & RF7_CHAMELEON))
2794 if ((old_r_ptr->flags3 & RF3_GOOD) && !(r_ptr->flags3 & RF3_GOOD)) return FALSE;
2795 if ((old_r_ptr->flags3 & RF3_EVIL) && !(r_ptr->flags3 & RF3_EVIL)) return FALSE;
2796 if (!(old_r_ptr->flags3 & (RF3_GOOD | RF3_EVIL)) && (r_ptr->flags3 & (RF3_GOOD | RF3_EVIL))) return FALSE;
2800 else if (summon_specific_who > 0)
2802 monster_type *sm_ptr = &m_list[summon_specific_who];
2804 if ((sm_ptr->sub_align & SUB_ALIGN_EVIL) && (r_ptr->flags3 & RF3_GOOD)) return FALSE;
2805 if ((sm_ptr->sub_align & SUB_ALIGN_GOOD) && (r_ptr->flags3 & RF3_EVIL)) return FALSE;
2808 return (*(get_monster_hook()))(r_idx);
2812 void choose_new_monster(int m_idx, bool born, int r_idx)
2815 monster_type *m_ptr = &m_list[m_idx];
2816 monster_race *r_ptr;
2817 char old_m_name[80];
2818 bool old_unique = FALSE;
2820 if (r_info[m_ptr->r_idx].flags1 & RF1_UNIQUE)
2822 if (old_unique && (r_idx == MON_CHAMELEON)) r_idx = MON_CHAMELEON_K;
2823 r_ptr = &r_info[r_idx];
2825 monster_desc(old_m_name, m_ptr, 0);
2831 chameleon_change_m_idx = m_idx;
2833 get_mon_num_prep(monster_hook_chameleon_lord, NULL);
2835 get_mon_num_prep(monster_hook_chameleon, NULL);
2838 level = r_info[MON_CHAMELEON_K].level;
2839 else if (!dun_level)
2840 level = wilderness[p_ptr->wilderness_y][p_ptr->wilderness_x].level;
2844 if (d_info[dungeon_type].flags1 & DF1_CHAMELEON) level+= 2+randint1(3);
2846 r_idx = get_mon_num(level);
2847 r_ptr = &r_info[r_idx];
2849 chameleon_change_m_idx = 0;
2855 m_ptr->r_idx = r_idx;
2856 m_ptr->ap_r_idx = r_idx;
2857 update_mon(m_idx, FALSE);
2858 lite_spot(m_ptr->fy, m_ptr->fx);
2861 /* Sub-alignment of a chameleon */
2862 if (r_ptr->flags3 & (RF3_EVIL | RF3_GOOD))
2864 m_ptr->sub_align = SUB_ALIGN_NEUTRAL;
2865 if (r_ptr->flags3 & RF3_EVIL) m_ptr->sub_align |= SUB_ALIGN_EVIL;
2866 if (r_ptr->flags3 & RF3_GOOD) m_ptr->sub_align |= SUB_ALIGN_GOOD;
2871 if (m_idx == p_ptr->riding)
2874 monster_desc(m_name, m_ptr, 0);
2876 msg_format("ÆÍÁ³%s¤¬ÊѿȤ·¤¿¡£", old_m_name);
2878 msg_format("Suddenly, %s transforms!", old_m_name);
2880 if (!(r_ptr->flags7 & RF7_RIDING))
2882 if (rakuba(0, TRUE)) msg_print("ÃÏÌ̤ËÍî¤È¤µ¤ì¤¿¡£");
2884 if (rakuba(0, TRUE)) msg_format("You have fallen from %s.", m_name);
2888 /* Extract the monster base speed */
2889 m_ptr->mspeed = get_mspeed(r_ptr);
2891 oldmaxhp = m_ptr->max_maxhp;
2892 /* Assign maximal hitpoints */
2893 if (r_ptr->flags1 & RF1_FORCE_MAXHP)
2895 m_ptr->max_maxhp = maxroll(r_ptr->hdice, r_ptr->hside);
2899 m_ptr->max_maxhp = damroll(r_ptr->hdice, r_ptr->hside);
2901 m_ptr->maxhp = (long)(m_ptr->maxhp * m_ptr->max_maxhp) / oldmaxhp;
2902 m_ptr->hp = (long)(m_ptr->hp * m_ptr->max_maxhp) / oldmaxhp;
2909 static bool monster_hook_tanuki(int r_idx)
2911 monster_race *r_ptr = &r_info[r_idx];
2913 if (r_ptr->flags1 & (RF1_UNIQUE)) return FALSE;
2914 if (r_ptr->flags2 & RF2_MULTIPLY) return FALSE;
2915 if (r_ptr->flags7 & (RF7_FRIENDLY | RF7_CHAMELEON)) return FALSE;
2916 if (r_ptr->flags7 & RF7_AQUATIC) return FALSE;
2918 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))
2921 return (*(get_monster_hook()))(r_idx);
2926 * Set initial racial appearance of a monster
2928 static int initial_r_appearance(int r_idx)
2930 int attempts = 1000;
2933 int min = MIN(base_level-5, 50);
2935 if (!(r_info[r_idx].flags7 & RF7_TANUKI))
2938 get_mon_num_prep(monster_hook_tanuki, NULL);
2942 ap_r_idx = get_mon_num(base_level + 10);
2943 if (r_info[ap_r_idx].level >= min) return ap_r_idx;
2951 * Get initial monster speed
2953 byte get_mspeed(monster_race *r_ptr)
2955 /* Extract the monster base speed */
2956 int mspeed = r_ptr->speed;
2958 /* Hack -- small racial variety */
2959 if (!(r_ptr->flags1 & RF1_UNIQUE) && !p_ptr->inside_arena)
2961 /* Allow some small variation per monster */
2962 int i = SPEED_TO_ENERGY(r_ptr->speed) / (one_in_(4) ? 3 : 10);
2963 if (i) mspeed += rand_spread(0, i);
2966 if (mspeed > 199) mspeed = 199;
2968 return (byte)mspeed;
2973 * Attempt to place a monster of the given race at the given location.
2975 * To give the player a sporting chance, any monster that appears in
2976 * line-of-sight and is extremely dangerous can be marked as
2977 * "FORCE_SLEEP", which will cause them to be placed with low energy,
2978 * which often (but not always) lets the player move before they do.
2980 * This routine refuses to place out-of-depth "FORCE_DEPTH" monsters.
2982 * XXX XXX XXX Use special "here" and "dead" flags for unique monsters,
2983 * remove old "cur_num" and "max_num" fields.
2985 * XXX XXX XXX Actually, do something similar for artifacts, to simplify
2986 * the "preserve" mode, and to make the "what artifacts" flag more useful.
2988 * This is the only function which may place a monster in the dungeon,
2989 * except for the savefile loading code.
2991 bool place_monster_one(int who, int y, int x, int r_idx, u32b mode)
2995 monster_type *m_ptr;
2997 monster_race *r_ptr = &r_info[r_idx];
2999 cptr name = (r_name + r_ptr->name);
3001 /* DO NOT PLACE A MONSTER IN THE SMALL SCALE WILDERNESS !!! */
3002 if(p_ptr->wild_mode) return FALSE;
3004 /* Verify location */
3005 if (!in_bounds(y, x)) return (FALSE);
3007 /* Require empty space (if not ghostly) */
3008 if (!(!dun_level && (cave[y][x].feat == FEAT_MOUNTAIN) && ((r_ptr->flags8 & RF8_WILD_MOUNTAIN) || (r_ptr->flags7 & RF7_CAN_FLY))) &&
3009 !(cave_empty_bold2(y, x) || (mode & PM_IGNORE_TERRAIN)) &&
3010 !((r_ptr->flags2 & RF2_PASS_WALL) &&
3011 !(cave_perma_bold(y, x) || cave[y][x].m_idx ||
3012 ((y == py) && (x == px))))) return (FALSE);
3015 if (!r_idx) return (FALSE);
3018 if (!r_ptr->name) return (FALSE);
3020 /* Nor on the Pattern */
3021 if ((cave[y][x].feat >= FEAT_PATTERN_START)
3022 && (cave[y][x].feat <= FEAT_PATTERN_XTRA2))
3025 if (!(mode & PM_IGNORE_TERRAIN) &&
3026 !monster_can_cross_terrain(cave[y][x].feat, r_ptr))
3031 if (!p_ptr->inside_battle)
3033 /* Hack -- "unique" monsters must be "unique" */
3034 if (((r_ptr->flags1 & (RF1_UNIQUE)) ||
3035 (r_ptr->flags7 & (RF7_UNIQUE_7))) &&
3036 (r_ptr->cur_num >= r_ptr->max_num))
3042 if ((r_ptr->flags7 & (RF7_UNIQUE2)) &&
3043 (r_ptr->cur_num >= 1))
3048 if (r_idx == MON_BANORLUPART)
3050 if (r_info[MON_BANOR].cur_num > 0) return FALSE;
3051 if (r_info[MON_LUPART].cur_num > 0) return FALSE;
3054 /* Depth monsters may NOT be created out of depth, unless in Nightmare mode */
3055 if ((r_ptr->flags1 & (RF1_FORCE_DEPTH)) && (dun_level < r_ptr->level) &&
3056 (!ironman_nightmare || (r_ptr->flags1 & (RF1_QUESTOR))))
3063 if(quest_number(dun_level))
3065 int hoge = quest_number(dun_level);
3066 if((quest[hoge].type == QUEST_TYPE_KILL_LEVEL) || (quest[hoge].type == QUEST_TYPE_RANDOM))
3068 if(r_idx == quest[hoge].r_idx)
3070 int number_mon, i2, j2;
3073 /* Count all quest monsters */
3074 for (i2 = 0; i2 < cur_wid; ++i2)
3075 for (j2 = 0; j2 < cur_hgt; j2++)
3076 if (cave[j2][i2].m_idx > 0)
3077 if (m_list[cave[j2][i2].m_idx].r_idx == quest[hoge].r_idx)
3079 if(number_mon + quest[hoge].cur_num >= quest[hoge].max_num)
3085 /* Access the location */
3086 c_ptr = &cave[y][x];
3088 if (is_glyph_grid(c_ptr))
3090 if (randint1(BREAK_GLYPH) < (r_ptr->level+20))
3092 /* Describe observable breakage */
3093 if (c_ptr->info & CAVE_MARK)
3096 msg_print("¼é¤ê¤Î¥ë¡¼¥ó¤¬²õ¤ì¤¿¡ª");
3098 msg_print("The rune of protection is broken!");
3103 /* Forget the rune */
3104 c_ptr->info &= ~(CAVE_MARK);
3106 /* Break the rune */
3107 c_ptr->info &= ~(CAVE_OBJECT);
3116 /* Powerful monster */
3117 if (r_ptr->level > dun_level)
3119 /* Unique monsters */
3120 if (r_ptr->flags1 & (RF1_UNIQUE))
3122 /* Message for cheaters */
3124 if (cheat_hear) msg_format("¿¼ÁؤΥæ¥Ë¡¼¥¯¡¦¥â¥ó¥¹¥¿¡¼ (%s)¡£", name);
3126 if (cheat_hear) msg_format("Deep Unique (%s).", name);
3130 /* Boost rating by twice delta-depth */
3131 rating += (r_ptr->level - dun_level) * 2;
3134 /* Normal monsters */
3137 /* Message for cheaters */
3139 if (cheat_hear) msg_format("¿¼ÁؤΥâ¥ó¥¹¥¿¡¼ (%s)¡£", name);
3141 if (cheat_hear) msg_format("Deep Monster (%s).", name);
3145 /* Boost rating by delta-depth */
3146 rating += (r_ptr->level - dun_level);
3150 /* Note the monster */
3151 else if (r_ptr->flags1 & (RF1_UNIQUE))
3153 /* Unique monsters induce message */
3155 if (cheat_hear) msg_format("¥æ¥Ë¡¼¥¯¡¦¥â¥ó¥¹¥¿¡¼ (%s)¡£", name);
3157 if (cheat_hear) msg_format("Unique (%s).", name);
3162 if ((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags7 & RF7_UNIQUE_7) || (r_ptr->level < 10)) is_kage = FALSE;
3164 /* Make a new monster */
3165 c_ptr->m_idx = m_pop();
3166 hack_m_idx_ii = c_ptr->m_idx;
3168 /* Mega-Hack -- catch "failure" */
3169 if (!c_ptr->m_idx) return (FALSE);
3172 /* Get a new monster record */
3173 m_ptr = &m_list[c_ptr->m_idx];
3176 m_ptr->r_idx = r_idx;
3177 m_ptr->ap_r_idx = initial_r_appearance(r_idx);
3179 /* Sub-alignment of a monster */
3180 if ((who > 0) && !(r_ptr->flags3 & (RF3_EVIL | RF3_GOOD)))
3181 m_ptr->sub_align = m_list[who].sub_align;
3184 m_ptr->sub_align = SUB_ALIGN_NEUTRAL;
3185 if (r_ptr->flags3 & RF3_EVIL) m_ptr->sub_align |= SUB_ALIGN_EVIL;
3186 if (r_ptr->flags3 & RF3_GOOD) m_ptr->sub_align |= SUB_ALIGN_GOOD;
3189 /* Place the monster at the location */
3194 /* No "damage" yet */
3196 m_ptr->confused = 0;
3199 /* Unknown distance */
3202 reset_target(m_ptr);
3204 m_ptr->nickname = 0;
3212 if (r_ptr->flags7 & RF7_CHAMELEON)
3214 choose_new_monster(c_ptr->m_idx, TRUE, 0);
3215 r_ptr = &r_info[m_ptr->r_idx];
3216 m_ptr->mflag2 |= MFLAG2_CHAMELEON;
3219 /* Hack - Set sub_align to neutral when the Chameleon Lord is generated as "GUARDIAN" */
3220 if ((r_ptr->flags1 & RF1_UNIQUE) && (who <= 0))
3221 m_ptr->sub_align = SUB_ALIGN_NEUTRAL;
3225 m_ptr->ap_r_idx = MON_KAGE;
3226 m_ptr->mflag2 |= MFLAG2_KAGE;
3229 if (mode & PM_NO_PET) m_ptr->mflag2 |= MFLAG2_NOPET;
3235 if (mode & PM_FORCE_PET)
3240 else if ((r_ptr->flags7 & RF7_FRIENDLY) ||
3241 (mode & PM_FORCE_FRIENDLY) || is_friendly_idx(who))
3243 if (!(p_ptr->align >= 0 && (r_ptr->flags3 & RF3_EVIL)) &&
3244 !(p_ptr->align < 0 && (r_ptr->flags3 & RF3_GOOD)))
3246 set_friendly(m_ptr);
3250 /* Assume no sleeping */
3253 /* Enforce sleeping if needed */
3254 if ((mode & PM_ALLOW_SLEEP) && r_ptr->sleep && !ironman_nightmare)
3256 int val = r_ptr->sleep;
3257 m_ptr->csleep = ((val * 2) + randint1(val * 10));
3260 /* Assign maximal hitpoints */
3261 if (r_ptr->flags1 & RF1_FORCE_MAXHP)
3263 m_ptr->max_maxhp = maxroll(r_ptr->hdice, r_ptr->hside);
3267 m_ptr->max_maxhp = damroll(r_ptr->hdice, r_ptr->hside);
3270 /* Monsters have double hitpoints in Nightmare mode */
3271 if (ironman_nightmare)
3273 u32b hp = m_ptr->max_maxhp * 2L;
3275 m_ptr->max_maxhp = (s16b)MIN(30000, hp);
3278 m_ptr->maxhp = m_ptr->max_maxhp;
3280 /* And start out fully healthy */
3281 if (m_ptr->r_idx == MON_WOUNDED_BEAR)
3282 m_ptr->hp = m_ptr->maxhp / 2;
3283 else m_ptr->hp = m_ptr->maxhp;
3286 /* Extract the monster base speed */
3287 m_ptr->mspeed = get_mspeed(r_ptr);
3289 if (mode & PM_HASTE) m_ptr->fast = 100;
3291 /* Give a random starting energy */
3292 if (!ironman_nightmare)
3294 m_ptr->energy_need = ENERGY_NEED() - (s16b)randint0(100);
3298 /* Nightmare monsters are more prepared */
3299 m_ptr->energy_need = ENERGY_NEED() - (s16b)randint0(100) * 2;
3302 /* Force monster to wait for player, unless in Nightmare mode */
3303 if ((r_ptr->flags1 & RF1_FORCE_SLEEP) && !ironman_nightmare)
3305 /* Monster is still being nice */
3306 m_ptr->mflag |= (MFLAG_NICE);
3308 /* Must repair monsters */
3309 repair_monsters = TRUE;
3312 /* Hack -- see "process_monsters()" */
3313 if (c_ptr->m_idx < hack_m_idx)
3315 /* Monster is still being born */
3316 m_ptr->mflag |= (MFLAG_BORN);
3320 /* Update the monster */
3321 update_mon(c_ptr->m_idx, TRUE);
3324 /* Count the monsters on the level */
3325 real_r_ptr(m_ptr)->cur_num++;
3328 * Memorize location of the unique monster in saved floors.
3329 * A unique monster move from old saved floor.
3331 if (character_dungeon &&
3332 ((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags7 & RF7_UNIQUE_7)))
3333 real_r_ptr(m_ptr)->floor_id = p_ptr->floor_id;
3335 /* Hack -- Count the number of "reproducers" */
3336 if (r_ptr->flags2 & RF2_MULTIPLY) num_repro++;
3339 /* Hack -- Notice new multi-hued monsters */
3341 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
3342 if ((ap_r_ptr->flags1 & RF1_ATTR_MULTI) || (ap_r_ptr->flags2 & RF2_SHAPECHANGER))
3343 shimmer_monsters = TRUE;
3346 if (p_ptr->warning && character_dungeon)
3348 if (r_ptr->flags1 & RF1_UNIQUE)
3352 char o_name[MAX_NLEN];
3354 if (r_ptr->level > p_ptr->lev + 30)
3360 else if (r_ptr->level > p_ptr->lev + 15)
3366 else if (r_ptr->level > p_ptr->lev + 5)
3368 color = "¥ë¥Ó¡¼¿§¤Ë";
3372 else if (r_ptr->level > p_ptr->lev - 5)
3378 else if (r_ptr->level > p_ptr->lev - 15)
3380 color = "¥Ô¥ó¥¯¿§¤Ë";
3391 o_ptr = choose_warning_item();
3392 object_desc(o_name, o_ptr, FALSE, 0);
3394 msg_format("%s¤Ï%s¸÷¤Ã¤¿¡£",o_name, color);
3396 msg_format("%s glows %s.",o_name, color);
3401 if (is_explosive_rune_grid(c_ptr))
3403 /* Break the ward */
3404 if (randint1(BREAK_MINOR_GLYPH) > r_ptr->level)
3406 /* Describe observable breakage */
3407 if (c_ptr->info & CAVE_MARK)
3410 msg_print("¥ë¡¼¥ó¤¬Çúȯ¤·¤¿¡ª");
3412 msg_print("The rune explodes!");
3415 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);
3421 msg_print("Çúȯ¤Î¥ë¡¼¥ó¤Ï²ò½ü¤µ¤ì¤¿¡£");
3423 msg_print("An explosive rune was disarmed.");
3427 /* Forget the rune */
3428 c_ptr->info &= ~(CAVE_MARK);
3430 /* Break the rune */
3431 c_ptr->info &= ~(CAVE_OBJECT);
3444 * improved version of scatter() for place monster
3447 #define MON_SCAT_MAXD 10
3449 static bool mon_scatter(int *yp, int *xp, int y, int x, int max_dist)
3451 int place_x[MON_SCAT_MAXD];
3452 int place_y[MON_SCAT_MAXD];
3453 int num[MON_SCAT_MAXD];
3457 if (max_dist >= MON_SCAT_MAXD)
3460 for (i = 0; i < MON_SCAT_MAXD; i++)
3463 for (nx = x - max_dist; nx <= x + max_dist; nx++)
3464 for (ny = y - max_dist; ny <= y + max_dist; ny++)
3466 /* Ignore annoying locations */
3467 if (!in_bounds(ny, nx)) continue;
3469 /* Require "line of sight" */
3470 if (!los(y, x, ny, nx)) continue;
3472 /* Walls and Monsters block flow */
3473 if (!cave_empty_bold2(ny, nx)) continue;
3474 if (cave[ny][nx].m_idx) continue;
3475 if ((ny == py) && (nx == px)) continue;
3477 /* ... nor on the Pattern */
3478 if ((cave[ny][nx].feat >= FEAT_PATTERN_START) &&
3479 (cave[ny][nx].feat <= FEAT_PATTERN_XTRA2))
3482 i = distance(y, x, ny, nx);
3499 while (i < MON_SCAT_MAXD && 0 == num[i])
3501 if (i >= MON_SCAT_MAXD)
3512 * Maximum size of a group of monsters
3514 #define GROUP_MAX 32
3518 * Attempt to place a "group" of monsters around the given location
3520 static bool place_monster_group(int who, int y, int x, int r_idx, u32b mode)
3522 monster_race *r_ptr = &r_info[r_idx];
3525 int total = 0, extra = 0;
3529 byte hack_y[GROUP_MAX];
3530 byte hack_x[GROUP_MAX];
3533 /* Pick a group size */
3534 total = randint1(10);
3536 /* Hard monsters, small groups */
3537 if (r_ptr->level > dun_level)
3539 extra = r_ptr->level - dun_level;
3540 extra = 0 - randint1(extra);
3543 /* Easy monsters, large groups */
3544 else if (r_ptr->level < dun_level)
3546 extra = dun_level - r_ptr->level;
3547 extra = randint1(extra);
3550 /* Hack -- limit group reduction */
3551 if (extra > 9) extra = 9;
3553 /* Modify the group size */
3557 if (total < 1) total = 1;
3560 if (total > GROUP_MAX) total = GROUP_MAX;
3563 /* Save the rating */
3566 /* Start on the monster */
3571 /* Puddle monsters, breadth first, up to total */
3572 for (n = 0; (n < hack_n) && (hack_n < total); n++)
3574 /* Grab the location */
3578 /* Check each direction, up to total */
3579 for (i = 0; (i < 8) && (hack_n < total); i++)
3583 scatter(&my, &mx, hy, hx, 4, 0);
3585 /* Walls and Monsters block flow */
3586 if (!cave_empty_bold2(my, mx)) continue;
3588 /* Attempt to place another monster */
3589 if (place_monster_one(who, my, mx, r_idx, mode))
3591 /* Add it to the "hack" set */
3592 hack_y[hack_n] = my;
3593 hack_x[hack_n] = mx;
3599 /* Hack -- restore the rating */
3609 * Hack -- help pick an escort type
3611 static int place_monster_idx = 0;
3612 static int place_monster_m_idx = 0;
3615 * Hack -- help pick an escort type
3617 static bool place_monster_okay(int r_idx)
3619 monster_race *r_ptr = &r_info[place_monster_idx];
3620 monster_type *m_ptr = &m_list[place_monster_m_idx];
3622 monster_race *z_ptr = &r_info[r_idx];
3624 /* Hack - Escorts have to have the same dungeon flag */
3625 if (monster_dungeon(place_monster_idx) != monster_dungeon(r_idx)) return (FALSE);
3627 /* Require similar "race" */
3628 if (z_ptr->d_char != r_ptr->d_char) return (FALSE);
3630 /* Skip more advanced monsters */
3631 if (z_ptr->level > r_ptr->level) return (FALSE);
3633 /* Skip unique monsters */
3634 if (z_ptr->flags1 & RF1_UNIQUE) return (FALSE);
3636 /* Paranoia -- Skip identical monsters */
3637 if (place_monster_idx == r_idx) return (FALSE);
3639 /* Skip different alignment */
3640 if (((m_ptr->sub_align & SUB_ALIGN_EVIL) && (z_ptr->flags3 & RF3_GOOD)) ||
3641 ((m_ptr->sub_align & SUB_ALIGN_GOOD) && (z_ptr->flags3 & RF3_EVIL)))
3644 if (r_ptr->flags7 & RF7_FRIENDLY)
3646 if (((p_ptr->align < 0) && (z_ptr->flags3 & RF3_GOOD)) ||
3647 ((p_ptr->align > 0) && (z_ptr->flags3 & RF3_EVIL)))
3651 if ((r_ptr->flags7 & RF7_CHAMELEON) && !(z_ptr->flags7 & RF7_CHAMELEON))
3660 * Attempt to place a monster of the given race at the given location
3662 * Note that certain monsters are now marked as requiring "friends".
3663 * These monsters, if successfully placed, and if the "grp" parameter
3664 * is TRUE, will be surrounded by a "group" of identical monsters.
3666 * Note that certain monsters are now marked as requiring an "escort",
3667 * which is a collection of monsters with similar "race" but lower level.
3669 * Some monsters induce a fake "group" flag on their escorts.
3671 * Note the "bizarre" use of non-recursion to prevent annoying output
3672 * when running a code profiler.
3674 * Note the use of the new "monster allocation table" code to restrict
3675 * the "get_mon_num()" function to "legal" escort types.
3677 bool place_monster_aux(int who, int y, int x, int r_idx, u32b mode)
3680 monster_race *r_ptr = &r_info[r_idx];
3682 if (one_in_(333) && !(mode & PM_NO_KAGE) && !(mode & PM_FORCE_PET))
3687 /* Place one monster, or fail */
3688 if (!place_monster_one(who, y, x, r_idx, mode)) return (FALSE);
3691 /* Require the "group" flag */
3692 if (!(mode & PM_ALLOW_GROUP)) return (TRUE);
3694 place_monster_m_idx = hack_m_idx_ii;
3696 /* Friends for certain monsters */
3697 if (r_ptr->flags1 & (RF1_FRIENDS))
3699 /* Attempt to place a group */
3700 (void)place_monster_group(who, y, x, r_idx, mode);
3704 /* Escorts for certain monsters */
3705 if (r_ptr->flags1 & (RF1_ESCORT))
3707 /* Set the escort index */
3708 place_monster_idx = r_idx;
3710 /* Try to place several "escorts" */
3711 for (i = 0; i < 32; i++)
3713 int nx, ny, z, d = 3;
3715 /* Pick a location */
3716 scatter(&ny, &nx, y, x, d, 0);
3718 /* Require empty grids */
3719 if (!cave_empty_bold2(ny, nx)) continue;
3721 /* Prepare allocation table */
3722 get_mon_num_prep(place_monster_okay, get_monster_hook2(ny, nx));
3724 /* Pick a random race */
3725 z = get_mon_num(r_ptr->level);
3727 /* Handle failure */
3730 /* Place a single escort */
3731 (void)place_monster_one(place_monster_m_idx, ny, nx, z, mode);
3733 /* Place a "group" of escorts if needed */
3734 if ((r_info[z].flags1 & RF1_FRIENDS) ||
3735 (r_ptr->flags1 & RF1_ESCORTS))
3737 /* Place a group of monsters */
3738 (void)place_monster_group(place_monster_m_idx, ny, nx, z, mode);
3749 * Hack -- attempt to place a monster at the given location
3751 * Attempt to find a monster appropriate to the "monster_level"
3753 bool place_monster(int y, int x, u32b mode)
3757 /* Prepare allocation table */
3758 get_mon_num_prep(get_monster_hook(), get_monster_hook2(y, x));
3760 /* Pick a monster */
3761 r_idx = get_mon_num(monster_level);
3763 /* Handle failure */
3764 if (!r_idx) return (FALSE);
3766 /* Attempt to place the monster */
3767 if (place_monster_aux(0, y, x, r_idx, mode)) return (TRUE);
3774 #ifdef MONSTER_HORDES
3776 bool alloc_horde(int y, int x)
3778 monster_race *r_ptr = NULL;
3781 int attempts = 1000;
3785 /* Prepare allocation table */
3786 get_mon_num_prep(get_monster_hook(), get_monster_hook2(y, x));
3790 /* Pick a monster */
3791 r_idx = get_mon_num(monster_level);
3793 /* Handle failure */
3794 if (!r_idx) return (FALSE);
3796 r_ptr = &r_info[r_idx];
3798 if (r_ptr->flags1 & RF1_UNIQUE) continue;
3800 if (r_idx == MON_HAGURE) continue;
3803 if (attempts < 1) return FALSE;
3809 /* Attempt to place the monster */
3810 if (place_monster_aux(0, y, x, r_idx, 0L)) break;
3813 if (attempts < 1) return FALSE;
3815 m_idx = cave[y][x].m_idx;
3817 if (m_list[m_idx].mflag2 & MFLAG2_CHAMELEON) r_ptr = &r_info[m_list[m_idx].r_idx];
3818 summon_kin_type = r_ptr->d_char;
3820 for (attempts = randint1(10) + 5; attempts; attempts--)
3822 scatter(&cy, &cx, y, x, 5, 0);
3824 (void)summon_specific(m_idx, cy, cx, dun_level + 5, SUMMON_KIN, PM_ALLOW_GROUP);
3833 #endif /* MONSTER_HORDES */
3838 * Attempt to allocate a random monster in the dungeon.
3840 * Place the monster at least "dis" distance from the player.
3842 * Use "slp" to choose the initial "sleep" status
3844 * Use "monster_level" for the monster level
3846 bool alloc_monster(int dis, u32b mode)
3849 int attempts_left = 10000;
3850 int guardian = d_info[dungeon_type].final_guardian;
3852 /* Put an Guardian */
3853 if(guardian && d_info[dungeon_type].maxdepth == dun_level && r_info[guardian].cur_num < r_info[guardian].max_num )
3859 /* Find a good position */
3862 /* Get a random spot */
3863 oy = randint1(cur_hgt - 4) + 2;
3864 ox = randint1(cur_wid - 4) + 2;
3866 /* Is it a good spot ? */
3867 if (cave_empty_bold2(oy, ox) && monster_can_cross_terrain(cave[oy][ox].feat, &r_info[guardian]))
3869 /* Place the guardian */
3870 if (place_monster_aux(0, oy, ox, guardian, (PM_ALLOW_GROUP | PM_NO_KAGE | PM_NO_PET))) break;
3878 /* Find a legal, distant, unoccupied, space */
3879 while (attempts_left--)
3881 /* Pick a location */
3882 y = randint0(cur_hgt);
3883 x = randint0(cur_wid);
3885 /* Require empty floor grid (was "naked") */
3886 if (dun_level || (wilderness[p_ptr->wilderness_y][p_ptr->wilderness_x].terrain != TERRAIN_MOUNTAIN))
3888 if (!cave_empty_bold2(y, x)) continue;
3892 if (!cave_empty_bold2(y, x) && (cave[y][x].feat != FEAT_MOUNTAIN)) continue;
3895 /* Accept far away grids */
3896 if (distance(y, x, py, px) > dis) break;
3901 if (cheat_xtra || cheat_hear)
3904 msg_print("·Ù¹ð¡ª¿·¤¿¤Ê¥â¥ó¥¹¥¿¡¼¤òÇÛÃ֤Ǥ¤Þ¤»¤ó¡£¾®¤µ¤¤³¬¤Ç¤¹¤«¡©");
3906 msg_print("Warning! Could not allocate a new monster. Small level?");
3915 #ifdef MONSTER_HORDES
3916 if (randint1(5000) <= dun_level)
3918 if (alloc_horde(y, x))
3921 if (cheat_hear) msg_print("¥â¥ó¥¹¥¿¡¼¤ÎÂç·²");
3923 if (cheat_hear) msg_print("Monster horde.");
3931 #endif /* MONSTER_HORDES */
3933 /* Attempt to place the monster, allow groups */
3934 if (place_monster(y, x, (mode | PM_ALLOW_GROUP))) return (TRUE);
3936 #ifdef MONSTER_HORDES
3938 #endif /* MONSTER_HORDES */
3948 * Hack -- help decide if a monster race is "okay" to summon
3950 static bool summon_specific_okay(int r_idx)
3952 monster_race *r_ptr = &r_info[r_idx];
3954 /* Hack - Only summon dungeon monsters */
3955 if (!monster_dungeon(r_idx)) return (FALSE);
3957 /* Hack -- identify the summoning monster */
3958 if (summon_specific_who > 0)
3960 monster_type *m_ptr = &m_list[summon_specific_who];
3962 /* Do not summon enemies */
3964 /* Friendly vs. opposite aligned normal or pet */
3965 if (((r_ptr->flags3 & RF3_EVIL) &&
3966 (m_ptr->sub_align & SUB_ALIGN_GOOD)) ||
3967 ((r_ptr->flags3 & RF3_GOOD) &&
3968 (m_ptr->sub_align & SUB_ALIGN_EVIL)))
3973 /* Hostile vs. non-hostile */
3974 if (is_hostile(m_ptr) != summon_specific_hostile)
3979 /* Use the player's alignment */
3980 else if (summon_specific_who < 0)
3982 /* Do not summon enemies of the pets */
3983 if ((p_ptr->align < -9) && (r_ptr->flags3 & RF3_GOOD))
3985 if (!one_in_((0-p_ptr->align)/2+1)) return FALSE;
3987 else if ((p_ptr->align > 9) && (r_ptr->flags3 & RF3_EVIL))
3989 if (!one_in_(p_ptr->align/2+1)) return FALSE;
3993 /* Hack -- no specific type specified */
3994 if (!summon_specific_type) return (TRUE);
3996 if (!summon_unique_okay && ((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags7 & RF7_UNIQUE_7))) return FALSE;
3998 if ((summon_specific_who < 0) &&
3999 ((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags7 & RF7_UNIQUE_7)) &&
4000 (((p_ptr->align > 9) && (r_ptr->flags3 & RF3_EVIL)) ||
4001 ((p_ptr->align < -9) && (r_ptr->flags3 & RF3_GOOD))))
4004 if ((r_ptr->flags7 & RF7_CHAMELEON) && (d_info[dungeon_type].flags1 & DF1_CHAMELEON)) return TRUE;
4006 return (summon_specific_aux(r_idx));
4011 * Place a monster (of the specified "type") near the given
4012 * location. Return TRUE if a monster was actually summoned.
4014 * We will attempt to place the monster up to 10 times before giving up.
4016 * Note: SUMMON_UNIQUE and SUMMON_AMBERITES will summon Unique's
4017 * Note: SUMMON_HI_UNDEAD and SUMMON_HI_DRAGON may summon Unique's
4018 * Note: None of the other summon codes will ever summon Unique's.
4020 * This function has been changed. We now take the "monster level"
4021 * of the summoning monster as a parameter, and use that, along with
4022 * the current dungeon level, to help determine the level of the
4023 * desired monster. Note that this is an upper bound, and also
4024 * tends to "prefer" monsters of that level. Currently, we use
4025 * the average of the dungeon and monster levels, and then add
4026 * five to allow slight increases in monster power.
4028 * Note that we use the new "monster allocation table" creation code
4029 * to restrict the "get_mon_num()" function to the set of "legal"
4030 * monsters, making this function much faster and more reliable.
4032 * Note that this function may not succeed, though this is very rare.
4034 bool summon_specific(int who, int y1, int x1, int lev, int type, u32b mode)
4038 if (p_ptr->inside_arena) return (FALSE);
4040 if (!mon_scatter(&y, &x, y1, x1, 2)) return FALSE;
4042 /* Save the summoner */
4043 summon_specific_who = who;
4045 /* Save the "summon" type */
4046 summon_specific_type = type;
4048 summon_unique_okay = (mode & PM_ALLOW_UNIQUE) ? TRUE : FALSE;
4050 /* Save the hostility */
4051 summon_specific_hostile = (!(mode & PM_FORCE_FRIENDLY) && !(is_friendly_idx(who)) && !(mode & PM_FORCE_PET));
4053 /* Prepare allocation table */
4054 get_mon_num_prep(summon_specific_okay, get_monster_hook2(y, x));
4056 /* Pick a monster, using the level calculation */
4057 r_idx = get_mon_num((dun_level + lev) / 2 + 5);
4059 /* Handle failure */
4062 summon_specific_type = 0;
4066 if ((type == SUMMON_BLUE_HORROR) || (type == SUMMON_DAWN)) mode |= PM_NO_KAGE;
4068 /* Attempt to place the monster (awake, allow groups) */
4069 if (!place_monster_aux(who, y, x, r_idx, mode))
4071 summon_specific_type = 0;
4075 summon_specific_type = 0;
4080 /* A "dangerous" function, creates a pet of the specified type */
4081 bool summon_named_creature (int who, int oy, int ox, int r_idx, u32b mode)
4086 /* if (!r_idx) return; */
4088 /* Prevent illegal monsters */
4089 if (r_idx >= max_r_idx) return FALSE;
4091 if (p_ptr->inside_arena) return FALSE;
4093 if (!mon_scatter(&y, &x, oy, ox, 2)) return FALSE;
4095 /* Place it (allow groups) */
4096 return place_monster_aux(who, y, x, r_idx, (mode | PM_NO_KAGE));
4101 * Let the given monster attempt to reproduce.
4103 * Note that "reproduction" REQUIRES empty space.
4105 bool multiply_monster(int m_idx, bool clone, u32b mode)
4107 monster_type *m_ptr = &m_list[m_idx];
4111 if (!mon_scatter(&y, &x, m_ptr->fy, m_ptr->fx, 1))
4114 if (m_ptr->mflag2 & MFLAG2_NOPET) mode |= PM_NO_PET;
4116 /* Create a new monster (awake, no groups) */
4117 if (!place_monster_aux(m_idx, y, x, m_ptr->r_idx, (mode | PM_NO_KAGE)))
4122 m_list[hack_m_idx_ii].smart |= SM_CLONED;
4123 m_list[hack_m_idx_ii].mflag2 |= MFLAG2_NOPET;
4134 * Dump a message describing a monster's reaction to damage
4136 * Technically should attempt to treat "Beholder"'s as jelly's
4138 void message_pain(int m_idx, int dam)
4140 long oldhp, newhp, tmp;
4143 monster_type *m_ptr = &m_list[m_idx];
4144 monster_race *r_ptr = &r_info[m_ptr->r_idx];
4149 /* Get the monster name */
4150 monster_desc(m_name, m_ptr, 0);
4152 /* Notice non-damage */
4156 msg_format("%^s¤Ï¥À¥á¡¼¥¸¤ò¼õ¤±¤Æ¤¤¤Ê¤¤¡£", m_name);
4158 msg_format("%^s is unharmed.", m_name);
4164 /* Note -- subtle fix -CFT */
4165 newhp = (long)(m_ptr->hp);
4166 oldhp = newhp + (long)(dam);
4167 tmp = (newhp * 100L) / oldhp;
4168 percentage = (int)(tmp);
4171 /* Mushrooms, Eyes, Jellies, Molds, Vortices, Worms, Quylthulgs */
4172 if (strchr(",ejmvwQ", r_ptr->d_char))
4175 if (percentage > 95)
4176 msg_format("%^s¤Ï¤Û¤È¤ó¤Éµ¤¤Ë¤È¤á¤Æ¤¤¤Ê¤¤¡£", m_name);
4177 else if (percentage > 75)
4178 msg_format("%^s¤Ï¤·¤ê¹þ¤ß¤·¤¿¡£", m_name);
4179 else if (percentage > 50)
4180 msg_format("%^s¤Ï½Ì¤³¤Þ¤Ã¤¿¡£", m_name);
4181 else if (percentage > 35)
4182 msg_format("%^s¤ÏÄˤߤ˿̤¨¤¿¡£", m_name);
4183 else if (percentage > 20)
4184 msg_format("%^s¤Ï¿È¤â¤À¤¨¤·¤¿¡£", m_name);
4185 else if (percentage > 10)
4186 msg_format("%^s¤Ï¶ìÄˤǿȤâ¤À¤¨¤·¤¿¡£", m_name);
4188 msg_format("%^s¤Ï¤°¤Ë¤ã¤°¤Ë¤ã¤ÈáÛÚ»¤·¤¿¡£", m_name);
4190 if (percentage > 95)
4191 msg_format("%^s barely notices.", m_name);
4192 else if (percentage > 75)
4193 msg_format("%^s flinches.", m_name);
4194 else if (percentage > 50)
4195 msg_format("%^s squelches.", m_name);
4196 else if (percentage > 35)
4197 msg_format("%^s quivers in pain.", m_name);
4198 else if (percentage > 20)
4199 msg_format("%^s writhes about.", m_name);
4200 else if (percentage > 10)
4201 msg_format("%^s writhes in agony.", m_name);
4203 msg_format("%^s jerks limply.", m_name);
4210 else if (strchr("l", r_ptr->d_char))
4212 if (percentage > 95)
4214 msg_format("%^s¤Ï¤Û¤È¤ó¤Éµ¤¤Ë¤È¤á¤Æ¤¤¤Ê¤¤¡£", m_name);
4216 msg_format("%^s barely notices.", m_name);
4218 else if (percentage > 75)
4220 msg_format("%^s¤Ï¤·¤ê¹þ¤ß¤·¤¿¡£", m_name);
4222 msg_format("%^s flinches.", m_name);
4224 else if (percentage > 50)
4226 msg_format("%^s¤Ïí´í°¤·¤¿¡£", m_name);
4228 msg_format("%^s hesitates.", m_name);
4230 else if (percentage > 35)
4232 msg_format("%^s¤ÏÄˤߤ˿̤¨¤¿¡£", m_name);
4234 msg_format("%^s quivers in pain.", m_name);
4236 else if (percentage > 20)
4238 msg_format("%^s¤Ï¿È¤â¤À¤¨¤·¤¿¡£", m_name);
4240 msg_format("%^s writhes about.", m_name);
4242 else if (percentage > 10)
4244 msg_format("%^s¤Ï¶ìÄˤǿȤâ¤À¤¨¤·¤¿¡£", m_name);
4246 msg_format("%^s writhes in agony.", m_name);
4250 msg_format("%^s¤Ï¤°¤Ë¤ã¤°¤Ë¤ã¤ÈáÛÚ»¤·¤¿¡£", m_name);
4252 msg_format("%^s jerks limply.", m_name);
4257 /* Golems, Walls, Doors, Stairs */
4258 else if (strchr("g#+<>", r_ptr->d_char))
4260 if (percentage > 95)
4262 msg_format("%s¤Ï¹¶·â¤òµ¤¤Ë¤È¤á¤Æ¤¤¤Ê¤¤¡£", m_name);
4264 msg_format("%^s ignores the attack.", m_name);
4266 else if (percentage > 75)
4268 msg_format("%s¤Ï¹¶·â¤Ë¸ª¤ò¤¹¤¯¤á¤¿¡£", m_name);
4270 msg_format("%^s shrugs off the attack.", m_name);
4272 else if (percentage > 50)
4274 msg_format("%^s¤ÏÍëÌĤΤ褦¤ËËʤ¨¤¿¡£", m_name);
4276 msg_format("%^s roars thunderously.", m_name);
4278 else if (percentage > 35)
4280 msg_format("%^s¤Ï¶ì¤·¤²¤ËËʤ¨¤¿¡£", m_name);
4282 msg_format("%^s rumbles.", m_name);
4284 else if (percentage > 20)
4286 msg_format("%^s¤Ï¤¦¤á¤¤¤¿¡£", m_name);
4288 msg_format("%^s grunts.", m_name);
4290 else if (percentage > 10)
4292 msg_format("%^s¤Ïí´í°¤·¤¿¡£", m_name);
4294 msg_format("%^s hesitates.", m_name);
4298 msg_format("%^s¤Ï¤¯¤·¤ã¤¯¤·¤ã¤Ë¤Ê¤Ã¤¿¡£", m_name);
4300 msg_format("%^s crumples.", m_name);
4305 /* Snakes, Hydrae, Reptiles, Mimics */
4306 else if (strchr("JMR", r_ptr->d_char) || !isalpha(r_ptr->d_char))
4308 if (percentage > 95)
4310 msg_format("%^s¤Ï¤Û¤È¤ó¤Éµ¤¤Ë¤È¤á¤Æ¤¤¤Ê¤¤¡£", m_name);
4312 msg_format("%^s barely notices.", m_name);
4314 else if (percentage > 75)
4316 msg_format("%^s¤Ï¥·¡¼¥Ã¤ÈÌĤ¤¤¿¡£", m_name);
4318 msg_format("%^s hisses.", m_name);
4320 else if (percentage > 50)
4322 msg_format("%^s¤ÏÅܤäÆƬ¤ò¾å¤²¤¿¡£", m_name);
4324 msg_format("%^s rears up in anger.", m_name);
4326 else if (percentage > 35)
4328 msg_format("%^s¤ÏÌÔÁ³¤È°Ò³Å¤·¤¿¡£", m_name);
4330 msg_format("%^s hisses furiously.", m_name);
4332 else if (percentage > 20)
4334 msg_format("%^s¤Ï¿È¤â¤À¤¨¤·¤¿¡£", m_name);
4336 msg_format("%^s writhes about.", m_name);
4338 else if (percentage > 10)
4340 msg_format("%^s¤Ï¶ìÄˤǿȤâ¤À¤¨¤·¤¿¡£", m_name);
4342 msg_format("%^s writhes in agony.", m_name);
4346 msg_format("%^s¤Ï¤°¤Ë¤ã¤°¤Ë¤ã¤ÈáÛÚ»¤·¤¿¡£", m_name);
4348 msg_format("%^s jerks limply.", m_name);
4354 else if (strchr("f", r_ptr->d_char))
4356 if (percentage > 95)
4358 msg_format("%s¤Ï¹¶·â¤Ë¸ª¤ò¤¹¤¯¤á¤¿¡£", m_name);
4360 msg_format("%^s shrugs off the attack.", m_name);
4362 else if (percentage > 75)
4364 msg_format("%^s¤ÏËʤ¨¤¿¡£", m_name);
4366 msg_format("%^s roars.", m_name);
4368 else if (percentage > 50)
4370 msg_format("%^s¤ÏÅܤäÆËʤ¨¤¿¡£", m_name);
4372 msg_format("%^s growls angrily.", m_name);
4374 else if (percentage > 35)
4376 msg_format("%^s¤ÏÄˤߤǥ·¡¼¥Ã¤ÈÌĤ¤¤¿¡£", m_name);
4378 msg_format("%^s hisses with pain.", m_name);
4380 else if (percentage > 20)
4382 msg_format("%^s¤ÏÄˤߤǼ塹¤·¤¯ÌĤ¤¤¿¡£", m_name);
4384 msg_format("%^s mewls in pain.", m_name);
4386 else if (percentage > 10)
4388 msg_format("%^s¤Ï¶ìÄˤˤ¦¤á¤¤¤¿¡£", m_name);
4390 msg_format("%^s hisses in agony.", m_name);
4394 msg_format("%s¤Ï°¥¤ì¤ÊÌĤÀ¼¤ò½Ð¤·¤¿¡£", m_name);
4396 msg_format("%^s mewls pitifully.", m_name);
4401 /* Ants, Centipedes, Flies, Insects, Beetles, Spiders */
4402 else if (strchr("acFIKS", r_ptr->d_char))
4404 if (percentage > 95)
4406 msg_format("%s¤Ï¹¶·â¤òµ¤¤Ë¤È¤á¤Æ¤¤¤Ê¤¤¡£", m_name);
4408 msg_format("%^s ignores the attack.", m_name);
4410 else if (percentage > 75)
4412 msg_format("%^s¤Ï¥¡¼¥¡¼ÌĤ¤¤¿¡£", m_name);
4414 msg_format("%^s chitters.", m_name);
4417 else if (percentage > 50)
4419 msg_format("%^s¤Ï¥è¥í¥è¥íƨ¤²²ó¤Ã¤¿¡£", m_name);
4421 msg_format("%^s scuttles about.", m_name);
4424 else if (percentage > 35)
4426 msg_format("%^s¤Ï¤¦¤ë¤µ¤¯ÌĤ¤¤¿¡£", m_name);
4428 msg_format("%^s twitters.", m_name);
4431 else if (percentage > 20)
4433 msg_format("%^s¤ÏÄˤߤËáÛÚ»¤·¤¿¡£", m_name);
4435 msg_format("%^s jerks in pain.", m_name);
4438 else if (percentage > 10)
4440 msg_format("%^s¤Ï¶ìÄˤÇáÛÚ»¤·¤¿¡£", m_name);
4442 msg_format("%^s jerks in agony.", m_name);
4447 msg_format("%^s¤Ï¥Ô¥¯¥Ô¥¯¤Ò¤¤Ä¤Ã¤¿¡£", m_name);
4449 msg_format("%^s twitches.", m_name);
4456 else if (strchr("B", r_ptr->d_char))
4458 if (percentage > 95)
4460 msg_format("%^s¤Ï¤µ¤¨¤º¤Ã¤¿¡£", m_name);
4462 msg_format("%^s chirps.", m_name);
4465 else if (percentage > 75)
4467 msg_format("%^s¤Ï¥Ô¡¼¥Ô¡¼ÌĤ¤¤¿¡£", m_name);
4469 msg_format("%^s twitters.", m_name);
4472 else if (percentage > 50)
4474 msg_format("%^s¤Ï¥®¥ã¡¼¥®¥ã¡¼ÌĤ¤¤¿¡£", m_name);
4476 msg_format("%^s squawks.", m_name);
4479 else if (percentage > 35)
4481 msg_format("%^s¤Ï¥®¥ã¡¼¥®¥ã¡¼ÌĤ¤ï¤á¤¤¤¿¡£", m_name);
4483 msg_format("%^s chatters.", m_name);
4486 else if (percentage > 20)
4488 msg_format("%^s¤Ï¶ì¤·¤ó¤À¡£", m_name);
4490 msg_format("%^s jeers.", m_name);
4493 else if (percentage > 10)
4495 msg_format("%^s¤Ï¤Î¤¿¤¦¤Á²ó¤Ã¤¿¡£", m_name);
4497 msg_format("%^s flutters about.", m_name);
4502 msg_format("%^s¤Ï¥¡¼¥¡¼¤ÈÌĤ¶«¤ó¤À¡£", m_name);
4504 msg_format("%^s squeaks.", m_name);
4510 /* Dragons, Demons, High Undead */
4511 else if (strchr("duDLUW", r_ptr->d_char))
4513 if (percentage > 95)
4515 msg_format("%s¤Ï¹¶·â¤òµ¤¤Ë¤È¤á¤Æ¤¤¤Ê¤¤¡£", m_name);
4517 msg_format("%^s ignores the attack.", m_name);
4520 else if (percentage > 75)
4522 msg_format("%^s¤Ï¤·¤ê¹þ¤ß¤·¤¿¡£", m_name);
4524 msg_format("%^s flinches.", m_name);
4527 else if (percentage > 50)
4529 msg_format("%^s¤ÏÄˤߤǥ·¡¼¥Ã¤ÈÌĤ¤¤¿¡£", m_name);
4531 msg_format("%^s hisses in pain.", m_name);
4534 else if (percentage > 35)
4536 msg_format("%^s¤ÏÄˤߤǤ¦¤Ê¤Ã¤¿¡£", m_name);
4538 msg_format("%^s snarls with pain.", m_name);
4541 else if (percentage > 20)
4543 msg_format("%^s¤ÏÄˤߤËËʤ¨¤¿¡£", m_name);
4545 msg_format("%^s roars with pain.", m_name);
4548 else if (percentage > 10)
4550 msg_format("%^s¤Ï¶ì¤·¤²¤Ë¶«¤ó¤À¡£", m_name);
4552 msg_format("%^s gasps.", m_name);
4557 msg_format("%^s¤Ï¼å¡¹¤·¤¯¤¦¤Ê¤Ã¤¿¡£", m_name);
4559 msg_format("%^s snarls feebly.", m_name);
4566 else if (strchr("s", r_ptr->d_char))
4568 if (percentage > 95)
4570 msg_format("%s¤Ï¹¶·â¤òµ¤¤Ë¤È¤á¤Æ¤¤¤Ê¤¤¡£", m_name);
4572 msg_format("%^s ignores the attack.", m_name);
4575 else if (percentage > 75)
4577 msg_format("%s¤Ï¹¶·â¤Ë¸ª¤ò¤¹¤¯¤á¤¿¡£", m_name);
4579 msg_format("%^s shrugs off the attack.", m_name);
4582 else if (percentage > 50)
4584 msg_format("%^s¤Ï¥«¥¿¥«¥¿¤È¾Ð¤Ã¤¿¡£", m_name);
4586 msg_format("%^s rattles.", m_name);
4589 else if (percentage > 35)
4591 msg_format("%^s¤Ï¤è¤í¤á¤¤¤¿¡£", m_name);
4593 msg_format("%^s stumbles.", m_name);
4596 else if (percentage > 20)
4598 msg_format("%^s¤Ï¥«¥¿¥«¥¿¸À¤Ã¤¿¡£", m_name);
4600 msg_format("%^s rattles.", m_name);
4603 else if (percentage > 10)
4605 msg_format("%^s¤Ï¤è¤í¤á¤¤¤¿¡£", m_name);
4607 msg_format("%^s staggers.", m_name);
4612 msg_format("%^s¤Ï¥¬¥¿¥¬¥¿¸À¤Ã¤¿¡£", m_name);
4614 msg_format("%^s clatters.", m_name);
4621 else if (strchr("z", r_ptr->d_char))
4623 if (percentage > 95)
4625 msg_format("%s¤Ï¹¶·â¤òµ¤¤Ë¤È¤á¤Æ¤¤¤Ê¤¤¡£", m_name);
4627 msg_format("%^s ignores the attack.", m_name);
4630 else if (percentage > 75)
4632 msg_format("%s¤Ï¹¶·â¤Ë¸ª¤ò¤¹¤¯¤á¤¿¡£", m_name);
4634 msg_format("%^s shrugs off the attack.", m_name);
4637 else if (percentage > 50)
4639 msg_format("%^s¤Ï¤¦¤á¤¤¤¿¡£", m_name);
4641 msg_format("%^s groans.", m_name);
4644 else if (percentage > 35)
4646 msg_format("%s¤Ï¶ì¤·¤²¤Ë¤¦¤á¤¤¤¿¡£", m_name);
4648 msg_format("%^s moans.", m_name);
4651 else if (percentage > 20)
4653 msg_format("%^s¤Ïí´í°¤·¤¿¡£", m_name);
4655 msg_format("%^s hesitates.", m_name);
4658 else if (percentage > 10)
4660 msg_format("%^s¤Ï¤¦¤Ê¤Ã¤¿¡£", m_name);
4662 msg_format("%^s grunts.", m_name);
4667 msg_format("%^s¤Ï¤è¤í¤á¤¤¤¿¡£", m_name);
4669 msg_format("%^s staggers.", m_name);
4676 else if (strchr("G", r_ptr->d_char))
4679 if (percentage > 95)
4681 msg_format("%s¤Ï¹¶·â¤òµ¤¤Ë¤È¤á¤Æ¤¤¤Ê¤¤¡£", m_name);
4683 msg_format("%^s ignores the attack.", m_name);
4686 else if (percentage > 75)
4688 msg_format("%s¤Ï¹¶·â¤Ë¸ª¤ò¤¹¤¯¤á¤¿¡£", m_name);
4690 msg_format("%^s shrugs off the attack.", m_name);
4693 else if (percentage > 50)
4695 msg_format("%s¤Ï¤¦¤á¤¤¤¿¡£", m_name);
4697 msg_format("%^s moans.", m_name);
4700 else if (percentage > 35)
4702 msg_format("%^s¤Ïµã¤¤ï¤á¤¤¤¿¡£", m_name);
4704 msg_format("%^s wails.", m_name);
4707 else if (percentage > 20)
4709 msg_format("%^s¤ÏËʤ¨¤¿¡£", m_name);
4711 msg_format("%^s howls.", m_name);
4714 else if (percentage > 10)
4716 msg_format("%s¤Ï¼å¡¹¤·¤¯¤¦¤á¤¤¤¿¡£", m_name);
4718 msg_format("%^s moans softly.", m_name);
4723 msg_format("%^s¤Ï¤«¤¹¤«¤Ë¤¦¤á¤¤¤¿¡£", m_name);
4725 msg_format("%^s sighs.", m_name);
4731 /* Dogs and Hounds */
4732 else if (strchr("CZ", r_ptr->d_char))
4735 if (percentage > 95)
4736 msg_format("%^s¤Ï¹¶·â¤Ë¸ª¤ò¤¹¤¯¤á¤¿¡£", m_name);
4737 else if (percentage > 75)
4738 msg_format("%^s¤ÏÄˤߤǤ¦¤Ê¤Ã¤¿¡£", m_name);
4739 else if (percentage > 50)
4740 msg_format("%^s¤ÏÄˤߤǥ¥ã¥ó¥¥ã¥óËʤ¨¤¿¡£", m_name);
4741 else if (percentage > 35)
4742 msg_format("%^s¤ÏÄˤߤÇÌĤ¤ï¤á¤¤¤¿¡£", m_name);
4743 else if (percentage > 20)
4744 msg_format("%^s¤Ï¶ìÄˤΤ¢¤Þ¤êÌĤ¤ï¤á¤¤¤¿¡£", m_name);
4745 else if (percentage > 10)
4746 msg_format("%^s¤Ï¶ìÄˤǤâ¤À¤¨¶ì¤·¤ó¤À¡£", m_name);
4748 msg_format("%^s¤Ï¼å¡¹¤·¤¯Ëʤ¨¤¿¡£", m_name);
4750 if (percentage > 95)
4751 msg_format("%^s shrugs off the attack.", m_name);
4752 else if (percentage > 75)
4753 msg_format("%^s snarls with pain.", m_name);
4754 else if (percentage > 50)
4755 msg_format("%^s yelps in pain.", m_name);
4756 else if (percentage > 35)
4757 msg_format("%^s howls in pain.", m_name);
4758 else if (percentage > 20)
4759 msg_format("%^s howls in agony.", m_name);
4760 else if (percentage > 10)
4761 msg_format("%^s writhes in agony.", m_name);
4763 msg_format("%^s yelps feebly.", m_name);
4768 /* One type of monsters (ignore,squeal,shriek) */
4769 else if (strchr("Xbilqrt", r_ptr->d_char))
4772 if (percentage > 95)
4773 msg_format("%^s¤Ï¹¶·â¤òµ¤¤Ë¤È¤á¤Æ¤¤¤Ê¤¤¡£", m_name);
4774 else if (percentage > 75)
4775 msg_format("%^s¤ÏÄˤߤǤ¦¤Ê¤Ã¤¿¡£", m_name);
4776 else if (percentage > 50)
4777 msg_format("%^s¤ÏÄˤߤǶ«¤ó¤À¡£", m_name);
4778 else if (percentage > 35)
4779 msg_format("%^s¤ÏÄˤߤÇÀ䶫¤·¤¿¡£", m_name);
4780 else if (percentage > 20)
4781 msg_format("%^s¤Ï¶ìÄˤΤ¢¤Þ¤êÀ䶫¤·¤¿¡£", m_name);
4782 else if (percentage > 10)
4783 msg_format("%^s¤Ï¶ìÄˤǤâ¤À¤¨¶ì¤·¤ó¤À¡£", m_name);
4785 msg_format("%^s¤Ï¼å¡¹¤·¤¯¶«¤ó¤À¡£", m_name);
4787 if (percentage > 95)
4788 msg_format("%^s ignores the attack.", m_name);
4789 else if (percentage > 75)
4790 msg_format("%^s grunts with pain.", m_name);
4791 else if (percentage > 50)
4792 msg_format("%^s squeals in pain.", m_name);
4793 else if (percentage > 35)
4794 msg_format("%^s shrieks in pain.", m_name);
4795 else if (percentage > 20)
4796 msg_format("%^s shrieks in agony.", m_name);
4797 else if (percentage > 10)
4798 msg_format("%^s writhes in agony.", m_name);
4800 msg_format("%^s cries out feebly.", m_name);
4805 /* Another type of monsters (shrug,cry,scream) */
4809 if (percentage > 95)
4810 msg_format("%^s¤Ï¹¶·â¤Ë¸ª¤ò¤¹¤¯¤á¤¿¡£", m_name);
4811 else if (percentage > 75)
4812 msg_format("%^s¤ÏÄˤߤǤ¦¤Ê¤Ã¤¿¡£", m_name);
4813 else if (percentage > 50)
4814 msg_format("%^s¤ÏÄˤߤǶ«¤ó¤À¡£", m_name);
4815 else if (percentage > 35)
4816 msg_format("%^s¤ÏÄˤߤÇÀ䶫¤·¤¿¡£", m_name);
4817 else if (percentage > 20)
4818 msg_format("%^s¤Ï¶ìÄˤΤ¢¤Þ¤êÀ䶫¤·¤¿¡£", m_name);
4819 else if (percentage > 10)
4820 msg_format("%^s¤Ï¶ìÄˤǤâ¤À¤¨¶ì¤·¤ó¤À¡£", m_name);
4822 msg_format("%^s¤Ï¼å¡¹¤·¤¯¶«¤ó¤À¡£", m_name);
4824 if (percentage > 95)
4825 msg_format("%^s shrugs off the attack.", m_name);
4826 else if (percentage > 75)
4827 msg_format("%^s grunts with pain.", m_name);
4828 else if (percentage > 50)
4829 msg_format("%^s cries out in pain.", m_name);
4830 else if (percentage > 35)
4831 msg_format("%^s screams in pain.", m_name);
4832 else if (percentage > 20)
4833 msg_format("%^s screams in agony.", m_name);
4834 else if (percentage > 10)
4835 msg_format("%^s writhes in agony.", m_name);
4837 msg_format("%^s cries out feebly.", m_name);
4845 * Learn about an "observed" resistance.
4847 void update_smart_learn(int m_idx, int what)
4849 #ifdef DRS_SMART_OPTIONS
4851 monster_type *m_ptr = &m_list[m_idx];
4853 monster_race *r_ptr = &r_info[m_ptr->r_idx];
4856 /* Not allowed to learn */
4857 if (!smart_learn) return;
4859 /* Too stupid to learn anything */
4860 if (r_ptr->flags2 & (RF2_STUPID)) return;
4862 /* Not intelligent, only learn sometimes */
4863 if (!(r_ptr->flags2 & (RF2_SMART)) && (randint0(100) < 50)) return;
4868 /* Analyze the knowledge */
4872 if (p_ptr->resist_acid) m_ptr->smart |= (SM_RES_ACID);
4873 if (IS_OPPOSE_ACID()) m_ptr->smart |= (SM_OPP_ACID);
4874 if (p_ptr->immune_acid) m_ptr->smart |= (SM_IMM_ACID);
4878 if (p_ptr->resist_elec) m_ptr->smart |= (SM_RES_ELEC);
4879 if (IS_OPPOSE_ELEC()) m_ptr->smart |= (SM_OPP_ELEC);
4880 if (p_ptr->immune_elec) m_ptr->smart |= (SM_IMM_ELEC);
4884 if (p_ptr->resist_fire) m_ptr->smart |= (SM_RES_FIRE);
4885 if (IS_OPPOSE_FIRE()) m_ptr->smart |= (SM_OPP_FIRE);
4886 if (p_ptr->immune_fire) m_ptr->smart |= (SM_IMM_FIRE);
4890 if (p_ptr->resist_cold) m_ptr->smart |= (SM_RES_COLD);
4891 if (IS_OPPOSE_COLD()) m_ptr->smart |= (SM_OPP_COLD);
4892 if (p_ptr->immune_cold) m_ptr->smart |= (SM_IMM_COLD);
4896 if (p_ptr->resist_pois) m_ptr->smart |= (SM_RES_POIS);
4897 if (IS_OPPOSE_POIS()) m_ptr->smart |= (SM_OPP_POIS);
4902 if (p_ptr->resist_neth) m_ptr->smart |= (SM_RES_NETH);
4906 if (p_ptr->resist_lite) m_ptr->smart |= (SM_RES_LITE);
4910 if (p_ptr->resist_dark) m_ptr->smart |= (SM_RES_DARK);
4914 if (p_ptr->resist_fear) m_ptr->smart |= (SM_RES_FEAR);
4918 if (p_ptr->resist_conf) m_ptr->smart |= (SM_RES_CONF);
4922 if (p_ptr->resist_chaos) m_ptr->smart |= (SM_RES_CHAOS);
4926 if (p_ptr->resist_disen) m_ptr->smart |= (SM_RES_DISEN);
4930 if (p_ptr->resist_blind) m_ptr->smart |= (SM_RES_BLIND);
4934 if (p_ptr->resist_nexus) m_ptr->smart |= (SM_RES_NEXUS);
4938 if (p_ptr->resist_sound) m_ptr->smart |= (SM_RES_SOUND);
4942 if (p_ptr->resist_shard) m_ptr->smart |= (SM_RES_SHARD);
4946 if (p_ptr->free_act) m_ptr->smart |= (SM_IMM_FREE);
4950 if (!p_ptr->msp) m_ptr->smart |= (SM_IMM_MANA);
4954 if (p_ptr->reflect) m_ptr-> smart |= (SM_IMM_REFLECT);
4958 #endif /* DRS_SMART_OPTIONS */
4964 * Place the player in the dungeon XXX XXX
4966 bool player_place(int y, int x)
4968 /* Paranoia XXX XXX */
4969 if (cave[y][x].m_idx != 0) return FALSE;
4971 /* Save player location */
4981 * Drop all items carried by a monster
4983 void monster_drop_carried_objects(monster_type *m_ptr)
4985 s16b this_o_idx, next_o_idx = 0;
4991 /* Drop objects being carried */
4992 for (this_o_idx = m_ptr->hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
4994 /* Acquire object */
4995 o_ptr = &o_list[this_o_idx];
4997 /* Acquire next object */
4998 next_o_idx = o_ptr->next_o_idx;
5001 o_ptr->held_m_idx = 0;
5003 /* Get local object */
5006 /* Copy the object */
5007 object_copy(q_ptr, o_ptr);
5009 /* Delete the object */
5010 delete_object_idx(this_o_idx);
5013 (void)drop_near(q_ptr, -1, m_ptr->fy, m_ptr->fx);
5016 /* Forget objects */
5017 m_ptr->hold_o_idx = 0;