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
20 cptr horror_desc[MAX_SAN_HORROR] =
74 cptr funny_desc[MAX_SAN_FUNNY] =
89 "¥Õ¥¡¥ó¥¿¥¹¥Æ¥£¥Ã¥¯¤Ê",
134 cptr funny_comments[MAX_SAN_COMMENT] =
155 * Set the target of counter attack
157 void set_target(monster_type *m_ptr, int y, int x)
165 * Reset the target of counter attack
167 void reset_target(monster_type *m_ptr)
169 set_target(m_ptr, 0, 0);
174 * Extract monster race pointer of a monster's true form
176 monster_race *real_r_ptr(monster_type *m_ptr)
178 monster_race *r_ptr = &r_info[m_ptr->r_idx];
180 /* Extract real race */
181 if (m_ptr->mflag2 & MFLAG_CHAMELEON)
183 if (r_ptr->flags1 & RF1_UNIQUE)
184 return &r_info[MON_CHAMELEON_K];
186 return &r_info[MON_CHAMELEON];
196 * Delete a monster by index.
198 * When a monster is deleted, all of its objects are deleted.
200 void delete_monster_idx(int i)
204 monster_type *m_ptr = &m_list[i];
206 monster_race *r_ptr = &r_info[m_ptr->r_idx];
208 s16b this_o_idx, next_o_idx = 0;
216 /* Hack -- Reduce the racial counter */
217 real_r_ptr(m_ptr)->cur_num--;
219 /* Hack -- count the number of "reproducers" */
220 if (r_ptr->flags2 & (RF2_MULTIPLY)) num_repro--;
223 /* Hack -- remove target monster */
224 if (i == target_who) target_who = 0;
226 /* Hack -- remove tracked monster */
227 if (i == p_ptr->health_who) health_track(0);
229 if (pet_t_m_idx == i ) pet_t_m_idx = 0;
230 if (riding_t_m_idx == i) riding_t_m_idx = 0;
231 if (p_ptr->riding == i) p_ptr->riding = 0;
233 /* Monster is gone */
234 cave[y][x].m_idx = 0;
238 for (this_o_idx = m_ptr->hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
243 o_ptr = &o_list[this_o_idx];
245 /* Acquire next object */
246 next_o_idx = o_ptr->next_o_idx;
248 /* Hack -- efficiency */
249 o_ptr->held_m_idx = 0;
251 /* Delete the object */
252 delete_object_idx(this_o_idx);
256 /* Wipe the Monster */
257 (void)WIPE(m_ptr, monster_type);
265 /* Update some things */
266 p_ptr->update |= (PU_MON_LITE);
271 * Delete the monster, if any, at a given location
273 void delete_monster(int y, int x)
278 if (!in_bounds(y, x)) return;
283 /* Delete the monster (if any) */
284 if (c_ptr->m_idx) delete_monster_idx(c_ptr->m_idx);
289 * Move an object from index i1 to index i2 in the object list
291 static void compact_monsters_aux(int i1, int i2)
299 s16b this_o_idx, next_o_idx = 0;
303 if (i1 == i2) return;
316 /* Update the cave */
319 /* Repair objects being carried by monster */
320 for (this_o_idx = m_ptr->hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
325 o_ptr = &o_list[this_o_idx];
327 /* Acquire next object */
328 next_o_idx = o_ptr->next_o_idx;
330 /* Reset monster pointer */
331 o_ptr->held_m_idx = i2;
334 /* Hack -- Update the target */
335 if (target_who == i1) target_who = i2;
337 /* Hack -- Update the target */
338 if (pet_t_m_idx == i1) pet_t_m_idx = i2;
339 if (riding_t_m_idx == i1) riding_t_m_idx = i2;
341 /* Hack -- Update the riding */
342 if (p_ptr->riding == i1) p_ptr->riding = i2;
344 /* Hack -- Update the health bar */
345 if (p_ptr->health_who == i1) health_track(i2);
348 COPY(&m_list[i2], &m_list[i1], monster_type);
351 (void)WIPE(&m_list[i1], monster_type);
357 * Compact and Reorder the monster list
359 * This function can be very dangerous, use with caution!
361 * When actually "compacting" monsters, we base the saving throw
362 * on a combination of monster level, distance from player, and
363 * current "desperation".
365 * After "compacting" (if needed), we "reorder" the monsters into a more
366 * compact order, and we reset the allocation info, and the "live" array.
368 void compact_monsters(int size)
371 int cur_lev, cur_dis, chance;
373 /* Message (only if compacting) */
375 if (size) msg_print("¥â¥ó¥¹¥¿¡¼¾ðÊó¤ò°µ½Ì¤·¤Æ¤¤¤Þ¤¹...");
377 if (size) msg_print("Compacting monsters...");
381 /* Compact at least 'size' objects */
382 for (num = 0, cnt = 1; num < size; cnt++)
384 /* Get more vicious each iteration */
387 /* Get closer each iteration */
388 cur_dis = 5 * (20 - cnt);
390 /* Check all the monsters */
391 for (i = 1; i < m_max; i++)
393 monster_type *m_ptr = &m_list[i];
395 monster_race *r_ptr = &r_info[m_ptr->r_idx];
397 /* Paranoia -- skip "dead" monsters */
398 if (!m_ptr->r_idx) continue;
400 /* Hack -- High level monsters start out "immune" */
401 if (r_ptr->level > cur_lev) continue;
403 if (i == p_ptr->riding) continue;
405 /* Ignore nearby monsters */
406 if ((cur_dis > 0) && (m_ptr->cdis < cur_dis)) continue;
408 /* Saving throw chance */
411 /* Only compact "Quest" Monsters in emergencies */
412 if ((r_ptr->flags1 & (RF1_QUESTOR)) && (cnt < 1000)) chance = 100;
414 /* Try not to compact Unique Monsters */
415 if (r_ptr->flags1 & (RF1_UNIQUE)) chance = 100;
417 /* All monsters get a saving throw */
418 if (randint0(100) < chance) continue;
420 /* Delete the monster */
421 delete_monster_idx(i);
423 /* Count the monster */
429 /* Excise dead monsters (backwards!) */
430 for (i = m_max - 1; i >= 1; i--)
432 /* Get the i'th monster */
433 monster_type *m_ptr = &m_list[i];
435 /* Skip real monsters */
436 if (m_ptr->r_idx) continue;
438 /* Move last monster into open hole */
439 compact_monsters_aux(m_max - 1, i);
441 /* Compress "m_max" */
448 * Delete/Remove all the monsters when the player leaves the level
450 * This is an efficient method of simulating multiple calls to the
451 * "delete_monster()" function, with no visual effects.
453 void wipe_m_list(void)
457 /* Hack -- if Banor or Lupart dies, stay another dead */
458 if (!r_info[MON_BANORLUPART].max_num)
460 if (r_info[MON_BANOR].max_num)
462 r_info[MON_BANOR].max_num = 0;
463 r_info[MON_BANOR].r_pkills++;
464 if (r_info[MON_BANOR].r_tkills < MAX_SHORT) r_info[MON_BANOR].r_tkills++;
466 if (r_info[MON_LUPART].max_num)
468 r_info[MON_LUPART].max_num = 0;
469 r_info[MON_LUPART].r_pkills++;
470 if (r_info[MON_LUPART].r_tkills < MAX_SHORT) r_info[MON_LUPART].r_tkills++;
474 /* Delete all the monsters */
475 for (i = m_max - 1; i >= 1; i--)
477 monster_type *m_ptr = &m_list[i];
479 monster_race *r_ptr = &r_info[m_ptr->r_idx];
481 /* Skip dead monsters */
482 if (!m_ptr->r_idx) continue;
484 /* Mega-Hack -- preserve Unique's XXX XXX XXX */
486 /* Hack -- Reduce the racial counter */
487 real_r_ptr(m_ptr)->cur_num = 0;
489 /* Monster is gone */
490 cave[m_ptr->fy][m_ptr->fx].m_idx = 0;
492 /* Wipe the Monster */
493 (void)WIPE(m_ptr, monster_type);
503 /* Hack -- reset "reproducer" count */
506 /* Hack -- no more target */
511 /* Hack -- no more tracking */
517 * Acquires and returns the index of a "free" monster.
519 * This routine should almost never fail, but it *can* happen.
526 /* Normal allocation */
527 if (m_max < max_m_idx)
529 /* Access the next hole */
532 /* Expand the array */
538 /* Return the index */
543 /* Recycle dead monsters */
544 for (i = 1; i < m_max; i++)
548 /* Acquire monster */
551 /* Skip live monsters */
552 if (m_ptr->r_idx) continue;
557 /* Use this monster */
562 /* Warn the player (except during dungeon creation) */
564 if (character_dungeon) msg_print("¥â¥ó¥¹¥¿¡¼¤¬Â¿¤¹¤®¤ë¡ª");
566 if (character_dungeon) msg_print("Too many monsters!");
570 /* Try not to crash */
578 * Hack -- the "type" of the current "summon specific"
580 static int summon_specific_type = 0;
584 * Hack -- the index of the summoning monster
586 static int summon_specific_who = -1;
590 * Hack -- the hostility of the summoned monster
592 static bool summon_specific_hostile = TRUE;
594 static bool summon_unique_okay = FALSE;
597 static bool summon_specific_aux(int r_idx)
599 monster_race *r_ptr = &r_info[r_idx];
602 /* Check our requirements */
603 switch (summon_specific_type)
607 okay = (r_ptr->d_char == 'a');
613 okay = (r_ptr->d_char == 'S');
619 okay = ((r_ptr->d_char == 'C') || (r_ptr->d_char == 'Z'));
625 okay = (r_ptr->d_char == 'M');
631 okay = (r_ptr->d_char == 'A' && ((r_ptr->flags3 & RF3_EVIL) || (r_ptr->flags3 & RF3_GOOD)));
637 okay = (r_ptr->flags3 & RF3_DEMON);
643 okay = (r_ptr->flags3 & RF3_UNDEAD);
649 okay = (r_ptr->flags3 & RF3_DRAGON);
653 case SUMMON_HI_UNDEAD:
655 okay = ((r_ptr->d_char == 'L') ||
656 (r_ptr->d_char == 'V') ||
657 (r_ptr->d_char == 'W'));
661 case SUMMON_HI_DRAGON:
663 okay = (r_ptr->d_char == 'D');
667 case SUMMON_HI_DEMON:
669 okay = (((r_ptr->d_char == 'U') ||
670 (r_ptr->d_char == 'H') ||
671 (r_ptr->d_char == 'B')) &&
672 (r_ptr->flags3 & RF3_DEMON)) ? TRUE : FALSE;
676 case SUMMON_AMBERITES:
678 okay = (r_ptr->flags3 & (RF3_AMBERITE)) ? TRUE : FALSE;
684 okay = (r_ptr->flags1 & (RF1_UNIQUE)) ? TRUE : FALSE;
688 case SUMMON_BIZARRE1:
690 okay = (r_ptr->d_char == 'm');
693 case SUMMON_BIZARRE2:
695 okay = (r_ptr->d_char == 'b');
698 case SUMMON_BIZARRE3:
700 okay = (r_ptr->d_char == 'Q');
704 case SUMMON_BIZARRE4:
706 okay = (r_ptr->d_char == 'v');
710 case SUMMON_BIZARRE5:
712 okay = (r_ptr->d_char == '$');
716 case SUMMON_BIZARRE6:
718 okay = ((r_ptr->d_char == '!') ||
719 (r_ptr->d_char == '?') ||
720 (r_ptr->d_char == '=') ||
721 (r_ptr->d_char == '$') ||
722 (r_ptr->d_char == '|'));
728 okay = (r_ptr->d_char == 'g');
734 okay = ((r_ptr->d_char == 'U') &&
735 (r_ptr->flags4 & RF4_ROCKET));
742 okay = ((r_ptr->d_char == summon_kin_type) && (r_idx != MON_HAGURE));
748 okay = (r_idx == MON_DAWN);
754 okay = (r_ptr->flags3 & (RF3_ANIMAL));
758 case SUMMON_ANIMAL_RANGER:
760 okay = ((r_ptr->flags3 & (RF3_ANIMAL)) &&
761 (strchr("abcflqrwBCHIJKMRS", r_ptr->d_char)) &&
762 !(r_ptr->flags3 & (RF3_DRAGON)) &&
763 !(r_ptr->flags3 & (RF3_EVIL)) &&
764 !(r_ptr->flags3 & (RF3_UNDEAD)) &&
765 !(r_ptr->flags3 & (RF3_DEMON)) &&
766 !(r_ptr->flags2 & (RF2_MULTIPLY)) &&
767 !(r_ptr->flags4 || r_ptr->flags5 || r_ptr->flags6));
771 case SUMMON_HI_DRAGON_LIVING:
773 okay = ((r_ptr->d_char == 'D') &&
774 !(r_ptr->flags3 & (RF3_DEMON | RF3_UNDEAD | RF3_NONLIVING)));
780 okay = (!(r_ptr->flags3 & (RF3_DEMON | RF3_UNDEAD | RF3_NONLIVING)));
786 okay = (r_idx == MON_PHANTOM_B || r_idx == MON_PHANTOM_W);
790 case SUMMON_BLUE_HORROR:
792 okay = (r_idx == MON_BLUE_HORROR);
796 case SUMMON_ELEMENTAL:
798 okay = (r_ptr->d_char == 'E');
804 okay = (r_ptr->d_char == 'v');
810 okay = (r_ptr->d_char == 'H');
816 okay = (r_ptr->d_char == 'B');
820 case SUMMON_KAMIKAZE:
823 for (i = 0; i < 4; i++)
824 if (r_ptr->blow[i].method == RBM_EXPLODE) okay = TRUE;
828 case SUMMON_KAMIKAZE_LIVING:
832 for (i = 0; i < 4; i++)
833 if (r_ptr->blow[i].method == RBM_EXPLODE) okay = TRUE;
834 okay = (okay && (!(r_ptr->flags3 & (RF3_DEMON | RF3_UNDEAD | RF3_NONLIVING))));
840 okay = (r_idx == MON_MANES);
846 okay = (r_idx == MON_LOUSE);
850 case SUMMON_GUARDIANS:
852 okay = (r_ptr->flags7 & RF7_GUARDIAN);
858 okay = ((r_idx == MON_NOV_PALADIN) ||
859 (r_idx == MON_NOV_PALADIN_G) ||
860 (r_idx == MON_PALADIN) ||
861 (r_idx == MON_W_KNIGHT) ||
862 (r_idx == MON_ULTRA_PALADIN) ||
863 (r_idx == MON_KNI_TEMPLAR));
868 okay = (r_ptr->d_char == 'B' &&
869 (r_ptr->flags8 & RF8_WILD_MOUNTAIN) &&
870 (r_ptr->flags8 & RF8_WILD_ONLY));
873 case SUMMON_PIRANHAS:
875 okay = (r_idx == MON_PIRANHA);
881 /* Since okay is int, "return (okay);" is not correct. */
882 return (bool)(okay ? TRUE : FALSE);
886 static int chameleon_change_m_idx = 0;
890 * Some dungeon types restrict the possible monsters.
891 * Return TRUE is the monster is OK and FALSE otherwise
893 static bool restrict_monster_to_dungeon(int r_idx)
895 dungeon_info_type *d_ptr = &d_info[dungeon_type];
896 monster_race *r_ptr = &r_info[r_idx];
899 if (d_ptr->flags1 & DF1_CHAMELEON)
901 if (chameleon_change_m_idx) return TRUE;
903 if (d_ptr->flags1 & DF1_NO_MAGIC)
905 if (r_idx != MON_CHAMELEON &&
907 !(r_ptr->flags4 & RF4_NOMAGIC_MASK) &&
908 !(r_ptr->flags5 & RF5_NOMAGIC_MASK) &&
909 !(r_ptr->flags6 & RF6_NOMAGIC_MASK))
912 if (d_ptr->flags1 & DF1_NO_MELEE)
914 if (r_idx == MON_CHAMELEON) return TRUE;
915 if (!(r_ptr->flags4 & (RF4_BOLT_MASK | RF4_BEAM_MASK | RF4_BALL_MASK)) &&
916 !(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)) &&
917 !(r_ptr->flags6 & (RF6_BOLT_MASK | RF6_BEAM_MASK | RF6_BALL_MASK)))
920 if (d_ptr->flags1 & DF1_BEGINNER)
922 if (r_ptr->level > dun_level)
926 if (d_ptr->special_div == 64) return TRUE;
927 if (summon_specific_type && !(d_ptr->flags1 & DF1_CHAMELEON)) return TRUE;
929 if(d_ptr->mode == DUNGEON_MODE_AND)
933 if((d_ptr->mflags1 & r_ptr->flags1) != d_ptr->mflags1)
938 if((d_ptr->mflags2 & r_ptr->flags2) != d_ptr->mflags2)
943 if((d_ptr->mflags3 & r_ptr->flags3) != d_ptr->mflags3)
948 if((d_ptr->mflags4 & r_ptr->flags4) != d_ptr->mflags4)
953 if((d_ptr->mflags5 & r_ptr->flags5) != d_ptr->mflags5)
958 if((d_ptr->mflags6 & r_ptr->flags6) != d_ptr->mflags6)
963 if((d_ptr->mflags7 & r_ptr->flags7) != d_ptr->mflags7)
968 if((d_ptr->mflags8 & r_ptr->flags8) != d_ptr->mflags8)
973 if((d_ptr->mflags9 & r_ptr->flags9) != d_ptr->mflags9)
976 for(a = 0; a < 5; a++)
977 if(d_ptr->r_char[a] && (d_ptr->r_char[a] != r_ptr->d_char)) return FALSE;
979 else if(d_ptr->mode == DUNGEON_MODE_NAND)
981 byte ok[9 + 5], i = 0, j = 0;
986 if(d_ptr->mflags1 & r_ptr->flags1)
992 if(d_ptr->mflags2 & r_ptr->flags2)
998 if(d_ptr->mflags3 & r_ptr->flags3)
1004 if(d_ptr->mflags4 & r_ptr->flags4)
1010 if(d_ptr->mflags5 & r_ptr->flags5)
1016 if(d_ptr->mflags6 & r_ptr->flags6)
1022 if(d_ptr->mflags7 & r_ptr->flags7)
1028 if(d_ptr->mflags8 & r_ptr->flags8)
1034 if(d_ptr->mflags9 & r_ptr->flags9)
1038 for(a = 0; a < 5; a++)
1040 if(d_ptr->r_char[a])
1043 if (d_ptr->r_char[a] != r_ptr->d_char) ok[9 + a] = 1;
1047 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];
1049 if(i == j) return FALSE;
1051 else if(d_ptr->mode == DUNGEON_MODE_OR)
1056 for(i = 0; i < 32; i++)
1058 flag = d_ptr->mflags1 & (1 << i);
1059 if(r_ptr->flags1 & flag) ok = TRUE;
1061 flag = d_ptr->mflags2 & (1 << i);
1062 if(r_ptr->flags2 & flag) ok = TRUE;
1064 flag = d_ptr->mflags3 & (1 << i);
1065 if(r_ptr->flags3 & flag) ok = TRUE;
1067 flag = d_ptr->mflags4 & (1 << i);
1068 if(r_ptr->flags4 & flag) ok = TRUE;
1070 flag = d_ptr->mflags5 & (1 << i);
1071 if(r_ptr->flags5 & flag) ok = TRUE;
1073 flag = d_ptr->mflags6 & (1 << i);
1074 if(r_ptr->flags6 & flag) ok = TRUE;
1076 flag = d_ptr->mflags7 & (1 << i);
1077 if(r_ptr->flags7 & flag) ok = TRUE;
1079 flag = d_ptr->mflags8 & (1 << i);
1080 if(r_ptr->flags8 & flag) ok = TRUE;
1082 flag = d_ptr->mflags9 & (1 << i);
1083 if(r_ptr->flags9 & flag) ok = TRUE;
1085 for(a = 0; a < 5; a++)
1086 if(d_ptr->r_char[a] == r_ptr->d_char) ok = TRUE;
1090 else if(d_ptr->mode == DUNGEON_MODE_NOR)
1095 for(i = 0; i < 32; i++)
1097 flag = d_ptr->mflags1 & (1 << i);
1098 if(r_ptr->flags1 & flag) ok = FALSE;
1100 flag = d_ptr->mflags2 & (1 << i);
1101 if(r_ptr->flags2 & flag) ok = FALSE;
1103 flag = d_ptr->mflags3 & (1 << i);
1104 if(r_ptr->flags3 & flag) ok = FALSE;
1106 flag = d_ptr->mflags4 & (1 << i);
1107 if(r_ptr->flags4 & flag) ok = FALSE;
1109 flag = d_ptr->mflags5 & (1 << i);
1110 if(r_ptr->flags5 & flag) ok = FALSE;
1112 flag = d_ptr->mflags6 & (1 << i);
1113 if(r_ptr->flags6 & flag) ok = FALSE;
1115 flag = d_ptr->mflags7 & (1 << i);
1116 if(r_ptr->flags7 & flag) ok = FALSE;
1118 flag = d_ptr->mflags8 & (1 << i);
1119 if(r_ptr->flags8 & flag) ok = FALSE;
1121 flag = d_ptr->mflags9 & (1 << i);
1122 if(r_ptr->flags9 & flag) ok = FALSE;
1124 for(a = 0; a < 5; a++)
1125 if(d_ptr->r_char[a] == r_ptr->d_char) ok = FALSE;
1133 * Apply a "monster restriction function" to the "monster allocation table"
1135 errr get_mon_num_prep(monster_hook_type monster_hook,
1136 monster_hook_type monster_hook2)
1140 /* Todo: Check the hooks for non-changes */
1142 /* Set the new hooks */
1143 get_mon_num_hook = monster_hook;
1144 get_mon_num2_hook = monster_hook2;
1146 /* Scan the allocation table */
1147 for (i = 0; i < alloc_race_size; i++)
1149 monster_race *r_ptr;
1152 alloc_entry *entry = &alloc_race_table[i];
1155 r_ptr = &r_info[entry->index];
1157 /* Skip monsters which don't pass the restriction */
1158 if ((get_mon_num_hook && !((*get_mon_num_hook)(entry->index))) ||
1159 (get_mon_num2_hook && !((*get_mon_num2_hook)(entry->index))))
1162 if (!p_ptr->inside_battle && !chameleon_change_m_idx &&
1163 summon_specific_type != SUMMON_GUARDIANS)
1165 /* Hack -- don't create questors */
1166 if (r_ptr->flags1 & RF1_QUESTOR)
1169 if (r_ptr->flags7 & RF7_GUARDIAN)
1172 /* Depth Monsters never appear out of depth */
1173 if ((r_ptr->flags1 & (RF1_FORCE_DEPTH)) &&
1174 (r_ptr->level > dun_level))
1178 /* Accept this monster */
1179 entry->prob2 = entry->prob1;
1181 if (dun_level && (!p_ptr->inside_quest || p_ptr->inside_quest < MIN_RANDOM_QUEST) && !restrict_monster_to_dungeon(entry->index) && !p_ptr->inside_battle)
1183 int hoge = entry->prob2 * d_info[dungeon_type].special_div;
1184 entry->prob2 = hoge / 64;
1185 if (randint0(64) < (hoge & 0x3f)) entry->prob2++;
1194 static int mysqrt(int n)
1232 * Choose a monster race that seems "appropriate" to the given level
1234 * This function uses the "prob2" field of the "monster allocation table",
1235 * and various local information, to calculate the "prob3" field of the
1236 * same table, which is then used to choose an "appropriate" monster, in
1237 * a relatively efficient manner.
1239 * Note that "town" monsters will *only* be created in the town, and
1240 * "normal" monsters will *never* be created in the town, unless the
1241 * "level" is "modified", for example, by polymorph or summoning.
1243 * There is a small chance (1/50) of "boosting" the given depth by
1244 * a small amount (up to four levels), except in the town.
1246 * It is (slightly) more likely to acquire a monster of the given level
1247 * than one of a lower level. This is done by choosing several monsters
1248 * appropriate to the given level and keeping the "hardest" one.
1250 * Note that if no monsters are "appropriate", then this function will
1251 * fail, and return zero, but this should *almost* never happen.
1253 s16b get_mon_num(int level)
1261 monster_race *r_ptr;
1263 alloc_entry *table = alloc_race_table;
1265 int pls_kakuritu, pls_level;
1266 int hoge=mysqrt(level*10000L);
1268 if (level > MAX_DEPTH - 1) level = MAX_DEPTH - 1;
1270 if ((dungeon_turn > hoge*(TURNS_PER_TICK*500L)) && !level)
1272 pls_kakuritu = MAX(2, NASTY_MON-((dungeon_turn/(TURNS_PER_TICK*2500L)-hoge/10)));
1273 pls_level = MIN(8,3 + dungeon_turn/(TURNS_PER_TICK*20000L)-hoge/40);
1277 pls_kakuritu = NASTY_MON;
1281 if (d_info[dungeon_type].flags1 & DF1_MAZE)
1283 pls_kakuritu = MIN(pls_kakuritu/2, pls_kakuritu-10);
1284 if (pls_kakuritu < 2) pls_kakuritu = 2;
1289 /* Boost the level */
1290 if ((level > 0) && !p_ptr->inside_battle && !(d_info[dungeon_type].flags1 & DF1_BEGINNER))
1292 /* Nightmare mode allows more out-of depth monsters */
1293 if (ironman_nightmare && !randint0(pls_kakuritu))
1295 /* What a bizarre calculation */
1296 level = 1 + (level * MAX_DEPTH / randint1(MAX_DEPTH));
1300 /* Occasional "nasty" monster */
1301 if (!randint0(pls_kakuritu))
1303 /* Pick a level bonus */
1304 int d = MIN(5, level/10) + pls_level;
1306 /* Boost the level */
1310 /* Occasional "nasty" monster */
1311 if (!randint0(pls_kakuritu))
1313 /* Pick a level bonus */
1314 int d = MIN(5, level/10) + pls_level;
1316 /* Boost the level */
1326 /* Process probabilities */
1327 for (i = 0; i < alloc_race_size; i++)
1329 /* Monsters are sorted by depth */
1330 if (table[i].level > level) break;
1335 /* Access the "r_idx" of the chosen monster */
1336 r_idx = table[i].index;
1338 /* Access the actual race */
1339 r_ptr = &r_info[r_idx];
1341 if (!p_ptr->inside_battle && !chameleon_change_m_idx)
1343 /* Hack -- "unique" monsters must be "unique" */
1344 if (((r_ptr->flags1 & (RF1_UNIQUE)) ||
1345 (r_ptr->flags7 & (RF7_UNIQUE_7))) &&
1346 (r_ptr->cur_num >= r_ptr->max_num))
1351 if ((r_ptr->flags7 & (RF7_UNIQUE2)) &&
1352 (r_ptr->cur_num >= 1))
1357 if (r_idx == MON_BANORLUPART)
1359 if (r_info[MON_BANOR].cur_num > 0) continue;
1360 if (r_info[MON_LUPART].cur_num > 0) continue;
1365 table[i].prob3 = table[i].prob2;
1368 total += table[i].prob3;
1371 /* No legal monsters */
1372 if (total <= 0) return (0);
1375 /* Pick a monster */
1376 value = randint0(total);
1378 /* Find the monster */
1379 for (i = 0; i < alloc_race_size; i++)
1381 /* Found the entry */
1382 if (value < table[i].prob3) break;
1385 value = value - table[i].prob3;
1392 /* Try for a "harder" monster once (50%) or twice (10%) */
1398 /* Pick a monster */
1399 value = randint0(total);
1401 /* Find the monster */
1402 for (i = 0; i < alloc_race_size; i++)
1404 /* Found the entry */
1405 if (value < table[i].prob3) break;
1408 value = value - table[i].prob3;
1411 /* Keep the "best" one */
1412 if (table[i].level < table[j].level) i = j;
1415 /* Try for a "harder" monster twice (10%) */
1421 /* Pick a monster */
1422 value = randint0(total);
1424 /* Find the monster */
1425 for (i = 0; i < alloc_race_size; i++)
1427 /* Found the entry */
1428 if (value < table[i].prob3) break;
1431 value = value - table[i].prob3;
1434 /* Keep the "best" one */
1435 if (table[i].level < table[j].level) i = j;
1439 return (table[i].index);
1447 * Build a string describing a monster in some way.
1449 * We can correctly describe monsters based on their visibility.
1450 * We can force all monsters to be treated as visible or invisible.
1451 * We can build nominatives, objectives, possessives, or reflexives.
1452 * We can selectively pronominalize hidden, visible, or all monsters.
1453 * We can use definite or indefinite descriptions for hidden monsters.
1454 * We can use definite or indefinite descriptions for visible monsters.
1456 * Pronominalization involves the gender whenever possible and allowed,
1457 * so that by cleverly requesting pronominalization / visibility, you
1458 * can get messages like "You hit someone. She screams in agony!".
1460 * Reflexives are acquired by requesting Objective plus Possessive.
1462 * If no m_ptr arg is given (?), the monster is assumed to be hidden,
1463 * unless the "Assume Visible" mode is requested.
1465 * If no r_ptr arg is given, it is extracted from m_ptr and r_info
1466 * If neither m_ptr nor r_ptr is given, the monster is assumed to
1467 * be neuter, singular, and hidden (unless "Assume Visible" is set),
1468 * in which case you may be in trouble... :-)
1470 * I am assuming that no monster name is more than 70 characters long,
1471 * so that "char desc[80];" is sufficiently large for any result.
1474 * 0x01 --> Objective (or Reflexive)
1475 * 0x02 --> Possessive (or Reflexive)
1476 * 0x04 --> Use indefinites for hidden monsters ("something")
1477 * 0x08 --> Use indefinites for visible monsters ("a kobold")
1478 * 0x10 --> Pronominalize hidden monsters
1479 * 0x20 --> Pronominalize visible monsters
1480 * 0x40 --> Assume the monster is hidden
1481 * 0x80 --> Assume the monster is visible
1482 * 0x100 --> Chameleon's true name
1483 * 0x200 --> Ignore hallucination, and penetrate shape change
1486 * 0x00 --> Full nominative name ("the kobold") or "it"
1487 * 0x04 --> Full nominative name ("the kobold") or "something"
1488 * 0x80 --> Genocide resistance name ("the kobold")
1489 * 0x88 --> Killing name ("a kobold")
1490 * 0x22 --> Possessive, genderized if visable ("his") or "its"
1491 * 0x23 --> Reflexive, genderized if visable ("himself") or "itself"
1493 void monster_desc(char *desc, monster_type *m_ptr, int mode)
1496 monster_race *r_ptr;
1500 char silly_name[1024];
1504 r_ptr = &r_info[m_ptr->ap_r_idx];
1506 /* Mode of 0x100 will reveal Chameleon's true name */
1507 if (mode & 0x100) name = (r_name + real_r_ptr(m_ptr)->name);
1508 else name = (r_name + r_ptr->name);
1510 /* Are we hallucinating? (Idea from Nethack...) */
1511 if (p_ptr->image && !(mode & 0x200))
1516 if (!get_rnd_line("silly_j.txt", m_ptr->r_idx, silly_name))
1518 if (!get_rnd_line("silly.txt", m_ptr->r_idx, silly_name))
1526 monster_race *hallu_race;
1530 hallu_race = &r_info[randint1(max_r_idx - 1)];
1532 while (hallu_race->flags1 & RF1_UNIQUE);
1534 strcpy(silly_name, (r_name + hallu_race->name));
1537 /* Better not strcpy it, or we could corrupt r_info... */
1541 /* Can we "see" it (exists + forced, or visible + not unforced) */
1542 seen = (m_ptr && ((mode & 0x80) || (!(mode & 0x40) && m_ptr->ml)));
1544 /* Sexed Pronouns (seen and allowed, or unseen and allowed) */
1545 pron = (m_ptr && ((seen && (mode & 0x20)) || (!seen && (mode & 0x10))));
1548 /* First, try using pronouns, or describing hidden monsters */
1551 /* an encoding of the monster "sex" */
1554 /* Extract the gender (if applicable) */
1555 if (r_ptr->flags1 & (RF1_FEMALE)) kind = 0x20;
1556 else if (r_ptr->flags1 & (RF1_MALE)) kind = 0x10;
1558 /* Ignore the gender (if desired) */
1559 if (!m_ptr || !pron) kind = 0x00;
1562 /* Assume simple result */
1570 /* Brute force: split on the possibilities */
1571 switch (kind + (mode & 0x07))
1573 /* Neuter, or unknown */
1575 case 0x00: res = "²¿¤«"; break;
1576 case 0x01: res = "²¿¤«"; break;
1577 case 0x02: res = "²¿¤«¤Î"; break;
1578 case 0x03: res = "²¿¤«¼«¿È"; break;
1579 case 0x04: res = "²¿¤«"; break;
1580 case 0x05: res = "²¿¤«"; break;
1581 case 0x06: res = "²¿¤«"; break;
1582 case 0x07: res = "¤½¤ì¼«¿È"; break;
1584 case 0x00: res = "it"; break;
1585 case 0x01: res = "it"; break;
1586 case 0x02: res = "its"; break;
1587 case 0x03: res = "itself"; break;
1588 case 0x04: res = "something"; break;
1589 case 0x05: res = "something"; break;
1590 case 0x06: res = "something's"; break;
1591 case 0x07: res = "itself"; break;
1595 /* Male (assume human if vague) */
1597 case 0x10: res = "Èà"; break;
1598 case 0x11: res = "Èà"; break;
1599 case 0x12: res = "Èà¤Î"; break;
1600 case 0x13: res = "È༫¿È"; break;
1601 case 0x14: res = "狼"; break;
1602 case 0x15: res = "狼"; break;
1603 case 0x16: res = "狼¤Î"; break;
1604 case 0x17: res = "È༫¿È"; break;
1606 case 0x10: res = "he"; break;
1607 case 0x11: res = "him"; break;
1608 case 0x12: res = "his"; break;
1609 case 0x13: res = "himself"; break;
1610 case 0x14: res = "someone"; break;
1611 case 0x15: res = "someone"; break;
1612 case 0x16: res = "someone's"; break;
1613 case 0x17: res = "himself"; break;
1617 /* Female (assume human if vague) */
1619 case 0x20: res = "Èà½÷"; break;
1620 case 0x21: res = "Èà½÷"; break;
1621 case 0x22: res = "Èà½÷¤Î"; break;
1622 case 0x23: res = "Èà½÷¼«¿È"; break;
1623 case 0x24: res = "狼"; break;
1624 case 0x25: res = "狼"; break;
1625 case 0x26: res = "狼¤Î"; break;
1626 case 0x27: res = "Èà½÷¼«¿È"; break;
1628 case 0x20: res = "she"; break;
1629 case 0x21: res = "her"; break;
1630 case 0x22: res = "her"; break;
1631 case 0x23: res = "herself"; break;
1632 case 0x24: res = "someone"; break;
1633 case 0x25: res = "someone"; break;
1634 case 0x26: res = "someone's"; break;
1635 case 0x27: res = "herself"; break;
1640 /* Copy the result */
1641 (void)strcpy(desc, res);
1645 /* Handle visible monsters, "reflexive" request */
1646 else if ((mode & 0x02) && (mode & 0x01))
1648 /* The monster is visible, so use its gender */
1650 if (r_ptr->flags1 & (RF1_FEMALE)) strcpy(desc, "Èà½÷¼«¿È");
1651 else if (r_ptr->flags1 & (RF1_MALE)) strcpy(desc, "È༫¿È");
1652 else strcpy(desc, "¤½¤ì¼«¿È");
1654 if (r_ptr->flags1 & RF1_FEMALE) strcpy(desc, "herself");
1655 else if (r_ptr->flags1 & RF1_MALE) strcpy(desc, "himself");
1656 else strcpy(desc, "itself");
1662 /* Handle all other visible monster requests */
1666 if (is_pet(m_ptr) && m_ptr->ap_r_idx != m_ptr->r_idx)
1672 while(strncmp(t, "¡Ù", 2) && *t) t++;
1676 (void)sprintf(desc, "%s¡©¡Ù", buf);
1679 (void)sprintf(desc, "%s¡©", name);
1681 (void)sprintf(desc, "%s?", name);
1686 /* It could be a Unique */
1687 if ((r_ptr->flags1 & RF1_UNIQUE) && !(p_ptr->image && !(mode & 0x200)))
1689 /* Start with the name (thus nominative and objective) */
1690 if ((m_ptr->mflag2 & MFLAG_CHAMELEON) && !(mode & 0x100))
1696 while(strncmp(t, "¡Ù", 2) && *t) t++;
1700 (void)sprintf(desc, "%s¡©¡Ù", buf);
1703 (void)sprintf(desc, "%s¡©", name);
1705 (void)sprintf(desc, "%s?", name);
1708 else if ((cave[m_ptr->fy][m_ptr->fx].m_idx == p_ptr->riding) || !p_ptr->inside_battle)
1709 (void)strcpy(desc, name);
1712 (void)sprintf(desc, "%s¤â¤É¤", name);
1714 (void)sprintf(desc, "fake %s", name);
1718 /* It could be an indefinite monster */
1719 else if (mode & 0x08)
1721 /* XXX Check plurality for "some" */
1723 /* Indefinite monsters need an indefinite article */
1725 (void)strcpy(desc, "");
1727 (void)strcpy(desc, is_a_vowel(name[0]) ? "an " : "a ");
1730 (void)strcat(desc, name);
1733 /* It could be a normal, definite, monster */
1736 /* Definite monsters need a definite article */
1739 (void)strcpy(desc, "¤¢¤Ê¤¿¤Î");
1741 (void)strcpy(desc, "your ");
1746 (void)strcpy(desc, "");
1748 (void)strcpy(desc, "the ");
1751 (void)strcat(desc, name);
1754 if (m_ptr->nickname)
1757 sprintf(buf,"¡Ö%s¡×",quark_str(m_ptr->nickname));
1759 sprintf(buf," called %s",quark_str(m_ptr->nickname));
1764 if ((m_ptr->fy == py) && (m_ptr->fx == px))
1767 strcat(desc,"(¾èÇÏÃæ)");
1769 strcat(desc,"(riding)");
1773 if ((mode & 0x200) && (m_ptr->mflag2 & MFLAG_CHAMELEON))
1775 if (r_ptr->flags1 & RF1_UNIQUE)
1778 strcat(desc,"(¥«¥á¥ì¥ª¥ó¤Î²¦)");
1780 strcat(desc,"(Chameleon Lord)");
1786 strcat(desc,"(¥«¥á¥ì¥ª¥ó)");
1788 strcat(desc,"(Chameleon)");
1793 if ((mode & 0x200) && m_ptr->ap_r_idx != m_ptr->r_idx)
1795 strcat(desc, format("(%s)", r_name + r_info[m_ptr->r_idx].name));
1798 /* Handle the Possessive as a special afterthought */
1801 /* XXX Check for trailing "s" */
1803 /* Simply append "apostrophe" and "s" */
1805 (void)strcat(desc, "¤Î");
1807 (void)strcat(desc, "'s");
1818 * Learn about a monster (by "probing" it)
1820 void lore_do_probe(int m_idx)
1822 monster_type *m_ptr = &m_list[m_idx];
1824 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1826 /* Hack -- Memorize some flags */
1827 r_ptr->r_flags1 = r_ptr->flags1;
1828 r_ptr->r_flags2 = r_ptr->flags2;
1829 r_ptr->r_flags3 = r_ptr->flags3;
1831 /* Update monster recall window */
1832 if (p_ptr->monster_race_idx == m_ptr->r_idx)
1835 p_ptr->window |= (PW_MONSTER);
1841 * Take note that the given monster just dropped some treasure
1843 * Note that learning the "GOOD"/"GREAT" flags gives information
1844 * about the treasure (even when the monster is killed for the first
1845 * time, such as uniques, and the treasure has not been examined yet).
1847 * This "indirect" method is used to prevent the player from learning
1848 * exactly how much treasure a monster can drop from observing only
1849 * a single example of a drop. This method actually observes how much
1850 * gold and items are dropped, and remembers that information to be
1851 * described later by the monster recall code.
1853 void lore_treasure(int m_idx, int num_item, int num_gold)
1855 monster_type *m_ptr = &m_list[m_idx];
1857 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1859 /* Note the number of things dropped */
1860 if (num_item > r_ptr->r_drop_item) r_ptr->r_drop_item = num_item;
1861 if (num_gold > r_ptr->r_drop_gold) r_ptr->r_drop_gold = num_gold;
1863 /* Hack -- memorize the good/great flags */
1864 if (r_ptr->flags1 & (RF1_DROP_GOOD)) r_ptr->r_flags1 |= (RF1_DROP_GOOD);
1865 if (r_ptr->flags1 & (RF1_DROP_GREAT)) r_ptr->r_flags1 |= (RF1_DROP_GREAT);
1867 /* Update monster recall window */
1868 if (p_ptr->monster_race_idx == m_ptr->r_idx)
1871 p_ptr->window |= (PW_MONSTER);
1877 void sanity_blast(monster_type *m_ptr, bool necro)
1879 bool happened = FALSE;
1882 if (p_ptr->inside_battle || !character_dungeon) return;
1887 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1889 power = r_ptr->level / 2;
1891 monster_desc(m_name, m_ptr, 0);
1893 if (!(r_ptr->flags1 & RF1_UNIQUE))
1895 if (r_ptr->flags1 & RF1_FRIENDS)
1901 return; /* No effect yet, just loaded... */
1904 return; /* Cannot see it for some reason */
1906 if (!(r_ptr->flags2 & RF2_ELDRITCH_HORROR))
1912 return; /* Pet eldritch horrors are safe most of the time */
1914 if (randint1(100) > power) return;
1916 if (saving_throw(p_ptr->skill_sav - power))
1918 return; /* Save, no adverse effects */
1923 /* Something silly happens... */
1925 msg_format("%s%s¤Î´é¤ò¸«¤Æ¤·¤Þ¤Ã¤¿¡ª",
1926 funny_desc[randint0(MAX_SAN_FUNNY)], m_name);
1928 msg_format("You behold the %s visage of %s!",
1929 funny_desc[randint0(MAX_SAN_FUNNY)], m_name);
1935 msg_print(funny_comments[randint0(MAX_SAN_COMMENT)]);
1936 p_ptr->image = p_ptr->image + randint1(r_ptr->level);
1939 return; /* Never mind; we can't see it clearly enough */
1942 /* Something frightening happens... */
1944 msg_format("%s%s¤Î´é¤ò¸«¤Æ¤·¤Þ¤Ã¤¿¡ª",
1945 horror_desc[randint0(MAX_SAN_HORROR)], m_name);
1947 msg_format("You behold the %s visage of %s!",
1948 horror_desc[randint0(MAX_SAN_HORROR)], m_name);
1951 r_ptr->r_flags2 |= RF2_ELDRITCH_HORROR;
1953 /* Demon characters are unaffected */
1954 if ((p_ptr->prace == RACE_IMP) || (p_ptr->prace == RACE_DEMON) || (mimic_info[p_ptr->mimic_form].MIMIC_FLAGS & MIMIC_IS_DEMON)) return;
1955 if (p_ptr->wizard) return;
1957 /* Undead characters are 50% likely to be unaffected */
1958 if ((p_ptr->prace == RACE_SKELETON) || (p_ptr->prace == RACE_ZOMBIE)
1959 || (p_ptr->prace == RACE_VAMPIRE) || (p_ptr->prace == RACE_SPECTRE) ||
1960 (mimic_info[p_ptr->mimic_form].MIMIC_FLAGS & MIMIC_IS_UNDEAD))
1962 if (saving_throw(25 + p_ptr->lev)) return;
1968 msg_print("¥Í¥¯¥í¥Î¥ß¥³¥ó¤òÆɤó¤ÇÀµµ¤¤ò¼º¤Ã¤¿¡ª");
1970 msg_print("Your sanity is shaken by reading the Necronomicon!");
1975 if (!saving_throw(p_ptr->skill_sav - power)) /* Mind blast */
1977 if (!p_ptr->resist_conf)
1979 (void)set_confused(p_ptr->confused + randint0(4) + 4);
1981 if (!p_ptr->resist_chaos && one_in_(3))
1983 (void)set_image(p_ptr->image + randint0(250) + 150);
1988 if (!saving_throw(p_ptr->skill_sav - power)) /* Lose int & wis */
1995 if (!saving_throw(p_ptr->skill_sav - power)) /* Brain smash */
1997 if (!p_ptr->resist_conf)
1999 (void)set_confused(p_ptr->confused + randint0(4) + 4);
2001 if (!p_ptr->free_act)
2003 (void)set_paralyzed(p_ptr->paralyzed + randint0(4) + 4);
2005 while (randint0(100) > p_ptr->skill_sav)
2006 (void)do_dec_stat(A_INT);
2007 while (randint0(100) > p_ptr->skill_sav)
2008 (void)do_dec_stat(A_WIS);
2009 if (!p_ptr->resist_chaos)
2011 (void)set_image(p_ptr->image + randint0(250) + 150);
2016 if (!saving_throw(p_ptr->skill_sav - power)) /* Amnesia */
2019 if (lose_all_info())
2021 msg_print("¤¢¤Þ¤ê¤Î¶²ÉݤËÁ´¤Æ¤Î¤³¤È¤ò˺¤ì¤Æ¤·¤Þ¤Ã¤¿¡ª");
2023 msg_print("You forget everything in your utmost terror!");
2029 if (saving_throw(p_ptr->skill_sav - power))
2034 /* Else gain permanent insanity */
2035 if ((p_ptr->muta3 & MUT3_MORONIC) && /*(p_ptr->muta2 & MUT2_BERS_RAGE) &&*/
2036 ((p_ptr->muta2 & MUT2_COWARDICE) || (p_ptr->resist_fear)) &&
2037 ((p_ptr->muta2 & MUT2_HALLU) || (p_ptr->resist_chaos)))
2039 /* The poor bastard already has all possible insanities! */
2045 switch (randint1(21))
2048 if (!(p_ptr->muta3 & MUT3_MORONIC) && one_in_(5))
2050 if ((p_ptr->stat_use[A_INT] < 4) && (p_ptr->stat_use[A_WIS] < 4))
2053 msg_print("¤¢¤Ê¤¿¤Ï´°àú¤ÊÇϼ¯¤Ë¤Ê¤Ã¤¿¤è¤¦¤Êµ¤¤¬¤·¤¿¡£¤·¤«¤·¤½¤ì¤Ï¸µ¡¹¤À¤Ã¤¿¡£");
2055 msg_print("You turn into an utter moron!");
2061 msg_print("¤¢¤Ê¤¿¤Ï´°àú¤ÊÇϼ¯¤Ë¤Ê¤Ã¤¿¡ª");
2063 msg_print("You turn into an utter moron!");
2067 if (p_ptr->muta3 & MUT3_HYPER_INT)
2070 msg_print("¤¢¤Ê¤¿¤ÎǾ¤ÏÀ¸ÂÎ¥³¥ó¥Ô¥å¡¼¥¿¤Ç¤Ï¤Ê¤¯¤Ê¤Ã¤¿¡£");
2072 msg_print("Your brain is no longer a living computer.");
2075 p_ptr->muta3 &= ~(MUT3_HYPER_INT);
2077 p_ptr->muta3 |= MUT3_MORONIC;
2091 if (!(p_ptr->muta2 & MUT2_COWARDICE) && !p_ptr->resist_fear)
2094 msg_print("¤¢¤Ê¤¿¤Ï¥Ñ¥é¥Î¥¤¥¢¤Ë¤Ê¤Ã¤¿¡ª");
2096 msg_print("You become paranoid!");
2100 /* Duh, the following should never happen, but anyway... */
2101 if (p_ptr->muta3 & MUT3_FEARLESS)
2104 msg_print("¤¢¤Ê¤¿¤Ï¤â¤¦¶²¤ìÃΤ餺¤Ç¤Ï¤Ê¤¯¤Ê¤Ã¤¿¡£");
2106 msg_print("You are no longer fearless.");
2109 p_ptr->muta3 &= ~(MUT3_FEARLESS);
2112 p_ptr->muta2 |= MUT2_COWARDICE;
2126 if (!(p_ptr->muta2 & MUT2_HALLU) && !p_ptr->resist_chaos)
2129 msg_print("¸¸³Ð¤ò¤Ò¤µ¯¤³¤¹Àº¿ÀºøÍð¤Ë´Ù¤Ã¤¿¡ª");
2131 msg_print("You are afflicted by a hallucinatory insanity!");
2134 p_ptr->muta2 |= MUT2_HALLU;
2139 if (!(p_ptr->muta2 & MUT2_BERS_RAGE))
2142 msg_print("·ãÎõ¤Ê´¶¾ð¤Îȯºî¤Ë¤ª¤½¤ï¤ì¤ë¤è¤¦¤Ë¤Ê¤Ã¤¿¡ª");
2144 msg_print("You become subject to fits of berserk rage!");
2147 p_ptr->muta2 |= MUT2_BERS_RAGE;
2154 p_ptr->update |= PU_BONUS;
2160 * This function updates the monster record of the given monster
2162 * This involves extracting the distance to the player (if requested),
2163 * and then checking for visibility (natural, infravision, see-invis,
2164 * telepathy), updating the monster visibility flag, redrawing (or
2165 * erasing) the monster when its visibility changes, and taking note
2166 * of any interesting monster flags (cold-blooded, invisible, etc).
2168 * Note the new "mflag" field which encodes several monster state flags,
2169 * including "view" for when the monster is currently in line of sight,
2170 * and "mark" for when the monster is currently visible via detection.
2172 * The only monster fields that are changed here are "cdis" (the
2173 * distance from the player), "ml" (visible to the player), and
2174 * "mflag" (to maintain the "MFLAG_VIEW" flag).
2176 * Note the special "update_monsters()" function which can be used to
2177 * call this function once for every monster.
2179 * Note the "full" flag which requests that the "cdis" field be updated,
2180 * this is only needed when the monster (or the player) has moved.
2182 * Every time a monster moves, we must call this function for that
2183 * monster, and update the distance, and the visibility. Every time
2184 * the player moves, we must call this function for every monster, and
2185 * update the distance, and the visibility. Whenever the player "state"
2186 * changes in certain ways ("blindness", "infravision", "telepathy",
2187 * and "see invisible"), we must call this function for every monster,
2188 * and update the visibility.
2190 * Routines that change the "illumination" of a grid must also call this
2191 * function for any monster in that grid, since the "visibility" of some
2192 * monsters may be based on the illumination of their grid.
2194 * Note that this function is called once per monster every time the
2195 * player moves. When the player is running, this function is one
2196 * of the primary bottlenecks, along with "update_view()" and the
2197 * "process_monsters()" code, so efficiency is important.
2199 * Note the optimized "inline" version of the "distance()" function.
2201 * A monster is "visible" to the player if (1) it has been detected
2202 * by the player, (2) it is close to the player and the player has
2203 * telepathy, or (3) it is close to the player, and in line of sight
2204 * of the player, and it is "illuminated" by some combination of
2205 * infravision, torch light, or permanent light (invisible monsters
2206 * are only affected by "light" if the player can see invisible).
2208 * Monsters which are not on the current panel may be "visible" to
2209 * the player, and their descriptions will include an "offscreen"
2210 * reference. Currently, offscreen monsters cannot be targetted
2211 * or viewed directly, but old targets will remain set. XXX XXX
2213 * The player can choose to be disturbed by several things, including
2214 * "disturb_move" (monster which is viewable moves in some way), and
2215 * "disturb_near" (monster which is "easily" viewable moves in some
2216 * way). Note that "moves" includes "appears" and "disappears".
2218 void update_mon(int m_idx, bool full)
2220 monster_type *m_ptr = &m_list[m_idx];
2222 monster_race *r_ptr = &r_info[m_ptr->r_idx];
2224 bool do_disturb = disturb_move;
2228 /* Current location */
2235 /* Seen by vision */
2241 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
2243 if (ap_r_ptr->r_tkills && ap_r_ptr->level >= p_ptr->lev)
2247 /* Compute distance */
2250 /* Distance components */
2251 int dy = (py > fy) ? (py - fy) : (fy - py);
2252 int dx = (px > fx) ? (px - fx) : (fx - px);
2254 /* Approximate distance */
2255 d = (dy > dx) ? (dy + (dx>>1)) : (dx + (dy>>1));
2257 /* Restrict distance */
2258 if (d > 255) d = 255;
2262 /* Save the distance */
2266 /* Extract distance */
2269 /* Extract the distance */
2275 if (m_ptr->mflag & (MFLAG_MARK)) flag = TRUE;
2279 if (d <= ((d_info[dungeon_type].flags1 & DF1_DARKNESS) ? MAX_SIGHT / 2 : MAX_SIGHT))
2281 if (!(d_info[dungeon_type].flags1 & DF1_DARKNESS) || (d <= MAX_SIGHT / 4))
2283 if (p_ptr->special_defense & KATA_MUSOU)
2288 /* Hack -- Memorize mental flags */
2289 if (r_ptr->flags2 & (RF2_SMART)) r_ptr->r_flags2 |= (RF2_SMART);
2290 if (r_ptr->flags2 & (RF2_STUPID)) r_ptr->r_flags2 |= (RF2_STUPID);
2293 /* Basic telepathy */
2294 else if (p_ptr->telepathy)
2296 /* Empty mind, no telepathy */
2297 if (r_ptr->flags2 & (RF2_EMPTY_MIND))
2299 /* Memorize flags */
2300 r_ptr->r_flags2 |= (RF2_EMPTY_MIND);
2303 /* Weird mind, occasional telepathy */
2304 else if (r_ptr->flags2 & (RF2_WEIRD_MIND))
2306 /* One in ten individuals are detectable */
2307 if ((m_idx % 10) == 5)
2312 /* Memorize flags */
2313 r_ptr->r_flags2 |= (RF2_WEIRD_MIND);
2315 /* Hack -- Memorize mental flags */
2316 if (r_ptr->flags2 & (RF2_SMART)) r_ptr->r_flags2 |= (RF2_SMART);
2317 if (r_ptr->flags2 & (RF2_STUPID)) r_ptr->r_flags2 |= (RF2_STUPID);
2321 /* Normal mind, allow telepathy */
2327 /* Hack -- Memorize mental flags */
2328 if (r_ptr->flags2 & (RF2_SMART)) r_ptr->r_flags2 |= (RF2_SMART);
2329 if (r_ptr->flags2 & (RF2_STUPID)) r_ptr->r_flags2 |= (RF2_STUPID);
2333 /* Magical sensing */
2334 if ((p_ptr->esp_animal) && (r_ptr->flags3 & (RF3_ANIMAL)))
2337 r_ptr->r_flags3 |= (RF3_ANIMAL);
2341 /* Magical sensing */
2342 if ((p_ptr->esp_undead) && (r_ptr->flags3 & (RF3_UNDEAD)))
2345 r_ptr->r_flags3 |= (RF3_UNDEAD);
2349 /* Magical sensing */
2350 if ((p_ptr->esp_demon) && (r_ptr->flags3 & (RF3_DEMON)))
2353 r_ptr->r_flags3 |= (RF3_DEMON);
2357 /* Magical sensing */
2358 if ((p_ptr->esp_orc) && (r_ptr->flags3 & (RF3_ORC)))
2361 r_ptr->r_flags3 |= (RF3_ORC);
2365 /* Magical sensing */
2366 if ((p_ptr->esp_troll) && (r_ptr->flags3 & (RF3_TROLL)))
2369 r_ptr->r_flags3 |= (RF3_TROLL);
2373 /* Magical sensing */
2374 if ((p_ptr->esp_giant) && (r_ptr->flags3 & (RF3_GIANT)))
2377 r_ptr->r_flags3 |= (RF3_GIANT);
2381 /* Magical sensing */
2382 if ((p_ptr->esp_dragon) && (r_ptr->flags3 & (RF3_DRAGON)))
2385 r_ptr->r_flags3 |= (RF3_DRAGON);
2389 /* Magical sensing */
2390 if ((p_ptr->esp_human) && (r_ptr->flags2 & (RF2_HUMAN)))
2393 r_ptr->r_flags2 |= (RF2_HUMAN);
2397 /* Magical sensing */
2398 if ((p_ptr->esp_evil) && (r_ptr->flags3 & (RF3_EVIL)))
2401 r_ptr->r_flags3 |= (RF3_EVIL);
2405 /* Magical sensing */
2406 if ((p_ptr->esp_good) && (r_ptr->flags3 & (RF3_GOOD)))
2409 r_ptr->r_flags3 |= (RF3_GOOD);
2413 /* Magical sensing */
2414 if ((p_ptr->esp_nonliving) &&
2415 (r_ptr->flags3 & (RF3_NONLIVING)) &&
2416 !(r_ptr->flags3 & (RF3_DEMON)) &&
2417 !(r_ptr->flags3 & (RF3_UNDEAD)))
2420 r_ptr->r_flags3 |= (RF3_NONLIVING);
2424 /* Magical sensing */
2425 if ((p_ptr->esp_unique) && (r_ptr->flags1 & (RF1_UNIQUE)))
2428 r_ptr->r_flags1 |= (RF1_UNIQUE);
2433 /* Normal line of sight, and not blind */
2434 if (player_has_los_bold(fy, fx) && !p_ptr->blind)
2436 bool do_invisible = FALSE;
2437 bool do_cold_blood = FALSE;
2439 /* Use "infravision" */
2440 if (d <= p_ptr->see_infra)
2442 /* Handle "cold blooded" monsters */
2443 if (r_ptr->flags2 & (RF2_COLD_BLOOD))
2446 do_cold_blood = TRUE;
2449 /* Handle "warm blooded" monsters */
2457 /* Use "illumination" */
2458 if (player_can_see_bold(fy, fx))
2460 /* Handle "invisible" monsters */
2461 if (r_ptr->flags2 & (RF2_INVISIBLE))
2464 do_invisible = TRUE;
2474 /* Handle "normal" monsters */
2485 /* Memorize flags */
2486 if (do_invisible) r_ptr->r_flags2 |= (RF2_INVISIBLE);
2487 if (do_cold_blood) r_ptr->r_flags2 |= (RF2_COLD_BLOOD);
2493 /* The monster is now visible */
2496 /* It was previously unseen */
2499 /* Mark as visible */
2502 /* Draw the monster */
2505 /* Update health bar as needed */
2506 if (p_ptr->health_who == m_idx) p_ptr->redraw |= (PR_HEALTH);
2507 if (p_ptr->riding == m_idx) p_ptr->redraw |= (PR_UHEALTH);
2509 /* Hack -- Count "fresh" sightings */
2510 if ((m_ptr->ap_r_idx == MON_KAGE) && (r_info[MON_KAGE].r_sights < MAX_SHORT))
2511 r_info[MON_KAGE].r_sights++;
2512 else if (m_ptr->ap_r_idx == m_ptr->r_idx &&
2513 r_ptr->r_sights < MAX_SHORT) r_ptr->r_sights++;
2515 /* Eldritch Horror */
2516 if (r_ptr->flags2 & RF2_ELDRITCH_HORROR)
2518 sanity_blast(m_ptr, FALSE);
2521 /* Disturb on appearance */
2522 if (disturb_near && (projectable(m_ptr->fy, m_ptr->fx, py, px) && projectable(py, px, m_ptr->fy, m_ptr->fx)))
2524 if (disturb_pets || is_hostile(m_ptr))
2530 /* The monster is not visible */
2533 /* It was previously seen */
2536 /* Mark as not visible */
2539 /* Erase the monster */
2542 /* Update health bar as needed */
2543 if (p_ptr->health_who == m_idx) p_ptr->redraw |= (PR_HEALTH);
2544 if (p_ptr->riding == m_idx) p_ptr->redraw |= (PR_UHEALTH);
2546 /* Disturb on disappearance */
2549 if (disturb_pets || is_hostile(m_ptr))
2556 /* The monster is now easily visible */
2560 if (!(m_ptr->mflag & (MFLAG_VIEW)))
2562 /* Mark as easily visible */
2563 m_ptr->mflag |= (MFLAG_VIEW);
2565 /* Disturb on appearance */
2568 if (disturb_pets || is_hostile(m_ptr))
2574 /* The monster is not easily visible */
2578 if (m_ptr->mflag & (MFLAG_VIEW))
2580 /* Mark as not easily visible */
2581 m_ptr->mflag &= ~(MFLAG_VIEW);
2583 /* Disturb on disappearance */
2586 if (disturb_pets || is_hostile(m_ptr))
2595 * This function simply updates all the (non-dead) monsters (see above).
2597 void update_monsters(bool full)
2601 /* Update each (live) monster */
2602 for (i = 1; i < m_max; i++)
2604 monster_type *m_ptr = &m_list[i];
2606 /* Skip dead monsters */
2607 if (!m_ptr->r_idx) continue;
2609 /* Update the monster */
2610 update_mon(i, full);
2616 * Hack -- the index of the summoning monster
2618 static bool monster_hook_chameleon_lord(int r_idx)
2620 monster_race *r_ptr = &r_info[r_idx];
2621 monster_type *m_ptr = &m_list[chameleon_change_m_idx];
2622 monster_race *old_r_ptr = &r_info[m_ptr->r_idx];
2624 if (!(r_ptr->flags1 & (RF1_UNIQUE))) return FALSE;
2625 if (r_ptr->flags7 & (RF7_FRIENDLY | RF7_CHAMELEON)) return FALSE;
2627 if (ABS(r_ptr->level - r_info[MON_CHAMELEON_K].level) > 5) return FALSE;
2629 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))
2632 if (!monster_can_cross_terrain(cave[m_ptr->fy][m_ptr->fx].feat, r_ptr)) return FALSE;
2635 if (!(old_r_ptr->flags7 & RF7_CHAMELEON))
2637 if ((m_ptr->sub_align & SUB_ALIGN_EVIL) && (r_ptr->flags3 & RF3_GOOD)) return FALSE;
2638 if ((m_ptr->sub_align & SUB_ALIGN_GOOD) && (r_ptr->flags3 & RF3_EVIL)) return FALSE;
2642 else if (summon_specific_who > 0)
2644 monster_type *sm_ptr = &m_list[summon_specific_who];
2646 if ((sm_ptr->sub_align & SUB_ALIGN_EVIL) && (r_ptr->flags3 & RF3_GOOD)) return FALSE;
2647 if ((sm_ptr->sub_align & SUB_ALIGN_GOOD) && (r_ptr->flags3 & RF3_EVIL)) return FALSE;
2653 static bool monster_hook_chameleon(int r_idx)
2655 monster_race *r_ptr = &r_info[r_idx];
2656 monster_type *m_ptr = &m_list[chameleon_change_m_idx];
2657 monster_race *old_r_ptr = &r_info[m_ptr->r_idx];
2659 if (r_ptr->flags1 & (RF1_UNIQUE)) return FALSE;
2660 if (r_ptr->flags2 & RF2_MULTIPLY) return FALSE;
2661 if (r_ptr->flags7 & (RF7_FRIENDLY | RF7_CHAMELEON)) return FALSE;
2663 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))
2666 if (!monster_can_cross_terrain(cave[m_ptr->fy][m_ptr->fx].feat, r_ptr)) return FALSE;
2669 if (!(old_r_ptr->flags7 & RF7_CHAMELEON))
2671 if ((old_r_ptr->flags3 & RF3_GOOD) && !(r_ptr->flags3 & RF3_GOOD)) return FALSE;
2672 if ((old_r_ptr->flags3 & RF3_EVIL) && !(r_ptr->flags3 & RF3_EVIL)) return FALSE;
2673 if (!(old_r_ptr->flags3 & (RF3_GOOD | RF3_EVIL)) && (r_ptr->flags3 & (RF3_GOOD | RF3_EVIL))) return FALSE;
2677 else if (summon_specific_who > 0)
2679 monster_type *sm_ptr = &m_list[summon_specific_who];
2681 if ((sm_ptr->sub_align & SUB_ALIGN_EVIL) && (r_ptr->flags3 & RF3_GOOD)) return FALSE;
2682 if ((sm_ptr->sub_align & SUB_ALIGN_GOOD) && (r_ptr->flags3 & RF3_EVIL)) return FALSE;
2685 return (*(get_monster_hook()))(r_idx);
2689 void choose_new_monster(int m_idx, bool born, int r_idx)
2692 monster_type *m_ptr = &m_list[m_idx];
2693 monster_race *r_ptr;
2694 char old_m_name[80];
2695 int old_r_idx = m_ptr->r_idx;
2696 bool old_unique = FALSE;
2698 if (r_info[m_ptr->r_idx].flags1 & RF1_UNIQUE)
2700 if (old_unique && (r_idx == MON_CHAMELEON)) r_idx = MON_CHAMELEON_K;
2701 r_ptr = &r_info[r_idx];
2703 monster_desc(old_m_name, m_ptr, 0);
2709 chameleon_change_m_idx = m_idx;
2711 get_mon_num_prep(monster_hook_chameleon_lord, NULL);
2713 get_mon_num_prep(monster_hook_chameleon, NULL);
2716 level = r_info[MON_CHAMELEON_K].level;
2717 else if (!dun_level)
2718 level = wilderness[p_ptr->wilderness_y][p_ptr->wilderness_x].level;
2722 if (d_info[dungeon_type].flags1 & DF1_CHAMELEON) level+= 2+randint1(3);
2724 r_idx = get_mon_num(level);
2725 r_ptr = &r_info[r_idx];
2727 chameleon_change_m_idx = 0;
2733 m_ptr->r_idx = r_idx;
2734 m_ptr->ap_r_idx = r_idx;
2735 update_mon(m_idx, FALSE);
2736 lite_spot(m_ptr->fy, m_ptr->fx);
2739 /* Sub-alignment of a chameleon */
2740 if (r_ptr->flags3 & (RF3_EVIL | RF3_GOOD))
2742 m_ptr->sub_align = SUB_ALIGN_NEUTRAL;
2743 if (r_ptr->flags3 & RF3_EVIL) m_ptr->sub_align |= SUB_ALIGN_EVIL;
2744 if (r_ptr->flags3 & RF3_GOOD) m_ptr->sub_align |= SUB_ALIGN_GOOD;
2749 if (m_idx == p_ptr->riding)
2752 monster_desc(m_name, m_ptr, 0);
2754 msg_format("ÆÍÁ³%s¤¬ÊѿȤ·¤¿¡£", old_m_name);
2756 msg_format("Suddenly, %s transforms!", old_m_name);
2758 if (!(r_ptr->flags7 & RF7_RIDING))
2760 if (rakuba(0, TRUE)) msg_print("ÃÏÌ̤ËÍî¤È¤µ¤ì¤¿¡£");
2762 if (rakuba(0, TRUE)) msg_format("You have fallen from %s.", m_name);
2766 /* Extract the monster base speed */
2767 m_ptr->mspeed = r_ptr->speed;
2768 /* Hack -- small racial variety */
2769 /* Allow some small variation per monster */
2771 i = extract_energy[r_ptr->speed] / 3;
2772 if (i) m_ptr->mspeed += rand_spread(0, i);
2775 i = extract_energy[r_ptr->speed] / 10;
2776 if (i) m_ptr->mspeed += rand_spread(0, i);
2779 oldmaxhp = m_ptr->max_maxhp;
2780 /* Assign maximal hitpoints */
2781 if (r_ptr->flags1 & RF1_FORCE_MAXHP)
2783 m_ptr->max_maxhp = maxroll(r_ptr->hdice, r_ptr->hside);
2787 m_ptr->max_maxhp = damroll(r_ptr->hdice, r_ptr->hside);
2789 m_ptr->maxhp = (long)(m_ptr->maxhp * m_ptr->max_maxhp) / oldmaxhp;
2790 m_ptr->hp = (long)(m_ptr->hp * m_ptr->max_maxhp) / oldmaxhp;
2797 static bool monster_hook_tanuki(int r_idx)
2799 monster_race *r_ptr = &r_info[r_idx];
2801 if (r_ptr->flags1 & (RF1_UNIQUE)) return FALSE;
2802 if (r_ptr->flags2 & RF2_MULTIPLY) return FALSE;
2803 if (r_ptr->flags7 & (RF7_FRIENDLY | RF7_CHAMELEON)) return FALSE;
2804 if (r_ptr->flags7 & RF7_AQUATIC) return FALSE;
2806 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))
2809 return (*(get_monster_hook()))(r_idx);
2814 * Set initial racial appearance of a monster
2816 static int initial_r_appearance(int r_idx)
2818 int attempts = 1000;
2821 int min = MIN(base_level-5, 50);
2823 if (!(r_info[r_idx].flags7 & RF7_TANUKI))
2826 get_mon_num_prep(monster_hook_tanuki, NULL);
2830 ap_r_idx = get_mon_num(base_level + 10);
2831 if (r_info[ap_r_idx].level >= min) return ap_r_idx;
2839 * Attempt to place a monster of the given race at the given location.
2841 * To give the player a sporting chance, any monster that appears in
2842 * line-of-sight and is extremely dangerous can be marked as
2843 * "FORCE_SLEEP", which will cause them to be placed with low energy,
2844 * which often (but not always) lets the player move before they do.
2846 * This routine refuses to place out-of-depth "FORCE_DEPTH" monsters.
2848 * XXX XXX XXX Use special "here" and "dead" flags for unique monsters,
2849 * remove old "cur_num" and "max_num" fields.
2851 * XXX XXX XXX Actually, do something similar for artifacts, to simplify
2852 * the "preserve" mode, and to make the "what artifacts" flag more useful.
2854 * This is the only function which may place a monster in the dungeon,
2855 * except for the savefile loading code.
2857 bool place_monster_one(int who, int y, int x, int r_idx, u32b mode)
2864 monster_type *m_ptr;
2866 monster_race *r_ptr = &r_info[r_idx];
2868 cptr name = (r_name + r_ptr->name);
2870 /* DO NOT PLACE A MONSTER IN THE SMALL SCALE WILDERNESS !!! */
2871 if(p_ptr->wild_mode) return FALSE;
2873 /* Verify location */
2874 if (!in_bounds(y, x)) return (FALSE);
2876 /* Require empty space (if not ghostly) */
2877 if (!(!dun_level && (cave[y][x].feat == FEAT_MOUNTAIN) && ((r_ptr->flags8 & RF8_WILD_MOUNTAIN) || (r_ptr->flags7 & RF7_CAN_FLY))) &&
2878 !(cave_empty_bold2(y, x) || (mode & PM_IGNORE_TERRAIN)) &&
2879 !((r_ptr->flags2 & RF2_PASS_WALL) &&
2880 !(cave_perma_bold(y, x) || cave[y][x].m_idx ||
2881 ((y == py) && (x == px))))) return (FALSE);
2884 if (!r_idx) return (FALSE);
2887 if (!r_ptr->name) return (FALSE);
2889 /* Nor on the Pattern */
2890 if ((cave[y][x].feat >= FEAT_PATTERN_START)
2891 && (cave[y][x].feat <= FEAT_PATTERN_XTRA2))
2894 if (!(mode & PM_IGNORE_TERRAIN) &&
2895 !monster_can_cross_terrain(cave[y][x].feat, r_ptr))
2900 if (!p_ptr->inside_battle)
2902 /* Hack -- "unique" monsters must be "unique" */
2903 if (((r_ptr->flags1 & (RF1_UNIQUE)) ||
2904 (r_ptr->flags7 & (RF7_UNIQUE_7))) &&
2905 (r_ptr->cur_num >= r_ptr->max_num))
2911 if ((r_ptr->flags7 & (RF7_UNIQUE2)) &&
2912 (r_ptr->cur_num >= 1))
2917 if (r_idx == MON_BANORLUPART)
2919 if (r_info[MON_BANOR].cur_num > 0) return FALSE;
2920 if (r_info[MON_LUPART].cur_num > 0) return FALSE;
2923 /* Depth monsters may NOT be created out of depth, unless in Nightmare mode */
2924 if ((r_ptr->flags1 & (RF1_FORCE_DEPTH)) && (dun_level < r_ptr->level) &&
2925 (!ironman_nightmare || (r_ptr->flags1 & (RF1_QUESTOR))))
2932 if(quest_number(dun_level))
2934 int hoge = quest_number(dun_level);
2935 if((quest[hoge].type == QUEST_TYPE_KILL_LEVEL) || (quest[hoge].type == QUEST_TYPE_RANDOM))
2937 if(r_idx == quest[hoge].r_idx)
2939 int number_mon, i2, j2;
2942 /* Count all quest monsters */
2943 for (i2 = 0; i2 < cur_wid; ++i2)
2944 for (j2 = 0; j2 < cur_hgt; j2++)
2945 if (cave[j2][i2].m_idx > 0)
2946 if (m_list[cave[j2][i2].m_idx].r_idx == quest[hoge].r_idx)
2948 if(number_mon + quest[hoge].cur_num >= quest[hoge].max_num)
2954 /* Access the location */
2955 c_ptr = &cave[y][x];
2957 if (is_glyph_grid(c_ptr))
2959 if (randint1(BREAK_GLYPH) < (r_ptr->level+20))
2961 /* Describe observable breakage */
2962 if (c_ptr->info & CAVE_MARK)
2965 msg_print("¼é¤ê¤Î¥ë¡¼¥ó¤¬²õ¤ì¤¿¡ª");
2967 msg_print("The rune of protection is broken!");
2972 /* Forget the rune */
2973 c_ptr->info &= ~(CAVE_MARK);
2975 /* Break the rune */
2976 c_ptr->info &= ~(CAVE_OBJECT);
2986 /* Powerful monster */
2987 if (r_ptr->level > dun_level)
2989 /* Unique monsters */
2990 if (r_ptr->flags1 & (RF1_UNIQUE))
2992 /* Message for cheaters */
2994 if (cheat_hear) msg_format("¿¼ÁؤΥæ¥Ë¡¼¥¯¡¦¥â¥ó¥¹¥¿¡¼ (%s)¡£", name);
2996 if (cheat_hear) msg_format("Deep Unique (%s).", name);
3000 /* Boost rating by twice delta-depth */
3001 rating += (r_ptr->level - dun_level) * 2;
3004 /* Normal monsters */
3007 /* Message for cheaters */
3009 if (cheat_hear) msg_format("¿¼ÁؤΥâ¥ó¥¹¥¿¡¼ (%s)¡£", name);
3011 if (cheat_hear) msg_format("Deep Monster (%s).", name);
3015 /* Boost rating by delta-depth */
3016 rating += (r_ptr->level - dun_level);
3020 /* Note the monster */
3021 else if (r_ptr->flags1 & (RF1_UNIQUE))
3023 /* Unique monsters induce message */
3025 if (cheat_hear) msg_format("¥æ¥Ë¡¼¥¯¡¦¥â¥ó¥¹¥¿¡¼ (%s)¡£", name);
3027 if (cheat_hear) msg_format("Unique (%s).", name);
3032 if ((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags7 & RF7_UNIQUE_7) || (r_ptr->level < 10)) is_kage = FALSE;
3034 /* Make a new monster */
3035 c_ptr->m_idx = m_pop();
3036 hack_m_idx_ii = c_ptr->m_idx;
3038 /* Mega-Hack -- catch "failure" */
3039 if (!c_ptr->m_idx) return (FALSE);
3042 /* Get a new monster record */
3043 m_ptr = &m_list[c_ptr->m_idx];
3046 m_ptr->r_idx = r_idx;
3047 m_ptr->ap_r_idx = initial_r_appearance(r_idx);
3049 /* Sub-alignment of a monster */
3050 if ((who > 0) && !(r_ptr->flags3 & (RF3_EVIL | RF3_GOOD)))
3051 m_ptr->sub_align = m_list[who].sub_align;
3054 m_ptr->sub_align = SUB_ALIGN_NEUTRAL;
3055 if (r_ptr->flags3 & RF3_EVIL) m_ptr->sub_align |= SUB_ALIGN_EVIL;
3056 if (r_ptr->flags3 & RF3_GOOD) m_ptr->sub_align |= SUB_ALIGN_GOOD;
3059 /* Place the monster at the location */
3064 /* No "damage" yet */
3066 m_ptr->confused = 0;
3069 /* Unknown distance */
3072 reset_target(m_ptr);
3074 m_ptr->nickname = 0;
3082 if (r_ptr->flags7 & RF7_CHAMELEON)
3084 choose_new_monster(c_ptr->m_idx, TRUE, 0);
3085 r_ptr = &r_info[m_ptr->r_idx];
3086 m_ptr->mflag2 |= MFLAG_CHAMELEON;
3089 /* Hack - Set sub_align to neutral when the Chameleon Lord is generated as "GUARDIAN" */
3090 if ((r_ptr->flags1 & RF1_UNIQUE) && (who <= 0))
3091 m_ptr->sub_align = SUB_ALIGN_NEUTRAL;
3095 m_ptr->ap_r_idx = MON_KAGE;
3096 m_ptr->mflag2 |= MFLAG_KAGE;
3099 if (mode & PM_NO_PET) m_ptr->mflag2 |= MFLAG_NOPET;
3105 if (mode & PM_FORCE_PET)
3110 else if ((r_ptr->flags7 & RF7_FRIENDLY) ||
3111 (mode & PM_FORCE_FRIENDLY) || is_friendly_idx(who))
3113 if (!(p_ptr->align >= 0 && (r_ptr->flags3 & RF3_EVIL)) &&
3114 !(p_ptr->align < 0 && (r_ptr->flags3 & RF3_GOOD)))
3116 set_friendly(m_ptr);
3120 /* Assume no sleeping */
3123 /* Enforce sleeping if needed */
3124 if ((mode & PM_ALLOW_SLEEP) && r_ptr->sleep && !ironman_nightmare)
3126 int val = r_ptr->sleep;
3127 m_ptr->csleep = ((val * 2) + randint1(val * 10));
3130 /* Assign maximal hitpoints */
3131 if (r_ptr->flags1 & RF1_FORCE_MAXHP)
3133 m_ptr->max_maxhp = maxroll(r_ptr->hdice, r_ptr->hside);
3137 m_ptr->max_maxhp = damroll(r_ptr->hdice, r_ptr->hside);
3140 /* Monsters have double hitpoints in Nightmare mode */
3141 if (ironman_nightmare)
3143 u32b hp = m_ptr->max_maxhp * 2L;
3145 m_ptr->max_maxhp = (s16b)MIN(30000, hp);
3148 m_ptr->maxhp = m_ptr->max_maxhp;
3150 /* And start out fully healthy */
3151 if (m_ptr->r_idx == MON_WOUNDED_BEAR)
3152 m_ptr->hp = m_ptr->maxhp / 2;
3153 else m_ptr->hp = m_ptr->maxhp;
3156 /* Extract the monster base speed */
3157 m_ptr->mspeed = r_ptr->speed;
3159 /* Hack -- small racial variety */
3160 if (!(r_ptr->flags1 & RF1_UNIQUE) && !p_ptr->inside_arena)
3162 /* Allow some small variation per monster */
3164 i = extract_energy[r_ptr->speed] / 3;
3165 if (i) m_ptr->mspeed += rand_spread(0, i);
3168 i = extract_energy[r_ptr->speed] / 10;
3169 if (i) m_ptr->mspeed += rand_spread(0, i);
3173 if (mode & PM_HASTE) m_ptr->fast = 100;
3175 if (m_ptr->mspeed > 199) m_ptr->mspeed = 199;
3177 /* Give a random starting energy */
3178 if (!ironman_nightmare)
3180 m_ptr->energy_need = ENERGY_NEED() - (s16b)randint0(100);
3184 /* Nightmare monsters are more prepared */
3185 m_ptr->energy_need = ENERGY_NEED() - (s16b)randint0(100) * 2;
3188 /* Force monster to wait for player, unless in Nightmare mode */
3189 if ((r_ptr->flags1 & RF1_FORCE_SLEEP) && !ironman_nightmare)
3191 /* Monster is still being nice */
3192 m_ptr->mflag |= (MFLAG_NICE);
3194 /* Must repair monsters */
3195 repair_monsters = TRUE;
3198 /* Hack -- see "process_monsters()" */
3199 if (c_ptr->m_idx < hack_m_idx)
3201 /* Monster is still being born */
3202 m_ptr->mflag |= (MFLAG_BORN);
3206 /* Update the monster */
3207 update_mon(c_ptr->m_idx, TRUE);
3210 /* Count the monsters on the level */
3211 real_r_ptr(m_ptr)->cur_num++;
3214 * Memorize location of the unique monster in saved floors.
3215 * A unique monster move from old saved floor.
3217 if (character_dungeon &&
3218 ((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags7 & RF7_UNIQUE_7)))
3219 real_r_ptr(m_ptr)->floor_id = p_ptr->floor_id;
3221 /* Hack -- Count the number of "reproducers" */
3222 if (r_ptr->flags2 & RF2_MULTIPLY) num_repro++;
3225 /* Hack -- Notice new multi-hued monsters */
3226 if (r_ptr->flags1 & RF1_ATTR_MULTI) shimmer_monsters = TRUE;
3228 if (p_ptr->warning && character_dungeon)
3230 if (r_ptr->flags1 & RF1_UNIQUE)
3234 char o_name[MAX_NLEN];
3236 if (r_ptr->level > p_ptr->lev + 30)
3242 else if (r_ptr->level > p_ptr->lev + 15)
3248 else if (r_ptr->level > p_ptr->lev + 5)
3250 color = "¥ë¥Ó¡¼¿§¤Ë";
3254 else if (r_ptr->level > p_ptr->lev - 5)
3260 else if (r_ptr->level > p_ptr->lev - 15)
3262 color = "¥Ô¥ó¥¯¿§¤Ë";
3273 o_ptr = choose_warning_item();
3274 object_desc(o_name, o_ptr, FALSE, 0);
3276 msg_format("%s¤Ï%s¸÷¤Ã¤¿¡£",o_name, color);
3278 msg_format("%s glows %s.",o_name, color);
3283 if (is_explosive_rune_grid(c_ptr))
3285 /* Break the ward */
3286 if (randint1(BREAK_MINOR_GLYPH) > r_ptr->level)
3288 /* Describe observable breakage */
3289 if (c_ptr->info & CAVE_MARK)
3292 msg_print("¥ë¡¼¥ó¤¬Çúȯ¤·¤¿¡ª");
3294 msg_print("The rune explodes!");
3297 project(0, 2, y, x, 2 * (p_ptr->lev + damroll(7, 7)), GF_MANA, (PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL | PROJECT_JUMP | PROJECT_NO_HANGEKI), -1);
3303 msg_print("Çúȯ¤Î¥ë¡¼¥ó¤Ï²ò½ü¤µ¤ì¤¿¡£");
3305 msg_print("An explosive rune was disarmed.");
3309 /* Forget the rune */
3310 c_ptr->info &= ~(CAVE_MARK);
3312 /* Break the rune */
3313 c_ptr->info &= ~(CAVE_OBJECT);
3326 * improved version of scatter() for place monster
3329 #define MON_SCAT_MAXD 10
3331 static bool mon_scatter(int *yp, int *xp, int y, int x, int max_dist)
3333 int place_x[MON_SCAT_MAXD];
3334 int place_y[MON_SCAT_MAXD];
3335 int num[MON_SCAT_MAXD];
3339 if (max_dist >= MON_SCAT_MAXD)
3342 for (i = 0; i < MON_SCAT_MAXD; i++)
3345 for (nx = x - max_dist; nx <= x + max_dist; nx++)
3346 for (ny = y - max_dist; ny <= y + max_dist; ny++)
3348 /* Ignore annoying locations */
3349 if (!in_bounds(ny, nx)) continue;
3351 /* Require "line of sight" */
3352 if (!los(y, x, ny, nx)) continue;
3354 /* Walls and Monsters block flow */
3355 if (!cave_empty_bold2(ny, nx)) continue;
3356 if (cave[ny][nx].m_idx) continue;
3357 if ((ny == py) && (nx == px)) continue;
3359 /* ... nor on the Pattern */
3360 if ((cave[ny][nx].feat >= FEAT_PATTERN_START) &&
3361 (cave[ny][nx].feat <= FEAT_PATTERN_XTRA2))
3364 i = distance(y, x, ny, nx);
3381 while (i < MON_SCAT_MAXD && 0 == num[i])
3383 if (i >= MON_SCAT_MAXD)
3394 * Maximum size of a group of monsters
3396 #define GROUP_MAX 32
3400 * Attempt to place a "group" of monsters around the given location
3402 static bool place_monster_group(int who, int y, int x, int r_idx, u32b mode)
3404 monster_race *r_ptr = &r_info[r_idx];
3407 int total = 0, extra = 0;
3411 byte hack_y[GROUP_MAX];
3412 byte hack_x[GROUP_MAX];
3415 /* Pick a group size */
3416 total = randint1(10);
3418 /* Hard monsters, small groups */
3419 if (r_ptr->level > dun_level)
3421 extra = r_ptr->level - dun_level;
3422 extra = 0 - randint1(extra);
3425 /* Easy monsters, large groups */
3426 else if (r_ptr->level < dun_level)
3428 extra = dun_level - r_ptr->level;
3429 extra = randint1(extra);
3432 /* Hack -- limit group reduction */
3433 if (extra > 9) extra = 9;
3435 /* Modify the group size */
3439 if (total < 1) total = 1;
3442 if (total > GROUP_MAX) total = GROUP_MAX;
3445 /* Save the rating */
3448 /* Start on the monster */
3453 /* Puddle monsters, breadth first, up to total */
3454 for (n = 0; (n < hack_n) && (hack_n < total); n++)
3456 /* Grab the location */
3460 /* Check each direction, up to total */
3461 for (i = 0; (i < 8) && (hack_n < total); i++)
3465 scatter(&my, &mx, hy, hx, 4, 0);
3467 /* Walls and Monsters block flow */
3468 if (!cave_empty_bold2(my, mx)) continue;
3470 /* Attempt to place another monster */
3471 if (place_monster_one(who, my, mx, r_idx, mode))
3473 /* Add it to the "hack" set */
3474 hack_y[hack_n] = my;
3475 hack_x[hack_n] = mx;
3481 /* Hack -- restore the rating */
3491 * Hack -- help pick an escort type
3493 static int place_monster_idx = 0;
3494 static int place_monster_m_idx = 0;
3497 * Hack -- help pick an escort type
3499 static bool place_monster_okay(int r_idx)
3501 monster_race *r_ptr = &r_info[place_monster_idx];
3502 monster_type *m_ptr = &m_list[place_monster_m_idx];
3504 monster_race *z_ptr = &r_info[r_idx];
3506 /* Hack - Escorts have to have the same dungeon flag */
3507 if (monster_dungeon(place_monster_idx) != monster_dungeon(r_idx)) return (FALSE);
3509 /* Require similar "race" */
3510 if (z_ptr->d_char != r_ptr->d_char) return (FALSE);
3512 /* Skip more advanced monsters */
3513 if (z_ptr->level > r_ptr->level) return (FALSE);
3515 /* Skip unique monsters */
3516 if (z_ptr->flags1 & RF1_UNIQUE) return (FALSE);
3518 /* Paranoia -- Skip identical monsters */
3519 if (place_monster_idx == r_idx) return (FALSE);
3521 /* Skip different alignment */
3522 if (((m_ptr->sub_align & SUB_ALIGN_EVIL) && (z_ptr->flags3 & RF3_GOOD)) ||
3523 ((m_ptr->sub_align & SUB_ALIGN_GOOD) && (z_ptr->flags3 & RF3_EVIL)))
3526 if (r_ptr->flags7 & RF7_FRIENDLY)
3528 if (((p_ptr->align < 0) && (z_ptr->flags3 & RF3_GOOD)) ||
3529 ((p_ptr->align > 0) && (z_ptr->flags3 & RF3_EVIL)))
3533 if ((r_ptr->flags7 & RF7_CHAMELEON) && !(z_ptr->flags7 & RF7_CHAMELEON))
3542 * Attempt to place a monster of the given race at the given location
3544 * Note that certain monsters are now marked as requiring "friends".
3545 * These monsters, if successfully placed, and if the "grp" parameter
3546 * is TRUE, will be surrounded by a "group" of identical monsters.
3548 * Note that certain monsters are now marked as requiring an "escort",
3549 * which is a collection of monsters with similar "race" but lower level.
3551 * Some monsters induce a fake "group" flag on their escorts.
3553 * Note the "bizarre" use of non-recursion to prevent annoying output
3554 * when running a code profiler.
3556 * Note the use of the new "monster allocation table" code to restrict
3557 * the "get_mon_num()" function to "legal" escort types.
3559 bool place_monster_aux(int who, int y, int x, int r_idx, u32b mode)
3562 monster_race *r_ptr = &r_info[r_idx];
3564 if (one_in_(333) && !(mode & PM_NO_KAGE) && !(mode & PM_FORCE_PET))
3569 /* Place one monster, or fail */
3570 if (!place_monster_one(who, y, x, r_idx, mode)) return (FALSE);
3573 /* Require the "group" flag */
3574 if (!(mode & PM_ALLOW_GROUP)) return (TRUE);
3576 place_monster_m_idx = hack_m_idx_ii;
3578 /* Friends for certain monsters */
3579 if (r_ptr->flags1 & (RF1_FRIENDS))
3581 /* Attempt to place a group */
3582 (void)place_monster_group(who, y, x, r_idx, mode);
3586 /* Escorts for certain monsters */
3587 if (r_ptr->flags1 & (RF1_ESCORT))
3589 /* Set the escort index */
3590 place_monster_idx = r_idx;
3592 /* Try to place several "escorts" */
3593 for (i = 0; i < 32; i++)
3595 int nx, ny, z, d = 3;
3597 /* Pick a location */
3598 scatter(&ny, &nx, y, x, d, 0);
3600 /* Require empty grids */
3601 if (!cave_empty_bold2(ny, nx)) continue;
3603 /* Prepare allocation table */
3604 get_mon_num_prep(place_monster_okay, get_monster_hook2(ny, nx));
3606 /* Pick a random race */
3607 z = get_mon_num(r_ptr->level);
3609 /* Handle failure */
3612 /* Place a single escort */
3613 (void)place_monster_one(place_monster_m_idx, ny, nx, z, mode);
3615 /* Place a "group" of escorts if needed */
3616 if ((r_info[z].flags1 & RF1_FRIENDS) ||
3617 (r_ptr->flags1 & RF1_ESCORTS))
3619 /* Place a group of monsters */
3620 (void)place_monster_group(place_monster_m_idx, ny, nx, z, mode);
3631 * Hack -- attempt to place a monster at the given location
3633 * Attempt to find a monster appropriate to the "monster_level"
3635 bool place_monster(int y, int x, u32b mode)
3639 /* Prepare allocation table */
3640 get_mon_num_prep(get_monster_hook(), get_monster_hook2(y, x));
3642 /* Pick a monster */
3643 r_idx = get_mon_num(monster_level);
3645 /* Handle failure */
3646 if (!r_idx) return (FALSE);
3648 /* Attempt to place the monster */
3649 if (place_monster_aux(0, y, x, r_idx, mode)) return (TRUE);
3656 #ifdef MONSTER_HORDES
3658 bool alloc_horde(int y, int x)
3660 monster_race *r_ptr = NULL;
3663 int attempts = 1000;
3667 /* Prepare allocation table */
3668 get_mon_num_prep(get_monster_hook(), get_monster_hook2(y, x));
3672 /* Pick a monster */
3673 r_idx = get_mon_num(monster_level);
3675 /* Handle failure */
3676 if (!r_idx) return (FALSE);
3678 r_ptr = &r_info[r_idx];
3680 if (r_ptr->flags1 & RF1_UNIQUE) continue;
3682 if (r_idx == MON_HAGURE) continue;
3685 if (attempts < 1) return FALSE;
3691 /* Attempt to place the monster */
3692 if (place_monster_aux(0, y, x, r_idx, 0L)) break;
3695 if (attempts < 1) return FALSE;
3697 m_idx = cave[y][x].m_idx;
3699 if (m_list[m_idx].mflag2 & MFLAG_CHAMELEON) r_ptr = &r_info[m_list[m_idx].r_idx];
3700 summon_kin_type = r_ptr->d_char;
3702 for (attempts = randint1(10) + 5; attempts; attempts--)
3704 scatter(&cy, &cx, y, x, 5, 0);
3706 (void)summon_specific(m_idx, cy, cx, dun_level + 5, SUMMON_KIN, PM_ALLOW_GROUP);
3715 #endif /* MONSTER_HORDES */
3720 * Attempt to allocate a random monster in the dungeon.
3722 * Place the monster at least "dis" distance from the player.
3724 * Use "slp" to choose the initial "sleep" status
3726 * Use "monster_level" for the monster level
3728 bool alloc_monster(int dis, u32b mode)
3731 int attempts_left = 10000;
3732 int guardian = d_info[dungeon_type].final_guardian;
3734 /* Put an Guardian */
3735 if(guardian && d_info[dungeon_type].maxdepth == dun_level && r_info[guardian].cur_num < r_info[guardian].max_num )
3741 /* Find a good position */
3744 /* Get a random spot */
3745 oy = randint1(cur_hgt - 4) + 2;
3746 ox = randint1(cur_wid - 4) + 2;
3748 /* Is it a good spot ? */
3749 if (cave_empty_bold2(oy, ox) && monster_can_cross_terrain(cave[oy][ox].feat, &r_info[guardian]))
3751 /* Place the guardian */
3752 if (place_monster_aux(0, oy, ox, guardian, (PM_ALLOW_GROUP | PM_NO_KAGE | PM_NO_PET))) break;
3760 /* Find a legal, distant, unoccupied, space */
3761 while (attempts_left--)
3763 /* Pick a location */
3764 y = randint0(cur_hgt);
3765 x = randint0(cur_wid);
3767 /* Require empty floor grid (was "naked") */
3768 if (dun_level || (wilderness[p_ptr->wilderness_y][p_ptr->wilderness_x].terrain != TERRAIN_MOUNTAIN))
3770 if (!cave_empty_bold2(y, x)) continue;
3774 if (!cave_empty_bold2(y, x) && (cave[y][x].feat != FEAT_MOUNTAIN)) continue;
3777 /* Accept far away grids */
3778 if (distance(y, x, py, px) > dis) break;
3783 if (cheat_xtra || cheat_hear)
3786 msg_print("·Ù¹ð¡ª¿·¤¿¤Ê¥â¥ó¥¹¥¿¡¼¤òÇÛÃ֤Ǥ¤Þ¤»¤ó¡£¾®¤µ¤¤³¬¤Ç¤¹¤«¡©");
3788 msg_print("Warning! Could not allocate a new monster. Small level?");
3797 #ifdef MONSTER_HORDES
3798 if (randint1(5000) <= dun_level)
3800 if (alloc_horde(y, x))
3803 if (cheat_hear) msg_print("¥â¥ó¥¹¥¿¡¼¤ÎÂç·²");
3805 if (cheat_hear) msg_print("Monster horde.");
3813 #endif /* MONSTER_HORDES */
3815 /* Attempt to place the monster, allow groups */
3816 if (place_monster(y, x, (mode | PM_ALLOW_GROUP))) return (TRUE);
3818 #ifdef MONSTER_HORDES
3820 #endif /* MONSTER_HORDES */
3830 * Hack -- help decide if a monster race is "okay" to summon
3832 static bool summon_specific_okay(int r_idx)
3834 monster_race *r_ptr = &r_info[r_idx];
3836 /* Hack - Only summon dungeon monsters */
3837 if (!monster_dungeon(r_idx)) return (FALSE);
3839 /* Hack -- identify the summoning monster */
3840 if (summon_specific_who > 0)
3842 monster_type *m_ptr = &m_list[summon_specific_who];
3844 /* Do not summon enemies */
3846 /* Friendly vs. opposite aligned normal or pet */
3847 if (((r_ptr->flags3 & RF3_EVIL) &&
3848 (m_ptr->sub_align & SUB_ALIGN_GOOD)) ||
3849 ((r_ptr->flags3 & RF3_GOOD) &&
3850 (m_ptr->sub_align & SUB_ALIGN_EVIL)))
3855 /* Hostile vs. non-hostile */
3856 if (is_hostile(m_ptr) != summon_specific_hostile)
3861 /* Use the player's alignment */
3862 else if (summon_specific_who < 0)
3864 /* Do not summon enemies of the pets */
3865 if ((p_ptr->align < -9) && (r_ptr->flags3 & RF3_GOOD))
3867 if (!one_in_((0-p_ptr->align)/2+1)) return FALSE;
3869 else if ((p_ptr->align > 9) && (r_ptr->flags3 & RF3_EVIL))
3871 if (!one_in_(p_ptr->align/2+1)) return FALSE;
3875 /* Hack -- no specific type specified */
3876 if (!summon_specific_type) return (TRUE);
3878 if (!summon_unique_okay && ((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags7 & RF7_UNIQUE_7))) return FALSE;
3880 if ((summon_specific_who < 0) &&
3881 ((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags7 & RF7_UNIQUE_7)) &&
3882 (((p_ptr->align > 9) && (r_ptr->flags3 & RF3_EVIL)) ||
3883 ((p_ptr->align < -9) && (r_ptr->flags3 & RF3_GOOD))))
3886 if ((r_ptr->flags7 & RF7_CHAMELEON) && (d_info[dungeon_type].flags1 & DF1_CHAMELEON)) return TRUE;
3888 return (summon_specific_aux(r_idx));
3893 * Place a monster (of the specified "type") near the given
3894 * location. Return TRUE if a monster was actually summoned.
3896 * We will attempt to place the monster up to 10 times before giving up.
3898 * Note: SUMMON_UNIQUE and SUMMON_AMBERITES will summon Unique's
3899 * Note: SUMMON_HI_UNDEAD and SUMMON_HI_DRAGON may summon Unique's
3900 * Note: None of the other summon codes will ever summon Unique's.
3902 * This function has been changed. We now take the "monster level"
3903 * of the summoning monster as a parameter, and use that, along with
3904 * the current dungeon level, to help determine the level of the
3905 * desired monster. Note that this is an upper bound, and also
3906 * tends to "prefer" monsters of that level. Currently, we use
3907 * the average of the dungeon and monster levels, and then add
3908 * five to allow slight increases in monster power.
3910 * Note that we use the new "monster allocation table" creation code
3911 * to restrict the "get_mon_num()" function to the set of "legal"
3912 * monsters, making this function much faster and more reliable.
3914 * Note that this function may not succeed, though this is very rare.
3916 bool summon_specific(int who, int y1, int x1, int lev, int type, u32b mode)
3920 if (p_ptr->inside_arena) return (FALSE);
3922 if (!mon_scatter(&y, &x, y1, x1, 2)) return FALSE;
3924 /* Save the summoner */
3925 summon_specific_who = who;
3927 /* Save the "summon" type */
3928 summon_specific_type = type;
3930 summon_unique_okay = (mode & PM_ALLOW_UNIQUE) ? TRUE : FALSE;
3932 /* Save the hostility */
3933 summon_specific_hostile = (!(mode & PM_FORCE_FRIENDLY) && !(is_friendly_idx(who)) && !(mode & PM_FORCE_PET));
3935 /* Prepare allocation table */
3936 get_mon_num_prep(summon_specific_okay, get_monster_hook2(y, x));
3938 /* Pick a monster, using the level calculation */
3939 r_idx = get_mon_num((dun_level + lev) / 2 + 5);
3941 /* Handle failure */
3944 summon_specific_type = 0;
3948 if ((type == SUMMON_BLUE_HORROR) || (type == SUMMON_DAWN)) mode |= PM_NO_KAGE;
3950 /* Attempt to place the monster (awake, allow groups) */
3951 if (!place_monster_aux(who, y, x, r_idx, mode))
3953 summon_specific_type = 0;
3957 summon_specific_type = 0;
3962 /* A "dangerous" function, creates a pet of the specified type */
3963 bool summon_named_creature (int who, int oy, int ox, int r_idx, u32b mode)
3968 /* if (!r_idx) return; */
3970 /* Prevent illegal monsters */
3971 if (r_idx >= max_r_idx) return FALSE;
3973 if (p_ptr->inside_arena) return FALSE;
3975 if (!mon_scatter(&y, &x, oy, ox, 2)) return FALSE;
3977 /* Place it (allow groups) */
3978 return place_monster_aux(who, y, x, r_idx, (mode | PM_NO_KAGE));
3983 * Let the given monster attempt to reproduce.
3985 * Note that "reproduction" REQUIRES empty space.
3987 bool multiply_monster(int m_idx, bool clone, u32b mode)
3989 monster_type *m_ptr = &m_list[m_idx];
3993 if (!mon_scatter(&y, &x, m_ptr->fy, m_ptr->fx, 1))
3996 if (m_ptr->mflag2 & MFLAG_NOPET) mode |= PM_NO_PET;
3998 /* Create a new monster (awake, no groups) */
3999 if (!place_monster_aux(m_idx, y, x, m_ptr->r_idx, (mode | PM_NO_KAGE)))
4004 m_list[hack_m_idx_ii].smart |= SM_CLONED;
4005 m_list[hack_m_idx_ii].mflag2 |= MFLAG_NOPET;
4016 * Dump a message describing a monster's reaction to damage
4018 * Technically should attempt to treat "Beholder"'s as jelly's
4020 void message_pain(int m_idx, int dam)
4022 long oldhp, newhp, tmp;
4025 monster_type *m_ptr = &m_list[m_idx];
4026 monster_race *r_ptr = &r_info[m_ptr->r_idx];
4031 /* Get the monster name */
4032 monster_desc(m_name, m_ptr, 0);
4034 /* Notice non-damage */
4038 msg_format("%^s¤Ï¥À¥á¡¼¥¸¤ò¼õ¤±¤Æ¤¤¤Ê¤¤¡£", m_name);
4040 msg_format("%^s is unharmed.", m_name);
4046 /* Note -- subtle fix -CFT */
4047 newhp = (long)(m_ptr->hp);
4048 oldhp = newhp + (long)(dam);
4049 tmp = (newhp * 100L) / oldhp;
4050 percentage = (int)(tmp);
4053 /* Mushrooms, Eyes, Jellies, Molds, Vortices, Worms, Quylthulgs */
4054 if (strchr(",ejmvwQ", r_ptr->d_char))
4057 if (percentage > 95)
4058 msg_format("%^s¤Ï¤Û¤È¤ó¤Éµ¤¤Ë¤È¤á¤Æ¤¤¤Ê¤¤¡£", m_name);
4059 else if (percentage > 75)
4060 msg_format("%^s¤Ï¤·¤ê¹þ¤ß¤·¤¿¡£", m_name);
4061 else if (percentage > 50)
4062 msg_format("%^s¤Ï½Ì¤³¤Þ¤Ã¤¿¡£", m_name);
4063 else if (percentage > 35)
4064 msg_format("%^s¤ÏÄˤߤ˿̤¨¤¿¡£", m_name);
4065 else if (percentage > 20)
4066 msg_format("%^s¤Ï¿È¤â¤À¤¨¤·¤¿¡£", m_name);
4067 else if (percentage > 10)
4068 msg_format("%^s¤Ï¶ìÄˤǿȤâ¤À¤¨¤·¤¿¡£", m_name);
4070 msg_format("%^s¤Ï¤°¤Ë¤ã¤°¤Ë¤ã¤ÈáÛÚ»¤·¤¿¡£", m_name);
4072 if (percentage > 95)
4073 msg_format("%^s barely notices.", m_name);
4074 else if (percentage > 75)
4075 msg_format("%^s flinches.", m_name);
4076 else if (percentage > 50)
4077 msg_format("%^s squelches.", m_name);
4078 else if (percentage > 35)
4079 msg_format("%^s quivers in pain.", m_name);
4080 else if (percentage > 20)
4081 msg_format("%^s writhes about.", m_name);
4082 else if (percentage > 10)
4083 msg_format("%^s writhes in agony.", m_name);
4085 msg_format("%^s jerks limply.", m_name);
4092 else if (strchr("l", r_ptr->d_char))
4094 if (percentage > 95)
4096 msg_format("%^s¤Ï¤Û¤È¤ó¤Éµ¤¤Ë¤È¤á¤Æ¤¤¤Ê¤¤¡£", m_name);
4098 msg_format("%^s barely notices.", m_name);
4100 else if (percentage > 75)
4102 msg_format("%^s¤Ï¤·¤ê¹þ¤ß¤·¤¿¡£", m_name);
4104 msg_format("%^s flinches.", m_name);
4106 else if (percentage > 50)
4108 msg_format("%^s¤Ïí´í°¤·¤¿¡£", m_name);
4110 msg_format("%^s hesitates.", m_name);
4112 else if (percentage > 35)
4114 msg_format("%^s¤ÏÄˤߤ˿̤¨¤¿¡£", m_name);
4116 msg_format("%^s quivers in pain.", m_name);
4118 else if (percentage > 20)
4120 msg_format("%^s¤Ï¿È¤â¤À¤¨¤·¤¿¡£", m_name);
4122 msg_format("%^s writhes about.", m_name);
4124 else if (percentage > 10)
4126 msg_format("%^s¤Ï¶ìÄˤǿȤâ¤À¤¨¤·¤¿¡£", m_name);
4128 msg_format("%^s writhes in agony.", m_name);
4132 msg_format("%^s¤Ï¤°¤Ë¤ã¤°¤Ë¤ã¤ÈáÛÚ»¤·¤¿¡£", m_name);
4134 msg_format("%^s jerks limply.", m_name);
4139 /* Golems, Walls, Doors, Stairs */
4140 else if (strchr("g#+<>", r_ptr->d_char))
4142 if (percentage > 95)
4144 msg_format("%s¤Ï¹¶·â¤òµ¤¤Ë¤È¤á¤Æ¤¤¤Ê¤¤¡£", m_name);
4146 msg_format("%^s ignores the attack.", m_name);
4148 else if (percentage > 75)
4150 msg_format("%s¤Ï¹¶·â¤Ë¸ª¤ò¤¹¤¯¤á¤¿¡£", m_name);
4152 msg_format("%^s shrugs off the attack.", m_name);
4154 else if (percentage > 50)
4156 msg_format("%^s¤ÏÍëÌĤΤ褦¤ËËʤ¨¤¿¡£", m_name);
4158 msg_format("%^s roars thunderously.", m_name);
4160 else if (percentage > 35)
4162 msg_format("%^s¤Ï¶ì¤·¤²¤ËËʤ¨¤¿¡£", m_name);
4164 msg_format("%^s rumbles.", m_name);
4166 else if (percentage > 20)
4168 msg_format("%^s¤Ï¤¦¤á¤¤¤¿¡£", m_name);
4170 msg_format("%^s grunts.", m_name);
4172 else if (percentage > 10)
4174 msg_format("%^s¤Ïí´í°¤·¤¿¡£", m_name);
4176 msg_format("%^s hesitates.", m_name);
4180 msg_format("%^s¤Ï¤¯¤·¤ã¤¯¤·¤ã¤Ë¤Ê¤Ã¤¿¡£", m_name);
4182 msg_format("%^s crumples.", m_name);
4187 /* Snakes, Hydrae, Reptiles, Mimics */
4188 else if (strchr("JMR", r_ptr->d_char) || !isalpha(r_ptr->d_char))
4190 if (percentage > 95)
4192 msg_format("%^s¤Ï¤Û¤È¤ó¤Éµ¤¤Ë¤È¤á¤Æ¤¤¤Ê¤¤¡£", m_name);
4194 msg_format("%^s barely notices.", m_name);
4196 else if (percentage > 75)
4198 msg_format("%^s¤Ï¥·¡¼¥Ã¤ÈÌĤ¤¤¿¡£", m_name);
4200 msg_format("%^s hisses.", m_name);
4202 else if (percentage > 50)
4204 msg_format("%^s¤ÏÅܤäÆƬ¤ò¾å¤²¤¿¡£", m_name);
4206 msg_format("%^s rears up in anger.", m_name);
4208 else if (percentage > 35)
4210 msg_format("%^s¤ÏÌÔÁ³¤È°Ò³Å¤·¤¿¡£", m_name);
4212 msg_format("%^s hisses furiously.", m_name);
4214 else if (percentage > 20)
4216 msg_format("%^s¤Ï¿È¤â¤À¤¨¤·¤¿¡£", m_name);
4218 msg_format("%^s writhes about.", m_name);
4220 else if (percentage > 10)
4222 msg_format("%^s¤Ï¶ìÄˤǿȤâ¤À¤¨¤·¤¿¡£", m_name);
4224 msg_format("%^s writhes in agony.", m_name);
4228 msg_format("%^s¤Ï¤°¤Ë¤ã¤°¤Ë¤ã¤ÈáÛÚ»¤·¤¿¡£", m_name);
4230 msg_format("%^s jerks limply.", m_name);
4236 else if (strchr("f", r_ptr->d_char))
4238 if (percentage > 95)
4240 msg_format("%s¤Ï¹¶·â¤Ë¸ª¤ò¤¹¤¯¤á¤¿¡£", m_name);
4242 msg_format("%^s shrugs off the attack.", m_name);
4244 else if (percentage > 75)
4246 msg_format("%^s¤ÏËʤ¨¤¿¡£", m_name);
4248 msg_format("%^s roars.", m_name);
4250 else if (percentage > 50)
4252 msg_format("%^s¤ÏÅܤäÆËʤ¨¤¿¡£", m_name);
4254 msg_format("%^s growls angrily.", m_name);
4256 else if (percentage > 35)
4258 msg_format("%^s¤ÏÄˤߤǥ·¡¼¥Ã¤ÈÌĤ¤¤¿¡£", m_name);
4260 msg_format("%^s hisses with pain.", m_name);
4262 else if (percentage > 20)
4264 msg_format("%^s¤ÏÄˤߤǼ塹¤·¤¯ÌĤ¤¤¿¡£", m_name);
4266 msg_format("%^s mewls in pain.", m_name);
4268 else if (percentage > 10)
4270 msg_format("%^s¤Ï¶ìÄˤˤ¦¤á¤¤¤¿¡£", m_name);
4272 msg_format("%^s hisses in agony.", m_name);
4276 msg_format("%s¤Ï°¥¤ì¤ÊÌĤÀ¼¤ò½Ð¤·¤¿¡£", m_name);
4278 msg_format("%^s mewls pitifully.", m_name);
4283 /* Ants, Centipedes, Flies, Insects, Beetles, Spiders */
4284 else if (strchr("acFIKS", r_ptr->d_char))
4286 if (percentage > 95)
4288 msg_format("%s¤Ï¹¶·â¤òµ¤¤Ë¤È¤á¤Æ¤¤¤Ê¤¤¡£", m_name);
4290 msg_format("%^s ignores the attack.", m_name);
4292 else if (percentage > 75)
4294 msg_format("%^s¤Ï¥¡¼¥¡¼ÌĤ¤¤¿¡£", m_name);
4296 msg_format("%^s chitters.", m_name);
4299 else if (percentage > 50)
4301 msg_format("%^s¤Ï¥è¥í¥è¥íƨ¤²²ó¤Ã¤¿¡£", m_name);
4303 msg_format("%^s scuttles about.", m_name);
4306 else if (percentage > 35)
4308 msg_format("%^s¤Ï¤¦¤ë¤µ¤¯ÌĤ¤¤¿¡£", m_name);
4310 msg_format("%^s twitters.", m_name);
4313 else if (percentage > 20)
4315 msg_format("%^s¤ÏÄˤߤËáÛÚ»¤·¤¿¡£", m_name);
4317 msg_format("%^s jerks in pain.", m_name);
4320 else if (percentage > 10)
4322 msg_format("%^s¤Ï¶ìÄˤÇáÛÚ»¤·¤¿¡£", m_name);
4324 msg_format("%^s jerks in agony.", m_name);
4329 msg_format("%^s¤Ï¥Ô¥¯¥Ô¥¯¤Ò¤¤Ä¤Ã¤¿¡£", m_name);
4331 msg_format("%^s twitches.", m_name);
4338 else if (strchr("B", r_ptr->d_char))
4340 if (percentage > 95)
4342 msg_format("%^s¤Ï¤µ¤¨¤º¤Ã¤¿¡£", m_name);
4344 msg_format("%^s chirps.", m_name);
4347 else if (percentage > 75)
4349 msg_format("%^s¤Ï¥Ô¡¼¥Ô¡¼ÌĤ¤¤¿¡£", m_name);
4351 msg_format("%^s twitters.", m_name);
4354 else if (percentage > 50)
4356 msg_format("%^s¤Ï¥®¥ã¡¼¥®¥ã¡¼ÌĤ¤¤¿¡£", m_name);
4358 msg_format("%^s squawks.", m_name);
4361 else if (percentage > 35)
4363 msg_format("%^s¤Ï¥®¥ã¡¼¥®¥ã¡¼ÌĤ¤ï¤á¤¤¤¿¡£", m_name);
4365 msg_format("%^s chatters.", m_name);
4368 else if (percentage > 20)
4370 msg_format("%^s¤Ï¶ì¤·¤ó¤À¡£", m_name);
4372 msg_format("%^s jeers.", m_name);
4375 else if (percentage > 10)
4377 msg_format("%^s¤Ï¤Î¤¿¤¦¤Á²ó¤Ã¤¿¡£", m_name);
4379 msg_format("%^s flutters about.", m_name);
4384 msg_format("%^s¤Ï¥¡¼¥¡¼¤ÈÌĤ¶«¤ó¤À¡£", m_name);
4386 msg_format("%^s squeaks.", m_name);
4392 /* Dragons, Demons, High Undead */
4393 else if (strchr("duDLUW", r_ptr->d_char))
4395 if (percentage > 95)
4397 msg_format("%s¤Ï¹¶·â¤òµ¤¤Ë¤È¤á¤Æ¤¤¤Ê¤¤¡£", m_name);
4399 msg_format("%^s ignores the attack.", m_name);
4402 else if (percentage > 75)
4404 msg_format("%^s¤Ï¤·¤ê¹þ¤ß¤·¤¿¡£", m_name);
4406 msg_format("%^s flinches.", m_name);
4409 else if (percentage > 50)
4411 msg_format("%^s¤ÏÄˤߤǥ·¡¼¥Ã¤ÈÌĤ¤¤¿¡£", m_name);
4413 msg_format("%^s hisses in pain.", m_name);
4416 else if (percentage > 35)
4418 msg_format("%^s¤ÏÄˤߤǤ¦¤Ê¤Ã¤¿¡£", m_name);
4420 msg_format("%^s snarls with pain.", m_name);
4423 else if (percentage > 20)
4425 msg_format("%^s¤ÏÄˤߤËËʤ¨¤¿¡£", m_name);
4427 msg_format("%^s roars with pain.", m_name);
4430 else if (percentage > 10)
4432 msg_format("%^s¤Ï¶ì¤·¤²¤Ë¶«¤ó¤À¡£", m_name);
4434 msg_format("%^s gasps.", m_name);
4439 msg_format("%^s¤Ï¼å¡¹¤·¤¯¤¦¤Ê¤Ã¤¿¡£", m_name);
4441 msg_format("%^s snarls feebly.", m_name);
4448 else if (strchr("s", r_ptr->d_char))
4450 if (percentage > 95)
4452 msg_format("%s¤Ï¹¶·â¤òµ¤¤Ë¤È¤á¤Æ¤¤¤Ê¤¤¡£", m_name);
4454 msg_format("%^s ignores the attack.", m_name);
4457 else if (percentage > 75)
4459 msg_format("%s¤Ï¹¶·â¤Ë¸ª¤ò¤¹¤¯¤á¤¿¡£", m_name);
4461 msg_format("%^s shrugs off the attack.", m_name);
4464 else if (percentage > 50)
4466 msg_format("%^s¤Ï¥«¥¿¥«¥¿¤È¾Ð¤Ã¤¿¡£", m_name);
4468 msg_format("%^s rattles.", m_name);
4471 else if (percentage > 35)
4473 msg_format("%^s¤Ï¤è¤í¤á¤¤¤¿¡£", m_name);
4475 msg_format("%^s stumbles.", m_name);
4478 else if (percentage > 20)
4480 msg_format("%^s¤Ï¥«¥¿¥«¥¿¸À¤Ã¤¿¡£", m_name);
4482 msg_format("%^s rattles.", m_name);
4485 else if (percentage > 10)
4487 msg_format("%^s¤Ï¤è¤í¤á¤¤¤¿¡£", m_name);
4489 msg_format("%^s staggers.", m_name);
4494 msg_format("%^s¤Ï¥¬¥¿¥¬¥¿¸À¤Ã¤¿¡£", m_name);
4496 msg_format("%^s clatters.", m_name);
4503 else if (strchr("z", r_ptr->d_char))
4505 if (percentage > 95)
4507 msg_format("%s¤Ï¹¶·â¤òµ¤¤Ë¤È¤á¤Æ¤¤¤Ê¤¤¡£", m_name);
4509 msg_format("%^s ignores the attack.", m_name);
4512 else if (percentage > 75)
4514 msg_format("%s¤Ï¹¶·â¤Ë¸ª¤ò¤¹¤¯¤á¤¿¡£", m_name);
4516 msg_format("%^s shrugs off the attack.", m_name);
4519 else if (percentage > 50)
4521 msg_format("%^s¤Ï¤¦¤á¤¤¤¿¡£", m_name);
4523 msg_format("%^s groans.", m_name);
4526 else if (percentage > 35)
4528 msg_format("%s¤Ï¶ì¤·¤²¤Ë¤¦¤á¤¤¤¿¡£", m_name);
4530 msg_format("%^s moans.", m_name);
4533 else if (percentage > 20)
4535 msg_format("%^s¤Ïí´í°¤·¤¿¡£", m_name);
4537 msg_format("%^s hesitates.", m_name);
4540 else if (percentage > 10)
4542 msg_format("%^s¤Ï¤¦¤Ê¤Ã¤¿¡£", m_name);
4544 msg_format("%^s grunts.", m_name);
4549 msg_format("%^s¤Ï¤è¤í¤á¤¤¤¿¡£", m_name);
4551 msg_format("%^s staggers.", m_name);
4558 else if (strchr("G", r_ptr->d_char))
4561 if (percentage > 95)
4563 msg_format("%s¤Ï¹¶·â¤òµ¤¤Ë¤È¤á¤Æ¤¤¤Ê¤¤¡£", m_name);
4565 msg_format("%^s ignores the attack.", m_name);
4568 else if (percentage > 75)
4570 msg_format("%s¤Ï¹¶·â¤Ë¸ª¤ò¤¹¤¯¤á¤¿¡£", m_name);
4572 msg_format("%^s shrugs off the attack.", m_name);
4575 else if (percentage > 50)
4577 msg_format("%s¤Ï¤¦¤á¤¤¤¿¡£", m_name);
4579 msg_format("%^s moans.", m_name);
4582 else if (percentage > 35)
4584 msg_format("%^s¤Ïµã¤¤ï¤á¤¤¤¿¡£", m_name);
4586 msg_format("%^s wails.", m_name);
4589 else if (percentage > 20)
4591 msg_format("%^s¤ÏËʤ¨¤¿¡£", m_name);
4593 msg_format("%^s howls.", m_name);
4596 else if (percentage > 10)
4598 msg_format("%s¤Ï¼å¡¹¤·¤¯¤¦¤á¤¤¤¿¡£", m_name);
4600 msg_format("%^s moans softly.", m_name);
4605 msg_format("%^s¤Ï¤«¤¹¤«¤Ë¤¦¤á¤¤¤¿¡£", m_name);
4607 msg_format("%^s sighs.", m_name);
4613 /* Dogs and Hounds */
4614 else if (strchr("CZ", r_ptr->d_char))
4617 if (percentage > 95)
4618 msg_format("%^s¤Ï¹¶·â¤Ë¸ª¤ò¤¹¤¯¤á¤¿¡£", m_name);
4619 else if (percentage > 75)
4620 msg_format("%^s¤ÏÄˤߤǤ¦¤Ê¤Ã¤¿¡£", m_name);
4621 else if (percentage > 50)
4622 msg_format("%^s¤ÏÄˤߤǥ¥ã¥ó¥¥ã¥óËʤ¨¤¿¡£", m_name);
4623 else if (percentage > 35)
4624 msg_format("%^s¤ÏÄˤߤÇÌĤ¤ï¤á¤¤¤¿¡£", m_name);
4625 else if (percentage > 20)
4626 msg_format("%^s¤Ï¶ìÄˤΤ¢¤Þ¤êÌĤ¤ï¤á¤¤¤¿¡£", m_name);
4627 else if (percentage > 10)
4628 msg_format("%^s¤Ï¶ìÄˤǤâ¤À¤¨¶ì¤·¤ó¤À¡£", m_name);
4630 msg_format("%^s¤Ï¼å¡¹¤·¤¯Ëʤ¨¤¿¡£", m_name);
4632 if (percentage > 95)
4633 msg_format("%^s shrugs off the attack.", m_name);
4634 else if (percentage > 75)
4635 msg_format("%^s snarls with pain.", m_name);
4636 else if (percentage > 50)
4637 msg_format("%^s yelps in pain.", m_name);
4638 else if (percentage > 35)
4639 msg_format("%^s howls in pain.", m_name);
4640 else if (percentage > 20)
4641 msg_format("%^s howls in agony.", m_name);
4642 else if (percentage > 10)
4643 msg_format("%^s writhes in agony.", m_name);
4645 msg_format("%^s yelps feebly.", m_name);
4650 /* One type of monsters (ignore,squeal,shriek) */
4651 else if (strchr("Xbilqrt", r_ptr->d_char))
4654 if (percentage > 95)
4655 msg_format("%^s¤Ï¹¶·â¤òµ¤¤Ë¤È¤á¤Æ¤¤¤Ê¤¤¡£", m_name);
4656 else if (percentage > 75)
4657 msg_format("%^s¤ÏÄˤߤǤ¦¤Ê¤Ã¤¿¡£", m_name);
4658 else if (percentage > 50)
4659 msg_format("%^s¤ÏÄˤߤǶ«¤ó¤À¡£", m_name);
4660 else if (percentage > 35)
4661 msg_format("%^s¤ÏÄˤߤÇÀ䶫¤·¤¿¡£", m_name);
4662 else if (percentage > 20)
4663 msg_format("%^s¤Ï¶ìÄˤΤ¢¤Þ¤êÀ䶫¤·¤¿¡£", m_name);
4664 else if (percentage > 10)
4665 msg_format("%^s¤Ï¶ìÄˤǤâ¤À¤¨¶ì¤·¤ó¤À¡£", m_name);
4667 msg_format("%^s¤Ï¼å¡¹¤·¤¯¶«¤ó¤À¡£", m_name);
4669 if (percentage > 95)
4670 msg_format("%^s ignores the attack.", m_name);
4671 else if (percentage > 75)
4672 msg_format("%^s grunts with pain.", m_name);
4673 else if (percentage > 50)
4674 msg_format("%^s squeals in pain.", m_name);
4675 else if (percentage > 35)
4676 msg_format("%^s shrieks in pain.", m_name);
4677 else if (percentage > 20)
4678 msg_format("%^s shrieks in agony.", m_name);
4679 else if (percentage > 10)
4680 msg_format("%^s writhes in agony.", m_name);
4682 msg_format("%^s cries out feebly.", m_name);
4687 /* Another type of monsters (shrug,cry,scream) */
4691 if (percentage > 95)
4692 msg_format("%^s¤Ï¹¶·â¤Ë¸ª¤ò¤¹¤¯¤á¤¿¡£", m_name);
4693 else if (percentage > 75)
4694 msg_format("%^s¤ÏÄˤߤǤ¦¤Ê¤Ã¤¿¡£", m_name);
4695 else if (percentage > 50)
4696 msg_format("%^s¤ÏÄˤߤǶ«¤ó¤À¡£", m_name);
4697 else if (percentage > 35)
4698 msg_format("%^s¤ÏÄˤߤÇÀ䶫¤·¤¿¡£", m_name);
4699 else if (percentage > 20)
4700 msg_format("%^s¤Ï¶ìÄˤΤ¢¤Þ¤êÀ䶫¤·¤¿¡£", m_name);
4701 else if (percentage > 10)
4702 msg_format("%^s¤Ï¶ìÄˤǤâ¤À¤¨¶ì¤·¤ó¤À¡£", m_name);
4704 msg_format("%^s¤Ï¼å¡¹¤·¤¯¶«¤ó¤À¡£", m_name);
4706 if (percentage > 95)
4707 msg_format("%^s shrugs off the attack.", m_name);
4708 else if (percentage > 75)
4709 msg_format("%^s grunts with pain.", m_name);
4710 else if (percentage > 50)
4711 msg_format("%^s cries out in pain.", m_name);
4712 else if (percentage > 35)
4713 msg_format("%^s screams in pain.", m_name);
4714 else if (percentage > 20)
4715 msg_format("%^s screams in agony.", m_name);
4716 else if (percentage > 10)
4717 msg_format("%^s writhes in agony.", m_name);
4719 msg_format("%^s cries out feebly.", m_name);
4727 * Learn about an "observed" resistance.
4729 void update_smart_learn(int m_idx, int what)
4731 #ifdef DRS_SMART_OPTIONS
4733 monster_type *m_ptr = &m_list[m_idx];
4735 monster_race *r_ptr = &r_info[m_ptr->r_idx];
4738 /* Not allowed to learn */
4739 if (!smart_learn) return;
4741 /* Too stupid to learn anything */
4742 if (r_ptr->flags2 & (RF2_STUPID)) return;
4744 /* Not intelligent, only learn sometimes */
4745 if (!(r_ptr->flags2 & (RF2_SMART)) && (randint0(100) < 50)) return;
4750 /* Analyze the knowledge */
4754 if (p_ptr->resist_acid) m_ptr->smart |= (SM_RES_ACID);
4755 if (p_ptr->oppose_acid) m_ptr->smart |= (SM_OPP_ACID);
4756 if (p_ptr->immune_acid) m_ptr->smart |= (SM_IMM_ACID);
4760 if (p_ptr->resist_elec) m_ptr->smart |= (SM_RES_ELEC);
4761 if (p_ptr->oppose_elec) m_ptr->smart |= (SM_OPP_ELEC);
4762 if (p_ptr->immune_elec) m_ptr->smart |= (SM_IMM_ELEC);
4766 if (p_ptr->resist_fire) m_ptr->smart |= (SM_RES_FIRE);
4767 if (p_ptr->oppose_fire) m_ptr->smart |= (SM_OPP_FIRE);
4768 if (p_ptr->immune_fire) m_ptr->smart |= (SM_IMM_FIRE);
4772 if (p_ptr->resist_cold) m_ptr->smart |= (SM_RES_COLD);
4773 if (p_ptr->oppose_cold) m_ptr->smart |= (SM_OPP_COLD);
4774 if (p_ptr->immune_cold) m_ptr->smart |= (SM_IMM_COLD);
4778 if (p_ptr->resist_pois) m_ptr->smart |= (SM_RES_POIS);
4779 if (p_ptr->oppose_pois) m_ptr->smart |= (SM_OPP_POIS);
4784 if (p_ptr->resist_neth) m_ptr->smart |= (SM_RES_NETH);
4788 if (p_ptr->resist_lite) m_ptr->smart |= (SM_RES_LITE);
4792 if (p_ptr->resist_dark) m_ptr->smart |= (SM_RES_DARK);
4796 if (p_ptr->resist_fear) m_ptr->smart |= (SM_RES_FEAR);
4800 if (p_ptr->resist_conf) m_ptr->smart |= (SM_RES_CONF);
4804 if (p_ptr->resist_chaos) m_ptr->smart |= (SM_RES_CHAOS);
4808 if (p_ptr->resist_disen) m_ptr->smart |= (SM_RES_DISEN);
4812 if (p_ptr->resist_blind) m_ptr->smart |= (SM_RES_BLIND);
4816 if (p_ptr->resist_nexus) m_ptr->smart |= (SM_RES_NEXUS);
4820 if (p_ptr->resist_sound) m_ptr->smart |= (SM_RES_SOUND);
4824 if (p_ptr->resist_shard) m_ptr->smart |= (SM_RES_SHARD);
4828 if (p_ptr->free_act) m_ptr->smart |= (SM_IMM_FREE);
4832 if (!p_ptr->msp) m_ptr->smart |= (SM_IMM_MANA);
4836 if (p_ptr->reflect) m_ptr-> smart |= (SM_IMM_REFLECT);
4840 #endif /* DRS_SMART_OPTIONS */
4846 * Place the player in the dungeon XXX XXX
4848 bool player_place(int y, int x)
4850 /* Paranoia XXX XXX */
4851 if (cave[y][x].m_idx != 0) return FALSE;
4853 /* Save player location */
4863 * Drop all items carried by a monster
4865 void monster_drop_carried_objects(monster_type *m_ptr)
4867 s16b this_o_idx, next_o_idx = 0;
4873 /* Drop objects being carried */
4874 for (this_o_idx = m_ptr->hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
4876 /* Acquire object */
4877 o_ptr = &o_list[this_o_idx];
4879 /* Acquire next object */
4880 next_o_idx = o_ptr->next_o_idx;
4883 o_ptr->held_m_idx = 0;
4885 /* Get local object */
4888 /* Copy the object */
4889 object_copy(q_ptr, o_ptr);
4891 /* Delete the object */
4892 delete_object_idx(this_o_idx);
4895 (void)drop_near(q_ptr, -1, m_ptr->fy, m_ptr->fx);
4898 /* Forget objects */
4899 m_ptr->hold_o_idx = 0;