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 bool 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));
860 okay = (r_ptr->d_char == 'B' &&
861 (r_ptr->flags8 & RF8_WILD_MOUNTAIN) &&
862 (r_ptr->flags8 & RF8_WILD_ONLY));
868 /* Since okay is int, "return (okay);" is not correct. */
869 return (bool)(okay ? TRUE : FALSE);
873 static int chameleon_change_m_idx = 0;
877 * Some dungeon types restrict the possible monsters.
878 * Return TRUE is the monster is OK and FALSE otherwise
880 static bool restrict_monster_to_dungeon(int r_idx)
882 dungeon_info_type *d_ptr = &d_info[dungeon_type];
883 monster_race *r_ptr = &r_info[r_idx];
886 if (d_ptr->flags1 & DF1_CHAMELEON)
888 if (chameleon_change_m_idx) return TRUE;
890 if (d_ptr->flags1 & DF1_NO_MAGIC)
892 if (r_idx == MON_CHAMELEON) return TRUE;
893 if (r_ptr->freq_spell && !(r_ptr->flags4 & RF4_NOMAGIC_MASK) && !(r_ptr->flags5 & RF5_NOMAGIC_MASK) && !(r_ptr->flags6 & RF6_NOMAGIC_MASK))
897 if (d_ptr->flags1 & DF1_NO_MELEE)
899 if (r_idx == MON_CHAMELEON) return TRUE;
900 if (!(r_ptr->flags4 & (RF4_BOLT_MASK | RF4_BEAM_MASK | RF4_BALL_MASK)) &&
901 !(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)) &&
902 !(r_ptr->flags6 & (RF6_BOLT_MASK | RF6_BEAM_MASK | RF6_BALL_MASK)))
906 if (d_ptr->flags1 & DF1_BEGINNER)
908 if (r_ptr->level > dun_level)
913 if (d_ptr->special_div == 64) return TRUE;
914 if (summon_specific_type && !(d_ptr->flags1 & DF1_CHAMELEON)) return TRUE;
916 if(d_ptr->mode == DUNGEON_MODE_AND)
920 if((d_ptr->mflags1 & r_ptr->flags1) != d_ptr->mflags1)
925 if((d_ptr->mflags2 & r_ptr->flags2) != d_ptr->mflags2)
930 if((d_ptr->mflags3 & r_ptr->flags3) != d_ptr->mflags3)
935 if((d_ptr->mflags4 & r_ptr->flags4) != d_ptr->mflags4)
940 if((d_ptr->mflags5 & r_ptr->flags5) != d_ptr->mflags5)
945 if((d_ptr->mflags6 & r_ptr->flags6) != d_ptr->mflags6)
950 if((d_ptr->mflags7 & r_ptr->flags7) != d_ptr->mflags7)
955 if((d_ptr->mflags8 & r_ptr->flags8) != d_ptr->mflags8)
960 if((d_ptr->mflags9 & r_ptr->flags9) != d_ptr->mflags9)
963 for(a = 0; a < 5; a++)
964 if(d_ptr->r_char[a] && (d_ptr->r_char[a] != r_ptr->d_char)) return FALSE;
966 else if(d_ptr->mode == DUNGEON_MODE_NAND)
968 byte ok[9 + 5], i = 0, j = 0;
973 if(d_ptr->mflags1 & r_ptr->flags1)
979 if(d_ptr->mflags2 & r_ptr->flags2)
985 if(d_ptr->mflags3 & r_ptr->flags3)
991 if(d_ptr->mflags4 & r_ptr->flags4)
997 if(d_ptr->mflags5 & r_ptr->flags5)
1003 if(d_ptr->mflags6 & r_ptr->flags6)
1009 if(d_ptr->mflags7 & r_ptr->flags7)
1015 if(d_ptr->mflags8 & r_ptr->flags8)
1021 if(d_ptr->mflags9 & r_ptr->flags9)
1025 for(a = 0; a < 5; a++)
1027 if(d_ptr->r_char[a])
1030 if (d_ptr->r_char[a] != r_ptr->d_char) ok[9 + a] = 1;
1034 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];
1036 if(i == j) return FALSE;
1038 else if(d_ptr->mode == DUNGEON_MODE_OR)
1043 for(i = 0; i < 32; i++)
1045 flag = d_ptr->mflags1 & (1 << i);
1046 if(r_ptr->flags1 & flag) ok = TRUE;
1048 flag = d_ptr->mflags2 & (1 << i);
1049 if(r_ptr->flags2 & flag) ok = TRUE;
1051 flag = d_ptr->mflags3 & (1 << i);
1052 if(r_ptr->flags3 & flag) ok = TRUE;
1054 flag = d_ptr->mflags4 & (1 << i);
1055 if(r_ptr->flags4 & flag) ok = TRUE;
1057 flag = d_ptr->mflags5 & (1 << i);
1058 if(r_ptr->flags5 & flag) ok = TRUE;
1060 flag = d_ptr->mflags6 & (1 << i);
1061 if(r_ptr->flags6 & flag) ok = TRUE;
1063 flag = d_ptr->mflags7 & (1 << i);
1064 if(r_ptr->flags7 & flag) ok = TRUE;
1066 flag = d_ptr->mflags8 & (1 << i);
1067 if(r_ptr->flags8 & flag) ok = TRUE;
1069 flag = d_ptr->mflags9 & (1 << i);
1070 if(r_ptr->flags9 & flag) ok = TRUE;
1072 for(a = 0; a < 5; a++)
1073 if(d_ptr->r_char[a] == r_ptr->d_char) ok = TRUE;
1077 else if(d_ptr->mode == DUNGEON_MODE_NOR)
1082 for(i = 0; i < 32; i++)
1084 flag = d_ptr->mflags1 & (1 << i);
1085 if(r_ptr->flags1 & flag) ok = FALSE;
1087 flag = d_ptr->mflags2 & (1 << i);
1088 if(r_ptr->flags2 & flag) ok = FALSE;
1090 flag = d_ptr->mflags3 & (1 << i);
1091 if(r_ptr->flags3 & flag) ok = FALSE;
1093 flag = d_ptr->mflags4 & (1 << i);
1094 if(r_ptr->flags4 & flag) ok = FALSE;
1096 flag = d_ptr->mflags5 & (1 << i);
1097 if(r_ptr->flags5 & flag) ok = FALSE;
1099 flag = d_ptr->mflags6 & (1 << i);
1100 if(r_ptr->flags6 & flag) ok = FALSE;
1102 flag = d_ptr->mflags7 & (1 << i);
1103 if(r_ptr->flags7 & flag) ok = FALSE;
1105 flag = d_ptr->mflags8 & (1 << i);
1106 if(r_ptr->flags8 & flag) ok = FALSE;
1108 flag = d_ptr->mflags9 & (1 << i);
1109 if(r_ptr->flags9 & flag) ok = FALSE;
1111 for(a = 0; a < 5; a++)
1112 if(d_ptr->r_char[a] == r_ptr->d_char) ok = FALSE;
1120 * Apply a "monster restriction function" to the "monster allocation table"
1122 errr get_mon_num_prep(monster_hook_type monster_hook,
1123 monster_hook_type monster_hook2)
1127 /* Todo: Check the hooks for non-changes */
1129 /* Set the new hooks */
1130 get_mon_num_hook = monster_hook;
1131 get_mon_num2_hook = monster_hook2;
1133 /* Scan the allocation table */
1134 for (i = 0; i < alloc_race_size; i++)
1136 monster_race *r_ptr;
1139 alloc_entry *entry = &alloc_race_table[i];
1142 r_ptr = &r_info[entry->index];
1144 /* Skip monsters which don't pass the restriction */
1145 if ((get_mon_num_hook && !((*get_mon_num_hook)(entry->index))) ||
1146 (get_mon_num2_hook && !((*get_mon_num2_hook)(entry->index))))
1149 if (!p_ptr->inside_battle && !chameleon_change_m_idx &&
1150 summon_specific_type != SUMMON_GUARDIANS)
1152 /* Hack -- don't create questors */
1153 if (r_ptr->flags1 & RF1_QUESTOR)
1156 if (r_ptr->flags7 & RF7_GUARDIAN)
1159 /* Depth Monsters never appear out of depth */
1160 if ((r_ptr->flags1 & (RF1_FORCE_DEPTH)) &&
1161 (r_ptr->level > dun_level))
1165 /* Accept this monster */
1166 entry->prob2 = entry->prob1;
1168 if (dun_level && (!p_ptr->inside_quest || p_ptr->inside_quest < MIN_RANDOM_QUEST) && !restrict_monster_to_dungeon(entry->index) && !p_ptr->inside_battle)
1170 int hoge = entry->prob2 * d_info[dungeon_type].special_div;
1171 entry->prob2 = hoge / 64;
1172 if (randint0(64) < (hoge & 0x3f)) entry->prob2++;
1181 static int mysqrt(int n)
1219 * Choose a monster race that seems "appropriate" to the given level
1221 * This function uses the "prob2" field of the "monster allocation table",
1222 * and various local information, to calculate the "prob3" field of the
1223 * same table, which is then used to choose an "appropriate" monster, in
1224 * a relatively efficient manner.
1226 * Note that "town" monsters will *only* be created in the town, and
1227 * "normal" monsters will *never* be created in the town, unless the
1228 * "level" is "modified", for example, by polymorph or summoning.
1230 * There is a small chance (1/50) of "boosting" the given depth by
1231 * a small amount (up to four levels), except in the town.
1233 * It is (slightly) more likely to acquire a monster of the given level
1234 * than one of a lower level. This is done by choosing several monsters
1235 * appropriate to the given level and keeping the "hardest" one.
1237 * Note that if no monsters are "appropriate", then this function will
1238 * fail, and return zero, but this should *almost* never happen.
1240 s16b get_mon_num(int level)
1248 monster_race *r_ptr;
1250 alloc_entry *table = alloc_race_table;
1252 int pls_kakuritu, pls_level;
1253 int hoge=mysqrt(level*10000L);
1255 if (level > MAX_DEPTH - 1) level = MAX_DEPTH - 1;
1257 if ((dungeon_turn > hoge*(TURNS_PER_TICK*500L)) && !level)
1259 pls_kakuritu = MAX(2, NASTY_MON-((dungeon_turn/(TURNS_PER_TICK*2500L)-hoge/10)));
1260 pls_level = MIN(8,3 + dungeon_turn/(TURNS_PER_TICK*20000L)-hoge/40);
1264 pls_kakuritu = NASTY_MON;
1268 if (d_info[dungeon_type].flags1 & DF1_MAZE)
1270 pls_kakuritu = MIN(pls_kakuritu/2, pls_kakuritu-10);
1271 if (pls_kakuritu < 2) pls_kakuritu = 2;
1276 /* Boost the level */
1277 if ((level > 0) && !p_ptr->inside_battle && !(d_info[dungeon_type].flags1 & DF1_BEGINNER))
1279 /* Nightmare mode allows more out-of depth monsters */
1280 if (ironman_nightmare && !randint0(pls_kakuritu))
1282 /* What a bizarre calculation */
1283 level = 1 + (level * MAX_DEPTH / randint1(MAX_DEPTH));
1287 /* Occasional "nasty" monster */
1288 if (!randint0(pls_kakuritu))
1290 /* Pick a level bonus */
1291 int d = MIN(5, level/10) + pls_level;
1293 /* Boost the level */
1297 /* Occasional "nasty" monster */
1298 if (!randint0(pls_kakuritu))
1300 /* Pick a level bonus */
1301 int d = MIN(5, level/10) + pls_level;
1303 /* Boost the level */
1313 /* Process probabilities */
1314 for (i = 0; i < alloc_race_size; i++)
1316 /* Monsters are sorted by depth */
1317 if (table[i].level > level) break;
1322 /* Access the "r_idx" of the chosen monster */
1323 r_idx = table[i].index;
1325 /* Access the actual race */
1326 r_ptr = &r_info[r_idx];
1328 if (!p_ptr->inside_battle && !chameleon_change_m_idx)
1330 /* Hack -- "unique" monsters must be "unique" */
1331 if (((r_ptr->flags1 & (RF1_UNIQUE)) ||
1332 (r_ptr->flags7 & (RF7_UNIQUE_7))) &&
1333 (r_ptr->cur_num >= r_ptr->max_num))
1338 if ((r_ptr->flags7 & (RF7_UNIQUE2)) &&
1339 (r_ptr->cur_num >= 1))
1344 if (r_idx == MON_BANORLUPART)
1346 if (r_info[MON_BANOR].cur_num > 0) continue;
1347 if (r_info[MON_LUPART].cur_num > 0) continue;
1352 table[i].prob3 = table[i].prob2;
1355 total += table[i].prob3;
1358 /* No legal monsters */
1359 if (total <= 0) return (0);
1362 /* Pick a monster */
1363 value = randint0(total);
1365 /* Find the monster */
1366 for (i = 0; i < alloc_race_size; i++)
1368 /* Found the entry */
1369 if (value < table[i].prob3) break;
1372 value = value - table[i].prob3;
1379 /* Try for a "harder" monster once (50%) or twice (10%) */
1385 /* Pick a monster */
1386 value = randint0(total);
1388 /* Find the monster */
1389 for (i = 0; i < alloc_race_size; i++)
1391 /* Found the entry */
1392 if (value < table[i].prob3) break;
1395 value = value - table[i].prob3;
1398 /* Keep the "best" one */
1399 if (table[i].level < table[j].level) i = j;
1402 /* Try for a "harder" monster twice (10%) */
1408 /* Pick a monster */
1409 value = randint0(total);
1411 /* Find the monster */
1412 for (i = 0; i < alloc_race_size; i++)
1414 /* Found the entry */
1415 if (value < table[i].prob3) break;
1418 value = value - table[i].prob3;
1421 /* Keep the "best" one */
1422 if (table[i].level < table[j].level) i = j;
1426 return (table[i].index);
1434 * Build a string describing a monster in some way.
1436 * We can correctly describe monsters based on their visibility.
1437 * We can force all monsters to be treated as visible or invisible.
1438 * We can build nominatives, objectives, possessives, or reflexives.
1439 * We can selectively pronominalize hidden, visible, or all monsters.
1440 * We can use definite or indefinite descriptions for hidden monsters.
1441 * We can use definite or indefinite descriptions for visible monsters.
1443 * Pronominalization involves the gender whenever possible and allowed,
1444 * so that by cleverly requesting pronominalization / visibility, you
1445 * can get messages like "You hit someone. She screams in agony!".
1447 * Reflexives are acquired by requesting Objective plus Possessive.
1449 * If no m_ptr arg is given (?), the monster is assumed to be hidden,
1450 * unless the "Assume Visible" mode is requested.
1452 * If no r_ptr arg is given, it is extracted from m_ptr and r_info
1453 * If neither m_ptr nor r_ptr is given, the monster is assumed to
1454 * be neuter, singular, and hidden (unless "Assume Visible" is set),
1455 * in which case you may be in trouble... :-)
1457 * I am assuming that no monster name is more than 70 characters long,
1458 * so that "char desc[80];" is sufficiently large for any result.
1461 * 0x01 --> Objective (or Reflexive)
1462 * 0x02 --> Possessive (or Reflexive)
1463 * 0x04 --> Use indefinites for hidden monsters ("something")
1464 * 0x08 --> Use indefinites for visible monsters ("a kobold")
1465 * 0x10 --> Pronominalize hidden monsters
1466 * 0x20 --> Pronominalize visible monsters
1467 * 0x40 --> Assume the monster is hidden
1468 * 0x80 --> Assume the monster is visible
1469 * 0x100 --> Chameleon's true name
1470 * 0x200 --> Ignore hallucination, and penetrate shape change
1473 * 0x00 --> Full nominative name ("the kobold") or "it"
1474 * 0x04 --> Full nominative name ("the kobold") or "something"
1475 * 0x80 --> Genocide resistance name ("the kobold")
1476 * 0x88 --> Killing name ("a kobold")
1477 * 0x22 --> Possessive, genderized if visable ("his") or "its"
1478 * 0x23 --> Reflexive, genderized if visable ("himself") or "itself"
1480 void monster_desc(char *desc, monster_type *m_ptr, int mode)
1483 monster_race *r_ptr;
1487 char silly_name[1024];
1491 r_ptr = &r_info[m_ptr->ap_r_idx];
1493 if ((mode & 0x100) && (m_ptr->mflag2 & MFLAG_CHAMELEON))
1495 if (r_ptr->flags1 & RF1_UNIQUE) name = (r_name + r_info[MON_CHAMELEON_K].name);
1496 else name = (r_name + r_info[MON_CHAMELEON].name);
1498 else name = (r_name + r_ptr->name);
1500 /* Are we hallucinating? (Idea from Nethack...) */
1501 if (p_ptr->image && !(mode & 0x200))
1506 if (!get_rnd_line("silly_j.txt", m_ptr->r_idx, silly_name))
1508 if (!get_rnd_line("silly.txt", m_ptr->r_idx, silly_name))
1516 monster_race *hallu_race;
1520 hallu_race = &r_info[randint1(max_r_idx - 1)];
1522 while (hallu_race->flags1 & RF1_UNIQUE);
1524 strcpy(silly_name, (r_name + hallu_race->name));
1527 /* Better not strcpy it, or we could corrupt r_info... */
1531 /* Can we "see" it (exists + forced, or visible + not unforced) */
1532 seen = (m_ptr && ((mode & 0x80) || (!(mode & 0x40) && m_ptr->ml)));
1534 /* Sexed Pronouns (seen and allowed, or unseen and allowed) */
1535 pron = (m_ptr && ((seen && (mode & 0x20)) || (!seen && (mode & 0x10))));
1538 /* First, try using pronouns, or describing hidden monsters */
1541 /* an encoding of the monster "sex" */
1544 /* Extract the gender (if applicable) */
1545 if (r_ptr->flags1 & (RF1_FEMALE)) kind = 0x20;
1546 else if (r_ptr->flags1 & (RF1_MALE)) kind = 0x10;
1548 /* Ignore the gender (if desired) */
1549 if (!m_ptr || !pron) kind = 0x00;
1552 /* Assume simple result */
1560 /* Brute force: split on the possibilities */
1561 switch (kind + (mode & 0x07))
1563 /* Neuter, or unknown */
1565 case 0x00: res = "²¿¤«"; break;
1566 case 0x01: res = "²¿¤«"; break;
1567 case 0x02: res = "²¿¤«¤Î"; break;
1568 case 0x03: res = "²¿¤«¼«¿È"; break;
1569 case 0x04: res = "²¿¤«"; break;
1570 case 0x05: res = "²¿¤«"; break;
1571 case 0x06: res = "²¿¤«"; break;
1572 case 0x07: res = "¤½¤ì¼«¿È"; break;
1574 case 0x00: res = "it"; break;
1575 case 0x01: res = "it"; break;
1576 case 0x02: res = "its"; break;
1577 case 0x03: res = "itself"; break;
1578 case 0x04: res = "something"; break;
1579 case 0x05: res = "something"; break;
1580 case 0x06: res = "something's"; break;
1581 case 0x07: res = "itself"; break;
1585 /* Male (assume human if vague) */
1587 case 0x10: res = "Èà"; break;
1588 case 0x11: res = "Èà"; break;
1589 case 0x12: res = "Èà¤Î"; break;
1590 case 0x13: res = "È༫¿È"; break;
1591 case 0x14: res = "狼"; break;
1592 case 0x15: res = "狼"; break;
1593 case 0x16: res = "狼¤Î"; break;
1594 case 0x17: res = "È༫¿È"; break;
1596 case 0x10: res = "he"; break;
1597 case 0x11: res = "him"; break;
1598 case 0x12: res = "his"; break;
1599 case 0x13: res = "himself"; break;
1600 case 0x14: res = "someone"; break;
1601 case 0x15: res = "someone"; break;
1602 case 0x16: res = "someone's"; break;
1603 case 0x17: res = "himself"; break;
1607 /* Female (assume human if vague) */
1609 case 0x20: res = "Èà½÷"; break;
1610 case 0x21: res = "Èà½÷"; break;
1611 case 0x22: res = "Èà½÷¤Î"; break;
1612 case 0x23: res = "Èà½÷¼«¿È"; break;
1613 case 0x24: res = "狼"; break;
1614 case 0x25: res = "狼"; break;
1615 case 0x26: res = "狼¤Î"; break;
1616 case 0x27: res = "Èà½÷¼«¿È"; break;
1618 case 0x20: res = "she"; break;
1619 case 0x21: res = "her"; break;
1620 case 0x22: res = "her"; break;
1621 case 0x23: res = "herself"; break;
1622 case 0x24: res = "someone"; break;
1623 case 0x25: res = "someone"; break;
1624 case 0x26: res = "someone's"; break;
1625 case 0x27: res = "herself"; break;
1630 /* Copy the result */
1631 (void)strcpy(desc, res);
1635 /* Handle visible monsters, "reflexive" request */
1636 else if ((mode & 0x02) && (mode & 0x01))
1638 /* The monster is visible, so use its gender */
1640 if (r_ptr->flags1 & (RF1_FEMALE)) strcpy(desc, "Èà½÷¼«¿È");
1641 else if (r_ptr->flags1 & (RF1_MALE)) strcpy(desc, "È༫¿È");
1642 else strcpy(desc, "¤½¤ì¼«¿È");
1644 if (r_ptr->flags1 & RF1_FEMALE) strcpy(desc, "herself");
1645 else if (r_ptr->flags1 & RF1_MALE) strcpy(desc, "himself");
1646 else strcpy(desc, "itself");
1652 /* Handle all other visible monster requests */
1656 if (is_pet(m_ptr) && m_ptr->ap_r_idx != m_ptr->r_idx)
1662 while(strncmp(t, "¡Ù", 2) && *t) t++;
1666 (void)sprintf(desc, "%s¡©¡Ù", buf);
1669 (void)sprintf(desc, "%s¡©", name);
1671 (void)sprintf(desc, "%s?", name);
1676 /* It could be a Unique */
1677 if ((r_ptr->flags1 & RF1_UNIQUE) && !(p_ptr->image && !(mode & 0x200)))
1679 /* Start with the name (thus nominative and objective) */
1680 if ((m_ptr->mflag2 & MFLAG_CHAMELEON) && !(mode & 0x100))
1686 while(strncmp(t, "¡Ù", 2) && *t) t++;
1690 (void)sprintf(desc, "%s¡©¡Ù", buf);
1693 (void)sprintf(desc, "%s¡©", name);
1695 (void)sprintf(desc, "%s?", name);
1698 else if ((cave[m_ptr->fy][m_ptr->fx].m_idx == p_ptr->riding) || !p_ptr->inside_battle)
1699 (void)strcpy(desc, name);
1702 (void)sprintf(desc, "%s¤â¤É¤", name);
1704 (void)sprintf(desc, "fake %s", name);
1708 /* It could be an indefinite monster */
1709 else if (mode & 0x08)
1711 /* XXX Check plurality for "some" */
1713 /* Indefinite monsters need an indefinite article */
1715 (void)strcpy(desc, "");
1717 (void)strcpy(desc, is_a_vowel(name[0]) ? "an " : "a ");
1720 (void)strcat(desc, name);
1723 /* It could be a normal, definite, monster */
1726 /* Definite monsters need a definite article */
1729 (void)strcpy(desc, "¤¢¤Ê¤¿¤Î");
1731 (void)strcpy(desc, "your ");
1736 (void)strcpy(desc, "");
1738 (void)strcpy(desc, "the ");
1741 (void)strcat(desc, name);
1744 if (m_ptr->nickname)
1747 sprintf(buf,"¡Ö%s¡×",quark_str(m_ptr->nickname));
1749 sprintf(buf," called %s",quark_str(m_ptr->nickname));
1754 if ((m_ptr->fy == py) && (m_ptr->fx == px))
1757 strcat(desc,"(¾èÇÏÃæ)");
1759 strcat(desc,"(riding)");
1763 if ((mode & 0x200) && (m_ptr->mflag2 & MFLAG_CHAMELEON))
1765 if (r_ptr->flags1 & RF1_UNIQUE)
1768 strcat(desc,"(¥«¥á¥ì¥ª¥ó¤Î²¦)");
1770 strcat(desc,"(Chameleon Lord)");
1776 strcat(desc,"(¥«¥á¥ì¥ª¥ó)");
1778 strcat(desc,"(Chameleon)");
1783 if ((mode & 0x200) && m_ptr->ap_r_idx != m_ptr->r_idx)
1785 strcat(desc, format("(%s)", r_name + r_info[m_ptr->r_idx].name));
1788 /* Handle the Possessive as a special afterthought */
1791 /* XXX Check for trailing "s" */
1793 /* Simply append "apostrophe" and "s" */
1795 (void)strcat(desc, "¤Î");
1797 (void)strcat(desc, "'s");
1808 * Learn about a monster (by "probing" it)
1810 void lore_do_probe(int m_idx)
1812 monster_type *m_ptr = &m_list[m_idx];
1814 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1816 /* Hack -- Memorize some flags */
1817 r_ptr->r_flags1 = r_ptr->flags1;
1818 r_ptr->r_flags2 = r_ptr->flags2;
1819 r_ptr->r_flags3 = r_ptr->flags3;
1821 /* Update monster recall window */
1822 if (p_ptr->monster_race_idx == m_ptr->r_idx)
1825 p_ptr->window |= (PW_MONSTER);
1831 * Take note that the given monster just dropped some treasure
1833 * Note that learning the "GOOD"/"GREAT" flags gives information
1834 * about the treasure (even when the monster is killed for the first
1835 * time, such as uniques, and the treasure has not been examined yet).
1837 * This "indirect" method is used to prevent the player from learning
1838 * exactly how much treasure a monster can drop from observing only
1839 * a single example of a drop. This method actually observes how much
1840 * gold and items are dropped, and remembers that information to be
1841 * described later by the monster recall code.
1843 void lore_treasure(int m_idx, int num_item, int num_gold)
1845 monster_type *m_ptr = &m_list[m_idx];
1847 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1849 /* Note the number of things dropped */
1850 if (num_item > r_ptr->r_drop_item) r_ptr->r_drop_item = num_item;
1851 if (num_gold > r_ptr->r_drop_gold) r_ptr->r_drop_gold = num_gold;
1853 /* Hack -- memorize the good/great flags */
1854 if (r_ptr->flags1 & (RF1_DROP_GOOD)) r_ptr->r_flags1 |= (RF1_DROP_GOOD);
1855 if (r_ptr->flags1 & (RF1_DROP_GREAT)) r_ptr->r_flags1 |= (RF1_DROP_GREAT);
1857 /* Update monster recall window */
1858 if (p_ptr->monster_race_idx == m_ptr->r_idx)
1861 p_ptr->window |= (PW_MONSTER);
1867 void sanity_blast(monster_type *m_ptr, bool necro)
1869 bool happened = FALSE;
1872 if (p_ptr->inside_battle || !character_dungeon) return;
1877 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1879 power = r_ptr->level / 2;
1881 monster_desc(m_name, m_ptr, 0);
1883 if (!(r_ptr->flags1 & RF1_UNIQUE))
1885 if (r_ptr->flags1 & RF1_FRIENDS)
1891 return; /* No effect yet, just loaded... */
1894 return; /* Cannot see it for some reason */
1896 if (!(r_ptr->flags2 & RF2_ELDRITCH_HORROR))
1902 return; /* Pet eldritch horrors are safe most of the time */
1904 if (randint1(100) > power) return;
1906 if (saving_throw(p_ptr->skill_sav - power))
1908 return; /* Save, no adverse effects */
1913 /* Something silly happens... */
1915 msg_format("%s%s¤Î´é¤ò¸«¤Æ¤·¤Þ¤Ã¤¿¡ª",
1917 msg_format("You behold the %s visage of %s!",
1920 funny_desc[randint0(MAX_SAN_FUNNY)], m_name);
1924 msg_print(funny_comments[randint0(MAX_SAN_COMMENT)]);
1925 p_ptr->image = p_ptr->image + randint1(r_ptr->level);
1928 return; /* Never mind; we can't see it clearly enough */
1931 /* Something frightening happens... */
1933 msg_format("%s%s¤Î´é¤ò¸«¤Æ¤·¤Þ¤Ã¤¿¡ª",
1935 msg_format("You behold the %s visage of %s!",
1938 horror_desc[randint0(MAX_SAN_HORROR)], m_name);
1940 r_ptr->r_flags2 |= RF2_ELDRITCH_HORROR;
1942 /* Demon characters are unaffected */
1943 if ((p_ptr->prace == RACE_IMP) || (p_ptr->prace == RACE_DEMON) || (mimic_info[p_ptr->mimic_form].MIMIC_FLAGS & MIMIC_IS_DEMON)) return;
1944 if (p_ptr->wizard) return;
1946 /* Undead characters are 50% likely to be unaffected */
1947 if ((p_ptr->prace == RACE_SKELETON) || (p_ptr->prace == RACE_ZOMBIE)
1948 || (p_ptr->prace == RACE_VAMPIRE) || (p_ptr->prace == RACE_SPECTRE) ||
1949 (mimic_info[p_ptr->mimic_form].MIMIC_FLAGS & MIMIC_IS_UNDEAD))
1951 if (saving_throw(25 + p_ptr->lev)) return;
1957 msg_print("¥Í¥¯¥í¥Î¥ß¥³¥ó¤òÆɤó¤ÇÀµµ¤¤ò¼º¤Ã¤¿¡ª");
1959 msg_print("Your sanity is shaken by reading the Necronomicon!");
1964 if (!saving_throw(p_ptr->skill_sav - power)) /* Mind blast */
1966 if (!p_ptr->resist_conf)
1968 (void)set_confused(p_ptr->confused + randint0(4) + 4);
1970 if (!p_ptr->resist_chaos && one_in_(3))
1972 (void)set_image(p_ptr->image + randint0(250) + 150);
1977 if (!saving_throw(p_ptr->skill_sav - power)) /* Lose int & wis */
1984 if (!saving_throw(p_ptr->skill_sav - power)) /* Brain smash */
1986 if (!p_ptr->resist_conf)
1988 (void)set_confused(p_ptr->confused + randint0(4) + 4);
1990 if (!p_ptr->free_act)
1992 (void)set_paralyzed(p_ptr->paralyzed + randint0(4) + 4);
1994 while (randint0(100) > p_ptr->skill_sav)
1995 (void)do_dec_stat(A_INT);
1996 while (randint0(100) > p_ptr->skill_sav)
1997 (void)do_dec_stat(A_WIS);
1998 if (!p_ptr->resist_chaos)
2000 (void)set_image(p_ptr->image + randint0(250) + 150);
2005 if (!saving_throw(p_ptr->skill_sav - power)) /* Amnesia */
2008 if (lose_all_info())
2010 msg_print("¤¢¤Þ¤ê¤Î¶²ÉݤËÁ´¤Æ¤Î¤³¤È¤ò˺¤ì¤Æ¤·¤Þ¤Ã¤¿¡ª");
2012 msg_print("You forget everything in your utmost terror!");
2018 if (saving_throw(p_ptr->skill_sav - power))
2023 /* Else gain permanent insanity */
2024 if ((p_ptr->muta3 & MUT3_MORONIC) && /*(p_ptr->muta2 & MUT2_BERS_RAGE) &&*/
2025 ((p_ptr->muta2 & MUT2_COWARDICE) || (p_ptr->resist_fear)) &&
2026 ((p_ptr->muta2 & MUT2_HALLU) || (p_ptr->resist_chaos)))
2028 /* The poor bastard already has all possible insanities! */
2034 switch (randint1(21))
2037 if (!(p_ptr->muta3 & MUT3_MORONIC) && one_in_(5))
2039 if ((p_ptr->stat_use[A_INT] < 4) && (p_ptr->stat_use[A_WIS] < 4))
2042 msg_print("¤¢¤Ê¤¿¤Ï´°àú¤ÊÇϼ¯¤Ë¤Ê¤Ã¤¿¤è¤¦¤Êµ¤¤¬¤·¤¿¡£¤·¤«¤·¤½¤ì¤Ï¸µ¡¹¤À¤Ã¤¿¡£");
2044 msg_print("You turn into an utter moron!");
2050 msg_print("¤¢¤Ê¤¿¤Ï´°àú¤ÊÇϼ¯¤Ë¤Ê¤Ã¤¿¡ª");
2052 msg_print("You turn into an utter moron!");
2056 if (p_ptr->muta3 & MUT3_HYPER_INT)
2059 msg_print("¤¢¤Ê¤¿¤ÎǾ¤ÏÀ¸ÂÎ¥³¥ó¥Ô¥å¡¼¥¿¤Ç¤Ï¤Ê¤¯¤Ê¤Ã¤¿¡£");
2061 msg_print("Your brain is no longer a living computer.");
2064 p_ptr->muta3 &= ~(MUT3_HYPER_INT);
2066 p_ptr->muta3 |= MUT3_MORONIC;
2080 if (!(p_ptr->muta2 & MUT2_COWARDICE) && !p_ptr->resist_fear)
2083 msg_print("¤¢¤Ê¤¿¤Ï¥Ñ¥é¥Î¥¤¥¢¤Ë¤Ê¤Ã¤¿¡ª");
2085 msg_print("You become paranoid!");
2089 /* Duh, the following should never happen, but anyway... */
2090 if (p_ptr->muta3 & MUT3_FEARLESS)
2093 msg_print("¤¢¤Ê¤¿¤Ï¤â¤¦¶²¤ìÃΤ餺¤Ç¤Ï¤Ê¤¯¤Ê¤Ã¤¿¡£");
2095 msg_print("You are no longer fearless.");
2098 p_ptr->muta3 &= ~(MUT3_FEARLESS);
2101 p_ptr->muta2 |= MUT2_COWARDICE;
2115 if (!(p_ptr->muta2 & MUT2_HALLU) && !p_ptr->resist_chaos)
2118 msg_print("¸¸³Ð¤ò¤Ò¤µ¯¤³¤¹Àº¿ÀºøÍð¤Ë´Ù¤Ã¤¿¡ª");
2120 msg_print("You are afflicted by a hallucinatory insanity!");
2123 p_ptr->muta2 |= MUT2_HALLU;
2128 if (!(p_ptr->muta2 & MUT2_BERS_RAGE))
2131 msg_print("·ãÎõ¤Ê´¶¾ð¤Îȯºî¤Ë¤ª¤½¤ï¤ì¤ë¤è¤¦¤Ë¤Ê¤Ã¤¿¡ª");
2133 msg_print("You become subject to fits of berserk rage!");
2136 p_ptr->muta2 |= MUT2_BERS_RAGE;
2143 p_ptr->update |= PU_BONUS;
2149 * This function updates the monster record of the given monster
2151 * This involves extracting the distance to the player (if requested),
2152 * and then checking for visibility (natural, infravision, see-invis,
2153 * telepathy), updating the monster visibility flag, redrawing (or
2154 * erasing) the monster when its visibility changes, and taking note
2155 * of any interesting monster flags (cold-blooded, invisible, etc).
2157 * Note the new "mflag" field which encodes several monster state flags,
2158 * including "view" for when the monster is currently in line of sight,
2159 * and "mark" for when the monster is currently visible via detection.
2161 * The only monster fields that are changed here are "cdis" (the
2162 * distance from the player), "ml" (visible to the player), and
2163 * "mflag" (to maintain the "MFLAG_VIEW" flag).
2165 * Note the special "update_monsters()" function which can be used to
2166 * call this function once for every monster.
2168 * Note the "full" flag which requests that the "cdis" field be updated,
2169 * this is only needed when the monster (or the player) has moved.
2171 * Every time a monster moves, we must call this function for that
2172 * monster, and update the distance, and the visibility. Every time
2173 * the player moves, we must call this function for every monster, and
2174 * update the distance, and the visibility. Whenever the player "state"
2175 * changes in certain ways ("blindness", "infravision", "telepathy",
2176 * and "see invisible"), we must call this function for every monster,
2177 * and update the visibility.
2179 * Routines that change the "illumination" of a grid must also call this
2180 * function for any monster in that grid, since the "visibility" of some
2181 * monsters may be based on the illumination of their grid.
2183 * Note that this function is called once per monster every time the
2184 * player moves. When the player is running, this function is one
2185 * of the primary bottlenecks, along with "update_view()" and the
2186 * "process_monsters()" code, so efficiency is important.
2188 * Note the optimized "inline" version of the "distance()" function.
2190 * A monster is "visible" to the player if (1) it has been detected
2191 * by the player, (2) it is close to the player and the player has
2192 * telepathy, or (3) it is close to the player, and in line of sight
2193 * of the player, and it is "illuminated" by some combination of
2194 * infravision, torch light, or permanent light (invisible monsters
2195 * are only affected by "light" if the player can see invisible).
2197 * Monsters which are not on the current panel may be "visible" to
2198 * the player, and their descriptions will include an "offscreen"
2199 * reference. Currently, offscreen monsters cannot be targetted
2200 * or viewed directly, but old targets will remain set. XXX XXX
2202 * The player can choose to be disturbed by several things, including
2203 * "disturb_move" (monster which is viewable moves in some way), and
2204 * "disturb_near" (monster which is "easily" viewable moves in some
2205 * way). Note that "moves" includes "appears" and "disappears".
2207 void update_mon(int m_idx, bool full)
2209 monster_type *m_ptr = &m_list[m_idx];
2211 monster_race *r_ptr = &r_info[m_ptr->r_idx];
2215 /* Current location */
2222 /* Seen by vision */
2226 /* Compute distance */
2229 /* Distance components */
2230 int dy = (py > fy) ? (py - fy) : (fy - py);
2231 int dx = (px > fx) ? (px - fx) : (fx - px);
2233 /* Approximate distance */
2234 d = (dy > dx) ? (dy + (dx>>1)) : (dx + (dy>>1));
2236 /* Restrict distance */
2237 if (d > 255) d = 255;
2241 /* Save the distance */
2245 /* Extract distance */
2248 /* Extract the distance */
2254 if (m_ptr->mflag & (MFLAG_MARK)) flag = TRUE;
2258 if (d <= ((d_info[dungeon_type].flags1 & DF1_DARKNESS) ? MAX_SIGHT / 2 : MAX_SIGHT))
2260 if (!(d_info[dungeon_type].flags1 & DF1_DARKNESS) || (d <= MAX_SIGHT / 4))
2262 if (p_ptr->special_defense & KATA_MUSOU)
2267 /* Hack -- Memorize mental flags */
2268 if (r_ptr->flags2 & (RF2_SMART)) r_ptr->r_flags2 |= (RF2_SMART);
2269 if (r_ptr->flags2 & (RF2_STUPID)) r_ptr->r_flags2 |= (RF2_STUPID);
2272 /* Basic telepathy */
2273 else if (p_ptr->telepathy)
2275 /* Empty mind, no telepathy */
2276 if (r_ptr->flags2 & (RF2_EMPTY_MIND))
2278 /* Memorize flags */
2279 r_ptr->r_flags2 |= (RF2_EMPTY_MIND);
2282 /* Weird mind, occasional telepathy */
2283 else if (r_ptr->flags2 & (RF2_WEIRD_MIND))
2285 /* One in ten individuals are detectable */
2286 if ((m_idx % 10) == 5)
2291 /* Memorize flags */
2292 r_ptr->r_flags2 |= (RF2_WEIRD_MIND);
2294 /* Hack -- Memorize mental flags */
2295 if (r_ptr->flags2 & (RF2_SMART)) r_ptr->r_flags2 |= (RF2_SMART);
2296 if (r_ptr->flags2 & (RF2_STUPID)) r_ptr->r_flags2 |= (RF2_STUPID);
2300 /* Normal mind, allow telepathy */
2306 /* Hack -- Memorize mental flags */
2307 if (r_ptr->flags2 & (RF2_SMART)) r_ptr->r_flags2 |= (RF2_SMART);
2308 if (r_ptr->flags2 & (RF2_STUPID)) r_ptr->r_flags2 |= (RF2_STUPID);
2312 /* Magical sensing */
2313 if ((p_ptr->esp_animal) && (r_ptr->flags3 & (RF3_ANIMAL)))
2316 r_ptr->r_flags3 |= (RF3_ANIMAL);
2320 /* Magical sensing */
2321 if ((p_ptr->esp_undead) && (r_ptr->flags3 & (RF3_UNDEAD)))
2324 r_ptr->r_flags3 |= (RF3_UNDEAD);
2328 /* Magical sensing */
2329 if ((p_ptr->esp_demon) && (r_ptr->flags3 & (RF3_DEMON)))
2332 r_ptr->r_flags3 |= (RF3_DEMON);
2336 /* Magical sensing */
2337 if ((p_ptr->esp_orc) && (r_ptr->flags3 & (RF3_ORC)))
2340 r_ptr->r_flags3 |= (RF3_ORC);
2344 /* Magical sensing */
2345 if ((p_ptr->esp_troll) && (r_ptr->flags3 & (RF3_TROLL)))
2348 r_ptr->r_flags3 |= (RF3_TROLL);
2352 /* Magical sensing */
2353 if ((p_ptr->esp_giant) && (r_ptr->flags3 & (RF3_GIANT)))
2356 r_ptr->r_flags3 |= (RF3_GIANT);
2360 /* Magical sensing */
2361 if ((p_ptr->esp_dragon) && (r_ptr->flags3 & (RF3_DRAGON)))
2364 r_ptr->r_flags3 |= (RF3_DRAGON);
2368 /* Magical sensing */
2369 if ((p_ptr->esp_human) && (r_ptr->flags2 & (RF2_HUMAN)))
2372 r_ptr->r_flags2 |= (RF2_HUMAN);
2376 /* Magical sensing */
2377 if ((p_ptr->esp_evil) && (r_ptr->flags3 & (RF3_EVIL)))
2380 r_ptr->r_flags3 |= (RF3_EVIL);
2384 /* Magical sensing */
2385 if ((p_ptr->esp_good) && (r_ptr->flags3 & (RF3_GOOD)))
2388 r_ptr->r_flags3 |= (RF3_GOOD);
2392 /* Magical sensing */
2393 if ((p_ptr->esp_nonliving) &&
2394 (r_ptr->flags3 & (RF3_NONLIVING)) &&
2395 !(r_ptr->flags3 & (RF3_DEMON)) &&
2396 !(r_ptr->flags3 & (RF3_UNDEAD)))
2399 r_ptr->r_flags3 |= (RF3_NONLIVING);
2403 /* Magical sensing */
2404 if ((p_ptr->esp_unique) && (r_ptr->flags1 & (RF1_UNIQUE)))
2407 r_ptr->r_flags1 |= (RF1_UNIQUE);
2412 /* Normal line of sight, and not blind */
2413 if (player_has_los_bold(fy, fx) && !p_ptr->blind)
2415 bool do_invisible = FALSE;
2416 bool do_cold_blood = FALSE;
2418 /* Use "infravision" */
2419 if (d <= p_ptr->see_infra)
2421 /* Handle "cold blooded" monsters */
2422 if (r_ptr->flags2 & (RF2_COLD_BLOOD))
2425 do_cold_blood = TRUE;
2428 /* Handle "warm blooded" monsters */
2436 /* Use "illumination" */
2437 if (player_can_see_bold(fy, fx))
2439 /* Handle "invisible" monsters */
2440 if (r_ptr->flags2 & (RF2_INVISIBLE))
2443 do_invisible = TRUE;
2453 /* Handle "normal" monsters */
2464 /* Memorize flags */
2465 if (do_invisible) r_ptr->r_flags2 |= (RF2_INVISIBLE);
2466 if (do_cold_blood) r_ptr->r_flags2 |= (RF2_COLD_BLOOD);
2472 /* The monster is now visible */
2475 /* It was previously unseen */
2478 /* Mark as visible */
2481 /* Draw the monster */
2484 /* Update health bar as needed */
2485 if (p_ptr->health_who == m_idx) p_ptr->redraw |= (PR_HEALTH);
2486 if (p_ptr->riding == m_idx) p_ptr->redraw |= (PR_UHEALTH);
2488 /* Hack -- Count "fresh" sightings */
2489 if ((m_ptr->ap_r_idx == MON_KAGE) && (r_info[MON_KAGE].r_sights < MAX_SHORT))
2490 r_info[MON_KAGE].r_sights++;
2491 else if (m_ptr->ap_r_idx == m_ptr->r_idx &&
2492 r_ptr->r_sights < MAX_SHORT) r_ptr->r_sights++;
2494 /* Eldritch Horror */
2495 if (r_ptr->flags2 & RF2_ELDRITCH_HORROR)
2497 sanity_blast(m_ptr, FALSE);
2500 /* Disturb on appearance */
2501 if (disturb_near && (projectable(m_ptr->fy, m_ptr->fx, py, px) && projectable(py, px, m_ptr->fy, m_ptr->fx)))
2503 if (disturb_pets || is_hostile(m_ptr))
2509 /* The monster is not visible */
2512 /* It was previously seen */
2515 /* Mark as not visible */
2518 /* Erase the monster */
2521 /* Update health bar as needed */
2522 if (p_ptr->health_who == m_idx) p_ptr->redraw |= (PR_HEALTH);
2523 if (p_ptr->riding == m_idx) p_ptr->redraw |= (PR_UHEALTH);
2525 /* Disturb on disappearance */
2528 if (disturb_pets || is_hostile(m_ptr))
2535 /* The monster is now easily visible */
2539 if (!(m_ptr->mflag & (MFLAG_VIEW)))
2541 /* Mark as easily visible */
2542 m_ptr->mflag |= (MFLAG_VIEW);
2544 /* Disturb on appearance */
2547 if (disturb_pets || is_hostile(m_ptr))
2553 /* The monster is not easily visible */
2557 if (m_ptr->mflag & (MFLAG_VIEW))
2559 /* Mark as not easily visible */
2560 m_ptr->mflag &= ~(MFLAG_VIEW);
2562 /* Disturb on disappearance */
2565 if (disturb_pets || is_hostile(m_ptr))
2574 * This function simply updates all the (non-dead) monsters (see above).
2576 void update_monsters(bool full)
2580 /* Update each (live) monster */
2581 for (i = 1; i < m_max; i++)
2583 monster_type *m_ptr = &m_list[i];
2585 /* Skip dead monsters */
2586 if (!m_ptr->r_idx) continue;
2588 /* Update the monster */
2589 update_mon(i, full);
2595 * Hack -- the index of the summoning monster
2597 static bool monster_hook_chameleon_lord(int r_idx)
2599 monster_race *r_ptr = &r_info[r_idx];
2600 monster_type *m_ptr = &m_list[chameleon_change_m_idx];
2601 monster_race *old_r_ptr = &r_info[m_ptr->r_idx];
2603 if (!(r_ptr->flags1 & (RF1_UNIQUE))) return FALSE;
2604 if (r_ptr->flags7 & (RF7_FRIENDLY | RF7_CHAMELEON)) return FALSE;
2606 if (ABS(r_ptr->level - r_info[MON_CHAMELEON_K].level) > 5) return FALSE;
2608 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))
2611 if (!monster_can_cross_terrain(cave[m_ptr->fy][m_ptr->fx].feat, r_ptr)) return FALSE;
2614 if (!(old_r_ptr->flags7 & RF7_CHAMELEON))
2616 if ((m_ptr->sub_align & SUB_ALIGN_EVIL) && (r_ptr->flags3 & RF3_GOOD)) return FALSE;
2617 if ((m_ptr->sub_align & SUB_ALIGN_GOOD) && (r_ptr->flags3 & RF3_EVIL)) return FALSE;
2621 else if (summon_specific_who > 0)
2623 monster_type *sm_ptr = &m_list[summon_specific_who];
2625 if ((sm_ptr->sub_align & SUB_ALIGN_EVIL) && (r_ptr->flags3 & RF3_GOOD)) return FALSE;
2626 if ((sm_ptr->sub_align & SUB_ALIGN_GOOD) && (r_ptr->flags3 & RF3_EVIL)) return FALSE;
2632 static bool monster_hook_chameleon(int r_idx)
2634 monster_race *r_ptr = &r_info[r_idx];
2635 monster_type *m_ptr = &m_list[chameleon_change_m_idx];
2636 monster_race *old_r_ptr = &r_info[m_ptr->r_idx];
2638 if (r_ptr->flags1 & (RF1_UNIQUE)) return FALSE;
2639 if (r_ptr->flags2 & RF2_MULTIPLY) return FALSE;
2640 if (r_ptr->flags7 & (RF7_FRIENDLY | RF7_CHAMELEON)) return FALSE;
2642 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))
2645 if (!monster_can_cross_terrain(cave[m_ptr->fy][m_ptr->fx].feat, r_ptr)) return FALSE;
2648 if (!(old_r_ptr->flags7 & RF7_CHAMELEON))
2650 if ((old_r_ptr->flags3 & RF3_GOOD) && !(r_ptr->flags3 & RF3_GOOD)) return FALSE;
2651 if ((old_r_ptr->flags3 & RF3_EVIL) && !(r_ptr->flags3 & RF3_EVIL)) return FALSE;
2652 if (!(old_r_ptr->flags3 & (RF3_GOOD | RF3_EVIL)) && (r_ptr->flags3 & (RF3_GOOD | RF3_EVIL))) return FALSE;
2656 else if (summon_specific_who > 0)
2658 monster_type *sm_ptr = &m_list[summon_specific_who];
2660 if ((sm_ptr->sub_align & SUB_ALIGN_EVIL) && (r_ptr->flags3 & RF3_GOOD)) return FALSE;
2661 if ((sm_ptr->sub_align & SUB_ALIGN_GOOD) && (r_ptr->flags3 & RF3_EVIL)) return FALSE;
2664 return (*(get_monster_hook()))(r_idx);
2668 void choose_new_monster(int m_idx, bool born, int r_idx)
2671 monster_type *m_ptr = &m_list[m_idx];
2672 monster_race *r_ptr;
2673 char old_m_name[80];
2674 int old_r_idx = m_ptr->r_idx;
2675 bool old_unique = FALSE;
2677 if (r_info[m_ptr->r_idx].flags1 & RF1_UNIQUE)
2679 if (old_unique && (r_idx == MON_CHAMELEON)) r_idx = MON_CHAMELEON_K;
2680 r_ptr = &r_info[r_idx];
2682 monster_desc(old_m_name, m_ptr, 0);
2688 chameleon_change_m_idx = m_idx;
2690 get_mon_num_prep(monster_hook_chameleon_lord, NULL);
2692 get_mon_num_prep(monster_hook_chameleon, NULL);
2695 level = r_info[MON_CHAMELEON_K].level;
2696 else if (!dun_level)
2697 level = wilderness[p_ptr->wilderness_y][p_ptr->wilderness_x].level;
2701 if (d_info[dungeon_type].flags1 & DF1_CHAMELEON) level+= 2+randint1(3);
2703 r_idx = get_mon_num(level);
2704 r_ptr = &r_info[r_idx];
2706 chameleon_change_m_idx = 0;
2712 m_ptr->r_idx = r_idx;
2713 m_ptr->ap_r_idx = r_idx;
2714 update_mon(m_idx, FALSE);
2715 lite_spot(m_ptr->fy, m_ptr->fx);
2718 /* Sub-alignment of a chameleon */
2719 if (r_ptr->flags3 & (RF3_EVIL | RF3_GOOD))
2721 m_ptr->sub_align = SUB_ALIGN_NEUTRAL;
2722 if (r_ptr->flags3 & RF3_EVIL) m_ptr->sub_align |= SUB_ALIGN_EVIL;
2723 if (r_ptr->flags3 & RF3_GOOD) m_ptr->sub_align |= SUB_ALIGN_GOOD;
2728 if (m_idx == p_ptr->riding)
2731 monster_desc(m_name, m_ptr, 0);
2733 msg_format("ÆÍÁ³%s¤¬ÊѿȤ·¤¿¡£", old_m_name);
2735 msg_format("Suddenly, %s transforms!", old_m_name);
2737 if (!(r_ptr->flags7 & RF7_RIDING))
2739 if (rakuba(0, TRUE)) msg_print("ÃÏÌ̤ËÍî¤È¤µ¤ì¤¿¡£");
2741 if (rakuba(0, TRUE)) msg_format("You have fallen from %s.", m_name);
2745 /* Extract the monster base speed */
2746 m_ptr->mspeed = r_ptr->speed;
2747 /* Hack -- small racial variety */
2748 /* Allow some small variation per monster */
2750 i = extract_energy[r_ptr->speed] / 3;
2751 if (i) m_ptr->mspeed += rand_spread(0, i);
2754 i = extract_energy[r_ptr->speed] / 10;
2755 if (i) m_ptr->mspeed += rand_spread(0, i);
2758 oldmaxhp = m_ptr->max_maxhp;
2759 /* Assign maximal hitpoints */
2760 if (r_ptr->flags1 & RF1_FORCE_MAXHP)
2762 m_ptr->max_maxhp = maxroll(r_ptr->hdice, r_ptr->hside);
2766 m_ptr->max_maxhp = damroll(r_ptr->hdice, r_ptr->hside);
2768 m_ptr->maxhp = (long)(m_ptr->maxhp * m_ptr->max_maxhp) / oldmaxhp;
2769 m_ptr->hp = (long)(m_ptr->hp * m_ptr->max_maxhp) / oldmaxhp;
2776 static bool monster_hook_tanuki(int r_idx)
2778 monster_race *r_ptr = &r_info[r_idx];
2780 if (r_ptr->flags1 & (RF1_UNIQUE)) return FALSE;
2781 if (r_ptr->flags2 & RF2_MULTIPLY) return FALSE;
2782 if (r_ptr->flags7 & (RF7_FRIENDLY | RF7_CHAMELEON)) return FALSE;
2783 if (r_ptr->flags7 & RF7_AQUATIC) return FALSE;
2785 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))
2788 return (*(get_monster_hook()))(r_idx);
2793 * Set initial racial appearance of a monster
2795 static int initial_r_appearance(int r_idx)
2797 int attempts = 1000;
2800 int min = MIN(base_level-5, 50);
2802 if (!(r_info[r_idx].flags7 & RF7_TANUKI))
2805 get_mon_num_prep(monster_hook_tanuki, NULL);
2809 ap_r_idx = get_mon_num(base_level + 10);
2810 if (r_info[ap_r_idx].level >= min) return ap_r_idx;
2818 * Attempt to place a monster of the given race at the given location.
2820 * To give the player a sporting chance, any monster that appears in
2821 * line-of-sight and is extremely dangerous can be marked as
2822 * "FORCE_SLEEP", which will cause them to be placed with low energy,
2823 * which often (but not always) lets the player move before they do.
2825 * This routine refuses to place out-of-depth "FORCE_DEPTH" monsters.
2827 * XXX XXX XXX Use special "here" and "dead" flags for unique monsters,
2828 * remove old "cur_num" and "max_num" fields.
2830 * XXX XXX XXX Actually, do something similar for artifacts, to simplify
2831 * the "preserve" mode, and to make the "what artifacts" flag more useful.
2833 * This is the only function which may place a monster in the dungeon,
2834 * except for the savefile loading code.
2836 bool place_monster_one(int who, int y, int x, int r_idx, u32b mode)
2843 monster_type *m_ptr;
2845 monster_race *r_ptr = &r_info[r_idx];
2847 cptr name = (r_name + r_ptr->name);
2849 /* DO NOT PLACE A MONSTER IN THE SMALL SCALE WILDERNESS !!! */
2850 if(p_ptr->wild_mode) return FALSE;
2852 /* Verify location */
2853 if (!in_bounds(y, x)) return (FALSE);
2855 /* Require empty space (if not ghostly) */
2856 if (!(!dun_level && (cave[y][x].feat == FEAT_MOUNTAIN) && ((r_ptr->flags8 & RF8_WILD_MOUNTAIN) || (r_ptr->flags7 & RF7_CAN_FLY))) &&
2857 !(cave_empty_bold2(y, x) || (mode & PM_IGNORE_TERRAIN)) &&
2858 !((r_ptr->flags2 & RF2_PASS_WALL) &&
2859 !(cave_perma_bold(y, x) || cave[y][x].m_idx ||
2860 ((y == py) && (x == px))))) return (FALSE);
2863 if (!r_idx) return (FALSE);
2866 if (!r_ptr->name) return (FALSE);
2868 /* Nor on the Pattern */
2869 if ((cave[y][x].feat >= FEAT_PATTERN_START)
2870 && (cave[y][x].feat <= FEAT_PATTERN_XTRA2))
2873 if (!(mode & PM_IGNORE_TERRAIN) &&
2874 !monster_can_cross_terrain(cave[y][x].feat, r_ptr))
2879 if (!p_ptr->inside_battle)
2881 /* Hack -- "unique" monsters must be "unique" */
2882 if (((r_ptr->flags1 & (RF1_UNIQUE)) ||
2883 (r_ptr->flags7 & (RF7_UNIQUE_7))) &&
2884 (r_ptr->cur_num >= r_ptr->max_num))
2890 if ((r_ptr->flags7 & (RF7_UNIQUE2)) &&
2891 (r_ptr->cur_num >= 1))
2896 if (r_idx == MON_BANORLUPART)
2898 if (r_info[MON_BANOR].cur_num > 0) return FALSE;
2899 if (r_info[MON_LUPART].cur_num > 0) return FALSE;
2902 /* Depth monsters may NOT be created out of depth, unless in Nightmare mode */
2903 if ((r_ptr->flags1 & (RF1_FORCE_DEPTH)) && (dun_level < r_ptr->level) &&
2904 (!ironman_nightmare || (r_ptr->flags1 & (RF1_QUESTOR))))
2911 if(quest_number(dun_level))
2913 int hoge = quest_number(dun_level);
2914 if((quest[hoge].type == QUEST_TYPE_KILL_LEVEL) || (quest[hoge].type == QUEST_TYPE_RANDOM))
2916 if(r_idx == quest[hoge].r_idx)
2918 int number_mon, i2, j2;
2921 /* Count all quest monsters */
2922 for (i2 = 0; i2 < cur_wid; ++i2)
2923 for (j2 = 0; j2 < cur_hgt; j2++)
2924 if (cave[j2][i2].m_idx > 0)
2925 if (m_list[cave[j2][i2].m_idx].r_idx == quest[hoge].r_idx)
2927 if(number_mon + quest[hoge].cur_num >= quest[hoge].max_num)
2933 /* Access the location */
2934 c_ptr = &cave[y][x];
2936 if (is_glyph_grid(c_ptr))
2938 if (randint1(BREAK_GLYPH) < (r_ptr->level+20))
2940 /* Describe observable breakage */
2941 if (c_ptr->info & CAVE_MARK)
2944 msg_print("¼é¤ê¤Î¥ë¡¼¥ó¤¬²õ¤ì¤¿¡ª");
2946 msg_print("The rune of protection is broken!");
2951 /* Forget the rune */
2952 c_ptr->info &= ~(CAVE_MARK);
2954 /* Break the rune */
2955 c_ptr->info &= ~(CAVE_OBJECT);
2965 /* Powerful monster */
2966 if (r_ptr->level > dun_level)
2968 /* Unique monsters */
2969 if (r_ptr->flags1 & (RF1_UNIQUE))
2971 /* Message for cheaters */
2973 if (cheat_hear) msg_format("¿¼ÁؤΥæ¥Ë¡¼¥¯¡¦¥â¥ó¥¹¥¿¡¼ (%s)¡£", name);
2975 if (cheat_hear) msg_format("Deep Unique (%s).", name);
2979 /* Boost rating by twice delta-depth */
2980 rating += (r_ptr->level - dun_level) * 2;
2983 /* Normal monsters */
2986 /* Message for cheaters */
2988 if (cheat_hear) msg_format("¿¼ÁؤΥâ¥ó¥¹¥¿¡¼ (%s)¡£", name);
2990 if (cheat_hear) msg_format("Deep Monster (%s).", name);
2994 /* Boost rating by delta-depth */
2995 rating += (r_ptr->level - dun_level);
2999 /* Note the monster */
3000 else if (r_ptr->flags1 & (RF1_UNIQUE))
3002 /* Unique monsters induce message */
3004 if (cheat_hear) msg_format("¥æ¥Ë¡¼¥¯¡¦¥â¥ó¥¹¥¿¡¼ (%s)¡£", name);
3006 if (cheat_hear) msg_format("Unique (%s).", name);
3011 if ((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags7 & RF7_UNIQUE_7) || (r_ptr->level < 10)) is_kage = FALSE;
3013 /* Make a new monster */
3014 c_ptr->m_idx = m_pop();
3015 hack_m_idx_ii = c_ptr->m_idx;
3017 /* Mega-Hack -- catch "failure" */
3018 if (!c_ptr->m_idx) return (FALSE);
3021 /* Get a new monster record */
3022 m_ptr = &m_list[c_ptr->m_idx];
3025 m_ptr->r_idx = r_idx;
3026 m_ptr->ap_r_idx = initial_r_appearance(r_idx);
3028 /* Sub-alignment of a monster */
3029 if ((who > 0) && !(r_ptr->flags3 & (RF3_EVIL | RF3_GOOD)))
3030 m_ptr->sub_align = m_list[who].sub_align;
3033 m_ptr->sub_align = SUB_ALIGN_NEUTRAL;
3034 if (r_ptr->flags3 & RF3_EVIL) m_ptr->sub_align |= SUB_ALIGN_EVIL;
3035 if (r_ptr->flags3 & RF3_GOOD) m_ptr->sub_align |= SUB_ALIGN_GOOD;
3038 /* Place the monster at the location */
3043 /* No "damage" yet */
3045 m_ptr->confused = 0;
3048 /* Unknown distance */
3051 reset_target(m_ptr);
3053 m_ptr->nickname = 0;
3061 if (r_ptr->flags7 & RF7_CHAMELEON)
3063 choose_new_monster(c_ptr->m_idx, TRUE, 0);
3064 r_ptr = &r_info[m_ptr->r_idx];
3065 m_ptr->mflag2 |= MFLAG_CHAMELEON;
3068 /* Hack - Set sub_align to neutral when the Chameleon Lord is generated as "GUARDIAN" */
3069 if ((r_ptr->flags1 & RF1_UNIQUE) && (who <= 0))
3070 m_ptr->sub_align = SUB_ALIGN_NEUTRAL;
3074 m_ptr->ap_r_idx = MON_KAGE;
3075 m_ptr->mflag2 |= MFLAG_KAGE;
3078 if (mode & PM_NO_PET) m_ptr->mflag2 |= MFLAG_NOPET;
3084 if (mode & PM_FORCE_PET)
3089 else if ((r_ptr->flags7 & RF7_FRIENDLY) ||
3090 (mode & PM_FORCE_FRIENDLY) || is_friendly_idx(who))
3092 if (!(p_ptr->align >= 0 && (r_ptr->flags3 & RF3_EVIL)) &&
3093 !(p_ptr->align < 0 && (r_ptr->flags3 & RF3_GOOD)))
3095 set_friendly(m_ptr);
3099 /* Assume no sleeping */
3102 /* Enforce sleeping if needed */
3103 if ((mode & PM_ALLOW_SLEEP) && r_ptr->sleep && !ironman_nightmare)
3105 int val = r_ptr->sleep;
3106 m_ptr->csleep = ((val * 2) + randint1(val * 10));
3109 /* Assign maximal hitpoints */
3110 if (r_ptr->flags1 & RF1_FORCE_MAXHP)
3112 m_ptr->max_maxhp = maxroll(r_ptr->hdice, r_ptr->hside);
3116 m_ptr->max_maxhp = damroll(r_ptr->hdice, r_ptr->hside);
3119 /* Monsters have double hitpoints in Nightmare mode */
3120 if (ironman_nightmare)
3122 u32b hp = m_ptr->max_maxhp * 2L;
3124 m_ptr->max_maxhp = (s16b)MIN(30000, hp);
3127 m_ptr->maxhp = m_ptr->max_maxhp;
3129 /* And start out fully healthy */
3130 if (m_ptr->r_idx == MON_WOUNDED_BEAR)
3131 m_ptr->hp = m_ptr->maxhp / 2;
3132 else m_ptr->hp = m_ptr->maxhp;
3135 /* Extract the monster base speed */
3136 m_ptr->mspeed = r_ptr->speed;
3138 /* Hack -- small racial variety */
3139 if (!(r_ptr->flags1 & RF1_UNIQUE) && !p_ptr->inside_arena)
3141 /* Allow some small variation per monster */
3143 i = extract_energy[r_ptr->speed] / 3;
3144 if (i) m_ptr->mspeed += rand_spread(0, i);
3147 i = extract_energy[r_ptr->speed] / 10;
3148 if (i) m_ptr->mspeed += rand_spread(0, i);
3152 if (mode & PM_HASTE) m_ptr->fast = 100;
3154 if (m_ptr->mspeed > 199) m_ptr->mspeed = 199;
3156 /* Give a random starting energy */
3157 if (!ironman_nightmare)
3159 m_ptr->energy_need = ENERGY_NEED() - (s16b)randint0(100);
3163 /* Nightmare monsters are more prepared */
3164 m_ptr->energy_need = ENERGY_NEED() - (s16b)randint0(100) * 2;
3167 /* Force monster to wait for player, unless in Nightmare mode */
3168 if ((r_ptr->flags1 & RF1_FORCE_SLEEP) && !ironman_nightmare)
3170 /* Monster is still being nice */
3171 m_ptr->mflag |= (MFLAG_NICE);
3173 /* Must repair monsters */
3174 repair_monsters = TRUE;
3177 /* Hack -- see "process_monsters()" */
3178 if (c_ptr->m_idx < hack_m_idx)
3180 /* Monster is still being born */
3181 m_ptr->mflag |= (MFLAG_BORN);
3185 /* Update the monster */
3186 update_mon(c_ptr->m_idx, TRUE);
3189 /* Hack -- Count the monsters on the level */
3190 if (m_ptr->mflag2 & MFLAG_CHAMELEON)
3191 r_info[r_idx].cur_num++;
3196 /* Hack -- Count the number of "reproducers" */
3197 if (r_ptr->flags2 & RF2_MULTIPLY) num_repro++;
3200 /* Hack -- Notice new multi-hued monsters */
3201 if (r_ptr->flags1 & RF1_ATTR_MULTI) shimmer_monsters = TRUE;
3203 if (p_ptr->warning && character_dungeon)
3205 if (r_ptr->flags1 & RF1_UNIQUE)
3209 char o_name[MAX_NLEN];
3211 if (r_ptr->level > p_ptr->lev + 30)
3217 else if (r_ptr->level > p_ptr->lev + 15)
3223 else if (r_ptr->level > p_ptr->lev + 5)
3225 color = "¥ë¥Ó¡¼¿§¤Ë";
3229 else if (r_ptr->level > p_ptr->lev - 5)
3235 else if (r_ptr->level > p_ptr->lev - 15)
3237 color = "¥Ô¥ó¥¯¿§¤Ë";
3248 o_ptr = choose_warning_item();
3249 object_desc(o_name, o_ptr, FALSE, 0);
3251 msg_format("%s¤Ï%s¸÷¤Ã¤¿¡£",o_name, color);
3253 msg_format("%s glows %s.",o_name, color);
3258 if (is_explosive_rune_grid(c_ptr))
3260 /* Break the ward */
3261 if (randint1(BREAK_MINOR_GLYPH) > r_ptr->level)
3263 /* Describe observable breakage */
3264 if (c_ptr->info & CAVE_MARK)
3267 msg_print("¥ë¡¼¥ó¤¬Çúȯ¤·¤¿¡ª");
3269 msg_print("The rune explodes!");
3272 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);
3278 msg_print("Çúȯ¤Î¥ë¡¼¥ó¤Ï²ò½ü¤µ¤ì¤¿¡£");
3280 msg_print("An explosive rune was disarmed.");
3284 /* Forget the rune */
3285 c_ptr->info &= ~(CAVE_MARK);
3287 /* Break the rune */
3288 c_ptr->info &= ~(CAVE_OBJECT);
3301 * improved version of scatter() for place monster
3304 #define MON_SCAT_MAXD 10
3306 static bool mon_scatter(int *yp, int *xp, int y, int x, int max_dist)
3308 int place_x[MON_SCAT_MAXD];
3309 int place_y[MON_SCAT_MAXD];
3310 int num[MON_SCAT_MAXD];
3314 if (max_dist >= MON_SCAT_MAXD)
3317 for (i = 0; i < MON_SCAT_MAXD; i++)
3320 for (nx = x - max_dist; nx <= x + max_dist; nx++)
3321 for (ny = y - max_dist; ny <= y + max_dist; ny++)
3323 /* Ignore annoying locations */
3324 if (!in_bounds(ny, nx)) continue;
3326 /* Require "line of sight" */
3327 if (!los(y, x, ny, nx)) continue;
3329 /* Walls and Monsters block flow */
3330 if (!cave_empty_bold2(ny, nx)) continue;
3331 if (cave[ny][nx].m_idx) continue;
3332 if ((ny == py) && (nx == px)) continue;
3334 /* ... nor on the Pattern */
3335 if ((cave[ny][nx].feat >= FEAT_PATTERN_START) &&
3336 (cave[ny][nx].feat <= FEAT_PATTERN_XTRA2))
3339 i = distance(y, x, ny, nx);
3356 while (i < MON_SCAT_MAXD && 0 == num[i])
3358 if (i >= MON_SCAT_MAXD)
3369 * Maximum size of a group of monsters
3371 #define GROUP_MAX 32
3375 * Attempt to place a "group" of monsters around the given location
3377 static bool place_monster_group(int who, int y, int x, int r_idx, u32b mode)
3379 monster_race *r_ptr = &r_info[r_idx];
3382 int total = 0, extra = 0;
3386 byte hack_y[GROUP_MAX];
3387 byte hack_x[GROUP_MAX];
3390 /* Pick a group size */
3391 total = randint1(10);
3393 /* Hard monsters, small groups */
3394 if (r_ptr->level > dun_level)
3396 extra = r_ptr->level - dun_level;
3397 extra = 0 - randint1(extra);
3400 /* Easy monsters, large groups */
3401 else if (r_ptr->level < dun_level)
3403 extra = dun_level - r_ptr->level;
3404 extra = randint1(extra);
3407 /* Hack -- limit group reduction */
3408 if (extra > 9) extra = 9;
3410 /* Modify the group size */
3414 if (total < 1) total = 1;
3417 if (total > GROUP_MAX) total = GROUP_MAX;
3420 /* Save the rating */
3423 /* Start on the monster */
3428 /* Puddle monsters, breadth first, up to total */
3429 for (n = 0; (n < hack_n) && (hack_n < total); n++)
3431 /* Grab the location */
3435 /* Check each direction, up to total */
3436 for (i = 0; (i < 8) && (hack_n < total); i++)
3440 scatter(&my, &mx, hy, hx, 4, 0);
3442 /* Walls and Monsters block flow */
3443 if (!cave_empty_bold2(my, mx)) continue;
3445 /* Attempt to place another monster */
3446 if (place_monster_one(who, my, mx, r_idx, mode))
3448 /* Add it to the "hack" set */
3449 hack_y[hack_n] = my;
3450 hack_x[hack_n] = mx;
3456 /* Hack -- restore the rating */
3466 * Hack -- help pick an escort type
3468 static int place_monster_idx = 0;
3469 static int place_monster_m_idx = 0;
3472 * Hack -- help pick an escort type
3474 static bool place_monster_okay(int r_idx)
3476 monster_race *r_ptr = &r_info[place_monster_idx];
3477 monster_type *m_ptr = &m_list[place_monster_m_idx];
3479 monster_race *z_ptr = &r_info[r_idx];
3481 /* Hack - Escorts have to have the same dungeon flag */
3482 if (monster_dungeon(place_monster_idx) != monster_dungeon(r_idx)) return (FALSE);
3484 /* Require similar "race" */
3485 if (z_ptr->d_char != r_ptr->d_char) return (FALSE);
3487 /* Skip more advanced monsters */
3488 if (z_ptr->level > r_ptr->level) return (FALSE);
3490 /* Skip unique monsters */
3491 if (z_ptr->flags1 & RF1_UNIQUE) return (FALSE);
3493 /* Paranoia -- Skip identical monsters */
3494 if (place_monster_idx == r_idx) return (FALSE);
3496 /* Skip different alignment */
3497 if (((m_ptr->sub_align & SUB_ALIGN_EVIL) && (z_ptr->flags3 & RF3_GOOD)) ||
3498 ((m_ptr->sub_align & SUB_ALIGN_GOOD) && (z_ptr->flags3 & RF3_EVIL)))
3501 if (r_ptr->flags7 & RF7_FRIENDLY)
3503 if (((p_ptr->align < 0) && (z_ptr->flags3 & RF3_GOOD)) ||
3504 ((p_ptr->align > 0) && (z_ptr->flags3 & RF3_EVIL)))
3508 if ((r_ptr->flags7 & RF7_CHAMELEON) && !(z_ptr->flags7 & RF7_CHAMELEON))
3517 * Attempt to place a monster of the given race at the given location
3519 * Note that certain monsters are now marked as requiring "friends".
3520 * These monsters, if successfully placed, and if the "grp" parameter
3521 * is TRUE, will be surrounded by a "group" of identical monsters.
3523 * Note that certain monsters are now marked as requiring an "escort",
3524 * which is a collection of monsters with similar "race" but lower level.
3526 * Some monsters induce a fake "group" flag on their escorts.
3528 * Note the "bizarre" use of non-recursion to prevent annoying output
3529 * when running a code profiler.
3531 * Note the use of the new "monster allocation table" code to restrict
3532 * the "get_mon_num()" function to "legal" escort types.
3534 bool place_monster_aux(int who, int y, int x, int r_idx, u32b mode)
3537 monster_race *r_ptr = &r_info[r_idx];
3539 if (one_in_(333) && !(mode & PM_NO_KAGE) && !(mode & PM_FORCE_PET))
3544 /* Place one monster, or fail */
3545 if (!place_monster_one(who, y, x, r_idx, mode)) return (FALSE);
3548 /* Require the "group" flag */
3549 if (!(mode & PM_ALLOW_GROUP)) return (TRUE);
3551 place_monster_m_idx = hack_m_idx_ii;
3553 /* Friends for certain monsters */
3554 if (r_ptr->flags1 & (RF1_FRIENDS))
3556 /* Attempt to place a group */
3557 (void)place_monster_group(who, y, x, r_idx, mode);
3561 /* Escorts for certain monsters */
3562 if (r_ptr->flags1 & (RF1_ESCORT))
3564 /* Set the escort index */
3565 place_monster_idx = r_idx;
3567 /* Try to place several "escorts" */
3568 for (i = 0; i < 32; i++)
3570 int nx, ny, z, d = 3;
3572 /* Pick a location */
3573 scatter(&ny, &nx, y, x, d, 0);
3575 /* Require empty grids */
3576 if (!cave_empty_bold2(ny, nx)) continue;
3578 /* Prepare allocation table */
3579 get_mon_num_prep(place_monster_okay, get_monster_hook2(ny, nx));
3581 /* Pick a random race */
3582 z = get_mon_num(r_ptr->level);
3584 /* Handle failure */
3587 /* Place a single escort */
3588 (void)place_monster_one(place_monster_m_idx, ny, nx, z, mode);
3590 /* Place a "group" of escorts if needed */
3591 if ((r_info[z].flags1 & RF1_FRIENDS) ||
3592 (r_ptr->flags1 & RF1_ESCORTS))
3594 /* Place a group of monsters */
3595 (void)place_monster_group(place_monster_m_idx, ny, nx, z, mode);
3606 * Hack -- attempt to place a monster at the given location
3608 * Attempt to find a monster appropriate to the "monster_level"
3610 bool place_monster(int y, int x, u32b mode)
3614 /* Prepare allocation table */
3615 get_mon_num_prep(get_monster_hook(), get_monster_hook2(y, x));
3617 /* Pick a monster */
3618 r_idx = get_mon_num(monster_level);
3620 /* Handle failure */
3621 if (!r_idx) return (FALSE);
3623 /* Attempt to place the monster */
3624 if (place_monster_aux(0, y, x, r_idx, mode)) return (TRUE);
3631 #ifdef MONSTER_HORDES
3633 bool alloc_horde(int y, int x)
3635 monster_race *r_ptr = NULL;
3638 int attempts = 1000;
3642 /* Prepare allocation table */
3643 get_mon_num_prep(get_monster_hook(), get_monster_hook2(y, x));
3647 /* Pick a monster */
3648 r_idx = get_mon_num(monster_level);
3650 /* Handle failure */
3651 if (!r_idx) return (FALSE);
3653 r_ptr = &r_info[r_idx];
3655 if (r_ptr->flags1 & RF1_UNIQUE) continue;
3657 if (r_idx == MON_HAGURE) continue;
3660 if (attempts < 1) return FALSE;
3662 if (r_ptr->flags3 & RF3_GOOD) horde_align |= HORDE_NOEVIL;
3663 if (r_ptr->flags3 & RF3_EVIL) horde_align |= HORDE_NOGOOD;
3669 /* Attempt to place the monster */
3670 if (place_monster_aux(0, y, x, r_idx, 0L)) break;
3673 if (attempts < 1) {horde_align = 0;return FALSE;}
3675 m_idx = cave[y][x].m_idx;
3677 if (m_list[m_idx].mflag2 & MFLAG_CHAMELEON) r_ptr = &r_info[m_list[m_idx].r_idx];
3678 summon_kin_type = r_ptr->d_char;
3680 for (attempts = randint1(10) + 5; attempts; attempts--)
3682 scatter(&cy, &cx, y, x, 5, 0);
3684 (void)summon_specific(m_idx, cy, cx, dun_level + 5, SUMMON_KIN, PM_ALLOW_GROUP);
3694 #endif /* MONSTER_HORDES */
3699 * Attempt to allocate a random monster in the dungeon.
3701 * Place the monster at least "dis" distance from the player.
3703 * Use "slp" to choose the initial "sleep" status
3705 * Use "monster_level" for the monster level
3707 bool alloc_monster(int dis, u32b mode)
3710 int attempts_left = 10000;
3711 int guardian = d_info[dungeon_type].final_guardian;
3713 /* Put an Guardian */
3714 if(guardian && d_info[dungeon_type].maxdepth == dun_level && r_info[guardian].cur_num < r_info[guardian].max_num )
3720 /* Find a good position */
3723 /* Get a random spot */
3724 oy = randint1(cur_hgt - 4) + 2;
3725 ox = randint1(cur_wid - 4) + 2;
3727 /* Is it a good spot ? */
3728 if (cave_empty_bold2(oy, ox) && monster_can_cross_terrain(cave[oy][ox].feat, &r_info[guardian]))
3730 /* Place the guardian */
3731 if (place_monster_aux(0, oy, ox, guardian, (PM_ALLOW_GROUP | PM_NO_KAGE | PM_NO_PET))) break;
3739 /* Find a legal, distant, unoccupied, space */
3740 while (attempts_left--)
3742 /* Pick a location */
3743 y = randint0(cur_hgt);
3744 x = randint0(cur_wid);
3746 /* Require empty floor grid (was "naked") */
3747 if (dun_level || (wilderness[p_ptr->wilderness_y][p_ptr->wilderness_x].terrain != TERRAIN_MOUNTAIN))
3749 if (!cave_empty_bold2(y, x)) continue;
3753 if (!cave_empty_bold2(y, x) && (cave[y][x].feat != FEAT_MOUNTAIN)) continue;
3756 /* Accept far away grids */
3757 if (distance(y, x, py, px) > dis) break;
3762 if (cheat_xtra || cheat_hear)
3765 msg_print("·Ù¹ð¡ª¿·¤¿¤Ê¥â¥ó¥¹¥¿¡¼¤òÇÛÃ֤Ǥ¤Þ¤»¤ó¡£¾®¤µ¤¤³¬¤Ç¤¹¤«¡©");
3767 msg_print("Warning! Could not allocate a new monster. Small level?");
3776 #ifdef MONSTER_HORDES
3777 if (randint1(5000) <= dun_level)
3779 if (alloc_horde(y, x))
3782 if (cheat_hear) msg_print("¥â¥ó¥¹¥¿¡¼¤ÎÂç·²");
3784 if (cheat_hear) msg_print("Monster horde.");
3792 #endif /* MONSTER_HORDES */
3794 /* Attempt to place the monster, allow groups */
3795 if (place_monster(y, x, (mode | PM_ALLOW_GROUP))) return (TRUE);
3797 #ifdef MONSTER_HORDES
3799 #endif /* MONSTER_HORDES */
3809 * Hack -- help decide if a monster race is "okay" to summon
3811 static bool summon_specific_okay(int r_idx)
3813 monster_race *r_ptr = &r_info[r_idx];
3815 /* Hack - Only summon dungeon monsters */
3816 if (!monster_dungeon(r_idx)) return (FALSE);
3818 /* Hack -- identify the summoning monster */
3819 if (summon_specific_who > 0)
3821 monster_type *m_ptr = &m_list[summon_specific_who];
3823 /* Do not summon enemies */
3825 /* Friendly vs. opposite aligned normal or pet */
3826 if (((r_ptr->flags3 & RF3_EVIL) &&
3827 (m_ptr->sub_align & SUB_ALIGN_GOOD)) ||
3828 ((r_ptr->flags3 & RF3_GOOD) &&
3829 (m_ptr->sub_align & SUB_ALIGN_EVIL)))
3834 /* Hostile vs. non-hostile */
3835 if (is_hostile(m_ptr) != summon_specific_hostile)
3840 /* Use the player's alignment */
3841 else if (summon_specific_who < 0)
3843 /* Do not summon enemies of the pets */
3844 if ((p_ptr->align < -9) && (r_ptr->flags3 & RF3_GOOD))
3846 if (!one_in_((0-p_ptr->align)/2+1)) return FALSE;
3848 else if ((p_ptr->align > 9) && (r_ptr->flags3 & RF3_EVIL))
3850 if (!one_in_(p_ptr->align/2+1)) return FALSE;
3854 /* Hack -- no specific type specified */
3855 if (!summon_specific_type) return (TRUE);
3857 if (!summon_unique_okay && ((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags7 & RF7_UNIQUE_7))) return FALSE;
3859 if ((summon_specific_who < 0) &&
3860 ((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags7 & RF7_UNIQUE_7)) &&
3861 (((p_ptr->align > 9) && (r_ptr->flags3 & RF3_EVIL)) ||
3862 ((p_ptr->align < -9) && (r_ptr->flags3 & RF3_GOOD))))
3865 if ((horde_align & HORDE_NOGOOD) && (r_ptr->flags3 & RF3_GOOD)) return FALSE;
3866 if ((horde_align & HORDE_NOEVIL) && (r_ptr->flags3 & RF3_EVIL)) return FALSE;
3868 if ((r_ptr->flags7 & RF7_CHAMELEON) && (d_info[dungeon_type].flags1 & DF1_CHAMELEON)) return TRUE;
3870 return (summon_specific_aux(r_idx));
3875 * Place a monster (of the specified "type") near the given
3876 * location. Return TRUE if a monster was actually summoned.
3878 * We will attempt to place the monster up to 10 times before giving up.
3880 * Note: SUMMON_UNIQUE and SUMMON_AMBERITES will summon Unique's
3881 * Note: SUMMON_HI_UNDEAD and SUMMON_HI_DRAGON may summon Unique's
3882 * Note: None of the other summon codes will ever summon Unique's.
3884 * This function has been changed. We now take the "monster level"
3885 * of the summoning monster as a parameter, and use that, along with
3886 * the current dungeon level, to help determine the level of the
3887 * desired monster. Note that this is an upper bound, and also
3888 * tends to "prefer" monsters of that level. Currently, we use
3889 * the average of the dungeon and monster levels, and then add
3890 * five to allow slight increases in monster power.
3892 * Note that we use the new "monster allocation table" creation code
3893 * to restrict the "get_mon_num()" function to the set of "legal"
3894 * monsters, making this function much faster and more reliable.
3896 * Note that this function may not succeed, though this is very rare.
3898 bool summon_specific(int who, int y1, int x1, int lev, int type, u32b mode)
3902 if (p_ptr->inside_arena) return (FALSE);
3904 if (!mon_scatter(&y, &x, y1, x1, 2)) return FALSE;
3906 /* Save the summoner */
3907 summon_specific_who = who;
3909 /* Save the "summon" type */
3910 summon_specific_type = type;
3912 summon_unique_okay = (mode & PM_ALLOW_UNIQUE) ? TRUE : FALSE;
3914 /* Save the hostility */
3915 summon_specific_hostile = (!(mode & PM_FORCE_FRIENDLY) && !(is_friendly_idx(who)) && !(mode & PM_FORCE_PET));
3917 /* Prepare allocation table */
3918 get_mon_num_prep(summon_specific_okay, get_monster_hook2(y, x));
3920 /* Pick a monster, using the level calculation */
3921 r_idx = get_mon_num((dun_level + lev) / 2 + 5);
3923 /* Handle failure */
3926 summon_specific_type = 0;
3930 if ((type == SUMMON_BLUE_HORROR) || (type == SUMMON_DAWN)) mode |= PM_NO_KAGE;
3932 /* Attempt to place the monster (awake, allow groups) */
3933 if (!place_monster_aux(who, y, x, r_idx, mode))
3935 summon_specific_type = 0;
3939 summon_specific_type = 0;
3944 /* A "dangerous" function, creates a pet of the specified type */
3945 bool summon_named_creature (int who, int oy, int ox, int r_idx, u32b mode)
3950 /* if (!r_idx) return; */
3952 /* Prevent illegal monsters */
3953 if (r_idx >= max_r_idx) return FALSE;
3955 if (p_ptr->inside_arena) return FALSE;
3957 if (!mon_scatter(&y, &x, oy, ox, 2)) return FALSE;
3959 /* Place it (allow groups) */
3960 return place_monster_aux(who, y, x, r_idx, (mode | PM_NO_KAGE));
3965 * Let the given monster attempt to reproduce.
3967 * Note that "reproduction" REQUIRES empty space.
3969 bool multiply_monster(int m_idx, bool clone, u32b mode)
3971 monster_type *m_ptr = &m_list[m_idx];
3975 if (!mon_scatter(&y, &x, m_ptr->fy, m_ptr->fx, 1))
3978 if (m_ptr->mflag2 & MFLAG_NOPET) mode |= PM_NO_PET;
3980 /* Create a new monster (awake, no groups) */
3981 if (!place_monster_aux(m_idx, y, x, m_ptr->r_idx, (mode | PM_NO_KAGE)))
3986 m_list[hack_m_idx_ii].smart |= SM_CLONED;
3987 m_list[hack_m_idx_ii].mflag2 |= MFLAG_NOPET;
3998 * Dump a message describing a monster's reaction to damage
4000 * Technically should attempt to treat "Beholder"'s as jelly's
4002 void message_pain(int m_idx, int dam)
4004 long oldhp, newhp, tmp;
4007 monster_type *m_ptr = &m_list[m_idx];
4008 monster_race *r_ptr = &r_info[m_ptr->r_idx];
4013 /* Get the monster name */
4014 monster_desc(m_name, m_ptr, 0);
4016 /* Notice non-damage */
4020 msg_format("%^s¤Ï¥À¥á¡¼¥¸¤ò¼õ¤±¤Æ¤¤¤Ê¤¤¡£", m_name);
4022 msg_format("%^s is unharmed.", m_name);
4028 /* Note -- subtle fix -CFT */
4029 newhp = (long)(m_ptr->hp);
4030 oldhp = newhp + (long)(dam);
4031 tmp = (newhp * 100L) / oldhp;
4032 percentage = (int)(tmp);
4035 /* Mushrooms, Eyes, Jellies, Molds, Vortices, Worms, Quylthulgs */
4036 if (strchr(",ejmvwQ", r_ptr->d_char))
4039 if (percentage > 95)
4040 msg_format("%^s¤Ï¤Û¤È¤ó¤Éµ¤¤Ë¤È¤á¤Æ¤¤¤Ê¤¤¡£", m_name);
4041 else if (percentage > 75)
4042 msg_format("%^s¤Ï¤·¤ê¹þ¤ß¤·¤¿¡£", m_name);
4043 else if (percentage > 50)
4044 msg_format("%^s¤Ï½Ì¤³¤Þ¤Ã¤¿¡£", m_name);
4045 else if (percentage > 35)
4046 msg_format("%^s¤ÏÄˤߤ˿̤¨¤¿¡£", m_name);
4047 else if (percentage > 20)
4048 msg_format("%^s¤Ï¿È¤â¤À¤¨¤·¤¿¡£", m_name);
4049 else if (percentage > 10)
4050 msg_format("%^s¤Ï¶ìÄˤǿȤâ¤À¤¨¤·¤¿¡£", m_name);
4052 msg_format("%^s¤Ï¤°¤Ë¤ã¤°¤Ë¤ã¤ÈáÛÚ»¤·¤¿¡£", m_name);
4054 if (percentage > 95)
4055 msg_format("%^s barely notices.", m_name);
4056 else if (percentage > 75)
4057 msg_format("%^s flinches.", m_name);
4058 else if (percentage > 50)
4059 msg_format("%^s squelches.", m_name);
4060 else if (percentage > 35)
4061 msg_format("%^s quivers in pain.", m_name);
4062 else if (percentage > 20)
4063 msg_format("%^s writhes about.", m_name);
4064 else if (percentage > 10)
4065 msg_format("%^s writhes in agony.", m_name);
4067 msg_format("%^s jerks limply.", m_name);
4074 else if (strchr("l", r_ptr->d_char))
4076 if (percentage > 95)
4078 msg_format("%^s¤Ï¤Û¤È¤ó¤Éµ¤¤Ë¤È¤á¤Æ¤¤¤Ê¤¤¡£", m_name);
4080 msg_format("%^s barely notices.", m_name);
4082 else if (percentage > 75)
4084 msg_format("%^s¤Ï¤·¤ê¹þ¤ß¤·¤¿¡£", m_name);
4086 msg_format("%^s flinches.", m_name);
4088 else if (percentage > 50)
4090 msg_format("%^s¤Ïí´í°¤·¤¿¡£", m_name);
4092 msg_format("%^s hesitates.", m_name);
4094 else if (percentage > 35)
4096 msg_format("%^s¤ÏÄˤߤ˿̤¨¤¿¡£", m_name);
4098 msg_format("%^s quivers in pain.", m_name);
4100 else if (percentage > 20)
4102 msg_format("%^s¤Ï¿È¤â¤À¤¨¤·¤¿¡£", m_name);
4104 msg_format("%^s writhes about.", m_name);
4106 else if (percentage > 10)
4108 msg_format("%^s¤Ï¶ìÄˤǿȤâ¤À¤¨¤·¤¿¡£", m_name);
4110 msg_format("%^s writhes in agony.", m_name);
4114 msg_format("%^s¤Ï¤°¤Ë¤ã¤°¤Ë¤ã¤ÈáÛÚ»¤·¤¿¡£", m_name);
4116 msg_format("%^s jerks limply.", m_name);
4121 /* Golems, Walls, Doors, Stairs */
4122 else if (strchr("g#+<>", r_ptr->d_char))
4124 if (percentage > 95)
4126 msg_format("%s¤Ï¹¶·â¤òµ¤¤Ë¤È¤á¤Æ¤¤¤Ê¤¤¡£", m_name);
4128 msg_format("%^s ignores the attack.", m_name);
4130 else if (percentage > 75)
4132 msg_format("%s¤Ï¹¶·â¤Ë¸ª¤ò¤¹¤¯¤á¤¿¡£", m_name);
4134 msg_format("%^s shrugs off the attack.", m_name);
4136 else if (percentage > 50)
4138 msg_format("%^s¤ÏÍëÌĤΤ褦¤ËËʤ¨¤¿¡£", m_name);
4140 msg_format("%^s roars thunderously.", m_name);
4142 else if (percentage > 35)
4144 msg_format("%^s¤Ï¶ì¤·¤²¤ËËʤ¨¤¿¡£", m_name);
4146 msg_format("%^s rumbles.", m_name);
4148 else if (percentage > 20)
4150 msg_format("%^s¤Ï¤¦¤á¤¤¤¿¡£", m_name);
4152 msg_format("%^s grunts.", m_name);
4154 else if (percentage > 10)
4156 msg_format("%^s¤Ïí´í°¤·¤¿¡£", m_name);
4158 msg_format("%^s hesitates.", m_name);
4162 msg_format("%^s¤Ï¤¯¤·¤ã¤¯¤·¤ã¤Ë¤Ê¤Ã¤¿¡£", m_name);
4164 msg_format("%^s crumples.", m_name);
4169 /* Snakes, Hydrae, Reptiles, Mimics */
4170 else if (strchr("JMR", r_ptr->d_char) || !isalpha(r_ptr->d_char))
4172 if (percentage > 95)
4174 msg_format("%^s¤Ï¤Û¤È¤ó¤Éµ¤¤Ë¤È¤á¤Æ¤¤¤Ê¤¤¡£", m_name);
4176 msg_format("%^s barely notices.", m_name);
4178 else if (percentage > 75)
4180 msg_format("%^s¤Ï¥·¡¼¥Ã¤ÈÌĤ¤¤¿¡£", m_name);
4182 msg_format("%^s hisses.", m_name);
4184 else if (percentage > 50)
4186 msg_format("%^s¤ÏÅܤäÆƬ¤ò¾å¤²¤¿¡£", m_name);
4188 msg_format("%^s rears up in anger.", m_name);
4190 else if (percentage > 35)
4192 msg_format("%^s¤ÏÌÔÁ³¤È°Ò³Å¤·¤¿¡£", m_name);
4194 msg_format("%^s hisses furiously.", m_name);
4196 else if (percentage > 20)
4198 msg_format("%^s¤Ï¿È¤â¤À¤¨¤·¤¿¡£", m_name);
4200 msg_format("%^s writhes about.", m_name);
4202 else if (percentage > 10)
4204 msg_format("%^s¤Ï¶ìÄˤǿȤâ¤À¤¨¤·¤¿¡£", m_name);
4206 msg_format("%^s writhes in agony.", m_name);
4210 msg_format("%^s¤Ï¤°¤Ë¤ã¤°¤Ë¤ã¤ÈáÛÚ»¤·¤¿¡£", m_name);
4212 msg_format("%^s jerks limply.", m_name);
4218 else if (strchr("f", r_ptr->d_char))
4220 if (percentage > 95)
4222 msg_format("%s¤Ï¹¶·â¤Ë¸ª¤ò¤¹¤¯¤á¤¿¡£", m_name);
4224 msg_format("%^s shrugs off the attack.", m_name);
4226 else if (percentage > 75)
4228 msg_format("%^s¤ÏËʤ¨¤¿¡£", m_name);
4230 msg_format("%^s roars.", m_name);
4232 else if (percentage > 50)
4234 msg_format("%^s¤ÏÅܤäÆËʤ¨¤¿¡£", m_name);
4236 msg_format("%^s growls angrily.", m_name);
4238 else if (percentage > 35)
4240 msg_format("%^s¤ÏÄˤߤǥ·¡¼¥Ã¤ÈÌĤ¤¤¿¡£", m_name);
4242 msg_format("%^s hisses with pain.", m_name);
4244 else if (percentage > 20)
4246 msg_format("%^s¤ÏÄˤߤǼ塹¤·¤¯ÌĤ¤¤¿¡£", m_name);
4248 msg_format("%^s mewls in pain.", m_name);
4250 else if (percentage > 10)
4252 msg_format("%^s¤Ï¶ìÄˤˤ¦¤á¤¤¤¿¡£", m_name);
4254 msg_format("%^s hisses in agony.", m_name);
4258 msg_format("%s¤Ï°¥¤ì¤ÊÌĤÀ¼¤ò½Ð¤·¤¿¡£", m_name);
4260 msg_format("%^s mewls pitifully.", m_name);
4265 /* Ants, Centipedes, Flies, Insects, Beetles, Spiders */
4266 else if (strchr("acFIKS", r_ptr->d_char))
4268 if (percentage > 95)
4270 msg_format("%s¤Ï¹¶·â¤òµ¤¤Ë¤È¤á¤Æ¤¤¤Ê¤¤¡£", m_name);
4272 msg_format("%^s ignores the attack.", m_name);
4274 else if (percentage > 75)
4276 msg_format("%^s¤Ï¥¡¼¥¡¼ÌĤ¤¤¿¡£", m_name);
4278 msg_format("%^s chitters.", m_name);
4281 else if (percentage > 50)
4283 msg_format("%^s¤Ï¥è¥í¥è¥íƨ¤²²ó¤Ã¤¿¡£", m_name);
4285 msg_format("%^s scuttles about.", m_name);
4288 else if (percentage > 35)
4290 msg_format("%^s¤Ï¤¦¤ë¤µ¤¯ÌĤ¤¤¿¡£", m_name);
4292 msg_format("%^s twitters.", m_name);
4295 else if (percentage > 20)
4297 msg_format("%^s¤ÏÄˤߤËáÛÚ»¤·¤¿¡£", m_name);
4299 msg_format("%^s jerks in pain.", m_name);
4302 else if (percentage > 10)
4304 msg_format("%^s¤Ï¶ìÄˤÇáÛÚ»¤·¤¿¡£", m_name);
4306 msg_format("%^s jerks in agony.", m_name);
4311 msg_format("%^s¤Ï¥Ô¥¯¥Ô¥¯¤Ò¤¤Ä¤Ã¤¿¡£", m_name);
4313 msg_format("%^s twitches.", m_name);
4320 else if (strchr("B", r_ptr->d_char))
4322 if (percentage > 95)
4324 msg_format("%^s¤Ï¤µ¤¨¤º¤Ã¤¿¡£", m_name);
4326 msg_format("%^s chirps.", m_name);
4329 else if (percentage > 75)
4331 msg_format("%^s¤Ï¥Ô¡¼¥Ô¡¼ÌĤ¤¤¿¡£", m_name);
4333 msg_format("%^s twitters.", m_name);
4336 else if (percentage > 50)
4338 msg_format("%^s¤Ï¥®¥ã¡¼¥®¥ã¡¼ÌĤ¤¤¿¡£", m_name);
4340 msg_format("%^s squawks.", m_name);
4343 else if (percentage > 35)
4345 msg_format("%^s¤Ï¥®¥ã¡¼¥®¥ã¡¼ÌĤ¤ï¤á¤¤¤¿¡£", m_name);
4347 msg_format("%^s chatters.", m_name);
4350 else if (percentage > 20)
4352 msg_format("%^s¤Ï¶ì¤·¤ó¤À¡£", m_name);
4354 msg_format("%^s jeers.", m_name);
4357 else if (percentage > 10)
4359 msg_format("%^s¤Ï¤Î¤¿¤¦¤Á²ó¤Ã¤¿¡£", m_name);
4361 msg_format("%^s flutters about.", m_name);
4366 msg_format("%^s¤Ï¥¡¼¥¡¼¤ÈÌĤ¶«¤ó¤À¡£", m_name);
4368 msg_format("%^s squeaks.", m_name);
4374 /* Dragons, Demons, High Undead */
4375 else if (strchr("duDLUW", r_ptr->d_char))
4377 if (percentage > 95)
4379 msg_format("%s¤Ï¹¶·â¤òµ¤¤Ë¤È¤á¤Æ¤¤¤Ê¤¤¡£", m_name);
4381 msg_format("%^s ignores the attack.", m_name);
4384 else if (percentage > 75)
4386 msg_format("%^s¤Ï¤·¤ê¹þ¤ß¤·¤¿¡£", m_name);
4388 msg_format("%^s flinches.", m_name);
4391 else if (percentage > 50)
4393 msg_format("%^s¤ÏÄˤߤǥ·¡¼¥Ã¤ÈÌĤ¤¤¿¡£", m_name);
4395 msg_format("%^s hisses in pain.", m_name);
4398 else if (percentage > 35)
4400 msg_format("%^s¤ÏÄˤߤǤ¦¤Ê¤Ã¤¿¡£", m_name);
4402 msg_format("%^s snarls with pain.", m_name);
4405 else if (percentage > 20)
4407 msg_format("%^s¤ÏÄˤߤËËʤ¨¤¿¡£", m_name);
4409 msg_format("%^s roars with pain.", m_name);
4412 else if (percentage > 10)
4414 msg_format("%^s¤Ï¶ì¤·¤²¤Ë¶«¤ó¤À¡£", m_name);
4416 msg_format("%^s gasps.", m_name);
4421 msg_format("%^s¤Ï¼å¡¹¤·¤¯¤¦¤Ê¤Ã¤¿¡£", m_name);
4423 msg_format("%^s snarls feebly.", m_name);
4430 else if (strchr("s", r_ptr->d_char))
4432 if (percentage > 95)
4434 msg_format("%s¤Ï¹¶·â¤òµ¤¤Ë¤È¤á¤Æ¤¤¤Ê¤¤¡£", m_name);
4436 msg_format("%^s ignores the attack.", m_name);
4439 else if (percentage > 75)
4441 msg_format("%s¤Ï¹¶·â¤Ë¸ª¤ò¤¹¤¯¤á¤¿¡£", m_name);
4443 msg_format("%^s shrugs off the attack.", m_name);
4446 else if (percentage > 50)
4448 msg_format("%^s¤Ï¥«¥¿¥«¥¿¤È¾Ð¤Ã¤¿¡£", m_name);
4450 msg_format("%^s rattles.", m_name);
4453 else if (percentage > 35)
4455 msg_format("%^s¤Ï¤è¤í¤á¤¤¤¿¡£", m_name);
4457 msg_format("%^s stumbles.", m_name);
4460 else if (percentage > 20)
4462 msg_format("%^s¤Ï¥«¥¿¥«¥¿¸À¤Ã¤¿¡£", m_name);
4464 msg_format("%^s rattles.", m_name);
4467 else if (percentage > 10)
4469 msg_format("%^s¤Ï¤è¤í¤á¤¤¤¿¡£", m_name);
4471 msg_format("%^s staggers.", m_name);
4476 msg_format("%^s¤Ï¥¬¥¿¥¬¥¿¸À¤Ã¤¿¡£", m_name);
4478 msg_format("%^s clatters.", m_name);
4485 else if (strchr("z", r_ptr->d_char))
4487 if (percentage > 95)
4489 msg_format("%s¤Ï¹¶·â¤òµ¤¤Ë¤È¤á¤Æ¤¤¤Ê¤¤¡£", m_name);
4491 msg_format("%^s ignores the attack.", m_name);
4494 else if (percentage > 75)
4496 msg_format("%s¤Ï¹¶·â¤Ë¸ª¤ò¤¹¤¯¤á¤¿¡£", m_name);
4498 msg_format("%^s shrugs off the attack.", m_name);
4501 else if (percentage > 50)
4503 msg_format("%^s¤Ï¤¦¤á¤¤¤¿¡£", m_name);
4505 msg_format("%^s groans.", m_name);
4508 else if (percentage > 35)
4510 msg_format("%s¤Ï¶ì¤·¤²¤Ë¤¦¤á¤¤¤¿¡£", m_name);
4512 msg_format("%^s moans.", m_name);
4515 else if (percentage > 20)
4517 msg_format("%^s¤Ïí´í°¤·¤¿¡£", m_name);
4519 msg_format("%^s hesitates.", m_name);
4522 else if (percentage > 10)
4524 msg_format("%^s¤Ï¤¦¤Ê¤Ã¤¿¡£", m_name);
4526 msg_format("%^s grunts.", m_name);
4531 msg_format("%^s¤Ï¤è¤í¤á¤¤¤¿¡£", m_name);
4533 msg_format("%^s staggers.", m_name);
4540 else if (strchr("G", r_ptr->d_char))
4543 if (percentage > 95)
4545 msg_format("%s¤Ï¹¶·â¤òµ¤¤Ë¤È¤á¤Æ¤¤¤Ê¤¤¡£", m_name);
4547 msg_format("%^s ignores the attack.", m_name);
4550 else if (percentage > 75)
4552 msg_format("%s¤Ï¹¶·â¤Ë¸ª¤ò¤¹¤¯¤á¤¿¡£", m_name);
4554 msg_format("%^s shrugs off the attack.", m_name);
4557 else if (percentage > 50)
4559 msg_format("%s¤Ï¤¦¤á¤¤¤¿¡£", m_name);
4561 msg_format("%^s moans.", m_name);
4564 else if (percentage > 35)
4566 msg_format("%^s¤Ïµã¤¤ï¤á¤¤¤¿¡£", m_name);
4568 msg_format("%^s wails.", m_name);
4571 else if (percentage > 20)
4573 msg_format("%^s¤ÏËʤ¨¤¿¡£", m_name);
4575 msg_format("%^s howls.", m_name);
4578 else if (percentage > 10)
4580 msg_format("%s¤Ï¼å¡¹¤·¤¯¤¦¤á¤¤¤¿¡£", m_name);
4582 msg_format("%^s moans softly.", m_name);
4587 msg_format("%^s¤Ï¤«¤¹¤«¤Ë¤¦¤á¤¤¤¿¡£", m_name);
4589 msg_format("%^s sighs.", m_name);
4595 /* Dogs and Hounds */
4596 else if (strchr("CZ", r_ptr->d_char))
4599 if (percentage > 95)
4600 msg_format("%^s¤Ï¹¶·â¤Ë¸ª¤ò¤¹¤¯¤á¤¿¡£", m_name);
4601 else if (percentage > 75)
4602 msg_format("%^s¤ÏÄˤߤǤ¦¤Ê¤Ã¤¿¡£", m_name);
4603 else if (percentage > 50)
4604 msg_format("%^s¤ÏÄˤߤǥ¥ã¥ó¥¥ã¥óËʤ¨¤¿¡£", m_name);
4605 else if (percentage > 35)
4606 msg_format("%^s¤ÏÄˤߤÇÌĤ¤ï¤á¤¤¤¿¡£", m_name);
4607 else if (percentage > 20)
4608 msg_format("%^s¤Ï¶ìÄˤΤ¢¤Þ¤êÌĤ¤ï¤á¤¤¤¿¡£", m_name);
4609 else if (percentage > 10)
4610 msg_format("%^s¤Ï¶ìÄˤǤâ¤À¤¨¶ì¤·¤ó¤À¡£", m_name);
4612 msg_format("%^s¤Ï¼å¡¹¤·¤¯Ëʤ¨¤¿¡£", m_name);
4614 if (percentage > 95)
4615 msg_format("%^s shrugs off the attack.", m_name);
4616 else if (percentage > 75)
4617 msg_format("%^s snarls with pain.", m_name);
4618 else if (percentage > 50)
4619 msg_format("%^s yelps in pain.", m_name);
4620 else if (percentage > 35)
4621 msg_format("%^s howls in pain.", m_name);
4622 else if (percentage > 20)
4623 msg_format("%^s howls in agony.", m_name);
4624 else if (percentage > 10)
4625 msg_format("%^s writhes in agony.", m_name);
4627 msg_format("%^s yelps feebly.", m_name);
4632 /* One type of monsters (ignore,squeal,shriek) */
4633 else if (strchr("Xbilqrt", r_ptr->d_char))
4636 if (percentage > 95)
4637 msg_format("%^s¤Ï¹¶·â¤òµ¤¤Ë¤È¤á¤Æ¤¤¤Ê¤¤¡£", m_name);
4638 else if (percentage > 75)
4639 msg_format("%^s¤ÏÄˤߤǤ¦¤Ê¤Ã¤¿¡£", m_name);
4640 else if (percentage > 50)
4641 msg_format("%^s¤ÏÄˤߤǶ«¤ó¤À¡£", m_name);
4642 else if (percentage > 35)
4643 msg_format("%^s¤ÏÄˤߤÇÀ䶫¤·¤¿¡£", m_name);
4644 else if (percentage > 20)
4645 msg_format("%^s¤Ï¶ìÄˤΤ¢¤Þ¤êÀ䶫¤·¤¿¡£", m_name);
4646 else if (percentage > 10)
4647 msg_format("%^s¤Ï¶ìÄˤǤâ¤À¤¨¶ì¤·¤ó¤À¡£", m_name);
4649 msg_format("%^s¤Ï¼å¡¹¤·¤¯¶«¤ó¤À¡£", m_name);
4651 if (percentage > 95)
4652 msg_format("%^s ignores the attack.", m_name);
4653 else if (percentage > 75)
4654 msg_format("%^s grunts with pain.", m_name);
4655 else if (percentage > 50)
4656 msg_format("%^s squeals in pain.", m_name);
4657 else if (percentage > 35)
4658 msg_format("%^s shrieks in pain.", m_name);
4659 else if (percentage > 20)
4660 msg_format("%^s shrieks in agony.", m_name);
4661 else if (percentage > 10)
4662 msg_format("%^s writhes in agony.", m_name);
4664 msg_format("%^s cries out feebly.", m_name);
4669 /* Another type of monsters (shrug,cry,scream) */
4673 if (percentage > 95)
4674 msg_format("%^s¤Ï¹¶·â¤Ë¸ª¤ò¤¹¤¯¤á¤¿¡£", m_name);
4675 else if (percentage > 75)
4676 msg_format("%^s¤ÏÄˤߤǤ¦¤Ê¤Ã¤¿¡£", m_name);
4677 else if (percentage > 50)
4678 msg_format("%^s¤ÏÄˤߤǶ«¤ó¤À¡£", m_name);
4679 else if (percentage > 35)
4680 msg_format("%^s¤ÏÄˤߤÇÀ䶫¤·¤¿¡£", m_name);
4681 else if (percentage > 20)
4682 msg_format("%^s¤Ï¶ìÄˤΤ¢¤Þ¤êÀ䶫¤·¤¿¡£", m_name);
4683 else if (percentage > 10)
4684 msg_format("%^s¤Ï¶ìÄˤǤâ¤À¤¨¶ì¤·¤ó¤À¡£", m_name);
4686 msg_format("%^s¤Ï¼å¡¹¤·¤¯¶«¤ó¤À¡£", m_name);
4688 if (percentage > 95)
4689 msg_format("%^s shrugs off the attack.", m_name);
4690 else if (percentage > 75)
4691 msg_format("%^s grunts with pain.", m_name);
4692 else if (percentage > 50)
4693 msg_format("%^s cries out in pain.", m_name);
4694 else if (percentage > 35)
4695 msg_format("%^s screams in pain.", m_name);
4696 else if (percentage > 20)
4697 msg_format("%^s screams in agony.", m_name);
4698 else if (percentage > 10)
4699 msg_format("%^s writhes in agony.", m_name);
4701 msg_format("%^s cries out feebly.", m_name);
4709 * Learn about an "observed" resistance.
4711 void update_smart_learn(int m_idx, int what)
4713 #ifdef DRS_SMART_OPTIONS
4715 monster_type *m_ptr = &m_list[m_idx];
4717 monster_race *r_ptr = &r_info[m_ptr->r_idx];
4720 /* Not allowed to learn */
4721 if (!smart_learn) return;
4723 /* Too stupid to learn anything */
4724 if (r_ptr->flags2 & (RF2_STUPID)) return;
4726 /* Not intelligent, only learn sometimes */
4727 if (!(r_ptr->flags2 & (RF2_SMART)) && (randint0(100) < 50)) return;
4732 /* Analyze the knowledge */
4736 if (p_ptr->resist_acid) m_ptr->smart |= (SM_RES_ACID);
4737 if (p_ptr->oppose_acid) m_ptr->smart |= (SM_OPP_ACID);
4738 if (p_ptr->immune_acid) m_ptr->smart |= (SM_IMM_ACID);
4742 if (p_ptr->resist_elec) m_ptr->smart |= (SM_RES_ELEC);
4743 if (p_ptr->oppose_elec) m_ptr->smart |= (SM_OPP_ELEC);
4744 if (p_ptr->immune_elec) m_ptr->smart |= (SM_IMM_ELEC);
4748 if (p_ptr->resist_fire) m_ptr->smart |= (SM_RES_FIRE);
4749 if (p_ptr->oppose_fire) m_ptr->smart |= (SM_OPP_FIRE);
4750 if (p_ptr->immune_fire) m_ptr->smart |= (SM_IMM_FIRE);
4754 if (p_ptr->resist_cold) m_ptr->smart |= (SM_RES_COLD);
4755 if (p_ptr->oppose_cold) m_ptr->smart |= (SM_OPP_COLD);
4756 if (p_ptr->immune_cold) m_ptr->smart |= (SM_IMM_COLD);
4760 if (p_ptr->resist_pois) m_ptr->smart |= (SM_RES_POIS);
4761 if (p_ptr->oppose_pois) m_ptr->smart |= (SM_OPP_POIS);
4766 if (p_ptr->resist_neth) m_ptr->smart |= (SM_RES_NETH);
4770 if (p_ptr->resist_lite) m_ptr->smart |= (SM_RES_LITE);
4774 if (p_ptr->resist_dark) m_ptr->smart |= (SM_RES_DARK);
4778 if (p_ptr->resist_fear) m_ptr->smart |= (SM_RES_FEAR);
4782 if (p_ptr->resist_conf) m_ptr->smart |= (SM_RES_CONF);
4786 if (p_ptr->resist_chaos) m_ptr->smart |= (SM_RES_CHAOS);
4790 if (p_ptr->resist_disen) m_ptr->smart |= (SM_RES_DISEN);
4794 if (p_ptr->resist_blind) m_ptr->smart |= (SM_RES_BLIND);
4798 if (p_ptr->resist_nexus) m_ptr->smart |= (SM_RES_NEXUS);
4802 if (p_ptr->resist_sound) m_ptr->smart |= (SM_RES_SOUND);
4806 if (p_ptr->resist_shard) m_ptr->smart |= (SM_RES_SHARD);
4810 if (p_ptr->free_act) m_ptr->smart |= (SM_IMM_FREE);
4814 if (!p_ptr->msp) m_ptr->smart |= (SM_IMM_MANA);
4818 if (p_ptr->reflect) m_ptr-> smart |= (SM_IMM_REFLECT);
4822 #endif /* DRS_SMART_OPTIONS */
4828 * Place the player in the dungeon XXX XXX
4830 bool player_place(int y, int x)
4832 /* Paranoia XXX XXX */
4833 if (cave[y][x].m_idx != 0) return FALSE;
4835 /* Save player location */
4845 * Drop all items carried by a monster
4847 void monster_drop_carried_objects(monster_type *m_ptr)
4849 s16b this_o_idx, next_o_idx = 0;
4855 /* Drop objects being carried */
4856 for (this_o_idx = m_ptr->hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
4858 /* Acquire object */
4859 o_ptr = &o_list[this_o_idx];
4861 /* Acquire next object */
4862 next_o_idx = o_ptr->next_o_idx;
4865 o_ptr->held_m_idx = 0;
4867 /* Get local object */
4870 /* Copy the object */
4871 object_copy(q_ptr, o_ptr);
4873 /* Delete the object */
4874 delete_object_idx(this_o_idx);
4877 (void)drop_near(q_ptr, -1, m_ptr->fy, m_ptr->fx);
4880 /* Forget objects */
4881 m_ptr->hold_o_idx = 0;