3 /* Purpose: misc code for monsters */
6 * Copyright (c) 1989 James E. Wilson, Robert A. Koeneke
8 * This software may be copied and distributed for educational, research, and
9 * not for profit purposes provided that this copyright and statement are
10 * included in all such copies.
15 #define HORDE_NOGOOD 0x01
16 #define HORDE_NOEVIL 0x02
21 cptr horror_desc[MAX_SAN_HORROR] =
75 cptr funny_desc[MAX_SAN_FUNNY] =
90 "¥Õ¥¡¥ó¥¿¥¹¥Æ¥£¥Ã¥¯¤Ê",
135 cptr funny_comments[MAX_SAN_COMMENT] =
156 * Delete a monster by index.
158 * When a monster is deleted, all of its objects are deleted.
160 void delete_monster_idx(int i)
164 monster_type *m_ptr = &m_list[i];
166 monster_race *r_ptr = &r_info[m_ptr->r_idx];
168 s16b this_o_idx, next_o_idx = 0;
176 /* Hack -- Reduce the racial counter */
179 /* Hack -- count the number of "reproducers" */
180 if (r_ptr->flags2 & (RF2_MULTIPLY)) num_repro--;
183 /* Hack -- remove target monster */
184 if (i == target_who) target_who = 0;
186 /* Hack -- remove tracked monster */
187 if (i == p_ptr->health_who) health_track(0);
189 if (pet_t_m_idx == i ) pet_t_m_idx = 0;
190 if (riding_t_m_idx == i) riding_t_m_idx = 0;
191 if (p_ptr->riding == i) p_ptr->riding = 0;
193 /* Monster is gone */
194 cave[y][x].m_idx = 0;
198 for (this_o_idx = m_ptr->hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
203 o_ptr = &o_list[this_o_idx];
205 /* Acquire next object */
206 next_o_idx = o_ptr->next_o_idx;
208 /* Hack -- efficiency */
209 o_ptr->held_m_idx = 0;
211 /* Delete the object */
212 delete_object_idx(this_o_idx);
216 /* Wipe the Monster */
217 (void)WIPE(m_ptr, monster_type);
223 delete_monster_callback(i);
224 #endif /* USE_SCRIPT */
232 * Delete the monster, if any, at a given location
234 void delete_monster(int y, int x)
239 if (!in_bounds(y, x)) return;
244 /* Delete the monster (if any) */
245 if (c_ptr->m_idx) delete_monster_idx(c_ptr->m_idx);
250 * Move an object from index i1 to index i2 in the object list
252 static void compact_monsters_aux(int i1, int i2)
260 s16b this_o_idx, next_o_idx = 0;
264 if (i1 == i2) return;
277 /* Update the cave */
280 /* Repair objects being carried by monster */
281 for (this_o_idx = m_ptr->hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
286 o_ptr = &o_list[this_o_idx];
288 /* Acquire next object */
289 next_o_idx = o_ptr->next_o_idx;
291 /* Reset monster pointer */
292 o_ptr->held_m_idx = i2;
295 /* Hack -- Update the target */
296 if (target_who == i1) target_who = i2;
298 /* Hack -- Update the target */
299 if (pet_t_m_idx == i1) pet_t_m_idx = i2;
300 if (riding_t_m_idx == i1) riding_t_m_idx = i2;
302 /* Hack -- Update the riding */
303 if (p_ptr->riding == i1) p_ptr->riding = i2;
305 /* Hack -- Update the health bar */
306 if (p_ptr->health_who == i1) health_track(i2);
309 COPY(&m_list[i2], &m_list[i1], monster_type);
312 (void)WIPE(&m_list[i1], monster_type);
315 copy_monster_callback(i1, i2);
316 #endif /* USE_SCRIPT */
322 * Compact and Reorder the monster list
324 * This function can be very dangerous, use with caution!
326 * When actually "compacting" monsters, we base the saving throw
327 * on a combination of monster level, distance from player, and
328 * current "desperation".
330 * After "compacting" (if needed), we "reorder" the monsters into a more
331 * compact order, and we reset the allocation info, and the "live" array.
333 void compact_monsters(int size)
336 int cur_lev, cur_dis, chance;
338 /* Message (only if compacting) */
340 if (size) msg_print("¥â¥ó¥¹¥¿¡¼¾ðÊó¤ò°µ½Ì¤·¤Æ¤¤¤Þ¤¹...");
342 if (size) msg_print("Compacting monsters...");
346 /* Compact at least 'size' objects */
347 for (num = 0, cnt = 1; num < size; cnt++)
349 /* Get more vicious each iteration */
352 /* Get closer each iteration */
353 cur_dis = 5 * (20 - cnt);
355 /* Check all the monsters */
356 for (i = 1; i < m_max; i++)
358 monster_type *m_ptr = &m_list[i];
360 monster_race *r_ptr = &r_info[m_ptr->r_idx];
362 /* Paranoia -- skip "dead" monsters */
363 if (!m_ptr->r_idx) continue;
365 /* Hack -- High level monsters start out "immune" */
366 if (r_ptr->level > cur_lev) continue;
368 if (i == p_ptr->riding) continue;
370 /* Ignore nearby monsters */
371 if ((cur_dis > 0) && (m_ptr->cdis < cur_dis)) continue;
373 /* Saving throw chance */
376 /* Only compact "Quest" Monsters in emergencies */
377 if ((r_ptr->flags1 & (RF1_QUESTOR)) && (cnt < 1000)) chance = 100;
379 /* Try not to compact Unique Monsters */
380 if (r_ptr->flags1 & (RF1_UNIQUE)) chance = 100;
382 /* All monsters get a saving throw */
383 if (rand_int(100) < chance) continue;
385 /* Delete the monster */
386 delete_monster_idx(i);
388 /* Count the monster */
394 /* Excise dead monsters (backwards!) */
395 for (i = m_max - 1; i >= 1; i--)
397 /* Get the i'th monster */
398 monster_type *m_ptr = &m_list[i];
400 /* Skip real monsters */
401 if (m_ptr->r_idx) continue;
403 /* Move last monster into open hole */
404 compact_monsters_aux(m_max - 1, i);
406 /* Compress "m_max" */
413 * Delete/Remove all the monsters when the player leaves the level
415 * This is an efficient method of simulating multiple calls to the
416 * "delete_monster()" function, with no visual effects.
418 void wipe_m_list(void)
422 /* Delete all the monsters */
423 for (i = m_max - 1; i >= 1; i--)
425 monster_type *m_ptr = &m_list[i];
427 monster_race *r_ptr = &r_info[m_ptr->r_idx];
429 /* Skip dead monsters */
430 if (!m_ptr->r_idx) continue;
432 /* Mega-Hack -- preserve Unique's XXX XXX XXX */
434 /* Hack -- Reduce the racial counter */
437 /* Monster is gone */
438 cave[m_ptr->fy][m_ptr->fx].m_idx = 0;
440 /* Wipe the Monster */
441 (void)WIPE(m_ptr, monster_type);
444 delete_monster_callback(i);
445 #endif /* USE_SCRIPT */
454 /* Hack -- reset "reproducer" count */
457 /* Hack -- no more target */
462 /* Hack -- no more tracking */
468 * Acquires and returns the index of a "free" monster.
470 * This routine should almost never fail, but it *can* happen.
477 /* Normal allocation */
478 if (m_max < max_m_idx)
480 /* Access the next hole */
483 /* Expand the array */
489 /* Return the index */
494 /* Recycle dead monsters */
495 for (i = 1; i < m_max; i++)
499 /* Acquire monster */
502 /* Skip live monsters */
503 if (m_ptr->r_idx) continue;
508 /* Use this monster */
513 /* Warn the player (except during dungeon creation) */
515 if (character_dungeon) msg_print("¥â¥ó¥¹¥¿¡¼¤¬Â¿¤¹¤®¤ë¡ª");
517 if (character_dungeon) msg_print("Too many monsters!");
521 /* Try not to crash */
529 * Hack -- the "type" of the current "summon specific"
531 static int summon_specific_type = 0;
535 * Hack -- the index of the summoning monster
537 static int summon_specific_who = -1;
541 * Hack -- the hostility of the summoned monster
543 static int summon_specific_hostile = TRUE;
545 static bool summon_unique_okay = FALSE;
548 static bool summon_specific_aux(int r_idx)
550 monster_race *r_ptr = &r_info[r_idx];
553 /* Check our requirements */
554 switch (summon_specific_type)
558 okay = (r_ptr->d_char == 'a');
564 okay = (r_ptr->d_char == 'S');
570 okay = ((r_ptr->d_char == 'C') || (r_ptr->d_char == 'Z'));
576 okay = (r_ptr->d_char == 'M');
582 okay = (r_ptr->d_char == 'A' && ((r_ptr->flags3 & RF3_EVIL) || (r_ptr->flags3 & RF3_GOOD)));
588 okay = (bool)(r_ptr->flags3 & RF3_DEMON);
594 okay = (bool)(r_ptr->flags3 & RF3_UNDEAD);
600 okay = (bool)(r_ptr->flags3 & RF3_DRAGON);
604 case SUMMON_HI_UNDEAD:
606 okay = ((r_ptr->d_char == 'L') ||
607 (r_ptr->d_char == 'V') ||
608 (r_ptr->d_char == 'W'));
612 case SUMMON_HI_DRAGON:
614 okay = (r_ptr->d_char == 'D');
618 case SUMMON_HI_DEMON:
620 okay = (((r_ptr->d_char == 'U') ||
621 (r_ptr->d_char == 'H') ||
622 (r_ptr->d_char == 'B')) &&
623 (r_ptr->flags3 & RF3_DEMON)) ? TRUE : FALSE;
627 case SUMMON_AMBERITES:
629 okay = (r_ptr->flags3 & (RF3_AMBERITE)) ? TRUE : FALSE;
635 okay = (r_ptr->flags1 & (RF1_UNIQUE)) ? TRUE : FALSE;
639 case SUMMON_BIZARRE1:
641 okay = (r_ptr->d_char == 'm');
644 case SUMMON_BIZARRE2:
646 okay = (r_ptr->d_char == 'b');
649 case SUMMON_BIZARRE3:
651 okay = (r_ptr->d_char == 'Q');
655 case SUMMON_BIZARRE4:
657 okay = (r_ptr->d_char == 'v');
661 case SUMMON_BIZARRE5:
663 okay = (r_ptr->d_char == '$');
667 case SUMMON_BIZARRE6:
669 okay = ((r_ptr->d_char == '!') ||
670 (r_ptr->d_char == '?') ||
671 (r_ptr->d_char == '=') ||
672 (r_ptr->d_char == '$') ||
673 (r_ptr->d_char == '|'));
679 okay = (r_ptr->d_char == 'g');
685 okay = ((r_ptr->d_char == 'U') &&
686 (r_ptr->flags4 & RF4_ROCKET));
693 okay = ((r_ptr->d_char == summon_kin_type) && (r_idx != MON_HAGURE));
699 okay = (r_idx == MON_DAWN);
705 okay = (bool)(r_ptr->flags3 & (RF3_ANIMAL));
709 case SUMMON_ANIMAL_RANGER:
711 okay = ((r_ptr->flags3 & (RF3_ANIMAL)) &&
712 (strchr("abcflqrwBCHIJKMRS", r_ptr->d_char)) &&
713 !(r_ptr->flags3 & (RF3_DRAGON)) &&
714 !(r_ptr->flags3 & (RF3_EVIL)) &&
715 !(r_ptr->flags3 & (RF3_UNDEAD)) &&
716 !(r_ptr->flags3 & (RF3_DEMON)) &&
717 !(r_ptr->flags2 & (RF2_MULTIPLY)) &&
718 !(r_ptr->flags4 || r_ptr->flags5 || r_ptr->flags6));
722 case SUMMON_HI_DRAGON_LIVING:
724 okay = ((r_ptr->d_char == 'D') &&
725 !(r_ptr->flags3 & (RF3_DEMON | RF3_UNDEAD | RF3_NONLIVING)));
731 okay = (!(r_ptr->flags3 & (RF3_DEMON | RF3_UNDEAD | RF3_NONLIVING)));
737 okay = (r_idx == MON_PHANTOM_B || r_idx == MON_PHANTOM_W);
741 case SUMMON_BLUE_HORROR:
743 okay = (r_idx == MON_BLUE_HORROR);
747 case SUMMON_ELEMENTAL:
749 okay = (r_ptr->d_char == 'E');
755 okay = (r_ptr->d_char == 'v');
761 okay = (r_ptr->d_char == 'H');
767 okay = (r_ptr->d_char == 'B');
771 case SUMMON_KAMIKAZE:
774 for (i = 0; i < 4; i++)
775 if (r_ptr->blow[i].method == RBM_EXPLODE) okay = TRUE;
779 case SUMMON_KAMIKAZE_LIVING:
783 for (i = 0; i < 4; i++)
784 if (r_ptr->blow[i].method == RBM_EXPLODE) okay = TRUE;
785 okay = (okay && (!(r_ptr->flags3 & (RF3_DEMON | RF3_UNDEAD | RF3_NONLIVING))));
791 okay = (r_idx == MON_MANES);
797 okay = (r_idx == MON_LOUSE);
807 static bool chameleon_change = FALSE;
811 * Some dungeon types restrict the possible monsters.
812 * Return TRUE is the monster is OK and FALSE otherwise
814 static bool restrict_monster_to_dungeon(int r_idx)
816 dungeon_info_type *d_ptr = &d_info[dungeon_type];
817 monster_race *r_ptr = &r_info[r_idx];
820 if (d_ptr->flags1 & DF1_CHAMELEON)
822 if (chameleon_change) return TRUE;
824 if (d_ptr->flags1 & DF1_NO_MAGIC)
826 if (r_idx == MON_CHAMELEON) return TRUE;
827 if (r_ptr->freq_spell && !(r_ptr->flags4 & RF4_NOMAGIC_MASK) && !(r_ptr->flags5 & RF5_NOMAGIC_MASK) && !(r_ptr->flags6 & RF6_NOMAGIC_MASK))
831 if (d_ptr->flags1 & DF1_NO_MELEE)
833 if (r_idx == MON_CHAMELEON) return TRUE;
834 if (!(r_ptr->flags4 & (RF4_BOLT_MASK | RF4_BEAM_MASK | RF4_BALL_MASK)) &&
835 !(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)) &&
836 !(r_ptr->flags6 & (RF6_BOLT_MASK | RF6_BEAM_MASK | RF6_BALL_MASK)))
840 if (d_ptr->flags1 & DF1_BEGINNER)
842 if (r_ptr->level > dun_level)
847 if (d_ptr->special_div == 64) return TRUE;
848 if (summon_specific_type && !(d_ptr->flags1 & DF1_CHAMELEON)) return TRUE;
850 if(d_ptr->mode == DUNGEON_MODE_AND)
854 if((d_ptr->mflags1 & r_ptr->flags1) != d_ptr->mflags1)
859 if((d_ptr->mflags2 & r_ptr->flags2) != d_ptr->mflags2)
864 if((d_ptr->mflags3 & r_ptr->flags3) != d_ptr->mflags3)
869 if((d_ptr->mflags4 & r_ptr->flags4) != d_ptr->mflags4)
874 if((d_ptr->mflags5 & r_ptr->flags5) != d_ptr->mflags5)
879 if((d_ptr->mflags6 & r_ptr->flags6) != d_ptr->mflags6)
884 if((d_ptr->mflags7 & r_ptr->flags7) != d_ptr->mflags7)
889 if((d_ptr->mflags8 & r_ptr->flags8) != d_ptr->mflags8)
894 if((d_ptr->mflags9 & r_ptr->flags9) != d_ptr->mflags9)
897 for(a = 0; a < 5; a++)
898 if(d_ptr->r_char[a] && (d_ptr->r_char[a] != r_ptr->d_char)) return FALSE;
900 else if(d_ptr->mode == DUNGEON_MODE_NAND)
902 byte ok[9 + 5], i = 0, j = 0;
907 if(d_ptr->mflags1 & r_ptr->flags1)
913 if(d_ptr->mflags2 & r_ptr->flags2)
919 if(d_ptr->mflags3 & r_ptr->flags3)
925 if(d_ptr->mflags4 & r_ptr->flags4)
931 if(d_ptr->mflags5 & r_ptr->flags5)
937 if(d_ptr->mflags6 & r_ptr->flags6)
943 if(d_ptr->mflags7 & r_ptr->flags7)
949 if(d_ptr->mflags8 & r_ptr->flags8)
955 if(d_ptr->mflags9 & r_ptr->flags9)
959 for(a = 0; a < 5; a++)
964 if (d_ptr->r_char[a] != r_ptr->d_char) ok[9 + a] = 1;
968 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];
970 if(i == j) return FALSE;
972 else if(d_ptr->mode == DUNGEON_MODE_OR)
977 for(i = 0; i < 32; i++)
979 flag = d_ptr->mflags1 & (1 << i);
980 if(r_ptr->flags1 & flag) ok = TRUE;
982 flag = d_ptr->mflags2 & (1 << i);
983 if(r_ptr->flags2 & flag) ok = TRUE;
985 flag = d_ptr->mflags3 & (1 << i);
986 if(r_ptr->flags3 & flag) ok = TRUE;
988 flag = d_ptr->mflags4 & (1 << i);
989 if(r_ptr->flags4 & flag) ok = TRUE;
991 flag = d_ptr->mflags5 & (1 << i);
992 if(r_ptr->flags5 & flag) ok = TRUE;
994 flag = d_ptr->mflags6 & (1 << i);
995 if(r_ptr->flags6 & flag) ok = TRUE;
997 flag = d_ptr->mflags7 & (1 << i);
998 if(r_ptr->flags7 & flag) ok = TRUE;
1000 flag = d_ptr->mflags8 & (1 << i);
1001 if(r_ptr->flags8 & flag) ok = TRUE;
1003 flag = d_ptr->mflags9 & (1 << i);
1004 if(r_ptr->flags9 & flag) ok = TRUE;
1006 for(a = 0; a < 5; a++)
1007 if(d_ptr->r_char[a] == r_ptr->d_char) ok = TRUE;
1011 else if(d_ptr->mode == DUNGEON_MODE_NOR)
1016 for(i = 0; i < 32; i++)
1018 flag = d_ptr->mflags1 & (1 << i);
1019 if(r_ptr->flags1 & flag) ok = FALSE;
1021 flag = d_ptr->mflags2 & (1 << i);
1022 if(r_ptr->flags2 & flag) ok = FALSE;
1024 flag = d_ptr->mflags3 & (1 << i);
1025 if(r_ptr->flags3 & flag) ok = FALSE;
1027 flag = d_ptr->mflags4 & (1 << i);
1028 if(r_ptr->flags4 & flag) ok = FALSE;
1030 flag = d_ptr->mflags5 & (1 << i);
1031 if(r_ptr->flags5 & flag) ok = FALSE;
1033 flag = d_ptr->mflags6 & (1 << i);
1034 if(r_ptr->flags6 & flag) ok = FALSE;
1036 flag = d_ptr->mflags7 & (1 << i);
1037 if(r_ptr->flags7 & flag) ok = FALSE;
1039 flag = d_ptr->mflags8 & (1 << i);
1040 if(r_ptr->flags8 & flag) ok = FALSE;
1042 flag = d_ptr->mflags9 & (1 << i);
1043 if(r_ptr->flags9 & flag) ok = FALSE;
1045 for(a = 0; a < 5; a++)
1046 if(d_ptr->r_char[a] == r_ptr->d_char) ok = FALSE;
1054 * Apply a "monster restriction function" to the "monster allocation table"
1056 errr get_mon_num_prep(monster_hook_type monster_hook,
1057 monster_hook_type monster_hook2)
1061 /* Todo: Check the hooks for non-changes */
1063 /* Set the new hooks */
1064 get_mon_num_hook = monster_hook;
1065 get_mon_num2_hook = monster_hook2;
1067 /* Scan the allocation table */
1068 for (i = 0; i < alloc_race_size; i++)
1071 alloc_entry *entry = &alloc_race_table[i];
1073 /* Accept monsters which pass the restriction, if any */
1074 if ((!get_mon_num_hook || (*get_mon_num_hook)(entry->index)) &&
1075 (!get_mon_num2_hook || (*get_mon_num2_hook)(entry->index)))
1077 /* Accept this monster */
1078 entry->prob2 = entry->prob1;
1080 if (dun_level && (!p_ptr->inside_quest || p_ptr->inside_quest < MIN_RANDOM_QUEST) && !restrict_monster_to_dungeon(entry->index) && !p_ptr->inside_battle)
1082 int hoge = entry->prob2 * d_info[dungeon_type].special_div;
1083 entry->prob2 = hoge / 64;
1084 if (rand_int(64) < (hoge & 0x3f)) entry->prob2++;
1088 /* Do not use this monster */
1091 /* Decline this monster */
1101 static int mysqrt(int n)
1139 * Choose a monster race that seems "appropriate" to the given level
1141 * This function uses the "prob2" field of the "monster allocation table",
1142 * and various local information, to calculate the "prob3" field of the
1143 * same table, which is then used to choose an "appropriate" monster, in
1144 * a relatively efficient manner.
1146 * Note that "town" monsters will *only* be created in the town, and
1147 * "normal" monsters will *never* be created in the town, unless the
1148 * "level" is "modified", for example, by polymorph or summoning.
1150 * There is a small chance (1/50) of "boosting" the given depth by
1151 * a small amount (up to four levels), except in the town.
1153 * It is (slightly) more likely to acquire a monster of the given level
1154 * than one of a lower level. This is done by choosing several monsters
1155 * appropriate to the given level and keeping the "hardest" one.
1157 * Note that if no monsters are "appropriate", then this function will
1158 * fail, and return zero, but this should *almost* never happen.
1160 s16b get_mon_num(int level)
1168 monster_race *r_ptr;
1170 alloc_entry *table = alloc_race_table;
1172 int pls_kakuritu, pls_level;
1173 int hoge=mysqrt(level*10000L);
1175 if (level > MAX_DEPTH - 1) level = MAX_DEPTH - 1;
1177 if ((dungeon_turn > hoge*10000L) && !level)
1179 pls_kakuritu = MAX(2, NASTY_MON-((dungeon_turn/50000L-hoge/10)));
1180 pls_level = MIN(8,3 + dungeon_turn/400000L-hoge/40);
1184 pls_kakuritu = NASTY_MON;
1188 if (d_info[dungeon_type].flags1 & DF1_MAZE)
1190 pls_kakuritu = MIN(pls_kakuritu/2, pls_kakuritu-10);
1191 if (pls_kakuritu < 2) pls_kakuritu = 2;
1196 /* Boost the level */
1197 if ((level > 0) && !p_ptr->inside_battle && !(d_info[dungeon_type].flags1 & DF1_BEGINNER))
1199 /* Nightmare mode allows more out-of depth monsters */
1200 if (ironman_nightmare && !rand_int(pls_kakuritu))
1202 /* What a bizarre calculation */
1203 level = 1 + (level * MAX_DEPTH / randint(MAX_DEPTH));
1207 /* Occasional "nasty" monster */
1208 if (!rand_int(pls_kakuritu))
1210 /* Pick a level bonus */
1211 int d = MIN(5, level/10) + pls_level;
1213 /* Boost the level */
1217 /* Occasional "nasty" monster */
1218 if (!rand_int(pls_kakuritu))
1220 /* Pick a level bonus */
1221 int d = MIN(5, level/10) + pls_level;
1223 /* Boost the level */
1233 /* Process probabilities */
1234 for (i = 0; i < alloc_race_size; i++)
1236 /* Monsters are sorted by depth */
1237 if (table[i].level > level) break;
1242 /* Access the "r_idx" of the chosen monster */
1243 r_idx = table[i].index;
1245 /* Access the actual race */
1246 r_ptr = &r_info[r_idx];
1248 if (!p_ptr->inside_battle && !chameleon_change)
1250 /* Hack -- "unique" monsters must be "unique" */
1251 if (((r_ptr->flags1 & (RF1_UNIQUE)) || (r_ptr->flags7 & (RF7_UNIQUE_7))) &&
1252 (r_ptr->cur_num >= r_ptr->max_num))
1257 if (r_ptr->flags7 & (RF7_UNIQUE2))
1261 for (j = m_max -1; j >=1; j--)
1263 if(m_list[j].r_idx == r_idx)
1272 if (r_idx == MON_BANORLUPART)
1276 for (j = m_max -1; j >=1; j--)
1278 if((m_list[j].r_idx == MON_BANOR) ||(m_list[j].r_idx == MON_LUPART))
1287 /* Hack -- don't create questors */
1288 if (r_ptr->flags1 & RF1_QUESTOR)
1293 if (r_ptr->flags7 & RF7_GUARDIAN)
1298 /* Depth Monsters never appear out of depth */
1299 if ((r_ptr->flags1 & (RF1_FORCE_DEPTH)) && (r_ptr->level > dun_level))
1304 /* Some dungeon types restrict the possible monsters */
1305 /* if(!restrict_monster_to_dungeon(r_ptr) && dun_level) continue; */
1309 table[i].prob3 = table[i].prob2;
1312 total += table[i].prob3;
1315 /* No legal monsters */
1316 if (total <= 0) return (0);
1319 /* Pick a monster */
1320 value = rand_int(total);
1322 /* Find the monster */
1323 for (i = 0; i < alloc_race_size; i++)
1325 /* Found the entry */
1326 if (value < table[i].prob3) break;
1329 value = value - table[i].prob3;
1336 /* Try for a "harder" monster once (50%) or twice (10%) */
1342 /* Pick a monster */
1343 value = rand_int(total);
1345 /* Find the monster */
1346 for (i = 0; i < alloc_race_size; i++)
1348 /* Found the entry */
1349 if (value < table[i].prob3) break;
1352 value = value - table[i].prob3;
1355 /* Keep the "best" one */
1356 if (table[i].level < table[j].level) i = j;
1359 /* Try for a "harder" monster twice (10%) */
1365 /* Pick a monster */
1366 value = rand_int(total);
1368 /* Find the monster */
1369 for (i = 0; i < alloc_race_size; i++)
1371 /* Found the entry */
1372 if (value < table[i].prob3) break;
1375 value = value - table[i].prob3;
1378 /* Keep the "best" one */
1379 if (table[i].level < table[j].level) i = j;
1383 return (table[i].index);
1391 * Build a string describing a monster in some way.
1393 * We can correctly describe monsters based on their visibility.
1394 * We can force all monsters to be treated as visible or invisible.
1395 * We can build nominatives, objectives, possessives, or reflexives.
1396 * We can selectively pronominalize hidden, visible, or all monsters.
1397 * We can use definite or indefinite descriptions for hidden monsters.
1398 * We can use definite or indefinite descriptions for visible monsters.
1400 * Pronominalization involves the gender whenever possible and allowed,
1401 * so that by cleverly requesting pronominalization / visibility, you
1402 * can get messages like "You hit someone. She screams in agony!".
1404 * Reflexives are acquired by requesting Objective plus Possessive.
1406 * If no m_ptr arg is given (?), the monster is assumed to be hidden,
1407 * unless the "Assume Visible" mode is requested.
1409 * If no r_ptr arg is given, it is extracted from m_ptr and r_info
1410 * If neither m_ptr nor r_ptr is given, the monster is assumed to
1411 * be neuter, singular, and hidden (unless "Assume Visible" is set),
1412 * in which case you may be in trouble... :-)
1414 * I am assuming that no monster name is more than 70 characters long,
1415 * so that "char desc[80];" is sufficiently large for any result.
1418 * 0x01 --> Objective (or Reflexive)
1419 * 0x02 --> Possessive (or Reflexive)
1420 * 0x04 --> Use indefinites for hidden monsters ("something")
1421 * 0x08 --> Use indefinites for visible monsters ("a kobold")
1422 * 0x10 --> Pronominalize hidden monsters
1423 * 0x20 --> Pronominalize visible monsters
1424 * 0x40 --> Assume the monster is hidden
1425 * 0x80 --> Assume the monster is visible
1428 * 0x00 --> Full nominative name ("the kobold") or "it"
1429 * 0x04 --> Full nominative name ("the kobold") or "something"
1430 * 0x80 --> Genocide resistance name ("the kobold")
1431 * 0x88 --> Killing name ("a kobold")
1432 * 0x22 --> Possessive, genderized if visable ("his") or "its"
1433 * 0x23 --> Reflexive, genderized if visable ("himself") or "itself"
1435 void monster_desc(char *desc, monster_type *m_ptr, int mode)
1438 monster_race *r_ptr;
1442 char silly_name[1024];
1446 if (m_ptr->mflag2 & MFLAG_KAGE) r_ptr = &r_info[MON_KAGE];
1447 else r_ptr = &r_info[m_ptr->r_idx];
1449 if ((mode & 0x100) && (m_ptr->mflag2 & MFLAG_CHAMELEON))
1451 if (r_ptr->flags1 & RF1_UNIQUE) name = (r_name + r_info[MON_CHAMELEON_K].name);
1452 else name = (r_name + r_info[MON_CHAMELEON].name);
1454 else name = (r_name + r_ptr->name);
1456 /* Are we hallucinating? (Idea from Nethack...) */
1459 if (randint(2) == 1)
1462 if (!get_rnd_line("silly_j.txt", m_ptr->r_idx, silly_name))
1464 if (!get_rnd_line("silly.txt", m_ptr->r_idx, silly_name))
1472 monster_race *hallu_race;
1476 hallu_race = &r_info[randint(max_r_idx - 1)];
1478 while (hallu_race->flags1 & RF1_UNIQUE);
1480 strcpy(silly_name, (r_name + hallu_race->name));
1483 /* Better not strcpy it, or we could corrupt r_info... */
1487 /* Can we "see" it (exists + forced, or visible + not unforced) */
1488 seen = (m_ptr && ((mode & 0x80) || (!(mode & 0x40) && m_ptr->ml)));
1490 /* Sexed Pronouns (seen and allowed, or unseen and allowed) */
1491 pron = (m_ptr && ((seen && (mode & 0x20)) || (!seen && (mode & 0x10))));
1494 /* First, try using pronouns, or describing hidden monsters */
1497 /* an encoding of the monster "sex" */
1500 /* Extract the gender (if applicable) */
1501 if (r_ptr->flags1 & (RF1_FEMALE)) kind = 0x20;
1502 else if (r_ptr->flags1 & (RF1_MALE)) kind = 0x10;
1504 /* Ignore the gender (if desired) */
1505 if (!m_ptr || !pron) kind = 0x00;
1508 /* Assume simple result */
1516 /* Brute force: split on the possibilities */
1517 switch (kind + (mode & 0x07))
1519 /* Neuter, or unknown */
1521 case 0x00: res = "²¿¤«"; break;
1522 case 0x01: res = "²¿¤«"; break;
1523 case 0x02: res = "²¿¤«¤Î"; break;
1524 case 0x03: res = "²¿¤«¼«¿È"; break;
1525 case 0x04: res = "²¿¤«"; break;
1526 case 0x05: res = "²¿¤«"; break;
1527 case 0x06: res = "²¿¤«"; break;
1528 case 0x07: res = "¤½¤ì¼«¿È"; break;
1530 case 0x00: res = "it"; break;
1531 case 0x01: res = "it"; break;
1532 case 0x02: res = "its"; break;
1533 case 0x03: res = "itself"; break;
1534 case 0x04: res = "something"; break;
1535 case 0x05: res = "something"; break;
1536 case 0x06: res = "something's"; break;
1537 case 0x07: res = "itself"; break;
1541 /* Male (assume human if vague) */
1543 case 0x10: res = "Èà"; break;
1544 case 0x11: res = "Èà"; break;
1545 case 0x12: res = "Èà¤Î"; break;
1546 case 0x13: res = "È༫¿È"; break;
1547 case 0x14: res = "狼"; break;
1548 case 0x15: res = "狼"; break;
1549 case 0x16: res = "狼¤Î"; break;
1550 case 0x17: res = "È༫¿È"; break;
1552 case 0x10: res = "he"; break;
1553 case 0x11: res = "him"; break;
1554 case 0x12: res = "his"; break;
1555 case 0x13: res = "himself"; break;
1556 case 0x14: res = "someone"; break;
1557 case 0x15: res = "someone"; break;
1558 case 0x16: res = "someone's"; break;
1559 case 0x17: res = "himself"; break;
1563 /* Female (assume human if vague) */
1565 case 0x20: res = "Èà½÷"; break;
1566 case 0x21: res = "Èà½÷"; break;
1567 case 0x22: res = "Èà½÷¤Î"; break;
1568 case 0x23: res = "Èà½÷¼«¿È"; break;
1569 case 0x24: res = "狼"; break;
1570 case 0x25: res = "狼"; break;
1571 case 0x26: res = "狼¤Î"; break;
1572 case 0x27: res = "Èà½÷¼«¿È"; break;
1574 case 0x20: res = "she"; break;
1575 case 0x21: res = "her"; break;
1576 case 0x22: res = "her"; break;
1577 case 0x23: res = "herself"; break;
1578 case 0x24: res = "someone"; break;
1579 case 0x25: res = "someone"; break;
1580 case 0x26: res = "someone's"; break;
1581 case 0x27: res = "herself"; break;
1586 /* Copy the result */
1587 (void)strcpy(desc, res);
1591 /* Handle visible monsters, "reflexive" request */
1592 else if ((mode & 0x02) && (mode & 0x01))
1594 /* The monster is visible, so use its gender */
1596 if (r_ptr->flags1 & (RF1_FEMALE)) strcpy(desc, "Èà½÷¼«¿È");
1597 else if (r_ptr->flags1 & (RF1_MALE)) strcpy(desc, "È༫¿È");
1598 else strcpy(desc, "¤½¤ì¼«¿È");
1600 if (r_ptr->flags1 & RF1_FEMALE) strcpy(desc, "herself");
1601 else if (r_ptr->flags1 & RF1_MALE) strcpy(desc, "himself");
1602 else strcpy(desc, "itself");
1608 /* Handle all other visible monster requests */
1611 /* It could be a Unique */
1612 if ((r_ptr->flags1 & RF1_UNIQUE) && !p_ptr->image)
1614 /* Start with the name (thus nominative and objective) */
1615 if ((m_ptr->mflag2 & MFLAG_CHAMELEON) && !(mode & 0x100))
1621 while(strncmp(t, "¡Ù", 2) && *t) t++;
1625 (void)sprintf(desc, "%s¡©¡Ù", buf);
1628 (void)sprintf(desc, "%s¡©", name);
1630 (void)sprintf(desc, "%s?", name);
1633 else if ((cave[m_ptr->fy][m_ptr->fx].m_idx == p_ptr->riding) || !p_ptr->inside_battle)
1634 (void)strcpy(desc, name);
1637 (void)sprintf(desc, "%s¤â¤É¤", name);
1639 (void)sprintf(desc, "fake %s", name);
1643 /* It could be an indefinite monster */
1644 else if (mode & 0x08)
1646 /* XXX Check plurality for "some" */
1648 /* Indefinite monsters need an indefinite article */
1650 (void)strcpy(desc, "");
1652 (void)strcpy(desc, is_a_vowel(name[0]) ? "an " : "a ");
1655 (void)strcat(desc, name);
1657 if (m_ptr->nickname)
1660 sprintf(buf,"¡Ö%s¡×",quark_str(m_ptr->nickname));
1662 sprintf(buf," called %s",quark_str(m_ptr->nickname));
1668 /* It could be a normal, definite, monster */
1671 /* Definite monsters need a definite article */
1674 (void)strcpy(desc, "¤¢¤Ê¤¿¤Î");
1676 (void)strcpy(desc, "your ");
1681 (void)strcpy(desc, "");
1683 (void)strcpy(desc, "the ");
1686 (void)strcat(desc, name);
1688 if (m_ptr->nickname)
1691 sprintf(buf,"¡Ö%s¡×",quark_str(m_ptr->nickname));
1693 sprintf(buf," called %s",quark_str(m_ptr->nickname));
1698 if ((m_ptr->fy == py) && (m_ptr->fx == px))
1700 strcat(desc,"(¾èÇÏÃæ)");
1702 strcat(desc,"(riding)");
1704 if ((mode & 0x200) && (m_ptr->mflag2 & MFLAG_CHAMELEON))
1706 if (r_ptr->flags1 & RF1_UNIQUE)
1708 strcat(desc,"(¥«¥á¥ì¥ª¥ó¤Î²¦)");
1710 strcat(desc,"(Chameleon Lord)");
1714 strcat(desc,"(¥«¥á¥ì¥ª¥ó)");
1716 strcat(desc,"(Chameleon)");
1721 /* Handle the Possessive as a special afterthought */
1724 /* XXX Check for trailing "s" */
1726 /* Simply append "apostrophe" and "s" */
1728 (void)strcat(desc, "¤Î");
1730 (void)strcat(desc, "'s");
1741 * Learn about a monster (by "probing" it)
1743 void lore_do_probe(int m_idx)
1745 monster_type *m_ptr = &m_list[m_idx];
1747 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1749 /* Hack -- Memorize some flags */
1750 r_ptr->r_flags1 = r_ptr->flags1;
1751 r_ptr->r_flags2 = r_ptr->flags2;
1752 r_ptr->r_flags3 = r_ptr->flags3;
1754 /* Update monster recall window */
1755 if (p_ptr->monster_race_idx == m_ptr->r_idx)
1758 p_ptr->window |= (PW_MONSTER);
1764 * Take note that the given monster just dropped some treasure
1766 * Note that learning the "GOOD"/"GREAT" flags gives information
1767 * about the treasure (even when the monster is killed for the first
1768 * time, such as uniques, and the treasure has not been examined yet).
1770 * This "indirect" method is used to prevent the player from learning
1771 * exactly how much treasure a monster can drop from observing only
1772 * a single example of a drop. This method actually observes how much
1773 * gold and items are dropped, and remembers that information to be
1774 * described later by the monster recall code.
1776 void lore_treasure(int m_idx, int num_item, int num_gold)
1778 monster_type *m_ptr = &m_list[m_idx];
1780 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1782 /* Note the number of things dropped */
1783 if (num_item > r_ptr->r_drop_item) r_ptr->r_drop_item = num_item;
1784 if (num_gold > r_ptr->r_drop_gold) r_ptr->r_drop_gold = num_gold;
1786 /* Hack -- memorize the good/great flags */
1787 if (r_ptr->flags1 & (RF1_DROP_GOOD)) r_ptr->r_flags1 |= (RF1_DROP_GOOD);
1788 if (r_ptr->flags1 & (RF1_DROP_GREAT)) r_ptr->r_flags1 |= (RF1_DROP_GREAT);
1790 /* Update monster recall window */
1791 if (p_ptr->monster_race_idx == m_ptr->r_idx)
1794 p_ptr->window |= (PW_MONSTER);
1800 void sanity_blast(monster_type *m_ptr, bool necro)
1802 bool happened = FALSE;
1805 if (p_ptr->inside_battle || !character_dungeon) return;
1810 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1812 power = r_ptr->level / 2;
1814 monster_desc(m_name, m_ptr, 0);
1816 if (!(r_ptr->flags1 & RF1_UNIQUE))
1818 if (r_ptr->flags1 & RF1_FRIENDS)
1824 return; /* No effect yet, just loaded... */
1827 return; /* Cannot see it for some reason */
1829 if (!(r_ptr->flags2 & RF2_ELDRITCH_HORROR))
1835 return; /* Pet eldritch horrors are safe most of the time */
1837 if (randint(100) > power) return;
1839 if (saving_throw(p_ptr->skill_sav - power))
1841 return; /* Save, no adverse effects */
1846 /* Something silly happens... */
1848 msg_format("%s%s¤Î´é¤ò¸«¤Æ¤·¤Þ¤Ã¤¿¡ª",
1850 msg_format("You behold the %s visage of %s!",
1853 funny_desc[rand_int(MAX_SAN_FUNNY)], m_name);
1855 if (randint(3) == 1)
1857 msg_print(funny_comments[rand_int(MAX_SAN_COMMENT)]);
1858 p_ptr->image = p_ptr->image + randint(r_ptr->level);
1861 return; /* Never mind; we can't see it clearly enough */
1864 /* Something frightening happens... */
1866 msg_format("%s%s¤Î´é¤ò¸«¤Æ¤·¤Þ¤Ã¤¿¡ª",
1868 msg_format("You behold the %s visage of %s!",
1871 horror_desc[rand_int(MAX_SAN_HORROR)], m_name);
1873 r_ptr->r_flags2 |= RF2_ELDRITCH_HORROR;
1875 /* Demon characters are unaffected */
1876 if ((p_ptr->prace == RACE_IMP) || (p_ptr->prace == RACE_DEMON) || (mimic_info[p_ptr->mimic_form].MIMIC_FLAGS & MIMIC_IS_DEMON)) return;
1879 /* Undead characters are 50% likely to be unaffected */
1880 if ((p_ptr->prace == RACE_SKELETON) || (p_ptr->prace == RACE_ZOMBIE)
1881 || (p_ptr->prace == RACE_VAMPIRE) || (p_ptr->prace == RACE_SPECTRE) ||
1882 (mimic_info[p_ptr->mimic_form].MIMIC_FLAGS & MIMIC_IS_UNDEAD))
1884 if (saving_throw(25 + p_ptr->lev)) return;
1890 msg_print("¥Í¥¯¥í¥Î¥ß¥³¥ó¤òÆɤó¤ÇÀµµ¤¤ò¼º¤Ã¤¿¡ª");
1892 msg_print("Your sanity is shaken by reading the Necronomicon!");
1897 if (!saving_throw(p_ptr->skill_sav - power)) /* Mind blast */
1899 if (!p_ptr->resist_conf)
1901 (void)set_confused(p_ptr->confused + rand_int(4) + 4);
1903 if (!p_ptr->resist_chaos && one_in_(3))
1905 (void)set_image(p_ptr->image + rand_int(250) + 150);
1910 if (!saving_throw(p_ptr->skill_sav - power)) /* Lose int & wis */
1917 if (!saving_throw(p_ptr->skill_sav - power)) /* Brain smash */
1919 if (!p_ptr->resist_conf)
1921 (void)set_confused(p_ptr->confused + rand_int(4) + 4);
1923 if (!p_ptr->free_act)
1925 (void)set_paralyzed(p_ptr->paralyzed + rand_int(4) + 4);
1927 while (rand_int(100) > p_ptr->skill_sav)
1928 (void)do_dec_stat(A_INT);
1929 while (rand_int(100) > p_ptr->skill_sav)
1930 (void)do_dec_stat(A_WIS);
1931 if (!p_ptr->resist_chaos)
1933 (void)set_image(p_ptr->image + rand_int(250) + 150);
1938 if (!saving_throw(p_ptr->skill_sav - power)) /* Amnesia */
1941 if (lose_all_info())
1943 msg_print("¤¢¤Þ¤ê¤Î¶²ÉݤËÁ´¤Æ¤Î¤³¤È¤ò˺¤ì¤Æ¤·¤Þ¤Ã¤¿¡ª");
1945 msg_print("You forget everything in your utmost terror!");
1951 if (saving_throw(p_ptr->skill_sav - power))
1956 /* Else gain permanent insanity */
1957 if ((p_ptr->muta3 & MUT3_MORONIC) && /*(p_ptr->muta2 & MUT2_BERS_RAGE) &&*/
1958 ((p_ptr->muta2 & MUT2_COWARDICE) || (p_ptr->resist_fear)) &&
1959 ((p_ptr->muta2 & MUT2_HALLU) || (p_ptr->resist_chaos)))
1961 /* The poor bastard already has all possible insanities! */
1967 switch (randint(21))
1970 if (!(p_ptr->muta3 & MUT3_MORONIC) && one_in_(5))
1972 if ((p_ptr->stat_use[A_INT] < 4) && (p_ptr->stat_use[A_WIS] < 4))
1975 msg_print("¤¢¤Ê¤¿¤Ï´°àú¤ÊÇϼ¯¤Ë¤Ê¤Ã¤¿¤è¤¦¤Êµ¤¤¬¤·¤¿¡£¤·¤«¤·¤½¤ì¤Ï¸µ¡¹¤À¤Ã¤¿¡£");
1977 msg_print("You turn into an utter moron!");
1983 msg_print("¤¢¤Ê¤¿¤Ï´°àú¤ÊÇϼ¯¤Ë¤Ê¤Ã¤¿¡ª");
1985 msg_print("You turn into an utter moron!");
1989 if (p_ptr->muta3 & MUT3_HYPER_INT)
1992 msg_print("¤¢¤Ê¤¿¤ÎǾ¤ÏÀ¸ÂÎ¥³¥ó¥Ô¥å¡¼¥¿¤Ç¤Ï¤Ê¤¯¤Ê¤Ã¤¿¡£");
1994 msg_print("Your brain is no longer a living computer.");
1997 p_ptr->muta3 &= ~(MUT3_HYPER_INT);
1999 p_ptr->muta3 |= MUT3_MORONIC;
2013 if (!(p_ptr->muta2 & MUT2_COWARDICE) && !p_ptr->resist_fear)
2016 msg_print("¤¢¤Ê¤¿¤Ï¥Ñ¥é¥Î¥¤¥¢¤Ë¤Ê¤Ã¤¿¡ª");
2018 msg_print("You become paranoid!");
2022 /* Duh, the following should never happen, but anyway... */
2023 if (p_ptr->muta3 & MUT3_FEARLESS)
2026 msg_print("¤¢¤Ê¤¿¤Ï¤â¤¦¶²¤ìÃΤ餺¤Ç¤Ï¤Ê¤¯¤Ê¤Ã¤¿¡£");
2028 msg_print("You are no longer fearless.");
2031 p_ptr->muta3 &= ~(MUT3_FEARLESS);
2034 p_ptr->muta2 |= MUT2_COWARDICE;
2048 if (!(p_ptr->muta2 & MUT2_HALLU) && !p_ptr->resist_chaos)
2051 msg_print("¸¸³Ð¤ò¤Ò¤µ¯¤³¤¹Àº¿ÀºøÍð¤Ë´Ù¤Ã¤¿¡ª");
2053 msg_print("You are afflicted by a hallucinatory insanity!");
2056 p_ptr->muta2 |= MUT2_HALLU;
2061 if (!(p_ptr->muta2 & MUT2_BERS_RAGE))
2064 msg_print("·ãÎõ¤Ê´¶¾ð¤Îȯºî¤Ë¤ª¤½¤ï¤ì¤ë¤è¤¦¤Ë¤Ê¤Ã¤¿¡ª");
2066 msg_print("You become subject to fits of berserk rage!");
2069 p_ptr->muta2 |= MUT2_BERS_RAGE;
2076 p_ptr->update |= PU_BONUS;
2082 * This function updates the monster record of the given monster
2084 * This involves extracting the distance to the player (if requested),
2085 * and then checking for visibility (natural, infravision, see-invis,
2086 * telepathy), updating the monster visibility flag, redrawing (or
2087 * erasing) the monster when its visibility changes, and taking note
2088 * of any interesting monster flags (cold-blooded, invisible, etc).
2090 * Note the new "mflag" field which encodes several monster state flags,
2091 * including "view" for when the monster is currently in line of sight,
2092 * and "mark" for when the monster is currently visible via detection.
2094 * The only monster fields that are changed here are "cdis" (the
2095 * distance from the player), "ml" (visible to the player), and
2096 * "mflag" (to maintain the "MFLAG_VIEW" flag).
2098 * Note the special "update_monsters()" function which can be used to
2099 * call this function once for every monster.
2101 * Note the "full" flag which requests that the "cdis" field be updated,
2102 * this is only needed when the monster (or the player) has moved.
2104 * Every time a monster moves, we must call this function for that
2105 * monster, and update the distance, and the visibility. Every time
2106 * the player moves, we must call this function for every monster, and
2107 * update the distance, and the visibility. Whenever the player "state"
2108 * changes in certain ways ("blindness", "infravision", "telepathy",
2109 * and "see invisible"), we must call this function for every monster,
2110 * and update the visibility.
2112 * Routines that change the "illumination" of a grid must also call this
2113 * function for any monster in that grid, since the "visibility" of some
2114 * monsters may be based on the illumination of their grid.
2116 * Note that this function is called once per monster every time the
2117 * player moves. When the player is running, this function is one
2118 * of the primary bottlenecks, along with "update_view()" and the
2119 * "process_monsters()" code, so efficiency is important.
2121 * Note the optimized "inline" version of the "distance()" function.
2123 * A monster is "visible" to the player if (1) it has been detected
2124 * by the player, (2) it is close to the player and the player has
2125 * telepathy, or (3) it is close to the player, and in line of sight
2126 * of the player, and it is "illuminated" by some combination of
2127 * infravision, torch light, or permanent light (invisible monsters
2128 * are only affected by "light" if the player can see invisible).
2130 * Monsters which are not on the current panel may be "visible" to
2131 * the player, and their descriptions will include an "offscreen"
2132 * reference. Currently, offscreen monsters cannot be targetted
2133 * or viewed directly, but old targets will remain set. XXX XXX
2135 * The player can choose to be disturbed by several things, including
2136 * "disturb_move" (monster which is viewable moves in some way), and
2137 * "disturb_near" (monster which is "easily" viewable moves in some
2138 * way). Note that "moves" includes "appears" and "disappears".
2140 void update_mon(int m_idx, bool full)
2142 monster_type *m_ptr = &m_list[m_idx];
2144 monster_race *r_ptr = &r_info[m_ptr->r_idx];
2148 /* Current location */
2155 /* Seen by vision */
2159 /* Compute distance */
2162 /* Distance components */
2163 int dy = (py > fy) ? (py - fy) : (fy - py);
2164 int dx = (px > fx) ? (px - fx) : (fx - px);
2166 /* Approximate distance */
2167 d = (dy > dx) ? (dy + (dx>>1)) : (dx + (dy>>1));
2169 /* Restrict distance */
2170 if (d > 255) d = 255;
2174 /* Save the distance */
2178 /* Extract distance */
2181 /* Extract the distance */
2187 if (m_ptr->mflag & (MFLAG_MARK)) flag = TRUE;
2191 if (d <= ((d_info[dungeon_type].flags1 & DF1_DARKNESS) ? MAX_SIGHT / 2 : MAX_SIGHT))
2193 if (!(d_info[dungeon_type].flags1 & DF1_DARKNESS) || (d <= MAX_SIGHT / 4))
2195 if (p_ptr->special_defense & KATA_MUSOU)
2200 /* Hack -- Memorize mental flags */
2201 if (r_ptr->flags2 & (RF2_SMART)) r_ptr->r_flags2 |= (RF2_SMART);
2202 if (r_ptr->flags2 & (RF2_STUPID)) r_ptr->r_flags2 |= (RF2_STUPID);
2205 /* Basic telepathy */
2206 else if (p_ptr->telepathy)
2208 /* Empty mind, no telepathy */
2209 if (r_ptr->flags2 & (RF2_EMPTY_MIND))
2211 /* Memorize flags */
2212 r_ptr->r_flags2 |= (RF2_EMPTY_MIND);
2215 /* Weird mind, occasional telepathy */
2216 else if (r_ptr->flags2 & (RF2_WEIRD_MIND))
2218 /* One in ten individuals are detectable */
2219 if ((m_idx % 10) == 5)
2224 /* Memorize flags */
2225 r_ptr->r_flags2 |= (RF2_WEIRD_MIND);
2227 /* Hack -- Memorize mental flags */
2228 if (r_ptr->flags2 & (RF2_SMART)) r_ptr->r_flags2 |= (RF2_SMART);
2229 if (r_ptr->flags2 & (RF2_STUPID)) r_ptr->r_flags2 |= (RF2_STUPID);
2233 /* Normal mind, allow telepathy */
2239 /* Hack -- Memorize mental flags */
2240 if (r_ptr->flags2 & (RF2_SMART)) r_ptr->r_flags2 |= (RF2_SMART);
2241 if (r_ptr->flags2 & (RF2_STUPID)) r_ptr->r_flags2 |= (RF2_STUPID);
2246 /* Normal line of sight, and not blind */
2247 if (player_has_los_bold(fy, fx) && !p_ptr->blind)
2249 bool do_invisible = FALSE;
2250 bool do_cold_blood = FALSE;
2252 /* Use "infravision" */
2253 if (d <= p_ptr->see_infra)
2255 /* Handle "cold blooded" monsters */
2256 if (r_ptr->flags2 & (RF2_COLD_BLOOD))
2259 do_cold_blood = TRUE;
2262 /* Handle "warm blooded" monsters */
2270 /* Use "illumination" */
2271 if (player_can_see_bold(fy, fx))
2273 /* Handle "invisible" monsters */
2274 if (r_ptr->flags2 & (RF2_INVISIBLE))
2277 do_invisible = TRUE;
2287 /* Handle "normal" monsters */
2298 /* Memorize flags */
2299 if (do_invisible) r_ptr->r_flags2 |= (RF2_INVISIBLE);
2300 if (do_cold_blood) r_ptr->r_flags2 |= (RF2_COLD_BLOOD);
2306 /* The monster is now visible */
2309 /* It was previously unseen */
2312 /* Mark as visible */
2315 /* Draw the monster */
2318 /* Update health bar as needed */
2319 if (p_ptr->health_who == m_idx) p_ptr->redraw |= (PR_HEALTH);
2320 if (p_ptr->riding == m_idx) p_ptr->redraw |= (PR_UHEALTH);
2322 /* Hack -- Count "fresh" sightings */
2323 if ((m_ptr->mflag2 & MFLAG_KAGE) && (r_info[MON_KAGE].r_sights < MAX_SHORT))
2324 r_info[MON_KAGE].r_sights++;
2325 else if (r_ptr->r_sights < MAX_SHORT) r_ptr->r_sights++;
2327 /* Eldritch Horror */
2328 if (r_ptr->flags2 & RF2_ELDRITCH_HORROR)
2330 sanity_blast(m_ptr, FALSE);
2333 /* Disturb on appearance */
2334 if (disturb_near && (projectable(m_ptr->fy, m_ptr->fx, py, px) && projectable(py, px, m_ptr->fy, m_ptr->fx)))
2336 if (disturb_pets || is_hostile(m_ptr))
2342 /* The monster is not visible */
2345 /* It was previously seen */
2348 /* Mark as not visible */
2351 /* Erase the monster */
2354 /* Update health bar as needed */
2355 if (p_ptr->health_who == m_idx) p_ptr->redraw |= (PR_HEALTH);
2356 if (p_ptr->riding == m_idx) p_ptr->redraw |= (PR_UHEALTH);
2358 /* Disturb on disappearance */
2361 if (disturb_pets || is_hostile(m_ptr))
2368 /* The monster is now easily visible */
2372 if (!(m_ptr->mflag & (MFLAG_VIEW)))
2374 /* Mark as easily visible */
2375 m_ptr->mflag |= (MFLAG_VIEW);
2377 /* Disturb on appearance */
2380 if (disturb_pets || is_hostile(m_ptr))
2386 /* The monster is not easily visible */
2390 if (m_ptr->mflag & (MFLAG_VIEW))
2392 /* Mark as not easily visible */
2393 m_ptr->mflag &= ~(MFLAG_VIEW);
2395 /* Disturb on disappearance */
2398 if (disturb_pets || is_hostile(m_ptr))
2407 * This function simply updates all the (non-dead) monsters (see above).
2409 void update_monsters(bool full)
2413 /* Update each (live) monster */
2414 for (i = 1; i < m_max; i++)
2416 monster_type *m_ptr = &m_list[i];
2418 /* Skip dead monsters */
2419 if (!m_ptr->r_idx) continue;
2421 /* Update the monster */
2422 update_mon(i, full);
2428 void choose_new_monster(int m_idx, bool born, int r_idx)
2432 monster_type *m_ptr = &m_list[m_idx];
2433 monster_race *r_ptr;
2434 char old_m_name[80];
2435 int old_r_idx = m_ptr->r_idx;
2436 bool old_unique = FALSE;
2438 if (r_info[m_ptr->r_idx].flags1 & RF1_UNIQUE) old_unique = TRUE;
2439 if (old_unique && (r_idx == MON_CHAMELEON)) r_idx = MON_CHAMELEON_K;
2440 r_ptr = &r_info[r_idx];
2442 monster_desc(old_m_name, m_ptr, 0);
2446 chameleon_change = TRUE;
2447 get_mon_num_prep(get_monster_hook(), NULL);
2452 if (!dun_level) level = wilderness[p_ptr->wilderness_y][p_ptr->wilderness_x].level;
2453 else level = dun_level;
2454 if (d_info[dungeon_type].flags1 & DF1_CHAMELEON) level+= 2+randint(3);
2455 r_idx = get_mon_num(level);
2456 r_ptr = &r_info[r_idx];
2457 if ((old_unique && !(r_ptr->flags1 & RF1_UNIQUE)) || (!old_unique && (r_ptr->flags1 & RF1_UNIQUE))) continue;
2460 if (ABS(r_ptr->level - r_info[MON_CHAMELEON_K].level) > 5) continue;
2461 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)) continue;
2463 if ((r_ptr->flags2 & RF2_MULTIPLY) || (r_ptr->flags7 & (RF7_UNIQUE_7 | RF7_GUARDIAN | RF7_FRIENDLY | RF7_UNIQUE2 | RF7_CHAMELEON))) continue;
2464 if (!monster_can_cross_terrain(cave[m_ptr->fy][m_ptr->fx].feat, r_ptr)) continue;
2465 if (!born && !old_unique)
2467 if ((r_info[old_r_idx].flags3 & RF3_GOOD) && !(r_ptr->flags3 & RF3_GOOD)) continue;
2468 if ((r_info[old_r_idx].flags3 & RF3_EVIL) && !(r_ptr->flags3 & RF3_EVIL)) continue;
2469 if (!(r_info[old_r_idx].flags3 & (RF3_GOOD | RF3_EVIL)) && (r_ptr->flags3 & (RF3_GOOD | RF3_EVIL))) continue;
2471 if (born && !old_unique && summon_specific_type)
2473 if (!summon_specific_aux(r_idx)) continue;
2477 chameleon_change = FALSE;
2478 if (!attempt) return;
2481 m_ptr->r_idx = r_idx;
2482 update_mon(m_idx, FALSE);
2483 lite_spot(m_ptr->fy, m_ptr->fx);
2486 if (m_idx == p_ptr->riding)
2489 monster_desc(m_name, m_ptr, 0);
2491 msg_format("ÆÍÁ³%s¤¬ÊѿȤ·¤¿¡£", old_m_name);
2493 msg_format("Suddenly, %s transforms!", old_m_name);
2495 if (!(r_ptr->flags7 & RF7_RIDING))
2497 if (rakuba(0, TRUE)) msg_print("ÃÏÌ̤ËÍî¤È¤µ¤ì¤¿¡£");
2499 if (rakuba(0, TRUE)) msg_format("You have fallen from %s.", m_name);
2503 /* Extract the monster base speed */
2504 m_ptr->mspeed = r_ptr->speed;
2505 /* Hack -- small racial variety */
2506 /* Allow some small variation per monster */
2507 if(rand_int(4) == 1){
2508 i = extract_energy[r_ptr->speed] / 3;
2509 if (i) m_ptr->mspeed += rand_spread(0, i);
2512 i = extract_energy[r_ptr->speed] / 10;
2513 if (i) m_ptr->mspeed += rand_spread(0, i);
2516 oldmaxhp = m_ptr->max_maxhp;
2517 /* Assign maximal hitpoints */
2518 if (r_ptr->flags1 & RF1_FORCE_MAXHP)
2520 m_ptr->max_maxhp = maxroll(r_ptr->hdice, r_ptr->hside);
2524 m_ptr->max_maxhp = damroll(r_ptr->hdice, r_ptr->hside);
2526 m_ptr->maxhp = (long)(m_ptr->maxhp * m_ptr->max_maxhp) / oldmaxhp;
2527 m_ptr->hp = (long)(m_ptr->hp * m_ptr->max_maxhp) / oldmaxhp;
2532 * Attempt to place a monster of the given race at the given location.
2534 * To give the player a sporting chance, any monster that appears in
2535 * line-of-sight and is extremely dangerous can be marked as
2536 * "FORCE_SLEEP", which will cause them to be placed with low energy,
2537 * which often (but not always) lets the player move before they do.
2539 * This routine refuses to place out-of-depth "FORCE_DEPTH" monsters.
2541 * XXX XXX XXX Use special "here" and "dead" flags for unique monsters,
2542 * remove old "cur_num" and "max_num" fields.
2544 * XXX XXX XXX Actually, do something similar for artifacts, to simplify
2545 * the "preserve" mode, and to make the "what artifacts" flag more useful.
2547 * This is the only function which may place a monster in the dungeon,
2548 * except for the savefile loading code.
2550 bool place_monster_one(int y, int x, int r_idx, bool slp, bool friendly, bool pet, bool no_pet)
2557 monster_type *m_ptr;
2559 monster_race *r_ptr = &r_info[r_idx];
2561 cptr name = (r_name + r_ptr->name);
2563 /* DO NOT PLACE A MONSTER IN THE SMALL SCALE WILDERNESS !!! */
2564 if(p_ptr->wild_mode) return FALSE;
2566 /* Verify location */
2567 if (!in_bounds(y, x)) return (FALSE);
2569 /* Require empty space (if not ghostly) */
2570 if (!(!dun_level && (cave[y][x].feat == FEAT_MOUNTAIN) && ((r_ptr->flags8 & RF8_WILD_MOUNTAIN) || (r_ptr->flags7 & RF7_CAN_FLY))) &&
2571 !cave_empty_bold2(y, x) &&
2572 !((r_ptr->flags2 & RF2_PASS_WALL) &&
2573 !(cave_perma_bold(y, x) || cave[y][x].m_idx ||
2574 ((y == py) && (x == px))))) return (FALSE);
2577 if (!r_idx) return (FALSE);
2580 if (!r_ptr->name) return (FALSE);
2583 /* Hack -- no creation on glyph of warding */
2584 if (cave[y][x].feat == FEAT_GLYPH) return (FALSE);
2585 if (cave[y][x].feat == FEAT_MINOR_GLYPH) return (FALSE);
2588 /* Nor on the Pattern */
2589 if ((cave[y][x].feat >= FEAT_PATTERN_START)
2590 && (cave[y][x].feat <= FEAT_PATTERN_XTRA2))
2593 if (monster_terrain_sensitive &&
2594 !monster_can_cross_terrain(cave[y][x].feat, r_ptr))
2599 if (!p_ptr->inside_battle)
2601 /* Hack -- "unique" monsters must be "unique" */
2602 if (((r_ptr->flags1 & (RF1_UNIQUE)) || (r_ptr->flags7 & (RF7_UNIQUE_7))) &&
2603 (r_ptr->cur_num >= r_ptr->max_num))
2609 if (r_ptr->flags7 & (RF7_UNIQUE2))
2613 for (j = m_max -1; j >=1; j--)
2615 if(m_list[j].r_idx == r_idx)
2621 if (fail) return (FALSE);
2624 if (r_idx == MON_BANORLUPART)
2628 for (j = m_max -1; j >=1; j--)
2630 if((m_list[j].r_idx == MON_BANOR) ||(m_list[j].r_idx == MON_LUPART))
2636 if (fail) return (FALSE);
2639 /* Depth monsters may NOT be created out of depth, unless in Nightmare mode */
2640 if ((r_ptr->flags1 & (RF1_FORCE_DEPTH)) && (dun_level < r_ptr->level) &&
2641 (!ironman_nightmare || (r_ptr->flags1 & (RF1_QUESTOR))))
2648 if(quest_number(dun_level))
2650 int hoge = quest_number(dun_level);
2651 if((quest[hoge].type == QUEST_TYPE_KILL_LEVEL) || (quest[hoge].type == QUEST_TYPE_RANDOM))
2653 if(r_idx == quest[hoge].r_idx)
2655 int number_mon, i2, j2;
2658 /* Count all quest monsters */
2659 for (i2 = 0; i2 < cur_wid; ++i2)
2660 for (j2 = 0; j2 < cur_hgt; j2++)
2661 if (cave[j2][i2].m_idx > 0)
2662 if (m_list[cave[j2][i2].m_idx].r_idx == quest[hoge].r_idx)
2664 if(number_mon + quest[hoge].cur_num >= quest[hoge].max_num)
2670 /* Access the location */
2671 c_ptr = &cave[y][x];
2673 if (c_ptr->feat == FEAT_GLYPH)
2675 if (randint(BREAK_GLYPH) < (r_ptr->level+20))
2677 /* Describe observable breakage */
2678 if (c_ptr->info & CAVE_MARK)
2681 msg_print("¼é¤ê¤Î¥ë¡¼¥ó¤¬²õ¤ì¤¿¡ª");
2683 msg_print("The rune of protection is broken!");
2688 /* Forget the rune */
2689 c_ptr->info &= ~(CAVE_MARK);
2691 /* Break the rune */
2692 c_ptr->feat = floor_type[rand_int(100)];
2693 c_ptr->info &= ~(CAVE_MASK);
2694 c_ptr->info |= CAVE_FLOOR;
2703 /* Powerful monster */
2704 if (r_ptr->level > dun_level)
2706 /* Unique monsters */
2707 if (r_ptr->flags1 & (RF1_UNIQUE))
2709 /* Message for cheaters */
2711 if (cheat_hear) msg_format("¿¼ÁؤΥæ¥Ë¡¼¥¯¡¦¥â¥ó¥¹¥¿¡¼ (%s)¡£", name);
2713 if (cheat_hear) msg_format("Deep Unique (%s).", name);
2717 /* Boost rating by twice delta-depth */
2718 rating += (r_ptr->level - dun_level) * 2;
2721 /* Normal monsters */
2724 /* Message for cheaters */
2726 if (cheat_hear) msg_format("¿¼ÁؤΥâ¥ó¥¹¥¿¡¼ (%s)¡£", name);
2728 if (cheat_hear) msg_format("Deep Monster (%s).", name);
2732 /* Boost rating by delta-depth */
2733 rating += (r_ptr->level - dun_level);
2737 /* Note the monster */
2738 else if (r_ptr->flags1 & (RF1_UNIQUE))
2740 /* Unique monsters induce message */
2742 if (cheat_hear) msg_format("¥æ¥Ë¡¼¥¯¡¦¥â¥ó¥¹¥¿¡¼ (%s)¡£", name);
2744 if (cheat_hear) msg_format("Unique (%s).", name);
2749 if ((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags7 & RF7_UNIQUE_7) || (r_ptr->level < 10)) is_kage = FALSE;
2751 /* Make a new monster */
2752 c_ptr->m_idx = m_pop();
2753 hack_m_idx_ii = c_ptr->m_idx;
2755 /* Mega-Hack -- catch "failure" */
2756 if (!c_ptr->m_idx) return (FALSE);
2759 /* Get a new monster record */
2760 m_ptr = &m_list[c_ptr->m_idx];
2763 m_ptr->r_idx = r_idx;
2765 /* Place the monster at the location */
2770 /* No "damage" yet */
2772 m_ptr->confused = 0;
2775 /* Unknown distance */
2778 m_ptr->target_y = 0;
2779 m_ptr->target_x = 0;
2781 m_ptr->nickname = 0;
2789 if (r_ptr->flags7 & RF7_CHAMELEON)
2791 choose_new_monster(c_ptr->m_idx, TRUE, 0);
2792 r_ptr = &r_info[m_ptr->r_idx];
2793 m_ptr->mflag2 |= MFLAG_CHAMELEON;
2796 else if (is_kage) m_ptr->mflag2 |= MFLAG_KAGE;
2797 if (no_pet) m_ptr->mflag2 |= MFLAG_NOPET;
2808 else if ((friendly || (r_ptr->flags7 & RF7_FRIENDLY)) &&
2809 !(p_ptr->align >= 0 && (r_ptr->flags3 & RF3_EVIL)) &&
2810 !(p_ptr->align < 0 && (r_ptr->flags3 & RF3_GOOD)))
2812 set_friendly(m_ptr);
2815 /* Assume no sleeping */
2818 /* Enforce sleeping if needed */
2819 if (slp && r_ptr->sleep && !ironman_nightmare)
2821 int val = r_ptr->sleep;
2822 m_ptr->csleep = ((val * 2) + randint(val * 10));
2825 /* Assign maximal hitpoints */
2826 if (r_ptr->flags1 & RF1_FORCE_MAXHP)
2828 m_ptr->max_maxhp = maxroll(r_ptr->hdice, r_ptr->hside);
2832 m_ptr->max_maxhp = damroll(r_ptr->hdice, r_ptr->hside);
2835 /* Monsters have double hitpoints in Nightmare mode */
2836 if (ironman_nightmare)
2838 u32b hp = m_ptr->max_maxhp * 2L;
2840 m_ptr->max_maxhp = (s16b)MIN(30000, hp);
2843 m_ptr->maxhp = m_ptr->max_maxhp;
2845 /* And start out fully healthy */
2846 if (m_ptr->r_idx == MON_WOUNDED_BEAR)
2847 m_ptr->hp = m_ptr->maxhp / 2;
2848 else m_ptr->hp = m_ptr->maxhp;
2851 /* Extract the monster base speed */
2852 m_ptr->mspeed = r_ptr->speed;
2854 /* Hack -- small racial variety */
2855 if (!(r_ptr->flags1 & RF1_UNIQUE) && !p_ptr->inside_arena)
2857 /* Allow some small variation per monster */
2858 if(rand_int(4) == 1){
2859 i = extract_energy[r_ptr->speed] / 3;
2860 if (i) m_ptr->mspeed += rand_spread(0, i);
2863 i = extract_energy[r_ptr->speed] / 10;
2864 if (i) m_ptr->mspeed += rand_spread(0, i);
2868 if (m_ptr->mspeed > 199) m_ptr->mspeed = 199;
2870 /* Give a random starting energy */
2871 m_ptr->energy = (byte)rand_int(100);
2873 /* Nightmare monsters are more prepared */
2874 if (ironman_nightmare)
2879 /* Force monster to wait for player, unless in Nightmare mode */
2880 if ((r_ptr->flags1 & RF1_FORCE_SLEEP) && !ironman_nightmare)
2882 /* Monster is still being nice */
2883 m_ptr->mflag |= (MFLAG_NICE);
2885 /* Must repair monsters */
2886 repair_monsters = TRUE;
2889 /* Hack -- see "process_monsters()" */
2890 if (c_ptr->m_idx < hack_m_idx)
2892 /* Monster is still being born */
2893 m_ptr->mflag |= (MFLAG_BORN);
2897 /* Update the monster */
2898 update_mon(c_ptr->m_idx, TRUE);
2901 /* Hack -- Count the monsters on the level */
2905 /* Hack -- Count the number of "reproducers" */
2906 if (r_ptr->flags2 & RF2_MULTIPLY) num_repro++;
2909 /* Hack -- Notice new multi-hued monsters */
2910 if (r_ptr->flags1 & RF1_ATTR_MULTI) shimmer_monsters = TRUE;
2913 create_monster_callback(c_ptr->m_idx);
2914 #endif /* USE_SCRIPT */
2916 if (p_ptr->warning && character_dungeon)
2919 if (r_ptr->flags1 & RF1_UNIQUE)
2921 if (r_ptr->level > p_ptr->lev + 30)
2927 else if (r_ptr->level > p_ptr->lev + 15)
2933 else if (r_ptr->level > p_ptr->lev + 5)
2935 color = "¥ë¥Ó¡¼¿§¤Ë";
2939 else if (r_ptr->level > p_ptr->lev - 5)
2945 else if (r_ptr->level > p_ptr->lev - 15)
2947 color = "¥Ô¥ó¥¯¿§¤Ë";
2958 msg_format("»ØÎؤÏ%s¸÷¤Ã¤¿¡£",color);
2960 msg_format("Your ring glows %s.",color);
2965 if (c_ptr->feat == FEAT_MINOR_GLYPH)
2967 /* Break the ward */
2968 if (randint(BREAK_MINOR_GLYPH) > r_ptr->level)
2970 /* Describe observable breakage */
2971 if (c_ptr->info & CAVE_MARK)
2974 msg_print("¥ë¡¼¥ó¤¬Çúȯ¤·¤¿¡ª");
2976 msg_print("The rune explodes!");
2979 project(0, 2, y, x, 2 * (p_ptr->lev + damroll(7, 7)), GF_MANA, (PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL | PROJECT_JUMP | PROJECT_NO_REF | PROJECT_NO_HANGEKI), -1);
2985 msg_print("Çúȯ¤Î¥ë¡¼¥ó¤Ï²ò½ü¤µ¤ì¤¿¡£");
2987 msg_print("An explosive rune was disarmed.");
2991 /* Forget the rune */
2992 c_ptr->info &= ~(CAVE_MARK);
2994 /* Break the rune */
2995 c_ptr->feat = floor_type[rand_int(100)];
2996 c_ptr->info &= ~(CAVE_MASK);
2997 c_ptr->info |= CAVE_FLOOR;
3008 * improved version of scatter() for place monster
3011 #define MON_SCAT_MAXD 10
3013 static bool mon_scatter(int *yp, int *xp, int y, int x, int max_dist)
3015 int place_x[MON_SCAT_MAXD];
3016 int place_y[MON_SCAT_MAXD];
3017 int num[MON_SCAT_MAXD];
3021 if (max_dist >= MON_SCAT_MAXD)
3024 for (i = 0; i < MON_SCAT_MAXD; i++)
3027 for (nx = x - max_dist; nx <= x + max_dist; nx++)
3028 for (ny = y - max_dist; ny <= y + max_dist; ny++)
3030 /* Ignore annoying locations */
3031 if (!in_bounds(ny, nx)) continue;
3033 /* Require "line of sight" */
3034 if (!los(y, x, ny, nx)) continue;
3036 /* Walls and Monsters block flow */
3037 if (!cave_empty_bold2(ny, nx)) continue;
3038 if (cave[ny][nx].m_idx) continue;
3039 if ((ny == py) && (nx == px)) continue;
3042 /* Hack -- no summon on glyph of warding */
3043 if (cave[ny][nx].feat == FEAT_GLYPH) continue;
3044 if (cave[ny][nx].feat == FEAT_MINOR_GLYPH) continue;
3047 /* ... nor on the Pattern */
3048 if ((cave[ny][nx].feat >= FEAT_PATTERN_START) &&
3049 (cave[ny][nx].feat <= FEAT_PATTERN_XTRA2))
3052 i = distance(y, x, ny, nx);
3069 while (i < MON_SCAT_MAXD && 0 == num[i])
3071 if (i >= MON_SCAT_MAXD)
3082 * Maximum size of a group of monsters
3084 #define GROUP_MAX 32
3088 * Attempt to place a "group" of monsters around the given location
3090 static bool place_monster_group(int y, int x, int r_idx, bool slp, bool friendly, bool pet, bool no_pet)
3092 monster_race *r_ptr = &r_info[r_idx];
3095 int total = 0, extra = 0;
3099 byte hack_y[GROUP_MAX];
3100 byte hack_x[GROUP_MAX];
3103 /* Pick a group size */
3104 total = randint(10);
3106 /* Hard monsters, small groups */
3107 if (r_ptr->level > dun_level)
3109 extra = r_ptr->level - dun_level;
3110 extra = 0 - randint(extra);
3113 /* Easy monsters, large groups */
3114 else if (r_ptr->level < dun_level)
3116 extra = dun_level - r_ptr->level;
3117 extra = randint(extra);
3120 /* Hack -- limit group reduction */
3121 if (extra > 9) extra = 9;
3123 /* Modify the group size */
3127 if (total < 1) total = 1;
3130 if (total > GROUP_MAX) total = GROUP_MAX;
3133 /* Save the rating */
3136 /* Start on the monster */
3141 /* Puddle monsters, breadth first, up to total */
3142 for (n = 0; (n < hack_n) && (hack_n < total); n++)
3144 /* Grab the location */
3148 /* Check each direction, up to total */
3149 for (i = 0; (i < 8) && (hack_n < total); i++)
3153 scatter(&my, &mx, hy, hx, 4, 0);
3155 /* Walls and Monsters block flow */
3156 if (!cave_empty_bold2(my, mx)) continue;
3158 /* Attempt to place another monster */
3159 if (place_monster_one(my, mx, r_idx, slp, friendly, pet, no_pet))
3161 /* Add it to the "hack" set */
3162 hack_y[hack_n] = my;
3163 hack_x[hack_n] = mx;
3169 /* Hack -- restore the rating */
3179 * Hack -- help pick an escort type
3181 static int place_monster_idx = 0;
3184 * Hack -- help pick an escort type
3186 static bool place_monster_okay(int r_idx)
3188 monster_race *r_ptr = &r_info[place_monster_idx];
3190 monster_race *z_ptr = &r_info[r_idx];
3192 /* Hack - Escorts have to have the same dungeon flag */
3193 if (monster_dungeon(place_monster_idx) != monster_dungeon(r_idx)) return (FALSE);
3195 /* Require similar "race" */
3196 if (z_ptr->d_char != r_ptr->d_char) return (FALSE);
3198 /* Skip more advanced monsters */
3199 if (z_ptr->level > r_ptr->level) return (FALSE);
3201 /* Skip unique monsters */
3202 if (z_ptr->flags1 & RF1_UNIQUE) return (FALSE);
3204 /* Paranoia -- Skip identical monsters */
3205 if (place_monster_idx == r_idx) return (FALSE);
3213 * Attempt to place a monster of the given race at the given location
3215 * Note that certain monsters are now marked as requiring "friends".
3216 * These monsters, if successfully placed, and if the "grp" parameter
3217 * is TRUE, will be surrounded by a "group" of identical monsters.
3219 * Note that certain monsters are now marked as requiring an "escort",
3220 * which is a collection of monsters with similar "race" but lower level.
3222 * Some monsters induce a fake "group" flag on their escorts.
3224 * Note the "bizarre" use of non-recursion to prevent annoying output
3225 * when running a code profiler.
3227 * Note the use of the new "monster allocation table" code to restrict
3228 * the "get_mon_num()" function to "legal" escort types.
3230 bool place_monster_aux(int y, int x, int r_idx, bool slp, bool grp, bool friendly, bool pet, bool no_kage, bool no_pet)
3233 monster_race *r_ptr = &r_info[r_idx];
3235 if (one_in_(333) && !no_kage && !pet) is_kage = TRUE;
3236 else is_kage = FALSE;
3238 /* Place one monster, or fail */
3239 if (!place_monster_one(y, x, r_idx, slp, friendly, pet, no_pet)) return (FALSE);
3242 /* Require the "group" flag */
3243 if (!grp) return (TRUE);
3246 /* Friends for certain monsters */
3247 if (r_ptr->flags1 & (RF1_FRIENDS))
3249 /* Attempt to place a group */
3250 (void)place_monster_group(y, x, r_idx, slp, friendly, pet, no_pet);
3254 /* Escorts for certain monsters */
3255 if (r_ptr->flags1 & (RF1_ESCORT))
3257 /* Set the escort index */
3258 place_monster_idx = r_idx;
3260 /* Try to place several "escorts" */
3261 for (i = 0; i < 32; i++)
3263 int nx, ny, z, d = 3;
3265 /* Pick a location */
3266 scatter(&ny, &nx, y, x, d, 0);
3268 /* Require empty grids */
3269 if (!cave_empty_bold2(ny, nx)) continue;
3271 /* Prepare allocation table */
3272 get_mon_num_prep(place_monster_okay, get_monster_hook2(ny, nx));
3274 /* Pick a random race */
3275 z = get_mon_num(r_ptr->level);
3277 /* Handle failure */
3280 if (((r_ptr->flags3 & RF3_EVIL) && (r_info[z].flags3 & RF3_GOOD)) || ((r_ptr->flags3 & RF3_GOOD) && (r_info[z].flags3 & RF3_EVIL)))
3286 if (r_ptr->flags7 & RF7_FRIENDLY)
3288 if (((p_ptr->align < 0) && (r_info[z].flags3 & RF3_GOOD)) ||
3289 ((p_ptr->align > 0) && (r_info[z].flags3 & RF3_EVIL)))
3296 /* Place a single escort */
3297 (void)place_monster_one(ny, nx, z, slp, friendly, pet, no_pet);
3299 /* Place a "group" of escorts if needed */
3300 if ((r_info[z].flags1 & RF1_FRIENDS) ||
3301 (r_ptr->flags1 & RF1_ESCORTS))
3303 /* Place a group of monsters */
3304 (void)place_monster_group(ny, nx, z, slp, friendly, pet, no_pet);
3315 * Hack -- attempt to place a monster at the given location
3317 * Attempt to find a monster appropriate to the "monster_level"
3319 bool place_monster(int y, int x, bool slp, bool grp)
3323 /* Prepare allocation table */
3324 get_mon_num_prep(get_monster_hook(), get_monster_hook2(y, x));
3326 /* Pick a monster */
3327 r_idx = get_mon_num(monster_level);
3329 /* Handle failure */
3330 if (!r_idx) return (FALSE);
3332 /* Attempt to place the monster */
3333 if (place_monster_aux(y, x, r_idx, slp, grp, FALSE, FALSE, FALSE, FALSE)) return (TRUE);
3340 #ifdef MONSTER_HORDES
3342 bool alloc_horde(int y, int x)
3344 monster_race *r_ptr = NULL;
3347 int attempts = 1000;
3351 /* Prepare allocation table */
3352 get_mon_num_prep(get_monster_hook(), get_monster_hook2(y, x));
3356 /* Pick a monster */
3357 r_idx = get_mon_num(monster_level);
3359 /* Handle failure */
3360 if (!r_idx) return (FALSE);
3362 r_ptr = &r_info[r_idx];
3364 if (r_ptr->flags1 & RF1_UNIQUE) continue;
3366 if (r_idx == MON_HAGURE) continue;
3369 if (attempts < 1) return FALSE;
3371 if (r_ptr->flags3 & RF3_GOOD) horde_align |= HORDE_NOEVIL;
3372 if (r_ptr->flags3 & RF3_EVIL) horde_align |= HORDE_NOGOOD;
3378 /* Attempt to place the monster */
3379 if (place_monster_aux(y, x, r_idx, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE)) break;
3382 if (attempts < 1) {horde_align = 0;return FALSE;}
3384 m_idx = cave[y][x].m_idx;
3386 if (m_list[m_idx].mflag2 & MFLAG_CHAMELEON) r_ptr = &r_info[m_list[m_idx].r_idx];
3387 summon_kin_type = r_ptr->d_char;
3389 for (attempts = randint(10) + 5; attempts; attempts--)
3391 scatter(&cy, &cx, y, x, 5, 0);
3393 (void)summon_specific(m_idx, cy, cx, dun_level + 5, SUMMON_KIN, TRUE, FALSE, FALSE, FALSE, FALSE);
3403 #endif /* MONSTER_HORDES */
3408 * Attempt to allocate a random monster in the dungeon.
3410 * Place the monster at least "dis" distance from the player.
3412 * Use "slp" to choose the initial "sleep" status
3414 * Use "monster_level" for the monster level
3416 bool alloc_monster(int dis, bool slp)
3419 int attempts_left = 10000;
3421 /* Find a legal, distant, unoccupied, space */
3422 while (attempts_left--)
3424 /* Pick a location */
3425 y = rand_int(cur_hgt);
3426 x = rand_int(cur_wid);
3428 /* Require empty floor grid (was "naked") */
3429 if (dun_level || (wilderness[p_ptr->wilderness_y][p_ptr->wilderness_x].terrain != TERRAIN_MOUNTAIN))
3431 if (!cave_empty_bold2(y, x)) continue;
3435 if (!cave_empty_bold2(y, x) && (cave[y][x].feat != FEAT_MOUNTAIN)) continue;
3438 /* Accept far away grids */
3439 if (distance(y, x, py, px) > dis) break;
3444 if (cheat_xtra || cheat_hear)
3447 msg_print("·Ù¹ð¡ª¿·¤¿¤Ê¥â¥ó¥¹¥¿¡¼¤òÇÛÃ֤Ǥ¤Þ¤»¤ó¡£¾®¤µ¤¤³¬¤Ç¤¹¤«¡©");
3449 msg_print("Warning! Could not allocate a new monster. Small level?");
3458 #ifdef MONSTER_HORDES
3459 if (randint(5000) <= dun_level)
3461 if (alloc_horde(y, x))
3464 if (cheat_hear) msg_print("¥â¥ó¥¹¥¿¡¼¤ÎÂç·²");
3466 if (cheat_hear) msg_print("Monster horde.");
3474 #endif /* MONSTER_HORDES */
3476 /* Attempt to place the monster, allow groups */
3477 if (place_monster(y, x, slp, TRUE)) return (TRUE);
3479 #ifdef MONSTER_HORDES
3481 #endif /* MONSTER_HORDES */
3491 * Hack -- help decide if a monster race is "okay" to summon
3493 static bool summon_specific_okay(int r_idx)
3495 monster_race *r_ptr = &r_info[r_idx];
3497 /* Hack - Only summon dungeon monsters */
3498 if (!monster_dungeon(r_idx)) return (FALSE);
3500 /* Hack -- identify the summoning monster */
3501 if (summon_specific_who > 0)
3503 monster_type *m_ptr = &m_list[summon_specific_who];
3504 monster_race *s_ptr = &r_info[m_ptr->r_idx];
3506 /* Do not summon enemies */
3508 /* Friendly vs. opposite aligned normal or pet */
3509 if (((r_ptr->flags3 & RF3_EVIL) &&
3510 (s_ptr->flags3 & RF3_GOOD)) ||
3511 ((r_ptr->flags3 & RF3_GOOD) &&
3512 (s_ptr->flags3 & RF3_EVIL)))
3517 /* Hostile vs. non-hostile */
3518 if (is_hostile(m_ptr) != summon_specific_hostile)
3523 /* Use the player's alignment */
3524 else if (summon_specific_who < 0)
3526 /* Do not summon enemies of the pets */
3527 if ((p_ptr->align < -9) && (r_ptr->flags3 & RF3_GOOD))
3529 if (!(one_in_((0-p_ptr->align)/2+1))) return FALSE;
3531 else if ((p_ptr->align > 9) && (r_ptr->flags3 & RF3_EVIL))
3533 if (!(one_in_(p_ptr->align/2+1))) return FALSE;
3537 /* Hack -- no specific type specified */
3538 if (!summon_specific_type) return (TRUE);
3540 if (!summon_unique_okay && ((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags7 & RF7_UNIQUE_7))) return FALSE;
3542 if ((summon_specific_who < 0) &&
3543 ((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags7 & RF7_UNIQUE_7)) &&
3544 (((p_ptr->align > 9) && (r_ptr->flags3 & RF3_EVIL)) ||
3545 ((p_ptr->align < -9) && (r_ptr->flags3 & RF3_GOOD))))
3548 if ((horde_align & HORDE_NOGOOD) && (r_ptr->flags3 & RF3_GOOD)) return FALSE;
3549 if ((horde_align & HORDE_NOEVIL) && (r_ptr->flags3 & RF3_EVIL)) return FALSE;
3551 if ((r_ptr->flags7 & RF7_CHAMELEON) && (d_info[dungeon_type].flags1 & DF1_CHAMELEON)) return TRUE;
3553 return (summon_specific_aux(r_idx));
3558 * Place a monster (of the specified "type") near the given
3559 * location. Return TRUE if a monster was actually summoned.
3561 * We will attempt to place the monster up to 10 times before giving up.
3563 * Note: SUMMON_UNIQUE and SUMMON_AMBERITES will summon Unique's
3564 * Note: SUMMON_HI_UNDEAD and SUMMON_HI_DRAGON may summon Unique's
3565 * Note: None of the other summon codes will ever summon Unique's.
3567 * This function has been changed. We now take the "monster level"
3568 * of the summoning monster as a parameter, and use that, along with
3569 * the current dungeon level, to help determine the level of the
3570 * desired monster. Note that this is an upper bound, and also
3571 * tends to "prefer" monsters of that level. Currently, we use
3572 * the average of the dungeon and monster levels, and then add
3573 * five to allow slight increases in monster power.
3575 * Note that we use the new "monster allocation table" creation code
3576 * to restrict the "get_mon_num()" function to the set of "legal"
3577 * monsters, making this function much faster and more reliable.
3579 * Note that this function may not succeed, though this is very rare.
3581 bool summon_specific(int who, int y1, int x1, int lev, int type, bool group, bool friendly, bool pet, bool unique_okay, bool no_pet)
3585 bool no_kage = FALSE;
3587 if (p_ptr->inside_arena) return (FALSE);
3589 if (!mon_scatter(&y, &x, y1, x1, 2)) return FALSE;
3591 /* Save the summoner */
3592 summon_specific_who = who;
3594 /* Save the "summon" type */
3595 summon_specific_type = type;
3597 summon_unique_okay = unique_okay;
3599 /* Save the hostility */
3600 summon_specific_hostile = (!friendly && !pet);
3602 /* Prepare allocation table */
3603 get_mon_num_prep(summon_specific_okay, get_monster_hook2(y, x));
3605 /* Pick a monster, using the level calculation */
3606 r_idx = get_mon_num((dun_level + lev) / 2 + 5);
3608 /* Handle failure */
3611 summon_specific_type = 0;
3615 if ((type == SUMMON_BLUE_HORROR) || (type == SUMMON_DAWN)) no_kage = TRUE;
3617 /* Attempt to place the monster (awake, allow groups) */
3618 if (!place_monster_aux(y, x, r_idx, FALSE, group, friendly, pet, no_kage, no_pet))
3620 summon_specific_type = 0;
3624 summon_specific_type = 0;
3629 /* A "dangerous" function, creates a pet of the specified type */
3630 bool summon_named_creature (int oy, int ox, int r_idx, bool slp, bool group_ok, bool friendly, bool pet)
3635 /* if (!r_idx) return; */
3637 /* Prevent illegal monsters */
3638 if (r_idx >= max_r_idx) return FALSE;
3640 if (p_ptr->inside_arena) return FALSE;
3642 if (!mon_scatter(&y, &x, oy, ox, 2)) return FALSE;
3644 /* Place it (allow groups) */
3645 return place_monster_aux(y, x, r_idx, slp, group_ok, friendly, pet, TRUE, FALSE);
3650 * Let the given monster attempt to reproduce.
3652 * Note that "reproduction" REQUIRES empty space.
3654 bool multiply_monster(int m_idx, bool clone, bool friendly, bool pet)
3656 monster_type *m_ptr = &m_list[m_idx];
3660 if (!mon_scatter(&y, &x, m_ptr->fy, m_ptr->fx, 1))
3663 /* Create a new monster (awake, no groups) */
3664 if (!place_monster_aux(y, x, m_ptr->r_idx, FALSE, FALSE, friendly, pet, TRUE, (bool)(m_ptr->mflag2 & MFLAG_NOPET)))
3669 m_list[hack_m_idx_ii].smart |= SM_CLONED;
3670 m_list[hack_m_idx_ii].mflag2 |= MFLAG_NOPET;
3681 * Dump a message describing a monster's reaction to damage
3683 * Technically should attempt to treat "Beholder"'s as jelly's
3685 void message_pain(int m_idx, int dam)
3687 long oldhp, newhp, tmp;
3690 monster_type *m_ptr = &m_list[m_idx];
3691 monster_race *r_ptr = &r_info[m_ptr->r_idx];
3696 /* Get the monster name */
3697 monster_desc(m_name, m_ptr, 0);
3699 /* Notice non-damage */
3703 msg_format("%^s¤Ï¥À¥á¡¼¥¸¤ò¼õ¤±¤Æ¤¤¤Ê¤¤¡£", m_name);
3705 msg_format("%^s is unharmed.", m_name);
3711 /* Note -- subtle fix -CFT */
3712 newhp = (long)(m_ptr->hp);
3713 oldhp = newhp + (long)(dam);
3714 tmp = (newhp * 100L) / oldhp;
3715 percentage = (int)(tmp);
3718 /* Mushrooms, Eyes, Jellies, Molds, Vortices, Worms, Quylthulgs */
3719 if (strchr(",ejmvwQ", r_ptr->d_char))
3722 if (percentage > 95)
3723 msg_format("%^s¤Ï¤Û¤È¤ó¤Éµ¤¤Ë¤È¤á¤Æ¤¤¤Ê¤¤¡£", m_name);
3724 else if (percentage > 75)
3725 msg_format("%^s¤Ï¤·¤ê¹þ¤ß¤·¤¿¡£", m_name);
3726 else if (percentage > 50)
3727 msg_format("%^s¤Ï½Ì¤³¤Þ¤Ã¤¿¡£", m_name);
3728 else if (percentage > 35)
3729 msg_format("%^s¤ÏÄˤߤ˿̤¨¤¿¡£", m_name);
3730 else if (percentage > 20)
3731 msg_format("%^s¤Ï¿È¤â¤À¤¨¤·¤¿¡£", m_name);
3732 else if (percentage > 10)
3733 msg_format("%^s¤Ï¶ìÄˤǿȤâ¤À¤¨¤·¤¿¡£", m_name);
3735 msg_format("%^s¤Ï¤°¤Ë¤ã¤°¤Ë¤ã¤ÈáÛÚ»¤·¤¿¡£", m_name);
3737 if (percentage > 95)
3738 msg_format("%^s barely notices.", m_name);
3739 else if (percentage > 75)
3740 msg_format("%^s flinches.", m_name);
3741 else if (percentage > 50)
3742 msg_format("%^s squelches.", m_name);
3743 else if (percentage > 35)
3744 msg_format("%^s quivers in pain.", m_name);
3745 else if (percentage > 20)
3746 msg_format("%^s writhes about.", m_name);
3747 else if (percentage > 10)
3748 msg_format("%^s writhes in agony.", m_name);
3750 msg_format("%^s jerks limply.", m_name);
3757 else if (strchr("l", r_ptr->d_char))
3759 if (percentage > 95)
3761 msg_format("%^s¤Ï¤Û¤È¤ó¤Éµ¤¤Ë¤È¤á¤Æ¤¤¤Ê¤¤¡£", m_name);
3763 msg_format("%^s barely notices.", m_name);
3765 else if (percentage > 75)
3767 msg_format("%^s¤Ï¤·¤ê¹þ¤ß¤·¤¿¡£", m_name);
3769 msg_format("%^s flinches.", m_name);
3771 else if (percentage > 50)
3773 msg_format("%^s¤Ïí´í°¤·¤¿¡£", m_name);
3775 msg_format("%^s hesitates.", m_name);
3777 else if (percentage > 35)
3779 msg_format("%^s¤ÏÄˤߤ˿̤¨¤¿¡£", m_name);
3781 msg_format("%^s quivers in pain.", m_name);
3783 else if (percentage > 20)
3785 msg_format("%^s¤Ï¿È¤â¤À¤¨¤·¤¿¡£", m_name);
3787 msg_format("%^s writhes about.", m_name);
3789 else if (percentage > 10)
3791 msg_format("%^s¤Ï¶ìÄˤǿȤâ¤À¤¨¤·¤¿¡£", m_name);
3793 msg_format("%^s writhes in agony.", m_name);
3797 msg_format("%^s¤Ï¤°¤Ë¤ã¤°¤Ë¤ã¤ÈáÛÚ»¤·¤¿¡£", m_name);
3799 msg_format("%^s jerks limply.", m_name);
3804 /* Golems, Walls, Doors, Stairs */
3805 else if (strchr("g#+<>", r_ptr->d_char))
3807 if (percentage > 95)
3809 msg_format("%s¤Ï¹¶·â¤òµ¤¤Ë¤È¤á¤Æ¤¤¤Ê¤¤¡£", m_name);
3811 msg_format("%^s ignores the attack.", m_name);
3813 else if (percentage > 75)
3815 msg_format("%s¤Ï¹¶·â¤Ë¸ª¤ò¤¹¤¯¤á¤¿¡£", m_name);
3817 msg_format("%^s shrugs off the attack.", m_name);
3819 else if (percentage > 50)
3821 msg_format("%^s¤ÏÍëÌĤΤ褦¤ËËʤ¨¤¿¡£", m_name);
3823 msg_format("%^s roars thunderously.", m_name);
3825 else if (percentage > 35)
3827 msg_format("%^s¤Ï¶ì¤·¤²¤ËËʤ¨¤¿¡£", m_name);
3829 msg_format("%^s rumbles.", m_name);
3831 else if (percentage > 20)
3833 msg_format("%^s¤Ï¤¦¤á¤¤¤¿¡£", m_name);
3835 msg_format("%^s grunts.", m_name);
3837 else if (percentage > 10)
3839 msg_format("%^s¤Ïí´í°¤·¤¿¡£", m_name);
3841 msg_format("%^s hesitates.", m_name);
3845 msg_format("%^s¤Ï¤¯¤·¤ã¤¯¤·¤ã¤Ë¤Ê¤Ã¤¿¡£", m_name);
3847 msg_format("%^s crumples.", m_name);
3852 /* Snakes, Hydrae, Reptiles, Mimics */
3853 else if (strchr("JMR", r_ptr->d_char) || !isalpha(r_ptr->d_char))
3855 if (percentage > 95)
3857 msg_format("%^s¤Ï¤Û¤È¤ó¤Éµ¤¤Ë¤È¤á¤Æ¤¤¤Ê¤¤¡£", m_name);
3859 msg_format("%^s barely notices.", m_name);
3861 else if (percentage > 75)
3863 msg_format("%^s¤Ï¥·¡¼¥Ã¤ÈÌĤ¤¤¿¡£", m_name);
3865 msg_format("%^s hisses.", m_name);
3867 else if (percentage > 50)
3869 msg_format("%^s¤ÏÅܤäÆƬ¤ò¾å¤²¤¿¡£", m_name);
3871 msg_format("%^s rears up in anger.", m_name);
3873 else if (percentage > 35)
3875 msg_format("%^s¤ÏÌÔÁ³¤È°Ò³Å¤·¤¿¡£", m_name);
3877 msg_format("%^s hisses furiously.", m_name);
3879 else if (percentage > 20)
3881 msg_format("%^s¤Ï¿È¤â¤À¤¨¤·¤¿¡£", m_name);
3883 msg_format("%^s writhes about.", m_name);
3885 else if (percentage > 10)
3887 msg_format("%^s¤Ï¶ìÄˤǿȤâ¤À¤¨¤·¤¿¡£", m_name);
3889 msg_format("%^s writhes in agony.", m_name);
3893 msg_format("%^s¤Ï¤°¤Ë¤ã¤°¤Ë¤ã¤ÈáÛÚ»¤·¤¿¡£", m_name);
3895 msg_format("%^s jerks limply.", m_name);
3901 else if (strchr("f", r_ptr->d_char))
3903 if (percentage > 95)
3905 msg_format("%s¤Ï¹¶·â¤Ë¸ª¤ò¤¹¤¯¤á¤¿¡£", m_name);
3907 msg_format("%^s shrugs off the attack.", m_name);
3909 else if (percentage > 75)
3911 msg_format("%^s¤ÏËʤ¨¤¿¡£", m_name);
3913 msg_format("%^s roars.", m_name);
3915 else if (percentage > 50)
3917 msg_format("%^s¤ÏÅܤäÆËʤ¨¤¿¡£", m_name);
3919 msg_format("%^s growls angrily.", m_name);
3921 else if (percentage > 35)
3923 msg_format("%^s¤ÏÄˤߤǥ·¡¼¥Ã¤ÈÌĤ¤¤¿¡£", m_name);
3925 msg_format("%^s hisses with pain.", m_name);
3927 else if (percentage > 20)
3929 msg_format("%^s¤ÏÄˤߤǼ塹¤·¤¯ÌĤ¤¤¿¡£", m_name);
3931 msg_format("%^s mewls in pain.", m_name);
3933 else if (percentage > 10)
3935 msg_format("%^s¤Ï¶ìÄˤˤ¦¤á¤¤¤¿¡£", m_name);
3937 msg_format("%^s hisses in agony.", m_name);
3941 msg_format("%s¤Ï°¥¤ì¤ÊÌĤÀ¼¤ò½Ð¤·¤¿¡£", m_name);
3943 msg_format("%^s mewls pitifully.", m_name);
3948 /* Ants, Centipedes, Flies, Insects, Beetles, Spiders */
3949 else if (strchr("acFIKS", r_ptr->d_char))
3951 if (percentage > 95)
3953 msg_format("%s¤Ï¹¶·â¤òµ¤¤Ë¤È¤á¤Æ¤¤¤Ê¤¤¡£", m_name);
3955 msg_format("%^s ignores the attack.", m_name);
3957 else if (percentage > 75)
3959 msg_format("%^s¤Ï¥¡¼¥¡¼ÌĤ¤¤¿¡£", m_name);
3961 msg_format("%^s chitters.", m_name);
3964 else if (percentage > 50)
3966 msg_format("%^s¤Ï¥è¥í¥è¥íƨ¤²²ó¤Ã¤¿¡£", m_name);
3968 msg_format("%^s scuttles about.", m_name);
3971 else if (percentage > 35)
3973 msg_format("%^s¤Ï¤¦¤ë¤µ¤¯ÌĤ¤¤¿¡£", m_name);
3975 msg_format("%^s twitters.", m_name);
3978 else if (percentage > 20)
3980 msg_format("%^s¤ÏÄˤߤËáÛÚ»¤·¤¿¡£", m_name);
3982 msg_format("%^s jerks in pain.", m_name);
3985 else if (percentage > 10)
3987 msg_format("%^s¤Ï¶ìÄˤÇáÛÚ»¤·¤¿¡£", m_name);
3989 msg_format("%^s jerks in agony.", m_name);
3994 msg_format("%^s¤Ï¥Ô¥¯¥Ô¥¯¤Ò¤¤Ä¤Ã¤¿¡£", m_name);
3996 msg_format("%^s twitches.", m_name);
4003 else if (strchr("B", r_ptr->d_char))
4005 if (percentage > 95)
4007 msg_format("%^s¤Ï¤µ¤¨¤º¤Ã¤¿¡£", m_name);
4009 msg_format("%^s chirps.", m_name);
4012 else if (percentage > 75)
4014 msg_format("%^s¤Ï¥Ô¡¼¥Ô¡¼ÌĤ¤¤¿¡£", m_name);
4016 msg_format("%^s twitters.", m_name);
4019 else if (percentage > 50)
4021 msg_format("%^s¤Ï¥®¥ã¡¼¥®¥ã¡¼ÌĤ¤¤¿¡£", m_name);
4023 msg_format("%^s squawks.", m_name);
4026 else if (percentage > 35)
4028 msg_format("%^s¤Ï¥®¥ã¡¼¥®¥ã¡¼ÌĤ¤ï¤á¤¤¤¿¡£", m_name);
4030 msg_format("%^s chatters.", m_name);
4033 else if (percentage > 20)
4035 msg_format("%^s¤Ï¶ì¤·¤ó¤À¡£", m_name);
4037 msg_format("%^s jeers.", m_name);
4040 else if (percentage > 10)
4042 msg_format("%^s¤Ï¤Î¤¿¤¦¤Á²ó¤Ã¤¿¡£", m_name);
4044 msg_format("%^s flutters about.", m_name);
4049 msg_format("%^s¤Ï¥¡¼¥¡¼¤ÈÌĤ¶«¤ó¤À¡£", m_name);
4051 msg_format("%^s squeaks.", m_name);
4057 /* Dragons, Demons, High Undead */
4058 else if (strchr("duDLUW", r_ptr->d_char))
4060 if (percentage > 95)
4062 msg_format("%s¤Ï¹¶·â¤òµ¤¤Ë¤È¤á¤Æ¤¤¤Ê¤¤¡£", m_name);
4064 msg_format("%^s ignores the attack.", m_name);
4067 else if (percentage > 75)
4069 msg_format("%^s¤Ï¤·¤ê¹þ¤ß¤·¤¿¡£", m_name);
4071 msg_format("%^s flinches.", m_name);
4074 else if (percentage > 50)
4076 msg_format("%^s¤ÏÄˤߤǥ·¡¼¥Ã¤ÈÌĤ¤¤¿¡£", m_name);
4078 msg_format("%^s hisses in pain.", m_name);
4081 else if (percentage > 35)
4083 msg_format("%^s¤ÏÄˤߤǤ¦¤Ê¤Ã¤¿¡£", m_name);
4085 msg_format("%^s snarls with pain.", m_name);
4088 else if (percentage > 20)
4090 msg_format("%^s¤ÏÄˤߤËËʤ¨¤¿¡£", m_name);
4092 msg_format("%^s roars with pain.", m_name);
4095 else if (percentage > 10)
4097 msg_format("%^s¤Ï¶ì¤·¤²¤Ë¶«¤ó¤À¡£", m_name);
4099 msg_format("%^s gasps.", m_name);
4104 msg_format("%^s¤Ï¼å¡¹¤·¤¯¤¦¤Ê¤Ã¤¿¡£", m_name);
4106 msg_format("%^s snarls feebly.", m_name);
4113 else if (strchr("s", r_ptr->d_char))
4115 if (percentage > 95)
4117 msg_format("%s¤Ï¹¶·â¤òµ¤¤Ë¤È¤á¤Æ¤¤¤Ê¤¤¡£", m_name);
4119 msg_format("%^s ignores the attack.", m_name);
4122 else if (percentage > 75)
4124 msg_format("%s¤Ï¹¶·â¤Ë¸ª¤ò¤¹¤¯¤á¤¿¡£", m_name);
4126 msg_format("%^s shrugs off the attack.", m_name);
4129 else if (percentage > 50)
4131 msg_format("%^s¤Ï¥«¥¿¥«¥¿¤È¾Ð¤Ã¤¿¡£", m_name);
4133 msg_format("%^s rattles.", m_name);
4136 else if (percentage > 35)
4138 msg_format("%^s¤Ï¤è¤í¤á¤¤¤¿¡£", m_name);
4140 msg_format("%^s stumbles.", m_name);
4143 else if (percentage > 20)
4145 msg_format("%^s¤Ï¥«¥¿¥«¥¿¸À¤Ã¤¿¡£", m_name);
4147 msg_format("%^s rattles.", m_name);
4150 else if (percentage > 10)
4152 msg_format("%^s¤Ï¤è¤í¤á¤¤¤¿¡£", m_name);
4154 msg_format("%^s staggers.", m_name);
4159 msg_format("%^s¤Ï¥¬¥¿¥¬¥¿¸À¤Ã¤¿¡£", m_name);
4161 msg_format("%^s clatters.", m_name);
4168 else if (strchr("z", r_ptr->d_char))
4170 if (percentage > 95)
4172 msg_format("%s¤Ï¹¶·â¤òµ¤¤Ë¤È¤á¤Æ¤¤¤Ê¤¤¡£", m_name);
4174 msg_format("%^s ignores the attack.", m_name);
4177 else if (percentage > 75)
4179 msg_format("%s¤Ï¹¶·â¤Ë¸ª¤ò¤¹¤¯¤á¤¿¡£", m_name);
4181 msg_format("%^s shrugs off the attack.", m_name);
4184 else if (percentage > 50)
4186 msg_format("%^s¤Ï¤¦¤á¤¤¤¿¡£", m_name);
4188 msg_format("%^s groans.", m_name);
4191 else if (percentage > 35)
4193 msg_format("%s¤Ï¶ì¤·¤²¤Ë¤¦¤á¤¤¤¿¡£", m_name);
4195 msg_format("%^s moans.", m_name);
4198 else if (percentage > 20)
4200 msg_format("%^s¤Ïí´í°¤·¤¿¡£", m_name);
4202 msg_format("%^s hesitates.", m_name);
4205 else if (percentage > 10)
4207 msg_format("%^s¤Ï¤¦¤Ê¤Ã¤¿¡£", m_name);
4209 msg_format("%^s grunts.", m_name);
4214 msg_format("%^s¤Ï¤è¤í¤á¤¤¤¿¡£", m_name);
4216 msg_format("%^s staggers.", m_name);
4223 else if (strchr("G", r_ptr->d_char))
4226 if (percentage > 95)
4228 msg_format("%s¤Ï¹¶·â¤òµ¤¤Ë¤È¤á¤Æ¤¤¤Ê¤¤¡£", m_name);
4230 msg_format("%^s ignores the attack.", m_name);
4233 else if (percentage > 75)
4235 msg_format("%s¤Ï¹¶·â¤Ë¸ª¤ò¤¹¤¯¤á¤¿¡£", m_name);
4237 msg_format("%^s shrugs off the attack.", m_name);
4240 else if (percentage > 50)
4242 msg_format("%s¤Ï¤¦¤á¤¤¤¿¡£", m_name);
4244 msg_format("%^s moans.", m_name);
4247 else if (percentage > 35)
4249 msg_format("%^s¤Ïµã¤¤ï¤á¤¤¤¿¡£", m_name);
4251 msg_format("%^s wails.", m_name);
4254 else if (percentage > 20)
4256 msg_format("%^s¤ÏËʤ¨¤¿¡£", m_name);
4258 msg_format("%^s howls.", m_name);
4261 else if (percentage > 10)
4263 msg_format("%s¤Ï¼å¡¹¤·¤¯¤¦¤á¤¤¤¿¡£", m_name);
4265 msg_format("%^s moans softly.", m_name);
4270 msg_format("%^s¤Ï¤«¤¹¤«¤Ë¤¦¤á¤¤¤¿¡£", m_name);
4272 msg_format("%^s sighs.", m_name);
4278 /* Dogs and Hounds */
4279 else if (strchr("CZ", r_ptr->d_char))
4282 if (percentage > 95)
4283 msg_format("%^s¤Ï¹¶·â¤Ë¸ª¤ò¤¹¤¯¤á¤¿¡£", m_name);
4284 else if (percentage > 75)
4285 msg_format("%^s¤ÏÄˤߤǤ¦¤Ê¤Ã¤¿¡£", m_name);
4286 else if (percentage > 50)
4287 msg_format("%^s¤ÏÄˤߤǥ¥ã¥ó¥¥ã¥óËʤ¨¤¿¡£", m_name);
4288 else if (percentage > 35)
4289 msg_format("%^s¤ÏÄˤߤÇÌĤ¤ï¤á¤¤¤¿¡£", m_name);
4290 else if (percentage > 20)
4291 msg_format("%^s¤Ï¶ìÄˤΤ¢¤Þ¤êÌĤ¤ï¤á¤¤¤¿¡£", m_name);
4292 else if (percentage > 10)
4293 msg_format("%^s¤Ï¶ìÄˤǤâ¤À¤¨¶ì¤·¤ó¤À¡£", m_name);
4295 msg_format("%^s¤Ï¼å¡¹¤·¤¯Ëʤ¨¤¿¡£", m_name);
4297 if (percentage > 95)
4298 msg_format("%^s shrugs off the attack.", m_name);
4299 else if (percentage > 75)
4300 msg_format("%^s snarls with pain.", m_name);
4301 else if (percentage > 50)
4302 msg_format("%^s yelps in pain.", m_name);
4303 else if (percentage > 35)
4304 msg_format("%^s howls in pain.", m_name);
4305 else if (percentage > 20)
4306 msg_format("%^s howls in agony.", m_name);
4307 else if (percentage > 10)
4308 msg_format("%^s writhes in agony.", m_name);
4310 msg_format("%^s yelps feebly.", m_name);
4315 /* One type of monsters (ignore,squeal,shriek) */
4316 else if (strchr("Xbilqrt", r_ptr->d_char))
4319 if (percentage > 95)
4320 msg_format("%^s¤Ï¹¶·â¤òµ¤¤Ë¤È¤á¤Æ¤¤¤Ê¤¤¡£", m_name);
4321 else if (percentage > 75)
4322 msg_format("%^s¤ÏÄˤߤǤ¦¤Ê¤Ã¤¿¡£", m_name);
4323 else if (percentage > 50)
4324 msg_format("%^s¤ÏÄˤߤǶ«¤ó¤À¡£", m_name);
4325 else if (percentage > 35)
4326 msg_format("%^s¤ÏÄˤߤÇÀ䶫¤·¤¿¡£", m_name);
4327 else if (percentage > 20)
4328 msg_format("%^s¤Ï¶ìÄˤΤ¢¤Þ¤êÀ䶫¤·¤¿¡£", m_name);
4329 else if (percentage > 10)
4330 msg_format("%^s¤Ï¶ìÄˤǤâ¤À¤¨¶ì¤·¤ó¤À¡£", m_name);
4332 msg_format("%^s¤Ï¼å¡¹¤·¤¯¶«¤ó¤À¡£", m_name);
4334 if (percentage > 95)
4335 msg_format("%^s ignores the attack.", m_name);
4336 else if (percentage > 75)
4337 msg_format("%^s grunts with pain.", m_name);
4338 else if (percentage > 50)
4339 msg_format("%^s squeals in pain.", m_name);
4340 else if (percentage > 35)
4341 msg_format("%^s shrieks in pain.", m_name);
4342 else if (percentage > 20)
4343 msg_format("%^s shrieks in agony.", m_name);
4344 else if (percentage > 10)
4345 msg_format("%^s writhes in agony.", m_name);
4347 msg_format("%^s cries out feebly.", m_name);
4352 /* Another type of monsters (shrug,cry,scream) */
4356 if (percentage > 95)
4357 msg_format("%^s¤Ï¹¶·â¤Ë¸ª¤ò¤¹¤¯¤á¤¿¡£", m_name);
4358 else if (percentage > 75)
4359 msg_format("%^s¤ÏÄˤߤǤ¦¤Ê¤Ã¤¿¡£", m_name);
4360 else if (percentage > 50)
4361 msg_format("%^s¤ÏÄˤߤǶ«¤ó¤À¡£", m_name);
4362 else if (percentage > 35)
4363 msg_format("%^s¤ÏÄˤߤÇÀ䶫¤·¤¿¡£", m_name);
4364 else if (percentage > 20)
4365 msg_format("%^s¤Ï¶ìÄˤΤ¢¤Þ¤êÀ䶫¤·¤¿¡£", m_name);
4366 else if (percentage > 10)
4367 msg_format("%^s¤Ï¶ìÄˤǤâ¤À¤¨¶ì¤·¤ó¤À¡£", m_name);
4369 msg_format("%^s¤Ï¼å¡¹¤·¤¯¶«¤ó¤À¡£", m_name);
4371 if (percentage > 95)
4372 msg_format("%^s shrugs off the attack.", m_name);
4373 else if (percentage > 75)
4374 msg_format("%^s grunts with pain.", m_name);
4375 else if (percentage > 50)
4376 msg_format("%^s cries out in pain.", m_name);
4377 else if (percentage > 35)
4378 msg_format("%^s screams in pain.", m_name);
4379 else if (percentage > 20)
4380 msg_format("%^s screams in agony.", m_name);
4381 else if (percentage > 10)
4382 msg_format("%^s writhes in agony.", m_name);
4384 msg_format("%^s cries out feebly.", m_name);
4392 * Learn about an "observed" resistance.
4394 void update_smart_learn(int m_idx, int what)
4396 #ifdef DRS_SMART_OPTIONS
4398 monster_type *m_ptr = &m_list[m_idx];
4400 monster_race *r_ptr = &r_info[m_ptr->r_idx];
4403 /* Not allowed to learn */
4404 if (!smart_learn) return;
4406 /* Too stupid to learn anything */
4407 if (r_ptr->flags2 & (RF2_STUPID)) return;
4409 /* Not intelligent, only learn sometimes */
4410 if (!(r_ptr->flags2 & (RF2_SMART)) && (rand_int(100) < 50)) return;
4415 /* Analyze the knowledge */
4419 if (p_ptr->resist_acid) m_ptr->smart |= (SM_RES_ACID);
4420 if (p_ptr->oppose_acid) m_ptr->smart |= (SM_OPP_ACID);
4421 if (p_ptr->immune_acid) m_ptr->smart |= (SM_IMM_ACID);
4425 if (p_ptr->resist_elec) m_ptr->smart |= (SM_RES_ELEC);
4426 if (p_ptr->oppose_elec) m_ptr->smart |= (SM_OPP_ELEC);
4427 if (p_ptr->immune_elec) m_ptr->smart |= (SM_IMM_ELEC);
4431 if (p_ptr->resist_fire) m_ptr->smart |= (SM_RES_FIRE);
4432 if (p_ptr->oppose_fire) m_ptr->smart |= (SM_OPP_FIRE);
4433 if (p_ptr->immune_fire) m_ptr->smart |= (SM_IMM_FIRE);
4437 if (p_ptr->resist_cold) m_ptr->smart |= (SM_RES_COLD);
4438 if (p_ptr->oppose_cold) m_ptr->smart |= (SM_OPP_COLD);
4439 if (p_ptr->immune_cold) m_ptr->smart |= (SM_IMM_COLD);
4443 if (p_ptr->resist_pois) m_ptr->smart |= (SM_RES_POIS);
4444 if (p_ptr->oppose_pois) m_ptr->smart |= (SM_OPP_POIS);
4449 if (p_ptr->resist_neth) m_ptr->smart |= (SM_RES_NETH);
4453 if (p_ptr->resist_lite) m_ptr->smart |= (SM_RES_LITE);
4457 if (p_ptr->resist_dark) m_ptr->smart |= (SM_RES_DARK);
4461 if (p_ptr->resist_fear) m_ptr->smart |= (SM_RES_FEAR);
4465 if (p_ptr->resist_conf) m_ptr->smart |= (SM_RES_CONF);
4469 if (p_ptr->resist_chaos) m_ptr->smart |= (SM_RES_CHAOS);
4473 if (p_ptr->resist_disen) m_ptr->smart |= (SM_RES_DISEN);
4477 if (p_ptr->resist_blind) m_ptr->smart |= (SM_RES_BLIND);
4481 if (p_ptr->resist_nexus) m_ptr->smart |= (SM_RES_NEXUS);
4485 if (p_ptr->resist_sound) m_ptr->smart |= (SM_RES_SOUND);
4489 if (p_ptr->resist_shard) m_ptr->smart |= (SM_RES_SHARD);
4493 if (p_ptr->free_act) m_ptr->smart |= (SM_IMM_FREE);
4497 if (!p_ptr->msp) m_ptr->smart |= (SM_IMM_MANA);
4501 if (p_ptr->reflect) m_ptr-> smart |= (SM_IMM_REFLECT);
4505 #endif /* DRS_SMART_OPTIONS */
4511 * Place the player in the dungeon XXX XXX
4513 bool player_place(int y, int x)
4515 /* Paranoia XXX XXX */
4516 if (cave[y][x].m_idx != 0) return FALSE;
4518 /* Save player location */
4528 * Drop all items carried by a monster
4530 void monster_drop_carried_objects(monster_type *m_ptr)
4532 s16b this_o_idx, next_o_idx = 0;
4538 /* Drop objects being carried */
4539 for (this_o_idx = m_ptr->hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
4541 /* Acquire object */
4542 o_ptr = &o_list[this_o_idx];
4544 /* Acquire next object */
4545 next_o_idx = o_ptr->next_o_idx;
4548 o_ptr->held_m_idx = 0;
4550 /* Get local object */
4553 /* Copy the object */
4554 object_copy(q_ptr, o_ptr);
4556 /* Delete the object */
4557 delete_object_idx(this_o_idx);
4560 (void)drop_near(q_ptr, -1, m_ptr->fy, m_ptr->fx);
4563 /* Forget objects */
4564 m_ptr->hold_o_idx = 0;