3 * @brief 雑多なその他の処理2 / effects of various "objects"
6 * Copyright (c) 1989 James E. Wilson, Robert A. Koeneke\n
7 * This software may be copied and distributed for educational, research, and\n
8 * not for profit purposes provided that this copyright and statement are\n
9 * included in all such copies.\n
10 * 2014 Deskull rearranged comment for Doxygen.
16 #include "object-curse.h"
18 #define REWARD_CHANCE 10
22 * @brief プレイヤーの経験値について整合性のためのチェックと調整を行う /
23 * Advance experience levels and print experience
26 void check_experience(void)
28 bool level_reward = FALSE;
29 bool level_mutation = FALSE;
30 bool level_inc_stat = FALSE;
31 bool android = (p_ptr->prace == RACE_ANDROID ? TRUE : FALSE);
32 PLAYER_LEVEL old_lev = p_ptr->lev;
34 /* Hack -- lower limit */
35 if (p_ptr->exp < 0) p_ptr->exp = 0;
36 if (p_ptr->max_exp < 0) p_ptr->max_exp = 0;
37 if (p_ptr->max_max_exp < 0) p_ptr->max_max_exp = 0;
39 /* Hack -- upper limit */
40 if (p_ptr->exp > PY_MAX_EXP) p_ptr->exp = PY_MAX_EXP;
41 if (p_ptr->max_exp > PY_MAX_EXP) p_ptr->max_exp = PY_MAX_EXP;
42 if (p_ptr->max_max_exp > PY_MAX_EXP) p_ptr->max_max_exp = PY_MAX_EXP;
44 /* Hack -- maintain "max" experience */
45 if (p_ptr->exp > p_ptr->max_exp) p_ptr->max_exp = p_ptr->exp;
47 /* Hack -- maintain "max max" experience */
48 if (p_ptr->max_exp > p_ptr->max_max_exp) p_ptr->max_max_exp = p_ptr->max_exp;
50 /* Redraw experience */
51 p_ptr->redraw |= (PR_EXP);
57 /* Lose levels while possible */
58 while ((p_ptr->lev > 1) &&
59 (p_ptr->exp < ((android ? player_exp_a : player_exp)[p_ptr->lev - 2] * p_ptr->expfact / 100L)))
64 /* Update some stuff */
65 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
67 /* Redraw some stuff */
68 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);
105 msg_format(_("レベル %d にようこそ。", "Welcome to level %d."), p_ptr->lev);
107 /* Update some stuff */
108 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
110 /* Redraw some stuff */
111 p_ptr->redraw |= (PR_LEV | PR_TITLE | PR_EXP);
113 p_ptr->window |= (PW_PLAYER | PW_SPELL | PW_INVEN);
125 if(!(p_ptr->max_plv % 10))
135 cnv_stat(p_ptr->stat_max[0], tmp);
136 prt(format(" a) 腕力 (現在値 %s)", tmp), 2, 14);
137 cnv_stat(p_ptr->stat_max[1], tmp);
138 prt(format(" b) 知能 (現在値 %s)", tmp), 3, 14);
139 cnv_stat(p_ptr->stat_max[2], tmp);
140 prt(format(" c) 賢さ (現在値 %s)", tmp), 4, 14);
141 cnv_stat(p_ptr->stat_max[3], tmp);
142 prt(format(" d) 器用 (現在値 %s)", tmp), 5, 14);
143 cnv_stat(p_ptr->stat_max[4], tmp);
144 prt(format(" e) 耐久 (現在値 %s)", tmp), 6, 14);
145 cnv_stat(p_ptr->stat_max[5], tmp);
146 prt(format(" f) 魅力 (現在値 %s)", tmp), 7, 14);
148 prt(" どの能力値を上げますか?", 1, 14);
150 cnv_stat(p_ptr->stat_max[0], tmp);
151 prt(format(" a) Str (cur %s)", tmp), 2, 14);
152 cnv_stat(p_ptr->stat_max[1], tmp);
153 prt(format(" b) Int (cur %s)", tmp), 3, 14);
154 cnv_stat(p_ptr->stat_max[2], tmp);
155 prt(format(" c) Wis (cur %s)", tmp), 4, 14);
156 cnv_stat(p_ptr->stat_max[3], tmp);
157 prt(format(" d) Dex (cur %s)", tmp), 5, 14);
158 cnv_stat(p_ptr->stat_max[4], tmp);
159 prt(format(" e) Con (cur %s)", tmp), 6, 14);
160 cnv_stat(p_ptr->stat_max[5], tmp);
161 prt(format(" f) Chr (cur %s)", tmp), 7, 14);
163 prt(" Which stat do you want to raise?", 1, 14);
168 if ((choice >= 'a') && (choice <= 'f')) break;
170 for(n = 0; n < 6; n++)
171 if (n != choice - 'a')
173 if (get_check(_("よろしいですか?", "Are you sure? "))) break;
175 do_inc_stat(choice - 'a');
178 else if(!(p_ptr->max_plv % 2))
179 do_inc_stat(randint0(6));
184 msg_print(_("あなたは変わった気がする...", "You feel different..."));
185 (void)gain_random_mutation(0);
186 level_mutation = FALSE;
190 * 報酬でレベルが上ると再帰的に check_experience() が
195 gain_level_reward(0);
196 level_reward = FALSE;
199 /* Update some stuff */
200 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
202 /* Redraw some stuff */
203 p_ptr->redraw |= (PR_LEV | PR_TITLE);
205 p_ptr->window |= (PW_PLAYER | PW_SPELL);
211 /* Load an autopick preference file */
212 if (old_lev != p_ptr->lev) autopick_load_pref(FALSE);
217 * @brief モンスターを倒した際の財宝svalを返す
218 * @param r_idx 倒したモンスターの種族ID
221 * Hack -- Return the "automatic coin type" of a monster race
222 * Used to allocate proper treasure when "Creeping coins" die
223 * Note the use of actual "monster names"
225 static int get_coin_type(MONRACE_IDX r_idx)
227 /* Analyze monsters */
230 case MON_COPPER_COINS: return 2;
231 case MON_SILVER_COINS: return 5;
232 case MON_GOLD_COINS: return 10;
233 case MON_MITHRIL_COINS:
234 case MON_MITHRIL_GOLEM: return 16;
235 case MON_ADAMANT_COINS: return 17;
244 * @brief オブジェクトがクロークかどうかを判定する /
245 * Hack -- determine if a template is Cloak
246 * @param k_idx 判定したいオブジェクトのベースアイテムID
247 * @return オブジェクトがクロークならばTRUEを返す
249 static bool kind_is_cloak(KIND_OBJECT_IDX k_idx)
251 object_kind *k_ptr = &k_info[k_idx];
253 /* Analyze the item type */
254 if (k_ptr->tval == TV_CLOAK)
259 /* Assume not good */
265 * @brief オブジェクトが竿状武器かどうかを判定する /
266 * Hack -- determine if a template is Polearm
267 * @param k_idx 判定したいオブジェクトのベースアイテムID
268 * @return オブジェクトが竿状武器ならばTRUEを返す
270 static bool kind_is_polearm(KIND_OBJECT_IDX k_idx)
272 object_kind *k_ptr = &k_info[k_idx];
274 /* Analyze the item type */
275 if (k_ptr->tval == TV_POLEARM)
280 /* Assume not good */
286 * @brief オブジェクトが剣かどうかを判定する /
287 * Hack -- determine if a template is Sword
288 * @param k_idx 判定したいオブジェクトのベースアイテムID
289 * @return オブジェクトが剣ならばTRUEを返す
291 static bool kind_is_sword(KIND_OBJECT_IDX k_idx)
293 object_kind *k_ptr = &k_info[k_idx];
295 /* Analyze the item type */
296 if ((k_ptr->tval == TV_SWORD) && (k_ptr->sval > 2))
301 /* Assume not good */
307 * @brief オブジェクトが魔法書かどうかを判定する /
308 * Hack -- determine if a template is Book
309 * @param k_idx 判定したいオブジェクトのベースアイテムID
310 * @return オブジェクトが魔法書ならばTRUEを返す
312 static bool kind_is_book(KIND_OBJECT_IDX k_idx)
314 object_kind *k_ptr = &k_info[k_idx];
316 /* Analyze the item type */
317 if ((k_ptr->tval >= TV_LIFE_BOOK) && (k_ptr->tval <= TV_CRUSADE_BOOK))
322 /* Assume not good */
328 * @brief オブジェクトがベースアイテム時点でGOODかどうかを判定する /
329 * Hack -- determine if a template is Good book
330 * @param k_idx 判定したいオブジェクトのベースアイテムID
331 * @return オブジェクトがベースアイテム時点でGOODなアイテムならばTRUEを返す
333 static bool kind_is_good_book(KIND_OBJECT_IDX k_idx)
335 object_kind *k_ptr = &k_info[k_idx];
337 /* Analyze the item type */
338 if ((k_ptr->tval >= TV_LIFE_BOOK) && (k_ptr->tval <= TV_CRUSADE_BOOK) && (k_ptr->tval != TV_ARCANE_BOOK) && (k_ptr->sval > 1))
343 /* Assume not good */
349 * @brief オブジェクトが鎧かどうかを判定する /
350 * Hack -- determine if a template is Armor
351 * @param k_idx 判定したいオブジェクトのベースアイテムID
352 * @return オブジェクトが鎧ならばTRUEを返す
354 static bool kind_is_armor(KIND_OBJECT_IDX k_idx)
356 object_kind *k_ptr = &k_info[k_idx];
358 /* Analyze the item type */
359 if (k_ptr->tval == TV_HARD_ARMOR)
364 /* Assume not good */
370 * @brief オブジェクトが打撃武器かどうかを判定する /
371 * Hack -- determine if a template is hafted weapon
372 * @param k_idx 判定したいオブジェクトのベースアイテムID
373 * @return オブジェクトが打撃武器ならばTRUEを返す
375 static bool kind_is_hafted(KIND_OBJECT_IDX k_idx)
377 object_kind *k_ptr = &k_info[k_idx];
379 /* Analyze the item type */
380 if (k_ptr->tval == TV_HAFTED)
385 /* Assume not good */
390 * @brief クエストを達成状態にする /
391 * @param quest_num 達成状態にしたいクエストのID
394 void complete_quest(QUEST_IDX quest_num)
396 quest_type* const q_ptr = &quest[quest_num];
400 case QUEST_TYPE_RANDOM:
401 if (record_rand_quest) do_cmd_write_nikki(NIKKI_RAND_QUEST_C, quest_num, NULL);
404 if (record_fix_quest) do_cmd_write_nikki(NIKKI_FIX_QUEST_C, quest_num, NULL);
408 q_ptr->status = QUEST_STATUS_COMPLETED;
409 q_ptr->complev = (byte)p_ptr->lev;
411 q_ptr->comptime = playtime;
413 if (!(q_ptr->flags & QUEST_FLAG_SILENT))
415 play_music(TERM_XTRA_MUSIC_BASIC, MUSIC_BASIC_QUEST_CLEAR);
416 msg_print(_("クエストを達成した!", "You just completed your quest!"));
422 * @brief 現在フロアに残っている敵モンスターの数を返す /
423 * @return 現在の敵モンスターの数
425 static MONSTER_NUMBER count_all_hostile_monsters(void)
428 MONSTER_NUMBER number_mon = 0;
430 for (x = 0; x < cur_wid; ++ x)
432 for (y = 0; y < cur_hgt; ++ y)
434 MONSTER_IDX m_idx = cave[y][x].m_idx;
436 if (m_idx > 0 && is_hostile(&m_list[m_idx]))
447 * @brief 特定の敵を倒した際にクエスト達成処理 /
448 * Check for "Quest" completion when a quest monster is killed or charmed.
449 * @param m_ptr 撃破したモンスターの構造体参照ポインタ
452 void check_quest_completion(monster_type *m_ptr)
457 bool create_stairs = FALSE;
463 /* Get the location */
468 quest_num = p_ptr->inside_quest;
470 /* Search for an active quest on this dungeon level */
475 for (i = max_q_idx - 1; i > 0; i--)
477 quest_type* const q_ptr = &quest[i];
479 /* Quest is not active */
480 if (q_ptr->status != QUEST_STATUS_TAKEN)
483 /* Quest is not a dungeon quest */
484 if (q_ptr->flags & QUEST_FLAG_PRESET)
487 /* Quest is not on this level */
488 if ((q_ptr->level != dun_level) &&
489 (q_ptr->type != QUEST_TYPE_KILL_ANY_LEVEL))
492 /* Not a "kill monster" quest */
493 if ((q_ptr->type == QUEST_TYPE_FIND_ARTIFACT) ||
494 (q_ptr->type == QUEST_TYPE_FIND_EXIT))
497 /* Interesting quest */
498 if ((q_ptr->type == QUEST_TYPE_KILL_NUMBER) ||
499 (q_ptr->type == QUEST_TYPE_TOWER) ||
500 (q_ptr->type == QUEST_TYPE_KILL_ALL))
503 /* Interesting quest */
504 if (((q_ptr->type == QUEST_TYPE_KILL_LEVEL) ||
505 (q_ptr->type == QUEST_TYPE_KILL_ANY_LEVEL) ||
506 (q_ptr->type == QUEST_TYPE_RANDOM)) &&
507 (q_ptr->r_idx == m_ptr->r_idx))
514 /* Handle the current quest */
515 if (quest_num && (quest[quest_num].status == QUEST_STATUS_TAKEN))
518 quest_type* const q_ptr = &quest[quest_num];
522 case QUEST_TYPE_KILL_NUMBER:
526 if (q_ptr->cur_num >= q_ptr->num_mon)
528 complete_quest(quest_num);
534 case QUEST_TYPE_KILL_ALL:
536 if (!is_hostile(m_ptr)) break;
538 if (count_all_hostile_monsters() == 1)
540 if (q_ptr->flags & QUEST_FLAG_SILENT)
542 q_ptr->status = QUEST_STATUS_FINISHED;
546 complete_quest(quest_num);
551 case QUEST_TYPE_KILL_LEVEL:
552 case QUEST_TYPE_RANDOM:
554 /* Only count valid monsters */
555 if (q_ptr->r_idx != m_ptr->r_idx)
560 if (q_ptr->cur_num >= q_ptr->max_num)
562 complete_quest(quest_num);
564 if (!(q_ptr->flags & QUEST_FLAG_PRESET))
566 create_stairs = TRUE;
567 p_ptr->inside_quest = 0;
570 /* Finish the two main quests without rewarding */
571 if ((quest_num == QUEST_OBERON) || (quest_num == QUEST_SERPENT))
573 q_ptr->status = QUEST_STATUS_FINISHED;
576 if (q_ptr->type == QUEST_TYPE_RANDOM)
579 q_ptr->status = QUEST_STATUS_FINISHED;
584 case QUEST_TYPE_KILL_ANY_LEVEL:
587 if (q_ptr->cur_num >= q_ptr->max_num)
589 complete_quest(quest_num);
594 case QUEST_TYPE_TOWER:
596 if (!is_hostile(m_ptr)) break;
598 if (count_all_hostile_monsters() == 1)
600 q_ptr->status = QUEST_STATUS_STAGE_COMPLETED;
602 if((quest[QUEST_TOWER1].status == QUEST_STATUS_STAGE_COMPLETED) &&
603 (quest[QUEST_TOWER2].status == QUEST_STATUS_STAGE_COMPLETED) &&
604 (quest[QUEST_TOWER3].status == QUEST_STATUS_STAGE_COMPLETED))
607 complete_quest(QUEST_TOWER1);
615 /* Create a magical staircase */
621 while (cave_perma_bold(y, x) || cave[y][x].o_idx || (cave[y][x].info & CAVE_OBJECT) )
623 /* Pick a location */
624 scatter(&ny, &nx, y, x, 1, 0);
630 /* Explain the staircase */
631 msg_print(_("魔法の階段が現れた...", "A magical staircase appears..."));
633 /* Create stairs down */
634 cave_set_feat(y, x, feat_down_stair);
636 /* Remember to update everything */
637 p_ptr->update |= (PU_FLOW);
647 for (i = 0; i < (dun_level / 15)+1; i++)
649 /* Get local object */
653 /* Make a great object */
654 make_object(o_ptr, AM_GOOD | AM_GREAT);
656 /* Drop it in the dungeon */
657 (void)drop_near(o_ptr, -1, y, x);
663 * @brief 特定のアーティファクトを入手した際のクエスト達成処理 /
664 * Check for "Quest" completion when a quest monster is killed or charmed.
665 * @param o_ptr 入手したオブジェクトの構造体参照ポインタ
668 void check_find_art_quest_completion(object_type *o_ptr)
671 /* Check if completed a quest */
672 for (i = 0; i < max_q_idx; i++)
674 if((quest[i].type == QUEST_TYPE_FIND_ARTIFACT) &&
675 (quest[i].status == QUEST_STATUS_TAKEN) &&
676 (quest[i].k_idx == o_ptr->name1))
685 * @brief モンスターを撃破した際の述語メッセージを返す /
686 * Return monster death string
687 * @param r_ptr 撃破されたモンスターの種族情報を持つ構造体の参照ポインタ
688 * @return 撃破されたモンスターの述語
690 cptr extract_note_dies(monster_race *r_ptr)
692 /* Some monsters get "destroyed" */
693 if (!monster_living(r_ptr))
697 for (i = 0; i < 4; i++)
699 if (r_ptr->blow[i].method == RBM_EXPLODE)
701 return _("は爆発して粉々になった。", " explodes into tiny shreds.");
704 return _("を倒した。", " is destroyed.");
707 /* Assume a default death */
708 return _("は死んだ。", " dies.");
713 * @brief モンスターが死亡した時の処理 /
714 * Handle the "death" of a monster.
715 * @param m_idx 死亡したモンスターのID
716 * @param drop_item TRUEならばモンスターのドロップ処理を行う
717 * @return 撃破されたモンスターの述語
720 * Disperse treasures centered at the monster location based on the
721 * various flags contained in the monster flags fields.
722 * Check for "Quest" completion when a quest monster is killed.
723 * Note that only the player can induce "monster_death()" on Uniques.
724 * Thus (for now) all Quest monsters should be Uniques.
725 * Note that monsters can now carry objects, and when a monster dies,
726 * it drops all of its objects, which may disappear in crowded rooms.
729 void monster_death(MONSTER_IDX m_idx, bool drop_item)
738 monster_type *m_ptr = &m_list[m_idx];
740 monster_race *r_ptr = &r_info[m_ptr->r_idx];
742 bool visible = ((m_ptr->ml && !p_ptr->image) || (r_ptr->flags1 & RF1_UNIQUE));
746 bool do_gold = (!(r_ptr->flags1 & RF1_ONLY_ITEM));
747 bool do_item = (!(r_ptr->flags1 & RF1_ONLY_GOLD));
748 bool cloned = (m_ptr->smart & SM_CLONED) ? TRUE : FALSE;
749 int force_coin = get_coin_type(m_ptr->r_idx);
754 bool drop_chosen_item = drop_item && !cloned && !p_ptr->inside_arena
755 && !p_ptr->inside_battle && !is_pet(m_ptr);
757 /* The caster is dead? */
758 if (world_monster && world_monster == m_idx) world_monster = 0;
760 /* Notice changes in view */
761 if (r_ptr->flags7 & (RF7_LITE_MASK | RF7_DARK_MASK))
763 /* Update some things */
764 p_ptr->update |= (PU_MON_LITE);
767 /* Get the location */
771 if (record_named_pet && is_pet(m_ptr) && m_ptr->nickname)
775 monster_desc(m_name, m_ptr, MD_INDEF_VISIBLE);
776 do_cmd_write_nikki(NIKKI_NAMED_PET, 3, m_name);
779 /* Let monsters explode! */
780 for (i = 0; i < 4; i++)
782 if (r_ptr->blow[i].method == RBM_EXPLODE)
784 BIT_FLAGS flg = PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL;
785 EFFECT_ID typ = mbe_info[r_ptr->blow[i].effect].explode_type;
786 DICE_NUMBER d_dice = r_ptr->blow[i].d_dice;
787 DICE_SID d_side = r_ptr->blow[i].d_side;
788 HIT_POINT damage = damroll(d_dice, d_side);
790 project(m_idx, 3, y, x, damage, typ, flg, -1);
795 if (m_ptr->mflag2 & MFLAG2_CHAMELEON)
797 choose_new_monster(m_idx, TRUE, MON_CHAMELEON);
798 r_ptr = &r_info[m_ptr->r_idx];
801 /* Check for quest completion */
802 check_quest_completion(m_ptr);
804 /* Handle the possibility of player vanquishing arena combatant -KMW- */
805 if (p_ptr->inside_arena && !is_pet(m_ptr))
807 p_ptr->exit_bldg = TRUE;
809 if (p_ptr->arena_number > MAX_ARENA_MONS)
811 msg_print(_("素晴らしい!君こそ真の勝利者だ。", "You are a Genuine Champion!"));
815 msg_print(_("勝利!チャンピオンへの道を進んでいる。", "Victorious! You're on your way to becoming Champion."));
818 if (arena_info[p_ptr->arena_number].tval)
820 /* Get local object */
823 /* Prepare to make a prize */
824 object_prep(q_ptr, lookup_kind(arena_info[p_ptr->arena_number].tval, arena_info[p_ptr->arena_number].sval));
826 apply_magic(q_ptr, object_level, AM_NO_FIXED_ART);
828 /* Drop it in the dungeon */
829 (void)drop_near(q_ptr, -1, y, x);
832 if (p_ptr->arena_number > MAX_ARENA_MONS) p_ptr->arena_number++;
833 p_ptr->arena_number++;
838 /* Extract monster name */
839 monster_desc(m_name, m_ptr, MD_IGNORE_HALLU | MD_ASSUME_VISIBLE | MD_INDEF_VISIBLE);
841 do_cmd_write_nikki(NIKKI_ARENA, p_ptr->arena_number, m_name);
845 if (m_idx == p_ptr->riding)
847 if (rakuba(-1, FALSE))
849 msg_print(_("地面に落とされた。", "You have fallen from your riding pet."));
853 /* Drop a dead corpse? */
854 if (one_in_(r_ptr->flags1 & RF1_UNIQUE ? 1 : 4) &&
855 (r_ptr->flags9 & (RF9_DROP_CORPSE | RF9_DROP_SKELETON)) &&
856 !(p_ptr->inside_arena || p_ptr->inside_battle || cloned || ((m_ptr->r_idx == today_mon) && is_pet(m_ptr))))
858 /* Assume skeleton */
862 * We cannot drop a skeleton? Note, if we are in this check,
863 * we *know* we can drop at least a corpse or a skeleton
865 if (!(r_ptr->flags9 & RF9_DROP_SKELETON))
867 else if ((r_ptr->flags9 & RF9_DROP_CORPSE) && (r_ptr->flags1 & RF1_UNIQUE))
870 /* Else, a corpse is more likely unless we did a "lot" of damage */
871 else if (r_ptr->flags9 & RF9_DROP_CORPSE)
873 /* Lots of damage in one blow */
874 if ((0 - ((m_ptr->maxhp) / 4)) > m_ptr->hp)
876 if (one_in_(5)) corpse = TRUE;
880 if (!one_in_(5)) corpse = TRUE;
884 /* Get local object */
887 /* Prepare to make an object */
888 object_prep(q_ptr, lookup_kind(TV_CORPSE, (corpse ? SV_CORPSE : SV_SKELETON)));
890 apply_magic(q_ptr, object_level, AM_NO_FIXED_ART);
892 q_ptr->pval = m_ptr->r_idx;
894 /* Drop it in the dungeon */
895 (void)drop_near(q_ptr, -1, y, x);
898 /* Drop objects being carried */
899 monster_drop_carried_objects(m_ptr);
901 if (r_ptr->flags1 & RF1_DROP_GOOD) mo_mode |= AM_GOOD;
902 if (r_ptr->flags1 & RF1_DROP_GREAT) mo_mode |= AM_GREAT;
904 switch (m_ptr->r_idx)
906 case MON_PINK_HORROR:
907 /* Pink horrors are replaced with 2 Blue horrors */
908 if (!(p_ptr->inside_arena || p_ptr->inside_battle))
912 for (i = 0; i < 2; i++)
915 bool pet = is_pet(m_ptr);
918 if (pet) mode |= PM_FORCE_PET;
920 if (summon_specific((pet ? -1 : m_idx), wy, wx, 100, SUMMON_BLUE_HORROR, mode))
922 if (player_can_see_bold(wy, wx))
928 msg_print(_("ピンク・ホラーは分裂した!", "The Pink horror divides!"));
932 case MON_BLOODLETTER:
933 /* Bloodletters of Khorne may drop a blade of chaos */
934 if (drop_chosen_item && (randint1(100) < 15))
936 /* Get local object */
939 /* Prepare to make a Blade of Chaos */
940 object_prep(q_ptr, lookup_kind(TV_SWORD, SV_BLADE_OF_CHAOS));
942 apply_magic(q_ptr, object_level, AM_NO_FIXED_ART | mo_mode);
944 /* Drop it in the dungeon */
945 (void)drop_near(q_ptr, -1, y, x);
950 if (drop_chosen_item && (dun_level > 9))
952 /* Get local object */
956 /* Activate restriction */
957 if ((dun_level > 49) && one_in_(5))
958 get_obj_num_hook = kind_is_good_book;
960 get_obj_num_hook = kind_is_book;
963 make_object(q_ptr, mo_mode);
965 /* Drop it in the dungeon */
966 (void)drop_near(q_ptr, -1, y, x);
972 * Mega^3-hack: killing a 'Warrior of the Dawn' is likely to
973 * spawn another in the fallen one's place!
975 if (!p_ptr->inside_arena && !p_ptr->inside_battle)
979 POSITION wy = y, wx = x;
981 bool pet = is_pet(m_ptr);
985 scatter(&wy, &wx, y, x, 20, 0);
987 while (!(in_bounds(wy, wx) && cave_empty_bold2(wy, wx)) && --attempts);
992 if (pet) mode |= PM_FORCE_PET;
994 if (summon_specific((pet ? -1 : m_idx), wy, wx, 100, SUMMON_DAWN, mode))
996 if (player_can_see_bold(wy, wx))
997 msg_print(_("新たな戦士が現れた!", "A new warrior steps forth!"));
1005 /* One more ultra-hack: An Unmaker goes out with a big bang! */
1007 BIT_FLAGS flg = PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL;
1008 (void)project(m_idx, 6, y, x, 100, GF_CHAOS, flg, -1);
1012 case MON_UNICORN_ORD:
1015 /* Reward for "lazy" player */
1016 if (p_ptr->pseikaku == SEIKAKU_NAMAKE)
1018 ARTIFACT_IDX a_idx = 0;
1019 artifact_type *a_ptr = NULL;
1021 if (!drop_chosen_item) break;
1025 switch (randint0(3))
1028 a_idx = ART_NAMAKE_HAMMER;
1031 a_idx = ART_NAMAKE_BOW;
1034 a_idx = ART_NAMAKE_ARMOR;
1038 a_ptr = &a_info[a_idx];
1040 while (a_ptr->cur_num);
1042 /* Create the artifact */
1043 if (create_named_art(a_idx, y, x))
1047 /* Hack -- Memorize location of artifact in saved floors */
1048 if (character_dungeon) a_ptr->floor_id = p_ptr->floor_id;
1050 else if (!preserve_mode) a_ptr->cur_num = 1;
1055 if (!drop_chosen_item) break;
1057 /* Get local object */
1060 /* Mega-Hack -- Prepare to make "Grond" */
1061 object_prep(q_ptr, lookup_kind(TV_HAFTED, SV_GROND));
1063 /* Mega-Hack -- Mark this item as "Grond" */
1064 q_ptr->name1 = ART_GROND;
1066 /* Mega-Hack -- Actually create "Grond" */
1067 apply_magic(q_ptr, -1, AM_GOOD | AM_GREAT);
1069 /* Drop it in the dungeon */
1070 (void)drop_near(q_ptr, -1, y, x);
1072 /* Get local object */
1075 /* Mega-Hack -- Prepare to make "Chaos" */
1076 object_prep(q_ptr, lookup_kind(TV_CROWN, SV_CHAOS));
1078 /* Mega-Hack -- Mark this item as "Chaos" */
1079 q_ptr->name1 = ART_CHAOS;
1081 /* Mega-Hack -- Actually create "Chaos" */
1082 apply_magic(q_ptr, -1, AM_GOOD | AM_GREAT);
1084 /* Drop it in the dungeon */
1085 (void)drop_near(q_ptr, -1, y, x);
1088 case MON_B_DEATH_SWORD:
1089 if (drop_chosen_item)
1091 /* Get local object */
1094 /* Prepare to make a broken sword */
1095 object_prep(q_ptr, lookup_kind(TV_SWORD, randint1(2)));
1097 /* Drop it in the dungeon */
1098 (void)drop_near(q_ptr, -1, y, x);
1104 if (drop_chosen_item && ((m_ptr->r_idx == MON_A_GOLD) ||
1105 ((m_ptr->r_idx == MON_A_SILVER) && (r_ptr->r_akills % 5 == 0))))
1107 /* Get local object */
1110 /* Prepare to make a Can of Toys */
1111 object_prep(q_ptr, lookup_kind(TV_CHEST, SV_CHEST_KANDUME));
1113 apply_magic(q_ptr, object_level, AM_NO_FIXED_ART);
1115 /* Drop it in the dungeon */
1116 (void)drop_near(q_ptr, -1, y, x);
1122 BIT_FLAGS flg = PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL;
1123 (void)project(m_idx, 3, y, x, damroll(20, 10), GF_FIRE, flg, -1);
1128 if (!drop_chosen_item) break;
1130 switch (r_ptr->d_char)
1135 /* Get local object */
1139 /* Activate restriction */
1140 get_obj_num_hook = kind_is_cloak;
1143 make_object(q_ptr, mo_mode);
1145 /* Drop it in the dungeon */
1146 (void)drop_near(q_ptr, -1, y, x);
1153 /* Get local object */
1157 /* Activate restriction */
1158 get_obj_num_hook = kind_is_polearm;
1160 /* Make a poleweapon */
1161 make_object(q_ptr, mo_mode);
1163 /* Drop it in the dungeon */
1164 (void)drop_near(q_ptr, -1, y, x);
1171 /* Get local object */
1175 /* Activate restriction */
1176 get_obj_num_hook = kind_is_armor;
1178 /* Make a hard armor */
1179 make_object(q_ptr, mo_mode);
1181 /* Drop it in the dungeon */
1182 (void)drop_near(q_ptr, -1, y, x);
1189 /* Get local object */
1193 /* Activate restriction */
1194 get_obj_num_hook = kind_is_hafted;
1196 /* Make a hafted weapon */
1197 make_object(q_ptr, mo_mode);
1199 /* Drop it in the dungeon */
1200 (void)drop_near(q_ptr, -1, y, x);
1205 if (m_ptr->r_idx != MON_STORMBRINGER)
1207 /* Get local object */
1211 /* Activate restriction */
1212 get_obj_num_hook = kind_is_sword;
1215 make_object(q_ptr, mo_mode);
1217 /* Drop it in the dungeon */
1218 (void)drop_near(q_ptr, -1, y, x);
1225 /* Mega-Hack -- drop fixed items */
1226 if (drop_chosen_item)
1228 ARTIFACT_IDX a_idx = 0;
1231 for(i = 0; i < 4; i++)
1233 if(!r_ptr->artifact_id[i]) break;
1234 a_idx = r_ptr->artifact_id[i];
1235 chance = r_ptr->artifact_percent[i];
1238 if ((a_idx > 0) && ((randint0(100) < chance) || p_ptr->wizard))
1240 artifact_type *a_ptr = &a_info[a_idx];
1242 if (!a_ptr->cur_num)
1244 /* Create the artifact */
1245 if (create_named_art(a_idx, y, x))
1249 /* Hack -- Memorize location of artifact in saved floors */
1250 if (character_dungeon) a_ptr->floor_id = p_ptr->floor_id;
1252 else if (!preserve_mode) a_ptr->cur_num = 1;
1256 if ((r_ptr->flags7 & RF7_GUARDIAN) && (d_info[dungeon_type].final_guardian == m_ptr->r_idx))
1258 KIND_OBJECT_IDX k_idx = d_info[dungeon_type].final_object ? d_info[dungeon_type].final_object
1259 : lookup_kind(TV_SCROLL, SV_SCROLL_ACQUIREMENT);
1261 if (d_info[dungeon_type].final_artifact)
1263 a_idx = d_info[dungeon_type].final_artifact;
1264 artifact_type *a_ptr = &a_info[a_idx];
1266 if (!a_ptr->cur_num)
1268 /* Create the artifact */
1269 if (create_named_art(a_idx, y, x))
1273 /* Hack -- Memorize location of artifact in saved floors */
1274 if (character_dungeon) a_ptr->floor_id = p_ptr->floor_id;
1276 else if (!preserve_mode) a_ptr->cur_num = 1;
1278 /* Prevent rewarding both artifact and "default" object */
1279 if (!d_info[dungeon_type].final_object) k_idx = 0;
1285 /* Get local object */
1288 /* Prepare to make a reward */
1289 object_prep(q_ptr, k_idx);
1291 apply_magic(q_ptr, object_level, AM_NO_FIXED_ART | AM_GOOD);
1293 /* Drop it in the dungeon */
1294 (void)drop_near(q_ptr, -1, y, x);
1296 msg_format(_("あなたは%sを制覇した!", "You have conquered %s!"),d_name+d_info[dungeon_type].name);
1300 /* Determine how much we can drop */
1301 if ((r_ptr->flags1 & RF1_DROP_60) && (randint0(100) < 60)) number++;
1302 if ((r_ptr->flags1 & RF1_DROP_90) && (randint0(100) < 90)) number++;
1303 if (r_ptr->flags1 & RF1_DROP_1D2) number += damroll(1, 2);
1304 if (r_ptr->flags1 & RF1_DROP_2D2) number += damroll(2, 2);
1305 if (r_ptr->flags1 & RF1_DROP_3D2) number += damroll(3, 2);
1306 if (r_ptr->flags1 & RF1_DROP_4D2) number += damroll(4, 2);
1308 if (cloned && !(r_ptr->flags1 & RF1_UNIQUE))
1309 number = 0; /* Clones drop no stuff unless Cloning Pits */
1311 if (is_pet(m_ptr) || p_ptr->inside_battle || p_ptr->inside_arena)
1312 number = 0; /* Pets drop no stuff */
1313 if (!drop_item && (r_ptr->d_char != '$')) number = 0;
1315 if((r_ptr->flags2 & (RF2_MULTIPLY)) && (r_ptr->r_akills > 1024))
1316 number = 0; /* Limit of Multiply monster drop */
1318 /* Hack -- handle creeping coins */
1319 coin_type = force_coin;
1321 /* Average dungeon and monster levels */
1322 object_level = (dun_level + r_ptr->level) / 2;
1324 /* Drop some objects */
1325 for (j = 0; j < number; j++)
1327 /* Get local object */
1332 if (do_gold && (!do_item || (randint0(100) < 50)))
1334 /* Make some gold */
1335 if (!make_gold(q_ptr)) continue;
1343 /* Make an object */
1344 if (!make_object(q_ptr, mo_mode)) continue;
1349 /* Drop it in the dungeon */
1350 (void)drop_near(q_ptr, -1, y, x);
1353 /* Reset the object level */
1354 object_level = base_level;
1356 /* Reset "coin" type */
1360 /* Take note of any dropped treasure */
1361 if (visible && (dump_item || dump_gold))
1363 /* Take notes on treasure */
1364 lore_treasure(m_idx, dump_item, dump_gold);
1367 /* Only process "Quest Monsters" */
1368 if (!(r_ptr->flags1 & RF1_QUESTOR)) return;
1369 if (p_ptr->inside_battle) return;
1372 if ((m_ptr->r_idx == MON_SERPENT) && !cloned)
1375 p_ptr->total_winner = TRUE;
1377 /* Redraw the "title" */
1378 p_ptr->redraw |= (PR_TITLE);
1380 play_music(TERM_XTRA_MUSIC_BASIC, MUSIC_BASIC_FINAL_QUEST_CLEAR);
1382 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, _("見事に変愚蛮怒の勝利者となった!", "become *WINNER* of Hengband finely!"));
1384 if ((p_ptr->pclass == CLASS_CHAOS_WARRIOR) || (p_ptr->muta2 & MUT2_CHAOS_GIFT))
1386 msg_format(_("%sからの声が響いた。", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
1387 msg_print(_("『よくやった、定命の者よ!』", "'Thou art donst well, mortal!'"));
1390 /* Congratulations */
1391 msg_print(_("*** おめでとう ***", "*** CONGRATULATIONS ***"));
1392 msg_print(_("あなたはゲームをコンプリートしました。", "You have won the game!"));
1393 msg_print(_("準備が整ったら引退(自殺コマンド)しても結構です。", "You may retire (commit suicide) when you are ready."));
1398 * @brief モンスターに与えたダメージの修正処理 /
1399 * Modify the physical damage done to the monster.
1400 * @param m_ptr ダメージを受けるモンスターの構造体参照ポインタ
1401 * @param dam ダメージ基本値
1402 * @param is_psy_spear 攻撃手段が光の剣ならばTRUE
1403 * @return 修正を行った結果のダメージ量
1406 * (for example when it's invulnerable or shielded)
1407 * ToDo: Accept a damage-type to calculate the modified damage from
1408 * things like fire, frost, lightning, poison, ... attacks.
1409 * "type" is not yet used and should be 0.
1412 HIT_POINT mon_damage_mod(monster_type *m_ptr, HIT_POINT dam, bool is_psy_spear)
1414 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1416 if ((r_ptr->flagsr & RFR_RES_ALL) && dam > 0)
1419 if ((dam == 0) && one_in_(3)) dam = 1;
1422 if (MON_INVULNER(m_ptr))
1426 if (!p_ptr->blind && is_seen(m_ptr))
1428 msg_print(_("バリアを切り裂いた!", "The barrier is penetrated!"));
1431 else if (!one_in_(PENETRATE_INVULNERABILITY))
1441 * @brief モンスターに与えたダメージを元に経験値を加算する /
1442 * Calculate experience point to be get
1443 * @param dam 与えたダメージ量
1444 * @param m_ptr ダメージを与えたモンスターの構造体参照ポインタ
1448 * Even the 64 bit operation is not big enough to avoid overflaw
1449 * unless we carefully choose orders of multiplication and division.
1450 * Get the coefficient first, and multiply (potentially huge) base
1451 * experience point of a monster later.
1454 static void get_exp_from_mon(HIT_POINT dam, monster_type *m_ptr)
1456 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1463 if (!m_ptr->r_idx) return;
1464 if (is_pet(m_ptr) || p_ptr->inside_battle) return;
1467 * - Ratio of monster's level to player's level effects
1468 * - Varying speed effects
1469 * - Get a fraction in proportion of damage point
1471 new_exp = r_ptr->level * SPEED_TO_ENERGY(m_ptr->mspeed) * dam;
1474 div_l = (p_ptr->max_plv+2) * SPEED_TO_ENERGY(r_ptr->speed);
1476 /* Use (average maxhp * 2) as a denominator */
1477 if (!(r_ptr->flags1 & RF1_FORCE_MAXHP))
1478 s64b_mul(&div_h, &div_l, 0, r_ptr->hdice * (ironman_nightmare ? 2 : 1) * (r_ptr->hside + 1));
1480 s64b_mul(&div_h, &div_l, 0, r_ptr->hdice * (ironman_nightmare ? 2 : 1) * r_ptr->hside * 2);
1482 /* Special penalty in the wilderness */
1483 if (!dun_level && (!(r_ptr->flags8 & RF8_WILD_ONLY) || !(r_ptr->flags1 & RF1_UNIQUE)))
1484 s64b_mul(&div_h, &div_l, 0, 5);
1486 /* Do division first to prevent overflaw */
1487 s64b_div(&new_exp, &new_exp_frac, div_h, div_l);
1489 /* Special penalty for mutiply-monster */
1490 if ((r_ptr->flags2 & RF2_MULTIPLY) || (m_ptr->r_idx == MON_DAWN))
1492 int monnum_penarty = r_ptr->r_akills / 400;
1493 if (monnum_penarty > 8) monnum_penarty = 8;
1495 while (monnum_penarty--)
1498 s64b_RSHIFT(new_exp, new_exp_frac, 2);
1502 /* Special penalty for rest_and_shoot exp scum */
1503 if ((m_ptr->dealt_damage > m_ptr->max_maxhp) && (m_ptr->hp >= 0))
1505 int over_damage = m_ptr->dealt_damage / m_ptr->max_maxhp;
1506 if (over_damage > 32) over_damage = 32;
1508 while (over_damage--)
1511 s64b_mul(&new_exp, &new_exp_frac, 0, 9);
1512 s64b_div(&new_exp, &new_exp_frac, 0, 10);
1516 /* Finally multiply base experience point of the monster */
1517 s64b_mul(&new_exp, &new_exp_frac, 0, r_ptr->mexp);
1519 /* Gain experience */
1520 gain_exp_64(new_exp, new_exp_frac);
1525 * @brief モンスターのHPをダメージに応じて減算する /
1526 * Decreases monsters hit points, handling monster death.
1527 * @param dam 与えたダメージ量
1528 * @param m_idx ダメージを与えたモンスターのID
1529 * @param fear ダメージによってモンスターが恐慌状態に陥ったならばTRUEを返す
1530 * @param note モンスターが倒された際の特別なメッセージ述語
1534 * We return TRUE if the monster has been killed (and deleted).
1535 * We announce monster death (using an optional "death message"
1536 * if given, and a otherwise a generic killed/destroyed message).
1537 * Only "physical attacks" can induce the "You have slain" message.
1538 * Missile and Spell attacks will induce the "dies" message, or
1539 * various "specialized" messages. Note that "You have destroyed"
1540 * and "is destroyed" are synonyms for "You have slain" and "dies".
1541 * Hack -- unseen monsters yield "You have killed it." message.
1542 * Added fear (DGK) and check whether to print fear messages -CWS
1543 * Made name, sex, and capitalization generic -BEN-
1544 * As always, the "ghost" processing is a total hack.
1545 * Hack -- we "delay" fear messages by passing around a "fear" flag.
1546 * Consider decreasing monster experience over time, say,
1547 * by using "(m_exp * m_lev * (m_lev)) / (p_lev * (m_lev + n_killed))"
1548 * instead of simply "(m_exp * m_lev) / (p_lev)", to make the first
1549 * monster worth more than subsequent monsters. This would also need
1550 * to induce changes in the monster recall code.
1553 bool mon_take_hit(MONSTER_IDX m_idx, HIT_POINT dam, bool *fear, cptr note)
1555 monster_type *m_ptr = &m_list[m_idx];
1556 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1558 monster_type exp_mon;
1560 /* Innocent until proven otherwise */
1561 bool innocent = TRUE, thief = FALSE;
1565 (void)COPY(&exp_mon, m_ptr, monster_type);
1567 expdam = (m_ptr->hp > dam) ? dam : m_ptr->hp;
1569 get_exp_from_mon(expdam, &exp_mon);
1571 /* Genocided by chaos patron */
1572 if (!m_ptr->r_idx) m_idx = 0;
1574 /* Redraw (later) if needed */
1575 if (p_ptr->health_who == m_idx) p_ptr->redraw |= (PR_HEALTH);
1576 if (p_ptr->riding == m_idx) p_ptr->redraw |= (PR_UHEALTH);
1579 (void)set_monster_csleep(m_idx, 0);
1581 /* Hack - Cancel any special player stealth magics. -LM- */
1582 if (p_ptr->special_defense & NINJA_S_STEALTH)
1584 set_superstealth(FALSE);
1587 /* Genocided by chaos patron */
1588 if (!m_idx) return TRUE;
1593 m_ptr->dealt_damage += dam;
1594 if(m_ptr->dealt_damage > m_ptr->max_maxhp * 100) m_ptr->dealt_damage = m_ptr->max_maxhp * 100;
1597 msg_format( _("合計%d/%dのダメージを与えた。","You do %d (out of %d) damage."),
1598 m_ptr->dealt_damage, m_ptr->maxhp);
1601 /* It is dead now */
1606 if (r_info[m_ptr->r_idx].flags7 & RF7_TANUKI)
1608 /* You might have unmasked Tanuki first time */
1609 r_ptr = &r_info[m_ptr->r_idx];
1610 m_ptr->ap_r_idx = m_ptr->r_idx;
1611 if (r_ptr->r_sights < MAX_SHORT) r_ptr->r_sights++;
1614 if (m_ptr->mflag2 & MFLAG2_CHAMELEON)
1616 /* You might have unmasked Chameleon first time */
1617 r_ptr = real_r_ptr(m_ptr);
1618 if (r_ptr->r_sights < MAX_SHORT) r_ptr->r_sights++;
1621 if (!(m_ptr->smart & SM_CLONED))
1623 /* When the player kills a Unique, it stays dead */
1624 if (r_ptr->flags1 & RF1_UNIQUE)
1628 /* Mega-Hack -- Banor & Lupart */
1629 if ((m_ptr->r_idx == MON_BANOR) || (m_ptr->r_idx == MON_LUPART))
1631 r_info[MON_BANORLUPART].max_num = 0;
1632 r_info[MON_BANORLUPART].r_pkills++;
1633 r_info[MON_BANORLUPART].r_akills++;
1634 if (r_info[MON_BANORLUPART].r_tkills < MAX_SHORT) r_info[MON_BANORLUPART].r_tkills++;
1636 else if (m_ptr->r_idx == MON_BANORLUPART)
1638 r_info[MON_BANOR].max_num = 0;
1639 r_info[MON_BANOR].r_pkills++;
1640 r_info[MON_BANOR].r_akills++;
1641 if (r_info[MON_BANOR].r_tkills < MAX_SHORT) r_info[MON_BANOR].r_tkills++;
1642 r_info[MON_LUPART].max_num = 0;
1643 r_info[MON_LUPART].r_pkills++;
1644 r_info[MON_LUPART].r_akills++;
1645 if (r_info[MON_LUPART].r_tkills < MAX_SHORT) r_info[MON_LUPART].r_tkills++;
1649 /* When the player kills a Nazgul, it stays dead */
1650 else if (r_ptr->flags7 & RF7_NAZGUL) r_ptr->max_num--;
1653 /* Count all monsters killed */
1654 if (r_ptr->r_akills < MAX_SHORT) r_ptr->r_akills++;
1656 /* Recall even invisible uniques or winners */
1657 if ((m_ptr->ml && !p_ptr->image) || (r_ptr->flags1 & RF1_UNIQUE))
1659 /* Count kills this life */
1660 if ((m_ptr->mflag2 & MFLAG2_KAGE) && (r_info[MON_KAGE].r_pkills < MAX_SHORT)) r_info[MON_KAGE].r_pkills++;
1661 else if (r_ptr->r_pkills < MAX_SHORT) r_ptr->r_pkills++;
1663 /* Count kills in all lives */
1664 if ((m_ptr->mflag2 & MFLAG2_KAGE) && (r_info[MON_KAGE].r_tkills < MAX_SHORT)) r_info[MON_KAGE].r_tkills++;
1665 else if (r_ptr->r_tkills < MAX_SHORT) r_ptr->r_tkills++;
1667 /* Hack -- Auto-recall */
1668 monster_race_track(m_ptr->ap_r_idx);
1671 /* Extract monster name */
1672 monster_desc(m_name, m_ptr, MD_TRUE_NAME);
1674 /* Don't kill Amberites */
1675 if ((r_ptr->flags3 & RF3_AMBERITE) && one_in_(2))
1677 int curses = 1 + randint1(3);
1678 bool stop_ty = FALSE;
1681 msg_format(_("%^sは恐ろしい血の呪いをあなたにかけた!", "%^s puts a terrible blood curse on you!"), m_name);
1682 curse_equipment(100, 50);
1686 stop_ty = activate_ty_curse(stop_ty, &count);
1691 if (r_ptr->flags2 & RF2_CAN_SPEAK)
1693 char line_got[1024];
1695 /* Dump a message */
1696 if (!get_rnd_line(_("mondeath_j.txt", "mondeath.txt"), m_ptr->r_idx, line_got))
1698 msg_format("%^s %s", m_name, line_got);
1701 if (m_ptr->r_idx == MON_SERPENT)
1703 /* Make screen dump */
1704 screen_dump = make_screen_dump();
1709 if (!(d_info[dungeon_type].flags1 & DF1_BEGINNER))
1711 if (!dun_level && !ambush_flag && !p_ptr->inside_arena)
1713 chg_virtue(V_VALOUR, -1);
1715 else if (r_ptr->level > dun_level)
1717 if (randint1(10) <= (r_ptr->level - dun_level))
1718 chg_virtue(V_VALOUR, 1);
1720 if (r_ptr->level > 60)
1722 chg_virtue(V_VALOUR, 1);
1724 if (r_ptr->level >= 2 * (p_ptr->lev+1))
1725 chg_virtue(V_VALOUR, 2);
1728 if (r_ptr->flags1 & RF1_UNIQUE)
1730 if (r_ptr->flags3 & (RF3_EVIL | RF3_GOOD)) chg_virtue(V_HARMONY, 2);
1732 if (r_ptr->flags3 & RF3_GOOD)
1734 chg_virtue(V_UNLIFE, 2);
1735 chg_virtue(V_VITALITY, -2);
1738 if (one_in_(3)) chg_virtue(V_INDIVIDUALISM, -1);
1741 if (m_ptr->r_idx == MON_BEGGAR || m_ptr->r_idx == MON_LEPER)
1743 chg_virtue(V_COMPASSION, -1);
1746 if ((r_ptr->flags3 & RF3_GOOD) &&
1747 ((r_ptr->level) / 10 + (3 * dun_level) >= randint1(100)))
1748 chg_virtue(V_UNLIFE, 1);
1750 if (r_ptr->d_char == 'A')
1752 if (r_ptr->flags1 & RF1_UNIQUE)
1753 chg_virtue(V_FAITH, -2);
1754 else if ((r_ptr->level) / 10 + (3 * dun_level) >= randint1(100))
1756 if (r_ptr->flags3 & RF3_GOOD) chg_virtue(V_FAITH, -1);
1757 else chg_virtue(V_FAITH, 1);
1760 else if (r_ptr->flags3 & RF3_DEMON)
1762 if (r_ptr->flags1 & RF1_UNIQUE)
1763 chg_virtue(V_FAITH, 2);
1764 else if ((r_ptr->level) / 10 + (3 * dun_level) >= randint1(100))
1765 chg_virtue(V_FAITH, 1);
1768 if ((r_ptr->flags3 & RF3_UNDEAD) && (r_ptr->flags1 & RF1_UNIQUE))
1769 chg_virtue(V_VITALITY, 2);
1771 if (r_ptr->r_deaths)
1773 if (r_ptr->flags1 & RF1_UNIQUE)
1775 chg_virtue(V_HONOUR, 10);
1777 else if ((r_ptr->level) / 10 + (2 * dun_level) >= randint1(100))
1779 chg_virtue(V_HONOUR, 1);
1782 if ((r_ptr->flags2 & RF2_MULTIPLY) && (r_ptr->r_akills > 1000) && one_in_(10))
1784 chg_virtue(V_VALOUR, -1);
1787 for (i = 0; i < 4; i++)
1789 if (r_ptr->blow[i].d_dice != 0) innocent = FALSE; /* Murderer! */
1791 if ((r_ptr->blow[i].effect == RBE_EAT_ITEM)
1792 || (r_ptr->blow[i].effect == RBE_EAT_GOLD))
1794 thief = TRUE; /* Thief! */
1797 /* The new law says it is illegal to live in the dungeon */
1798 if (r_ptr->level != 0) innocent = FALSE;
1802 if (r_ptr->flags1 & RF1_UNIQUE)
1803 chg_virtue(V_JUSTICE, 3);
1804 else if (1+((r_ptr->level) / 10 + (2 * dun_level))
1806 chg_virtue(V_JUSTICE, 1);
1810 chg_virtue (V_JUSTICE, -1);
1813 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)))
1815 if (one_in_(4)) chg_virtue(V_NATURE, -1);
1818 if ((r_ptr->flags1 & RF1_UNIQUE) && record_destroy_uniq)
1822 sprintf(note_buf, "%s%s", r_name + r_ptr->name, (m_ptr->smart & SM_CLONED) ? "(クローン)" : "");
1824 sprintf(note_buf, "%s%s", r_name + r_ptr->name, (m_ptr->smart & SM_CLONED) ? "(Clone)" : "");
1826 do_cmd_write_nikki(NIKKI_UNIQUE, 0, note_buf);
1832 /* Death by Missile/Spell attack */
1835 msg_format("%^s%s", m_name, note);
1838 /* Death by physical attack -- invisible monster */
1839 else if (!m_ptr->ml)
1842 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
1843 msg_format("せっかくだから%sを殺した。", m_name);
1845 msg_format("%sを殺した。", m_name);
1847 msg_format("You have killed %s.", m_name);
1852 /* Death by Physical attack -- non-living monster */
1853 else if (!monster_living(r_ptr))
1855 bool explode = FALSE;
1857 for (i = 0; i < 4; i++)
1859 if (r_ptr->blow[i].method == RBM_EXPLODE) explode = TRUE;
1862 /* Special note at death */
1864 msg_format(_("%sは爆発して粉々になった。", "%^s explodes into tiny shreds."), m_name);
1868 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
1869 msg_format("せっかくだから%sを倒した。", m_name);
1871 msg_format("%sを倒した。", m_name);
1873 msg_format("You have destroyed %s.", m_name);
1878 /* Death by Physical attack -- living monster */
1882 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
1883 msg_format("せっかくだから%sを葬り去った。", m_name);
1885 msg_format("%sを葬り去った。", m_name);
1887 msg_format("You have slain %s.", m_name);
1891 if ((r_ptr->flags1 & RF1_UNIQUE) && !(m_ptr->smart & SM_CLONED) && !vanilla_town)
1893 for (i = 0; i < MAX_KUBI; i++)
1895 if ((kubi_r_idx[i] == m_ptr->r_idx) && !(m_ptr->mflag2 & MFLAG2_CHAMELEON))
1897 msg_format(_("%sの首には賞金がかかっている。", "There is a price on %s's head."), m_name);
1903 /* Generate treasure */
1904 monster_death(m_idx, TRUE);
1906 /* Mega hack : replace IKETA to BIKETAL */
1907 if ((m_ptr->r_idx == MON_IKETA) &&
1908 !(p_ptr->inside_arena || p_ptr->inside_battle))
1910 int dummy_y = m_ptr->fy;
1911 int dummy_x = m_ptr->fx;
1912 BIT_FLAGS mode = 0L;
1914 if (is_pet(m_ptr)) mode |= PM_FORCE_PET;
1917 delete_monster_idx(m_idx);
1919 if (summon_named_creature(0, dummy_y, dummy_x, MON_BIKETAL, mode))
1921 msg_print(_("「ハァッハッハッハ!!私がバイケタルだ!!」", "Uwa-hahaha! *I* am Biketal!"));
1927 delete_monster_idx(m_idx);
1930 get_exp_from_mon((long)exp_mon.max_maxhp*2, &exp_mon);
1935 /* Monster is dead */
1942 /* Mega-Hack -- Pain cancels fear */
1943 if (MON_MONFEAR(m_ptr) && (dam > 0))
1946 if (set_monster_monfear(m_idx, MON_MONFEAR(m_ptr) - randint1(dam)))
1953 /* Sometimes a monster gets scared by damage */
1954 if (!MON_MONFEAR(m_ptr) && !(r_ptr->flags3 & (RF3_NO_FEAR)))
1956 /* Percentage of fully healthy */
1957 int percentage = (100L * m_ptr->hp) / m_ptr->maxhp;
1960 * Run (sometimes) if at 10% or less of max hit points,
1961 * or (usually) when hit for half its current hit points
1963 if ((randint1(10) >= percentage) ||
1964 ((dam >= m_ptr->hp) && (randint0(100) < 80)))
1966 /* Hack -- note fear */
1969 /* Hack -- Add some timed fear */
1970 (void)set_monster_monfear(m_idx, (randint1(10) +
1971 (((dam >= m_ptr->hp) && (percentage > 7)) ?
1972 20 : ((11 - percentage) * 5))));
1979 if (p_ptr->riding && (p_ptr->riding == m_idx) && (dam > 0))
1983 /* Extract monster name */
1984 monster_desc(m_name, m_ptr, 0);
1986 if (m_ptr->hp > m_ptr->maxhp/3) dam = (dam + 1) / 2;
1987 if (rakuba((dam > 200) ? 200 : dam, FALSE))
1989 msg_format(_("%^sに振り落とされた!", "%^s has thrown you off!"), m_name);
2000 * @brief 現在のコンソール表示の縦横を返す。 /
2001 * Get term size and calculate screen size
2002 * @param wid_p コンソールの表示幅文字数を返す
2003 * @param hgt_p コンソールの表示行数を返す
2006 void get_screen_size(TERM_LEN *wid_p, TERM_LEN *hgt_p)
2008 Term_get_size(wid_p, hgt_p);
2009 *hgt_p -= ROW_MAP + 2;
2010 *wid_p -= COL_MAP + 2;
2011 if (use_bigtile) *wid_p /= 2;
2016 * @brief コンソール上におけるマップ表示の左上位置を返す /
2017 * Calculates current boundaries Called below and from "do_cmd_locate()".
2020 void panel_bounds_center(void)
2024 get_screen_size(&wid, &hgt);
2026 panel_row_max = panel_row_min + hgt - 1;
2027 panel_row_prt = panel_row_min - 1;
2028 panel_col_max = panel_col_min + wid - 1;
2029 panel_col_prt = panel_col_min - 13;
2034 * @brief コンソールのリサイズに合わせてマップを再描画する /
2035 * Map resizing whenever the main term changes size
2038 void resize_map(void)
2040 /* Only if the dungeon exists */
2041 if (!character_dungeon) return;
2043 /* Mega-Hack -- no panel yet */
2047 /* Reset the panels */
2048 panel_row_min = cur_hgt;
2049 panel_col_min = cur_wid;
2053 p_ptr->update |= (PU_TORCH | PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
2055 /* Forget lite/view */
2056 p_ptr->update |= (PU_UN_VIEW | PU_UN_LITE);
2058 /* Update lite/view */
2059 p_ptr->update |= (PU_VIEW | PU_LITE | PU_MON_LITE);
2061 /* Update monsters */
2062 p_ptr->update |= (PU_MONSTERS);
2064 /* Redraw everything */
2065 p_ptr->redraw |= (PR_WIPE | PR_BASIC | PR_EXTRA | PR_MAP | PR_EQUIPPY);
2067 /* Hack -- update */
2075 * Place the cursor on the player
2077 if (can_save) move_cursor_relative(p_ptr->y, p_ptr->x);
2084 * @brief コンソールを再描画する /
2085 * Redraw a term when it is resized
2088 void redraw_window(void)
2090 /* Only if the dungeon exists */
2091 if (!character_dungeon) return;
2093 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_SPELL | PW_PLAYER);
2095 p_ptr->window |= (PW_MESSAGE | PW_OVERHEAD | PW_DUNGEON | PW_MONSTER | PW_OBJECT);
2097 /* Hack -- update */
2106 * @brief フォーカスを当てるべきマップ描画の基準座標を指定する(サブルーチン)
2107 * @param dy 変更先のフロアY座標
2108 * @param dx 変更先のフロアX座標
2109 * Handle a request to change the current panel
2110 * Return TRUE if the panel was changed.
2111 * Also used in do_cmd_locate
2112 * @return 実際に再描画が必要だった場合TRUEを返す
2114 bool change_panel(POSITION dy, POSITION dx)
2119 get_screen_size(&wid, &hgt);
2121 /* Apply the motion */
2122 y = panel_row_min + dy * hgt / 2;
2123 x = panel_col_min + dx * wid / 2;
2125 /* Verify the row */
2126 if (y > cur_hgt - hgt) y = cur_hgt - hgt;
2129 /* Verify the col */
2130 if (x > cur_wid - wid) x = cur_wid - wid;
2133 /* Handle "changes" */
2134 if ((y != panel_row_min) || (x != panel_col_min))
2136 /* Save the new panel info */
2140 /* Recalculate the boundaries */
2141 panel_bounds_center();
2143 p_ptr->update |= (PU_MONSTERS);
2145 p_ptr->redraw |= (PR_MAP);
2159 * @brief フォーカスを当てるべきマップ描画の基準座標を指定する
2160 * @param y 変更先のフロアY座標
2161 * @param x 変更先のフロアX座標
2163 * Handle a request to change the current panel
2164 * Return TRUE if the panel was changed.
2165 * Also used in do_cmd_locate
2166 * @return 実際に再描画が必要だった場合TRUEを返す
2168 static bool change_panel_xy(POSITION y, POSITION x)
2170 POSITION dy = 0, dx = 0;
2173 get_screen_size(&wid, &hgt);
2175 if (y < panel_row_min) dy = -1;
2176 if (y > panel_row_max) dy = 1;
2177 if (x < panel_col_min) dx = -1;
2178 if (x > panel_col_max) dx = 1;
2180 if (!dy && !dx) return (FALSE);
2182 return change_panel(dy, dx);
2187 * @brief マップ描画のフォーカスを当てるべき座標を更新する
2189 * Given an row (y) and col (x), this routine detects when a move
2190 * off the screen has occurred and figures new borders. -RAK-
2191 * "Update" forces a "full update" to take place.
2192 * The map is reprinted if necessary, and "TRUE" is returned.
2193 * @return 実際に再描画が必要だった場合TRUEを返す
2195 void verify_panel(void)
2197 POSITION y = p_ptr->y;
2198 POSITION x = p_ptr->x;
2206 get_screen_size(&wid, &hgt);
2208 max_prow_min = cur_hgt - hgt;
2209 max_pcol_min = cur_wid - wid;
2211 /* Bounds checking */
2212 if (max_prow_min < 0) max_prow_min = 0;
2213 if (max_pcol_min < 0) max_pcol_min = 0;
2215 /* Center on player */
2216 if (center_player && (center_running || !running))
2218 /* Center vertically */
2219 prow_min = y - hgt / 2;
2220 if (prow_min < 0) prow_min = 0;
2221 else if (prow_min > max_prow_min) prow_min = max_prow_min;
2223 /* Center horizontally */
2224 pcol_min = x - wid / 2;
2225 if (pcol_min < 0) pcol_min = 0;
2226 else if (pcol_min > max_pcol_min) pcol_min = max_pcol_min;
2230 prow_min = panel_row_min;
2231 pcol_min = panel_col_min;
2233 /* Scroll screen when 2 grids from top/bottom edge */
2234 if (y > panel_row_max - 2)
2236 while (y > prow_min + hgt-1 - 2)
2238 prow_min += (hgt / 2);
2242 if (y < panel_row_min + 2)
2244 while (y < prow_min + 2)
2246 prow_min -= (hgt / 2);
2250 if (prow_min > max_prow_min) prow_min = max_prow_min;
2251 if (prow_min < 0) prow_min = 0;
2253 /* Scroll screen when 4 grids from left/right edge */
2254 if (x > panel_col_max - 4)
2256 while (x > pcol_min + wid-1 - 4)
2258 pcol_min += (wid / 2);
2262 if (x < panel_col_min + 4)
2264 while (x < pcol_min + 4)
2266 pcol_min -= (wid / 2);
2270 if (pcol_min > max_pcol_min) pcol_min = max_pcol_min;
2271 if (pcol_min < 0) pcol_min = 0;
2274 /* Check for "no change" */
2275 if ((prow_min == panel_row_min) && (pcol_min == panel_col_min)) return;
2277 /* Save the new panel info */
2278 panel_row_min = prow_min;
2279 panel_col_min = pcol_min;
2281 /* Hack -- optional disturb on "panel change" */
2282 if (disturb_panel && !center_player) disturb(FALSE, FALSE);
2284 /* Recalculate the boundaries */
2285 panel_bounds_center();
2287 p_ptr->update |= (PU_MONSTERS);
2289 p_ptr->redraw |= (PR_MAP);
2291 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
2296 * Monster health description
2298 cptr look_mon_desc(monster_type *m_ptr, BIT_FLAGS mode)
2300 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
2307 /* Determine if the monster is "living" */
2308 living = monster_living(ap_r_ptr);
2310 /* Calculate a health "percentage" */
2311 perc = 100L * m_ptr->hp / m_ptr->maxhp;
2313 /* Healthy monsters */
2314 if (m_ptr->hp >= m_ptr->maxhp)
2318 desc = living ? "無傷" : "無ダメージ";
2320 desc = living ? "unhurt" : "undamaged";
2325 else if (perc >= 60)
2328 desc = living ? "軽傷" : "小ダメージ";
2330 desc = living ? "somewhat wounded" : "somewhat damaged";
2335 else if (perc >= 25)
2338 desc = living ? "負傷" : "中ダメージ";
2340 desc = living ? "wounded" : "damaged";
2345 else if (perc >= 10)
2348 desc = living ? "重傷" : "大ダメージ";
2350 desc = living ? "badly wounded" : "badly damaged";
2358 desc = living ? "半死半生" : "倒れかけ";
2360 desc = living ? "almost dead" : "almost destroyed";
2365 /* Need attitude information? */
2368 /* Full information is not needed */
2371 else if (is_pet(m_ptr))
2373 attitude = _(", ペット", ", pet");
2375 else if (is_friendly(m_ptr))
2377 attitude = _(", 友好的", ", friendly");
2381 attitude = _("", "");
2385 /* Clone monster? */
2386 if (m_ptr->smart & SM_CLONED)
2395 /* Display monster's level --- idea borrowed from ToME */
2396 if (ap_r_ptr->r_tkills && !(m_ptr->mflag2 & MFLAG2_KAGE))
2398 return format(_("レベル%d, %s%s%s", "Level %d, %s%s%s"), ap_r_ptr->level, desc, attitude, clone);
2402 return format(_("レベル???, %s%s%s", "Level ???, %s%s%s"), desc, attitude, clone);
2409 * Angband sorting algorithm -- quick sort in place
2411 * Note that the details of the data we are sorting is hidden,
2412 * and we rely on the "ang_sort_comp()" and "ang_sort_swap()"
2413 * function hooks to interact with the data, which is given as
2414 * two pointers, and which may have any user-defined form.
2416 void ang_sort_aux(vptr u, vptr v, int p, int q)
2434 while (!(*ang_sort_comp)(u, v, b, z)) b--;
2437 while (!(*ang_sort_comp)(u, v, z, a)) a++;
2439 /* Done partition */
2443 (*ang_sort_swap)(u, v, a, b);
2449 /* Recurse left side */
2450 ang_sort_aux(u, v, p, b);
2452 /* Recurse right side */
2453 ang_sort_aux(u, v, b+1, q);
2458 * Angband sorting algorithm -- quick sort in place
2460 * Note that the details of the data we are sorting is hidden,
2461 * and we rely on the "ang_sort_comp()" and "ang_sort_swap()"
2462 * function hooks to interact with the data, which is given as
2463 * two pointers, and which may have any user-defined form.
2465 void ang_sort(vptr u, vptr v, int n)
2467 /* Sort the array */
2468 ang_sort_aux(u, v, 0, n-1);
2473 /*** Targeting Code ***/
2477 * Determine is a monster makes a reasonable target
2479 * The concept of "targeting" was stolen from "Morgul" (?)
2481 * The player can target any location, or any "target-able" monster.
2483 * Currently, a monster is "target_able" if it is visible, and if
2484 * the player can hit it with a projection, and the player is not
2485 * hallucinating. This allows use of "use closest target" macros.
2487 * Future versions may restrict the ability to target "trappers"
2488 * and "mimics", but the semantics is a little bit weird.
2490 bool target_able(MONSTER_IDX m_idx)
2492 monster_type *m_ptr = &m_list[m_idx];
2494 /* Monster must be alive */
2495 if (!m_ptr->r_idx) return (FALSE);
2497 /* Hack -- no targeting hallucinations */
2498 if (p_ptr->image) return (FALSE);
2500 /* Monster must be visible */
2501 if (!m_ptr->ml) return (FALSE);
2503 if (p_ptr->riding && (p_ptr->riding == m_idx)) return (TRUE);
2505 /* Monster must be projectable */
2506 if (!projectable(p_ptr->y, p_ptr->x, m_ptr->fy, m_ptr->fx)) return (FALSE);
2508 /* Hack -- Never target trappers */
2509 /* if (CLEAR_ATTR && (CLEAR_CHAR)) return (FALSE); */
2519 * Update (if necessary) and verify (if possible) the target.
2521 * We return TRUE if the target is "okay" and FALSE otherwise.
2523 bool target_okay(void)
2525 /* Accept stationary targets */
2526 if (target_who < 0) return (TRUE);
2528 /* Check moving targets */
2531 /* Accept reasonable targets */
2532 if (target_able(target_who))
2534 monster_type *m_ptr = &m_list[target_who];
2536 /* Acquire monster location */
2537 target_row = m_ptr->fy;
2538 target_col = m_ptr->fx;
2545 /* Assume no target */
2551 * Sorting hook -- comp function -- by "distance to player"
2553 * We use "u" and "v" to point to arrays of "x" and "y" positions,
2554 * and sort the arrays by double-distance to the player.
2556 static bool ang_sort_comp_distance(vptr u, vptr v, int a, int b)
2558 POSITION *x = (POSITION*)(u);
2559 POSITION *y = (POSITION*)(v);
2561 POSITION da, db, kx, ky;
2563 /* Absolute distance components */
2564 kx = x[a]; kx -= p_ptr->x; kx = ABS(kx);
2565 ky = y[a]; ky -= p_ptr->y; ky = ABS(ky);
2567 /* Approximate Double Distance to the first point */
2568 da = ((kx > ky) ? (kx + kx + ky) : (ky + ky + kx));
2570 /* Absolute distance components */
2571 kx = x[b]; kx -= p_ptr->x; kx = ABS(kx);
2572 ky = y[b]; ky -= p_ptr->y; ky = ABS(ky);
2574 /* Approximate Double Distance to the first point */
2575 db = ((kx > ky) ? (kx + kx + ky) : (ky + ky + kx));
2577 /* Compare the distances */
2583 * Sorting hook -- comp function -- by importance level of grids
2585 * We use "u" and "v" to point to arrays of "x" and "y" positions,
2586 * and sort the arrays by level of monster
2588 static bool ang_sort_comp_importance(vptr u, vptr v, int a, int b)
2590 POSITION *x = (POSITION*)(u);
2591 POSITION *y = (POSITION*)(v);
2592 cave_type *ca_ptr = &cave[y[a]][x[a]];
2593 cave_type *cb_ptr = &cave[y[b]][x[b]];
2594 monster_type *ma_ptr = &m_list[ca_ptr->m_idx];
2595 monster_type *mb_ptr = &m_list[cb_ptr->m_idx];
2596 monster_race *ap_ra_ptr, *ap_rb_ptr;
2598 /* The player grid */
2599 if (y[a] == p_ptr->y && x[a] == p_ptr->x) return TRUE;
2600 if (y[b] == p_ptr->y && x[b] == p_ptr->x) return FALSE;
2602 /* Extract monster race */
2603 if (ca_ptr->m_idx && ma_ptr->ml) ap_ra_ptr = &r_info[ma_ptr->ap_r_idx];
2604 else ap_ra_ptr = NULL;
2605 if (cb_ptr->m_idx && mb_ptr->ml) ap_rb_ptr = &r_info[mb_ptr->ap_r_idx];
2606 else ap_rb_ptr = NULL;
2608 if (ap_ra_ptr && !ap_rb_ptr) return TRUE;
2609 if (!ap_ra_ptr && ap_rb_ptr) return FALSE;
2611 /* Compare two monsters */
2612 if (ap_ra_ptr && ap_rb_ptr)
2614 /* Unique monsters first */
2615 if ((ap_ra_ptr->flags1 & RF1_UNIQUE) && !(ap_rb_ptr->flags1 & RF1_UNIQUE)) return TRUE;
2616 if (!(ap_ra_ptr->flags1 & RF1_UNIQUE) && (ap_rb_ptr->flags1 & RF1_UNIQUE)) return FALSE;
2618 /* Shadowers first (あやしい影) */
2619 if ((ma_ptr->mflag2 & MFLAG2_KAGE) && !(mb_ptr->mflag2 & MFLAG2_KAGE)) return TRUE;
2620 if (!(ma_ptr->mflag2 & MFLAG2_KAGE) && (mb_ptr->mflag2 & MFLAG2_KAGE)) return FALSE;
2622 /* Unknown monsters first */
2623 if (!ap_ra_ptr->r_tkills && ap_rb_ptr->r_tkills) return TRUE;
2624 if (ap_ra_ptr->r_tkills && !ap_rb_ptr->r_tkills) return FALSE;
2626 /* Higher level monsters first (if known) */
2627 if (ap_ra_ptr->r_tkills && ap_rb_ptr->r_tkills)
2629 if (ap_ra_ptr->level > ap_rb_ptr->level) return TRUE;
2630 if (ap_ra_ptr->level < ap_rb_ptr->level) return FALSE;
2633 /* Sort by index if all conditions are same */
2634 if (ma_ptr->ap_r_idx > mb_ptr->ap_r_idx) return TRUE;
2635 if (ma_ptr->ap_r_idx < mb_ptr->ap_r_idx) return FALSE;
2638 /* An object get higher priority */
2639 if (cave[y[a]][x[a]].o_idx && !cave[y[b]][x[b]].o_idx) return TRUE;
2640 if (!cave[y[a]][x[a]].o_idx && cave[y[b]][x[b]].o_idx) return FALSE;
2642 /* Priority from the terrain */
2643 if (f_info[ca_ptr->feat].priority > f_info[cb_ptr->feat].priority) return TRUE;
2644 if (f_info[ca_ptr->feat].priority < f_info[cb_ptr->feat].priority) return FALSE;
2646 /* If all conditions are same, compare distance */
2647 return ang_sort_comp_distance(u, v, a, b);
2652 * Sorting hook -- swap function -- by "distance to player"
2654 * We use "u" and "v" to point to arrays of "x" and "y" positions,
2655 * and sort the arrays by distance to the player.
2657 static void ang_sort_swap_distance(vptr u, vptr v, int a, int b)
2659 POSITION *x = (POSITION*)(u);
2660 POSITION *y = (POSITION*)(v);
2678 * Hack -- help "select" a location (see below)
2680 static POSITION_IDX target_pick(POSITION y1, POSITION x1, POSITION dy, POSITION dx)
2683 POSITION x2, y2, x3, y3, x4, y4;
2684 POSITION_IDX b_i = -1, b_v = 9999;
2687 /* Scan the locations */
2688 for (i = 0; i < temp_n; i++)
2694 /* Directed distance */
2698 /* Verify quadrant */
2699 if (dx && (x3 * dx <= 0)) continue;
2700 if (dy && (y3 * dy <= 0)) continue;
2702 /* Absolute distance */
2706 /* Verify quadrant */
2707 if (dy && !dx && (x4 > y4)) continue;
2708 if (dx && !dy && (y4 > x4)) continue;
2710 /* Approximate Double Distance */
2711 v = ((x4 > y4) ? (x4 + x4 + y4) : (y4 + y4 + x4));
2713 /* Penalize location */
2716 if ((b_i >= 0) && (v >= b_v)) continue;
2726 * Hack -- determine if a given location is "interesting"
2728 static bool target_set_accept(POSITION y, POSITION x)
2731 OBJECT_IDX this_o_idx, next_o_idx = 0;
2734 if (!(in_bounds(y, x))) return (FALSE);
2736 /* Player grid is always interesting */
2737 if (player_bold(y, x)) return (TRUE);
2739 /* Handle hallucination */
2740 if (p_ptr->image) return (FALSE);
2742 /* Examine the grid */
2743 c_ptr = &cave[y][x];
2745 /* Visible monsters */
2748 monster_type *m_ptr = &m_list[c_ptr->m_idx];
2750 /* Visible monsters */
2751 if (m_ptr->ml) return (TRUE);
2754 /* Scan all objects in the grid */
2755 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
2759 /* Acquire object */
2760 o_ptr = &o_list[this_o_idx];
2762 /* Acquire next object */
2763 next_o_idx = o_ptr->next_o_idx;
2765 /* Memorized object */
2766 if (o_ptr->marked & OM_FOUND) return (TRUE);
2769 /* Interesting memorized features */
2770 if (c_ptr->info & (CAVE_MARK))
2772 /* Notice object features */
2773 if (c_ptr->info & CAVE_OBJECT) return (TRUE);
2775 /* Feature code (applying "mimic" field) */
2776 if (have_flag(f_info[get_feat_mimic(c_ptr)].flags, FF_NOTICE)) return TRUE;
2784 * Prepare the "temp" array for "target_set"
2786 * Return the number of target_able monsters in the set.
2788 static void target_set_prepare(BIT_FLAGS mode)
2791 POSITION min_hgt, max_hgt, min_wid, max_wid;
2793 if (mode & TARGET_KILL)
2796 min_hgt = MAX((p_ptr->y - MAX_RANGE), 0);
2797 max_hgt = MIN((p_ptr->y + MAX_RANGE), cur_hgt - 1);
2798 min_wid = MAX((p_ptr->x - MAX_RANGE), 0);
2799 max_wid = MIN((p_ptr->x + MAX_RANGE), cur_wid - 1);
2801 else /* not targetting */
2804 min_hgt = panel_row_min;
2805 max_hgt = panel_row_max;
2806 min_wid = panel_col_min;
2807 max_wid = panel_col_max;
2810 /* Reset "temp" array */
2813 /* Scan the current panel */
2814 for (y = min_hgt; y <= max_hgt; y++)
2816 for (x = min_wid; x <= max_wid; x++)
2820 /* Require "interesting" contents */
2821 if (!target_set_accept(y, x)) continue;
2823 c_ptr = &cave[y][x];
2825 /* Require target_able monsters for "TARGET_KILL" */
2826 if ((mode & (TARGET_KILL)) && !target_able(c_ptr->m_idx)) continue;
2828 if ((mode & (TARGET_KILL)) && !target_pet && is_pet(&m_list[c_ptr->m_idx])) continue;
2830 /* Save the location */
2837 /* Set the sort hooks */
2838 if (mode & (TARGET_KILL))
2840 /* Target the nearest monster for shooting */
2841 ang_sort_comp = ang_sort_comp_distance;
2842 ang_sort_swap = ang_sort_swap_distance;
2846 /* Look important grids first in Look command */
2847 ang_sort_comp = ang_sort_comp_importance;
2848 ang_sort_swap = ang_sort_swap_distance;
2851 /* Sort the positions */
2852 ang_sort(temp_x, temp_y, temp_n);
2854 if (p_ptr->riding && target_pet && (temp_n > 1) && (mode & (TARGET_KILL)))
2859 temp_y[0] = temp_y[1];
2862 temp_x[0] = temp_x[1];
2867 void target_set_prepare_look(void){
2868 target_set_prepare(TARGET_LOOK);
2873 * Evaluate number of kill needed to gain level
2875 static void evaluate_monster_exp(char *buf, monster_type *m_ptr)
2877 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
2879 s32b exp_mon, exp_adv;
2880 u32b exp_mon_frac, exp_adv_frac;
2882 if ((p_ptr->lev >= PY_MAX_LEVEL) || (p_ptr->prace == RACE_ANDROID))
2887 else if (!ap_r_ptr->r_tkills || (m_ptr->mflag2 & MFLAG2_KAGE))
2897 /* The monster's experience point (assuming average monster speed) */
2898 exp_mon = ap_r_ptr->mexp * ap_r_ptr->level;
2900 s64b_div(&exp_mon, &exp_mon_frac, 0, (p_ptr->max_plv + 2));
2903 /* Total experience value for next level */
2904 exp_adv = player_exp[p_ptr->lev -1] * p_ptr->expfact;
2906 s64b_div(&exp_adv, &exp_adv_frac, 0, 100);
2908 /* Experience value need to get */
2909 s64b_sub(&exp_adv, &exp_adv_frac, p_ptr->exp, p_ptr->exp_frac);
2912 /* You need to kill at least one monster to get any experience */
2913 s64b_add(&exp_adv, &exp_adv_frac, exp_mon, exp_mon_frac);
2914 s64b_sub(&exp_adv, &exp_adv_frac, 0, 1);
2916 /* Extract number of monsters needed */
2917 s64b_div(&exp_adv, &exp_adv_frac, exp_mon, exp_mon_frac);
2919 /* If 999 or more monsters needed, only display "999". */
2920 num = MIN(999, exp_adv_frac);
2922 /* Display the number */
2923 sprintf(buf,"%03ld", (long int)num);
2927 bool show_gold_on_floor = FALSE;
2930 * Examine a grid, return a keypress.
2932 * The "mode" argument contains the "TARGET_LOOK" bit flag, which
2933 * indicates that the "space" key should scan through the contents
2934 * of the grid, instead of simply returning immediately. This lets
2935 * the "look" command get complete information, without making the
2936 * "target" command annoying.
2938 * The "info" argument contains the "commands" which should be shown
2939 * inside the "[xxx]" text. This string must never be empty, or grids
2940 * containing monsters will be displayed with an extra comma.
2942 * Note that if a monster is in the grid, we update both the monster
2943 * recall info and the health bar info to track that monster.
2945 * Eventually, we may allow multiple objects per grid, or objects
2946 * and terrain features in the same grid.
2948 * This function must handle blindness/hallucination.
2950 static char target_set_aux(POSITION y, POSITION x, BIT_FLAGS mode, cptr info)
2952 cave_type *c_ptr = &cave[y][x];
2953 OBJECT_IDX this_o_idx, next_o_idx = 0;
2954 cptr s1 = "", s2 = "", s3 = "", x_info = "";
2957 feature_type *f_ptr;
2958 char query = '\001';
2959 char out_val[MAX_NLEN+80];
2960 OBJECT_IDX floor_list[23];
2961 ITEM_NUMBER floor_num = 0;
2963 /* Scan all objects in the grid */
2966 floor_num = scan_floor(floor_list, y, x, 0x02);
2970 x_info = _("x物 ", "x,");
2974 /* Hack -- under the player */
2975 if (player_bold(y, x))
2991 s1 = _("ターゲット:", "Target:");
2994 /* Hack -- hallucination */
2997 cptr name = _("何か奇妙な物", "something strange");
2999 /* Display a message */
3001 sprintf(out_val, "%s%s%s%s [%s]", s1, name, s2, s3, info);
3003 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, name, info);
3007 move_cursor_relative(y, x);
3010 /* Stop on everything but "return" */
3011 if ((query != '\r') && (query != '\n')) return query;
3013 /* Repeat forever */
3018 /* Actual monsters */
3019 if (c_ptr->m_idx && m_list[c_ptr->m_idx].ml)
3021 monster_type *m_ptr = &m_list[c_ptr->m_idx];
3022 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
3024 bool recall = FALSE;
3029 /* Get the monster name ("a kobold") */
3030 monster_desc(m_name, m_ptr, MD_INDEF_VISIBLE);
3032 /* Hack -- track this monster race */
3033 monster_race_track(m_ptr->ap_r_idx);
3035 /* Hack -- health bar for this monster */
3036 health_track(c_ptr->m_idx);
3038 /* Hack -- handle stuff */
3052 /* Recall on screen */
3053 screen_roff(m_ptr->ap_r_idx, 0);
3055 /* Hack -- Complete the prompt (again) */
3056 Term_addstr(-1, TERM_WHITE, format(_(" [r思 %s%s]", " [r,%s%s]"), x_info, info));
3064 /* Normal commands */
3065 if (query != 'r') break;
3070 /* Cleare recall text and repeat */
3076 /* Describe, and prompt for recall */
3077 evaluate_monster_exp(acount, m_ptr);
3080 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);
3082 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);
3088 move_cursor_relative(y, x);
3093 /* Normal commands */
3094 if (query != 'r') break;
3100 /* Always stop at "normal" keys */
3101 if ((query != '\r') && (query != '\n') && (query != ' ') && (query != 'x')) return query;
3103 /* Sometimes stop at "space" key */
3104 if ((query == ' ') && !(mode & (TARGET_LOOK))) return query;
3106 /* Change the intro */
3107 s1 = _("それは", "It is ");
3109 /* Hack -- take account of gender */
3110 if (ap_r_ptr->flags1 & (RF1_FEMALE)) s1 = _("彼女は", "She is ");
3111 else if (ap_r_ptr->flags1 & (RF1_MALE)) s1 = _("彼は", "He is ");
3113 /* Use a preposition */
3122 /* Scan all objects being carried */
3123 for (this_o_idx = m_ptr->hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
3125 char o_name[MAX_NLEN];
3129 /* Acquire object */
3130 o_ptr = &o_list[this_o_idx];
3132 /* Acquire next object */
3133 next_o_idx = o_ptr->next_o_idx;
3135 /* Obtain an object description */
3136 object_desc(o_name, o_ptr, 0);
3139 sprintf(out_val, "%s%s%s%s[%s]", s1, o_name, s2, s3, info);
3141 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, o_name, info);
3145 move_cursor_relative(y, x);
3148 /* Always stop at "normal" keys */
3149 if ((query != '\r') && (query != '\n') && (query != ' ') && (query != 'x')) return query;
3151 /* Sometimes stop at "space" key */
3152 if ((query == ' ') && !(mode & (TARGET_LOOK))) return query;
3154 /* Change the intro */
3155 s2 = _("をまた", "also carrying ");
3158 /* Use a preposition */
3175 char o_name[MAX_NLEN];
3179 /* Acquire object */
3180 o_ptr = &o_list[floor_list[0]];
3182 object_desc(o_name, o_ptr, 0);
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);
3200 /* Provide one cushion before item listing */
3203 /* Display rough information about items */
3205 sprintf(out_val, "%s %d個のアイテム%s%s ['x'で一覧, %s]",
3206 s1, (int)floor_num, s2, s3, info);
3208 sprintf(out_val, "%s%s%sa pile of %d items [x,%s]",
3209 s1, s2, s3, (int)floor_num, info);
3213 move_cursor_relative(y, x);
3218 /* No request for listing */
3219 if (query != 'x' && query != ' ') return query;
3223 /** Display list of items **/
3225 /* Continue scrolling list if requested */
3235 show_gold_on_floor = TRUE;
3236 (void)show_floor(0, y, x, &min_width);
3237 show_gold_on_floor = FALSE;
3241 sprintf(out_val, "%s %d個のアイテム%s%s [Enterで次へ, %s]",
3242 s1, (int)floor_num, s2, s3, info);
3244 sprintf(out_val, "%s%s%sa pile of %d items [Enter,%s]",
3245 s1, s2, s3, (int)floor_num, info);
3256 /* Exit unless 'Enter' */
3257 if (query != '\n' && query != '\r')
3262 /* Get the object being moved. */
3263 o_idx = c_ptr->o_idx;
3265 /* Only rotate a pile of two or more objects. */
3266 if (!(o_idx && o_list[o_idx].next_o_idx)) continue;
3268 /* Remove the first object from the list. */
3269 excise_object_idx(o_idx);
3271 /* Find end of the list. */
3273 while (o_list[i].next_o_idx)
3274 i = o_list[i].next_o_idx;
3276 /* Add after the last object. */
3277 o_list[i].next_o_idx = o_idx;
3279 /* Loop and re-display the list */
3286 /* Scan all objects in the grid */
3287 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
3291 /* Acquire object */
3292 o_ptr = &o_list[this_o_idx];
3294 /* Acquire next object */
3295 next_o_idx = o_ptr->next_o_idx;
3298 if (o_ptr->marked & OM_FOUND)
3300 char o_name[MAX_NLEN];
3305 /* Obtain an object description */
3306 object_desc(o_name, o_ptr, 0);
3309 sprintf(out_val, "%s%s%s%s[%s]", s1, o_name, s2, s3, info);
3311 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, o_name, info);
3315 move_cursor_relative(y, x);
3318 /* Always stop at "normal" keys */
3319 if ((query != '\r') && (query != '\n') && (query != ' ') && (query != 'x')) return query;
3321 /* Sometimes stop at "space" key */
3322 if ((query == ' ') && !(mode & TARGET_LOOK)) return query;
3324 /* Change the intro */
3325 s1 = _("それは", "It is ");
3328 if (o_ptr->number != 1) s1 = _("それらは", "They are ");
3342 /* Feature code (applying "mimic" field) */
3343 feat = get_feat_mimic(c_ptr);
3345 /* Require knowledge about grid, or ability to see grid */
3346 if (!(c_ptr->info & CAVE_MARK) && !player_can_see_bold(y, x))
3348 /* Forget feature */
3352 f_ptr = &f_info[feat];
3354 /* Terrain feature if needed */
3355 if (boring || have_flag(f_ptr->flags, FF_REMEMBER))
3359 /* Hack -- special handling for quest entrances */
3360 if (have_flag(f_ptr->flags, FF_QUEST_ENTER))
3362 /* Set the quest number temporary */
3363 IDX old_quest = p_ptr->inside_quest;
3366 /* Clear the text */
3367 for (j = 0; j < 10; j++) quest_text[j][0] = '\0';
3368 quest_text_line = 0;
3370 p_ptr->inside_quest = c_ptr->special;
3372 /* Get the quest text */
3373 init_flags = INIT_NAME_ONLY;
3375 process_dungeon_file("q_info.txt", 0, 0, 0, 0);
3377 name = format(_("クエスト「%s」(%d階相当)", "the entrance to the quest '%s'(level %d)"),
3378 quest[c_ptr->special].name, quest[c_ptr->special].level);
3380 /* Reset the old quest number */
3381 p_ptr->inside_quest = old_quest;
3384 /* Hack -- special handling for building doors */
3385 else if (have_flag(f_ptr->flags, FF_BLDG) && !p_ptr->inside_arena)
3387 name = building[f_ptr->subtype].name;
3389 else if (have_flag(f_ptr->flags, FF_ENTRANCE))
3391 name = format(_("%s(%d階相当)", "%s(level %d)"), d_text + d_info[c_ptr->special].text, d_info[c_ptr->special].mindepth);
3393 else if (have_flag(f_ptr->flags, FF_TOWN))
3395 name = town[c_ptr->special].name;
3397 else if (p_ptr->wild_mode && (feat == feat_floor))
3399 name = _("道", "road");
3403 name = f_name + f_ptr->name;
3409 ((!have_flag(f_ptr->flags, FF_MOVE) && !have_flag(f_ptr->flags, FF_CAN_FLY)) ||
3410 (!have_flag(f_ptr->flags, FF_LOS) && !have_flag(f_ptr->flags, FF_TREE)) ||
3411 have_flag(f_ptr->flags, FF_TOWN)))
3413 s2 = _("の中", "in ");
3416 /* Hack -- special introduction for store & building doors -KMW- */
3417 if (have_flag(f_ptr->flags, FF_STORE) ||
3418 have_flag(f_ptr->flags, FF_QUEST_ENTER) ||
3419 (have_flag(f_ptr->flags, FF_BLDG) && !p_ptr->inside_arena) ||
3420 have_flag(f_ptr->flags, FF_ENTRANCE))
3429 else if (have_flag(f_ptr->flags, FF_FLOOR) ||
3430 have_flag(f_ptr->flags, FF_TOWN) ||
3431 have_flag(f_ptr->flags, FF_SHALLOW) ||
3432 have_flag(f_ptr->flags, FF_DEEP))
3438 /* Pick proper indefinite article */
3439 s3 = (is_a_vowel(name[0])) ? "an " : "a ";
3443 /* Display a message */
3447 if (c_ptr->mimic) sprintf(f_idx_str, "%d/%d", c_ptr->feat, c_ptr->mimic);
3448 else sprintf(f_idx_str, "%d", c_ptr->feat);
3450 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]);
3452 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);
3457 sprintf(out_val, "%s%s%s%s[%s]", s1, name, s2, s3, info);
3459 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, name, info);
3463 move_cursor_relative(y, x);
3466 /* Always stop at "normal" keys */
3467 if ((query != '\r') && (query != '\n') && (query != ' ')) return query;
3470 /* Stop on everything but "return" */
3471 if ((query != '\r') && (query != '\n')) return query;
3473 /* Repeat forever */
3479 * Handle "target" and "look".
3481 * Note that this code can be called from "get_aim_dir()".
3483 * All locations must be on the current panel. Consider the use of
3484 * "panel_bounds()" to allow "off-panel" targets, perhaps by using
3485 * some form of "scrolling" the map around the cursor.
3486 * That is, consider the possibility of "auto-scrolling" the screen
3487 * while the cursor moves around. This may require changes in the
3488 * "update_monster()" code to allow "visibility" even if off panel, and
3489 * may require dynamic recalculation of the "temp" grid set.
3491 * Hack -- targeting/observing an "outer border grid" may induce
3492 * problems, so this is not currently allowed.
3494 * The player can use the direction keys to move among "interesting"
3495 * grids in a heuristic manner, or the "space", "+", and "-" keys to
3496 * move through the "interesting" grids in a sequential manner, or
3497 * can enter "location" mode, and use the direction keys to move one
3498 * grid at a time in any direction. The "t" (set target) command will
3499 * only target a monster (as opposed to a location) if the monster is
3500 * target_able and the "interesting" mode is being used.
3502 * The current grid is described using the "look" method above, and
3503 * a new command may be entered at any time, but note that if the
3504 * "TARGET_LOOK" bit flag is set (or if we are in "location" mode,
3505 * where "space" has no obvious meaning) then "space" will scan
3506 * through the description of the current grid until done, instead
3507 * of immediately jumping to the next "interesting" grid. This
3508 * allows the "target" command to retain its old semantics.
3510 * The "*", "+", and "-" keys may always be used to jump immediately
3511 * to the next (or previous) interesting grid, in the proper mode.
3513 * The "return" key may always be used to scan through a complete
3514 * grid description (forever).
3516 * This command will cancel any old target, even if used from
3517 * inside the "look" command.
3519 bool target_set(BIT_FLAGS mode)
3522 POSITION y = p_ptr->y;
3523 POSITION x = p_ptr->x;
3535 get_screen_size(&wid, &hgt);
3541 /* Cancel tracking */
3542 /* health_track(0); */
3544 if (rogue_like_commands)
3553 /* Prepare the "temp" array */
3554 target_set_prepare(mode);
3556 /* Start near the player */
3562 /* Interesting grids */
3569 change_panel_xy(y, x);
3571 if (!(mode & TARGET_LOOK)) prt_path(y, x);
3574 c_ptr = &cave[y][x];
3577 if (target_able(c_ptr->m_idx))
3579 strcpy(info, _("q止 t決 p自 o現 +次 -前", "q,t,p,o,+,-,<dir>"));
3582 /* Dis-allow target */
3585 strcpy(info, _("q止 p自 o現 +次 -前", "q,p,o,+,-,<dir>"));
3591 sprintf(cheatinfo, " LOS:%d, PROJECTABLE:%d",
3592 los(p_ptr->y, p_ptr->x, y, x),
3593 projectable(p_ptr->y, p_ptr->x, y, x));
3594 strcat(info, cheatinfo);
3597 /* Describe and Prompt */
3599 query = target_set_aux(y, x, mode, info);
3603 /* Cancel tracking */
3604 /* health_track(0); */
3606 /* Assume no "direction" */
3611 if (query == '\r') query = 't';
3629 if (target_able(c_ptr->m_idx))
3631 health_track(c_ptr->m_idx);
3632 target_who = c_ptr->m_idx;
3651 if (!expand_list) done = TRUE;
3661 if (!expand_list) done = TRUE;
3668 /* Recenter the map around the player */
3671 p_ptr->update |= (PU_MONSTERS);
3673 p_ptr->redraw |= (PR_MAP);
3675 p_ptr->window |= (PW_OVERHEAD);
3680 /* Recalculate interesting grids */
3681 target_set_prepare(mode);
3700 if(query == same_key)
3705 if (!expand_list) done = TRUE;
3710 /* Extract the action (if any) */
3711 d = get_keymap_dir(query);
3718 /* Hack -- move around */
3721 /* Modified to scroll to monster */
3722 POSITION y2 = panel_row_min;
3723 POSITION x2 = panel_col_min;
3725 /* Find a new monster */
3726 i = target_pick(temp_y[m], temp_x[m], ddy[d], ddx[d]);
3728 /* Request to target past last interesting grid */
3729 while (flag && (i < 0))
3731 /* Note the change */
3732 if (change_panel(ddy[d], ddx[d]))
3737 /* Recalculate interesting grids */
3738 target_set_prepare(mode);
3740 /* Look at interesting grids */
3743 /* Find a new monster */
3744 i = target_pick(v, u, ddy[d], ddx[d]);
3750 /* Nothing interesting */
3756 /* Restore previous position */
3759 panel_bounds_center();
3761 p_ptr->update |= (PU_MONSTERS);
3763 p_ptr->redraw |= (PR_MAP);
3765 p_ptr->window |= (PW_OVERHEAD);
3770 /* Recalculate interesting grids */
3771 target_set_prepare(mode);
3773 /* Look at boring grids */
3780 /* Do not move horizontally if unnecessary */
3781 if (((x < panel_col_min + wid / 2) && (dx > 0)) ||
3782 ((x > panel_col_min + wid / 2) && (dx < 0)))
3787 /* Do not move vertically if unnecessary */
3788 if (((y < panel_row_min + hgt / 2) && (dy > 0)) ||
3789 ((y > panel_row_min + hgt / 2) && (dy < 0)))
3794 /* Apply the motion */
3795 if ((y >= panel_row_min+hgt) || (y < panel_row_min) ||
3796 (x >= panel_col_min+wid) || (x < panel_col_min))
3798 if (change_panel(dy, dx)) target_set_prepare(mode);
3801 /* Slide into legality */
3802 if (x >= cur_wid-1) x = cur_wid - 2;
3803 else if (x <= 0) x = 1;
3805 /* Slide into legality */
3806 if (y >= cur_hgt-1) y = cur_hgt- 2;
3807 else if (y <= 0) y = 1;
3816 /* Arbitrary grids */
3819 bool move_fast = FALSE;
3821 if (!(mode & TARGET_LOOK)) prt_path(y, x);
3824 c_ptr = &cave[y][x];
3826 /* Default prompt */
3827 strcpy(info, _("q止 t決 p自 m近 +次 -前", "q,t,p,m,+,-,<dir>"));
3832 sprintf(cheatinfo, " LOS:%d, PROJECTABLE:%d",
3833 los(p_ptr->y, p_ptr->x, y, x),
3834 projectable(p_ptr->y, p_ptr->x, y, x));
3835 strcat(info, cheatinfo);
3838 /* Describe and Prompt (enable "TARGET_LOOK") */
3839 while ((query = target_set_aux(y, x, mode | TARGET_LOOK, info)) == 0);
3841 /* Cancel tracking */
3842 /* health_track(0); */
3844 /* Assume no direction */
3849 if (query == '\r') query = 't';
3852 /* Analyze the keypress */
3876 /* Recenter the map around the player */
3879 p_ptr->update |= (PU_MONSTERS);
3881 p_ptr->redraw |= (PR_MAP);
3883 p_ptr->window |= (PW_OVERHEAD);
3888 /* Recalculate interesting grids */
3889 target_set_prepare(mode);
3911 /* Pick a nearby monster */
3912 for (i = 0; i < temp_n; i++)
3914 t = distance(y, x, temp_y[i], temp_x[i]);
3924 /* Nothing interesting */
3925 if (bd == 999) flag = FALSE;
3932 /* Extract the action (if any) */
3933 d = get_keymap_dir(query);
3935 /* XTRA HACK MOVEFAST */
3936 if (isupper(query)) move_fast = TRUE;
3943 /* Handle "direction" */
3949 /* XTRA HACK MOVEFAST */
3952 int mag = MIN(wid / 2, hgt / 2);
3962 /* Do not move horizontally if unnecessary */
3963 if (((x < panel_col_min + wid / 2) && (dx > 0)) ||
3964 ((x > panel_col_min + wid / 2) && (dx < 0)))
3969 /* Do not move vertically if unnecessary */
3970 if (((y < panel_row_min + hgt / 2) && (dy > 0)) ||
3971 ((y > panel_row_min + hgt / 2) && (dy < 0)))
3976 /* Apply the motion */
3977 if ((y >= panel_row_min + hgt) || (y < panel_row_min) ||
3978 (x >= panel_col_min + wid) || (x < panel_col_min))
3980 if (change_panel(dy, dx)) target_set_prepare(mode);
3983 /* Slide into legality */
3984 if (x >= cur_wid-1) x = cur_wid - 2;
3985 else if (x <= 0) x = 1;
3987 /* Slide into legality */
3988 if (y >= cur_hgt-1) y = cur_hgt- 2;
3989 else if (y <= 0) y = 1;
3997 /* Clear the top line */
4000 /* Recenter the map around the player */
4003 p_ptr->update |= (PU_MONSTERS);
4005 p_ptr->redraw |= (PR_MAP);
4007 p_ptr->window |= (PW_OVERHEAD);
4012 /* Failure to set target */
4013 if (!target_who) return (FALSE);
4021 * Get an "aiming direction" from the user.
4023 * The "dir" is loaded with 1,2,3,4,6,7,8,9 for "actual direction", and
4024 * "0" for "current target", and "-1" for "entry aborted".
4026 * Note that "Force Target", if set, will pre-empt user interaction,
4027 * if there is a usable target already set.
4029 * Note that confusion over-rides any (explicit?) user choice.
4031 bool get_aim_dir(DIRECTION *dp)
4040 /* Global direction */
4043 /* Hack -- auto-target if requested */
4044 if (use_old_target && target_okay()) dir = 5;
4046 if (repeat_pull(&code))
4051 if (!(code == 5 && !target_okay()))
4053 /* return (TRUE); */
4054 dir = (DIRECTION)code;
4057 *dp = (DIRECTION)code;
4059 /* Ask until satisfied */
4062 /* Choose a prompt */
4065 p = _("方向 ('*'でターゲット選択, ESCで中断)? ", "Direction ('*' to choose a target, Escape to cancel)? ");
4069 p = _("方向 ('5'でターゲットへ, '*'でターゲット再選択, ESCで中断)? ", "Direction ('5' for target, '*' to re-target, Escape to cancel)? ");
4072 /* Get a command (or Cancel) */
4073 if (!get_com(p, &command, TRUE)) break;
4077 if (command == '\r') command = 't';
4080 /* Convert various keys to "standard" keys */
4083 /* Use current target */
4094 /* Set new target */
4099 if (target_set(TARGET_KILL)) dir = 5;
4105 /* Extract the action (if any) */
4106 dir = get_keymap_dir(command);
4112 /* Verify requested targets */
4113 if ((dir == 5) && !target_okay()) dir = 0;
4122 project_length = 0; /* reset to default */
4126 /* Save the direction */
4129 /* Check for confusion */
4130 if (p_ptr->confused)
4132 /* Random direction */
4133 dir = ddd[randint0(8)];
4136 /* Notice confusion */
4137 if (command_dir != dir)
4140 msg_print(_("あなたは混乱している。", "You are confused."));
4143 /* Save direction */
4146 /* repeat_push(dir); */
4147 repeat_push((COMMAND_CODE)command_dir);
4149 /* A "valid" direction was entered */
4154 bool get_direction(DIRECTION *dp, bool allow_under, bool with_steed)
4162 /* Global direction */
4165 if (repeat_pull(&code))
4167 dir = (DIRECTION)code;
4168 /* return (TRUE); */
4170 *dp = (DIRECTION)code;
4174 prompt = _("方向 ('.'足元, ESCで中断)? ", "Direction ('.' at feet, Escape to cancel)? ");
4178 prompt = _("方向 (ESCで中断)? ", "Direction (Escape to cancel)? ");
4181 /* Get a direction */
4186 /* Get a command (or Cancel) */
4187 if (!get_com(prompt, &ch, TRUE)) break;
4190 if ((allow_under) && ((ch == '5') || (ch == '-') || (ch == '.')))
4196 /* Look up the direction */
4197 dir = get_keymap_dir(ch);
4203 /* Prevent weirdness */
4204 if ((dir == 5) && (!allow_under)) dir = 0;
4207 if (!dir) return (FALSE);
4209 /* Save desired direction */
4212 /* Apply "confusion" */
4213 if (p_ptr->confused)
4215 /* Standard confusion */
4216 if (randint0(100) < 75)
4218 /* Random direction */
4219 dir = ddd[randint0(8)];
4222 else if (p_ptr->riding && with_steed)
4224 monster_type *m_ptr = &m_list[p_ptr->riding];
4225 monster_race *r_ptr = &r_info[m_ptr->r_idx];
4227 if (MON_CONFUSED(m_ptr))
4229 /* Standard confusion */
4230 if (randint0(100) < 75)
4232 /* Random direction */
4233 dir = ddd[randint0(8)];
4236 else if ((r_ptr->flags1 & RF1_RAND_50) && (r_ptr->flags1 & RF1_RAND_25) && (randint0(100) < 50))
4238 /* Random direction */
4239 dir = ddd[randint0(8)];
4241 else if ((r_ptr->flags1 & RF1_RAND_50) && (randint0(100) < 25))
4243 /* Random direction */
4244 dir = ddd[randint0(8)];
4248 /* Notice confusion */
4249 if (command_dir != dir)
4251 if (p_ptr->confused)
4254 msg_print(_("あなたは混乱している。", "You are confused."));
4259 monster_type *m_ptr = &m_list[p_ptr->riding];
4261 monster_desc(m_name, m_ptr, 0);
4262 if (MON_CONFUSED(m_ptr))
4264 msg_format(_("%sは混乱している。", "%^s is confusing."), m_name);
4268 msg_format(_("%sは思い通りに動いてくれない。", "You cannot control %s."), m_name);
4273 /* Save direction */
4276 /* repeat_push(dir); */
4277 repeat_push((COMMAND_CODE)command_dir);
4284 * @brief 進行方向を指定する(騎乗対象の混乱の影響を受ける) / Request a "movement" direction (1,2,3,4,6,7,8,9) from the user,
4285 * and place it into "command_dir", unless we already have one.
4287 * This function should be used for all "repeatable" commands, such as
4288 * run, walk, open, close, bash, disarm, spike, tunnel, etc, as well
4289 * as all commands which must reference a grid adjacent to the player,
4290 * and which may not reference the grid under the player. Note that,
4291 * for example, it is no longer possible to "disarm" or "open" chests
4292 * in the same grid as the player.
4294 * Direction "5" is illegal and will (cleanly) abort the command.
4296 * This function tracks and uses the "global direction", and uses
4297 * that as the "desired direction", to which "confusion" is applied.
4299 bool get_rep_dir(DIRECTION *dp, bool under)
4307 /* Global direction */
4310 if (repeat_pull(&code))
4312 dir = (DIRECTION)code;
4313 /* return (TRUE); */
4315 *dp = (DIRECTION)code;
4319 prompt = _("方向 ('.'足元, ESCで中断)? ", "Direction ('.' at feet, Escape to cancel)? ");
4323 prompt = _("方向 (ESCで中断)? ", "Direction (Escape to cancel)? ");
4326 /* Get a direction */
4331 /* Get a command (or Cancel) */
4332 if (!get_com(prompt, &ch, TRUE)) break;
4335 if ((under) && ((ch == '5') || (ch == '-') || (ch == '.')))
4341 /* Look up the direction */
4342 dir = get_keymap_dir(ch);
4348 /* Prevent weirdness */
4349 if ((dir == 5) && (!under)) dir = 0;
4352 if (!dir) return (FALSE);
4354 /* Save desired direction */
4357 /* Apply "confusion" */
4358 if (p_ptr->confused)
4360 /* Standard confusion */
4361 if (randint0(100) < 75)
4363 /* Random direction */
4364 dir = ddd[randint0(8)];
4367 else if (p_ptr->riding)
4369 monster_type *m_ptr = &m_list[p_ptr->riding];
4370 monster_race *r_ptr = &r_info[m_ptr->r_idx];
4372 if (MON_CONFUSED(m_ptr))
4374 /* Standard confusion */
4375 if (randint0(100) < 75)
4377 /* Random direction */
4378 dir = ddd[randint0(8)];
4381 else if ((r_ptr->flags1 & RF1_RAND_50) && (r_ptr->flags1 & RF1_RAND_25) && (randint0(100) < 50))
4383 /* Random direction */
4384 dir = ddd[randint0(8)];
4386 else if ((r_ptr->flags1 & RF1_RAND_50) && (randint0(100) < 25))
4388 /* Random direction */
4389 dir = ddd[randint0(8)];
4393 /* Notice confusion */
4394 if (command_dir != dir)
4396 if (p_ptr->confused)
4399 msg_print(_("あなたは混乱している。", "You are confused."));
4404 monster_type *m_ptr = &m_list[p_ptr->riding];
4406 monster_desc(m_name, m_ptr, 0);
4407 if (MON_CONFUSED(m_ptr))
4409 msg_format(_("%sは混乱している。", "%^s is confusing."), m_name);
4413 msg_format(_("%sは思い通りに動いてくれない。", "You cannot control %s."), m_name);
4418 /* Save direction */
4421 /* repeat_push(dir); */
4422 repeat_push((COMMAND_CODE)command_dir);
4428 void gain_level_reward(int chosen_reward)
4432 char wrath_reason[32] = "";
4433 int nasty_chance = 6;
4434 OBJECT_TYPE_VALUE dummy = 0;
4435 OBJECT_SUBTYPE_VALUE dummy2 = 0;
4438 char o_name[MAX_NLEN];
4444 if (multi_rew) return;
4445 else multi_rew = TRUE;
4449 if (p_ptr->lev == 13) nasty_chance = 2;
4450 else if (!(p_ptr->lev % 13)) nasty_chance = 3;
4451 else if (!(p_ptr->lev % 14)) nasty_chance = 12;
4453 if (one_in_(nasty_chance))
4454 type = randint1(20); /* Allow the 'nasty' effects */
4456 type = randint1(15) + 5; /* Or disallow them */
4458 if (type < 1) type = 1;
4459 if (type > 20) type = 20;
4463 sprintf(wrath_reason, _("%sの怒り", "the Wrath of %s"), chaos_patrons[p_ptr->chaos_patron]);
4465 effect = chaos_rewards[p_ptr->chaos_patron][type];
4467 if (one_in_(6) && !chosen_reward)
4469 msg_format(_("%^sは褒美としてあなたを突然変異させた。", "%^s rewards you with a mutation!"), chaos_patrons[p_ptr->chaos_patron]);
4470 (void)gain_random_mutation(0);
4471 reward = _("変異した。", "mutation");
4475 switch (chosen_reward ? chosen_reward : effect)
4480 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4481 msg_print(_("「汝、新たなる姿を必要とせり!」", "'Thou needst a new form, mortal!'"));
4484 reward = _("変異した。", "polymorphing");
4489 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4490 msg_print(_("「汝は良く行いたり!続けよ!」", "'Well done, mortal! Lead on!'"));
4492 if (p_ptr->prace == RACE_ANDROID)
4494 msg_print(_("しかし何も起こらなかった。", "But, nothing happen."));
4496 else if (p_ptr->exp < PY_MAX_EXP)
4498 s32b ee = (p_ptr->exp / 2) + 10;
4499 if (ee > 100000L) ee = 100000L;
4500 msg_print(_("更に経験を積んだような気がする。", "You feel more experienced."));
4503 reward = _("経験値を得た", "experience");
4509 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4510 msg_print(_("「下僕よ、汝それに値せず。」", "'Thou didst not deserve that, slave.'"));
4512 if (p_ptr->prace == RACE_ANDROID)
4514 msg_print(_("しかし何も起こらなかった。", "But, nothing happen."));
4518 lose_exp(p_ptr->exp / 6);
4519 reward = _("経験値を失った。", "losing experience");
4525 msg_format("%sの声がささやいた:",
4526 chaos_patrons[p_ptr->chaos_patron]);
4528 msg_format("The voice of %s whispers:",
4529 chaos_patrons[p_ptr->chaos_patron]);
4532 msg_print(_("「我が与えし物を賢明に使うべし。」", "'Use my gift wisely.'"));
4534 acquirement(p_ptr->y, p_ptr->x, 1, FALSE, FALSE, FALSE);
4535 reward = _("上質なアイテムを手に入れた。", "a good item");
4540 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4541 msg_print(_("「我が与えし物を賢明に使うべし。」", "'Use my gift wisely.'"));
4543 acquirement(p_ptr->y, p_ptr->x, 1, TRUE, FALSE, FALSE);
4544 reward = _("高級品のアイテムを手に入れた。", "an excellent item");
4549 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4550 msg_print(_("「汝の行いは貴き剣に値せり。」", "'Thy deed hath earned thee a worthy blade.'"));
4552 /* Get local object */
4555 switch (randint1(p_ptr->lev))
4561 dummy2 = SV_MAIN_GAUCHE;
4570 dummy2 = SV_SMALL_SWORD;
4573 dummy2 = SV_BASILLARD;
4575 case 11: case 12: case 13:
4576 dummy2 = SV_SHORT_SWORD;
4582 dummy2 = SV_CUTLASS;
4585 dummy2 = SV_WAKIZASHI;
4588 dummy2 = SV_KHOPESH;
4594 dummy2 = SV_BROAD_SWORD;
4597 dummy2 = SV_LONG_SWORD;
4600 dummy2 = SV_SCIMITAR;
4603 dummy2 = SV_NINJATO;
4609 dummy2 = SV_BASTARD_SWORD;
4612 dummy2 = SV_GREAT_SCIMITAR;
4615 dummy2 = SV_CLAYMORE;
4618 dummy2 = SV_ESPADON;
4621 dummy2 = SV_TWO_HANDED_SWORD;
4624 dummy2 = SV_FLAMBERGE;
4627 dummy2 = SV_NO_DACHI;
4630 dummy2 = SV_EXECUTIONERS_SWORD;
4633 dummy2 = SV_ZWEIHANDER;
4636 dummy2 = SV_HAYABUSA;
4639 dummy2 = SV_BLADE_OF_CHAOS;
4642 object_prep(q_ptr, lookup_kind(dummy, dummy2));
4643 q_ptr->to_h = 3 + randint1(dun_level) % 10;
4644 q_ptr->to_d = 3 + randint1(dun_level) % 10;
4645 one_resistance(q_ptr);
4646 q_ptr->name2 = EGO_CHAOTIC;
4648 /* Drop it in the dungeon */
4649 (void)drop_near(q_ptr, -1, p_ptr->y, p_ptr->x);
4650 reward = _("(混沌)の武器を手に入れた。", "chaos weapon");
4655 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4656 msg_print(_("「汝の行いは貴き報いに値せり。」", "'Thy deed hath earned thee a worthy reward.'"));
4658 acquirement(p_ptr->y, p_ptr->x, randint1(2) + 1, FALSE, FALSE, FALSE);
4659 reward = _("上質なアイテムを手に入れた。", "good items");
4664 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4665 msg_print(_("「下僕よ、汝の献身への我が惜しみ無き報いを見るがよい。」", "'Behold, mortal, how generously I reward thy loyalty.'"));
4667 acquirement(p_ptr->y, p_ptr->x, randint1(2) + 1, TRUE, FALSE, FALSE);
4668 reward = _("高級品のアイテムを手に入れた。", "excellent items");
4673 msg_format("%sの声が轟き渡った:", chaos_patrons[p_ptr->chaos_patron]);
4675 msg_format("The voice of %s thunders:", chaos_patrons[p_ptr->chaos_patron]);
4678 msg_print(_("「下僕よ、汝傲慢なり。」", "'Thou art growing arrogant, mortal.'"));
4680 (void)activate_ty_curse(FALSE, &count);
4681 reward = _("禍々しい呪いをかけられた。", "cursing");
4686 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4687 msg_print(_("「我が下僕たちよ、かの傲慢なる者を倒すべし!」", "'My pets, destroy the arrogant mortal!'"));
4689 for (dummy = 0; dummy < randint1(5) + 1; dummy++)
4691 (void)summon_specific(0, p_ptr->y, p_ptr->x, dun_level, 0, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET));
4693 reward = _("モンスターを召喚された。", "summoning hostile monsters");
4699 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4700 msg_print(_("「汝、より強き敵を必要とせり!」", "'Thou needst worthier opponents!'"));
4702 activate_hi_summon(p_ptr->y, p_ptr->x, FALSE);
4703 reward = _("モンスターを召喚された。", "summoning many hostile monsters");
4709 msg_format("%sの声が響き渡った:",
4710 chaos_patrons[p_ptr->chaos_patron]);
4712 msg_format("The voice of %s booms out:",
4713 chaos_patrons[p_ptr->chaos_patron]);
4716 msg_print(_("「死と破壊こそ我が喜びなり!」", "'Death and destruction! This pleaseth me!'"));
4719 reward = _("カオスの力が渦巻いた。", "calling chaos");
4725 msg_format("%sの声が鳴り響いた:",
4726 chaos_patrons[p_ptr->chaos_patron]);
4728 msg_format("The voice of %s rings out:",
4729 chaos_patrons[p_ptr->chaos_patron]);
4732 msg_print(_("「留まるのだ、下僕よ。余が汝の肉体を鍛えん。」", "'Stay, mortal, and let me mold thee.'"));
4734 if (one_in_(3) && !(chaos_stats[p_ptr->chaos_patron] < 0))
4735 do_inc_stat(chaos_stats[p_ptr->chaos_patron]);
4737 do_inc_stat(randint0(6));
4738 reward = _("能力値が上がった。", "increasing a stat");
4744 msg_format("%sの声が響き渡った:",
4745 chaos_patrons[p_ptr->chaos_patron]);
4747 msg_format("The voice of %s booms out:",
4748 chaos_patrons[p_ptr->chaos_patron]);
4751 msg_print(_("「下僕よ、余は汝に飽みたり。」", "'I grow tired of thee, mortal.'"));
4753 if (one_in_(3) && !(chaos_stats[p_ptr->chaos_patron] < 0))
4754 do_dec_stat(chaos_stats[p_ptr->chaos_patron]);
4756 (void)do_dec_stat(randint0(6));
4757 reward = _("能力値が下がった。", "decreasing a stat");
4764 msg_format("%sの声が轟き渡った:",
4765 chaos_patrons[p_ptr->chaos_patron]);
4767 msg_format("The voice of %s thunders:",
4768 chaos_patrons[p_ptr->chaos_patron]);
4771 msg_print(_("「汝、謙虚たることを学ぶべし!」", "'Thou needst a lesson in humility, mortal!'"));
4772 msg_print(_("あなたは以前より弱くなった!", "You feel less powerful!"));
4774 for (dummy = 0; dummy < 6; dummy++)
4776 (void)dec_stat(dummy, 10 + randint1(15), TRUE);
4778 reward = _("全能力値が下がった。", "decreasing all stats");
4783 msg_format(_("%sの力が触れるのを感じた。", "You feel the power of %s touch you."),
4784 chaos_patrons[p_ptr->chaos_patron]);
4786 reward = _("傷が変化した。", "polymorphing wounds");
4791 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4793 msg_print(_("「我がささやかなる賜物を受けとるがよい!」", "'Receive this modest gift from me!'"));
4795 for (dummy = 0; dummy < 6; dummy++)
4797 (void)do_inc_stat(dummy);
4799 reward = _("全能力値が上がった。", "increasing all stats");
4804 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4805 msg_print(_("「苦しむがよい、無能な愚か者よ!」", "'Suffer, pathetic fool!'"));
4807 fire_ball(GF_DISINTEGRATE, 0, p_ptr->lev * 4, 4);
4808 take_hit(DAMAGE_NOESCAPE, p_ptr->lev * 4, wrath_reason, -1);
4809 reward = _("分解の球が発生した。", "generating disintegration ball");
4814 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4815 (void)restore_level();
4816 (void)restore_all_status();
4817 (void)true_healing(5000);
4818 reward = _("体力が回復した。", "healing");
4823 if (!buki_motteruka(INVEN_RARM) && !buki_motteruka(INVEN_LARM)) break;
4824 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4825 msg_print(_("「汝、武器に頼ることなかれ。」", "'Thou reliest too much on thy weapon.'"));
4828 if (buki_motteruka(INVEN_LARM))
4831 if (buki_motteruka(INVEN_RARM) && one_in_(2)) dummy = INVEN_RARM;
4833 object_desc(o_name, &inventory[dummy], OD_NAME_ONLY);
4834 (void)curse_weapon(FALSE, dummy);
4835 reward = format(_("%sが破壊された。", "destroying %s"), o_name);
4840 if (!inventory[INVEN_BODY].k_idx) break;
4841 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4842 msg_print(_("「汝、防具に頼ることなかれ。」", "'Thou reliest too much on thine equipment.'"));
4844 object_desc(o_name, &inventory[INVEN_BODY], OD_NAME_ONLY);
4845 (void)curse_armor();
4846 reward = format(_("%sが破壊された。", "destroying %s"), o_name);
4850 msg_format(_("%sの声がささやいた:", "The voice of %s whispers:"), chaos_patrons[p_ptr->chaos_patron]);
4851 msg_print(_("「我を怒りしめた罪を償うべし。」", "'Now thou shalt pay for annoying me.'"));
4853 switch (randint1(4))
4856 (void)activate_ty_curse(FALSE, &count);
4857 reward = _("禍々しい呪いをかけられた。", "cursing");
4860 activate_hi_summon(p_ptr->y, p_ptr->x, FALSE);
4861 reward = _("モンスターを召喚された。", "summoning hostile monsters");
4866 if (!buki_motteruka(INVEN_RARM) && !buki_motteruka(INVEN_LARM)) break;
4868 if (buki_motteruka(INVEN_LARM))
4871 if (buki_motteruka(INVEN_RARM) && one_in_(2)) dummy = INVEN_RARM;
4873 object_desc(o_name, &inventory[dummy], OD_NAME_ONLY);
4874 (void)curse_weapon(FALSE, dummy);
4875 reward = format(_("%sが破壊された。", "destroying %s"), o_name);
4879 if (!inventory[INVEN_BODY].k_idx) break;
4880 object_desc(o_name, &inventory[INVEN_BODY], OD_NAME_ONLY);
4881 (void)curse_armor();
4882 reward = format(_("%sが破壊された。", "destroying %s"), o_name);
4886 for (dummy = 0; dummy < 6; dummy++)
4888 (void)dec_stat(dummy, 10 + randint1(15), TRUE);
4890 reward = _("全能力値が下がった。", "decreasing all stats");
4897 msg_format(_("%sの声が轟き渡った:", "The voice of %s thunders:"), chaos_patrons[p_ptr->chaos_patron]);
4898 msg_print(_("「死ぬがよい、下僕よ!」", "'Die, mortal!'"));
4900 take_hit(DAMAGE_LOSELIFE, p_ptr->lev * 4, wrath_reason, -1);
4901 for (dummy = 0; dummy < 6; dummy++)
4903 (void)dec_stat(dummy, 10 + randint1(15), FALSE);
4905 activate_hi_summon(p_ptr->y, p_ptr->x, FALSE);
4906 (void)activate_ty_curse(FALSE, &count);
4911 if (buki_motteruka(INVEN_RARM))
4914 if (buki_motteruka(INVEN_LARM) && one_in_(2)) dummy = INVEN_LARM;
4916 else if (buki_motteruka(INVEN_LARM)) dummy = INVEN_LARM;
4918 if (dummy) (void)curse_weapon(FALSE, dummy);
4920 if (one_in_(2)) (void)curse_armor();
4925 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4926 msg_print(_("「死と破壊こそ我が喜びなり!」", "'Death and destruction! This pleaseth me!'"));
4928 (void)destroy_area(p_ptr->y, p_ptr->x, 25, FALSE);
4929 reward = _("ダンジョンが*破壊*された。", "*destruct*ing dungeon");
4934 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4935 msg_print(_("「我、汝の敵を抹殺せん!」", "'Let me relieve thee of thine oppressors!'"));
4936 (void)symbol_genocide(0, FALSE);
4937 reward = _("モンスターが抹殺された。", "genociding monsters");
4942 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4943 msg_print(_("「我、汝の敵を抹殺せん!」", "'Let me relieve thee of thine oppressors!'"));
4945 (void)mass_genocide(0, FALSE);
4946 reward = _("モンスターが抹殺された。", "genociding nearby monsters");
4951 msg_format(_("%sの力が敵を攻撃するのを感じた!", "You can feel the power of %s assault your enemies!"), chaos_patrons[p_ptr->chaos_patron]);
4952 (void)dispel_monsters(p_ptr->lev * 4);
4957 msg_format(_("%sはあなたを無視した。", "%s ignores you."), chaos_patrons[p_ptr->chaos_patron]);
4962 msg_format(_("%sは褒美として悪魔の使いをよこした!", "%s rewards you with a demonic servant!"),chaos_patrons[p_ptr->chaos_patron]);
4964 if (!summon_specific(-1, p_ptr->y, p_ptr->x, dun_level, SUMMON_DEMON, PM_FORCE_PET))
4965 msg_print(_("何も現れなかった...", "Nobody ever turns up..."));
4967 reward = _("悪魔がペットになった。", "a demonic servant");
4972 msg_format(_("%sは褒美として使いをよこした!", "%s rewards you with a servant!"),chaos_patrons[p_ptr->chaos_patron]);
4974 if (!summon_specific(-1, p_ptr->y, p_ptr->x, dun_level, 0, PM_FORCE_PET))
4975 msg_print(_("何も現れなかった...", "Nobody ever turns up..."));
4977 reward = _("モンスターがペットになった。", "a servant");
4982 msg_format(_("%sは褒美としてアンデッドの使いをよこした。", "%s rewards you with an undead servant!"),chaos_patrons[p_ptr->chaos_patron]);
4984 if (!summon_specific(-1, p_ptr->y, p_ptr->x, dun_level, SUMMON_UNDEAD, PM_FORCE_PET))
4985 msg_print(_("何も現れなかった...", "Nobody ever turns up..."));
4987 reward = _("アンデッドがペットになった。", "an undead servant");
4992 msg_format(_("%sの声がどもった:", "The voice of %s stammers:"),
4994 chaos_patrons[p_ptr->chaos_patron]);
4995 msg_format(_("「あー、あー、答えは %d/%d。質問は何?」", "'Uh... uh... the answer's %d/%d, what's the question?'"), type, effect);
5001 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, format(_("パトロンの報酬で%s", "The patron rewards you with %s."), reward));
5007 * XAngband: determine if a given location is "interesting"
5008 * based on target_set_accept function.
5010 static bool tgt_pt_accept(POSITION y, POSITION x)
5015 if (!(in_bounds(y, x))) return (FALSE);
5017 /* Player grid is always interesting */
5018 if ((y == p_ptr->y) && (x == p_ptr->x)) return (TRUE);
5020 /* Handle hallucination */
5021 if (p_ptr->image) return (FALSE);
5023 /* Examine the grid */
5024 c_ptr = &cave[y][x];
5026 /* Interesting memorized features */
5027 if (c_ptr->info & (CAVE_MARK))
5030 if (cave_have_flag_grid(c_ptr, FF_LESS)) return (TRUE);
5031 if (cave_have_flag_grid(c_ptr, FF_MORE)) return (TRUE);
5033 /* Notice quest features */
5034 if (cave_have_flag_grid(c_ptr, FF_QUEST_ENTER)) return (TRUE);
5035 if (cave_have_flag_grid(c_ptr, FF_QUEST_EXIT)) return (TRUE);
5043 * XAngband: Prepare the "temp" array for "tget_pt"
5044 * based on target_set_prepare funciton.
5046 static void tgt_pt_prepare(void)
5050 /* Reset "temp" array */
5053 if (!expand_list) return;
5055 /* Scan the current panel */
5056 for (y = 1; y < cur_hgt; y++)
5058 for (x = 1; x < cur_wid; x++)
5060 /* Require "interesting" contents */
5061 if (!tgt_pt_accept(y, x)) continue;
5063 /* Save the location */
5070 /* Target the nearest monster for shooting */
5071 ang_sort_comp = ang_sort_comp_distance;
5072 ang_sort_swap = ang_sort_swap_distance;
5074 /* Sort the positions */
5075 ang_sort(temp_x, temp_y, temp_n);
5079 * old -- from PsiAngband.
5081 bool tgt_pt(POSITION *x_ptr, POSITION *y_ptr)
5086 bool success = FALSE;
5090 get_screen_size(&wid, &hgt);
5100 msg_print(_("場所を選んでスペースキーを押して下さい。", "Select a point and press space."));
5101 msg_flag = FALSE; /* prevents "-more-" message. */
5103 while ((ch != ESCAPE) && !success)
5105 bool move_fast = FALSE;
5107 move_cursor_relative(y, x);
5119 if (player_bold(y, x)) ch = 0;
5122 else success = TRUE;
5126 /* XAngband: Move cursor to stairs */
5129 if (expand_list && temp_n)
5132 int cx = (panel_col_min + panel_col_max) / 2;
5133 int cy = (panel_row_min + panel_row_max) / 2;
5137 /* Skip stairs which have defferent distance */
5138 for (; n < temp_n; ++ n)
5140 cave_type *c_ptr = &cave[temp_y[n]][temp_x[n]];
5142 if (cave_have_flag_grid(c_ptr, FF_STAIRS) &&
5143 cave_have_flag_grid(c_ptr, ch == '>' ? FF_MORE : FF_LESS))
5150 if (n == temp_n) /* Loop out taget list */
5155 verify_panel(); /* Move cursor to player */
5157 p_ptr->update |= (PU_MONSTERS);
5159 p_ptr->redraw |= (PR_MAP);
5161 p_ptr->window |= (PW_OVERHEAD);
5166 else /* move cursor to next stair and change panel */
5171 dy = 2 * (y - cy) / hgt;
5172 dx = 2 * (x - cx) / wid;
5173 if (dy || dx) change_panel(dy, dx);
5179 /* Look up the direction */
5180 d = get_keymap_dir(ch);
5182 /* XTRA HACK MOVEFAST */
5183 if (isupper(ch)) move_fast = TRUE;
5185 /* Handle "direction" */
5191 /* XTRA HACK MOVEFAST */
5194 int mag = MIN(wid / 2, hgt / 2);
5204 /* Do not move horizontally if unnecessary */
5205 if (((x < panel_col_min + wid / 2) && (dx > 0)) ||
5206 ((x > panel_col_min + wid / 2) && (dx < 0)))
5211 /* Do not move vertically if unnecessary */
5212 if (((y < panel_row_min + hgt / 2) && (dy > 0)) ||
5213 ((y > panel_row_min + hgt / 2) && (dy < 0)))
5218 /* Apply the motion */
5219 if ((y >= panel_row_min + hgt) || (y < panel_row_min) ||
5220 (x >= panel_col_min + wid) || (x < panel_col_min))
5222 /* if (change_panel(dy, dx)) target_set_prepare(mode); */
5223 change_panel(dy, dx);
5226 /* Slide into legality */
5227 if (x >= cur_wid-1) x = cur_wid - 2;
5228 else if (x <= 0) x = 1;
5230 /* Slide into legality */
5231 if (y >= cur_hgt-1) y = cur_hgt- 2;
5232 else if (y <= 0) y = 1;
5239 /* Clear the top line */
5242 /* Recenter the map around the player */
5245 p_ptr->update |= (PU_MONSTERS);
5247 p_ptr->redraw |= (PR_MAP);
5249 p_ptr->window |= (PW_OVERHEAD);
5260 bool get_hack_dir(DIRECTION *dp)
5268 /* Global direction */
5271 /* (No auto-targeting) */
5273 /* Ask until satisfied */
5276 /* Choose a prompt */
5279 p = _("方向 ('*'でターゲット選択, ESCで中断)? ", "Direction ('*' to choose a target, Escape to cancel)? ");
5283 p = _("方向 ('5'でターゲットへ, '*'でターゲット再選択, ESCで中断)? ", "Direction ('5' for target, '*' to re-target, Escape to cancel)? ");
5286 /* Get a command (or Cancel) */
5287 if (!get_com(p, &command, TRUE)) break;
5291 if (command == '\r') command = 't';
5294 /* Convert various keys to "standard" keys */
5297 /* Use current target */
5308 /* Set new target */
5313 if (target_set(TARGET_KILL)) dir = 5;
5319 /* Look up the direction */
5320 dir = get_keymap_dir(command);
5326 /* Verify requested targets */
5327 if ((dir == 5) && !target_okay()) dir = 0;
5334 if (!dir) return (FALSE);
5336 /* Save the direction */
5339 /* Check for confusion */
5340 if (p_ptr->confused)
5342 /* Random direction */
5343 dir = ddd[randint0(8)];
5346 /* Notice confusion */
5347 if (command_dir != dir)
5350 msg_print(_("あなたは混乱している。", "You are confused."));
5353 /* Save direction */
5356 /* A "valid" direction was entered */
5362 * エネルギーの増加量10d5を速く計算するための関数
5365 #define Go_no_JuuJou 5*5*5*5*5*5*5*5*5*5
5367 s16b gain_energy(void)
5370 s32b energy_result = 10;
5373 tmp = randint0(Go_no_JuuJou);
5375 for (i = 0; i < 9; i ++){
5376 energy_result += tmp % 5;
5380 return (s16b)(energy_result + tmp);
5385 * @brief 射撃武器の攻撃に必要な基本消費エネルギーを返す/Return bow energy
5386 * @param sval 射撃武器のアイテム副分類ID
5387 * @return 消費する基本エネルギー
5389 ENERGY bow_energy(OBJECT_SUBTYPE_VALUE sval)
5391 ENERGY energy = 10000;
5393 /* Analyze the launcher */
5396 /* Sling and ammo */
5403 /* Short Bow and Arrow */
5410 /* Long Bow and Arrow */
5417 /* Bow of irresponsiblity and Arrow */
5424 /* Light Crossbow and Bolt */
5431 /* Heavy Crossbow and Bolt */
5446 int bow_tmul(OBJECT_SUBTYPE_VALUE sval)
5450 /* Analyze the launcher */
5453 /* Sling and ammo */
5460 /* Short Bow and Arrow */
5467 /* Long Bow and Arrow */
5474 /* Bow of irresponsiblity and Arrow */
5481 /* Light Crossbow and Bolt */
5488 /* Heavy Crossbow and Bolt */
5500 * Return alignment title
5502 cptr your_alignment(void)
5505 if (p_ptr->align > 150) return "大善";
5506 else if (p_ptr->align > 50) return "中善";
5507 else if (p_ptr->align > 10) return "小善";
5508 else if (p_ptr->align > -11) return "中立";
5509 else if (p_ptr->align > -51) return "小悪";
5510 else if (p_ptr->align > -151) return "中悪";
5513 if (p_ptr->align > 150) return "Lawful";
5514 else if (p_ptr->align > 50) return "Good";
5515 else if (p_ptr->align > 10) return "Neutral Good";
5516 else if (p_ptr->align > -11) return "Neutral";
5517 else if (p_ptr->align > -51) return "Neutral Evil";
5518 else if (p_ptr->align > -151) return "Evil";
5519 else return "Chaotic";
5525 * Return proficiency level of weapons and misc. skills (except riding)
5527 int weapon_exp_level(int weapon_exp)
5529 if (weapon_exp < WEAPON_EXP_BEGINNER) return EXP_LEVEL_UNSKILLED;
5530 else if (weapon_exp < WEAPON_EXP_SKILLED) return EXP_LEVEL_BEGINNER;
5531 else if (weapon_exp < WEAPON_EXP_EXPERT) return EXP_LEVEL_SKILLED;
5532 else if (weapon_exp < WEAPON_EXP_MASTER) return EXP_LEVEL_EXPERT;
5533 else return EXP_LEVEL_MASTER;
5538 * Return proficiency level of riding
5540 int riding_exp_level(int riding_exp)
5542 if (riding_exp < RIDING_EXP_BEGINNER) return EXP_LEVEL_UNSKILLED;
5543 else if (riding_exp < RIDING_EXP_SKILLED) return EXP_LEVEL_BEGINNER;
5544 else if (riding_exp < RIDING_EXP_EXPERT) return EXP_LEVEL_SKILLED;
5545 else if (riding_exp < RIDING_EXP_MASTER) return EXP_LEVEL_EXPERT;
5546 else return EXP_LEVEL_MASTER;
5551 * Return proficiency level of spells
5553 int spell_exp_level(int spell_exp)
5555 if (spell_exp < SPELL_EXP_BEGINNER) return EXP_LEVEL_UNSKILLED;
5556 else if (spell_exp < SPELL_EXP_SKILLED) return EXP_LEVEL_BEGINNER;
5557 else if (spell_exp < SPELL_EXP_EXPERT) return EXP_LEVEL_SKILLED;
5558 else if (spell_exp < SPELL_EXP_MASTER) return EXP_LEVEL_EXPERT;
5559 else return EXP_LEVEL_MASTER;
5564 * Display a rumor and apply its effects
5567 IDX rumor_num(char *zz, IDX max_idx)
5569 if (strcmp(zz, "*") == 0) return randint1(max_idx - 1);
5570 return (IDX)atoi(zz);
5573 cptr rumor_bind_name(char *base, cptr fullname)
5577 s = strstr(base, "{Name}");
5581 v = format("%s%s%s", base, fullname, (s + 6));
5591 void display_rumor(bool ex)
5599 if (randint0(3) == 0) section = 1;
5602 err = _(get_rnd_line_jonly("rumors_j.txt", section, Rumor, 10),
5603 get_rnd_line("rumors.txt", section, Rumor));
5604 if (err) strcpy(Rumor, _("嘘の噂もある。", "Some rumors are wrong."));
5608 if (strncmp(Rumor, "R:", 2) == 0)
5611 cptr rumor_msg = NULL;
5612 cptr rumor_eff_format = NULL;
5613 char fullname[1024] = "";
5615 if (tokenize(Rumor + 2, 3, zz, TOKENIZE_CHECKQUOTE) == 3)
5617 if (strcmp(zz[0], "ARTIFACT") == 0)
5621 object_type *q_ptr = &forge;
5622 artifact_type *a_ptr;
5626 a_idx = rumor_num(zz[1], max_a_idx);
5628 a_ptr = &a_info[a_idx];
5629 if (a_ptr->name) break;
5632 k_idx = lookup_kind(a_ptr->tval, a_ptr->sval);
5633 object_prep(q_ptr, k_idx);
5634 q_ptr->name1 = a_idx;
5635 q_ptr->ident = IDENT_STORE;
5636 object_desc(fullname, q_ptr, OD_NAME_ONLY);
5638 else if (strcmp(zz[0], "MONSTER") == 0)
5641 monster_race *r_ptr;
5645 r_idx = rumor_num(zz[1], max_r_idx);
5646 r_ptr = &r_info[r_idx];
5647 if (r_ptr->name) break;
5650 strcpy(fullname, r_name + r_ptr->name);
5652 /* Remember this monster */
5653 if (!r_ptr->r_sights)
5658 else if (strcmp(zz[0], "DUNGEON") == 0)
5661 dungeon_info_type *d_ptr;
5665 d_idx = rumor_num(zz[1], max_d_idx);
5666 d_ptr = &d_info[d_idx];
5667 if (d_ptr->name) break;
5670 strcpy(fullname, d_name + d_ptr->name);
5672 if (!max_dlv[d_idx])
5674 max_dlv[d_idx] = d_ptr->mindepth;
5675 rumor_eff_format = _("%sに帰還できるようになった。", "You can recall to %s.");
5678 else if (strcmp(zz[0], "TOWN") == 0)
5685 t_idx = rumor_num(zz[1], NO_TOWN);
5686 if (town[t_idx].name) break;
5689 strcpy(fullname, town[t_idx].name);
5691 visit = (1L << (t_idx - 1));
5692 if ((t_idx != SECRET_TOWN) && !(p_ptr->visit & visit))
5694 p_ptr->visit |= visit;
5695 rumor_eff_format = _("%sに行ったことがある気がする。", "You feel you have been to %s.");
5699 rumor_msg = rumor_bind_name(zz[2], fullname);
5700 msg_print(rumor_msg);
5701 if (rumor_eff_format)
5704 msg_format(rumor_eff_format, fullname);
5709 if (err) msg_print(_("この情報は間違っている。", "This information is wrong."));
5713 msg_format("%s", Rumor);