1 /* File: monster2.c */
4 * Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke
6 * This software may be copied and distributed for educational, research,
7 * and not for profit purposes provided that this copyright and statement
8 * are included in all such copies. Other copyrights may also apply.
11 /* Purpose: misc code for monsters */
15 #define HORDE_NOGOOD 0x01
16 #define HORDE_NOEVIL 0x02
18 cptr horror_desc[MAX_SAN_HORROR] =
72 cptr funny_desc[MAX_SAN_FUNNY] =
132 cptr funny_comments[MAX_SAN_COMMENT] =
153 * Set the target of counter attack
155 void set_target(monster_type *m_ptr, int y, int x)
163 * Reset the target of counter attack
165 void reset_target(monster_type *m_ptr)
167 set_target(m_ptr, 0, 0);
172 * Extract monster race pointer of a monster's true form
174 monster_race *real_r_ptr(monster_type *m_ptr)
176 monster_race *r_ptr = &r_info[m_ptr->r_idx];
178 /* Extract real race */
179 if (m_ptr->mflag2 & MFLAG2_CHAMELEON)
181 if (r_ptr->flags1 & RF1_UNIQUE)
182 return &r_info[MON_CHAMELEON_K];
184 return &r_info[MON_CHAMELEON];
194 * Delete a monster by index.
196 * When a monster is deleted, all of its objects are deleted.
198 void delete_monster_idx(int i)
202 monster_type *m_ptr = &m_list[i];
204 monster_race *r_ptr = &r_info[m_ptr->r_idx];
206 s16b this_o_idx, next_o_idx = 0;
214 /* Hack -- Reduce the racial counter */
215 real_r_ptr(m_ptr)->cur_num--;
217 /* Hack -- count the number of "reproducers" */
218 if (r_ptr->flags2 & (RF2_MULTIPLY)) num_repro--;
220 if (MON_CSLEEP(m_ptr)) (void)set_monster_csleep(i, 0);
221 if (MON_FAST(m_ptr)) (void)set_monster_fast(i, 0);
222 if (MON_SLOW(m_ptr)) (void)set_monster_slow(i, 0);
223 if (MON_STUNNED(m_ptr)) (void)set_monster_stunned(i, 0);
224 if (MON_CONFUSED(m_ptr)) (void)set_monster_confused(i, 0);
225 if (MON_MONFEAR(m_ptr)) (void)set_monster_monfear(i, 0);
226 if (MON_INVULNER(m_ptr)) (void)set_monster_invulner(i, 0, FALSE);
229 /* Hack -- remove target monster */
230 if (i == target_who) target_who = 0;
232 /* Hack -- remove tracked monster */
233 if (i == p_ptr->health_who) health_track(0);
235 if (pet_t_m_idx == i ) pet_t_m_idx = 0;
236 if (riding_t_m_idx == i) riding_t_m_idx = 0;
237 if (p_ptr->riding == i) p_ptr->riding = 0;
239 /* Monster is gone */
240 cave[y][x].m_idx = 0;
244 for (this_o_idx = m_ptr->hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
249 o_ptr = &o_list[this_o_idx];
251 /* Acquire next object */
252 next_o_idx = o_ptr->next_o_idx;
255 * o_ptr->held_m_idx is needed in delete_object_idx()
256 * to prevent calling lite_spot()
259 /* Delete the object */
260 delete_object_idx(this_o_idx);
264 if (is_pet(m_ptr)) check_pets_num_and_align(m_ptr, FALSE);
267 /* Wipe the Monster */
268 (void)WIPE(m_ptr, monster_type);
276 /* Update some things */
277 if (r_ptr->flags7 & (RF7_LITE_MASK | RF7_DARK_MASK))
278 p_ptr->update |= (PU_MON_LITE);
283 * Delete the monster, if any, at a given location
285 void delete_monster(int y, int x)
290 if (!in_bounds(y, x)) return;
295 /* Delete the monster (if any) */
296 if (c_ptr->m_idx) delete_monster_idx(c_ptr->m_idx);
301 * Move an object from index i1 to index i2 in the object list
303 static void compact_monsters_aux(int i1, int i2)
311 s16b this_o_idx, next_o_idx = 0;
315 if (i1 == i2) return;
328 /* Update the cave */
331 /* Repair objects being carried by monster */
332 for (this_o_idx = m_ptr->hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
337 o_ptr = &o_list[this_o_idx];
339 /* Acquire next object */
340 next_o_idx = o_ptr->next_o_idx;
342 /* Reset monster pointer */
343 o_ptr->held_m_idx = i2;
346 /* Hack -- Update the target */
347 if (target_who == i1) target_who = i2;
349 /* Hack -- Update the target */
350 if (pet_t_m_idx == i1) pet_t_m_idx = i2;
351 if (riding_t_m_idx == i1) riding_t_m_idx = i2;
353 /* Hack -- Update the riding */
354 if (p_ptr->riding == i1) p_ptr->riding = i2;
356 /* Hack -- Update the health bar */
357 if (p_ptr->health_who == i1) health_track(i2);
359 /* Hack -- Update parent index */
362 for (i = 1; i < m_max; i++)
364 monster_type *m2_ptr = &m_list[i];
366 if (m2_ptr->parent_m_idx == i1)
367 m2_ptr->parent_m_idx = i2;
372 (void)COPY(&m_list[i2], &m_list[i1], monster_type);
375 (void)WIPE(&m_list[i1], monster_type);
377 for (i = 0; i < MAX_MTIMED; i++)
379 int mproc_idx = get_mproc_idx(i1, i);
380 if (mproc_idx >= 0) mproc_list[i][mproc_idx] = i2;
386 * Compact and Reorder the monster list
388 * This function can be very dangerous, use with caution!
390 * When actually "compacting" monsters, we base the saving throw
391 * on a combination of monster level, distance from player, and
392 * current "desperation".
394 * After "compacting" (if needed), we "reorder" the monsters into a more
395 * compact order, and we reset the allocation info, and the "live" array.
397 void compact_monsters(int size)
400 int cur_lev, cur_dis, chance;
402 /* Message (only if compacting) */
403 if (size) msg_print(_("モンスター情報を圧縮しています...", "Compacting monsters..."));
406 /* Compact at least 'size' objects */
407 for (num = 0, cnt = 1; num < size; cnt++)
409 /* Get more vicious each iteration */
412 /* Get closer each iteration */
413 cur_dis = 5 * (20 - cnt);
415 /* Check all the monsters */
416 for (i = 1; i < m_max; i++)
418 monster_type *m_ptr = &m_list[i];
420 monster_race *r_ptr = &r_info[m_ptr->r_idx];
422 /* Paranoia -- skip "dead" monsters */
423 if (!m_ptr->r_idx) continue;
425 /* Hack -- High level monsters start out "immune" */
426 if (r_ptr->level > cur_lev) continue;
428 if (i == p_ptr->riding) continue;
430 /* Ignore nearby monsters */
431 if ((cur_dis > 0) && (m_ptr->cdis < cur_dis)) continue;
433 /* Saving throw chance */
436 /* Only compact "Quest" Monsters in emergencies */
437 if ((r_ptr->flags1 & (RF1_QUESTOR)) && (cnt < 1000)) chance = 100;
439 /* Try not to compact Unique Monsters */
440 if (r_ptr->flags1 & (RF1_UNIQUE)) chance = 100;
442 /* All monsters get a saving throw */
443 if (randint0(100) < chance) continue;
445 if (record_named_pet && is_pet(m_ptr) && m_ptr->nickname)
449 monster_desc(m_name, m_ptr, MD_INDEF_VISIBLE);
450 do_cmd_write_nikki(NIKKI_NAMED_PET, RECORD_NAMED_PET_COMPACT, m_name);
453 /* Delete the monster */
454 delete_monster_idx(i);
456 /* Count the monster */
462 /* Excise dead monsters (backwards!) */
463 for (i = m_max - 1; i >= 1; i--)
465 /* Get the i'th monster */
466 monster_type *m_ptr = &m_list[i];
468 /* Skip real monsters */
469 if (m_ptr->r_idx) continue;
471 /* Move last monster into open hole */
472 compact_monsters_aux(m_max - 1, i);
474 /* Compress "m_max" */
481 * Delete/Remove all the monsters when the player leaves the level
483 * This is an efficient method of simulating multiple calls to the
484 * "delete_monster()" function, with no visual effects.
486 void wipe_m_list(void)
490 /* Hack -- if Banor or Lupart dies, stay another dead */
491 if (!r_info[MON_BANORLUPART].max_num)
493 if (r_info[MON_BANOR].max_num)
495 r_info[MON_BANOR].max_num = 0;
496 r_info[MON_BANOR].r_pkills++;
497 r_info[MON_BANOR].r_akills++;
498 if (r_info[MON_BANOR].r_tkills < MAX_SHORT) r_info[MON_BANOR].r_tkills++;
500 if (r_info[MON_LUPART].max_num)
502 r_info[MON_LUPART].max_num = 0;
503 r_info[MON_LUPART].r_pkills++;
504 r_info[MON_LUPART].r_akills++;
505 if (r_info[MON_LUPART].r_tkills < MAX_SHORT) r_info[MON_LUPART].r_tkills++;
509 /* Delete all the monsters */
510 for (i = m_max - 1; i >= 1; i--)
512 monster_type *m_ptr = &m_list[i];
514 /* Skip dead monsters */
515 if (!m_ptr->r_idx) continue;
517 /* Monster is gone */
518 cave[m_ptr->fy][m_ptr->fx].m_idx = 0;
520 /* Wipe the Monster */
521 (void)WIPE(m_ptr, monster_type);
526 * Wiping racial counters of all monsters and incrementing of racial
527 * counters of monsters in party_mon[] are required to prevent multiple
528 * generation of unique monster who is the minion of player.
531 /* Hack -- Wipe the racial counter of all monster races */
532 for (i = 1; i < max_r_idx; i++) r_info[i].cur_num = 0;
540 /* Reset "mproc_max[]" */
541 for (i = 0; i < MAX_MTIMED; i++) mproc_max[i] = 0;
543 /* Hack -- reset "reproducer" count */
546 /* Hack -- no more target */
551 /* Hack -- no more tracking */
557 * Acquires and returns the index of a "free" monster.
559 * This routine should almost never fail, but it *can* happen.
566 /* Normal allocation */
567 if (m_max < max_m_idx)
569 /* Access the next hole */
572 /* Expand the array */
578 /* Return the index */
583 /* Recycle dead monsters */
584 for (i = 1; i < m_max; i++)
588 /* Acquire monster */
591 /* Skip live monsters */
592 if (m_ptr->r_idx) continue;
597 /* Use this monster */
602 /* Warn the player (except during dungeon creation) */
603 if (character_dungeon) msg_print(_("モンスターが多すぎる!", "Too many monsters!"));
605 /* Try not to crash */
613 * Hack -- the "type" of the current "summon specific"
615 static int summon_specific_type = 0;
619 * Hack -- the index of the summoning monster
621 static int summon_specific_who = -1;
624 static bool summon_unique_okay = FALSE;
627 static bool summon_specific_aux(int r_idx)
629 monster_race *r_ptr = &r_info[r_idx];
632 /* Check our requirements */
633 switch (summon_specific_type)
637 okay = (r_ptr->d_char == 'a');
643 okay = (r_ptr->d_char == 'S');
649 okay = ((r_ptr->d_char == 'C') || (r_ptr->d_char == 'Z'));
655 okay = (r_ptr->d_char == 'M');
661 okay = (r_ptr->d_char == 'A' && ((r_ptr->flags3 & RF3_EVIL) || (r_ptr->flags3 & RF3_GOOD)));
667 okay = (r_ptr->flags3 & RF3_DEMON);
673 okay = (r_ptr->flags3 & RF3_UNDEAD);
679 okay = (r_ptr->flags3 & RF3_DRAGON);
683 case SUMMON_HI_UNDEAD:
685 okay = ((r_ptr->d_char == 'L') ||
686 (r_ptr->d_char == 'V') ||
687 (r_ptr->d_char == 'W'));
691 case SUMMON_HI_DRAGON:
693 okay = (r_ptr->d_char == 'D');
697 case SUMMON_HI_DEMON:
699 okay = (((r_ptr->d_char == 'U') ||
700 (r_ptr->d_char == 'H') ||
701 (r_ptr->d_char == 'B')) &&
702 (r_ptr->flags3 & RF3_DEMON)) ? TRUE : FALSE;
706 case SUMMON_AMBERITES:
708 okay = (r_ptr->flags3 & (RF3_AMBERITE)) ? TRUE : FALSE;
714 okay = (r_ptr->flags1 & (RF1_UNIQUE)) ? TRUE : FALSE;
718 case SUMMON_BIZARRE1:
720 okay = (r_ptr->d_char == 'm');
723 case SUMMON_BIZARRE2:
725 okay = (r_ptr->d_char == 'b');
728 case SUMMON_BIZARRE3:
730 okay = (r_ptr->d_char == 'Q');
734 case SUMMON_BIZARRE4:
736 okay = (r_ptr->d_char == 'v');
740 case SUMMON_BIZARRE5:
742 okay = (r_ptr->d_char == '$');
746 case SUMMON_BIZARRE6:
748 okay = ((r_ptr->d_char == '!') ||
749 (r_ptr->d_char == '?') ||
750 (r_ptr->d_char == '=') ||
751 (r_ptr->d_char == '$') ||
752 (r_ptr->d_char == '|'));
758 okay = (r_ptr->d_char == 'g');
764 okay = ((r_ptr->d_char == 'U') &&
765 (r_ptr->flags4 & RF4_ROCKET));
772 okay = ((r_ptr->d_char == summon_kin_type) && (r_idx != MON_HAGURE));
778 okay = (r_idx == MON_DAWN);
784 okay = (r_ptr->flags3 & (RF3_ANIMAL));
788 case SUMMON_ANIMAL_RANGER:
790 okay = ((r_ptr->flags3 & (RF3_ANIMAL)) &&
791 (my_strchr("abcflqrwBCHIJKMRS", r_ptr->d_char)) &&
792 !(r_ptr->flags3 & (RF3_DRAGON)) &&
793 !(r_ptr->flags3 & (RF3_EVIL)) &&
794 !(r_ptr->flags3 & (RF3_UNDEAD)) &&
795 !(r_ptr->flags3 & (RF3_DEMON)) &&
796 !(r_ptr->flags2 & (RF2_MULTIPLY)) &&
797 !(r_ptr->flags4 || r_ptr->flags5 || r_ptr->flags6));
801 case SUMMON_HI_DRAGON_LIVING:
803 okay = ((r_ptr->d_char == 'D') && monster_living(r_ptr));
809 okay = monster_living(r_ptr);
815 okay = (r_idx == MON_PHANTOM_B || r_idx == MON_PHANTOM_W);
819 case SUMMON_BLUE_HORROR:
821 okay = (r_idx == MON_BLUE_HORROR);
825 case SUMMON_ELEMENTAL:
827 okay = (r_ptr->d_char == 'E');
833 okay = (r_ptr->d_char == 'v');
839 okay = (r_ptr->d_char == 'H');
845 okay = (r_ptr->d_char == 'B');
849 case SUMMON_KAMIKAZE:
852 for (i = 0; i < 4; i++)
853 if (r_ptr->blow[i].method == RBM_EXPLODE) okay = TRUE;
857 case SUMMON_KAMIKAZE_LIVING:
861 for (i = 0; i < 4; i++)
862 if (r_ptr->blow[i].method == RBM_EXPLODE) okay = TRUE;
863 okay = (okay && monster_living(r_ptr));
869 okay = (r_idx == MON_MANES);
875 okay = (r_idx == MON_LOUSE);
879 case SUMMON_GUARDIANS:
881 okay = (r_ptr->flags7 & RF7_GUARDIAN);
887 okay = ((r_idx == MON_NOV_PALADIN) ||
888 (r_idx == MON_NOV_PALADIN_G) ||
889 (r_idx == MON_PALADIN) ||
890 (r_idx == MON_W_KNIGHT) ||
891 (r_idx == MON_ULTRA_PALADIN) ||
892 (r_idx == MON_KNI_TEMPLAR));
898 okay = (r_ptr->d_char == 'B' &&
899 (r_ptr->flags8 & RF8_WILD_MOUNTAIN) &&
900 (r_ptr->flags8 & RF8_WILD_ONLY));
904 case SUMMON_PIRANHAS:
906 okay = (r_idx == MON_PIRANHA);
910 case SUMMON_ARMAGE_GOOD:
912 okay = (r_ptr->d_char == 'A' && (r_ptr->flags3 & RF3_GOOD));
916 case SUMMON_ARMAGE_EVIL:
918 okay = ((r_ptr->flags3 & RF3_DEMON) ||
919 (r_ptr->d_char == 'A' && (r_ptr->flags3 & RF3_EVIL)));
925 /* Since okay is int, "return (okay);" is not correct. */
926 return (bool)(okay ? TRUE : FALSE);
930 static int chameleon_change_m_idx = 0;
934 * Some dungeon types restrict the possible monsters.
935 * Return TRUE is the monster is OK and FALSE otherwise
937 static bool restrict_monster_to_dungeon(int r_idx)
939 dungeon_info_type *d_ptr = &d_info[dungeon_type];
940 monster_race *r_ptr = &r_info[r_idx];
943 if (d_ptr->flags1 & DF1_CHAMELEON)
945 if (chameleon_change_m_idx) return TRUE;
947 if (d_ptr->flags1 & DF1_NO_MAGIC)
949 if (r_idx != MON_CHAMELEON &&
951 !(r_ptr->flags4 & RF4_NOMAGIC_MASK) &&
952 !(r_ptr->flags5 & RF5_NOMAGIC_MASK) &&
953 !(r_ptr->flags6 & RF6_NOMAGIC_MASK))
956 if (d_ptr->flags1 & DF1_NO_MELEE)
958 if (r_idx == MON_CHAMELEON) return TRUE;
959 if (!(r_ptr->flags4 & (RF4_BOLT_MASK | RF4_BEAM_MASK | RF4_BALL_MASK)) &&
960 !(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)) &&
961 !(r_ptr->flags6 & (RF6_BOLT_MASK | RF6_BEAM_MASK | RF6_BALL_MASK)))
964 if (d_ptr->flags1 & DF1_BEGINNER)
966 if (r_ptr->level > dun_level)
970 if (d_ptr->special_div >= 64) return TRUE;
971 if (summon_specific_type && !(d_ptr->flags1 & DF1_CHAMELEON)) return TRUE;
975 case DUNGEON_MODE_AND:
978 if ((d_ptr->mflags1 & r_ptr->flags1) != d_ptr->mflags1)
983 if ((d_ptr->mflags2 & r_ptr->flags2) != d_ptr->mflags2)
988 if ((d_ptr->mflags3 & r_ptr->flags3) != d_ptr->mflags3)
993 if ((d_ptr->mflags4 & r_ptr->flags4) != d_ptr->mflags4)
998 if ((d_ptr->mflags5 & r_ptr->flags5) != d_ptr->mflags5)
1003 if ((d_ptr->mflags6 & r_ptr->flags6) != d_ptr->mflags6)
1008 if ((d_ptr->mflags7 & r_ptr->flags7) != d_ptr->mflags7)
1013 if ((d_ptr->mflags8 & r_ptr->flags8) != d_ptr->mflags8)
1018 if ((d_ptr->mflags9 & r_ptr->flags9) != d_ptr->mflags9)
1023 if ((d_ptr->mflagsr & r_ptr->flagsr) != d_ptr->mflagsr)
1026 for (a = 0; a < 5; a++)
1027 if (d_ptr->r_char[a] && (d_ptr->r_char[a] != r_ptr->d_char)) return FALSE;
1031 case DUNGEON_MODE_NAND:
1034 if ((d_ptr->mflags1 & r_ptr->flags1) != d_ptr->mflags1)
1039 if ((d_ptr->mflags2 & r_ptr->flags2) != d_ptr->mflags2)
1044 if ((d_ptr->mflags3 & r_ptr->flags3) != d_ptr->mflags3)
1049 if ((d_ptr->mflags4 & r_ptr->flags4) != d_ptr->mflags4)
1054 if ((d_ptr->mflags5 & r_ptr->flags5) != d_ptr->mflags5)
1059 if ((d_ptr->mflags6 & r_ptr->flags6) != d_ptr->mflags6)
1064 if ((d_ptr->mflags7 & r_ptr->flags7) != d_ptr->mflags7)
1069 if ((d_ptr->mflags8 & r_ptr->flags8) != d_ptr->mflags8)
1074 if ((d_ptr->mflags9 & r_ptr->flags9) != d_ptr->mflags9)
1079 if ((d_ptr->mflagsr & r_ptr->flagsr) != d_ptr->mflagsr)
1082 for (a = 0; a < 5; a++)
1083 if (d_ptr->r_char[a] && (d_ptr->r_char[a] != r_ptr->d_char)) return TRUE;
1087 case DUNGEON_MODE_OR:
1088 if (r_ptr->flags1 & d_ptr->mflags1) return TRUE;
1089 if (r_ptr->flags2 & d_ptr->mflags2) return TRUE;
1090 if (r_ptr->flags3 & d_ptr->mflags3) return TRUE;
1091 if (r_ptr->flags4 & d_ptr->mflags4) return TRUE;
1092 if (r_ptr->flags5 & d_ptr->mflags5) return TRUE;
1093 if (r_ptr->flags6 & d_ptr->mflags6) return TRUE;
1094 if (r_ptr->flags7 & d_ptr->mflags7) return TRUE;
1095 if (r_ptr->flags8 & d_ptr->mflags8) return TRUE;
1096 if (r_ptr->flags9 & d_ptr->mflags9) return TRUE;
1097 if (r_ptr->flagsr & d_ptr->mflagsr) return TRUE;
1098 for (a = 0; a < 5; a++)
1099 if (d_ptr->r_char[a] == r_ptr->d_char) return TRUE;
1103 case DUNGEON_MODE_NOR:
1104 if (r_ptr->flags1 & d_ptr->mflags1) return FALSE;
1105 if (r_ptr->flags2 & d_ptr->mflags2) return FALSE;
1106 if (r_ptr->flags3 & d_ptr->mflags3) return FALSE;
1107 if (r_ptr->flags4 & d_ptr->mflags4) return FALSE;
1108 if (r_ptr->flags5 & d_ptr->mflags5) return FALSE;
1109 if (r_ptr->flags6 & d_ptr->mflags6) return FALSE;
1110 if (r_ptr->flags7 & d_ptr->mflags7) return FALSE;
1111 if (r_ptr->flags8 & d_ptr->mflags8) return FALSE;
1112 if (r_ptr->flags9 & d_ptr->mflags9) return FALSE;
1113 if (r_ptr->flagsr & d_ptr->mflagsr) return FALSE;
1114 for (a = 0; a < 5; a++)
1115 if (d_ptr->r_char[a] == r_ptr->d_char) return FALSE;
1124 * Apply a "monster restriction function" to the "monster allocation table"
1126 errr get_mon_num_prep(monster_hook_type monster_hook,
1127 monster_hook_type monster_hook2)
1131 /* Todo: Check the hooks for non-changes */
1133 /* Set the new hooks */
1134 get_mon_num_hook = monster_hook;
1135 get_mon_num2_hook = monster_hook2;
1137 /* Scan the allocation table */
1138 for (i = 0; i < alloc_race_size; i++)
1140 monster_race *r_ptr;
1143 alloc_entry *entry = &alloc_race_table[i];
1146 r_ptr = &r_info[entry->index];
1148 /* Skip monsters which don't pass the restriction */
1149 if ((get_mon_num_hook && !((*get_mon_num_hook)(entry->index))) ||
1150 (get_mon_num2_hook && !((*get_mon_num2_hook)(entry->index))))
1153 if (!p_ptr->inside_battle && !chameleon_change_m_idx &&
1154 summon_specific_type != SUMMON_GUARDIANS)
1156 /* Hack -- don't create questors */
1157 if (r_ptr->flags1 & RF1_QUESTOR)
1160 if (r_ptr->flags7 & RF7_GUARDIAN)
1163 /* Depth Monsters never appear out of depth */
1164 if ((r_ptr->flags1 & (RF1_FORCE_DEPTH)) &&
1165 (r_ptr->level > dun_level))
1169 /* Accept this monster */
1170 entry->prob2 = entry->prob1;
1172 if (dun_level && (!p_ptr->inside_quest || is_fixed_quest_idx(p_ptr->inside_quest)) && !restrict_monster_to_dungeon(entry->index) && !p_ptr->inside_battle)
1174 int hoge = entry->prob2 * d_info[dungeon_type].special_div;
1175 entry->prob2 = hoge / 64;
1176 if (randint0(64) < (hoge & 0x3f)) entry->prob2++;
1185 static int mysqrt(int n)
1223 * Choose a monster race that seems "appropriate" to the given level
1225 * This function uses the "prob2" field of the "monster allocation table",
1226 * and various local information, to calculate the "prob3" field of the
1227 * same table, which is then used to choose an "appropriate" monster, in
1228 * a relatively efficient manner.
1230 * Note that "town" monsters will *only* be created in the town, and
1231 * "normal" monsters will *never* be created in the town, unless the
1232 * "level" is "modified", for example, by polymorph or summoning.
1234 * There is a small chance (1/50) of "boosting" the given depth by
1235 * a small amount (up to four levels), except in the town.
1237 * It is (slightly) more likely to acquire a monster of the given level
1238 * than one of a lower level. This is done by choosing several monsters
1239 * appropriate to the given level and keeping the "hardest" one.
1241 * Note that if no monsters are "appropriate", then this function will
1242 * fail, and return zero, but this should *almost* never happen.
1244 s16b get_mon_num(int level)
1249 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 pls_kakuritu = MAX(NASTY_MON_MAX, NASTY_MON_BASE - ((dungeon_turn / (TURNS_PER_TICK * 2500L) - hoge / 10)));
1258 pls_level = MIN(NASTY_MON_PLUS_MAX, 3 + dungeon_turn / (TURNS_PER_TICK * 20000L) - hoge / 40 + MIN(5, level / 10)) ;
1260 if (d_info[dungeon_type].flags1 & DF1_MAZE)
1262 pls_kakuritu = MIN(pls_kakuritu / 2, pls_kakuritu - 10);
1263 if (pls_kakuritu < 2) pls_kakuritu = 2;
1268 /* Boost the level */
1269 if (!p_ptr->inside_battle && !(d_info[dungeon_type].flags1 & DF1_BEGINNER))
1271 /* Nightmare mode allows more out-of depth monsters */
1272 if (ironman_nightmare && !randint0(pls_kakuritu))
1274 /* What a bizarre calculation */
1275 level = 1 + (level * MAX_DEPTH / randint1(MAX_DEPTH));
1279 /* Occasional "nasty" monster */
1280 if (!randint0(pls_kakuritu))
1282 /* Pick a level bonus */
1291 /* Process probabilities */
1292 for (i = 0; i < alloc_race_size; i++)
1294 /* Monsters are sorted by depth */
1295 if (table[i].level > level) break;
1300 /* Access the "r_idx" of the chosen monster */
1301 r_idx = table[i].index;
1303 /* Access the actual race */
1304 r_ptr = &r_info[r_idx];
1306 if (!p_ptr->inside_battle && !chameleon_change_m_idx)
1308 /* Hack -- "unique" monsters must be "unique" */
1309 if (((r_ptr->flags1 & (RF1_UNIQUE)) ||
1310 (r_ptr->flags7 & (RF7_NAZGUL))) &&
1311 (r_ptr->cur_num >= r_ptr->max_num))
1316 if ((r_ptr->flags7 & (RF7_UNIQUE2)) &&
1317 (r_ptr->cur_num >= 1))
1322 if (r_idx == MON_BANORLUPART)
1324 if (r_info[MON_BANOR].cur_num > 0) continue;
1325 if (r_info[MON_LUPART].cur_num > 0) continue;
1330 table[i].prob3 = table[i].prob2;
1333 total += table[i].prob3;
1336 /* No legal monsters */
1337 if (total <= 0) return (0);
1339 /* Pick a monster */
1340 value = randint0(total);
1342 /* Find the monster */
1343 for (i = 0; i < alloc_race_size; i++)
1345 /* Found the entry */
1346 if (value < table[i].prob3) break;
1349 value = value - table[i].prob3;
1355 /* Try for a "harder" monster once (50%) or twice (10%) */
1361 /* Pick a monster */
1362 value = randint0(total);
1364 /* Find the monster */
1365 for (i = 0; i < alloc_race_size; i++)
1367 /* Found the entry */
1368 if (value < table[i].prob3) break;
1371 value = value - table[i].prob3;
1374 /* Keep the "best" one */
1375 if (table[i].level < table[j].level) i = j;
1378 /* Try for a "harder" monster twice (10%) */
1384 /* Pick a monster */
1385 value = randint0(total);
1387 /* Find the monster */
1388 for (i = 0; i < alloc_race_size; i++)
1390 /* Found the entry */
1391 if (value < table[i].prob3) break;
1394 value = value - table[i].prob3;
1397 /* Keep the "best" one */
1398 if (table[i].level < table[j].level) i = j;
1402 return (table[i].index);
1410 * Build a string describing a monster in some way.
1412 * We can correctly describe monsters based on their visibility.
1413 * We can force all monsters to be treated as visible or invisible.
1414 * We can build nominatives, objectives, possessives, or reflexives.
1415 * We can selectively pronominalize hidden, visible, or all monsters.
1416 * We can use definite or indefinite descriptions for hidden monsters.
1417 * We can use definite or indefinite descriptions for visible monsters.
1419 * Pronominalization involves the gender whenever possible and allowed,
1420 * so that by cleverly requesting pronominalization / visibility, you
1421 * can get messages like "You hit someone. She screams in agony!".
1423 * Reflexives are acquired by requesting Objective plus Possessive.
1425 * If no m_ptr arg is given (?), the monster is assumed to be hidden,
1426 * unless the "Assume Visible" mode is requested.
1428 * If no r_ptr arg is given, it is extracted from m_ptr and r_info
1429 * If neither m_ptr nor r_ptr is given, the monster is assumed to
1430 * be neuter, singular, and hidden (unless "Assume Visible" is set),
1431 * in which case you may be in trouble... :-)
1433 * I am assuming that no monster name is more than 70 characters long,
1434 * so that "char desc[80];" is sufficiently large for any result.
1437 * MD_OBJECTIVE --> Objective (or Reflexive)
1438 * MD_POSSESSIVE --> Possessive (or Reflexive)
1439 * MD_INDEF_HIDDEN --> Use indefinites for hidden monsters ("something")
1440 * MD_INDEF_VISIBLE --> Use indefinites for visible monsters ("a kobold")
1441 * MD_PRON_HIDDEN --> Pronominalize hidden monsters
1442 * MD_PRON_VISIBLE --> Pronominalize visible monsters
1443 * MD_ASSUME_HIDDEN --> Assume the monster is hidden
1444 * MD_ASSUME_VISIBLE --> Assume the monster is visible
1445 * MD_TRUE_NAME --> Chameleon's true name
1446 * MD_IGNORE_HALLU --> Ignore hallucination, and penetrate shape change
1449 * 0x00 --> Full nominative name ("the kobold") or "it"
1450 * MD_INDEF_HIDDEN --> Full nominative name ("the kobold") or "something"
1451 * MD_ASSUME_VISIBLE --> Genocide resistance name ("the kobold")
1452 * MD_ASSUME_VISIBLE | MD_INDEF_VISIBLE --> Killing name ("a kobold")
1453 * MD_PRON_VISIBLE | MD_POSSESSIVE
1454 * --> Possessive, genderized if visable ("his") or "its"
1455 * MD_PRON_VISIBLE | MD_POSSESSIVE | MD_OBJECTIVE
1456 * --> Reflexive, genderized if visable ("himself") or "itself"
1458 void monster_desc(char *desc, monster_type *m_ptr, int mode)
1461 monster_race *r_ptr;
1465 char silly_name[1024];
1469 r_ptr = &r_info[m_ptr->ap_r_idx];
1471 /* Mode of MD_TRUE_NAME will reveal Chameleon's true name */
1472 if (mode & MD_TRUE_NAME) name = (r_name + real_r_ptr(m_ptr)->name);
1473 else name = (r_name + r_ptr->name);
1475 /* Are we hallucinating? (Idea from Nethack...) */
1476 if (p_ptr->image && !(mode & MD_IGNORE_HALLU))
1480 if (!get_rnd_line(_("silly_j.txt", "silly.txt"), m_ptr->r_idx, silly_name))
1486 monster_race *hallu_race;
1490 hallu_race = &r_info[randint1(max_r_idx - 1)];
1492 while (!hallu_race->name || (hallu_race->flags1 & RF1_UNIQUE));
1494 strcpy(silly_name, (r_name + hallu_race->name));
1497 /* Better not strcpy it, or we could corrupt r_info... */
1501 /* Can we "see" it (exists + forced, or visible + not unforced) */
1502 seen = (m_ptr && ((mode & MD_ASSUME_VISIBLE) || (!(mode & MD_ASSUME_HIDDEN) && m_ptr->ml)));
1504 /* Sexed Pronouns (seen and allowed, or unseen and allowed) */
1505 pron = (m_ptr && ((seen && (mode & MD_PRON_VISIBLE)) || (!seen && (mode & MD_PRON_HIDDEN))));
1508 /* First, try using pronouns, or describing hidden monsters */
1511 /* an encoding of the monster "sex" */
1514 /* Extract the gender (if applicable) */
1515 if (r_ptr->flags1 & (RF1_FEMALE)) kind = 0x20;
1516 else if (r_ptr->flags1 & (RF1_MALE)) kind = 0x10;
1518 /* Ignore the gender (if desired) */
1519 if (!m_ptr || !pron) kind = 0x00;
1522 /* Assume simple result */
1523 res = _("何か", "it");
1525 /* Brute force: split on the possibilities */
1526 switch (kind + (mode & (MD_INDEF_HIDDEN | MD_POSSESSIVE | MD_OBJECTIVE)))
1528 /* Neuter, or unknown */
1530 case 0x00: res = "何か"; break;
1531 case 0x00 + (MD_OBJECTIVE): res = "何か"; break;
1532 case 0x00 + (MD_POSSESSIVE): res = "何かの"; break;
1533 case 0x00 + (MD_POSSESSIVE | MD_OBJECTIVE): res = "何か自身"; break;
1534 case 0x00 + (MD_INDEF_HIDDEN): res = "何か"; break;
1535 case 0x00 + (MD_INDEF_HIDDEN | MD_OBJECTIVE): res = "何か"; break;
1536 case 0x00 + (MD_INDEF_HIDDEN | MD_POSSESSIVE): res = "何か"; break;
1537 case 0x00 + (MD_INDEF_HIDDEN | MD_POSSESSIVE | MD_OBJECTIVE): res = "それ自身"; break;
1539 case 0x00: res = "it"; break;
1540 case 0x00 + (MD_OBJECTIVE): res = "it"; break;
1541 case 0x00 + (MD_POSSESSIVE): res = "its"; break;
1542 case 0x00 + (MD_POSSESSIVE | MD_OBJECTIVE): res = "itself"; break;
1543 case 0x00 + (MD_INDEF_HIDDEN): res = "something"; break;
1544 case 0x00 + (MD_INDEF_HIDDEN | MD_OBJECTIVE): res = "something"; break;
1545 case 0x00 + (MD_INDEF_HIDDEN | MD_POSSESSIVE): res = "something's"; break;
1546 case 0x00 + (MD_INDEF_HIDDEN | MD_POSSESSIVE | MD_OBJECTIVE): res = "itself"; break;
1550 /* Male (assume human if vague) */
1552 case 0x10: res = "彼"; break;
1553 case 0x10 + (MD_OBJECTIVE): res = "彼"; break;
1554 case 0x10 + (MD_POSSESSIVE): res = "彼の"; break;
1555 case 0x10 + (MD_POSSESSIVE | MD_OBJECTIVE): res = "彼自身"; break;
1556 case 0x10 + (MD_INDEF_HIDDEN): res = "誰か"; break;
1557 case 0x10 + (MD_INDEF_HIDDEN | MD_OBJECTIVE): res = "誰か"; break;
1558 case 0x10 + (MD_INDEF_HIDDEN | MD_POSSESSIVE): res = "誰かの"; break;
1559 case 0x10 + (MD_INDEF_HIDDEN | MD_POSSESSIVE | MD_OBJECTIVE): res = "彼自身"; break;
1561 case 0x10: res = "he"; break;
1562 case 0x10 + (MD_OBJECTIVE): res = "him"; break;
1563 case 0x10 + (MD_POSSESSIVE): res = "his"; break;
1564 case 0x10 + (MD_POSSESSIVE | MD_OBJECTIVE): res = "himself"; break;
1565 case 0x10 + (MD_INDEF_HIDDEN): res = "someone"; break;
1566 case 0x10 + (MD_INDEF_HIDDEN | MD_OBJECTIVE): res = "someone"; break;
1567 case 0x10 + (MD_INDEF_HIDDEN | MD_POSSESSIVE): res = "someone's"; break;
1568 case 0x10 + (MD_INDEF_HIDDEN | MD_POSSESSIVE | MD_OBJECTIVE): res = "himself"; break;
1572 /* Female (assume human if vague) */
1574 case 0x20: res = "彼女"; break;
1575 case 0x20 + (MD_OBJECTIVE): res = "彼女"; break;
1576 case 0x20 + (MD_POSSESSIVE): res = "彼女の"; break;
1577 case 0x20 + (MD_POSSESSIVE | MD_OBJECTIVE): res = "彼女自身"; break;
1578 case 0x20 + (MD_INDEF_HIDDEN): res = "誰か"; break;
1579 case 0x20 + (MD_INDEF_HIDDEN | MD_OBJECTIVE): res = "誰か"; break;
1580 case 0x20 + (MD_INDEF_HIDDEN | MD_POSSESSIVE): res = "誰かの"; break;
1581 case 0x20 + (MD_INDEF_HIDDEN | MD_POSSESSIVE | MD_OBJECTIVE): res = "彼女自身"; break;
1583 case 0x20: res = "she"; break;
1584 case 0x20 + (MD_OBJECTIVE): res = "her"; break;
1585 case 0x20 + (MD_POSSESSIVE): res = "her"; break;
1586 case 0x20 + (MD_POSSESSIVE | MD_OBJECTIVE): res = "herself"; break;
1587 case 0x20 + (MD_INDEF_HIDDEN): res = "someone"; break;
1588 case 0x20 + (MD_INDEF_HIDDEN | MD_OBJECTIVE): res = "someone"; break;
1589 case 0x20 + (MD_INDEF_HIDDEN | MD_POSSESSIVE): res = "someone's"; break;
1590 case 0x20 + (MD_INDEF_HIDDEN | MD_POSSESSIVE | MD_OBJECTIVE): res = "herself"; break;
1594 /* Copy the result */
1595 (void)strcpy(desc, res);
1599 /* Handle visible monsters, "reflexive" request */
1600 else if ((mode & (MD_POSSESSIVE | MD_OBJECTIVE)) == (MD_POSSESSIVE | MD_OBJECTIVE))
1602 /* The monster is visible, so use its gender */
1604 if (r_ptr->flags1 & (RF1_FEMALE)) strcpy(desc, "彼女自身");
1605 else if (r_ptr->flags1 & (RF1_MALE)) strcpy(desc, "彼自身");
1606 else strcpy(desc, "それ自身");
1608 if (r_ptr->flags1 & RF1_FEMALE) strcpy(desc, "herself");
1609 else if (r_ptr->flags1 & RF1_MALE) strcpy(desc, "himself");
1610 else strcpy(desc, "itself");
1615 /* Handle all other visible monster requests */
1619 if (is_pet(m_ptr) && !is_original_ap(m_ptr))
1625 while(strncmp(t, "』", 2) && *t) t++;
1629 (void)sprintf(desc, "%s?』", buf);
1632 (void)sprintf(desc, "%s?", name);
1634 (void)sprintf(desc, "%s?", name);
1639 /* It could be a Unique */
1640 if ((r_ptr->flags1 & RF1_UNIQUE) && !(p_ptr->image && !(mode & MD_IGNORE_HALLU)))
1642 /* Start with the name (thus nominative and objective) */
1643 if ((m_ptr->mflag2 & MFLAG2_CHAMELEON) && !(mode & MD_TRUE_NAME))
1649 while (strncmp(t, "』", 2) && *t) t++;
1653 (void)sprintf(desc, "%s?』", buf);
1656 (void)sprintf(desc, "%s?", name);
1658 (void)sprintf(desc, "%s?", name);
1662 /* Inside monster arena, and it is not your mount */
1663 else if (p_ptr->inside_battle &&
1664 !(p_ptr->riding && (&m_list[p_ptr->riding] == m_ptr)))
1666 /* It is a fake unique monster */
1667 (void)sprintf(desc, _("%sもどき", "fake %s"), name);
1672 (void)strcpy(desc, name);
1676 /* It could be an indefinite monster */
1677 else if (mode & MD_INDEF_VISIBLE)
1679 /* XXX Check plurality for "some" */
1681 /* Indefinite monsters need an indefinite article */
1683 (void)strcpy(desc, "");
1685 (void)strcpy(desc, is_a_vowel(name[0]) ? "an " : "a ");
1688 (void)strcat(desc, name);
1691 /* It could be a normal, definite, monster */
1694 /* Definite monsters need a definite article */
1696 (void)strcpy(desc, _("あなたの", "your "));
1698 (void)strcpy(desc, _("", "the "));
1700 (void)strcat(desc, name);
1703 if (m_ptr->nickname)
1705 sprintf(buf,_("「%s」", " called %s"),quark_str(m_ptr->nickname));
1709 if (p_ptr->riding && (&m_list[p_ptr->riding] == m_ptr))
1711 strcat(desc,_("(乗馬中)", "(riding)"));
1714 if ((mode & MD_IGNORE_HALLU) && (m_ptr->mflag2 & MFLAG2_CHAMELEON))
1716 if (r_ptr->flags1 & RF1_UNIQUE)
1718 strcat(desc,_("(カメレオンの王)", "(Chameleon Lord)"));
1722 strcat(desc,_("(カメレオン)", "(Chameleon)"));
1726 if ((mode & MD_IGNORE_HALLU) && !is_original_ap(m_ptr))
1728 strcat(desc, format("(%s)", r_name + r_info[m_ptr->r_idx].name));
1731 /* Handle the Possessive as a special afterthought */
1732 if (mode & MD_POSSESSIVE)
1734 /* XXX Check for trailing "s" */
1736 /* Simply append "apostrophe" and "s" */
1737 (void)strcat(desc, _("の", "'s"));
1746 * Learn about a monster (by "probing" it)
1748 * Return the number of new flags learnt. -Mogami-
1750 int lore_do_probe(int r_idx)
1752 monster_race *r_ptr = &r_info[r_idx];
1756 /* Maximal info about awareness */
1757 if (r_ptr->r_wake != MAX_UCHAR) n++;
1758 if (r_ptr->r_ignore != MAX_UCHAR) n++;
1759 r_ptr->r_wake = r_ptr->r_ignore = MAX_UCHAR;
1761 /* Observe "maximal" attacks */
1762 for (i = 0; i < 4; i++)
1764 /* Examine "actual" blows */
1765 if (r_ptr->blow[i].effect || r_ptr->blow[i].method)
1767 /* Maximal observations */
1768 if (r_ptr->r_blows[i] != MAX_UCHAR) n++;
1769 r_ptr->r_blows[i] = MAX_UCHAR;
1775 (((r_ptr->flags1 & RF1_DROP_4D2) ? 8 : 0) +
1776 ((r_ptr->flags1 & RF1_DROP_3D2) ? 6 : 0) +
1777 ((r_ptr->flags1 & RF1_DROP_2D2) ? 4 : 0) +
1778 ((r_ptr->flags1 & RF1_DROP_1D2) ? 2 : 0) +
1779 ((r_ptr->flags1 & RF1_DROP_90) ? 1 : 0) +
1780 ((r_ptr->flags1 & RF1_DROP_60) ? 1 : 0));
1782 /* Only "valid" drops */
1783 if (!(r_ptr->flags1 & RF1_ONLY_GOLD))
1785 if (r_ptr->r_drop_item != tmp_byte) n++;
1786 r_ptr->r_drop_item = tmp_byte;
1788 if (!(r_ptr->flags1 & RF1_ONLY_ITEM))
1790 if (r_ptr->r_drop_gold != tmp_byte) n++;
1791 r_ptr->r_drop_gold = tmp_byte;
1794 /* Observe many spells */
1795 if (r_ptr->r_cast_spell != MAX_UCHAR) n++;
1796 r_ptr->r_cast_spell = MAX_UCHAR;
1798 /* Count unknown flags */
1799 for (i = 0; i < 32; i++)
1801 if (!(r_ptr->r_flags1 & (1L << i)) &&
1802 (r_ptr->flags1 & (1L << i))) n++;
1803 if (!(r_ptr->r_flags2 & (1L << i)) &&
1804 (r_ptr->flags2 & (1L << i))) n++;
1805 if (!(r_ptr->r_flags3 & (1L << i)) &&
1806 (r_ptr->flags3 & (1L << i))) n++;
1807 if (!(r_ptr->r_flags4 & (1L << i)) &&
1808 (r_ptr->flags4 & (1L << i))) n++;
1809 if (!(r_ptr->r_flags5 & (1L << i)) &&
1810 (r_ptr->flags5 & (1L << i))) n++;
1811 if (!(r_ptr->r_flags6 & (1L << i)) &&
1812 (r_ptr->flags6 & (1L << i))) n++;
1813 if (!(r_ptr->r_flagsr & (1L << i)) &&
1814 (r_ptr->flagsr & (1L << i))) n++;
1816 /* r_flags7 is actually unused */
1818 if (!(r_ptr->r_flags7 & (1L << i)) &&
1819 (r_ptr->flags7 & (1L << i))) n++;
1823 /* Know all the flags */
1824 r_ptr->r_flags1 = r_ptr->flags1;
1825 r_ptr->r_flags2 = r_ptr->flags2;
1826 r_ptr->r_flags3 = r_ptr->flags3;
1827 r_ptr->r_flags4 = r_ptr->flags4;
1828 r_ptr->r_flags5 = r_ptr->flags5;
1829 r_ptr->r_flags6 = r_ptr->flags6;
1830 r_ptr->r_flagsr = r_ptr->flagsr;
1832 /* r_flags7 is actually unused */
1833 /* r_ptr->r_flags7 = r_ptr->flags7; */
1835 /* Know about evolution */
1836 if (!(r_ptr->r_xtra1 & MR1_SINKA)) n++;
1837 r_ptr->r_xtra1 |= MR1_SINKA;
1839 /* Update monster recall window */
1840 if (p_ptr->monster_race_idx == r_idx)
1843 p_ptr->window |= (PW_MONSTER);
1846 /* Return the number of new flags learnt */
1852 * Take note that the given monster just dropped some treasure
1854 * Note that learning the "GOOD"/"GREAT" flags gives information
1855 * about the treasure (even when the monster is killed for the first
1856 * time, such as uniques, and the treasure has not been examined yet).
1858 * This "indirect" method is used to prevent the player from learning
1859 * exactly how much treasure a monster can drop from observing only
1860 * a single example of a drop. This method actually observes how much
1861 * gold and items are dropped, and remembers that information to be
1862 * described later by the monster recall code.
1864 void lore_treasure(int m_idx, int num_item, int num_gold)
1866 monster_type *m_ptr = &m_list[m_idx];
1868 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1870 /* If the monster doesn't have original appearance, don't note */
1871 if (!is_original_ap(m_ptr)) return;
1873 /* Note the number of things dropped */
1874 if (num_item > r_ptr->r_drop_item) r_ptr->r_drop_item = num_item;
1875 if (num_gold > r_ptr->r_drop_gold) r_ptr->r_drop_gold = num_gold;
1877 /* Hack -- memorize the good/great flags */
1878 if (r_ptr->flags1 & (RF1_DROP_GOOD)) r_ptr->r_flags1 |= (RF1_DROP_GOOD);
1879 if (r_ptr->flags1 & (RF1_DROP_GREAT)) r_ptr->r_flags1 |= (RF1_DROP_GREAT);
1881 /* Update monster recall window */
1882 if (p_ptr->monster_race_idx == m_ptr->r_idx)
1885 p_ptr->window |= (PW_MONSTER);
1891 void sanity_blast(monster_type *m_ptr, bool necro)
1893 bool happened = FALSE;
1896 if (p_ptr->inside_battle || !character_dungeon) return;
1901 monster_race *r_ptr = &r_info[m_ptr->ap_r_idx];
1903 power = r_ptr->level / 2;
1905 monster_desc(m_name, m_ptr, 0);
1907 if (!(r_ptr->flags1 & RF1_UNIQUE))
1909 if (r_ptr->flags1 & RF1_FRIENDS)
1915 return; /* No effect yet, just loaded... */
1918 return; /* Cannot see it for some reason */
1920 if (!(r_ptr->flags2 & RF2_ELDRITCH_HORROR))
1926 return; /* Pet eldritch horrors are safe most of the time */
1928 if (randint1(100) > power) return;
1930 if (saving_throw(p_ptr->skill_sav - power))
1932 return; /* Save, no adverse effects */
1937 /* Something silly happens... */
1939 msg_format("%s%sの顔を見てしまった!",
1940 funny_desc[randint0(MAX_SAN_FUNNY)], m_name);
1942 msg_format("You behold the %s visage of %s!",
1943 funny_desc[randint0(MAX_SAN_FUNNY)], m_name);
1949 msg_print(funny_comments[randint0(MAX_SAN_COMMENT)]);
1950 p_ptr->image = p_ptr->image + randint1(r_ptr->level);
1953 return; /* Never mind; we can't see it clearly enough */
1956 /* Something frightening happens... */
1958 msg_format("%s%sの顔を見てしまった!",
1959 horror_desc[randint0(MAX_SAN_HORROR)], m_name);
1961 msg_format("You behold the %s visage of %s!",
1962 horror_desc[randint0(MAX_SAN_HORROR)], m_name);
1965 r_ptr->r_flags2 |= RF2_ELDRITCH_HORROR;
1967 /* Demon characters are unaffected */
1968 if (prace_is_(RACE_IMP) || prace_is_(RACE_DEMON) || (mimic_info[p_ptr->mimic_form].MIMIC_FLAGS & MIMIC_IS_DEMON)) return;
1969 if (p_ptr->wizard) return;
1971 /* Undead characters are 50% likely to be unaffected */
1972 if (prace_is_(RACE_SKELETON) || prace_is_(RACE_ZOMBIE)
1973 || prace_is_(RACE_VAMPIRE) || prace_is_(RACE_SPECTRE) ||
1974 (mimic_info[p_ptr->mimic_form].MIMIC_FLAGS & MIMIC_IS_UNDEAD))
1976 if (saving_throw(25 + p_ptr->lev)) return;
1981 msg_print(_("ネクロノミコンを読んで正気を失った!", "Your sanity is shaken by reading the Necronomicon!"));
1984 if (!saving_throw(p_ptr->skill_sav - power)) /* Mind blast */
1986 if (!p_ptr->resist_conf)
1988 (void)set_confused(p_ptr->confused + randint0(4) + 4);
1990 if (!p_ptr->resist_chaos && one_in_(3))
1992 (void)set_image(p_ptr->image + randint0(250) + 150);
1997 if (!saving_throw(p_ptr->skill_sav - power)) /* Lose int & wis */
2004 if (!saving_throw(p_ptr->skill_sav - power)) /* Brain smash */
2006 if (!p_ptr->resist_conf)
2008 (void)set_confused(p_ptr->confused + randint0(4) + 4);
2010 if (!p_ptr->free_act)
2012 (void)set_paralyzed(p_ptr->paralyzed + randint0(4) + 4);
2014 while (randint0(100) > p_ptr->skill_sav)
2015 (void)do_dec_stat(A_INT);
2016 while (randint0(100) > p_ptr->skill_sav)
2017 (void)do_dec_stat(A_WIS);
2018 if (!p_ptr->resist_chaos)
2020 (void)set_image(p_ptr->image + randint0(250) + 150);
2025 if (!saving_throw(p_ptr->skill_sav - power)) /* Amnesia */
2028 if (lose_all_info())
2029 msg_print(_("あまりの恐怖に全てのことを忘れてしまった!", "You forget everything in your utmost terror!"));
2034 if (saving_throw(p_ptr->skill_sav - power))
2039 /* Else gain permanent insanity */
2040 if ((p_ptr->muta3 & MUT3_MORONIC) && /*(p_ptr->muta2 & MUT2_BERS_RAGE) &&*/
2041 ((p_ptr->muta2 & MUT2_COWARDICE) || (p_ptr->resist_fear)) &&
2042 ((p_ptr->muta2 & MUT2_HALLU) || (p_ptr->resist_chaos)))
2044 /* The poor bastard already has all possible insanities! */
2050 switch (randint1(21))
2053 if (!(p_ptr->muta3 & MUT3_MORONIC) && one_in_(5))
2055 if ((p_ptr->stat_use[A_INT] < 4) && (p_ptr->stat_use[A_WIS] < 4))
2057 msg_print(_("あなたは完璧な馬鹿になったような気がした。しかしそれは元々だった。", "You turn into an utter moron!"));
2061 msg_print(_("あなたは完璧な馬鹿になった!", "You turn into an utter moron!"));
2064 if (p_ptr->muta3 & MUT3_HYPER_INT)
2066 msg_print(_("あなたの脳は生体コンピュータではなくなった。", "Your brain is no longer a living computer."));
2067 p_ptr->muta3 &= ~(MUT3_HYPER_INT);
2069 p_ptr->muta3 |= MUT3_MORONIC;
2083 if (!(p_ptr->muta2 & MUT2_COWARDICE) && !p_ptr->resist_fear)
2085 msg_print(_("あなたはパラノイアになった!", "You become paranoid!"));
2087 /* Duh, the following should never happen, but anyway... */
2088 if (p_ptr->muta3 & MUT3_FEARLESS)
2090 msg_print(_("あなたはもう恐れ知らずではなくなった。", "You are no longer fearless."));
2091 p_ptr->muta3 &= ~(MUT3_FEARLESS);
2094 p_ptr->muta2 |= MUT2_COWARDICE;
2108 if (!(p_ptr->muta2 & MUT2_HALLU) && !p_ptr->resist_chaos)
2110 msg_print(_("幻覚をひき起こす精神錯乱に陥った!", "You are afflicted by a hallucinatory insanity!"));
2111 p_ptr->muta2 |= MUT2_HALLU;
2116 if (!(p_ptr->muta2 & MUT2_BERS_RAGE))
2118 msg_print(_("激烈な感情の発作におそわれるようになった!", "You become subject to fits of berserk rage!"));
2119 p_ptr->muta2 |= MUT2_BERS_RAGE;
2126 p_ptr->update |= PU_BONUS;
2132 * This function updates the monster record of the given monster
2134 * This involves extracting the distance to the player (if requested),
2135 * and then checking for visibility (natural, infravision, see-invis,
2136 * telepathy), updating the monster visibility flag, redrawing (or
2137 * erasing) the monster when its visibility changes, and taking note
2138 * of any interesting monster flags (cold-blooded, invisible, etc).
2140 * Note the new "mflag" field which encodes several monster state flags,
2141 * including "view" for when the monster is currently in line of sight,
2142 * and "mark" for when the monster is currently visible via detection.
2144 * The only monster fields that are changed here are "cdis" (the
2145 * distance from the player), "ml" (visible to the player), and
2146 * "mflag" (to maintain the "MFLAG_VIEW" flag).
2148 * Note the special "update_monsters()" function which can be used to
2149 * call this function once for every monster.
2151 * Note the "full" flag which requests that the "cdis" field be updated,
2152 * this is only needed when the monster (or the player) has moved.
2154 * Every time a monster moves, we must call this function for that
2155 * monster, and update the distance, and the visibility. Every time
2156 * the player moves, we must call this function for every monster, and
2157 * update the distance, and the visibility. Whenever the player "state"
2158 * changes in certain ways ("blindness", "infravision", "telepathy",
2159 * and "see invisible"), we must call this function for every monster,
2160 * and update the visibility.
2162 * Routines that change the "illumination" of a grid must also call this
2163 * function for any monster in that grid, since the "visibility" of some
2164 * monsters may be based on the illumination of their grid.
2166 * Note that this function is called once per monster every time the
2167 * player moves. When the player is running, this function is one
2168 * of the primary bottlenecks, along with "update_view()" and the
2169 * "process_monsters()" code, so efficiency is important.
2171 * Note the optimized "inline" version of the "distance()" function.
2173 * A monster is "visible" to the player if (1) it has been detected
2174 * by the player, (2) it is close to the player and the player has
2175 * telepathy, or (3) it is close to the player, and in line of sight
2176 * of the player, and it is "illuminated" by some combination of
2177 * infravision, torch light, or permanent light (invisible monsters
2178 * are only affected by "light" if the player can see invisible).
2180 * Monsters which are not on the current panel may be "visible" to
2181 * the player, and their descriptions will include an "offscreen"
2182 * reference. Currently, offscreen monsters cannot be targetted
2183 * or viewed directly, but old targets will remain set. XXX XXX
2185 * The player can choose to be disturbed by several things, including
2186 * "disturb_move" (monster which is viewable moves in some way), and
2187 * "disturb_near" (monster which is "easily" viewable moves in some
2188 * way). Note that "moves" includes "appears" and "disappears".
2190 void update_mon(int m_idx, bool full)
2192 monster_type *m_ptr = &m_list[m_idx];
2194 monster_race *r_ptr = &r_info[m_ptr->r_idx];
2196 bool do_disturb = disturb_move;
2200 /* Current location */
2207 /* Seen by vision */
2210 /* Non-Ninja player in the darkness */
2211 bool in_darkness = (d_info[dungeon_type].flags1 & DF1_DARKNESS) && !p_ptr->see_nocto;
2216 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
2218 if (ap_r_ptr->r_tkills && ap_r_ptr->level >= p_ptr->lev)
2222 /* Compute distance */
2225 /* Distance components */
2226 int dy = (py > fy) ? (py - fy) : (fy - py);
2227 int dx = (px > fx) ? (px - fx) : (fx - px);
2229 /* Approximate distance */
2230 d = (dy > dx) ? (dy + (dx>>1)) : (dx + (dy>>1));
2232 /* Restrict distance */
2233 if (d > 255) d = 255;
2237 /* Save the distance */
2241 /* Extract distance */
2244 /* Extract the distance */
2250 if (m_ptr->mflag2 & (MFLAG2_MARK)) flag = TRUE;
2254 if (d <= (in_darkness ? MAX_SIGHT / 2 : MAX_SIGHT))
2256 if (!in_darkness || (d <= MAX_SIGHT / 4))
2258 if (p_ptr->special_defense & KATA_MUSOU)
2263 if (is_original_ap(m_ptr) && !p_ptr->image)
2265 /* Hack -- Memorize mental flags */
2266 if (r_ptr->flags2 & (RF2_SMART)) r_ptr->r_flags2 |= (RF2_SMART);
2267 if (r_ptr->flags2 & (RF2_STUPID)) r_ptr->r_flags2 |= (RF2_STUPID);
2271 /* Basic telepathy */
2272 /* Snipers get telepathy when they concentrate deeper */
2273 else if (p_ptr->telepathy)
2275 /* Empty mind, no telepathy */
2276 if (r_ptr->flags2 & (RF2_EMPTY_MIND))
2278 /* Memorize flags */
2279 if (is_original_ap(m_ptr) && !p_ptr->image) 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 if (is_original_ap(m_ptr) && !p_ptr->image)
2293 /* Memorize flags */
2294 r_ptr->r_flags2 |= (RF2_WEIRD_MIND);
2296 /* Hack -- Memorize mental flags */
2297 if (r_ptr->flags2 & (RF2_SMART)) r_ptr->r_flags2 |= (RF2_SMART);
2298 if (r_ptr->flags2 & (RF2_STUPID)) r_ptr->r_flags2 |= (RF2_STUPID);
2303 /* Normal mind, allow telepathy */
2309 if (is_original_ap(m_ptr) && !p_ptr->image)
2311 /* Hack -- Memorize mental flags */
2312 if (r_ptr->flags2 & (RF2_SMART)) r_ptr->r_flags2 |= (RF2_SMART);
2313 if (r_ptr->flags2 & (RF2_STUPID)) r_ptr->r_flags2 |= (RF2_STUPID);
2318 /* Magical sensing */
2319 if ((p_ptr->esp_animal) && (r_ptr->flags3 & (RF3_ANIMAL)))
2322 if (is_original_ap(m_ptr) && !p_ptr->image) r_ptr->r_flags3 |= (RF3_ANIMAL);
2325 /* Magical sensing */
2326 if ((p_ptr->esp_undead) && (r_ptr->flags3 & (RF3_UNDEAD)))
2329 if (is_original_ap(m_ptr) && !p_ptr->image) r_ptr->r_flags3 |= (RF3_UNDEAD);
2332 /* Magical sensing */
2333 if ((p_ptr->esp_demon) && (r_ptr->flags3 & (RF3_DEMON)))
2336 if (is_original_ap(m_ptr) && !p_ptr->image) r_ptr->r_flags3 |= (RF3_DEMON);
2339 /* Magical sensing */
2340 if ((p_ptr->esp_orc) && (r_ptr->flags3 & (RF3_ORC)))
2343 if (is_original_ap(m_ptr) && !p_ptr->image) r_ptr->r_flags3 |= (RF3_ORC);
2346 /* Magical sensing */
2347 if ((p_ptr->esp_troll) && (r_ptr->flags3 & (RF3_TROLL)))
2350 if (is_original_ap(m_ptr) && !p_ptr->image) r_ptr->r_flags3 |= (RF3_TROLL);
2353 /* Magical sensing */
2354 if ((p_ptr->esp_giant) && (r_ptr->flags3 & (RF3_GIANT)))
2357 if (is_original_ap(m_ptr) && !p_ptr->image) r_ptr->r_flags3 |= (RF3_GIANT);
2360 /* Magical sensing */
2361 if ((p_ptr->esp_dragon) && (r_ptr->flags3 & (RF3_DRAGON)))
2364 if (is_original_ap(m_ptr) && !p_ptr->image) r_ptr->r_flags3 |= (RF3_DRAGON);
2367 /* Magical sensing */
2368 if ((p_ptr->esp_human) && (r_ptr->flags2 & (RF2_HUMAN)))
2371 if (is_original_ap(m_ptr) && !p_ptr->image) r_ptr->r_flags2 |= (RF2_HUMAN);
2374 /* Magical sensing */
2375 if ((p_ptr->esp_evil) && (r_ptr->flags3 & (RF3_EVIL)))
2378 if (is_original_ap(m_ptr) && !p_ptr->image) r_ptr->r_flags3 |= (RF3_EVIL);
2381 /* Magical sensing */
2382 if ((p_ptr->esp_good) && (r_ptr->flags3 & (RF3_GOOD)))
2385 if (is_original_ap(m_ptr) && !p_ptr->image) r_ptr->r_flags3 |= (RF3_GOOD);
2388 /* Magical sensing */
2389 if ((p_ptr->esp_nonliving) &&
2390 ((r_ptr->flags3 & (RF3_DEMON | RF3_UNDEAD | RF3_NONLIVING)) == RF3_NONLIVING))
2393 if (is_original_ap(m_ptr) && !p_ptr->image) r_ptr->r_flags3 |= (RF3_NONLIVING);
2396 /* Magical sensing */
2397 if ((p_ptr->esp_unique) && (r_ptr->flags1 & (RF1_UNIQUE)))
2400 if (is_original_ap(m_ptr) && !p_ptr->image) r_ptr->r_flags1 |= (RF1_UNIQUE);
2404 /* Normal line of sight, and not blind */
2405 if (player_has_los_bold(fy, fx) && !p_ptr->blind)
2407 bool do_invisible = FALSE;
2408 bool do_cold_blood = FALSE;
2410 /* Snipers can see targets in darkness when they concentrate deeper */
2411 if (p_ptr->concent >= CONCENT_RADAR_THRESHOLD)
2417 /* Use "infravision" */
2418 if (d <= p_ptr->see_infra)
2420 /* Handle "cold blooded" monsters */
2421 if ((r_ptr->flags2 & (RF2_COLD_BLOOD | RF2_AURA_FIRE)) == RF2_COLD_BLOOD)
2424 do_cold_blood = TRUE;
2427 /* Handle "warm blooded" monsters */
2435 /* Use "illumination" */
2436 if (player_can_see_bold(fy, fx))
2438 /* Handle "invisible" monsters */
2439 if (r_ptr->flags2 & (RF2_INVISIBLE))
2442 do_invisible = TRUE;
2452 /* Handle "normal" monsters */
2463 if (is_original_ap(m_ptr) && !p_ptr->image)
2465 /* Memorize flags */
2466 if (do_invisible) r_ptr->r_flags2 |= (RF2_INVISIBLE);
2467 if (do_cold_blood) r_ptr->r_flags2 |= (RF2_COLD_BLOOD);
2474 /* The monster is now visible */
2477 /* It was previously unseen */
2480 /* Mark as visible */
2483 /* Draw the monster */
2486 /* Update health bar as needed */
2487 if (p_ptr->health_who == m_idx) p_ptr->redraw |= (PR_HEALTH);
2488 if (p_ptr->riding == m_idx) p_ptr->redraw |= (PR_UHEALTH);
2490 /* Hack -- Count "fresh" sightings */
2493 if ((m_ptr->ap_r_idx == MON_KAGE) && (r_info[MON_KAGE].r_sights < MAX_SHORT))
2494 r_info[MON_KAGE].r_sights++;
2495 else if (is_original_ap(m_ptr) && (r_ptr->r_sights < MAX_SHORT))
2499 /* Eldritch Horror */
2500 if (r_info[m_ptr->ap_r_idx].flags2 & RF2_ELDRITCH_HORROR)
2502 sanity_blast(m_ptr, FALSE);
2505 /* Disturb on appearance */
2506 if (disturb_near && (projectable(m_ptr->fy, m_ptr->fx, py, px) && projectable(py, px, m_ptr->fy, m_ptr->fx)))
2508 if (disturb_pets || is_hostile(m_ptr))
2514 /* The monster is not visible */
2517 /* It was previously seen */
2520 /* Mark as not visible */
2523 /* Erase the monster */
2526 /* Update health bar as needed */
2527 if (p_ptr->health_who == m_idx) p_ptr->redraw |= (PR_HEALTH);
2528 if (p_ptr->riding == m_idx) p_ptr->redraw |= (PR_UHEALTH);
2530 /* Disturb on disappearance */
2533 if (disturb_pets || is_hostile(m_ptr))
2540 /* The monster is now easily visible */
2544 if (!(m_ptr->mflag & (MFLAG_VIEW)))
2546 /* Mark as easily visible */
2547 m_ptr->mflag |= (MFLAG_VIEW);
2549 /* Disturb on appearance */
2552 if (disturb_pets || is_hostile(m_ptr))
2558 /* The monster is not easily visible */
2562 if (m_ptr->mflag & (MFLAG_VIEW))
2564 /* Mark as not easily visible */
2565 m_ptr->mflag &= ~(MFLAG_VIEW);
2567 /* Disturb on disappearance */
2570 if (disturb_pets || is_hostile(m_ptr))
2579 * This function simply updates all the (non-dead) monsters (see above).
2581 void update_monsters(bool full)
2585 /* Update each (live) monster */
2586 for (i = 1; i < m_max; i++)
2588 monster_type *m_ptr = &m_list[i];
2590 /* Skip dead monsters */
2591 if (!m_ptr->r_idx) continue;
2593 /* Update the monster */
2594 update_mon(i, full);
2600 * Hack -- the index of the summoning monster
2602 static bool monster_hook_chameleon_lord(int r_idx)
2604 monster_race *r_ptr = &r_info[r_idx];
2605 monster_type *m_ptr = &m_list[chameleon_change_m_idx];
2606 monster_race *old_r_ptr = &r_info[m_ptr->r_idx];
2608 if (!(r_ptr->flags1 & (RF1_UNIQUE))) return FALSE;
2609 if (r_ptr->flags7 & (RF7_FRIENDLY | RF7_CHAMELEON)) return FALSE;
2611 if (ABS(r_ptr->level - r_info[MON_CHAMELEON_K].level) > 5) return FALSE;
2613 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))
2616 if (!monster_can_cross_terrain(cave[m_ptr->fy][m_ptr->fx].feat, r_ptr, 0)) return FALSE;
2619 if (!(old_r_ptr->flags7 & RF7_CHAMELEON))
2621 if (monster_has_hostile_align(m_ptr, 0, 0, r_ptr)) return FALSE;
2625 else if (summon_specific_who > 0)
2627 if (monster_has_hostile_align(&m_list[summon_specific_who], 0, 0, r_ptr)) return FALSE;
2633 static bool monster_hook_chameleon(int r_idx)
2635 monster_race *r_ptr = &r_info[r_idx];
2636 monster_type *m_ptr = &m_list[chameleon_change_m_idx];
2637 monster_race *old_r_ptr = &r_info[m_ptr->r_idx];
2639 if (r_ptr->flags1 & (RF1_UNIQUE)) return FALSE;
2640 if (r_ptr->flags2 & RF2_MULTIPLY) return FALSE;
2641 if (r_ptr->flags7 & (RF7_FRIENDLY | RF7_CHAMELEON)) return FALSE;
2643 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))
2646 if (!monster_can_cross_terrain(cave[m_ptr->fy][m_ptr->fx].feat, r_ptr, 0)) return FALSE;
2649 if (!(old_r_ptr->flags7 & RF7_CHAMELEON))
2651 if ((old_r_ptr->flags3 & RF3_GOOD) && !(r_ptr->flags3 & RF3_GOOD)) return FALSE;
2652 if ((old_r_ptr->flags3 & RF3_EVIL) && !(r_ptr->flags3 & RF3_EVIL)) return FALSE;
2653 if (!(old_r_ptr->flags3 & (RF3_GOOD | RF3_EVIL)) && (r_ptr->flags3 & (RF3_GOOD | RF3_EVIL))) return FALSE;
2657 else if (summon_specific_who > 0)
2659 if (monster_has_hostile_align(&m_list[summon_specific_who], 0, 0, r_ptr)) return FALSE;
2662 return (*(get_monster_hook()))(r_idx);
2666 void choose_new_monster(int m_idx, bool born, int r_idx)
2669 monster_type *m_ptr = &m_list[m_idx];
2670 monster_race *r_ptr;
2671 char old_m_name[80];
2672 bool old_unique = FALSE;
2673 int old_r_idx = m_ptr->r_idx;
2675 if (r_info[m_ptr->r_idx].flags1 & RF1_UNIQUE)
2677 if (old_unique && (r_idx == MON_CHAMELEON)) r_idx = MON_CHAMELEON_K;
2678 r_ptr = &r_info[r_idx];
2680 monster_desc(old_m_name, m_ptr, 0);
2686 chameleon_change_m_idx = m_idx;
2688 get_mon_num_prep(monster_hook_chameleon_lord, NULL);
2690 get_mon_num_prep(monster_hook_chameleon, NULL);
2693 level = r_info[MON_CHAMELEON_K].level;
2694 else if (!dun_level)
2695 level = wilderness[p_ptr->wilderness_y][p_ptr->wilderness_x].level;
2699 if (d_info[dungeon_type].flags1 & DF1_CHAMELEON) level+= 2+randint1(3);
2701 r_idx = get_mon_num(level);
2702 r_ptr = &r_info[r_idx];
2704 chameleon_change_m_idx = 0;
2710 if (is_pet(m_ptr)) check_pets_num_and_align(m_ptr, FALSE);
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);
2717 if ((r_info[old_r_idx].flags7 & (RF7_LITE_MASK | RF7_DARK_MASK)) ||
2718 (r_ptr->flags7 & (RF7_LITE_MASK | RF7_DARK_MASK)))
2719 p_ptr->update |= (PU_MON_LITE);
2721 if (is_pet(m_ptr)) check_pets_num_and_align(m_ptr, TRUE);
2725 /* Sub-alignment of a chameleon */
2726 if (r_ptr->flags3 & (RF3_EVIL | RF3_GOOD))
2728 m_ptr->sub_align = SUB_ALIGN_NEUTRAL;
2729 if (r_ptr->flags3 & RF3_EVIL) m_ptr->sub_align |= SUB_ALIGN_EVIL;
2730 if (r_ptr->flags3 & RF3_GOOD) m_ptr->sub_align |= SUB_ALIGN_GOOD;
2735 if (m_idx == p_ptr->riding)
2738 monster_desc(m_name, m_ptr, 0);
2739 msg_format(_("突然%sが変身した。", "Suddenly, %s transforms!"), old_m_name);
2740 if (!(r_ptr->flags7 & RF7_RIDING))
2741 if (rakuba(0, TRUE)) msg_format(_("地面に落とされた。", "You have fallen from %s."), m_name);
2744 /* Extract the monster base speed */
2745 m_ptr->mspeed = get_mspeed(r_ptr);
2747 oldmaxhp = m_ptr->max_maxhp;
2748 /* Assign maximal hitpoints */
2749 if (r_ptr->flags1 & RF1_FORCE_MAXHP)
2751 m_ptr->max_maxhp = maxroll(r_ptr->hdice, r_ptr->hside);
2755 m_ptr->max_maxhp = damroll(r_ptr->hdice, r_ptr->hside);
2758 /* Monsters have double hitpoints in Nightmare mode */
2759 if (ironman_nightmare)
2761 u32b hp = m_ptr->max_maxhp * 2L;
2762 m_ptr->max_maxhp = (s16b)MIN(30000, hp);
2765 m_ptr->maxhp = (long)(m_ptr->maxhp * m_ptr->max_maxhp) / oldmaxhp;
2766 if (m_ptr->maxhp < 1) m_ptr->maxhp = 1;
2767 m_ptr->hp = (long)(m_ptr->hp * m_ptr->max_maxhp) / oldmaxhp;
2769 /* reset dealt_damage */
2770 m_ptr->dealt_damage = 0;
2777 static bool monster_hook_tanuki(int r_idx)
2779 monster_race *r_ptr = &r_info[r_idx];
2781 if (r_ptr->flags1 & (RF1_UNIQUE)) return FALSE;
2782 if (r_ptr->flags2 & RF2_MULTIPLY) return FALSE;
2783 if (r_ptr->flags7 & (RF7_FRIENDLY | RF7_CHAMELEON)) return FALSE;
2784 if (r_ptr->flags7 & RF7_AQUATIC) return FALSE;
2786 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))
2789 return (*(get_monster_hook()))(r_idx);
2794 * Set initial racial appearance of a monster
2796 static int initial_r_appearance(int r_idx)
2798 int attempts = 1000;
2801 int min = MIN(base_level-5, 50);
2803 if (!(r_info[r_idx].flags7 & RF7_TANUKI))
2806 get_mon_num_prep(monster_hook_tanuki, NULL);
2810 ap_r_idx = get_mon_num(base_level + 10);
2811 if (r_info[ap_r_idx].level >= min) return ap_r_idx;
2819 * Get initial monster speed
2821 byte get_mspeed(monster_race *r_ptr)
2823 /* Extract the monster base speed */
2824 int mspeed = r_ptr->speed;
2826 /* Hack -- small racial variety */
2827 if (!(r_ptr->flags1 & RF1_UNIQUE) && !p_ptr->inside_arena)
2829 /* Allow some small variation per monster */
2830 int i = SPEED_TO_ENERGY(r_ptr->speed) / (one_in_(4) ? 3 : 10);
2831 if (i) mspeed += rand_spread(0, i);
2834 if (mspeed > 199) mspeed = 199;
2836 return (byte)mspeed;
2841 * Attempt to place a monster of the given race at the given location.
2843 * To give the player a sporting chance, any monster that appears in
2844 * line-of-sight and is extremely dangerous can be marked as
2845 * "FORCE_SLEEP", which will cause them to be placed with low energy,
2846 * which often (but not always) lets the player move before they do.
2848 * This routine refuses to place out-of-depth "FORCE_DEPTH" monsters.
2850 * XXX XXX XXX Use special "here" and "dead" flags for unique monsters,
2851 * remove old "cur_num" and "max_num" fields.
2853 * XXX XXX XXX Actually, do something similar for artifacts, to simplify
2854 * the "preserve" mode, and to make the "what artifacts" flag more useful.
2856 * This is the only function which may place a monster in the dungeon,
2857 * except for the savefile loading code.
2859 static bool place_monster_one(int who, int y, int x, int r_idx, u32b mode)
2861 /* Access the location */
2862 cave_type *c_ptr = &cave[y][x];
2864 monster_type *m_ptr;
2866 monster_race *r_ptr = &r_info[r_idx];
2868 cptr name = (r_name + r_ptr->name);
2872 /* DO NOT PLACE A MONSTER IN THE SMALL SCALE WILDERNESS !!! */
2873 if (p_ptr->wild_mode) return FALSE;
2875 /* Verify location */
2876 if (!in_bounds(y, x)) return (FALSE);
2879 if (!r_idx) return (FALSE);
2882 if (!r_ptr->name) return (FALSE);
2884 if (!(mode & PM_IGNORE_TERRAIN))
2886 /* Not on the Pattern */
2887 if (pattern_tile(y, x)) return FALSE;
2889 /* Require empty space (if not ghostly) */
2890 if (!monster_can_enter(y, x, r_ptr, 0)) return FALSE;
2893 if (!p_ptr->inside_battle)
2895 /* Hack -- "unique" monsters must be "unique" */
2896 if (((r_ptr->flags1 & (RF1_UNIQUE)) ||
2897 (r_ptr->flags7 & (RF7_NAZGUL))) &&
2898 (r_ptr->cur_num >= r_ptr->max_num))
2904 if ((r_ptr->flags7 & (RF7_UNIQUE2)) &&
2905 (r_ptr->cur_num >= 1))
2910 if (r_idx == MON_BANORLUPART)
2912 if (r_info[MON_BANOR].cur_num > 0) return FALSE;
2913 if (r_info[MON_LUPART].cur_num > 0) return FALSE;
2916 /* Depth monsters may NOT be created out of depth, unless in Nightmare mode */
2917 if ((r_ptr->flags1 & (RF1_FORCE_DEPTH)) && (dun_level < r_ptr->level) &&
2918 (!ironman_nightmare || (r_ptr->flags1 & (RF1_QUESTOR))))
2925 if (quest_number(dun_level))
2927 int hoge = quest_number(dun_level);
2928 if ((quest[hoge].type == QUEST_TYPE_KILL_LEVEL) || (quest[hoge].type == QUEST_TYPE_RANDOM))
2930 if(r_idx == quest[hoge].r_idx)
2932 int number_mon, i2, j2;
2935 /* Count all quest monsters */
2936 for (i2 = 0; i2 < cur_wid; ++i2)
2937 for (j2 = 0; j2 < cur_hgt; j2++)
2938 if (cave[j2][i2].m_idx > 0)
2939 if (m_list[cave[j2][i2].m_idx].r_idx == quest[hoge].r_idx)
2941 if(number_mon + quest[hoge].cur_num >= quest[hoge].max_num)
2947 if (is_glyph_grid(c_ptr))
2949 if (randint1(BREAK_GLYPH) < (r_ptr->level+20))
2951 /* Describe observable breakage */
2952 if (c_ptr->info & CAVE_MARK)
2954 msg_print(_("守りのルーンが壊れた!", "The rune of protection is broken!"));
2957 /* Forget the rune */
2958 c_ptr->info &= ~(CAVE_MARK);
2960 /* Break the rune */
2961 c_ptr->info &= ~(CAVE_OBJECT);
2970 /* Powerful monster */
2971 if (r_ptr->level > dun_level)
2973 /* Unique monsters */
2974 if (r_ptr->flags1 & (RF1_UNIQUE))
2976 /* Message for cheaters */
2977 if (cheat_hear) msg_format(_("深層のユニーク・モンスター (%s)。", "Deep Unique (%s)."), name);
2980 /* Normal monsters */
2983 /* Message for cheaters */
2984 if (cheat_hear) msg_format(_("深層のモンスター (%s)。", "Deep Monster (%s)."), name);
2988 /* Note the monster */
2989 else if (r_ptr->flags1 & (RF1_UNIQUE))
2991 /* Unique monsters induce message */
2992 if (cheat_hear) msg_format(_("ユニーク・モンスター (%s)。", "Unique (%s)."), name);
2995 if ((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags7 & RF7_NAZGUL) || (r_ptr->level < 10)) mode &= ~PM_KAGE;
2997 /* Make a new monster */
2998 c_ptr->m_idx = m_pop();
2999 hack_m_idx_ii = c_ptr->m_idx;
3001 /* Mega-Hack -- catch "failure" */
3002 if (!c_ptr->m_idx) return (FALSE);
3005 /* Get a new monster record */
3006 m_ptr = &m_list[c_ptr->m_idx];
3009 m_ptr->r_idx = r_idx;
3010 m_ptr->ap_r_idx = initial_r_appearance(r_idx);
3016 /* Hack -- Appearance transfer */
3017 if ((mode & PM_MULTIPLY) && (who > 0) && !is_original_ap(&m_list[who]))
3019 m_ptr->ap_r_idx = m_list[who].ap_r_idx;
3021 /* Hack -- Shadower spawns Shadower */
3022 if (m_list[who].mflag2 & MFLAG2_KAGE) m_ptr->mflag2 |= MFLAG2_KAGE;
3025 /* Sub-alignment of a monster */
3026 if ((who > 0) && !(r_ptr->flags3 & (RF3_EVIL | RF3_GOOD)))
3027 m_ptr->sub_align = m_list[who].sub_align;
3030 m_ptr->sub_align = SUB_ALIGN_NEUTRAL;
3031 if (r_ptr->flags3 & RF3_EVIL) m_ptr->sub_align |= SUB_ALIGN_EVIL;
3032 if (r_ptr->flags3 & RF3_GOOD) m_ptr->sub_align |= SUB_ALIGN_GOOD;
3035 /* Place the monster at the location */
3040 /* No "timed status" yet */
3041 for (cmi = 0; cmi < MAX_MTIMED; cmi++) m_ptr->mtimed[cmi] = 0;
3043 /* Unknown distance */
3046 reset_target(m_ptr);
3048 m_ptr->nickname = 0;
3053 /* Your pet summons its pet. */
3054 if (who > 0 && is_pet(&m_list[who]))
3056 mode |= PM_FORCE_PET;
3057 m_ptr->parent_m_idx = who;
3061 m_ptr->parent_m_idx = 0;
3064 if (r_ptr->flags7 & RF7_CHAMELEON)
3066 choose_new_monster(c_ptr->m_idx, TRUE, 0);
3067 r_ptr = &r_info[m_ptr->r_idx];
3068 m_ptr->mflag2 |= MFLAG2_CHAMELEON;
3070 /* Hack - Set sub_align to neutral when the Chameleon Lord is generated as "GUARDIAN" */
3071 if ((r_ptr->flags1 & RF1_UNIQUE) && (who <= 0))
3072 m_ptr->sub_align = SUB_ALIGN_NEUTRAL;
3074 else if ((mode & PM_KAGE) && !(mode & PM_FORCE_PET))
3076 m_ptr->ap_r_idx = MON_KAGE;
3077 m_ptr->mflag2 |= MFLAG2_KAGE;
3080 if (mode & PM_NO_PET) m_ptr->mflag2 |= MFLAG2_NOPET;
3086 if (mode & PM_FORCE_PET)
3091 else if ((r_ptr->flags7 & RF7_FRIENDLY) ||
3092 (mode & PM_FORCE_FRIENDLY) || is_friendly_idx(who))
3094 if (!monster_has_hostile_align(NULL, 0, -1, r_ptr)) set_friendly(m_ptr);
3097 /* Assume no sleeping */
3098 m_ptr->mtimed[MTIMED_CSLEEP] = 0;
3100 /* Enforce sleeping if needed */
3101 if ((mode & PM_ALLOW_SLEEP) && r_ptr->sleep && !ironman_nightmare)
3103 int val = r_ptr->sleep;
3104 (void)set_monster_csleep(c_ptr->m_idx, (val * 2) + randint1(val * 10));
3107 /* Assign maximal hitpoints */
3108 if (r_ptr->flags1 & RF1_FORCE_MAXHP)
3110 m_ptr->max_maxhp = maxroll(r_ptr->hdice, r_ptr->hside);
3114 m_ptr->max_maxhp = damroll(r_ptr->hdice, r_ptr->hside);
3117 /* Monsters have double hitpoints in Nightmare mode */
3118 if (ironman_nightmare)
3120 u32b hp = m_ptr->max_maxhp * 2L;
3122 m_ptr->max_maxhp = (s16b)MIN(30000, hp);
3125 m_ptr->maxhp = m_ptr->max_maxhp;
3127 /* And start out fully healthy */
3128 if (m_ptr->r_idx == MON_WOUNDED_BEAR)
3129 m_ptr->hp = m_ptr->maxhp / 2;
3130 else m_ptr->hp = m_ptr->maxhp;
3133 /* dealt damage is 0 at initial*/
3134 m_ptr->dealt_damage = 0;
3137 /* Extract the monster base speed */
3138 m_ptr->mspeed = get_mspeed(r_ptr);
3140 if (mode & PM_HASTE) (void)set_monster_fast(c_ptr->m_idx, 100);
3142 /* Give a random starting energy */
3143 if (!ironman_nightmare)
3145 m_ptr->energy_need = ENERGY_NEED() - (s16b)randint0(100);
3149 /* Nightmare monsters are more prepared */
3150 m_ptr->energy_need = ENERGY_NEED() - (s16b)randint0(100) * 2;
3153 /* Force monster to wait for player, unless in Nightmare mode */
3154 if ((r_ptr->flags1 & RF1_FORCE_SLEEP) && !ironman_nightmare)
3156 /* Monster is still being nice */
3157 m_ptr->mflag |= (MFLAG_NICE);
3159 /* Must repair monsters */
3160 repair_monsters = TRUE;
3163 /* Hack -- see "process_monsters()" */
3164 if (c_ptr->m_idx < hack_m_idx)
3166 /* Monster is still being born */
3167 m_ptr->mflag |= (MFLAG_BORN);
3171 if (r_ptr->flags7 & RF7_SELF_LD_MASK)
3172 p_ptr->update |= (PU_MON_LITE);
3173 else if ((r_ptr->flags7 & RF7_HAS_LD_MASK) && !MON_CSLEEP(m_ptr))
3174 p_ptr->update |= (PU_MON_LITE);
3176 /* Update the monster */
3177 update_mon(c_ptr->m_idx, TRUE);
3180 /* Count the monsters on the level */
3181 real_r_ptr(m_ptr)->cur_num++;
3184 * Memorize location of the unique monster in saved floors.
3185 * A unique monster move from old saved floor.
3187 if (character_dungeon &&
3188 ((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags7 & RF7_NAZGUL)))
3189 real_r_ptr(m_ptr)->floor_id = p_ptr->floor_id;
3191 /* Hack -- Count the number of "reproducers" */
3192 if (r_ptr->flags2 & RF2_MULTIPLY) num_repro++;
3194 /* Hack -- Notice new multi-hued monsters */
3196 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
3197 if (ap_r_ptr->flags1 & (RF1_ATTR_MULTI | RF1_SHAPECHANGER))
3198 shimmer_monsters = TRUE;
3201 if (p_ptr->warning && character_dungeon)
3203 if (r_ptr->flags1 & RF1_UNIQUE)
3207 char o_name[MAX_NLEN];
3209 if (r_ptr->level > p_ptr->lev + 30)
3210 color = _("黒く", "black");
3211 else if (r_ptr->level > p_ptr->lev + 15)
3212 color = _("紫色に", "purple");
3213 else if (r_ptr->level > p_ptr->lev + 5)
3214 color = _("ルビー色に", "deep red");
3215 else if (r_ptr->level > p_ptr->lev - 5)
3216 color = _("赤く", "red");
3217 else if (r_ptr->level > p_ptr->lev - 15)
3218 color = _("ピンク色に", "pink");
3220 color = _("白く", "white");
3222 o_ptr = choose_warning_item();
3225 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
3226 msg_format(_("%sは%s光った。", "%s glows %s."), o_name, color);
3230 msg_format(_("%s光る物が頭に浮かんだ。", "An %s image forms in your mind."), color);
3235 if (is_explosive_rune_grid(c_ptr))
3237 /* Break the ward */
3238 if (randint1(BREAK_MINOR_GLYPH) > r_ptr->level)
3240 /* Describe observable breakage */
3241 if (c_ptr->info & CAVE_MARK)
3243 msg_print(_("ルーンが爆発した!", "The rune explodes!"));
3244 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);
3249 msg_print(_("爆発のルーンは解除された。", "An explosive rune was disarmed."));
3252 /* Forget the rune */
3253 c_ptr->info &= ~(CAVE_MARK);
3255 /* Break the rune */
3256 c_ptr->info &= ~(CAVE_OBJECT);
3269 * improved version of scatter() for place monster
3272 #define MON_SCAT_MAXD 10
3274 static bool mon_scatter(int r_idx, int *yp, int *xp, int y, int x, int max_dist)
3276 int place_x[MON_SCAT_MAXD];
3277 int place_y[MON_SCAT_MAXD];
3278 int num[MON_SCAT_MAXD];
3282 if (max_dist >= MON_SCAT_MAXD)
3285 for (i = 0; i < MON_SCAT_MAXD; i++)
3288 for (nx = x - max_dist; nx <= x + max_dist; nx++)
3290 for (ny = y - max_dist; ny <= y + max_dist; ny++)
3292 /* Ignore annoying locations */
3293 if (!in_bounds(ny, nx)) continue;
3295 /* Require "line of projection" */
3296 if (!projectable(y, x, ny, nx)) continue;
3300 monster_race *r_ptr = &r_info[r_idx];
3302 /* Require empty space (if not ghostly) */
3303 if (!monster_can_enter(ny, nx, r_ptr, 0))
3308 /* Walls and Monsters block flow */
3309 if (!cave_empty_bold2(ny, nx)) continue;
3311 /* ... nor on the Pattern */
3312 if (pattern_tile(ny, nx)) continue;
3315 i = distance(y, x, ny, nx);
3323 if (one_in_(num[i]))
3332 while (i < MON_SCAT_MAXD && 0 == num[i])
3334 if (i >= MON_SCAT_MAXD)
3345 * Maximum size of a group of monsters
3347 #define GROUP_MAX 32
3351 * Attempt to place a "group" of monsters around the given location
3353 static bool place_monster_group(int who, int y, int x, int r_idx, u32b mode)
3355 monster_race *r_ptr = &r_info[r_idx];
3358 int total = 0, extra = 0;
3362 byte hack_y[GROUP_MAX];
3363 byte hack_x[GROUP_MAX];
3366 /* Pick a group size */
3367 total = randint1(10);
3369 /* Hard monsters, small groups */
3370 if (r_ptr->level > dun_level)
3372 extra = r_ptr->level - dun_level;
3373 extra = 0 - randint1(extra);
3376 /* Easy monsters, large groups */
3377 else if (r_ptr->level < dun_level)
3379 extra = dun_level - r_ptr->level;
3380 extra = randint1(extra);
3383 /* Hack -- limit group reduction */
3384 if (extra > 9) extra = 9;
3386 /* Modify the group size */
3390 if (total < 1) total = 1;
3393 if (total > GROUP_MAX) total = GROUP_MAX;
3396 /* Start on the monster */
3401 /* Puddle monsters, breadth first, up to total */
3402 for (n = 0; (n < hack_n) && (hack_n < total); n++)
3404 /* Grab the location */
3408 /* Check each direction, up to total */
3409 for (i = 0; (i < 8) && (hack_n < total); i++)
3413 scatter(&my, &mx, hy, hx, 4, 0);
3415 /* Walls and Monsters block flow */
3416 if (!cave_empty_bold2(my, mx)) continue;
3418 /* Attempt to place another monster */
3419 if (place_monster_one(who, my, mx, r_idx, mode))
3421 /* Add it to the "hack" set */
3422 hack_y[hack_n] = my;
3423 hack_x[hack_n] = mx;
3436 * Hack -- help pick an escort type
3438 static int place_monster_idx = 0;
3439 static int place_monster_m_idx = 0;
3442 * Hack -- help pick an escort type
3444 static bool place_monster_okay(int r_idx)
3446 monster_race *r_ptr = &r_info[place_monster_idx];
3447 monster_type *m_ptr = &m_list[place_monster_m_idx];
3449 monster_race *z_ptr = &r_info[r_idx];
3451 /* Hack - Escorts have to have the same dungeon flag */
3452 if (mon_hook_dungeon(place_monster_idx) != mon_hook_dungeon(r_idx)) return (FALSE);
3454 /* Require similar "race" */
3455 if (z_ptr->d_char != r_ptr->d_char) return (FALSE);
3457 /* Skip more advanced monsters */
3458 if (z_ptr->level > r_ptr->level) return (FALSE);
3460 /* Skip unique monsters */
3461 if (z_ptr->flags1 & RF1_UNIQUE) return (FALSE);
3463 /* Paranoia -- Skip identical monsters */
3464 if (place_monster_idx == r_idx) return (FALSE);
3466 /* Skip different alignment */
3467 if (monster_has_hostile_align(m_ptr, 0, 0, z_ptr)) return FALSE;
3469 if (r_ptr->flags7 & RF7_FRIENDLY)
3471 if (monster_has_hostile_align(NULL, 1, -1, z_ptr)) return FALSE;
3474 if ((r_ptr->flags7 & RF7_CHAMELEON) && !(z_ptr->flags7 & RF7_CHAMELEON))
3483 * Attempt to place a monster of the given race at the given location
3485 * Note that certain monsters are now marked as requiring "friends".
3486 * These monsters, if successfully placed, and if the "grp" parameter
3487 * is TRUE, will be surrounded by a "group" of identical monsters.
3489 * Note that certain monsters are now marked as requiring an "escort",
3490 * which is a collection of monsters with similar "race" but lower level.
3492 * Some monsters induce a fake "group" flag on their escorts.
3494 * Note the "bizarre" use of non-recursion to prevent annoying output
3495 * when running a code profiler.
3497 * Note the use of the new "monster allocation table" code to restrict
3498 * the "get_mon_num()" function to "legal" escort types.
3500 bool place_monster_aux(int who, int y, int x, int r_idx, u32b mode)
3503 monster_race *r_ptr = &r_info[r_idx];
3505 if (!(mode & PM_NO_KAGE) && one_in_(333))
3508 /* Place one monster, or fail */
3509 if (!place_monster_one(who, y, x, r_idx, mode)) return (FALSE);
3511 /* Require the "group" flag */
3512 if (!(mode & PM_ALLOW_GROUP)) return (TRUE);
3514 place_monster_m_idx = hack_m_idx_ii;
3517 for(i = 0; i < 6; i++)
3519 if(!r_ptr->reinforce_id[i]) break;
3520 n = damroll(r_ptr->reinforce_dd[i], r_ptr->reinforce_ds[i]);
3521 for(j = 0; j < n; j++)
3524 scatter(&ny, &nx, y, x, d, 0);
3525 (void)place_monster_one(place_monster_m_idx, ny, nx, r_ptr->reinforce_id[i], mode);
3529 /* Friends for certain monsters */
3530 if (r_ptr->flags1 & (RF1_FRIENDS))
3532 /* Attempt to place a group */
3533 (void)place_monster_group(who, y, x, r_idx, mode);
3536 /* Escorts for certain monsters */
3537 if (r_ptr->flags1 & (RF1_ESCORT))
3539 /* Set the escort index */
3540 place_monster_idx = r_idx;
3542 /* Try to place several "escorts" */
3543 for (i = 0; i < 32; i++)
3545 int nx, ny, z, d = 3;
3547 /* Pick a location */
3548 scatter(&ny, &nx, y, x, d, 0);
3550 /* Require empty grids */
3551 if (!cave_empty_bold2(ny, nx)) continue;
3553 /* Prepare allocation table */
3554 get_mon_num_prep(place_monster_okay, get_monster_hook2(ny, nx));
3556 /* Pick a random race */
3557 z = get_mon_num(r_ptr->level);
3559 /* Handle failure */
3562 /* Place a single escort */
3563 (void)place_monster_one(place_monster_m_idx, ny, nx, z, mode);
3565 /* Place a "group" of escorts if needed */
3566 if ((r_info[z].flags1 & RF1_FRIENDS) ||
3567 (r_ptr->flags1 & RF1_ESCORTS))
3569 /* Place a group of monsters */
3570 (void)place_monster_group(place_monster_m_idx, ny, nx, z, mode);
3581 * Hack -- attempt to place a monster at the given location
3583 * Attempt to find a monster appropriate to the "monster_level"
3585 bool place_monster(int y, int x, u32b mode)
3589 /* Prepare allocation table */
3590 get_mon_num_prep(get_monster_hook(), get_monster_hook2(y, x));
3592 /* Pick a monster */
3593 r_idx = get_mon_num(monster_level);
3595 /* Handle failure */
3596 if (!r_idx) return (FALSE);
3598 /* Attempt to place the monster */
3599 if (place_monster_aux(0, y, x, r_idx, mode)) return (TRUE);
3606 #ifdef MONSTER_HORDES
3608 bool alloc_horde(int y, int x)
3610 monster_race *r_ptr = NULL;
3613 int attempts = 1000;
3617 /* Prepare allocation table */
3618 get_mon_num_prep(get_monster_hook(), get_monster_hook2(y, x));
3622 /* Pick a monster */
3623 r_idx = get_mon_num(monster_level);
3625 /* Handle failure */
3626 if (!r_idx) return (FALSE);
3628 r_ptr = &r_info[r_idx];
3630 if (r_ptr->flags1 & RF1_UNIQUE) continue;
3632 if (r_idx == MON_HAGURE) continue;
3635 if (attempts < 1) return FALSE;
3641 /* Attempt to place the monster */
3642 if (place_monster_aux(0, y, x, r_idx, 0L)) break;
3645 if (attempts < 1) return FALSE;
3647 m_idx = cave[y][x].m_idx;
3649 if (m_list[m_idx].mflag2 & MFLAG2_CHAMELEON) r_ptr = &r_info[m_list[m_idx].r_idx];
3650 summon_kin_type = r_ptr->d_char;
3652 for (attempts = randint1(10) + 5; attempts; attempts--)
3654 scatter(&cy, &cx, y, x, 5, 0);
3656 (void)summon_specific(m_idx, cy, cx, dun_level + 5, SUMMON_KIN, PM_ALLOW_GROUP);
3665 #endif /* MONSTER_HORDES */
3671 bool alloc_guardian(bool def_val)
3673 int guardian = d_info[dungeon_type].final_guardian;
3675 if (guardian && (d_info[dungeon_type].maxdepth == dun_level) && (r_info[guardian].cur_num < r_info[guardian].max_num))
3679 int try_count = 4000;
3681 /* Find a good position */
3684 /* Get a random spot */
3685 oy = randint1(cur_hgt - 4) + 2;
3686 ox = randint1(cur_wid - 4) + 2;
3688 /* Is it a good spot ? */
3689 if (cave_empty_bold2(oy, ox) && monster_can_cross_terrain(cave[oy][ox].feat, &r_info[guardian], 0))
3691 /* Place the guardian */
3692 if (place_monster_aux(0, oy, ox, guardian, (PM_ALLOW_GROUP | PM_NO_KAGE | PM_NO_PET))) return TRUE;
3695 /* One less try count */
3707 * Attempt to allocate a random monster in the dungeon.
3709 * Place the monster at least "dis" distance from the player.
3711 * Use "slp" to choose the initial "sleep" status
3713 * Use "monster_level" for the monster level
3715 bool alloc_monster(int dis, u32b mode)
3718 int attempts_left = 10000;
3720 /* Put the Guardian */
3721 if (alloc_guardian(FALSE)) return TRUE;
3723 /* Find a legal, distant, unoccupied, space */
3724 while (attempts_left--)
3726 /* Pick a location */
3727 y = randint0(cur_hgt);
3728 x = randint0(cur_wid);
3730 /* Require empty floor grid (was "naked") */
3733 if (!cave_empty_bold2(y, x)) continue;
3737 if (!cave_empty_bold(y, x)) continue;
3740 /* Accept far away grids */
3741 if (distance(y, x, py, px) > dis) break;
3746 if (cheat_xtra || cheat_hear)
3748 msg_print(_("警告!新たなモンスターを配置できません。小さい階ですか?", "Warning! Could not allocate a new monster. Small level?"));
3755 #ifdef MONSTER_HORDES
3756 if (randint1(5000) <= dun_level)
3758 if (alloc_horde(y, x))
3760 if (cheat_hear) msg_format(_("モンスターの大群(%c)", "Monster horde (%c)."), summon_kin_type);
3766 #endif /* MONSTER_HORDES */
3768 /* Attempt to place the monster, allow groups */
3769 if (place_monster(y, x, (mode | PM_ALLOW_GROUP))) return (TRUE);
3771 #ifdef MONSTER_HORDES
3773 #endif /* MONSTER_HORDES */
3783 * Hack -- help decide if a monster race is "okay" to summon
3785 static bool summon_specific_okay(int r_idx)
3787 monster_race *r_ptr = &r_info[r_idx];
3789 /* Hack - Only summon dungeon monsters */
3790 if (!mon_hook_dungeon(r_idx)) return (FALSE);
3792 /* Hack -- identify the summoning monster */
3793 if (summon_specific_who > 0)
3795 monster_type *m_ptr = &m_list[summon_specific_who];
3797 /* Do not summon enemies */
3799 /* Friendly vs. opposite aligned normal or pet */
3800 if (monster_has_hostile_align(m_ptr, 0, 0, r_ptr)) return FALSE;
3802 /* Use the player's alignment */
3803 else if (summon_specific_who < 0)
3805 /* Do not summon enemies of the pets */
3806 if (monster_has_hostile_align(NULL, 10, -10, r_ptr))
3808 if (!one_in_(ABS(p_ptr->align) / 2 + 1)) return FALSE;
3812 /* Hack -- no specific type specified */
3813 if (!summon_specific_type) return (TRUE);
3815 if (!summon_unique_okay && ((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags7 & RF7_NAZGUL))) return FALSE;
3817 if ((summon_specific_who < 0) &&
3818 ((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags7 & RF7_NAZGUL)) &&
3819 monster_has_hostile_align(NULL, 10, -10, r_ptr))
3822 if ((r_ptr->flags7 & RF7_CHAMELEON) && (d_info[dungeon_type].flags1 & DF1_CHAMELEON)) return TRUE;
3824 return (summon_specific_aux(r_idx));
3829 * Place a monster (of the specified "type") near the given
3830 * location. Return TRUE if a monster was actually summoned.
3832 * We will attempt to place the monster up to 10 times before giving up.
3834 * Note: SUMMON_UNIQUE and SUMMON_AMBERITES will summon Unique's
3835 * Note: SUMMON_HI_UNDEAD and SUMMON_HI_DRAGON may summon Unique's
3836 * Note: None of the other summon codes will ever summon Unique's.
3838 * This function has been changed. We now take the "monster level"
3839 * of the summoning monster as a parameter, and use that, along with
3840 * the current dungeon level, to help determine the level of the
3841 * desired monster. Note that this is an upper bound, and also
3842 * tends to "prefer" monsters of that level. Currently, we use
3843 * the average of the dungeon and monster levels, and then add
3844 * five to allow slight increases in monster power.
3846 * Note that we use the new "monster allocation table" creation code
3847 * to restrict the "get_mon_num()" function to the set of "legal"
3848 * monsters, making this function much faster and more reliable.
3850 * Note that this function may not succeed, though this is very rare.
3852 bool summon_specific(int who, int y1, int x1, int lev, int type, u32b mode)
3856 if (p_ptr->inside_arena) return (FALSE);
3858 if (!mon_scatter(0, &y, &x, y1, x1, 2)) return FALSE;
3860 /* Save the summoner */
3861 summon_specific_who = who;
3863 /* Save the "summon" type */
3864 summon_specific_type = type;
3866 summon_unique_okay = (mode & PM_ALLOW_UNIQUE) ? TRUE : FALSE;
3868 /* Prepare allocation table */
3869 get_mon_num_prep(summon_specific_okay, get_monster_hook2(y, x));
3871 /* Pick a monster, using the level calculation */
3872 r_idx = get_mon_num((dun_level + lev) / 2 + 5);
3874 /* Handle failure */
3877 summon_specific_type = 0;
3881 if ((type == SUMMON_BLUE_HORROR) || (type == SUMMON_DAWN)) mode |= PM_NO_KAGE;
3883 /* Attempt to place the monster (awake, allow groups) */
3884 if (!place_monster_aux(who, y, x, r_idx, mode))
3886 summon_specific_type = 0;
3890 summon_specific_type = 0;
3895 /* A "dangerous" function, creates a pet of the specified type */
3896 bool summon_named_creature (int who, int oy, int ox, int r_idx, u32b mode)
3901 /* if (!r_idx) return; */
3903 /* Prevent illegal monsters */
3904 if (r_idx >= max_r_idx) return FALSE;
3906 if (p_ptr->inside_arena) return FALSE;
3908 if (!mon_scatter(r_idx, &y, &x, oy, ox, 2)) return FALSE;
3910 /* Place it (allow groups) */
3911 return place_monster_aux(who, y, x, r_idx, (mode | PM_NO_KAGE));
3916 * Let the given monster attempt to reproduce.
3918 * Note that "reproduction" REQUIRES empty space.
3920 bool multiply_monster(int m_idx, bool clone, u32b mode)
3922 monster_type *m_ptr = &m_list[m_idx];
3926 if (!mon_scatter(m_ptr->r_idx, &y, &x, m_ptr->fy, m_ptr->fx, 1))
3929 if (m_ptr->mflag2 & MFLAG2_NOPET) mode |= PM_NO_PET;
3931 /* Create a new monster (awake, no groups) */
3932 if (!place_monster_aux(m_idx, y, x, m_ptr->r_idx, (mode | PM_NO_KAGE | PM_MULTIPLY)))
3935 /* Hack -- Transfer "clone" flag */
3936 if (clone || (m_ptr->smart & SM_CLONED))
3938 m_list[hack_m_idx_ii].smart |= SM_CLONED;
3939 m_list[hack_m_idx_ii].mflag2 |= MFLAG2_NOPET;
3950 * Dump a message describing a monster's reaction to damage
3952 * Technically should attempt to treat "Beholder"'s as jelly's
3954 void message_pain(int m_idx, int dam)
3956 long oldhp, newhp, tmp;
3959 monster_type *m_ptr = &m_list[m_idx];
3960 monster_race *r_ptr = &r_info[m_ptr->r_idx];
3964 /* Get the monster name */
3965 monster_desc(m_name, m_ptr, 0);
3967 if(dam == 0) // Notice non-damage
3969 msg_format(_("%^sはダメージを受けていない。", "%^s is unharmed."), m_name);
3973 /* Note -- subtle fix -CFT */
3974 newhp = (long)(m_ptr->hp);
3975 oldhp = newhp + (long)(dam);
3976 tmp = (newhp * 100L) / oldhp;
3977 percentage = (int)(tmp);
3979 if(my_strchr(",ejmvwQ", r_ptr->d_char)) // Mushrooms, Eyes, Jellies, Molds, Vortices, Worms, Quylthulgs
3982 if(percentage > 95) msg_format("%^sはほとんど気にとめていない。", m_name);
3983 else if(percentage > 75) msg_format("%^sはしり込みした。", m_name);
3984 else if(percentage > 50) msg_format("%^sは縮こまった。", m_name);
3985 else if(percentage > 35) msg_format("%^sは痛みに震えた。", m_name);
3986 else if(percentage > 20) msg_format("%^sは身もだえした。", m_name);
3987 else if(percentage > 10) msg_format("%^sは苦痛で身もだえした。", m_name);
3988 else msg_format("%^sはぐにゃぐにゃと痙攣した。", m_name);
3990 if(percentage > 95) msg_format("%^s barely notices.", m_name);
3991 else if(percentage > 75) msg_format("%^s flinches.", m_name);
3992 else if(percentage > 50) msg_format("%^s squelches.", m_name);
3993 else if(percentage > 35) msg_format("%^s quivers in pain.", m_name);
3994 else if(percentage > 20) msg_format("%^s writhes about.", m_name);
3995 else if(percentage > 10) msg_format("%^s writhes in agony.", m_name);
3996 else msg_format("%^s jerks limply.", m_name);
4000 else if(my_strchr("l", r_ptr->d_char)) // Fish
4003 if(percentage > 95) msg_format("%^sはほとんど気にとめていない。", m_name);
4004 else if(percentage > 75) msg_format("%^sはしり込みした。", m_name);
4005 else if(percentage > 50) msg_format("%^sは躊躇した。", m_name);
4006 else if(percentage > 35) msg_format("%^sは痛みに震えた。", m_name);
4007 else if(percentage > 20) msg_format("%^sは身もだえした。", m_name);
4008 else if(percentage > 10) msg_format("%^sは苦痛で身もだえした。", m_name);
4009 else msg_format("%^sはぐにゃぐにゃと痙攣した。", m_name);
4011 if(percentage > 95) msg_format("%^s barely notices.", m_name);
4012 else if(percentage > 75) msg_format("%^s flinches.", m_name);
4013 else if(percentage > 50) msg_format("%^s hesitates.", m_name);
4014 else if(percentage > 35) msg_format("%^s quivers in pain.", m_name);
4015 else if(percentage > 20) msg_format("%^s writhes about.", m_name);
4016 else if(percentage > 10) msg_format("%^s writhes in agony.", m_name);
4017 else msg_format("%^s jerks limply.", m_name);
4021 else if(my_strchr("g#+<>", r_ptr->d_char)) // Golems, Walls, Doors, Stairs
4024 if(percentage > 95) msg_format("%sは攻撃を気にとめていない。", m_name);
4025 else if(percentage > 75) msg_format("%sは攻撃に肩をすくめた。", m_name);
4026 else if(percentage > 50) msg_format("%^sは雷鳴のように吠えた。", m_name);
4027 else if(percentage > 35) msg_format("%^sは苦しげに吠えた。", m_name);
4028 else if(percentage > 20) msg_format("%^sはうめいた。", m_name);
4029 else if(percentage > 10) msg_format("%^sは躊躇した。", m_name);
4030 else msg_format("%^sはくしゃくしゃになった。", m_name);
4032 if(percentage > 95) msg_format("%^s ignores the attack.", m_name);
4033 else if(percentage > 75) msg_format("%^s shrugs off the attack.", m_name);
4034 else if(percentage > 50) msg_format("%^s roars thunderously.", m_name);
4035 else if(percentage > 35) msg_format("%^s rumbles.", m_name);
4036 else if(percentage > 20) msg_format("%^s grunts.", m_name);
4037 else if(percentage > 10) msg_format("%^s hesitates.", m_name);
4038 else msg_format("%^s crumples.", m_name);
4042 else if(my_strchr("JMR", r_ptr->d_char) || !isalpha(r_ptr->d_char)) // Snakes, Hydrae, Reptiles, Mimics
4045 if(percentage > 95) msg_format("%^sはほとんど気にとめていない。", m_name);
4046 else if(percentage > 75) msg_format("%^sはシーッと鳴いた。", m_name);
4047 else if(percentage > 50) msg_format("%^sは怒って頭を上げた。", m_name);
4048 else if(percentage > 35) msg_format("%^sは猛然と威嚇した。", m_name);
4049 else if(percentage > 20) msg_format("%^sは身もだえした。", m_name);
4050 else if(percentage > 10) msg_format("%^sは苦痛で身もだえした。", m_name);
4051 else msg_format("%^sはぐにゃぐにゃと痙攣した。", m_name);
4053 if(percentage > 95) msg_format("%^s barely notices.", m_name);
4054 else if(percentage > 75) msg_format("%^s hisses.", m_name);
4055 else if(percentage > 50) msg_format("%^s rears up in anger.", m_name);
4056 else if(percentage > 35) msg_format("%^s hisses furiously.", m_name);
4057 else if(percentage > 20) msg_format("%^s writhes about.", m_name);
4058 else if(percentage > 10) msg_format("%^s writhes in agony.", m_name);
4059 else msg_format("%^s jerks limply.", m_name);
4063 else if(my_strchr("f", r_ptr->d_char))
4066 if(percentage > 95) msg_format("%sは攻撃に肩をすくめた。", m_name);
4067 else if(percentage > 75) msg_format("%^sは吠えた。", m_name);
4068 else if(percentage > 50) msg_format("%^sは怒って吠えた。", m_name);
4069 else if(percentage > 35) msg_format("%^sは痛みでシーッと鳴いた。", m_name);
4070 else if(percentage > 20) msg_format("%^sは痛みで弱々しく鳴いた。", m_name);
4071 else if(percentage > 10) msg_format("%^sは苦痛にうめいた。", m_name);
4072 else msg_format("%sは哀れな鳴き声を出した。", m_name);
4074 if(percentage > 95) msg_format("%^s shrugs off the attack.", m_name);
4075 else if(percentage > 75) msg_format("%^s roars.", m_name);
4076 else if(percentage > 50) msg_format("%^s growls angrily.", m_name);
4077 else if(percentage > 35) msg_format("%^s hisses with pain.", m_name);
4078 else if(percentage > 20) msg_format("%^s mewls in pain.", m_name);
4079 else if(percentage > 10) msg_format("%^s hisses in agony.", m_name);
4080 else msg_format("%^s mewls pitifully.", m_name);
4084 else if(my_strchr("acFIKS", r_ptr->d_char)) // Ants, Centipedes, Flies, Insects, Beetles, Spiders
4087 if(percentage > 95) msg_format("%sは攻撃を気にとめていない。", m_name);
4088 else if(percentage > 75) msg_format("%^sはキーキー鳴いた。", m_name);
4089 else if(percentage > 50) msg_format("%^sはヨロヨロ逃げ回った。", m_name);
4090 else if(percentage > 35) msg_format("%^sはうるさく鳴いた。", m_name);
4091 else if(percentage > 20) msg_format("%^sは痛みに痙攣した。", m_name);
4092 else if(percentage > 10) msg_format("%^sは苦痛で痙攣した。", m_name);
4093 else msg_format("%^sはピクピクひきつった。", m_name);
4095 if(percentage > 95) msg_format("%^s ignores the attack.", m_name);
4096 else if(percentage > 75) msg_format("%^s chitters.", m_name);
4097 else if(percentage > 50) msg_format("%^s scuttles about.", m_name);
4098 else if(percentage > 35) msg_format("%^s twitters.", m_name);
4099 else if(percentage > 20) msg_format("%^s jerks in pain.", m_name);
4100 else if(percentage > 10) msg_format("%^s jerks in agony.", m_name);
4101 else msg_format("%^s twitches.", m_name);
4105 else if(my_strchr("B", r_ptr->d_char)) // Birds
4108 if(percentage > 95) msg_format("%^sはさえずった。", m_name);
4109 else if(percentage > 75) msg_format("%^sはピーピー鳴いた。", m_name);
4110 else if(percentage > 50) msg_format("%^sはギャーギャー鳴いた。", m_name);
4111 else if(percentage > 35) msg_format("%^sはギャーギャー鳴きわめいた。", m_name);
4112 else if(percentage > 20) msg_format("%^sは苦しんだ。", m_name);
4113 else if(percentage > 10) msg_format("%^sはのたうち回った。", m_name);
4114 else msg_format("%^sはキーキーと鳴き叫んだ。", m_name);
4116 if(percentage > 95) msg_format("%^s chirps.", m_name);
4117 else if(percentage > 75) msg_format("%^s twitters.", m_name);
4118 else if(percentage > 50) msg_format("%^s squawks.", m_name);
4119 else if(percentage > 35) msg_format("%^s chatters.", m_name);
4120 else if(percentage > 20) msg_format("%^s jeers.", m_name);
4121 else if(percentage > 10) msg_format("%^s flutters about.", m_name);
4122 else msg_format("%^s squeaks.", m_name);
4126 else if(my_strchr("duDLUW", r_ptr->d_char)) // Dragons, Demons, High Undead
4129 if(percentage > 95) msg_format("%sは攻撃を気にとめていない。", m_name);
4130 else if(percentage > 75) msg_format("%^sはしり込みした。", m_name);
4131 else if(percentage > 50) msg_format("%^sは痛みでシーッと鳴いた。", m_name);
4132 else if(percentage > 35) msg_format("%^sは痛みでうなった。", m_name);
4133 else if(percentage > 20) msg_format("%^sは痛みに吠えた。", m_name);
4134 else if(percentage > 10) msg_format("%^sは苦しげに叫んだ。", m_name);
4135 else msg_format("%^sは弱々しくうなった。", m_name);
4137 if(percentage > 95) msg_format("%^s ignores the attack.", m_name);
4138 else if(percentage > 75) msg_format("%^s flinches.", m_name);
4139 else if(percentage > 50) msg_format("%^s hisses in pain.", m_name);
4140 else if(percentage > 35) msg_format("%^s snarls with pain.", m_name);
4141 else if(percentage > 20) msg_format("%^s roars with pain.", m_name);
4142 else if(percentage > 10) msg_format("%^s gasps.", m_name);
4143 else msg_format("%^s snarls feebly.", m_name);
4147 else if(my_strchr("s", r_ptr->d_char)) // Skeletons
4150 if(percentage > 95) msg_format("%sは攻撃を気にとめていない。", m_name);
4151 else if(percentage > 75) msg_format("%sは攻撃に肩をすくめた。", m_name);
4152 else if(percentage > 50) msg_format("%^sはカタカタと笑った。", m_name);
4153 else if(percentage > 35) msg_format("%^sはよろめいた。", m_name);
4154 else if(percentage > 20) msg_format("%^sはカタカタ言った。", m_name);
4155 else if(percentage > 10) msg_format("%^sはよろめいた。", m_name);
4156 else msg_format("%^sはガタガタ言った。", m_name);
4158 if(percentage > 95) msg_format("%^s ignores the attack.", m_name);
4159 else if(percentage > 75) msg_format("%^s shrugs off the attack.", m_name);
4160 else if(percentage > 50) msg_format("%^s rattles.", m_name);
4161 else if(percentage > 35) msg_format("%^s stumbles.", m_name);
4162 else if(percentage > 20) msg_format("%^s rattles.", m_name);
4163 else if(percentage > 10) msg_format("%^s staggers.", m_name);
4164 else msg_format("%^s clatters.", m_name);
4168 else if(my_strchr("z", r_ptr->d_char)) // Zombies
4171 if(percentage > 95) msg_format("%sは攻撃を気にとめていない。", m_name);
4172 else if(percentage > 75) msg_format("%sは攻撃に肩をすくめた。", m_name);
4173 else if(percentage > 50) msg_format("%^sはうめいた。", m_name);
4174 else if(percentage > 35) msg_format("%sは苦しげにうめいた。", m_name);
4175 else if(percentage > 20) msg_format("%^sは躊躇した。", m_name);
4176 else if(percentage > 10) msg_format("%^sはうなった。", m_name);
4177 else msg_format("%^sはよろめいた。", m_name);
4179 if(percentage > 95) msg_format("%^s ignores the attack.", m_name);
4180 else if(percentage > 75) msg_format("%^s shrugs off the attack.", m_name);
4181 else if(percentage > 50) msg_format("%^s groans.", m_name);
4182 else if(percentage > 35) msg_format("%^s moans.", m_name);
4183 else if(percentage > 20) msg_format("%^s hesitates.", m_name);
4184 else if(percentage > 10) msg_format("%^s grunts.", m_name);
4185 else msg_format("%^s staggers.", m_name);
4189 else if(my_strchr("G", r_ptr->d_char)) // Ghosts
4192 if(percentage > 95) msg_format("%sは攻撃を気にとめていない。", m_name);
4193 else if(percentage > 75) msg_format("%sは攻撃に肩をすくめた。", m_name);
4194 else if(percentage > 50) msg_format("%sはうめいた。", m_name);
4195 else if(percentage > 35) msg_format("%^sは泣きわめいた。", m_name);
4196 else if(percentage > 20) msg_format("%^sは吠えた。", m_name);
4197 else if(percentage > 10) msg_format("%sは弱々しくうめいた。", m_name);
4198 else msg_format("%^sはかすかにうめいた。", m_name);
4200 if(percentage > 95) msg_format("%^s ignores the attack.", m_name);
4201 else if(percentage > 75) msg_format("%^s shrugs off the attack.", m_name);
4202 else if(percentage > 50) msg_format("%^s moans.", m_name);
4203 else if(percentage > 35) msg_format("%^s wails.", m_name);
4204 else if(percentage > 20) msg_format("%^s howls.", m_name);
4205 else if(percentage > 10) msg_format("%^s moans softly.", m_name);
4206 else msg_format("%^s sighs.", m_name);
4210 else if(my_strchr("CZ", r_ptr->d_char)) // Dogs and Hounds
4213 if(percentage > 95) msg_format("%^sは攻撃に肩をすくめた。", m_name);
4214 else if(percentage > 75) msg_format("%^sは痛みでうなった。", m_name);
4215 else if(percentage > 50) msg_format("%^sは痛みでキャンキャン吠えた。", m_name);
4216 else if(percentage > 35) msg_format("%^sは痛みで鳴きわめいた。", m_name);
4217 else if(percentage > 20) msg_format("%^sは苦痛のあまり鳴きわめいた。", m_name);
4218 else if(percentage > 10) msg_format("%^sは苦痛でもだえ苦しんだ。", m_name);
4219 else msg_format("%^sは弱々しく吠えた。", m_name);
4221 if(percentage > 95) msg_format("%^s shrugs off the attack.", m_name);
4222 else if(percentage > 75) msg_format("%^s snarls with pain.", m_name);
4223 else if(percentage > 50) msg_format("%^s yelps in pain.", m_name);
4224 else if(percentage > 35) msg_format("%^s howls in pain.", m_name);
4225 else if(percentage > 20) msg_format("%^s howls in agony.", m_name);
4226 else if(percentage > 10) msg_format("%^s writhes in agony.", m_name);
4227 else msg_format("%^s yelps feebly.", m_name);
4231 else if(my_strchr("Xbilqrt", r_ptr->d_char)) // One type of creatures (ignore,squeal,shriek)
4234 if(percentage > 95) msg_format("%^sは攻撃を気にとめていない。", m_name);
4235 else if(percentage > 75) msg_format("%^sは痛みでうなった。", m_name);
4236 else if(percentage > 50) msg_format("%^sは痛みで叫んだ。", m_name);
4237 else if(percentage > 35) msg_format("%^sは痛みで絶叫した。", m_name);
4238 else if(percentage > 20) msg_format("%^sは苦痛のあまり絶叫した。", m_name);
4239 else if(percentage > 10) msg_format("%^sは苦痛でもだえ苦しんだ。", m_name);
4240 else msg_format("%^sは弱々しく叫んだ。", m_name);
4242 if(percentage > 95) msg_format("%^s ignores the attack.", m_name);
4243 else if(percentage > 75) msg_format("%^s grunts with pain.", m_name);
4244 else if(percentage > 50) msg_format("%^s squeals in pain.", m_name);
4245 else if(percentage > 35) msg_format("%^s shrieks in pain.", m_name);
4246 else if(percentage > 20) msg_format("%^s shrieks in agony.", m_name);
4247 else if(percentage > 10) msg_format("%^s writhes in agony.", m_name);
4248 else msg_format("%^s cries out feebly.", m_name);
4252 else // Another type of creatures (shrug,cry,scream)
4255 if(percentage > 95) msg_format("%^sは攻撃に肩をすくめた。", m_name);
4256 else if(percentage > 75) msg_format("%^sは痛みでうなった。", m_name);
4257 else if(percentage > 50) msg_format("%^sは痛みで叫んだ。", m_name);
4258 else if(percentage > 35) msg_format("%^sは痛みで絶叫した。", m_name);
4259 else if(percentage > 20) msg_format("%^sは苦痛のあまり絶叫した。", m_name);
4260 else if(percentage > 10) msg_format("%^sは苦痛でもだえ苦しんだ。", m_name);
4261 else msg_format("%^sは弱々しく叫んだ。", m_name);
4263 if(percentage > 95) msg_format("%^s shrugs off the attack.", m_name);
4264 else if(percentage > 75) msg_format("%^s grunts with pain.", m_name);
4265 else if(percentage > 50) msg_format("%^s cries out in pain.", m_name);
4266 else if(percentage > 35) msg_format("%^s screams in pain.", m_name);
4267 else if(percentage > 20) msg_format("%^s screams in agony.", m_name);
4268 else if(percentage > 10) msg_format("%^s writhes in agony.", m_name);
4269 else msg_format("%^s cries out feebly.", m_name);
4278 * Learn about an "observed" resistance.
4280 void update_smart_learn(int m_idx, int what)
4282 monster_type *m_ptr = &m_list[m_idx];
4284 monster_race *r_ptr = &r_info[m_ptr->r_idx];
4287 /* Not allowed to learn */
4288 if (!smart_learn) return;
4290 /* Too stupid to learn anything */
4291 if (r_ptr->flags2 & (RF2_STUPID)) return;
4293 /* Not intelligent, only learn sometimes */
4294 if (!(r_ptr->flags2 & (RF2_SMART)) && (randint0(100) < 50)) return;
4299 /* Analyze the knowledge */
4303 if (p_ptr->resist_acid) m_ptr->smart |= (SM_RES_ACID);
4304 if (IS_OPPOSE_ACID()) m_ptr->smart |= (SM_OPP_ACID);
4305 if (p_ptr->immune_acid) m_ptr->smart |= (SM_IMM_ACID);
4309 if (p_ptr->resist_elec) m_ptr->smart |= (SM_RES_ELEC);
4310 if (IS_OPPOSE_ELEC()) m_ptr->smart |= (SM_OPP_ELEC);
4311 if (p_ptr->immune_elec) m_ptr->smart |= (SM_IMM_ELEC);
4315 if (p_ptr->resist_fire) m_ptr->smart |= (SM_RES_FIRE);
4316 if (IS_OPPOSE_FIRE()) m_ptr->smart |= (SM_OPP_FIRE);
4317 if (p_ptr->immune_fire) m_ptr->smart |= (SM_IMM_FIRE);
4321 if (p_ptr->resist_cold) m_ptr->smart |= (SM_RES_COLD);
4322 if (IS_OPPOSE_COLD()) m_ptr->smart |= (SM_OPP_COLD);
4323 if (p_ptr->immune_cold) m_ptr->smart |= (SM_IMM_COLD);
4327 if (p_ptr->resist_pois) m_ptr->smart |= (SM_RES_POIS);
4328 if (IS_OPPOSE_POIS()) m_ptr->smart |= (SM_OPP_POIS);
4333 if (p_ptr->resist_neth) m_ptr->smart |= (SM_RES_NETH);
4337 if (p_ptr->resist_lite) m_ptr->smart |= (SM_RES_LITE);
4341 if (p_ptr->resist_dark) m_ptr->smart |= (SM_RES_DARK);
4345 if (p_ptr->resist_fear) m_ptr->smart |= (SM_RES_FEAR);
4349 if (p_ptr->resist_conf) m_ptr->smart |= (SM_RES_CONF);
4353 if (p_ptr->resist_chaos) m_ptr->smart |= (SM_RES_CHAOS);
4357 if (p_ptr->resist_disen) m_ptr->smart |= (SM_RES_DISEN);
4361 if (p_ptr->resist_blind) m_ptr->smart |= (SM_RES_BLIND);
4365 if (p_ptr->resist_nexus) m_ptr->smart |= (SM_RES_NEXUS);
4369 if (p_ptr->resist_sound) m_ptr->smart |= (SM_RES_SOUND);
4373 if (p_ptr->resist_shard) m_ptr->smart |= (SM_RES_SHARD);
4377 if (p_ptr->free_act) m_ptr->smart |= (SM_IMM_FREE);
4381 if (!p_ptr->msp) m_ptr->smart |= (SM_IMM_MANA);
4385 if (p_ptr->reflect) m_ptr-> smart |= (SM_IMM_REFLECT);
4392 * Place the player in the dungeon XXX XXX
4394 bool player_place(int y, int x)
4396 /* Paranoia XXX XXX */
4397 if (cave[y][x].m_idx != 0) return FALSE;
4399 /* Save player location */
4409 * Drop all items carried by a monster
4411 void monster_drop_carried_objects(monster_type *m_ptr)
4413 s16b this_o_idx, next_o_idx = 0;
4419 /* Drop objects being carried */
4420 for (this_o_idx = m_ptr->hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
4422 /* Acquire object */
4423 o_ptr = &o_list[this_o_idx];
4425 /* Acquire next object */
4426 next_o_idx = o_ptr->next_o_idx;
4428 /* Get local object */
4431 /* Copy the object */
4432 object_copy(q_ptr, o_ptr);
4434 /* Forget monster */
4435 q_ptr->held_m_idx = 0;
4437 /* Delete the object */
4438 delete_object_idx(this_o_idx);
4441 (void)drop_near(q_ptr, -1, m_ptr->fy, m_ptr->fx);
4444 /* Forget objects */
4445 m_ptr->hold_o_idx = 0;