3 /* Purpose: misc code for monsters */
6 * Copyright (c) 1989 James E. Wilson, Robert A. Koeneke
8 * This software may be copied and distributed for educational, research, and
9 * not for profit purposes provided that this copyright and statement are
10 * included in all such copies.
15 #define HORDE_NOGOOD 0x01
16 #define HORDE_NOEVIL 0x02
21 cptr horror_desc[MAX_SAN_HORROR] =
75 cptr funny_desc[MAX_SAN_FUNNY] =
90 "¥Õ¥¡¥ó¥¿¥¹¥Æ¥£¥Ã¥¯¤Ê",
135 cptr funny_comments[MAX_SAN_COMMENT] =
156 * Set the target of counter attack
158 void set_target(monster_type *m_ptr, int y, int x)
165 * Reset the target of counter attack
167 void reset_target(monster_type *m_ptr)
169 set_target(m_ptr, 0, 0);
173 * Delete a monster by index.
175 * When a monster is deleted, all of its objects are deleted.
177 void delete_monster_idx(int i)
181 monster_type *m_ptr = &m_list[i];
183 monster_race *r_ptr = &r_info[m_ptr->r_idx];
185 s16b this_o_idx, next_o_idx = 0;
193 /* Hack -- Reduce the racial counter */
194 if (m_ptr->mflag2 & MFLAG_CHAMELEON)
196 if (r_ptr->flags1 & RF1_UNIQUE)
197 r_info[MON_CHAMELEON_K].cur_num--;
199 r_info[MON_CHAMELEON].cur_num--;
206 /* Hack -- count the number of "reproducers" */
207 if (r_ptr->flags2 & (RF2_MULTIPLY)) num_repro--;
210 /* Hack -- remove target monster */
211 if (i == target_who) target_who = 0;
213 /* Hack -- remove tracked monster */
214 if (i == p_ptr->health_who) health_track(0);
216 if (pet_t_m_idx == i ) pet_t_m_idx = 0;
217 if (riding_t_m_idx == i) riding_t_m_idx = 0;
218 if (p_ptr->riding == i) p_ptr->riding = 0;
220 /* Monster is gone */
221 cave[y][x].m_idx = 0;
225 for (this_o_idx = m_ptr->hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
230 o_ptr = &o_list[this_o_idx];
232 /* Acquire next object */
233 next_o_idx = o_ptr->next_o_idx;
235 /* Hack -- efficiency */
236 o_ptr->held_m_idx = 0;
238 /* Delete the object */
239 delete_object_idx(this_o_idx);
243 /* Wipe the Monster */
244 (void)WIPE(m_ptr, monster_type);
255 * Delete the monster, if any, at a given location
257 void delete_monster(int y, int x)
262 if (!in_bounds(y, x)) return;
267 /* Delete the monster (if any) */
268 if (c_ptr->m_idx) delete_monster_idx(c_ptr->m_idx);
273 * Move an object from index i1 to index i2 in the object list
275 static void compact_monsters_aux(int i1, int i2)
283 s16b this_o_idx, next_o_idx = 0;
287 if (i1 == i2) return;
300 /* Update the cave */
303 /* Repair objects being carried by monster */
304 for (this_o_idx = m_ptr->hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
309 o_ptr = &o_list[this_o_idx];
311 /* Acquire next object */
312 next_o_idx = o_ptr->next_o_idx;
314 /* Reset monster pointer */
315 o_ptr->held_m_idx = i2;
318 /* Hack -- Update the target */
319 if (target_who == i1) target_who = i2;
321 /* Hack -- Update the target */
322 if (pet_t_m_idx == i1) pet_t_m_idx = i2;
323 if (riding_t_m_idx == i1) riding_t_m_idx = i2;
325 /* Hack -- Update the riding */
326 if (p_ptr->riding == i1) p_ptr->riding = i2;
328 /* Hack -- Update the health bar */
329 if (p_ptr->health_who == i1) health_track(i2);
332 COPY(&m_list[i2], &m_list[i1], monster_type);
335 (void)WIPE(&m_list[i1], monster_type);
341 * Compact and Reorder the monster list
343 * This function can be very dangerous, use with caution!
345 * When actually "compacting" monsters, we base the saving throw
346 * on a combination of monster level, distance from player, and
347 * current "desperation".
349 * After "compacting" (if needed), we "reorder" the monsters into a more
350 * compact order, and we reset the allocation info, and the "live" array.
352 void compact_monsters(int size)
355 int cur_lev, cur_dis, chance;
357 /* Message (only if compacting) */
359 if (size) msg_print("¥â¥ó¥¹¥¿¡¼¾ðÊó¤ò°µ½Ì¤·¤Æ¤¤¤Þ¤¹...");
361 if (size) msg_print("Compacting monsters...");
365 /* Compact at least 'size' objects */
366 for (num = 0, cnt = 1; num < size; cnt++)
368 /* Get more vicious each iteration */
371 /* Get closer each iteration */
372 cur_dis = 5 * (20 - cnt);
374 /* Check all the monsters */
375 for (i = 1; i < m_max; i++)
377 monster_type *m_ptr = &m_list[i];
379 monster_race *r_ptr = &r_info[m_ptr->r_idx];
381 /* Paranoia -- skip "dead" monsters */
382 if (!m_ptr->r_idx) continue;
384 /* Hack -- High level monsters start out "immune" */
385 if (r_ptr->level > cur_lev) continue;
387 if (i == p_ptr->riding) continue;
389 /* Ignore nearby monsters */
390 if ((cur_dis > 0) && (m_ptr->cdis < cur_dis)) continue;
392 /* Saving throw chance */
395 /* Only compact "Quest" Monsters in emergencies */
396 if ((r_ptr->flags1 & (RF1_QUESTOR)) && (cnt < 1000)) chance = 100;
398 /* Try not to compact Unique Monsters */
399 if (r_ptr->flags1 & (RF1_UNIQUE)) chance = 100;
401 /* All monsters get a saving throw */
402 if (randint0(100) < chance) continue;
404 /* Delete the monster */
405 delete_monster_idx(i);
407 /* Count the monster */
413 /* Excise dead monsters (backwards!) */
414 for (i = m_max - 1; i >= 1; i--)
416 /* Get the i'th monster */
417 monster_type *m_ptr = &m_list[i];
419 /* Skip real monsters */
420 if (m_ptr->r_idx) continue;
422 /* Move last monster into open hole */
423 compact_monsters_aux(m_max - 1, i);
425 /* Compress "m_max" */
432 * Delete/Remove all the monsters when the player leaves the level
434 * This is an efficient method of simulating multiple calls to the
435 * "delete_monster()" function, with no visual effects.
437 void wipe_m_list(void)
441 /* Hack -- if Banor or Lupart dies, stay another dead */
442 if (!r_info[MON_BANORLUPART].max_num)
444 if (r_info[MON_BANOR].max_num)
446 r_info[MON_BANOR].max_num = 0;
447 r_info[MON_BANOR].r_pkills++;
448 if (r_info[MON_BANOR].r_tkills < MAX_SHORT) r_info[MON_BANOR].r_tkills++;
450 if (r_info[MON_LUPART].max_num)
452 r_info[MON_LUPART].max_num = 0;
453 r_info[MON_LUPART].r_pkills++;
454 if (r_info[MON_LUPART].r_tkills < MAX_SHORT) r_info[MON_LUPART].r_tkills++;
458 /* Delete all the monsters */
459 for (i = m_max - 1; i >= 1; i--)
461 monster_type *m_ptr = &m_list[i];
463 monster_race *r_ptr = &r_info[m_ptr->r_idx];
465 /* Skip dead monsters */
466 if (!m_ptr->r_idx) continue;
468 /* Mega-Hack -- preserve Unique's XXX XXX XXX */
470 /* Hack -- Reduce the racial counter */
471 if (m_ptr->mflag2 & MFLAG_CHAMELEON)
473 if (r_ptr->flags1 & RF1_UNIQUE)
474 r_info[MON_CHAMELEON_K].cur_num = 0;
476 r_info[MON_CHAMELEON].cur_num = 0;
481 /* Monster is gone */
482 cave[m_ptr->fy][m_ptr->fx].m_idx = 0;
484 /* Wipe the Monster */
485 (void)WIPE(m_ptr, monster_type);
495 /* Hack -- reset "reproducer" count */
498 /* Hack -- no more target */
503 /* Hack -- no more tracking */
509 * Acquires and returns the index of a "free" monster.
511 * This routine should almost never fail, but it *can* happen.
518 /* Normal allocation */
519 if (m_max < max_m_idx)
521 /* Access the next hole */
524 /* Expand the array */
530 /* Return the index */
535 /* Recycle dead monsters */
536 for (i = 1; i < m_max; i++)
540 /* Acquire monster */
543 /* Skip live monsters */
544 if (m_ptr->r_idx) continue;
549 /* Use this monster */
554 /* Warn the player (except during dungeon creation) */
556 if (character_dungeon) msg_print("¥â¥ó¥¹¥¿¡¼¤¬Â¿¤¹¤®¤ë¡ª");
558 if (character_dungeon) msg_print("Too many monsters!");
562 /* Try not to crash */
570 * Hack -- the "type" of the current "summon specific"
572 static int summon_specific_type = 0;
576 * Hack -- the index of the summoning monster
578 static int summon_specific_who = -1;
582 * Hack -- the hostility of the summoned monster
584 static int summon_specific_hostile = TRUE;
586 static bool summon_unique_okay = FALSE;
589 static bool summon_specific_aux(int r_idx)
591 monster_race *r_ptr = &r_info[r_idx];
594 /* Check our requirements */
595 switch (summon_specific_type)
599 okay = (r_ptr->d_char == 'a');
605 okay = (r_ptr->d_char == 'S');
611 okay = ((r_ptr->d_char == 'C') || (r_ptr->d_char == 'Z'));
617 okay = (r_ptr->d_char == 'M');
623 okay = (r_ptr->d_char == 'A' && ((r_ptr->flags3 & RF3_EVIL) || (r_ptr->flags3 & RF3_GOOD)));
629 okay = (r_ptr->flags3 & RF3_DEMON);
635 okay = (r_ptr->flags3 & RF3_UNDEAD);
641 okay = (r_ptr->flags3 & RF3_DRAGON);
645 case SUMMON_HI_UNDEAD:
647 okay = ((r_ptr->d_char == 'L') ||
648 (r_ptr->d_char == 'V') ||
649 (r_ptr->d_char == 'W'));
653 case SUMMON_HI_DRAGON:
655 okay = (r_ptr->d_char == 'D');
659 case SUMMON_HI_DEMON:
661 okay = (((r_ptr->d_char == 'U') ||
662 (r_ptr->d_char == 'H') ||
663 (r_ptr->d_char == 'B')) &&
664 (r_ptr->flags3 & RF3_DEMON)) ? TRUE : FALSE;
668 case SUMMON_AMBERITES:
670 okay = (r_ptr->flags3 & (RF3_AMBERITE)) ? TRUE : FALSE;
676 okay = (r_ptr->flags1 & (RF1_UNIQUE)) ? TRUE : FALSE;
680 case SUMMON_BIZARRE1:
682 okay = (r_ptr->d_char == 'm');
685 case SUMMON_BIZARRE2:
687 okay = (r_ptr->d_char == 'b');
690 case SUMMON_BIZARRE3:
692 okay = (r_ptr->d_char == 'Q');
696 case SUMMON_BIZARRE4:
698 okay = (r_ptr->d_char == 'v');
702 case SUMMON_BIZARRE5:
704 okay = (r_ptr->d_char == '$');
708 case SUMMON_BIZARRE6:
710 okay = ((r_ptr->d_char == '!') ||
711 (r_ptr->d_char == '?') ||
712 (r_ptr->d_char == '=') ||
713 (r_ptr->d_char == '$') ||
714 (r_ptr->d_char == '|'));
720 okay = (r_ptr->d_char == 'g');
726 okay = ((r_ptr->d_char == 'U') &&
727 (r_ptr->flags4 & RF4_ROCKET));
734 okay = ((r_ptr->d_char == summon_kin_type) && (r_idx != MON_HAGURE));
740 okay = (r_idx == MON_DAWN);
746 okay = (r_ptr->flags3 & (RF3_ANIMAL));
750 case SUMMON_ANIMAL_RANGER:
752 okay = ((r_ptr->flags3 & (RF3_ANIMAL)) &&
753 (strchr("abcflqrwBCHIJKMRS", r_ptr->d_char)) &&
754 !(r_ptr->flags3 & (RF3_DRAGON)) &&
755 !(r_ptr->flags3 & (RF3_EVIL)) &&
756 !(r_ptr->flags3 & (RF3_UNDEAD)) &&
757 !(r_ptr->flags3 & (RF3_DEMON)) &&
758 !(r_ptr->flags2 & (RF2_MULTIPLY)) &&
759 !(r_ptr->flags4 || r_ptr->flags5 || r_ptr->flags6));
763 case SUMMON_HI_DRAGON_LIVING:
765 okay = ((r_ptr->d_char == 'D') &&
766 !(r_ptr->flags3 & (RF3_DEMON | RF3_UNDEAD | RF3_NONLIVING)));
772 okay = (!(r_ptr->flags3 & (RF3_DEMON | RF3_UNDEAD | RF3_NONLIVING)));
778 okay = (r_idx == MON_PHANTOM_B || r_idx == MON_PHANTOM_W);
782 case SUMMON_BLUE_HORROR:
784 okay = (r_idx == MON_BLUE_HORROR);
788 case SUMMON_ELEMENTAL:
790 okay = (r_ptr->d_char == 'E');
796 okay = (r_ptr->d_char == 'v');
802 okay = (r_ptr->d_char == 'H');
808 okay = (r_ptr->d_char == 'B');
812 case SUMMON_KAMIKAZE:
815 for (i = 0; i < 4; i++)
816 if (r_ptr->blow[i].method == RBM_EXPLODE) okay = TRUE;
820 case SUMMON_KAMIKAZE_LIVING:
824 for (i = 0; i < 4; i++)
825 if (r_ptr->blow[i].method == RBM_EXPLODE) okay = TRUE;
826 okay = (okay && (!(r_ptr->flags3 & (RF3_DEMON | RF3_UNDEAD | RF3_NONLIVING))));
832 okay = (r_idx == MON_MANES);
838 okay = (r_idx == MON_LOUSE);
842 case SUMMON_GUARDIANS:
844 okay = (r_ptr->flags7 & RF7_GUARDIAN);
850 okay = ((r_idx == MON_NOV_PALADIN) ||
851 (r_idx == MON_NOV_PALADIN_G) ||
852 (r_idx == MON_PALADIN) ||
853 (r_idx == MON_W_KNIGHT) ||
854 (r_idx == MON_ULTRA_PALADIN) ||
855 (r_idx == MON_KNI_TEMPLAR));
861 /* Since okay is int, "return (okay);" is not correct. */
862 return (bool)(okay ? TRUE : FALSE);
866 static bool chameleon_change = FALSE;
870 * Some dungeon types restrict the possible monsters.
871 * Return TRUE is the monster is OK and FALSE otherwise
873 static bool restrict_monster_to_dungeon(int r_idx)
875 dungeon_info_type *d_ptr = &d_info[dungeon_type];
876 monster_race *r_ptr = &r_info[r_idx];
879 if (d_ptr->flags1 & DF1_CHAMELEON)
881 if (chameleon_change) return TRUE;
883 if (d_ptr->flags1 & DF1_NO_MAGIC)
885 if (r_idx == MON_CHAMELEON) return TRUE;
886 if (r_ptr->freq_spell && !(r_ptr->flags4 & RF4_NOMAGIC_MASK) && !(r_ptr->flags5 & RF5_NOMAGIC_MASK) && !(r_ptr->flags6 & RF6_NOMAGIC_MASK))
890 if (d_ptr->flags1 & DF1_NO_MELEE)
892 if (r_idx == MON_CHAMELEON) return TRUE;
893 if (!(r_ptr->flags4 & (RF4_BOLT_MASK | RF4_BEAM_MASK | RF4_BALL_MASK)) &&
894 !(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)) &&
895 !(r_ptr->flags6 & (RF6_BOLT_MASK | RF6_BEAM_MASK | RF6_BALL_MASK)))
899 if (d_ptr->flags1 & DF1_BEGINNER)
901 if (r_ptr->level > dun_level)
906 if (d_ptr->special_div == 64) return TRUE;
907 if (summon_specific_type && !(d_ptr->flags1 & DF1_CHAMELEON)) return TRUE;
909 if(d_ptr->mode == DUNGEON_MODE_AND)
913 if((d_ptr->mflags1 & r_ptr->flags1) != d_ptr->mflags1)
918 if((d_ptr->mflags2 & r_ptr->flags2) != d_ptr->mflags2)
923 if((d_ptr->mflags3 & r_ptr->flags3) != d_ptr->mflags3)
928 if((d_ptr->mflags4 & r_ptr->flags4) != d_ptr->mflags4)
933 if((d_ptr->mflags5 & r_ptr->flags5) != d_ptr->mflags5)
938 if((d_ptr->mflags6 & r_ptr->flags6) != d_ptr->mflags6)
943 if((d_ptr->mflags7 & r_ptr->flags7) != d_ptr->mflags7)
948 if((d_ptr->mflags8 & r_ptr->flags8) != d_ptr->mflags8)
953 if((d_ptr->mflags9 & r_ptr->flags9) != d_ptr->mflags9)
956 for(a = 0; a < 5; a++)
957 if(d_ptr->r_char[a] && (d_ptr->r_char[a] != r_ptr->d_char)) return FALSE;
959 else if(d_ptr->mode == DUNGEON_MODE_NAND)
961 byte ok[9 + 5], i = 0, j = 0;
966 if(d_ptr->mflags1 & r_ptr->flags1)
972 if(d_ptr->mflags2 & r_ptr->flags2)
978 if(d_ptr->mflags3 & r_ptr->flags3)
984 if(d_ptr->mflags4 & r_ptr->flags4)
990 if(d_ptr->mflags5 & r_ptr->flags5)
996 if(d_ptr->mflags6 & r_ptr->flags6)
1002 if(d_ptr->mflags7 & r_ptr->flags7)
1008 if(d_ptr->mflags8 & r_ptr->flags8)
1014 if(d_ptr->mflags9 & r_ptr->flags9)
1018 for(a = 0; a < 5; a++)
1020 if(d_ptr->r_char[a])
1023 if (d_ptr->r_char[a] != r_ptr->d_char) ok[9 + a] = 1;
1027 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];
1029 if(i == j) return FALSE;
1031 else if(d_ptr->mode == DUNGEON_MODE_OR)
1036 for(i = 0; i < 32; i++)
1038 flag = d_ptr->mflags1 & (1 << i);
1039 if(r_ptr->flags1 & flag) ok = TRUE;
1041 flag = d_ptr->mflags2 & (1 << i);
1042 if(r_ptr->flags2 & flag) ok = TRUE;
1044 flag = d_ptr->mflags3 & (1 << i);
1045 if(r_ptr->flags3 & flag) ok = TRUE;
1047 flag = d_ptr->mflags4 & (1 << i);
1048 if(r_ptr->flags4 & flag) ok = TRUE;
1050 flag = d_ptr->mflags5 & (1 << i);
1051 if(r_ptr->flags5 & flag) ok = TRUE;
1053 flag = d_ptr->mflags6 & (1 << i);
1054 if(r_ptr->flags6 & flag) ok = TRUE;
1056 flag = d_ptr->mflags7 & (1 << i);
1057 if(r_ptr->flags7 & flag) ok = TRUE;
1059 flag = d_ptr->mflags8 & (1 << i);
1060 if(r_ptr->flags8 & flag) ok = TRUE;
1062 flag = d_ptr->mflags9 & (1 << i);
1063 if(r_ptr->flags9 & flag) ok = TRUE;
1065 for(a = 0; a < 5; a++)
1066 if(d_ptr->r_char[a] == r_ptr->d_char) ok = TRUE;
1070 else if(d_ptr->mode == DUNGEON_MODE_NOR)
1075 for(i = 0; i < 32; i++)
1077 flag = d_ptr->mflags1 & (1 << i);
1078 if(r_ptr->flags1 & flag) ok = FALSE;
1080 flag = d_ptr->mflags2 & (1 << i);
1081 if(r_ptr->flags2 & flag) ok = FALSE;
1083 flag = d_ptr->mflags3 & (1 << i);
1084 if(r_ptr->flags3 & flag) ok = FALSE;
1086 flag = d_ptr->mflags4 & (1 << i);
1087 if(r_ptr->flags4 & flag) ok = FALSE;
1089 flag = d_ptr->mflags5 & (1 << i);
1090 if(r_ptr->flags5 & flag) ok = FALSE;
1092 flag = d_ptr->mflags6 & (1 << i);
1093 if(r_ptr->flags6 & flag) ok = FALSE;
1095 flag = d_ptr->mflags7 & (1 << i);
1096 if(r_ptr->flags7 & flag) ok = FALSE;
1098 flag = d_ptr->mflags8 & (1 << i);
1099 if(r_ptr->flags8 & flag) ok = FALSE;
1101 flag = d_ptr->mflags9 & (1 << i);
1102 if(r_ptr->flags9 & flag) ok = FALSE;
1104 for(a = 0; a < 5; a++)
1105 if(d_ptr->r_char[a] == r_ptr->d_char) ok = FALSE;
1113 * Apply a "monster restriction function" to the "monster allocation table"
1115 errr get_mon_num_prep(monster_hook_type monster_hook,
1116 monster_hook_type monster_hook2)
1120 /* Todo: Check the hooks for non-changes */
1122 /* Set the new hooks */
1123 get_mon_num_hook = monster_hook;
1124 get_mon_num2_hook = monster_hook2;
1126 /* Scan the allocation table */
1127 for (i = 0; i < alloc_race_size; i++)
1129 monster_race *r_ptr;
1132 alloc_entry *entry = &alloc_race_table[i];
1135 r_ptr = &r_info[entry->index];
1137 /* Skip monsters which don't pass the restriction */
1138 if ((get_mon_num_hook && !((*get_mon_num_hook)(entry->index))) ||
1139 (get_mon_num2_hook && !((*get_mon_num2_hook)(entry->index))))
1142 if (!p_ptr->inside_battle && !chameleon_change &&
1143 summon_specific_type != SUMMON_GUARDIANS)
1145 /* Hack -- don't create questors */
1146 if (r_ptr->flags1 & RF1_QUESTOR)
1149 if (r_ptr->flags7 & RF7_GUARDIAN)
1152 /* Depth Monsters never appear out of depth */
1153 if ((r_ptr->flags1 & (RF1_FORCE_DEPTH)) &&
1154 (r_ptr->level > dun_level))
1158 /* Accept this monster */
1159 entry->prob2 = entry->prob1;
1161 if (dun_level && (!p_ptr->inside_quest || p_ptr->inside_quest < MIN_RANDOM_QUEST) && !restrict_monster_to_dungeon(entry->index) && !p_ptr->inside_battle)
1163 int hoge = entry->prob2 * d_info[dungeon_type].special_div;
1164 entry->prob2 = hoge / 64;
1165 if (randint0(64) < (hoge & 0x3f)) entry->prob2++;
1174 static int mysqrt(int n)
1212 * Choose a monster race that seems "appropriate" to the given level
1214 * This function uses the "prob2" field of the "monster allocation table",
1215 * and various local information, to calculate the "prob3" field of the
1216 * same table, which is then used to choose an "appropriate" monster, in
1217 * a relatively efficient manner.
1219 * Note that "town" monsters will *only* be created in the town, and
1220 * "normal" monsters will *never* be created in the town, unless the
1221 * "level" is "modified", for example, by polymorph or summoning.
1223 * There is a small chance (1/50) of "boosting" the given depth by
1224 * a small amount (up to four levels), except in the town.
1226 * It is (slightly) more likely to acquire a monster of the given level
1227 * than one of a lower level. This is done by choosing several monsters
1228 * appropriate to the given level and keeping the "hardest" one.
1230 * Note that if no monsters are "appropriate", then this function will
1231 * fail, and return zero, but this should *almost* never happen.
1233 s16b get_mon_num(int level)
1241 monster_race *r_ptr;
1243 alloc_entry *table = alloc_race_table;
1245 int pls_kakuritu, pls_level;
1246 int hoge=mysqrt(level*10000L);
1248 if (level > MAX_DEPTH - 1) level = MAX_DEPTH - 1;
1250 if ((dungeon_turn > hoge*(TURNS_PER_TICK*500L)) && !level)
1252 pls_kakuritu = MAX(2, NASTY_MON-((dungeon_turn/(TURNS_PER_TICK*2500L)-hoge/10)));
1253 pls_level = MIN(8,3 + dungeon_turn/(TURNS_PER_TICK*20000L)-hoge/40);
1257 pls_kakuritu = NASTY_MON;
1261 if (d_info[dungeon_type].flags1 & DF1_MAZE)
1263 pls_kakuritu = MIN(pls_kakuritu/2, pls_kakuritu-10);
1264 if (pls_kakuritu < 2) pls_kakuritu = 2;
1269 /* Boost the level */
1270 if ((level > 0) && !p_ptr->inside_battle && !(d_info[dungeon_type].flags1 & DF1_BEGINNER))
1272 /* Nightmare mode allows more out-of depth monsters */
1273 if (ironman_nightmare && !randint0(pls_kakuritu))
1275 /* What a bizarre calculation */
1276 level = 1 + (level * MAX_DEPTH / randint1(MAX_DEPTH));
1280 /* Occasional "nasty" monster */
1281 if (!randint0(pls_kakuritu))
1283 /* Pick a level bonus */
1284 int d = MIN(5, level/10) + pls_level;
1286 /* Boost the level */
1290 /* Occasional "nasty" monster */
1291 if (!randint0(pls_kakuritu))
1293 /* Pick a level bonus */
1294 int d = MIN(5, level/10) + pls_level;
1296 /* Boost the level */
1306 /* Process probabilities */
1307 for (i = 0; i < alloc_race_size; i++)
1309 /* Monsters are sorted by depth */
1310 if (table[i].level > level) break;
1315 /* Access the "r_idx" of the chosen monster */
1316 r_idx = table[i].index;
1318 /* Access the actual race */
1319 r_ptr = &r_info[r_idx];
1321 if (!p_ptr->inside_battle && !chameleon_change)
1323 /* Hack -- "unique" monsters must be "unique" */
1324 if (((r_ptr->flags1 & (RF1_UNIQUE)) ||
1325 (r_ptr->flags7 & (RF7_UNIQUE_7))) &&
1326 (r_ptr->cur_num >= r_ptr->max_num))
1331 if ((r_ptr->flags7 & (RF7_UNIQUE2)) &&
1332 (r_ptr->cur_num >= 1))
1337 if (r_idx == MON_BANORLUPART)
1339 if (r_info[MON_BANOR].cur_num > 0) continue;
1340 if (r_info[MON_LUPART].cur_num > 0) continue;
1345 table[i].prob3 = table[i].prob2;
1348 total += table[i].prob3;
1351 /* No legal monsters */
1352 if (total <= 0) return (0);
1355 /* Pick a monster */
1356 value = randint0(total);
1358 /* Find the monster */
1359 for (i = 0; i < alloc_race_size; i++)
1361 /* Found the entry */
1362 if (value < table[i].prob3) break;
1365 value = value - table[i].prob3;
1372 /* Try for a "harder" monster once (50%) or twice (10%) */
1378 /* Pick a monster */
1379 value = randint0(total);
1381 /* Find the monster */
1382 for (i = 0; i < alloc_race_size; i++)
1384 /* Found the entry */
1385 if (value < table[i].prob3) break;
1388 value = value - table[i].prob3;
1391 /* Keep the "best" one */
1392 if (table[i].level < table[j].level) i = j;
1395 /* Try for a "harder" monster twice (10%) */
1401 /* Pick a monster */
1402 value = randint0(total);
1404 /* Find the monster */
1405 for (i = 0; i < alloc_race_size; i++)
1407 /* Found the entry */
1408 if (value < table[i].prob3) break;
1411 value = value - table[i].prob3;
1414 /* Keep the "best" one */
1415 if (table[i].level < table[j].level) i = j;
1419 return (table[i].index);
1427 * Build a string describing a monster in some way.
1429 * We can correctly describe monsters based on their visibility.
1430 * We can force all monsters to be treated as visible or invisible.
1431 * We can build nominatives, objectives, possessives, or reflexives.
1432 * We can selectively pronominalize hidden, visible, or all monsters.
1433 * We can use definite or indefinite descriptions for hidden monsters.
1434 * We can use definite or indefinite descriptions for visible monsters.
1436 * Pronominalization involves the gender whenever possible and allowed,
1437 * so that by cleverly requesting pronominalization / visibility, you
1438 * can get messages like "You hit someone. She screams in agony!".
1440 * Reflexives are acquired by requesting Objective plus Possessive.
1442 * If no m_ptr arg is given (?), the monster is assumed to be hidden,
1443 * unless the "Assume Visible" mode is requested.
1445 * If no r_ptr arg is given, it is extracted from m_ptr and r_info
1446 * If neither m_ptr nor r_ptr is given, the monster is assumed to
1447 * be neuter, singular, and hidden (unless "Assume Visible" is set),
1448 * in which case you may be in trouble... :-)
1450 * I am assuming that no monster name is more than 70 characters long,
1451 * so that "char desc[80];" is sufficiently large for any result.
1454 * 0x01 --> Objective (or Reflexive)
1455 * 0x02 --> Possessive (or Reflexive)
1456 * 0x04 --> Use indefinites for hidden monsters ("something")
1457 * 0x08 --> Use indefinites for visible monsters ("a kobold")
1458 * 0x10 --> Pronominalize hidden monsters
1459 * 0x20 --> Pronominalize visible monsters
1460 * 0x40 --> Assume the monster is hidden
1461 * 0x80 --> Assume the monster is visible
1462 * 0x100 --> Chameleon's true name
1463 * 0x200 --> Ignore hallucination, and penetrate shape change
1466 * 0x00 --> Full nominative name ("the kobold") or "it"
1467 * 0x04 --> Full nominative name ("the kobold") or "something"
1468 * 0x80 --> Genocide resistance name ("the kobold")
1469 * 0x88 --> Killing name ("a kobold")
1470 * 0x22 --> Possessive, genderized if visable ("his") or "its"
1471 * 0x23 --> Reflexive, genderized if visable ("himself") or "itself"
1473 void monster_desc(char *desc, monster_type *m_ptr, int mode)
1476 monster_race *r_ptr;
1480 char silly_name[1024];
1484 r_ptr = &r_info[m_ptr->ap_r_idx];
1486 if ((mode & 0x100) && (m_ptr->mflag2 & MFLAG_CHAMELEON))
1488 if (r_ptr->flags1 & RF1_UNIQUE) name = (r_name + r_info[MON_CHAMELEON_K].name);
1489 else name = (r_name + r_info[MON_CHAMELEON].name);
1491 else name = (r_name + r_ptr->name);
1493 /* Are we hallucinating? (Idea from Nethack...) */
1494 if (p_ptr->image && !(mode & 0x200))
1499 if (!get_rnd_line("silly_j.txt", m_ptr->r_idx, silly_name))
1501 if (!get_rnd_line("silly.txt", m_ptr->r_idx, silly_name))
1509 monster_race *hallu_race;
1513 hallu_race = &r_info[randint1(max_r_idx - 1)];
1515 while (hallu_race->flags1 & RF1_UNIQUE);
1517 strcpy(silly_name, (r_name + hallu_race->name));
1520 /* Better not strcpy it, or we could corrupt r_info... */
1524 /* Can we "see" it (exists + forced, or visible + not unforced) */
1525 seen = (m_ptr && ((mode & 0x80) || (!(mode & 0x40) && m_ptr->ml)));
1527 /* Sexed Pronouns (seen and allowed, or unseen and allowed) */
1528 pron = (m_ptr && ((seen && (mode & 0x20)) || (!seen && (mode & 0x10))));
1531 /* First, try using pronouns, or describing hidden monsters */
1534 /* an encoding of the monster "sex" */
1537 /* Extract the gender (if applicable) */
1538 if (r_ptr->flags1 & (RF1_FEMALE)) kind = 0x20;
1539 else if (r_ptr->flags1 & (RF1_MALE)) kind = 0x10;
1541 /* Ignore the gender (if desired) */
1542 if (!m_ptr || !pron) kind = 0x00;
1545 /* Assume simple result */
1553 /* Brute force: split on the possibilities */
1554 switch (kind + (mode & 0x07))
1556 /* Neuter, or unknown */
1558 case 0x00: res = "²¿¤«"; break;
1559 case 0x01: res = "²¿¤«"; break;
1560 case 0x02: res = "²¿¤«¤Î"; break;
1561 case 0x03: res = "²¿¤«¼«¿È"; break;
1562 case 0x04: res = "²¿¤«"; break;
1563 case 0x05: res = "²¿¤«"; break;
1564 case 0x06: res = "²¿¤«"; break;
1565 case 0x07: res = "¤½¤ì¼«¿È"; break;
1567 case 0x00: res = "it"; break;
1568 case 0x01: res = "it"; break;
1569 case 0x02: res = "its"; break;
1570 case 0x03: res = "itself"; break;
1571 case 0x04: res = "something"; break;
1572 case 0x05: res = "something"; break;
1573 case 0x06: res = "something's"; break;
1574 case 0x07: res = "itself"; break;
1578 /* Male (assume human if vague) */
1580 case 0x10: res = "Èà"; break;
1581 case 0x11: res = "Èà"; break;
1582 case 0x12: res = "Èà¤Î"; break;
1583 case 0x13: res = "È༫¿È"; break;
1584 case 0x14: res = "狼"; break;
1585 case 0x15: res = "狼"; break;
1586 case 0x16: res = "狼¤Î"; break;
1587 case 0x17: res = "È༫¿È"; break;
1589 case 0x10: res = "he"; break;
1590 case 0x11: res = "him"; break;
1591 case 0x12: res = "his"; break;
1592 case 0x13: res = "himself"; break;
1593 case 0x14: res = "someone"; break;
1594 case 0x15: res = "someone"; break;
1595 case 0x16: res = "someone's"; break;
1596 case 0x17: res = "himself"; break;
1600 /* Female (assume human if vague) */
1602 case 0x20: res = "Èà½÷"; break;
1603 case 0x21: res = "Èà½÷"; break;
1604 case 0x22: res = "Èà½÷¤Î"; break;
1605 case 0x23: res = "Èà½÷¼«¿È"; break;
1606 case 0x24: res = "狼"; break;
1607 case 0x25: res = "狼"; break;
1608 case 0x26: res = "狼¤Î"; break;
1609 case 0x27: res = "Èà½÷¼«¿È"; break;
1611 case 0x20: res = "she"; break;
1612 case 0x21: res = "her"; break;
1613 case 0x22: res = "her"; break;
1614 case 0x23: res = "herself"; break;
1615 case 0x24: res = "someone"; break;
1616 case 0x25: res = "someone"; break;
1617 case 0x26: res = "someone's"; break;
1618 case 0x27: res = "herself"; break;
1623 /* Copy the result */
1624 (void)strcpy(desc, res);
1628 /* Handle visible monsters, "reflexive" request */
1629 else if ((mode & 0x02) && (mode & 0x01))
1631 /* The monster is visible, so use its gender */
1633 if (r_ptr->flags1 & (RF1_FEMALE)) strcpy(desc, "Èà½÷¼«¿È");
1634 else if (r_ptr->flags1 & (RF1_MALE)) strcpy(desc, "È༫¿È");
1635 else strcpy(desc, "¤½¤ì¼«¿È");
1637 if (r_ptr->flags1 & RF1_FEMALE) strcpy(desc, "herself");
1638 else if (r_ptr->flags1 & RF1_MALE) strcpy(desc, "himself");
1639 else strcpy(desc, "itself");
1645 /* Handle all other visible monster requests */
1649 if (is_pet(m_ptr) && m_ptr->ap_r_idx != m_ptr->r_idx)
1655 while(strncmp(t, "¡Ù", 2) && *t) t++;
1659 (void)sprintf(desc, "%s¡©¡Ù", buf);
1662 (void)sprintf(desc, "%s¡©", name);
1664 (void)sprintf(desc, "%s?", name);
1669 /* It could be a Unique */
1670 if ((r_ptr->flags1 & RF1_UNIQUE) && !(p_ptr->image && !(mode & 0x200)))
1672 /* Start with the name (thus nominative and objective) */
1673 if ((m_ptr->mflag2 & MFLAG_CHAMELEON) && !(mode & 0x100))
1679 while(strncmp(t, "¡Ù", 2) && *t) t++;
1683 (void)sprintf(desc, "%s¡©¡Ù", buf);
1686 (void)sprintf(desc, "%s¡©", name);
1688 (void)sprintf(desc, "%s?", name);
1691 else if ((cave[m_ptr->fy][m_ptr->fx].m_idx == p_ptr->riding) || !p_ptr->inside_battle)
1692 (void)strcpy(desc, name);
1695 (void)sprintf(desc, "%s¤â¤É¤", name);
1697 (void)sprintf(desc, "fake %s", name);
1701 /* It could be an indefinite monster */
1702 else if (mode & 0x08)
1704 /* XXX Check plurality for "some" */
1706 /* Indefinite monsters need an indefinite article */
1708 (void)strcpy(desc, "");
1710 (void)strcpy(desc, is_a_vowel(name[0]) ? "an " : "a ");
1713 (void)strcat(desc, name);
1716 /* It could be a normal, definite, monster */
1719 /* Definite monsters need a definite article */
1722 (void)strcpy(desc, "¤¢¤Ê¤¿¤Î");
1724 (void)strcpy(desc, "your ");
1729 (void)strcpy(desc, "");
1731 (void)strcpy(desc, "the ");
1734 (void)strcat(desc, name);
1737 if (m_ptr->nickname)
1740 sprintf(buf,"¡Ö%s¡×",quark_str(m_ptr->nickname));
1742 sprintf(buf," called %s",quark_str(m_ptr->nickname));
1747 if ((m_ptr->fy == py) && (m_ptr->fx == px))
1750 strcat(desc,"(¾èÇÏÃæ)");
1752 strcat(desc,"(riding)");
1756 if ((mode & 0x200) && (m_ptr->mflag2 & MFLAG_CHAMELEON))
1758 if (r_ptr->flags1 & RF1_UNIQUE)
1761 strcat(desc,"(¥«¥á¥ì¥ª¥ó¤Î²¦)");
1763 strcat(desc,"(Chameleon Lord)");
1769 strcat(desc,"(¥«¥á¥ì¥ª¥ó)");
1771 strcat(desc,"(Chameleon)");
1776 if ((mode & 0x200) && m_ptr->ap_r_idx != m_ptr->r_idx)
1778 strcat(desc, format("(%s)", r_name + r_info[m_ptr->r_idx].name));
1781 /* Handle the Possessive as a special afterthought */
1784 /* XXX Check for trailing "s" */
1786 /* Simply append "apostrophe" and "s" */
1788 (void)strcat(desc, "¤Î");
1790 (void)strcat(desc, "'s");
1801 * Learn about a monster (by "probing" it)
1803 void lore_do_probe(int m_idx)
1805 monster_type *m_ptr = &m_list[m_idx];
1807 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1809 /* Hack -- Memorize some flags */
1810 r_ptr->r_flags1 = r_ptr->flags1;
1811 r_ptr->r_flags2 = r_ptr->flags2;
1812 r_ptr->r_flags3 = r_ptr->flags3;
1814 /* Update monster recall window */
1815 if (p_ptr->monster_race_idx == m_ptr->r_idx)
1818 p_ptr->window |= (PW_MONSTER);
1824 * Take note that the given monster just dropped some treasure
1826 * Note that learning the "GOOD"/"GREAT" flags gives information
1827 * about the treasure (even when the monster is killed for the first
1828 * time, such as uniques, and the treasure has not been examined yet).
1830 * This "indirect" method is used to prevent the player from learning
1831 * exactly how much treasure a monster can drop from observing only
1832 * a single example of a drop. This method actually observes how much
1833 * gold and items are dropped, and remembers that information to be
1834 * described later by the monster recall code.
1836 void lore_treasure(int m_idx, int num_item, int num_gold)
1838 monster_type *m_ptr = &m_list[m_idx];
1840 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1842 /* Note the number of things dropped */
1843 if (num_item > r_ptr->r_drop_item) r_ptr->r_drop_item = num_item;
1844 if (num_gold > r_ptr->r_drop_gold) r_ptr->r_drop_gold = num_gold;
1846 /* Hack -- memorize the good/great flags */
1847 if (r_ptr->flags1 & (RF1_DROP_GOOD)) r_ptr->r_flags1 |= (RF1_DROP_GOOD);
1848 if (r_ptr->flags1 & (RF1_DROP_GREAT)) r_ptr->r_flags1 |= (RF1_DROP_GREAT);
1850 /* Update monster recall window */
1851 if (p_ptr->monster_race_idx == m_ptr->r_idx)
1854 p_ptr->window |= (PW_MONSTER);
1860 void sanity_blast(monster_type *m_ptr, bool necro)
1862 bool happened = FALSE;
1865 if (p_ptr->inside_battle || !character_dungeon) return;
1870 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1872 power = r_ptr->level / 2;
1874 monster_desc(m_name, m_ptr, 0);
1876 if (!(r_ptr->flags1 & RF1_UNIQUE))
1878 if (r_ptr->flags1 & RF1_FRIENDS)
1884 return; /* No effect yet, just loaded... */
1887 return; /* Cannot see it for some reason */
1889 if (!(r_ptr->flags2 & RF2_ELDRITCH_HORROR))
1895 return; /* Pet eldritch horrors are safe most of the time */
1897 if (randint1(100) > power) return;
1899 if (saving_throw(p_ptr->skill_sav - power))
1901 return; /* Save, no adverse effects */
1906 /* Something silly happens... */
1908 msg_format("%s%s¤Î´é¤ò¸«¤Æ¤·¤Þ¤Ã¤¿¡ª",
1910 msg_format("You behold the %s visage of %s!",
1913 funny_desc[randint0(MAX_SAN_FUNNY)], m_name);
1917 msg_print(funny_comments[randint0(MAX_SAN_COMMENT)]);
1918 p_ptr->image = p_ptr->image + randint1(r_ptr->level);
1921 return; /* Never mind; we can't see it clearly enough */
1924 /* Something frightening happens... */
1926 msg_format("%s%s¤Î´é¤ò¸«¤Æ¤·¤Þ¤Ã¤¿¡ª",
1928 msg_format("You behold the %s visage of %s!",
1931 horror_desc[randint0(MAX_SAN_HORROR)], m_name);
1933 r_ptr->r_flags2 |= RF2_ELDRITCH_HORROR;
1935 /* Demon characters are unaffected */
1936 if ((p_ptr->prace == RACE_IMP) || (p_ptr->prace == RACE_DEMON) || (mimic_info[p_ptr->mimic_form].MIMIC_FLAGS & MIMIC_IS_DEMON)) return;
1939 /* Undead characters are 50% likely to be unaffected */
1940 if ((p_ptr->prace == RACE_SKELETON) || (p_ptr->prace == RACE_ZOMBIE)
1941 || (p_ptr->prace == RACE_VAMPIRE) || (p_ptr->prace == RACE_SPECTRE) ||
1942 (mimic_info[p_ptr->mimic_form].MIMIC_FLAGS & MIMIC_IS_UNDEAD))
1944 if (saving_throw(25 + p_ptr->lev)) return;
1950 msg_print("¥Í¥¯¥í¥Î¥ß¥³¥ó¤òÆɤó¤ÇÀµµ¤¤ò¼º¤Ã¤¿¡ª");
1952 msg_print("Your sanity is shaken by reading the Necronomicon!");
1957 if (!saving_throw(p_ptr->skill_sav - power)) /* Mind blast */
1959 if (!p_ptr->resist_conf)
1961 (void)set_confused(p_ptr->confused + randint0(4) + 4);
1963 if (!p_ptr->resist_chaos && one_in_(3))
1965 (void)set_image(p_ptr->image + randint0(250) + 150);
1970 if (!saving_throw(p_ptr->skill_sav - power)) /* Lose int & wis */
1977 if (!saving_throw(p_ptr->skill_sav - power)) /* Brain smash */
1979 if (!p_ptr->resist_conf)
1981 (void)set_confused(p_ptr->confused + randint0(4) + 4);
1983 if (!p_ptr->free_act)
1985 (void)set_paralyzed(p_ptr->paralyzed + randint0(4) + 4);
1987 while (randint0(100) > p_ptr->skill_sav)
1988 (void)do_dec_stat(A_INT);
1989 while (randint0(100) > p_ptr->skill_sav)
1990 (void)do_dec_stat(A_WIS);
1991 if (!p_ptr->resist_chaos)
1993 (void)set_image(p_ptr->image + randint0(250) + 150);
1998 if (!saving_throw(p_ptr->skill_sav - power)) /* Amnesia */
2001 if (lose_all_info())
2003 msg_print("¤¢¤Þ¤ê¤Î¶²ÉݤËÁ´¤Æ¤Î¤³¤È¤ò˺¤ì¤Æ¤·¤Þ¤Ã¤¿¡ª");
2005 msg_print("You forget everything in your utmost terror!");
2011 if (saving_throw(p_ptr->skill_sav - power))
2016 /* Else gain permanent insanity */
2017 if ((p_ptr->muta3 & MUT3_MORONIC) && /*(p_ptr->muta2 & MUT2_BERS_RAGE) &&*/
2018 ((p_ptr->muta2 & MUT2_COWARDICE) || (p_ptr->resist_fear)) &&
2019 ((p_ptr->muta2 & MUT2_HALLU) || (p_ptr->resist_chaos)))
2021 /* The poor bastard already has all possible insanities! */
2027 switch (randint1(21))
2030 if (!(p_ptr->muta3 & MUT3_MORONIC) && one_in_(5))
2032 if ((p_ptr->stat_use[A_INT] < 4) && (p_ptr->stat_use[A_WIS] < 4))
2035 msg_print("¤¢¤Ê¤¿¤Ï´°àú¤ÊÇϼ¯¤Ë¤Ê¤Ã¤¿¤è¤¦¤Êµ¤¤¬¤·¤¿¡£¤·¤«¤·¤½¤ì¤Ï¸µ¡¹¤À¤Ã¤¿¡£");
2037 msg_print("You turn into an utter moron!");
2043 msg_print("¤¢¤Ê¤¿¤Ï´°àú¤ÊÇϼ¯¤Ë¤Ê¤Ã¤¿¡ª");
2045 msg_print("You turn into an utter moron!");
2049 if (p_ptr->muta3 & MUT3_HYPER_INT)
2052 msg_print("¤¢¤Ê¤¿¤ÎǾ¤ÏÀ¸ÂÎ¥³¥ó¥Ô¥å¡¼¥¿¤Ç¤Ï¤Ê¤¯¤Ê¤Ã¤¿¡£");
2054 msg_print("Your brain is no longer a living computer.");
2057 p_ptr->muta3 &= ~(MUT3_HYPER_INT);
2059 p_ptr->muta3 |= MUT3_MORONIC;
2073 if (!(p_ptr->muta2 & MUT2_COWARDICE) && !p_ptr->resist_fear)
2076 msg_print("¤¢¤Ê¤¿¤Ï¥Ñ¥é¥Î¥¤¥¢¤Ë¤Ê¤Ã¤¿¡ª");
2078 msg_print("You become paranoid!");
2082 /* Duh, the following should never happen, but anyway... */
2083 if (p_ptr->muta3 & MUT3_FEARLESS)
2086 msg_print("¤¢¤Ê¤¿¤Ï¤â¤¦¶²¤ìÃΤ餺¤Ç¤Ï¤Ê¤¯¤Ê¤Ã¤¿¡£");
2088 msg_print("You are no longer fearless.");
2091 p_ptr->muta3 &= ~(MUT3_FEARLESS);
2094 p_ptr->muta2 |= MUT2_COWARDICE;
2108 if (!(p_ptr->muta2 & MUT2_HALLU) && !p_ptr->resist_chaos)
2111 msg_print("¸¸³Ð¤ò¤Ò¤µ¯¤³¤¹Àº¿ÀºøÍð¤Ë´Ù¤Ã¤¿¡ª");
2113 msg_print("You are afflicted by a hallucinatory insanity!");
2116 p_ptr->muta2 |= MUT2_HALLU;
2121 if (!(p_ptr->muta2 & MUT2_BERS_RAGE))
2124 msg_print("·ãÎõ¤Ê´¶¾ð¤Îȯºî¤Ë¤ª¤½¤ï¤ì¤ë¤è¤¦¤Ë¤Ê¤Ã¤¿¡ª");
2126 msg_print("You become subject to fits of berserk rage!");
2129 p_ptr->muta2 |= MUT2_BERS_RAGE;
2136 p_ptr->update |= PU_BONUS;
2142 * This function updates the monster record of the given monster
2144 * This involves extracting the distance to the player (if requested),
2145 * and then checking for visibility (natural, infravision, see-invis,
2146 * telepathy), updating the monster visibility flag, redrawing (or
2147 * erasing) the monster when its visibility changes, and taking note
2148 * of any interesting monster flags (cold-blooded, invisible, etc).
2150 * Note the new "mflag" field which encodes several monster state flags,
2151 * including "view" for when the monster is currently in line of sight,
2152 * and "mark" for when the monster is currently visible via detection.
2154 * The only monster fields that are changed here are "cdis" (the
2155 * distance from the player), "ml" (visible to the player), and
2156 * "mflag" (to maintain the "MFLAG_VIEW" flag).
2158 * Note the special "update_monsters()" function which can be used to
2159 * call this function once for every monster.
2161 * Note the "full" flag which requests that the "cdis" field be updated,
2162 * this is only needed when the monster (or the player) has moved.
2164 * Every time a monster moves, we must call this function for that
2165 * monster, and update the distance, and the visibility. Every time
2166 * the player moves, we must call this function for every monster, and
2167 * update the distance, and the visibility. Whenever the player "state"
2168 * changes in certain ways ("blindness", "infravision", "telepathy",
2169 * and "see invisible"), we must call this function for every monster,
2170 * and update the visibility.
2172 * Routines that change the "illumination" of a grid must also call this
2173 * function for any monster in that grid, since the "visibility" of some
2174 * monsters may be based on the illumination of their grid.
2176 * Note that this function is called once per monster every time the
2177 * player moves. When the player is running, this function is one
2178 * of the primary bottlenecks, along with "update_view()" and the
2179 * "process_monsters()" code, so efficiency is important.
2181 * Note the optimized "inline" version of the "distance()" function.
2183 * A monster is "visible" to the player if (1) it has been detected
2184 * by the player, (2) it is close to the player and the player has
2185 * telepathy, or (3) it is close to the player, and in line of sight
2186 * of the player, and it is "illuminated" by some combination of
2187 * infravision, torch light, or permanent light (invisible monsters
2188 * are only affected by "light" if the player can see invisible).
2190 * Monsters which are not on the current panel may be "visible" to
2191 * the player, and their descriptions will include an "offscreen"
2192 * reference. Currently, offscreen monsters cannot be targetted
2193 * or viewed directly, but old targets will remain set. XXX XXX
2195 * The player can choose to be disturbed by several things, including
2196 * "disturb_move" (monster which is viewable moves in some way), and
2197 * "disturb_near" (monster which is "easily" viewable moves in some
2198 * way). Note that "moves" includes "appears" and "disappears".
2200 void update_mon(int m_idx, bool full)
2202 monster_type *m_ptr = &m_list[m_idx];
2204 monster_race *r_ptr = &r_info[m_ptr->r_idx];
2208 /* Current location */
2215 /* Seen by vision */
2219 /* Compute distance */
2222 /* Distance components */
2223 int dy = (py > fy) ? (py - fy) : (fy - py);
2224 int dx = (px > fx) ? (px - fx) : (fx - px);
2226 /* Approximate distance */
2227 d = (dy > dx) ? (dy + (dx>>1)) : (dx + (dy>>1));
2229 /* Restrict distance */
2230 if (d > 255) d = 255;
2234 /* Save the distance */
2238 /* Extract distance */
2241 /* Extract the distance */
2247 if (m_ptr->mflag & (MFLAG_MARK)) flag = TRUE;
2251 if (d <= ((d_info[dungeon_type].flags1 & DF1_DARKNESS) ? MAX_SIGHT / 2 : MAX_SIGHT))
2253 if (!(d_info[dungeon_type].flags1 & DF1_DARKNESS) || (d <= MAX_SIGHT / 4))
2255 if (p_ptr->special_defense & KATA_MUSOU)
2260 /* Hack -- Memorize mental flags */
2261 if (r_ptr->flags2 & (RF2_SMART)) r_ptr->r_flags2 |= (RF2_SMART);
2262 if (r_ptr->flags2 & (RF2_STUPID)) r_ptr->r_flags2 |= (RF2_STUPID);
2265 /* Basic telepathy */
2266 else if (p_ptr->telepathy)
2268 /* Empty mind, no telepathy */
2269 if (r_ptr->flags2 & (RF2_EMPTY_MIND))
2271 /* Memorize flags */
2272 r_ptr->r_flags2 |= (RF2_EMPTY_MIND);
2275 /* Weird mind, occasional telepathy */
2276 else if (r_ptr->flags2 & (RF2_WEIRD_MIND))
2278 /* One in ten individuals are detectable */
2279 if ((m_idx % 10) == 5)
2284 /* Memorize flags */
2285 r_ptr->r_flags2 |= (RF2_WEIRD_MIND);
2287 /* Hack -- Memorize mental flags */
2288 if (r_ptr->flags2 & (RF2_SMART)) r_ptr->r_flags2 |= (RF2_SMART);
2289 if (r_ptr->flags2 & (RF2_STUPID)) r_ptr->r_flags2 |= (RF2_STUPID);
2293 /* Normal mind, allow telepathy */
2299 /* Hack -- Memorize mental flags */
2300 if (r_ptr->flags2 & (RF2_SMART)) r_ptr->r_flags2 |= (RF2_SMART);
2301 if (r_ptr->flags2 & (RF2_STUPID)) r_ptr->r_flags2 |= (RF2_STUPID);
2306 /* Normal line of sight, and not blind */
2307 if (player_has_los_bold(fy, fx) && !p_ptr->blind)
2309 bool do_invisible = FALSE;
2310 bool do_cold_blood = FALSE;
2312 /* Use "infravision" */
2313 if (d <= p_ptr->see_infra)
2315 /* Handle "cold blooded" monsters */
2316 if (r_ptr->flags2 & (RF2_COLD_BLOOD))
2319 do_cold_blood = TRUE;
2322 /* Handle "warm blooded" monsters */
2330 /* Use "illumination" */
2331 if (player_can_see_bold(fy, fx))
2333 /* Handle "invisible" monsters */
2334 if (r_ptr->flags2 & (RF2_INVISIBLE))
2337 do_invisible = TRUE;
2347 /* Handle "normal" monsters */
2358 /* Memorize flags */
2359 if (do_invisible) r_ptr->r_flags2 |= (RF2_INVISIBLE);
2360 if (do_cold_blood) r_ptr->r_flags2 |= (RF2_COLD_BLOOD);
2366 /* The monster is now visible */
2369 /* It was previously unseen */
2372 /* Mark as visible */
2375 /* Draw the monster */
2378 /* Update health bar as needed */
2379 if (p_ptr->health_who == m_idx) p_ptr->redraw |= (PR_HEALTH);
2380 if (p_ptr->riding == m_idx) p_ptr->redraw |= (PR_UHEALTH);
2382 /* Hack -- Count "fresh" sightings */
2383 if ((m_ptr->ap_r_idx == MON_KAGE) && (r_info[MON_KAGE].r_sights < MAX_SHORT))
2384 r_info[MON_KAGE].r_sights++;
2385 else if (m_ptr->ap_r_idx == m_ptr->r_idx &&
2386 r_ptr->r_sights < MAX_SHORT) r_ptr->r_sights++;
2388 /* Eldritch Horror */
2389 if (r_ptr->flags2 & RF2_ELDRITCH_HORROR)
2391 sanity_blast(m_ptr, FALSE);
2394 /* Disturb on appearance */
2395 if (disturb_near && (projectable(m_ptr->fy, m_ptr->fx, py, px) && projectable(py, px, m_ptr->fy, m_ptr->fx)))
2397 if (disturb_pets || is_hostile(m_ptr))
2403 /* The monster is not visible */
2406 /* It was previously seen */
2409 /* Mark as not visible */
2412 /* Erase the monster */
2415 /* Update health bar as needed */
2416 if (p_ptr->health_who == m_idx) p_ptr->redraw |= (PR_HEALTH);
2417 if (p_ptr->riding == m_idx) p_ptr->redraw |= (PR_UHEALTH);
2419 /* Disturb on disappearance */
2422 if (disturb_pets || is_hostile(m_ptr))
2429 /* The monster is now easily visible */
2433 if (!(m_ptr->mflag & (MFLAG_VIEW)))
2435 /* Mark as easily visible */
2436 m_ptr->mflag |= (MFLAG_VIEW);
2438 /* Disturb on appearance */
2441 if (disturb_pets || is_hostile(m_ptr))
2447 /* The monster is not easily visible */
2451 if (m_ptr->mflag & (MFLAG_VIEW))
2453 /* Mark as not easily visible */
2454 m_ptr->mflag &= ~(MFLAG_VIEW);
2456 /* Disturb on disappearance */
2459 if (disturb_pets || is_hostile(m_ptr))
2468 * This function simply updates all the (non-dead) monsters (see above).
2470 void update_monsters(bool full)
2474 /* Update each (live) monster */
2475 for (i = 1; i < m_max; i++)
2477 monster_type *m_ptr = &m_list[i];
2479 /* Skip dead monsters */
2480 if (!m_ptr->r_idx) continue;
2482 /* Update the monster */
2483 update_mon(i, full);
2489 * Hack -- the index of the summoning monster
2491 static int summon_specific_who_for_chameleons = 0;
2493 static bool monster_hook_chameleon_lord(int r_idx)
2495 monster_race *r_ptr = &r_info[r_idx];
2497 if (!(r_ptr->flags1 & (RF1_UNIQUE))) return FALSE;
2498 if (r_ptr->flags7 & (RF7_FRIENDLY | RF7_CHAMELEON)) return FALSE;
2500 if (ABS(r_ptr->level - r_info[MON_CHAMELEON_K].level) > 5) return FALSE;
2502 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))
2508 static bool monster_hook_chameleon(int r_idx)
2510 monster_race *r_ptr = &r_info[r_idx];
2512 if (r_ptr->flags1 & (RF1_UNIQUE)) return FALSE;
2513 if (r_ptr->flags2 & RF2_MULTIPLY) return FALSE;
2514 if (r_ptr->flags7 & (RF7_FRIENDLY | RF7_CHAMELEON)) return FALSE;
2516 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))
2519 return (*(get_monster_hook()))(r_idx);
2523 void choose_new_monster(int m_idx, bool born, int r_idx)
2527 monster_type *m_ptr = &m_list[m_idx];
2528 monster_race *r_ptr;
2529 char old_m_name[80];
2530 int old_r_idx = m_ptr->r_idx;
2531 bool old_unique = FALSE;
2533 if (r_info[m_ptr->r_idx].flags1 & RF1_UNIQUE)
2535 if (old_unique && (r_idx == MON_CHAMELEON)) r_idx = MON_CHAMELEON_K;
2536 r_ptr = &r_info[r_idx];
2538 monster_desc(old_m_name, m_ptr, 0);
2542 chameleon_change = TRUE;
2544 get_mon_num_prep(monster_hook_chameleon_lord, NULL);
2546 get_mon_num_prep(monster_hook_chameleon, NULL);
2553 level = r_info[MON_CHAMELEON_K].level;
2554 else if (!dun_level)
2555 level = wilderness[p_ptr->wilderness_y][p_ptr->wilderness_x].level;
2559 if (d_info[dungeon_type].flags1 & DF1_CHAMELEON) level+= 2+randint1(3);
2560 r_idx = get_mon_num(level);
2561 r_ptr = &r_info[r_idx];
2563 if (!monster_can_cross_terrain(cave[m_ptr->fy][m_ptr->fx].feat, r_ptr)) continue;
2568 if ((r_info[old_r_idx].flags3 & RF3_GOOD) && !(r_ptr->flags3 & RF3_GOOD)) continue;
2569 if ((r_info[old_r_idx].flags3 & RF3_EVIL) && !(r_ptr->flags3 & RF3_EVIL)) continue;
2570 if (!(r_info[old_r_idx].flags3 & (RF3_GOOD | RF3_EVIL)) && (r_ptr->flags3 & (RF3_GOOD | RF3_EVIL))) continue;
2574 if ((m_ptr->sub_align & SUB_ALIGN_EVIL) && (r_ptr->flags3 & RF3_GOOD)) continue;
2575 if ((m_ptr->sub_align & SUB_ALIGN_GOOD) && (r_ptr->flags3 & RF3_EVIL)) continue;
2578 else if (summon_specific_who_for_chameleons > 0)
2580 monster_type *sm_ptr = &m_list[summon_specific_who_for_chameleons];
2582 if ((sm_ptr->sub_align & SUB_ALIGN_EVIL) && (r_ptr->flags3 & RF3_GOOD)) continue;
2583 if ((sm_ptr->sub_align & SUB_ALIGN_GOOD) && (r_ptr->flags3 & RF3_EVIL)) continue;
2587 chameleon_change = FALSE;
2588 if (!attempt) return;
2591 m_ptr->r_idx = r_idx;
2592 m_ptr->ap_r_idx = r_idx;
2593 update_mon(m_idx, FALSE);
2594 lite_spot(m_ptr->fy, m_ptr->fx);
2597 /* Sub-alignment of a chameleon */
2598 if (r_ptr->flags3 & (RF3_EVIL | RF3_GOOD))
2600 m_ptr->sub_align = SUB_ALIGN_NEUTRAL;
2601 if (r_ptr->flags3 & RF3_EVIL) m_ptr->sub_align |= SUB_ALIGN_EVIL;
2602 if (r_ptr->flags3 & RF3_GOOD) m_ptr->sub_align |= SUB_ALIGN_GOOD;
2607 if (m_idx == p_ptr->riding)
2610 monster_desc(m_name, m_ptr, 0);
2612 msg_format("ÆÍÁ³%s¤¬ÊѿȤ·¤¿¡£", old_m_name);
2614 msg_format("Suddenly, %s transforms!", old_m_name);
2616 if (!(r_ptr->flags7 & RF7_RIDING))
2618 if (rakuba(0, TRUE)) msg_print("ÃÏÌ̤ËÍî¤È¤µ¤ì¤¿¡£");
2620 if (rakuba(0, TRUE)) msg_format("You have fallen from %s.", m_name);
2624 /* Extract the monster base speed */
2625 m_ptr->mspeed = r_ptr->speed;
2626 /* Hack -- small racial variety */
2627 /* Allow some small variation per monster */
2629 i = extract_energy[r_ptr->speed] / 3;
2630 if (i) m_ptr->mspeed += rand_spread(0, i);
2633 i = extract_energy[r_ptr->speed] / 10;
2634 if (i) m_ptr->mspeed += rand_spread(0, i);
2637 oldmaxhp = m_ptr->max_maxhp;
2638 /* Assign maximal hitpoints */
2639 if (r_ptr->flags1 & RF1_FORCE_MAXHP)
2641 m_ptr->max_maxhp = maxroll(r_ptr->hdice, r_ptr->hside);
2645 m_ptr->max_maxhp = damroll(r_ptr->hdice, r_ptr->hside);
2647 m_ptr->maxhp = (long)(m_ptr->maxhp * m_ptr->max_maxhp) / oldmaxhp;
2648 m_ptr->hp = (long)(m_ptr->hp * m_ptr->max_maxhp) / oldmaxhp;
2652 * Set initial racial appearance of a monster
2654 static int initial_r_appearance(int r_idx)
2657 int min = MIN(base_level-5, 50);
2659 if (!(r_info[r_idx].flags7 & RF7_TANUKI))
2662 get_mon_num_prep(monster_hook_chameleon, NULL);
2666 ap_r_idx = get_mon_num(base_level + 10);
2667 if (r_info[ap_r_idx].flags7 & RF7_AQUATIC) continue;
2668 if (r_info[ap_r_idx].level >= min) break;
2675 * Attempt to place a monster of the given race at the given location.
2677 * To give the player a sporting chance, any monster that appears in
2678 * line-of-sight and is extremely dangerous can be marked as
2679 * "FORCE_SLEEP", which will cause them to be placed with low energy,
2680 * which often (but not always) lets the player move before they do.
2682 * This routine refuses to place out-of-depth "FORCE_DEPTH" monsters.
2684 * XXX XXX XXX Use special "here" and "dead" flags for unique monsters,
2685 * remove old "cur_num" and "max_num" fields.
2687 * XXX XXX XXX Actually, do something similar for artifacts, to simplify
2688 * the "preserve" mode, and to make the "what artifacts" flag more useful.
2690 * This is the only function which may place a monster in the dungeon,
2691 * except for the savefile loading code.
2693 bool place_monster_one(int who, int y, int x, int r_idx, bool slp, bool friendly, bool pet, bool no_pet)
2700 monster_type *m_ptr;
2702 monster_race *r_ptr = &r_info[r_idx];
2704 cptr name = (r_name + r_ptr->name);
2706 /* DO NOT PLACE A MONSTER IN THE SMALL SCALE WILDERNESS !!! */
2707 if(p_ptr->wild_mode) return FALSE;
2709 /* Verify location */
2710 if (!in_bounds(y, x)) return (FALSE);
2712 /* Require empty space (if not ghostly) */
2713 if (!(!dun_level && (cave[y][x].feat == FEAT_MOUNTAIN) && ((r_ptr->flags8 & RF8_WILD_MOUNTAIN) || (r_ptr->flags7 & RF7_CAN_FLY))) &&
2714 !cave_empty_bold2(y, x) &&
2715 !((r_ptr->flags2 & RF2_PASS_WALL) &&
2716 !(cave_perma_bold(y, x) || cave[y][x].m_idx ||
2717 ((y == py) && (x == px))))) return (FALSE);
2720 if (!r_idx) return (FALSE);
2723 if (!r_ptr->name) return (FALSE);
2726 /* Hack -- no creation on glyph of warding */
2727 if (cave[y][x].feat == FEAT_GLYPH) return (FALSE);
2728 if (cave[y][x].feat == FEAT_MINOR_GLYPH) return (FALSE);
2731 /* Nor on the Pattern */
2732 if ((cave[y][x].feat >= FEAT_PATTERN_START)
2733 && (cave[y][x].feat <= FEAT_PATTERN_XTRA2))
2736 if (monster_terrain_sensitive &&
2737 !monster_can_cross_terrain(cave[y][x].feat, r_ptr))
2742 if (!p_ptr->inside_battle)
2744 /* Hack -- "unique" monsters must be "unique" */
2745 if (((r_ptr->flags1 & (RF1_UNIQUE)) ||
2746 (r_ptr->flags7 & (RF7_UNIQUE_7))) &&
2747 (r_ptr->cur_num >= r_ptr->max_num))
2753 if ((r_ptr->flags7 & (RF7_UNIQUE2)) &&
2754 (r_ptr->cur_num >= 1))
2759 if (r_idx == MON_BANORLUPART)
2761 if (r_info[MON_BANOR].cur_num > 0) return FALSE;
2762 if (r_info[MON_LUPART].cur_num > 0) return FALSE;
2765 /* Depth monsters may NOT be created out of depth, unless in Nightmare mode */
2766 if ((r_ptr->flags1 & (RF1_FORCE_DEPTH)) && (dun_level < r_ptr->level) &&
2767 (!ironman_nightmare || (r_ptr->flags1 & (RF1_QUESTOR))))
2774 if(quest_number(dun_level))
2776 int hoge = quest_number(dun_level);
2777 if((quest[hoge].type == QUEST_TYPE_KILL_LEVEL) || (quest[hoge].type == QUEST_TYPE_RANDOM))
2779 if(r_idx == quest[hoge].r_idx)
2781 int number_mon, i2, j2;
2784 /* Count all quest monsters */
2785 for (i2 = 0; i2 < cur_wid; ++i2)
2786 for (j2 = 0; j2 < cur_hgt; j2++)
2787 if (cave[j2][i2].m_idx > 0)
2788 if (m_list[cave[j2][i2].m_idx].r_idx == quest[hoge].r_idx)
2790 if(number_mon + quest[hoge].cur_num >= quest[hoge].max_num)
2796 /* Access the location */
2797 c_ptr = &cave[y][x];
2799 if (c_ptr->feat == FEAT_GLYPH)
2801 if (randint1(BREAK_GLYPH) < (r_ptr->level+20))
2803 /* Describe observable breakage */
2804 if (c_ptr->info & CAVE_MARK)
2807 msg_print("¼é¤ê¤Î¥ë¡¼¥ó¤¬²õ¤ì¤¿¡ª");
2809 msg_print("The rune of protection is broken!");
2814 /* Forget the rune */
2815 c_ptr->info &= ~(CAVE_MARK);
2817 /* Break the rune */
2818 c_ptr->feat = floor_type[randint0(100)];
2827 /* Powerful monster */
2828 if (r_ptr->level > dun_level)
2830 /* Unique monsters */
2831 if (r_ptr->flags1 & (RF1_UNIQUE))
2833 /* Message for cheaters */
2835 if (cheat_hear) msg_format("¿¼ÁؤΥæ¥Ë¡¼¥¯¡¦¥â¥ó¥¹¥¿¡¼ (%s)¡£", name);
2837 if (cheat_hear) msg_format("Deep Unique (%s).", name);
2841 /* Boost rating by twice delta-depth */
2842 rating += (r_ptr->level - dun_level) * 2;
2845 /* Normal monsters */
2848 /* Message for cheaters */
2850 if (cheat_hear) msg_format("¿¼ÁؤΥâ¥ó¥¹¥¿¡¼ (%s)¡£", name);
2852 if (cheat_hear) msg_format("Deep Monster (%s).", name);
2856 /* Boost rating by delta-depth */
2857 rating += (r_ptr->level - dun_level);
2861 /* Note the monster */
2862 else if (r_ptr->flags1 & (RF1_UNIQUE))
2864 /* Unique monsters induce message */
2866 if (cheat_hear) msg_format("¥æ¥Ë¡¼¥¯¡¦¥â¥ó¥¹¥¿¡¼ (%s)¡£", name);
2868 if (cheat_hear) msg_format("Unique (%s).", name);
2873 if ((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags7 & RF7_UNIQUE_7) || (r_ptr->level < 10)) is_kage = FALSE;
2875 /* Make a new monster */
2876 c_ptr->m_idx = m_pop();
2877 hack_m_idx_ii = c_ptr->m_idx;
2879 /* Mega-Hack -- catch "failure" */
2880 if (!c_ptr->m_idx) return (FALSE);
2883 /* Get a new monster record */
2884 m_ptr = &m_list[c_ptr->m_idx];
2887 m_ptr->r_idx = r_idx;
2888 m_ptr->ap_r_idx = initial_r_appearance(r_idx);
2890 /* Sub-alignment of a monster */
2891 if ((who > 0) && !(r_ptr->flags3 & (RF3_EVIL | RF3_GOOD)))
2892 m_ptr->sub_align = m_list[who].sub_align;
2895 m_ptr->sub_align = SUB_ALIGN_NEUTRAL;
2896 if (r_ptr->flags3 & RF3_EVIL) m_ptr->sub_align |= SUB_ALIGN_EVIL;
2897 if (r_ptr->flags3 & RF3_GOOD) m_ptr->sub_align |= SUB_ALIGN_GOOD;
2900 /* Place the monster at the location */
2905 /* No "damage" yet */
2907 m_ptr->confused = 0;
2910 /* Unknown distance */
2913 reset_target(m_ptr);
2915 m_ptr->nickname = 0;
2923 if (r_ptr->flags7 & RF7_CHAMELEON)
2925 if (who > 0) summon_specific_who_for_chameleons = who;
2926 else summon_specific_who_for_chameleons = 0;
2928 choose_new_monster(c_ptr->m_idx, TRUE, 0);
2929 r_ptr = &r_info[m_ptr->r_idx];
2930 m_ptr->mflag2 |= MFLAG_CHAMELEON;
2933 /* Hack - Set sub_align to neutral when the Chameleon Lord is generated as "GUARDIAN" */
2934 if ((r_ptr->flags1 & RF1_UNIQUE) && (who <= 0))
2935 m_ptr->sub_align = SUB_ALIGN_NEUTRAL;
2937 summon_specific_who_for_chameleons = 0;
2941 m_ptr->ap_r_idx = MON_KAGE;
2942 m_ptr->mflag2 |= MFLAG_KAGE;
2945 if (no_pet) m_ptr->mflag2 |= MFLAG_NOPET;
2956 else if ((friendly || (r_ptr->flags7 & RF7_FRIENDLY)) &&
2957 !(p_ptr->align >= 0 && (r_ptr->flags3 & RF3_EVIL)) &&
2958 !(p_ptr->align < 0 && (r_ptr->flags3 & RF3_GOOD)))
2960 set_friendly(m_ptr);
2963 /* Assume no sleeping */
2966 /* Enforce sleeping if needed */
2967 if (slp && r_ptr->sleep && !ironman_nightmare)
2969 int val = r_ptr->sleep;
2970 m_ptr->csleep = ((val * 2) + randint1(val * 10));
2973 /* Assign maximal hitpoints */
2974 if (r_ptr->flags1 & RF1_FORCE_MAXHP)
2976 m_ptr->max_maxhp = maxroll(r_ptr->hdice, r_ptr->hside);
2980 m_ptr->max_maxhp = damroll(r_ptr->hdice, r_ptr->hside);
2983 /* Monsters have double hitpoints in Nightmare mode */
2984 if (ironman_nightmare)
2986 u32b hp = m_ptr->max_maxhp * 2L;
2988 m_ptr->max_maxhp = (s16b)MIN(30000, hp);
2991 m_ptr->maxhp = m_ptr->max_maxhp;
2993 /* And start out fully healthy */
2994 if (m_ptr->r_idx == MON_WOUNDED_BEAR)
2995 m_ptr->hp = m_ptr->maxhp / 2;
2996 else m_ptr->hp = m_ptr->maxhp;
2999 /* Extract the monster base speed */
3000 m_ptr->mspeed = r_ptr->speed;
3002 /* Hack -- small racial variety */
3003 if (!(r_ptr->flags1 & RF1_UNIQUE) && !p_ptr->inside_arena)
3005 /* Allow some small variation per monster */
3007 i = extract_energy[r_ptr->speed] / 3;
3008 if (i) m_ptr->mspeed += rand_spread(0, i);
3011 i = extract_energy[r_ptr->speed] / 10;
3012 if (i) m_ptr->mspeed += rand_spread(0, i);
3016 if (summon_specific_type == SUMMON_KNIGHTS) m_ptr->fast = 100;
3018 if (m_ptr->mspeed > 199) m_ptr->mspeed = 199;
3020 /* Give a random starting energy */
3021 if (!ironman_nightmare)
3023 m_ptr->energy_need = ENERGY_NEED() - (s16b)randint0(100);
3027 /* Nightmare monsters are more prepared */
3028 m_ptr->energy_need = ENERGY_NEED() - (s16b)randint0(100) * 2;
3031 /* Force monster to wait for player, unless in Nightmare mode */
3032 if ((r_ptr->flags1 & RF1_FORCE_SLEEP) && !ironman_nightmare)
3034 /* Monster is still being nice */
3035 m_ptr->mflag |= (MFLAG_NICE);
3037 /* Must repair monsters */
3038 repair_monsters = TRUE;
3041 /* Hack -- see "process_monsters()" */
3042 if (c_ptr->m_idx < hack_m_idx)
3044 /* Monster is still being born */
3045 m_ptr->mflag |= (MFLAG_BORN);
3049 /* Update the monster */
3050 update_mon(c_ptr->m_idx, TRUE);
3053 /* Hack -- Count the monsters on the level */
3054 if (m_ptr->mflag2 & MFLAG_CHAMELEON)
3055 r_info[r_idx].cur_num++;
3060 /* Hack -- Count the number of "reproducers" */
3061 if (r_ptr->flags2 & RF2_MULTIPLY) num_repro++;
3064 /* Hack -- Notice new multi-hued monsters */
3065 if (r_ptr->flags1 & RF1_ATTR_MULTI) shimmer_monsters = TRUE;
3067 if (p_ptr->warning && character_dungeon)
3069 if (r_ptr->flags1 & RF1_UNIQUE)
3073 char o_name[MAX_NLEN];
3075 if (r_ptr->level > p_ptr->lev + 30)
3081 else if (r_ptr->level > p_ptr->lev + 15)
3087 else if (r_ptr->level > p_ptr->lev + 5)
3089 color = "¥ë¥Ó¡¼¿§¤Ë";
3093 else if (r_ptr->level > p_ptr->lev - 5)
3099 else if (r_ptr->level > p_ptr->lev - 15)
3101 color = "¥Ô¥ó¥¯¿§¤Ë";
3112 o_ptr = choose_warning_item();
3113 object_desc(o_name, o_ptr, FALSE, 0);
3115 msg_format("%s¤Ï%s¸÷¤Ã¤¿¡£",o_name, color);
3117 msg_format("%s glows %s.",o_name, color);
3122 if (c_ptr->feat == FEAT_MINOR_GLYPH)
3124 /* Break the ward */
3125 if (randint1(BREAK_MINOR_GLYPH) > r_ptr->level)
3127 /* Describe observable breakage */
3128 if (c_ptr->info & CAVE_MARK)
3131 msg_print("¥ë¡¼¥ó¤¬Çúȯ¤·¤¿¡ª");
3133 msg_print("The rune explodes!");
3136 project(0, 2, y, x, 2 * (p_ptr->lev + damroll(7, 7)), GF_MANA, (PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL | PROJECT_JUMP | PROJECT_NO_REF | PROJECT_NO_HANGEKI), -1);
3142 msg_print("Çúȯ¤Î¥ë¡¼¥ó¤Ï²ò½ü¤µ¤ì¤¿¡£");
3144 msg_print("An explosive rune was disarmed.");
3148 /* Forget the rune */
3149 c_ptr->info &= ~(CAVE_MARK);
3151 /* Break the rune */
3152 c_ptr->feat = floor_type[randint0(100)];
3163 * improved version of scatter() for place monster
3166 #define MON_SCAT_MAXD 10
3168 static bool mon_scatter(int *yp, int *xp, int y, int x, int max_dist)
3170 int place_x[MON_SCAT_MAXD];
3171 int place_y[MON_SCAT_MAXD];
3172 int num[MON_SCAT_MAXD];
3176 if (max_dist >= MON_SCAT_MAXD)
3179 for (i = 0; i < MON_SCAT_MAXD; i++)
3182 for (nx = x - max_dist; nx <= x + max_dist; nx++)
3183 for (ny = y - max_dist; ny <= y + max_dist; ny++)
3185 /* Ignore annoying locations */
3186 if (!in_bounds(ny, nx)) continue;
3188 /* Require "line of sight" */
3189 if (!los(y, x, ny, nx)) continue;
3191 /* Walls and Monsters block flow */
3192 if (!cave_empty_bold2(ny, nx)) continue;
3193 if (cave[ny][nx].m_idx) continue;
3194 if ((ny == py) && (nx == px)) continue;
3197 /* Hack -- no summon on glyph of warding */
3198 if (cave[ny][nx].feat == FEAT_GLYPH) continue;
3199 if (cave[ny][nx].feat == FEAT_MINOR_GLYPH) continue;
3202 /* ... nor on the Pattern */
3203 if ((cave[ny][nx].feat >= FEAT_PATTERN_START) &&
3204 (cave[ny][nx].feat <= FEAT_PATTERN_XTRA2))
3207 i = distance(y, x, ny, nx);
3224 while (i < MON_SCAT_MAXD && 0 == num[i])
3226 if (i >= MON_SCAT_MAXD)
3237 * Maximum size of a group of monsters
3239 #define GROUP_MAX 32
3243 * Attempt to place a "group" of monsters around the given location
3245 static bool place_monster_group(int who, int y, int x, int r_idx, bool slp, bool friendly, bool pet, bool no_pet)
3247 monster_race *r_ptr = &r_info[r_idx];
3250 int total = 0, extra = 0;
3254 byte hack_y[GROUP_MAX];
3255 byte hack_x[GROUP_MAX];
3258 /* Pick a group size */
3259 total = randint1(10);
3261 /* Hard monsters, small groups */
3262 if (r_ptr->level > dun_level)
3264 extra = r_ptr->level - dun_level;
3265 extra = 0 - randint1(extra);
3268 /* Easy monsters, large groups */
3269 else if (r_ptr->level < dun_level)
3271 extra = dun_level - r_ptr->level;
3272 extra = randint1(extra);
3275 /* Hack -- limit group reduction */
3276 if (extra > 9) extra = 9;
3278 /* Modify the group size */
3282 if (total < 1) total = 1;
3285 if (total > GROUP_MAX) total = GROUP_MAX;
3288 /* Save the rating */
3291 /* Start on the monster */
3296 /* Puddle monsters, breadth first, up to total */
3297 for (n = 0; (n < hack_n) && (hack_n < total); n++)
3299 /* Grab the location */
3303 /* Check each direction, up to total */
3304 for (i = 0; (i < 8) && (hack_n < total); i++)
3308 scatter(&my, &mx, hy, hx, 4, 0);
3310 /* Walls and Monsters block flow */
3311 if (!cave_empty_bold2(my, mx)) continue;
3313 /* Attempt to place another monster */
3314 if (place_monster_one(who, my, mx, r_idx, slp, friendly, pet, no_pet))
3316 /* Add it to the "hack" set */
3317 hack_y[hack_n] = my;
3318 hack_x[hack_n] = mx;
3324 /* Hack -- restore the rating */
3334 * Hack -- help pick an escort type
3336 static int place_monster_idx = 0;
3337 static int place_monster_m_idx = 0;
3340 * Hack -- help pick an escort type
3342 static bool place_monster_okay(int r_idx)
3344 monster_race *r_ptr = &r_info[place_monster_idx];
3345 monster_type *m_ptr = &m_list[place_monster_m_idx];
3347 monster_race *z_ptr = &r_info[r_idx];
3349 /* Hack - Escorts have to have the same dungeon flag */
3350 if (monster_dungeon(place_monster_idx) != monster_dungeon(r_idx)) return (FALSE);
3352 /* Require similar "race" */
3353 if (z_ptr->d_char != r_ptr->d_char) return (FALSE);
3355 /* Skip more advanced monsters */
3356 if (z_ptr->level > r_ptr->level) return (FALSE);
3358 /* Skip unique monsters */
3359 if (z_ptr->flags1 & RF1_UNIQUE) return (FALSE);
3361 /* Paranoia -- Skip identical monsters */
3362 if (place_monster_idx == r_idx) return (FALSE);
3364 /* Skip different alignment */
3365 if (((m_ptr->sub_align & SUB_ALIGN_EVIL) && (z_ptr->flags3 & RF3_GOOD)) ||
3366 ((m_ptr->sub_align & SUB_ALIGN_GOOD) && (z_ptr->flags3 & RF3_EVIL)))
3369 if (r_ptr->flags7 & RF7_FRIENDLY)
3371 if (((p_ptr->align < 0) && (z_ptr->flags3 & RF3_GOOD)) ||
3372 ((p_ptr->align > 0) && (z_ptr->flags3 & RF3_EVIL)))
3376 if ((r_ptr->flags7 & RF7_CHAMELEON) && !(z_ptr->flags7 & RF7_CHAMELEON))
3385 * Attempt to place a monster of the given race at the given location
3387 * Note that certain monsters are now marked as requiring "friends".
3388 * These monsters, if successfully placed, and if the "grp" parameter
3389 * is TRUE, will be surrounded by a "group" of identical monsters.
3391 * Note that certain monsters are now marked as requiring an "escort",
3392 * which is a collection of monsters with similar "race" but lower level.
3394 * Some monsters induce a fake "group" flag on their escorts.
3396 * Note the "bizarre" use of non-recursion to prevent annoying output
3397 * when running a code profiler.
3399 * Note the use of the new "monster allocation table" code to restrict
3400 * the "get_mon_num()" function to "legal" escort types.
3402 bool place_monster_aux(int who, int y, int x, int r_idx, bool slp, bool grp, bool friendly, bool pet, bool no_kage, bool no_pet)
3405 monster_race *r_ptr = &r_info[r_idx];
3407 if (one_in_(333) && !no_kage && !pet) is_kage = TRUE;
3408 else is_kage = FALSE;
3410 /* Place one monster, or fail */
3411 if (!place_monster_one(who, y, x, r_idx, slp, friendly, pet, no_pet)) return (FALSE);
3414 /* Require the "group" flag */
3415 if (!grp) return (TRUE);
3416 place_monster_m_idx = hack_m_idx_ii;
3419 /* Friends for certain monsters */
3420 if (r_ptr->flags1 & (RF1_FRIENDS))
3422 /* Attempt to place a group */
3423 (void)place_monster_group(who, y, x, r_idx, slp, friendly, pet, no_pet);
3427 /* Escorts for certain monsters */
3428 if (r_ptr->flags1 & (RF1_ESCORT))
3430 /* Set the escort index */
3431 place_monster_idx = r_idx;
3433 /* Try to place several "escorts" */
3434 for (i = 0; i < 32; i++)
3436 int nx, ny, z, d = 3;
3438 /* Pick a location */
3439 scatter(&ny, &nx, y, x, d, 0);
3441 /* Require empty grids */
3442 if (!cave_empty_bold2(ny, nx)) continue;
3444 /* Prepare allocation table */
3445 get_mon_num_prep(place_monster_okay, get_monster_hook2(ny, nx));
3447 /* Pick a random race */
3448 z = get_mon_num(r_ptr->level);
3450 /* Handle failure */
3453 /* Place a single escort */
3454 (void)place_monster_one(place_monster_m_idx, ny, nx, z, slp, friendly, pet, no_pet);
3456 /* Place a "group" of escorts if needed */
3457 if ((r_info[z].flags1 & RF1_FRIENDS) ||
3458 (r_ptr->flags1 & RF1_ESCORTS))
3460 /* Place a group of monsters */
3461 (void)place_monster_group(place_monster_m_idx, ny, nx, z, slp, friendly, pet, no_pet);
3472 * Hack -- attempt to place a monster at the given location
3474 * Attempt to find a monster appropriate to the "monster_level"
3476 bool place_monster(int y, int x, bool slp, bool grp)
3480 /* Prepare allocation table */
3481 get_mon_num_prep(get_monster_hook(), get_monster_hook2(y, x));
3483 /* Pick a monster */
3484 r_idx = get_mon_num(monster_level);
3486 /* Handle failure */
3487 if (!r_idx) return (FALSE);
3489 /* Attempt to place the monster */
3490 if (place_monster_aux(0, y, x, r_idx, slp, grp, FALSE, FALSE, FALSE, FALSE)) return (TRUE);
3497 #ifdef MONSTER_HORDES
3499 bool alloc_horde(int y, int x)
3501 monster_race *r_ptr = NULL;
3504 int attempts = 1000;
3508 /* Prepare allocation table */
3509 get_mon_num_prep(get_monster_hook(), get_monster_hook2(y, x));
3513 /* Pick a monster */
3514 r_idx = get_mon_num(monster_level);
3516 /* Handle failure */
3517 if (!r_idx) return (FALSE);
3519 r_ptr = &r_info[r_idx];
3521 if (r_ptr->flags1 & RF1_UNIQUE) continue;
3523 if (r_idx == MON_HAGURE) continue;
3526 if (attempts < 1) return FALSE;
3528 if (r_ptr->flags3 & RF3_GOOD) horde_align |= HORDE_NOEVIL;
3529 if (r_ptr->flags3 & RF3_EVIL) horde_align |= HORDE_NOGOOD;
3535 /* Attempt to place the monster */
3536 if (place_monster_aux(0, y, x, r_idx, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE)) break;
3539 if (attempts < 1) {horde_align = 0;return FALSE;}
3541 m_idx = cave[y][x].m_idx;
3543 if (m_list[m_idx].mflag2 & MFLAG_CHAMELEON) r_ptr = &r_info[m_list[m_idx].r_idx];
3544 summon_kin_type = r_ptr->d_char;
3546 for (attempts = randint1(10) + 5; attempts; attempts--)
3548 scatter(&cy, &cx, y, x, 5, 0);
3550 (void)summon_specific(m_idx, cy, cx, dun_level + 5, SUMMON_KIN, TRUE, FALSE, FALSE, FALSE, FALSE);
3560 #endif /* MONSTER_HORDES */
3565 * Attempt to allocate a random monster in the dungeon.
3567 * Place the monster at least "dis" distance from the player.
3569 * Use "slp" to choose the initial "sleep" status
3571 * Use "monster_level" for the monster level
3573 bool alloc_monster(int dis, bool slp)
3576 int attempts_left = 10000;
3577 int guardian = d_info[dungeon_type].final_guardian;
3579 /* Put an Guardian */
3580 if(guardian && d_info[dungeon_type].maxdepth == dun_level && r_info[guardian].cur_num < r_info[guardian].max_num )
3586 /* Find a good position */
3589 /* Get a random spot */
3590 oy = randint1(cur_hgt - 4) + 2;
3591 ox = randint1(cur_wid - 4) + 2;
3593 /* Is it a good spot ? */
3594 if (cave_empty_bold2(oy, ox) && monster_can_cross_terrain(cave[oy][ox].feat, &r_info[guardian]))
3596 /* Place the guardian */
3597 if (place_monster_aux(0, oy, ox, guardian, FALSE, TRUE, FALSE, FALSE, TRUE, TRUE)) break;
3605 /* Find a legal, distant, unoccupied, space */
3606 while (attempts_left--)
3608 /* Pick a location */
3609 y = randint0(cur_hgt);
3610 x = randint0(cur_wid);
3612 /* Require empty floor grid (was "naked") */
3613 if (dun_level || (wilderness[p_ptr->wilderness_y][p_ptr->wilderness_x].terrain != TERRAIN_MOUNTAIN))
3615 if (!cave_empty_bold2(y, x)) continue;
3619 if (!cave_empty_bold2(y, x) && (cave[y][x].feat != FEAT_MOUNTAIN)) continue;
3622 /* Accept far away grids */
3623 if (distance(y, x, py, px) > dis) break;
3628 if (cheat_xtra || cheat_hear)
3631 msg_print("·Ù¹ð¡ª¿·¤¿¤Ê¥â¥ó¥¹¥¿¡¼¤òÇÛÃ֤Ǥ¤Þ¤»¤ó¡£¾®¤µ¤¤³¬¤Ç¤¹¤«¡©");
3633 msg_print("Warning! Could not allocate a new monster. Small level?");
3642 #ifdef MONSTER_HORDES
3643 if (randint1(5000) <= dun_level)
3645 if (alloc_horde(y, x))
3648 if (cheat_hear) msg_print("¥â¥ó¥¹¥¿¡¼¤ÎÂç·²");
3650 if (cheat_hear) msg_print("Monster horde.");
3658 #endif /* MONSTER_HORDES */
3660 /* Attempt to place the monster, allow groups */
3661 if (place_monster(y, x, slp, TRUE)) return (TRUE);
3663 #ifdef MONSTER_HORDES
3665 #endif /* MONSTER_HORDES */
3675 * Hack -- help decide if a monster race is "okay" to summon
3677 static bool summon_specific_okay(int r_idx)
3679 monster_race *r_ptr = &r_info[r_idx];
3681 /* Hack - Only summon dungeon monsters */
3682 if (!monster_dungeon(r_idx)) return (FALSE);
3684 /* Hack -- identify the summoning monster */
3685 if (summon_specific_who > 0)
3687 monster_type *m_ptr = &m_list[summon_specific_who];
3689 /* Do not summon enemies */
3691 /* Friendly vs. opposite aligned normal or pet */
3692 if (((r_ptr->flags3 & RF3_EVIL) &&
3693 (m_ptr->sub_align & SUB_ALIGN_GOOD)) ||
3694 ((r_ptr->flags3 & RF3_GOOD) &&
3695 (m_ptr->sub_align & SUB_ALIGN_EVIL)))
3700 /* Hostile vs. non-hostile */
3701 if (is_hostile(m_ptr) != summon_specific_hostile)
3706 /* Use the player's alignment */
3707 else if (summon_specific_who < 0)
3709 /* Do not summon enemies of the pets */
3710 if ((p_ptr->align < -9) && (r_ptr->flags3 & RF3_GOOD))
3712 if (!one_in_((0-p_ptr->align)/2+1)) return FALSE;
3714 else if ((p_ptr->align > 9) && (r_ptr->flags3 & RF3_EVIL))
3716 if (!one_in_(p_ptr->align/2+1)) return FALSE;
3720 /* Hack -- no specific type specified */
3721 if (!summon_specific_type) return (TRUE);
3723 if (!summon_unique_okay && ((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags7 & RF7_UNIQUE_7))) return FALSE;
3725 if ((summon_specific_who < 0) &&
3726 ((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags7 & RF7_UNIQUE_7)) &&
3727 (((p_ptr->align > 9) && (r_ptr->flags3 & RF3_EVIL)) ||
3728 ((p_ptr->align < -9) && (r_ptr->flags3 & RF3_GOOD))))
3731 if ((horde_align & HORDE_NOGOOD) && (r_ptr->flags3 & RF3_GOOD)) return FALSE;
3732 if ((horde_align & HORDE_NOEVIL) && (r_ptr->flags3 & RF3_EVIL)) return FALSE;
3734 if ((r_ptr->flags7 & RF7_CHAMELEON) && (d_info[dungeon_type].flags1 & DF1_CHAMELEON)) return TRUE;
3736 return (summon_specific_aux(r_idx));
3741 * Place a monster (of the specified "type") near the given
3742 * location. Return TRUE if a monster was actually summoned.
3744 * We will attempt to place the monster up to 10 times before giving up.
3746 * Note: SUMMON_UNIQUE and SUMMON_AMBERITES will summon Unique's
3747 * Note: SUMMON_HI_UNDEAD and SUMMON_HI_DRAGON may summon Unique's
3748 * Note: None of the other summon codes will ever summon Unique's.
3750 * This function has been changed. We now take the "monster level"
3751 * of the summoning monster as a parameter, and use that, along with
3752 * the current dungeon level, to help determine the level of the
3753 * desired monster. Note that this is an upper bound, and also
3754 * tends to "prefer" monsters of that level. Currently, we use
3755 * the average of the dungeon and monster levels, and then add
3756 * five to allow slight increases in monster power.
3758 * Note that we use the new "monster allocation table" creation code
3759 * to restrict the "get_mon_num()" function to the set of "legal"
3760 * monsters, making this function much faster and more reliable.
3762 * Note that this function may not succeed, though this is very rare.
3764 bool summon_specific(int who, int y1, int x1, int lev, int type, bool group, bool friendly, bool pet, bool unique_okay, bool no_pet)
3768 bool no_kage = FALSE;
3770 if (p_ptr->inside_arena) return (FALSE);
3772 if (!mon_scatter(&y, &x, y1, x1, 2)) return FALSE;
3774 /* Save the summoner */
3775 summon_specific_who = who;
3777 /* Save the "summon" type */
3778 summon_specific_type = type;
3780 summon_unique_okay = unique_okay;
3782 /* Save the hostility */
3783 summon_specific_hostile = (!friendly && !pet);
3785 /* Prepare allocation table */
3786 get_mon_num_prep(summon_specific_okay, get_monster_hook2(y, x));
3788 /* Pick a monster, using the level calculation */
3789 r_idx = get_mon_num((dun_level + lev) / 2 + 5);
3791 /* Handle failure */
3794 summon_specific_type = 0;
3798 if ((type == SUMMON_BLUE_HORROR) || (type == SUMMON_DAWN)) no_kage = TRUE;
3800 /* Attempt to place the monster (awake, allow groups) */
3801 if (!place_monster_aux(who, y, x, r_idx, FALSE, group, friendly, pet, no_kage, no_pet))
3803 summon_specific_type = 0;
3807 summon_specific_type = 0;
3812 /* A "dangerous" function, creates a pet of the specified type */
3813 bool summon_named_creature (int who, int oy, int ox, int r_idx, bool slp, bool group_ok, bool friendly, bool pet)
3818 /* if (!r_idx) return; */
3820 /* Prevent illegal monsters */
3821 if (r_idx >= max_r_idx) return FALSE;
3823 if (p_ptr->inside_arena) return FALSE;
3825 if (!mon_scatter(&y, &x, oy, ox, 2)) return FALSE;
3827 /* Place it (allow groups) */
3828 return place_monster_aux(who, y, x, r_idx, slp, group_ok, friendly, pet, TRUE, FALSE);
3833 * Let the given monster attempt to reproduce.
3835 * Note that "reproduction" REQUIRES empty space.
3837 bool multiply_monster(int m_idx, bool clone, bool friendly, bool pet)
3839 monster_type *m_ptr = &m_list[m_idx];
3843 if (!mon_scatter(&y, &x, m_ptr->fy, m_ptr->fx, 1))
3846 /* Create a new monster (awake, no groups) */
3847 if (!place_monster_aux(m_idx, y, x, m_ptr->r_idx, FALSE, FALSE, friendly, pet, TRUE, (bool)(m_ptr->mflag2 & MFLAG_NOPET)))
3852 m_list[hack_m_idx_ii].smart |= SM_CLONED;
3853 m_list[hack_m_idx_ii].mflag2 |= MFLAG_NOPET;
3864 * Dump a message describing a monster's reaction to damage
3866 * Technically should attempt to treat "Beholder"'s as jelly's
3868 void message_pain(int m_idx, int dam)
3870 long oldhp, newhp, tmp;
3873 monster_type *m_ptr = &m_list[m_idx];
3874 monster_race *r_ptr = &r_info[m_ptr->r_idx];
3879 /* Get the monster name */
3880 monster_desc(m_name, m_ptr, 0);
3882 /* Notice non-damage */
3886 msg_format("%^s¤Ï¥À¥á¡¼¥¸¤ò¼õ¤±¤Æ¤¤¤Ê¤¤¡£", m_name);
3888 msg_format("%^s is unharmed.", m_name);
3894 /* Note -- subtle fix -CFT */
3895 newhp = (long)(m_ptr->hp);
3896 oldhp = newhp + (long)(dam);
3897 tmp = (newhp * 100L) / oldhp;
3898 percentage = (int)(tmp);
3901 /* Mushrooms, Eyes, Jellies, Molds, Vortices, Worms, Quylthulgs */
3902 if (strchr(",ejmvwQ", r_ptr->d_char))
3905 if (percentage > 95)
3906 msg_format("%^s¤Ï¤Û¤È¤ó¤Éµ¤¤Ë¤È¤á¤Æ¤¤¤Ê¤¤¡£", m_name);
3907 else if (percentage > 75)
3908 msg_format("%^s¤Ï¤·¤ê¹þ¤ß¤·¤¿¡£", m_name);
3909 else if (percentage > 50)
3910 msg_format("%^s¤Ï½Ì¤³¤Þ¤Ã¤¿¡£", m_name);
3911 else if (percentage > 35)
3912 msg_format("%^s¤ÏÄˤߤ˿̤¨¤¿¡£", m_name);
3913 else if (percentage > 20)
3914 msg_format("%^s¤Ï¿È¤â¤À¤¨¤·¤¿¡£", m_name);
3915 else if (percentage > 10)
3916 msg_format("%^s¤Ï¶ìÄˤǿȤâ¤À¤¨¤·¤¿¡£", m_name);
3918 msg_format("%^s¤Ï¤°¤Ë¤ã¤°¤Ë¤ã¤ÈáÛÚ»¤·¤¿¡£", m_name);
3920 if (percentage > 95)
3921 msg_format("%^s barely notices.", m_name);
3922 else if (percentage > 75)
3923 msg_format("%^s flinches.", m_name);
3924 else if (percentage > 50)
3925 msg_format("%^s squelches.", m_name);
3926 else if (percentage > 35)
3927 msg_format("%^s quivers in pain.", m_name);
3928 else if (percentage > 20)
3929 msg_format("%^s writhes about.", m_name);
3930 else if (percentage > 10)
3931 msg_format("%^s writhes in agony.", m_name);
3933 msg_format("%^s jerks limply.", m_name);
3940 else if (strchr("l", r_ptr->d_char))
3942 if (percentage > 95)
3944 msg_format("%^s¤Ï¤Û¤È¤ó¤Éµ¤¤Ë¤È¤á¤Æ¤¤¤Ê¤¤¡£", m_name);
3946 msg_format("%^s barely notices.", m_name);
3948 else if (percentage > 75)
3950 msg_format("%^s¤Ï¤·¤ê¹þ¤ß¤·¤¿¡£", m_name);
3952 msg_format("%^s flinches.", m_name);
3954 else if (percentage > 50)
3956 msg_format("%^s¤Ïí´í°¤·¤¿¡£", m_name);
3958 msg_format("%^s hesitates.", m_name);
3960 else if (percentage > 35)
3962 msg_format("%^s¤ÏÄˤߤ˿̤¨¤¿¡£", m_name);
3964 msg_format("%^s quivers in pain.", m_name);
3966 else if (percentage > 20)
3968 msg_format("%^s¤Ï¿È¤â¤À¤¨¤·¤¿¡£", m_name);
3970 msg_format("%^s writhes about.", m_name);
3972 else if (percentage > 10)
3974 msg_format("%^s¤Ï¶ìÄˤǿȤâ¤À¤¨¤·¤¿¡£", m_name);
3976 msg_format("%^s writhes in agony.", m_name);
3980 msg_format("%^s¤Ï¤°¤Ë¤ã¤°¤Ë¤ã¤ÈáÛÚ»¤·¤¿¡£", m_name);
3982 msg_format("%^s jerks limply.", m_name);
3987 /* Golems, Walls, Doors, Stairs */
3988 else if (strchr("g#+<>", r_ptr->d_char))
3990 if (percentage > 95)
3992 msg_format("%s¤Ï¹¶·â¤òµ¤¤Ë¤È¤á¤Æ¤¤¤Ê¤¤¡£", m_name);
3994 msg_format("%^s ignores the attack.", m_name);
3996 else if (percentage > 75)
3998 msg_format("%s¤Ï¹¶·â¤Ë¸ª¤ò¤¹¤¯¤á¤¿¡£", m_name);
4000 msg_format("%^s shrugs off the attack.", m_name);
4002 else if (percentage > 50)
4004 msg_format("%^s¤ÏÍëÌĤΤ褦¤ËËʤ¨¤¿¡£", m_name);
4006 msg_format("%^s roars thunderously.", m_name);
4008 else if (percentage > 35)
4010 msg_format("%^s¤Ï¶ì¤·¤²¤ËËʤ¨¤¿¡£", m_name);
4012 msg_format("%^s rumbles.", m_name);
4014 else if (percentage > 20)
4016 msg_format("%^s¤Ï¤¦¤á¤¤¤¿¡£", m_name);
4018 msg_format("%^s grunts.", m_name);
4020 else if (percentage > 10)
4022 msg_format("%^s¤Ïí´í°¤·¤¿¡£", m_name);
4024 msg_format("%^s hesitates.", m_name);
4028 msg_format("%^s¤Ï¤¯¤·¤ã¤¯¤·¤ã¤Ë¤Ê¤Ã¤¿¡£", m_name);
4030 msg_format("%^s crumples.", m_name);
4035 /* Snakes, Hydrae, Reptiles, Mimics */
4036 else if (strchr("JMR", r_ptr->d_char) || !isalpha(r_ptr->d_char))
4038 if (percentage > 95)
4040 msg_format("%^s¤Ï¤Û¤È¤ó¤Éµ¤¤Ë¤È¤á¤Æ¤¤¤Ê¤¤¡£", m_name);
4042 msg_format("%^s barely notices.", m_name);
4044 else if (percentage > 75)
4046 msg_format("%^s¤Ï¥·¡¼¥Ã¤ÈÌĤ¤¤¿¡£", m_name);
4048 msg_format("%^s hisses.", m_name);
4050 else if (percentage > 50)
4052 msg_format("%^s¤ÏÅܤäÆƬ¤ò¾å¤²¤¿¡£", m_name);
4054 msg_format("%^s rears up in anger.", m_name);
4056 else if (percentage > 35)
4058 msg_format("%^s¤ÏÌÔÁ³¤È°Ò³Å¤·¤¿¡£", m_name);
4060 msg_format("%^s hisses furiously.", m_name);
4062 else if (percentage > 20)
4064 msg_format("%^s¤Ï¿È¤â¤À¤¨¤·¤¿¡£", m_name);
4066 msg_format("%^s writhes about.", m_name);
4068 else if (percentage > 10)
4070 msg_format("%^s¤Ï¶ìÄˤǿȤâ¤À¤¨¤·¤¿¡£", m_name);
4072 msg_format("%^s writhes in agony.", m_name);
4076 msg_format("%^s¤Ï¤°¤Ë¤ã¤°¤Ë¤ã¤ÈáÛÚ»¤·¤¿¡£", m_name);
4078 msg_format("%^s jerks limply.", m_name);
4084 else if (strchr("f", r_ptr->d_char))
4086 if (percentage > 95)
4088 msg_format("%s¤Ï¹¶·â¤Ë¸ª¤ò¤¹¤¯¤á¤¿¡£", m_name);
4090 msg_format("%^s shrugs off the attack.", m_name);
4092 else if (percentage > 75)
4094 msg_format("%^s¤ÏËʤ¨¤¿¡£", m_name);
4096 msg_format("%^s roars.", m_name);
4098 else if (percentage > 50)
4100 msg_format("%^s¤ÏÅܤäÆËʤ¨¤¿¡£", m_name);
4102 msg_format("%^s growls angrily.", m_name);
4104 else if (percentage > 35)
4106 msg_format("%^s¤ÏÄˤߤǥ·¡¼¥Ã¤ÈÌĤ¤¤¿¡£", m_name);
4108 msg_format("%^s hisses with pain.", m_name);
4110 else if (percentage > 20)
4112 msg_format("%^s¤ÏÄˤߤǼ塹¤·¤¯ÌĤ¤¤¿¡£", m_name);
4114 msg_format("%^s mewls in pain.", m_name);
4116 else if (percentage > 10)
4118 msg_format("%^s¤Ï¶ìÄˤˤ¦¤á¤¤¤¿¡£", m_name);
4120 msg_format("%^s hisses in agony.", m_name);
4124 msg_format("%s¤Ï°¥¤ì¤ÊÌĤÀ¼¤ò½Ð¤·¤¿¡£", m_name);
4126 msg_format("%^s mewls pitifully.", m_name);
4131 /* Ants, Centipedes, Flies, Insects, Beetles, Spiders */
4132 else if (strchr("acFIKS", r_ptr->d_char))
4134 if (percentage > 95)
4136 msg_format("%s¤Ï¹¶·â¤òµ¤¤Ë¤È¤á¤Æ¤¤¤Ê¤¤¡£", m_name);
4138 msg_format("%^s ignores the attack.", m_name);
4140 else if (percentage > 75)
4142 msg_format("%^s¤Ï¥¡¼¥¡¼ÌĤ¤¤¿¡£", m_name);
4144 msg_format("%^s chitters.", m_name);
4147 else if (percentage > 50)
4149 msg_format("%^s¤Ï¥è¥í¥è¥íƨ¤²²ó¤Ã¤¿¡£", m_name);
4151 msg_format("%^s scuttles about.", m_name);
4154 else if (percentage > 35)
4156 msg_format("%^s¤Ï¤¦¤ë¤µ¤¯ÌĤ¤¤¿¡£", m_name);
4158 msg_format("%^s twitters.", m_name);
4161 else if (percentage > 20)
4163 msg_format("%^s¤ÏÄˤߤËáÛÚ»¤·¤¿¡£", m_name);
4165 msg_format("%^s jerks in pain.", m_name);
4168 else if (percentage > 10)
4170 msg_format("%^s¤Ï¶ìÄˤÇáÛÚ»¤·¤¿¡£", m_name);
4172 msg_format("%^s jerks in agony.", m_name);
4177 msg_format("%^s¤Ï¥Ô¥¯¥Ô¥¯¤Ò¤¤Ä¤Ã¤¿¡£", m_name);
4179 msg_format("%^s twitches.", m_name);
4186 else if (strchr("B", r_ptr->d_char))
4188 if (percentage > 95)
4190 msg_format("%^s¤Ï¤µ¤¨¤º¤Ã¤¿¡£", m_name);
4192 msg_format("%^s chirps.", m_name);
4195 else if (percentage > 75)
4197 msg_format("%^s¤Ï¥Ô¡¼¥Ô¡¼ÌĤ¤¤¿¡£", m_name);
4199 msg_format("%^s twitters.", m_name);
4202 else if (percentage > 50)
4204 msg_format("%^s¤Ï¥®¥ã¡¼¥®¥ã¡¼ÌĤ¤¤¿¡£", m_name);
4206 msg_format("%^s squawks.", m_name);
4209 else if (percentage > 35)
4211 msg_format("%^s¤Ï¥®¥ã¡¼¥®¥ã¡¼ÌĤ¤ï¤á¤¤¤¿¡£", m_name);
4213 msg_format("%^s chatters.", m_name);
4216 else if (percentage > 20)
4218 msg_format("%^s¤Ï¶ì¤·¤ó¤À¡£", m_name);
4220 msg_format("%^s jeers.", m_name);
4223 else if (percentage > 10)
4225 msg_format("%^s¤Ï¤Î¤¿¤¦¤Á²ó¤Ã¤¿¡£", m_name);
4227 msg_format("%^s flutters about.", m_name);
4232 msg_format("%^s¤Ï¥¡¼¥¡¼¤ÈÌĤ¶«¤ó¤À¡£", m_name);
4234 msg_format("%^s squeaks.", m_name);
4240 /* Dragons, Demons, High Undead */
4241 else if (strchr("duDLUW", r_ptr->d_char))
4243 if (percentage > 95)
4245 msg_format("%s¤Ï¹¶·â¤òµ¤¤Ë¤È¤á¤Æ¤¤¤Ê¤¤¡£", m_name);
4247 msg_format("%^s ignores the attack.", m_name);
4250 else if (percentage > 75)
4252 msg_format("%^s¤Ï¤·¤ê¹þ¤ß¤·¤¿¡£", m_name);
4254 msg_format("%^s flinches.", m_name);
4257 else if (percentage > 50)
4259 msg_format("%^s¤ÏÄˤߤǥ·¡¼¥Ã¤ÈÌĤ¤¤¿¡£", m_name);
4261 msg_format("%^s hisses in pain.", m_name);
4264 else if (percentage > 35)
4266 msg_format("%^s¤ÏÄˤߤǤ¦¤Ê¤Ã¤¿¡£", m_name);
4268 msg_format("%^s snarls with pain.", m_name);
4271 else if (percentage > 20)
4273 msg_format("%^s¤ÏÄˤߤËËʤ¨¤¿¡£", m_name);
4275 msg_format("%^s roars with pain.", m_name);
4278 else if (percentage > 10)
4280 msg_format("%^s¤Ï¶ì¤·¤²¤Ë¶«¤ó¤À¡£", m_name);
4282 msg_format("%^s gasps.", m_name);
4287 msg_format("%^s¤Ï¼å¡¹¤·¤¯¤¦¤Ê¤Ã¤¿¡£", m_name);
4289 msg_format("%^s snarls feebly.", m_name);
4296 else if (strchr("s", r_ptr->d_char))
4298 if (percentage > 95)
4300 msg_format("%s¤Ï¹¶·â¤òµ¤¤Ë¤È¤á¤Æ¤¤¤Ê¤¤¡£", m_name);
4302 msg_format("%^s ignores the attack.", m_name);
4305 else if (percentage > 75)
4307 msg_format("%s¤Ï¹¶·â¤Ë¸ª¤ò¤¹¤¯¤á¤¿¡£", m_name);
4309 msg_format("%^s shrugs off the attack.", m_name);
4312 else if (percentage > 50)
4314 msg_format("%^s¤Ï¥«¥¿¥«¥¿¤È¾Ð¤Ã¤¿¡£", m_name);
4316 msg_format("%^s rattles.", m_name);
4319 else if (percentage > 35)
4321 msg_format("%^s¤Ï¤è¤í¤á¤¤¤¿¡£", m_name);
4323 msg_format("%^s stumbles.", m_name);
4326 else if (percentage > 20)
4328 msg_format("%^s¤Ï¥«¥¿¥«¥¿¸À¤Ã¤¿¡£", m_name);
4330 msg_format("%^s rattles.", m_name);
4333 else if (percentage > 10)
4335 msg_format("%^s¤Ï¤è¤í¤á¤¤¤¿¡£", m_name);
4337 msg_format("%^s staggers.", m_name);
4342 msg_format("%^s¤Ï¥¬¥¿¥¬¥¿¸À¤Ã¤¿¡£", m_name);
4344 msg_format("%^s clatters.", m_name);
4351 else if (strchr("z", r_ptr->d_char))
4353 if (percentage > 95)
4355 msg_format("%s¤Ï¹¶·â¤òµ¤¤Ë¤È¤á¤Æ¤¤¤Ê¤¤¡£", m_name);
4357 msg_format("%^s ignores the attack.", m_name);
4360 else if (percentage > 75)
4362 msg_format("%s¤Ï¹¶·â¤Ë¸ª¤ò¤¹¤¯¤á¤¿¡£", m_name);
4364 msg_format("%^s shrugs off the attack.", m_name);
4367 else if (percentage > 50)
4369 msg_format("%^s¤Ï¤¦¤á¤¤¤¿¡£", m_name);
4371 msg_format("%^s groans.", m_name);
4374 else if (percentage > 35)
4376 msg_format("%s¤Ï¶ì¤·¤²¤Ë¤¦¤á¤¤¤¿¡£", m_name);
4378 msg_format("%^s moans.", m_name);
4381 else if (percentage > 20)
4383 msg_format("%^s¤Ïí´í°¤·¤¿¡£", m_name);
4385 msg_format("%^s hesitates.", m_name);
4388 else if (percentage > 10)
4390 msg_format("%^s¤Ï¤¦¤Ê¤Ã¤¿¡£", m_name);
4392 msg_format("%^s grunts.", m_name);
4397 msg_format("%^s¤Ï¤è¤í¤á¤¤¤¿¡£", m_name);
4399 msg_format("%^s staggers.", m_name);
4406 else if (strchr("G", r_ptr->d_char))
4409 if (percentage > 95)
4411 msg_format("%s¤Ï¹¶·â¤òµ¤¤Ë¤È¤á¤Æ¤¤¤Ê¤¤¡£", m_name);
4413 msg_format("%^s ignores the attack.", m_name);
4416 else if (percentage > 75)
4418 msg_format("%s¤Ï¹¶·â¤Ë¸ª¤ò¤¹¤¯¤á¤¿¡£", m_name);
4420 msg_format("%^s shrugs off the attack.", m_name);
4423 else if (percentage > 50)
4425 msg_format("%s¤Ï¤¦¤á¤¤¤¿¡£", m_name);
4427 msg_format("%^s moans.", m_name);
4430 else if (percentage > 35)
4432 msg_format("%^s¤Ïµã¤¤ï¤á¤¤¤¿¡£", m_name);
4434 msg_format("%^s wails.", m_name);
4437 else if (percentage > 20)
4439 msg_format("%^s¤ÏËʤ¨¤¿¡£", m_name);
4441 msg_format("%^s howls.", m_name);
4444 else if (percentage > 10)
4446 msg_format("%s¤Ï¼å¡¹¤·¤¯¤¦¤á¤¤¤¿¡£", m_name);
4448 msg_format("%^s moans softly.", m_name);
4453 msg_format("%^s¤Ï¤«¤¹¤«¤Ë¤¦¤á¤¤¤¿¡£", m_name);
4455 msg_format("%^s sighs.", m_name);
4461 /* Dogs and Hounds */
4462 else if (strchr("CZ", r_ptr->d_char))
4465 if (percentage > 95)
4466 msg_format("%^s¤Ï¹¶·â¤Ë¸ª¤ò¤¹¤¯¤á¤¿¡£", m_name);
4467 else if (percentage > 75)
4468 msg_format("%^s¤ÏÄˤߤǤ¦¤Ê¤Ã¤¿¡£", m_name);
4469 else if (percentage > 50)
4470 msg_format("%^s¤ÏÄˤߤǥ¥ã¥ó¥¥ã¥óËʤ¨¤¿¡£", m_name);
4471 else if (percentage > 35)
4472 msg_format("%^s¤ÏÄˤߤÇÌĤ¤ï¤á¤¤¤¿¡£", m_name);
4473 else if (percentage > 20)
4474 msg_format("%^s¤Ï¶ìÄˤΤ¢¤Þ¤êÌĤ¤ï¤á¤¤¤¿¡£", m_name);
4475 else if (percentage > 10)
4476 msg_format("%^s¤Ï¶ìÄˤǤâ¤À¤¨¶ì¤·¤ó¤À¡£", m_name);
4478 msg_format("%^s¤Ï¼å¡¹¤·¤¯Ëʤ¨¤¿¡£", m_name);
4480 if (percentage > 95)
4481 msg_format("%^s shrugs off the attack.", m_name);
4482 else if (percentage > 75)
4483 msg_format("%^s snarls with pain.", m_name);
4484 else if (percentage > 50)
4485 msg_format("%^s yelps in pain.", m_name);
4486 else if (percentage > 35)
4487 msg_format("%^s howls in pain.", m_name);
4488 else if (percentage > 20)
4489 msg_format("%^s howls in agony.", m_name);
4490 else if (percentage > 10)
4491 msg_format("%^s writhes in agony.", m_name);
4493 msg_format("%^s yelps feebly.", m_name);
4498 /* One type of monsters (ignore,squeal,shriek) */
4499 else if (strchr("Xbilqrt", r_ptr->d_char))
4502 if (percentage > 95)
4503 msg_format("%^s¤Ï¹¶·â¤òµ¤¤Ë¤È¤á¤Æ¤¤¤Ê¤¤¡£", m_name);
4504 else if (percentage > 75)
4505 msg_format("%^s¤ÏÄˤߤǤ¦¤Ê¤Ã¤¿¡£", m_name);
4506 else if (percentage > 50)
4507 msg_format("%^s¤ÏÄˤߤǶ«¤ó¤À¡£", m_name);
4508 else if (percentage > 35)
4509 msg_format("%^s¤ÏÄˤߤÇÀ䶫¤·¤¿¡£", m_name);
4510 else if (percentage > 20)
4511 msg_format("%^s¤Ï¶ìÄˤΤ¢¤Þ¤êÀ䶫¤·¤¿¡£", m_name);
4512 else if (percentage > 10)
4513 msg_format("%^s¤Ï¶ìÄˤǤâ¤À¤¨¶ì¤·¤ó¤À¡£", m_name);
4515 msg_format("%^s¤Ï¼å¡¹¤·¤¯¶«¤ó¤À¡£", m_name);
4517 if (percentage > 95)
4518 msg_format("%^s ignores the attack.", m_name);
4519 else if (percentage > 75)
4520 msg_format("%^s grunts with pain.", m_name);
4521 else if (percentage > 50)
4522 msg_format("%^s squeals in pain.", m_name);
4523 else if (percentage > 35)
4524 msg_format("%^s shrieks in pain.", m_name);
4525 else if (percentage > 20)
4526 msg_format("%^s shrieks in agony.", m_name);
4527 else if (percentage > 10)
4528 msg_format("%^s writhes in agony.", m_name);
4530 msg_format("%^s cries out feebly.", m_name);
4535 /* Another type of monsters (shrug,cry,scream) */
4539 if (percentage > 95)
4540 msg_format("%^s¤Ï¹¶·â¤Ë¸ª¤ò¤¹¤¯¤á¤¿¡£", m_name);
4541 else if (percentage > 75)
4542 msg_format("%^s¤ÏÄˤߤǤ¦¤Ê¤Ã¤¿¡£", m_name);
4543 else if (percentage > 50)
4544 msg_format("%^s¤ÏÄˤߤǶ«¤ó¤À¡£", m_name);
4545 else if (percentage > 35)
4546 msg_format("%^s¤ÏÄˤߤÇÀ䶫¤·¤¿¡£", m_name);
4547 else if (percentage > 20)
4548 msg_format("%^s¤Ï¶ìÄˤΤ¢¤Þ¤êÀ䶫¤·¤¿¡£", m_name);
4549 else if (percentage > 10)
4550 msg_format("%^s¤Ï¶ìÄˤǤâ¤À¤¨¶ì¤·¤ó¤À¡£", m_name);
4552 msg_format("%^s¤Ï¼å¡¹¤·¤¯¶«¤ó¤À¡£", m_name);
4554 if (percentage > 95)
4555 msg_format("%^s shrugs off the attack.", m_name);
4556 else if (percentage > 75)
4557 msg_format("%^s grunts with pain.", m_name);
4558 else if (percentage > 50)
4559 msg_format("%^s cries out in pain.", m_name);
4560 else if (percentage > 35)
4561 msg_format("%^s screams in pain.", m_name);
4562 else if (percentage > 20)
4563 msg_format("%^s screams in agony.", m_name);
4564 else if (percentage > 10)
4565 msg_format("%^s writhes in agony.", m_name);
4567 msg_format("%^s cries out feebly.", m_name);
4575 * Learn about an "observed" resistance.
4577 void update_smart_learn(int m_idx, int what)
4579 #ifdef DRS_SMART_OPTIONS
4581 monster_type *m_ptr = &m_list[m_idx];
4583 monster_race *r_ptr = &r_info[m_ptr->r_idx];
4586 /* Not allowed to learn */
4587 if (!smart_learn) return;
4589 /* Too stupid to learn anything */
4590 if (r_ptr->flags2 & (RF2_STUPID)) return;
4592 /* Not intelligent, only learn sometimes */
4593 if (!(r_ptr->flags2 & (RF2_SMART)) && (randint0(100) < 50)) return;
4598 /* Analyze the knowledge */
4602 if (p_ptr->resist_acid) m_ptr->smart |= (SM_RES_ACID);
4603 if (p_ptr->oppose_acid) m_ptr->smart |= (SM_OPP_ACID);
4604 if (p_ptr->immune_acid) m_ptr->smart |= (SM_IMM_ACID);
4608 if (p_ptr->resist_elec) m_ptr->smart |= (SM_RES_ELEC);
4609 if (p_ptr->oppose_elec) m_ptr->smart |= (SM_OPP_ELEC);
4610 if (p_ptr->immune_elec) m_ptr->smart |= (SM_IMM_ELEC);
4614 if (p_ptr->resist_fire) m_ptr->smart |= (SM_RES_FIRE);
4615 if (p_ptr->oppose_fire) m_ptr->smart |= (SM_OPP_FIRE);
4616 if (p_ptr->immune_fire) m_ptr->smart |= (SM_IMM_FIRE);
4620 if (p_ptr->resist_cold) m_ptr->smart |= (SM_RES_COLD);
4621 if (p_ptr->oppose_cold) m_ptr->smart |= (SM_OPP_COLD);
4622 if (p_ptr->immune_cold) m_ptr->smart |= (SM_IMM_COLD);
4626 if (p_ptr->resist_pois) m_ptr->smart |= (SM_RES_POIS);
4627 if (p_ptr->oppose_pois) m_ptr->smart |= (SM_OPP_POIS);
4632 if (p_ptr->resist_neth) m_ptr->smart |= (SM_RES_NETH);
4636 if (p_ptr->resist_lite) m_ptr->smart |= (SM_RES_LITE);
4640 if (p_ptr->resist_dark) m_ptr->smart |= (SM_RES_DARK);
4644 if (p_ptr->resist_fear) m_ptr->smart |= (SM_RES_FEAR);
4648 if (p_ptr->resist_conf) m_ptr->smart |= (SM_RES_CONF);
4652 if (p_ptr->resist_chaos) m_ptr->smart |= (SM_RES_CHAOS);
4656 if (p_ptr->resist_disen) m_ptr->smart |= (SM_RES_DISEN);
4660 if (p_ptr->resist_blind) m_ptr->smart |= (SM_RES_BLIND);
4664 if (p_ptr->resist_nexus) m_ptr->smart |= (SM_RES_NEXUS);
4668 if (p_ptr->resist_sound) m_ptr->smart |= (SM_RES_SOUND);
4672 if (p_ptr->resist_shard) m_ptr->smart |= (SM_RES_SHARD);
4676 if (p_ptr->free_act) m_ptr->smart |= (SM_IMM_FREE);
4680 if (!p_ptr->msp) m_ptr->smart |= (SM_IMM_MANA);
4684 if (p_ptr->reflect) m_ptr-> smart |= (SM_IMM_REFLECT);
4688 #endif /* DRS_SMART_OPTIONS */
4694 * Place the player in the dungeon XXX XXX
4696 bool player_place(int y, int x)
4698 /* Paranoia XXX XXX */
4699 if (cave[y][x].m_idx != 0) return FALSE;
4701 /* Save player location */
4711 * Drop all items carried by a monster
4713 void monster_drop_carried_objects(monster_type *m_ptr)
4715 s16b this_o_idx, next_o_idx = 0;
4721 /* Drop objects being carried */
4722 for (this_o_idx = m_ptr->hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
4724 /* Acquire object */
4725 o_ptr = &o_list[this_o_idx];
4727 /* Acquire next object */
4728 next_o_idx = o_ptr->next_o_idx;
4731 o_ptr->held_m_idx = 0;
4733 /* Get local object */
4736 /* Copy the object */
4737 object_copy(q_ptr, o_ptr);
4739 /* Delete the object */
4740 delete_object_idx(this_o_idx);
4743 (void)drop_near(q_ptr, -1, m_ptr->fy, m_ptr->fx);
4746 /* Forget objects */
4747 m_ptr->hold_o_idx = 0;