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 PLAYER_LEVEL 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);
106 msg_format(_("レベル %d にようこそ。", "Welcome to level %d."), p_ptr->lev);
108 /* Update some stuff */
109 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
111 /* Redraw some stuff */
112 p_ptr->redraw |= (PR_LEV | PR_TITLE | PR_EXP);
115 p_ptr->window |= (PW_PLAYER | PW_SPELL | PW_INVEN);
127 if(!(p_ptr->max_plv % 10))
137 cnv_stat(p_ptr->stat_max[0], tmp);
138 prt(format(" a) 腕力 (現在値 %s)", tmp), 2, 14);
139 cnv_stat(p_ptr->stat_max[1], tmp);
140 prt(format(" b) 知能 (現在値 %s)", tmp), 3, 14);
141 cnv_stat(p_ptr->stat_max[2], tmp);
142 prt(format(" c) 賢さ (現在値 %s)", tmp), 4, 14);
143 cnv_stat(p_ptr->stat_max[3], tmp);
144 prt(format(" d) 器用 (現在値 %s)", tmp), 5, 14);
145 cnv_stat(p_ptr->stat_max[4], tmp);
146 prt(format(" e) 耐久 (現在値 %s)", tmp), 6, 14);
147 cnv_stat(p_ptr->stat_max[5], tmp);
148 prt(format(" f) 魅力 (現在値 %s)", tmp), 7, 14);
150 prt(" どの能力値を上げますか?", 1, 14);
152 cnv_stat(p_ptr->stat_max[0], tmp);
153 prt(format(" a) Str (cur %s)", tmp), 2, 14);
154 cnv_stat(p_ptr->stat_max[1], tmp);
155 prt(format(" b) Int (cur %s)", tmp), 3, 14);
156 cnv_stat(p_ptr->stat_max[2], tmp);
157 prt(format(" c) Wis (cur %s)", tmp), 4, 14);
158 cnv_stat(p_ptr->stat_max[3], tmp);
159 prt(format(" d) Dex (cur %s)", tmp), 5, 14);
160 cnv_stat(p_ptr->stat_max[4], tmp);
161 prt(format(" e) Con (cur %s)", tmp), 6, 14);
162 cnv_stat(p_ptr->stat_max[5], tmp);
163 prt(format(" f) Chr (cur %s)", tmp), 7, 14);
165 prt(" Which stat do you want to raise?", 1, 14);
170 if ((choice >= 'a') && (choice <= 'f')) break;
172 for(n = 0; n < 6; n++)
173 if (n != choice - 'a')
175 if (get_check(_("よろしいですか?", "Are you sure? "))) break;
177 do_inc_stat(choice - 'a');
180 else if(!(p_ptr->max_plv % 2))
181 do_inc_stat(randint0(6));
186 msg_print(_("あなたは変わった気がする...", "You feel different..."));
187 (void)gain_random_mutation(0);
188 level_mutation = FALSE;
192 * 報酬でレベルが上ると再帰的に check_experience() が
197 gain_level_reward(0);
198 level_reward = FALSE;
201 /* Update some stuff */
202 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
204 /* Redraw some stuff */
205 p_ptr->redraw |= (PR_LEV | PR_TITLE);
208 p_ptr->window |= (PW_PLAYER | PW_SPELL);
214 /* Load an autopick preference file */
215 if (old_lev != p_ptr->lev) autopick_load_pref(FALSE);
220 * @brief モンスターを倒した際の財宝svalを返す
221 * @param r_idx 倒したモンスターの種族ID
224 * Hack -- Return the "automatic coin type" of a monster race
225 * Used to allocate proper treasure when "Creeping coins" die
226 * XXX XXX XXX Note the use of actual "monster names"
228 static int get_coin_type(MONRACE_IDX r_idx)
230 /* Analyze monsters */
233 case MON_COPPER_COINS: return 2;
234 case MON_SILVER_COINS: return 5;
235 case MON_GOLD_COINS: return 10;
236 case MON_MITHRIL_COINS:
237 case MON_MITHRIL_GOLEM: return 16;
238 case MON_ADAMANT_COINS: return 17;
247 * @brief オブジェクトがクロークかどうかを判定する /
248 * Hack -- determine if a template is Cloak
249 * @param k_idx 判定したいオブジェクトのベースアイテムID
250 * @return オブジェクトがクロークならばTRUEを返す
252 static bool kind_is_cloak(KIND_OBJECT_IDX k_idx)
254 object_kind *k_ptr = &k_info[k_idx];
256 /* Analyze the item type */
257 if (k_ptr->tval == TV_CLOAK)
262 /* Assume not good */
268 * @brief オブジェクトが竿状武器かどうかを判定する /
269 * Hack -- determine if a template is Polearm
270 * @param k_idx 判定したいオブジェクトのベースアイテムID
271 * @return オブジェクトが竿状武器ならばTRUEを返す
273 static bool kind_is_polearm(KIND_OBJECT_IDX k_idx)
275 object_kind *k_ptr = &k_info[k_idx];
277 /* Analyze the item type */
278 if (k_ptr->tval == TV_POLEARM)
283 /* Assume not good */
289 * @brief オブジェクトが剣かどうかを判定する /
290 * Hack -- determine if a template is Sword
291 * @param k_idx 判定したいオブジェクトのベースアイテムID
292 * @return オブジェクトが剣ならばTRUEを返す
294 static bool kind_is_sword(KIND_OBJECT_IDX k_idx)
296 object_kind *k_ptr = &k_info[k_idx];
298 /* Analyze the item type */
299 if ((k_ptr->tval == TV_SWORD) && (k_ptr->sval > 2))
304 /* Assume not good */
310 * @brief オブジェクトが魔法書かどうかを判定する /
311 * Hack -- determine if a template is Book
312 * @param k_idx 判定したいオブジェクトのベースアイテムID
313 * @return オブジェクトが魔法書ならばTRUEを返す
315 static bool kind_is_book(KIND_OBJECT_IDX k_idx)
317 object_kind *k_ptr = &k_info[k_idx];
319 /* Analyze the item type */
320 if ((k_ptr->tval >= TV_LIFE_BOOK) && (k_ptr->tval <= TV_CRUSADE_BOOK))
325 /* Assume not good */
331 * @brief オブジェクトがベースアイテム時点でGOODかどうかを判定する /
332 * Hack -- determine if a template is Good book
333 * @param k_idx 判定したいオブジェクトのベースアイテムID
334 * @return オブジェクトがベースアイテム時点でGOODなアイテムならばTRUEを返す
336 static bool kind_is_good_book(KIND_OBJECT_IDX k_idx)
338 object_kind *k_ptr = &k_info[k_idx];
340 /* Analyze the item type */
341 if ((k_ptr->tval >= TV_LIFE_BOOK) && (k_ptr->tval <= TV_CRUSADE_BOOK) && (k_ptr->tval != TV_ARCANE_BOOK) && (k_ptr->sval > 1))
346 /* Assume not good */
352 * @brief オブジェクトが鎧かどうかを判定する /
353 * Hack -- determine if a template is Armor
354 * @param k_idx 判定したいオブジェクトのベースアイテムID
355 * @return オブジェクトが鎧ならばTRUEを返す
357 static bool kind_is_armor(KIND_OBJECT_IDX k_idx)
359 object_kind *k_ptr = &k_info[k_idx];
361 /* Analyze the item type */
362 if (k_ptr->tval == TV_HARD_ARMOR)
367 /* Assume not good */
373 * @brief オブジェクトが打撃武器かどうかを判定する /
374 * Hack -- determine if a template is hafted weapon
375 * @param k_idx 判定したいオブジェクトのベースアイテムID
376 * @return オブジェクトが打撃武器ならばTRUEを返す
378 static bool kind_is_hafted(KIND_OBJECT_IDX k_idx)
380 object_kind *k_ptr = &k_info[k_idx];
382 /* Analyze the item type */
383 if (k_ptr->tval == TV_HAFTED)
388 /* Assume not good */
393 * @brief クエストを達成状態にする /
394 * @param quest_num 達成状態にしたいクエストのID
397 void complete_quest(int quest_num)
399 quest_type* const q_ptr = &quest[quest_num];
403 case QUEST_TYPE_RANDOM:
404 if (record_rand_quest) do_cmd_write_nikki(NIKKI_RAND_QUEST_C, quest_num, NULL);
407 if (record_fix_quest) do_cmd_write_nikki(NIKKI_FIX_QUEST_C, quest_num, NULL);
411 q_ptr->status = QUEST_STATUS_COMPLETED;
412 q_ptr->complev = (byte)p_ptr->lev;
414 q_ptr->comptime = playtime;
416 if (!(q_ptr->flags & QUEST_FLAG_SILENT))
418 play_music(TERM_XTRA_MUSIC_BASIC, MUSIC_BASIC_QUEST_CLEAR);
419 msg_print(_("クエストを達成した!", "You just completed your quest!"));
425 * @brief 現在フロアに残っている敵モンスターの数を返す /
426 * @return 現在の敵モンスターの数
428 static int count_all_hostile_monsters(void)
433 for (x = 0; x < cur_wid; ++ x)
435 for (y = 0; y < cur_hgt; ++ y)
437 MONSTER_IDX m_idx = cave[y][x].m_idx;
439 if (m_idx > 0 && is_hostile(&m_list[m_idx]))
450 * @brief 特定の敵を倒した際にクエスト達成処理 /
451 * Check for "Quest" completion when a quest monster is killed or charmed.
452 * @param m_ptr 撃破したモンスターの構造体参照ポインタ
455 void check_quest_completion(monster_type *m_ptr)
461 bool create_stairs = FALSE;
467 /* Get the location */
472 quest_num = p_ptr->inside_quest;
474 /* Search for an active quest on this dungeon level */
479 for (i = max_q_idx - 1; i > 0; i--)
481 quest_type* const q_ptr = &quest[i];
483 /* Quest is not active */
484 if (q_ptr->status != QUEST_STATUS_TAKEN)
487 /* Quest is not a dungeon quest */
488 if (q_ptr->flags & QUEST_FLAG_PRESET)
491 /* Quest is not on this level */
492 if ((q_ptr->level != dun_level) &&
493 (q_ptr->type != QUEST_TYPE_KILL_ANY_LEVEL))
496 /* Not a "kill monster" quest */
497 if ((q_ptr->type == QUEST_TYPE_FIND_ARTIFACT) ||
498 (q_ptr->type == QUEST_TYPE_FIND_EXIT))
501 /* Interesting quest */
502 if ((q_ptr->type == QUEST_TYPE_KILL_NUMBER) ||
503 (q_ptr->type == QUEST_TYPE_TOWER) ||
504 (q_ptr->type == QUEST_TYPE_KILL_ALL))
507 /* Interesting quest */
508 if (((q_ptr->type == QUEST_TYPE_KILL_LEVEL) ||
509 (q_ptr->type == QUEST_TYPE_KILL_ANY_LEVEL) ||
510 (q_ptr->type == QUEST_TYPE_RANDOM)) &&
511 (q_ptr->r_idx == m_ptr->r_idx))
518 /* Handle the current quest */
519 if (quest_num && (quest[quest_num].status == QUEST_STATUS_TAKEN))
522 quest_type* const q_ptr = &quest[quest_num];
526 case QUEST_TYPE_KILL_NUMBER:
530 if (q_ptr->cur_num >= q_ptr->num_mon)
532 complete_quest(quest_num);
538 case QUEST_TYPE_KILL_ALL:
540 if (!is_hostile(m_ptr)) break;
542 if (count_all_hostile_monsters() == 1)
544 if (q_ptr->flags & QUEST_FLAG_SILENT)
546 q_ptr->status = QUEST_STATUS_FINISHED;
550 complete_quest(quest_num);
555 case QUEST_TYPE_KILL_LEVEL:
556 case QUEST_TYPE_RANDOM:
558 /* Only count valid monsters */
559 if (q_ptr->r_idx != m_ptr->r_idx)
564 if (q_ptr->cur_num >= q_ptr->max_num)
566 complete_quest(quest_num);
568 if (!(q_ptr->flags & QUEST_FLAG_PRESET))
570 create_stairs = TRUE;
571 p_ptr->inside_quest = 0;
574 /* Finish the two main quests without rewarding */
575 if ((quest_num == QUEST_OBERON) || (quest_num == QUEST_SERPENT))
577 q_ptr->status = QUEST_STATUS_FINISHED;
580 if (q_ptr->type == QUEST_TYPE_RANDOM)
583 q_ptr->status = QUEST_STATUS_FINISHED;
588 case QUEST_TYPE_KILL_ANY_LEVEL:
591 if (q_ptr->cur_num >= q_ptr->max_num)
593 complete_quest(quest_num);
598 case QUEST_TYPE_TOWER:
600 if (!is_hostile(m_ptr)) break;
602 if (count_all_hostile_monsters() == 1)
604 q_ptr->status = QUEST_STATUS_STAGE_COMPLETED;
606 if((quest[QUEST_TOWER1].status == QUEST_STATUS_STAGE_COMPLETED) &&
607 (quest[QUEST_TOWER2].status == QUEST_STATUS_STAGE_COMPLETED) &&
608 (quest[QUEST_TOWER3].status == QUEST_STATUS_STAGE_COMPLETED))
611 complete_quest(QUEST_TOWER1);
619 /* Create a magical staircase */
625 while (cave_perma_bold(y, x) || cave[y][x].o_idx || (cave[y][x].info & CAVE_OBJECT) )
627 /* Pick a location */
628 scatter(&ny, &nx, y, x, 1, 0);
634 /* Explain the staircase */
635 msg_print(_("魔法の階段が現れた...", "A magical staircase appears..."));
637 /* Create stairs down */
638 cave_set_feat(y, x, feat_down_stair);
640 /* Remember to update everything */
641 p_ptr->update |= (PU_FLOW);
651 for (i = 0; i < (dun_level / 15)+1; i++)
653 /* Get local object */
656 /* Wipe the object */
659 /* Make a great object */
660 make_object(o_ptr, AM_GOOD | AM_GREAT);
662 /* Drop it in the dungeon */
663 (void)drop_near(o_ptr, -1, y, x);
669 * @brief 特定のアーティファクトを入手した際のクエスト達成処理 /
670 * Check for "Quest" completion when a quest monster is killed or charmed.
671 * @param o_ptr 入手したオブジェクトの構造体参照ポインタ
674 void check_find_art_quest_completion(object_type *o_ptr)
677 /* Check if completed a quest */
678 for (i = 0; i < max_q_idx; i++)
680 if ((quest[i].type == QUEST_TYPE_FIND_ARTIFACT) &&
681 (quest[i].status == QUEST_STATUS_TAKEN) &&
682 (quest[i].k_idx == o_ptr->name1))
691 * @brief モンスターを撃破した際の述語メッセージを返す /
692 * Return monster death string
693 * @param r_ptr 撃破されたモンスターの種族情報を持つ構造体の参照ポインタ
694 * @return 撃破されたモンスターの述語
696 cptr extract_note_dies(monster_race *r_ptr)
698 /* Some monsters get "destroyed" */
699 if (!monster_living(r_ptr))
703 for (i = 0; i < 4; i++)
705 if (r_ptr->blow[i].method == RBM_EXPLODE)
707 return _("は爆発して粉々になった。", " explodes into tiny shreds.");
710 return _("を倒した。", " is destroyed.");
713 /* Assume a default death */
714 return _("は死んだ。", " dies.");
719 * @brief モンスターが死亡した時の処理 /
720 * Handle the "death" of a monster.
721 * @param m_idx 死亡したモンスターのID
722 * @param drop_item TRUEならばモンスターのドロップ処理を行う
723 * @return 撃破されたモンスターの述語
726 * Disperse treasures centered at the monster location based on the
727 * various flags contained in the monster flags fields.
728 * Check for "Quest" completion when a quest monster is killed.
729 * Note that only the player can induce "monster_death()" on Uniques.
730 * Thus (for now) all Quest monsters should be Uniques.
731 * Note that monsters can now carry objects, and when a monster dies,
732 * it drops all of its objects, which may disappear in crowded rooms.
735 void monster_death(MONSTER_IDX m_idx, bool drop_item)
744 monster_type *m_ptr = &m_list[m_idx];
746 monster_race *r_ptr = &r_info[m_ptr->r_idx];
748 bool visible = ((m_ptr->ml && !p_ptr->image) || (r_ptr->flags1 & RF1_UNIQUE));
752 bool do_gold = (!(r_ptr->flags1 & RF1_ONLY_ITEM));
753 bool do_item = (!(r_ptr->flags1 & RF1_ONLY_GOLD));
754 bool cloned = (m_ptr->smart & SM_CLONED) ? TRUE : FALSE;
755 int force_coin = get_coin_type(m_ptr->r_idx);
760 bool drop_chosen_item = drop_item && !cloned && !p_ptr->inside_arena
761 && !p_ptr->inside_battle && !is_pet(m_ptr);
763 /* The caster is dead? */
764 if (world_monster && world_monster == m_idx) world_monster = 0;
766 /* Notice changes in view */
767 if (r_ptr->flags7 & (RF7_LITE_MASK | RF7_DARK_MASK))
769 /* Update some things */
770 p_ptr->update |= (PU_MON_LITE);
773 /* Get the location */
777 if (record_named_pet && is_pet(m_ptr) && m_ptr->nickname)
781 monster_desc(m_name, m_ptr, MD_INDEF_VISIBLE);
782 do_cmd_write_nikki(NIKKI_NAMED_PET, 3, m_name);
785 /* Let monsters explode! */
786 for (i = 0; i < 4; i++)
788 if (r_ptr->blow[i].method == RBM_EXPLODE)
790 BIT_FLAGS flg = PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL;
791 int typ = mbe_info[r_ptr->blow[i].effect].explode_type;
792 DICE_NUMBER d_dice = r_ptr->blow[i].d_dice;
793 DICE_SID d_side = r_ptr->blow[i].d_side;
794 HIT_POINT damage = damroll(d_dice, d_side);
796 project(m_idx, 3, y, x, damage, typ, flg, -1);
801 if (m_ptr->mflag2 & MFLAG2_CHAMELEON)
803 choose_new_monster(m_idx, TRUE, MON_CHAMELEON);
804 r_ptr = &r_info[m_ptr->r_idx];
807 /* Check for quest completion */
808 check_quest_completion(m_ptr);
810 /* Handle the possibility of player vanquishing arena combatant -KMW- */
811 if (p_ptr->inside_arena && !is_pet(m_ptr))
813 p_ptr->exit_bldg = TRUE;
815 if (p_ptr->arena_number > MAX_ARENA_MONS)
817 msg_print(_("素晴らしい!君こそ真の勝利者だ。", "You are a Genuine Champion!"));
821 msg_print(_("勝利!チャンピオンへの道を進んでいる。", "Victorious! You're on your way to becoming Champion."));
824 if (arena_info[p_ptr->arena_number].tval)
826 /* Get local object */
829 /* Prepare to make a prize */
830 object_prep(q_ptr, lookup_kind(arena_info[p_ptr->arena_number].tval, arena_info[p_ptr->arena_number].sval));
832 apply_magic(q_ptr, object_level, AM_NO_FIXED_ART);
834 /* Drop it in the dungeon */
835 (void)drop_near(q_ptr, -1, y, x);
838 if (p_ptr->arena_number > MAX_ARENA_MONS) p_ptr->arena_number++;
839 p_ptr->arena_number++;
844 /* Extract monster name */
845 monster_desc(m_name, m_ptr, MD_IGNORE_HALLU | MD_ASSUME_VISIBLE | MD_INDEF_VISIBLE);
847 do_cmd_write_nikki(NIKKI_ARENA, p_ptr->arena_number, m_name);
851 if (m_idx == p_ptr->riding)
853 if (rakuba(-1, FALSE))
855 msg_print(_("地面に落とされた。", "You have fallen from your riding pet."));
859 /* Drop a dead corpse? */
860 if (one_in_(r_ptr->flags1 & RF1_UNIQUE ? 1 : 4) &&
861 (r_ptr->flags9 & (RF9_DROP_CORPSE | RF9_DROP_SKELETON)) &&
862 !(p_ptr->inside_arena || p_ptr->inside_battle || cloned || ((m_ptr->r_idx == today_mon) && is_pet(m_ptr))))
864 /* Assume skeleton */
868 * We cannot drop a skeleton? Note, if we are in this check,
869 * we *know* we can drop at least a corpse or a skeleton
871 if (!(r_ptr->flags9 & RF9_DROP_SKELETON))
873 else if ((r_ptr->flags9 & RF9_DROP_CORPSE) && (r_ptr->flags1 & RF1_UNIQUE))
876 /* Else, a corpse is more likely unless we did a "lot" of damage */
877 else if (r_ptr->flags9 & RF9_DROP_CORPSE)
879 /* Lots of damage in one blow */
880 if ((0 - ((m_ptr->maxhp) / 4)) > m_ptr->hp)
882 if (one_in_(5)) corpse = TRUE;
886 if (!one_in_(5)) corpse = TRUE;
890 /* Get local object */
893 /* Prepare to make an object */
894 object_prep(q_ptr, lookup_kind(TV_CORPSE, (corpse ? SV_CORPSE : SV_SKELETON)));
896 apply_magic(q_ptr, object_level, AM_NO_FIXED_ART);
898 q_ptr->pval = m_ptr->r_idx;
900 /* Drop it in the dungeon */
901 (void)drop_near(q_ptr, -1, y, x);
904 /* Drop objects being carried */
905 monster_drop_carried_objects(m_ptr);
907 if (r_ptr->flags1 & RF1_DROP_GOOD) mo_mode |= AM_GOOD;
908 if (r_ptr->flags1 & RF1_DROP_GREAT) mo_mode |= AM_GREAT;
910 switch (m_ptr->r_idx)
912 case MON_PINK_HORROR:
913 /* Pink horrors are replaced with 2 Blue horrors */
914 if (!(p_ptr->inside_arena || p_ptr->inside_battle))
918 for (i = 0; i < 2; i++)
921 bool pet = is_pet(m_ptr);
924 if (pet) mode |= PM_FORCE_PET;
926 if (summon_specific((pet ? -1 : m_idx), wy, wx, 100, SUMMON_BLUE_HORROR, mode))
928 if (player_can_see_bold(wy, wx))
934 msg_print(_("ピンク・ホラーは分裂した!", "The Pink horror divides!"));
938 case MON_BLOODLETTER:
939 /* Bloodletters of Khorne may drop a blade of chaos */
940 if (drop_chosen_item && (randint1(100) < 15))
942 /* Get local object */
945 /* Prepare to make a Blade of Chaos */
946 object_prep(q_ptr, lookup_kind(TV_SWORD, SV_BLADE_OF_CHAOS));
948 apply_magic(q_ptr, object_level, AM_NO_FIXED_ART | mo_mode);
950 /* Drop it in the dungeon */
951 (void)drop_near(q_ptr, -1, y, x);
956 if (drop_chosen_item && (dun_level > 9))
958 /* Get local object */
961 /* Wipe the object */
964 /* Activate restriction */
965 if ((dun_level > 49) && one_in_(5))
966 get_obj_num_hook = kind_is_good_book;
968 get_obj_num_hook = kind_is_book;
971 make_object(q_ptr, mo_mode);
973 /* Drop it in the dungeon */
974 (void)drop_near(q_ptr, -1, y, x);
980 * Mega^3-hack: killing a 'Warrior of the Dawn' is likely to
981 * spawn another in the fallen one's place!
983 if (!p_ptr->inside_arena && !p_ptr->inside_battle)
987 POSITION wy = y, wx = x;
989 bool pet = is_pet(m_ptr);
993 scatter(&wy, &wx, y, x, 20, 0);
995 while (!(in_bounds(wy, wx) && cave_empty_bold2(wy, wx)) && --attempts);
1000 if (pet) mode |= PM_FORCE_PET;
1002 if (summon_specific((pet ? -1 : m_idx), wy, wx, 100, SUMMON_DAWN, mode))
1004 if (player_can_see_bold(wy, wx))
1005 msg_print(_("新たな戦士が現れた!", "A new warrior steps forth!"));
1013 /* One more ultra-hack: An Unmaker goes out with a big bang! */
1015 BIT_FLAGS flg = PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL;
1016 (void)project(m_idx, 6, y, x, 100, GF_CHAOS, flg, -1);
1020 case MON_UNICORN_ORD:
1023 /* Reward for "lazy" player */
1024 if (p_ptr->pseikaku == SEIKAKU_NAMAKE)
1027 artifact_type *a_ptr = NULL;
1029 if (!drop_chosen_item) break;
1033 switch (randint0(3))
1036 a_idx = ART_NAMAKE_HAMMER;
1039 a_idx = ART_NAMAKE_BOW;
1042 a_idx = ART_NAMAKE_ARMOR;
1046 a_ptr = &a_info[a_idx];
1048 while (a_ptr->cur_num);
1050 /* Create the artifact */
1051 if (create_named_art(a_idx, y, x))
1055 /* Hack -- Memorize location of artifact in saved floors */
1056 if (character_dungeon) a_ptr->floor_id = p_ptr->floor_id;
1058 else if (!preserve_mode) a_ptr->cur_num = 1;
1063 if (!drop_chosen_item) break;
1065 /* Get local object */
1068 /* Mega-Hack -- Prepare to make "Grond" */
1069 object_prep(q_ptr, lookup_kind(TV_HAFTED, SV_GROND));
1071 /* Mega-Hack -- Mark this item as "Grond" */
1072 q_ptr->name1 = ART_GROND;
1074 /* Mega-Hack -- Actually create "Grond" */
1075 apply_magic(q_ptr, -1, AM_GOOD | AM_GREAT);
1077 /* Drop it in the dungeon */
1078 (void)drop_near(q_ptr, -1, y, x);
1080 /* Get local object */
1083 /* Mega-Hack -- Prepare to make "Chaos" */
1084 object_prep(q_ptr, lookup_kind(TV_CROWN, SV_CHAOS));
1086 /* Mega-Hack -- Mark this item as "Chaos" */
1087 q_ptr->name1 = ART_CHAOS;
1089 /* Mega-Hack -- Actually create "Chaos" */
1090 apply_magic(q_ptr, -1, AM_GOOD | AM_GREAT);
1092 /* Drop it in the dungeon */
1093 (void)drop_near(q_ptr, -1, y, x);
1096 case MON_B_DEATH_SWORD:
1097 if (drop_chosen_item)
1099 /* Get local object */
1102 /* Prepare to make a broken sword */
1103 object_prep(q_ptr, lookup_kind(TV_SWORD, randint1(2)));
1105 /* Drop it in the dungeon */
1106 (void)drop_near(q_ptr, -1, y, x);
1112 if (drop_chosen_item && ((m_ptr->r_idx == MON_A_GOLD) ||
1113 ((m_ptr->r_idx == MON_A_SILVER) && (r_ptr->r_akills % 5 == 0))))
1115 /* Get local object */
1118 /* Prepare to make a Can of Toys */
1119 object_prep(q_ptr, lookup_kind(TV_CHEST, SV_CHEST_KANDUME));
1121 apply_magic(q_ptr, object_level, AM_NO_FIXED_ART);
1123 /* Drop it in the dungeon */
1124 (void)drop_near(q_ptr, -1, y, x);
1130 BIT_FLAGS flg = PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL;
1131 (void)project(m_idx, 3, y, x, damroll(20, 10), GF_FIRE, flg, -1);
1136 if (!drop_chosen_item) break;
1138 switch (r_ptr->d_char)
1143 /* Get local object */
1146 /* Wipe the object */
1149 /* Activate restriction */
1150 get_obj_num_hook = kind_is_cloak;
1153 make_object(q_ptr, mo_mode);
1155 /* Drop it in the dungeon */
1156 (void)drop_near(q_ptr, -1, y, x);
1163 /* Get local object */
1166 /* Wipe the object */
1169 /* Activate restriction */
1170 get_obj_num_hook = kind_is_polearm;
1172 /* Make a poleweapon */
1173 make_object(q_ptr, mo_mode);
1175 /* Drop it in the dungeon */
1176 (void)drop_near(q_ptr, -1, y, x);
1183 /* Get local object */
1186 /* Wipe the object */
1189 /* Activate restriction */
1190 get_obj_num_hook = kind_is_armor;
1192 /* Make a hard armor */
1193 make_object(q_ptr, mo_mode);
1195 /* Drop it in the dungeon */
1196 (void)drop_near(q_ptr, -1, y, x);
1203 /* Get local object */
1206 /* Wipe the object */
1209 /* Activate restriction */
1210 get_obj_num_hook = kind_is_hafted;
1212 /* Make a hafted weapon */
1213 make_object(q_ptr, mo_mode);
1215 /* Drop it in the dungeon */
1216 (void)drop_near(q_ptr, -1, y, x);
1221 if (m_ptr->r_idx != MON_STORMBRINGER)
1223 /* Get local object */
1226 /* Wipe the object */
1229 /* Activate restriction */
1230 get_obj_num_hook = kind_is_sword;
1233 make_object(q_ptr, mo_mode);
1235 /* Drop it in the dungeon */
1236 (void)drop_near(q_ptr, -1, y, x);
1243 /* Mega-Hack -- drop fixed items */
1244 if (drop_chosen_item)
1249 for(i = 0; i < 4; i++)
1251 if(!r_ptr->artifact_id[i]) break;
1252 a_idx = r_ptr->artifact_id[i];
1253 chance = r_ptr->artifact_percent[i];
1256 if ((a_idx > 0) && ((randint0(100) < chance) || p_ptr->wizard))
1258 artifact_type *a_ptr = &a_info[a_idx];
1260 if (!a_ptr->cur_num)
1262 /* Create the artifact */
1263 if (create_named_art(a_idx, y, x))
1267 /* Hack -- Memorize location of artifact in saved floors */
1268 if (character_dungeon) a_ptr->floor_id = p_ptr->floor_id;
1270 else if (!preserve_mode) a_ptr->cur_num = 1;
1274 if ((r_ptr->flags7 & RF7_GUARDIAN) && (d_info[dungeon_type].final_guardian == m_ptr->r_idx))
1276 IDX k_idx = d_info[dungeon_type].final_object ? d_info[dungeon_type].final_object
1277 : lookup_kind(TV_SCROLL, SV_SCROLL_ACQUIREMENT);
1279 if (d_info[dungeon_type].final_artifact)
1281 a_idx = d_info[dungeon_type].final_artifact;
1282 artifact_type *a_ptr = &a_info[a_idx];
1284 if (!a_ptr->cur_num)
1286 /* Create the artifact */
1287 if (create_named_art(a_idx, y, x))
1291 /* Hack -- Memorize location of artifact in saved floors */
1292 if (character_dungeon) a_ptr->floor_id = p_ptr->floor_id;
1294 else if (!preserve_mode) a_ptr->cur_num = 1;
1296 /* Prevent rewarding both artifact and "default" object */
1297 if (!d_info[dungeon_type].final_object) k_idx = 0;
1303 /* Get local object */
1306 /* Prepare to make a reward */
1307 object_prep(q_ptr, k_idx);
1309 apply_magic(q_ptr, object_level, AM_NO_FIXED_ART | AM_GOOD);
1311 /* Drop it in the dungeon */
1312 (void)drop_near(q_ptr, -1, y, x);
1314 msg_format(_("あなたは%sを制覇した!", "You have conquered %s!"),d_name+d_info[dungeon_type].name);
1318 /* Determine how much we can drop */
1319 if ((r_ptr->flags1 & RF1_DROP_60) && (randint0(100) < 60)) number++;
1320 if ((r_ptr->flags1 & RF1_DROP_90) && (randint0(100) < 90)) number++;
1321 if (r_ptr->flags1 & RF1_DROP_1D2) number += damroll(1, 2);
1322 if (r_ptr->flags1 & RF1_DROP_2D2) number += damroll(2, 2);
1323 if (r_ptr->flags1 & RF1_DROP_3D2) number += damroll(3, 2);
1324 if (r_ptr->flags1 & RF1_DROP_4D2) number += damroll(4, 2);
1326 if (cloned && !(r_ptr->flags1 & RF1_UNIQUE))
1327 number = 0; /* Clones drop no stuff unless Cloning Pits */
1329 if (is_pet(m_ptr) || p_ptr->inside_battle || p_ptr->inside_arena)
1330 number = 0; /* Pets drop no stuff */
1331 if (!drop_item && (r_ptr->d_char != '$')) number = 0;
1333 if((r_ptr->flags2 & (RF2_MULTIPLY)) && (r_ptr->r_akills > 1024))
1334 number = 0; /* Limit of Multiply monster drop */
1336 /* Hack -- handle creeping coins */
1337 coin_type = force_coin;
1339 /* Average dungeon and monster levels */
1340 object_level = (dun_level + r_ptr->level) / 2;
1342 /* Drop some objects */
1343 for (j = 0; j < number; j++)
1345 /* Get local object */
1348 /* Wipe the object */
1352 if (do_gold && (!do_item || (randint0(100) < 50)))
1354 /* Make some gold */
1355 if (!make_gold(q_ptr)) continue;
1364 /* Make an object */
1365 if (!make_object(q_ptr, mo_mode)) continue;
1371 /* Drop it in the dungeon */
1372 (void)drop_near(q_ptr, -1, y, x);
1375 /* Reset the object level */
1376 object_level = base_level;
1378 /* Reset "coin" type */
1382 /* Take note of any dropped treasure */
1383 if (visible && (dump_item || dump_gold))
1385 /* Take notes on treasure */
1386 lore_treasure(m_idx, dump_item, dump_gold);
1389 /* Only process "Quest Monsters" */
1390 if (!(r_ptr->flags1 & RF1_QUESTOR)) return;
1391 if (p_ptr->inside_battle) return;
1394 if ((m_ptr->r_idx == MON_SERPENT) && !cloned)
1397 p_ptr->total_winner = TRUE;
1399 /* Redraw the "title" */
1400 p_ptr->redraw |= (PR_TITLE);
1402 play_music(TERM_XTRA_MUSIC_BASIC, MUSIC_BASIC_FINAL_QUEST_CLEAR);
1404 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, _("見事に変愚蛮怒の勝利者となった!", "become *WINNER* of Hengband finely!"));
1406 if ((p_ptr->pclass == CLASS_CHAOS_WARRIOR) || (p_ptr->muta2 & MUT2_CHAOS_GIFT))
1408 msg_format(_("%sからの声が響いた。", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
1409 msg_print(_("『よくやった、定命の者よ!』", "'Thou art donst well, mortal!'"));
1412 /* Congratulations */
1413 msg_print(_("*** おめでとう ***", "*** CONGRATULATIONS ***"));
1414 msg_print(_("あなたはゲームをコンプリートしました。", "You have won the game!"));
1415 msg_print(_("準備が整ったら引退(自殺コマンド)しても結構です。", "You may retire (commit suicide) when you are ready."));
1420 * @brief モンスターに与えたダメージの修正処理 /
1421 * Modify the physical damage done to the monster.
1422 * @param m_ptr ダメージを受けるモンスターの構造体参照ポインタ
1423 * @param dam ダメージ基本値
1424 * @param is_psy_spear 攻撃手段が光の剣ならばTRUE
1425 * @return 修正を行った結果のダメージ量
1428 * (for example when it's invulnerable or shielded)
1429 * ToDo: Accept a damage-type to calculate the modified damage from
1430 * things like fire, frost, lightning, poison, ... attacks.
1431 * "type" is not yet used and should be 0.
1434 HIT_POINT mon_damage_mod(monster_type *m_ptr, HIT_POINT dam, bool is_psy_spear)
1436 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1438 if ((r_ptr->flagsr & RFR_RES_ALL) && dam > 0)
1441 if ((dam == 0) && one_in_(3)) dam = 1;
1444 if (MON_INVULNER(m_ptr))
1448 if (!p_ptr->blind && is_seen(m_ptr))
1450 msg_print(_("バリアを切り裂いた!", "The barrier is penetrated!"));
1453 else if (!one_in_(PENETRATE_INVULNERABILITY))
1463 * @brief モンスターに与えたダメージを元に経験値を加算する /
1464 * Calculate experience point to be get
1465 * @param dam 与えたダメージ量
1466 * @param m_ptr ダメージを与えたモンスターの構造体参照ポインタ
1470 * Even the 64 bit operation is not big enough to avoid overflaw
1471 * unless we carefully choose orders of multiplication and division.
1472 * Get the coefficient first, and multiply (potentially huge) base
1473 * experience point of a monster later.
1476 static void get_exp_from_mon(HIT_POINT dam, monster_type *m_ptr)
1478 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1485 if (!m_ptr->r_idx) return;
1486 if (is_pet(m_ptr) || p_ptr->inside_battle) return;
1489 * - Ratio of monster's level to player's level effects
1490 * - Varying speed effects
1491 * - Get a fraction in proportion of damage point
1493 new_exp = r_ptr->level * SPEED_TO_ENERGY(m_ptr->mspeed) * dam;
1496 div_l = (p_ptr->max_plv+2) * SPEED_TO_ENERGY(r_ptr->speed);
1498 /* Use (average maxhp * 2) as a denominator */
1499 if (!(r_ptr->flags1 & RF1_FORCE_MAXHP))
1500 s64b_mul(&div_h, &div_l, 0, r_ptr->hdice * (ironman_nightmare ? 2 : 1) * (r_ptr->hside + 1));
1502 s64b_mul(&div_h, &div_l, 0, r_ptr->hdice * (ironman_nightmare ? 2 : 1) * r_ptr->hside * 2);
1504 /* Special penalty in the wilderness */
1505 if (!dun_level && (!(r_ptr->flags8 & RF8_WILD_ONLY) || !(r_ptr->flags1 & RF1_UNIQUE)))
1506 s64b_mul(&div_h, &div_l, 0, 5);
1508 /* Do division first to prevent overflaw */
1509 s64b_div(&new_exp, &new_exp_frac, div_h, div_l);
1511 /* Special penalty for mutiply-monster */
1512 if ((r_ptr->flags2 & RF2_MULTIPLY) || (m_ptr->r_idx == MON_DAWN))
1514 int monnum_penarty = r_ptr->r_akills / 400;
1515 if (monnum_penarty > 8) monnum_penarty = 8;
1517 while (monnum_penarty--)
1520 s64b_RSHIFT(new_exp, new_exp_frac, 2);
1524 /* Special penalty for rest_and_shoot exp scum */
1525 if ((m_ptr->dealt_damage > (u32b)m_ptr->max_maxhp) && (m_ptr->hp >= 0))
1527 int over_damage = m_ptr->dealt_damage / m_ptr->max_maxhp;
1528 if (over_damage > 32) over_damage = 32;
1530 while (over_damage--)
1533 s64b_mul(&new_exp, &new_exp_frac, 0, 9);
1534 s64b_div(&new_exp, &new_exp_frac, 0, 10);
1538 /* Finally multiply base experience point of the monster */
1539 s64b_mul(&new_exp, &new_exp_frac, 0, r_ptr->mexp);
1541 /* Gain experience */
1542 gain_exp_64(new_exp, new_exp_frac);
1547 * @brief モンスターのHPをダメージに応じて減算する /
1548 * Decreases monsters hit points, handling monster death.
1549 * @param dam 与えたダメージ量
1550 * @param m_idx ダメージを与えたモンスターのID
1551 * @param fear ダメージによってモンスターが恐慌状態に陥ったならばTRUEを返す
1552 * @param note モンスターが倒された際の特別なメッセージ述語
1556 * We return TRUE if the monster has been killed (and deleted).
1557 * We announce monster death (using an optional "death message"
1558 * if given, and a otherwise a generic killed/destroyed message).
1559 * Only "physical attacks" can induce the "You have slain" message.
1560 * Missile and Spell attacks will induce the "dies" message, or
1561 * various "specialized" messages. Note that "You have destroyed"
1562 * and "is destroyed" are synonyms for "You have slain" and "dies".
1563 * Hack -- unseen monsters yield "You have killed it." message.
1564 * Added fear (DGK) and check whether to print fear messages -CWS
1565 * Made name, sex, and capitalization generic -BEN-
1566 * As always, the "ghost" processing is a total hack.
1567 * Hack -- we "delay" fear messages by passing around a "fear" flag.
1568 * XXX XXX XXX Consider decreasing monster experience over time, say,
1569 * by using "(m_exp * m_lev * (m_lev)) / (p_lev * (m_lev + n_killed))"
1570 * instead of simply "(m_exp * m_lev) / (p_lev)", to make the first
1571 * monster worth more than subsequent monsters. This would also need
1572 * to induce changes in the monster recall code.
1575 bool mon_take_hit(MONSTER_IDX m_idx, HIT_POINT dam, bool *fear, cptr note)
1577 monster_type *m_ptr = &m_list[m_idx];
1578 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1580 monster_type exp_mon;
1582 /* Innocent until proven otherwise */
1583 bool innocent = TRUE, thief = FALSE;
1587 (void)COPY(&exp_mon, m_ptr, monster_type);
1589 expdam = (m_ptr->hp > dam) ? dam : m_ptr->hp;
1591 get_exp_from_mon(expdam, &exp_mon);
1593 /* Genocided by chaos patron */
1594 if (!m_ptr->r_idx) m_idx = 0;
1596 /* Redraw (later) if needed */
1597 if (p_ptr->health_who == m_idx) p_ptr->redraw |= (PR_HEALTH);
1598 if (p_ptr->riding == m_idx) p_ptr->redraw |= (PR_UHEALTH);
1601 (void)set_monster_csleep(m_idx, 0);
1603 /* Hack - Cancel any special player stealth magics. -LM- */
1604 if (p_ptr->special_defense & NINJA_S_STEALTH)
1606 set_superstealth(FALSE);
1609 /* Genocided by chaos patron */
1610 if (!m_idx) return TRUE;
1615 m_ptr->dealt_damage += dam;
1616 if(m_ptr->dealt_damage > (u32b)m_ptr->max_maxhp * 100) m_ptr->dealt_damage = m_ptr->max_maxhp * 100;
1619 msg_format( _("合計%d/%dのダメージを与えた。","You do %d (out of %d) damage."),
1620 m_ptr->dealt_damage, m_ptr->maxhp);
1623 /* It is dead now */
1628 if (r_info[m_ptr->r_idx].flags7 & RF7_TANUKI)
1630 /* You might have unmasked Tanuki first time */
1631 r_ptr = &r_info[m_ptr->r_idx];
1632 m_ptr->ap_r_idx = m_ptr->r_idx;
1633 if (r_ptr->r_sights < MAX_SHORT) r_ptr->r_sights++;
1636 if (m_ptr->mflag2 & MFLAG2_CHAMELEON)
1638 /* You might have unmasked Chameleon first time */
1639 r_ptr = real_r_ptr(m_ptr);
1640 if (r_ptr->r_sights < MAX_SHORT) r_ptr->r_sights++;
1643 if (!(m_ptr->smart & SM_CLONED))
1645 /* When the player kills a Unique, it stays dead */
1646 if (r_ptr->flags1 & RF1_UNIQUE)
1650 /* Mega-Hack -- Banor & Lupart */
1651 if ((m_ptr->r_idx == MON_BANOR) || (m_ptr->r_idx == MON_LUPART))
1653 r_info[MON_BANORLUPART].max_num = 0;
1654 r_info[MON_BANORLUPART].r_pkills++;
1655 r_info[MON_BANORLUPART].r_akills++;
1656 if (r_info[MON_BANORLUPART].r_tkills < MAX_SHORT) r_info[MON_BANORLUPART].r_tkills++;
1658 else if (m_ptr->r_idx == MON_BANORLUPART)
1660 r_info[MON_BANOR].max_num = 0;
1661 r_info[MON_BANOR].r_pkills++;
1662 r_info[MON_BANOR].r_akills++;
1663 if (r_info[MON_BANOR].r_tkills < MAX_SHORT) r_info[MON_BANOR].r_tkills++;
1664 r_info[MON_LUPART].max_num = 0;
1665 r_info[MON_LUPART].r_pkills++;
1666 r_info[MON_LUPART].r_akills++;
1667 if (r_info[MON_LUPART].r_tkills < MAX_SHORT) r_info[MON_LUPART].r_tkills++;
1671 /* When the player kills a Nazgul, it stays dead */
1672 else if (r_ptr->flags7 & RF7_NAZGUL) r_ptr->max_num--;
1675 /* Count all monsters killed */
1676 if (r_ptr->r_akills < MAX_SHORT) r_ptr->r_akills++;
1678 /* Recall even invisible uniques or winners */
1679 if ((m_ptr->ml && !p_ptr->image) || (r_ptr->flags1 & RF1_UNIQUE))
1681 /* Count kills this life */
1682 if ((m_ptr->mflag2 & MFLAG2_KAGE) && (r_info[MON_KAGE].r_pkills < MAX_SHORT)) r_info[MON_KAGE].r_pkills++;
1683 else if (r_ptr->r_pkills < MAX_SHORT) r_ptr->r_pkills++;
1685 /* Count kills in all lives */
1686 if ((m_ptr->mflag2 & MFLAG2_KAGE) && (r_info[MON_KAGE].r_tkills < MAX_SHORT)) r_info[MON_KAGE].r_tkills++;
1687 else if (r_ptr->r_tkills < MAX_SHORT) r_ptr->r_tkills++;
1689 /* Hack -- Auto-recall */
1690 monster_race_track(m_ptr->ap_r_idx);
1693 /* Extract monster name */
1694 monster_desc(m_name, m_ptr, MD_TRUE_NAME);
1696 /* Don't kill Amberites */
1697 if ((r_ptr->flags3 & RF3_AMBERITE) && one_in_(2))
1699 int curses = 1 + randint1(3);
1700 bool stop_ty = FALSE;
1703 msg_format(_("%^sは恐ろしい血の呪いをあなたにかけた!", "%^s puts a terrible blood curse on you!"), m_name);
1704 curse_equipment(100, 50);
1708 stop_ty = activate_ty_curse(stop_ty, &count);
1713 if (r_ptr->flags2 & RF2_CAN_SPEAK)
1715 char line_got[1024];
1717 /* Dump a message */
1718 if (!get_rnd_line(_("mondeath_j.txt", "mondeath.txt"), m_ptr->r_idx, line_got))
1720 msg_format("%^s %s", m_name, line_got);
1723 if (m_ptr->r_idx == MON_SERPENT)
1725 /* Make screen dump */
1726 screen_dump = make_screen_dump();
1731 if (!(d_info[dungeon_type].flags1 & DF1_BEGINNER))
1733 if (!dun_level && !ambush_flag && !p_ptr->inside_arena)
1735 chg_virtue(V_VALOUR, -1);
1737 else if (r_ptr->level > dun_level)
1739 if (randint1(10) <= (r_ptr->level - dun_level))
1740 chg_virtue(V_VALOUR, 1);
1742 if (r_ptr->level > 60)
1744 chg_virtue(V_VALOUR, 1);
1746 if (r_ptr->level >= 2 * (p_ptr->lev+1))
1747 chg_virtue(V_VALOUR, 2);
1750 if (r_ptr->flags1 & RF1_UNIQUE)
1752 if (r_ptr->flags3 & (RF3_EVIL | RF3_GOOD)) chg_virtue(V_HARMONY, 2);
1754 if (r_ptr->flags3 & RF3_GOOD)
1756 chg_virtue(V_UNLIFE, 2);
1757 chg_virtue(V_VITALITY, -2);
1760 if (one_in_(3)) chg_virtue(V_INDIVIDUALISM, -1);
1763 if (m_ptr->r_idx == MON_BEGGAR || m_ptr->r_idx == MON_LEPER)
1765 chg_virtue(V_COMPASSION, -1);
1768 if ((r_ptr->flags3 & RF3_GOOD) &&
1769 ((r_ptr->level) / 10 + (3 * dun_level) >= randint1(100)))
1770 chg_virtue(V_UNLIFE, 1);
1772 if (r_ptr->d_char == 'A')
1774 if (r_ptr->flags1 & RF1_UNIQUE)
1775 chg_virtue(V_FAITH, -2);
1776 else if ((r_ptr->level) / 10 + (3 * dun_level) >= randint1(100))
1778 if (r_ptr->flags3 & RF3_GOOD) chg_virtue(V_FAITH, -1);
1779 else chg_virtue(V_FAITH, 1);
1782 else if (r_ptr->flags3 & RF3_DEMON)
1784 if (r_ptr->flags1 & RF1_UNIQUE)
1785 chg_virtue(V_FAITH, 2);
1786 else if ((r_ptr->level) / 10 + (3 * dun_level) >= randint1(100))
1787 chg_virtue(V_FAITH, 1);
1790 if ((r_ptr->flags3 & RF3_UNDEAD) && (r_ptr->flags1 & RF1_UNIQUE))
1791 chg_virtue(V_VITALITY, 2);
1793 if (r_ptr->r_deaths)
1795 if (r_ptr->flags1 & RF1_UNIQUE)
1797 chg_virtue(V_HONOUR, 10);
1799 else if ((r_ptr->level) / 10 + (2 * dun_level) >= randint1(100))
1801 chg_virtue(V_HONOUR, 1);
1804 if ((r_ptr->flags2 & RF2_MULTIPLY) && (r_ptr->r_akills > 1000) && one_in_(10))
1806 chg_virtue(V_VALOUR, -1);
1809 for (i = 0; i < 4; i++)
1811 if (r_ptr->blow[i].d_dice != 0) innocent = FALSE; /* Murderer! */
1813 if ((r_ptr->blow[i].effect == RBE_EAT_ITEM)
1814 || (r_ptr->blow[i].effect == RBE_EAT_GOLD))
1816 thief = TRUE; /* Thief! */
1819 /* The new law says it is illegal to live in the dungeon */
1820 if (r_ptr->level != 0) innocent = FALSE;
1824 if (r_ptr->flags1 & RF1_UNIQUE)
1825 chg_virtue(V_JUSTICE, 3);
1826 else if (1+((r_ptr->level) / 10 + (2 * dun_level))
1828 chg_virtue(V_JUSTICE, 1);
1832 chg_virtue (V_JUSTICE, -1);
1835 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)))
1837 if (one_in_(4)) chg_virtue(V_NATURE, -1);
1840 if ((r_ptr->flags1 & RF1_UNIQUE) && record_destroy_uniq)
1844 sprintf(note_buf, "%s%s", r_name + r_ptr->name, (m_ptr->smart & SM_CLONED) ? "(クローン)" : "");
1846 sprintf(note_buf, "%s%s", r_name + r_ptr->name, (m_ptr->smart & SM_CLONED) ? "(Clone)" : "");
1848 do_cmd_write_nikki(NIKKI_UNIQUE, 0, note_buf);
1854 /* Death by Missile/Spell attack */
1857 msg_format("%^s%s", m_name, note);
1860 /* Death by physical attack -- invisible monster */
1861 else if (!m_ptr->ml)
1864 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
1865 msg_format("せっかくだから%sを殺した。", m_name);
1867 msg_format("%sを殺した。", m_name);
1869 msg_format("You have killed %s.", m_name);
1874 /* Death by Physical attack -- non-living monster */
1875 else if (!monster_living(r_ptr))
1877 bool explode = FALSE;
1879 for (i = 0; i < 4; i++)
1881 if (r_ptr->blow[i].method == RBM_EXPLODE) explode = TRUE;
1884 /* Special note at death */
1886 msg_format(_("%sは爆発して粉々になった。", "%^s explodes into tiny shreds."), m_name);
1890 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
1891 msg_format("せっかくだから%sを倒した。", m_name);
1893 msg_format("%sを倒した。", m_name);
1895 msg_format("You have destroyed %s.", m_name);
1900 /* Death by Physical attack -- living monster */
1904 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
1905 msg_format("せっかくだから%sを葬り去った。", m_name);
1907 msg_format("%sを葬り去った。", m_name);
1909 msg_format("You have slain %s.", m_name);
1913 if ((r_ptr->flags1 & RF1_UNIQUE) && !(m_ptr->smart & SM_CLONED) && !vanilla_town)
1915 for (i = 0; i < MAX_KUBI; i++)
1917 if ((kubi_r_idx[i] == m_ptr->r_idx) && !(m_ptr->mflag2 & MFLAG2_CHAMELEON))
1919 msg_format(_("%sの首には賞金がかかっている。", "There is a price on %s's head."), m_name);
1925 /* Generate treasure */
1926 monster_death(m_idx, TRUE);
1928 /* Mega hack : replace IKETA to BIKETAL */
1929 if ((m_ptr->r_idx == MON_IKETA) &&
1930 !(p_ptr->inside_arena || p_ptr->inside_battle))
1932 int dummy_y = m_ptr->fy;
1933 int dummy_x = m_ptr->fx;
1934 BIT_FLAGS mode = 0L;
1936 if (is_pet(m_ptr)) mode |= PM_FORCE_PET;
1938 /* Delete the monster */
1939 delete_monster_idx(m_idx);
1941 if (summon_named_creature(0, dummy_y, dummy_x, MON_BIKETAL, mode))
1943 msg_print(_("「ハァッハッハッハ!!私がバイケタルだ!!」", "Uwa-hahaha! *I* am Biketal!"));
1948 /* Delete the monster */
1949 delete_monster_idx(m_idx);
1952 get_exp_from_mon((long)exp_mon.max_maxhp*2, &exp_mon);
1957 /* Monster is dead */
1964 /* Mega-Hack -- Pain cancels fear */
1965 if (MON_MONFEAR(m_ptr) && (dam > 0))
1968 if (set_monster_monfear(m_idx, MON_MONFEAR(m_ptr) - randint1(dam)))
1975 /* Sometimes a monster gets scared by damage */
1976 if (!MON_MONFEAR(m_ptr) && !(r_ptr->flags3 & (RF3_NO_FEAR)))
1978 /* Percentage of fully healthy */
1979 int percentage = (100L * m_ptr->hp) / m_ptr->maxhp;
1982 * Run (sometimes) if at 10% or less of max hit points,
1983 * or (usually) when hit for half its current hit points
1985 if ((randint1(10) >= percentage) ||
1986 ((dam >= m_ptr->hp) && (randint0(100) < 80)))
1988 /* Hack -- note fear */
1991 /* XXX XXX XXX Hack -- Add some timed fear */
1992 (void)set_monster_monfear(m_idx, (randint1(10) +
1993 (((dam >= m_ptr->hp) && (percentage > 7)) ?
1994 20 : ((11 - percentage) * 5))));
2001 if (p_ptr->riding && (p_ptr->riding == m_idx) && (dam > 0))
2005 /* Extract monster name */
2006 monster_desc(m_name, m_ptr, 0);
2008 if (m_ptr->hp > m_ptr->maxhp/3) dam = (dam + 1) / 2;
2009 if (rakuba((dam > 200) ? 200 : dam, FALSE))
2011 msg_format(_("%^sに振り落とされた!", "%^s has thrown you off!"), m_name);
2022 * @brief 現在のコンソール表示の縦横を返す。 /
2023 * Get term size and calculate screen size
2024 * @param wid_p コンソールの表示幅文字数を返す
2025 * @param hgt_p コンソールの表示行数を返す
2028 void get_screen_size(int *wid_p, int *hgt_p)
2030 Term_get_size(wid_p, hgt_p);
2031 *hgt_p -= ROW_MAP + 2;
2032 *wid_p -= COL_MAP + 2;
2033 if (use_bigtile) *wid_p /= 2;
2038 * @brief コンソール上におけるマップ表示の左上位置を返す /
2039 * Calculates current boundaries Called below and from "do_cmd_locate()".
2042 void panel_bounds_center(void)
2047 get_screen_size(&wid, &hgt);
2049 panel_row_max = panel_row_min + hgt - 1;
2050 panel_row_prt = panel_row_min - 1;
2051 panel_col_max = panel_col_min + wid - 1;
2052 panel_col_prt = panel_col_min - 13;
2057 * @brief コンソールのリサイズに合わせてマップを再描画する /
2058 * Map resizing whenever the main term changes size
2061 void resize_map(void)
2063 /* Only if the dungeon exists */
2064 if (!character_dungeon) return;
2066 /* Mega-Hack -- no panel yet */
2070 /* Reset the panels */
2071 panel_row_min = cur_hgt;
2072 panel_col_min = cur_wid;
2077 p_ptr->update |= (PU_TORCH | PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
2079 /* Forget lite/view */
2080 p_ptr->update |= (PU_UN_VIEW | PU_UN_LITE);
2082 /* Update lite/view */
2083 p_ptr->update |= (PU_VIEW | PU_LITE | PU_MON_LITE);
2085 /* Update monsters */
2086 p_ptr->update |= (PU_MONSTERS);
2088 /* Redraw everything */
2089 p_ptr->redraw |= (PR_WIPE | PR_BASIC | PR_EXTRA | PR_MAP | PR_EQUIPPY);
2091 /* Hack -- update */
2099 * Place the cursor on the player
2101 if (can_save) move_cursor_relative(p_ptr->y, p_ptr->x);
2108 * @brief コンソールを再描画する /
2109 * Redraw a term when it is resized
2112 void redraw_window(void)
2114 /* Only if the dungeon exists */
2115 if (!character_dungeon) return;
2118 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_SPELL | PW_PLAYER);
2121 p_ptr->window |= (PW_MESSAGE | PW_OVERHEAD | PW_DUNGEON | PW_MONSTER | PW_OBJECT);
2123 /* Hack -- update */
2132 * @brief フォーカスを当てるべきマップ描画の基準座標を指定する(サブルーチン)
2133 * @param dy 変更先のフロアY座標
2134 * @param dx 変更先のフロアX座標
2135 * Handle a request to change the current panel
2136 * Return TRUE if the panel was changed.
2137 * Also used in do_cmd_locate
2138 * @return 実際に再描画が必要だった場合TRUEを返す
2140 bool change_panel(int dy, int dx)
2146 get_screen_size(&wid, &hgt);
2148 /* Apply the motion */
2149 y = panel_row_min + dy * hgt / 2;
2150 x = panel_col_min + dx * wid / 2;
2152 /* Verify the row */
2153 if (y > cur_hgt - hgt) y = cur_hgt - hgt;
2156 /* Verify the col */
2157 if (x > cur_wid - wid) x = cur_wid - wid;
2160 /* Handle "changes" */
2161 if ((y != panel_row_min) || (x != panel_col_min))
2163 /* Save the new panel info */
2167 /* Recalculate the boundaries */
2168 panel_bounds_center();
2171 p_ptr->update |= (PU_MONSTERS);
2174 p_ptr->redraw |= (PR_MAP);
2188 * @brief フォーカスを当てるべきマップ描画の基準座標を指定する
2189 * @param y 変更先のフロアY座標
2190 * @param x 変更先のフロアX座標
2192 * Handle a request to change the current panel
2193 * Return TRUE if the panel was changed.
2194 * Also used in do_cmd_locate
2195 * @return 実際に再描画が必要だった場合TRUEを返す
2197 bool change_panel_xy(int y, int x)
2203 get_screen_size(&wid, &hgt);
2205 if (y < panel_row_min) dy = -1;
2206 if (y > panel_row_max) dy = 1;
2207 if (x < panel_col_min) dx = -1;
2208 if (x > panel_col_max) dx = 1;
2210 if (!dy && !dx) return (FALSE);
2212 return change_panel(dy, dx);
2217 * @brief マップ描画のフォーカスを当てるべき座標を更新する
2219 * Given an row (y) and col (x), this routine detects when a move
2220 * off the screen has occurred and figures new borders. -RAK-
2221 * "Update" forces a "full update" to take place.
2222 * The map is reprinted if necessary, and "TRUE" is returned.
2223 * @return 実際に再描画が必要だった場合TRUEを返す
2225 void verify_panel(void)
2237 get_screen_size(&wid, &hgt);
2239 max_prow_min = cur_hgt - hgt;
2240 max_pcol_min = cur_wid - wid;
2242 /* Bounds checking */
2243 if (max_prow_min < 0) max_prow_min = 0;
2244 if (max_pcol_min < 0) max_pcol_min = 0;
2246 /* Center on player */
2247 if (center_player && (center_running || !running))
2249 /* Center vertically */
2250 prow_min = y - hgt / 2;
2251 if (prow_min < 0) prow_min = 0;
2252 else if (prow_min > max_prow_min) prow_min = max_prow_min;
2254 /* Center horizontally */
2255 pcol_min = x - wid / 2;
2256 if (pcol_min < 0) pcol_min = 0;
2257 else if (pcol_min > max_pcol_min) pcol_min = max_pcol_min;
2261 prow_min = panel_row_min;
2262 pcol_min = panel_col_min;
2264 /* Scroll screen when 2 grids from top/bottom edge */
2265 if (y > panel_row_max - 2)
2267 while (y > prow_min + hgt-1 - 2)
2269 prow_min += (hgt / 2);
2273 if (y < panel_row_min + 2)
2275 while (y < prow_min + 2)
2277 prow_min -= (hgt / 2);
2281 if (prow_min > max_prow_min) prow_min = max_prow_min;
2282 if (prow_min < 0) prow_min = 0;
2284 /* Scroll screen when 4 grids from left/right edge */
2285 if (x > panel_col_max - 4)
2287 while (x > pcol_min + wid-1 - 4)
2289 pcol_min += (wid / 2);
2293 if (x < panel_col_min + 4)
2295 while (x < pcol_min + 4)
2297 pcol_min -= (wid / 2);
2301 if (pcol_min > max_pcol_min) pcol_min = max_pcol_min;
2302 if (pcol_min < 0) pcol_min = 0;
2305 /* Check for "no change" */
2306 if ((prow_min == panel_row_min) && (pcol_min == panel_col_min)) return;
2308 /* Save the new panel info */
2309 panel_row_min = prow_min;
2310 panel_col_min = pcol_min;
2312 /* Hack -- optional disturb on "panel change" */
2313 if (disturb_panel && !center_player) disturb(0, 0);
2315 /* Recalculate the boundaries */
2316 panel_bounds_center();
2319 p_ptr->update |= (PU_MONSTERS);
2322 p_ptr->redraw |= (PR_MAP);
2325 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
2330 * Monster health description
2332 cptr look_mon_desc(monster_type *m_ptr, BIT_FLAGS mode)
2334 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
2341 /* Determine if the monster is "living" */
2342 living = monster_living(ap_r_ptr);
2344 /* Calculate a health "percentage" */
2345 perc = 100L * m_ptr->hp / m_ptr->maxhp;
2347 /* Healthy monsters */
2348 if (m_ptr->hp >= m_ptr->maxhp)
2352 desc = living ? "無傷" : "無ダメージ";
2354 desc = living ? "unhurt" : "undamaged";
2359 else if (perc >= 60)
2362 desc = living ? "軽傷" : "小ダメージ";
2364 desc = living ? "somewhat wounded" : "somewhat damaged";
2369 else if (perc >= 25)
2372 desc = living ? "負傷" : "中ダメージ";
2374 desc = living ? "wounded" : "damaged";
2379 else if (perc >= 10)
2382 desc = living ? "重傷" : "大ダメージ";
2384 desc = living ? "badly wounded" : "badly damaged";
2392 desc = living ? "半死半生" : "倒れかけ";
2394 desc = living ? "almost dead" : "almost destroyed";
2399 /* Need attitude information? */
2402 /* Full information is not needed */
2405 else if (is_pet(m_ptr))
2407 attitude = _(", ペット", ", pet");
2409 else if (is_friendly(m_ptr))
2411 attitude = _(", 友好的", ", friendly");
2415 attitude = _("", "");
2419 /* Clone monster? */
2420 if (m_ptr->smart & SM_CLONED)
2429 /* Display monster's level --- idea borrowed from ToME */
2430 if (ap_r_ptr->r_tkills && !(m_ptr->mflag2 & MFLAG2_KAGE))
2432 return format(_("レベル%d, %s%s%s", "Level %d, %s%s%s"), ap_r_ptr->level, desc, attitude, clone);
2436 return format(_("レベル???, %s%s%s", "Level ???, %s%s%s"), desc, attitude, clone);
2443 * Angband sorting algorithm -- quick sort in place
2445 * Note that the details of the data we are sorting is hidden,
2446 * and we rely on the "ang_sort_comp()" and "ang_sort_swap()"
2447 * function hooks to interact with the data, which is given as
2448 * two pointers, and which may have any user-defined form.
2450 void ang_sort_aux(vptr u, vptr v, int p, int q)
2468 while (!(*ang_sort_comp)(u, v, b, z)) b--;
2471 while (!(*ang_sort_comp)(u, v, z, a)) a++;
2473 /* Done partition */
2477 (*ang_sort_swap)(u, v, a, b);
2483 /* Recurse left side */
2484 ang_sort_aux(u, v, p, b);
2486 /* Recurse right side */
2487 ang_sort_aux(u, v, b+1, q);
2492 * Angband sorting algorithm -- quick sort in place
2494 * Note that the details of the data we are sorting is hidden,
2495 * and we rely on the "ang_sort_comp()" and "ang_sort_swap()"
2496 * function hooks to interact with the data, which is given as
2497 * two pointers, and which may have any user-defined form.
2499 void ang_sort(vptr u, vptr v, int n)
2501 /* Sort the array */
2502 ang_sort_aux(u, v, 0, n-1);
2507 /*** Targeting Code ***/
2511 * Determine is a monster makes a reasonable target
2513 * The concept of "targeting" was stolen from "Morgul" (?)
2515 * The player can target any location, or any "target-able" monster.
2517 * Currently, a monster is "target_able" if it is visible, and if
2518 * the player can hit it with a projection, and the player is not
2519 * hallucinating. This allows use of "use closest target" macros.
2521 * Future versions may restrict the ability to target "trappers"
2522 * and "mimics", but the semantics is a little bit weird.
2524 bool target_able(MONSTER_IDX m_idx)
2526 monster_type *m_ptr = &m_list[m_idx];
2528 /* Monster must be alive */
2529 if (!m_ptr->r_idx) return (FALSE);
2531 /* Hack -- no targeting hallucinations */
2532 if (p_ptr->image) return (FALSE);
2534 /* Monster must be visible */
2535 if (!m_ptr->ml) return (FALSE);
2537 if (p_ptr->riding && (p_ptr->riding == m_idx)) return (TRUE);
2539 /* Monster must be projectable */
2540 if (!projectable(p_ptr->y, p_ptr->x, m_ptr->fy, m_ptr->fx)) return (FALSE);
2542 /* XXX XXX XXX Hack -- Never target trappers */
2543 /* if (CLEAR_ATTR && (CLEAR_CHAR)) return (FALSE); */
2553 * Update (if necessary) and verify (if possible) the target.
2555 * We return TRUE if the target is "okay" and FALSE otherwise.
2557 bool target_okay(void)
2559 /* Accept stationary targets */
2560 if (target_who < 0) return (TRUE);
2562 /* Check moving targets */
2565 /* Accept reasonable targets */
2566 if (target_able(target_who))
2568 monster_type *m_ptr = &m_list[target_who];
2570 /* Acquire monster location */
2571 target_row = m_ptr->fy;
2572 target_col = m_ptr->fx;
2579 /* Assume no target */
2585 * Sorting hook -- comp function -- by "distance to player"
2587 * We use "u" and "v" to point to arrays of "x" and "y" positions,
2588 * and sort the arrays by double-distance to the player.
2590 static bool ang_sort_comp_distance(vptr u, vptr v, int a, int b)
2592 POSITION *x = (POSITION*)(u);
2593 POSITION *y = (POSITION*)(v);
2595 POSITION da, db, kx, ky;
2597 /* Absolute distance components */
2598 kx = x[a]; kx -= p_ptr->x; kx = ABS(kx);
2599 ky = y[a]; ky -= p_ptr->y; ky = ABS(ky);
2601 /* Approximate Double Distance to the first point */
2602 da = ((kx > ky) ? (kx + kx + ky) : (ky + ky + kx));
2604 /* Absolute distance components */
2605 kx = x[b]; kx -= p_ptr->x; kx = ABS(kx);
2606 ky = y[b]; ky -= p_ptr->y; ky = ABS(ky);
2608 /* Approximate Double Distance to the first point */
2609 db = ((kx > ky) ? (kx + kx + ky) : (ky + ky + kx));
2611 /* Compare the distances */
2617 * Sorting hook -- comp function -- by importance level of grids
2619 * We use "u" and "v" to point to arrays of "x" and "y" positions,
2620 * and sort the arrays by level of monster
2622 static bool ang_sort_comp_importance(vptr u, vptr v, int a, int b)
2624 POSITION *x = (POSITION*)(u);
2625 POSITION *y = (POSITION*)(v);
2626 cave_type *ca_ptr = &cave[y[a]][x[a]];
2627 cave_type *cb_ptr = &cave[y[b]][x[b]];
2628 monster_type *ma_ptr = &m_list[ca_ptr->m_idx];
2629 monster_type *mb_ptr = &m_list[cb_ptr->m_idx];
2630 monster_race *ap_ra_ptr, *ap_rb_ptr;
2632 /* The player grid */
2633 if (y[a] == p_ptr->y && x[a] == p_ptr->x) return TRUE;
2634 if (y[b] == p_ptr->y && x[b] == p_ptr->x) return FALSE;
2636 /* Extract monster race */
2637 if (ca_ptr->m_idx && ma_ptr->ml) ap_ra_ptr = &r_info[ma_ptr->ap_r_idx];
2638 else ap_ra_ptr = NULL;
2639 if (cb_ptr->m_idx && mb_ptr->ml) ap_rb_ptr = &r_info[mb_ptr->ap_r_idx];
2640 else ap_rb_ptr = NULL;
2642 if (ap_ra_ptr && !ap_rb_ptr) return TRUE;
2643 if (!ap_ra_ptr && ap_rb_ptr) return FALSE;
2645 /* Compare two monsters */
2646 if (ap_ra_ptr && ap_rb_ptr)
2648 /* Unique monsters first */
2649 if ((ap_ra_ptr->flags1 & RF1_UNIQUE) && !(ap_rb_ptr->flags1 & RF1_UNIQUE)) return TRUE;
2650 if (!(ap_ra_ptr->flags1 & RF1_UNIQUE) && (ap_rb_ptr->flags1 & RF1_UNIQUE)) return FALSE;
2652 /* Shadowers first (あやしい影) */
2653 if ((ma_ptr->mflag2 & MFLAG2_KAGE) && !(mb_ptr->mflag2 & MFLAG2_KAGE)) return TRUE;
2654 if (!(ma_ptr->mflag2 & MFLAG2_KAGE) && (mb_ptr->mflag2 & MFLAG2_KAGE)) return FALSE;
2656 /* Unknown monsters first */
2657 if (!ap_ra_ptr->r_tkills && ap_rb_ptr->r_tkills) return TRUE;
2658 if (ap_ra_ptr->r_tkills && !ap_rb_ptr->r_tkills) return FALSE;
2660 /* Higher level monsters first (if known) */
2661 if (ap_ra_ptr->r_tkills && ap_rb_ptr->r_tkills)
2663 if (ap_ra_ptr->level > ap_rb_ptr->level) return TRUE;
2664 if (ap_ra_ptr->level < ap_rb_ptr->level) return FALSE;
2667 /* Sort by index if all conditions are same */
2668 if (ma_ptr->ap_r_idx > mb_ptr->ap_r_idx) return TRUE;
2669 if (ma_ptr->ap_r_idx < mb_ptr->ap_r_idx) return FALSE;
2672 /* An object get higher priority */
2673 if (cave[y[a]][x[a]].o_idx && !cave[y[b]][x[b]].o_idx) return TRUE;
2674 if (!cave[y[a]][x[a]].o_idx && cave[y[b]][x[b]].o_idx) return FALSE;
2676 /* Priority from the terrain */
2677 if (f_info[ca_ptr->feat].priority > f_info[cb_ptr->feat].priority) return TRUE;
2678 if (f_info[ca_ptr->feat].priority < f_info[cb_ptr->feat].priority) return FALSE;
2680 /* If all conditions are same, compare distance */
2681 return ang_sort_comp_distance(u, v, a, b);
2686 * Sorting hook -- swap function -- by "distance to player"
2688 * We use "u" and "v" to point to arrays of "x" and "y" positions,
2689 * and sort the arrays by distance to the player.
2691 static void ang_sort_swap_distance(vptr u, vptr v, int a, int b)
2693 POSITION *x = (POSITION*)(u);
2694 POSITION *y = (POSITION*)(v);
2712 * Hack -- help "select" a location (see below)
2714 static POSITION_IDX target_pick(POSITION y1, POSITION x1, POSITION dy, POSITION dx)
2717 POSITION x2, y2, x3, y3, x4, y4;
2718 POSITION_IDX b_i = -1, b_v = 9999;
2721 /* Scan the locations */
2722 for (i = 0; i < temp_n; i++)
2728 /* Directed distance */
2732 /* Verify quadrant */
2733 if (dx && (x3 * dx <= 0)) continue;
2734 if (dy && (y3 * dy <= 0)) continue;
2736 /* Absolute distance */
2740 /* Verify quadrant */
2741 if (dy && !dx && (x4 > y4)) continue;
2742 if (dx && !dy && (y4 > x4)) continue;
2744 /* Approximate Double Distance */
2745 v = ((x4 > y4) ? (x4 + x4 + y4) : (y4 + y4 + x4));
2747 /* XXX XXX XXX Penalize location */
2750 if ((b_i >= 0) && (v >= b_v)) continue;
2762 * Hack -- determine if a given location is "interesting"
2764 static bool target_set_accept(int y, int x)
2768 s16b this_o_idx, next_o_idx = 0;
2771 if (!(in_bounds(y, x))) return (FALSE);
2773 /* Player grid is always interesting */
2774 if (player_bold(y, x)) return (TRUE);
2777 /* Handle hallucination */
2778 if (p_ptr->image) return (FALSE);
2781 /* Examine the grid */
2782 c_ptr = &cave[y][x];
2784 /* Visible monsters */
2787 monster_type *m_ptr = &m_list[c_ptr->m_idx];
2789 /* Visible monsters */
2790 if (m_ptr->ml) return (TRUE);
2793 /* Scan all objects in the grid */
2794 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
2798 /* Acquire object */
2799 o_ptr = &o_list[this_o_idx];
2801 /* Acquire next object */
2802 next_o_idx = o_ptr->next_o_idx;
2804 /* Memorized object */
2805 if (o_ptr->marked & OM_FOUND) return (TRUE);
2808 /* Interesting memorized features */
2809 if (c_ptr->info & (CAVE_MARK))
2811 /* Notice object features */
2812 if (c_ptr->info & CAVE_OBJECT) return (TRUE);
2814 /* Feature code (applying "mimic" field) */
2815 if (have_flag(f_info[get_feat_mimic(c_ptr)].flags, FF_NOTICE)) return TRUE;
2824 * Prepare the "temp" array for "target_set"
2826 * Return the number of target_able monsters in the set.
2828 static void target_set_prepare(BIT_FLAGS mode)
2831 int min_hgt, max_hgt, min_wid, max_wid;
2833 if (mode & TARGET_KILL)
2836 min_hgt = MAX((p_ptr->y - MAX_RANGE), 0);
2837 max_hgt = MIN((p_ptr->y + MAX_RANGE), cur_hgt - 1);
2838 min_wid = MAX((p_ptr->x - MAX_RANGE), 0);
2839 max_wid = MIN((p_ptr->x + MAX_RANGE), cur_wid - 1);
2841 else /* not targetting */
2844 min_hgt = panel_row_min;
2845 max_hgt = panel_row_max;
2846 min_wid = panel_col_min;
2847 max_wid = panel_col_max;
2850 /* Reset "temp" array */
2853 /* Scan the current panel */
2854 for (y = min_hgt; y <= max_hgt; y++)
2856 for (x = min_wid; x <= max_wid; x++)
2860 /* Require "interesting" contents */
2861 if (!target_set_accept(y, x)) continue;
2863 c_ptr = &cave[y][x];
2865 /* Require target_able monsters for "TARGET_KILL" */
2866 if ((mode & (TARGET_KILL)) && !target_able(c_ptr->m_idx)) continue;
2868 if ((mode & (TARGET_KILL)) && !target_pet && is_pet(&m_list[c_ptr->m_idx])) continue;
2870 /* Save the location */
2877 /* Set the sort hooks */
2878 if (mode & (TARGET_KILL))
2880 /* Target the nearest monster for shooting */
2881 ang_sort_comp = ang_sort_comp_distance;
2882 ang_sort_swap = ang_sort_swap_distance;
2886 /* Look important grids first in Look command */
2887 ang_sort_comp = ang_sort_comp_importance;
2888 ang_sort_swap = ang_sort_swap_distance;
2891 /* Sort the positions */
2892 ang_sort(temp_x, temp_y, temp_n);
2894 if (p_ptr->riding && target_pet && (temp_n > 1) && (mode & (TARGET_KILL)))
2899 temp_y[0] = temp_y[1];
2902 temp_x[0] = temp_x[1];
2907 void target_set_prepare_look(void){
2908 target_set_prepare(TARGET_LOOK);
2913 * Evaluate number of kill needed to gain level
2915 static void evaluate_monster_exp(char *buf, monster_type *m_ptr)
2917 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
2919 s32b exp_mon, exp_adv;
2920 u32b exp_mon_frac, exp_adv_frac;
2922 if ((p_ptr->lev >= PY_MAX_LEVEL) || (p_ptr->prace == RACE_ANDROID))
2927 else if (!ap_r_ptr->r_tkills || (m_ptr->mflag2 & MFLAG2_KAGE))
2937 /* The monster's experience point (assuming average monster speed) */
2938 exp_mon = ap_r_ptr->mexp * ap_r_ptr->level;
2940 s64b_div(&exp_mon, &exp_mon_frac, 0, (p_ptr->max_plv + 2));
2943 /* Total experience value for next level */
2944 exp_adv = player_exp[p_ptr->lev -1] * p_ptr->expfact;
2946 s64b_div(&exp_adv, &exp_adv_frac, 0, 100);
2948 /* Experience value need to get */
2949 s64b_sub(&exp_adv, &exp_adv_frac, p_ptr->exp, p_ptr->exp_frac);
2952 /* You need to kill at least one monster to get any experience */
2953 s64b_add(&exp_adv, &exp_adv_frac, exp_mon, exp_mon_frac);
2954 s64b_sub(&exp_adv, &exp_adv_frac, 0, 1);
2956 /* Extract number of monsters needed */
2957 s64b_div(&exp_adv, &exp_adv_frac, exp_mon, exp_mon_frac);
2959 /* If 999 or more monsters needed, only display "999". */
2960 num = MIN(999, exp_adv_frac);
2962 /* Display the number */
2963 sprintf(buf,"%03ld", (long int)num);
2967 bool show_gold_on_floor = FALSE;
2970 * Examine a grid, return a keypress.
2972 * The "mode" argument contains the "TARGET_LOOK" bit flag, which
2973 * indicates that the "space" key should scan through the contents
2974 * of the grid, instead of simply returning immediately. This lets
2975 * the "look" command get complete information, without making the
2976 * "target" command annoying.
2978 * The "info" argument contains the "commands" which should be shown
2979 * inside the "[xxx]" text. This string must never be empty, or grids
2980 * containing monsters will be displayed with an extra comma.
2982 * Note that if a monster is in the grid, we update both the monster
2983 * recall info and the health bar info to track that monster.
2985 * Eventually, we may allow multiple objects per grid, or objects
2986 * and terrain features in the same grid. XXX XXX XXX
2988 * This function must handle blindness/hallucination.
2990 static char target_set_aux(POSITION y, POSITION x, BIT_FLAGS mode, cptr info)
2992 cave_type *c_ptr = &cave[y][x];
2993 s16b this_o_idx, next_o_idx = 0;
2994 cptr s1 = "", s2 = "", s3 = "", x_info = "";
2997 feature_type *f_ptr;
2998 char query = '\001';
2999 char out_val[MAX_NLEN+80];
3001 #ifdef ALLOW_EASY_FLOOR
3002 OBJECT_IDX floor_list[23];
3003 ITEM_NUMBER floor_num = 0;
3005 /* Scan all objects in the grid */
3008 floor_num = scan_floor(floor_list, y, x, 0x02);
3012 x_info = _("x物 ", "x,");
3016 #endif /* ALLOW_EASY_FLOOR */
3018 /* Hack -- under the player */
3019 if (player_bold(y, x))
3035 s1 = _("ターゲット:", "Target:");
3038 /* Hack -- hallucination */
3041 cptr name = _("何か奇妙な物", "something strange");
3043 /* Display a message */
3045 sprintf(out_val, "%s%s%s%s [%s]", s1, name, s2, s3, info);
3047 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, name, info);
3051 move_cursor_relative(y, x);
3054 /* Stop on everything but "return" */
3055 if ((query != '\r') && (query != '\n')) return query;
3057 /* Repeat forever */
3062 /* Actual monsters */
3063 if (c_ptr->m_idx && m_list[c_ptr->m_idx].ml)
3065 monster_type *m_ptr = &m_list[c_ptr->m_idx];
3066 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
3068 bool recall = FALSE;
3073 /* Get the monster name ("a kobold") */
3074 monster_desc(m_name, m_ptr, MD_INDEF_VISIBLE);
3076 /* Hack -- track this monster race */
3077 monster_race_track(m_ptr->ap_r_idx);
3079 /* Hack -- health bar for this monster */
3080 health_track(c_ptr->m_idx);
3082 /* Hack -- handle stuff */
3096 /* Recall on screen */
3097 screen_roff(m_ptr->ap_r_idx, 0);
3099 /* Hack -- Complete the prompt (again) */
3100 Term_addstr(-1, TERM_WHITE, format(_(" [r思 %s%s]", " [r,%s%s]"), x_info, info));
3108 /* Normal commands */
3109 if (query != 'r') break;
3114 /* Cleare recall text and repeat */
3120 /* Describe, and prompt for recall */
3121 evaluate_monster_exp(acount, m_ptr);
3124 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);
3126 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);
3132 move_cursor_relative(y, x);
3137 /* Normal commands */
3138 if (query != 'r') break;
3144 /* Always stop at "normal" keys */
3145 if ((query != '\r') && (query != '\n') && (query != ' ') && (query != 'x')) return query;
3147 /* Sometimes stop at "space" key */
3148 if ((query == ' ') && !(mode & (TARGET_LOOK))) return query;
3150 /* Change the intro */
3151 s1 = _("それは", "It is ");
3153 /* Hack -- take account of gender */
3154 if (ap_r_ptr->flags1 & (RF1_FEMALE)) s1 = _("彼女は", "She is ");
3155 else if (ap_r_ptr->flags1 & (RF1_MALE)) s1 = _("彼は", "He is ");
3157 /* Use a preposition */
3166 /* Scan all objects being carried */
3167 for (this_o_idx = m_ptr->hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
3169 char o_name[MAX_NLEN];
3173 /* Acquire object */
3174 o_ptr = &o_list[this_o_idx];
3176 /* Acquire next object */
3177 next_o_idx = o_ptr->next_o_idx;
3179 /* Obtain an object description */
3180 object_desc(o_name, o_ptr, 0);
3182 /* Describe the object */
3184 sprintf(out_val, "%s%s%s%s[%s]", s1, o_name, s2, s3, info);
3186 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, o_name, info);
3190 move_cursor_relative(y, x);
3193 /* Always stop at "normal" keys */
3194 if ((query != '\r') && (query != '\n') && (query != ' ') && (query != 'x')) return query;
3196 /* Sometimes stop at "space" key */
3197 if ((query == ' ') && !(mode & (TARGET_LOOK))) return query;
3199 /* Change the intro */
3200 s2 = _("をまた", "also carrying ");
3203 /* Use a preposition */
3213 #ifdef ALLOW_EASY_FLOOR
3222 char o_name[MAX_NLEN];
3226 /* Acquire object */
3227 o_ptr = &o_list[floor_list[0]];
3229 /* Describe the object */
3230 object_desc(o_name, o_ptr, 0);
3234 sprintf(out_val, "%s%s%s%s[%s]",
3235 s1, o_name, s2, s3, info);
3237 sprintf(out_val, "%s%s%s%s [%s]",
3238 s1, s2, s3, o_name, info);
3242 move_cursor_relative(y, x);
3251 /* Provide one cushion before item listing */
3254 /* Display rough information about items */
3256 sprintf(out_val, "%s %d個のアイテム%s%s ['x'で一覧, %s]",
3257 s1, (int)floor_num, s2, s3, info);
3259 sprintf(out_val, "%s%s%sa pile of %d items [x,%s]",
3260 s1, s2, s3, (int)floor_num, info);
3264 move_cursor_relative(y, x);
3269 /* No request for listing */
3270 if (query != 'x' && query != ' ') return query;
3274 /** Display list of items **/
3276 /* Continue scrolling list if requested */
3286 show_gold_on_floor = TRUE;
3287 (void)show_floor(0, y, x, &min_width);
3288 show_gold_on_floor = FALSE;
3292 sprintf(out_val, "%s %d個のアイテム%s%s [Enterで次へ, %s]",
3293 s1, (int)floor_num, s2, s3, info);
3295 sprintf(out_val, "%s%s%sa pile of %d items [Enter,%s]",
3296 s1, s2, s3, (int)floor_num, info);
3307 /* Exit unless 'Enter' */
3308 if (query != '\n' && query != '\r')
3313 /* Get the object being moved. */
3314 o_idx = c_ptr->o_idx;
3316 /* Only rotate a pile of two or more objects. */
3317 if (!(o_idx && o_list[o_idx].next_o_idx)) continue;
3319 /* Remove the first object from the list. */
3320 excise_object_idx(o_idx);
3322 /* Find end of the list. */
3324 while (o_list[i].next_o_idx)
3325 i = o_list[i].next_o_idx;
3327 /* Add after the last object. */
3328 o_list[i].next_o_idx = o_idx;
3330 /* Loop and re-display the list */
3336 #endif /* ALLOW_EASY_FLOOR */
3339 /* Scan all objects in the grid */
3340 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
3344 /* Acquire object */
3345 o_ptr = &o_list[this_o_idx];
3347 /* Acquire next object */
3348 next_o_idx = o_ptr->next_o_idx;
3351 if (o_ptr->marked & OM_FOUND)
3353 char o_name[MAX_NLEN];
3358 /* Obtain an object description */
3359 object_desc(o_name, o_ptr, 0);
3361 /* Describe the object */
3363 sprintf(out_val, "%s%s%s%s[%s]", s1, o_name, s2, s3, info);
3365 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, o_name, info);
3369 move_cursor_relative(y, x);
3372 /* Always stop at "normal" keys */
3373 if ((query != '\r') && (query != '\n') && (query != ' ') && (query != 'x')) return query;
3375 /* Sometimes stop at "space" key */
3376 if ((query == ' ') && !(mode & TARGET_LOOK)) return query;
3378 /* Change the intro */
3379 s1 = _("それは", "It is ");
3382 if (o_ptr->number != 1) s1 = _("それらは", "They are ");
3396 /* Feature code (applying "mimic" field) */
3397 feat = get_feat_mimic(c_ptr);
3399 /* Require knowledge about grid, or ability to see grid */
3400 if (!(c_ptr->info & CAVE_MARK) && !player_can_see_bold(y, x))
3402 /* Forget feature */
3406 f_ptr = &f_info[feat];
3408 /* Terrain feature if needed */
3409 if (boring || have_flag(f_ptr->flags, FF_REMEMBER))
3413 /* Hack -- special handling for quest entrances */
3414 if (have_flag(f_ptr->flags, FF_QUEST_ENTER))
3416 /* Set the quest number temporary */
3417 IDX old_quest = p_ptr->inside_quest;
3420 /* Clear the text */
3421 for (j = 0; j < 10; j++) quest_text[j][0] = '\0';
3422 quest_text_line = 0;
3424 p_ptr->inside_quest = c_ptr->special;
3426 /* Get the quest text */
3427 init_flags = INIT_NAME_ONLY;
3429 process_dungeon_file("q_info.txt", 0, 0, 0, 0);
3431 name = format(_("クエスト「%s」(%d階相当)", "the entrance to the quest '%s'(level %d)"),
3432 quest[c_ptr->special].name, quest[c_ptr->special].level);
3434 /* Reset the old quest number */
3435 p_ptr->inside_quest = old_quest;
3438 /* Hack -- special handling for building doors */
3439 else if (have_flag(f_ptr->flags, FF_BLDG) && !p_ptr->inside_arena)
3441 name = building[f_ptr->subtype].name;
3443 else if (have_flag(f_ptr->flags, FF_ENTRANCE))
3445 name = format(_("%s(%d階相当)", "%s(level %d)"), d_text + d_info[c_ptr->special].text, d_info[c_ptr->special].mindepth);
3447 else if (have_flag(f_ptr->flags, FF_TOWN))
3449 name = town[c_ptr->special].name;
3451 else if (p_ptr->wild_mode && (feat == feat_floor))
3453 name = _("道", "road");
3457 name = f_name + f_ptr->name;
3463 ((!have_flag(f_ptr->flags, FF_MOVE) && !have_flag(f_ptr->flags, FF_CAN_FLY)) ||
3464 (!have_flag(f_ptr->flags, FF_LOS) && !have_flag(f_ptr->flags, FF_TREE)) ||
3465 have_flag(f_ptr->flags, FF_TOWN)))
3467 s2 = _("の中", "in ");
3470 /* Hack -- special introduction for store & building doors -KMW- */
3471 if (have_flag(f_ptr->flags, FF_STORE) ||
3472 have_flag(f_ptr->flags, FF_QUEST_ENTER) ||
3473 (have_flag(f_ptr->flags, FF_BLDG) && !p_ptr->inside_arena) ||
3474 have_flag(f_ptr->flags, FF_ENTRANCE))
3483 else if (have_flag(f_ptr->flags, FF_FLOOR) ||
3484 have_flag(f_ptr->flags, FF_TOWN) ||
3485 have_flag(f_ptr->flags, FF_SHALLOW) ||
3486 have_flag(f_ptr->flags, FF_DEEP))
3492 /* Pick proper indefinite article */
3493 s3 = (is_a_vowel(name[0])) ? "an " : "a ";
3497 /* Display a message */
3501 if (c_ptr->mimic) sprintf(f_idx_str, "%d/%d", c_ptr->feat, c_ptr->mimic);
3502 else sprintf(f_idx_str, "%d", c_ptr->feat);
3504 sprintf(out_val, "%s%s%s%s[%s] %x %s %d %d %d (%d,%d) %d", s1, name, s2, s3, info, (unsigned int)c_ptr->info, f_idx_str, c_ptr->dist, c_ptr->cost, c_ptr->when, (int)y, (int)x, travel.cost[y][x]);
3506 sprintf(out_val, "%s%s%s%s [%s] %x %s %d %d %d (%d,%d)", s1, s2, s3, name, info, c_ptr->info, f_idx_str, c_ptr->dist, c_ptr->cost, c_ptr->when, (int)y, (int)x);
3511 sprintf(out_val, "%s%s%s%s[%s]", s1, name, s2, s3, info);
3513 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, name, info);
3517 move_cursor_relative(y, x);
3520 /* Always stop at "normal" keys */
3521 if ((query != '\r') && (query != '\n') && (query != ' ')) return query;
3524 /* Stop on everything but "return" */
3525 if ((query != '\r') && (query != '\n')) return query;
3527 /* Repeat forever */
3533 * Handle "target" and "look".
3535 * Note that this code can be called from "get_aim_dir()".
3537 * All locations must be on the current panel. Consider the use of
3538 * "panel_bounds()" to allow "off-panel" targets, perhaps by using
3539 * some form of "scrolling" the map around the cursor. XXX XXX XXX
3540 * That is, consider the possibility of "auto-scrolling" the screen
3541 * while the cursor moves around. This may require changes in the
3542 * "update_mon()" code to allow "visibility" even if off panel, and
3543 * may require dynamic recalculation of the "temp" grid set.
3545 * Hack -- targeting/observing an "outer border grid" may induce
3546 * problems, so this is not currently allowed.
3548 * The player can use the direction keys to move among "interesting"
3549 * grids in a heuristic manner, or the "space", "+", and "-" keys to
3550 * move through the "interesting" grids in a sequential manner, or
3551 * can enter "location" mode, and use the direction keys to move one
3552 * grid at a time in any direction. The "t" (set target) command will
3553 * only target a monster (as opposed to a location) if the monster is
3554 * target_able and the "interesting" mode is being used.
3556 * The current grid is described using the "look" method above, and
3557 * a new command may be entered at any time, but note that if the
3558 * "TARGET_LOOK" bit flag is set (or if we are in "location" mode,
3559 * where "space" has no obvious meaning) then "space" will scan
3560 * through the description of the current grid until done, instead
3561 * of immediately jumping to the next "interesting" grid. This
3562 * allows the "target" command to retain its old semantics.
3564 * The "*", "+", and "-" keys may always be used to jump immediately
3565 * to the next (or previous) interesting grid, in the proper mode.
3567 * The "return" key may always be used to scan through a complete
3568 * grid description (forever).
3570 * This command will cancel any old target, even if used from
3571 * inside the "look" command.
3573 bool target_set(BIT_FLAGS mode)
3576 POSITION y = p_ptr->y;
3577 POSITION x = p_ptr->x;
3590 get_screen_size(&wid, &hgt);
3596 /* Cancel tracking */
3597 /* health_track(0); */
3599 if (rogue_like_commands)
3608 /* Prepare the "temp" array */
3609 target_set_prepare(mode);
3611 /* Start near the player */
3617 /* Interesting grids */
3624 change_panel_xy(y, x);
3626 if (!(mode & TARGET_LOOK)) prt_path(y, x);
3629 c_ptr = &cave[y][x];
3632 if (target_able(c_ptr->m_idx))
3634 strcpy(info, _("q止 t決 p自 o現 +次 -前", "q,t,p,o,+,-,<dir>"));
3637 /* Dis-allow target */
3640 strcpy(info, _("q止 p自 o現 +次 -前", "q,p,o,+,-,<dir>"));
3643 /* Describe and Prompt */
3645 query = target_set_aux(y, x, mode, info);
3649 /* Cancel tracking */
3650 /* health_track(0); */
3652 /* Assume no "direction" */
3657 if (query == '\r') query = 't';
3675 if (target_able(c_ptr->m_idx))
3677 health_track(c_ptr->m_idx);
3678 target_who = c_ptr->m_idx;
3697 if (!expand_list) done = TRUE;
3707 if (!expand_list) done = TRUE;
3714 /* Recenter the map around the player */
3718 p_ptr->update |= (PU_MONSTERS);
3721 p_ptr->redraw |= (PR_MAP);
3724 p_ptr->window |= (PW_OVERHEAD);
3729 /* Recalculate interesting grids */
3730 target_set_prepare(mode);
3749 if(query == same_key)
3754 if (!expand_list) done = TRUE;
3759 /* Extract the action (if any) */
3760 d = get_keymap_dir(query);
3767 /* Hack -- move around */
3770 /* Modified to scroll to monster */
3771 int y2 = panel_row_min;
3772 int x2 = panel_col_min;
3774 /* Find a new monster */
3775 i = target_pick(temp_y[m], temp_x[m], ddy[d], ddx[d]);
3777 /* Request to target past last interesting grid */
3778 while (flag && (i < 0))
3780 /* Note the change */
3781 if (change_panel(ddy[d], ddx[d]))
3786 /* Recalculate interesting grids */
3787 target_set_prepare(mode);
3789 /* Look at interesting grids */
3792 /* Find a new monster */
3793 i = target_pick(v, u, ddy[d], ddx[d]);
3799 /* Nothing interesting */
3805 /* Restore previous position */
3808 panel_bounds_center();
3811 p_ptr->update |= (PU_MONSTERS);
3814 p_ptr->redraw |= (PR_MAP);
3817 p_ptr->window |= (PW_OVERHEAD);
3822 /* Recalculate interesting grids */
3823 target_set_prepare(mode);
3825 /* Look at boring grids */
3832 /* Do not move horizontally if unnecessary */
3833 if (((x < panel_col_min + wid / 2) && (dx > 0)) ||
3834 ((x > panel_col_min + wid / 2) && (dx < 0)))
3839 /* Do not move vertically if unnecessary */
3840 if (((y < panel_row_min + hgt / 2) && (dy > 0)) ||
3841 ((y > panel_row_min + hgt / 2) && (dy < 0)))
3846 /* Apply the motion */
3847 if ((y >= panel_row_min+hgt) || (y < panel_row_min) ||
3848 (x >= panel_col_min+wid) || (x < panel_col_min))
3850 if (change_panel(dy, dx)) target_set_prepare(mode);
3853 /* Slide into legality */
3854 if (x >= cur_wid-1) x = cur_wid - 2;
3855 else if (x <= 0) x = 1;
3857 /* Slide into legality */
3858 if (y >= cur_hgt-1) y = cur_hgt- 2;
3859 else if (y <= 0) y = 1;
3868 /* Arbitrary grids */
3871 bool move_fast = FALSE;
3873 if (!(mode & TARGET_LOOK)) prt_path(y, x);
3876 c_ptr = &cave[y][x];
3878 /* Default prompt */
3879 strcpy(info, _("q止 t決 p自 m近 +次 -前", "q,t,p,m,+,-,<dir>"));
3881 /* Describe and Prompt (enable "TARGET_LOOK") */
3882 while ((query = target_set_aux(y, x, mode | TARGET_LOOK, info)) == 0);
3884 /* Cancel tracking */
3885 /* health_track(0); */
3887 /* Assume no direction */
3892 if (query == '\r') query = 't';
3895 /* Analyze the keypress */
3919 /* Recenter the map around the player */
3923 p_ptr->update |= (PU_MONSTERS);
3926 p_ptr->redraw |= (PR_MAP);
3929 p_ptr->window |= (PW_OVERHEAD);
3934 /* Recalculate interesting grids */
3935 target_set_prepare(mode);
3957 /* Pick a nearby monster */
3958 for (i = 0; i < temp_n; i++)
3960 t = distance(y, x, temp_y[i], temp_x[i]);
3970 /* Nothing interesting */
3971 if (bd == 999) flag = FALSE;
3978 /* Extract the action (if any) */
3979 d = get_keymap_dir(query);
3981 /* XTRA HACK MOVEFAST */
3982 if (isupper(query)) move_fast = TRUE;
3989 /* Handle "direction" */
3995 /* XTRA HACK MOVEFAST */
3998 int mag = MIN(wid / 2, hgt / 2);
4008 /* Do not move horizontally if unnecessary */
4009 if (((x < panel_col_min + wid / 2) && (dx > 0)) ||
4010 ((x > panel_col_min + wid / 2) && (dx < 0)))
4015 /* Do not move vertically if unnecessary */
4016 if (((y < panel_row_min + hgt / 2) && (dy > 0)) ||
4017 ((y > panel_row_min + hgt / 2) && (dy < 0)))
4022 /* Apply the motion */
4023 if ((y >= panel_row_min + hgt) || (y < panel_row_min) ||
4024 (x >= panel_col_min + wid) || (x < panel_col_min))
4026 if (change_panel(dy, dx)) target_set_prepare(mode);
4029 /* Slide into legality */
4030 if (x >= cur_wid-1) x = cur_wid - 2;
4031 else if (x <= 0) x = 1;
4033 /* Slide into legality */
4034 if (y >= cur_hgt-1) y = cur_hgt- 2;
4035 else if (y <= 0) y = 1;
4043 /* Clear the top line */
4046 /* Recenter the map around the player */
4050 p_ptr->update |= (PU_MONSTERS);
4053 p_ptr->redraw |= (PR_MAP);
4056 p_ptr->window |= (PW_OVERHEAD);
4061 /* Failure to set target */
4062 if (!target_who) return (FALSE);
4070 * Get an "aiming direction" from the user.
4072 * The "dir" is loaded with 1,2,3,4,6,7,8,9 for "actual direction", and
4073 * "0" for "current target", and "-1" for "entry aborted".
4075 * Note that "Force Target", if set, will pre-empt user interaction,
4076 * if there is a usable target already set.
4078 * Note that confusion over-rides any (explicit?) user choice.
4080 bool get_aim_dir(DIRECTION *dp)
4090 /* Global direction */
4093 /* Hack -- auto-target if requested */
4094 if (use_old_target && target_okay()) dir = 5;
4096 #ifdef ALLOW_REPEAT /* TNB */
4098 if (repeat_pull(&code))
4103 if (!(code == 5 && !target_okay()))
4105 /* return (TRUE); */
4106 dir = (DIRECTION)code;
4109 *dp = (DIRECTION)code;
4111 #endif /* ALLOW_REPEAT -- TNB */
4113 /* Ask until satisfied */
4116 /* Choose a prompt */
4119 p = _("方向 ('*'でターゲット選択, ESCで中断)? ", "Direction ('*' to choose a target, Escape to cancel)? ");
4123 p = _("方向 ('5'でターゲットへ, '*'でターゲット再選択, ESCで中断)? ", "Direction ('5' for target, '*' to re-target, Escape to cancel)? ");
4126 /* Get a command (or Cancel) */
4127 if (!get_com(p, &command, TRUE)) break;
4131 if (command == '\r') command = 't';
4134 /* Convert various keys to "standard" keys */
4137 /* Use current target */
4148 /* Set new target */
4153 if (target_set(TARGET_KILL)) dir = 5;
4159 /* Extract the action (if any) */
4160 dir = get_keymap_dir(command);
4166 /* Verify requested targets */
4167 if ((dir == 5) && !target_okay()) dir = 0;
4176 project_length = 0; /* reset to default */
4180 /* Save the direction */
4183 /* Check for confusion */
4184 if (p_ptr->confused)
4187 /* Random direction */
4188 dir = ddd[randint0(8)];
4191 /* Notice confusion */
4192 if (command_dir != dir)
4195 msg_print(_("あなたは混乱している。", "You are confused."));
4198 /* Save direction */
4201 #ifdef ALLOW_REPEAT /* TNB */
4203 /* repeat_push(dir); */
4204 repeat_push((COMMAND_CODE)command_dir);
4206 #endif /* ALLOW_REPEAT -- TNB */
4208 /* A "valid" direction was entered */
4215 * Request a "movement" direction (1,2,3,4,6,7,8,9) from the user,
4216 * and place it into "command_dir", unless we already have one.
4218 * This function should be used for all "repeatable" commands, such as
4219 * run, walk, open, close, bash, disarm, spike, tunnel, etc, as well
4220 * as all commands which must reference a grid adjacent to the player,
4221 * and which may not reference the grid under the player. Note that,
4222 * for example, it is no longer possible to "disarm" or "open" chests
4223 * in the same grid as the player.
4225 * Direction "5" is illegal and will (cleanly) abort the command.
4227 * This function tracks and uses the "global direction", and uses
4228 * that as the "desired direction", to which "confusion" is applied.
4230 bool get_rep_dir(DIRECTION *dp, bool under)
4239 /* Global direction */
4242 #ifdef ALLOW_REPEAT /* TNB */
4244 if (repeat_pull(&code))
4246 dir = (DIRECTION)code;
4247 /* return (TRUE); */
4249 *dp = (DIRECTION)code;
4251 #endif /* ALLOW_REPEAT -- TNB */
4255 prompt = _("方向 ('.'足元, ESCで中断)? ", "Direction ('.' at feet, Escape to cancel)? ");
4259 prompt = _("方向 (ESCで中断)? ", "Direction (Escape to cancel)? ");
4262 /* Get a direction */
4267 /* Get a command (or Cancel) */
4268 if (!get_com(prompt, &ch, TRUE)) break;
4271 if ((under) && ((ch == '5') || (ch == '-') || (ch == '.')))
4277 /* Look up the direction */
4278 dir = get_keymap_dir(ch);
4285 /* Prevent weirdness */
4286 if ((dir == 5) && (!under)) dir = 0;
4289 if (!dir) return (FALSE);
4291 /* Save desired direction */
4294 /* Apply "confusion" */
4295 if (p_ptr->confused)
4297 /* Standard confusion */
4298 if (randint0(100) < 75)
4300 /* Random direction */
4301 dir = ddd[randint0(8)];
4304 else if (p_ptr->riding)
4306 monster_type *m_ptr = &m_list[p_ptr->riding];
4307 monster_race *r_ptr = &r_info[m_ptr->r_idx];
4309 if (MON_CONFUSED(m_ptr))
4311 /* Standard confusion */
4312 if (randint0(100) < 75)
4314 /* Random direction */
4315 dir = ddd[randint0(8)];
4318 else if ((r_ptr->flags1 & RF1_RAND_50) && (r_ptr->flags1 & RF1_RAND_25) && (randint0(100) < 50))
4320 /* Random direction */
4321 dir = ddd[randint0(8)];
4323 else if ((r_ptr->flags1 & RF1_RAND_50) && (randint0(100) < 25))
4325 /* Random direction */
4326 dir = ddd[randint0(8)];
4330 /* Notice confusion */
4331 if (command_dir != dir)
4333 if (p_ptr->confused)
4336 msg_print(_("あなたは混乱している。", "You are confused."));
4341 monster_type *m_ptr = &m_list[p_ptr->riding];
4343 monster_desc(m_name, m_ptr, 0);
4344 if (MON_CONFUSED(m_ptr))
4346 msg_format(_("%sは混乱している。", "%^s is confusing."), m_name);
4350 msg_format(_("%sは思い通りに動いてくれない。", "You cannot control %s."), m_name);
4355 /* Save direction */
4358 #ifdef ALLOW_REPEAT /* TNB */
4360 /* repeat_push(dir); */
4361 repeat_push((COMMAND_CODE)command_dir);
4363 #endif /* ALLOW_REPEAT -- TNB */
4370 bool get_rep_dir2(DIRECTION *dp)
4378 /* Global direction */
4381 #ifdef ALLOW_REPEAT /* TNB */
4383 if (repeat_pull(&code))
4385 dir = (DIRECTION)code;
4386 /* return (TRUE); */
4388 *dp = (DIRECTION)code;
4390 #endif /* ALLOW_REPEAT -- TNB */
4392 /* Get a direction */
4397 /* Get a command (or Cancel) */
4398 if (!get_com(_("方向 (ESCで中断)? ", "Direction (Escape to cancel)? "), &ch, TRUE)) break;
4400 /* Look up the direction */
4401 dir = get_keymap_dir(ch);
4407 /* Prevent weirdness */
4408 if (dir == 5) dir = 0;
4411 if (!dir) return (FALSE);
4413 /* Save desired direction */
4416 /* Apply "confusion" */
4417 if (p_ptr->confused)
4419 /* Standard confusion */
4420 if (randint0(100) < 75)
4422 /* Random direction */
4423 dir = ddd[randint0(8)];
4427 /* Notice confusion */
4428 if (command_dir != dir)
4431 msg_print(_("あなたは混乱している。", "You are confused."));
4434 /* Save direction */
4437 #ifdef ALLOW_REPEAT /* TNB */
4439 /* repeat_push(dir); */
4440 repeat_push((COMMAND_CODE)command_dir);
4442 #endif /* ALLOW_REPEAT -- TNB */
4448 void gain_level_reward(int chosen_reward)
4452 char wrath_reason[32] = "";
4453 int nasty_chance = 6;
4454 OBJECT_TYPE_VALUE dummy = 0;
4455 OBJECT_SUBTYPE_VALUE dummy2 = 0;
4458 char o_name[MAX_NLEN];
4464 if (multi_rew) return;
4465 else multi_rew = TRUE;
4469 if (p_ptr->lev == 13) nasty_chance = 2;
4470 else if (!(p_ptr->lev % 13)) nasty_chance = 3;
4471 else if (!(p_ptr->lev % 14)) nasty_chance = 12;
4473 if (one_in_(nasty_chance))
4474 type = randint1(20); /* Allow the 'nasty' effects */
4476 type = randint1(15) + 5; /* Or disallow them */
4478 if (type < 1) type = 1;
4479 if (type > 20) type = 20;
4483 sprintf(wrath_reason, _("%sの怒り", "the Wrath of %s"), chaos_patrons[p_ptr->chaos_patron]);
4485 effect = chaos_rewards[p_ptr->chaos_patron][type];
4487 if (one_in_(6) && !chosen_reward)
4489 msg_format(_("%^sは褒美としてあなたを突然変異させた。", "%^s rewards you with a mutation!"), chaos_patrons[p_ptr->chaos_patron]);
4490 (void)gain_random_mutation(0);
4491 reward = _("変異した。", "mutation");
4495 switch (chosen_reward ? chosen_reward : effect)
4500 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4501 msg_print(_("「汝、新たなる姿を必要とせり!」", "'Thou needst a new form, mortal!'"));
4504 reward = _("変異した。", "polymorphing");
4509 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4510 msg_print(_("「汝は良く行いたり!続けよ!」", "'Well done, mortal! Lead on!'"));
4512 if (p_ptr->prace == RACE_ANDROID)
4514 msg_print(_("しかし何も起こらなかった。", "But, nothing happen."));
4516 else if (p_ptr->exp < PY_MAX_EXP)
4518 s32b ee = (p_ptr->exp / 2) + 10;
4519 if (ee > 100000L) ee = 100000L;
4520 msg_print(_("更に経験を積んだような気がする。", "You feel more experienced."));
4523 reward = _("経験値を得た", "experience");
4529 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4530 msg_print(_("「下僕よ、汝それに値せず。」", "'Thou didst not deserve that, slave.'"));
4532 if (p_ptr->prace == RACE_ANDROID)
4534 msg_print(_("しかし何も起こらなかった。", "But, nothing happen."));
4538 lose_exp(p_ptr->exp / 6);
4539 reward = _("経験値を失った。", "losing experience");
4545 msg_format("%sの声がささやいた:",
4546 chaos_patrons[p_ptr->chaos_patron]);
4548 msg_format("The voice of %s whispers:",
4549 chaos_patrons[p_ptr->chaos_patron]);
4552 msg_print(_("「我が与えし物を賢明に使うべし。」", "'Use my gift wisely.'"));
4554 acquirement(p_ptr->y, p_ptr->x, 1, FALSE, FALSE, FALSE);
4555 reward = _("上質なアイテムを手に入れた。", "a good item");
4560 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4561 msg_print(_("「我が与えし物を賢明に使うべし。」", "'Use my gift wisely.'"));
4563 acquirement(p_ptr->y, p_ptr->x, 1, TRUE, FALSE, FALSE);
4564 reward = _("高級品のアイテムを手に入れた。", "an excellent item");
4569 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4570 msg_print(_("「汝の行いは貴き剣に値せり。」", "'Thy deed hath earned thee a worthy blade.'"));
4572 /* Get local object */
4575 switch (randint1(p_ptr->lev))
4581 dummy2 = SV_MAIN_GAUCHE;
4590 dummy2 = SV_SMALL_SWORD;
4593 dummy2 = SV_BASILLARD;
4595 case 11: case 12: case 13:
4596 dummy2 = SV_SHORT_SWORD;
4602 dummy2 = SV_CUTLASS;
4605 dummy2 = SV_WAKIZASHI;
4608 dummy2 = SV_KHOPESH;
4614 dummy2 = SV_BROAD_SWORD;
4617 dummy2 = SV_LONG_SWORD;
4620 dummy2 = SV_SCIMITAR;
4623 dummy2 = SV_NINJATO;
4629 dummy2 = SV_BASTARD_SWORD;
4632 dummy2 = SV_GREAT_SCIMITAR;
4635 dummy2 = SV_CLAYMORE;
4638 dummy2 = SV_ESPADON;
4641 dummy2 = SV_TWO_HANDED_SWORD;
4644 dummy2 = SV_FLAMBERGE;
4647 dummy2 = SV_NO_DACHI;
4650 dummy2 = SV_EXECUTIONERS_SWORD;
4653 dummy2 = SV_ZWEIHANDER;
4656 dummy2 = SV_HAYABUSA;
4659 dummy2 = SV_BLADE_OF_CHAOS;
4662 object_prep(q_ptr, lookup_kind(dummy, dummy2));
4663 q_ptr->to_h = 3 + randint1(dun_level) % 10;
4664 q_ptr->to_d = 3 + randint1(dun_level) % 10;
4665 one_resistance(q_ptr);
4666 q_ptr->name2 = EGO_CHAOTIC;
4668 /* Drop it in the dungeon */
4669 (void)drop_near(q_ptr, -1, p_ptr->y, p_ptr->x);
4670 reward = _("(混沌)の武器を手に入れた。", "chaos weapon");
4675 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4676 msg_print(_("「汝の行いは貴き報いに値せり。」", "'Thy deed hath earned thee a worthy reward.'"));
4678 acquirement(p_ptr->y, p_ptr->x, randint1(2) + 1, FALSE, FALSE, FALSE);
4679 reward = _("上質なアイテムを手に入れた。", "good items");
4684 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4685 msg_print(_("「下僕よ、汝の献身への我が惜しみ無き報いを見るがよい。」", "'Behold, mortal, how generously I reward thy loyalty.'"));
4687 acquirement(p_ptr->y, p_ptr->x, randint1(2) + 1, TRUE, FALSE, FALSE);
4688 reward = _("高級品のアイテムを手に入れた。", "excellent items");
4693 msg_format("%sの声が轟き渡った:", chaos_patrons[p_ptr->chaos_patron]);
4695 msg_format("The voice of %s thunders:", chaos_patrons[p_ptr->chaos_patron]);
4698 msg_print(_("「下僕よ、汝傲慢なり。」", "'Thou art growing arrogant, mortal.'"));
4700 (void)activate_ty_curse(FALSE, &count);
4701 reward = _("禍々しい呪いをかけられた。", "cursing");
4706 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4707 msg_print(_("「我が下僕たちよ、かの傲慢なる者を倒すべし!」", "'My pets, destroy the arrogant mortal!'"));
4709 for (dummy = 0; dummy < randint1(5) + 1; dummy++)
4711 (void)summon_specific(0, p_ptr->y, p_ptr->x, dun_level, 0, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET));
4713 reward = _("モンスターを召喚された。", "summoning hostile monsters");
4719 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4720 msg_print(_("「汝、より強き敵を必要とせり!」", "'Thou needst worthier opponents!'"));
4722 activate_hi_summon(p_ptr->y, p_ptr->x, FALSE);
4723 reward = _("モンスターを召喚された。", "summoning many hostile monsters");
4729 msg_format("%sの声が響き渡った:",
4730 chaos_patrons[p_ptr->chaos_patron]);
4732 msg_format("The voice of %s booms out:",
4733 chaos_patrons[p_ptr->chaos_patron]);
4736 msg_print(_("「死と破壊こそ我が喜びなり!」", "'Death and destruction! This pleaseth me!'"));
4739 reward = _("カオスの力が渦巻いた。", "calling chaos");
4745 msg_format("%sの声が鳴り響いた:",
4746 chaos_patrons[p_ptr->chaos_patron]);
4748 msg_format("The voice of %s rings out:",
4749 chaos_patrons[p_ptr->chaos_patron]);
4752 msg_print(_("「留まるのだ、下僕よ。余が汝の肉体を鍛えん。」", "'Stay, mortal, and let me mold thee.'"));
4754 if (one_in_(3) && !(chaos_stats[p_ptr->chaos_patron] < 0))
4755 do_inc_stat(chaos_stats[p_ptr->chaos_patron]);
4757 do_inc_stat(randint0(6));
4758 reward = _("能力値が上がった。", "increasing a stat");
4764 msg_format("%sの声が響き渡った:",
4765 chaos_patrons[p_ptr->chaos_patron]);
4767 msg_format("The voice of %s booms out:",
4768 chaos_patrons[p_ptr->chaos_patron]);
4771 msg_print(_("「下僕よ、余は汝に飽みたり。」", "'I grow tired of thee, mortal.'"));
4773 if (one_in_(3) && !(chaos_stats[p_ptr->chaos_patron] < 0))
4774 do_dec_stat(chaos_stats[p_ptr->chaos_patron]);
4776 (void)do_dec_stat(randint0(6));
4777 reward = _("能力値が下がった。", "decreasing a stat");
4784 msg_format("%sの声が轟き渡った:",
4785 chaos_patrons[p_ptr->chaos_patron]);
4787 msg_format("The voice of %s thunders:",
4788 chaos_patrons[p_ptr->chaos_patron]);
4791 msg_print(_("「汝、謙虚たることを学ぶべし!」", "'Thou needst a lesson in humility, mortal!'"));
4792 msg_print(_("あなたは以前より弱くなった!", "You feel less powerful!"));
4794 for (dummy = 0; dummy < 6; dummy++)
4796 (void)dec_stat(dummy, 10 + randint1(15), TRUE);
4798 reward = _("全能力値が下がった。", "decreasing all stats");
4803 msg_format(_("%sの力が触れるのを感じた。", "You feel the power of %s touch you."),
4804 chaos_patrons[p_ptr->chaos_patron]);
4806 reward = _("傷が変化した。", "polymorphing wounds");
4811 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4813 msg_print(_("「我がささやかなる賜物を受けとるがよい!」", "'Receive this modest gift from me!'"));
4815 for (dummy = 0; dummy < 6; dummy++)
4817 (void)do_inc_stat(dummy);
4819 reward = _("全能力値が上がった。", "increasing all stats");
4824 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4825 msg_print(_("「苦しむがよい、無能な愚か者よ!」", "'Suffer, pathetic fool!'"));
4827 fire_ball(GF_DISINTEGRATE, 0, p_ptr->lev * 4, 4);
4828 take_hit(DAMAGE_NOESCAPE, p_ptr->lev * 4, wrath_reason, -1);
4829 reward = _("分解の球が発生した。", "generating disintegration ball");
4834 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4836 (void)set_poisoned(0);
4838 (void)set_confused(0);
4843 for (dummy = 0; dummy < 6; dummy++)
4845 (void)do_res_stat(dummy);
4847 reward = _("体力が回復した。", "healing");
4852 if (!buki_motteruka(INVEN_RARM) && !buki_motteruka(INVEN_LARM)) break;
4853 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4854 msg_print(_("「汝、武器に頼ることなかれ。」", "'Thou reliest too much on thy weapon.'"));
4857 if (buki_motteruka(INVEN_LARM))
4860 if (buki_motteruka(INVEN_RARM) && one_in_(2)) dummy = INVEN_RARM;
4862 object_desc(o_name, &inventory[dummy], OD_NAME_ONLY);
4863 (void)curse_weapon(FALSE, dummy);
4864 reward = format(_("%sが破壊された。", "destroying %s"), o_name);
4869 if (!inventory[INVEN_BODY].k_idx) break;
4870 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4871 msg_print(_("「汝、防具に頼ることなかれ。」", "'Thou reliest too much on thine equipment.'"));
4873 object_desc(o_name, &inventory[INVEN_BODY], OD_NAME_ONLY);
4874 (void)curse_armor();
4875 reward = format(_("%sが破壊された。", "destroying %s"), o_name);
4879 msg_format(_("%sの声がささやいた:", "The voice of %s whispers:"), chaos_patrons[p_ptr->chaos_patron]);
4880 msg_print(_("「我を怒りしめた罪を償うべし。」", "'Now thou shalt pay for annoying me.'"));
4882 switch (randint1(4))
4885 (void)activate_ty_curse(FALSE, &count);
4886 reward = _("禍々しい呪いをかけられた。", "cursing");
4889 activate_hi_summon(p_ptr->y, p_ptr->x, FALSE);
4890 reward = _("モンスターを召喚された。", "summoning hostile monsters");
4895 if (!buki_motteruka(INVEN_RARM) && !buki_motteruka(INVEN_LARM)) break;
4897 if (buki_motteruka(INVEN_LARM))
4900 if (buki_motteruka(INVEN_RARM) && one_in_(2)) dummy = INVEN_RARM;
4902 object_desc(o_name, &inventory[dummy], OD_NAME_ONLY);
4903 (void)curse_weapon(FALSE, dummy);
4904 reward = format(_("%sが破壊された。", "destroying %s"), o_name);
4908 if (!inventory[INVEN_BODY].k_idx) break;
4909 object_desc(o_name, &inventory[INVEN_BODY], OD_NAME_ONLY);
4910 (void)curse_armor();
4911 reward = format(_("%sが破壊された。", "destroying %s"), o_name);
4915 for (dummy = 0; dummy < 6; dummy++)
4917 (void)dec_stat(dummy, 10 + randint1(15), TRUE);
4919 reward = _("全能力値が下がった。", "decreasing all stats");
4926 msg_format(_("%sの声が轟き渡った:", "The voice of %s thunders:"), chaos_patrons[p_ptr->chaos_patron]);
4927 msg_print(_("「死ぬがよい、下僕よ!」", "'Die, mortal!'"));
4929 take_hit(DAMAGE_LOSELIFE, p_ptr->lev * 4, wrath_reason, -1);
4930 for (dummy = 0; dummy < 6; dummy++)
4932 (void)dec_stat(dummy, 10 + randint1(15), FALSE);
4934 activate_hi_summon(p_ptr->y, p_ptr->x, FALSE);
4935 (void)activate_ty_curse(FALSE, &count);
4940 if (buki_motteruka(INVEN_RARM))
4943 if (buki_motteruka(INVEN_LARM) && one_in_(2)) dummy = INVEN_LARM;
4945 else if (buki_motteruka(INVEN_LARM)) dummy = INVEN_LARM;
4947 if (dummy) (void)curse_weapon(FALSE, dummy);
4949 if (one_in_(2)) (void)curse_armor();
4954 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4955 msg_print(_("「死と破壊こそ我が喜びなり!」", "'Death and destruction! This pleaseth me!'"));
4957 (void)destroy_area(p_ptr->y, p_ptr->x, 25, FALSE);
4958 reward = _("ダンジョンが*破壊*された。", "*destruct*ing dungeon");
4963 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4964 msg_print(_("「我、汝の敵を抹殺せん!」", "'Let me relieve thee of thine oppressors!'"));
4965 (void)symbol_genocide(0, FALSE);
4966 reward = _("モンスターが抹殺された。", "genociding monsters");
4971 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4972 msg_print(_("「我、汝の敵を抹殺せん!」", "'Let me relieve thee of thine oppressors!'"));
4974 (void)mass_genocide(0, FALSE);
4975 reward = _("モンスターが抹殺された。", "genociding nearby monsters");
4980 msg_format(_("%sの力が敵を攻撃するのを感じた!", "You can feel the power of %s assault your enemies!"), chaos_patrons[p_ptr->chaos_patron]);
4981 (void)dispel_monsters(p_ptr->lev * 4);
4986 msg_format(_("%sはあなたを無視した。", "%s ignores you."), chaos_patrons[p_ptr->chaos_patron]);
4991 msg_format(_("%sは褒美として悪魔の使いをよこした!", "%s rewards you with a demonic servant!"),chaos_patrons[p_ptr->chaos_patron]);
4993 if (!summon_specific(-1, p_ptr->y, p_ptr->x, dun_level, SUMMON_DEMON, PM_FORCE_PET))
4994 msg_print(_("何も現れなかった...", "Nobody ever turns up..."));
4996 reward = _("悪魔がペットになった。", "a demonic servant");
5001 msg_format(_("%sは褒美として使いをよこした!", "%s rewards you with a servant!"),chaos_patrons[p_ptr->chaos_patron]);
5003 if (!summon_specific(-1, p_ptr->y, p_ptr->x, dun_level, 0, PM_FORCE_PET))
5004 msg_print(_("何も現れなかった...", "Nobody ever turns up..."));
5006 reward = _("モンスターがペットになった。", "a servant");
5011 msg_format(_("%sは褒美としてアンデッドの使いをよこした。", "%s rewards you with an undead servant!"),chaos_patrons[p_ptr->chaos_patron]);
5013 if (!summon_specific(-1, p_ptr->y, p_ptr->x, dun_level, SUMMON_UNDEAD, PM_FORCE_PET))
5014 msg_print(_("何も現れなかった...", "Nobody ever turns up..."));
5016 reward = _("アンデッドがペットになった。", "an undead servant");
5021 msg_format(_("%sの声がどもった:", "The voice of %s stammers:"),
5023 chaos_patrons[p_ptr->chaos_patron]);
5024 msg_format(_("「あー、あー、答えは %d/%d。質問は何?」", "'Uh... uh... the answer's %d/%d, what's the question?'"), type, effect);
5030 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, format(_("パトロンの報酬で%s", "The patron rewards you with %s."), reward));
5036 * XAngband: determine if a given location is "interesting"
5037 * based on target_set_accept function.
5039 static bool tgt_pt_accept(POSITION y, POSITION x)
5044 if (!(in_bounds(y, x))) return (FALSE);
5046 /* Player grid is always interesting */
5047 if ((y == p_ptr->y) && (x == p_ptr->x)) return (TRUE);
5049 /* Handle hallucination */
5050 if (p_ptr->image) return (FALSE);
5052 /* Examine the grid */
5053 c_ptr = &cave[y][x];
5055 /* Interesting memorized features */
5056 if (c_ptr->info & (CAVE_MARK))
5059 if (cave_have_flag_grid(c_ptr, FF_LESS)) return (TRUE);
5060 if (cave_have_flag_grid(c_ptr, FF_MORE)) return (TRUE);
5062 /* Notice quest features */
5063 if (cave_have_flag_grid(c_ptr, FF_QUEST_ENTER)) return (TRUE);
5064 if (cave_have_flag_grid(c_ptr, FF_QUEST_EXIT)) return (TRUE);
5073 * XAngband: Prepare the "temp" array for "tget_pt"
5074 * based on target_set_prepare funciton.
5076 static void tgt_pt_prepare(void)
5080 /* Reset "temp" array */
5083 if (!expand_list) return;
5085 /* Scan the current panel */
5086 for (y = 1; y < cur_hgt; y++)
5088 for (x = 1; x < cur_wid; x++)
5090 /* Require "interesting" contents */
5091 if (!tgt_pt_accept(y, x)) continue;
5093 /* Save the location */
5100 /* Target the nearest monster for shooting */
5101 ang_sort_comp = ang_sort_comp_distance;
5102 ang_sort_swap = ang_sort_swap_distance;
5104 /* Sort the positions */
5105 ang_sort(temp_x, temp_y, temp_n);
5109 * old -- from PsiAngband.
5111 bool tgt_pt(POSITION *x_ptr, POSITION *y_ptr)
5116 bool success = FALSE;
5121 get_screen_size(&wid, &hgt);
5131 msg_print(_("場所を選んでスペースキーを押して下さい。", "Select a point and press space."));
5132 msg_flag = FALSE; /* prevents "-more-" message. */
5134 while ((ch != ESCAPE) && !success)
5136 bool move_fast = FALSE;
5138 move_cursor_relative(y, x);
5150 if (player_bold(y, x)) ch = 0;
5153 else success = TRUE;
5157 /* XAngband: Move cursor to stairs */
5160 if (expand_list && temp_n)
5163 int cx = (panel_col_min + panel_col_max) / 2;
5164 int cy = (panel_row_min + panel_row_max) / 2;
5168 /* Skip stairs which have defferent distance */
5169 for (; n < temp_n; ++ n)
5171 cave_type *c_ptr = &cave[temp_y[n]][temp_x[n]];
5173 if (cave_have_flag_grid(c_ptr, FF_STAIRS) &&
5174 cave_have_flag_grid(c_ptr, ch == '>' ? FF_MORE : FF_LESS))
5181 if (n == temp_n) /* Loop out taget list */
5186 verify_panel(); /* Move cursor to player */
5189 p_ptr->update |= (PU_MONSTERS);
5192 p_ptr->redraw |= (PR_MAP);
5195 p_ptr->window |= (PW_OVERHEAD);
5200 else /* move cursor to next stair and change panel */
5205 dy = 2 * (y - cy) / hgt;
5206 dx = 2 * (x - cx) / wid;
5207 if (dy || dx) change_panel(dy, dx);
5213 /* Look up the direction */
5214 d = get_keymap_dir(ch);
5216 /* XTRA HACK MOVEFAST */
5217 if (isupper(ch)) move_fast = TRUE;
5219 /* Handle "direction" */
5225 /* XTRA HACK MOVEFAST */
5228 int mag = MIN(wid / 2, hgt / 2);
5238 /* Do not move horizontally if unnecessary */
5239 if (((x < panel_col_min + wid / 2) && (dx > 0)) ||
5240 ((x > panel_col_min + wid / 2) && (dx < 0)))
5245 /* Do not move vertically if unnecessary */
5246 if (((y < panel_row_min + hgt / 2) && (dy > 0)) ||
5247 ((y > panel_row_min + hgt / 2) && (dy < 0)))
5252 /* Apply the motion */
5253 if ((y >= panel_row_min + hgt) || (y < panel_row_min) ||
5254 (x >= panel_col_min + wid) || (x < panel_col_min))
5256 /* if (change_panel(dy, dx)) target_set_prepare(mode); */
5257 change_panel(dy, dx);
5260 /* Slide into legality */
5261 if (x >= cur_wid-1) x = cur_wid - 2;
5262 else if (x <= 0) x = 1;
5264 /* Slide into legality */
5265 if (y >= cur_hgt-1) y = cur_hgt- 2;
5266 else if (y <= 0) y = 1;
5273 /* Clear the top line */
5276 /* Recenter the map around the player */
5280 p_ptr->update |= (PU_MONSTERS);
5283 p_ptr->redraw |= (PR_MAP);
5286 p_ptr->window |= (PW_OVERHEAD);
5297 bool get_hack_dir(DIRECTION *dp)
5306 /* Global direction */
5309 /* (No auto-targeting) */
5311 /* Ask until satisfied */
5314 /* Choose a prompt */
5317 p = _("方向 ('*'でターゲット選択, ESCで中断)? ", "Direction ('*' to choose a target, Escape to cancel)? ");
5321 p = _("方向 ('5'でターゲットへ, '*'でターゲット再選択, ESCで中断)? ", "Direction ('5' for target, '*' to re-target, Escape to cancel)? ");
5324 /* Get a command (or Cancel) */
5325 if (!get_com(p, &command, TRUE)) break;
5329 if (command == '\r') command = 't';
5332 /* Convert various keys to "standard" keys */
5335 /* Use current target */
5346 /* Set new target */
5351 if (target_set(TARGET_KILL)) dir = 5;
5357 /* Look up the direction */
5358 dir = get_keymap_dir(command);
5364 /* Verify requested targets */
5365 if ((dir == 5) && !target_okay()) dir = 0;
5372 if (!dir) return (FALSE);
5374 /* Save the direction */
5377 /* Check for confusion */
5378 if (p_ptr->confused)
5381 /* Random direction */
5382 dir = ddd[randint0(8)];
5385 /* Notice confusion */
5386 if (command_dir != dir)
5389 msg_print(_("あなたは混乱している。", "You are confused."));
5392 /* Save direction */
5395 /* A "valid" direction was entered */
5401 * エネルギーの増加量10d5を速く計算するための関数
5404 #define Go_no_JuuJou 5*5*5*5*5*5*5*5*5*5
5406 s16b gain_energy(void)
5409 s32b energy_result = 10;
5412 tmp = randint0(Go_no_JuuJou);
5414 for (i = 0; i < 9; i ++){
5415 energy_result += tmp % 5;
5419 return (s16b)(energy_result + tmp);
5424 * @brief 射撃武器の攻撃に必要な基本消費エネルギーを返す/Return bow energy
5425 * @param sval 射撃武器のアイテム副分類ID
5426 * @return 消費する基本エネルギー
5428 ENERGY bow_energy(OBJECT_SUBTYPE_VALUE sval)
5430 ENERGY energy = 10000;
5432 /* Analyze the launcher */
5435 /* Sling and ammo */
5442 /* Short Bow and Arrow */
5449 /* Long Bow and Arrow */
5456 /* Bow of irresponsiblity and Arrow */
5463 /* Light Crossbow and Bolt */
5470 /* Heavy Crossbow and Bolt */
5485 int bow_tmul(OBJECT_SUBTYPE_VALUE sval)
5489 /* Analyze the launcher */
5492 /* Sling and ammo */
5499 /* Short Bow and Arrow */
5506 /* Long Bow and Arrow */
5513 /* Bow of irresponsiblity and Arrow */
5520 /* Light Crossbow and Bolt */
5527 /* Heavy Crossbow and Bolt */
5539 * Return alignment title
5541 cptr your_alignment(void)
5544 if (p_ptr->align > 150) return "大善";
5545 else if (p_ptr->align > 50) return "中善";
5546 else if (p_ptr->align > 10) return "小善";
5547 else if (p_ptr->align > -11) return "中立";
5548 else if (p_ptr->align > -51) return "小悪";
5549 else if (p_ptr->align > -151) return "中悪";
5552 if (p_ptr->align > 150) return "Lawful";
5553 else if (p_ptr->align > 50) return "Good";
5554 else if (p_ptr->align > 10) return "Neutral Good";
5555 else if (p_ptr->align > -11) return "Neutral";
5556 else if (p_ptr->align > -51) return "Neutral Evil";
5557 else if (p_ptr->align > -151) return "Evil";
5558 else return "Chaotic";
5564 * Return proficiency level of weapons and misc. skills (except riding)
5566 int weapon_exp_level(int weapon_exp)
5568 if (weapon_exp < WEAPON_EXP_BEGINNER) return EXP_LEVEL_UNSKILLED;
5569 else if (weapon_exp < WEAPON_EXP_SKILLED) return EXP_LEVEL_BEGINNER;
5570 else if (weapon_exp < WEAPON_EXP_EXPERT) return EXP_LEVEL_SKILLED;
5571 else if (weapon_exp < WEAPON_EXP_MASTER) return EXP_LEVEL_EXPERT;
5572 else return EXP_LEVEL_MASTER;
5577 * Return proficiency level of riding
5579 int riding_exp_level(int riding_exp)
5581 if (riding_exp < RIDING_EXP_BEGINNER) return EXP_LEVEL_UNSKILLED;
5582 else if (riding_exp < RIDING_EXP_SKILLED) return EXP_LEVEL_BEGINNER;
5583 else if (riding_exp < RIDING_EXP_EXPERT) return EXP_LEVEL_SKILLED;
5584 else if (riding_exp < RIDING_EXP_MASTER) return EXP_LEVEL_EXPERT;
5585 else return EXP_LEVEL_MASTER;
5590 * Return proficiency level of spells
5592 int spell_exp_level(int spell_exp)
5594 if (spell_exp < SPELL_EXP_BEGINNER) return EXP_LEVEL_UNSKILLED;
5595 else if (spell_exp < SPELL_EXP_SKILLED) return EXP_LEVEL_BEGINNER;
5596 else if (spell_exp < SPELL_EXP_EXPERT) return EXP_LEVEL_SKILLED;
5597 else if (spell_exp < SPELL_EXP_MASTER) return EXP_LEVEL_EXPERT;
5598 else return EXP_LEVEL_MASTER;
5603 * Display a rumor and apply its effects
5606 IDX rumor_num(char *zz, IDX max_idx)
5608 if (strcmp(zz, "*") == 0) return randint1(max_idx - 1);
5609 return (IDX)atoi(zz);
5612 cptr rumor_bind_name(char *base, cptr fullname)
5616 s = strstr(base, "{Name}");
5620 v = format("%s%s%s", base, fullname, (s + 6));
5630 void display_rumor(bool ex)
5638 if (randint0(3) == 0) section = 1;
5641 err = _(get_rnd_line_jonly("rumors_j.txt", section, Rumor, 10),
5642 get_rnd_line("rumors.txt", section, Rumor));
5643 if (err) strcpy(Rumor, _("嘘の噂もある。", "Some rumors are wrong."));
5647 if (strncmp(Rumor, "R:", 2) == 0)
5650 cptr rumor_msg = NULL;
5651 cptr rumor_eff_format = NULL;
5652 char fullname[1024] = "";
5654 if (tokenize(Rumor + 2, 3, zz, TOKENIZE_CHECKQUOTE) == 3)
5656 if (strcmp(zz[0], "ARTIFACT") == 0)
5660 object_type *q_ptr = &forge;
5661 artifact_type *a_ptr;
5665 a_idx = rumor_num(zz[1], max_a_idx);
5667 a_ptr = &a_info[a_idx];
5668 if (a_ptr->name) break;
5671 k_idx = lookup_kind(a_ptr->tval, a_ptr->sval);
5672 object_prep(q_ptr, k_idx);
5673 q_ptr->name1 = a_idx;
5674 q_ptr->ident = IDENT_STORE;
5675 object_desc(fullname, q_ptr, OD_NAME_ONLY);
5677 else if (strcmp(zz[0], "MONSTER") == 0)
5680 monster_race *r_ptr;
5684 r_idx = rumor_num(zz[1], max_r_idx);
5685 r_ptr = &r_info[r_idx];
5686 if (r_ptr->name) break;
5689 strcpy(fullname, r_name + r_ptr->name);
5691 /* Remember this monster */
5692 if (!r_ptr->r_sights)
5697 else if (strcmp(zz[0], "DUNGEON") == 0)
5700 dungeon_info_type *d_ptr;
5704 d_idx = rumor_num(zz[1], max_d_idx);
5705 d_ptr = &d_info[d_idx];
5706 if (d_ptr->name) break;
5709 strcpy(fullname, d_name + d_ptr->name);
5711 if (!max_dlv[d_idx])
5713 max_dlv[d_idx] = d_ptr->mindepth;
5714 rumor_eff_format = _("%sに帰還できるようになった。", "You can recall to %s.");
5717 else if (strcmp(zz[0], "TOWN") == 0)
5724 t_idx = rumor_num(zz[1], NO_TOWN);
5725 if (town[t_idx].name) break;
5728 strcpy(fullname, town[t_idx].name);
5730 visit = (1L << (t_idx - 1));
5731 if ((t_idx != SECRET_TOWN) && !(p_ptr->visit & visit))
5733 p_ptr->visit |= visit;
5734 rumor_eff_format = _("%sに行ったことがある気がする。", "You feel you have been to %s.");
5738 rumor_msg = rumor_bind_name(zz[2], fullname);
5739 msg_print(rumor_msg);
5740 if (rumor_eff_format)
5743 msg_format(rumor_eff_format, fullname);
5748 if (err) msg_print(_("この情報は間違っている。", "This information is wrong."));
5752 msg_format("%s", Rumor);