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] =
155 int get_wilderness_flag(void)
157 int x = p_ptr->wilderness_x;
158 int y = p_ptr->wilderness_y;
161 return (RF8_DUNGEON);
163 return (1L << wilderness[y][x].terrain);
168 * Delete a monster by index.
170 * When a monster is deleted, all of its objects are deleted.
172 void delete_monster_idx(int i)
176 monster_type *m_ptr = &m_list[i];
178 monster_race *r_ptr = &r_info[m_ptr->r_idx];
180 s16b this_o_idx, next_o_idx = 0;
188 /* Hack -- Reduce the racial counter */
191 /* Hack -- count the number of "reproducers" */
192 if (r_ptr->flags2 & (RF2_MULTIPLY)) num_repro--;
195 /* Hack -- remove target monster */
196 if (i == target_who) target_who = 0;
198 /* Hack -- remove tracked monster */
199 if (i == p_ptr->health_who) health_track(0);
201 if (pet_t_m_idx == i ) pet_t_m_idx = 0;
202 if (riding_t_m_idx == i) riding_t_m_idx = 0;
203 if (p_ptr->riding == i) p_ptr->riding = 0;
205 /* Monster is gone */
206 cave[y][x].m_idx = 0;
210 for (this_o_idx = m_ptr->hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
215 o_ptr = &o_list[this_o_idx];
217 /* Acquire next object */
218 next_o_idx = o_ptr->next_o_idx;
220 /* Hack -- efficiency */
221 o_ptr->held_m_idx = 0;
223 /* Delete the object */
224 delete_object_idx(this_o_idx);
228 /* Wipe the Monster */
229 (void)WIPE(m_ptr, monster_type);
235 delete_monster_callback(i);
236 #endif /* USE_SCRIPT */
244 * Delete the monster, if any, at a given location
246 void delete_monster(int y, int x)
251 if (!in_bounds(y, x)) return;
256 /* Delete the monster (if any) */
257 if (c_ptr->m_idx) delete_monster_idx(c_ptr->m_idx);
262 * Move an object from index i1 to index i2 in the object list
264 static void compact_monsters_aux(int i1, int i2)
272 s16b this_o_idx, next_o_idx = 0;
276 if (i1 == i2) return;
289 /* Update the cave */
292 /* Repair objects being carried by monster */
293 for (this_o_idx = m_ptr->hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
298 o_ptr = &o_list[this_o_idx];
300 /* Acquire next object */
301 next_o_idx = o_ptr->next_o_idx;
303 /* Reset monster pointer */
304 o_ptr->held_m_idx = i2;
307 /* Hack -- Update the target */
308 if (target_who == i1) target_who = i2;
310 /* Hack -- Update the target */
311 if (pet_t_m_idx == i1) pet_t_m_idx = i2;
312 if (riding_t_m_idx == i1) riding_t_m_idx = i2;
314 /* Hack -- Update the riding */
315 if (p_ptr->riding == i1) p_ptr->riding = i2;
317 /* Hack -- Update the health bar */
318 if (p_ptr->health_who == i1) health_track(i2);
321 COPY(&m_list[i2], &m_list[i1], monster_type);
324 (void)WIPE(&m_list[i1], monster_type);
327 copy_monster_callback(i1, i2);
328 #endif /* USE_SCRIPT */
334 * Compact and Reorder the monster list
336 * This function can be very dangerous, use with caution!
338 * When actually "compacting" monsters, we base the saving throw
339 * on a combination of monster level, distance from player, and
340 * current "desperation".
342 * After "compacting" (if needed), we "reorder" the monsters into a more
343 * compact order, and we reset the allocation info, and the "live" array.
345 void compact_monsters(int size)
348 int cur_lev, cur_dis, chance;
350 /* Message (only if compacting) */
352 if (size) msg_print("¥â¥ó¥¹¥¿¡¼¾ðÊó¤ò°µ½Ì¤·¤Æ¤¤¤Þ¤¹...");
354 if (size) msg_print("Compacting monsters...");
358 /* Compact at least 'size' objects */
359 for (num = 0, cnt = 1; num < size; cnt++)
361 /* Get more vicious each iteration */
364 /* Get closer each iteration */
365 cur_dis = 5 * (20 - cnt);
367 /* Check all the monsters */
368 for (i = 1; i < m_max; i++)
370 monster_type *m_ptr = &m_list[i];
372 monster_race *r_ptr = &r_info[m_ptr->r_idx];
374 /* Paranoia -- skip "dead" monsters */
375 if (!m_ptr->r_idx) continue;
377 /* Hack -- High level monsters start out "immune" */
378 if (r_ptr->level > cur_lev) continue;
380 if (i == p_ptr->riding) continue;
382 /* Ignore nearby monsters */
383 if ((cur_dis > 0) && (m_ptr->cdis < cur_dis)) continue;
385 /* Saving throw chance */
388 /* Only compact "Quest" Monsters in emergencies */
389 if ((r_ptr->flags1 & (RF1_QUESTOR)) && (cnt < 1000)) chance = 100;
391 /* Try not to compact Unique Monsters */
392 if (r_ptr->flags1 & (RF1_UNIQUE)) chance = 100;
394 /* All monsters get a saving throw */
395 if (rand_int(100) < chance) continue;
397 /* Delete the monster */
398 delete_monster_idx(i);
400 /* Count the monster */
406 /* Excise dead monsters (backwards!) */
407 for (i = m_max - 1; i >= 1; i--)
409 /* Get the i'th monster */
410 monster_type *m_ptr = &m_list[i];
412 /* Skip real monsters */
413 if (m_ptr->r_idx) continue;
415 /* Move last monster into open hole */
416 compact_monsters_aux(m_max - 1, i);
418 /* Compress "m_max" */
425 * Delete/Remove all the monsters when the player leaves the level
427 * This is an efficient method of simulating multiple calls to the
428 * "delete_monster()" function, with no visual effects.
430 void wipe_m_list(void)
434 /* Delete all the monsters */
435 for (i = m_max - 1; i >= 1; i--)
437 monster_type *m_ptr = &m_list[i];
439 monster_race *r_ptr = &r_info[m_ptr->r_idx];
441 /* Skip dead monsters */
442 if (!m_ptr->r_idx) continue;
444 /* Mega-Hack -- preserve Unique's XXX XXX XXX */
446 /* Hack -- Reduce the racial counter */
449 /* Monster is gone */
450 cave[m_ptr->fy][m_ptr->fx].m_idx = 0;
452 /* Wipe the Monster */
453 (void)WIPE(m_ptr, monster_type);
456 delete_monster_callback(i);
457 #endif /* USE_SCRIPT */
466 /* Hack -- reset "reproducer" count */
469 /* Hack -- no more target */
474 /* Hack -- no more tracking */
480 * Acquires and returns the index of a "free" monster.
482 * This routine should almost never fail, but it *can* happen.
489 /* Normal allocation */
490 if (m_max < max_m_idx)
492 /* Access the next hole */
495 /* Expand the array */
501 /* Return the index */
506 /* Recycle dead monsters */
507 for (i = 1; i < m_max; i++)
511 /* Acquire monster */
514 /* Skip live monsters */
515 if (m_ptr->r_idx) continue;
520 /* Use this monster */
525 /* Warn the player (except during dungeon creation) */
527 if (character_dungeon) msg_print("¥â¥ó¥¹¥¿¡¼¤¬Â¿¤¹¤®¤ë¡ª");
529 if (character_dungeon) msg_print("Too many monsters!");
533 /* Try not to crash */
541 * Hack -- the "type" of the current "summon specific"
543 static int summon_specific_type = 0;
547 * Hack -- the index of the summoning monster
549 static int summon_specific_who = -1;
553 * Hack -- the hostility of the summoned monster
555 static int summon_specific_hostile = TRUE;
557 static bool summon_unique_okay = FALSE;
560 static bool summon_specific_aux(int r_idx)
562 monster_race *r_ptr = &r_info[r_idx];
565 /* Check our requirements */
566 switch (summon_specific_type)
570 okay = (r_ptr->d_char == 'a');
576 okay = (r_ptr->d_char == 'S');
582 okay = ((r_ptr->d_char == 'C') || (r_ptr->d_char == 'Z'));
588 okay = (r_ptr->d_char == 'M');
594 okay = (r_ptr->d_char == 'A' && ((r_ptr->flags3 & RF3_EVIL) || (r_ptr->flags3 & RF3_GOOD)));
600 okay = (bool)(r_ptr->flags3 & RF3_DEMON);
606 okay = (bool)(r_ptr->flags3 & RF3_UNDEAD);
612 okay = (bool)(r_ptr->flags3 & RF3_DRAGON);
616 case SUMMON_HI_UNDEAD:
618 okay = ((r_ptr->d_char == 'L') ||
619 (r_ptr->d_char == 'V') ||
620 (r_ptr->d_char == 'W'));
624 case SUMMON_HI_DRAGON:
626 okay = (r_ptr->d_char == 'D');
630 case SUMMON_HI_DEMON:
632 okay = (((r_ptr->d_char == 'U') ||
633 (r_ptr->d_char == 'H') ||
634 (r_ptr->d_char == 'B')) &&
635 (r_ptr->flags3 & RF3_DEMON)) ? TRUE : FALSE;
639 case SUMMON_AMBERITES:
641 okay = (r_ptr->flags3 & (RF3_AMBERITE)) ? TRUE : FALSE;
647 okay = (r_ptr->flags1 & (RF1_UNIQUE)) ? TRUE : FALSE;
651 case SUMMON_BIZARRE1:
653 okay = (r_ptr->d_char == 'm');
656 case SUMMON_BIZARRE2:
658 okay = (r_ptr->d_char == 'b');
661 case SUMMON_BIZARRE3:
663 okay = (r_ptr->d_char == 'Q');
667 case SUMMON_BIZARRE4:
669 okay = (r_ptr->d_char == 'v');
673 case SUMMON_BIZARRE5:
675 okay = (r_ptr->d_char == '$');
679 case SUMMON_BIZARRE6:
681 okay = ((r_ptr->d_char == '!') ||
682 (r_ptr->d_char == '?') ||
683 (r_ptr->d_char == '=') ||
684 (r_ptr->d_char == '$') ||
685 (r_ptr->d_char == '|'));
691 okay = (r_ptr->d_char == 'g');
697 okay = ((r_ptr->d_char == 'U') &&
698 (r_ptr->flags4 & RF4_ROCKET));
705 okay = ((r_ptr->d_char == summon_kin_type) && (r_idx != MON_HAGURE));
711 okay = (r_idx == MON_DAWN);
717 okay = (bool)(r_ptr->flags3 & (RF3_ANIMAL));
721 case SUMMON_ANIMAL_RANGER:
723 okay = ((r_ptr->flags3 & (RF3_ANIMAL)) &&
724 (strchr("abcflqrwBCHIJKMRS", r_ptr->d_char)) &&
725 !(r_ptr->flags3 & (RF3_DRAGON)) &&
726 !(r_ptr->flags3 & (RF3_EVIL)) &&
727 !(r_ptr->flags3 & (RF3_UNDEAD)) &&
728 !(r_ptr->flags3 & (RF3_DEMON)) &&
729 !(r_ptr->flags2 & (RF2_MULTIPLY)) &&
730 !(r_ptr->flags4 || r_ptr->flags5 || r_ptr->flags6));
734 case SUMMON_HI_DRAGON_LIVING:
736 okay = ((r_ptr->d_char == 'D') &&
737 !(r_ptr->flags3 & (RF3_DEMON | RF3_UNDEAD | RF3_NONLIVING)));
743 okay = (!(r_ptr->flags3 & (RF3_DEMON | RF3_UNDEAD | RF3_NONLIVING)));
749 okay = (r_idx == MON_PHANTOM_B || r_idx == MON_PHANTOM_W);
753 case SUMMON_BLUE_HORROR:
755 okay = (r_idx == MON_BLUE_HORROR);
759 case SUMMON_ELEMENTAL:
761 okay = (r_ptr->d_char == 'E');
767 okay = (r_ptr->d_char == 'v');
773 okay = (r_ptr->d_char == 'H');
779 okay = (r_ptr->d_char == 'B');
783 case SUMMON_KAMIKAZE:
786 for (i = 0; i < 4; i++)
787 if (r_ptr->blow[i].method == RBM_EXPLODE) okay = TRUE;
791 case SUMMON_KAMIKAZE_LIVING:
795 for (i = 0; i < 4; i++)
796 if (r_ptr->blow[i].method == RBM_EXPLODE) okay = TRUE;
797 okay = (okay && (!(r_ptr->flags3 & (RF3_DEMON | RF3_UNDEAD | RF3_NONLIVING))));
803 okay = (r_idx == MON_MANES);
809 okay = (r_idx == MON_LOUSE);
819 static bool chameleon_change = FALSE;
823 * Some dungeon types restrict the possible monsters.
824 * Return TRUE is the monster is OK and FALSE otherwise
826 static bool restrict_monster_to_dungeon(int r_idx)
828 dungeon_info_type *d_ptr = &d_info[dungeon_type];
829 monster_race *r_ptr = &r_info[r_idx];
832 if (d_ptr->flags1 & DF1_CHAMELEON)
834 if (chameleon_change) return TRUE;
836 if (d_ptr->flags1 & DF1_NO_MAGIC)
838 if (r_idx == MON_CHAMELEON) return TRUE;
839 if (r_ptr->freq_spell && !(r_ptr->flags4 & RF4_NOMAGIC_MASK) && !(r_ptr->flags5 & RF5_NOMAGIC_MASK) && !(r_ptr->flags6 & RF6_NOMAGIC_MASK))
843 if (d_ptr->flags1 & DF1_NO_MELEE)
845 if (r_idx == MON_CHAMELEON) return TRUE;
846 if (!(r_ptr->flags4 & (RF4_BOLT_MASK | RF4_BEAM_MASK | RF4_BALL_MASK)) &&
847 !(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)) &&
848 !(r_ptr->flags6 & (RF6_BOLT_MASK | RF6_BEAM_MASK | RF6_BALL_MASK)))
852 if (d_ptr->flags1 & DF1_BEGINNER)
854 if (r_ptr->level > dun_level)
859 if (d_ptr->special_div == 64) return TRUE;
860 if (summon_specific_type && !(d_ptr->flags1 & DF1_CHAMELEON)) return TRUE;
862 if(d_ptr->mode == DUNGEON_MODE_AND)
866 if((d_ptr->mflags1 & r_ptr->flags1) != d_ptr->mflags1)
871 if((d_ptr->mflags2 & r_ptr->flags2) != d_ptr->mflags2)
876 if((d_ptr->mflags3 & r_ptr->flags3) != d_ptr->mflags3)
881 if((d_ptr->mflags4 & r_ptr->flags4) != d_ptr->mflags4)
886 if((d_ptr->mflags5 & r_ptr->flags5) != d_ptr->mflags5)
891 if((d_ptr->mflags6 & r_ptr->flags6) != d_ptr->mflags6)
896 if((d_ptr->mflags7 & r_ptr->flags7) != d_ptr->mflags7)
901 if((d_ptr->mflags8 & r_ptr->flags8) != d_ptr->mflags8)
906 if((d_ptr->mflags9 & r_ptr->flags9) != d_ptr->mflags9)
909 for(a = 0; a < 5; a++)
910 if(d_ptr->r_char[a] && (d_ptr->r_char[a] != r_ptr->d_char)) return FALSE;
912 else if(d_ptr->mode == DUNGEON_MODE_NAND)
914 byte ok[9 + 5], i = 0, j = 0;
919 if(d_ptr->mflags1 & r_ptr->flags1)
925 if(d_ptr->mflags2 & r_ptr->flags2)
931 if(d_ptr->mflags3 & r_ptr->flags3)
937 if(d_ptr->mflags4 & r_ptr->flags4)
943 if(d_ptr->mflags5 & r_ptr->flags5)
949 if(d_ptr->mflags6 & r_ptr->flags6)
955 if(d_ptr->mflags7 & r_ptr->flags7)
961 if(d_ptr->mflags8 & r_ptr->flags8)
967 if(d_ptr->mflags9 & r_ptr->flags9)
971 for(a = 0; a < 5; a++)
976 if (d_ptr->r_char[a] != r_ptr->d_char) ok[9 + a] = 1;
980 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];
982 if(i == j) return FALSE;
984 else if(d_ptr->mode == DUNGEON_MODE_OR)
989 for(i = 0; i < 32; i++)
991 flag = d_ptr->mflags1 & (1 << i);
992 if(r_ptr->flags1 & flag) ok = TRUE;
994 flag = d_ptr->mflags2 & (1 << i);
995 if(r_ptr->flags2 & flag) ok = TRUE;
997 flag = d_ptr->mflags3 & (1 << i);
998 if(r_ptr->flags3 & flag) ok = TRUE;
1000 flag = d_ptr->mflags4 & (1 << i);
1001 if(r_ptr->flags4 & flag) ok = TRUE;
1003 flag = d_ptr->mflags5 & (1 << i);
1004 if(r_ptr->flags5 & flag) ok = TRUE;
1006 flag = d_ptr->mflags6 & (1 << i);
1007 if(r_ptr->flags6 & flag) ok = TRUE;
1009 flag = d_ptr->mflags7 & (1 << i);
1010 if(r_ptr->flags7 & flag) ok = TRUE;
1012 flag = d_ptr->mflags8 & (1 << i);
1013 if(r_ptr->flags8 & flag) ok = TRUE;
1015 flag = d_ptr->mflags9 & (1 << i);
1016 if(r_ptr->flags9 & flag) ok = TRUE;
1018 for(a = 0; a < 5; a++)
1019 if(d_ptr->r_char[a] == r_ptr->d_char) ok = TRUE;
1023 else if(d_ptr->mode == DUNGEON_MODE_NOR)
1028 for(i = 0; i < 32; i++)
1030 flag = d_ptr->mflags1 & (1 << i);
1031 if(r_ptr->flags1 & flag) ok = FALSE;
1033 flag = d_ptr->mflags2 & (1 << i);
1034 if(r_ptr->flags2 & flag) ok = FALSE;
1036 flag = d_ptr->mflags3 & (1 << i);
1037 if(r_ptr->flags3 & flag) ok = FALSE;
1039 flag = d_ptr->mflags4 & (1 << i);
1040 if(r_ptr->flags4 & flag) ok = FALSE;
1042 flag = d_ptr->mflags5 & (1 << i);
1043 if(r_ptr->flags5 & flag) ok = FALSE;
1045 flag = d_ptr->mflags6 & (1 << i);
1046 if(r_ptr->flags6 & flag) ok = FALSE;
1048 flag = d_ptr->mflags7 & (1 << i);
1049 if(r_ptr->flags7 & flag) ok = FALSE;
1051 flag = d_ptr->mflags8 & (1 << i);
1052 if(r_ptr->flags8 & flag) ok = FALSE;
1054 flag = d_ptr->mflags9 & (1 << i);
1055 if(r_ptr->flags9 & flag) ok = FALSE;
1057 for(a = 0; a < 5; a++)
1058 if(d_ptr->r_char[a] == r_ptr->d_char) ok = FALSE;
1066 * Apply a "monster restriction function" to the "monster allocation table"
1068 errr get_mon_num_prep(monster_hook_type monster_hook,
1069 monster_hook_type monster_hook2)
1073 /* Todo: Check the hooks for non-changes */
1075 /* Set the new hooks */
1076 get_mon_num_hook = monster_hook;
1077 get_mon_num2_hook = monster_hook2;
1079 /* Scan the allocation table */
1080 for (i = 0; i < alloc_race_size; i++)
1083 alloc_entry *entry = &alloc_race_table[i];
1085 /* Accept monsters which pass the restriction, if any */
1086 if ((!get_mon_num_hook || (*get_mon_num_hook)(entry->index)) &&
1087 (!get_mon_num2_hook || (*get_mon_num2_hook)(entry->index)))
1089 /* Accept this monster */
1090 entry->prob2 = entry->prob1;
1092 if (dun_level && (!p_ptr->inside_quest || p_ptr->inside_quest < MIN_RANDOM_QUEST) && !restrict_monster_to_dungeon(entry->index) && !p_ptr->inside_battle)
1094 int hoge = entry->prob2 * d_info[dungeon_type].special_div;
1095 entry->prob2 = hoge / 64;
1096 if (rand_int(64) < (hoge & 0x3f)) entry->prob2++;
1100 /* Do not use this monster */
1103 /* Decline this monster */
1113 static int mysqrt(int n)
1151 * Choose a monster race that seems "appropriate" to the given level
1153 * This function uses the "prob2" field of the "monster allocation table",
1154 * and various local information, to calculate the "prob3" field of the
1155 * same table, which is then used to choose an "appropriate" monster, in
1156 * a relatively efficient manner.
1158 * Note that "town" monsters will *only* be created in the town, and
1159 * "normal" monsters will *never* be created in the town, unless the
1160 * "level" is "modified", for example, by polymorph or summoning.
1162 * There is a small chance (1/50) of "boosting" the given depth by
1163 * a small amount (up to four levels), except in the town.
1165 * It is (slightly) more likely to acquire a monster of the given level
1166 * than one of a lower level. This is done by choosing several monsters
1167 * appropriate to the given level and keeping the "hardest" one.
1169 * Note that if no monsters are "appropriate", then this function will
1170 * fail, and return zero, but this should *almost* never happen.
1172 s16b get_mon_num(int level)
1180 monster_race *r_ptr;
1182 alloc_entry *table = alloc_race_table;
1184 int pls_kakuritu, pls_level;
1185 int hoge=mysqrt(level*10000L);
1187 if (level > MAX_DEPTH - 1) level = MAX_DEPTH - 1;
1189 if ((dungeon_turn > hoge*10000L) && !level)
1191 pls_kakuritu = MAX(2, NASTY_MON-((dungeon_turn/50000L-hoge/10)));
1192 pls_level = MIN(8,3 + dungeon_turn/400000L-hoge/40);
1196 pls_kakuritu = NASTY_MON;
1200 if (d_info[dungeon_type].flags1 & DF1_MAZE)
1202 pls_kakuritu = MIN(pls_kakuritu/2, pls_kakuritu-10);
1203 if (pls_kakuritu < 2) pls_kakuritu = 2;
1208 /* Boost the level */
1209 if ((level > 0) && !p_ptr->inside_battle && !(d_info[dungeon_type].flags1 & DF1_BEGINNER))
1211 /* Nightmare mode allows more out-of depth monsters */
1212 if (ironman_nightmare && !rand_int(pls_kakuritu))
1214 /* What a bizarre calculation */
1215 level = 1 + (level * MAX_DEPTH / randint(MAX_DEPTH));
1219 /* Occasional "nasty" monster */
1220 if (!rand_int(pls_kakuritu))
1222 /* Pick a level bonus */
1223 int d = MIN(5, level/10) + pls_level;
1225 /* Boost the level */
1229 /* Occasional "nasty" monster */
1230 if (!rand_int(pls_kakuritu))
1232 /* Pick a level bonus */
1233 int d = MIN(5, level/10) + pls_level;
1235 /* Boost the level */
1245 /* Process probabilities */
1246 for (i = 0; i < alloc_race_size; i++)
1248 /* Monsters are sorted by depth */
1249 if (table[i].level > level) break;
1254 /* Access the "r_idx" of the chosen monster */
1255 r_idx = table[i].index;
1257 /* Access the actual race */
1258 r_ptr = &r_info[r_idx];
1260 if (!p_ptr->inside_battle && !chameleon_change)
1262 /* Hack -- "unique" monsters must be "unique" */
1263 if (((r_ptr->flags1 & (RF1_UNIQUE)) || (r_ptr->flags7 & (RF7_UNIQUE_7))) &&
1264 (r_ptr->cur_num >= r_ptr->max_num))
1269 if (r_ptr->flags7 & (RF7_UNIQUE2))
1273 for (j = m_max -1; j >=1; j--)
1275 if(m_list[j].r_idx == r_idx)
1284 if (r_idx == MON_BANORLUPART)
1288 for (j = m_max -1; j >=1; j--)
1290 if((m_list[j].r_idx == MON_BANOR) ||(m_list[j].r_idx == MON_LUPART))
1299 /* Hack -- don't create questors */
1300 if (r_ptr->flags1 & RF1_QUESTOR)
1305 if (r_ptr->flags7 & RF7_GUARDIAN)
1310 /* Depth Monsters never appear out of depth */
1311 if ((r_ptr->flags1 & (RF1_FORCE_DEPTH)) && (r_ptr->level > dun_level))
1316 /* Some dungeon types restrict the possible monsters */
1317 /* if(!restrict_monster_to_dungeon(r_ptr) && dun_level) continue; */
1321 table[i].prob3 = table[i].prob2;
1324 total += table[i].prob3;
1327 /* No legal monsters */
1328 if (total <= 0) return (0);
1331 /* Pick a monster */
1332 value = rand_int(total);
1334 /* Find the monster */
1335 for (i = 0; i < alloc_race_size; i++)
1337 /* Found the entry */
1338 if (value < table[i].prob3) break;
1341 value = value - table[i].prob3;
1348 /* Try for a "harder" monster once (50%) or twice (10%) */
1354 /* Pick a monster */
1355 value = rand_int(total);
1357 /* Find the monster */
1358 for (i = 0; i < alloc_race_size; i++)
1360 /* Found the entry */
1361 if (value < table[i].prob3) break;
1364 value = value - table[i].prob3;
1367 /* Keep the "best" one */
1368 if (table[i].level < table[j].level) i = j;
1371 /* Try for a "harder" monster twice (10%) */
1377 /* Pick a monster */
1378 value = rand_int(total);
1380 /* Find the monster */
1381 for (i = 0; i < alloc_race_size; i++)
1383 /* Found the entry */
1384 if (value < table[i].prob3) break;
1387 value = value - table[i].prob3;
1390 /* Keep the "best" one */
1391 if (table[i].level < table[j].level) i = j;
1395 return (table[i].index);
1403 * Build a string describing a monster in some way.
1405 * We can correctly describe monsters based on their visibility.
1406 * We can force all monsters to be treated as visible or invisible.
1407 * We can build nominatives, objectives, possessives, or reflexives.
1408 * We can selectively pronominalize hidden, visible, or all monsters.
1409 * We can use definite or indefinite descriptions for hidden monsters.
1410 * We can use definite or indefinite descriptions for visible monsters.
1412 * Pronominalization involves the gender whenever possible and allowed,
1413 * so that by cleverly requesting pronominalization / visibility, you
1414 * can get messages like "You hit someone. She screams in agony!".
1416 * Reflexives are acquired by requesting Objective plus Possessive.
1418 * If no m_ptr arg is given (?), the monster is assumed to be hidden,
1419 * unless the "Assume Visible" mode is requested.
1421 * If no r_ptr arg is given, it is extracted from m_ptr and r_info
1422 * If neither m_ptr nor r_ptr is given, the monster is assumed to
1423 * be neuter, singular, and hidden (unless "Assume Visible" is set),
1424 * in which case you may be in trouble... :-)
1426 * I am assuming that no monster name is more than 70 characters long,
1427 * so that "char desc[80];" is sufficiently large for any result.
1430 * 0x01 --> Objective (or Reflexive)
1431 * 0x02 --> Possessive (or Reflexive)
1432 * 0x04 --> Use indefinites for hidden monsters ("something")
1433 * 0x08 --> Use indefinites for visible monsters ("a kobold")
1434 * 0x10 --> Pronominalize hidden monsters
1435 * 0x20 --> Pronominalize visible monsters
1436 * 0x40 --> Assume the monster is hidden
1437 * 0x80 --> Assume the monster is visible
1440 * 0x00 --> Full nominative name ("the kobold") or "it"
1441 * 0x04 --> Full nominative name ("the kobold") or "something"
1442 * 0x80 --> Genocide resistance name ("the kobold")
1443 * 0x88 --> Killing name ("a kobold")
1444 * 0x22 --> Possessive, genderized if visable ("his") or "its"
1445 * 0x23 --> Reflexive, genderized if visable ("himself") or "itself"
1447 void monster_desc(char *desc, monster_type *m_ptr, int mode)
1450 monster_race *r_ptr;
1454 char silly_name[1024];
1458 if (m_ptr->mflag2 & MFLAG_KAGE) r_ptr = &r_info[MON_KAGE];
1459 else r_ptr = &r_info[m_ptr->r_idx];
1461 if ((mode & 0x100) && (m_ptr->mflag2 & MFLAG_CHAMELEON))
1463 if (r_ptr->flags1 & RF1_UNIQUE) name = (r_name + r_info[MON_CHAMELEON_K].name);
1464 else name = (r_name + r_info[MON_CHAMELEON].name);
1466 else name = (r_name + r_ptr->name);
1468 /* Are we hallucinating? (Idea from Nethack...) */
1471 if (randint(2) == 1)
1474 if (!get_rnd_line("silly_j.txt", m_ptr->r_idx, silly_name))
1476 if (!get_rnd_line("silly.txt", m_ptr->r_idx, silly_name))
1484 monster_race *hallu_race;
1488 hallu_race = &r_info[randint(max_r_idx - 1)];
1490 while (hallu_race->flags1 & RF1_UNIQUE);
1492 strcpy(silly_name, (r_name + hallu_race->name));
1495 /* Better not strcpy it, or we could corrupt r_info... */
1499 /* Can we "see" it (exists + forced, or visible + not unforced) */
1500 seen = (m_ptr && ((mode & 0x80) || (!(mode & 0x40) && m_ptr->ml)));
1502 /* Sexed Pronouns (seen and allowed, or unseen and allowed) */
1503 pron = (m_ptr && ((seen && (mode & 0x20)) || (!seen && (mode & 0x10))));
1506 /* First, try using pronouns, or describing hidden monsters */
1509 /* an encoding of the monster "sex" */
1512 /* Extract the gender (if applicable) */
1513 if (r_ptr->flags1 & (RF1_FEMALE)) kind = 0x20;
1514 else if (r_ptr->flags1 & (RF1_MALE)) kind = 0x10;
1516 /* Ignore the gender (if desired) */
1517 if (!m_ptr || !pron) kind = 0x00;
1520 /* Assume simple result */
1528 /* Brute force: split on the possibilities */
1529 switch (kind + (mode & 0x07))
1531 /* Neuter, or unknown */
1533 case 0x00: res = "²¿¤«"; break;
1534 case 0x01: res = "²¿¤«"; break;
1535 case 0x02: res = "²¿¤«¤Î"; break;
1536 case 0x03: res = "²¿¤«¼«¿È"; break;
1537 case 0x04: res = "²¿¤«"; break;
1538 case 0x05: res = "²¿¤«"; break;
1539 case 0x06: res = "²¿¤«"; break;
1540 case 0x07: res = "¤½¤ì¼«¿È"; break;
1542 case 0x00: res = "it"; break;
1543 case 0x01: res = "it"; break;
1544 case 0x02: res = "its"; break;
1545 case 0x03: res = "itself"; break;
1546 case 0x04: res = "something"; break;
1547 case 0x05: res = "something"; break;
1548 case 0x06: res = "something's"; break;
1549 case 0x07: res = "itself"; break;
1553 /* Male (assume human if vague) */
1555 case 0x10: res = "Èà"; break;
1556 case 0x11: res = "Èà"; break;
1557 case 0x12: res = "Èà¤Î"; break;
1558 case 0x13: res = "È༫¿È"; break;
1559 case 0x14: res = "狼"; break;
1560 case 0x15: res = "狼"; break;
1561 case 0x16: res = "狼¤Î"; break;
1562 case 0x17: res = "È༫¿È"; break;
1564 case 0x10: res = "he"; break;
1565 case 0x11: res = "him"; break;
1566 case 0x12: res = "his"; break;
1567 case 0x13: res = "himself"; break;
1568 case 0x14: res = "someone"; break;
1569 case 0x15: res = "someone"; break;
1570 case 0x16: res = "someone's"; break;
1571 case 0x17: res = "himself"; break;
1575 /* Female (assume human if vague) */
1577 case 0x20: res = "Èà½÷"; break;
1578 case 0x21: res = "Èà½÷"; break;
1579 case 0x22: res = "Èà½÷¤Î"; break;
1580 case 0x23: res = "Èà½÷¼«¿È"; break;
1581 case 0x24: res = "狼"; break;
1582 case 0x25: res = "狼"; break;
1583 case 0x26: res = "狼¤Î"; break;
1584 case 0x27: res = "Èà½÷¼«¿È"; break;
1586 case 0x20: res = "she"; break;
1587 case 0x21: res = "her"; break;
1588 case 0x22: res = "her"; break;
1589 case 0x23: res = "herself"; break;
1590 case 0x24: res = "someone"; break;
1591 case 0x25: res = "someone"; break;
1592 case 0x26: res = "someone's"; break;
1593 case 0x27: res = "herself"; break;
1598 /* Copy the result */
1599 (void)strcpy(desc, res);
1603 /* Handle visible monsters, "reflexive" request */
1604 else if ((mode & 0x02) && (mode & 0x01))
1606 /* The monster is visible, so use its gender */
1608 if (r_ptr->flags1 & (RF1_FEMALE)) strcpy(desc, "Èà½÷¼«¿È");
1609 else if (r_ptr->flags1 & (RF1_MALE)) strcpy(desc, "È༫¿È");
1610 else strcpy(desc, "¤½¤ì¼«¿È");
1612 if (r_ptr->flags1 & RF1_FEMALE) strcpy(desc, "herself");
1613 else if (r_ptr->flags1 & RF1_MALE) strcpy(desc, "himself");
1614 else strcpy(desc, "itself");
1620 /* Handle all other visible monster requests */
1623 /* It could be a Unique */
1624 if ((r_ptr->flags1 & RF1_UNIQUE) && !p_ptr->image)
1626 /* Start with the name (thus nominative and objective) */
1627 if ((m_ptr->mflag2 & MFLAG_CHAMELEON) && !(mode & 0x100))
1633 while(strncmp(t, "¡Ù", 2) && *t) t++;
1637 (void)sprintf(desc, "%s¡©¡Ù", buf);
1640 (void)sprintf(desc, "%s¡©", name);
1642 (void)sprintf(desc, "%s?", name);
1645 else if ((cave[m_ptr->fy][m_ptr->fx].m_idx == p_ptr->riding) || !p_ptr->inside_battle)
1646 (void)strcpy(desc, name);
1649 (void)sprintf(desc, "%s¤â¤É¤", name);
1651 (void)sprintf(desc, "fake %s", name);
1655 /* It could be an indefinite monster */
1656 else if (mode & 0x08)
1658 /* XXX Check plurality for "some" */
1660 /* Indefinite monsters need an indefinite article */
1662 (void)strcpy(desc, "");
1664 (void)strcpy(desc, is_a_vowel(name[0]) ? "an " : "a ");
1667 (void)strcat(desc, name);
1669 if (m_ptr->nickname)
1672 sprintf(buf,"¡Ö%s¡×",quark_str(m_ptr->nickname));
1674 sprintf(buf," called %s",quark_str(m_ptr->nickname));
1680 /* It could be a normal, definite, monster */
1683 /* Definite monsters need a definite article */
1686 (void)strcpy(desc, "¤¢¤Ê¤¿¤Î");
1688 (void)strcpy(desc, "your ");
1693 (void)strcpy(desc, "");
1695 (void)strcpy(desc, "the ");
1698 (void)strcat(desc, name);
1700 if (m_ptr->nickname)
1703 sprintf(buf,"¡Ö%s¡×",quark_str(m_ptr->nickname));
1705 sprintf(buf," called %s",quark_str(m_ptr->nickname));
1710 if ((m_ptr->fy == py) && (m_ptr->fx == px))
1712 strcat(desc,"(¾èÇÏÃæ)");
1714 strcat(desc,"(riding)");
1716 if ((mode & 0x200) && (m_ptr->mflag2 & MFLAG_CHAMELEON))
1718 if (r_ptr->flags1 & RF1_UNIQUE)
1720 strcat(desc,"(¥«¥á¥ì¥ª¥ó¤Î²¦)");
1722 strcat(desc,"(Chameleon Lord)");
1726 strcat(desc,"(¥«¥á¥ì¥ª¥ó)");
1728 strcat(desc,"(Chameleon)");
1733 /* Handle the Possessive as a special afterthought */
1736 /* XXX Check for trailing "s" */
1738 /* Simply append "apostrophe" and "s" */
1740 (void)strcat(desc, "¤Î");
1742 (void)strcat(desc, "'s");
1753 * Learn about a monster (by "probing" it)
1755 void lore_do_probe(int m_idx)
1757 monster_type *m_ptr = &m_list[m_idx];
1759 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1761 /* Hack -- Memorize some flags */
1762 r_ptr->r_flags1 = r_ptr->flags1;
1763 r_ptr->r_flags2 = r_ptr->flags2;
1764 r_ptr->r_flags3 = r_ptr->flags3;
1766 /* Update monster recall window */
1767 if (p_ptr->monster_race_idx == m_ptr->r_idx)
1770 p_ptr->window |= (PW_MONSTER);
1776 * Take note that the given monster just dropped some treasure
1778 * Note that learning the "GOOD"/"GREAT" flags gives information
1779 * about the treasure (even when the monster is killed for the first
1780 * time, such as uniques, and the treasure has not been examined yet).
1782 * This "indirect" method is used to prevent the player from learning
1783 * exactly how much treasure a monster can drop from observing only
1784 * a single example of a drop. This method actually observes how much
1785 * gold and items are dropped, and remembers that information to be
1786 * described later by the monster recall code.
1788 void lore_treasure(int m_idx, int num_item, int num_gold)
1790 monster_type *m_ptr = &m_list[m_idx];
1792 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1794 /* Note the number of things dropped */
1795 if (num_item > r_ptr->r_drop_item) r_ptr->r_drop_item = num_item;
1796 if (num_gold > r_ptr->r_drop_gold) r_ptr->r_drop_gold = num_gold;
1798 /* Hack -- memorize the good/great flags */
1799 if (r_ptr->flags1 & (RF1_DROP_GOOD)) r_ptr->r_flags1 |= (RF1_DROP_GOOD);
1800 if (r_ptr->flags1 & (RF1_DROP_GREAT)) r_ptr->r_flags1 |= (RF1_DROP_GREAT);
1802 /* Update monster recall window */
1803 if (p_ptr->monster_race_idx == m_ptr->r_idx)
1806 p_ptr->window |= (PW_MONSTER);
1812 void sanity_blast(monster_type *m_ptr, bool necro)
1814 bool happened = FALSE;
1817 if (p_ptr->inside_battle || !character_dungeon) return;
1822 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1824 power = r_ptr->level / 2;
1826 monster_desc(m_name, m_ptr, 0);
1828 if (!(r_ptr->flags1 & RF1_UNIQUE))
1830 if (r_ptr->flags1 & RF1_FRIENDS)
1836 return; /* No effect yet, just loaded... */
1839 return; /* Cannot see it for some reason */
1841 if (!(r_ptr->flags2 & RF2_ELDRITCH_HORROR))
1847 return; /* Pet eldritch horrors are safe most of the time */
1849 if (randint(100) > power) return;
1851 if (saving_throw(p_ptr->skill_sav - power))
1853 return; /* Save, no adverse effects */
1858 /* Something silly happens... */
1860 msg_format("%s%s¤Î´é¤ò¸«¤Æ¤·¤Þ¤Ã¤¿¡ª",
1862 msg_format("You behold the %s visage of %s!",
1865 funny_desc[rand_int(MAX_SAN_FUNNY)], m_name);
1867 if (randint(3) == 1)
1869 msg_print(funny_comments[rand_int(MAX_SAN_COMMENT)]);
1870 p_ptr->image = p_ptr->image + randint(r_ptr->level);
1873 return; /* Never mind; we can't see it clearly enough */
1876 /* Something frightening happens... */
1878 msg_format("%s%s¤Î´é¤ò¸«¤Æ¤·¤Þ¤Ã¤¿¡ª",
1880 msg_format("You behold the %s visage of %s!",
1883 horror_desc[rand_int(MAX_SAN_HORROR)], m_name);
1885 r_ptr->r_flags2 |= RF2_ELDRITCH_HORROR;
1887 /* Demon characters are unaffected */
1888 if ((p_ptr->prace == RACE_IMP) || (p_ptr->prace == RACE_DEMON) || (mimic_info[p_ptr->mimic_form].MIMIC_FLAGS & MIMIC_IS_DEMON)) return;
1891 /* Undead characters are 50% likely to be unaffected */
1892 if ((p_ptr->prace == RACE_SKELETON) || (p_ptr->prace == RACE_ZOMBIE)
1893 || (p_ptr->prace == RACE_VAMPIRE) || (p_ptr->prace == RACE_SPECTRE) ||
1894 (mimic_info[p_ptr->mimic_form].MIMIC_FLAGS & MIMIC_IS_UNDEAD))
1896 if (saving_throw(25 + p_ptr->lev)) return;
1902 msg_print("¥Í¥¯¥í¥Î¥ß¥³¥ó¤òÆɤó¤ÇÀµµ¤¤ò¼º¤Ã¤¿¡ª");
1904 msg_print("Your sanity is shaken by reading the Necronomicon!");
1909 if (!saving_throw(p_ptr->skill_sav - power)) /* Mind blast */
1911 if (!p_ptr->resist_conf)
1913 (void)set_confused(p_ptr->confused + rand_int(4) + 4);
1915 if (!p_ptr->resist_chaos && one_in_(3))
1917 (void)set_image(p_ptr->image + rand_int(250) + 150);
1922 if (!saving_throw(p_ptr->skill_sav - power)) /* Lose int & wis */
1929 if (!saving_throw(p_ptr->skill_sav - power)) /* Brain smash */
1931 if (!p_ptr->resist_conf)
1933 (void)set_confused(p_ptr->confused + rand_int(4) + 4);
1935 if (!p_ptr->free_act)
1937 (void)set_paralyzed(p_ptr->paralyzed + rand_int(4) + 4);
1939 while (rand_int(100) > p_ptr->skill_sav)
1940 (void)do_dec_stat(A_INT);
1941 while (rand_int(100) > p_ptr->skill_sav)
1942 (void)do_dec_stat(A_WIS);
1943 if (!p_ptr->resist_chaos)
1945 (void)set_image(p_ptr->image + rand_int(250) + 150);
1950 if (!saving_throw(p_ptr->skill_sav - power)) /* Amnesia */
1953 if (lose_all_info())
1955 msg_print("¤¢¤Þ¤ê¤Î¶²ÉݤËÁ´¤Æ¤Î¤³¤È¤ò˺¤ì¤Æ¤·¤Þ¤Ã¤¿¡ª");
1957 msg_print("You forget everything in your utmost terror!");
1963 if (saving_throw(p_ptr->skill_sav - power))
1968 /* Else gain permanent insanity */
1969 if ((p_ptr->muta3 & MUT3_MORONIC) && /*(p_ptr->muta2 & MUT2_BERS_RAGE) &&*/
1970 ((p_ptr->muta2 & MUT2_COWARDICE) || (p_ptr->resist_fear)) &&
1971 ((p_ptr->muta2 & MUT2_HALLU) || (p_ptr->resist_chaos)))
1973 /* The poor bastard already has all possible insanities! */
1979 switch (randint(21))
1982 if (!(p_ptr->muta3 & MUT3_MORONIC) && one_in_(5))
1984 if ((p_ptr->stat_use[A_INT] < 4) && (p_ptr->stat_use[A_WIS] < 4))
1987 msg_print("¤¢¤Ê¤¿¤Ï´°àú¤ÊÇϼ¯¤Ë¤Ê¤Ã¤¿¤è¤¦¤Êµ¤¤¬¤·¤¿¡£¤·¤«¤·¤½¤ì¤Ï¸µ¡¹¤À¤Ã¤¿¡£");
1989 msg_print("You turn into an utter moron!");
1995 msg_print("¤¢¤Ê¤¿¤Ï´°àú¤ÊÇϼ¯¤Ë¤Ê¤Ã¤¿¡ª");
1997 msg_print("You turn into an utter moron!");
2001 if (p_ptr->muta3 & MUT3_HYPER_INT)
2004 msg_print("¤¢¤Ê¤¿¤ÎǾ¤ÏÀ¸ÂÎ¥³¥ó¥Ô¥å¡¼¥¿¤Ç¤Ï¤Ê¤¯¤Ê¤Ã¤¿¡£");
2006 msg_print("Your brain is no longer a living computer.");
2009 p_ptr->muta3 &= ~(MUT3_HYPER_INT);
2011 p_ptr->muta3 |= MUT3_MORONIC;
2025 if (!(p_ptr->muta2 & MUT2_COWARDICE) && !p_ptr->resist_fear)
2028 msg_print("¤¢¤Ê¤¿¤Ï¥Ñ¥é¥Î¥¤¥¢¤Ë¤Ê¤Ã¤¿¡ª");
2030 msg_print("You become paranoid!");
2034 /* Duh, the following should never happen, but anyway... */
2035 if (p_ptr->muta3 & MUT3_FEARLESS)
2038 msg_print("¤¢¤Ê¤¿¤Ï¤â¤¦¶²¤ìÃΤ餺¤Ç¤Ï¤Ê¤¯¤Ê¤Ã¤¿¡£");
2040 msg_print("You are no longer fearless.");
2043 p_ptr->muta3 &= ~(MUT3_FEARLESS);
2046 p_ptr->muta2 |= MUT2_COWARDICE;
2060 if (!(p_ptr->muta2 & MUT2_HALLU) && !p_ptr->resist_chaos)
2063 msg_print("¸¸³Ð¤ò¤Ò¤µ¯¤³¤¹Àº¿ÀºøÍð¤Ë´Ù¤Ã¤¿¡ª");
2065 msg_print("You are afflicted by a hallucinatory insanity!");
2068 p_ptr->muta2 |= MUT2_HALLU;
2073 if (!(p_ptr->muta2 & MUT2_BERS_RAGE))
2076 msg_print("·ãÎõ¤Ê´¶¾ð¤Îȯºî¤Ë¤ª¤½¤ï¤ì¤ë¤è¤¦¤Ë¤Ê¤Ã¤¿¡ª");
2078 msg_print("You become subject to fits of berserk rage!");
2081 p_ptr->muta2 |= MUT2_BERS_RAGE;
2088 p_ptr->update |= PU_BONUS;
2094 * This function updates the monster record of the given monster
2096 * This involves extracting the distance to the player (if requested),
2097 * and then checking for visibility (natural, infravision, see-invis,
2098 * telepathy), updating the monster visibility flag, redrawing (or
2099 * erasing) the monster when its visibility changes, and taking note
2100 * of any interesting monster flags (cold-blooded, invisible, etc).
2102 * Note the new "mflag" field which encodes several monster state flags,
2103 * including "view" for when the monster is currently in line of sight,
2104 * and "mark" for when the monster is currently visible via detection.
2106 * The only monster fields that are changed here are "cdis" (the
2107 * distance from the player), "ml" (visible to the player), and
2108 * "mflag" (to maintain the "MFLAG_VIEW" flag).
2110 * Note the special "update_monsters()" function which can be used to
2111 * call this function once for every monster.
2113 * Note the "full" flag which requests that the "cdis" field be updated,
2114 * this is only needed when the monster (or the player) has moved.
2116 * Every time a monster moves, we must call this function for that
2117 * monster, and update the distance, and the visibility. Every time
2118 * the player moves, we must call this function for every monster, and
2119 * update the distance, and the visibility. Whenever the player "state"
2120 * changes in certain ways ("blindness", "infravision", "telepathy",
2121 * and "see invisible"), we must call this function for every monster,
2122 * and update the visibility.
2124 * Routines that change the "illumination" of a grid must also call this
2125 * function for any monster in that grid, since the "visibility" of some
2126 * monsters may be based on the illumination of their grid.
2128 * Note that this function is called once per monster every time the
2129 * player moves. When the player is running, this function is one
2130 * of the primary bottlenecks, along with "update_view()" and the
2131 * "process_monsters()" code, so efficiency is important.
2133 * Note the optimized "inline" version of the "distance()" function.
2135 * A monster is "visible" to the player if (1) it has been detected
2136 * by the player, (2) it is close to the player and the player has
2137 * telepathy, or (3) it is close to the player, and in line of sight
2138 * of the player, and it is "illuminated" by some combination of
2139 * infravision, torch light, or permanent light (invisible monsters
2140 * are only affected by "light" if the player can see invisible).
2142 * Monsters which are not on the current panel may be "visible" to
2143 * the player, and their descriptions will include an "offscreen"
2144 * reference. Currently, offscreen monsters cannot be targetted
2145 * or viewed directly, but old targets will remain set. XXX XXX
2147 * The player can choose to be disturbed by several things, including
2148 * "disturb_move" (monster which is viewable moves in some way), and
2149 * "disturb_near" (monster which is "easily" viewable moves in some
2150 * way). Note that "moves" includes "appears" and "disappears".
2152 void update_mon(int m_idx, bool full)
2154 monster_type *m_ptr = &m_list[m_idx];
2156 monster_race *r_ptr = &r_info[m_ptr->r_idx];
2160 /* Current location */
2167 /* Seen by vision */
2171 /* Compute distance */
2174 /* Distance components */
2175 int dy = (py > fy) ? (py - fy) : (fy - py);
2176 int dx = (px > fx) ? (px - fx) : (fx - px);
2178 /* Approximate distance */
2179 d = (dy > dx) ? (dy + (dx>>1)) : (dx + (dy>>1));
2181 /* Restrict distance */
2182 if (d > 255) d = 255;
2186 /* Save the distance */
2190 /* Extract distance */
2193 /* Extract the distance */
2199 if (m_ptr->mflag & (MFLAG_MARK)) flag = TRUE;
2203 if (d <= ((d_info[dungeon_type].flags1 & DF1_DARKNESS) ? MAX_SIGHT / 2 : MAX_SIGHT))
2205 if (!(d_info[dungeon_type].flags1 & DF1_DARKNESS) || (d <= MAX_SIGHT / 4))
2207 if (p_ptr->special_defense & KATA_MUSOU)
2212 /* Hack -- Memorize mental flags */
2213 if (r_ptr->flags2 & (RF2_SMART)) r_ptr->r_flags2 |= (RF2_SMART);
2214 if (r_ptr->flags2 & (RF2_STUPID)) r_ptr->r_flags2 |= (RF2_STUPID);
2217 /* Basic telepathy */
2218 else if (p_ptr->telepathy)
2220 /* Empty mind, no telepathy */
2221 if (r_ptr->flags2 & (RF2_EMPTY_MIND))
2223 /* Memorize flags */
2224 r_ptr->r_flags2 |= (RF2_EMPTY_MIND);
2227 /* Weird mind, occasional telepathy */
2228 else if (r_ptr->flags2 & (RF2_WEIRD_MIND))
2230 /* One in ten individuals are detectable */
2231 if ((m_idx % 10) == 5)
2236 /* Memorize flags */
2237 r_ptr->r_flags2 |= (RF2_WEIRD_MIND);
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);
2245 /* Normal mind, allow telepathy */
2251 /* Hack -- Memorize mental flags */
2252 if (r_ptr->flags2 & (RF2_SMART)) r_ptr->r_flags2 |= (RF2_SMART);
2253 if (r_ptr->flags2 & (RF2_STUPID)) r_ptr->r_flags2 |= (RF2_STUPID);
2258 /* Normal line of sight, and not blind */
2259 if (player_has_los_bold(fy, fx) && !p_ptr->blind)
2261 bool do_invisible = FALSE;
2262 bool do_cold_blood = FALSE;
2264 /* Use "infravision" */
2265 if (d <= p_ptr->see_infra)
2267 /* Handle "cold blooded" monsters */
2268 if (r_ptr->flags2 & (RF2_COLD_BLOOD))
2271 do_cold_blood = TRUE;
2274 /* Handle "warm blooded" monsters */
2282 /* Use "illumination" */
2283 if (player_can_see_bold(fy, fx))
2285 /* Handle "invisible" monsters */
2286 if (r_ptr->flags2 & (RF2_INVISIBLE))
2289 do_invisible = TRUE;
2299 /* Handle "normal" monsters */
2310 /* Memorize flags */
2311 if (do_invisible) r_ptr->r_flags2 |= (RF2_INVISIBLE);
2312 if (do_cold_blood) r_ptr->r_flags2 |= (RF2_COLD_BLOOD);
2318 /* The monster is now visible */
2321 /* It was previously unseen */
2324 /* Mark as visible */
2327 /* Draw the monster */
2330 /* Update health bar as needed */
2331 if (p_ptr->health_who == m_idx) p_ptr->redraw |= (PR_HEALTH);
2332 if (p_ptr->riding == m_idx) p_ptr->redraw |= (PR_UHEALTH);
2334 /* Hack -- Count "fresh" sightings */
2335 if ((m_ptr->mflag2 & MFLAG_KAGE) && (r_info[MON_KAGE].r_sights < MAX_SHORT))
2336 r_info[MON_KAGE].r_sights++;
2337 else if (r_ptr->r_sights < MAX_SHORT) r_ptr->r_sights++;
2339 /* Eldritch Horror */
2340 if (r_ptr->flags2 & RF2_ELDRITCH_HORROR)
2342 sanity_blast(m_ptr, FALSE);
2345 /* Disturb on appearance */
2346 if (disturb_near && (projectable(m_ptr->fy, m_ptr->fx, py, px) && projectable(py, px, m_ptr->fy, m_ptr->fx)))
2348 if (disturb_pets || is_hostile(m_ptr))
2354 /* The monster is not visible */
2357 /* It was previously seen */
2360 /* Mark as not visible */
2363 /* Erase the monster */
2366 /* Update health bar as needed */
2367 if (p_ptr->health_who == m_idx) p_ptr->redraw |= (PR_HEALTH);
2368 if (p_ptr->riding == m_idx) p_ptr->redraw |= (PR_UHEALTH);
2370 /* Disturb on disappearance */
2373 if (disturb_pets || is_hostile(m_ptr))
2380 /* The monster is now easily visible */
2384 if (!(m_ptr->mflag & (MFLAG_VIEW)))
2386 /* Mark as easily visible */
2387 m_ptr->mflag |= (MFLAG_VIEW);
2389 /* Disturb on appearance */
2392 if (disturb_pets || is_hostile(m_ptr))
2398 /* The monster is not easily visible */
2402 if (m_ptr->mflag & (MFLAG_VIEW))
2404 /* Mark as not easily visible */
2405 m_ptr->mflag &= ~(MFLAG_VIEW);
2407 /* Disturb on disappearance */
2410 if (disturb_pets || is_hostile(m_ptr))
2419 * This function simply updates all the (non-dead) monsters (see above).
2421 void update_monsters(bool full)
2425 /* Update each (live) monster */
2426 for (i = 1; i < m_max; i++)
2428 monster_type *m_ptr = &m_list[i];
2430 /* Skip dead monsters */
2431 if (!m_ptr->r_idx) continue;
2433 /* Update the monster */
2434 update_mon(i, full);
2440 void choose_new_monster(int m_idx, bool born, int r_idx)
2444 monster_type *m_ptr = &m_list[m_idx];
2445 monster_race *r_ptr;
2446 char old_m_name[80];
2447 int old_r_idx = m_ptr->r_idx;
2448 bool old_unique = FALSE;
2450 if (r_info[m_ptr->r_idx].flags1 & RF1_UNIQUE) old_unique = TRUE;
2451 if (old_unique && (r_idx == MON_CHAMELEON)) r_idx = MON_CHAMELEON_K;
2452 r_ptr = &r_info[r_idx];
2454 monster_desc(old_m_name, m_ptr, 0);
2458 chameleon_change = TRUE;
2459 get_mon_num_prep(get_monster_hook(), NULL);
2464 if (!dun_level) level = wilderness[p_ptr->wilderness_y][p_ptr->wilderness_x].level;
2465 else level = dun_level;
2466 if (d_info[dungeon_type].flags1 & DF1_CHAMELEON) level+= 2+randint(3);
2467 r_idx = get_mon_num(level);
2468 r_ptr = &r_info[r_idx];
2469 if ((old_unique && !(r_ptr->flags1 & RF1_UNIQUE)) || (!old_unique && (r_ptr->flags1 & RF1_UNIQUE))) continue;
2472 if (ABS(r_ptr->level - r_info[MON_CHAMELEON_K].level) > 5) continue;
2473 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;
2475 if ((r_ptr->flags2 & RF2_MULTIPLY) || (r_ptr->flags7 & (RF7_UNIQUE_7 | RF7_GUARDIAN | RF7_FRIENDLY | RF7_UNIQUE2 | RF7_CHAMELEON))) continue;
2476 if (!monster_can_cross_terrain(cave[m_ptr->fy][m_ptr->fx].feat, r_ptr)) continue;
2477 if (!born && !old_unique)
2479 if ((r_info[old_r_idx].flags3 & RF3_GOOD) && !(r_ptr->flags3 & RF3_GOOD)) continue;
2480 if ((r_info[old_r_idx].flags3 & RF3_EVIL) && !(r_ptr->flags3 & RF3_EVIL)) continue;
2481 if (!(r_info[old_r_idx].flags3 & (RF3_GOOD | RF3_EVIL)) && (r_ptr->flags3 & (RF3_GOOD | RF3_EVIL))) continue;
2483 if (born && !old_unique && summon_specific_type)
2485 if (!summon_specific_aux(r_idx)) continue;
2489 chameleon_change = FALSE;
2490 if (!attempt) return;
2493 m_ptr->r_idx = r_idx;
2494 update_mon(m_idx, FALSE);
2495 lite_spot(m_ptr->fy, m_ptr->fx);
2498 if (m_idx == p_ptr->riding)
2501 monster_desc(m_name, m_ptr, 0);
2503 msg_format("ÆÍÁ³%s¤¬ÊѿȤ·¤¿¡£", old_m_name);
2505 msg_format("Suddenly, %s transforms!", old_m_name);
2507 if (!(r_ptr->flags7 & RF7_RIDING))
2509 if (rakuba(0, TRUE)) msg_print("ÃÏÌ̤ËÍî¤È¤µ¤ì¤¿¡£");
2511 if (rakuba(0, TRUE)) msg_format("You have fallen from %s.", m_name);
2515 /* Extract the monster base speed */
2516 m_ptr->mspeed = r_ptr->speed;
2517 /* Hack -- small racial variety */
2518 /* Allow some small variation per monster */
2519 if(rand_int(4) == 1){
2520 i = extract_energy[r_ptr->speed] / 3;
2521 if (i) m_ptr->mspeed += rand_spread(0, i);
2524 i = extract_energy[r_ptr->speed] / 10;
2525 if (i) m_ptr->mspeed += rand_spread(0, i);
2528 oldmaxhp = m_ptr->max_maxhp;
2529 /* Assign maximal hitpoints */
2530 if (r_ptr->flags1 & RF1_FORCE_MAXHP)
2532 m_ptr->max_maxhp = maxroll(r_ptr->hdice, r_ptr->hside);
2536 m_ptr->max_maxhp = damroll(r_ptr->hdice, r_ptr->hside);
2538 m_ptr->maxhp = (long)(m_ptr->maxhp * m_ptr->max_maxhp) / oldmaxhp;
2539 m_ptr->hp = (long)(m_ptr->hp * m_ptr->max_maxhp) / oldmaxhp;
2544 * Attempt to place a monster of the given race at the given location.
2546 * To give the player a sporting chance, any monster that appears in
2547 * line-of-sight and is extremely dangerous can be marked as
2548 * "FORCE_SLEEP", which will cause them to be placed with low energy,
2549 * which often (but not always) lets the player move before they do.
2551 * This routine refuses to place out-of-depth "FORCE_DEPTH" monsters.
2553 * XXX XXX XXX Use special "here" and "dead" flags for unique monsters,
2554 * remove old "cur_num" and "max_num" fields.
2556 * XXX XXX XXX Actually, do something similar for artifacts, to simplify
2557 * the "preserve" mode, and to make the "what artifacts" flag more useful.
2559 * This is the only function which may place a monster in the dungeon,
2560 * except for the savefile loading code.
2562 bool place_monster_one(int y, int x, int r_idx, bool slp, bool friendly, bool pet, bool no_pet)
2568 monster_type *m_ptr;
2570 monster_race *r_ptr = &r_info[r_idx];
2572 cptr name = (r_name + r_ptr->name);
2574 /* DO NOT PLACE A MONSTER IN THE SMALL SCALE WILDERNESS !!! */
2575 if(p_ptr->wild_mode) return FALSE;
2577 /* Verify location */
2578 if (!in_bounds(y, x)) return (FALSE);
2580 /* Require empty space (if not ghostly) */
2581 if (!(!dun_level && (cave[y][x].feat == FEAT_MOUNTAIN) && ((r_ptr->flags8 & RF8_WILD_MOUNTAIN) || (r_ptr->flags7 & RF7_CAN_FLY))) &&
2582 !cave_empty_bold2(y, x) &&
2583 !((r_ptr->flags2 & RF2_PASS_WALL) &&
2584 !(cave_perma_bold(y, x) || cave[y][x].m_idx ||
2585 ((y == py) && (x == px))))) return (FALSE);
2587 /* Hack -- no creation on glyph of warding */
2588 if (cave[y][x].feat == FEAT_GLYPH) return (FALSE);
2589 if (cave[y][x].feat == FEAT_MINOR_GLYPH) return (FALSE);
2591 /* Nor on the Pattern */
2592 if ((cave[y][x].feat >= FEAT_PATTERN_START)
2593 && (cave[y][x].feat <= FEAT_PATTERN_XTRA2))
2597 if (!r_idx) return (FALSE);
2600 if (!r_ptr->name) return (FALSE);
2602 if (monster_terrain_sensitive &&
2603 !monster_can_cross_terrain(cave[y][x].feat, r_ptr))
2608 if (!p_ptr->inside_battle)
2610 /* Hack -- "unique" monsters must be "unique" */
2611 if (((r_ptr->flags1 & (RF1_UNIQUE)) || (r_ptr->flags7 & (RF7_UNIQUE_7))) &&
2612 (r_ptr->cur_num >= r_ptr->max_num))
2618 if (r_ptr->flags7 & (RF7_UNIQUE2))
2622 for (j = m_max -1; j >=1; j--)
2624 if(m_list[j].r_idx == r_idx)
2630 if (fail) return (FALSE);
2633 if (r_idx == MON_BANORLUPART)
2637 for (j = m_max -1; j >=1; j--)
2639 if((m_list[j].r_idx == MON_BANOR) ||(m_list[j].r_idx == MON_LUPART))
2645 if (fail) return (FALSE);
2648 /* Depth monsters may NOT be created out of depth, unless in Nightmare mode */
2649 if ((r_ptr->flags1 & (RF1_FORCE_DEPTH)) && (dun_level < r_ptr->level) &&
2650 (!ironman_nightmare || (r_ptr->flags1 & (RF1_QUESTOR))))
2657 if(quest_number(dun_level))
2659 int hoge = quest_number(dun_level);
2660 if((quest[hoge].type == QUEST_TYPE_KILL_LEVEL) || (quest[hoge].type == QUEST_TYPE_RANDOM))
2662 if(r_idx == quest[hoge].r_idx)
2664 int number_mon, i2, j2;
2667 /* Count all quest monsters */
2668 for (i2 = 0; i2 < cur_wid; ++i2)
2669 for (j2 = 0; j2 < cur_hgt; j2++)
2670 if (cave[j2][i2].m_idx > 0)
2671 if (m_list[cave[j2][i2].m_idx].r_idx == quest[hoge].r_idx)
2673 if(number_mon + quest[hoge].cur_num >= quest[hoge].max_num)
2679 /* Powerful monster */
2680 if (r_ptr->level > dun_level)
2682 /* Unique monsters */
2683 if (r_ptr->flags1 & (RF1_UNIQUE))
2685 /* Message for cheaters */
2687 if (cheat_hear) msg_format("¿¼ÁؤΥæ¥Ë¡¼¥¯¡¦¥â¥ó¥¹¥¿¡¼ (%s)¡£", name);
2689 if (cheat_hear) msg_format("Deep Unique (%s).", name);
2693 /* Boost rating by twice delta-depth */
2694 rating += (r_ptr->level - dun_level) * 2;
2697 /* Normal monsters */
2700 /* Message for cheaters */
2702 if (cheat_hear) msg_format("¿¼ÁؤΥâ¥ó¥¹¥¿¡¼ (%s)¡£", name);
2704 if (cheat_hear) msg_format("Deep Monster (%s).", name);
2708 /* Boost rating by delta-depth */
2709 rating += (r_ptr->level - dun_level);
2713 /* Note the monster */
2714 else if (r_ptr->flags1 & (RF1_UNIQUE))
2716 /* Unique monsters induce message */
2718 if (cheat_hear) msg_format("¥æ¥Ë¡¼¥¯¡¦¥â¥ó¥¹¥¿¡¼ (%s)¡£", name);
2720 if (cheat_hear) msg_format("Unique (%s).", name);
2725 if ((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags7 & RF7_UNIQUE_7) || (r_ptr->level < 10)) is_kage = FALSE;
2727 /* Access the location */
2728 c_ptr = &cave[y][x];
2730 /* Make a new monster */
2731 c_ptr->m_idx = m_pop();
2732 hack_m_idx_ii = c_ptr->m_idx;
2734 /* Mega-Hack -- catch "failure" */
2735 if (!c_ptr->m_idx) return (FALSE);
2738 /* Get a new monster record */
2739 m_ptr = &m_list[c_ptr->m_idx];
2742 m_ptr->r_idx = r_idx;
2744 /* Place the monster at the location */
2749 /* No "damage" yet */
2751 m_ptr->confused = 0;
2754 /* Unknown distance */
2757 m_ptr->target_y = 0;
2758 m_ptr->target_x = 0;
2760 m_ptr->nickname = 0;
2768 if (r_ptr->flags7 & RF7_CHAMELEON)
2770 choose_new_monster(c_ptr->m_idx, TRUE, 0);
2771 r_ptr = &r_info[m_ptr->r_idx];
2772 m_ptr->mflag2 |= MFLAG_CHAMELEON;
2775 else if (is_kage) m_ptr->mflag2 |= MFLAG_KAGE;
2776 if (no_pet) m_ptr->mflag2 |= MFLAG_NOPET;
2787 else if ((friendly || (r_ptr->flags7 & RF7_FRIENDLY)) &&
2788 !(p_ptr->align >= 0 && (r_ptr->flags3 & RF3_EVIL)) &&
2789 !(p_ptr->align < 0 && (r_ptr->flags3 & RF3_GOOD)))
2791 set_friendly(m_ptr);
2794 /* Assume no sleeping */
2797 /* Enforce sleeping if needed */
2798 if (slp && r_ptr->sleep && !ironman_nightmare)
2800 int val = r_ptr->sleep;
2801 m_ptr->csleep = ((val * 2) + randint(val * 10));
2804 /* Assign maximal hitpoints */
2805 if (r_ptr->flags1 & RF1_FORCE_MAXHP)
2807 m_ptr->max_maxhp = maxroll(r_ptr->hdice, r_ptr->hside);
2811 m_ptr->max_maxhp = damroll(r_ptr->hdice, r_ptr->hside);
2814 /* Monsters have double hitpoints in Nightmare mode */
2815 if (ironman_nightmare)
2817 u32b hp = m_ptr->max_maxhp * 2L;
2819 m_ptr->max_maxhp = (s16b)MIN(30000, hp);
2822 m_ptr->maxhp = m_ptr->max_maxhp;
2824 /* And start out fully healthy */
2825 if (m_ptr->r_idx == MON_WOUNDED_BEAR)
2826 m_ptr->hp = m_ptr->maxhp / 2;
2827 else m_ptr->hp = m_ptr->maxhp;
2830 /* Extract the monster base speed */
2831 m_ptr->mspeed = r_ptr->speed;
2833 /* Hack -- small racial variety */
2834 if (!(r_ptr->flags1 & RF1_UNIQUE) && !p_ptr->inside_arena)
2836 /* Allow some small variation per monster */
2837 if(rand_int(4) == 1){
2838 i = extract_energy[r_ptr->speed] / 3;
2839 if (i) m_ptr->mspeed += rand_spread(0, i);
2842 i = extract_energy[r_ptr->speed] / 10;
2843 if (i) m_ptr->mspeed += rand_spread(0, i);
2847 if (m_ptr->mspeed > 199) m_ptr->mspeed = 199;
2849 /* Give a random starting energy */
2850 m_ptr->energy = (byte)rand_int(100);
2852 /* Nightmare monsters are more prepared */
2853 if (ironman_nightmare)
2858 /* Force monster to wait for player, unless in Nightmare mode */
2859 if ((r_ptr->flags1 & RF1_FORCE_SLEEP) && !ironman_nightmare)
2861 /* Monster is still being nice */
2862 m_ptr->mflag |= (MFLAG_NICE);
2864 /* Must repair monsters */
2865 repair_monsters = TRUE;
2868 /* Hack -- see "process_monsters()" */
2869 if (c_ptr->m_idx < hack_m_idx)
2871 /* Monster is still being born */
2872 m_ptr->mflag |= (MFLAG_BORN);
2876 /* Update the monster */
2877 update_mon(c_ptr->m_idx, TRUE);
2880 /* Hack -- Count the monsters on the level */
2884 /* Hack -- Count the number of "reproducers" */
2885 if (r_ptr->flags2 & RF2_MULTIPLY) num_repro++;
2888 /* Hack -- Notice new multi-hued monsters */
2889 if (r_ptr->flags1 & RF1_ATTR_MULTI) shimmer_monsters = TRUE;
2892 create_monster_callback(c_ptr->m_idx);
2893 #endif /* USE_SCRIPT */
2895 if (p_ptr->warning && character_dungeon)
2898 if (r_ptr->flags1 & RF1_UNIQUE)
2900 if (r_ptr->level > p_ptr->lev + 30)
2906 else if (r_ptr->level > p_ptr->lev + 15)
2912 else if (r_ptr->level > p_ptr->lev + 5)
2914 color = "¥ë¥Ó¡¼¿§¤Ë";
2918 else if (r_ptr->level > p_ptr->lev - 5)
2924 else if (r_ptr->level > p_ptr->lev - 15)
2926 color = "¥Ô¥ó¥¯¿§¤Ë";
2937 msg_format("»ØÎؤÏ%s¸÷¤Ã¤¿¡£",color);
2939 msg_format("Your ring glows %s.",color);
2950 * improved version of scatter() for place monster
2953 #define MON_SCAT_MAXD 10
2955 static bool mon_scatter(int *yp, int *xp, int y, int x, int max_dist)
2957 int place_x[MON_SCAT_MAXD];
2958 int place_y[MON_SCAT_MAXD];
2959 int num[MON_SCAT_MAXD];
2963 if (max_dist >= MON_SCAT_MAXD)
2966 for (i = 0; i < MON_SCAT_MAXD; i++)
2969 for (nx = x - max_dist; nx <= x + max_dist; nx++)
2970 for (ny = y - max_dist; ny <= y + max_dist; ny++)
2972 /* Ignore annoying locations */
2973 if (!in_bounds(ny, nx)) continue;
2975 /* Require "line of sight" */
2976 if (!los(y, x, ny, nx)) continue;
2978 /* Walls and Monsters block flow */
2979 if (!cave_empty_bold2(ny, nx)) continue;
2980 if (cave[ny][nx].m_idx) continue;
2981 if ((ny == py) && (nx == px)) continue;
2983 /* Hack -- no summon on glyph of warding */
2984 if (cave[ny][nx].feat == FEAT_GLYPH) continue;
2985 if (cave[ny][nx].feat == FEAT_MINOR_GLYPH) continue;
2987 /* ... nor on the Pattern */
2988 if ((cave[ny][nx].feat >= FEAT_PATTERN_START) &&
2989 (cave[ny][nx].feat <= FEAT_PATTERN_XTRA2))
2992 i = distance(y, x, ny, nx);
3009 while (i < MON_SCAT_MAXD && 0 == num[i])
3011 if (i >= MON_SCAT_MAXD)
3022 * Maximum size of a group of monsters
3024 #define GROUP_MAX 32
3028 * Attempt to place a "group" of monsters around the given location
3030 static bool place_monster_group(int y, int x, int r_idx, bool slp, bool friendly, bool pet, bool no_pet)
3032 monster_race *r_ptr = &r_info[r_idx];
3035 int total = 0, extra = 0;
3039 byte hack_y[GROUP_MAX];
3040 byte hack_x[GROUP_MAX];
3043 /* Pick a group size */
3044 total = randint(10);
3046 /* Hard monsters, small groups */
3047 if (r_ptr->level > dun_level)
3049 extra = r_ptr->level - dun_level;
3050 extra = 0 - randint(extra);
3053 /* Easy monsters, large groups */
3054 else if (r_ptr->level < dun_level)
3056 extra = dun_level - r_ptr->level;
3057 extra = randint(extra);
3060 /* Hack -- limit group reduction */
3061 if (extra > 9) extra = 9;
3063 /* Modify the group size */
3067 if (total < 1) total = 1;
3070 if (total > GROUP_MAX) total = GROUP_MAX;
3073 /* Save the rating */
3076 /* Start on the monster */
3081 /* Puddle monsters, breadth first, up to total */
3082 for (n = 0; (n < hack_n) && (hack_n < total); n++)
3084 /* Grab the location */
3088 /* Check each direction, up to total */
3089 for (i = 0; (i < 8) && (hack_n < total); i++)
3093 scatter(&my, &mx, hy, hx, 4, 0);
3095 /* Walls and Monsters block flow */
3096 if (!cave_empty_bold2(my, mx)) continue;
3098 /* Attempt to place another monster */
3099 if (place_monster_one(my, mx, r_idx, slp, friendly, pet, no_pet))
3101 /* Add it to the "hack" set */
3102 hack_y[hack_n] = my;
3103 hack_x[hack_n] = mx;
3109 /* Hack -- restore the rating */
3119 * Hack -- help pick an escort type
3121 static int place_monster_idx = 0;
3124 * Hack -- help pick an escort type
3126 static bool place_monster_okay(int r_idx)
3128 monster_race *r_ptr = &r_info[place_monster_idx];
3130 monster_race *z_ptr = &r_info[r_idx];
3132 /* Hack - Escorts have to have the same dungeon flag */
3133 if (monster_dungeon(place_monster_idx) != monster_dungeon(r_idx)) return (FALSE);
3135 /* Require similar "race" */
3136 if (z_ptr->d_char != r_ptr->d_char) return (FALSE);
3138 /* Skip more advanced monsters */
3139 if (z_ptr->level > r_ptr->level) return (FALSE);
3141 /* Skip unique monsters */
3142 if (z_ptr->flags1 & RF1_UNIQUE) return (FALSE);
3144 /* Paranoia -- Skip identical monsters */
3145 if (place_monster_idx == r_idx) return (FALSE);
3153 * Attempt to place a monster of the given race at the given location
3155 * Note that certain monsters are now marked as requiring "friends".
3156 * These monsters, if successfully placed, and if the "grp" parameter
3157 * is TRUE, will be surrounded by a "group" of identical monsters.
3159 * Note that certain monsters are now marked as requiring an "escort",
3160 * which is a collection of monsters with similar "race" but lower level.
3162 * Some monsters induce a fake "group" flag on their escorts.
3164 * Note the "bizarre" use of non-recursion to prevent annoying output
3165 * when running a code profiler.
3167 * Note the use of the new "monster allocation table" code to restrict
3168 * the "get_mon_num()" function to "legal" escort types.
3170 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)
3173 monster_race *r_ptr = &r_info[r_idx];
3175 if (one_in_(333) && !no_kage && !pet) is_kage = TRUE;
3176 else is_kage = FALSE;
3178 /* Place one monster, or fail */
3179 if (!place_monster_one(y, x, r_idx, slp, friendly, pet, no_pet)) return (FALSE);
3182 /* Require the "group" flag */
3183 if (!grp) return (TRUE);
3186 /* Friends for certain monsters */
3187 if (r_ptr->flags1 & (RF1_FRIENDS))
3189 /* Attempt to place a group */
3190 (void)place_monster_group(y, x, r_idx, slp, friendly, pet, no_pet);
3194 /* Escorts for certain monsters */
3195 if (r_ptr->flags1 & (RF1_ESCORT))
3197 /* Set the escort index */
3198 place_monster_idx = r_idx;
3200 /* Try to place several "escorts" */
3201 for (i = 0; i < 32; i++)
3203 int nx, ny, z, d = 3;
3205 /* Pick a location */
3206 scatter(&ny, &nx, y, x, d, 0);
3208 /* Require empty grids */
3209 if (!cave_empty_bold2(ny, nx)) continue;
3211 /* Prepare allocation table */
3212 get_mon_num_prep(place_monster_okay, get_monster_hook2(ny, nx));
3214 /* Pick a random race */
3215 z = get_mon_num(r_ptr->level);
3217 /* Handle failure */
3220 if (((r_ptr->flags3 & RF3_EVIL) && (r_info[z].flags3 & RF3_GOOD)) || ((r_ptr->flags3 & RF3_GOOD) && (r_info[z].flags3 & RF3_EVIL)))
3226 if (r_ptr->flags7 & RF7_FRIENDLY)
3228 if (((p_ptr->align < 0) && (r_info[z].flags3 & RF3_GOOD)) ||
3229 ((p_ptr->align > 0) && (r_info[z].flags3 & RF3_EVIL)))
3236 /* Place a single escort */
3237 (void)place_monster_one(ny, nx, z, slp, friendly, pet, no_pet);
3239 /* Place a "group" of escorts if needed */
3240 if ((r_info[z].flags1 & RF1_FRIENDS) ||
3241 (r_ptr->flags1 & RF1_ESCORTS))
3243 /* Place a group of monsters */
3244 (void)place_monster_group(ny, nx, z, slp, friendly, pet, no_pet);
3255 * Hack -- attempt to place a monster at the given location
3257 * Attempt to find a monster appropriate to the "monster_level"
3259 bool place_monster(int y, int x, bool slp, bool grp)
3263 /* Prepare allocation table */
3264 get_mon_num_prep(get_monster_hook(), get_monster_hook2(y, x));
3266 /* Pick a monster */
3267 r_idx = get_mon_num(monster_level);
3269 /* Handle failure */
3270 if (!r_idx) return (FALSE);
3272 /* Attempt to place the monster */
3273 if (place_monster_aux(y, x, r_idx, slp, grp, FALSE, FALSE, FALSE, FALSE)) return (TRUE);
3280 #ifdef MONSTER_HORDES
3282 bool alloc_horde(int y, int x)
3284 monster_race *r_ptr = NULL;
3287 int attempts = 1000;
3291 /* Prepare allocation table */
3292 get_mon_num_prep(get_monster_hook(), get_monster_hook2(y, x));
3296 /* Pick a monster */
3297 r_idx = get_mon_num(monster_level);
3299 /* Handle failure */
3300 if (!r_idx) return (FALSE);
3302 r_ptr = &r_info[r_idx];
3304 if (r_ptr->flags1 & RF1_UNIQUE) continue;
3306 if (r_idx == MON_HAGURE) continue;
3309 if (attempts < 1) return FALSE;
3311 if (r_ptr->flags3 & RF3_GOOD) horde_align |= HORDE_NOEVIL;
3312 if (r_ptr->flags3 & RF3_EVIL) horde_align |= HORDE_NOGOOD;
3318 /* Attempt to place the monster */
3319 if (place_monster_aux(y, x, r_idx, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE)) break;
3322 if (attempts < 1) {horde_align = 0;return FALSE;}
3324 m_idx = cave[y][x].m_idx;
3326 if (m_list[m_idx].mflag2 & MFLAG_CHAMELEON) r_ptr = &r_info[m_list[m_idx].r_idx];
3327 summon_kin_type = r_ptr->d_char;
3329 for (attempts = randint(10) + 5; attempts; attempts--)
3331 scatter(&cy, &cx, y, x, 5, 0);
3333 (void)summon_specific(m_idx, cy, cx, dun_level + 5, SUMMON_KIN, TRUE, FALSE, FALSE, FALSE, FALSE);
3343 #endif /* MONSTER_HORDES */
3348 * Attempt to allocate a random monster in the dungeon.
3350 * Place the monster at least "dis" distance from the player.
3352 * Use "slp" to choose the initial "sleep" status
3354 * Use "monster_level" for the monster level
3356 bool alloc_monster(int dis, bool slp)
3359 int attempts_left = 10000;
3361 /* Find a legal, distant, unoccupied, space */
3362 while (attempts_left--)
3364 /* Pick a location */
3365 y = rand_int(cur_hgt);
3366 x = rand_int(cur_wid);
3368 /* Require empty floor grid (was "naked") */
3369 if (dun_level || (wilderness[p_ptr->wilderness_y][p_ptr->wilderness_x].terrain != TERRAIN_MOUNTAIN))
3371 if (!cave_empty_bold2(y, x)) continue;
3375 if (!cave_empty_bold2(y, x) && (cave[y][x].feat != FEAT_MOUNTAIN)) continue;
3378 /* Accept far away grids */
3379 if (distance(y, x, py, px) > dis) break;
3384 if (cheat_xtra || cheat_hear)
3387 msg_print("·Ù¹ð¡ª¿·¤¿¤Ê¥â¥ó¥¹¥¿¡¼¤òÇÛÃ֤Ǥ¤Þ¤»¤ó¡£¾®¤µ¤¤³¬¤Ç¤¹¤«¡©");
3389 msg_print("Warning! Could not allocate a new monster. Small level?");
3398 #ifdef MONSTER_HORDES
3399 if (randint(5000) <= dun_level)
3401 if (alloc_horde(y, x))
3404 if (cheat_hear) msg_print("¥â¥ó¥¹¥¿¡¼¤ÎÂç·²");
3406 if (cheat_hear) msg_print("Monster horde.");
3414 #endif /* MONSTER_HORDES */
3416 /* Attempt to place the monster, allow groups */
3417 if (place_monster(y, x, slp, TRUE)) return (TRUE);
3419 #ifdef MONSTER_HORDES
3421 #endif /* MONSTER_HORDES */
3431 * Hack -- help decide if a monster race is "okay" to summon
3433 static bool summon_specific_okay(int r_idx)
3435 monster_race *r_ptr = &r_info[r_idx];
3437 /* Hack - Only summon dungeon monsters */
3438 if (!monster_dungeon(r_idx)) return (FALSE);
3440 /* Hack -- identify the summoning monster */
3441 if (summon_specific_who > 0)
3443 monster_type *m_ptr = &m_list[summon_specific_who];
3444 monster_race *s_ptr = &r_info[m_ptr->r_idx];
3446 /* Do not summon enemies */
3448 /* Friendly vs. opposite aligned normal or pet */
3449 if (((r_ptr->flags3 & RF3_EVIL) &&
3450 (s_ptr->flags3 & RF3_GOOD)) ||
3451 ((r_ptr->flags3 & RF3_GOOD) &&
3452 (s_ptr->flags3 & RF3_EVIL)))
3457 /* Hostile vs. non-hostile */
3458 if (is_hostile(m_ptr) != summon_specific_hostile)
3463 /* Use the player's alignment */
3464 else if (summon_specific_who < 0)
3466 /* Do not summon enemies of the pets */
3467 if ((p_ptr->align < -9) && (r_ptr->flags3 & RF3_GOOD))
3469 if (!(one_in_((0-p_ptr->align)/2+1))) return FALSE;
3471 else if ((p_ptr->align > 9) && (r_ptr->flags3 & RF3_EVIL))
3473 if (!(one_in_(p_ptr->align/2+1))) return FALSE;
3477 /* Hack -- no specific type specified */
3478 if (!summon_specific_type) return (TRUE);
3480 if (!summon_unique_okay && ((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags7 & RF7_UNIQUE_7))) return FALSE;
3482 if ((summon_specific_who < 0) &&
3483 ((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags7 & RF7_UNIQUE_7)) &&
3484 (((p_ptr->align > 9) && (r_ptr->flags3 & RF3_EVIL)) ||
3485 ((p_ptr->align < -9) && (r_ptr->flags3 & RF3_GOOD))))
3488 if ((horde_align & HORDE_NOGOOD) && (r_ptr->flags3 & RF3_GOOD)) return FALSE;
3489 if ((horde_align & HORDE_NOEVIL) && (r_ptr->flags3 & RF3_EVIL)) return FALSE;
3491 if ((r_ptr->flags7 & RF7_CHAMELEON) && (d_info[dungeon_type].flags1 & DF1_CHAMELEON)) return TRUE;
3493 return (summon_specific_aux(r_idx));
3498 * Place a monster (of the specified "type") near the given
3499 * location. Return TRUE if a monster was actually summoned.
3501 * We will attempt to place the monster up to 10 times before giving up.
3503 * Note: SUMMON_UNIQUE and SUMMON_AMBERITES will summon Unique's
3504 * Note: SUMMON_HI_UNDEAD and SUMMON_HI_DRAGON may summon Unique's
3505 * Note: None of the other summon codes will ever summon Unique's.
3507 * This function has been changed. We now take the "monster level"
3508 * of the summoning monster as a parameter, and use that, along with
3509 * the current dungeon level, to help determine the level of the
3510 * desired monster. Note that this is an upper bound, and also
3511 * tends to "prefer" monsters of that level. Currently, we use
3512 * the average of the dungeon and monster levels, and then add
3513 * five to allow slight increases in monster power.
3515 * Note that we use the new "monster allocation table" creation code
3516 * to restrict the "get_mon_num()" function to the set of "legal"
3517 * monsters, making this function much faster and more reliable.
3519 * Note that this function may not succeed, though this is very rare.
3521 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)
3525 bool no_kage = FALSE;
3527 if (p_ptr->inside_arena) return (FALSE);
3529 if (!mon_scatter(&y, &x, y1, x1, 2)) return FALSE;
3531 /* Save the summoner */
3532 summon_specific_who = who;
3534 /* Save the "summon" type */
3535 summon_specific_type = type;
3537 summon_unique_okay = unique_okay;
3539 /* Save the hostility */
3540 summon_specific_hostile = (!friendly && !pet);
3542 /* Prepare allocation table */
3543 get_mon_num_prep(summon_specific_okay, get_monster_hook2(y, x));
3545 /* Pick a monster, using the level calculation */
3546 r_idx = get_mon_num((dun_level + lev) / 2 + 5);
3548 /* Handle failure */
3551 summon_specific_type = 0;
3555 if ((type == SUMMON_BLUE_HORROR) || (type == SUMMON_DAWN)) no_kage = TRUE;
3557 /* Attempt to place the monster (awake, allow groups) */
3558 if (!place_monster_aux(y, x, r_idx, FALSE, group, friendly, pet, no_kage, no_pet))
3560 summon_specific_type = 0;
3564 summon_specific_type = 0;
3569 /* A "dangerous" function, creates a pet of the specified type */
3570 bool summon_named_creature (int oy, int ox, int r_idx, bool slp, bool group_ok, bool friendly, bool pet)
3575 /* if (!r_idx) return; */
3577 /* Prevent illegal monsters */
3578 if (r_idx >= max_r_idx) return FALSE;
3580 if (p_ptr->inside_arena) return FALSE;
3582 if (!mon_scatter(&y, &x, oy, ox, 2)) return FALSE;
3584 /* Place it (allow groups) */
3585 return place_monster_aux(y, x, r_idx, slp, group_ok, friendly, pet, TRUE, FALSE);
3590 * Let the given monster attempt to reproduce.
3592 * Note that "reproduction" REQUIRES empty space.
3594 bool multiply_monster(int m_idx, bool clone, bool friendly, bool pet)
3596 monster_type *m_ptr = &m_list[m_idx];
3600 if (!mon_scatter(&y, &x, m_ptr->fy, m_ptr->fx, 1))
3603 /* Create a new monster (awake, no groups) */
3604 if (!place_monster_aux(y, x, m_ptr->r_idx, FALSE, FALSE, friendly, pet, TRUE, (bool)(m_ptr->mflag2 & MFLAG_NOPET)))
3609 m_list[hack_m_idx_ii].smart |= SM_CLONED;
3610 m_list[hack_m_idx_ii].mflag2 |= MFLAG_NOPET;
3621 * Dump a message describing a monster's reaction to damage
3623 * Technically should attempt to treat "Beholder"'s as jelly's
3625 void message_pain(int m_idx, int dam)
3627 long oldhp, newhp, tmp;
3630 monster_type *m_ptr = &m_list[m_idx];
3631 monster_race *r_ptr = &r_info[m_ptr->r_idx];
3636 /* Get the monster name */
3637 monster_desc(m_name, m_ptr, 0);
3639 /* Notice non-damage */
3643 msg_format("%^s¤Ï¥À¥á¡¼¥¸¤ò¼õ¤±¤Æ¤¤¤Ê¤¤¡£", m_name);
3645 msg_format("%^s is unharmed.", m_name);
3651 /* Note -- subtle fix -CFT */
3652 newhp = (long)(m_ptr->hp);
3653 oldhp = newhp + (long)(dam);
3654 tmp = (newhp * 100L) / oldhp;
3655 percentage = (int)(tmp);
3658 /* Mushrooms, Eyes, Jellies, Molds, Vortices, Worms, Quylthulgs */
3659 if (strchr(",ejmvwQ", r_ptr->d_char))
3662 if (percentage > 95)
3663 msg_format("%^s¤Ï¤Û¤È¤ó¤Éµ¤¤Ë¤È¤á¤Æ¤¤¤Ê¤¤¡£", m_name);
3664 else if (percentage > 75)
3665 msg_format("%^s¤Ï¤·¤ê¹þ¤ß¤·¤¿¡£", m_name);
3666 else if (percentage > 50)
3667 msg_format("%^s¤Ï½Ì¤³¤Þ¤Ã¤¿¡£", m_name);
3668 else if (percentage > 35)
3669 msg_format("%^s¤ÏÄˤߤ˿̤¨¤¿¡£", m_name);
3670 else if (percentage > 20)
3671 msg_format("%^s¤Ï¿È¤â¤À¤¨¤·¤¿¡£", m_name);
3672 else if (percentage > 10)
3673 msg_format("%^s¤Ï¶ìÄˤǿȤâ¤À¤¨¤·¤¿¡£", m_name);
3675 msg_format("%^s¤Ï¤°¤Ë¤ã¤°¤Ë¤ã¤ÈáÛÚ»¤·¤¿¡£", m_name);
3677 if (percentage > 95)
3678 msg_format("%^s barely notices.", m_name);
3679 else if (percentage > 75)
3680 msg_format("%^s flinches.", m_name);
3681 else if (percentage > 50)
3682 msg_format("%^s squelches.", m_name);
3683 else if (percentage > 35)
3684 msg_format("%^s quivers in pain.", m_name);
3685 else if (percentage > 20)
3686 msg_format("%^s writhes about.", m_name);
3687 else if (percentage > 10)
3688 msg_format("%^s writhes in agony.", m_name);
3690 msg_format("%^s jerks limply.", m_name);
3697 else if (strchr("l", r_ptr->d_char))
3699 if (percentage > 95)
3701 msg_format("%^s¤Ï¤Û¤È¤ó¤Éµ¤¤Ë¤È¤á¤Æ¤¤¤Ê¤¤¡£", m_name);
3703 msg_format("%^s barely notices.", m_name);
3705 else if (percentage > 75)
3707 msg_format("%^s¤Ï¤·¤ê¹þ¤ß¤·¤¿¡£", m_name);
3709 msg_format("%^s flinches.", m_name);
3711 else if (percentage > 50)
3713 msg_format("%^s¤Ïí´í°¤·¤¿¡£", m_name);
3715 msg_format("%^s hesitates.", m_name);
3717 else if (percentage > 35)
3719 msg_format("%^s¤ÏÄˤߤ˿̤¨¤¿¡£", m_name);
3721 msg_format("%^s quivers in pain.", m_name);
3723 else if (percentage > 20)
3725 msg_format("%^s¤Ï¿È¤â¤À¤¨¤·¤¿¡£", m_name);
3727 msg_format("%^s writhes about.", m_name);
3729 else if (percentage > 10)
3731 msg_format("%^s¤Ï¶ìÄˤǿȤâ¤À¤¨¤·¤¿¡£", m_name);
3733 msg_format("%^s writhes in agony.", m_name);
3737 msg_format("%^s¤Ï¤°¤Ë¤ã¤°¤Ë¤ã¤ÈáÛÚ»¤·¤¿¡£", m_name);
3739 msg_format("%^s jerks limply.", m_name);
3744 /* Golems, Walls, Doors, Stairs */
3745 else if (strchr("g#+<>", r_ptr->d_char))
3747 if (percentage > 95)
3749 msg_format("%s¤Ï¹¶·â¤òµ¤¤Ë¤È¤á¤Æ¤¤¤Ê¤¤¡£", m_name);
3751 msg_format("%^s ignores the attack.", m_name);
3753 else if (percentage > 75)
3755 msg_format("%s¤Ï¹¶·â¤Ë¸ª¤ò¤¹¤¯¤á¤¿¡£", m_name);
3757 msg_format("%^s shrugs off the attack.", m_name);
3759 else if (percentage > 50)
3761 msg_format("%^s¤ÏÍëÌĤΤ褦¤ËËʤ¨¤¿¡£", m_name);
3763 msg_format("%^s roars thunderously.", m_name);
3765 else if (percentage > 35)
3767 msg_format("%^s¤Ï¶ì¤·¤²¤ËËʤ¨¤¿¡£", m_name);
3769 msg_format("%^s rumbles.", m_name);
3771 else if (percentage > 20)
3773 msg_format("%^s¤Ï¤¦¤á¤¤¤¿¡£", m_name);
3775 msg_format("%^s grunts.", m_name);
3777 else if (percentage > 10)
3779 msg_format("%^s¤Ïí´í°¤·¤¿¡£", m_name);
3781 msg_format("%^s hesitates.", m_name);
3785 msg_format("%^s¤Ï¤¯¤·¤ã¤¯¤·¤ã¤Ë¤Ê¤Ã¤¿¡£", m_name);
3787 msg_format("%^s crumples.", m_name);
3792 /* Snakes, Hydrae, Reptiles, Mimics */
3793 else if (strchr("JMR", r_ptr->d_char) || !isalpha(r_ptr->d_char))
3795 if (percentage > 95)
3797 msg_format("%^s¤Ï¤Û¤È¤ó¤Éµ¤¤Ë¤È¤á¤Æ¤¤¤Ê¤¤¡£", m_name);
3799 msg_format("%^s barely notices.", m_name);
3801 else if (percentage > 75)
3803 msg_format("%^s¤Ï¥·¡¼¥Ã¤ÈÌĤ¤¤¿¡£", m_name);
3805 msg_format("%^s hisses.", m_name);
3807 else if (percentage > 50)
3809 msg_format("%^s¤ÏÅܤäÆƬ¤ò¾å¤²¤¿¡£", m_name);
3811 msg_format("%^s rears up in anger.", m_name);
3813 else if (percentage > 35)
3815 msg_format("%^s¤ÏÌÔÁ³¤È°Ò³Å¤·¤¿¡£", m_name);
3817 msg_format("%^s hisses furiously.", m_name);
3819 else if (percentage > 20)
3821 msg_format("%^s¤Ï¿È¤â¤À¤¨¤·¤¿¡£", m_name);
3823 msg_format("%^s writhes about.", m_name);
3825 else if (percentage > 10)
3827 msg_format("%^s¤Ï¶ìÄˤǿȤâ¤À¤¨¤·¤¿¡£", m_name);
3829 msg_format("%^s writhes in agony.", m_name);
3833 msg_format("%^s¤Ï¤°¤Ë¤ã¤°¤Ë¤ã¤ÈáÛÚ»¤·¤¿¡£", m_name);
3835 msg_format("%^s jerks limply.", m_name);
3841 else if (strchr("f", r_ptr->d_char))
3843 if (percentage > 95)
3845 msg_format("%s¤Ï¹¶·â¤Ë¸ª¤ò¤¹¤¯¤á¤¿¡£", m_name);
3847 msg_format("%^s shrugs off the attack.", m_name);
3849 else if (percentage > 75)
3851 msg_format("%^s¤ÏËʤ¨¤¿¡£", m_name);
3853 msg_format("%^s roars.", m_name);
3855 else if (percentage > 50)
3857 msg_format("%^s¤ÏÅܤäÆËʤ¨¤¿¡£", m_name);
3859 msg_format("%^s growls angrily.", m_name);
3861 else if (percentage > 35)
3863 msg_format("%^s¤ÏÄˤߤǥ·¡¼¥Ã¤ÈÌĤ¤¤¿¡£", m_name);
3865 msg_format("%^s hisses with pain.", m_name);
3867 else if (percentage > 20)
3869 msg_format("%^s¤ÏÄˤߤǼ塹¤·¤¯ÌĤ¤¤¿¡£", m_name);
3871 msg_format("%^s mewls in pain.", m_name);
3873 else if (percentage > 10)
3875 msg_format("%^s¤Ï¶ìÄˤˤ¦¤á¤¤¤¿¡£", m_name);
3877 msg_format("%^s hisses in agony.", m_name);
3881 msg_format("%s¤Ï°¥¤ì¤ÊÌĤÀ¼¤ò½Ð¤·¤¿¡£", m_name);
3883 msg_format("%^s mewls pitifully.", m_name);
3888 /* Ants, Centipedes, Flies, Insects, Beetles, Spiders */
3889 else if (strchr("acFIKS", r_ptr->d_char))
3891 if (percentage > 95)
3893 msg_format("%s¤Ï¹¶·â¤òµ¤¤Ë¤È¤á¤Æ¤¤¤Ê¤¤¡£", m_name);
3895 msg_format("%^s ignores the attack.", m_name);
3897 else if (percentage > 75)
3899 msg_format("%^s¤Ï¥¡¼¥¡¼ÌĤ¤¤¿¡£", m_name);
3901 msg_format("%^s chitters.", m_name);
3904 else if (percentage > 50)
3906 msg_format("%^s¤Ï¥è¥í¥è¥íƨ¤²²ó¤Ã¤¿¡£", m_name);
3908 msg_format("%^s scuttles about.", m_name);
3911 else if (percentage > 35)
3913 msg_format("%^s¤Ï¤¦¤ë¤µ¤¯ÌĤ¤¤¿¡£", m_name);
3915 msg_format("%^s twitters.", m_name);
3918 else if (percentage > 20)
3920 msg_format("%^s¤ÏÄˤߤËáÛÚ»¤·¤¿¡£", m_name);
3922 msg_format("%^s jerks in pain.", m_name);
3925 else if (percentage > 10)
3927 msg_format("%^s¤Ï¶ìÄˤÇáÛÚ»¤·¤¿¡£", m_name);
3929 msg_format("%^s jerks in agony.", m_name);
3934 msg_format("%^s¤Ï¥Ô¥¯¥Ô¥¯¤Ò¤¤Ä¤Ã¤¿¡£", m_name);
3936 msg_format("%^s twitches.", m_name);
3943 else if (strchr("B", r_ptr->d_char))
3945 if (percentage > 95)
3947 msg_format("%^s¤Ï¤µ¤¨¤º¤Ã¤¿¡£", m_name);
3949 msg_format("%^s chirps.", m_name);
3952 else if (percentage > 75)
3954 msg_format("%^s¤Ï¥Ô¡¼¥Ô¡¼ÌĤ¤¤¿¡£", m_name);
3956 msg_format("%^s twitters.", m_name);
3959 else if (percentage > 50)
3961 msg_format("%^s¤Ï¥®¥ã¡¼¥®¥ã¡¼ÌĤ¤¤¿¡£", m_name);
3963 msg_format("%^s squawks.", m_name);
3966 else if (percentage > 35)
3968 msg_format("%^s¤Ï¥®¥ã¡¼¥®¥ã¡¼ÌĤ¤ï¤á¤¤¤¿¡£", m_name);
3970 msg_format("%^s chatters.", m_name);
3973 else if (percentage > 20)
3975 msg_format("%^s¤Ï¶ì¤·¤ó¤À¡£", m_name);
3977 msg_format("%^s jeers.", m_name);
3980 else if (percentage > 10)
3982 msg_format("%^s¤Ï¤Î¤¿¤¦¤Á²ó¤Ã¤¿¡£", m_name);
3984 msg_format("%^s flutters about.", m_name);
3989 msg_format("%^s¤Ï¥¡¼¥¡¼¤ÈÌĤ¶«¤ó¤À¡£", m_name);
3991 msg_format("%^s squeaks.", m_name);
3997 /* Dragons, Demons, High Undead */
3998 else if (strchr("duDLUW", r_ptr->d_char))
4000 if (percentage > 95)
4002 msg_format("%s¤Ï¹¶·â¤òµ¤¤Ë¤È¤á¤Æ¤¤¤Ê¤¤¡£", m_name);
4004 msg_format("%^s ignores the attack.", m_name);
4007 else if (percentage > 75)
4009 msg_format("%^s¤Ï¤·¤ê¹þ¤ß¤·¤¿¡£", m_name);
4011 msg_format("%^s flinches.", m_name);
4014 else if (percentage > 50)
4016 msg_format("%^s¤ÏÄˤߤǥ·¡¼¥Ã¤ÈÌĤ¤¤¿¡£", m_name);
4018 msg_format("%^s hisses in pain.", m_name);
4021 else if (percentage > 35)
4023 msg_format("%^s¤ÏÄˤߤǤ¦¤Ê¤Ã¤¿¡£", m_name);
4025 msg_format("%^s snarls with pain.", m_name);
4028 else if (percentage > 20)
4030 msg_format("%^s¤ÏÄˤߤËËʤ¨¤¿¡£", m_name);
4032 msg_format("%^s roars with pain.", m_name);
4035 else if (percentage > 10)
4037 msg_format("%^s¤Ï¶ì¤·¤²¤Ë¶«¤ó¤À¡£", m_name);
4039 msg_format("%^s gasps.", m_name);
4044 msg_format("%^s¤Ï¼å¡¹¤·¤¯¤¦¤Ê¤Ã¤¿¡£", m_name);
4046 msg_format("%^s snarls feebly.", m_name);
4053 else if (strchr("s", r_ptr->d_char))
4055 if (percentage > 95)
4057 msg_format("%s¤Ï¹¶·â¤òµ¤¤Ë¤È¤á¤Æ¤¤¤Ê¤¤¡£", m_name);
4059 msg_format("%^s ignores the attack.", m_name);
4062 else if (percentage > 75)
4064 msg_format("%s¤Ï¹¶·â¤Ë¸ª¤ò¤¹¤¯¤á¤¿¡£", m_name);
4066 msg_format("%^s shrugs off the attack.", m_name);
4069 else if (percentage > 50)
4071 msg_format("%^s¤Ï¥«¥¿¥«¥¿¤È¾Ð¤Ã¤¿¡£", m_name);
4073 msg_format("%^s rattles.", m_name);
4076 else if (percentage > 35)
4078 msg_format("%^s¤Ï¤è¤í¤á¤¤¤¿¡£", m_name);
4080 msg_format("%^s stumbles.", m_name);
4083 else if (percentage > 20)
4085 msg_format("%^s¤Ï¥«¥¿¥«¥¿¸À¤Ã¤¿¡£", m_name);
4087 msg_format("%^s rattles.", m_name);
4090 else if (percentage > 10)
4092 msg_format("%^s¤Ï¤è¤í¤á¤¤¤¿¡£", m_name);
4094 msg_format("%^s staggers.", m_name);
4099 msg_format("%^s¤Ï¥¬¥¿¥¬¥¿¸À¤Ã¤¿¡£", m_name);
4101 msg_format("%^s clatters.", m_name);
4108 else if (strchr("z", r_ptr->d_char))
4110 if (percentage > 95)
4112 msg_format("%s¤Ï¹¶·â¤òµ¤¤Ë¤È¤á¤Æ¤¤¤Ê¤¤¡£", m_name);
4114 msg_format("%^s ignores the attack.", m_name);
4117 else if (percentage > 75)
4119 msg_format("%s¤Ï¹¶·â¤Ë¸ª¤ò¤¹¤¯¤á¤¿¡£", m_name);
4121 msg_format("%^s shrugs off the attack.", m_name);
4124 else if (percentage > 50)
4126 msg_format("%^s¤Ï¤¦¤á¤¤¤¿¡£", m_name);
4128 msg_format("%^s groans.", m_name);
4131 else if (percentage > 35)
4133 msg_format("%s¤Ï¶ì¤·¤²¤Ë¤¦¤á¤¤¤¿¡£", m_name);
4135 msg_format("%^s moans.", m_name);
4138 else if (percentage > 20)
4140 msg_format("%^s¤Ïí´í°¤·¤¿¡£", m_name);
4142 msg_format("%^s hesitates.", m_name);
4145 else if (percentage > 10)
4147 msg_format("%^s¤Ï¤¦¤Ê¤Ã¤¿¡£", m_name);
4149 msg_format("%^s grunts.", m_name);
4154 msg_format("%^s¤Ï¤è¤í¤á¤¤¤¿¡£", m_name);
4156 msg_format("%^s staggers.", m_name);
4163 else if (strchr("G", r_ptr->d_char))
4166 if (percentage > 95)
4168 msg_format("%s¤Ï¹¶·â¤òµ¤¤Ë¤È¤á¤Æ¤¤¤Ê¤¤¡£", m_name);
4170 msg_format("%^s ignores the attack.", m_name);
4173 else if (percentage > 75)
4175 msg_format("%s¤Ï¹¶·â¤Ë¸ª¤ò¤¹¤¯¤á¤¿¡£", m_name);
4177 msg_format("%^s shrugs off the attack.", m_name);
4180 else if (percentage > 50)
4182 msg_format("%s¤Ï¤¦¤á¤¤¤¿¡£", m_name);
4184 msg_format("%^s moans.", m_name);
4187 else if (percentage > 35)
4189 msg_format("%^s¤Ïµã¤¤ï¤á¤¤¤¿¡£", m_name);
4191 msg_format("%^s wails.", m_name);
4194 else if (percentage > 20)
4196 msg_format("%^s¤ÏËʤ¨¤¿¡£", m_name);
4198 msg_format("%^s howls.", m_name);
4201 else if (percentage > 10)
4203 msg_format("%s¤Ï¼å¡¹¤·¤¯¤¦¤á¤¤¤¿¡£", m_name);
4205 msg_format("%^s moans softly.", m_name);
4210 msg_format("%^s¤Ï¤«¤¹¤«¤Ë¤¦¤á¤¤¤¿¡£", m_name);
4212 msg_format("%^s sighs.", m_name);
4218 /* Dogs and Hounds */
4219 else if (strchr("CZ", r_ptr->d_char))
4222 if (percentage > 95)
4223 msg_format("%^s¤Ï¹¶·â¤Ë¸ª¤ò¤¹¤¯¤á¤¿¡£", m_name);
4224 else if (percentage > 75)
4225 msg_format("%^s¤ÏÄˤߤǤ¦¤Ê¤Ã¤¿¡£", m_name);
4226 else if (percentage > 50)
4227 msg_format("%^s¤ÏÄˤߤǥ¥ã¥ó¥¥ã¥óËʤ¨¤¿¡£", m_name);
4228 else if (percentage > 35)
4229 msg_format("%^s¤ÏÄˤߤÇÌĤ¤ï¤á¤¤¤¿¡£", m_name);
4230 else if (percentage > 20)
4231 msg_format("%^s¤Ï¶ìÄˤΤ¢¤Þ¤êÌĤ¤ï¤á¤¤¤¿¡£", m_name);
4232 else if (percentage > 10)
4233 msg_format("%^s¤Ï¶ìÄˤǤâ¤À¤¨¶ì¤·¤ó¤À¡£", m_name);
4235 msg_format("%^s¤Ï¼å¡¹¤·¤¯Ëʤ¨¤¿¡£", m_name);
4237 if (percentage > 95)
4238 msg_format("%^s shrugs off the attack.", m_name);
4239 else if (percentage > 75)
4240 msg_format("%^s snarls with pain.", m_name);
4241 else if (percentage > 50)
4242 msg_format("%^s yelps in pain.", m_name);
4243 else if (percentage > 35)
4244 msg_format("%^s howls in pain.", m_name);
4245 else if (percentage > 20)
4246 msg_format("%^s howls in agony.", m_name);
4247 else if (percentage > 10)
4248 msg_format("%^s writhes in agony.", m_name);
4250 msg_format("%^s yelps feebly.", m_name);
4255 /* One type of monsters (ignore,squeal,shriek) */
4256 else if (strchr("Xbilqrt", r_ptr->d_char))
4259 if (percentage > 95)
4260 msg_format("%^s¤Ï¹¶·â¤òµ¤¤Ë¤È¤á¤Æ¤¤¤Ê¤¤¡£", m_name);
4261 else if (percentage > 75)
4262 msg_format("%^s¤ÏÄˤߤǤ¦¤Ê¤Ã¤¿¡£", m_name);
4263 else if (percentage > 50)
4264 msg_format("%^s¤ÏÄˤߤǶ«¤ó¤À¡£", m_name);
4265 else if (percentage > 35)
4266 msg_format("%^s¤ÏÄˤߤÇÀ䶫¤·¤¿¡£", m_name);
4267 else if (percentage > 20)
4268 msg_format("%^s¤Ï¶ìÄˤΤ¢¤Þ¤êÀ䶫¤·¤¿¡£", m_name);
4269 else if (percentage > 10)
4270 msg_format("%^s¤Ï¶ìÄˤǤâ¤À¤¨¶ì¤·¤ó¤À¡£", m_name);
4272 msg_format("%^s¤Ï¼å¡¹¤·¤¯¶«¤ó¤À¡£", m_name);
4274 if (percentage > 95)
4275 msg_format("%^s ignores the attack.", m_name);
4276 else if (percentage > 75)
4277 msg_format("%^s grunts with pain.", m_name);
4278 else if (percentage > 50)
4279 msg_format("%^s squeals in pain.", m_name);
4280 else if (percentage > 35)
4281 msg_format("%^s shrieks in pain.", m_name);
4282 else if (percentage > 20)
4283 msg_format("%^s shrieks in agony.", m_name);
4284 else if (percentage > 10)
4285 msg_format("%^s writhes in agony.", m_name);
4287 msg_format("%^s cries out feebly.", m_name);
4292 /* Another type of monsters (shrug,cry,scream) */
4296 if (percentage > 95)
4297 msg_format("%^s¤Ï¹¶·â¤Ë¸ª¤ò¤¹¤¯¤á¤¿¡£", m_name);
4298 else if (percentage > 75)
4299 msg_format("%^s¤ÏÄˤߤǤ¦¤Ê¤Ã¤¿¡£", m_name);
4300 else if (percentage > 50)
4301 msg_format("%^s¤ÏÄˤߤǶ«¤ó¤À¡£", m_name);
4302 else if (percentage > 35)
4303 msg_format("%^s¤ÏÄˤߤÇÀ䶫¤·¤¿¡£", m_name);
4304 else if (percentage > 20)
4305 msg_format("%^s¤Ï¶ìÄˤΤ¢¤Þ¤êÀ䶫¤·¤¿¡£", m_name);
4306 else if (percentage > 10)
4307 msg_format("%^s¤Ï¶ìÄˤǤâ¤À¤¨¶ì¤·¤ó¤À¡£", m_name);
4309 msg_format("%^s¤Ï¼å¡¹¤·¤¯¶«¤ó¤À¡£", m_name);
4311 if (percentage > 95)
4312 msg_format("%^s shrugs off the attack.", m_name);
4313 else if (percentage > 75)
4314 msg_format("%^s grunts with pain.", m_name);
4315 else if (percentage > 50)
4316 msg_format("%^s cries out in pain.", m_name);
4317 else if (percentage > 35)
4318 msg_format("%^s screams in pain.", m_name);
4319 else if (percentage > 20)
4320 msg_format("%^s screams in agony.", m_name);
4321 else if (percentage > 10)
4322 msg_format("%^s writhes in agony.", m_name);
4324 msg_format("%^s cries out feebly.", m_name);
4332 * Learn about an "observed" resistance.
4334 void update_smart_learn(int m_idx, int what)
4336 #ifdef DRS_SMART_OPTIONS
4338 monster_type *m_ptr = &m_list[m_idx];
4340 monster_race *r_ptr = &r_info[m_ptr->r_idx];
4343 /* Not allowed to learn */
4344 if (!smart_learn) return;
4346 /* Too stupid to learn anything */
4347 if (r_ptr->flags2 & (RF2_STUPID)) return;
4349 /* Not intelligent, only learn sometimes */
4350 if (!(r_ptr->flags2 & (RF2_SMART)) && (rand_int(100) < 50)) return;
4355 /* Analyze the knowledge */
4359 if (p_ptr->resist_acid) m_ptr->smart |= (SM_RES_ACID);
4360 if (p_ptr->oppose_acid) m_ptr->smart |= (SM_OPP_ACID);
4361 if (p_ptr->immune_acid) m_ptr->smart |= (SM_IMM_ACID);
4365 if (p_ptr->resist_elec) m_ptr->smart |= (SM_RES_ELEC);
4366 if (p_ptr->oppose_elec) m_ptr->smart |= (SM_OPP_ELEC);
4367 if (p_ptr->immune_elec) m_ptr->smart |= (SM_IMM_ELEC);
4371 if (p_ptr->resist_fire) m_ptr->smart |= (SM_RES_FIRE);
4372 if (p_ptr->oppose_fire) m_ptr->smart |= (SM_OPP_FIRE);
4373 if (p_ptr->immune_fire) m_ptr->smart |= (SM_IMM_FIRE);
4377 if (p_ptr->resist_cold) m_ptr->smart |= (SM_RES_COLD);
4378 if (p_ptr->oppose_cold) m_ptr->smart |= (SM_OPP_COLD);
4379 if (p_ptr->immune_cold) m_ptr->smart |= (SM_IMM_COLD);
4383 if (p_ptr->resist_pois) m_ptr->smart |= (SM_RES_POIS);
4384 if (p_ptr->oppose_pois) m_ptr->smart |= (SM_OPP_POIS);
4389 if (p_ptr->resist_neth) m_ptr->smart |= (SM_RES_NETH);
4393 if (p_ptr->resist_lite) m_ptr->smart |= (SM_RES_LITE);
4397 if (p_ptr->resist_dark) m_ptr->smart |= (SM_RES_DARK);
4401 if (p_ptr->resist_fear) m_ptr->smart |= (SM_RES_FEAR);
4405 if (p_ptr->resist_conf) m_ptr->smart |= (SM_RES_CONF);
4409 if (p_ptr->resist_chaos) m_ptr->smart |= (SM_RES_CHAOS);
4413 if (p_ptr->resist_disen) m_ptr->smart |= (SM_RES_DISEN);
4417 if (p_ptr->resist_blind) m_ptr->smart |= (SM_RES_BLIND);
4421 if (p_ptr->resist_nexus) m_ptr->smart |= (SM_RES_NEXUS);
4425 if (p_ptr->resist_sound) m_ptr->smart |= (SM_RES_SOUND);
4429 if (p_ptr->resist_shard) m_ptr->smart |= (SM_RES_SHARD);
4433 if (p_ptr->free_act) m_ptr->smart |= (SM_IMM_FREE);
4437 if (!p_ptr->msp) m_ptr->smart |= (SM_IMM_MANA);
4441 if (p_ptr->reflect) m_ptr-> smart |= (SM_IMM_REFLECT);
4445 #endif /* DRS_SMART_OPTIONS */
4451 * Place the player in the dungeon XXX XXX
4453 bool player_place(int y, int x)
4455 /* Paranoia XXX XXX */
4456 if (cave[y][x].m_idx != 0) return FALSE;
4458 /* Save player location */
4468 * Drop all items carried by a monster
4470 void monster_drop_carried_objects(monster_type *m_ptr)
4472 s16b this_o_idx, next_o_idx = 0;
4478 /* Drop objects being carried */
4479 for (this_o_idx = m_ptr->hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
4481 /* Acquire object */
4482 o_ptr = &o_list[this_o_idx];
4484 /* Acquire next object */
4485 next_o_idx = o_ptr->next_o_idx;
4488 o_ptr->held_m_idx = 0;
4490 /* Get local object */
4493 /* Copy the object */
4494 object_copy(q_ptr, o_ptr);
4496 /* Delete the object */
4497 delete_object_idx(this_o_idx);
4500 (void)drop_near(q_ptr, -1, m_ptr->fy, m_ptr->fx);
4503 /* Forget objects */
4504 m_ptr->hold_o_idx = 0;