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 = (r_ptr->flags3 & RF3_DEMON);
606 okay = (r_ptr->flags3 & RF3_UNDEAD);
612 okay = (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 = (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)
2500 msg_format("ÆÍÁ³%s¤¬ÊѿȤ·¤¿¡£", old_m_name);
2501 if (!(r_ptr->flags7 & RF7_RIDING))
2502 if (rakuba(0, TRUE)) msg_print("ÃÏÌ̤ËÍî¤È¤µ¤ì¤¿¡£");
2505 /* Extract the monster base speed */
2506 m_ptr->mspeed = r_ptr->speed;
2507 /* Hack -- small racial variety */
2508 /* Allow some small variation per monster */
2509 if(rand_int(4) == 1){
2510 i = extract_energy[r_ptr->speed] / 3;
2511 if (i) m_ptr->mspeed += rand_spread(0, i);
2514 i = extract_energy[r_ptr->speed] / 10;
2515 if (i) m_ptr->mspeed += rand_spread(0, i);
2518 oldmaxhp = m_ptr->max_maxhp;
2519 /* Assign maximal hitpoints */
2520 if (r_ptr->flags1 & RF1_FORCE_MAXHP)
2522 m_ptr->max_maxhp = maxroll(r_ptr->hdice, r_ptr->hside);
2526 m_ptr->max_maxhp = damroll(r_ptr->hdice, r_ptr->hside);
2528 m_ptr->maxhp = (long)(m_ptr->maxhp * m_ptr->max_maxhp) / oldmaxhp;
2529 m_ptr->hp = (long)(m_ptr->hp * m_ptr->max_maxhp) / oldmaxhp;
2534 * Attempt to place a monster of the given race at the given location.
2536 * To give the player a sporting chance, any monster that appears in
2537 * line-of-sight and is extremely dangerous can be marked as
2538 * "FORCE_SLEEP", which will cause them to be placed with low energy,
2539 * which often (but not always) lets the player move before they do.
2541 * This routine refuses to place out-of-depth "FORCE_DEPTH" monsters.
2543 * XXX XXX XXX Use special "here" and "dead" flags for unique monsters,
2544 * remove old "cur_num" and "max_num" fields.
2546 * XXX XXX XXX Actually, do something similar for artifacts, to simplify
2547 * the "preserve" mode, and to make the "what artifacts" flag more useful.
2549 * This is the only function which may place a monster in the dungeon,
2550 * except for the savefile loading code.
2552 bool place_monster_one(int y, int x, int r_idx, bool slp, bool friendly, bool pet, bool no_pet)
2558 monster_type *m_ptr;
2560 monster_race *r_ptr = &r_info[r_idx];
2562 cptr name = (r_name + r_ptr->name);
2564 /* DO NOT PLACE A MONSTER IN THE SMALL SCALE WILDERNESS !!! */
2565 if(p_ptr->wild_mode) return FALSE;
2567 /* Verify location */
2568 if (!in_bounds(y, x)) return (FALSE);
2570 /* Require empty space (if not ghostly) */
2571 if (!(!dun_level && (cave[y][x].feat == FEAT_MOUNTAIN) && ((r_ptr->flags8 & RF8_WILD_MOUNTAIN) || (r_ptr->flags7 & RF7_CAN_FLY))) &&
2572 !cave_empty_bold2(y, x) &&
2573 !((r_ptr->flags2 & RF2_PASS_WALL) &&
2574 !(cave_perma_bold(y, x) || cave[y][x].m_idx ||
2575 ((y == py) && (x == px))))) return (FALSE);
2577 /* Hack -- no creation on glyph of warding */
2578 if (cave[y][x].feat == FEAT_GLYPH) return (FALSE);
2579 if (cave[y][x].feat == FEAT_MINOR_GLYPH) return (FALSE);
2581 /* Nor on the Pattern */
2582 if ((cave[y][x].feat >= FEAT_PATTERN_START)
2583 && (cave[y][x].feat <= FEAT_PATTERN_XTRA2))
2587 if (!r_idx) return (FALSE);
2590 if (!r_ptr->name) return (FALSE);
2592 if (monster_terrain_sensitive &&
2593 !monster_can_cross_terrain(cave[y][x].feat, r_ptr))
2598 if (!p_ptr->inside_battle)
2600 /* Hack -- "unique" monsters must be "unique" */
2601 if (((r_ptr->flags1 & (RF1_UNIQUE)) || (r_ptr->flags7 & (RF7_UNIQUE_7))) &&
2602 (r_ptr->cur_num >= r_ptr->max_num))
2608 if (r_ptr->flags7 & (RF7_UNIQUE2))
2612 for (j = m_max -1; j >=1; j--)
2614 if(m_list[j].r_idx == r_idx)
2620 if (fail) return (FALSE);
2623 if (r_idx == MON_BANORLUPART)
2627 for (j = m_max -1; j >=1; j--)
2629 if((m_list[j].r_idx == MON_BANOR) ||(m_list[j].r_idx == MON_LUPART))
2635 if (fail) return (FALSE);
2638 /* Depth monsters may NOT be created out of depth, unless in Nightmare mode */
2639 if ((r_ptr->flags1 & (RF1_FORCE_DEPTH)) && (dun_level < r_ptr->level) &&
2640 (!ironman_nightmare || (r_ptr->flags1 & (RF1_QUESTOR))))
2647 if(quest_number(dun_level))
2649 int hoge = quest_number(dun_level);
2650 if((quest[hoge].type == QUEST_TYPE_KILL_LEVEL) || (quest[hoge].type == QUEST_TYPE_RANDOM))
2652 if(r_idx == quest[hoge].r_idx)
2654 int number_mon, i2, j2;
2657 /* Count all quest monsters */
2658 for (i2 = 0; i2 < cur_wid; ++i2)
2659 for (j2 = 0; j2 < cur_hgt; j2++)
2660 if (cave[j2][i2].m_idx > 0)
2661 if (m_list[cave[j2][i2].m_idx].r_idx == quest[hoge].r_idx)
2663 if(number_mon + quest[hoge].cur_num >= quest[hoge].max_num)
2669 /* Powerful monster */
2670 if (r_ptr->level > dun_level)
2672 /* Unique monsters */
2673 if (r_ptr->flags1 & (RF1_UNIQUE))
2675 /* Message for cheaters */
2677 if (cheat_hear) msg_format("¿¼ÁؤΥæ¥Ë¡¼¥¯¡¦¥â¥ó¥¹¥¿¡¼ (%s)¡£", name);
2679 if (cheat_hear) msg_format("Deep Unique (%s).", name);
2683 /* Boost rating by twice delta-depth */
2684 rating += (r_ptr->level - dun_level) * 2;
2687 /* Normal monsters */
2690 /* Message for cheaters */
2692 if (cheat_hear) msg_format("¿¼ÁؤΥâ¥ó¥¹¥¿¡¼ (%s)¡£", name);
2694 if (cheat_hear) msg_format("Deep Monster (%s).", name);
2698 /* Boost rating by delta-depth */
2699 rating += (r_ptr->level - dun_level);
2703 /* Note the monster */
2704 else if (r_ptr->flags1 & (RF1_UNIQUE))
2706 /* Unique monsters induce message */
2708 if (cheat_hear) msg_format("¥æ¥Ë¡¼¥¯¡¦¥â¥ó¥¹¥¿¡¼ (%s)¡£", name);
2710 if (cheat_hear) msg_format("Unique (%s).", name);
2715 if ((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags7 & RF7_UNIQUE_7) || (r_ptr->level < 10)) is_kage = FALSE;
2717 /* Access the location */
2718 c_ptr = &cave[y][x];
2720 /* Make a new monster */
2721 c_ptr->m_idx = m_pop();
2722 hack_m_idx_ii = c_ptr->m_idx;
2724 /* Mega-Hack -- catch "failure" */
2725 if (!c_ptr->m_idx) return (FALSE);
2728 /* Get a new monster record */
2729 m_ptr = &m_list[c_ptr->m_idx];
2732 m_ptr->r_idx = r_idx;
2734 /* Place the monster at the location */
2739 /* No "damage" yet */
2741 m_ptr->confused = 0;
2744 /* Unknown distance */
2747 m_ptr->target_y = 0;
2748 m_ptr->target_x = 0;
2750 m_ptr->nickname = 0;
2758 if (r_ptr->flags7 & RF7_CHAMELEON)
2760 choose_new_monster(c_ptr->m_idx, TRUE, 0);
2761 r_ptr = &r_info[m_ptr->r_idx];
2762 m_ptr->mflag2 |= MFLAG_CHAMELEON;
2765 else if (is_kage) m_ptr->mflag2 |= MFLAG_KAGE;
2766 if (no_pet) m_ptr->mflag2 |= MFLAG_NOPET;
2777 else if ((friendly || (r_ptr->flags7 & RF7_FRIENDLY)) &&
2778 !(p_ptr->align >= 0 && (r_ptr->flags3 & RF3_EVIL)) &&
2779 !(p_ptr->align < 0 && (r_ptr->flags3 & RF3_GOOD)))
2781 set_friendly(m_ptr);
2784 /* Assume no sleeping */
2787 /* Enforce sleeping if needed */
2788 if (slp && r_ptr->sleep && !ironman_nightmare)
2790 int val = r_ptr->sleep;
2791 m_ptr->csleep = ((val * 2) + randint(val * 10));
2794 /* Assign maximal hitpoints */
2795 if (r_ptr->flags1 & RF1_FORCE_MAXHP)
2797 m_ptr->max_maxhp = maxroll(r_ptr->hdice, r_ptr->hside);
2801 m_ptr->max_maxhp = damroll(r_ptr->hdice, r_ptr->hside);
2804 /* Monsters have double hitpoints in Nightmare mode */
2805 if (ironman_nightmare)
2807 u32b hp = m_ptr->max_maxhp * 2L;
2809 m_ptr->max_maxhp = (s16b)MIN(30000, hp);
2812 m_ptr->maxhp = m_ptr->max_maxhp;
2814 /* And start out fully healthy */
2815 if (m_ptr->r_idx == MON_WOUNDED_BEAR)
2816 m_ptr->hp = m_ptr->maxhp / 2;
2817 else m_ptr->hp = m_ptr->maxhp;
2820 /* Extract the monster base speed */
2821 m_ptr->mspeed = r_ptr->speed;
2823 /* Hack -- small racial variety */
2824 if (!(r_ptr->flags1 & RF1_UNIQUE) && !p_ptr->inside_arena)
2826 /* Allow some small variation per monster */
2827 if(rand_int(4) == 1){
2828 i = extract_energy[r_ptr->speed] / 3;
2829 if (i) m_ptr->mspeed += rand_spread(0, i);
2832 i = extract_energy[r_ptr->speed] / 10;
2833 if (i) m_ptr->mspeed += rand_spread(0, i);
2837 if (m_ptr->mspeed > 199) m_ptr->mspeed = 199;
2839 /* Give a random starting energy */
2840 m_ptr->energy = (byte)rand_int(100);
2842 /* Nightmare monsters are more prepared */
2843 if (ironman_nightmare)
2848 /* Force monster to wait for player, unless in Nightmare mode */
2849 if ((r_ptr->flags1 & RF1_FORCE_SLEEP) && !ironman_nightmare)
2851 /* Monster is still being nice */
2852 m_ptr->mflag |= (MFLAG_NICE);
2854 /* Must repair monsters */
2855 repair_monsters = TRUE;
2858 /* Hack -- see "process_monsters()" */
2859 if (c_ptr->m_idx < hack_m_idx)
2861 /* Monster is still being born */
2862 m_ptr->mflag |= (MFLAG_BORN);
2866 /* Update the monster */
2867 update_mon(c_ptr->m_idx, TRUE);
2870 /* Hack -- Count the monsters on the level */
2874 /* Hack -- Count the number of "reproducers" */
2875 if (r_ptr->flags2 & RF2_MULTIPLY) num_repro++;
2878 /* Hack -- Notice new multi-hued monsters */
2879 if (r_ptr->flags1 & RF1_ATTR_MULTI) shimmer_monsters = TRUE;
2882 create_monster_callback(c_ptr->m_idx);
2883 #endif /* USE_SCRIPT */
2885 if (p_ptr->warning && character_dungeon)
2888 if (r_ptr->flags1 & RF1_UNIQUE)
2890 if (r_ptr->level > p_ptr->lev + 30)
2896 else if (r_ptr->level > p_ptr->lev + 15)
2902 else if (r_ptr->level > p_ptr->lev + 5)
2904 color = "¥ë¥Ó¡¼¿§¤Ë";
2908 else if (r_ptr->level > p_ptr->lev - 5)
2914 else if (r_ptr->level > p_ptr->lev - 15)
2916 color = "¥Ô¥ó¥¯¿§¤Ë";
2927 msg_format("»ØÎؤÏ%s¸÷¤Ã¤¿¡£",color);
2929 msg_format("Your ring glows %s.",color);
2940 * improved version of scatter() for place monster
2943 #define MON_SCAT_MAXD 10
2945 static bool mon_scatter(int *yp, int *xp, int y, int x, int max_dist)
2947 int place_x[MON_SCAT_MAXD];
2948 int place_y[MON_SCAT_MAXD];
2949 int num[MON_SCAT_MAXD];
2953 if (max_dist >= MON_SCAT_MAXD)
2956 for (i = 0; i < MON_SCAT_MAXD; i++)
2959 for (nx = x - max_dist; nx <= x + max_dist; nx++)
2960 for (ny = y - max_dist; ny <= y + max_dist; ny++)
2962 /* Ignore annoying locations */
2963 if (!in_bounds(ny, nx)) continue;
2965 /* Require "line of sight" */
2966 if (!los(y, x, ny, nx)) continue;
2968 /* Walls and Monsters block flow */
2969 if (!cave_empty_bold2(ny, nx)) continue;
2970 if (cave[ny][nx].m_idx) continue;
2971 if ((ny == py) && (nx == px)) continue;
2973 /* Hack -- no summon on glyph of warding */
2974 if (cave[ny][nx].feat == FEAT_GLYPH) continue;
2975 if (cave[ny][nx].feat == FEAT_MINOR_GLYPH) continue;
2977 /* ... nor on the Pattern */
2978 if ((cave[ny][nx].feat >= FEAT_PATTERN_START) &&
2979 (cave[ny][nx].feat <= FEAT_PATTERN_XTRA2))
2982 i = distance(y, x, ny, nx);
2999 while (i < MON_SCAT_MAXD && 0 == num[i])
3001 if (i >= MON_SCAT_MAXD)
3012 * Maximum size of a group of monsters
3014 #define GROUP_MAX 32
3018 * Attempt to place a "group" of monsters around the given location
3020 static bool place_monster_group(int y, int x, int r_idx, bool slp, bool friendly, bool pet, bool no_pet)
3022 monster_race *r_ptr = &r_info[r_idx];
3025 int total = 0, extra = 0;
3029 byte hack_y[GROUP_MAX];
3030 byte hack_x[GROUP_MAX];
3033 /* Pick a group size */
3034 total = randint(10);
3036 /* Hard monsters, small groups */
3037 if (r_ptr->level > dun_level)
3039 extra = r_ptr->level - dun_level;
3040 extra = 0 - randint(extra);
3043 /* Easy monsters, large groups */
3044 else if (r_ptr->level < dun_level)
3046 extra = dun_level - r_ptr->level;
3047 extra = randint(extra);
3050 /* Hack -- limit group reduction */
3051 if (extra > 9) extra = 9;
3053 /* Modify the group size */
3057 if (total < 1) total = 1;
3060 if (total > GROUP_MAX) total = GROUP_MAX;
3063 /* Save the rating */
3066 /* Start on the monster */
3071 /* Puddle monsters, breadth first, up to total */
3072 for (n = 0; (n < hack_n) && (hack_n < total); n++)
3074 /* Grab the location */
3078 /* Check each direction, up to total */
3079 for (i = 0; (i < 8) && (hack_n < total); i++)
3083 scatter(&my, &mx, hy, hx, 4, 0);
3085 /* Walls and Monsters block flow */
3086 if (!cave_empty_bold2(my, mx)) continue;
3088 /* Attempt to place another monster */
3089 if (place_monster_one(my, mx, r_idx, slp, friendly, pet, no_pet))
3091 /* Add it to the "hack" set */
3092 hack_y[hack_n] = my;
3093 hack_x[hack_n] = mx;
3099 /* Hack -- restore the rating */
3109 * Hack -- help pick an escort type
3111 static int place_monster_idx = 0;
3114 * Hack -- help pick an escort type
3116 static bool place_monster_okay(int r_idx)
3118 monster_race *r_ptr = &r_info[place_monster_idx];
3120 monster_race *z_ptr = &r_info[r_idx];
3122 /* Hack - Escorts have to have the same dungeon flag */
3123 if (monster_dungeon(place_monster_idx) != monster_dungeon(r_idx)) return (FALSE);
3125 /* Require similar "race" */
3126 if (z_ptr->d_char != r_ptr->d_char) return (FALSE);
3128 /* Skip more advanced monsters */
3129 if (z_ptr->level > r_ptr->level) return (FALSE);
3131 /* Skip unique monsters */
3132 if (z_ptr->flags1 & RF1_UNIQUE) return (FALSE);
3134 /* Paranoia -- Skip identical monsters */
3135 if (place_monster_idx == r_idx) return (FALSE);
3143 * Attempt to place a monster of the given race at the given location
3145 * Note that certain monsters are now marked as requiring "friends".
3146 * These monsters, if successfully placed, and if the "grp" parameter
3147 * is TRUE, will be surrounded by a "group" of identical monsters.
3149 * Note that certain monsters are now marked as requiring an "escort",
3150 * which is a collection of monsters with similar "race" but lower level.
3152 * Some monsters induce a fake "group" flag on their escorts.
3154 * Note the "bizarre" use of non-recursion to prevent annoying output
3155 * when running a code profiler.
3157 * Note the use of the new "monster allocation table" code to restrict
3158 * the "get_mon_num()" function to "legal" escort types.
3160 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)
3163 monster_race *r_ptr = &r_info[r_idx];
3165 if (one_in_(333) && !no_kage && !pet) is_kage = TRUE;
3166 else is_kage = FALSE;
3168 /* Place one monster, or fail */
3169 if (!place_monster_one(y, x, r_idx, slp, friendly, pet, no_pet)) return (FALSE);
3172 /* Require the "group" flag */
3173 if (!grp) return (TRUE);
3176 /* Friends for certain monsters */
3177 if (r_ptr->flags1 & (RF1_FRIENDS))
3179 /* Attempt to place a group */
3180 (void)place_monster_group(y, x, r_idx, slp, friendly, pet, no_pet);
3184 /* Escorts for certain monsters */
3185 if (r_ptr->flags1 & (RF1_ESCORT))
3187 /* Set the escort index */
3188 place_monster_idx = r_idx;
3190 /* Try to place several "escorts" */
3191 for (i = 0; i < 32; i++)
3193 int nx, ny, z, d = 3;
3195 /* Pick a location */
3196 scatter(&ny, &nx, y, x, d, 0);
3198 /* Require empty grids */
3199 if (!cave_empty_bold2(ny, nx)) continue;
3201 /* Prepare allocation table */
3202 get_mon_num_prep(place_monster_okay, get_monster_hook2(ny, nx));
3204 /* Pick a random race */
3205 z = get_mon_num(r_ptr->level);
3207 /* Handle failure */
3210 if (((r_ptr->flags3 & RF3_EVIL) && (r_info[z].flags3 & RF3_GOOD)) || ((r_ptr->flags3 & RF3_GOOD) && (r_info[z].flags3 & RF3_EVIL)))
3216 if (r_ptr->flags7 & RF7_FRIENDLY)
3218 if (((p_ptr->align < 0) && (r_info[z].flags3 & RF3_GOOD)) ||
3219 ((p_ptr->align > 0) && (r_info[z].flags3 & RF3_EVIL)))
3226 /* Place a single escort */
3227 (void)place_monster_one(ny, nx, z, slp, friendly, pet, no_pet);
3229 /* Place a "group" of escorts if needed */
3230 if ((r_info[z].flags1 & RF1_FRIENDS) ||
3231 (r_ptr->flags1 & RF1_ESCORTS))
3233 /* Place a group of monsters */
3234 (void)place_monster_group(ny, nx, z, slp, friendly, pet, no_pet);
3245 * Hack -- attempt to place a monster at the given location
3247 * Attempt to find a monster appropriate to the "monster_level"
3249 bool place_monster(int y, int x, bool slp, bool grp)
3253 /* Prepare allocation table */
3254 get_mon_num_prep(get_monster_hook(), get_monster_hook2(y, x));
3256 /* Pick a monster */
3257 r_idx = get_mon_num(monster_level);
3259 /* Handle failure */
3260 if (!r_idx) return (FALSE);
3262 /* Attempt to place the monster */
3263 if (place_monster_aux(y, x, r_idx, slp, grp, FALSE, FALSE, FALSE, FALSE)) return (TRUE);
3270 #ifdef MONSTER_HORDES
3272 bool alloc_horde(int y, int x)
3274 monster_race *r_ptr = NULL;
3277 int attempts = 1000;
3281 /* Prepare allocation table */
3282 get_mon_num_prep(get_monster_hook(), get_monster_hook2(y, x));
3286 /* Pick a monster */
3287 r_idx = get_mon_num(monster_level);
3289 /* Handle failure */
3290 if (!r_idx) return (FALSE);
3292 r_ptr = &r_info[r_idx];
3294 if (r_ptr->flags1 & RF1_UNIQUE) continue;
3296 if (r_idx == MON_HAGURE) continue;
3299 if (attempts < 1) return FALSE;
3301 if (r_ptr->flags3 & RF3_GOOD) horde_align |= HORDE_NOEVIL;
3302 if (r_ptr->flags3 & RF3_EVIL) horde_align |= HORDE_NOGOOD;
3308 /* Attempt to place the monster */
3309 if (place_monster_aux(y, x, r_idx, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE)) break;
3312 if (attempts < 1) {horde_align = 0;return FALSE;}
3314 m_idx = cave[y][x].m_idx;
3316 if (m_list[m_idx].mflag2 & MFLAG_CHAMELEON) r_ptr = &r_info[m_list[m_idx].r_idx];
3317 summon_kin_type = r_ptr->d_char;
3319 for (attempts = randint(10) + 5; attempts; attempts--)
3321 scatter(&cy, &cx, y, x, 5, 0);
3323 (void)summon_specific(m_idx, cy, cx, dun_level + 5, SUMMON_KIN, TRUE, FALSE, FALSE, FALSE, FALSE);
3333 #endif /* MONSTER_HORDES */
3338 * Attempt to allocate a random monster in the dungeon.
3340 * Place the monster at least "dis" distance from the player.
3342 * Use "slp" to choose the initial "sleep" status
3344 * Use "monster_level" for the monster level
3346 bool alloc_monster(int dis, bool slp)
3349 int attempts_left = 10000;
3351 /* Find a legal, distant, unoccupied, space */
3352 while (attempts_left--)
3354 /* Pick a location */
3355 y = rand_int(cur_hgt);
3356 x = rand_int(cur_wid);
3358 /* Require empty floor grid (was "naked") */
3359 if (dun_level || (wilderness[p_ptr->wilderness_y][p_ptr->wilderness_x].terrain != TERRAIN_MOUNTAIN))
3361 if (!cave_empty_bold2(y, x)) continue;
3365 if (!cave_empty_bold2(y, x) && (cave[y][x].feat != FEAT_MOUNTAIN)) continue;
3368 /* Accept far away grids */
3369 if (distance(y, x, py, px) > dis) break;
3374 if (cheat_xtra || cheat_hear)
3377 msg_print("·Ù¹ð¡ª¿·¤¿¤Ê¥â¥ó¥¹¥¿¡¼¤òÇÛÃ֤Ǥ¤Þ¤»¤ó¡£¾®¤µ¤¤³¬¤Ç¤¹¤«¡©");
3379 msg_print("Warning! Could not allocate a new monster. Small level?");
3388 #ifdef MONSTER_HORDES
3389 if (randint(5000) <= dun_level)
3391 if (alloc_horde(y, x))
3394 if (cheat_hear) msg_print("¥â¥ó¥¹¥¿¡¼¤ÎÂç·²");
3396 if (cheat_hear) msg_print("Monster horde.");
3404 #endif /* MONSTER_HORDES */
3406 /* Attempt to place the monster, allow groups */
3407 if (place_monster(y, x, slp, TRUE)) return (TRUE);
3409 #ifdef MONSTER_HORDES
3411 #endif /* MONSTER_HORDES */
3421 * Hack -- help decide if a monster race is "okay" to summon
3423 static bool summon_specific_okay(int r_idx)
3425 monster_race *r_ptr = &r_info[r_idx];
3427 /* Hack - Only summon dungeon monsters */
3428 if (!monster_dungeon(r_idx)) return (FALSE);
3430 /* Hack -- identify the summoning monster */
3431 if (summon_specific_who > 0)
3433 monster_type *m_ptr = &m_list[summon_specific_who];
3434 monster_race *s_ptr = &r_info[m_ptr->r_idx];
3436 /* Do not summon enemies */
3438 /* Friendly vs. opposite aligned normal or pet */
3439 if (((r_ptr->flags3 & RF3_EVIL) &&
3440 (s_ptr->flags3 & RF3_GOOD)) ||
3441 ((r_ptr->flags3 & RF3_GOOD) &&
3442 (s_ptr->flags3 & RF3_EVIL)))
3447 /* Hostile vs. non-hostile */
3448 if (is_hostile(m_ptr) != summon_specific_hostile)
3453 /* Use the player's alignment */
3454 else if (summon_specific_who < 0)
3456 /* Do not summon enemies of the pets */
3457 if ((p_ptr->align < -9) && (r_ptr->flags3 & RF3_GOOD))
3459 if (!(one_in_((0-p_ptr->align)/2+1))) return FALSE;
3461 else if ((p_ptr->align > 9) && (r_ptr->flags3 & RF3_EVIL))
3463 if (!(one_in_(p_ptr->align/2+1))) return FALSE;
3467 /* Hack -- no specific type specified */
3468 if (!summon_specific_type) return (TRUE);
3470 if (!summon_unique_okay && ((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags7 & RF7_UNIQUE_7))) return FALSE;
3472 if ((summon_specific_who < 0) &&
3473 ((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags7 & RF7_UNIQUE_7)) &&
3474 (((p_ptr->align > 9) && (r_ptr->flags3 & RF3_EVIL)) ||
3475 ((p_ptr->align < -9) && (r_ptr->flags3 & RF3_GOOD))))
3478 if ((horde_align & HORDE_NOGOOD) && (r_ptr->flags3 & RF3_GOOD)) return FALSE;
3479 if ((horde_align & HORDE_NOEVIL) && (r_ptr->flags3 & RF3_EVIL)) return FALSE;
3481 if ((r_ptr->flags7 & RF7_CHAMELEON) && (d_info[dungeon_type].flags1 & DF1_CHAMELEON)) return TRUE;
3483 return (summon_specific_aux(r_idx));
3488 * Place a monster (of the specified "type") near the given
3489 * location. Return TRUE if a monster was actually summoned.
3491 * We will attempt to place the monster up to 10 times before giving up.
3493 * Note: SUMMON_UNIQUE and SUMMON_AMBERITES will summon Unique's
3494 * Note: SUMMON_HI_UNDEAD and SUMMON_HI_DRAGON may summon Unique's
3495 * Note: None of the other summon codes will ever summon Unique's.
3497 * This function has been changed. We now take the "monster level"
3498 * of the summoning monster as a parameter, and use that, along with
3499 * the current dungeon level, to help determine the level of the
3500 * desired monster. Note that this is an upper bound, and also
3501 * tends to "prefer" monsters of that level. Currently, we use
3502 * the average of the dungeon and monster levels, and then add
3503 * five to allow slight increases in monster power.
3505 * Note that we use the new "monster allocation table" creation code
3506 * to restrict the "get_mon_num()" function to the set of "legal"
3507 * monsters, making this function much faster and more reliable.
3509 * Note that this function may not succeed, though this is very rare.
3511 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)
3515 bool no_kage = FALSE;
3517 if (p_ptr->inside_arena) return (FALSE);
3519 if (!mon_scatter(&y, &x, y1, x1, 2)) return FALSE;
3521 /* Save the summoner */
3522 summon_specific_who = who;
3524 /* Save the "summon" type */
3525 summon_specific_type = type;
3527 summon_unique_okay = unique_okay;
3529 /* Save the hostility */
3530 summon_specific_hostile = (!friendly && !pet);
3532 /* Prepare allocation table */
3533 get_mon_num_prep(summon_specific_okay, get_monster_hook2(y, x));
3535 /* Pick a monster, using the level calculation */
3536 r_idx = get_mon_num((dun_level + lev) / 2 + 5);
3538 /* Handle failure */
3541 summon_specific_type = 0;
3545 if ((type == SUMMON_BLUE_HORROR) || (type == SUMMON_DAWN)) no_kage = TRUE;
3547 /* Attempt to place the monster (awake, allow groups) */
3548 if (!place_monster_aux(y, x, r_idx, FALSE, group, friendly, pet, no_kage, no_pet))
3550 summon_specific_type = 0;
3554 summon_specific_type = 0;
3559 /* A "dangerous" function, creates a pet of the specified type */
3560 bool summon_named_creature (int oy, int ox, int r_idx, bool slp, bool group_ok, bool friendly, bool pet)
3565 /* if (!r_idx) return; */
3567 /* Prevent illegal monsters */
3568 if (r_idx >= max_r_idx) return FALSE;
3570 if (p_ptr->inside_arena) return FALSE;
3572 if (!mon_scatter(&y, &x, oy, ox, 2)) return FALSE;
3574 /* Place it (allow groups) */
3575 return place_monster_aux(y, x, r_idx, slp, group_ok, friendly, pet, TRUE, FALSE);
3580 * Let the given monster attempt to reproduce.
3582 * Note that "reproduction" REQUIRES empty space.
3584 bool multiply_monster(int m_idx, bool clone, bool friendly, bool pet)
3586 monster_type *m_ptr = &m_list[m_idx];
3590 if (!mon_scatter(&y, &x, m_ptr->fy, m_ptr->fx, 1))
3593 /* Create a new monster (awake, no groups) */
3594 if (!place_monster_aux(y, x, m_ptr->r_idx, FALSE, FALSE, friendly, pet, TRUE, (m_ptr->mflag2 & MFLAG_NOPET)))
3599 m_list[hack_m_idx_ii].smart |= SM_CLONED;
3600 m_list[hack_m_idx_ii].mflag2 |= MFLAG_NOPET;
3611 * Dump a message describing a monster's reaction to damage
3613 * Technically should attempt to treat "Beholder"'s as jelly's
3615 void message_pain(int m_idx, int dam)
3617 long oldhp, newhp, tmp;
3620 monster_type *m_ptr = &m_list[m_idx];
3621 monster_race *r_ptr = &r_info[m_ptr->r_idx];
3626 /* Get the monster name */
3627 monster_desc(m_name, m_ptr, 0);
3629 /* Notice non-damage */
3633 msg_format("%^s¤Ï¥À¥á¡¼¥¸¤ò¼õ¤±¤Æ¤¤¤Ê¤¤¡£", m_name);
3635 msg_format("%^s is unharmed.", m_name);
3641 /* Note -- subtle fix -CFT */
3642 newhp = (long)(m_ptr->hp);
3643 oldhp = newhp + (long)(dam);
3644 tmp = (newhp * 100L) / oldhp;
3645 percentage = (int)(tmp);
3648 /* Mushrooms, Eyes, Jellies, Molds, Vortices, Worms, Quylthulgs */
3649 if (strchr(",ejmvwQ", r_ptr->d_char))
3652 if (percentage > 95)
3653 msg_format("%^s¤Ï¤Û¤È¤ó¤Éµ¤¤Ë¤È¤á¤Æ¤¤¤Ê¤¤¡£", m_name);
3654 else if (percentage > 75)
3655 msg_format("%^s¤Ï¤·¤ê¹þ¤ß¤·¤¿¡£", m_name);
3656 else if (percentage > 50)
3657 msg_format("%^s¤Ï½Ì¤³¤Þ¤Ã¤¿¡£", m_name);
3658 else if (percentage > 35)
3659 msg_format("%^s¤ÏÄˤߤ˿̤¨¤¿¡£", m_name);
3660 else if (percentage > 20)
3661 msg_format("%^s¤Ï¿È¤â¤À¤¨¤·¤¿¡£", m_name);
3662 else if (percentage > 10)
3663 msg_format("%^s¤Ï¶ìÄˤǿȤâ¤À¤¨¤·¤¿¡£", m_name);
3665 msg_format("%^s¤Ï¤°¤Ë¤ã¤°¤Ë¤ã¤ÈáÛÚ»¤·¤¿¡£", m_name);
3667 if (percentage > 95)
3668 msg_format("%^s barely notices.", m_name);
3669 else if (percentage > 75)
3670 msg_format("%^s flinches.", m_name);
3671 else if (percentage > 50)
3672 msg_format("%^s squelches.", m_name);
3673 else if (percentage > 35)
3674 msg_format("%^s quivers in pain.", m_name);
3675 else if (percentage > 20)
3676 msg_format("%^s writhes about.", m_name);
3677 else if (percentage > 10)
3678 msg_format("%^s writhes in agony.", m_name);
3680 msg_format("%^s jerks limply.", m_name);
3687 else if (strchr("l", r_ptr->d_char))
3689 if (percentage > 95)
3691 msg_format("%^s¤Ï¤Û¤È¤ó¤Éµ¤¤Ë¤È¤á¤Æ¤¤¤Ê¤¤¡£", m_name);
3693 msg_format("%^s barely notices.", m_name);
3695 else if (percentage > 75)
3697 msg_format("%^s¤Ï¤·¤ê¹þ¤ß¤·¤¿¡£", m_name);
3699 msg_format("%^s flinches.", m_name);
3701 else if (percentage > 50)
3703 msg_format("%^s¤Ïí´í°¤·¤¿¡£", m_name);
3705 msg_format("%^s hesitates.", m_name);
3707 else if (percentage > 35)
3709 msg_format("%^s¤ÏÄˤߤ˿̤¨¤¿¡£", m_name);
3711 msg_format("%^s quivers in pain.", m_name);
3713 else if (percentage > 20)
3715 msg_format("%^s¤Ï¿È¤â¤À¤¨¤·¤¿¡£", m_name);
3717 msg_format("%^s writhes about.", m_name);
3719 else if (percentage > 10)
3721 msg_format("%^s¤Ï¶ìÄˤǿȤâ¤À¤¨¤·¤¿¡£", m_name);
3723 msg_format("%^s writhes in agony.", m_name);
3727 msg_format("%^s¤Ï¤°¤Ë¤ã¤°¤Ë¤ã¤ÈáÛÚ»¤·¤¿¡£", m_name);
3729 msg_format("%^s jerks limply.", m_name);
3734 /* Golems, Walls, Doors, Stairs */
3735 else if (strchr("g#+<>", r_ptr->d_char))
3737 if (percentage > 95)
3739 msg_format("%s¤Ï¹¶·â¤òµ¤¤Ë¤È¤á¤Æ¤¤¤Ê¤¤¡£", m_name);
3741 msg_format("%^s ignores the attack.", m_name);
3743 else if (percentage > 75)
3745 msg_format("%s¤Ï¹¶·â¤Ë¸ª¤ò¤¹¤¯¤á¤¿¡£", m_name);
3747 msg_format("%^s shrugs off the attack.", m_name);
3749 else if (percentage > 50)
3751 msg_format("%^s¤ÏÍëÌĤΤ褦¤ËËʤ¨¤¿¡£", m_name);
3753 msg_format("%^s roars thunderously.", m_name);
3755 else if (percentage > 35)
3757 msg_format("%^s¤Ï¶ì¤·¤²¤ËËʤ¨¤¿¡£", m_name);
3759 msg_format("%^s rumbles.", m_name);
3761 else if (percentage > 20)
3763 msg_format("%^s¤Ï¤¦¤á¤¤¤¿¡£", m_name);
3765 msg_format("%^s grunts.", m_name);
3767 else if (percentage > 10)
3769 msg_format("%^s¤Ïí´í°¤·¤¿¡£", m_name);
3771 msg_format("%^s hesitates.", m_name);
3775 msg_format("%^s¤Ï¤¯¤·¤ã¤¯¤·¤ã¤Ë¤Ê¤Ã¤¿¡£", m_name);
3777 msg_format("%^s crumples.", m_name);
3782 /* Snakes, Hydrae, Reptiles, Mimics */
3783 else if (strchr("JMR", r_ptr->d_char) || !isalpha(r_ptr->d_char))
3785 if (percentage > 95)
3787 msg_format("%^s¤Ï¤Û¤È¤ó¤Éµ¤¤Ë¤È¤á¤Æ¤¤¤Ê¤¤¡£", m_name);
3789 msg_format("%^s barely notices.", m_name);
3791 else if (percentage > 75)
3793 msg_format("%^s¤Ï¥·¡¼¥Ã¤ÈÌĤ¤¤¿¡£", m_name);
3795 msg_format("%^s hisses.", m_name);
3797 else if (percentage > 50)
3799 msg_format("%^s¤ÏÅܤäÆƬ¤ò¾å¤²¤¿¡£", m_name);
3801 msg_format("%^s rears up in anger.", m_name);
3803 else if (percentage > 35)
3805 msg_format("%^s¤ÏÌÔÁ³¤È°Ò³Å¤·¤¿¡£", m_name);
3807 msg_format("%^s hisses furiously.", m_name);
3809 else if (percentage > 20)
3811 msg_format("%^s¤Ï¿È¤â¤À¤¨¤·¤¿¡£", m_name);
3813 msg_format("%^s writhes about.", m_name);
3815 else if (percentage > 10)
3817 msg_format("%^s¤Ï¶ìÄˤǿȤâ¤À¤¨¤·¤¿¡£", m_name);
3819 msg_format("%^s writhes in agony.", m_name);
3823 msg_format("%^s¤Ï¤°¤Ë¤ã¤°¤Ë¤ã¤ÈáÛÚ»¤·¤¿¡£", m_name);
3825 msg_format("%^s jerks limply.", m_name);
3831 else if (strchr("f", r_ptr->d_char))
3833 if (percentage > 95)
3835 msg_format("%s¤Ï¹¶·â¤Ë¸ª¤ò¤¹¤¯¤á¤¿¡£", m_name);
3837 msg_format("%^s shrugs off the attack.", m_name);
3839 else if (percentage > 75)
3841 msg_format("%^s¤ÏËʤ¨¤¿¡£", m_name);
3843 msg_format("%^s roars.", m_name);
3845 else if (percentage > 50)
3847 msg_format("%^s¤ÏÅܤäÆËʤ¨¤¿¡£", m_name);
3849 msg_format("%^s growls angrily.", m_name);
3851 else if (percentage > 35)
3853 msg_format("%^s¤ÏÄˤߤǥ·¡¼¥Ã¤ÈÌĤ¤¤¿¡£", m_name);
3855 msg_format("%^s hisses with pain.", m_name);
3857 else if (percentage > 20)
3859 msg_format("%^s¤ÏÄˤߤǼ塹¤·¤¯ÌĤ¤¤¿¡£", m_name);
3861 msg_format("%^s mewls in pain.", m_name);
3863 else if (percentage > 10)
3865 msg_format("%^s¤Ï¶ìÄˤˤ¦¤á¤¤¤¿¡£", m_name);
3867 msg_format("%^s hisses in agony.", m_name);
3871 msg_format("%s¤Ï°¥¤ì¤ÊÌĤÀ¼¤ò½Ð¤·¤¿¡£", m_name);
3873 msg_format("%^s mewls pitifully.", m_name);
3878 /* Ants, Centipedes, Flies, Insects, Beetles, Spiders */
3879 else if (strchr("acFIKS", r_ptr->d_char))
3881 if (percentage > 95)
3883 msg_format("%s¤Ï¹¶·â¤òµ¤¤Ë¤È¤á¤Æ¤¤¤Ê¤¤¡£", m_name);
3885 msg_format("%^s ignores the attack.", m_name);
3887 else if (percentage > 75)
3889 msg_format("%^s¤Ï¥¡¼¥¡¼ÌĤ¤¤¿¡£", m_name);
3891 msg_format("%^s chitters.", m_name);
3894 else if (percentage > 50)
3896 msg_format("%^s¤Ï¥è¥í¥è¥íƨ¤²²ó¤Ã¤¿¡£", m_name);
3898 msg_format("%^s scuttles about.", m_name);
3901 else if (percentage > 35)
3903 msg_format("%^s¤Ï¤¦¤ë¤µ¤¯ÌĤ¤¤¿¡£", m_name);
3905 msg_format("%^s twitters.", m_name);
3908 else if (percentage > 20)
3910 msg_format("%^s¤ÏÄˤߤËáÛÚ»¤·¤¿¡£", m_name);
3912 msg_format("%^s jerks in pain.", m_name);
3915 else if (percentage > 10)
3917 msg_format("%^s¤Ï¶ìÄˤÇáÛÚ»¤·¤¿¡£", m_name);
3919 msg_format("%^s jerks in agony.", m_name);
3924 msg_format("%^s¤Ï¥Ô¥¯¥Ô¥¯¤Ò¤¤Ä¤Ã¤¿¡£", m_name);
3926 msg_format("%^s twitches.", m_name);
3933 else if (strchr("B", r_ptr->d_char))
3935 if (percentage > 95)
3937 msg_format("%^s¤Ï¤µ¤¨¤º¤Ã¤¿¡£", m_name);
3939 msg_format("%^s chirps.", m_name);
3942 else if (percentage > 75)
3944 msg_format("%^s¤Ï¥Ô¡¼¥Ô¡¼ÌĤ¤¤¿¡£", m_name);
3946 msg_format("%^s twitters.", m_name);
3949 else if (percentage > 50)
3951 msg_format("%^s¤Ï¥®¥ã¡¼¥®¥ã¡¼ÌĤ¤¤¿¡£", m_name);
3953 msg_format("%^s squawks.", m_name);
3956 else if (percentage > 35)
3958 msg_format("%^s¤Ï¥®¥ã¡¼¥®¥ã¡¼ÌĤ¤ï¤á¤¤¤¿¡£", m_name);
3960 msg_format("%^s chatters.", m_name);
3963 else if (percentage > 20)
3965 msg_format("%^s¤Ï¶ì¤·¤ó¤À¡£", m_name);
3967 msg_format("%^s jeers.", m_name);
3970 else if (percentage > 10)
3972 msg_format("%^s¤Ï¤Î¤¿¤¦¤Á²ó¤Ã¤¿¡£", m_name);
3974 msg_format("%^s flutters about.", m_name);
3979 msg_format("%^s¤Ï¥¡¼¥¡¼¤ÈÌĤ¶«¤ó¤À¡£", m_name);
3981 msg_format("%^s squeaks.", m_name);
3987 /* Dragons, Demons, High Undead */
3988 else if (strchr("duDLUW", r_ptr->d_char))
3990 if (percentage > 95)
3992 msg_format("%s¤Ï¹¶·â¤òµ¤¤Ë¤È¤á¤Æ¤¤¤Ê¤¤¡£", m_name);
3994 msg_format("%^s ignores the attack.", m_name);
3997 else if (percentage > 75)
3999 msg_format("%^s¤Ï¤·¤ê¹þ¤ß¤·¤¿¡£", m_name);
4001 msg_format("%^s flinches.", m_name);
4004 else if (percentage > 50)
4006 msg_format("%^s¤ÏÄˤߤǥ·¡¼¥Ã¤ÈÌĤ¤¤¿¡£", m_name);
4008 msg_format("%^s hisses in pain.", m_name);
4011 else if (percentage > 35)
4013 msg_format("%^s¤ÏÄˤߤǤ¦¤Ê¤Ã¤¿¡£", m_name);
4015 msg_format("%^s snarls with pain.", m_name);
4018 else if (percentage > 20)
4020 msg_format("%^s¤ÏÄˤߤËËʤ¨¤¿¡£", m_name);
4022 msg_format("%^s roars with pain.", m_name);
4025 else if (percentage > 10)
4027 msg_format("%^s¤Ï¶ì¤·¤²¤Ë¶«¤ó¤À¡£", m_name);
4029 msg_format("%^s gasps.", m_name);
4034 msg_format("%^s¤Ï¼å¡¹¤·¤¯¤¦¤Ê¤Ã¤¿¡£", m_name);
4036 msg_format("%^s snarls feebly.", m_name);
4043 else if (strchr("s", r_ptr->d_char))
4045 if (percentage > 95)
4047 msg_format("%s¤Ï¹¶·â¤òµ¤¤Ë¤È¤á¤Æ¤¤¤Ê¤¤¡£", m_name);
4049 msg_format("%^s ignores the attack.", m_name);
4052 else if (percentage > 75)
4054 msg_format("%s¤Ï¹¶·â¤Ë¸ª¤ò¤¹¤¯¤á¤¿¡£", m_name);
4056 msg_format("%^s shrugs off the attack.", m_name);
4059 else if (percentage > 50)
4061 msg_format("%^s¤Ï¥«¥¿¥«¥¿¤È¾Ð¤Ã¤¿¡£", m_name);
4063 msg_format("%^s rattles.", m_name);
4066 else if (percentage > 35)
4068 msg_format("%^s¤Ï¤è¤í¤á¤¤¤¿¡£", m_name);
4070 msg_format("%^s stumbles.", m_name);
4073 else if (percentage > 20)
4075 msg_format("%^s¤Ï¥«¥¿¥«¥¿¸À¤Ã¤¿¡£", m_name);
4077 msg_format("%^s rattles.", m_name);
4080 else if (percentage > 10)
4082 msg_format("%^s¤Ï¤è¤í¤á¤¤¤¿¡£", m_name);
4084 msg_format("%^s staggers.", m_name);
4089 msg_format("%^s¤Ï¥¬¥¿¥¬¥¿¸À¤Ã¤¿¡£", m_name);
4091 msg_format("%^s clatters.", m_name);
4098 else if (strchr("z", r_ptr->d_char))
4100 if (percentage > 95)
4102 msg_format("%s¤Ï¹¶·â¤òµ¤¤Ë¤È¤á¤Æ¤¤¤Ê¤¤¡£", m_name);
4104 msg_format("%^s ignores the attack.", m_name);
4107 else if (percentage > 75)
4109 msg_format("%s¤Ï¹¶·â¤Ë¸ª¤ò¤¹¤¯¤á¤¿¡£", m_name);
4111 msg_format("%^s shrugs off the attack.", m_name);
4114 else if (percentage > 50)
4116 msg_format("%^s¤Ï¤¦¤á¤¤¤¿¡£", m_name);
4118 msg_format("%^s groans.", m_name);
4121 else if (percentage > 35)
4123 msg_format("%s¤Ï¶ì¤·¤²¤Ë¤¦¤á¤¤¤¿¡£", m_name);
4125 msg_format("%^s moans.", m_name);
4128 else if (percentage > 20)
4130 msg_format("%^s¤Ïí´í°¤·¤¿¡£", m_name);
4132 msg_format("%^s hesitates.", m_name);
4135 else if (percentage > 10)
4137 msg_format("%^s¤Ï¤¦¤Ê¤Ã¤¿¡£", m_name);
4139 msg_format("%^s grunts.", m_name);
4144 msg_format("%^s¤Ï¤è¤í¤á¤¤¤¿¡£", m_name);
4146 msg_format("%^s staggers.", m_name);
4153 else if (strchr("G", r_ptr->d_char))
4156 if (percentage > 95)
4158 msg_format("%s¤Ï¹¶·â¤òµ¤¤Ë¤È¤á¤Æ¤¤¤Ê¤¤¡£", m_name);
4160 msg_format("%^s ignores the attack.", m_name);
4163 else if (percentage > 75)
4165 msg_format("%s¤Ï¹¶·â¤Ë¸ª¤ò¤¹¤¯¤á¤¿¡£", m_name);
4167 msg_format("%^s shrugs off the attack.", m_name);
4170 else if (percentage > 50)
4172 msg_format("%s¤Ï¤¦¤á¤¤¤¿¡£", m_name);
4174 msg_format("%^s moans.", m_name);
4177 else if (percentage > 35)
4179 msg_format("%^s¤Ïµã¤¤ï¤á¤¤¤¿¡£", m_name);
4181 msg_format("%^s wails.", m_name);
4184 else if (percentage > 20)
4186 msg_format("%^s¤ÏËʤ¨¤¿¡£", m_name);
4188 msg_format("%^s howls.", m_name);
4191 else if (percentage > 10)
4193 msg_format("%s¤Ï¼å¡¹¤·¤¯¤¦¤á¤¤¤¿¡£", m_name);
4195 msg_format("%^s moans softly.", m_name);
4200 msg_format("%^s¤Ï¤«¤¹¤«¤Ë¤¦¤á¤¤¤¿¡£", m_name);
4202 msg_format("%^s sighs.", m_name);
4208 /* Dogs and Hounds */
4209 else if (strchr("CZ", r_ptr->d_char))
4212 if (percentage > 95)
4213 msg_format("%^s¤Ï¹¶·â¤Ë¸ª¤ò¤¹¤¯¤á¤¿¡£", m_name);
4214 else if (percentage > 75)
4215 msg_format("%^s¤ÏÄˤߤǤ¦¤Ê¤Ã¤¿¡£", m_name);
4216 else if (percentage > 50)
4217 msg_format("%^s¤ÏÄˤߤǥ¥ã¥ó¥¥ã¥óËʤ¨¤¿¡£", m_name);
4218 else if (percentage > 35)
4219 msg_format("%^s¤ÏÄˤߤÇÌĤ¤ï¤á¤¤¤¿¡£", m_name);
4220 else if (percentage > 20)
4221 msg_format("%^s¤Ï¶ìÄˤΤ¢¤Þ¤êÌĤ¤ï¤á¤¤¤¿¡£", m_name);
4222 else if (percentage > 10)
4223 msg_format("%^s¤Ï¶ìÄˤǤâ¤À¤¨¶ì¤·¤ó¤À¡£", m_name);
4225 msg_format("%^s¤Ï¼å¡¹¤·¤¯Ëʤ¨¤¿¡£", m_name);
4227 if (percentage > 95)
4228 msg_format("%^s shrugs off the attack.", m_name);
4229 else if (percentage > 75)
4230 msg_format("%^s snarls with pain.", m_name);
4231 else if (percentage > 50)
4232 msg_format("%^s yelps in pain.", m_name);
4233 else if (percentage > 35)
4234 msg_format("%^s howls in pain.", m_name);
4235 else if (percentage > 20)
4236 msg_format("%^s howls in agony.", m_name);
4237 else if (percentage > 10)
4238 msg_format("%^s writhes in agony.", m_name);
4240 msg_format("%^s yelps feebly.", m_name);
4245 /* One type of monsters (ignore,squeal,shriek) */
4246 else if (strchr("Xbilqrt", r_ptr->d_char))
4249 if (percentage > 95)
4250 msg_format("%^s¤Ï¹¶·â¤òµ¤¤Ë¤È¤á¤Æ¤¤¤Ê¤¤¡£", m_name);
4251 else if (percentage > 75)
4252 msg_format("%^s¤ÏÄˤߤǤ¦¤Ê¤Ã¤¿¡£", m_name);
4253 else if (percentage > 50)
4254 msg_format("%^s¤ÏÄˤߤǶ«¤ó¤À¡£", m_name);
4255 else if (percentage > 35)
4256 msg_format("%^s¤ÏÄˤߤÇÀ䶫¤·¤¿¡£", m_name);
4257 else if (percentage > 20)
4258 msg_format("%^s¤Ï¶ìÄˤΤ¢¤Þ¤êÀ䶫¤·¤¿¡£", m_name);
4259 else if (percentage > 10)
4260 msg_format("%^s¤Ï¶ìÄˤǤâ¤À¤¨¶ì¤·¤ó¤À¡£", m_name);
4262 msg_format("%^s¤Ï¼å¡¹¤·¤¯¶«¤ó¤À¡£", m_name);
4264 if (percentage > 95)
4265 msg_format("%^s ignores the attack.", m_name);
4266 else if (percentage > 75)
4267 msg_format("%^s grunts with pain.", m_name);
4268 else if (percentage > 50)
4269 msg_format("%^s squeals in pain.", m_name);
4270 else if (percentage > 35)
4271 msg_format("%^s shrieks in pain.", m_name);
4272 else if (percentage > 20)
4273 msg_format("%^s shrieks in agony.", m_name);
4274 else if (percentage > 10)
4275 msg_format("%^s writhes in agony.", m_name);
4277 msg_format("%^s cries out feebly.", m_name);
4282 /* Another type of monsters (shrug,cry,scream) */
4286 if (percentage > 95)
4287 msg_format("%^s¤Ï¹¶·â¤Ë¸ª¤ò¤¹¤¯¤á¤¿¡£", m_name);
4288 else if (percentage > 75)
4289 msg_format("%^s¤ÏÄˤߤǤ¦¤Ê¤Ã¤¿¡£", m_name);
4290 else if (percentage > 50)
4291 msg_format("%^s¤ÏÄˤߤǶ«¤ó¤À¡£", m_name);
4292 else if (percentage > 35)
4293 msg_format("%^s¤ÏÄˤߤÇÀ䶫¤·¤¿¡£", m_name);
4294 else if (percentage > 20)
4295 msg_format("%^s¤Ï¶ìÄˤΤ¢¤Þ¤êÀ䶫¤·¤¿¡£", m_name);
4296 else if (percentage > 10)
4297 msg_format("%^s¤Ï¶ìÄˤǤâ¤À¤¨¶ì¤·¤ó¤À¡£", m_name);
4299 msg_format("%^s¤Ï¼å¡¹¤·¤¯¶«¤ó¤À¡£", m_name);
4301 if (percentage > 95)
4302 msg_format("%^s shrugs off the attack.", m_name);
4303 else if (percentage > 75)
4304 msg_format("%^s grunts with pain.", m_name);
4305 else if (percentage > 50)
4306 msg_format("%^s cries out in pain.", m_name);
4307 else if (percentage > 35)
4308 msg_format("%^s screams in pain.", m_name);
4309 else if (percentage > 20)
4310 msg_format("%^s screams in agony.", m_name);
4311 else if (percentage > 10)
4312 msg_format("%^s writhes in agony.", m_name);
4314 msg_format("%^s cries out feebly.", m_name);
4322 * Learn about an "observed" resistance.
4324 void update_smart_learn(int m_idx, int what)
4326 #ifdef DRS_SMART_OPTIONS
4328 monster_type *m_ptr = &m_list[m_idx];
4330 monster_race *r_ptr = &r_info[m_ptr->r_idx];
4333 /* Not allowed to learn */
4334 if (!smart_learn) return;
4336 /* Too stupid to learn anything */
4337 if (r_ptr->flags2 & (RF2_STUPID)) return;
4339 /* Not intelligent, only learn sometimes */
4340 if (!(r_ptr->flags2 & (RF2_SMART)) && (rand_int(100) < 50)) return;
4345 /* Analyze the knowledge */
4349 if (p_ptr->resist_acid) m_ptr->smart |= (SM_RES_ACID);
4350 if (p_ptr->oppose_acid) m_ptr->smart |= (SM_OPP_ACID);
4351 if (p_ptr->immune_acid) m_ptr->smart |= (SM_IMM_ACID);
4355 if (p_ptr->resist_elec) m_ptr->smart |= (SM_RES_ELEC);
4356 if (p_ptr->oppose_elec) m_ptr->smart |= (SM_OPP_ELEC);
4357 if (p_ptr->immune_elec) m_ptr->smart |= (SM_IMM_ELEC);
4361 if (p_ptr->resist_fire) m_ptr->smart |= (SM_RES_FIRE);
4362 if (p_ptr->oppose_fire) m_ptr->smart |= (SM_OPP_FIRE);
4363 if (p_ptr->immune_fire) m_ptr->smart |= (SM_IMM_FIRE);
4367 if (p_ptr->resist_cold) m_ptr->smart |= (SM_RES_COLD);
4368 if (p_ptr->oppose_cold) m_ptr->smart |= (SM_OPP_COLD);
4369 if (p_ptr->immune_cold) m_ptr->smart |= (SM_IMM_COLD);
4373 if (p_ptr->resist_pois) m_ptr->smart |= (SM_RES_POIS);
4374 if (p_ptr->oppose_pois) m_ptr->smart |= (SM_OPP_POIS);
4379 if (p_ptr->resist_neth) m_ptr->smart |= (SM_RES_NETH);
4383 if (p_ptr->resist_lite) m_ptr->smart |= (SM_RES_LITE);
4387 if (p_ptr->resist_dark) m_ptr->smart |= (SM_RES_DARK);
4391 if (p_ptr->resist_fear) m_ptr->smart |= (SM_RES_FEAR);
4395 if (p_ptr->resist_conf) m_ptr->smart |= (SM_RES_CONF);
4399 if (p_ptr->resist_chaos) m_ptr->smart |= (SM_RES_CHAOS);
4403 if (p_ptr->resist_disen) m_ptr->smart |= (SM_RES_DISEN);
4407 if (p_ptr->resist_blind) m_ptr->smart |= (SM_RES_BLIND);
4411 if (p_ptr->resist_nexus) m_ptr->smart |= (SM_RES_NEXUS);
4415 if (p_ptr->resist_sound) m_ptr->smart |= (SM_RES_SOUND);
4419 if (p_ptr->resist_shard) m_ptr->smart |= (SM_RES_SHARD);
4423 if (p_ptr->free_act) m_ptr->smart |= (SM_IMM_FREE);
4427 if (!p_ptr->msp) m_ptr->smart |= (SM_IMM_MANA);
4431 if (p_ptr->reflect) m_ptr-> smart |= (SM_IMM_REFLECT);
4435 #endif /* DRS_SMART_OPTIONS */
4441 * Place the player in the dungeon XXX XXX
4443 bool player_place(int y, int x)
4445 /* Paranoia XXX XXX */
4446 if (cave[y][x].m_idx != 0) return FALSE;
4448 /* Save player location */
4458 * Drop all items carried by a monster
4460 void monster_drop_carried_objects(monster_type *m_ptr)
4462 s16b this_o_idx, next_o_idx = 0;
4468 /* Drop objects being carried */
4469 for (this_o_idx = m_ptr->hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
4471 /* Acquire object */
4472 o_ptr = &o_list[this_o_idx];
4474 /* Acquire next object */
4475 next_o_idx = o_ptr->next_o_idx;
4478 o_ptr->held_m_idx = 0;
4480 /* Get local object */
4483 /* Copy the object */
4484 object_copy(q_ptr, o_ptr);
4486 /* Delete the object */
4487 delete_object_idx(this_o_idx);
4490 (void)drop_near(q_ptr, -1, m_ptr->fy, m_ptr->fx);
4493 /* Forget objects */
4494 m_ptr->hold_o_idx = 0;