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 #define REWARD_CHANCE 10
20 * @brief プレイヤーの経験値について整合性のためのチェックと調整を行う /
21 * Advance experience levels and print experience
24 void check_experience(void)
26 bool level_reward = FALSE;
27 bool level_mutation = FALSE;
28 bool level_inc_stat = FALSE;
29 bool android = (p_ptr->prace == RACE_ANDROID ? TRUE : FALSE);
30 int old_lev = p_ptr->lev;
32 /* Hack -- lower limit */
33 if (p_ptr->exp < 0) p_ptr->exp = 0;
34 if (p_ptr->max_exp < 0) p_ptr->max_exp = 0;
35 if (p_ptr->max_max_exp < 0) p_ptr->max_max_exp = 0;
37 /* Hack -- upper limit */
38 if (p_ptr->exp > PY_MAX_EXP) p_ptr->exp = PY_MAX_EXP;
39 if (p_ptr->max_exp > PY_MAX_EXP) p_ptr->max_exp = PY_MAX_EXP;
40 if (p_ptr->max_max_exp > PY_MAX_EXP) p_ptr->max_max_exp = PY_MAX_EXP;
42 /* Hack -- maintain "max" experience */
43 if (p_ptr->exp > p_ptr->max_exp) p_ptr->max_exp = p_ptr->exp;
45 /* Hack -- maintain "max max" experience */
46 if (p_ptr->max_exp > p_ptr->max_max_exp) p_ptr->max_max_exp = p_ptr->max_exp;
48 /* Redraw experience */
49 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)))
62 /* Update some stuff */
63 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
65 /* Redraw some stuff */
66 p_ptr->redraw |= (PR_LEV | PR_TITLE);
69 p_ptr->window |= (PW_PLAYER);
76 /* Gain levels while possible */
77 while ((p_ptr->lev < PY_MAX_LEVEL) &&
78 (p_ptr->exp >= ((android ? player_exp_a : player_exp)[p_ptr->lev-1] * p_ptr->expfact / 100L)))
83 /* Save the highest level */
84 if (p_ptr->lev > p_ptr->max_plv)
86 p_ptr->max_plv = p_ptr->lev;
88 if ((p_ptr->pclass == CLASS_CHAOS_WARRIOR) ||
89 (p_ptr->muta2 & MUT2_CHAOS_GIFT))
93 if (p_ptr->prace == RACE_BEASTMAN)
95 if (one_in_(5)) level_mutation = TRUE;
97 level_inc_stat = TRUE;
99 do_cmd_write_nikki(NIKKI_LEVELUP, p_ptr->lev, NULL);
107 msg_format("レベル %d にようこそ。", p_ptr->lev);
109 msg_format("Welcome to level %d.", p_ptr->lev);
113 /* Update some stuff */
114 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
116 /* Redraw some stuff */
117 p_ptr->redraw |= (PR_LEV | PR_TITLE | PR_EXP);
120 p_ptr->window |= (PW_PLAYER | PW_SPELL | PW_INVEN);
132 if(!(p_ptr->max_plv % 10))
142 cnv_stat(p_ptr->stat_max[0], tmp);
143 prt(format(" a) 腕力 (現在値 %s)", tmp), 2, 14);
144 cnv_stat(p_ptr->stat_max[1], tmp);
145 prt(format(" b) 知能 (現在値 %s)", tmp), 3, 14);
146 cnv_stat(p_ptr->stat_max[2], tmp);
147 prt(format(" c) 賢さ (現在値 %s)", tmp), 4, 14);
148 cnv_stat(p_ptr->stat_max[3], tmp);
149 prt(format(" d) 器用 (現在値 %s)", tmp), 5, 14);
150 cnv_stat(p_ptr->stat_max[4], tmp);
151 prt(format(" e) 耐久 (現在値 %s)", tmp), 6, 14);
152 cnv_stat(p_ptr->stat_max[5], tmp);
153 prt(format(" f) 魅力 (現在値 %s)", tmp), 7, 14);
155 prt(" どの能力値を上げますか?", 1, 14);
157 cnv_stat(p_ptr->stat_max[0], tmp);
158 prt(format(" a) Str (cur %s)", tmp), 2, 14);
159 cnv_stat(p_ptr->stat_max[1], tmp);
160 prt(format(" b) Int (cur %s)", tmp), 3, 14);
161 cnv_stat(p_ptr->stat_max[2], tmp);
162 prt(format(" c) Wis (cur %s)", tmp), 4, 14);
163 cnv_stat(p_ptr->stat_max[3], tmp);
164 prt(format(" d) Dex (cur %s)", tmp), 5, 14);
165 cnv_stat(p_ptr->stat_max[4], tmp);
166 prt(format(" e) Con (cur %s)", tmp), 6, 14);
167 cnv_stat(p_ptr->stat_max[5], tmp);
168 prt(format(" f) Chr (cur %s)", tmp), 7, 14);
170 prt(" Which stat do you want to raise?", 1, 14);
175 if ((choice >= 'a') && (choice <= 'f')) break;
177 for(n = 0; n < 6; n++)
178 if (n != choice - 'a')
180 if (get_check(_("よろしいですか?", "Are you sure? "))) break;
182 do_inc_stat(choice - 'a');
185 else if(!(p_ptr->max_plv % 2))
186 do_inc_stat(randint0(6));
191 msg_print(_("あなたは変わった気がする...", "You feel different..."));
192 (void)gain_random_mutation(0);
193 level_mutation = FALSE;
197 * 報酬でレベルが上ると再帰的に check_experience() が
202 gain_level_reward(0);
203 level_reward = FALSE;
206 /* Update some stuff */
207 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
209 /* Redraw some stuff */
210 p_ptr->redraw |= (PR_LEV | PR_TITLE);
213 p_ptr->window |= (PW_PLAYER | PW_SPELL);
219 /* Load an autopick preference file */
220 if (old_lev != p_ptr->lev) autopick_load_pref(FALSE);
225 * @brief モンスターを倒した際の財宝svalを返す
226 * @param r_idx 倒したモンスターの種族ID
229 * Hack -- Return the "automatic coin type" of a monster race
230 * Used to allocate proper treasure when "Creeping coins" die
231 * XXX XXX XXX Note the use of actual "monster names"
233 static int get_coin_type(MONRACE_IDX r_idx)
235 /* Analyze monsters */
238 case MON_COPPER_COINS: return 2;
239 case MON_SILVER_COINS: return 5;
240 case MON_GOLD_COINS: return 10;
241 case MON_MITHRIL_COINS:
242 case MON_MITHRIL_GOLEM: return 16;
243 case MON_ADAMANT_COINS: return 17;
252 * @brief オブジェクトがクロークかどうかを判定する /
253 * Hack -- determine if a template is Cloak
254 * @param k_idx 判定したいオブジェクトのベースアイテムID
255 * @return オブジェクトがクロークならばTRUEを返す
257 static bool kind_is_cloak(int k_idx)
259 object_kind *k_ptr = &k_info[k_idx];
261 /* Analyze the item type */
262 if (k_ptr->tval == TV_CLOAK)
267 /* Assume not good */
273 * @brief オブジェクトが竿状武器かどうかを判定する /
274 * Hack -- determine if a template is Polearm
275 * @param k_idx 判定したいオブジェクトのベースアイテムID
276 * @return オブジェクトが竿状武器ならばTRUEを返す
278 static bool kind_is_polearm(int k_idx)
280 object_kind *k_ptr = &k_info[k_idx];
282 /* Analyze the item type */
283 if (k_ptr->tval == TV_POLEARM)
288 /* Assume not good */
294 * @brief オブジェクトが剣かどうかを判定する /
295 * Hack -- determine if a template is Sword
296 * @param k_idx 判定したいオブジェクトのベースアイテムID
297 * @return オブジェクトが剣ならばTRUEを返す
299 static bool kind_is_sword(int k_idx)
301 object_kind *k_ptr = &k_info[k_idx];
303 /* Analyze the item type */
304 if ((k_ptr->tval == TV_SWORD) && (k_ptr->sval > 2))
309 /* Assume not good */
315 * @brief オブジェクトが魔法書かどうかを判定する /
316 * Hack -- determine if a template is Book
317 * @param k_idx 判定したいオブジェクトのベースアイテムID
318 * @return オブジェクトが魔法書ならばTRUEを返す
320 static bool kind_is_book(int k_idx)
322 object_kind *k_ptr = &k_info[k_idx];
324 /* Analyze the item type */
325 if ((k_ptr->tval >= TV_LIFE_BOOK) && (k_ptr->tval <= TV_CRUSADE_BOOK))
330 /* Assume not good */
336 * @brief オブジェクトがベースアイテム時点でGOODかどうかを判定する /
337 * Hack -- determine if a template is Good book
338 * @param k_idx 判定したいオブジェクトのベースアイテムID
339 * @return オブジェクトがベースアイテム時点でGOODなアイテムならばTRUEを返す
341 static bool kind_is_good_book(int k_idx)
343 object_kind *k_ptr = &k_info[k_idx];
345 /* Analyze the item type */
346 if ((k_ptr->tval >= TV_LIFE_BOOK) && (k_ptr->tval <= TV_CRUSADE_BOOK) && (k_ptr->tval != TV_ARCANE_BOOK) && (k_ptr->sval > 1))
351 /* Assume not good */
357 * @brief オブジェクトが鎧かどうかを判定する /
358 * Hack -- determine if a template is Armor
359 * @param k_idx 判定したいオブジェクトのベースアイテムID
360 * @return オブジェクトが鎧ならばTRUEを返す
362 static bool kind_is_armor(int k_idx)
364 object_kind *k_ptr = &k_info[k_idx];
366 /* Analyze the item type */
367 if (k_ptr->tval == TV_HARD_ARMOR)
372 /* Assume not good */
378 * @brief オブジェクトが打撃武器かどうかを判定する /
379 * Hack -- determine if a template is hafted weapon
380 * @param k_idx 判定したいオブジェクトのベースアイテムID
381 * @return オブジェクトが打撃武器ならばTRUEを返す
383 static bool kind_is_hafted(int k_idx)
385 object_kind *k_ptr = &k_info[k_idx];
387 /* Analyze the item type */
388 if (k_ptr->tval == TV_HAFTED)
393 /* Assume not good */
398 * @brief クエストを達成状態にする /
399 * @param quest_num 達成状態にしたいクエストのID
402 void complete_quest(int quest_num)
404 quest_type* const q_ptr = &quest[quest_num];
408 case QUEST_TYPE_RANDOM:
409 if (record_rand_quest) do_cmd_write_nikki(NIKKI_RAND_QUEST_C, quest_num, NULL);
412 if (record_fix_quest) do_cmd_write_nikki(NIKKI_FIX_QUEST_C, quest_num, NULL);
416 q_ptr->status = QUEST_STATUS_COMPLETED;
417 q_ptr->complev = (byte)p_ptr->lev;
419 q_ptr->comptime = playtime;
421 if (!(q_ptr->flags & QUEST_FLAG_SILENT))
423 play_music(TERM_XTRA_MUSIC_BASIC, MUSIC_BASIC_QUEST_CLEAR);
424 msg_print(_("クエストを達成した!", "You just completed your quest!"));
430 * @brief 現在フロアに残っている敵モンスターの数を返す /
431 * @return 現在の敵モンスターの数
433 static int count_all_hostile_monsters(void)
438 for (x = 0; x < cur_wid; ++ x)
440 for (y = 0; y < cur_hgt; ++ y)
442 MONSTER_IDX m_idx = cave[y][x].m_idx;
444 if (m_idx > 0 && is_hostile(&m_list[m_idx]))
455 * @brief 特定の敵を倒した際にクエスト達成処理 /
456 * Check for "Quest" completion when a quest monster is killed or charmed.
457 * @param m_ptr 撃破したモンスターの構造体参照ポインタ
460 void check_quest_completion(monster_type *m_ptr)
466 bool create_stairs = FALSE;
472 /* Get the location */
477 quest_num = p_ptr->inside_quest;
479 /* Search for an active quest on this dungeon level */
484 for (i = max_quests - 1; i > 0; i--)
486 quest_type* const q_ptr = &quest[i];
488 /* Quest is not active */
489 if (q_ptr->status != QUEST_STATUS_TAKEN)
492 /* Quest is not a dungeon quest */
493 if (q_ptr->flags & QUEST_FLAG_PRESET)
496 /* Quest is not on this level */
497 if ((q_ptr->level != dun_level) &&
498 (q_ptr->type != QUEST_TYPE_KILL_ANY_LEVEL))
501 /* Not a "kill monster" quest */
502 if ((q_ptr->type == QUEST_TYPE_FIND_ARTIFACT) ||
503 (q_ptr->type == QUEST_TYPE_FIND_EXIT))
506 /* Interesting quest */
507 if ((q_ptr->type == QUEST_TYPE_KILL_NUMBER) ||
508 (q_ptr->type == QUEST_TYPE_TOWER) ||
509 (q_ptr->type == QUEST_TYPE_KILL_ALL))
512 /* Interesting quest */
513 if (((q_ptr->type == QUEST_TYPE_KILL_LEVEL) ||
514 (q_ptr->type == QUEST_TYPE_KILL_ANY_LEVEL) ||
515 (q_ptr->type == QUEST_TYPE_RANDOM)) &&
516 (q_ptr->r_idx == m_ptr->r_idx))
523 /* Handle the current quest */
524 if (quest_num && (quest[quest_num].status == QUEST_STATUS_TAKEN))
527 quest_type* const q_ptr = &quest[quest_num];
531 case QUEST_TYPE_KILL_NUMBER:
535 if (q_ptr->cur_num >= q_ptr->num_mon)
537 complete_quest(quest_num);
543 case QUEST_TYPE_KILL_ALL:
545 if (!is_hostile(m_ptr)) break;
547 if (count_all_hostile_monsters() == 1)
549 if (q_ptr->flags & QUEST_FLAG_SILENT)
551 q_ptr->status = QUEST_STATUS_FINISHED;
555 complete_quest(quest_num);
560 case QUEST_TYPE_KILL_LEVEL:
561 case QUEST_TYPE_RANDOM:
563 /* Only count valid monsters */
564 if (q_ptr->r_idx != m_ptr->r_idx)
569 if (q_ptr->cur_num >= q_ptr->max_num)
571 complete_quest(quest_num);
573 if (!(q_ptr->flags & QUEST_FLAG_PRESET))
575 create_stairs = TRUE;
576 p_ptr->inside_quest = 0;
579 /* Finish the two main quests without rewarding */
580 if ((quest_num == QUEST_OBERON) || (quest_num == QUEST_SERPENT))
582 q_ptr->status = QUEST_STATUS_FINISHED;
585 if (q_ptr->type == QUEST_TYPE_RANDOM)
588 q_ptr->status = QUEST_STATUS_FINISHED;
593 case QUEST_TYPE_KILL_ANY_LEVEL:
596 if (q_ptr->cur_num >= q_ptr->max_num)
598 complete_quest(quest_num);
603 case QUEST_TYPE_TOWER:
605 if (!is_hostile(m_ptr)) break;
607 if (count_all_hostile_monsters() == 1)
609 q_ptr->status = QUEST_STATUS_STAGE_COMPLETED;
611 if((quest[QUEST_TOWER1].status == QUEST_STATUS_STAGE_COMPLETED) &&
612 (quest[QUEST_TOWER2].status == QUEST_STATUS_STAGE_COMPLETED) &&
613 (quest[QUEST_TOWER3].status == QUEST_STATUS_STAGE_COMPLETED))
616 complete_quest(QUEST_TOWER1);
624 /* Create a magical staircase */
630 while (cave_perma_bold(y, x) || cave[y][x].o_idx || (cave[y][x].info & CAVE_OBJECT) )
632 /* Pick a location */
633 scatter(&ny, &nx, y, x, 1, 0);
639 /* Explain the staircase */
640 msg_print(_("魔法の階段が現れた...", "A magical staircase appears..."));
642 /* Create stairs down */
643 cave_set_feat(y, x, feat_down_stair);
645 /* Remember to update everything */
646 p_ptr->update |= (PU_FLOW);
656 for (i = 0; i < (dun_level / 15)+1; i++)
658 /* Get local object */
661 /* Wipe the object */
664 /* Make a great object */
665 make_object(o_ptr, AM_GOOD | AM_GREAT);
667 /* Drop it in the dungeon */
668 (void)drop_near(o_ptr, -1, y, x);
674 * @brief 特定のアーティファクトを入手した際のクエスト達成処理 /
675 * Check for "Quest" completion when a quest monster is killed or charmed.
676 * @param o_ptr 入手したオブジェクトの構造体参照ポインタ
679 void check_find_art_quest_completion(object_type *o_ptr)
682 /* Check if completed a quest */
683 for (i = 0; i < max_quests; i++)
685 if ((quest[i].type == QUEST_TYPE_FIND_ARTIFACT) &&
686 (quest[i].status == QUEST_STATUS_TAKEN) &&
687 (quest[i].k_idx == o_ptr->name1))
696 * @brief モンスターを撃破した際の述語メッセージを返す /
697 * Return monster death string
698 * @param r_ptr 撃破されたモンスターの種族情報を持つ構造体の参照ポインタ
699 * @return 撃破されたモンスターの述語
701 cptr extract_note_dies(monster_race *r_ptr)
703 /* Some monsters get "destroyed" */
704 if (!monster_living(r_ptr))
708 for (i = 0; i < 4; i++)
710 if (r_ptr->blow[i].method == RBM_EXPLODE)
712 return _("は爆発して粉々になった。", " explodes into tiny shreds.");
715 return _("を倒した。", " is destroyed.");
718 /* Assume a default death */
719 return _("は死んだ。", " dies.");
724 * @brief モンスターが死亡した時の処理 /
725 * Handle the "death" of a monster.
726 * @param m_idx 死亡したモンスターのID
727 * @param drop_item TRUEならばモンスターのドロップ処理を行う
728 * @return 撃破されたモンスターの述語
731 * Disperse treasures centered at the monster location based on the
732 * various flags contained in the monster flags fields.
733 * Check for "Quest" completion when a quest monster is killed.
734 * Note that only the player can induce "monster_death()" on Uniques.
735 * Thus (for now) all Quest monsters should be Uniques.
736 * Note that monsters can now carry objects, and when a monster dies,
737 * it drops all of its objects, which may disappear in crowded rooms.
740 void monster_death(MONSTER_IDX m_idx, bool drop_item)
749 monster_type *m_ptr = &m_list[m_idx];
751 monster_race *r_ptr = &r_info[m_ptr->r_idx];
753 bool visible = ((m_ptr->ml && !p_ptr->image) || (r_ptr->flags1 & RF1_UNIQUE));
757 bool do_gold = (!(r_ptr->flags1 & RF1_ONLY_ITEM));
758 bool do_item = (!(r_ptr->flags1 & RF1_ONLY_GOLD));
759 bool cloned = (m_ptr->smart & SM_CLONED) ? TRUE : FALSE;
760 int force_coin = get_coin_type(m_ptr->r_idx);
765 bool drop_chosen_item = drop_item && !cloned && !p_ptr->inside_arena
766 && !p_ptr->inside_battle && !is_pet(m_ptr);
768 /* The caster is dead? */
769 if (world_monster && world_monster == m_idx) world_monster = 0;
771 /* Notice changes in view */
772 if (r_ptr->flags7 & (RF7_LITE_MASK | RF7_DARK_MASK))
774 /* Update some things */
775 p_ptr->update |= (PU_MON_LITE);
778 /* Get the location */
782 if (record_named_pet && is_pet(m_ptr) && m_ptr->nickname)
786 monster_desc(m_name, m_ptr, MD_INDEF_VISIBLE);
787 do_cmd_write_nikki(NIKKI_NAMED_PET, 3, m_name);
790 /* Let monsters explode! */
791 for (i = 0; i < 4; i++)
793 if (r_ptr->blow[i].method == RBM_EXPLODE)
795 int flg = PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL;
796 int typ = mbe_info[r_ptr->blow[i].effect].explode_type;
797 DICE_NUMBER d_dice = r_ptr->blow[i].d_dice;
798 DICE_SID d_side = r_ptr->blow[i].d_side;
799 HIT_POINT damage = damroll(d_dice, d_side);
801 project(m_idx, 3, y, x, damage, typ, flg, -1);
806 if (m_ptr->mflag2 & MFLAG2_CHAMELEON)
808 choose_new_monster(m_idx, TRUE, MON_CHAMELEON);
809 r_ptr = &r_info[m_ptr->r_idx];
812 /* Check for quest completion */
813 check_quest_completion(m_ptr);
815 /* Handle the possibility of player vanquishing arena combatant -KMW- */
816 if (p_ptr->inside_arena && !is_pet(m_ptr))
818 p_ptr->exit_bldg = TRUE;
820 if (p_ptr->arena_number > MAX_ARENA_MONS)
822 msg_print(_("素晴らしい!君こそ真の勝利者だ。", "You are a Genuine Champion!"));
826 msg_print(_("勝利!チャンピオンへの道を進んでいる。", "Victorious! You're on your way to becoming Champion."));
829 if (arena_info[p_ptr->arena_number].tval)
831 /* Get local object */
834 /* Prepare to make a prize */
835 object_prep(q_ptr, lookup_kind(arena_info[p_ptr->arena_number].tval, arena_info[p_ptr->arena_number].sval));
837 apply_magic(q_ptr, object_level, AM_NO_FIXED_ART);
839 /* Drop it in the dungeon */
840 (void)drop_near(q_ptr, -1, y, x);
843 if (p_ptr->arena_number > MAX_ARENA_MONS) p_ptr->arena_number++;
844 p_ptr->arena_number++;
849 /* Extract monster name */
850 monster_desc(m_name, m_ptr, MD_IGNORE_HALLU | MD_ASSUME_VISIBLE | MD_INDEF_VISIBLE);
852 do_cmd_write_nikki(NIKKI_ARENA, p_ptr->arena_number, m_name);
856 if (m_idx == p_ptr->riding)
858 if (rakuba(-1, FALSE))
860 msg_print(_("地面に落とされた。", "You have fallen from your riding pet."));
864 /* Drop a dead corpse? */
865 if (one_in_(r_ptr->flags1 & RF1_UNIQUE ? 1 : 4) &&
866 (r_ptr->flags9 & (RF9_DROP_CORPSE | RF9_DROP_SKELETON)) &&
867 !(p_ptr->inside_arena || p_ptr->inside_battle || cloned || ((m_ptr->r_idx == today_mon) && is_pet(m_ptr))))
869 /* Assume skeleton */
873 * We cannot drop a skeleton? Note, if we are in this check,
874 * we *know* we can drop at least a corpse or a skeleton
876 if (!(r_ptr->flags9 & RF9_DROP_SKELETON))
878 else if ((r_ptr->flags9 & RF9_DROP_CORPSE) && (r_ptr->flags1 & RF1_UNIQUE))
881 /* Else, a corpse is more likely unless we did a "lot" of damage */
882 else if (r_ptr->flags9 & RF9_DROP_CORPSE)
884 /* Lots of damage in one blow */
885 if ((0 - ((m_ptr->maxhp) / 4)) > m_ptr->hp)
887 if (one_in_(5)) corpse = TRUE;
891 if (!one_in_(5)) corpse = TRUE;
895 /* Get local object */
898 /* Prepare to make an object */
899 object_prep(q_ptr, lookup_kind(TV_CORPSE, (corpse ? SV_CORPSE : SV_SKELETON)));
901 apply_magic(q_ptr, object_level, AM_NO_FIXED_ART);
903 q_ptr->pval = m_ptr->r_idx;
905 /* Drop it in the dungeon */
906 (void)drop_near(q_ptr, -1, y, x);
909 /* Drop objects being carried */
910 monster_drop_carried_objects(m_ptr);
912 if (r_ptr->flags1 & RF1_DROP_GOOD) mo_mode |= AM_GOOD;
913 if (r_ptr->flags1 & RF1_DROP_GREAT) mo_mode |= AM_GREAT;
915 switch (m_ptr->r_idx)
917 case MON_PINK_HORROR:
918 /* Pink horrors are replaced with 2 Blue horrors */
919 if (!(p_ptr->inside_arena || p_ptr->inside_battle))
923 for (i = 0; i < 2; i++)
926 bool pet = is_pet(m_ptr);
929 if (pet) mode |= PM_FORCE_PET;
931 if (summon_specific((pet ? -1 : m_idx), wy, wx, 100, SUMMON_BLUE_HORROR, mode))
933 if (player_can_see_bold(wy, wx))
939 msg_print(_("ピンク・ホラーは分裂した!", "The Pink horror divides!"));
943 case MON_BLOODLETTER:
944 /* Bloodletters of Khorne may drop a blade of chaos */
945 if (drop_chosen_item && (randint1(100) < 15))
947 /* Get local object */
950 /* Prepare to make a Blade of Chaos */
951 object_prep(q_ptr, lookup_kind(TV_SWORD, SV_BLADE_OF_CHAOS));
953 apply_magic(q_ptr, object_level, AM_NO_FIXED_ART | mo_mode);
955 /* Drop it in the dungeon */
956 (void)drop_near(q_ptr, -1, y, x);
961 if (drop_chosen_item && (dun_level > 9))
963 /* Get local object */
966 /* Wipe the object */
969 /* Activate restriction */
970 if ((dun_level > 49) && one_in_(5))
971 get_obj_num_hook = kind_is_good_book;
973 get_obj_num_hook = kind_is_book;
976 make_object(q_ptr, mo_mode);
978 /* Drop it in the dungeon */
979 (void)drop_near(q_ptr, -1, y, x);
985 * Mega^3-hack: killing a 'Warrior of the Dawn' is likely to
986 * spawn another in the fallen one's place!
988 if (!p_ptr->inside_arena && !p_ptr->inside_battle)
992 POSITION wy = y, wx = x;
994 bool pet = is_pet(m_ptr);
998 scatter(&wy, &wx, y, x, 20, 0);
1000 while (!(in_bounds(wy, wx) && cave_empty_bold2(wy, wx)) && --attempts);
1005 if (pet) mode |= PM_FORCE_PET;
1007 if (summon_specific((pet ? -1 : m_idx), wy, wx, 100, SUMMON_DAWN, mode))
1009 if (player_can_see_bold(wy, wx))
1010 msg_print(_("新たな戦士が現れた!", "A new warrior steps forth!"));
1018 /* One more ultra-hack: An Unmaker goes out with a big bang! */
1020 int flg = PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL;
1021 (void)project(m_idx, 6, y, x, 100, GF_CHAOS, flg, -1);
1025 case MON_UNICORN_ORD:
1028 /* Reward for "lazy" player */
1029 if (p_ptr->pseikaku == SEIKAKU_NAMAKE)
1032 artifact_type *a_ptr = NULL;
1034 if (!drop_chosen_item) break;
1038 switch (randint0(3))
1041 a_idx = ART_NAMAKE_HAMMER;
1044 a_idx = ART_NAMAKE_BOW;
1047 a_idx = ART_NAMAKE_ARMOR;
1051 a_ptr = &a_info[a_idx];
1053 while (a_ptr->cur_num);
1055 /* Create the artifact */
1056 if (create_named_art(a_idx, y, x))
1060 /* Hack -- Memorize location of artifact in saved floors */
1061 if (character_dungeon) a_ptr->floor_id = p_ptr->floor_id;
1063 else if (!preserve_mode) a_ptr->cur_num = 1;
1068 if (!drop_chosen_item) break;
1070 /* Get local object */
1073 /* Mega-Hack -- Prepare to make "Grond" */
1074 object_prep(q_ptr, lookup_kind(TV_HAFTED, SV_GROND));
1076 /* Mega-Hack -- Mark this item as "Grond" */
1077 q_ptr->name1 = ART_GROND;
1079 /* Mega-Hack -- Actually create "Grond" */
1080 apply_magic(q_ptr, -1, AM_GOOD | AM_GREAT);
1082 /* Drop it in the dungeon */
1083 (void)drop_near(q_ptr, -1, y, x);
1085 /* Get local object */
1088 /* Mega-Hack -- Prepare to make "Chaos" */
1089 object_prep(q_ptr, lookup_kind(TV_CROWN, SV_CHAOS));
1091 /* Mega-Hack -- Mark this item as "Chaos" */
1092 q_ptr->name1 = ART_CHAOS;
1094 /* Mega-Hack -- Actually create "Chaos" */
1095 apply_magic(q_ptr, -1, AM_GOOD | AM_GREAT);
1097 /* Drop it in the dungeon */
1098 (void)drop_near(q_ptr, -1, y, x);
1101 case MON_B_DEATH_SWORD:
1102 if (drop_chosen_item)
1104 /* Get local object */
1107 /* Prepare to make a broken sword */
1108 object_prep(q_ptr, lookup_kind(TV_SWORD, randint1(2)));
1110 /* Drop it in the dungeon */
1111 (void)drop_near(q_ptr, -1, y, x);
1117 if (drop_chosen_item && ((m_ptr->r_idx == MON_A_GOLD) ||
1118 ((m_ptr->r_idx == MON_A_SILVER) && (r_ptr->r_akills % 5 == 0))))
1120 /* Get local object */
1123 /* Prepare to make a Can of Toys */
1124 object_prep(q_ptr, lookup_kind(TV_CHEST, SV_CHEST_KANDUME));
1126 apply_magic(q_ptr, object_level, AM_NO_FIXED_ART);
1128 /* Drop it in the dungeon */
1129 (void)drop_near(q_ptr, -1, y, x);
1135 int flg = PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL;
1136 (void)project(m_idx, 3, y, x, damroll(20, 10), GF_FIRE, flg, -1);
1141 if (!drop_chosen_item) break;
1143 switch (r_ptr->d_char)
1148 /* Get local object */
1151 /* Wipe the object */
1154 /* Activate restriction */
1155 get_obj_num_hook = kind_is_cloak;
1158 make_object(q_ptr, mo_mode);
1160 /* Drop it in the dungeon */
1161 (void)drop_near(q_ptr, -1, y, x);
1168 /* Get local object */
1171 /* Wipe the object */
1174 /* Activate restriction */
1175 get_obj_num_hook = kind_is_polearm;
1177 /* Make a poleweapon */
1178 make_object(q_ptr, mo_mode);
1180 /* Drop it in the dungeon */
1181 (void)drop_near(q_ptr, -1, y, x);
1188 /* Get local object */
1191 /* Wipe the object */
1194 /* Activate restriction */
1195 get_obj_num_hook = kind_is_armor;
1197 /* Make a hard armor */
1198 make_object(q_ptr, mo_mode);
1200 /* Drop it in the dungeon */
1201 (void)drop_near(q_ptr, -1, y, x);
1208 /* Get local object */
1211 /* Wipe the object */
1214 /* Activate restriction */
1215 get_obj_num_hook = kind_is_hafted;
1217 /* Make a hafted weapon */
1218 make_object(q_ptr, mo_mode);
1220 /* Drop it in the dungeon */
1221 (void)drop_near(q_ptr, -1, y, x);
1226 if (m_ptr->r_idx != MON_STORMBRINGER)
1228 /* Get local object */
1231 /* Wipe the object */
1234 /* Activate restriction */
1235 get_obj_num_hook = kind_is_sword;
1238 make_object(q_ptr, mo_mode);
1240 /* Drop it in the dungeon */
1241 (void)drop_near(q_ptr, -1, y, x);
1248 /* Mega-Hack -- drop fixed items */
1249 if (drop_chosen_item)
1254 for(i = 0; i < 4; i++)
1256 if(!r_ptr->artifact_id[i]) break;
1257 a_idx = r_ptr->artifact_id[i];
1258 chance = r_ptr->artifact_percent[i];
1261 if ((a_idx > 0) && ((randint0(100) < chance) || p_ptr->wizard))
1263 artifact_type *a_ptr = &a_info[a_idx];
1265 if (!a_ptr->cur_num)
1267 /* Create the artifact */
1268 if (create_named_art(a_idx, y, x))
1272 /* Hack -- Memorize location of artifact in saved floors */
1273 if (character_dungeon) a_ptr->floor_id = p_ptr->floor_id;
1275 else if (!preserve_mode) a_ptr->cur_num = 1;
1279 if ((r_ptr->flags7 & RF7_GUARDIAN) && (d_info[dungeon_type].final_guardian == m_ptr->r_idx))
1281 IDX k_idx = d_info[dungeon_type].final_object ? d_info[dungeon_type].final_object
1282 : lookup_kind(TV_SCROLL, SV_SCROLL_ACQUIREMENT);
1284 if (d_info[dungeon_type].final_artifact)
1286 a_idx = d_info[dungeon_type].final_artifact;
1287 artifact_type *a_ptr = &a_info[a_idx];
1289 if (!a_ptr->cur_num)
1291 /* Create the artifact */
1292 if (create_named_art(a_idx, y, x))
1296 /* Hack -- Memorize location of artifact in saved floors */
1297 if (character_dungeon) a_ptr->floor_id = p_ptr->floor_id;
1299 else if (!preserve_mode) a_ptr->cur_num = 1;
1301 /* Prevent rewarding both artifact and "default" object */
1302 if (!d_info[dungeon_type].final_object) k_idx = 0;
1308 /* Get local object */
1311 /* Prepare to make a reward */
1312 object_prep(q_ptr, k_idx);
1314 apply_magic(q_ptr, object_level, AM_NO_FIXED_ART | AM_GOOD);
1316 /* Drop it in the dungeon */
1317 (void)drop_near(q_ptr, -1, y, x);
1319 msg_format(_("あなたは%sを制覇した!", "You have conquered %s!"),d_name+d_info[dungeon_type].name);
1323 /* Determine how much we can drop */
1324 if ((r_ptr->flags1 & RF1_DROP_60) && (randint0(100) < 60)) number++;
1325 if ((r_ptr->flags1 & RF1_DROP_90) && (randint0(100) < 90)) number++;
1326 if (r_ptr->flags1 & RF1_DROP_1D2) number += damroll(1, 2);
1327 if (r_ptr->flags1 & RF1_DROP_2D2) number += damroll(2, 2);
1328 if (r_ptr->flags1 & RF1_DROP_3D2) number += damroll(3, 2);
1329 if (r_ptr->flags1 & RF1_DROP_4D2) number += damroll(4, 2);
1331 if (cloned && !(r_ptr->flags1 & RF1_UNIQUE))
1332 number = 0; /* Clones drop no stuff unless Cloning Pits */
1334 if (is_pet(m_ptr) || p_ptr->inside_battle || p_ptr->inside_arena)
1335 number = 0; /* Pets drop no stuff */
1336 if (!drop_item && (r_ptr->d_char != '$')) number = 0;
1338 if((r_ptr->flags2 & (RF2_MULTIPLY)) && (r_ptr->r_akills > 1024))
1339 number = 0; /* Limit of Multiply monster drop */
1341 /* Hack -- handle creeping coins */
1342 coin_type = force_coin;
1344 /* Average dungeon and monster levels */
1345 object_level = (dun_level + r_ptr->level) / 2;
1347 /* Drop some objects */
1348 for (j = 0; j < number; j++)
1350 /* Get local object */
1353 /* Wipe the object */
1357 if (do_gold && (!do_item || (randint0(100) < 50)))
1359 /* Make some gold */
1360 if (!make_gold(q_ptr)) continue;
1369 /* Make an object */
1370 if (!make_object(q_ptr, mo_mode)) continue;
1376 /* Drop it in the dungeon */
1377 (void)drop_near(q_ptr, -1, y, x);
1380 /* Reset the object level */
1381 object_level = base_level;
1383 /* Reset "coin" type */
1387 /* Take note of any dropped treasure */
1388 if (visible && (dump_item || dump_gold))
1390 /* Take notes on treasure */
1391 lore_treasure(m_idx, dump_item, dump_gold);
1394 /* Only process "Quest Monsters" */
1395 if (!(r_ptr->flags1 & RF1_QUESTOR)) return;
1396 if (p_ptr->inside_battle) return;
1399 if ((m_ptr->r_idx == MON_SERPENT) && !cloned)
1402 p_ptr->total_winner = TRUE;
1404 /* Redraw the "title" */
1405 p_ptr->redraw |= (PR_TITLE);
1407 play_music(TERM_XTRA_MUSIC_BASIC, MUSIC_BASIC_FINAL_QUEST_CLEAR);
1409 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, _("見事に変愚蛮怒の勝利者となった!", "become *WINNER* of Hengband finely!"));
1411 if ((p_ptr->pclass == CLASS_CHAOS_WARRIOR) || (p_ptr->muta2 & MUT2_CHAOS_GIFT))
1413 msg_format(_("%sからの声が響いた。", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
1414 msg_print(_("『よくやった、定命の者よ!』", "'Thou art donst well, mortal!'"));
1417 /* Congratulations */
1418 msg_print(_("*** おめでとう ***", "*** CONGRATULATIONS ***"));
1419 msg_print(_("あなたはゲームをコンプリートしました。", "You have won the game!"));
1420 msg_print(_("準備が整ったら引退(自殺コマンド)しても結構です。", "You may retire (commit suicide) when you are ready."));
1425 * @brief モンスターに与えたダメージの修正処理 /
1426 * Modify the physical damage done to the monster.
1427 * @param m_ptr ダメージを受けるモンスターの構造体参照ポインタ
1428 * @param dam ダメージ基本値
1429 * @param is_psy_spear 攻撃手段が光の剣ならばTRUE
1430 * @return 修正を行った結果のダメージ量
1433 * (for example when it's invulnerable or shielded)
1434 * ToDo: Accept a damage-type to calculate the modified damage from
1435 * things like fire, frost, lightning, poison, ... attacks.
1436 * "type" is not yet used and should be 0.
1439 HIT_POINT mon_damage_mod(monster_type *m_ptr, HIT_POINT dam, bool is_psy_spear)
1441 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1443 if ((r_ptr->flagsr & RFR_RES_ALL) && dam > 0)
1446 if ((dam == 0) && one_in_(3)) dam = 1;
1449 if (MON_INVULNER(m_ptr))
1453 if (!p_ptr->blind && is_seen(m_ptr))
1455 msg_print(_("バリアを切り裂いた!", "The barrier is penetrated!"));
1458 else if (!one_in_(PENETRATE_INVULNERABILITY))
1468 * @brief モンスターに与えたダメージを元に経験値を加算する /
1469 * Calculate experience point to be get
1470 * @param dam 与えたダメージ量
1471 * @param m_ptr ダメージを与えたモンスターの構造体参照ポインタ
1475 * Even the 64 bit operation is not big enough to avoid overflaw
1476 * unless we carefully choose orders of multiplication and division.
1477 * Get the coefficient first, and multiply (potentially huge) base
1478 * experience point of a monster later.
1481 static void get_exp_from_mon(int dam, monster_type *m_ptr)
1483 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1490 if (!m_ptr->r_idx) return;
1491 if (is_pet(m_ptr) || p_ptr->inside_battle) return;
1494 * - Ratio of monster's level to player's level effects
1495 * - Varying speed effects
1496 * - Get a fraction in proportion of damage point
1498 new_exp = r_ptr->level * SPEED_TO_ENERGY(m_ptr->mspeed) * dam;
1501 div_l = (p_ptr->max_plv+2) * SPEED_TO_ENERGY(r_ptr->speed);
1503 /* Use (average maxhp * 2) as a denominator */
1504 if (!(r_ptr->flags1 & RF1_FORCE_MAXHP))
1505 s64b_mul(&div_h, &div_l, 0, r_ptr->hdice * (ironman_nightmare ? 2 : 1) * (r_ptr->hside + 1));
1507 s64b_mul(&div_h, &div_l, 0, r_ptr->hdice * (ironman_nightmare ? 2 : 1) * r_ptr->hside * 2);
1509 /* Special penalty in the wilderness */
1510 if (!dun_level && (!(r_ptr->flags8 & RF8_WILD_ONLY) || !(r_ptr->flags1 & RF1_UNIQUE)))
1511 s64b_mul(&div_h, &div_l, 0, 5);
1513 /* Do division first to prevent overflaw */
1514 s64b_div(&new_exp, &new_exp_frac, div_h, div_l);
1516 /* Special penalty for mutiply-monster */
1517 if ((r_ptr->flags2 & RF2_MULTIPLY) || (m_ptr->r_idx == MON_DAWN))
1519 int monnum_penarty = r_ptr->r_akills / 400;
1520 if (monnum_penarty > 8) monnum_penarty = 8;
1522 while (monnum_penarty--)
1525 s64b_RSHIFT(new_exp, new_exp_frac, 2);
1529 /* Special penalty for rest_and_shoot exp scum */
1530 if ((m_ptr->dealt_damage > (u32b)m_ptr->max_maxhp) && (m_ptr->hp >= 0))
1532 int over_damage = m_ptr->dealt_damage / m_ptr->max_maxhp;
1533 if (over_damage > 32) over_damage = 32;
1535 while (over_damage--)
1538 s64b_mul(&new_exp, &new_exp_frac, 0, 9);
1539 s64b_div(&new_exp, &new_exp_frac, 0, 10);
1543 /* Finally multiply base experience point of the monster */
1544 s64b_mul(&new_exp, &new_exp_frac, 0, r_ptr->mexp);
1546 /* Gain experience */
1547 gain_exp_64(new_exp, new_exp_frac);
1552 * @brief モンスターのHPをダメージに応じて減算する /
1553 * Decreases monsters hit points, handling monster death.
1554 * @param dam 与えたダメージ量
1555 * @param m_idx ダメージを与えたモンスターのID
1556 * @param fear ダメージによってモンスターが恐慌状態に陥ったならばTRUEを返す
1557 * @param note モンスターが倒された際の特別なメッセージ述語
1561 * We return TRUE if the monster has been killed (and deleted).
1562 * We announce monster death (using an optional "death message"
1563 * if given, and a otherwise a generic killed/destroyed message).
1564 * Only "physical attacks" can induce the "You have slain" message.
1565 * Missile and Spell attacks will induce the "dies" message, or
1566 * various "specialized" messages. Note that "You have destroyed"
1567 * and "is destroyed" are synonyms for "You have slain" and "dies".
1568 * Hack -- unseen monsters yield "You have killed it." message.
1569 * Added fear (DGK) and check whether to print fear messages -CWS
1570 * Made name, sex, and capitalization generic -BEN-
1571 * As always, the "ghost" processing is a total hack.
1572 * Hack -- we "delay" fear messages by passing around a "fear" flag.
1573 * XXX XXX XXX Consider decreasing monster experience over time, say,
1574 * by using "(m_exp * m_lev * (m_lev)) / (p_lev * (m_lev + n_killed))"
1575 * instead of simply "(m_exp * m_lev) / (p_lev)", to make the first
1576 * monster worth more than subsequent monsters. This would also need
1577 * to induce changes in the monster recall code.
1580 bool mon_take_hit(MONSTER_IDX m_idx, int dam, bool *fear, cptr note)
1582 monster_type *m_ptr = &m_list[m_idx];
1583 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1585 monster_type exp_mon;
1587 /* Innocent until proven otherwise */
1588 bool innocent = TRUE, thief = FALSE;
1593 (void)COPY(&exp_mon, m_ptr, monster_type);
1595 expdam = (m_ptr->hp > dam) ? dam : m_ptr->hp;
1597 get_exp_from_mon(expdam, &exp_mon);
1599 /* Genocided by chaos patron */
1600 if (!m_ptr->r_idx) m_idx = 0;
1602 /* Redraw (later) if needed */
1603 if (p_ptr->health_who == m_idx) p_ptr->redraw |= (PR_HEALTH);
1604 if (p_ptr->riding == m_idx) p_ptr->redraw |= (PR_UHEALTH);
1607 (void)set_monster_csleep(m_idx, 0);
1609 /* Hack - Cancel any special player stealth magics. -LM- */
1610 if (p_ptr->special_defense & NINJA_S_STEALTH)
1612 set_superstealth(FALSE);
1615 /* Genocided by chaos patron */
1616 if (!m_idx) return TRUE;
1618 /* Remember dealt_damage before this attack*/
1619 dealt_damage = m_ptr->dealt_damage;
1624 m_ptr->dealt_damage += dam;
1625 if(m_ptr->dealt_damage > (u32b)m_ptr->max_maxhp * 100) m_ptr->dealt_damage = m_ptr->max_maxhp * 100;
1628 msg_format( _("合計%d/%dのダメージを与えた。","You do %d (out of %d) damage."),
1629 m_ptr->dealt_damage, m_ptr->maxhp);
1632 /* It is dead now */
1637 if (r_info[m_ptr->r_idx].flags7 & RF7_TANUKI)
1639 /* You might have unmasked Tanuki first time */
1640 r_ptr = &r_info[m_ptr->r_idx];
1641 m_ptr->ap_r_idx = m_ptr->r_idx;
1642 if (r_ptr->r_sights < MAX_SHORT) r_ptr->r_sights++;
1645 if (m_ptr->mflag2 & MFLAG2_CHAMELEON)
1647 /* You might have unmasked Chameleon first time */
1648 r_ptr = real_r_ptr(m_ptr);
1649 if (r_ptr->r_sights < MAX_SHORT) r_ptr->r_sights++;
1652 if (!(m_ptr->smart & SM_CLONED))
1654 /* When the player kills a Unique, it stays dead */
1655 if (r_ptr->flags1 & RF1_UNIQUE)
1659 /* Mega-Hack -- Banor & Lupart */
1660 if ((m_ptr->r_idx == MON_BANOR) || (m_ptr->r_idx == MON_LUPART))
1662 r_info[MON_BANORLUPART].max_num = 0;
1663 r_info[MON_BANORLUPART].r_pkills++;
1664 r_info[MON_BANORLUPART].r_akills++;
1665 if (r_info[MON_BANORLUPART].r_tkills < MAX_SHORT) r_info[MON_BANORLUPART].r_tkills++;
1667 else if (m_ptr->r_idx == MON_BANORLUPART)
1669 r_info[MON_BANOR].max_num = 0;
1670 r_info[MON_BANOR].r_pkills++;
1671 r_info[MON_BANOR].r_akills++;
1672 if (r_info[MON_BANOR].r_tkills < MAX_SHORT) r_info[MON_BANOR].r_tkills++;
1673 r_info[MON_LUPART].max_num = 0;
1674 r_info[MON_LUPART].r_pkills++;
1675 r_info[MON_LUPART].r_akills++;
1676 if (r_info[MON_LUPART].r_tkills < MAX_SHORT) r_info[MON_LUPART].r_tkills++;
1680 /* When the player kills a Nazgul, it stays dead */
1681 else if (r_ptr->flags7 & RF7_NAZGUL) r_ptr->max_num--;
1684 /* Count all monsters killed */
1685 if (r_ptr->r_akills < MAX_SHORT) r_ptr->r_akills++;
1687 /* Recall even invisible uniques or winners */
1688 if ((m_ptr->ml && !p_ptr->image) || (r_ptr->flags1 & RF1_UNIQUE))
1690 /* Count kills this life */
1691 if ((m_ptr->mflag2 & MFLAG2_KAGE) && (r_info[MON_KAGE].r_pkills < MAX_SHORT)) r_info[MON_KAGE].r_pkills++;
1692 else if (r_ptr->r_pkills < MAX_SHORT) r_ptr->r_pkills++;
1694 /* Count kills in all lives */
1695 if ((m_ptr->mflag2 & MFLAG2_KAGE) && (r_info[MON_KAGE].r_tkills < MAX_SHORT)) r_info[MON_KAGE].r_tkills++;
1696 else if (r_ptr->r_tkills < MAX_SHORT) r_ptr->r_tkills++;
1698 /* Hack -- Auto-recall */
1699 monster_race_track(m_ptr->ap_r_idx);
1702 /* Extract monster name */
1703 monster_desc(m_name, m_ptr, MD_TRUE_NAME);
1705 /* Don't kill Amberites */
1706 if ((r_ptr->flags3 & RF3_AMBERITE) && one_in_(2))
1708 int curses = 1 + randint1(3);
1709 bool stop_ty = FALSE;
1712 msg_format(_("%^sは恐ろしい血の呪いをあなたにかけた!", "%^s puts a terrible blood curse on you!"), m_name);
1713 curse_equipment(100, 50);
1717 stop_ty = activate_ty_curse(stop_ty, &count);
1722 if (r_ptr->flags2 & RF2_CAN_SPEAK)
1724 char line_got[1024];
1726 /* Dump a message */
1727 if (!get_rnd_line(_("mondeath_j.txt", "mondeath.txt"), m_ptr->r_idx, line_got))
1729 msg_format("%^s %s", m_name, line_got);
1732 if (m_ptr->r_idx == MON_SERPENT)
1734 /* Make screen dump */
1735 screen_dump = make_screen_dump();
1740 if (!(d_info[dungeon_type].flags1 & DF1_BEGINNER))
1742 if (!dun_level && !ambush_flag && !p_ptr->inside_arena)
1744 chg_virtue(V_VALOUR, -1);
1746 else if (r_ptr->level > dun_level)
1748 if (randint1(10) <= (r_ptr->level - dun_level))
1749 chg_virtue(V_VALOUR, 1);
1751 if (r_ptr->level > 60)
1753 chg_virtue(V_VALOUR, 1);
1755 if (r_ptr->level >= 2 * (p_ptr->lev+1))
1756 chg_virtue(V_VALOUR, 2);
1759 if (r_ptr->flags1 & RF1_UNIQUE)
1761 if (r_ptr->flags3 & (RF3_EVIL | RF3_GOOD)) chg_virtue(V_HARMONY, 2);
1763 if (r_ptr->flags3 & RF3_GOOD)
1765 chg_virtue(V_UNLIFE, 2);
1766 chg_virtue(V_VITALITY, -2);
1769 if (one_in_(3)) chg_virtue(V_INDIVIDUALISM, -1);
1772 if (m_ptr->r_idx == MON_BEGGAR || m_ptr->r_idx == MON_LEPER)
1774 chg_virtue(V_COMPASSION, -1);
1777 if ((r_ptr->flags3 & RF3_GOOD) &&
1778 ((r_ptr->level) / 10 + (3 * dun_level) >= randint1(100)))
1779 chg_virtue(V_UNLIFE, 1);
1781 if (r_ptr->d_char == 'A')
1783 if (r_ptr->flags1 & RF1_UNIQUE)
1784 chg_virtue(V_FAITH, -2);
1785 else if ((r_ptr->level) / 10 + (3 * dun_level) >= randint1(100))
1787 if (r_ptr->flags3 & RF3_GOOD) chg_virtue(V_FAITH, -1);
1788 else chg_virtue(V_FAITH, 1);
1791 else if (r_ptr->flags3 & RF3_DEMON)
1793 if (r_ptr->flags1 & RF1_UNIQUE)
1794 chg_virtue(V_FAITH, 2);
1795 else if ((r_ptr->level) / 10 + (3 * dun_level) >= randint1(100))
1796 chg_virtue(V_FAITH, 1);
1799 if ((r_ptr->flags3 & RF3_UNDEAD) && (r_ptr->flags1 & RF1_UNIQUE))
1800 chg_virtue(V_VITALITY, 2);
1802 if (r_ptr->r_deaths)
1804 if (r_ptr->flags1 & RF1_UNIQUE)
1806 chg_virtue(V_HONOUR, 10);
1808 else if ((r_ptr->level) / 10 + (2 * dun_level) >= randint1(100))
1810 chg_virtue(V_HONOUR, 1);
1813 if ((r_ptr->flags2 & RF2_MULTIPLY) && (r_ptr->r_akills > 1000) && one_in_(10))
1815 chg_virtue(V_VALOUR, -1);
1818 for (i = 0; i < 4; i++)
1820 if (r_ptr->blow[i].d_dice != 0) innocent = FALSE; /* Murderer! */
1822 if ((r_ptr->blow[i].effect == RBE_EAT_ITEM)
1823 || (r_ptr->blow[i].effect == RBE_EAT_GOLD))
1825 thief = TRUE; /* Thief! */
1828 /* The new law says it is illegal to live in the dungeon */
1829 if (r_ptr->level != 0) innocent = FALSE;
1833 if (r_ptr->flags1 & RF1_UNIQUE)
1834 chg_virtue(V_JUSTICE, 3);
1835 else if (1+((r_ptr->level) / 10 + (2 * dun_level))
1837 chg_virtue(V_JUSTICE, 1);
1841 chg_virtue (V_JUSTICE, -1);
1844 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)))
1846 if (one_in_(4)) chg_virtue(V_NATURE, -1);
1849 if ((r_ptr->flags1 & RF1_UNIQUE) && record_destroy_uniq)
1853 sprintf(note_buf, "%s%s", r_name + r_ptr->name, (m_ptr->smart & SM_CLONED) ? "(クローン)" : "");
1855 sprintf(note_buf, "%s%s", r_name + r_ptr->name, (m_ptr->smart & SM_CLONED) ? "(Clone)" : "");
1857 do_cmd_write_nikki(NIKKI_UNIQUE, 0, note_buf);
1863 /* Death by Missile/Spell attack */
1866 msg_format("%^s%s", m_name, note);
1869 /* Death by physical attack -- invisible monster */
1870 else if (!m_ptr->ml)
1873 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
1874 msg_format("せっかくだから%sを殺した。", m_name);
1876 msg_format("%sを殺した。", m_name);
1878 msg_format("You have killed %s.", m_name);
1883 /* Death by Physical attack -- non-living monster */
1884 else if (!monster_living(r_ptr))
1886 bool explode = FALSE;
1888 for (i = 0; i < 4; i++)
1890 if (r_ptr->blow[i].method == RBM_EXPLODE) explode = TRUE;
1893 /* Special note at death */
1895 msg_format(_("%sは爆発して粉々になった。", "%^s explodes into tiny shreds."), m_name);
1899 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
1900 msg_format("せっかくだから%sを倒した。", m_name);
1902 msg_format("%sを倒した。", m_name);
1904 msg_format("You have destroyed %s.", m_name);
1909 /* Death by Physical attack -- living monster */
1913 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
1914 msg_format("せっかくだから%sを葬り去った。", m_name);
1916 msg_format("%sを葬り去った。", m_name);
1918 msg_format("You have slain %s.", m_name);
1922 if ((r_ptr->flags1 & RF1_UNIQUE) && !(m_ptr->smart & SM_CLONED) && !vanilla_town)
1924 for (i = 0; i < MAX_KUBI; i++)
1926 if ((kubi_r_idx[i] == m_ptr->r_idx) && !(m_ptr->mflag2 & MFLAG2_CHAMELEON))
1928 msg_format(_("%sの首には賞金がかかっている。", "There is a price on %s's head."), m_name);
1934 /* Generate treasure */
1935 monster_death(m_idx, TRUE);
1937 /* Mega hack : replace IKETA to BIKETAL */
1938 if ((m_ptr->r_idx == MON_IKETA) &&
1939 !(p_ptr->inside_arena || p_ptr->inside_battle))
1941 int dummy_y = m_ptr->fy;
1942 int dummy_x = m_ptr->fx;
1945 if (is_pet(m_ptr)) mode |= PM_FORCE_PET;
1947 /* Delete the monster */
1948 delete_monster_idx(m_idx);
1950 if (summon_named_creature(0, dummy_y, dummy_x, MON_BIKETAL, mode))
1952 msg_print(_("「ハァッハッハッハ!!私がバイケタルだ!!」", "Uwa-hahaha! *I* am Biketal!"));
1957 /* Delete the monster */
1958 delete_monster_idx(m_idx);
1961 get_exp_from_mon((long)exp_mon.max_maxhp*2, &exp_mon);
1966 /* Monster is dead */
1973 /* Mega-Hack -- Pain cancels fear */
1974 if (MON_MONFEAR(m_ptr) && (dam > 0))
1977 if (set_monster_monfear(m_idx, MON_MONFEAR(m_ptr) - randint1(dam)))
1984 /* Sometimes a monster gets scared by damage */
1985 if (!MON_MONFEAR(m_ptr) && !(r_ptr->flags3 & (RF3_NO_FEAR)))
1987 /* Percentage of fully healthy */
1988 int percentage = (100L * m_ptr->hp) / m_ptr->maxhp;
1991 * Run (sometimes) if at 10% or less of max hit points,
1992 * or (usually) when hit for half its current hit points
1994 if ((randint1(10) >= percentage) ||
1995 ((dam >= m_ptr->hp) && (randint0(100) < 80)))
1997 /* Hack -- note fear */
2000 /* XXX XXX XXX Hack -- Add some timed fear */
2001 (void)set_monster_monfear(m_idx, (randint1(10) +
2002 (((dam >= m_ptr->hp) && (percentage > 7)) ?
2003 20 : ((11 - percentage) * 5))));
2010 if (p_ptr->riding && (p_ptr->riding == m_idx) && (dam > 0))
2014 /* Extract monster name */
2015 monster_desc(m_name, m_ptr, 0);
2017 if (m_ptr->hp > m_ptr->maxhp/3) dam = (dam + 1) / 2;
2018 if (rakuba((dam > 200) ? 200 : dam, FALSE))
2020 msg_format(_("%^sに振り落とされた!", "%^s has thrown you off!"), m_name);
2031 * @brief 現在のコンソール表示の縦横を返す。 /
2032 * Get term size and calculate screen size
2033 * @param wid_p コンソールの表示幅文字数を返す
2034 * @param hgt_p コンソールの表示行数を返す
2037 void get_screen_size(int *wid_p, int *hgt_p)
2039 Term_get_size(wid_p, hgt_p);
2040 *hgt_p -= ROW_MAP + 2;
2041 *wid_p -= COL_MAP + 2;
2042 if (use_bigtile) *wid_p /= 2;
2047 * @brief コンソール上におけるマップ表示の左上位置を返す /
2048 * Calculates current boundaries Called below and from "do_cmd_locate()".
2051 void panel_bounds_center(void)
2056 get_screen_size(&wid, &hgt);
2058 panel_row_max = panel_row_min + hgt - 1;
2059 panel_row_prt = panel_row_min - 1;
2060 panel_col_max = panel_col_min + wid - 1;
2061 panel_col_prt = panel_col_min - 13;
2066 * @brief コンソールのリサイズに合わせてマップを再描画する /
2067 * Map resizing whenever the main term changes size
2070 void resize_map(void)
2072 /* Only if the dungeon exists */
2073 if (!character_dungeon) return;
2075 /* Mega-Hack -- no panel yet */
2079 /* Reset the panels */
2080 panel_row_min = cur_hgt;
2081 panel_col_min = cur_wid;
2086 p_ptr->update |= (PU_TORCH | PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
2088 /* Forget lite/view */
2089 p_ptr->update |= (PU_UN_VIEW | PU_UN_LITE);
2091 /* Update lite/view */
2092 p_ptr->update |= (PU_VIEW | PU_LITE | PU_MON_LITE);
2094 /* Update monsters */
2095 p_ptr->update |= (PU_MONSTERS);
2097 /* Redraw everything */
2098 p_ptr->redraw |= (PR_WIPE | PR_BASIC | PR_EXTRA | PR_MAP | PR_EQUIPPY);
2100 /* Hack -- update */
2108 * Place the cursor on the player
2110 if (can_save) move_cursor_relative(p_ptr->y, p_ptr->x);
2117 * @brief コンソールを再描画する /
2118 * Redraw a term when it is resized
2121 void redraw_window(void)
2123 /* Only if the dungeon exists */
2124 if (!character_dungeon) return;
2127 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_SPELL | PW_PLAYER);
2130 p_ptr->window |= (PW_MESSAGE | PW_OVERHEAD | PW_DUNGEON | PW_MONSTER | PW_OBJECT);
2132 /* Hack -- update */
2141 * @brief フォーカスを当てるべきマップ描画の基準座標を指定する(サブルーチン)
2142 * @param dy 変更先のフロアY座標
2143 * @param dx 変更先のフロアX座標
2144 * Handle a request to change the current panel
2145 * Return TRUE if the panel was changed.
2146 * Also used in do_cmd_locate
2147 * @return 実際に再描画が必要だった場合TRUEを返す
2149 bool change_panel(int dy, int dx)
2155 get_screen_size(&wid, &hgt);
2157 /* Apply the motion */
2158 y = panel_row_min + dy * hgt / 2;
2159 x = panel_col_min + dx * wid / 2;
2161 /* Verify the row */
2162 if (y > cur_hgt - hgt) y = cur_hgt - hgt;
2165 /* Verify the col */
2166 if (x > cur_wid - wid) x = cur_wid - wid;
2169 /* Handle "changes" */
2170 if ((y != panel_row_min) || (x != panel_col_min))
2172 /* Save the new panel info */
2176 /* Recalculate the boundaries */
2177 panel_bounds_center();
2180 p_ptr->update |= (PU_MONSTERS);
2183 p_ptr->redraw |= (PR_MAP);
2197 * @brief フォーカスを当てるべきマップ描画の基準座標を指定する
2198 * @param y 変更先のフロアY座標
2199 * @param x 変更先のフロアX座標
2201 * Handle a request to change the current panel
2202 * Return TRUE if the panel was changed.
2203 * Also used in do_cmd_locate
2204 * @return 実際に再描画が必要だった場合TRUEを返す
2206 bool change_panel_xy(int y, int x)
2212 get_screen_size(&wid, &hgt);
2214 if (y < panel_row_min) dy = -1;
2215 if (y > panel_row_max) dy = 1;
2216 if (x < panel_col_min) dx = -1;
2217 if (x > panel_col_max) dx = 1;
2219 if (!dy && !dx) return (FALSE);
2221 return change_panel(dy, dx);
2226 * @brief マップ描画のフォーカスを当てるべき座標を更新する
2228 * Given an row (y) and col (x), this routine detects when a move
2229 * off the screen has occurred and figures new borders. -RAK-
2230 * "Update" forces a "full update" to take place.
2231 * The map is reprinted if necessary, and "TRUE" is returned.
2232 * @return 実際に再描画が必要だった場合TRUEを返す
2234 void verify_panel(void)
2246 get_screen_size(&wid, &hgt);
2248 max_prow_min = cur_hgt - hgt;
2249 max_pcol_min = cur_wid - wid;
2251 /* Bounds checking */
2252 if (max_prow_min < 0) max_prow_min = 0;
2253 if (max_pcol_min < 0) max_pcol_min = 0;
2255 /* Center on player */
2256 if (center_player && (center_running || !running))
2258 /* Center vertically */
2259 prow_min = y - hgt / 2;
2260 if (prow_min < 0) prow_min = 0;
2261 else if (prow_min > max_prow_min) prow_min = max_prow_min;
2263 /* Center horizontally */
2264 pcol_min = x - wid / 2;
2265 if (pcol_min < 0) pcol_min = 0;
2266 else if (pcol_min > max_pcol_min) pcol_min = max_pcol_min;
2270 prow_min = panel_row_min;
2271 pcol_min = panel_col_min;
2273 /* Scroll screen when 2 grids from top/bottom edge */
2274 if (y > panel_row_max - 2)
2276 while (y > prow_min + hgt-1 - 2)
2278 prow_min += (hgt / 2);
2282 if (y < panel_row_min + 2)
2284 while (y < prow_min + 2)
2286 prow_min -= (hgt / 2);
2290 if (prow_min > max_prow_min) prow_min = max_prow_min;
2291 if (prow_min < 0) prow_min = 0;
2293 /* Scroll screen when 4 grids from left/right edge */
2294 if (x > panel_col_max - 4)
2296 while (x > pcol_min + wid-1 - 4)
2298 pcol_min += (wid / 2);
2302 if (x < panel_col_min + 4)
2304 while (x < pcol_min + 4)
2306 pcol_min -= (wid / 2);
2310 if (pcol_min > max_pcol_min) pcol_min = max_pcol_min;
2311 if (pcol_min < 0) pcol_min = 0;
2314 /* Check for "no change" */
2315 if ((prow_min == panel_row_min) && (pcol_min == panel_col_min)) return;
2317 /* Save the new panel info */
2318 panel_row_min = prow_min;
2319 panel_col_min = pcol_min;
2321 /* Hack -- optional disturb on "panel change" */
2322 if (disturb_panel && !center_player) disturb(0, 0);
2324 /* Recalculate the boundaries */
2325 panel_bounds_center();
2328 p_ptr->update |= (PU_MONSTERS);
2331 p_ptr->redraw |= (PR_MAP);
2334 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
2339 * Monster health description
2341 cptr look_mon_desc(monster_type *m_ptr, u32b mode)
2343 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
2350 /* Determine if the monster is "living" */
2351 living = monster_living(ap_r_ptr);
2353 /* Calculate a health "percentage" */
2354 perc = 100L * m_ptr->hp / m_ptr->maxhp;
2356 /* Healthy monsters */
2357 if (m_ptr->hp >= m_ptr->maxhp)
2361 desc = living ? "無傷" : "無ダメージ";
2363 desc = living ? "unhurt" : "undamaged";
2368 else if (perc >= 60)
2371 desc = living ? "軽傷" : "小ダメージ";
2373 desc = living ? "somewhat wounded" : "somewhat damaged";
2378 else if (perc >= 25)
2381 desc = living ? "負傷" : "中ダメージ";
2383 desc = living ? "wounded" : "damaged";
2388 else if (perc >= 10)
2391 desc = living ? "重傷" : "大ダメージ";
2393 desc = living ? "badly wounded" : "badly damaged";
2401 desc = living ? "半死半生" : "倒れかけ";
2403 desc = living ? "almost dead" : "almost destroyed";
2408 /* Need attitude information? */
2411 /* Full information is not needed */
2414 else if (is_pet(m_ptr))
2416 attitude = _(", ペット", ", pet");
2418 else if (is_friendly(m_ptr))
2420 attitude = _(", 友好的", ", friendly");
2424 attitude = _("", "");
2428 /* Clone monster? */
2429 if (m_ptr->smart & SM_CLONED)
2438 /* Display monster's level --- idea borrowed from ToME */
2439 if (ap_r_ptr->r_tkills && !(m_ptr->mflag2 & MFLAG2_KAGE))
2441 return format(_("レベル%d, %s%s%s", "Level %d, %s%s%s"), ap_r_ptr->level, desc, attitude, clone);
2445 return format(_("レベル???, %s%s%s", "Level ???, %s%s%s"), desc, attitude, clone);
2452 * Angband sorting algorithm -- quick sort in place
2454 * Note that the details of the data we are sorting is hidden,
2455 * and we rely on the "ang_sort_comp()" and "ang_sort_swap()"
2456 * function hooks to interact with the data, which is given as
2457 * two pointers, and which may have any user-defined form.
2459 void ang_sort_aux(vptr u, vptr v, int p, int q)
2477 while (!(*ang_sort_comp)(u, v, b, z)) b--;
2480 while (!(*ang_sort_comp)(u, v, z, a)) a++;
2482 /* Done partition */
2486 (*ang_sort_swap)(u, v, a, b);
2492 /* Recurse left side */
2493 ang_sort_aux(u, v, p, b);
2495 /* Recurse right side */
2496 ang_sort_aux(u, v, b+1, q);
2501 * Angband sorting algorithm -- quick sort in place
2503 * Note that the details of the data we are sorting is hidden,
2504 * and we rely on the "ang_sort_comp()" and "ang_sort_swap()"
2505 * function hooks to interact with the data, which is given as
2506 * two pointers, and which may have any user-defined form.
2508 void ang_sort(vptr u, vptr v, int n)
2510 /* Sort the array */
2511 ang_sort_aux(u, v, 0, n-1);
2516 /*** Targeting Code ***/
2520 * Determine is a monster makes a reasonable target
2522 * The concept of "targeting" was stolen from "Morgul" (?)
2524 * The player can target any location, or any "target-able" monster.
2526 * Currently, a monster is "target_able" if it is visible, and if
2527 * the player can hit it with a projection, and the player is not
2528 * hallucinating. This allows use of "use closest target" macros.
2530 * Future versions may restrict the ability to target "trappers"
2531 * and "mimics", but the semantics is a little bit weird.
2533 bool target_able(MONSTER_IDX m_idx)
2535 monster_type *m_ptr = &m_list[m_idx];
2537 /* Monster must be alive */
2538 if (!m_ptr->r_idx) return (FALSE);
2540 /* Hack -- no targeting hallucinations */
2541 if (p_ptr->image) return (FALSE);
2543 /* Monster must be visible */
2544 if (!m_ptr->ml) return (FALSE);
2546 if (p_ptr->riding && (p_ptr->riding == m_idx)) return (TRUE);
2548 /* Monster must be projectable */
2549 if (!projectable(p_ptr->y, p_ptr->x, m_ptr->fy, m_ptr->fx)) return (FALSE);
2551 /* XXX XXX XXX Hack -- Never target trappers */
2552 /* if (CLEAR_ATTR && (CLEAR_CHAR)) return (FALSE); */
2562 * Update (if necessary) and verify (if possible) the target.
2564 * We return TRUE if the target is "okay" and FALSE otherwise.
2566 bool target_okay(void)
2568 /* Accept stationary targets */
2569 if (target_who < 0) return (TRUE);
2571 /* Check moving targets */
2574 /* Accept reasonable targets */
2575 if (target_able(target_who))
2577 monster_type *m_ptr = &m_list[target_who];
2579 /* Acquire monster location */
2580 target_row = m_ptr->fy;
2581 target_col = m_ptr->fx;
2588 /* Assume no target */
2594 * Sorting hook -- comp function -- by "distance to player"
2596 * We use "u" and "v" to point to arrays of "x" and "y" positions,
2597 * and sort the arrays by double-distance to the player.
2599 static bool ang_sort_comp_distance(vptr u, vptr v, int a, int b)
2601 byte *x = (byte*)(u);
2602 byte *y = (byte*)(v);
2606 /* Absolute distance components */
2607 kx = x[a]; kx -= p_ptr->x; kx = ABS(kx);
2608 ky = y[a]; ky -= p_ptr->y; ky = ABS(ky);
2610 /* Approximate Double Distance to the first point */
2611 da = ((kx > ky) ? (kx + kx + ky) : (ky + ky + kx));
2613 /* Absolute distance components */
2614 kx = x[b]; kx -= p_ptr->x; kx = ABS(kx);
2615 ky = y[b]; ky -= p_ptr->y; ky = ABS(ky);
2617 /* Approximate Double Distance to the first point */
2618 db = ((kx > ky) ? (kx + kx + ky) : (ky + ky + kx));
2620 /* Compare the distances */
2626 * Sorting hook -- comp function -- by importance level of grids
2628 * We use "u" and "v" to point to arrays of "x" and "y" positions,
2629 * and sort the arrays by level of monster
2631 static bool ang_sort_comp_importance(vptr u, vptr v, int a, int b)
2633 byte *x = (byte*)(u);
2634 byte *y = (byte*)(v);
2635 cave_type *ca_ptr = &cave[y[a]][x[a]];
2636 cave_type *cb_ptr = &cave[y[b]][x[b]];
2637 monster_type *ma_ptr = &m_list[ca_ptr->m_idx];
2638 monster_type *mb_ptr = &m_list[cb_ptr->m_idx];
2639 monster_race *ap_ra_ptr, *ap_rb_ptr;
2641 /* The player grid */
2642 if (y[a] == p_ptr->y && x[a] == p_ptr->x) return TRUE;
2643 if (y[b] == p_ptr->y && x[b] == p_ptr->x) return FALSE;
2645 /* Extract monster race */
2646 if (ca_ptr->m_idx && ma_ptr->ml) ap_ra_ptr = &r_info[ma_ptr->ap_r_idx];
2647 else ap_ra_ptr = NULL;
2648 if (cb_ptr->m_idx && mb_ptr->ml) ap_rb_ptr = &r_info[mb_ptr->ap_r_idx];
2649 else ap_rb_ptr = NULL;
2651 if (ap_ra_ptr && !ap_rb_ptr) return TRUE;
2652 if (!ap_ra_ptr && ap_rb_ptr) return FALSE;
2654 /* Compare two monsters */
2655 if (ap_ra_ptr && ap_rb_ptr)
2657 /* Unique monsters first */
2658 if ((ap_ra_ptr->flags1 & RF1_UNIQUE) && !(ap_rb_ptr->flags1 & RF1_UNIQUE)) return TRUE;
2659 if (!(ap_ra_ptr->flags1 & RF1_UNIQUE) && (ap_rb_ptr->flags1 & RF1_UNIQUE)) return FALSE;
2661 /* Shadowers first (あやしい影) */
2662 if ((ma_ptr->mflag2 & MFLAG2_KAGE) && !(mb_ptr->mflag2 & MFLAG2_KAGE)) return TRUE;
2663 if (!(ma_ptr->mflag2 & MFLAG2_KAGE) && (mb_ptr->mflag2 & MFLAG2_KAGE)) return FALSE;
2665 /* Unknown monsters first */
2666 if (!ap_ra_ptr->r_tkills && ap_rb_ptr->r_tkills) return TRUE;
2667 if (ap_ra_ptr->r_tkills && !ap_rb_ptr->r_tkills) return FALSE;
2669 /* Higher level monsters first (if known) */
2670 if (ap_ra_ptr->r_tkills && ap_rb_ptr->r_tkills)
2672 if (ap_ra_ptr->level > ap_rb_ptr->level) return TRUE;
2673 if (ap_ra_ptr->level < ap_rb_ptr->level) return FALSE;
2676 /* Sort by index if all conditions are same */
2677 if (ma_ptr->ap_r_idx > mb_ptr->ap_r_idx) return TRUE;
2678 if (ma_ptr->ap_r_idx < mb_ptr->ap_r_idx) return FALSE;
2681 /* An object get higher priority */
2682 if (cave[y[a]][x[a]].o_idx && !cave[y[b]][x[b]].o_idx) return TRUE;
2683 if (!cave[y[a]][x[a]].o_idx && cave[y[b]][x[b]].o_idx) return FALSE;
2685 /* Priority from the terrain */
2686 if (f_info[ca_ptr->feat].priority > f_info[cb_ptr->feat].priority) return TRUE;
2687 if (f_info[ca_ptr->feat].priority < f_info[cb_ptr->feat].priority) return FALSE;
2689 /* If all conditions are same, compare distance */
2690 return ang_sort_comp_distance(u, v, a, b);
2695 * Sorting hook -- swap function -- by "distance to player"
2697 * We use "u" and "v" to point to arrays of "x" and "y" positions,
2698 * and sort the arrays by distance to the player.
2700 static void ang_sort_swap_distance(vptr u, vptr v, int a, int b)
2702 byte *x = (byte*)(u);
2703 byte *y = (byte*)(v);
2721 * Hack -- help "select" a location (see below)
2723 static s16b target_pick(POSITION y1, POSITION x1, POSITION dy, POSITION dx)
2727 int x2, y2, x3, y3, x4, y4;
2729 int b_i = -1, b_v = 9999;
2732 /* Scan the locations */
2733 for (i = 0; i < temp_n; i++)
2739 /* Directed distance */
2743 /* Verify quadrant */
2744 if (dx && (x3 * dx <= 0)) continue;
2745 if (dy && (y3 * dy <= 0)) continue;
2747 /* Absolute distance */
2751 /* Verify quadrant */
2752 if (dy && !dx && (x4 > y4)) continue;
2753 if (dx && !dy && (y4 > x4)) continue;
2755 /* Approximate Double Distance */
2756 v = ((x4 > y4) ? (x4 + x4 + y4) : (y4 + y4 + x4));
2758 /* XXX XXX XXX Penalize location */
2761 if ((b_i >= 0) && (v >= b_v)) continue;
2773 * Hack -- determine if a given location is "interesting"
2775 static bool target_set_accept(int y, int x)
2779 s16b this_o_idx, next_o_idx = 0;
2782 if (!(in_bounds(y, x))) return (FALSE);
2784 /* Player grid is always interesting */
2785 if (player_bold(y, x)) return (TRUE);
2788 /* Handle hallucination */
2789 if (p_ptr->image) return (FALSE);
2792 /* Examine the grid */
2793 c_ptr = &cave[y][x];
2795 /* Visible monsters */
2798 monster_type *m_ptr = &m_list[c_ptr->m_idx];
2800 /* Visible monsters */
2801 if (m_ptr->ml) return (TRUE);
2804 /* Scan all objects in the grid */
2805 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
2809 /* Acquire object */
2810 o_ptr = &o_list[this_o_idx];
2812 /* Acquire next object */
2813 next_o_idx = o_ptr->next_o_idx;
2815 /* Memorized object */
2816 if (o_ptr->marked & OM_FOUND) return (TRUE);
2819 /* Interesting memorized features */
2820 if (c_ptr->info & (CAVE_MARK))
2822 /* Notice object features */
2823 if (c_ptr->info & CAVE_OBJECT) return (TRUE);
2825 /* Feature code (applying "mimic" field) */
2826 if (have_flag(f_info[get_feat_mimic(c_ptr)].flags, FF_NOTICE)) return TRUE;
2835 * Prepare the "temp" array for "target_set"
2837 * Return the number of target_able monsters in the set.
2839 static void target_set_prepare(int mode)
2842 int min_hgt, max_hgt, min_wid, max_wid;
2844 if (mode & TARGET_KILL)
2847 min_hgt = MAX((p_ptr->y - MAX_RANGE), 0);
2848 max_hgt = MIN((p_ptr->y + MAX_RANGE), cur_hgt - 1);
2849 min_wid = MAX((p_ptr->x - MAX_RANGE), 0);
2850 max_wid = MIN((p_ptr->x + MAX_RANGE), cur_wid - 1);
2852 else /* not targetting */
2855 min_hgt = panel_row_min;
2856 max_hgt = panel_row_max;
2857 min_wid = panel_col_min;
2858 max_wid = panel_col_max;
2861 /* Reset "temp" array */
2864 /* Scan the current panel */
2865 for (y = min_hgt; y <= max_hgt; y++)
2867 for (x = min_wid; x <= max_wid; x++)
2871 /* Require "interesting" contents */
2872 if (!target_set_accept(y, x)) continue;
2874 c_ptr = &cave[y][x];
2876 /* Require target_able monsters for "TARGET_KILL" */
2877 if ((mode & (TARGET_KILL)) && !target_able(c_ptr->m_idx)) continue;
2879 if ((mode & (TARGET_KILL)) && !target_pet && is_pet(&m_list[c_ptr->m_idx])) continue;
2881 /* Save the location */
2888 /* Set the sort hooks */
2889 if (mode & (TARGET_KILL))
2891 /* Target the nearest monster for shooting */
2892 ang_sort_comp = ang_sort_comp_distance;
2893 ang_sort_swap = ang_sort_swap_distance;
2897 /* Look important grids first in Look command */
2898 ang_sort_comp = ang_sort_comp_importance;
2899 ang_sort_swap = ang_sort_swap_distance;
2902 /* Sort the positions */
2903 ang_sort(temp_x, temp_y, temp_n);
2905 if (p_ptr->riding && target_pet && (temp_n > 1) && (mode & (TARGET_KILL)))
2910 temp_y[0] = temp_y[1];
2913 temp_x[0] = temp_x[1];
2918 void target_set_prepare_look(void){
2919 target_set_prepare(TARGET_LOOK);
2924 * Evaluate number of kill needed to gain level
2926 static void evaluate_monster_exp(char *buf, monster_type *m_ptr)
2928 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
2930 s32b exp_mon, exp_adv;
2931 u32b exp_mon_frac, exp_adv_frac;
2933 if ((p_ptr->lev >= PY_MAX_LEVEL) || (p_ptr->prace == RACE_ANDROID))
2938 else if (!ap_r_ptr->r_tkills || (m_ptr->mflag2 & MFLAG2_KAGE))
2948 /* The monster's experience point (assuming average monster speed) */
2949 exp_mon = ap_r_ptr->mexp * ap_r_ptr->level;
2951 s64b_div(&exp_mon, &exp_mon_frac, 0, (p_ptr->max_plv + 2));
2954 /* Total experience value for next level */
2955 exp_adv = player_exp[p_ptr->lev -1] * p_ptr->expfact;
2957 s64b_div(&exp_adv, &exp_adv_frac, 0, 100);
2959 /* Experience value need to get */
2960 s64b_sub(&exp_adv, &exp_adv_frac, p_ptr->exp, p_ptr->exp_frac);
2963 /* You need to kill at least one monster to get any experience */
2964 s64b_add(&exp_adv, &exp_adv_frac, exp_mon, exp_mon_frac);
2965 s64b_sub(&exp_adv, &exp_adv_frac, 0, 1);
2967 /* Extract number of monsters needed */
2968 s64b_div(&exp_adv, &exp_adv_frac, exp_mon, exp_mon_frac);
2970 /* If 999 or more monsters needed, only display "999". */
2971 num = MIN(999, exp_adv_frac);
2973 /* Display the number */
2974 sprintf(buf,"%03ld", (long int)num);
2978 bool show_gold_on_floor = FALSE;
2981 * Examine a grid, return a keypress.
2983 * The "mode" argument contains the "TARGET_LOOK" bit flag, which
2984 * indicates that the "space" key should scan through the contents
2985 * of the grid, instead of simply returning immediately. This lets
2986 * the "look" command get complete information, without making the
2987 * "target" command annoying.
2989 * The "info" argument contains the "commands" which should be shown
2990 * inside the "[xxx]" text. This string must never be empty, or grids
2991 * containing monsters will be displayed with an extra comma.
2993 * Note that if a monster is in the grid, we update both the monster
2994 * recall info and the health bar info to track that monster.
2996 * Eventually, we may allow multiple objects per grid, or objects
2997 * and terrain features in the same grid. XXX XXX XXX
2999 * This function must handle blindness/hallucination.
3001 static int target_set_aux(int y, int x, int mode, cptr info)
3003 cave_type *c_ptr = &cave[y][x];
3004 s16b this_o_idx, next_o_idx = 0;
3005 cptr s1 = "", s2 = "", s3 = "", x_info = "";
3008 feature_type *f_ptr;
3010 char out_val[MAX_NLEN+80];
3012 #ifdef ALLOW_EASY_FLOOR
3013 int floor_list[23], floor_num = 0;
3015 /* Scan all objects in the grid */
3018 floor_num = scan_floor(floor_list, y, x, 0x02);
3022 x_info = _("x物 ", "x,");
3026 #endif /* ALLOW_EASY_FLOOR */
3028 /* Hack -- under the player */
3029 if (player_bold(y, x))
3045 s1 = _("ターゲット:", "Target:");
3048 /* Hack -- hallucination */
3051 cptr name = _("何か奇妙な物", "something strange");
3053 /* Display a message */
3055 sprintf(out_val, "%s%s%s%s [%s]", s1, name, s2, s3, info);
3057 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, name, info);
3061 move_cursor_relative(y, x);
3064 /* Stop on everything but "return" */
3065 if ((query != '\r') && (query != '\n')) return query;
3067 /* Repeat forever */
3072 /* Actual monsters */
3073 if (c_ptr->m_idx && m_list[c_ptr->m_idx].ml)
3075 monster_type *m_ptr = &m_list[c_ptr->m_idx];
3076 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
3078 bool recall = FALSE;
3083 /* Get the monster name ("a kobold") */
3084 monster_desc(m_name, m_ptr, MD_INDEF_VISIBLE);
3086 /* Hack -- track this monster race */
3087 monster_race_track(m_ptr->ap_r_idx);
3089 /* Hack -- health bar for this monster */
3090 health_track(c_ptr->m_idx);
3092 /* Hack -- handle stuff */
3106 /* Recall on screen */
3107 screen_roff(m_ptr->ap_r_idx, 0);
3109 /* Hack -- Complete the prompt (again) */
3110 Term_addstr(-1, TERM_WHITE, format(_(" [r思 %s%s]", " [r,%s%s]"), x_info, info));
3118 /* Normal commands */
3119 if (query != 'r') break;
3124 /* Cleare recall text and repeat */
3130 /* Describe, and prompt for recall */
3131 evaluate_monster_exp(acount, m_ptr);
3134 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);
3136 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);
3142 move_cursor_relative(y, x);
3147 /* Normal commands */
3148 if (query != 'r') break;
3154 /* Always stop at "normal" keys */
3155 if ((query != '\r') && (query != '\n') && (query != ' ') && (query != 'x')) return query;
3157 /* Sometimes stop at "space" key */
3158 if ((query == ' ') && !(mode & (TARGET_LOOK))) return query;
3160 /* Change the intro */
3161 s1 = _("それは", "It is ");
3163 /* Hack -- take account of gender */
3164 if (ap_r_ptr->flags1 & (RF1_FEMALE)) s1 = _("彼女は", "She is ");
3165 else if (ap_r_ptr->flags1 & (RF1_MALE)) s1 = _("彼は", "He is ");
3167 /* Use a preposition */
3176 /* Scan all objects being carried */
3177 for (this_o_idx = m_ptr->hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
3179 char o_name[MAX_NLEN];
3183 /* Acquire object */
3184 o_ptr = &o_list[this_o_idx];
3186 /* Acquire next object */
3187 next_o_idx = o_ptr->next_o_idx;
3189 /* Obtain an object description */
3190 object_desc(o_name, o_ptr, 0);
3192 /* Describe the object */
3194 sprintf(out_val, "%s%s%s%s[%s]", s1, o_name, s2, s3, info);
3196 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, o_name, info);
3200 move_cursor_relative(y, x);
3203 /* Always stop at "normal" keys */
3204 if ((query != '\r') && (query != '\n') && (query != ' ') && (query != 'x')) return query;
3206 /* Sometimes stop at "space" key */
3207 if ((query == ' ') && !(mode & (TARGET_LOOK))) return query;
3209 /* Change the intro */
3210 s2 = _("をまた", "also carrying ");
3213 /* Use a preposition */
3223 #ifdef ALLOW_EASY_FLOOR
3232 char o_name[MAX_NLEN];
3236 /* Acquire object */
3237 o_ptr = &o_list[floor_list[0]];
3239 /* Describe the object */
3240 object_desc(o_name, o_ptr, 0);
3244 sprintf(out_val, "%s%s%s%s[%s]",
3245 s1, o_name, s2, s3, info);
3247 sprintf(out_val, "%s%s%s%s [%s]",
3248 s1, s2, s3, o_name, info);
3252 move_cursor_relative(y, x);
3261 /* Provide one cushion before item listing */
3264 /* Display rough information about items */
3266 sprintf(out_val, "%s %d個のアイテム%s%s ['x'で一覧, %s]",
3267 s1, floor_num, s2, s3, info);
3269 sprintf(out_val, "%s%s%sa pile of %d items [x,%s]",
3270 s1, s2, s3, floor_num, info);
3274 move_cursor_relative(y, x);
3279 /* No request for listing */
3280 if (query != 'x' && query != ' ') return query;
3284 /** Display list of items **/
3286 /* Continue scrolling list if requested */
3296 show_gold_on_floor = TRUE;
3297 (void)show_floor(0, y, x, &min_width);
3298 show_gold_on_floor = FALSE;
3302 sprintf(out_val, "%s %d個のアイテム%s%s [Enterで次へ, %s]",
3303 s1, floor_num, s2, s3, info);
3305 sprintf(out_val, "%s%s%sa pile of %d items [Enter,%s]",
3306 s1, s2, s3, floor_num, info);
3317 /* Exit unless 'Enter' */
3318 if (query != '\n' && query != '\r')
3323 /* Get the object being moved. */
3324 o_idx = c_ptr->o_idx;
3326 /* Only rotate a pile of two or more objects. */
3327 if (!(o_idx && o_list[o_idx].next_o_idx)) continue;
3329 /* Remove the first object from the list. */
3330 excise_object_idx(o_idx);
3332 /* Find end of the list. */
3334 while (o_list[i].next_o_idx)
3335 i = o_list[i].next_o_idx;
3337 /* Add after the last object. */
3338 o_list[i].next_o_idx = o_idx;
3340 /* Loop and re-display the list */
3346 #endif /* ALLOW_EASY_FLOOR */
3349 /* Scan all objects in the grid */
3350 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
3354 /* Acquire object */
3355 o_ptr = &o_list[this_o_idx];
3357 /* Acquire next object */
3358 next_o_idx = o_ptr->next_o_idx;
3361 if (o_ptr->marked & OM_FOUND)
3363 char o_name[MAX_NLEN];
3368 /* Obtain an object description */
3369 object_desc(o_name, o_ptr, 0);
3371 /* Describe the object */
3373 sprintf(out_val, "%s%s%s%s[%s]", s1, o_name, s2, s3, info);
3375 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, o_name, info);
3379 move_cursor_relative(y, x);
3382 /* Always stop at "normal" keys */
3383 if ((query != '\r') && (query != '\n') && (query != ' ') && (query != 'x')) return query;
3385 /* Sometimes stop at "space" key */
3386 if ((query == ' ') && !(mode & TARGET_LOOK)) return query;
3388 /* Change the intro */
3389 s1 = _("それは", "It is ");
3392 if (o_ptr->number != 1) s1 = _("それらは", "They are ");
3406 /* Feature code (applying "mimic" field) */
3407 feat = get_feat_mimic(c_ptr);
3409 /* Require knowledge about grid, or ability to see grid */
3410 if (!(c_ptr->info & CAVE_MARK) && !player_can_see_bold(y, x))
3412 /* Forget feature */
3416 f_ptr = &f_info[feat];
3418 /* Terrain feature if needed */
3419 if (boring || have_flag(f_ptr->flags, FF_REMEMBER))
3423 /* Hack -- special handling for quest entrances */
3424 if (have_flag(f_ptr->flags, FF_QUEST_ENTER))
3426 /* Set the quest number temporary */
3427 IDX old_quest = p_ptr->inside_quest;
3430 /* Clear the text */
3431 for (j = 0; j < 10; j++) quest_text[j][0] = '\0';
3432 quest_text_line = 0;
3434 p_ptr->inside_quest = c_ptr->special;
3436 /* Get the quest text */
3437 init_flags = INIT_NAME_ONLY;
3439 process_dungeon_file("q_info.txt", 0, 0, 0, 0);
3441 name = format(_("クエスト「%s」(%d階相当)", "the entrance to the quest '%s'(level %d)"),
3442 quest[c_ptr->special].name, quest[c_ptr->special].level);
3444 /* Reset the old quest number */
3445 p_ptr->inside_quest = old_quest;
3448 /* Hack -- special handling for building doors */
3449 else if (have_flag(f_ptr->flags, FF_BLDG) && !p_ptr->inside_arena)
3451 name = building[f_ptr->subtype].name;
3453 else if (have_flag(f_ptr->flags, FF_ENTRANCE))
3455 name = format(_("%s(%d階相当)", "%s(level %d)"), d_text + d_info[c_ptr->special].text, d_info[c_ptr->special].mindepth);
3457 else if (have_flag(f_ptr->flags, FF_TOWN))
3459 name = town[c_ptr->special].name;
3461 else if (p_ptr->wild_mode && (feat == feat_floor))
3463 name = _("道", "road");
3467 name = f_name + f_ptr->name;
3473 ((!have_flag(f_ptr->flags, FF_MOVE) && !have_flag(f_ptr->flags, FF_CAN_FLY)) ||
3474 (!have_flag(f_ptr->flags, FF_LOS) && !have_flag(f_ptr->flags, FF_TREE)) ||
3475 have_flag(f_ptr->flags, FF_TOWN)))
3477 s2 = _("の中", "in ");
3480 /* Hack -- special introduction for store & building doors -KMW- */
3481 if (have_flag(f_ptr->flags, FF_STORE) ||
3482 have_flag(f_ptr->flags, FF_QUEST_ENTER) ||
3483 (have_flag(f_ptr->flags, FF_BLDG) && !p_ptr->inside_arena) ||
3484 have_flag(f_ptr->flags, FF_ENTRANCE))
3493 else if (have_flag(f_ptr->flags, FF_FLOOR) ||
3494 have_flag(f_ptr->flags, FF_TOWN) ||
3495 have_flag(f_ptr->flags, FF_SHALLOW) ||
3496 have_flag(f_ptr->flags, FF_DEEP))
3502 /* Pick proper indefinite article */
3503 s3 = (is_a_vowel(name[0])) ? "an " : "a ";
3507 /* Display a message */
3511 if (c_ptr->mimic) sprintf(f_idx_str, "%d/%d", c_ptr->feat, c_ptr->mimic);
3512 else sprintf(f_idx_str, "%d", c_ptr->feat);
3514 sprintf(out_val, "%s%s%s%s[%s] %x %s %d %d %d (%d,%d) %d", s1, name, s2, s3, info, c_ptr->info, f_idx_str, c_ptr->dist, c_ptr->cost, c_ptr->when, y, x, travel.cost[y][x]);
3516 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, y, x);
3521 sprintf(out_val, "%s%s%s%s[%s]", s1, name, s2, s3, info);
3523 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, name, info);
3527 move_cursor_relative(y, x);
3530 /* Always stop at "normal" keys */
3531 if ((query != '\r') && (query != '\n') && (query != ' ')) return query;
3534 /* Stop on everything but "return" */
3535 if ((query != '\r') && (query != '\n')) return query;
3537 /* Repeat forever */
3543 * Handle "target" and "look".
3545 * Note that this code can be called from "get_aim_dir()".
3547 * All locations must be on the current panel. Consider the use of
3548 * "panel_bounds()" to allow "off-panel" targets, perhaps by using
3549 * some form of "scrolling" the map around the cursor. XXX XXX XXX
3550 * That is, consider the possibility of "auto-scrolling" the screen
3551 * while the cursor moves around. This may require changes in the
3552 * "update_mon()" code to allow "visibility" even if off panel, and
3553 * may require dynamic recalculation of the "temp" grid set.
3555 * Hack -- targeting/observing an "outer border grid" may induce
3556 * problems, so this is not currently allowed.
3558 * The player can use the direction keys to move among "interesting"
3559 * grids in a heuristic manner, or the "space", "+", and "-" keys to
3560 * move through the "interesting" grids in a sequential manner, or
3561 * can enter "location" mode, and use the direction keys to move one
3562 * grid at a time in any direction. The "t" (set target) command will
3563 * only target a monster (as opposed to a location) if the monster is
3564 * target_able and the "interesting" mode is being used.
3566 * The current grid is described using the "look" method above, and
3567 * a new command may be entered at any time, but note that if the
3568 * "TARGET_LOOK" bit flag is set (or if we are in "location" mode,
3569 * where "space" has no obvious meaning) then "space" will scan
3570 * through the description of the current grid until done, instead
3571 * of immediately jumping to the next "interesting" grid. This
3572 * allows the "target" command to retain its old semantics.
3574 * The "*", "+", and "-" keys may always be used to jump immediately
3575 * to the next (or previous) interesting grid, in the proper mode.
3577 * The "return" key may always be used to scan through a complete
3578 * grid description (forever).
3580 * This command will cancel any old target, even if used from
3581 * inside the "look" command.
3583 bool target_set(int mode)
3586 POSITION y = p_ptr->y;
3587 POSITION x = p_ptr->x;
3604 get_screen_size(&wid, &hgt);
3610 /* Cancel tracking */
3611 /* health_track(0); */
3613 if (rogue_like_commands)
3622 /* Prepare the "temp" array */
3623 target_set_prepare(mode);
3625 /* Start near the player */
3631 /* Interesting grids */
3638 change_panel_xy(y, x);
3640 if (!(mode & TARGET_LOOK)) prt_path(y, x);
3643 c_ptr = &cave[y][x];
3646 if (target_able(c_ptr->m_idx))
3648 strcpy(info, _("q止 t決 p自 o現 +次 -前", "q,t,p,o,+,-,<dir>"));
3651 /* Dis-allow target */
3654 strcpy(info, _("q止 p自 o現 +次 -前", "q,p,o,+,-,<dir>"));
3657 /* Describe and Prompt */
3659 query = target_set_aux(y, x, mode, info);
3663 /* Cancel tracking */
3664 /* health_track(0); */
3666 /* Assume no "direction" */
3671 if (query == '\r') query = 't';
3689 if (target_able(c_ptr->m_idx))
3691 health_track(c_ptr->m_idx);
3692 target_who = c_ptr->m_idx;
3711 if (!expand_list) done = TRUE;
3721 if (!expand_list) done = TRUE;
3728 /* Recenter the map around the player */
3732 p_ptr->update |= (PU_MONSTERS);
3735 p_ptr->redraw |= (PR_MAP);
3738 p_ptr->window |= (PW_OVERHEAD);
3743 /* Recalculate interesting grids */
3744 target_set_prepare(mode);
3763 if(query == same_key)
3768 if (!expand_list) done = TRUE;
3773 /* Extract the action (if any) */
3774 d = get_keymap_dir(query);
3781 /* Hack -- move around */
3784 /* Modified to scroll to monster */
3785 int y2 = panel_row_min;
3786 int x2 = panel_col_min;
3788 /* Find a new monster */
3789 i = target_pick(temp_y[m], temp_x[m], ddy[d], ddx[d]);
3791 /* Request to target past last interesting grid */
3792 while (flag && (i < 0))
3794 /* Note the change */
3795 if (change_panel(ddy[d], ddx[d]))
3800 /* Recalculate interesting grids */
3801 target_set_prepare(mode);
3803 /* Look at interesting grids */
3806 /* Find a new monster */
3807 i = target_pick(v, u, ddy[d], ddx[d]);
3813 /* Nothing interesting */
3819 /* Restore previous position */
3822 panel_bounds_center();
3825 p_ptr->update |= (PU_MONSTERS);
3828 p_ptr->redraw |= (PR_MAP);
3831 p_ptr->window |= (PW_OVERHEAD);
3836 /* Recalculate interesting grids */
3837 target_set_prepare(mode);
3839 /* Look at boring grids */
3846 /* Do not move horizontally if unnecessary */
3847 if (((x < panel_col_min + wid / 2) && (dx > 0)) ||
3848 ((x > panel_col_min + wid / 2) && (dx < 0)))
3853 /* Do not move vertically if unnecessary */
3854 if (((y < panel_row_min + hgt / 2) && (dy > 0)) ||
3855 ((y > panel_row_min + hgt / 2) && (dy < 0)))
3860 /* Apply the motion */
3861 if ((y >= panel_row_min+hgt) || (y < panel_row_min) ||
3862 (x >= panel_col_min+wid) || (x < panel_col_min))
3864 if (change_panel(dy, dx)) target_set_prepare(mode);
3867 /* Slide into legality */
3868 if (x >= cur_wid-1) x = cur_wid - 2;
3869 else if (x <= 0) x = 1;
3871 /* Slide into legality */
3872 if (y >= cur_hgt-1) y = cur_hgt- 2;
3873 else if (y <= 0) y = 1;
3882 /* Arbitrary grids */
3885 bool move_fast = FALSE;
3887 if (!(mode & TARGET_LOOK)) prt_path(y, x);
3890 c_ptr = &cave[y][x];
3892 /* Default prompt */
3893 strcpy(info, _("q止 t決 p自 m近 +次 -前", "q,t,p,m,+,-,<dir>"));
3895 /* Describe and Prompt (enable "TARGET_LOOK") */
3896 while (!(query = target_set_aux(y, x, mode | TARGET_LOOK, info)));
3898 /* Cancel tracking */
3899 /* health_track(0); */
3901 /* Assume no direction */
3906 if (query == '\r') query = 't';
3909 /* Analyze the keypress */
3933 /* Recenter the map around the player */
3937 p_ptr->update |= (PU_MONSTERS);
3940 p_ptr->redraw |= (PR_MAP);
3943 p_ptr->window |= (PW_OVERHEAD);
3948 /* Recalculate interesting grids */
3949 target_set_prepare(mode);
3971 /* Pick a nearby monster */
3972 for (i = 0; i < temp_n; i++)
3974 t = distance(y, x, temp_y[i], temp_x[i]);
3984 /* Nothing interesting */
3985 if (bd == 999) flag = FALSE;
3992 /* Extract the action (if any) */
3993 d = get_keymap_dir(query);
3995 /* XTRA HACK MOVEFAST */
3996 if (isupper(query)) move_fast = TRUE;
4003 /* Handle "direction" */
4009 /* XTRA HACK MOVEFAST */
4012 int mag = MIN(wid / 2, hgt / 2);
4022 /* Do not move horizontally if unnecessary */
4023 if (((x < panel_col_min + wid / 2) && (dx > 0)) ||
4024 ((x > panel_col_min + wid / 2) && (dx < 0)))
4029 /* Do not move vertically if unnecessary */
4030 if (((y < panel_row_min + hgt / 2) && (dy > 0)) ||
4031 ((y > panel_row_min + hgt / 2) && (dy < 0)))
4036 /* Apply the motion */
4037 if ((y >= panel_row_min + hgt) || (y < panel_row_min) ||
4038 (x >= panel_col_min + wid) || (x < panel_col_min))
4040 if (change_panel(dy, dx)) target_set_prepare(mode);
4043 /* Slide into legality */
4044 if (x >= cur_wid-1) x = cur_wid - 2;
4045 else if (x <= 0) x = 1;
4047 /* Slide into legality */
4048 if (y >= cur_hgt-1) y = cur_hgt- 2;
4049 else if (y <= 0) y = 1;
4057 /* Clear the top line */
4060 /* Recenter the map around the player */
4064 p_ptr->update |= (PU_MONSTERS);
4067 p_ptr->redraw |= (PR_MAP);
4070 p_ptr->window |= (PW_OVERHEAD);
4075 /* Failure to set target */
4076 if (!target_who) return (FALSE);
4084 * Get an "aiming direction" from the user.
4086 * The "dir" is loaded with 1,2,3,4,6,7,8,9 for "actual direction", and
4087 * "0" for "current target", and "-1" for "entry aborted".
4089 * Note that "Force Target", if set, will pre-empt user interaction,
4090 * if there is a usable target already set.
4092 * Note that confusion over-rides any (explicit?) user choice.
4094 bool get_aim_dir(DIRECTION *dp)
4103 /* Global direction */
4106 /* Hack -- auto-target if requested */
4107 if (use_old_target && target_okay()) dir = 5;
4109 #ifdef ALLOW_REPEAT /* TNB */
4111 if (repeat_pull(dp))
4116 if (!(*dp == 5 && !target_okay()))
4118 /* return (TRUE); */
4123 #endif /* ALLOW_REPEAT -- TNB */
4125 /* Ask until satisfied */
4128 /* Choose a prompt */
4131 p = _("方向 ('*'でターゲット選択, ESCで中断)? ", "Direction ('*' to choose a target, Escape to cancel)? ");
4135 p = _("方向 ('5'でターゲットへ, '*'でターゲット再選択, ESCで中断)? ", "Direction ('5' for target, '*' to re-target, Escape to cancel)? ");
4138 /* Get a command (or Cancel) */
4139 if (!get_com(p, &command, TRUE)) break;
4143 if (command == '\r') command = 't';
4146 /* Convert various keys to "standard" keys */
4149 /* Use current target */
4160 /* Set new target */
4165 if (target_set(TARGET_KILL)) dir = 5;
4171 /* Extract the action (if any) */
4172 dir = get_keymap_dir(command);
4178 /* Verify requested targets */
4179 if ((dir == 5) && !target_okay()) dir = 0;
4188 project_length = 0; /* reset to default */
4192 /* Save the direction */
4195 /* Check for confusion */
4196 if (p_ptr->confused)
4199 /* Random direction */
4200 dir = ddd[randint0(8)];
4203 /* Notice confusion */
4204 if (command_dir != dir)
4207 msg_print(_("あなたは混乱している。", "You are confused."));
4210 /* Save direction */
4213 #ifdef ALLOW_REPEAT /* TNB */
4215 /* repeat_push(dir); */
4216 repeat_push(command_dir);
4218 #endif /* ALLOW_REPEAT -- TNB */
4220 /* A "valid" direction was entered */
4227 * Request a "movement" direction (1,2,3,4,6,7,8,9) from the user,
4228 * and place it into "command_dir", unless we already have one.
4230 * This function should be used for all "repeatable" commands, such as
4231 * run, walk, open, close, bash, disarm, spike, tunnel, etc, as well
4232 * as all commands which must reference a grid adjacent to the player,
4233 * and which may not reference the grid under the player. Note that,
4234 * for example, it is no longer possible to "disarm" or "open" chests
4235 * in the same grid as the player.
4237 * Direction "5" is illegal and will (cleanly) abort the command.
4239 * This function tracks and uses the "global direction", and uses
4240 * that as the "desired direction", to which "confusion" is applied.
4242 bool get_rep_dir(int *dp, bool under)
4250 /* Global direction */
4253 #ifdef ALLOW_REPEAT /* TNB */
4255 if (repeat_pull(dp))
4258 /* return (TRUE); */
4261 #endif /* ALLOW_REPEAT -- TNB */
4265 prompt = _("方向 ('.'足元, ESCで中断)? ", "Direction ('.' at feet, Escape to cancel)? ");
4269 prompt = _("方向 (ESCで中断)? ", "Direction (Escape to cancel)? ");
4272 /* Get a direction */
4277 /* Get a command (or Cancel) */
4278 if (!get_com(prompt, &ch, TRUE)) break;
4281 if ((under) && ((ch == '5') || (ch == '-') || (ch == '.')))
4287 /* Look up the direction */
4288 dir = get_keymap_dir(ch);
4295 /* Prevent weirdness */
4296 if ((dir == 5) && (!under)) dir = 0;
4299 if (!dir) return (FALSE);
4301 /* Save desired direction */
4304 /* Apply "confusion" */
4305 if (p_ptr->confused)
4307 /* Standard confusion */
4308 if (randint0(100) < 75)
4310 /* Random direction */
4311 dir = ddd[randint0(8)];
4314 else if (p_ptr->riding)
4316 monster_type *m_ptr = &m_list[p_ptr->riding];
4317 monster_race *r_ptr = &r_info[m_ptr->r_idx];
4319 if (MON_CONFUSED(m_ptr))
4321 /* Standard confusion */
4322 if (randint0(100) < 75)
4324 /* Random direction */
4325 dir = ddd[randint0(8)];
4328 else if ((r_ptr->flags1 & RF1_RAND_50) && (r_ptr->flags1 & RF1_RAND_25) && (randint0(100) < 50))
4330 /* Random direction */
4331 dir = ddd[randint0(8)];
4333 else if ((r_ptr->flags1 & RF1_RAND_50) && (randint0(100) < 25))
4335 /* Random direction */
4336 dir = ddd[randint0(8)];
4340 /* Notice confusion */
4341 if (command_dir != dir)
4343 if (p_ptr->confused)
4346 msg_print(_("あなたは混乱している。", "You are confused."));
4351 monster_type *m_ptr = &m_list[p_ptr->riding];
4353 monster_desc(m_name, m_ptr, 0);
4354 if (MON_CONFUSED(m_ptr))
4356 msg_format(_("%sは混乱している。", "%^s is confusing."), m_name);
4360 msg_format(_("%sは思い通りに動いてくれない。", "You cannot control %s."), m_name);
4365 /* Save direction */
4368 #ifdef ALLOW_REPEAT /* TNB */
4370 /* repeat_push(dir); */
4371 repeat_push(command_dir);
4373 #endif /* ALLOW_REPEAT -- TNB */
4380 bool get_rep_dir2(int *dp)
4387 /* Global direction */
4390 #ifdef ALLOW_REPEAT /* TNB */
4392 if (repeat_pull(dp))
4395 /* return (TRUE); */
4398 #endif /* ALLOW_REPEAT -- TNB */
4400 /* Get a direction */
4405 /* Get a command (or Cancel) */
4406 if (!get_com(_("方向 (ESCで中断)? ", "Direction (Escape to cancel)? "), &ch, TRUE)) break;
4408 /* Look up the direction */
4409 dir = get_keymap_dir(ch);
4415 /* Prevent weirdness */
4416 if (dir == 5) dir = 0;
4419 if (!dir) return (FALSE);
4421 /* Save desired direction */
4424 /* Apply "confusion" */
4425 if (p_ptr->confused)
4427 /* Standard confusion */
4428 if (randint0(100) < 75)
4430 /* Random direction */
4431 dir = ddd[randint0(8)];
4435 /* Notice confusion */
4436 if (command_dir != dir)
4439 msg_print(_("あなたは混乱している。", "You are confused."));
4442 /* Save direction */
4445 #ifdef ALLOW_REPEAT /* TNB */
4447 /* repeat_push(dir); */
4448 repeat_push(command_dir);
4450 #endif /* ALLOW_REPEAT -- TNB */
4456 void gain_level_reward(int chosen_reward)
4460 char wrath_reason[32] = "";
4461 int nasty_chance = 6;
4462 OBJECT_TYPE_VALUE dummy = 0;
4463 OBJECT_SUBTYPE_VALUE dummy2 = 0;
4466 char o_name[MAX_NLEN];
4472 if (multi_rew) return;
4473 else multi_rew = TRUE;
4477 if (p_ptr->lev == 13) nasty_chance = 2;
4478 else if (!(p_ptr->lev % 13)) nasty_chance = 3;
4479 else if (!(p_ptr->lev % 14)) nasty_chance = 12;
4481 if (one_in_(nasty_chance))
4482 type = randint1(20); /* Allow the 'nasty' effects */
4484 type = randint1(15) + 5; /* Or disallow them */
4486 if (type < 1) type = 1;
4487 if (type > 20) type = 20;
4492 sprintf(wrath_reason, "%sの怒り",
4493 chaos_patrons[p_ptr->chaos_patron]);
4495 sprintf(wrath_reason, "the Wrath of %s",
4496 chaos_patrons[p_ptr->chaos_patron]);
4500 effect = chaos_rewards[p_ptr->chaos_patron][type];
4502 if (one_in_(6) && !chosen_reward)
4505 msg_format("%^sは褒美としてあなたを突然変異させた。",
4506 chaos_patrons[p_ptr->chaos_patron]);
4508 msg_format("%^s rewards you with a mutation!",
4509 chaos_patrons[p_ptr->chaos_patron]);
4512 (void)gain_random_mutation(0);
4513 reward = _("変異した。", "mutation");
4517 switch (chosen_reward ? chosen_reward : effect)
4521 msg_format("%sの声が響き渡った:",
4522 chaos_patrons[p_ptr->chaos_patron]);
4524 msg_format("The voice of %s booms out:",
4525 chaos_patrons[p_ptr->chaos_patron]);
4528 msg_print(_("「汝、新たなる姿を必要とせり!」", "'Thou needst a new form, mortal!'"));
4531 reward = _("変異した。", "polymorphing");
4535 msg_format("%sの声が響き渡った:",
4536 chaos_patrons[p_ptr->chaos_patron]);
4538 msg_format("The voice of %s booms out:",
4539 chaos_patrons[p_ptr->chaos_patron]);
4542 msg_print(_("「汝は良く行いたり!続けよ!」", "'Well done, mortal! Lead on!'"));
4544 if (p_ptr->prace == RACE_ANDROID)
4546 msg_print(_("しかし何も起こらなかった。", "But, nothing happen."));
4548 else if (p_ptr->exp < PY_MAX_EXP)
4550 s32b ee = (p_ptr->exp / 2) + 10;
4551 if (ee > 100000L) ee = 100000L;
4552 msg_print(_("更に経験を積んだような気がする。", "You feel more experienced."));
4555 reward = _("経験値を得た", "experience");
4560 msg_format("%sの声が響き渡った:",
4561 chaos_patrons[p_ptr->chaos_patron]);
4563 msg_format("The voice of %s booms out:",
4564 chaos_patrons[p_ptr->chaos_patron]);
4567 msg_print(_("「下僕よ、汝それに値せず。」", "'Thou didst not deserve that, slave.'"));
4569 if (p_ptr->prace == RACE_ANDROID)
4571 msg_print(_("しかし何も起こらなかった。", "But, nothing happen."));
4575 lose_exp(p_ptr->exp / 6);
4576 reward = _("経験値を失った。", "losing experience");
4581 msg_format("%sの声がささやいた:",
4582 chaos_patrons[p_ptr->chaos_patron]);
4584 msg_format("The voice of %s whispers:",
4585 chaos_patrons[p_ptr->chaos_patron]);
4588 msg_print(_("「我が与えし物を賢明に使うべし。」", "'Use my gift wisely.'"));
4590 acquirement(p_ptr->y, p_ptr->x, 1, FALSE, FALSE, FALSE);
4591 reward = _("上質なアイテムを手に入れた。", "a good item");
4595 msg_format("%sの声が響き渡った:",
4596 chaos_patrons[p_ptr->chaos_patron]);
4598 msg_format("The voice of %s booms out:",
4599 chaos_patrons[p_ptr->chaos_patron]);
4602 msg_print(_("「我が与えし物を賢明に使うべし。」", "'Use my gift wisely.'"));
4604 acquirement(p_ptr->y, p_ptr->x, 1, TRUE, FALSE, FALSE);
4605 reward = _("高級品のアイテムを手に入れた。", "an excellent item");
4609 msg_format("%sの声が響き渡った:",
4610 chaos_patrons[p_ptr->chaos_patron]);
4612 msg_format("The voice of %s booms out:",
4613 chaos_patrons[p_ptr->chaos_patron]);
4616 msg_print(_("「汝の行いは貴き剣に値せり。」", "'Thy deed hath earned thee a worthy blade.'"));
4618 /* Get local object */
4621 switch (randint1(p_ptr->lev))
4627 dummy2 = SV_MAIN_GAUCHE;
4636 dummy2 = SV_SMALL_SWORD;
4639 dummy2 = SV_BASILLARD;
4641 case 11: case 12: case 13:
4642 dummy2 = SV_SHORT_SWORD;
4648 dummy2 = SV_CUTLASS;
4651 dummy2 = SV_WAKIZASHI;
4654 dummy2 = SV_KHOPESH;
4660 dummy2 = SV_BROAD_SWORD;
4663 dummy2 = SV_LONG_SWORD;
4666 dummy2 = SV_SCIMITAR;
4669 dummy2 = SV_NINJATO;
4675 dummy2 = SV_BASTARD_SWORD;
4678 dummy2 = SV_GREAT_SCIMITAR;
4681 dummy2 = SV_CLAYMORE;
4684 dummy2 = SV_ESPADON;
4687 dummy2 = SV_TWO_HANDED_SWORD;
4690 dummy2 = SV_FLAMBERGE;
4693 dummy2 = SV_NO_DACHI;
4696 dummy2 = SV_EXECUTIONERS_SWORD;
4699 dummy2 = SV_ZWEIHANDER;
4702 dummy2 = SV_HAYABUSA;
4705 dummy2 = SV_BLADE_OF_CHAOS;
4708 object_prep(q_ptr, lookup_kind(dummy, dummy2));
4709 q_ptr->to_h = 3 + randint1(dun_level) % 10;
4710 q_ptr->to_d = 3 + randint1(dun_level) % 10;
4711 one_resistance(q_ptr);
4712 q_ptr->name2 = EGO_CHAOTIC;
4714 /* Drop it in the dungeon */
4715 (void)drop_near(q_ptr, -1, p_ptr->y, p_ptr->x);
4716 reward = _("(混沌)の武器を手に入れた。", "chaos weapon");
4720 msg_format("%sの声が響き渡った:",
4721 chaos_patrons[p_ptr->chaos_patron]);
4723 msg_format("The voice of %s booms out:",
4724 chaos_patrons[p_ptr->chaos_patron]);
4727 msg_print(_("「汝の行いは貴き報いに値せり。」", "'Thy deed hath earned thee a worthy reward.'"));
4729 acquirement(p_ptr->y, p_ptr->x, randint1(2) + 1, FALSE, FALSE, FALSE);
4730 reward = _("上質なアイテムを手に入れた。", "good items");
4734 msg_format("%sの声が響き渡った:",
4735 chaos_patrons[p_ptr->chaos_patron]);
4737 msg_format("The voice of %s booms out:",
4738 chaos_patrons[p_ptr->chaos_patron]);
4741 msg_print(_("「下僕よ、汝の献身への我が惜しみ無き報いを見るがよい。」", "'Behold, mortal, how generously I reward thy loyalty.'"));
4743 acquirement(p_ptr->y, p_ptr->x, randint1(2) + 1, TRUE, FALSE, FALSE);
4744 reward = _("高級品のアイテムを手に入れた。", "excellent items");
4748 msg_format("%sの声が轟き渡った:",
4749 chaos_patrons[p_ptr->chaos_patron]);
4751 msg_format("The voice of %s thunders:",
4752 chaos_patrons[p_ptr->chaos_patron]);
4755 msg_print(_("「下僕よ、汝傲慢なり。」", "'Thou art growing arrogant, mortal.'"));
4757 (void)activate_ty_curse(FALSE, &count);
4758 reward = _("禍々しい呪いをかけられた。", "cursing");
4762 msg_format("%sの声が響き渡った:",
4763 chaos_patrons[p_ptr->chaos_patron]);
4765 msg_format("The voice of %s booms out:",
4766 chaos_patrons[p_ptr->chaos_patron]);
4769 msg_print(_("「我が下僕たちよ、かの傲慢なる者を倒すべし!」", "'My pets, destroy the arrogant mortal!'"));
4771 for (dummy = 0; dummy < randint1(5) + 1; dummy++)
4773 (void)summon_specific(0, p_ptr->y, p_ptr->x, dun_level, 0, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET));
4775 reward = _("モンスターを召喚された。", "summoning hostile monsters");
4779 msg_format("%sの声が響き渡った:",
4780 chaos_patrons[p_ptr->chaos_patron]);
4782 msg_format("The voice of %s booms out:",
4783 chaos_patrons[p_ptr->chaos_patron]);
4786 msg_print(_("「汝、より強き敵を必要とせり!」", "'Thou needst worthier opponents!'"));
4788 activate_hi_summon(p_ptr->y, p_ptr->x, FALSE);
4789 reward = _("モンスターを召喚された。", "summoning many hostile monsters");
4793 msg_format("%sの声が響き渡った:",
4794 chaos_patrons[p_ptr->chaos_patron]);
4796 msg_format("The voice of %s booms out:",
4797 chaos_patrons[p_ptr->chaos_patron]);
4800 msg_print(_("「死と破壊こそ我が喜びなり!」", "'Death and destruction! This pleaseth me!'"));
4803 reward = _("カオスの力が渦巻いた。", "calling chaos");
4807 msg_format("%sの声が鳴り響いた:",
4808 chaos_patrons[p_ptr->chaos_patron]);
4810 msg_format("The voice of %s rings out:",
4811 chaos_patrons[p_ptr->chaos_patron]);
4814 msg_print(_("「留まるのだ、下僕よ。余が汝の肉体を鍛えん。」", "'Stay, mortal, and let me mold thee.'"));
4816 if (one_in_(3) && !(chaos_stats[p_ptr->chaos_patron] < 0))
4817 do_inc_stat(chaos_stats[p_ptr->chaos_patron]);
4819 do_inc_stat(randint0(6));
4820 reward = _("能力値が上がった。", "increasing a stat");
4824 msg_format("%sの声が響き渡った:",
4825 chaos_patrons[p_ptr->chaos_patron]);
4827 msg_format("The voice of %s booms out:",
4828 chaos_patrons[p_ptr->chaos_patron]);
4831 msg_print(_("「下僕よ、余は汝に飽みたり。」", "'I grow tired of thee, mortal.'"));
4833 if (one_in_(3) && !(chaos_stats[p_ptr->chaos_patron] < 0))
4834 do_dec_stat(chaos_stats[p_ptr->chaos_patron]);
4836 (void)do_dec_stat(randint0(6));
4837 reward = _("能力値が下がった。", "decreasing a stat");
4841 msg_format("%sの声が轟き渡った:",
4842 chaos_patrons[p_ptr->chaos_patron]);
4844 msg_format("The voice of %s thunders:",
4845 chaos_patrons[p_ptr->chaos_patron]);
4848 msg_print(_("「汝、謙虚たることを学ぶべし!」", "'Thou needst a lesson in humility, mortal!'"));
4849 msg_print(_("あなたは以前より弱くなった!", "You feel less powerful!"));
4851 for (dummy = 0; dummy < 6; dummy++)
4853 (void)dec_stat(dummy, 10 + randint1(15), TRUE);
4855 reward = _("全能力値が下がった。", "decreasing all stats");
4858 msg_format(_("%sの力が触れるのを感じた。", "You feel the power of %s touch you."),
4860 chaos_patrons[p_ptr->chaos_patron]);
4862 reward = _("傷が変化した。", "polymorphing wounds");
4866 msg_format("%sの声が響き渡った:",
4867 chaos_patrons[p_ptr->chaos_patron]);
4869 msg_format("The voice of %s booms out:",
4870 chaos_patrons[p_ptr->chaos_patron]);
4873 msg_print(_("「我がささやかなる賜物を受けとるがよい!」", "'Receive this modest gift from me!'"));
4875 for (dummy = 0; dummy < 6; dummy++)
4877 (void)do_inc_stat(dummy);
4879 reward = _("全能力値が上がった。", "increasing all stats");
4883 msg_format("%sの声が響き渡った:",
4884 chaos_patrons[p_ptr->chaos_patron]);
4886 msg_format("The voice of %s booms out:",
4887 chaos_patrons[p_ptr->chaos_patron]);
4890 msg_print(_("「苦しむがよい、無能な愚か者よ!」", "'Suffer, pathetic fool!'"));
4892 fire_ball(GF_DISINTEGRATE, 0, p_ptr->lev * 4, 4);
4893 take_hit(DAMAGE_NOESCAPE, p_ptr->lev * 4, wrath_reason, -1);
4894 reward = _("分解の球が発生した。", "generating disintegration ball");
4898 msg_format("%sの声が響き渡った:",
4899 chaos_patrons[p_ptr->chaos_patron]);
4901 msg_format("The voice of %s booms out:",
4902 chaos_patrons[p_ptr->chaos_patron]);
4905 msg_print(_("「甦るがよい、我が下僕よ!」", "'Rise, my servant!'"));
4908 (void)set_poisoned(0);
4910 (void)set_confused(0);
4915 for (dummy = 0; dummy < 6; dummy++)
4917 (void)do_res_stat(dummy);
4919 reward = _("体力が回復した。", "healing");
4922 if (!buki_motteruka(INVEN_RARM) && !buki_motteruka(INVEN_LARM)) break;
4924 msg_format("%sの声が響き渡った:",
4925 chaos_patrons[p_ptr->chaos_patron]);
4927 msg_format("The voice of %s booms out:",
4928 chaos_patrons[p_ptr->chaos_patron]);
4931 msg_print(_("「汝、武器に頼ることなかれ。」", "'Thou reliest too much on thy weapon.'"));
4934 if (buki_motteruka(INVEN_LARM))
4937 if (buki_motteruka(INVEN_RARM) && one_in_(2)) dummy = INVEN_RARM;
4939 object_desc(o_name, &inventory[dummy], OD_NAME_ONLY);
4940 (void)curse_weapon(FALSE, dummy);
4941 reward = format(_("%sが破壊された。", "destroying %s"), o_name);
4944 if (!inventory[INVEN_BODY].k_idx) break;
4946 msg_format("%sの声が響き渡った:",
4947 chaos_patrons[p_ptr->chaos_patron]);
4949 msg_format("The voice of %s booms out:",
4950 chaos_patrons[p_ptr->chaos_patron]);
4953 msg_print(_("「汝、防具に頼ることなかれ。」", "'Thou reliest too much on thine equipment.'"));
4955 object_desc(o_name, &inventory[INVEN_BODY], OD_NAME_ONLY);
4956 (void)curse_armor();
4957 reward = format(_("%sが破壊された。", "destroying %s"), o_name);
4961 msg_format("%sの声がささやいた:",
4962 chaos_patrons[p_ptr->chaos_patron]);
4964 msg_format("The voice of %s whispers:",
4965 chaos_patrons[p_ptr->chaos_patron]);
4968 msg_print(_("「我を怒りしめた罪を償うべし。」", "'Now thou shalt pay for annoying me.'"));
4970 switch (randint1(4))
4973 (void)activate_ty_curse(FALSE, &count);
4974 reward = _("禍々しい呪いをかけられた。", "cursing");
4977 activate_hi_summon(p_ptr->y, p_ptr->x, FALSE);
4978 reward = _("モンスターを召喚された。", "summoning hostile monsters");
4983 if (!buki_motteruka(INVEN_RARM) && !buki_motteruka(INVEN_LARM)) break;
4985 if (buki_motteruka(INVEN_LARM))
4988 if (buki_motteruka(INVEN_RARM) && one_in_(2)) dummy = INVEN_RARM;
4990 object_desc(o_name, &inventory[dummy], OD_NAME_ONLY);
4991 (void)curse_weapon(FALSE, dummy);
4992 reward = format(_("%sが破壊された。", "destroying %s"), o_name);
4996 if (!inventory[INVEN_BODY].k_idx) break;
4997 object_desc(o_name, &inventory[INVEN_BODY], OD_NAME_ONLY);
4998 (void)curse_armor();
4999 reward = format(_("%sが破壊された。", "destroying %s"), o_name);
5003 for (dummy = 0; dummy < 6; dummy++)
5005 (void)dec_stat(dummy, 10 + randint1(15), TRUE);
5007 reward = _("全能力値が下がった。", "decreasing all stats");
5012 msg_format(_("%sの声が轟き渡った:", "The voice of %s thunders:"),
5014 chaos_patrons[p_ptr->chaos_patron]);
5015 msg_print(_("「死ぬがよい、下僕よ!」", "'Die, mortal!'"));
5017 take_hit(DAMAGE_LOSELIFE, p_ptr->lev * 4, wrath_reason, -1);
5018 for (dummy = 0; dummy < 6; dummy++)
5020 (void)dec_stat(dummy, 10 + randint1(15), FALSE);
5022 activate_hi_summon(p_ptr->y, p_ptr->x, FALSE);
5023 (void)activate_ty_curse(FALSE, &count);
5028 if (buki_motteruka(INVEN_RARM))
5031 if (buki_motteruka(INVEN_LARM) && one_in_(2)) dummy = INVEN_LARM;
5033 else if (buki_motteruka(INVEN_LARM)) dummy = INVEN_LARM;
5035 if (dummy) (void)curse_weapon(FALSE, dummy);
5037 if (one_in_(2)) (void)curse_armor();
5041 msg_format("%sの声が響き渡った:",
5042 chaos_patrons[p_ptr->chaos_patron]);
5044 msg_format("The voice of %s booms out:",
5045 chaos_patrons[p_ptr->chaos_patron]);
5048 msg_print(_("「死と破壊こそ我が喜びなり!」", "'Death and destruction! This pleaseth me!'"));
5050 (void)destroy_area(p_ptr->y, p_ptr->x, 25, FALSE);
5051 reward = _("ダンジョンが*破壊*された。", "*destruct*ing dungeon");
5055 msg_format("%sの声が響き渡った:",
5056 chaos_patrons[p_ptr->chaos_patron]);
5058 msg_format("The voice of %s booms out:",
5059 chaos_patrons[p_ptr->chaos_patron]);
5062 msg_print(_("「我、汝の敵を抹殺せん!」", "'Let me relieve thee of thine oppressors!'"));
5064 (void)symbol_genocide(0, FALSE);
5065 reward = _("モンスターが抹殺された。", "genociding monsters");
5069 msg_format("%sの声が響き渡った:",
5070 chaos_patrons[p_ptr->chaos_patron]);
5072 msg_format("The voice of %s booms out:",
5073 chaos_patrons[p_ptr->chaos_patron]);
5076 msg_print(_("「我、汝の敵を抹殺せん!」", "'Let me relieve thee of thine oppressors!'"));
5078 (void)mass_genocide(0, FALSE);
5079 reward = _("モンスターが抹殺された。", "genociding nearby monsters");
5083 msg_format("%sの力が敵を攻撃するのを感じた!",
5084 chaos_patrons[p_ptr->chaos_patron]);
5086 msg_format("You can feel the power of %s assault your enemies!",
5087 chaos_patrons[p_ptr->chaos_patron]);
5090 (void)dispel_monsters(p_ptr->lev * 4);
5094 msg_format("%sはあなたを無視した。",
5095 chaos_patrons[p_ptr->chaos_patron]);
5097 msg_format("%s ignores you.",
5098 chaos_patrons[p_ptr->chaos_patron]);
5103 msg_format(_("%sは褒美として悪魔の使いをよこした!", "%s rewards you with a demonic servant!"),chaos_patrons[p_ptr->chaos_patron]);
5105 if (!summon_specific(-1, p_ptr->y, p_ptr->x, dun_level, SUMMON_DEMON, PM_FORCE_PET))
5106 msg_print(_("何も現れなかった...", "Nobody ever turns up..."));
5108 reward = _("悪魔がペットになった。", "a demonic servant");
5112 msg_format(_("%sは褒美として使いをよこした!", "%s rewards you with a servant!"),chaos_patrons[p_ptr->chaos_patron]);
5114 if (!summon_specific(-1, p_ptr->y, p_ptr->x, dun_level, 0, PM_FORCE_PET))
5115 msg_print(_("何も現れなかった...", "Nobody ever turns up..."));
5117 reward = _("モンスターがペットになった。", "a servant");
5121 msg_format(_("%sは褒美としてアンデッドの使いをよこした。", "%s rewards you with an undead servant!"),chaos_patrons[p_ptr->chaos_patron]);
5123 if (!summon_specific(-1, p_ptr->y, p_ptr->x, dun_level, SUMMON_UNDEAD, PM_FORCE_PET))
5124 msg_print(_("何も現れなかった...", "Nobody ever turns up..."));
5126 reward = _("アンデッドがペットになった。", "an undead servant");
5130 msg_format(_("%sの声がどもった:", "The voice of %s stammers:"),
5132 chaos_patrons[p_ptr->chaos_patron]);
5133 msg_format(_("「あー、あー、答えは %d/%d。質問は何?」", "'Uh... uh... the answer's %d/%d, what's the question?'"), type, effect);
5139 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, format(_("パトロンの報酬で%s", "The patron rewards you with %s."), reward));
5145 * XAngband: determine if a given location is "interesting"
5146 * based on target_set_accept function.
5148 static bool tgt_pt_accept(POSITION y, POSITION x)
5153 if (!(in_bounds(y, x))) return (FALSE);
5155 /* Player grid is always interesting */
5156 if ((y == p_ptr->y) && (x == p_ptr->x)) return (TRUE);
5158 /* Handle hallucination */
5159 if (p_ptr->image) return (FALSE);
5161 /* Examine the grid */
5162 c_ptr = &cave[y][x];
5164 /* Interesting memorized features */
5165 if (c_ptr->info & (CAVE_MARK))
5168 if (cave_have_flag_grid(c_ptr, FF_LESS)) return (TRUE);
5169 if (cave_have_flag_grid(c_ptr, FF_MORE)) return (TRUE);
5171 /* Notice quest features */
5172 if (cave_have_flag_grid(c_ptr, FF_QUEST_ENTER)) return (TRUE);
5173 if (cave_have_flag_grid(c_ptr, FF_QUEST_EXIT)) return (TRUE);
5182 * XAngband: Prepare the "temp" array for "tget_pt"
5183 * based on target_set_prepare funciton.
5185 static void tgt_pt_prepare(void)
5189 /* Reset "temp" array */
5192 if (!expand_list) return;
5194 /* Scan the current panel */
5195 for (y = 1; y < cur_hgt; y++)
5197 for (x = 1; x < cur_wid; x++)
5199 /* Require "interesting" contents */
5200 if (!tgt_pt_accept(y, x)) continue;
5202 /* Save the location */
5209 /* Target the nearest monster for shooting */
5210 ang_sort_comp = ang_sort_comp_distance;
5211 ang_sort_swap = ang_sort_swap_distance;
5213 /* Sort the positions */
5214 ang_sort(temp_x, temp_y, temp_n);
5218 * old -- from PsiAngband.
5220 bool tgt_pt(POSITION *x_ptr, POSITION *y_ptr)
5225 bool success = FALSE;
5230 get_screen_size(&wid, &hgt);
5240 msg_print(_("場所を選んでスペースキーを押して下さい。", "Select a point and press space."));
5241 msg_flag = FALSE; /* prevents "-more-" message. */
5243 while ((ch != ESCAPE) && !success)
5245 bool move_fast = FALSE;
5247 move_cursor_relative(y, x);
5259 if (player_bold(y, x)) ch = 0;
5262 else success = TRUE;
5266 /* XAngband: Move cursor to stairs */
5269 if (expand_list && temp_n)
5272 int cx = (panel_col_min + panel_col_max) / 2;
5273 int cy = (panel_row_min + panel_row_max) / 2;
5277 /* Skip stairs which have defferent distance */
5278 for (; n < temp_n; ++ n)
5280 cave_type *c_ptr = &cave[temp_y[n]][temp_x[n]];
5282 if (cave_have_flag_grid(c_ptr, FF_STAIRS) &&
5283 cave_have_flag_grid(c_ptr, ch == '>' ? FF_MORE : FF_LESS))
5290 if (n == temp_n) /* Loop out taget list */
5295 verify_panel(); /* Move cursor to player */
5298 p_ptr->update |= (PU_MONSTERS);
5301 p_ptr->redraw |= (PR_MAP);
5304 p_ptr->window |= (PW_OVERHEAD);
5309 else /* move cursor to next stair and change panel */
5314 dy = 2 * (y - cy) / hgt;
5315 dx = 2 * (x - cx) / wid;
5316 if (dy || dx) change_panel(dy, dx);
5322 /* Look up the direction */
5323 d = get_keymap_dir(ch);
5325 /* XTRA HACK MOVEFAST */
5326 if (isupper(ch)) move_fast = TRUE;
5328 /* Handle "direction" */
5334 /* XTRA HACK MOVEFAST */
5337 int mag = MIN(wid / 2, hgt / 2);
5347 /* Do not move horizontally if unnecessary */
5348 if (((x < panel_col_min + wid / 2) && (dx > 0)) ||
5349 ((x > panel_col_min + wid / 2) && (dx < 0)))
5354 /* Do not move vertically if unnecessary */
5355 if (((y < panel_row_min + hgt / 2) && (dy > 0)) ||
5356 ((y > panel_row_min + hgt / 2) && (dy < 0)))
5361 /* Apply the motion */
5362 if ((y >= panel_row_min + hgt) || (y < panel_row_min) ||
5363 (x >= panel_col_min + wid) || (x < panel_col_min))
5365 /* if (change_panel(dy, dx)) target_set_prepare(mode); */
5366 change_panel(dy, dx);
5369 /* Slide into legality */
5370 if (x >= cur_wid-1) x = cur_wid - 2;
5371 else if (x <= 0) x = 1;
5373 /* Slide into legality */
5374 if (y >= cur_hgt-1) y = cur_hgt- 2;
5375 else if (y <= 0) y = 1;
5382 /* Clear the top line */
5385 /* Recenter the map around the player */
5389 p_ptr->update |= (PU_MONSTERS);
5392 p_ptr->redraw |= (PR_MAP);
5395 p_ptr->window |= (PW_OVERHEAD);
5406 bool get_hack_dir(int *dp)
5416 /* Global direction */
5419 /* (No auto-targeting) */
5421 /* Ask until satisfied */
5424 /* Choose a prompt */
5427 p = _("方向 ('*'でターゲット選択, ESCで中断)? ", "Direction ('*' to choose a target, Escape to cancel)? ");
5431 p = _("方向 ('5'でターゲットへ, '*'でターゲット再選択, ESCで中断)? ", "Direction ('5' for target, '*' to re-target, Escape to cancel)? ");
5434 /* Get a command (or Cancel) */
5435 if (!get_com(p, &command, TRUE)) break;
5439 if (command == '\r') command = 't';
5442 /* Convert various keys to "standard" keys */
5445 /* Use current target */
5456 /* Set new target */
5461 if (target_set(TARGET_KILL)) dir = 5;
5467 /* Look up the direction */
5468 dir = get_keymap_dir(command);
5474 /* Verify requested targets */
5475 if ((dir == 5) && !target_okay()) dir = 0;
5482 if (!dir) return (FALSE);
5484 /* Save the direction */
5487 /* Check for confusion */
5488 if (p_ptr->confused)
5491 /* Random direction */
5492 dir = ddd[randint0(8)];
5495 /* Notice confusion */
5496 if (command_dir != dir)
5499 msg_print(_("あなたは混乱している。", "You are confused."));
5502 /* Save direction */
5505 /* A "valid" direction was entered */
5511 * エネルギーの増加量10d5を速く計算するための関数
5514 #define Go_no_JuuJou 5*5*5*5*5*5*5*5*5*5
5516 s16b gain_energy(void)
5519 s32b energy_result = 10;
5522 tmp = randint0(Go_no_JuuJou);
5524 for (i = 0; i < 9; i ++){
5525 energy_result += tmp % 5;
5529 return (s16b)(energy_result + tmp);
5536 s16b bow_energy(OBJECT_SUBTYPE_VALUE sval)
5540 /* Analyze the launcher */
5543 /* Sling and ammo */
5550 /* Short Bow and Arrow */
5557 /* Long Bow and Arrow */
5564 /* Bow of irresponsiblity and Arrow */
5571 /* Light Crossbow and Bolt */
5578 /* Heavy Crossbow and Bolt */
5593 int bow_tmul(OBJECT_SUBTYPE_VALUE sval)
5597 /* Analyze the launcher */
5600 /* Sling and ammo */
5607 /* Short Bow and Arrow */
5614 /* Long Bow and Arrow */
5621 /* Bow of irresponsiblity and Arrow */
5628 /* Light Crossbow and Bolt */
5635 /* Heavy Crossbow and Bolt */
5647 * Return alignment title
5649 cptr your_alignment(void)
5652 if (p_ptr->align > 150) return "大善";
5653 else if (p_ptr->align > 50) return "中善";
5654 else if (p_ptr->align > 10) return "小善";
5655 else if (p_ptr->align > -11) return "中立";
5656 else if (p_ptr->align > -51) return "小悪";
5657 else if (p_ptr->align > -151) return "中悪";
5660 if (p_ptr->align > 150) return "Lawful";
5661 else if (p_ptr->align > 50) return "Good";
5662 else if (p_ptr->align > 10) return "Neutral Good";
5663 else if (p_ptr->align > -11) return "Neutral";
5664 else if (p_ptr->align > -51) return "Neutral Evil";
5665 else if (p_ptr->align > -151) return "Evil";
5666 else return "Chaotic";
5672 * Return proficiency level of weapons and misc. skills (except riding)
5674 int weapon_exp_level(int weapon_exp)
5676 if (weapon_exp < WEAPON_EXP_BEGINNER) return EXP_LEVEL_UNSKILLED;
5677 else if (weapon_exp < WEAPON_EXP_SKILLED) return EXP_LEVEL_BEGINNER;
5678 else if (weapon_exp < WEAPON_EXP_EXPERT) return EXP_LEVEL_SKILLED;
5679 else if (weapon_exp < WEAPON_EXP_MASTER) return EXP_LEVEL_EXPERT;
5680 else return EXP_LEVEL_MASTER;
5685 * Return proficiency level of riding
5687 int riding_exp_level(int riding_exp)
5689 if (riding_exp < RIDING_EXP_BEGINNER) return EXP_LEVEL_UNSKILLED;
5690 else if (riding_exp < RIDING_EXP_SKILLED) return EXP_LEVEL_BEGINNER;
5691 else if (riding_exp < RIDING_EXP_EXPERT) return EXP_LEVEL_SKILLED;
5692 else if (riding_exp < RIDING_EXP_MASTER) return EXP_LEVEL_EXPERT;
5693 else return EXP_LEVEL_MASTER;
5698 * Return proficiency level of spells
5700 int spell_exp_level(int spell_exp)
5702 if (spell_exp < SPELL_EXP_BEGINNER) return EXP_LEVEL_UNSKILLED;
5703 else if (spell_exp < SPELL_EXP_SKILLED) return EXP_LEVEL_BEGINNER;
5704 else if (spell_exp < SPELL_EXP_EXPERT) return EXP_LEVEL_SKILLED;
5705 else if (spell_exp < SPELL_EXP_MASTER) return EXP_LEVEL_EXPERT;
5706 else return EXP_LEVEL_MASTER;
5711 * Display a rumor and apply its effects
5714 IDX rumor_num(char *zz, IDX max_idx)
5716 if (strcmp(zz, "*") == 0) return randint1(max_idx - 1);
5717 return (IDX)atoi(zz);
5720 cptr rumor_bind_name(char *base, cptr fullname)
5724 s = strstr(base, "{Name}");
5728 v = format("%s%s%s", base, fullname, (s + 6));
5738 void display_rumor(bool ex)
5746 if (randint0(3) == 0) section = 1;
5749 err = _(get_rnd_line_jonly("rumors_j.txt", section, Rumor, 10),
5750 get_rnd_line("rumors.txt", section, Rumor));
5751 if (err) strcpy(Rumor, _("嘘の噂もある。", "Some rumors are wrong."));
5755 if (strncmp(Rumor, "R:", 2) == 0)
5758 cptr rumor_msg = NULL;
5759 cptr rumor_eff_format = NULL;
5760 char fullname[1024] = "";
5762 if (tokenize(Rumor + 2, 3, zz, TOKENIZE_CHECKQUOTE) == 3)
5764 if (strcmp(zz[0], "ARTIFACT") == 0)
5768 object_type *q_ptr = &forge;
5769 artifact_type *a_ptr;
5773 a_idx = rumor_num(zz[1], max_a_idx);
5775 a_ptr = &a_info[a_idx];
5776 if (a_ptr->name) break;
5779 k_idx = lookup_kind(a_ptr->tval, a_ptr->sval);
5780 object_prep(q_ptr, k_idx);
5781 q_ptr->name1 = a_idx;
5782 q_ptr->ident = IDENT_STORE;
5783 object_desc(fullname, q_ptr, OD_NAME_ONLY);
5785 else if (strcmp(zz[0], "MONSTER") == 0)
5788 monster_race *r_ptr;
5792 r_idx = rumor_num(zz[1], max_r_idx);
5793 r_ptr = &r_info[r_idx];
5794 if (r_ptr->name) break;
5797 strcpy(fullname, r_name + r_ptr->name);
5799 /* Remember this monster */
5800 if (!r_ptr->r_sights)
5805 else if (strcmp(zz[0], "DUNGEON") == 0)
5808 dungeon_info_type *d_ptr;
5812 d_idx = rumor_num(zz[1], max_d_idx);
5813 d_ptr = &d_info[d_idx];
5814 if (d_ptr->name) break;
5817 strcpy(fullname, d_name + d_ptr->name);
5819 if (!max_dlv[d_idx])
5821 max_dlv[d_idx] = d_ptr->mindepth;
5822 rumor_eff_format = _("%sに帰還できるようになった。", "You can recall to %s.");
5825 else if (strcmp(zz[0], "TOWN") == 0)
5832 t_idx = rumor_num(zz[1], NO_TOWN);
5833 if (town[t_idx].name) break;
5836 strcpy(fullname, town[t_idx].name);
5838 visit = (1L << (t_idx - 1));
5839 if ((t_idx != SECRET_TOWN) && !(p_ptr->visit & visit))
5841 p_ptr->visit |= visit;
5842 rumor_eff_format = _("%sに行ったことがある気がする。", "You feel you have been to %s.");
5846 rumor_msg = rumor_bind_name(zz[2], fullname);
5847 msg_print(rumor_msg);
5848 if (rumor_eff_format)
5851 msg_format(rumor_eff_format, fullname);
5856 if (err) msg_print(_("この情報は間違っている。", "This information is wrong."));
5860 msg_format("%s", Rumor);