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"
17 #include "monsterrace-hook.h"
18 #include "objectkind-hook.h"
21 #define REWARD_CHANCE 10
25 * @brief プレイヤーの経験値について整合性のためのチェックと調整を行う /
26 * Advance experience levels and print experience
29 void check_experience(void)
31 bool level_reward = FALSE;
32 bool level_mutation = FALSE;
33 bool level_inc_stat = FALSE;
34 bool android = (p_ptr->prace == RACE_ANDROID ? TRUE : FALSE);
35 PLAYER_LEVEL old_lev = p_ptr->lev;
37 /* Hack -- lower limit */
38 if (p_ptr->exp < 0) p_ptr->exp = 0;
39 if (p_ptr->max_exp < 0) p_ptr->max_exp = 0;
40 if (p_ptr->max_max_exp < 0) p_ptr->max_max_exp = 0;
42 /* Hack -- upper limit */
43 if (p_ptr->exp > PY_MAX_EXP) p_ptr->exp = PY_MAX_EXP;
44 if (p_ptr->max_exp > PY_MAX_EXP) p_ptr->max_exp = PY_MAX_EXP;
45 if (p_ptr->max_max_exp > PY_MAX_EXP) p_ptr->max_max_exp = PY_MAX_EXP;
47 /* Hack -- maintain "max" experience */
48 if (p_ptr->exp > p_ptr->max_exp) p_ptr->max_exp = p_ptr->exp;
50 /* Hack -- maintain "max max" experience */
51 if (p_ptr->max_exp > p_ptr->max_max_exp) p_ptr->max_max_exp = p_ptr->max_exp;
53 /* Redraw experience */
54 p_ptr->redraw |= (PR_EXP);
58 /* Lose levels while possible */
59 while ((p_ptr->lev > 1) &&
60 (p_ptr->exp < ((android ? player_exp_a : player_exp)[p_ptr->lev - 2] * p_ptr->expfact / 100L)))
64 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
65 p_ptr->redraw |= (PR_LEV | PR_TITLE);
66 p_ptr->window |= (PW_PLAYER);
71 /* Gain levels while possible */
72 while ((p_ptr->lev < PY_MAX_LEVEL) &&
73 (p_ptr->exp >= ((android ? player_exp_a : player_exp)[p_ptr->lev-1] * p_ptr->expfact / 100L)))
78 /* Save the highest level */
79 if (p_ptr->lev > p_ptr->max_plv)
81 p_ptr->max_plv = p_ptr->lev;
83 if ((p_ptr->pclass == CLASS_CHAOS_WARRIOR) ||
84 (p_ptr->muta2 & MUT2_CHAOS_GIFT))
88 if (p_ptr->prace == RACE_BEASTMAN)
90 if (one_in_(5)) level_mutation = TRUE;
92 level_inc_stat = TRUE;
94 do_cmd_write_nikki(NIKKI_LEVELUP, p_ptr->lev, NULL);
99 msg_format(_("レベル %d にようこそ。", "Welcome to level %d."), p_ptr->lev);
101 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
102 p_ptr->redraw |= (PR_LEV | PR_TITLE | PR_EXP);
103 p_ptr->window |= (PW_PLAYER | PW_SPELL | PW_INVEN);
113 if(!(p_ptr->max_plv % 10))
122 cnv_stat(p_ptr->stat_max[0], tmp);
123 prt(format(_(" a) 腕力 (現在値 %s)", " a) Str (cur %s)"), tmp), 2, 14);
124 cnv_stat(p_ptr->stat_max[1], tmp);
125 prt(format(_(" b) 知能 (現在値 %s)", " a) Int (cur %s)"), tmp), 3, 14);
126 cnv_stat(p_ptr->stat_max[2], tmp);
127 prt(format(_(" c) 賢さ (現在値 %s)", " a) Wis (cur %s)"), tmp), 4, 14);
128 cnv_stat(p_ptr->stat_max[3], tmp);
129 prt(format(_(" d) 器用 (現在値 %s)", " a) Dex (cur %s)"), tmp), 5, 14);
130 cnv_stat(p_ptr->stat_max[4], tmp);
131 prt(format(_(" e) 耐久 (現在値 %s)", " a) Con (cur %s)"), tmp), 6, 14);
132 cnv_stat(p_ptr->stat_max[5], tmp);
133 prt(format(_(" f) 魅力 (現在値 %s)", " a) Chr (cur %s)"), tmp), 7, 14);
136 prt(_(" どの能力値を上げますか?", " Which stat do you want to raise?"), 1, 14);
141 if ((choice >= 'a') && (choice <= 'f')) break;
143 for(n = 0; n < A_MAX; n++)
144 if (n != choice - 'a')
146 if (get_check(_("よろしいですか?", "Are you sure? "))) break;
148 do_inc_stat(choice - 'a');
151 else if(!(p_ptr->max_plv % 2))
152 do_inc_stat(randint0(6));
157 msg_print(_("あなたは変わった気がする...", "You feel different..."));
158 (void)gain_random_mutation(0);
159 level_mutation = FALSE;
163 * 報酬でレベルが上ると再帰的に check_experience() が
168 gain_level_reward(0);
169 level_reward = FALSE;
172 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
173 p_ptr->redraw |= (PR_LEV | PR_TITLE);
174 p_ptr->window |= (PW_PLAYER | PW_SPELL);
178 /* Load an autopick preference file */
179 if (old_lev != p_ptr->lev) autopick_load_pref(FALSE);
184 * @brief モンスターを倒した際の財宝svalを返す
185 * @param r_idx 倒したモンスターの種族ID
188 * Hack -- Return the "automatic coin type" of a monster race
189 * Used to allocate proper treasure when "Creeping coins" die
190 * Note the use of actual "monster names"
192 static OBJECT_SUBTYPE_VALUE get_coin_type(MONRACE_IDX r_idx)
194 /* Analyze monsters */
197 case MON_COPPER_COINS: return 2;
198 case MON_SILVER_COINS: return 5;
199 case MON_GOLD_COINS: return 10;
200 case MON_MITHRIL_COINS:
201 case MON_MITHRIL_GOLEM: return 16;
202 case MON_ADAMANT_COINS: return 17;
212 * @brief クエストを達成状態にする /
213 * @param quest_num 達成状態にしたいクエストのID
216 void complete_quest(QUEST_IDX quest_num)
218 quest_type* const q_ptr = &quest[quest_num];
222 case QUEST_TYPE_RANDOM:
223 if (record_rand_quest) do_cmd_write_nikki(NIKKI_RAND_QUEST_C, quest_num, NULL);
226 if (record_fix_quest) do_cmd_write_nikki(NIKKI_FIX_QUEST_C, quest_num, NULL);
230 q_ptr->status = QUEST_STATUS_COMPLETED;
231 q_ptr->complev = (byte)p_ptr->lev;
233 q_ptr->comptime = playtime;
235 if (!(q_ptr->flags & QUEST_FLAG_SILENT))
237 play_music(TERM_XTRA_MUSIC_BASIC, MUSIC_BASIC_QUEST_CLEAR);
238 msg_print(_("クエストを達成した!", "You just completed your quest!"));
244 * @brief 現在フロアに残っている敵モンスターの数を返す /
245 * @return 現在の敵モンスターの数
247 static MONSTER_NUMBER count_all_hostile_monsters(void)
250 MONSTER_NUMBER number_mon = 0;
252 for (x = 0; x < cur_wid; ++ x)
254 for (y = 0; y < cur_hgt; ++ y)
256 MONSTER_IDX m_idx = cave[y][x].m_idx;
258 if (m_idx > 0 && is_hostile(&m_list[m_idx]))
269 * @brief 特定の敵を倒した際にクエスト達成処理 /
270 * Check for "Quest" completion when a quest monster is killed or charmed.
271 * @param m_ptr 撃破したモンスターの構造体参照ポインタ
274 void check_quest_completion(monster_type *m_ptr)
279 bool create_stairs = FALSE;
289 quest_num = p_ptr->inside_quest;
291 /* Search for an active quest on this dungeon level */
296 for (i = max_q_idx - 1; i > 0; i--)
298 quest_type* const q_ptr = &quest[i];
300 /* Quest is not active */
301 if (q_ptr->status != QUEST_STATUS_TAKEN)
304 /* Quest is not a dungeon quest */
305 if (q_ptr->flags & QUEST_FLAG_PRESET)
308 /* Quest is not on this level */
309 if ((q_ptr->level != dun_level) &&
310 (q_ptr->type != QUEST_TYPE_KILL_ANY_LEVEL))
313 /* Not a "kill monster" quest */
314 if ((q_ptr->type == QUEST_TYPE_FIND_ARTIFACT) ||
315 (q_ptr->type == QUEST_TYPE_FIND_EXIT))
318 /* Interesting quest */
319 if ((q_ptr->type == QUEST_TYPE_KILL_NUMBER) ||
320 (q_ptr->type == QUEST_TYPE_TOWER) ||
321 (q_ptr->type == QUEST_TYPE_KILL_ALL))
324 /* Interesting quest */
325 if (((q_ptr->type == QUEST_TYPE_KILL_LEVEL) ||
326 (q_ptr->type == QUEST_TYPE_KILL_ANY_LEVEL) ||
327 (q_ptr->type == QUEST_TYPE_RANDOM)) &&
328 (q_ptr->r_idx == m_ptr->r_idx))
335 /* Handle the current quest */
336 if (quest_num && (quest[quest_num].status == QUEST_STATUS_TAKEN))
339 quest_type* const q_ptr = &quest[quest_num];
343 case QUEST_TYPE_KILL_NUMBER:
347 if (q_ptr->cur_num >= q_ptr->num_mon)
349 complete_quest(quest_num);
355 case QUEST_TYPE_KILL_ALL:
357 if (!is_hostile(m_ptr)) break;
359 if (count_all_hostile_monsters() == 1)
361 if (q_ptr->flags & QUEST_FLAG_SILENT)
363 q_ptr->status = QUEST_STATUS_FINISHED;
367 complete_quest(quest_num);
372 case QUEST_TYPE_KILL_LEVEL:
373 case QUEST_TYPE_RANDOM:
375 /* Only count valid monsters */
376 if (q_ptr->r_idx != m_ptr->r_idx)
381 if (q_ptr->cur_num >= q_ptr->max_num)
383 complete_quest(quest_num);
385 if (!(q_ptr->flags & QUEST_FLAG_PRESET))
387 create_stairs = TRUE;
388 p_ptr->inside_quest = 0;
391 /* Finish the two main quests without rewarding */
392 if ((quest_num == QUEST_OBERON) || (quest_num == QUEST_SERPENT))
394 q_ptr->status = QUEST_STATUS_FINISHED;
397 if (q_ptr->type == QUEST_TYPE_RANDOM)
400 q_ptr->status = QUEST_STATUS_FINISHED;
405 case QUEST_TYPE_KILL_ANY_LEVEL:
408 if (q_ptr->cur_num >= q_ptr->max_num)
410 complete_quest(quest_num);
415 case QUEST_TYPE_TOWER:
417 if (!is_hostile(m_ptr)) break;
419 if (count_all_hostile_monsters() == 1)
421 q_ptr->status = QUEST_STATUS_STAGE_COMPLETED;
423 if((quest[QUEST_TOWER1].status == QUEST_STATUS_STAGE_COMPLETED) &&
424 (quest[QUEST_TOWER2].status == QUEST_STATUS_STAGE_COMPLETED) &&
425 (quest[QUEST_TOWER3].status == QUEST_STATUS_STAGE_COMPLETED))
428 complete_quest(QUEST_TOWER1);
436 /* Create a magical staircase */
442 while (cave_perma_bold(y, x) || cave[y][x].o_idx || (cave[y][x].info & CAVE_OBJECT) )
444 /* Pick a location */
445 scatter(&ny, &nx, y, x, 1, 0);
451 /* Explain the staircase */
452 msg_print(_("魔法の階段が現れた...", "A magical staircase appears..."));
454 /* Create stairs down */
455 cave_set_feat(y, x, feat_down_stair);
457 /* Remember to update everything */
458 p_ptr->update |= (PU_FLOW);
468 for (i = 0; i < (dun_level / 15)+1; i++)
473 /* Make a great object */
474 make_object(o_ptr, AM_GOOD | AM_GREAT);
475 (void)drop_near(o_ptr, -1, y, x);
481 * @brief 特定のアーティファクトを入手した際のクエスト達成処理 /
482 * Check for "Quest" completion when a quest monster is killed or charmed.
483 * @param o_ptr 入手したオブジェクトの構造体参照ポインタ
486 void check_find_art_quest_completion(object_type *o_ptr)
489 /* Check if completed a quest */
490 for (i = 0; i < max_q_idx; i++)
492 if((quest[i].type == QUEST_TYPE_FIND_ARTIFACT) &&
493 (quest[i].status == QUEST_STATUS_TAKEN) &&
494 (quest[i].k_idx == o_ptr->name1))
503 * @brief モンスターを撃破した際の述語メッセージを返す /
504 * Return monster death string
505 * @param r_ptr 撃破されたモンスターの種族情報を持つ構造体の参照ポインタ
506 * @return 撃破されたモンスターの述語
508 cptr extract_note_dies(MONRACE_IDX r_idx)
510 monster_race *r_ptr = &r_info[r_idx];
511 /* Some monsters get "destroyed" */
512 if (!monster_living(r_idx))
516 for (i = 0; i < 4; i++)
518 if (r_ptr->blow[i].method == RBM_EXPLODE)
520 return _("は爆発して粉々になった。", " explodes into tiny shreds.");
523 return _("を倒した。", " is destroyed.");
526 /* Assume a default death */
527 return _("は死んだ。", " dies.");
532 * @brief モンスターが死亡した時の処理 /
533 * Handle the "death" of a monster.
534 * @param m_idx 死亡したモンスターのID
535 * @param drop_item TRUEならばモンスターのドロップ処理を行う
536 * @return 撃破されたモンスターの述語
539 * Disperse treasures centered at the monster location based on the
540 * various flags contained in the monster flags fields.
541 * Check for "Quest" completion when a quest monster is killed.
542 * Note that only the player can induce "monster_death()" on Uniques.
543 * Thus (for now) all Quest monsters should be Uniques.
544 * Note that monsters can now carry objects, and when a monster dies,
545 * it drops all of its objects, which may disappear in crowded rooms.
548 void monster_death(MONSTER_IDX m_idx, bool drop_item)
557 monster_type *m_ptr = &m_list[m_idx];
558 monster_race *r_ptr = &r_info[m_ptr->r_idx];
560 bool visible = ((m_ptr->ml && !p_ptr->image) || (r_ptr->flags1 & RF1_UNIQUE));
564 bool do_gold = (!(r_ptr->flags1 & RF1_ONLY_ITEM));
565 bool do_item = (!(r_ptr->flags1 & RF1_ONLY_GOLD));
566 bool cloned = (m_ptr->smart & SM_CLONED) ? TRUE : FALSE;
567 int force_coin = get_coin_type(m_ptr->r_idx);
572 bool drop_chosen_item = drop_item && !cloned && !p_ptr->inside_arena
573 && !p_ptr->inside_battle && !is_pet(m_ptr);
575 /* The caster is dead? */
576 if (world_monster && world_monster == m_idx) world_monster = 0;
578 /* Notice changes in view */
579 if (r_ptr->flags7 & (RF7_LITE_MASK | RF7_DARK_MASK))
581 /* Update some things */
582 p_ptr->update |= (PU_MON_LITE);
588 if (record_named_pet && is_pet(m_ptr) && m_ptr->nickname)
590 GAME_TEXT m_name[MAX_NLEN];
592 monster_desc(m_name, m_ptr, MD_INDEF_VISIBLE);
593 do_cmd_write_nikki(NIKKI_NAMED_PET, 3, m_name);
596 /* Let monsters explode! */
597 for (i = 0; i < 4; i++)
599 if (r_ptr->blow[i].method == RBM_EXPLODE)
601 BIT_FLAGS flg = PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL;
602 EFFECT_ID typ = mbe_info[r_ptr->blow[i].effect].explode_type;
603 DICE_NUMBER d_dice = r_ptr->blow[i].d_dice;
604 DICE_SID d_side = r_ptr->blow[i].d_side;
605 HIT_POINT damage = damroll(d_dice, d_side);
607 project(m_idx, 3, y, x, damage, typ, flg, -1);
612 if (m_ptr->mflag2 & MFLAG2_CHAMELEON)
614 choose_new_monster(m_idx, TRUE, MON_CHAMELEON);
615 r_ptr = &r_info[m_ptr->r_idx];
618 /* Check for quest completion */
619 check_quest_completion(m_ptr);
621 /* Handle the possibility of player vanquishing arena combatant -KMW- */
622 if (p_ptr->inside_arena && !is_pet(m_ptr))
624 p_ptr->exit_bldg = TRUE;
626 if (p_ptr->arena_number > MAX_ARENA_MONS)
628 msg_print(_("素晴らしい!君こそ真の勝利者だ。", "You are a Genuine Champion!"));
632 msg_print(_("勝利!チャンピオンへの道を進んでいる。", "Victorious! You're on your way to becoming Champion."));
635 if (arena_info[p_ptr->arena_number].tval)
639 /* Prepare to make a prize */
640 object_prep(q_ptr, lookup_kind(arena_info[p_ptr->arena_number].tval, arena_info[p_ptr->arena_number].sval));
641 apply_magic(q_ptr, object_level, AM_NO_FIXED_ART);
642 (void)drop_near(q_ptr, -1, y, x);
645 if (p_ptr->arena_number > MAX_ARENA_MONS) p_ptr->arena_number++;
646 p_ptr->arena_number++;
649 GAME_TEXT m_name[MAX_NLEN];
651 /* Extract monster name */
652 monster_desc(m_name, m_ptr, MD_IGNORE_HALLU | MD_ASSUME_VISIBLE | MD_INDEF_VISIBLE);
654 do_cmd_write_nikki(NIKKI_ARENA, p_ptr->arena_number, m_name);
658 if (m_idx == p_ptr->riding)
660 if (rakuba(-1, FALSE))
662 msg_print(_("地面に落とされた。", "You have fallen from your riding pet."));
666 /* Drop a dead corpse? */
667 if (one_in_(r_ptr->flags1 & RF1_UNIQUE ? 1 : 4) &&
668 (r_ptr->flags9 & (RF9_DROP_CORPSE | RF9_DROP_SKELETON)) &&
669 !(p_ptr->inside_arena || p_ptr->inside_battle || cloned || ((m_ptr->r_idx == today_mon) && is_pet(m_ptr))))
671 /* Assume skeleton */
675 * We cannot drop a skeleton? Note, if we are in this check,
676 * we *know* we can drop at least a corpse or a skeleton
678 if (!(r_ptr->flags9 & RF9_DROP_SKELETON))
680 else if ((r_ptr->flags9 & RF9_DROP_CORPSE) && (r_ptr->flags1 & RF1_UNIQUE))
683 /* Else, a corpse is more likely unless we did a "lot" of damage */
684 else if (r_ptr->flags9 & RF9_DROP_CORPSE)
686 /* Lots of damage in one blow */
687 if ((0 - ((m_ptr->maxhp) / 4)) > m_ptr->hp)
689 if (one_in_(5)) corpse = TRUE;
693 if (!one_in_(5)) corpse = TRUE;
698 /* Prepare to make an object */
699 object_prep(q_ptr, lookup_kind(TV_CORPSE, (corpse ? SV_CORPSE : SV_SKELETON)));
701 apply_magic(q_ptr, object_level, AM_NO_FIXED_ART);
703 q_ptr->pval = m_ptr->r_idx;
704 (void)drop_near(q_ptr, -1, y, x);
707 /* Drop objects being carried */
708 monster_drop_carried_objects(m_ptr);
710 if (r_ptr->flags1 & RF1_DROP_GOOD) mo_mode |= AM_GOOD;
711 if (r_ptr->flags1 & RF1_DROP_GREAT) mo_mode |= AM_GREAT;
713 switch (m_ptr->r_idx)
715 case MON_PINK_HORROR:
716 /* Pink horrors are replaced with 2 Blue horrors */
717 if (!(p_ptr->inside_arena || p_ptr->inside_battle))
721 for (i = 0; i < 2; i++)
723 POSITION wy = y, wx = x;
724 bool pet = is_pet(m_ptr);
727 if (pet) mode |= PM_FORCE_PET;
729 if (summon_specific((pet ? -1 : m_idx), wy, wx, 100, SUMMON_BLUE_HORROR, mode, '\0'))
731 if (player_can_see_bold(wy, wx)) notice = TRUE;
735 if (notice) msg_print(_("ピンク・ホラーは分裂した!", "The Pink horror divides!"));
739 case MON_BLOODLETTER:
740 /* Bloodletters of Khorne may drop a blade of chaos */
741 if (drop_chosen_item && (randint1(100) < 15))
745 /* Prepare to make a Blade of Chaos */
746 object_prep(q_ptr, lookup_kind(TV_SWORD, SV_BLADE_OF_CHAOS));
748 apply_magic(q_ptr, object_level, AM_NO_FIXED_ART | mo_mode);
749 (void)drop_near(q_ptr, -1, y, x);
754 if (drop_chosen_item && (dun_level > 9))
759 /* Activate restriction */
760 if ((dun_level > 49) && one_in_(5))
761 get_obj_num_hook = kind_is_good_book;
763 get_obj_num_hook = kind_is_book;
766 make_object(q_ptr, mo_mode);
767 (void)drop_near(q_ptr, -1, y, x);
773 * Mega^3-hack: killing a 'Warrior of the Dawn' is likely to
774 * spawn another in the fallen one's place!
776 if (!p_ptr->inside_arena && !p_ptr->inside_battle)
780 POSITION wy = y, wx = x;
782 bool pet = is_pet(m_ptr);
786 scatter(&wy, &wx, y, x, 20, 0);
788 while (!(in_bounds(wy, wx) && cave_empty_bold2(wy, wx)) && --attempts);
793 if (pet) mode |= PM_FORCE_PET;
795 if (summon_specific((pet ? -1 : m_idx), wy, wx, 100, SUMMON_DAWN, mode, '\0'))
797 if (player_can_see_bold(wy, wx))
798 msg_print(_("新たな戦士が現れた!", "A new warrior steps forth!"));
806 /* One more ultra-hack: An Unmaker goes out with a big bang! */
808 BIT_FLAGS flg = PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL;
809 (void)project(m_idx, 6, y, x, 100, GF_CHAOS, flg, -1);
813 case MON_UNICORN_ORD:
816 /* Reward for "lazy" player */
817 if (p_ptr->pseikaku == SEIKAKU_NAMAKE)
819 ARTIFACT_IDX a_idx = 0;
820 artifact_type *a_ptr = NULL;
822 if (!drop_chosen_item) break;
829 a_idx = ART_NAMAKE_HAMMER;
832 a_idx = ART_NAMAKE_BOW;
835 a_idx = ART_NAMAKE_ARMOR;
839 a_ptr = &a_info[a_idx];
841 while (a_ptr->cur_num);
843 /* Create the artifact */
844 if (create_named_art(a_idx, y, x))
848 /* Hack -- Memorize location of artifact in saved floors */
849 if (character_dungeon) a_ptr->floor_id = p_ptr->floor_id;
851 else if (!preserve_mode) a_ptr->cur_num = 1;
856 if (!drop_chosen_item) break;
859 /* Mega-Hack -- Prepare to make "Grond" */
860 object_prep(q_ptr, lookup_kind(TV_HAFTED, SV_GROND));
862 /* Mega-Hack -- Mark this item as "Grond" */
863 q_ptr->name1 = ART_GROND;
865 /* Mega-Hack -- Actually create "Grond" */
866 apply_magic(q_ptr, -1, AM_GOOD | AM_GREAT);
867 (void)drop_near(q_ptr, -1, y, x);
870 /* Mega-Hack -- Prepare to make "Chaos" */
871 object_prep(q_ptr, lookup_kind(TV_CROWN, SV_CHAOS));
873 /* Mega-Hack -- Mark this item as "Chaos" */
874 q_ptr->name1 = ART_CHAOS;
876 /* Mega-Hack -- Actually create "Chaos" */
877 apply_magic(q_ptr, -1, AM_GOOD | AM_GREAT);
878 (void)drop_near(q_ptr, -1, y, x);
881 case MON_B_DEATH_SWORD:
882 if (drop_chosen_item)
886 /* Prepare to make a broken sword */
887 object_prep(q_ptr, lookup_kind(TV_SWORD, randint1(2)));
888 (void)drop_near(q_ptr, -1, y, x);
894 if (drop_chosen_item && ((m_ptr->r_idx == MON_A_GOLD) ||
895 ((m_ptr->r_idx == MON_A_SILVER) && (r_ptr->r_akills % 5 == 0))))
899 /* Prepare to make a Can of Toys */
900 object_prep(q_ptr, lookup_kind(TV_CHEST, SV_CHEST_KANDUME));
902 apply_magic(q_ptr, object_level, AM_NO_FIXED_ART);
903 (void)drop_near(q_ptr, -1, y, x);
909 BIT_FLAGS flg = PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL;
910 (void)project(m_idx, 3, y, x, damroll(20, 10), GF_FIRE, flg, -1);
915 if (!drop_chosen_item) break;
917 switch (r_ptr->d_char)
925 /* Activate restriction */
926 get_obj_num_hook = kind_is_cloak;
929 make_object(q_ptr, mo_mode);
930 (void)drop_near(q_ptr, -1, y, x);
940 /* Activate restriction */
941 get_obj_num_hook = kind_is_polearm;
943 /* Make a poleweapon */
944 make_object(q_ptr, mo_mode);
945 (void)drop_near(q_ptr, -1, y, x);
955 /* Activate restriction */
956 get_obj_num_hook = kind_is_armor;
958 /* Make a hard armor */
959 make_object(q_ptr, mo_mode);
960 (void)drop_near(q_ptr, -1, y, x);
970 /* Activate restriction */
971 get_obj_num_hook = kind_is_hafted;
973 /* Make a hafted weapon */
974 make_object(q_ptr, mo_mode);
975 (void)drop_near(q_ptr, -1, y, x);
980 if (m_ptr->r_idx != MON_STORMBRINGER)
985 /* Activate restriction */
986 get_obj_num_hook = kind_is_sword;
989 make_object(q_ptr, mo_mode);
990 (void)drop_near(q_ptr, -1, y, x);
997 /* Mega-Hack -- drop fixed items */
998 if (drop_chosen_item)
1000 ARTIFACT_IDX a_idx = 0;
1003 for(i = 0; i < 4; i++)
1005 if(!r_ptr->artifact_id[i]) break;
1006 a_idx = r_ptr->artifact_id[i];
1007 chance = r_ptr->artifact_percent[i];
1010 if ((a_idx > 0) && ((randint0(100) < chance) || p_ptr->wizard))
1012 artifact_type *a_ptr = &a_info[a_idx];
1014 if (!a_ptr->cur_num)
1016 /* Create the artifact */
1017 if (create_named_art(a_idx, y, x))
1021 /* Hack -- Memorize location of artifact in saved floors */
1022 if (character_dungeon) a_ptr->floor_id = p_ptr->floor_id;
1024 else if (!preserve_mode) a_ptr->cur_num = 1;
1028 if ((r_ptr->flags7 & RF7_GUARDIAN) && (d_info[dungeon_type].final_guardian == m_ptr->r_idx))
1030 KIND_OBJECT_IDX k_idx = d_info[dungeon_type].final_object ? d_info[dungeon_type].final_object
1031 : lookup_kind(TV_SCROLL, SV_SCROLL_ACQUIREMENT);
1033 if (d_info[dungeon_type].final_artifact)
1035 a_idx = d_info[dungeon_type].final_artifact;
1036 artifact_type *a_ptr = &a_info[a_idx];
1038 if (!a_ptr->cur_num)
1040 /* Create the artifact */
1041 if (create_named_art(a_idx, y, x))
1045 /* Hack -- Memorize location of artifact in saved floors */
1046 if (character_dungeon) a_ptr->floor_id = p_ptr->floor_id;
1048 else if (!preserve_mode) a_ptr->cur_num = 1;
1050 /* Prevent rewarding both artifact and "default" object */
1051 if (!d_info[dungeon_type].final_object) k_idx = 0;
1059 /* Prepare to make a reward */
1060 object_prep(q_ptr, k_idx);
1062 apply_magic(q_ptr, object_level, AM_NO_FIXED_ART | AM_GOOD);
1063 (void)drop_near(q_ptr, -1, y, x);
1065 msg_format(_("あなたは%sを制覇した!", "You have conquered %s!"),d_name+d_info[dungeon_type].name);
1069 /* Determine how much we can drop */
1070 if ((r_ptr->flags1 & RF1_DROP_60) && (randint0(100) < 60)) number++;
1071 if ((r_ptr->flags1 & RF1_DROP_90) && (randint0(100) < 90)) number++;
1072 if (r_ptr->flags1 & RF1_DROP_1D2) number += damroll(1, 2);
1073 if (r_ptr->flags1 & RF1_DROP_2D2) number += damroll(2, 2);
1074 if (r_ptr->flags1 & RF1_DROP_3D2) number += damroll(3, 2);
1075 if (r_ptr->flags1 & RF1_DROP_4D2) number += damroll(4, 2);
1077 if (cloned && !(r_ptr->flags1 & RF1_UNIQUE))
1078 number = 0; /* Clones drop no stuff unless Cloning Pits */
1080 if (is_pet(m_ptr) || p_ptr->inside_battle || p_ptr->inside_arena)
1081 number = 0; /* Pets drop no stuff */
1082 if (!drop_item && (r_ptr->d_char != '$')) number = 0;
1084 if((r_ptr->flags2 & (RF2_MULTIPLY)) && (r_ptr->r_akills > 1024))
1085 number = 0; /* Limit of Multiply monster drop */
1087 /* Hack -- handle creeping coins */
1088 coin_type = force_coin;
1090 /* Average dungeon and monster levels */
1091 object_level = (dun_level + r_ptr->level) / 2;
1093 /* Drop some objects */
1094 for (j = 0; j < number; j++)
1100 if (do_gold && (!do_item || (randint0(100) < 50)))
1102 /* Make some gold */
1103 if (!make_gold(q_ptr)) continue;
1111 /* Make an object */
1112 if (!make_object(q_ptr, mo_mode)) continue;
1116 (void)drop_near(q_ptr, -1, y, x);
1119 /* Reset the object level */
1120 object_level = base_level;
1122 /* Reset "coin" type */
1126 /* Take note of any dropped treasure */
1127 if (visible && (dump_item || dump_gold))
1129 /* Take notes on treasure */
1130 lore_treasure(m_idx, dump_item, dump_gold);
1133 /* Only process "Quest Monsters" */
1134 if (!(r_ptr->flags1 & RF1_QUESTOR)) return;
1135 if (p_ptr->inside_battle) return;
1138 if ((m_ptr->r_idx == MON_SERPENT) && !cloned)
1141 p_ptr->total_winner = TRUE;
1143 /* Redraw the "title" */
1144 p_ptr->redraw |= (PR_TITLE);
1146 play_music(TERM_XTRA_MUSIC_BASIC, MUSIC_BASIC_FINAL_QUEST_CLEAR);
1148 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, _("見事に変愚蛮怒の勝利者となった!", "become *WINNER* of Hengband finely!"));
1150 if ((p_ptr->pclass == CLASS_CHAOS_WARRIOR) || (p_ptr->muta2 & MUT2_CHAOS_GIFT))
1152 msg_format(_("%sからの声が響いた。", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
1153 msg_print(_("『よくやった、定命の者よ!』", "'Thou art donst well, mortal!'"));
1156 /* Congratulations */
1157 msg_print(_("*** おめでとう ***", "*** CONGRATULATIONS ***"));
1158 msg_print(_("あなたはゲームをコンプリートしました。", "You have won the game!"));
1159 msg_print(_("準備が整ったら引退(自殺コマンド)しても結構です。", "You may retire (commit suicide) when you are ready."));
1164 * @brief モンスターに与えたダメージの修正処理 /
1165 * Modify the physical damage done to the monster.
1166 * @param m_ptr ダメージを受けるモンスターの構造体参照ポインタ
1167 * @param dam ダメージ基本値
1168 * @param is_psy_spear 攻撃手段が光の剣ならばTRUE
1169 * @return 修正を行った結果のダメージ量
1172 * (for example when it's invulnerable or shielded)
1173 * ToDo: Accept a damage-type to calculate the modified damage from
1174 * things like fire, frost, lightning, poison, ... attacks.
1175 * "type" is not yet used and should be 0.
1178 HIT_POINT mon_damage_mod(monster_type *m_ptr, HIT_POINT dam, bool is_psy_spear)
1180 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1182 if ((r_ptr->flagsr & RFR_RES_ALL) && dam > 0)
1185 if ((dam == 0) && one_in_(3)) dam = 1;
1188 if (MON_INVULNER(m_ptr))
1192 if (!p_ptr->blind && is_seen(m_ptr))
1194 msg_print(_("バリアを切り裂いた!", "The barrier is penetrated!"));
1197 else if (!one_in_(PENETRATE_INVULNERABILITY))
1207 * @brief モンスターに与えたダメージを元に経験値を加算する /
1208 * Calculate experience point to be get
1209 * @param dam 与えたダメージ量
1210 * @param m_ptr ダメージを与えたモンスターの構造体参照ポインタ
1214 * Even the 64 bit operation is not big enough to avoid overflaw
1215 * unless we carefully choose orders of multiplication and division.
1216 * Get the coefficient first, and multiply (potentially huge) base
1217 * experience point of a monster later.
1220 static void get_exp_from_mon(HIT_POINT dam, monster_type *m_ptr)
1222 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1229 if (!m_ptr->r_idx) return;
1230 if (is_pet(m_ptr) || p_ptr->inside_battle) return;
1233 * - Ratio of monster's level to player's level effects
1234 * - Varying speed effects
1235 * - Get a fraction in proportion of damage point
1237 new_exp = r_ptr->level * SPEED_TO_ENERGY(m_ptr->mspeed) * dam;
1240 div_l = (p_ptr->max_plv+2) * SPEED_TO_ENERGY(r_ptr->speed);
1242 /* Use (average maxhp * 2) as a denominator */
1243 if (!(r_ptr->flags1 & RF1_FORCE_MAXHP))
1244 s64b_mul(&div_h, &div_l, 0, r_ptr->hdice * (ironman_nightmare ? 2 : 1) * (r_ptr->hside + 1));
1246 s64b_mul(&div_h, &div_l, 0, r_ptr->hdice * (ironman_nightmare ? 2 : 1) * r_ptr->hside * 2);
1248 /* Special penalty in the wilderness */
1249 if (!dun_level && (!(r_ptr->flags8 & RF8_WILD_ONLY) || !(r_ptr->flags1 & RF1_UNIQUE)))
1250 s64b_mul(&div_h, &div_l, 0, 5);
1252 /* Do division first to prevent overflaw */
1253 s64b_div(&new_exp, &new_exp_frac, div_h, div_l);
1255 /* Special penalty for mutiply-monster */
1256 if ((r_ptr->flags2 & RF2_MULTIPLY) || (m_ptr->r_idx == MON_DAWN))
1258 int monnum_penarty = r_ptr->r_akills / 400;
1259 if (monnum_penarty > 8) monnum_penarty = 8;
1261 while (monnum_penarty--)
1264 s64b_RSHIFT(new_exp, new_exp_frac, 2);
1268 /* Special penalty for rest_and_shoot exp scum */
1269 if ((m_ptr->dealt_damage > m_ptr->max_maxhp) && (m_ptr->hp >= 0))
1271 int over_damage = m_ptr->dealt_damage / m_ptr->max_maxhp;
1272 if (over_damage > 32) over_damage = 32;
1274 while (over_damage--)
1277 s64b_mul(&new_exp, &new_exp_frac, 0, 9);
1278 s64b_div(&new_exp, &new_exp_frac, 0, 10);
1282 /* Finally multiply base experience point of the monster */
1283 s64b_mul(&new_exp, &new_exp_frac, 0, r_ptr->mexp);
1285 /* Gain experience */
1286 gain_exp_64(new_exp, new_exp_frac);
1291 * @brief モンスターのHPをダメージに応じて減算する /
1292 * Decreases monsters hit points, handling monster death.
1293 * @param dam 与えたダメージ量
1294 * @param m_idx ダメージを与えたモンスターのID
1295 * @param fear ダメージによってモンスターが恐慌状態に陥ったならばTRUEを返す
1296 * @param note モンスターが倒された際の特別なメッセージ述語
1300 * We return TRUE if the monster has been killed (and deleted).
1301 * We announce monster death (using an optional "death message"
1302 * if given, and a otherwise a generic killed/destroyed message).
1303 * Only "physical attacks" can induce the "You have slain" message.
1304 * Missile and Spell attacks will induce the "dies" message, or
1305 * various "specialized" messages. Note that "You have destroyed"
1306 * and "is destroyed" are synonyms for "You have slain" and "dies".
1307 * Hack -- unseen monsters yield "You have killed it." message.
1308 * Added fear (DGK) and check whether to print fear messages -CWS
1309 * Made name, sex, and capitalization generic -BEN-
1310 * As always, the "ghost" processing is a total hack.
1311 * Hack -- we "delay" fear messages by passing around a "fear" flag.
1312 * Consider decreasing monster experience over time, say,
1313 * by using "(m_exp * m_lev * (m_lev)) / (p_lev * (m_lev + n_killed))"
1314 * instead of simply "(m_exp * m_lev) / (p_lev)", to make the first
1315 * monster worth more than subsequent monsters. This would also need
1316 * to induce changes in the monster recall code.
1319 bool mon_take_hit(MONSTER_IDX m_idx, HIT_POINT dam, bool *fear, cptr note)
1321 monster_type *m_ptr = &m_list[m_idx];
1322 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1323 monster_type exp_mon;
1325 /* Innocent until proven otherwise */
1326 bool innocent = TRUE, thief = FALSE;
1330 (void)COPY(&exp_mon, m_ptr, monster_type);
1332 expdam = (m_ptr->hp > dam) ? dam : m_ptr->hp;
1334 get_exp_from_mon(expdam, &exp_mon);
1336 /* Genocided by chaos patron */
1337 if (!m_ptr->r_idx) m_idx = 0;
1339 /* Redraw (later) if needed */
1340 if (p_ptr->health_who == m_idx) p_ptr->redraw |= (PR_HEALTH);
1341 if (p_ptr->riding == m_idx) p_ptr->redraw |= (PR_UHEALTH);
1343 (void)set_monster_csleep(m_idx, 0);
1345 /* Hack - Cancel any special player stealth magics. -LM- */
1346 if (p_ptr->special_defense & NINJA_S_STEALTH)
1348 set_superstealth(FALSE);
1351 /* Genocided by chaos patron */
1352 if (!m_idx) return TRUE;
1355 m_ptr->dealt_damage += dam;
1357 if(m_ptr->dealt_damage > m_ptr->max_maxhp * 100) m_ptr->dealt_damage = m_ptr->max_maxhp * 100;
1361 msg_format( _("合計%d/%dのダメージを与えた。","You do %d (out of %d) damage."), m_ptr->dealt_damage, m_ptr->maxhp);
1364 /* It is dead now */
1367 GAME_TEXT m_name[MAX_NLEN];
1369 if (r_info[m_ptr->r_idx].flags7 & RF7_TANUKI)
1371 /* You might have unmasked Tanuki first time */
1372 r_ptr = &r_info[m_ptr->r_idx];
1373 m_ptr->ap_r_idx = m_ptr->r_idx;
1374 if (r_ptr->r_sights < MAX_SHORT) r_ptr->r_sights++;
1377 if (m_ptr->mflag2 & MFLAG2_CHAMELEON)
1379 /* You might have unmasked Chameleon first time */
1380 r_ptr = real_r_ptr(m_ptr);
1381 if (r_ptr->r_sights < MAX_SHORT) r_ptr->r_sights++;
1384 if (!(m_ptr->smart & SM_CLONED))
1386 /* When the player kills a Unique, it stays dead */
1387 if (r_ptr->flags1 & RF1_UNIQUE)
1391 /* Mega-Hack -- Banor & Lupart */
1392 if ((m_ptr->r_idx == MON_BANOR) || (m_ptr->r_idx == MON_LUPART))
1394 r_info[MON_BANORLUPART].max_num = 0;
1395 r_info[MON_BANORLUPART].r_pkills++;
1396 r_info[MON_BANORLUPART].r_akills++;
1397 if (r_info[MON_BANORLUPART].r_tkills < MAX_SHORT) r_info[MON_BANORLUPART].r_tkills++;
1399 else if (m_ptr->r_idx == MON_BANORLUPART)
1401 r_info[MON_BANOR].max_num = 0;
1402 r_info[MON_BANOR].r_pkills++;
1403 r_info[MON_BANOR].r_akills++;
1404 if (r_info[MON_BANOR].r_tkills < MAX_SHORT) r_info[MON_BANOR].r_tkills++;
1405 r_info[MON_LUPART].max_num = 0;
1406 r_info[MON_LUPART].r_pkills++;
1407 r_info[MON_LUPART].r_akills++;
1408 if (r_info[MON_LUPART].r_tkills < MAX_SHORT) r_info[MON_LUPART].r_tkills++;
1412 /* When the player kills a Nazgul, it stays dead */
1413 else if (r_ptr->flags7 & RF7_NAZGUL) r_ptr->max_num--;
1416 /* Count all monsters killed */
1417 if (r_ptr->r_akills < MAX_SHORT) r_ptr->r_akills++;
1419 /* Recall even invisible uniques or winners */
1420 if ((m_ptr->ml && !p_ptr->image) || (r_ptr->flags1 & RF1_UNIQUE))
1422 /* Count kills this life */
1423 if ((m_ptr->mflag2 & MFLAG2_KAGE) && (r_info[MON_KAGE].r_pkills < MAX_SHORT)) r_info[MON_KAGE].r_pkills++;
1424 else if (r_ptr->r_pkills < MAX_SHORT) r_ptr->r_pkills++;
1426 /* Count kills in all lives */
1427 if ((m_ptr->mflag2 & MFLAG2_KAGE) && (r_info[MON_KAGE].r_tkills < MAX_SHORT)) r_info[MON_KAGE].r_tkills++;
1428 else if (r_ptr->r_tkills < MAX_SHORT) r_ptr->r_tkills++;
1430 /* Hack -- Auto-recall */
1431 monster_race_track(m_ptr->ap_r_idx);
1434 /* Extract monster name */
1435 monster_desc(m_name, m_ptr, MD_TRUE_NAME);
1437 /* Don't kill Amberites */
1438 if ((r_ptr->flags3 & RF3_AMBERITE) && one_in_(2))
1440 int curses = 1 + randint1(3);
1441 bool stop_ty = FALSE;
1444 msg_format(_("%^sは恐ろしい血の呪いをあなたにかけた!", "%^s puts a terrible blood curse on you!"), m_name);
1445 curse_equipment(100, 50);
1449 stop_ty = activate_ty_curse(stop_ty, &count);
1454 if (r_ptr->flags2 & RF2_CAN_SPEAK)
1456 char line_got[1024];
1457 if (!get_rnd_line(_("mondeath_j.txt", "mondeath.txt"), m_ptr->r_idx, line_got))
1459 msg_format("%^s %s", m_name, line_got);
1463 if (m_ptr->r_idx == MON_SERPENT)
1465 screen_dump = make_screen_dump();
1470 if (!(d_info[dungeon_type].flags1 & DF1_BEGINNER))
1472 if (!dun_level && !ambush_flag && !p_ptr->inside_arena)
1474 chg_virtue(V_VALOUR, -1);
1476 else if (r_ptr->level > dun_level)
1478 if (randint1(10) <= (r_ptr->level - dun_level))
1479 chg_virtue(V_VALOUR, 1);
1481 if (r_ptr->level > 60)
1483 chg_virtue(V_VALOUR, 1);
1485 if (r_ptr->level >= 2 * (p_ptr->lev+1))
1486 chg_virtue(V_VALOUR, 2);
1489 if (r_ptr->flags1 & RF1_UNIQUE)
1491 if (r_ptr->flags3 & (RF3_EVIL | RF3_GOOD)) chg_virtue(V_HARMONY, 2);
1493 if (r_ptr->flags3 & RF3_GOOD)
1495 chg_virtue(V_UNLIFE, 2);
1496 chg_virtue(V_VITALITY, -2);
1499 if (one_in_(3)) chg_virtue(V_INDIVIDUALISM, -1);
1502 if (m_ptr->r_idx == MON_BEGGAR || m_ptr->r_idx == MON_LEPER)
1504 chg_virtue(V_COMPASSION, -1);
1507 if ((r_ptr->flags3 & RF3_GOOD) && ((r_ptr->level) / 10 + (3 * dun_level) >= randint1(100)))
1508 chg_virtue(V_UNLIFE, 1);
1510 if (r_ptr->d_char == 'A')
1512 if (r_ptr->flags1 & RF1_UNIQUE)
1513 chg_virtue(V_FAITH, -2);
1514 else if ((r_ptr->level) / 10 + (3 * dun_level) >= randint1(100))
1516 if (r_ptr->flags3 & RF3_GOOD) chg_virtue(V_FAITH, -1);
1517 else chg_virtue(V_FAITH, 1);
1520 else if (r_ptr->flags3 & RF3_DEMON)
1522 if (r_ptr->flags1 & RF1_UNIQUE)
1523 chg_virtue(V_FAITH, 2);
1524 else if ((r_ptr->level) / 10 + (3 * dun_level) >= randint1(100))
1525 chg_virtue(V_FAITH, 1);
1528 if ((r_ptr->flags3 & RF3_UNDEAD) && (r_ptr->flags1 & RF1_UNIQUE))
1529 chg_virtue(V_VITALITY, 2);
1531 if (r_ptr->r_deaths)
1533 if (r_ptr->flags1 & RF1_UNIQUE)
1535 chg_virtue(V_HONOUR, 10);
1537 else if ((r_ptr->level) / 10 + (2 * dun_level) >= randint1(100))
1539 chg_virtue(V_HONOUR, 1);
1542 if ((r_ptr->flags2 & RF2_MULTIPLY) && (r_ptr->r_akills > 1000) && one_in_(10))
1544 chg_virtue(V_VALOUR, -1);
1547 for (i = 0; i < 4; i++)
1549 if (r_ptr->blow[i].d_dice != 0) innocent = FALSE; /* Murderer! */
1551 if ((r_ptr->blow[i].effect == RBE_EAT_ITEM)
1552 || (r_ptr->blow[i].effect == RBE_EAT_GOLD))
1554 thief = TRUE; /* Thief! */
1557 /* The new law says it is illegal to live in the dungeon */
1558 if (r_ptr->level != 0) innocent = FALSE;
1562 if (r_ptr->flags1 & RF1_UNIQUE)
1563 chg_virtue(V_JUSTICE, 3);
1564 else if (1+((r_ptr->level) / 10 + (2 * dun_level)) >= randint1(100))
1565 chg_virtue(V_JUSTICE, 1);
1569 chg_virtue (V_JUSTICE, -1);
1572 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)))
1574 if (one_in_(4)) chg_virtue(V_NATURE, -1);
1577 if ((r_ptr->flags1 & RF1_UNIQUE) && record_destroy_uniq)
1580 sprintf(note_buf, "%s%s", r_name + r_ptr->name, (m_ptr->smart & SM_CLONED) ? _("(クローン)", "(Clone)") : "");
1581 do_cmd_write_nikki(NIKKI_UNIQUE, 0, note_buf);
1587 /* Death by Missile/Spell attack */
1590 msg_format("%^s%s", m_name, note);
1593 /* Death by physical attack -- invisible monster */
1594 else if (!m_ptr->ml)
1597 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
1598 msg_format("せっかくだから%sを殺した。", m_name);
1600 msg_format("%sを殺した。", m_name);
1602 msg_format("You have killed %s.", m_name);
1607 /* Death by Physical attack -- non-living monster */
1608 else if (!monster_living(m_ptr->r_idx))
1610 bool explode = FALSE;
1612 for (i = 0; i < 4; i++)
1614 if (r_ptr->blow[i].method == RBM_EXPLODE) explode = TRUE;
1617 /* Special note at death */
1619 msg_format(_("%sは爆発して粉々になった。", "%^s explodes into tiny shreds."), m_name);
1623 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
1624 msg_format("せっかくだから%sを倒した。", m_name);
1626 msg_format("%sを倒した。", m_name);
1628 msg_format("You have destroyed %s.", m_name);
1633 /* Death by Physical attack -- living monster */
1637 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
1638 msg_format("せっかくだから%sを葬り去った。", m_name);
1640 msg_format("%sを葬り去った。", m_name);
1642 msg_format("You have slain %s.", m_name);
1646 if ((r_ptr->flags1 & RF1_UNIQUE) && !(m_ptr->smart & SM_CLONED) && !vanilla_town)
1648 for (i = 0; i < MAX_KUBI; i++)
1650 if ((kubi_r_idx[i] == m_ptr->r_idx) && !(m_ptr->mflag2 & MFLAG2_CHAMELEON))
1652 msg_format(_("%sの首には賞金がかかっている。", "There is a price on %s's head."), m_name);
1658 /* Generate treasure */
1659 monster_death(m_idx, TRUE);
1661 /* Mega hack : replace IKETA to BIKETAL */
1662 if ((m_ptr->r_idx == MON_IKETA) && !(p_ptr->inside_arena || p_ptr->inside_battle))
1664 POSITION dummy_y = m_ptr->fy;
1665 POSITION dummy_x = m_ptr->fx;
1666 BIT_FLAGS mode = 0L;
1667 if (is_pet(m_ptr)) mode |= PM_FORCE_PET;
1668 delete_monster_idx(m_idx);
1669 if (summon_named_creature(0, dummy_y, dummy_x, MON_BIKETAL, mode))
1671 msg_print(_("「ハァッハッハッハ!!私がバイケタルだ!!」", "Uwa-hahaha! *I* am Biketal!"));
1676 delete_monster_idx(m_idx);
1679 get_exp_from_mon((long)exp_mon.max_maxhp*2, &exp_mon);
1684 /* Monster is dead */
1691 /* Mega-Hack -- Pain cancels fear */
1692 if (MON_MONFEAR(m_ptr) && (dam > 0))
1695 if (set_monster_monfear(m_idx, MON_MONFEAR(m_ptr) - randint1(dam)))
1702 /* Sometimes a monster gets scared by damage */
1703 if (!MON_MONFEAR(m_ptr) && !(r_ptr->flags3 & (RF3_NO_FEAR)))
1705 /* Percentage of fully healthy */
1706 int percentage = (100L * m_ptr->hp) / m_ptr->maxhp;
1709 * Run (sometimes) if at 10% or less of max hit points,
1710 * or (usually) when hit for half its current hit points
1712 if ((randint1(10) >= percentage) || ((dam >= m_ptr->hp) && (randint0(100) < 80)))
1714 /* Hack -- note fear */
1717 /* Hack -- Add some timed fear */
1718 (void)set_monster_monfear(m_idx, (randint1(10) +
1719 (((dam >= m_ptr->hp) && (percentage > 7)) ?
1720 20 : ((11 - percentage) * 5))));
1732 * @brief 現在のコンソール表示の縦横を返す。 /
1733 * Get term size and calculate screen size
1734 * @param wid_p コンソールの表示幅文字数を返す
1735 * @param hgt_p コンソールの表示行数を返す
1738 void get_screen_size(TERM_LEN *wid_p, TERM_LEN *hgt_p)
1740 Term_get_size(wid_p, hgt_p);
1741 *hgt_p -= ROW_MAP + 2;
1742 *wid_p -= COL_MAP + 2;
1743 if (use_bigtile) *wid_p /= 2;
1748 * @brief コンソール上におけるマップ表示の左上位置を返す /
1749 * Calculates current boundaries Called below and from "do_cmd_locate()".
1752 void panel_bounds_center(void)
1756 get_screen_size(&wid, &hgt);
1758 panel_row_max = panel_row_min + hgt - 1;
1759 panel_row_prt = panel_row_min - 1;
1760 panel_col_max = panel_col_min + wid - 1;
1761 panel_col_prt = panel_col_min - 13;
1766 * @brief コンソールのリサイズに合わせてマップを再描画する /
1767 * Map resizing whenever the main term changes size
1770 void resize_map(void)
1772 /* Only if the dungeon exists */
1773 if (!character_dungeon) return;
1775 /* Mega-Hack -- no panel yet */
1779 /* Reset the panels */
1780 panel_row_min = cur_hgt;
1781 panel_col_min = cur_wid;
1785 p_ptr->update |= (PU_TORCH | PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
1786 p_ptr->update |= (PU_UN_VIEW | PU_UN_LITE);
1787 p_ptr->update |= (PU_VIEW | PU_LITE | PU_MON_LITE);
1788 p_ptr->update |= (PU_MONSTERS);
1789 p_ptr->redraw |= (PR_WIPE | PR_BASIC | PR_EXTRA | PR_MAP | PR_EQUIPPY);
1796 * Place the cursor on the player
1798 if (can_save) move_cursor_relative(p_ptr->y, p_ptr->x);
1804 * @brief コンソールを再描画する /
1805 * Redraw a term when it is resized
1808 void redraw_window(void)
1810 /* Only if the dungeon exists */
1811 if (!character_dungeon) return;
1813 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_SPELL | PW_PLAYER);
1814 p_ptr->window |= (PW_MESSAGE | PW_OVERHEAD | PW_DUNGEON | PW_MONSTER | PW_OBJECT);
1822 * @brief フォーカスを当てるべきマップ描画の基準座標を指定する(サブルーチン)
1823 * @param dy 変更先のフロアY座標
1824 * @param dx 変更先のフロアX座標
1825 * Handle a request to change the current panel
1826 * Return TRUE if the panel was changed.
1827 * Also used in do_cmd_locate
1828 * @return 実際に再描画が必要だった場合TRUEを返す
1830 bool change_panel(POSITION dy, POSITION dx)
1835 get_screen_size(&wid, &hgt);
1837 /* Apply the motion */
1838 y = panel_row_min + dy * hgt / 2;
1839 x = panel_col_min + dx * wid / 2;
1841 /* Verify the row */
1842 if (y > cur_hgt - hgt) y = cur_hgt - hgt;
1845 /* Verify the col */
1846 if (x > cur_wid - wid) x = cur_wid - wid;
1849 /* Handle "changes" */
1850 if ((y != panel_row_min) || (x != panel_col_min))
1852 /* Save the new panel info */
1856 /* Recalculate the boundaries */
1857 panel_bounds_center();
1859 p_ptr->update |= (PU_MONSTERS);
1860 p_ptr->redraw |= (PR_MAP);
1872 * @brief フォーカスを当てるべきマップ描画の基準座標を指定する
1873 * @param y 変更先のフロアY座標
1874 * @param x 変更先のフロアX座標
1876 * Handle a request to change the current panel
1877 * Return TRUE if the panel was changed.
1878 * Also used in do_cmd_locate
1879 * @return 実際に再描画が必要だった場合TRUEを返す
1881 static bool change_panel_xy(POSITION y, POSITION x)
1883 POSITION dy = 0, dx = 0;
1886 get_screen_size(&wid, &hgt);
1888 if (y < panel_row_min) dy = -1;
1889 if (y > panel_row_max) dy = 1;
1890 if (x < panel_col_min) dx = -1;
1891 if (x > panel_col_max) dx = 1;
1893 if (!dy && !dx) return (FALSE);
1895 return change_panel(dy, dx);
1900 * @brief マップ描画のフォーカスを当てるべき座標を更新する
1902 * Given an row (y) and col (x), this routine detects when a move
1903 * off the screen has occurred and figures new borders. -RAK-
1904 * "Update" forces a "full update" to take place.
1905 * The map is reprinted if necessary, and "TRUE" is returned.
1906 * @return 実際に再描画が必要だった場合TRUEを返す
1908 void verify_panel(void)
1910 POSITION y = p_ptr->y;
1911 POSITION x = p_ptr->x;
1919 get_screen_size(&wid, &hgt);
1921 max_prow_min = cur_hgt - hgt;
1922 max_pcol_min = cur_wid - wid;
1924 /* Bounds checking */
1925 if (max_prow_min < 0) max_prow_min = 0;
1926 if (max_pcol_min < 0) max_pcol_min = 0;
1928 /* Center on player */
1929 if (center_player && (center_running || !running))
1931 /* Center vertically */
1932 prow_min = y - hgt / 2;
1933 if (prow_min < 0) prow_min = 0;
1934 else if (prow_min > max_prow_min) prow_min = max_prow_min;
1936 /* Center horizontally */
1937 pcol_min = x - wid / 2;
1938 if (pcol_min < 0) pcol_min = 0;
1939 else if (pcol_min > max_pcol_min) pcol_min = max_pcol_min;
1943 prow_min = panel_row_min;
1944 pcol_min = panel_col_min;
1946 /* Scroll screen when 2 grids from top/bottom edge */
1947 if (y > panel_row_max - 2)
1949 while (y > prow_min + hgt-1 - 2)
1951 prow_min += (hgt / 2);
1955 if (y < panel_row_min + 2)
1957 while (y < prow_min + 2)
1959 prow_min -= (hgt / 2);
1963 if (prow_min > max_prow_min) prow_min = max_prow_min;
1964 if (prow_min < 0) prow_min = 0;
1966 /* Scroll screen when 4 grids from left/right edge */
1967 if (x > panel_col_max - 4)
1969 while (x > pcol_min + wid-1 - 4)
1971 pcol_min += (wid / 2);
1975 if (x < panel_col_min + 4)
1977 while (x < pcol_min + 4)
1979 pcol_min -= (wid / 2);
1983 if (pcol_min > max_pcol_min) pcol_min = max_pcol_min;
1984 if (pcol_min < 0) pcol_min = 0;
1987 /* Check for "no change" */
1988 if ((prow_min == panel_row_min) && (pcol_min == panel_col_min)) return;
1990 /* Save the new panel info */
1991 panel_row_min = prow_min;
1992 panel_col_min = pcol_min;
1994 /* Hack -- optional disturb on "panel change" */
1995 if (disturb_panel && !center_player) disturb(FALSE, FALSE);
1997 /* Recalculate the boundaries */
1998 panel_bounds_center();
2000 p_ptr->update |= (PU_MONSTERS);
2001 p_ptr->redraw |= (PR_MAP);
2002 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
2007 * Monster health description
2009 cptr look_mon_desc(monster_type *m_ptr, BIT_FLAGS mode)
2011 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
2018 /* Determine if the monster is "living" */
2019 living = monster_living(m_ptr->ap_r_idx);
2021 /* Calculate a health "percentage" */
2022 perc = m_ptr->maxhp > 0 ? 100L * m_ptr->hp / m_ptr->maxhp : 0;
2024 /* Healthy monsters */
2025 if (m_ptr->hp >= m_ptr->maxhp)
2027 desc = living ? _("無傷", "unhurt") : _("無ダメージ", "undamaged");
2030 else if (perc >= 60)
2032 desc = living ? _("軽傷", "somewhat wounded") : _("小ダメージ", "somewhat damaged");
2035 else if (perc >= 25)
2037 desc = living ? _("負傷", "wounded") : _("中ダメージ", "damaged");
2040 else if (perc >= 10)
2042 desc = living ? _("重傷", "badly wounded") : _("大ダメージ", "badly damaged");
2047 desc = living ? _("半死半生", "almost dead") : _("倒れかけ", "almost destroyed");
2050 /* Need attitude information? */
2053 /* Full information is not needed */
2056 else if (is_pet(m_ptr))
2058 attitude = _(", ペット", ", pet");
2060 else if (is_friendly(m_ptr))
2062 attitude = _(", 友好的", ", friendly");
2066 attitude = _("", "");
2069 /* Clone monster? */
2070 if (m_ptr->smart & SM_CLONED)
2079 /* Display monster's level --- idea borrowed from ToME */
2080 if (ap_r_ptr->r_tkills && !(m_ptr->mflag2 & MFLAG2_KAGE))
2082 return format(_("レベル%d, %s%s%s", "Level %d, %s%s%s"), ap_r_ptr->level, desc, attitude, clone);
2086 return format(_("レベル???, %s%s%s", "Level ???, %s%s%s"), desc, attitude, clone);
2093 /*** Targeting Code ***/
2097 * Determine is a monster makes a reasonable target
2099 * The concept of "targeting" was stolen from "Morgul" (?)
2101 * The player can target any location, or any "target-able" monster.
2103 * Currently, a monster is "target_able" if it is visible, and if
2104 * the player can hit it with a projection, and the player is not
2105 * hallucinating. This allows use of "use closest target" macros.
2107 * Future versions may restrict the ability to target "trappers"
2108 * and "mimics", but the semantics is a little bit weird.
2110 bool target_able(MONSTER_IDX m_idx)
2112 monster_type *m_ptr = &m_list[m_idx];
2114 /* Monster must be alive */
2115 if (!m_ptr->r_idx) return (FALSE);
2117 /* Hack -- no targeting hallucinations */
2118 if (p_ptr->image) return (FALSE);
2120 /* Monster must be visible */
2121 if (!m_ptr->ml) return (FALSE);
2123 if (p_ptr->riding && (p_ptr->riding == m_idx)) return (TRUE);
2125 /* Monster must be projectable */
2126 if (!projectable(p_ptr->y, p_ptr->x, m_ptr->fy, m_ptr->fx)) return (FALSE);
2128 /* Hack -- Never target trappers */
2129 /* if (CLEAR_ATTR && (CLEAR_CHAR)) return (FALSE); */
2139 * Update (if necessary) and verify (if possible) the target.
2141 * We return TRUE if the target is "okay" and FALSE otherwise.
2143 bool target_okay(void)
2145 /* Accept stationary targets */
2146 if (target_who < 0) return (TRUE);
2148 /* Check moving targets */
2151 /* Accept reasonable targets */
2152 if (target_able(target_who))
2154 monster_type *m_ptr = &m_list[target_who];
2156 /* Acquire monster location */
2157 target_row = m_ptr->fy;
2158 target_col = m_ptr->fx;
2165 /* Assume no target */
2171 * Sorting hook -- comp function -- by "distance to player"
2173 * We use "u" and "v" to point to arrays of "x" and "y" positions,
2174 * and sort the arrays by double-distance to the player.
2176 static bool ang_sort_comp_distance(vptr u, vptr v, int a, int b)
2178 POSITION *x = (POSITION*)(u);
2179 POSITION *y = (POSITION*)(v);
2181 POSITION da, db, kx, ky;
2183 /* Absolute distance components */
2184 kx = x[a]; kx -= p_ptr->x; kx = ABS(kx);
2185 ky = y[a]; ky -= p_ptr->y; ky = ABS(ky);
2187 /* Approximate Double Distance to the first point */
2188 da = ((kx > ky) ? (kx + kx + ky) : (ky + ky + kx));
2190 /* Absolute distance components */
2191 kx = x[b]; kx -= p_ptr->x; kx = ABS(kx);
2192 ky = y[b]; ky -= p_ptr->y; ky = ABS(ky);
2194 /* Approximate Double Distance to the first point */
2195 db = ((kx > ky) ? (kx + kx + ky) : (ky + ky + kx));
2197 /* Compare the distances */
2203 * Sorting hook -- comp function -- by importance level of grids
2205 * We use "u" and "v" to point to arrays of "x" and "y" positions,
2206 * and sort the arrays by level of monster
2208 static bool ang_sort_comp_importance(vptr u, vptr v, int a, int b)
2210 POSITION *x = (POSITION*)(u);
2211 POSITION *y = (POSITION*)(v);
2212 cave_type *ca_ptr = &cave[y[a]][x[a]];
2213 cave_type *cb_ptr = &cave[y[b]][x[b]];
2214 monster_type *ma_ptr = &m_list[ca_ptr->m_idx];
2215 monster_type *mb_ptr = &m_list[cb_ptr->m_idx];
2216 monster_race *ap_ra_ptr, *ap_rb_ptr;
2218 /* The player grid */
2219 if (y[a] == p_ptr->y && x[a] == p_ptr->x) return TRUE;
2220 if (y[b] == p_ptr->y && x[b] == p_ptr->x) return FALSE;
2222 /* Extract monster race */
2223 if (ca_ptr->m_idx && ma_ptr->ml) ap_ra_ptr = &r_info[ma_ptr->ap_r_idx];
2224 else ap_ra_ptr = NULL;
2225 if (cb_ptr->m_idx && mb_ptr->ml) ap_rb_ptr = &r_info[mb_ptr->ap_r_idx];
2226 else ap_rb_ptr = NULL;
2228 if (ap_ra_ptr && !ap_rb_ptr) return TRUE;
2229 if (!ap_ra_ptr && ap_rb_ptr) return FALSE;
2231 /* Compare two monsters */
2232 if (ap_ra_ptr && ap_rb_ptr)
2234 /* Unique monsters first */
2235 if ((ap_ra_ptr->flags1 & RF1_UNIQUE) && !(ap_rb_ptr->flags1 & RF1_UNIQUE)) return TRUE;
2236 if (!(ap_ra_ptr->flags1 & RF1_UNIQUE) && (ap_rb_ptr->flags1 & RF1_UNIQUE)) return FALSE;
2238 /* Shadowers first (あやしい影) */
2239 if ((ma_ptr->mflag2 & MFLAG2_KAGE) && !(mb_ptr->mflag2 & MFLAG2_KAGE)) return TRUE;
2240 if (!(ma_ptr->mflag2 & MFLAG2_KAGE) && (mb_ptr->mflag2 & MFLAG2_KAGE)) return FALSE;
2242 /* Unknown monsters first */
2243 if (!ap_ra_ptr->r_tkills && ap_rb_ptr->r_tkills) return TRUE;
2244 if (ap_ra_ptr->r_tkills && !ap_rb_ptr->r_tkills) return FALSE;
2246 /* Higher level monsters first (if known) */
2247 if (ap_ra_ptr->r_tkills && ap_rb_ptr->r_tkills)
2249 if (ap_ra_ptr->level > ap_rb_ptr->level) return TRUE;
2250 if (ap_ra_ptr->level < ap_rb_ptr->level) return FALSE;
2253 /* Sort by index if all conditions are same */
2254 if (ma_ptr->ap_r_idx > mb_ptr->ap_r_idx) return TRUE;
2255 if (ma_ptr->ap_r_idx < mb_ptr->ap_r_idx) return FALSE;
2258 /* An object get higher priority */
2259 if (cave[y[a]][x[a]].o_idx && !cave[y[b]][x[b]].o_idx) return TRUE;
2260 if (!cave[y[a]][x[a]].o_idx && cave[y[b]][x[b]].o_idx) return FALSE;
2262 /* Priority from the terrain */
2263 if (f_info[ca_ptr->feat].priority > f_info[cb_ptr->feat].priority) return TRUE;
2264 if (f_info[ca_ptr->feat].priority < f_info[cb_ptr->feat].priority) return FALSE;
2266 /* If all conditions are same, compare distance */
2267 return ang_sort_comp_distance(u, v, a, b);
2272 * Sorting hook -- swap function -- by "distance to player"
2274 * We use "u" and "v" to point to arrays of "x" and "y" positions,
2275 * and sort the arrays by distance to the player.
2277 static void ang_sort_swap_distance(vptr u, vptr v, int a, int b)
2279 POSITION *x = (POSITION*)(u);
2280 POSITION *y = (POSITION*)(v);
2298 * Hack -- help "select" a location (see below)
2300 static POSITION_IDX target_pick(POSITION y1, POSITION x1, POSITION dy, POSITION dx)
2303 POSITION x2, y2, x3, y3, x4, y4;
2304 POSITION_IDX b_i = -1, b_v = 9999;
2307 /* Scan the locations */
2308 for (i = 0; i < temp_n; i++)
2314 /* Directed distance */
2318 /* Verify quadrant */
2319 if (dx && (x3 * dx <= 0)) continue;
2320 if (dy && (y3 * dy <= 0)) continue;
2322 /* Absolute distance */
2326 /* Verify quadrant */
2327 if (dy && !dx && (x4 > y4)) continue;
2328 if (dx && !dy && (y4 > x4)) continue;
2330 /* Approximate Double Distance */
2331 v = ((x4 > y4) ? (x4 + x4 + y4) : (y4 + y4 + x4));
2333 /* Penalize location */
2336 if ((b_i >= 0) && (v >= b_v)) continue;
2346 * Hack -- determine if a given location is "interesting"
2348 static bool target_set_accept(POSITION y, POSITION x)
2351 OBJECT_IDX this_o_idx, next_o_idx = 0;
2354 if (!(in_bounds(y, x))) return (FALSE);
2356 /* Player grid is always interesting */
2357 if (player_bold(y, x)) return (TRUE);
2359 /* Handle hallucination */
2360 if (p_ptr->image) return (FALSE);
2362 /* Examine the grid */
2363 c_ptr = &cave[y][x];
2365 /* Visible monsters */
2368 monster_type *m_ptr = &m_list[c_ptr->m_idx];
2370 /* Visible monsters */
2371 if (m_ptr->ml) return (TRUE);
2374 /* Scan all objects in the grid */
2375 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
2378 o_ptr = &o_list[this_o_idx];
2380 /* Acquire next object */
2381 next_o_idx = o_ptr->next_o_idx;
2383 /* Memorized object */
2384 if (o_ptr->marked & OM_FOUND) return (TRUE);
2387 /* Interesting memorized features */
2388 if (c_ptr->info & (CAVE_MARK))
2390 /* Notice object features */
2391 if (c_ptr->info & CAVE_OBJECT) return (TRUE);
2393 /* Feature code (applying "mimic" field) */
2394 if (have_flag(f_info[get_feat_mimic(c_ptr)].flags, FF_NOTICE)) return TRUE;
2402 * Prepare the "temp" array for "target_set"
2404 * Return the number of target_able monsters in the set.
2406 static void target_set_prepare(BIT_FLAGS mode)
2409 POSITION min_hgt, max_hgt, min_wid, max_wid;
2411 if (mode & TARGET_KILL)
2414 min_hgt = MAX((p_ptr->y - MAX_RANGE), 0);
2415 max_hgt = MIN((p_ptr->y + MAX_RANGE), cur_hgt - 1);
2416 min_wid = MAX((p_ptr->x - MAX_RANGE), 0);
2417 max_wid = MIN((p_ptr->x + MAX_RANGE), cur_wid - 1);
2419 else /* not targetting */
2422 min_hgt = panel_row_min;
2423 max_hgt = panel_row_max;
2424 min_wid = panel_col_min;
2425 max_wid = panel_col_max;
2428 /* Reset "temp" array */
2431 /* Scan the current panel */
2432 for (y = min_hgt; y <= max_hgt; y++)
2434 for (x = min_wid; x <= max_wid; x++)
2438 /* Require "interesting" contents */
2439 if (!target_set_accept(y, x)) continue;
2441 c_ptr = &cave[y][x];
2443 /* Require target_able monsters for "TARGET_KILL" */
2444 if ((mode & (TARGET_KILL)) && !target_able(c_ptr->m_idx)) continue;
2446 if ((mode & (TARGET_KILL)) && !target_pet && is_pet(&m_list[c_ptr->m_idx])) continue;
2448 /* Save the location */
2455 /* Set the sort hooks */
2456 if (mode & (TARGET_KILL))
2458 /* Target the nearest monster for shooting */
2459 ang_sort_comp = ang_sort_comp_distance;
2460 ang_sort_swap = ang_sort_swap_distance;
2464 /* Look important grids first in Look command */
2465 ang_sort_comp = ang_sort_comp_importance;
2466 ang_sort_swap = ang_sort_swap_distance;
2469 /* Sort the positions */
2470 ang_sort(temp_x, temp_y, temp_n);
2472 if (p_ptr->riding && target_pet && (temp_n > 1) && (mode & (TARGET_KILL)))
2477 temp_y[0] = temp_y[1];
2480 temp_x[0] = temp_x[1];
2485 void target_set_prepare_look(void){
2486 target_set_prepare(TARGET_LOOK);
2491 * Evaluate number of kill needed to gain level
2493 static void evaluate_monster_exp(char *buf, monster_type *m_ptr)
2495 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
2497 s32b exp_mon, exp_adv;
2498 u32b exp_mon_frac, exp_adv_frac;
2500 if ((p_ptr->lev >= PY_MAX_LEVEL) || (p_ptr->prace == RACE_ANDROID))
2505 else if (!ap_r_ptr->r_tkills || (m_ptr->mflag2 & MFLAG2_KAGE))
2515 /* The monster's experience point (assuming average monster speed) */
2516 exp_mon = ap_r_ptr->mexp * ap_r_ptr->level;
2518 s64b_div(&exp_mon, &exp_mon_frac, 0, (p_ptr->max_plv + 2));
2521 /* Total experience value for next level */
2522 exp_adv = player_exp[p_ptr->lev -1] * p_ptr->expfact;
2524 s64b_div(&exp_adv, &exp_adv_frac, 0, 100);
2526 /* Experience value need to get */
2527 s64b_sub(&exp_adv, &exp_adv_frac, p_ptr->exp, p_ptr->exp_frac);
2530 /* You need to kill at least one monster to get any experience */
2531 s64b_add(&exp_adv, &exp_adv_frac, exp_mon, exp_mon_frac);
2532 s64b_sub(&exp_adv, &exp_adv_frac, 0, 1);
2534 /* Extract number of monsters needed */
2535 s64b_div(&exp_adv, &exp_adv_frac, exp_mon, exp_mon_frac);
2537 /* If 999 or more monsters needed, only display "999". */
2538 num = MIN(999, exp_adv_frac);
2540 /* Display the number */
2541 sprintf(buf,"%03ld", (long int)num);
2545 bool show_gold_on_floor = FALSE;
2548 * Examine a grid, return a keypress.
2550 * The "mode" argument contains the "TARGET_LOOK" bit flag, which
2551 * indicates that the "space" key should scan through the contents
2552 * of the grid, instead of simply returning immediately. This lets
2553 * the "look" command get complete information, without making the
2554 * "target" command annoying.
2556 * The "info" argument contains the "commands" which should be shown
2557 * inside the "[xxx]" text. This string must never be empty, or grids
2558 * containing monsters will be displayed with an extra comma.
2560 * Note that if a monster is in the grid, we update both the monster
2561 * recall info and the health bar info to track that monster.
2563 * Eventually, we may allow multiple objects per grid, or objects
2564 * and terrain features in the same grid.
2566 * This function must handle blindness/hallucination.
2568 static char target_set_aux(POSITION y, POSITION x, BIT_FLAGS mode, cptr info)
2570 cave_type *c_ptr = &cave[y][x];
2571 OBJECT_IDX this_o_idx, next_o_idx = 0;
2572 cptr s1 = "", s2 = "", s3 = "", x_info = "";
2575 feature_type *f_ptr;
2576 char query = '\001';
2577 char out_val[MAX_NLEN+80];
2578 OBJECT_IDX floor_list[23];
2579 ITEM_NUMBER floor_num = 0;
2581 /* Scan all objects in the grid */
2584 floor_num = scan_floor(floor_list, y, x, 0x02);
2588 x_info = _("x物 ", "x,");
2592 /* Hack -- under the player */
2593 if (player_bold(y, x))
2606 s1 = _("ターゲット:", "Target:");
2609 /* Hack -- hallucination */
2612 cptr name = _("何か奇妙な物", "something strange");
2614 /* Display a message */
2616 sprintf(out_val, "%s%s%s%s [%s]", s1, name, s2, s3, info);
2618 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, name, info);
2622 move_cursor_relative(y, x);
2625 /* Stop on everything but "return" */
2626 if ((query != '\r') && (query != '\n')) return query;
2628 /* Repeat forever */
2633 /* Actual monsters */
2634 if (c_ptr->m_idx && m_list[c_ptr->m_idx].ml)
2636 monster_type *m_ptr = &m_list[c_ptr->m_idx];
2637 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
2638 GAME_TEXT m_name[MAX_NLEN];
2639 bool recall = FALSE;
2644 monster_desc(m_name, m_ptr, MD_INDEF_VISIBLE);
2645 monster_race_track(m_ptr->ap_r_idx);
2646 health_track(c_ptr->m_idx);
2659 /* Recall on screen */
2660 screen_roff(m_ptr->ap_r_idx, 0);
2662 /* Hack -- Complete the prompt (again) */
2663 Term_addstr(-1, TERM_WHITE, format(_(" [r思 %s%s]", " [r,%s%s]"), x_info, info));
2670 /* Normal commands */
2671 if (query != 'r') break;
2676 /* Cleare recall text and repeat */
2682 /* Describe, and prompt for recall */
2683 evaluate_monster_exp(acount, m_ptr);
2686 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);
2688 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);
2694 move_cursor_relative(y, x);
2699 /* Normal commands */
2700 if (query != 'r') break;
2706 /* Always stop at "normal" keys */
2707 if ((query != '\r') && (query != '\n') && (query != ' ') && (query != 'x')) return query;
2709 /* Sometimes stop at "space" key */
2710 if ((query == ' ') && !(mode & (TARGET_LOOK))) return query;
2712 /* Change the intro */
2713 s1 = _("それは", "It is ");
2715 /* Hack -- take account of gender */
2716 if (ap_r_ptr->flags1 & (RF1_FEMALE)) s1 = _("彼女は", "She is ");
2717 else if (ap_r_ptr->flags1 & (RF1_MALE)) s1 = _("彼は", "He is ");
2719 /* Use a preposition */
2728 /* Scan all objects being carried */
2729 for (this_o_idx = m_ptr->hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
2731 GAME_TEXT o_name[MAX_NLEN];
2734 o_ptr = &o_list[this_o_idx];
2736 /* Acquire next object */
2737 next_o_idx = o_ptr->next_o_idx;
2739 /* Obtain an object description */
2740 object_desc(o_name, o_ptr, 0);
2743 sprintf(out_val, "%s%s%s%s[%s]", s1, o_name, s2, s3, info);
2745 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, o_name, info);
2749 move_cursor_relative(y, x);
2752 /* Always stop at "normal" keys */
2753 if ((query != '\r') && (query != '\n') && (query != ' ') && (query != 'x')) return query;
2755 /* Sometimes stop at "space" key */
2756 if ((query == ' ') && !(mode & (TARGET_LOOK))) return query;
2758 /* Change the intro */
2759 s2 = _("をまた", "also carrying ");
2762 /* Use a preposition */
2779 GAME_TEXT o_name[MAX_NLEN];
2782 o_ptr = &o_list[floor_list[0]];
2784 object_desc(o_name, o_ptr, 0);
2787 sprintf(out_val, "%s%s%s%s[%s]", s1, o_name, s2, s3, info);
2789 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, o_name, info);
2793 move_cursor_relative(y, x);
2802 /* Provide one cushion before item listing */
2805 /* Display rough information about items */
2807 sprintf(out_val, "%s %d個のアイテム%s%s ['x'で一覧, %s]", s1, (int)floor_num, s2, s3, info);
2809 sprintf(out_val, "%s%s%sa pile of %d items [x,%s]", s1, s2, s3, (int)floor_num, info);
2813 move_cursor_relative(y, x);
2818 /* No request for listing */
2819 if (query != 'x' && query != ' ') return query;
2823 /** Display list of items **/
2825 /* Continue scrolling list if requested */
2833 show_gold_on_floor = TRUE;
2834 (void)show_floor(0, y, x, &min_width);
2835 show_gold_on_floor = FALSE;
2839 sprintf(out_val, "%s %d個のアイテム%s%s [Enterで次へ, %s]", s1, (int)floor_num, s2, s3, info);
2841 sprintf(out_val, "%s%s%sa pile of %d items [Enter,%s]", s1, s2, s3, (int)floor_num, info);
2848 /* Exit unless 'Enter' */
2849 if (query != '\n' && query != '\r')
2854 /* Get the object being moved. */
2855 o_idx = c_ptr->o_idx;
2857 /* Only rotate a pile of two or more objects. */
2858 if (!(o_idx && o_list[o_idx].next_o_idx)) continue;
2860 /* Remove the first object from the list. */
2861 excise_object_idx(o_idx);
2863 /* Find end of the list. */
2865 while (o_list[i].next_o_idx)
2866 i = o_list[i].next_o_idx;
2868 /* Add after the last object. */
2869 o_list[i].next_o_idx = o_idx;
2871 /* Loop and re-display the list */
2878 /* Scan all objects in the grid */
2879 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
2882 o_ptr = &o_list[this_o_idx];
2884 /* Acquire next object */
2885 next_o_idx = o_ptr->next_o_idx;
2887 if (o_ptr->marked & OM_FOUND)
2889 GAME_TEXT o_name[MAX_NLEN];
2894 /* Obtain an object description */
2895 object_desc(o_name, o_ptr, 0);
2898 sprintf(out_val, "%s%s%s%s[%s]", s1, o_name, s2, s3, info);
2900 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, o_name, info);
2904 move_cursor_relative(y, x);
2907 /* Always stop at "normal" keys */
2908 if ((query != '\r') && (query != '\n') && (query != ' ') && (query != 'x')) return query;
2910 /* Sometimes stop at "space" key */
2911 if ((query == ' ') && !(mode & TARGET_LOOK)) return query;
2913 /* Change the intro */
2914 s1 = _("それは", "It is ");
2917 if (o_ptr->number != 1) s1 = _("それらは", "They are ");
2931 /* Feature code (applying "mimic" field) */
2932 feat = get_feat_mimic(c_ptr);
2934 /* Require knowledge about grid, or ability to see grid */
2935 if (!(c_ptr->info & CAVE_MARK) && !player_can_see_bold(y, x))
2937 /* Forget feature */
2941 f_ptr = &f_info[feat];
2943 /* Terrain feature if needed */
2944 if (boring || have_flag(f_ptr->flags, FF_REMEMBER))
2948 /* Hack -- special handling for quest entrances */
2949 if (have_flag(f_ptr->flags, FF_QUEST_ENTER))
2951 /* Set the quest number temporary */
2952 IDX old_quest = p_ptr->inside_quest;
2955 /* Clear the text */
2956 for (j = 0; j < 10; j++) quest_text[j][0] = '\0';
2957 quest_text_line = 0;
2959 p_ptr->inside_quest = c_ptr->special;
2961 /* Get the quest text */
2962 init_flags = INIT_NAME_ONLY;
2964 process_dungeon_file("q_info.txt", 0, 0, 0, 0);
2966 name = format(_("クエスト「%s」(%d階相当)", "the entrance to the quest '%s'(level %d)"),
2967 quest[c_ptr->special].name, quest[c_ptr->special].level);
2969 /* Reset the old quest number */
2970 p_ptr->inside_quest = old_quest;
2973 /* Hack -- special handling for building doors */
2974 else if (have_flag(f_ptr->flags, FF_BLDG) && !p_ptr->inside_arena)
2976 name = building[f_ptr->subtype].name;
2978 else if (have_flag(f_ptr->flags, FF_ENTRANCE))
2980 name = format(_("%s(%d階相当)", "%s(level %d)"), d_text + d_info[c_ptr->special].text, d_info[c_ptr->special].mindepth);
2982 else if (have_flag(f_ptr->flags, FF_TOWN))
2984 name = town[c_ptr->special].name;
2986 else if (p_ptr->wild_mode && (feat == feat_floor))
2988 name = _("道", "road");
2992 name = f_name + f_ptr->name;
2998 ((!have_flag(f_ptr->flags, FF_MOVE) && !have_flag(f_ptr->flags, FF_CAN_FLY)) ||
2999 (!have_flag(f_ptr->flags, FF_LOS) && !have_flag(f_ptr->flags, FF_TREE)) ||
3000 have_flag(f_ptr->flags, FF_TOWN)))
3002 s2 = _("の中", "in ");
3005 /* Hack -- special introduction for store & building doors -KMW- */
3006 if (have_flag(f_ptr->flags, FF_STORE) ||
3007 have_flag(f_ptr->flags, FF_QUEST_ENTER) ||
3008 (have_flag(f_ptr->flags, FF_BLDG) && !p_ptr->inside_arena) ||
3009 have_flag(f_ptr->flags, FF_ENTRANCE))
3014 else if (have_flag(f_ptr->flags, FF_FLOOR) ||
3015 have_flag(f_ptr->flags, FF_TOWN) ||
3016 have_flag(f_ptr->flags, FF_SHALLOW) ||
3017 have_flag(f_ptr->flags, FF_DEEP))
3023 /* Pick proper indefinite article */
3024 s3 = (is_a_vowel(name[0])) ? "an " : "a ";
3028 /* Display a message */
3032 if (c_ptr->mimic) sprintf(f_idx_str, "%d/%d", c_ptr->feat, c_ptr->mimic);
3033 else sprintf(f_idx_str, "%d", c_ptr->feat);
3035 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]);
3037 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);
3042 sprintf(out_val, "%s%s%s%s[%s]", s1, name, s2, s3, info);
3044 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, name, info);
3048 move_cursor_relative(y, x);
3051 /* Always stop at "normal" keys */
3052 if ((query != '\r') && (query != '\n') && (query != ' ')) return query;
3055 /* Stop on everything but "return" */
3056 if ((query != '\r') && (query != '\n')) return query;
3058 /* Repeat forever */
3064 * Handle "target" and "look".
3066 * Note that this code can be called from "get_aim_dir()".
3068 * All locations must be on the current panel. Consider the use of
3069 * "panel_bounds()" to allow "off-panel" targets, perhaps by using
3070 * some form of "scrolling" the map around the cursor.
3071 * That is, consider the possibility of "auto-scrolling" the screen
3072 * while the cursor moves around. This may require changes in the
3073 * "update_monster()" code to allow "visibility" even if off panel, and
3074 * may require dynamic recalculation of the "temp" grid set.
3076 * Hack -- targeting/observing an "outer border grid" may induce
3077 * problems, so this is not currently allowed.
3079 * The player can use the direction keys to move among "interesting"
3080 * grids in a heuristic manner, or the "space", "+", and "-" keys to
3081 * move through the "interesting" grids in a sequential manner, or
3082 * can enter "location" mode, and use the direction keys to move one
3083 * grid at a time in any direction. The "t" (set target) command will
3084 * only target a monster (as opposed to a location) if the monster is
3085 * target_able and the "interesting" mode is being used.
3087 * The current grid is described using the "look" method above, and
3088 * a new command may be entered at any time, but note that if the
3089 * "TARGET_LOOK" bit flag is set (or if we are in "location" mode,
3090 * where "space" has no obvious meaning) then "space" will scan
3091 * through the description of the current grid until done, instead
3092 * of immediately jumping to the next "interesting" grid. This
3093 * allows the "target" command to retain its old semantics.
3095 * The "*", "+", and "-" keys may always be used to jump immediately
3096 * to the next (or previous) interesting grid, in the proper mode.
3098 * The "return" key may always be used to scan through a complete
3099 * grid description (forever).
3101 * This command will cancel any old target, even if used from
3102 * inside the "look" command.
3104 bool target_set(BIT_FLAGS mode)
3107 POSITION y = p_ptr->y;
3108 POSITION x = p_ptr->x;
3118 get_screen_size(&wid, &hgt);
3123 if (rogue_like_commands)
3132 /* Prepare the "temp" array */
3133 target_set_prepare(mode);
3135 /* Start near the player */
3141 /* Interesting grids */
3148 change_panel_xy(y, x);
3150 if (!(mode & TARGET_LOOK)) prt_path(y, x);
3153 c_ptr = &cave[y][x];
3156 if (target_able(c_ptr->m_idx))
3158 strcpy(info, _("q止 t決 p自 o現 +次 -前", "q,t,p,o,+,-,<dir>"));
3161 /* Dis-allow target */
3164 strcpy(info, _("q止 p自 o現 +次 -前", "q,p,o,+,-,<dir>"));
3170 sprintf(cheatinfo, " LOS:%d, PROJECTABLE:%d",
3171 los(p_ptr->y, p_ptr->x, y, x), projectable(p_ptr->y, p_ptr->x, y, x));
3172 strcat(info, cheatinfo);
3175 /* Describe and Prompt */
3177 query = target_set_aux(y, x, mode, info);
3181 /* Assume no "direction" */
3186 if (query == '\r') query = 't';
3204 if (target_able(c_ptr->m_idx))
3206 health_track(c_ptr->m_idx);
3207 target_who = c_ptr->m_idx;
3226 if (!expand_list) done = TRUE;
3236 if (!expand_list) done = TRUE;
3243 /* Recenter the map around the player */
3245 p_ptr->update |= (PU_MONSTERS);
3246 p_ptr->redraw |= (PR_MAP);
3247 p_ptr->window |= (PW_OVERHEAD);
3250 /* Recalculate interesting grids */
3251 target_set_prepare(mode);
3270 if(query == same_key)
3275 if (!expand_list) done = TRUE;
3280 /* Extract the action (if any) */
3281 d = get_keymap_dir(query);
3288 /* Hack -- move around */
3291 /* Modified to scroll to monster */
3292 POSITION y2 = panel_row_min;
3293 POSITION x2 = panel_col_min;
3295 /* Find a new monster */
3296 i = target_pick(temp_y[m], temp_x[m], ddy[d], ddx[d]);
3298 /* Request to target past last interesting grid */
3299 while (flag && (i < 0))
3301 /* Note the change */
3302 if (change_panel(ddy[d], ddx[d]))
3307 /* Recalculate interesting grids */
3308 target_set_prepare(mode);
3310 /* Look at interesting grids */
3313 /* Find a new monster */
3314 i = target_pick(v, u, ddy[d], ddx[d]);
3320 /* Nothing interesting */
3323 POSITION dx = ddx[d];
3324 POSITION dy = ddy[d];
3326 /* Restore previous position */
3329 panel_bounds_center();
3331 p_ptr->update |= (PU_MONSTERS);
3332 p_ptr->redraw |= (PR_MAP);
3333 p_ptr->window |= (PW_OVERHEAD);
3336 /* Recalculate interesting grids */
3337 target_set_prepare(mode);
3339 /* Look at boring grids */
3346 /* Do not move horizontally if unnecessary */
3347 if (((x < panel_col_min + wid / 2) && (dx > 0)) ||
3348 ((x > panel_col_min + wid / 2) && (dx < 0)))
3353 /* Do not move vertically if unnecessary */
3354 if (((y < panel_row_min + hgt / 2) && (dy > 0)) ||
3355 ((y > panel_row_min + hgt / 2) && (dy < 0)))
3360 /* Apply the motion */
3361 if ((y >= panel_row_min+hgt) || (y < panel_row_min) ||
3362 (x >= panel_col_min+wid) || (x < panel_col_min))
3364 if (change_panel(dy, dx)) target_set_prepare(mode);
3367 /* Slide into legality */
3368 if (x >= cur_wid-1) x = cur_wid - 2;
3369 else if (x <= 0) x = 1;
3371 /* Slide into legality */
3372 if (y >= cur_hgt-1) y = cur_hgt- 2;
3373 else if (y <= 0) y = 1;
3382 /* Arbitrary grids */
3385 bool move_fast = FALSE;
3387 if (!(mode & TARGET_LOOK)) prt_path(y, x);
3390 c_ptr = &cave[y][x];
3392 /* Default prompt */
3393 strcpy(info, _("q止 t決 p自 m近 +次 -前", "q,t,p,m,+,-,<dir>"));
3398 sprintf(cheatinfo, " LOS:%d, PROJECTABLE:%d",
3399 los(p_ptr->y, p_ptr->x, y, x),
3400 projectable(p_ptr->y, p_ptr->x, y, x));
3401 strcat(info, cheatinfo);
3404 /* Describe and Prompt (enable "TARGET_LOOK") */
3405 while ((query = target_set_aux(y, x, mode | TARGET_LOOK, info)) == 0);
3407 /* Assume no direction */
3412 if (query == '\r') query = 't';
3415 /* Analyze the keypress */
3439 /* Recenter the map around the player */
3441 p_ptr->update |= (PU_MONSTERS);
3442 p_ptr->redraw |= (PR_MAP);
3443 p_ptr->window |= (PW_OVERHEAD);
3446 /* Recalculate interesting grids */
3447 target_set_prepare(mode);
3469 /* Pick a nearby monster */
3470 for (i = 0; i < temp_n; i++)
3472 t = distance(y, x, temp_y[i], temp_x[i]);
3482 /* Nothing interesting */
3483 if (bd == 999) flag = FALSE;
3490 /* Extract the action (if any) */
3491 d = get_keymap_dir(query);
3493 /* XTRA HACK MOVEFAST */
3494 if (isupper(query)) move_fast = TRUE;
3501 /* Handle "direction" */
3504 POSITION dx = ddx[d];
3505 POSITION dy = ddy[d];
3507 /* XTRA HACK MOVEFAST */
3510 int mag = MIN(wid / 2, hgt / 2);
3520 /* Do not move horizontally if unnecessary */
3521 if (((x < panel_col_min + wid / 2) && (dx > 0)) ||
3522 ((x > panel_col_min + wid / 2) && (dx < 0)))
3527 /* Do not move vertically if unnecessary */
3528 if (((y < panel_row_min + hgt / 2) && (dy > 0)) ||
3529 ((y > panel_row_min + hgt / 2) && (dy < 0)))
3534 /* Apply the motion */
3535 if ((y >= panel_row_min + hgt) || (y < panel_row_min) ||
3536 (x >= panel_col_min + wid) || (x < panel_col_min))
3538 if (change_panel(dy, dx)) target_set_prepare(mode);
3541 /* Slide into legality */
3542 if (x >= cur_wid-1) x = cur_wid - 2;
3543 else if (x <= 0) x = 1;
3545 /* Slide into legality */
3546 if (y >= cur_hgt-1) y = cur_hgt- 2;
3547 else if (y <= 0) y = 1;
3555 /* Clear the top line */
3558 /* Recenter the map around the player */
3560 p_ptr->update |= (PU_MONSTERS);
3561 p_ptr->redraw |= (PR_MAP);
3562 p_ptr->window |= (PW_OVERHEAD);
3565 /* Failure to set target */
3566 if (!target_who) return (FALSE);
3574 * Get an "aiming direction" from the user.
3576 * The "dir" is loaded with 1,2,3,4,6,7,8,9 for "actual direction", and
3577 * "0" for "current target", and "-1" for "entry aborted".
3579 * Note that "Force Target", if set, will pre-empt user interaction,
3580 * if there is a usable target already set.
3582 * Note that confusion over-rides any (explicit?) user choice.
3584 bool get_aim_dir(DIRECTION *dp)
3593 /* Global direction */
3596 /* Hack -- auto-target if requested */
3597 if (use_old_target && target_okay()) dir = 5;
3599 if (repeat_pull(&code))
3604 if (!(code == 5 && !target_okay()))
3606 /* return (TRUE); */
3607 dir = (DIRECTION)code;
3610 *dp = (DIRECTION)code;
3612 /* Ask until satisfied */
3615 /* Choose a prompt */
3618 p = _("方向 ('*'でターゲット選択, ESCで中断)? ", "Direction ('*' to choose a target, Escape to cancel)? ");
3622 p = _("方向 ('5'でターゲットへ, '*'でターゲット再選択, ESCで中断)? ", "Direction ('5' for target, '*' to re-target, Escape to cancel)? ");
3625 /* Get a command (or Cancel) */
3626 if (!get_com(p, &command, TRUE)) break;
3630 if (command == '\r') command = 't';
3633 /* Convert various keys to "standard" keys */
3636 /* Use current target */
3647 /* Set new target */
3652 if (target_set(TARGET_KILL)) dir = 5;
3658 /* Extract the action (if any) */
3659 dir = get_keymap_dir(command);
3665 /* Verify requested targets */
3666 if ((dir == 5) && !target_okay()) dir = 0;
3675 project_length = 0; /* reset to default */
3679 /* Save the direction */
3682 /* Check for confusion */
3683 if (p_ptr->confused)
3685 /* Random direction */
3686 dir = ddd[randint0(8)];
3689 /* Notice confusion */
3690 if (command_dir != dir)
3693 msg_print(_("あなたは混乱している。", "You are confused."));
3696 /* Save direction */
3699 /* repeat_push(dir); */
3700 repeat_push((COMMAND_CODE)command_dir);
3702 /* A "valid" direction was entered */
3707 bool get_direction(DIRECTION *dp, bool allow_under, bool with_steed)
3715 /* Global direction */
3718 if (repeat_pull(&code))
3720 dir = (DIRECTION)code;
3721 /* return (TRUE); */
3723 *dp = (DIRECTION)code;
3727 prompt = _("方向 ('.'足元, ESCで中断)? ", "Direction ('.' at feet, Escape to cancel)? ");
3731 prompt = _("方向 (ESCで中断)? ", "Direction (Escape to cancel)? ");
3734 /* Get a direction */
3739 /* Get a command (or Cancel) */
3740 if (!get_com(prompt, &ch, TRUE)) break;
3743 if ((allow_under) && ((ch == '5') || (ch == '-') || (ch == '.')))
3749 /* Look up the direction */
3750 dir = get_keymap_dir(ch);
3756 /* Prevent weirdness */
3757 if ((dir == 5) && (!allow_under)) dir = 0;
3760 if (!dir) return (FALSE);
3762 /* Save desired direction */
3765 /* Apply "confusion" */
3766 if (p_ptr->confused)
3768 /* Standard confusion */
3769 if (randint0(100) < 75)
3771 /* Random direction */
3772 dir = ddd[randint0(8)];
3775 else if (p_ptr->riding && with_steed)
3777 monster_type *m_ptr = &m_list[p_ptr->riding];
3778 monster_race *r_ptr = &r_info[m_ptr->r_idx];
3780 if (MON_CONFUSED(m_ptr))
3782 /* Standard confusion */
3783 if (randint0(100) < 75)
3785 /* Random direction */
3786 dir = ddd[randint0(8)];
3789 else if ((r_ptr->flags1 & RF1_RAND_50) && (r_ptr->flags1 & RF1_RAND_25) && (randint0(100) < 50))
3791 /* Random direction */
3792 dir = ddd[randint0(8)];
3794 else if ((r_ptr->flags1 & RF1_RAND_50) && (randint0(100) < 25))
3796 /* Random direction */
3797 dir = ddd[randint0(8)];
3801 /* Notice confusion */
3802 if (command_dir != dir)
3804 if (p_ptr->confused)
3807 msg_print(_("あなたは混乱している。", "You are confused."));
3811 GAME_TEXT m_name[MAX_NLEN];
3812 monster_type *m_ptr = &m_list[p_ptr->riding];
3814 monster_desc(m_name, m_ptr, 0);
3815 if (MON_CONFUSED(m_ptr))
3817 msg_format(_("%sは混乱している。", "%^s is confusing."), m_name);
3821 msg_format(_("%sは思い通りに動いてくれない。", "You cannot control %s."), m_name);
3826 /* Save direction */
3829 /* repeat_push(dir); */
3830 repeat_push((COMMAND_CODE)command_dir);
3837 * @brief 進行方向を指定する(騎乗対象の混乱の影響を受ける) / Request a "movement" direction (1,2,3,4,6,7,8,9) from the user,
3838 * and place it into "command_dir", unless we already have one.
3840 * This function should be used for all "repeatable" commands, such as
3841 * run, walk, open, close, bash, disarm, spike, tunnel, etc, as well
3842 * as all commands which must reference a grid adjacent to the player,
3843 * and which may not reference the grid under the player. Note that,
3844 * for example, it is no longer possible to "disarm" or "open" chests
3845 * in the same grid as the player.
3847 * Direction "5" is illegal and will (cleanly) abort the command.
3849 * This function tracks and uses the "global direction", and uses
3850 * that as the "desired direction", to which "confusion" is applied.
3852 bool get_rep_dir(DIRECTION *dp, bool under)
3860 /* Global direction */
3863 if (repeat_pull(&code))
3865 dir = (DIRECTION)code;
3866 /* return (TRUE); */
3868 *dp = (DIRECTION)code;
3872 prompt = _("方向 ('.'足元, ESCで中断)? ", "Direction ('.' at feet, Escape to cancel)? ");
3876 prompt = _("方向 (ESCで中断)? ", "Direction (Escape to cancel)? ");
3879 /* Get a direction */
3884 /* Get a command (or Cancel) */
3885 if (!get_com(prompt, &ch, TRUE)) break;
3888 if ((under) && ((ch == '5') || (ch == '-') || (ch == '.')))
3894 /* Look up the direction */
3895 dir = get_keymap_dir(ch);
3901 /* Prevent weirdness */
3902 if ((dir == 5) && (!under)) dir = 0;
3905 if (!dir) return (FALSE);
3907 /* Save desired direction */
3910 /* Apply "confusion" */
3911 if (p_ptr->confused)
3913 /* Standard confusion */
3914 if (randint0(100) < 75)
3916 /* Random direction */
3917 dir = ddd[randint0(8)];
3920 else if (p_ptr->riding)
3922 monster_type *m_ptr = &m_list[p_ptr->riding];
3923 monster_race *r_ptr = &r_info[m_ptr->r_idx];
3925 if (MON_CONFUSED(m_ptr))
3927 /* Standard confusion */
3928 if (randint0(100) < 75)
3930 /* Random direction */
3931 dir = ddd[randint0(8)];
3934 else if ((r_ptr->flags1 & RF1_RAND_50) && (r_ptr->flags1 & RF1_RAND_25) && (randint0(100) < 50))
3936 /* Random direction */
3937 dir = ddd[randint0(8)];
3939 else if ((r_ptr->flags1 & RF1_RAND_50) && (randint0(100) < 25))
3941 /* Random direction */
3942 dir = ddd[randint0(8)];
3946 /* Notice confusion */
3947 if (command_dir != dir)
3949 if (p_ptr->confused)
3952 msg_print(_("あなたは混乱している。", "You are confused."));
3956 GAME_TEXT m_name[MAX_NLEN];
3957 monster_type *m_ptr = &m_list[p_ptr->riding];
3959 monster_desc(m_name, m_ptr, 0);
3960 if (MON_CONFUSED(m_ptr))
3962 msg_format(_("%sは混乱している。", "%^s is confusing."), m_name);
3966 msg_format(_("%sは思い通りに動いてくれない。", "You cannot control %s."), m_name);
3971 /* Save direction */
3974 /* repeat_push(dir); */
3975 repeat_push((COMMAND_CODE)command_dir);
3981 void gain_level_reward(int chosen_reward)
3985 char wrath_reason[32] = "";
3986 int nasty_chance = 6;
3987 OBJECT_TYPE_VALUE dummy = 0;
3988 OBJECT_SUBTYPE_VALUE dummy2 = 0;
3991 GAME_TEXT o_name[MAX_NLEN];
3997 if (multi_rew) return;
3998 else multi_rew = TRUE;
4002 if (p_ptr->lev == 13) nasty_chance = 2;
4003 else if (!(p_ptr->lev % 13)) nasty_chance = 3;
4004 else if (!(p_ptr->lev % 14)) nasty_chance = 12;
4006 if (one_in_(nasty_chance))
4007 type = randint1(20); /* Allow the 'nasty' effects */
4009 type = randint1(15) + 5; /* Or disallow them */
4011 if (type < 1) type = 1;
4012 if (type > 20) type = 20;
4016 sprintf(wrath_reason, _("%sの怒り", "the Wrath of %s"), chaos_patrons[p_ptr->chaos_patron]);
4018 effect = chaos_rewards[p_ptr->chaos_patron][type];
4020 if (one_in_(6) && !chosen_reward)
4022 msg_format(_("%^sは褒美としてあなたを突然変異させた。", "%^s rewards you with a mutation!"), chaos_patrons[p_ptr->chaos_patron]);
4023 (void)gain_random_mutation(0);
4024 reward = _("変異した。", "mutation");
4028 switch (chosen_reward ? chosen_reward : effect)
4033 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4034 msg_print(_("「汝、新たなる姿を必要とせり!」", "'Thou needst a new form, mortal!'"));
4037 reward = _("変異した。", "polymorphing");
4042 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4043 msg_print(_("「汝は良く行いたり!続けよ!」", "'Well done, mortal! Lead on!'"));
4045 if (p_ptr->prace == RACE_ANDROID)
4047 msg_print(_("しかし何も起こらなかった。", "But, nothing happen."));
4049 else if (p_ptr->exp < PY_MAX_EXP)
4051 s32b ee = (p_ptr->exp / 2) + 10;
4052 if (ee > 100000L) ee = 100000L;
4053 msg_print(_("更に経験を積んだような気がする。", "You feel more experienced."));
4056 reward = _("経験値を得た", "experience");
4062 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4063 msg_print(_("「下僕よ、汝それに値せず。」", "'Thou didst not deserve that, slave.'"));
4065 if (p_ptr->prace == RACE_ANDROID)
4067 msg_print(_("しかし何も起こらなかった。", "But, nothing happen."));
4071 lose_exp(p_ptr->exp / 6);
4072 reward = _("経験値を失った。", "losing experience");
4078 msg_format("%sの声がささやいた:",
4079 chaos_patrons[p_ptr->chaos_patron]);
4081 msg_format("The voice of %s whispers:",
4082 chaos_patrons[p_ptr->chaos_patron]);
4085 msg_print(_("「我が与えし物を賢明に使うべし。」", "'Use my gift wisely.'"));
4087 acquirement(p_ptr->y, p_ptr->x, 1, FALSE, FALSE, FALSE);
4088 reward = _("上質なアイテムを手に入れた。", "a good item");
4093 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4094 msg_print(_("「我が与えし物を賢明に使うべし。」", "'Use my gift wisely.'"));
4096 acquirement(p_ptr->y, p_ptr->x, 1, TRUE, FALSE, FALSE);
4097 reward = _("高級品のアイテムを手に入れた。", "an excellent item");
4102 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4103 msg_print(_("「汝の行いは貴き剣に値せり。」", "'Thy deed hath earned thee a worthy blade.'"));
4106 switch (randint1(p_ptr->lev))
4112 dummy2 = SV_MAIN_GAUCHE;
4121 dummy2 = SV_SMALL_SWORD;
4124 dummy2 = SV_BASILLARD;
4126 case 11: case 12: case 13:
4127 dummy2 = SV_SHORT_SWORD;
4133 dummy2 = SV_CUTLASS;
4136 dummy2 = SV_WAKIZASHI;
4139 dummy2 = SV_KHOPESH;
4145 dummy2 = SV_BROAD_SWORD;
4148 dummy2 = SV_LONG_SWORD;
4151 dummy2 = SV_SCIMITAR;
4154 dummy2 = SV_NINJATO;
4160 dummy2 = SV_BASTARD_SWORD;
4163 dummy2 = SV_GREAT_SCIMITAR;
4166 dummy2 = SV_CLAYMORE;
4169 dummy2 = SV_ESPADON;
4172 dummy2 = SV_TWO_HANDED_SWORD;
4175 dummy2 = SV_FLAMBERGE;
4178 dummy2 = SV_NO_DACHI;
4181 dummy2 = SV_EXECUTIONERS_SWORD;
4184 dummy2 = SV_ZWEIHANDER;
4187 dummy2 = SV_HAYABUSA;
4190 dummy2 = SV_BLADE_OF_CHAOS;
4193 object_prep(q_ptr, lookup_kind(dummy, dummy2));
4194 q_ptr->to_h = 3 + randint1(dun_level) % 10;
4195 q_ptr->to_d = 3 + randint1(dun_level) % 10;
4196 one_resistance(q_ptr);
4197 q_ptr->name2 = EGO_CHAOTIC;
4198 (void)drop_near(q_ptr, -1, p_ptr->y, p_ptr->x);
4199 reward = _("(混沌)の武器を手に入れた。", "chaos weapon");
4204 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4205 msg_print(_("「汝の行いは貴き報いに値せり。」", "'Thy deed hath earned thee a worthy reward.'"));
4207 acquirement(p_ptr->y, p_ptr->x, randint1(2) + 1, FALSE, FALSE, FALSE);
4208 reward = _("上質なアイテムを手に入れた。", "good items");
4213 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4214 msg_print(_("「下僕よ、汝の献身への我が惜しみ無き報いを見るがよい。」", "'Behold, mortal, how generously I reward thy loyalty.'"));
4216 acquirement(p_ptr->y, p_ptr->x, randint1(2) + 1, TRUE, FALSE, FALSE);
4217 reward = _("高級品のアイテムを手に入れた。", "excellent items");
4222 msg_format("%sの声が轟き渡った:", chaos_patrons[p_ptr->chaos_patron]);
4224 msg_format("The voice of %s thunders:", chaos_patrons[p_ptr->chaos_patron]);
4227 msg_print(_("「下僕よ、汝傲慢なり。」", "'Thou art growing arrogant, mortal.'"));
4229 (void)activate_ty_curse(FALSE, &count);
4230 reward = _("禍々しい呪いをかけられた。", "cursing");
4235 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4236 msg_print(_("「我が下僕たちよ、かの傲慢なる者を倒すべし!」", "'My pets, destroy the arrogant mortal!'"));
4238 for (dummy = 0; dummy < randint1(5) + 1; dummy++)
4240 (void)summon_specific(0, p_ptr->y, p_ptr->x, dun_level, 0, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET), '\0');
4242 reward = _("モンスターを召喚された。", "summoning hostile monsters");
4248 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4249 msg_print(_("「汝、より強き敵を必要とせり!」", "'Thou needst worthier opponents!'"));
4251 activate_hi_summon(p_ptr->y, p_ptr->x, FALSE);
4252 reward = _("モンスターを召喚された。", "summoning many hostile monsters");
4258 msg_format("%sの声が響き渡った:",
4259 chaos_patrons[p_ptr->chaos_patron]);
4261 msg_format("The voice of %s booms out:",
4262 chaos_patrons[p_ptr->chaos_patron]);
4265 msg_print(_("「死と破壊こそ我が喜びなり!」", "'Death and destruction! This pleaseth me!'"));
4268 reward = _("カオスの力が渦巻いた。", "calling chaos");
4274 msg_format("%sの声が鳴り響いた:",
4275 chaos_patrons[p_ptr->chaos_patron]);
4277 msg_format("The voice of %s rings out:",
4278 chaos_patrons[p_ptr->chaos_patron]);
4281 msg_print(_("「留まるのだ、下僕よ。余が汝の肉体を鍛えん。」", "'Stay, mortal, and let me mold thee.'"));
4283 if (one_in_(3) && !(chaos_stats[p_ptr->chaos_patron] < 0))
4284 do_inc_stat(chaos_stats[p_ptr->chaos_patron]);
4286 do_inc_stat(randint0(6));
4287 reward = _("能力値が上がった。", "increasing a stat");
4293 msg_format("%sの声が響き渡った:",
4294 chaos_patrons[p_ptr->chaos_patron]);
4296 msg_format("The voice of %s booms out:",
4297 chaos_patrons[p_ptr->chaos_patron]);
4300 msg_print(_("「下僕よ、余は汝に飽みたり。」", "'I grow tired of thee, mortal.'"));
4302 if (one_in_(3) && !(chaos_stats[p_ptr->chaos_patron] < 0))
4303 do_dec_stat(chaos_stats[p_ptr->chaos_patron]);
4305 (void)do_dec_stat(randint0(6));
4306 reward = _("能力値が下がった。", "decreasing a stat");
4313 msg_format("%sの声が轟き渡った:",
4314 chaos_patrons[p_ptr->chaos_patron]);
4316 msg_format("The voice of %s thunders:",
4317 chaos_patrons[p_ptr->chaos_patron]);
4320 msg_print(_("「汝、謙虚たることを学ぶべし!」", "'Thou needst a lesson in humility, mortal!'"));
4321 msg_print(_("あなたは以前より弱くなった!", "You feel less powerful!"));
4323 for (dummy = 0; dummy < A_MAX; dummy++)
4325 (void)dec_stat(dummy, 10 + randint1(15), TRUE);
4327 reward = _("全能力値が下がった。", "decreasing all stats");
4332 msg_format(_("%sの力が触れるのを感じた。", "You feel the power of %s touch you."),
4333 chaos_patrons[p_ptr->chaos_patron]);
4335 reward = _("傷が変化した。", "polymorphing wounds");
4340 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4342 msg_print(_("「我がささやかなる賜物を受けとるがよい!」", "'Receive this modest gift from me!'"));
4344 for (dummy = 0; dummy < A_MAX; dummy++)
4346 (void)do_inc_stat(dummy);
4348 reward = _("全能力値が上がった。", "increasing all stats");
4353 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4354 msg_print(_("「苦しむがよい、無能な愚か者よ!」", "'Suffer, pathetic fool!'"));
4356 fire_ball(GF_DISINTEGRATE, 0, p_ptr->lev * 4, 4);
4357 take_hit(DAMAGE_NOESCAPE, p_ptr->lev * 4, wrath_reason, -1);
4358 reward = _("分解の球が発生した。", "generating disintegration ball");
4363 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4364 (void)restore_level();
4365 (void)restore_all_status();
4366 (void)true_healing(5000);
4367 reward = _("体力が回復した。", "healing");
4372 if (!buki_motteruka(INVEN_RARM) && !buki_motteruka(INVEN_LARM)) break;
4373 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4374 msg_print(_("「汝、武器に頼ることなかれ。」", "'Thou reliest too much on thy weapon.'"));
4377 if (buki_motteruka(INVEN_LARM))
4380 if (buki_motteruka(INVEN_RARM) && one_in_(2)) dummy = INVEN_RARM;
4382 object_desc(o_name, &inventory[dummy], OD_NAME_ONLY);
4383 (void)curse_weapon(FALSE, dummy);
4384 reward = format(_("%sが破壊された。", "destroying %s"), o_name);
4389 if (!inventory[INVEN_BODY].k_idx) break;
4390 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4391 msg_print(_("「汝、防具に頼ることなかれ。」", "'Thou reliest too much on thine equipment.'"));
4393 object_desc(o_name, &inventory[INVEN_BODY], OD_NAME_ONLY);
4394 (void)curse_armor();
4395 reward = format(_("%sが破壊された。", "destroying %s"), o_name);
4399 msg_format(_("%sの声がささやいた:", "The voice of %s whispers:"), chaos_patrons[p_ptr->chaos_patron]);
4400 msg_print(_("「我を怒りしめた罪を償うべし。」", "'Now thou shalt pay for annoying me.'"));
4402 switch (randint1(4))
4405 (void)activate_ty_curse(FALSE, &count);
4406 reward = _("禍々しい呪いをかけられた。", "cursing");
4409 activate_hi_summon(p_ptr->y, p_ptr->x, FALSE);
4410 reward = _("モンスターを召喚された。", "summoning hostile monsters");
4415 if (!buki_motteruka(INVEN_RARM) && !buki_motteruka(INVEN_LARM)) break;
4417 if (buki_motteruka(INVEN_LARM))
4420 if (buki_motteruka(INVEN_RARM) && one_in_(2)) dummy = INVEN_RARM;
4422 object_desc(o_name, &inventory[dummy], OD_NAME_ONLY);
4423 (void)curse_weapon(FALSE, dummy);
4424 reward = format(_("%sが破壊された。", "destroying %s"), o_name);
4428 if (!inventory[INVEN_BODY].k_idx) break;
4429 object_desc(o_name, &inventory[INVEN_BODY], OD_NAME_ONLY);
4430 (void)curse_armor();
4431 reward = format(_("%sが破壊された。", "destroying %s"), o_name);
4435 for (dummy = 0; dummy < A_MAX; dummy++)
4437 (void)dec_stat(dummy, 10 + randint1(15), TRUE);
4439 reward = _("全能力値が下がった。", "decreasing all stats");
4446 msg_format(_("%sの声が轟き渡った:", "The voice of %s thunders:"), chaos_patrons[p_ptr->chaos_patron]);
4447 msg_print(_("「死ぬがよい、下僕よ!」", "'Die, mortal!'"));
4449 take_hit(DAMAGE_LOSELIFE, p_ptr->lev * 4, wrath_reason, -1);
4450 for (dummy = 0; dummy < A_MAX; dummy++)
4452 (void)dec_stat(dummy, 10 + randint1(15), FALSE);
4454 activate_hi_summon(p_ptr->y, p_ptr->x, FALSE);
4455 (void)activate_ty_curse(FALSE, &count);
4460 if (buki_motteruka(INVEN_RARM))
4463 if (buki_motteruka(INVEN_LARM) && one_in_(2)) dummy = INVEN_LARM;
4465 else if (buki_motteruka(INVEN_LARM)) dummy = INVEN_LARM;
4467 if (dummy) (void)curse_weapon(FALSE, dummy);
4469 if (one_in_(2)) (void)curse_armor();
4474 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4475 msg_print(_("「死と破壊こそ我が喜びなり!」", "'Death and destruction! This pleaseth me!'"));
4477 (void)destroy_area(p_ptr->y, p_ptr->x, 25, FALSE);
4478 reward = _("ダンジョンが*破壊*された。", "*destruct*ing dungeon");
4483 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4484 msg_print(_("「我、汝の敵を抹殺せん!」", "'Let me relieve thee of thine oppressors!'"));
4485 (void)symbol_genocide(0, FALSE);
4486 reward = _("モンスターが抹殺された。", "genociding monsters");
4491 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4492 msg_print(_("「我、汝の敵を抹殺せん!」", "'Let me relieve thee of thine oppressors!'"));
4494 (void)mass_genocide(0, FALSE);
4495 reward = _("モンスターが抹殺された。", "genociding nearby monsters");
4500 msg_format(_("%sの力が敵を攻撃するのを感じた!", "You can feel the power of %s assault your enemies!"), chaos_patrons[p_ptr->chaos_patron]);
4501 (void)dispel_monsters(p_ptr->lev * 4);
4506 msg_format(_("%sはあなたを無視した。", "%s ignores you."), chaos_patrons[p_ptr->chaos_patron]);
4511 msg_format(_("%sは褒美として悪魔の使いをよこした!", "%s rewards you with a demonic servant!"),chaos_patrons[p_ptr->chaos_patron]);
4513 if (!summon_specific(-1, p_ptr->y, p_ptr->x, dun_level, SUMMON_DEMON, PM_FORCE_PET, '\0'))
4514 msg_print(_("何も現れなかった...", "Nobody ever turns up..."));
4516 reward = _("悪魔がペットになった。", "a demonic servant");
4521 msg_format(_("%sは褒美として使いをよこした!", "%s rewards you with a servant!"),chaos_patrons[p_ptr->chaos_patron]);
4523 if (!summon_specific(-1, p_ptr->y, p_ptr->x, dun_level, 0, PM_FORCE_PET, '\0'))
4524 msg_print(_("何も現れなかった...", "Nobody ever turns up..."));
4526 reward = _("モンスターがペットになった。", "a servant");
4531 msg_format(_("%sは褒美としてアンデッドの使いをよこした。", "%s rewards you with an undead servant!"),chaos_patrons[p_ptr->chaos_patron]);
4533 if (!summon_specific(-1, p_ptr->y, p_ptr->x, dun_level, SUMMON_UNDEAD, PM_FORCE_PET, '\0'))
4534 msg_print(_("何も現れなかった...", "Nobody ever turns up..."));
4536 reward = _("アンデッドがペットになった。", "an undead servant");
4541 msg_format(_("%sの声がどもった:", "The voice of %s stammers:"),
4543 chaos_patrons[p_ptr->chaos_patron]);
4544 msg_format(_("「あー、あー、答えは %d/%d。質問は何?」", "'Uh... uh... the answer's %d/%d, what's the question?'"), type, effect);
4550 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, format(_("パトロンの報酬で%s", "The patron rewards you with %s."), reward));
4556 * XAngband: determine if a given location is "interesting"
4557 * based on target_set_accept function.
4559 static bool tgt_pt_accept(POSITION y, POSITION x)
4564 if (!(in_bounds(y, x))) return (FALSE);
4566 /* Player grid is always interesting */
4567 if ((y == p_ptr->y) && (x == p_ptr->x)) return (TRUE);
4569 /* Handle hallucination */
4570 if (p_ptr->image) return (FALSE);
4572 /* Examine the grid */
4573 c_ptr = &cave[y][x];
4575 /* Interesting memorized features */
4576 if (c_ptr->info & (CAVE_MARK))
4579 if (cave_have_flag_grid(c_ptr, FF_LESS)) return (TRUE);
4580 if (cave_have_flag_grid(c_ptr, FF_MORE)) return (TRUE);
4582 /* Notice quest features */
4583 if (cave_have_flag_grid(c_ptr, FF_QUEST_ENTER)) return (TRUE);
4584 if (cave_have_flag_grid(c_ptr, FF_QUEST_EXIT)) return (TRUE);
4592 * XAngband: Prepare the "temp" array for "tget_pt"
4593 * based on target_set_prepare funciton.
4595 static void tgt_pt_prepare(void)
4599 /* Reset "temp" array */
4602 if (!expand_list) return;
4604 /* Scan the current panel */
4605 for (y = 1; y < cur_hgt; y++)
4607 for (x = 1; x < cur_wid; x++)
4609 /* Require "interesting" contents */
4610 if (!tgt_pt_accept(y, x)) continue;
4612 /* Save the location */
4619 /* Target the nearest monster for shooting */
4620 ang_sort_comp = ang_sort_comp_distance;
4621 ang_sort_swap = ang_sort_swap_distance;
4623 /* Sort the positions */
4624 ang_sort(temp_x, temp_y, temp_n);
4628 * old -- from PsiAngband.
4630 bool tgt_pt(POSITION *x_ptr, POSITION *y_ptr)
4635 bool success = FALSE;
4639 get_screen_size(&wid, &hgt);
4649 msg_print(_("場所を選んでスペースキーを押して下さい。", "Select a point and press space."));
4650 msg_flag = FALSE; /* prevents "-more-" message. */
4652 while ((ch != ESCAPE) && !success)
4654 bool move_fast = FALSE;
4656 move_cursor_relative(y, x);
4668 if (player_bold(y, x)) ch = 0;
4671 else success = TRUE;
4675 /* XAngband: Move cursor to stairs */
4678 if (expand_list && temp_n)
4681 int cx = (panel_col_min + panel_col_max) / 2;
4682 int cy = (panel_row_min + panel_row_max) / 2;
4686 /* Skip stairs which have defferent distance */
4687 for (; n < temp_n; ++ n)
4689 cave_type *c_ptr = &cave[temp_y[n]][temp_x[n]];
4691 if (cave_have_flag_grid(c_ptr, FF_STAIRS) &&
4692 cave_have_flag_grid(c_ptr, ch == '>' ? FF_MORE : FF_LESS))
4699 if (n == temp_n) /* Loop out taget list */
4704 verify_panel(); /* Move cursor to player */
4706 p_ptr->update |= (PU_MONSTERS);
4708 p_ptr->redraw |= (PR_MAP);
4710 p_ptr->window |= (PW_OVERHEAD);
4713 else /* move cursor to next stair and change panel */
4718 dy = 2 * (y - cy) / hgt;
4719 dx = 2 * (x - cx) / wid;
4720 if (dy || dx) change_panel(dy, dx);
4726 /* Look up the direction */
4727 d = get_keymap_dir(ch);
4729 /* XTRA HACK MOVEFAST */
4730 if (isupper(ch)) move_fast = TRUE;
4732 /* Handle "direction" */
4738 /* XTRA HACK MOVEFAST */
4741 int mag = MIN(wid / 2, hgt / 2);
4751 /* Do not move horizontally if unnecessary */
4752 if (((x < panel_col_min + wid / 2) && (dx > 0)) ||
4753 ((x > panel_col_min + wid / 2) && (dx < 0)))
4758 /* Do not move vertically if unnecessary */
4759 if (((y < panel_row_min + hgt / 2) && (dy > 0)) ||
4760 ((y > panel_row_min + hgt / 2) && (dy < 0)))
4765 /* Apply the motion */
4766 if ((y >= panel_row_min + hgt) || (y < panel_row_min) ||
4767 (x >= panel_col_min + wid) || (x < panel_col_min))
4769 /* if (change_panel(dy, dx)) target_set_prepare(mode); */
4770 change_panel(dy, dx);
4773 /* Slide into legality */
4774 if (x >= cur_wid-1) x = cur_wid - 2;
4775 else if (x <= 0) x = 1;
4777 /* Slide into legality */
4778 if (y >= cur_hgt-1) y = cur_hgt- 2;
4779 else if (y <= 0) y = 1;
4786 /* Clear the top line */
4789 /* Recenter the map around the player */
4792 p_ptr->update |= (PU_MONSTERS);
4794 p_ptr->redraw |= (PR_MAP);
4796 p_ptr->window |= (PW_OVERHEAD);
4805 bool get_hack_dir(DIRECTION *dp)
4813 /* Global direction */
4816 /* (No auto-targeting) */
4818 /* Ask until satisfied */
4821 /* Choose a prompt */
4824 p = _("方向 ('*'でターゲット選択, ESCで中断)? ", "Direction ('*' to choose a target, Escape to cancel)? ");
4828 p = _("方向 ('5'でターゲットへ, '*'でターゲット再選択, ESCで中断)? ", "Direction ('5' for target, '*' to re-target, Escape to cancel)? ");
4831 /* Get a command (or Cancel) */
4832 if (!get_com(p, &command, TRUE)) break;
4836 if (command == '\r') command = 't';
4839 /* Convert various keys to "standard" keys */
4842 /* Use current target */
4853 /* Set new target */
4858 if (target_set(TARGET_KILL)) dir = 5;
4864 /* Look up the direction */
4865 dir = get_keymap_dir(command);
4871 /* Verify requested targets */
4872 if ((dir == 5) && !target_okay()) dir = 0;
4879 if (!dir) return (FALSE);
4881 /* Save the direction */
4884 /* Check for confusion */
4885 if (p_ptr->confused)
4887 /* Random direction */
4888 dir = ddd[randint0(8)];
4891 /* Notice confusion */
4892 if (command_dir != dir)
4895 msg_print(_("あなたは混乱している。", "You are confused."));
4898 /* Save direction */
4901 /* A "valid" direction was entered */
4907 * @brief 射撃武器の攻撃に必要な基本消費エネルギーを返す/Return bow energy
4908 * @param sval 射撃武器のアイテム副分類ID
4909 * @return 消費する基本エネルギー
4911 ENERGY bow_energy(OBJECT_SUBTYPE_VALUE sval)
4913 ENERGY energy = 10000;
4915 /* Analyze the launcher */
4918 /* Sling and ammo */
4925 /* Short Bow and Arrow */
4932 /* Long Bow and Arrow */
4939 /* Bow of irresponsiblity and Arrow */
4946 /* Light Crossbow and Bolt */
4953 /* Heavy Crossbow and Bolt */
4968 int bow_tmul(OBJECT_SUBTYPE_VALUE sval)
4972 /* Analyze the launcher */
4975 /* Sling and ammo */
4982 /* Short Bow and Arrow */
4989 /* Long Bow and Arrow */
4996 /* Bow of irresponsiblity and Arrow */
5003 /* Light Crossbow and Bolt */
5010 /* Heavy Crossbow and Bolt */
5023 * Display a rumor and apply its effects
5026 IDX rumor_num(char *zz, IDX max_idx)
5028 if (strcmp(zz, "*") == 0) return randint1(max_idx - 1);
5029 return (IDX)atoi(zz);
5032 cptr rumor_bind_name(char *base, cptr fullname)
5036 s = strstr(base, "{Name}");
5040 v = format("%s%s%s", base, fullname, (s + 6));
5050 void display_rumor(bool ex)
5058 if (randint0(3) == 0) section = 1;
5061 err = _(get_rnd_line_jonly("rumors_j.txt", section, Rumor, 10),
5062 get_rnd_line("rumors.txt", section, Rumor));
5063 if (err) strcpy(Rumor, _("嘘の噂もある。", "Some rumors are wrong."));
5067 if (strncmp(Rumor, "R:", 2) == 0)
5070 cptr rumor_msg = NULL;
5071 cptr rumor_eff_format = NULL;
5072 char fullname[1024] = "";
5074 if (tokenize(Rumor + 2, 3, zz, TOKENIZE_CHECKQUOTE) == 3)
5076 if (strcmp(zz[0], "ARTIFACT") == 0)
5080 object_type *q_ptr = &forge;
5081 artifact_type *a_ptr;
5085 a_idx = rumor_num(zz[1], max_a_idx);
5087 a_ptr = &a_info[a_idx];
5088 if (a_ptr->name) break;
5091 k_idx = lookup_kind(a_ptr->tval, a_ptr->sval);
5092 object_prep(q_ptr, k_idx);
5093 q_ptr->name1 = a_idx;
5094 q_ptr->ident = IDENT_STORE;
5095 object_desc(fullname, q_ptr, OD_NAME_ONLY);
5097 else if (strcmp(zz[0], "MONSTER") == 0)
5100 monster_race *r_ptr;
5104 r_idx = rumor_num(zz[1], max_r_idx);
5105 r_ptr = &r_info[r_idx];
5106 if (r_ptr->name) break;
5109 strcpy(fullname, r_name + r_ptr->name);
5111 /* Remember this monster */
5112 if (!r_ptr->r_sights)
5117 else if (strcmp(zz[0], "DUNGEON") == 0)
5120 dungeon_info_type *d_ptr;
5124 d_idx = rumor_num(zz[1], max_d_idx);
5125 d_ptr = &d_info[d_idx];
5126 if (d_ptr->name) break;
5129 strcpy(fullname, d_name + d_ptr->name);
5131 if (!max_dlv[d_idx])
5133 max_dlv[d_idx] = d_ptr->mindepth;
5134 rumor_eff_format = _("%sに帰還できるようになった。", "You can recall to %s.");
5137 else if (strcmp(zz[0], "TOWN") == 0)
5144 t_idx = rumor_num(zz[1], NO_TOWN);
5145 if (town[t_idx].name) break;
5148 strcpy(fullname, town[t_idx].name);
5150 visit = (1L << (t_idx - 1));
5151 if ((t_idx != SECRET_TOWN) && !(p_ptr->visit & visit))
5153 p_ptr->visit |= visit;
5154 rumor_eff_format = _("%sに行ったことがある気がする。", "You feel you have been to %s.");
5158 rumor_msg = rumor_bind_name(zz[2], fullname);
5159 msg_print(rumor_msg);
5160 if (rumor_eff_format)
5163 msg_format(rumor_eff_format, fullname);
5168 if (err) msg_print(_("この情報は間違っている。", "This information is wrong."));
5172 msg_format("%s", Rumor);