4 * Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke
6 * This software may be copied and distributed for educational, research,
7 * and not for profit purposes provided that this copyright and statement
8 * are included in all such copies. Other copyrights may also apply.
11 /* Purpose: misc code for monsters */
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 & MFLAG2_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 /* Skip dead monsters */
480 if (!m_ptr->r_idx) continue;
482 /* Hack -- Reduce the racial counter */
483 real_r_ptr(m_ptr)->cur_num = 0;
485 /* Monster is gone */
486 cave[m_ptr->fy][m_ptr->fx].m_idx = 0;
488 /* Wipe the Monster */
489 (void)WIPE(m_ptr, monster_type);
499 /* Hack -- reset "reproducer" count */
502 /* Hack -- no more target */
507 /* Hack -- no more tracking */
513 * Acquires and returns the index of a "free" monster.
515 * This routine should almost never fail, but it *can* happen.
522 /* Normal allocation */
523 if (m_max < max_m_idx)
525 /* Access the next hole */
528 /* Expand the array */
534 /* Return the index */
539 /* Recycle dead monsters */
540 for (i = 1; i < m_max; i++)
544 /* Acquire monster */
547 /* Skip live monsters */
548 if (m_ptr->r_idx) continue;
553 /* Use this monster */
558 /* Warn the player (except during dungeon creation) */
560 if (character_dungeon) msg_print("¥â¥ó¥¹¥¿¡¼¤¬Â¿¤¹¤®¤ë¡ª");
562 if (character_dungeon) msg_print("Too many monsters!");
566 /* Try not to crash */
574 * Hack -- the "type" of the current "summon specific"
576 static int summon_specific_type = 0;
580 * Hack -- the index of the summoning monster
582 static int summon_specific_who = -1;
586 * Hack -- the hostility of the summoned monster
588 static bool summon_specific_hostile = TRUE;
590 static bool summon_unique_okay = FALSE;
593 static bool summon_specific_aux(int r_idx)
595 monster_race *r_ptr = &r_info[r_idx];
598 /* Check our requirements */
599 switch (summon_specific_type)
603 okay = (r_ptr->d_char == 'a');
609 okay = (r_ptr->d_char == 'S');
615 okay = ((r_ptr->d_char == 'C') || (r_ptr->d_char == 'Z'));
621 okay = (r_ptr->d_char == 'M');
627 okay = (r_ptr->d_char == 'A' && ((r_ptr->flags3 & RF3_EVIL) || (r_ptr->flags3 & RF3_GOOD)));
633 okay = (r_ptr->flags3 & RF3_DEMON);
639 okay = (r_ptr->flags3 & RF3_UNDEAD);
645 okay = (r_ptr->flags3 & RF3_DRAGON);
649 case SUMMON_HI_UNDEAD:
651 okay = ((r_ptr->d_char == 'L') ||
652 (r_ptr->d_char == 'V') ||
653 (r_ptr->d_char == 'W'));
657 case SUMMON_HI_DRAGON:
659 okay = (r_ptr->d_char == 'D');
663 case SUMMON_HI_DEMON:
665 okay = (((r_ptr->d_char == 'U') ||
666 (r_ptr->d_char == 'H') ||
667 (r_ptr->d_char == 'B')) &&
668 (r_ptr->flags3 & RF3_DEMON)) ? TRUE : FALSE;
672 case SUMMON_AMBERITES:
674 okay = (r_ptr->flags3 & (RF3_AMBERITE)) ? TRUE : FALSE;
680 okay = (r_ptr->flags1 & (RF1_UNIQUE)) ? TRUE : FALSE;
684 case SUMMON_BIZARRE1:
686 okay = (r_ptr->d_char == 'm');
689 case SUMMON_BIZARRE2:
691 okay = (r_ptr->d_char == 'b');
694 case SUMMON_BIZARRE3:
696 okay = (r_ptr->d_char == 'Q');
700 case SUMMON_BIZARRE4:
702 okay = (r_ptr->d_char == 'v');
706 case SUMMON_BIZARRE5:
708 okay = (r_ptr->d_char == '$');
712 case SUMMON_BIZARRE6:
714 okay = ((r_ptr->d_char == '!') ||
715 (r_ptr->d_char == '?') ||
716 (r_ptr->d_char == '=') ||
717 (r_ptr->d_char == '$') ||
718 (r_ptr->d_char == '|'));
724 okay = (r_ptr->d_char == 'g');
730 okay = ((r_ptr->d_char == 'U') &&
731 (r_ptr->flags4 & RF4_ROCKET));
738 okay = ((r_ptr->d_char == summon_kin_type) && (r_idx != MON_HAGURE));
744 okay = (r_idx == MON_DAWN);
750 okay = (r_ptr->flags3 & (RF3_ANIMAL));
754 case SUMMON_ANIMAL_RANGER:
756 okay = ((r_ptr->flags3 & (RF3_ANIMAL)) &&
757 (strchr("abcflqrwBCHIJKMRS", r_ptr->d_char)) &&
758 !(r_ptr->flags3 & (RF3_DRAGON)) &&
759 !(r_ptr->flags3 & (RF3_EVIL)) &&
760 !(r_ptr->flags3 & (RF3_UNDEAD)) &&
761 !(r_ptr->flags3 & (RF3_DEMON)) &&
762 !(r_ptr->flags2 & (RF2_MULTIPLY)) &&
763 !(r_ptr->flags4 || r_ptr->flags5 || r_ptr->flags6));
767 case SUMMON_HI_DRAGON_LIVING:
769 okay = ((r_ptr->d_char == 'D') &&
770 !(r_ptr->flags3 & (RF3_DEMON | RF3_UNDEAD | RF3_NONLIVING)));
776 okay = (!(r_ptr->flags3 & (RF3_DEMON | RF3_UNDEAD | RF3_NONLIVING)));
782 okay = (r_idx == MON_PHANTOM_B || r_idx == MON_PHANTOM_W);
786 case SUMMON_BLUE_HORROR:
788 okay = (r_idx == MON_BLUE_HORROR);
792 case SUMMON_ELEMENTAL:
794 okay = (r_ptr->d_char == 'E');
800 okay = (r_ptr->d_char == 'v');
806 okay = (r_ptr->d_char == 'H');
812 okay = (r_ptr->d_char == 'B');
816 case SUMMON_KAMIKAZE:
819 for (i = 0; i < 4; i++)
820 if (r_ptr->blow[i].method == RBM_EXPLODE) okay = TRUE;
824 case SUMMON_KAMIKAZE_LIVING:
828 for (i = 0; i < 4; i++)
829 if (r_ptr->blow[i].method == RBM_EXPLODE) okay = TRUE;
830 okay = (okay && (!(r_ptr->flags3 & (RF3_DEMON | RF3_UNDEAD | RF3_NONLIVING))));
836 okay = (r_idx == MON_MANES);
842 okay = (r_idx == MON_LOUSE);
846 case SUMMON_GUARDIANS:
848 okay = (r_ptr->flags7 & RF7_GUARDIAN);
854 okay = ((r_idx == MON_NOV_PALADIN) ||
855 (r_idx == MON_NOV_PALADIN_G) ||
856 (r_idx == MON_PALADIN) ||
857 (r_idx == MON_W_KNIGHT) ||
858 (r_idx == MON_ULTRA_PALADIN) ||
859 (r_idx == MON_KNI_TEMPLAR));
865 okay = (r_ptr->d_char == 'B' &&
866 (r_ptr->flags8 & RF8_WILD_MOUNTAIN) &&
867 (r_ptr->flags8 & RF8_WILD_ONLY));
871 case SUMMON_PIRANHAS:
873 okay = (r_idx == MON_PIRANHA);
877 case SUMMON_ARMAGE_GOOD:
879 okay = (r_ptr->d_char == 'A' && (r_ptr->flags3 & RF3_GOOD));
883 case SUMMON_ARMAGE_EVIL:
885 okay = ((r_ptr->flags3 & RF3_DEMON) ||
886 (r_ptr->d_char == 'A' && (r_ptr->flags3 & RF3_EVIL)));
892 /* Since okay is int, "return (okay);" is not correct. */
893 return (bool)(okay ? TRUE : FALSE);
897 static int chameleon_change_m_idx = 0;
901 * Some dungeon types restrict the possible monsters.
902 * Return TRUE is the monster is OK and FALSE otherwise
904 static bool restrict_monster_to_dungeon(int r_idx)
906 dungeon_info_type *d_ptr = &d_info[dungeon_type];
907 monster_race *r_ptr = &r_info[r_idx];
910 if (d_ptr->flags1 & DF1_CHAMELEON)
912 if (chameleon_change_m_idx) return TRUE;
914 if (d_ptr->flags1 & DF1_NO_MAGIC)
916 if (r_idx != MON_CHAMELEON &&
918 !(r_ptr->flags4 & RF4_NOMAGIC_MASK) &&
919 !(r_ptr->flags5 & RF5_NOMAGIC_MASK) &&
920 !(r_ptr->flags6 & RF6_NOMAGIC_MASK))
923 if (d_ptr->flags1 & DF1_NO_MELEE)
925 if (r_idx == MON_CHAMELEON) return TRUE;
926 if (!(r_ptr->flags4 & (RF4_BOLT_MASK | RF4_BEAM_MASK | RF4_BALL_MASK)) &&
927 !(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)) &&
928 !(r_ptr->flags6 & (RF6_BOLT_MASK | RF6_BEAM_MASK | RF6_BALL_MASK)))
931 if (d_ptr->flags1 & DF1_BEGINNER)
933 if (r_ptr->level > dun_level)
937 if (d_ptr->special_div == 64) return TRUE;
938 if (summon_specific_type && !(d_ptr->flags1 & DF1_CHAMELEON)) return TRUE;
940 if(d_ptr->mode == DUNGEON_MODE_AND)
944 if((d_ptr->mflags1 & r_ptr->flags1) != d_ptr->mflags1)
949 if((d_ptr->mflags2 & r_ptr->flags2) != d_ptr->mflags2)
954 if((d_ptr->mflags3 & r_ptr->flags3) != d_ptr->mflags3)
959 if((d_ptr->mflags4 & r_ptr->flags4) != d_ptr->mflags4)
964 if((d_ptr->mflags5 & r_ptr->flags5) != d_ptr->mflags5)
969 if((d_ptr->mflags6 & r_ptr->flags6) != d_ptr->mflags6)
974 if((d_ptr->mflags7 & r_ptr->flags7) != d_ptr->mflags7)
979 if((d_ptr->mflags8 & r_ptr->flags8) != d_ptr->mflags8)
984 if((d_ptr->mflags9 & r_ptr->flags9) != d_ptr->mflags9)
987 for(a = 0; a < 5; a++)
988 if(d_ptr->r_char[a] && (d_ptr->r_char[a] != r_ptr->d_char)) return FALSE;
990 else if(d_ptr->mode == DUNGEON_MODE_NAND)
992 byte ok[9 + 5], i = 0, j = 0;
997 if(d_ptr->mflags1 & r_ptr->flags1)
1003 if(d_ptr->mflags2 & r_ptr->flags2)
1009 if(d_ptr->mflags3 & r_ptr->flags3)
1015 if(d_ptr->mflags4 & r_ptr->flags4)
1021 if(d_ptr->mflags5 & r_ptr->flags5)
1027 if(d_ptr->mflags6 & r_ptr->flags6)
1033 if(d_ptr->mflags7 & r_ptr->flags7)
1039 if(d_ptr->mflags8 & r_ptr->flags8)
1045 if(d_ptr->mflags9 & r_ptr->flags9)
1049 for(a = 0; a < 5; a++)
1051 if(d_ptr->r_char[a])
1054 if (d_ptr->r_char[a] != r_ptr->d_char) ok[9 + a] = 1;
1058 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];
1060 if(i == j) return FALSE;
1062 else if(d_ptr->mode == DUNGEON_MODE_OR)
1067 for(i = 0; i < 32; i++)
1069 flag = d_ptr->mflags1 & (1 << i);
1070 if(r_ptr->flags1 & flag) ok = TRUE;
1072 flag = d_ptr->mflags2 & (1 << i);
1073 if(r_ptr->flags2 & flag) ok = TRUE;
1075 flag = d_ptr->mflags3 & (1 << i);
1076 if(r_ptr->flags3 & flag) ok = TRUE;
1078 flag = d_ptr->mflags4 & (1 << i);
1079 if(r_ptr->flags4 & flag) ok = TRUE;
1081 flag = d_ptr->mflags5 & (1 << i);
1082 if(r_ptr->flags5 & flag) ok = TRUE;
1084 flag = d_ptr->mflags6 & (1 << i);
1085 if(r_ptr->flags6 & flag) ok = TRUE;
1087 flag = d_ptr->mflags7 & (1 << i);
1088 if(r_ptr->flags7 & flag) ok = TRUE;
1090 flag = d_ptr->mflags8 & (1 << i);
1091 if(r_ptr->flags8 & flag) ok = TRUE;
1093 flag = d_ptr->mflags9 & (1 << i);
1094 if(r_ptr->flags9 & flag) ok = TRUE;
1096 for(a = 0; a < 5; a++)
1097 if(d_ptr->r_char[a] == r_ptr->d_char) ok = TRUE;
1101 else if(d_ptr->mode == DUNGEON_MODE_NOR)
1106 for(i = 0; i < 32; i++)
1108 flag = d_ptr->mflags1 & (1 << i);
1109 if(r_ptr->flags1 & flag) ok = FALSE;
1111 flag = d_ptr->mflags2 & (1 << i);
1112 if(r_ptr->flags2 & flag) ok = FALSE;
1114 flag = d_ptr->mflags3 & (1 << i);
1115 if(r_ptr->flags3 & flag) ok = FALSE;
1117 flag = d_ptr->mflags4 & (1 << i);
1118 if(r_ptr->flags4 & flag) ok = FALSE;
1120 flag = d_ptr->mflags5 & (1 << i);
1121 if(r_ptr->flags5 & flag) ok = FALSE;
1123 flag = d_ptr->mflags6 & (1 << i);
1124 if(r_ptr->flags6 & flag) ok = FALSE;
1126 flag = d_ptr->mflags7 & (1 << i);
1127 if(r_ptr->flags7 & flag) ok = FALSE;
1129 flag = d_ptr->mflags8 & (1 << i);
1130 if(r_ptr->flags8 & flag) ok = FALSE;
1132 flag = d_ptr->mflags9 & (1 << i);
1133 if(r_ptr->flags9 & flag) ok = FALSE;
1135 for(a = 0; a < 5; a++)
1136 if(d_ptr->r_char[a] == r_ptr->d_char) ok = FALSE;
1144 * Apply a "monster restriction function" to the "monster allocation table"
1146 errr get_mon_num_prep(monster_hook_type monster_hook,
1147 monster_hook_type monster_hook2)
1151 /* Todo: Check the hooks for non-changes */
1153 /* Set the new hooks */
1154 get_mon_num_hook = monster_hook;
1155 get_mon_num2_hook = monster_hook2;
1157 /* Scan the allocation table */
1158 for (i = 0; i < alloc_race_size; i++)
1160 monster_race *r_ptr;
1163 alloc_entry *entry = &alloc_race_table[i];
1166 r_ptr = &r_info[entry->index];
1168 /* Skip monsters which don't pass the restriction */
1169 if ((get_mon_num_hook && !((*get_mon_num_hook)(entry->index))) ||
1170 (get_mon_num2_hook && !((*get_mon_num2_hook)(entry->index))))
1173 if (!p_ptr->inside_battle && !chameleon_change_m_idx &&
1174 summon_specific_type != SUMMON_GUARDIANS)
1176 /* Hack -- don't create questors */
1177 if (r_ptr->flags1 & RF1_QUESTOR)
1180 if (r_ptr->flags7 & RF7_GUARDIAN)
1183 /* Depth Monsters never appear out of depth */
1184 if ((r_ptr->flags1 & (RF1_FORCE_DEPTH)) &&
1185 (r_ptr->level > dun_level))
1189 /* Accept this monster */
1190 entry->prob2 = entry->prob1;
1192 if (dun_level && (!p_ptr->inside_quest || p_ptr->inside_quest < MIN_RANDOM_QUEST) && !restrict_monster_to_dungeon(entry->index) && !p_ptr->inside_battle)
1194 int hoge = entry->prob2 * d_info[dungeon_type].special_div;
1195 entry->prob2 = hoge / 64;
1196 if (randint0(64) < (hoge & 0x3f)) entry->prob2++;
1205 static int mysqrt(int n)
1243 * Choose a monster race that seems "appropriate" to the given level
1245 * This function uses the "prob2" field of the "monster allocation table",
1246 * and various local information, to calculate the "prob3" field of the
1247 * same table, which is then used to choose an "appropriate" monster, in
1248 * a relatively efficient manner.
1250 * Note that "town" monsters will *only* be created in the town, and
1251 * "normal" monsters will *never* be created in the town, unless the
1252 * "level" is "modified", for example, by polymorph or summoning.
1254 * There is a small chance (1/50) of "boosting" the given depth by
1255 * a small amount (up to four levels), except in the town.
1257 * It is (slightly) more likely to acquire a monster of the given level
1258 * than one of a lower level. This is done by choosing several monsters
1259 * appropriate to the given level and keeping the "hardest" one.
1261 * Note that if no monsters are "appropriate", then this function will
1262 * fail, and return zero, but this should *almost* never happen.
1264 s16b get_mon_num(int level)
1272 monster_race *r_ptr;
1274 alloc_entry *table = alloc_race_table;
1276 int pls_kakuritu, pls_level;
1277 int hoge=mysqrt(level*10000L);
1279 if (level > MAX_DEPTH - 1) level = MAX_DEPTH - 1;
1281 if ((dungeon_turn > hoge*(TURNS_PER_TICK*500L)) && !level)
1283 pls_kakuritu = MAX(2, NASTY_MON-((dungeon_turn/(TURNS_PER_TICK*2500L)-hoge/10)));
1284 pls_level = MIN(8,3 + dungeon_turn/(TURNS_PER_TICK*20000L)-hoge/40);
1288 pls_kakuritu = NASTY_MON;
1292 if (d_info[dungeon_type].flags1 & DF1_MAZE)
1294 pls_kakuritu = MIN(pls_kakuritu/2, pls_kakuritu-10);
1295 if (pls_kakuritu < 2) pls_kakuritu = 2;
1300 /* Boost the level */
1301 if ((level > 0) && !p_ptr->inside_battle && !(d_info[dungeon_type].flags1 & DF1_BEGINNER))
1303 /* Nightmare mode allows more out-of depth monsters */
1304 if (ironman_nightmare && !randint0(pls_kakuritu))
1306 /* What a bizarre calculation */
1307 level = 1 + (level * MAX_DEPTH / randint1(MAX_DEPTH));
1311 /* Occasional "nasty" monster */
1312 if (!randint0(pls_kakuritu))
1314 /* Pick a level bonus */
1315 int d = MIN(5, level/10) + pls_level;
1317 /* Boost the level */
1321 /* Occasional "nasty" monster */
1322 if (!randint0(pls_kakuritu))
1324 /* Pick a level bonus */
1325 int d = MIN(5, level/10) + pls_level;
1327 /* Boost the level */
1337 /* Process probabilities */
1338 for (i = 0; i < alloc_race_size; i++)
1340 /* Monsters are sorted by depth */
1341 if (table[i].level > level) break;
1346 /* Access the "r_idx" of the chosen monster */
1347 r_idx = table[i].index;
1349 /* Access the actual race */
1350 r_ptr = &r_info[r_idx];
1352 if (!p_ptr->inside_battle && !chameleon_change_m_idx)
1354 /* Hack -- "unique" monsters must be "unique" */
1355 if (((r_ptr->flags1 & (RF1_UNIQUE)) ||
1356 (r_ptr->flags7 & (RF7_UNIQUE_7))) &&
1357 (r_ptr->cur_num >= r_ptr->max_num))
1362 if ((r_ptr->flags7 & (RF7_UNIQUE2)) &&
1363 (r_ptr->cur_num >= 1))
1368 if (r_idx == MON_BANORLUPART)
1370 if (r_info[MON_BANOR].cur_num > 0) continue;
1371 if (r_info[MON_LUPART].cur_num > 0) continue;
1376 table[i].prob3 = table[i].prob2;
1379 total += table[i].prob3;
1382 /* No legal monsters */
1383 if (total <= 0) return (0);
1386 /* Pick a monster */
1387 value = randint0(total);
1389 /* Find the monster */
1390 for (i = 0; i < alloc_race_size; i++)
1392 /* Found the entry */
1393 if (value < table[i].prob3) break;
1396 value = value - table[i].prob3;
1403 /* Try for a "harder" monster once (50%) or twice (10%) */
1409 /* Pick a monster */
1410 value = randint0(total);
1412 /* Find the monster */
1413 for (i = 0; i < alloc_race_size; i++)
1415 /* Found the entry */
1416 if (value < table[i].prob3) break;
1419 value = value - table[i].prob3;
1422 /* Keep the "best" one */
1423 if (table[i].level < table[j].level) i = j;
1426 /* Try for a "harder" monster twice (10%) */
1432 /* Pick a monster */
1433 value = randint0(total);
1435 /* Find the monster */
1436 for (i = 0; i < alloc_race_size; i++)
1438 /* Found the entry */
1439 if (value < table[i].prob3) break;
1442 value = value - table[i].prob3;
1445 /* Keep the "best" one */
1446 if (table[i].level < table[j].level) i = j;
1450 return (table[i].index);
1458 * Build a string describing a monster in some way.
1460 * We can correctly describe monsters based on their visibility.
1461 * We can force all monsters to be treated as visible or invisible.
1462 * We can build nominatives, objectives, possessives, or reflexives.
1463 * We can selectively pronominalize hidden, visible, or all monsters.
1464 * We can use definite or indefinite descriptions for hidden monsters.
1465 * We can use definite or indefinite descriptions for visible monsters.
1467 * Pronominalization involves the gender whenever possible and allowed,
1468 * so that by cleverly requesting pronominalization / visibility, you
1469 * can get messages like "You hit someone. She screams in agony!".
1471 * Reflexives are acquired by requesting Objective plus Possessive.
1473 * If no m_ptr arg is given (?), the monster is assumed to be hidden,
1474 * unless the "Assume Visible" mode is requested.
1476 * If no r_ptr arg is given, it is extracted from m_ptr and r_info
1477 * If neither m_ptr nor r_ptr is given, the monster is assumed to
1478 * be neuter, singular, and hidden (unless "Assume Visible" is set),
1479 * in which case you may be in trouble... :-)
1481 * I am assuming that no monster name is more than 70 characters long,
1482 * so that "char desc[80];" is sufficiently large for any result.
1485 * 0x01 --> Objective (or Reflexive)
1486 * 0x02 --> Possessive (or Reflexive)
1487 * 0x04 --> Use indefinites for hidden monsters ("something")
1488 * 0x08 --> Use indefinites for visible monsters ("a kobold")
1489 * 0x10 --> Pronominalize hidden monsters
1490 * 0x20 --> Pronominalize visible monsters
1491 * 0x40 --> Assume the monster is hidden
1492 * 0x80 --> Assume the monster is visible
1493 * 0x100 --> Chameleon's true name
1494 * 0x200 --> Ignore hallucination, and penetrate shape change
1497 * 0x00 --> Full nominative name ("the kobold") or "it"
1498 * 0x04 --> Full nominative name ("the kobold") or "something"
1499 * 0x80 --> Genocide resistance name ("the kobold")
1500 * 0x88 --> Killing name ("a kobold")
1501 * 0x22 --> Possessive, genderized if visable ("his") or "its"
1502 * 0x23 --> Reflexive, genderized if visable ("himself") or "itself"
1504 void monster_desc(char *desc, monster_type *m_ptr, int mode)
1507 monster_race *r_ptr;
1511 char silly_name[1024];
1515 r_ptr = &r_info[m_ptr->ap_r_idx];
1517 /* Mode of 0x100 will reveal Chameleon's true name */
1518 if (mode & 0x100) name = (r_name + real_r_ptr(m_ptr)->name);
1519 else name = (r_name + r_ptr->name);
1521 /* Are we hallucinating? (Idea from Nethack...) */
1522 if (p_ptr->image && !(mode & 0x200))
1527 if (!get_rnd_line("silly_j.txt", m_ptr->r_idx, silly_name))
1529 if (!get_rnd_line("silly.txt", m_ptr->r_idx, silly_name))
1537 monster_race *hallu_race;
1541 hallu_race = &r_info[randint1(max_r_idx - 1)];
1543 while (hallu_race->flags1 & RF1_UNIQUE);
1545 strcpy(silly_name, (r_name + hallu_race->name));
1548 /* Better not strcpy it, or we could corrupt r_info... */
1552 /* Can we "see" it (exists + forced, or visible + not unforced) */
1553 seen = (m_ptr && ((mode & 0x80) || (!(mode & 0x40) && m_ptr->ml)));
1555 /* Sexed Pronouns (seen and allowed, or unseen and allowed) */
1556 pron = (m_ptr && ((seen && (mode & 0x20)) || (!seen && (mode & 0x10))));
1559 /* First, try using pronouns, or describing hidden monsters */
1562 /* an encoding of the monster "sex" */
1565 /* Extract the gender (if applicable) */
1566 if (r_ptr->flags1 & (RF1_FEMALE)) kind = 0x20;
1567 else if (r_ptr->flags1 & (RF1_MALE)) kind = 0x10;
1569 /* Ignore the gender (if desired) */
1570 if (!m_ptr || !pron) kind = 0x00;
1573 /* Assume simple result */
1581 /* Brute force: split on the possibilities */
1582 switch (kind + (mode & 0x07))
1584 /* Neuter, or unknown */
1586 case 0x00: res = "²¿¤«"; break;
1587 case 0x01: res = "²¿¤«"; break;
1588 case 0x02: res = "²¿¤«¤Î"; break;
1589 case 0x03: res = "²¿¤«¼«¿È"; break;
1590 case 0x04: res = "²¿¤«"; break;
1591 case 0x05: res = "²¿¤«"; break;
1592 case 0x06: res = "²¿¤«"; break;
1593 case 0x07: res = "¤½¤ì¼«¿È"; break;
1595 case 0x00: res = "it"; break;
1596 case 0x01: res = "it"; break;
1597 case 0x02: res = "its"; break;
1598 case 0x03: res = "itself"; break;
1599 case 0x04: res = "something"; break;
1600 case 0x05: res = "something"; break;
1601 case 0x06: res = "something's"; break;
1602 case 0x07: res = "itself"; break;
1606 /* Male (assume human if vague) */
1608 case 0x10: res = "Èà"; break;
1609 case 0x11: res = "Èà"; break;
1610 case 0x12: res = "Èà¤Î"; break;
1611 case 0x13: res = "È༫¿È"; break;
1612 case 0x14: res = "狼"; break;
1613 case 0x15: res = "狼"; break;
1614 case 0x16: res = "狼¤Î"; break;
1615 case 0x17: res = "È༫¿È"; break;
1617 case 0x10: res = "he"; break;
1618 case 0x11: res = "him"; break;
1619 case 0x12: res = "his"; break;
1620 case 0x13: res = "himself"; break;
1621 case 0x14: res = "someone"; break;
1622 case 0x15: res = "someone"; break;
1623 case 0x16: res = "someone's"; break;
1624 case 0x17: res = "himself"; break;
1628 /* Female (assume human if vague) */
1630 case 0x20: res = "Èà½÷"; break;
1631 case 0x21: res = "Èà½÷"; break;
1632 case 0x22: res = "Èà½÷¤Î"; break;
1633 case 0x23: res = "Èà½÷¼«¿È"; break;
1634 case 0x24: res = "狼"; break;
1635 case 0x25: res = "狼"; break;
1636 case 0x26: res = "狼¤Î"; break;
1637 case 0x27: res = "Èà½÷¼«¿È"; break;
1639 case 0x20: res = "she"; break;
1640 case 0x21: res = "her"; break;
1641 case 0x22: res = "her"; break;
1642 case 0x23: res = "herself"; break;
1643 case 0x24: res = "someone"; break;
1644 case 0x25: res = "someone"; break;
1645 case 0x26: res = "someone's"; break;
1646 case 0x27: res = "herself"; break;
1651 /* Copy the result */
1652 (void)strcpy(desc, res);
1656 /* Handle visible monsters, "reflexive" request */
1657 else if ((mode & 0x02) && (mode & 0x01))
1659 /* The monster is visible, so use its gender */
1661 if (r_ptr->flags1 & (RF1_FEMALE)) strcpy(desc, "Èà½÷¼«¿È");
1662 else if (r_ptr->flags1 & (RF1_MALE)) strcpy(desc, "È༫¿È");
1663 else strcpy(desc, "¤½¤ì¼«¿È");
1665 if (r_ptr->flags1 & RF1_FEMALE) strcpy(desc, "herself");
1666 else if (r_ptr->flags1 & RF1_MALE) strcpy(desc, "himself");
1667 else strcpy(desc, "itself");
1673 /* Handle all other visible monster requests */
1677 if (is_pet(m_ptr) && m_ptr->ap_r_idx != m_ptr->r_idx)
1683 while(strncmp(t, "¡Ù", 2) && *t) t++;
1687 (void)sprintf(desc, "%s¡©¡Ù", buf);
1690 (void)sprintf(desc, "%s¡©", name);
1692 (void)sprintf(desc, "%s?", name);
1697 /* It could be a Unique */
1698 if ((r_ptr->flags1 & RF1_UNIQUE) && !(p_ptr->image && !(mode & 0x200)))
1700 /* Start with the name (thus nominative and objective) */
1701 if ((m_ptr->mflag2 & MFLAG2_CHAMELEON) && !(mode & 0x100))
1707 while(strncmp(t, "¡Ù", 2) && *t) t++;
1711 (void)sprintf(desc, "%s¡©¡Ù", buf);
1714 (void)sprintf(desc, "%s¡©", name);
1716 (void)sprintf(desc, "%s?", name);
1719 else if ((cave[m_ptr->fy][m_ptr->fx].m_idx == p_ptr->riding) || !p_ptr->inside_battle)
1720 (void)strcpy(desc, name);
1723 (void)sprintf(desc, "%s¤â¤É¤", name);
1725 (void)sprintf(desc, "fake %s", name);
1729 /* It could be an indefinite monster */
1730 else if (mode & 0x08)
1732 /* XXX Check plurality for "some" */
1734 /* Indefinite monsters need an indefinite article */
1736 (void)strcpy(desc, "");
1738 (void)strcpy(desc, is_a_vowel(name[0]) ? "an " : "a ");
1741 (void)strcat(desc, name);
1744 /* It could be a normal, definite, monster */
1747 /* Definite monsters need a definite article */
1750 (void)strcpy(desc, "¤¢¤Ê¤¿¤Î");
1752 (void)strcpy(desc, "your ");
1757 (void)strcpy(desc, "");
1759 (void)strcpy(desc, "the ");
1762 (void)strcat(desc, name);
1765 if (m_ptr->nickname)
1768 sprintf(buf,"¡Ö%s¡×",quark_str(m_ptr->nickname));
1770 sprintf(buf," called %s",quark_str(m_ptr->nickname));
1775 if ((m_ptr->fy == py) && (m_ptr->fx == px))
1778 strcat(desc,"(¾èÇÏÃæ)");
1780 strcat(desc,"(riding)");
1784 if ((mode & 0x200) && (m_ptr->mflag2 & MFLAG2_CHAMELEON))
1786 if (r_ptr->flags1 & RF1_UNIQUE)
1789 strcat(desc,"(¥«¥á¥ì¥ª¥ó¤Î²¦)");
1791 strcat(desc,"(Chameleon Lord)");
1797 strcat(desc,"(¥«¥á¥ì¥ª¥ó)");
1799 strcat(desc,"(Chameleon)");
1804 if ((mode & 0x200) && m_ptr->ap_r_idx != m_ptr->r_idx)
1806 strcat(desc, format("(%s)", r_name + r_info[m_ptr->r_idx].name));
1809 /* Handle the Possessive as a special afterthought */
1812 /* XXX Check for trailing "s" */
1814 /* Simply append "apostrophe" and "s" */
1816 (void)strcat(desc, "¤Î");
1818 (void)strcat(desc, "'s");
1829 * Learn about a monster (by "probing" it)
1831 * Return the number of new flags learnt. -Mogami-
1833 int lore_do_probe(int r_idx)
1835 monster_race *r_ptr = &r_info[r_idx];
1839 /* Maximal info about awareness */
1840 if (r_ptr->r_wake != MAX_UCHAR) n++;
1841 if (r_ptr->r_ignore != MAX_UCHAR) n++;
1842 r_ptr->r_wake = r_ptr->r_ignore = MAX_UCHAR;
1844 /* Observe "maximal" attacks */
1845 for (i = 0; i < 4; i++)
1847 /* Examine "actual" blows */
1848 if (r_ptr->blow[i].effect || r_ptr->blow[i].method)
1850 /* Maximal observations */
1851 if (r_ptr->r_blows[i] != MAX_UCHAR) n++;
1852 r_ptr->r_blows[i] = MAX_UCHAR;
1858 (((r_ptr->flags1 & RF1_DROP_4D2) ? 8 : 0) +
1859 ((r_ptr->flags1 & RF1_DROP_3D2) ? 6 : 0) +
1860 ((r_ptr->flags1 & RF1_DROP_2D2) ? 4 : 0) +
1861 ((r_ptr->flags1 & RF1_DROP_1D2) ? 2 : 0) +
1862 ((r_ptr->flags1 & RF1_DROP_90) ? 1 : 0) +
1863 ((r_ptr->flags1 & RF1_DROP_60) ? 1 : 0));
1865 /* Only "valid" drops */
1866 if (!(r_ptr->flags1 & RF1_ONLY_GOLD))
1868 if (r_ptr->r_drop_item != tmp_byte) n++;
1869 r_ptr->r_drop_item = tmp_byte;
1871 if (!(r_ptr->flags1 & RF1_ONLY_ITEM))
1873 if (r_ptr->r_drop_gold != tmp_byte) n++;
1874 r_ptr->r_drop_gold = tmp_byte;
1877 /* Observe many spells */
1878 if (r_ptr->r_cast_spell != MAX_UCHAR) n++;
1879 r_ptr->r_cast_spell = MAX_UCHAR;
1881 /* Count unknown flags */
1882 for (i = 0; i < 32; i++)
1884 if (!(r_ptr->r_flags1 & (1L << i)) &&
1885 (r_ptr->flags1 & (1L << i))) n++;
1886 if (!(r_ptr->r_flags2 & (1L << i)) &&
1887 (r_ptr->flags2 & (1L << i))) n++;
1888 if (!(r_ptr->r_flags3 & (1L << i)) &&
1889 (r_ptr->flags3 & (1L << i))) n++;
1890 if (!(r_ptr->r_flags4 & (1L << i)) &&
1891 (r_ptr->flags4 & (1L << i))) n++;
1892 if (!(r_ptr->r_flags5 & (1L << i)) &&
1893 (r_ptr->flags5 & (1L << i))) n++;
1894 if (!(r_ptr->r_flags6 & (1L << i)) &&
1895 (r_ptr->flags6 & (1L << i))) n++;
1897 /* r_flags7 is actually unused */
1899 if (!(r_ptr->r_flags7 & (1L << i)) &&
1900 (r_ptr->flags7 & (1L << i))) n++;
1904 /* Know all the flags */
1905 r_ptr->r_flags1 = r_ptr->flags1;
1906 r_ptr->r_flags2 = r_ptr->flags2;
1907 r_ptr->r_flags3 = r_ptr->flags3;
1908 r_ptr->r_flags4 = r_ptr->flags4;
1909 r_ptr->r_flags5 = r_ptr->flags5;
1910 r_ptr->r_flags6 = r_ptr->flags6;
1912 /* r_flags7 is actually unused */
1913 /* r_ptr->r_flags7 = r_ptr->flags7; */
1915 /* Know about evolution */
1916 if (!(r_ptr->r_xtra1 & MR1_SINKA)) n++;
1917 r_ptr->r_xtra1 |= MR1_SINKA;
1919 /* Update monster recall window */
1920 if (p_ptr->monster_race_idx == r_idx)
1923 p_ptr->window |= (PW_MONSTER);
1926 /* Return the number of new flags learnt */
1932 * Take note that the given monster just dropped some treasure
1934 * Note that learning the "GOOD"/"GREAT" flags gives information
1935 * about the treasure (even when the monster is killed for the first
1936 * time, such as uniques, and the treasure has not been examined yet).
1938 * This "indirect" method is used to prevent the player from learning
1939 * exactly how much treasure a monster can drop from observing only
1940 * a single example of a drop. This method actually observes how much
1941 * gold and items are dropped, and remembers that information to be
1942 * described later by the monster recall code.
1944 void lore_treasure(int m_idx, int num_item, int num_gold)
1946 monster_type *m_ptr = &m_list[m_idx];
1948 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1950 /* Note the number of things dropped */
1951 if (num_item > r_ptr->r_drop_item) r_ptr->r_drop_item = num_item;
1952 if (num_gold > r_ptr->r_drop_gold) r_ptr->r_drop_gold = num_gold;
1954 /* Hack -- memorize the good/great flags */
1955 if (r_ptr->flags1 & (RF1_DROP_GOOD)) r_ptr->r_flags1 |= (RF1_DROP_GOOD);
1956 if (r_ptr->flags1 & (RF1_DROP_GREAT)) r_ptr->r_flags1 |= (RF1_DROP_GREAT);
1958 /* Update monster recall window */
1959 if (p_ptr->monster_race_idx == m_ptr->r_idx)
1962 p_ptr->window |= (PW_MONSTER);
1968 void sanity_blast(monster_type *m_ptr, bool necro)
1970 bool happened = FALSE;
1973 if (p_ptr->inside_battle || !character_dungeon) return;
1978 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1980 power = r_ptr->level / 2;
1982 monster_desc(m_name, m_ptr, 0);
1984 if (!(r_ptr->flags1 & RF1_UNIQUE))
1986 if (r_ptr->flags1 & RF1_FRIENDS)
1992 return; /* No effect yet, just loaded... */
1995 return; /* Cannot see it for some reason */
1997 if (!(r_ptr->flags2 & RF2_ELDRITCH_HORROR))
2003 return; /* Pet eldritch horrors are safe most of the time */
2005 if (randint1(100) > power) return;
2007 if (saving_throw(p_ptr->skill_sav - power))
2009 return; /* Save, no adverse effects */
2014 /* Something silly happens... */
2016 msg_format("%s%s¤Î´é¤ò¸«¤Æ¤·¤Þ¤Ã¤¿¡ª",
2017 funny_desc[randint0(MAX_SAN_FUNNY)], m_name);
2019 msg_format("You behold the %s visage of %s!",
2020 funny_desc[randint0(MAX_SAN_FUNNY)], m_name);
2026 msg_print(funny_comments[randint0(MAX_SAN_COMMENT)]);
2027 p_ptr->image = p_ptr->image + randint1(r_ptr->level);
2030 return; /* Never mind; we can't see it clearly enough */
2033 /* Something frightening happens... */
2035 msg_format("%s%s¤Î´é¤ò¸«¤Æ¤·¤Þ¤Ã¤¿¡ª",
2036 horror_desc[randint0(MAX_SAN_HORROR)], m_name);
2038 msg_format("You behold the %s visage of %s!",
2039 horror_desc[randint0(MAX_SAN_HORROR)], m_name);
2042 r_ptr->r_flags2 |= RF2_ELDRITCH_HORROR;
2044 /* Demon characters are unaffected */
2045 if (prace_is_(RACE_IMP) || prace_is_(RACE_DEMON) || (mimic_info[p_ptr->mimic_form].MIMIC_FLAGS & MIMIC_IS_DEMON)) return;
2046 if (p_ptr->wizard) return;
2048 /* Undead characters are 50% likely to be unaffected */
2049 if (prace_is_(RACE_SKELETON) || prace_is_(RACE_ZOMBIE)
2050 || prace_is_(RACE_VAMPIRE) || prace_is_(RACE_SPECTRE) ||
2051 (mimic_info[p_ptr->mimic_form].MIMIC_FLAGS & MIMIC_IS_UNDEAD))
2053 if (saving_throw(25 + p_ptr->lev)) return;
2059 msg_print("¥Í¥¯¥í¥Î¥ß¥³¥ó¤òÆɤó¤ÇÀµµ¤¤ò¼º¤Ã¤¿¡ª");
2061 msg_print("Your sanity is shaken by reading the Necronomicon!");
2066 if (!saving_throw(p_ptr->skill_sav - power)) /* Mind blast */
2068 if (!p_ptr->resist_conf)
2070 (void)set_confused(p_ptr->confused + randint0(4) + 4);
2072 if (!p_ptr->resist_chaos && one_in_(3))
2074 (void)set_image(p_ptr->image + randint0(250) + 150);
2079 if (!saving_throw(p_ptr->skill_sav - power)) /* Lose int & wis */
2086 if (!saving_throw(p_ptr->skill_sav - power)) /* Brain smash */
2088 if (!p_ptr->resist_conf)
2090 (void)set_confused(p_ptr->confused + randint0(4) + 4);
2092 if (!p_ptr->free_act)
2094 (void)set_paralyzed(p_ptr->paralyzed + randint0(4) + 4);
2096 while (randint0(100) > p_ptr->skill_sav)
2097 (void)do_dec_stat(A_INT);
2098 while (randint0(100) > p_ptr->skill_sav)
2099 (void)do_dec_stat(A_WIS);
2100 if (!p_ptr->resist_chaos)
2102 (void)set_image(p_ptr->image + randint0(250) + 150);
2107 if (!saving_throw(p_ptr->skill_sav - power)) /* Amnesia */
2110 if (lose_all_info())
2112 msg_print("¤¢¤Þ¤ê¤Î¶²ÉݤËÁ´¤Æ¤Î¤³¤È¤ò˺¤ì¤Æ¤·¤Þ¤Ã¤¿¡ª");
2114 msg_print("You forget everything in your utmost terror!");
2120 if (saving_throw(p_ptr->skill_sav - power))
2125 /* Else gain permanent insanity */
2126 if ((p_ptr->muta3 & MUT3_MORONIC) && /*(p_ptr->muta2 & MUT2_BERS_RAGE) &&*/
2127 ((p_ptr->muta2 & MUT2_COWARDICE) || (p_ptr->resist_fear)) &&
2128 ((p_ptr->muta2 & MUT2_HALLU) || (p_ptr->resist_chaos)))
2130 /* The poor bastard already has all possible insanities! */
2136 switch (randint1(21))
2139 if (!(p_ptr->muta3 & MUT3_MORONIC) && one_in_(5))
2141 if ((p_ptr->stat_use[A_INT] < 4) && (p_ptr->stat_use[A_WIS] < 4))
2144 msg_print("¤¢¤Ê¤¿¤Ï´°àú¤ÊÇϼ¯¤Ë¤Ê¤Ã¤¿¤è¤¦¤Êµ¤¤¬¤·¤¿¡£¤·¤«¤·¤½¤ì¤Ï¸µ¡¹¤À¤Ã¤¿¡£");
2146 msg_print("You turn into an utter moron!");
2152 msg_print("¤¢¤Ê¤¿¤Ï´°àú¤ÊÇϼ¯¤Ë¤Ê¤Ã¤¿¡ª");
2154 msg_print("You turn into an utter moron!");
2158 if (p_ptr->muta3 & MUT3_HYPER_INT)
2161 msg_print("¤¢¤Ê¤¿¤ÎǾ¤ÏÀ¸ÂÎ¥³¥ó¥Ô¥å¡¼¥¿¤Ç¤Ï¤Ê¤¯¤Ê¤Ã¤¿¡£");
2163 msg_print("Your brain is no longer a living computer.");
2166 p_ptr->muta3 &= ~(MUT3_HYPER_INT);
2168 p_ptr->muta3 |= MUT3_MORONIC;
2182 if (!(p_ptr->muta2 & MUT2_COWARDICE) && !p_ptr->resist_fear)
2185 msg_print("¤¢¤Ê¤¿¤Ï¥Ñ¥é¥Î¥¤¥¢¤Ë¤Ê¤Ã¤¿¡ª");
2187 msg_print("You become paranoid!");
2191 /* Duh, the following should never happen, but anyway... */
2192 if (p_ptr->muta3 & MUT3_FEARLESS)
2195 msg_print("¤¢¤Ê¤¿¤Ï¤â¤¦¶²¤ìÃΤ餺¤Ç¤Ï¤Ê¤¯¤Ê¤Ã¤¿¡£");
2197 msg_print("You are no longer fearless.");
2200 p_ptr->muta3 &= ~(MUT3_FEARLESS);
2203 p_ptr->muta2 |= MUT2_COWARDICE;
2217 if (!(p_ptr->muta2 & MUT2_HALLU) && !p_ptr->resist_chaos)
2220 msg_print("¸¸³Ð¤ò¤Ò¤µ¯¤³¤¹Àº¿ÀºøÍð¤Ë´Ù¤Ã¤¿¡ª");
2222 msg_print("You are afflicted by a hallucinatory insanity!");
2225 p_ptr->muta2 |= MUT2_HALLU;
2230 if (!(p_ptr->muta2 & MUT2_BERS_RAGE))
2233 msg_print("·ãÎõ¤Ê´¶¾ð¤Îȯºî¤Ë¤ª¤½¤ï¤ì¤ë¤è¤¦¤Ë¤Ê¤Ã¤¿¡ª");
2235 msg_print("You become subject to fits of berserk rage!");
2238 p_ptr->muta2 |= MUT2_BERS_RAGE;
2245 p_ptr->update |= PU_BONUS;
2251 * This function updates the monster record of the given monster
2253 * This involves extracting the distance to the player (if requested),
2254 * and then checking for visibility (natural, infravision, see-invis,
2255 * telepathy), updating the monster visibility flag, redrawing (or
2256 * erasing) the monster when its visibility changes, and taking note
2257 * of any interesting monster flags (cold-blooded, invisible, etc).
2259 * Note the new "mflag" field which encodes several monster state flags,
2260 * including "view" for when the monster is currently in line of sight,
2261 * and "mark" for when the monster is currently visible via detection.
2263 * The only monster fields that are changed here are "cdis" (the
2264 * distance from the player), "ml" (visible to the player), and
2265 * "mflag" (to maintain the "MFLAG_VIEW" flag).
2267 * Note the special "update_monsters()" function which can be used to
2268 * call this function once for every monster.
2270 * Note the "full" flag which requests that the "cdis" field be updated,
2271 * this is only needed when the monster (or the player) has moved.
2273 * Every time a monster moves, we must call this function for that
2274 * monster, and update the distance, and the visibility. Every time
2275 * the player moves, we must call this function for every monster, and
2276 * update the distance, and the visibility. Whenever the player "state"
2277 * changes in certain ways ("blindness", "infravision", "telepathy",
2278 * and "see invisible"), we must call this function for every monster,
2279 * and update the visibility.
2281 * Routines that change the "illumination" of a grid must also call this
2282 * function for any monster in that grid, since the "visibility" of some
2283 * monsters may be based on the illumination of their grid.
2285 * Note that this function is called once per monster every time the
2286 * player moves. When the player is running, this function is one
2287 * of the primary bottlenecks, along with "update_view()" and the
2288 * "process_monsters()" code, so efficiency is important.
2290 * Note the optimized "inline" version of the "distance()" function.
2292 * A monster is "visible" to the player if (1) it has been detected
2293 * by the player, (2) it is close to the player and the player has
2294 * telepathy, or (3) it is close to the player, and in line of sight
2295 * of the player, and it is "illuminated" by some combination of
2296 * infravision, torch light, or permanent light (invisible monsters
2297 * are only affected by "light" if the player can see invisible).
2299 * Monsters which are not on the current panel may be "visible" to
2300 * the player, and their descriptions will include an "offscreen"
2301 * reference. Currently, offscreen monsters cannot be targetted
2302 * or viewed directly, but old targets will remain set. XXX XXX
2304 * The player can choose to be disturbed by several things, including
2305 * "disturb_move" (monster which is viewable moves in some way), and
2306 * "disturb_near" (monster which is "easily" viewable moves in some
2307 * way). Note that "moves" includes "appears" and "disappears".
2309 void update_mon(int m_idx, bool full)
2311 monster_type *m_ptr = &m_list[m_idx];
2313 monster_race *r_ptr = &r_info[m_ptr->r_idx];
2315 bool do_disturb = disturb_move;
2319 /* Current location */
2326 /* Seen by vision */
2332 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
2334 if (ap_r_ptr->r_tkills && ap_r_ptr->level >= p_ptr->lev)
2338 /* Compute distance */
2341 /* Distance components */
2342 int dy = (py > fy) ? (py - fy) : (fy - py);
2343 int dx = (px > fx) ? (px - fx) : (fx - px);
2345 /* Approximate distance */
2346 d = (dy > dx) ? (dy + (dx>>1)) : (dx + (dy>>1));
2348 /* Restrict distance */
2349 if (d > 255) d = 255;
2353 /* Save the distance */
2357 /* Extract distance */
2360 /* Extract the distance */
2366 if (m_ptr->mflag & (MFLAG_MARK)) flag = TRUE;
2370 if (d <= ((d_info[dungeon_type].flags1 & DF1_DARKNESS) ? MAX_SIGHT / 2 : MAX_SIGHT))
2372 if (!(d_info[dungeon_type].flags1 & DF1_DARKNESS) || (d <= MAX_SIGHT / 4))
2374 if (p_ptr->special_defense & KATA_MUSOU)
2379 /* Hack -- Memorize mental flags */
2380 if (r_ptr->flags2 & (RF2_SMART)) r_ptr->r_flags2 |= (RF2_SMART);
2381 if (r_ptr->flags2 & (RF2_STUPID)) r_ptr->r_flags2 |= (RF2_STUPID);
2384 /* Basic telepathy */
2385 else if (p_ptr->telepathy)
2387 /* Empty mind, no telepathy */
2388 if (r_ptr->flags2 & (RF2_EMPTY_MIND))
2390 /* Memorize flags */
2391 r_ptr->r_flags2 |= (RF2_EMPTY_MIND);
2394 /* Weird mind, occasional telepathy */
2395 else if (r_ptr->flags2 & (RF2_WEIRD_MIND))
2397 /* One in ten individuals are detectable */
2398 if ((m_idx % 10) == 5)
2403 /* Memorize flags */
2404 r_ptr->r_flags2 |= (RF2_WEIRD_MIND);
2406 /* Hack -- Memorize mental flags */
2407 if (r_ptr->flags2 & (RF2_SMART)) r_ptr->r_flags2 |= (RF2_SMART);
2408 if (r_ptr->flags2 & (RF2_STUPID)) r_ptr->r_flags2 |= (RF2_STUPID);
2412 /* Normal mind, allow telepathy */
2418 /* Hack -- Memorize mental flags */
2419 if (r_ptr->flags2 & (RF2_SMART)) r_ptr->r_flags2 |= (RF2_SMART);
2420 if (r_ptr->flags2 & (RF2_STUPID)) r_ptr->r_flags2 |= (RF2_STUPID);
2424 /* Magical sensing */
2425 if ((p_ptr->esp_animal) && (r_ptr->flags3 & (RF3_ANIMAL)))
2428 r_ptr->r_flags3 |= (RF3_ANIMAL);
2432 /* Magical sensing */
2433 if ((p_ptr->esp_undead) && (r_ptr->flags3 & (RF3_UNDEAD)))
2436 r_ptr->r_flags3 |= (RF3_UNDEAD);
2440 /* Magical sensing */
2441 if ((p_ptr->esp_demon) && (r_ptr->flags3 & (RF3_DEMON)))
2444 r_ptr->r_flags3 |= (RF3_DEMON);
2448 /* Magical sensing */
2449 if ((p_ptr->esp_orc) && (r_ptr->flags3 & (RF3_ORC)))
2452 r_ptr->r_flags3 |= (RF3_ORC);
2456 /* Magical sensing */
2457 if ((p_ptr->esp_troll) && (r_ptr->flags3 & (RF3_TROLL)))
2460 r_ptr->r_flags3 |= (RF3_TROLL);
2464 /* Magical sensing */
2465 if ((p_ptr->esp_giant) && (r_ptr->flags3 & (RF3_GIANT)))
2468 r_ptr->r_flags3 |= (RF3_GIANT);
2472 /* Magical sensing */
2473 if ((p_ptr->esp_dragon) && (r_ptr->flags3 & (RF3_DRAGON)))
2476 r_ptr->r_flags3 |= (RF3_DRAGON);
2480 /* Magical sensing */
2481 if ((p_ptr->esp_human) && (r_ptr->flags2 & (RF2_HUMAN)))
2484 r_ptr->r_flags2 |= (RF2_HUMAN);
2488 /* Magical sensing */
2489 if ((p_ptr->esp_evil) && (r_ptr->flags3 & (RF3_EVIL)))
2492 r_ptr->r_flags3 |= (RF3_EVIL);
2496 /* Magical sensing */
2497 if ((p_ptr->esp_good) && (r_ptr->flags3 & (RF3_GOOD)))
2500 r_ptr->r_flags3 |= (RF3_GOOD);
2504 /* Magical sensing */
2505 if ((p_ptr->esp_nonliving) &&
2506 (r_ptr->flags3 & (RF3_NONLIVING)) &&
2507 !(r_ptr->flags3 & (RF3_DEMON)) &&
2508 !(r_ptr->flags3 & (RF3_UNDEAD)))
2511 r_ptr->r_flags3 |= (RF3_NONLIVING);
2515 /* Magical sensing */
2516 if ((p_ptr->esp_unique) && (r_ptr->flags1 & (RF1_UNIQUE)))
2519 r_ptr->r_flags1 |= (RF1_UNIQUE);
2524 /* Normal line of sight, and not blind */
2525 if (player_has_los_bold(fy, fx) && !p_ptr->blind)
2527 bool do_invisible = FALSE;
2528 bool do_cold_blood = FALSE;
2530 /* Use "infravision" */
2531 if (d <= p_ptr->see_infra)
2533 /* Handle "cold blooded" monsters */
2534 if (r_ptr->flags2 & (RF2_COLD_BLOOD))
2537 do_cold_blood = TRUE;
2540 /* Handle "warm blooded" monsters */
2548 /* Use "illumination" */
2549 if (player_can_see_bold(fy, fx))
2551 /* Handle "invisible" monsters */
2552 if (r_ptr->flags2 & (RF2_INVISIBLE))
2555 do_invisible = TRUE;
2565 /* Handle "normal" monsters */
2576 /* Memorize flags */
2577 if (do_invisible) r_ptr->r_flags2 |= (RF2_INVISIBLE);
2578 if (do_cold_blood) r_ptr->r_flags2 |= (RF2_COLD_BLOOD);
2584 /* The monster is now visible */
2587 /* It was previously unseen */
2590 /* Mark as visible */
2593 /* Draw the monster */
2596 /* Update health bar as needed */
2597 if (p_ptr->health_who == m_idx) p_ptr->redraw |= (PR_HEALTH);
2598 if (p_ptr->riding == m_idx) p_ptr->redraw |= (PR_UHEALTH);
2600 /* Hack -- Count "fresh" sightings */
2601 if ((m_ptr->ap_r_idx == MON_KAGE) && (r_info[MON_KAGE].r_sights < MAX_SHORT))
2602 r_info[MON_KAGE].r_sights++;
2603 else if (m_ptr->ap_r_idx == m_ptr->r_idx &&
2604 r_ptr->r_sights < MAX_SHORT) r_ptr->r_sights++;
2606 /* Eldritch Horror */
2607 if (r_ptr->flags2 & RF2_ELDRITCH_HORROR)
2609 sanity_blast(m_ptr, FALSE);
2612 /* Disturb on appearance */
2613 if (disturb_near && (projectable(m_ptr->fy, m_ptr->fx, py, px) && projectable(py, px, m_ptr->fy, m_ptr->fx)))
2615 if (disturb_pets || is_hostile(m_ptr))
2621 /* The monster is not visible */
2624 /* It was previously seen */
2627 /* Mark as not visible */
2630 /* Erase the monster */
2633 /* Update health bar as needed */
2634 if (p_ptr->health_who == m_idx) p_ptr->redraw |= (PR_HEALTH);
2635 if (p_ptr->riding == m_idx) p_ptr->redraw |= (PR_UHEALTH);
2637 /* Disturb on disappearance */
2640 if (disturb_pets || is_hostile(m_ptr))
2647 /* The monster is now easily visible */
2651 if (!(m_ptr->mflag & (MFLAG_VIEW)))
2653 /* Mark as easily visible */
2654 m_ptr->mflag |= (MFLAG_VIEW);
2656 /* Disturb on appearance */
2659 if (disturb_pets || is_hostile(m_ptr))
2665 /* The monster is not easily visible */
2669 if (m_ptr->mflag & (MFLAG_VIEW))
2671 /* Mark as not easily visible */
2672 m_ptr->mflag &= ~(MFLAG_VIEW);
2674 /* Disturb on disappearance */
2677 if (disturb_pets || is_hostile(m_ptr))
2686 * This function simply updates all the (non-dead) monsters (see above).
2688 void update_monsters(bool full)
2692 /* Update each (live) monster */
2693 for (i = 1; i < m_max; i++)
2695 monster_type *m_ptr = &m_list[i];
2697 /* Skip dead monsters */
2698 if (!m_ptr->r_idx) continue;
2700 /* Update the monster */
2701 update_mon(i, full);
2707 * Hack -- the index of the summoning monster
2709 static bool monster_hook_chameleon_lord(int r_idx)
2711 monster_race *r_ptr = &r_info[r_idx];
2712 monster_type *m_ptr = &m_list[chameleon_change_m_idx];
2713 monster_race *old_r_ptr = &r_info[m_ptr->r_idx];
2715 if (!(r_ptr->flags1 & (RF1_UNIQUE))) return FALSE;
2716 if (r_ptr->flags7 & (RF7_FRIENDLY | RF7_CHAMELEON)) return FALSE;
2718 if (ABS(r_ptr->level - r_info[MON_CHAMELEON_K].level) > 5) return FALSE;
2720 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))
2723 if (!monster_can_cross_terrain(cave[m_ptr->fy][m_ptr->fx].feat, r_ptr)) return FALSE;
2726 if (!(old_r_ptr->flags7 & RF7_CHAMELEON))
2728 if ((m_ptr->sub_align & SUB_ALIGN_EVIL) && (r_ptr->flags3 & RF3_GOOD)) return FALSE;
2729 if ((m_ptr->sub_align & SUB_ALIGN_GOOD) && (r_ptr->flags3 & RF3_EVIL)) return FALSE;
2733 else if (summon_specific_who > 0)
2735 monster_type *sm_ptr = &m_list[summon_specific_who];
2737 if ((sm_ptr->sub_align & SUB_ALIGN_EVIL) && (r_ptr->flags3 & RF3_GOOD)) return FALSE;
2738 if ((sm_ptr->sub_align & SUB_ALIGN_GOOD) && (r_ptr->flags3 & RF3_EVIL)) return FALSE;
2744 static bool monster_hook_chameleon(int r_idx)
2746 monster_race *r_ptr = &r_info[r_idx];
2747 monster_type *m_ptr = &m_list[chameleon_change_m_idx];
2748 monster_race *old_r_ptr = &r_info[m_ptr->r_idx];
2750 if (r_ptr->flags1 & (RF1_UNIQUE)) return FALSE;
2751 if (r_ptr->flags2 & RF2_MULTIPLY) return FALSE;
2752 if (r_ptr->flags7 & (RF7_FRIENDLY | RF7_CHAMELEON)) return FALSE;
2754 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))
2757 if (!monster_can_cross_terrain(cave[m_ptr->fy][m_ptr->fx].feat, r_ptr)) return FALSE;
2760 if (!(old_r_ptr->flags7 & RF7_CHAMELEON))
2762 if ((old_r_ptr->flags3 & RF3_GOOD) && !(r_ptr->flags3 & RF3_GOOD)) return FALSE;
2763 if ((old_r_ptr->flags3 & RF3_EVIL) && !(r_ptr->flags3 & RF3_EVIL)) return FALSE;
2764 if (!(old_r_ptr->flags3 & (RF3_GOOD | RF3_EVIL)) && (r_ptr->flags3 & (RF3_GOOD | RF3_EVIL))) return FALSE;
2768 else if (summon_specific_who > 0)
2770 monster_type *sm_ptr = &m_list[summon_specific_who];
2772 if ((sm_ptr->sub_align & SUB_ALIGN_EVIL) && (r_ptr->flags3 & RF3_GOOD)) return FALSE;
2773 if ((sm_ptr->sub_align & SUB_ALIGN_GOOD) && (r_ptr->flags3 & RF3_EVIL)) return FALSE;
2776 return (*(get_monster_hook()))(r_idx);
2780 void choose_new_monster(int m_idx, bool born, int r_idx)
2783 monster_type *m_ptr = &m_list[m_idx];
2784 monster_race *r_ptr;
2785 char old_m_name[80];
2786 bool old_unique = FALSE;
2788 if (r_info[m_ptr->r_idx].flags1 & RF1_UNIQUE)
2790 if (old_unique && (r_idx == MON_CHAMELEON)) r_idx = MON_CHAMELEON_K;
2791 r_ptr = &r_info[r_idx];
2793 monster_desc(old_m_name, m_ptr, 0);
2799 chameleon_change_m_idx = m_idx;
2801 get_mon_num_prep(monster_hook_chameleon_lord, NULL);
2803 get_mon_num_prep(monster_hook_chameleon, NULL);
2806 level = r_info[MON_CHAMELEON_K].level;
2807 else if (!dun_level)
2808 level = wilderness[p_ptr->wilderness_y][p_ptr->wilderness_x].level;
2812 if (d_info[dungeon_type].flags1 & DF1_CHAMELEON) level+= 2+randint1(3);
2814 r_idx = get_mon_num(level);
2815 r_ptr = &r_info[r_idx];
2817 chameleon_change_m_idx = 0;
2823 m_ptr->r_idx = r_idx;
2824 m_ptr->ap_r_idx = r_idx;
2825 update_mon(m_idx, FALSE);
2826 lite_spot(m_ptr->fy, m_ptr->fx);
2829 /* Sub-alignment of a chameleon */
2830 if (r_ptr->flags3 & (RF3_EVIL | RF3_GOOD))
2832 m_ptr->sub_align = SUB_ALIGN_NEUTRAL;
2833 if (r_ptr->flags3 & RF3_EVIL) m_ptr->sub_align |= SUB_ALIGN_EVIL;
2834 if (r_ptr->flags3 & RF3_GOOD) m_ptr->sub_align |= SUB_ALIGN_GOOD;
2839 if (m_idx == p_ptr->riding)
2842 monster_desc(m_name, m_ptr, 0);
2844 msg_format("ÆÍÁ³%s¤¬ÊѿȤ·¤¿¡£", old_m_name);
2846 msg_format("Suddenly, %s transforms!", old_m_name);
2848 if (!(r_ptr->flags7 & RF7_RIDING))
2850 if (rakuba(0, TRUE)) msg_print("ÃÏÌ̤ËÍî¤È¤µ¤ì¤¿¡£");
2852 if (rakuba(0, TRUE)) msg_format("You have fallen from %s.", m_name);
2856 /* Extract the monster base speed */
2857 m_ptr->mspeed = r_ptr->speed;
2858 /* Hack -- small racial variety */
2859 /* Allow some small variation per monster */
2861 i = extract_energy[r_ptr->speed] / 3;
2862 if (i) m_ptr->mspeed += rand_spread(0, i);
2865 i = extract_energy[r_ptr->speed] / 10;
2866 if (i) m_ptr->mspeed += rand_spread(0, i);
2869 oldmaxhp = m_ptr->max_maxhp;
2870 /* Assign maximal hitpoints */
2871 if (r_ptr->flags1 & RF1_FORCE_MAXHP)
2873 m_ptr->max_maxhp = maxroll(r_ptr->hdice, r_ptr->hside);
2877 m_ptr->max_maxhp = damroll(r_ptr->hdice, r_ptr->hside);
2879 m_ptr->maxhp = (long)(m_ptr->maxhp * m_ptr->max_maxhp) / oldmaxhp;
2880 m_ptr->hp = (long)(m_ptr->hp * m_ptr->max_maxhp) / oldmaxhp;
2887 static bool monster_hook_tanuki(int r_idx)
2889 monster_race *r_ptr = &r_info[r_idx];
2891 if (r_ptr->flags1 & (RF1_UNIQUE)) return FALSE;
2892 if (r_ptr->flags2 & RF2_MULTIPLY) return FALSE;
2893 if (r_ptr->flags7 & (RF7_FRIENDLY | RF7_CHAMELEON)) return FALSE;
2894 if (r_ptr->flags7 & RF7_AQUATIC) return FALSE;
2896 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))
2899 return (*(get_monster_hook()))(r_idx);
2904 * Set initial racial appearance of a monster
2906 static int initial_r_appearance(int r_idx)
2908 int attempts = 1000;
2911 int min = MIN(base_level-5, 50);
2913 if (!(r_info[r_idx].flags7 & RF7_TANUKI))
2916 get_mon_num_prep(monster_hook_tanuki, NULL);
2920 ap_r_idx = get_mon_num(base_level + 10);
2921 if (r_info[ap_r_idx].level >= min) return ap_r_idx;
2929 * Attempt to place a monster of the given race at the given location.
2931 * To give the player a sporting chance, any monster that appears in
2932 * line-of-sight and is extremely dangerous can be marked as
2933 * "FORCE_SLEEP", which will cause them to be placed with low energy,
2934 * which often (but not always) lets the player move before they do.
2936 * This routine refuses to place out-of-depth "FORCE_DEPTH" monsters.
2938 * XXX XXX XXX Use special "here" and "dead" flags for unique monsters,
2939 * remove old "cur_num" and "max_num" fields.
2941 * XXX XXX XXX Actually, do something similar for artifacts, to simplify
2942 * the "preserve" mode, and to make the "what artifacts" flag more useful.
2944 * This is the only function which may place a monster in the dungeon,
2945 * except for the savefile loading code.
2947 bool place_monster_one(int who, int y, int x, int r_idx, u32b mode)
2953 monster_type *m_ptr;
2955 monster_race *r_ptr = &r_info[r_idx];
2957 cptr name = (r_name + r_ptr->name);
2959 /* DO NOT PLACE A MONSTER IN THE SMALL SCALE WILDERNESS !!! */
2960 if(p_ptr->wild_mode) return FALSE;
2962 /* Verify location */
2963 if (!in_bounds(y, x)) return (FALSE);
2965 /* Require empty space (if not ghostly) */
2966 if (!(!dun_level && (cave[y][x].feat == FEAT_MOUNTAIN) && ((r_ptr->flags8 & RF8_WILD_MOUNTAIN) || (r_ptr->flags7 & RF7_CAN_FLY))) &&
2967 !(cave_empty_bold2(y, x) || (mode & PM_IGNORE_TERRAIN)) &&
2968 !((r_ptr->flags2 & RF2_PASS_WALL) &&
2969 !(cave_perma_bold(y, x) || cave[y][x].m_idx ||
2970 ((y == py) && (x == px))))) return (FALSE);
2973 if (!r_idx) return (FALSE);
2976 if (!r_ptr->name) return (FALSE);
2978 /* Nor on the Pattern */
2979 if ((cave[y][x].feat >= FEAT_PATTERN_START)
2980 && (cave[y][x].feat <= FEAT_PATTERN_XTRA2))
2983 if (!(mode & PM_IGNORE_TERRAIN) &&
2984 !monster_can_cross_terrain(cave[y][x].feat, r_ptr))
2989 if (!p_ptr->inside_battle)
2991 /* Hack -- "unique" monsters must be "unique" */
2992 if (((r_ptr->flags1 & (RF1_UNIQUE)) ||
2993 (r_ptr->flags7 & (RF7_UNIQUE_7))) &&
2994 (r_ptr->cur_num >= r_ptr->max_num))
3000 if ((r_ptr->flags7 & (RF7_UNIQUE2)) &&
3001 (r_ptr->cur_num >= 1))
3006 if (r_idx == MON_BANORLUPART)
3008 if (r_info[MON_BANOR].cur_num > 0) return FALSE;
3009 if (r_info[MON_LUPART].cur_num > 0) return FALSE;
3012 /* Depth monsters may NOT be created out of depth, unless in Nightmare mode */
3013 if ((r_ptr->flags1 & (RF1_FORCE_DEPTH)) && (dun_level < r_ptr->level) &&
3014 (!ironman_nightmare || (r_ptr->flags1 & (RF1_QUESTOR))))
3021 if(quest_number(dun_level))
3023 int hoge = quest_number(dun_level);
3024 if((quest[hoge].type == QUEST_TYPE_KILL_LEVEL) || (quest[hoge].type == QUEST_TYPE_RANDOM))
3026 if(r_idx == quest[hoge].r_idx)
3028 int number_mon, i2, j2;
3031 /* Count all quest monsters */
3032 for (i2 = 0; i2 < cur_wid; ++i2)
3033 for (j2 = 0; j2 < cur_hgt; j2++)
3034 if (cave[j2][i2].m_idx > 0)
3035 if (m_list[cave[j2][i2].m_idx].r_idx == quest[hoge].r_idx)
3037 if(number_mon + quest[hoge].cur_num >= quest[hoge].max_num)
3043 /* Access the location */
3044 c_ptr = &cave[y][x];
3046 if (is_glyph_grid(c_ptr))
3048 if (randint1(BREAK_GLYPH) < (r_ptr->level+20))
3050 /* Describe observable breakage */
3051 if (c_ptr->info & CAVE_MARK)
3054 msg_print("¼é¤ê¤Î¥ë¡¼¥ó¤¬²õ¤ì¤¿¡ª");
3056 msg_print("The rune of protection is broken!");
3061 /* Forget the rune */
3062 c_ptr->info &= ~(CAVE_MARK);
3064 /* Break the rune */
3065 c_ptr->info &= ~(CAVE_OBJECT);
3074 /* Powerful monster */
3075 if (r_ptr->level > dun_level)
3077 /* Unique monsters */
3078 if (r_ptr->flags1 & (RF1_UNIQUE))
3080 /* Message for cheaters */
3082 if (cheat_hear) msg_format("¿¼ÁؤΥæ¥Ë¡¼¥¯¡¦¥â¥ó¥¹¥¿¡¼ (%s)¡£", name);
3084 if (cheat_hear) msg_format("Deep Unique (%s).", name);
3088 /* Boost rating by twice delta-depth */
3089 rating += (r_ptr->level - dun_level) * 2;
3092 /* Normal monsters */
3095 /* Message for cheaters */
3097 if (cheat_hear) msg_format("¿¼ÁؤΥâ¥ó¥¹¥¿¡¼ (%s)¡£", name);
3099 if (cheat_hear) msg_format("Deep Monster (%s).", name);
3103 /* Boost rating by delta-depth */
3104 rating += (r_ptr->level - dun_level);
3108 /* Note the monster */
3109 else if (r_ptr->flags1 & (RF1_UNIQUE))
3111 /* Unique monsters induce message */
3113 if (cheat_hear) msg_format("¥æ¥Ë¡¼¥¯¡¦¥â¥ó¥¹¥¿¡¼ (%s)¡£", name);
3115 if (cheat_hear) msg_format("Unique (%s).", name);
3120 if ((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags7 & RF7_UNIQUE_7) || (r_ptr->level < 10)) is_kage = FALSE;
3122 /* Make a new monster */
3123 c_ptr->m_idx = m_pop();
3124 hack_m_idx_ii = c_ptr->m_idx;
3126 /* Mega-Hack -- catch "failure" */
3127 if (!c_ptr->m_idx) return (FALSE);
3130 /* Get a new monster record */
3131 m_ptr = &m_list[c_ptr->m_idx];
3134 m_ptr->r_idx = r_idx;
3135 m_ptr->ap_r_idx = initial_r_appearance(r_idx);
3137 /* Sub-alignment of a monster */
3138 if ((who > 0) && !(r_ptr->flags3 & (RF3_EVIL | RF3_GOOD)))
3139 m_ptr->sub_align = m_list[who].sub_align;
3142 m_ptr->sub_align = SUB_ALIGN_NEUTRAL;
3143 if (r_ptr->flags3 & RF3_EVIL) m_ptr->sub_align |= SUB_ALIGN_EVIL;
3144 if (r_ptr->flags3 & RF3_GOOD) m_ptr->sub_align |= SUB_ALIGN_GOOD;
3147 /* Place the monster at the location */
3152 /* No "damage" yet */
3154 m_ptr->confused = 0;
3157 /* Unknown distance */
3160 reset_target(m_ptr);
3162 m_ptr->nickname = 0;
3170 if (r_ptr->flags7 & RF7_CHAMELEON)
3172 choose_new_monster(c_ptr->m_idx, TRUE, 0);
3173 r_ptr = &r_info[m_ptr->r_idx];
3174 m_ptr->mflag2 |= MFLAG2_CHAMELEON;
3177 /* Hack - Set sub_align to neutral when the Chameleon Lord is generated as "GUARDIAN" */
3178 if ((r_ptr->flags1 & RF1_UNIQUE) && (who <= 0))
3179 m_ptr->sub_align = SUB_ALIGN_NEUTRAL;
3183 m_ptr->ap_r_idx = MON_KAGE;
3184 m_ptr->mflag2 |= MFLAG2_KAGE;
3187 if (mode & PM_NO_PET) m_ptr->mflag2 |= MFLAG2_NOPET;
3193 if (mode & PM_FORCE_PET)
3198 else if ((r_ptr->flags7 & RF7_FRIENDLY) ||
3199 (mode & PM_FORCE_FRIENDLY) || is_friendly_idx(who))
3201 if (!(p_ptr->align >= 0 && (r_ptr->flags3 & RF3_EVIL)) &&
3202 !(p_ptr->align < 0 && (r_ptr->flags3 & RF3_GOOD)))
3204 set_friendly(m_ptr);
3208 /* Assume no sleeping */
3211 /* Enforce sleeping if needed */
3212 if ((mode & PM_ALLOW_SLEEP) && r_ptr->sleep && !ironman_nightmare)
3214 int val = r_ptr->sleep;
3215 m_ptr->csleep = ((val * 2) + randint1(val * 10));
3218 /* Assign maximal hitpoints */
3219 if (r_ptr->flags1 & RF1_FORCE_MAXHP)
3221 m_ptr->max_maxhp = maxroll(r_ptr->hdice, r_ptr->hside);
3225 m_ptr->max_maxhp = damroll(r_ptr->hdice, r_ptr->hside);
3228 /* Monsters have double hitpoints in Nightmare mode */
3229 if (ironman_nightmare)
3231 u32b hp = m_ptr->max_maxhp * 2L;
3233 m_ptr->max_maxhp = (s16b)MIN(30000, hp);
3236 m_ptr->maxhp = m_ptr->max_maxhp;
3238 /* And start out fully healthy */
3239 if (m_ptr->r_idx == MON_WOUNDED_BEAR)
3240 m_ptr->hp = m_ptr->maxhp / 2;
3241 else m_ptr->hp = m_ptr->maxhp;
3244 /* Extract the monster base speed */
3245 m_ptr->mspeed = r_ptr->speed;
3247 /* Hack -- small racial variety */
3248 if (!(r_ptr->flags1 & RF1_UNIQUE) && !p_ptr->inside_arena)
3250 /* Allow some small variation per monster */
3252 i = extract_energy[r_ptr->speed] / 3;
3253 if (i) m_ptr->mspeed += rand_spread(0, i);
3256 i = extract_energy[r_ptr->speed] / 10;
3257 if (i) m_ptr->mspeed += rand_spread(0, i);
3261 if (mode & PM_HASTE) m_ptr->fast = 100;
3263 if (m_ptr->mspeed > 199) m_ptr->mspeed = 199;
3265 /* Give a random starting energy */
3266 if (!ironman_nightmare)
3268 m_ptr->energy_need = ENERGY_NEED() - (s16b)randint0(100);
3272 /* Nightmare monsters are more prepared */
3273 m_ptr->energy_need = ENERGY_NEED() - (s16b)randint0(100) * 2;
3276 /* Force monster to wait for player, unless in Nightmare mode */
3277 if ((r_ptr->flags1 & RF1_FORCE_SLEEP) && !ironman_nightmare)
3279 /* Monster is still being nice */
3280 m_ptr->mflag |= (MFLAG_NICE);
3282 /* Must repair monsters */
3283 repair_monsters = TRUE;
3286 /* Hack -- see "process_monsters()" */
3287 if (c_ptr->m_idx < hack_m_idx)
3289 /* Monster is still being born */
3290 m_ptr->mflag |= (MFLAG_BORN);
3294 /* Update the monster */
3295 update_mon(c_ptr->m_idx, TRUE);
3298 /* Count the monsters on the level */
3299 real_r_ptr(m_ptr)->cur_num++;
3302 * Memorize location of the unique monster in saved floors.
3303 * A unique monster move from old saved floor.
3305 if (character_dungeon &&
3306 ((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags7 & RF7_UNIQUE_7)))
3307 real_r_ptr(m_ptr)->floor_id = p_ptr->floor_id;
3309 /* Hack -- Count the number of "reproducers" */
3310 if (r_ptr->flags2 & RF2_MULTIPLY) num_repro++;
3313 /* Hack -- Notice new multi-hued monsters */
3314 if (r_ptr->flags1 & RF1_ATTR_MULTI) shimmer_monsters = TRUE;
3316 if (p_ptr->warning && character_dungeon)
3318 if (r_ptr->flags1 & RF1_UNIQUE)
3322 char o_name[MAX_NLEN];
3324 if (r_ptr->level > p_ptr->lev + 30)
3330 else if (r_ptr->level > p_ptr->lev + 15)
3336 else if (r_ptr->level > p_ptr->lev + 5)
3338 color = "¥ë¥Ó¡¼¿§¤Ë";
3342 else if (r_ptr->level > p_ptr->lev - 5)
3348 else if (r_ptr->level > p_ptr->lev - 15)
3350 color = "¥Ô¥ó¥¯¿§¤Ë";
3361 o_ptr = choose_warning_item();
3362 object_desc(o_name, o_ptr, FALSE, 0);
3364 msg_format("%s¤Ï%s¸÷¤Ã¤¿¡£",o_name, color);
3366 msg_format("%s glows %s.",o_name, color);
3371 if (is_explosive_rune_grid(c_ptr))
3373 /* Break the ward */
3374 if (randint1(BREAK_MINOR_GLYPH) > r_ptr->level)
3376 /* Describe observable breakage */
3377 if (c_ptr->info & CAVE_MARK)
3380 msg_print("¥ë¡¼¥ó¤¬Çúȯ¤·¤¿¡ª");
3382 msg_print("The rune explodes!");
3385 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);
3391 msg_print("Çúȯ¤Î¥ë¡¼¥ó¤Ï²ò½ü¤µ¤ì¤¿¡£");
3393 msg_print("An explosive rune was disarmed.");
3397 /* Forget the rune */
3398 c_ptr->info &= ~(CAVE_MARK);
3400 /* Break the rune */
3401 c_ptr->info &= ~(CAVE_OBJECT);
3414 * improved version of scatter() for place monster
3417 #define MON_SCAT_MAXD 10
3419 static bool mon_scatter(int *yp, int *xp, int y, int x, int max_dist)
3421 int place_x[MON_SCAT_MAXD];
3422 int place_y[MON_SCAT_MAXD];
3423 int num[MON_SCAT_MAXD];
3427 if (max_dist >= MON_SCAT_MAXD)
3430 for (i = 0; i < MON_SCAT_MAXD; i++)
3433 for (nx = x - max_dist; nx <= x + max_dist; nx++)
3434 for (ny = y - max_dist; ny <= y + max_dist; ny++)
3436 /* Ignore annoying locations */
3437 if (!in_bounds(ny, nx)) continue;
3439 /* Require "line of sight" */
3440 if (!los(y, x, ny, nx)) continue;
3442 /* Walls and Monsters block flow */
3443 if (!cave_empty_bold2(ny, nx)) continue;
3444 if (cave[ny][nx].m_idx) continue;
3445 if ((ny == py) && (nx == px)) continue;
3447 /* ... nor on the Pattern */
3448 if ((cave[ny][nx].feat >= FEAT_PATTERN_START) &&
3449 (cave[ny][nx].feat <= FEAT_PATTERN_XTRA2))
3452 i = distance(y, x, ny, nx);
3469 while (i < MON_SCAT_MAXD && 0 == num[i])
3471 if (i >= MON_SCAT_MAXD)
3482 * Maximum size of a group of monsters
3484 #define GROUP_MAX 32
3488 * Attempt to place a "group" of monsters around the given location
3490 static bool place_monster_group(int who, int y, int x, int r_idx, u32b mode)
3492 monster_race *r_ptr = &r_info[r_idx];
3495 int total = 0, extra = 0;
3499 byte hack_y[GROUP_MAX];
3500 byte hack_x[GROUP_MAX];
3503 /* Pick a group size */
3504 total = randint1(10);
3506 /* Hard monsters, small groups */
3507 if (r_ptr->level > dun_level)
3509 extra = r_ptr->level - dun_level;
3510 extra = 0 - randint1(extra);
3513 /* Easy monsters, large groups */
3514 else if (r_ptr->level < dun_level)
3516 extra = dun_level - r_ptr->level;
3517 extra = randint1(extra);
3520 /* Hack -- limit group reduction */
3521 if (extra > 9) extra = 9;
3523 /* Modify the group size */
3527 if (total < 1) total = 1;
3530 if (total > GROUP_MAX) total = GROUP_MAX;
3533 /* Save the rating */
3536 /* Start on the monster */
3541 /* Puddle monsters, breadth first, up to total */
3542 for (n = 0; (n < hack_n) && (hack_n < total); n++)
3544 /* Grab the location */
3548 /* Check each direction, up to total */
3549 for (i = 0; (i < 8) && (hack_n < total); i++)
3553 scatter(&my, &mx, hy, hx, 4, 0);
3555 /* Walls and Monsters block flow */
3556 if (!cave_empty_bold2(my, mx)) continue;
3558 /* Attempt to place another monster */
3559 if (place_monster_one(who, my, mx, r_idx, mode))
3561 /* Add it to the "hack" set */
3562 hack_y[hack_n] = my;
3563 hack_x[hack_n] = mx;
3569 /* Hack -- restore the rating */
3579 * Hack -- help pick an escort type
3581 static int place_monster_idx = 0;
3582 static int place_monster_m_idx = 0;
3585 * Hack -- help pick an escort type
3587 static bool place_monster_okay(int r_idx)
3589 monster_race *r_ptr = &r_info[place_monster_idx];
3590 monster_type *m_ptr = &m_list[place_monster_m_idx];
3592 monster_race *z_ptr = &r_info[r_idx];
3594 /* Hack - Escorts have to have the same dungeon flag */
3595 if (monster_dungeon(place_monster_idx) != monster_dungeon(r_idx)) return (FALSE);
3597 /* Require similar "race" */
3598 if (z_ptr->d_char != r_ptr->d_char) return (FALSE);
3600 /* Skip more advanced monsters */
3601 if (z_ptr->level > r_ptr->level) return (FALSE);
3603 /* Skip unique monsters */
3604 if (z_ptr->flags1 & RF1_UNIQUE) return (FALSE);
3606 /* Paranoia -- Skip identical monsters */
3607 if (place_monster_idx == r_idx) return (FALSE);
3609 /* Skip different alignment */
3610 if (((m_ptr->sub_align & SUB_ALIGN_EVIL) && (z_ptr->flags3 & RF3_GOOD)) ||
3611 ((m_ptr->sub_align & SUB_ALIGN_GOOD) && (z_ptr->flags3 & RF3_EVIL)))
3614 if (r_ptr->flags7 & RF7_FRIENDLY)
3616 if (((p_ptr->align < 0) && (z_ptr->flags3 & RF3_GOOD)) ||
3617 ((p_ptr->align > 0) && (z_ptr->flags3 & RF3_EVIL)))
3621 if ((r_ptr->flags7 & RF7_CHAMELEON) && !(z_ptr->flags7 & RF7_CHAMELEON))
3630 * Attempt to place a monster of the given race at the given location
3632 * Note that certain monsters are now marked as requiring "friends".
3633 * These monsters, if successfully placed, and if the "grp" parameter
3634 * is TRUE, will be surrounded by a "group" of identical monsters.
3636 * Note that certain monsters are now marked as requiring an "escort",
3637 * which is a collection of monsters with similar "race" but lower level.
3639 * Some monsters induce a fake "group" flag on their escorts.
3641 * Note the "bizarre" use of non-recursion to prevent annoying output
3642 * when running a code profiler.
3644 * Note the use of the new "monster allocation table" code to restrict
3645 * the "get_mon_num()" function to "legal" escort types.
3647 bool place_monster_aux(int who, int y, int x, int r_idx, u32b mode)
3650 monster_race *r_ptr = &r_info[r_idx];
3652 if (one_in_(333) && !(mode & PM_NO_KAGE) && !(mode & PM_FORCE_PET))
3657 /* Place one monster, or fail */
3658 if (!place_monster_one(who, y, x, r_idx, mode)) return (FALSE);
3661 /* Require the "group" flag */
3662 if (!(mode & PM_ALLOW_GROUP)) return (TRUE);
3664 place_monster_m_idx = hack_m_idx_ii;
3666 /* Friends for certain monsters */
3667 if (r_ptr->flags1 & (RF1_FRIENDS))
3669 /* Attempt to place a group */
3670 (void)place_monster_group(who, y, x, r_idx, mode);
3674 /* Escorts for certain monsters */
3675 if (r_ptr->flags1 & (RF1_ESCORT))
3677 /* Set the escort index */
3678 place_monster_idx = r_idx;
3680 /* Try to place several "escorts" */
3681 for (i = 0; i < 32; i++)
3683 int nx, ny, z, d = 3;
3685 /* Pick a location */
3686 scatter(&ny, &nx, y, x, d, 0);
3688 /* Require empty grids */
3689 if (!cave_empty_bold2(ny, nx)) continue;
3691 /* Prepare allocation table */
3692 get_mon_num_prep(place_monster_okay, get_monster_hook2(ny, nx));
3694 /* Pick a random race */
3695 z = get_mon_num(r_ptr->level);
3697 /* Handle failure */
3700 /* Place a single escort */
3701 (void)place_monster_one(place_monster_m_idx, ny, nx, z, mode);
3703 /* Place a "group" of escorts if needed */
3704 if ((r_info[z].flags1 & RF1_FRIENDS) ||
3705 (r_ptr->flags1 & RF1_ESCORTS))
3707 /* Place a group of monsters */
3708 (void)place_monster_group(place_monster_m_idx, ny, nx, z, mode);
3719 * Hack -- attempt to place a monster at the given location
3721 * Attempt to find a monster appropriate to the "monster_level"
3723 bool place_monster(int y, int x, u32b mode)
3727 /* Prepare allocation table */
3728 get_mon_num_prep(get_monster_hook(), get_monster_hook2(y, x));
3730 /* Pick a monster */
3731 r_idx = get_mon_num(monster_level);
3733 /* Handle failure */
3734 if (!r_idx) return (FALSE);
3736 /* Attempt to place the monster */
3737 if (place_monster_aux(0, y, x, r_idx, mode)) return (TRUE);
3744 #ifdef MONSTER_HORDES
3746 bool alloc_horde(int y, int x)
3748 monster_race *r_ptr = NULL;
3751 int attempts = 1000;
3755 /* Prepare allocation table */
3756 get_mon_num_prep(get_monster_hook(), get_monster_hook2(y, x));
3760 /* Pick a monster */
3761 r_idx = get_mon_num(monster_level);
3763 /* Handle failure */
3764 if (!r_idx) return (FALSE);
3766 r_ptr = &r_info[r_idx];
3768 if (r_ptr->flags1 & RF1_UNIQUE) continue;
3770 if (r_idx == MON_HAGURE) continue;
3773 if (attempts < 1) return FALSE;
3779 /* Attempt to place the monster */
3780 if (place_monster_aux(0, y, x, r_idx, 0L)) break;
3783 if (attempts < 1) return FALSE;
3785 m_idx = cave[y][x].m_idx;
3787 if (m_list[m_idx].mflag2 & MFLAG2_CHAMELEON) r_ptr = &r_info[m_list[m_idx].r_idx];
3788 summon_kin_type = r_ptr->d_char;
3790 for (attempts = randint1(10) + 5; attempts; attempts--)
3792 scatter(&cy, &cx, y, x, 5, 0);
3794 (void)summon_specific(m_idx, cy, cx, dun_level + 5, SUMMON_KIN, PM_ALLOW_GROUP);
3803 #endif /* MONSTER_HORDES */
3808 * Attempt to allocate a random monster in the dungeon.
3810 * Place the monster at least "dis" distance from the player.
3812 * Use "slp" to choose the initial "sleep" status
3814 * Use "monster_level" for the monster level
3816 bool alloc_monster(int dis, u32b mode)
3819 int attempts_left = 10000;
3820 int guardian = d_info[dungeon_type].final_guardian;
3822 /* Put an Guardian */
3823 if(guardian && d_info[dungeon_type].maxdepth == dun_level && r_info[guardian].cur_num < r_info[guardian].max_num )
3829 /* Find a good position */
3832 /* Get a random spot */
3833 oy = randint1(cur_hgt - 4) + 2;
3834 ox = randint1(cur_wid - 4) + 2;
3836 /* Is it a good spot ? */
3837 if (cave_empty_bold2(oy, ox) && monster_can_cross_terrain(cave[oy][ox].feat, &r_info[guardian]))
3839 /* Place the guardian */
3840 if (place_monster_aux(0, oy, ox, guardian, (PM_ALLOW_GROUP | PM_NO_KAGE | PM_NO_PET))) break;
3848 /* Find a legal, distant, unoccupied, space */
3849 while (attempts_left--)
3851 /* Pick a location */
3852 y = randint0(cur_hgt);
3853 x = randint0(cur_wid);
3855 /* Require empty floor grid (was "naked") */
3856 if (dun_level || (wilderness[p_ptr->wilderness_y][p_ptr->wilderness_x].terrain != TERRAIN_MOUNTAIN))
3858 if (!cave_empty_bold2(y, x)) continue;
3862 if (!cave_empty_bold2(y, x) && (cave[y][x].feat != FEAT_MOUNTAIN)) continue;
3865 /* Accept far away grids */
3866 if (distance(y, x, py, px) > dis) break;
3871 if (cheat_xtra || cheat_hear)
3874 msg_print("·Ù¹ð¡ª¿·¤¿¤Ê¥â¥ó¥¹¥¿¡¼¤òÇÛÃ֤Ǥ¤Þ¤»¤ó¡£¾®¤µ¤¤³¬¤Ç¤¹¤«¡©");
3876 msg_print("Warning! Could not allocate a new monster. Small level?");
3885 #ifdef MONSTER_HORDES
3886 if (randint1(5000) <= dun_level)
3888 if (alloc_horde(y, x))
3891 if (cheat_hear) msg_print("¥â¥ó¥¹¥¿¡¼¤ÎÂç·²");
3893 if (cheat_hear) msg_print("Monster horde.");
3901 #endif /* MONSTER_HORDES */
3903 /* Attempt to place the monster, allow groups */
3904 if (place_monster(y, x, (mode | PM_ALLOW_GROUP))) return (TRUE);
3906 #ifdef MONSTER_HORDES
3908 #endif /* MONSTER_HORDES */
3918 * Hack -- help decide if a monster race is "okay" to summon
3920 static bool summon_specific_okay(int r_idx)
3922 monster_race *r_ptr = &r_info[r_idx];
3924 /* Hack - Only summon dungeon monsters */
3925 if (!monster_dungeon(r_idx)) return (FALSE);
3927 /* Hack -- identify the summoning monster */
3928 if (summon_specific_who > 0)
3930 monster_type *m_ptr = &m_list[summon_specific_who];
3932 /* Do not summon enemies */
3934 /* Friendly vs. opposite aligned normal or pet */
3935 if (((r_ptr->flags3 & RF3_EVIL) &&
3936 (m_ptr->sub_align & SUB_ALIGN_GOOD)) ||
3937 ((r_ptr->flags3 & RF3_GOOD) &&
3938 (m_ptr->sub_align & SUB_ALIGN_EVIL)))
3943 /* Hostile vs. non-hostile */
3944 if (is_hostile(m_ptr) != summon_specific_hostile)
3949 /* Use the player's alignment */
3950 else if (summon_specific_who < 0)
3952 /* Do not summon enemies of the pets */
3953 if ((p_ptr->align < -9) && (r_ptr->flags3 & RF3_GOOD))
3955 if (!one_in_((0-p_ptr->align)/2+1)) return FALSE;
3957 else if ((p_ptr->align > 9) && (r_ptr->flags3 & RF3_EVIL))
3959 if (!one_in_(p_ptr->align/2+1)) return FALSE;
3963 /* Hack -- no specific type specified */
3964 if (!summon_specific_type) return (TRUE);
3966 if (!summon_unique_okay && ((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags7 & RF7_UNIQUE_7))) return FALSE;
3968 if ((summon_specific_who < 0) &&
3969 ((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags7 & RF7_UNIQUE_7)) &&
3970 (((p_ptr->align > 9) && (r_ptr->flags3 & RF3_EVIL)) ||
3971 ((p_ptr->align < -9) && (r_ptr->flags3 & RF3_GOOD))))
3974 if ((r_ptr->flags7 & RF7_CHAMELEON) && (d_info[dungeon_type].flags1 & DF1_CHAMELEON)) return TRUE;
3976 return (summon_specific_aux(r_idx));
3981 * Place a monster (of the specified "type") near the given
3982 * location. Return TRUE if a monster was actually summoned.
3984 * We will attempt to place the monster up to 10 times before giving up.
3986 * Note: SUMMON_UNIQUE and SUMMON_AMBERITES will summon Unique's
3987 * Note: SUMMON_HI_UNDEAD and SUMMON_HI_DRAGON may summon Unique's
3988 * Note: None of the other summon codes will ever summon Unique's.
3990 * This function has been changed. We now take the "monster level"
3991 * of the summoning monster as a parameter, and use that, along with
3992 * the current dungeon level, to help determine the level of the
3993 * desired monster. Note that this is an upper bound, and also
3994 * tends to "prefer" monsters of that level. Currently, we use
3995 * the average of the dungeon and monster levels, and then add
3996 * five to allow slight increases in monster power.
3998 * Note that we use the new "monster allocation table" creation code
3999 * to restrict the "get_mon_num()" function to the set of "legal"
4000 * monsters, making this function much faster and more reliable.
4002 * Note that this function may not succeed, though this is very rare.
4004 bool summon_specific(int who, int y1, int x1, int lev, int type, u32b mode)
4008 if (p_ptr->inside_arena) return (FALSE);
4010 if (!mon_scatter(&y, &x, y1, x1, 2)) return FALSE;
4012 /* Save the summoner */
4013 summon_specific_who = who;
4015 /* Save the "summon" type */
4016 summon_specific_type = type;
4018 summon_unique_okay = (mode & PM_ALLOW_UNIQUE) ? TRUE : FALSE;
4020 /* Save the hostility */
4021 summon_specific_hostile = (!(mode & PM_FORCE_FRIENDLY) && !(is_friendly_idx(who)) && !(mode & PM_FORCE_PET));
4023 /* Prepare allocation table */
4024 get_mon_num_prep(summon_specific_okay, get_monster_hook2(y, x));
4026 /* Pick a monster, using the level calculation */
4027 r_idx = get_mon_num((dun_level + lev) / 2 + 5);
4029 /* Handle failure */
4032 summon_specific_type = 0;
4036 if ((type == SUMMON_BLUE_HORROR) || (type == SUMMON_DAWN)) mode |= PM_NO_KAGE;
4038 /* Attempt to place the monster (awake, allow groups) */
4039 if (!place_monster_aux(who, y, x, r_idx, mode))
4041 summon_specific_type = 0;
4045 summon_specific_type = 0;
4050 /* A "dangerous" function, creates a pet of the specified type */
4051 bool summon_named_creature (int who, int oy, int ox, int r_idx, u32b mode)
4056 /* if (!r_idx) return; */
4058 /* Prevent illegal monsters */
4059 if (r_idx >= max_r_idx) return FALSE;
4061 if (p_ptr->inside_arena) return FALSE;
4063 if (!mon_scatter(&y, &x, oy, ox, 2)) return FALSE;
4065 /* Place it (allow groups) */
4066 return place_monster_aux(who, y, x, r_idx, (mode | PM_NO_KAGE));
4071 * Let the given monster attempt to reproduce.
4073 * Note that "reproduction" REQUIRES empty space.
4075 bool multiply_monster(int m_idx, bool clone, u32b mode)
4077 monster_type *m_ptr = &m_list[m_idx];
4081 if (!mon_scatter(&y, &x, m_ptr->fy, m_ptr->fx, 1))
4084 if (m_ptr->mflag2 & MFLAG2_NOPET) mode |= PM_NO_PET;
4086 /* Create a new monster (awake, no groups) */
4087 if (!place_monster_aux(m_idx, y, x, m_ptr->r_idx, (mode | PM_NO_KAGE)))
4092 m_list[hack_m_idx_ii].smart |= SM_CLONED;
4093 m_list[hack_m_idx_ii].mflag2 |= MFLAG2_NOPET;
4104 * Dump a message describing a monster's reaction to damage
4106 * Technically should attempt to treat "Beholder"'s as jelly's
4108 void message_pain(int m_idx, int dam)
4110 long oldhp, newhp, tmp;
4113 monster_type *m_ptr = &m_list[m_idx];
4114 monster_race *r_ptr = &r_info[m_ptr->r_idx];
4119 /* Get the monster name */
4120 monster_desc(m_name, m_ptr, 0);
4122 /* Notice non-damage */
4126 msg_format("%^s¤Ï¥À¥á¡¼¥¸¤ò¼õ¤±¤Æ¤¤¤Ê¤¤¡£", m_name);
4128 msg_format("%^s is unharmed.", m_name);
4134 /* Note -- subtle fix -CFT */
4135 newhp = (long)(m_ptr->hp);
4136 oldhp = newhp + (long)(dam);
4137 tmp = (newhp * 100L) / oldhp;
4138 percentage = (int)(tmp);
4141 /* Mushrooms, Eyes, Jellies, Molds, Vortices, Worms, Quylthulgs */
4142 if (strchr(",ejmvwQ", r_ptr->d_char))
4145 if (percentage > 95)
4146 msg_format("%^s¤Ï¤Û¤È¤ó¤Éµ¤¤Ë¤È¤á¤Æ¤¤¤Ê¤¤¡£", m_name);
4147 else if (percentage > 75)
4148 msg_format("%^s¤Ï¤·¤ê¹þ¤ß¤·¤¿¡£", m_name);
4149 else if (percentage > 50)
4150 msg_format("%^s¤Ï½Ì¤³¤Þ¤Ã¤¿¡£", m_name);
4151 else if (percentage > 35)
4152 msg_format("%^s¤ÏÄˤߤ˿̤¨¤¿¡£", m_name);
4153 else if (percentage > 20)
4154 msg_format("%^s¤Ï¿È¤â¤À¤¨¤·¤¿¡£", m_name);
4155 else if (percentage > 10)
4156 msg_format("%^s¤Ï¶ìÄˤǿȤâ¤À¤¨¤·¤¿¡£", m_name);
4158 msg_format("%^s¤Ï¤°¤Ë¤ã¤°¤Ë¤ã¤ÈáÛÚ»¤·¤¿¡£", m_name);
4160 if (percentage > 95)
4161 msg_format("%^s barely notices.", m_name);
4162 else if (percentage > 75)
4163 msg_format("%^s flinches.", m_name);
4164 else if (percentage > 50)
4165 msg_format("%^s squelches.", m_name);
4166 else if (percentage > 35)
4167 msg_format("%^s quivers in pain.", m_name);
4168 else if (percentage > 20)
4169 msg_format("%^s writhes about.", m_name);
4170 else if (percentage > 10)
4171 msg_format("%^s writhes in agony.", m_name);
4173 msg_format("%^s jerks limply.", m_name);
4180 else if (strchr("l", r_ptr->d_char))
4182 if (percentage > 95)
4184 msg_format("%^s¤Ï¤Û¤È¤ó¤Éµ¤¤Ë¤È¤á¤Æ¤¤¤Ê¤¤¡£", m_name);
4186 msg_format("%^s barely notices.", m_name);
4188 else if (percentage > 75)
4190 msg_format("%^s¤Ï¤·¤ê¹þ¤ß¤·¤¿¡£", m_name);
4192 msg_format("%^s flinches.", m_name);
4194 else if (percentage > 50)
4196 msg_format("%^s¤Ïí´í°¤·¤¿¡£", m_name);
4198 msg_format("%^s hesitates.", m_name);
4200 else if (percentage > 35)
4202 msg_format("%^s¤ÏÄˤߤ˿̤¨¤¿¡£", m_name);
4204 msg_format("%^s quivers in pain.", m_name);
4206 else if (percentage > 20)
4208 msg_format("%^s¤Ï¿È¤â¤À¤¨¤·¤¿¡£", m_name);
4210 msg_format("%^s writhes about.", m_name);
4212 else if (percentage > 10)
4214 msg_format("%^s¤Ï¶ìÄˤǿȤâ¤À¤¨¤·¤¿¡£", m_name);
4216 msg_format("%^s writhes in agony.", m_name);
4220 msg_format("%^s¤Ï¤°¤Ë¤ã¤°¤Ë¤ã¤ÈáÛÚ»¤·¤¿¡£", m_name);
4222 msg_format("%^s jerks limply.", m_name);
4227 /* Golems, Walls, Doors, Stairs */
4228 else if (strchr("g#+<>", r_ptr->d_char))
4230 if (percentage > 95)
4232 msg_format("%s¤Ï¹¶·â¤òµ¤¤Ë¤È¤á¤Æ¤¤¤Ê¤¤¡£", m_name);
4234 msg_format("%^s ignores the attack.", m_name);
4236 else if (percentage > 75)
4238 msg_format("%s¤Ï¹¶·â¤Ë¸ª¤ò¤¹¤¯¤á¤¿¡£", m_name);
4240 msg_format("%^s shrugs off the attack.", m_name);
4242 else if (percentage > 50)
4244 msg_format("%^s¤ÏÍëÌĤΤ褦¤ËËʤ¨¤¿¡£", m_name);
4246 msg_format("%^s roars thunderously.", m_name);
4248 else if (percentage > 35)
4250 msg_format("%^s¤Ï¶ì¤·¤²¤ËËʤ¨¤¿¡£", m_name);
4252 msg_format("%^s rumbles.", m_name);
4254 else if (percentage > 20)
4256 msg_format("%^s¤Ï¤¦¤á¤¤¤¿¡£", m_name);
4258 msg_format("%^s grunts.", m_name);
4260 else if (percentage > 10)
4262 msg_format("%^s¤Ïí´í°¤·¤¿¡£", m_name);
4264 msg_format("%^s hesitates.", m_name);
4268 msg_format("%^s¤Ï¤¯¤·¤ã¤¯¤·¤ã¤Ë¤Ê¤Ã¤¿¡£", m_name);
4270 msg_format("%^s crumples.", m_name);
4275 /* Snakes, Hydrae, Reptiles, Mimics */
4276 else if (strchr("JMR", r_ptr->d_char) || !isalpha(r_ptr->d_char))
4278 if (percentage > 95)
4280 msg_format("%^s¤Ï¤Û¤È¤ó¤Éµ¤¤Ë¤È¤á¤Æ¤¤¤Ê¤¤¡£", m_name);
4282 msg_format("%^s barely notices.", m_name);
4284 else if (percentage > 75)
4286 msg_format("%^s¤Ï¥·¡¼¥Ã¤ÈÌĤ¤¤¿¡£", m_name);
4288 msg_format("%^s hisses.", m_name);
4290 else if (percentage > 50)
4292 msg_format("%^s¤ÏÅܤäÆƬ¤ò¾å¤²¤¿¡£", m_name);
4294 msg_format("%^s rears up in anger.", m_name);
4296 else if (percentage > 35)
4298 msg_format("%^s¤ÏÌÔÁ³¤È°Ò³Å¤·¤¿¡£", m_name);
4300 msg_format("%^s hisses furiously.", m_name);
4302 else if (percentage > 20)
4304 msg_format("%^s¤Ï¿È¤â¤À¤¨¤·¤¿¡£", m_name);
4306 msg_format("%^s writhes about.", m_name);
4308 else if (percentage > 10)
4310 msg_format("%^s¤Ï¶ìÄˤǿȤâ¤À¤¨¤·¤¿¡£", m_name);
4312 msg_format("%^s writhes in agony.", m_name);
4316 msg_format("%^s¤Ï¤°¤Ë¤ã¤°¤Ë¤ã¤ÈáÛÚ»¤·¤¿¡£", m_name);
4318 msg_format("%^s jerks limply.", m_name);
4324 else if (strchr("f", r_ptr->d_char))
4326 if (percentage > 95)
4328 msg_format("%s¤Ï¹¶·â¤Ë¸ª¤ò¤¹¤¯¤á¤¿¡£", m_name);
4330 msg_format("%^s shrugs off the attack.", m_name);
4332 else if (percentage > 75)
4334 msg_format("%^s¤ÏËʤ¨¤¿¡£", m_name);
4336 msg_format("%^s roars.", m_name);
4338 else if (percentage > 50)
4340 msg_format("%^s¤ÏÅܤäÆËʤ¨¤¿¡£", m_name);
4342 msg_format("%^s growls angrily.", m_name);
4344 else if (percentage > 35)
4346 msg_format("%^s¤ÏÄˤߤǥ·¡¼¥Ã¤ÈÌĤ¤¤¿¡£", m_name);
4348 msg_format("%^s hisses with pain.", m_name);
4350 else if (percentage > 20)
4352 msg_format("%^s¤ÏÄˤߤǼ塹¤·¤¯ÌĤ¤¤¿¡£", m_name);
4354 msg_format("%^s mewls in pain.", m_name);
4356 else if (percentage > 10)
4358 msg_format("%^s¤Ï¶ìÄˤˤ¦¤á¤¤¤¿¡£", m_name);
4360 msg_format("%^s hisses in agony.", m_name);
4364 msg_format("%s¤Ï°¥¤ì¤ÊÌĤÀ¼¤ò½Ð¤·¤¿¡£", m_name);
4366 msg_format("%^s mewls pitifully.", m_name);
4371 /* Ants, Centipedes, Flies, Insects, Beetles, Spiders */
4372 else if (strchr("acFIKS", r_ptr->d_char))
4374 if (percentage > 95)
4376 msg_format("%s¤Ï¹¶·â¤òµ¤¤Ë¤È¤á¤Æ¤¤¤Ê¤¤¡£", m_name);
4378 msg_format("%^s ignores the attack.", m_name);
4380 else if (percentage > 75)
4382 msg_format("%^s¤Ï¥¡¼¥¡¼ÌĤ¤¤¿¡£", m_name);
4384 msg_format("%^s chitters.", m_name);
4387 else if (percentage > 50)
4389 msg_format("%^s¤Ï¥è¥í¥è¥íƨ¤²²ó¤Ã¤¿¡£", m_name);
4391 msg_format("%^s scuttles about.", m_name);
4394 else if (percentage > 35)
4396 msg_format("%^s¤Ï¤¦¤ë¤µ¤¯ÌĤ¤¤¿¡£", m_name);
4398 msg_format("%^s twitters.", m_name);
4401 else if (percentage > 20)
4403 msg_format("%^s¤ÏÄˤߤËáÛÚ»¤·¤¿¡£", m_name);
4405 msg_format("%^s jerks in pain.", m_name);
4408 else if (percentage > 10)
4410 msg_format("%^s¤Ï¶ìÄˤÇáÛÚ»¤·¤¿¡£", m_name);
4412 msg_format("%^s jerks in agony.", m_name);
4417 msg_format("%^s¤Ï¥Ô¥¯¥Ô¥¯¤Ò¤¤Ä¤Ã¤¿¡£", m_name);
4419 msg_format("%^s twitches.", m_name);
4426 else if (strchr("B", r_ptr->d_char))
4428 if (percentage > 95)
4430 msg_format("%^s¤Ï¤µ¤¨¤º¤Ã¤¿¡£", m_name);
4432 msg_format("%^s chirps.", m_name);
4435 else if (percentage > 75)
4437 msg_format("%^s¤Ï¥Ô¡¼¥Ô¡¼ÌĤ¤¤¿¡£", m_name);
4439 msg_format("%^s twitters.", m_name);
4442 else if (percentage > 50)
4444 msg_format("%^s¤Ï¥®¥ã¡¼¥®¥ã¡¼ÌĤ¤¤¿¡£", m_name);
4446 msg_format("%^s squawks.", m_name);
4449 else if (percentage > 35)
4451 msg_format("%^s¤Ï¥®¥ã¡¼¥®¥ã¡¼ÌĤ¤ï¤á¤¤¤¿¡£", m_name);
4453 msg_format("%^s chatters.", m_name);
4456 else if (percentage > 20)
4458 msg_format("%^s¤Ï¶ì¤·¤ó¤À¡£", m_name);
4460 msg_format("%^s jeers.", m_name);
4463 else if (percentage > 10)
4465 msg_format("%^s¤Ï¤Î¤¿¤¦¤Á²ó¤Ã¤¿¡£", m_name);
4467 msg_format("%^s flutters about.", m_name);
4472 msg_format("%^s¤Ï¥¡¼¥¡¼¤ÈÌĤ¶«¤ó¤À¡£", m_name);
4474 msg_format("%^s squeaks.", m_name);
4480 /* Dragons, Demons, High Undead */
4481 else if (strchr("duDLUW", r_ptr->d_char))
4483 if (percentage > 95)
4485 msg_format("%s¤Ï¹¶·â¤òµ¤¤Ë¤È¤á¤Æ¤¤¤Ê¤¤¡£", m_name);
4487 msg_format("%^s ignores the attack.", m_name);
4490 else if (percentage > 75)
4492 msg_format("%^s¤Ï¤·¤ê¹þ¤ß¤·¤¿¡£", m_name);
4494 msg_format("%^s flinches.", m_name);
4497 else if (percentage > 50)
4499 msg_format("%^s¤ÏÄˤߤǥ·¡¼¥Ã¤ÈÌĤ¤¤¿¡£", m_name);
4501 msg_format("%^s hisses in pain.", m_name);
4504 else if (percentage > 35)
4506 msg_format("%^s¤ÏÄˤߤǤ¦¤Ê¤Ã¤¿¡£", m_name);
4508 msg_format("%^s snarls with pain.", m_name);
4511 else if (percentage > 20)
4513 msg_format("%^s¤ÏÄˤߤËËʤ¨¤¿¡£", m_name);
4515 msg_format("%^s roars with pain.", m_name);
4518 else if (percentage > 10)
4520 msg_format("%^s¤Ï¶ì¤·¤²¤Ë¶«¤ó¤À¡£", m_name);
4522 msg_format("%^s gasps.", m_name);
4527 msg_format("%^s¤Ï¼å¡¹¤·¤¯¤¦¤Ê¤Ã¤¿¡£", m_name);
4529 msg_format("%^s snarls feebly.", m_name);
4536 else if (strchr("s", r_ptr->d_char))
4538 if (percentage > 95)
4540 msg_format("%s¤Ï¹¶·â¤òµ¤¤Ë¤È¤á¤Æ¤¤¤Ê¤¤¡£", m_name);
4542 msg_format("%^s ignores the attack.", m_name);
4545 else if (percentage > 75)
4547 msg_format("%s¤Ï¹¶·â¤Ë¸ª¤ò¤¹¤¯¤á¤¿¡£", m_name);
4549 msg_format("%^s shrugs off the attack.", m_name);
4552 else if (percentage > 50)
4554 msg_format("%^s¤Ï¥«¥¿¥«¥¿¤È¾Ð¤Ã¤¿¡£", m_name);
4556 msg_format("%^s rattles.", m_name);
4559 else if (percentage > 35)
4561 msg_format("%^s¤Ï¤è¤í¤á¤¤¤¿¡£", m_name);
4563 msg_format("%^s stumbles.", m_name);
4566 else if (percentage > 20)
4568 msg_format("%^s¤Ï¥«¥¿¥«¥¿¸À¤Ã¤¿¡£", m_name);
4570 msg_format("%^s rattles.", m_name);
4573 else if (percentage > 10)
4575 msg_format("%^s¤Ï¤è¤í¤á¤¤¤¿¡£", m_name);
4577 msg_format("%^s staggers.", m_name);
4582 msg_format("%^s¤Ï¥¬¥¿¥¬¥¿¸À¤Ã¤¿¡£", m_name);
4584 msg_format("%^s clatters.", m_name);
4591 else if (strchr("z", r_ptr->d_char))
4593 if (percentage > 95)
4595 msg_format("%s¤Ï¹¶·â¤òµ¤¤Ë¤È¤á¤Æ¤¤¤Ê¤¤¡£", m_name);
4597 msg_format("%^s ignores the attack.", m_name);
4600 else if (percentage > 75)
4602 msg_format("%s¤Ï¹¶·â¤Ë¸ª¤ò¤¹¤¯¤á¤¿¡£", m_name);
4604 msg_format("%^s shrugs off the attack.", m_name);
4607 else if (percentage > 50)
4609 msg_format("%^s¤Ï¤¦¤á¤¤¤¿¡£", m_name);
4611 msg_format("%^s groans.", m_name);
4614 else if (percentage > 35)
4616 msg_format("%s¤Ï¶ì¤·¤²¤Ë¤¦¤á¤¤¤¿¡£", m_name);
4618 msg_format("%^s moans.", m_name);
4621 else if (percentage > 20)
4623 msg_format("%^s¤Ïí´í°¤·¤¿¡£", m_name);
4625 msg_format("%^s hesitates.", m_name);
4628 else if (percentage > 10)
4630 msg_format("%^s¤Ï¤¦¤Ê¤Ã¤¿¡£", m_name);
4632 msg_format("%^s grunts.", m_name);
4637 msg_format("%^s¤Ï¤è¤í¤á¤¤¤¿¡£", m_name);
4639 msg_format("%^s staggers.", m_name);
4646 else if (strchr("G", r_ptr->d_char))
4649 if (percentage > 95)
4651 msg_format("%s¤Ï¹¶·â¤òµ¤¤Ë¤È¤á¤Æ¤¤¤Ê¤¤¡£", m_name);
4653 msg_format("%^s ignores the attack.", m_name);
4656 else if (percentage > 75)
4658 msg_format("%s¤Ï¹¶·â¤Ë¸ª¤ò¤¹¤¯¤á¤¿¡£", m_name);
4660 msg_format("%^s shrugs off the attack.", m_name);
4663 else if (percentage > 50)
4665 msg_format("%s¤Ï¤¦¤á¤¤¤¿¡£", m_name);
4667 msg_format("%^s moans.", m_name);
4670 else if (percentage > 35)
4672 msg_format("%^s¤Ïµã¤¤ï¤á¤¤¤¿¡£", m_name);
4674 msg_format("%^s wails.", m_name);
4677 else if (percentage > 20)
4679 msg_format("%^s¤ÏËʤ¨¤¿¡£", m_name);
4681 msg_format("%^s howls.", m_name);
4684 else if (percentage > 10)
4686 msg_format("%s¤Ï¼å¡¹¤·¤¯¤¦¤á¤¤¤¿¡£", m_name);
4688 msg_format("%^s moans softly.", m_name);
4693 msg_format("%^s¤Ï¤«¤¹¤«¤Ë¤¦¤á¤¤¤¿¡£", m_name);
4695 msg_format("%^s sighs.", m_name);
4701 /* Dogs and Hounds */
4702 else if (strchr("CZ", r_ptr->d_char))
4705 if (percentage > 95)
4706 msg_format("%^s¤Ï¹¶·â¤Ë¸ª¤ò¤¹¤¯¤á¤¿¡£", m_name);
4707 else if (percentage > 75)
4708 msg_format("%^s¤ÏÄˤߤǤ¦¤Ê¤Ã¤¿¡£", m_name);
4709 else if (percentage > 50)
4710 msg_format("%^s¤ÏÄˤߤǥ¥ã¥ó¥¥ã¥óËʤ¨¤¿¡£", m_name);
4711 else if (percentage > 35)
4712 msg_format("%^s¤ÏÄˤߤÇÌĤ¤ï¤á¤¤¤¿¡£", m_name);
4713 else if (percentage > 20)
4714 msg_format("%^s¤Ï¶ìÄˤΤ¢¤Þ¤êÌĤ¤ï¤á¤¤¤¿¡£", m_name);
4715 else if (percentage > 10)
4716 msg_format("%^s¤Ï¶ìÄˤǤâ¤À¤¨¶ì¤·¤ó¤À¡£", m_name);
4718 msg_format("%^s¤Ï¼å¡¹¤·¤¯Ëʤ¨¤¿¡£", m_name);
4720 if (percentage > 95)
4721 msg_format("%^s shrugs off the attack.", m_name);
4722 else if (percentage > 75)
4723 msg_format("%^s snarls with pain.", m_name);
4724 else if (percentage > 50)
4725 msg_format("%^s yelps in pain.", m_name);
4726 else if (percentage > 35)
4727 msg_format("%^s howls in pain.", m_name);
4728 else if (percentage > 20)
4729 msg_format("%^s howls in agony.", m_name);
4730 else if (percentage > 10)
4731 msg_format("%^s writhes in agony.", m_name);
4733 msg_format("%^s yelps feebly.", m_name);
4738 /* One type of monsters (ignore,squeal,shriek) */
4739 else if (strchr("Xbilqrt", r_ptr->d_char))
4742 if (percentage > 95)
4743 msg_format("%^s¤Ï¹¶·â¤òµ¤¤Ë¤È¤á¤Æ¤¤¤Ê¤¤¡£", m_name);
4744 else if (percentage > 75)
4745 msg_format("%^s¤ÏÄˤߤǤ¦¤Ê¤Ã¤¿¡£", m_name);
4746 else if (percentage > 50)
4747 msg_format("%^s¤ÏÄˤߤǶ«¤ó¤À¡£", m_name);
4748 else if (percentage > 35)
4749 msg_format("%^s¤ÏÄˤߤÇÀ䶫¤·¤¿¡£", m_name);
4750 else if (percentage > 20)
4751 msg_format("%^s¤Ï¶ìÄˤΤ¢¤Þ¤êÀ䶫¤·¤¿¡£", m_name);
4752 else if (percentage > 10)
4753 msg_format("%^s¤Ï¶ìÄˤǤâ¤À¤¨¶ì¤·¤ó¤À¡£", m_name);
4755 msg_format("%^s¤Ï¼å¡¹¤·¤¯¶«¤ó¤À¡£", m_name);
4757 if (percentage > 95)
4758 msg_format("%^s ignores the attack.", m_name);
4759 else if (percentage > 75)
4760 msg_format("%^s grunts with pain.", m_name);
4761 else if (percentage > 50)
4762 msg_format("%^s squeals in pain.", m_name);
4763 else if (percentage > 35)
4764 msg_format("%^s shrieks in pain.", m_name);
4765 else if (percentage > 20)
4766 msg_format("%^s shrieks in agony.", m_name);
4767 else if (percentage > 10)
4768 msg_format("%^s writhes in agony.", m_name);
4770 msg_format("%^s cries out feebly.", m_name);
4775 /* Another type of monsters (shrug,cry,scream) */
4779 if (percentage > 95)
4780 msg_format("%^s¤Ï¹¶·â¤Ë¸ª¤ò¤¹¤¯¤á¤¿¡£", m_name);
4781 else if (percentage > 75)
4782 msg_format("%^s¤ÏÄˤߤǤ¦¤Ê¤Ã¤¿¡£", m_name);
4783 else if (percentage > 50)
4784 msg_format("%^s¤ÏÄˤߤǶ«¤ó¤À¡£", m_name);
4785 else if (percentage > 35)
4786 msg_format("%^s¤ÏÄˤߤÇÀ䶫¤·¤¿¡£", m_name);
4787 else if (percentage > 20)
4788 msg_format("%^s¤Ï¶ìÄˤΤ¢¤Þ¤êÀ䶫¤·¤¿¡£", m_name);
4789 else if (percentage > 10)
4790 msg_format("%^s¤Ï¶ìÄˤǤâ¤À¤¨¶ì¤·¤ó¤À¡£", m_name);
4792 msg_format("%^s¤Ï¼å¡¹¤·¤¯¶«¤ó¤À¡£", m_name);
4794 if (percentage > 95)
4795 msg_format("%^s shrugs off the attack.", m_name);
4796 else if (percentage > 75)
4797 msg_format("%^s grunts with pain.", m_name);
4798 else if (percentage > 50)
4799 msg_format("%^s cries out in pain.", m_name);
4800 else if (percentage > 35)
4801 msg_format("%^s screams in pain.", m_name);
4802 else if (percentage > 20)
4803 msg_format("%^s screams in agony.", m_name);
4804 else if (percentage > 10)
4805 msg_format("%^s writhes in agony.", m_name);
4807 msg_format("%^s cries out feebly.", m_name);
4815 * Learn about an "observed" resistance.
4817 void update_smart_learn(int m_idx, int what)
4819 #ifdef DRS_SMART_OPTIONS
4821 monster_type *m_ptr = &m_list[m_idx];
4823 monster_race *r_ptr = &r_info[m_ptr->r_idx];
4826 /* Not allowed to learn */
4827 if (!smart_learn) return;
4829 /* Too stupid to learn anything */
4830 if (r_ptr->flags2 & (RF2_STUPID)) return;
4832 /* Not intelligent, only learn sometimes */
4833 if (!(r_ptr->flags2 & (RF2_SMART)) && (randint0(100) < 50)) return;
4838 /* Analyze the knowledge */
4842 if (p_ptr->resist_acid) m_ptr->smart |= (SM_RES_ACID);
4843 if (p_ptr->oppose_acid) m_ptr->smart |= (SM_OPP_ACID);
4844 if (p_ptr->immune_acid) m_ptr->smart |= (SM_IMM_ACID);
4848 if (p_ptr->resist_elec) m_ptr->smart |= (SM_RES_ELEC);
4849 if (p_ptr->oppose_elec) m_ptr->smart |= (SM_OPP_ELEC);
4850 if (p_ptr->immune_elec) m_ptr->smart |= (SM_IMM_ELEC);
4854 if (p_ptr->resist_fire) m_ptr->smart |= (SM_RES_FIRE);
4855 if (p_ptr->oppose_fire) m_ptr->smart |= (SM_OPP_FIRE);
4856 if (p_ptr->immune_fire) m_ptr->smart |= (SM_IMM_FIRE);
4860 if (p_ptr->resist_cold) m_ptr->smart |= (SM_RES_COLD);
4861 if (p_ptr->oppose_cold) m_ptr->smart |= (SM_OPP_COLD);
4862 if (p_ptr->immune_cold) m_ptr->smart |= (SM_IMM_COLD);
4866 if (p_ptr->resist_pois) m_ptr->smart |= (SM_RES_POIS);
4867 if (p_ptr->oppose_pois) m_ptr->smart |= (SM_OPP_POIS);
4872 if (p_ptr->resist_neth) m_ptr->smart |= (SM_RES_NETH);
4876 if (p_ptr->resist_lite) m_ptr->smart |= (SM_RES_LITE);
4880 if (p_ptr->resist_dark) m_ptr->smart |= (SM_RES_DARK);
4884 if (p_ptr->resist_fear) m_ptr->smart |= (SM_RES_FEAR);
4888 if (p_ptr->resist_conf) m_ptr->smart |= (SM_RES_CONF);
4892 if (p_ptr->resist_chaos) m_ptr->smart |= (SM_RES_CHAOS);
4896 if (p_ptr->resist_disen) m_ptr->smart |= (SM_RES_DISEN);
4900 if (p_ptr->resist_blind) m_ptr->smart |= (SM_RES_BLIND);
4904 if (p_ptr->resist_nexus) m_ptr->smart |= (SM_RES_NEXUS);
4908 if (p_ptr->resist_sound) m_ptr->smart |= (SM_RES_SOUND);
4912 if (p_ptr->resist_shard) m_ptr->smart |= (SM_RES_SHARD);
4916 if (p_ptr->free_act) m_ptr->smart |= (SM_IMM_FREE);
4920 if (!p_ptr->msp) m_ptr->smart |= (SM_IMM_MANA);
4924 if (p_ptr->reflect) m_ptr-> smart |= (SM_IMM_REFLECT);
4928 #endif /* DRS_SMART_OPTIONS */
4934 * Place the player in the dungeon XXX XXX
4936 bool player_place(int y, int x)
4938 /* Paranoia XXX XXX */
4939 if (cave[y][x].m_idx != 0) return FALSE;
4941 /* Save player location */
4951 * Drop all items carried by a monster
4953 void monster_drop_carried_objects(monster_type *m_ptr)
4955 s16b this_o_idx, next_o_idx = 0;
4961 /* Drop objects being carried */
4962 for (this_o_idx = m_ptr->hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
4964 /* Acquire object */
4965 o_ptr = &o_list[this_o_idx];
4967 /* Acquire next object */
4968 next_o_idx = o_ptr->next_o_idx;
4971 o_ptr->held_m_idx = 0;
4973 /* Get local object */
4976 /* Copy the object */
4977 object_copy(q_ptr, o_ptr);
4979 /* Delete the object */
4980 delete_object_idx(this_o_idx);
4983 (void)drop_near(q_ptr, -1, m_ptr->fy, m_ptr->fx);
4986 /* Forget objects */
4987 m_ptr->hold_o_idx = 0;