3 * @brief 雑多なその他の処理2 / effects of various "objects"
6 * Copyright (c) 1989 James E. Wilson, Robert A. Koeneke\n
7 * This software may be copied and distributed for educational, research, and\n
8 * not for profit purposes provided that this copyright and statement are\n
9 * included in all such copies.\n
10 * 2014 Deskull rearranged comment for Doxygen.
16 #include "object-curse.h"
17 #include "monster-hook.h"
19 #define REWARD_CHANCE 10
23 * @brief プレイヤーの経験値について整合性のためのチェックと調整を行う /
24 * Advance experience levels and print experience
27 void check_experience(void)
29 bool level_reward = FALSE;
30 bool level_mutation = FALSE;
31 bool level_inc_stat = FALSE;
32 bool android = (p_ptr->prace == RACE_ANDROID ? TRUE : FALSE);
33 PLAYER_LEVEL old_lev = p_ptr->lev;
35 /* Hack -- lower limit */
36 if (p_ptr->exp < 0) p_ptr->exp = 0;
37 if (p_ptr->max_exp < 0) p_ptr->max_exp = 0;
38 if (p_ptr->max_max_exp < 0) p_ptr->max_max_exp = 0;
40 /* Hack -- upper limit */
41 if (p_ptr->exp > PY_MAX_EXP) p_ptr->exp = PY_MAX_EXP;
42 if (p_ptr->max_exp > PY_MAX_EXP) p_ptr->max_exp = PY_MAX_EXP;
43 if (p_ptr->max_max_exp > PY_MAX_EXP) p_ptr->max_max_exp = PY_MAX_EXP;
45 /* Hack -- maintain "max" experience */
46 if (p_ptr->exp > p_ptr->max_exp) p_ptr->max_exp = p_ptr->exp;
48 /* Hack -- maintain "max max" experience */
49 if (p_ptr->max_exp > p_ptr->max_max_exp) p_ptr->max_max_exp = p_ptr->max_exp;
51 /* Redraw experience */
52 p_ptr->redraw |= (PR_EXP);
56 /* Lose levels while possible */
57 while ((p_ptr->lev > 1) &&
58 (p_ptr->exp < ((android ? player_exp_a : player_exp)[p_ptr->lev - 2] * p_ptr->expfact / 100L)))
62 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
63 p_ptr->redraw |= (PR_LEV | PR_TITLE);
64 p_ptr->window |= (PW_PLAYER);
69 /* Gain levels while possible */
70 while ((p_ptr->lev < PY_MAX_LEVEL) &&
71 (p_ptr->exp >= ((android ? player_exp_a : player_exp)[p_ptr->lev-1] * p_ptr->expfact / 100L)))
76 /* Save the highest level */
77 if (p_ptr->lev > p_ptr->max_plv)
79 p_ptr->max_plv = p_ptr->lev;
81 if ((p_ptr->pclass == CLASS_CHAOS_WARRIOR) ||
82 (p_ptr->muta2 & MUT2_CHAOS_GIFT))
86 if (p_ptr->prace == RACE_BEASTMAN)
88 if (one_in_(5)) level_mutation = TRUE;
90 level_inc_stat = TRUE;
92 do_cmd_write_nikki(NIKKI_LEVELUP, p_ptr->lev, NULL);
97 msg_format(_("レベル %d にようこそ。", "Welcome to level %d."), p_ptr->lev);
99 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
100 p_ptr->redraw |= (PR_LEV | PR_TITLE | PR_EXP);
101 p_ptr->window |= (PW_PLAYER | PW_SPELL | PW_INVEN);
111 if(!(p_ptr->max_plv % 10))
121 cnv_stat(p_ptr->stat_max[0], tmp);
122 prt(format(" a) 腕力 (現在値 %s)", tmp), 2, 14);
123 cnv_stat(p_ptr->stat_max[1], tmp);
124 prt(format(" b) 知能 (現在値 %s)", tmp), 3, 14);
125 cnv_stat(p_ptr->stat_max[2], tmp);
126 prt(format(" c) 賢さ (現在値 %s)", tmp), 4, 14);
127 cnv_stat(p_ptr->stat_max[3], tmp);
128 prt(format(" d) 器用 (現在値 %s)", tmp), 5, 14);
129 cnv_stat(p_ptr->stat_max[4], tmp);
130 prt(format(" e) 耐久 (現在値 %s)", tmp), 6, 14);
131 cnv_stat(p_ptr->stat_max[5], tmp);
132 prt(format(" f) 魅力 (現在値 %s)", tmp), 7, 14);
134 prt(" どの能力値を上げますか?", 1, 14);
136 cnv_stat(p_ptr->stat_max[0], tmp);
137 prt(format(" a) Str (cur %s)", tmp), 2, 14);
138 cnv_stat(p_ptr->stat_max[1], tmp);
139 prt(format(" b) Int (cur %s)", tmp), 3, 14);
140 cnv_stat(p_ptr->stat_max[2], tmp);
141 prt(format(" c) Wis (cur %s)", tmp), 4, 14);
142 cnv_stat(p_ptr->stat_max[3], tmp);
143 prt(format(" d) Dex (cur %s)", tmp), 5, 14);
144 cnv_stat(p_ptr->stat_max[4], tmp);
145 prt(format(" e) Con (cur %s)", tmp), 6, 14);
146 cnv_stat(p_ptr->stat_max[5], tmp);
147 prt(format(" f) Chr (cur %s)", tmp), 7, 14);
149 prt(" Which stat do you want to raise?", 1, 14);
154 if ((choice >= 'a') && (choice <= 'f')) break;
156 for(n = 0; n < 6; n++)
157 if (n != choice - 'a')
159 if (get_check(_("よろしいですか?", "Are you sure? "))) break;
161 do_inc_stat(choice - 'a');
164 else if(!(p_ptr->max_plv % 2))
165 do_inc_stat(randint0(6));
170 msg_print(_("あなたは変わった気がする...", "You feel different..."));
171 (void)gain_random_mutation(0);
172 level_mutation = FALSE;
176 * 報酬でレベルが上ると再帰的に check_experience() が
181 gain_level_reward(0);
182 level_reward = FALSE;
185 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
186 p_ptr->redraw |= (PR_LEV | PR_TITLE);
187 p_ptr->window |= (PW_PLAYER | PW_SPELL);
191 /* Load an autopick preference file */
192 if (old_lev != p_ptr->lev) autopick_load_pref(FALSE);
197 * @brief モンスターを倒した際の財宝svalを返す
198 * @param r_idx 倒したモンスターの種族ID
201 * Hack -- Return the "automatic coin type" of a monster race
202 * Used to allocate proper treasure when "Creeping coins" die
203 * Note the use of actual "monster names"
205 static int get_coin_type(MONRACE_IDX r_idx)
207 /* Analyze monsters */
210 case MON_COPPER_COINS: return 2;
211 case MON_SILVER_COINS: return 5;
212 case MON_GOLD_COINS: return 10;
213 case MON_MITHRIL_COINS:
214 case MON_MITHRIL_GOLEM: return 16;
215 case MON_ADAMANT_COINS: return 17;
224 * @brief オブジェクトがクロークかどうかを判定する /
225 * Hack -- determine if a template is Cloak
226 * @param k_idx 判定したいオブジェクトのベースアイテムID
227 * @return オブジェクトがクロークならばTRUEを返す
229 static bool kind_is_cloak(KIND_OBJECT_IDX k_idx)
231 object_kind *k_ptr = &k_info[k_idx];
233 /* Analyze the item type */
234 if (k_ptr->tval == TV_CLOAK)
239 /* Assume not good */
245 * @brief オブジェクトが竿状武器かどうかを判定する /
246 * Hack -- determine if a template is Polearm
247 * @param k_idx 判定したいオブジェクトのベースアイテムID
248 * @return オブジェクトが竿状武器ならばTRUEを返す
250 static bool kind_is_polearm(KIND_OBJECT_IDX k_idx)
252 object_kind *k_ptr = &k_info[k_idx];
254 /* Analyze the item type */
255 if (k_ptr->tval == TV_POLEARM)
260 /* Assume not good */
266 * @brief オブジェクトが剣かどうかを判定する /
267 * Hack -- determine if a template is Sword
268 * @param k_idx 判定したいオブジェクトのベースアイテムID
269 * @return オブジェクトが剣ならばTRUEを返す
271 static bool kind_is_sword(KIND_OBJECT_IDX k_idx)
273 object_kind *k_ptr = &k_info[k_idx];
275 /* Analyze the item type */
276 if ((k_ptr->tval == TV_SWORD) && (k_ptr->sval > 2))
281 /* Assume not good */
287 * @brief オブジェクトが魔法書かどうかを判定する /
288 * Hack -- determine if a template is Book
289 * @param k_idx 判定したいオブジェクトのベースアイテムID
290 * @return オブジェクトが魔法書ならばTRUEを返す
292 static bool kind_is_book(KIND_OBJECT_IDX k_idx)
294 object_kind *k_ptr = &k_info[k_idx];
296 /* Analyze the item type */
297 if ((k_ptr->tval >= TV_LIFE_BOOK) && (k_ptr->tval <= TV_CRUSADE_BOOK))
302 /* Assume not good */
308 * @brief オブジェクトがベースアイテム時点でGOODかどうかを判定する /
309 * Hack -- determine if a template is Good book
310 * @param k_idx 判定したいオブジェクトのベースアイテムID
311 * @return オブジェクトがベースアイテム時点でGOODなアイテムならばTRUEを返す
313 static bool kind_is_good_book(KIND_OBJECT_IDX k_idx)
315 object_kind *k_ptr = &k_info[k_idx];
317 /* Analyze the item type */
318 if ((k_ptr->tval >= TV_LIFE_BOOK) && (k_ptr->tval <= TV_CRUSADE_BOOK) && (k_ptr->tval != TV_ARCANE_BOOK) && (k_ptr->sval > 1))
323 /* Assume not good */
329 * @brief オブジェクトが鎧かどうかを判定する /
330 * Hack -- determine if a template is Armor
331 * @param k_idx 判定したいオブジェクトのベースアイテムID
332 * @return オブジェクトが鎧ならばTRUEを返す
334 static bool kind_is_armor(KIND_OBJECT_IDX k_idx)
336 object_kind *k_ptr = &k_info[k_idx];
338 /* Analyze the item type */
339 if (k_ptr->tval == TV_HARD_ARMOR)
344 /* Assume not good */
350 * @brief オブジェクトが打撃武器かどうかを判定する /
351 * Hack -- determine if a template is hafted weapon
352 * @param k_idx 判定したいオブジェクトのベースアイテムID
353 * @return オブジェクトが打撃武器ならばTRUEを返す
355 static bool kind_is_hafted(KIND_OBJECT_IDX k_idx)
357 object_kind *k_ptr = &k_info[k_idx];
359 /* Analyze the item type */
360 if (k_ptr->tval == TV_HAFTED)
365 /* Assume not good */
370 * @brief クエストを達成状態にする /
371 * @param quest_num 達成状態にしたいクエストのID
374 void complete_quest(QUEST_IDX quest_num)
376 quest_type* const q_ptr = &quest[quest_num];
380 case QUEST_TYPE_RANDOM:
381 if (record_rand_quest) do_cmd_write_nikki(NIKKI_RAND_QUEST_C, quest_num, NULL);
384 if (record_fix_quest) do_cmd_write_nikki(NIKKI_FIX_QUEST_C, quest_num, NULL);
388 q_ptr->status = QUEST_STATUS_COMPLETED;
389 q_ptr->complev = (byte)p_ptr->lev;
391 q_ptr->comptime = playtime;
393 if (!(q_ptr->flags & QUEST_FLAG_SILENT))
395 play_music(TERM_XTRA_MUSIC_BASIC, MUSIC_BASIC_QUEST_CLEAR);
396 msg_print(_("クエストを達成した!", "You just completed your quest!"));
402 * @brief 現在フロアに残っている敵モンスターの数を返す /
403 * @return 現在の敵モンスターの数
405 static MONSTER_NUMBER count_all_hostile_monsters(void)
408 MONSTER_NUMBER number_mon = 0;
410 for (x = 0; x < cur_wid; ++ x)
412 for (y = 0; y < cur_hgt; ++ y)
414 MONSTER_IDX m_idx = cave[y][x].m_idx;
416 if (m_idx > 0 && is_hostile(&m_list[m_idx]))
427 * @brief 特定の敵を倒した際にクエスト達成処理 /
428 * Check for "Quest" completion when a quest monster is killed or charmed.
429 * @param m_ptr 撃破したモンスターの構造体参照ポインタ
432 void check_quest_completion(monster_type *m_ptr)
437 bool create_stairs = FALSE;
443 /* Get the location */
448 quest_num = p_ptr->inside_quest;
450 /* Search for an active quest on this dungeon level */
455 for (i = max_q_idx - 1; i > 0; i--)
457 quest_type* const q_ptr = &quest[i];
459 /* Quest is not active */
460 if (q_ptr->status != QUEST_STATUS_TAKEN)
463 /* Quest is not a dungeon quest */
464 if (q_ptr->flags & QUEST_FLAG_PRESET)
467 /* Quest is not on this level */
468 if ((q_ptr->level != dun_level) &&
469 (q_ptr->type != QUEST_TYPE_KILL_ANY_LEVEL))
472 /* Not a "kill monster" quest */
473 if ((q_ptr->type == QUEST_TYPE_FIND_ARTIFACT) ||
474 (q_ptr->type == QUEST_TYPE_FIND_EXIT))
477 /* Interesting quest */
478 if ((q_ptr->type == QUEST_TYPE_KILL_NUMBER) ||
479 (q_ptr->type == QUEST_TYPE_TOWER) ||
480 (q_ptr->type == QUEST_TYPE_KILL_ALL))
483 /* Interesting quest */
484 if (((q_ptr->type == QUEST_TYPE_KILL_LEVEL) ||
485 (q_ptr->type == QUEST_TYPE_KILL_ANY_LEVEL) ||
486 (q_ptr->type == QUEST_TYPE_RANDOM)) &&
487 (q_ptr->r_idx == m_ptr->r_idx))
494 /* Handle the current quest */
495 if (quest_num && (quest[quest_num].status == QUEST_STATUS_TAKEN))
498 quest_type* const q_ptr = &quest[quest_num];
502 case QUEST_TYPE_KILL_NUMBER:
506 if (q_ptr->cur_num >= q_ptr->num_mon)
508 complete_quest(quest_num);
514 case QUEST_TYPE_KILL_ALL:
516 if (!is_hostile(m_ptr)) break;
518 if (count_all_hostile_monsters() == 1)
520 if (q_ptr->flags & QUEST_FLAG_SILENT)
522 q_ptr->status = QUEST_STATUS_FINISHED;
526 complete_quest(quest_num);
531 case QUEST_TYPE_KILL_LEVEL:
532 case QUEST_TYPE_RANDOM:
534 /* Only count valid monsters */
535 if (q_ptr->r_idx != m_ptr->r_idx)
540 if (q_ptr->cur_num >= q_ptr->max_num)
542 complete_quest(quest_num);
544 if (!(q_ptr->flags & QUEST_FLAG_PRESET))
546 create_stairs = TRUE;
547 p_ptr->inside_quest = 0;
550 /* Finish the two main quests without rewarding */
551 if ((quest_num == QUEST_OBERON) || (quest_num == QUEST_SERPENT))
553 q_ptr->status = QUEST_STATUS_FINISHED;
556 if (q_ptr->type == QUEST_TYPE_RANDOM)
559 q_ptr->status = QUEST_STATUS_FINISHED;
564 case QUEST_TYPE_KILL_ANY_LEVEL:
567 if (q_ptr->cur_num >= q_ptr->max_num)
569 complete_quest(quest_num);
574 case QUEST_TYPE_TOWER:
576 if (!is_hostile(m_ptr)) break;
578 if (count_all_hostile_monsters() == 1)
580 q_ptr->status = QUEST_STATUS_STAGE_COMPLETED;
582 if((quest[QUEST_TOWER1].status == QUEST_STATUS_STAGE_COMPLETED) &&
583 (quest[QUEST_TOWER2].status == QUEST_STATUS_STAGE_COMPLETED) &&
584 (quest[QUEST_TOWER3].status == QUEST_STATUS_STAGE_COMPLETED))
587 complete_quest(QUEST_TOWER1);
595 /* Create a magical staircase */
601 while (cave_perma_bold(y, x) || cave[y][x].o_idx || (cave[y][x].info & CAVE_OBJECT) )
603 /* Pick a location */
604 scatter(&ny, &nx, y, x, 1, 0);
610 /* Explain the staircase */
611 msg_print(_("魔法の階段が現れた...", "A magical staircase appears..."));
613 /* Create stairs down */
614 cave_set_feat(y, x, feat_down_stair);
616 /* Remember to update everything */
617 p_ptr->update |= (PU_FLOW);
627 for (i = 0; i < (dun_level / 15)+1; i++)
632 /* Make a great object */
633 make_object(o_ptr, AM_GOOD | AM_GREAT);
635 /* Drop it in the dungeon */
636 (void)drop_near(o_ptr, -1, y, x);
642 * @brief 特定のアーティファクトを入手した際のクエスト達成処理 /
643 * Check for "Quest" completion when a quest monster is killed or charmed.
644 * @param o_ptr 入手したオブジェクトの構造体参照ポインタ
647 void check_find_art_quest_completion(object_type *o_ptr)
650 /* Check if completed a quest */
651 for (i = 0; i < max_q_idx; i++)
653 if((quest[i].type == QUEST_TYPE_FIND_ARTIFACT) &&
654 (quest[i].status == QUEST_STATUS_TAKEN) &&
655 (quest[i].k_idx == o_ptr->name1))
664 * @brief モンスターを撃破した際の述語メッセージを返す /
665 * Return monster death string
666 * @param r_ptr 撃破されたモンスターの種族情報を持つ構造体の参照ポインタ
667 * @return 撃破されたモンスターの述語
669 cptr extract_note_dies(MONRACE_IDX r_idx)
671 monster_race *r_ptr = &r_info[r_idx];
672 /* Some monsters get "destroyed" */
673 if (!monster_living(r_idx))
677 for (i = 0; i < 4; i++)
679 if (r_ptr->blow[i].method == RBM_EXPLODE)
681 return _("は爆発して粉々になった。", " explodes into tiny shreds.");
684 return _("を倒した。", " is destroyed.");
687 /* Assume a default death */
688 return _("は死んだ。", " dies.");
693 * @brief モンスターが死亡した時の処理 /
694 * Handle the "death" of a monster.
695 * @param m_idx 死亡したモンスターのID
696 * @param drop_item TRUEならばモンスターのドロップ処理を行う
697 * @return 撃破されたモンスターの述語
700 * Disperse treasures centered at the monster location based on the
701 * various flags contained in the monster flags fields.
702 * Check for "Quest" completion when a quest monster is killed.
703 * Note that only the player can induce "monster_death()" on Uniques.
704 * Thus (for now) all Quest monsters should be Uniques.
705 * Note that monsters can now carry objects, and when a monster dies,
706 * it drops all of its objects, which may disappear in crowded rooms.
709 void monster_death(MONSTER_IDX m_idx, bool drop_item)
718 monster_type *m_ptr = &m_list[m_idx];
719 monster_race *r_ptr = &r_info[m_ptr->r_idx];
721 bool visible = ((m_ptr->ml && !p_ptr->image) || (r_ptr->flags1 & RF1_UNIQUE));
725 bool do_gold = (!(r_ptr->flags1 & RF1_ONLY_ITEM));
726 bool do_item = (!(r_ptr->flags1 & RF1_ONLY_GOLD));
727 bool cloned = (m_ptr->smart & SM_CLONED) ? TRUE : FALSE;
728 int force_coin = get_coin_type(m_ptr->r_idx);
733 bool drop_chosen_item = drop_item && !cloned && !p_ptr->inside_arena
734 && !p_ptr->inside_battle && !is_pet(m_ptr);
736 /* The caster is dead? */
737 if (world_monster && world_monster == m_idx) world_monster = 0;
739 /* Notice changes in view */
740 if (r_ptr->flags7 & (RF7_LITE_MASK | RF7_DARK_MASK))
742 /* Update some things */
743 p_ptr->update |= (PU_MON_LITE);
746 /* Get the location */
750 if (record_named_pet && is_pet(m_ptr) && m_ptr->nickname)
754 monster_desc(m_name, m_ptr, MD_INDEF_VISIBLE);
755 do_cmd_write_nikki(NIKKI_NAMED_PET, 3, m_name);
758 /* Let monsters explode! */
759 for (i = 0; i < 4; i++)
761 if (r_ptr->blow[i].method == RBM_EXPLODE)
763 BIT_FLAGS flg = PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL;
764 EFFECT_ID typ = mbe_info[r_ptr->blow[i].effect].explode_type;
765 DICE_NUMBER d_dice = r_ptr->blow[i].d_dice;
766 DICE_SID d_side = r_ptr->blow[i].d_side;
767 HIT_POINT damage = damroll(d_dice, d_side);
769 project(m_idx, 3, y, x, damage, typ, flg, -1);
774 if (m_ptr->mflag2 & MFLAG2_CHAMELEON)
776 choose_new_monster(m_idx, TRUE, MON_CHAMELEON);
777 r_ptr = &r_info[m_ptr->r_idx];
780 /* Check for quest completion */
781 check_quest_completion(m_ptr);
783 /* Handle the possibility of player vanquishing arena combatant -KMW- */
784 if (p_ptr->inside_arena && !is_pet(m_ptr))
786 p_ptr->exit_bldg = TRUE;
788 if (p_ptr->arena_number > MAX_ARENA_MONS)
790 msg_print(_("素晴らしい!君こそ真の勝利者だ。", "You are a Genuine Champion!"));
794 msg_print(_("勝利!チャンピオンへの道を進んでいる。", "Victorious! You're on your way to becoming Champion."));
797 if (arena_info[p_ptr->arena_number].tval)
801 /* Prepare to make a prize */
802 object_prep(q_ptr, lookup_kind(arena_info[p_ptr->arena_number].tval, arena_info[p_ptr->arena_number].sval));
803 apply_magic(q_ptr, object_level, AM_NO_FIXED_ART);
805 /* Drop it in the dungeon */
806 (void)drop_near(q_ptr, -1, y, x);
809 if (p_ptr->arena_number > MAX_ARENA_MONS) p_ptr->arena_number++;
810 p_ptr->arena_number++;
815 /* Extract monster name */
816 monster_desc(m_name, m_ptr, MD_IGNORE_HALLU | MD_ASSUME_VISIBLE | MD_INDEF_VISIBLE);
818 do_cmd_write_nikki(NIKKI_ARENA, p_ptr->arena_number, m_name);
822 if (m_idx == p_ptr->riding)
824 if (rakuba(-1, FALSE))
826 msg_print(_("地面に落とされた。", "You have fallen from your riding pet."));
830 /* Drop a dead corpse? */
831 if (one_in_(r_ptr->flags1 & RF1_UNIQUE ? 1 : 4) &&
832 (r_ptr->flags9 & (RF9_DROP_CORPSE | RF9_DROP_SKELETON)) &&
833 !(p_ptr->inside_arena || p_ptr->inside_battle || cloned || ((m_ptr->r_idx == today_mon) && is_pet(m_ptr))))
835 /* Assume skeleton */
839 * We cannot drop a skeleton? Note, if we are in this check,
840 * we *know* we can drop at least a corpse or a skeleton
842 if (!(r_ptr->flags9 & RF9_DROP_SKELETON))
844 else if ((r_ptr->flags9 & RF9_DROP_CORPSE) && (r_ptr->flags1 & RF1_UNIQUE))
847 /* Else, a corpse is more likely unless we did a "lot" of damage */
848 else if (r_ptr->flags9 & RF9_DROP_CORPSE)
850 /* Lots of damage in one blow */
851 if ((0 - ((m_ptr->maxhp) / 4)) > m_ptr->hp)
853 if (one_in_(5)) corpse = TRUE;
857 if (!one_in_(5)) corpse = TRUE;
862 /* Prepare to make an object */
863 object_prep(q_ptr, lookup_kind(TV_CORPSE, (corpse ? SV_CORPSE : SV_SKELETON)));
865 apply_magic(q_ptr, object_level, AM_NO_FIXED_ART);
867 q_ptr->pval = m_ptr->r_idx;
869 /* Drop it in the dungeon */
870 (void)drop_near(q_ptr, -1, y, x);
873 /* Drop objects being carried */
874 monster_drop_carried_objects(m_ptr);
876 if (r_ptr->flags1 & RF1_DROP_GOOD) mo_mode |= AM_GOOD;
877 if (r_ptr->flags1 & RF1_DROP_GREAT) mo_mode |= AM_GREAT;
879 switch (m_ptr->r_idx)
881 case MON_PINK_HORROR:
882 /* Pink horrors are replaced with 2 Blue horrors */
883 if (!(p_ptr->inside_arena || p_ptr->inside_battle))
887 for (i = 0; i < 2; i++)
890 bool pet = is_pet(m_ptr);
893 if (pet) mode |= PM_FORCE_PET;
895 if (summon_specific((pet ? -1 : m_idx), wy, wx, 100, SUMMON_BLUE_HORROR, mode))
897 if (player_can_see_bold(wy, wx))
903 msg_print(_("ピンク・ホラーは分裂した!", "The Pink horror divides!"));
907 case MON_BLOODLETTER:
908 /* Bloodletters of Khorne may drop a blade of chaos */
909 if (drop_chosen_item && (randint1(100) < 15))
913 /* Prepare to make a Blade of Chaos */
914 object_prep(q_ptr, lookup_kind(TV_SWORD, SV_BLADE_OF_CHAOS));
916 apply_magic(q_ptr, object_level, AM_NO_FIXED_ART | mo_mode);
918 /* Drop it in the dungeon */
919 (void)drop_near(q_ptr, -1, y, x);
924 if (drop_chosen_item && (dun_level > 9))
929 /* Activate restriction */
930 if ((dun_level > 49) && one_in_(5))
931 get_obj_num_hook = kind_is_good_book;
933 get_obj_num_hook = kind_is_book;
936 make_object(q_ptr, mo_mode);
938 /* Drop it in the dungeon */
939 (void)drop_near(q_ptr, -1, y, x);
945 * Mega^3-hack: killing a 'Warrior of the Dawn' is likely to
946 * spawn another in the fallen one's place!
948 if (!p_ptr->inside_arena && !p_ptr->inside_battle)
952 POSITION wy = y, wx = x;
954 bool pet = is_pet(m_ptr);
958 scatter(&wy, &wx, y, x, 20, 0);
960 while (!(in_bounds(wy, wx) && cave_empty_bold2(wy, wx)) && --attempts);
965 if (pet) mode |= PM_FORCE_PET;
967 if (summon_specific((pet ? -1 : m_idx), wy, wx, 100, SUMMON_DAWN, mode))
969 if (player_can_see_bold(wy, wx))
970 msg_print(_("新たな戦士が現れた!", "A new warrior steps forth!"));
978 /* One more ultra-hack: An Unmaker goes out with a big bang! */
980 BIT_FLAGS flg = PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL;
981 (void)project(m_idx, 6, y, x, 100, GF_CHAOS, flg, -1);
985 case MON_UNICORN_ORD:
988 /* Reward for "lazy" player */
989 if (p_ptr->pseikaku == SEIKAKU_NAMAKE)
991 ARTIFACT_IDX a_idx = 0;
992 artifact_type *a_ptr = NULL;
994 if (!drop_chosen_item) break;
1001 a_idx = ART_NAMAKE_HAMMER;
1004 a_idx = ART_NAMAKE_BOW;
1007 a_idx = ART_NAMAKE_ARMOR;
1011 a_ptr = &a_info[a_idx];
1013 while (a_ptr->cur_num);
1015 /* Create the artifact */
1016 if (create_named_art(a_idx, y, x))
1020 /* Hack -- Memorize location of artifact in saved floors */
1021 if (character_dungeon) a_ptr->floor_id = p_ptr->floor_id;
1023 else if (!preserve_mode) a_ptr->cur_num = 1;
1028 if (!drop_chosen_item) break;
1031 /* Mega-Hack -- Prepare to make "Grond" */
1032 object_prep(q_ptr, lookup_kind(TV_HAFTED, SV_GROND));
1034 /* Mega-Hack -- Mark this item as "Grond" */
1035 q_ptr->name1 = ART_GROND;
1037 /* Mega-Hack -- Actually create "Grond" */
1038 apply_magic(q_ptr, -1, AM_GOOD | AM_GREAT);
1040 /* Drop it in the dungeon */
1041 (void)drop_near(q_ptr, -1, y, x);
1044 /* Mega-Hack -- Prepare to make "Chaos" */
1045 object_prep(q_ptr, lookup_kind(TV_CROWN, SV_CHAOS));
1047 /* Mega-Hack -- Mark this item as "Chaos" */
1048 q_ptr->name1 = ART_CHAOS;
1050 /* Mega-Hack -- Actually create "Chaos" */
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 case MON_B_DEATH_SWORD:
1058 if (drop_chosen_item)
1062 /* Prepare to make a broken sword */
1063 object_prep(q_ptr, lookup_kind(TV_SWORD, randint1(2)));
1065 /* Drop it in the dungeon */
1066 (void)drop_near(q_ptr, -1, y, x);
1072 if (drop_chosen_item && ((m_ptr->r_idx == MON_A_GOLD) ||
1073 ((m_ptr->r_idx == MON_A_SILVER) && (r_ptr->r_akills % 5 == 0))))
1077 /* Prepare to make a Can of Toys */
1078 object_prep(q_ptr, lookup_kind(TV_CHEST, SV_CHEST_KANDUME));
1080 apply_magic(q_ptr, object_level, AM_NO_FIXED_ART);
1082 /* Drop it in the dungeon */
1083 (void)drop_near(q_ptr, -1, y, x);
1089 BIT_FLAGS flg = PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL;
1090 (void)project(m_idx, 3, y, x, damroll(20, 10), GF_FIRE, flg, -1);
1095 if (!drop_chosen_item) break;
1097 switch (r_ptr->d_char)
1105 /* Activate restriction */
1106 get_obj_num_hook = kind_is_cloak;
1109 make_object(q_ptr, mo_mode);
1111 /* Drop it in the dungeon */
1112 (void)drop_near(q_ptr, -1, y, x);
1122 /* Activate restriction */
1123 get_obj_num_hook = kind_is_polearm;
1125 /* Make a poleweapon */
1126 make_object(q_ptr, mo_mode);
1128 /* Drop it in the dungeon */
1129 (void)drop_near(q_ptr, -1, y, x);
1139 /* Activate restriction */
1140 get_obj_num_hook = kind_is_armor;
1142 /* Make a hard armor */
1143 make_object(q_ptr, mo_mode);
1145 /* Drop it in the dungeon */
1146 (void)drop_near(q_ptr, -1, y, x);
1156 /* Activate restriction */
1157 get_obj_num_hook = kind_is_hafted;
1159 /* Make a hafted weapon */
1160 make_object(q_ptr, mo_mode);
1162 /* Drop it in the dungeon */
1163 (void)drop_near(q_ptr, -1, y, x);
1168 if (m_ptr->r_idx != MON_STORMBRINGER)
1173 /* Activate restriction */
1174 get_obj_num_hook = kind_is_sword;
1177 make_object(q_ptr, mo_mode);
1179 /* Drop it in the dungeon */
1180 (void)drop_near(q_ptr, -1, y, x);
1187 /* Mega-Hack -- drop fixed items */
1188 if (drop_chosen_item)
1190 ARTIFACT_IDX a_idx = 0;
1193 for(i = 0; i < 4; i++)
1195 if(!r_ptr->artifact_id[i]) break;
1196 a_idx = r_ptr->artifact_id[i];
1197 chance = r_ptr->artifact_percent[i];
1200 if ((a_idx > 0) && ((randint0(100) < chance) || p_ptr->wizard))
1202 artifact_type *a_ptr = &a_info[a_idx];
1204 if (!a_ptr->cur_num)
1206 /* Create the artifact */
1207 if (create_named_art(a_idx, y, x))
1211 /* Hack -- Memorize location of artifact in saved floors */
1212 if (character_dungeon) a_ptr->floor_id = p_ptr->floor_id;
1214 else if (!preserve_mode) a_ptr->cur_num = 1;
1218 if ((r_ptr->flags7 & RF7_GUARDIAN) && (d_info[dungeon_type].final_guardian == m_ptr->r_idx))
1220 KIND_OBJECT_IDX k_idx = d_info[dungeon_type].final_object ? d_info[dungeon_type].final_object
1221 : lookup_kind(TV_SCROLL, SV_SCROLL_ACQUIREMENT);
1223 if (d_info[dungeon_type].final_artifact)
1225 a_idx = d_info[dungeon_type].final_artifact;
1226 artifact_type *a_ptr = &a_info[a_idx];
1228 if (!a_ptr->cur_num)
1230 /* Create the artifact */
1231 if (create_named_art(a_idx, y, x))
1235 /* Hack -- Memorize location of artifact in saved floors */
1236 if (character_dungeon) a_ptr->floor_id = p_ptr->floor_id;
1238 else if (!preserve_mode) a_ptr->cur_num = 1;
1240 /* Prevent rewarding both artifact and "default" object */
1241 if (!d_info[dungeon_type].final_object) k_idx = 0;
1249 /* Prepare to make a reward */
1250 object_prep(q_ptr, k_idx);
1252 apply_magic(q_ptr, object_level, AM_NO_FIXED_ART | AM_GOOD);
1254 /* Drop it in the dungeon */
1255 (void)drop_near(q_ptr, -1, y, x);
1257 msg_format(_("あなたは%sを制覇した!", "You have conquered %s!"),d_name+d_info[dungeon_type].name);
1261 /* Determine how much we can drop */
1262 if ((r_ptr->flags1 & RF1_DROP_60) && (randint0(100) < 60)) number++;
1263 if ((r_ptr->flags1 & RF1_DROP_90) && (randint0(100) < 90)) number++;
1264 if (r_ptr->flags1 & RF1_DROP_1D2) number += damroll(1, 2);
1265 if (r_ptr->flags1 & RF1_DROP_2D2) number += damroll(2, 2);
1266 if (r_ptr->flags1 & RF1_DROP_3D2) number += damroll(3, 2);
1267 if (r_ptr->flags1 & RF1_DROP_4D2) number += damroll(4, 2);
1269 if (cloned && !(r_ptr->flags1 & RF1_UNIQUE))
1270 number = 0; /* Clones drop no stuff unless Cloning Pits */
1272 if (is_pet(m_ptr) || p_ptr->inside_battle || p_ptr->inside_arena)
1273 number = 0; /* Pets drop no stuff */
1274 if (!drop_item && (r_ptr->d_char != '$')) number = 0;
1276 if((r_ptr->flags2 & (RF2_MULTIPLY)) && (r_ptr->r_akills > 1024))
1277 number = 0; /* Limit of Multiply monster drop */
1279 /* Hack -- handle creeping coins */
1280 coin_type = force_coin;
1282 /* Average dungeon and monster levels */
1283 object_level = (dun_level + r_ptr->level) / 2;
1285 /* Drop some objects */
1286 for (j = 0; j < number; j++)
1292 if (do_gold && (!do_item || (randint0(100) < 50)))
1294 /* Make some gold */
1295 if (!make_gold(q_ptr)) continue;
1303 /* Make an object */
1304 if (!make_object(q_ptr, mo_mode)) continue;
1309 /* Drop it in the dungeon */
1310 (void)drop_near(q_ptr, -1, y, x);
1313 /* Reset the object level */
1314 object_level = base_level;
1316 /* Reset "coin" type */
1320 /* Take note of any dropped treasure */
1321 if (visible && (dump_item || dump_gold))
1323 /* Take notes on treasure */
1324 lore_treasure(m_idx, dump_item, dump_gold);
1327 /* Only process "Quest Monsters" */
1328 if (!(r_ptr->flags1 & RF1_QUESTOR)) return;
1329 if (p_ptr->inside_battle) return;
1332 if ((m_ptr->r_idx == MON_SERPENT) && !cloned)
1335 p_ptr->total_winner = TRUE;
1337 /* Redraw the "title" */
1338 p_ptr->redraw |= (PR_TITLE);
1340 play_music(TERM_XTRA_MUSIC_BASIC, MUSIC_BASIC_FINAL_QUEST_CLEAR);
1342 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, _("見事に変愚蛮怒の勝利者となった!", "become *WINNER* of Hengband finely!"));
1344 if ((p_ptr->pclass == CLASS_CHAOS_WARRIOR) || (p_ptr->muta2 & MUT2_CHAOS_GIFT))
1346 msg_format(_("%sからの声が響いた。", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
1347 msg_print(_("『よくやった、定命の者よ!』", "'Thou art donst well, mortal!'"));
1350 /* Congratulations */
1351 msg_print(_("*** おめでとう ***", "*** CONGRATULATIONS ***"));
1352 msg_print(_("あなたはゲームをコンプリートしました。", "You have won the game!"));
1353 msg_print(_("準備が整ったら引退(自殺コマンド)しても結構です。", "You may retire (commit suicide) when you are ready."));
1358 * @brief モンスターに与えたダメージの修正処理 /
1359 * Modify the physical damage done to the monster.
1360 * @param m_ptr ダメージを受けるモンスターの構造体参照ポインタ
1361 * @param dam ダメージ基本値
1362 * @param is_psy_spear 攻撃手段が光の剣ならばTRUE
1363 * @return 修正を行った結果のダメージ量
1366 * (for example when it's invulnerable or shielded)
1367 * ToDo: Accept a damage-type to calculate the modified damage from
1368 * things like fire, frost, lightning, poison, ... attacks.
1369 * "type" is not yet used and should be 0.
1372 HIT_POINT mon_damage_mod(monster_type *m_ptr, HIT_POINT dam, bool is_psy_spear)
1374 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1376 if ((r_ptr->flagsr & RFR_RES_ALL) && dam > 0)
1379 if ((dam == 0) && one_in_(3)) dam = 1;
1382 if (MON_INVULNER(m_ptr))
1386 if (!p_ptr->blind && is_seen(m_ptr))
1388 msg_print(_("バリアを切り裂いた!", "The barrier is penetrated!"));
1391 else if (!one_in_(PENETRATE_INVULNERABILITY))
1401 * @brief モンスターに与えたダメージを元に経験値を加算する /
1402 * Calculate experience point to be get
1403 * @param dam 与えたダメージ量
1404 * @param m_ptr ダメージを与えたモンスターの構造体参照ポインタ
1408 * Even the 64 bit operation is not big enough to avoid overflaw
1409 * unless we carefully choose orders of multiplication and division.
1410 * Get the coefficient first, and multiply (potentially huge) base
1411 * experience point of a monster later.
1414 static void get_exp_from_mon(HIT_POINT dam, monster_type *m_ptr)
1416 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1423 if (!m_ptr->r_idx) return;
1424 if (is_pet(m_ptr) || p_ptr->inside_battle) return;
1427 * - Ratio of monster's level to player's level effects
1428 * - Varying speed effects
1429 * - Get a fraction in proportion of damage point
1431 new_exp = r_ptr->level * SPEED_TO_ENERGY(m_ptr->mspeed) * dam;
1434 div_l = (p_ptr->max_plv+2) * SPEED_TO_ENERGY(r_ptr->speed);
1436 /* Use (average maxhp * 2) as a denominator */
1437 if (!(r_ptr->flags1 & RF1_FORCE_MAXHP))
1438 s64b_mul(&div_h, &div_l, 0, r_ptr->hdice * (ironman_nightmare ? 2 : 1) * (r_ptr->hside + 1));
1440 s64b_mul(&div_h, &div_l, 0, r_ptr->hdice * (ironman_nightmare ? 2 : 1) * r_ptr->hside * 2);
1442 /* Special penalty in the wilderness */
1443 if (!dun_level && (!(r_ptr->flags8 & RF8_WILD_ONLY) || !(r_ptr->flags1 & RF1_UNIQUE)))
1444 s64b_mul(&div_h, &div_l, 0, 5);
1446 /* Do division first to prevent overflaw */
1447 s64b_div(&new_exp, &new_exp_frac, div_h, div_l);
1449 /* Special penalty for mutiply-monster */
1450 if ((r_ptr->flags2 & RF2_MULTIPLY) || (m_ptr->r_idx == MON_DAWN))
1452 int monnum_penarty = r_ptr->r_akills / 400;
1453 if (monnum_penarty > 8) monnum_penarty = 8;
1455 while (monnum_penarty--)
1458 s64b_RSHIFT(new_exp, new_exp_frac, 2);
1462 /* Special penalty for rest_and_shoot exp scum */
1463 if ((m_ptr->dealt_damage > m_ptr->max_maxhp) && (m_ptr->hp >= 0))
1465 int over_damage = m_ptr->dealt_damage / m_ptr->max_maxhp;
1466 if (over_damage > 32) over_damage = 32;
1468 while (over_damage--)
1471 s64b_mul(&new_exp, &new_exp_frac, 0, 9);
1472 s64b_div(&new_exp, &new_exp_frac, 0, 10);
1476 /* Finally multiply base experience point of the monster */
1477 s64b_mul(&new_exp, &new_exp_frac, 0, r_ptr->mexp);
1479 /* Gain experience */
1480 gain_exp_64(new_exp, new_exp_frac);
1485 * @brief モンスターのHPをダメージに応じて減算する /
1486 * Decreases monsters hit points, handling monster death.
1487 * @param dam 与えたダメージ量
1488 * @param m_idx ダメージを与えたモンスターのID
1489 * @param fear ダメージによってモンスターが恐慌状態に陥ったならばTRUEを返す
1490 * @param note モンスターが倒された際の特別なメッセージ述語
1494 * We return TRUE if the monster has been killed (and deleted).
1495 * We announce monster death (using an optional "death message"
1496 * if given, and a otherwise a generic killed/destroyed message).
1497 * Only "physical attacks" can induce the "You have slain" message.
1498 * Missile and Spell attacks will induce the "dies" message, or
1499 * various "specialized" messages. Note that "You have destroyed"
1500 * and "is destroyed" are synonyms for "You have slain" and "dies".
1501 * Hack -- unseen monsters yield "You have killed it." message.
1502 * Added fear (DGK) and check whether to print fear messages -CWS
1503 * Made name, sex, and capitalization generic -BEN-
1504 * As always, the "ghost" processing is a total hack.
1505 * Hack -- we "delay" fear messages by passing around a "fear" flag.
1506 * Consider decreasing monster experience over time, say,
1507 * by using "(m_exp * m_lev * (m_lev)) / (p_lev * (m_lev + n_killed))"
1508 * instead of simply "(m_exp * m_lev) / (p_lev)", to make the first
1509 * monster worth more than subsequent monsters. This would also need
1510 * to induce changes in the monster recall code.
1513 bool mon_take_hit(MONSTER_IDX m_idx, HIT_POINT dam, bool *fear, cptr note)
1515 monster_type *m_ptr = &m_list[m_idx];
1516 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1517 monster_type exp_mon;
1519 /* Innocent until proven otherwise */
1520 bool innocent = TRUE, thief = FALSE;
1524 (void)COPY(&exp_mon, m_ptr, monster_type);
1526 expdam = (m_ptr->hp > dam) ? dam : m_ptr->hp;
1528 get_exp_from_mon(expdam, &exp_mon);
1530 /* Genocided by chaos patron */
1531 if (!m_ptr->r_idx) m_idx = 0;
1533 /* Redraw (later) if needed */
1534 if (p_ptr->health_who == m_idx) p_ptr->redraw |= (PR_HEALTH);
1535 if (p_ptr->riding == m_idx) p_ptr->redraw |= (PR_UHEALTH);
1537 (void)set_monster_csleep(m_idx, 0);
1539 /* Hack - Cancel any special player stealth magics. -LM- */
1540 if (p_ptr->special_defense & NINJA_S_STEALTH)
1542 set_superstealth(FALSE);
1545 /* Genocided by chaos patron */
1546 if (!m_idx) return TRUE;
1549 m_ptr->dealt_damage += dam;
1551 if(m_ptr->dealt_damage > m_ptr->max_maxhp * 100) m_ptr->dealt_damage = m_ptr->max_maxhp * 100;
1555 msg_format( _("合計%d/%dのダメージを与えた。","You do %d (out of %d) damage."), m_ptr->dealt_damage, m_ptr->maxhp);
1558 /* It is dead now */
1563 if (r_info[m_ptr->r_idx].flags7 & RF7_TANUKI)
1565 /* You might have unmasked Tanuki first time */
1566 r_ptr = &r_info[m_ptr->r_idx];
1567 m_ptr->ap_r_idx = m_ptr->r_idx;
1568 if (r_ptr->r_sights < MAX_SHORT) r_ptr->r_sights++;
1571 if (m_ptr->mflag2 & MFLAG2_CHAMELEON)
1573 /* You might have unmasked Chameleon first time */
1574 r_ptr = real_r_ptr(m_ptr);
1575 if (r_ptr->r_sights < MAX_SHORT) r_ptr->r_sights++;
1578 if (!(m_ptr->smart & SM_CLONED))
1580 /* When the player kills a Unique, it stays dead */
1581 if (r_ptr->flags1 & RF1_UNIQUE)
1585 /* Mega-Hack -- Banor & Lupart */
1586 if ((m_ptr->r_idx == MON_BANOR) || (m_ptr->r_idx == MON_LUPART))
1588 r_info[MON_BANORLUPART].max_num = 0;
1589 r_info[MON_BANORLUPART].r_pkills++;
1590 r_info[MON_BANORLUPART].r_akills++;
1591 if (r_info[MON_BANORLUPART].r_tkills < MAX_SHORT) r_info[MON_BANORLUPART].r_tkills++;
1593 else if (m_ptr->r_idx == MON_BANORLUPART)
1595 r_info[MON_BANOR].max_num = 0;
1596 r_info[MON_BANOR].r_pkills++;
1597 r_info[MON_BANOR].r_akills++;
1598 if (r_info[MON_BANOR].r_tkills < MAX_SHORT) r_info[MON_BANOR].r_tkills++;
1599 r_info[MON_LUPART].max_num = 0;
1600 r_info[MON_LUPART].r_pkills++;
1601 r_info[MON_LUPART].r_akills++;
1602 if (r_info[MON_LUPART].r_tkills < MAX_SHORT) r_info[MON_LUPART].r_tkills++;
1606 /* When the player kills a Nazgul, it stays dead */
1607 else if (r_ptr->flags7 & RF7_NAZGUL) r_ptr->max_num--;
1610 /* Count all monsters killed */
1611 if (r_ptr->r_akills < MAX_SHORT) r_ptr->r_akills++;
1613 /* Recall even invisible uniques or winners */
1614 if ((m_ptr->ml && !p_ptr->image) || (r_ptr->flags1 & RF1_UNIQUE))
1616 /* Count kills this life */
1617 if ((m_ptr->mflag2 & MFLAG2_KAGE) && (r_info[MON_KAGE].r_pkills < MAX_SHORT)) r_info[MON_KAGE].r_pkills++;
1618 else if (r_ptr->r_pkills < MAX_SHORT) r_ptr->r_pkills++;
1620 /* Count kills in all lives */
1621 if ((m_ptr->mflag2 & MFLAG2_KAGE) && (r_info[MON_KAGE].r_tkills < MAX_SHORT)) r_info[MON_KAGE].r_tkills++;
1622 else if (r_ptr->r_tkills < MAX_SHORT) r_ptr->r_tkills++;
1624 /* Hack -- Auto-recall */
1625 monster_race_track(m_ptr->ap_r_idx);
1628 /* Extract monster name */
1629 monster_desc(m_name, m_ptr, MD_TRUE_NAME);
1631 /* Don't kill Amberites */
1632 if ((r_ptr->flags3 & RF3_AMBERITE) && one_in_(2))
1634 int curses = 1 + randint1(3);
1635 bool stop_ty = FALSE;
1638 msg_format(_("%^sは恐ろしい血の呪いをあなたにかけた!", "%^s puts a terrible blood curse on you!"), m_name);
1639 curse_equipment(100, 50);
1643 stop_ty = activate_ty_curse(stop_ty, &count);
1648 if (r_ptr->flags2 & RF2_CAN_SPEAK)
1650 char line_got[1024];
1652 /* Dump a message */
1653 if (!get_rnd_line(_("mondeath_j.txt", "mondeath.txt"), m_ptr->r_idx, line_got))
1655 msg_format("%^s %s", m_name, line_got);
1659 if (m_ptr->r_idx == MON_SERPENT)
1661 screen_dump = make_screen_dump();
1666 if (!(d_info[dungeon_type].flags1 & DF1_BEGINNER))
1668 if (!dun_level && !ambush_flag && !p_ptr->inside_arena)
1670 chg_virtue(V_VALOUR, -1);
1672 else if (r_ptr->level > dun_level)
1674 if (randint1(10) <= (r_ptr->level - dun_level))
1675 chg_virtue(V_VALOUR, 1);
1677 if (r_ptr->level > 60)
1679 chg_virtue(V_VALOUR, 1);
1681 if (r_ptr->level >= 2 * (p_ptr->lev+1))
1682 chg_virtue(V_VALOUR, 2);
1685 if (r_ptr->flags1 & RF1_UNIQUE)
1687 if (r_ptr->flags3 & (RF3_EVIL | RF3_GOOD)) chg_virtue(V_HARMONY, 2);
1689 if (r_ptr->flags3 & RF3_GOOD)
1691 chg_virtue(V_UNLIFE, 2);
1692 chg_virtue(V_VITALITY, -2);
1695 if (one_in_(3)) chg_virtue(V_INDIVIDUALISM, -1);
1698 if (m_ptr->r_idx == MON_BEGGAR || m_ptr->r_idx == MON_LEPER)
1700 chg_virtue(V_COMPASSION, -1);
1703 if ((r_ptr->flags3 & RF3_GOOD) && ((r_ptr->level) / 10 + (3 * dun_level) >= randint1(100)))
1704 chg_virtue(V_UNLIFE, 1);
1706 if (r_ptr->d_char == 'A')
1708 if (r_ptr->flags1 & RF1_UNIQUE)
1709 chg_virtue(V_FAITH, -2);
1710 else if ((r_ptr->level) / 10 + (3 * dun_level) >= randint1(100))
1712 if (r_ptr->flags3 & RF3_GOOD) chg_virtue(V_FAITH, -1);
1713 else chg_virtue(V_FAITH, 1);
1716 else if (r_ptr->flags3 & RF3_DEMON)
1718 if (r_ptr->flags1 & RF1_UNIQUE)
1719 chg_virtue(V_FAITH, 2);
1720 else if ((r_ptr->level) / 10 + (3 * dun_level) >= randint1(100))
1721 chg_virtue(V_FAITH, 1);
1724 if ((r_ptr->flags3 & RF3_UNDEAD) && (r_ptr->flags1 & RF1_UNIQUE))
1725 chg_virtue(V_VITALITY, 2);
1727 if (r_ptr->r_deaths)
1729 if (r_ptr->flags1 & RF1_UNIQUE)
1731 chg_virtue(V_HONOUR, 10);
1733 else if ((r_ptr->level) / 10 + (2 * dun_level) >= randint1(100))
1735 chg_virtue(V_HONOUR, 1);
1738 if ((r_ptr->flags2 & RF2_MULTIPLY) && (r_ptr->r_akills > 1000) && one_in_(10))
1740 chg_virtue(V_VALOUR, -1);
1743 for (i = 0; i < 4; i++)
1745 if (r_ptr->blow[i].d_dice != 0) innocent = FALSE; /* Murderer! */
1747 if ((r_ptr->blow[i].effect == RBE_EAT_ITEM)
1748 || (r_ptr->blow[i].effect == RBE_EAT_GOLD))
1750 thief = TRUE; /* Thief! */
1753 /* The new law says it is illegal to live in the dungeon */
1754 if (r_ptr->level != 0) innocent = FALSE;
1758 if (r_ptr->flags1 & RF1_UNIQUE)
1759 chg_virtue(V_JUSTICE, 3);
1760 else if (1+((r_ptr->level) / 10 + (2 * dun_level)) >= randint1(100))
1761 chg_virtue(V_JUSTICE, 1);
1765 chg_virtue (V_JUSTICE, -1);
1768 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)))
1770 if (one_in_(4)) chg_virtue(V_NATURE, -1);
1773 if ((r_ptr->flags1 & RF1_UNIQUE) && record_destroy_uniq)
1776 sprintf(note_buf, "%s%s", r_name + r_ptr->name, (m_ptr->smart & SM_CLONED) ? _("(クローン)", "(Clone)") : "");
1777 do_cmd_write_nikki(NIKKI_UNIQUE, 0, note_buf);
1783 /* Death by Missile/Spell attack */
1786 msg_format("%^s%s", m_name, note);
1789 /* Death by physical attack -- invisible monster */
1790 else if (!m_ptr->ml)
1793 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
1794 msg_format("せっかくだから%sを殺した。", m_name);
1796 msg_format("%sを殺した。", m_name);
1798 msg_format("You have killed %s.", m_name);
1803 /* Death by Physical attack -- non-living monster */
1804 else if (!monster_living(m_ptr->r_idx))
1806 bool explode = FALSE;
1808 for (i = 0; i < 4; i++)
1810 if (r_ptr->blow[i].method == RBM_EXPLODE) explode = TRUE;
1813 /* Special note at death */
1815 msg_format(_("%sは爆発して粉々になった。", "%^s explodes into tiny shreds."), m_name);
1819 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
1820 msg_format("せっかくだから%sを倒した。", m_name);
1822 msg_format("%sを倒した。", m_name);
1824 msg_format("You have destroyed %s.", m_name);
1829 /* Death by Physical attack -- living monster */
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 slain %s.", m_name);
1842 if ((r_ptr->flags1 & RF1_UNIQUE) && !(m_ptr->smart & SM_CLONED) && !vanilla_town)
1844 for (i = 0; i < MAX_KUBI; i++)
1846 if ((kubi_r_idx[i] == m_ptr->r_idx) && !(m_ptr->mflag2 & MFLAG2_CHAMELEON))
1848 msg_format(_("%sの首には賞金がかかっている。", "There is a price on %s's head."), m_name);
1854 /* Generate treasure */
1855 monster_death(m_idx, TRUE);
1857 /* Mega hack : replace IKETA to BIKETAL */
1858 if ((m_ptr->r_idx == MON_IKETA) && !(p_ptr->inside_arena || p_ptr->inside_battle))
1860 POSITION dummy_y = m_ptr->fy;
1861 POSITION dummy_x = m_ptr->fx;
1862 BIT_FLAGS mode = 0L;
1863 if (is_pet(m_ptr)) mode |= PM_FORCE_PET;
1864 delete_monster_idx(m_idx);
1865 if (summon_named_creature(0, dummy_y, dummy_x, MON_BIKETAL, mode))
1867 msg_print(_("「ハァッハッハッハ!!私がバイケタルだ!!」", "Uwa-hahaha! *I* am Biketal!"));
1872 delete_monster_idx(m_idx);
1875 get_exp_from_mon((long)exp_mon.max_maxhp*2, &exp_mon);
1880 /* Monster is dead */
1887 /* Mega-Hack -- Pain cancels fear */
1888 if (MON_MONFEAR(m_ptr) && (dam > 0))
1891 if (set_monster_monfear(m_idx, MON_MONFEAR(m_ptr) - randint1(dam)))
1898 /* Sometimes a monster gets scared by damage */
1899 if (!MON_MONFEAR(m_ptr) && !(r_ptr->flags3 & (RF3_NO_FEAR)))
1901 /* Percentage of fully healthy */
1902 int percentage = (100L * m_ptr->hp) / m_ptr->maxhp;
1905 * Run (sometimes) if at 10% or less of max hit points,
1906 * or (usually) when hit for half its current hit points
1908 if ((randint1(10) >= percentage) || ((dam >= m_ptr->hp) && (randint0(100) < 80)))
1910 /* Hack -- note fear */
1913 /* Hack -- Add some timed fear */
1914 (void)set_monster_monfear(m_idx, (randint1(10) +
1915 (((dam >= m_ptr->hp) && (percentage > 7)) ?
1916 20 : ((11 - percentage) * 5))));
1928 * @brief 現在のコンソール表示の縦横を返す。 /
1929 * Get term size and calculate screen size
1930 * @param wid_p コンソールの表示幅文字数を返す
1931 * @param hgt_p コンソールの表示行数を返す
1934 void get_screen_size(TERM_LEN *wid_p, TERM_LEN *hgt_p)
1936 Term_get_size(wid_p, hgt_p);
1937 *hgt_p -= ROW_MAP + 2;
1938 *wid_p -= COL_MAP + 2;
1939 if (use_bigtile) *wid_p /= 2;
1944 * @brief コンソール上におけるマップ表示の左上位置を返す /
1945 * Calculates current boundaries Called below and from "do_cmd_locate()".
1948 void panel_bounds_center(void)
1952 get_screen_size(&wid, &hgt);
1954 panel_row_max = panel_row_min + hgt - 1;
1955 panel_row_prt = panel_row_min - 1;
1956 panel_col_max = panel_col_min + wid - 1;
1957 panel_col_prt = panel_col_min - 13;
1962 * @brief コンソールのリサイズに合わせてマップを再描画する /
1963 * Map resizing whenever the main term changes size
1966 void resize_map(void)
1968 /* Only if the dungeon exists */
1969 if (!character_dungeon) return;
1971 /* Mega-Hack -- no panel yet */
1975 /* Reset the panels */
1976 panel_row_min = cur_hgt;
1977 panel_col_min = cur_wid;
1981 p_ptr->update |= (PU_TORCH | PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
1983 /* Forget lite/view */
1984 p_ptr->update |= (PU_UN_VIEW | PU_UN_LITE);
1986 /* Update lite/view */
1987 p_ptr->update |= (PU_VIEW | PU_LITE | PU_MON_LITE);
1989 /* Update monsters */
1990 p_ptr->update |= (PU_MONSTERS);
1992 /* Redraw everything */
1993 p_ptr->redraw |= (PR_WIPE | PR_BASIC | PR_EXTRA | PR_MAP | PR_EQUIPPY);
1995 /* Hack -- update */
2001 * Place the cursor on the player
2003 if (can_save) move_cursor_relative(p_ptr->y, p_ptr->x);
2010 * @brief コンソールを再描画する /
2011 * Redraw a term when it is resized
2014 void redraw_window(void)
2016 /* Only if the dungeon exists */
2017 if (!character_dungeon) return;
2019 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_SPELL | PW_PLAYER);
2020 p_ptr->window |= (PW_MESSAGE | PW_OVERHEAD | PW_DUNGEON | PW_MONSTER | PW_OBJECT);
2022 /* Hack -- update */
2029 * @brief フォーカスを当てるべきマップ描画の基準座標を指定する(サブルーチン)
2030 * @param dy 変更先のフロアY座標
2031 * @param dx 変更先のフロアX座標
2032 * Handle a request to change the current panel
2033 * Return TRUE if the panel was changed.
2034 * Also used in do_cmd_locate
2035 * @return 実際に再描画が必要だった場合TRUEを返す
2037 bool change_panel(POSITION dy, POSITION dx)
2042 get_screen_size(&wid, &hgt);
2044 /* Apply the motion */
2045 y = panel_row_min + dy * hgt / 2;
2046 x = panel_col_min + dx * wid / 2;
2048 /* Verify the row */
2049 if (y > cur_hgt - hgt) y = cur_hgt - hgt;
2052 /* Verify the col */
2053 if (x > cur_wid - wid) x = cur_wid - wid;
2056 /* Handle "changes" */
2057 if ((y != panel_row_min) || (x != panel_col_min))
2059 /* Save the new panel info */
2063 /* Recalculate the boundaries */
2064 panel_bounds_center();
2066 p_ptr->update |= (PU_MONSTERS);
2068 p_ptr->redraw |= (PR_MAP);
2080 * @brief フォーカスを当てるべきマップ描画の基準座標を指定する
2081 * @param y 変更先のフロアY座標
2082 * @param x 変更先のフロアX座標
2084 * Handle a request to change the current panel
2085 * Return TRUE if the panel was changed.
2086 * Also used in do_cmd_locate
2087 * @return 実際に再描画が必要だった場合TRUEを返す
2089 static bool change_panel_xy(POSITION y, POSITION x)
2091 POSITION dy = 0, dx = 0;
2094 get_screen_size(&wid, &hgt);
2096 if (y < panel_row_min) dy = -1;
2097 if (y > panel_row_max) dy = 1;
2098 if (x < panel_col_min) dx = -1;
2099 if (x > panel_col_max) dx = 1;
2101 if (!dy && !dx) return (FALSE);
2103 return change_panel(dy, dx);
2108 * @brief マップ描画のフォーカスを当てるべき座標を更新する
2110 * Given an row (y) and col (x), this routine detects when a move
2111 * off the screen has occurred and figures new borders. -RAK-
2112 * "Update" forces a "full update" to take place.
2113 * The map is reprinted if necessary, and "TRUE" is returned.
2114 * @return 実際に再描画が必要だった場合TRUEを返す
2116 void verify_panel(void)
2118 POSITION y = p_ptr->y;
2119 POSITION x = p_ptr->x;
2127 get_screen_size(&wid, &hgt);
2129 max_prow_min = cur_hgt - hgt;
2130 max_pcol_min = cur_wid - wid;
2132 /* Bounds checking */
2133 if (max_prow_min < 0) max_prow_min = 0;
2134 if (max_pcol_min < 0) max_pcol_min = 0;
2136 /* Center on player */
2137 if (center_player && (center_running || !running))
2139 /* Center vertically */
2140 prow_min = y - hgt / 2;
2141 if (prow_min < 0) prow_min = 0;
2142 else if (prow_min > max_prow_min) prow_min = max_prow_min;
2144 /* Center horizontally */
2145 pcol_min = x - wid / 2;
2146 if (pcol_min < 0) pcol_min = 0;
2147 else if (pcol_min > max_pcol_min) pcol_min = max_pcol_min;
2151 prow_min = panel_row_min;
2152 pcol_min = panel_col_min;
2154 /* Scroll screen when 2 grids from top/bottom edge */
2155 if (y > panel_row_max - 2)
2157 while (y > prow_min + hgt-1 - 2)
2159 prow_min += (hgt / 2);
2163 if (y < panel_row_min + 2)
2165 while (y < prow_min + 2)
2167 prow_min -= (hgt / 2);
2171 if (prow_min > max_prow_min) prow_min = max_prow_min;
2172 if (prow_min < 0) prow_min = 0;
2174 /* Scroll screen when 4 grids from left/right edge */
2175 if (x > panel_col_max - 4)
2177 while (x > pcol_min + wid-1 - 4)
2179 pcol_min += (wid / 2);
2183 if (x < panel_col_min + 4)
2185 while (x < pcol_min + 4)
2187 pcol_min -= (wid / 2);
2191 if (pcol_min > max_pcol_min) pcol_min = max_pcol_min;
2192 if (pcol_min < 0) pcol_min = 0;
2195 /* Check for "no change" */
2196 if ((prow_min == panel_row_min) && (pcol_min == panel_col_min)) return;
2198 /* Save the new panel info */
2199 panel_row_min = prow_min;
2200 panel_col_min = pcol_min;
2202 /* Hack -- optional disturb on "panel change" */
2203 if (disturb_panel && !center_player) disturb(FALSE, FALSE);
2205 /* Recalculate the boundaries */
2206 panel_bounds_center();
2208 p_ptr->update |= (PU_MONSTERS);
2209 p_ptr->redraw |= (PR_MAP);
2210 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
2215 * Monster health description
2217 cptr look_mon_desc(monster_type *m_ptr, BIT_FLAGS mode)
2219 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
2226 /* Determine if the monster is "living" */
2227 living = monster_living(m_ptr->ap_r_idx);
2229 /* Calculate a health "percentage" */
2230 perc = 100L * m_ptr->hp / m_ptr->maxhp;
2232 /* Healthy monsters */
2233 if (m_ptr->hp >= m_ptr->maxhp)
2235 desc = living ? _("無傷", "unhurt") : _("無ダメージ", "undamaged");
2238 else if (perc >= 60)
2240 desc = living ? _("軽傷", "somewhat wounded") : _("小ダメージ", "somewhat damaged");
2243 else if (perc >= 25)
2245 desc = living ? _("負傷", "wounded") : _("中ダメージ", "damaged");
2248 else if (perc >= 10)
2250 desc = living ? _("重傷", "badly wounded") : _("大ダメージ", "badly damaged");
2255 desc = living ? _("半死半生", "almost dead") : _("倒れかけ", "almost destroyed");
2258 /* Need attitude information? */
2261 /* Full information is not needed */
2264 else if (is_pet(m_ptr))
2266 attitude = _(", ペット", ", pet");
2268 else if (is_friendly(m_ptr))
2270 attitude = _(", 友好的", ", friendly");
2274 attitude = _("", "");
2277 /* Clone monster? */
2278 if (m_ptr->smart & SM_CLONED)
2287 /* Display monster's level --- idea borrowed from ToME */
2288 if (ap_r_ptr->r_tkills && !(m_ptr->mflag2 & MFLAG2_KAGE))
2290 return format(_("レベル%d, %s%s%s", "Level %d, %s%s%s"), ap_r_ptr->level, desc, attitude, clone);
2294 return format(_("レベル???, %s%s%s", "Level ???, %s%s%s"), desc, attitude, clone);
2302 * Angband sorting algorithm -- quick sort in place
2304 * Note that the details of the data we are sorting is hidden,
2305 * and we rely on the "ang_sort_comp()" and "ang_sort_swap()"
2306 * function hooks to interact with the data, which is given as
2307 * two pointers, and which may have any user-defined form.
2309 void ang_sort_aux(vptr u, vptr v, int p, int q)
2327 while (!(*ang_sort_comp)(u, v, b, z)) b--;
2330 while (!(*ang_sort_comp)(u, v, z, a)) a++;
2332 /* Done partition */
2336 (*ang_sort_swap)(u, v, a, b);
2342 /* Recurse left side */
2343 ang_sort_aux(u, v, p, b);
2345 /* Recurse right side */
2346 ang_sort_aux(u, v, b+1, q);
2351 * Angband sorting algorithm -- quick sort in place
2353 * Note that the details of the data we are sorting is hidden,
2354 * and we rely on the "ang_sort_comp()" and "ang_sort_swap()"
2355 * function hooks to interact with the data, which is given as
2356 * two pointers, and which may have any user-defined form.
2358 void ang_sort(vptr u, vptr v, int n)
2360 /* Sort the array */
2361 ang_sort_aux(u, v, 0, n-1);
2366 /*** Targeting Code ***/
2370 * Determine is a monster makes a reasonable target
2372 * The concept of "targeting" was stolen from "Morgul" (?)
2374 * The player can target any location, or any "target-able" monster.
2376 * Currently, a monster is "target_able" if it is visible, and if
2377 * the player can hit it with a projection, and the player is not
2378 * hallucinating. This allows use of "use closest target" macros.
2380 * Future versions may restrict the ability to target "trappers"
2381 * and "mimics", but the semantics is a little bit weird.
2383 bool target_able(MONSTER_IDX m_idx)
2385 monster_type *m_ptr = &m_list[m_idx];
2387 /* Monster must be alive */
2388 if (!m_ptr->r_idx) return (FALSE);
2390 /* Hack -- no targeting hallucinations */
2391 if (p_ptr->image) return (FALSE);
2393 /* Monster must be visible */
2394 if (!m_ptr->ml) return (FALSE);
2396 if (p_ptr->riding && (p_ptr->riding == m_idx)) return (TRUE);
2398 /* Monster must be projectable */
2399 if (!projectable(p_ptr->y, p_ptr->x, m_ptr->fy, m_ptr->fx)) return (FALSE);
2401 /* Hack -- Never target trappers */
2402 /* if (CLEAR_ATTR && (CLEAR_CHAR)) return (FALSE); */
2412 * Update (if necessary) and verify (if possible) the target.
2414 * We return TRUE if the target is "okay" and FALSE otherwise.
2416 bool target_okay(void)
2418 /* Accept stationary targets */
2419 if (target_who < 0) return (TRUE);
2421 /* Check moving targets */
2424 /* Accept reasonable targets */
2425 if (target_able(target_who))
2427 monster_type *m_ptr = &m_list[target_who];
2429 /* Acquire monster location */
2430 target_row = m_ptr->fy;
2431 target_col = m_ptr->fx;
2438 /* Assume no target */
2444 * Sorting hook -- comp function -- by "distance to player"
2446 * We use "u" and "v" to point to arrays of "x" and "y" positions,
2447 * and sort the arrays by double-distance to the player.
2449 static bool ang_sort_comp_distance(vptr u, vptr v, int a, int b)
2451 POSITION *x = (POSITION*)(u);
2452 POSITION *y = (POSITION*)(v);
2454 POSITION da, db, kx, ky;
2456 /* Absolute distance components */
2457 kx = x[a]; kx -= p_ptr->x; kx = ABS(kx);
2458 ky = y[a]; ky -= p_ptr->y; ky = ABS(ky);
2460 /* Approximate Double Distance to the first point */
2461 da = ((kx > ky) ? (kx + kx + ky) : (ky + ky + kx));
2463 /* Absolute distance components */
2464 kx = x[b]; kx -= p_ptr->x; kx = ABS(kx);
2465 ky = y[b]; ky -= p_ptr->y; ky = ABS(ky);
2467 /* Approximate Double Distance to the first point */
2468 db = ((kx > ky) ? (kx + kx + ky) : (ky + ky + kx));
2470 /* Compare the distances */
2476 * Sorting hook -- comp function -- by importance level of grids
2478 * We use "u" and "v" to point to arrays of "x" and "y" positions,
2479 * and sort the arrays by level of monster
2481 static bool ang_sort_comp_importance(vptr u, vptr v, int a, int b)
2483 POSITION *x = (POSITION*)(u);
2484 POSITION *y = (POSITION*)(v);
2485 cave_type *ca_ptr = &cave[y[a]][x[a]];
2486 cave_type *cb_ptr = &cave[y[b]][x[b]];
2487 monster_type *ma_ptr = &m_list[ca_ptr->m_idx];
2488 monster_type *mb_ptr = &m_list[cb_ptr->m_idx];
2489 monster_race *ap_ra_ptr, *ap_rb_ptr;
2491 /* The player grid */
2492 if (y[a] == p_ptr->y && x[a] == p_ptr->x) return TRUE;
2493 if (y[b] == p_ptr->y && x[b] == p_ptr->x) return FALSE;
2495 /* Extract monster race */
2496 if (ca_ptr->m_idx && ma_ptr->ml) ap_ra_ptr = &r_info[ma_ptr->ap_r_idx];
2497 else ap_ra_ptr = NULL;
2498 if (cb_ptr->m_idx && mb_ptr->ml) ap_rb_ptr = &r_info[mb_ptr->ap_r_idx];
2499 else ap_rb_ptr = NULL;
2501 if (ap_ra_ptr && !ap_rb_ptr) return TRUE;
2502 if (!ap_ra_ptr && ap_rb_ptr) return FALSE;
2504 /* Compare two monsters */
2505 if (ap_ra_ptr && ap_rb_ptr)
2507 /* Unique monsters first */
2508 if ((ap_ra_ptr->flags1 & RF1_UNIQUE) && !(ap_rb_ptr->flags1 & RF1_UNIQUE)) return TRUE;
2509 if (!(ap_ra_ptr->flags1 & RF1_UNIQUE) && (ap_rb_ptr->flags1 & RF1_UNIQUE)) return FALSE;
2511 /* Shadowers first (あやしい影) */
2512 if ((ma_ptr->mflag2 & MFLAG2_KAGE) && !(mb_ptr->mflag2 & MFLAG2_KAGE)) return TRUE;
2513 if (!(ma_ptr->mflag2 & MFLAG2_KAGE) && (mb_ptr->mflag2 & MFLAG2_KAGE)) return FALSE;
2515 /* Unknown monsters first */
2516 if (!ap_ra_ptr->r_tkills && ap_rb_ptr->r_tkills) return TRUE;
2517 if (ap_ra_ptr->r_tkills && !ap_rb_ptr->r_tkills) return FALSE;
2519 /* Higher level monsters first (if known) */
2520 if (ap_ra_ptr->r_tkills && ap_rb_ptr->r_tkills)
2522 if (ap_ra_ptr->level > ap_rb_ptr->level) return TRUE;
2523 if (ap_ra_ptr->level < ap_rb_ptr->level) return FALSE;
2526 /* Sort by index if all conditions are same */
2527 if (ma_ptr->ap_r_idx > mb_ptr->ap_r_idx) return TRUE;
2528 if (ma_ptr->ap_r_idx < mb_ptr->ap_r_idx) return FALSE;
2531 /* An object get higher priority */
2532 if (cave[y[a]][x[a]].o_idx && !cave[y[b]][x[b]].o_idx) return TRUE;
2533 if (!cave[y[a]][x[a]].o_idx && cave[y[b]][x[b]].o_idx) return FALSE;
2535 /* Priority from the terrain */
2536 if (f_info[ca_ptr->feat].priority > f_info[cb_ptr->feat].priority) return TRUE;
2537 if (f_info[ca_ptr->feat].priority < f_info[cb_ptr->feat].priority) return FALSE;
2539 /* If all conditions are same, compare distance */
2540 return ang_sort_comp_distance(u, v, a, b);
2545 * Sorting hook -- swap function -- by "distance to player"
2547 * We use "u" and "v" to point to arrays of "x" and "y" positions,
2548 * and sort the arrays by distance to the player.
2550 static void ang_sort_swap_distance(vptr u, vptr v, int a, int b)
2552 POSITION *x = (POSITION*)(u);
2553 POSITION *y = (POSITION*)(v);
2571 * Hack -- help "select" a location (see below)
2573 static POSITION_IDX target_pick(POSITION y1, POSITION x1, POSITION dy, POSITION dx)
2576 POSITION x2, y2, x3, y3, x4, y4;
2577 POSITION_IDX b_i = -1, b_v = 9999;
2580 /* Scan the locations */
2581 for (i = 0; i < temp_n; i++)
2587 /* Directed distance */
2591 /* Verify quadrant */
2592 if (dx && (x3 * dx <= 0)) continue;
2593 if (dy && (y3 * dy <= 0)) continue;
2595 /* Absolute distance */
2599 /* Verify quadrant */
2600 if (dy && !dx && (x4 > y4)) continue;
2601 if (dx && !dy && (y4 > x4)) continue;
2603 /* Approximate Double Distance */
2604 v = ((x4 > y4) ? (x4 + x4 + y4) : (y4 + y4 + x4));
2606 /* Penalize location */
2609 if ((b_i >= 0) && (v >= b_v)) continue;
2619 * Hack -- determine if a given location is "interesting"
2621 static bool target_set_accept(POSITION y, POSITION x)
2624 OBJECT_IDX this_o_idx, next_o_idx = 0;
2627 if (!(in_bounds(y, x))) return (FALSE);
2629 /* Player grid is always interesting */
2630 if (player_bold(y, x)) return (TRUE);
2632 /* Handle hallucination */
2633 if (p_ptr->image) return (FALSE);
2635 /* Examine the grid */
2636 c_ptr = &cave[y][x];
2638 /* Visible monsters */
2641 monster_type *m_ptr = &m_list[c_ptr->m_idx];
2643 /* Visible monsters */
2644 if (m_ptr->ml) return (TRUE);
2647 /* Scan all objects in the grid */
2648 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
2651 o_ptr = &o_list[this_o_idx];
2653 /* Acquire next object */
2654 next_o_idx = o_ptr->next_o_idx;
2656 /* Memorized object */
2657 if (o_ptr->marked & OM_FOUND) return (TRUE);
2660 /* Interesting memorized features */
2661 if (c_ptr->info & (CAVE_MARK))
2663 /* Notice object features */
2664 if (c_ptr->info & CAVE_OBJECT) return (TRUE);
2666 /* Feature code (applying "mimic" field) */
2667 if (have_flag(f_info[get_feat_mimic(c_ptr)].flags, FF_NOTICE)) return TRUE;
2675 * Prepare the "temp" array for "target_set"
2677 * Return the number of target_able monsters in the set.
2679 static void target_set_prepare(BIT_FLAGS mode)
2682 POSITION min_hgt, max_hgt, min_wid, max_wid;
2684 if (mode & TARGET_KILL)
2687 min_hgt = MAX((p_ptr->y - MAX_RANGE), 0);
2688 max_hgt = MIN((p_ptr->y + MAX_RANGE), cur_hgt - 1);
2689 min_wid = MAX((p_ptr->x - MAX_RANGE), 0);
2690 max_wid = MIN((p_ptr->x + MAX_RANGE), cur_wid - 1);
2692 else /* not targetting */
2695 min_hgt = panel_row_min;
2696 max_hgt = panel_row_max;
2697 min_wid = panel_col_min;
2698 max_wid = panel_col_max;
2701 /* Reset "temp" array */
2704 /* Scan the current panel */
2705 for (y = min_hgt; y <= max_hgt; y++)
2707 for (x = min_wid; x <= max_wid; x++)
2711 /* Require "interesting" contents */
2712 if (!target_set_accept(y, x)) continue;
2714 c_ptr = &cave[y][x];
2716 /* Require target_able monsters for "TARGET_KILL" */
2717 if ((mode & (TARGET_KILL)) && !target_able(c_ptr->m_idx)) continue;
2719 if ((mode & (TARGET_KILL)) && !target_pet && is_pet(&m_list[c_ptr->m_idx])) continue;
2721 /* Save the location */
2728 /* Set the sort hooks */
2729 if (mode & (TARGET_KILL))
2731 /* Target the nearest monster for shooting */
2732 ang_sort_comp = ang_sort_comp_distance;
2733 ang_sort_swap = ang_sort_swap_distance;
2737 /* Look important grids first in Look command */
2738 ang_sort_comp = ang_sort_comp_importance;
2739 ang_sort_swap = ang_sort_swap_distance;
2742 /* Sort the positions */
2743 ang_sort(temp_x, temp_y, temp_n);
2745 if (p_ptr->riding && target_pet && (temp_n > 1) && (mode & (TARGET_KILL)))
2750 temp_y[0] = temp_y[1];
2753 temp_x[0] = temp_x[1];
2758 void target_set_prepare_look(void){
2759 target_set_prepare(TARGET_LOOK);
2764 * Evaluate number of kill needed to gain level
2766 static void evaluate_monster_exp(char *buf, monster_type *m_ptr)
2768 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
2770 s32b exp_mon, exp_adv;
2771 u32b exp_mon_frac, exp_adv_frac;
2773 if ((p_ptr->lev >= PY_MAX_LEVEL) || (p_ptr->prace == RACE_ANDROID))
2778 else if (!ap_r_ptr->r_tkills || (m_ptr->mflag2 & MFLAG2_KAGE))
2788 /* The monster's experience point (assuming average monster speed) */
2789 exp_mon = ap_r_ptr->mexp * ap_r_ptr->level;
2791 s64b_div(&exp_mon, &exp_mon_frac, 0, (p_ptr->max_plv + 2));
2794 /* Total experience value for next level */
2795 exp_adv = player_exp[p_ptr->lev -1] * p_ptr->expfact;
2797 s64b_div(&exp_adv, &exp_adv_frac, 0, 100);
2799 /* Experience value need to get */
2800 s64b_sub(&exp_adv, &exp_adv_frac, p_ptr->exp, p_ptr->exp_frac);
2803 /* You need to kill at least one monster to get any experience */
2804 s64b_add(&exp_adv, &exp_adv_frac, exp_mon, exp_mon_frac);
2805 s64b_sub(&exp_adv, &exp_adv_frac, 0, 1);
2807 /* Extract number of monsters needed */
2808 s64b_div(&exp_adv, &exp_adv_frac, exp_mon, exp_mon_frac);
2810 /* If 999 or more monsters needed, only display "999". */
2811 num = MIN(999, exp_adv_frac);
2813 /* Display the number */
2814 sprintf(buf,"%03ld", (long int)num);
2818 bool show_gold_on_floor = FALSE;
2821 * Examine a grid, return a keypress.
2823 * The "mode" argument contains the "TARGET_LOOK" bit flag, which
2824 * indicates that the "space" key should scan through the contents
2825 * of the grid, instead of simply returning immediately. This lets
2826 * the "look" command get complete information, without making the
2827 * "target" command annoying.
2829 * The "info" argument contains the "commands" which should be shown
2830 * inside the "[xxx]" text. This string must never be empty, or grids
2831 * containing monsters will be displayed with an extra comma.
2833 * Note that if a monster is in the grid, we update both the monster
2834 * recall info and the health bar info to track that monster.
2836 * Eventually, we may allow multiple objects per grid, or objects
2837 * and terrain features in the same grid.
2839 * This function must handle blindness/hallucination.
2841 static char target_set_aux(POSITION y, POSITION x, BIT_FLAGS mode, cptr info)
2843 cave_type *c_ptr = &cave[y][x];
2844 OBJECT_IDX this_o_idx, next_o_idx = 0;
2845 cptr s1 = "", s2 = "", s3 = "", x_info = "";
2848 feature_type *f_ptr;
2849 char query = '\001';
2850 char out_val[MAX_NLEN+80];
2851 OBJECT_IDX floor_list[23];
2852 ITEM_NUMBER floor_num = 0;
2854 /* Scan all objects in the grid */
2857 floor_num = scan_floor(floor_list, y, x, 0x02);
2861 x_info = _("x物 ", "x,");
2865 /* Hack -- under the player */
2866 if (player_bold(y, x))
2882 s1 = _("ターゲット:", "Target:");
2885 /* Hack -- hallucination */
2888 cptr name = _("何か奇妙な物", "something strange");
2890 /* Display a message */
2892 sprintf(out_val, "%s%s%s%s [%s]", s1, name, s2, s3, info);
2894 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, name, info);
2898 move_cursor_relative(y, x);
2901 /* Stop on everything but "return" */
2902 if ((query != '\r') && (query != '\n')) return query;
2904 /* Repeat forever */
2909 /* Actual monsters */
2910 if (c_ptr->m_idx && m_list[c_ptr->m_idx].ml)
2912 monster_type *m_ptr = &m_list[c_ptr->m_idx];
2913 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
2915 bool recall = FALSE;
2920 /* Get the monster name ("a kobold") */
2921 monster_desc(m_name, m_ptr, MD_INDEF_VISIBLE);
2923 /* Hack -- track this monster race */
2924 monster_race_track(m_ptr->ap_r_idx);
2926 /* Hack -- health bar for this monster */
2927 health_track(c_ptr->m_idx);
2941 /* Recall on screen */
2942 screen_roff(m_ptr->ap_r_idx, 0);
2944 /* Hack -- Complete the prompt (again) */
2945 Term_addstr(-1, TERM_WHITE, format(_(" [r思 %s%s]", " [r,%s%s]"), x_info, info));
2953 /* Normal commands */
2954 if (query != 'r') break;
2959 /* Cleare recall text and repeat */
2965 /* Describe, and prompt for recall */
2966 evaluate_monster_exp(acount, m_ptr);
2969 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);
2971 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);
2977 move_cursor_relative(y, x);
2982 /* Normal commands */
2983 if (query != 'r') break;
2989 /* Always stop at "normal" keys */
2990 if ((query != '\r') && (query != '\n') && (query != ' ') && (query != 'x')) return query;
2992 /* Sometimes stop at "space" key */
2993 if ((query == ' ') && !(mode & (TARGET_LOOK))) return query;
2995 /* Change the intro */
2996 s1 = _("それは", "It is ");
2998 /* Hack -- take account of gender */
2999 if (ap_r_ptr->flags1 & (RF1_FEMALE)) s1 = _("彼女は", "She is ");
3000 else if (ap_r_ptr->flags1 & (RF1_MALE)) s1 = _("彼は", "He is ");
3002 /* Use a preposition */
3011 /* Scan all objects being carried */
3012 for (this_o_idx = m_ptr->hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
3014 char o_name[MAX_NLEN];
3017 o_ptr = &o_list[this_o_idx];
3019 /* Acquire next object */
3020 next_o_idx = o_ptr->next_o_idx;
3022 /* Obtain an object description */
3023 object_desc(o_name, o_ptr, 0);
3026 sprintf(out_val, "%s%s%s%s[%s]", s1, o_name, s2, s3, info);
3028 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, o_name, info);
3032 move_cursor_relative(y, x);
3035 /* Always stop at "normal" keys */
3036 if ((query != '\r') && (query != '\n') && (query != ' ') && (query != 'x')) return query;
3038 /* Sometimes stop at "space" key */
3039 if ((query == ' ') && !(mode & (TARGET_LOOK))) return query;
3041 /* Change the intro */
3042 s2 = _("をまた", "also carrying ");
3045 /* Use a preposition */
3062 char o_name[MAX_NLEN];
3065 o_ptr = &o_list[floor_list[0]];
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);
3085 /* Provide one cushion before item listing */
3088 /* Display rough information about items */
3090 sprintf(out_val, "%s %d個のアイテム%s%s ['x'で一覧, %s]", s1, (int)floor_num, s2, s3, info);
3092 sprintf(out_val, "%s%s%sa pile of %d items [x,%s]", s1, s2, s3, (int)floor_num, info);
3096 move_cursor_relative(y, x);
3101 /* No request for listing */
3102 if (query != 'x' && query != ' ') return query;
3106 /** Display list of items **/
3108 /* Continue scrolling list if requested */
3116 show_gold_on_floor = TRUE;
3117 (void)show_floor(0, y, x, &min_width);
3118 show_gold_on_floor = FALSE;
3122 sprintf(out_val, "%s %d個のアイテム%s%s [Enterで次へ, %s]", s1, (int)floor_num, s2, s3, info);
3124 sprintf(out_val, "%s%s%sa pile of %d items [Enter,%s]", s1, s2, s3, (int)floor_num, info);
3131 /* Exit unless 'Enter' */
3132 if (query != '\n' && query != '\r')
3137 /* Get the object being moved. */
3138 o_idx = c_ptr->o_idx;
3140 /* Only rotate a pile of two or more objects. */
3141 if (!(o_idx && o_list[o_idx].next_o_idx)) continue;
3143 /* Remove the first object from the list. */
3144 excise_object_idx(o_idx);
3146 /* Find end of the list. */
3148 while (o_list[i].next_o_idx)
3149 i = o_list[i].next_o_idx;
3151 /* Add after the last object. */
3152 o_list[i].next_o_idx = o_idx;
3154 /* Loop and re-display the list */
3161 /* Scan all objects in the grid */
3162 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
3165 o_ptr = &o_list[this_o_idx];
3167 /* Acquire next object */
3168 next_o_idx = o_ptr->next_o_idx;
3171 if (o_ptr->marked & OM_FOUND)
3173 char o_name[MAX_NLEN];
3178 /* Obtain an object description */
3179 object_desc(o_name, o_ptr, 0);
3182 sprintf(out_val, "%s%s%s%s[%s]", s1, o_name, s2, s3, info);
3184 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, o_name, info);
3188 move_cursor_relative(y, x);
3191 /* Always stop at "normal" keys */
3192 if ((query != '\r') && (query != '\n') && (query != ' ') && (query != 'x')) return query;
3194 /* Sometimes stop at "space" key */
3195 if ((query == ' ') && !(mode & TARGET_LOOK)) return query;
3197 /* Change the intro */
3198 s1 = _("それは", "It is ");
3201 if (o_ptr->number != 1) s1 = _("それらは", "They are ");
3215 /* Feature code (applying "mimic" field) */
3216 feat = get_feat_mimic(c_ptr);
3218 /* Require knowledge about grid, or ability to see grid */
3219 if (!(c_ptr->info & CAVE_MARK) && !player_can_see_bold(y, x))
3221 /* Forget feature */
3225 f_ptr = &f_info[feat];
3227 /* Terrain feature if needed */
3228 if (boring || have_flag(f_ptr->flags, FF_REMEMBER))
3232 /* Hack -- special handling for quest entrances */
3233 if (have_flag(f_ptr->flags, FF_QUEST_ENTER))
3235 /* Set the quest number temporary */
3236 IDX old_quest = p_ptr->inside_quest;
3239 /* Clear the text */
3240 for (j = 0; j < 10; j++) quest_text[j][0] = '\0';
3241 quest_text_line = 0;
3243 p_ptr->inside_quest = c_ptr->special;
3245 /* Get the quest text */
3246 init_flags = INIT_NAME_ONLY;
3248 process_dungeon_file("q_info.txt", 0, 0, 0, 0);
3250 name = format(_("クエスト「%s」(%d階相当)", "the entrance to the quest '%s'(level %d)"),
3251 quest[c_ptr->special].name, quest[c_ptr->special].level);
3253 /* Reset the old quest number */
3254 p_ptr->inside_quest = old_quest;
3257 /* Hack -- special handling for building doors */
3258 else if (have_flag(f_ptr->flags, FF_BLDG) && !p_ptr->inside_arena)
3260 name = building[f_ptr->subtype].name;
3262 else if (have_flag(f_ptr->flags, FF_ENTRANCE))
3264 name = format(_("%s(%d階相当)", "%s(level %d)"), d_text + d_info[c_ptr->special].text, d_info[c_ptr->special].mindepth);
3266 else if (have_flag(f_ptr->flags, FF_TOWN))
3268 name = town[c_ptr->special].name;
3270 else if (p_ptr->wild_mode && (feat == feat_floor))
3272 name = _("道", "road");
3276 name = f_name + f_ptr->name;
3282 ((!have_flag(f_ptr->flags, FF_MOVE) && !have_flag(f_ptr->flags, FF_CAN_FLY)) ||
3283 (!have_flag(f_ptr->flags, FF_LOS) && !have_flag(f_ptr->flags, FF_TREE)) ||
3284 have_flag(f_ptr->flags, FF_TOWN)))
3286 s2 = _("の中", "in ");
3289 /* Hack -- special introduction for store & building doors -KMW- */
3290 if (have_flag(f_ptr->flags, FF_STORE) ||
3291 have_flag(f_ptr->flags, FF_QUEST_ENTER) ||
3292 (have_flag(f_ptr->flags, FF_BLDG) && !p_ptr->inside_arena) ||
3293 have_flag(f_ptr->flags, FF_ENTRANCE))
3302 else if (have_flag(f_ptr->flags, FF_FLOOR) ||
3303 have_flag(f_ptr->flags, FF_TOWN) ||
3304 have_flag(f_ptr->flags, FF_SHALLOW) ||
3305 have_flag(f_ptr->flags, FF_DEEP))
3311 /* Pick proper indefinite article */
3312 s3 = (is_a_vowel(name[0])) ? "an " : "a ";
3316 /* Display a message */
3320 if (c_ptr->mimic) sprintf(f_idx_str, "%d/%d", c_ptr->feat, c_ptr->mimic);
3321 else sprintf(f_idx_str, "%d", c_ptr->feat);
3323 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]);
3325 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);
3330 sprintf(out_val, "%s%s%s%s[%s]", s1, name, s2, s3, info);
3332 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, name, info);
3336 move_cursor_relative(y, x);
3339 /* Always stop at "normal" keys */
3340 if ((query != '\r') && (query != '\n') && (query != ' ')) return query;
3343 /* Stop on everything but "return" */
3344 if ((query != '\r') && (query != '\n')) return query;
3346 /* Repeat forever */
3352 * Handle "target" and "look".
3354 * Note that this code can be called from "get_aim_dir()".
3356 * All locations must be on the current panel. Consider the use of
3357 * "panel_bounds()" to allow "off-panel" targets, perhaps by using
3358 * some form of "scrolling" the map around the cursor.
3359 * That is, consider the possibility of "auto-scrolling" the screen
3360 * while the cursor moves around. This may require changes in the
3361 * "update_monster()" code to allow "visibility" even if off panel, and
3362 * may require dynamic recalculation of the "temp" grid set.
3364 * Hack -- targeting/observing an "outer border grid" may induce
3365 * problems, so this is not currently allowed.
3367 * The player can use the direction keys to move among "interesting"
3368 * grids in a heuristic manner, or the "space", "+", and "-" keys to
3369 * move through the "interesting" grids in a sequential manner, or
3370 * can enter "location" mode, and use the direction keys to move one
3371 * grid at a time in any direction. The "t" (set target) command will
3372 * only target a monster (as opposed to a location) if the monster is
3373 * target_able and the "interesting" mode is being used.
3375 * The current grid is described using the "look" method above, and
3376 * a new command may be entered at any time, but note that if the
3377 * "TARGET_LOOK" bit flag is set (or if we are in "location" mode,
3378 * where "space" has no obvious meaning) then "space" will scan
3379 * through the description of the current grid until done, instead
3380 * of immediately jumping to the next "interesting" grid. This
3381 * allows the "target" command to retain its old semantics.
3383 * The "*", "+", and "-" keys may always be used to jump immediately
3384 * to the next (or previous) interesting grid, in the proper mode.
3386 * The "return" key may always be used to scan through a complete
3387 * grid description (forever).
3389 * This command will cancel any old target, even if used from
3390 * inside the "look" command.
3392 bool target_set(BIT_FLAGS mode)
3395 POSITION y = p_ptr->y;
3396 POSITION x = p_ptr->x;
3408 get_screen_size(&wid, &hgt);
3414 /* Cancel tracking */
3415 /* health_track(0); */
3417 if (rogue_like_commands)
3426 /* Prepare the "temp" array */
3427 target_set_prepare(mode);
3429 /* Start near the player */
3435 /* Interesting grids */
3442 change_panel_xy(y, x);
3444 if (!(mode & TARGET_LOOK)) prt_path(y, x);
3447 c_ptr = &cave[y][x];
3450 if (target_able(c_ptr->m_idx))
3452 strcpy(info, _("q止 t決 p自 o現 +次 -前", "q,t,p,o,+,-,<dir>"));
3455 /* Dis-allow target */
3458 strcpy(info, _("q止 p自 o現 +次 -前", "q,p,o,+,-,<dir>"));
3464 sprintf(cheatinfo, " LOS:%d, PROJECTABLE:%d",
3465 los(p_ptr->y, p_ptr->x, y, x),
3466 projectable(p_ptr->y, p_ptr->x, y, x));
3467 strcat(info, cheatinfo);
3470 /* Describe and Prompt */
3472 query = target_set_aux(y, x, mode, info);
3476 /* Cancel tracking */
3477 /* health_track(0); */
3479 /* Assume no "direction" */
3484 if (query == '\r') query = 't';
3502 if (target_able(c_ptr->m_idx))
3504 health_track(c_ptr->m_idx);
3505 target_who = c_ptr->m_idx;
3524 if (!expand_list) done = TRUE;
3534 if (!expand_list) done = TRUE;
3541 /* Recenter the map around the player */
3544 p_ptr->update |= (PU_MONSTERS);
3546 p_ptr->redraw |= (PR_MAP);
3548 p_ptr->window |= (PW_OVERHEAD);
3551 /* Recalculate interesting grids */
3552 target_set_prepare(mode);
3571 if(query == same_key)
3576 if (!expand_list) done = TRUE;
3581 /* Extract the action (if any) */
3582 d = get_keymap_dir(query);
3589 /* Hack -- move around */
3592 /* Modified to scroll to monster */
3593 POSITION y2 = panel_row_min;
3594 POSITION x2 = panel_col_min;
3596 /* Find a new monster */
3597 i = target_pick(temp_y[m], temp_x[m], ddy[d], ddx[d]);
3599 /* Request to target past last interesting grid */
3600 while (flag && (i < 0))
3602 /* Note the change */
3603 if (change_panel(ddy[d], ddx[d]))
3608 /* Recalculate interesting grids */
3609 target_set_prepare(mode);
3611 /* Look at interesting grids */
3614 /* Find a new monster */
3615 i = target_pick(v, u, ddy[d], ddx[d]);
3621 /* Nothing interesting */
3627 /* Restore previous position */
3630 panel_bounds_center();
3632 p_ptr->update |= (PU_MONSTERS);
3634 p_ptr->redraw |= (PR_MAP);
3636 p_ptr->window |= (PW_OVERHEAD);
3639 /* Recalculate interesting grids */
3640 target_set_prepare(mode);
3642 /* Look at boring grids */
3649 /* Do not move horizontally if unnecessary */
3650 if (((x < panel_col_min + wid / 2) && (dx > 0)) ||
3651 ((x > panel_col_min + wid / 2) && (dx < 0)))
3656 /* Do not move vertically if unnecessary */
3657 if (((y < panel_row_min + hgt / 2) && (dy > 0)) ||
3658 ((y > panel_row_min + hgt / 2) && (dy < 0)))
3663 /* Apply the motion */
3664 if ((y >= panel_row_min+hgt) || (y < panel_row_min) ||
3665 (x >= panel_col_min+wid) || (x < panel_col_min))
3667 if (change_panel(dy, dx)) target_set_prepare(mode);
3670 /* Slide into legality */
3671 if (x >= cur_wid-1) x = cur_wid - 2;
3672 else if (x <= 0) x = 1;
3674 /* Slide into legality */
3675 if (y >= cur_hgt-1) y = cur_hgt- 2;
3676 else if (y <= 0) y = 1;
3685 /* Arbitrary grids */
3688 bool move_fast = FALSE;
3690 if (!(mode & TARGET_LOOK)) prt_path(y, x);
3693 c_ptr = &cave[y][x];
3695 /* Default prompt */
3696 strcpy(info, _("q止 t決 p自 m近 +次 -前", "q,t,p,m,+,-,<dir>"));
3701 sprintf(cheatinfo, " LOS:%d, PROJECTABLE:%d",
3702 los(p_ptr->y, p_ptr->x, y, x),
3703 projectable(p_ptr->y, p_ptr->x, y, x));
3704 strcat(info, cheatinfo);
3707 /* Describe and Prompt (enable "TARGET_LOOK") */
3708 while ((query = target_set_aux(y, x, mode | TARGET_LOOK, info)) == 0);
3710 /* Cancel tracking */
3711 /* health_track(0); */
3713 /* Assume no direction */
3718 if (query == '\r') query = 't';
3721 /* Analyze the keypress */
3745 /* Recenter the map around the player */
3748 p_ptr->update |= (PU_MONSTERS);
3750 p_ptr->redraw |= (PR_MAP);
3752 p_ptr->window |= (PW_OVERHEAD);
3755 /* Recalculate interesting grids */
3756 target_set_prepare(mode);
3778 /* Pick a nearby monster */
3779 for (i = 0; i < temp_n; i++)
3781 t = distance(y, x, temp_y[i], temp_x[i]);
3791 /* Nothing interesting */
3792 if (bd == 999) flag = FALSE;
3799 /* Extract the action (if any) */
3800 d = get_keymap_dir(query);
3802 /* XTRA HACK MOVEFAST */
3803 if (isupper(query)) move_fast = TRUE;
3810 /* Handle "direction" */
3816 /* XTRA HACK MOVEFAST */
3819 int mag = MIN(wid / 2, hgt / 2);
3829 /* Do not move horizontally if unnecessary */
3830 if (((x < panel_col_min + wid / 2) && (dx > 0)) ||
3831 ((x > panel_col_min + wid / 2) && (dx < 0)))
3836 /* Do not move vertically if unnecessary */
3837 if (((y < panel_row_min + hgt / 2) && (dy > 0)) ||
3838 ((y > panel_row_min + hgt / 2) && (dy < 0)))
3843 /* Apply the motion */
3844 if ((y >= panel_row_min + hgt) || (y < panel_row_min) ||
3845 (x >= panel_col_min + wid) || (x < panel_col_min))
3847 if (change_panel(dy, dx)) target_set_prepare(mode);
3850 /* Slide into legality */
3851 if (x >= cur_wid-1) x = cur_wid - 2;
3852 else if (x <= 0) x = 1;
3854 /* Slide into legality */
3855 if (y >= cur_hgt-1) y = cur_hgt- 2;
3856 else if (y <= 0) y = 1;
3864 /* Clear the top line */
3867 /* Recenter the map around the player */
3870 p_ptr->update |= (PU_MONSTERS);
3872 p_ptr->redraw |= (PR_MAP);
3874 p_ptr->window |= (PW_OVERHEAD);
3877 /* Failure to set target */
3878 if (!target_who) return (FALSE);
3886 * Get an "aiming direction" from the user.
3888 * The "dir" is loaded with 1,2,3,4,6,7,8,9 for "actual direction", and
3889 * "0" for "current target", and "-1" for "entry aborted".
3891 * Note that "Force Target", if set, will pre-empt user interaction,
3892 * if there is a usable target already set.
3894 * Note that confusion over-rides any (explicit?) user choice.
3896 bool get_aim_dir(DIRECTION *dp)
3905 /* Global direction */
3908 /* Hack -- auto-target if requested */
3909 if (use_old_target && target_okay()) dir = 5;
3911 if (repeat_pull(&code))
3916 if (!(code == 5 && !target_okay()))
3918 /* return (TRUE); */
3919 dir = (DIRECTION)code;
3922 *dp = (DIRECTION)code;
3924 /* Ask until satisfied */
3927 /* Choose a prompt */
3930 p = _("方向 ('*'でターゲット選択, ESCで中断)? ", "Direction ('*' to choose a target, Escape to cancel)? ");
3934 p = _("方向 ('5'でターゲットへ, '*'でターゲット再選択, ESCで中断)? ", "Direction ('5' for target, '*' to re-target, Escape to cancel)? ");
3937 /* Get a command (or Cancel) */
3938 if (!get_com(p, &command, TRUE)) break;
3942 if (command == '\r') command = 't';
3945 /* Convert various keys to "standard" keys */
3948 /* Use current target */
3959 /* Set new target */
3964 if (target_set(TARGET_KILL)) dir = 5;
3970 /* Extract the action (if any) */
3971 dir = get_keymap_dir(command);
3977 /* Verify requested targets */
3978 if ((dir == 5) && !target_okay()) dir = 0;
3987 project_length = 0; /* reset to default */
3991 /* Save the direction */
3994 /* Check for confusion */
3995 if (p_ptr->confused)
3997 /* Random direction */
3998 dir = ddd[randint0(8)];
4001 /* Notice confusion */
4002 if (command_dir != dir)
4005 msg_print(_("あなたは混乱している。", "You are confused."));
4008 /* Save direction */
4011 /* repeat_push(dir); */
4012 repeat_push((COMMAND_CODE)command_dir);
4014 /* A "valid" direction was entered */
4019 bool get_direction(DIRECTION *dp, bool allow_under, bool with_steed)
4027 /* Global direction */
4030 if (repeat_pull(&code))
4032 dir = (DIRECTION)code;
4033 /* return (TRUE); */
4035 *dp = (DIRECTION)code;
4039 prompt = _("方向 ('.'足元, ESCで中断)? ", "Direction ('.' at feet, Escape to cancel)? ");
4043 prompt = _("方向 (ESCで中断)? ", "Direction (Escape to cancel)? ");
4046 /* Get a direction */
4051 /* Get a command (or Cancel) */
4052 if (!get_com(prompt, &ch, TRUE)) break;
4055 if ((allow_under) && ((ch == '5') || (ch == '-') || (ch == '.')))
4061 /* Look up the direction */
4062 dir = get_keymap_dir(ch);
4068 /* Prevent weirdness */
4069 if ((dir == 5) && (!allow_under)) dir = 0;
4072 if (!dir) return (FALSE);
4074 /* Save desired direction */
4077 /* Apply "confusion" */
4078 if (p_ptr->confused)
4080 /* Standard confusion */
4081 if (randint0(100) < 75)
4083 /* Random direction */
4084 dir = ddd[randint0(8)];
4087 else if (p_ptr->riding && with_steed)
4089 monster_type *m_ptr = &m_list[p_ptr->riding];
4090 monster_race *r_ptr = &r_info[m_ptr->r_idx];
4092 if (MON_CONFUSED(m_ptr))
4094 /* Standard confusion */
4095 if (randint0(100) < 75)
4097 /* Random direction */
4098 dir = ddd[randint0(8)];
4101 else if ((r_ptr->flags1 & RF1_RAND_50) && (r_ptr->flags1 & RF1_RAND_25) && (randint0(100) < 50))
4103 /* Random direction */
4104 dir = ddd[randint0(8)];
4106 else if ((r_ptr->flags1 & RF1_RAND_50) && (randint0(100) < 25))
4108 /* Random direction */
4109 dir = ddd[randint0(8)];
4113 /* Notice confusion */
4114 if (command_dir != dir)
4116 if (p_ptr->confused)
4119 msg_print(_("あなたは混乱している。", "You are confused."));
4124 monster_type *m_ptr = &m_list[p_ptr->riding];
4126 monster_desc(m_name, m_ptr, 0);
4127 if (MON_CONFUSED(m_ptr))
4129 msg_format(_("%sは混乱している。", "%^s is confusing."), m_name);
4133 msg_format(_("%sは思い通りに動いてくれない。", "You cannot control %s."), m_name);
4138 /* Save direction */
4141 /* repeat_push(dir); */
4142 repeat_push((COMMAND_CODE)command_dir);
4149 * @brief 進行方向を指定する(騎乗対象の混乱の影響を受ける) / Request a "movement" direction (1,2,3,4,6,7,8,9) from the user,
4150 * and place it into "command_dir", unless we already have one.
4152 * This function should be used for all "repeatable" commands, such as
4153 * run, walk, open, close, bash, disarm, spike, tunnel, etc, as well
4154 * as all commands which must reference a grid adjacent to the player,
4155 * and which may not reference the grid under the player. Note that,
4156 * for example, it is no longer possible to "disarm" or "open" chests
4157 * in the same grid as the player.
4159 * Direction "5" is illegal and will (cleanly) abort the command.
4161 * This function tracks and uses the "global direction", and uses
4162 * that as the "desired direction", to which "confusion" is applied.
4164 bool get_rep_dir(DIRECTION *dp, bool under)
4172 /* Global direction */
4175 if (repeat_pull(&code))
4177 dir = (DIRECTION)code;
4178 /* return (TRUE); */
4180 *dp = (DIRECTION)code;
4184 prompt = _("方向 ('.'足元, ESCで中断)? ", "Direction ('.' at feet, Escape to cancel)? ");
4188 prompt = _("方向 (ESCで中断)? ", "Direction (Escape to cancel)? ");
4191 /* Get a direction */
4196 /* Get a command (or Cancel) */
4197 if (!get_com(prompt, &ch, TRUE)) break;
4200 if ((under) && ((ch == '5') || (ch == '-') || (ch == '.')))
4206 /* Look up the direction */
4207 dir = get_keymap_dir(ch);
4213 /* Prevent weirdness */
4214 if ((dir == 5) && (!under)) dir = 0;
4217 if (!dir) return (FALSE);
4219 /* Save desired direction */
4222 /* Apply "confusion" */
4223 if (p_ptr->confused)
4225 /* Standard confusion */
4226 if (randint0(100) < 75)
4228 /* Random direction */
4229 dir = ddd[randint0(8)];
4232 else if (p_ptr->riding)
4234 monster_type *m_ptr = &m_list[p_ptr->riding];
4235 monster_race *r_ptr = &r_info[m_ptr->r_idx];
4237 if (MON_CONFUSED(m_ptr))
4239 /* Standard confusion */
4240 if (randint0(100) < 75)
4242 /* Random direction */
4243 dir = ddd[randint0(8)];
4246 else if ((r_ptr->flags1 & RF1_RAND_50) && (r_ptr->flags1 & RF1_RAND_25) && (randint0(100) < 50))
4248 /* Random direction */
4249 dir = ddd[randint0(8)];
4251 else if ((r_ptr->flags1 & RF1_RAND_50) && (randint0(100) < 25))
4253 /* Random direction */
4254 dir = ddd[randint0(8)];
4258 /* Notice confusion */
4259 if (command_dir != dir)
4261 if (p_ptr->confused)
4264 msg_print(_("あなたは混乱している。", "You are confused."));
4269 monster_type *m_ptr = &m_list[p_ptr->riding];
4271 monster_desc(m_name, m_ptr, 0);
4272 if (MON_CONFUSED(m_ptr))
4274 msg_format(_("%sは混乱している。", "%^s is confusing."), m_name);
4278 msg_format(_("%sは思い通りに動いてくれない。", "You cannot control %s."), m_name);
4283 /* Save direction */
4286 /* repeat_push(dir); */
4287 repeat_push((COMMAND_CODE)command_dir);
4293 void gain_level_reward(int chosen_reward)
4297 char wrath_reason[32] = "";
4298 int nasty_chance = 6;
4299 OBJECT_TYPE_VALUE dummy = 0;
4300 OBJECT_SUBTYPE_VALUE dummy2 = 0;
4303 char o_name[MAX_NLEN];
4309 if (multi_rew) return;
4310 else multi_rew = TRUE;
4314 if (p_ptr->lev == 13) nasty_chance = 2;
4315 else if (!(p_ptr->lev % 13)) nasty_chance = 3;
4316 else if (!(p_ptr->lev % 14)) nasty_chance = 12;
4318 if (one_in_(nasty_chance))
4319 type = randint1(20); /* Allow the 'nasty' effects */
4321 type = randint1(15) + 5; /* Or disallow them */
4323 if (type < 1) type = 1;
4324 if (type > 20) type = 20;
4328 sprintf(wrath_reason, _("%sの怒り", "the Wrath of %s"), chaos_patrons[p_ptr->chaos_patron]);
4330 effect = chaos_rewards[p_ptr->chaos_patron][type];
4332 if (one_in_(6) && !chosen_reward)
4334 msg_format(_("%^sは褒美としてあなたを突然変異させた。", "%^s rewards you with a mutation!"), chaos_patrons[p_ptr->chaos_patron]);
4335 (void)gain_random_mutation(0);
4336 reward = _("変異した。", "mutation");
4340 switch (chosen_reward ? chosen_reward : effect)
4345 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4346 msg_print(_("「汝、新たなる姿を必要とせり!」", "'Thou needst a new form, mortal!'"));
4349 reward = _("変異した。", "polymorphing");
4354 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4355 msg_print(_("「汝は良く行いたり!続けよ!」", "'Well done, mortal! Lead on!'"));
4357 if (p_ptr->prace == RACE_ANDROID)
4359 msg_print(_("しかし何も起こらなかった。", "But, nothing happen."));
4361 else if (p_ptr->exp < PY_MAX_EXP)
4363 s32b ee = (p_ptr->exp / 2) + 10;
4364 if (ee > 100000L) ee = 100000L;
4365 msg_print(_("更に経験を積んだような気がする。", "You feel more experienced."));
4368 reward = _("経験値を得た", "experience");
4374 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4375 msg_print(_("「下僕よ、汝それに値せず。」", "'Thou didst not deserve that, slave.'"));
4377 if (p_ptr->prace == RACE_ANDROID)
4379 msg_print(_("しかし何も起こらなかった。", "But, nothing happen."));
4383 lose_exp(p_ptr->exp / 6);
4384 reward = _("経験値を失った。", "losing experience");
4390 msg_format("%sの声がささやいた:",
4391 chaos_patrons[p_ptr->chaos_patron]);
4393 msg_format("The voice of %s whispers:",
4394 chaos_patrons[p_ptr->chaos_patron]);
4397 msg_print(_("「我が与えし物を賢明に使うべし。」", "'Use my gift wisely.'"));
4399 acquirement(p_ptr->y, p_ptr->x, 1, FALSE, FALSE, FALSE);
4400 reward = _("上質なアイテムを手に入れた。", "a good item");
4405 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4406 msg_print(_("「我が与えし物を賢明に使うべし。」", "'Use my gift wisely.'"));
4408 acquirement(p_ptr->y, p_ptr->x, 1, TRUE, FALSE, FALSE);
4409 reward = _("高級品のアイテムを手に入れた。", "an excellent item");
4414 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4415 msg_print(_("「汝の行いは貴き剣に値せり。」", "'Thy deed hath earned thee a worthy blade.'"));
4418 switch (randint1(p_ptr->lev))
4424 dummy2 = SV_MAIN_GAUCHE;
4433 dummy2 = SV_SMALL_SWORD;
4436 dummy2 = SV_BASILLARD;
4438 case 11: case 12: case 13:
4439 dummy2 = SV_SHORT_SWORD;
4445 dummy2 = SV_CUTLASS;
4448 dummy2 = SV_WAKIZASHI;
4451 dummy2 = SV_KHOPESH;
4457 dummy2 = SV_BROAD_SWORD;
4460 dummy2 = SV_LONG_SWORD;
4463 dummy2 = SV_SCIMITAR;
4466 dummy2 = SV_NINJATO;
4472 dummy2 = SV_BASTARD_SWORD;
4475 dummy2 = SV_GREAT_SCIMITAR;
4478 dummy2 = SV_CLAYMORE;
4481 dummy2 = SV_ESPADON;
4484 dummy2 = SV_TWO_HANDED_SWORD;
4487 dummy2 = SV_FLAMBERGE;
4490 dummy2 = SV_NO_DACHI;
4493 dummy2 = SV_EXECUTIONERS_SWORD;
4496 dummy2 = SV_ZWEIHANDER;
4499 dummy2 = SV_HAYABUSA;
4502 dummy2 = SV_BLADE_OF_CHAOS;
4505 object_prep(q_ptr, lookup_kind(dummy, dummy2));
4506 q_ptr->to_h = 3 + randint1(dun_level) % 10;
4507 q_ptr->to_d = 3 + randint1(dun_level) % 10;
4508 one_resistance(q_ptr);
4509 q_ptr->name2 = EGO_CHAOTIC;
4511 /* Drop it in the dungeon */
4512 (void)drop_near(q_ptr, -1, p_ptr->y, p_ptr->x);
4513 reward = _("(混沌)の武器を手に入れた。", "chaos weapon");
4518 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4519 msg_print(_("「汝の行いは貴き報いに値せり。」", "'Thy deed hath earned thee a worthy reward.'"));
4521 acquirement(p_ptr->y, p_ptr->x, randint1(2) + 1, FALSE, FALSE, FALSE);
4522 reward = _("上質なアイテムを手に入れた。", "good items");
4527 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4528 msg_print(_("「下僕よ、汝の献身への我が惜しみ無き報いを見るがよい。」", "'Behold, mortal, how generously I reward thy loyalty.'"));
4530 acquirement(p_ptr->y, p_ptr->x, randint1(2) + 1, TRUE, FALSE, FALSE);
4531 reward = _("高級品のアイテムを手に入れた。", "excellent items");
4536 msg_format("%sの声が轟き渡った:", chaos_patrons[p_ptr->chaos_patron]);
4538 msg_format("The voice of %s thunders:", chaos_patrons[p_ptr->chaos_patron]);
4541 msg_print(_("「下僕よ、汝傲慢なり。」", "'Thou art growing arrogant, mortal.'"));
4543 (void)activate_ty_curse(FALSE, &count);
4544 reward = _("禍々しい呪いをかけられた。", "cursing");
4549 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4550 msg_print(_("「我が下僕たちよ、かの傲慢なる者を倒すべし!」", "'My pets, destroy the arrogant mortal!'"));
4552 for (dummy = 0; dummy < randint1(5) + 1; dummy++)
4554 (void)summon_specific(0, p_ptr->y, p_ptr->x, dun_level, 0, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET));
4556 reward = _("モンスターを召喚された。", "summoning hostile monsters");
4562 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4563 msg_print(_("「汝、より強き敵を必要とせり!」", "'Thou needst worthier opponents!'"));
4565 activate_hi_summon(p_ptr->y, p_ptr->x, FALSE);
4566 reward = _("モンスターを召喚された。", "summoning many hostile monsters");
4572 msg_format("%sの声が響き渡った:",
4573 chaos_patrons[p_ptr->chaos_patron]);
4575 msg_format("The voice of %s booms out:",
4576 chaos_patrons[p_ptr->chaos_patron]);
4579 msg_print(_("「死と破壊こそ我が喜びなり!」", "'Death and destruction! This pleaseth me!'"));
4582 reward = _("カオスの力が渦巻いた。", "calling chaos");
4588 msg_format("%sの声が鳴り響いた:",
4589 chaos_patrons[p_ptr->chaos_patron]);
4591 msg_format("The voice of %s rings out:",
4592 chaos_patrons[p_ptr->chaos_patron]);
4595 msg_print(_("「留まるのだ、下僕よ。余が汝の肉体を鍛えん。」", "'Stay, mortal, and let me mold thee.'"));
4597 if (one_in_(3) && !(chaos_stats[p_ptr->chaos_patron] < 0))
4598 do_inc_stat(chaos_stats[p_ptr->chaos_patron]);
4600 do_inc_stat(randint0(6));
4601 reward = _("能力値が上がった。", "increasing a stat");
4607 msg_format("%sの声が響き渡った:",
4608 chaos_patrons[p_ptr->chaos_patron]);
4610 msg_format("The voice of %s booms out:",
4611 chaos_patrons[p_ptr->chaos_patron]);
4614 msg_print(_("「下僕よ、余は汝に飽みたり。」", "'I grow tired of thee, mortal.'"));
4616 if (one_in_(3) && !(chaos_stats[p_ptr->chaos_patron] < 0))
4617 do_dec_stat(chaos_stats[p_ptr->chaos_patron]);
4619 (void)do_dec_stat(randint0(6));
4620 reward = _("能力値が下がった。", "decreasing a stat");
4627 msg_format("%sの声が轟き渡った:",
4628 chaos_patrons[p_ptr->chaos_patron]);
4630 msg_format("The voice of %s thunders:",
4631 chaos_patrons[p_ptr->chaos_patron]);
4634 msg_print(_("「汝、謙虚たることを学ぶべし!」", "'Thou needst a lesson in humility, mortal!'"));
4635 msg_print(_("あなたは以前より弱くなった!", "You feel less powerful!"));
4637 for (dummy = 0; dummy < 6; dummy++)
4639 (void)dec_stat(dummy, 10 + randint1(15), TRUE);
4641 reward = _("全能力値が下がった。", "decreasing all stats");
4646 msg_format(_("%sの力が触れるのを感じた。", "You feel the power of %s touch you."),
4647 chaos_patrons[p_ptr->chaos_patron]);
4649 reward = _("傷が変化した。", "polymorphing wounds");
4654 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4656 msg_print(_("「我がささやかなる賜物を受けとるがよい!」", "'Receive this modest gift from me!'"));
4658 for (dummy = 0; dummy < 6; dummy++)
4660 (void)do_inc_stat(dummy);
4662 reward = _("全能力値が上がった。", "increasing all stats");
4667 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4668 msg_print(_("「苦しむがよい、無能な愚か者よ!」", "'Suffer, pathetic fool!'"));
4670 fire_ball(GF_DISINTEGRATE, 0, p_ptr->lev * 4, 4);
4671 take_hit(DAMAGE_NOESCAPE, p_ptr->lev * 4, wrath_reason, -1);
4672 reward = _("分解の球が発生した。", "generating disintegration ball");
4677 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4678 (void)restore_level();
4679 (void)restore_all_status();
4680 (void)true_healing(5000);
4681 reward = _("体力が回復した。", "healing");
4686 if (!buki_motteruka(INVEN_RARM) && !buki_motteruka(INVEN_LARM)) break;
4687 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4688 msg_print(_("「汝、武器に頼ることなかれ。」", "'Thou reliest too much on thy weapon.'"));
4691 if (buki_motteruka(INVEN_LARM))
4694 if (buki_motteruka(INVEN_RARM) && one_in_(2)) dummy = INVEN_RARM;
4696 object_desc(o_name, &inventory[dummy], OD_NAME_ONLY);
4697 (void)curse_weapon(FALSE, dummy);
4698 reward = format(_("%sが破壊された。", "destroying %s"), o_name);
4703 if (!inventory[INVEN_BODY].k_idx) break;
4704 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4705 msg_print(_("「汝、防具に頼ることなかれ。」", "'Thou reliest too much on thine equipment.'"));
4707 object_desc(o_name, &inventory[INVEN_BODY], OD_NAME_ONLY);
4708 (void)curse_armor();
4709 reward = format(_("%sが破壊された。", "destroying %s"), o_name);
4713 msg_format(_("%sの声がささやいた:", "The voice of %s whispers:"), chaos_patrons[p_ptr->chaos_patron]);
4714 msg_print(_("「我を怒りしめた罪を償うべし。」", "'Now thou shalt pay for annoying me.'"));
4716 switch (randint1(4))
4719 (void)activate_ty_curse(FALSE, &count);
4720 reward = _("禍々しい呪いをかけられた。", "cursing");
4723 activate_hi_summon(p_ptr->y, p_ptr->x, FALSE);
4724 reward = _("モンスターを召喚された。", "summoning hostile monsters");
4729 if (!buki_motteruka(INVEN_RARM) && !buki_motteruka(INVEN_LARM)) break;
4731 if (buki_motteruka(INVEN_LARM))
4734 if (buki_motteruka(INVEN_RARM) && one_in_(2)) dummy = INVEN_RARM;
4736 object_desc(o_name, &inventory[dummy], OD_NAME_ONLY);
4737 (void)curse_weapon(FALSE, dummy);
4738 reward = format(_("%sが破壊された。", "destroying %s"), o_name);
4742 if (!inventory[INVEN_BODY].k_idx) break;
4743 object_desc(o_name, &inventory[INVEN_BODY], OD_NAME_ONLY);
4744 (void)curse_armor();
4745 reward = format(_("%sが破壊された。", "destroying %s"), o_name);
4749 for (dummy = 0; dummy < 6; dummy++)
4751 (void)dec_stat(dummy, 10 + randint1(15), TRUE);
4753 reward = _("全能力値が下がった。", "decreasing all stats");
4760 msg_format(_("%sの声が轟き渡った:", "The voice of %s thunders:"), chaos_patrons[p_ptr->chaos_patron]);
4761 msg_print(_("「死ぬがよい、下僕よ!」", "'Die, mortal!'"));
4763 take_hit(DAMAGE_LOSELIFE, p_ptr->lev * 4, wrath_reason, -1);
4764 for (dummy = 0; dummy < 6; dummy++)
4766 (void)dec_stat(dummy, 10 + randint1(15), FALSE);
4768 activate_hi_summon(p_ptr->y, p_ptr->x, FALSE);
4769 (void)activate_ty_curse(FALSE, &count);
4774 if (buki_motteruka(INVEN_RARM))
4777 if (buki_motteruka(INVEN_LARM) && one_in_(2)) dummy = INVEN_LARM;
4779 else if (buki_motteruka(INVEN_LARM)) dummy = INVEN_LARM;
4781 if (dummy) (void)curse_weapon(FALSE, dummy);
4783 if (one_in_(2)) (void)curse_armor();
4788 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4789 msg_print(_("「死と破壊こそ我が喜びなり!」", "'Death and destruction! This pleaseth me!'"));
4791 (void)destroy_area(p_ptr->y, p_ptr->x, 25, FALSE);
4792 reward = _("ダンジョンが*破壊*された。", "*destruct*ing dungeon");
4797 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4798 msg_print(_("「我、汝の敵を抹殺せん!」", "'Let me relieve thee of thine oppressors!'"));
4799 (void)symbol_genocide(0, FALSE);
4800 reward = _("モンスターが抹殺された。", "genociding monsters");
4805 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4806 msg_print(_("「我、汝の敵を抹殺せん!」", "'Let me relieve thee of thine oppressors!'"));
4808 (void)mass_genocide(0, FALSE);
4809 reward = _("モンスターが抹殺された。", "genociding nearby monsters");
4814 msg_format(_("%sの力が敵を攻撃するのを感じた!", "You can feel the power of %s assault your enemies!"), chaos_patrons[p_ptr->chaos_patron]);
4815 (void)dispel_monsters(p_ptr->lev * 4);
4820 msg_format(_("%sはあなたを無視した。", "%s ignores you."), chaos_patrons[p_ptr->chaos_patron]);
4825 msg_format(_("%sは褒美として悪魔の使いをよこした!", "%s rewards you with a demonic servant!"),chaos_patrons[p_ptr->chaos_patron]);
4827 if (!summon_specific(-1, p_ptr->y, p_ptr->x, dun_level, SUMMON_DEMON, PM_FORCE_PET))
4828 msg_print(_("何も現れなかった...", "Nobody ever turns up..."));
4830 reward = _("悪魔がペットになった。", "a demonic servant");
4835 msg_format(_("%sは褒美として使いをよこした!", "%s rewards you with a servant!"),chaos_patrons[p_ptr->chaos_patron]);
4837 if (!summon_specific(-1, p_ptr->y, p_ptr->x, dun_level, 0, PM_FORCE_PET))
4838 msg_print(_("何も現れなかった...", "Nobody ever turns up..."));
4840 reward = _("モンスターがペットになった。", "a servant");
4845 msg_format(_("%sは褒美としてアンデッドの使いをよこした。", "%s rewards you with an undead servant!"),chaos_patrons[p_ptr->chaos_patron]);
4847 if (!summon_specific(-1, p_ptr->y, p_ptr->x, dun_level, SUMMON_UNDEAD, PM_FORCE_PET))
4848 msg_print(_("何も現れなかった...", "Nobody ever turns up..."));
4850 reward = _("アンデッドがペットになった。", "an undead servant");
4855 msg_format(_("%sの声がどもった:", "The voice of %s stammers:"),
4857 chaos_patrons[p_ptr->chaos_patron]);
4858 msg_format(_("「あー、あー、答えは %d/%d。質問は何?」", "'Uh... uh... the answer's %d/%d, what's the question?'"), type, effect);
4864 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, format(_("パトロンの報酬で%s", "The patron rewards you with %s."), reward));
4870 * XAngband: determine if a given location is "interesting"
4871 * based on target_set_accept function.
4873 static bool tgt_pt_accept(POSITION y, POSITION x)
4878 if (!(in_bounds(y, x))) return (FALSE);
4880 /* Player grid is always interesting */
4881 if ((y == p_ptr->y) && (x == p_ptr->x)) return (TRUE);
4883 /* Handle hallucination */
4884 if (p_ptr->image) return (FALSE);
4886 /* Examine the grid */
4887 c_ptr = &cave[y][x];
4889 /* Interesting memorized features */
4890 if (c_ptr->info & (CAVE_MARK))
4893 if (cave_have_flag_grid(c_ptr, FF_LESS)) return (TRUE);
4894 if (cave_have_flag_grid(c_ptr, FF_MORE)) return (TRUE);
4896 /* Notice quest features */
4897 if (cave_have_flag_grid(c_ptr, FF_QUEST_ENTER)) return (TRUE);
4898 if (cave_have_flag_grid(c_ptr, FF_QUEST_EXIT)) return (TRUE);
4906 * XAngband: Prepare the "temp" array for "tget_pt"
4907 * based on target_set_prepare funciton.
4909 static void tgt_pt_prepare(void)
4913 /* Reset "temp" array */
4916 if (!expand_list) return;
4918 /* Scan the current panel */
4919 for (y = 1; y < cur_hgt; y++)
4921 for (x = 1; x < cur_wid; x++)
4923 /* Require "interesting" contents */
4924 if (!tgt_pt_accept(y, x)) continue;
4926 /* Save the location */
4933 /* Target the nearest monster for shooting */
4934 ang_sort_comp = ang_sort_comp_distance;
4935 ang_sort_swap = ang_sort_swap_distance;
4937 /* Sort the positions */
4938 ang_sort(temp_x, temp_y, temp_n);
4942 * old -- from PsiAngband.
4944 bool tgt_pt(POSITION *x_ptr, POSITION *y_ptr)
4949 bool success = FALSE;
4953 get_screen_size(&wid, &hgt);
4963 msg_print(_("場所を選んでスペースキーを押して下さい。", "Select a point and press space."));
4964 msg_flag = FALSE; /* prevents "-more-" message. */
4966 while ((ch != ESCAPE) && !success)
4968 bool move_fast = FALSE;
4970 move_cursor_relative(y, x);
4982 if (player_bold(y, x)) ch = 0;
4985 else success = TRUE;
4989 /* XAngband: Move cursor to stairs */
4992 if (expand_list && temp_n)
4995 int cx = (panel_col_min + panel_col_max) / 2;
4996 int cy = (panel_row_min + panel_row_max) / 2;
5000 /* Skip stairs which have defferent distance */
5001 for (; n < temp_n; ++ n)
5003 cave_type *c_ptr = &cave[temp_y[n]][temp_x[n]];
5005 if (cave_have_flag_grid(c_ptr, FF_STAIRS) &&
5006 cave_have_flag_grid(c_ptr, ch == '>' ? FF_MORE : FF_LESS))
5013 if (n == temp_n) /* Loop out taget list */
5018 verify_panel(); /* Move cursor to player */
5020 p_ptr->update |= (PU_MONSTERS);
5022 p_ptr->redraw |= (PR_MAP);
5024 p_ptr->window |= (PW_OVERHEAD);
5027 else /* move cursor to next stair and change panel */
5032 dy = 2 * (y - cy) / hgt;
5033 dx = 2 * (x - cx) / wid;
5034 if (dy || dx) change_panel(dy, dx);
5040 /* Look up the direction */
5041 d = get_keymap_dir(ch);
5043 /* XTRA HACK MOVEFAST */
5044 if (isupper(ch)) move_fast = TRUE;
5046 /* Handle "direction" */
5052 /* XTRA HACK MOVEFAST */
5055 int mag = MIN(wid / 2, hgt / 2);
5065 /* Do not move horizontally if unnecessary */
5066 if (((x < panel_col_min + wid / 2) && (dx > 0)) ||
5067 ((x > panel_col_min + wid / 2) && (dx < 0)))
5072 /* Do not move vertically if unnecessary */
5073 if (((y < panel_row_min + hgt / 2) && (dy > 0)) ||
5074 ((y > panel_row_min + hgt / 2) && (dy < 0)))
5079 /* Apply the motion */
5080 if ((y >= panel_row_min + hgt) || (y < panel_row_min) ||
5081 (x >= panel_col_min + wid) || (x < panel_col_min))
5083 /* if (change_panel(dy, dx)) target_set_prepare(mode); */
5084 change_panel(dy, dx);
5087 /* Slide into legality */
5088 if (x >= cur_wid-1) x = cur_wid - 2;
5089 else if (x <= 0) x = 1;
5091 /* Slide into legality */
5092 if (y >= cur_hgt-1) y = cur_hgt- 2;
5093 else if (y <= 0) y = 1;
5100 /* Clear the top line */
5103 /* Recenter the map around the player */
5106 p_ptr->update |= (PU_MONSTERS);
5108 p_ptr->redraw |= (PR_MAP);
5110 p_ptr->window |= (PW_OVERHEAD);
5119 bool get_hack_dir(DIRECTION *dp)
5127 /* Global direction */
5130 /* (No auto-targeting) */
5132 /* Ask until satisfied */
5135 /* Choose a prompt */
5138 p = _("方向 ('*'でターゲット選択, ESCで中断)? ", "Direction ('*' to choose a target, Escape to cancel)? ");
5142 p = _("方向 ('5'でターゲットへ, '*'でターゲット再選択, ESCで中断)? ", "Direction ('5' for target, '*' to re-target, Escape to cancel)? ");
5145 /* Get a command (or Cancel) */
5146 if (!get_com(p, &command, TRUE)) break;
5150 if (command == '\r') command = 't';
5153 /* Convert various keys to "standard" keys */
5156 /* Use current target */
5167 /* Set new target */
5172 if (target_set(TARGET_KILL)) dir = 5;
5178 /* Look up the direction */
5179 dir = get_keymap_dir(command);
5185 /* Verify requested targets */
5186 if ((dir == 5) && !target_okay()) dir = 0;
5193 if (!dir) return (FALSE);
5195 /* Save the direction */
5198 /* Check for confusion */
5199 if (p_ptr->confused)
5201 /* Random direction */
5202 dir = ddd[randint0(8)];
5205 /* Notice confusion */
5206 if (command_dir != dir)
5209 msg_print(_("あなたは混乱している。", "You are confused."));
5212 /* Save direction */
5215 /* A "valid" direction was entered */
5221 * エネルギーの増加量10d5を速く計算するための関数
5224 #define Go_no_JuuJou 5*5*5*5*5*5*5*5*5*5
5226 s16b gain_energy(void)
5229 s32b energy_result = 10;
5232 tmp = randint0(Go_no_JuuJou);
5234 for (i = 0; i < 9; i ++){
5235 energy_result += tmp % 5;
5239 return (s16b)(energy_result + tmp);
5244 * @brief 射撃武器の攻撃に必要な基本消費エネルギーを返す/Return bow energy
5245 * @param sval 射撃武器のアイテム副分類ID
5246 * @return 消費する基本エネルギー
5248 ENERGY bow_energy(OBJECT_SUBTYPE_VALUE sval)
5250 ENERGY energy = 10000;
5252 /* Analyze the launcher */
5255 /* Sling and ammo */
5262 /* Short Bow and Arrow */
5269 /* Long Bow and Arrow */
5276 /* Bow of irresponsiblity and Arrow */
5283 /* Light Crossbow and Bolt */
5290 /* Heavy Crossbow and Bolt */
5305 int bow_tmul(OBJECT_SUBTYPE_VALUE sval)
5309 /* Analyze the launcher */
5312 /* Sling and ammo */
5319 /* Short Bow and Arrow */
5326 /* Long Bow and Arrow */
5333 /* Bow of irresponsiblity and Arrow */
5340 /* Light Crossbow and Bolt */
5347 /* Heavy Crossbow and Bolt */
5359 * Return alignment title
5361 cptr your_alignment(void)
5364 if (p_ptr->align > 150) return "大善";
5365 else if (p_ptr->align > 50) return "中善";
5366 else if (p_ptr->align > 10) return "小善";
5367 else if (p_ptr->align > -11) return "中立";
5368 else if (p_ptr->align > -51) return "小悪";
5369 else if (p_ptr->align > -151) return "中悪";
5372 if (p_ptr->align > 150) return "Lawful";
5373 else if (p_ptr->align > 50) return "Good";
5374 else if (p_ptr->align > 10) return "Neutral Good";
5375 else if (p_ptr->align > -11) return "Neutral";
5376 else if (p_ptr->align > -51) return "Neutral Evil";
5377 else if (p_ptr->align > -151) return "Evil";
5378 else return "Chaotic";
5384 * Return proficiency level of weapons and misc. skills (except riding)
5386 int weapon_exp_level(int weapon_exp)
5388 if (weapon_exp < WEAPON_EXP_BEGINNER) return EXP_LEVEL_UNSKILLED;
5389 else if (weapon_exp < WEAPON_EXP_SKILLED) return EXP_LEVEL_BEGINNER;
5390 else if (weapon_exp < WEAPON_EXP_EXPERT) return EXP_LEVEL_SKILLED;
5391 else if (weapon_exp < WEAPON_EXP_MASTER) return EXP_LEVEL_EXPERT;
5392 else return EXP_LEVEL_MASTER;
5397 * Return proficiency level of riding
5399 int riding_exp_level(int riding_exp)
5401 if (riding_exp < RIDING_EXP_BEGINNER) return EXP_LEVEL_UNSKILLED;
5402 else if (riding_exp < RIDING_EXP_SKILLED) return EXP_LEVEL_BEGINNER;
5403 else if (riding_exp < RIDING_EXP_EXPERT) return EXP_LEVEL_SKILLED;
5404 else if (riding_exp < RIDING_EXP_MASTER) return EXP_LEVEL_EXPERT;
5405 else return EXP_LEVEL_MASTER;
5410 * Return proficiency level of spells
5412 int spell_exp_level(int spell_exp)
5414 if (spell_exp < SPELL_EXP_BEGINNER) return EXP_LEVEL_UNSKILLED;
5415 else if (spell_exp < SPELL_EXP_SKILLED) return EXP_LEVEL_BEGINNER;
5416 else if (spell_exp < SPELL_EXP_EXPERT) return EXP_LEVEL_SKILLED;
5417 else if (spell_exp < SPELL_EXP_MASTER) return EXP_LEVEL_EXPERT;
5418 else return EXP_LEVEL_MASTER;
5423 * Display a rumor and apply its effects
5426 IDX rumor_num(char *zz, IDX max_idx)
5428 if (strcmp(zz, "*") == 0) return randint1(max_idx - 1);
5429 return (IDX)atoi(zz);
5432 cptr rumor_bind_name(char *base, cptr fullname)
5436 s = strstr(base, "{Name}");
5440 v = format("%s%s%s", base, fullname, (s + 6));
5450 void display_rumor(bool ex)
5458 if (randint0(3) == 0) section = 1;
5461 err = _(get_rnd_line_jonly("rumors_j.txt", section, Rumor, 10),
5462 get_rnd_line("rumors.txt", section, Rumor));
5463 if (err) strcpy(Rumor, _("嘘の噂もある。", "Some rumors are wrong."));
5467 if (strncmp(Rumor, "R:", 2) == 0)
5470 cptr rumor_msg = NULL;
5471 cptr rumor_eff_format = NULL;
5472 char fullname[1024] = "";
5474 if (tokenize(Rumor + 2, 3, zz, TOKENIZE_CHECKQUOTE) == 3)
5476 if (strcmp(zz[0], "ARTIFACT") == 0)
5480 object_type *q_ptr = &forge;
5481 artifact_type *a_ptr;
5485 a_idx = rumor_num(zz[1], max_a_idx);
5487 a_ptr = &a_info[a_idx];
5488 if (a_ptr->name) break;
5491 k_idx = lookup_kind(a_ptr->tval, a_ptr->sval);
5492 object_prep(q_ptr, k_idx);
5493 q_ptr->name1 = a_idx;
5494 q_ptr->ident = IDENT_STORE;
5495 object_desc(fullname, q_ptr, OD_NAME_ONLY);
5497 else if (strcmp(zz[0], "MONSTER") == 0)
5500 monster_race *r_ptr;
5504 r_idx = rumor_num(zz[1], max_r_idx);
5505 r_ptr = &r_info[r_idx];
5506 if (r_ptr->name) break;
5509 strcpy(fullname, r_name + r_ptr->name);
5511 /* Remember this monster */
5512 if (!r_ptr->r_sights)
5517 else if (strcmp(zz[0], "DUNGEON") == 0)
5520 dungeon_info_type *d_ptr;
5524 d_idx = rumor_num(zz[1], max_d_idx);
5525 d_ptr = &d_info[d_idx];
5526 if (d_ptr->name) break;
5529 strcpy(fullname, d_name + d_ptr->name);
5531 if (!max_dlv[d_idx])
5533 max_dlv[d_idx] = d_ptr->mindepth;
5534 rumor_eff_format = _("%sに帰還できるようになった。", "You can recall to %s.");
5537 else if (strcmp(zz[0], "TOWN") == 0)
5544 t_idx = rumor_num(zz[1], NO_TOWN);
5545 if (town[t_idx].name) break;
5548 strcpy(fullname, town[t_idx].name);
5550 visit = (1L << (t_idx - 1));
5551 if ((t_idx != SECRET_TOWN) && !(p_ptr->visit & visit))
5553 p_ptr->visit |= visit;
5554 rumor_eff_format = _("%sに行ったことがある気がする。", "You feel you have been to %s.");
5558 rumor_msg = rumor_bind_name(zz[2], fullname);
5559 msg_print(rumor_msg);
5560 if (rumor_eff_format)
5563 msg_format(rumor_eff_format, fullname);
5568 if (err) msg_print(_("この情報は間違っている。", "This information is wrong."));
5572 msg_format("%s", Rumor);