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);
2955 /* Hack -- handle stuff */
2969 /* Recall on screen */
2970 screen_roff(m_ptr->ap_r_idx, 0);
2972 /* Hack -- Complete the prompt (again) */
2973 Term_addstr(-1, TERM_WHITE, format(_(" [r思 %s%s]", " [r,%s%s]"), x_info, info));
2981 /* Normal commands */
2982 if (query != 'r') break;
2987 /* Cleare recall text and repeat */
2993 /* Describe, and prompt for recall */
2994 evaluate_monster_exp(acount, m_ptr);
2997 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);
2999 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);
3005 move_cursor_relative(y, x);
3010 /* Normal commands */
3011 if (query != 'r') break;
3017 /* Always stop at "normal" keys */
3018 if ((query != '\r') && (query != '\n') && (query != ' ') && (query != 'x')) return query;
3020 /* Sometimes stop at "space" key */
3021 if ((query == ' ') && !(mode & (TARGET_LOOK))) return query;
3023 /* Change the intro */
3024 s1 = _("それは", "It is ");
3026 /* Hack -- take account of gender */
3027 if (ap_r_ptr->flags1 & (RF1_FEMALE)) s1 = _("彼女は", "She is ");
3028 else if (ap_r_ptr->flags1 & (RF1_MALE)) s1 = _("彼は", "He is ");
3030 /* Use a preposition */
3039 /* Scan all objects being carried */
3040 for (this_o_idx = m_ptr->hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
3042 char o_name[MAX_NLEN];
3045 o_ptr = &o_list[this_o_idx];
3047 /* Acquire next object */
3048 next_o_idx = o_ptr->next_o_idx;
3050 /* Obtain an object description */
3051 object_desc(o_name, o_ptr, 0);
3054 sprintf(out_val, "%s%s%s%s[%s]", s1, o_name, s2, s3, info);
3056 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, o_name, info);
3060 move_cursor_relative(y, x);
3063 /* Always stop at "normal" keys */
3064 if ((query != '\r') && (query != '\n') && (query != ' ') && (query != 'x')) return query;
3066 /* Sometimes stop at "space" key */
3067 if ((query == ' ') && !(mode & (TARGET_LOOK))) return query;
3069 /* Change the intro */
3070 s2 = _("をまた", "also carrying ");
3073 /* Use a preposition */
3090 char o_name[MAX_NLEN];
3093 o_ptr = &o_list[floor_list[0]];
3095 object_desc(o_name, o_ptr, 0);
3098 sprintf(out_val, "%s%s%s%s[%s]", s1, o_name, s2, s3, info);
3100 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, o_name, info);
3104 move_cursor_relative(y, x);
3113 /* Provide one cushion before item listing */
3116 /* Display rough information about items */
3118 sprintf(out_val, "%s %d個のアイテム%s%s ['x'で一覧, %s]", s1, (int)floor_num, s2, s3, info);
3120 sprintf(out_val, "%s%s%sa pile of %d items [x,%s]", s1, s2, s3, (int)floor_num, info);
3124 move_cursor_relative(y, x);
3129 /* No request for listing */
3130 if (query != 'x' && query != ' ') return query;
3134 /** Display list of items **/
3136 /* Continue scrolling list if requested */
3144 show_gold_on_floor = TRUE;
3145 (void)show_floor(0, y, x, &min_width);
3146 show_gold_on_floor = FALSE;
3150 sprintf(out_val, "%s %d個のアイテム%s%s [Enterで次へ, %s]", s1, (int)floor_num, s2, s3, info);
3152 sprintf(out_val, "%s%s%sa pile of %d items [Enter,%s]", s1, s2, s3, (int)floor_num, info);
3159 /* Exit unless 'Enter' */
3160 if (query != '\n' && query != '\r')
3165 /* Get the object being moved. */
3166 o_idx = c_ptr->o_idx;
3168 /* Only rotate a pile of two or more objects. */
3169 if (!(o_idx && o_list[o_idx].next_o_idx)) continue;
3171 /* Remove the first object from the list. */
3172 excise_object_idx(o_idx);
3174 /* Find end of the list. */
3176 while (o_list[i].next_o_idx)
3177 i = o_list[i].next_o_idx;
3179 /* Add after the last object. */
3180 o_list[i].next_o_idx = o_idx;
3182 /* Loop and re-display the list */
3189 /* Scan all objects in the grid */
3190 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
3193 o_ptr = &o_list[this_o_idx];
3195 /* Acquire next object */
3196 next_o_idx = o_ptr->next_o_idx;
3199 if (o_ptr->marked & OM_FOUND)
3201 char o_name[MAX_NLEN];
3206 /* Obtain an object description */
3207 object_desc(o_name, o_ptr, 0);
3210 sprintf(out_val, "%s%s%s%s[%s]", s1, o_name, s2, s3, info);
3212 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, o_name, info);
3216 move_cursor_relative(y, x);
3219 /* Always stop at "normal" keys */
3220 if ((query != '\r') && (query != '\n') && (query != ' ') && (query != 'x')) return query;
3222 /* Sometimes stop at "space" key */
3223 if ((query == ' ') && !(mode & TARGET_LOOK)) return query;
3225 /* Change the intro */
3226 s1 = _("それは", "It is ");
3229 if (o_ptr->number != 1) s1 = _("それらは", "They are ");
3243 /* Feature code (applying "mimic" field) */
3244 feat = get_feat_mimic(c_ptr);
3246 /* Require knowledge about grid, or ability to see grid */
3247 if (!(c_ptr->info & CAVE_MARK) && !player_can_see_bold(y, x))
3249 /* Forget feature */
3253 f_ptr = &f_info[feat];
3255 /* Terrain feature if needed */
3256 if (boring || have_flag(f_ptr->flags, FF_REMEMBER))
3260 /* Hack -- special handling for quest entrances */
3261 if (have_flag(f_ptr->flags, FF_QUEST_ENTER))
3263 /* Set the quest number temporary */
3264 IDX old_quest = p_ptr->inside_quest;
3267 /* Clear the text */
3268 for (j = 0; j < 10; j++) quest_text[j][0] = '\0';
3269 quest_text_line = 0;
3271 p_ptr->inside_quest = c_ptr->special;
3273 /* Get the quest text */
3274 init_flags = INIT_NAME_ONLY;
3276 process_dungeon_file("q_info.txt", 0, 0, 0, 0);
3278 name = format(_("クエスト「%s」(%d階相当)", "the entrance to the quest '%s'(level %d)"),
3279 quest[c_ptr->special].name, quest[c_ptr->special].level);
3281 /* Reset the old quest number */
3282 p_ptr->inside_quest = old_quest;
3285 /* Hack -- special handling for building doors */
3286 else if (have_flag(f_ptr->flags, FF_BLDG) && !p_ptr->inside_arena)
3288 name = building[f_ptr->subtype].name;
3290 else if (have_flag(f_ptr->flags, FF_ENTRANCE))
3292 name = format(_("%s(%d階相当)", "%s(level %d)"), d_text + d_info[c_ptr->special].text, d_info[c_ptr->special].mindepth);
3294 else if (have_flag(f_ptr->flags, FF_TOWN))
3296 name = town[c_ptr->special].name;
3298 else if (p_ptr->wild_mode && (feat == feat_floor))
3300 name = _("道", "road");
3304 name = f_name + f_ptr->name;
3310 ((!have_flag(f_ptr->flags, FF_MOVE) && !have_flag(f_ptr->flags, FF_CAN_FLY)) ||
3311 (!have_flag(f_ptr->flags, FF_LOS) && !have_flag(f_ptr->flags, FF_TREE)) ||
3312 have_flag(f_ptr->flags, FF_TOWN)))
3314 s2 = _("の中", "in ");
3317 /* Hack -- special introduction for store & building doors -KMW- */
3318 if (have_flag(f_ptr->flags, FF_STORE) ||
3319 have_flag(f_ptr->flags, FF_QUEST_ENTER) ||
3320 (have_flag(f_ptr->flags, FF_BLDG) && !p_ptr->inside_arena) ||
3321 have_flag(f_ptr->flags, FF_ENTRANCE))
3330 else if (have_flag(f_ptr->flags, FF_FLOOR) ||
3331 have_flag(f_ptr->flags, FF_TOWN) ||
3332 have_flag(f_ptr->flags, FF_SHALLOW) ||
3333 have_flag(f_ptr->flags, FF_DEEP))
3339 /* Pick proper indefinite article */
3340 s3 = (is_a_vowel(name[0])) ? "an " : "a ";
3344 /* Display a message */
3348 if (c_ptr->mimic) sprintf(f_idx_str, "%d/%d", c_ptr->feat, c_ptr->mimic);
3349 else sprintf(f_idx_str, "%d", c_ptr->feat);
3351 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]);
3353 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);
3358 sprintf(out_val, "%s%s%s%s[%s]", s1, name, s2, s3, info);
3360 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, name, info);
3364 move_cursor_relative(y, x);
3367 /* Always stop at "normal" keys */
3368 if ((query != '\r') && (query != '\n') && (query != ' ')) return query;
3371 /* Stop on everything but "return" */
3372 if ((query != '\r') && (query != '\n')) return query;
3374 /* Repeat forever */
3380 * Handle "target" and "look".
3382 * Note that this code can be called from "get_aim_dir()".
3384 * All locations must be on the current panel. Consider the use of
3385 * "panel_bounds()" to allow "off-panel" targets, perhaps by using
3386 * some form of "scrolling" the map around the cursor.
3387 * That is, consider the possibility of "auto-scrolling" the screen
3388 * while the cursor moves around. This may require changes in the
3389 * "update_monster()" code to allow "visibility" even if off panel, and
3390 * may require dynamic recalculation of the "temp" grid set.
3392 * Hack -- targeting/observing an "outer border grid" may induce
3393 * problems, so this is not currently allowed.
3395 * The player can use the direction keys to move among "interesting"
3396 * grids in a heuristic manner, or the "space", "+", and "-" keys to
3397 * move through the "interesting" grids in a sequential manner, or
3398 * can enter "location" mode, and use the direction keys to move one
3399 * grid at a time in any direction. The "t" (set target) command will
3400 * only target a monster (as opposed to a location) if the monster is
3401 * target_able and the "interesting" mode is being used.
3403 * The current grid is described using the "look" method above, and
3404 * a new command may be entered at any time, but note that if the
3405 * "TARGET_LOOK" bit flag is set (or if we are in "location" mode,
3406 * where "space" has no obvious meaning) then "space" will scan
3407 * through the description of the current grid until done, instead
3408 * of immediately jumping to the next "interesting" grid. This
3409 * allows the "target" command to retain its old semantics.
3411 * The "*", "+", and "-" keys may always be used to jump immediately
3412 * to the next (or previous) interesting grid, in the proper mode.
3414 * The "return" key may always be used to scan through a complete
3415 * grid description (forever).
3417 * This command will cancel any old target, even if used from
3418 * inside the "look" command.
3420 bool target_set(BIT_FLAGS mode)
3423 POSITION y = p_ptr->y;
3424 POSITION x = p_ptr->x;
3436 get_screen_size(&wid, &hgt);
3442 /* Cancel tracking */
3443 /* health_track(0); */
3445 if (rogue_like_commands)
3454 /* Prepare the "temp" array */
3455 target_set_prepare(mode);
3457 /* Start near the player */
3463 /* Interesting grids */
3470 change_panel_xy(y, x);
3472 if (!(mode & TARGET_LOOK)) prt_path(y, x);
3475 c_ptr = &cave[y][x];
3478 if (target_able(c_ptr->m_idx))
3480 strcpy(info, _("q止 t決 p自 o現 +次 -前", "q,t,p,o,+,-,<dir>"));
3483 /* Dis-allow target */
3486 strcpy(info, _("q止 p自 o現 +次 -前", "q,p,o,+,-,<dir>"));
3492 sprintf(cheatinfo, " LOS:%d, PROJECTABLE:%d",
3493 los(p_ptr->y, p_ptr->x, y, x),
3494 projectable(p_ptr->y, p_ptr->x, y, x));
3495 strcat(info, cheatinfo);
3498 /* Describe and Prompt */
3500 query = target_set_aux(y, x, mode, info);
3504 /* Cancel tracking */
3505 /* health_track(0); */
3507 /* Assume no "direction" */
3512 if (query == '\r') query = 't';
3530 if (target_able(c_ptr->m_idx))
3532 health_track(c_ptr->m_idx);
3533 target_who = c_ptr->m_idx;
3552 if (!expand_list) done = TRUE;
3562 if (!expand_list) done = TRUE;
3569 /* Recenter the map around the player */
3572 p_ptr->update |= (PU_MONSTERS);
3574 p_ptr->redraw |= (PR_MAP);
3576 p_ptr->window |= (PW_OVERHEAD);
3579 /* Recalculate interesting grids */
3580 target_set_prepare(mode);
3599 if(query == same_key)
3604 if (!expand_list) done = TRUE;
3609 /* Extract the action (if any) */
3610 d = get_keymap_dir(query);
3617 /* Hack -- move around */
3620 /* Modified to scroll to monster */
3621 POSITION y2 = panel_row_min;
3622 POSITION x2 = panel_col_min;
3624 /* Find a new monster */
3625 i = target_pick(temp_y[m], temp_x[m], ddy[d], ddx[d]);
3627 /* Request to target past last interesting grid */
3628 while (flag && (i < 0))
3630 /* Note the change */
3631 if (change_panel(ddy[d], ddx[d]))
3636 /* Recalculate interesting grids */
3637 target_set_prepare(mode);
3639 /* Look at interesting grids */
3642 /* Find a new monster */
3643 i = target_pick(v, u, ddy[d], ddx[d]);
3649 /* Nothing interesting */
3655 /* Restore previous position */
3658 panel_bounds_center();
3660 p_ptr->update |= (PU_MONSTERS);
3662 p_ptr->redraw |= (PR_MAP);
3664 p_ptr->window |= (PW_OVERHEAD);
3667 /* Recalculate interesting grids */
3668 target_set_prepare(mode);
3670 /* Look at boring grids */
3677 /* Do not move horizontally if unnecessary */
3678 if (((x < panel_col_min + wid / 2) && (dx > 0)) ||
3679 ((x > panel_col_min + wid / 2) && (dx < 0)))
3684 /* Do not move vertically if unnecessary */
3685 if (((y < panel_row_min + hgt / 2) && (dy > 0)) ||
3686 ((y > panel_row_min + hgt / 2) && (dy < 0)))
3691 /* Apply the motion */
3692 if ((y >= panel_row_min+hgt) || (y < panel_row_min) ||
3693 (x >= panel_col_min+wid) || (x < panel_col_min))
3695 if (change_panel(dy, dx)) target_set_prepare(mode);
3698 /* Slide into legality */
3699 if (x >= cur_wid-1) x = cur_wid - 2;
3700 else if (x <= 0) x = 1;
3702 /* Slide into legality */
3703 if (y >= cur_hgt-1) y = cur_hgt- 2;
3704 else if (y <= 0) y = 1;
3713 /* Arbitrary grids */
3716 bool move_fast = FALSE;
3718 if (!(mode & TARGET_LOOK)) prt_path(y, x);
3721 c_ptr = &cave[y][x];
3723 /* Default prompt */
3724 strcpy(info, _("q止 t決 p自 m近 +次 -前", "q,t,p,m,+,-,<dir>"));
3729 sprintf(cheatinfo, " LOS:%d, PROJECTABLE:%d",
3730 los(p_ptr->y, p_ptr->x, y, x),
3731 projectable(p_ptr->y, p_ptr->x, y, x));
3732 strcat(info, cheatinfo);
3735 /* Describe and Prompt (enable "TARGET_LOOK") */
3736 while ((query = target_set_aux(y, x, mode | TARGET_LOOK, info)) == 0);
3738 /* Cancel tracking */
3739 /* health_track(0); */
3741 /* Assume no direction */
3746 if (query == '\r') query = 't';
3749 /* Analyze the keypress */
3773 /* Recenter the map around the player */
3776 p_ptr->update |= (PU_MONSTERS);
3778 p_ptr->redraw |= (PR_MAP);
3780 p_ptr->window |= (PW_OVERHEAD);
3783 /* Recalculate interesting grids */
3784 target_set_prepare(mode);
3806 /* Pick a nearby monster */
3807 for (i = 0; i < temp_n; i++)
3809 t = distance(y, x, temp_y[i], temp_x[i]);
3819 /* Nothing interesting */
3820 if (bd == 999) flag = FALSE;
3827 /* Extract the action (if any) */
3828 d = get_keymap_dir(query);
3830 /* XTRA HACK MOVEFAST */
3831 if (isupper(query)) move_fast = TRUE;
3838 /* Handle "direction" */
3844 /* XTRA HACK MOVEFAST */
3847 int mag = MIN(wid / 2, hgt / 2);
3857 /* Do not move horizontally if unnecessary */
3858 if (((x < panel_col_min + wid / 2) && (dx > 0)) ||
3859 ((x > panel_col_min + wid / 2) && (dx < 0)))
3864 /* Do not move vertically if unnecessary */
3865 if (((y < panel_row_min + hgt / 2) && (dy > 0)) ||
3866 ((y > panel_row_min + hgt / 2) && (dy < 0)))
3871 /* Apply the motion */
3872 if ((y >= panel_row_min + hgt) || (y < panel_row_min) ||
3873 (x >= panel_col_min + wid) || (x < panel_col_min))
3875 if (change_panel(dy, dx)) target_set_prepare(mode);
3878 /* Slide into legality */
3879 if (x >= cur_wid-1) x = cur_wid - 2;
3880 else if (x <= 0) x = 1;
3882 /* Slide into legality */
3883 if (y >= cur_hgt-1) y = cur_hgt- 2;
3884 else if (y <= 0) y = 1;
3892 /* Clear the top line */
3895 /* Recenter the map around the player */
3898 p_ptr->update |= (PU_MONSTERS);
3900 p_ptr->redraw |= (PR_MAP);
3902 p_ptr->window |= (PW_OVERHEAD);
3905 /* Failure to set target */
3906 if (!target_who) return (FALSE);
3914 * Get an "aiming direction" from the user.
3916 * The "dir" is loaded with 1,2,3,4,6,7,8,9 for "actual direction", and
3917 * "0" for "current target", and "-1" for "entry aborted".
3919 * Note that "Force Target", if set, will pre-empt user interaction,
3920 * if there is a usable target already set.
3922 * Note that confusion over-rides any (explicit?) user choice.
3924 bool get_aim_dir(DIRECTION *dp)
3933 /* Global direction */
3936 /* Hack -- auto-target if requested */
3937 if (use_old_target && target_okay()) dir = 5;
3939 if (repeat_pull(&code))
3944 if (!(code == 5 && !target_okay()))
3946 /* return (TRUE); */
3947 dir = (DIRECTION)code;
3950 *dp = (DIRECTION)code;
3952 /* Ask until satisfied */
3955 /* Choose a prompt */
3958 p = _("方向 ('*'でターゲット選択, ESCで中断)? ", "Direction ('*' to choose a target, Escape to cancel)? ");
3962 p = _("方向 ('5'でターゲットへ, '*'でターゲット再選択, ESCで中断)? ", "Direction ('5' for target, '*' to re-target, Escape to cancel)? ");
3965 /* Get a command (or Cancel) */
3966 if (!get_com(p, &command, TRUE)) break;
3970 if (command == '\r') command = 't';
3973 /* Convert various keys to "standard" keys */
3976 /* Use current target */
3987 /* Set new target */
3992 if (target_set(TARGET_KILL)) dir = 5;
3998 /* Extract the action (if any) */
3999 dir = get_keymap_dir(command);
4005 /* Verify requested targets */
4006 if ((dir == 5) && !target_okay()) dir = 0;
4015 project_length = 0; /* reset to default */
4019 /* Save the direction */
4022 /* Check for confusion */
4023 if (p_ptr->confused)
4025 /* Random direction */
4026 dir = ddd[randint0(8)];
4029 /* Notice confusion */
4030 if (command_dir != dir)
4033 msg_print(_("あなたは混乱している。", "You are confused."));
4036 /* Save direction */
4039 /* repeat_push(dir); */
4040 repeat_push((COMMAND_CODE)command_dir);
4042 /* A "valid" direction was entered */
4047 bool get_direction(DIRECTION *dp, bool allow_under, bool with_steed)
4055 /* Global direction */
4058 if (repeat_pull(&code))
4060 dir = (DIRECTION)code;
4061 /* return (TRUE); */
4063 *dp = (DIRECTION)code;
4067 prompt = _("方向 ('.'足元, ESCで中断)? ", "Direction ('.' at feet, Escape to cancel)? ");
4071 prompt = _("方向 (ESCで中断)? ", "Direction (Escape to cancel)? ");
4074 /* Get a direction */
4079 /* Get a command (or Cancel) */
4080 if (!get_com(prompt, &ch, TRUE)) break;
4083 if ((allow_under) && ((ch == '5') || (ch == '-') || (ch == '.')))
4089 /* Look up the direction */
4090 dir = get_keymap_dir(ch);
4096 /* Prevent weirdness */
4097 if ((dir == 5) && (!allow_under)) dir = 0;
4100 if (!dir) return (FALSE);
4102 /* Save desired direction */
4105 /* Apply "confusion" */
4106 if (p_ptr->confused)
4108 /* Standard confusion */
4109 if (randint0(100) < 75)
4111 /* Random direction */
4112 dir = ddd[randint0(8)];
4115 else if (p_ptr->riding && with_steed)
4117 monster_type *m_ptr = &m_list[p_ptr->riding];
4118 monster_race *r_ptr = &r_info[m_ptr->r_idx];
4120 if (MON_CONFUSED(m_ptr))
4122 /* Standard confusion */
4123 if (randint0(100) < 75)
4125 /* Random direction */
4126 dir = ddd[randint0(8)];
4129 else if ((r_ptr->flags1 & RF1_RAND_50) && (r_ptr->flags1 & RF1_RAND_25) && (randint0(100) < 50))
4131 /* Random direction */
4132 dir = ddd[randint0(8)];
4134 else if ((r_ptr->flags1 & RF1_RAND_50) && (randint0(100) < 25))
4136 /* Random direction */
4137 dir = ddd[randint0(8)];
4141 /* Notice confusion */
4142 if (command_dir != dir)
4144 if (p_ptr->confused)
4147 msg_print(_("あなたは混乱している。", "You are confused."));
4152 monster_type *m_ptr = &m_list[p_ptr->riding];
4154 monster_desc(m_name, m_ptr, 0);
4155 if (MON_CONFUSED(m_ptr))
4157 msg_format(_("%sは混乱している。", "%^s is confusing."), m_name);
4161 msg_format(_("%sは思い通りに動いてくれない。", "You cannot control %s."), m_name);
4166 /* Save direction */
4169 /* repeat_push(dir); */
4170 repeat_push((COMMAND_CODE)command_dir);
4177 * @brief 進行方向を指定する(騎乗対象の混乱の影響を受ける) / Request a "movement" direction (1,2,3,4,6,7,8,9) from the user,
4178 * and place it into "command_dir", unless we already have one.
4180 * This function should be used for all "repeatable" commands, such as
4181 * run, walk, open, close, bash, disarm, spike, tunnel, etc, as well
4182 * as all commands which must reference a grid adjacent to the player,
4183 * and which may not reference the grid under the player. Note that,
4184 * for example, it is no longer possible to "disarm" or "open" chests
4185 * in the same grid as the player.
4187 * Direction "5" is illegal and will (cleanly) abort the command.
4189 * This function tracks and uses the "global direction", and uses
4190 * that as the "desired direction", to which "confusion" is applied.
4192 bool get_rep_dir(DIRECTION *dp, bool under)
4200 /* Global direction */
4203 if (repeat_pull(&code))
4205 dir = (DIRECTION)code;
4206 /* return (TRUE); */
4208 *dp = (DIRECTION)code;
4212 prompt = _("方向 ('.'足元, ESCで中断)? ", "Direction ('.' at feet, Escape to cancel)? ");
4216 prompt = _("方向 (ESCで中断)? ", "Direction (Escape to cancel)? ");
4219 /* Get a direction */
4224 /* Get a command (or Cancel) */
4225 if (!get_com(prompt, &ch, TRUE)) break;
4228 if ((under) && ((ch == '5') || (ch == '-') || (ch == '.')))
4234 /* Look up the direction */
4235 dir = get_keymap_dir(ch);
4241 /* Prevent weirdness */
4242 if ((dir == 5) && (!under)) dir = 0;
4245 if (!dir) return (FALSE);
4247 /* Save desired direction */
4250 /* Apply "confusion" */
4251 if (p_ptr->confused)
4253 /* Standard confusion */
4254 if (randint0(100) < 75)
4256 /* Random direction */
4257 dir = ddd[randint0(8)];
4260 else if (p_ptr->riding)
4262 monster_type *m_ptr = &m_list[p_ptr->riding];
4263 monster_race *r_ptr = &r_info[m_ptr->r_idx];
4265 if (MON_CONFUSED(m_ptr))
4267 /* Standard confusion */
4268 if (randint0(100) < 75)
4270 /* Random direction */
4271 dir = ddd[randint0(8)];
4274 else if ((r_ptr->flags1 & RF1_RAND_50) && (r_ptr->flags1 & RF1_RAND_25) && (randint0(100) < 50))
4276 /* Random direction */
4277 dir = ddd[randint0(8)];
4279 else if ((r_ptr->flags1 & RF1_RAND_50) && (randint0(100) < 25))
4281 /* Random direction */
4282 dir = ddd[randint0(8)];
4286 /* Notice confusion */
4287 if (command_dir != dir)
4289 if (p_ptr->confused)
4292 msg_print(_("あなたは混乱している。", "You are confused."));
4297 monster_type *m_ptr = &m_list[p_ptr->riding];
4299 monster_desc(m_name, m_ptr, 0);
4300 if (MON_CONFUSED(m_ptr))
4302 msg_format(_("%sは混乱している。", "%^s is confusing."), m_name);
4306 msg_format(_("%sは思い通りに動いてくれない。", "You cannot control %s."), m_name);
4311 /* Save direction */
4314 /* repeat_push(dir); */
4315 repeat_push((COMMAND_CODE)command_dir);
4321 void gain_level_reward(int chosen_reward)
4325 char wrath_reason[32] = "";
4326 int nasty_chance = 6;
4327 OBJECT_TYPE_VALUE dummy = 0;
4328 OBJECT_SUBTYPE_VALUE dummy2 = 0;
4331 char o_name[MAX_NLEN];
4337 if (multi_rew) return;
4338 else multi_rew = TRUE;
4342 if (p_ptr->lev == 13) nasty_chance = 2;
4343 else if (!(p_ptr->lev % 13)) nasty_chance = 3;
4344 else if (!(p_ptr->lev % 14)) nasty_chance = 12;
4346 if (one_in_(nasty_chance))
4347 type = randint1(20); /* Allow the 'nasty' effects */
4349 type = randint1(15) + 5; /* Or disallow them */
4351 if (type < 1) type = 1;
4352 if (type > 20) type = 20;
4356 sprintf(wrath_reason, _("%sの怒り", "the Wrath of %s"), chaos_patrons[p_ptr->chaos_patron]);
4358 effect = chaos_rewards[p_ptr->chaos_patron][type];
4360 if (one_in_(6) && !chosen_reward)
4362 msg_format(_("%^sは褒美としてあなたを突然変異させた。", "%^s rewards you with a mutation!"), chaos_patrons[p_ptr->chaos_patron]);
4363 (void)gain_random_mutation(0);
4364 reward = _("変異した。", "mutation");
4368 switch (chosen_reward ? chosen_reward : effect)
4373 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4374 msg_print(_("「汝、新たなる姿を必要とせり!」", "'Thou needst a new form, mortal!'"));
4377 reward = _("変異した。", "polymorphing");
4382 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4383 msg_print(_("「汝は良く行いたり!続けよ!」", "'Well done, mortal! Lead on!'"));
4385 if (p_ptr->prace == RACE_ANDROID)
4387 msg_print(_("しかし何も起こらなかった。", "But, nothing happen."));
4389 else if (p_ptr->exp < PY_MAX_EXP)
4391 s32b ee = (p_ptr->exp / 2) + 10;
4392 if (ee > 100000L) ee = 100000L;
4393 msg_print(_("更に経験を積んだような気がする。", "You feel more experienced."));
4396 reward = _("経験値を得た", "experience");
4402 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4403 msg_print(_("「下僕よ、汝それに値せず。」", "'Thou didst not deserve that, slave.'"));
4405 if (p_ptr->prace == RACE_ANDROID)
4407 msg_print(_("しかし何も起こらなかった。", "But, nothing happen."));
4411 lose_exp(p_ptr->exp / 6);
4412 reward = _("経験値を失った。", "losing experience");
4418 msg_format("%sの声がささやいた:",
4419 chaos_patrons[p_ptr->chaos_patron]);
4421 msg_format("The voice of %s whispers:",
4422 chaos_patrons[p_ptr->chaos_patron]);
4425 msg_print(_("「我が与えし物を賢明に使うべし。」", "'Use my gift wisely.'"));
4427 acquirement(p_ptr->y, p_ptr->x, 1, FALSE, FALSE, FALSE);
4428 reward = _("上質なアイテムを手に入れた。", "a good item");
4433 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4434 msg_print(_("「我が与えし物を賢明に使うべし。」", "'Use my gift wisely.'"));
4436 acquirement(p_ptr->y, p_ptr->x, 1, TRUE, FALSE, FALSE);
4437 reward = _("高級品のアイテムを手に入れた。", "an excellent item");
4442 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4443 msg_print(_("「汝の行いは貴き剣に値せり。」", "'Thy deed hath earned thee a worthy blade.'"));
4446 switch (randint1(p_ptr->lev))
4452 dummy2 = SV_MAIN_GAUCHE;
4461 dummy2 = SV_SMALL_SWORD;
4464 dummy2 = SV_BASILLARD;
4466 case 11: case 12: case 13:
4467 dummy2 = SV_SHORT_SWORD;
4473 dummy2 = SV_CUTLASS;
4476 dummy2 = SV_WAKIZASHI;
4479 dummy2 = SV_KHOPESH;
4485 dummy2 = SV_BROAD_SWORD;
4488 dummy2 = SV_LONG_SWORD;
4491 dummy2 = SV_SCIMITAR;
4494 dummy2 = SV_NINJATO;
4500 dummy2 = SV_BASTARD_SWORD;
4503 dummy2 = SV_GREAT_SCIMITAR;
4506 dummy2 = SV_CLAYMORE;
4509 dummy2 = SV_ESPADON;
4512 dummy2 = SV_TWO_HANDED_SWORD;
4515 dummy2 = SV_FLAMBERGE;
4518 dummy2 = SV_NO_DACHI;
4521 dummy2 = SV_EXECUTIONERS_SWORD;
4524 dummy2 = SV_ZWEIHANDER;
4527 dummy2 = SV_HAYABUSA;
4530 dummy2 = SV_BLADE_OF_CHAOS;
4533 object_prep(q_ptr, lookup_kind(dummy, dummy2));
4534 q_ptr->to_h = 3 + randint1(dun_level) % 10;
4535 q_ptr->to_d = 3 + randint1(dun_level) % 10;
4536 one_resistance(q_ptr);
4537 q_ptr->name2 = EGO_CHAOTIC;
4539 /* Drop it in the dungeon */
4540 (void)drop_near(q_ptr, -1, p_ptr->y, p_ptr->x);
4541 reward = _("(混沌)の武器を手に入れた。", "chaos weapon");
4546 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4547 msg_print(_("「汝の行いは貴き報いに値せり。」", "'Thy deed hath earned thee a worthy reward.'"));
4549 acquirement(p_ptr->y, p_ptr->x, randint1(2) + 1, FALSE, FALSE, FALSE);
4550 reward = _("上質なアイテムを手に入れた。", "good items");
4555 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4556 msg_print(_("「下僕よ、汝の献身への我が惜しみ無き報いを見るがよい。」", "'Behold, mortal, how generously I reward thy loyalty.'"));
4558 acquirement(p_ptr->y, p_ptr->x, randint1(2) + 1, TRUE, FALSE, FALSE);
4559 reward = _("高級品のアイテムを手に入れた。", "excellent items");
4564 msg_format("%sの声が轟き渡った:", chaos_patrons[p_ptr->chaos_patron]);
4566 msg_format("The voice of %s thunders:", chaos_patrons[p_ptr->chaos_patron]);
4569 msg_print(_("「下僕よ、汝傲慢なり。」", "'Thou art growing arrogant, mortal.'"));
4571 (void)activate_ty_curse(FALSE, &count);
4572 reward = _("禍々しい呪いをかけられた。", "cursing");
4577 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4578 msg_print(_("「我が下僕たちよ、かの傲慢なる者を倒すべし!」", "'My pets, destroy the arrogant mortal!'"));
4580 for (dummy = 0; dummy < randint1(5) + 1; dummy++)
4582 (void)summon_specific(0, p_ptr->y, p_ptr->x, dun_level, 0, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET));
4584 reward = _("モンスターを召喚された。", "summoning hostile monsters");
4590 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4591 msg_print(_("「汝、より強き敵を必要とせり!」", "'Thou needst worthier opponents!'"));
4593 activate_hi_summon(p_ptr->y, p_ptr->x, FALSE);
4594 reward = _("モンスターを召喚された。", "summoning many hostile monsters");
4600 msg_format("%sの声が響き渡った:",
4601 chaos_patrons[p_ptr->chaos_patron]);
4603 msg_format("The voice of %s booms out:",
4604 chaos_patrons[p_ptr->chaos_patron]);
4607 msg_print(_("「死と破壊こそ我が喜びなり!」", "'Death and destruction! This pleaseth me!'"));
4610 reward = _("カオスの力が渦巻いた。", "calling chaos");
4616 msg_format("%sの声が鳴り響いた:",
4617 chaos_patrons[p_ptr->chaos_patron]);
4619 msg_format("The voice of %s rings out:",
4620 chaos_patrons[p_ptr->chaos_patron]);
4623 msg_print(_("「留まるのだ、下僕よ。余が汝の肉体を鍛えん。」", "'Stay, mortal, and let me mold thee.'"));
4625 if (one_in_(3) && !(chaos_stats[p_ptr->chaos_patron] < 0))
4626 do_inc_stat(chaos_stats[p_ptr->chaos_patron]);
4628 do_inc_stat(randint0(6));
4629 reward = _("能力値が上がった。", "increasing a stat");
4635 msg_format("%sの声が響き渡った:",
4636 chaos_patrons[p_ptr->chaos_patron]);
4638 msg_format("The voice of %s booms out:",
4639 chaos_patrons[p_ptr->chaos_patron]);
4642 msg_print(_("「下僕よ、余は汝に飽みたり。」", "'I grow tired of thee, mortal.'"));
4644 if (one_in_(3) && !(chaos_stats[p_ptr->chaos_patron] < 0))
4645 do_dec_stat(chaos_stats[p_ptr->chaos_patron]);
4647 (void)do_dec_stat(randint0(6));
4648 reward = _("能力値が下がった。", "decreasing a stat");
4655 msg_format("%sの声が轟き渡った:",
4656 chaos_patrons[p_ptr->chaos_patron]);
4658 msg_format("The voice of %s thunders:",
4659 chaos_patrons[p_ptr->chaos_patron]);
4662 msg_print(_("「汝、謙虚たることを学ぶべし!」", "'Thou needst a lesson in humility, mortal!'"));
4663 msg_print(_("あなたは以前より弱くなった!", "You feel less powerful!"));
4665 for (dummy = 0; dummy < 6; dummy++)
4667 (void)dec_stat(dummy, 10 + randint1(15), TRUE);
4669 reward = _("全能力値が下がった。", "decreasing all stats");
4674 msg_format(_("%sの力が触れるのを感じた。", "You feel the power of %s touch you."),
4675 chaos_patrons[p_ptr->chaos_patron]);
4677 reward = _("傷が変化した。", "polymorphing wounds");
4682 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4684 msg_print(_("「我がささやかなる賜物を受けとるがよい!」", "'Receive this modest gift from me!'"));
4686 for (dummy = 0; dummy < 6; dummy++)
4688 (void)do_inc_stat(dummy);
4690 reward = _("全能力値が上がった。", "increasing all stats");
4695 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4696 msg_print(_("「苦しむがよい、無能な愚か者よ!」", "'Suffer, pathetic fool!'"));
4698 fire_ball(GF_DISINTEGRATE, 0, p_ptr->lev * 4, 4);
4699 take_hit(DAMAGE_NOESCAPE, p_ptr->lev * 4, wrath_reason, -1);
4700 reward = _("分解の球が発生した。", "generating disintegration ball");
4705 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4706 (void)restore_level();
4707 (void)restore_all_status();
4708 (void)true_healing(5000);
4709 reward = _("体力が回復した。", "healing");
4714 if (!buki_motteruka(INVEN_RARM) && !buki_motteruka(INVEN_LARM)) break;
4715 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4716 msg_print(_("「汝、武器に頼ることなかれ。」", "'Thou reliest too much on thy weapon.'"));
4719 if (buki_motteruka(INVEN_LARM))
4722 if (buki_motteruka(INVEN_RARM) && one_in_(2)) dummy = INVEN_RARM;
4724 object_desc(o_name, &inventory[dummy], OD_NAME_ONLY);
4725 (void)curse_weapon(FALSE, dummy);
4726 reward = format(_("%sが破壊された。", "destroying %s"), o_name);
4731 if (!inventory[INVEN_BODY].k_idx) break;
4732 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4733 msg_print(_("「汝、防具に頼ることなかれ。」", "'Thou reliest too much on thine equipment.'"));
4735 object_desc(o_name, &inventory[INVEN_BODY], OD_NAME_ONLY);
4736 (void)curse_armor();
4737 reward = format(_("%sが破壊された。", "destroying %s"), o_name);
4741 msg_format(_("%sの声がささやいた:", "The voice of %s whispers:"), chaos_patrons[p_ptr->chaos_patron]);
4742 msg_print(_("「我を怒りしめた罪を償うべし。」", "'Now thou shalt pay for annoying me.'"));
4744 switch (randint1(4))
4747 (void)activate_ty_curse(FALSE, &count);
4748 reward = _("禍々しい呪いをかけられた。", "cursing");
4751 activate_hi_summon(p_ptr->y, p_ptr->x, FALSE);
4752 reward = _("モンスターを召喚された。", "summoning hostile monsters");
4757 if (!buki_motteruka(INVEN_RARM) && !buki_motteruka(INVEN_LARM)) break;
4759 if (buki_motteruka(INVEN_LARM))
4762 if (buki_motteruka(INVEN_RARM) && one_in_(2)) dummy = INVEN_RARM;
4764 object_desc(o_name, &inventory[dummy], OD_NAME_ONLY);
4765 (void)curse_weapon(FALSE, dummy);
4766 reward = format(_("%sが破壊された。", "destroying %s"), o_name);
4770 if (!inventory[INVEN_BODY].k_idx) break;
4771 object_desc(o_name, &inventory[INVEN_BODY], OD_NAME_ONLY);
4772 (void)curse_armor();
4773 reward = format(_("%sが破壊された。", "destroying %s"), o_name);
4777 for (dummy = 0; dummy < 6; dummy++)
4779 (void)dec_stat(dummy, 10 + randint1(15), TRUE);
4781 reward = _("全能力値が下がった。", "decreasing all stats");
4788 msg_format(_("%sの声が轟き渡った:", "The voice of %s thunders:"), chaos_patrons[p_ptr->chaos_patron]);
4789 msg_print(_("「死ぬがよい、下僕よ!」", "'Die, mortal!'"));
4791 take_hit(DAMAGE_LOSELIFE, p_ptr->lev * 4, wrath_reason, -1);
4792 for (dummy = 0; dummy < 6; dummy++)
4794 (void)dec_stat(dummy, 10 + randint1(15), FALSE);
4796 activate_hi_summon(p_ptr->y, p_ptr->x, FALSE);
4797 (void)activate_ty_curse(FALSE, &count);
4802 if (buki_motteruka(INVEN_RARM))
4805 if (buki_motteruka(INVEN_LARM) && one_in_(2)) dummy = INVEN_LARM;
4807 else if (buki_motteruka(INVEN_LARM)) dummy = INVEN_LARM;
4809 if (dummy) (void)curse_weapon(FALSE, dummy);
4811 if (one_in_(2)) (void)curse_armor();
4816 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4817 msg_print(_("「死と破壊こそ我が喜びなり!」", "'Death and destruction! This pleaseth me!'"));
4819 (void)destroy_area(p_ptr->y, p_ptr->x, 25, FALSE);
4820 reward = _("ダンジョンが*破壊*された。", "*destruct*ing dungeon");
4825 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4826 msg_print(_("「我、汝の敵を抹殺せん!」", "'Let me relieve thee of thine oppressors!'"));
4827 (void)symbol_genocide(0, FALSE);
4828 reward = _("モンスターが抹殺された。", "genociding monsters");
4833 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4834 msg_print(_("「我、汝の敵を抹殺せん!」", "'Let me relieve thee of thine oppressors!'"));
4836 (void)mass_genocide(0, FALSE);
4837 reward = _("モンスターが抹殺された。", "genociding nearby monsters");
4842 msg_format(_("%sの力が敵を攻撃するのを感じた!", "You can feel the power of %s assault your enemies!"), chaos_patrons[p_ptr->chaos_patron]);
4843 (void)dispel_monsters(p_ptr->lev * 4);
4848 msg_format(_("%sはあなたを無視した。", "%s ignores you."), chaos_patrons[p_ptr->chaos_patron]);
4853 msg_format(_("%sは褒美として悪魔の使いをよこした!", "%s rewards you with a demonic servant!"),chaos_patrons[p_ptr->chaos_patron]);
4855 if (!summon_specific(-1, p_ptr->y, p_ptr->x, dun_level, SUMMON_DEMON, PM_FORCE_PET))
4856 msg_print(_("何も現れなかった...", "Nobody ever turns up..."));
4858 reward = _("悪魔がペットになった。", "a demonic servant");
4863 msg_format(_("%sは褒美として使いをよこした!", "%s rewards you with a servant!"),chaos_patrons[p_ptr->chaos_patron]);
4865 if (!summon_specific(-1, p_ptr->y, p_ptr->x, dun_level, 0, PM_FORCE_PET))
4866 msg_print(_("何も現れなかった...", "Nobody ever turns up..."));
4868 reward = _("モンスターがペットになった。", "a servant");
4873 msg_format(_("%sは褒美としてアンデッドの使いをよこした。", "%s rewards you with an undead servant!"),chaos_patrons[p_ptr->chaos_patron]);
4875 if (!summon_specific(-1, p_ptr->y, p_ptr->x, dun_level, SUMMON_UNDEAD, PM_FORCE_PET))
4876 msg_print(_("何も現れなかった...", "Nobody ever turns up..."));
4878 reward = _("アンデッドがペットになった。", "an undead servant");
4883 msg_format(_("%sの声がどもった:", "The voice of %s stammers:"),
4885 chaos_patrons[p_ptr->chaos_patron]);
4886 msg_format(_("「あー、あー、答えは %d/%d。質問は何?」", "'Uh... uh... the answer's %d/%d, what's the question?'"), type, effect);
4892 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, format(_("パトロンの報酬で%s", "The patron rewards you with %s."), reward));
4898 * XAngband: determine if a given location is "interesting"
4899 * based on target_set_accept function.
4901 static bool tgt_pt_accept(POSITION y, POSITION x)
4906 if (!(in_bounds(y, x))) return (FALSE);
4908 /* Player grid is always interesting */
4909 if ((y == p_ptr->y) && (x == p_ptr->x)) return (TRUE);
4911 /* Handle hallucination */
4912 if (p_ptr->image) return (FALSE);
4914 /* Examine the grid */
4915 c_ptr = &cave[y][x];
4917 /* Interesting memorized features */
4918 if (c_ptr->info & (CAVE_MARK))
4921 if (cave_have_flag_grid(c_ptr, FF_LESS)) return (TRUE);
4922 if (cave_have_flag_grid(c_ptr, FF_MORE)) return (TRUE);
4924 /* Notice quest features */
4925 if (cave_have_flag_grid(c_ptr, FF_QUEST_ENTER)) return (TRUE);
4926 if (cave_have_flag_grid(c_ptr, FF_QUEST_EXIT)) return (TRUE);
4934 * XAngband: Prepare the "temp" array for "tget_pt"
4935 * based on target_set_prepare funciton.
4937 static void tgt_pt_prepare(void)
4941 /* Reset "temp" array */
4944 if (!expand_list) return;
4946 /* Scan the current panel */
4947 for (y = 1; y < cur_hgt; y++)
4949 for (x = 1; x < cur_wid; x++)
4951 /* Require "interesting" contents */
4952 if (!tgt_pt_accept(y, x)) continue;
4954 /* Save the location */
4961 /* Target the nearest monster for shooting */
4962 ang_sort_comp = ang_sort_comp_distance;
4963 ang_sort_swap = ang_sort_swap_distance;
4965 /* Sort the positions */
4966 ang_sort(temp_x, temp_y, temp_n);
4970 * old -- from PsiAngband.
4972 bool tgt_pt(POSITION *x_ptr, POSITION *y_ptr)
4977 bool success = FALSE;
4981 get_screen_size(&wid, &hgt);
4991 msg_print(_("場所を選んでスペースキーを押して下さい。", "Select a point and press space."));
4992 msg_flag = FALSE; /* prevents "-more-" message. */
4994 while ((ch != ESCAPE) && !success)
4996 bool move_fast = FALSE;
4998 move_cursor_relative(y, x);
5010 if (player_bold(y, x)) ch = 0;
5013 else success = TRUE;
5017 /* XAngband: Move cursor to stairs */
5020 if (expand_list && temp_n)
5023 int cx = (panel_col_min + panel_col_max) / 2;
5024 int cy = (panel_row_min + panel_row_max) / 2;
5028 /* Skip stairs which have defferent distance */
5029 for (; n < temp_n; ++ n)
5031 cave_type *c_ptr = &cave[temp_y[n]][temp_x[n]];
5033 if (cave_have_flag_grid(c_ptr, FF_STAIRS) &&
5034 cave_have_flag_grid(c_ptr, ch == '>' ? FF_MORE : FF_LESS))
5041 if (n == temp_n) /* Loop out taget list */
5046 verify_panel(); /* Move cursor to player */
5048 p_ptr->update |= (PU_MONSTERS);
5050 p_ptr->redraw |= (PR_MAP);
5052 p_ptr->window |= (PW_OVERHEAD);
5055 else /* move cursor to next stair and change panel */
5060 dy = 2 * (y - cy) / hgt;
5061 dx = 2 * (x - cx) / wid;
5062 if (dy || dx) change_panel(dy, dx);
5068 /* Look up the direction */
5069 d = get_keymap_dir(ch);
5071 /* XTRA HACK MOVEFAST */
5072 if (isupper(ch)) move_fast = TRUE;
5074 /* Handle "direction" */
5080 /* XTRA HACK MOVEFAST */
5083 int mag = MIN(wid / 2, hgt / 2);
5093 /* Do not move horizontally if unnecessary */
5094 if (((x < panel_col_min + wid / 2) && (dx > 0)) ||
5095 ((x > panel_col_min + wid / 2) && (dx < 0)))
5100 /* Do not move vertically if unnecessary */
5101 if (((y < panel_row_min + hgt / 2) && (dy > 0)) ||
5102 ((y > panel_row_min + hgt / 2) && (dy < 0)))
5107 /* Apply the motion */
5108 if ((y >= panel_row_min + hgt) || (y < panel_row_min) ||
5109 (x >= panel_col_min + wid) || (x < panel_col_min))
5111 /* if (change_panel(dy, dx)) target_set_prepare(mode); */
5112 change_panel(dy, dx);
5115 /* Slide into legality */
5116 if (x >= cur_wid-1) x = cur_wid - 2;
5117 else if (x <= 0) x = 1;
5119 /* Slide into legality */
5120 if (y >= cur_hgt-1) y = cur_hgt- 2;
5121 else if (y <= 0) y = 1;
5128 /* Clear the top line */
5131 /* Recenter the map around the player */
5134 p_ptr->update |= (PU_MONSTERS);
5136 p_ptr->redraw |= (PR_MAP);
5138 p_ptr->window |= (PW_OVERHEAD);
5147 bool get_hack_dir(DIRECTION *dp)
5155 /* Global direction */
5158 /* (No auto-targeting) */
5160 /* Ask until satisfied */
5163 /* Choose a prompt */
5166 p = _("方向 ('*'でターゲット選択, ESCで中断)? ", "Direction ('*' to choose a target, Escape to cancel)? ");
5170 p = _("方向 ('5'でターゲットへ, '*'でターゲット再選択, ESCで中断)? ", "Direction ('5' for target, '*' to re-target, Escape to cancel)? ");
5173 /* Get a command (or Cancel) */
5174 if (!get_com(p, &command, TRUE)) break;
5178 if (command == '\r') command = 't';
5181 /* Convert various keys to "standard" keys */
5184 /* Use current target */
5195 /* Set new target */
5200 if (target_set(TARGET_KILL)) dir = 5;
5206 /* Look up the direction */
5207 dir = get_keymap_dir(command);
5213 /* Verify requested targets */
5214 if ((dir == 5) && !target_okay()) dir = 0;
5221 if (!dir) return (FALSE);
5223 /* Save the direction */
5226 /* Check for confusion */
5227 if (p_ptr->confused)
5229 /* Random direction */
5230 dir = ddd[randint0(8)];
5233 /* Notice confusion */
5234 if (command_dir != dir)
5237 msg_print(_("あなたは混乱している。", "You are confused."));
5240 /* Save direction */
5243 /* A "valid" direction was entered */
5249 * エネルギーの増加量10d5を速く計算するための関数
5252 #define Go_no_JuuJou 5*5*5*5*5*5*5*5*5*5
5254 s16b gain_energy(void)
5257 s32b energy_result = 10;
5260 tmp = randint0(Go_no_JuuJou);
5262 for (i = 0; i < 9; i ++){
5263 energy_result += tmp % 5;
5267 return (s16b)(energy_result + tmp);
5272 * @brief 射撃武器の攻撃に必要な基本消費エネルギーを返す/Return bow energy
5273 * @param sval 射撃武器のアイテム副分類ID
5274 * @return 消費する基本エネルギー
5276 ENERGY bow_energy(OBJECT_SUBTYPE_VALUE sval)
5278 ENERGY energy = 10000;
5280 /* Analyze the launcher */
5283 /* Sling and ammo */
5290 /* Short Bow and Arrow */
5297 /* Long Bow and Arrow */
5304 /* Bow of irresponsiblity and Arrow */
5311 /* Light Crossbow and Bolt */
5318 /* Heavy Crossbow and Bolt */
5333 int bow_tmul(OBJECT_SUBTYPE_VALUE sval)
5337 /* Analyze the launcher */
5340 /* Sling and ammo */
5347 /* Short Bow and Arrow */
5354 /* Long Bow and Arrow */
5361 /* Bow of irresponsiblity and Arrow */
5368 /* Light Crossbow and Bolt */
5375 /* Heavy Crossbow and Bolt */
5387 * Return alignment title
5389 cptr your_alignment(void)
5392 if (p_ptr->align > 150) return "大善";
5393 else if (p_ptr->align > 50) return "中善";
5394 else if (p_ptr->align > 10) return "小善";
5395 else if (p_ptr->align > -11) return "中立";
5396 else if (p_ptr->align > -51) return "小悪";
5397 else if (p_ptr->align > -151) return "中悪";
5400 if (p_ptr->align > 150) return "Lawful";
5401 else if (p_ptr->align > 50) return "Good";
5402 else if (p_ptr->align > 10) return "Neutral Good";
5403 else if (p_ptr->align > -11) return "Neutral";
5404 else if (p_ptr->align > -51) return "Neutral Evil";
5405 else if (p_ptr->align > -151) return "Evil";
5406 else return "Chaotic";
5412 * Return proficiency level of weapons and misc. skills (except riding)
5414 int weapon_exp_level(int weapon_exp)
5416 if (weapon_exp < WEAPON_EXP_BEGINNER) return EXP_LEVEL_UNSKILLED;
5417 else if (weapon_exp < WEAPON_EXP_SKILLED) return EXP_LEVEL_BEGINNER;
5418 else if (weapon_exp < WEAPON_EXP_EXPERT) return EXP_LEVEL_SKILLED;
5419 else if (weapon_exp < WEAPON_EXP_MASTER) return EXP_LEVEL_EXPERT;
5420 else return EXP_LEVEL_MASTER;
5425 * Return proficiency level of riding
5427 int riding_exp_level(int riding_exp)
5429 if (riding_exp < RIDING_EXP_BEGINNER) return EXP_LEVEL_UNSKILLED;
5430 else if (riding_exp < RIDING_EXP_SKILLED) return EXP_LEVEL_BEGINNER;
5431 else if (riding_exp < RIDING_EXP_EXPERT) return EXP_LEVEL_SKILLED;
5432 else if (riding_exp < RIDING_EXP_MASTER) return EXP_LEVEL_EXPERT;
5433 else return EXP_LEVEL_MASTER;
5438 * Return proficiency level of spells
5440 int spell_exp_level(int spell_exp)
5442 if (spell_exp < SPELL_EXP_BEGINNER) return EXP_LEVEL_UNSKILLED;
5443 else if (spell_exp < SPELL_EXP_SKILLED) return EXP_LEVEL_BEGINNER;
5444 else if (spell_exp < SPELL_EXP_EXPERT) return EXP_LEVEL_SKILLED;
5445 else if (spell_exp < SPELL_EXP_MASTER) return EXP_LEVEL_EXPERT;
5446 else return EXP_LEVEL_MASTER;
5451 * Display a rumor and apply its effects
5454 IDX rumor_num(char *zz, IDX max_idx)
5456 if (strcmp(zz, "*") == 0) return randint1(max_idx - 1);
5457 return (IDX)atoi(zz);
5460 cptr rumor_bind_name(char *base, cptr fullname)
5464 s = strstr(base, "{Name}");
5468 v = format("%s%s%s", base, fullname, (s + 6));
5478 void display_rumor(bool ex)
5486 if (randint0(3) == 0) section = 1;
5489 err = _(get_rnd_line_jonly("rumors_j.txt", section, Rumor, 10),
5490 get_rnd_line("rumors.txt", section, Rumor));
5491 if (err) strcpy(Rumor, _("嘘の噂もある。", "Some rumors are wrong."));
5495 if (strncmp(Rumor, "R:", 2) == 0)
5498 cptr rumor_msg = NULL;
5499 cptr rumor_eff_format = NULL;
5500 char fullname[1024] = "";
5502 if (tokenize(Rumor + 2, 3, zz, TOKENIZE_CHECKQUOTE) == 3)
5504 if (strcmp(zz[0], "ARTIFACT") == 0)
5508 object_type *q_ptr = &forge;
5509 artifact_type *a_ptr;
5513 a_idx = rumor_num(zz[1], max_a_idx);
5515 a_ptr = &a_info[a_idx];
5516 if (a_ptr->name) break;
5519 k_idx = lookup_kind(a_ptr->tval, a_ptr->sval);
5520 object_prep(q_ptr, k_idx);
5521 q_ptr->name1 = a_idx;
5522 q_ptr->ident = IDENT_STORE;
5523 object_desc(fullname, q_ptr, OD_NAME_ONLY);
5525 else if (strcmp(zz[0], "MONSTER") == 0)
5528 monster_race *r_ptr;
5532 r_idx = rumor_num(zz[1], max_r_idx);
5533 r_ptr = &r_info[r_idx];
5534 if (r_ptr->name) break;
5537 strcpy(fullname, r_name + r_ptr->name);
5539 /* Remember this monster */
5540 if (!r_ptr->r_sights)
5545 else if (strcmp(zz[0], "DUNGEON") == 0)
5548 dungeon_info_type *d_ptr;
5552 d_idx = rumor_num(zz[1], max_d_idx);
5553 d_ptr = &d_info[d_idx];
5554 if (d_ptr->name) break;
5557 strcpy(fullname, d_name + d_ptr->name);
5559 if (!max_dlv[d_idx])
5561 max_dlv[d_idx] = d_ptr->mindepth;
5562 rumor_eff_format = _("%sに帰還できるようになった。", "You can recall to %s.");
5565 else if (strcmp(zz[0], "TOWN") == 0)
5572 t_idx = rumor_num(zz[1], NO_TOWN);
5573 if (town[t_idx].name) break;
5576 strcpy(fullname, town[t_idx].name);
5578 visit = (1L << (t_idx - 1));
5579 if ((t_idx != SECRET_TOWN) && !(p_ptr->visit & visit))
5581 p_ptr->visit |= visit;
5582 rumor_eff_format = _("%sに行ったことがある気がする。", "You feel you have been to %s.");
5586 rumor_msg = rumor_bind_name(zz[2], fullname);
5587 msg_print(rumor_msg);
5588 if (rumor_eff_format)
5591 msg_format(rumor_eff_format, fullname);
5596 if (err) msg_print(_("この情報は間違っている。", "This information is wrong."));
5600 msg_format("%s", Rumor);