3 /* Purpose: misc code for monsters */
6 * Copyright (c) 1989 James E. Wilson, Robert A. Koeneke
8 * This software may be copied and distributed for educational, research, and
9 * not for profit purposes provided that this copyright and statement are
10 * included in all such copies.
15 #define HORDE_NOGOOD 0x01
16 #define HORDE_NOEVIL 0x02
21 cptr horror_desc[MAX_SAN_HORROR] =
75 cptr funny_desc[MAX_SAN_FUNNY] =
90 "¥Õ¥¡¥ó¥¿¥¹¥Æ¥£¥Ã¥¯¤Ê",
135 cptr funny_comments[MAX_SAN_COMMENT] =
156 * Set the target of counter attack
158 void set_target(monster_type *m_ptr, int y, int x)
165 * Reset the target of counter attack
167 void reset_target(monster_type *m_ptr)
169 set_target(m_ptr, 0, 0);
173 * Delete a monster by index.
175 * When a monster is deleted, all of its objects are deleted.
177 void delete_monster_idx(int i)
181 monster_type *m_ptr = &m_list[i];
183 monster_race *r_ptr = &r_info[m_ptr->r_idx];
185 s16b this_o_idx, next_o_idx = 0;
193 /* Hack -- Reduce the racial counter */
194 if (m_ptr->mflag2 & MFLAG_CHAMELEON)
196 if (r_ptr->flags1 & RF1_UNIQUE)
197 r_info[MON_CHAMELEON_K].cur_num--;
199 r_info[MON_CHAMELEON].cur_num--;
206 /* Hack -- count the number of "reproducers" */
207 if (r_ptr->flags2 & (RF2_MULTIPLY)) num_repro--;
210 /* Hack -- remove target monster */
211 if (i == target_who) target_who = 0;
213 /* Hack -- remove tracked monster */
214 if (i == p_ptr->health_who) health_track(0);
216 if (pet_t_m_idx == i ) pet_t_m_idx = 0;
217 if (riding_t_m_idx == i) riding_t_m_idx = 0;
218 if (p_ptr->riding == i) p_ptr->riding = 0;
220 /* Monster is gone */
221 cave[y][x].m_idx = 0;
225 for (this_o_idx = m_ptr->hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
230 o_ptr = &o_list[this_o_idx];
232 /* Acquire next object */
233 next_o_idx = o_ptr->next_o_idx;
235 /* Hack -- efficiency */
236 o_ptr->held_m_idx = 0;
238 /* Delete the object */
239 delete_object_idx(this_o_idx);
243 /* Wipe the Monster */
244 (void)WIPE(m_ptr, monster_type);
255 * Delete the monster, if any, at a given location
257 void delete_monster(int y, int x)
262 if (!in_bounds(y, x)) return;
267 /* Delete the monster (if any) */
268 if (c_ptr->m_idx) delete_monster_idx(c_ptr->m_idx);
273 * Move an object from index i1 to index i2 in the object list
275 static void compact_monsters_aux(int i1, int i2)
283 s16b this_o_idx, next_o_idx = 0;
287 if (i1 == i2) return;
300 /* Update the cave */
303 /* Repair objects being carried by monster */
304 for (this_o_idx = m_ptr->hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
309 o_ptr = &o_list[this_o_idx];
311 /* Acquire next object */
312 next_o_idx = o_ptr->next_o_idx;
314 /* Reset monster pointer */
315 o_ptr->held_m_idx = i2;
318 /* Hack -- Update the target */
319 if (target_who == i1) target_who = i2;
321 /* Hack -- Update the target */
322 if (pet_t_m_idx == i1) pet_t_m_idx = i2;
323 if (riding_t_m_idx == i1) riding_t_m_idx = i2;
325 /* Hack -- Update the riding */
326 if (p_ptr->riding == i1) p_ptr->riding = i2;
328 /* Hack -- Update the health bar */
329 if (p_ptr->health_who == i1) health_track(i2);
332 COPY(&m_list[i2], &m_list[i1], monster_type);
335 (void)WIPE(&m_list[i1], monster_type);
341 * Compact and Reorder the monster list
343 * This function can be very dangerous, use with caution!
345 * When actually "compacting" monsters, we base the saving throw
346 * on a combination of monster level, distance from player, and
347 * current "desperation".
349 * After "compacting" (if needed), we "reorder" the monsters into a more
350 * compact order, and we reset the allocation info, and the "live" array.
352 void compact_monsters(int size)
355 int cur_lev, cur_dis, chance;
357 /* Message (only if compacting) */
359 if (size) msg_print("¥â¥ó¥¹¥¿¡¼¾ðÊó¤ò°µ½Ì¤·¤Æ¤¤¤Þ¤¹...");
361 if (size) msg_print("Compacting monsters...");
365 /* Compact at least 'size' objects */
366 for (num = 0, cnt = 1; num < size; cnt++)
368 /* Get more vicious each iteration */
371 /* Get closer each iteration */
372 cur_dis = 5 * (20 - cnt);
374 /* Check all the monsters */
375 for (i = 1; i < m_max; i++)
377 monster_type *m_ptr = &m_list[i];
379 monster_race *r_ptr = &r_info[m_ptr->r_idx];
381 /* Paranoia -- skip "dead" monsters */
382 if (!m_ptr->r_idx) continue;
384 /* Hack -- High level monsters start out "immune" */
385 if (r_ptr->level > cur_lev) continue;
387 if (i == p_ptr->riding) continue;
389 /* Ignore nearby monsters */
390 if ((cur_dis > 0) && (m_ptr->cdis < cur_dis)) continue;
392 /* Saving throw chance */
395 /* Only compact "Quest" Monsters in emergencies */
396 if ((r_ptr->flags1 & (RF1_QUESTOR)) && (cnt < 1000)) chance = 100;
398 /* Try not to compact Unique Monsters */
399 if (r_ptr->flags1 & (RF1_UNIQUE)) chance = 100;
401 /* All monsters get a saving throw */
402 if (randint0(100) < chance) continue;
404 /* Delete the monster */
405 delete_monster_idx(i);
407 /* Count the monster */
413 /* Excise dead monsters (backwards!) */
414 for (i = m_max - 1; i >= 1; i--)
416 /* Get the i'th monster */
417 monster_type *m_ptr = &m_list[i];
419 /* Skip real monsters */
420 if (m_ptr->r_idx) continue;
422 /* Move last monster into open hole */
423 compact_monsters_aux(m_max - 1, i);
425 /* Compress "m_max" */
432 * Delete/Remove all the monsters when the player leaves the level
434 * This is an efficient method of simulating multiple calls to the
435 * "delete_monster()" function, with no visual effects.
437 void wipe_m_list(void)
441 /* Hack -- if Banor or Lupart dies, stay another dead */
442 if (!r_info[MON_BANORLUPART].max_num)
444 if (r_info[MON_BANOR].max_num)
446 r_info[MON_BANOR].max_num = 0;
447 r_info[MON_BANOR].r_pkills++;
448 if (r_info[MON_BANOR].r_tkills < MAX_SHORT) r_info[MON_BANOR].r_tkills++;
450 if (r_info[MON_LUPART].max_num)
452 r_info[MON_LUPART].max_num = 0;
453 r_info[MON_LUPART].r_pkills++;
454 if (r_info[MON_LUPART].r_tkills < MAX_SHORT) r_info[MON_LUPART].r_tkills++;
458 /* Delete all the monsters */
459 for (i = m_max - 1; i >= 1; i--)
461 monster_type *m_ptr = &m_list[i];
463 monster_race *r_ptr = &r_info[m_ptr->r_idx];
465 /* Skip dead monsters */
466 if (!m_ptr->r_idx) continue;
468 /* Mega-Hack -- preserve Unique's XXX XXX XXX */
470 /* Hack -- Reduce the racial counter */
471 if (m_ptr->mflag2 & MFLAG_CHAMELEON)
473 if (r_ptr->flags1 & RF1_UNIQUE)
474 r_info[MON_CHAMELEON_K].cur_num = 0;
476 r_info[MON_CHAMELEON].cur_num = 0;
481 /* Monster is gone */
482 cave[m_ptr->fy][m_ptr->fx].m_idx = 0;
484 /* Wipe the Monster */
485 (void)WIPE(m_ptr, monster_type);
495 /* Hack -- reset "reproducer" count */
498 /* Hack -- no more target */
503 /* Hack -- no more tracking */
509 * Acquires and returns the index of a "free" monster.
511 * This routine should almost never fail, but it *can* happen.
518 /* Normal allocation */
519 if (m_max < max_m_idx)
521 /* Access the next hole */
524 /* Expand the array */
530 /* Return the index */
535 /* Recycle dead monsters */
536 for (i = 1; i < m_max; i++)
540 /* Acquire monster */
543 /* Skip live monsters */
544 if (m_ptr->r_idx) continue;
549 /* Use this monster */
554 /* Warn the player (except during dungeon creation) */
556 if (character_dungeon) msg_print("¥â¥ó¥¹¥¿¡¼¤¬Â¿¤¹¤®¤ë¡ª");
558 if (character_dungeon) msg_print("Too many monsters!");
562 /* Try not to crash */
570 * Hack -- the "type" of the current "summon specific"
572 static int summon_specific_type = 0;
576 * Hack -- the index of the summoning monster
578 static int summon_specific_who = -1;
582 * Hack -- the hostility of the summoned monster
584 static int summon_specific_hostile = TRUE;
586 static bool summon_unique_okay = FALSE;
589 static bool summon_specific_aux(int r_idx)
591 monster_race *r_ptr = &r_info[r_idx];
594 /* Check our requirements */
595 switch (summon_specific_type)
599 okay = (r_ptr->d_char == 'a');
605 okay = (r_ptr->d_char == 'S');
611 okay = ((r_ptr->d_char == 'C') || (r_ptr->d_char == 'Z'));
617 okay = (r_ptr->d_char == 'M');
623 okay = (r_ptr->d_char == 'A' && ((r_ptr->flags3 & RF3_EVIL) || (r_ptr->flags3 & RF3_GOOD)));
629 okay = (r_ptr->flags3 & RF3_DEMON);
635 okay = (r_ptr->flags3 & RF3_UNDEAD);
641 okay = (r_ptr->flags3 & RF3_DRAGON);
645 case SUMMON_HI_UNDEAD:
647 okay = ((r_ptr->d_char == 'L') ||
648 (r_ptr->d_char == 'V') ||
649 (r_ptr->d_char == 'W'));
653 case SUMMON_HI_DRAGON:
655 okay = (r_ptr->d_char == 'D');
659 case SUMMON_HI_DEMON:
661 okay = (((r_ptr->d_char == 'U') ||
662 (r_ptr->d_char == 'H') ||
663 (r_ptr->d_char == 'B')) &&
664 (r_ptr->flags3 & RF3_DEMON)) ? TRUE : FALSE;
668 case SUMMON_AMBERITES:
670 okay = (r_ptr->flags3 & (RF3_AMBERITE)) ? TRUE : FALSE;
676 okay = (r_ptr->flags1 & (RF1_UNIQUE)) ? TRUE : FALSE;
680 case SUMMON_BIZARRE1:
682 okay = (r_ptr->d_char == 'm');
685 case SUMMON_BIZARRE2:
687 okay = (r_ptr->d_char == 'b');
690 case SUMMON_BIZARRE3:
692 okay = (r_ptr->d_char == 'Q');
696 case SUMMON_BIZARRE4:
698 okay = (r_ptr->d_char == 'v');
702 case SUMMON_BIZARRE5:
704 okay = (r_ptr->d_char == '$');
708 case SUMMON_BIZARRE6:
710 okay = ((r_ptr->d_char == '!') ||
711 (r_ptr->d_char == '?') ||
712 (r_ptr->d_char == '=') ||
713 (r_ptr->d_char == '$') ||
714 (r_ptr->d_char == '|'));
720 okay = (r_ptr->d_char == 'g');
726 okay = ((r_ptr->d_char == 'U') &&
727 (r_ptr->flags4 & RF4_ROCKET));
734 okay = ((r_ptr->d_char == summon_kin_type) && (r_idx != MON_HAGURE));
740 okay = (r_idx == MON_DAWN);
746 okay = (r_ptr->flags3 & (RF3_ANIMAL));
750 case SUMMON_ANIMAL_RANGER:
752 okay = ((r_ptr->flags3 & (RF3_ANIMAL)) &&
753 (strchr("abcflqrwBCHIJKMRS", r_ptr->d_char)) &&
754 !(r_ptr->flags3 & (RF3_DRAGON)) &&
755 !(r_ptr->flags3 & (RF3_EVIL)) &&
756 !(r_ptr->flags3 & (RF3_UNDEAD)) &&
757 !(r_ptr->flags3 & (RF3_DEMON)) &&
758 !(r_ptr->flags2 & (RF2_MULTIPLY)) &&
759 !(r_ptr->flags4 || r_ptr->flags5 || r_ptr->flags6));
763 case SUMMON_HI_DRAGON_LIVING:
765 okay = ((r_ptr->d_char == 'D') &&
766 !(r_ptr->flags3 & (RF3_DEMON | RF3_UNDEAD | RF3_NONLIVING)));
772 okay = (!(r_ptr->flags3 & (RF3_DEMON | RF3_UNDEAD | RF3_NONLIVING)));
778 okay = (r_idx == MON_PHANTOM_B || r_idx == MON_PHANTOM_W);
782 case SUMMON_BLUE_HORROR:
784 okay = (r_idx == MON_BLUE_HORROR);
788 case SUMMON_ELEMENTAL:
790 okay = (r_ptr->d_char == 'E');
796 okay = (r_ptr->d_char == 'v');
802 okay = (r_ptr->d_char == 'H');
808 okay = (r_ptr->d_char == 'B');
812 case SUMMON_KAMIKAZE:
815 for (i = 0; i < 4; i++)
816 if (r_ptr->blow[i].method == RBM_EXPLODE) okay = TRUE;
820 case SUMMON_KAMIKAZE_LIVING:
824 for (i = 0; i < 4; i++)
825 if (r_ptr->blow[i].method == RBM_EXPLODE) okay = TRUE;
826 okay = (okay && (!(r_ptr->flags3 & (RF3_DEMON | RF3_UNDEAD | RF3_NONLIVING))));
832 okay = (r_idx == MON_MANES);
838 okay = (r_idx == MON_LOUSE);
842 case SUMMON_GUARDIANS:
844 okay = (r_ptr->flags7 & RF7_GUARDIAN);
850 /* Since okay is int, "return (okay);" is not correct. */
851 return (bool)(okay ? TRUE : FALSE);
855 static bool chameleon_change = FALSE;
859 * Some dungeon types restrict the possible monsters.
860 * Return TRUE is the monster is OK and FALSE otherwise
862 static bool restrict_monster_to_dungeon(int r_idx)
864 dungeon_info_type *d_ptr = &d_info[dungeon_type];
865 monster_race *r_ptr = &r_info[r_idx];
868 if (d_ptr->flags1 & DF1_CHAMELEON)
870 if (chameleon_change) return TRUE;
872 if (d_ptr->flags1 & DF1_NO_MAGIC)
874 if (r_idx == MON_CHAMELEON) return TRUE;
875 if (r_ptr->freq_spell && !(r_ptr->flags4 & RF4_NOMAGIC_MASK) && !(r_ptr->flags5 & RF5_NOMAGIC_MASK) && !(r_ptr->flags6 & RF6_NOMAGIC_MASK))
879 if (d_ptr->flags1 & DF1_NO_MELEE)
881 if (r_idx == MON_CHAMELEON) return TRUE;
882 if (!(r_ptr->flags4 & (RF4_BOLT_MASK | RF4_BEAM_MASK | RF4_BALL_MASK)) &&
883 !(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)) &&
884 !(r_ptr->flags6 & (RF6_BOLT_MASK | RF6_BEAM_MASK | RF6_BALL_MASK)))
888 if (d_ptr->flags1 & DF1_BEGINNER)
890 if (r_ptr->level > dun_level)
895 if (d_ptr->special_div == 64) return TRUE;
896 if (summon_specific_type && !(d_ptr->flags1 & DF1_CHAMELEON)) return TRUE;
898 if(d_ptr->mode == DUNGEON_MODE_AND)
902 if((d_ptr->mflags1 & r_ptr->flags1) != d_ptr->mflags1)
907 if((d_ptr->mflags2 & r_ptr->flags2) != d_ptr->mflags2)
912 if((d_ptr->mflags3 & r_ptr->flags3) != d_ptr->mflags3)
917 if((d_ptr->mflags4 & r_ptr->flags4) != d_ptr->mflags4)
922 if((d_ptr->mflags5 & r_ptr->flags5) != d_ptr->mflags5)
927 if((d_ptr->mflags6 & r_ptr->flags6) != d_ptr->mflags6)
932 if((d_ptr->mflags7 & r_ptr->flags7) != d_ptr->mflags7)
937 if((d_ptr->mflags8 & r_ptr->flags8) != d_ptr->mflags8)
942 if((d_ptr->mflags9 & r_ptr->flags9) != d_ptr->mflags9)
945 for(a = 0; a < 5; a++)
946 if(d_ptr->r_char[a] && (d_ptr->r_char[a] != r_ptr->d_char)) return FALSE;
948 else if(d_ptr->mode == DUNGEON_MODE_NAND)
950 byte ok[9 + 5], i = 0, j = 0;
955 if(d_ptr->mflags1 & r_ptr->flags1)
961 if(d_ptr->mflags2 & r_ptr->flags2)
967 if(d_ptr->mflags3 & r_ptr->flags3)
973 if(d_ptr->mflags4 & r_ptr->flags4)
979 if(d_ptr->mflags5 & r_ptr->flags5)
985 if(d_ptr->mflags6 & r_ptr->flags6)
991 if(d_ptr->mflags7 & r_ptr->flags7)
997 if(d_ptr->mflags8 & r_ptr->flags8)
1003 if(d_ptr->mflags9 & r_ptr->flags9)
1007 for(a = 0; a < 5; a++)
1009 if(d_ptr->r_char[a])
1012 if (d_ptr->r_char[a] != r_ptr->d_char) ok[9 + a] = 1;
1016 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];
1018 if(i == j) return FALSE;
1020 else if(d_ptr->mode == DUNGEON_MODE_OR)
1025 for(i = 0; i < 32; i++)
1027 flag = d_ptr->mflags1 & (1 << i);
1028 if(r_ptr->flags1 & flag) ok = TRUE;
1030 flag = d_ptr->mflags2 & (1 << i);
1031 if(r_ptr->flags2 & flag) ok = TRUE;
1033 flag = d_ptr->mflags3 & (1 << i);
1034 if(r_ptr->flags3 & flag) ok = TRUE;
1036 flag = d_ptr->mflags4 & (1 << i);
1037 if(r_ptr->flags4 & flag) ok = TRUE;
1039 flag = d_ptr->mflags5 & (1 << i);
1040 if(r_ptr->flags5 & flag) ok = TRUE;
1042 flag = d_ptr->mflags6 & (1 << i);
1043 if(r_ptr->flags6 & flag) ok = TRUE;
1045 flag = d_ptr->mflags7 & (1 << i);
1046 if(r_ptr->flags7 & flag) ok = TRUE;
1048 flag = d_ptr->mflags8 & (1 << i);
1049 if(r_ptr->flags8 & flag) ok = TRUE;
1051 flag = d_ptr->mflags9 & (1 << i);
1052 if(r_ptr->flags9 & flag) ok = TRUE;
1054 for(a = 0; a < 5; a++)
1055 if(d_ptr->r_char[a] == r_ptr->d_char) ok = TRUE;
1059 else if(d_ptr->mode == DUNGEON_MODE_NOR)
1064 for(i = 0; i < 32; i++)
1066 flag = d_ptr->mflags1 & (1 << i);
1067 if(r_ptr->flags1 & flag) ok = FALSE;
1069 flag = d_ptr->mflags2 & (1 << i);
1070 if(r_ptr->flags2 & flag) ok = FALSE;
1072 flag = d_ptr->mflags3 & (1 << i);
1073 if(r_ptr->flags3 & flag) ok = FALSE;
1075 flag = d_ptr->mflags4 & (1 << i);
1076 if(r_ptr->flags4 & flag) ok = FALSE;
1078 flag = d_ptr->mflags5 & (1 << i);
1079 if(r_ptr->flags5 & flag) ok = FALSE;
1081 flag = d_ptr->mflags6 & (1 << i);
1082 if(r_ptr->flags6 & flag) ok = FALSE;
1084 flag = d_ptr->mflags7 & (1 << i);
1085 if(r_ptr->flags7 & flag) ok = FALSE;
1087 flag = d_ptr->mflags8 & (1 << i);
1088 if(r_ptr->flags8 & flag) ok = FALSE;
1090 flag = d_ptr->mflags9 & (1 << i);
1091 if(r_ptr->flags9 & flag) ok = FALSE;
1093 for(a = 0; a < 5; a++)
1094 if(d_ptr->r_char[a] == r_ptr->d_char) ok = FALSE;
1102 * Apply a "monster restriction function" to the "monster allocation table"
1104 errr get_mon_num_prep(monster_hook_type monster_hook,
1105 monster_hook_type monster_hook2)
1109 /* Todo: Check the hooks for non-changes */
1111 /* Set the new hooks */
1112 get_mon_num_hook = monster_hook;
1113 get_mon_num2_hook = monster_hook2;
1115 /* Scan the allocation table */
1116 for (i = 0; i < alloc_race_size; i++)
1118 monster_race *r_ptr;
1121 alloc_entry *entry = &alloc_race_table[i];
1124 r_ptr = &r_info[entry->index];
1126 /* Skip monsters which don't pass the restriction */
1127 if ((get_mon_num_hook && !((*get_mon_num_hook)(entry->index))) ||
1128 (get_mon_num2_hook && !((*get_mon_num2_hook)(entry->index))))
1131 if (!p_ptr->inside_battle && !chameleon_change &&
1132 summon_specific_type != SUMMON_GUARDIANS)
1134 /* Hack -- don't create questors */
1135 if (r_ptr->flags1 & RF1_QUESTOR)
1138 if (r_ptr->flags7 & RF7_GUARDIAN)
1141 /* Depth Monsters never appear out of depth */
1142 if ((r_ptr->flags1 & (RF1_FORCE_DEPTH)) &&
1143 (r_ptr->level > dun_level))
1147 /* Accept this monster */
1148 entry->prob2 = entry->prob1;
1150 if (dun_level && (!p_ptr->inside_quest || p_ptr->inside_quest < MIN_RANDOM_QUEST) && !restrict_monster_to_dungeon(entry->index) && !p_ptr->inside_battle)
1152 int hoge = entry->prob2 * d_info[dungeon_type].special_div;
1153 entry->prob2 = hoge / 64;
1154 if (randint0(64) < (hoge & 0x3f)) entry->prob2++;
1163 static int mysqrt(int n)
1201 * Choose a monster race that seems "appropriate" to the given level
1203 * This function uses the "prob2" field of the "monster allocation table",
1204 * and various local information, to calculate the "prob3" field of the
1205 * same table, which is then used to choose an "appropriate" monster, in
1206 * a relatively efficient manner.
1208 * Note that "town" monsters will *only* be created in the town, and
1209 * "normal" monsters will *never* be created in the town, unless the
1210 * "level" is "modified", for example, by polymorph or summoning.
1212 * There is a small chance (1/50) of "boosting" the given depth by
1213 * a small amount (up to four levels), except in the town.
1215 * It is (slightly) more likely to acquire a monster of the given level
1216 * than one of a lower level. This is done by choosing several monsters
1217 * appropriate to the given level and keeping the "hardest" one.
1219 * Note that if no monsters are "appropriate", then this function will
1220 * fail, and return zero, but this should *almost* never happen.
1222 s16b get_mon_num(int level)
1230 monster_race *r_ptr;
1232 alloc_entry *table = alloc_race_table;
1234 int pls_kakuritu, pls_level;
1235 int hoge=mysqrt(level*10000L);
1237 if (level > MAX_DEPTH - 1) level = MAX_DEPTH - 1;
1239 if ((dungeon_turn > hoge*10000L) && !level)
1241 pls_kakuritu = MAX(2, NASTY_MON-((dungeon_turn/50000L-hoge/10)));
1242 pls_level = MIN(8,3 + dungeon_turn/400000L-hoge/40);
1246 pls_kakuritu = NASTY_MON;
1250 if (d_info[dungeon_type].flags1 & DF1_MAZE)
1252 pls_kakuritu = MIN(pls_kakuritu/2, pls_kakuritu-10);
1253 if (pls_kakuritu < 2) pls_kakuritu = 2;
1258 /* Boost the level */
1259 if ((level > 0) && !p_ptr->inside_battle && !(d_info[dungeon_type].flags1 & DF1_BEGINNER))
1261 /* Nightmare mode allows more out-of depth monsters */
1262 if (ironman_nightmare && !randint0(pls_kakuritu))
1264 /* What a bizarre calculation */
1265 level = 1 + (level * MAX_DEPTH / randint1(MAX_DEPTH));
1269 /* Occasional "nasty" monster */
1270 if (!randint0(pls_kakuritu))
1272 /* Pick a level bonus */
1273 int d = MIN(5, level/10) + pls_level;
1275 /* Boost the level */
1279 /* Occasional "nasty" monster */
1280 if (!randint0(pls_kakuritu))
1282 /* Pick a level bonus */
1283 int d = MIN(5, level/10) + pls_level;
1285 /* Boost the level */
1295 /* Process probabilities */
1296 for (i = 0; i < alloc_race_size; i++)
1298 /* Monsters are sorted by depth */
1299 if (table[i].level > level) break;
1304 /* Access the "r_idx" of the chosen monster */
1305 r_idx = table[i].index;
1307 /* Access the actual race */
1308 r_ptr = &r_info[r_idx];
1310 if (!p_ptr->inside_battle && !chameleon_change)
1312 /* Hack -- "unique" monsters must be "unique" */
1313 if (((r_ptr->flags1 & (RF1_UNIQUE)) ||
1314 (r_ptr->flags7 & (RF7_UNIQUE_7))) &&
1315 (r_ptr->cur_num >= r_ptr->max_num))
1320 if ((r_ptr->flags7 & (RF7_UNIQUE2)) &&
1321 (r_ptr->cur_num >= 1))
1326 if (r_idx == MON_BANORLUPART)
1328 if (r_info[MON_BANOR].cur_num > 0) continue;
1329 if (r_info[MON_LUPART].cur_num > 0) continue;
1332 else if (!p_ptr->inside_battle && chameleon_change
1333 && (r_ptr->flags1 & (RF1_UNIQUE)))
1335 /* Hack -- Chameleon Lord must be "unique" */
1336 if (r_info[MON_CHAMELEON_K].cur_num >= r_ptr->max_num)
1341 table[i].prob3 = table[i].prob2;
1344 total += table[i].prob3;
1347 /* No legal monsters */
1348 if (total <= 0) return (0);
1351 /* Pick a monster */
1352 value = randint0(total);
1354 /* Find the monster */
1355 for (i = 0; i < alloc_race_size; i++)
1357 /* Found the entry */
1358 if (value < table[i].prob3) break;
1361 value = value - table[i].prob3;
1368 /* Try for a "harder" monster once (50%) or twice (10%) */
1374 /* Pick a monster */
1375 value = randint0(total);
1377 /* Find the monster */
1378 for (i = 0; i < alloc_race_size; i++)
1380 /* Found the entry */
1381 if (value < table[i].prob3) break;
1384 value = value - table[i].prob3;
1387 /* Keep the "best" one */
1388 if (table[i].level < table[j].level) i = j;
1391 /* Try for a "harder" monster twice (10%) */
1397 /* Pick a monster */
1398 value = randint0(total);
1400 /* Find the monster */
1401 for (i = 0; i < alloc_race_size; i++)
1403 /* Found the entry */
1404 if (value < table[i].prob3) break;
1407 value = value - table[i].prob3;
1410 /* Keep the "best" one */
1411 if (table[i].level < table[j].level) i = j;
1415 return (table[i].index);
1423 * Build a string describing a monster in some way.
1425 * We can correctly describe monsters based on their visibility.
1426 * We can force all monsters to be treated as visible or invisible.
1427 * We can build nominatives, objectives, possessives, or reflexives.
1428 * We can selectively pronominalize hidden, visible, or all monsters.
1429 * We can use definite or indefinite descriptions for hidden monsters.
1430 * We can use definite or indefinite descriptions for visible monsters.
1432 * Pronominalization involves the gender whenever possible and allowed,
1433 * so that by cleverly requesting pronominalization / visibility, you
1434 * can get messages like "You hit someone. She screams in agony!".
1436 * Reflexives are acquired by requesting Objective plus Possessive.
1438 * If no m_ptr arg is given (?), the monster is assumed to be hidden,
1439 * unless the "Assume Visible" mode is requested.
1441 * If no r_ptr arg is given, it is extracted from m_ptr and r_info
1442 * If neither m_ptr nor r_ptr is given, the monster is assumed to
1443 * be neuter, singular, and hidden (unless "Assume Visible" is set),
1444 * in which case you may be in trouble... :-)
1446 * I am assuming that no monster name is more than 70 characters long,
1447 * so that "char desc[80];" is sufficiently large for any result.
1450 * 0x01 --> Objective (or Reflexive)
1451 * 0x02 --> Possessive (or Reflexive)
1452 * 0x04 --> Use indefinites for hidden monsters ("something")
1453 * 0x08 --> Use indefinites for visible monsters ("a kobold")
1454 * 0x10 --> Pronominalize hidden monsters
1455 * 0x20 --> Pronominalize visible monsters
1456 * 0x40 --> Assume the monster is hidden
1457 * 0x80 --> Assume the monster is visible
1460 * 0x00 --> Full nominative name ("the kobold") or "it"
1461 * 0x04 --> Full nominative name ("the kobold") or "something"
1462 * 0x80 --> Genocide resistance name ("the kobold")
1463 * 0x88 --> Killing name ("a kobold")
1464 * 0x22 --> Possessive, genderized if visable ("his") or "its"
1465 * 0x23 --> Reflexive, genderized if visable ("himself") or "itself"
1467 void monster_desc(char *desc, monster_type *m_ptr, int mode)
1470 monster_race *r_ptr;
1474 char silly_name[1024];
1478 if (m_ptr->mflag2 & MFLAG_KAGE) r_ptr = &r_info[MON_KAGE];
1479 else r_ptr = &r_info[m_ptr->r_idx];
1481 if ((mode & 0x100) && (m_ptr->mflag2 & MFLAG_CHAMELEON))
1483 if (r_ptr->flags1 & RF1_UNIQUE) name = (r_name + r_info[MON_CHAMELEON_K].name);
1484 else name = (r_name + r_info[MON_CHAMELEON].name);
1486 else name = (r_name + r_ptr->name);
1488 /* Are we hallucinating? (Idea from Nethack...) */
1494 if (!get_rnd_line("silly_j.txt", m_ptr->r_idx, silly_name))
1496 if (!get_rnd_line("silly.txt", m_ptr->r_idx, silly_name))
1504 monster_race *hallu_race;
1508 hallu_race = &r_info[randint1(max_r_idx - 1)];
1510 while (hallu_race->flags1 & RF1_UNIQUE);
1512 strcpy(silly_name, (r_name + hallu_race->name));
1515 /* Better not strcpy it, or we could corrupt r_info... */
1519 /* Can we "see" it (exists + forced, or visible + not unforced) */
1520 seen = (m_ptr && ((mode & 0x80) || (!(mode & 0x40) && m_ptr->ml)));
1522 /* Sexed Pronouns (seen and allowed, or unseen and allowed) */
1523 pron = (m_ptr && ((seen && (mode & 0x20)) || (!seen && (mode & 0x10))));
1526 /* First, try using pronouns, or describing hidden monsters */
1529 /* an encoding of the monster "sex" */
1532 /* Extract the gender (if applicable) */
1533 if (r_ptr->flags1 & (RF1_FEMALE)) kind = 0x20;
1534 else if (r_ptr->flags1 & (RF1_MALE)) kind = 0x10;
1536 /* Ignore the gender (if desired) */
1537 if (!m_ptr || !pron) kind = 0x00;
1540 /* Assume simple result */
1548 /* Brute force: split on the possibilities */
1549 switch (kind + (mode & 0x07))
1551 /* Neuter, or unknown */
1553 case 0x00: res = "²¿¤«"; break;
1554 case 0x01: res = "²¿¤«"; break;
1555 case 0x02: res = "²¿¤«¤Î"; break;
1556 case 0x03: res = "²¿¤«¼«¿È"; break;
1557 case 0x04: res = "²¿¤«"; break;
1558 case 0x05: res = "²¿¤«"; break;
1559 case 0x06: res = "²¿¤«"; break;
1560 case 0x07: res = "¤½¤ì¼«¿È"; break;
1562 case 0x00: res = "it"; break;
1563 case 0x01: res = "it"; break;
1564 case 0x02: res = "its"; break;
1565 case 0x03: res = "itself"; break;
1566 case 0x04: res = "something"; break;
1567 case 0x05: res = "something"; break;
1568 case 0x06: res = "something's"; break;
1569 case 0x07: res = "itself"; break;
1573 /* Male (assume human if vague) */
1575 case 0x10: res = "Èà"; break;
1576 case 0x11: res = "Èà"; break;
1577 case 0x12: res = "Èà¤Î"; break;
1578 case 0x13: res = "È༫¿È"; break;
1579 case 0x14: res = "狼"; break;
1580 case 0x15: res = "狼"; break;
1581 case 0x16: res = "狼¤Î"; break;
1582 case 0x17: res = "È༫¿È"; break;
1584 case 0x10: res = "he"; break;
1585 case 0x11: res = "him"; break;
1586 case 0x12: res = "his"; break;
1587 case 0x13: res = "himself"; break;
1588 case 0x14: res = "someone"; break;
1589 case 0x15: res = "someone"; break;
1590 case 0x16: res = "someone's"; break;
1591 case 0x17: res = "himself"; break;
1595 /* Female (assume human if vague) */
1597 case 0x20: res = "Èà½÷"; break;
1598 case 0x21: res = "Èà½÷"; break;
1599 case 0x22: res = "Èà½÷¤Î"; break;
1600 case 0x23: res = "Èà½÷¼«¿È"; break;
1601 case 0x24: res = "狼"; break;
1602 case 0x25: res = "狼"; break;
1603 case 0x26: res = "狼¤Î"; break;
1604 case 0x27: res = "Èà½÷¼«¿È"; break;
1606 case 0x20: res = "she"; break;
1607 case 0x21: res = "her"; break;
1608 case 0x22: res = "her"; break;
1609 case 0x23: res = "herself"; break;
1610 case 0x24: res = "someone"; break;
1611 case 0x25: res = "someone"; break;
1612 case 0x26: res = "someone's"; break;
1613 case 0x27: res = "herself"; break;
1618 /* Copy the result */
1619 (void)strcpy(desc, res);
1623 /* Handle visible monsters, "reflexive" request */
1624 else if ((mode & 0x02) && (mode & 0x01))
1626 /* The monster is visible, so use its gender */
1628 if (r_ptr->flags1 & (RF1_FEMALE)) strcpy(desc, "Èà½÷¼«¿È");
1629 else if (r_ptr->flags1 & (RF1_MALE)) strcpy(desc, "È༫¿È");
1630 else strcpy(desc, "¤½¤ì¼«¿È");
1632 if (r_ptr->flags1 & RF1_FEMALE) strcpy(desc, "herself");
1633 else if (r_ptr->flags1 & RF1_MALE) strcpy(desc, "himself");
1634 else strcpy(desc, "itself");
1640 /* Handle all other visible monster requests */
1643 /* It could be a Unique */
1644 if ((r_ptr->flags1 & RF1_UNIQUE) && !p_ptr->image)
1646 /* Start with the name (thus nominative and objective) */
1647 if ((m_ptr->mflag2 & MFLAG_CHAMELEON) && !(mode & 0x100))
1653 while(strncmp(t, "¡Ù", 2) && *t) t++;
1657 (void)sprintf(desc, "%s¡©¡Ù", buf);
1660 (void)sprintf(desc, "%s¡©", name);
1662 (void)sprintf(desc, "%s?", name);
1665 else if ((cave[m_ptr->fy][m_ptr->fx].m_idx == p_ptr->riding) || !p_ptr->inside_battle)
1666 (void)strcpy(desc, name);
1669 (void)sprintf(desc, "%s¤â¤É¤", name);
1671 (void)sprintf(desc, "fake %s", name);
1675 /* It could be an indefinite monster */
1676 else if (mode & 0x08)
1678 /* XXX Check plurality for "some" */
1680 /* Indefinite monsters need an indefinite article */
1682 (void)strcpy(desc, "");
1684 (void)strcpy(desc, is_a_vowel(name[0]) ? "an " : "a ");
1687 (void)strcat(desc, name);
1689 if (m_ptr->nickname)
1692 sprintf(buf,"¡Ö%s¡×",quark_str(m_ptr->nickname));
1694 sprintf(buf," called %s",quark_str(m_ptr->nickname));
1700 /* It could be a normal, definite, monster */
1703 /* Definite monsters need a definite article */
1706 (void)strcpy(desc, "¤¢¤Ê¤¿¤Î");
1708 (void)strcpy(desc, "your ");
1713 (void)strcpy(desc, "");
1715 (void)strcpy(desc, "the ");
1718 (void)strcat(desc, name);
1720 if (m_ptr->nickname)
1723 sprintf(buf,"¡Ö%s¡×",quark_str(m_ptr->nickname));
1725 sprintf(buf," called %s",quark_str(m_ptr->nickname));
1730 if ((m_ptr->fy == py) && (m_ptr->fx == px))
1732 strcat(desc,"(¾èÇÏÃæ)");
1734 strcat(desc,"(riding)");
1736 if ((mode & 0x200) && (m_ptr->mflag2 & MFLAG_CHAMELEON))
1738 if (r_ptr->flags1 & RF1_UNIQUE)
1740 strcat(desc,"(¥«¥á¥ì¥ª¥ó¤Î²¦)");
1742 strcat(desc,"(Chameleon Lord)");
1746 strcat(desc,"(¥«¥á¥ì¥ª¥ó)");
1748 strcat(desc,"(Chameleon)");
1753 /* Handle the Possessive as a special afterthought */
1756 /* XXX Check for trailing "s" */
1758 /* Simply append "apostrophe" and "s" */
1760 (void)strcat(desc, "¤Î");
1762 (void)strcat(desc, "'s");
1773 * Learn about a monster (by "probing" it)
1775 void lore_do_probe(int m_idx)
1777 monster_type *m_ptr = &m_list[m_idx];
1779 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1781 /* Hack -- Memorize some flags */
1782 r_ptr->r_flags1 = r_ptr->flags1;
1783 r_ptr->r_flags2 = r_ptr->flags2;
1784 r_ptr->r_flags3 = r_ptr->flags3;
1786 /* Update monster recall window */
1787 if (p_ptr->monster_race_idx == m_ptr->r_idx)
1790 p_ptr->window |= (PW_MONSTER);
1796 * Take note that the given monster just dropped some treasure
1798 * Note that learning the "GOOD"/"GREAT" flags gives information
1799 * about the treasure (even when the monster is killed for the first
1800 * time, such as uniques, and the treasure has not been examined yet).
1802 * This "indirect" method is used to prevent the player from learning
1803 * exactly how much treasure a monster can drop from observing only
1804 * a single example of a drop. This method actually observes how much
1805 * gold and items are dropped, and remembers that information to be
1806 * described later by the monster recall code.
1808 void lore_treasure(int m_idx, int num_item, int num_gold)
1810 monster_type *m_ptr = &m_list[m_idx];
1812 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1814 /* Note the number of things dropped */
1815 if (num_item > r_ptr->r_drop_item) r_ptr->r_drop_item = num_item;
1816 if (num_gold > r_ptr->r_drop_gold) r_ptr->r_drop_gold = num_gold;
1818 /* Hack -- memorize the good/great flags */
1819 if (r_ptr->flags1 & (RF1_DROP_GOOD)) r_ptr->r_flags1 |= (RF1_DROP_GOOD);
1820 if (r_ptr->flags1 & (RF1_DROP_GREAT)) r_ptr->r_flags1 |= (RF1_DROP_GREAT);
1822 /* Update monster recall window */
1823 if (p_ptr->monster_race_idx == m_ptr->r_idx)
1826 p_ptr->window |= (PW_MONSTER);
1832 void sanity_blast(monster_type *m_ptr, bool necro)
1834 bool happened = FALSE;
1837 if (p_ptr->inside_battle || !character_dungeon) return;
1842 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1844 power = r_ptr->level / 2;
1846 monster_desc(m_name, m_ptr, 0);
1848 if (!(r_ptr->flags1 & RF1_UNIQUE))
1850 if (r_ptr->flags1 & RF1_FRIENDS)
1856 return; /* No effect yet, just loaded... */
1859 return; /* Cannot see it for some reason */
1861 if (!(r_ptr->flags2 & RF2_ELDRITCH_HORROR))
1867 return; /* Pet eldritch horrors are safe most of the time */
1869 if (randint1(100) > power) return;
1871 if (saving_throw(p_ptr->skill_sav - power))
1873 return; /* Save, no adverse effects */
1878 /* Something silly happens... */
1880 msg_format("%s%s¤Î´é¤ò¸«¤Æ¤·¤Þ¤Ã¤¿¡ª",
1882 msg_format("You behold the %s visage of %s!",
1885 funny_desc[randint0(MAX_SAN_FUNNY)], m_name);
1889 msg_print(funny_comments[randint0(MAX_SAN_COMMENT)]);
1890 p_ptr->image = p_ptr->image + randint1(r_ptr->level);
1893 return; /* Never mind; we can't see it clearly enough */
1896 /* Something frightening happens... */
1898 msg_format("%s%s¤Î´é¤ò¸«¤Æ¤·¤Þ¤Ã¤¿¡ª",
1900 msg_format("You behold the %s visage of %s!",
1903 horror_desc[randint0(MAX_SAN_HORROR)], m_name);
1905 r_ptr->r_flags2 |= RF2_ELDRITCH_HORROR;
1907 /* Demon characters are unaffected */
1908 if ((p_ptr->prace == RACE_IMP) || (p_ptr->prace == RACE_DEMON) || (mimic_info[p_ptr->mimic_form].MIMIC_FLAGS & MIMIC_IS_DEMON)) return;
1911 /* Undead characters are 50% likely to be unaffected */
1912 if ((p_ptr->prace == RACE_SKELETON) || (p_ptr->prace == RACE_ZOMBIE)
1913 || (p_ptr->prace == RACE_VAMPIRE) || (p_ptr->prace == RACE_SPECTRE) ||
1914 (mimic_info[p_ptr->mimic_form].MIMIC_FLAGS & MIMIC_IS_UNDEAD))
1916 if (saving_throw(25 + p_ptr->lev)) return;
1922 msg_print("¥Í¥¯¥í¥Î¥ß¥³¥ó¤òÆɤó¤ÇÀµµ¤¤ò¼º¤Ã¤¿¡ª");
1924 msg_print("Your sanity is shaken by reading the Necronomicon!");
1929 if (!saving_throw(p_ptr->skill_sav - power)) /* Mind blast */
1931 if (!p_ptr->resist_conf)
1933 (void)set_confused(p_ptr->confused + randint0(4) + 4);
1935 if (!p_ptr->resist_chaos && one_in_(3))
1937 (void)set_image(p_ptr->image + randint0(250) + 150);
1942 if (!saving_throw(p_ptr->skill_sav - power)) /* Lose int & wis */
1949 if (!saving_throw(p_ptr->skill_sav - power)) /* Brain smash */
1951 if (!p_ptr->resist_conf)
1953 (void)set_confused(p_ptr->confused + randint0(4) + 4);
1955 if (!p_ptr->free_act)
1957 (void)set_paralyzed(p_ptr->paralyzed + randint0(4) + 4);
1959 while (randint0(100) > p_ptr->skill_sav)
1960 (void)do_dec_stat(A_INT);
1961 while (randint0(100) > p_ptr->skill_sav)
1962 (void)do_dec_stat(A_WIS);
1963 if (!p_ptr->resist_chaos)
1965 (void)set_image(p_ptr->image + randint0(250) + 150);
1970 if (!saving_throw(p_ptr->skill_sav - power)) /* Amnesia */
1973 if (lose_all_info())
1975 msg_print("¤¢¤Þ¤ê¤Î¶²ÉݤËÁ´¤Æ¤Î¤³¤È¤ò˺¤ì¤Æ¤·¤Þ¤Ã¤¿¡ª");
1977 msg_print("You forget everything in your utmost terror!");
1983 if (saving_throw(p_ptr->skill_sav - power))
1988 /* Else gain permanent insanity */
1989 if ((p_ptr->muta3 & MUT3_MORONIC) && /*(p_ptr->muta2 & MUT2_BERS_RAGE) &&*/
1990 ((p_ptr->muta2 & MUT2_COWARDICE) || (p_ptr->resist_fear)) &&
1991 ((p_ptr->muta2 & MUT2_HALLU) || (p_ptr->resist_chaos)))
1993 /* The poor bastard already has all possible insanities! */
1999 switch (randint1(21))
2002 if (!(p_ptr->muta3 & MUT3_MORONIC) && one_in_(5))
2004 if ((p_ptr->stat_use[A_INT] < 4) && (p_ptr->stat_use[A_WIS] < 4))
2007 msg_print("¤¢¤Ê¤¿¤Ï´°àú¤ÊÇϼ¯¤Ë¤Ê¤Ã¤¿¤è¤¦¤Êµ¤¤¬¤·¤¿¡£¤·¤«¤·¤½¤ì¤Ï¸µ¡¹¤À¤Ã¤¿¡£");
2009 msg_print("You turn into an utter moron!");
2015 msg_print("¤¢¤Ê¤¿¤Ï´°àú¤ÊÇϼ¯¤Ë¤Ê¤Ã¤¿¡ª");
2017 msg_print("You turn into an utter moron!");
2021 if (p_ptr->muta3 & MUT3_HYPER_INT)
2024 msg_print("¤¢¤Ê¤¿¤ÎǾ¤ÏÀ¸ÂÎ¥³¥ó¥Ô¥å¡¼¥¿¤Ç¤Ï¤Ê¤¯¤Ê¤Ã¤¿¡£");
2026 msg_print("Your brain is no longer a living computer.");
2029 p_ptr->muta3 &= ~(MUT3_HYPER_INT);
2031 p_ptr->muta3 |= MUT3_MORONIC;
2045 if (!(p_ptr->muta2 & MUT2_COWARDICE) && !p_ptr->resist_fear)
2048 msg_print("¤¢¤Ê¤¿¤Ï¥Ñ¥é¥Î¥¤¥¢¤Ë¤Ê¤Ã¤¿¡ª");
2050 msg_print("You become paranoid!");
2054 /* Duh, the following should never happen, but anyway... */
2055 if (p_ptr->muta3 & MUT3_FEARLESS)
2058 msg_print("¤¢¤Ê¤¿¤Ï¤â¤¦¶²¤ìÃΤ餺¤Ç¤Ï¤Ê¤¯¤Ê¤Ã¤¿¡£");
2060 msg_print("You are no longer fearless.");
2063 p_ptr->muta3 &= ~(MUT3_FEARLESS);
2066 p_ptr->muta2 |= MUT2_COWARDICE;
2080 if (!(p_ptr->muta2 & MUT2_HALLU) && !p_ptr->resist_chaos)
2083 msg_print("¸¸³Ð¤ò¤Ò¤µ¯¤³¤¹Àº¿ÀºøÍð¤Ë´Ù¤Ã¤¿¡ª");
2085 msg_print("You are afflicted by a hallucinatory insanity!");
2088 p_ptr->muta2 |= MUT2_HALLU;
2093 if (!(p_ptr->muta2 & MUT2_BERS_RAGE))
2096 msg_print("·ãÎõ¤Ê´¶¾ð¤Îȯºî¤Ë¤ª¤½¤ï¤ì¤ë¤è¤¦¤Ë¤Ê¤Ã¤¿¡ª");
2098 msg_print("You become subject to fits of berserk rage!");
2101 p_ptr->muta2 |= MUT2_BERS_RAGE;
2108 p_ptr->update |= PU_BONUS;
2114 * This function updates the monster record of the given monster
2116 * This involves extracting the distance to the player (if requested),
2117 * and then checking for visibility (natural, infravision, see-invis,
2118 * telepathy), updating the monster visibility flag, redrawing (or
2119 * erasing) the monster when its visibility changes, and taking note
2120 * of any interesting monster flags (cold-blooded, invisible, etc).
2122 * Note the new "mflag" field which encodes several monster state flags,
2123 * including "view" for when the monster is currently in line of sight,
2124 * and "mark" for when the monster is currently visible via detection.
2126 * The only monster fields that are changed here are "cdis" (the
2127 * distance from the player), "ml" (visible to the player), and
2128 * "mflag" (to maintain the "MFLAG_VIEW" flag).
2130 * Note the special "update_monsters()" function which can be used to
2131 * call this function once for every monster.
2133 * Note the "full" flag which requests that the "cdis" field be updated,
2134 * this is only needed when the monster (or the player) has moved.
2136 * Every time a monster moves, we must call this function for that
2137 * monster, and update the distance, and the visibility. Every time
2138 * the player moves, we must call this function for every monster, and
2139 * update the distance, and the visibility. Whenever the player "state"
2140 * changes in certain ways ("blindness", "infravision", "telepathy",
2141 * and "see invisible"), we must call this function for every monster,
2142 * and update the visibility.
2144 * Routines that change the "illumination" of a grid must also call this
2145 * function for any monster in that grid, since the "visibility" of some
2146 * monsters may be based on the illumination of their grid.
2148 * Note that this function is called once per monster every time the
2149 * player moves. When the player is running, this function is one
2150 * of the primary bottlenecks, along with "update_view()" and the
2151 * "process_monsters()" code, so efficiency is important.
2153 * Note the optimized "inline" version of the "distance()" function.
2155 * A monster is "visible" to the player if (1) it has been detected
2156 * by the player, (2) it is close to the player and the player has
2157 * telepathy, or (3) it is close to the player, and in line of sight
2158 * of the player, and it is "illuminated" by some combination of
2159 * infravision, torch light, or permanent light (invisible monsters
2160 * are only affected by "light" if the player can see invisible).
2162 * Monsters which are not on the current panel may be "visible" to
2163 * the player, and their descriptions will include an "offscreen"
2164 * reference. Currently, offscreen monsters cannot be targetted
2165 * or viewed directly, but old targets will remain set. XXX XXX
2167 * The player can choose to be disturbed by several things, including
2168 * "disturb_move" (monster which is viewable moves in some way), and
2169 * "disturb_near" (monster which is "easily" viewable moves in some
2170 * way). Note that "moves" includes "appears" and "disappears".
2172 void update_mon(int m_idx, bool full)
2174 monster_type *m_ptr = &m_list[m_idx];
2176 monster_race *r_ptr = &r_info[m_ptr->r_idx];
2180 /* Current location */
2187 /* Seen by vision */
2191 /* Compute distance */
2194 /* Distance components */
2195 int dy = (py > fy) ? (py - fy) : (fy - py);
2196 int dx = (px > fx) ? (px - fx) : (fx - px);
2198 /* Approximate distance */
2199 d = (dy > dx) ? (dy + (dx>>1)) : (dx + (dy>>1));
2201 /* Restrict distance */
2202 if (d > 255) d = 255;
2206 /* Save the distance */
2210 /* Extract distance */
2213 /* Extract the distance */
2219 if (m_ptr->mflag & (MFLAG_MARK)) flag = TRUE;
2223 if (d <= ((d_info[dungeon_type].flags1 & DF1_DARKNESS) ? MAX_SIGHT / 2 : MAX_SIGHT))
2225 if (!(d_info[dungeon_type].flags1 & DF1_DARKNESS) || (d <= MAX_SIGHT / 4))
2227 if (p_ptr->special_defense & KATA_MUSOU)
2232 /* Hack -- Memorize mental flags */
2233 if (r_ptr->flags2 & (RF2_SMART)) r_ptr->r_flags2 |= (RF2_SMART);
2234 if (r_ptr->flags2 & (RF2_STUPID)) r_ptr->r_flags2 |= (RF2_STUPID);
2237 /* Basic telepathy */
2238 else if (p_ptr->telepathy)
2240 /* Empty mind, no telepathy */
2241 if (r_ptr->flags2 & (RF2_EMPTY_MIND))
2243 /* Memorize flags */
2244 r_ptr->r_flags2 |= (RF2_EMPTY_MIND);
2247 /* Weird mind, occasional telepathy */
2248 else if (r_ptr->flags2 & (RF2_WEIRD_MIND))
2250 /* One in ten individuals are detectable */
2251 if ((m_idx % 10) == 5)
2256 /* Memorize flags */
2257 r_ptr->r_flags2 |= (RF2_WEIRD_MIND);
2259 /* Hack -- Memorize mental flags */
2260 if (r_ptr->flags2 & (RF2_SMART)) r_ptr->r_flags2 |= (RF2_SMART);
2261 if (r_ptr->flags2 & (RF2_STUPID)) r_ptr->r_flags2 |= (RF2_STUPID);
2265 /* Normal mind, allow telepathy */
2271 /* Hack -- Memorize mental flags */
2272 if (r_ptr->flags2 & (RF2_SMART)) r_ptr->r_flags2 |= (RF2_SMART);
2273 if (r_ptr->flags2 & (RF2_STUPID)) r_ptr->r_flags2 |= (RF2_STUPID);
2278 /* Normal line of sight, and not blind */
2279 if (player_has_los_bold(fy, fx) && !p_ptr->blind)
2281 bool do_invisible = FALSE;
2282 bool do_cold_blood = FALSE;
2284 /* Use "infravision" */
2285 if (d <= p_ptr->see_infra)
2287 /* Handle "cold blooded" monsters */
2288 if (r_ptr->flags2 & (RF2_COLD_BLOOD))
2291 do_cold_blood = TRUE;
2294 /* Handle "warm blooded" monsters */
2302 /* Use "illumination" */
2303 if (player_can_see_bold(fy, fx))
2305 /* Handle "invisible" monsters */
2306 if (r_ptr->flags2 & (RF2_INVISIBLE))
2309 do_invisible = TRUE;
2319 /* Handle "normal" monsters */
2330 /* Memorize flags */
2331 if (do_invisible) r_ptr->r_flags2 |= (RF2_INVISIBLE);
2332 if (do_cold_blood) r_ptr->r_flags2 |= (RF2_COLD_BLOOD);
2338 /* The monster is now visible */
2341 /* It was previously unseen */
2344 /* Mark as visible */
2347 /* Draw the monster */
2350 /* Update health bar as needed */
2351 if (p_ptr->health_who == m_idx) p_ptr->redraw |= (PR_HEALTH);
2352 if (p_ptr->riding == m_idx) p_ptr->redraw |= (PR_UHEALTH);
2354 /* Hack -- Count "fresh" sightings */
2355 if ((m_ptr->mflag2 & MFLAG_KAGE) && (r_info[MON_KAGE].r_sights < MAX_SHORT))
2356 r_info[MON_KAGE].r_sights++;
2357 else if (r_ptr->r_sights < MAX_SHORT) r_ptr->r_sights++;
2359 /* Eldritch Horror */
2360 if (r_ptr->flags2 & RF2_ELDRITCH_HORROR)
2362 sanity_blast(m_ptr, FALSE);
2365 /* Disturb on appearance */
2366 if (disturb_near && (projectable(m_ptr->fy, m_ptr->fx, py, px) && projectable(py, px, m_ptr->fy, m_ptr->fx)))
2368 if (disturb_pets || is_hostile(m_ptr))
2374 /* The monster is not visible */
2377 /* It was previously seen */
2380 /* Mark as not visible */
2383 /* Erase the monster */
2386 /* Update health bar as needed */
2387 if (p_ptr->health_who == m_idx) p_ptr->redraw |= (PR_HEALTH);
2388 if (p_ptr->riding == m_idx) p_ptr->redraw |= (PR_UHEALTH);
2390 /* Disturb on disappearance */
2393 if (disturb_pets || is_hostile(m_ptr))
2400 /* The monster is now easily visible */
2404 if (!(m_ptr->mflag & (MFLAG_VIEW)))
2406 /* Mark as easily visible */
2407 m_ptr->mflag |= (MFLAG_VIEW);
2409 /* Disturb on appearance */
2412 if (disturb_pets || is_hostile(m_ptr))
2418 /* The monster is not easily visible */
2422 if (m_ptr->mflag & (MFLAG_VIEW))
2424 /* Mark as not easily visible */
2425 m_ptr->mflag &= ~(MFLAG_VIEW);
2427 /* Disturb on disappearance */
2430 if (disturb_pets || is_hostile(m_ptr))
2439 * This function simply updates all the (non-dead) monsters (see above).
2441 void update_monsters(bool full)
2445 /* Update each (live) monster */
2446 for (i = 1; i < m_max; i++)
2448 monster_type *m_ptr = &m_list[i];
2450 /* Skip dead monsters */
2451 if (!m_ptr->r_idx) continue;
2453 /* Update the monster */
2454 update_mon(i, full);
2459 static bool monster_hook_chameleon_lord(int r_idx)
2461 monster_race *r_ptr = &r_info[r_idx];
2463 if (!(r_ptr->flags1 & (RF1_UNIQUE))) return FALSE;
2464 if (r_ptr->flags7 & (RF7_FRIENDLY | RF7_CHAMELEON)) return FALSE;
2466 if (ABS(r_ptr->level - r_info[MON_CHAMELEON_K].level) > 5) return FALSE;
2468 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))
2474 static bool monster_hook_chameleon(int r_idx)
2476 monster_race *r_ptr = &r_info[r_idx];
2478 if (r_ptr->flags1 & (RF1_UNIQUE)) return FALSE;
2479 if (r_ptr->flags2 & RF2_MULTIPLY) return FALSE;
2480 if (r_ptr->flags7 & (RF7_FRIENDLY | RF7_CHAMELEON)) return FALSE;
2482 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))
2485 return (*(get_monster_hook()))(r_idx);
2489 void choose_new_monster(int m_idx, bool born, int r_idx)
2493 monster_type *m_ptr = &m_list[m_idx];
2494 monster_race *r_ptr;
2495 char old_m_name[80];
2496 int old_r_idx = m_ptr->r_idx;
2497 bool old_unique = FALSE;
2499 if (r_info[m_ptr->r_idx].flags1 & RF1_UNIQUE) old_unique = TRUE;
2500 if (old_unique && (r_idx == MON_CHAMELEON)) r_idx = MON_CHAMELEON_K;
2501 r_ptr = &r_info[r_idx];
2503 monster_desc(old_m_name, m_ptr, 0);
2507 chameleon_change = TRUE;
2509 get_mon_num_prep(monster_hook_chameleon_lord, NULL);
2511 get_mon_num_prep(monster_hook_chameleon, NULL);
2518 level = r_info[MON_CHAMELEON_K].level;
2519 else if (!dun_level)
2520 level = wilderness[p_ptr->wilderness_y][p_ptr->wilderness_x].level;
2524 if (d_info[dungeon_type].flags1 & DF1_CHAMELEON) level+= 2+randint1(3);
2525 r_idx = get_mon_num(level);
2526 r_ptr = &r_info[r_idx];
2528 if (!monster_can_cross_terrain(cave[m_ptr->fy][m_ptr->fx].feat, r_ptr)) continue;
2529 if (!born && !old_unique)
2531 if ((r_info[old_r_idx].flags3 & RF3_GOOD) && !(r_ptr->flags3 & RF3_GOOD)) continue;
2532 if ((r_info[old_r_idx].flags3 & RF3_EVIL) && !(r_ptr->flags3 & RF3_EVIL)) continue;
2533 if (!(r_info[old_r_idx].flags3 & (RF3_GOOD | RF3_EVIL)) && (r_ptr->flags3 & (RF3_GOOD | RF3_EVIL))) continue;
2537 chameleon_change = FALSE;
2538 if (!attempt) return;
2541 m_ptr->r_idx = r_idx;
2542 update_mon(m_idx, FALSE);
2543 lite_spot(m_ptr->fy, m_ptr->fx);
2546 if (m_idx == p_ptr->riding)
2549 monster_desc(m_name, m_ptr, 0);
2551 msg_format("ÆÍÁ³%s¤¬ÊѿȤ·¤¿¡£", old_m_name);
2553 msg_format("Suddenly, %s transforms!", old_m_name);
2555 if (!(r_ptr->flags7 & RF7_RIDING))
2557 if (rakuba(0, TRUE)) msg_print("ÃÏÌ̤ËÍî¤È¤µ¤ì¤¿¡£");
2559 if (rakuba(0, TRUE)) msg_format("You have fallen from %s.", m_name);
2563 /* Extract the monster base speed */
2564 m_ptr->mspeed = r_ptr->speed;
2565 /* Hack -- small racial variety */
2566 /* Allow some small variation per monster */
2568 i = extract_energy[r_ptr->speed] / 3;
2569 if (i) m_ptr->mspeed += rand_spread(0, i);
2572 i = extract_energy[r_ptr->speed] / 10;
2573 if (i) m_ptr->mspeed += rand_spread(0, i);
2576 oldmaxhp = m_ptr->max_maxhp;
2577 /* Assign maximal hitpoints */
2578 if (r_ptr->flags1 & RF1_FORCE_MAXHP)
2580 m_ptr->max_maxhp = maxroll(r_ptr->hdice, r_ptr->hside);
2584 m_ptr->max_maxhp = damroll(r_ptr->hdice, r_ptr->hside);
2586 m_ptr->maxhp = (long)(m_ptr->maxhp * m_ptr->max_maxhp) / oldmaxhp;
2587 m_ptr->hp = (long)(m_ptr->hp * m_ptr->max_maxhp) / oldmaxhp;
2592 * Attempt to place a monster of the given race at the given location.
2594 * To give the player a sporting chance, any monster that appears in
2595 * line-of-sight and is extremely dangerous can be marked as
2596 * "FORCE_SLEEP", which will cause them to be placed with low energy,
2597 * which often (but not always) lets the player move before they do.
2599 * This routine refuses to place out-of-depth "FORCE_DEPTH" monsters.
2601 * XXX XXX XXX Use special "here" and "dead" flags for unique monsters,
2602 * remove old "cur_num" and "max_num" fields.
2604 * XXX XXX XXX Actually, do something similar for artifacts, to simplify
2605 * the "preserve" mode, and to make the "what artifacts" flag more useful.
2607 * This is the only function which may place a monster in the dungeon,
2608 * except for the savefile loading code.
2610 bool place_monster_one(int y, int x, int r_idx, bool slp, bool friendly, bool pet, bool no_pet)
2617 monster_type *m_ptr;
2619 monster_race *r_ptr = &r_info[r_idx];
2621 cptr name = (r_name + r_ptr->name);
2623 /* DO NOT PLACE A MONSTER IN THE SMALL SCALE WILDERNESS !!! */
2624 if(p_ptr->wild_mode) return FALSE;
2626 /* Verify location */
2627 if (!in_bounds(y, x)) return (FALSE);
2629 /* Require empty space (if not ghostly) */
2630 if (!(!dun_level && (cave[y][x].feat == FEAT_MOUNTAIN) && ((r_ptr->flags8 & RF8_WILD_MOUNTAIN) || (r_ptr->flags7 & RF7_CAN_FLY))) &&
2631 !cave_empty_bold2(y, x) &&
2632 !((r_ptr->flags2 & RF2_PASS_WALL) &&
2633 !(cave_perma_bold(y, x) || cave[y][x].m_idx ||
2634 ((y == py) && (x == px))))) return (FALSE);
2637 if (!r_idx) return (FALSE);
2640 if (!r_ptr->name) return (FALSE);
2643 /* Hack -- no creation on glyph of warding */
2644 if (cave[y][x].feat == FEAT_GLYPH) return (FALSE);
2645 if (cave[y][x].feat == FEAT_MINOR_GLYPH) return (FALSE);
2648 /* Nor on the Pattern */
2649 if ((cave[y][x].feat >= FEAT_PATTERN_START)
2650 && (cave[y][x].feat <= FEAT_PATTERN_XTRA2))
2653 if (monster_terrain_sensitive &&
2654 !monster_can_cross_terrain(cave[y][x].feat, r_ptr))
2659 if (!p_ptr->inside_battle)
2661 /* Hack -- "unique" monsters must be "unique" */
2662 if (((r_ptr->flags1 & (RF1_UNIQUE)) ||
2663 (r_ptr->flags7 & (RF7_UNIQUE_7))) &&
2664 (r_ptr->cur_num >= r_ptr->max_num))
2670 if ((r_ptr->flags7 & (RF7_UNIQUE2)) &&
2671 (r_ptr->cur_num >= 1))
2676 if (r_idx == MON_BANORLUPART)
2678 if (r_info[MON_BANOR].cur_num > 0) return FALSE;
2679 if (r_info[MON_LUPART].cur_num > 0) return FALSE;
2682 /* Depth monsters may NOT be created out of depth, unless in Nightmare mode */
2683 if ((r_ptr->flags1 & (RF1_FORCE_DEPTH)) && (dun_level < r_ptr->level) &&
2684 (!ironman_nightmare || (r_ptr->flags1 & (RF1_QUESTOR))))
2691 if(quest_number(dun_level))
2693 int hoge = quest_number(dun_level);
2694 if((quest[hoge].type == QUEST_TYPE_KILL_LEVEL) || (quest[hoge].type == QUEST_TYPE_RANDOM))
2696 if(r_idx == quest[hoge].r_idx)
2698 int number_mon, i2, j2;
2701 /* Count all quest monsters */
2702 for (i2 = 0; i2 < cur_wid; ++i2)
2703 for (j2 = 0; j2 < cur_hgt; j2++)
2704 if (cave[j2][i2].m_idx > 0)
2705 if (m_list[cave[j2][i2].m_idx].r_idx == quest[hoge].r_idx)
2707 if(number_mon + quest[hoge].cur_num >= quest[hoge].max_num)
2713 /* Access the location */
2714 c_ptr = &cave[y][x];
2716 if (c_ptr->feat == FEAT_GLYPH)
2718 if (randint1(BREAK_GLYPH) < (r_ptr->level+20))
2720 /* Describe observable breakage */
2721 if (c_ptr->info & CAVE_MARK)
2724 msg_print("¼é¤ê¤Î¥ë¡¼¥ó¤¬²õ¤ì¤¿¡ª");
2726 msg_print("The rune of protection is broken!");
2731 /* Forget the rune */
2732 c_ptr->info &= ~(CAVE_MARK);
2734 /* Break the rune */
2735 c_ptr->feat = floor_type[randint0(100)];
2736 c_ptr->info &= ~(CAVE_MASK);
2737 c_ptr->info |= CAVE_FLOOR;
2746 /* Powerful monster */
2747 if (r_ptr->level > dun_level)
2749 /* Unique monsters */
2750 if (r_ptr->flags1 & (RF1_UNIQUE))
2752 /* Message for cheaters */
2754 if (cheat_hear) msg_format("¿¼ÁؤΥæ¥Ë¡¼¥¯¡¦¥â¥ó¥¹¥¿¡¼ (%s)¡£", name);
2756 if (cheat_hear) msg_format("Deep Unique (%s).", name);
2760 /* Boost rating by twice delta-depth */
2761 rating += (r_ptr->level - dun_level) * 2;
2764 /* Normal monsters */
2767 /* Message for cheaters */
2769 if (cheat_hear) msg_format("¿¼ÁؤΥâ¥ó¥¹¥¿¡¼ (%s)¡£", name);
2771 if (cheat_hear) msg_format("Deep Monster (%s).", name);
2775 /* Boost rating by delta-depth */
2776 rating += (r_ptr->level - dun_level);
2780 /* Note the monster */
2781 else if (r_ptr->flags1 & (RF1_UNIQUE))
2783 /* Unique monsters induce message */
2785 if (cheat_hear) msg_format("¥æ¥Ë¡¼¥¯¡¦¥â¥ó¥¹¥¿¡¼ (%s)¡£", name);
2787 if (cheat_hear) msg_format("Unique (%s).", name);
2792 if ((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags7 & RF7_UNIQUE_7) || (r_ptr->level < 10)) is_kage = FALSE;
2794 /* Make a new monster */
2795 c_ptr->m_idx = m_pop();
2796 hack_m_idx_ii = c_ptr->m_idx;
2798 /* Mega-Hack -- catch "failure" */
2799 if (!c_ptr->m_idx) return (FALSE);
2802 /* Get a new monster record */
2803 m_ptr = &m_list[c_ptr->m_idx];
2806 m_ptr->r_idx = r_idx;
2808 /* Place the monster at the location */
2813 /* No "damage" yet */
2815 m_ptr->confused = 0;
2818 /* Unknown distance */
2821 reset_target(m_ptr);
2823 m_ptr->nickname = 0;
2831 if (r_ptr->flags7 & RF7_CHAMELEON)
2833 choose_new_monster(c_ptr->m_idx, TRUE, 0);
2834 r_ptr = &r_info[m_ptr->r_idx];
2835 m_ptr->mflag2 |= MFLAG_CHAMELEON;
2838 else if (is_kage) m_ptr->mflag2 |= MFLAG_KAGE;
2839 if (no_pet) m_ptr->mflag2 |= MFLAG_NOPET;
2850 else if ((friendly || (r_ptr->flags7 & RF7_FRIENDLY)) &&
2851 !(p_ptr->align >= 0 && (r_ptr->flags3 & RF3_EVIL)) &&
2852 !(p_ptr->align < 0 && (r_ptr->flags3 & RF3_GOOD)))
2854 set_friendly(m_ptr);
2857 /* Assume no sleeping */
2860 /* Enforce sleeping if needed */
2861 if (slp && r_ptr->sleep && !ironman_nightmare)
2863 int val = r_ptr->sleep;
2864 m_ptr->csleep = ((val * 2) + randint1(val * 10));
2867 /* Assign maximal hitpoints */
2868 if (r_ptr->flags1 & RF1_FORCE_MAXHP)
2870 m_ptr->max_maxhp = maxroll(r_ptr->hdice, r_ptr->hside);
2874 m_ptr->max_maxhp = damroll(r_ptr->hdice, r_ptr->hside);
2877 /* Monsters have double hitpoints in Nightmare mode */
2878 if (ironman_nightmare)
2880 u32b hp = m_ptr->max_maxhp * 2L;
2882 m_ptr->max_maxhp = (s16b)MIN(30000, hp);
2885 m_ptr->maxhp = m_ptr->max_maxhp;
2887 /* And start out fully healthy */
2888 if (m_ptr->r_idx == MON_WOUNDED_BEAR)
2889 m_ptr->hp = m_ptr->maxhp / 2;
2890 else m_ptr->hp = m_ptr->maxhp;
2893 /* Extract the monster base speed */
2894 m_ptr->mspeed = r_ptr->speed;
2896 /* Hack -- small racial variety */
2897 if (!(r_ptr->flags1 & RF1_UNIQUE) && !p_ptr->inside_arena)
2899 /* Allow some small variation per monster */
2901 i = extract_energy[r_ptr->speed] / 3;
2902 if (i) m_ptr->mspeed += rand_spread(0, i);
2905 i = extract_energy[r_ptr->speed] / 10;
2906 if (i) m_ptr->mspeed += rand_spread(0, i);
2910 if (m_ptr->mspeed > 199) m_ptr->mspeed = 199;
2912 /* Give a random starting energy */
2913 m_ptr->energy = (byte)randint0(100);
2915 /* Nightmare monsters are more prepared */
2916 if (ironman_nightmare)
2921 /* Force monster to wait for player, unless in Nightmare mode */
2922 if ((r_ptr->flags1 & RF1_FORCE_SLEEP) && !ironman_nightmare)
2924 /* Monster is still being nice */
2925 m_ptr->mflag |= (MFLAG_NICE);
2927 /* Must repair monsters */
2928 repair_monsters = TRUE;
2931 /* Hack -- see "process_monsters()" */
2932 if (c_ptr->m_idx < hack_m_idx)
2934 /* Monster is still being born */
2935 m_ptr->mflag |= (MFLAG_BORN);
2939 /* Update the monster */
2940 update_mon(c_ptr->m_idx, TRUE);
2943 /* Hack -- Count the monsters on the level */
2944 if (m_ptr->mflag2 & MFLAG_CHAMELEON)
2945 r_info[r_idx].cur_num++;
2950 /* Hack -- Count the number of "reproducers" */
2951 if (r_ptr->flags2 & RF2_MULTIPLY) num_repro++;
2954 /* Hack -- Notice new multi-hued monsters */
2955 if (r_ptr->flags1 & RF1_ATTR_MULTI) shimmer_monsters = TRUE;
2957 if (p_ptr->warning && character_dungeon)
2959 if (r_ptr->flags1 & RF1_UNIQUE)
2963 char o_name[MAX_NLEN];
2965 if (r_ptr->level > p_ptr->lev + 30)
2971 else if (r_ptr->level > p_ptr->lev + 15)
2977 else if (r_ptr->level > p_ptr->lev + 5)
2979 color = "¥ë¥Ó¡¼¿§¤Ë";
2983 else if (r_ptr->level > p_ptr->lev - 5)
2989 else if (r_ptr->level > p_ptr->lev - 15)
2991 color = "¥Ô¥ó¥¯¿§¤Ë";
3002 o_ptr = choose_warning_item();
3003 object_desc(o_name, o_ptr, FALSE, 0);
3005 msg_format("%s¤Ï%s¸÷¤Ã¤¿¡£",o_name, color);
3007 msg_format("%s glows %s.",o_name, color);
3012 if (c_ptr->feat == FEAT_MINOR_GLYPH)
3014 /* Break the ward */
3015 if (randint1(BREAK_MINOR_GLYPH) > r_ptr->level)
3017 /* Describe observable breakage */
3018 if (c_ptr->info & CAVE_MARK)
3021 msg_print("¥ë¡¼¥ó¤¬Çúȯ¤·¤¿¡ª");
3023 msg_print("The rune explodes!");
3026 project(0, 2, y, x, 2 * (p_ptr->lev + damroll(7, 7)), GF_MANA, (PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL | PROJECT_JUMP | PROJECT_NO_REF | PROJECT_NO_HANGEKI), -1);
3032 msg_print("Çúȯ¤Î¥ë¡¼¥ó¤Ï²ò½ü¤µ¤ì¤¿¡£");
3034 msg_print("An explosive rune was disarmed.");
3038 /* Forget the rune */
3039 c_ptr->info &= ~(CAVE_MARK);
3041 /* Break the rune */
3042 c_ptr->feat = floor_type[randint0(100)];
3043 c_ptr->info &= ~(CAVE_MASK);
3044 c_ptr->info |= CAVE_FLOOR;
3055 * improved version of scatter() for place monster
3058 #define MON_SCAT_MAXD 10
3060 static bool mon_scatter(int *yp, int *xp, int y, int x, int max_dist)
3062 int place_x[MON_SCAT_MAXD];
3063 int place_y[MON_SCAT_MAXD];
3064 int num[MON_SCAT_MAXD];
3068 if (max_dist >= MON_SCAT_MAXD)
3071 for (i = 0; i < MON_SCAT_MAXD; i++)
3074 for (nx = x - max_dist; nx <= x + max_dist; nx++)
3075 for (ny = y - max_dist; ny <= y + max_dist; ny++)
3077 /* Ignore annoying locations */
3078 if (!in_bounds(ny, nx)) continue;
3080 /* Require "line of sight" */
3081 if (!los(y, x, ny, nx)) continue;
3083 /* Walls and Monsters block flow */
3084 if (!cave_empty_bold2(ny, nx)) continue;
3085 if (cave[ny][nx].m_idx) continue;
3086 if ((ny == py) && (nx == px)) continue;
3089 /* Hack -- no summon on glyph of warding */
3090 if (cave[ny][nx].feat == FEAT_GLYPH) continue;
3091 if (cave[ny][nx].feat == FEAT_MINOR_GLYPH) continue;
3094 /* ... nor on the Pattern */
3095 if ((cave[ny][nx].feat >= FEAT_PATTERN_START) &&
3096 (cave[ny][nx].feat <= FEAT_PATTERN_XTRA2))
3099 i = distance(y, x, ny, nx);
3116 while (i < MON_SCAT_MAXD && 0 == num[i])
3118 if (i >= MON_SCAT_MAXD)
3129 * Maximum size of a group of monsters
3131 #define GROUP_MAX 32
3135 * Attempt to place a "group" of monsters around the given location
3137 static bool place_monster_group(int y, int x, int r_idx, bool slp, bool friendly, bool pet, bool no_pet)
3139 monster_race *r_ptr = &r_info[r_idx];
3142 int total = 0, extra = 0;
3146 byte hack_y[GROUP_MAX];
3147 byte hack_x[GROUP_MAX];
3150 /* Pick a group size */
3151 total = randint1(10);
3153 /* Hard monsters, small groups */
3154 if (r_ptr->level > dun_level)
3156 extra = r_ptr->level - dun_level;
3157 extra = 0 - randint1(extra);
3160 /* Easy monsters, large groups */
3161 else if (r_ptr->level < dun_level)
3163 extra = dun_level - r_ptr->level;
3164 extra = randint1(extra);
3167 /* Hack -- limit group reduction */
3168 if (extra > 9) extra = 9;
3170 /* Modify the group size */
3174 if (total < 1) total = 1;
3177 if (total > GROUP_MAX) total = GROUP_MAX;
3180 /* Save the rating */
3183 /* Start on the monster */
3188 /* Puddle monsters, breadth first, up to total */
3189 for (n = 0; (n < hack_n) && (hack_n < total); n++)
3191 /* Grab the location */
3195 /* Check each direction, up to total */
3196 for (i = 0; (i < 8) && (hack_n < total); i++)
3200 scatter(&my, &mx, hy, hx, 4, 0);
3202 /* Walls and Monsters block flow */
3203 if (!cave_empty_bold2(my, mx)) continue;
3205 /* Attempt to place another monster */
3206 if (place_monster_one(my, mx, r_idx, slp, friendly, pet, no_pet))
3208 /* Add it to the "hack" set */
3209 hack_y[hack_n] = my;
3210 hack_x[hack_n] = mx;
3216 /* Hack -- restore the rating */
3226 * Hack -- help pick an escort type
3228 static int place_monster_idx = 0;
3231 * Hack -- help pick an escort type
3233 static bool place_monster_okay(int r_idx)
3235 monster_race *r_ptr = &r_info[place_monster_idx];
3237 monster_race *z_ptr = &r_info[r_idx];
3239 /* Hack - Escorts have to have the same dungeon flag */
3240 if (monster_dungeon(place_monster_idx) != monster_dungeon(r_idx)) return (FALSE);
3242 /* Require similar "race" */
3243 if (z_ptr->d_char != r_ptr->d_char) return (FALSE);
3245 /* Skip more advanced monsters */
3246 if (z_ptr->level > r_ptr->level) return (FALSE);
3248 /* Skip unique monsters */
3249 if (z_ptr->flags1 & RF1_UNIQUE) return (FALSE);
3251 /* Paranoia -- Skip identical monsters */
3252 if (place_monster_idx == r_idx) return (FALSE);
3254 /* Skip different alignment */
3255 if (((r_ptr->flags3 & RF3_EVIL) && (z_ptr->flags3 & RF3_GOOD)) ||
3256 ((r_ptr->flags3 & RF3_GOOD) && (z_ptr->flags3 & RF3_EVIL)))
3259 if (r_ptr->flags7 & RF7_FRIENDLY)
3261 if (((p_ptr->align < 0) && (z_ptr->flags3 & RF3_GOOD)) ||
3262 ((p_ptr->align > 0) && (z_ptr->flags3 & RF3_EVIL)))
3272 * Attempt to place a monster of the given race at the given location
3274 * Note that certain monsters are now marked as requiring "friends".
3275 * These monsters, if successfully placed, and if the "grp" parameter
3276 * is TRUE, will be surrounded by a "group" of identical monsters.
3278 * Note that certain monsters are now marked as requiring an "escort",
3279 * which is a collection of monsters with similar "race" but lower level.
3281 * Some monsters induce a fake "group" flag on their escorts.
3283 * Note the "bizarre" use of non-recursion to prevent annoying output
3284 * when running a code profiler.
3286 * Note the use of the new "monster allocation table" code to restrict
3287 * the "get_mon_num()" function to "legal" escort types.
3289 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)
3292 monster_race *r_ptr = &r_info[r_idx];
3294 if (one_in_(333) && !no_kage && !pet) is_kage = TRUE;
3295 else is_kage = FALSE;
3297 /* Place one monster, or fail */
3298 if (!place_monster_one(y, x, r_idx, slp, friendly, pet, no_pet)) return (FALSE);
3301 /* Require the "group" flag */
3302 if (!grp) return (TRUE);
3305 /* Friends for certain monsters */
3306 if (r_ptr->flags1 & (RF1_FRIENDS))
3308 /* Attempt to place a group */
3309 (void)place_monster_group(y, x, r_idx, slp, friendly, pet, no_pet);
3313 /* Escorts for certain monsters */
3314 if (r_ptr->flags1 & (RF1_ESCORT))
3316 /* Set the escort index */
3317 place_monster_idx = r_idx;
3319 /* Try to place several "escorts" */
3320 for (i = 0; i < 32; i++)
3322 int nx, ny, z, d = 3;
3324 /* Pick a location */
3325 scatter(&ny, &nx, y, x, d, 0);
3327 /* Require empty grids */
3328 if (!cave_empty_bold2(ny, nx)) continue;
3330 /* Prepare allocation table */
3331 get_mon_num_prep(place_monster_okay, get_monster_hook2(ny, nx));
3333 /* Pick a random race */
3334 z = get_mon_num(r_ptr->level);
3336 /* Handle failure */
3339 /* Place a single escort */
3340 (void)place_monster_one(ny, nx, z, slp, friendly, pet, no_pet);
3342 /* Place a "group" of escorts if needed */
3343 if ((r_info[z].flags1 & RF1_FRIENDS) ||
3344 (r_ptr->flags1 & RF1_ESCORTS))
3346 /* Place a group of monsters */
3347 (void)place_monster_group(ny, nx, z, slp, friendly, pet, no_pet);
3358 * Hack -- attempt to place a monster at the given location
3360 * Attempt to find a monster appropriate to the "monster_level"
3362 bool place_monster(int y, int x, bool slp, bool grp)
3366 /* Prepare allocation table */
3367 get_mon_num_prep(get_monster_hook(), get_monster_hook2(y, x));
3369 /* Pick a monster */
3370 r_idx = get_mon_num(monster_level);
3372 /* Handle failure */
3373 if (!r_idx) return (FALSE);
3375 /* Attempt to place the monster */
3376 if (place_monster_aux(y, x, r_idx, slp, grp, FALSE, FALSE, FALSE, FALSE)) return (TRUE);
3383 #ifdef MONSTER_HORDES
3385 bool alloc_horde(int y, int x)
3387 monster_race *r_ptr = NULL;
3390 int attempts = 1000;
3394 /* Prepare allocation table */
3395 get_mon_num_prep(get_monster_hook(), get_monster_hook2(y, x));
3399 /* Pick a monster */
3400 r_idx = get_mon_num(monster_level);
3402 /* Handle failure */
3403 if (!r_idx) return (FALSE);
3405 r_ptr = &r_info[r_idx];
3407 if (r_ptr->flags1 & RF1_UNIQUE) continue;
3409 if (r_idx == MON_HAGURE) continue;
3412 if (attempts < 1) return FALSE;
3414 if (r_ptr->flags3 & RF3_GOOD) horde_align |= HORDE_NOEVIL;
3415 if (r_ptr->flags3 & RF3_EVIL) horde_align |= HORDE_NOGOOD;
3421 /* Attempt to place the monster */
3422 if (place_monster_aux(y, x, r_idx, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE)) break;
3425 if (attempts < 1) {horde_align = 0;return FALSE;}
3427 m_idx = cave[y][x].m_idx;
3429 if (m_list[m_idx].mflag2 & MFLAG_CHAMELEON) r_ptr = &r_info[m_list[m_idx].r_idx];
3430 summon_kin_type = r_ptr->d_char;
3432 for (attempts = randint1(10) + 5; attempts; attempts--)
3434 scatter(&cy, &cx, y, x, 5, 0);
3436 (void)summon_specific(m_idx, cy, cx, dun_level + 5, SUMMON_KIN, TRUE, FALSE, FALSE, FALSE, FALSE);
3446 #endif /* MONSTER_HORDES */
3451 * Attempt to allocate a random monster in the dungeon.
3453 * Place the monster at least "dis" distance from the player.
3455 * Use "slp" to choose the initial "sleep" status
3457 * Use "monster_level" for the monster level
3459 bool alloc_monster(int dis, bool slp)
3462 int attempts_left = 10000;
3463 int guardian = d_info[dungeon_type].final_guardian;
3465 /* Put an Guardian */
3466 if(guardian && d_info[dungeon_type].maxdepth == dun_level && r_info[guardian].cur_num < r_info[guardian].max_num )
3472 /* Find a good position */
3475 /* Get a random spot */
3476 oy = randint1(cur_hgt - 4) + 2;
3477 ox = randint1(cur_wid - 4) + 2;
3479 /* Is it a good spot ? */
3480 if (cave_empty_bold2(oy, ox) && monster_can_cross_terrain(cave[oy][ox].feat, &r_info[guardian]))
3482 /* Place the guardian */
3483 if (place_monster_aux(oy, ox, guardian, FALSE, TRUE, FALSE, FALSE, TRUE, TRUE)) break;
3491 /* Find a legal, distant, unoccupied, space */
3492 while (attempts_left--)
3494 /* Pick a location */
3495 y = randint0(cur_hgt);
3496 x = randint0(cur_wid);
3498 /* Require empty floor grid (was "naked") */
3499 if (dun_level || (wilderness[p_ptr->wilderness_y][p_ptr->wilderness_x].terrain != TERRAIN_MOUNTAIN))
3501 if (!cave_empty_bold2(y, x)) continue;
3505 if (!cave_empty_bold2(y, x) && (cave[y][x].feat != FEAT_MOUNTAIN)) continue;
3508 /* Accept far away grids */
3509 if (distance(y, x, py, px) > dis) break;
3514 if (cheat_xtra || cheat_hear)
3517 msg_print("·Ù¹ð¡ª¿·¤¿¤Ê¥â¥ó¥¹¥¿¡¼¤òÇÛÃ֤Ǥ¤Þ¤»¤ó¡£¾®¤µ¤¤³¬¤Ç¤¹¤«¡©");
3519 msg_print("Warning! Could not allocate a new monster. Small level?");
3528 #ifdef MONSTER_HORDES
3529 if (randint1(5000) <= dun_level)
3531 if (alloc_horde(y, x))
3534 if (cheat_hear) msg_print("¥â¥ó¥¹¥¿¡¼¤ÎÂç·²");
3536 if (cheat_hear) msg_print("Monster horde.");
3544 #endif /* MONSTER_HORDES */
3546 /* Attempt to place the monster, allow groups */
3547 if (place_monster(y, x, slp, TRUE)) return (TRUE);
3549 #ifdef MONSTER_HORDES
3551 #endif /* MONSTER_HORDES */
3561 * Hack -- help decide if a monster race is "okay" to summon
3563 static bool summon_specific_okay(int r_idx)
3565 monster_race *r_ptr = &r_info[r_idx];
3567 /* Hack - Only summon dungeon monsters */
3568 if (!monster_dungeon(r_idx)) return (FALSE);
3570 /* Hack -- identify the summoning monster */
3571 if (summon_specific_who > 0)
3573 monster_type *m_ptr = &m_list[summon_specific_who];
3574 monster_race *s_ptr = &r_info[m_ptr->r_idx];
3576 /* Do not summon enemies */
3578 /* Friendly vs. opposite aligned normal or pet */
3579 if (((r_ptr->flags3 & RF3_EVIL) &&
3580 (s_ptr->flags3 & RF3_GOOD)) ||
3581 ((r_ptr->flags3 & RF3_GOOD) &&
3582 (s_ptr->flags3 & RF3_EVIL)))
3587 /* Hostile vs. non-hostile */
3588 if (is_hostile(m_ptr) != summon_specific_hostile)
3593 /* Use the player's alignment */
3594 else if (summon_specific_who < 0)
3596 /* Do not summon enemies of the pets */
3597 if ((p_ptr->align < -9) && (r_ptr->flags3 & RF3_GOOD))
3599 if (!one_in_((0-p_ptr->align)/2+1)) return FALSE;
3601 else if ((p_ptr->align > 9) && (r_ptr->flags3 & RF3_EVIL))
3603 if (!one_in_(p_ptr->align/2+1)) return FALSE;
3607 /* Hack -- no specific type specified */
3608 if (!summon_specific_type) return (TRUE);
3610 if (!summon_unique_okay && ((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags7 & RF7_UNIQUE_7))) return FALSE;
3612 if ((summon_specific_who < 0) &&
3613 ((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags7 & RF7_UNIQUE_7)) &&
3614 (((p_ptr->align > 9) && (r_ptr->flags3 & RF3_EVIL)) ||
3615 ((p_ptr->align < -9) && (r_ptr->flags3 & RF3_GOOD))))
3618 if ((horde_align & HORDE_NOGOOD) && (r_ptr->flags3 & RF3_GOOD)) return FALSE;
3619 if ((horde_align & HORDE_NOEVIL) && (r_ptr->flags3 & RF3_EVIL)) return FALSE;
3621 if ((r_ptr->flags7 & RF7_CHAMELEON) && (d_info[dungeon_type].flags1 & DF1_CHAMELEON)) return TRUE;
3623 return (summon_specific_aux(r_idx));
3628 * Place a monster (of the specified "type") near the given
3629 * location. Return TRUE if a monster was actually summoned.
3631 * We will attempt to place the monster up to 10 times before giving up.
3633 * Note: SUMMON_UNIQUE and SUMMON_AMBERITES will summon Unique's
3634 * Note: SUMMON_HI_UNDEAD and SUMMON_HI_DRAGON may summon Unique's
3635 * Note: None of the other summon codes will ever summon Unique's.
3637 * This function has been changed. We now take the "monster level"
3638 * of the summoning monster as a parameter, and use that, along with
3639 * the current dungeon level, to help determine the level of the
3640 * desired monster. Note that this is an upper bound, and also
3641 * tends to "prefer" monsters of that level. Currently, we use
3642 * the average of the dungeon and monster levels, and then add
3643 * five to allow slight increases in monster power.
3645 * Note that we use the new "monster allocation table" creation code
3646 * to restrict the "get_mon_num()" function to the set of "legal"
3647 * monsters, making this function much faster and more reliable.
3649 * Note that this function may not succeed, though this is very rare.
3651 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)
3655 bool no_kage = FALSE;
3657 if (p_ptr->inside_arena) return (FALSE);
3659 if (!mon_scatter(&y, &x, y1, x1, 2)) return FALSE;
3661 /* Save the summoner */
3662 summon_specific_who = who;
3664 /* Save the "summon" type */
3665 summon_specific_type = type;
3667 summon_unique_okay = unique_okay;
3669 /* Save the hostility */
3670 summon_specific_hostile = (!friendly && !pet);
3672 /* Prepare allocation table */
3673 get_mon_num_prep(summon_specific_okay, get_monster_hook2(y, x));
3675 /* Pick a monster, using the level calculation */
3676 r_idx = get_mon_num((dun_level + lev) / 2 + 5);
3678 /* Handle failure */
3681 summon_specific_type = 0;
3685 if ((type == SUMMON_BLUE_HORROR) || (type == SUMMON_DAWN)) no_kage = TRUE;
3687 /* Attempt to place the monster (awake, allow groups) */
3688 if (!place_monster_aux(y, x, r_idx, FALSE, group, friendly, pet, no_kage, no_pet))
3690 summon_specific_type = 0;
3694 summon_specific_type = 0;
3699 /* A "dangerous" function, creates a pet of the specified type */
3700 bool summon_named_creature (int oy, int ox, int r_idx, bool slp, bool group_ok, bool friendly, bool pet)
3705 /* if (!r_idx) return; */
3707 /* Prevent illegal monsters */
3708 if (r_idx >= max_r_idx) return FALSE;
3710 if (p_ptr->inside_arena) return FALSE;
3712 if (!mon_scatter(&y, &x, oy, ox, 2)) return FALSE;
3714 /* Place it (allow groups) */
3715 return place_monster_aux(y, x, r_idx, slp, group_ok, friendly, pet, TRUE, FALSE);
3720 * Let the given monster attempt to reproduce.
3722 * Note that "reproduction" REQUIRES empty space.
3724 bool multiply_monster(int m_idx, bool clone, bool friendly, bool pet)
3726 monster_type *m_ptr = &m_list[m_idx];
3730 if (!mon_scatter(&y, &x, m_ptr->fy, m_ptr->fx, 1))
3733 /* Create a new monster (awake, no groups) */
3734 if (!place_monster_aux(y, x, m_ptr->r_idx, FALSE, FALSE, friendly, pet, TRUE, (bool)(m_ptr->mflag2 & MFLAG_NOPET)))
3739 m_list[hack_m_idx_ii].smart |= SM_CLONED;
3740 m_list[hack_m_idx_ii].mflag2 |= MFLAG_NOPET;
3751 * Dump a message describing a monster's reaction to damage
3753 * Technically should attempt to treat "Beholder"'s as jelly's
3755 void message_pain(int m_idx, int dam)
3757 long oldhp, newhp, tmp;
3760 monster_type *m_ptr = &m_list[m_idx];
3761 monster_race *r_ptr = &r_info[m_ptr->r_idx];
3766 /* Get the monster name */
3767 monster_desc(m_name, m_ptr, 0);
3769 /* Notice non-damage */
3773 msg_format("%^s¤Ï¥À¥á¡¼¥¸¤ò¼õ¤±¤Æ¤¤¤Ê¤¤¡£", m_name);
3775 msg_format("%^s is unharmed.", m_name);
3781 /* Note -- subtle fix -CFT */
3782 newhp = (long)(m_ptr->hp);
3783 oldhp = newhp + (long)(dam);
3784 tmp = (newhp * 100L) / oldhp;
3785 percentage = (int)(tmp);
3788 /* Mushrooms, Eyes, Jellies, Molds, Vortices, Worms, Quylthulgs */
3789 if (strchr(",ejmvwQ", r_ptr->d_char))
3792 if (percentage > 95)
3793 msg_format("%^s¤Ï¤Û¤È¤ó¤Éµ¤¤Ë¤È¤á¤Æ¤¤¤Ê¤¤¡£", m_name);
3794 else if (percentage > 75)
3795 msg_format("%^s¤Ï¤·¤ê¹þ¤ß¤·¤¿¡£", m_name);
3796 else if (percentage > 50)
3797 msg_format("%^s¤Ï½Ì¤³¤Þ¤Ã¤¿¡£", m_name);
3798 else if (percentage > 35)
3799 msg_format("%^s¤ÏÄˤߤ˿̤¨¤¿¡£", m_name);
3800 else if (percentage > 20)
3801 msg_format("%^s¤Ï¿È¤â¤À¤¨¤·¤¿¡£", m_name);
3802 else if (percentage > 10)
3803 msg_format("%^s¤Ï¶ìÄˤǿȤâ¤À¤¨¤·¤¿¡£", m_name);
3805 msg_format("%^s¤Ï¤°¤Ë¤ã¤°¤Ë¤ã¤ÈáÛÚ»¤·¤¿¡£", m_name);
3807 if (percentage > 95)
3808 msg_format("%^s barely notices.", m_name);
3809 else if (percentage > 75)
3810 msg_format("%^s flinches.", m_name);
3811 else if (percentage > 50)
3812 msg_format("%^s squelches.", m_name);
3813 else if (percentage > 35)
3814 msg_format("%^s quivers in pain.", m_name);
3815 else if (percentage > 20)
3816 msg_format("%^s writhes about.", m_name);
3817 else if (percentage > 10)
3818 msg_format("%^s writhes in agony.", m_name);
3820 msg_format("%^s jerks limply.", m_name);
3827 else if (strchr("l", r_ptr->d_char))
3829 if (percentage > 95)
3831 msg_format("%^s¤Ï¤Û¤È¤ó¤Éµ¤¤Ë¤È¤á¤Æ¤¤¤Ê¤¤¡£", m_name);
3833 msg_format("%^s barely notices.", m_name);
3835 else if (percentage > 75)
3837 msg_format("%^s¤Ï¤·¤ê¹þ¤ß¤·¤¿¡£", m_name);
3839 msg_format("%^s flinches.", m_name);
3841 else if (percentage > 50)
3843 msg_format("%^s¤Ïí´í°¤·¤¿¡£", m_name);
3845 msg_format("%^s hesitates.", m_name);
3847 else if (percentage > 35)
3849 msg_format("%^s¤ÏÄˤߤ˿̤¨¤¿¡£", m_name);
3851 msg_format("%^s quivers in pain.", m_name);
3853 else if (percentage > 20)
3855 msg_format("%^s¤Ï¿È¤â¤À¤¨¤·¤¿¡£", m_name);
3857 msg_format("%^s writhes about.", m_name);
3859 else if (percentage > 10)
3861 msg_format("%^s¤Ï¶ìÄˤǿȤâ¤À¤¨¤·¤¿¡£", m_name);
3863 msg_format("%^s writhes in agony.", m_name);
3867 msg_format("%^s¤Ï¤°¤Ë¤ã¤°¤Ë¤ã¤ÈáÛÚ»¤·¤¿¡£", m_name);
3869 msg_format("%^s jerks limply.", m_name);
3874 /* Golems, Walls, Doors, Stairs */
3875 else if (strchr("g#+<>", r_ptr->d_char))
3877 if (percentage > 95)
3879 msg_format("%s¤Ï¹¶·â¤òµ¤¤Ë¤È¤á¤Æ¤¤¤Ê¤¤¡£", m_name);
3881 msg_format("%^s ignores the attack.", m_name);
3883 else if (percentage > 75)
3885 msg_format("%s¤Ï¹¶·â¤Ë¸ª¤ò¤¹¤¯¤á¤¿¡£", m_name);
3887 msg_format("%^s shrugs off the attack.", m_name);
3889 else if (percentage > 50)
3891 msg_format("%^s¤ÏÍëÌĤΤ褦¤ËËʤ¨¤¿¡£", m_name);
3893 msg_format("%^s roars thunderously.", m_name);
3895 else if (percentage > 35)
3897 msg_format("%^s¤Ï¶ì¤·¤²¤ËËʤ¨¤¿¡£", m_name);
3899 msg_format("%^s rumbles.", m_name);
3901 else if (percentage > 20)
3903 msg_format("%^s¤Ï¤¦¤á¤¤¤¿¡£", m_name);
3905 msg_format("%^s grunts.", m_name);
3907 else if (percentage > 10)
3909 msg_format("%^s¤Ïí´í°¤·¤¿¡£", m_name);
3911 msg_format("%^s hesitates.", m_name);
3915 msg_format("%^s¤Ï¤¯¤·¤ã¤¯¤·¤ã¤Ë¤Ê¤Ã¤¿¡£", m_name);
3917 msg_format("%^s crumples.", m_name);
3922 /* Snakes, Hydrae, Reptiles, Mimics */
3923 else if (strchr("JMR", r_ptr->d_char) || !isalpha(r_ptr->d_char))
3925 if (percentage > 95)
3927 msg_format("%^s¤Ï¤Û¤È¤ó¤Éµ¤¤Ë¤È¤á¤Æ¤¤¤Ê¤¤¡£", m_name);
3929 msg_format("%^s barely notices.", m_name);
3931 else if (percentage > 75)
3933 msg_format("%^s¤Ï¥·¡¼¥Ã¤ÈÌĤ¤¤¿¡£", m_name);
3935 msg_format("%^s hisses.", m_name);
3937 else if (percentage > 50)
3939 msg_format("%^s¤ÏÅܤäÆƬ¤ò¾å¤²¤¿¡£", m_name);
3941 msg_format("%^s rears up in anger.", m_name);
3943 else if (percentage > 35)
3945 msg_format("%^s¤ÏÌÔÁ³¤È°Ò³Å¤·¤¿¡£", m_name);
3947 msg_format("%^s hisses furiously.", m_name);
3949 else if (percentage > 20)
3951 msg_format("%^s¤Ï¿È¤â¤À¤¨¤·¤¿¡£", m_name);
3953 msg_format("%^s writhes about.", m_name);
3955 else if (percentage > 10)
3957 msg_format("%^s¤Ï¶ìÄˤǿȤâ¤À¤¨¤·¤¿¡£", m_name);
3959 msg_format("%^s writhes in agony.", m_name);
3963 msg_format("%^s¤Ï¤°¤Ë¤ã¤°¤Ë¤ã¤ÈáÛÚ»¤·¤¿¡£", m_name);
3965 msg_format("%^s jerks limply.", m_name);
3971 else if (strchr("f", r_ptr->d_char))
3973 if (percentage > 95)
3975 msg_format("%s¤Ï¹¶·â¤Ë¸ª¤ò¤¹¤¯¤á¤¿¡£", m_name);
3977 msg_format("%^s shrugs off the attack.", m_name);
3979 else if (percentage > 75)
3981 msg_format("%^s¤ÏËʤ¨¤¿¡£", m_name);
3983 msg_format("%^s roars.", m_name);
3985 else if (percentage > 50)
3987 msg_format("%^s¤ÏÅܤäÆËʤ¨¤¿¡£", m_name);
3989 msg_format("%^s growls angrily.", m_name);
3991 else if (percentage > 35)
3993 msg_format("%^s¤ÏÄˤߤǥ·¡¼¥Ã¤ÈÌĤ¤¤¿¡£", m_name);
3995 msg_format("%^s hisses with pain.", m_name);
3997 else if (percentage > 20)
3999 msg_format("%^s¤ÏÄˤߤǼ塹¤·¤¯ÌĤ¤¤¿¡£", m_name);
4001 msg_format("%^s mewls in pain.", m_name);
4003 else if (percentage > 10)
4005 msg_format("%^s¤Ï¶ìÄˤˤ¦¤á¤¤¤¿¡£", m_name);
4007 msg_format("%^s hisses in agony.", m_name);
4011 msg_format("%s¤Ï°¥¤ì¤ÊÌĤÀ¼¤ò½Ð¤·¤¿¡£", m_name);
4013 msg_format("%^s mewls pitifully.", m_name);
4018 /* Ants, Centipedes, Flies, Insects, Beetles, Spiders */
4019 else if (strchr("acFIKS", r_ptr->d_char))
4021 if (percentage > 95)
4023 msg_format("%s¤Ï¹¶·â¤òµ¤¤Ë¤È¤á¤Æ¤¤¤Ê¤¤¡£", m_name);
4025 msg_format("%^s ignores the attack.", m_name);
4027 else if (percentage > 75)
4029 msg_format("%^s¤Ï¥¡¼¥¡¼ÌĤ¤¤¿¡£", m_name);
4031 msg_format("%^s chitters.", m_name);
4034 else if (percentage > 50)
4036 msg_format("%^s¤Ï¥è¥í¥è¥íƨ¤²²ó¤Ã¤¿¡£", m_name);
4038 msg_format("%^s scuttles about.", m_name);
4041 else if (percentage > 35)
4043 msg_format("%^s¤Ï¤¦¤ë¤µ¤¯ÌĤ¤¤¿¡£", m_name);
4045 msg_format("%^s twitters.", m_name);
4048 else if (percentage > 20)
4050 msg_format("%^s¤ÏÄˤߤËáÛÚ»¤·¤¿¡£", m_name);
4052 msg_format("%^s jerks in pain.", m_name);
4055 else if (percentage > 10)
4057 msg_format("%^s¤Ï¶ìÄˤÇáÛÚ»¤·¤¿¡£", m_name);
4059 msg_format("%^s jerks in agony.", m_name);
4064 msg_format("%^s¤Ï¥Ô¥¯¥Ô¥¯¤Ò¤¤Ä¤Ã¤¿¡£", m_name);
4066 msg_format("%^s twitches.", m_name);
4073 else if (strchr("B", r_ptr->d_char))
4075 if (percentage > 95)
4077 msg_format("%^s¤Ï¤µ¤¨¤º¤Ã¤¿¡£", m_name);
4079 msg_format("%^s chirps.", m_name);
4082 else if (percentage > 75)
4084 msg_format("%^s¤Ï¥Ô¡¼¥Ô¡¼ÌĤ¤¤¿¡£", m_name);
4086 msg_format("%^s twitters.", m_name);
4089 else if (percentage > 50)
4091 msg_format("%^s¤Ï¥®¥ã¡¼¥®¥ã¡¼ÌĤ¤¤¿¡£", m_name);
4093 msg_format("%^s squawks.", m_name);
4096 else if (percentage > 35)
4098 msg_format("%^s¤Ï¥®¥ã¡¼¥®¥ã¡¼ÌĤ¤ï¤á¤¤¤¿¡£", m_name);
4100 msg_format("%^s chatters.", m_name);
4103 else if (percentage > 20)
4105 msg_format("%^s¤Ï¶ì¤·¤ó¤À¡£", m_name);
4107 msg_format("%^s jeers.", m_name);
4110 else if (percentage > 10)
4112 msg_format("%^s¤Ï¤Î¤¿¤¦¤Á²ó¤Ã¤¿¡£", m_name);
4114 msg_format("%^s flutters about.", m_name);
4119 msg_format("%^s¤Ï¥¡¼¥¡¼¤ÈÌĤ¶«¤ó¤À¡£", m_name);
4121 msg_format("%^s squeaks.", m_name);
4127 /* Dragons, Demons, High Undead */
4128 else if (strchr("duDLUW", r_ptr->d_char))
4130 if (percentage > 95)
4132 msg_format("%s¤Ï¹¶·â¤òµ¤¤Ë¤È¤á¤Æ¤¤¤Ê¤¤¡£", m_name);
4134 msg_format("%^s ignores the attack.", m_name);
4137 else if (percentage > 75)
4139 msg_format("%^s¤Ï¤·¤ê¹þ¤ß¤·¤¿¡£", m_name);
4141 msg_format("%^s flinches.", m_name);
4144 else if (percentage > 50)
4146 msg_format("%^s¤ÏÄˤߤǥ·¡¼¥Ã¤ÈÌĤ¤¤¿¡£", m_name);
4148 msg_format("%^s hisses in pain.", m_name);
4151 else if (percentage > 35)
4153 msg_format("%^s¤ÏÄˤߤǤ¦¤Ê¤Ã¤¿¡£", m_name);
4155 msg_format("%^s snarls with pain.", m_name);
4158 else if (percentage > 20)
4160 msg_format("%^s¤ÏÄˤߤËËʤ¨¤¿¡£", m_name);
4162 msg_format("%^s roars with pain.", m_name);
4165 else if (percentage > 10)
4167 msg_format("%^s¤Ï¶ì¤·¤²¤Ë¶«¤ó¤À¡£", m_name);
4169 msg_format("%^s gasps.", m_name);
4174 msg_format("%^s¤Ï¼å¡¹¤·¤¯¤¦¤Ê¤Ã¤¿¡£", m_name);
4176 msg_format("%^s snarls feebly.", m_name);
4183 else if (strchr("s", r_ptr->d_char))
4185 if (percentage > 95)
4187 msg_format("%s¤Ï¹¶·â¤òµ¤¤Ë¤È¤á¤Æ¤¤¤Ê¤¤¡£", m_name);
4189 msg_format("%^s ignores the attack.", m_name);
4192 else if (percentage > 75)
4194 msg_format("%s¤Ï¹¶·â¤Ë¸ª¤ò¤¹¤¯¤á¤¿¡£", m_name);
4196 msg_format("%^s shrugs off the attack.", m_name);
4199 else if (percentage > 50)
4201 msg_format("%^s¤Ï¥«¥¿¥«¥¿¤È¾Ð¤Ã¤¿¡£", m_name);
4203 msg_format("%^s rattles.", m_name);
4206 else if (percentage > 35)
4208 msg_format("%^s¤Ï¤è¤í¤á¤¤¤¿¡£", m_name);
4210 msg_format("%^s stumbles.", m_name);
4213 else if (percentage > 20)
4215 msg_format("%^s¤Ï¥«¥¿¥«¥¿¸À¤Ã¤¿¡£", m_name);
4217 msg_format("%^s rattles.", m_name);
4220 else if (percentage > 10)
4222 msg_format("%^s¤Ï¤è¤í¤á¤¤¤¿¡£", m_name);
4224 msg_format("%^s staggers.", m_name);
4229 msg_format("%^s¤Ï¥¬¥¿¥¬¥¿¸À¤Ã¤¿¡£", m_name);
4231 msg_format("%^s clatters.", m_name);
4238 else if (strchr("z", r_ptr->d_char))
4240 if (percentage > 95)
4242 msg_format("%s¤Ï¹¶·â¤òµ¤¤Ë¤È¤á¤Æ¤¤¤Ê¤¤¡£", m_name);
4244 msg_format("%^s ignores the attack.", m_name);
4247 else if (percentage > 75)
4249 msg_format("%s¤Ï¹¶·â¤Ë¸ª¤ò¤¹¤¯¤á¤¿¡£", m_name);
4251 msg_format("%^s shrugs off the attack.", m_name);
4254 else if (percentage > 50)
4256 msg_format("%^s¤Ï¤¦¤á¤¤¤¿¡£", m_name);
4258 msg_format("%^s groans.", m_name);
4261 else if (percentage > 35)
4263 msg_format("%s¤Ï¶ì¤·¤²¤Ë¤¦¤á¤¤¤¿¡£", m_name);
4265 msg_format("%^s moans.", m_name);
4268 else if (percentage > 20)
4270 msg_format("%^s¤Ïí´í°¤·¤¿¡£", m_name);
4272 msg_format("%^s hesitates.", m_name);
4275 else if (percentage > 10)
4277 msg_format("%^s¤Ï¤¦¤Ê¤Ã¤¿¡£", m_name);
4279 msg_format("%^s grunts.", m_name);
4284 msg_format("%^s¤Ï¤è¤í¤á¤¤¤¿¡£", m_name);
4286 msg_format("%^s staggers.", m_name);
4293 else if (strchr("G", r_ptr->d_char))
4296 if (percentage > 95)
4298 msg_format("%s¤Ï¹¶·â¤òµ¤¤Ë¤È¤á¤Æ¤¤¤Ê¤¤¡£", m_name);
4300 msg_format("%^s ignores the attack.", m_name);
4303 else if (percentage > 75)
4305 msg_format("%s¤Ï¹¶·â¤Ë¸ª¤ò¤¹¤¯¤á¤¿¡£", m_name);
4307 msg_format("%^s shrugs off the attack.", m_name);
4310 else if (percentage > 50)
4312 msg_format("%s¤Ï¤¦¤á¤¤¤¿¡£", m_name);
4314 msg_format("%^s moans.", m_name);
4317 else if (percentage > 35)
4319 msg_format("%^s¤Ïµã¤¤ï¤á¤¤¤¿¡£", m_name);
4321 msg_format("%^s wails.", m_name);
4324 else if (percentage > 20)
4326 msg_format("%^s¤ÏËʤ¨¤¿¡£", m_name);
4328 msg_format("%^s howls.", m_name);
4331 else if (percentage > 10)
4333 msg_format("%s¤Ï¼å¡¹¤·¤¯¤¦¤á¤¤¤¿¡£", m_name);
4335 msg_format("%^s moans softly.", m_name);
4340 msg_format("%^s¤Ï¤«¤¹¤«¤Ë¤¦¤á¤¤¤¿¡£", m_name);
4342 msg_format("%^s sighs.", m_name);
4348 /* Dogs and Hounds */
4349 else if (strchr("CZ", r_ptr->d_char))
4352 if (percentage > 95)
4353 msg_format("%^s¤Ï¹¶·â¤Ë¸ª¤ò¤¹¤¯¤á¤¿¡£", m_name);
4354 else if (percentage > 75)
4355 msg_format("%^s¤ÏÄˤߤǤ¦¤Ê¤Ã¤¿¡£", m_name);
4356 else if (percentage > 50)
4357 msg_format("%^s¤ÏÄˤߤǥ¥ã¥ó¥¥ã¥óËʤ¨¤¿¡£", m_name);
4358 else if (percentage > 35)
4359 msg_format("%^s¤ÏÄˤߤÇÌĤ¤ï¤á¤¤¤¿¡£", m_name);
4360 else if (percentage > 20)
4361 msg_format("%^s¤Ï¶ìÄˤΤ¢¤Þ¤êÌĤ¤ï¤á¤¤¤¿¡£", m_name);
4362 else if (percentage > 10)
4363 msg_format("%^s¤Ï¶ìÄˤǤâ¤À¤¨¶ì¤·¤ó¤À¡£", m_name);
4365 msg_format("%^s¤Ï¼å¡¹¤·¤¯Ëʤ¨¤¿¡£", m_name);
4367 if (percentage > 95)
4368 msg_format("%^s shrugs off the attack.", m_name);
4369 else if (percentage > 75)
4370 msg_format("%^s snarls with pain.", m_name);
4371 else if (percentage > 50)
4372 msg_format("%^s yelps in pain.", m_name);
4373 else if (percentage > 35)
4374 msg_format("%^s howls in pain.", m_name);
4375 else if (percentage > 20)
4376 msg_format("%^s howls in agony.", m_name);
4377 else if (percentage > 10)
4378 msg_format("%^s writhes in agony.", m_name);
4380 msg_format("%^s yelps feebly.", m_name);
4385 /* One type of monsters (ignore,squeal,shriek) */
4386 else if (strchr("Xbilqrt", r_ptr->d_char))
4389 if (percentage > 95)
4390 msg_format("%^s¤Ï¹¶·â¤òµ¤¤Ë¤È¤á¤Æ¤¤¤Ê¤¤¡£", m_name);
4391 else if (percentage > 75)
4392 msg_format("%^s¤ÏÄˤߤǤ¦¤Ê¤Ã¤¿¡£", m_name);
4393 else if (percentage > 50)
4394 msg_format("%^s¤ÏÄˤߤǶ«¤ó¤À¡£", m_name);
4395 else if (percentage > 35)
4396 msg_format("%^s¤ÏÄˤߤÇÀ䶫¤·¤¿¡£", m_name);
4397 else if (percentage > 20)
4398 msg_format("%^s¤Ï¶ìÄˤΤ¢¤Þ¤êÀ䶫¤·¤¿¡£", m_name);
4399 else if (percentage > 10)
4400 msg_format("%^s¤Ï¶ìÄˤǤâ¤À¤¨¶ì¤·¤ó¤À¡£", m_name);
4402 msg_format("%^s¤Ï¼å¡¹¤·¤¯¶«¤ó¤À¡£", m_name);
4404 if (percentage > 95)
4405 msg_format("%^s ignores the attack.", m_name);
4406 else if (percentage > 75)
4407 msg_format("%^s grunts with pain.", m_name);
4408 else if (percentage > 50)
4409 msg_format("%^s squeals in pain.", m_name);
4410 else if (percentage > 35)
4411 msg_format("%^s shrieks in pain.", m_name);
4412 else if (percentage > 20)
4413 msg_format("%^s shrieks in agony.", m_name);
4414 else if (percentage > 10)
4415 msg_format("%^s writhes in agony.", m_name);
4417 msg_format("%^s cries out feebly.", m_name);
4422 /* Another type of monsters (shrug,cry,scream) */
4426 if (percentage > 95)
4427 msg_format("%^s¤Ï¹¶·â¤Ë¸ª¤ò¤¹¤¯¤á¤¿¡£", m_name);
4428 else if (percentage > 75)
4429 msg_format("%^s¤ÏÄˤߤǤ¦¤Ê¤Ã¤¿¡£", m_name);
4430 else if (percentage > 50)
4431 msg_format("%^s¤ÏÄˤߤǶ«¤ó¤À¡£", m_name);
4432 else if (percentage > 35)
4433 msg_format("%^s¤ÏÄˤߤÇÀ䶫¤·¤¿¡£", m_name);
4434 else if (percentage > 20)
4435 msg_format("%^s¤Ï¶ìÄˤΤ¢¤Þ¤êÀ䶫¤·¤¿¡£", m_name);
4436 else if (percentage > 10)
4437 msg_format("%^s¤Ï¶ìÄˤǤâ¤À¤¨¶ì¤·¤ó¤À¡£", m_name);
4439 msg_format("%^s¤Ï¼å¡¹¤·¤¯¶«¤ó¤À¡£", m_name);
4441 if (percentage > 95)
4442 msg_format("%^s shrugs off the attack.", m_name);
4443 else if (percentage > 75)
4444 msg_format("%^s grunts with pain.", m_name);
4445 else if (percentage > 50)
4446 msg_format("%^s cries out in pain.", m_name);
4447 else if (percentage > 35)
4448 msg_format("%^s screams in pain.", m_name);
4449 else if (percentage > 20)
4450 msg_format("%^s screams in agony.", m_name);
4451 else if (percentage > 10)
4452 msg_format("%^s writhes in agony.", m_name);
4454 msg_format("%^s cries out feebly.", m_name);
4462 * Learn about an "observed" resistance.
4464 void update_smart_learn(int m_idx, int what)
4466 #ifdef DRS_SMART_OPTIONS
4468 monster_type *m_ptr = &m_list[m_idx];
4470 monster_race *r_ptr = &r_info[m_ptr->r_idx];
4473 /* Not allowed to learn */
4474 if (!smart_learn) return;
4476 /* Too stupid to learn anything */
4477 if (r_ptr->flags2 & (RF2_STUPID)) return;
4479 /* Not intelligent, only learn sometimes */
4480 if (!(r_ptr->flags2 & (RF2_SMART)) && (randint0(100) < 50)) return;
4485 /* Analyze the knowledge */
4489 if (p_ptr->resist_acid) m_ptr->smart |= (SM_RES_ACID);
4490 if (p_ptr->oppose_acid) m_ptr->smart |= (SM_OPP_ACID);
4491 if (p_ptr->immune_acid) m_ptr->smart |= (SM_IMM_ACID);
4495 if (p_ptr->resist_elec) m_ptr->smart |= (SM_RES_ELEC);
4496 if (p_ptr->oppose_elec) m_ptr->smart |= (SM_OPP_ELEC);
4497 if (p_ptr->immune_elec) m_ptr->smart |= (SM_IMM_ELEC);
4501 if (p_ptr->resist_fire) m_ptr->smart |= (SM_RES_FIRE);
4502 if (p_ptr->oppose_fire) m_ptr->smart |= (SM_OPP_FIRE);
4503 if (p_ptr->immune_fire) m_ptr->smart |= (SM_IMM_FIRE);
4507 if (p_ptr->resist_cold) m_ptr->smart |= (SM_RES_COLD);
4508 if (p_ptr->oppose_cold) m_ptr->smart |= (SM_OPP_COLD);
4509 if (p_ptr->immune_cold) m_ptr->smart |= (SM_IMM_COLD);
4513 if (p_ptr->resist_pois) m_ptr->smart |= (SM_RES_POIS);
4514 if (p_ptr->oppose_pois) m_ptr->smart |= (SM_OPP_POIS);
4519 if (p_ptr->resist_neth) m_ptr->smart |= (SM_RES_NETH);
4523 if (p_ptr->resist_lite) m_ptr->smart |= (SM_RES_LITE);
4527 if (p_ptr->resist_dark) m_ptr->smart |= (SM_RES_DARK);
4531 if (p_ptr->resist_fear) m_ptr->smart |= (SM_RES_FEAR);
4535 if (p_ptr->resist_conf) m_ptr->smart |= (SM_RES_CONF);
4539 if (p_ptr->resist_chaos) m_ptr->smart |= (SM_RES_CHAOS);
4543 if (p_ptr->resist_disen) m_ptr->smart |= (SM_RES_DISEN);
4547 if (p_ptr->resist_blind) m_ptr->smart |= (SM_RES_BLIND);
4551 if (p_ptr->resist_nexus) m_ptr->smart |= (SM_RES_NEXUS);
4555 if (p_ptr->resist_sound) m_ptr->smart |= (SM_RES_SOUND);
4559 if (p_ptr->resist_shard) m_ptr->smart |= (SM_RES_SHARD);
4563 if (p_ptr->free_act) m_ptr->smart |= (SM_IMM_FREE);
4567 if (!p_ptr->msp) m_ptr->smart |= (SM_IMM_MANA);
4571 if (p_ptr->reflect) m_ptr-> smart |= (SM_IMM_REFLECT);
4575 #endif /* DRS_SMART_OPTIONS */
4581 * Place the player in the dungeon XXX XXX
4583 bool player_place(int y, int x)
4585 /* Paranoia XXX XXX */
4586 if (cave[y][x].m_idx != 0) return FALSE;
4588 /* Save player location */
4598 * Drop all items carried by a monster
4600 void monster_drop_carried_objects(monster_type *m_ptr)
4602 s16b this_o_idx, next_o_idx = 0;
4608 /* Drop objects being carried */
4609 for (this_o_idx = m_ptr->hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
4611 /* Acquire object */
4612 o_ptr = &o_list[this_o_idx];
4614 /* Acquire next object */
4615 next_o_idx = o_ptr->next_o_idx;
4618 o_ptr->held_m_idx = 0;
4620 /* Get local object */
4623 /* Copy the object */
4624 object_copy(q_ptr, o_ptr);
4626 /* Delete the object */
4627 delete_object_idx(this_o_idx);
4630 (void)drop_near(q_ptr, -1, m_ptr->fy, m_ptr->fx);
4633 /* Forget objects */
4634 m_ptr->hold_o_idx = 0;