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"
18 #define REWARD_CHANCE 10
22 * @brief プレイヤーの経験値について整合性のためのチェックと調整を行う /
23 * Advance experience levels and print experience
26 void check_experience(void)
28 bool level_reward = FALSE;
29 bool level_mutation = FALSE;
30 bool level_inc_stat = FALSE;
31 bool android = (p_ptr->prace == RACE_ANDROID ? TRUE : FALSE);
32 PLAYER_LEVEL old_lev = p_ptr->lev;
34 /* Hack -- lower limit */
35 if (p_ptr->exp < 0) p_ptr->exp = 0;
36 if (p_ptr->max_exp < 0) p_ptr->max_exp = 0;
37 if (p_ptr->max_max_exp < 0) p_ptr->max_max_exp = 0;
39 /* Hack -- upper limit */
40 if (p_ptr->exp > PY_MAX_EXP) p_ptr->exp = PY_MAX_EXP;
41 if (p_ptr->max_exp > PY_MAX_EXP) p_ptr->max_exp = PY_MAX_EXP;
42 if (p_ptr->max_max_exp > PY_MAX_EXP) p_ptr->max_max_exp = PY_MAX_EXP;
44 /* Hack -- maintain "max" experience */
45 if (p_ptr->exp > p_ptr->max_exp) p_ptr->max_exp = p_ptr->exp;
47 /* Hack -- maintain "max max" experience */
48 if (p_ptr->max_exp > p_ptr->max_max_exp) p_ptr->max_max_exp = p_ptr->max_exp;
50 /* Redraw experience */
51 p_ptr->redraw |= (PR_EXP);
55 /* Lose levels while possible */
56 while ((p_ptr->lev > 1) &&
57 (p_ptr->exp < ((android ? player_exp_a : player_exp)[p_ptr->lev - 2] * p_ptr->expfact / 100L)))
62 /* Update some stuff */
63 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
65 /* Redraw some stuff */
66 p_ptr->redraw |= (PR_LEV | PR_TITLE);
68 p_ptr->window |= (PW_PLAYER);
73 /* Gain levels while possible */
74 while ((p_ptr->lev < PY_MAX_LEVEL) &&
75 (p_ptr->exp >= ((android ? player_exp_a : player_exp)[p_ptr->lev-1] * p_ptr->expfact / 100L)))
80 /* Save the highest level */
81 if (p_ptr->lev > p_ptr->max_plv)
83 p_ptr->max_plv = p_ptr->lev;
85 if ((p_ptr->pclass == CLASS_CHAOS_WARRIOR) ||
86 (p_ptr->muta2 & MUT2_CHAOS_GIFT))
90 if (p_ptr->prace == RACE_BEASTMAN)
92 if (one_in_(5)) level_mutation = TRUE;
94 level_inc_stat = TRUE;
96 do_cmd_write_nikki(NIKKI_LEVELUP, p_ptr->lev, NULL);
101 msg_format(_("レベル %d にようこそ。", "Welcome to level %d."), p_ptr->lev);
103 /* Update some stuff */
104 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
106 /* Redraw some stuff */
107 p_ptr->redraw |= (PR_LEV | PR_TITLE | PR_EXP);
109 p_ptr->window |= (PW_PLAYER | PW_SPELL | PW_INVEN);
119 if(!(p_ptr->max_plv % 10))
129 cnv_stat(p_ptr->stat_max[0], tmp);
130 prt(format(" a) 腕力 (現在値 %s)", tmp), 2, 14);
131 cnv_stat(p_ptr->stat_max[1], tmp);
132 prt(format(" b) 知能 (現在値 %s)", tmp), 3, 14);
133 cnv_stat(p_ptr->stat_max[2], tmp);
134 prt(format(" c) 賢さ (現在値 %s)", tmp), 4, 14);
135 cnv_stat(p_ptr->stat_max[3], tmp);
136 prt(format(" d) 器用 (現在値 %s)", tmp), 5, 14);
137 cnv_stat(p_ptr->stat_max[4], tmp);
138 prt(format(" e) 耐久 (現在値 %s)", tmp), 6, 14);
139 cnv_stat(p_ptr->stat_max[5], tmp);
140 prt(format(" f) 魅力 (現在値 %s)", tmp), 7, 14);
142 prt(" どの能力値を上げますか?", 1, 14);
144 cnv_stat(p_ptr->stat_max[0], tmp);
145 prt(format(" a) Str (cur %s)", tmp), 2, 14);
146 cnv_stat(p_ptr->stat_max[1], tmp);
147 prt(format(" b) Int (cur %s)", tmp), 3, 14);
148 cnv_stat(p_ptr->stat_max[2], tmp);
149 prt(format(" c) Wis (cur %s)", tmp), 4, 14);
150 cnv_stat(p_ptr->stat_max[3], tmp);
151 prt(format(" d) Dex (cur %s)", tmp), 5, 14);
152 cnv_stat(p_ptr->stat_max[4], tmp);
153 prt(format(" e) Con (cur %s)", tmp), 6, 14);
154 cnv_stat(p_ptr->stat_max[5], tmp);
155 prt(format(" f) Chr (cur %s)", tmp), 7, 14);
157 prt(" Which stat do you want to raise?", 1, 14);
162 if ((choice >= 'a') && (choice <= 'f')) break;
164 for(n = 0; n < 6; n++)
165 if (n != choice - 'a')
167 if (get_check(_("よろしいですか?", "Are you sure? "))) break;
169 do_inc_stat(choice - 'a');
172 else if(!(p_ptr->max_plv % 2))
173 do_inc_stat(randint0(6));
178 msg_print(_("あなたは変わった気がする...", "You feel different..."));
179 (void)gain_random_mutation(0);
180 level_mutation = FALSE;
184 * 報酬でレベルが上ると再帰的に check_experience() が
189 gain_level_reward(0);
190 level_reward = FALSE;
193 /* Update some stuff */
194 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
196 /* Redraw some stuff */
197 p_ptr->redraw |= (PR_LEV | PR_TITLE);
199 p_ptr->window |= (PW_PLAYER | PW_SPELL);
203 /* Load an autopick preference file */
204 if (old_lev != p_ptr->lev) autopick_load_pref(FALSE);
209 * @brief モンスターを倒した際の財宝svalを返す
210 * @param r_idx 倒したモンスターの種族ID
213 * Hack -- Return the "automatic coin type" of a monster race
214 * Used to allocate proper treasure when "Creeping coins" die
215 * Note the use of actual "monster names"
217 static int get_coin_type(MONRACE_IDX r_idx)
219 /* Analyze monsters */
222 case MON_COPPER_COINS: return 2;
223 case MON_SILVER_COINS: return 5;
224 case MON_GOLD_COINS: return 10;
225 case MON_MITHRIL_COINS:
226 case MON_MITHRIL_GOLEM: return 16;
227 case MON_ADAMANT_COINS: return 17;
236 * @brief オブジェクトがクロークかどうかを判定する /
237 * Hack -- determine if a template is Cloak
238 * @param k_idx 判定したいオブジェクトのベースアイテムID
239 * @return オブジェクトがクロークならばTRUEを返す
241 static bool kind_is_cloak(KIND_OBJECT_IDX k_idx)
243 object_kind *k_ptr = &k_info[k_idx];
245 /* Analyze the item type */
246 if (k_ptr->tval == TV_CLOAK)
251 /* Assume not good */
257 * @brief オブジェクトが竿状武器かどうかを判定する /
258 * Hack -- determine if a template is Polearm
259 * @param k_idx 判定したいオブジェクトのベースアイテムID
260 * @return オブジェクトが竿状武器ならばTRUEを返す
262 static bool kind_is_polearm(KIND_OBJECT_IDX k_idx)
264 object_kind *k_ptr = &k_info[k_idx];
266 /* Analyze the item type */
267 if (k_ptr->tval == TV_POLEARM)
272 /* Assume not good */
278 * @brief オブジェクトが剣かどうかを判定する /
279 * Hack -- determine if a template is Sword
280 * @param k_idx 判定したいオブジェクトのベースアイテムID
281 * @return オブジェクトが剣ならばTRUEを返す
283 static bool kind_is_sword(KIND_OBJECT_IDX k_idx)
285 object_kind *k_ptr = &k_info[k_idx];
287 /* Analyze the item type */
288 if ((k_ptr->tval == TV_SWORD) && (k_ptr->sval > 2))
293 /* Assume not good */
299 * @brief オブジェクトが魔法書かどうかを判定する /
300 * Hack -- determine if a template is Book
301 * @param k_idx 判定したいオブジェクトのベースアイテムID
302 * @return オブジェクトが魔法書ならばTRUEを返す
304 static bool kind_is_book(KIND_OBJECT_IDX k_idx)
306 object_kind *k_ptr = &k_info[k_idx];
308 /* Analyze the item type */
309 if ((k_ptr->tval >= TV_LIFE_BOOK) && (k_ptr->tval <= TV_CRUSADE_BOOK))
314 /* Assume not good */
320 * @brief オブジェクトがベースアイテム時点でGOODかどうかを判定する /
321 * Hack -- determine if a template is Good book
322 * @param k_idx 判定したいオブジェクトのベースアイテムID
323 * @return オブジェクトがベースアイテム時点でGOODなアイテムならばTRUEを返す
325 static bool kind_is_good_book(KIND_OBJECT_IDX k_idx)
327 object_kind *k_ptr = &k_info[k_idx];
329 /* Analyze the item type */
330 if ((k_ptr->tval >= TV_LIFE_BOOK) && (k_ptr->tval <= TV_CRUSADE_BOOK) && (k_ptr->tval != TV_ARCANE_BOOK) && (k_ptr->sval > 1))
335 /* Assume not good */
341 * @brief オブジェクトが鎧かどうかを判定する /
342 * Hack -- determine if a template is Armor
343 * @param k_idx 判定したいオブジェクトのベースアイテムID
344 * @return オブジェクトが鎧ならばTRUEを返す
346 static bool kind_is_armor(KIND_OBJECT_IDX k_idx)
348 object_kind *k_ptr = &k_info[k_idx];
350 /* Analyze the item type */
351 if (k_ptr->tval == TV_HARD_ARMOR)
356 /* Assume not good */
362 * @brief オブジェクトが打撃武器かどうかを判定する /
363 * Hack -- determine if a template is hafted weapon
364 * @param k_idx 判定したいオブジェクトのベースアイテムID
365 * @return オブジェクトが打撃武器ならばTRUEを返す
367 static bool kind_is_hafted(KIND_OBJECT_IDX k_idx)
369 object_kind *k_ptr = &k_info[k_idx];
371 /* Analyze the item type */
372 if (k_ptr->tval == TV_HAFTED)
377 /* Assume not good */
382 * @brief クエストを達成状態にする /
383 * @param quest_num 達成状態にしたいクエストのID
386 void complete_quest(QUEST_IDX quest_num)
388 quest_type* const q_ptr = &quest[quest_num];
392 case QUEST_TYPE_RANDOM:
393 if (record_rand_quest) do_cmd_write_nikki(NIKKI_RAND_QUEST_C, quest_num, NULL);
396 if (record_fix_quest) do_cmd_write_nikki(NIKKI_FIX_QUEST_C, quest_num, NULL);
400 q_ptr->status = QUEST_STATUS_COMPLETED;
401 q_ptr->complev = (byte)p_ptr->lev;
403 q_ptr->comptime = playtime;
405 if (!(q_ptr->flags & QUEST_FLAG_SILENT))
407 play_music(TERM_XTRA_MUSIC_BASIC, MUSIC_BASIC_QUEST_CLEAR);
408 msg_print(_("クエストを達成した!", "You just completed your quest!"));
414 * @brief 現在フロアに残っている敵モンスターの数を返す /
415 * @return 現在の敵モンスターの数
417 static MONSTER_NUMBER count_all_hostile_monsters(void)
420 MONSTER_NUMBER number_mon = 0;
422 for (x = 0; x < cur_wid; ++ x)
424 for (y = 0; y < cur_hgt; ++ y)
426 MONSTER_IDX m_idx = cave[y][x].m_idx;
428 if (m_idx > 0 && is_hostile(&m_list[m_idx]))
439 * @brief 特定の敵を倒した際にクエスト達成処理 /
440 * Check for "Quest" completion when a quest monster is killed or charmed.
441 * @param m_ptr 撃破したモンスターの構造体参照ポインタ
444 void check_quest_completion(monster_type *m_ptr)
449 bool create_stairs = FALSE;
455 /* Get the location */
460 quest_num = p_ptr->inside_quest;
462 /* Search for an active quest on this dungeon level */
467 for (i = max_q_idx - 1; i > 0; i--)
469 quest_type* const q_ptr = &quest[i];
471 /* Quest is not active */
472 if (q_ptr->status != QUEST_STATUS_TAKEN)
475 /* Quest is not a dungeon quest */
476 if (q_ptr->flags & QUEST_FLAG_PRESET)
479 /* Quest is not on this level */
480 if ((q_ptr->level != dun_level) &&
481 (q_ptr->type != QUEST_TYPE_KILL_ANY_LEVEL))
484 /* Not a "kill monster" quest */
485 if ((q_ptr->type == QUEST_TYPE_FIND_ARTIFACT) ||
486 (q_ptr->type == QUEST_TYPE_FIND_EXIT))
489 /* Interesting quest */
490 if ((q_ptr->type == QUEST_TYPE_KILL_NUMBER) ||
491 (q_ptr->type == QUEST_TYPE_TOWER) ||
492 (q_ptr->type == QUEST_TYPE_KILL_ALL))
495 /* Interesting quest */
496 if (((q_ptr->type == QUEST_TYPE_KILL_LEVEL) ||
497 (q_ptr->type == QUEST_TYPE_KILL_ANY_LEVEL) ||
498 (q_ptr->type == QUEST_TYPE_RANDOM)) &&
499 (q_ptr->r_idx == m_ptr->r_idx))
506 /* Handle the current quest */
507 if (quest_num && (quest[quest_num].status == QUEST_STATUS_TAKEN))
510 quest_type* const q_ptr = &quest[quest_num];
514 case QUEST_TYPE_KILL_NUMBER:
518 if (q_ptr->cur_num >= q_ptr->num_mon)
520 complete_quest(quest_num);
526 case QUEST_TYPE_KILL_ALL:
528 if (!is_hostile(m_ptr)) break;
530 if (count_all_hostile_monsters() == 1)
532 if (q_ptr->flags & QUEST_FLAG_SILENT)
534 q_ptr->status = QUEST_STATUS_FINISHED;
538 complete_quest(quest_num);
543 case QUEST_TYPE_KILL_LEVEL:
544 case QUEST_TYPE_RANDOM:
546 /* Only count valid monsters */
547 if (q_ptr->r_idx != m_ptr->r_idx)
552 if (q_ptr->cur_num >= q_ptr->max_num)
554 complete_quest(quest_num);
556 if (!(q_ptr->flags & QUEST_FLAG_PRESET))
558 create_stairs = TRUE;
559 p_ptr->inside_quest = 0;
562 /* Finish the two main quests without rewarding */
563 if ((quest_num == QUEST_OBERON) || (quest_num == QUEST_SERPENT))
565 q_ptr->status = QUEST_STATUS_FINISHED;
568 if (q_ptr->type == QUEST_TYPE_RANDOM)
571 q_ptr->status = QUEST_STATUS_FINISHED;
576 case QUEST_TYPE_KILL_ANY_LEVEL:
579 if (q_ptr->cur_num >= q_ptr->max_num)
581 complete_quest(quest_num);
586 case QUEST_TYPE_TOWER:
588 if (!is_hostile(m_ptr)) break;
590 if (count_all_hostile_monsters() == 1)
592 q_ptr->status = QUEST_STATUS_STAGE_COMPLETED;
594 if((quest[QUEST_TOWER1].status == QUEST_STATUS_STAGE_COMPLETED) &&
595 (quest[QUEST_TOWER2].status == QUEST_STATUS_STAGE_COMPLETED) &&
596 (quest[QUEST_TOWER3].status == QUEST_STATUS_STAGE_COMPLETED))
599 complete_quest(QUEST_TOWER1);
607 /* Create a magical staircase */
613 while (cave_perma_bold(y, x) || cave[y][x].o_idx || (cave[y][x].info & CAVE_OBJECT) )
615 /* Pick a location */
616 scatter(&ny, &nx, y, x, 1, 0);
622 /* Explain the staircase */
623 msg_print(_("魔法の階段が現れた...", "A magical staircase appears..."));
625 /* Create stairs down */
626 cave_set_feat(y, x, feat_down_stair);
628 /* Remember to update everything */
629 p_ptr->update |= (PU_FLOW);
639 for (i = 0; i < (dun_level / 15)+1; i++)
644 /* Make a great object */
645 make_object(o_ptr, AM_GOOD | AM_GREAT);
647 /* Drop it in the dungeon */
648 (void)drop_near(o_ptr, -1, y, x);
654 * @brief 特定のアーティファクトを入手した際のクエスト達成処理 /
655 * Check for "Quest" completion when a quest monster is killed or charmed.
656 * @param o_ptr 入手したオブジェクトの構造体参照ポインタ
659 void check_find_art_quest_completion(object_type *o_ptr)
662 /* Check if completed a quest */
663 for (i = 0; i < max_q_idx; i++)
665 if((quest[i].type == QUEST_TYPE_FIND_ARTIFACT) &&
666 (quest[i].status == QUEST_STATUS_TAKEN) &&
667 (quest[i].k_idx == o_ptr->name1))
676 * @brief モンスターを撃破した際の述語メッセージを返す /
677 * Return monster death string
678 * @param r_ptr 撃破されたモンスターの種族情報を持つ構造体の参照ポインタ
679 * @return 撃破されたモンスターの述語
681 cptr extract_note_dies(monster_race *r_ptr)
683 /* Some monsters get "destroyed" */
684 if (!monster_living(r_ptr))
688 for (i = 0; i < 4; i++)
690 if (r_ptr->blow[i].method == RBM_EXPLODE)
692 return _("は爆発して粉々になった。", " explodes into tiny shreds.");
695 return _("を倒した。", " is destroyed.");
698 /* Assume a default death */
699 return _("は死んだ。", " dies.");
704 * @brief モンスターが死亡した時の処理 /
705 * Handle the "death" of a monster.
706 * @param m_idx 死亡したモンスターのID
707 * @param drop_item TRUEならばモンスターのドロップ処理を行う
708 * @return 撃破されたモンスターの述語
711 * Disperse treasures centered at the monster location based on the
712 * various flags contained in the monster flags fields.
713 * Check for "Quest" completion when a quest monster is killed.
714 * Note that only the player can induce "monster_death()" on Uniques.
715 * Thus (for now) all Quest monsters should be Uniques.
716 * Note that monsters can now carry objects, and when a monster dies,
717 * it drops all of its objects, which may disappear in crowded rooms.
720 void monster_death(MONSTER_IDX m_idx, bool drop_item)
729 monster_type *m_ptr = &m_list[m_idx];
731 monster_race *r_ptr = &r_info[m_ptr->r_idx];
733 bool visible = ((m_ptr->ml && !p_ptr->image) || (r_ptr->flags1 & RF1_UNIQUE));
737 bool do_gold = (!(r_ptr->flags1 & RF1_ONLY_ITEM));
738 bool do_item = (!(r_ptr->flags1 & RF1_ONLY_GOLD));
739 bool cloned = (m_ptr->smart & SM_CLONED) ? TRUE : FALSE;
740 int force_coin = get_coin_type(m_ptr->r_idx);
745 bool drop_chosen_item = drop_item && !cloned && !p_ptr->inside_arena
746 && !p_ptr->inside_battle && !is_pet(m_ptr);
748 /* The caster is dead? */
749 if (world_monster && world_monster == m_idx) world_monster = 0;
751 /* Notice changes in view */
752 if (r_ptr->flags7 & (RF7_LITE_MASK | RF7_DARK_MASK))
754 /* Update some things */
755 p_ptr->update |= (PU_MON_LITE);
758 /* Get the location */
762 if (record_named_pet && is_pet(m_ptr) && m_ptr->nickname)
766 monster_desc(m_name, m_ptr, MD_INDEF_VISIBLE);
767 do_cmd_write_nikki(NIKKI_NAMED_PET, 3, m_name);
770 /* Let monsters explode! */
771 for (i = 0; i < 4; i++)
773 if (r_ptr->blow[i].method == RBM_EXPLODE)
775 BIT_FLAGS flg = PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL;
776 EFFECT_ID typ = mbe_info[r_ptr->blow[i].effect].explode_type;
777 DICE_NUMBER d_dice = r_ptr->blow[i].d_dice;
778 DICE_SID d_side = r_ptr->blow[i].d_side;
779 HIT_POINT damage = damroll(d_dice, d_side);
781 project(m_idx, 3, y, x, damage, typ, flg, -1);
786 if (m_ptr->mflag2 & MFLAG2_CHAMELEON)
788 choose_new_monster(m_idx, TRUE, MON_CHAMELEON);
789 r_ptr = &r_info[m_ptr->r_idx];
792 /* Check for quest completion */
793 check_quest_completion(m_ptr);
795 /* Handle the possibility of player vanquishing arena combatant -KMW- */
796 if (p_ptr->inside_arena && !is_pet(m_ptr))
798 p_ptr->exit_bldg = TRUE;
800 if (p_ptr->arena_number > MAX_ARENA_MONS)
802 msg_print(_("素晴らしい!君こそ真の勝利者だ。", "You are a Genuine Champion!"));
806 msg_print(_("勝利!チャンピオンへの道を進んでいる。", "Victorious! You're on your way to becoming Champion."));
809 if (arena_info[p_ptr->arena_number].tval)
813 /* Prepare to make a prize */
814 object_prep(q_ptr, lookup_kind(arena_info[p_ptr->arena_number].tval, arena_info[p_ptr->arena_number].sval));
816 apply_magic(q_ptr, object_level, AM_NO_FIXED_ART);
818 /* Drop it in the dungeon */
819 (void)drop_near(q_ptr, -1, y, x);
822 if (p_ptr->arena_number > MAX_ARENA_MONS) p_ptr->arena_number++;
823 p_ptr->arena_number++;
828 /* Extract monster name */
829 monster_desc(m_name, m_ptr, MD_IGNORE_HALLU | MD_ASSUME_VISIBLE | MD_INDEF_VISIBLE);
831 do_cmd_write_nikki(NIKKI_ARENA, p_ptr->arena_number, m_name);
835 if (m_idx == p_ptr->riding)
837 if (rakuba(-1, FALSE))
839 msg_print(_("地面に落とされた。", "You have fallen from your riding pet."));
843 /* Drop a dead corpse? */
844 if (one_in_(r_ptr->flags1 & RF1_UNIQUE ? 1 : 4) &&
845 (r_ptr->flags9 & (RF9_DROP_CORPSE | RF9_DROP_SKELETON)) &&
846 !(p_ptr->inside_arena || p_ptr->inside_battle || cloned || ((m_ptr->r_idx == today_mon) && is_pet(m_ptr))))
848 /* Assume skeleton */
852 * We cannot drop a skeleton? Note, if we are in this check,
853 * we *know* we can drop at least a corpse or a skeleton
855 if (!(r_ptr->flags9 & RF9_DROP_SKELETON))
857 else if ((r_ptr->flags9 & RF9_DROP_CORPSE) && (r_ptr->flags1 & RF1_UNIQUE))
860 /* Else, a corpse is more likely unless we did a "lot" of damage */
861 else if (r_ptr->flags9 & RF9_DROP_CORPSE)
863 /* Lots of damage in one blow */
864 if ((0 - ((m_ptr->maxhp) / 4)) > m_ptr->hp)
866 if (one_in_(5)) corpse = TRUE;
870 if (!one_in_(5)) corpse = TRUE;
875 /* Prepare to make an object */
876 object_prep(q_ptr, lookup_kind(TV_CORPSE, (corpse ? SV_CORPSE : SV_SKELETON)));
878 apply_magic(q_ptr, object_level, AM_NO_FIXED_ART);
880 q_ptr->pval = m_ptr->r_idx;
882 /* Drop it in the dungeon */
883 (void)drop_near(q_ptr, -1, y, x);
886 /* Drop objects being carried */
887 monster_drop_carried_objects(m_ptr);
889 if (r_ptr->flags1 & RF1_DROP_GOOD) mo_mode |= AM_GOOD;
890 if (r_ptr->flags1 & RF1_DROP_GREAT) mo_mode |= AM_GREAT;
892 switch (m_ptr->r_idx)
894 case MON_PINK_HORROR:
895 /* Pink horrors are replaced with 2 Blue horrors */
896 if (!(p_ptr->inside_arena || p_ptr->inside_battle))
900 for (i = 0; i < 2; i++)
903 bool pet = is_pet(m_ptr);
906 if (pet) mode |= PM_FORCE_PET;
908 if (summon_specific((pet ? -1 : m_idx), wy, wx, 100, SUMMON_BLUE_HORROR, mode))
910 if (player_can_see_bold(wy, wx))
916 msg_print(_("ピンク・ホラーは分裂した!", "The Pink horror divides!"));
920 case MON_BLOODLETTER:
921 /* Bloodletters of Khorne may drop a blade of chaos */
922 if (drop_chosen_item && (randint1(100) < 15))
926 /* Prepare to make a Blade of Chaos */
927 object_prep(q_ptr, lookup_kind(TV_SWORD, SV_BLADE_OF_CHAOS));
929 apply_magic(q_ptr, object_level, AM_NO_FIXED_ART | mo_mode);
931 /* Drop it in the dungeon */
932 (void)drop_near(q_ptr, -1, y, x);
937 if (drop_chosen_item && (dun_level > 9))
942 /* Activate restriction */
943 if ((dun_level > 49) && one_in_(5))
944 get_obj_num_hook = kind_is_good_book;
946 get_obj_num_hook = kind_is_book;
949 make_object(q_ptr, mo_mode);
951 /* Drop it in the dungeon */
952 (void)drop_near(q_ptr, -1, y, x);
958 * Mega^3-hack: killing a 'Warrior of the Dawn' is likely to
959 * spawn another in the fallen one's place!
961 if (!p_ptr->inside_arena && !p_ptr->inside_battle)
965 POSITION wy = y, wx = x;
967 bool pet = is_pet(m_ptr);
971 scatter(&wy, &wx, y, x, 20, 0);
973 while (!(in_bounds(wy, wx) && cave_empty_bold2(wy, wx)) && --attempts);
978 if (pet) mode |= PM_FORCE_PET;
980 if (summon_specific((pet ? -1 : m_idx), wy, wx, 100, SUMMON_DAWN, mode))
982 if (player_can_see_bold(wy, wx))
983 msg_print(_("新たな戦士が現れた!", "A new warrior steps forth!"));
991 /* One more ultra-hack: An Unmaker goes out with a big bang! */
993 BIT_FLAGS flg = PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL;
994 (void)project(m_idx, 6, y, x, 100, GF_CHAOS, flg, -1);
998 case MON_UNICORN_ORD:
1001 /* Reward for "lazy" player */
1002 if (p_ptr->pseikaku == SEIKAKU_NAMAKE)
1004 ARTIFACT_IDX a_idx = 0;
1005 artifact_type *a_ptr = NULL;
1007 if (!drop_chosen_item) break;
1011 switch (randint0(3))
1014 a_idx = ART_NAMAKE_HAMMER;
1017 a_idx = ART_NAMAKE_BOW;
1020 a_idx = ART_NAMAKE_ARMOR;
1024 a_ptr = &a_info[a_idx];
1026 while (a_ptr->cur_num);
1028 /* Create the artifact */
1029 if (create_named_art(a_idx, y, x))
1033 /* Hack -- Memorize location of artifact in saved floors */
1034 if (character_dungeon) a_ptr->floor_id = p_ptr->floor_id;
1036 else if (!preserve_mode) a_ptr->cur_num = 1;
1041 if (!drop_chosen_item) break;
1044 /* Mega-Hack -- Prepare to make "Grond" */
1045 object_prep(q_ptr, lookup_kind(TV_HAFTED, SV_GROND));
1047 /* Mega-Hack -- Mark this item as "Grond" */
1048 q_ptr->name1 = ART_GROND;
1050 /* Mega-Hack -- Actually create "Grond" */
1051 apply_magic(q_ptr, -1, AM_GOOD | AM_GREAT);
1053 /* Drop it in the dungeon */
1054 (void)drop_near(q_ptr, -1, y, x);
1057 /* Mega-Hack -- Prepare to make "Chaos" */
1058 object_prep(q_ptr, lookup_kind(TV_CROWN, SV_CHAOS));
1060 /* Mega-Hack -- Mark this item as "Chaos" */
1061 q_ptr->name1 = ART_CHAOS;
1063 /* Mega-Hack -- Actually create "Chaos" */
1064 apply_magic(q_ptr, -1, AM_GOOD | AM_GREAT);
1066 /* Drop it in the dungeon */
1067 (void)drop_near(q_ptr, -1, y, x);
1070 case MON_B_DEATH_SWORD:
1071 if (drop_chosen_item)
1075 /* Prepare to make a broken sword */
1076 object_prep(q_ptr, lookup_kind(TV_SWORD, randint1(2)));
1078 /* Drop it in the dungeon */
1079 (void)drop_near(q_ptr, -1, y, x);
1085 if (drop_chosen_item && ((m_ptr->r_idx == MON_A_GOLD) ||
1086 ((m_ptr->r_idx == MON_A_SILVER) && (r_ptr->r_akills % 5 == 0))))
1090 /* Prepare to make a Can of Toys */
1091 object_prep(q_ptr, lookup_kind(TV_CHEST, SV_CHEST_KANDUME));
1093 apply_magic(q_ptr, object_level, AM_NO_FIXED_ART);
1095 /* Drop it in the dungeon */
1096 (void)drop_near(q_ptr, -1, y, x);
1102 BIT_FLAGS flg = PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL;
1103 (void)project(m_idx, 3, y, x, damroll(20, 10), GF_FIRE, flg, -1);
1108 if (!drop_chosen_item) break;
1110 switch (r_ptr->d_char)
1118 /* Activate restriction */
1119 get_obj_num_hook = kind_is_cloak;
1122 make_object(q_ptr, mo_mode);
1124 /* Drop it in the dungeon */
1125 (void)drop_near(q_ptr, -1, y, x);
1135 /* Activate restriction */
1136 get_obj_num_hook = kind_is_polearm;
1138 /* Make a poleweapon */
1139 make_object(q_ptr, mo_mode);
1141 /* Drop it in the dungeon */
1142 (void)drop_near(q_ptr, -1, y, x);
1152 /* Activate restriction */
1153 get_obj_num_hook = kind_is_armor;
1155 /* Make a hard armor */
1156 make_object(q_ptr, mo_mode);
1158 /* Drop it in the dungeon */
1159 (void)drop_near(q_ptr, -1, y, x);
1169 /* Activate restriction */
1170 get_obj_num_hook = kind_is_hafted;
1172 /* Make a hafted weapon */
1173 make_object(q_ptr, mo_mode);
1175 /* Drop it in the dungeon */
1176 (void)drop_near(q_ptr, -1, y, x);
1181 if (m_ptr->r_idx != MON_STORMBRINGER)
1186 /* Activate restriction */
1187 get_obj_num_hook = kind_is_sword;
1190 make_object(q_ptr, mo_mode);
1192 /* Drop it in the dungeon */
1193 (void)drop_near(q_ptr, -1, y, x);
1200 /* Mega-Hack -- drop fixed items */
1201 if (drop_chosen_item)
1203 ARTIFACT_IDX a_idx = 0;
1206 for(i = 0; i < 4; i++)
1208 if(!r_ptr->artifact_id[i]) break;
1209 a_idx = r_ptr->artifact_id[i];
1210 chance = r_ptr->artifact_percent[i];
1213 if ((a_idx > 0) && ((randint0(100) < chance) || p_ptr->wizard))
1215 artifact_type *a_ptr = &a_info[a_idx];
1217 if (!a_ptr->cur_num)
1219 /* Create the artifact */
1220 if (create_named_art(a_idx, y, x))
1224 /* Hack -- Memorize location of artifact in saved floors */
1225 if (character_dungeon) a_ptr->floor_id = p_ptr->floor_id;
1227 else if (!preserve_mode) a_ptr->cur_num = 1;
1231 if ((r_ptr->flags7 & RF7_GUARDIAN) && (d_info[dungeon_type].final_guardian == m_ptr->r_idx))
1233 KIND_OBJECT_IDX k_idx = d_info[dungeon_type].final_object ? d_info[dungeon_type].final_object
1234 : lookup_kind(TV_SCROLL, SV_SCROLL_ACQUIREMENT);
1236 if (d_info[dungeon_type].final_artifact)
1238 a_idx = d_info[dungeon_type].final_artifact;
1239 artifact_type *a_ptr = &a_info[a_idx];
1241 if (!a_ptr->cur_num)
1243 /* Create the artifact */
1244 if (create_named_art(a_idx, y, x))
1248 /* Hack -- Memorize location of artifact in saved floors */
1249 if (character_dungeon) a_ptr->floor_id = p_ptr->floor_id;
1251 else if (!preserve_mode) a_ptr->cur_num = 1;
1253 /* Prevent rewarding both artifact and "default" object */
1254 if (!d_info[dungeon_type].final_object) k_idx = 0;
1262 /* Prepare to make a reward */
1263 object_prep(q_ptr, k_idx);
1265 apply_magic(q_ptr, object_level, AM_NO_FIXED_ART | AM_GOOD);
1267 /* Drop it in the dungeon */
1268 (void)drop_near(q_ptr, -1, y, x);
1270 msg_format(_("あなたは%sを制覇した!", "You have conquered %s!"),d_name+d_info[dungeon_type].name);
1274 /* Determine how much we can drop */
1275 if ((r_ptr->flags1 & RF1_DROP_60) && (randint0(100) < 60)) number++;
1276 if ((r_ptr->flags1 & RF1_DROP_90) && (randint0(100) < 90)) number++;
1277 if (r_ptr->flags1 & RF1_DROP_1D2) number += damroll(1, 2);
1278 if (r_ptr->flags1 & RF1_DROP_2D2) number += damroll(2, 2);
1279 if (r_ptr->flags1 & RF1_DROP_3D2) number += damroll(3, 2);
1280 if (r_ptr->flags1 & RF1_DROP_4D2) number += damroll(4, 2);
1282 if (cloned && !(r_ptr->flags1 & RF1_UNIQUE))
1283 number = 0; /* Clones drop no stuff unless Cloning Pits */
1285 if (is_pet(m_ptr) || p_ptr->inside_battle || p_ptr->inside_arena)
1286 number = 0; /* Pets drop no stuff */
1287 if (!drop_item && (r_ptr->d_char != '$')) number = 0;
1289 if((r_ptr->flags2 & (RF2_MULTIPLY)) && (r_ptr->r_akills > 1024))
1290 number = 0; /* Limit of Multiply monster drop */
1292 /* Hack -- handle creeping coins */
1293 coin_type = force_coin;
1295 /* Average dungeon and monster levels */
1296 object_level = (dun_level + r_ptr->level) / 2;
1298 /* Drop some objects */
1299 for (j = 0; j < number; j++)
1305 if (do_gold && (!do_item || (randint0(100) < 50)))
1307 /* Make some gold */
1308 if (!make_gold(q_ptr)) continue;
1316 /* Make an object */
1317 if (!make_object(q_ptr, mo_mode)) continue;
1322 /* Drop it in the dungeon */
1323 (void)drop_near(q_ptr, -1, y, x);
1326 /* Reset the object level */
1327 object_level = base_level;
1329 /* Reset "coin" type */
1333 /* Take note of any dropped treasure */
1334 if (visible && (dump_item || dump_gold))
1336 /* Take notes on treasure */
1337 lore_treasure(m_idx, dump_item, dump_gold);
1340 /* Only process "Quest Monsters" */
1341 if (!(r_ptr->flags1 & RF1_QUESTOR)) return;
1342 if (p_ptr->inside_battle) return;
1345 if ((m_ptr->r_idx == MON_SERPENT) && !cloned)
1348 p_ptr->total_winner = TRUE;
1350 /* Redraw the "title" */
1351 p_ptr->redraw |= (PR_TITLE);
1353 play_music(TERM_XTRA_MUSIC_BASIC, MUSIC_BASIC_FINAL_QUEST_CLEAR);
1355 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, _("見事に変愚蛮怒の勝利者となった!", "become *WINNER* of Hengband finely!"));
1357 if ((p_ptr->pclass == CLASS_CHAOS_WARRIOR) || (p_ptr->muta2 & MUT2_CHAOS_GIFT))
1359 msg_format(_("%sからの声が響いた。", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
1360 msg_print(_("『よくやった、定命の者よ!』", "'Thou art donst well, mortal!'"));
1363 /* Congratulations */
1364 msg_print(_("*** おめでとう ***", "*** CONGRATULATIONS ***"));
1365 msg_print(_("あなたはゲームをコンプリートしました。", "You have won the game!"));
1366 msg_print(_("準備が整ったら引退(自殺コマンド)しても結構です。", "You may retire (commit suicide) when you are ready."));
1371 * @brief モンスターに与えたダメージの修正処理 /
1372 * Modify the physical damage done to the monster.
1373 * @param m_ptr ダメージを受けるモンスターの構造体参照ポインタ
1374 * @param dam ダメージ基本値
1375 * @param is_psy_spear 攻撃手段が光の剣ならばTRUE
1376 * @return 修正を行った結果のダメージ量
1379 * (for example when it's invulnerable or shielded)
1380 * ToDo: Accept a damage-type to calculate the modified damage from
1381 * things like fire, frost, lightning, poison, ... attacks.
1382 * "type" is not yet used and should be 0.
1385 HIT_POINT mon_damage_mod(monster_type *m_ptr, HIT_POINT dam, bool is_psy_spear)
1387 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1389 if ((r_ptr->flagsr & RFR_RES_ALL) && dam > 0)
1392 if ((dam == 0) && one_in_(3)) dam = 1;
1395 if (MON_INVULNER(m_ptr))
1399 if (!p_ptr->blind && is_seen(m_ptr))
1401 msg_print(_("バリアを切り裂いた!", "The barrier is penetrated!"));
1404 else if (!one_in_(PENETRATE_INVULNERABILITY))
1414 * @brief モンスターに与えたダメージを元に経験値を加算する /
1415 * Calculate experience point to be get
1416 * @param dam 与えたダメージ量
1417 * @param m_ptr ダメージを与えたモンスターの構造体参照ポインタ
1421 * Even the 64 bit operation is not big enough to avoid overflaw
1422 * unless we carefully choose orders of multiplication and division.
1423 * Get the coefficient first, and multiply (potentially huge) base
1424 * experience point of a monster later.
1427 static void get_exp_from_mon(HIT_POINT dam, monster_type *m_ptr)
1429 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1436 if (!m_ptr->r_idx) return;
1437 if (is_pet(m_ptr) || p_ptr->inside_battle) return;
1440 * - Ratio of monster's level to player's level effects
1441 * - Varying speed effects
1442 * - Get a fraction in proportion of damage point
1444 new_exp = r_ptr->level * SPEED_TO_ENERGY(m_ptr->mspeed) * dam;
1447 div_l = (p_ptr->max_plv+2) * SPEED_TO_ENERGY(r_ptr->speed);
1449 /* Use (average maxhp * 2) as a denominator */
1450 if (!(r_ptr->flags1 & RF1_FORCE_MAXHP))
1451 s64b_mul(&div_h, &div_l, 0, r_ptr->hdice * (ironman_nightmare ? 2 : 1) * (r_ptr->hside + 1));
1453 s64b_mul(&div_h, &div_l, 0, r_ptr->hdice * (ironman_nightmare ? 2 : 1) * r_ptr->hside * 2);
1455 /* Special penalty in the wilderness */
1456 if (!dun_level && (!(r_ptr->flags8 & RF8_WILD_ONLY) || !(r_ptr->flags1 & RF1_UNIQUE)))
1457 s64b_mul(&div_h, &div_l, 0, 5);
1459 /* Do division first to prevent overflaw */
1460 s64b_div(&new_exp, &new_exp_frac, div_h, div_l);
1462 /* Special penalty for mutiply-monster */
1463 if ((r_ptr->flags2 & RF2_MULTIPLY) || (m_ptr->r_idx == MON_DAWN))
1465 int monnum_penarty = r_ptr->r_akills / 400;
1466 if (monnum_penarty > 8) monnum_penarty = 8;
1468 while (monnum_penarty--)
1471 s64b_RSHIFT(new_exp, new_exp_frac, 2);
1475 /* Special penalty for rest_and_shoot exp scum */
1476 if ((m_ptr->dealt_damage > m_ptr->max_maxhp) && (m_ptr->hp >= 0))
1478 int over_damage = m_ptr->dealt_damage / m_ptr->max_maxhp;
1479 if (over_damage > 32) over_damage = 32;
1481 while (over_damage--)
1484 s64b_mul(&new_exp, &new_exp_frac, 0, 9);
1485 s64b_div(&new_exp, &new_exp_frac, 0, 10);
1489 /* Finally multiply base experience point of the monster */
1490 s64b_mul(&new_exp, &new_exp_frac, 0, r_ptr->mexp);
1492 /* Gain experience */
1493 gain_exp_64(new_exp, new_exp_frac);
1498 * @brief モンスターのHPをダメージに応じて減算する /
1499 * Decreases monsters hit points, handling monster death.
1500 * @param dam 与えたダメージ量
1501 * @param m_idx ダメージを与えたモンスターのID
1502 * @param fear ダメージによってモンスターが恐慌状態に陥ったならばTRUEを返す
1503 * @param note モンスターが倒された際の特別なメッセージ述語
1507 * We return TRUE if the monster has been killed (and deleted).
1508 * We announce monster death (using an optional "death message"
1509 * if given, and a otherwise a generic killed/destroyed message).
1510 * Only "physical attacks" can induce the "You have slain" message.
1511 * Missile and Spell attacks will induce the "dies" message, or
1512 * various "specialized" messages. Note that "You have destroyed"
1513 * and "is destroyed" are synonyms for "You have slain" and "dies".
1514 * Hack -- unseen monsters yield "You have killed it." message.
1515 * Added fear (DGK) and check whether to print fear messages -CWS
1516 * Made name, sex, and capitalization generic -BEN-
1517 * As always, the "ghost" processing is a total hack.
1518 * Hack -- we "delay" fear messages by passing around a "fear" flag.
1519 * Consider decreasing monster experience over time, say,
1520 * by using "(m_exp * m_lev * (m_lev)) / (p_lev * (m_lev + n_killed))"
1521 * instead of simply "(m_exp * m_lev) / (p_lev)", to make the first
1522 * monster worth more than subsequent monsters. This would also need
1523 * to induce changes in the monster recall code.
1526 bool mon_take_hit(MONSTER_IDX m_idx, HIT_POINT dam, bool *fear, cptr note)
1528 monster_type *m_ptr = &m_list[m_idx];
1529 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1530 monster_type exp_mon;
1532 /* Innocent until proven otherwise */
1533 bool innocent = TRUE, thief = FALSE;
1537 (void)COPY(&exp_mon, m_ptr, monster_type);
1539 expdam = (m_ptr->hp > dam) ? dam : m_ptr->hp;
1541 get_exp_from_mon(expdam, &exp_mon);
1543 /* Genocided by chaos patron */
1544 if (!m_ptr->r_idx) m_idx = 0;
1546 /* Redraw (later) if needed */
1547 if (p_ptr->health_who == m_idx) p_ptr->redraw |= (PR_HEALTH);
1548 if (p_ptr->riding == m_idx) p_ptr->redraw |= (PR_UHEALTH);
1550 (void)set_monster_csleep(m_idx, 0);
1552 /* Hack - Cancel any special player stealth magics. -LM- */
1553 if (p_ptr->special_defense & NINJA_S_STEALTH)
1555 set_superstealth(FALSE);
1558 /* Genocided by chaos patron */
1559 if (!m_idx) return TRUE;
1562 m_ptr->dealt_damage += dam;
1564 if(m_ptr->dealt_damage > m_ptr->max_maxhp * 100) m_ptr->dealt_damage = m_ptr->max_maxhp * 100;
1568 msg_format( _("合計%d/%dのダメージを与えた。","You do %d (out of %d) damage."), m_ptr->dealt_damage, m_ptr->maxhp);
1571 /* It is dead now */
1576 if (r_info[m_ptr->r_idx].flags7 & RF7_TANUKI)
1578 /* You might have unmasked Tanuki first time */
1579 r_ptr = &r_info[m_ptr->r_idx];
1580 m_ptr->ap_r_idx = m_ptr->r_idx;
1581 if (r_ptr->r_sights < MAX_SHORT) r_ptr->r_sights++;
1584 if (m_ptr->mflag2 & MFLAG2_CHAMELEON)
1586 /* You might have unmasked Chameleon first time */
1587 r_ptr = real_r_ptr(m_ptr);
1588 if (r_ptr->r_sights < MAX_SHORT) r_ptr->r_sights++;
1591 if (!(m_ptr->smart & SM_CLONED))
1593 /* When the player kills a Unique, it stays dead */
1594 if (r_ptr->flags1 & RF1_UNIQUE)
1598 /* Mega-Hack -- Banor & Lupart */
1599 if ((m_ptr->r_idx == MON_BANOR) || (m_ptr->r_idx == MON_LUPART))
1601 r_info[MON_BANORLUPART].max_num = 0;
1602 r_info[MON_BANORLUPART].r_pkills++;
1603 r_info[MON_BANORLUPART].r_akills++;
1604 if (r_info[MON_BANORLUPART].r_tkills < MAX_SHORT) r_info[MON_BANORLUPART].r_tkills++;
1606 else if (m_ptr->r_idx == MON_BANORLUPART)
1608 r_info[MON_BANOR].max_num = 0;
1609 r_info[MON_BANOR].r_pkills++;
1610 r_info[MON_BANOR].r_akills++;
1611 if (r_info[MON_BANOR].r_tkills < MAX_SHORT) r_info[MON_BANOR].r_tkills++;
1612 r_info[MON_LUPART].max_num = 0;
1613 r_info[MON_LUPART].r_pkills++;
1614 r_info[MON_LUPART].r_akills++;
1615 if (r_info[MON_LUPART].r_tkills < MAX_SHORT) r_info[MON_LUPART].r_tkills++;
1619 /* When the player kills a Nazgul, it stays dead */
1620 else if (r_ptr->flags7 & RF7_NAZGUL) r_ptr->max_num--;
1623 /* Count all monsters killed */
1624 if (r_ptr->r_akills < MAX_SHORT) r_ptr->r_akills++;
1626 /* Recall even invisible uniques or winners */
1627 if ((m_ptr->ml && !p_ptr->image) || (r_ptr->flags1 & RF1_UNIQUE))
1629 /* Count kills this life */
1630 if ((m_ptr->mflag2 & MFLAG2_KAGE) && (r_info[MON_KAGE].r_pkills < MAX_SHORT)) r_info[MON_KAGE].r_pkills++;
1631 else if (r_ptr->r_pkills < MAX_SHORT) r_ptr->r_pkills++;
1633 /* Count kills in all lives */
1634 if ((m_ptr->mflag2 & MFLAG2_KAGE) && (r_info[MON_KAGE].r_tkills < MAX_SHORT)) r_info[MON_KAGE].r_tkills++;
1635 else if (r_ptr->r_tkills < MAX_SHORT) r_ptr->r_tkills++;
1637 /* Hack -- Auto-recall */
1638 monster_race_track(m_ptr->ap_r_idx);
1641 /* Extract monster name */
1642 monster_desc(m_name, m_ptr, MD_TRUE_NAME);
1644 /* Don't kill Amberites */
1645 if ((r_ptr->flags3 & RF3_AMBERITE) && one_in_(2))
1647 int curses = 1 + randint1(3);
1648 bool stop_ty = FALSE;
1651 msg_format(_("%^sは恐ろしい血の呪いをあなたにかけた!", "%^s puts a terrible blood curse on you!"), m_name);
1652 curse_equipment(100, 50);
1656 stop_ty = activate_ty_curse(stop_ty, &count);
1661 if (r_ptr->flags2 & RF2_CAN_SPEAK)
1663 char line_got[1024];
1665 /* Dump a message */
1666 if (!get_rnd_line(_("mondeath_j.txt", "mondeath.txt"), m_ptr->r_idx, line_got))
1668 msg_format("%^s %s", m_name, line_got);
1672 if (m_ptr->r_idx == MON_SERPENT)
1674 /* Make screen dump */
1675 screen_dump = make_screen_dump();
1680 if (!(d_info[dungeon_type].flags1 & DF1_BEGINNER))
1682 if (!dun_level && !ambush_flag && !p_ptr->inside_arena)
1684 chg_virtue(V_VALOUR, -1);
1686 else if (r_ptr->level > dun_level)
1688 if (randint1(10) <= (r_ptr->level - dun_level))
1689 chg_virtue(V_VALOUR, 1);
1691 if (r_ptr->level > 60)
1693 chg_virtue(V_VALOUR, 1);
1695 if (r_ptr->level >= 2 * (p_ptr->lev+1))
1696 chg_virtue(V_VALOUR, 2);
1699 if (r_ptr->flags1 & RF1_UNIQUE)
1701 if (r_ptr->flags3 & (RF3_EVIL | RF3_GOOD)) chg_virtue(V_HARMONY, 2);
1703 if (r_ptr->flags3 & RF3_GOOD)
1705 chg_virtue(V_UNLIFE, 2);
1706 chg_virtue(V_VITALITY, -2);
1709 if (one_in_(3)) chg_virtue(V_INDIVIDUALISM, -1);
1712 if (m_ptr->r_idx == MON_BEGGAR || m_ptr->r_idx == MON_LEPER)
1714 chg_virtue(V_COMPASSION, -1);
1717 if ((r_ptr->flags3 & RF3_GOOD) && ((r_ptr->level) / 10 + (3 * dun_level) >= randint1(100)))
1718 chg_virtue(V_UNLIFE, 1);
1720 if (r_ptr->d_char == 'A')
1722 if (r_ptr->flags1 & RF1_UNIQUE)
1723 chg_virtue(V_FAITH, -2);
1724 else if ((r_ptr->level) / 10 + (3 * dun_level) >= randint1(100))
1726 if (r_ptr->flags3 & RF3_GOOD) chg_virtue(V_FAITH, -1);
1727 else chg_virtue(V_FAITH, 1);
1730 else if (r_ptr->flags3 & RF3_DEMON)
1732 if (r_ptr->flags1 & RF1_UNIQUE)
1733 chg_virtue(V_FAITH, 2);
1734 else if ((r_ptr->level) / 10 + (3 * dun_level) >= randint1(100))
1735 chg_virtue(V_FAITH, 1);
1738 if ((r_ptr->flags3 & RF3_UNDEAD) && (r_ptr->flags1 & RF1_UNIQUE))
1739 chg_virtue(V_VITALITY, 2);
1741 if (r_ptr->r_deaths)
1743 if (r_ptr->flags1 & RF1_UNIQUE)
1745 chg_virtue(V_HONOUR, 10);
1747 else if ((r_ptr->level) / 10 + (2 * dun_level) >= randint1(100))
1749 chg_virtue(V_HONOUR, 1);
1752 if ((r_ptr->flags2 & RF2_MULTIPLY) && (r_ptr->r_akills > 1000) && one_in_(10))
1754 chg_virtue(V_VALOUR, -1);
1757 for (i = 0; i < 4; i++)
1759 if (r_ptr->blow[i].d_dice != 0) innocent = FALSE; /* Murderer! */
1761 if ((r_ptr->blow[i].effect == RBE_EAT_ITEM)
1762 || (r_ptr->blow[i].effect == RBE_EAT_GOLD))
1764 thief = TRUE; /* Thief! */
1767 /* The new law says it is illegal to live in the dungeon */
1768 if (r_ptr->level != 0) innocent = FALSE;
1772 if (r_ptr->flags1 & RF1_UNIQUE)
1773 chg_virtue(V_JUSTICE, 3);
1774 else if (1+((r_ptr->level) / 10 + (2 * dun_level)) >= randint1(100))
1775 chg_virtue(V_JUSTICE, 1);
1779 chg_virtue (V_JUSTICE, -1);
1782 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)))
1784 if (one_in_(4)) chg_virtue(V_NATURE, -1);
1787 if ((r_ptr->flags1 & RF1_UNIQUE) && record_destroy_uniq)
1790 sprintf(note_buf, "%s%s", r_name + r_ptr->name, (m_ptr->smart & SM_CLONED) ? _("(クローン)", "(Clone)") : "");
1791 do_cmd_write_nikki(NIKKI_UNIQUE, 0, note_buf);
1797 /* Death by Missile/Spell attack */
1800 msg_format("%^s%s", m_name, note);
1803 /* Death by physical attack -- invisible monster */
1804 else if (!m_ptr->ml)
1807 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
1808 msg_format("せっかくだから%sを殺した。", m_name);
1810 msg_format("%sを殺した。", m_name);
1812 msg_format("You have killed %s.", m_name);
1817 /* Death by Physical attack -- non-living monster */
1818 else if (!monster_living(r_ptr))
1820 bool explode = FALSE;
1822 for (i = 0; i < 4; i++)
1824 if (r_ptr->blow[i].method == RBM_EXPLODE) explode = TRUE;
1827 /* Special note at death */
1829 msg_format(_("%sは爆発して粉々になった。", "%^s explodes into tiny shreds."), m_name);
1833 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
1834 msg_format("せっかくだから%sを倒した。", m_name);
1836 msg_format("%sを倒した。", m_name);
1838 msg_format("You have destroyed %s.", m_name);
1843 /* Death by Physical attack -- living monster */
1847 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
1848 msg_format("せっかくだから%sを葬り去った。", m_name);
1850 msg_format("%sを葬り去った。", m_name);
1852 msg_format("You have slain %s.", m_name);
1856 if ((r_ptr->flags1 & RF1_UNIQUE) && !(m_ptr->smart & SM_CLONED) && !vanilla_town)
1858 for (i = 0; i < MAX_KUBI; i++)
1860 if ((kubi_r_idx[i] == m_ptr->r_idx) && !(m_ptr->mflag2 & MFLAG2_CHAMELEON))
1862 msg_format(_("%sの首には賞金がかかっている。", "There is a price on %s's head."), m_name);
1868 /* Generate treasure */
1869 monster_death(m_idx, TRUE);
1871 /* Mega hack : replace IKETA to BIKETAL */
1872 if ((m_ptr->r_idx == MON_IKETA) && !(p_ptr->inside_arena || p_ptr->inside_battle))
1874 POSITION dummy_y = m_ptr->fy;
1875 POSITION dummy_x = m_ptr->fx;
1876 BIT_FLAGS mode = 0L;
1877 if (is_pet(m_ptr)) mode |= PM_FORCE_PET;
1878 delete_monster_idx(m_idx);
1879 if (summon_named_creature(0, dummy_y, dummy_x, MON_BIKETAL, mode))
1881 msg_print(_("「ハァッハッハッハ!!私がバイケタルだ!!」", "Uwa-hahaha! *I* am Biketal!"));
1886 delete_monster_idx(m_idx);
1889 get_exp_from_mon((long)exp_mon.max_maxhp*2, &exp_mon);
1894 /* Monster is dead */
1901 /* Mega-Hack -- Pain cancels fear */
1902 if (MON_MONFEAR(m_ptr) && (dam > 0))
1905 if (set_monster_monfear(m_idx, MON_MONFEAR(m_ptr) - randint1(dam)))
1912 /* Sometimes a monster gets scared by damage */
1913 if (!MON_MONFEAR(m_ptr) && !(r_ptr->flags3 & (RF3_NO_FEAR)))
1915 /* Percentage of fully healthy */
1916 int percentage = (100L * m_ptr->hp) / m_ptr->maxhp;
1919 * Run (sometimes) if at 10% or less of max hit points,
1920 * or (usually) when hit for half its current hit points
1922 if ((randint1(10) >= percentage) || ((dam >= m_ptr->hp) && (randint0(100) < 80)))
1924 /* Hack -- note fear */
1927 /* Hack -- Add some timed fear */
1928 (void)set_monster_monfear(m_idx, (randint1(10) +
1929 (((dam >= m_ptr->hp) && (percentage > 7)) ?
1930 20 : ((11 - percentage) * 5))));
1942 * @brief 現在のコンソール表示の縦横を返す。 /
1943 * Get term size and calculate screen size
1944 * @param wid_p コンソールの表示幅文字数を返す
1945 * @param hgt_p コンソールの表示行数を返す
1948 void get_screen_size(TERM_LEN *wid_p, TERM_LEN *hgt_p)
1950 Term_get_size(wid_p, hgt_p);
1951 *hgt_p -= ROW_MAP + 2;
1952 *wid_p -= COL_MAP + 2;
1953 if (use_bigtile) *wid_p /= 2;
1958 * @brief コンソール上におけるマップ表示の左上位置を返す /
1959 * Calculates current boundaries Called below and from "do_cmd_locate()".
1962 void panel_bounds_center(void)
1966 get_screen_size(&wid, &hgt);
1968 panel_row_max = panel_row_min + hgt - 1;
1969 panel_row_prt = panel_row_min - 1;
1970 panel_col_max = panel_col_min + wid - 1;
1971 panel_col_prt = panel_col_min - 13;
1976 * @brief コンソールのリサイズに合わせてマップを再描画する /
1977 * Map resizing whenever the main term changes size
1980 void resize_map(void)
1982 /* Only if the dungeon exists */
1983 if (!character_dungeon) return;
1985 /* Mega-Hack -- no panel yet */
1989 /* Reset the panels */
1990 panel_row_min = cur_hgt;
1991 panel_col_min = cur_wid;
1995 p_ptr->update |= (PU_TORCH | PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
1997 /* Forget lite/view */
1998 p_ptr->update |= (PU_UN_VIEW | PU_UN_LITE);
2000 /* Update lite/view */
2001 p_ptr->update |= (PU_VIEW | PU_LITE | PU_MON_LITE);
2003 /* Update monsters */
2004 p_ptr->update |= (PU_MONSTERS);
2006 /* Redraw everything */
2007 p_ptr->redraw |= (PR_WIPE | PR_BASIC | PR_EXTRA | PR_MAP | PR_EQUIPPY);
2009 /* Hack -- update */
2015 * Place the cursor on the player
2017 if (can_save) move_cursor_relative(p_ptr->y, p_ptr->x);
2024 * @brief コンソールを再描画する /
2025 * Redraw a term when it is resized
2028 void redraw_window(void)
2030 /* Only if the dungeon exists */
2031 if (!character_dungeon) return;
2033 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_SPELL | PW_PLAYER);
2034 p_ptr->window |= (PW_MESSAGE | PW_OVERHEAD | PW_DUNGEON | PW_MONSTER | PW_OBJECT);
2036 /* Hack -- update */
2043 * @brief フォーカスを当てるべきマップ描画の基準座標を指定する(サブルーチン)
2044 * @param dy 変更先のフロアY座標
2045 * @param dx 変更先のフロアX座標
2046 * Handle a request to change the current panel
2047 * Return TRUE if the panel was changed.
2048 * Also used in do_cmd_locate
2049 * @return 実際に再描画が必要だった場合TRUEを返す
2051 bool change_panel(POSITION dy, POSITION dx)
2056 get_screen_size(&wid, &hgt);
2058 /* Apply the motion */
2059 y = panel_row_min + dy * hgt / 2;
2060 x = panel_col_min + dx * wid / 2;
2062 /* Verify the row */
2063 if (y > cur_hgt - hgt) y = cur_hgt - hgt;
2066 /* Verify the col */
2067 if (x > cur_wid - wid) x = cur_wid - wid;
2070 /* Handle "changes" */
2071 if ((y != panel_row_min) || (x != panel_col_min))
2073 /* Save the new panel info */
2077 /* Recalculate the boundaries */
2078 panel_bounds_center();
2080 p_ptr->update |= (PU_MONSTERS);
2082 p_ptr->redraw |= (PR_MAP);
2094 * @brief フォーカスを当てるべきマップ描画の基準座標を指定する
2095 * @param y 変更先のフロアY座標
2096 * @param x 変更先のフロアX座標
2098 * Handle a request to change the current panel
2099 * Return TRUE if the panel was changed.
2100 * Also used in do_cmd_locate
2101 * @return 実際に再描画が必要だった場合TRUEを返す
2103 static bool change_panel_xy(POSITION y, POSITION x)
2105 POSITION dy = 0, dx = 0;
2108 get_screen_size(&wid, &hgt);
2110 if (y < panel_row_min) dy = -1;
2111 if (y > panel_row_max) dy = 1;
2112 if (x < panel_col_min) dx = -1;
2113 if (x > panel_col_max) dx = 1;
2115 if (!dy && !dx) return (FALSE);
2117 return change_panel(dy, dx);
2122 * @brief マップ描画のフォーカスを当てるべき座標を更新する
2124 * Given an row (y) and col (x), this routine detects when a move
2125 * off the screen has occurred and figures new borders. -RAK-
2126 * "Update" forces a "full update" to take place.
2127 * The map is reprinted if necessary, and "TRUE" is returned.
2128 * @return 実際に再描画が必要だった場合TRUEを返す
2130 void verify_panel(void)
2132 POSITION y = p_ptr->y;
2133 POSITION x = p_ptr->x;
2141 get_screen_size(&wid, &hgt);
2143 max_prow_min = cur_hgt - hgt;
2144 max_pcol_min = cur_wid - wid;
2146 /* Bounds checking */
2147 if (max_prow_min < 0) max_prow_min = 0;
2148 if (max_pcol_min < 0) max_pcol_min = 0;
2150 /* Center on player */
2151 if (center_player && (center_running || !running))
2153 /* Center vertically */
2154 prow_min = y - hgt / 2;
2155 if (prow_min < 0) prow_min = 0;
2156 else if (prow_min > max_prow_min) prow_min = max_prow_min;
2158 /* Center horizontally */
2159 pcol_min = x - wid / 2;
2160 if (pcol_min < 0) pcol_min = 0;
2161 else if (pcol_min > max_pcol_min) pcol_min = max_pcol_min;
2165 prow_min = panel_row_min;
2166 pcol_min = panel_col_min;
2168 /* Scroll screen when 2 grids from top/bottom edge */
2169 if (y > panel_row_max - 2)
2171 while (y > prow_min + hgt-1 - 2)
2173 prow_min += (hgt / 2);
2177 if (y < panel_row_min + 2)
2179 while (y < prow_min + 2)
2181 prow_min -= (hgt / 2);
2185 if (prow_min > max_prow_min) prow_min = max_prow_min;
2186 if (prow_min < 0) prow_min = 0;
2188 /* Scroll screen when 4 grids from left/right edge */
2189 if (x > panel_col_max - 4)
2191 while (x > pcol_min + wid-1 - 4)
2193 pcol_min += (wid / 2);
2197 if (x < panel_col_min + 4)
2199 while (x < pcol_min + 4)
2201 pcol_min -= (wid / 2);
2205 if (pcol_min > max_pcol_min) pcol_min = max_pcol_min;
2206 if (pcol_min < 0) pcol_min = 0;
2209 /* Check for "no change" */
2210 if ((prow_min == panel_row_min) && (pcol_min == panel_col_min)) return;
2212 /* Save the new panel info */
2213 panel_row_min = prow_min;
2214 panel_col_min = pcol_min;
2216 /* Hack -- optional disturb on "panel change" */
2217 if (disturb_panel && !center_player) disturb(FALSE, FALSE);
2219 /* Recalculate the boundaries */
2220 panel_bounds_center();
2222 p_ptr->update |= (PU_MONSTERS);
2224 p_ptr->redraw |= (PR_MAP);
2226 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
2231 * Monster health description
2233 cptr look_mon_desc(monster_type *m_ptr, BIT_FLAGS mode)
2235 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
2242 /* Determine if the monster is "living" */
2243 living = monster_living(ap_r_ptr);
2245 /* Calculate a health "percentage" */
2246 perc = 100L * m_ptr->hp / m_ptr->maxhp;
2248 /* Healthy monsters */
2249 if (m_ptr->hp >= m_ptr->maxhp)
2253 desc = living ? "無傷" : "無ダメージ";
2255 desc = living ? "unhurt" : "undamaged";
2260 else if (perc >= 60)
2263 desc = living ? "軽傷" : "小ダメージ";
2265 desc = living ? "somewhat wounded" : "somewhat damaged";
2270 else if (perc >= 25)
2273 desc = living ? "負傷" : "中ダメージ";
2275 desc = living ? "wounded" : "damaged";
2280 else if (perc >= 10)
2283 desc = living ? "重傷" : "大ダメージ";
2285 desc = living ? "badly wounded" : "badly damaged";
2293 desc = living ? "半死半生" : "倒れかけ";
2295 desc = living ? "almost dead" : "almost destroyed";
2300 /* Need attitude information? */
2303 /* Full information is not needed */
2306 else if (is_pet(m_ptr))
2308 attitude = _(", ペット", ", pet");
2310 else if (is_friendly(m_ptr))
2312 attitude = _(", 友好的", ", friendly");
2316 attitude = _("", "");
2320 /* Clone monster? */
2321 if (m_ptr->smart & SM_CLONED)
2330 /* Display monster's level --- idea borrowed from ToME */
2331 if (ap_r_ptr->r_tkills && !(m_ptr->mflag2 & MFLAG2_KAGE))
2333 return format(_("レベル%d, %s%s%s", "Level %d, %s%s%s"), ap_r_ptr->level, desc, attitude, clone);
2337 return format(_("レベル???, %s%s%s", "Level ???, %s%s%s"), desc, attitude, clone);
2344 * Angband sorting algorithm -- quick sort in place
2346 * Note that the details of the data we are sorting is hidden,
2347 * and we rely on the "ang_sort_comp()" and "ang_sort_swap()"
2348 * function hooks to interact with the data, which is given as
2349 * two pointers, and which may have any user-defined form.
2351 void ang_sort_aux(vptr u, vptr v, int p, int q)
2369 while (!(*ang_sort_comp)(u, v, b, z)) b--;
2372 while (!(*ang_sort_comp)(u, v, z, a)) a++;
2374 /* Done partition */
2378 (*ang_sort_swap)(u, v, a, b);
2384 /* Recurse left side */
2385 ang_sort_aux(u, v, p, b);
2387 /* Recurse right side */
2388 ang_sort_aux(u, v, b+1, q);
2393 * Angband sorting algorithm -- quick sort in place
2395 * Note that the details of the data we are sorting is hidden,
2396 * and we rely on the "ang_sort_comp()" and "ang_sort_swap()"
2397 * function hooks to interact with the data, which is given as
2398 * two pointers, and which may have any user-defined form.
2400 void ang_sort(vptr u, vptr v, int n)
2402 /* Sort the array */
2403 ang_sort_aux(u, v, 0, n-1);
2408 /*** Targeting Code ***/
2412 * Determine is a monster makes a reasonable target
2414 * The concept of "targeting" was stolen from "Morgul" (?)
2416 * The player can target any location, or any "target-able" monster.
2418 * Currently, a monster is "target_able" if it is visible, and if
2419 * the player can hit it with a projection, and the player is not
2420 * hallucinating. This allows use of "use closest target" macros.
2422 * Future versions may restrict the ability to target "trappers"
2423 * and "mimics", but the semantics is a little bit weird.
2425 bool target_able(MONSTER_IDX m_idx)
2427 monster_type *m_ptr = &m_list[m_idx];
2429 /* Monster must be alive */
2430 if (!m_ptr->r_idx) return (FALSE);
2432 /* Hack -- no targeting hallucinations */
2433 if (p_ptr->image) return (FALSE);
2435 /* Monster must be visible */
2436 if (!m_ptr->ml) return (FALSE);
2438 if (p_ptr->riding && (p_ptr->riding == m_idx)) return (TRUE);
2440 /* Monster must be projectable */
2441 if (!projectable(p_ptr->y, p_ptr->x, m_ptr->fy, m_ptr->fx)) return (FALSE);
2443 /* Hack -- Never target trappers */
2444 /* if (CLEAR_ATTR && (CLEAR_CHAR)) return (FALSE); */
2454 * Update (if necessary) and verify (if possible) the target.
2456 * We return TRUE if the target is "okay" and FALSE otherwise.
2458 bool target_okay(void)
2460 /* Accept stationary targets */
2461 if (target_who < 0) return (TRUE);
2463 /* Check moving targets */
2466 /* Accept reasonable targets */
2467 if (target_able(target_who))
2469 monster_type *m_ptr = &m_list[target_who];
2471 /* Acquire monster location */
2472 target_row = m_ptr->fy;
2473 target_col = m_ptr->fx;
2480 /* Assume no target */
2486 * Sorting hook -- comp function -- by "distance to player"
2488 * We use "u" and "v" to point to arrays of "x" and "y" positions,
2489 * and sort the arrays by double-distance to the player.
2491 static bool ang_sort_comp_distance(vptr u, vptr v, int a, int b)
2493 POSITION *x = (POSITION*)(u);
2494 POSITION *y = (POSITION*)(v);
2496 POSITION da, db, kx, ky;
2498 /* Absolute distance components */
2499 kx = x[a]; kx -= p_ptr->x; kx = ABS(kx);
2500 ky = y[a]; ky -= p_ptr->y; ky = ABS(ky);
2502 /* Approximate Double Distance to the first point */
2503 da = ((kx > ky) ? (kx + kx + ky) : (ky + ky + kx));
2505 /* Absolute distance components */
2506 kx = x[b]; kx -= p_ptr->x; kx = ABS(kx);
2507 ky = y[b]; ky -= p_ptr->y; ky = ABS(ky);
2509 /* Approximate Double Distance to the first point */
2510 db = ((kx > ky) ? (kx + kx + ky) : (ky + ky + kx));
2512 /* Compare the distances */
2518 * Sorting hook -- comp function -- by importance level of grids
2520 * We use "u" and "v" to point to arrays of "x" and "y" positions,
2521 * and sort the arrays by level of monster
2523 static bool ang_sort_comp_importance(vptr u, vptr v, int a, int b)
2525 POSITION *x = (POSITION*)(u);
2526 POSITION *y = (POSITION*)(v);
2527 cave_type *ca_ptr = &cave[y[a]][x[a]];
2528 cave_type *cb_ptr = &cave[y[b]][x[b]];
2529 monster_type *ma_ptr = &m_list[ca_ptr->m_idx];
2530 monster_type *mb_ptr = &m_list[cb_ptr->m_idx];
2531 monster_race *ap_ra_ptr, *ap_rb_ptr;
2533 /* The player grid */
2534 if (y[a] == p_ptr->y && x[a] == p_ptr->x) return TRUE;
2535 if (y[b] == p_ptr->y && x[b] == p_ptr->x) return FALSE;
2537 /* Extract monster race */
2538 if (ca_ptr->m_idx && ma_ptr->ml) ap_ra_ptr = &r_info[ma_ptr->ap_r_idx];
2539 else ap_ra_ptr = NULL;
2540 if (cb_ptr->m_idx && mb_ptr->ml) ap_rb_ptr = &r_info[mb_ptr->ap_r_idx];
2541 else ap_rb_ptr = NULL;
2543 if (ap_ra_ptr && !ap_rb_ptr) return TRUE;
2544 if (!ap_ra_ptr && ap_rb_ptr) return FALSE;
2546 /* Compare two monsters */
2547 if (ap_ra_ptr && ap_rb_ptr)
2549 /* Unique monsters first */
2550 if ((ap_ra_ptr->flags1 & RF1_UNIQUE) && !(ap_rb_ptr->flags1 & RF1_UNIQUE)) return TRUE;
2551 if (!(ap_ra_ptr->flags1 & RF1_UNIQUE) && (ap_rb_ptr->flags1 & RF1_UNIQUE)) return FALSE;
2553 /* Shadowers first (あやしい影) */
2554 if ((ma_ptr->mflag2 & MFLAG2_KAGE) && !(mb_ptr->mflag2 & MFLAG2_KAGE)) return TRUE;
2555 if (!(ma_ptr->mflag2 & MFLAG2_KAGE) && (mb_ptr->mflag2 & MFLAG2_KAGE)) return FALSE;
2557 /* Unknown monsters first */
2558 if (!ap_ra_ptr->r_tkills && ap_rb_ptr->r_tkills) return TRUE;
2559 if (ap_ra_ptr->r_tkills && !ap_rb_ptr->r_tkills) return FALSE;
2561 /* Higher level monsters first (if known) */
2562 if (ap_ra_ptr->r_tkills && ap_rb_ptr->r_tkills)
2564 if (ap_ra_ptr->level > ap_rb_ptr->level) return TRUE;
2565 if (ap_ra_ptr->level < ap_rb_ptr->level) return FALSE;
2568 /* Sort by index if all conditions are same */
2569 if (ma_ptr->ap_r_idx > mb_ptr->ap_r_idx) return TRUE;
2570 if (ma_ptr->ap_r_idx < mb_ptr->ap_r_idx) return FALSE;
2573 /* An object get higher priority */
2574 if (cave[y[a]][x[a]].o_idx && !cave[y[b]][x[b]].o_idx) return TRUE;
2575 if (!cave[y[a]][x[a]].o_idx && cave[y[b]][x[b]].o_idx) return FALSE;
2577 /* Priority from the terrain */
2578 if (f_info[ca_ptr->feat].priority > f_info[cb_ptr->feat].priority) return TRUE;
2579 if (f_info[ca_ptr->feat].priority < f_info[cb_ptr->feat].priority) return FALSE;
2581 /* If all conditions are same, compare distance */
2582 return ang_sort_comp_distance(u, v, a, b);
2587 * Sorting hook -- swap function -- by "distance to player"
2589 * We use "u" and "v" to point to arrays of "x" and "y" positions,
2590 * and sort the arrays by distance to the player.
2592 static void ang_sort_swap_distance(vptr u, vptr v, int a, int b)
2594 POSITION *x = (POSITION*)(u);
2595 POSITION *y = (POSITION*)(v);
2613 * Hack -- help "select" a location (see below)
2615 static POSITION_IDX target_pick(POSITION y1, POSITION x1, POSITION dy, POSITION dx)
2618 POSITION x2, y2, x3, y3, x4, y4;
2619 POSITION_IDX b_i = -1, b_v = 9999;
2622 /* Scan the locations */
2623 for (i = 0; i < temp_n; i++)
2629 /* Directed distance */
2633 /* Verify quadrant */
2634 if (dx && (x3 * dx <= 0)) continue;
2635 if (dy && (y3 * dy <= 0)) continue;
2637 /* Absolute distance */
2641 /* Verify quadrant */
2642 if (dy && !dx && (x4 > y4)) continue;
2643 if (dx && !dy && (y4 > x4)) continue;
2645 /* Approximate Double Distance */
2646 v = ((x4 > y4) ? (x4 + x4 + y4) : (y4 + y4 + x4));
2648 /* Penalize location */
2651 if ((b_i >= 0) && (v >= b_v)) continue;
2661 * Hack -- determine if a given location is "interesting"
2663 static bool target_set_accept(POSITION y, POSITION x)
2666 OBJECT_IDX this_o_idx, next_o_idx = 0;
2669 if (!(in_bounds(y, x))) return (FALSE);
2671 /* Player grid is always interesting */
2672 if (player_bold(y, x)) return (TRUE);
2674 /* Handle hallucination */
2675 if (p_ptr->image) return (FALSE);
2677 /* Examine the grid */
2678 c_ptr = &cave[y][x];
2680 /* Visible monsters */
2683 monster_type *m_ptr = &m_list[c_ptr->m_idx];
2685 /* Visible monsters */
2686 if (m_ptr->ml) return (TRUE);
2689 /* Scan all objects in the grid */
2690 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
2693 o_ptr = &o_list[this_o_idx];
2695 /* Acquire next object */
2696 next_o_idx = o_ptr->next_o_idx;
2698 /* Memorized object */
2699 if (o_ptr->marked & OM_FOUND) return (TRUE);
2702 /* Interesting memorized features */
2703 if (c_ptr->info & (CAVE_MARK))
2705 /* Notice object features */
2706 if (c_ptr->info & CAVE_OBJECT) return (TRUE);
2708 /* Feature code (applying "mimic" field) */
2709 if (have_flag(f_info[get_feat_mimic(c_ptr)].flags, FF_NOTICE)) return TRUE;
2717 * Prepare the "temp" array for "target_set"
2719 * Return the number of target_able monsters in the set.
2721 static void target_set_prepare(BIT_FLAGS mode)
2724 POSITION min_hgt, max_hgt, min_wid, max_wid;
2726 if (mode & TARGET_KILL)
2729 min_hgt = MAX((p_ptr->y - MAX_RANGE), 0);
2730 max_hgt = MIN((p_ptr->y + MAX_RANGE), cur_hgt - 1);
2731 min_wid = MAX((p_ptr->x - MAX_RANGE), 0);
2732 max_wid = MIN((p_ptr->x + MAX_RANGE), cur_wid - 1);
2734 else /* not targetting */
2737 min_hgt = panel_row_min;
2738 max_hgt = panel_row_max;
2739 min_wid = panel_col_min;
2740 max_wid = panel_col_max;
2743 /* Reset "temp" array */
2746 /* Scan the current panel */
2747 for (y = min_hgt; y <= max_hgt; y++)
2749 for (x = min_wid; x <= max_wid; x++)
2753 /* Require "interesting" contents */
2754 if (!target_set_accept(y, x)) continue;
2756 c_ptr = &cave[y][x];
2758 /* Require target_able monsters for "TARGET_KILL" */
2759 if ((mode & (TARGET_KILL)) && !target_able(c_ptr->m_idx)) continue;
2761 if ((mode & (TARGET_KILL)) && !target_pet && is_pet(&m_list[c_ptr->m_idx])) continue;
2763 /* Save the location */
2770 /* Set the sort hooks */
2771 if (mode & (TARGET_KILL))
2773 /* Target the nearest monster for shooting */
2774 ang_sort_comp = ang_sort_comp_distance;
2775 ang_sort_swap = ang_sort_swap_distance;
2779 /* Look important grids first in Look command */
2780 ang_sort_comp = ang_sort_comp_importance;
2781 ang_sort_swap = ang_sort_swap_distance;
2784 /* Sort the positions */
2785 ang_sort(temp_x, temp_y, temp_n);
2787 if (p_ptr->riding && target_pet && (temp_n > 1) && (mode & (TARGET_KILL)))
2792 temp_y[0] = temp_y[1];
2795 temp_x[0] = temp_x[1];
2800 void target_set_prepare_look(void){
2801 target_set_prepare(TARGET_LOOK);
2806 * Evaluate number of kill needed to gain level
2808 static void evaluate_monster_exp(char *buf, monster_type *m_ptr)
2810 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
2812 s32b exp_mon, exp_adv;
2813 u32b exp_mon_frac, exp_adv_frac;
2815 if ((p_ptr->lev >= PY_MAX_LEVEL) || (p_ptr->prace == RACE_ANDROID))
2820 else if (!ap_r_ptr->r_tkills || (m_ptr->mflag2 & MFLAG2_KAGE))
2830 /* The monster's experience point (assuming average monster speed) */
2831 exp_mon = ap_r_ptr->mexp * ap_r_ptr->level;
2833 s64b_div(&exp_mon, &exp_mon_frac, 0, (p_ptr->max_plv + 2));
2836 /* Total experience value for next level */
2837 exp_adv = player_exp[p_ptr->lev -1] * p_ptr->expfact;
2839 s64b_div(&exp_adv, &exp_adv_frac, 0, 100);
2841 /* Experience value need to get */
2842 s64b_sub(&exp_adv, &exp_adv_frac, p_ptr->exp, p_ptr->exp_frac);
2845 /* You need to kill at least one monster to get any experience */
2846 s64b_add(&exp_adv, &exp_adv_frac, exp_mon, exp_mon_frac);
2847 s64b_sub(&exp_adv, &exp_adv_frac, 0, 1);
2849 /* Extract number of monsters needed */
2850 s64b_div(&exp_adv, &exp_adv_frac, exp_mon, exp_mon_frac);
2852 /* If 999 or more monsters needed, only display "999". */
2853 num = MIN(999, exp_adv_frac);
2855 /* Display the number */
2856 sprintf(buf,"%03ld", (long int)num);
2860 bool show_gold_on_floor = FALSE;
2863 * Examine a grid, return a keypress.
2865 * The "mode" argument contains the "TARGET_LOOK" bit flag, which
2866 * indicates that the "space" key should scan through the contents
2867 * of the grid, instead of simply returning immediately. This lets
2868 * the "look" command get complete information, without making the
2869 * "target" command annoying.
2871 * The "info" argument contains the "commands" which should be shown
2872 * inside the "[xxx]" text. This string must never be empty, or grids
2873 * containing monsters will be displayed with an extra comma.
2875 * Note that if a monster is in the grid, we update both the monster
2876 * recall info and the health bar info to track that monster.
2878 * Eventually, we may allow multiple objects per grid, or objects
2879 * and terrain features in the same grid.
2881 * This function must handle blindness/hallucination.
2883 static char target_set_aux(POSITION y, POSITION x, BIT_FLAGS mode, cptr info)
2885 cave_type *c_ptr = &cave[y][x];
2886 OBJECT_IDX this_o_idx, next_o_idx = 0;
2887 cptr s1 = "", s2 = "", s3 = "", x_info = "";
2890 feature_type *f_ptr;
2891 char query = '\001';
2892 char out_val[MAX_NLEN+80];
2893 OBJECT_IDX floor_list[23];
2894 ITEM_NUMBER floor_num = 0;
2896 /* Scan all objects in the grid */
2899 floor_num = scan_floor(floor_list, y, x, 0x02);
2903 x_info = _("x物 ", "x,");
2907 /* Hack -- under the player */
2908 if (player_bold(y, x))
2924 s1 = _("ターゲット:", "Target:");
2927 /* Hack -- hallucination */
2930 cptr name = _("何か奇妙な物", "something strange");
2932 /* Display a message */
2934 sprintf(out_val, "%s%s%s%s [%s]", s1, name, s2, s3, info);
2936 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, name, info);
2940 move_cursor_relative(y, x);
2943 /* Stop on everything but "return" */
2944 if ((query != '\r') && (query != '\n')) return query;
2946 /* Repeat forever */
2951 /* Actual monsters */
2952 if (c_ptr->m_idx && m_list[c_ptr->m_idx].ml)
2954 monster_type *m_ptr = &m_list[c_ptr->m_idx];
2955 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
2957 bool recall = FALSE;
2962 /* Get the monster name ("a kobold") */
2963 monster_desc(m_name, m_ptr, MD_INDEF_VISIBLE);
2965 /* Hack -- track this monster race */
2966 monster_race_track(m_ptr->ap_r_idx);
2968 /* Hack -- health bar for this monster */
2969 health_track(c_ptr->m_idx);
2971 /* Hack -- handle stuff */
2985 /* Recall on screen */
2986 screen_roff(m_ptr->ap_r_idx, 0);
2988 /* Hack -- Complete the prompt (again) */
2989 Term_addstr(-1, TERM_WHITE, format(_(" [r思 %s%s]", " [r,%s%s]"), x_info, info));
2997 /* Normal commands */
2998 if (query != 'r') break;
3003 /* Cleare recall text and repeat */
3009 /* Describe, and prompt for recall */
3010 evaluate_monster_exp(acount, m_ptr);
3013 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);
3015 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);
3021 move_cursor_relative(y, x);
3026 /* Normal commands */
3027 if (query != 'r') break;
3033 /* Always stop at "normal" keys */
3034 if ((query != '\r') && (query != '\n') && (query != ' ') && (query != 'x')) return query;
3036 /* Sometimes stop at "space" key */
3037 if ((query == ' ') && !(mode & (TARGET_LOOK))) return query;
3039 /* Change the intro */
3040 s1 = _("それは", "It is ");
3042 /* Hack -- take account of gender */
3043 if (ap_r_ptr->flags1 & (RF1_FEMALE)) s1 = _("彼女は", "She is ");
3044 else if (ap_r_ptr->flags1 & (RF1_MALE)) s1 = _("彼は", "He is ");
3046 /* Use a preposition */
3055 /* Scan all objects being carried */
3056 for (this_o_idx = m_ptr->hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
3058 char o_name[MAX_NLEN];
3061 o_ptr = &o_list[this_o_idx];
3063 /* Acquire next object */
3064 next_o_idx = o_ptr->next_o_idx;
3066 /* Obtain an object description */
3067 object_desc(o_name, o_ptr, 0);
3070 sprintf(out_val, "%s%s%s%s[%s]", s1, o_name, s2, s3, info);
3072 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, o_name, info);
3076 move_cursor_relative(y, x);
3079 /* Always stop at "normal" keys */
3080 if ((query != '\r') && (query != '\n') && (query != ' ') && (query != 'x')) return query;
3082 /* Sometimes stop at "space" key */
3083 if ((query == ' ') && !(mode & (TARGET_LOOK))) return query;
3085 /* Change the intro */
3086 s2 = _("をまた", "also carrying ");
3089 /* Use a preposition */
3106 char o_name[MAX_NLEN];
3109 o_ptr = &o_list[floor_list[0]];
3111 object_desc(o_name, o_ptr, 0);
3114 sprintf(out_val, "%s%s%s%s[%s]", s1, o_name, s2, s3, info);
3116 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, o_name, info);
3120 move_cursor_relative(y, x);
3129 /* Provide one cushion before item listing */
3132 /* Display rough information about items */
3134 sprintf(out_val, "%s %d個のアイテム%s%s ['x'で一覧, %s]", s1, (int)floor_num, s2, s3, info);
3136 sprintf(out_val, "%s%s%sa pile of %d items [x,%s]", s1, s2, s3, (int)floor_num, info);
3140 move_cursor_relative(y, x);
3145 /* No request for listing */
3146 if (query != 'x' && query != ' ') return query;
3150 /** Display list of items **/
3152 /* Continue scrolling list if requested */
3160 show_gold_on_floor = TRUE;
3161 (void)show_floor(0, y, x, &min_width);
3162 show_gold_on_floor = FALSE;
3166 sprintf(out_val, "%s %d個のアイテム%s%s [Enterで次へ, %s]", s1, (int)floor_num, s2, s3, info);
3168 sprintf(out_val, "%s%s%sa pile of %d items [Enter,%s]", s1, s2, s3, (int)floor_num, info);
3175 /* Exit unless 'Enter' */
3176 if (query != '\n' && query != '\r')
3181 /* Get the object being moved. */
3182 o_idx = c_ptr->o_idx;
3184 /* Only rotate a pile of two or more objects. */
3185 if (!(o_idx && o_list[o_idx].next_o_idx)) continue;
3187 /* Remove the first object from the list. */
3188 excise_object_idx(o_idx);
3190 /* Find end of the list. */
3192 while (o_list[i].next_o_idx)
3193 i = o_list[i].next_o_idx;
3195 /* Add after the last object. */
3196 o_list[i].next_o_idx = o_idx;
3198 /* Loop and re-display the list */
3205 /* Scan all objects in the grid */
3206 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
3209 o_ptr = &o_list[this_o_idx];
3211 /* Acquire next object */
3212 next_o_idx = o_ptr->next_o_idx;
3215 if (o_ptr->marked & OM_FOUND)
3217 char o_name[MAX_NLEN];
3222 /* Obtain an object description */
3223 object_desc(o_name, o_ptr, 0);
3226 sprintf(out_val, "%s%s%s%s[%s]", s1, o_name, s2, s3, info);
3228 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, o_name, info);
3232 move_cursor_relative(y, x);
3235 /* Always stop at "normal" keys */
3236 if ((query != '\r') && (query != '\n') && (query != ' ') && (query != 'x')) return query;
3238 /* Sometimes stop at "space" key */
3239 if ((query == ' ') && !(mode & TARGET_LOOK)) return query;
3241 /* Change the intro */
3242 s1 = _("それは", "It is ");
3245 if (o_ptr->number != 1) s1 = _("それらは", "They are ");
3259 /* Feature code (applying "mimic" field) */
3260 feat = get_feat_mimic(c_ptr);
3262 /* Require knowledge about grid, or ability to see grid */
3263 if (!(c_ptr->info & CAVE_MARK) && !player_can_see_bold(y, x))
3265 /* Forget feature */
3269 f_ptr = &f_info[feat];
3271 /* Terrain feature if needed */
3272 if (boring || have_flag(f_ptr->flags, FF_REMEMBER))
3276 /* Hack -- special handling for quest entrances */
3277 if (have_flag(f_ptr->flags, FF_QUEST_ENTER))
3279 /* Set the quest number temporary */
3280 IDX old_quest = p_ptr->inside_quest;
3283 /* Clear the text */
3284 for (j = 0; j < 10; j++) quest_text[j][0] = '\0';
3285 quest_text_line = 0;
3287 p_ptr->inside_quest = c_ptr->special;
3289 /* Get the quest text */
3290 init_flags = INIT_NAME_ONLY;
3292 process_dungeon_file("q_info.txt", 0, 0, 0, 0);
3294 name = format(_("クエスト「%s」(%d階相当)", "the entrance to the quest '%s'(level %d)"),
3295 quest[c_ptr->special].name, quest[c_ptr->special].level);
3297 /* Reset the old quest number */
3298 p_ptr->inside_quest = old_quest;
3301 /* Hack -- special handling for building doors */
3302 else if (have_flag(f_ptr->flags, FF_BLDG) && !p_ptr->inside_arena)
3304 name = building[f_ptr->subtype].name;
3306 else if (have_flag(f_ptr->flags, FF_ENTRANCE))
3308 name = format(_("%s(%d階相当)", "%s(level %d)"), d_text + d_info[c_ptr->special].text, d_info[c_ptr->special].mindepth);
3310 else if (have_flag(f_ptr->flags, FF_TOWN))
3312 name = town[c_ptr->special].name;
3314 else if (p_ptr->wild_mode && (feat == feat_floor))
3316 name = _("道", "road");
3320 name = f_name + f_ptr->name;
3326 ((!have_flag(f_ptr->flags, FF_MOVE) && !have_flag(f_ptr->flags, FF_CAN_FLY)) ||
3327 (!have_flag(f_ptr->flags, FF_LOS) && !have_flag(f_ptr->flags, FF_TREE)) ||
3328 have_flag(f_ptr->flags, FF_TOWN)))
3330 s2 = _("の中", "in ");
3333 /* Hack -- special introduction for store & building doors -KMW- */
3334 if (have_flag(f_ptr->flags, FF_STORE) ||
3335 have_flag(f_ptr->flags, FF_QUEST_ENTER) ||
3336 (have_flag(f_ptr->flags, FF_BLDG) && !p_ptr->inside_arena) ||
3337 have_flag(f_ptr->flags, FF_ENTRANCE))
3346 else if (have_flag(f_ptr->flags, FF_FLOOR) ||
3347 have_flag(f_ptr->flags, FF_TOWN) ||
3348 have_flag(f_ptr->flags, FF_SHALLOW) ||
3349 have_flag(f_ptr->flags, FF_DEEP))
3355 /* Pick proper indefinite article */
3356 s3 = (is_a_vowel(name[0])) ? "an " : "a ";
3360 /* Display a message */
3364 if (c_ptr->mimic) sprintf(f_idx_str, "%d/%d", c_ptr->feat, c_ptr->mimic);
3365 else sprintf(f_idx_str, "%d", c_ptr->feat);
3367 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]);
3369 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);
3374 sprintf(out_val, "%s%s%s%s[%s]", s1, name, s2, s3, info);
3376 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, name, info);
3380 move_cursor_relative(y, x);
3383 /* Always stop at "normal" keys */
3384 if ((query != '\r') && (query != '\n') && (query != ' ')) return query;
3387 /* Stop on everything but "return" */
3388 if ((query != '\r') && (query != '\n')) return query;
3390 /* Repeat forever */
3396 * Handle "target" and "look".
3398 * Note that this code can be called from "get_aim_dir()".
3400 * All locations must be on the current panel. Consider the use of
3401 * "panel_bounds()" to allow "off-panel" targets, perhaps by using
3402 * some form of "scrolling" the map around the cursor.
3403 * That is, consider the possibility of "auto-scrolling" the screen
3404 * while the cursor moves around. This may require changes in the
3405 * "update_monster()" code to allow "visibility" even if off panel, and
3406 * may require dynamic recalculation of the "temp" grid set.
3408 * Hack -- targeting/observing an "outer border grid" may induce
3409 * problems, so this is not currently allowed.
3411 * The player can use the direction keys to move among "interesting"
3412 * grids in a heuristic manner, or the "space", "+", and "-" keys to
3413 * move through the "interesting" grids in a sequential manner, or
3414 * can enter "location" mode, and use the direction keys to move one
3415 * grid at a time in any direction. The "t" (set target) command will
3416 * only target a monster (as opposed to a location) if the monster is
3417 * target_able and the "interesting" mode is being used.
3419 * The current grid is described using the "look" method above, and
3420 * a new command may be entered at any time, but note that if the
3421 * "TARGET_LOOK" bit flag is set (or if we are in "location" mode,
3422 * where "space" has no obvious meaning) then "space" will scan
3423 * through the description of the current grid until done, instead
3424 * of immediately jumping to the next "interesting" grid. This
3425 * allows the "target" command to retain its old semantics.
3427 * The "*", "+", and "-" keys may always be used to jump immediately
3428 * to the next (or previous) interesting grid, in the proper mode.
3430 * The "return" key may always be used to scan through a complete
3431 * grid description (forever).
3433 * This command will cancel any old target, even if used from
3434 * inside the "look" command.
3436 bool target_set(BIT_FLAGS mode)
3439 POSITION y = p_ptr->y;
3440 POSITION x = p_ptr->x;
3452 get_screen_size(&wid, &hgt);
3458 /* Cancel tracking */
3459 /* health_track(0); */
3461 if (rogue_like_commands)
3470 /* Prepare the "temp" array */
3471 target_set_prepare(mode);
3473 /* Start near the player */
3479 /* Interesting grids */
3486 change_panel_xy(y, x);
3488 if (!(mode & TARGET_LOOK)) prt_path(y, x);
3491 c_ptr = &cave[y][x];
3494 if (target_able(c_ptr->m_idx))
3496 strcpy(info, _("q止 t決 p自 o現 +次 -前", "q,t,p,o,+,-,<dir>"));
3499 /* Dis-allow target */
3502 strcpy(info, _("q止 p自 o現 +次 -前", "q,p,o,+,-,<dir>"));
3508 sprintf(cheatinfo, " LOS:%d, PROJECTABLE:%d",
3509 los(p_ptr->y, p_ptr->x, y, x),
3510 projectable(p_ptr->y, p_ptr->x, y, x));
3511 strcat(info, cheatinfo);
3514 /* Describe and Prompt */
3516 query = target_set_aux(y, x, mode, info);
3520 /* Cancel tracking */
3521 /* health_track(0); */
3523 /* Assume no "direction" */
3528 if (query == '\r') query = 't';
3546 if (target_able(c_ptr->m_idx))
3548 health_track(c_ptr->m_idx);
3549 target_who = c_ptr->m_idx;
3568 if (!expand_list) done = TRUE;
3578 if (!expand_list) done = TRUE;
3585 /* Recenter the map around the player */
3588 p_ptr->update |= (PU_MONSTERS);
3590 p_ptr->redraw |= (PR_MAP);
3592 p_ptr->window |= (PW_OVERHEAD);
3595 /* Recalculate interesting grids */
3596 target_set_prepare(mode);
3615 if(query == same_key)
3620 if (!expand_list) done = TRUE;
3625 /* Extract the action (if any) */
3626 d = get_keymap_dir(query);
3633 /* Hack -- move around */
3636 /* Modified to scroll to monster */
3637 POSITION y2 = panel_row_min;
3638 POSITION x2 = panel_col_min;
3640 /* Find a new monster */
3641 i = target_pick(temp_y[m], temp_x[m], ddy[d], ddx[d]);
3643 /* Request to target past last interesting grid */
3644 while (flag && (i < 0))
3646 /* Note the change */
3647 if (change_panel(ddy[d], ddx[d]))
3652 /* Recalculate interesting grids */
3653 target_set_prepare(mode);
3655 /* Look at interesting grids */
3658 /* Find a new monster */
3659 i = target_pick(v, u, ddy[d], ddx[d]);
3665 /* Nothing interesting */
3671 /* Restore previous position */
3674 panel_bounds_center();
3676 p_ptr->update |= (PU_MONSTERS);
3678 p_ptr->redraw |= (PR_MAP);
3680 p_ptr->window |= (PW_OVERHEAD);
3683 /* Recalculate interesting grids */
3684 target_set_prepare(mode);
3686 /* Look at boring grids */
3693 /* Do not move horizontally if unnecessary */
3694 if (((x < panel_col_min + wid / 2) && (dx > 0)) ||
3695 ((x > panel_col_min + wid / 2) && (dx < 0)))
3700 /* Do not move vertically if unnecessary */
3701 if (((y < panel_row_min + hgt / 2) && (dy > 0)) ||
3702 ((y > panel_row_min + hgt / 2) && (dy < 0)))
3707 /* Apply the motion */
3708 if ((y >= panel_row_min+hgt) || (y < panel_row_min) ||
3709 (x >= panel_col_min+wid) || (x < panel_col_min))
3711 if (change_panel(dy, dx)) target_set_prepare(mode);
3714 /* Slide into legality */
3715 if (x >= cur_wid-1) x = cur_wid - 2;
3716 else if (x <= 0) x = 1;
3718 /* Slide into legality */
3719 if (y >= cur_hgt-1) y = cur_hgt- 2;
3720 else if (y <= 0) y = 1;
3729 /* Arbitrary grids */
3732 bool move_fast = FALSE;
3734 if (!(mode & TARGET_LOOK)) prt_path(y, x);
3737 c_ptr = &cave[y][x];
3739 /* Default prompt */
3740 strcpy(info, _("q止 t決 p自 m近 +次 -前", "q,t,p,m,+,-,<dir>"));
3745 sprintf(cheatinfo, " LOS:%d, PROJECTABLE:%d",
3746 los(p_ptr->y, p_ptr->x, y, x),
3747 projectable(p_ptr->y, p_ptr->x, y, x));
3748 strcat(info, cheatinfo);
3751 /* Describe and Prompt (enable "TARGET_LOOK") */
3752 while ((query = target_set_aux(y, x, mode | TARGET_LOOK, info)) == 0);
3754 /* Cancel tracking */
3755 /* health_track(0); */
3757 /* Assume no direction */
3762 if (query == '\r') query = 't';
3765 /* Analyze the keypress */
3789 /* Recenter the map around the player */
3792 p_ptr->update |= (PU_MONSTERS);
3794 p_ptr->redraw |= (PR_MAP);
3796 p_ptr->window |= (PW_OVERHEAD);
3799 /* Recalculate interesting grids */
3800 target_set_prepare(mode);
3822 /* Pick a nearby monster */
3823 for (i = 0; i < temp_n; i++)
3825 t = distance(y, x, temp_y[i], temp_x[i]);
3835 /* Nothing interesting */
3836 if (bd == 999) flag = FALSE;
3843 /* Extract the action (if any) */
3844 d = get_keymap_dir(query);
3846 /* XTRA HACK MOVEFAST */
3847 if (isupper(query)) move_fast = TRUE;
3854 /* Handle "direction" */
3860 /* XTRA HACK MOVEFAST */
3863 int mag = MIN(wid / 2, hgt / 2);
3873 /* Do not move horizontally if unnecessary */
3874 if (((x < panel_col_min + wid / 2) && (dx > 0)) ||
3875 ((x > panel_col_min + wid / 2) && (dx < 0)))
3880 /* Do not move vertically if unnecessary */
3881 if (((y < panel_row_min + hgt / 2) && (dy > 0)) ||
3882 ((y > panel_row_min + hgt / 2) && (dy < 0)))
3887 /* Apply the motion */
3888 if ((y >= panel_row_min + hgt) || (y < panel_row_min) ||
3889 (x >= panel_col_min + wid) || (x < panel_col_min))
3891 if (change_panel(dy, dx)) target_set_prepare(mode);
3894 /* Slide into legality */
3895 if (x >= cur_wid-1) x = cur_wid - 2;
3896 else if (x <= 0) x = 1;
3898 /* Slide into legality */
3899 if (y >= cur_hgt-1) y = cur_hgt- 2;
3900 else if (y <= 0) y = 1;
3908 /* Clear the top line */
3911 /* Recenter the map around the player */
3914 p_ptr->update |= (PU_MONSTERS);
3916 p_ptr->redraw |= (PR_MAP);
3918 p_ptr->window |= (PW_OVERHEAD);
3921 /* Failure to set target */
3922 if (!target_who) return (FALSE);
3930 * Get an "aiming direction" from the user.
3932 * The "dir" is loaded with 1,2,3,4,6,7,8,9 for "actual direction", and
3933 * "0" for "current target", and "-1" for "entry aborted".
3935 * Note that "Force Target", if set, will pre-empt user interaction,
3936 * if there is a usable target already set.
3938 * Note that confusion over-rides any (explicit?) user choice.
3940 bool get_aim_dir(DIRECTION *dp)
3949 /* Global direction */
3952 /* Hack -- auto-target if requested */
3953 if (use_old_target && target_okay()) dir = 5;
3955 if (repeat_pull(&code))
3960 if (!(code == 5 && !target_okay()))
3962 /* return (TRUE); */
3963 dir = (DIRECTION)code;
3966 *dp = (DIRECTION)code;
3968 /* Ask until satisfied */
3971 /* Choose a prompt */
3974 p = _("方向 ('*'でターゲット選択, ESCで中断)? ", "Direction ('*' to choose a target, Escape to cancel)? ");
3978 p = _("方向 ('5'でターゲットへ, '*'でターゲット再選択, ESCで中断)? ", "Direction ('5' for target, '*' to re-target, Escape to cancel)? ");
3981 /* Get a command (or Cancel) */
3982 if (!get_com(p, &command, TRUE)) break;
3986 if (command == '\r') command = 't';
3989 /* Convert various keys to "standard" keys */
3992 /* Use current target */
4003 /* Set new target */
4008 if (target_set(TARGET_KILL)) dir = 5;
4014 /* Extract the action (if any) */
4015 dir = get_keymap_dir(command);
4021 /* Verify requested targets */
4022 if ((dir == 5) && !target_okay()) dir = 0;
4031 project_length = 0; /* reset to default */
4035 /* Save the direction */
4038 /* Check for confusion */
4039 if (p_ptr->confused)
4041 /* Random direction */
4042 dir = ddd[randint0(8)];
4045 /* Notice confusion */
4046 if (command_dir != dir)
4049 msg_print(_("あなたは混乱している。", "You are confused."));
4052 /* Save direction */
4055 /* repeat_push(dir); */
4056 repeat_push((COMMAND_CODE)command_dir);
4058 /* A "valid" direction was entered */
4063 bool get_direction(DIRECTION *dp, bool allow_under, bool with_steed)
4071 /* Global direction */
4074 if (repeat_pull(&code))
4076 dir = (DIRECTION)code;
4077 /* return (TRUE); */
4079 *dp = (DIRECTION)code;
4083 prompt = _("方向 ('.'足元, ESCで中断)? ", "Direction ('.' at feet, Escape to cancel)? ");
4087 prompt = _("方向 (ESCで中断)? ", "Direction (Escape to cancel)? ");
4090 /* Get a direction */
4095 /* Get a command (or Cancel) */
4096 if (!get_com(prompt, &ch, TRUE)) break;
4099 if ((allow_under) && ((ch == '5') || (ch == '-') || (ch == '.')))
4105 /* Look up the direction */
4106 dir = get_keymap_dir(ch);
4112 /* Prevent weirdness */
4113 if ((dir == 5) && (!allow_under)) dir = 0;
4116 if (!dir) return (FALSE);
4118 /* Save desired direction */
4121 /* Apply "confusion" */
4122 if (p_ptr->confused)
4124 /* Standard confusion */
4125 if (randint0(100) < 75)
4127 /* Random direction */
4128 dir = ddd[randint0(8)];
4131 else if (p_ptr->riding && with_steed)
4133 monster_type *m_ptr = &m_list[p_ptr->riding];
4134 monster_race *r_ptr = &r_info[m_ptr->r_idx];
4136 if (MON_CONFUSED(m_ptr))
4138 /* Standard confusion */
4139 if (randint0(100) < 75)
4141 /* Random direction */
4142 dir = ddd[randint0(8)];
4145 else if ((r_ptr->flags1 & RF1_RAND_50) && (r_ptr->flags1 & RF1_RAND_25) && (randint0(100) < 50))
4147 /* Random direction */
4148 dir = ddd[randint0(8)];
4150 else if ((r_ptr->flags1 & RF1_RAND_50) && (randint0(100) < 25))
4152 /* Random direction */
4153 dir = ddd[randint0(8)];
4157 /* Notice confusion */
4158 if (command_dir != dir)
4160 if (p_ptr->confused)
4163 msg_print(_("あなたは混乱している。", "You are confused."));
4168 monster_type *m_ptr = &m_list[p_ptr->riding];
4170 monster_desc(m_name, m_ptr, 0);
4171 if (MON_CONFUSED(m_ptr))
4173 msg_format(_("%sは混乱している。", "%^s is confusing."), m_name);
4177 msg_format(_("%sは思い通りに動いてくれない。", "You cannot control %s."), m_name);
4182 /* Save direction */
4185 /* repeat_push(dir); */
4186 repeat_push((COMMAND_CODE)command_dir);
4193 * @brief 進行方向を指定する(騎乗対象の混乱の影響を受ける) / Request a "movement" direction (1,2,3,4,6,7,8,9) from the user,
4194 * and place it into "command_dir", unless we already have one.
4196 * This function should be used for all "repeatable" commands, such as
4197 * run, walk, open, close, bash, disarm, spike, tunnel, etc, as well
4198 * as all commands which must reference a grid adjacent to the player,
4199 * and which may not reference the grid under the player. Note that,
4200 * for example, it is no longer possible to "disarm" or "open" chests
4201 * in the same grid as the player.
4203 * Direction "5" is illegal and will (cleanly) abort the command.
4205 * This function tracks and uses the "global direction", and uses
4206 * that as the "desired direction", to which "confusion" is applied.
4208 bool get_rep_dir(DIRECTION *dp, bool under)
4216 /* Global direction */
4219 if (repeat_pull(&code))
4221 dir = (DIRECTION)code;
4222 /* return (TRUE); */
4224 *dp = (DIRECTION)code;
4228 prompt = _("方向 ('.'足元, ESCで中断)? ", "Direction ('.' at feet, Escape to cancel)? ");
4232 prompt = _("方向 (ESCで中断)? ", "Direction (Escape to cancel)? ");
4235 /* Get a direction */
4240 /* Get a command (or Cancel) */
4241 if (!get_com(prompt, &ch, TRUE)) break;
4244 if ((under) && ((ch == '5') || (ch == '-') || (ch == '.')))
4250 /* Look up the direction */
4251 dir = get_keymap_dir(ch);
4257 /* Prevent weirdness */
4258 if ((dir == 5) && (!under)) dir = 0;
4261 if (!dir) return (FALSE);
4263 /* Save desired direction */
4266 /* Apply "confusion" */
4267 if (p_ptr->confused)
4269 /* Standard confusion */
4270 if (randint0(100) < 75)
4272 /* Random direction */
4273 dir = ddd[randint0(8)];
4276 else if (p_ptr->riding)
4278 monster_type *m_ptr = &m_list[p_ptr->riding];
4279 monster_race *r_ptr = &r_info[m_ptr->r_idx];
4281 if (MON_CONFUSED(m_ptr))
4283 /* Standard confusion */
4284 if (randint0(100) < 75)
4286 /* Random direction */
4287 dir = ddd[randint0(8)];
4290 else if ((r_ptr->flags1 & RF1_RAND_50) && (r_ptr->flags1 & RF1_RAND_25) && (randint0(100) < 50))
4292 /* Random direction */
4293 dir = ddd[randint0(8)];
4295 else if ((r_ptr->flags1 & RF1_RAND_50) && (randint0(100) < 25))
4297 /* Random direction */
4298 dir = ddd[randint0(8)];
4302 /* Notice confusion */
4303 if (command_dir != dir)
4305 if (p_ptr->confused)
4308 msg_print(_("あなたは混乱している。", "You are confused."));
4313 monster_type *m_ptr = &m_list[p_ptr->riding];
4315 monster_desc(m_name, m_ptr, 0);
4316 if (MON_CONFUSED(m_ptr))
4318 msg_format(_("%sは混乱している。", "%^s is confusing."), m_name);
4322 msg_format(_("%sは思い通りに動いてくれない。", "You cannot control %s."), m_name);
4327 /* Save direction */
4330 /* repeat_push(dir); */
4331 repeat_push((COMMAND_CODE)command_dir);
4337 void gain_level_reward(int chosen_reward)
4341 char wrath_reason[32] = "";
4342 int nasty_chance = 6;
4343 OBJECT_TYPE_VALUE dummy = 0;
4344 OBJECT_SUBTYPE_VALUE dummy2 = 0;
4347 char o_name[MAX_NLEN];
4353 if (multi_rew) return;
4354 else multi_rew = TRUE;
4358 if (p_ptr->lev == 13) nasty_chance = 2;
4359 else if (!(p_ptr->lev % 13)) nasty_chance = 3;
4360 else if (!(p_ptr->lev % 14)) nasty_chance = 12;
4362 if (one_in_(nasty_chance))
4363 type = randint1(20); /* Allow the 'nasty' effects */
4365 type = randint1(15) + 5; /* Or disallow them */
4367 if (type < 1) type = 1;
4368 if (type > 20) type = 20;
4372 sprintf(wrath_reason, _("%sの怒り", "the Wrath of %s"), chaos_patrons[p_ptr->chaos_patron]);
4374 effect = chaos_rewards[p_ptr->chaos_patron][type];
4376 if (one_in_(6) && !chosen_reward)
4378 msg_format(_("%^sは褒美としてあなたを突然変異させた。", "%^s rewards you with a mutation!"), chaos_patrons[p_ptr->chaos_patron]);
4379 (void)gain_random_mutation(0);
4380 reward = _("変異した。", "mutation");
4384 switch (chosen_reward ? chosen_reward : effect)
4389 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4390 msg_print(_("「汝、新たなる姿を必要とせり!」", "'Thou needst a new form, mortal!'"));
4393 reward = _("変異した。", "polymorphing");
4398 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4399 msg_print(_("「汝は良く行いたり!続けよ!」", "'Well done, mortal! Lead on!'"));
4401 if (p_ptr->prace == RACE_ANDROID)
4403 msg_print(_("しかし何も起こらなかった。", "But, nothing happen."));
4405 else if (p_ptr->exp < PY_MAX_EXP)
4407 s32b ee = (p_ptr->exp / 2) + 10;
4408 if (ee > 100000L) ee = 100000L;
4409 msg_print(_("更に経験を積んだような気がする。", "You feel more experienced."));
4412 reward = _("経験値を得た", "experience");
4418 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4419 msg_print(_("「下僕よ、汝それに値せず。」", "'Thou didst not deserve that, slave.'"));
4421 if (p_ptr->prace == RACE_ANDROID)
4423 msg_print(_("しかし何も起こらなかった。", "But, nothing happen."));
4427 lose_exp(p_ptr->exp / 6);
4428 reward = _("経験値を失った。", "losing experience");
4434 msg_format("%sの声がささやいた:",
4435 chaos_patrons[p_ptr->chaos_patron]);
4437 msg_format("The voice of %s whispers:",
4438 chaos_patrons[p_ptr->chaos_patron]);
4441 msg_print(_("「我が与えし物を賢明に使うべし。」", "'Use my gift wisely.'"));
4443 acquirement(p_ptr->y, p_ptr->x, 1, FALSE, FALSE, FALSE);
4444 reward = _("上質なアイテムを手に入れた。", "a good item");
4449 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4450 msg_print(_("「我が与えし物を賢明に使うべし。」", "'Use my gift wisely.'"));
4452 acquirement(p_ptr->y, p_ptr->x, 1, TRUE, FALSE, FALSE);
4453 reward = _("高級品のアイテムを手に入れた。", "an excellent item");
4458 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4459 msg_print(_("「汝の行いは貴き剣に値せり。」", "'Thy deed hath earned thee a worthy blade.'"));
4462 switch (randint1(p_ptr->lev))
4468 dummy2 = SV_MAIN_GAUCHE;
4477 dummy2 = SV_SMALL_SWORD;
4480 dummy2 = SV_BASILLARD;
4482 case 11: case 12: case 13:
4483 dummy2 = SV_SHORT_SWORD;
4489 dummy2 = SV_CUTLASS;
4492 dummy2 = SV_WAKIZASHI;
4495 dummy2 = SV_KHOPESH;
4501 dummy2 = SV_BROAD_SWORD;
4504 dummy2 = SV_LONG_SWORD;
4507 dummy2 = SV_SCIMITAR;
4510 dummy2 = SV_NINJATO;
4516 dummy2 = SV_BASTARD_SWORD;
4519 dummy2 = SV_GREAT_SCIMITAR;
4522 dummy2 = SV_CLAYMORE;
4525 dummy2 = SV_ESPADON;
4528 dummy2 = SV_TWO_HANDED_SWORD;
4531 dummy2 = SV_FLAMBERGE;
4534 dummy2 = SV_NO_DACHI;
4537 dummy2 = SV_EXECUTIONERS_SWORD;
4540 dummy2 = SV_ZWEIHANDER;
4543 dummy2 = SV_HAYABUSA;
4546 dummy2 = SV_BLADE_OF_CHAOS;
4549 object_prep(q_ptr, lookup_kind(dummy, dummy2));
4550 q_ptr->to_h = 3 + randint1(dun_level) % 10;
4551 q_ptr->to_d = 3 + randint1(dun_level) % 10;
4552 one_resistance(q_ptr);
4553 q_ptr->name2 = EGO_CHAOTIC;
4555 /* Drop it in the dungeon */
4556 (void)drop_near(q_ptr, -1, p_ptr->y, p_ptr->x);
4557 reward = _("(混沌)の武器を手に入れた。", "chaos weapon");
4562 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4563 msg_print(_("「汝の行いは貴き報いに値せり。」", "'Thy deed hath earned thee a worthy reward.'"));
4565 acquirement(p_ptr->y, p_ptr->x, randint1(2) + 1, FALSE, FALSE, FALSE);
4566 reward = _("上質なアイテムを手に入れた。", "good items");
4571 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4572 msg_print(_("「下僕よ、汝の献身への我が惜しみ無き報いを見るがよい。」", "'Behold, mortal, how generously I reward thy loyalty.'"));
4574 acquirement(p_ptr->y, p_ptr->x, randint1(2) + 1, TRUE, FALSE, FALSE);
4575 reward = _("高級品のアイテムを手に入れた。", "excellent items");
4580 msg_format("%sの声が轟き渡った:", chaos_patrons[p_ptr->chaos_patron]);
4582 msg_format("The voice of %s thunders:", chaos_patrons[p_ptr->chaos_patron]);
4585 msg_print(_("「下僕よ、汝傲慢なり。」", "'Thou art growing arrogant, mortal.'"));
4587 (void)activate_ty_curse(FALSE, &count);
4588 reward = _("禍々しい呪いをかけられた。", "cursing");
4593 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4594 msg_print(_("「我が下僕たちよ、かの傲慢なる者を倒すべし!」", "'My pets, destroy the arrogant mortal!'"));
4596 for (dummy = 0; dummy < randint1(5) + 1; dummy++)
4598 (void)summon_specific(0, p_ptr->y, p_ptr->x, dun_level, 0, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET));
4600 reward = _("モンスターを召喚された。", "summoning hostile monsters");
4606 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4607 msg_print(_("「汝、より強き敵を必要とせり!」", "'Thou needst worthier opponents!'"));
4609 activate_hi_summon(p_ptr->y, p_ptr->x, FALSE);
4610 reward = _("モンスターを召喚された。", "summoning many hostile monsters");
4616 msg_format("%sの声が響き渡った:",
4617 chaos_patrons[p_ptr->chaos_patron]);
4619 msg_format("The voice of %s booms out:",
4620 chaos_patrons[p_ptr->chaos_patron]);
4623 msg_print(_("「死と破壊こそ我が喜びなり!」", "'Death and destruction! This pleaseth me!'"));
4626 reward = _("カオスの力が渦巻いた。", "calling chaos");
4632 msg_format("%sの声が鳴り響いた:",
4633 chaos_patrons[p_ptr->chaos_patron]);
4635 msg_format("The voice of %s rings out:",
4636 chaos_patrons[p_ptr->chaos_patron]);
4639 msg_print(_("「留まるのだ、下僕よ。余が汝の肉体を鍛えん。」", "'Stay, mortal, and let me mold thee.'"));
4641 if (one_in_(3) && !(chaos_stats[p_ptr->chaos_patron] < 0))
4642 do_inc_stat(chaos_stats[p_ptr->chaos_patron]);
4644 do_inc_stat(randint0(6));
4645 reward = _("能力値が上がった。", "increasing a stat");
4651 msg_format("%sの声が響き渡った:",
4652 chaos_patrons[p_ptr->chaos_patron]);
4654 msg_format("The voice of %s booms out:",
4655 chaos_patrons[p_ptr->chaos_patron]);
4658 msg_print(_("「下僕よ、余は汝に飽みたり。」", "'I grow tired of thee, mortal.'"));
4660 if (one_in_(3) && !(chaos_stats[p_ptr->chaos_patron] < 0))
4661 do_dec_stat(chaos_stats[p_ptr->chaos_patron]);
4663 (void)do_dec_stat(randint0(6));
4664 reward = _("能力値が下がった。", "decreasing a stat");
4671 msg_format("%sの声が轟き渡った:",
4672 chaos_patrons[p_ptr->chaos_patron]);
4674 msg_format("The voice of %s thunders:",
4675 chaos_patrons[p_ptr->chaos_patron]);
4678 msg_print(_("「汝、謙虚たることを学ぶべし!」", "'Thou needst a lesson in humility, mortal!'"));
4679 msg_print(_("あなたは以前より弱くなった!", "You feel less powerful!"));
4681 for (dummy = 0; dummy < 6; dummy++)
4683 (void)dec_stat(dummy, 10 + randint1(15), TRUE);
4685 reward = _("全能力値が下がった。", "decreasing all stats");
4690 msg_format(_("%sの力が触れるのを感じた。", "You feel the power of %s touch you."),
4691 chaos_patrons[p_ptr->chaos_patron]);
4693 reward = _("傷が変化した。", "polymorphing wounds");
4698 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4700 msg_print(_("「我がささやかなる賜物を受けとるがよい!」", "'Receive this modest gift from me!'"));
4702 for (dummy = 0; dummy < 6; dummy++)
4704 (void)do_inc_stat(dummy);
4706 reward = _("全能力値が上がった。", "increasing all stats");
4711 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4712 msg_print(_("「苦しむがよい、無能な愚か者よ!」", "'Suffer, pathetic fool!'"));
4714 fire_ball(GF_DISINTEGRATE, 0, p_ptr->lev * 4, 4);
4715 take_hit(DAMAGE_NOESCAPE, p_ptr->lev * 4, wrath_reason, -1);
4716 reward = _("分解の球が発生した。", "generating disintegration ball");
4721 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4722 (void)restore_level();
4723 (void)restore_all_status();
4724 (void)true_healing(5000);
4725 reward = _("体力が回復した。", "healing");
4730 if (!buki_motteruka(INVEN_RARM) && !buki_motteruka(INVEN_LARM)) break;
4731 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4732 msg_print(_("「汝、武器に頼ることなかれ。」", "'Thou reliest too much on thy weapon.'"));
4735 if (buki_motteruka(INVEN_LARM))
4738 if (buki_motteruka(INVEN_RARM) && one_in_(2)) dummy = INVEN_RARM;
4740 object_desc(o_name, &inventory[dummy], OD_NAME_ONLY);
4741 (void)curse_weapon(FALSE, dummy);
4742 reward = format(_("%sが破壊された。", "destroying %s"), o_name);
4747 if (!inventory[INVEN_BODY].k_idx) break;
4748 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4749 msg_print(_("「汝、防具に頼ることなかれ。」", "'Thou reliest too much on thine equipment.'"));
4751 object_desc(o_name, &inventory[INVEN_BODY], OD_NAME_ONLY);
4752 (void)curse_armor();
4753 reward = format(_("%sが破壊された。", "destroying %s"), o_name);
4757 msg_format(_("%sの声がささやいた:", "The voice of %s whispers:"), chaos_patrons[p_ptr->chaos_patron]);
4758 msg_print(_("「我を怒りしめた罪を償うべし。」", "'Now thou shalt pay for annoying me.'"));
4760 switch (randint1(4))
4763 (void)activate_ty_curse(FALSE, &count);
4764 reward = _("禍々しい呪いをかけられた。", "cursing");
4767 activate_hi_summon(p_ptr->y, p_ptr->x, FALSE);
4768 reward = _("モンスターを召喚された。", "summoning hostile monsters");
4773 if (!buki_motteruka(INVEN_RARM) && !buki_motteruka(INVEN_LARM)) break;
4775 if (buki_motteruka(INVEN_LARM))
4778 if (buki_motteruka(INVEN_RARM) && one_in_(2)) dummy = INVEN_RARM;
4780 object_desc(o_name, &inventory[dummy], OD_NAME_ONLY);
4781 (void)curse_weapon(FALSE, dummy);
4782 reward = format(_("%sが破壊された。", "destroying %s"), o_name);
4786 if (!inventory[INVEN_BODY].k_idx) break;
4787 object_desc(o_name, &inventory[INVEN_BODY], OD_NAME_ONLY);
4788 (void)curse_armor();
4789 reward = format(_("%sが破壊された。", "destroying %s"), o_name);
4793 for (dummy = 0; dummy < 6; dummy++)
4795 (void)dec_stat(dummy, 10 + randint1(15), TRUE);
4797 reward = _("全能力値が下がった。", "decreasing all stats");
4804 msg_format(_("%sの声が轟き渡った:", "The voice of %s thunders:"), chaos_patrons[p_ptr->chaos_patron]);
4805 msg_print(_("「死ぬがよい、下僕よ!」", "'Die, mortal!'"));
4807 take_hit(DAMAGE_LOSELIFE, p_ptr->lev * 4, wrath_reason, -1);
4808 for (dummy = 0; dummy < 6; dummy++)
4810 (void)dec_stat(dummy, 10 + randint1(15), FALSE);
4812 activate_hi_summon(p_ptr->y, p_ptr->x, FALSE);
4813 (void)activate_ty_curse(FALSE, &count);
4818 if (buki_motteruka(INVEN_RARM))
4821 if (buki_motteruka(INVEN_LARM) && one_in_(2)) dummy = INVEN_LARM;
4823 else if (buki_motteruka(INVEN_LARM)) dummy = INVEN_LARM;
4825 if (dummy) (void)curse_weapon(FALSE, dummy);
4827 if (one_in_(2)) (void)curse_armor();
4832 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4833 msg_print(_("「死と破壊こそ我が喜びなり!」", "'Death and destruction! This pleaseth me!'"));
4835 (void)destroy_area(p_ptr->y, p_ptr->x, 25, FALSE);
4836 reward = _("ダンジョンが*破壊*された。", "*destruct*ing dungeon");
4841 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4842 msg_print(_("「我、汝の敵を抹殺せん!」", "'Let me relieve thee of thine oppressors!'"));
4843 (void)symbol_genocide(0, FALSE);
4844 reward = _("モンスターが抹殺された。", "genociding monsters");
4849 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4850 msg_print(_("「我、汝の敵を抹殺せん!」", "'Let me relieve thee of thine oppressors!'"));
4852 (void)mass_genocide(0, FALSE);
4853 reward = _("モンスターが抹殺された。", "genociding nearby monsters");
4858 msg_format(_("%sの力が敵を攻撃するのを感じた!", "You can feel the power of %s assault your enemies!"), chaos_patrons[p_ptr->chaos_patron]);
4859 (void)dispel_monsters(p_ptr->lev * 4);
4864 msg_format(_("%sはあなたを無視した。", "%s ignores you."), chaos_patrons[p_ptr->chaos_patron]);
4869 msg_format(_("%sは褒美として悪魔の使いをよこした!", "%s rewards you with a demonic servant!"),chaos_patrons[p_ptr->chaos_patron]);
4871 if (!summon_specific(-1, p_ptr->y, p_ptr->x, dun_level, SUMMON_DEMON, PM_FORCE_PET))
4872 msg_print(_("何も現れなかった...", "Nobody ever turns up..."));
4874 reward = _("悪魔がペットになった。", "a demonic servant");
4879 msg_format(_("%sは褒美として使いをよこした!", "%s rewards you with a servant!"),chaos_patrons[p_ptr->chaos_patron]);
4881 if (!summon_specific(-1, p_ptr->y, p_ptr->x, dun_level, 0, PM_FORCE_PET))
4882 msg_print(_("何も現れなかった...", "Nobody ever turns up..."));
4884 reward = _("モンスターがペットになった。", "a servant");
4889 msg_format(_("%sは褒美としてアンデッドの使いをよこした。", "%s rewards you with an undead servant!"),chaos_patrons[p_ptr->chaos_patron]);
4891 if (!summon_specific(-1, p_ptr->y, p_ptr->x, dun_level, SUMMON_UNDEAD, PM_FORCE_PET))
4892 msg_print(_("何も現れなかった...", "Nobody ever turns up..."));
4894 reward = _("アンデッドがペットになった。", "an undead servant");
4899 msg_format(_("%sの声がどもった:", "The voice of %s stammers:"),
4901 chaos_patrons[p_ptr->chaos_patron]);
4902 msg_format(_("「あー、あー、答えは %d/%d。質問は何?」", "'Uh... uh... the answer's %d/%d, what's the question?'"), type, effect);
4908 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, format(_("パトロンの報酬で%s", "The patron rewards you with %s."), reward));
4914 * XAngband: determine if a given location is "interesting"
4915 * based on target_set_accept function.
4917 static bool tgt_pt_accept(POSITION y, POSITION x)
4922 if (!(in_bounds(y, x))) return (FALSE);
4924 /* Player grid is always interesting */
4925 if ((y == p_ptr->y) && (x == p_ptr->x)) return (TRUE);
4927 /* Handle hallucination */
4928 if (p_ptr->image) return (FALSE);
4930 /* Examine the grid */
4931 c_ptr = &cave[y][x];
4933 /* Interesting memorized features */
4934 if (c_ptr->info & (CAVE_MARK))
4937 if (cave_have_flag_grid(c_ptr, FF_LESS)) return (TRUE);
4938 if (cave_have_flag_grid(c_ptr, FF_MORE)) return (TRUE);
4940 /* Notice quest features */
4941 if (cave_have_flag_grid(c_ptr, FF_QUEST_ENTER)) return (TRUE);
4942 if (cave_have_flag_grid(c_ptr, FF_QUEST_EXIT)) return (TRUE);
4950 * XAngband: Prepare the "temp" array for "tget_pt"
4951 * based on target_set_prepare funciton.
4953 static void tgt_pt_prepare(void)
4957 /* Reset "temp" array */
4960 if (!expand_list) return;
4962 /* Scan the current panel */
4963 for (y = 1; y < cur_hgt; y++)
4965 for (x = 1; x < cur_wid; x++)
4967 /* Require "interesting" contents */
4968 if (!tgt_pt_accept(y, x)) continue;
4970 /* Save the location */
4977 /* Target the nearest monster for shooting */
4978 ang_sort_comp = ang_sort_comp_distance;
4979 ang_sort_swap = ang_sort_swap_distance;
4981 /* Sort the positions */
4982 ang_sort(temp_x, temp_y, temp_n);
4986 * old -- from PsiAngband.
4988 bool tgt_pt(POSITION *x_ptr, POSITION *y_ptr)
4993 bool success = FALSE;
4997 get_screen_size(&wid, &hgt);
5007 msg_print(_("場所を選んでスペースキーを押して下さい。", "Select a point and press space."));
5008 msg_flag = FALSE; /* prevents "-more-" message. */
5010 while ((ch != ESCAPE) && !success)
5012 bool move_fast = FALSE;
5014 move_cursor_relative(y, x);
5026 if (player_bold(y, x)) ch = 0;
5029 else success = TRUE;
5033 /* XAngband: Move cursor to stairs */
5036 if (expand_list && temp_n)
5039 int cx = (panel_col_min + panel_col_max) / 2;
5040 int cy = (panel_row_min + panel_row_max) / 2;
5044 /* Skip stairs which have defferent distance */
5045 for (; n < temp_n; ++ n)
5047 cave_type *c_ptr = &cave[temp_y[n]][temp_x[n]];
5049 if (cave_have_flag_grid(c_ptr, FF_STAIRS) &&
5050 cave_have_flag_grid(c_ptr, ch == '>' ? FF_MORE : FF_LESS))
5057 if (n == temp_n) /* Loop out taget list */
5062 verify_panel(); /* Move cursor to player */
5064 p_ptr->update |= (PU_MONSTERS);
5066 p_ptr->redraw |= (PR_MAP);
5068 p_ptr->window |= (PW_OVERHEAD);
5071 else /* move cursor to next stair and change panel */
5076 dy = 2 * (y - cy) / hgt;
5077 dx = 2 * (x - cx) / wid;
5078 if (dy || dx) change_panel(dy, dx);
5084 /* Look up the direction */
5085 d = get_keymap_dir(ch);
5087 /* XTRA HACK MOVEFAST */
5088 if (isupper(ch)) move_fast = TRUE;
5090 /* Handle "direction" */
5096 /* XTRA HACK MOVEFAST */
5099 int mag = MIN(wid / 2, hgt / 2);
5109 /* Do not move horizontally if unnecessary */
5110 if (((x < panel_col_min + wid / 2) && (dx > 0)) ||
5111 ((x > panel_col_min + wid / 2) && (dx < 0)))
5116 /* Do not move vertically if unnecessary */
5117 if (((y < panel_row_min + hgt / 2) && (dy > 0)) ||
5118 ((y > panel_row_min + hgt / 2) && (dy < 0)))
5123 /* Apply the motion */
5124 if ((y >= panel_row_min + hgt) || (y < panel_row_min) ||
5125 (x >= panel_col_min + wid) || (x < panel_col_min))
5127 /* if (change_panel(dy, dx)) target_set_prepare(mode); */
5128 change_panel(dy, dx);
5131 /* Slide into legality */
5132 if (x >= cur_wid-1) x = cur_wid - 2;
5133 else if (x <= 0) x = 1;
5135 /* Slide into legality */
5136 if (y >= cur_hgt-1) y = cur_hgt- 2;
5137 else if (y <= 0) y = 1;
5144 /* Clear the top line */
5147 /* Recenter the map around the player */
5150 p_ptr->update |= (PU_MONSTERS);
5152 p_ptr->redraw |= (PR_MAP);
5154 p_ptr->window |= (PW_OVERHEAD);
5163 bool get_hack_dir(DIRECTION *dp)
5171 /* Global direction */
5174 /* (No auto-targeting) */
5176 /* Ask until satisfied */
5179 /* Choose a prompt */
5182 p = _("方向 ('*'でターゲット選択, ESCで中断)? ", "Direction ('*' to choose a target, Escape to cancel)? ");
5186 p = _("方向 ('5'でターゲットへ, '*'でターゲット再選択, ESCで中断)? ", "Direction ('5' for target, '*' to re-target, Escape to cancel)? ");
5189 /* Get a command (or Cancel) */
5190 if (!get_com(p, &command, TRUE)) break;
5194 if (command == '\r') command = 't';
5197 /* Convert various keys to "standard" keys */
5200 /* Use current target */
5211 /* Set new target */
5216 if (target_set(TARGET_KILL)) dir = 5;
5222 /* Look up the direction */
5223 dir = get_keymap_dir(command);
5229 /* Verify requested targets */
5230 if ((dir == 5) && !target_okay()) dir = 0;
5237 if (!dir) return (FALSE);
5239 /* Save the direction */
5242 /* Check for confusion */
5243 if (p_ptr->confused)
5245 /* Random direction */
5246 dir = ddd[randint0(8)];
5249 /* Notice confusion */
5250 if (command_dir != dir)
5253 msg_print(_("あなたは混乱している。", "You are confused."));
5256 /* Save direction */
5259 /* A "valid" direction was entered */
5265 * エネルギーの増加量10d5を速く計算するための関数
5268 #define Go_no_JuuJou 5*5*5*5*5*5*5*5*5*5
5270 s16b gain_energy(void)
5273 s32b energy_result = 10;
5276 tmp = randint0(Go_no_JuuJou);
5278 for (i = 0; i < 9; i ++){
5279 energy_result += tmp % 5;
5283 return (s16b)(energy_result + tmp);
5288 * @brief 射撃武器の攻撃に必要な基本消費エネルギーを返す/Return bow energy
5289 * @param sval 射撃武器のアイテム副分類ID
5290 * @return 消費する基本エネルギー
5292 ENERGY bow_energy(OBJECT_SUBTYPE_VALUE sval)
5294 ENERGY energy = 10000;
5296 /* Analyze the launcher */
5299 /* Sling and ammo */
5306 /* Short Bow and Arrow */
5313 /* Long Bow and Arrow */
5320 /* Bow of irresponsiblity and Arrow */
5327 /* Light Crossbow and Bolt */
5334 /* Heavy Crossbow and Bolt */
5349 int bow_tmul(OBJECT_SUBTYPE_VALUE sval)
5353 /* Analyze the launcher */
5356 /* Sling and ammo */
5363 /* Short Bow and Arrow */
5370 /* Long Bow and Arrow */
5377 /* Bow of irresponsiblity and Arrow */
5384 /* Light Crossbow and Bolt */
5391 /* Heavy Crossbow and Bolt */
5403 * Return alignment title
5405 cptr your_alignment(void)
5408 if (p_ptr->align > 150) return "大善";
5409 else if (p_ptr->align > 50) return "中善";
5410 else if (p_ptr->align > 10) return "小善";
5411 else if (p_ptr->align > -11) return "中立";
5412 else if (p_ptr->align > -51) return "小悪";
5413 else if (p_ptr->align > -151) return "中悪";
5416 if (p_ptr->align > 150) return "Lawful";
5417 else if (p_ptr->align > 50) return "Good";
5418 else if (p_ptr->align > 10) return "Neutral Good";
5419 else if (p_ptr->align > -11) return "Neutral";
5420 else if (p_ptr->align > -51) return "Neutral Evil";
5421 else if (p_ptr->align > -151) return "Evil";
5422 else return "Chaotic";
5428 * Return proficiency level of weapons and misc. skills (except riding)
5430 int weapon_exp_level(int weapon_exp)
5432 if (weapon_exp < WEAPON_EXP_BEGINNER) return EXP_LEVEL_UNSKILLED;
5433 else if (weapon_exp < WEAPON_EXP_SKILLED) return EXP_LEVEL_BEGINNER;
5434 else if (weapon_exp < WEAPON_EXP_EXPERT) return EXP_LEVEL_SKILLED;
5435 else if (weapon_exp < WEAPON_EXP_MASTER) return EXP_LEVEL_EXPERT;
5436 else return EXP_LEVEL_MASTER;
5441 * Return proficiency level of riding
5443 int riding_exp_level(int riding_exp)
5445 if (riding_exp < RIDING_EXP_BEGINNER) return EXP_LEVEL_UNSKILLED;
5446 else if (riding_exp < RIDING_EXP_SKILLED) return EXP_LEVEL_BEGINNER;
5447 else if (riding_exp < RIDING_EXP_EXPERT) return EXP_LEVEL_SKILLED;
5448 else if (riding_exp < RIDING_EXP_MASTER) return EXP_LEVEL_EXPERT;
5449 else return EXP_LEVEL_MASTER;
5454 * Return proficiency level of spells
5456 int spell_exp_level(int spell_exp)
5458 if (spell_exp < SPELL_EXP_BEGINNER) return EXP_LEVEL_UNSKILLED;
5459 else if (spell_exp < SPELL_EXP_SKILLED) return EXP_LEVEL_BEGINNER;
5460 else if (spell_exp < SPELL_EXP_EXPERT) return EXP_LEVEL_SKILLED;
5461 else if (spell_exp < SPELL_EXP_MASTER) return EXP_LEVEL_EXPERT;
5462 else return EXP_LEVEL_MASTER;
5467 * Display a rumor and apply its effects
5470 IDX rumor_num(char *zz, IDX max_idx)
5472 if (strcmp(zz, "*") == 0) return randint1(max_idx - 1);
5473 return (IDX)atoi(zz);
5476 cptr rumor_bind_name(char *base, cptr fullname)
5480 s = strstr(base, "{Name}");
5484 v = format("%s%s%s", base, fullname, (s + 6));
5494 void display_rumor(bool ex)
5502 if (randint0(3) == 0) section = 1;
5505 err = _(get_rnd_line_jonly("rumors_j.txt", section, Rumor, 10),
5506 get_rnd_line("rumors.txt", section, Rumor));
5507 if (err) strcpy(Rumor, _("嘘の噂もある。", "Some rumors are wrong."));
5511 if (strncmp(Rumor, "R:", 2) == 0)
5514 cptr rumor_msg = NULL;
5515 cptr rumor_eff_format = NULL;
5516 char fullname[1024] = "";
5518 if (tokenize(Rumor + 2, 3, zz, TOKENIZE_CHECKQUOTE) == 3)
5520 if (strcmp(zz[0], "ARTIFACT") == 0)
5524 object_type *q_ptr = &forge;
5525 artifact_type *a_ptr;
5529 a_idx = rumor_num(zz[1], max_a_idx);
5531 a_ptr = &a_info[a_idx];
5532 if (a_ptr->name) break;
5535 k_idx = lookup_kind(a_ptr->tval, a_ptr->sval);
5536 object_prep(q_ptr, k_idx);
5537 q_ptr->name1 = a_idx;
5538 q_ptr->ident = IDENT_STORE;
5539 object_desc(fullname, q_ptr, OD_NAME_ONLY);
5541 else if (strcmp(zz[0], "MONSTER") == 0)
5544 monster_race *r_ptr;
5548 r_idx = rumor_num(zz[1], max_r_idx);
5549 r_ptr = &r_info[r_idx];
5550 if (r_ptr->name) break;
5553 strcpy(fullname, r_name + r_ptr->name);
5555 /* Remember this monster */
5556 if (!r_ptr->r_sights)
5561 else if (strcmp(zz[0], "DUNGEON") == 0)
5564 dungeon_info_type *d_ptr;
5568 d_idx = rumor_num(zz[1], max_d_idx);
5569 d_ptr = &d_info[d_idx];
5570 if (d_ptr->name) break;
5573 strcpy(fullname, d_name + d_ptr->name);
5575 if (!max_dlv[d_idx])
5577 max_dlv[d_idx] = d_ptr->mindepth;
5578 rumor_eff_format = _("%sに帰還できるようになった。", "You can recall to %s.");
5581 else if (strcmp(zz[0], "TOWN") == 0)
5588 t_idx = rumor_num(zz[1], NO_TOWN);
5589 if (town[t_idx].name) break;
5592 strcpy(fullname, town[t_idx].name);
5594 visit = (1L << (t_idx - 1));
5595 if ((t_idx != SECRET_TOWN) && !(p_ptr->visit & visit))
5597 p_ptr->visit |= visit;
5598 rumor_eff_format = _("%sに行ったことがある気がする。", "You feel you have been to %s.");
5602 rumor_msg = rumor_bind_name(zz[2], fullname);
5603 msg_print(rumor_msg);
5604 if (rumor_eff_format)
5607 msg_format(rumor_eff_format, fullname);
5612 if (err) msg_print(_("この情報は間違っている。", "This information is wrong."));
5616 msg_format("%s", Rumor);