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.
17 #define REWARD_CHANCE 10
21 * @brief プレイヤーの経験値について整合性のためのチェックと調整を行う /
22 * Advance experience levels and print experience
25 void check_experience(void)
27 bool level_reward = FALSE;
28 bool level_mutation = FALSE;
29 bool level_inc_stat = FALSE;
30 bool android = (p_ptr->prace == RACE_ANDROID ? TRUE : FALSE);
31 PLAYER_LEVEL old_lev = p_ptr->lev;
33 /* Hack -- lower limit */
34 if (p_ptr->exp < 0) p_ptr->exp = 0;
35 if (p_ptr->max_exp < 0) p_ptr->max_exp = 0;
36 if (p_ptr->max_max_exp < 0) p_ptr->max_max_exp = 0;
38 /* Hack -- upper limit */
39 if (p_ptr->exp > PY_MAX_EXP) p_ptr->exp = PY_MAX_EXP;
40 if (p_ptr->max_exp > PY_MAX_EXP) p_ptr->max_exp = PY_MAX_EXP;
41 if (p_ptr->max_max_exp > PY_MAX_EXP) p_ptr->max_max_exp = PY_MAX_EXP;
43 /* Hack -- maintain "max" experience */
44 if (p_ptr->exp > p_ptr->max_exp) p_ptr->max_exp = p_ptr->exp;
46 /* Hack -- maintain "max max" experience */
47 if (p_ptr->max_exp > p_ptr->max_max_exp) p_ptr->max_max_exp = p_ptr->max_exp;
49 /* Redraw experience */
50 p_ptr->redraw |= (PR_EXP);
56 /* Lose levels while possible */
57 while ((p_ptr->lev > 1) &&
58 (p_ptr->exp < ((android ? player_exp_a : player_exp)[p_ptr->lev - 2] * p_ptr->expfact / 100L)))
63 /* Update some stuff */
64 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
66 /* Redraw some stuff */
67 p_ptr->redraw |= (PR_LEV | PR_TITLE);
70 p_ptr->window |= (PW_PLAYER);
77 /* Gain levels while possible */
78 while ((p_ptr->lev < PY_MAX_LEVEL) &&
79 (p_ptr->exp >= ((android ? player_exp_a : player_exp)[p_ptr->lev-1] * p_ptr->expfact / 100L)))
84 /* Save the highest level */
85 if (p_ptr->lev > p_ptr->max_plv)
87 p_ptr->max_plv = p_ptr->lev;
89 if ((p_ptr->pclass == CLASS_CHAOS_WARRIOR) ||
90 (p_ptr->muta2 & MUT2_CHAOS_GIFT))
94 if (p_ptr->prace == RACE_BEASTMAN)
96 if (one_in_(5)) level_mutation = TRUE;
98 level_inc_stat = TRUE;
100 do_cmd_write_nikki(NIKKI_LEVELUP, p_ptr->lev, NULL);
107 msg_format(_("レベル %d にようこそ。", "Welcome to level %d."), p_ptr->lev);
109 /* Update some stuff */
110 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
112 /* Redraw some stuff */
113 p_ptr->redraw |= (PR_LEV | PR_TITLE | PR_EXP);
116 p_ptr->window |= (PW_PLAYER | PW_SPELL | PW_INVEN);
128 if(!(p_ptr->max_plv % 10))
138 cnv_stat(p_ptr->stat_max[0], tmp);
139 prt(format(" a) 腕力 (現在値 %s)", tmp), 2, 14);
140 cnv_stat(p_ptr->stat_max[1], tmp);
141 prt(format(" b) 知能 (現在値 %s)", tmp), 3, 14);
142 cnv_stat(p_ptr->stat_max[2], tmp);
143 prt(format(" c) 賢さ (現在値 %s)", tmp), 4, 14);
144 cnv_stat(p_ptr->stat_max[3], tmp);
145 prt(format(" d) 器用 (現在値 %s)", tmp), 5, 14);
146 cnv_stat(p_ptr->stat_max[4], tmp);
147 prt(format(" e) 耐久 (現在値 %s)", tmp), 6, 14);
148 cnv_stat(p_ptr->stat_max[5], tmp);
149 prt(format(" f) 魅力 (現在値 %s)", tmp), 7, 14);
151 prt(" どの能力値を上げますか?", 1, 14);
153 cnv_stat(p_ptr->stat_max[0], tmp);
154 prt(format(" a) Str (cur %s)", tmp), 2, 14);
155 cnv_stat(p_ptr->stat_max[1], tmp);
156 prt(format(" b) Int (cur %s)", tmp), 3, 14);
157 cnv_stat(p_ptr->stat_max[2], tmp);
158 prt(format(" c) Wis (cur %s)", tmp), 4, 14);
159 cnv_stat(p_ptr->stat_max[3], tmp);
160 prt(format(" d) Dex (cur %s)", tmp), 5, 14);
161 cnv_stat(p_ptr->stat_max[4], tmp);
162 prt(format(" e) Con (cur %s)", tmp), 6, 14);
163 cnv_stat(p_ptr->stat_max[5], tmp);
164 prt(format(" f) Chr (cur %s)", tmp), 7, 14);
166 prt(" Which stat do you want to raise?", 1, 14);
171 if ((choice >= 'a') && (choice <= 'f')) break;
173 for(n = 0; n < 6; n++)
174 if (n != choice - 'a')
176 if (get_check(_("よろしいですか?", "Are you sure? "))) break;
178 do_inc_stat(choice - 'a');
181 else if(!(p_ptr->max_plv % 2))
182 do_inc_stat(randint0(6));
187 msg_print(_("あなたは変わった気がする...", "You feel different..."));
188 (void)gain_random_mutation(0);
189 level_mutation = FALSE;
193 * 報酬でレベルが上ると再帰的に check_experience() が
198 gain_level_reward(0);
199 level_reward = FALSE;
202 /* Update some stuff */
203 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
205 /* Redraw some stuff */
206 p_ptr->redraw |= (PR_LEV | PR_TITLE);
209 p_ptr->window |= (PW_PLAYER | PW_SPELL);
215 /* Load an autopick preference file */
216 if (old_lev != p_ptr->lev) autopick_load_pref(FALSE);
221 * @brief モンスターを倒した際の財宝svalを返す
222 * @param r_idx 倒したモンスターの種族ID
225 * Hack -- Return the "automatic coin type" of a monster race
226 * Used to allocate proper treasure when "Creeping coins" die
227 * XXX XXX XXX Note the use of actual "monster names"
229 static int get_coin_type(MONRACE_IDX r_idx)
231 /* Analyze monsters */
234 case MON_COPPER_COINS: return 2;
235 case MON_SILVER_COINS: return 5;
236 case MON_GOLD_COINS: return 10;
237 case MON_MITHRIL_COINS:
238 case MON_MITHRIL_GOLEM: return 16;
239 case MON_ADAMANT_COINS: return 17;
248 * @brief オブジェクトがクロークかどうかを判定する /
249 * Hack -- determine if a template is Cloak
250 * @param k_idx 判定したいオブジェクトのベースアイテムID
251 * @return オブジェクトがクロークならばTRUEを返す
253 static bool kind_is_cloak(KIND_OBJECT_IDX k_idx)
255 object_kind *k_ptr = &k_info[k_idx];
257 /* Analyze the item type */
258 if (k_ptr->tval == TV_CLOAK)
263 /* Assume not good */
269 * @brief オブジェクトが竿状武器かどうかを判定する /
270 * Hack -- determine if a template is Polearm
271 * @param k_idx 判定したいオブジェクトのベースアイテムID
272 * @return オブジェクトが竿状武器ならばTRUEを返す
274 static bool kind_is_polearm(KIND_OBJECT_IDX k_idx)
276 object_kind *k_ptr = &k_info[k_idx];
278 /* Analyze the item type */
279 if (k_ptr->tval == TV_POLEARM)
284 /* Assume not good */
290 * @brief オブジェクトが剣かどうかを判定する /
291 * Hack -- determine if a template is Sword
292 * @param k_idx 判定したいオブジェクトのベースアイテムID
293 * @return オブジェクトが剣ならばTRUEを返す
295 static bool kind_is_sword(KIND_OBJECT_IDX k_idx)
297 object_kind *k_ptr = &k_info[k_idx];
299 /* Analyze the item type */
300 if ((k_ptr->tval == TV_SWORD) && (k_ptr->sval > 2))
305 /* Assume not good */
311 * @brief オブジェクトが魔法書かどうかを判定する /
312 * Hack -- determine if a template is Book
313 * @param k_idx 判定したいオブジェクトのベースアイテムID
314 * @return オブジェクトが魔法書ならばTRUEを返す
316 static bool kind_is_book(KIND_OBJECT_IDX k_idx)
318 object_kind *k_ptr = &k_info[k_idx];
320 /* Analyze the item type */
321 if ((k_ptr->tval >= TV_LIFE_BOOK) && (k_ptr->tval <= TV_CRUSADE_BOOK))
326 /* Assume not good */
332 * @brief オブジェクトがベースアイテム時点でGOODかどうかを判定する /
333 * Hack -- determine if a template is Good book
334 * @param k_idx 判定したいオブジェクトのベースアイテムID
335 * @return オブジェクトがベースアイテム時点でGOODなアイテムならばTRUEを返す
337 static bool kind_is_good_book(KIND_OBJECT_IDX k_idx)
339 object_kind *k_ptr = &k_info[k_idx];
341 /* Analyze the item type */
342 if ((k_ptr->tval >= TV_LIFE_BOOK) && (k_ptr->tval <= TV_CRUSADE_BOOK) && (k_ptr->tval != TV_ARCANE_BOOK) && (k_ptr->sval > 1))
347 /* Assume not good */
353 * @brief オブジェクトが鎧かどうかを判定する /
354 * Hack -- determine if a template is Armor
355 * @param k_idx 判定したいオブジェクトのベースアイテムID
356 * @return オブジェクトが鎧ならばTRUEを返す
358 static bool kind_is_armor(KIND_OBJECT_IDX k_idx)
360 object_kind *k_ptr = &k_info[k_idx];
362 /* Analyze the item type */
363 if (k_ptr->tval == TV_HARD_ARMOR)
368 /* Assume not good */
374 * @brief オブジェクトが打撃武器かどうかを判定する /
375 * Hack -- determine if a template is hafted weapon
376 * @param k_idx 判定したいオブジェクトのベースアイテムID
377 * @return オブジェクトが打撃武器ならばTRUEを返す
379 static bool kind_is_hafted(KIND_OBJECT_IDX k_idx)
381 object_kind *k_ptr = &k_info[k_idx];
383 /* Analyze the item type */
384 if (k_ptr->tval == TV_HAFTED)
389 /* Assume not good */
394 * @brief クエストを達成状態にする /
395 * @param quest_num 達成状態にしたいクエストのID
398 void complete_quest(int quest_num)
400 quest_type* const q_ptr = &quest[quest_num];
404 case QUEST_TYPE_RANDOM:
405 if (record_rand_quest) do_cmd_write_nikki(NIKKI_RAND_QUEST_C, quest_num, NULL);
408 if (record_fix_quest) do_cmd_write_nikki(NIKKI_FIX_QUEST_C, quest_num, NULL);
412 q_ptr->status = QUEST_STATUS_COMPLETED;
413 q_ptr->complev = (byte)p_ptr->lev;
415 q_ptr->comptime = playtime;
417 if (!(q_ptr->flags & QUEST_FLAG_SILENT))
419 play_music(TERM_XTRA_MUSIC_BASIC, MUSIC_BASIC_QUEST_CLEAR);
420 msg_print(_("クエストを達成した!", "You just completed your quest!"));
426 * @brief 現在フロアに残っている敵モンスターの数を返す /
427 * @return 現在の敵モンスターの数
429 static int count_all_hostile_monsters(void)
434 for (x = 0; x < cur_wid; ++ x)
436 for (y = 0; y < cur_hgt; ++ y)
438 MONSTER_IDX m_idx = cave[y][x].m_idx;
440 if (m_idx > 0 && is_hostile(&m_list[m_idx]))
451 * @brief 特定の敵を倒した際にクエスト達成処理 /
452 * Check for "Quest" completion when a quest monster is killed or charmed.
453 * @param m_ptr 撃破したモンスターの構造体参照ポインタ
456 void check_quest_completion(monster_type *m_ptr)
462 bool create_stairs = FALSE;
468 /* Get the location */
473 quest_num = p_ptr->inside_quest;
475 /* Search for an active quest on this dungeon level */
480 for (i = max_q_idx - 1; i > 0; i--)
482 quest_type* const q_ptr = &quest[i];
484 /* Quest is not active */
485 if (q_ptr->status != QUEST_STATUS_TAKEN)
488 /* Quest is not a dungeon quest */
489 if (q_ptr->flags & QUEST_FLAG_PRESET)
492 /* Quest is not on this level */
493 if ((q_ptr->level != dun_level) &&
494 (q_ptr->type != QUEST_TYPE_KILL_ANY_LEVEL))
497 /* Not a "kill monster" quest */
498 if ((q_ptr->type == QUEST_TYPE_FIND_ARTIFACT) ||
499 (q_ptr->type == QUEST_TYPE_FIND_EXIT))
502 /* Interesting quest */
503 if ((q_ptr->type == QUEST_TYPE_KILL_NUMBER) ||
504 (q_ptr->type == QUEST_TYPE_TOWER) ||
505 (q_ptr->type == QUEST_TYPE_KILL_ALL))
508 /* Interesting quest */
509 if (((q_ptr->type == QUEST_TYPE_KILL_LEVEL) ||
510 (q_ptr->type == QUEST_TYPE_KILL_ANY_LEVEL) ||
511 (q_ptr->type == QUEST_TYPE_RANDOM)) &&
512 (q_ptr->r_idx == m_ptr->r_idx))
519 /* Handle the current quest */
520 if (quest_num && (quest[quest_num].status == QUEST_STATUS_TAKEN))
523 quest_type* const q_ptr = &quest[quest_num];
527 case QUEST_TYPE_KILL_NUMBER:
531 if (q_ptr->cur_num >= q_ptr->num_mon)
533 complete_quest(quest_num);
539 case QUEST_TYPE_KILL_ALL:
541 if (!is_hostile(m_ptr)) break;
543 if (count_all_hostile_monsters() == 1)
545 if (q_ptr->flags & QUEST_FLAG_SILENT)
547 q_ptr->status = QUEST_STATUS_FINISHED;
551 complete_quest(quest_num);
556 case QUEST_TYPE_KILL_LEVEL:
557 case QUEST_TYPE_RANDOM:
559 /* Only count valid monsters */
560 if (q_ptr->r_idx != m_ptr->r_idx)
565 if (q_ptr->cur_num >= q_ptr->max_num)
567 complete_quest(quest_num);
569 if (!(q_ptr->flags & QUEST_FLAG_PRESET))
571 create_stairs = TRUE;
572 p_ptr->inside_quest = 0;
575 /* Finish the two main quests without rewarding */
576 if ((quest_num == QUEST_OBERON) || (quest_num == QUEST_SERPENT))
578 q_ptr->status = QUEST_STATUS_FINISHED;
581 if (q_ptr->type == QUEST_TYPE_RANDOM)
584 q_ptr->status = QUEST_STATUS_FINISHED;
589 case QUEST_TYPE_KILL_ANY_LEVEL:
592 if (q_ptr->cur_num >= q_ptr->max_num)
594 complete_quest(quest_num);
599 case QUEST_TYPE_TOWER:
601 if (!is_hostile(m_ptr)) break;
603 if (count_all_hostile_monsters() == 1)
605 q_ptr->status = QUEST_STATUS_STAGE_COMPLETED;
607 if((quest[QUEST_TOWER1].status == QUEST_STATUS_STAGE_COMPLETED) &&
608 (quest[QUEST_TOWER2].status == QUEST_STATUS_STAGE_COMPLETED) &&
609 (quest[QUEST_TOWER3].status == QUEST_STATUS_STAGE_COMPLETED))
612 complete_quest(QUEST_TOWER1);
620 /* Create a magical staircase */
626 while (cave_perma_bold(y, x) || cave[y][x].o_idx || (cave[y][x].info & CAVE_OBJECT) )
628 /* Pick a location */
629 scatter(&ny, &nx, y, x, 1, 0);
635 /* Explain the staircase */
636 msg_print(_("魔法の階段が現れた...", "A magical staircase appears..."));
638 /* Create stairs down */
639 cave_set_feat(y, x, feat_down_stair);
641 /* Remember to update everything */
642 p_ptr->update |= (PU_FLOW);
652 for (i = 0; i < (dun_level / 15)+1; i++)
654 /* Get local object */
657 /* Wipe the object */
660 /* Make a great object */
661 make_object(o_ptr, AM_GOOD | AM_GREAT);
663 /* Drop it in the dungeon */
664 (void)drop_near(o_ptr, -1, y, x);
670 * @brief 特定のアーティファクトを入手した際のクエスト達成処理 /
671 * Check for "Quest" completion when a quest monster is killed or charmed.
672 * @param o_ptr 入手したオブジェクトの構造体参照ポインタ
675 void check_find_art_quest_completion(object_type *o_ptr)
678 /* Check if completed a quest */
679 for (i = 0; i < max_q_idx; i++)
681 if ((quest[i].type == QUEST_TYPE_FIND_ARTIFACT) &&
682 (quest[i].status == QUEST_STATUS_TAKEN) &&
683 (quest[i].k_idx == o_ptr->name1))
692 * @brief モンスターを撃破した際の述語メッセージを返す /
693 * Return monster death string
694 * @param r_ptr 撃破されたモンスターの種族情報を持つ構造体の参照ポインタ
695 * @return 撃破されたモンスターの述語
697 cptr extract_note_dies(monster_race *r_ptr)
699 /* Some monsters get "destroyed" */
700 if (!monster_living(r_ptr))
704 for (i = 0; i < 4; i++)
706 if (r_ptr->blow[i].method == RBM_EXPLODE)
708 return _("は爆発して粉々になった。", " explodes into tiny shreds.");
711 return _("を倒した。", " is destroyed.");
714 /* Assume a default death */
715 return _("は死んだ。", " dies.");
720 * @brief モンスターが死亡した時の処理 /
721 * Handle the "death" of a monster.
722 * @param m_idx 死亡したモンスターのID
723 * @param drop_item TRUEならばモンスターのドロップ処理を行う
724 * @return 撃破されたモンスターの述語
727 * Disperse treasures centered at the monster location based on the
728 * various flags contained in the monster flags fields.
729 * Check for "Quest" completion when a quest monster is killed.
730 * Note that only the player can induce "monster_death()" on Uniques.
731 * Thus (for now) all Quest monsters should be Uniques.
732 * Note that monsters can now carry objects, and when a monster dies,
733 * it drops all of its objects, which may disappear in crowded rooms.
736 void monster_death(MONSTER_IDX m_idx, bool drop_item)
745 monster_type *m_ptr = &m_list[m_idx];
747 monster_race *r_ptr = &r_info[m_ptr->r_idx];
749 bool visible = ((m_ptr->ml && !p_ptr->image) || (r_ptr->flags1 & RF1_UNIQUE));
753 bool do_gold = (!(r_ptr->flags1 & RF1_ONLY_ITEM));
754 bool do_item = (!(r_ptr->flags1 & RF1_ONLY_GOLD));
755 bool cloned = (m_ptr->smart & SM_CLONED) ? TRUE : FALSE;
756 int force_coin = get_coin_type(m_ptr->r_idx);
761 bool drop_chosen_item = drop_item && !cloned && !p_ptr->inside_arena
762 && !p_ptr->inside_battle && !is_pet(m_ptr);
764 /* The caster is dead? */
765 if (world_monster && world_monster == m_idx) world_monster = 0;
767 /* Notice changes in view */
768 if (r_ptr->flags7 & (RF7_LITE_MASK | RF7_DARK_MASK))
770 /* Update some things */
771 p_ptr->update |= (PU_MON_LITE);
774 /* Get the location */
778 if (record_named_pet && is_pet(m_ptr) && m_ptr->nickname)
782 monster_desc(m_name, m_ptr, MD_INDEF_VISIBLE);
783 do_cmd_write_nikki(NIKKI_NAMED_PET, 3, m_name);
786 /* Let monsters explode! */
787 for (i = 0; i < 4; i++)
789 if (r_ptr->blow[i].method == RBM_EXPLODE)
791 BIT_FLAGS flg = PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL;
792 int typ = mbe_info[r_ptr->blow[i].effect].explode_type;
793 DICE_NUMBER d_dice = r_ptr->blow[i].d_dice;
794 DICE_SID d_side = r_ptr->blow[i].d_side;
795 HIT_POINT damage = damroll(d_dice, d_side);
797 project(m_idx, 3, y, x, damage, typ, flg, -1);
802 if (m_ptr->mflag2 & MFLAG2_CHAMELEON)
804 choose_new_monster(m_idx, TRUE, MON_CHAMELEON);
805 r_ptr = &r_info[m_ptr->r_idx];
808 /* Check for quest completion */
809 check_quest_completion(m_ptr);
811 /* Handle the possibility of player vanquishing arena combatant -KMW- */
812 if (p_ptr->inside_arena && !is_pet(m_ptr))
814 p_ptr->exit_bldg = TRUE;
816 if (p_ptr->arena_number > MAX_ARENA_MONS)
818 msg_print(_("素晴らしい!君こそ真の勝利者だ。", "You are a Genuine Champion!"));
822 msg_print(_("勝利!チャンピオンへの道を進んでいる。", "Victorious! You're on your way to becoming Champion."));
825 if (arena_info[p_ptr->arena_number].tval)
827 /* Get local object */
830 /* Prepare to make a prize */
831 object_prep(q_ptr, lookup_kind(arena_info[p_ptr->arena_number].tval, arena_info[p_ptr->arena_number].sval));
833 apply_magic(q_ptr, object_level, AM_NO_FIXED_ART);
835 /* Drop it in the dungeon */
836 (void)drop_near(q_ptr, -1, y, x);
839 if (p_ptr->arena_number > MAX_ARENA_MONS) p_ptr->arena_number++;
840 p_ptr->arena_number++;
845 /* Extract monster name */
846 monster_desc(m_name, m_ptr, MD_IGNORE_HALLU | MD_ASSUME_VISIBLE | MD_INDEF_VISIBLE);
848 do_cmd_write_nikki(NIKKI_ARENA, p_ptr->arena_number, m_name);
852 if (m_idx == p_ptr->riding)
854 if (rakuba(-1, FALSE))
856 msg_print(_("地面に落とされた。", "You have fallen from your riding pet."));
860 /* Drop a dead corpse? */
861 if (one_in_(r_ptr->flags1 & RF1_UNIQUE ? 1 : 4) &&
862 (r_ptr->flags9 & (RF9_DROP_CORPSE | RF9_DROP_SKELETON)) &&
863 !(p_ptr->inside_arena || p_ptr->inside_battle || cloned || ((m_ptr->r_idx == today_mon) && is_pet(m_ptr))))
865 /* Assume skeleton */
869 * We cannot drop a skeleton? Note, if we are in this check,
870 * we *know* we can drop at least a corpse or a skeleton
872 if (!(r_ptr->flags9 & RF9_DROP_SKELETON))
874 else if ((r_ptr->flags9 & RF9_DROP_CORPSE) && (r_ptr->flags1 & RF1_UNIQUE))
877 /* Else, a corpse is more likely unless we did a "lot" of damage */
878 else if (r_ptr->flags9 & RF9_DROP_CORPSE)
880 /* Lots of damage in one blow */
881 if ((0 - ((m_ptr->maxhp) / 4)) > m_ptr->hp)
883 if (one_in_(5)) corpse = TRUE;
887 if (!one_in_(5)) corpse = TRUE;
891 /* Get local object */
894 /* Prepare to make an object */
895 object_prep(q_ptr, lookup_kind(TV_CORPSE, (corpse ? SV_CORPSE : SV_SKELETON)));
897 apply_magic(q_ptr, object_level, AM_NO_FIXED_ART);
899 q_ptr->pval = m_ptr->r_idx;
901 /* Drop it in the dungeon */
902 (void)drop_near(q_ptr, -1, y, x);
905 /* Drop objects being carried */
906 monster_drop_carried_objects(m_ptr);
908 if (r_ptr->flags1 & RF1_DROP_GOOD) mo_mode |= AM_GOOD;
909 if (r_ptr->flags1 & RF1_DROP_GREAT) mo_mode |= AM_GREAT;
911 switch (m_ptr->r_idx)
913 case MON_PINK_HORROR:
914 /* Pink horrors are replaced with 2 Blue horrors */
915 if (!(p_ptr->inside_arena || p_ptr->inside_battle))
919 for (i = 0; i < 2; i++)
922 bool pet = is_pet(m_ptr);
925 if (pet) mode |= PM_FORCE_PET;
927 if (summon_specific((pet ? -1 : m_idx), wy, wx, 100, SUMMON_BLUE_HORROR, mode))
929 if (player_can_see_bold(wy, wx))
935 msg_print(_("ピンク・ホラーは分裂した!", "The Pink horror divides!"));
939 case MON_BLOODLETTER:
940 /* Bloodletters of Khorne may drop a blade of chaos */
941 if (drop_chosen_item && (randint1(100) < 15))
943 /* Get local object */
946 /* Prepare to make a Blade of Chaos */
947 object_prep(q_ptr, lookup_kind(TV_SWORD, SV_BLADE_OF_CHAOS));
949 apply_magic(q_ptr, object_level, AM_NO_FIXED_ART | mo_mode);
951 /* Drop it in the dungeon */
952 (void)drop_near(q_ptr, -1, y, x);
957 if (drop_chosen_item && (dun_level > 9))
959 /* Get local object */
962 /* Wipe the object */
965 /* Activate restriction */
966 if ((dun_level > 49) && one_in_(5))
967 get_obj_num_hook = kind_is_good_book;
969 get_obj_num_hook = kind_is_book;
972 make_object(q_ptr, mo_mode);
974 /* Drop it in the dungeon */
975 (void)drop_near(q_ptr, -1, y, x);
981 * Mega^3-hack: killing a 'Warrior of the Dawn' is likely to
982 * spawn another in the fallen one's place!
984 if (!p_ptr->inside_arena && !p_ptr->inside_battle)
988 POSITION wy = y, wx = x;
990 bool pet = is_pet(m_ptr);
994 scatter(&wy, &wx, y, x, 20, 0);
996 while (!(in_bounds(wy, wx) && cave_empty_bold2(wy, wx)) && --attempts);
1000 BIT_FLAGS mode = 0L;
1001 if (pet) mode |= PM_FORCE_PET;
1003 if (summon_specific((pet ? -1 : m_idx), wy, wx, 100, SUMMON_DAWN, mode))
1005 if (player_can_see_bold(wy, wx))
1006 msg_print(_("新たな戦士が現れた!", "A new warrior steps forth!"));
1014 /* One more ultra-hack: An Unmaker goes out with a big bang! */
1016 BIT_FLAGS flg = PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL;
1017 (void)project(m_idx, 6, y, x, 100, GF_CHAOS, flg, -1);
1021 case MON_UNICORN_ORD:
1024 /* Reward for "lazy" player */
1025 if (p_ptr->pseikaku == SEIKAKU_NAMAKE)
1027 ARTIFACT_IDX a_idx = 0;
1028 artifact_type *a_ptr = NULL;
1030 if (!drop_chosen_item) break;
1034 switch (randint0(3))
1037 a_idx = ART_NAMAKE_HAMMER;
1040 a_idx = ART_NAMAKE_BOW;
1043 a_idx = ART_NAMAKE_ARMOR;
1047 a_ptr = &a_info[a_idx];
1049 while (a_ptr->cur_num);
1051 /* Create the artifact */
1052 if (create_named_art(a_idx, y, x))
1056 /* Hack -- Memorize location of artifact in saved floors */
1057 if (character_dungeon) a_ptr->floor_id = p_ptr->floor_id;
1059 else if (!preserve_mode) a_ptr->cur_num = 1;
1064 if (!drop_chosen_item) break;
1066 /* Get local object */
1069 /* Mega-Hack -- Prepare to make "Grond" */
1070 object_prep(q_ptr, lookup_kind(TV_HAFTED, SV_GROND));
1072 /* Mega-Hack -- Mark this item as "Grond" */
1073 q_ptr->name1 = ART_GROND;
1075 /* Mega-Hack -- Actually create "Grond" */
1076 apply_magic(q_ptr, -1, AM_GOOD | AM_GREAT);
1078 /* Drop it in the dungeon */
1079 (void)drop_near(q_ptr, -1, y, x);
1081 /* Get local object */
1084 /* Mega-Hack -- Prepare to make "Chaos" */
1085 object_prep(q_ptr, lookup_kind(TV_CROWN, SV_CHAOS));
1087 /* Mega-Hack -- Mark this item as "Chaos" */
1088 q_ptr->name1 = ART_CHAOS;
1090 /* Mega-Hack -- Actually create "Chaos" */
1091 apply_magic(q_ptr, -1, AM_GOOD | AM_GREAT);
1093 /* Drop it in the dungeon */
1094 (void)drop_near(q_ptr, -1, y, x);
1097 case MON_B_DEATH_SWORD:
1098 if (drop_chosen_item)
1100 /* Get local object */
1103 /* Prepare to make a broken sword */
1104 object_prep(q_ptr, lookup_kind(TV_SWORD, randint1(2)));
1106 /* Drop it in the dungeon */
1107 (void)drop_near(q_ptr, -1, y, x);
1113 if (drop_chosen_item && ((m_ptr->r_idx == MON_A_GOLD) ||
1114 ((m_ptr->r_idx == MON_A_SILVER) && (r_ptr->r_akills % 5 == 0))))
1116 /* Get local object */
1119 /* Prepare to make a Can of Toys */
1120 object_prep(q_ptr, lookup_kind(TV_CHEST, SV_CHEST_KANDUME));
1122 apply_magic(q_ptr, object_level, AM_NO_FIXED_ART);
1124 /* Drop it in the dungeon */
1125 (void)drop_near(q_ptr, -1, y, x);
1131 BIT_FLAGS flg = PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL;
1132 (void)project(m_idx, 3, y, x, damroll(20, 10), GF_FIRE, flg, -1);
1137 if (!drop_chosen_item) break;
1139 switch (r_ptr->d_char)
1144 /* Get local object */
1147 /* Wipe the object */
1150 /* Activate restriction */
1151 get_obj_num_hook = kind_is_cloak;
1154 make_object(q_ptr, mo_mode);
1156 /* Drop it in the dungeon */
1157 (void)drop_near(q_ptr, -1, y, x);
1164 /* Get local object */
1167 /* Wipe the object */
1170 /* Activate restriction */
1171 get_obj_num_hook = kind_is_polearm;
1173 /* Make a poleweapon */
1174 make_object(q_ptr, mo_mode);
1176 /* Drop it in the dungeon */
1177 (void)drop_near(q_ptr, -1, y, x);
1184 /* Get local object */
1187 /* Wipe the object */
1190 /* Activate restriction */
1191 get_obj_num_hook = kind_is_armor;
1193 /* Make a hard armor */
1194 make_object(q_ptr, mo_mode);
1196 /* Drop it in the dungeon */
1197 (void)drop_near(q_ptr, -1, y, x);
1204 /* Get local object */
1207 /* Wipe the object */
1210 /* Activate restriction */
1211 get_obj_num_hook = kind_is_hafted;
1213 /* Make a hafted weapon */
1214 make_object(q_ptr, mo_mode);
1216 /* Drop it in the dungeon */
1217 (void)drop_near(q_ptr, -1, y, x);
1222 if (m_ptr->r_idx != MON_STORMBRINGER)
1224 /* Get local object */
1227 /* Wipe the object */
1230 /* Activate restriction */
1231 get_obj_num_hook = kind_is_sword;
1234 make_object(q_ptr, mo_mode);
1236 /* Drop it in the dungeon */
1237 (void)drop_near(q_ptr, -1, y, x);
1244 /* Mega-Hack -- drop fixed items */
1245 if (drop_chosen_item)
1247 ARTIFACT_IDX a_idx = 0;
1250 for(i = 0; i < 4; i++)
1252 if(!r_ptr->artifact_id[i]) break;
1253 a_idx = r_ptr->artifact_id[i];
1254 chance = r_ptr->artifact_percent[i];
1257 if ((a_idx > 0) && ((randint0(100) < chance) || p_ptr->wizard))
1259 artifact_type *a_ptr = &a_info[a_idx];
1261 if (!a_ptr->cur_num)
1263 /* Create the artifact */
1264 if (create_named_art(a_idx, y, x))
1268 /* Hack -- Memorize location of artifact in saved floors */
1269 if (character_dungeon) a_ptr->floor_id = p_ptr->floor_id;
1271 else if (!preserve_mode) a_ptr->cur_num = 1;
1275 if ((r_ptr->flags7 & RF7_GUARDIAN) && (d_info[dungeon_type].final_guardian == m_ptr->r_idx))
1277 IDX k_idx = d_info[dungeon_type].final_object ? d_info[dungeon_type].final_object
1278 : lookup_kind(TV_SCROLL, SV_SCROLL_ACQUIREMENT);
1280 if (d_info[dungeon_type].final_artifact)
1282 a_idx = d_info[dungeon_type].final_artifact;
1283 artifact_type *a_ptr = &a_info[a_idx];
1285 if (!a_ptr->cur_num)
1287 /* Create the artifact */
1288 if (create_named_art(a_idx, y, x))
1292 /* Hack -- Memorize location of artifact in saved floors */
1293 if (character_dungeon) a_ptr->floor_id = p_ptr->floor_id;
1295 else if (!preserve_mode) a_ptr->cur_num = 1;
1297 /* Prevent rewarding both artifact and "default" object */
1298 if (!d_info[dungeon_type].final_object) k_idx = 0;
1304 /* Get local object */
1307 /* Prepare to make a reward */
1308 object_prep(q_ptr, k_idx);
1310 apply_magic(q_ptr, object_level, AM_NO_FIXED_ART | AM_GOOD);
1312 /* Drop it in the dungeon */
1313 (void)drop_near(q_ptr, -1, y, x);
1315 msg_format(_("あなたは%sを制覇した!", "You have conquered %s!"),d_name+d_info[dungeon_type].name);
1319 /* Determine how much we can drop */
1320 if ((r_ptr->flags1 & RF1_DROP_60) && (randint0(100) < 60)) number++;
1321 if ((r_ptr->flags1 & RF1_DROP_90) && (randint0(100) < 90)) number++;
1322 if (r_ptr->flags1 & RF1_DROP_1D2) number += damroll(1, 2);
1323 if (r_ptr->flags1 & RF1_DROP_2D2) number += damroll(2, 2);
1324 if (r_ptr->flags1 & RF1_DROP_3D2) number += damroll(3, 2);
1325 if (r_ptr->flags1 & RF1_DROP_4D2) number += damroll(4, 2);
1327 if (cloned && !(r_ptr->flags1 & RF1_UNIQUE))
1328 number = 0; /* Clones drop no stuff unless Cloning Pits */
1330 if (is_pet(m_ptr) || p_ptr->inside_battle || p_ptr->inside_arena)
1331 number = 0; /* Pets drop no stuff */
1332 if (!drop_item && (r_ptr->d_char != '$')) number = 0;
1334 if((r_ptr->flags2 & (RF2_MULTIPLY)) && (r_ptr->r_akills > 1024))
1335 number = 0; /* Limit of Multiply monster drop */
1337 /* Hack -- handle creeping coins */
1338 coin_type = force_coin;
1340 /* Average dungeon and monster levels */
1341 object_level = (dun_level + r_ptr->level) / 2;
1343 /* Drop some objects */
1344 for (j = 0; j < number; j++)
1346 /* Get local object */
1349 /* Wipe the object */
1353 if (do_gold && (!do_item || (randint0(100) < 50)))
1355 /* Make some gold */
1356 if (!make_gold(q_ptr)) continue;
1365 /* Make an object */
1366 if (!make_object(q_ptr, mo_mode)) continue;
1372 /* Drop it in the dungeon */
1373 (void)drop_near(q_ptr, -1, y, x);
1376 /* Reset the object level */
1377 object_level = base_level;
1379 /* Reset "coin" type */
1383 /* Take note of any dropped treasure */
1384 if (visible && (dump_item || dump_gold))
1386 /* Take notes on treasure */
1387 lore_treasure(m_idx, dump_item, dump_gold);
1390 /* Only process "Quest Monsters" */
1391 if (!(r_ptr->flags1 & RF1_QUESTOR)) return;
1392 if (p_ptr->inside_battle) return;
1395 if ((m_ptr->r_idx == MON_SERPENT) && !cloned)
1398 p_ptr->total_winner = TRUE;
1400 /* Redraw the "title" */
1401 p_ptr->redraw |= (PR_TITLE);
1403 play_music(TERM_XTRA_MUSIC_BASIC, MUSIC_BASIC_FINAL_QUEST_CLEAR);
1405 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, _("見事に変愚蛮怒の勝利者となった!", "become *WINNER* of Hengband finely!"));
1407 if ((p_ptr->pclass == CLASS_CHAOS_WARRIOR) || (p_ptr->muta2 & MUT2_CHAOS_GIFT))
1409 msg_format(_("%sからの声が響いた。", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
1410 msg_print(_("『よくやった、定命の者よ!』", "'Thou art donst well, mortal!'"));
1413 /* Congratulations */
1414 msg_print(_("*** おめでとう ***", "*** CONGRATULATIONS ***"));
1415 msg_print(_("あなたはゲームをコンプリートしました。", "You have won the game!"));
1416 msg_print(_("準備が整ったら引退(自殺コマンド)しても結構です。", "You may retire (commit suicide) when you are ready."));
1421 * @brief モンスターに与えたダメージの修正処理 /
1422 * Modify the physical damage done to the monster.
1423 * @param m_ptr ダメージを受けるモンスターの構造体参照ポインタ
1424 * @param dam ダメージ基本値
1425 * @param is_psy_spear 攻撃手段が光の剣ならばTRUE
1426 * @return 修正を行った結果のダメージ量
1429 * (for example when it's invulnerable or shielded)
1430 * ToDo: Accept a damage-type to calculate the modified damage from
1431 * things like fire, frost, lightning, poison, ... attacks.
1432 * "type" is not yet used and should be 0.
1435 HIT_POINT mon_damage_mod(monster_type *m_ptr, HIT_POINT dam, bool is_psy_spear)
1437 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1439 if ((r_ptr->flagsr & RFR_RES_ALL) && dam > 0)
1442 if ((dam == 0) && one_in_(3)) dam = 1;
1445 if (MON_INVULNER(m_ptr))
1449 if (!p_ptr->blind && is_seen(m_ptr))
1451 msg_print(_("バリアを切り裂いた!", "The barrier is penetrated!"));
1454 else if (!one_in_(PENETRATE_INVULNERABILITY))
1464 * @brief モンスターに与えたダメージを元に経験値を加算する /
1465 * Calculate experience point to be get
1466 * @param dam 与えたダメージ量
1467 * @param m_ptr ダメージを与えたモンスターの構造体参照ポインタ
1471 * Even the 64 bit operation is not big enough to avoid overflaw
1472 * unless we carefully choose orders of multiplication and division.
1473 * Get the coefficient first, and multiply (potentially huge) base
1474 * experience point of a monster later.
1477 static void get_exp_from_mon(HIT_POINT dam, monster_type *m_ptr)
1479 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1486 if (!m_ptr->r_idx) return;
1487 if (is_pet(m_ptr) || p_ptr->inside_battle) return;
1490 * - Ratio of monster's level to player's level effects
1491 * - Varying speed effects
1492 * - Get a fraction in proportion of damage point
1494 new_exp = r_ptr->level * SPEED_TO_ENERGY(m_ptr->mspeed) * dam;
1497 div_l = (p_ptr->max_plv+2) * SPEED_TO_ENERGY(r_ptr->speed);
1499 /* Use (average maxhp * 2) as a denominator */
1500 if (!(r_ptr->flags1 & RF1_FORCE_MAXHP))
1501 s64b_mul(&div_h, &div_l, 0, r_ptr->hdice * (ironman_nightmare ? 2 : 1) * (r_ptr->hside + 1));
1503 s64b_mul(&div_h, &div_l, 0, r_ptr->hdice * (ironman_nightmare ? 2 : 1) * r_ptr->hside * 2);
1505 /* Special penalty in the wilderness */
1506 if (!dun_level && (!(r_ptr->flags8 & RF8_WILD_ONLY) || !(r_ptr->flags1 & RF1_UNIQUE)))
1507 s64b_mul(&div_h, &div_l, 0, 5);
1509 /* Do division first to prevent overflaw */
1510 s64b_div(&new_exp, &new_exp_frac, div_h, div_l);
1512 /* Special penalty for mutiply-monster */
1513 if ((r_ptr->flags2 & RF2_MULTIPLY) || (m_ptr->r_idx == MON_DAWN))
1515 int monnum_penarty = r_ptr->r_akills / 400;
1516 if (monnum_penarty > 8) monnum_penarty = 8;
1518 while (monnum_penarty--)
1521 s64b_RSHIFT(new_exp, new_exp_frac, 2);
1525 /* Special penalty for rest_and_shoot exp scum */
1526 if ((m_ptr->dealt_damage > (u32b)m_ptr->max_maxhp) && (m_ptr->hp >= 0))
1528 int over_damage = m_ptr->dealt_damage / m_ptr->max_maxhp;
1529 if (over_damage > 32) over_damage = 32;
1531 while (over_damage--)
1534 s64b_mul(&new_exp, &new_exp_frac, 0, 9);
1535 s64b_div(&new_exp, &new_exp_frac, 0, 10);
1539 /* Finally multiply base experience point of the monster */
1540 s64b_mul(&new_exp, &new_exp_frac, 0, r_ptr->mexp);
1542 /* Gain experience */
1543 gain_exp_64(new_exp, new_exp_frac);
1548 * @brief モンスターのHPをダメージに応じて減算する /
1549 * Decreases monsters hit points, handling monster death.
1550 * @param dam 与えたダメージ量
1551 * @param m_idx ダメージを与えたモンスターのID
1552 * @param fear ダメージによってモンスターが恐慌状態に陥ったならばTRUEを返す
1553 * @param note モンスターが倒された際の特別なメッセージ述語
1557 * We return TRUE if the monster has been killed (and deleted).
1558 * We announce monster death (using an optional "death message"
1559 * if given, and a otherwise a generic killed/destroyed message).
1560 * Only "physical attacks" can induce the "You have slain" message.
1561 * Missile and Spell attacks will induce the "dies" message, or
1562 * various "specialized" messages. Note that "You have destroyed"
1563 * and "is destroyed" are synonyms for "You have slain" and "dies".
1564 * Hack -- unseen monsters yield "You have killed it." message.
1565 * Added fear (DGK) and check whether to print fear messages -CWS
1566 * Made name, sex, and capitalization generic -BEN-
1567 * As always, the "ghost" processing is a total hack.
1568 * Hack -- we "delay" fear messages by passing around a "fear" flag.
1569 * XXX XXX XXX Consider decreasing monster experience over time, say,
1570 * by using "(m_exp * m_lev * (m_lev)) / (p_lev * (m_lev + n_killed))"
1571 * instead of simply "(m_exp * m_lev) / (p_lev)", to make the first
1572 * monster worth more than subsequent monsters. This would also need
1573 * to induce changes in the monster recall code.
1576 bool mon_take_hit(MONSTER_IDX m_idx, HIT_POINT dam, bool *fear, cptr note)
1578 monster_type *m_ptr = &m_list[m_idx];
1579 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1581 monster_type exp_mon;
1583 /* Innocent until proven otherwise */
1584 bool innocent = TRUE, thief = FALSE;
1588 (void)COPY(&exp_mon, m_ptr, monster_type);
1590 expdam = (m_ptr->hp > dam) ? dam : m_ptr->hp;
1592 get_exp_from_mon(expdam, &exp_mon);
1594 /* Genocided by chaos patron */
1595 if (!m_ptr->r_idx) m_idx = 0;
1597 /* Redraw (later) if needed */
1598 if (p_ptr->health_who == m_idx) p_ptr->redraw |= (PR_HEALTH);
1599 if (p_ptr->riding == m_idx) p_ptr->redraw |= (PR_UHEALTH);
1602 (void)set_monster_csleep(m_idx, 0);
1604 /* Hack - Cancel any special player stealth magics. -LM- */
1605 if (p_ptr->special_defense & NINJA_S_STEALTH)
1607 set_superstealth(FALSE);
1610 /* Genocided by chaos patron */
1611 if (!m_idx) return TRUE;
1616 m_ptr->dealt_damage += dam;
1617 if(m_ptr->dealt_damage > (u32b)m_ptr->max_maxhp * 100) m_ptr->dealt_damage = m_ptr->max_maxhp * 100;
1620 msg_format( _("合計%d/%dのダメージを与えた。","You do %d (out of %d) damage."),
1621 m_ptr->dealt_damage, m_ptr->maxhp);
1624 /* It is dead now */
1629 if (r_info[m_ptr->r_idx].flags7 & RF7_TANUKI)
1631 /* You might have unmasked Tanuki first time */
1632 r_ptr = &r_info[m_ptr->r_idx];
1633 m_ptr->ap_r_idx = m_ptr->r_idx;
1634 if (r_ptr->r_sights < MAX_SHORT) r_ptr->r_sights++;
1637 if (m_ptr->mflag2 & MFLAG2_CHAMELEON)
1639 /* You might have unmasked Chameleon first time */
1640 r_ptr = real_r_ptr(m_ptr);
1641 if (r_ptr->r_sights < MAX_SHORT) r_ptr->r_sights++;
1644 if (!(m_ptr->smart & SM_CLONED))
1646 /* When the player kills a Unique, it stays dead */
1647 if (r_ptr->flags1 & RF1_UNIQUE)
1651 /* Mega-Hack -- Banor & Lupart */
1652 if ((m_ptr->r_idx == MON_BANOR) || (m_ptr->r_idx == MON_LUPART))
1654 r_info[MON_BANORLUPART].max_num = 0;
1655 r_info[MON_BANORLUPART].r_pkills++;
1656 r_info[MON_BANORLUPART].r_akills++;
1657 if (r_info[MON_BANORLUPART].r_tkills < MAX_SHORT) r_info[MON_BANORLUPART].r_tkills++;
1659 else if (m_ptr->r_idx == MON_BANORLUPART)
1661 r_info[MON_BANOR].max_num = 0;
1662 r_info[MON_BANOR].r_pkills++;
1663 r_info[MON_BANOR].r_akills++;
1664 if (r_info[MON_BANOR].r_tkills < MAX_SHORT) r_info[MON_BANOR].r_tkills++;
1665 r_info[MON_LUPART].max_num = 0;
1666 r_info[MON_LUPART].r_pkills++;
1667 r_info[MON_LUPART].r_akills++;
1668 if (r_info[MON_LUPART].r_tkills < MAX_SHORT) r_info[MON_LUPART].r_tkills++;
1672 /* When the player kills a Nazgul, it stays dead */
1673 else if (r_ptr->flags7 & RF7_NAZGUL) r_ptr->max_num--;
1676 /* Count all monsters killed */
1677 if (r_ptr->r_akills < MAX_SHORT) r_ptr->r_akills++;
1679 /* Recall even invisible uniques or winners */
1680 if ((m_ptr->ml && !p_ptr->image) || (r_ptr->flags1 & RF1_UNIQUE))
1682 /* Count kills this life */
1683 if ((m_ptr->mflag2 & MFLAG2_KAGE) && (r_info[MON_KAGE].r_pkills < MAX_SHORT)) r_info[MON_KAGE].r_pkills++;
1684 else if (r_ptr->r_pkills < MAX_SHORT) r_ptr->r_pkills++;
1686 /* Count kills in all lives */
1687 if ((m_ptr->mflag2 & MFLAG2_KAGE) && (r_info[MON_KAGE].r_tkills < MAX_SHORT)) r_info[MON_KAGE].r_tkills++;
1688 else if (r_ptr->r_tkills < MAX_SHORT) r_ptr->r_tkills++;
1690 /* Hack -- Auto-recall */
1691 monster_race_track(m_ptr->ap_r_idx);
1694 /* Extract monster name */
1695 monster_desc(m_name, m_ptr, MD_TRUE_NAME);
1697 /* Don't kill Amberites */
1698 if ((r_ptr->flags3 & RF3_AMBERITE) && one_in_(2))
1700 int curses = 1 + randint1(3);
1701 bool stop_ty = FALSE;
1704 msg_format(_("%^sは恐ろしい血の呪いをあなたにかけた!", "%^s puts a terrible blood curse on you!"), m_name);
1705 curse_equipment(100, 50);
1709 stop_ty = activate_ty_curse(stop_ty, &count);
1714 if (r_ptr->flags2 & RF2_CAN_SPEAK)
1716 char line_got[1024];
1718 /* Dump a message */
1719 if (!get_rnd_line(_("mondeath_j.txt", "mondeath.txt"), m_ptr->r_idx, line_got))
1721 msg_format("%^s %s", m_name, line_got);
1724 if (m_ptr->r_idx == MON_SERPENT)
1726 /* Make screen dump */
1727 screen_dump = make_screen_dump();
1732 if (!(d_info[dungeon_type].flags1 & DF1_BEGINNER))
1734 if (!dun_level && !ambush_flag && !p_ptr->inside_arena)
1736 chg_virtue(V_VALOUR, -1);
1738 else if (r_ptr->level > dun_level)
1740 if (randint1(10) <= (r_ptr->level - dun_level))
1741 chg_virtue(V_VALOUR, 1);
1743 if (r_ptr->level > 60)
1745 chg_virtue(V_VALOUR, 1);
1747 if (r_ptr->level >= 2 * (p_ptr->lev+1))
1748 chg_virtue(V_VALOUR, 2);
1751 if (r_ptr->flags1 & RF1_UNIQUE)
1753 if (r_ptr->flags3 & (RF3_EVIL | RF3_GOOD)) chg_virtue(V_HARMONY, 2);
1755 if (r_ptr->flags3 & RF3_GOOD)
1757 chg_virtue(V_UNLIFE, 2);
1758 chg_virtue(V_VITALITY, -2);
1761 if (one_in_(3)) chg_virtue(V_INDIVIDUALISM, -1);
1764 if (m_ptr->r_idx == MON_BEGGAR || m_ptr->r_idx == MON_LEPER)
1766 chg_virtue(V_COMPASSION, -1);
1769 if ((r_ptr->flags3 & RF3_GOOD) &&
1770 ((r_ptr->level) / 10 + (3 * dun_level) >= randint1(100)))
1771 chg_virtue(V_UNLIFE, 1);
1773 if (r_ptr->d_char == 'A')
1775 if (r_ptr->flags1 & RF1_UNIQUE)
1776 chg_virtue(V_FAITH, -2);
1777 else if ((r_ptr->level) / 10 + (3 * dun_level) >= randint1(100))
1779 if (r_ptr->flags3 & RF3_GOOD) chg_virtue(V_FAITH, -1);
1780 else chg_virtue(V_FAITH, 1);
1783 else if (r_ptr->flags3 & RF3_DEMON)
1785 if (r_ptr->flags1 & RF1_UNIQUE)
1786 chg_virtue(V_FAITH, 2);
1787 else if ((r_ptr->level) / 10 + (3 * dun_level) >= randint1(100))
1788 chg_virtue(V_FAITH, 1);
1791 if ((r_ptr->flags3 & RF3_UNDEAD) && (r_ptr->flags1 & RF1_UNIQUE))
1792 chg_virtue(V_VITALITY, 2);
1794 if (r_ptr->r_deaths)
1796 if (r_ptr->flags1 & RF1_UNIQUE)
1798 chg_virtue(V_HONOUR, 10);
1800 else if ((r_ptr->level) / 10 + (2 * dun_level) >= randint1(100))
1802 chg_virtue(V_HONOUR, 1);
1805 if ((r_ptr->flags2 & RF2_MULTIPLY) && (r_ptr->r_akills > 1000) && one_in_(10))
1807 chg_virtue(V_VALOUR, -1);
1810 for (i = 0; i < 4; i++)
1812 if (r_ptr->blow[i].d_dice != 0) innocent = FALSE; /* Murderer! */
1814 if ((r_ptr->blow[i].effect == RBE_EAT_ITEM)
1815 || (r_ptr->blow[i].effect == RBE_EAT_GOLD))
1817 thief = TRUE; /* Thief! */
1820 /* The new law says it is illegal to live in the dungeon */
1821 if (r_ptr->level != 0) innocent = FALSE;
1825 if (r_ptr->flags1 & RF1_UNIQUE)
1826 chg_virtue(V_JUSTICE, 3);
1827 else if (1+((r_ptr->level) / 10 + (2 * dun_level))
1829 chg_virtue(V_JUSTICE, 1);
1833 chg_virtue (V_JUSTICE, -1);
1836 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)))
1838 if (one_in_(4)) chg_virtue(V_NATURE, -1);
1841 if ((r_ptr->flags1 & RF1_UNIQUE) && record_destroy_uniq)
1845 sprintf(note_buf, "%s%s", r_name + r_ptr->name, (m_ptr->smart & SM_CLONED) ? "(クローン)" : "");
1847 sprintf(note_buf, "%s%s", r_name + r_ptr->name, (m_ptr->smart & SM_CLONED) ? "(Clone)" : "");
1849 do_cmd_write_nikki(NIKKI_UNIQUE, 0, note_buf);
1855 /* Death by Missile/Spell attack */
1858 msg_format("%^s%s", m_name, note);
1861 /* Death by physical attack -- invisible monster */
1862 else if (!m_ptr->ml)
1865 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
1866 msg_format("せっかくだから%sを殺した。", m_name);
1868 msg_format("%sを殺した。", m_name);
1870 msg_format("You have killed %s.", m_name);
1875 /* Death by Physical attack -- non-living monster */
1876 else if (!monster_living(r_ptr))
1878 bool explode = FALSE;
1880 for (i = 0; i < 4; i++)
1882 if (r_ptr->blow[i].method == RBM_EXPLODE) explode = TRUE;
1885 /* Special note at death */
1887 msg_format(_("%sは爆発して粉々になった。", "%^s explodes into tiny shreds."), m_name);
1891 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
1892 msg_format("せっかくだから%sを倒した。", m_name);
1894 msg_format("%sを倒した。", m_name);
1896 msg_format("You have destroyed %s.", m_name);
1901 /* Death by Physical attack -- living monster */
1905 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
1906 msg_format("せっかくだから%sを葬り去った。", m_name);
1908 msg_format("%sを葬り去った。", m_name);
1910 msg_format("You have slain %s.", m_name);
1914 if ((r_ptr->flags1 & RF1_UNIQUE) && !(m_ptr->smart & SM_CLONED) && !vanilla_town)
1916 for (i = 0; i < MAX_KUBI; i++)
1918 if ((kubi_r_idx[i] == m_ptr->r_idx) && !(m_ptr->mflag2 & MFLAG2_CHAMELEON))
1920 msg_format(_("%sの首には賞金がかかっている。", "There is a price on %s's head."), m_name);
1926 /* Generate treasure */
1927 monster_death(m_idx, TRUE);
1929 /* Mega hack : replace IKETA to BIKETAL */
1930 if ((m_ptr->r_idx == MON_IKETA) &&
1931 !(p_ptr->inside_arena || p_ptr->inside_battle))
1933 int dummy_y = m_ptr->fy;
1934 int dummy_x = m_ptr->fx;
1935 BIT_FLAGS mode = 0L;
1937 if (is_pet(m_ptr)) mode |= PM_FORCE_PET;
1939 /* Delete the monster */
1940 delete_monster_idx(m_idx);
1942 if (summon_named_creature(0, dummy_y, dummy_x, MON_BIKETAL, mode))
1944 msg_print(_("「ハァッハッハッハ!!私がバイケタルだ!!」", "Uwa-hahaha! *I* am Biketal!"));
1949 /* Delete the monster */
1950 delete_monster_idx(m_idx);
1953 get_exp_from_mon((long)exp_mon.max_maxhp*2, &exp_mon);
1958 /* Monster is dead */
1965 /* Mega-Hack -- Pain cancels fear */
1966 if (MON_MONFEAR(m_ptr) && (dam > 0))
1969 if (set_monster_monfear(m_idx, MON_MONFEAR(m_ptr) - randint1(dam)))
1976 /* Sometimes a monster gets scared by damage */
1977 if (!MON_MONFEAR(m_ptr) && !(r_ptr->flags3 & (RF3_NO_FEAR)))
1979 /* Percentage of fully healthy */
1980 int percentage = (100L * m_ptr->hp) / m_ptr->maxhp;
1983 * Run (sometimes) if at 10% or less of max hit points,
1984 * or (usually) when hit for half its current hit points
1986 if ((randint1(10) >= percentage) ||
1987 ((dam >= m_ptr->hp) && (randint0(100) < 80)))
1989 /* Hack -- note fear */
1992 /* XXX XXX XXX Hack -- Add some timed fear */
1993 (void)set_monster_monfear(m_idx, (randint1(10) +
1994 (((dam >= m_ptr->hp) && (percentage > 7)) ?
1995 20 : ((11 - percentage) * 5))));
2002 if (p_ptr->riding && (p_ptr->riding == m_idx) && (dam > 0))
2006 /* Extract monster name */
2007 monster_desc(m_name, m_ptr, 0);
2009 if (m_ptr->hp > m_ptr->maxhp/3) dam = (dam + 1) / 2;
2010 if (rakuba((dam > 200) ? 200 : dam, FALSE))
2012 msg_format(_("%^sに振り落とされた!", "%^s has thrown you off!"), m_name);
2023 * @brief 現在のコンソール表示の縦横を返す。 /
2024 * Get term size and calculate screen size
2025 * @param wid_p コンソールの表示幅文字数を返す
2026 * @param hgt_p コンソールの表示行数を返す
2029 void get_screen_size(int *wid_p, int *hgt_p)
2031 Term_get_size(wid_p, hgt_p);
2032 *hgt_p -= ROW_MAP + 2;
2033 *wid_p -= COL_MAP + 2;
2034 if (use_bigtile) *wid_p /= 2;
2039 * @brief コンソール上におけるマップ表示の左上位置を返す /
2040 * Calculates current boundaries Called below and from "do_cmd_locate()".
2043 void panel_bounds_center(void)
2048 get_screen_size(&wid, &hgt);
2050 panel_row_max = panel_row_min + hgt - 1;
2051 panel_row_prt = panel_row_min - 1;
2052 panel_col_max = panel_col_min + wid - 1;
2053 panel_col_prt = panel_col_min - 13;
2058 * @brief コンソールのリサイズに合わせてマップを再描画する /
2059 * Map resizing whenever the main term changes size
2062 void resize_map(void)
2064 /* Only if the dungeon exists */
2065 if (!character_dungeon) return;
2067 /* Mega-Hack -- no panel yet */
2071 /* Reset the panels */
2072 panel_row_min = cur_hgt;
2073 panel_col_min = cur_wid;
2078 p_ptr->update |= (PU_TORCH | PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
2080 /* Forget lite/view */
2081 p_ptr->update |= (PU_UN_VIEW | PU_UN_LITE);
2083 /* Update lite/view */
2084 p_ptr->update |= (PU_VIEW | PU_LITE | PU_MON_LITE);
2086 /* Update monsters */
2087 p_ptr->update |= (PU_MONSTERS);
2089 /* Redraw everything */
2090 p_ptr->redraw |= (PR_WIPE | PR_BASIC | PR_EXTRA | PR_MAP | PR_EQUIPPY);
2092 /* Hack -- update */
2100 * Place the cursor on the player
2102 if (can_save) move_cursor_relative(p_ptr->y, p_ptr->x);
2109 * @brief コンソールを再描画する /
2110 * Redraw a term when it is resized
2113 void redraw_window(void)
2115 /* Only if the dungeon exists */
2116 if (!character_dungeon) return;
2119 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_SPELL | PW_PLAYER);
2122 p_ptr->window |= (PW_MESSAGE | PW_OVERHEAD | PW_DUNGEON | PW_MONSTER | PW_OBJECT);
2124 /* Hack -- update */
2133 * @brief フォーカスを当てるべきマップ描画の基準座標を指定する(サブルーチン)
2134 * @param dy 変更先のフロアY座標
2135 * @param dx 変更先のフロアX座標
2136 * Handle a request to change the current panel
2137 * Return TRUE if the panel was changed.
2138 * Also used in do_cmd_locate
2139 * @return 実際に再描画が必要だった場合TRUEを返す
2141 bool change_panel(int dy, int dx)
2147 get_screen_size(&wid, &hgt);
2149 /* Apply the motion */
2150 y = panel_row_min + dy * hgt / 2;
2151 x = panel_col_min + dx * wid / 2;
2153 /* Verify the row */
2154 if (y > cur_hgt - hgt) y = cur_hgt - hgt;
2157 /* Verify the col */
2158 if (x > cur_wid - wid) x = cur_wid - wid;
2161 /* Handle "changes" */
2162 if ((y != panel_row_min) || (x != panel_col_min))
2164 /* Save the new panel info */
2168 /* Recalculate the boundaries */
2169 panel_bounds_center();
2172 p_ptr->update |= (PU_MONSTERS);
2175 p_ptr->redraw |= (PR_MAP);
2189 * @brief フォーカスを当てるべきマップ描画の基準座標を指定する
2190 * @param y 変更先のフロアY座標
2191 * @param x 変更先のフロアX座標
2193 * Handle a request to change the current panel
2194 * Return TRUE if the panel was changed.
2195 * Also used in do_cmd_locate
2196 * @return 実際に再描画が必要だった場合TRUEを返す
2198 bool change_panel_xy(int y, int x)
2204 get_screen_size(&wid, &hgt);
2206 if (y < panel_row_min) dy = -1;
2207 if (y > panel_row_max) dy = 1;
2208 if (x < panel_col_min) dx = -1;
2209 if (x > panel_col_max) dx = 1;
2211 if (!dy && !dx) return (FALSE);
2213 return change_panel(dy, dx);
2218 * @brief マップ描画のフォーカスを当てるべき座標を更新する
2220 * Given an row (y) and col (x), this routine detects when a move
2221 * off the screen has occurred and figures new borders. -RAK-
2222 * "Update" forces a "full update" to take place.
2223 * The map is reprinted if necessary, and "TRUE" is returned.
2224 * @return 実際に再描画が必要だった場合TRUEを返す
2226 void verify_panel(void)
2238 get_screen_size(&wid, &hgt);
2240 max_prow_min = cur_hgt - hgt;
2241 max_pcol_min = cur_wid - wid;
2243 /* Bounds checking */
2244 if (max_prow_min < 0) max_prow_min = 0;
2245 if (max_pcol_min < 0) max_pcol_min = 0;
2247 /* Center on player */
2248 if (center_player && (center_running || !running))
2250 /* Center vertically */
2251 prow_min = y - hgt / 2;
2252 if (prow_min < 0) prow_min = 0;
2253 else if (prow_min > max_prow_min) prow_min = max_prow_min;
2255 /* Center horizontally */
2256 pcol_min = x - wid / 2;
2257 if (pcol_min < 0) pcol_min = 0;
2258 else if (pcol_min > max_pcol_min) pcol_min = max_pcol_min;
2262 prow_min = panel_row_min;
2263 pcol_min = panel_col_min;
2265 /* Scroll screen when 2 grids from top/bottom edge */
2266 if (y > panel_row_max - 2)
2268 while (y > prow_min + hgt-1 - 2)
2270 prow_min += (hgt / 2);
2274 if (y < panel_row_min + 2)
2276 while (y < prow_min + 2)
2278 prow_min -= (hgt / 2);
2282 if (prow_min > max_prow_min) prow_min = max_prow_min;
2283 if (prow_min < 0) prow_min = 0;
2285 /* Scroll screen when 4 grids from left/right edge */
2286 if (x > panel_col_max - 4)
2288 while (x > pcol_min + wid-1 - 4)
2290 pcol_min += (wid / 2);
2294 if (x < panel_col_min + 4)
2296 while (x < pcol_min + 4)
2298 pcol_min -= (wid / 2);
2302 if (pcol_min > max_pcol_min) pcol_min = max_pcol_min;
2303 if (pcol_min < 0) pcol_min = 0;
2306 /* Check for "no change" */
2307 if ((prow_min == panel_row_min) && (pcol_min == panel_col_min)) return;
2309 /* Save the new panel info */
2310 panel_row_min = prow_min;
2311 panel_col_min = pcol_min;
2313 /* Hack -- optional disturb on "panel change" */
2314 if (disturb_panel && !center_player) disturb(0, 0);
2316 /* Recalculate the boundaries */
2317 panel_bounds_center();
2320 p_ptr->update |= (PU_MONSTERS);
2323 p_ptr->redraw |= (PR_MAP);
2326 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
2331 * Monster health description
2333 cptr look_mon_desc(monster_type *m_ptr, BIT_FLAGS mode)
2335 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
2342 /* Determine if the monster is "living" */
2343 living = monster_living(ap_r_ptr);
2345 /* Calculate a health "percentage" */
2346 perc = 100L * m_ptr->hp / m_ptr->maxhp;
2348 /* Healthy monsters */
2349 if (m_ptr->hp >= m_ptr->maxhp)
2353 desc = living ? "無傷" : "無ダメージ";
2355 desc = living ? "unhurt" : "undamaged";
2360 else if (perc >= 60)
2363 desc = living ? "軽傷" : "小ダメージ";
2365 desc = living ? "somewhat wounded" : "somewhat damaged";
2370 else if (perc >= 25)
2373 desc = living ? "負傷" : "中ダメージ";
2375 desc = living ? "wounded" : "damaged";
2380 else if (perc >= 10)
2383 desc = living ? "重傷" : "大ダメージ";
2385 desc = living ? "badly wounded" : "badly damaged";
2393 desc = living ? "半死半生" : "倒れかけ";
2395 desc = living ? "almost dead" : "almost destroyed";
2400 /* Need attitude information? */
2403 /* Full information is not needed */
2406 else if (is_pet(m_ptr))
2408 attitude = _(", ペット", ", pet");
2410 else if (is_friendly(m_ptr))
2412 attitude = _(", 友好的", ", friendly");
2416 attitude = _("", "");
2420 /* Clone monster? */
2421 if (m_ptr->smart & SM_CLONED)
2430 /* Display monster's level --- idea borrowed from ToME */
2431 if (ap_r_ptr->r_tkills && !(m_ptr->mflag2 & MFLAG2_KAGE))
2433 return format(_("レベル%d, %s%s%s", "Level %d, %s%s%s"), ap_r_ptr->level, desc, attitude, clone);
2437 return format(_("レベル???, %s%s%s", "Level ???, %s%s%s"), desc, attitude, clone);
2444 * Angband sorting algorithm -- quick sort in place
2446 * Note that the details of the data we are sorting is hidden,
2447 * and we rely on the "ang_sort_comp()" and "ang_sort_swap()"
2448 * function hooks to interact with the data, which is given as
2449 * two pointers, and which may have any user-defined form.
2451 void ang_sort_aux(vptr u, vptr v, int p, int q)
2469 while (!(*ang_sort_comp)(u, v, b, z)) b--;
2472 while (!(*ang_sort_comp)(u, v, z, a)) a++;
2474 /* Done partition */
2478 (*ang_sort_swap)(u, v, a, b);
2484 /* Recurse left side */
2485 ang_sort_aux(u, v, p, b);
2487 /* Recurse right side */
2488 ang_sort_aux(u, v, b+1, q);
2493 * Angband sorting algorithm -- quick sort in place
2495 * Note that the details of the data we are sorting is hidden,
2496 * and we rely on the "ang_sort_comp()" and "ang_sort_swap()"
2497 * function hooks to interact with the data, which is given as
2498 * two pointers, and which may have any user-defined form.
2500 void ang_sort(vptr u, vptr v, int n)
2502 /* Sort the array */
2503 ang_sort_aux(u, v, 0, n-1);
2508 /*** Targeting Code ***/
2512 * Determine is a monster makes a reasonable target
2514 * The concept of "targeting" was stolen from "Morgul" (?)
2516 * The player can target any location, or any "target-able" monster.
2518 * Currently, a monster is "target_able" if it is visible, and if
2519 * the player can hit it with a projection, and the player is not
2520 * hallucinating. This allows use of "use closest target" macros.
2522 * Future versions may restrict the ability to target "trappers"
2523 * and "mimics", but the semantics is a little bit weird.
2525 bool target_able(MONSTER_IDX m_idx)
2527 monster_type *m_ptr = &m_list[m_idx];
2529 /* Monster must be alive */
2530 if (!m_ptr->r_idx) return (FALSE);
2532 /* Hack -- no targeting hallucinations */
2533 if (p_ptr->image) return (FALSE);
2535 /* Monster must be visible */
2536 if (!m_ptr->ml) return (FALSE);
2538 if (p_ptr->riding && (p_ptr->riding == m_idx)) return (TRUE);
2540 /* Monster must be projectable */
2541 if (!projectable(p_ptr->y, p_ptr->x, m_ptr->fy, m_ptr->fx)) return (FALSE);
2543 /* XXX XXX XXX Hack -- Never target trappers */
2544 /* if (CLEAR_ATTR && (CLEAR_CHAR)) return (FALSE); */
2554 * Update (if necessary) and verify (if possible) the target.
2556 * We return TRUE if the target is "okay" and FALSE otherwise.
2558 bool target_okay(void)
2560 /* Accept stationary targets */
2561 if (target_who < 0) return (TRUE);
2563 /* Check moving targets */
2566 /* Accept reasonable targets */
2567 if (target_able(target_who))
2569 monster_type *m_ptr = &m_list[target_who];
2571 /* Acquire monster location */
2572 target_row = m_ptr->fy;
2573 target_col = m_ptr->fx;
2580 /* Assume no target */
2586 * Sorting hook -- comp function -- by "distance to player"
2588 * We use "u" and "v" to point to arrays of "x" and "y" positions,
2589 * and sort the arrays by double-distance to the player.
2591 static bool ang_sort_comp_distance(vptr u, vptr v, int a, int b)
2593 POSITION *x = (POSITION*)(u);
2594 POSITION *y = (POSITION*)(v);
2596 POSITION da, db, kx, ky;
2598 /* Absolute distance components */
2599 kx = x[a]; kx -= p_ptr->x; kx = ABS(kx);
2600 ky = y[a]; ky -= p_ptr->y; ky = ABS(ky);
2602 /* Approximate Double Distance to the first point */
2603 da = ((kx > ky) ? (kx + kx + ky) : (ky + ky + kx));
2605 /* Absolute distance components */
2606 kx = x[b]; kx -= p_ptr->x; kx = ABS(kx);
2607 ky = y[b]; ky -= p_ptr->y; ky = ABS(ky);
2609 /* Approximate Double Distance to the first point */
2610 db = ((kx > ky) ? (kx + kx + ky) : (ky + ky + kx));
2612 /* Compare the distances */
2618 * Sorting hook -- comp function -- by importance level of grids
2620 * We use "u" and "v" to point to arrays of "x" and "y" positions,
2621 * and sort the arrays by level of monster
2623 static bool ang_sort_comp_importance(vptr u, vptr v, int a, int b)
2625 POSITION *x = (POSITION*)(u);
2626 POSITION *y = (POSITION*)(v);
2627 cave_type *ca_ptr = &cave[y[a]][x[a]];
2628 cave_type *cb_ptr = &cave[y[b]][x[b]];
2629 monster_type *ma_ptr = &m_list[ca_ptr->m_idx];
2630 monster_type *mb_ptr = &m_list[cb_ptr->m_idx];
2631 monster_race *ap_ra_ptr, *ap_rb_ptr;
2633 /* The player grid */
2634 if (y[a] == p_ptr->y && x[a] == p_ptr->x) return TRUE;
2635 if (y[b] == p_ptr->y && x[b] == p_ptr->x) return FALSE;
2637 /* Extract monster race */
2638 if (ca_ptr->m_idx && ma_ptr->ml) ap_ra_ptr = &r_info[ma_ptr->ap_r_idx];
2639 else ap_ra_ptr = NULL;
2640 if (cb_ptr->m_idx && mb_ptr->ml) ap_rb_ptr = &r_info[mb_ptr->ap_r_idx];
2641 else ap_rb_ptr = NULL;
2643 if (ap_ra_ptr && !ap_rb_ptr) return TRUE;
2644 if (!ap_ra_ptr && ap_rb_ptr) return FALSE;
2646 /* Compare two monsters */
2647 if (ap_ra_ptr && ap_rb_ptr)
2649 /* Unique monsters first */
2650 if ((ap_ra_ptr->flags1 & RF1_UNIQUE) && !(ap_rb_ptr->flags1 & RF1_UNIQUE)) return TRUE;
2651 if (!(ap_ra_ptr->flags1 & RF1_UNIQUE) && (ap_rb_ptr->flags1 & RF1_UNIQUE)) return FALSE;
2653 /* Shadowers first (あやしい影) */
2654 if ((ma_ptr->mflag2 & MFLAG2_KAGE) && !(mb_ptr->mflag2 & MFLAG2_KAGE)) return TRUE;
2655 if (!(ma_ptr->mflag2 & MFLAG2_KAGE) && (mb_ptr->mflag2 & MFLAG2_KAGE)) return FALSE;
2657 /* Unknown monsters first */
2658 if (!ap_ra_ptr->r_tkills && ap_rb_ptr->r_tkills) return TRUE;
2659 if (ap_ra_ptr->r_tkills && !ap_rb_ptr->r_tkills) return FALSE;
2661 /* Higher level monsters first (if known) */
2662 if (ap_ra_ptr->r_tkills && ap_rb_ptr->r_tkills)
2664 if (ap_ra_ptr->level > ap_rb_ptr->level) return TRUE;
2665 if (ap_ra_ptr->level < ap_rb_ptr->level) return FALSE;
2668 /* Sort by index if all conditions are same */
2669 if (ma_ptr->ap_r_idx > mb_ptr->ap_r_idx) return TRUE;
2670 if (ma_ptr->ap_r_idx < mb_ptr->ap_r_idx) return FALSE;
2673 /* An object get higher priority */
2674 if (cave[y[a]][x[a]].o_idx && !cave[y[b]][x[b]].o_idx) return TRUE;
2675 if (!cave[y[a]][x[a]].o_idx && cave[y[b]][x[b]].o_idx) return FALSE;
2677 /* Priority from the terrain */
2678 if (f_info[ca_ptr->feat].priority > f_info[cb_ptr->feat].priority) return TRUE;
2679 if (f_info[ca_ptr->feat].priority < f_info[cb_ptr->feat].priority) return FALSE;
2681 /* If all conditions are same, compare distance */
2682 return ang_sort_comp_distance(u, v, a, b);
2687 * Sorting hook -- swap function -- by "distance to player"
2689 * We use "u" and "v" to point to arrays of "x" and "y" positions,
2690 * and sort the arrays by distance to the player.
2692 static void ang_sort_swap_distance(vptr u, vptr v, int a, int b)
2694 POSITION *x = (POSITION*)(u);
2695 POSITION *y = (POSITION*)(v);
2713 * Hack -- help "select" a location (see below)
2715 static POSITION_IDX target_pick(POSITION y1, POSITION x1, POSITION dy, POSITION dx)
2718 POSITION x2, y2, x3, y3, x4, y4;
2719 POSITION_IDX b_i = -1, b_v = 9999;
2722 /* Scan the locations */
2723 for (i = 0; i < temp_n; i++)
2729 /* Directed distance */
2733 /* Verify quadrant */
2734 if (dx && (x3 * dx <= 0)) continue;
2735 if (dy && (y3 * dy <= 0)) continue;
2737 /* Absolute distance */
2741 /* Verify quadrant */
2742 if (dy && !dx && (x4 > y4)) continue;
2743 if (dx && !dy && (y4 > x4)) continue;
2745 /* Approximate Double Distance */
2746 v = ((x4 > y4) ? (x4 + x4 + y4) : (y4 + y4 + x4));
2748 /* XXX XXX XXX Penalize location */
2751 if ((b_i >= 0) && (v >= b_v)) continue;
2763 * Hack -- determine if a given location is "interesting"
2765 static bool target_set_accept(int y, int x)
2769 s16b this_o_idx, next_o_idx = 0;
2772 if (!(in_bounds(y, x))) return (FALSE);
2774 /* Player grid is always interesting */
2775 if (player_bold(y, x)) return (TRUE);
2778 /* Handle hallucination */
2779 if (p_ptr->image) return (FALSE);
2782 /* Examine the grid */
2783 c_ptr = &cave[y][x];
2785 /* Visible monsters */
2788 monster_type *m_ptr = &m_list[c_ptr->m_idx];
2790 /* Visible monsters */
2791 if (m_ptr->ml) return (TRUE);
2794 /* Scan all objects in the grid */
2795 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
2799 /* Acquire object */
2800 o_ptr = &o_list[this_o_idx];
2802 /* Acquire next object */
2803 next_o_idx = o_ptr->next_o_idx;
2805 /* Memorized object */
2806 if (o_ptr->marked & OM_FOUND) return (TRUE);
2809 /* Interesting memorized features */
2810 if (c_ptr->info & (CAVE_MARK))
2812 /* Notice object features */
2813 if (c_ptr->info & CAVE_OBJECT) return (TRUE);
2815 /* Feature code (applying "mimic" field) */
2816 if (have_flag(f_info[get_feat_mimic(c_ptr)].flags, FF_NOTICE)) return TRUE;
2825 * Prepare the "temp" array for "target_set"
2827 * Return the number of target_able monsters in the set.
2829 static void target_set_prepare(BIT_FLAGS mode)
2832 int min_hgt, max_hgt, min_wid, max_wid;
2834 if (mode & TARGET_KILL)
2837 min_hgt = MAX((p_ptr->y - MAX_RANGE), 0);
2838 max_hgt = MIN((p_ptr->y + MAX_RANGE), cur_hgt - 1);
2839 min_wid = MAX((p_ptr->x - MAX_RANGE), 0);
2840 max_wid = MIN((p_ptr->x + MAX_RANGE), cur_wid - 1);
2842 else /* not targetting */
2845 min_hgt = panel_row_min;
2846 max_hgt = panel_row_max;
2847 min_wid = panel_col_min;
2848 max_wid = panel_col_max;
2851 /* Reset "temp" array */
2854 /* Scan the current panel */
2855 for (y = min_hgt; y <= max_hgt; y++)
2857 for (x = min_wid; x <= max_wid; x++)
2861 /* Require "interesting" contents */
2862 if (!target_set_accept(y, x)) continue;
2864 c_ptr = &cave[y][x];
2866 /* Require target_able monsters for "TARGET_KILL" */
2867 if ((mode & (TARGET_KILL)) && !target_able(c_ptr->m_idx)) continue;
2869 if ((mode & (TARGET_KILL)) && !target_pet && is_pet(&m_list[c_ptr->m_idx])) continue;
2871 /* Save the location */
2878 /* Set the sort hooks */
2879 if (mode & (TARGET_KILL))
2881 /* Target the nearest monster for shooting */
2882 ang_sort_comp = ang_sort_comp_distance;
2883 ang_sort_swap = ang_sort_swap_distance;
2887 /* Look important grids first in Look command */
2888 ang_sort_comp = ang_sort_comp_importance;
2889 ang_sort_swap = ang_sort_swap_distance;
2892 /* Sort the positions */
2893 ang_sort(temp_x, temp_y, temp_n);
2895 if (p_ptr->riding && target_pet && (temp_n > 1) && (mode & (TARGET_KILL)))
2900 temp_y[0] = temp_y[1];
2903 temp_x[0] = temp_x[1];
2908 void target_set_prepare_look(void){
2909 target_set_prepare(TARGET_LOOK);
2914 * Evaluate number of kill needed to gain level
2916 static void evaluate_monster_exp(char *buf, monster_type *m_ptr)
2918 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
2920 s32b exp_mon, exp_adv;
2921 u32b exp_mon_frac, exp_adv_frac;
2923 if ((p_ptr->lev >= PY_MAX_LEVEL) || (p_ptr->prace == RACE_ANDROID))
2928 else if (!ap_r_ptr->r_tkills || (m_ptr->mflag2 & MFLAG2_KAGE))
2938 /* The monster's experience point (assuming average monster speed) */
2939 exp_mon = ap_r_ptr->mexp * ap_r_ptr->level;
2941 s64b_div(&exp_mon, &exp_mon_frac, 0, (p_ptr->max_plv + 2));
2944 /* Total experience value for next level */
2945 exp_adv = player_exp[p_ptr->lev -1] * p_ptr->expfact;
2947 s64b_div(&exp_adv, &exp_adv_frac, 0, 100);
2949 /* Experience value need to get */
2950 s64b_sub(&exp_adv, &exp_adv_frac, p_ptr->exp, p_ptr->exp_frac);
2953 /* You need to kill at least one monster to get any experience */
2954 s64b_add(&exp_adv, &exp_adv_frac, exp_mon, exp_mon_frac);
2955 s64b_sub(&exp_adv, &exp_adv_frac, 0, 1);
2957 /* Extract number of monsters needed */
2958 s64b_div(&exp_adv, &exp_adv_frac, exp_mon, exp_mon_frac);
2960 /* If 999 or more monsters needed, only display "999". */
2961 num = MIN(999, exp_adv_frac);
2963 /* Display the number */
2964 sprintf(buf,"%03ld", (long int)num);
2968 bool show_gold_on_floor = FALSE;
2971 * Examine a grid, return a keypress.
2973 * The "mode" argument contains the "TARGET_LOOK" bit flag, which
2974 * indicates that the "space" key should scan through the contents
2975 * of the grid, instead of simply returning immediately. This lets
2976 * the "look" command get complete information, without making the
2977 * "target" command annoying.
2979 * The "info" argument contains the "commands" which should be shown
2980 * inside the "[xxx]" text. This string must never be empty, or grids
2981 * containing monsters will be displayed with an extra comma.
2983 * Note that if a monster is in the grid, we update both the monster
2984 * recall info and the health bar info to track that monster.
2986 * Eventually, we may allow multiple objects per grid, or objects
2987 * and terrain features in the same grid. XXX XXX XXX
2989 * This function must handle blindness/hallucination.
2991 static char target_set_aux(POSITION y, POSITION x, BIT_FLAGS mode, cptr info)
2993 cave_type *c_ptr = &cave[y][x];
2994 s16b this_o_idx, next_o_idx = 0;
2995 cptr s1 = "", s2 = "", s3 = "", x_info = "";
2998 feature_type *f_ptr;
2999 char query = '\001';
3000 char out_val[MAX_NLEN+80];
3002 #ifdef ALLOW_EASY_FLOOR
3003 OBJECT_IDX floor_list[23];
3004 ITEM_NUMBER floor_num = 0;
3006 /* Scan all objects in the grid */
3009 floor_num = scan_floor(floor_list, y, x, 0x02);
3013 x_info = _("x物 ", "x,");
3017 #endif /* ALLOW_EASY_FLOOR */
3019 /* Hack -- under the player */
3020 if (player_bold(y, x))
3036 s1 = _("ターゲット:", "Target:");
3039 /* Hack -- hallucination */
3042 cptr name = _("何か奇妙な物", "something strange");
3044 /* Display a message */
3046 sprintf(out_val, "%s%s%s%s [%s]", s1, name, s2, s3, info);
3048 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, name, info);
3052 move_cursor_relative(y, x);
3055 /* Stop on everything but "return" */
3056 if ((query != '\r') && (query != '\n')) return query;
3058 /* Repeat forever */
3063 /* Actual monsters */
3064 if (c_ptr->m_idx && m_list[c_ptr->m_idx].ml)
3066 monster_type *m_ptr = &m_list[c_ptr->m_idx];
3067 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
3069 bool recall = FALSE;
3074 /* Get the monster name ("a kobold") */
3075 monster_desc(m_name, m_ptr, MD_INDEF_VISIBLE);
3077 /* Hack -- track this monster race */
3078 monster_race_track(m_ptr->ap_r_idx);
3080 /* Hack -- health bar for this monster */
3081 health_track(c_ptr->m_idx);
3083 /* Hack -- handle stuff */
3097 /* Recall on screen */
3098 screen_roff(m_ptr->ap_r_idx, 0);
3100 /* Hack -- Complete the prompt (again) */
3101 Term_addstr(-1, TERM_WHITE, format(_(" [r思 %s%s]", " [r,%s%s]"), x_info, info));
3109 /* Normal commands */
3110 if (query != 'r') break;
3115 /* Cleare recall text and repeat */
3121 /* Describe, and prompt for recall */
3122 evaluate_monster_exp(acount, m_ptr);
3125 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);
3127 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);
3133 move_cursor_relative(y, x);
3138 /* Normal commands */
3139 if (query != 'r') break;
3145 /* Always stop at "normal" keys */
3146 if ((query != '\r') && (query != '\n') && (query != ' ') && (query != 'x')) return query;
3148 /* Sometimes stop at "space" key */
3149 if ((query == ' ') && !(mode & (TARGET_LOOK))) return query;
3151 /* Change the intro */
3152 s1 = _("それは", "It is ");
3154 /* Hack -- take account of gender */
3155 if (ap_r_ptr->flags1 & (RF1_FEMALE)) s1 = _("彼女は", "She is ");
3156 else if (ap_r_ptr->flags1 & (RF1_MALE)) s1 = _("彼は", "He is ");
3158 /* Use a preposition */
3167 /* Scan all objects being carried */
3168 for (this_o_idx = m_ptr->hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
3170 char o_name[MAX_NLEN];
3174 /* Acquire object */
3175 o_ptr = &o_list[this_o_idx];
3177 /* Acquire next object */
3178 next_o_idx = o_ptr->next_o_idx;
3180 /* Obtain an object description */
3181 object_desc(o_name, o_ptr, 0);
3183 /* Describe the object */
3185 sprintf(out_val, "%s%s%s%s[%s]", s1, o_name, s2, s3, info);
3187 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, o_name, info);
3191 move_cursor_relative(y, x);
3194 /* Always stop at "normal" keys */
3195 if ((query != '\r') && (query != '\n') && (query != ' ') && (query != 'x')) return query;
3197 /* Sometimes stop at "space" key */
3198 if ((query == ' ') && !(mode & (TARGET_LOOK))) return query;
3200 /* Change the intro */
3201 s2 = _("をまた", "also carrying ");
3204 /* Use a preposition */
3214 #ifdef ALLOW_EASY_FLOOR
3223 char o_name[MAX_NLEN];
3227 /* Acquire object */
3228 o_ptr = &o_list[floor_list[0]];
3230 /* Describe the object */
3231 object_desc(o_name, o_ptr, 0);
3235 sprintf(out_val, "%s%s%s%s[%s]",
3236 s1, o_name, s2, s3, info);
3238 sprintf(out_val, "%s%s%s%s [%s]",
3239 s1, s2, s3, o_name, info);
3243 move_cursor_relative(y, x);
3252 /* Provide one cushion before item listing */
3255 /* Display rough information about items */
3257 sprintf(out_val, "%s %d個のアイテム%s%s ['x'で一覧, %s]",
3258 s1, (int)floor_num, s2, s3, info);
3260 sprintf(out_val, "%s%s%sa pile of %d items [x,%s]",
3261 s1, s2, s3, (int)floor_num, info);
3265 move_cursor_relative(y, x);
3270 /* No request for listing */
3271 if (query != 'x' && query != ' ') return query;
3275 /** Display list of items **/
3277 /* Continue scrolling list if requested */
3287 show_gold_on_floor = TRUE;
3288 (void)show_floor(0, y, x, &min_width);
3289 show_gold_on_floor = FALSE;
3293 sprintf(out_val, "%s %d個のアイテム%s%s [Enterで次へ, %s]",
3294 s1, (int)floor_num, s2, s3, info);
3296 sprintf(out_val, "%s%s%sa pile of %d items [Enter,%s]",
3297 s1, s2, s3, (int)floor_num, info);
3308 /* Exit unless 'Enter' */
3309 if (query != '\n' && query != '\r')
3314 /* Get the object being moved. */
3315 o_idx = c_ptr->o_idx;
3317 /* Only rotate a pile of two or more objects. */
3318 if (!(o_idx && o_list[o_idx].next_o_idx)) continue;
3320 /* Remove the first object from the list. */
3321 excise_object_idx(o_idx);
3323 /* Find end of the list. */
3325 while (o_list[i].next_o_idx)
3326 i = o_list[i].next_o_idx;
3328 /* Add after the last object. */
3329 o_list[i].next_o_idx = o_idx;
3331 /* Loop and re-display the list */
3337 #endif /* ALLOW_EASY_FLOOR */
3340 /* Scan all objects in the grid */
3341 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
3345 /* Acquire object */
3346 o_ptr = &o_list[this_o_idx];
3348 /* Acquire next object */
3349 next_o_idx = o_ptr->next_o_idx;
3352 if (o_ptr->marked & OM_FOUND)
3354 char o_name[MAX_NLEN];
3359 /* Obtain an object description */
3360 object_desc(o_name, o_ptr, 0);
3362 /* Describe the object */
3364 sprintf(out_val, "%s%s%s%s[%s]", s1, o_name, s2, s3, info);
3366 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, o_name, info);
3370 move_cursor_relative(y, x);
3373 /* Always stop at "normal" keys */
3374 if ((query != '\r') && (query != '\n') && (query != ' ') && (query != 'x')) return query;
3376 /* Sometimes stop at "space" key */
3377 if ((query == ' ') && !(mode & TARGET_LOOK)) return query;
3379 /* Change the intro */
3380 s1 = _("それは", "It is ");
3383 if (o_ptr->number != 1) s1 = _("それらは", "They are ");
3397 /* Feature code (applying "mimic" field) */
3398 feat = get_feat_mimic(c_ptr);
3400 /* Require knowledge about grid, or ability to see grid */
3401 if (!(c_ptr->info & CAVE_MARK) && !player_can_see_bold(y, x))
3403 /* Forget feature */
3407 f_ptr = &f_info[feat];
3409 /* Terrain feature if needed */
3410 if (boring || have_flag(f_ptr->flags, FF_REMEMBER))
3414 /* Hack -- special handling for quest entrances */
3415 if (have_flag(f_ptr->flags, FF_QUEST_ENTER))
3417 /* Set the quest number temporary */
3418 IDX old_quest = p_ptr->inside_quest;
3421 /* Clear the text */
3422 for (j = 0; j < 10; j++) quest_text[j][0] = '\0';
3423 quest_text_line = 0;
3425 p_ptr->inside_quest = c_ptr->special;
3427 /* Get the quest text */
3428 init_flags = INIT_NAME_ONLY;
3430 process_dungeon_file("q_info.txt", 0, 0, 0, 0);
3432 name = format(_("クエスト「%s」(%d階相当)", "the entrance to the quest '%s'(level %d)"),
3433 quest[c_ptr->special].name, quest[c_ptr->special].level);
3435 /* Reset the old quest number */
3436 p_ptr->inside_quest = old_quest;
3439 /* Hack -- special handling for building doors */
3440 else if (have_flag(f_ptr->flags, FF_BLDG) && !p_ptr->inside_arena)
3442 name = building[f_ptr->subtype].name;
3444 else if (have_flag(f_ptr->flags, FF_ENTRANCE))
3446 name = format(_("%s(%d階相当)", "%s(level %d)"), d_text + d_info[c_ptr->special].text, d_info[c_ptr->special].mindepth);
3448 else if (have_flag(f_ptr->flags, FF_TOWN))
3450 name = town[c_ptr->special].name;
3452 else if (p_ptr->wild_mode && (feat == feat_floor))
3454 name = _("道", "road");
3458 name = f_name + f_ptr->name;
3464 ((!have_flag(f_ptr->flags, FF_MOVE) && !have_flag(f_ptr->flags, FF_CAN_FLY)) ||
3465 (!have_flag(f_ptr->flags, FF_LOS) && !have_flag(f_ptr->flags, FF_TREE)) ||
3466 have_flag(f_ptr->flags, FF_TOWN)))
3468 s2 = _("の中", "in ");
3471 /* Hack -- special introduction for store & building doors -KMW- */
3472 if (have_flag(f_ptr->flags, FF_STORE) ||
3473 have_flag(f_ptr->flags, FF_QUEST_ENTER) ||
3474 (have_flag(f_ptr->flags, FF_BLDG) && !p_ptr->inside_arena) ||
3475 have_flag(f_ptr->flags, FF_ENTRANCE))
3484 else if (have_flag(f_ptr->flags, FF_FLOOR) ||
3485 have_flag(f_ptr->flags, FF_TOWN) ||
3486 have_flag(f_ptr->flags, FF_SHALLOW) ||
3487 have_flag(f_ptr->flags, FF_DEEP))
3493 /* Pick proper indefinite article */
3494 s3 = (is_a_vowel(name[0])) ? "an " : "a ";
3498 /* Display a message */
3502 if (c_ptr->mimic) sprintf(f_idx_str, "%d/%d", c_ptr->feat, c_ptr->mimic);
3503 else sprintf(f_idx_str, "%d", c_ptr->feat);
3505 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]);
3507 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);
3512 sprintf(out_val, "%s%s%s%s[%s]", s1, name, s2, s3, info);
3514 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, name, info);
3518 move_cursor_relative(y, x);
3521 /* Always stop at "normal" keys */
3522 if ((query != '\r') && (query != '\n') && (query != ' ')) return query;
3525 /* Stop on everything but "return" */
3526 if ((query != '\r') && (query != '\n')) return query;
3528 /* Repeat forever */
3534 * Handle "target" and "look".
3536 * Note that this code can be called from "get_aim_dir()".
3538 * All locations must be on the current panel. Consider the use of
3539 * "panel_bounds()" to allow "off-panel" targets, perhaps by using
3540 * some form of "scrolling" the map around the cursor. XXX XXX XXX
3541 * That is, consider the possibility of "auto-scrolling" the screen
3542 * while the cursor moves around. This may require changes in the
3543 * "update_mon()" code to allow "visibility" even if off panel, and
3544 * may require dynamic recalculation of the "temp" grid set.
3546 * Hack -- targeting/observing an "outer border grid" may induce
3547 * problems, so this is not currently allowed.
3549 * The player can use the direction keys to move among "interesting"
3550 * grids in a heuristic manner, or the "space", "+", and "-" keys to
3551 * move through the "interesting" grids in a sequential manner, or
3552 * can enter "location" mode, and use the direction keys to move one
3553 * grid at a time in any direction. The "t" (set target) command will
3554 * only target a monster (as opposed to a location) if the monster is
3555 * target_able and the "interesting" mode is being used.
3557 * The current grid is described using the "look" method above, and
3558 * a new command may be entered at any time, but note that if the
3559 * "TARGET_LOOK" bit flag is set (or if we are in "location" mode,
3560 * where "space" has no obvious meaning) then "space" will scan
3561 * through the description of the current grid until done, instead
3562 * of immediately jumping to the next "interesting" grid. This
3563 * allows the "target" command to retain its old semantics.
3565 * The "*", "+", and "-" keys may always be used to jump immediately
3566 * to the next (or previous) interesting grid, in the proper mode.
3568 * The "return" key may always be used to scan through a complete
3569 * grid description (forever).
3571 * This command will cancel any old target, even if used from
3572 * inside the "look" command.
3574 bool target_set(BIT_FLAGS mode)
3577 POSITION y = p_ptr->y;
3578 POSITION x = p_ptr->x;
3591 get_screen_size(&wid, &hgt);
3597 /* Cancel tracking */
3598 /* health_track(0); */
3600 if (rogue_like_commands)
3609 /* Prepare the "temp" array */
3610 target_set_prepare(mode);
3612 /* Start near the player */
3618 /* Interesting grids */
3625 change_panel_xy(y, x);
3627 if (!(mode & TARGET_LOOK)) prt_path(y, x);
3630 c_ptr = &cave[y][x];
3633 if (target_able(c_ptr->m_idx))
3635 strcpy(info, _("q止 t決 p自 o現 +次 -前", "q,t,p,o,+,-,<dir>"));
3638 /* Dis-allow target */
3641 strcpy(info, _("q止 p自 o現 +次 -前", "q,p,o,+,-,<dir>"));
3647 sprintf(cheatinfo, " LOS:%d, PROJECTABLE:%d",
3648 los(p_ptr->y, p_ptr->x, y, x),
3649 projectable(p_ptr->y, p_ptr->x, y, x));
3650 strcat(info, cheatinfo);
3653 /* Describe and Prompt */
3655 query = target_set_aux(y, x, mode, info);
3659 /* Cancel tracking */
3660 /* health_track(0); */
3662 /* Assume no "direction" */
3667 if (query == '\r') query = 't';
3685 if (target_able(c_ptr->m_idx))
3687 health_track(c_ptr->m_idx);
3688 target_who = c_ptr->m_idx;
3707 if (!expand_list) done = TRUE;
3717 if (!expand_list) done = TRUE;
3724 /* Recenter the map around the player */
3728 p_ptr->update |= (PU_MONSTERS);
3731 p_ptr->redraw |= (PR_MAP);
3734 p_ptr->window |= (PW_OVERHEAD);
3739 /* Recalculate interesting grids */
3740 target_set_prepare(mode);
3759 if(query == same_key)
3764 if (!expand_list) done = TRUE;
3769 /* Extract the action (if any) */
3770 d = get_keymap_dir(query);
3777 /* Hack -- move around */
3780 /* Modified to scroll to monster */
3781 int y2 = panel_row_min;
3782 int x2 = panel_col_min;
3784 /* Find a new monster */
3785 i = target_pick(temp_y[m], temp_x[m], ddy[d], ddx[d]);
3787 /* Request to target past last interesting grid */
3788 while (flag && (i < 0))
3790 /* Note the change */
3791 if (change_panel(ddy[d], ddx[d]))
3796 /* Recalculate interesting grids */
3797 target_set_prepare(mode);
3799 /* Look at interesting grids */
3802 /* Find a new monster */
3803 i = target_pick(v, u, ddy[d], ddx[d]);
3809 /* Nothing interesting */
3815 /* Restore previous position */
3818 panel_bounds_center();
3821 p_ptr->update |= (PU_MONSTERS);
3824 p_ptr->redraw |= (PR_MAP);
3827 p_ptr->window |= (PW_OVERHEAD);
3832 /* Recalculate interesting grids */
3833 target_set_prepare(mode);
3835 /* Look at boring grids */
3842 /* Do not move horizontally if unnecessary */
3843 if (((x < panel_col_min + wid / 2) && (dx > 0)) ||
3844 ((x > panel_col_min + wid / 2) && (dx < 0)))
3849 /* Do not move vertically if unnecessary */
3850 if (((y < panel_row_min + hgt / 2) && (dy > 0)) ||
3851 ((y > panel_row_min + hgt / 2) && (dy < 0)))
3856 /* Apply the motion */
3857 if ((y >= panel_row_min+hgt) || (y < panel_row_min) ||
3858 (x >= panel_col_min+wid) || (x < panel_col_min))
3860 if (change_panel(dy, dx)) target_set_prepare(mode);
3863 /* Slide into legality */
3864 if (x >= cur_wid-1) x = cur_wid - 2;
3865 else if (x <= 0) x = 1;
3867 /* Slide into legality */
3868 if (y >= cur_hgt-1) y = cur_hgt- 2;
3869 else if (y <= 0) y = 1;
3878 /* Arbitrary grids */
3881 bool move_fast = FALSE;
3883 if (!(mode & TARGET_LOOK)) prt_path(y, x);
3886 c_ptr = &cave[y][x];
3888 /* Default prompt */
3889 strcpy(info, _("q止 t決 p自 m近 +次 -前", "q,t,p,m,+,-,<dir>"));
3894 sprintf(cheatinfo, " LOS:%d, PROJECTABLE:%d",
3895 los(p_ptr->y, p_ptr->x, y, x),
3896 projectable(p_ptr->y, p_ptr->x, y, x));
3897 strcat(info, cheatinfo);
3900 /* Describe and Prompt (enable "TARGET_LOOK") */
3901 while ((query = target_set_aux(y, x, mode | TARGET_LOOK, info)) == 0);
3903 /* Cancel tracking */
3904 /* health_track(0); */
3906 /* Assume no direction */
3911 if (query == '\r') query = 't';
3914 /* Analyze the keypress */
3938 /* Recenter the map around the player */
3942 p_ptr->update |= (PU_MONSTERS);
3945 p_ptr->redraw |= (PR_MAP);
3948 p_ptr->window |= (PW_OVERHEAD);
3953 /* Recalculate interesting grids */
3954 target_set_prepare(mode);
3976 /* Pick a nearby monster */
3977 for (i = 0; i < temp_n; i++)
3979 t = distance(y, x, temp_y[i], temp_x[i]);
3989 /* Nothing interesting */
3990 if (bd == 999) flag = FALSE;
3997 /* Extract the action (if any) */
3998 d = get_keymap_dir(query);
4000 /* XTRA HACK MOVEFAST */
4001 if (isupper(query)) move_fast = TRUE;
4008 /* Handle "direction" */
4014 /* XTRA HACK MOVEFAST */
4017 int mag = MIN(wid / 2, hgt / 2);
4027 /* Do not move horizontally if unnecessary */
4028 if (((x < panel_col_min + wid / 2) && (dx > 0)) ||
4029 ((x > panel_col_min + wid / 2) && (dx < 0)))
4034 /* Do not move vertically if unnecessary */
4035 if (((y < panel_row_min + hgt / 2) && (dy > 0)) ||
4036 ((y > panel_row_min + hgt / 2) && (dy < 0)))
4041 /* Apply the motion */
4042 if ((y >= panel_row_min + hgt) || (y < panel_row_min) ||
4043 (x >= panel_col_min + wid) || (x < panel_col_min))
4045 if (change_panel(dy, dx)) target_set_prepare(mode);
4048 /* Slide into legality */
4049 if (x >= cur_wid-1) x = cur_wid - 2;
4050 else if (x <= 0) x = 1;
4052 /* Slide into legality */
4053 if (y >= cur_hgt-1) y = cur_hgt- 2;
4054 else if (y <= 0) y = 1;
4062 /* Clear the top line */
4065 /* Recenter the map around the player */
4069 p_ptr->update |= (PU_MONSTERS);
4072 p_ptr->redraw |= (PR_MAP);
4075 p_ptr->window |= (PW_OVERHEAD);
4080 /* Failure to set target */
4081 if (!target_who) return (FALSE);
4089 * Get an "aiming direction" from the user.
4091 * The "dir" is loaded with 1,2,3,4,6,7,8,9 for "actual direction", and
4092 * "0" for "current target", and "-1" for "entry aborted".
4094 * Note that "Force Target", if set, will pre-empt user interaction,
4095 * if there is a usable target already set.
4097 * Note that confusion over-rides any (explicit?) user choice.
4099 bool get_aim_dir(DIRECTION *dp)
4109 /* Global direction */
4112 /* Hack -- auto-target if requested */
4113 if (use_old_target && target_okay()) dir = 5;
4115 #ifdef ALLOW_REPEAT /* TNB */
4117 if (repeat_pull(&code))
4122 if (!(code == 5 && !target_okay()))
4124 /* return (TRUE); */
4125 dir = (DIRECTION)code;
4128 *dp = (DIRECTION)code;
4130 #endif /* ALLOW_REPEAT -- TNB */
4132 /* Ask until satisfied */
4135 /* Choose a prompt */
4138 p = _("方向 ('*'でターゲット選択, ESCで中断)? ", "Direction ('*' to choose a target, Escape to cancel)? ");
4142 p = _("方向 ('5'でターゲットへ, '*'でターゲット再選択, ESCで中断)? ", "Direction ('5' for target, '*' to re-target, Escape to cancel)? ");
4145 /* Get a command (or Cancel) */
4146 if (!get_com(p, &command, TRUE)) break;
4150 if (command == '\r') command = 't';
4153 /* Convert various keys to "standard" keys */
4156 /* Use current target */
4167 /* Set new target */
4172 if (target_set(TARGET_KILL)) dir = 5;
4178 /* Extract the action (if any) */
4179 dir = get_keymap_dir(command);
4185 /* Verify requested targets */
4186 if ((dir == 5) && !target_okay()) dir = 0;
4195 project_length = 0; /* reset to default */
4199 /* Save the direction */
4202 /* Check for confusion */
4203 if (p_ptr->confused)
4206 /* Random direction */
4207 dir = ddd[randint0(8)];
4210 /* Notice confusion */
4211 if (command_dir != dir)
4214 msg_print(_("あなたは混乱している。", "You are confused."));
4217 /* Save direction */
4220 #ifdef ALLOW_REPEAT /* TNB */
4222 /* repeat_push(dir); */
4223 repeat_push((COMMAND_CODE)command_dir);
4225 #endif /* ALLOW_REPEAT -- TNB */
4227 /* A "valid" direction was entered */
4234 * Request a "movement" direction (1,2,3,4,6,7,8,9) from the user,
4235 * and place it into "command_dir", unless we already have one.
4237 * This function should be used for all "repeatable" commands, such as
4238 * run, walk, open, close, bash, disarm, spike, tunnel, etc, as well
4239 * as all commands which must reference a grid adjacent to the player,
4240 * and which may not reference the grid under the player. Note that,
4241 * for example, it is no longer possible to "disarm" or "open" chests
4242 * in the same grid as the player.
4244 * Direction "5" is illegal and will (cleanly) abort the command.
4246 * This function tracks and uses the "global direction", and uses
4247 * that as the "desired direction", to which "confusion" is applied.
4249 bool get_rep_dir(DIRECTION *dp, bool under)
4258 /* Global direction */
4261 #ifdef ALLOW_REPEAT /* TNB */
4263 if (repeat_pull(&code))
4265 dir = (DIRECTION)code;
4266 /* return (TRUE); */
4268 *dp = (DIRECTION)code;
4270 #endif /* ALLOW_REPEAT -- TNB */
4274 prompt = _("方向 ('.'足元, ESCで中断)? ", "Direction ('.' at feet, Escape to cancel)? ");
4278 prompt = _("方向 (ESCで中断)? ", "Direction (Escape to cancel)? ");
4281 /* Get a direction */
4286 /* Get a command (or Cancel) */
4287 if (!get_com(prompt, &ch, TRUE)) break;
4290 if ((under) && ((ch == '5') || (ch == '-') || (ch == '.')))
4296 /* Look up the direction */
4297 dir = get_keymap_dir(ch);
4304 /* Prevent weirdness */
4305 if ((dir == 5) && (!under)) dir = 0;
4308 if (!dir) return (FALSE);
4310 /* Save desired direction */
4313 /* Apply "confusion" */
4314 if (p_ptr->confused)
4316 /* Standard confusion */
4317 if (randint0(100) < 75)
4319 /* Random direction */
4320 dir = ddd[randint0(8)];
4323 else if (p_ptr->riding)
4325 monster_type *m_ptr = &m_list[p_ptr->riding];
4326 monster_race *r_ptr = &r_info[m_ptr->r_idx];
4328 if (MON_CONFUSED(m_ptr))
4330 /* Standard confusion */
4331 if (randint0(100) < 75)
4333 /* Random direction */
4334 dir = ddd[randint0(8)];
4337 else if ((r_ptr->flags1 & RF1_RAND_50) && (r_ptr->flags1 & RF1_RAND_25) && (randint0(100) < 50))
4339 /* Random direction */
4340 dir = ddd[randint0(8)];
4342 else if ((r_ptr->flags1 & RF1_RAND_50) && (randint0(100) < 25))
4344 /* Random direction */
4345 dir = ddd[randint0(8)];
4349 /* Notice confusion */
4350 if (command_dir != dir)
4352 if (p_ptr->confused)
4355 msg_print(_("あなたは混乱している。", "You are confused."));
4360 monster_type *m_ptr = &m_list[p_ptr->riding];
4362 monster_desc(m_name, m_ptr, 0);
4363 if (MON_CONFUSED(m_ptr))
4365 msg_format(_("%sは混乱している。", "%^s is confusing."), m_name);
4369 msg_format(_("%sは思い通りに動いてくれない。", "You cannot control %s."), m_name);
4374 /* Save direction */
4377 #ifdef ALLOW_REPEAT /* TNB */
4379 /* repeat_push(dir); */
4380 repeat_push((COMMAND_CODE)command_dir);
4382 #endif /* ALLOW_REPEAT -- TNB */
4389 bool get_rep_dir2(DIRECTION *dp)
4397 /* Global direction */
4400 #ifdef ALLOW_REPEAT /* TNB */
4402 if (repeat_pull(&code))
4404 dir = (DIRECTION)code;
4405 /* return (TRUE); */
4407 *dp = (DIRECTION)code;
4409 #endif /* ALLOW_REPEAT -- TNB */
4411 /* Get a direction */
4416 /* Get a command (or Cancel) */
4417 if (!get_com(_("方向 (ESCで中断)? ", "Direction (Escape to cancel)? "), &ch, TRUE)) break;
4419 /* Look up the direction */
4420 dir = get_keymap_dir(ch);
4426 /* Prevent weirdness */
4427 if (dir == 5) dir = 0;
4430 if (!dir) return (FALSE);
4432 /* Save desired direction */
4435 /* Apply "confusion" */
4436 if (p_ptr->confused)
4438 /* Standard confusion */
4439 if (randint0(100) < 75)
4441 /* Random direction */
4442 dir = ddd[randint0(8)];
4446 /* Notice confusion */
4447 if (command_dir != dir)
4450 msg_print(_("あなたは混乱している。", "You are confused."));
4453 /* Save direction */
4456 #ifdef ALLOW_REPEAT /* TNB */
4458 /* repeat_push(dir); */
4459 repeat_push((COMMAND_CODE)command_dir);
4461 #endif /* ALLOW_REPEAT -- TNB */
4467 void gain_level_reward(int chosen_reward)
4471 char wrath_reason[32] = "";
4472 int nasty_chance = 6;
4473 OBJECT_TYPE_VALUE dummy = 0;
4474 OBJECT_SUBTYPE_VALUE dummy2 = 0;
4477 char o_name[MAX_NLEN];
4483 if (multi_rew) return;
4484 else multi_rew = TRUE;
4488 if (p_ptr->lev == 13) nasty_chance = 2;
4489 else if (!(p_ptr->lev % 13)) nasty_chance = 3;
4490 else if (!(p_ptr->lev % 14)) nasty_chance = 12;
4492 if (one_in_(nasty_chance))
4493 type = randint1(20); /* Allow the 'nasty' effects */
4495 type = randint1(15) + 5; /* Or disallow them */
4497 if (type < 1) type = 1;
4498 if (type > 20) type = 20;
4502 sprintf(wrath_reason, _("%sの怒り", "the Wrath of %s"), chaos_patrons[p_ptr->chaos_patron]);
4504 effect = chaos_rewards[p_ptr->chaos_patron][type];
4506 if (one_in_(6) && !chosen_reward)
4508 msg_format(_("%^sは褒美としてあなたを突然変異させた。", "%^s rewards you with a mutation!"), chaos_patrons[p_ptr->chaos_patron]);
4509 (void)gain_random_mutation(0);
4510 reward = _("変異した。", "mutation");
4514 switch (chosen_reward ? chosen_reward : effect)
4519 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4520 msg_print(_("「汝、新たなる姿を必要とせり!」", "'Thou needst a new form, mortal!'"));
4523 reward = _("変異した。", "polymorphing");
4528 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4529 msg_print(_("「汝は良く行いたり!続けよ!」", "'Well done, mortal! Lead on!'"));
4531 if (p_ptr->prace == RACE_ANDROID)
4533 msg_print(_("しかし何も起こらなかった。", "But, nothing happen."));
4535 else if (p_ptr->exp < PY_MAX_EXP)
4537 s32b ee = (p_ptr->exp / 2) + 10;
4538 if (ee > 100000L) ee = 100000L;
4539 msg_print(_("更に経験を積んだような気がする。", "You feel more experienced."));
4542 reward = _("経験値を得た", "experience");
4548 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4549 msg_print(_("「下僕よ、汝それに値せず。」", "'Thou didst not deserve that, slave.'"));
4551 if (p_ptr->prace == RACE_ANDROID)
4553 msg_print(_("しかし何も起こらなかった。", "But, nothing happen."));
4557 lose_exp(p_ptr->exp / 6);
4558 reward = _("経験値を失った。", "losing experience");
4564 msg_format("%sの声がささやいた:",
4565 chaos_patrons[p_ptr->chaos_patron]);
4567 msg_format("The voice of %s whispers:",
4568 chaos_patrons[p_ptr->chaos_patron]);
4571 msg_print(_("「我が与えし物を賢明に使うべし。」", "'Use my gift wisely.'"));
4573 acquirement(p_ptr->y, p_ptr->x, 1, FALSE, FALSE, FALSE);
4574 reward = _("上質なアイテムを手に入れた。", "a good item");
4579 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4580 msg_print(_("「我が与えし物を賢明に使うべし。」", "'Use my gift wisely.'"));
4582 acquirement(p_ptr->y, p_ptr->x, 1, TRUE, FALSE, FALSE);
4583 reward = _("高級品のアイテムを手に入れた。", "an excellent item");
4588 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4589 msg_print(_("「汝の行いは貴き剣に値せり。」", "'Thy deed hath earned thee a worthy blade.'"));
4591 /* Get local object */
4594 switch (randint1(p_ptr->lev))
4600 dummy2 = SV_MAIN_GAUCHE;
4609 dummy2 = SV_SMALL_SWORD;
4612 dummy2 = SV_BASILLARD;
4614 case 11: case 12: case 13:
4615 dummy2 = SV_SHORT_SWORD;
4621 dummy2 = SV_CUTLASS;
4624 dummy2 = SV_WAKIZASHI;
4627 dummy2 = SV_KHOPESH;
4633 dummy2 = SV_BROAD_SWORD;
4636 dummy2 = SV_LONG_SWORD;
4639 dummy2 = SV_SCIMITAR;
4642 dummy2 = SV_NINJATO;
4648 dummy2 = SV_BASTARD_SWORD;
4651 dummy2 = SV_GREAT_SCIMITAR;
4654 dummy2 = SV_CLAYMORE;
4657 dummy2 = SV_ESPADON;
4660 dummy2 = SV_TWO_HANDED_SWORD;
4663 dummy2 = SV_FLAMBERGE;
4666 dummy2 = SV_NO_DACHI;
4669 dummy2 = SV_EXECUTIONERS_SWORD;
4672 dummy2 = SV_ZWEIHANDER;
4675 dummy2 = SV_HAYABUSA;
4678 dummy2 = SV_BLADE_OF_CHAOS;
4681 object_prep(q_ptr, lookup_kind(dummy, dummy2));
4682 q_ptr->to_h = 3 + randint1(dun_level) % 10;
4683 q_ptr->to_d = 3 + randint1(dun_level) % 10;
4684 one_resistance(q_ptr);
4685 q_ptr->name2 = EGO_CHAOTIC;
4687 /* Drop it in the dungeon */
4688 (void)drop_near(q_ptr, -1, p_ptr->y, p_ptr->x);
4689 reward = _("(混沌)の武器を手に入れた。", "chaos weapon");
4694 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4695 msg_print(_("「汝の行いは貴き報いに値せり。」", "'Thy deed hath earned thee a worthy reward.'"));
4697 acquirement(p_ptr->y, p_ptr->x, randint1(2) + 1, FALSE, FALSE, FALSE);
4698 reward = _("上質なアイテムを手に入れた。", "good items");
4703 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4704 msg_print(_("「下僕よ、汝の献身への我が惜しみ無き報いを見るがよい。」", "'Behold, mortal, how generously I reward thy loyalty.'"));
4706 acquirement(p_ptr->y, p_ptr->x, randint1(2) + 1, TRUE, FALSE, FALSE);
4707 reward = _("高級品のアイテムを手に入れた。", "excellent items");
4712 msg_format("%sの声が轟き渡った:", chaos_patrons[p_ptr->chaos_patron]);
4714 msg_format("The voice of %s thunders:", chaos_patrons[p_ptr->chaos_patron]);
4717 msg_print(_("「下僕よ、汝傲慢なり。」", "'Thou art growing arrogant, mortal.'"));
4719 (void)activate_ty_curse(FALSE, &count);
4720 reward = _("禍々しい呪いをかけられた。", "cursing");
4725 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4726 msg_print(_("「我が下僕たちよ、かの傲慢なる者を倒すべし!」", "'My pets, destroy the arrogant mortal!'"));
4728 for (dummy = 0; dummy < randint1(5) + 1; dummy++)
4730 (void)summon_specific(0, p_ptr->y, p_ptr->x, dun_level, 0, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET));
4732 reward = _("モンスターを召喚された。", "summoning hostile monsters");
4738 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4739 msg_print(_("「汝、より強き敵を必要とせり!」", "'Thou needst worthier opponents!'"));
4741 activate_hi_summon(p_ptr->y, p_ptr->x, FALSE);
4742 reward = _("モンスターを召喚された。", "summoning many hostile monsters");
4748 msg_format("%sの声が響き渡った:",
4749 chaos_patrons[p_ptr->chaos_patron]);
4751 msg_format("The voice of %s booms out:",
4752 chaos_patrons[p_ptr->chaos_patron]);
4755 msg_print(_("「死と破壊こそ我が喜びなり!」", "'Death and destruction! This pleaseth me!'"));
4758 reward = _("カオスの力が渦巻いた。", "calling chaos");
4764 msg_format("%sの声が鳴り響いた:",
4765 chaos_patrons[p_ptr->chaos_patron]);
4767 msg_format("The voice of %s rings out:",
4768 chaos_patrons[p_ptr->chaos_patron]);
4771 msg_print(_("「留まるのだ、下僕よ。余が汝の肉体を鍛えん。」", "'Stay, mortal, and let me mold thee.'"));
4773 if (one_in_(3) && !(chaos_stats[p_ptr->chaos_patron] < 0))
4774 do_inc_stat(chaos_stats[p_ptr->chaos_patron]);
4776 do_inc_stat(randint0(6));
4777 reward = _("能力値が上がった。", "increasing a stat");
4783 msg_format("%sの声が響き渡った:",
4784 chaos_patrons[p_ptr->chaos_patron]);
4786 msg_format("The voice of %s booms out:",
4787 chaos_patrons[p_ptr->chaos_patron]);
4790 msg_print(_("「下僕よ、余は汝に飽みたり。」", "'I grow tired of thee, mortal.'"));
4792 if (one_in_(3) && !(chaos_stats[p_ptr->chaos_patron] < 0))
4793 do_dec_stat(chaos_stats[p_ptr->chaos_patron]);
4795 (void)do_dec_stat(randint0(6));
4796 reward = _("能力値が下がった。", "decreasing a stat");
4803 msg_format("%sの声が轟き渡った:",
4804 chaos_patrons[p_ptr->chaos_patron]);
4806 msg_format("The voice of %s thunders:",
4807 chaos_patrons[p_ptr->chaos_patron]);
4810 msg_print(_("「汝、謙虚たることを学ぶべし!」", "'Thou needst a lesson in humility, mortal!'"));
4811 msg_print(_("あなたは以前より弱くなった!", "You feel less powerful!"));
4813 for (dummy = 0; dummy < 6; dummy++)
4815 (void)dec_stat(dummy, 10 + randint1(15), TRUE);
4817 reward = _("全能力値が下がった。", "decreasing all stats");
4822 msg_format(_("%sの力が触れるのを感じた。", "You feel the power of %s touch you."),
4823 chaos_patrons[p_ptr->chaos_patron]);
4825 reward = _("傷が変化した。", "polymorphing wounds");
4830 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4832 msg_print(_("「我がささやかなる賜物を受けとるがよい!」", "'Receive this modest gift from me!'"));
4834 for (dummy = 0; dummy < 6; dummy++)
4836 (void)do_inc_stat(dummy);
4838 reward = _("全能力値が上がった。", "increasing all stats");
4843 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4844 msg_print(_("「苦しむがよい、無能な愚か者よ!」", "'Suffer, pathetic fool!'"));
4846 fire_ball(GF_DISINTEGRATE, 0, p_ptr->lev * 4, 4);
4847 take_hit(DAMAGE_NOESCAPE, p_ptr->lev * 4, wrath_reason, -1);
4848 reward = _("分解の球が発生した。", "generating disintegration ball");
4853 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4854 (void)restore_level();
4855 (void)restore_all_status();
4856 (void)true_healing(5000);
4857 reward = _("体力が回復した。", "healing");
4862 if (!buki_motteruka(INVEN_RARM) && !buki_motteruka(INVEN_LARM)) break;
4863 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4864 msg_print(_("「汝、武器に頼ることなかれ。」", "'Thou reliest too much on thy weapon.'"));
4867 if (buki_motteruka(INVEN_LARM))
4870 if (buki_motteruka(INVEN_RARM) && one_in_(2)) dummy = INVEN_RARM;
4872 object_desc(o_name, &inventory[dummy], OD_NAME_ONLY);
4873 (void)curse_weapon(FALSE, dummy);
4874 reward = format(_("%sが破壊された。", "destroying %s"), o_name);
4879 if (!inventory[INVEN_BODY].k_idx) break;
4880 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4881 msg_print(_("「汝、防具に頼ることなかれ。」", "'Thou reliest too much on thine equipment.'"));
4883 object_desc(o_name, &inventory[INVEN_BODY], OD_NAME_ONLY);
4884 (void)curse_armor();
4885 reward = format(_("%sが破壊された。", "destroying %s"), o_name);
4889 msg_format(_("%sの声がささやいた:", "The voice of %s whispers:"), chaos_patrons[p_ptr->chaos_patron]);
4890 msg_print(_("「我を怒りしめた罪を償うべし。」", "'Now thou shalt pay for annoying me.'"));
4892 switch (randint1(4))
4895 (void)activate_ty_curse(FALSE, &count);
4896 reward = _("禍々しい呪いをかけられた。", "cursing");
4899 activate_hi_summon(p_ptr->y, p_ptr->x, FALSE);
4900 reward = _("モンスターを召喚された。", "summoning hostile monsters");
4905 if (!buki_motteruka(INVEN_RARM) && !buki_motteruka(INVEN_LARM)) break;
4907 if (buki_motteruka(INVEN_LARM))
4910 if (buki_motteruka(INVEN_RARM) && one_in_(2)) dummy = INVEN_RARM;
4912 object_desc(o_name, &inventory[dummy], OD_NAME_ONLY);
4913 (void)curse_weapon(FALSE, dummy);
4914 reward = format(_("%sが破壊された。", "destroying %s"), o_name);
4918 if (!inventory[INVEN_BODY].k_idx) break;
4919 object_desc(o_name, &inventory[INVEN_BODY], OD_NAME_ONLY);
4920 (void)curse_armor();
4921 reward = format(_("%sが破壊された。", "destroying %s"), o_name);
4925 for (dummy = 0; dummy < 6; dummy++)
4927 (void)dec_stat(dummy, 10 + randint1(15), TRUE);
4929 reward = _("全能力値が下がった。", "decreasing all stats");
4936 msg_format(_("%sの声が轟き渡った:", "The voice of %s thunders:"), chaos_patrons[p_ptr->chaos_patron]);
4937 msg_print(_("「死ぬがよい、下僕よ!」", "'Die, mortal!'"));
4939 take_hit(DAMAGE_LOSELIFE, p_ptr->lev * 4, wrath_reason, -1);
4940 for (dummy = 0; dummy < 6; dummy++)
4942 (void)dec_stat(dummy, 10 + randint1(15), FALSE);
4944 activate_hi_summon(p_ptr->y, p_ptr->x, FALSE);
4945 (void)activate_ty_curse(FALSE, &count);
4950 if (buki_motteruka(INVEN_RARM))
4953 if (buki_motteruka(INVEN_LARM) && one_in_(2)) dummy = INVEN_LARM;
4955 else if (buki_motteruka(INVEN_LARM)) dummy = INVEN_LARM;
4957 if (dummy) (void)curse_weapon(FALSE, dummy);
4959 if (one_in_(2)) (void)curse_armor();
4964 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4965 msg_print(_("「死と破壊こそ我が喜びなり!」", "'Death and destruction! This pleaseth me!'"));
4967 (void)destroy_area(p_ptr->y, p_ptr->x, 25, FALSE);
4968 reward = _("ダンジョンが*破壊*された。", "*destruct*ing dungeon");
4973 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4974 msg_print(_("「我、汝の敵を抹殺せん!」", "'Let me relieve thee of thine oppressors!'"));
4975 (void)symbol_genocide(0, FALSE);
4976 reward = _("モンスターが抹殺された。", "genociding monsters");
4981 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4982 msg_print(_("「我、汝の敵を抹殺せん!」", "'Let me relieve thee of thine oppressors!'"));
4984 (void)mass_genocide(0, FALSE);
4985 reward = _("モンスターが抹殺された。", "genociding nearby monsters");
4990 msg_format(_("%sの力が敵を攻撃するのを感じた!", "You can feel the power of %s assault your enemies!"), chaos_patrons[p_ptr->chaos_patron]);
4991 (void)dispel_monsters(p_ptr->lev * 4);
4996 msg_format(_("%sはあなたを無視した。", "%s ignores you."), chaos_patrons[p_ptr->chaos_patron]);
5001 msg_format(_("%sは褒美として悪魔の使いをよこした!", "%s rewards you with a demonic servant!"),chaos_patrons[p_ptr->chaos_patron]);
5003 if (!summon_specific(-1, p_ptr->y, p_ptr->x, dun_level, SUMMON_DEMON, PM_FORCE_PET))
5004 msg_print(_("何も現れなかった...", "Nobody ever turns up..."));
5006 reward = _("悪魔がペットになった。", "a demonic servant");
5011 msg_format(_("%sは褒美として使いをよこした!", "%s rewards you with a servant!"),chaos_patrons[p_ptr->chaos_patron]);
5013 if (!summon_specific(-1, p_ptr->y, p_ptr->x, dun_level, 0, PM_FORCE_PET))
5014 msg_print(_("何も現れなかった...", "Nobody ever turns up..."));
5016 reward = _("モンスターがペットになった。", "a servant");
5021 msg_format(_("%sは褒美としてアンデッドの使いをよこした。", "%s rewards you with an undead servant!"),chaos_patrons[p_ptr->chaos_patron]);
5023 if (!summon_specific(-1, p_ptr->y, p_ptr->x, dun_level, SUMMON_UNDEAD, PM_FORCE_PET))
5024 msg_print(_("何も現れなかった...", "Nobody ever turns up..."));
5026 reward = _("アンデッドがペットになった。", "an undead servant");
5031 msg_format(_("%sの声がどもった:", "The voice of %s stammers:"),
5033 chaos_patrons[p_ptr->chaos_patron]);
5034 msg_format(_("「あー、あー、答えは %d/%d。質問は何?」", "'Uh... uh... the answer's %d/%d, what's the question?'"), type, effect);
5040 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, format(_("パトロンの報酬で%s", "The patron rewards you with %s."), reward));
5046 * XAngband: determine if a given location is "interesting"
5047 * based on target_set_accept function.
5049 static bool tgt_pt_accept(POSITION y, POSITION x)
5054 if (!(in_bounds(y, x))) return (FALSE);
5056 /* Player grid is always interesting */
5057 if ((y == p_ptr->y) && (x == p_ptr->x)) return (TRUE);
5059 /* Handle hallucination */
5060 if (p_ptr->image) return (FALSE);
5062 /* Examine the grid */
5063 c_ptr = &cave[y][x];
5065 /* Interesting memorized features */
5066 if (c_ptr->info & (CAVE_MARK))
5069 if (cave_have_flag_grid(c_ptr, FF_LESS)) return (TRUE);
5070 if (cave_have_flag_grid(c_ptr, FF_MORE)) return (TRUE);
5072 /* Notice quest features */
5073 if (cave_have_flag_grid(c_ptr, FF_QUEST_ENTER)) return (TRUE);
5074 if (cave_have_flag_grid(c_ptr, FF_QUEST_EXIT)) return (TRUE);
5083 * XAngband: Prepare the "temp" array for "tget_pt"
5084 * based on target_set_prepare funciton.
5086 static void tgt_pt_prepare(void)
5090 /* Reset "temp" array */
5093 if (!expand_list) return;
5095 /* Scan the current panel */
5096 for (y = 1; y < cur_hgt; y++)
5098 for (x = 1; x < cur_wid; x++)
5100 /* Require "interesting" contents */
5101 if (!tgt_pt_accept(y, x)) continue;
5103 /* Save the location */
5110 /* Target the nearest monster for shooting */
5111 ang_sort_comp = ang_sort_comp_distance;
5112 ang_sort_swap = ang_sort_swap_distance;
5114 /* Sort the positions */
5115 ang_sort(temp_x, temp_y, temp_n);
5119 * old -- from PsiAngband.
5121 bool tgt_pt(POSITION *x_ptr, POSITION *y_ptr)
5126 bool success = FALSE;
5131 get_screen_size(&wid, &hgt);
5141 msg_print(_("場所を選んでスペースキーを押して下さい。", "Select a point and press space."));
5142 msg_flag = FALSE; /* prevents "-more-" message. */
5144 while ((ch != ESCAPE) && !success)
5146 bool move_fast = FALSE;
5148 move_cursor_relative(y, x);
5160 if (player_bold(y, x)) ch = 0;
5163 else success = TRUE;
5167 /* XAngband: Move cursor to stairs */
5170 if (expand_list && temp_n)
5173 int cx = (panel_col_min + panel_col_max) / 2;
5174 int cy = (panel_row_min + panel_row_max) / 2;
5178 /* Skip stairs which have defferent distance */
5179 for (; n < temp_n; ++ n)
5181 cave_type *c_ptr = &cave[temp_y[n]][temp_x[n]];
5183 if (cave_have_flag_grid(c_ptr, FF_STAIRS) &&
5184 cave_have_flag_grid(c_ptr, ch == '>' ? FF_MORE : FF_LESS))
5191 if (n == temp_n) /* Loop out taget list */
5196 verify_panel(); /* Move cursor to player */
5199 p_ptr->update |= (PU_MONSTERS);
5202 p_ptr->redraw |= (PR_MAP);
5205 p_ptr->window |= (PW_OVERHEAD);
5210 else /* move cursor to next stair and change panel */
5215 dy = 2 * (y - cy) / hgt;
5216 dx = 2 * (x - cx) / wid;
5217 if (dy || dx) change_panel(dy, dx);
5223 /* Look up the direction */
5224 d = get_keymap_dir(ch);
5226 /* XTRA HACK MOVEFAST */
5227 if (isupper(ch)) move_fast = TRUE;
5229 /* Handle "direction" */
5235 /* XTRA HACK MOVEFAST */
5238 int mag = MIN(wid / 2, hgt / 2);
5248 /* Do not move horizontally if unnecessary */
5249 if (((x < panel_col_min + wid / 2) && (dx > 0)) ||
5250 ((x > panel_col_min + wid / 2) && (dx < 0)))
5255 /* Do not move vertically if unnecessary */
5256 if (((y < panel_row_min + hgt / 2) && (dy > 0)) ||
5257 ((y > panel_row_min + hgt / 2) && (dy < 0)))
5262 /* Apply the motion */
5263 if ((y >= panel_row_min + hgt) || (y < panel_row_min) ||
5264 (x >= panel_col_min + wid) || (x < panel_col_min))
5266 /* if (change_panel(dy, dx)) target_set_prepare(mode); */
5267 change_panel(dy, dx);
5270 /* Slide into legality */
5271 if (x >= cur_wid-1) x = cur_wid - 2;
5272 else if (x <= 0) x = 1;
5274 /* Slide into legality */
5275 if (y >= cur_hgt-1) y = cur_hgt- 2;
5276 else if (y <= 0) y = 1;
5283 /* Clear the top line */
5286 /* Recenter the map around the player */
5290 p_ptr->update |= (PU_MONSTERS);
5293 p_ptr->redraw |= (PR_MAP);
5296 p_ptr->window |= (PW_OVERHEAD);
5307 bool get_hack_dir(DIRECTION *dp)
5316 /* Global direction */
5319 /* (No auto-targeting) */
5321 /* Ask until satisfied */
5324 /* Choose a prompt */
5327 p = _("方向 ('*'でターゲット選択, ESCで中断)? ", "Direction ('*' to choose a target, Escape to cancel)? ");
5331 p = _("方向 ('5'でターゲットへ, '*'でターゲット再選択, ESCで中断)? ", "Direction ('5' for target, '*' to re-target, Escape to cancel)? ");
5334 /* Get a command (or Cancel) */
5335 if (!get_com(p, &command, TRUE)) break;
5339 if (command == '\r') command = 't';
5342 /* Convert various keys to "standard" keys */
5345 /* Use current target */
5356 /* Set new target */
5361 if (target_set(TARGET_KILL)) dir = 5;
5367 /* Look up the direction */
5368 dir = get_keymap_dir(command);
5374 /* Verify requested targets */
5375 if ((dir == 5) && !target_okay()) dir = 0;
5382 if (!dir) return (FALSE);
5384 /* Save the direction */
5387 /* Check for confusion */
5388 if (p_ptr->confused)
5391 /* Random direction */
5392 dir = ddd[randint0(8)];
5395 /* Notice confusion */
5396 if (command_dir != dir)
5399 msg_print(_("あなたは混乱している。", "You are confused."));
5402 /* Save direction */
5405 /* A "valid" direction was entered */
5411 * エネルギーの増加量10d5を速く計算するための関数
5414 #define Go_no_JuuJou 5*5*5*5*5*5*5*5*5*5
5416 s16b gain_energy(void)
5419 s32b energy_result = 10;
5422 tmp = randint0(Go_no_JuuJou);
5424 for (i = 0; i < 9; i ++){
5425 energy_result += tmp % 5;
5429 return (s16b)(energy_result + tmp);
5434 * @brief 射撃武器の攻撃に必要な基本消費エネルギーを返す/Return bow energy
5435 * @param sval 射撃武器のアイテム副分類ID
5436 * @return 消費する基本エネルギー
5438 ENERGY bow_energy(OBJECT_SUBTYPE_VALUE sval)
5440 ENERGY energy = 10000;
5442 /* Analyze the launcher */
5445 /* Sling and ammo */
5452 /* Short Bow and Arrow */
5459 /* Long Bow and Arrow */
5466 /* Bow of irresponsiblity and Arrow */
5473 /* Light Crossbow and Bolt */
5480 /* Heavy Crossbow and Bolt */
5495 int bow_tmul(OBJECT_SUBTYPE_VALUE sval)
5499 /* Analyze the launcher */
5502 /* Sling and ammo */
5509 /* Short Bow and Arrow */
5516 /* Long Bow and Arrow */
5523 /* Bow of irresponsiblity and Arrow */
5530 /* Light Crossbow and Bolt */
5537 /* Heavy Crossbow and Bolt */
5549 * Return alignment title
5551 cptr your_alignment(void)
5554 if (p_ptr->align > 150) return "大善";
5555 else if (p_ptr->align > 50) return "中善";
5556 else if (p_ptr->align > 10) return "小善";
5557 else if (p_ptr->align > -11) return "中立";
5558 else if (p_ptr->align > -51) return "小悪";
5559 else if (p_ptr->align > -151) return "中悪";
5562 if (p_ptr->align > 150) return "Lawful";
5563 else if (p_ptr->align > 50) return "Good";
5564 else if (p_ptr->align > 10) return "Neutral Good";
5565 else if (p_ptr->align > -11) return "Neutral";
5566 else if (p_ptr->align > -51) return "Neutral Evil";
5567 else if (p_ptr->align > -151) return "Evil";
5568 else return "Chaotic";
5574 * Return proficiency level of weapons and misc. skills (except riding)
5576 int weapon_exp_level(int weapon_exp)
5578 if (weapon_exp < WEAPON_EXP_BEGINNER) return EXP_LEVEL_UNSKILLED;
5579 else if (weapon_exp < WEAPON_EXP_SKILLED) return EXP_LEVEL_BEGINNER;
5580 else if (weapon_exp < WEAPON_EXP_EXPERT) return EXP_LEVEL_SKILLED;
5581 else if (weapon_exp < WEAPON_EXP_MASTER) return EXP_LEVEL_EXPERT;
5582 else return EXP_LEVEL_MASTER;
5587 * Return proficiency level of riding
5589 int riding_exp_level(int riding_exp)
5591 if (riding_exp < RIDING_EXP_BEGINNER) return EXP_LEVEL_UNSKILLED;
5592 else if (riding_exp < RIDING_EXP_SKILLED) return EXP_LEVEL_BEGINNER;
5593 else if (riding_exp < RIDING_EXP_EXPERT) return EXP_LEVEL_SKILLED;
5594 else if (riding_exp < RIDING_EXP_MASTER) return EXP_LEVEL_EXPERT;
5595 else return EXP_LEVEL_MASTER;
5600 * Return proficiency level of spells
5602 int spell_exp_level(int spell_exp)
5604 if (spell_exp < SPELL_EXP_BEGINNER) return EXP_LEVEL_UNSKILLED;
5605 else if (spell_exp < SPELL_EXP_SKILLED) return EXP_LEVEL_BEGINNER;
5606 else if (spell_exp < SPELL_EXP_EXPERT) return EXP_LEVEL_SKILLED;
5607 else if (spell_exp < SPELL_EXP_MASTER) return EXP_LEVEL_EXPERT;
5608 else return EXP_LEVEL_MASTER;
5613 * Display a rumor and apply its effects
5616 IDX rumor_num(char *zz, IDX max_idx)
5618 if (strcmp(zz, "*") == 0) return randint1(max_idx - 1);
5619 return (IDX)atoi(zz);
5622 cptr rumor_bind_name(char *base, cptr fullname)
5626 s = strstr(base, "{Name}");
5630 v = format("%s%s%s", base, fullname, (s + 6));
5640 void display_rumor(bool ex)
5648 if (randint0(3) == 0) section = 1;
5651 err = _(get_rnd_line_jonly("rumors_j.txt", section, Rumor, 10),
5652 get_rnd_line("rumors.txt", section, Rumor));
5653 if (err) strcpy(Rumor, _("嘘の噂もある。", "Some rumors are wrong."));
5657 if (strncmp(Rumor, "R:", 2) == 0)
5660 cptr rumor_msg = NULL;
5661 cptr rumor_eff_format = NULL;
5662 char fullname[1024] = "";
5664 if (tokenize(Rumor + 2, 3, zz, TOKENIZE_CHECKQUOTE) == 3)
5666 if (strcmp(zz[0], "ARTIFACT") == 0)
5670 object_type *q_ptr = &forge;
5671 artifact_type *a_ptr;
5675 a_idx = rumor_num(zz[1], max_a_idx);
5677 a_ptr = &a_info[a_idx];
5678 if (a_ptr->name) break;
5681 k_idx = lookup_kind(a_ptr->tval, a_ptr->sval);
5682 object_prep(q_ptr, k_idx);
5683 q_ptr->name1 = a_idx;
5684 q_ptr->ident = IDENT_STORE;
5685 object_desc(fullname, q_ptr, OD_NAME_ONLY);
5687 else if (strcmp(zz[0], "MONSTER") == 0)
5690 monster_race *r_ptr;
5694 r_idx = rumor_num(zz[1], max_r_idx);
5695 r_ptr = &r_info[r_idx];
5696 if (r_ptr->name) break;
5699 strcpy(fullname, r_name + r_ptr->name);
5701 /* Remember this monster */
5702 if (!r_ptr->r_sights)
5707 else if (strcmp(zz[0], "DUNGEON") == 0)
5710 dungeon_info_type *d_ptr;
5714 d_idx = rumor_num(zz[1], max_d_idx);
5715 d_ptr = &d_info[d_idx];
5716 if (d_ptr->name) break;
5719 strcpy(fullname, d_name + d_ptr->name);
5721 if (!max_dlv[d_idx])
5723 max_dlv[d_idx] = d_ptr->mindepth;
5724 rumor_eff_format = _("%sに帰還できるようになった。", "You can recall to %s.");
5727 else if (strcmp(zz[0], "TOWN") == 0)
5734 t_idx = rumor_num(zz[1], NO_TOWN);
5735 if (town[t_idx].name) break;
5738 strcpy(fullname, town[t_idx].name);
5740 visit = (1L << (t_idx - 1));
5741 if ((t_idx != SECRET_TOWN) && !(p_ptr->visit & visit))
5743 p_ptr->visit |= visit;
5744 rumor_eff_format = _("%sに行ったことがある気がする。", "You feel you have been to %s.");
5748 rumor_msg = rumor_bind_name(zz[2], fullname);
5749 msg_print(rumor_msg);
5750 if (rumor_eff_format)
5753 msg_format(rumor_eff_format, fullname);
5758 if (err) msg_print(_("この情報は間違っている。", "This information is wrong."));
5762 msg_format("%s", Rumor);