3 * @brief モンスター処理 / misc code for monsters
6 * Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke
7 * This software may be copied and distributed for educational, research,
8 * and not for profit purposes provided that this copyright and statement
9 * are included in all such copies. Other copyrights may also apply.
10 * 2014 Deskull rearranged comment for Doxygen.
15 #include "monsterrace-hook.h"
16 #include "monster-status.h"
17 #include "projection.h"
19 #include "spells-summon.h"
22 #include "player-move.h"
25 #include "player-status.h"
27 #define HORDE_NOGOOD 0x01 /*!< (未実装フラグ)HORDE生成でGOODなモンスターの生成を禁止する? */
28 #define HORDE_NOEVIL 0x02 /*!< (未実装フラグ)HORDE生成でEVILなモンスターの生成を禁止する? */
33 * @brief ELDRITCH HORROR効果時のモンスターの形容メッセージ(通常時)
35 concptr horror_desc[MAX_SAN_HORROR] =
91 * @brief ELDRITCH HORROR効果時のモンスターの形容メッセージ(幻覚状態時)
93 concptr funny_desc[MAX_SAN_FUNNY] =
154 * @var funny_comments
155 * @brief ELDRITCH HORROR効果時の幻覚時間延長を示す錯乱表現
157 concptr funny_comments[MAX_SAN_COMMENT] =
178 * @brief モンスターの目標地点をセットする / Set the target of counter attack
179 * @param m_ptr モンスターの参照ポインタ
184 void set_target(monster_type *m_ptr, POSITION y, POSITION x)
192 * @brief モンスターの目標地点をリセットする / Reset the target of counter attack
193 * @param m_ptr モンスターの参照ポインタ
196 void reset_target(monster_type *m_ptr)
198 set_target(m_ptr, 0, 0);
203 * @brief モンスターの真の種族を返す / Extract monster race pointer of a monster's true form
204 * @param m_ptr モンスターの参照ポインタ
205 * @return 本当のモンスター種族参照ポインタ
207 monster_race *real_r_ptr(monster_type *m_ptr)
209 return &r_info[real_r_idx(m_ptr)];
212 MONRACE_IDX real_r_idx(monster_type *m_ptr)
214 monster_race *r_ptr = &r_info[m_ptr->r_idx];
216 /* Extract real race */
217 if (m_ptr->mflag2 & MFLAG2_CHAMELEON)
219 if (r_ptr->flags1 & RF1_UNIQUE)
220 return MON_CHAMELEON_K;
222 return MON_CHAMELEON;
232 * @brief モンスター配列からモンスターを消去する / Delete a monster by index.
233 * @param i 消去するモンスターのID
236 * モンスターを削除するとそのモンスターが拾っていたアイテムも同時に削除される。 /
237 * When a monster is deleted, all of its objects are deleted.
239 void delete_monster_idx(MONSTER_IDX i)
242 monster_type *m_ptr = ¤t_floor_ptr->m_list[i];
243 monster_race *r_ptr = &r_info[m_ptr->r_idx];
244 OBJECT_IDX this_o_idx, next_o_idx = 0;
249 /* Hack -- Reduce the racial counter */
250 real_r_ptr(m_ptr)->cur_num--;
252 /* Hack -- count the number of "reproducers" */
253 if (r_ptr->flags2 & (RF2_MULTIPLY)) current_floor_ptr->num_repro--;
255 if (MON_CSLEEP(m_ptr)) (void)set_monster_csleep(i, 0);
256 if (MON_FAST(m_ptr)) (void)set_monster_fast(i, 0);
257 if (MON_SLOW(m_ptr)) (void)set_monster_slow(i, 0);
258 if (MON_STUNNED(m_ptr)) (void)set_monster_stunned(i, 0);
259 if (MON_CONFUSED(m_ptr)) (void)set_monster_confused(i, 0);
260 if (MON_MONFEAR(m_ptr)) (void)set_monster_monfear(i, 0);
261 if (MON_INVULNER(m_ptr)) (void)set_monster_invulner(i, 0, FALSE);
263 /* Hack -- remove target monster */
264 if (i == target_who) target_who = 0;
266 /* Hack -- remove tracked monster */
267 if (i == p_ptr->health_who) health_track(0);
269 if (pet_t_m_idx == i ) pet_t_m_idx = 0;
270 if (riding_t_m_idx == i) riding_t_m_idx = 0;
271 if (p_ptr->riding == i) p_ptr->riding = 0;
273 /* Monster is gone */
274 current_floor_ptr->grid_array[y][x].m_idx = 0;
276 for (this_o_idx = m_ptr->hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
279 o_ptr = ¤t_floor_ptr->o_list[this_o_idx];
280 next_o_idx = o_ptr->next_o_idx;
283 * o_ptr->held_m_idx is needed in delete_object_idx()
284 * to prevent calling lite_spot()
287 delete_object_idx(this_o_idx);
290 (void)WIPE(m_ptr, monster_type);
296 if (r_ptr->flags7 & (RF7_LITE_MASK | RF7_DARK_MASK))
298 p_ptr->update |= (PU_MON_LITE);
304 * @brief 指定位置に存在するモンスターを削除する / Delete the monster, if any, at a given location
309 void delete_monster(POSITION y, POSITION x)
312 if (!in_bounds(y, x)) return;
315 g_ptr = ¤t_floor_ptr->grid_array[y][x];
317 /* Delete the monster (if any) */
318 if (g_ptr->m_idx) delete_monster_idx(g_ptr->m_idx);
323 * @brief モンスター情報を配列内移動する / Move an object from index i1 to index i2 in the object list
328 static void compact_monsters_aux(IDX i1, IDX i2)
334 OBJECT_IDX this_o_idx, next_o_idx = 0;
337 if (i1 == i2) return;
340 m_ptr = ¤t_floor_ptr->m_list[i1];
346 g_ptr = ¤t_floor_ptr->grid_array[y][x];
348 /* Update the current_floor_ptr->grid_array */
351 /* Repair objects being carried by monster */
352 for (this_o_idx = m_ptr->hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
355 o_ptr = ¤t_floor_ptr->o_list[this_o_idx];
356 next_o_idx = o_ptr->next_o_idx;
358 /* Reset monster pointer */
359 o_ptr->held_m_idx = i2;
362 /* Hack -- Update the target */
363 if (target_who == i1) target_who = i2;
365 /* Hack -- Update the target */
366 if (pet_t_m_idx == i1) pet_t_m_idx = i2;
367 if (riding_t_m_idx == i1) riding_t_m_idx = i2;
369 /* Hack -- Update the riding */
370 if (p_ptr->riding == i1) p_ptr->riding = i2;
372 /* Hack -- Update the health bar */
373 if (p_ptr->health_who == i1) health_track(i2);
375 /* Hack -- Update parent index */
378 for (i = 1; i < m_max; i++)
380 monster_type *m2_ptr = ¤t_floor_ptr->m_list[i];
382 if (m2_ptr->parent_m_idx == i1)
383 m2_ptr->parent_m_idx = i2;
388 (void)COPY(¤t_floor_ptr->m_list[i2], ¤t_floor_ptr->m_list[i1], monster_type);
391 (void)WIPE(¤t_floor_ptr->m_list[i1], monster_type);
393 for (i = 0; i < MAX_MTIMED; i++)
395 int mproc_idx = get_mproc_idx(i1, i);
396 if (mproc_idx >= 0) current_floor_ptr->mproc_list[i][mproc_idx] = i2;
402 * @brief モンスター情報配列を圧縮する / Compact and Reorder the monster list
403 * @param size 圧縮後のモンスター件数目標
406 * This function can be very dangerous, use with caution!
408 * When actually "compacting" monsters, we base the saving throw
409 * on a combination of monster level, distance from player, and
410 * current "desperation".
412 * After "compacting" (if needed), we "reorder" the monsters into a more
413 * compact order, and we reset the allocation info, and the "live" array.
415 void compact_monsters(int size)
419 int cur_lev, cur_dis, chance;
421 /* Message (only if compacting) */
422 if (size) msg_print(_("モンスター情報を圧縮しています...", "Compacting monsters..."));
425 /* Compact at least 'size' objects */
426 for (num = 0, cnt = 1; num < size; cnt++)
428 /* Get more vicious each iteration */
431 /* Get closer each iteration */
432 cur_dis = 5 * (20 - cnt);
434 /* Check all the monsters */
435 for (i = 1; i < m_max; i++)
437 monster_type *m_ptr = ¤t_floor_ptr->m_list[i];
439 monster_race *r_ptr = &r_info[m_ptr->r_idx];
441 /* Paranoia -- skip "dead" monsters */
442 if (!monster_is_valid(m_ptr)) continue;
444 /* Hack -- High level monsters start out "immune" */
445 if (r_ptr->level > cur_lev) continue;
447 if (i == p_ptr->riding) continue;
449 /* Ignore nearby monsters */
450 if ((cur_dis > 0) && (m_ptr->cdis < cur_dis)) continue;
452 /* Saving throw chance */
455 /* Only compact "Quest" Monsters in emergencies */
456 if ((r_ptr->flags1 & (RF1_QUESTOR)) && (cnt < 1000)) chance = 100;
458 /* Try not to compact Unique Monsters */
459 if (r_ptr->flags1 & (RF1_UNIQUE)) chance = 100;
461 /* All monsters get a saving throw */
462 if (randint0(100) < chance) continue;
464 if (record_named_pet && is_pet(m_ptr) && m_ptr->nickname)
466 GAME_TEXT m_name[MAX_NLEN];
467 monster_desc(m_name, m_ptr, MD_INDEF_VISIBLE);
468 do_cmd_write_nikki(NIKKI_NAMED_PET, RECORD_NAMED_PET_COMPACT, m_name);
471 delete_monster_idx(i);
473 /* Count the monster */
479 /* Excise dead monsters (backwards!) */
480 for (i = m_max - 1; i >= 1; i--)
482 /* Get the i'th monster */
483 monster_type *m_ptr = ¤t_floor_ptr->m_list[i];
485 /* Skip real monsters */
486 if (m_ptr->r_idx) continue;
488 /* Move last monster into open hole */
489 compact_monsters_aux(m_max - 1, i);
491 /* Compress "m_max" */
498 * @brief プレイヤーのフロア離脱に伴う全モンスター配列の消去 / Delete/Remove all the monsters when the player leaves the level
501 * This is an efficient method of simulating multiple calls to the
502 * "delete_monster()" function, with no visual effects.
504 void wipe_m_list(void)
508 /* Hack -- if Banor or Lupart dies, stay another dead */
509 if (!r_info[MON_BANORLUPART].max_num)
511 if (r_info[MON_BANOR].max_num)
513 r_info[MON_BANOR].max_num = 0;
514 r_info[MON_BANOR].r_pkills++;
515 r_info[MON_BANOR].r_akills++;
516 if (r_info[MON_BANOR].r_tkills < MAX_SHORT) r_info[MON_BANOR].r_tkills++;
518 if (r_info[MON_LUPART].max_num)
520 r_info[MON_LUPART].max_num = 0;
521 r_info[MON_LUPART].r_pkills++;
522 r_info[MON_LUPART].r_akills++;
523 if (r_info[MON_LUPART].r_tkills < MAX_SHORT) r_info[MON_LUPART].r_tkills++;
527 /* Delete all the monsters */
528 for (i = m_max - 1; i >= 1; i--)
530 monster_type *m_ptr = ¤t_floor_ptr->m_list[i];
531 if (!monster_is_valid(m_ptr)) continue;
533 /* Monster is gone */
534 current_floor_ptr->grid_array[m_ptr->fy][m_ptr->fx].m_idx = 0;
536 (void)WIPE(m_ptr, monster_type);
541 * Wiping racial counters of all monsters and incrementing of racial
542 * counters of monsters in party_mon[] are required to prevent multiple
543 * generation of unique monster who is the minion of player.
546 /* Hack -- Wipe the racial counter of all monster races */
547 for (i = 1; i < max_r_idx; i++) r_info[i].cur_num = 0;
555 /* Reset "current_floor_ptr->mproc_max[]" */
556 for (i = 0; i < MAX_MTIMED; i++) current_floor_ptr->mproc_max[i] = 0;
558 /* Hack -- reset "reproducer" count */
559 current_floor_ptr->num_repro = 0;
561 /* Hack -- no more target */
566 /* Hack -- no more tracking */
572 * @brief モンスター配列の空きを探す / Acquires and returns the index of a "free" monster.
573 * @return 利用可能なモンスター配列の添字
575 * This routine should almost never fail, but it *can* happen.
577 MONSTER_IDX m_pop(void)
581 /* Normal allocation */
582 if (m_max < current_floor_ptr->max_m_idx)
584 /* Access the next hole */
587 /* Expand the array */
593 /* Return the index */
597 /* Recycle dead monsters */
598 for (i = 1; i < m_max; i++)
602 /* Acquire monster */
603 m_ptr = ¤t_floor_ptr->m_list[i];
605 /* Skip live monsters */
606 if (m_ptr->r_idx) continue;
611 /* Use this monster */
615 /* Warn the player (except during dungeon creation) */
616 if (character_dungeon) msg_print(_("モンスターが多すぎる!", "Too many monsters!"));
618 /* Try not to crash */
626 * @var summon_specific_type
627 * @brief 召喚条件を指定するグローバル変数 / Hack -- the "type" of the current "summon specific"
628 * @todo summon_specific_typeグローバル変数の除去と関数引数への代替を行う
630 static int summon_specific_type = 0;
634 * @var summon_specific_who
635 * @brief 召喚を行ったプレイヤーあるいはモンスターのIDを示すグローバル変数 / Hack -- the index of the summoning monster
636 * @todo summon_specific_who グローバル変数の除去と関数引数への代替を行う
638 static int summon_specific_who = -1;
641 * @var summon_unique_okay
642 * @brief 召喚対象にユニークを含めるかを示すグローバル変数 / summoning unique enable
643 * @todo summon_unique_okay グローバル変数の除去と関数引数への代替を行う
645 static bool summon_unique_okay = FALSE;
648 * @brief 指定されたモンスター種族がsummon_specific_typeで指定された召喚条件に合うかどうかを返す
649 * @return 召喚条件が一致するならtrue
652 static bool summon_specific_aux(MONRACE_IDX r_idx)
654 monster_race *r_ptr = &r_info[r_idx];
657 /* Check our requirements */
658 switch (summon_specific_type)
662 okay = (r_ptr->d_char == 'a');
668 okay = (r_ptr->d_char == 'S');
674 okay = ((r_ptr->d_char == 'C') || (r_ptr->d_char == 'Z'));
680 okay = (r_ptr->d_char == 'M');
686 okay = (r_ptr->d_char == 'A' && ((r_ptr->flags3 & RF3_EVIL) || (r_ptr->flags3 & RF3_GOOD)));
692 okay = (r_ptr->flags3 & RF3_DEMON);
698 okay = (r_ptr->flags3 & RF3_UNDEAD);
704 okay = (r_ptr->flags3 & RF3_DRAGON);
708 case SUMMON_HI_UNDEAD:
710 okay = ((r_ptr->d_char == 'L') ||
711 (r_ptr->d_char == 'V') ||
712 (r_ptr->d_char == 'W'));
716 case SUMMON_HI_DRAGON:
718 okay = (r_ptr->d_char == 'D');
722 case SUMMON_HI_DEMON:
724 okay = (((r_ptr->d_char == 'U') ||
725 (r_ptr->d_char == 'H') ||
726 (r_ptr->d_char == 'B')) &&
727 (r_ptr->flags3 & RF3_DEMON)) ? TRUE : FALSE;
731 case SUMMON_AMBERITES:
733 okay = (r_ptr->flags3 & (RF3_AMBERITE)) ? TRUE : FALSE;
739 okay = (r_ptr->flags1 & (RF1_UNIQUE)) ? TRUE : FALSE;
745 okay = (r_ptr->d_char == 'm');
750 okay = (r_ptr->d_char == 'b');
753 case SUMMON_QUYLTHULG:
755 okay = (r_ptr->d_char == 'Q');
759 case SUMMON_COIN_MIMIC:
761 okay = (r_ptr->d_char == '$');
767 okay = ((r_ptr->d_char == '!') ||
768 (r_ptr->d_char == '?') ||
769 (r_ptr->d_char == '=') ||
770 (r_ptr->d_char == '$') ||
771 (r_ptr->d_char == '|'));
777 okay = (r_ptr->d_char == 'g');
783 okay = ((r_ptr->d_char == 'U') &&
784 (r_ptr->flags4 & RF4_ROCKET));
790 okay = ((r_ptr->d_char == summon_kin_type) && (r_idx != MON_HAGURE));
796 okay = (r_idx == MON_DAWN);
802 okay = (r_ptr->flags3 & (RF3_ANIMAL));
806 case SUMMON_ANIMAL_RANGER:
808 okay = ((r_ptr->flags3 & (RF3_ANIMAL)) &&
809 (my_strchr("abcflqrwBCHIJKMRS", r_ptr->d_char)) &&
810 !(r_ptr->flags3 & (RF3_DRAGON)) &&
811 !(r_ptr->flags3 & (RF3_EVIL)) &&
812 !(r_ptr->flags3 & (RF3_UNDEAD)) &&
813 !(r_ptr->flags3 & (RF3_DEMON)) &&
814 !(r_ptr->flags2 & (RF2_MULTIPLY)) &&
815 !(r_ptr->flags4 || r_ptr->a_ability_flags1 || r_ptr->a_ability_flags2));
819 case SUMMON_HI_DRAGON_LIVING:
821 okay = ((r_ptr->d_char == 'D') && monster_living(r_idx));
827 okay = monster_living(r_idx);
833 okay = (r_idx == MON_PHANTOM_B || r_idx == MON_PHANTOM_W);
837 case SUMMON_BLUE_HORROR:
839 okay = (r_idx == MON_BLUE_HORROR);
843 case SUMMON_ELEMENTAL:
845 okay = (r_ptr->d_char == 'E');
851 okay = (r_ptr->d_char == 'v');
857 okay = (r_ptr->d_char == 'H');
863 okay = (r_ptr->d_char == 'B');
867 case SUMMON_KAMIKAZE:
870 for (i = 0; i < 4; i++)
871 if (r_ptr->blow[i].method == RBM_EXPLODE) okay = TRUE;
875 case SUMMON_KAMIKAZE_LIVING:
879 for (i = 0; i < 4; i++)
880 if (r_ptr->blow[i].method == RBM_EXPLODE) okay = TRUE;
881 okay = (okay && monster_living(r_idx));
887 okay = (r_idx == MON_MANES);
893 okay = (r_idx == MON_LOUSE);
897 case SUMMON_GUARDIANS:
899 okay = (r_ptr->flags7 & RF7_GUARDIAN);
905 okay = ((r_idx == MON_NOV_PALADIN) ||
906 (r_idx == MON_NOV_PALADIN_G) ||
907 (r_idx == MON_PALADIN) ||
908 (r_idx == MON_W_KNIGHT) ||
909 (r_idx == MON_ULTRA_PALADIN) ||
910 (r_idx == MON_KNI_TEMPLAR));
916 okay = (r_ptr->d_char == 'B' &&
917 (r_ptr->flags8 & RF8_WILD_MOUNTAIN) &&
918 (r_ptr->flags8 & RF8_WILD_ONLY));
922 case SUMMON_PIRANHAS:
924 okay = (r_idx == MON_PIRANHA);
928 case SUMMON_ARMAGE_GOOD:
930 okay = (r_ptr->d_char == 'A' && (r_ptr->flags3 & RF3_GOOD));
934 case SUMMON_ARMAGE_EVIL:
936 okay = ((r_ptr->flags3 & RF3_DEMON) ||
937 (r_ptr->d_char == 'A' && (r_ptr->flags3 & RF3_EVIL)));
941 /* Since okay is int, "return (okay);" is not correct. */
942 return (bool)(okay ? TRUE : FALSE);
946 * @var chameleon_change_m_idx
947 * @brief カメレオンの変身先モンスターIDを受け渡すためのグローバル変数
948 * @todo 変数渡しの問題などもあるができればchameleon_change_m_idxのグローバル変数を除去し、関数引き渡しに移行すること
950 static int chameleon_change_m_idx = 0;
954 * @brief 指定されたモンスター種族がダンジョンの制限にかかるかどうかをチェックする / Some dungeon types restrict the possible monsters.
955 * @param r_idx チェックするモンスター種族ID
956 * @return 召喚条件が一致するならtrue / Return TRUE is the monster is OK and FALSE otherwise
958 static bool restrict_monster_to_dungeon(MONRACE_IDX r_idx)
960 dungeon_type *d_ptr = &d_info[p_ptr->dungeon_idx];
961 monster_race *r_ptr = &r_info[r_idx];
964 if (d_ptr->flags1 & DF1_CHAMELEON)
966 if (chameleon_change_m_idx) return TRUE;
968 if (d_ptr->flags1 & DF1_NO_MAGIC)
970 if (r_idx != MON_CHAMELEON &&
972 !(r_ptr->flags4 & RF4_NOMAGIC_MASK) &&
973 !(r_ptr->a_ability_flags1 & RF5_NOMAGIC_MASK) &&
974 !(r_ptr->a_ability_flags2 & RF6_NOMAGIC_MASK))
977 if (d_ptr->flags1 & DF1_NO_MELEE)
979 if (r_idx == MON_CHAMELEON) return TRUE;
980 if (!(r_ptr->flags4 & (RF4_BOLT_MASK | RF4_BEAM_MASK | RF4_BALL_MASK)) &&
981 !(r_ptr->a_ability_flags1 & (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)) &&
982 !(r_ptr->a_ability_flags2 & (RF6_BOLT_MASK | RF6_BEAM_MASK | RF6_BALL_MASK)))
985 if (d_ptr->flags1 & DF1_BEGINNER)
987 if (r_ptr->level > current_floor_ptr->dun_level)
991 if (d_ptr->special_div >= 64) return TRUE;
992 if (summon_specific_type && !(d_ptr->flags1 & DF1_CHAMELEON)) return TRUE;
996 case DUNGEON_MODE_AND:
999 if ((d_ptr->mflags1 & r_ptr->flags1) != d_ptr->mflags1)
1004 if ((d_ptr->mflags2 & r_ptr->flags2) != d_ptr->mflags2)
1009 if ((d_ptr->mflags3 & r_ptr->flags3) != d_ptr->mflags3)
1014 if ((d_ptr->mflags4 & r_ptr->flags4) != d_ptr->mflags4)
1017 if (d_ptr->m_a_ability_flags1)
1019 if ((d_ptr->m_a_ability_flags1 & r_ptr->a_ability_flags1) != d_ptr->m_a_ability_flags1)
1022 if (d_ptr->m_a_ability_flags2)
1024 if ((d_ptr->m_a_ability_flags2 & r_ptr->a_ability_flags2) != d_ptr->m_a_ability_flags2)
1029 if ((d_ptr->mflags7 & r_ptr->flags7) != d_ptr->mflags7)
1034 if ((d_ptr->mflags8 & r_ptr->flags8) != d_ptr->mflags8)
1039 if ((d_ptr->mflags9 & r_ptr->flags9) != d_ptr->mflags9)
1044 if ((d_ptr->mflagsr & r_ptr->flagsr) != d_ptr->mflagsr)
1047 for (a = 0; a < 5; a++)
1048 if (d_ptr->r_char[a] && (d_ptr->r_char[a] != r_ptr->d_char)) return FALSE;
1052 case DUNGEON_MODE_NAND:
1055 if ((d_ptr->mflags1 & r_ptr->flags1) != d_ptr->mflags1)
1060 if ((d_ptr->mflags2 & r_ptr->flags2) != d_ptr->mflags2)
1065 if ((d_ptr->mflags3 & r_ptr->flags3) != d_ptr->mflags3)
1070 if ((d_ptr->mflags4 & r_ptr->flags4) != d_ptr->mflags4)
1073 if (d_ptr->m_a_ability_flags1)
1075 if ((d_ptr->m_a_ability_flags1 & r_ptr->a_ability_flags1) != d_ptr->m_a_ability_flags1)
1078 if (d_ptr->m_a_ability_flags2)
1080 if ((d_ptr->m_a_ability_flags2 & r_ptr->a_ability_flags2) != d_ptr->m_a_ability_flags2)
1085 if ((d_ptr->mflags7 & r_ptr->flags7) != d_ptr->mflags7)
1090 if ((d_ptr->mflags8 & r_ptr->flags8) != d_ptr->mflags8)
1095 if ((d_ptr->mflags9 & r_ptr->flags9) != d_ptr->mflags9)
1100 if ((d_ptr->mflagsr & r_ptr->flagsr) != d_ptr->mflagsr)
1103 for (a = 0; a < 5; a++)
1104 if (d_ptr->r_char[a] && (d_ptr->r_char[a] != r_ptr->d_char)) return TRUE;
1108 case DUNGEON_MODE_OR:
1109 if (r_ptr->flags1 & d_ptr->mflags1) return TRUE;
1110 if (r_ptr->flags2 & d_ptr->mflags2) return TRUE;
1111 if (r_ptr->flags3 & d_ptr->mflags3) return TRUE;
1112 if (r_ptr->flags4 & d_ptr->mflags4) return TRUE;
1113 if (r_ptr->a_ability_flags1 & d_ptr->m_a_ability_flags1) return TRUE;
1114 if (r_ptr->a_ability_flags2 & d_ptr->m_a_ability_flags2) return TRUE;
1115 if (r_ptr->flags7 & d_ptr->mflags7) return TRUE;
1116 if (r_ptr->flags8 & d_ptr->mflags8) return TRUE;
1117 if (r_ptr->flags9 & d_ptr->mflags9) return TRUE;
1118 if (r_ptr->flagsr & d_ptr->mflagsr) return TRUE;
1119 for (a = 0; a < 5; a++)
1120 if (d_ptr->r_char[a] == r_ptr->d_char) return TRUE;
1124 case DUNGEON_MODE_NOR:
1125 if (r_ptr->flags1 & d_ptr->mflags1) return FALSE;
1126 if (r_ptr->flags2 & d_ptr->mflags2) return FALSE;
1127 if (r_ptr->flags3 & d_ptr->mflags3) return FALSE;
1128 if (r_ptr->flags4 & d_ptr->mflags4) return FALSE;
1129 if (r_ptr->a_ability_flags1 & d_ptr->m_a_ability_flags1) return FALSE;
1130 if (r_ptr->a_ability_flags2 & d_ptr->m_a_ability_flags2) return FALSE;
1131 if (r_ptr->flags7 & d_ptr->mflags7) return FALSE;
1132 if (r_ptr->flags8 & d_ptr->mflags8) return FALSE;
1133 if (r_ptr->flags9 & d_ptr->mflags9) return FALSE;
1134 if (r_ptr->flagsr & d_ptr->mflagsr) return FALSE;
1135 for (a = 0; a < 5; a++)
1136 if (d_ptr->r_char[a] == r_ptr->d_char) return FALSE;
1145 * @brief モンスター生成制限関数最大2つから / Apply a "monster restriction function" to the "monster allocation table"
1146 * @param monster_hook 制限関数1
1147 * @param monster_hook2 制限関数2
1150 errr get_mon_num_prep(monsterrace_hook_type monster_hook,
1151 monsterrace_hook_type monster_hook2)
1155 /* Todo: Check the hooks for non-changes */
1157 /* Set the new hooks */
1158 get_mon_num_hook = monster_hook;
1159 get_mon_num2_hook = monster_hook2;
1161 /* Scan the allocation table */
1162 for (i = 0; i < alloc_race_size; i++)
1164 monster_race *r_ptr;
1167 alloc_entry *entry = &alloc_race_table[i];
1170 r_ptr = &r_info[entry->index];
1172 /* Skip monsters which don't pass the restriction */
1173 if ((get_mon_num_hook && !((*get_mon_num_hook)(entry->index))) ||
1174 (get_mon_num2_hook && !((*get_mon_num2_hook)(entry->index))))
1177 if (!p_ptr->inside_battle && !chameleon_change_m_idx &&
1178 summon_specific_type != SUMMON_GUARDIANS)
1180 /* Hack -- don't create questors */
1181 if (r_ptr->flags1 & RF1_QUESTOR)
1184 if (r_ptr->flags7 & RF7_GUARDIAN)
1187 /* Depth Monsters never appear out of depth */
1188 if ((r_ptr->flags1 & (RF1_FORCE_DEPTH)) &&
1189 (r_ptr->level > current_floor_ptr->dun_level))
1193 /* Accept this monster */
1194 entry->prob2 = entry->prob1;
1196 if (current_floor_ptr->dun_level && (!p_ptr->inside_quest || is_fixed_quest_idx(p_ptr->inside_quest)) && !restrict_monster_to_dungeon(entry->index) && !p_ptr->inside_battle)
1198 int hoge = entry->prob2 * d_info[p_ptr->dungeon_idx].special_div;
1199 entry->prob2 = hoge / 64;
1200 if (randint0(64) < (hoge & 0x3f)) entry->prob2++;
1210 * @brief 生成モンスター種族を1種生成テーブルから選択する
1212 * @return 選択されたモンスター生成種族
1214 * Choose a monster race that seems "appropriate" to the given level
1216 * This function uses the "prob2" field of the "monster allocation table",
1217 * and various local information, to calculate the "prob3" field of the
1218 * same table, which is then used to choose an "appropriate" monster, in
1219 * a relatively efficient manner.
1221 * Note that "town" monsters will *only* be created in the town, and
1222 * "normal" monsters will *never* be created in the town, unless the
1223 * "level" is "modified", for example, by polymorph or summoning.
1225 * There is a small chance (1/50) of "boosting" the given depth by
1226 * a small amount (up to four levels), except in the town.
1228 * It is (slightly) more likely to acquire a monster of the given level
1229 * than one of a lower level. This is done by choosing several monsters
1230 * appropriate to the given level and keeping the "hardest" one.
1232 * Note that if no monsters are "appropriate", then this function will
1233 * fail, and return zero, but this should *almost* never happen.
1235 MONRACE_IDX get_mon_num(DEPTH level)
1240 monster_race *r_ptr;
1241 alloc_entry *table = alloc_race_table;
1243 int pls_kakuritu, pls_level;
1244 int delay = mysqrt(level * 10000L) + 400L;
1246 pls_kakuritu = MAX(NASTY_MON_MAX, NASTY_MON_BASE - ((current_world_ptr->dungeon_turn / (TURNS_PER_TICK * 5000L) - delay / 10)));
1247 pls_level = MIN(NASTY_MON_PLUS_MAX, 3 + current_world_ptr->dungeon_turn / (TURNS_PER_TICK * 40000L) - delay / 40 + MIN(5, level / 10)) ;
1249 if (d_info[p_ptr->dungeon_idx].flags1 & DF1_MAZE)
1251 pls_kakuritu = MIN(pls_kakuritu / 2, pls_kakuritu - 10);
1252 if (pls_kakuritu < 2) pls_kakuritu = 2;
1257 /* Boost the level */
1258 if (!p_ptr->inside_battle && !(d_info[p_ptr->dungeon_idx].flags1 & DF1_BEGINNER))
1260 /* Nightmare mode allows more out-of depth monsters */
1261 if (ironman_nightmare && !randint0(pls_kakuritu))
1263 /* What a bizarre calculation */
1264 level = 1 + (level * MAX_DEPTH / randint1(MAX_DEPTH));
1268 /* Occasional "nasty" monster */
1269 if (!randint0(pls_kakuritu))
1271 /* Pick a level bonus */
1277 if (level > MAX_DEPTH - 1) level = MAX_DEPTH - 1;
1278 if (level < 0) level = 0;
1283 /* Process probabilities */
1284 for (i = 0; i < alloc_race_size; i++)
1286 /* Monsters are sorted by depth */
1287 if (table[i].level > level) break;
1292 /* Access the "r_idx" of the chosen monster */
1293 r_idx = table[i].index;
1295 /* Access the actual race */
1296 r_ptr = &r_info[r_idx];
1298 if (!p_ptr->inside_battle && !chameleon_change_m_idx)
1300 /* Hack -- "unique" monsters must be "unique" */
1301 if (((r_ptr->flags1 & (RF1_UNIQUE)) ||
1302 (r_ptr->flags7 & (RF7_NAZGUL))) &&
1303 (r_ptr->cur_num >= r_ptr->max_num))
1308 if ((r_ptr->flags7 & (RF7_UNIQUE2)) &&
1309 (r_ptr->cur_num >= 1))
1314 if (r_idx == MON_BANORLUPART)
1316 if (r_info[MON_BANOR].cur_num > 0) continue;
1317 if (r_info[MON_LUPART].cur_num > 0) continue;
1322 table[i].prob3 = table[i].prob2;
1325 total += table[i].prob3;
1328 /* No legal monsters */
1329 if (total <= 0) return (0);
1331 /* Pick a monster */
1332 value = randint0(total);
1334 /* Find the monster */
1335 for (i = 0; i < alloc_race_size; i++)
1337 /* Found the entry */
1338 if (value < table[i].prob3) break;
1341 value = value - table[i].prob3;
1347 /* Try for a "harder" monster once (50%) or twice (10%) */
1353 /* Pick a monster */
1354 value = randint0(total);
1356 /* Find the monster */
1357 for (i = 0; i < alloc_race_size; i++)
1359 /* Found the entry */
1360 if (value < table[i].prob3) break;
1363 value = value - table[i].prob3;
1366 /* Keep the "best" one */
1367 if (table[i].level < table[j].level) i = j;
1370 /* Try for a "harder" monster twice (10%) */
1376 /* Pick a monster */
1377 value = randint0(total);
1379 /* Find the monster */
1380 for (i = 0; i < alloc_race_size; i++)
1382 /* Found the entry */
1383 if (value < table[i].prob3) break;
1386 value = value - table[i].prob3;
1389 /* Keep the "best" one */
1390 if (table[i].level < table[j].level) i = j;
1392 return (table[i].index);
1397 * @brief モンスターの呼称を作成する / Build a string describing a monster in some way.
1398 * @param desc 記述出力先の文字列参照ポインタ
1399 * @param m_ptr モンスターの参照ポインタ
1400 * @param mode 呼称オプション
1403 * We can correctly describe monsters based on their visibility.
1404 * We can force all monsters to be treated as visible or invisible.
1405 * We can build nominatives, objectives, possessives, or reflexives.
1406 * We can selectively pronominalize hidden, visible, or all monsters.
1407 * We can use definite or indefinite descriptions for hidden monsters.
1408 * We can use definite or indefinite descriptions for visible monsters.
1410 * Pronominalization involves the gender whenever possible and allowed,
1411 * so that by cleverly requesting pronominalization / visibility, you
1412 * can get messages like "You hit someone. She screams in agony!".
1414 * Reflexives are acquired by requesting Objective plus Possessive.
1416 * If no m_ptr arg is given (?), the monster is assumed to be hidden,
1417 * unless the "Assume Visible" mode is requested.
1419 * If no r_ptr arg is given, it is extracted from m_ptr and r_info
1420 * If neither m_ptr nor r_ptr is given, the monster is assumed to
1421 * be neuter, singular, and hidden (unless "Assume Visible" is set),
1422 * in which case you may be in trouble... :-)
1424 * I am assuming that no monster name is more than 70 characters long,
1425 * so that "char desc[80];" is sufficiently large for any result.
1428 * MD_OBJECTIVE --> Objective (or Reflexive)
1429 * MD_POSSESSIVE --> Possessive (or Reflexive)
1430 * MD_INDEF_HIDDEN --> Use indefinites for hidden monsters ("something")
1431 * MD_INDEF_VISIBLE --> Use indefinites for visible monsters ("a kobold")
1432 * MD_PRON_HIDDEN --> Pronominalize hidden monsters
1433 * MD_PRON_VISIBLE --> Pronominalize visible monsters
1434 * MD_ASSUME_HIDDEN --> Assume the monster is hidden
1435 * MD_ASSUME_VISIBLE --> Assume the monster is visible
1436 * MD_TRUE_NAME --> Chameleon's true name
1437 * MD_IGNORE_HALLU --> Ignore hallucination, and penetrate shape change
1440 * 0x00 --> Full nominative name ("the kobold") or "it"
1441 * MD_INDEF_HIDDEN --> Full nominative name ("the kobold") or "something"
1442 * MD_ASSUME_VISIBLE --> Genocide resistance name ("the kobold")
1443 * MD_ASSUME_VISIBLE | MD_INDEF_VISIBLE --> Killing name ("a kobold")
1444 * MD_PRON_VISIBLE | MD_POSSESSIVE
1445 * --> Possessive, genderized if visable ("his") or "its"
1446 * MD_PRON_VISIBLE | MD_POSSESSIVE | MD_OBJECTIVE
1447 * --> Reflexive, genderized if visable ("himself") or "itself"
1449 void monster_desc(char *desc, monster_type *m_ptr, BIT_FLAGS mode)
1452 monster_race *r_ptr;
1456 GAME_TEXT silly_name[1024];
1460 r_ptr = &r_info[m_ptr->ap_r_idx];
1462 /* Mode of MD_TRUE_NAME will reveal Chameleon's true name */
1463 if (mode & MD_TRUE_NAME) name = (r_name + real_r_ptr(m_ptr)->name);
1464 else name = (r_name + r_ptr->name);
1466 /* Are we hallucinating? (Idea from Nethack...) */
1467 if (p_ptr->image && !(mode & MD_IGNORE_HALLU))
1471 if (!get_rnd_line(_("silly_j.txt", "silly.txt"), m_ptr->r_idx, silly_name))
1477 monster_race *hallu_race;
1481 hallu_race = &r_info[randint1(max_r_idx - 1)];
1483 while (!hallu_race->name || (hallu_race->flags1 & RF1_UNIQUE));
1485 strcpy(silly_name, (r_name + hallu_race->name));
1488 /* Better not strcpy it, or we could corrupt r_info... */
1492 /* Can we "see" it (exists + forced, or visible + not unforced) */
1493 seen = (m_ptr && ((mode & MD_ASSUME_VISIBLE) || (!(mode & MD_ASSUME_HIDDEN) && m_ptr->ml)));
1495 /* Sexed Pronouns (seen and allowed, or unseen and allowed) */
1496 pron = (m_ptr && ((seen && (mode & MD_PRON_VISIBLE)) || (!seen && (mode & MD_PRON_HIDDEN))));
1499 /* First, try using pronouns, or describing hidden monsters */
1502 /* an encoding of the monster "sex" */
1505 /* Extract the gender (if applicable) */
1506 if (r_ptr->flags1 & (RF1_FEMALE)) kind = 0x20;
1507 else if (r_ptr->flags1 & (RF1_MALE)) kind = 0x10;
1509 /* Ignore the gender (if desired) */
1510 if (!m_ptr || !pron) kind = 0x00;
1513 /* Assume simple result */
1514 res = _("何か", "it");
1516 /* Brute force: split on the possibilities */
1517 switch (kind + (mode & (MD_INDEF_HIDDEN | MD_POSSESSIVE | MD_OBJECTIVE)))
1519 /* Neuter, or unknown */
1521 case 0x00: res = "何か"; break;
1522 case 0x00 + (MD_OBJECTIVE): res = "何か"; break;
1523 case 0x00 + (MD_POSSESSIVE): res = "何かの"; break;
1524 case 0x00 + (MD_POSSESSIVE | MD_OBJECTIVE): res = "何か自身"; break;
1525 case 0x00 + (MD_INDEF_HIDDEN): res = "何か"; break;
1526 case 0x00 + (MD_INDEF_HIDDEN | MD_OBJECTIVE): res = "何か"; break;
1527 case 0x00 + (MD_INDEF_HIDDEN | MD_POSSESSIVE): res = "何か"; break;
1528 case 0x00 + (MD_INDEF_HIDDEN | MD_POSSESSIVE | MD_OBJECTIVE): res = "それ自身"; break;
1530 case 0x00: res = "it"; break;
1531 case 0x00 + (MD_OBJECTIVE): res = "it"; break;
1532 case 0x00 + (MD_POSSESSIVE): res = "its"; break;
1533 case 0x00 + (MD_POSSESSIVE | MD_OBJECTIVE): res = "itself"; break;
1534 case 0x00 + (MD_INDEF_HIDDEN): res = "something"; break;
1535 case 0x00 + (MD_INDEF_HIDDEN | MD_OBJECTIVE): res = "something"; break;
1536 case 0x00 + (MD_INDEF_HIDDEN | MD_POSSESSIVE): res = "something's"; break;
1537 case 0x00 + (MD_INDEF_HIDDEN | MD_POSSESSIVE | MD_OBJECTIVE): res = "itself"; break;
1541 /* Male (assume human if vague) */
1543 case 0x10: res = "彼"; break;
1544 case 0x10 + (MD_OBJECTIVE): res = "彼"; break;
1545 case 0x10 + (MD_POSSESSIVE): res = "彼の"; break;
1546 case 0x10 + (MD_POSSESSIVE | MD_OBJECTIVE): res = "彼自身"; break;
1547 case 0x10 + (MD_INDEF_HIDDEN): res = "誰か"; break;
1548 case 0x10 + (MD_INDEF_HIDDEN | MD_OBJECTIVE): res = "誰か"; break;
1549 case 0x10 + (MD_INDEF_HIDDEN | MD_POSSESSIVE): res = "誰かの"; break;
1550 case 0x10 + (MD_INDEF_HIDDEN | MD_POSSESSIVE | MD_OBJECTIVE): res = "彼自身"; break;
1552 case 0x10: res = "he"; break;
1553 case 0x10 + (MD_OBJECTIVE): res = "him"; break;
1554 case 0x10 + (MD_POSSESSIVE): res = "his"; break;
1555 case 0x10 + (MD_POSSESSIVE | MD_OBJECTIVE): res = "himself"; break;
1556 case 0x10 + (MD_INDEF_HIDDEN): res = "someone"; break;
1557 case 0x10 + (MD_INDEF_HIDDEN | MD_OBJECTIVE): res = "someone"; break;
1558 case 0x10 + (MD_INDEF_HIDDEN | MD_POSSESSIVE): res = "someone's"; break;
1559 case 0x10 + (MD_INDEF_HIDDEN | MD_POSSESSIVE | MD_OBJECTIVE): res = "himself"; break;
1563 /* Female (assume human if vague) */
1565 case 0x20: res = "彼女"; break;
1566 case 0x20 + (MD_OBJECTIVE): res = "彼女"; break;
1567 case 0x20 + (MD_POSSESSIVE): res = "彼女の"; break;
1568 case 0x20 + (MD_POSSESSIVE | MD_OBJECTIVE): res = "彼女自身"; break;
1569 case 0x20 + (MD_INDEF_HIDDEN): res = "誰か"; break;
1570 case 0x20 + (MD_INDEF_HIDDEN | MD_OBJECTIVE): res = "誰か"; break;
1571 case 0x20 + (MD_INDEF_HIDDEN | MD_POSSESSIVE): res = "誰かの"; break;
1572 case 0x20 + (MD_INDEF_HIDDEN | MD_POSSESSIVE | MD_OBJECTIVE): res = "彼女自身"; break;
1574 case 0x20: res = "she"; break;
1575 case 0x20 + (MD_OBJECTIVE): res = "her"; break;
1576 case 0x20 + (MD_POSSESSIVE): res = "her"; break;
1577 case 0x20 + (MD_POSSESSIVE | MD_OBJECTIVE): res = "herself"; break;
1578 case 0x20 + (MD_INDEF_HIDDEN): res = "someone"; break;
1579 case 0x20 + (MD_INDEF_HIDDEN | MD_OBJECTIVE): res = "someone"; break;
1580 case 0x20 + (MD_INDEF_HIDDEN | MD_POSSESSIVE): res = "someone's"; break;
1581 case 0x20 + (MD_INDEF_HIDDEN | MD_POSSESSIVE | MD_OBJECTIVE): res = "herself"; break;
1585 /* Copy the result */
1586 (void)strcpy(desc, res);
1590 /* Handle visible monsters, "reflexive" request */
1591 else if ((mode & (MD_POSSESSIVE | MD_OBJECTIVE)) == (MD_POSSESSIVE | MD_OBJECTIVE))
1593 /* The monster is visible, so use its gender */
1594 if (r_ptr->flags1 & (RF1_FEMALE)) strcpy(desc, _("彼女自身", "herself"));
1595 else if (r_ptr->flags1 & (RF1_MALE)) strcpy(desc, _("彼自身", "himself"));
1596 else strcpy(desc, _("それ自身", "itself"));
1600 /* Handle all other visible monster requests */
1604 if (is_pet(m_ptr) && !is_original_ap(m_ptr))
1610 while(strncmp(t, "』", 2) && *t) t++;
1614 (void)sprintf(desc, "%s?』", buf);
1617 (void)sprintf(desc, "%s?", name);
1619 (void)sprintf(desc, "%s?", name);
1624 /* It could be a Unique */
1625 if ((r_ptr->flags1 & RF1_UNIQUE) && !(p_ptr->image && !(mode & MD_IGNORE_HALLU)))
1627 /* Start with the name (thus nominative and objective) */
1628 if ((m_ptr->mflag2 & MFLAG2_CHAMELEON) && !(mode & MD_TRUE_NAME))
1634 while (strncmp(t, "』", 2) && *t) t++;
1638 (void)sprintf(desc, "%s?』", buf);
1641 (void)sprintf(desc, "%s?", name);
1643 (void)sprintf(desc, "%s?", name);
1647 /* Inside monster arena, and it is not your mount */
1648 else if (p_ptr->inside_battle &&
1649 !(p_ptr->riding && (¤t_floor_ptr->m_list[p_ptr->riding] == m_ptr)))
1651 /* It is a fake unique monster */
1652 (void)sprintf(desc, _("%sもどき", "fake %s"), name);
1657 (void)strcpy(desc, name);
1661 /* It could be an indefinite monster */
1662 else if (mode & MD_INDEF_VISIBLE)
1664 /* XXX Check plurality for "some" */
1666 /* Indefinite monsters need an indefinite article */
1668 (void)strcpy(desc, "");
1670 (void)strcpy(desc, is_a_vowel(name[0]) ? "an " : "a ");
1673 (void)strcat(desc, name);
1676 /* It could be a normal, definite, monster */
1679 /* Definite monsters need a definite article */
1681 (void)strcpy(desc, _("あなたの", "your "));
1683 (void)strcpy(desc, _("", "the "));
1685 (void)strcat(desc, name);
1688 if (m_ptr->nickname)
1690 sprintf(buf,_("「%s」", " called %s"),quark_str(m_ptr->nickname));
1694 if (p_ptr->riding && (¤t_floor_ptr->m_list[p_ptr->riding] == m_ptr))
1696 strcat(desc,_("(乗馬中)", "(riding)"));
1699 if ((mode & MD_IGNORE_HALLU) && (m_ptr->mflag2 & MFLAG2_CHAMELEON))
1701 if (r_ptr->flags1 & RF1_UNIQUE)
1703 strcat(desc,_("(カメレオンの王)", "(Chameleon Lord)"));
1707 strcat(desc,_("(カメレオン)", "(Chameleon)"));
1711 if ((mode & MD_IGNORE_HALLU) && !is_original_ap(m_ptr))
1713 strcat(desc, format("(%s)", r_name + r_info[m_ptr->r_idx].name));
1716 /* Handle the Possessive as a special afterthought */
1717 if (mode & MD_POSSESSIVE)
1719 /* XXX Check for trailing "s" */
1721 /* Simply append "apostrophe" and "s" */
1722 (void)strcat(desc, _("の", "'s"));
1730 * @brief モンスターの調査による思い出補完処理 / Learn about a monster (by "probing" it)
1731 * @param r_idx 補完されるモンスター種族ID
1732 * @return 明らかになった情報の度数
1734 * Return the number of new flags learnt. -Mogami-
1736 int lore_do_probe(MONRACE_IDX r_idx)
1738 monster_race *r_ptr = &r_info[r_idx];
1742 /* Maximal info about awareness */
1743 if (r_ptr->r_wake != MAX_UCHAR) n++;
1744 if (r_ptr->r_ignore != MAX_UCHAR) n++;
1745 r_ptr->r_wake = r_ptr->r_ignore = MAX_UCHAR;
1747 /* Observe "maximal" attacks */
1748 for (i = 0; i < 4; i++)
1750 /* Examine "actual" blows */
1751 if (r_ptr->blow[i].effect || r_ptr->blow[i].method)
1753 /* Maximal observations */
1754 if (r_ptr->r_blows[i] != MAX_UCHAR) n++;
1755 r_ptr->r_blows[i] = MAX_UCHAR;
1761 (((r_ptr->flags1 & RF1_DROP_4D2) ? 8 : 0) +
1762 ((r_ptr->flags1 & RF1_DROP_3D2) ? 6 : 0) +
1763 ((r_ptr->flags1 & RF1_DROP_2D2) ? 4 : 0) +
1764 ((r_ptr->flags1 & RF1_DROP_1D2) ? 2 : 0) +
1765 ((r_ptr->flags1 & RF1_DROP_90) ? 1 : 0) +
1766 ((r_ptr->flags1 & RF1_DROP_60) ? 1 : 0));
1768 /* Only "valid" drops */
1769 if (!(r_ptr->flags1 & RF1_ONLY_GOLD))
1771 if (r_ptr->r_drop_item != tmp_byte) n++;
1772 r_ptr->r_drop_item = tmp_byte;
1774 if (!(r_ptr->flags1 & RF1_ONLY_ITEM))
1776 if (r_ptr->r_drop_gold != tmp_byte) n++;
1777 r_ptr->r_drop_gold = tmp_byte;
1780 /* Observe many spells */
1781 if (r_ptr->r_cast_spell != MAX_UCHAR) n++;
1782 r_ptr->r_cast_spell = MAX_UCHAR;
1784 /* Count unknown flags */
1785 for (i = 0; i < 32; i++)
1787 if (!(r_ptr->r_flags1 & (1L << i)) &&
1788 (r_ptr->flags1 & (1L << i))) n++;
1789 if (!(r_ptr->r_flags2 & (1L << i)) &&
1790 (r_ptr->flags2 & (1L << i))) n++;
1791 if (!(r_ptr->r_flags3 & (1L << i)) &&
1792 (r_ptr->flags3 & (1L << i))) n++;
1793 if (!(r_ptr->r_flags4 & (1L << i)) &&
1794 (r_ptr->flags4 & (1L << i))) n++;
1795 if (!(r_ptr->r_flags5 & (1L << i)) &&
1796 (r_ptr->a_ability_flags1 & (1L << i))) n++;
1797 if (!(r_ptr->r_flags6 & (1L << i)) &&
1798 (r_ptr->a_ability_flags2 & (1L << i))) n++;
1799 if (!(r_ptr->r_flagsr & (1L << i)) &&
1800 (r_ptr->flagsr & (1L << i))) n++;
1802 /* r_flags7 is actually unused */
1804 if (!(r_ptr->r_flags7 & (1L << i)) &&
1805 (r_ptr->flags7 & (1L << i))) n++;
1809 /* Know all the flags */
1810 r_ptr->r_flags1 = r_ptr->flags1;
1811 r_ptr->r_flags2 = r_ptr->flags2;
1812 r_ptr->r_flags3 = r_ptr->flags3;
1813 r_ptr->r_flags4 = r_ptr->flags4;
1814 r_ptr->r_flags5 = r_ptr->a_ability_flags1;
1815 r_ptr->r_flags6 = r_ptr->a_ability_flags2;
1816 r_ptr->r_flagsr = r_ptr->flagsr;
1818 /* r_flags7 is actually unused */
1819 /* r_ptr->r_flags7 = r_ptr->flags7; */
1821 /* Know about evolution */
1822 if (!(r_ptr->r_xtra1 & MR1_SINKA)) n++;
1823 r_ptr->r_xtra1 |= MR1_SINKA;
1825 /* Update monster recall window */
1826 if (p_ptr->monster_race_idx == r_idx)
1828 p_ptr->window |= (PW_MONSTER);
1831 /* Return the number of new flags learnt */
1837 * @brief モンスターの撃破に伴うドロップ情報の保管処理 / Take note that the given monster just dropped some treasure
1838 * @param m_idx モンスター情報のID
1839 * @param num_item 手に入れたアイテム数
1840 * @param num_gold 手に入れた財宝の単位数
1843 * Note that learning the "GOOD"/"GREAT" flags gives information
1844 * about the treasure (even when the monster is killed for the first
1845 * time, such as uniques, and the treasure has not been examined yet).
1847 * This "indirect" method is used to prevent the player from learning
1848 * exactly how much treasure a monster can drop from observing only
1849 * a single example of a drop. This method actually observes how much
1850 * gold and items are dropped, and remembers that information to be
1851 * described later by the monster recall code.
1853 void lore_treasure(MONSTER_IDX m_idx, ITEM_NUMBER num_item, ITEM_NUMBER num_gold)
1855 monster_type *m_ptr = ¤t_floor_ptr->m_list[m_idx];
1857 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1859 /* If the monster doesn't have original appearance, don't note */
1860 if (!is_original_ap(m_ptr)) return;
1862 /* Note the number of things dropped */
1863 if (num_item > r_ptr->r_drop_item) r_ptr->r_drop_item = num_item;
1864 if (num_gold > r_ptr->r_drop_gold) r_ptr->r_drop_gold = num_gold;
1866 /* Hack -- memorize the good/great flags */
1867 if (r_ptr->flags1 & (RF1_DROP_GOOD)) r_ptr->r_flags1 |= (RF1_DROP_GOOD);
1868 if (r_ptr->flags1 & (RF1_DROP_GREAT)) r_ptr->r_flags1 |= (RF1_DROP_GREAT);
1870 /* Update monster recall window */
1871 if (p_ptr->monster_race_idx == m_ptr->r_idx)
1873 p_ptr->window |= (PW_MONSTER);
1879 * @brief モンスターの各情報を更新する / This function updates the monster record of the given monster
1880 * @param m_idx 更新するモンスター情報のID
1881 * @param full プレイヤーとの距離更新を行うならばtrue
1884 * This involves extracting the distance to the player (if requested),
1885 * and then checking for visibility (natural, infravision, see-invis,
1886 * telepathy), updating the monster visibility flag, redrawing (or
1887 * erasing) the monster when its visibility changes, and taking note
1888 * of any interesting monster flags (cold-blooded, invisible, etc).
1890 * Note the new "mflag" field which encodes several monster state flags,
1891 * including "view" for when the monster is currently in line of sight,
1892 * and "mark" for when the monster is currently visible via detection.
1894 * The only monster fields that are changed here are "cdis" (the
1895 * distance from the player), "ml" (visible to the player), and
1896 * "mflag" (to maintain the "MFLAG_VIEW" flag).
1898 * Note the special "update_monsters()" function which can be used to
1899 * call this function once for every monster.
1901 * Note the "full" flag which requests that the "cdis" field be updated,
1902 * this is only needed when the monster (or the player) has moved.
1904 * Every time a monster moves, we must call this function for that
1905 * monster, and update the distance, and the visibility. Every time
1906 * the player moves, we must call this function for every monster, and
1907 * update the distance, and the visibility. Whenever the player "state"
1908 * changes in certain ways ("blindness", "infravision", "telepathy",
1909 * and "see invisible"), we must call this function for every monster,
1910 * and update the visibility.
1912 * Routines that change the "illumination" of a grid must also call this
1913 * function for any monster in that grid, since the "visibility" of some
1914 * monsters may be based on the illumination of their grid.
1916 * Note that this function is called once per monster every time the
1917 * player moves. When the player is running, this function is one
1918 * of the primary bottlenecks, along with "update_view()" and the
1919 * "process_monsters()" code, so efficiency is important.
1921 * Note the optimized "inline" version of the "distance()" function.
1923 * A monster is "visible" to the player if (1) it has been detected
1924 * by the player, (2) it is close to the player and the player has
1925 * telepathy, or (3) it is close to the player, and in line of sight
1926 * of the player, and it is "illuminated" by some combination of
1927 * infravision, torch light, or permanent light (invisible monsters
1928 * are only affected by "light" if the player can see invisible).
1930 * Monsters which are not on the current panel may be "visible" to
1931 * the player, and their descriptions will include an "offscreen"
1932 * reference. Currently, offscreen monsters cannot be targetted
1933 * or viewed directly, but old targets will remain set. XXX XXX
1935 * The player can choose to be disturbed by several things, including
1936 * "disturb_move" (monster which is viewable moves in some way), and
1937 * "disturb_near" (monster which is "easily" viewable moves in some
1938 * way). Note that "moves" includes "appears" and "disappears".
1940 void update_monster(MONSTER_IDX m_idx, bool full)
1942 monster_type *m_ptr = ¤t_floor_ptr->m_list[m_idx];
1943 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1945 bool do_disturb = disturb_move;
1949 /* Current location */
1950 POSITION fy = m_ptr->fy;
1951 POSITION fx = m_ptr->fx;
1956 /* Seen by vision */
1959 /* Non-Ninja player in the darkness */
1960 bool in_darkness = (d_info[p_ptr->dungeon_idx].flags1 & DF1_DARKNESS) && !p_ptr->see_nocto;
1965 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
1967 if (ap_r_ptr->r_tkills && ap_r_ptr->level >= p_ptr->lev)
1971 /* Compute distance */
1974 /* Distance components */
1975 int dy = (p_ptr->y > fy) ? (p_ptr->y - fy) : (fy - p_ptr->y);
1976 int dx = (p_ptr->x > fx) ? (p_ptr->x - fx) : (fx - p_ptr->x);
1978 /* Approximate distance */
1979 d = (dy > dx) ? (dy + (dx>>1)) : (dx + (dy>>1));
1981 /* Restrict distance */
1982 if (d > 255) d = 255;
1986 /* Save the distance */
1990 /* Extract distance */
1993 /* Extract the distance */
1999 if (m_ptr->mflag2 & (MFLAG2_MARK)) flag = TRUE;
2003 if (d <= (in_darkness ? MAX_SIGHT / 2 : MAX_SIGHT))
2005 if (!in_darkness || (d <= MAX_SIGHT / 4))
2007 if (p_ptr->special_defense & KATA_MUSOU)
2012 if (is_original_ap(m_ptr) && !p_ptr->image)
2014 /* Hack -- Memorize mental flags */
2015 if (r_ptr->flags2 & (RF2_SMART)) r_ptr->r_flags2 |= (RF2_SMART);
2016 if (r_ptr->flags2 & (RF2_STUPID)) r_ptr->r_flags2 |= (RF2_STUPID);
2020 /* Basic telepathy */
2021 /* Snipers get telepathy when they concentrate deeper */
2022 else if (p_ptr->telepathy)
2024 /* Empty mind, no telepathy */
2025 if (r_ptr->flags2 & (RF2_EMPTY_MIND))
2027 /* Memorize flags */
2028 if (is_original_ap(m_ptr) && !p_ptr->image) r_ptr->r_flags2 |= (RF2_EMPTY_MIND);
2031 /* Weird mind, occasional telepathy */
2032 else if (r_ptr->flags2 & (RF2_WEIRD_MIND))
2034 /* One in ten individuals are detectable */
2035 if ((m_idx % 10) == 5)
2040 if (is_original_ap(m_ptr) && !p_ptr->image)
2042 /* Memorize flags */
2043 r_ptr->r_flags2 |= (RF2_WEIRD_MIND);
2045 /* Hack -- Memorize mental flags */
2046 if (r_ptr->flags2 & (RF2_SMART)) r_ptr->r_flags2 |= (RF2_SMART);
2047 if (r_ptr->flags2 & (RF2_STUPID)) r_ptr->r_flags2 |= (RF2_STUPID);
2052 /* Normal mind, allow telepathy */
2058 if (is_original_ap(m_ptr) && !p_ptr->image)
2060 /* Hack -- Memorize mental flags */
2061 if (r_ptr->flags2 & (RF2_SMART)) r_ptr->r_flags2 |= (RF2_SMART);
2062 if (r_ptr->flags2 & (RF2_STUPID)) r_ptr->r_flags2 |= (RF2_STUPID);
2067 if ((p_ptr->esp_animal) && (r_ptr->flags3 & (RF3_ANIMAL)))
2070 if (is_original_ap(m_ptr) && !p_ptr->image) r_ptr->r_flags3 |= (RF3_ANIMAL);
2073 if ((p_ptr->esp_undead) && (r_ptr->flags3 & (RF3_UNDEAD)))
2076 if (is_original_ap(m_ptr) && !p_ptr->image) r_ptr->r_flags3 |= (RF3_UNDEAD);
2079 if ((p_ptr->esp_demon) && (r_ptr->flags3 & (RF3_DEMON)))
2082 if (is_original_ap(m_ptr) && !p_ptr->image) r_ptr->r_flags3 |= (RF3_DEMON);
2085 if ((p_ptr->esp_orc) && (r_ptr->flags3 & (RF3_ORC)))
2088 if (is_original_ap(m_ptr) && !p_ptr->image) r_ptr->r_flags3 |= (RF3_ORC);
2091 if ((p_ptr->esp_troll) && (r_ptr->flags3 & (RF3_TROLL)))
2094 if (is_original_ap(m_ptr) && !p_ptr->image) r_ptr->r_flags3 |= (RF3_TROLL);
2097 if ((p_ptr->esp_giant) && (r_ptr->flags3 & (RF3_GIANT)))
2100 if (is_original_ap(m_ptr) && !p_ptr->image) r_ptr->r_flags3 |= (RF3_GIANT);
2103 if ((p_ptr->esp_dragon) && (r_ptr->flags3 & (RF3_DRAGON)))
2106 if (is_original_ap(m_ptr) && !p_ptr->image) r_ptr->r_flags3 |= (RF3_DRAGON);
2109 if ((p_ptr->esp_human) && (r_ptr->flags2 & (RF2_HUMAN)))
2112 if (is_original_ap(m_ptr) && !p_ptr->image) r_ptr->r_flags2 |= (RF2_HUMAN);
2115 if ((p_ptr->esp_evil) && (r_ptr->flags3 & (RF3_EVIL)))
2118 if (is_original_ap(m_ptr) && !p_ptr->image) r_ptr->r_flags3 |= (RF3_EVIL);
2121 if ((p_ptr->esp_good) && (r_ptr->flags3 & (RF3_GOOD)))
2124 if (is_original_ap(m_ptr) && !p_ptr->image) r_ptr->r_flags3 |= (RF3_GOOD);
2127 if ((p_ptr->esp_nonliving) &&
2128 ((r_ptr->flags3 & (RF3_DEMON | RF3_UNDEAD | RF3_NONLIVING)) == RF3_NONLIVING))
2131 if (is_original_ap(m_ptr) && !p_ptr->image) r_ptr->r_flags3 |= (RF3_NONLIVING);
2134 if ((p_ptr->esp_unique) && (r_ptr->flags1 & (RF1_UNIQUE)))
2137 if (is_original_ap(m_ptr) && !p_ptr->image) r_ptr->r_flags1 |= (RF1_UNIQUE);
2141 /* Normal line of sight, and not blind */
2142 if (player_has_los_bold(fy, fx) && !p_ptr->blind)
2144 bool do_invisible = FALSE;
2145 bool do_cold_blood = FALSE;
2147 /* Snipers can see targets in darkness when they concentrate deeper */
2148 if (p_ptr->concent >= CONCENT_RADAR_THRESHOLD)
2154 /* Use "infravision" */
2155 if (d <= p_ptr->see_infra)
2157 /* Handle "cold blooded" monsters */
2158 if ((r_ptr->flags2 & (RF2_COLD_BLOOD | RF2_AURA_FIRE)) == RF2_COLD_BLOOD)
2160 do_cold_blood = TRUE;
2163 /* Handle "warm blooded" monsters */
2171 /* Use "illumination" */
2172 if (player_can_see_bold(fy, fx))
2174 /* Handle "invisible" monsters */
2175 if (r_ptr->flags2 & (RF2_INVISIBLE))
2177 do_invisible = TRUE;
2187 /* Handle "normal" monsters */
2198 if (is_original_ap(m_ptr) && !p_ptr->image)
2200 /* Memorize flags */
2201 if (do_invisible) r_ptr->r_flags2 |= (RF2_INVISIBLE);
2202 if (do_cold_blood) r_ptr->r_flags2 |= (RF2_COLD_BLOOD);
2209 /* The monster is now visible */
2212 /* It was previously unseen */
2215 /* Mark as visible */
2218 /* Draw the monster */
2221 /* Update health bar as needed */
2222 if (p_ptr->health_who == m_idx) p_ptr->redraw |= (PR_HEALTH);
2223 if (p_ptr->riding == m_idx) p_ptr->redraw |= (PR_UHEALTH);
2225 /* Hack -- Count "fresh" sightings */
2228 if ((m_ptr->ap_r_idx == MON_KAGE) && (r_info[MON_KAGE].r_sights < MAX_SHORT))
2229 r_info[MON_KAGE].r_sights++;
2230 else if (is_original_ap(m_ptr) && (r_ptr->r_sights < MAX_SHORT))
2234 /* Eldritch Horror */
2235 if (r_info[m_ptr->ap_r_idx].flags2 & RF2_ELDRITCH_HORROR)
2237 sanity_blast(m_ptr, FALSE);
2240 /* Disturb on appearance */
2241 if (disturb_near && (projectable(m_ptr->fy, m_ptr->fx, p_ptr->y, p_ptr->x) && projectable(p_ptr->y, p_ptr->x, m_ptr->fy, m_ptr->fx)))
2243 if (disturb_pets || is_hostile(m_ptr))
2244 disturb(TRUE, TRUE);
2249 /* The monster is not visible */
2252 /* It was previously seen */
2255 /* Mark as not visible */
2258 /* Erase the monster */
2261 /* Update health bar as needed */
2262 if (p_ptr->health_who == m_idx) p_ptr->redraw |= (PR_HEALTH);
2263 if (p_ptr->riding == m_idx) p_ptr->redraw |= (PR_UHEALTH);
2265 /* Disturb on disappearance */
2268 if (disturb_pets || is_hostile(m_ptr))
2269 disturb(TRUE, TRUE);
2275 /* The monster is now easily visible */
2279 if (!(m_ptr->mflag & (MFLAG_VIEW)))
2281 /* Mark as easily visible */
2282 m_ptr->mflag |= (MFLAG_VIEW);
2284 /* Disturb on appearance */
2287 if (disturb_pets || is_hostile(m_ptr))
2288 disturb(TRUE, TRUE);
2293 /* The monster is not easily visible */
2297 if (m_ptr->mflag & (MFLAG_VIEW))
2299 /* Mark as not easily visible */
2300 m_ptr->mflag &= ~(MFLAG_VIEW);
2302 /* Disturb on disappearance */
2305 if (disturb_pets || is_hostile(m_ptr))
2306 disturb(TRUE, TRUE);
2314 * @brief 単純に生存している全モンスターの更新処理を行う / This function simply updates all the (non-dead) monsters (see above).
2315 * @param full 距離更新を行うならtrue
2318 void update_monsters(bool full)
2322 /* Update each (live) monster */
2323 for (i = 1; i < m_max; i++)
2325 monster_type *m_ptr = ¤t_floor_ptr->m_list[i];
2326 if (!monster_is_valid(m_ptr)) continue;
2327 update_monster(i, full);
2333 * @brief カメレオンの王の変身対象となるモンスターかどうか判定する / Hack -- the index of the summoning monster
2334 * @param r_idx モンスター種族ID
2335 * @return 対象にできるならtrueを返す
2337 static bool monster_hook_chameleon_lord(MONRACE_IDX r_idx)
2339 monster_race *r_ptr = &r_info[r_idx];
2340 monster_type *m_ptr = ¤t_floor_ptr->m_list[chameleon_change_m_idx];
2341 monster_race *old_r_ptr = &r_info[m_ptr->r_idx];
2343 if (!(r_ptr->flags1 & (RF1_UNIQUE))) return FALSE;
2344 if (r_ptr->flags7 & (RF7_FRIENDLY | RF7_CHAMELEON)) return FALSE;
2346 if (ABS(r_ptr->level - r_info[MON_CHAMELEON_K].level) > 5) return FALSE;
2348 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))
2351 if (!monster_can_cross_terrain(current_floor_ptr->grid_array[m_ptr->fy][m_ptr->fx].feat, r_ptr, 0)) return FALSE;
2354 if (!(old_r_ptr->flags7 & RF7_CHAMELEON))
2356 if (monster_has_hostile_align(m_ptr, 0, 0, r_ptr)) return FALSE;
2360 else if (summon_specific_who > 0)
2362 if (monster_has_hostile_align(¤t_floor_ptr->m_list[summon_specific_who], 0, 0, r_ptr)) return FALSE;
2369 * @brief カメレオンの変身対象となるモンスターかどうか判定する / Hack -- the index of the summoning monster
2370 * @param r_idx モンスター種族ID
2371 * @return 対象にできるならtrueを返す
2372 * @todo グローバル変数対策の上 monster_hook.cへ移す。
2374 static bool monster_hook_chameleon(MONRACE_IDX r_idx)
2376 monster_race *r_ptr = &r_info[r_idx];
2377 monster_type *m_ptr = ¤t_floor_ptr->m_list[chameleon_change_m_idx];
2378 monster_race *old_r_ptr = &r_info[m_ptr->r_idx];
2380 if (r_ptr->flags1 & (RF1_UNIQUE)) return FALSE;
2381 if (r_ptr->flags2 & RF2_MULTIPLY) return FALSE;
2382 if (r_ptr->flags7 & (RF7_FRIENDLY | RF7_CHAMELEON)) return FALSE;
2384 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))
2387 if (!monster_can_cross_terrain(current_floor_ptr->grid_array[m_ptr->fy][m_ptr->fx].feat, r_ptr, 0)) return FALSE;
2390 if (!(old_r_ptr->flags7 & RF7_CHAMELEON))
2392 if ((old_r_ptr->flags3 & RF3_GOOD) && !(r_ptr->flags3 & RF3_GOOD)) return FALSE;
2393 if ((old_r_ptr->flags3 & RF3_EVIL) && !(r_ptr->flags3 & RF3_EVIL)) return FALSE;
2394 if (!(old_r_ptr->flags3 & (RF3_GOOD | RF3_EVIL)) && (r_ptr->flags3 & (RF3_GOOD | RF3_EVIL))) return FALSE;
2398 else if (summon_specific_who > 0)
2400 if (monster_has_hostile_align(¤t_floor_ptr->m_list[summon_specific_who], 0, 0, r_ptr)) return FALSE;
2403 return (*(get_monster_hook()))(r_idx);
2408 * @param m_idx 変身処理を受けるモンスター情報のID
2409 * @param born 生成時の初変身先指定ならばtrue
2410 * @param r_idx 旧モンスター種族のID
2413 void choose_new_monster(MONSTER_IDX m_idx, bool born, MONRACE_IDX r_idx)
2416 monster_type *m_ptr = ¤t_floor_ptr->m_list[m_idx];
2417 monster_race *r_ptr;
2418 char old_m_name[MAX_NLEN];
2419 bool old_unique = FALSE;
2420 int old_r_idx = m_ptr->r_idx;
2422 if (r_info[m_ptr->r_idx].flags1 & RF1_UNIQUE)
2424 if (old_unique && (r_idx == MON_CHAMELEON)) r_idx = MON_CHAMELEON_K;
2425 r_ptr = &r_info[r_idx];
2427 monster_desc(old_m_name, m_ptr, 0);
2433 chameleon_change_m_idx = m_idx;
2435 get_mon_num_prep(monster_hook_chameleon_lord, NULL);
2437 get_mon_num_prep(monster_hook_chameleon, NULL);
2440 level = r_info[MON_CHAMELEON_K].level;
2441 else if (!current_floor_ptr->dun_level)
2442 level = wilderness[p_ptr->wilderness_y][p_ptr->wilderness_x].level;
2444 level = current_floor_ptr->dun_level;
2446 if (d_info[p_ptr->dungeon_idx].flags1 & DF1_CHAMELEON) level+= 2+randint1(3);
2448 r_idx = get_mon_num(level);
2449 r_ptr = &r_info[r_idx];
2451 chameleon_change_m_idx = 0;
2455 m_ptr->r_idx = r_idx;
2456 m_ptr->ap_r_idx = r_idx;
2457 update_monster(m_idx, FALSE);
2458 lite_spot(m_ptr->fy, m_ptr->fx);
2460 if ((r_info[old_r_idx].flags7 & (RF7_LITE_MASK | RF7_DARK_MASK)) ||
2461 (r_ptr->flags7 & (RF7_LITE_MASK | RF7_DARK_MASK)))
2462 p_ptr->update |= (PU_MON_LITE);
2466 /* Sub-alignment of a chameleon */
2467 if (r_ptr->flags3 & (RF3_EVIL | RF3_GOOD))
2469 m_ptr->sub_align = SUB_ALIGN_NEUTRAL;
2470 if (r_ptr->flags3 & RF3_EVIL) m_ptr->sub_align |= SUB_ALIGN_EVIL;
2471 if (r_ptr->flags3 & RF3_GOOD) m_ptr->sub_align |= SUB_ALIGN_GOOD;
2476 if (m_idx == p_ptr->riding)
2478 GAME_TEXT m_name[MAX_NLEN];
2479 monster_desc(m_name, m_ptr, 0);
2480 msg_format(_("突然%sが変身した。", "Suddenly, %s transforms!"), old_m_name);
2481 if (!(r_ptr->flags7 & RF7_RIDING))
2482 if (rakuba(0, TRUE)) msg_format(_("地面に落とされた。", "You have fallen from %s."), m_name);
2485 /* Extract the monster base speed */
2486 m_ptr->mspeed = get_mspeed(r_ptr);
2488 oldmaxhp = m_ptr->max_maxhp;
2489 /* Assign maximal hitpoints */
2490 if (r_ptr->flags1 & RF1_FORCE_MAXHP)
2492 m_ptr->max_maxhp = maxroll(r_ptr->hdice, r_ptr->hside);
2496 m_ptr->max_maxhp = damroll(r_ptr->hdice, r_ptr->hside);
2499 /* Monsters have double hitpoints in Nightmare mode */
2500 if (ironman_nightmare)
2502 u32b hp = m_ptr->max_maxhp * 2L;
2503 m_ptr->max_maxhp = (HIT_POINT)MIN(30000, hp);
2506 m_ptr->maxhp = (long)(m_ptr->maxhp * m_ptr->max_maxhp) / oldmaxhp;
2507 if (m_ptr->maxhp < 1) m_ptr->maxhp = 1;
2508 m_ptr->hp = (long)(m_ptr->hp * m_ptr->max_maxhp) / oldmaxhp;
2510 /* reset dealt_damage */
2511 m_ptr->dealt_damage = 0;
2516 * @brief たぬきの変身対象となるモンスターかどうか判定する / Hook for Tanuki
2517 * @param r_idx モンスター種族ID
2518 * @return 対象にできるならtrueを返す
2519 * @todo グローバル変数対策の上 monster_hook.cへ移す。
2521 static bool monster_hook_tanuki(MONRACE_IDX r_idx)
2523 monster_race *r_ptr = &r_info[r_idx];
2525 if (r_ptr->flags1 & (RF1_UNIQUE)) return FALSE;
2526 if (r_ptr->flags2 & RF2_MULTIPLY) return FALSE;
2527 if (r_ptr->flags7 & (RF7_FRIENDLY | RF7_CHAMELEON)) return FALSE;
2528 if (r_ptr->flags7 & RF7_AQUATIC) return FALSE;
2530 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))
2533 return (*(get_monster_hook()))(r_idx);
2538 * @brief モンスターの表層IDを設定する / Set initial racial appearance of a monster
2539 * @param r_idx モンスター種族ID
2540 * @return モンスター種族の表層ID
2542 static IDX initial_r_appearance(MONRACE_IDX r_idx)
2544 int attempts = 1000;
2546 DEPTH min = MIN(current_floor_ptr->base_level-5, 50);
2548 if (p_ptr->pseikaku == SEIKAKU_CHARGEMAN)
2550 if (current_floor_ptr->base_level == 0 || one_in_(5)) return MON_ALIEN_JURAL;
2553 if (!(r_info[r_idx].flags7 & RF7_TANUKI))
2556 get_mon_num_prep(monster_hook_tanuki, NULL);
2560 ap_r_idx = get_mon_num(current_floor_ptr->base_level + 10);
2561 if (r_info[ap_r_idx].level >= min) return ap_r_idx;
2569 * @brief モンスターの個体加速を設定する / Get initial monster speed
2570 * @param r_ptr モンスター種族の参照ポインタ
2573 SPEED get_mspeed(monster_race *r_ptr)
2575 /* Extract the monster base speed */
2576 SPEED mspeed = r_ptr->speed;
2578 /* Hack -- small racial variety */
2579 if (!(r_ptr->flags1 & RF1_UNIQUE) && !p_ptr->inside_arena)
2581 /* Allow some small variation per monster */
2582 int i = SPEED_TO_ENERGY(r_ptr->speed) / (one_in_(4) ? 3 : 10);
2583 if (i) mspeed += rand_spread(0, i);
2586 if (mspeed > 199) mspeed = 199;
2593 * @brief モンスターを一体生成する / Attempt to place a monster of the given race at the given location.
2594 * @param who 召喚を行ったモンスターID
2597 * @param r_idx 生成モンスター種族
2598 * @param mode 生成オプション
2601 * To give the player a sporting chance, any monster that appears in
2602 * line-of-sight and is extremely dangerous can be marked as
2603 * "FORCE_SLEEP", which will cause them to be placed with low energy,
2604 * which often (but not always) lets the player move before they do.
2606 * This routine refuses to place out-of-depth "FORCE_DEPTH" monsters.
2608 * Use special "here" and "dead" flags for unique monsters,
2609 * remove old "cur_num" and "max_num" fields.
2611 * Actually, do something similar for artifacts, to simplify
2612 * the "preserve" mode, and to make the "what artifacts" flag more useful.
2614 * This is the only function which may place a monster in the dungeon,
2615 * except for the savefile loading code.
2617 static bool place_monster_one(MONSTER_IDX who, POSITION y, POSITION x, MONRACE_IDX r_idx, BIT_FLAGS mode)
2619 grid_type *g_ptr = ¤t_floor_ptr->grid_array[y][x];
2620 monster_type *m_ptr;
2621 monster_race *r_ptr = &r_info[r_idx];
2622 concptr name = (r_name + r_ptr->name);
2626 /* DO NOT PLACE A MONSTER IN THE SMALL SCALE WILDERNESS !!! */
2627 if (p_ptr->wild_mode) return FALSE;
2629 /* Verify location */
2630 if (!in_bounds(y, x)) return (FALSE);
2631 if (!r_idx) return (FALSE);
2632 if (!r_ptr->name) return (FALSE);
2634 if (!(mode & PM_IGNORE_TERRAIN))
2636 /* Not on the Pattern */
2637 if (pattern_tile(y, x)) return FALSE;
2639 /* Require empty space (if not ghostly) */
2640 if (!monster_can_enter(y, x, r_ptr, 0)) return FALSE;
2643 if (!p_ptr->inside_battle)
2645 /* Hack -- "unique" monsters must be "unique" */
2646 if (((r_ptr->flags1 & (RF1_UNIQUE)) ||
2647 (r_ptr->flags7 & (RF7_NAZGUL))) &&
2648 (r_ptr->cur_num >= r_ptr->max_num))
2654 if ((r_ptr->flags7 & (RF7_UNIQUE2)) &&
2655 (r_ptr->cur_num >= 1))
2660 if (r_idx == MON_BANORLUPART)
2662 if (r_info[MON_BANOR].cur_num > 0) return FALSE;
2663 if (r_info[MON_LUPART].cur_num > 0) return FALSE;
2666 /* Depth monsters may NOT be created out of depth, unless in Nightmare mode */
2667 if ((r_ptr->flags1 & (RF1_FORCE_DEPTH)) && (current_floor_ptr->dun_level < r_ptr->level) &&
2668 (!ironman_nightmare || (r_ptr->flags1 & (RF1_QUESTOR))))
2675 if (quest_number(current_floor_ptr->dun_level))
2677 int hoge = quest_number(current_floor_ptr->dun_level);
2678 if ((quest[hoge].type == QUEST_TYPE_KILL_LEVEL) || (quest[hoge].type == QUEST_TYPE_RANDOM))
2680 if(r_idx == quest[hoge].r_idx)
2682 int number_mon, i2, j2;
2685 /* Count all quest monsters */
2686 for (i2 = 0; i2 < current_floor_ptr->width; ++i2)
2687 for (j2 = 0; j2 < current_floor_ptr->height; j2++)
2688 if (current_floor_ptr->grid_array[j2][i2].m_idx > 0)
2689 if (current_floor_ptr->m_list[current_floor_ptr->grid_array[j2][i2].m_idx].r_idx == quest[hoge].r_idx)
2691 if(number_mon + quest[hoge].cur_num >= quest[hoge].max_num)
2697 if (is_glyph_grid(g_ptr))
2699 if (randint1(BREAK_GLYPH) < (r_ptr->level+20))
2701 /* Describe observable breakage */
2702 if (g_ptr->info & CAVE_MARK)
2704 msg_print(_("守りのルーンが壊れた!", "The rune of protection is broken!"));
2707 /* Forget the rune */
2708 g_ptr->info &= ~(CAVE_MARK);
2710 /* Break the rune */
2711 g_ptr->info &= ~(CAVE_OBJECT);
2719 msg_format_wizard(CHEAT_MONSTER, _("%s(Lv%d)を生成しました。", "%s(Lv%d) was generated."), name, r_ptr->level);
2721 if ((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags7 & RF7_NAZGUL) || (r_ptr->level < 10)) mode &= ~PM_KAGE;
2723 /* Make a new monster */
2724 g_ptr->m_idx = m_pop();
2725 hack_m_idx_ii = g_ptr->m_idx;
2727 /* Mega-Hack -- catch "failure" */
2728 if (!g_ptr->m_idx) return (FALSE);
2731 /* Get a new monster record */
2732 m_ptr = ¤t_floor_ptr->m_list[g_ptr->m_idx];
2735 m_ptr->r_idx = r_idx;
2736 m_ptr->ap_r_idx = initial_r_appearance(r_idx);
2742 /* Hack -- Appearance transfer */
2743 if ((mode & PM_MULTIPLY) && (who > 0) && !is_original_ap(¤t_floor_ptr->m_list[who]))
2745 m_ptr->ap_r_idx = current_floor_ptr->m_list[who].ap_r_idx;
2747 /* Hack -- Shadower spawns Shadower */
2748 if (current_floor_ptr->m_list[who].mflag2 & MFLAG2_KAGE) m_ptr->mflag2 |= MFLAG2_KAGE;
2751 /* Sub-alignment of a monster */
2752 if ((who > 0) && !(r_ptr->flags3 & (RF3_EVIL | RF3_GOOD)))
2753 m_ptr->sub_align = current_floor_ptr->m_list[who].sub_align;
2756 m_ptr->sub_align = SUB_ALIGN_NEUTRAL;
2757 if (r_ptr->flags3 & RF3_EVIL) m_ptr->sub_align |= SUB_ALIGN_EVIL;
2758 if (r_ptr->flags3 & RF3_GOOD) m_ptr->sub_align |= SUB_ALIGN_GOOD;
2761 /* Place the monster at the location */
2766 /* No "timed status" yet */
2767 for (cmi = 0; cmi < MAX_MTIMED; cmi++) m_ptr->mtimed[cmi] = 0;
2769 /* Unknown distance */
2772 reset_target(m_ptr);
2774 m_ptr->nickname = 0;
2779 /* Your pet summons its pet. */
2780 if (who > 0 && is_pet(¤t_floor_ptr->m_list[who]))
2782 mode |= PM_FORCE_PET;
2783 m_ptr->parent_m_idx = who;
2787 m_ptr->parent_m_idx = 0;
2790 if (r_ptr->flags7 & RF7_CHAMELEON)
2792 choose_new_monster(g_ptr->m_idx, TRUE, 0);
2793 r_ptr = &r_info[m_ptr->r_idx];
2794 m_ptr->mflag2 |= MFLAG2_CHAMELEON;
2796 /* Hack - Set sub_align to neutral when the Chameleon Lord is generated as "GUARDIAN" */
2797 if ((r_ptr->flags1 & RF1_UNIQUE) && (who <= 0))
2798 m_ptr->sub_align = SUB_ALIGN_NEUTRAL;
2800 else if ((mode & PM_KAGE) && !(mode & PM_FORCE_PET))
2802 m_ptr->ap_r_idx = MON_KAGE;
2803 m_ptr->mflag2 |= MFLAG2_KAGE;
2806 if (mode & PM_NO_PET) m_ptr->mflag2 |= MFLAG2_NOPET;
2812 if (mode & PM_FORCE_PET)
2817 else if ((r_ptr->flags7 & RF7_FRIENDLY) ||
2818 (mode & PM_FORCE_FRIENDLY) || is_friendly_idx(who))
2820 if (!monster_has_hostile_align(NULL, 0, -1, r_ptr)) set_friendly(m_ptr);
2823 /* Assume no sleeping */
2824 m_ptr->mtimed[MTIMED_CSLEEP] = 0;
2826 /* Enforce sleeping if needed */
2827 if ((mode & PM_ALLOW_SLEEP) && r_ptr->sleep && !ironman_nightmare)
2829 int val = r_ptr->sleep;
2830 (void)set_monster_csleep(g_ptr->m_idx, (val * 2) + randint1(val * 10));
2833 /* Assign maximal hitpoints */
2834 if (r_ptr->flags1 & RF1_FORCE_MAXHP)
2836 m_ptr->max_maxhp = maxroll(r_ptr->hdice, r_ptr->hside);
2840 m_ptr->max_maxhp = damroll(r_ptr->hdice, r_ptr->hside);
2843 /* Monsters have double hitpoints in Nightmare mode */
2844 if (ironman_nightmare)
2846 u32b hp = m_ptr->max_maxhp * 2L;
2848 m_ptr->max_maxhp = (HIT_POINT)MIN(30000, hp);
2851 m_ptr->maxhp = m_ptr->max_maxhp;
2853 /* And start out fully healthy */
2854 if (m_ptr->r_idx == MON_WOUNDED_BEAR)
2855 m_ptr->hp = m_ptr->maxhp / 2;
2856 else m_ptr->hp = m_ptr->maxhp;
2859 /* dealt damage is 0 at initial*/
2860 m_ptr->dealt_damage = 0;
2863 /* Extract the monster base speed */
2864 m_ptr->mspeed = get_mspeed(r_ptr);
2866 if (mode & PM_HASTE) (void)set_monster_fast(g_ptr->m_idx, 100);
2868 /* Give a random starting energy */
2869 if (!ironman_nightmare)
2871 m_ptr->energy_need = ENERGY_NEED() - (s16b)randint0(100);
2875 /* Nightmare monsters are more prepared */
2876 m_ptr->energy_need = ENERGY_NEED() - (s16b)randint0(100) * 2;
2879 /* Force monster to wait for player, unless in Nightmare mode */
2880 if ((r_ptr->flags1 & RF1_FORCE_SLEEP) && !ironman_nightmare)
2882 /* Monster is still being nice */
2883 m_ptr->mflag |= (MFLAG_NICE);
2885 /* Must repair monsters */
2886 repair_monsters = TRUE;
2889 /* Hack -- see "process_monsters()" */
2890 if (g_ptr->m_idx < hack_m_idx)
2892 /* Monster is still being born */
2893 m_ptr->mflag |= (MFLAG_BORN);
2897 if (r_ptr->flags7 & RF7_SELF_LD_MASK)
2898 p_ptr->update |= (PU_MON_LITE);
2899 else if ((r_ptr->flags7 & RF7_HAS_LD_MASK) && !MON_CSLEEP(m_ptr))
2900 p_ptr->update |= (PU_MON_LITE);
2901 update_monster(g_ptr->m_idx, TRUE);
2904 /* Count the monsters on the level */
2905 real_r_ptr(m_ptr)->cur_num++;
2908 * Memorize location of the unique monster in saved floors.
2909 * A unique monster move from old saved floor.
2911 if (character_dungeon &&
2912 ((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags7 & RF7_NAZGUL)))
2913 real_r_ptr(m_ptr)->floor_id = p_ptr->floor_id;
2915 /* Hack -- Count the number of "reproducers" */
2916 if (r_ptr->flags2 & RF2_MULTIPLY) current_floor_ptr->num_repro++;
2918 /* Hack -- Notice new multi-hued monsters */
2920 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
2921 if (ap_r_ptr->flags1 & (RF1_ATTR_MULTI | RF1_SHAPECHANGER))
2922 shimmer_monsters = TRUE;
2925 if (p_ptr->warning && character_dungeon)
2927 if (r_ptr->flags1 & RF1_UNIQUE)
2931 GAME_TEXT o_name[MAX_NLEN];
2933 if (r_ptr->level > p_ptr->lev + 30)
2934 color = _("黒く", "black");
2935 else if (r_ptr->level > p_ptr->lev + 15)
2936 color = _("紫色に", "purple");
2937 else if (r_ptr->level > p_ptr->lev + 5)
2938 color = _("ルビー色に", "deep red");
2939 else if (r_ptr->level > p_ptr->lev - 5)
2940 color = _("赤く", "red");
2941 else if (r_ptr->level > p_ptr->lev - 15)
2942 color = _("ピンク色に", "pink");
2944 color = _("白く", "white");
2946 o_ptr = choose_warning_item();
2949 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2950 msg_format(_("%sは%s光った。", "%s glows %s."), o_name, color);
2954 msg_format(_("%s光る物が頭に浮かんだ。", "An %s image forms in your mind."), color);
2959 if (is_explosive_rune_grid(g_ptr))
2961 /* Break the ward */
2962 if (randint1(BREAK_MINOR_GLYPH) > r_ptr->level)
2964 /* Describe observable breakage */
2965 if (g_ptr->info & CAVE_MARK)
2967 msg_print(_("ルーンが爆発した!", "The rune explodes!"));
2968 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);
2973 msg_print(_("爆発のルーンは解除された。", "An explosive rune was disarmed."));
2976 /* Forget the rune */
2977 g_ptr->info &= ~(CAVE_MARK);
2979 /* Break the rune */
2980 g_ptr->info &= ~(CAVE_OBJECT);
2993 #define MON_SCAT_MAXD 10 /*!< mon_scatter()関数によるモンスター配置で許される中心からの最大距離 */
2996 * @brief モンスター1体を目標地点に可能な限り近い位置に生成する / improved version of scatter() for place monster
2997 * @param r_idx 生成モンスター種族
2998 * @param yp 結果生成位置y座標
2999 * @param xp 結果生成位置x座標
3000 * @param y 中心生成位置y座標
3001 * @param x 中心生成位置x座標
3002 * @param max_dist 生成位置の最大半径
3006 static bool mon_scatter(MONRACE_IDX r_idx, POSITION *yp, POSITION *xp, POSITION y, POSITION x, POSITION max_dist)
3008 POSITION place_x[MON_SCAT_MAXD];
3009 POSITION place_y[MON_SCAT_MAXD];
3010 int num[MON_SCAT_MAXD];
3014 if (max_dist >= MON_SCAT_MAXD)
3017 for (i = 0; i < MON_SCAT_MAXD; i++)
3020 for (nx = x - max_dist; nx <= x + max_dist; nx++)
3022 for (ny = y - max_dist; ny <= y + max_dist; ny++)
3024 /* Ignore annoying locations */
3025 if (!in_bounds(ny, nx)) continue;
3027 /* Require "line of projection" */
3028 if (!projectable(y, x, ny, nx)) continue;
3032 monster_race *r_ptr = &r_info[r_idx];
3034 /* Require empty space (if not ghostly) */
3035 if (!monster_can_enter(ny, nx, r_ptr, 0))
3040 /* Walls and Monsters block flow */
3041 if (!cave_empty_bold2(ny, nx)) continue;
3043 /* ... nor on the Pattern */
3044 if (pattern_tile(ny, nx)) continue;
3047 i = distance(y, x, ny, nx);
3055 if (one_in_(num[i]))
3064 while (i < MON_SCAT_MAXD && 0 == num[i])
3066 if (i >= MON_SCAT_MAXD)
3076 * @brief モンスターを目標地点に集団生成する / Attempt to place a "group" of monsters around the given location
3077 * @param who 召喚主のモンスター情報ID
3078 * @param y 中心生成位置y座標
3079 * @param x 中心生成位置x座標
3080 * @param r_idx 生成モンスター種族
3081 * @param mode 生成オプション
3084 static bool place_monster_group(MONSTER_IDX who, POSITION y, POSITION x, MONRACE_IDX r_idx, BIT_FLAGS mode)
3086 monster_race *r_ptr = &r_info[r_idx];
3089 int total = 0, extra = 0;
3093 POSITION hack_y[GROUP_MAX];
3094 POSITION hack_x[GROUP_MAX];
3097 /* Pick a group size */
3098 total = randint1(10);
3100 /* Hard monsters, small groups */
3101 if (r_ptr->level > current_floor_ptr->dun_level)
3103 extra = r_ptr->level - current_floor_ptr->dun_level;
3104 extra = 0 - randint1(extra);
3107 /* Easy monsters, large groups */
3108 else if (r_ptr->level < current_floor_ptr->dun_level)
3110 extra = current_floor_ptr->dun_level - r_ptr->level;
3111 extra = randint1(extra);
3114 /* Hack -- limit group reduction */
3115 if (extra > 9) extra = 9;
3117 /* Modify the group size */
3121 if (total < 1) total = 1;
3124 if (total > GROUP_MAX) total = GROUP_MAX;
3127 /* Start on the monster */
3132 /* Puddle monsters, breadth first, up to total */
3133 for (n = 0; (n < hack_n) && (hack_n < total); n++)
3135 /* Grab the location */
3136 POSITION hx = hack_x[n];
3137 POSITION hy = hack_y[n];
3139 /* Check each direction, up to total */
3140 for (i = 0; (i < 8) && (hack_n < total); i++)
3144 scatter(&my, &mx, hy, hx, 4, 0);
3146 /* Walls and Monsters block flow */
3147 if (!cave_empty_bold2(my, mx)) continue;
3149 /* Attempt to place another monster */
3150 if (place_monster_one(who, my, mx, r_idx, mode))
3152 /* Add it to the "hack" set */
3153 hack_y[hack_n] = my;
3154 hack_x[hack_n] = mx;
3166 * @var place_monster_idx
3167 * @brief 護衛対象となるモンスター種族IDを渡すグローバル変数 / Hack -- help pick an escort type
3168 * @todo 関数ポインタの都合を配慮しながら、グローバル変数place_monster_idxを除去し、関数引数化する
3170 static MONSTER_IDX place_monster_idx = 0;
3173 * @var place_monster_m_idx
3174 * @brief 護衛対象となるモンスターIDを渡すグローバル変数 / Hack -- help pick an escort type
3175 * @todo 関数ポインタの都合を配慮しながら、グローバル変数place_monster_m_idxを除去し、関数引数化する
3177 static MONSTER_IDX place_monster_m_idx = 0;
3180 * @brief モンスター種族が召喚主の護衛となれるかどうかをチェックする / Hack -- help pick an escort type
3181 * @param r_idx チェックするモンスター種族のID
3182 * @return 護衛にできるならばtrue
3184 static bool place_monster_can_escort(MONRACE_IDX r_idx)
3186 monster_race *r_ptr = &r_info[place_monster_idx];
3187 monster_type *m_ptr = ¤t_floor_ptr->m_list[place_monster_m_idx];
3189 monster_race *z_ptr = &r_info[r_idx];
3191 /* Hack - Escorts have to have the same dungeon flag */
3192 if (mon_hook_dungeon(place_monster_idx) != mon_hook_dungeon(r_idx)) return (FALSE);
3194 /* Require similar "race" */
3195 if (z_ptr->d_char != r_ptr->d_char) return (FALSE);
3197 /* Skip more advanced monsters */
3198 if (z_ptr->level > r_ptr->level) return (FALSE);
3200 /* Skip unique monsters */
3201 if (z_ptr->flags1 & RF1_UNIQUE) return (FALSE);
3203 /* Paranoia -- Skip identical monsters */
3204 if (place_monster_idx == r_idx) return (FALSE);
3206 /* Skip different alignment */
3207 if (monster_has_hostile_align(m_ptr, 0, 0, z_ptr)) return FALSE;
3209 if (r_ptr->flags7 & RF7_FRIENDLY)
3211 if (monster_has_hostile_align(NULL, 1, -1, z_ptr)) return FALSE;
3214 if ((r_ptr->flags7 & RF7_CHAMELEON) && !(z_ptr->flags7 & RF7_CHAMELEON))
3222 * @brief 一般的なモンスター生成処理のサブルーチン / Attempt to place a monster of the given race at the given location
3223 * @param who 召喚主のモンスター情報ID
3226 * @param r_idx 生成するモンスターの種族ID
3227 * @param mode 生成オプション
3228 * @return 生成に成功したらtrue
3230 * Note that certain monsters are now marked as requiring "friends".
3231 * These monsters, if successfully placed, and if the "grp" parameter
3232 * is TRUE, will be surrounded by a "group" of identical monsters.
3234 * Note that certain monsters are now marked as requiring an "escort",
3235 * which is a collection of monsters with similar "race" but lower level.
3237 * Some monsters induce a fake "group" flag on their escorts.
3239 * Note the "bizarre" use of non-recursion to prevent annoying output
3240 * when running a code profiler.
3242 * Note the use of the new "monster allocation table" code to restrict
3243 * the "get_mon_num()" function to "legal" escort types.
3245 bool place_monster_aux(MONSTER_IDX who, POSITION y, POSITION x, MONRACE_IDX r_idx, BIT_FLAGS mode)
3248 monster_race *r_ptr = &r_info[r_idx];
3250 if (!(mode & PM_NO_KAGE) && one_in_(333))
3253 /* Place one monster, or fail */
3254 if (!place_monster_one(who, y, x, r_idx, mode)) return (FALSE);
3256 /* Require the "group" flag */
3257 if (!(mode & PM_ALLOW_GROUP)) return (TRUE);
3259 place_monster_m_idx = hack_m_idx_ii;
3262 for(i = 0; i < 6; i++)
3264 if(!r_ptr->reinforce_id[i]) break;
3265 n = damroll(r_ptr->reinforce_dd[i], r_ptr->reinforce_ds[i]);
3266 for(j = 0; j < n; j++)
3268 POSITION nx, ny, d = 7;
3269 scatter(&ny, &nx, y, x, d, 0);
3270 (void)place_monster_one(place_monster_m_idx, ny, nx, r_ptr->reinforce_id[i], mode);
3274 /* Friends for certain monsters */
3275 if (r_ptr->flags1 & (RF1_FRIENDS))
3277 /* Attempt to place a group */
3278 (void)place_monster_group(who, y, x, r_idx, mode);
3281 /* Escorts for certain monsters */
3282 if (r_ptr->flags1 & (RF1_ESCORT))
3284 /* Set the escort index */
3285 place_monster_idx = r_idx;
3287 /* Try to place several "escorts" */
3288 for (i = 0; i < 32; i++)
3290 POSITION nx, ny, d = 3;
3293 /* Pick a location */
3294 scatter(&ny, &nx, y, x, d, 0);
3296 /* Require empty grids */
3297 if (!cave_empty_bold2(ny, nx)) continue;
3298 get_mon_num_prep(place_monster_can_escort, get_monster_hook2(ny, nx));
3300 /* Pick a random race */
3301 z = get_mon_num(r_ptr->level);
3303 /* Handle failure */
3306 /* Place a single escort */
3307 (void)place_monster_one(place_monster_m_idx, ny, nx, z, mode);
3309 /* Place a "group" of escorts if needed */
3310 if ((r_info[z].flags1 & RF1_FRIENDS) ||
3311 (r_ptr->flags1 & RF1_ESCORTS))
3313 /* Place a group of monsters */
3314 (void)place_monster_group(place_monster_m_idx, ny, nx, z, mode);
3324 * @brief 一般的なモンスター生成処理のメインルーチン / Attempt to place a monster of the given race at the given location
3327 * @param mode 生成オプション
3328 * @return 生成に成功したらtrue
3330 bool place_monster(POSITION y, POSITION x, BIT_FLAGS mode)
3333 get_mon_num_prep(get_monster_hook(), get_monster_hook2(y, x));
3335 /* Pick a monster */
3336 r_idx = get_mon_num(current_floor_ptr->monster_level);
3338 /* Handle failure */
3339 if (!r_idx) return (FALSE);
3341 /* Attempt to place the monster */
3342 if (place_monster_aux(0, y, x, r_idx, mode)) return (TRUE);
3348 * @brief 指定地点に1種類のモンスター種族による群れを生成する
3351 * @return 生成に成功したらtrue
3353 bool alloc_horde(POSITION y, POSITION x)
3355 monster_race *r_ptr = NULL;
3356 MONRACE_IDX r_idx = 0;
3358 int attempts = 1000;
3361 get_mon_num_prep(get_monster_hook(), get_monster_hook2(y, x));
3365 /* Pick a monster */
3366 r_idx = get_mon_num(current_floor_ptr->monster_level);
3368 /* Handle failure */
3369 if (!r_idx) return (FALSE);
3371 r_ptr = &r_info[r_idx];
3373 if (r_ptr->flags1 & RF1_UNIQUE) continue;
3375 if (r_idx == MON_HAGURE) continue;
3378 if (attempts < 1) return FALSE;
3384 /* Attempt to place the monster */
3385 if (place_monster_aux(0, y, x, r_idx, 0L)) break;
3388 if (attempts < 1) return FALSE;
3390 m_idx = current_floor_ptr->grid_array[y][x].m_idx;
3392 if (current_floor_ptr->m_list[m_idx].mflag2 & MFLAG2_CHAMELEON) r_ptr = &r_info[current_floor_ptr->m_list[m_idx].r_idx];
3394 for (attempts = randint1(10) + 5; attempts; attempts--)
3396 scatter(&cy, &cx, y, x, 5, 0);
3398 (void)summon_specific(m_idx, cy, cx, current_floor_ptr->dun_level + 5, SUMMON_KIN, PM_ALLOW_GROUP, r_ptr->d_char);
3404 if (cheat_hear) msg_format(_("モンスターの大群(%c)", "Monster horde (%c)."), r_ptr->d_char);
3409 * @brief ダンジョンの主生成を試みる / Put the Guardian
3410 * @param def_val 現在の主の生成状態
3411 * @return 生成に成功したらtrue
3413 bool alloc_guardian(bool def_val)
3415 MONRACE_IDX guardian = d_info[p_ptr->dungeon_idx].final_guardian;
3417 if (guardian && (d_info[p_ptr->dungeon_idx].maxdepth == current_floor_ptr->dun_level) && (r_info[guardian].cur_num < r_info[guardian].max_num))
3421 int try_count = 4000;
3423 /* Find a good position */
3426 /* Get a random spot */
3427 oy = randint1(current_floor_ptr->height - 4) + 2;
3428 ox = randint1(current_floor_ptr->width - 4) + 2;
3430 /* Is it a good spot ? */
3431 if (cave_empty_bold2(oy, ox) && monster_can_cross_terrain(current_floor_ptr->grid_array[oy][ox].feat, &r_info[guardian], 0))
3433 /* Place the guardian */
3434 if (place_monster_aux(0, oy, ox, guardian, (PM_ALLOW_GROUP | PM_NO_KAGE | PM_NO_PET))) return TRUE;
3437 /* One less try count */
3449 * @brief ダンジョンの初期配置モンスターを生成1回生成する / Attempt to allocate a random monster in the dungeon.
3450 * @param dis プレイヤーから離れるべき最低距離
3451 * @param mode 生成オプション
3452 * @return 生成に成功したらtrue
3454 * Place the monster at least "dis" distance from the player.
3455 * Use "slp" to choose the initial "sleep" status
3456 * Use "current_floor_ptr->monster_level" for the monster level
3458 bool alloc_monster(POSITION dis, BIT_FLAGS mode)
3460 POSITION y = 0, x = 0;
3461 int attempts_left = 10000;
3463 /* Put the Guardian */
3464 if (alloc_guardian(FALSE)) return TRUE;
3466 /* Find a legal, distant, unoccupied, space */
3467 while (attempts_left--)
3469 /* Pick a location */
3470 y = randint0(current_floor_ptr->height);
3471 x = randint0(current_floor_ptr->width);
3473 /* Require empty floor grid (was "naked") */
3474 if (current_floor_ptr->dun_level)
3476 if (!cave_empty_bold2(y, x)) continue;
3480 if (!cave_empty_bold(y, x)) continue;
3483 /* Accept far away grids */
3484 if (distance(y, x, p_ptr->y, p_ptr->x) > dis) break;
3489 if (cheat_xtra || cheat_hear)
3491 msg_print(_("警告!新たなモンスターを配置できません。小さい階ですか?", "Warning! Could not allocate a new monster. Small level?"));
3498 if (randint1(5000) <= current_floor_ptr->dun_level)
3500 if (alloc_horde(y, x))
3507 /* Attempt to place the monster, allow groups */
3508 if (place_monster(y, x, (mode | PM_ALLOW_GROUP))) return (TRUE);
3516 * @brief モンスターが召喚の基本条件に合っているかをチェックする / Hack -- help decide if a monster race is "okay" to summon
3517 * @param r_idx チェックするモンスター種族ID
3518 * @return 召喚対象にできるならばTRUE
3520 static bool summon_specific_okay(MONRACE_IDX r_idx)
3522 monster_race *r_ptr = &r_info[r_idx];
3524 /* Hack - Only summon dungeon monsters */
3525 if (!mon_hook_dungeon(r_idx)) return (FALSE);
3527 /* Hack -- identify the summoning monster */
3528 if (summon_specific_who > 0)
3530 monster_type *m_ptr = ¤t_floor_ptr->m_list[summon_specific_who];
3532 /* Do not summon enemies */
3534 /* Friendly vs. opposite aligned normal or pet */
3535 if (monster_has_hostile_align(m_ptr, 0, 0, r_ptr)) return FALSE;
3537 /* Use the player's alignment */
3538 else if (summon_specific_who < 0)
3540 /* Do not summon enemies of the pets */
3541 if (monster_has_hostile_align(NULL, 10, -10, r_ptr))
3543 if (!one_in_(ABS(p_ptr->align) / 2 + 1)) return FALSE;
3547 if (!summon_unique_okay && ((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags7 & RF7_NAZGUL))) return FALSE;
3549 /* Hack -- no specific type specified */
3550 if (!summon_specific_type) return (TRUE);
3552 if ((summon_specific_who < 0) &&
3553 ((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->flags7 & RF7_NAZGUL)) &&
3554 monster_has_hostile_align(NULL, 10, -10, r_ptr))
3557 if ((r_ptr->flags7 & RF7_CHAMELEON) && (d_info[p_ptr->dungeon_idx].flags1 & DF1_CHAMELEON)) return TRUE;
3559 return (summon_specific_aux(r_idx));
3564 * @brief モンスターを召喚により配置する / Place a monster (of the specified "type") near the given location. Return TRUE if a monster was actually summoned.
3565 * @param who 召喚主のモンスター情報ID
3570 * @param mode 生成オプション
3571 * @return 召喚できたらtrueを返す
3574 * We will attempt to place the monster up to 10 times before giving up.
3576 * Note: SUMMON_UNIQUE and SUMMON_AMBERITES will summon Unique's
3577 * Note: SUMMON_HI_UNDEAD and SUMMON_HI_DRAGON may summon Unique's
3578 * Note: None of the other summon codes will ever summon Unique's.
3580 * This function has been changed. We now take the "monster level"
3581 * of the summoning monster as a parameter, and use that, along with
3582 * the current dungeon level, to help determine the level of the
3583 * desired monster. Note that this is an upper bound, and also
3584 * tends to "prefer" monsters of that level. Currently, we use
3585 * the average of the dungeon and monster levels, and then add
3586 * five to allow slight increases in monster power.
3588 * Note that we use the new "monster allocation table" creation code
3589 * to restrict the "get_mon_num()" function to the set of "legal"
3590 * monsters, making this function much faster and more reliable.
3592 * Note that this function may not succeed, though this is very rare.
3594 bool summon_specific(MONSTER_IDX who, POSITION y1, POSITION x1, DEPTH lev, int type, BIT_FLAGS mode, SYMBOL_CODE symbol)
3599 if (p_ptr->inside_arena) return (FALSE);
3601 if (!mon_scatter(0, &y, &x, y1, x1, 2)) return FALSE;
3603 /* Save the summoner */
3604 summon_specific_who = who;
3606 /* Save the "summon" type */
3607 summon_specific_type = type;
3609 summon_kin_type = symbol;
3611 summon_unique_okay = (mode & PM_ALLOW_UNIQUE) ? TRUE : FALSE;
3612 get_mon_num_prep(summon_specific_okay, get_monster_hook2(y, x));
3614 /* Pick a monster, using the level calculation */
3615 r_idx = get_mon_num((current_floor_ptr->dun_level + lev) / 2 + 5);
3617 /* Handle failure */
3620 summon_specific_type = 0;
3624 if ((type == SUMMON_BLUE_HORROR) || (type == SUMMON_DAWN)) mode |= PM_NO_KAGE;
3626 /* Attempt to place the monster (awake, allow groups) */
3627 if (!place_monster_aux(who, y, x, r_idx, mode))
3629 summon_specific_type = 0;
3633 summon_specific_type = 0;
3635 sound(SOUND_SUMMON);
3641 * @brief 特定モンスター種族を召喚により生成する / A "dangerous" function, creates a pet of the specified type
3642 * @param who 召喚主のモンスター情報ID
3645 * @param r_idx 生成するモンスター種族ID
3646 * @param mode 生成オプション
3647 * @return 召喚できたらtrueを返す
3649 bool summon_named_creature(MONSTER_IDX who, POSITION oy, POSITION ox, MONRACE_IDX r_idx, BIT_FLAGS mode)
3652 /* if (!r_idx) return; */
3654 /* Prevent illegal monsters */
3655 if (r_idx >= max_r_idx) return FALSE;
3657 if (p_ptr->inside_arena) return FALSE;
3659 if (!mon_scatter(r_idx, &y, &x, oy, ox, 2)) return FALSE;
3661 /* Place it (allow groups) */
3662 return place_monster_aux(who, y, x, r_idx, (mode | PM_NO_KAGE));
3667 * @brief モンスターを増殖生成する / Let the given monster attempt to reproduce.
3668 * @param m_idx 増殖するモンスター情報ID
3669 * @param clone クローン・モンスター処理ならばtrue
3670 * @param mode 生成オプション
3671 * @return 生成できたらtrueを返す
3673 * Note that "reproduction" REQUIRES empty space.
3675 bool multiply_monster(MONSTER_IDX m_idx, bool clone, BIT_FLAGS mode)
3677 monster_type *m_ptr = ¤t_floor_ptr->m_list[m_idx];
3680 if (!mon_scatter(m_ptr->r_idx, &y, &x, m_ptr->fy, m_ptr->fx, 1))
3683 if (m_ptr->mflag2 & MFLAG2_NOPET) mode |= PM_NO_PET;
3685 /* Create a new monster (awake, no groups) */
3686 if (!place_monster_aux(m_idx, y, x, m_ptr->r_idx, (mode | PM_NO_KAGE | PM_MULTIPLY)))
3689 /* Hack -- Transfer "clone" flag */
3690 if (clone || (m_ptr->smart & SM_CLONED))
3692 current_floor_ptr->m_list[hack_m_idx_ii].smart |= SM_CLONED;
3693 current_floor_ptr->m_list[hack_m_idx_ii].mflag2 |= MFLAG2_NOPET;
3702 * @brief ダメージを受けたモンスターの様子を記述する / Dump a message describing a monster's reaction to damage
3703 * @param m_idx モンスター情報ID
3704 * @param dam 与えたダメージ
3707 * Technically should attempt to treat "Beholder"'s as jelly's
3709 void message_pain(MONSTER_IDX m_idx, HIT_POINT dam)
3711 HIT_POINT oldhp, newhp;
3713 PERCENTAGE percentage;
3715 monster_type *m_ptr = ¤t_floor_ptr->m_list[m_idx];
3716 monster_race *r_ptr = &r_info[m_ptr->r_idx];
3718 GAME_TEXT m_name[MAX_NLEN];
3720 monster_desc(m_name, m_ptr, 0);
3722 if(dam == 0) // Notice non-damage
3724 msg_format(_("%^sはダメージを受けていない。", "%^s is unharmed."), m_name);
3728 /* Note -- subtle fix -CFT */
3730 oldhp = newhp + dam;
3731 tmp = (newhp * 100L) / oldhp;
3734 if(my_strchr(",ejmvwQ", r_ptr->d_char)) // Mushrooms, Eyes, Jellies, Molds, Vortices, Worms, Quylthulgs
3737 if(percentage > 95) msg_format("%^sはほとんど気にとめていない。", m_name);
3738 else if(percentage > 75) msg_format("%^sはしり込みした。", m_name);
3739 else if(percentage > 50) msg_format("%^sは縮こまった。", m_name);
3740 else if(percentage > 35) msg_format("%^sは痛みに震えた。", m_name);
3741 else if(percentage > 20) msg_format("%^sは身もだえした。", m_name);
3742 else if(percentage > 10) msg_format("%^sは苦痛で身もだえした。", m_name);
3743 else msg_format("%^sはぐにゃぐにゃと痙攣した。", m_name);
3745 if(percentage > 95) msg_format("%^s barely notices.", m_name);
3746 else if(percentage > 75) msg_format("%^s flinches.", m_name);
3747 else if(percentage > 50) msg_format("%^s squelches.", m_name);
3748 else if(percentage > 35) msg_format("%^s quivers in pain.", m_name);
3749 else if(percentage > 20) msg_format("%^s writhes about.", m_name);
3750 else if(percentage > 10) msg_format("%^s writhes in agony.", m_name);
3751 else msg_format("%^s jerks limply.", m_name);
3755 else if(my_strchr("l", r_ptr->d_char)) // Fish
3758 if(percentage > 95) msg_format("%^sはほとんど気にとめていない。", m_name);
3759 else if(percentage > 75) msg_format("%^sはしり込みした。", m_name);
3760 else if(percentage > 50) msg_format("%^sは躊躇した。", m_name);
3761 else if(percentage > 35) msg_format("%^sは痛みに震えた。", m_name);
3762 else if(percentage > 20) msg_format("%^sは身もだえした。", m_name);
3763 else if(percentage > 10) msg_format("%^sは苦痛で身もだえした。", m_name);
3764 else msg_format("%^sはぐにゃぐにゃと痙攣した。", m_name);
3766 if(percentage > 95) msg_format("%^s barely notices.", m_name);
3767 else if(percentage > 75) msg_format("%^s flinches.", m_name);
3768 else if(percentage > 50) msg_format("%^s hesitates.", m_name);
3769 else if(percentage > 35) msg_format("%^s quivers in pain.", m_name);
3770 else if(percentage > 20) msg_format("%^s writhes about.", m_name);
3771 else if(percentage > 10) msg_format("%^s writhes in agony.", m_name);
3772 else msg_format("%^s jerks limply.", m_name);
3776 else if(my_strchr("g#+<>", r_ptr->d_char)) // Golems, Walls, Doors, Stairs
3779 if(percentage > 95) msg_format("%sは攻撃を気にとめていない。", m_name);
3780 else if(percentage > 75) msg_format("%sは攻撃に肩をすくめた。", m_name);
3781 else if(percentage > 50) msg_format("%^sは雷鳴のように吠えた。", m_name);
3782 else if(percentage > 35) msg_format("%^sは苦しげに吠えた。", m_name);
3783 else if(percentage > 20) msg_format("%^sはうめいた。", m_name);
3784 else if(percentage > 10) msg_format("%^sは躊躇した。", m_name);
3785 else msg_format("%^sはくしゃくしゃになった。", m_name);
3787 if(percentage > 95) msg_format("%^s ignores the attack.", m_name);
3788 else if(percentage > 75) msg_format("%^s shrugs off the attack.", m_name);
3789 else if(percentage > 50) msg_format("%^s roars thunderously.", m_name);
3790 else if(percentage > 35) msg_format("%^s rumbles.", m_name);
3791 else if(percentage > 20) msg_format("%^s grunts.", m_name);
3792 else if(percentage > 10) msg_format("%^s hesitates.", m_name);
3793 else msg_format("%^s crumples.", m_name);
3797 else if(my_strchr("JMR", r_ptr->d_char) || !isalpha(r_ptr->d_char)) // Snakes, Hydrae, Reptiles, Mimics
3800 if(percentage > 95) msg_format("%^sはほとんど気にとめていない。", m_name);
3801 else if(percentage > 75) msg_format("%^sはシーッと鳴いた。", m_name);
3802 else if(percentage > 50) msg_format("%^sは怒って頭を上げた。", m_name);
3803 else if(percentage > 35) msg_format("%^sは猛然と威嚇した。", m_name);
3804 else if(percentage > 20) msg_format("%^sは身もだえした。", m_name);
3805 else if(percentage > 10) msg_format("%^sは苦痛で身もだえした。", m_name);
3806 else msg_format("%^sはぐにゃぐにゃと痙攣した。", m_name);
3808 if(percentage > 95) msg_format("%^s barely notices.", m_name);
3809 else if(percentage > 75) msg_format("%^s hisses.", m_name);
3810 else if(percentage > 50) msg_format("%^s rears up in anger.", m_name);
3811 else if(percentage > 35) msg_format("%^s hisses furiously.", m_name);
3812 else if(percentage > 20) msg_format("%^s writhes about.", m_name);
3813 else if(percentage > 10) msg_format("%^s writhes in agony.", m_name);
3814 else msg_format("%^s jerks limply.", m_name);
3818 else if(my_strchr("f", r_ptr->d_char))
3821 if(percentage > 95) msg_format("%sは攻撃に肩をすくめた。", m_name);
3822 else if(percentage > 75) msg_format("%^sは吠えた。", m_name);
3823 else if(percentage > 50) msg_format("%^sは怒って吠えた。", m_name);
3824 else if(percentage > 35) msg_format("%^sは痛みでシーッと鳴いた。", m_name);
3825 else if(percentage > 20) msg_format("%^sは痛みで弱々しく鳴いた。", m_name);
3826 else if(percentage > 10) msg_format("%^sは苦痛にうめいた。", m_name);
3827 else msg_format("%sは哀れな鳴き声を出した。", m_name);
3829 if(percentage > 95) msg_format("%^s shrugs off the attack.", m_name);
3830 else if(percentage > 75) msg_format("%^s roars.", m_name);
3831 else if(percentage > 50) msg_format("%^s growls angrily.", m_name);
3832 else if(percentage > 35) msg_format("%^s hisses with pain.", m_name);
3833 else if(percentage > 20) msg_format("%^s mewls in pain.", m_name);
3834 else if(percentage > 10) msg_format("%^s hisses in agony.", m_name);
3835 else msg_format("%^s mewls pitifully.", m_name);
3839 else if(my_strchr("acFIKS", r_ptr->d_char)) // Ants, Centipedes, Flies, Insects, Beetles, Spiders
3842 if(percentage > 95) msg_format("%sは攻撃を気にとめていない。", m_name);
3843 else if(percentage > 75) msg_format("%^sはキーキー鳴いた。", m_name);
3844 else if(percentage > 50) msg_format("%^sはヨロヨロ逃げ回った。", m_name);
3845 else if(percentage > 35) msg_format("%^sはうるさく鳴いた。", m_name);
3846 else if(percentage > 20) msg_format("%^sは痛みに痙攣した。", m_name);
3847 else if(percentage > 10) msg_format("%^sは苦痛で痙攣した。", m_name);
3848 else msg_format("%^sはピクピクひきつった。", m_name);
3850 if(percentage > 95) msg_format("%^s ignores the attack.", m_name);
3851 else if(percentage > 75) msg_format("%^s chitters.", m_name);
3852 else if(percentage > 50) msg_format("%^s scuttles about.", m_name);
3853 else if(percentage > 35) msg_format("%^s twitters.", m_name);
3854 else if(percentage > 20) msg_format("%^s jerks in pain.", m_name);
3855 else if(percentage > 10) msg_format("%^s jerks in agony.", m_name);
3856 else msg_format("%^s twitches.", m_name);
3860 else if(my_strchr("B", r_ptr->d_char)) // Birds
3863 if(percentage > 95) msg_format("%^sはさえずった。", m_name);
3864 else if(percentage > 75) msg_format("%^sはピーピー鳴いた。", m_name);
3865 else if(percentage > 50) msg_format("%^sはギャーギャー鳴いた。", m_name);
3866 else if(percentage > 35) msg_format("%^sはギャーギャー鳴きわめいた。", m_name);
3867 else if(percentage > 20) msg_format("%^sは苦しんだ。", m_name);
3868 else if(percentage > 10) msg_format("%^sはのたうち回った。", m_name);
3869 else msg_format("%^sはキーキーと鳴き叫んだ。", m_name);
3871 if(percentage > 95) msg_format("%^s chirps.", m_name);
3872 else if(percentage > 75) msg_format("%^s twitters.", m_name);
3873 else if(percentage > 50) msg_format("%^s squawks.", m_name);
3874 else if(percentage > 35) msg_format("%^s chatters.", m_name);
3875 else if(percentage > 20) msg_format("%^s jeers.", m_name);
3876 else if(percentage > 10) msg_format("%^s flutters about.", m_name);
3877 else msg_format("%^s squeaks.", m_name);
3881 else if(my_strchr("duDLUW", r_ptr->d_char)) // Dragons, Demons, High Undead
3884 if(percentage > 95) msg_format("%sは攻撃を気にとめていない。", m_name);
3885 else if(percentage > 75) msg_format("%^sはしり込みした。", m_name);
3886 else if(percentage > 50) msg_format("%^sは痛みでシーッと鳴いた。", m_name);
3887 else if(percentage > 35) msg_format("%^sは痛みでうなった。", m_name);
3888 else if(percentage > 20) msg_format("%^sは痛みに吠えた。", m_name);
3889 else if(percentage > 10) msg_format("%^sは苦しげに叫んだ。", m_name);
3890 else msg_format("%^sは弱々しくうなった。", m_name);
3892 if(percentage > 95) msg_format("%^s ignores the attack.", m_name);
3893 else if(percentage > 75) msg_format("%^s flinches.", m_name);
3894 else if(percentage > 50) msg_format("%^s hisses in pain.", m_name);
3895 else if(percentage > 35) msg_format("%^s snarls with pain.", m_name);
3896 else if(percentage > 20) msg_format("%^s roars with pain.", m_name);
3897 else if(percentage > 10) msg_format("%^s gasps.", m_name);
3898 else msg_format("%^s snarls feebly.", m_name);
3902 else if(my_strchr("s", r_ptr->d_char)) // Skeletons
3905 if(percentage > 95) msg_format("%sは攻撃を気にとめていない。", m_name);
3906 else if(percentage > 75) msg_format("%sは攻撃に肩をすくめた。", m_name);
3907 else if(percentage > 50) msg_format("%^sはカタカタと笑った。", m_name);
3908 else if(percentage > 35) msg_format("%^sはよろめいた。", m_name);
3909 else if(percentage > 20) msg_format("%^sはカタカタ言った。", m_name);
3910 else if(percentage > 10) msg_format("%^sはよろめいた。", m_name);
3911 else msg_format("%^sはガタガタ言った。", m_name);
3913 if(percentage > 95) msg_format("%^s ignores the attack.", m_name);
3914 else if(percentage > 75) msg_format("%^s shrugs off the attack.", m_name);
3915 else if(percentage > 50) msg_format("%^s rattles.", m_name);
3916 else if(percentage > 35) msg_format("%^s stumbles.", m_name);
3917 else if(percentage > 20) msg_format("%^s rattles.", m_name);
3918 else if(percentage > 10) msg_format("%^s staggers.", m_name);
3919 else msg_format("%^s clatters.", m_name);
3923 else if(my_strchr("z", r_ptr->d_char)) // Zombies
3926 if(percentage > 95) msg_format("%sは攻撃を気にとめていない。", m_name);
3927 else if(percentage > 75) msg_format("%sは攻撃に肩をすくめた。", m_name);
3928 else if(percentage > 50) msg_format("%^sはうめいた。", m_name);
3929 else if(percentage > 35) msg_format("%sは苦しげにうめいた。", m_name);
3930 else if(percentage > 20) msg_format("%^sは躊躇した。", m_name);
3931 else if(percentage > 10) msg_format("%^sはうなった。", m_name);
3932 else msg_format("%^sはよろめいた。", m_name);
3934 if(percentage > 95) msg_format("%^s ignores the attack.", m_name);
3935 else if(percentage > 75) msg_format("%^s shrugs off the attack.", m_name);
3936 else if(percentage > 50) msg_format("%^s groans.", m_name);
3937 else if(percentage > 35) msg_format("%^s moans.", m_name);
3938 else if(percentage > 20) msg_format("%^s hesitates.", m_name);
3939 else if(percentage > 10) msg_format("%^s grunts.", m_name);
3940 else msg_format("%^s staggers.", m_name);
3944 else if(my_strchr("G", r_ptr->d_char)) // Ghosts
3947 if(percentage > 95) msg_format("%sは攻撃を気にとめていない。", m_name);
3948 else if(percentage > 75) msg_format("%sは攻撃に肩をすくめた。", m_name);
3949 else if(percentage > 50) msg_format("%sはうめいた。", m_name);
3950 else if(percentage > 35) msg_format("%^sは泣きわめいた。", m_name);
3951 else if(percentage > 20) msg_format("%^sは吠えた。", m_name);
3952 else if(percentage > 10) msg_format("%sは弱々しくうめいた。", m_name);
3953 else msg_format("%^sはかすかにうめいた。", m_name);
3955 if(percentage > 95) msg_format("%^s ignores the attack.", m_name);
3956 else if(percentage > 75) msg_format("%^s shrugs off the attack.", m_name);
3957 else if(percentage > 50) msg_format("%^s moans.", m_name);
3958 else if(percentage > 35) msg_format("%^s wails.", m_name);
3959 else if(percentage > 20) msg_format("%^s howls.", m_name);
3960 else if(percentage > 10) msg_format("%^s moans softly.", m_name);
3961 else msg_format("%^s sighs.", m_name);
3965 else if(my_strchr("CZ", r_ptr->d_char)) // Dogs and Hounds
3968 if(percentage > 95) msg_format("%^sは攻撃に肩をすくめた。", m_name);
3969 else if(percentage > 75) msg_format("%^sは痛みでうなった。", m_name);
3970 else if(percentage > 50) msg_format("%^sは痛みでキャンキャン吠えた。", m_name);
3971 else if(percentage > 35) msg_format("%^sは痛みで鳴きわめいた。", m_name);
3972 else if(percentage > 20) msg_format("%^sは苦痛のあまり鳴きわめいた。", m_name);
3973 else if(percentage > 10) msg_format("%^sは苦痛でもだえ苦しんだ。", m_name);
3974 else msg_format("%^sは弱々しく吠えた。", m_name);
3976 if(percentage > 95) msg_format("%^s shrugs off the attack.", m_name);
3977 else if(percentage > 75) msg_format("%^s snarls with pain.", m_name);
3978 else if(percentage > 50) msg_format("%^s yelps in pain.", m_name);
3979 else if(percentage > 35) msg_format("%^s howls in pain.", m_name);
3980 else if(percentage > 20) msg_format("%^s howls in agony.", m_name);
3981 else if(percentage > 10) msg_format("%^s writhes in agony.", m_name);
3982 else msg_format("%^s yelps feebly.", m_name);
3986 else if(my_strchr("Xbilqrt", r_ptr->d_char)) // One type of creatures (ignore,squeal,shriek)
3989 if(percentage > 95) msg_format("%^sは攻撃を気にとめていない。", m_name);
3990 else if(percentage > 75) msg_format("%^sは痛みでうなった。", m_name);
3991 else if(percentage > 50) msg_format("%^sは痛みで叫んだ。", m_name);
3992 else if(percentage > 35) msg_format("%^sは痛みで絶叫した。", m_name);
3993 else if(percentage > 20) msg_format("%^sは苦痛のあまり絶叫した。", m_name);
3994 else if(percentage > 10) msg_format("%^sは苦痛でもだえ苦しんだ。", m_name);
3995 else msg_format("%^sは弱々しく叫んだ。", m_name);
3997 if(percentage > 95) msg_format("%^s ignores the attack.", m_name);
3998 else if(percentage > 75) msg_format("%^s grunts with pain.", m_name);
3999 else if(percentage > 50) msg_format("%^s squeals in pain.", m_name);
4000 else if(percentage > 35) msg_format("%^s shrieks in pain.", m_name);
4001 else if(percentage > 20) msg_format("%^s shrieks in agony.", m_name);
4002 else if(percentage > 10) msg_format("%^s writhes in agony.", m_name);
4003 else msg_format("%^s cries out feebly.", m_name);
4007 else // Another type of creatures (shrug,cry,scream)
4010 if(percentage > 95) msg_format("%^sは攻撃に肩をすくめた。", m_name);
4011 else if(percentage > 75) msg_format("%^sは痛みでうなった。", m_name);
4012 else if(percentage > 50) msg_format("%^sは痛みで叫んだ。", m_name);
4013 else if(percentage > 35) msg_format("%^sは痛みで絶叫した。", m_name);
4014 else if(percentage > 20) msg_format("%^sは苦痛のあまり絶叫した。", m_name);
4015 else if(percentage > 10) msg_format("%^sは苦痛でもだえ苦しんだ。", m_name);
4016 else msg_format("%^sは弱々しく叫んだ。", m_name);
4018 if(percentage > 95) msg_format("%^s shrugs off the attack.", m_name);
4019 else if(percentage > 75) msg_format("%^s grunts with pain.", m_name);
4020 else if(percentage > 50) msg_format("%^s cries out in pain.", m_name);
4021 else if(percentage > 35) msg_format("%^s screams in pain.", m_name);
4022 else if(percentage > 20) msg_format("%^s screams in agony.", m_name);
4023 else if(percentage > 10) msg_format("%^s writhes in agony.", m_name);
4024 else msg_format("%^s cries out feebly.", m_name);
4032 * @brief SMART(適格に攻撃を行う)モンスターの学習状況を更新する / Learn about an "observed" resistance.
4033 * @param m_idx 更新を行う「モンスター情報ID
4034 * @param what 学習対象ID
4037 void update_smart_learn(MONSTER_IDX m_idx, int what)
4039 monster_type *m_ptr = ¤t_floor_ptr->m_list[m_idx];
4040 monster_race *r_ptr = &r_info[m_ptr->r_idx];
4042 /* Not allowed to learn */
4043 if (!smart_learn) return;
4045 /* Too stupid to learn anything */
4046 if (r_ptr->flags2 & (RF2_STUPID)) return;
4048 /* Not intelligent, only learn sometimes */
4049 if (!(r_ptr->flags2 & (RF2_SMART)) && (randint0(100) < 50)) return;
4051 /* Analyze the knowledge */
4055 if (p_ptr->resist_acid) m_ptr->smart |= (SM_RES_ACID);
4056 if (IS_OPPOSE_ACID()) m_ptr->smart |= (SM_OPP_ACID);
4057 if (p_ptr->immune_acid) m_ptr->smart |= (SM_IMM_ACID);
4061 if (p_ptr->resist_elec) m_ptr->smart |= (SM_RES_ELEC);
4062 if (IS_OPPOSE_ELEC()) m_ptr->smart |= (SM_OPP_ELEC);
4063 if (p_ptr->immune_elec) m_ptr->smart |= (SM_IMM_ELEC);
4067 if (p_ptr->resist_fire) m_ptr->smart |= (SM_RES_FIRE);
4068 if (IS_OPPOSE_FIRE()) m_ptr->smart |= (SM_OPP_FIRE);
4069 if (p_ptr->immune_fire) m_ptr->smart |= (SM_IMM_FIRE);
4073 if (p_ptr->resist_cold) m_ptr->smart |= (SM_RES_COLD);
4074 if (IS_OPPOSE_COLD()) m_ptr->smart |= (SM_OPP_COLD);
4075 if (p_ptr->immune_cold) m_ptr->smart |= (SM_IMM_COLD);
4079 if (p_ptr->resist_pois) m_ptr->smart |= (SM_RES_POIS);
4080 if (IS_OPPOSE_POIS()) m_ptr->smart |= (SM_OPP_POIS);
4085 if (p_ptr->resist_neth) m_ptr->smart |= (SM_RES_NETH);
4089 if (p_ptr->resist_lite) m_ptr->smart |= (SM_RES_LITE);
4093 if (p_ptr->resist_dark) m_ptr->smart |= (SM_RES_DARK);
4097 if (p_ptr->resist_fear) m_ptr->smart |= (SM_RES_FEAR);
4101 if (p_ptr->resist_conf) m_ptr->smart |= (SM_RES_CONF);
4105 if (p_ptr->resist_chaos) m_ptr->smart |= (SM_RES_CHAOS);
4109 if (p_ptr->resist_disen) m_ptr->smart |= (SM_RES_DISEN);
4113 if (p_ptr->resist_blind) m_ptr->smart |= (SM_RES_BLIND);
4117 if (p_ptr->resist_nexus) m_ptr->smart |= (SM_RES_NEXUS);
4121 if (p_ptr->resist_sound) m_ptr->smart |= (SM_RES_SOUND);
4125 if (p_ptr->resist_shard) m_ptr->smart |= (SM_RES_SHARD);
4129 if (p_ptr->free_act) m_ptr->smart |= (SM_IMM_FREE);
4133 if (!p_ptr->msp) m_ptr->smart |= (SM_IMM_MANA);
4137 if (p_ptr->reflect) m_ptr-> smart |= (SM_IMM_REFLECT);
4144 * @brief モンスターが盗みや拾いで確保していたアイテムを全てドロップさせる / Drop all items carried by a monster
4145 * @param m_ptr モンスター参照ポインタ
4148 void monster_drop_carried_objects(monster_type *m_ptr)
4150 OBJECT_IDX this_o_idx, next_o_idx = 0;
4156 /* Drop objects being carried */
4157 for (this_o_idx = m_ptr->hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
4159 o_ptr = ¤t_floor_ptr->o_list[this_o_idx];
4160 next_o_idx = o_ptr->next_o_idx;
4163 /* Copy the object */
4164 object_copy(q_ptr, o_ptr);
4166 /* Forget monster */
4167 q_ptr->held_m_idx = 0;
4169 delete_object_idx(this_o_idx);
4172 (void)drop_near(q_ptr, -1, m_ptr->fy, m_ptr->fx);
4175 /* Forget objects */
4176 m_ptr->hold_o_idx = 0;