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(monster_race *r_ptr)
671 /* Some monsters get "destroyed" */
672 if (!monster_living(r_ptr))
676 for (i = 0; i < 4; i++)
678 if (r_ptr->blow[i].method == RBM_EXPLODE)
680 return _("は爆発して粉々になった。", " explodes into tiny shreds.");
683 return _("を倒した。", " is destroyed.");
686 /* Assume a default death */
687 return _("は死んだ。", " dies.");
692 * @brief モンスターが死亡した時の処理 /
693 * Handle the "death" of a monster.
694 * @param m_idx 死亡したモンスターのID
695 * @param drop_item TRUEならばモンスターのドロップ処理を行う
696 * @return 撃破されたモンスターの述語
699 * Disperse treasures centered at the monster location based on the
700 * various flags contained in the monster flags fields.
701 * Check for "Quest" completion when a quest monster is killed.
702 * Note that only the player can induce "monster_death()" on Uniques.
703 * Thus (for now) all Quest monsters should be Uniques.
704 * Note that monsters can now carry objects, and when a monster dies,
705 * it drops all of its objects, which may disappear in crowded rooms.
708 void monster_death(MONSTER_IDX m_idx, bool drop_item)
717 monster_type *m_ptr = &m_list[m_idx];
718 monster_race *r_ptr = &r_info[m_ptr->r_idx];
720 bool visible = ((m_ptr->ml && !p_ptr->image) || (r_ptr->flags1 & RF1_UNIQUE));
724 bool do_gold = (!(r_ptr->flags1 & RF1_ONLY_ITEM));
725 bool do_item = (!(r_ptr->flags1 & RF1_ONLY_GOLD));
726 bool cloned = (m_ptr->smart & SM_CLONED) ? TRUE : FALSE;
727 int force_coin = get_coin_type(m_ptr->r_idx);
732 bool drop_chosen_item = drop_item && !cloned && !p_ptr->inside_arena
733 && !p_ptr->inside_battle && !is_pet(m_ptr);
735 /* The caster is dead? */
736 if (world_monster && world_monster == m_idx) world_monster = 0;
738 /* Notice changes in view */
739 if (r_ptr->flags7 & (RF7_LITE_MASK | RF7_DARK_MASK))
741 /* Update some things */
742 p_ptr->update |= (PU_MON_LITE);
745 /* Get the location */
749 if (record_named_pet && is_pet(m_ptr) && m_ptr->nickname)
753 monster_desc(m_name, m_ptr, MD_INDEF_VISIBLE);
754 do_cmd_write_nikki(NIKKI_NAMED_PET, 3, m_name);
757 /* Let monsters explode! */
758 for (i = 0; i < 4; i++)
760 if (r_ptr->blow[i].method == RBM_EXPLODE)
762 BIT_FLAGS flg = PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL;
763 EFFECT_ID typ = mbe_info[r_ptr->blow[i].effect].explode_type;
764 DICE_NUMBER d_dice = r_ptr->blow[i].d_dice;
765 DICE_SID d_side = r_ptr->blow[i].d_side;
766 HIT_POINT damage = damroll(d_dice, d_side);
768 project(m_idx, 3, y, x, damage, typ, flg, -1);
773 if (m_ptr->mflag2 & MFLAG2_CHAMELEON)
775 choose_new_monster(m_idx, TRUE, MON_CHAMELEON);
776 r_ptr = &r_info[m_ptr->r_idx];
779 /* Check for quest completion */
780 check_quest_completion(m_ptr);
782 /* Handle the possibility of player vanquishing arena combatant -KMW- */
783 if (p_ptr->inside_arena && !is_pet(m_ptr))
785 p_ptr->exit_bldg = TRUE;
787 if (p_ptr->arena_number > MAX_ARENA_MONS)
789 msg_print(_("素晴らしい!君こそ真の勝利者だ。", "You are a Genuine Champion!"));
793 msg_print(_("勝利!チャンピオンへの道を進んでいる。", "Victorious! You're on your way to becoming Champion."));
796 if (arena_info[p_ptr->arena_number].tval)
800 /* Prepare to make a prize */
801 object_prep(q_ptr, lookup_kind(arena_info[p_ptr->arena_number].tval, arena_info[p_ptr->arena_number].sval));
802 apply_magic(q_ptr, object_level, AM_NO_FIXED_ART);
804 /* Drop it in the dungeon */
805 (void)drop_near(q_ptr, -1, y, x);
808 if (p_ptr->arena_number > MAX_ARENA_MONS) p_ptr->arena_number++;
809 p_ptr->arena_number++;
814 /* Extract monster name */
815 monster_desc(m_name, m_ptr, MD_IGNORE_HALLU | MD_ASSUME_VISIBLE | MD_INDEF_VISIBLE);
817 do_cmd_write_nikki(NIKKI_ARENA, p_ptr->arena_number, m_name);
821 if (m_idx == p_ptr->riding)
823 if (rakuba(-1, FALSE))
825 msg_print(_("地面に落とされた。", "You have fallen from your riding pet."));
829 /* Drop a dead corpse? */
830 if (one_in_(r_ptr->flags1 & RF1_UNIQUE ? 1 : 4) &&
831 (r_ptr->flags9 & (RF9_DROP_CORPSE | RF9_DROP_SKELETON)) &&
832 !(p_ptr->inside_arena || p_ptr->inside_battle || cloned || ((m_ptr->r_idx == today_mon) && is_pet(m_ptr))))
834 /* Assume skeleton */
838 * We cannot drop a skeleton? Note, if we are in this check,
839 * we *know* we can drop at least a corpse or a skeleton
841 if (!(r_ptr->flags9 & RF9_DROP_SKELETON))
843 else if ((r_ptr->flags9 & RF9_DROP_CORPSE) && (r_ptr->flags1 & RF1_UNIQUE))
846 /* Else, a corpse is more likely unless we did a "lot" of damage */
847 else if (r_ptr->flags9 & RF9_DROP_CORPSE)
849 /* Lots of damage in one blow */
850 if ((0 - ((m_ptr->maxhp) / 4)) > m_ptr->hp)
852 if (one_in_(5)) corpse = TRUE;
856 if (!one_in_(5)) corpse = TRUE;
861 /* Prepare to make an object */
862 object_prep(q_ptr, lookup_kind(TV_CORPSE, (corpse ? SV_CORPSE : SV_SKELETON)));
864 apply_magic(q_ptr, object_level, AM_NO_FIXED_ART);
866 q_ptr->pval = m_ptr->r_idx;
868 /* Drop it in the dungeon */
869 (void)drop_near(q_ptr, -1, y, x);
872 /* Drop objects being carried */
873 monster_drop_carried_objects(m_ptr);
875 if (r_ptr->flags1 & RF1_DROP_GOOD) mo_mode |= AM_GOOD;
876 if (r_ptr->flags1 & RF1_DROP_GREAT) mo_mode |= AM_GREAT;
878 switch (m_ptr->r_idx)
880 case MON_PINK_HORROR:
881 /* Pink horrors are replaced with 2 Blue horrors */
882 if (!(p_ptr->inside_arena || p_ptr->inside_battle))
886 for (i = 0; i < 2; i++)
889 bool pet = is_pet(m_ptr);
892 if (pet) mode |= PM_FORCE_PET;
894 if (summon_specific((pet ? -1 : m_idx), wy, wx, 100, SUMMON_BLUE_HORROR, mode))
896 if (player_can_see_bold(wy, wx))
902 msg_print(_("ピンク・ホラーは分裂した!", "The Pink horror divides!"));
906 case MON_BLOODLETTER:
907 /* Bloodletters of Khorne may drop a blade of chaos */
908 if (drop_chosen_item && (randint1(100) < 15))
912 /* Prepare to make a Blade of Chaos */
913 object_prep(q_ptr, lookup_kind(TV_SWORD, SV_BLADE_OF_CHAOS));
915 apply_magic(q_ptr, object_level, AM_NO_FIXED_ART | mo_mode);
917 /* Drop it in the dungeon */
918 (void)drop_near(q_ptr, -1, y, x);
923 if (drop_chosen_item && (dun_level > 9))
928 /* Activate restriction */
929 if ((dun_level > 49) && one_in_(5))
930 get_obj_num_hook = kind_is_good_book;
932 get_obj_num_hook = kind_is_book;
935 make_object(q_ptr, mo_mode);
937 /* Drop it in the dungeon */
938 (void)drop_near(q_ptr, -1, y, x);
944 * Mega^3-hack: killing a 'Warrior of the Dawn' is likely to
945 * spawn another in the fallen one's place!
947 if (!p_ptr->inside_arena && !p_ptr->inside_battle)
951 POSITION wy = y, wx = x;
953 bool pet = is_pet(m_ptr);
957 scatter(&wy, &wx, y, x, 20, 0);
959 while (!(in_bounds(wy, wx) && cave_empty_bold2(wy, wx)) && --attempts);
964 if (pet) mode |= PM_FORCE_PET;
966 if (summon_specific((pet ? -1 : m_idx), wy, wx, 100, SUMMON_DAWN, mode))
968 if (player_can_see_bold(wy, wx))
969 msg_print(_("新たな戦士が現れた!", "A new warrior steps forth!"));
977 /* One more ultra-hack: An Unmaker goes out with a big bang! */
979 BIT_FLAGS flg = PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL;
980 (void)project(m_idx, 6, y, x, 100, GF_CHAOS, flg, -1);
984 case MON_UNICORN_ORD:
987 /* Reward for "lazy" player */
988 if (p_ptr->pseikaku == SEIKAKU_NAMAKE)
990 ARTIFACT_IDX a_idx = 0;
991 artifact_type *a_ptr = NULL;
993 if (!drop_chosen_item) break;
1000 a_idx = ART_NAMAKE_HAMMER;
1003 a_idx = ART_NAMAKE_BOW;
1006 a_idx = ART_NAMAKE_ARMOR;
1010 a_ptr = &a_info[a_idx];
1012 while (a_ptr->cur_num);
1014 /* Create the artifact */
1015 if (create_named_art(a_idx, y, x))
1019 /* Hack -- Memorize location of artifact in saved floors */
1020 if (character_dungeon) a_ptr->floor_id = p_ptr->floor_id;
1022 else if (!preserve_mode) a_ptr->cur_num = 1;
1027 if (!drop_chosen_item) break;
1030 /* Mega-Hack -- Prepare to make "Grond" */
1031 object_prep(q_ptr, lookup_kind(TV_HAFTED, SV_GROND));
1033 /* Mega-Hack -- Mark this item as "Grond" */
1034 q_ptr->name1 = ART_GROND;
1036 /* Mega-Hack -- Actually create "Grond" */
1037 apply_magic(q_ptr, -1, AM_GOOD | AM_GREAT);
1039 /* Drop it in the dungeon */
1040 (void)drop_near(q_ptr, -1, y, x);
1043 /* Mega-Hack -- Prepare to make "Chaos" */
1044 object_prep(q_ptr, lookup_kind(TV_CROWN, SV_CHAOS));
1046 /* Mega-Hack -- Mark this item as "Chaos" */
1047 q_ptr->name1 = ART_CHAOS;
1049 /* Mega-Hack -- Actually create "Chaos" */
1050 apply_magic(q_ptr, -1, AM_GOOD | AM_GREAT);
1052 /* Drop it in the dungeon */
1053 (void)drop_near(q_ptr, -1, y, x);
1056 case MON_B_DEATH_SWORD:
1057 if (drop_chosen_item)
1061 /* Prepare to make a broken sword */
1062 object_prep(q_ptr, lookup_kind(TV_SWORD, randint1(2)));
1064 /* Drop it in the dungeon */
1065 (void)drop_near(q_ptr, -1, y, x);
1071 if (drop_chosen_item && ((m_ptr->r_idx == MON_A_GOLD) ||
1072 ((m_ptr->r_idx == MON_A_SILVER) && (r_ptr->r_akills % 5 == 0))))
1076 /* Prepare to make a Can of Toys */
1077 object_prep(q_ptr, lookup_kind(TV_CHEST, SV_CHEST_KANDUME));
1079 apply_magic(q_ptr, object_level, AM_NO_FIXED_ART);
1081 /* Drop it in the dungeon */
1082 (void)drop_near(q_ptr, -1, y, x);
1088 BIT_FLAGS flg = PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL;
1089 (void)project(m_idx, 3, y, x, damroll(20, 10), GF_FIRE, flg, -1);
1094 if (!drop_chosen_item) break;
1096 switch (r_ptr->d_char)
1104 /* Activate restriction */
1105 get_obj_num_hook = kind_is_cloak;
1108 make_object(q_ptr, mo_mode);
1110 /* Drop it in the dungeon */
1111 (void)drop_near(q_ptr, -1, y, x);
1121 /* Activate restriction */
1122 get_obj_num_hook = kind_is_polearm;
1124 /* Make a poleweapon */
1125 make_object(q_ptr, mo_mode);
1127 /* Drop it in the dungeon */
1128 (void)drop_near(q_ptr, -1, y, x);
1138 /* Activate restriction */
1139 get_obj_num_hook = kind_is_armor;
1141 /* Make a hard armor */
1142 make_object(q_ptr, mo_mode);
1144 /* Drop it in the dungeon */
1145 (void)drop_near(q_ptr, -1, y, x);
1155 /* Activate restriction */
1156 get_obj_num_hook = kind_is_hafted;
1158 /* Make a hafted weapon */
1159 make_object(q_ptr, mo_mode);
1161 /* Drop it in the dungeon */
1162 (void)drop_near(q_ptr, -1, y, x);
1167 if (m_ptr->r_idx != MON_STORMBRINGER)
1172 /* Activate restriction */
1173 get_obj_num_hook = kind_is_sword;
1176 make_object(q_ptr, mo_mode);
1178 /* Drop it in the dungeon */
1179 (void)drop_near(q_ptr, -1, y, x);
1186 /* Mega-Hack -- drop fixed items */
1187 if (drop_chosen_item)
1189 ARTIFACT_IDX a_idx = 0;
1192 for(i = 0; i < 4; i++)
1194 if(!r_ptr->artifact_id[i]) break;
1195 a_idx = r_ptr->artifact_id[i];
1196 chance = r_ptr->artifact_percent[i];
1199 if ((a_idx > 0) && ((randint0(100) < chance) || p_ptr->wizard))
1201 artifact_type *a_ptr = &a_info[a_idx];
1203 if (!a_ptr->cur_num)
1205 /* Create the artifact */
1206 if (create_named_art(a_idx, y, x))
1210 /* Hack -- Memorize location of artifact in saved floors */
1211 if (character_dungeon) a_ptr->floor_id = p_ptr->floor_id;
1213 else if (!preserve_mode) a_ptr->cur_num = 1;
1217 if ((r_ptr->flags7 & RF7_GUARDIAN) && (d_info[dungeon_type].final_guardian == m_ptr->r_idx))
1219 KIND_OBJECT_IDX k_idx = d_info[dungeon_type].final_object ? d_info[dungeon_type].final_object
1220 : lookup_kind(TV_SCROLL, SV_SCROLL_ACQUIREMENT);
1222 if (d_info[dungeon_type].final_artifact)
1224 a_idx = d_info[dungeon_type].final_artifact;
1225 artifact_type *a_ptr = &a_info[a_idx];
1227 if (!a_ptr->cur_num)
1229 /* Create the artifact */
1230 if (create_named_art(a_idx, y, x))
1234 /* Hack -- Memorize location of artifact in saved floors */
1235 if (character_dungeon) a_ptr->floor_id = p_ptr->floor_id;
1237 else if (!preserve_mode) a_ptr->cur_num = 1;
1239 /* Prevent rewarding both artifact and "default" object */
1240 if (!d_info[dungeon_type].final_object) k_idx = 0;
1248 /* Prepare to make a reward */
1249 object_prep(q_ptr, k_idx);
1251 apply_magic(q_ptr, object_level, AM_NO_FIXED_ART | AM_GOOD);
1253 /* Drop it in the dungeon */
1254 (void)drop_near(q_ptr, -1, y, x);
1256 msg_format(_("あなたは%sを制覇した!", "You have conquered %s!"),d_name+d_info[dungeon_type].name);
1260 /* Determine how much we can drop */
1261 if ((r_ptr->flags1 & RF1_DROP_60) && (randint0(100) < 60)) number++;
1262 if ((r_ptr->flags1 & RF1_DROP_90) && (randint0(100) < 90)) number++;
1263 if (r_ptr->flags1 & RF1_DROP_1D2) number += damroll(1, 2);
1264 if (r_ptr->flags1 & RF1_DROP_2D2) number += damroll(2, 2);
1265 if (r_ptr->flags1 & RF1_DROP_3D2) number += damroll(3, 2);
1266 if (r_ptr->flags1 & RF1_DROP_4D2) number += damroll(4, 2);
1268 if (cloned && !(r_ptr->flags1 & RF1_UNIQUE))
1269 number = 0; /* Clones drop no stuff unless Cloning Pits */
1271 if (is_pet(m_ptr) || p_ptr->inside_battle || p_ptr->inside_arena)
1272 number = 0; /* Pets drop no stuff */
1273 if (!drop_item && (r_ptr->d_char != '$')) number = 0;
1275 if((r_ptr->flags2 & (RF2_MULTIPLY)) && (r_ptr->r_akills > 1024))
1276 number = 0; /* Limit of Multiply monster drop */
1278 /* Hack -- handle creeping coins */
1279 coin_type = force_coin;
1281 /* Average dungeon and monster levels */
1282 object_level = (dun_level + r_ptr->level) / 2;
1284 /* Drop some objects */
1285 for (j = 0; j < number; j++)
1291 if (do_gold && (!do_item || (randint0(100) < 50)))
1293 /* Make some gold */
1294 if (!make_gold(q_ptr)) continue;
1302 /* Make an object */
1303 if (!make_object(q_ptr, mo_mode)) continue;
1308 /* Drop it in the dungeon */
1309 (void)drop_near(q_ptr, -1, y, x);
1312 /* Reset the object level */
1313 object_level = base_level;
1315 /* Reset "coin" type */
1319 /* Take note of any dropped treasure */
1320 if (visible && (dump_item || dump_gold))
1322 /* Take notes on treasure */
1323 lore_treasure(m_idx, dump_item, dump_gold);
1326 /* Only process "Quest Monsters" */
1327 if (!(r_ptr->flags1 & RF1_QUESTOR)) return;
1328 if (p_ptr->inside_battle) return;
1331 if ((m_ptr->r_idx == MON_SERPENT) && !cloned)
1334 p_ptr->total_winner = TRUE;
1336 /* Redraw the "title" */
1337 p_ptr->redraw |= (PR_TITLE);
1339 play_music(TERM_XTRA_MUSIC_BASIC, MUSIC_BASIC_FINAL_QUEST_CLEAR);
1341 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, _("見事に変愚蛮怒の勝利者となった!", "become *WINNER* of Hengband finely!"));
1343 if ((p_ptr->pclass == CLASS_CHAOS_WARRIOR) || (p_ptr->muta2 & MUT2_CHAOS_GIFT))
1345 msg_format(_("%sからの声が響いた。", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
1346 msg_print(_("『よくやった、定命の者よ!』", "'Thou art donst well, mortal!'"));
1349 /* Congratulations */
1350 msg_print(_("*** おめでとう ***", "*** CONGRATULATIONS ***"));
1351 msg_print(_("あなたはゲームをコンプリートしました。", "You have won the game!"));
1352 msg_print(_("準備が整ったら引退(自殺コマンド)しても結構です。", "You may retire (commit suicide) when you are ready."));
1357 * @brief モンスターに与えたダメージの修正処理 /
1358 * Modify the physical damage done to the monster.
1359 * @param m_ptr ダメージを受けるモンスターの構造体参照ポインタ
1360 * @param dam ダメージ基本値
1361 * @param is_psy_spear 攻撃手段が光の剣ならばTRUE
1362 * @return 修正を行った結果のダメージ量
1365 * (for example when it's invulnerable or shielded)
1366 * ToDo: Accept a damage-type to calculate the modified damage from
1367 * things like fire, frost, lightning, poison, ... attacks.
1368 * "type" is not yet used and should be 0.
1371 HIT_POINT mon_damage_mod(monster_type *m_ptr, HIT_POINT dam, bool is_psy_spear)
1373 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1375 if ((r_ptr->flagsr & RFR_RES_ALL) && dam > 0)
1378 if ((dam == 0) && one_in_(3)) dam = 1;
1381 if (MON_INVULNER(m_ptr))
1385 if (!p_ptr->blind && is_seen(m_ptr))
1387 msg_print(_("バリアを切り裂いた!", "The barrier is penetrated!"));
1390 else if (!one_in_(PENETRATE_INVULNERABILITY))
1400 * @brief モンスターに与えたダメージを元に経験値を加算する /
1401 * Calculate experience point to be get
1402 * @param dam 与えたダメージ量
1403 * @param m_ptr ダメージを与えたモンスターの構造体参照ポインタ
1407 * Even the 64 bit operation is not big enough to avoid overflaw
1408 * unless we carefully choose orders of multiplication and division.
1409 * Get the coefficient first, and multiply (potentially huge) base
1410 * experience point of a monster later.
1413 static void get_exp_from_mon(HIT_POINT dam, monster_type *m_ptr)
1415 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1422 if (!m_ptr->r_idx) return;
1423 if (is_pet(m_ptr) || p_ptr->inside_battle) return;
1426 * - Ratio of monster's level to player's level effects
1427 * - Varying speed effects
1428 * - Get a fraction in proportion of damage point
1430 new_exp = r_ptr->level * SPEED_TO_ENERGY(m_ptr->mspeed) * dam;
1433 div_l = (p_ptr->max_plv+2) * SPEED_TO_ENERGY(r_ptr->speed);
1435 /* Use (average maxhp * 2) as a denominator */
1436 if (!(r_ptr->flags1 & RF1_FORCE_MAXHP))
1437 s64b_mul(&div_h, &div_l, 0, r_ptr->hdice * (ironman_nightmare ? 2 : 1) * (r_ptr->hside + 1));
1439 s64b_mul(&div_h, &div_l, 0, r_ptr->hdice * (ironman_nightmare ? 2 : 1) * r_ptr->hside * 2);
1441 /* Special penalty in the wilderness */
1442 if (!dun_level && (!(r_ptr->flags8 & RF8_WILD_ONLY) || !(r_ptr->flags1 & RF1_UNIQUE)))
1443 s64b_mul(&div_h, &div_l, 0, 5);
1445 /* Do division first to prevent overflaw */
1446 s64b_div(&new_exp, &new_exp_frac, div_h, div_l);
1448 /* Special penalty for mutiply-monster */
1449 if ((r_ptr->flags2 & RF2_MULTIPLY) || (m_ptr->r_idx == MON_DAWN))
1451 int monnum_penarty = r_ptr->r_akills / 400;
1452 if (monnum_penarty > 8) monnum_penarty = 8;
1454 while (monnum_penarty--)
1457 s64b_RSHIFT(new_exp, new_exp_frac, 2);
1461 /* Special penalty for rest_and_shoot exp scum */
1462 if ((m_ptr->dealt_damage > m_ptr->max_maxhp) && (m_ptr->hp >= 0))
1464 int over_damage = m_ptr->dealt_damage / m_ptr->max_maxhp;
1465 if (over_damage > 32) over_damage = 32;
1467 while (over_damage--)
1470 s64b_mul(&new_exp, &new_exp_frac, 0, 9);
1471 s64b_div(&new_exp, &new_exp_frac, 0, 10);
1475 /* Finally multiply base experience point of the monster */
1476 s64b_mul(&new_exp, &new_exp_frac, 0, r_ptr->mexp);
1478 /* Gain experience */
1479 gain_exp_64(new_exp, new_exp_frac);
1484 * @brief モンスターのHPをダメージに応じて減算する /
1485 * Decreases monsters hit points, handling monster death.
1486 * @param dam 与えたダメージ量
1487 * @param m_idx ダメージを与えたモンスターのID
1488 * @param fear ダメージによってモンスターが恐慌状態に陥ったならばTRUEを返す
1489 * @param note モンスターが倒された際の特別なメッセージ述語
1493 * We return TRUE if the monster has been killed (and deleted).
1494 * We announce monster death (using an optional "death message"
1495 * if given, and a otherwise a generic killed/destroyed message).
1496 * Only "physical attacks" can induce the "You have slain" message.
1497 * Missile and Spell attacks will induce the "dies" message, or
1498 * various "specialized" messages. Note that "You have destroyed"
1499 * and "is destroyed" are synonyms for "You have slain" and "dies".
1500 * Hack -- unseen monsters yield "You have killed it." message.
1501 * Added fear (DGK) and check whether to print fear messages -CWS
1502 * Made name, sex, and capitalization generic -BEN-
1503 * As always, the "ghost" processing is a total hack.
1504 * Hack -- we "delay" fear messages by passing around a "fear" flag.
1505 * Consider decreasing monster experience over time, say,
1506 * by using "(m_exp * m_lev * (m_lev)) / (p_lev * (m_lev + n_killed))"
1507 * instead of simply "(m_exp * m_lev) / (p_lev)", to make the first
1508 * monster worth more than subsequent monsters. This would also need
1509 * to induce changes in the monster recall code.
1512 bool mon_take_hit(MONSTER_IDX m_idx, HIT_POINT dam, bool *fear, cptr note)
1514 monster_type *m_ptr = &m_list[m_idx];
1515 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1516 monster_type exp_mon;
1518 /* Innocent until proven otherwise */
1519 bool innocent = TRUE, thief = FALSE;
1523 (void)COPY(&exp_mon, m_ptr, monster_type);
1525 expdam = (m_ptr->hp > dam) ? dam : m_ptr->hp;
1527 get_exp_from_mon(expdam, &exp_mon);
1529 /* Genocided by chaos patron */
1530 if (!m_ptr->r_idx) m_idx = 0;
1532 /* Redraw (later) if needed */
1533 if (p_ptr->health_who == m_idx) p_ptr->redraw |= (PR_HEALTH);
1534 if (p_ptr->riding == m_idx) p_ptr->redraw |= (PR_UHEALTH);
1536 (void)set_monster_csleep(m_idx, 0);
1538 /* Hack - Cancel any special player stealth magics. -LM- */
1539 if (p_ptr->special_defense & NINJA_S_STEALTH)
1541 set_superstealth(FALSE);
1544 /* Genocided by chaos patron */
1545 if (!m_idx) return TRUE;
1548 m_ptr->dealt_damage += dam;
1550 if(m_ptr->dealt_damage > m_ptr->max_maxhp * 100) m_ptr->dealt_damage = m_ptr->max_maxhp * 100;
1554 msg_format( _("合計%d/%dのダメージを与えた。","You do %d (out of %d) damage."), m_ptr->dealt_damage, m_ptr->maxhp);
1557 /* It is dead now */
1562 if (r_info[m_ptr->r_idx].flags7 & RF7_TANUKI)
1564 /* You might have unmasked Tanuki first time */
1565 r_ptr = &r_info[m_ptr->r_idx];
1566 m_ptr->ap_r_idx = m_ptr->r_idx;
1567 if (r_ptr->r_sights < MAX_SHORT) r_ptr->r_sights++;
1570 if (m_ptr->mflag2 & MFLAG2_CHAMELEON)
1572 /* You might have unmasked Chameleon first time */
1573 r_ptr = real_r_ptr(m_ptr);
1574 if (r_ptr->r_sights < MAX_SHORT) r_ptr->r_sights++;
1577 if (!(m_ptr->smart & SM_CLONED))
1579 /* When the player kills a Unique, it stays dead */
1580 if (r_ptr->flags1 & RF1_UNIQUE)
1584 /* Mega-Hack -- Banor & Lupart */
1585 if ((m_ptr->r_idx == MON_BANOR) || (m_ptr->r_idx == MON_LUPART))
1587 r_info[MON_BANORLUPART].max_num = 0;
1588 r_info[MON_BANORLUPART].r_pkills++;
1589 r_info[MON_BANORLUPART].r_akills++;
1590 if (r_info[MON_BANORLUPART].r_tkills < MAX_SHORT) r_info[MON_BANORLUPART].r_tkills++;
1592 else if (m_ptr->r_idx == MON_BANORLUPART)
1594 r_info[MON_BANOR].max_num = 0;
1595 r_info[MON_BANOR].r_pkills++;
1596 r_info[MON_BANOR].r_akills++;
1597 if (r_info[MON_BANOR].r_tkills < MAX_SHORT) r_info[MON_BANOR].r_tkills++;
1598 r_info[MON_LUPART].max_num = 0;
1599 r_info[MON_LUPART].r_pkills++;
1600 r_info[MON_LUPART].r_akills++;
1601 if (r_info[MON_LUPART].r_tkills < MAX_SHORT) r_info[MON_LUPART].r_tkills++;
1605 /* When the player kills a Nazgul, it stays dead */
1606 else if (r_ptr->flags7 & RF7_NAZGUL) r_ptr->max_num--;
1609 /* Count all monsters killed */
1610 if (r_ptr->r_akills < MAX_SHORT) r_ptr->r_akills++;
1612 /* Recall even invisible uniques or winners */
1613 if ((m_ptr->ml && !p_ptr->image) || (r_ptr->flags1 & RF1_UNIQUE))
1615 /* Count kills this life */
1616 if ((m_ptr->mflag2 & MFLAG2_KAGE) && (r_info[MON_KAGE].r_pkills < MAX_SHORT)) r_info[MON_KAGE].r_pkills++;
1617 else if (r_ptr->r_pkills < MAX_SHORT) r_ptr->r_pkills++;
1619 /* Count kills in all lives */
1620 if ((m_ptr->mflag2 & MFLAG2_KAGE) && (r_info[MON_KAGE].r_tkills < MAX_SHORT)) r_info[MON_KAGE].r_tkills++;
1621 else if (r_ptr->r_tkills < MAX_SHORT) r_ptr->r_tkills++;
1623 /* Hack -- Auto-recall */
1624 monster_race_track(m_ptr->ap_r_idx);
1627 /* Extract monster name */
1628 monster_desc(m_name, m_ptr, MD_TRUE_NAME);
1630 /* Don't kill Amberites */
1631 if ((r_ptr->flags3 & RF3_AMBERITE) && one_in_(2))
1633 int curses = 1 + randint1(3);
1634 bool stop_ty = FALSE;
1637 msg_format(_("%^sは恐ろしい血の呪いをあなたにかけた!", "%^s puts a terrible blood curse on you!"), m_name);
1638 curse_equipment(100, 50);
1642 stop_ty = activate_ty_curse(stop_ty, &count);
1647 if (r_ptr->flags2 & RF2_CAN_SPEAK)
1649 char line_got[1024];
1651 /* Dump a message */
1652 if (!get_rnd_line(_("mondeath_j.txt", "mondeath.txt"), m_ptr->r_idx, line_got))
1654 msg_format("%^s %s", m_name, line_got);
1658 if (m_ptr->r_idx == MON_SERPENT)
1660 screen_dump = make_screen_dump();
1665 if (!(d_info[dungeon_type].flags1 & DF1_BEGINNER))
1667 if (!dun_level && !ambush_flag && !p_ptr->inside_arena)
1669 chg_virtue(V_VALOUR, -1);
1671 else if (r_ptr->level > dun_level)
1673 if (randint1(10) <= (r_ptr->level - dun_level))
1674 chg_virtue(V_VALOUR, 1);
1676 if (r_ptr->level > 60)
1678 chg_virtue(V_VALOUR, 1);
1680 if (r_ptr->level >= 2 * (p_ptr->lev+1))
1681 chg_virtue(V_VALOUR, 2);
1684 if (r_ptr->flags1 & RF1_UNIQUE)
1686 if (r_ptr->flags3 & (RF3_EVIL | RF3_GOOD)) chg_virtue(V_HARMONY, 2);
1688 if (r_ptr->flags3 & RF3_GOOD)
1690 chg_virtue(V_UNLIFE, 2);
1691 chg_virtue(V_VITALITY, -2);
1694 if (one_in_(3)) chg_virtue(V_INDIVIDUALISM, -1);
1697 if (m_ptr->r_idx == MON_BEGGAR || m_ptr->r_idx == MON_LEPER)
1699 chg_virtue(V_COMPASSION, -1);
1702 if ((r_ptr->flags3 & RF3_GOOD) && ((r_ptr->level) / 10 + (3 * dun_level) >= randint1(100)))
1703 chg_virtue(V_UNLIFE, 1);
1705 if (r_ptr->d_char == 'A')
1707 if (r_ptr->flags1 & RF1_UNIQUE)
1708 chg_virtue(V_FAITH, -2);
1709 else if ((r_ptr->level) / 10 + (3 * dun_level) >= randint1(100))
1711 if (r_ptr->flags3 & RF3_GOOD) chg_virtue(V_FAITH, -1);
1712 else chg_virtue(V_FAITH, 1);
1715 else if (r_ptr->flags3 & RF3_DEMON)
1717 if (r_ptr->flags1 & RF1_UNIQUE)
1718 chg_virtue(V_FAITH, 2);
1719 else if ((r_ptr->level) / 10 + (3 * dun_level) >= randint1(100))
1720 chg_virtue(V_FAITH, 1);
1723 if ((r_ptr->flags3 & RF3_UNDEAD) && (r_ptr->flags1 & RF1_UNIQUE))
1724 chg_virtue(V_VITALITY, 2);
1726 if (r_ptr->r_deaths)
1728 if (r_ptr->flags1 & RF1_UNIQUE)
1730 chg_virtue(V_HONOUR, 10);
1732 else if ((r_ptr->level) / 10 + (2 * dun_level) >= randint1(100))
1734 chg_virtue(V_HONOUR, 1);
1737 if ((r_ptr->flags2 & RF2_MULTIPLY) && (r_ptr->r_akills > 1000) && one_in_(10))
1739 chg_virtue(V_VALOUR, -1);
1742 for (i = 0; i < 4; i++)
1744 if (r_ptr->blow[i].d_dice != 0) innocent = FALSE; /* Murderer! */
1746 if ((r_ptr->blow[i].effect == RBE_EAT_ITEM)
1747 || (r_ptr->blow[i].effect == RBE_EAT_GOLD))
1749 thief = TRUE; /* Thief! */
1752 /* The new law says it is illegal to live in the dungeon */
1753 if (r_ptr->level != 0) innocent = FALSE;
1757 if (r_ptr->flags1 & RF1_UNIQUE)
1758 chg_virtue(V_JUSTICE, 3);
1759 else if (1+((r_ptr->level) / 10 + (2 * dun_level)) >= randint1(100))
1760 chg_virtue(V_JUSTICE, 1);
1764 chg_virtue (V_JUSTICE, -1);
1767 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)))
1769 if (one_in_(4)) chg_virtue(V_NATURE, -1);
1772 if ((r_ptr->flags1 & RF1_UNIQUE) && record_destroy_uniq)
1775 sprintf(note_buf, "%s%s", r_name + r_ptr->name, (m_ptr->smart & SM_CLONED) ? _("(クローン)", "(Clone)") : "");
1776 do_cmd_write_nikki(NIKKI_UNIQUE, 0, note_buf);
1782 /* Death by Missile/Spell attack */
1785 msg_format("%^s%s", m_name, note);
1788 /* Death by physical attack -- invisible monster */
1789 else if (!m_ptr->ml)
1792 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
1793 msg_format("せっかくだから%sを殺した。", m_name);
1795 msg_format("%sを殺した。", m_name);
1797 msg_format("You have killed %s.", m_name);
1802 /* Death by Physical attack -- non-living monster */
1803 else if (!monster_living(r_ptr))
1805 bool explode = FALSE;
1807 for (i = 0; i < 4; i++)
1809 if (r_ptr->blow[i].method == RBM_EXPLODE) explode = TRUE;
1812 /* Special note at death */
1814 msg_format(_("%sは爆発して粉々になった。", "%^s explodes into tiny shreds."), m_name);
1818 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
1819 msg_format("せっかくだから%sを倒した。", m_name);
1821 msg_format("%sを倒した。", m_name);
1823 msg_format("You have destroyed %s.", m_name);
1828 /* Death by Physical attack -- living monster */
1832 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
1833 msg_format("せっかくだから%sを葬り去った。", m_name);
1835 msg_format("%sを葬り去った。", m_name);
1837 msg_format("You have slain %s.", m_name);
1841 if ((r_ptr->flags1 & RF1_UNIQUE) && !(m_ptr->smart & SM_CLONED) && !vanilla_town)
1843 for (i = 0; i < MAX_KUBI; i++)
1845 if ((kubi_r_idx[i] == m_ptr->r_idx) && !(m_ptr->mflag2 & MFLAG2_CHAMELEON))
1847 msg_format(_("%sの首には賞金がかかっている。", "There is a price on %s's head."), m_name);
1853 /* Generate treasure */
1854 monster_death(m_idx, TRUE);
1856 /* Mega hack : replace IKETA to BIKETAL */
1857 if ((m_ptr->r_idx == MON_IKETA) && !(p_ptr->inside_arena || p_ptr->inside_battle))
1859 POSITION dummy_y = m_ptr->fy;
1860 POSITION dummy_x = m_ptr->fx;
1861 BIT_FLAGS mode = 0L;
1862 if (is_pet(m_ptr)) mode |= PM_FORCE_PET;
1863 delete_monster_idx(m_idx);
1864 if (summon_named_creature(0, dummy_y, dummy_x, MON_BIKETAL, mode))
1866 msg_print(_("「ハァッハッハッハ!!私がバイケタルだ!!」", "Uwa-hahaha! *I* am Biketal!"));
1871 delete_monster_idx(m_idx);
1874 get_exp_from_mon((long)exp_mon.max_maxhp*2, &exp_mon);
1879 /* Monster is dead */
1886 /* Mega-Hack -- Pain cancels fear */
1887 if (MON_MONFEAR(m_ptr) && (dam > 0))
1890 if (set_monster_monfear(m_idx, MON_MONFEAR(m_ptr) - randint1(dam)))
1897 /* Sometimes a monster gets scared by damage */
1898 if (!MON_MONFEAR(m_ptr) && !(r_ptr->flags3 & (RF3_NO_FEAR)))
1900 /* Percentage of fully healthy */
1901 int percentage = (100L * m_ptr->hp) / m_ptr->maxhp;
1904 * Run (sometimes) if at 10% or less of max hit points,
1905 * or (usually) when hit for half its current hit points
1907 if ((randint1(10) >= percentage) || ((dam >= m_ptr->hp) && (randint0(100) < 80)))
1909 /* Hack -- note fear */
1912 /* Hack -- Add some timed fear */
1913 (void)set_monster_monfear(m_idx, (randint1(10) +
1914 (((dam >= m_ptr->hp) && (percentage > 7)) ?
1915 20 : ((11 - percentage) * 5))));
1927 * @brief 現在のコンソール表示の縦横を返す。 /
1928 * Get term size and calculate screen size
1929 * @param wid_p コンソールの表示幅文字数を返す
1930 * @param hgt_p コンソールの表示行数を返す
1933 void get_screen_size(TERM_LEN *wid_p, TERM_LEN *hgt_p)
1935 Term_get_size(wid_p, hgt_p);
1936 *hgt_p -= ROW_MAP + 2;
1937 *wid_p -= COL_MAP + 2;
1938 if (use_bigtile) *wid_p /= 2;
1943 * @brief コンソール上におけるマップ表示の左上位置を返す /
1944 * Calculates current boundaries Called below and from "do_cmd_locate()".
1947 void panel_bounds_center(void)
1951 get_screen_size(&wid, &hgt);
1953 panel_row_max = panel_row_min + hgt - 1;
1954 panel_row_prt = panel_row_min - 1;
1955 panel_col_max = panel_col_min + wid - 1;
1956 panel_col_prt = panel_col_min - 13;
1961 * @brief コンソールのリサイズに合わせてマップを再描画する /
1962 * Map resizing whenever the main term changes size
1965 void resize_map(void)
1967 /* Only if the dungeon exists */
1968 if (!character_dungeon) return;
1970 /* Mega-Hack -- no panel yet */
1974 /* Reset the panels */
1975 panel_row_min = cur_hgt;
1976 panel_col_min = cur_wid;
1980 p_ptr->update |= (PU_TORCH | PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
1982 /* Forget lite/view */
1983 p_ptr->update |= (PU_UN_VIEW | PU_UN_LITE);
1985 /* Update lite/view */
1986 p_ptr->update |= (PU_VIEW | PU_LITE | PU_MON_LITE);
1988 /* Update monsters */
1989 p_ptr->update |= (PU_MONSTERS);
1991 /* Redraw everything */
1992 p_ptr->redraw |= (PR_WIPE | PR_BASIC | PR_EXTRA | PR_MAP | PR_EQUIPPY);
1994 /* Hack -- update */
2000 * Place the cursor on the player
2002 if (can_save) move_cursor_relative(p_ptr->y, p_ptr->x);
2009 * @brief コンソールを再描画する /
2010 * Redraw a term when it is resized
2013 void redraw_window(void)
2015 /* Only if the dungeon exists */
2016 if (!character_dungeon) return;
2018 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_SPELL | PW_PLAYER);
2019 p_ptr->window |= (PW_MESSAGE | PW_OVERHEAD | PW_DUNGEON | PW_MONSTER | PW_OBJECT);
2021 /* Hack -- update */
2028 * @brief フォーカスを当てるべきマップ描画の基準座標を指定する(サブルーチン)
2029 * @param dy 変更先のフロアY座標
2030 * @param dx 変更先のフロアX座標
2031 * Handle a request to change the current panel
2032 * Return TRUE if the panel was changed.
2033 * Also used in do_cmd_locate
2034 * @return 実際に再描画が必要だった場合TRUEを返す
2036 bool change_panel(POSITION dy, POSITION dx)
2041 get_screen_size(&wid, &hgt);
2043 /* Apply the motion */
2044 y = panel_row_min + dy * hgt / 2;
2045 x = panel_col_min + dx * wid / 2;
2047 /* Verify the row */
2048 if (y > cur_hgt - hgt) y = cur_hgt - hgt;
2051 /* Verify the col */
2052 if (x > cur_wid - wid) x = cur_wid - wid;
2055 /* Handle "changes" */
2056 if ((y != panel_row_min) || (x != panel_col_min))
2058 /* Save the new panel info */
2062 /* Recalculate the boundaries */
2063 panel_bounds_center();
2065 p_ptr->update |= (PU_MONSTERS);
2067 p_ptr->redraw |= (PR_MAP);
2079 * @brief フォーカスを当てるべきマップ描画の基準座標を指定する
2080 * @param y 変更先のフロアY座標
2081 * @param x 変更先のフロアX座標
2083 * Handle a request to change the current panel
2084 * Return TRUE if the panel was changed.
2085 * Also used in do_cmd_locate
2086 * @return 実際に再描画が必要だった場合TRUEを返す
2088 static bool change_panel_xy(POSITION y, POSITION x)
2090 POSITION dy = 0, dx = 0;
2093 get_screen_size(&wid, &hgt);
2095 if (y < panel_row_min) dy = -1;
2096 if (y > panel_row_max) dy = 1;
2097 if (x < panel_col_min) dx = -1;
2098 if (x > panel_col_max) dx = 1;
2100 if (!dy && !dx) return (FALSE);
2102 return change_panel(dy, dx);
2107 * @brief マップ描画のフォーカスを当てるべき座標を更新する
2109 * Given an row (y) and col (x), this routine detects when a move
2110 * off the screen has occurred and figures new borders. -RAK-
2111 * "Update" forces a "full update" to take place.
2112 * The map is reprinted if necessary, and "TRUE" is returned.
2113 * @return 実際に再描画が必要だった場合TRUEを返す
2115 void verify_panel(void)
2117 POSITION y = p_ptr->y;
2118 POSITION x = p_ptr->x;
2126 get_screen_size(&wid, &hgt);
2128 max_prow_min = cur_hgt - hgt;
2129 max_pcol_min = cur_wid - wid;
2131 /* Bounds checking */
2132 if (max_prow_min < 0) max_prow_min = 0;
2133 if (max_pcol_min < 0) max_pcol_min = 0;
2135 /* Center on player */
2136 if (center_player && (center_running || !running))
2138 /* Center vertically */
2139 prow_min = y - hgt / 2;
2140 if (prow_min < 0) prow_min = 0;
2141 else if (prow_min > max_prow_min) prow_min = max_prow_min;
2143 /* Center horizontally */
2144 pcol_min = x - wid / 2;
2145 if (pcol_min < 0) pcol_min = 0;
2146 else if (pcol_min > max_pcol_min) pcol_min = max_pcol_min;
2150 prow_min = panel_row_min;
2151 pcol_min = panel_col_min;
2153 /* Scroll screen when 2 grids from top/bottom edge */
2154 if (y > panel_row_max - 2)
2156 while (y > prow_min + hgt-1 - 2)
2158 prow_min += (hgt / 2);
2162 if (y < panel_row_min + 2)
2164 while (y < prow_min + 2)
2166 prow_min -= (hgt / 2);
2170 if (prow_min > max_prow_min) prow_min = max_prow_min;
2171 if (prow_min < 0) prow_min = 0;
2173 /* Scroll screen when 4 grids from left/right edge */
2174 if (x > panel_col_max - 4)
2176 while (x > pcol_min + wid-1 - 4)
2178 pcol_min += (wid / 2);
2182 if (x < panel_col_min + 4)
2184 while (x < pcol_min + 4)
2186 pcol_min -= (wid / 2);
2190 if (pcol_min > max_pcol_min) pcol_min = max_pcol_min;
2191 if (pcol_min < 0) pcol_min = 0;
2194 /* Check for "no change" */
2195 if ((prow_min == panel_row_min) && (pcol_min == panel_col_min)) return;
2197 /* Save the new panel info */
2198 panel_row_min = prow_min;
2199 panel_col_min = pcol_min;
2201 /* Hack -- optional disturb on "panel change" */
2202 if (disturb_panel && !center_player) disturb(FALSE, FALSE);
2204 /* Recalculate the boundaries */
2205 panel_bounds_center();
2207 p_ptr->update |= (PU_MONSTERS);
2208 p_ptr->redraw |= (PR_MAP);
2209 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
2214 * Monster health description
2216 cptr look_mon_desc(monster_type *m_ptr, BIT_FLAGS mode)
2218 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
2225 /* Determine if the monster is "living" */
2226 living = monster_living(ap_r_ptr);
2228 /* Calculate a health "percentage" */
2229 perc = 100L * m_ptr->hp / m_ptr->maxhp;
2231 /* Healthy monsters */
2232 if (m_ptr->hp >= m_ptr->maxhp)
2234 desc = living ? _("無傷", "unhurt") : _("無ダメージ", "undamaged");
2237 else if (perc >= 60)
2239 desc = living ? _("軽傷", "somewhat wounded") : _("小ダメージ", "somewhat damaged");
2242 else if (perc >= 25)
2244 desc = living ? _("負傷", "wounded") : _("中ダメージ", "damaged");
2247 else if (perc >= 10)
2249 desc = living ? _("重傷", "badly wounded") : _("大ダメージ", "badly damaged");
2254 desc = living ? _("半死半生", "almost dead") : _("倒れかけ", "almost destroyed");
2257 /* Need attitude information? */
2260 /* Full information is not needed */
2263 else if (is_pet(m_ptr))
2265 attitude = _(", ペット", ", pet");
2267 else if (is_friendly(m_ptr))
2269 attitude = _(", 友好的", ", friendly");
2273 attitude = _("", "");
2276 /* Clone monster? */
2277 if (m_ptr->smart & SM_CLONED)
2286 /* Display monster's level --- idea borrowed from ToME */
2287 if (ap_r_ptr->r_tkills && !(m_ptr->mflag2 & MFLAG2_KAGE))
2289 return format(_("レベル%d, %s%s%s", "Level %d, %s%s%s"), ap_r_ptr->level, desc, attitude, clone);
2293 return format(_("レベル???, %s%s%s", "Level ???, %s%s%s"), desc, attitude, clone);
2301 * Angband sorting algorithm -- quick sort in place
2303 * Note that the details of the data we are sorting is hidden,
2304 * and we rely on the "ang_sort_comp()" and "ang_sort_swap()"
2305 * function hooks to interact with the data, which is given as
2306 * two pointers, and which may have any user-defined form.
2308 void ang_sort_aux(vptr u, vptr v, int p, int q)
2326 while (!(*ang_sort_comp)(u, v, b, z)) b--;
2329 while (!(*ang_sort_comp)(u, v, z, a)) a++;
2331 /* Done partition */
2335 (*ang_sort_swap)(u, v, a, b);
2341 /* Recurse left side */
2342 ang_sort_aux(u, v, p, b);
2344 /* Recurse right side */
2345 ang_sort_aux(u, v, b+1, q);
2350 * Angband sorting algorithm -- quick sort in place
2352 * Note that the details of the data we are sorting is hidden,
2353 * and we rely on the "ang_sort_comp()" and "ang_sort_swap()"
2354 * function hooks to interact with the data, which is given as
2355 * two pointers, and which may have any user-defined form.
2357 void ang_sort(vptr u, vptr v, int n)
2359 /* Sort the array */
2360 ang_sort_aux(u, v, 0, n-1);
2365 /*** Targeting Code ***/
2369 * Determine is a monster makes a reasonable target
2371 * The concept of "targeting" was stolen from "Morgul" (?)
2373 * The player can target any location, or any "target-able" monster.
2375 * Currently, a monster is "target_able" if it is visible, and if
2376 * the player can hit it with a projection, and the player is not
2377 * hallucinating. This allows use of "use closest target" macros.
2379 * Future versions may restrict the ability to target "trappers"
2380 * and "mimics", but the semantics is a little bit weird.
2382 bool target_able(MONSTER_IDX m_idx)
2384 monster_type *m_ptr = &m_list[m_idx];
2386 /* Monster must be alive */
2387 if (!m_ptr->r_idx) return (FALSE);
2389 /* Hack -- no targeting hallucinations */
2390 if (p_ptr->image) return (FALSE);
2392 /* Monster must be visible */
2393 if (!m_ptr->ml) return (FALSE);
2395 if (p_ptr->riding && (p_ptr->riding == m_idx)) return (TRUE);
2397 /* Monster must be projectable */
2398 if (!projectable(p_ptr->y, p_ptr->x, m_ptr->fy, m_ptr->fx)) return (FALSE);
2400 /* Hack -- Never target trappers */
2401 /* if (CLEAR_ATTR && (CLEAR_CHAR)) return (FALSE); */
2411 * Update (if necessary) and verify (if possible) the target.
2413 * We return TRUE if the target is "okay" and FALSE otherwise.
2415 bool target_okay(void)
2417 /* Accept stationary targets */
2418 if (target_who < 0) return (TRUE);
2420 /* Check moving targets */
2423 /* Accept reasonable targets */
2424 if (target_able(target_who))
2426 monster_type *m_ptr = &m_list[target_who];
2428 /* Acquire monster location */
2429 target_row = m_ptr->fy;
2430 target_col = m_ptr->fx;
2437 /* Assume no target */
2443 * Sorting hook -- comp function -- by "distance to player"
2445 * We use "u" and "v" to point to arrays of "x" and "y" positions,
2446 * and sort the arrays by double-distance to the player.
2448 static bool ang_sort_comp_distance(vptr u, vptr v, int a, int b)
2450 POSITION *x = (POSITION*)(u);
2451 POSITION *y = (POSITION*)(v);
2453 POSITION da, db, kx, ky;
2455 /* Absolute distance components */
2456 kx = x[a]; kx -= p_ptr->x; kx = ABS(kx);
2457 ky = y[a]; ky -= p_ptr->y; ky = ABS(ky);
2459 /* Approximate Double Distance to the first point */
2460 da = ((kx > ky) ? (kx + kx + ky) : (ky + ky + kx));
2462 /* Absolute distance components */
2463 kx = x[b]; kx -= p_ptr->x; kx = ABS(kx);
2464 ky = y[b]; ky -= p_ptr->y; ky = ABS(ky);
2466 /* Approximate Double Distance to the first point */
2467 db = ((kx > ky) ? (kx + kx + ky) : (ky + ky + kx));
2469 /* Compare the distances */
2475 * Sorting hook -- comp function -- by importance level of grids
2477 * We use "u" and "v" to point to arrays of "x" and "y" positions,
2478 * and sort the arrays by level of monster
2480 static bool ang_sort_comp_importance(vptr u, vptr v, int a, int b)
2482 POSITION *x = (POSITION*)(u);
2483 POSITION *y = (POSITION*)(v);
2484 cave_type *ca_ptr = &cave[y[a]][x[a]];
2485 cave_type *cb_ptr = &cave[y[b]][x[b]];
2486 monster_type *ma_ptr = &m_list[ca_ptr->m_idx];
2487 monster_type *mb_ptr = &m_list[cb_ptr->m_idx];
2488 monster_race *ap_ra_ptr, *ap_rb_ptr;
2490 /* The player grid */
2491 if (y[a] == p_ptr->y && x[a] == p_ptr->x) return TRUE;
2492 if (y[b] == p_ptr->y && x[b] == p_ptr->x) return FALSE;
2494 /* Extract monster race */
2495 if (ca_ptr->m_idx && ma_ptr->ml) ap_ra_ptr = &r_info[ma_ptr->ap_r_idx];
2496 else ap_ra_ptr = NULL;
2497 if (cb_ptr->m_idx && mb_ptr->ml) ap_rb_ptr = &r_info[mb_ptr->ap_r_idx];
2498 else ap_rb_ptr = NULL;
2500 if (ap_ra_ptr && !ap_rb_ptr) return TRUE;
2501 if (!ap_ra_ptr && ap_rb_ptr) return FALSE;
2503 /* Compare two monsters */
2504 if (ap_ra_ptr && ap_rb_ptr)
2506 /* Unique monsters first */
2507 if ((ap_ra_ptr->flags1 & RF1_UNIQUE) && !(ap_rb_ptr->flags1 & RF1_UNIQUE)) return TRUE;
2508 if (!(ap_ra_ptr->flags1 & RF1_UNIQUE) && (ap_rb_ptr->flags1 & RF1_UNIQUE)) return FALSE;
2510 /* Shadowers first (あやしい影) */
2511 if ((ma_ptr->mflag2 & MFLAG2_KAGE) && !(mb_ptr->mflag2 & MFLAG2_KAGE)) return TRUE;
2512 if (!(ma_ptr->mflag2 & MFLAG2_KAGE) && (mb_ptr->mflag2 & MFLAG2_KAGE)) return FALSE;
2514 /* Unknown monsters first */
2515 if (!ap_ra_ptr->r_tkills && ap_rb_ptr->r_tkills) return TRUE;
2516 if (ap_ra_ptr->r_tkills && !ap_rb_ptr->r_tkills) return FALSE;
2518 /* Higher level monsters first (if known) */
2519 if (ap_ra_ptr->r_tkills && ap_rb_ptr->r_tkills)
2521 if (ap_ra_ptr->level > ap_rb_ptr->level) return TRUE;
2522 if (ap_ra_ptr->level < ap_rb_ptr->level) return FALSE;
2525 /* Sort by index if all conditions are same */
2526 if (ma_ptr->ap_r_idx > mb_ptr->ap_r_idx) return TRUE;
2527 if (ma_ptr->ap_r_idx < mb_ptr->ap_r_idx) return FALSE;
2530 /* An object get higher priority */
2531 if (cave[y[a]][x[a]].o_idx && !cave[y[b]][x[b]].o_idx) return TRUE;
2532 if (!cave[y[a]][x[a]].o_idx && cave[y[b]][x[b]].o_idx) return FALSE;
2534 /* Priority from the terrain */
2535 if (f_info[ca_ptr->feat].priority > f_info[cb_ptr->feat].priority) return TRUE;
2536 if (f_info[ca_ptr->feat].priority < f_info[cb_ptr->feat].priority) return FALSE;
2538 /* If all conditions are same, compare distance */
2539 return ang_sort_comp_distance(u, v, a, b);
2544 * Sorting hook -- swap function -- by "distance to player"
2546 * We use "u" and "v" to point to arrays of "x" and "y" positions,
2547 * and sort the arrays by distance to the player.
2549 static void ang_sort_swap_distance(vptr u, vptr v, int a, int b)
2551 POSITION *x = (POSITION*)(u);
2552 POSITION *y = (POSITION*)(v);
2570 * Hack -- help "select" a location (see below)
2572 static POSITION_IDX target_pick(POSITION y1, POSITION x1, POSITION dy, POSITION dx)
2575 POSITION x2, y2, x3, y3, x4, y4;
2576 POSITION_IDX b_i = -1, b_v = 9999;
2579 /* Scan the locations */
2580 for (i = 0; i < temp_n; i++)
2586 /* Directed distance */
2590 /* Verify quadrant */
2591 if (dx && (x3 * dx <= 0)) continue;
2592 if (dy && (y3 * dy <= 0)) continue;
2594 /* Absolute distance */
2598 /* Verify quadrant */
2599 if (dy && !dx && (x4 > y4)) continue;
2600 if (dx && !dy && (y4 > x4)) continue;
2602 /* Approximate Double Distance */
2603 v = ((x4 > y4) ? (x4 + x4 + y4) : (y4 + y4 + x4));
2605 /* Penalize location */
2608 if ((b_i >= 0) && (v >= b_v)) continue;
2618 * Hack -- determine if a given location is "interesting"
2620 static bool target_set_accept(POSITION y, POSITION x)
2623 OBJECT_IDX this_o_idx, next_o_idx = 0;
2626 if (!(in_bounds(y, x))) return (FALSE);
2628 /* Player grid is always interesting */
2629 if (player_bold(y, x)) return (TRUE);
2631 /* Handle hallucination */
2632 if (p_ptr->image) return (FALSE);
2634 /* Examine the grid */
2635 c_ptr = &cave[y][x];
2637 /* Visible monsters */
2640 monster_type *m_ptr = &m_list[c_ptr->m_idx];
2642 /* Visible monsters */
2643 if (m_ptr->ml) return (TRUE);
2646 /* Scan all objects in the grid */
2647 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
2650 o_ptr = &o_list[this_o_idx];
2652 /* Acquire next object */
2653 next_o_idx = o_ptr->next_o_idx;
2655 /* Memorized object */
2656 if (o_ptr->marked & OM_FOUND) return (TRUE);
2659 /* Interesting memorized features */
2660 if (c_ptr->info & (CAVE_MARK))
2662 /* Notice object features */
2663 if (c_ptr->info & CAVE_OBJECT) return (TRUE);
2665 /* Feature code (applying "mimic" field) */
2666 if (have_flag(f_info[get_feat_mimic(c_ptr)].flags, FF_NOTICE)) return TRUE;
2674 * Prepare the "temp" array for "target_set"
2676 * Return the number of target_able monsters in the set.
2678 static void target_set_prepare(BIT_FLAGS mode)
2681 POSITION min_hgt, max_hgt, min_wid, max_wid;
2683 if (mode & TARGET_KILL)
2686 min_hgt = MAX((p_ptr->y - MAX_RANGE), 0);
2687 max_hgt = MIN((p_ptr->y + MAX_RANGE), cur_hgt - 1);
2688 min_wid = MAX((p_ptr->x - MAX_RANGE), 0);
2689 max_wid = MIN((p_ptr->x + MAX_RANGE), cur_wid - 1);
2691 else /* not targetting */
2694 min_hgt = panel_row_min;
2695 max_hgt = panel_row_max;
2696 min_wid = panel_col_min;
2697 max_wid = panel_col_max;
2700 /* Reset "temp" array */
2703 /* Scan the current panel */
2704 for (y = min_hgt; y <= max_hgt; y++)
2706 for (x = min_wid; x <= max_wid; x++)
2710 /* Require "interesting" contents */
2711 if (!target_set_accept(y, x)) continue;
2713 c_ptr = &cave[y][x];
2715 /* Require target_able monsters for "TARGET_KILL" */
2716 if ((mode & (TARGET_KILL)) && !target_able(c_ptr->m_idx)) continue;
2718 if ((mode & (TARGET_KILL)) && !target_pet && is_pet(&m_list[c_ptr->m_idx])) continue;
2720 /* Save the location */
2727 /* Set the sort hooks */
2728 if (mode & (TARGET_KILL))
2730 /* Target the nearest monster for shooting */
2731 ang_sort_comp = ang_sort_comp_distance;
2732 ang_sort_swap = ang_sort_swap_distance;
2736 /* Look important grids first in Look command */
2737 ang_sort_comp = ang_sort_comp_importance;
2738 ang_sort_swap = ang_sort_swap_distance;
2741 /* Sort the positions */
2742 ang_sort(temp_x, temp_y, temp_n);
2744 if (p_ptr->riding && target_pet && (temp_n > 1) && (mode & (TARGET_KILL)))
2749 temp_y[0] = temp_y[1];
2752 temp_x[0] = temp_x[1];
2757 void target_set_prepare_look(void){
2758 target_set_prepare(TARGET_LOOK);
2763 * Evaluate number of kill needed to gain level
2765 static void evaluate_monster_exp(char *buf, monster_type *m_ptr)
2767 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
2769 s32b exp_mon, exp_adv;
2770 u32b exp_mon_frac, exp_adv_frac;
2772 if ((p_ptr->lev >= PY_MAX_LEVEL) || (p_ptr->prace == RACE_ANDROID))
2777 else if (!ap_r_ptr->r_tkills || (m_ptr->mflag2 & MFLAG2_KAGE))
2787 /* The monster's experience point (assuming average monster speed) */
2788 exp_mon = ap_r_ptr->mexp * ap_r_ptr->level;
2790 s64b_div(&exp_mon, &exp_mon_frac, 0, (p_ptr->max_plv + 2));
2793 /* Total experience value for next level */
2794 exp_adv = player_exp[p_ptr->lev -1] * p_ptr->expfact;
2796 s64b_div(&exp_adv, &exp_adv_frac, 0, 100);
2798 /* Experience value need to get */
2799 s64b_sub(&exp_adv, &exp_adv_frac, p_ptr->exp, p_ptr->exp_frac);
2802 /* You need to kill at least one monster to get any experience */
2803 s64b_add(&exp_adv, &exp_adv_frac, exp_mon, exp_mon_frac);
2804 s64b_sub(&exp_adv, &exp_adv_frac, 0, 1);
2806 /* Extract number of monsters needed */
2807 s64b_div(&exp_adv, &exp_adv_frac, exp_mon, exp_mon_frac);
2809 /* If 999 or more monsters needed, only display "999". */
2810 num = MIN(999, exp_adv_frac);
2812 /* Display the number */
2813 sprintf(buf,"%03ld", (long int)num);
2817 bool show_gold_on_floor = FALSE;
2820 * Examine a grid, return a keypress.
2822 * The "mode" argument contains the "TARGET_LOOK" bit flag, which
2823 * indicates that the "space" key should scan through the contents
2824 * of the grid, instead of simply returning immediately. This lets
2825 * the "look" command get complete information, without making the
2826 * "target" command annoying.
2828 * The "info" argument contains the "commands" which should be shown
2829 * inside the "[xxx]" text. This string must never be empty, or grids
2830 * containing monsters will be displayed with an extra comma.
2832 * Note that if a monster is in the grid, we update both the monster
2833 * recall info and the health bar info to track that monster.
2835 * Eventually, we may allow multiple objects per grid, or objects
2836 * and terrain features in the same grid.
2838 * This function must handle blindness/hallucination.
2840 static char target_set_aux(POSITION y, POSITION x, BIT_FLAGS mode, cptr info)
2842 cave_type *c_ptr = &cave[y][x];
2843 OBJECT_IDX this_o_idx, next_o_idx = 0;
2844 cptr s1 = "", s2 = "", s3 = "", x_info = "";
2847 feature_type *f_ptr;
2848 char query = '\001';
2849 char out_val[MAX_NLEN+80];
2850 OBJECT_IDX floor_list[23];
2851 ITEM_NUMBER floor_num = 0;
2853 /* Scan all objects in the grid */
2856 floor_num = scan_floor(floor_list, y, x, 0x02);
2860 x_info = _("x物 ", "x,");
2864 /* Hack -- under the player */
2865 if (player_bold(y, x))
2881 s1 = _("ターゲット:", "Target:");
2884 /* Hack -- hallucination */
2887 cptr name = _("何か奇妙な物", "something strange");
2889 /* Display a message */
2891 sprintf(out_val, "%s%s%s%s [%s]", s1, name, s2, s3, info);
2893 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, name, info);
2897 move_cursor_relative(y, x);
2900 /* Stop on everything but "return" */
2901 if ((query != '\r') && (query != '\n')) return query;
2903 /* Repeat forever */
2908 /* Actual monsters */
2909 if (c_ptr->m_idx && m_list[c_ptr->m_idx].ml)
2911 monster_type *m_ptr = &m_list[c_ptr->m_idx];
2912 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
2914 bool recall = FALSE;
2919 /* Get the monster name ("a kobold") */
2920 monster_desc(m_name, m_ptr, MD_INDEF_VISIBLE);
2922 /* Hack -- track this monster race */
2923 monster_race_track(m_ptr->ap_r_idx);
2925 /* Hack -- health bar for this monster */
2926 health_track(c_ptr->m_idx);
2940 /* Recall on screen */
2941 screen_roff(m_ptr->ap_r_idx, 0);
2943 /* Hack -- Complete the prompt (again) */
2944 Term_addstr(-1, TERM_WHITE, format(_(" [r思 %s%s]", " [r,%s%s]"), x_info, info));
2952 /* Normal commands */
2953 if (query != 'r') break;
2958 /* Cleare recall text and repeat */
2964 /* Describe, and prompt for recall */
2965 evaluate_monster_exp(acount, m_ptr);
2968 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);
2970 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);
2976 move_cursor_relative(y, x);
2981 /* Normal commands */
2982 if (query != 'r') break;
2988 /* Always stop at "normal" keys */
2989 if ((query != '\r') && (query != '\n') && (query != ' ') && (query != 'x')) return query;
2991 /* Sometimes stop at "space" key */
2992 if ((query == ' ') && !(mode & (TARGET_LOOK))) return query;
2994 /* Change the intro */
2995 s1 = _("それは", "It is ");
2997 /* Hack -- take account of gender */
2998 if (ap_r_ptr->flags1 & (RF1_FEMALE)) s1 = _("彼女は", "She is ");
2999 else if (ap_r_ptr->flags1 & (RF1_MALE)) s1 = _("彼は", "He is ");
3001 /* Use a preposition */
3010 /* Scan all objects being carried */
3011 for (this_o_idx = m_ptr->hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
3013 char o_name[MAX_NLEN];
3016 o_ptr = &o_list[this_o_idx];
3018 /* Acquire next object */
3019 next_o_idx = o_ptr->next_o_idx;
3021 /* Obtain an object description */
3022 object_desc(o_name, o_ptr, 0);
3025 sprintf(out_val, "%s%s%s%s[%s]", s1, o_name, s2, s3, info);
3027 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, o_name, info);
3031 move_cursor_relative(y, x);
3034 /* Always stop at "normal" keys */
3035 if ((query != '\r') && (query != '\n') && (query != ' ') && (query != 'x')) return query;
3037 /* Sometimes stop at "space" key */
3038 if ((query == ' ') && !(mode & (TARGET_LOOK))) return query;
3040 /* Change the intro */
3041 s2 = _("をまた", "also carrying ");
3044 /* Use a preposition */
3061 char o_name[MAX_NLEN];
3064 o_ptr = &o_list[floor_list[0]];
3066 object_desc(o_name, o_ptr, 0);
3069 sprintf(out_val, "%s%s%s%s[%s]", s1, o_name, s2, s3, info);
3071 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, o_name, info);
3075 move_cursor_relative(y, x);
3084 /* Provide one cushion before item listing */
3087 /* Display rough information about items */
3089 sprintf(out_val, "%s %d個のアイテム%s%s ['x'で一覧, %s]", s1, (int)floor_num, s2, s3, info);
3091 sprintf(out_val, "%s%s%sa pile of %d items [x,%s]", s1, s2, s3, (int)floor_num, info);
3095 move_cursor_relative(y, x);
3100 /* No request for listing */
3101 if (query != 'x' && query != ' ') return query;
3105 /** Display list of items **/
3107 /* Continue scrolling list if requested */
3115 show_gold_on_floor = TRUE;
3116 (void)show_floor(0, y, x, &min_width);
3117 show_gold_on_floor = FALSE;
3121 sprintf(out_val, "%s %d個のアイテム%s%s [Enterで次へ, %s]", s1, (int)floor_num, s2, s3, info);
3123 sprintf(out_val, "%s%s%sa pile of %d items [Enter,%s]", s1, s2, s3, (int)floor_num, info);
3130 /* Exit unless 'Enter' */
3131 if (query != '\n' && query != '\r')
3136 /* Get the object being moved. */
3137 o_idx = c_ptr->o_idx;
3139 /* Only rotate a pile of two or more objects. */
3140 if (!(o_idx && o_list[o_idx].next_o_idx)) continue;
3142 /* Remove the first object from the list. */
3143 excise_object_idx(o_idx);
3145 /* Find end of the list. */
3147 while (o_list[i].next_o_idx)
3148 i = o_list[i].next_o_idx;
3150 /* Add after the last object. */
3151 o_list[i].next_o_idx = o_idx;
3153 /* Loop and re-display the list */
3160 /* Scan all objects in the grid */
3161 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
3164 o_ptr = &o_list[this_o_idx];
3166 /* Acquire next object */
3167 next_o_idx = o_ptr->next_o_idx;
3170 if (o_ptr->marked & OM_FOUND)
3172 char o_name[MAX_NLEN];
3177 /* Obtain an object description */
3178 object_desc(o_name, o_ptr, 0);
3181 sprintf(out_val, "%s%s%s%s[%s]", s1, o_name, s2, s3, info);
3183 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, o_name, info);
3187 move_cursor_relative(y, x);
3190 /* Always stop at "normal" keys */
3191 if ((query != '\r') && (query != '\n') && (query != ' ') && (query != 'x')) return query;
3193 /* Sometimes stop at "space" key */
3194 if ((query == ' ') && !(mode & TARGET_LOOK)) return query;
3196 /* Change the intro */
3197 s1 = _("それは", "It is ");
3200 if (o_ptr->number != 1) s1 = _("それらは", "They are ");
3214 /* Feature code (applying "mimic" field) */
3215 feat = get_feat_mimic(c_ptr);
3217 /* Require knowledge about grid, or ability to see grid */
3218 if (!(c_ptr->info & CAVE_MARK) && !player_can_see_bold(y, x))
3220 /* Forget feature */
3224 f_ptr = &f_info[feat];
3226 /* Terrain feature if needed */
3227 if (boring || have_flag(f_ptr->flags, FF_REMEMBER))
3231 /* Hack -- special handling for quest entrances */
3232 if (have_flag(f_ptr->flags, FF_QUEST_ENTER))
3234 /* Set the quest number temporary */
3235 IDX old_quest = p_ptr->inside_quest;
3238 /* Clear the text */
3239 for (j = 0; j < 10; j++) quest_text[j][0] = '\0';
3240 quest_text_line = 0;
3242 p_ptr->inside_quest = c_ptr->special;
3244 /* Get the quest text */
3245 init_flags = INIT_NAME_ONLY;
3247 process_dungeon_file("q_info.txt", 0, 0, 0, 0);
3249 name = format(_("クエスト「%s」(%d階相当)", "the entrance to the quest '%s'(level %d)"),
3250 quest[c_ptr->special].name, quest[c_ptr->special].level);
3252 /* Reset the old quest number */
3253 p_ptr->inside_quest = old_quest;
3256 /* Hack -- special handling for building doors */
3257 else if (have_flag(f_ptr->flags, FF_BLDG) && !p_ptr->inside_arena)
3259 name = building[f_ptr->subtype].name;
3261 else if (have_flag(f_ptr->flags, FF_ENTRANCE))
3263 name = format(_("%s(%d階相当)", "%s(level %d)"), d_text + d_info[c_ptr->special].text, d_info[c_ptr->special].mindepth);
3265 else if (have_flag(f_ptr->flags, FF_TOWN))
3267 name = town[c_ptr->special].name;
3269 else if (p_ptr->wild_mode && (feat == feat_floor))
3271 name = _("道", "road");
3275 name = f_name + f_ptr->name;
3281 ((!have_flag(f_ptr->flags, FF_MOVE) && !have_flag(f_ptr->flags, FF_CAN_FLY)) ||
3282 (!have_flag(f_ptr->flags, FF_LOS) && !have_flag(f_ptr->flags, FF_TREE)) ||
3283 have_flag(f_ptr->flags, FF_TOWN)))
3285 s2 = _("の中", "in ");
3288 /* Hack -- special introduction for store & building doors -KMW- */
3289 if (have_flag(f_ptr->flags, FF_STORE) ||
3290 have_flag(f_ptr->flags, FF_QUEST_ENTER) ||
3291 (have_flag(f_ptr->flags, FF_BLDG) && !p_ptr->inside_arena) ||
3292 have_flag(f_ptr->flags, FF_ENTRANCE))
3301 else if (have_flag(f_ptr->flags, FF_FLOOR) ||
3302 have_flag(f_ptr->flags, FF_TOWN) ||
3303 have_flag(f_ptr->flags, FF_SHALLOW) ||
3304 have_flag(f_ptr->flags, FF_DEEP))
3310 /* Pick proper indefinite article */
3311 s3 = (is_a_vowel(name[0])) ? "an " : "a ";
3315 /* Display a message */
3319 if (c_ptr->mimic) sprintf(f_idx_str, "%d/%d", c_ptr->feat, c_ptr->mimic);
3320 else sprintf(f_idx_str, "%d", c_ptr->feat);
3322 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]);
3324 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);
3329 sprintf(out_val, "%s%s%s%s[%s]", s1, name, s2, s3, info);
3331 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, name, info);
3335 move_cursor_relative(y, x);
3338 /* Always stop at "normal" keys */
3339 if ((query != '\r') && (query != '\n') && (query != ' ')) return query;
3342 /* Stop on everything but "return" */
3343 if ((query != '\r') && (query != '\n')) return query;
3345 /* Repeat forever */
3351 * Handle "target" and "look".
3353 * Note that this code can be called from "get_aim_dir()".
3355 * All locations must be on the current panel. Consider the use of
3356 * "panel_bounds()" to allow "off-panel" targets, perhaps by using
3357 * some form of "scrolling" the map around the cursor.
3358 * That is, consider the possibility of "auto-scrolling" the screen
3359 * while the cursor moves around. This may require changes in the
3360 * "update_monster()" code to allow "visibility" even if off panel, and
3361 * may require dynamic recalculation of the "temp" grid set.
3363 * Hack -- targeting/observing an "outer border grid" may induce
3364 * problems, so this is not currently allowed.
3366 * The player can use the direction keys to move among "interesting"
3367 * grids in a heuristic manner, or the "space", "+", and "-" keys to
3368 * move through the "interesting" grids in a sequential manner, or
3369 * can enter "location" mode, and use the direction keys to move one
3370 * grid at a time in any direction. The "t" (set target) command will
3371 * only target a monster (as opposed to a location) if the monster is
3372 * target_able and the "interesting" mode is being used.
3374 * The current grid is described using the "look" method above, and
3375 * a new command may be entered at any time, but note that if the
3376 * "TARGET_LOOK" bit flag is set (or if we are in "location" mode,
3377 * where "space" has no obvious meaning) then "space" will scan
3378 * through the description of the current grid until done, instead
3379 * of immediately jumping to the next "interesting" grid. This
3380 * allows the "target" command to retain its old semantics.
3382 * The "*", "+", and "-" keys may always be used to jump immediately
3383 * to the next (or previous) interesting grid, in the proper mode.
3385 * The "return" key may always be used to scan through a complete
3386 * grid description (forever).
3388 * This command will cancel any old target, even if used from
3389 * inside the "look" command.
3391 bool target_set(BIT_FLAGS mode)
3394 POSITION y = p_ptr->y;
3395 POSITION x = p_ptr->x;
3407 get_screen_size(&wid, &hgt);
3413 /* Cancel tracking */
3414 /* health_track(0); */
3416 if (rogue_like_commands)
3425 /* Prepare the "temp" array */
3426 target_set_prepare(mode);
3428 /* Start near the player */
3434 /* Interesting grids */
3441 change_panel_xy(y, x);
3443 if (!(mode & TARGET_LOOK)) prt_path(y, x);
3446 c_ptr = &cave[y][x];
3449 if (target_able(c_ptr->m_idx))
3451 strcpy(info, _("q止 t決 p自 o現 +次 -前", "q,t,p,o,+,-,<dir>"));
3454 /* Dis-allow target */
3457 strcpy(info, _("q止 p自 o現 +次 -前", "q,p,o,+,-,<dir>"));
3463 sprintf(cheatinfo, " LOS:%d, PROJECTABLE:%d",
3464 los(p_ptr->y, p_ptr->x, y, x),
3465 projectable(p_ptr->y, p_ptr->x, y, x));
3466 strcat(info, cheatinfo);
3469 /* Describe and Prompt */
3471 query = target_set_aux(y, x, mode, info);
3475 /* Cancel tracking */
3476 /* health_track(0); */
3478 /* Assume no "direction" */
3483 if (query == '\r') query = 't';
3501 if (target_able(c_ptr->m_idx))
3503 health_track(c_ptr->m_idx);
3504 target_who = c_ptr->m_idx;
3523 if (!expand_list) done = TRUE;
3533 if (!expand_list) done = TRUE;
3540 /* Recenter the map around the player */
3543 p_ptr->update |= (PU_MONSTERS);
3545 p_ptr->redraw |= (PR_MAP);
3547 p_ptr->window |= (PW_OVERHEAD);
3550 /* Recalculate interesting grids */
3551 target_set_prepare(mode);
3570 if(query == same_key)
3575 if (!expand_list) done = TRUE;
3580 /* Extract the action (if any) */
3581 d = get_keymap_dir(query);
3588 /* Hack -- move around */
3591 /* Modified to scroll to monster */
3592 POSITION y2 = panel_row_min;
3593 POSITION x2 = panel_col_min;
3595 /* Find a new monster */
3596 i = target_pick(temp_y[m], temp_x[m], ddy[d], ddx[d]);
3598 /* Request to target past last interesting grid */
3599 while (flag && (i < 0))
3601 /* Note the change */
3602 if (change_panel(ddy[d], ddx[d]))
3607 /* Recalculate interesting grids */
3608 target_set_prepare(mode);
3610 /* Look at interesting grids */
3613 /* Find a new monster */
3614 i = target_pick(v, u, ddy[d], ddx[d]);
3620 /* Nothing interesting */
3626 /* Restore previous position */
3629 panel_bounds_center();
3631 p_ptr->update |= (PU_MONSTERS);
3633 p_ptr->redraw |= (PR_MAP);
3635 p_ptr->window |= (PW_OVERHEAD);
3638 /* Recalculate interesting grids */
3639 target_set_prepare(mode);
3641 /* Look at boring grids */
3648 /* Do not move horizontally if unnecessary */
3649 if (((x < panel_col_min + wid / 2) && (dx > 0)) ||
3650 ((x > panel_col_min + wid / 2) && (dx < 0)))
3655 /* Do not move vertically if unnecessary */
3656 if (((y < panel_row_min + hgt / 2) && (dy > 0)) ||
3657 ((y > panel_row_min + hgt / 2) && (dy < 0)))
3662 /* Apply the motion */
3663 if ((y >= panel_row_min+hgt) || (y < panel_row_min) ||
3664 (x >= panel_col_min+wid) || (x < panel_col_min))
3666 if (change_panel(dy, dx)) target_set_prepare(mode);
3669 /* Slide into legality */
3670 if (x >= cur_wid-1) x = cur_wid - 2;
3671 else if (x <= 0) x = 1;
3673 /* Slide into legality */
3674 if (y >= cur_hgt-1) y = cur_hgt- 2;
3675 else if (y <= 0) y = 1;
3684 /* Arbitrary grids */
3687 bool move_fast = FALSE;
3689 if (!(mode & TARGET_LOOK)) prt_path(y, x);
3692 c_ptr = &cave[y][x];
3694 /* Default prompt */
3695 strcpy(info, _("q止 t決 p自 m近 +次 -前", "q,t,p,m,+,-,<dir>"));
3700 sprintf(cheatinfo, " LOS:%d, PROJECTABLE:%d",
3701 los(p_ptr->y, p_ptr->x, y, x),
3702 projectable(p_ptr->y, p_ptr->x, y, x));
3703 strcat(info, cheatinfo);
3706 /* Describe and Prompt (enable "TARGET_LOOK") */
3707 while ((query = target_set_aux(y, x, mode | TARGET_LOOK, info)) == 0);
3709 /* Cancel tracking */
3710 /* health_track(0); */
3712 /* Assume no direction */
3717 if (query == '\r') query = 't';
3720 /* Analyze the keypress */
3744 /* Recenter the map around the player */
3747 p_ptr->update |= (PU_MONSTERS);
3749 p_ptr->redraw |= (PR_MAP);
3751 p_ptr->window |= (PW_OVERHEAD);
3754 /* Recalculate interesting grids */
3755 target_set_prepare(mode);
3777 /* Pick a nearby monster */
3778 for (i = 0; i < temp_n; i++)
3780 t = distance(y, x, temp_y[i], temp_x[i]);
3790 /* Nothing interesting */
3791 if (bd == 999) flag = FALSE;
3798 /* Extract the action (if any) */
3799 d = get_keymap_dir(query);
3801 /* XTRA HACK MOVEFAST */
3802 if (isupper(query)) move_fast = TRUE;
3809 /* Handle "direction" */
3815 /* XTRA HACK MOVEFAST */
3818 int mag = MIN(wid / 2, hgt / 2);
3828 /* Do not move horizontally if unnecessary */
3829 if (((x < panel_col_min + wid / 2) && (dx > 0)) ||
3830 ((x > panel_col_min + wid / 2) && (dx < 0)))
3835 /* Do not move vertically if unnecessary */
3836 if (((y < panel_row_min + hgt / 2) && (dy > 0)) ||
3837 ((y > panel_row_min + hgt / 2) && (dy < 0)))
3842 /* Apply the motion */
3843 if ((y >= panel_row_min + hgt) || (y < panel_row_min) ||
3844 (x >= panel_col_min + wid) || (x < panel_col_min))
3846 if (change_panel(dy, dx)) target_set_prepare(mode);
3849 /* Slide into legality */
3850 if (x >= cur_wid-1) x = cur_wid - 2;
3851 else if (x <= 0) x = 1;
3853 /* Slide into legality */
3854 if (y >= cur_hgt-1) y = cur_hgt- 2;
3855 else if (y <= 0) y = 1;
3863 /* Clear the top line */
3866 /* Recenter the map around the player */
3869 p_ptr->update |= (PU_MONSTERS);
3871 p_ptr->redraw |= (PR_MAP);
3873 p_ptr->window |= (PW_OVERHEAD);
3876 /* Failure to set target */
3877 if (!target_who) return (FALSE);
3885 * Get an "aiming direction" from the user.
3887 * The "dir" is loaded with 1,2,3,4,6,7,8,9 for "actual direction", and
3888 * "0" for "current target", and "-1" for "entry aborted".
3890 * Note that "Force Target", if set, will pre-empt user interaction,
3891 * if there is a usable target already set.
3893 * Note that confusion over-rides any (explicit?) user choice.
3895 bool get_aim_dir(DIRECTION *dp)
3904 /* Global direction */
3907 /* Hack -- auto-target if requested */
3908 if (use_old_target && target_okay()) dir = 5;
3910 if (repeat_pull(&code))
3915 if (!(code == 5 && !target_okay()))
3917 /* return (TRUE); */
3918 dir = (DIRECTION)code;
3921 *dp = (DIRECTION)code;
3923 /* Ask until satisfied */
3926 /* Choose a prompt */
3929 p = _("方向 ('*'でターゲット選択, ESCで中断)? ", "Direction ('*' to choose a target, Escape to cancel)? ");
3933 p = _("方向 ('5'でターゲットへ, '*'でターゲット再選択, ESCで中断)? ", "Direction ('5' for target, '*' to re-target, Escape to cancel)? ");
3936 /* Get a command (or Cancel) */
3937 if (!get_com(p, &command, TRUE)) break;
3941 if (command == '\r') command = 't';
3944 /* Convert various keys to "standard" keys */
3947 /* Use current target */
3958 /* Set new target */
3963 if (target_set(TARGET_KILL)) dir = 5;
3969 /* Extract the action (if any) */
3970 dir = get_keymap_dir(command);
3976 /* Verify requested targets */
3977 if ((dir == 5) && !target_okay()) dir = 0;
3986 project_length = 0; /* reset to default */
3990 /* Save the direction */
3993 /* Check for confusion */
3994 if (p_ptr->confused)
3996 /* Random direction */
3997 dir = ddd[randint0(8)];
4000 /* Notice confusion */
4001 if (command_dir != dir)
4004 msg_print(_("あなたは混乱している。", "You are confused."));
4007 /* Save direction */
4010 /* repeat_push(dir); */
4011 repeat_push((COMMAND_CODE)command_dir);
4013 /* A "valid" direction was entered */
4018 bool get_direction(DIRECTION *dp, bool allow_under, bool with_steed)
4026 /* Global direction */
4029 if (repeat_pull(&code))
4031 dir = (DIRECTION)code;
4032 /* return (TRUE); */
4034 *dp = (DIRECTION)code;
4038 prompt = _("方向 ('.'足元, ESCで中断)? ", "Direction ('.' at feet, Escape to cancel)? ");
4042 prompt = _("方向 (ESCで中断)? ", "Direction (Escape to cancel)? ");
4045 /* Get a direction */
4050 /* Get a command (or Cancel) */
4051 if (!get_com(prompt, &ch, TRUE)) break;
4054 if ((allow_under) && ((ch == '5') || (ch == '-') || (ch == '.')))
4060 /* Look up the direction */
4061 dir = get_keymap_dir(ch);
4067 /* Prevent weirdness */
4068 if ((dir == 5) && (!allow_under)) dir = 0;
4071 if (!dir) return (FALSE);
4073 /* Save desired direction */
4076 /* Apply "confusion" */
4077 if (p_ptr->confused)
4079 /* Standard confusion */
4080 if (randint0(100) < 75)
4082 /* Random direction */
4083 dir = ddd[randint0(8)];
4086 else if (p_ptr->riding && with_steed)
4088 monster_type *m_ptr = &m_list[p_ptr->riding];
4089 monster_race *r_ptr = &r_info[m_ptr->r_idx];
4091 if (MON_CONFUSED(m_ptr))
4093 /* Standard confusion */
4094 if (randint0(100) < 75)
4096 /* Random direction */
4097 dir = ddd[randint0(8)];
4100 else if ((r_ptr->flags1 & RF1_RAND_50) && (r_ptr->flags1 & RF1_RAND_25) && (randint0(100) < 50))
4102 /* Random direction */
4103 dir = ddd[randint0(8)];
4105 else if ((r_ptr->flags1 & RF1_RAND_50) && (randint0(100) < 25))
4107 /* Random direction */
4108 dir = ddd[randint0(8)];
4112 /* Notice confusion */
4113 if (command_dir != dir)
4115 if (p_ptr->confused)
4118 msg_print(_("あなたは混乱している。", "You are confused."));
4123 monster_type *m_ptr = &m_list[p_ptr->riding];
4125 monster_desc(m_name, m_ptr, 0);
4126 if (MON_CONFUSED(m_ptr))
4128 msg_format(_("%sは混乱している。", "%^s is confusing."), m_name);
4132 msg_format(_("%sは思い通りに動いてくれない。", "You cannot control %s."), m_name);
4137 /* Save direction */
4140 /* repeat_push(dir); */
4141 repeat_push((COMMAND_CODE)command_dir);
4148 * @brief 進行方向を指定する(騎乗対象の混乱の影響を受ける) / Request a "movement" direction (1,2,3,4,6,7,8,9) from the user,
4149 * and place it into "command_dir", unless we already have one.
4151 * This function should be used for all "repeatable" commands, such as
4152 * run, walk, open, close, bash, disarm, spike, tunnel, etc, as well
4153 * as all commands which must reference a grid adjacent to the player,
4154 * and which may not reference the grid under the player. Note that,
4155 * for example, it is no longer possible to "disarm" or "open" chests
4156 * in the same grid as the player.
4158 * Direction "5" is illegal and will (cleanly) abort the command.
4160 * This function tracks and uses the "global direction", and uses
4161 * that as the "desired direction", to which "confusion" is applied.
4163 bool get_rep_dir(DIRECTION *dp, bool under)
4171 /* Global direction */
4174 if (repeat_pull(&code))
4176 dir = (DIRECTION)code;
4177 /* return (TRUE); */
4179 *dp = (DIRECTION)code;
4183 prompt = _("方向 ('.'足元, ESCで中断)? ", "Direction ('.' at feet, Escape to cancel)? ");
4187 prompt = _("方向 (ESCで中断)? ", "Direction (Escape to cancel)? ");
4190 /* Get a direction */
4195 /* Get a command (or Cancel) */
4196 if (!get_com(prompt, &ch, TRUE)) break;
4199 if ((under) && ((ch == '5') || (ch == '-') || (ch == '.')))
4205 /* Look up the direction */
4206 dir = get_keymap_dir(ch);
4212 /* Prevent weirdness */
4213 if ((dir == 5) && (!under)) dir = 0;
4216 if (!dir) return (FALSE);
4218 /* Save desired direction */
4221 /* Apply "confusion" */
4222 if (p_ptr->confused)
4224 /* Standard confusion */
4225 if (randint0(100) < 75)
4227 /* Random direction */
4228 dir = ddd[randint0(8)];
4231 else if (p_ptr->riding)
4233 monster_type *m_ptr = &m_list[p_ptr->riding];
4234 monster_race *r_ptr = &r_info[m_ptr->r_idx];
4236 if (MON_CONFUSED(m_ptr))
4238 /* Standard confusion */
4239 if (randint0(100) < 75)
4241 /* Random direction */
4242 dir = ddd[randint0(8)];
4245 else if ((r_ptr->flags1 & RF1_RAND_50) && (r_ptr->flags1 & RF1_RAND_25) && (randint0(100) < 50))
4247 /* Random direction */
4248 dir = ddd[randint0(8)];
4250 else if ((r_ptr->flags1 & RF1_RAND_50) && (randint0(100) < 25))
4252 /* Random direction */
4253 dir = ddd[randint0(8)];
4257 /* Notice confusion */
4258 if (command_dir != dir)
4260 if (p_ptr->confused)
4263 msg_print(_("あなたは混乱している。", "You are confused."));
4268 monster_type *m_ptr = &m_list[p_ptr->riding];
4270 monster_desc(m_name, m_ptr, 0);
4271 if (MON_CONFUSED(m_ptr))
4273 msg_format(_("%sは混乱している。", "%^s is confusing."), m_name);
4277 msg_format(_("%sは思い通りに動いてくれない。", "You cannot control %s."), m_name);
4282 /* Save direction */
4285 /* repeat_push(dir); */
4286 repeat_push((COMMAND_CODE)command_dir);
4292 void gain_level_reward(int chosen_reward)
4296 char wrath_reason[32] = "";
4297 int nasty_chance = 6;
4298 OBJECT_TYPE_VALUE dummy = 0;
4299 OBJECT_SUBTYPE_VALUE dummy2 = 0;
4302 char o_name[MAX_NLEN];
4308 if (multi_rew) return;
4309 else multi_rew = TRUE;
4313 if (p_ptr->lev == 13) nasty_chance = 2;
4314 else if (!(p_ptr->lev % 13)) nasty_chance = 3;
4315 else if (!(p_ptr->lev % 14)) nasty_chance = 12;
4317 if (one_in_(nasty_chance))
4318 type = randint1(20); /* Allow the 'nasty' effects */
4320 type = randint1(15) + 5; /* Or disallow them */
4322 if (type < 1) type = 1;
4323 if (type > 20) type = 20;
4327 sprintf(wrath_reason, _("%sの怒り", "the Wrath of %s"), chaos_patrons[p_ptr->chaos_patron]);
4329 effect = chaos_rewards[p_ptr->chaos_patron][type];
4331 if (one_in_(6) && !chosen_reward)
4333 msg_format(_("%^sは褒美としてあなたを突然変異させた。", "%^s rewards you with a mutation!"), chaos_patrons[p_ptr->chaos_patron]);
4334 (void)gain_random_mutation(0);
4335 reward = _("変異した。", "mutation");
4339 switch (chosen_reward ? chosen_reward : effect)
4344 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4345 msg_print(_("「汝、新たなる姿を必要とせり!」", "'Thou needst a new form, mortal!'"));
4348 reward = _("変異した。", "polymorphing");
4353 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4354 msg_print(_("「汝は良く行いたり!続けよ!」", "'Well done, mortal! Lead on!'"));
4356 if (p_ptr->prace == RACE_ANDROID)
4358 msg_print(_("しかし何も起こらなかった。", "But, nothing happen."));
4360 else if (p_ptr->exp < PY_MAX_EXP)
4362 s32b ee = (p_ptr->exp / 2) + 10;
4363 if (ee > 100000L) ee = 100000L;
4364 msg_print(_("更に経験を積んだような気がする。", "You feel more experienced."));
4367 reward = _("経験値を得た", "experience");
4373 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4374 msg_print(_("「下僕よ、汝それに値せず。」", "'Thou didst not deserve that, slave.'"));
4376 if (p_ptr->prace == RACE_ANDROID)
4378 msg_print(_("しかし何も起こらなかった。", "But, nothing happen."));
4382 lose_exp(p_ptr->exp / 6);
4383 reward = _("経験値を失った。", "losing experience");
4389 msg_format("%sの声がささやいた:",
4390 chaos_patrons[p_ptr->chaos_patron]);
4392 msg_format("The voice of %s whispers:",
4393 chaos_patrons[p_ptr->chaos_patron]);
4396 msg_print(_("「我が与えし物を賢明に使うべし。」", "'Use my gift wisely.'"));
4398 acquirement(p_ptr->y, p_ptr->x, 1, FALSE, FALSE, FALSE);
4399 reward = _("上質なアイテムを手に入れた。", "a good item");
4404 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4405 msg_print(_("「我が与えし物を賢明に使うべし。」", "'Use my gift wisely.'"));
4407 acquirement(p_ptr->y, p_ptr->x, 1, TRUE, FALSE, FALSE);
4408 reward = _("高級品のアイテムを手に入れた。", "an excellent item");
4413 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4414 msg_print(_("「汝の行いは貴き剣に値せり。」", "'Thy deed hath earned thee a worthy blade.'"));
4417 switch (randint1(p_ptr->lev))
4423 dummy2 = SV_MAIN_GAUCHE;
4432 dummy2 = SV_SMALL_SWORD;
4435 dummy2 = SV_BASILLARD;
4437 case 11: case 12: case 13:
4438 dummy2 = SV_SHORT_SWORD;
4444 dummy2 = SV_CUTLASS;
4447 dummy2 = SV_WAKIZASHI;
4450 dummy2 = SV_KHOPESH;
4456 dummy2 = SV_BROAD_SWORD;
4459 dummy2 = SV_LONG_SWORD;
4462 dummy2 = SV_SCIMITAR;
4465 dummy2 = SV_NINJATO;
4471 dummy2 = SV_BASTARD_SWORD;
4474 dummy2 = SV_GREAT_SCIMITAR;
4477 dummy2 = SV_CLAYMORE;
4480 dummy2 = SV_ESPADON;
4483 dummy2 = SV_TWO_HANDED_SWORD;
4486 dummy2 = SV_FLAMBERGE;
4489 dummy2 = SV_NO_DACHI;
4492 dummy2 = SV_EXECUTIONERS_SWORD;
4495 dummy2 = SV_ZWEIHANDER;
4498 dummy2 = SV_HAYABUSA;
4501 dummy2 = SV_BLADE_OF_CHAOS;
4504 object_prep(q_ptr, lookup_kind(dummy, dummy2));
4505 q_ptr->to_h = 3 + randint1(dun_level) % 10;
4506 q_ptr->to_d = 3 + randint1(dun_level) % 10;
4507 one_resistance(q_ptr);
4508 q_ptr->name2 = EGO_CHAOTIC;
4510 /* Drop it in the dungeon */
4511 (void)drop_near(q_ptr, -1, p_ptr->y, p_ptr->x);
4512 reward = _("(混沌)の武器を手に入れた。", "chaos weapon");
4517 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4518 msg_print(_("「汝の行いは貴き報いに値せり。」", "'Thy deed hath earned thee a worthy reward.'"));
4520 acquirement(p_ptr->y, p_ptr->x, randint1(2) + 1, FALSE, FALSE, FALSE);
4521 reward = _("上質なアイテムを手に入れた。", "good items");
4526 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4527 msg_print(_("「下僕よ、汝の献身への我が惜しみ無き報いを見るがよい。」", "'Behold, mortal, how generously I reward thy loyalty.'"));
4529 acquirement(p_ptr->y, p_ptr->x, randint1(2) + 1, TRUE, FALSE, FALSE);
4530 reward = _("高級品のアイテムを手に入れた。", "excellent items");
4535 msg_format("%sの声が轟き渡った:", chaos_patrons[p_ptr->chaos_patron]);
4537 msg_format("The voice of %s thunders:", chaos_patrons[p_ptr->chaos_patron]);
4540 msg_print(_("「下僕よ、汝傲慢なり。」", "'Thou art growing arrogant, mortal.'"));
4542 (void)activate_ty_curse(FALSE, &count);
4543 reward = _("禍々しい呪いをかけられた。", "cursing");
4548 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4549 msg_print(_("「我が下僕たちよ、かの傲慢なる者を倒すべし!」", "'My pets, destroy the arrogant mortal!'"));
4551 for (dummy = 0; dummy < randint1(5) + 1; dummy++)
4553 (void)summon_specific(0, p_ptr->y, p_ptr->x, dun_level, 0, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET));
4555 reward = _("モンスターを召喚された。", "summoning hostile monsters");
4561 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4562 msg_print(_("「汝、より強き敵を必要とせり!」", "'Thou needst worthier opponents!'"));
4564 activate_hi_summon(p_ptr->y, p_ptr->x, FALSE);
4565 reward = _("モンスターを召喚された。", "summoning many hostile monsters");
4571 msg_format("%sの声が響き渡った:",
4572 chaos_patrons[p_ptr->chaos_patron]);
4574 msg_format("The voice of %s booms out:",
4575 chaos_patrons[p_ptr->chaos_patron]);
4578 msg_print(_("「死と破壊こそ我が喜びなり!」", "'Death and destruction! This pleaseth me!'"));
4581 reward = _("カオスの力が渦巻いた。", "calling chaos");
4587 msg_format("%sの声が鳴り響いた:",
4588 chaos_patrons[p_ptr->chaos_patron]);
4590 msg_format("The voice of %s rings out:",
4591 chaos_patrons[p_ptr->chaos_patron]);
4594 msg_print(_("「留まるのだ、下僕よ。余が汝の肉体を鍛えん。」", "'Stay, mortal, and let me mold thee.'"));
4596 if (one_in_(3) && !(chaos_stats[p_ptr->chaos_patron] < 0))
4597 do_inc_stat(chaos_stats[p_ptr->chaos_patron]);
4599 do_inc_stat(randint0(6));
4600 reward = _("能力値が上がった。", "increasing a stat");
4606 msg_format("%sの声が響き渡った:",
4607 chaos_patrons[p_ptr->chaos_patron]);
4609 msg_format("The voice of %s booms out:",
4610 chaos_patrons[p_ptr->chaos_patron]);
4613 msg_print(_("「下僕よ、余は汝に飽みたり。」", "'I grow tired of thee, mortal.'"));
4615 if (one_in_(3) && !(chaos_stats[p_ptr->chaos_patron] < 0))
4616 do_dec_stat(chaos_stats[p_ptr->chaos_patron]);
4618 (void)do_dec_stat(randint0(6));
4619 reward = _("能力値が下がった。", "decreasing a stat");
4626 msg_format("%sの声が轟き渡った:",
4627 chaos_patrons[p_ptr->chaos_patron]);
4629 msg_format("The voice of %s thunders:",
4630 chaos_patrons[p_ptr->chaos_patron]);
4633 msg_print(_("「汝、謙虚たることを学ぶべし!」", "'Thou needst a lesson in humility, mortal!'"));
4634 msg_print(_("あなたは以前より弱くなった!", "You feel less powerful!"));
4636 for (dummy = 0; dummy < 6; dummy++)
4638 (void)dec_stat(dummy, 10 + randint1(15), TRUE);
4640 reward = _("全能力値が下がった。", "decreasing all stats");
4645 msg_format(_("%sの力が触れるのを感じた。", "You feel the power of %s touch you."),
4646 chaos_patrons[p_ptr->chaos_patron]);
4648 reward = _("傷が変化した。", "polymorphing wounds");
4653 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4655 msg_print(_("「我がささやかなる賜物を受けとるがよい!」", "'Receive this modest gift from me!'"));
4657 for (dummy = 0; dummy < 6; dummy++)
4659 (void)do_inc_stat(dummy);
4661 reward = _("全能力値が上がった。", "increasing all stats");
4666 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4667 msg_print(_("「苦しむがよい、無能な愚か者よ!」", "'Suffer, pathetic fool!'"));
4669 fire_ball(GF_DISINTEGRATE, 0, p_ptr->lev * 4, 4);
4670 take_hit(DAMAGE_NOESCAPE, p_ptr->lev * 4, wrath_reason, -1);
4671 reward = _("分解の球が発生した。", "generating disintegration ball");
4676 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4677 (void)restore_level();
4678 (void)restore_all_status();
4679 (void)true_healing(5000);
4680 reward = _("体力が回復した。", "healing");
4685 if (!buki_motteruka(INVEN_RARM) && !buki_motteruka(INVEN_LARM)) break;
4686 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4687 msg_print(_("「汝、武器に頼ることなかれ。」", "'Thou reliest too much on thy weapon.'"));
4690 if (buki_motteruka(INVEN_LARM))
4693 if (buki_motteruka(INVEN_RARM) && one_in_(2)) dummy = INVEN_RARM;
4695 object_desc(o_name, &inventory[dummy], OD_NAME_ONLY);
4696 (void)curse_weapon(FALSE, dummy);
4697 reward = format(_("%sが破壊された。", "destroying %s"), o_name);
4702 if (!inventory[INVEN_BODY].k_idx) break;
4703 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4704 msg_print(_("「汝、防具に頼ることなかれ。」", "'Thou reliest too much on thine equipment.'"));
4706 object_desc(o_name, &inventory[INVEN_BODY], OD_NAME_ONLY);
4707 (void)curse_armor();
4708 reward = format(_("%sが破壊された。", "destroying %s"), o_name);
4712 msg_format(_("%sの声がささやいた:", "The voice of %s whispers:"), chaos_patrons[p_ptr->chaos_patron]);
4713 msg_print(_("「我を怒りしめた罪を償うべし。」", "'Now thou shalt pay for annoying me.'"));
4715 switch (randint1(4))
4718 (void)activate_ty_curse(FALSE, &count);
4719 reward = _("禍々しい呪いをかけられた。", "cursing");
4722 activate_hi_summon(p_ptr->y, p_ptr->x, FALSE);
4723 reward = _("モンスターを召喚された。", "summoning hostile monsters");
4728 if (!buki_motteruka(INVEN_RARM) && !buki_motteruka(INVEN_LARM)) break;
4730 if (buki_motteruka(INVEN_LARM))
4733 if (buki_motteruka(INVEN_RARM) && one_in_(2)) dummy = INVEN_RARM;
4735 object_desc(o_name, &inventory[dummy], OD_NAME_ONLY);
4736 (void)curse_weapon(FALSE, dummy);
4737 reward = format(_("%sが破壊された。", "destroying %s"), o_name);
4741 if (!inventory[INVEN_BODY].k_idx) break;
4742 object_desc(o_name, &inventory[INVEN_BODY], OD_NAME_ONLY);
4743 (void)curse_armor();
4744 reward = format(_("%sが破壊された。", "destroying %s"), o_name);
4748 for (dummy = 0; dummy < 6; dummy++)
4750 (void)dec_stat(dummy, 10 + randint1(15), TRUE);
4752 reward = _("全能力値が下がった。", "decreasing all stats");
4759 msg_format(_("%sの声が轟き渡った:", "The voice of %s thunders:"), chaos_patrons[p_ptr->chaos_patron]);
4760 msg_print(_("「死ぬがよい、下僕よ!」", "'Die, mortal!'"));
4762 take_hit(DAMAGE_LOSELIFE, p_ptr->lev * 4, wrath_reason, -1);
4763 for (dummy = 0; dummy < 6; dummy++)
4765 (void)dec_stat(dummy, 10 + randint1(15), FALSE);
4767 activate_hi_summon(p_ptr->y, p_ptr->x, FALSE);
4768 (void)activate_ty_curse(FALSE, &count);
4773 if (buki_motteruka(INVEN_RARM))
4776 if (buki_motteruka(INVEN_LARM) && one_in_(2)) dummy = INVEN_LARM;
4778 else if (buki_motteruka(INVEN_LARM)) dummy = INVEN_LARM;
4780 if (dummy) (void)curse_weapon(FALSE, dummy);
4782 if (one_in_(2)) (void)curse_armor();
4787 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4788 msg_print(_("「死と破壊こそ我が喜びなり!」", "'Death and destruction! This pleaseth me!'"));
4790 (void)destroy_area(p_ptr->y, p_ptr->x, 25, FALSE);
4791 reward = _("ダンジョンが*破壊*された。", "*destruct*ing dungeon");
4796 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4797 msg_print(_("「我、汝の敵を抹殺せん!」", "'Let me relieve thee of thine oppressors!'"));
4798 (void)symbol_genocide(0, FALSE);
4799 reward = _("モンスターが抹殺された。", "genociding monsters");
4804 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4805 msg_print(_("「我、汝の敵を抹殺せん!」", "'Let me relieve thee of thine oppressors!'"));
4807 (void)mass_genocide(0, FALSE);
4808 reward = _("モンスターが抹殺された。", "genociding nearby monsters");
4813 msg_format(_("%sの力が敵を攻撃するのを感じた!", "You can feel the power of %s assault your enemies!"), chaos_patrons[p_ptr->chaos_patron]);
4814 (void)dispel_monsters(p_ptr->lev * 4);
4819 msg_format(_("%sはあなたを無視した。", "%s ignores you."), chaos_patrons[p_ptr->chaos_patron]);
4824 msg_format(_("%sは褒美として悪魔の使いをよこした!", "%s rewards you with a demonic servant!"),chaos_patrons[p_ptr->chaos_patron]);
4826 if (!summon_specific(-1, p_ptr->y, p_ptr->x, dun_level, SUMMON_DEMON, PM_FORCE_PET))
4827 msg_print(_("何も現れなかった...", "Nobody ever turns up..."));
4829 reward = _("悪魔がペットになった。", "a demonic servant");
4834 msg_format(_("%sは褒美として使いをよこした!", "%s rewards you with a servant!"),chaos_patrons[p_ptr->chaos_patron]);
4836 if (!summon_specific(-1, p_ptr->y, p_ptr->x, dun_level, 0, PM_FORCE_PET))
4837 msg_print(_("何も現れなかった...", "Nobody ever turns up..."));
4839 reward = _("モンスターがペットになった。", "a servant");
4844 msg_format(_("%sは褒美としてアンデッドの使いをよこした。", "%s rewards you with an undead servant!"),chaos_patrons[p_ptr->chaos_patron]);
4846 if (!summon_specific(-1, p_ptr->y, p_ptr->x, dun_level, SUMMON_UNDEAD, PM_FORCE_PET))
4847 msg_print(_("何も現れなかった...", "Nobody ever turns up..."));
4849 reward = _("アンデッドがペットになった。", "an undead servant");
4854 msg_format(_("%sの声がどもった:", "The voice of %s stammers:"),
4856 chaos_patrons[p_ptr->chaos_patron]);
4857 msg_format(_("「あー、あー、答えは %d/%d。質問は何?」", "'Uh... uh... the answer's %d/%d, what's the question?'"), type, effect);
4863 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, format(_("パトロンの報酬で%s", "The patron rewards you with %s."), reward));
4869 * XAngband: determine if a given location is "interesting"
4870 * based on target_set_accept function.
4872 static bool tgt_pt_accept(POSITION y, POSITION x)
4877 if (!(in_bounds(y, x))) return (FALSE);
4879 /* Player grid is always interesting */
4880 if ((y == p_ptr->y) && (x == p_ptr->x)) return (TRUE);
4882 /* Handle hallucination */
4883 if (p_ptr->image) return (FALSE);
4885 /* Examine the grid */
4886 c_ptr = &cave[y][x];
4888 /* Interesting memorized features */
4889 if (c_ptr->info & (CAVE_MARK))
4892 if (cave_have_flag_grid(c_ptr, FF_LESS)) return (TRUE);
4893 if (cave_have_flag_grid(c_ptr, FF_MORE)) return (TRUE);
4895 /* Notice quest features */
4896 if (cave_have_flag_grid(c_ptr, FF_QUEST_ENTER)) return (TRUE);
4897 if (cave_have_flag_grid(c_ptr, FF_QUEST_EXIT)) return (TRUE);
4905 * XAngband: Prepare the "temp" array for "tget_pt"
4906 * based on target_set_prepare funciton.
4908 static void tgt_pt_prepare(void)
4912 /* Reset "temp" array */
4915 if (!expand_list) return;
4917 /* Scan the current panel */
4918 for (y = 1; y < cur_hgt; y++)
4920 for (x = 1; x < cur_wid; x++)
4922 /* Require "interesting" contents */
4923 if (!tgt_pt_accept(y, x)) continue;
4925 /* Save the location */
4932 /* Target the nearest monster for shooting */
4933 ang_sort_comp = ang_sort_comp_distance;
4934 ang_sort_swap = ang_sort_swap_distance;
4936 /* Sort the positions */
4937 ang_sort(temp_x, temp_y, temp_n);
4941 * old -- from PsiAngband.
4943 bool tgt_pt(POSITION *x_ptr, POSITION *y_ptr)
4948 bool success = FALSE;
4952 get_screen_size(&wid, &hgt);
4962 msg_print(_("場所を選んでスペースキーを押して下さい。", "Select a point and press space."));
4963 msg_flag = FALSE; /* prevents "-more-" message. */
4965 while ((ch != ESCAPE) && !success)
4967 bool move_fast = FALSE;
4969 move_cursor_relative(y, x);
4981 if (player_bold(y, x)) ch = 0;
4984 else success = TRUE;
4988 /* XAngband: Move cursor to stairs */
4991 if (expand_list && temp_n)
4994 int cx = (panel_col_min + panel_col_max) / 2;
4995 int cy = (panel_row_min + panel_row_max) / 2;
4999 /* Skip stairs which have defferent distance */
5000 for (; n < temp_n; ++ n)
5002 cave_type *c_ptr = &cave[temp_y[n]][temp_x[n]];
5004 if (cave_have_flag_grid(c_ptr, FF_STAIRS) &&
5005 cave_have_flag_grid(c_ptr, ch == '>' ? FF_MORE : FF_LESS))
5012 if (n == temp_n) /* Loop out taget list */
5017 verify_panel(); /* Move cursor to player */
5019 p_ptr->update |= (PU_MONSTERS);
5021 p_ptr->redraw |= (PR_MAP);
5023 p_ptr->window |= (PW_OVERHEAD);
5026 else /* move cursor to next stair and change panel */
5031 dy = 2 * (y - cy) / hgt;
5032 dx = 2 * (x - cx) / wid;
5033 if (dy || dx) change_panel(dy, dx);
5039 /* Look up the direction */
5040 d = get_keymap_dir(ch);
5042 /* XTRA HACK MOVEFAST */
5043 if (isupper(ch)) move_fast = TRUE;
5045 /* Handle "direction" */
5051 /* XTRA HACK MOVEFAST */
5054 int mag = MIN(wid / 2, hgt / 2);
5064 /* Do not move horizontally if unnecessary */
5065 if (((x < panel_col_min + wid / 2) && (dx > 0)) ||
5066 ((x > panel_col_min + wid / 2) && (dx < 0)))
5071 /* Do not move vertically if unnecessary */
5072 if (((y < panel_row_min + hgt / 2) && (dy > 0)) ||
5073 ((y > panel_row_min + hgt / 2) && (dy < 0)))
5078 /* Apply the motion */
5079 if ((y >= panel_row_min + hgt) || (y < panel_row_min) ||
5080 (x >= panel_col_min + wid) || (x < panel_col_min))
5082 /* if (change_panel(dy, dx)) target_set_prepare(mode); */
5083 change_panel(dy, dx);
5086 /* Slide into legality */
5087 if (x >= cur_wid-1) x = cur_wid - 2;
5088 else if (x <= 0) x = 1;
5090 /* Slide into legality */
5091 if (y >= cur_hgt-1) y = cur_hgt- 2;
5092 else if (y <= 0) y = 1;
5099 /* Clear the top line */
5102 /* Recenter the map around the player */
5105 p_ptr->update |= (PU_MONSTERS);
5107 p_ptr->redraw |= (PR_MAP);
5109 p_ptr->window |= (PW_OVERHEAD);
5118 bool get_hack_dir(DIRECTION *dp)
5126 /* Global direction */
5129 /* (No auto-targeting) */
5131 /* Ask until satisfied */
5134 /* Choose a prompt */
5137 p = _("方向 ('*'でターゲット選択, ESCで中断)? ", "Direction ('*' to choose a target, Escape to cancel)? ");
5141 p = _("方向 ('5'でターゲットへ, '*'でターゲット再選択, ESCで中断)? ", "Direction ('5' for target, '*' to re-target, Escape to cancel)? ");
5144 /* Get a command (or Cancel) */
5145 if (!get_com(p, &command, TRUE)) break;
5149 if (command == '\r') command = 't';
5152 /* Convert various keys to "standard" keys */
5155 /* Use current target */
5166 /* Set new target */
5171 if (target_set(TARGET_KILL)) dir = 5;
5177 /* Look up the direction */
5178 dir = get_keymap_dir(command);
5184 /* Verify requested targets */
5185 if ((dir == 5) && !target_okay()) dir = 0;
5192 if (!dir) return (FALSE);
5194 /* Save the direction */
5197 /* Check for confusion */
5198 if (p_ptr->confused)
5200 /* Random direction */
5201 dir = ddd[randint0(8)];
5204 /* Notice confusion */
5205 if (command_dir != dir)
5208 msg_print(_("あなたは混乱している。", "You are confused."));
5211 /* Save direction */
5214 /* A "valid" direction was entered */
5220 * エネルギーの増加量10d5を速く計算するための関数
5223 #define Go_no_JuuJou 5*5*5*5*5*5*5*5*5*5
5225 s16b gain_energy(void)
5228 s32b energy_result = 10;
5231 tmp = randint0(Go_no_JuuJou);
5233 for (i = 0; i < 9; i ++){
5234 energy_result += tmp % 5;
5238 return (s16b)(energy_result + tmp);
5243 * @brief 射撃武器の攻撃に必要な基本消費エネルギーを返す/Return bow energy
5244 * @param sval 射撃武器のアイテム副分類ID
5245 * @return 消費する基本エネルギー
5247 ENERGY bow_energy(OBJECT_SUBTYPE_VALUE sval)
5249 ENERGY energy = 10000;
5251 /* Analyze the launcher */
5254 /* Sling and ammo */
5261 /* Short Bow and Arrow */
5268 /* Long Bow and Arrow */
5275 /* Bow of irresponsiblity and Arrow */
5282 /* Light Crossbow and Bolt */
5289 /* Heavy Crossbow and Bolt */
5304 int bow_tmul(OBJECT_SUBTYPE_VALUE sval)
5308 /* Analyze the launcher */
5311 /* Sling and ammo */
5318 /* Short Bow and Arrow */
5325 /* Long Bow and Arrow */
5332 /* Bow of irresponsiblity and Arrow */
5339 /* Light Crossbow and Bolt */
5346 /* Heavy Crossbow and Bolt */
5358 * Return alignment title
5360 cptr your_alignment(void)
5363 if (p_ptr->align > 150) return "大善";
5364 else if (p_ptr->align > 50) return "中善";
5365 else if (p_ptr->align > 10) return "小善";
5366 else if (p_ptr->align > -11) return "中立";
5367 else if (p_ptr->align > -51) return "小悪";
5368 else if (p_ptr->align > -151) return "中悪";
5371 if (p_ptr->align > 150) return "Lawful";
5372 else if (p_ptr->align > 50) return "Good";
5373 else if (p_ptr->align > 10) return "Neutral Good";
5374 else if (p_ptr->align > -11) return "Neutral";
5375 else if (p_ptr->align > -51) return "Neutral Evil";
5376 else if (p_ptr->align > -151) return "Evil";
5377 else return "Chaotic";
5383 * Return proficiency level of weapons and misc. skills (except riding)
5385 int weapon_exp_level(int weapon_exp)
5387 if (weapon_exp < WEAPON_EXP_BEGINNER) return EXP_LEVEL_UNSKILLED;
5388 else if (weapon_exp < WEAPON_EXP_SKILLED) return EXP_LEVEL_BEGINNER;
5389 else if (weapon_exp < WEAPON_EXP_EXPERT) return EXP_LEVEL_SKILLED;
5390 else if (weapon_exp < WEAPON_EXP_MASTER) return EXP_LEVEL_EXPERT;
5391 else return EXP_LEVEL_MASTER;
5396 * Return proficiency level of riding
5398 int riding_exp_level(int riding_exp)
5400 if (riding_exp < RIDING_EXP_BEGINNER) return EXP_LEVEL_UNSKILLED;
5401 else if (riding_exp < RIDING_EXP_SKILLED) return EXP_LEVEL_BEGINNER;
5402 else if (riding_exp < RIDING_EXP_EXPERT) return EXP_LEVEL_SKILLED;
5403 else if (riding_exp < RIDING_EXP_MASTER) return EXP_LEVEL_EXPERT;
5404 else return EXP_LEVEL_MASTER;
5409 * Return proficiency level of spells
5411 int spell_exp_level(int spell_exp)
5413 if (spell_exp < SPELL_EXP_BEGINNER) return EXP_LEVEL_UNSKILLED;
5414 else if (spell_exp < SPELL_EXP_SKILLED) return EXP_LEVEL_BEGINNER;
5415 else if (spell_exp < SPELL_EXP_EXPERT) return EXP_LEVEL_SKILLED;
5416 else if (spell_exp < SPELL_EXP_MASTER) return EXP_LEVEL_EXPERT;
5417 else return EXP_LEVEL_MASTER;
5422 * Display a rumor and apply its effects
5425 IDX rumor_num(char *zz, IDX max_idx)
5427 if (strcmp(zz, "*") == 0) return randint1(max_idx - 1);
5428 return (IDX)atoi(zz);
5431 cptr rumor_bind_name(char *base, cptr fullname)
5435 s = strstr(base, "{Name}");
5439 v = format("%s%s%s", base, fullname, (s + 6));
5449 void display_rumor(bool ex)
5457 if (randint0(3) == 0) section = 1;
5460 err = _(get_rnd_line_jonly("rumors_j.txt", section, Rumor, 10),
5461 get_rnd_line("rumors.txt", section, Rumor));
5462 if (err) strcpy(Rumor, _("嘘の噂もある。", "Some rumors are wrong."));
5466 if (strncmp(Rumor, "R:", 2) == 0)
5469 cptr rumor_msg = NULL;
5470 cptr rumor_eff_format = NULL;
5471 char fullname[1024] = "";
5473 if (tokenize(Rumor + 2, 3, zz, TOKENIZE_CHECKQUOTE) == 3)
5475 if (strcmp(zz[0], "ARTIFACT") == 0)
5479 object_type *q_ptr = &forge;
5480 artifact_type *a_ptr;
5484 a_idx = rumor_num(zz[1], max_a_idx);
5486 a_ptr = &a_info[a_idx];
5487 if (a_ptr->name) break;
5490 k_idx = lookup_kind(a_ptr->tval, a_ptr->sval);
5491 object_prep(q_ptr, k_idx);
5492 q_ptr->name1 = a_idx;
5493 q_ptr->ident = IDENT_STORE;
5494 object_desc(fullname, q_ptr, OD_NAME_ONLY);
5496 else if (strcmp(zz[0], "MONSTER") == 0)
5499 monster_race *r_ptr;
5503 r_idx = rumor_num(zz[1], max_r_idx);
5504 r_ptr = &r_info[r_idx];
5505 if (r_ptr->name) break;
5508 strcpy(fullname, r_name + r_ptr->name);
5510 /* Remember this monster */
5511 if (!r_ptr->r_sights)
5516 else if (strcmp(zz[0], "DUNGEON") == 0)
5519 dungeon_info_type *d_ptr;
5523 d_idx = rumor_num(zz[1], max_d_idx);
5524 d_ptr = &d_info[d_idx];
5525 if (d_ptr->name) break;
5528 strcpy(fullname, d_name + d_ptr->name);
5530 if (!max_dlv[d_idx])
5532 max_dlv[d_idx] = d_ptr->mindepth;
5533 rumor_eff_format = _("%sに帰還できるようになった。", "You can recall to %s.");
5536 else if (strcmp(zz[0], "TOWN") == 0)
5543 t_idx = rumor_num(zz[1], NO_TOWN);
5544 if (town[t_idx].name) break;
5547 strcpy(fullname, town[t_idx].name);
5549 visit = (1L << (t_idx - 1));
5550 if ((t_idx != SECRET_TOWN) && !(p_ptr->visit & visit))
5552 p_ptr->visit |= visit;
5553 rumor_eff_format = _("%sに行ったことがある気がする。", "You feel you have been to %s.");
5557 rumor_msg = rumor_bind_name(zz[2], fullname);
5558 msg_print(rumor_msg);
5559 if (rumor_eff_format)
5562 msg_format(rumor_eff_format, fullname);
5567 if (err) msg_print(_("この情報は間違っている。", "This information is wrong."));
5571 msg_format("%s", Rumor);