3 * @brief 雑多なその他の処理2 / effects of various "objects"
6 * Copyright (c) 1989 James E. Wilson, Robert A. Koeneke\n
7 * This software may be copied and distributed for educational, research, and\n
8 * not for profit purposes provided that this copyright and statement are\n
9 * included in all such copies.\n
10 * 2014 Deskull rearranged comment for Doxygen.
16 #include "object-curse.h"
17 #include "monsterrace-hook.h"
18 #include "objectkind-hook.h"
20 #define REWARD_CHANCE 10
24 * @brief プレイヤーの経験値について整合性のためのチェックと調整を行う /
25 * Advance experience levels and print experience
28 void check_experience(void)
30 bool level_reward = FALSE;
31 bool level_mutation = FALSE;
32 bool level_inc_stat = FALSE;
33 bool android = (p_ptr->prace == RACE_ANDROID ? TRUE : FALSE);
34 PLAYER_LEVEL old_lev = p_ptr->lev;
36 /* Hack -- lower limit */
37 if (p_ptr->exp < 0) p_ptr->exp = 0;
38 if (p_ptr->max_exp < 0) p_ptr->max_exp = 0;
39 if (p_ptr->max_max_exp < 0) p_ptr->max_max_exp = 0;
41 /* Hack -- upper limit */
42 if (p_ptr->exp > PY_MAX_EXP) p_ptr->exp = PY_MAX_EXP;
43 if (p_ptr->max_exp > PY_MAX_EXP) p_ptr->max_exp = PY_MAX_EXP;
44 if (p_ptr->max_max_exp > PY_MAX_EXP) p_ptr->max_max_exp = PY_MAX_EXP;
46 /* Hack -- maintain "max" experience */
47 if (p_ptr->exp > p_ptr->max_exp) p_ptr->max_exp = p_ptr->exp;
49 /* Hack -- maintain "max max" experience */
50 if (p_ptr->max_exp > p_ptr->max_max_exp) p_ptr->max_max_exp = p_ptr->max_exp;
52 /* Redraw experience */
53 p_ptr->redraw |= (PR_EXP);
57 /* Lose levels while possible */
58 while ((p_ptr->lev > 1) &&
59 (p_ptr->exp < ((android ? player_exp_a : player_exp)[p_ptr->lev - 2] * p_ptr->expfact / 100L)))
63 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
64 p_ptr->redraw |= (PR_LEV | PR_TITLE);
65 p_ptr->window |= (PW_PLAYER);
70 /* Gain levels while possible */
71 while ((p_ptr->lev < PY_MAX_LEVEL) &&
72 (p_ptr->exp >= ((android ? player_exp_a : player_exp)[p_ptr->lev-1] * p_ptr->expfact / 100L)))
77 /* Save the highest level */
78 if (p_ptr->lev > p_ptr->max_plv)
80 p_ptr->max_plv = p_ptr->lev;
82 if ((p_ptr->pclass == CLASS_CHAOS_WARRIOR) ||
83 (p_ptr->muta2 & MUT2_CHAOS_GIFT))
87 if (p_ptr->prace == RACE_BEASTMAN)
89 if (one_in_(5)) level_mutation = TRUE;
91 level_inc_stat = TRUE;
93 do_cmd_write_nikki(NIKKI_LEVELUP, p_ptr->lev, NULL);
98 msg_format(_("レベル %d にようこそ。", "Welcome to level %d."), p_ptr->lev);
100 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
101 p_ptr->redraw |= (PR_LEV | PR_TITLE | PR_EXP);
102 p_ptr->window |= (PW_PLAYER | PW_SPELL | PW_INVEN);
112 if(!(p_ptr->max_plv % 10))
121 cnv_stat(p_ptr->stat_max[0], tmp);
122 prt(format(_(" a) 腕力 (現在値 %s)", " a) Str (cur %s)"), tmp), 2, 14);
123 cnv_stat(p_ptr->stat_max[1], tmp);
124 prt(format(_(" b) 知能 (現在値 %s)", " a) Int (cur %s)"), tmp), 3, 14);
125 cnv_stat(p_ptr->stat_max[2], tmp);
126 prt(format(_(" c) 賢さ (現在値 %s)", " a) Wis (cur %s)"), tmp), 4, 14);
127 cnv_stat(p_ptr->stat_max[3], tmp);
128 prt(format(_(" d) 器用 (現在値 %s)", " a) Dex (cur %s)"), tmp), 5, 14);
129 cnv_stat(p_ptr->stat_max[4], tmp);
130 prt(format(_(" e) 耐久 (現在値 %s)", " a) Con (cur %s)"), tmp), 6, 14);
131 cnv_stat(p_ptr->stat_max[5], tmp);
132 prt(format(_(" f) 魅力 (現在値 %s)", " a) Chr (cur %s)"), tmp), 7, 14);
135 prt(_(" どの能力値を上げますか?", " Which stat do you want to raise?"), 1, 14);
140 if ((choice >= 'a') && (choice <= 'f')) break;
142 for(n = 0; n < 6; n++)
143 if (n != choice - 'a')
145 if (get_check(_("よろしいですか?", "Are you sure? "))) break;
147 do_inc_stat(choice - 'a');
150 else if(!(p_ptr->max_plv % 2))
151 do_inc_stat(randint0(6));
156 msg_print(_("あなたは変わった気がする...", "You feel different..."));
157 (void)gain_random_mutation(0);
158 level_mutation = FALSE;
162 * 報酬でレベルが上ると再帰的に check_experience() が
167 gain_level_reward(0);
168 level_reward = FALSE;
171 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
172 p_ptr->redraw |= (PR_LEV | PR_TITLE);
173 p_ptr->window |= (PW_PLAYER | PW_SPELL);
177 /* Load an autopick preference file */
178 if (old_lev != p_ptr->lev) autopick_load_pref(FALSE);
183 * @brief モンスターを倒した際の財宝svalを返す
184 * @param r_idx 倒したモンスターの種族ID
187 * Hack -- Return the "automatic coin type" of a monster race
188 * Used to allocate proper treasure when "Creeping coins" die
189 * Note the use of actual "monster names"
191 static int get_coin_type(MONRACE_IDX r_idx)
193 /* Analyze monsters */
196 case MON_COPPER_COINS: return 2;
197 case MON_SILVER_COINS: return 5;
198 case MON_GOLD_COINS: return 10;
199 case MON_MITHRIL_COINS:
200 case MON_MITHRIL_GOLEM: return 16;
201 case MON_ADAMANT_COINS: return 17;
211 * @brief クエストを達成状態にする /
212 * @param quest_num 達成状態にしたいクエストのID
215 void complete_quest(QUEST_IDX quest_num)
217 quest_type* const q_ptr = &quest[quest_num];
221 case QUEST_TYPE_RANDOM:
222 if (record_rand_quest) do_cmd_write_nikki(NIKKI_RAND_QUEST_C, quest_num, NULL);
225 if (record_fix_quest) do_cmd_write_nikki(NIKKI_FIX_QUEST_C, quest_num, NULL);
229 q_ptr->status = QUEST_STATUS_COMPLETED;
230 q_ptr->complev = (byte)p_ptr->lev;
232 q_ptr->comptime = playtime;
234 if (!(q_ptr->flags & QUEST_FLAG_SILENT))
236 play_music(TERM_XTRA_MUSIC_BASIC, MUSIC_BASIC_QUEST_CLEAR);
237 msg_print(_("クエストを達成した!", "You just completed your quest!"));
243 * @brief 現在フロアに残っている敵モンスターの数を返す /
244 * @return 現在の敵モンスターの数
246 static MONSTER_NUMBER count_all_hostile_monsters(void)
249 MONSTER_NUMBER number_mon = 0;
251 for (x = 0; x < cur_wid; ++ x)
253 for (y = 0; y < cur_hgt; ++ y)
255 MONSTER_IDX m_idx = cave[y][x].m_idx;
257 if (m_idx > 0 && is_hostile(&m_list[m_idx]))
268 * @brief 特定の敵を倒した際にクエスト達成処理 /
269 * Check for "Quest" completion when a quest monster is killed or charmed.
270 * @param m_ptr 撃破したモンスターの構造体参照ポインタ
273 void check_quest_completion(monster_type *m_ptr)
278 bool create_stairs = FALSE;
288 quest_num = p_ptr->inside_quest;
290 /* Search for an active quest on this dungeon level */
295 for (i = max_q_idx - 1; i > 0; i--)
297 quest_type* const q_ptr = &quest[i];
299 /* Quest is not active */
300 if (q_ptr->status != QUEST_STATUS_TAKEN)
303 /* Quest is not a dungeon quest */
304 if (q_ptr->flags & QUEST_FLAG_PRESET)
307 /* Quest is not on this level */
308 if ((q_ptr->level != dun_level) &&
309 (q_ptr->type != QUEST_TYPE_KILL_ANY_LEVEL))
312 /* Not a "kill monster" quest */
313 if ((q_ptr->type == QUEST_TYPE_FIND_ARTIFACT) ||
314 (q_ptr->type == QUEST_TYPE_FIND_EXIT))
317 /* Interesting quest */
318 if ((q_ptr->type == QUEST_TYPE_KILL_NUMBER) ||
319 (q_ptr->type == QUEST_TYPE_TOWER) ||
320 (q_ptr->type == QUEST_TYPE_KILL_ALL))
323 /* Interesting quest */
324 if (((q_ptr->type == QUEST_TYPE_KILL_LEVEL) ||
325 (q_ptr->type == QUEST_TYPE_KILL_ANY_LEVEL) ||
326 (q_ptr->type == QUEST_TYPE_RANDOM)) &&
327 (q_ptr->r_idx == m_ptr->r_idx))
334 /* Handle the current quest */
335 if (quest_num && (quest[quest_num].status == QUEST_STATUS_TAKEN))
338 quest_type* const q_ptr = &quest[quest_num];
342 case QUEST_TYPE_KILL_NUMBER:
346 if (q_ptr->cur_num >= q_ptr->num_mon)
348 complete_quest(quest_num);
354 case QUEST_TYPE_KILL_ALL:
356 if (!is_hostile(m_ptr)) break;
358 if (count_all_hostile_monsters() == 1)
360 if (q_ptr->flags & QUEST_FLAG_SILENT)
362 q_ptr->status = QUEST_STATUS_FINISHED;
366 complete_quest(quest_num);
371 case QUEST_TYPE_KILL_LEVEL:
372 case QUEST_TYPE_RANDOM:
374 /* Only count valid monsters */
375 if (q_ptr->r_idx != m_ptr->r_idx)
380 if (q_ptr->cur_num >= q_ptr->max_num)
382 complete_quest(quest_num);
384 if (!(q_ptr->flags & QUEST_FLAG_PRESET))
386 create_stairs = TRUE;
387 p_ptr->inside_quest = 0;
390 /* Finish the two main quests without rewarding */
391 if ((quest_num == QUEST_OBERON) || (quest_num == QUEST_SERPENT))
393 q_ptr->status = QUEST_STATUS_FINISHED;
396 if (q_ptr->type == QUEST_TYPE_RANDOM)
399 q_ptr->status = QUEST_STATUS_FINISHED;
404 case QUEST_TYPE_KILL_ANY_LEVEL:
407 if (q_ptr->cur_num >= q_ptr->max_num)
409 complete_quest(quest_num);
414 case QUEST_TYPE_TOWER:
416 if (!is_hostile(m_ptr)) break;
418 if (count_all_hostile_monsters() == 1)
420 q_ptr->status = QUEST_STATUS_STAGE_COMPLETED;
422 if((quest[QUEST_TOWER1].status == QUEST_STATUS_STAGE_COMPLETED) &&
423 (quest[QUEST_TOWER2].status == QUEST_STATUS_STAGE_COMPLETED) &&
424 (quest[QUEST_TOWER3].status == QUEST_STATUS_STAGE_COMPLETED))
427 complete_quest(QUEST_TOWER1);
435 /* Create a magical staircase */
441 while (cave_perma_bold(y, x) || cave[y][x].o_idx || (cave[y][x].info & CAVE_OBJECT) )
443 /* Pick a location */
444 scatter(&ny, &nx, y, x, 1, 0);
450 /* Explain the staircase */
451 msg_print(_("魔法の階段が現れた...", "A magical staircase appears..."));
453 /* Create stairs down */
454 cave_set_feat(y, x, feat_down_stair);
456 /* Remember to update everything */
457 p_ptr->update |= (PU_FLOW);
467 for (i = 0; i < (dun_level / 15)+1; i++)
472 /* Make a great object */
473 make_object(o_ptr, AM_GOOD | AM_GREAT);
475 /* Drop it in the dungeon */
476 (void)drop_near(o_ptr, -1, y, x);
482 * @brief 特定のアーティファクトを入手した際のクエスト達成処理 /
483 * Check for "Quest" completion when a quest monster is killed or charmed.
484 * @param o_ptr 入手したオブジェクトの構造体参照ポインタ
487 void check_find_art_quest_completion(object_type *o_ptr)
490 /* Check if completed a quest */
491 for (i = 0; i < max_q_idx; i++)
493 if((quest[i].type == QUEST_TYPE_FIND_ARTIFACT) &&
494 (quest[i].status == QUEST_STATUS_TAKEN) &&
495 (quest[i].k_idx == o_ptr->name1))
504 * @brief モンスターを撃破した際の述語メッセージを返す /
505 * Return monster death string
506 * @param r_ptr 撃破されたモンスターの種族情報を持つ構造体の参照ポインタ
507 * @return 撃破されたモンスターの述語
509 cptr extract_note_dies(MONRACE_IDX r_idx)
511 monster_race *r_ptr = &r_info[r_idx];
512 /* Some monsters get "destroyed" */
513 if (!monster_living(r_idx))
517 for (i = 0; i < 4; i++)
519 if (r_ptr->blow[i].method == RBM_EXPLODE)
521 return _("は爆発して粉々になった。", " explodes into tiny shreds.");
524 return _("を倒した。", " is destroyed.");
527 /* Assume a default death */
528 return _("は死んだ。", " dies.");
533 * @brief モンスターが死亡した時の処理 /
534 * Handle the "death" of a monster.
535 * @param m_idx 死亡したモンスターのID
536 * @param drop_item TRUEならばモンスターのドロップ処理を行う
537 * @return 撃破されたモンスターの述語
540 * Disperse treasures centered at the monster location based on the
541 * various flags contained in the monster flags fields.
542 * Check for "Quest" completion when a quest monster is killed.
543 * Note that only the player can induce "monster_death()" on Uniques.
544 * Thus (for now) all Quest monsters should be Uniques.
545 * Note that monsters can now carry objects, and when a monster dies,
546 * it drops all of its objects, which may disappear in crowded rooms.
549 void monster_death(MONSTER_IDX m_idx, bool drop_item)
558 monster_type *m_ptr = &m_list[m_idx];
559 monster_race *r_ptr = &r_info[m_ptr->r_idx];
561 bool visible = ((m_ptr->ml && !p_ptr->image) || (r_ptr->flags1 & RF1_UNIQUE));
565 bool do_gold = (!(r_ptr->flags1 & RF1_ONLY_ITEM));
566 bool do_item = (!(r_ptr->flags1 & RF1_ONLY_GOLD));
567 bool cloned = (m_ptr->smart & SM_CLONED) ? TRUE : FALSE;
568 int force_coin = get_coin_type(m_ptr->r_idx);
573 bool drop_chosen_item = drop_item && !cloned && !p_ptr->inside_arena
574 && !p_ptr->inside_battle && !is_pet(m_ptr);
576 /* The caster is dead? */
577 if (world_monster && world_monster == m_idx) world_monster = 0;
579 /* Notice changes in view */
580 if (r_ptr->flags7 & (RF7_LITE_MASK | RF7_DARK_MASK))
582 /* Update some things */
583 p_ptr->update |= (PU_MON_LITE);
589 if (record_named_pet && is_pet(m_ptr) && m_ptr->nickname)
593 monster_desc(m_name, m_ptr, MD_INDEF_VISIBLE);
594 do_cmd_write_nikki(NIKKI_NAMED_PET, 3, m_name);
597 /* Let monsters explode! */
598 for (i = 0; i < 4; i++)
600 if (r_ptr->blow[i].method == RBM_EXPLODE)
602 BIT_FLAGS flg = PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL;
603 EFFECT_ID typ = mbe_info[r_ptr->blow[i].effect].explode_type;
604 DICE_NUMBER d_dice = r_ptr->blow[i].d_dice;
605 DICE_SID d_side = r_ptr->blow[i].d_side;
606 HIT_POINT damage = damroll(d_dice, d_side);
608 project(m_idx, 3, y, x, damage, typ, flg, -1);
613 if (m_ptr->mflag2 & MFLAG2_CHAMELEON)
615 choose_new_monster(m_idx, TRUE, MON_CHAMELEON);
616 r_ptr = &r_info[m_ptr->r_idx];
619 /* Check for quest completion */
620 check_quest_completion(m_ptr);
622 /* Handle the possibility of player vanquishing arena combatant -KMW- */
623 if (p_ptr->inside_arena && !is_pet(m_ptr))
625 p_ptr->exit_bldg = TRUE;
627 if (p_ptr->arena_number > MAX_ARENA_MONS)
629 msg_print(_("素晴らしい!君こそ真の勝利者だ。", "You are a Genuine Champion!"));
633 msg_print(_("勝利!チャンピオンへの道を進んでいる。", "Victorious! You're on your way to becoming Champion."));
636 if (arena_info[p_ptr->arena_number].tval)
640 /* Prepare to make a prize */
641 object_prep(q_ptr, lookup_kind(arena_info[p_ptr->arena_number].tval, arena_info[p_ptr->arena_number].sval));
642 apply_magic(q_ptr, object_level, AM_NO_FIXED_ART);
644 /* Drop it in the dungeon */
645 (void)drop_near(q_ptr, -1, y, x);
648 if (p_ptr->arena_number > MAX_ARENA_MONS) p_ptr->arena_number++;
649 p_ptr->arena_number++;
654 /* Extract monster name */
655 monster_desc(m_name, m_ptr, MD_IGNORE_HALLU | MD_ASSUME_VISIBLE | MD_INDEF_VISIBLE);
657 do_cmd_write_nikki(NIKKI_ARENA, p_ptr->arena_number, m_name);
661 if (m_idx == p_ptr->riding)
663 if (rakuba(-1, FALSE))
665 msg_print(_("地面に落とされた。", "You have fallen from your riding pet."));
669 /* Drop a dead corpse? */
670 if (one_in_(r_ptr->flags1 & RF1_UNIQUE ? 1 : 4) &&
671 (r_ptr->flags9 & (RF9_DROP_CORPSE | RF9_DROP_SKELETON)) &&
672 !(p_ptr->inside_arena || p_ptr->inside_battle || cloned || ((m_ptr->r_idx == today_mon) && is_pet(m_ptr))))
674 /* Assume skeleton */
678 * We cannot drop a skeleton? Note, if we are in this check,
679 * we *know* we can drop at least a corpse or a skeleton
681 if (!(r_ptr->flags9 & RF9_DROP_SKELETON))
683 else if ((r_ptr->flags9 & RF9_DROP_CORPSE) && (r_ptr->flags1 & RF1_UNIQUE))
686 /* Else, a corpse is more likely unless we did a "lot" of damage */
687 else if (r_ptr->flags9 & RF9_DROP_CORPSE)
689 /* Lots of damage in one blow */
690 if ((0 - ((m_ptr->maxhp) / 4)) > m_ptr->hp)
692 if (one_in_(5)) corpse = TRUE;
696 if (!one_in_(5)) corpse = TRUE;
701 /* Prepare to make an object */
702 object_prep(q_ptr, lookup_kind(TV_CORPSE, (corpse ? SV_CORPSE : SV_SKELETON)));
704 apply_magic(q_ptr, object_level, AM_NO_FIXED_ART);
706 q_ptr->pval = m_ptr->r_idx;
708 /* Drop it in the dungeon */
709 (void)drop_near(q_ptr, -1, y, x);
712 /* Drop objects being carried */
713 monster_drop_carried_objects(m_ptr);
715 if (r_ptr->flags1 & RF1_DROP_GOOD) mo_mode |= AM_GOOD;
716 if (r_ptr->flags1 & RF1_DROP_GREAT) mo_mode |= AM_GREAT;
718 switch (m_ptr->r_idx)
720 case MON_PINK_HORROR:
721 /* Pink horrors are replaced with 2 Blue horrors */
722 if (!(p_ptr->inside_arena || p_ptr->inside_battle))
726 for (i = 0; i < 2; i++)
728 POSITION wy = y, wx = x;
729 bool pet = is_pet(m_ptr);
732 if (pet) mode |= PM_FORCE_PET;
734 if (summon_specific((pet ? -1 : m_idx), wy, wx, 100, SUMMON_BLUE_HORROR, mode))
736 if (player_can_see_bold(wy, wx)) notice = TRUE;
740 if (notice) msg_print(_("ピンク・ホラーは分裂した!", "The Pink horror divides!"));
744 case MON_BLOODLETTER:
745 /* Bloodletters of Khorne may drop a blade of chaos */
746 if (drop_chosen_item && (randint1(100) < 15))
750 /* Prepare to make a Blade of Chaos */
751 object_prep(q_ptr, lookup_kind(TV_SWORD, SV_BLADE_OF_CHAOS));
753 apply_magic(q_ptr, object_level, AM_NO_FIXED_ART | mo_mode);
755 /* Drop it in the dungeon */
756 (void)drop_near(q_ptr, -1, y, x);
761 if (drop_chosen_item && (dun_level > 9))
766 /* Activate restriction */
767 if ((dun_level > 49) && one_in_(5))
768 get_obj_num_hook = kind_is_good_book;
770 get_obj_num_hook = kind_is_book;
773 make_object(q_ptr, mo_mode);
775 /* Drop it in the dungeon */
776 (void)drop_near(q_ptr, -1, y, x);
782 * Mega^3-hack: killing a 'Warrior of the Dawn' is likely to
783 * spawn another in the fallen one's place!
785 if (!p_ptr->inside_arena && !p_ptr->inside_battle)
789 POSITION wy = y, wx = x;
791 bool pet = is_pet(m_ptr);
795 scatter(&wy, &wx, y, x, 20, 0);
797 while (!(in_bounds(wy, wx) && cave_empty_bold2(wy, wx)) && --attempts);
802 if (pet) mode |= PM_FORCE_PET;
804 if (summon_specific((pet ? -1 : m_idx), wy, wx, 100, SUMMON_DAWN, mode))
806 if (player_can_see_bold(wy, wx))
807 msg_print(_("新たな戦士が現れた!", "A new warrior steps forth!"));
815 /* One more ultra-hack: An Unmaker goes out with a big bang! */
817 BIT_FLAGS flg = PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL;
818 (void)project(m_idx, 6, y, x, 100, GF_CHAOS, flg, -1);
822 case MON_UNICORN_ORD:
825 /* Reward for "lazy" player */
826 if (p_ptr->pseikaku == SEIKAKU_NAMAKE)
828 ARTIFACT_IDX a_idx = 0;
829 artifact_type *a_ptr = NULL;
831 if (!drop_chosen_item) break;
838 a_idx = ART_NAMAKE_HAMMER;
841 a_idx = ART_NAMAKE_BOW;
844 a_idx = ART_NAMAKE_ARMOR;
848 a_ptr = &a_info[a_idx];
850 while (a_ptr->cur_num);
852 /* Create the artifact */
853 if (create_named_art(a_idx, y, x))
857 /* Hack -- Memorize location of artifact in saved floors */
858 if (character_dungeon) a_ptr->floor_id = p_ptr->floor_id;
860 else if (!preserve_mode) a_ptr->cur_num = 1;
865 if (!drop_chosen_item) break;
868 /* Mega-Hack -- Prepare to make "Grond" */
869 object_prep(q_ptr, lookup_kind(TV_HAFTED, SV_GROND));
871 /* Mega-Hack -- Mark this item as "Grond" */
872 q_ptr->name1 = ART_GROND;
874 /* Mega-Hack -- Actually create "Grond" */
875 apply_magic(q_ptr, -1, AM_GOOD | AM_GREAT);
877 /* Drop it in the dungeon */
878 (void)drop_near(q_ptr, -1, y, x);
881 /* Mega-Hack -- Prepare to make "Chaos" */
882 object_prep(q_ptr, lookup_kind(TV_CROWN, SV_CHAOS));
884 /* Mega-Hack -- Mark this item as "Chaos" */
885 q_ptr->name1 = ART_CHAOS;
887 /* Mega-Hack -- Actually create "Chaos" */
888 apply_magic(q_ptr, -1, AM_GOOD | AM_GREAT);
890 /* Drop it in the dungeon */
891 (void)drop_near(q_ptr, -1, y, x);
894 case MON_B_DEATH_SWORD:
895 if (drop_chosen_item)
899 /* Prepare to make a broken sword */
900 object_prep(q_ptr, lookup_kind(TV_SWORD, randint1(2)));
902 /* Drop it in the dungeon */
903 (void)drop_near(q_ptr, -1, y, x);
909 if (drop_chosen_item && ((m_ptr->r_idx == MON_A_GOLD) ||
910 ((m_ptr->r_idx == MON_A_SILVER) && (r_ptr->r_akills % 5 == 0))))
914 /* Prepare to make a Can of Toys */
915 object_prep(q_ptr, lookup_kind(TV_CHEST, SV_CHEST_KANDUME));
917 apply_magic(q_ptr, object_level, AM_NO_FIXED_ART);
919 /* Drop it in the dungeon */
920 (void)drop_near(q_ptr, -1, y, x);
926 BIT_FLAGS flg = PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL;
927 (void)project(m_idx, 3, y, x, damroll(20, 10), GF_FIRE, flg, -1);
932 if (!drop_chosen_item) break;
934 switch (r_ptr->d_char)
942 /* Activate restriction */
943 get_obj_num_hook = kind_is_cloak;
946 make_object(q_ptr, mo_mode);
948 /* Drop it in the dungeon */
949 (void)drop_near(q_ptr, -1, y, x);
959 /* Activate restriction */
960 get_obj_num_hook = kind_is_polearm;
962 /* Make a poleweapon */
963 make_object(q_ptr, mo_mode);
965 /* Drop it in the dungeon */
966 (void)drop_near(q_ptr, -1, y, x);
976 /* Activate restriction */
977 get_obj_num_hook = kind_is_armor;
979 /* Make a hard armor */
980 make_object(q_ptr, mo_mode);
982 /* Drop it in the dungeon */
983 (void)drop_near(q_ptr, -1, y, x);
993 /* Activate restriction */
994 get_obj_num_hook = kind_is_hafted;
996 /* Make a hafted weapon */
997 make_object(q_ptr, mo_mode);
999 /* Drop it in the dungeon */
1000 (void)drop_near(q_ptr, -1, y, x);
1005 if (m_ptr->r_idx != MON_STORMBRINGER)
1010 /* Activate restriction */
1011 get_obj_num_hook = kind_is_sword;
1014 make_object(q_ptr, mo_mode);
1016 /* Drop it in the dungeon */
1017 (void)drop_near(q_ptr, -1, y, x);
1024 /* Mega-Hack -- drop fixed items */
1025 if (drop_chosen_item)
1027 ARTIFACT_IDX a_idx = 0;
1030 for(i = 0; i < 4; i++)
1032 if(!r_ptr->artifact_id[i]) break;
1033 a_idx = r_ptr->artifact_id[i];
1034 chance = r_ptr->artifact_percent[i];
1037 if ((a_idx > 0) && ((randint0(100) < chance) || p_ptr->wizard))
1039 artifact_type *a_ptr = &a_info[a_idx];
1041 if (!a_ptr->cur_num)
1043 /* Create the artifact */
1044 if (create_named_art(a_idx, y, x))
1048 /* Hack -- Memorize location of artifact in saved floors */
1049 if (character_dungeon) a_ptr->floor_id = p_ptr->floor_id;
1051 else if (!preserve_mode) a_ptr->cur_num = 1;
1055 if ((r_ptr->flags7 & RF7_GUARDIAN) && (d_info[dungeon_type].final_guardian == m_ptr->r_idx))
1057 KIND_OBJECT_IDX k_idx = d_info[dungeon_type].final_object ? d_info[dungeon_type].final_object
1058 : lookup_kind(TV_SCROLL, SV_SCROLL_ACQUIREMENT);
1060 if (d_info[dungeon_type].final_artifact)
1062 a_idx = d_info[dungeon_type].final_artifact;
1063 artifact_type *a_ptr = &a_info[a_idx];
1065 if (!a_ptr->cur_num)
1067 /* Create the artifact */
1068 if (create_named_art(a_idx, y, x))
1072 /* Hack -- Memorize location of artifact in saved floors */
1073 if (character_dungeon) a_ptr->floor_id = p_ptr->floor_id;
1075 else if (!preserve_mode) a_ptr->cur_num = 1;
1077 /* Prevent rewarding both artifact and "default" object */
1078 if (!d_info[dungeon_type].final_object) k_idx = 0;
1086 /* Prepare to make a reward */
1087 object_prep(q_ptr, k_idx);
1089 apply_magic(q_ptr, object_level, AM_NO_FIXED_ART | AM_GOOD);
1091 /* Drop it in the dungeon */
1092 (void)drop_near(q_ptr, -1, y, x);
1094 msg_format(_("あなたは%sを制覇した!", "You have conquered %s!"),d_name+d_info[dungeon_type].name);
1098 /* Determine how much we can drop */
1099 if ((r_ptr->flags1 & RF1_DROP_60) && (randint0(100) < 60)) number++;
1100 if ((r_ptr->flags1 & RF1_DROP_90) && (randint0(100) < 90)) number++;
1101 if (r_ptr->flags1 & RF1_DROP_1D2) number += damroll(1, 2);
1102 if (r_ptr->flags1 & RF1_DROP_2D2) number += damroll(2, 2);
1103 if (r_ptr->flags1 & RF1_DROP_3D2) number += damroll(3, 2);
1104 if (r_ptr->flags1 & RF1_DROP_4D2) number += damroll(4, 2);
1106 if (cloned && !(r_ptr->flags1 & RF1_UNIQUE))
1107 number = 0; /* Clones drop no stuff unless Cloning Pits */
1109 if (is_pet(m_ptr) || p_ptr->inside_battle || p_ptr->inside_arena)
1110 number = 0; /* Pets drop no stuff */
1111 if (!drop_item && (r_ptr->d_char != '$')) number = 0;
1113 if((r_ptr->flags2 & (RF2_MULTIPLY)) && (r_ptr->r_akills > 1024))
1114 number = 0; /* Limit of Multiply monster drop */
1116 /* Hack -- handle creeping coins */
1117 coin_type = force_coin;
1119 /* Average dungeon and monster levels */
1120 object_level = (dun_level + r_ptr->level) / 2;
1122 /* Drop some objects */
1123 for (j = 0; j < number; j++)
1129 if (do_gold && (!do_item || (randint0(100) < 50)))
1131 /* Make some gold */
1132 if (!make_gold(q_ptr)) continue;
1140 /* Make an object */
1141 if (!make_object(q_ptr, mo_mode)) continue;
1146 /* Drop it in the dungeon */
1147 (void)drop_near(q_ptr, -1, y, x);
1150 /* Reset the object level */
1151 object_level = base_level;
1153 /* Reset "coin" type */
1157 /* Take note of any dropped treasure */
1158 if (visible && (dump_item || dump_gold))
1160 /* Take notes on treasure */
1161 lore_treasure(m_idx, dump_item, dump_gold);
1164 /* Only process "Quest Monsters" */
1165 if (!(r_ptr->flags1 & RF1_QUESTOR)) return;
1166 if (p_ptr->inside_battle) return;
1169 if ((m_ptr->r_idx == MON_SERPENT) && !cloned)
1172 p_ptr->total_winner = TRUE;
1174 /* Redraw the "title" */
1175 p_ptr->redraw |= (PR_TITLE);
1177 play_music(TERM_XTRA_MUSIC_BASIC, MUSIC_BASIC_FINAL_QUEST_CLEAR);
1179 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, _("見事に変愚蛮怒の勝利者となった!", "become *WINNER* of Hengband finely!"));
1181 if ((p_ptr->pclass == CLASS_CHAOS_WARRIOR) || (p_ptr->muta2 & MUT2_CHAOS_GIFT))
1183 msg_format(_("%sからの声が響いた。", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
1184 msg_print(_("『よくやった、定命の者よ!』", "'Thou art donst well, mortal!'"));
1187 /* Congratulations */
1188 msg_print(_("*** おめでとう ***", "*** CONGRATULATIONS ***"));
1189 msg_print(_("あなたはゲームをコンプリートしました。", "You have won the game!"));
1190 msg_print(_("準備が整ったら引退(自殺コマンド)しても結構です。", "You may retire (commit suicide) when you are ready."));
1195 * @brief モンスターに与えたダメージの修正処理 /
1196 * Modify the physical damage done to the monster.
1197 * @param m_ptr ダメージを受けるモンスターの構造体参照ポインタ
1198 * @param dam ダメージ基本値
1199 * @param is_psy_spear 攻撃手段が光の剣ならばTRUE
1200 * @return 修正を行った結果のダメージ量
1203 * (for example when it's invulnerable or shielded)
1204 * ToDo: Accept a damage-type to calculate the modified damage from
1205 * things like fire, frost, lightning, poison, ... attacks.
1206 * "type" is not yet used and should be 0.
1209 HIT_POINT mon_damage_mod(monster_type *m_ptr, HIT_POINT dam, bool is_psy_spear)
1211 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1213 if ((r_ptr->flagsr & RFR_RES_ALL) && dam > 0)
1216 if ((dam == 0) && one_in_(3)) dam = 1;
1219 if (MON_INVULNER(m_ptr))
1223 if (!p_ptr->blind && is_seen(m_ptr))
1225 msg_print(_("バリアを切り裂いた!", "The barrier is penetrated!"));
1228 else if (!one_in_(PENETRATE_INVULNERABILITY))
1238 * @brief モンスターに与えたダメージを元に経験値を加算する /
1239 * Calculate experience point to be get
1240 * @param dam 与えたダメージ量
1241 * @param m_ptr ダメージを与えたモンスターの構造体参照ポインタ
1245 * Even the 64 bit operation is not big enough to avoid overflaw
1246 * unless we carefully choose orders of multiplication and division.
1247 * Get the coefficient first, and multiply (potentially huge) base
1248 * experience point of a monster later.
1251 static void get_exp_from_mon(HIT_POINT dam, monster_type *m_ptr)
1253 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1260 if (!m_ptr->r_idx) return;
1261 if (is_pet(m_ptr) || p_ptr->inside_battle) return;
1264 * - Ratio of monster's level to player's level effects
1265 * - Varying speed effects
1266 * - Get a fraction in proportion of damage point
1268 new_exp = r_ptr->level * SPEED_TO_ENERGY(m_ptr->mspeed) * dam;
1271 div_l = (p_ptr->max_plv+2) * SPEED_TO_ENERGY(r_ptr->speed);
1273 /* Use (average maxhp * 2) as a denominator */
1274 if (!(r_ptr->flags1 & RF1_FORCE_MAXHP))
1275 s64b_mul(&div_h, &div_l, 0, r_ptr->hdice * (ironman_nightmare ? 2 : 1) * (r_ptr->hside + 1));
1277 s64b_mul(&div_h, &div_l, 0, r_ptr->hdice * (ironman_nightmare ? 2 : 1) * r_ptr->hside * 2);
1279 /* Special penalty in the wilderness */
1280 if (!dun_level && (!(r_ptr->flags8 & RF8_WILD_ONLY) || !(r_ptr->flags1 & RF1_UNIQUE)))
1281 s64b_mul(&div_h, &div_l, 0, 5);
1283 /* Do division first to prevent overflaw */
1284 s64b_div(&new_exp, &new_exp_frac, div_h, div_l);
1286 /* Special penalty for mutiply-monster */
1287 if ((r_ptr->flags2 & RF2_MULTIPLY) || (m_ptr->r_idx == MON_DAWN))
1289 int monnum_penarty = r_ptr->r_akills / 400;
1290 if (monnum_penarty > 8) monnum_penarty = 8;
1292 while (monnum_penarty--)
1295 s64b_RSHIFT(new_exp, new_exp_frac, 2);
1299 /* Special penalty for rest_and_shoot exp scum */
1300 if ((m_ptr->dealt_damage > m_ptr->max_maxhp) && (m_ptr->hp >= 0))
1302 int over_damage = m_ptr->dealt_damage / m_ptr->max_maxhp;
1303 if (over_damage > 32) over_damage = 32;
1305 while (over_damage--)
1308 s64b_mul(&new_exp, &new_exp_frac, 0, 9);
1309 s64b_div(&new_exp, &new_exp_frac, 0, 10);
1313 /* Finally multiply base experience point of the monster */
1314 s64b_mul(&new_exp, &new_exp_frac, 0, r_ptr->mexp);
1316 /* Gain experience */
1317 gain_exp_64(new_exp, new_exp_frac);
1322 * @brief モンスターのHPをダメージに応じて減算する /
1323 * Decreases monsters hit points, handling monster death.
1324 * @param dam 与えたダメージ量
1325 * @param m_idx ダメージを与えたモンスターのID
1326 * @param fear ダメージによってモンスターが恐慌状態に陥ったならばTRUEを返す
1327 * @param note モンスターが倒された際の特別なメッセージ述語
1331 * We return TRUE if the monster has been killed (and deleted).
1332 * We announce monster death (using an optional "death message"
1333 * if given, and a otherwise a generic killed/destroyed message).
1334 * Only "physical attacks" can induce the "You have slain" message.
1335 * Missile and Spell attacks will induce the "dies" message, or
1336 * various "specialized" messages. Note that "You have destroyed"
1337 * and "is destroyed" are synonyms for "You have slain" and "dies".
1338 * Hack -- unseen monsters yield "You have killed it." message.
1339 * Added fear (DGK) and check whether to print fear messages -CWS
1340 * Made name, sex, and capitalization generic -BEN-
1341 * As always, the "ghost" processing is a total hack.
1342 * Hack -- we "delay" fear messages by passing around a "fear" flag.
1343 * Consider decreasing monster experience over time, say,
1344 * by using "(m_exp * m_lev * (m_lev)) / (p_lev * (m_lev + n_killed))"
1345 * instead of simply "(m_exp * m_lev) / (p_lev)", to make the first
1346 * monster worth more than subsequent monsters. This would also need
1347 * to induce changes in the monster recall code.
1350 bool mon_take_hit(MONSTER_IDX m_idx, HIT_POINT dam, bool *fear, cptr note)
1352 monster_type *m_ptr = &m_list[m_idx];
1353 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1354 monster_type exp_mon;
1356 /* Innocent until proven otherwise */
1357 bool innocent = TRUE, thief = FALSE;
1361 (void)COPY(&exp_mon, m_ptr, monster_type);
1363 expdam = (m_ptr->hp > dam) ? dam : m_ptr->hp;
1365 get_exp_from_mon(expdam, &exp_mon);
1367 /* Genocided by chaos patron */
1368 if (!m_ptr->r_idx) m_idx = 0;
1370 /* Redraw (later) if needed */
1371 if (p_ptr->health_who == m_idx) p_ptr->redraw |= (PR_HEALTH);
1372 if (p_ptr->riding == m_idx) p_ptr->redraw |= (PR_UHEALTH);
1374 (void)set_monster_csleep(m_idx, 0);
1376 /* Hack - Cancel any special player stealth magics. -LM- */
1377 if (p_ptr->special_defense & NINJA_S_STEALTH)
1379 set_superstealth(FALSE);
1382 /* Genocided by chaos patron */
1383 if (!m_idx) return TRUE;
1386 m_ptr->dealt_damage += dam;
1388 if(m_ptr->dealt_damage > m_ptr->max_maxhp * 100) m_ptr->dealt_damage = m_ptr->max_maxhp * 100;
1392 msg_format( _("合計%d/%dのダメージを与えた。","You do %d (out of %d) damage."), m_ptr->dealt_damage, m_ptr->maxhp);
1395 /* It is dead now */
1400 if (r_info[m_ptr->r_idx].flags7 & RF7_TANUKI)
1402 /* You might have unmasked Tanuki first time */
1403 r_ptr = &r_info[m_ptr->r_idx];
1404 m_ptr->ap_r_idx = m_ptr->r_idx;
1405 if (r_ptr->r_sights < MAX_SHORT) r_ptr->r_sights++;
1408 if (m_ptr->mflag2 & MFLAG2_CHAMELEON)
1410 /* You might have unmasked Chameleon first time */
1411 r_ptr = real_r_ptr(m_ptr);
1412 if (r_ptr->r_sights < MAX_SHORT) r_ptr->r_sights++;
1415 if (!(m_ptr->smart & SM_CLONED))
1417 /* When the player kills a Unique, it stays dead */
1418 if (r_ptr->flags1 & RF1_UNIQUE)
1422 /* Mega-Hack -- Banor & Lupart */
1423 if ((m_ptr->r_idx == MON_BANOR) || (m_ptr->r_idx == MON_LUPART))
1425 r_info[MON_BANORLUPART].max_num = 0;
1426 r_info[MON_BANORLUPART].r_pkills++;
1427 r_info[MON_BANORLUPART].r_akills++;
1428 if (r_info[MON_BANORLUPART].r_tkills < MAX_SHORT) r_info[MON_BANORLUPART].r_tkills++;
1430 else if (m_ptr->r_idx == MON_BANORLUPART)
1432 r_info[MON_BANOR].max_num = 0;
1433 r_info[MON_BANOR].r_pkills++;
1434 r_info[MON_BANOR].r_akills++;
1435 if (r_info[MON_BANOR].r_tkills < MAX_SHORT) r_info[MON_BANOR].r_tkills++;
1436 r_info[MON_LUPART].max_num = 0;
1437 r_info[MON_LUPART].r_pkills++;
1438 r_info[MON_LUPART].r_akills++;
1439 if (r_info[MON_LUPART].r_tkills < MAX_SHORT) r_info[MON_LUPART].r_tkills++;
1443 /* When the player kills a Nazgul, it stays dead */
1444 else if (r_ptr->flags7 & RF7_NAZGUL) r_ptr->max_num--;
1447 /* Count all monsters killed */
1448 if (r_ptr->r_akills < MAX_SHORT) r_ptr->r_akills++;
1450 /* Recall even invisible uniques or winners */
1451 if ((m_ptr->ml && !p_ptr->image) || (r_ptr->flags1 & RF1_UNIQUE))
1453 /* Count kills this life */
1454 if ((m_ptr->mflag2 & MFLAG2_KAGE) && (r_info[MON_KAGE].r_pkills < MAX_SHORT)) r_info[MON_KAGE].r_pkills++;
1455 else if (r_ptr->r_pkills < MAX_SHORT) r_ptr->r_pkills++;
1457 /* Count kills in all lives */
1458 if ((m_ptr->mflag2 & MFLAG2_KAGE) && (r_info[MON_KAGE].r_tkills < MAX_SHORT)) r_info[MON_KAGE].r_tkills++;
1459 else if (r_ptr->r_tkills < MAX_SHORT) r_ptr->r_tkills++;
1461 /* Hack -- Auto-recall */
1462 monster_race_track(m_ptr->ap_r_idx);
1465 /* Extract monster name */
1466 monster_desc(m_name, m_ptr, MD_TRUE_NAME);
1468 /* Don't kill Amberites */
1469 if ((r_ptr->flags3 & RF3_AMBERITE) && one_in_(2))
1471 int curses = 1 + randint1(3);
1472 bool stop_ty = FALSE;
1475 msg_format(_("%^sは恐ろしい血の呪いをあなたにかけた!", "%^s puts a terrible blood curse on you!"), m_name);
1476 curse_equipment(100, 50);
1480 stop_ty = activate_ty_curse(stop_ty, &count);
1485 if (r_ptr->flags2 & RF2_CAN_SPEAK)
1487 char line_got[1024];
1488 if (!get_rnd_line(_("mondeath_j.txt", "mondeath.txt"), m_ptr->r_idx, line_got))
1490 msg_format("%^s %s", m_name, line_got);
1494 if (m_ptr->r_idx == MON_SERPENT)
1496 screen_dump = make_screen_dump();
1501 if (!(d_info[dungeon_type].flags1 & DF1_BEGINNER))
1503 if (!dun_level && !ambush_flag && !p_ptr->inside_arena)
1505 chg_virtue(V_VALOUR, -1);
1507 else if (r_ptr->level > dun_level)
1509 if (randint1(10) <= (r_ptr->level - dun_level))
1510 chg_virtue(V_VALOUR, 1);
1512 if (r_ptr->level > 60)
1514 chg_virtue(V_VALOUR, 1);
1516 if (r_ptr->level >= 2 * (p_ptr->lev+1))
1517 chg_virtue(V_VALOUR, 2);
1520 if (r_ptr->flags1 & RF1_UNIQUE)
1522 if (r_ptr->flags3 & (RF3_EVIL | RF3_GOOD)) chg_virtue(V_HARMONY, 2);
1524 if (r_ptr->flags3 & RF3_GOOD)
1526 chg_virtue(V_UNLIFE, 2);
1527 chg_virtue(V_VITALITY, -2);
1530 if (one_in_(3)) chg_virtue(V_INDIVIDUALISM, -1);
1533 if (m_ptr->r_idx == MON_BEGGAR || m_ptr->r_idx == MON_LEPER)
1535 chg_virtue(V_COMPASSION, -1);
1538 if ((r_ptr->flags3 & RF3_GOOD) && ((r_ptr->level) / 10 + (3 * dun_level) >= randint1(100)))
1539 chg_virtue(V_UNLIFE, 1);
1541 if (r_ptr->d_char == 'A')
1543 if (r_ptr->flags1 & RF1_UNIQUE)
1544 chg_virtue(V_FAITH, -2);
1545 else if ((r_ptr->level) / 10 + (3 * dun_level) >= randint1(100))
1547 if (r_ptr->flags3 & RF3_GOOD) chg_virtue(V_FAITH, -1);
1548 else chg_virtue(V_FAITH, 1);
1551 else if (r_ptr->flags3 & RF3_DEMON)
1553 if (r_ptr->flags1 & RF1_UNIQUE)
1554 chg_virtue(V_FAITH, 2);
1555 else if ((r_ptr->level) / 10 + (3 * dun_level) >= randint1(100))
1556 chg_virtue(V_FAITH, 1);
1559 if ((r_ptr->flags3 & RF3_UNDEAD) && (r_ptr->flags1 & RF1_UNIQUE))
1560 chg_virtue(V_VITALITY, 2);
1562 if (r_ptr->r_deaths)
1564 if (r_ptr->flags1 & RF1_UNIQUE)
1566 chg_virtue(V_HONOUR, 10);
1568 else if ((r_ptr->level) / 10 + (2 * dun_level) >= randint1(100))
1570 chg_virtue(V_HONOUR, 1);
1573 if ((r_ptr->flags2 & RF2_MULTIPLY) && (r_ptr->r_akills > 1000) && one_in_(10))
1575 chg_virtue(V_VALOUR, -1);
1578 for (i = 0; i < 4; i++)
1580 if (r_ptr->blow[i].d_dice != 0) innocent = FALSE; /* Murderer! */
1582 if ((r_ptr->blow[i].effect == RBE_EAT_ITEM)
1583 || (r_ptr->blow[i].effect == RBE_EAT_GOLD))
1585 thief = TRUE; /* Thief! */
1588 /* The new law says it is illegal to live in the dungeon */
1589 if (r_ptr->level != 0) innocent = FALSE;
1593 if (r_ptr->flags1 & RF1_UNIQUE)
1594 chg_virtue(V_JUSTICE, 3);
1595 else if (1+((r_ptr->level) / 10 + (2 * dun_level)) >= randint1(100))
1596 chg_virtue(V_JUSTICE, 1);
1600 chg_virtue (V_JUSTICE, -1);
1603 if ((r_ptr->flags3 & RF3_ANIMAL) && !(r_ptr->flags3 & RF3_EVIL) && !(r_ptr->flags4 & ~(RF4_NOMAGIC_MASK)) && !(r_ptr->a_ability_flags1 & ~(RF5_NOMAGIC_MASK)) && !(r_ptr->a_ability_flags2 & ~(RF6_NOMAGIC_MASK)))
1605 if (one_in_(4)) chg_virtue(V_NATURE, -1);
1608 if ((r_ptr->flags1 & RF1_UNIQUE) && record_destroy_uniq)
1611 sprintf(note_buf, "%s%s", r_name + r_ptr->name, (m_ptr->smart & SM_CLONED) ? _("(クローン)", "(Clone)") : "");
1612 do_cmd_write_nikki(NIKKI_UNIQUE, 0, note_buf);
1618 /* Death by Missile/Spell attack */
1621 msg_format("%^s%s", m_name, note);
1624 /* Death by physical attack -- invisible monster */
1625 else if (!m_ptr->ml)
1628 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
1629 msg_format("せっかくだから%sを殺した。", m_name);
1631 msg_format("%sを殺した。", m_name);
1633 msg_format("You have killed %s.", m_name);
1638 /* Death by Physical attack -- non-living monster */
1639 else if (!monster_living(m_ptr->r_idx))
1641 bool explode = FALSE;
1643 for (i = 0; i < 4; i++)
1645 if (r_ptr->blow[i].method == RBM_EXPLODE) explode = TRUE;
1648 /* Special note at death */
1650 msg_format(_("%sは爆発して粉々になった。", "%^s explodes into tiny shreds."), m_name);
1654 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
1655 msg_format("せっかくだから%sを倒した。", m_name);
1657 msg_format("%sを倒した。", m_name);
1659 msg_format("You have destroyed %s.", m_name);
1664 /* Death by Physical attack -- living monster */
1668 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
1669 msg_format("せっかくだから%sを葬り去った。", m_name);
1671 msg_format("%sを葬り去った。", m_name);
1673 msg_format("You have slain %s.", m_name);
1677 if ((r_ptr->flags1 & RF1_UNIQUE) && !(m_ptr->smart & SM_CLONED) && !vanilla_town)
1679 for (i = 0; i < MAX_KUBI; i++)
1681 if ((kubi_r_idx[i] == m_ptr->r_idx) && !(m_ptr->mflag2 & MFLAG2_CHAMELEON))
1683 msg_format(_("%sの首には賞金がかかっている。", "There is a price on %s's head."), m_name);
1689 /* Generate treasure */
1690 monster_death(m_idx, TRUE);
1692 /* Mega hack : replace IKETA to BIKETAL */
1693 if ((m_ptr->r_idx == MON_IKETA) && !(p_ptr->inside_arena || p_ptr->inside_battle))
1695 POSITION dummy_y = m_ptr->fy;
1696 POSITION dummy_x = m_ptr->fx;
1697 BIT_FLAGS mode = 0L;
1698 if (is_pet(m_ptr)) mode |= PM_FORCE_PET;
1699 delete_monster_idx(m_idx);
1700 if (summon_named_creature(0, dummy_y, dummy_x, MON_BIKETAL, mode))
1702 msg_print(_("「ハァッハッハッハ!!私がバイケタルだ!!」", "Uwa-hahaha! *I* am Biketal!"));
1707 delete_monster_idx(m_idx);
1710 get_exp_from_mon((long)exp_mon.max_maxhp*2, &exp_mon);
1715 /* Monster is dead */
1722 /* Mega-Hack -- Pain cancels fear */
1723 if (MON_MONFEAR(m_ptr) && (dam > 0))
1726 if (set_monster_monfear(m_idx, MON_MONFEAR(m_ptr) - randint1(dam)))
1733 /* Sometimes a monster gets scared by damage */
1734 if (!MON_MONFEAR(m_ptr) && !(r_ptr->flags3 & (RF3_NO_FEAR)))
1736 /* Percentage of fully healthy */
1737 int percentage = (100L * m_ptr->hp) / m_ptr->maxhp;
1740 * Run (sometimes) if at 10% or less of max hit points,
1741 * or (usually) when hit for half its current hit points
1743 if ((randint1(10) >= percentage) || ((dam >= m_ptr->hp) && (randint0(100) < 80)))
1745 /* Hack -- note fear */
1748 /* Hack -- Add some timed fear */
1749 (void)set_monster_monfear(m_idx, (randint1(10) +
1750 (((dam >= m_ptr->hp) && (percentage > 7)) ?
1751 20 : ((11 - percentage) * 5))));
1763 * @brief 現在のコンソール表示の縦横を返す。 /
1764 * Get term size and calculate screen size
1765 * @param wid_p コンソールの表示幅文字数を返す
1766 * @param hgt_p コンソールの表示行数を返す
1769 void get_screen_size(TERM_LEN *wid_p, TERM_LEN *hgt_p)
1771 Term_get_size(wid_p, hgt_p);
1772 *hgt_p -= ROW_MAP + 2;
1773 *wid_p -= COL_MAP + 2;
1774 if (use_bigtile) *wid_p /= 2;
1779 * @brief コンソール上におけるマップ表示の左上位置を返す /
1780 * Calculates current boundaries Called below and from "do_cmd_locate()".
1783 void panel_bounds_center(void)
1787 get_screen_size(&wid, &hgt);
1789 panel_row_max = panel_row_min + hgt - 1;
1790 panel_row_prt = panel_row_min - 1;
1791 panel_col_max = panel_col_min + wid - 1;
1792 panel_col_prt = panel_col_min - 13;
1797 * @brief コンソールのリサイズに合わせてマップを再描画する /
1798 * Map resizing whenever the main term changes size
1801 void resize_map(void)
1803 /* Only if the dungeon exists */
1804 if (!character_dungeon) return;
1806 /* Mega-Hack -- no panel yet */
1810 /* Reset the panels */
1811 panel_row_min = cur_hgt;
1812 panel_col_min = cur_wid;
1816 p_ptr->update |= (PU_TORCH | PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
1817 p_ptr->update |= (PU_UN_VIEW | PU_UN_LITE);
1818 p_ptr->update |= (PU_VIEW | PU_LITE | PU_MON_LITE);
1819 p_ptr->update |= (PU_MONSTERS);
1821 p_ptr->redraw |= (PR_WIPE | PR_BASIC | PR_EXTRA | PR_MAP | PR_EQUIPPY);
1828 * Place the cursor on the player
1830 if (can_save) move_cursor_relative(p_ptr->y, p_ptr->x);
1837 * @brief コンソールを再描画する /
1838 * Redraw a term when it is resized
1841 void redraw_window(void)
1843 /* Only if the dungeon exists */
1844 if (!character_dungeon) return;
1846 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_SPELL | PW_PLAYER);
1847 p_ptr->window |= (PW_MESSAGE | PW_OVERHEAD | PW_DUNGEON | PW_MONSTER | PW_OBJECT);
1855 * @brief フォーカスを当てるべきマップ描画の基準座標を指定する(サブルーチン)
1856 * @param dy 変更先のフロアY座標
1857 * @param dx 変更先のフロアX座標
1858 * Handle a request to change the current panel
1859 * Return TRUE if the panel was changed.
1860 * Also used in do_cmd_locate
1861 * @return 実際に再描画が必要だった場合TRUEを返す
1863 bool change_panel(POSITION dy, POSITION dx)
1868 get_screen_size(&wid, &hgt);
1870 /* Apply the motion */
1871 y = panel_row_min + dy * hgt / 2;
1872 x = panel_col_min + dx * wid / 2;
1874 /* Verify the row */
1875 if (y > cur_hgt - hgt) y = cur_hgt - hgt;
1878 /* Verify the col */
1879 if (x > cur_wid - wid) x = cur_wid - wid;
1882 /* Handle "changes" */
1883 if ((y != panel_row_min) || (x != panel_col_min))
1885 /* Save the new panel info */
1889 /* Recalculate the boundaries */
1890 panel_bounds_center();
1892 p_ptr->update |= (PU_MONSTERS);
1893 p_ptr->redraw |= (PR_MAP);
1905 * @brief フォーカスを当てるべきマップ描画の基準座標を指定する
1906 * @param y 変更先のフロアY座標
1907 * @param x 変更先のフロアX座標
1909 * Handle a request to change the current panel
1910 * Return TRUE if the panel was changed.
1911 * Also used in do_cmd_locate
1912 * @return 実際に再描画が必要だった場合TRUEを返す
1914 static bool change_panel_xy(POSITION y, POSITION x)
1916 POSITION dy = 0, dx = 0;
1919 get_screen_size(&wid, &hgt);
1921 if (y < panel_row_min) dy = -1;
1922 if (y > panel_row_max) dy = 1;
1923 if (x < panel_col_min) dx = -1;
1924 if (x > panel_col_max) dx = 1;
1926 if (!dy && !dx) return (FALSE);
1928 return change_panel(dy, dx);
1933 * @brief マップ描画のフォーカスを当てるべき座標を更新する
1935 * Given an row (y) and col (x), this routine detects when a move
1936 * off the screen has occurred and figures new borders. -RAK-
1937 * "Update" forces a "full update" to take place.
1938 * The map is reprinted if necessary, and "TRUE" is returned.
1939 * @return 実際に再描画が必要だった場合TRUEを返す
1941 void verify_panel(void)
1943 POSITION y = p_ptr->y;
1944 POSITION x = p_ptr->x;
1952 get_screen_size(&wid, &hgt);
1954 max_prow_min = cur_hgt - hgt;
1955 max_pcol_min = cur_wid - wid;
1957 /* Bounds checking */
1958 if (max_prow_min < 0) max_prow_min = 0;
1959 if (max_pcol_min < 0) max_pcol_min = 0;
1961 /* Center on player */
1962 if (center_player && (center_running || !running))
1964 /* Center vertically */
1965 prow_min = y - hgt / 2;
1966 if (prow_min < 0) prow_min = 0;
1967 else if (prow_min > max_prow_min) prow_min = max_prow_min;
1969 /* Center horizontally */
1970 pcol_min = x - wid / 2;
1971 if (pcol_min < 0) pcol_min = 0;
1972 else if (pcol_min > max_pcol_min) pcol_min = max_pcol_min;
1976 prow_min = panel_row_min;
1977 pcol_min = panel_col_min;
1979 /* Scroll screen when 2 grids from top/bottom edge */
1980 if (y > panel_row_max - 2)
1982 while (y > prow_min + hgt-1 - 2)
1984 prow_min += (hgt / 2);
1988 if (y < panel_row_min + 2)
1990 while (y < prow_min + 2)
1992 prow_min -= (hgt / 2);
1996 if (prow_min > max_prow_min) prow_min = max_prow_min;
1997 if (prow_min < 0) prow_min = 0;
1999 /* Scroll screen when 4 grids from left/right edge */
2000 if (x > panel_col_max - 4)
2002 while (x > pcol_min + wid-1 - 4)
2004 pcol_min += (wid / 2);
2008 if (x < panel_col_min + 4)
2010 while (x < pcol_min + 4)
2012 pcol_min -= (wid / 2);
2016 if (pcol_min > max_pcol_min) pcol_min = max_pcol_min;
2017 if (pcol_min < 0) pcol_min = 0;
2020 /* Check for "no change" */
2021 if ((prow_min == panel_row_min) && (pcol_min == panel_col_min)) return;
2023 /* Save the new panel info */
2024 panel_row_min = prow_min;
2025 panel_col_min = pcol_min;
2027 /* Hack -- optional disturb on "panel change" */
2028 if (disturb_panel && !center_player) disturb(FALSE, FALSE);
2030 /* Recalculate the boundaries */
2031 panel_bounds_center();
2033 p_ptr->update |= (PU_MONSTERS);
2034 p_ptr->redraw |= (PR_MAP);
2035 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
2040 * Monster health description
2042 cptr look_mon_desc(monster_type *m_ptr, BIT_FLAGS mode)
2044 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
2051 /* Determine if the monster is "living" */
2052 living = monster_living(m_ptr->ap_r_idx);
2054 /* Calculate a health "percentage" */
2055 perc = m_ptr->maxhp > 0 ? 100L * m_ptr->hp / m_ptr->maxhp : 0;
2057 /* Healthy monsters */
2058 if (m_ptr->hp >= m_ptr->maxhp)
2060 desc = living ? _("無傷", "unhurt") : _("無ダメージ", "undamaged");
2063 else if (perc >= 60)
2065 desc = living ? _("軽傷", "somewhat wounded") : _("小ダメージ", "somewhat damaged");
2068 else if (perc >= 25)
2070 desc = living ? _("負傷", "wounded") : _("中ダメージ", "damaged");
2073 else if (perc >= 10)
2075 desc = living ? _("重傷", "badly wounded") : _("大ダメージ", "badly damaged");
2080 desc = living ? _("半死半生", "almost dead") : _("倒れかけ", "almost destroyed");
2083 /* Need attitude information? */
2086 /* Full information is not needed */
2089 else if (is_pet(m_ptr))
2091 attitude = _(", ペット", ", pet");
2093 else if (is_friendly(m_ptr))
2095 attitude = _(", 友好的", ", friendly");
2099 attitude = _("", "");
2102 /* Clone monster? */
2103 if (m_ptr->smart & SM_CLONED)
2112 /* Display monster's level --- idea borrowed from ToME */
2113 if (ap_r_ptr->r_tkills && !(m_ptr->mflag2 & MFLAG2_KAGE))
2115 return format(_("レベル%d, %s%s%s", "Level %d, %s%s%s"), ap_r_ptr->level, desc, attitude, clone);
2119 return format(_("レベル???, %s%s%s", "Level ???, %s%s%s"), desc, attitude, clone);
2127 * Angband sorting algorithm -- quick sort in place
2129 * Note that the details of the data we are sorting is hidden,
2130 * and we rely on the "ang_sort_comp()" and "ang_sort_swap()"
2131 * function hooks to interact with the data, which is given as
2132 * two pointers, and which may have any user-defined form.
2134 void ang_sort_aux(vptr u, vptr v, int p, int q)
2152 while (!(*ang_sort_comp)(u, v, b, z)) b--;
2155 while (!(*ang_sort_comp)(u, v, z, a)) a++;
2157 /* Done partition */
2161 (*ang_sort_swap)(u, v, a, b);
2167 /* Recurse left side */
2168 ang_sort_aux(u, v, p, b);
2170 /* Recurse right side */
2171 ang_sort_aux(u, v, b+1, q);
2176 * Angband sorting algorithm -- quick sort in place
2178 * Note that the details of the data we are sorting is hidden,
2179 * and we rely on the "ang_sort_comp()" and "ang_sort_swap()"
2180 * function hooks to interact with the data, which is given as
2181 * two pointers, and which may have any user-defined form.
2183 void ang_sort(vptr u, vptr v, int n)
2185 /* Sort the array */
2186 ang_sort_aux(u, v, 0, n-1);
2191 /*** Targeting Code ***/
2195 * Determine is a monster makes a reasonable target
2197 * The concept of "targeting" was stolen from "Morgul" (?)
2199 * The player can target any location, or any "target-able" monster.
2201 * Currently, a monster is "target_able" if it is visible, and if
2202 * the player can hit it with a projection, and the player is not
2203 * hallucinating. This allows use of "use closest target" macros.
2205 * Future versions may restrict the ability to target "trappers"
2206 * and "mimics", but the semantics is a little bit weird.
2208 bool target_able(MONSTER_IDX m_idx)
2210 monster_type *m_ptr = &m_list[m_idx];
2212 /* Monster must be alive */
2213 if (!m_ptr->r_idx) return (FALSE);
2215 /* Hack -- no targeting hallucinations */
2216 if (p_ptr->image) return (FALSE);
2218 /* Monster must be visible */
2219 if (!m_ptr->ml) return (FALSE);
2221 if (p_ptr->riding && (p_ptr->riding == m_idx)) return (TRUE);
2223 /* Monster must be projectable */
2224 if (!projectable(p_ptr->y, p_ptr->x, m_ptr->fy, m_ptr->fx)) return (FALSE);
2226 /* Hack -- Never target trappers */
2227 /* if (CLEAR_ATTR && (CLEAR_CHAR)) return (FALSE); */
2237 * Update (if necessary) and verify (if possible) the target.
2239 * We return TRUE if the target is "okay" and FALSE otherwise.
2241 bool target_okay(void)
2243 /* Accept stationary targets */
2244 if (target_who < 0) return (TRUE);
2246 /* Check moving targets */
2249 /* Accept reasonable targets */
2250 if (target_able(target_who))
2252 monster_type *m_ptr = &m_list[target_who];
2254 /* Acquire monster location */
2255 target_row = m_ptr->fy;
2256 target_col = m_ptr->fx;
2263 /* Assume no target */
2269 * Sorting hook -- comp function -- by "distance to player"
2271 * We use "u" and "v" to point to arrays of "x" and "y" positions,
2272 * and sort the arrays by double-distance to the player.
2274 static bool ang_sort_comp_distance(vptr u, vptr v, int a, int b)
2276 POSITION *x = (POSITION*)(u);
2277 POSITION *y = (POSITION*)(v);
2279 POSITION da, db, kx, ky;
2281 /* Absolute distance components */
2282 kx = x[a]; kx -= p_ptr->x; kx = ABS(kx);
2283 ky = y[a]; ky -= p_ptr->y; ky = ABS(ky);
2285 /* Approximate Double Distance to the first point */
2286 da = ((kx > ky) ? (kx + kx + ky) : (ky + ky + kx));
2288 /* Absolute distance components */
2289 kx = x[b]; kx -= p_ptr->x; kx = ABS(kx);
2290 ky = y[b]; ky -= p_ptr->y; ky = ABS(ky);
2292 /* Approximate Double Distance to the first point */
2293 db = ((kx > ky) ? (kx + kx + ky) : (ky + ky + kx));
2295 /* Compare the distances */
2301 * Sorting hook -- comp function -- by importance level of grids
2303 * We use "u" and "v" to point to arrays of "x" and "y" positions,
2304 * and sort the arrays by level of monster
2306 static bool ang_sort_comp_importance(vptr u, vptr v, int a, int b)
2308 POSITION *x = (POSITION*)(u);
2309 POSITION *y = (POSITION*)(v);
2310 cave_type *ca_ptr = &cave[y[a]][x[a]];
2311 cave_type *cb_ptr = &cave[y[b]][x[b]];
2312 monster_type *ma_ptr = &m_list[ca_ptr->m_idx];
2313 monster_type *mb_ptr = &m_list[cb_ptr->m_idx];
2314 monster_race *ap_ra_ptr, *ap_rb_ptr;
2316 /* The player grid */
2317 if (y[a] == p_ptr->y && x[a] == p_ptr->x) return TRUE;
2318 if (y[b] == p_ptr->y && x[b] == p_ptr->x) return FALSE;
2320 /* Extract monster race */
2321 if (ca_ptr->m_idx && ma_ptr->ml) ap_ra_ptr = &r_info[ma_ptr->ap_r_idx];
2322 else ap_ra_ptr = NULL;
2323 if (cb_ptr->m_idx && mb_ptr->ml) ap_rb_ptr = &r_info[mb_ptr->ap_r_idx];
2324 else ap_rb_ptr = NULL;
2326 if (ap_ra_ptr && !ap_rb_ptr) return TRUE;
2327 if (!ap_ra_ptr && ap_rb_ptr) return FALSE;
2329 /* Compare two monsters */
2330 if (ap_ra_ptr && ap_rb_ptr)
2332 /* Unique monsters first */
2333 if ((ap_ra_ptr->flags1 & RF1_UNIQUE) && !(ap_rb_ptr->flags1 & RF1_UNIQUE)) return TRUE;
2334 if (!(ap_ra_ptr->flags1 & RF1_UNIQUE) && (ap_rb_ptr->flags1 & RF1_UNIQUE)) return FALSE;
2336 /* Shadowers first (あやしい影) */
2337 if ((ma_ptr->mflag2 & MFLAG2_KAGE) && !(mb_ptr->mflag2 & MFLAG2_KAGE)) return TRUE;
2338 if (!(ma_ptr->mflag2 & MFLAG2_KAGE) && (mb_ptr->mflag2 & MFLAG2_KAGE)) return FALSE;
2340 /* Unknown monsters first */
2341 if (!ap_ra_ptr->r_tkills && ap_rb_ptr->r_tkills) return TRUE;
2342 if (ap_ra_ptr->r_tkills && !ap_rb_ptr->r_tkills) return FALSE;
2344 /* Higher level monsters first (if known) */
2345 if (ap_ra_ptr->r_tkills && ap_rb_ptr->r_tkills)
2347 if (ap_ra_ptr->level > ap_rb_ptr->level) return TRUE;
2348 if (ap_ra_ptr->level < ap_rb_ptr->level) return FALSE;
2351 /* Sort by index if all conditions are same */
2352 if (ma_ptr->ap_r_idx > mb_ptr->ap_r_idx) return TRUE;
2353 if (ma_ptr->ap_r_idx < mb_ptr->ap_r_idx) return FALSE;
2356 /* An object get higher priority */
2357 if (cave[y[a]][x[a]].o_idx && !cave[y[b]][x[b]].o_idx) return TRUE;
2358 if (!cave[y[a]][x[a]].o_idx && cave[y[b]][x[b]].o_idx) return FALSE;
2360 /* Priority from the terrain */
2361 if (f_info[ca_ptr->feat].priority > f_info[cb_ptr->feat].priority) return TRUE;
2362 if (f_info[ca_ptr->feat].priority < f_info[cb_ptr->feat].priority) return FALSE;
2364 /* If all conditions are same, compare distance */
2365 return ang_sort_comp_distance(u, v, a, b);
2370 * Sorting hook -- swap function -- by "distance to player"
2372 * We use "u" and "v" to point to arrays of "x" and "y" positions,
2373 * and sort the arrays by distance to the player.
2375 static void ang_sort_swap_distance(vptr u, vptr v, int a, int b)
2377 POSITION *x = (POSITION*)(u);
2378 POSITION *y = (POSITION*)(v);
2396 * Hack -- help "select" a location (see below)
2398 static POSITION_IDX target_pick(POSITION y1, POSITION x1, POSITION dy, POSITION dx)
2401 POSITION x2, y2, x3, y3, x4, y4;
2402 POSITION_IDX b_i = -1, b_v = 9999;
2405 /* Scan the locations */
2406 for (i = 0; i < temp_n; i++)
2412 /* Directed distance */
2416 /* Verify quadrant */
2417 if (dx && (x3 * dx <= 0)) continue;
2418 if (dy && (y3 * dy <= 0)) continue;
2420 /* Absolute distance */
2424 /* Verify quadrant */
2425 if (dy && !dx && (x4 > y4)) continue;
2426 if (dx && !dy && (y4 > x4)) continue;
2428 /* Approximate Double Distance */
2429 v = ((x4 > y4) ? (x4 + x4 + y4) : (y4 + y4 + x4));
2431 /* Penalize location */
2434 if ((b_i >= 0) && (v >= b_v)) continue;
2444 * Hack -- determine if a given location is "interesting"
2446 static bool target_set_accept(POSITION y, POSITION x)
2449 OBJECT_IDX this_o_idx, next_o_idx = 0;
2452 if (!(in_bounds(y, x))) return (FALSE);
2454 /* Player grid is always interesting */
2455 if (player_bold(y, x)) return (TRUE);
2457 /* Handle hallucination */
2458 if (p_ptr->image) return (FALSE);
2460 /* Examine the grid */
2461 c_ptr = &cave[y][x];
2463 /* Visible monsters */
2466 monster_type *m_ptr = &m_list[c_ptr->m_idx];
2468 /* Visible monsters */
2469 if (m_ptr->ml) return (TRUE);
2472 /* Scan all objects in the grid */
2473 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
2476 o_ptr = &o_list[this_o_idx];
2478 /* Acquire next object */
2479 next_o_idx = o_ptr->next_o_idx;
2481 /* Memorized object */
2482 if (o_ptr->marked & OM_FOUND) return (TRUE);
2485 /* Interesting memorized features */
2486 if (c_ptr->info & (CAVE_MARK))
2488 /* Notice object features */
2489 if (c_ptr->info & CAVE_OBJECT) return (TRUE);
2491 /* Feature code (applying "mimic" field) */
2492 if (have_flag(f_info[get_feat_mimic(c_ptr)].flags, FF_NOTICE)) return TRUE;
2500 * Prepare the "temp" array for "target_set"
2502 * Return the number of target_able monsters in the set.
2504 static void target_set_prepare(BIT_FLAGS mode)
2507 POSITION min_hgt, max_hgt, min_wid, max_wid;
2509 if (mode & TARGET_KILL)
2512 min_hgt = MAX((p_ptr->y - MAX_RANGE), 0);
2513 max_hgt = MIN((p_ptr->y + MAX_RANGE), cur_hgt - 1);
2514 min_wid = MAX((p_ptr->x - MAX_RANGE), 0);
2515 max_wid = MIN((p_ptr->x + MAX_RANGE), cur_wid - 1);
2517 else /* not targetting */
2520 min_hgt = panel_row_min;
2521 max_hgt = panel_row_max;
2522 min_wid = panel_col_min;
2523 max_wid = panel_col_max;
2526 /* Reset "temp" array */
2529 /* Scan the current panel */
2530 for (y = min_hgt; y <= max_hgt; y++)
2532 for (x = min_wid; x <= max_wid; x++)
2536 /* Require "interesting" contents */
2537 if (!target_set_accept(y, x)) continue;
2539 c_ptr = &cave[y][x];
2541 /* Require target_able monsters for "TARGET_KILL" */
2542 if ((mode & (TARGET_KILL)) && !target_able(c_ptr->m_idx)) continue;
2544 if ((mode & (TARGET_KILL)) && !target_pet && is_pet(&m_list[c_ptr->m_idx])) continue;
2546 /* Save the location */
2553 /* Set the sort hooks */
2554 if (mode & (TARGET_KILL))
2556 /* Target the nearest monster for shooting */
2557 ang_sort_comp = ang_sort_comp_distance;
2558 ang_sort_swap = ang_sort_swap_distance;
2562 /* Look important grids first in Look command */
2563 ang_sort_comp = ang_sort_comp_importance;
2564 ang_sort_swap = ang_sort_swap_distance;
2567 /* Sort the positions */
2568 ang_sort(temp_x, temp_y, temp_n);
2570 if (p_ptr->riding && target_pet && (temp_n > 1) && (mode & (TARGET_KILL)))
2575 temp_y[0] = temp_y[1];
2578 temp_x[0] = temp_x[1];
2583 void target_set_prepare_look(void){
2584 target_set_prepare(TARGET_LOOK);
2589 * Evaluate number of kill needed to gain level
2591 static void evaluate_monster_exp(char *buf, monster_type *m_ptr)
2593 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
2595 s32b exp_mon, exp_adv;
2596 u32b exp_mon_frac, exp_adv_frac;
2598 if ((p_ptr->lev >= PY_MAX_LEVEL) || (p_ptr->prace == RACE_ANDROID))
2603 else if (!ap_r_ptr->r_tkills || (m_ptr->mflag2 & MFLAG2_KAGE))
2613 /* The monster's experience point (assuming average monster speed) */
2614 exp_mon = ap_r_ptr->mexp * ap_r_ptr->level;
2616 s64b_div(&exp_mon, &exp_mon_frac, 0, (p_ptr->max_plv + 2));
2619 /* Total experience value for next level */
2620 exp_adv = player_exp[p_ptr->lev -1] * p_ptr->expfact;
2622 s64b_div(&exp_adv, &exp_adv_frac, 0, 100);
2624 /* Experience value need to get */
2625 s64b_sub(&exp_adv, &exp_adv_frac, p_ptr->exp, p_ptr->exp_frac);
2628 /* You need to kill at least one monster to get any experience */
2629 s64b_add(&exp_adv, &exp_adv_frac, exp_mon, exp_mon_frac);
2630 s64b_sub(&exp_adv, &exp_adv_frac, 0, 1);
2632 /* Extract number of monsters needed */
2633 s64b_div(&exp_adv, &exp_adv_frac, exp_mon, exp_mon_frac);
2635 /* If 999 or more monsters needed, only display "999". */
2636 num = MIN(999, exp_adv_frac);
2638 /* Display the number */
2639 sprintf(buf,"%03ld", (long int)num);
2643 bool show_gold_on_floor = FALSE;
2646 * Examine a grid, return a keypress.
2648 * The "mode" argument contains the "TARGET_LOOK" bit flag, which
2649 * indicates that the "space" key should scan through the contents
2650 * of the grid, instead of simply returning immediately. This lets
2651 * the "look" command get complete information, without making the
2652 * "target" command annoying.
2654 * The "info" argument contains the "commands" which should be shown
2655 * inside the "[xxx]" text. This string must never be empty, or grids
2656 * containing monsters will be displayed with an extra comma.
2658 * Note that if a monster is in the grid, we update both the monster
2659 * recall info and the health bar info to track that monster.
2661 * Eventually, we may allow multiple objects per grid, or objects
2662 * and terrain features in the same grid.
2664 * This function must handle blindness/hallucination.
2666 static char target_set_aux(POSITION y, POSITION x, BIT_FLAGS mode, cptr info)
2668 cave_type *c_ptr = &cave[y][x];
2669 OBJECT_IDX this_o_idx, next_o_idx = 0;
2670 cptr s1 = "", s2 = "", s3 = "", x_info = "";
2673 feature_type *f_ptr;
2674 char query = '\001';
2675 char out_val[MAX_NLEN+80];
2676 OBJECT_IDX floor_list[23];
2677 ITEM_NUMBER floor_num = 0;
2679 /* Scan all objects in the grid */
2682 floor_num = scan_floor(floor_list, y, x, 0x02);
2686 x_info = _("x物 ", "x,");
2690 /* Hack -- under the player */
2691 if (player_bold(y, x))
2707 s1 = _("ターゲット:", "Target:");
2710 /* Hack -- hallucination */
2713 cptr name = _("何か奇妙な物", "something strange");
2715 /* Display a message */
2717 sprintf(out_val, "%s%s%s%s [%s]", s1, name, s2, s3, info);
2719 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, name, info);
2723 move_cursor_relative(y, x);
2726 /* Stop on everything but "return" */
2727 if ((query != '\r') && (query != '\n')) return query;
2729 /* Repeat forever */
2734 /* Actual monsters */
2735 if (c_ptr->m_idx && m_list[c_ptr->m_idx].ml)
2737 monster_type *m_ptr = &m_list[c_ptr->m_idx];
2738 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
2740 bool recall = FALSE;
2745 /* Get the monster name ("a kobold") */
2746 monster_desc(m_name, m_ptr, MD_INDEF_VISIBLE);
2748 /* Hack -- track this monster race */
2749 monster_race_track(m_ptr->ap_r_idx);
2751 /* Hack -- health bar for this monster */
2752 health_track(c_ptr->m_idx);
2766 /* Recall on screen */
2767 screen_roff(m_ptr->ap_r_idx, 0);
2769 /* Hack -- Complete the prompt (again) */
2770 Term_addstr(-1, TERM_WHITE, format(_(" [r思 %s%s]", " [r,%s%s]"), x_info, info));
2778 /* Normal commands */
2779 if (query != 'r') break;
2784 /* Cleare recall text and repeat */
2790 /* Describe, and prompt for recall */
2791 evaluate_monster_exp(acount, m_ptr);
2794 sprintf(out_val, "[%s]%s%s(%s)%s%s [r思 %s%s]", acount, s1, m_name, look_mon_desc(m_ptr, 0x01), s2, s3, x_info, info);
2796 sprintf(out_val, "[%s]%s%s%s%s(%s) [r, %s%s]", acount, s1, s2, s3, m_name, look_mon_desc(m_ptr, 0x01), x_info, info);
2802 move_cursor_relative(y, x);
2807 /* Normal commands */
2808 if (query != 'r') break;
2814 /* Always stop at "normal" keys */
2815 if ((query != '\r') && (query != '\n') && (query != ' ') && (query != 'x')) return query;
2817 /* Sometimes stop at "space" key */
2818 if ((query == ' ') && !(mode & (TARGET_LOOK))) return query;
2820 /* Change the intro */
2821 s1 = _("それは", "It is ");
2823 /* Hack -- take account of gender */
2824 if (ap_r_ptr->flags1 & (RF1_FEMALE)) s1 = _("彼女は", "She is ");
2825 else if (ap_r_ptr->flags1 & (RF1_MALE)) s1 = _("彼は", "He is ");
2827 /* Use a preposition */
2836 /* Scan all objects being carried */
2837 for (this_o_idx = m_ptr->hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
2839 char o_name[MAX_NLEN];
2842 o_ptr = &o_list[this_o_idx];
2844 /* Acquire next object */
2845 next_o_idx = o_ptr->next_o_idx;
2847 /* Obtain an object description */
2848 object_desc(o_name, o_ptr, 0);
2851 sprintf(out_val, "%s%s%s%s[%s]", s1, o_name, s2, s3, info);
2853 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, o_name, info);
2857 move_cursor_relative(y, x);
2860 /* Always stop at "normal" keys */
2861 if ((query != '\r') && (query != '\n') && (query != ' ') && (query != 'x')) return query;
2863 /* Sometimes stop at "space" key */
2864 if ((query == ' ') && !(mode & (TARGET_LOOK))) return query;
2866 /* Change the intro */
2867 s2 = _("をまた", "also carrying ");
2870 /* Use a preposition */
2887 char o_name[MAX_NLEN];
2890 o_ptr = &o_list[floor_list[0]];
2892 object_desc(o_name, o_ptr, 0);
2895 sprintf(out_val, "%s%s%s%s[%s]", s1, o_name, s2, s3, info);
2897 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, o_name, info);
2901 move_cursor_relative(y, x);
2910 /* Provide one cushion before item listing */
2913 /* Display rough information about items */
2915 sprintf(out_val, "%s %d個のアイテム%s%s ['x'で一覧, %s]", s1, (int)floor_num, s2, s3, info);
2917 sprintf(out_val, "%s%s%sa pile of %d items [x,%s]", s1, s2, s3, (int)floor_num, info);
2921 move_cursor_relative(y, x);
2926 /* No request for listing */
2927 if (query != 'x' && query != ' ') return query;
2931 /** Display list of items **/
2933 /* Continue scrolling list if requested */
2941 show_gold_on_floor = TRUE;
2942 (void)show_floor(0, y, x, &min_width);
2943 show_gold_on_floor = FALSE;
2947 sprintf(out_val, "%s %d個のアイテム%s%s [Enterで次へ, %s]", s1, (int)floor_num, s2, s3, info);
2949 sprintf(out_val, "%s%s%sa pile of %d items [Enter,%s]", s1, s2, s3, (int)floor_num, info);
2956 /* Exit unless 'Enter' */
2957 if (query != '\n' && query != '\r')
2962 /* Get the object being moved. */
2963 o_idx = c_ptr->o_idx;
2965 /* Only rotate a pile of two or more objects. */
2966 if (!(o_idx && o_list[o_idx].next_o_idx)) continue;
2968 /* Remove the first object from the list. */
2969 excise_object_idx(o_idx);
2971 /* Find end of the list. */
2973 while (o_list[i].next_o_idx)
2974 i = o_list[i].next_o_idx;
2976 /* Add after the last object. */
2977 o_list[i].next_o_idx = o_idx;
2979 /* Loop and re-display the list */
2986 /* Scan all objects in the grid */
2987 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
2990 o_ptr = &o_list[this_o_idx];
2992 /* Acquire next object */
2993 next_o_idx = o_ptr->next_o_idx;
2995 if (o_ptr->marked & OM_FOUND)
2997 char o_name[MAX_NLEN];
3002 /* Obtain an object description */
3003 object_desc(o_name, o_ptr, 0);
3006 sprintf(out_val, "%s%s%s%s[%s]", s1, o_name, s2, s3, info);
3008 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, o_name, info);
3012 move_cursor_relative(y, x);
3015 /* Always stop at "normal" keys */
3016 if ((query != '\r') && (query != '\n') && (query != ' ') && (query != 'x')) return query;
3018 /* Sometimes stop at "space" key */
3019 if ((query == ' ') && !(mode & TARGET_LOOK)) return query;
3021 /* Change the intro */
3022 s1 = _("それは", "It is ");
3025 if (o_ptr->number != 1) s1 = _("それらは", "They are ");
3039 /* Feature code (applying "mimic" field) */
3040 feat = get_feat_mimic(c_ptr);
3042 /* Require knowledge about grid, or ability to see grid */
3043 if (!(c_ptr->info & CAVE_MARK) && !player_can_see_bold(y, x))
3045 /* Forget feature */
3049 f_ptr = &f_info[feat];
3051 /* Terrain feature if needed */
3052 if (boring || have_flag(f_ptr->flags, FF_REMEMBER))
3056 /* Hack -- special handling for quest entrances */
3057 if (have_flag(f_ptr->flags, FF_QUEST_ENTER))
3059 /* Set the quest number temporary */
3060 IDX old_quest = p_ptr->inside_quest;
3063 /* Clear the text */
3064 for (j = 0; j < 10; j++) quest_text[j][0] = '\0';
3065 quest_text_line = 0;
3067 p_ptr->inside_quest = c_ptr->special;
3069 /* Get the quest text */
3070 init_flags = INIT_NAME_ONLY;
3072 process_dungeon_file("q_info.txt", 0, 0, 0, 0);
3074 name = format(_("クエスト「%s」(%d階相当)", "the entrance to the quest '%s'(level %d)"),
3075 quest[c_ptr->special].name, quest[c_ptr->special].level);
3077 /* Reset the old quest number */
3078 p_ptr->inside_quest = old_quest;
3081 /* Hack -- special handling for building doors */
3082 else if (have_flag(f_ptr->flags, FF_BLDG) && !p_ptr->inside_arena)
3084 name = building[f_ptr->subtype].name;
3086 else if (have_flag(f_ptr->flags, FF_ENTRANCE))
3088 name = format(_("%s(%d階相当)", "%s(level %d)"), d_text + d_info[c_ptr->special].text, d_info[c_ptr->special].mindepth);
3090 else if (have_flag(f_ptr->flags, FF_TOWN))
3092 name = town[c_ptr->special].name;
3094 else if (p_ptr->wild_mode && (feat == feat_floor))
3096 name = _("道", "road");
3100 name = f_name + f_ptr->name;
3106 ((!have_flag(f_ptr->flags, FF_MOVE) && !have_flag(f_ptr->flags, FF_CAN_FLY)) ||
3107 (!have_flag(f_ptr->flags, FF_LOS) && !have_flag(f_ptr->flags, FF_TREE)) ||
3108 have_flag(f_ptr->flags, FF_TOWN)))
3110 s2 = _("の中", "in ");
3113 /* Hack -- special introduction for store & building doors -KMW- */
3114 if (have_flag(f_ptr->flags, FF_STORE) ||
3115 have_flag(f_ptr->flags, FF_QUEST_ENTER) ||
3116 (have_flag(f_ptr->flags, FF_BLDG) && !p_ptr->inside_arena) ||
3117 have_flag(f_ptr->flags, FF_ENTRANCE))
3126 else if (have_flag(f_ptr->flags, FF_FLOOR) ||
3127 have_flag(f_ptr->flags, FF_TOWN) ||
3128 have_flag(f_ptr->flags, FF_SHALLOW) ||
3129 have_flag(f_ptr->flags, FF_DEEP))
3135 /* Pick proper indefinite article */
3136 s3 = (is_a_vowel(name[0])) ? "an " : "a ";
3140 /* Display a message */
3144 if (c_ptr->mimic) sprintf(f_idx_str, "%d/%d", c_ptr->feat, c_ptr->mimic);
3145 else sprintf(f_idx_str, "%d", c_ptr->feat);
3147 sprintf(out_val, "%s%s%s%s[%s] %x %s %d %d %d (%d,%d) %d", s1, name, s2, s3, info, (unsigned int)c_ptr->info, f_idx_str, c_ptr->dist, c_ptr->cost, c_ptr->when, (int)y, (int)x, travel.cost[y][x]);
3149 sprintf(out_val, "%s%s%s%s [%s] %x %s %d %d %d (%d,%d)", s1, s2, s3, name, info, c_ptr->info, f_idx_str, c_ptr->dist, c_ptr->cost, c_ptr->when, (int)y, (int)x);
3154 sprintf(out_val, "%s%s%s%s[%s]", s1, name, s2, s3, info);
3156 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, name, info);
3160 move_cursor_relative(y, x);
3163 /* Always stop at "normal" keys */
3164 if ((query != '\r') && (query != '\n') && (query != ' ')) return query;
3167 /* Stop on everything but "return" */
3168 if ((query != '\r') && (query != '\n')) return query;
3170 /* Repeat forever */
3176 * Handle "target" and "look".
3178 * Note that this code can be called from "get_aim_dir()".
3180 * All locations must be on the current panel. Consider the use of
3181 * "panel_bounds()" to allow "off-panel" targets, perhaps by using
3182 * some form of "scrolling" the map around the cursor.
3183 * That is, consider the possibility of "auto-scrolling" the screen
3184 * while the cursor moves around. This may require changes in the
3185 * "update_monster()" code to allow "visibility" even if off panel, and
3186 * may require dynamic recalculation of the "temp" grid set.
3188 * Hack -- targeting/observing an "outer border grid" may induce
3189 * problems, so this is not currently allowed.
3191 * The player can use the direction keys to move among "interesting"
3192 * grids in a heuristic manner, or the "space", "+", and "-" keys to
3193 * move through the "interesting" grids in a sequential manner, or
3194 * can enter "location" mode, and use the direction keys to move one
3195 * grid at a time in any direction. The "t" (set target) command will
3196 * only target a monster (as opposed to a location) if the monster is
3197 * target_able and the "interesting" mode is being used.
3199 * The current grid is described using the "look" method above, and
3200 * a new command may be entered at any time, but note that if the
3201 * "TARGET_LOOK" bit flag is set (or if we are in "location" mode,
3202 * where "space" has no obvious meaning) then "space" will scan
3203 * through the description of the current grid until done, instead
3204 * of immediately jumping to the next "interesting" grid. This
3205 * allows the "target" command to retain its old semantics.
3207 * The "*", "+", and "-" keys may always be used to jump immediately
3208 * to the next (or previous) interesting grid, in the proper mode.
3210 * The "return" key may always be used to scan through a complete
3211 * grid description (forever).
3213 * This command will cancel any old target, even if used from
3214 * inside the "look" command.
3216 bool target_set(BIT_FLAGS mode)
3219 POSITION y = p_ptr->y;
3220 POSITION x = p_ptr->x;
3232 get_screen_size(&wid, &hgt);
3238 /* Cancel tracking */
3239 /* health_track(0); */
3241 if (rogue_like_commands)
3250 /* Prepare the "temp" array */
3251 target_set_prepare(mode);
3253 /* Start near the player */
3259 /* Interesting grids */
3266 change_panel_xy(y, x);
3268 if (!(mode & TARGET_LOOK)) prt_path(y, x);
3271 c_ptr = &cave[y][x];
3274 if (target_able(c_ptr->m_idx))
3276 strcpy(info, _("q止 t決 p自 o現 +次 -前", "q,t,p,o,+,-,<dir>"));
3279 /* Dis-allow target */
3282 strcpy(info, _("q止 p自 o現 +次 -前", "q,p,o,+,-,<dir>"));
3288 sprintf(cheatinfo, " LOS:%d, PROJECTABLE:%d",
3289 los(p_ptr->y, p_ptr->x, y, x),
3290 projectable(p_ptr->y, p_ptr->x, y, x));
3291 strcat(info, cheatinfo);
3294 /* Describe and Prompt */
3296 query = target_set_aux(y, x, mode, info);
3300 /* Cancel tracking */
3301 /* health_track(0); */
3303 /* Assume no "direction" */
3308 if (query == '\r') query = 't';
3326 if (target_able(c_ptr->m_idx))
3328 health_track(c_ptr->m_idx);
3329 target_who = c_ptr->m_idx;
3348 if (!expand_list) done = TRUE;
3358 if (!expand_list) done = TRUE;
3365 /* Recenter the map around the player */
3368 p_ptr->update |= (PU_MONSTERS);
3370 p_ptr->redraw |= (PR_MAP);
3372 p_ptr->window |= (PW_OVERHEAD);
3375 /* Recalculate interesting grids */
3376 target_set_prepare(mode);
3395 if(query == same_key)
3400 if (!expand_list) done = TRUE;
3405 /* Extract the action (if any) */
3406 d = get_keymap_dir(query);
3413 /* Hack -- move around */
3416 /* Modified to scroll to monster */
3417 POSITION y2 = panel_row_min;
3418 POSITION x2 = panel_col_min;
3420 /* Find a new monster */
3421 i = target_pick(temp_y[m], temp_x[m], ddy[d], ddx[d]);
3423 /* Request to target past last interesting grid */
3424 while (flag && (i < 0))
3426 /* Note the change */
3427 if (change_panel(ddy[d], ddx[d]))
3432 /* Recalculate interesting grids */
3433 target_set_prepare(mode);
3435 /* Look at interesting grids */
3438 /* Find a new monster */
3439 i = target_pick(v, u, ddy[d], ddx[d]);
3445 /* Nothing interesting */
3451 /* Restore previous position */
3454 panel_bounds_center();
3456 p_ptr->update |= (PU_MONSTERS);
3458 p_ptr->redraw |= (PR_MAP);
3460 p_ptr->window |= (PW_OVERHEAD);
3463 /* Recalculate interesting grids */
3464 target_set_prepare(mode);
3466 /* Look at boring grids */
3473 /* Do not move horizontally if unnecessary */
3474 if (((x < panel_col_min + wid / 2) && (dx > 0)) ||
3475 ((x > panel_col_min + wid / 2) && (dx < 0)))
3480 /* Do not move vertically if unnecessary */
3481 if (((y < panel_row_min + hgt / 2) && (dy > 0)) ||
3482 ((y > panel_row_min + hgt / 2) && (dy < 0)))
3487 /* Apply the motion */
3488 if ((y >= panel_row_min+hgt) || (y < panel_row_min) ||
3489 (x >= panel_col_min+wid) || (x < panel_col_min))
3491 if (change_panel(dy, dx)) target_set_prepare(mode);
3494 /* Slide into legality */
3495 if (x >= cur_wid-1) x = cur_wid - 2;
3496 else if (x <= 0) x = 1;
3498 /* Slide into legality */
3499 if (y >= cur_hgt-1) y = cur_hgt- 2;
3500 else if (y <= 0) y = 1;
3509 /* Arbitrary grids */
3512 bool move_fast = FALSE;
3514 if (!(mode & TARGET_LOOK)) prt_path(y, x);
3517 c_ptr = &cave[y][x];
3519 /* Default prompt */
3520 strcpy(info, _("q止 t決 p自 m近 +次 -前", "q,t,p,m,+,-,<dir>"));
3525 sprintf(cheatinfo, " LOS:%d, PROJECTABLE:%d",
3526 los(p_ptr->y, p_ptr->x, y, x),
3527 projectable(p_ptr->y, p_ptr->x, y, x));
3528 strcat(info, cheatinfo);
3531 /* Describe and Prompt (enable "TARGET_LOOK") */
3532 while ((query = target_set_aux(y, x, mode | TARGET_LOOK, info)) == 0);
3534 /* Cancel tracking */
3535 /* health_track(0); */
3537 /* Assume no direction */
3542 if (query == '\r') query = 't';
3545 /* Analyze the keypress */
3569 /* Recenter the map around the player */
3572 p_ptr->update |= (PU_MONSTERS);
3574 p_ptr->redraw |= (PR_MAP);
3576 p_ptr->window |= (PW_OVERHEAD);
3579 /* Recalculate interesting grids */
3580 target_set_prepare(mode);
3602 /* Pick a nearby monster */
3603 for (i = 0; i < temp_n; i++)
3605 t = distance(y, x, temp_y[i], temp_x[i]);
3615 /* Nothing interesting */
3616 if (bd == 999) flag = FALSE;
3623 /* Extract the action (if any) */
3624 d = get_keymap_dir(query);
3626 /* XTRA HACK MOVEFAST */
3627 if (isupper(query)) move_fast = TRUE;
3634 /* Handle "direction" */
3640 /* XTRA HACK MOVEFAST */
3643 int mag = MIN(wid / 2, hgt / 2);
3653 /* Do not move horizontally if unnecessary */
3654 if (((x < panel_col_min + wid / 2) && (dx > 0)) ||
3655 ((x > panel_col_min + wid / 2) && (dx < 0)))
3660 /* Do not move vertically if unnecessary */
3661 if (((y < panel_row_min + hgt / 2) && (dy > 0)) ||
3662 ((y > panel_row_min + hgt / 2) && (dy < 0)))
3667 /* Apply the motion */
3668 if ((y >= panel_row_min + hgt) || (y < panel_row_min) ||
3669 (x >= panel_col_min + wid) || (x < panel_col_min))
3671 if (change_panel(dy, dx)) target_set_prepare(mode);
3674 /* Slide into legality */
3675 if (x >= cur_wid-1) x = cur_wid - 2;
3676 else if (x <= 0) x = 1;
3678 /* Slide into legality */
3679 if (y >= cur_hgt-1) y = cur_hgt- 2;
3680 else if (y <= 0) y = 1;
3688 /* Clear the top line */
3691 /* Recenter the map around the player */
3694 p_ptr->update |= (PU_MONSTERS);
3696 p_ptr->redraw |= (PR_MAP);
3698 p_ptr->window |= (PW_OVERHEAD);
3701 /* Failure to set target */
3702 if (!target_who) return (FALSE);
3710 * Get an "aiming direction" from the user.
3712 * The "dir" is loaded with 1,2,3,4,6,7,8,9 for "actual direction", and
3713 * "0" for "current target", and "-1" for "entry aborted".
3715 * Note that "Force Target", if set, will pre-empt user interaction,
3716 * if there is a usable target already set.
3718 * Note that confusion over-rides any (explicit?) user choice.
3720 bool get_aim_dir(DIRECTION *dp)
3729 /* Global direction */
3732 /* Hack -- auto-target if requested */
3733 if (use_old_target && target_okay()) dir = 5;
3735 if (repeat_pull(&code))
3740 if (!(code == 5 && !target_okay()))
3742 /* return (TRUE); */
3743 dir = (DIRECTION)code;
3746 *dp = (DIRECTION)code;
3748 /* Ask until satisfied */
3751 /* Choose a prompt */
3754 p = _("方向 ('*'でターゲット選択, ESCで中断)? ", "Direction ('*' to choose a target, Escape to cancel)? ");
3758 p = _("方向 ('5'でターゲットへ, '*'でターゲット再選択, ESCで中断)? ", "Direction ('5' for target, '*' to re-target, Escape to cancel)? ");
3761 /* Get a command (or Cancel) */
3762 if (!get_com(p, &command, TRUE)) break;
3766 if (command == '\r') command = 't';
3769 /* Convert various keys to "standard" keys */
3772 /* Use current target */
3783 /* Set new target */
3788 if (target_set(TARGET_KILL)) dir = 5;
3794 /* Extract the action (if any) */
3795 dir = get_keymap_dir(command);
3801 /* Verify requested targets */
3802 if ((dir == 5) && !target_okay()) dir = 0;
3811 project_length = 0; /* reset to default */
3815 /* Save the direction */
3818 /* Check for confusion */
3819 if (p_ptr->confused)
3821 /* Random direction */
3822 dir = ddd[randint0(8)];
3825 /* Notice confusion */
3826 if (command_dir != dir)
3829 msg_print(_("あなたは混乱している。", "You are confused."));
3832 /* Save direction */
3835 /* repeat_push(dir); */
3836 repeat_push((COMMAND_CODE)command_dir);
3838 /* A "valid" direction was entered */
3843 bool get_direction(DIRECTION *dp, bool allow_under, bool with_steed)
3851 /* Global direction */
3854 if (repeat_pull(&code))
3856 dir = (DIRECTION)code;
3857 /* return (TRUE); */
3859 *dp = (DIRECTION)code;
3863 prompt = _("方向 ('.'足元, ESCで中断)? ", "Direction ('.' at feet, Escape to cancel)? ");
3867 prompt = _("方向 (ESCで中断)? ", "Direction (Escape to cancel)? ");
3870 /* Get a direction */
3875 /* Get a command (or Cancel) */
3876 if (!get_com(prompt, &ch, TRUE)) break;
3879 if ((allow_under) && ((ch == '5') || (ch == '-') || (ch == '.')))
3885 /* Look up the direction */
3886 dir = get_keymap_dir(ch);
3892 /* Prevent weirdness */
3893 if ((dir == 5) && (!allow_under)) dir = 0;
3896 if (!dir) return (FALSE);
3898 /* Save desired direction */
3901 /* Apply "confusion" */
3902 if (p_ptr->confused)
3904 /* Standard confusion */
3905 if (randint0(100) < 75)
3907 /* Random direction */
3908 dir = ddd[randint0(8)];
3911 else if (p_ptr->riding && with_steed)
3913 monster_type *m_ptr = &m_list[p_ptr->riding];
3914 monster_race *r_ptr = &r_info[m_ptr->r_idx];
3916 if (MON_CONFUSED(m_ptr))
3918 /* Standard confusion */
3919 if (randint0(100) < 75)
3921 /* Random direction */
3922 dir = ddd[randint0(8)];
3925 else if ((r_ptr->flags1 & RF1_RAND_50) && (r_ptr->flags1 & RF1_RAND_25) && (randint0(100) < 50))
3927 /* Random direction */
3928 dir = ddd[randint0(8)];
3930 else if ((r_ptr->flags1 & RF1_RAND_50) && (randint0(100) < 25))
3932 /* Random direction */
3933 dir = ddd[randint0(8)];
3937 /* Notice confusion */
3938 if (command_dir != dir)
3940 if (p_ptr->confused)
3943 msg_print(_("あなたは混乱している。", "You are confused."));
3948 monster_type *m_ptr = &m_list[p_ptr->riding];
3950 monster_desc(m_name, m_ptr, 0);
3951 if (MON_CONFUSED(m_ptr))
3953 msg_format(_("%sは混乱している。", "%^s is confusing."), m_name);
3957 msg_format(_("%sは思い通りに動いてくれない。", "You cannot control %s."), m_name);
3962 /* Save direction */
3965 /* repeat_push(dir); */
3966 repeat_push((COMMAND_CODE)command_dir);
3973 * @brief 進行方向を指定する(騎乗対象の混乱の影響を受ける) / Request a "movement" direction (1,2,3,4,6,7,8,9) from the user,
3974 * and place it into "command_dir", unless we already have one.
3976 * This function should be used for all "repeatable" commands, such as
3977 * run, walk, open, close, bash, disarm, spike, tunnel, etc, as well
3978 * as all commands which must reference a grid adjacent to the player,
3979 * and which may not reference the grid under the player. Note that,
3980 * for example, it is no longer possible to "disarm" or "open" chests
3981 * in the same grid as the player.
3983 * Direction "5" is illegal and will (cleanly) abort the command.
3985 * This function tracks and uses the "global direction", and uses
3986 * that as the "desired direction", to which "confusion" is applied.
3988 bool get_rep_dir(DIRECTION *dp, bool under)
3996 /* Global direction */
3999 if (repeat_pull(&code))
4001 dir = (DIRECTION)code;
4002 /* return (TRUE); */
4004 *dp = (DIRECTION)code;
4008 prompt = _("方向 ('.'足元, ESCで中断)? ", "Direction ('.' at feet, Escape to cancel)? ");
4012 prompt = _("方向 (ESCで中断)? ", "Direction (Escape to cancel)? ");
4015 /* Get a direction */
4020 /* Get a command (or Cancel) */
4021 if (!get_com(prompt, &ch, TRUE)) break;
4024 if ((under) && ((ch == '5') || (ch == '-') || (ch == '.')))
4030 /* Look up the direction */
4031 dir = get_keymap_dir(ch);
4037 /* Prevent weirdness */
4038 if ((dir == 5) && (!under)) dir = 0;
4041 if (!dir) return (FALSE);
4043 /* Save desired direction */
4046 /* Apply "confusion" */
4047 if (p_ptr->confused)
4049 /* Standard confusion */
4050 if (randint0(100) < 75)
4052 /* Random direction */
4053 dir = ddd[randint0(8)];
4056 else if (p_ptr->riding)
4058 monster_type *m_ptr = &m_list[p_ptr->riding];
4059 monster_race *r_ptr = &r_info[m_ptr->r_idx];
4061 if (MON_CONFUSED(m_ptr))
4063 /* Standard confusion */
4064 if (randint0(100) < 75)
4066 /* Random direction */
4067 dir = ddd[randint0(8)];
4070 else if ((r_ptr->flags1 & RF1_RAND_50) && (r_ptr->flags1 & RF1_RAND_25) && (randint0(100) < 50))
4072 /* Random direction */
4073 dir = ddd[randint0(8)];
4075 else if ((r_ptr->flags1 & RF1_RAND_50) && (randint0(100) < 25))
4077 /* Random direction */
4078 dir = ddd[randint0(8)];
4082 /* Notice confusion */
4083 if (command_dir != dir)
4085 if (p_ptr->confused)
4088 msg_print(_("あなたは混乱している。", "You are confused."));
4093 monster_type *m_ptr = &m_list[p_ptr->riding];
4095 monster_desc(m_name, m_ptr, 0);
4096 if (MON_CONFUSED(m_ptr))
4098 msg_format(_("%sは混乱している。", "%^s is confusing."), m_name);
4102 msg_format(_("%sは思い通りに動いてくれない。", "You cannot control %s."), m_name);
4107 /* Save direction */
4110 /* repeat_push(dir); */
4111 repeat_push((COMMAND_CODE)command_dir);
4117 void gain_level_reward(int chosen_reward)
4121 char wrath_reason[32] = "";
4122 int nasty_chance = 6;
4123 OBJECT_TYPE_VALUE dummy = 0;
4124 OBJECT_SUBTYPE_VALUE dummy2 = 0;
4127 char o_name[MAX_NLEN];
4133 if (multi_rew) return;
4134 else multi_rew = TRUE;
4138 if (p_ptr->lev == 13) nasty_chance = 2;
4139 else if (!(p_ptr->lev % 13)) nasty_chance = 3;
4140 else if (!(p_ptr->lev % 14)) nasty_chance = 12;
4142 if (one_in_(nasty_chance))
4143 type = randint1(20); /* Allow the 'nasty' effects */
4145 type = randint1(15) + 5; /* Or disallow them */
4147 if (type < 1) type = 1;
4148 if (type > 20) type = 20;
4152 sprintf(wrath_reason, _("%sの怒り", "the Wrath of %s"), chaos_patrons[p_ptr->chaos_patron]);
4154 effect = chaos_rewards[p_ptr->chaos_patron][type];
4156 if (one_in_(6) && !chosen_reward)
4158 msg_format(_("%^sは褒美としてあなたを突然変異させた。", "%^s rewards you with a mutation!"), chaos_patrons[p_ptr->chaos_patron]);
4159 (void)gain_random_mutation(0);
4160 reward = _("変異した。", "mutation");
4164 switch (chosen_reward ? chosen_reward : effect)
4169 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4170 msg_print(_("「汝、新たなる姿を必要とせり!」", "'Thou needst a new form, mortal!'"));
4173 reward = _("変異した。", "polymorphing");
4178 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4179 msg_print(_("「汝は良く行いたり!続けよ!」", "'Well done, mortal! Lead on!'"));
4181 if (p_ptr->prace == RACE_ANDROID)
4183 msg_print(_("しかし何も起こらなかった。", "But, nothing happen."));
4185 else if (p_ptr->exp < PY_MAX_EXP)
4187 s32b ee = (p_ptr->exp / 2) + 10;
4188 if (ee > 100000L) ee = 100000L;
4189 msg_print(_("更に経験を積んだような気がする。", "You feel more experienced."));
4192 reward = _("経験値を得た", "experience");
4198 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4199 msg_print(_("「下僕よ、汝それに値せず。」", "'Thou didst not deserve that, slave.'"));
4201 if (p_ptr->prace == RACE_ANDROID)
4203 msg_print(_("しかし何も起こらなかった。", "But, nothing happen."));
4207 lose_exp(p_ptr->exp / 6);
4208 reward = _("経験値を失った。", "losing experience");
4214 msg_format("%sの声がささやいた:",
4215 chaos_patrons[p_ptr->chaos_patron]);
4217 msg_format("The voice of %s whispers:",
4218 chaos_patrons[p_ptr->chaos_patron]);
4221 msg_print(_("「我が与えし物を賢明に使うべし。」", "'Use my gift wisely.'"));
4223 acquirement(p_ptr->y, p_ptr->x, 1, FALSE, FALSE, FALSE);
4224 reward = _("上質なアイテムを手に入れた。", "a good item");
4229 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4230 msg_print(_("「我が与えし物を賢明に使うべし。」", "'Use my gift wisely.'"));
4232 acquirement(p_ptr->y, p_ptr->x, 1, TRUE, FALSE, FALSE);
4233 reward = _("高級品のアイテムを手に入れた。", "an excellent item");
4238 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4239 msg_print(_("「汝の行いは貴き剣に値せり。」", "'Thy deed hath earned thee a worthy blade.'"));
4242 switch (randint1(p_ptr->lev))
4248 dummy2 = SV_MAIN_GAUCHE;
4257 dummy2 = SV_SMALL_SWORD;
4260 dummy2 = SV_BASILLARD;
4262 case 11: case 12: case 13:
4263 dummy2 = SV_SHORT_SWORD;
4269 dummy2 = SV_CUTLASS;
4272 dummy2 = SV_WAKIZASHI;
4275 dummy2 = SV_KHOPESH;
4281 dummy2 = SV_BROAD_SWORD;
4284 dummy2 = SV_LONG_SWORD;
4287 dummy2 = SV_SCIMITAR;
4290 dummy2 = SV_NINJATO;
4296 dummy2 = SV_BASTARD_SWORD;
4299 dummy2 = SV_GREAT_SCIMITAR;
4302 dummy2 = SV_CLAYMORE;
4305 dummy2 = SV_ESPADON;
4308 dummy2 = SV_TWO_HANDED_SWORD;
4311 dummy2 = SV_FLAMBERGE;
4314 dummy2 = SV_NO_DACHI;
4317 dummy2 = SV_EXECUTIONERS_SWORD;
4320 dummy2 = SV_ZWEIHANDER;
4323 dummy2 = SV_HAYABUSA;
4326 dummy2 = SV_BLADE_OF_CHAOS;
4329 object_prep(q_ptr, lookup_kind(dummy, dummy2));
4330 q_ptr->to_h = 3 + randint1(dun_level) % 10;
4331 q_ptr->to_d = 3 + randint1(dun_level) % 10;
4332 one_resistance(q_ptr);
4333 q_ptr->name2 = EGO_CHAOTIC;
4335 /* Drop it in the dungeon */
4336 (void)drop_near(q_ptr, -1, p_ptr->y, p_ptr->x);
4337 reward = _("(混沌)の武器を手に入れた。", "chaos weapon");
4342 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4343 msg_print(_("「汝の行いは貴き報いに値せり。」", "'Thy deed hath earned thee a worthy reward.'"));
4345 acquirement(p_ptr->y, p_ptr->x, randint1(2) + 1, FALSE, FALSE, FALSE);
4346 reward = _("上質なアイテムを手に入れた。", "good items");
4351 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4352 msg_print(_("「下僕よ、汝の献身への我が惜しみ無き報いを見るがよい。」", "'Behold, mortal, how generously I reward thy loyalty.'"));
4354 acquirement(p_ptr->y, p_ptr->x, randint1(2) + 1, TRUE, FALSE, FALSE);
4355 reward = _("高級品のアイテムを手に入れた。", "excellent items");
4360 msg_format("%sの声が轟き渡った:", chaos_patrons[p_ptr->chaos_patron]);
4362 msg_format("The voice of %s thunders:", chaos_patrons[p_ptr->chaos_patron]);
4365 msg_print(_("「下僕よ、汝傲慢なり。」", "'Thou art growing arrogant, mortal.'"));
4367 (void)activate_ty_curse(FALSE, &count);
4368 reward = _("禍々しい呪いをかけられた。", "cursing");
4373 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4374 msg_print(_("「我が下僕たちよ、かの傲慢なる者を倒すべし!」", "'My pets, destroy the arrogant mortal!'"));
4376 for (dummy = 0; dummy < randint1(5) + 1; dummy++)
4378 (void)summon_specific(0, p_ptr->y, p_ptr->x, dun_level, 0, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET));
4380 reward = _("モンスターを召喚された。", "summoning hostile monsters");
4386 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4387 msg_print(_("「汝、より強き敵を必要とせり!」", "'Thou needst worthier opponents!'"));
4389 activate_hi_summon(p_ptr->y, p_ptr->x, FALSE);
4390 reward = _("モンスターを召喚された。", "summoning many hostile monsters");
4396 msg_format("%sの声が響き渡った:",
4397 chaos_patrons[p_ptr->chaos_patron]);
4399 msg_format("The voice of %s booms out:",
4400 chaos_patrons[p_ptr->chaos_patron]);
4403 msg_print(_("「死と破壊こそ我が喜びなり!」", "'Death and destruction! This pleaseth me!'"));
4406 reward = _("カオスの力が渦巻いた。", "calling chaos");
4412 msg_format("%sの声が鳴り響いた:",
4413 chaos_patrons[p_ptr->chaos_patron]);
4415 msg_format("The voice of %s rings out:",
4416 chaos_patrons[p_ptr->chaos_patron]);
4419 msg_print(_("「留まるのだ、下僕よ。余が汝の肉体を鍛えん。」", "'Stay, mortal, and let me mold thee.'"));
4421 if (one_in_(3) && !(chaos_stats[p_ptr->chaos_patron] < 0))
4422 do_inc_stat(chaos_stats[p_ptr->chaos_patron]);
4424 do_inc_stat(randint0(6));
4425 reward = _("能力値が上がった。", "increasing a stat");
4431 msg_format("%sの声が響き渡った:",
4432 chaos_patrons[p_ptr->chaos_patron]);
4434 msg_format("The voice of %s booms out:",
4435 chaos_patrons[p_ptr->chaos_patron]);
4438 msg_print(_("「下僕よ、余は汝に飽みたり。」", "'I grow tired of thee, mortal.'"));
4440 if (one_in_(3) && !(chaos_stats[p_ptr->chaos_patron] < 0))
4441 do_dec_stat(chaos_stats[p_ptr->chaos_patron]);
4443 (void)do_dec_stat(randint0(6));
4444 reward = _("能力値が下がった。", "decreasing a stat");
4451 msg_format("%sの声が轟き渡った:",
4452 chaos_patrons[p_ptr->chaos_patron]);
4454 msg_format("The voice of %s thunders:",
4455 chaos_patrons[p_ptr->chaos_patron]);
4458 msg_print(_("「汝、謙虚たることを学ぶべし!」", "'Thou needst a lesson in humility, mortal!'"));
4459 msg_print(_("あなたは以前より弱くなった!", "You feel less powerful!"));
4461 for (dummy = 0; dummy < 6; dummy++)
4463 (void)dec_stat(dummy, 10 + randint1(15), TRUE);
4465 reward = _("全能力値が下がった。", "decreasing all stats");
4470 msg_format(_("%sの力が触れるのを感じた。", "You feel the power of %s touch you."),
4471 chaos_patrons[p_ptr->chaos_patron]);
4473 reward = _("傷が変化した。", "polymorphing wounds");
4478 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4480 msg_print(_("「我がささやかなる賜物を受けとるがよい!」", "'Receive this modest gift from me!'"));
4482 for (dummy = 0; dummy < 6; dummy++)
4484 (void)do_inc_stat(dummy);
4486 reward = _("全能力値が上がった。", "increasing all stats");
4491 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4492 msg_print(_("「苦しむがよい、無能な愚か者よ!」", "'Suffer, pathetic fool!'"));
4494 fire_ball(GF_DISINTEGRATE, 0, p_ptr->lev * 4, 4);
4495 take_hit(DAMAGE_NOESCAPE, p_ptr->lev * 4, wrath_reason, -1);
4496 reward = _("分解の球が発生した。", "generating disintegration ball");
4501 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4502 (void)restore_level();
4503 (void)restore_all_status();
4504 (void)true_healing(5000);
4505 reward = _("体力が回復した。", "healing");
4510 if (!buki_motteruka(INVEN_RARM) && !buki_motteruka(INVEN_LARM)) break;
4511 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4512 msg_print(_("「汝、武器に頼ることなかれ。」", "'Thou reliest too much on thy weapon.'"));
4515 if (buki_motteruka(INVEN_LARM))
4518 if (buki_motteruka(INVEN_RARM) && one_in_(2)) dummy = INVEN_RARM;
4520 object_desc(o_name, &inventory[dummy], OD_NAME_ONLY);
4521 (void)curse_weapon(FALSE, dummy);
4522 reward = format(_("%sが破壊された。", "destroying %s"), o_name);
4527 if (!inventory[INVEN_BODY].k_idx) break;
4528 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4529 msg_print(_("「汝、防具に頼ることなかれ。」", "'Thou reliest too much on thine equipment.'"));
4531 object_desc(o_name, &inventory[INVEN_BODY], OD_NAME_ONLY);
4532 (void)curse_armor();
4533 reward = format(_("%sが破壊された。", "destroying %s"), o_name);
4537 msg_format(_("%sの声がささやいた:", "The voice of %s whispers:"), chaos_patrons[p_ptr->chaos_patron]);
4538 msg_print(_("「我を怒りしめた罪を償うべし。」", "'Now thou shalt pay for annoying me.'"));
4540 switch (randint1(4))
4543 (void)activate_ty_curse(FALSE, &count);
4544 reward = _("禍々しい呪いをかけられた。", "cursing");
4547 activate_hi_summon(p_ptr->y, p_ptr->x, FALSE);
4548 reward = _("モンスターを召喚された。", "summoning hostile monsters");
4553 if (!buki_motteruka(INVEN_RARM) && !buki_motteruka(INVEN_LARM)) break;
4555 if (buki_motteruka(INVEN_LARM))
4558 if (buki_motteruka(INVEN_RARM) && one_in_(2)) dummy = INVEN_RARM;
4560 object_desc(o_name, &inventory[dummy], OD_NAME_ONLY);
4561 (void)curse_weapon(FALSE, dummy);
4562 reward = format(_("%sが破壊された。", "destroying %s"), o_name);
4566 if (!inventory[INVEN_BODY].k_idx) break;
4567 object_desc(o_name, &inventory[INVEN_BODY], OD_NAME_ONLY);
4568 (void)curse_armor();
4569 reward = format(_("%sが破壊された。", "destroying %s"), o_name);
4573 for (dummy = 0; dummy < 6; dummy++)
4575 (void)dec_stat(dummy, 10 + randint1(15), TRUE);
4577 reward = _("全能力値が下がった。", "decreasing all stats");
4584 msg_format(_("%sの声が轟き渡った:", "The voice of %s thunders:"), chaos_patrons[p_ptr->chaos_patron]);
4585 msg_print(_("「死ぬがよい、下僕よ!」", "'Die, mortal!'"));
4587 take_hit(DAMAGE_LOSELIFE, p_ptr->lev * 4, wrath_reason, -1);
4588 for (dummy = 0; dummy < 6; dummy++)
4590 (void)dec_stat(dummy, 10 + randint1(15), FALSE);
4592 activate_hi_summon(p_ptr->y, p_ptr->x, FALSE);
4593 (void)activate_ty_curse(FALSE, &count);
4598 if (buki_motteruka(INVEN_RARM))
4601 if (buki_motteruka(INVEN_LARM) && one_in_(2)) dummy = INVEN_LARM;
4603 else if (buki_motteruka(INVEN_LARM)) dummy = INVEN_LARM;
4605 if (dummy) (void)curse_weapon(FALSE, dummy);
4607 if (one_in_(2)) (void)curse_armor();
4612 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4613 msg_print(_("「死と破壊こそ我が喜びなり!」", "'Death and destruction! This pleaseth me!'"));
4615 (void)destroy_area(p_ptr->y, p_ptr->x, 25, FALSE);
4616 reward = _("ダンジョンが*破壊*された。", "*destruct*ing dungeon");
4621 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4622 msg_print(_("「我、汝の敵を抹殺せん!」", "'Let me relieve thee of thine oppressors!'"));
4623 (void)symbol_genocide(0, FALSE);
4624 reward = _("モンスターが抹殺された。", "genociding monsters");
4629 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4630 msg_print(_("「我、汝の敵を抹殺せん!」", "'Let me relieve thee of thine oppressors!'"));
4632 (void)mass_genocide(0, FALSE);
4633 reward = _("モンスターが抹殺された。", "genociding nearby monsters");
4638 msg_format(_("%sの力が敵を攻撃するのを感じた!", "You can feel the power of %s assault your enemies!"), chaos_patrons[p_ptr->chaos_patron]);
4639 (void)dispel_monsters(p_ptr->lev * 4);
4644 msg_format(_("%sはあなたを無視した。", "%s ignores you."), chaos_patrons[p_ptr->chaos_patron]);
4649 msg_format(_("%sは褒美として悪魔の使いをよこした!", "%s rewards you with a demonic servant!"),chaos_patrons[p_ptr->chaos_patron]);
4651 if (!summon_specific(-1, p_ptr->y, p_ptr->x, dun_level, SUMMON_DEMON, PM_FORCE_PET))
4652 msg_print(_("何も現れなかった...", "Nobody ever turns up..."));
4654 reward = _("悪魔がペットになった。", "a demonic servant");
4659 msg_format(_("%sは褒美として使いをよこした!", "%s rewards you with a servant!"),chaos_patrons[p_ptr->chaos_patron]);
4661 if (!summon_specific(-1, p_ptr->y, p_ptr->x, dun_level, 0, PM_FORCE_PET))
4662 msg_print(_("何も現れなかった...", "Nobody ever turns up..."));
4664 reward = _("モンスターがペットになった。", "a servant");
4669 msg_format(_("%sは褒美としてアンデッドの使いをよこした。", "%s rewards you with an undead servant!"),chaos_patrons[p_ptr->chaos_patron]);
4671 if (!summon_specific(-1, p_ptr->y, p_ptr->x, dun_level, SUMMON_UNDEAD, PM_FORCE_PET))
4672 msg_print(_("何も現れなかった...", "Nobody ever turns up..."));
4674 reward = _("アンデッドがペットになった。", "an undead servant");
4679 msg_format(_("%sの声がどもった:", "The voice of %s stammers:"),
4681 chaos_patrons[p_ptr->chaos_patron]);
4682 msg_format(_("「あー、あー、答えは %d/%d。質問は何?」", "'Uh... uh... the answer's %d/%d, what's the question?'"), type, effect);
4688 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, format(_("パトロンの報酬で%s", "The patron rewards you with %s."), reward));
4694 * XAngband: determine if a given location is "interesting"
4695 * based on target_set_accept function.
4697 static bool tgt_pt_accept(POSITION y, POSITION x)
4702 if (!(in_bounds(y, x))) return (FALSE);
4704 /* Player grid is always interesting */
4705 if ((y == p_ptr->y) && (x == p_ptr->x)) return (TRUE);
4707 /* Handle hallucination */
4708 if (p_ptr->image) return (FALSE);
4710 /* Examine the grid */
4711 c_ptr = &cave[y][x];
4713 /* Interesting memorized features */
4714 if (c_ptr->info & (CAVE_MARK))
4717 if (cave_have_flag_grid(c_ptr, FF_LESS)) return (TRUE);
4718 if (cave_have_flag_grid(c_ptr, FF_MORE)) return (TRUE);
4720 /* Notice quest features */
4721 if (cave_have_flag_grid(c_ptr, FF_QUEST_ENTER)) return (TRUE);
4722 if (cave_have_flag_grid(c_ptr, FF_QUEST_EXIT)) return (TRUE);
4730 * XAngband: Prepare the "temp" array for "tget_pt"
4731 * based on target_set_prepare funciton.
4733 static void tgt_pt_prepare(void)
4737 /* Reset "temp" array */
4740 if (!expand_list) return;
4742 /* Scan the current panel */
4743 for (y = 1; y < cur_hgt; y++)
4745 for (x = 1; x < cur_wid; x++)
4747 /* Require "interesting" contents */
4748 if (!tgt_pt_accept(y, x)) continue;
4750 /* Save the location */
4757 /* Target the nearest monster for shooting */
4758 ang_sort_comp = ang_sort_comp_distance;
4759 ang_sort_swap = ang_sort_swap_distance;
4761 /* Sort the positions */
4762 ang_sort(temp_x, temp_y, temp_n);
4766 * old -- from PsiAngband.
4768 bool tgt_pt(POSITION *x_ptr, POSITION *y_ptr)
4773 bool success = FALSE;
4777 get_screen_size(&wid, &hgt);
4787 msg_print(_("場所を選んでスペースキーを押して下さい。", "Select a point and press space."));
4788 msg_flag = FALSE; /* prevents "-more-" message. */
4790 while ((ch != ESCAPE) && !success)
4792 bool move_fast = FALSE;
4794 move_cursor_relative(y, x);
4806 if (player_bold(y, x)) ch = 0;
4809 else success = TRUE;
4813 /* XAngband: Move cursor to stairs */
4816 if (expand_list && temp_n)
4819 int cx = (panel_col_min + panel_col_max) / 2;
4820 int cy = (panel_row_min + panel_row_max) / 2;
4824 /* Skip stairs which have defferent distance */
4825 for (; n < temp_n; ++ n)
4827 cave_type *c_ptr = &cave[temp_y[n]][temp_x[n]];
4829 if (cave_have_flag_grid(c_ptr, FF_STAIRS) &&
4830 cave_have_flag_grid(c_ptr, ch == '>' ? FF_MORE : FF_LESS))
4837 if (n == temp_n) /* Loop out taget list */
4842 verify_panel(); /* Move cursor to player */
4844 p_ptr->update |= (PU_MONSTERS);
4846 p_ptr->redraw |= (PR_MAP);
4848 p_ptr->window |= (PW_OVERHEAD);
4851 else /* move cursor to next stair and change panel */
4856 dy = 2 * (y - cy) / hgt;
4857 dx = 2 * (x - cx) / wid;
4858 if (dy || dx) change_panel(dy, dx);
4864 /* Look up the direction */
4865 d = get_keymap_dir(ch);
4867 /* XTRA HACK MOVEFAST */
4868 if (isupper(ch)) move_fast = TRUE;
4870 /* Handle "direction" */
4876 /* XTRA HACK MOVEFAST */
4879 int mag = MIN(wid / 2, hgt / 2);
4889 /* Do not move horizontally if unnecessary */
4890 if (((x < panel_col_min + wid / 2) && (dx > 0)) ||
4891 ((x > panel_col_min + wid / 2) && (dx < 0)))
4896 /* Do not move vertically if unnecessary */
4897 if (((y < panel_row_min + hgt / 2) && (dy > 0)) ||
4898 ((y > panel_row_min + hgt / 2) && (dy < 0)))
4903 /* Apply the motion */
4904 if ((y >= panel_row_min + hgt) || (y < panel_row_min) ||
4905 (x >= panel_col_min + wid) || (x < panel_col_min))
4907 /* if (change_panel(dy, dx)) target_set_prepare(mode); */
4908 change_panel(dy, dx);
4911 /* Slide into legality */
4912 if (x >= cur_wid-1) x = cur_wid - 2;
4913 else if (x <= 0) x = 1;
4915 /* Slide into legality */
4916 if (y >= cur_hgt-1) y = cur_hgt- 2;
4917 else if (y <= 0) y = 1;
4924 /* Clear the top line */
4927 /* Recenter the map around the player */
4930 p_ptr->update |= (PU_MONSTERS);
4932 p_ptr->redraw |= (PR_MAP);
4934 p_ptr->window |= (PW_OVERHEAD);
4943 bool get_hack_dir(DIRECTION *dp)
4951 /* Global direction */
4954 /* (No auto-targeting) */
4956 /* Ask until satisfied */
4959 /* Choose a prompt */
4962 p = _("方向 ('*'でターゲット選択, ESCで中断)? ", "Direction ('*' to choose a target, Escape to cancel)? ");
4966 p = _("方向 ('5'でターゲットへ, '*'でターゲット再選択, ESCで中断)? ", "Direction ('5' for target, '*' to re-target, Escape to cancel)? ");
4969 /* Get a command (or Cancel) */
4970 if (!get_com(p, &command, TRUE)) break;
4974 if (command == '\r') command = 't';
4977 /* Convert various keys to "standard" keys */
4980 /* Use current target */
4991 /* Set new target */
4996 if (target_set(TARGET_KILL)) dir = 5;
5002 /* Look up the direction */
5003 dir = get_keymap_dir(command);
5009 /* Verify requested targets */
5010 if ((dir == 5) && !target_okay()) dir = 0;
5017 if (!dir) return (FALSE);
5019 /* Save the direction */
5022 /* Check for confusion */
5023 if (p_ptr->confused)
5025 /* Random direction */
5026 dir = ddd[randint0(8)];
5029 /* Notice confusion */
5030 if (command_dir != dir)
5033 msg_print(_("あなたは混乱している。", "You are confused."));
5036 /* Save direction */
5039 /* A "valid" direction was entered */
5045 * エネルギーの増加量10d5を速く計算するための関数
5048 #define Go_no_JuuJou 5*5*5*5*5*5*5*5*5*5
5050 s16b gain_energy(void)
5053 s32b energy_result = 10;
5056 tmp = randint0(Go_no_JuuJou);
5058 for (i = 0; i < 9; i ++){
5059 energy_result += tmp % 5;
5063 return (s16b)(energy_result + tmp);
5068 * @brief 射撃武器の攻撃に必要な基本消費エネルギーを返す/Return bow energy
5069 * @param sval 射撃武器のアイテム副分類ID
5070 * @return 消費する基本エネルギー
5072 ENERGY bow_energy(OBJECT_SUBTYPE_VALUE sval)
5074 ENERGY energy = 10000;
5076 /* Analyze the launcher */
5079 /* Sling and ammo */
5086 /* Short Bow and Arrow */
5093 /* Long Bow and Arrow */
5100 /* Bow of irresponsiblity and Arrow */
5107 /* Light Crossbow and Bolt */
5114 /* Heavy Crossbow and Bolt */
5129 int bow_tmul(OBJECT_SUBTYPE_VALUE sval)
5133 /* Analyze the launcher */
5136 /* Sling and ammo */
5143 /* Short Bow and Arrow */
5150 /* Long Bow and Arrow */
5157 /* Bow of irresponsiblity and Arrow */
5164 /* Light Crossbow and Bolt */
5171 /* Heavy Crossbow and Bolt */
5183 * Return alignment title
5185 cptr your_alignment(void)
5188 if (p_ptr->align > 150) return "大善";
5189 else if (p_ptr->align > 50) return "中善";
5190 else if (p_ptr->align > 10) return "小善";
5191 else if (p_ptr->align > -11) return "中立";
5192 else if (p_ptr->align > -51) return "小悪";
5193 else if (p_ptr->align > -151) return "中悪";
5196 if (p_ptr->align > 150) return "Lawful";
5197 else if (p_ptr->align > 50) return "Good";
5198 else if (p_ptr->align > 10) return "Neutral Good";
5199 else if (p_ptr->align > -11) return "Neutral";
5200 else if (p_ptr->align > -51) return "Neutral Evil";
5201 else if (p_ptr->align > -151) return "Evil";
5202 else return "Chaotic";
5208 * Return proficiency level of weapons and misc. skills (except riding)
5210 int weapon_exp_level(int weapon_exp)
5212 if (weapon_exp < WEAPON_EXP_BEGINNER) return EXP_LEVEL_UNSKILLED;
5213 else if (weapon_exp < WEAPON_EXP_SKILLED) return EXP_LEVEL_BEGINNER;
5214 else if (weapon_exp < WEAPON_EXP_EXPERT) return EXP_LEVEL_SKILLED;
5215 else if (weapon_exp < WEAPON_EXP_MASTER) return EXP_LEVEL_EXPERT;
5216 else return EXP_LEVEL_MASTER;
5221 * Return proficiency level of riding
5223 int riding_exp_level(int riding_exp)
5225 if (riding_exp < RIDING_EXP_BEGINNER) return EXP_LEVEL_UNSKILLED;
5226 else if (riding_exp < RIDING_EXP_SKILLED) return EXP_LEVEL_BEGINNER;
5227 else if (riding_exp < RIDING_EXP_EXPERT) return EXP_LEVEL_SKILLED;
5228 else if (riding_exp < RIDING_EXP_MASTER) return EXP_LEVEL_EXPERT;
5229 else return EXP_LEVEL_MASTER;
5234 * Return proficiency level of spells
5236 int spell_exp_level(int spell_exp)
5238 if (spell_exp < SPELL_EXP_BEGINNER) return EXP_LEVEL_UNSKILLED;
5239 else if (spell_exp < SPELL_EXP_SKILLED) return EXP_LEVEL_BEGINNER;
5240 else if (spell_exp < SPELL_EXP_EXPERT) return EXP_LEVEL_SKILLED;
5241 else if (spell_exp < SPELL_EXP_MASTER) return EXP_LEVEL_EXPERT;
5242 else return EXP_LEVEL_MASTER;
5247 * Display a rumor and apply its effects
5250 IDX rumor_num(char *zz, IDX max_idx)
5252 if (strcmp(zz, "*") == 0) return randint1(max_idx - 1);
5253 return (IDX)atoi(zz);
5256 cptr rumor_bind_name(char *base, cptr fullname)
5260 s = strstr(base, "{Name}");
5264 v = format("%s%s%s", base, fullname, (s + 6));
5274 void display_rumor(bool ex)
5282 if (randint0(3) == 0) section = 1;
5285 err = _(get_rnd_line_jonly("rumors_j.txt", section, Rumor, 10),
5286 get_rnd_line("rumors.txt", section, Rumor));
5287 if (err) strcpy(Rumor, _("嘘の噂もある。", "Some rumors are wrong."));
5291 if (strncmp(Rumor, "R:", 2) == 0)
5294 cptr rumor_msg = NULL;
5295 cptr rumor_eff_format = NULL;
5296 char fullname[1024] = "";
5298 if (tokenize(Rumor + 2, 3, zz, TOKENIZE_CHECKQUOTE) == 3)
5300 if (strcmp(zz[0], "ARTIFACT") == 0)
5304 object_type *q_ptr = &forge;
5305 artifact_type *a_ptr;
5309 a_idx = rumor_num(zz[1], max_a_idx);
5311 a_ptr = &a_info[a_idx];
5312 if (a_ptr->name) break;
5315 k_idx = lookup_kind(a_ptr->tval, a_ptr->sval);
5316 object_prep(q_ptr, k_idx);
5317 q_ptr->name1 = a_idx;
5318 q_ptr->ident = IDENT_STORE;
5319 object_desc(fullname, q_ptr, OD_NAME_ONLY);
5321 else if (strcmp(zz[0], "MONSTER") == 0)
5324 monster_race *r_ptr;
5328 r_idx = rumor_num(zz[1], max_r_idx);
5329 r_ptr = &r_info[r_idx];
5330 if (r_ptr->name) break;
5333 strcpy(fullname, r_name + r_ptr->name);
5335 /* Remember this monster */
5336 if (!r_ptr->r_sights)
5341 else if (strcmp(zz[0], "DUNGEON") == 0)
5344 dungeon_info_type *d_ptr;
5348 d_idx = rumor_num(zz[1], max_d_idx);
5349 d_ptr = &d_info[d_idx];
5350 if (d_ptr->name) break;
5353 strcpy(fullname, d_name + d_ptr->name);
5355 if (!max_dlv[d_idx])
5357 max_dlv[d_idx] = d_ptr->mindepth;
5358 rumor_eff_format = _("%sに帰還できるようになった。", "You can recall to %s.");
5361 else if (strcmp(zz[0], "TOWN") == 0)
5368 t_idx = rumor_num(zz[1], NO_TOWN);
5369 if (town[t_idx].name) break;
5372 strcpy(fullname, town[t_idx].name);
5374 visit = (1L << (t_idx - 1));
5375 if ((t_idx != SECRET_TOWN) && !(p_ptr->visit & visit))
5377 p_ptr->visit |= visit;
5378 rumor_eff_format = _("%sに行ったことがある気がする。", "You feel you have been to %s.");
5382 rumor_msg = rumor_bind_name(zz[2], fullname);
5383 msg_print(rumor_msg);
5384 if (rumor_eff_format)
5387 msg_format(rumor_eff_format, fullname);
5392 if (err) msg_print(_("この情報は間違っている。", "This information is wrong."));
5396 msg_format("%s", Rumor);