3 * @brief 雑多なその他の処理2 / effects of various "objects"
6 * Copyright (c) 1989 James E. Wilson, Robert A. Koeneke\n
7 * This software may be copied and distributed for educational, research, and\n
8 * not for profit purposes provided that this copyright and statement are\n
9 * included in all such copies.\n
10 * 2014 Deskull rearranged comment for Doxygen.
16 #include "object-curse.h"
17 #include "monsterrace-hook.h"
18 #include "objectkind-hook.h"
20 #include "projection.h"
22 #define REWARD_CHANCE 10
26 * @brief プレイヤーの経験値について整合性のためのチェックと調整を行う /
27 * Advance experience levels and print experience
30 void check_experience(void)
32 bool level_reward = FALSE;
33 bool level_mutation = FALSE;
34 bool level_inc_stat = FALSE;
35 bool android = (p_ptr->prace == RACE_ANDROID ? TRUE : FALSE);
36 PLAYER_LEVEL old_lev = p_ptr->lev;
38 /* Hack -- lower limit */
39 if (p_ptr->exp < 0) p_ptr->exp = 0;
40 if (p_ptr->max_exp < 0) p_ptr->max_exp = 0;
41 if (p_ptr->max_max_exp < 0) p_ptr->max_max_exp = 0;
43 /* Hack -- upper limit */
44 if (p_ptr->exp > PY_MAX_EXP) p_ptr->exp = PY_MAX_EXP;
45 if (p_ptr->max_exp > PY_MAX_EXP) p_ptr->max_exp = PY_MAX_EXP;
46 if (p_ptr->max_max_exp > PY_MAX_EXP) p_ptr->max_max_exp = PY_MAX_EXP;
48 /* Hack -- maintain "max" experience */
49 if (p_ptr->exp > p_ptr->max_exp) p_ptr->max_exp = p_ptr->exp;
51 /* Hack -- maintain "max max" experience */
52 if (p_ptr->max_exp > p_ptr->max_max_exp) p_ptr->max_max_exp = p_ptr->max_exp;
54 /* Redraw experience */
55 p_ptr->redraw |= (PR_EXP);
59 /* Lose levels while possible */
60 while ((p_ptr->lev > 1) &&
61 (p_ptr->exp < ((android ? player_exp_a : player_exp)[p_ptr->lev - 2] * p_ptr->expfact / 100L)))
65 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
66 p_ptr->redraw |= (PR_LEV | PR_TITLE);
67 p_ptr->window |= (PW_PLAYER);
72 /* Gain levels while possible */
73 while ((p_ptr->lev < PY_MAX_LEVEL) &&
74 (p_ptr->exp >= ((android ? player_exp_a : player_exp)[p_ptr->lev-1] * p_ptr->expfact / 100L)))
79 /* Save the highest level */
80 if (p_ptr->lev > p_ptr->max_plv)
82 p_ptr->max_plv = p_ptr->lev;
84 if ((p_ptr->pclass == CLASS_CHAOS_WARRIOR) ||
85 (p_ptr->muta2 & MUT2_CHAOS_GIFT))
89 if (p_ptr->prace == RACE_BEASTMAN)
91 if (one_in_(5)) level_mutation = TRUE;
93 level_inc_stat = TRUE;
95 do_cmd_write_nikki(NIKKI_LEVELUP, p_ptr->lev, NULL);
100 msg_format(_("レベル %d にようこそ。", "Welcome to level %d."), p_ptr->lev);
102 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
103 p_ptr->redraw |= (PR_LEV | PR_TITLE | PR_EXP);
104 p_ptr->window |= (PW_PLAYER | PW_SPELL | PW_INVEN);
114 if(!(p_ptr->max_plv % 10))
123 cnv_stat(p_ptr->stat_max[0], tmp);
124 prt(format(_(" a) 腕力 (現在値 %s)", " a) Str (cur %s)"), tmp), 2, 14);
125 cnv_stat(p_ptr->stat_max[1], tmp);
126 prt(format(_(" b) 知能 (現在値 %s)", " a) Int (cur %s)"), tmp), 3, 14);
127 cnv_stat(p_ptr->stat_max[2], tmp);
128 prt(format(_(" c) 賢さ (現在値 %s)", " a) Wis (cur %s)"), tmp), 4, 14);
129 cnv_stat(p_ptr->stat_max[3], tmp);
130 prt(format(_(" d) 器用 (現在値 %s)", " a) Dex (cur %s)"), tmp), 5, 14);
131 cnv_stat(p_ptr->stat_max[4], tmp);
132 prt(format(_(" e) 耐久 (現在値 %s)", " a) Con (cur %s)"), tmp), 6, 14);
133 cnv_stat(p_ptr->stat_max[5], tmp);
134 prt(format(_(" f) 魅力 (現在値 %s)", " a) Chr (cur %s)"), tmp), 7, 14);
137 prt(_(" どの能力値を上げますか?", " Which stat do you want to raise?"), 1, 14);
142 if ((choice >= 'a') && (choice <= 'f')) break;
144 for(n = 0; n < A_MAX; n++)
145 if (n != choice - 'a')
147 if (get_check(_("よろしいですか?", "Are you sure? "))) break;
149 do_inc_stat(choice - 'a');
152 else if(!(p_ptr->max_plv % 2))
153 do_inc_stat(randint0(6));
158 msg_print(_("あなたは変わった気がする...", "You feel different..."));
159 (void)gain_random_mutation(0);
160 level_mutation = FALSE;
164 * 報酬でレベルが上ると再帰的に check_experience() が
169 gain_level_reward(0);
170 level_reward = FALSE;
173 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
174 p_ptr->redraw |= (PR_LEV | PR_TITLE);
175 p_ptr->window |= (PW_PLAYER | PW_SPELL);
179 /* Load an autopick preference file */
180 if (old_lev != p_ptr->lev) autopick_load_pref(FALSE);
186 * @brief クエストを達成状態にする /
187 * @param quest_num 達成状態にしたいクエストのID
190 void complete_quest(QUEST_IDX quest_num)
192 quest_type* const q_ptr = &quest[quest_num];
196 case QUEST_TYPE_RANDOM:
197 if (record_rand_quest) do_cmd_write_nikki(NIKKI_RAND_QUEST_C, quest_num, NULL);
200 if (record_fix_quest) do_cmd_write_nikki(NIKKI_FIX_QUEST_C, quest_num, NULL);
204 q_ptr->status = QUEST_STATUS_COMPLETED;
205 q_ptr->complev = p_ptr->lev;
207 q_ptr->comptime = playtime;
209 if (!(q_ptr->flags & QUEST_FLAG_SILENT))
211 play_music(TERM_XTRA_MUSIC_BASIC, MUSIC_BASIC_QUEST_CLEAR);
212 msg_print(_("クエストを達成した!", "You just completed your quest!"));
218 * @brief 現在フロアに残っている敵モンスターの数を返す /
219 * @return 現在の敵モンスターの数
221 static MONSTER_NUMBER count_all_hostile_monsters(void)
224 MONSTER_NUMBER number_mon = 0;
226 for (x = 0; x < cur_wid; ++ x)
228 for (y = 0; y < cur_hgt; ++ y)
230 MONSTER_IDX m_idx = cave[y][x].m_idx;
232 if (m_idx > 0 && is_hostile(&m_list[m_idx]))
243 * @brief 特定の敵を倒した際にクエスト達成処理 /
244 * Check for "Quest" completion when a quest monster is killed or charmed.
245 * @param m_ptr 撃破したモンスターの構造体参照ポインタ
248 void check_quest_completion(monster_type *m_ptr)
253 bool create_stairs = FALSE;
263 quest_num = p_ptr->inside_quest;
265 /* Search for an active quest on this dungeon level */
270 for (i = max_q_idx - 1; i > 0; i--)
272 quest_type* const q_ptr = &quest[i];
274 /* Quest is not active */
275 if (q_ptr->status != QUEST_STATUS_TAKEN)
278 /* Quest is not a dungeon quest */
279 if (q_ptr->flags & QUEST_FLAG_PRESET)
282 /* Quest is not on this level */
283 if ((q_ptr->level != dun_level) &&
284 (q_ptr->type != QUEST_TYPE_KILL_ANY_LEVEL))
287 /* Not a "kill monster" quest */
288 if ((q_ptr->type == QUEST_TYPE_FIND_ARTIFACT) ||
289 (q_ptr->type == QUEST_TYPE_FIND_EXIT))
292 /* Interesting quest */
293 if ((q_ptr->type == QUEST_TYPE_KILL_NUMBER) ||
294 (q_ptr->type == QUEST_TYPE_TOWER) ||
295 (q_ptr->type == QUEST_TYPE_KILL_ALL))
298 /* Interesting quest */
299 if (((q_ptr->type == QUEST_TYPE_KILL_LEVEL) ||
300 (q_ptr->type == QUEST_TYPE_KILL_ANY_LEVEL) ||
301 (q_ptr->type == QUEST_TYPE_RANDOM)) &&
302 (q_ptr->r_idx == m_ptr->r_idx))
309 /* Handle the current quest */
310 if (quest_num && (quest[quest_num].status == QUEST_STATUS_TAKEN))
313 quest_type* const q_ptr = &quest[quest_num];
317 case QUEST_TYPE_KILL_NUMBER:
321 if (q_ptr->cur_num >= q_ptr->num_mon)
323 complete_quest(quest_num);
329 case QUEST_TYPE_KILL_ALL:
331 if (!is_hostile(m_ptr)) break;
333 if (count_all_hostile_monsters() == 1)
335 if (q_ptr->flags & QUEST_FLAG_SILENT)
337 q_ptr->status = QUEST_STATUS_FINISHED;
341 complete_quest(quest_num);
346 case QUEST_TYPE_KILL_LEVEL:
347 case QUEST_TYPE_RANDOM:
349 /* Only count valid monsters */
350 if (q_ptr->r_idx != m_ptr->r_idx)
355 if (q_ptr->cur_num >= q_ptr->max_num)
357 complete_quest(quest_num);
359 if (!(q_ptr->flags & QUEST_FLAG_PRESET))
361 create_stairs = TRUE;
362 p_ptr->inside_quest = 0;
365 /* Finish the two main quests without rewarding */
366 if ((quest_num == QUEST_OBERON) || (quest_num == QUEST_SERPENT))
368 q_ptr->status = QUEST_STATUS_FINISHED;
371 if (q_ptr->type == QUEST_TYPE_RANDOM)
374 q_ptr->status = QUEST_STATUS_FINISHED;
379 case QUEST_TYPE_KILL_ANY_LEVEL:
382 if (q_ptr->cur_num >= q_ptr->max_num)
384 complete_quest(quest_num);
389 case QUEST_TYPE_TOWER:
391 if (!is_hostile(m_ptr)) break;
393 if (count_all_hostile_monsters() == 1)
395 q_ptr->status = QUEST_STATUS_STAGE_COMPLETED;
397 if((quest[QUEST_TOWER1].status == QUEST_STATUS_STAGE_COMPLETED) &&
398 (quest[QUEST_TOWER2].status == QUEST_STATUS_STAGE_COMPLETED) &&
399 (quest[QUEST_TOWER3].status == QUEST_STATUS_STAGE_COMPLETED))
402 complete_quest(QUEST_TOWER1);
410 /* Create a magical staircase */
416 while (cave_perma_bold(y, x) || cave[y][x].o_idx || (cave[y][x].info & CAVE_OBJECT) )
418 /* Pick a location */
419 scatter(&ny, &nx, y, x, 1, 0);
425 /* Explain the staircase */
426 msg_print(_("魔法の階段が現れた...", "A magical staircase appears..."));
428 /* Create stairs down */
429 cave_set_feat(y, x, feat_down_stair);
431 /* Remember to update everything */
432 p_ptr->update |= (PU_FLOW);
442 for (i = 0; i < (dun_level / 15)+1; i++)
447 /* Make a great object */
448 make_object(o_ptr, AM_GOOD | AM_GREAT);
449 (void)drop_near(o_ptr, -1, y, x);
455 * @brief 特定のアーティファクトを入手した際のクエスト達成処理 /
456 * Check for "Quest" completion when a quest monster is killed or charmed.
457 * @param o_ptr 入手したオブジェクトの構造体参照ポインタ
460 void check_find_art_quest_completion(object_type *o_ptr)
463 /* Check if completed a quest */
464 for (i = 0; i < max_q_idx; i++)
466 if((quest[i].type == QUEST_TYPE_FIND_ARTIFACT) &&
467 (quest[i].status == QUEST_STATUS_TAKEN) &&
468 (quest[i].k_idx == o_ptr->name1))
477 * @brief モンスターを撃破した際の述語メッセージを返す /
478 * Return monster death string
479 * @param r_ptr 撃破されたモンスターの種族情報を持つ構造体の参照ポインタ
480 * @return 撃破されたモンスターの述語
482 concptr extract_note_dies(MONRACE_IDX r_idx)
484 monster_race *r_ptr = &r_info[r_idx];
485 /* Some monsters get "destroyed" */
486 if (!monster_living(r_idx))
490 for (i = 0; i < 4; i++)
492 if (r_ptr->blow[i].method == RBM_EXPLODE)
494 return _("は爆発して粉々になった。", " explodes into tiny shreds.");
497 return _("を倒した。", " is destroyed.");
500 /* Assume a default death */
501 return _("は死んだ。", " dies.");
506 * @brief モンスターに与えたダメージの修正処理 /
507 * Modify the physical damage done to the monster.
508 * @param m_ptr ダメージを受けるモンスターの構造体参照ポインタ
510 * @param is_psy_spear 攻撃手段が光の剣ならばTRUE
511 * @return 修正を行った結果のダメージ量
514 * (for example when it's invulnerable or shielded)
515 * ToDo: Accept a damage-type to calculate the modified damage from
516 * things like fire, frost, lightning, poison, ... attacks.
517 * "type" is not yet used and should be 0.
520 HIT_POINT mon_damage_mod(monster_type *m_ptr, HIT_POINT dam, bool is_psy_spear)
522 monster_race *r_ptr = &r_info[m_ptr->r_idx];
524 if ((r_ptr->flagsr & RFR_RES_ALL) && dam > 0)
527 if ((dam == 0) && one_in_(3)) dam = 1;
530 if (MON_INVULNER(m_ptr))
534 if (!p_ptr->blind && is_seen(m_ptr))
536 msg_print(_("バリアを切り裂いた!", "The barrier is penetrated!"));
539 else if (!one_in_(PENETRATE_INVULNERABILITY))
549 * @brief モンスターに与えたダメージを元に経験値を加算する /
550 * Calculate experience point to be get
551 * @param dam 与えたダメージ量
552 * @param m_ptr ダメージを与えたモンスターの構造体参照ポインタ
556 * Even the 64 bit operation is not big enough to avoid overflaw
557 * unless we carefully choose orders of multiplication and division.
558 * Get the coefficient first, and multiply (potentially huge) base
559 * experience point of a monster later.
562 static void get_exp_from_mon(HIT_POINT dam, monster_type *m_ptr)
564 monster_race *r_ptr = &r_info[m_ptr->r_idx];
571 if (!m_ptr->r_idx) return;
572 if (is_pet(m_ptr) || p_ptr->inside_battle) return;
575 * - Ratio of monster's level to player's level effects
576 * - Varying speed effects
577 * - Get a fraction in proportion of damage point
579 new_exp = r_ptr->level * SPEED_TO_ENERGY(m_ptr->mspeed) * dam;
582 div_l = (p_ptr->max_plv+2) * SPEED_TO_ENERGY(r_ptr->speed);
584 /* Use (average maxhp * 2) as a denominator */
585 if (!(r_ptr->flags1 & RF1_FORCE_MAXHP))
586 s64b_mul(&div_h, &div_l, 0, r_ptr->hdice * (ironman_nightmare ? 2 : 1) * (r_ptr->hside + 1));
588 s64b_mul(&div_h, &div_l, 0, r_ptr->hdice * (ironman_nightmare ? 2 : 1) * r_ptr->hside * 2);
590 /* Special penalty in the wilderness */
591 if (!dun_level && (!(r_ptr->flags8 & RF8_WILD_ONLY) || !(r_ptr->flags1 & RF1_UNIQUE)))
592 s64b_mul(&div_h, &div_l, 0, 5);
594 /* Do division first to prevent overflaw */
595 s64b_div(&new_exp, &new_exp_frac, div_h, div_l);
597 /* Special penalty for mutiply-monster */
598 if ((r_ptr->flags2 & RF2_MULTIPLY) || (m_ptr->r_idx == MON_DAWN))
600 int monnum_penarty = r_ptr->r_akills / 400;
601 if (monnum_penarty > 8) monnum_penarty = 8;
603 while (monnum_penarty--)
606 s64b_RSHIFT(new_exp, new_exp_frac, 2);
610 /* Special penalty for rest_and_shoot exp scum */
611 if ((m_ptr->dealt_damage > m_ptr->max_maxhp) && (m_ptr->hp >= 0))
613 int over_damage = m_ptr->dealt_damage / m_ptr->max_maxhp;
614 if (over_damage > 32) over_damage = 32;
616 while (over_damage--)
619 s64b_mul(&new_exp, &new_exp_frac, 0, 9);
620 s64b_div(&new_exp, &new_exp_frac, 0, 10);
624 /* Finally multiply base experience point of the monster */
625 s64b_mul(&new_exp, &new_exp_frac, 0, r_ptr->mexp);
627 /* Gain experience */
628 gain_exp_64(new_exp, new_exp_frac);
633 * @brief モンスターのHPをダメージに応じて減算する /
634 * Decreases monsters hit points, handling monster death.
635 * @param dam 与えたダメージ量
636 * @param m_idx ダメージを与えたモンスターのID
637 * @param fear ダメージによってモンスターが恐慌状態に陥ったならばTRUEを返す
638 * @param note モンスターが倒された際の特別なメッセージ述語
642 * We return TRUE if the monster has been killed (and deleted).
643 * We announce monster death (using an optional "death message"
644 * if given, and a otherwise a generic killed/destroyed message).
645 * Only "physical attacks" can induce the "You have slain" message.
646 * Missile and Spell attacks will induce the "dies" message, or
647 * various "specialized" messages. Note that "You have destroyed"
648 * and "is destroyed" are synonyms for "You have slain" and "dies".
649 * Hack -- unseen monsters yield "You have killed it." message.
650 * Added fear (DGK) and check whether to print fear messages -CWS
651 * Made name, sex, and capitalization generic -BEN-
652 * As always, the "ghost" processing is a total hack.
653 * Hack -- we "delay" fear messages by passing around a "fear" flag.
654 * Consider decreasing monster experience over time, say,
655 * by using "(m_exp * m_lev * (m_lev)) / (p_lev * (m_lev + n_killed))"
656 * instead of simply "(m_exp * m_lev) / (p_lev)", to make the first
657 * monster worth more than subsequent monsters. This would also need
658 * to induce changes in the monster recall code.
661 bool mon_take_hit(MONSTER_IDX m_idx, HIT_POINT dam, bool *fear, concptr note)
663 monster_type *m_ptr = &m_list[m_idx];
664 monster_race *r_ptr = &r_info[m_ptr->r_idx];
665 monster_type exp_mon;
667 /* Innocent until proven otherwise */
668 bool innocent = TRUE, thief = FALSE;
672 (void)COPY(&exp_mon, m_ptr, monster_type);
674 expdam = (m_ptr->hp > dam) ? dam : m_ptr->hp;
676 get_exp_from_mon(expdam, &exp_mon);
678 /* Genocided by chaos patron */
679 if (!m_ptr->r_idx) m_idx = 0;
681 /* Redraw (later) if needed */
682 if (p_ptr->health_who == m_idx) p_ptr->redraw |= (PR_HEALTH);
683 if (p_ptr->riding == m_idx) p_ptr->redraw |= (PR_UHEALTH);
685 (void)set_monster_csleep(m_idx, 0);
687 /* Hack - Cancel any special player stealth magics. -LM- */
688 if (p_ptr->special_defense & NINJA_S_STEALTH)
690 set_superstealth(FALSE);
693 /* Genocided by chaos patron */
694 if (!m_idx) return TRUE;
697 m_ptr->dealt_damage += dam;
699 if(m_ptr->dealt_damage > m_ptr->max_maxhp * 100) m_ptr->dealt_damage = m_ptr->max_maxhp * 100;
703 msg_format( _("合計%d/%dのダメージを与えた。","You do %d (out of %d) damage."), m_ptr->dealt_damage, m_ptr->maxhp);
709 GAME_TEXT m_name[MAX_NLEN];
711 if (r_info[m_ptr->r_idx].flags7 & RF7_TANUKI)
713 /* You might have unmasked Tanuki first time */
714 r_ptr = &r_info[m_ptr->r_idx];
715 m_ptr->ap_r_idx = m_ptr->r_idx;
716 if (r_ptr->r_sights < MAX_SHORT) r_ptr->r_sights++;
719 if (m_ptr->mflag2 & MFLAG2_CHAMELEON)
721 /* You might have unmasked Chameleon first time */
722 r_ptr = real_r_ptr(m_ptr);
723 if (r_ptr->r_sights < MAX_SHORT) r_ptr->r_sights++;
726 if (!(m_ptr->smart & SM_CLONED))
728 /* When the player kills a Unique, it stays dead */
729 if (r_ptr->flags1 & RF1_UNIQUE)
733 /* Mega-Hack -- Banor & Lupart */
734 if ((m_ptr->r_idx == MON_BANOR) || (m_ptr->r_idx == MON_LUPART))
736 r_info[MON_BANORLUPART].max_num = 0;
737 r_info[MON_BANORLUPART].r_pkills++;
738 r_info[MON_BANORLUPART].r_akills++;
739 if (r_info[MON_BANORLUPART].r_tkills < MAX_SHORT) r_info[MON_BANORLUPART].r_tkills++;
741 else if (m_ptr->r_idx == MON_BANORLUPART)
743 r_info[MON_BANOR].max_num = 0;
744 r_info[MON_BANOR].r_pkills++;
745 r_info[MON_BANOR].r_akills++;
746 if (r_info[MON_BANOR].r_tkills < MAX_SHORT) r_info[MON_BANOR].r_tkills++;
747 r_info[MON_LUPART].max_num = 0;
748 r_info[MON_LUPART].r_pkills++;
749 r_info[MON_LUPART].r_akills++;
750 if (r_info[MON_LUPART].r_tkills < MAX_SHORT) r_info[MON_LUPART].r_tkills++;
754 /* When the player kills a Nazgul, it stays dead */
755 else if (r_ptr->flags7 & RF7_NAZGUL) r_ptr->max_num--;
758 /* Count all monsters killed */
759 if (r_ptr->r_akills < MAX_SHORT) r_ptr->r_akills++;
761 /* Recall even invisible uniques or winners */
762 if ((m_ptr->ml && !p_ptr->image) || (r_ptr->flags1 & RF1_UNIQUE))
764 /* Count kills this life */
765 if ((m_ptr->mflag2 & MFLAG2_KAGE) && (r_info[MON_KAGE].r_pkills < MAX_SHORT)) r_info[MON_KAGE].r_pkills++;
766 else if (r_ptr->r_pkills < MAX_SHORT) r_ptr->r_pkills++;
768 /* Count kills in all lives */
769 if ((m_ptr->mflag2 & MFLAG2_KAGE) && (r_info[MON_KAGE].r_tkills < MAX_SHORT)) r_info[MON_KAGE].r_tkills++;
770 else if (r_ptr->r_tkills < MAX_SHORT) r_ptr->r_tkills++;
772 /* Hack -- Auto-recall */
773 monster_race_track(m_ptr->ap_r_idx);
776 /* Extract monster name */
777 monster_desc(m_name, m_ptr, MD_TRUE_NAME);
779 /* Don't kill Amberites */
780 if ((r_ptr->flags3 & RF3_AMBERITE) && one_in_(2))
782 int curses = 1 + randint1(3);
783 bool stop_ty = FALSE;
786 msg_format(_("%^sは恐ろしい血の呪いをあなたにかけた!", "%^s puts a terrible blood curse on you!"), m_name);
787 curse_equipment(100, 50);
791 stop_ty = activate_ty_curse(stop_ty, &count);
796 if (r_ptr->flags2 & RF2_CAN_SPEAK)
799 if (!get_rnd_line(_("mondeath_j.txt", "mondeath.txt"), m_ptr->r_idx, line_got))
801 msg_format("%^s %s", m_name, line_got);
805 if (m_ptr->r_idx == MON_SERPENT)
807 screen_dump = make_screen_dump();
812 if (!(d_info[dungeon_type].flags1 & DF1_BEGINNER))
814 if (!dun_level && !ambush_flag && !p_ptr->inside_arena)
816 chg_virtue(V_VALOUR, -1);
818 else if (r_ptr->level > dun_level)
820 if (randint1(10) <= (r_ptr->level - dun_level))
821 chg_virtue(V_VALOUR, 1);
823 if (r_ptr->level > 60)
825 chg_virtue(V_VALOUR, 1);
827 if (r_ptr->level >= 2 * (p_ptr->lev+1))
828 chg_virtue(V_VALOUR, 2);
831 if (r_ptr->flags1 & RF1_UNIQUE)
833 if (r_ptr->flags3 & (RF3_EVIL | RF3_GOOD)) chg_virtue(V_HARMONY, 2);
835 if (r_ptr->flags3 & RF3_GOOD)
837 chg_virtue(V_UNLIFE, 2);
838 chg_virtue(V_VITALITY, -2);
841 if (one_in_(3)) chg_virtue(V_INDIVIDUALISM, -1);
844 if (m_ptr->r_idx == MON_BEGGAR || m_ptr->r_idx == MON_LEPER)
846 chg_virtue(V_COMPASSION, -1);
849 if ((r_ptr->flags3 & RF3_GOOD) && ((r_ptr->level) / 10 + (3 * dun_level) >= randint1(100)))
850 chg_virtue(V_UNLIFE, 1);
852 if (r_ptr->d_char == 'A')
854 if (r_ptr->flags1 & RF1_UNIQUE)
855 chg_virtue(V_FAITH, -2);
856 else if ((r_ptr->level) / 10 + (3 * dun_level) >= randint1(100))
858 if (r_ptr->flags3 & RF3_GOOD) chg_virtue(V_FAITH, -1);
859 else chg_virtue(V_FAITH, 1);
862 else if (r_ptr->flags3 & RF3_DEMON)
864 if (r_ptr->flags1 & RF1_UNIQUE)
865 chg_virtue(V_FAITH, 2);
866 else if ((r_ptr->level) / 10 + (3 * dun_level) >= randint1(100))
867 chg_virtue(V_FAITH, 1);
870 if ((r_ptr->flags3 & RF3_UNDEAD) && (r_ptr->flags1 & RF1_UNIQUE))
871 chg_virtue(V_VITALITY, 2);
875 if (r_ptr->flags1 & RF1_UNIQUE)
877 chg_virtue(V_HONOUR, 10);
879 else if ((r_ptr->level) / 10 + (2 * dun_level) >= randint1(100))
881 chg_virtue(V_HONOUR, 1);
884 if ((r_ptr->flags2 & RF2_MULTIPLY) && (r_ptr->r_akills > 1000) && one_in_(10))
886 chg_virtue(V_VALOUR, -1);
889 for (i = 0; i < 4; i++)
891 if (r_ptr->blow[i].d_dice != 0) innocent = FALSE; /* Murderer! */
893 if ((r_ptr->blow[i].effect == RBE_EAT_ITEM)
894 || (r_ptr->blow[i].effect == RBE_EAT_GOLD))
896 thief = TRUE; /* Thief! */
899 /* The new law says it is illegal to live in the dungeon */
900 if (r_ptr->level != 0) innocent = FALSE;
904 if (r_ptr->flags1 & RF1_UNIQUE)
905 chg_virtue(V_JUSTICE, 3);
906 else if (1+((r_ptr->level) / 10 + (2 * dun_level)) >= randint1(100))
907 chg_virtue(V_JUSTICE, 1);
911 chg_virtue (V_JUSTICE, -1);
914 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)))
916 if (one_in_(4)) chg_virtue(V_NATURE, -1);
919 if ((r_ptr->flags1 & RF1_UNIQUE) && record_destroy_uniq)
922 sprintf(note_buf, "%s%s", r_name + r_ptr->name, (m_ptr->smart & SM_CLONED) ? _("(クローン)", "(Clone)") : "");
923 do_cmd_write_nikki(NIKKI_UNIQUE, 0, note_buf);
929 /* Death by Missile/Spell attack */
932 msg_format("%^s%s", m_name, note);
935 /* Death by physical attack -- invisible monster */
939 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
940 msg_format("せっかくだから%sを殺した。", m_name);
942 msg_format("%sを殺した。", m_name);
944 msg_format("You have killed %s.", m_name);
949 /* Death by Physical attack -- non-living monster */
950 else if (!monster_living(m_ptr->r_idx))
952 bool explode = FALSE;
954 for (i = 0; i < 4; i++)
956 if (r_ptr->blow[i].method == RBM_EXPLODE) explode = TRUE;
959 /* Special note at death */
961 msg_format(_("%sは爆発して粉々になった。", "%^s explodes into tiny shreds."), m_name);
965 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
966 msg_format("せっかくだから%sを倒した。", m_name);
968 msg_format("%sを倒した。", m_name);
970 msg_format("You have destroyed %s.", m_name);
975 /* Death by Physical attack -- living monster */
979 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
980 msg_format("せっかくだから%sを葬り去った。", m_name);
982 msg_format("%sを葬り去った。", m_name);
984 msg_format("You have slain %s.", m_name);
988 if ((r_ptr->flags1 & RF1_UNIQUE) && !(m_ptr->smart & SM_CLONED) && !vanilla_town)
990 for (i = 0; i < MAX_KUBI; i++)
992 if ((kubi_r_idx[i] == m_ptr->r_idx) && !(m_ptr->mflag2 & MFLAG2_CHAMELEON))
994 msg_format(_("%sの首には賞金がかかっている。", "There is a price on %s's head."), m_name);
1000 /* Generate treasure */
1001 monster_death(m_idx, TRUE);
1003 /* Mega hack : replace IKETA to BIKETAL */
1004 if ((m_ptr->r_idx == MON_IKETA) && !(p_ptr->inside_arena || p_ptr->inside_battle))
1006 POSITION dummy_y = m_ptr->fy;
1007 POSITION dummy_x = m_ptr->fx;
1008 BIT_FLAGS mode = 0L;
1009 if (is_pet(m_ptr)) mode |= PM_FORCE_PET;
1010 delete_monster_idx(m_idx);
1011 if (summon_named_creature(0, dummy_y, dummy_x, MON_BIKETAL, mode))
1013 msg_print(_("「ハァッハッハッハ!!私がバイケタルだ!!」", "Uwa-hahaha! *I* am Biketal!"));
1018 delete_monster_idx(m_idx);
1021 get_exp_from_mon((long)exp_mon.max_maxhp*2, &exp_mon);
1026 /* Monster is dead */
1033 /* Mega-Hack -- Pain cancels fear */
1034 if (MON_MONFEAR(m_ptr) && (dam > 0))
1037 if (set_monster_monfear(m_idx, MON_MONFEAR(m_ptr) - randint1(dam)))
1044 /* Sometimes a monster gets scared by damage */
1045 if (!MON_MONFEAR(m_ptr) && !(r_ptr->flags3 & (RF3_NO_FEAR)))
1047 /* Percentage of fully healthy */
1048 int percentage = (100L * m_ptr->hp) / m_ptr->maxhp;
1051 * Run (sometimes) if at 10% or less of max hit points,
1052 * or (usually) when hit for half its current hit points
1054 if ((randint1(10) >= percentage) || ((dam >= m_ptr->hp) && (randint0(100) < 80)))
1056 /* Hack -- note fear */
1059 /* Hack -- Add some timed fear */
1060 (void)set_monster_monfear(m_idx, (randint1(10) +
1061 (((dam >= m_ptr->hp) && (percentage > 7)) ?
1062 20 : ((11 - percentage) * 5))));
1074 * @brief 現在のコンソール表示の縦横を返す。 /
1075 * Get term size and calculate screen size
1076 * @param wid_p コンソールの表示幅文字数を返す
1077 * @param hgt_p コンソールの表示行数を返す
1080 void get_screen_size(TERM_LEN *wid_p, TERM_LEN *hgt_p)
1082 Term_get_size(wid_p, hgt_p);
1083 *hgt_p -= ROW_MAP + 2;
1084 *wid_p -= COL_MAP + 2;
1085 if (use_bigtile) *wid_p /= 2;
1090 * @brief コンソール上におけるマップ表示の左上位置を返す /
1091 * Calculates current boundaries Called below and from "do_cmd_locate()".
1094 void panel_bounds_center(void)
1098 get_screen_size(&wid, &hgt);
1100 panel_row_max = panel_row_min + hgt - 1;
1101 panel_row_prt = panel_row_min - 1;
1102 panel_col_max = panel_col_min + wid - 1;
1103 panel_col_prt = panel_col_min - 13;
1108 * @brief コンソールのリサイズに合わせてマップを再描画する /
1109 * Map resizing whenever the main term changes size
1112 void resize_map(void)
1114 /* Only if the dungeon exists */
1115 if (!character_dungeon) return;
1117 /* Mega-Hack -- no panel yet */
1121 /* Reset the panels */
1122 panel_row_min = cur_hgt;
1123 panel_col_min = cur_wid;
1127 p_ptr->update |= (PU_TORCH | PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
1128 p_ptr->update |= (PU_UN_VIEW | PU_UN_LITE);
1129 p_ptr->update |= (PU_VIEW | PU_LITE | PU_MON_LITE);
1130 p_ptr->update |= (PU_MONSTERS);
1131 p_ptr->redraw |= (PR_WIPE | PR_BASIC | PR_EXTRA | PR_MAP | PR_EQUIPPY);
1138 * Place the cursor on the player
1140 if (can_save) move_cursor_relative(p_ptr->y, p_ptr->x);
1146 * @brief コンソールを再描画する /
1147 * Redraw a term when it is resized
1150 void redraw_window(void)
1152 /* Only if the dungeon exists */
1153 if (!character_dungeon) return;
1155 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_SPELL | PW_PLAYER);
1156 p_ptr->window |= (PW_MESSAGE | PW_OVERHEAD | PW_DUNGEON | PW_MONSTER | PW_OBJECT);
1164 * @brief フォーカスを当てるべきマップ描画の基準座標を指定する(サブルーチン)
1165 * @param dy 変更先のフロアY座標
1166 * @param dx 変更先のフロアX座標
1167 * Handle a request to change the current panel
1168 * Return TRUE if the panel was changed.
1169 * Also used in do_cmd_locate
1170 * @return 実際に再描画が必要だった場合TRUEを返す
1172 bool change_panel(POSITION dy, POSITION dx)
1177 get_screen_size(&wid, &hgt);
1179 /* Apply the motion */
1180 y = panel_row_min + dy * hgt / 2;
1181 x = panel_col_min + dx * wid / 2;
1183 /* Verify the row */
1184 if (y > cur_hgt - hgt) y = cur_hgt - hgt;
1187 /* Verify the col */
1188 if (x > cur_wid - wid) x = cur_wid - wid;
1191 /* Handle "changes" */
1192 if ((y != panel_row_min) || (x != panel_col_min))
1194 /* Save the new panel info */
1198 /* Recalculate the boundaries */
1199 panel_bounds_center();
1201 p_ptr->update |= (PU_MONSTERS);
1202 p_ptr->redraw |= (PR_MAP);
1214 * @brief フォーカスを当てるべきマップ描画の基準座標を指定する
1215 * @param y 変更先のフロアY座標
1216 * @param x 変更先のフロアX座標
1218 * Handle a request to change the current panel
1219 * Return TRUE if the panel was changed.
1220 * Also used in do_cmd_locate
1221 * @return 実際に再描画が必要だった場合TRUEを返す
1223 static bool change_panel_xy(POSITION y, POSITION x)
1225 POSITION dy = 0, dx = 0;
1228 get_screen_size(&wid, &hgt);
1230 if (y < panel_row_min) dy = -1;
1231 if (y > panel_row_max) dy = 1;
1232 if (x < panel_col_min) dx = -1;
1233 if (x > panel_col_max) dx = 1;
1235 if (!dy && !dx) return (FALSE);
1237 return change_panel(dy, dx);
1242 * @brief マップ描画のフォーカスを当てるべき座標を更新する
1244 * Given an row (y) and col (x), this routine detects when a move
1245 * off the screen has occurred and figures new borders. -RAK-
1246 * "Update" forces a "full update" to take place.
1247 * The map is reprinted if necessary, and "TRUE" is returned.
1248 * @return 実際に再描画が必要だった場合TRUEを返す
1250 void verify_panel(void)
1252 POSITION y = p_ptr->y;
1253 POSITION x = p_ptr->x;
1261 get_screen_size(&wid, &hgt);
1263 max_prow_min = cur_hgt - hgt;
1264 max_pcol_min = cur_wid - wid;
1266 /* Bounds checking */
1267 if (max_prow_min < 0) max_prow_min = 0;
1268 if (max_pcol_min < 0) max_pcol_min = 0;
1270 /* Center on player */
1271 if (center_player && (center_running || !running))
1273 /* Center vertically */
1274 prow_min = y - hgt / 2;
1275 if (prow_min < 0) prow_min = 0;
1276 else if (prow_min > max_prow_min) prow_min = max_prow_min;
1278 /* Center horizontally */
1279 pcol_min = x - wid / 2;
1280 if (pcol_min < 0) pcol_min = 0;
1281 else if (pcol_min > max_pcol_min) pcol_min = max_pcol_min;
1285 prow_min = panel_row_min;
1286 pcol_min = panel_col_min;
1288 /* Scroll screen when 2 grids from top/bottom edge */
1289 if (y > panel_row_max - 2)
1291 while (y > prow_min + hgt-1 - 2)
1293 prow_min += (hgt / 2);
1297 if (y < panel_row_min + 2)
1299 while (y < prow_min + 2)
1301 prow_min -= (hgt / 2);
1305 if (prow_min > max_prow_min) prow_min = max_prow_min;
1306 if (prow_min < 0) prow_min = 0;
1308 /* Scroll screen when 4 grids from left/right edge */
1309 if (x > panel_col_max - 4)
1311 while (x > pcol_min + wid-1 - 4)
1313 pcol_min += (wid / 2);
1317 if (x < panel_col_min + 4)
1319 while (x < pcol_min + 4)
1321 pcol_min -= (wid / 2);
1325 if (pcol_min > max_pcol_min) pcol_min = max_pcol_min;
1326 if (pcol_min < 0) pcol_min = 0;
1329 /* Check for "no change" */
1330 if ((prow_min == panel_row_min) && (pcol_min == panel_col_min)) return;
1332 /* Save the new panel info */
1333 panel_row_min = prow_min;
1334 panel_col_min = pcol_min;
1336 /* Hack -- optional disturb on "panel change" */
1337 if (disturb_panel && !center_player) disturb(FALSE, FALSE);
1339 /* Recalculate the boundaries */
1340 panel_bounds_center();
1342 p_ptr->update |= (PU_MONSTERS);
1343 p_ptr->redraw |= (PR_MAP);
1344 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
1349 * Monster health description
1351 concptr look_mon_desc(monster_type *m_ptr, BIT_FLAGS mode)
1353 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
1360 /* Determine if the monster is "living" */
1361 living = monster_living(m_ptr->ap_r_idx);
1363 /* Calculate a health "percentage" */
1364 perc = m_ptr->maxhp > 0 ? 100L * m_ptr->hp / m_ptr->maxhp : 0;
1366 /* Healthy monsters */
1367 if (m_ptr->hp >= m_ptr->maxhp)
1369 desc = living ? _("無傷", "unhurt") : _("無ダメージ", "undamaged");
1372 else if (perc >= 60)
1374 desc = living ? _("軽傷", "somewhat wounded") : _("小ダメージ", "somewhat damaged");
1377 else if (perc >= 25)
1379 desc = living ? _("負傷", "wounded") : _("中ダメージ", "damaged");
1382 else if (perc >= 10)
1384 desc = living ? _("重傷", "badly wounded") : _("大ダメージ", "badly damaged");
1389 desc = living ? _("半死半生", "almost dead") : _("倒れかけ", "almost destroyed");
1392 /* Need attitude information? */
1395 /* Full information is not needed */
1398 else if (is_pet(m_ptr))
1400 attitude = _(", ペット", ", pet");
1402 else if (is_friendly(m_ptr))
1404 attitude = _(", 友好的", ", friendly");
1408 attitude = _("", "");
1411 /* Clone monster? */
1412 if (m_ptr->smart & SM_CLONED)
1421 /* Display monster's level --- idea borrowed from ToME */
1422 if (ap_r_ptr->r_tkills && !(m_ptr->mflag2 & MFLAG2_KAGE))
1424 return format(_("レベル%d, %s%s%s", "Level %d, %s%s%s"), ap_r_ptr->level, desc, attitude, clone);
1428 return format(_("レベル???, %s%s%s", "Level ???, %s%s%s"), desc, attitude, clone);
1435 /*** Targeting Code ***/
1439 * Determine is a monster makes a reasonable target
1441 * The concept of "targeting" was stolen from "Morgul" (?)
1443 * The player can target any location, or any "target-able" monster.
1445 * Currently, a monster is "target_able" if it is visible, and if
1446 * the player can hit it with a projection, and the player is not
1447 * hallucinating. This allows use of "use closest target" macros.
1449 * Future versions may restrict the ability to target "trappers"
1450 * and "mimics", but the semantics is a little bit weird.
1452 bool target_able(MONSTER_IDX m_idx)
1454 monster_type *m_ptr = &m_list[m_idx];
1456 /* Monster must be alive */
1457 if (!m_ptr->r_idx) return (FALSE);
1459 /* Hack -- no targeting hallucinations */
1460 if (p_ptr->image) return (FALSE);
1462 /* Monster must be visible */
1463 if (!m_ptr->ml) return (FALSE);
1465 if (p_ptr->riding && (p_ptr->riding == m_idx)) return (TRUE);
1467 /* Monster must be projectable */
1468 if (!projectable(p_ptr->y, p_ptr->x, m_ptr->fy, m_ptr->fx)) return (FALSE);
1470 /* Hack -- Never target trappers */
1471 /* if (CLEAR_ATTR && (CLEAR_CHAR)) return (FALSE); */
1481 * Update (if necessary) and verify (if possible) the target.
1483 * We return TRUE if the target is "okay" and FALSE otherwise.
1485 bool target_okay(void)
1487 /* Accept stationary targets */
1488 if (target_who < 0) return (TRUE);
1490 /* Check moving targets */
1493 /* Accept reasonable targets */
1494 if (target_able(target_who))
1496 monster_type *m_ptr = &m_list[target_who];
1498 /* Acquire monster location */
1499 target_row = m_ptr->fy;
1500 target_col = m_ptr->fx;
1507 /* Assume no target */
1513 * Sorting hook -- comp function -- by "distance to player"
1515 * We use "u" and "v" to point to arrays of "x" and "y" positions,
1516 * and sort the arrays by double-distance to the player.
1518 static bool ang_sort_comp_distance(vptr u, vptr v, int a, int b)
1520 POSITION *x = (POSITION*)(u);
1521 POSITION *y = (POSITION*)(v);
1523 POSITION da, db, kx, ky;
1525 /* Absolute distance components */
1526 kx = x[a]; kx -= p_ptr->x; kx = ABS(kx);
1527 ky = y[a]; ky -= p_ptr->y; ky = ABS(ky);
1529 /* Approximate Double Distance to the first point */
1530 da = ((kx > ky) ? (kx + kx + ky) : (ky + ky + kx));
1532 /* Absolute distance components */
1533 kx = x[b]; kx -= p_ptr->x; kx = ABS(kx);
1534 ky = y[b]; ky -= p_ptr->y; ky = ABS(ky);
1536 /* Approximate Double Distance to the first point */
1537 db = ((kx > ky) ? (kx + kx + ky) : (ky + ky + kx));
1539 /* Compare the distances */
1545 * Sorting hook -- comp function -- by importance level of grids
1547 * We use "u" and "v" to point to arrays of "x" and "y" positions,
1548 * and sort the arrays by level of monster
1550 static bool ang_sort_comp_importance(vptr u, vptr v, int a, int b)
1552 POSITION *x = (POSITION*)(u);
1553 POSITION *y = (POSITION*)(v);
1554 cave_type *ca_ptr = &cave[y[a]][x[a]];
1555 cave_type *cb_ptr = &cave[y[b]][x[b]];
1556 monster_type *ma_ptr = &m_list[ca_ptr->m_idx];
1557 monster_type *mb_ptr = &m_list[cb_ptr->m_idx];
1558 monster_race *ap_ra_ptr, *ap_rb_ptr;
1560 /* The player grid */
1561 if (y[a] == p_ptr->y && x[a] == p_ptr->x) return TRUE;
1562 if (y[b] == p_ptr->y && x[b] == p_ptr->x) return FALSE;
1564 /* Extract monster race */
1565 if (ca_ptr->m_idx && ma_ptr->ml) ap_ra_ptr = &r_info[ma_ptr->ap_r_idx];
1566 else ap_ra_ptr = NULL;
1567 if (cb_ptr->m_idx && mb_ptr->ml) ap_rb_ptr = &r_info[mb_ptr->ap_r_idx];
1568 else ap_rb_ptr = NULL;
1570 if (ap_ra_ptr && !ap_rb_ptr) return TRUE;
1571 if (!ap_ra_ptr && ap_rb_ptr) return FALSE;
1573 /* Compare two monsters */
1574 if (ap_ra_ptr && ap_rb_ptr)
1576 /* Unique monsters first */
1577 if ((ap_ra_ptr->flags1 & RF1_UNIQUE) && !(ap_rb_ptr->flags1 & RF1_UNIQUE)) return TRUE;
1578 if (!(ap_ra_ptr->flags1 & RF1_UNIQUE) && (ap_rb_ptr->flags1 & RF1_UNIQUE)) return FALSE;
1580 /* Shadowers first (あやしい影) */
1581 if ((ma_ptr->mflag2 & MFLAG2_KAGE) && !(mb_ptr->mflag2 & MFLAG2_KAGE)) return TRUE;
1582 if (!(ma_ptr->mflag2 & MFLAG2_KAGE) && (mb_ptr->mflag2 & MFLAG2_KAGE)) return FALSE;
1584 /* Unknown monsters first */
1585 if (!ap_ra_ptr->r_tkills && ap_rb_ptr->r_tkills) return TRUE;
1586 if (ap_ra_ptr->r_tkills && !ap_rb_ptr->r_tkills) return FALSE;
1588 /* Higher level monsters first (if known) */
1589 if (ap_ra_ptr->r_tkills && ap_rb_ptr->r_tkills)
1591 if (ap_ra_ptr->level > ap_rb_ptr->level) return TRUE;
1592 if (ap_ra_ptr->level < ap_rb_ptr->level) return FALSE;
1595 /* Sort by index if all conditions are same */
1596 if (ma_ptr->ap_r_idx > mb_ptr->ap_r_idx) return TRUE;
1597 if (ma_ptr->ap_r_idx < mb_ptr->ap_r_idx) return FALSE;
1600 /* An object get higher priority */
1601 if (cave[y[a]][x[a]].o_idx && !cave[y[b]][x[b]].o_idx) return TRUE;
1602 if (!cave[y[a]][x[a]].o_idx && cave[y[b]][x[b]].o_idx) return FALSE;
1604 /* Priority from the terrain */
1605 if (f_info[ca_ptr->feat].priority > f_info[cb_ptr->feat].priority) return TRUE;
1606 if (f_info[ca_ptr->feat].priority < f_info[cb_ptr->feat].priority) return FALSE;
1608 /* If all conditions are same, compare distance */
1609 return ang_sort_comp_distance(u, v, a, b);
1614 * Sorting hook -- swap function -- by "distance to player"
1616 * We use "u" and "v" to point to arrays of "x" and "y" positions,
1617 * and sort the arrays by distance to the player.
1619 static void ang_sort_swap_distance(vptr u, vptr v, int a, int b)
1621 POSITION *x = (POSITION*)(u);
1622 POSITION *y = (POSITION*)(v);
1640 * Hack -- help "select" a location (see below)
1642 static POSITION_IDX target_pick(POSITION y1, POSITION x1, POSITION dy, POSITION dx)
1645 POSITION x2, y2, x3, y3, x4, y4;
1646 POSITION_IDX b_i = -1, b_v = 9999;
1649 /* Scan the locations */
1650 for (i = 0; i < temp_n; i++)
1656 /* Directed distance */
1660 /* Verify quadrant */
1661 if (dx && (x3 * dx <= 0)) continue;
1662 if (dy && (y3 * dy <= 0)) continue;
1664 /* Absolute distance */
1668 /* Verify quadrant */
1669 if (dy && !dx && (x4 > y4)) continue;
1670 if (dx && !dy && (y4 > x4)) continue;
1672 /* Approximate Double Distance */
1673 v = ((x4 > y4) ? (x4 + x4 + y4) : (y4 + y4 + x4));
1675 /* Penalize location */
1678 if ((b_i >= 0) && (v >= b_v)) continue;
1688 * Hack -- determine if a given location is "interesting"
1690 static bool target_set_accept(POSITION y, POSITION x)
1693 OBJECT_IDX this_o_idx, next_o_idx = 0;
1696 if (!(in_bounds(y, x))) return (FALSE);
1698 /* Player grid is always interesting */
1699 if (player_bold(y, x)) return (TRUE);
1701 /* Handle hallucination */
1702 if (p_ptr->image) return (FALSE);
1704 /* Examine the grid */
1705 c_ptr = &cave[y][x];
1707 /* Visible monsters */
1710 monster_type *m_ptr = &m_list[c_ptr->m_idx];
1712 /* Visible monsters */
1713 if (m_ptr->ml) return (TRUE);
1716 /* Scan all objects in the grid */
1717 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
1720 o_ptr = &o_list[this_o_idx];
1722 /* Acquire next object */
1723 next_o_idx = o_ptr->next_o_idx;
1725 /* Memorized object */
1726 if (o_ptr->marked & OM_FOUND) return (TRUE);
1729 /* Interesting memorized features */
1730 if (c_ptr->info & (CAVE_MARK))
1732 /* Notice object features */
1733 if (c_ptr->info & CAVE_OBJECT) return (TRUE);
1735 /* Feature code (applying "mimic" field) */
1736 if (have_flag(f_info[get_feat_mimic(c_ptr)].flags, FF_NOTICE)) return TRUE;
1744 * Prepare the "temp" array for "target_set"
1746 * Return the number of target_able monsters in the set.
1748 static void target_set_prepare(BIT_FLAGS mode)
1751 POSITION min_hgt, max_hgt, min_wid, max_wid;
1753 if (mode & TARGET_KILL)
1756 min_hgt = MAX((p_ptr->y - MAX_RANGE), 0);
1757 max_hgt = MIN((p_ptr->y + MAX_RANGE), cur_hgt - 1);
1758 min_wid = MAX((p_ptr->x - MAX_RANGE), 0);
1759 max_wid = MIN((p_ptr->x + MAX_RANGE), cur_wid - 1);
1761 else /* not targetting */
1764 min_hgt = panel_row_min;
1765 max_hgt = panel_row_max;
1766 min_wid = panel_col_min;
1767 max_wid = panel_col_max;
1770 /* Reset "temp" array */
1773 /* Scan the current panel */
1774 for (y = min_hgt; y <= max_hgt; y++)
1776 for (x = min_wid; x <= max_wid; x++)
1780 /* Require "interesting" contents */
1781 if (!target_set_accept(y, x)) continue;
1783 c_ptr = &cave[y][x];
1785 /* Require target_able monsters for "TARGET_KILL" */
1786 if ((mode & (TARGET_KILL)) && !target_able(c_ptr->m_idx)) continue;
1788 if ((mode & (TARGET_KILL)) && !target_pet && is_pet(&m_list[c_ptr->m_idx])) continue;
1790 /* Save the location */
1797 /* Set the sort hooks */
1798 if (mode & (TARGET_KILL))
1800 /* Target the nearest monster for shooting */
1801 ang_sort_comp = ang_sort_comp_distance;
1802 ang_sort_swap = ang_sort_swap_distance;
1806 /* Look important grids first in Look command */
1807 ang_sort_comp = ang_sort_comp_importance;
1808 ang_sort_swap = ang_sort_swap_distance;
1811 /* Sort the positions */
1812 ang_sort(temp_x, temp_y, temp_n);
1814 if (p_ptr->riding && target_pet && (temp_n > 1) && (mode & (TARGET_KILL)))
1819 temp_y[0] = temp_y[1];
1822 temp_x[0] = temp_x[1];
1827 void target_set_prepare_look(void){
1828 target_set_prepare(TARGET_LOOK);
1833 * Evaluate number of kill needed to gain level
1835 static void evaluate_monster_exp(char *buf, monster_type *m_ptr)
1837 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
1839 s32b exp_mon, exp_adv;
1840 u32b exp_mon_frac, exp_adv_frac;
1842 if ((p_ptr->lev >= PY_MAX_LEVEL) || (p_ptr->prace == RACE_ANDROID))
1847 else if (!ap_r_ptr->r_tkills || (m_ptr->mflag2 & MFLAG2_KAGE))
1857 /* The monster's experience point (assuming average monster speed) */
1858 exp_mon = ap_r_ptr->mexp * ap_r_ptr->level;
1860 s64b_div(&exp_mon, &exp_mon_frac, 0, (p_ptr->max_plv + 2));
1863 /* Total experience value for next level */
1864 exp_adv = player_exp[p_ptr->lev -1] * p_ptr->expfact;
1866 s64b_div(&exp_adv, &exp_adv_frac, 0, 100);
1868 /* Experience value need to get */
1869 s64b_sub(&exp_adv, &exp_adv_frac, p_ptr->exp, p_ptr->exp_frac);
1872 /* You need to kill at least one monster to get any experience */
1873 s64b_add(&exp_adv, &exp_adv_frac, exp_mon, exp_mon_frac);
1874 s64b_sub(&exp_adv, &exp_adv_frac, 0, 1);
1876 /* Extract number of monsters needed */
1877 s64b_div(&exp_adv, &exp_adv_frac, exp_mon, exp_mon_frac);
1879 /* If 999 or more monsters needed, only display "999". */
1880 num = MIN(999, exp_adv_frac);
1882 /* Display the number */
1883 sprintf(buf,"%03ld", (long int)num);
1887 bool show_gold_on_floor = FALSE;
1890 * Examine a grid, return a keypress.
1892 * The "mode" argument contains the "TARGET_LOOK" bit flag, which
1893 * indicates that the "space" key should scan through the contents
1894 * of the grid, instead of simply returning immediately. This lets
1895 * the "look" command get complete information, without making the
1896 * "target" command annoying.
1898 * The "info" argument contains the "commands" which should be shown
1899 * inside the "[xxx]" text. This string must never be empty, or grids
1900 * containing monsters will be displayed with an extra comma.
1902 * Note that if a monster is in the grid, we update both the monster
1903 * recall info and the health bar info to track that monster.
1905 * Eventually, we may allow multiple objects per grid, or objects
1906 * and terrain features in the same grid.
1908 * This function must handle blindness/hallucination.
1910 static char target_set_aux(POSITION y, POSITION x, BIT_FLAGS mode, concptr info)
1912 cave_type *c_ptr = &cave[y][x];
1913 OBJECT_IDX this_o_idx, next_o_idx = 0;
1914 concptr s1 = "", s2 = "", s3 = "", x_info = "";
1917 feature_type *f_ptr;
1918 char query = '\001';
1919 char out_val[MAX_NLEN+80];
1920 OBJECT_IDX floor_list[23];
1921 ITEM_NUMBER floor_num = 0;
1923 /* Scan all objects in the grid */
1926 floor_num = scan_floor(floor_list, y, x, 0x02);
1930 x_info = _("x物 ", "x,");
1934 /* Hack -- under the player */
1935 if (player_bold(y, x))
1948 s1 = _("ターゲット:", "Target:");
1951 /* Hack -- hallucination */
1954 concptr name = _("何か奇妙な物", "something strange");
1956 /* Display a message */
1958 sprintf(out_val, "%s%s%s%s [%s]", s1, name, s2, s3, info);
1960 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, name, info);
1964 move_cursor_relative(y, x);
1967 /* Stop on everything but "return" */
1968 if ((query != '\r') && (query != '\n')) return query;
1970 /* Repeat forever */
1975 /* Actual monsters */
1976 if (c_ptr->m_idx && m_list[c_ptr->m_idx].ml)
1978 monster_type *m_ptr = &m_list[c_ptr->m_idx];
1979 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
1980 GAME_TEXT m_name[MAX_NLEN];
1981 bool recall = FALSE;
1986 monster_desc(m_name, m_ptr, MD_INDEF_VISIBLE);
1987 monster_race_track(m_ptr->ap_r_idx);
1988 health_track(c_ptr->m_idx);
2001 /* Recall on screen */
2002 screen_roff(m_ptr->ap_r_idx, 0);
2004 /* Hack -- Complete the prompt (again) */
2005 Term_addstr(-1, TERM_WHITE, format(_(" [r思 %s%s]", " [r,%s%s]"), x_info, info));
2012 /* Normal commands */
2013 if (query != 'r') break;
2018 /* Cleare recall text and repeat */
2024 /* Describe, and prompt for recall */
2025 evaluate_monster_exp(acount, m_ptr);
2028 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);
2030 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);
2036 move_cursor_relative(y, x);
2041 /* Normal commands */
2042 if (query != 'r') break;
2048 /* Always stop at "normal" keys */
2049 if ((query != '\r') && (query != '\n') && (query != ' ') && (query != 'x')) return query;
2051 /* Sometimes stop at "space" key */
2052 if ((query == ' ') && !(mode & (TARGET_LOOK))) return query;
2054 /* Change the intro */
2055 s1 = _("それは", "It is ");
2057 /* Hack -- take account of gender */
2058 if (ap_r_ptr->flags1 & (RF1_FEMALE)) s1 = _("彼女は", "She is ");
2059 else if (ap_r_ptr->flags1 & (RF1_MALE)) s1 = _("彼は", "He is ");
2061 /* Use a preposition */
2070 /* Scan all objects being carried */
2071 for (this_o_idx = m_ptr->hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
2073 GAME_TEXT o_name[MAX_NLEN];
2076 o_ptr = &o_list[this_o_idx];
2078 /* Acquire next object */
2079 next_o_idx = o_ptr->next_o_idx;
2081 /* Obtain an object description */
2082 object_desc(o_name, o_ptr, 0);
2085 sprintf(out_val, "%s%s%s%s[%s]", s1, o_name, s2, s3, info);
2087 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, o_name, info);
2091 move_cursor_relative(y, x);
2094 /* Always stop at "normal" keys */
2095 if ((query != '\r') && (query != '\n') && (query != ' ') && (query != 'x')) return query;
2097 /* Sometimes stop at "space" key */
2098 if ((query == ' ') && !(mode & (TARGET_LOOK))) return query;
2100 /* Change the intro */
2101 s2 = _("をまた", "also carrying ");
2104 /* Use a preposition */
2121 GAME_TEXT o_name[MAX_NLEN];
2124 o_ptr = &o_list[floor_list[0]];
2126 object_desc(o_name, o_ptr, 0);
2129 sprintf(out_val, "%s%s%s%s[%s]", s1, o_name, s2, s3, info);
2131 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, o_name, info);
2135 move_cursor_relative(y, x);
2144 /* Provide one cushion before item listing */
2147 /* Display rough information about items */
2149 sprintf(out_val, "%s %d個のアイテム%s%s ['x'で一覧, %s]", s1, (int)floor_num, s2, s3, info);
2151 sprintf(out_val, "%s%s%sa pile of %d items [x,%s]", s1, s2, s3, (int)floor_num, info);
2155 move_cursor_relative(y, x);
2160 /* No request for listing */
2161 if (query != 'x' && query != ' ') return query;
2165 /** Display list of items **/
2167 /* Continue scrolling list if requested */
2175 show_gold_on_floor = TRUE;
2176 (void)show_floor(0, y, x, &min_width);
2177 show_gold_on_floor = FALSE;
2181 sprintf(out_val, "%s %d個のアイテム%s%s [Enterで次へ, %s]", s1, (int)floor_num, s2, s3, info);
2183 sprintf(out_val, "%s%s%sa pile of %d items [Enter,%s]", s1, s2, s3, (int)floor_num, info);
2190 /* Exit unless 'Enter' */
2191 if (query != '\n' && query != '\r')
2196 /* Get the object being moved. */
2197 o_idx = c_ptr->o_idx;
2199 /* Only rotate a pile of two or more objects. */
2200 if (!(o_idx && o_list[o_idx].next_o_idx)) continue;
2202 /* Remove the first object from the list. */
2203 excise_object_idx(o_idx);
2205 /* Find end of the list. */
2207 while (o_list[i].next_o_idx)
2208 i = o_list[i].next_o_idx;
2210 /* Add after the last object. */
2211 o_list[i].next_o_idx = o_idx;
2213 /* Loop and re-display the list */
2220 /* Scan all objects in the grid */
2221 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
2224 o_ptr = &o_list[this_o_idx];
2226 /* Acquire next object */
2227 next_o_idx = o_ptr->next_o_idx;
2229 if (o_ptr->marked & OM_FOUND)
2231 GAME_TEXT o_name[MAX_NLEN];
2236 /* Obtain an object description */
2237 object_desc(o_name, o_ptr, 0);
2240 sprintf(out_val, "%s%s%s%s[%s]", s1, o_name, s2, s3, info);
2242 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, o_name, info);
2246 move_cursor_relative(y, x);
2249 /* Always stop at "normal" keys */
2250 if ((query != '\r') && (query != '\n') && (query != ' ') && (query != 'x')) return query;
2252 /* Sometimes stop at "space" key */
2253 if ((query == ' ') && !(mode & TARGET_LOOK)) return query;
2255 /* Change the intro */
2256 s1 = _("それは", "It is ");
2259 if (o_ptr->number != 1) s1 = _("それらは", "They are ");
2273 /* Feature code (applying "mimic" field) */
2274 feat = get_feat_mimic(c_ptr);
2276 /* Require knowledge about grid, or ability to see grid */
2277 if (!(c_ptr->info & CAVE_MARK) && !player_can_see_bold(y, x))
2279 /* Forget feature */
2283 f_ptr = &f_info[feat];
2285 /* Terrain feature if needed */
2286 if (boring || have_flag(f_ptr->flags, FF_REMEMBER))
2290 /* Hack -- special handling for quest entrances */
2291 if (have_flag(f_ptr->flags, FF_QUEST_ENTER))
2293 /* Set the quest number temporary */
2294 IDX old_quest = p_ptr->inside_quest;
2297 /* Clear the text */
2298 for (j = 0; j < 10; j++) quest_text[j][0] = '\0';
2299 quest_text_line = 0;
2301 p_ptr->inside_quest = c_ptr->special;
2303 /* Get the quest text */
2304 init_flags = INIT_NAME_ONLY;
2306 process_dungeon_file("q_info.txt", 0, 0, 0, 0);
2308 name = format(_("クエスト「%s」(%d階相当)", "the entrance to the quest '%s'(level %d)"),
2309 quest[c_ptr->special].name, quest[c_ptr->special].level);
2311 /* Reset the old quest number */
2312 p_ptr->inside_quest = old_quest;
2315 /* Hack -- special handling for building doors */
2316 else if (have_flag(f_ptr->flags, FF_BLDG) && !p_ptr->inside_arena)
2318 name = building[f_ptr->subtype].name;
2320 else if (have_flag(f_ptr->flags, FF_ENTRANCE))
2322 name = format(_("%s(%d階相当)", "%s(level %d)"), d_text + d_info[c_ptr->special].text, d_info[c_ptr->special].mindepth);
2324 else if (have_flag(f_ptr->flags, FF_TOWN))
2326 name = town[c_ptr->special].name;
2328 else if (p_ptr->wild_mode && (feat == feat_floor))
2330 name = _("道", "road");
2334 name = f_name + f_ptr->name;
2340 ((!have_flag(f_ptr->flags, FF_MOVE) && !have_flag(f_ptr->flags, FF_CAN_FLY)) ||
2341 (!have_flag(f_ptr->flags, FF_LOS) && !have_flag(f_ptr->flags, FF_TREE)) ||
2342 have_flag(f_ptr->flags, FF_TOWN)))
2344 s2 = _("の中", "in ");
2347 /* Hack -- special introduction for store & building doors -KMW- */
2348 if (have_flag(f_ptr->flags, FF_STORE) ||
2349 have_flag(f_ptr->flags, FF_QUEST_ENTER) ||
2350 (have_flag(f_ptr->flags, FF_BLDG) && !p_ptr->inside_arena) ||
2351 have_flag(f_ptr->flags, FF_ENTRANCE))
2356 else if (have_flag(f_ptr->flags, FF_FLOOR) ||
2357 have_flag(f_ptr->flags, FF_TOWN) ||
2358 have_flag(f_ptr->flags, FF_SHALLOW) ||
2359 have_flag(f_ptr->flags, FF_DEEP))
2365 /* Pick proper indefinite article */
2366 s3 = (is_a_vowel(name[0])) ? "an " : "a ";
2370 /* Display a message */
2374 if (c_ptr->mimic) sprintf(f_idx_str, "%d/%d", c_ptr->feat, c_ptr->mimic);
2375 else sprintf(f_idx_str, "%d", c_ptr->feat);
2377 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]);
2379 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);
2384 sprintf(out_val, "%s%s%s%s[%s]", s1, name, s2, s3, info);
2386 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, name, info);
2390 move_cursor_relative(y, x);
2393 /* Always stop at "normal" keys */
2394 if ((query != '\r') && (query != '\n') && (query != ' ')) return query;
2397 /* Stop on everything but "return" */
2398 if ((query != '\r') && (query != '\n')) return query;
2400 /* Repeat forever */
2406 * Handle "target" and "look".
2408 * Note that this code can be called from "get_aim_dir()".
2410 * All locations must be on the current panel. Consider the use of
2411 * "panel_bounds()" to allow "off-panel" targets, perhaps by using
2412 * some form of "scrolling" the map around the cursor.
2413 * That is, consider the possibility of "auto-scrolling" the screen
2414 * while the cursor moves around. This may require changes in the
2415 * "update_monster()" code to allow "visibility" even if off panel, and
2416 * may require dynamic recalculation of the "temp" grid set.
2418 * Hack -- targeting/observing an "outer border grid" may induce
2419 * problems, so this is not currently allowed.
2421 * The player can use the direction keys to move among "interesting"
2422 * grids in a heuristic manner, or the "space", "+", and "-" keys to
2423 * move through the "interesting" grids in a sequential manner, or
2424 * can enter "location" mode, and use the direction keys to move one
2425 * grid at a time in any direction. The "t" (set target) command will
2426 * only target a monster (as opposed to a location) if the monster is
2427 * target_able and the "interesting" mode is being used.
2429 * The current grid is described using the "look" method above, and
2430 * a new command may be entered at any time, but note that if the
2431 * "TARGET_LOOK" bit flag is set (or if we are in "location" mode,
2432 * where "space" has no obvious meaning) then "space" will scan
2433 * through the description of the current grid until done, instead
2434 * of immediately jumping to the next "interesting" grid. This
2435 * allows the "target" command to retain its old semantics.
2437 * The "*", "+", and "-" keys may always be used to jump immediately
2438 * to the next (or previous) interesting grid, in the proper mode.
2440 * The "return" key may always be used to scan through a complete
2441 * grid description (forever).
2443 * This command will cancel any old target, even if used from
2444 * inside the "look" command.
2446 bool target_set(BIT_FLAGS mode)
2449 POSITION y = p_ptr->y;
2450 POSITION x = p_ptr->x;
2460 get_screen_size(&wid, &hgt);
2465 if (rogue_like_commands)
2474 /* Prepare the "temp" array */
2475 target_set_prepare(mode);
2477 /* Start near the player */
2483 /* Interesting grids */
2490 change_panel_xy(y, x);
2492 if (!(mode & TARGET_LOOK)) prt_path(y, x);
2495 c_ptr = &cave[y][x];
2498 if (target_able(c_ptr->m_idx))
2500 strcpy(info, _("q止 t決 p自 o現 +次 -前", "q,t,p,o,+,-,<dir>"));
2503 /* Dis-allow target */
2506 strcpy(info, _("q止 p自 o現 +次 -前", "q,p,o,+,-,<dir>"));
2512 sprintf(cheatinfo, " LOS:%d, PROJECTABLE:%d",
2513 los(p_ptr->y, p_ptr->x, y, x), projectable(p_ptr->y, p_ptr->x, y, x));
2514 strcat(info, cheatinfo);
2517 /* Describe and Prompt */
2519 query = target_set_aux(y, x, mode, info);
2523 /* Assume no "direction" */
2528 if (query == '\r') query = 't';
2546 if (target_able(c_ptr->m_idx))
2548 health_track(c_ptr->m_idx);
2549 target_who = c_ptr->m_idx;
2568 if (!expand_list) done = TRUE;
2578 if (!expand_list) done = TRUE;
2585 /* Recenter the map around the player */
2587 p_ptr->update |= (PU_MONSTERS);
2588 p_ptr->redraw |= (PR_MAP);
2589 p_ptr->window |= (PW_OVERHEAD);
2592 /* Recalculate interesting grids */
2593 target_set_prepare(mode);
2612 if(query == same_key)
2617 if (!expand_list) done = TRUE;
2622 /* Extract the action (if any) */
2623 d = get_keymap_dir(query);
2630 /* Hack -- move around */
2633 /* Modified to scroll to monster */
2634 POSITION y2 = panel_row_min;
2635 POSITION x2 = panel_col_min;
2637 /* Find a new monster */
2638 i = target_pick(temp_y[m], temp_x[m], ddy[d], ddx[d]);
2640 /* Request to target past last interesting grid */
2641 while (flag && (i < 0))
2643 /* Note the change */
2644 if (change_panel(ddy[d], ddx[d]))
2649 /* Recalculate interesting grids */
2650 target_set_prepare(mode);
2652 /* Look at interesting grids */
2655 /* Find a new monster */
2656 i = target_pick(v, u, ddy[d], ddx[d]);
2662 /* Nothing interesting */
2665 POSITION dx = ddx[d];
2666 POSITION dy = ddy[d];
2668 /* Restore previous position */
2671 panel_bounds_center();
2673 p_ptr->update |= (PU_MONSTERS);
2674 p_ptr->redraw |= (PR_MAP);
2675 p_ptr->window |= (PW_OVERHEAD);
2678 /* Recalculate interesting grids */
2679 target_set_prepare(mode);
2681 /* Look at boring grids */
2688 /* Do not move horizontally if unnecessary */
2689 if (((x < panel_col_min + wid / 2) && (dx > 0)) ||
2690 ((x > panel_col_min + wid / 2) && (dx < 0)))
2695 /* Do not move vertically if unnecessary */
2696 if (((y < panel_row_min + hgt / 2) && (dy > 0)) ||
2697 ((y > panel_row_min + hgt / 2) && (dy < 0)))
2702 /* Apply the motion */
2703 if ((y >= panel_row_min+hgt) || (y < panel_row_min) ||
2704 (x >= panel_col_min+wid) || (x < panel_col_min))
2706 if (change_panel(dy, dx)) target_set_prepare(mode);
2709 /* Slide into legality */
2710 if (x >= cur_wid-1) x = cur_wid - 2;
2711 else if (x <= 0) x = 1;
2713 /* Slide into legality */
2714 if (y >= cur_hgt-1) y = cur_hgt- 2;
2715 else if (y <= 0) y = 1;
2724 /* Arbitrary grids */
2727 bool move_fast = FALSE;
2729 if (!(mode & TARGET_LOOK)) prt_path(y, x);
2732 c_ptr = &cave[y][x];
2734 /* Default prompt */
2735 strcpy(info, _("q止 t決 p自 m近 +次 -前", "q,t,p,m,+,-,<dir>"));
2740 sprintf(cheatinfo, " LOS:%d, PROJECTABLE:%d",
2741 los(p_ptr->y, p_ptr->x, y, x),
2742 projectable(p_ptr->y, p_ptr->x, y, x));
2743 strcat(info, cheatinfo);
2746 /* Describe and Prompt (enable "TARGET_LOOK") */
2747 while ((query = target_set_aux(y, x, mode | TARGET_LOOK, info)) == 0);
2749 /* Assume no direction */
2754 if (query == '\r') query = 't';
2757 /* Analyze the keypress */
2781 /* Recenter the map around the player */
2783 p_ptr->update |= (PU_MONSTERS);
2784 p_ptr->redraw |= (PR_MAP);
2785 p_ptr->window |= (PW_OVERHEAD);
2788 /* Recalculate interesting grids */
2789 target_set_prepare(mode);
2811 /* Pick a nearby monster */
2812 for (i = 0; i < temp_n; i++)
2814 t = distance(y, x, temp_y[i], temp_x[i]);
2824 /* Nothing interesting */
2825 if (bd == 999) flag = FALSE;
2832 /* Extract the action (if any) */
2833 d = get_keymap_dir(query);
2835 /* XTRA HACK MOVEFAST */
2836 if (isupper(query)) move_fast = TRUE;
2843 /* Handle "direction" */
2846 POSITION dx = ddx[d];
2847 POSITION dy = ddy[d];
2849 /* XTRA HACK MOVEFAST */
2852 int mag = MIN(wid / 2, hgt / 2);
2862 /* Do not move horizontally if unnecessary */
2863 if (((x < panel_col_min + wid / 2) && (dx > 0)) ||
2864 ((x > panel_col_min + wid / 2) && (dx < 0)))
2869 /* Do not move vertically if unnecessary */
2870 if (((y < panel_row_min + hgt / 2) && (dy > 0)) ||
2871 ((y > panel_row_min + hgt / 2) && (dy < 0)))
2876 /* Apply the motion */
2877 if ((y >= panel_row_min + hgt) || (y < panel_row_min) ||
2878 (x >= panel_col_min + wid) || (x < panel_col_min))
2880 if (change_panel(dy, dx)) target_set_prepare(mode);
2883 /* Slide into legality */
2884 if (x >= cur_wid-1) x = cur_wid - 2;
2885 else if (x <= 0) x = 1;
2887 /* Slide into legality */
2888 if (y >= cur_hgt-1) y = cur_hgt- 2;
2889 else if (y <= 0) y = 1;
2897 /* Clear the top line */
2900 /* Recenter the map around the player */
2902 p_ptr->update |= (PU_MONSTERS);
2903 p_ptr->redraw |= (PR_MAP);
2904 p_ptr->window |= (PW_OVERHEAD);
2907 /* Failure to set target */
2908 if (!target_who) return (FALSE);
2916 * Get an "aiming direction" from the user.
2918 * The "dir" is loaded with 1,2,3,4,6,7,8,9 for "actual direction", and
2919 * "0" for "current target", and "-1" for "entry aborted".
2921 * Note that "Force Target", if set, will pre-empt user interaction,
2922 * if there is a usable target already set.
2924 * Note that confusion over-rides any (explicit?) user choice.
2926 bool get_aim_dir(DIRECTION *dp)
2935 /* Global direction */
2938 /* Hack -- auto-target if requested */
2939 if (use_old_target && target_okay()) dir = 5;
2941 if (repeat_pull(&code))
2946 if (!(code == 5 && !target_okay()))
2948 /* return (TRUE); */
2949 dir = (DIRECTION)code;
2952 *dp = (DIRECTION)code;
2954 /* Ask until satisfied */
2957 /* Choose a prompt */
2960 p = _("方向 ('*'でターゲット選択, ESCで中断)? ", "Direction ('*' to choose a target, Escape to cancel)? ");
2964 p = _("方向 ('5'でターゲットへ, '*'でターゲット再選択, ESCで中断)? ", "Direction ('5' for target, '*' to re-target, Escape to cancel)? ");
2967 /* Get a command (or Cancel) */
2968 if (!get_com(p, &command, TRUE)) break;
2972 if (command == '\r') command = 't';
2975 /* Convert various keys to "standard" keys */
2978 /* Use current target */
2989 /* Set new target */
2994 if (target_set(TARGET_KILL)) dir = 5;
3000 /* Extract the action (if any) */
3001 dir = get_keymap_dir(command);
3007 /* Verify requested targets */
3008 if ((dir == 5) && !target_okay()) dir = 0;
3017 project_length = 0; /* reset to default */
3021 /* Save the direction */
3024 /* Check for confusion */
3025 if (p_ptr->confused)
3027 /* Random direction */
3028 dir = ddd[randint0(8)];
3031 /* Notice confusion */
3032 if (command_dir != dir)
3035 msg_print(_("あなたは混乱している。", "You are confused."));
3038 /* Save direction */
3041 /* repeat_push(dir); */
3042 repeat_push((COMMAND_CODE)command_dir);
3044 /* A "valid" direction was entered */
3049 bool get_direction(DIRECTION *dp, bool allow_under, bool with_steed)
3057 /* Global direction */
3060 if (repeat_pull(&code))
3062 dir = (DIRECTION)code;
3063 /* return (TRUE); */
3065 *dp = (DIRECTION)code;
3069 prompt = _("方向 ('.'足元, ESCで中断)? ", "Direction ('.' at feet, Escape to cancel)? ");
3073 prompt = _("方向 (ESCで中断)? ", "Direction (Escape to cancel)? ");
3076 /* Get a direction */
3081 /* Get a command (or Cancel) */
3082 if (!get_com(prompt, &ch, TRUE)) break;
3085 if ((allow_under) && ((ch == '5') || (ch == '-') || (ch == '.')))
3091 /* Look up the direction */
3092 dir = get_keymap_dir(ch);
3098 /* Prevent weirdness */
3099 if ((dir == 5) && (!allow_under)) dir = 0;
3102 if (!dir) return (FALSE);
3104 /* Save desired direction */
3107 /* Apply "confusion" */
3108 if (p_ptr->confused)
3110 /* Standard confusion */
3111 if (randint0(100) < 75)
3113 /* Random direction */
3114 dir = ddd[randint0(8)];
3117 else if (p_ptr->riding && with_steed)
3119 monster_type *m_ptr = &m_list[p_ptr->riding];
3120 monster_race *r_ptr = &r_info[m_ptr->r_idx];
3122 if (MON_CONFUSED(m_ptr))
3124 /* Standard confusion */
3125 if (randint0(100) < 75)
3127 /* Random direction */
3128 dir = ddd[randint0(8)];
3131 else if ((r_ptr->flags1 & RF1_RAND_50) && (r_ptr->flags1 & RF1_RAND_25) && (randint0(100) < 50))
3133 /* Random direction */
3134 dir = ddd[randint0(8)];
3136 else if ((r_ptr->flags1 & RF1_RAND_50) && (randint0(100) < 25))
3138 /* Random direction */
3139 dir = ddd[randint0(8)];
3143 /* Notice confusion */
3144 if (command_dir != dir)
3146 if (p_ptr->confused)
3149 msg_print(_("あなたは混乱している。", "You are confused."));
3153 GAME_TEXT m_name[MAX_NLEN];
3154 monster_type *m_ptr = &m_list[p_ptr->riding];
3156 monster_desc(m_name, m_ptr, 0);
3157 if (MON_CONFUSED(m_ptr))
3159 msg_format(_("%sは混乱している。", "%^s is confusing."), m_name);
3163 msg_format(_("%sは思い通りに動いてくれない。", "You cannot control %s."), m_name);
3168 /* Save direction */
3171 /* repeat_push(dir); */
3172 repeat_push((COMMAND_CODE)command_dir);
3179 * @brief 進行方向を指定する(騎乗対象の混乱の影響を受ける) / Request a "movement" direction (1,2,3,4,6,7,8,9) from the user,
3180 * and place it into "command_dir", unless we already have one.
3182 * This function should be used for all "repeatable" commands, such as
3183 * run, walk, open, close, bash, disarm, spike, tunnel, etc, as well
3184 * as all commands which must reference a grid adjacent to the player,
3185 * and which may not reference the grid under the player. Note that,
3186 * for example, it is no longer possible to "disarm" or "open" chests
3187 * in the same grid as the player.
3189 * Direction "5" is illegal and will (cleanly) abort the command.
3191 * This function tracks and uses the "global direction", and uses
3192 * that as the "desired direction", to which "confusion" is applied.
3194 bool get_rep_dir(DIRECTION *dp, bool under)
3202 /* Global direction */
3205 if (repeat_pull(&code))
3207 dir = (DIRECTION)code;
3208 /* return (TRUE); */
3210 *dp = (DIRECTION)code;
3214 prompt = _("方向 ('.'足元, ESCで中断)? ", "Direction ('.' at feet, Escape to cancel)? ");
3218 prompt = _("方向 (ESCで中断)? ", "Direction (Escape to cancel)? ");
3221 /* Get a direction */
3226 /* Get a command (or Cancel) */
3227 if (!get_com(prompt, &ch, TRUE)) break;
3230 if ((under) && ((ch == '5') || (ch == '-') || (ch == '.')))
3236 /* Look up the direction */
3237 dir = get_keymap_dir(ch);
3243 /* Prevent weirdness */
3244 if ((dir == 5) && (!under)) dir = 0;
3247 if (!dir) return (FALSE);
3249 /* Save desired direction */
3252 /* Apply "confusion" */
3253 if (p_ptr->confused)
3255 /* Standard confusion */
3256 if (randint0(100) < 75)
3258 /* Random direction */
3259 dir = ddd[randint0(8)];
3262 else if (p_ptr->riding)
3264 monster_type *m_ptr = &m_list[p_ptr->riding];
3265 monster_race *r_ptr = &r_info[m_ptr->r_idx];
3267 if (MON_CONFUSED(m_ptr))
3269 /* Standard confusion */
3270 if (randint0(100) < 75)
3272 /* Random direction */
3273 dir = ddd[randint0(8)];
3276 else if ((r_ptr->flags1 & RF1_RAND_50) && (r_ptr->flags1 & RF1_RAND_25) && (randint0(100) < 50))
3278 /* Random direction */
3279 dir = ddd[randint0(8)];
3281 else if ((r_ptr->flags1 & RF1_RAND_50) && (randint0(100) < 25))
3283 /* Random direction */
3284 dir = ddd[randint0(8)];
3288 /* Notice confusion */
3289 if (command_dir != dir)
3291 if (p_ptr->confused)
3294 msg_print(_("あなたは混乱している。", "You are confused."));
3298 GAME_TEXT m_name[MAX_NLEN];
3299 monster_type *m_ptr = &m_list[p_ptr->riding];
3301 monster_desc(m_name, m_ptr, 0);
3302 if (MON_CONFUSED(m_ptr))
3304 msg_format(_("%sは混乱している。", "%^s is confusing."), m_name);
3308 msg_format(_("%sは思い通りに動いてくれない。", "You cannot control %s."), m_name);
3313 /* Save direction */
3316 /* repeat_push(dir); */
3317 repeat_push((COMMAND_CODE)command_dir);
3323 void gain_level_reward(int chosen_reward)
3327 char wrath_reason[32] = "";
3328 int nasty_chance = 6;
3329 OBJECT_TYPE_VALUE dummy = 0;
3330 OBJECT_SUBTYPE_VALUE dummy2 = 0;
3332 concptr reward = NULL;
3333 GAME_TEXT o_name[MAX_NLEN];
3339 if (multi_rew) return;
3340 else multi_rew = TRUE;
3344 if (p_ptr->lev == 13) nasty_chance = 2;
3345 else if (!(p_ptr->lev % 13)) nasty_chance = 3;
3346 else if (!(p_ptr->lev % 14)) nasty_chance = 12;
3348 if (one_in_(nasty_chance))
3349 type = randint1(20); /* Allow the 'nasty' effects */
3351 type = randint1(15) + 5; /* Or disallow them */
3353 if (type < 1) type = 1;
3354 if (type > 20) type = 20;
3358 sprintf(wrath_reason, _("%sの怒り", "the Wrath of %s"), chaos_patrons[p_ptr->chaos_patron]);
3360 effect = chaos_rewards[p_ptr->chaos_patron][type];
3362 if (one_in_(6) && !chosen_reward)
3364 msg_format(_("%^sは褒美としてあなたを突然変異させた。", "%^s rewards you with a mutation!"), chaos_patrons[p_ptr->chaos_patron]);
3365 (void)gain_random_mutation(0);
3366 reward = _("変異した。", "mutation");
3370 switch (chosen_reward ? chosen_reward : effect)
3375 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
3376 msg_print(_("「汝、新たなる姿を必要とせり!」", "'Thou needst a new form, mortal!'"));
3379 reward = _("変異した。", "polymorphing");
3384 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
3385 msg_print(_("「汝は良く行いたり!続けよ!」", "'Well done, mortal! Lead on!'"));
3387 if (p_ptr->prace == RACE_ANDROID)
3389 msg_print(_("しかし何も起こらなかった。", "But, nothing happen."));
3391 else if (p_ptr->exp < PY_MAX_EXP)
3393 s32b ee = (p_ptr->exp / 2) + 10;
3394 if (ee > 100000L) ee = 100000L;
3395 msg_print(_("更に経験を積んだような気がする。", "You feel more experienced."));
3398 reward = _("経験値を得た", "experience");
3404 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
3405 msg_print(_("「下僕よ、汝それに値せず。」", "'Thou didst not deserve that, slave.'"));
3407 if (p_ptr->prace == RACE_ANDROID)
3409 msg_print(_("しかし何も起こらなかった。", "But, nothing happen."));
3413 lose_exp(p_ptr->exp / 6);
3414 reward = _("経験値を失った。", "losing experience");
3420 msg_format("%sの声がささやいた:",
3421 chaos_patrons[p_ptr->chaos_patron]);
3423 msg_format("The voice of %s whispers:",
3424 chaos_patrons[p_ptr->chaos_patron]);
3427 msg_print(_("「我が与えし物を賢明に使うべし。」", "'Use my gift wisely.'"));
3429 acquirement(p_ptr->y, p_ptr->x, 1, FALSE, FALSE, FALSE);
3430 reward = _("上質なアイテムを手に入れた。", "a good item");
3435 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
3436 msg_print(_("「我が与えし物を賢明に使うべし。」", "'Use my gift wisely.'"));
3438 acquirement(p_ptr->y, p_ptr->x, 1, TRUE, FALSE, FALSE);
3439 reward = _("高級品のアイテムを手に入れた。", "an excellent item");
3444 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
3445 msg_print(_("「汝の行いは貴き剣に値せり。」", "'Thy deed hath earned thee a worthy blade.'"));
3448 switch (randint1(p_ptr->lev))
3454 dummy2 = SV_MAIN_GAUCHE;
3463 dummy2 = SV_SMALL_SWORD;
3466 dummy2 = SV_BASILLARD;
3468 case 11: case 12: case 13:
3469 dummy2 = SV_SHORT_SWORD;
3475 dummy2 = SV_CUTLASS;
3478 dummy2 = SV_WAKIZASHI;
3481 dummy2 = SV_KHOPESH;
3487 dummy2 = SV_BROAD_SWORD;
3490 dummy2 = SV_LONG_SWORD;
3493 dummy2 = SV_SCIMITAR;
3496 dummy2 = SV_NINJATO;
3502 dummy2 = SV_BASTARD_SWORD;
3505 dummy2 = SV_GREAT_SCIMITAR;
3508 dummy2 = SV_CLAYMORE;
3511 dummy2 = SV_ESPADON;
3514 dummy2 = SV_TWO_HANDED_SWORD;
3517 dummy2 = SV_FLAMBERGE;
3520 dummy2 = SV_NO_DACHI;
3523 dummy2 = SV_EXECUTIONERS_SWORD;
3526 dummy2 = SV_ZWEIHANDER;
3529 dummy2 = SV_HAYABUSA;
3532 dummy2 = SV_BLADE_OF_CHAOS;
3535 object_prep(q_ptr, lookup_kind(dummy, dummy2));
3536 q_ptr->to_h = 3 + randint1(dun_level) % 10;
3537 q_ptr->to_d = 3 + randint1(dun_level) % 10;
3538 one_resistance(q_ptr);
3539 q_ptr->name2 = EGO_CHAOTIC;
3540 (void)drop_near(q_ptr, -1, p_ptr->y, p_ptr->x);
3541 reward = _("(混沌)の武器を手に入れた。", "chaos weapon");
3546 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
3547 msg_print(_("「汝の行いは貴き報いに値せり。」", "'Thy deed hath earned thee a worthy reward.'"));
3549 acquirement(p_ptr->y, p_ptr->x, randint1(2) + 1, FALSE, FALSE, FALSE);
3550 reward = _("上質なアイテムを手に入れた。", "good items");
3555 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
3556 msg_print(_("「下僕よ、汝の献身への我が惜しみ無き報いを見るがよい。」", "'Behold, mortal, how generously I reward thy loyalty.'"));
3558 acquirement(p_ptr->y, p_ptr->x, randint1(2) + 1, TRUE, FALSE, FALSE);
3559 reward = _("高級品のアイテムを手に入れた。", "excellent items");
3564 msg_format("%sの声が轟き渡った:", chaos_patrons[p_ptr->chaos_patron]);
3566 msg_format("The voice of %s thunders:", chaos_patrons[p_ptr->chaos_patron]);
3569 msg_print(_("「下僕よ、汝傲慢なり。」", "'Thou art growing arrogant, mortal.'"));
3571 (void)activate_ty_curse(FALSE, &count);
3572 reward = _("禍々しい呪いをかけられた。", "cursing");
3577 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
3578 msg_print(_("「我が下僕たちよ、かの傲慢なる者を倒すべし!」", "'My pets, destroy the arrogant mortal!'"));
3580 for (dummy = 0; dummy < randint1(5) + 1; dummy++)
3582 (void)summon_specific(0, p_ptr->y, p_ptr->x, dun_level, 0, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET), '\0');
3584 reward = _("モンスターを召喚された。", "summoning hostile monsters");
3590 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
3591 msg_print(_("「汝、より強き敵を必要とせり!」", "'Thou needst worthier opponents!'"));
3593 activate_hi_summon(p_ptr->y, p_ptr->x, FALSE);
3594 reward = _("モンスターを召喚された。", "summoning many hostile monsters");
3600 msg_format("%sの声が響き渡った:",
3601 chaos_patrons[p_ptr->chaos_patron]);
3603 msg_format("The voice of %s booms out:",
3604 chaos_patrons[p_ptr->chaos_patron]);
3607 msg_print(_("「死と破壊こそ我が喜びなり!」", "'Death and destruction! This pleaseth me!'"));
3610 reward = _("カオスの力が渦巻いた。", "calling chaos");
3616 msg_format("%sの声が鳴り響いた:",
3617 chaos_patrons[p_ptr->chaos_patron]);
3619 msg_format("The voice of %s rings out:",
3620 chaos_patrons[p_ptr->chaos_patron]);
3623 msg_print(_("「留まるのだ、下僕よ。余が汝の肉体を鍛えん。」", "'Stay, mortal, and let me mold thee.'"));
3625 if (one_in_(3) && !(chaos_stats[p_ptr->chaos_patron] < 0))
3626 do_inc_stat(chaos_stats[p_ptr->chaos_patron]);
3628 do_inc_stat(randint0(6));
3629 reward = _("能力値が上がった。", "increasing a stat");
3635 msg_format("%sの声が響き渡った:",
3636 chaos_patrons[p_ptr->chaos_patron]);
3638 msg_format("The voice of %s booms out:",
3639 chaos_patrons[p_ptr->chaos_patron]);
3642 msg_print(_("「下僕よ、余は汝に飽みたり。」", "'I grow tired of thee, mortal.'"));
3644 if (one_in_(3) && !(chaos_stats[p_ptr->chaos_patron] < 0))
3645 do_dec_stat(chaos_stats[p_ptr->chaos_patron]);
3647 (void)do_dec_stat(randint0(6));
3648 reward = _("能力値が下がった。", "decreasing a stat");
3655 msg_format("%sの声が轟き渡った:",
3656 chaos_patrons[p_ptr->chaos_patron]);
3658 msg_format("The voice of %s thunders:",
3659 chaos_patrons[p_ptr->chaos_patron]);
3662 msg_print(_("「汝、謙虚たることを学ぶべし!」", "'Thou needst a lesson in humility, mortal!'"));
3663 msg_print(_("あなたは以前より弱くなった!", "You feel less powerful!"));
3665 for (dummy = 0; dummy < A_MAX; dummy++)
3667 (void)dec_stat(dummy, 10 + randint1(15), TRUE);
3669 reward = _("全能力値が下がった。", "decreasing all stats");
3674 msg_format(_("%sの力が触れるのを感じた。", "You feel the power of %s touch you."),
3675 chaos_patrons[p_ptr->chaos_patron]);
3677 reward = _("傷が変化した。", "polymorphing wounds");
3682 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
3684 msg_print(_("「我がささやかなる賜物を受けとるがよい!」", "'Receive this modest gift from me!'"));
3686 for (dummy = 0; dummy < A_MAX; dummy++)
3688 (void)do_inc_stat(dummy);
3690 reward = _("全能力値が上がった。", "increasing all stats");
3695 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
3696 msg_print(_("「苦しむがよい、無能な愚か者よ!」", "'Suffer, pathetic fool!'"));
3698 fire_ball(GF_DISINTEGRATE, 0, p_ptr->lev * 4, 4);
3699 take_hit(DAMAGE_NOESCAPE, p_ptr->lev * 4, wrath_reason, -1);
3700 reward = _("分解の球が発生した。", "generating disintegration ball");
3705 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
3706 (void)restore_level();
3707 (void)restore_all_status();
3708 (void)true_healing(5000);
3709 reward = _("体力が回復した。", "healing");
3714 if (!buki_motteruka(INVEN_RARM) && !buki_motteruka(INVEN_LARM)) break;
3715 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
3716 msg_print(_("「汝、武器に頼ることなかれ。」", "'Thou reliest too much on thy weapon.'"));
3719 if (buki_motteruka(INVEN_LARM))
3722 if (buki_motteruka(INVEN_RARM) && one_in_(2)) dummy = INVEN_RARM;
3724 object_desc(o_name, &inventory[dummy], OD_NAME_ONLY);
3725 (void)curse_weapon(FALSE, dummy);
3726 reward = format(_("%sが破壊された。", "destroying %s"), o_name);
3731 if (!inventory[INVEN_BODY].k_idx) break;
3732 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
3733 msg_print(_("「汝、防具に頼ることなかれ。」", "'Thou reliest too much on thine equipment.'"));
3735 object_desc(o_name, &inventory[INVEN_BODY], OD_NAME_ONLY);
3736 (void)curse_armor();
3737 reward = format(_("%sが破壊された。", "destroying %s"), o_name);
3741 msg_format(_("%sの声がささやいた:", "The voice of %s whispers:"), chaos_patrons[p_ptr->chaos_patron]);
3742 msg_print(_("「我を怒りしめた罪を償うべし。」", "'Now thou shalt pay for annoying me.'"));
3744 switch (randint1(4))
3747 (void)activate_ty_curse(FALSE, &count);
3748 reward = _("禍々しい呪いをかけられた。", "cursing");
3751 activate_hi_summon(p_ptr->y, p_ptr->x, FALSE);
3752 reward = _("モンスターを召喚された。", "summoning hostile monsters");
3757 if (!buki_motteruka(INVEN_RARM) && !buki_motteruka(INVEN_LARM)) break;
3759 if (buki_motteruka(INVEN_LARM))
3762 if (buki_motteruka(INVEN_RARM) && one_in_(2)) dummy = INVEN_RARM;
3764 object_desc(o_name, &inventory[dummy], OD_NAME_ONLY);
3765 (void)curse_weapon(FALSE, dummy);
3766 reward = format(_("%sが破壊された。", "destroying %s"), o_name);
3770 if (!inventory[INVEN_BODY].k_idx) break;
3771 object_desc(o_name, &inventory[INVEN_BODY], OD_NAME_ONLY);
3772 (void)curse_armor();
3773 reward = format(_("%sが破壊された。", "destroying %s"), o_name);
3777 for (dummy = 0; dummy < A_MAX; dummy++)
3779 (void)dec_stat(dummy, 10 + randint1(15), TRUE);
3781 reward = _("全能力値が下がった。", "decreasing all stats");
3788 msg_format(_("%sの声が轟き渡った:", "The voice of %s thunders:"), chaos_patrons[p_ptr->chaos_patron]);
3789 msg_print(_("「死ぬがよい、下僕よ!」", "'Die, mortal!'"));
3791 take_hit(DAMAGE_LOSELIFE, p_ptr->lev * 4, wrath_reason, -1);
3792 for (dummy = 0; dummy < A_MAX; dummy++)
3794 (void)dec_stat(dummy, 10 + randint1(15), FALSE);
3796 activate_hi_summon(p_ptr->y, p_ptr->x, FALSE);
3797 (void)activate_ty_curse(FALSE, &count);
3802 if (buki_motteruka(INVEN_RARM))
3805 if (buki_motteruka(INVEN_LARM) && one_in_(2)) dummy = INVEN_LARM;
3807 else if (buki_motteruka(INVEN_LARM)) dummy = INVEN_LARM;
3809 if (dummy) (void)curse_weapon(FALSE, dummy);
3811 if (one_in_(2)) (void)curse_armor();
3816 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
3817 msg_print(_("「死と破壊こそ我が喜びなり!」", "'Death and destruction! This pleaseth me!'"));
3819 (void)destroy_area(p_ptr->y, p_ptr->x, 25, FALSE);
3820 reward = _("ダンジョンが*破壊*された。", "*destruct*ing dungeon");
3825 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
3826 msg_print(_("「我、汝の敵を抹殺せん!」", "'Let me relieve thee of thine oppressors!'"));
3827 (void)symbol_genocide(0, FALSE);
3828 reward = _("モンスターが抹殺された。", "genociding monsters");
3833 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
3834 msg_print(_("「我、汝の敵を抹殺せん!」", "'Let me relieve thee of thine oppressors!'"));
3836 (void)mass_genocide(0, FALSE);
3837 reward = _("モンスターが抹殺された。", "genociding nearby monsters");
3842 msg_format(_("%sの力が敵を攻撃するのを感じた!", "You can feel the power of %s assault your enemies!"), chaos_patrons[p_ptr->chaos_patron]);
3843 (void)dispel_monsters(p_ptr->lev * 4);
3848 msg_format(_("%sはあなたを無視した。", "%s ignores you."), chaos_patrons[p_ptr->chaos_patron]);
3853 msg_format(_("%sは褒美として悪魔の使いをよこした!", "%s rewards you with a demonic servant!"),chaos_patrons[p_ptr->chaos_patron]);
3855 if (!summon_specific(-1, p_ptr->y, p_ptr->x, dun_level, SUMMON_DEMON, PM_FORCE_PET, '\0'))
3856 msg_print(_("何も現れなかった...", "Nobody ever turns up..."));
3858 reward = _("悪魔がペットになった。", "a demonic servant");
3863 msg_format(_("%sは褒美として使いをよこした!", "%s rewards you with a servant!"),chaos_patrons[p_ptr->chaos_patron]);
3865 if (!summon_specific(-1, p_ptr->y, p_ptr->x, dun_level, 0, PM_FORCE_PET, '\0'))
3866 msg_print(_("何も現れなかった...", "Nobody ever turns up..."));
3868 reward = _("モンスターがペットになった。", "a servant");
3873 msg_format(_("%sは褒美としてアンデッドの使いをよこした。", "%s rewards you with an undead servant!"),chaos_patrons[p_ptr->chaos_patron]);
3875 if (!summon_specific(-1, p_ptr->y, p_ptr->x, dun_level, SUMMON_UNDEAD, PM_FORCE_PET, '\0'))
3876 msg_print(_("何も現れなかった...", "Nobody ever turns up..."));
3878 reward = _("アンデッドがペットになった。", "an undead servant");
3883 msg_format(_("%sの声がどもった:", "The voice of %s stammers:"),
3885 chaos_patrons[p_ptr->chaos_patron]);
3886 msg_format(_("「あー、あー、答えは %d/%d。質問は何?」", "'Uh... uh... the answer's %d/%d, what's the question?'"), type, effect);
3892 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, format(_("パトロンの報酬で%s", "The patron rewards you with %s."), reward));
3898 * XAngband: determine if a given location is "interesting"
3899 * based on target_set_accept function.
3901 static bool tgt_pt_accept(POSITION y, POSITION x)
3906 if (!(in_bounds(y, x))) return (FALSE);
3908 /* Player grid is always interesting */
3909 if ((y == p_ptr->y) && (x == p_ptr->x)) return (TRUE);
3911 /* Handle hallucination */
3912 if (p_ptr->image) return (FALSE);
3914 /* Examine the grid */
3915 c_ptr = &cave[y][x];
3917 /* Interesting memorized features */
3918 if (c_ptr->info & (CAVE_MARK))
3921 if (cave_have_flag_grid(c_ptr, FF_LESS)) return (TRUE);
3922 if (cave_have_flag_grid(c_ptr, FF_MORE)) return (TRUE);
3924 /* Notice quest features */
3925 if (cave_have_flag_grid(c_ptr, FF_QUEST_ENTER)) return (TRUE);
3926 if (cave_have_flag_grid(c_ptr, FF_QUEST_EXIT)) return (TRUE);
3934 * XAngband: Prepare the "temp" array for "tget_pt"
3935 * based on target_set_prepare funciton.
3937 static void tgt_pt_prepare(void)
3941 /* Reset "temp" array */
3944 if (!expand_list) return;
3946 /* Scan the current panel */
3947 for (y = 1; y < cur_hgt; y++)
3949 for (x = 1; x < cur_wid; x++)
3951 /* Require "interesting" contents */
3952 if (!tgt_pt_accept(y, x)) continue;
3954 /* Save the location */
3961 /* Target the nearest monster for shooting */
3962 ang_sort_comp = ang_sort_comp_distance;
3963 ang_sort_swap = ang_sort_swap_distance;
3965 /* Sort the positions */
3966 ang_sort(temp_x, temp_y, temp_n);
3970 * old -- from PsiAngband.
3972 bool tgt_pt(POSITION *x_ptr, POSITION *y_ptr)
3977 bool success = FALSE;
3981 get_screen_size(&wid, &hgt);
3991 msg_print(_("場所を選んでスペースキーを押して下さい。", "Select a point and press space."));
3992 msg_flag = FALSE; /* prevents "-more-" message. */
3994 while ((ch != ESCAPE) && !success)
3996 bool move_fast = FALSE;
3998 move_cursor_relative(y, x);
4010 if (player_bold(y, x)) ch = 0;
4013 else success = TRUE;
4017 /* XAngband: Move cursor to stairs */
4020 if (expand_list && temp_n)
4023 int cx = (panel_col_min + panel_col_max) / 2;
4024 int cy = (panel_row_min + panel_row_max) / 2;
4028 /* Skip stairs which have defferent distance */
4029 for (; n < temp_n; ++ n)
4031 cave_type *c_ptr = &cave[temp_y[n]][temp_x[n]];
4033 if (cave_have_flag_grid(c_ptr, FF_STAIRS) &&
4034 cave_have_flag_grid(c_ptr, ch == '>' ? FF_MORE : FF_LESS))
4041 if (n == temp_n) /* Loop out taget list */
4046 verify_panel(); /* Move cursor to player */
4048 p_ptr->update |= (PU_MONSTERS);
4050 p_ptr->redraw |= (PR_MAP);
4052 p_ptr->window |= (PW_OVERHEAD);
4055 else /* move cursor to next stair and change panel */
4060 dy = 2 * (y - cy) / hgt;
4061 dx = 2 * (x - cx) / wid;
4062 if (dy || dx) change_panel(dy, dx);
4068 /* Look up the direction */
4069 d = get_keymap_dir(ch);
4071 /* XTRA HACK MOVEFAST */
4072 if (isupper(ch)) move_fast = TRUE;
4074 /* Handle "direction" */
4080 /* XTRA HACK MOVEFAST */
4083 int mag = MIN(wid / 2, hgt / 2);
4093 /* Do not move horizontally if unnecessary */
4094 if (((x < panel_col_min + wid / 2) && (dx > 0)) ||
4095 ((x > panel_col_min + wid / 2) && (dx < 0)))
4100 /* Do not move vertically if unnecessary */
4101 if (((y < panel_row_min + hgt / 2) && (dy > 0)) ||
4102 ((y > panel_row_min + hgt / 2) && (dy < 0)))
4107 /* Apply the motion */
4108 if ((y >= panel_row_min + hgt) || (y < panel_row_min) ||
4109 (x >= panel_col_min + wid) || (x < panel_col_min))
4111 /* if (change_panel(dy, dx)) target_set_prepare(mode); */
4112 change_panel(dy, dx);
4115 /* Slide into legality */
4116 if (x >= cur_wid-1) x = cur_wid - 2;
4117 else if (x <= 0) x = 1;
4119 /* Slide into legality */
4120 if (y >= cur_hgt-1) y = cur_hgt- 2;
4121 else if (y <= 0) y = 1;
4128 /* Clear the top line */
4131 /* Recenter the map around the player */
4134 p_ptr->update |= (PU_MONSTERS);
4136 p_ptr->redraw |= (PR_MAP);
4138 p_ptr->window |= (PW_OVERHEAD);
4147 bool get_hack_dir(DIRECTION *dp)
4155 /* Global direction */
4158 /* (No auto-targeting) */
4160 /* Ask until satisfied */
4163 /* Choose a prompt */
4166 p = _("方向 ('*'でターゲット選択, ESCで中断)? ", "Direction ('*' to choose a target, Escape to cancel)? ");
4170 p = _("方向 ('5'でターゲットへ, '*'でターゲット再選択, ESCで中断)? ", "Direction ('5' for target, '*' to re-target, Escape to cancel)? ");
4173 /* Get a command (or Cancel) */
4174 if (!get_com(p, &command, TRUE)) break;
4178 if (command == '\r') command = 't';
4181 /* Convert various keys to "standard" keys */
4184 /* Use current target */
4195 /* Set new target */
4200 if (target_set(TARGET_KILL)) dir = 5;
4206 /* Look up the direction */
4207 dir = get_keymap_dir(command);
4213 /* Verify requested targets */
4214 if ((dir == 5) && !target_okay()) dir = 0;
4221 if (!dir) return (FALSE);
4223 /* Save the direction */
4226 /* Check for confusion */
4227 if (p_ptr->confused)
4229 /* Random direction */
4230 dir = ddd[randint0(8)];
4233 /* Notice confusion */
4234 if (command_dir != dir)
4237 msg_print(_("あなたは混乱している。", "You are confused."));
4240 /* Save direction */
4243 /* A "valid" direction was entered */
4249 * @brief 射撃武器の攻撃に必要な基本消費エネルギーを返す/Return bow energy
4250 * @param sval 射撃武器のアイテム副分類ID
4251 * @return 消費する基本エネルギー
4253 ENERGY bow_energy(OBJECT_SUBTYPE_VALUE sval)
4255 ENERGY energy = 10000;
4257 /* Analyze the launcher */
4260 /* Sling and ammo */
4267 /* Short Bow and Arrow */
4274 /* Long Bow and Arrow */
4281 /* Bow of irresponsiblity and Arrow */
4288 /* Light Crossbow and Bolt */
4295 /* Heavy Crossbow and Bolt */
4310 int bow_tmul(OBJECT_SUBTYPE_VALUE sval)
4314 /* Analyze the launcher */
4317 /* Sling and ammo */
4324 /* Short Bow and Arrow */
4331 /* Long Bow and Arrow */
4338 /* Bow of irresponsiblity and Arrow */
4345 /* Light Crossbow and Bolt */
4352 /* Heavy Crossbow and Bolt */
4365 * Display a rumor and apply its effects
4368 IDX rumor_num(char *zz, IDX max_idx)
4370 if (strcmp(zz, "*") == 0) return randint1(max_idx - 1);
4371 return (IDX)atoi(zz);
4374 concptr rumor_bind_name(char *base, concptr fullname)
4378 s = strstr(base, "{Name}");
4382 v = format("%s%s%s", base, fullname, (s + 6));
4392 void display_rumor(bool ex)
4400 if (randint0(3) == 0) section = 1;
4403 err = _(get_rnd_line_jonly("rumors_j.txt", section, Rumor, 10),
4404 get_rnd_line("rumors.txt", section, Rumor));
4405 if (err) strcpy(Rumor, _("嘘の噂もある。", "Some rumors are wrong."));
4409 if (strncmp(Rumor, "R:", 2) == 0)
4412 concptr rumor_msg = NULL;
4413 concptr rumor_eff_format = NULL;
4414 char fullname[1024] = "";
4416 if (tokenize(Rumor + 2, 3, zz, TOKENIZE_CHECKQUOTE) == 3)
4418 if (strcmp(zz[0], "ARTIFACT") == 0)
4422 object_type *q_ptr = &forge;
4423 artifact_type *a_ptr;
4427 a_idx = rumor_num(zz[1], max_a_idx);
4429 a_ptr = &a_info[a_idx];
4430 if (a_ptr->name) break;
4433 k_idx = lookup_kind(a_ptr->tval, a_ptr->sval);
4434 object_prep(q_ptr, k_idx);
4435 q_ptr->name1 = a_idx;
4436 q_ptr->ident = IDENT_STORE;
4437 object_desc(fullname, q_ptr, OD_NAME_ONLY);
4439 else if (strcmp(zz[0], "MONSTER") == 0)
4442 monster_race *r_ptr;
4446 r_idx = rumor_num(zz[1], max_r_idx);
4447 r_ptr = &r_info[r_idx];
4448 if (r_ptr->name) break;
4451 strcpy(fullname, r_name + r_ptr->name);
4453 /* Remember this monster */
4454 if (!r_ptr->r_sights)
4459 else if (strcmp(zz[0], "DUNGEON") == 0)
4462 dungeon_info_type *d_ptr;
4466 d_idx = rumor_num(zz[1], max_d_idx);
4467 d_ptr = &d_info[d_idx];
4468 if (d_ptr->name) break;
4471 strcpy(fullname, d_name + d_ptr->name);
4473 if (!max_dlv[d_idx])
4475 max_dlv[d_idx] = d_ptr->mindepth;
4476 rumor_eff_format = _("%sに帰還できるようになった。", "You can recall to %s.");
4479 else if (strcmp(zz[0], "TOWN") == 0)
4486 t_idx = rumor_num(zz[1], NO_TOWN);
4487 if (town[t_idx].name) break;
4490 strcpy(fullname, town[t_idx].name);
4492 visit = (1L << (t_idx - 1));
4493 if ((t_idx != SECRET_TOWN) && !(p_ptr->visit & visit))
4495 p_ptr->visit |= visit;
4496 rumor_eff_format = _("%sに行ったことがある気がする。", "You feel you have been to %s.");
4500 rumor_msg = rumor_bind_name(zz[2], fullname);
4501 msg_print(rumor_msg);
4502 if (rumor_eff_format)
4505 msg_format(rumor_eff_format, fullname);
4510 if (err) msg_print(_("この情報は間違っている。", "This information is wrong."));
4514 msg_format("%s", Rumor);