3 * @brief 雑多なその他の処理2 / effects of various "objects"
6 * Copyright (c) 1989 James E. Wilson, Robert A. Koeneke\n
7 * This software may be copied and distributed for educational, research, and\n
8 * not for profit purposes provided that this copyright and statement are\n
9 * included in all such copies.\n
10 * 2014 Deskull rearranged comment for Doxygen.
16 #include "object-curse.h"
18 #define REWARD_CHANCE 10
22 * @brief プレイヤーの経験値について整合性のためのチェックと調整を行う /
23 * Advance experience levels and print experience
26 void check_experience(void)
28 bool level_reward = FALSE;
29 bool level_mutation = FALSE;
30 bool level_inc_stat = FALSE;
31 bool android = (p_ptr->prace == RACE_ANDROID ? TRUE : FALSE);
32 PLAYER_LEVEL old_lev = p_ptr->lev;
34 /* Hack -- lower limit */
35 if (p_ptr->exp < 0) p_ptr->exp = 0;
36 if (p_ptr->max_exp < 0) p_ptr->max_exp = 0;
37 if (p_ptr->max_max_exp < 0) p_ptr->max_max_exp = 0;
39 /* Hack -- upper limit */
40 if (p_ptr->exp > PY_MAX_EXP) p_ptr->exp = PY_MAX_EXP;
41 if (p_ptr->max_exp > PY_MAX_EXP) p_ptr->max_exp = PY_MAX_EXP;
42 if (p_ptr->max_max_exp > PY_MAX_EXP) p_ptr->max_max_exp = PY_MAX_EXP;
44 /* Hack -- maintain "max" experience */
45 if (p_ptr->exp > p_ptr->max_exp) p_ptr->max_exp = p_ptr->exp;
47 /* Hack -- maintain "max max" experience */
48 if (p_ptr->max_exp > p_ptr->max_max_exp) p_ptr->max_max_exp = p_ptr->max_exp;
50 /* Redraw experience */
51 p_ptr->redraw |= (PR_EXP);
55 /* Lose levels while possible */
56 while ((p_ptr->lev > 1) &&
57 (p_ptr->exp < ((android ? player_exp_a : player_exp)[p_ptr->lev - 2] * p_ptr->expfact / 100L)))
61 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
62 p_ptr->redraw |= (PR_LEV | PR_TITLE);
63 p_ptr->window |= (PW_PLAYER);
68 /* Gain levels while possible */
69 while ((p_ptr->lev < PY_MAX_LEVEL) &&
70 (p_ptr->exp >= ((android ? player_exp_a : player_exp)[p_ptr->lev-1] * p_ptr->expfact / 100L)))
75 /* Save the highest level */
76 if (p_ptr->lev > p_ptr->max_plv)
78 p_ptr->max_plv = p_ptr->lev;
80 if ((p_ptr->pclass == CLASS_CHAOS_WARRIOR) ||
81 (p_ptr->muta2 & MUT2_CHAOS_GIFT))
85 if (p_ptr->prace == RACE_BEASTMAN)
87 if (one_in_(5)) level_mutation = TRUE;
89 level_inc_stat = TRUE;
91 do_cmd_write_nikki(NIKKI_LEVELUP, p_ptr->lev, NULL);
96 msg_format(_("レベル %d にようこそ。", "Welcome to level %d."), p_ptr->lev);
98 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
99 p_ptr->redraw |= (PR_LEV | PR_TITLE | PR_EXP);
100 p_ptr->window |= (PW_PLAYER | PW_SPELL | PW_INVEN);
110 if(!(p_ptr->max_plv % 10))
120 cnv_stat(p_ptr->stat_max[0], tmp);
121 prt(format(" a) 腕力 (現在値 %s)", tmp), 2, 14);
122 cnv_stat(p_ptr->stat_max[1], tmp);
123 prt(format(" b) 知能 (現在値 %s)", tmp), 3, 14);
124 cnv_stat(p_ptr->stat_max[2], tmp);
125 prt(format(" c) 賢さ (現在値 %s)", tmp), 4, 14);
126 cnv_stat(p_ptr->stat_max[3], tmp);
127 prt(format(" d) 器用 (現在値 %s)", tmp), 5, 14);
128 cnv_stat(p_ptr->stat_max[4], tmp);
129 prt(format(" e) 耐久 (現在値 %s)", tmp), 6, 14);
130 cnv_stat(p_ptr->stat_max[5], tmp);
131 prt(format(" f) 魅力 (現在値 %s)", tmp), 7, 14);
133 prt(" どの能力値を上げますか?", 1, 14);
135 cnv_stat(p_ptr->stat_max[0], tmp);
136 prt(format(" a) Str (cur %s)", tmp), 2, 14);
137 cnv_stat(p_ptr->stat_max[1], tmp);
138 prt(format(" b) Int (cur %s)", tmp), 3, 14);
139 cnv_stat(p_ptr->stat_max[2], tmp);
140 prt(format(" c) Wis (cur %s)", tmp), 4, 14);
141 cnv_stat(p_ptr->stat_max[3], tmp);
142 prt(format(" d) Dex (cur %s)", tmp), 5, 14);
143 cnv_stat(p_ptr->stat_max[4], tmp);
144 prt(format(" e) Con (cur %s)", tmp), 6, 14);
145 cnv_stat(p_ptr->stat_max[5], tmp);
146 prt(format(" f) Chr (cur %s)", tmp), 7, 14);
148 prt(" Which stat do you want to raise?", 1, 14);
153 if ((choice >= 'a') && (choice <= 'f')) break;
155 for(n = 0; n < 6; n++)
156 if (n != choice - 'a')
158 if (get_check(_("よろしいですか?", "Are you sure? "))) break;
160 do_inc_stat(choice - 'a');
163 else if(!(p_ptr->max_plv % 2))
164 do_inc_stat(randint0(6));
169 msg_print(_("あなたは変わった気がする...", "You feel different..."));
170 (void)gain_random_mutation(0);
171 level_mutation = FALSE;
175 * 報酬でレベルが上ると再帰的に check_experience() が
180 gain_level_reward(0);
181 level_reward = FALSE;
184 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
185 p_ptr->redraw |= (PR_LEV | PR_TITLE);
186 p_ptr->window |= (PW_PLAYER | PW_SPELL);
190 /* Load an autopick preference file */
191 if (old_lev != p_ptr->lev) autopick_load_pref(FALSE);
196 * @brief モンスターを倒した際の財宝svalを返す
197 * @param r_idx 倒したモンスターの種族ID
200 * Hack -- Return the "automatic coin type" of a monster race
201 * Used to allocate proper treasure when "Creeping coins" die
202 * Note the use of actual "monster names"
204 static int get_coin_type(MONRACE_IDX r_idx)
206 /* Analyze monsters */
209 case MON_COPPER_COINS: return 2;
210 case MON_SILVER_COINS: return 5;
211 case MON_GOLD_COINS: return 10;
212 case MON_MITHRIL_COINS:
213 case MON_MITHRIL_GOLEM: return 16;
214 case MON_ADAMANT_COINS: return 17;
223 * @brief オブジェクトがクロークかどうかを判定する /
224 * Hack -- determine if a template is Cloak
225 * @param k_idx 判定したいオブジェクトのベースアイテムID
226 * @return オブジェクトがクロークならばTRUEを返す
228 static bool kind_is_cloak(KIND_OBJECT_IDX k_idx)
230 object_kind *k_ptr = &k_info[k_idx];
232 /* Analyze the item type */
233 if (k_ptr->tval == TV_CLOAK)
238 /* Assume not good */
244 * @brief オブジェクトが竿状武器かどうかを判定する /
245 * Hack -- determine if a template is Polearm
246 * @param k_idx 判定したいオブジェクトのベースアイテムID
247 * @return オブジェクトが竿状武器ならばTRUEを返す
249 static bool kind_is_polearm(KIND_OBJECT_IDX k_idx)
251 object_kind *k_ptr = &k_info[k_idx];
253 /* Analyze the item type */
254 if (k_ptr->tval == TV_POLEARM)
259 /* Assume not good */
265 * @brief オブジェクトが剣かどうかを判定する /
266 * Hack -- determine if a template is Sword
267 * @param k_idx 判定したいオブジェクトのベースアイテムID
268 * @return オブジェクトが剣ならばTRUEを返す
270 static bool kind_is_sword(KIND_OBJECT_IDX k_idx)
272 object_kind *k_ptr = &k_info[k_idx];
274 /* Analyze the item type */
275 if ((k_ptr->tval == TV_SWORD) && (k_ptr->sval > 2))
280 /* Assume not good */
286 * @brief オブジェクトが魔法書かどうかを判定する /
287 * Hack -- determine if a template is Book
288 * @param k_idx 判定したいオブジェクトのベースアイテムID
289 * @return オブジェクトが魔法書ならばTRUEを返す
291 static bool kind_is_book(KIND_OBJECT_IDX k_idx)
293 object_kind *k_ptr = &k_info[k_idx];
295 /* Analyze the item type */
296 if ((k_ptr->tval >= TV_LIFE_BOOK) && (k_ptr->tval <= TV_CRUSADE_BOOK))
301 /* Assume not good */
307 * @brief オブジェクトがベースアイテム時点でGOODかどうかを判定する /
308 * Hack -- determine if a template is Good book
309 * @param k_idx 判定したいオブジェクトのベースアイテムID
310 * @return オブジェクトがベースアイテム時点でGOODなアイテムならばTRUEを返す
312 static bool kind_is_good_book(KIND_OBJECT_IDX k_idx)
314 object_kind *k_ptr = &k_info[k_idx];
316 /* Analyze the item type */
317 if ((k_ptr->tval >= TV_LIFE_BOOK) && (k_ptr->tval <= TV_CRUSADE_BOOK) && (k_ptr->tval != TV_ARCANE_BOOK) && (k_ptr->sval > 1))
322 /* Assume not good */
328 * @brief オブジェクトが鎧かどうかを判定する /
329 * Hack -- determine if a template is Armor
330 * @param k_idx 判定したいオブジェクトのベースアイテムID
331 * @return オブジェクトが鎧ならばTRUEを返す
333 static bool kind_is_armor(KIND_OBJECT_IDX k_idx)
335 object_kind *k_ptr = &k_info[k_idx];
337 /* Analyze the item type */
338 if (k_ptr->tval == TV_HARD_ARMOR)
343 /* Assume not good */
349 * @brief オブジェクトが打撃武器かどうかを判定する /
350 * Hack -- determine if a template is hafted weapon
351 * @param k_idx 判定したいオブジェクトのベースアイテムID
352 * @return オブジェクトが打撃武器ならばTRUEを返す
354 static bool kind_is_hafted(KIND_OBJECT_IDX k_idx)
356 object_kind *k_ptr = &k_info[k_idx];
358 /* Analyze the item type */
359 if (k_ptr->tval == TV_HAFTED)
364 /* Assume not good */
369 * @brief クエストを達成状態にする /
370 * @param quest_num 達成状態にしたいクエストのID
373 void complete_quest(QUEST_IDX quest_num)
375 quest_type* const q_ptr = &quest[quest_num];
379 case QUEST_TYPE_RANDOM:
380 if (record_rand_quest) do_cmd_write_nikki(NIKKI_RAND_QUEST_C, quest_num, NULL);
383 if (record_fix_quest) do_cmd_write_nikki(NIKKI_FIX_QUEST_C, quest_num, NULL);
387 q_ptr->status = QUEST_STATUS_COMPLETED;
388 q_ptr->complev = (byte)p_ptr->lev;
390 q_ptr->comptime = playtime;
392 if (!(q_ptr->flags & QUEST_FLAG_SILENT))
394 play_music(TERM_XTRA_MUSIC_BASIC, MUSIC_BASIC_QUEST_CLEAR);
395 msg_print(_("クエストを達成した!", "You just completed your quest!"));
401 * @brief 現在フロアに残っている敵モンスターの数を返す /
402 * @return 現在の敵モンスターの数
404 static MONSTER_NUMBER count_all_hostile_monsters(void)
407 MONSTER_NUMBER number_mon = 0;
409 for (x = 0; x < cur_wid; ++ x)
411 for (y = 0; y < cur_hgt; ++ y)
413 MONSTER_IDX m_idx = cave[y][x].m_idx;
415 if (m_idx > 0 && is_hostile(&m_list[m_idx]))
426 * @brief 特定の敵を倒した際にクエスト達成処理 /
427 * Check for "Quest" completion when a quest monster is killed or charmed.
428 * @param m_ptr 撃破したモンスターの構造体参照ポインタ
431 void check_quest_completion(monster_type *m_ptr)
436 bool create_stairs = FALSE;
442 /* Get the location */
447 quest_num = p_ptr->inside_quest;
449 /* Search for an active quest on this dungeon level */
454 for (i = max_q_idx - 1; i > 0; i--)
456 quest_type* const q_ptr = &quest[i];
458 /* Quest is not active */
459 if (q_ptr->status != QUEST_STATUS_TAKEN)
462 /* Quest is not a dungeon quest */
463 if (q_ptr->flags & QUEST_FLAG_PRESET)
466 /* Quest is not on this level */
467 if ((q_ptr->level != dun_level) &&
468 (q_ptr->type != QUEST_TYPE_KILL_ANY_LEVEL))
471 /* Not a "kill monster" quest */
472 if ((q_ptr->type == QUEST_TYPE_FIND_ARTIFACT) ||
473 (q_ptr->type == QUEST_TYPE_FIND_EXIT))
476 /* Interesting quest */
477 if ((q_ptr->type == QUEST_TYPE_KILL_NUMBER) ||
478 (q_ptr->type == QUEST_TYPE_TOWER) ||
479 (q_ptr->type == QUEST_TYPE_KILL_ALL))
482 /* Interesting quest */
483 if (((q_ptr->type == QUEST_TYPE_KILL_LEVEL) ||
484 (q_ptr->type == QUEST_TYPE_KILL_ANY_LEVEL) ||
485 (q_ptr->type == QUEST_TYPE_RANDOM)) &&
486 (q_ptr->r_idx == m_ptr->r_idx))
493 /* Handle the current quest */
494 if (quest_num && (quest[quest_num].status == QUEST_STATUS_TAKEN))
497 quest_type* const q_ptr = &quest[quest_num];
501 case QUEST_TYPE_KILL_NUMBER:
505 if (q_ptr->cur_num >= q_ptr->num_mon)
507 complete_quest(quest_num);
513 case QUEST_TYPE_KILL_ALL:
515 if (!is_hostile(m_ptr)) break;
517 if (count_all_hostile_monsters() == 1)
519 if (q_ptr->flags & QUEST_FLAG_SILENT)
521 q_ptr->status = QUEST_STATUS_FINISHED;
525 complete_quest(quest_num);
530 case QUEST_TYPE_KILL_LEVEL:
531 case QUEST_TYPE_RANDOM:
533 /* Only count valid monsters */
534 if (q_ptr->r_idx != m_ptr->r_idx)
539 if (q_ptr->cur_num >= q_ptr->max_num)
541 complete_quest(quest_num);
543 if (!(q_ptr->flags & QUEST_FLAG_PRESET))
545 create_stairs = TRUE;
546 p_ptr->inside_quest = 0;
549 /* Finish the two main quests without rewarding */
550 if ((quest_num == QUEST_OBERON) || (quest_num == QUEST_SERPENT))
552 q_ptr->status = QUEST_STATUS_FINISHED;
555 if (q_ptr->type == QUEST_TYPE_RANDOM)
558 q_ptr->status = QUEST_STATUS_FINISHED;
563 case QUEST_TYPE_KILL_ANY_LEVEL:
566 if (q_ptr->cur_num >= q_ptr->max_num)
568 complete_quest(quest_num);
573 case QUEST_TYPE_TOWER:
575 if (!is_hostile(m_ptr)) break;
577 if (count_all_hostile_monsters() == 1)
579 q_ptr->status = QUEST_STATUS_STAGE_COMPLETED;
581 if((quest[QUEST_TOWER1].status == QUEST_STATUS_STAGE_COMPLETED) &&
582 (quest[QUEST_TOWER2].status == QUEST_STATUS_STAGE_COMPLETED) &&
583 (quest[QUEST_TOWER3].status == QUEST_STATUS_STAGE_COMPLETED))
586 complete_quest(QUEST_TOWER1);
594 /* Create a magical staircase */
600 while (cave_perma_bold(y, x) || cave[y][x].o_idx || (cave[y][x].info & CAVE_OBJECT) )
602 /* Pick a location */
603 scatter(&ny, &nx, y, x, 1, 0);
609 /* Explain the staircase */
610 msg_print(_("魔法の階段が現れた...", "A magical staircase appears..."));
612 /* Create stairs down */
613 cave_set_feat(y, x, feat_down_stair);
615 /* Remember to update everything */
616 p_ptr->update |= (PU_FLOW);
626 for (i = 0; i < (dun_level / 15)+1; i++)
631 /* Make a great object */
632 make_object(o_ptr, AM_GOOD | AM_GREAT);
634 /* Drop it in the dungeon */
635 (void)drop_near(o_ptr, -1, y, x);
641 * @brief 特定のアーティファクトを入手した際のクエスト達成処理 /
642 * Check for "Quest" completion when a quest monster is killed or charmed.
643 * @param o_ptr 入手したオブジェクトの構造体参照ポインタ
646 void check_find_art_quest_completion(object_type *o_ptr)
649 /* Check if completed a quest */
650 for (i = 0; i < max_q_idx; i++)
652 if((quest[i].type == QUEST_TYPE_FIND_ARTIFACT) &&
653 (quest[i].status == QUEST_STATUS_TAKEN) &&
654 (quest[i].k_idx == o_ptr->name1))
663 * @brief モンスターを撃破した際の述語メッセージを返す /
664 * Return monster death string
665 * @param r_ptr 撃破されたモンスターの種族情報を持つ構造体の参照ポインタ
666 * @return 撃破されたモンスターの述語
668 cptr extract_note_dies(monster_race *r_ptr)
670 /* Some monsters get "destroyed" */
671 if (!monster_living(r_ptr))
675 for (i = 0; i < 4; i++)
677 if (r_ptr->blow[i].method == RBM_EXPLODE)
679 return _("は爆発して粉々になった。", " explodes into tiny shreds.");
682 return _("を倒した。", " is destroyed.");
685 /* Assume a default death */
686 return _("は死んだ。", " dies.");
691 * @brief モンスターが死亡した時の処理 /
692 * Handle the "death" of a monster.
693 * @param m_idx 死亡したモンスターのID
694 * @param drop_item TRUEならばモンスターのドロップ処理を行う
695 * @return 撃破されたモンスターの述語
698 * Disperse treasures centered at the monster location based on the
699 * various flags contained in the monster flags fields.
700 * Check for "Quest" completion when a quest monster is killed.
701 * Note that only the player can induce "monster_death()" on Uniques.
702 * Thus (for now) all Quest monsters should be Uniques.
703 * Note that monsters can now carry objects, and when a monster dies,
704 * it drops all of its objects, which may disappear in crowded rooms.
707 void monster_death(MONSTER_IDX m_idx, bool drop_item)
716 monster_type *m_ptr = &m_list[m_idx];
717 monster_race *r_ptr = &r_info[m_ptr->r_idx];
719 bool visible = ((m_ptr->ml && !p_ptr->image) || (r_ptr->flags1 & RF1_UNIQUE));
723 bool do_gold = (!(r_ptr->flags1 & RF1_ONLY_ITEM));
724 bool do_item = (!(r_ptr->flags1 & RF1_ONLY_GOLD));
725 bool cloned = (m_ptr->smart & SM_CLONED) ? TRUE : FALSE;
726 int force_coin = get_coin_type(m_ptr->r_idx);
731 bool drop_chosen_item = drop_item && !cloned && !p_ptr->inside_arena
732 && !p_ptr->inside_battle && !is_pet(m_ptr);
734 /* The caster is dead? */
735 if (world_monster && world_monster == m_idx) world_monster = 0;
737 /* Notice changes in view */
738 if (r_ptr->flags7 & (RF7_LITE_MASK | RF7_DARK_MASK))
740 /* Update some things */
741 p_ptr->update |= (PU_MON_LITE);
744 /* Get the location */
748 if (record_named_pet && is_pet(m_ptr) && m_ptr->nickname)
752 monster_desc(m_name, m_ptr, MD_INDEF_VISIBLE);
753 do_cmd_write_nikki(NIKKI_NAMED_PET, 3, m_name);
756 /* Let monsters explode! */
757 for (i = 0; i < 4; i++)
759 if (r_ptr->blow[i].method == RBM_EXPLODE)
761 BIT_FLAGS flg = PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL;
762 EFFECT_ID typ = mbe_info[r_ptr->blow[i].effect].explode_type;
763 DICE_NUMBER d_dice = r_ptr->blow[i].d_dice;
764 DICE_SID d_side = r_ptr->blow[i].d_side;
765 HIT_POINT damage = damroll(d_dice, d_side);
767 project(m_idx, 3, y, x, damage, typ, flg, -1);
772 if (m_ptr->mflag2 & MFLAG2_CHAMELEON)
774 choose_new_monster(m_idx, TRUE, MON_CHAMELEON);
775 r_ptr = &r_info[m_ptr->r_idx];
778 /* Check for quest completion */
779 check_quest_completion(m_ptr);
781 /* Handle the possibility of player vanquishing arena combatant -KMW- */
782 if (p_ptr->inside_arena && !is_pet(m_ptr))
784 p_ptr->exit_bldg = TRUE;
786 if (p_ptr->arena_number > MAX_ARENA_MONS)
788 msg_print(_("素晴らしい!君こそ真の勝利者だ。", "You are a Genuine Champion!"));
792 msg_print(_("勝利!チャンピオンへの道を進んでいる。", "Victorious! You're on your way to becoming Champion."));
795 if (arena_info[p_ptr->arena_number].tval)
799 /* Prepare to make a prize */
800 object_prep(q_ptr, lookup_kind(arena_info[p_ptr->arena_number].tval, arena_info[p_ptr->arena_number].sval));
801 apply_magic(q_ptr, object_level, AM_NO_FIXED_ART);
803 /* Drop it in the dungeon */
804 (void)drop_near(q_ptr, -1, y, x);
807 if (p_ptr->arena_number > MAX_ARENA_MONS) p_ptr->arena_number++;
808 p_ptr->arena_number++;
813 /* Extract monster name */
814 monster_desc(m_name, m_ptr, MD_IGNORE_HALLU | MD_ASSUME_VISIBLE | MD_INDEF_VISIBLE);
816 do_cmd_write_nikki(NIKKI_ARENA, p_ptr->arena_number, m_name);
820 if (m_idx == p_ptr->riding)
822 if (rakuba(-1, FALSE))
824 msg_print(_("地面に落とされた。", "You have fallen from your riding pet."));
828 /* Drop a dead corpse? */
829 if (one_in_(r_ptr->flags1 & RF1_UNIQUE ? 1 : 4) &&
830 (r_ptr->flags9 & (RF9_DROP_CORPSE | RF9_DROP_SKELETON)) &&
831 !(p_ptr->inside_arena || p_ptr->inside_battle || cloned || ((m_ptr->r_idx == today_mon) && is_pet(m_ptr))))
833 /* Assume skeleton */
837 * We cannot drop a skeleton? Note, if we are in this check,
838 * we *know* we can drop at least a corpse or a skeleton
840 if (!(r_ptr->flags9 & RF9_DROP_SKELETON))
842 else if ((r_ptr->flags9 & RF9_DROP_CORPSE) && (r_ptr->flags1 & RF1_UNIQUE))
845 /* Else, a corpse is more likely unless we did a "lot" of damage */
846 else if (r_ptr->flags9 & RF9_DROP_CORPSE)
848 /* Lots of damage in one blow */
849 if ((0 - ((m_ptr->maxhp) / 4)) > m_ptr->hp)
851 if (one_in_(5)) corpse = TRUE;
855 if (!one_in_(5)) corpse = TRUE;
860 /* Prepare to make an object */
861 object_prep(q_ptr, lookup_kind(TV_CORPSE, (corpse ? SV_CORPSE : SV_SKELETON)));
863 apply_magic(q_ptr, object_level, AM_NO_FIXED_ART);
865 q_ptr->pval = m_ptr->r_idx;
867 /* Drop it in the dungeon */
868 (void)drop_near(q_ptr, -1, y, x);
871 /* Drop objects being carried */
872 monster_drop_carried_objects(m_ptr);
874 if (r_ptr->flags1 & RF1_DROP_GOOD) mo_mode |= AM_GOOD;
875 if (r_ptr->flags1 & RF1_DROP_GREAT) mo_mode |= AM_GREAT;
877 switch (m_ptr->r_idx)
879 case MON_PINK_HORROR:
880 /* Pink horrors are replaced with 2 Blue horrors */
881 if (!(p_ptr->inside_arena || p_ptr->inside_battle))
885 for (i = 0; i < 2; i++)
888 bool pet = is_pet(m_ptr);
891 if (pet) mode |= PM_FORCE_PET;
893 if (summon_specific((pet ? -1 : m_idx), wy, wx, 100, SUMMON_BLUE_HORROR, mode))
895 if (player_can_see_bold(wy, wx))
901 msg_print(_("ピンク・ホラーは分裂した!", "The Pink horror divides!"));
905 case MON_BLOODLETTER:
906 /* Bloodletters of Khorne may drop a blade of chaos */
907 if (drop_chosen_item && (randint1(100) < 15))
911 /* Prepare to make a Blade of Chaos */
912 object_prep(q_ptr, lookup_kind(TV_SWORD, SV_BLADE_OF_CHAOS));
914 apply_magic(q_ptr, object_level, AM_NO_FIXED_ART | mo_mode);
916 /* Drop it in the dungeon */
917 (void)drop_near(q_ptr, -1, y, x);
922 if (drop_chosen_item && (dun_level > 9))
927 /* Activate restriction */
928 if ((dun_level > 49) && one_in_(5))
929 get_obj_num_hook = kind_is_good_book;
931 get_obj_num_hook = kind_is_book;
934 make_object(q_ptr, mo_mode);
936 /* Drop it in the dungeon */
937 (void)drop_near(q_ptr, -1, y, x);
943 * Mega^3-hack: killing a 'Warrior of the Dawn' is likely to
944 * spawn another in the fallen one's place!
946 if (!p_ptr->inside_arena && !p_ptr->inside_battle)
950 POSITION wy = y, wx = x;
952 bool pet = is_pet(m_ptr);
956 scatter(&wy, &wx, y, x, 20, 0);
958 while (!(in_bounds(wy, wx) && cave_empty_bold2(wy, wx)) && --attempts);
963 if (pet) mode |= PM_FORCE_PET;
965 if (summon_specific((pet ? -1 : m_idx), wy, wx, 100, SUMMON_DAWN, mode))
967 if (player_can_see_bold(wy, wx))
968 msg_print(_("新たな戦士が現れた!", "A new warrior steps forth!"));
976 /* One more ultra-hack: An Unmaker goes out with a big bang! */
978 BIT_FLAGS flg = PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL;
979 (void)project(m_idx, 6, y, x, 100, GF_CHAOS, flg, -1);
983 case MON_UNICORN_ORD:
986 /* Reward for "lazy" player */
987 if (p_ptr->pseikaku == SEIKAKU_NAMAKE)
989 ARTIFACT_IDX a_idx = 0;
990 artifact_type *a_ptr = NULL;
992 if (!drop_chosen_item) break;
999 a_idx = ART_NAMAKE_HAMMER;
1002 a_idx = ART_NAMAKE_BOW;
1005 a_idx = ART_NAMAKE_ARMOR;
1009 a_ptr = &a_info[a_idx];
1011 while (a_ptr->cur_num);
1013 /* Create the artifact */
1014 if (create_named_art(a_idx, y, x))
1018 /* Hack -- Memorize location of artifact in saved floors */
1019 if (character_dungeon) a_ptr->floor_id = p_ptr->floor_id;
1021 else if (!preserve_mode) a_ptr->cur_num = 1;
1026 if (!drop_chosen_item) break;
1029 /* Mega-Hack -- Prepare to make "Grond" */
1030 object_prep(q_ptr, lookup_kind(TV_HAFTED, SV_GROND));
1032 /* Mega-Hack -- Mark this item as "Grond" */
1033 q_ptr->name1 = ART_GROND;
1035 /* Mega-Hack -- Actually create "Grond" */
1036 apply_magic(q_ptr, -1, AM_GOOD | AM_GREAT);
1038 /* Drop it in the dungeon */
1039 (void)drop_near(q_ptr, -1, y, x);
1042 /* Mega-Hack -- Prepare to make "Chaos" */
1043 object_prep(q_ptr, lookup_kind(TV_CROWN, SV_CHAOS));
1045 /* Mega-Hack -- Mark this item as "Chaos" */
1046 q_ptr->name1 = ART_CHAOS;
1048 /* Mega-Hack -- Actually create "Chaos" */
1049 apply_magic(q_ptr, -1, AM_GOOD | AM_GREAT);
1051 /* Drop it in the dungeon */
1052 (void)drop_near(q_ptr, -1, y, x);
1055 case MON_B_DEATH_SWORD:
1056 if (drop_chosen_item)
1060 /* Prepare to make a broken sword */
1061 object_prep(q_ptr, lookup_kind(TV_SWORD, randint1(2)));
1063 /* Drop it in the dungeon */
1064 (void)drop_near(q_ptr, -1, y, x);
1070 if (drop_chosen_item && ((m_ptr->r_idx == MON_A_GOLD) ||
1071 ((m_ptr->r_idx == MON_A_SILVER) && (r_ptr->r_akills % 5 == 0))))
1075 /* Prepare to make a Can of Toys */
1076 object_prep(q_ptr, lookup_kind(TV_CHEST, SV_CHEST_KANDUME));
1078 apply_magic(q_ptr, object_level, AM_NO_FIXED_ART);
1080 /* Drop it in the dungeon */
1081 (void)drop_near(q_ptr, -1, y, x);
1087 BIT_FLAGS flg = PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL;
1088 (void)project(m_idx, 3, y, x, damroll(20, 10), GF_FIRE, flg, -1);
1093 if (!drop_chosen_item) break;
1095 switch (r_ptr->d_char)
1103 /* Activate restriction */
1104 get_obj_num_hook = kind_is_cloak;
1107 make_object(q_ptr, mo_mode);
1109 /* Drop it in the dungeon */
1110 (void)drop_near(q_ptr, -1, y, x);
1120 /* Activate restriction */
1121 get_obj_num_hook = kind_is_polearm;
1123 /* Make a poleweapon */
1124 make_object(q_ptr, mo_mode);
1126 /* Drop it in the dungeon */
1127 (void)drop_near(q_ptr, -1, y, x);
1137 /* Activate restriction */
1138 get_obj_num_hook = kind_is_armor;
1140 /* Make a hard armor */
1141 make_object(q_ptr, mo_mode);
1143 /* Drop it in the dungeon */
1144 (void)drop_near(q_ptr, -1, y, x);
1154 /* Activate restriction */
1155 get_obj_num_hook = kind_is_hafted;
1157 /* Make a hafted weapon */
1158 make_object(q_ptr, mo_mode);
1160 /* Drop it in the dungeon */
1161 (void)drop_near(q_ptr, -1, y, x);
1166 if (m_ptr->r_idx != MON_STORMBRINGER)
1171 /* Activate restriction */
1172 get_obj_num_hook = kind_is_sword;
1175 make_object(q_ptr, mo_mode);
1177 /* Drop it in the dungeon */
1178 (void)drop_near(q_ptr, -1, y, x);
1185 /* Mega-Hack -- drop fixed items */
1186 if (drop_chosen_item)
1188 ARTIFACT_IDX a_idx = 0;
1191 for(i = 0; i < 4; i++)
1193 if(!r_ptr->artifact_id[i]) break;
1194 a_idx = r_ptr->artifact_id[i];
1195 chance = r_ptr->artifact_percent[i];
1198 if ((a_idx > 0) && ((randint0(100) < chance) || p_ptr->wizard))
1200 artifact_type *a_ptr = &a_info[a_idx];
1202 if (!a_ptr->cur_num)
1204 /* Create the artifact */
1205 if (create_named_art(a_idx, y, x))
1209 /* Hack -- Memorize location of artifact in saved floors */
1210 if (character_dungeon) a_ptr->floor_id = p_ptr->floor_id;
1212 else if (!preserve_mode) a_ptr->cur_num = 1;
1216 if ((r_ptr->flags7 & RF7_GUARDIAN) && (d_info[dungeon_type].final_guardian == m_ptr->r_idx))
1218 KIND_OBJECT_IDX k_idx = d_info[dungeon_type].final_object ? d_info[dungeon_type].final_object
1219 : lookup_kind(TV_SCROLL, SV_SCROLL_ACQUIREMENT);
1221 if (d_info[dungeon_type].final_artifact)
1223 a_idx = d_info[dungeon_type].final_artifact;
1224 artifact_type *a_ptr = &a_info[a_idx];
1226 if (!a_ptr->cur_num)
1228 /* Create the artifact */
1229 if (create_named_art(a_idx, y, x))
1233 /* Hack -- Memorize location of artifact in saved floors */
1234 if (character_dungeon) a_ptr->floor_id = p_ptr->floor_id;
1236 else if (!preserve_mode) a_ptr->cur_num = 1;
1238 /* Prevent rewarding both artifact and "default" object */
1239 if (!d_info[dungeon_type].final_object) k_idx = 0;
1247 /* Prepare to make a reward */
1248 object_prep(q_ptr, k_idx);
1250 apply_magic(q_ptr, object_level, AM_NO_FIXED_ART | AM_GOOD);
1252 /* Drop it in the dungeon */
1253 (void)drop_near(q_ptr, -1, y, x);
1255 msg_format(_("あなたは%sを制覇した!", "You have conquered %s!"),d_name+d_info[dungeon_type].name);
1259 /* Determine how much we can drop */
1260 if ((r_ptr->flags1 & RF1_DROP_60) && (randint0(100) < 60)) number++;
1261 if ((r_ptr->flags1 & RF1_DROP_90) && (randint0(100) < 90)) number++;
1262 if (r_ptr->flags1 & RF1_DROP_1D2) number += damroll(1, 2);
1263 if (r_ptr->flags1 & RF1_DROP_2D2) number += damroll(2, 2);
1264 if (r_ptr->flags1 & RF1_DROP_3D2) number += damroll(3, 2);
1265 if (r_ptr->flags1 & RF1_DROP_4D2) number += damroll(4, 2);
1267 if (cloned && !(r_ptr->flags1 & RF1_UNIQUE))
1268 number = 0; /* Clones drop no stuff unless Cloning Pits */
1270 if (is_pet(m_ptr) || p_ptr->inside_battle || p_ptr->inside_arena)
1271 number = 0; /* Pets drop no stuff */
1272 if (!drop_item && (r_ptr->d_char != '$')) number = 0;
1274 if((r_ptr->flags2 & (RF2_MULTIPLY)) && (r_ptr->r_akills > 1024))
1275 number = 0; /* Limit of Multiply monster drop */
1277 /* Hack -- handle creeping coins */
1278 coin_type = force_coin;
1280 /* Average dungeon and monster levels */
1281 object_level = (dun_level + r_ptr->level) / 2;
1283 /* Drop some objects */
1284 for (j = 0; j < number; j++)
1290 if (do_gold && (!do_item || (randint0(100) < 50)))
1292 /* Make some gold */
1293 if (!make_gold(q_ptr)) continue;
1301 /* Make an object */
1302 if (!make_object(q_ptr, mo_mode)) continue;
1307 /* Drop it in the dungeon */
1308 (void)drop_near(q_ptr, -1, y, x);
1311 /* Reset the object level */
1312 object_level = base_level;
1314 /* Reset "coin" type */
1318 /* Take note of any dropped treasure */
1319 if (visible && (dump_item || dump_gold))
1321 /* Take notes on treasure */
1322 lore_treasure(m_idx, dump_item, dump_gold);
1325 /* Only process "Quest Monsters" */
1326 if (!(r_ptr->flags1 & RF1_QUESTOR)) return;
1327 if (p_ptr->inside_battle) return;
1330 if ((m_ptr->r_idx == MON_SERPENT) && !cloned)
1333 p_ptr->total_winner = TRUE;
1335 /* Redraw the "title" */
1336 p_ptr->redraw |= (PR_TITLE);
1338 play_music(TERM_XTRA_MUSIC_BASIC, MUSIC_BASIC_FINAL_QUEST_CLEAR);
1340 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, _("見事に変愚蛮怒の勝利者となった!", "become *WINNER* of Hengband finely!"));
1342 if ((p_ptr->pclass == CLASS_CHAOS_WARRIOR) || (p_ptr->muta2 & MUT2_CHAOS_GIFT))
1344 msg_format(_("%sからの声が響いた。", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
1345 msg_print(_("『よくやった、定命の者よ!』", "'Thou art donst well, mortal!'"));
1348 /* Congratulations */
1349 msg_print(_("*** おめでとう ***", "*** CONGRATULATIONS ***"));
1350 msg_print(_("あなたはゲームをコンプリートしました。", "You have won the game!"));
1351 msg_print(_("準備が整ったら引退(自殺コマンド)しても結構です。", "You may retire (commit suicide) when you are ready."));
1356 * @brief モンスターに与えたダメージの修正処理 /
1357 * Modify the physical damage done to the monster.
1358 * @param m_ptr ダメージを受けるモンスターの構造体参照ポインタ
1359 * @param dam ダメージ基本値
1360 * @param is_psy_spear 攻撃手段が光の剣ならばTRUE
1361 * @return 修正を行った結果のダメージ量
1364 * (for example when it's invulnerable or shielded)
1365 * ToDo: Accept a damage-type to calculate the modified damage from
1366 * things like fire, frost, lightning, poison, ... attacks.
1367 * "type" is not yet used and should be 0.
1370 HIT_POINT mon_damage_mod(monster_type *m_ptr, HIT_POINT dam, bool is_psy_spear)
1372 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1374 if ((r_ptr->flagsr & RFR_RES_ALL) && dam > 0)
1377 if ((dam == 0) && one_in_(3)) dam = 1;
1380 if (MON_INVULNER(m_ptr))
1384 if (!p_ptr->blind && is_seen(m_ptr))
1386 msg_print(_("バリアを切り裂いた!", "The barrier is penetrated!"));
1389 else if (!one_in_(PENETRATE_INVULNERABILITY))
1399 * @brief モンスターに与えたダメージを元に経験値を加算する /
1400 * Calculate experience point to be get
1401 * @param dam 与えたダメージ量
1402 * @param m_ptr ダメージを与えたモンスターの構造体参照ポインタ
1406 * Even the 64 bit operation is not big enough to avoid overflaw
1407 * unless we carefully choose orders of multiplication and division.
1408 * Get the coefficient first, and multiply (potentially huge) base
1409 * experience point of a monster later.
1412 static void get_exp_from_mon(HIT_POINT dam, monster_type *m_ptr)
1414 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1421 if (!m_ptr->r_idx) return;
1422 if (is_pet(m_ptr) || p_ptr->inside_battle) return;
1425 * - Ratio of monster's level to player's level effects
1426 * - Varying speed effects
1427 * - Get a fraction in proportion of damage point
1429 new_exp = r_ptr->level * SPEED_TO_ENERGY(m_ptr->mspeed) * dam;
1432 div_l = (p_ptr->max_plv+2) * SPEED_TO_ENERGY(r_ptr->speed);
1434 /* Use (average maxhp * 2) as a denominator */
1435 if (!(r_ptr->flags1 & RF1_FORCE_MAXHP))
1436 s64b_mul(&div_h, &div_l, 0, r_ptr->hdice * (ironman_nightmare ? 2 : 1) * (r_ptr->hside + 1));
1438 s64b_mul(&div_h, &div_l, 0, r_ptr->hdice * (ironman_nightmare ? 2 : 1) * r_ptr->hside * 2);
1440 /* Special penalty in the wilderness */
1441 if (!dun_level && (!(r_ptr->flags8 & RF8_WILD_ONLY) || !(r_ptr->flags1 & RF1_UNIQUE)))
1442 s64b_mul(&div_h, &div_l, 0, 5);
1444 /* Do division first to prevent overflaw */
1445 s64b_div(&new_exp, &new_exp_frac, div_h, div_l);
1447 /* Special penalty for mutiply-monster */
1448 if ((r_ptr->flags2 & RF2_MULTIPLY) || (m_ptr->r_idx == MON_DAWN))
1450 int monnum_penarty = r_ptr->r_akills / 400;
1451 if (monnum_penarty > 8) monnum_penarty = 8;
1453 while (monnum_penarty--)
1456 s64b_RSHIFT(new_exp, new_exp_frac, 2);
1460 /* Special penalty for rest_and_shoot exp scum */
1461 if ((m_ptr->dealt_damage > m_ptr->max_maxhp) && (m_ptr->hp >= 0))
1463 int over_damage = m_ptr->dealt_damage / m_ptr->max_maxhp;
1464 if (over_damage > 32) over_damage = 32;
1466 while (over_damage--)
1469 s64b_mul(&new_exp, &new_exp_frac, 0, 9);
1470 s64b_div(&new_exp, &new_exp_frac, 0, 10);
1474 /* Finally multiply base experience point of the monster */
1475 s64b_mul(&new_exp, &new_exp_frac, 0, r_ptr->mexp);
1477 /* Gain experience */
1478 gain_exp_64(new_exp, new_exp_frac);
1483 * @brief モンスターのHPをダメージに応じて減算する /
1484 * Decreases monsters hit points, handling monster death.
1485 * @param dam 与えたダメージ量
1486 * @param m_idx ダメージを与えたモンスターのID
1487 * @param fear ダメージによってモンスターが恐慌状態に陥ったならばTRUEを返す
1488 * @param note モンスターが倒された際の特別なメッセージ述語
1492 * We return TRUE if the monster has been killed (and deleted).
1493 * We announce monster death (using an optional "death message"
1494 * if given, and a otherwise a generic killed/destroyed message).
1495 * Only "physical attacks" can induce the "You have slain" message.
1496 * Missile and Spell attacks will induce the "dies" message, or
1497 * various "specialized" messages. Note that "You have destroyed"
1498 * and "is destroyed" are synonyms for "You have slain" and "dies".
1499 * Hack -- unseen monsters yield "You have killed it." message.
1500 * Added fear (DGK) and check whether to print fear messages -CWS
1501 * Made name, sex, and capitalization generic -BEN-
1502 * As always, the "ghost" processing is a total hack.
1503 * Hack -- we "delay" fear messages by passing around a "fear" flag.
1504 * Consider decreasing monster experience over time, say,
1505 * by using "(m_exp * m_lev * (m_lev)) / (p_lev * (m_lev + n_killed))"
1506 * instead of simply "(m_exp * m_lev) / (p_lev)", to make the first
1507 * monster worth more than subsequent monsters. This would also need
1508 * to induce changes in the monster recall code.
1511 bool mon_take_hit(MONSTER_IDX m_idx, HIT_POINT dam, bool *fear, cptr note)
1513 monster_type *m_ptr = &m_list[m_idx];
1514 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1515 monster_type exp_mon;
1517 /* Innocent until proven otherwise */
1518 bool innocent = TRUE, thief = FALSE;
1522 (void)COPY(&exp_mon, m_ptr, monster_type);
1524 expdam = (m_ptr->hp > dam) ? dam : m_ptr->hp;
1526 get_exp_from_mon(expdam, &exp_mon);
1528 /* Genocided by chaos patron */
1529 if (!m_ptr->r_idx) m_idx = 0;
1531 /* Redraw (later) if needed */
1532 if (p_ptr->health_who == m_idx) p_ptr->redraw |= (PR_HEALTH);
1533 if (p_ptr->riding == m_idx) p_ptr->redraw |= (PR_UHEALTH);
1535 (void)set_monster_csleep(m_idx, 0);
1537 /* Hack - Cancel any special player stealth magics. -LM- */
1538 if (p_ptr->special_defense & NINJA_S_STEALTH)
1540 set_superstealth(FALSE);
1543 /* Genocided by chaos patron */
1544 if (!m_idx) return TRUE;
1547 m_ptr->dealt_damage += dam;
1549 if(m_ptr->dealt_damage > m_ptr->max_maxhp * 100) m_ptr->dealt_damage = m_ptr->max_maxhp * 100;
1553 msg_format( _("合計%d/%dのダメージを与えた。","You do %d (out of %d) damage."), m_ptr->dealt_damage, m_ptr->maxhp);
1556 /* It is dead now */
1561 if (r_info[m_ptr->r_idx].flags7 & RF7_TANUKI)
1563 /* You might have unmasked Tanuki first time */
1564 r_ptr = &r_info[m_ptr->r_idx];
1565 m_ptr->ap_r_idx = m_ptr->r_idx;
1566 if (r_ptr->r_sights < MAX_SHORT) r_ptr->r_sights++;
1569 if (m_ptr->mflag2 & MFLAG2_CHAMELEON)
1571 /* You might have unmasked Chameleon first time */
1572 r_ptr = real_r_ptr(m_ptr);
1573 if (r_ptr->r_sights < MAX_SHORT) r_ptr->r_sights++;
1576 if (!(m_ptr->smart & SM_CLONED))
1578 /* When the player kills a Unique, it stays dead */
1579 if (r_ptr->flags1 & RF1_UNIQUE)
1583 /* Mega-Hack -- Banor & Lupart */
1584 if ((m_ptr->r_idx == MON_BANOR) || (m_ptr->r_idx == MON_LUPART))
1586 r_info[MON_BANORLUPART].max_num = 0;
1587 r_info[MON_BANORLUPART].r_pkills++;
1588 r_info[MON_BANORLUPART].r_akills++;
1589 if (r_info[MON_BANORLUPART].r_tkills < MAX_SHORT) r_info[MON_BANORLUPART].r_tkills++;
1591 else if (m_ptr->r_idx == MON_BANORLUPART)
1593 r_info[MON_BANOR].max_num = 0;
1594 r_info[MON_BANOR].r_pkills++;
1595 r_info[MON_BANOR].r_akills++;
1596 if (r_info[MON_BANOR].r_tkills < MAX_SHORT) r_info[MON_BANOR].r_tkills++;
1597 r_info[MON_LUPART].max_num = 0;
1598 r_info[MON_LUPART].r_pkills++;
1599 r_info[MON_LUPART].r_akills++;
1600 if (r_info[MON_LUPART].r_tkills < MAX_SHORT) r_info[MON_LUPART].r_tkills++;
1604 /* When the player kills a Nazgul, it stays dead */
1605 else if (r_ptr->flags7 & RF7_NAZGUL) r_ptr->max_num--;
1608 /* Count all monsters killed */
1609 if (r_ptr->r_akills < MAX_SHORT) r_ptr->r_akills++;
1611 /* Recall even invisible uniques or winners */
1612 if ((m_ptr->ml && !p_ptr->image) || (r_ptr->flags1 & RF1_UNIQUE))
1614 /* Count kills this life */
1615 if ((m_ptr->mflag2 & MFLAG2_KAGE) && (r_info[MON_KAGE].r_pkills < MAX_SHORT)) r_info[MON_KAGE].r_pkills++;
1616 else if (r_ptr->r_pkills < MAX_SHORT) r_ptr->r_pkills++;
1618 /* Count kills in all lives */
1619 if ((m_ptr->mflag2 & MFLAG2_KAGE) && (r_info[MON_KAGE].r_tkills < MAX_SHORT)) r_info[MON_KAGE].r_tkills++;
1620 else if (r_ptr->r_tkills < MAX_SHORT) r_ptr->r_tkills++;
1622 /* Hack -- Auto-recall */
1623 monster_race_track(m_ptr->ap_r_idx);
1626 /* Extract monster name */
1627 monster_desc(m_name, m_ptr, MD_TRUE_NAME);
1629 /* Don't kill Amberites */
1630 if ((r_ptr->flags3 & RF3_AMBERITE) && one_in_(2))
1632 int curses = 1 + randint1(3);
1633 bool stop_ty = FALSE;
1636 msg_format(_("%^sは恐ろしい血の呪いをあなたにかけた!", "%^s puts a terrible blood curse on you!"), m_name);
1637 curse_equipment(100, 50);
1641 stop_ty = activate_ty_curse(stop_ty, &count);
1646 if (r_ptr->flags2 & RF2_CAN_SPEAK)
1648 char line_got[1024];
1650 /* Dump a message */
1651 if (!get_rnd_line(_("mondeath_j.txt", "mondeath.txt"), m_ptr->r_idx, line_got))
1653 msg_format("%^s %s", m_name, line_got);
1657 if (m_ptr->r_idx == MON_SERPENT)
1659 screen_dump = make_screen_dump();
1664 if (!(d_info[dungeon_type].flags1 & DF1_BEGINNER))
1666 if (!dun_level && !ambush_flag && !p_ptr->inside_arena)
1668 chg_virtue(V_VALOUR, -1);
1670 else if (r_ptr->level > dun_level)
1672 if (randint1(10) <= (r_ptr->level - dun_level))
1673 chg_virtue(V_VALOUR, 1);
1675 if (r_ptr->level > 60)
1677 chg_virtue(V_VALOUR, 1);
1679 if (r_ptr->level >= 2 * (p_ptr->lev+1))
1680 chg_virtue(V_VALOUR, 2);
1683 if (r_ptr->flags1 & RF1_UNIQUE)
1685 if (r_ptr->flags3 & (RF3_EVIL | RF3_GOOD)) chg_virtue(V_HARMONY, 2);
1687 if (r_ptr->flags3 & RF3_GOOD)
1689 chg_virtue(V_UNLIFE, 2);
1690 chg_virtue(V_VITALITY, -2);
1693 if (one_in_(3)) chg_virtue(V_INDIVIDUALISM, -1);
1696 if (m_ptr->r_idx == MON_BEGGAR || m_ptr->r_idx == MON_LEPER)
1698 chg_virtue(V_COMPASSION, -1);
1701 if ((r_ptr->flags3 & RF3_GOOD) && ((r_ptr->level) / 10 + (3 * dun_level) >= randint1(100)))
1702 chg_virtue(V_UNLIFE, 1);
1704 if (r_ptr->d_char == 'A')
1706 if (r_ptr->flags1 & RF1_UNIQUE)
1707 chg_virtue(V_FAITH, -2);
1708 else if ((r_ptr->level) / 10 + (3 * dun_level) >= randint1(100))
1710 if (r_ptr->flags3 & RF3_GOOD) chg_virtue(V_FAITH, -1);
1711 else chg_virtue(V_FAITH, 1);
1714 else if (r_ptr->flags3 & RF3_DEMON)
1716 if (r_ptr->flags1 & RF1_UNIQUE)
1717 chg_virtue(V_FAITH, 2);
1718 else if ((r_ptr->level) / 10 + (3 * dun_level) >= randint1(100))
1719 chg_virtue(V_FAITH, 1);
1722 if ((r_ptr->flags3 & RF3_UNDEAD) && (r_ptr->flags1 & RF1_UNIQUE))
1723 chg_virtue(V_VITALITY, 2);
1725 if (r_ptr->r_deaths)
1727 if (r_ptr->flags1 & RF1_UNIQUE)
1729 chg_virtue(V_HONOUR, 10);
1731 else if ((r_ptr->level) / 10 + (2 * dun_level) >= randint1(100))
1733 chg_virtue(V_HONOUR, 1);
1736 if ((r_ptr->flags2 & RF2_MULTIPLY) && (r_ptr->r_akills > 1000) && one_in_(10))
1738 chg_virtue(V_VALOUR, -1);
1741 for (i = 0; i < 4; i++)
1743 if (r_ptr->blow[i].d_dice != 0) innocent = FALSE; /* Murderer! */
1745 if ((r_ptr->blow[i].effect == RBE_EAT_ITEM)
1746 || (r_ptr->blow[i].effect == RBE_EAT_GOLD))
1748 thief = TRUE; /* Thief! */
1751 /* The new law says it is illegal to live in the dungeon */
1752 if (r_ptr->level != 0) innocent = FALSE;
1756 if (r_ptr->flags1 & RF1_UNIQUE)
1757 chg_virtue(V_JUSTICE, 3);
1758 else if (1+((r_ptr->level) / 10 + (2 * dun_level)) >= randint1(100))
1759 chg_virtue(V_JUSTICE, 1);
1763 chg_virtue (V_JUSTICE, -1);
1766 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)))
1768 if (one_in_(4)) chg_virtue(V_NATURE, -1);
1771 if ((r_ptr->flags1 & RF1_UNIQUE) && record_destroy_uniq)
1774 sprintf(note_buf, "%s%s", r_name + r_ptr->name, (m_ptr->smart & SM_CLONED) ? _("(クローン)", "(Clone)") : "");
1775 do_cmd_write_nikki(NIKKI_UNIQUE, 0, note_buf);
1781 /* Death by Missile/Spell attack */
1784 msg_format("%^s%s", m_name, note);
1787 /* Death by physical attack -- invisible monster */
1788 else if (!m_ptr->ml)
1791 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
1792 msg_format("せっかくだから%sを殺した。", m_name);
1794 msg_format("%sを殺した。", m_name);
1796 msg_format("You have killed %s.", m_name);
1801 /* Death by Physical attack -- non-living monster */
1802 else if (!monster_living(r_ptr))
1804 bool explode = FALSE;
1806 for (i = 0; i < 4; i++)
1808 if (r_ptr->blow[i].method == RBM_EXPLODE) explode = TRUE;
1811 /* Special note at death */
1813 msg_format(_("%sは爆発して粉々になった。", "%^s explodes into tiny shreds."), m_name);
1817 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
1818 msg_format("せっかくだから%sを倒した。", m_name);
1820 msg_format("%sを倒した。", m_name);
1822 msg_format("You have destroyed %s.", m_name);
1827 /* Death by Physical attack -- living monster */
1831 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
1832 msg_format("せっかくだから%sを葬り去った。", m_name);
1834 msg_format("%sを葬り去った。", m_name);
1836 msg_format("You have slain %s.", m_name);
1840 if ((r_ptr->flags1 & RF1_UNIQUE) && !(m_ptr->smart & SM_CLONED) && !vanilla_town)
1842 for (i = 0; i < MAX_KUBI; i++)
1844 if ((kubi_r_idx[i] == m_ptr->r_idx) && !(m_ptr->mflag2 & MFLAG2_CHAMELEON))
1846 msg_format(_("%sの首には賞金がかかっている。", "There is a price on %s's head."), m_name);
1852 /* Generate treasure */
1853 monster_death(m_idx, TRUE);
1855 /* Mega hack : replace IKETA to BIKETAL */
1856 if ((m_ptr->r_idx == MON_IKETA) && !(p_ptr->inside_arena || p_ptr->inside_battle))
1858 POSITION dummy_y = m_ptr->fy;
1859 POSITION dummy_x = m_ptr->fx;
1860 BIT_FLAGS mode = 0L;
1861 if (is_pet(m_ptr)) mode |= PM_FORCE_PET;
1862 delete_monster_idx(m_idx);
1863 if (summon_named_creature(0, dummy_y, dummy_x, MON_BIKETAL, mode))
1865 msg_print(_("「ハァッハッハッハ!!私がバイケタルだ!!」", "Uwa-hahaha! *I* am Biketal!"));
1870 delete_monster_idx(m_idx);
1873 get_exp_from_mon((long)exp_mon.max_maxhp*2, &exp_mon);
1878 /* Monster is dead */
1885 /* Mega-Hack -- Pain cancels fear */
1886 if (MON_MONFEAR(m_ptr) && (dam > 0))
1889 if (set_monster_monfear(m_idx, MON_MONFEAR(m_ptr) - randint1(dam)))
1896 /* Sometimes a monster gets scared by damage */
1897 if (!MON_MONFEAR(m_ptr) && !(r_ptr->flags3 & (RF3_NO_FEAR)))
1899 /* Percentage of fully healthy */
1900 int percentage = (100L * m_ptr->hp) / m_ptr->maxhp;
1903 * Run (sometimes) if at 10% or less of max hit points,
1904 * or (usually) when hit for half its current hit points
1906 if ((randint1(10) >= percentage) || ((dam >= m_ptr->hp) && (randint0(100) < 80)))
1908 /* Hack -- note fear */
1911 /* Hack -- Add some timed fear */
1912 (void)set_monster_monfear(m_idx, (randint1(10) +
1913 (((dam >= m_ptr->hp) && (percentage > 7)) ?
1914 20 : ((11 - percentage) * 5))));
1926 * @brief 現在のコンソール表示の縦横を返す。 /
1927 * Get term size and calculate screen size
1928 * @param wid_p コンソールの表示幅文字数を返す
1929 * @param hgt_p コンソールの表示行数を返す
1932 void get_screen_size(TERM_LEN *wid_p, TERM_LEN *hgt_p)
1934 Term_get_size(wid_p, hgt_p);
1935 *hgt_p -= ROW_MAP + 2;
1936 *wid_p -= COL_MAP + 2;
1937 if (use_bigtile) *wid_p /= 2;
1942 * @brief コンソール上におけるマップ表示の左上位置を返す /
1943 * Calculates current boundaries Called below and from "do_cmd_locate()".
1946 void panel_bounds_center(void)
1950 get_screen_size(&wid, &hgt);
1952 panel_row_max = panel_row_min + hgt - 1;
1953 panel_row_prt = panel_row_min - 1;
1954 panel_col_max = panel_col_min + wid - 1;
1955 panel_col_prt = panel_col_min - 13;
1960 * @brief コンソールのリサイズに合わせてマップを再描画する /
1961 * Map resizing whenever the main term changes size
1964 void resize_map(void)
1966 /* Only if the dungeon exists */
1967 if (!character_dungeon) return;
1969 /* Mega-Hack -- no panel yet */
1973 /* Reset the panels */
1974 panel_row_min = cur_hgt;
1975 panel_col_min = cur_wid;
1979 p_ptr->update |= (PU_TORCH | PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
1981 /* Forget lite/view */
1982 p_ptr->update |= (PU_UN_VIEW | PU_UN_LITE);
1984 /* Update lite/view */
1985 p_ptr->update |= (PU_VIEW | PU_LITE | PU_MON_LITE);
1987 /* Update monsters */
1988 p_ptr->update |= (PU_MONSTERS);
1990 /* Redraw everything */
1991 p_ptr->redraw |= (PR_WIPE | PR_BASIC | PR_EXTRA | PR_MAP | PR_EQUIPPY);
1993 /* Hack -- update */
1999 * Place the cursor on the player
2001 if (can_save) move_cursor_relative(p_ptr->y, p_ptr->x);
2008 * @brief コンソールを再描画する /
2009 * Redraw a term when it is resized
2012 void redraw_window(void)
2014 /* Only if the dungeon exists */
2015 if (!character_dungeon) return;
2017 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_SPELL | PW_PLAYER);
2018 p_ptr->window |= (PW_MESSAGE | PW_OVERHEAD | PW_DUNGEON | PW_MONSTER | PW_OBJECT);
2020 /* Hack -- update */
2027 * @brief フォーカスを当てるべきマップ描画の基準座標を指定する(サブルーチン)
2028 * @param dy 変更先のフロアY座標
2029 * @param dx 変更先のフロアX座標
2030 * Handle a request to change the current panel
2031 * Return TRUE if the panel was changed.
2032 * Also used in do_cmd_locate
2033 * @return 実際に再描画が必要だった場合TRUEを返す
2035 bool change_panel(POSITION dy, POSITION dx)
2040 get_screen_size(&wid, &hgt);
2042 /* Apply the motion */
2043 y = panel_row_min + dy * hgt / 2;
2044 x = panel_col_min + dx * wid / 2;
2046 /* Verify the row */
2047 if (y > cur_hgt - hgt) y = cur_hgt - hgt;
2050 /* Verify the col */
2051 if (x > cur_wid - wid) x = cur_wid - wid;
2054 /* Handle "changes" */
2055 if ((y != panel_row_min) || (x != panel_col_min))
2057 /* Save the new panel info */
2061 /* Recalculate the boundaries */
2062 panel_bounds_center();
2064 p_ptr->update |= (PU_MONSTERS);
2066 p_ptr->redraw |= (PR_MAP);
2078 * @brief フォーカスを当てるべきマップ描画の基準座標を指定する
2079 * @param y 変更先のフロアY座標
2080 * @param x 変更先のフロアX座標
2082 * Handle a request to change the current panel
2083 * Return TRUE if the panel was changed.
2084 * Also used in do_cmd_locate
2085 * @return 実際に再描画が必要だった場合TRUEを返す
2087 static bool change_panel_xy(POSITION y, POSITION x)
2089 POSITION dy = 0, dx = 0;
2092 get_screen_size(&wid, &hgt);
2094 if (y < panel_row_min) dy = -1;
2095 if (y > panel_row_max) dy = 1;
2096 if (x < panel_col_min) dx = -1;
2097 if (x > panel_col_max) dx = 1;
2099 if (!dy && !dx) return (FALSE);
2101 return change_panel(dy, dx);
2106 * @brief マップ描画のフォーカスを当てるべき座標を更新する
2108 * Given an row (y) and col (x), this routine detects when a move
2109 * off the screen has occurred and figures new borders. -RAK-
2110 * "Update" forces a "full update" to take place.
2111 * The map is reprinted if necessary, and "TRUE" is returned.
2112 * @return 実際に再描画が必要だった場合TRUEを返す
2114 void verify_panel(void)
2116 POSITION y = p_ptr->y;
2117 POSITION x = p_ptr->x;
2125 get_screen_size(&wid, &hgt);
2127 max_prow_min = cur_hgt - hgt;
2128 max_pcol_min = cur_wid - wid;
2130 /* Bounds checking */
2131 if (max_prow_min < 0) max_prow_min = 0;
2132 if (max_pcol_min < 0) max_pcol_min = 0;
2134 /* Center on player */
2135 if (center_player && (center_running || !running))
2137 /* Center vertically */
2138 prow_min = y - hgt / 2;
2139 if (prow_min < 0) prow_min = 0;
2140 else if (prow_min > max_prow_min) prow_min = max_prow_min;
2142 /* Center horizontally */
2143 pcol_min = x - wid / 2;
2144 if (pcol_min < 0) pcol_min = 0;
2145 else if (pcol_min > max_pcol_min) pcol_min = max_pcol_min;
2149 prow_min = panel_row_min;
2150 pcol_min = panel_col_min;
2152 /* Scroll screen when 2 grids from top/bottom edge */
2153 if (y > panel_row_max - 2)
2155 while (y > prow_min + hgt-1 - 2)
2157 prow_min += (hgt / 2);
2161 if (y < panel_row_min + 2)
2163 while (y < prow_min + 2)
2165 prow_min -= (hgt / 2);
2169 if (prow_min > max_prow_min) prow_min = max_prow_min;
2170 if (prow_min < 0) prow_min = 0;
2172 /* Scroll screen when 4 grids from left/right edge */
2173 if (x > panel_col_max - 4)
2175 while (x > pcol_min + wid-1 - 4)
2177 pcol_min += (wid / 2);
2181 if (x < panel_col_min + 4)
2183 while (x < pcol_min + 4)
2185 pcol_min -= (wid / 2);
2189 if (pcol_min > max_pcol_min) pcol_min = max_pcol_min;
2190 if (pcol_min < 0) pcol_min = 0;
2193 /* Check for "no change" */
2194 if ((prow_min == panel_row_min) && (pcol_min == panel_col_min)) return;
2196 /* Save the new panel info */
2197 panel_row_min = prow_min;
2198 panel_col_min = pcol_min;
2200 /* Hack -- optional disturb on "panel change" */
2201 if (disturb_panel && !center_player) disturb(FALSE, FALSE);
2203 /* Recalculate the boundaries */
2204 panel_bounds_center();
2206 p_ptr->update |= (PU_MONSTERS);
2208 p_ptr->redraw |= (PR_MAP);
2210 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
2215 * Monster health description
2217 cptr look_mon_desc(monster_type *m_ptr, BIT_FLAGS mode)
2219 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
2226 /* Determine if the monster is "living" */
2227 living = monster_living(ap_r_ptr);
2229 /* Calculate a health "percentage" */
2230 perc = 100L * m_ptr->hp / m_ptr->maxhp;
2232 /* Healthy monsters */
2233 if (m_ptr->hp >= m_ptr->maxhp)
2237 desc = living ? "無傷" : "無ダメージ";
2239 desc = living ? "unhurt" : "undamaged";
2244 else if (perc >= 60)
2247 desc = living ? "軽傷" : "小ダメージ";
2249 desc = living ? "somewhat wounded" : "somewhat damaged";
2254 else if (perc >= 25)
2257 desc = living ? "負傷" : "中ダメージ";
2259 desc = living ? "wounded" : "damaged";
2264 else if (perc >= 10)
2267 desc = living ? "重傷" : "大ダメージ";
2269 desc = living ? "badly wounded" : "badly damaged";
2277 desc = living ? "半死半生" : "倒れかけ";
2279 desc = living ? "almost dead" : "almost destroyed";
2284 /* Need attitude information? */
2287 /* Full information is not needed */
2290 else if (is_pet(m_ptr))
2292 attitude = _(", ペット", ", pet");
2294 else if (is_friendly(m_ptr))
2296 attitude = _(", 友好的", ", friendly");
2300 attitude = _("", "");
2304 /* Clone monster? */
2305 if (m_ptr->smart & SM_CLONED)
2314 /* Display monster's level --- idea borrowed from ToME */
2315 if (ap_r_ptr->r_tkills && !(m_ptr->mflag2 & MFLAG2_KAGE))
2317 return format(_("レベル%d, %s%s%s", "Level %d, %s%s%s"), ap_r_ptr->level, desc, attitude, clone);
2321 return format(_("レベル???, %s%s%s", "Level ???, %s%s%s"), desc, attitude, clone);
2328 * Angband sorting algorithm -- quick sort in place
2330 * Note that the details of the data we are sorting is hidden,
2331 * and we rely on the "ang_sort_comp()" and "ang_sort_swap()"
2332 * function hooks to interact with the data, which is given as
2333 * two pointers, and which may have any user-defined form.
2335 void ang_sort_aux(vptr u, vptr v, int p, int q)
2353 while (!(*ang_sort_comp)(u, v, b, z)) b--;
2356 while (!(*ang_sort_comp)(u, v, z, a)) a++;
2358 /* Done partition */
2362 (*ang_sort_swap)(u, v, a, b);
2368 /* Recurse left side */
2369 ang_sort_aux(u, v, p, b);
2371 /* Recurse right side */
2372 ang_sort_aux(u, v, b+1, q);
2377 * Angband sorting algorithm -- quick sort in place
2379 * Note that the details of the data we are sorting is hidden,
2380 * and we rely on the "ang_sort_comp()" and "ang_sort_swap()"
2381 * function hooks to interact with the data, which is given as
2382 * two pointers, and which may have any user-defined form.
2384 void ang_sort(vptr u, vptr v, int n)
2386 /* Sort the array */
2387 ang_sort_aux(u, v, 0, n-1);
2392 /*** Targeting Code ***/
2396 * Determine is a monster makes a reasonable target
2398 * The concept of "targeting" was stolen from "Morgul" (?)
2400 * The player can target any location, or any "target-able" monster.
2402 * Currently, a monster is "target_able" if it is visible, and if
2403 * the player can hit it with a projection, and the player is not
2404 * hallucinating. This allows use of "use closest target" macros.
2406 * Future versions may restrict the ability to target "trappers"
2407 * and "mimics", but the semantics is a little bit weird.
2409 bool target_able(MONSTER_IDX m_idx)
2411 monster_type *m_ptr = &m_list[m_idx];
2413 /* Monster must be alive */
2414 if (!m_ptr->r_idx) return (FALSE);
2416 /* Hack -- no targeting hallucinations */
2417 if (p_ptr->image) return (FALSE);
2419 /* Monster must be visible */
2420 if (!m_ptr->ml) return (FALSE);
2422 if (p_ptr->riding && (p_ptr->riding == m_idx)) return (TRUE);
2424 /* Monster must be projectable */
2425 if (!projectable(p_ptr->y, p_ptr->x, m_ptr->fy, m_ptr->fx)) return (FALSE);
2427 /* Hack -- Never target trappers */
2428 /* if (CLEAR_ATTR && (CLEAR_CHAR)) return (FALSE); */
2438 * Update (if necessary) and verify (if possible) the target.
2440 * We return TRUE if the target is "okay" and FALSE otherwise.
2442 bool target_okay(void)
2444 /* Accept stationary targets */
2445 if (target_who < 0) return (TRUE);
2447 /* Check moving targets */
2450 /* Accept reasonable targets */
2451 if (target_able(target_who))
2453 monster_type *m_ptr = &m_list[target_who];
2455 /* Acquire monster location */
2456 target_row = m_ptr->fy;
2457 target_col = m_ptr->fx;
2464 /* Assume no target */
2470 * Sorting hook -- comp function -- by "distance to player"
2472 * We use "u" and "v" to point to arrays of "x" and "y" positions,
2473 * and sort the arrays by double-distance to the player.
2475 static bool ang_sort_comp_distance(vptr u, vptr v, int a, int b)
2477 POSITION *x = (POSITION*)(u);
2478 POSITION *y = (POSITION*)(v);
2480 POSITION da, db, kx, ky;
2482 /* Absolute distance components */
2483 kx = x[a]; kx -= p_ptr->x; kx = ABS(kx);
2484 ky = y[a]; ky -= p_ptr->y; ky = ABS(ky);
2486 /* Approximate Double Distance to the first point */
2487 da = ((kx > ky) ? (kx + kx + ky) : (ky + ky + kx));
2489 /* Absolute distance components */
2490 kx = x[b]; kx -= p_ptr->x; kx = ABS(kx);
2491 ky = y[b]; ky -= p_ptr->y; ky = ABS(ky);
2493 /* Approximate Double Distance to the first point */
2494 db = ((kx > ky) ? (kx + kx + ky) : (ky + ky + kx));
2496 /* Compare the distances */
2502 * Sorting hook -- comp function -- by importance level of grids
2504 * We use "u" and "v" to point to arrays of "x" and "y" positions,
2505 * and sort the arrays by level of monster
2507 static bool ang_sort_comp_importance(vptr u, vptr v, int a, int b)
2509 POSITION *x = (POSITION*)(u);
2510 POSITION *y = (POSITION*)(v);
2511 cave_type *ca_ptr = &cave[y[a]][x[a]];
2512 cave_type *cb_ptr = &cave[y[b]][x[b]];
2513 monster_type *ma_ptr = &m_list[ca_ptr->m_idx];
2514 monster_type *mb_ptr = &m_list[cb_ptr->m_idx];
2515 monster_race *ap_ra_ptr, *ap_rb_ptr;
2517 /* The player grid */
2518 if (y[a] == p_ptr->y && x[a] == p_ptr->x) return TRUE;
2519 if (y[b] == p_ptr->y && x[b] == p_ptr->x) return FALSE;
2521 /* Extract monster race */
2522 if (ca_ptr->m_idx && ma_ptr->ml) ap_ra_ptr = &r_info[ma_ptr->ap_r_idx];
2523 else ap_ra_ptr = NULL;
2524 if (cb_ptr->m_idx && mb_ptr->ml) ap_rb_ptr = &r_info[mb_ptr->ap_r_idx];
2525 else ap_rb_ptr = NULL;
2527 if (ap_ra_ptr && !ap_rb_ptr) return TRUE;
2528 if (!ap_ra_ptr && ap_rb_ptr) return FALSE;
2530 /* Compare two monsters */
2531 if (ap_ra_ptr && ap_rb_ptr)
2533 /* Unique monsters first */
2534 if ((ap_ra_ptr->flags1 & RF1_UNIQUE) && !(ap_rb_ptr->flags1 & RF1_UNIQUE)) return TRUE;
2535 if (!(ap_ra_ptr->flags1 & RF1_UNIQUE) && (ap_rb_ptr->flags1 & RF1_UNIQUE)) return FALSE;
2537 /* Shadowers first (あやしい影) */
2538 if ((ma_ptr->mflag2 & MFLAG2_KAGE) && !(mb_ptr->mflag2 & MFLAG2_KAGE)) return TRUE;
2539 if (!(ma_ptr->mflag2 & MFLAG2_KAGE) && (mb_ptr->mflag2 & MFLAG2_KAGE)) return FALSE;
2541 /* Unknown monsters first */
2542 if (!ap_ra_ptr->r_tkills && ap_rb_ptr->r_tkills) return TRUE;
2543 if (ap_ra_ptr->r_tkills && !ap_rb_ptr->r_tkills) return FALSE;
2545 /* Higher level monsters first (if known) */
2546 if (ap_ra_ptr->r_tkills && ap_rb_ptr->r_tkills)
2548 if (ap_ra_ptr->level > ap_rb_ptr->level) return TRUE;
2549 if (ap_ra_ptr->level < ap_rb_ptr->level) return FALSE;
2552 /* Sort by index if all conditions are same */
2553 if (ma_ptr->ap_r_idx > mb_ptr->ap_r_idx) return TRUE;
2554 if (ma_ptr->ap_r_idx < mb_ptr->ap_r_idx) return FALSE;
2557 /* An object get higher priority */
2558 if (cave[y[a]][x[a]].o_idx && !cave[y[b]][x[b]].o_idx) return TRUE;
2559 if (!cave[y[a]][x[a]].o_idx && cave[y[b]][x[b]].o_idx) return FALSE;
2561 /* Priority from the terrain */
2562 if (f_info[ca_ptr->feat].priority > f_info[cb_ptr->feat].priority) return TRUE;
2563 if (f_info[ca_ptr->feat].priority < f_info[cb_ptr->feat].priority) return FALSE;
2565 /* If all conditions are same, compare distance */
2566 return ang_sort_comp_distance(u, v, a, b);
2571 * Sorting hook -- swap function -- by "distance to player"
2573 * We use "u" and "v" to point to arrays of "x" and "y" positions,
2574 * and sort the arrays by distance to the player.
2576 static void ang_sort_swap_distance(vptr u, vptr v, int a, int b)
2578 POSITION *x = (POSITION*)(u);
2579 POSITION *y = (POSITION*)(v);
2597 * Hack -- help "select" a location (see below)
2599 static POSITION_IDX target_pick(POSITION y1, POSITION x1, POSITION dy, POSITION dx)
2602 POSITION x2, y2, x3, y3, x4, y4;
2603 POSITION_IDX b_i = -1, b_v = 9999;
2606 /* Scan the locations */
2607 for (i = 0; i < temp_n; i++)
2613 /* Directed distance */
2617 /* Verify quadrant */
2618 if (dx && (x3 * dx <= 0)) continue;
2619 if (dy && (y3 * dy <= 0)) continue;
2621 /* Absolute distance */
2625 /* Verify quadrant */
2626 if (dy && !dx && (x4 > y4)) continue;
2627 if (dx && !dy && (y4 > x4)) continue;
2629 /* Approximate Double Distance */
2630 v = ((x4 > y4) ? (x4 + x4 + y4) : (y4 + y4 + x4));
2632 /* Penalize location */
2635 if ((b_i >= 0) && (v >= b_v)) continue;
2645 * Hack -- determine if a given location is "interesting"
2647 static bool target_set_accept(POSITION y, POSITION x)
2650 OBJECT_IDX this_o_idx, next_o_idx = 0;
2653 if (!(in_bounds(y, x))) return (FALSE);
2655 /* Player grid is always interesting */
2656 if (player_bold(y, x)) return (TRUE);
2658 /* Handle hallucination */
2659 if (p_ptr->image) return (FALSE);
2661 /* Examine the grid */
2662 c_ptr = &cave[y][x];
2664 /* Visible monsters */
2667 monster_type *m_ptr = &m_list[c_ptr->m_idx];
2669 /* Visible monsters */
2670 if (m_ptr->ml) return (TRUE);
2673 /* Scan all objects in the grid */
2674 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
2677 o_ptr = &o_list[this_o_idx];
2679 /* Acquire next object */
2680 next_o_idx = o_ptr->next_o_idx;
2682 /* Memorized object */
2683 if (o_ptr->marked & OM_FOUND) return (TRUE);
2686 /* Interesting memorized features */
2687 if (c_ptr->info & (CAVE_MARK))
2689 /* Notice object features */
2690 if (c_ptr->info & CAVE_OBJECT) return (TRUE);
2692 /* Feature code (applying "mimic" field) */
2693 if (have_flag(f_info[get_feat_mimic(c_ptr)].flags, FF_NOTICE)) return TRUE;
2701 * Prepare the "temp" array for "target_set"
2703 * Return the number of target_able monsters in the set.
2705 static void target_set_prepare(BIT_FLAGS mode)
2708 POSITION min_hgt, max_hgt, min_wid, max_wid;
2710 if (mode & TARGET_KILL)
2713 min_hgt = MAX((p_ptr->y - MAX_RANGE), 0);
2714 max_hgt = MIN((p_ptr->y + MAX_RANGE), cur_hgt - 1);
2715 min_wid = MAX((p_ptr->x - MAX_RANGE), 0);
2716 max_wid = MIN((p_ptr->x + MAX_RANGE), cur_wid - 1);
2718 else /* not targetting */
2721 min_hgt = panel_row_min;
2722 max_hgt = panel_row_max;
2723 min_wid = panel_col_min;
2724 max_wid = panel_col_max;
2727 /* Reset "temp" array */
2730 /* Scan the current panel */
2731 for (y = min_hgt; y <= max_hgt; y++)
2733 for (x = min_wid; x <= max_wid; x++)
2737 /* Require "interesting" contents */
2738 if (!target_set_accept(y, x)) continue;
2740 c_ptr = &cave[y][x];
2742 /* Require target_able monsters for "TARGET_KILL" */
2743 if ((mode & (TARGET_KILL)) && !target_able(c_ptr->m_idx)) continue;
2745 if ((mode & (TARGET_KILL)) && !target_pet && is_pet(&m_list[c_ptr->m_idx])) continue;
2747 /* Save the location */
2754 /* Set the sort hooks */
2755 if (mode & (TARGET_KILL))
2757 /* Target the nearest monster for shooting */
2758 ang_sort_comp = ang_sort_comp_distance;
2759 ang_sort_swap = ang_sort_swap_distance;
2763 /* Look important grids first in Look command */
2764 ang_sort_comp = ang_sort_comp_importance;
2765 ang_sort_swap = ang_sort_swap_distance;
2768 /* Sort the positions */
2769 ang_sort(temp_x, temp_y, temp_n);
2771 if (p_ptr->riding && target_pet && (temp_n > 1) && (mode & (TARGET_KILL)))
2776 temp_y[0] = temp_y[1];
2779 temp_x[0] = temp_x[1];
2784 void target_set_prepare_look(void){
2785 target_set_prepare(TARGET_LOOK);
2790 * Evaluate number of kill needed to gain level
2792 static void evaluate_monster_exp(char *buf, monster_type *m_ptr)
2794 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
2796 s32b exp_mon, exp_adv;
2797 u32b exp_mon_frac, exp_adv_frac;
2799 if ((p_ptr->lev >= PY_MAX_LEVEL) || (p_ptr->prace == RACE_ANDROID))
2804 else if (!ap_r_ptr->r_tkills || (m_ptr->mflag2 & MFLAG2_KAGE))
2814 /* The monster's experience point (assuming average monster speed) */
2815 exp_mon = ap_r_ptr->mexp * ap_r_ptr->level;
2817 s64b_div(&exp_mon, &exp_mon_frac, 0, (p_ptr->max_plv + 2));
2820 /* Total experience value for next level */
2821 exp_adv = player_exp[p_ptr->lev -1] * p_ptr->expfact;
2823 s64b_div(&exp_adv, &exp_adv_frac, 0, 100);
2825 /* Experience value need to get */
2826 s64b_sub(&exp_adv, &exp_adv_frac, p_ptr->exp, p_ptr->exp_frac);
2829 /* You need to kill at least one monster to get any experience */
2830 s64b_add(&exp_adv, &exp_adv_frac, exp_mon, exp_mon_frac);
2831 s64b_sub(&exp_adv, &exp_adv_frac, 0, 1);
2833 /* Extract number of monsters needed */
2834 s64b_div(&exp_adv, &exp_adv_frac, exp_mon, exp_mon_frac);
2836 /* If 999 or more monsters needed, only display "999". */
2837 num = MIN(999, exp_adv_frac);
2839 /* Display the number */
2840 sprintf(buf,"%03ld", (long int)num);
2844 bool show_gold_on_floor = FALSE;
2847 * Examine a grid, return a keypress.
2849 * The "mode" argument contains the "TARGET_LOOK" bit flag, which
2850 * indicates that the "space" key should scan through the contents
2851 * of the grid, instead of simply returning immediately. This lets
2852 * the "look" command get complete information, without making the
2853 * "target" command annoying.
2855 * The "info" argument contains the "commands" which should be shown
2856 * inside the "[xxx]" text. This string must never be empty, or grids
2857 * containing monsters will be displayed with an extra comma.
2859 * Note that if a monster is in the grid, we update both the monster
2860 * recall info and the health bar info to track that monster.
2862 * Eventually, we may allow multiple objects per grid, or objects
2863 * and terrain features in the same grid.
2865 * This function must handle blindness/hallucination.
2867 static char target_set_aux(POSITION y, POSITION x, BIT_FLAGS mode, cptr info)
2869 cave_type *c_ptr = &cave[y][x];
2870 OBJECT_IDX this_o_idx, next_o_idx = 0;
2871 cptr s1 = "", s2 = "", s3 = "", x_info = "";
2874 feature_type *f_ptr;
2875 char query = '\001';
2876 char out_val[MAX_NLEN+80];
2877 OBJECT_IDX floor_list[23];
2878 ITEM_NUMBER floor_num = 0;
2880 /* Scan all objects in the grid */
2883 floor_num = scan_floor(floor_list, y, x, 0x02);
2887 x_info = _("x物 ", "x,");
2891 /* Hack -- under the player */
2892 if (player_bold(y, x))
2908 s1 = _("ターゲット:", "Target:");
2911 /* Hack -- hallucination */
2914 cptr name = _("何か奇妙な物", "something strange");
2916 /* Display a message */
2918 sprintf(out_val, "%s%s%s%s [%s]", s1, name, s2, s3, info);
2920 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, name, info);
2924 move_cursor_relative(y, x);
2927 /* Stop on everything but "return" */
2928 if ((query != '\r') && (query != '\n')) return query;
2930 /* Repeat forever */
2935 /* Actual monsters */
2936 if (c_ptr->m_idx && m_list[c_ptr->m_idx].ml)
2938 monster_type *m_ptr = &m_list[c_ptr->m_idx];
2939 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
2941 bool recall = FALSE;
2946 /* Get the monster name ("a kobold") */
2947 monster_desc(m_name, m_ptr, MD_INDEF_VISIBLE);
2949 /* Hack -- track this monster race */
2950 monster_race_track(m_ptr->ap_r_idx);
2952 /* Hack -- health bar for this monster */
2953 health_track(c_ptr->m_idx);
2967 /* Recall on screen */
2968 screen_roff(m_ptr->ap_r_idx, 0);
2970 /* Hack -- Complete the prompt (again) */
2971 Term_addstr(-1, TERM_WHITE, format(_(" [r思 %s%s]", " [r,%s%s]"), x_info, info));
2979 /* Normal commands */
2980 if (query != 'r') break;
2985 /* Cleare recall text and repeat */
2991 /* Describe, and prompt for recall */
2992 evaluate_monster_exp(acount, m_ptr);
2995 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);
2997 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);
3003 move_cursor_relative(y, x);
3008 /* Normal commands */
3009 if (query != 'r') break;
3015 /* Always stop at "normal" keys */
3016 if ((query != '\r') && (query != '\n') && (query != ' ') && (query != 'x')) return query;
3018 /* Sometimes stop at "space" key */
3019 if ((query == ' ') && !(mode & (TARGET_LOOK))) return query;
3021 /* Change the intro */
3022 s1 = _("それは", "It is ");
3024 /* Hack -- take account of gender */
3025 if (ap_r_ptr->flags1 & (RF1_FEMALE)) s1 = _("彼女は", "She is ");
3026 else if (ap_r_ptr->flags1 & (RF1_MALE)) s1 = _("彼は", "He is ");
3028 /* Use a preposition */
3037 /* Scan all objects being carried */
3038 for (this_o_idx = m_ptr->hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
3040 char o_name[MAX_NLEN];
3043 o_ptr = &o_list[this_o_idx];
3045 /* Acquire next object */
3046 next_o_idx = o_ptr->next_o_idx;
3048 /* Obtain an object description */
3049 object_desc(o_name, o_ptr, 0);
3052 sprintf(out_val, "%s%s%s%s[%s]", s1, o_name, s2, s3, info);
3054 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, o_name, info);
3058 move_cursor_relative(y, x);
3061 /* Always stop at "normal" keys */
3062 if ((query != '\r') && (query != '\n') && (query != ' ') && (query != 'x')) return query;
3064 /* Sometimes stop at "space" key */
3065 if ((query == ' ') && !(mode & (TARGET_LOOK))) return query;
3067 /* Change the intro */
3068 s2 = _("をまた", "also carrying ");
3071 /* Use a preposition */
3088 char o_name[MAX_NLEN];
3091 o_ptr = &o_list[floor_list[0]];
3093 object_desc(o_name, o_ptr, 0);
3096 sprintf(out_val, "%s%s%s%s[%s]", s1, o_name, s2, s3, info);
3098 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, o_name, info);
3102 move_cursor_relative(y, x);
3111 /* Provide one cushion before item listing */
3114 /* Display rough information about items */
3116 sprintf(out_val, "%s %d個のアイテム%s%s ['x'で一覧, %s]", s1, (int)floor_num, s2, s3, info);
3118 sprintf(out_val, "%s%s%sa pile of %d items [x,%s]", s1, s2, s3, (int)floor_num, info);
3122 move_cursor_relative(y, x);
3127 /* No request for listing */
3128 if (query != 'x' && query != ' ') return query;
3132 /** Display list of items **/
3134 /* Continue scrolling list if requested */
3142 show_gold_on_floor = TRUE;
3143 (void)show_floor(0, y, x, &min_width);
3144 show_gold_on_floor = FALSE;
3148 sprintf(out_val, "%s %d個のアイテム%s%s [Enterで次へ, %s]", s1, (int)floor_num, s2, s3, info);
3150 sprintf(out_val, "%s%s%sa pile of %d items [Enter,%s]", s1, s2, s3, (int)floor_num, info);
3157 /* Exit unless 'Enter' */
3158 if (query != '\n' && query != '\r')
3163 /* Get the object being moved. */
3164 o_idx = c_ptr->o_idx;
3166 /* Only rotate a pile of two or more objects. */
3167 if (!(o_idx && o_list[o_idx].next_o_idx)) continue;
3169 /* Remove the first object from the list. */
3170 excise_object_idx(o_idx);
3172 /* Find end of the list. */
3174 while (o_list[i].next_o_idx)
3175 i = o_list[i].next_o_idx;
3177 /* Add after the last object. */
3178 o_list[i].next_o_idx = o_idx;
3180 /* Loop and re-display the list */
3187 /* Scan all objects in the grid */
3188 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
3191 o_ptr = &o_list[this_o_idx];
3193 /* Acquire next object */
3194 next_o_idx = o_ptr->next_o_idx;
3197 if (o_ptr->marked & OM_FOUND)
3199 char o_name[MAX_NLEN];
3204 /* Obtain an object description */
3205 object_desc(o_name, o_ptr, 0);
3208 sprintf(out_val, "%s%s%s%s[%s]", s1, o_name, s2, s3, info);
3210 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, o_name, info);
3214 move_cursor_relative(y, x);
3217 /* Always stop at "normal" keys */
3218 if ((query != '\r') && (query != '\n') && (query != ' ') && (query != 'x')) return query;
3220 /* Sometimes stop at "space" key */
3221 if ((query == ' ') && !(mode & TARGET_LOOK)) return query;
3223 /* Change the intro */
3224 s1 = _("それは", "It is ");
3227 if (o_ptr->number != 1) s1 = _("それらは", "They are ");
3241 /* Feature code (applying "mimic" field) */
3242 feat = get_feat_mimic(c_ptr);
3244 /* Require knowledge about grid, or ability to see grid */
3245 if (!(c_ptr->info & CAVE_MARK) && !player_can_see_bold(y, x))
3247 /* Forget feature */
3251 f_ptr = &f_info[feat];
3253 /* Terrain feature if needed */
3254 if (boring || have_flag(f_ptr->flags, FF_REMEMBER))
3258 /* Hack -- special handling for quest entrances */
3259 if (have_flag(f_ptr->flags, FF_QUEST_ENTER))
3261 /* Set the quest number temporary */
3262 IDX old_quest = p_ptr->inside_quest;
3265 /* Clear the text */
3266 for (j = 0; j < 10; j++) quest_text[j][0] = '\0';
3267 quest_text_line = 0;
3269 p_ptr->inside_quest = c_ptr->special;
3271 /* Get the quest text */
3272 init_flags = INIT_NAME_ONLY;
3274 process_dungeon_file("q_info.txt", 0, 0, 0, 0);
3276 name = format(_("クエスト「%s」(%d階相当)", "the entrance to the quest '%s'(level %d)"),
3277 quest[c_ptr->special].name, quest[c_ptr->special].level);
3279 /* Reset the old quest number */
3280 p_ptr->inside_quest = old_quest;
3283 /* Hack -- special handling for building doors */
3284 else if (have_flag(f_ptr->flags, FF_BLDG) && !p_ptr->inside_arena)
3286 name = building[f_ptr->subtype].name;
3288 else if (have_flag(f_ptr->flags, FF_ENTRANCE))
3290 name = format(_("%s(%d階相当)", "%s(level %d)"), d_text + d_info[c_ptr->special].text, d_info[c_ptr->special].mindepth);
3292 else if (have_flag(f_ptr->flags, FF_TOWN))
3294 name = town[c_ptr->special].name;
3296 else if (p_ptr->wild_mode && (feat == feat_floor))
3298 name = _("道", "road");
3302 name = f_name + f_ptr->name;
3308 ((!have_flag(f_ptr->flags, FF_MOVE) && !have_flag(f_ptr->flags, FF_CAN_FLY)) ||
3309 (!have_flag(f_ptr->flags, FF_LOS) && !have_flag(f_ptr->flags, FF_TREE)) ||
3310 have_flag(f_ptr->flags, FF_TOWN)))
3312 s2 = _("の中", "in ");
3315 /* Hack -- special introduction for store & building doors -KMW- */
3316 if (have_flag(f_ptr->flags, FF_STORE) ||
3317 have_flag(f_ptr->flags, FF_QUEST_ENTER) ||
3318 (have_flag(f_ptr->flags, FF_BLDG) && !p_ptr->inside_arena) ||
3319 have_flag(f_ptr->flags, FF_ENTRANCE))
3328 else if (have_flag(f_ptr->flags, FF_FLOOR) ||
3329 have_flag(f_ptr->flags, FF_TOWN) ||
3330 have_flag(f_ptr->flags, FF_SHALLOW) ||
3331 have_flag(f_ptr->flags, FF_DEEP))
3337 /* Pick proper indefinite article */
3338 s3 = (is_a_vowel(name[0])) ? "an " : "a ";
3342 /* Display a message */
3346 if (c_ptr->mimic) sprintf(f_idx_str, "%d/%d", c_ptr->feat, c_ptr->mimic);
3347 else sprintf(f_idx_str, "%d", c_ptr->feat);
3349 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]);
3351 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);
3356 sprintf(out_val, "%s%s%s%s[%s]", s1, name, s2, s3, info);
3358 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, name, info);
3362 move_cursor_relative(y, x);
3365 /* Always stop at "normal" keys */
3366 if ((query != '\r') && (query != '\n') && (query != ' ')) return query;
3369 /* Stop on everything but "return" */
3370 if ((query != '\r') && (query != '\n')) return query;
3372 /* Repeat forever */
3378 * Handle "target" and "look".
3380 * Note that this code can be called from "get_aim_dir()".
3382 * All locations must be on the current panel. Consider the use of
3383 * "panel_bounds()" to allow "off-panel" targets, perhaps by using
3384 * some form of "scrolling" the map around the cursor.
3385 * That is, consider the possibility of "auto-scrolling" the screen
3386 * while the cursor moves around. This may require changes in the
3387 * "update_monster()" code to allow "visibility" even if off panel, and
3388 * may require dynamic recalculation of the "temp" grid set.
3390 * Hack -- targeting/observing an "outer border grid" may induce
3391 * problems, so this is not currently allowed.
3393 * The player can use the direction keys to move among "interesting"
3394 * grids in a heuristic manner, or the "space", "+", and "-" keys to
3395 * move through the "interesting" grids in a sequential manner, or
3396 * can enter "location" mode, and use the direction keys to move one
3397 * grid at a time in any direction. The "t" (set target) command will
3398 * only target a monster (as opposed to a location) if the monster is
3399 * target_able and the "interesting" mode is being used.
3401 * The current grid is described using the "look" method above, and
3402 * a new command may be entered at any time, but note that if the
3403 * "TARGET_LOOK" bit flag is set (or if we are in "location" mode,
3404 * where "space" has no obvious meaning) then "space" will scan
3405 * through the description of the current grid until done, instead
3406 * of immediately jumping to the next "interesting" grid. This
3407 * allows the "target" command to retain its old semantics.
3409 * The "*", "+", and "-" keys may always be used to jump immediately
3410 * to the next (or previous) interesting grid, in the proper mode.
3412 * The "return" key may always be used to scan through a complete
3413 * grid description (forever).
3415 * This command will cancel any old target, even if used from
3416 * inside the "look" command.
3418 bool target_set(BIT_FLAGS mode)
3421 POSITION y = p_ptr->y;
3422 POSITION x = p_ptr->x;
3434 get_screen_size(&wid, &hgt);
3440 /* Cancel tracking */
3441 /* health_track(0); */
3443 if (rogue_like_commands)
3452 /* Prepare the "temp" array */
3453 target_set_prepare(mode);
3455 /* Start near the player */
3461 /* Interesting grids */
3468 change_panel_xy(y, x);
3470 if (!(mode & TARGET_LOOK)) prt_path(y, x);
3473 c_ptr = &cave[y][x];
3476 if (target_able(c_ptr->m_idx))
3478 strcpy(info, _("q止 t決 p自 o現 +次 -前", "q,t,p,o,+,-,<dir>"));
3481 /* Dis-allow target */
3484 strcpy(info, _("q止 p自 o現 +次 -前", "q,p,o,+,-,<dir>"));
3490 sprintf(cheatinfo, " LOS:%d, PROJECTABLE:%d",
3491 los(p_ptr->y, p_ptr->x, y, x),
3492 projectable(p_ptr->y, p_ptr->x, y, x));
3493 strcat(info, cheatinfo);
3496 /* Describe and Prompt */
3498 query = target_set_aux(y, x, mode, info);
3502 /* Cancel tracking */
3503 /* health_track(0); */
3505 /* Assume no "direction" */
3510 if (query == '\r') query = 't';
3528 if (target_able(c_ptr->m_idx))
3530 health_track(c_ptr->m_idx);
3531 target_who = c_ptr->m_idx;
3550 if (!expand_list) done = TRUE;
3560 if (!expand_list) done = TRUE;
3567 /* Recenter the map around the player */
3570 p_ptr->update |= (PU_MONSTERS);
3572 p_ptr->redraw |= (PR_MAP);
3574 p_ptr->window |= (PW_OVERHEAD);
3577 /* Recalculate interesting grids */
3578 target_set_prepare(mode);
3597 if(query == same_key)
3602 if (!expand_list) done = TRUE;
3607 /* Extract the action (if any) */
3608 d = get_keymap_dir(query);
3615 /* Hack -- move around */
3618 /* Modified to scroll to monster */
3619 POSITION y2 = panel_row_min;
3620 POSITION x2 = panel_col_min;
3622 /* Find a new monster */
3623 i = target_pick(temp_y[m], temp_x[m], ddy[d], ddx[d]);
3625 /* Request to target past last interesting grid */
3626 while (flag && (i < 0))
3628 /* Note the change */
3629 if (change_panel(ddy[d], ddx[d]))
3634 /* Recalculate interesting grids */
3635 target_set_prepare(mode);
3637 /* Look at interesting grids */
3640 /* Find a new monster */
3641 i = target_pick(v, u, ddy[d], ddx[d]);
3647 /* Nothing interesting */
3653 /* Restore previous position */
3656 panel_bounds_center();
3658 p_ptr->update |= (PU_MONSTERS);
3660 p_ptr->redraw |= (PR_MAP);
3662 p_ptr->window |= (PW_OVERHEAD);
3665 /* Recalculate interesting grids */
3666 target_set_prepare(mode);
3668 /* Look at boring grids */
3675 /* Do not move horizontally if unnecessary */
3676 if (((x < panel_col_min + wid / 2) && (dx > 0)) ||
3677 ((x > panel_col_min + wid / 2) && (dx < 0)))
3682 /* Do not move vertically if unnecessary */
3683 if (((y < panel_row_min + hgt / 2) && (dy > 0)) ||
3684 ((y > panel_row_min + hgt / 2) && (dy < 0)))
3689 /* Apply the motion */
3690 if ((y >= panel_row_min+hgt) || (y < panel_row_min) ||
3691 (x >= panel_col_min+wid) || (x < panel_col_min))
3693 if (change_panel(dy, dx)) target_set_prepare(mode);
3696 /* Slide into legality */
3697 if (x >= cur_wid-1) x = cur_wid - 2;
3698 else if (x <= 0) x = 1;
3700 /* Slide into legality */
3701 if (y >= cur_hgt-1) y = cur_hgt- 2;
3702 else if (y <= 0) y = 1;
3711 /* Arbitrary grids */
3714 bool move_fast = FALSE;
3716 if (!(mode & TARGET_LOOK)) prt_path(y, x);
3719 c_ptr = &cave[y][x];
3721 /* Default prompt */
3722 strcpy(info, _("q止 t決 p自 m近 +次 -前", "q,t,p,m,+,-,<dir>"));
3727 sprintf(cheatinfo, " LOS:%d, PROJECTABLE:%d",
3728 los(p_ptr->y, p_ptr->x, y, x),
3729 projectable(p_ptr->y, p_ptr->x, y, x));
3730 strcat(info, cheatinfo);
3733 /* Describe and Prompt (enable "TARGET_LOOK") */
3734 while ((query = target_set_aux(y, x, mode | TARGET_LOOK, info)) == 0);
3736 /* Cancel tracking */
3737 /* health_track(0); */
3739 /* Assume no direction */
3744 if (query == '\r') query = 't';
3747 /* Analyze the keypress */
3771 /* Recenter the map around the player */
3774 p_ptr->update |= (PU_MONSTERS);
3776 p_ptr->redraw |= (PR_MAP);
3778 p_ptr->window |= (PW_OVERHEAD);
3781 /* Recalculate interesting grids */
3782 target_set_prepare(mode);
3804 /* Pick a nearby monster */
3805 for (i = 0; i < temp_n; i++)
3807 t = distance(y, x, temp_y[i], temp_x[i]);
3817 /* Nothing interesting */
3818 if (bd == 999) flag = FALSE;
3825 /* Extract the action (if any) */
3826 d = get_keymap_dir(query);
3828 /* XTRA HACK MOVEFAST */
3829 if (isupper(query)) move_fast = TRUE;
3836 /* Handle "direction" */
3842 /* XTRA HACK MOVEFAST */
3845 int mag = MIN(wid / 2, hgt / 2);
3855 /* Do not move horizontally if unnecessary */
3856 if (((x < panel_col_min + wid / 2) && (dx > 0)) ||
3857 ((x > panel_col_min + wid / 2) && (dx < 0)))
3862 /* Do not move vertically if unnecessary */
3863 if (((y < panel_row_min + hgt / 2) && (dy > 0)) ||
3864 ((y > panel_row_min + hgt / 2) && (dy < 0)))
3869 /* Apply the motion */
3870 if ((y >= panel_row_min + hgt) || (y < panel_row_min) ||
3871 (x >= panel_col_min + wid) || (x < panel_col_min))
3873 if (change_panel(dy, dx)) target_set_prepare(mode);
3876 /* Slide into legality */
3877 if (x >= cur_wid-1) x = cur_wid - 2;
3878 else if (x <= 0) x = 1;
3880 /* Slide into legality */
3881 if (y >= cur_hgt-1) y = cur_hgt- 2;
3882 else if (y <= 0) y = 1;
3890 /* Clear the top line */
3893 /* Recenter the map around the player */
3896 p_ptr->update |= (PU_MONSTERS);
3898 p_ptr->redraw |= (PR_MAP);
3900 p_ptr->window |= (PW_OVERHEAD);
3903 /* Failure to set target */
3904 if (!target_who) return (FALSE);
3912 * Get an "aiming direction" from the user.
3914 * The "dir" is loaded with 1,2,3,4,6,7,8,9 for "actual direction", and
3915 * "0" for "current target", and "-1" for "entry aborted".
3917 * Note that "Force Target", if set, will pre-empt user interaction,
3918 * if there is a usable target already set.
3920 * Note that confusion over-rides any (explicit?) user choice.
3922 bool get_aim_dir(DIRECTION *dp)
3931 /* Global direction */
3934 /* Hack -- auto-target if requested */
3935 if (use_old_target && target_okay()) dir = 5;
3937 if (repeat_pull(&code))
3942 if (!(code == 5 && !target_okay()))
3944 /* return (TRUE); */
3945 dir = (DIRECTION)code;
3948 *dp = (DIRECTION)code;
3950 /* Ask until satisfied */
3953 /* Choose a prompt */
3956 p = _("方向 ('*'でターゲット選択, ESCで中断)? ", "Direction ('*' to choose a target, Escape to cancel)? ");
3960 p = _("方向 ('5'でターゲットへ, '*'でターゲット再選択, ESCで中断)? ", "Direction ('5' for target, '*' to re-target, Escape to cancel)? ");
3963 /* Get a command (or Cancel) */
3964 if (!get_com(p, &command, TRUE)) break;
3968 if (command == '\r') command = 't';
3971 /* Convert various keys to "standard" keys */
3974 /* Use current target */
3985 /* Set new target */
3990 if (target_set(TARGET_KILL)) dir = 5;
3996 /* Extract the action (if any) */
3997 dir = get_keymap_dir(command);
4003 /* Verify requested targets */
4004 if ((dir == 5) && !target_okay()) dir = 0;
4013 project_length = 0; /* reset to default */
4017 /* Save the direction */
4020 /* Check for confusion */
4021 if (p_ptr->confused)
4023 /* Random direction */
4024 dir = ddd[randint0(8)];
4027 /* Notice confusion */
4028 if (command_dir != dir)
4031 msg_print(_("あなたは混乱している。", "You are confused."));
4034 /* Save direction */
4037 /* repeat_push(dir); */
4038 repeat_push((COMMAND_CODE)command_dir);
4040 /* A "valid" direction was entered */
4045 bool get_direction(DIRECTION *dp, bool allow_under, bool with_steed)
4053 /* Global direction */
4056 if (repeat_pull(&code))
4058 dir = (DIRECTION)code;
4059 /* return (TRUE); */
4061 *dp = (DIRECTION)code;
4065 prompt = _("方向 ('.'足元, ESCで中断)? ", "Direction ('.' at feet, Escape to cancel)? ");
4069 prompt = _("方向 (ESCで中断)? ", "Direction (Escape to cancel)? ");
4072 /* Get a direction */
4077 /* Get a command (or Cancel) */
4078 if (!get_com(prompt, &ch, TRUE)) break;
4081 if ((allow_under) && ((ch == '5') || (ch == '-') || (ch == '.')))
4087 /* Look up the direction */
4088 dir = get_keymap_dir(ch);
4094 /* Prevent weirdness */
4095 if ((dir == 5) && (!allow_under)) dir = 0;
4098 if (!dir) return (FALSE);
4100 /* Save desired direction */
4103 /* Apply "confusion" */
4104 if (p_ptr->confused)
4106 /* Standard confusion */
4107 if (randint0(100) < 75)
4109 /* Random direction */
4110 dir = ddd[randint0(8)];
4113 else if (p_ptr->riding && with_steed)
4115 monster_type *m_ptr = &m_list[p_ptr->riding];
4116 monster_race *r_ptr = &r_info[m_ptr->r_idx];
4118 if (MON_CONFUSED(m_ptr))
4120 /* Standard confusion */
4121 if (randint0(100) < 75)
4123 /* Random direction */
4124 dir = ddd[randint0(8)];
4127 else if ((r_ptr->flags1 & RF1_RAND_50) && (r_ptr->flags1 & RF1_RAND_25) && (randint0(100) < 50))
4129 /* Random direction */
4130 dir = ddd[randint0(8)];
4132 else if ((r_ptr->flags1 & RF1_RAND_50) && (randint0(100) < 25))
4134 /* Random direction */
4135 dir = ddd[randint0(8)];
4139 /* Notice confusion */
4140 if (command_dir != dir)
4142 if (p_ptr->confused)
4145 msg_print(_("あなたは混乱している。", "You are confused."));
4150 monster_type *m_ptr = &m_list[p_ptr->riding];
4152 monster_desc(m_name, m_ptr, 0);
4153 if (MON_CONFUSED(m_ptr))
4155 msg_format(_("%sは混乱している。", "%^s is confusing."), m_name);
4159 msg_format(_("%sは思い通りに動いてくれない。", "You cannot control %s."), m_name);
4164 /* Save direction */
4167 /* repeat_push(dir); */
4168 repeat_push((COMMAND_CODE)command_dir);
4175 * @brief 進行方向を指定する(騎乗対象の混乱の影響を受ける) / Request a "movement" direction (1,2,3,4,6,7,8,9) from the user,
4176 * and place it into "command_dir", unless we already have one.
4178 * This function should be used for all "repeatable" commands, such as
4179 * run, walk, open, close, bash, disarm, spike, tunnel, etc, as well
4180 * as all commands which must reference a grid adjacent to the player,
4181 * and which may not reference the grid under the player. Note that,
4182 * for example, it is no longer possible to "disarm" or "open" chests
4183 * in the same grid as the player.
4185 * Direction "5" is illegal and will (cleanly) abort the command.
4187 * This function tracks and uses the "global direction", and uses
4188 * that as the "desired direction", to which "confusion" is applied.
4190 bool get_rep_dir(DIRECTION *dp, bool under)
4198 /* Global direction */
4201 if (repeat_pull(&code))
4203 dir = (DIRECTION)code;
4204 /* return (TRUE); */
4206 *dp = (DIRECTION)code;
4210 prompt = _("方向 ('.'足元, ESCで中断)? ", "Direction ('.' at feet, Escape to cancel)? ");
4214 prompt = _("方向 (ESCで中断)? ", "Direction (Escape to cancel)? ");
4217 /* Get a direction */
4222 /* Get a command (or Cancel) */
4223 if (!get_com(prompt, &ch, TRUE)) break;
4226 if ((under) && ((ch == '5') || (ch == '-') || (ch == '.')))
4232 /* Look up the direction */
4233 dir = get_keymap_dir(ch);
4239 /* Prevent weirdness */
4240 if ((dir == 5) && (!under)) dir = 0;
4243 if (!dir) return (FALSE);
4245 /* Save desired direction */
4248 /* Apply "confusion" */
4249 if (p_ptr->confused)
4251 /* Standard confusion */
4252 if (randint0(100) < 75)
4254 /* Random direction */
4255 dir = ddd[randint0(8)];
4258 else if (p_ptr->riding)
4260 monster_type *m_ptr = &m_list[p_ptr->riding];
4261 monster_race *r_ptr = &r_info[m_ptr->r_idx];
4263 if (MON_CONFUSED(m_ptr))
4265 /* Standard confusion */
4266 if (randint0(100) < 75)
4268 /* Random direction */
4269 dir = ddd[randint0(8)];
4272 else if ((r_ptr->flags1 & RF1_RAND_50) && (r_ptr->flags1 & RF1_RAND_25) && (randint0(100) < 50))
4274 /* Random direction */
4275 dir = ddd[randint0(8)];
4277 else if ((r_ptr->flags1 & RF1_RAND_50) && (randint0(100) < 25))
4279 /* Random direction */
4280 dir = ddd[randint0(8)];
4284 /* Notice confusion */
4285 if (command_dir != dir)
4287 if (p_ptr->confused)
4290 msg_print(_("あなたは混乱している。", "You are confused."));
4295 monster_type *m_ptr = &m_list[p_ptr->riding];
4297 monster_desc(m_name, m_ptr, 0);
4298 if (MON_CONFUSED(m_ptr))
4300 msg_format(_("%sは混乱している。", "%^s is confusing."), m_name);
4304 msg_format(_("%sは思い通りに動いてくれない。", "You cannot control %s."), m_name);
4309 /* Save direction */
4312 /* repeat_push(dir); */
4313 repeat_push((COMMAND_CODE)command_dir);
4319 void gain_level_reward(int chosen_reward)
4323 char wrath_reason[32] = "";
4324 int nasty_chance = 6;
4325 OBJECT_TYPE_VALUE dummy = 0;
4326 OBJECT_SUBTYPE_VALUE dummy2 = 0;
4329 char o_name[MAX_NLEN];
4335 if (multi_rew) return;
4336 else multi_rew = TRUE;
4340 if (p_ptr->lev == 13) nasty_chance = 2;
4341 else if (!(p_ptr->lev % 13)) nasty_chance = 3;
4342 else if (!(p_ptr->lev % 14)) nasty_chance = 12;
4344 if (one_in_(nasty_chance))
4345 type = randint1(20); /* Allow the 'nasty' effects */
4347 type = randint1(15) + 5; /* Or disallow them */
4349 if (type < 1) type = 1;
4350 if (type > 20) type = 20;
4354 sprintf(wrath_reason, _("%sの怒り", "the Wrath of %s"), chaos_patrons[p_ptr->chaos_patron]);
4356 effect = chaos_rewards[p_ptr->chaos_patron][type];
4358 if (one_in_(6) && !chosen_reward)
4360 msg_format(_("%^sは褒美としてあなたを突然変異させた。", "%^s rewards you with a mutation!"), chaos_patrons[p_ptr->chaos_patron]);
4361 (void)gain_random_mutation(0);
4362 reward = _("変異した。", "mutation");
4366 switch (chosen_reward ? chosen_reward : effect)
4371 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4372 msg_print(_("「汝、新たなる姿を必要とせり!」", "'Thou needst a new form, mortal!'"));
4375 reward = _("変異した。", "polymorphing");
4380 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4381 msg_print(_("「汝は良く行いたり!続けよ!」", "'Well done, mortal! Lead on!'"));
4383 if (p_ptr->prace == RACE_ANDROID)
4385 msg_print(_("しかし何も起こらなかった。", "But, nothing happen."));
4387 else if (p_ptr->exp < PY_MAX_EXP)
4389 s32b ee = (p_ptr->exp / 2) + 10;
4390 if (ee > 100000L) ee = 100000L;
4391 msg_print(_("更に経験を積んだような気がする。", "You feel more experienced."));
4394 reward = _("経験値を得た", "experience");
4400 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4401 msg_print(_("「下僕よ、汝それに値せず。」", "'Thou didst not deserve that, slave.'"));
4403 if (p_ptr->prace == RACE_ANDROID)
4405 msg_print(_("しかし何も起こらなかった。", "But, nothing happen."));
4409 lose_exp(p_ptr->exp / 6);
4410 reward = _("経験値を失った。", "losing experience");
4416 msg_format("%sの声がささやいた:",
4417 chaos_patrons[p_ptr->chaos_patron]);
4419 msg_format("The voice of %s whispers:",
4420 chaos_patrons[p_ptr->chaos_patron]);
4423 msg_print(_("「我が与えし物を賢明に使うべし。」", "'Use my gift wisely.'"));
4425 acquirement(p_ptr->y, p_ptr->x, 1, FALSE, FALSE, FALSE);
4426 reward = _("上質なアイテムを手に入れた。", "a good item");
4431 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4432 msg_print(_("「我が与えし物を賢明に使うべし。」", "'Use my gift wisely.'"));
4434 acquirement(p_ptr->y, p_ptr->x, 1, TRUE, FALSE, FALSE);
4435 reward = _("高級品のアイテムを手に入れた。", "an excellent item");
4440 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4441 msg_print(_("「汝の行いは貴き剣に値せり。」", "'Thy deed hath earned thee a worthy blade.'"));
4444 switch (randint1(p_ptr->lev))
4450 dummy2 = SV_MAIN_GAUCHE;
4459 dummy2 = SV_SMALL_SWORD;
4462 dummy2 = SV_BASILLARD;
4464 case 11: case 12: case 13:
4465 dummy2 = SV_SHORT_SWORD;
4471 dummy2 = SV_CUTLASS;
4474 dummy2 = SV_WAKIZASHI;
4477 dummy2 = SV_KHOPESH;
4483 dummy2 = SV_BROAD_SWORD;
4486 dummy2 = SV_LONG_SWORD;
4489 dummy2 = SV_SCIMITAR;
4492 dummy2 = SV_NINJATO;
4498 dummy2 = SV_BASTARD_SWORD;
4501 dummy2 = SV_GREAT_SCIMITAR;
4504 dummy2 = SV_CLAYMORE;
4507 dummy2 = SV_ESPADON;
4510 dummy2 = SV_TWO_HANDED_SWORD;
4513 dummy2 = SV_FLAMBERGE;
4516 dummy2 = SV_NO_DACHI;
4519 dummy2 = SV_EXECUTIONERS_SWORD;
4522 dummy2 = SV_ZWEIHANDER;
4525 dummy2 = SV_HAYABUSA;
4528 dummy2 = SV_BLADE_OF_CHAOS;
4531 object_prep(q_ptr, lookup_kind(dummy, dummy2));
4532 q_ptr->to_h = 3 + randint1(dun_level) % 10;
4533 q_ptr->to_d = 3 + randint1(dun_level) % 10;
4534 one_resistance(q_ptr);
4535 q_ptr->name2 = EGO_CHAOTIC;
4537 /* Drop it in the dungeon */
4538 (void)drop_near(q_ptr, -1, p_ptr->y, p_ptr->x);
4539 reward = _("(混沌)の武器を手に入れた。", "chaos weapon");
4544 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4545 msg_print(_("「汝の行いは貴き報いに値せり。」", "'Thy deed hath earned thee a worthy reward.'"));
4547 acquirement(p_ptr->y, p_ptr->x, randint1(2) + 1, FALSE, FALSE, FALSE);
4548 reward = _("上質なアイテムを手に入れた。", "good items");
4553 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4554 msg_print(_("「下僕よ、汝の献身への我が惜しみ無き報いを見るがよい。」", "'Behold, mortal, how generously I reward thy loyalty.'"));
4556 acquirement(p_ptr->y, p_ptr->x, randint1(2) + 1, TRUE, FALSE, FALSE);
4557 reward = _("高級品のアイテムを手に入れた。", "excellent items");
4562 msg_format("%sの声が轟き渡った:", chaos_patrons[p_ptr->chaos_patron]);
4564 msg_format("The voice of %s thunders:", chaos_patrons[p_ptr->chaos_patron]);
4567 msg_print(_("「下僕よ、汝傲慢なり。」", "'Thou art growing arrogant, mortal.'"));
4569 (void)activate_ty_curse(FALSE, &count);
4570 reward = _("禍々しい呪いをかけられた。", "cursing");
4575 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4576 msg_print(_("「我が下僕たちよ、かの傲慢なる者を倒すべし!」", "'My pets, destroy the arrogant mortal!'"));
4578 for (dummy = 0; dummy < randint1(5) + 1; dummy++)
4580 (void)summon_specific(0, p_ptr->y, p_ptr->x, dun_level, 0, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET));
4582 reward = _("モンスターを召喚された。", "summoning hostile monsters");
4588 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4589 msg_print(_("「汝、より強き敵を必要とせり!」", "'Thou needst worthier opponents!'"));
4591 activate_hi_summon(p_ptr->y, p_ptr->x, FALSE);
4592 reward = _("モンスターを召喚された。", "summoning many hostile monsters");
4598 msg_format("%sの声が響き渡った:",
4599 chaos_patrons[p_ptr->chaos_patron]);
4601 msg_format("The voice of %s booms out:",
4602 chaos_patrons[p_ptr->chaos_patron]);
4605 msg_print(_("「死と破壊こそ我が喜びなり!」", "'Death and destruction! This pleaseth me!'"));
4608 reward = _("カオスの力が渦巻いた。", "calling chaos");
4614 msg_format("%sの声が鳴り響いた:",
4615 chaos_patrons[p_ptr->chaos_patron]);
4617 msg_format("The voice of %s rings out:",
4618 chaos_patrons[p_ptr->chaos_patron]);
4621 msg_print(_("「留まるのだ、下僕よ。余が汝の肉体を鍛えん。」", "'Stay, mortal, and let me mold thee.'"));
4623 if (one_in_(3) && !(chaos_stats[p_ptr->chaos_patron] < 0))
4624 do_inc_stat(chaos_stats[p_ptr->chaos_patron]);
4626 do_inc_stat(randint0(6));
4627 reward = _("能力値が上がった。", "increasing a stat");
4633 msg_format("%sの声が響き渡った:",
4634 chaos_patrons[p_ptr->chaos_patron]);
4636 msg_format("The voice of %s booms out:",
4637 chaos_patrons[p_ptr->chaos_patron]);
4640 msg_print(_("「下僕よ、余は汝に飽みたり。」", "'I grow tired of thee, mortal.'"));
4642 if (one_in_(3) && !(chaos_stats[p_ptr->chaos_patron] < 0))
4643 do_dec_stat(chaos_stats[p_ptr->chaos_patron]);
4645 (void)do_dec_stat(randint0(6));
4646 reward = _("能力値が下がった。", "decreasing a stat");
4653 msg_format("%sの声が轟き渡った:",
4654 chaos_patrons[p_ptr->chaos_patron]);
4656 msg_format("The voice of %s thunders:",
4657 chaos_patrons[p_ptr->chaos_patron]);
4660 msg_print(_("「汝、謙虚たることを学ぶべし!」", "'Thou needst a lesson in humility, mortal!'"));
4661 msg_print(_("あなたは以前より弱くなった!", "You feel less powerful!"));
4663 for (dummy = 0; dummy < 6; dummy++)
4665 (void)dec_stat(dummy, 10 + randint1(15), TRUE);
4667 reward = _("全能力値が下がった。", "decreasing all stats");
4672 msg_format(_("%sの力が触れるのを感じた。", "You feel the power of %s touch you."),
4673 chaos_patrons[p_ptr->chaos_patron]);
4675 reward = _("傷が変化した。", "polymorphing wounds");
4680 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4682 msg_print(_("「我がささやかなる賜物を受けとるがよい!」", "'Receive this modest gift from me!'"));
4684 for (dummy = 0; dummy < 6; dummy++)
4686 (void)do_inc_stat(dummy);
4688 reward = _("全能力値が上がった。", "increasing all stats");
4693 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4694 msg_print(_("「苦しむがよい、無能な愚か者よ!」", "'Suffer, pathetic fool!'"));
4696 fire_ball(GF_DISINTEGRATE, 0, p_ptr->lev * 4, 4);
4697 take_hit(DAMAGE_NOESCAPE, p_ptr->lev * 4, wrath_reason, -1);
4698 reward = _("分解の球が発生した。", "generating disintegration ball");
4703 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4704 (void)restore_level();
4705 (void)restore_all_status();
4706 (void)true_healing(5000);
4707 reward = _("体力が回復した。", "healing");
4712 if (!buki_motteruka(INVEN_RARM) && !buki_motteruka(INVEN_LARM)) break;
4713 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4714 msg_print(_("「汝、武器に頼ることなかれ。」", "'Thou reliest too much on thy weapon.'"));
4717 if (buki_motteruka(INVEN_LARM))
4720 if (buki_motteruka(INVEN_RARM) && one_in_(2)) dummy = INVEN_RARM;
4722 object_desc(o_name, &inventory[dummy], OD_NAME_ONLY);
4723 (void)curse_weapon(FALSE, dummy);
4724 reward = format(_("%sが破壊された。", "destroying %s"), o_name);
4729 if (!inventory[INVEN_BODY].k_idx) break;
4730 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4731 msg_print(_("「汝、防具に頼ることなかれ。」", "'Thou reliest too much on thine equipment.'"));
4733 object_desc(o_name, &inventory[INVEN_BODY], OD_NAME_ONLY);
4734 (void)curse_armor();
4735 reward = format(_("%sが破壊された。", "destroying %s"), o_name);
4739 msg_format(_("%sの声がささやいた:", "The voice of %s whispers:"), chaos_patrons[p_ptr->chaos_patron]);
4740 msg_print(_("「我を怒りしめた罪を償うべし。」", "'Now thou shalt pay for annoying me.'"));
4742 switch (randint1(4))
4745 (void)activate_ty_curse(FALSE, &count);
4746 reward = _("禍々しい呪いをかけられた。", "cursing");
4749 activate_hi_summon(p_ptr->y, p_ptr->x, FALSE);
4750 reward = _("モンスターを召喚された。", "summoning hostile monsters");
4755 if (!buki_motteruka(INVEN_RARM) && !buki_motteruka(INVEN_LARM)) break;
4757 if (buki_motteruka(INVEN_LARM))
4760 if (buki_motteruka(INVEN_RARM) && one_in_(2)) dummy = INVEN_RARM;
4762 object_desc(o_name, &inventory[dummy], OD_NAME_ONLY);
4763 (void)curse_weapon(FALSE, dummy);
4764 reward = format(_("%sが破壊された。", "destroying %s"), o_name);
4768 if (!inventory[INVEN_BODY].k_idx) break;
4769 object_desc(o_name, &inventory[INVEN_BODY], OD_NAME_ONLY);
4770 (void)curse_armor();
4771 reward = format(_("%sが破壊された。", "destroying %s"), o_name);
4775 for (dummy = 0; dummy < 6; dummy++)
4777 (void)dec_stat(dummy, 10 + randint1(15), TRUE);
4779 reward = _("全能力値が下がった。", "decreasing all stats");
4786 msg_format(_("%sの声が轟き渡った:", "The voice of %s thunders:"), chaos_patrons[p_ptr->chaos_patron]);
4787 msg_print(_("「死ぬがよい、下僕よ!」", "'Die, mortal!'"));
4789 take_hit(DAMAGE_LOSELIFE, p_ptr->lev * 4, wrath_reason, -1);
4790 for (dummy = 0; dummy < 6; dummy++)
4792 (void)dec_stat(dummy, 10 + randint1(15), FALSE);
4794 activate_hi_summon(p_ptr->y, p_ptr->x, FALSE);
4795 (void)activate_ty_curse(FALSE, &count);
4800 if (buki_motteruka(INVEN_RARM))
4803 if (buki_motteruka(INVEN_LARM) && one_in_(2)) dummy = INVEN_LARM;
4805 else if (buki_motteruka(INVEN_LARM)) dummy = INVEN_LARM;
4807 if (dummy) (void)curse_weapon(FALSE, dummy);
4809 if (one_in_(2)) (void)curse_armor();
4814 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4815 msg_print(_("「死と破壊こそ我が喜びなり!」", "'Death and destruction! This pleaseth me!'"));
4817 (void)destroy_area(p_ptr->y, p_ptr->x, 25, FALSE);
4818 reward = _("ダンジョンが*破壊*された。", "*destruct*ing dungeon");
4823 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4824 msg_print(_("「我、汝の敵を抹殺せん!」", "'Let me relieve thee of thine oppressors!'"));
4825 (void)symbol_genocide(0, FALSE);
4826 reward = _("モンスターが抹殺された。", "genociding monsters");
4831 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4832 msg_print(_("「我、汝の敵を抹殺せん!」", "'Let me relieve thee of thine oppressors!'"));
4834 (void)mass_genocide(0, FALSE);
4835 reward = _("モンスターが抹殺された。", "genociding nearby monsters");
4840 msg_format(_("%sの力が敵を攻撃するのを感じた!", "You can feel the power of %s assault your enemies!"), chaos_patrons[p_ptr->chaos_patron]);
4841 (void)dispel_monsters(p_ptr->lev * 4);
4846 msg_format(_("%sはあなたを無視した。", "%s ignores you."), chaos_patrons[p_ptr->chaos_patron]);
4851 msg_format(_("%sは褒美として悪魔の使いをよこした!", "%s rewards you with a demonic servant!"),chaos_patrons[p_ptr->chaos_patron]);
4853 if (!summon_specific(-1, p_ptr->y, p_ptr->x, dun_level, SUMMON_DEMON, PM_FORCE_PET))
4854 msg_print(_("何も現れなかった...", "Nobody ever turns up..."));
4856 reward = _("悪魔がペットになった。", "a demonic servant");
4861 msg_format(_("%sは褒美として使いをよこした!", "%s rewards you with a servant!"),chaos_patrons[p_ptr->chaos_patron]);
4863 if (!summon_specific(-1, p_ptr->y, p_ptr->x, dun_level, 0, PM_FORCE_PET))
4864 msg_print(_("何も現れなかった...", "Nobody ever turns up..."));
4866 reward = _("モンスターがペットになった。", "a servant");
4871 msg_format(_("%sは褒美としてアンデッドの使いをよこした。", "%s rewards you with an undead servant!"),chaos_patrons[p_ptr->chaos_patron]);
4873 if (!summon_specific(-1, p_ptr->y, p_ptr->x, dun_level, SUMMON_UNDEAD, PM_FORCE_PET))
4874 msg_print(_("何も現れなかった...", "Nobody ever turns up..."));
4876 reward = _("アンデッドがペットになった。", "an undead servant");
4881 msg_format(_("%sの声がどもった:", "The voice of %s stammers:"),
4883 chaos_patrons[p_ptr->chaos_patron]);
4884 msg_format(_("「あー、あー、答えは %d/%d。質問は何?」", "'Uh... uh... the answer's %d/%d, what's the question?'"), type, effect);
4890 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, format(_("パトロンの報酬で%s", "The patron rewards you with %s."), reward));
4896 * XAngband: determine if a given location is "interesting"
4897 * based on target_set_accept function.
4899 static bool tgt_pt_accept(POSITION y, POSITION x)
4904 if (!(in_bounds(y, x))) return (FALSE);
4906 /* Player grid is always interesting */
4907 if ((y == p_ptr->y) && (x == p_ptr->x)) return (TRUE);
4909 /* Handle hallucination */
4910 if (p_ptr->image) return (FALSE);
4912 /* Examine the grid */
4913 c_ptr = &cave[y][x];
4915 /* Interesting memorized features */
4916 if (c_ptr->info & (CAVE_MARK))
4919 if (cave_have_flag_grid(c_ptr, FF_LESS)) return (TRUE);
4920 if (cave_have_flag_grid(c_ptr, FF_MORE)) return (TRUE);
4922 /* Notice quest features */
4923 if (cave_have_flag_grid(c_ptr, FF_QUEST_ENTER)) return (TRUE);
4924 if (cave_have_flag_grid(c_ptr, FF_QUEST_EXIT)) return (TRUE);
4932 * XAngband: Prepare the "temp" array for "tget_pt"
4933 * based on target_set_prepare funciton.
4935 static void tgt_pt_prepare(void)
4939 /* Reset "temp" array */
4942 if (!expand_list) return;
4944 /* Scan the current panel */
4945 for (y = 1; y < cur_hgt; y++)
4947 for (x = 1; x < cur_wid; x++)
4949 /* Require "interesting" contents */
4950 if (!tgt_pt_accept(y, x)) continue;
4952 /* Save the location */
4959 /* Target the nearest monster for shooting */
4960 ang_sort_comp = ang_sort_comp_distance;
4961 ang_sort_swap = ang_sort_swap_distance;
4963 /* Sort the positions */
4964 ang_sort(temp_x, temp_y, temp_n);
4968 * old -- from PsiAngband.
4970 bool tgt_pt(POSITION *x_ptr, POSITION *y_ptr)
4975 bool success = FALSE;
4979 get_screen_size(&wid, &hgt);
4989 msg_print(_("場所を選んでスペースキーを押して下さい。", "Select a point and press space."));
4990 msg_flag = FALSE; /* prevents "-more-" message. */
4992 while ((ch != ESCAPE) && !success)
4994 bool move_fast = FALSE;
4996 move_cursor_relative(y, x);
5008 if (player_bold(y, x)) ch = 0;
5011 else success = TRUE;
5015 /* XAngband: Move cursor to stairs */
5018 if (expand_list && temp_n)
5021 int cx = (panel_col_min + panel_col_max) / 2;
5022 int cy = (panel_row_min + panel_row_max) / 2;
5026 /* Skip stairs which have defferent distance */
5027 for (; n < temp_n; ++ n)
5029 cave_type *c_ptr = &cave[temp_y[n]][temp_x[n]];
5031 if (cave_have_flag_grid(c_ptr, FF_STAIRS) &&
5032 cave_have_flag_grid(c_ptr, ch == '>' ? FF_MORE : FF_LESS))
5039 if (n == temp_n) /* Loop out taget list */
5044 verify_panel(); /* Move cursor to player */
5046 p_ptr->update |= (PU_MONSTERS);
5048 p_ptr->redraw |= (PR_MAP);
5050 p_ptr->window |= (PW_OVERHEAD);
5053 else /* move cursor to next stair and change panel */
5058 dy = 2 * (y - cy) / hgt;
5059 dx = 2 * (x - cx) / wid;
5060 if (dy || dx) change_panel(dy, dx);
5066 /* Look up the direction */
5067 d = get_keymap_dir(ch);
5069 /* XTRA HACK MOVEFAST */
5070 if (isupper(ch)) move_fast = TRUE;
5072 /* Handle "direction" */
5078 /* XTRA HACK MOVEFAST */
5081 int mag = MIN(wid / 2, hgt / 2);
5091 /* Do not move horizontally if unnecessary */
5092 if (((x < panel_col_min + wid / 2) && (dx > 0)) ||
5093 ((x > panel_col_min + wid / 2) && (dx < 0)))
5098 /* Do not move vertically if unnecessary */
5099 if (((y < panel_row_min + hgt / 2) && (dy > 0)) ||
5100 ((y > panel_row_min + hgt / 2) && (dy < 0)))
5105 /* Apply the motion */
5106 if ((y >= panel_row_min + hgt) || (y < panel_row_min) ||
5107 (x >= panel_col_min + wid) || (x < panel_col_min))
5109 /* if (change_panel(dy, dx)) target_set_prepare(mode); */
5110 change_panel(dy, dx);
5113 /* Slide into legality */
5114 if (x >= cur_wid-1) x = cur_wid - 2;
5115 else if (x <= 0) x = 1;
5117 /* Slide into legality */
5118 if (y >= cur_hgt-1) y = cur_hgt- 2;
5119 else if (y <= 0) y = 1;
5126 /* Clear the top line */
5129 /* Recenter the map around the player */
5132 p_ptr->update |= (PU_MONSTERS);
5134 p_ptr->redraw |= (PR_MAP);
5136 p_ptr->window |= (PW_OVERHEAD);
5145 bool get_hack_dir(DIRECTION *dp)
5153 /* Global direction */
5156 /* (No auto-targeting) */
5158 /* Ask until satisfied */
5161 /* Choose a prompt */
5164 p = _("方向 ('*'でターゲット選択, ESCで中断)? ", "Direction ('*' to choose a target, Escape to cancel)? ");
5168 p = _("方向 ('5'でターゲットへ, '*'でターゲット再選択, ESCで中断)? ", "Direction ('5' for target, '*' to re-target, Escape to cancel)? ");
5171 /* Get a command (or Cancel) */
5172 if (!get_com(p, &command, TRUE)) break;
5176 if (command == '\r') command = 't';
5179 /* Convert various keys to "standard" keys */
5182 /* Use current target */
5193 /* Set new target */
5198 if (target_set(TARGET_KILL)) dir = 5;
5204 /* Look up the direction */
5205 dir = get_keymap_dir(command);
5211 /* Verify requested targets */
5212 if ((dir == 5) && !target_okay()) dir = 0;
5219 if (!dir) return (FALSE);
5221 /* Save the direction */
5224 /* Check for confusion */
5225 if (p_ptr->confused)
5227 /* Random direction */
5228 dir = ddd[randint0(8)];
5231 /* Notice confusion */
5232 if (command_dir != dir)
5235 msg_print(_("あなたは混乱している。", "You are confused."));
5238 /* Save direction */
5241 /* A "valid" direction was entered */
5247 * エネルギーの増加量10d5を速く計算するための関数
5250 #define Go_no_JuuJou 5*5*5*5*5*5*5*5*5*5
5252 s16b gain_energy(void)
5255 s32b energy_result = 10;
5258 tmp = randint0(Go_no_JuuJou);
5260 for (i = 0; i < 9; i ++){
5261 energy_result += tmp % 5;
5265 return (s16b)(energy_result + tmp);
5270 * @brief 射撃武器の攻撃に必要な基本消費エネルギーを返す/Return bow energy
5271 * @param sval 射撃武器のアイテム副分類ID
5272 * @return 消費する基本エネルギー
5274 ENERGY bow_energy(OBJECT_SUBTYPE_VALUE sval)
5276 ENERGY energy = 10000;
5278 /* Analyze the launcher */
5281 /* Sling and ammo */
5288 /* Short Bow and Arrow */
5295 /* Long Bow and Arrow */
5302 /* Bow of irresponsiblity and Arrow */
5309 /* Light Crossbow and Bolt */
5316 /* Heavy Crossbow and Bolt */
5331 int bow_tmul(OBJECT_SUBTYPE_VALUE sval)
5335 /* Analyze the launcher */
5338 /* Sling and ammo */
5345 /* Short Bow and Arrow */
5352 /* Long Bow and Arrow */
5359 /* Bow of irresponsiblity and Arrow */
5366 /* Light Crossbow and Bolt */
5373 /* Heavy Crossbow and Bolt */
5385 * Return alignment title
5387 cptr your_alignment(void)
5390 if (p_ptr->align > 150) return "大善";
5391 else if (p_ptr->align > 50) return "中善";
5392 else if (p_ptr->align > 10) return "小善";
5393 else if (p_ptr->align > -11) return "中立";
5394 else if (p_ptr->align > -51) return "小悪";
5395 else if (p_ptr->align > -151) return "中悪";
5398 if (p_ptr->align > 150) return "Lawful";
5399 else if (p_ptr->align > 50) return "Good";
5400 else if (p_ptr->align > 10) return "Neutral Good";
5401 else if (p_ptr->align > -11) return "Neutral";
5402 else if (p_ptr->align > -51) return "Neutral Evil";
5403 else if (p_ptr->align > -151) return "Evil";
5404 else return "Chaotic";
5410 * Return proficiency level of weapons and misc. skills (except riding)
5412 int weapon_exp_level(int weapon_exp)
5414 if (weapon_exp < WEAPON_EXP_BEGINNER) return EXP_LEVEL_UNSKILLED;
5415 else if (weapon_exp < WEAPON_EXP_SKILLED) return EXP_LEVEL_BEGINNER;
5416 else if (weapon_exp < WEAPON_EXP_EXPERT) return EXP_LEVEL_SKILLED;
5417 else if (weapon_exp < WEAPON_EXP_MASTER) return EXP_LEVEL_EXPERT;
5418 else return EXP_LEVEL_MASTER;
5423 * Return proficiency level of riding
5425 int riding_exp_level(int riding_exp)
5427 if (riding_exp < RIDING_EXP_BEGINNER) return EXP_LEVEL_UNSKILLED;
5428 else if (riding_exp < RIDING_EXP_SKILLED) return EXP_LEVEL_BEGINNER;
5429 else if (riding_exp < RIDING_EXP_EXPERT) return EXP_LEVEL_SKILLED;
5430 else if (riding_exp < RIDING_EXP_MASTER) return EXP_LEVEL_EXPERT;
5431 else return EXP_LEVEL_MASTER;
5436 * Return proficiency level of spells
5438 int spell_exp_level(int spell_exp)
5440 if (spell_exp < SPELL_EXP_BEGINNER) return EXP_LEVEL_UNSKILLED;
5441 else if (spell_exp < SPELL_EXP_SKILLED) return EXP_LEVEL_BEGINNER;
5442 else if (spell_exp < SPELL_EXP_EXPERT) return EXP_LEVEL_SKILLED;
5443 else if (spell_exp < SPELL_EXP_MASTER) return EXP_LEVEL_EXPERT;
5444 else return EXP_LEVEL_MASTER;
5449 * Display a rumor and apply its effects
5452 IDX rumor_num(char *zz, IDX max_idx)
5454 if (strcmp(zz, "*") == 0) return randint1(max_idx - 1);
5455 return (IDX)atoi(zz);
5458 cptr rumor_bind_name(char *base, cptr fullname)
5462 s = strstr(base, "{Name}");
5466 v = format("%s%s%s", base, fullname, (s + 6));
5476 void display_rumor(bool ex)
5484 if (randint0(3) == 0) section = 1;
5487 err = _(get_rnd_line_jonly("rumors_j.txt", section, Rumor, 10),
5488 get_rnd_line("rumors.txt", section, Rumor));
5489 if (err) strcpy(Rumor, _("嘘の噂もある。", "Some rumors are wrong."));
5493 if (strncmp(Rumor, "R:", 2) == 0)
5496 cptr rumor_msg = NULL;
5497 cptr rumor_eff_format = NULL;
5498 char fullname[1024] = "";
5500 if (tokenize(Rumor + 2, 3, zz, TOKENIZE_CHECKQUOTE) == 3)
5502 if (strcmp(zz[0], "ARTIFACT") == 0)
5506 object_type *q_ptr = &forge;
5507 artifact_type *a_ptr;
5511 a_idx = rumor_num(zz[1], max_a_idx);
5513 a_ptr = &a_info[a_idx];
5514 if (a_ptr->name) break;
5517 k_idx = lookup_kind(a_ptr->tval, a_ptr->sval);
5518 object_prep(q_ptr, k_idx);
5519 q_ptr->name1 = a_idx;
5520 q_ptr->ident = IDENT_STORE;
5521 object_desc(fullname, q_ptr, OD_NAME_ONLY);
5523 else if (strcmp(zz[0], "MONSTER") == 0)
5526 monster_race *r_ptr;
5530 r_idx = rumor_num(zz[1], max_r_idx);
5531 r_ptr = &r_info[r_idx];
5532 if (r_ptr->name) break;
5535 strcpy(fullname, r_name + r_ptr->name);
5537 /* Remember this monster */
5538 if (!r_ptr->r_sights)
5543 else if (strcmp(zz[0], "DUNGEON") == 0)
5546 dungeon_info_type *d_ptr;
5550 d_idx = rumor_num(zz[1], max_d_idx);
5551 d_ptr = &d_info[d_idx];
5552 if (d_ptr->name) break;
5555 strcpy(fullname, d_name + d_ptr->name);
5557 if (!max_dlv[d_idx])
5559 max_dlv[d_idx] = d_ptr->mindepth;
5560 rumor_eff_format = _("%sに帰還できるようになった。", "You can recall to %s.");
5563 else if (strcmp(zz[0], "TOWN") == 0)
5570 t_idx = rumor_num(zz[1], NO_TOWN);
5571 if (town[t_idx].name) break;
5574 strcpy(fullname, town[t_idx].name);
5576 visit = (1L << (t_idx - 1));
5577 if ((t_idx != SECRET_TOWN) && !(p_ptr->visit & visit))
5579 p_ptr->visit |= visit;
5580 rumor_eff_format = _("%sに行ったことがある気がする。", "You feel you have been to %s.");
5584 rumor_msg = rumor_bind_name(zz[2], fullname);
5585 msg_print(rumor_msg);
5586 if (rumor_eff_format)
5589 msg_format(rumor_eff_format, fullname);
5594 if (err) msg_print(_("この情報は間違っている。", "This information is wrong."));
5598 msg_format("%s", Rumor);