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"
20 #include "projection.h"
22 #define REWARD_CHANCE 10
26 * @brief プレイヤーの経験値について整合性のためのチェックと調整を行う /
27 * Advance experience levels and print experience
30 void check_experience(void)
32 bool level_reward = FALSE;
33 bool level_mutation = FALSE;
34 bool level_inc_stat = FALSE;
35 bool android = (p_ptr->prace == RACE_ANDROID ? TRUE : FALSE);
36 PLAYER_LEVEL old_lev = p_ptr->lev;
38 /* Hack -- lower limit */
39 if (p_ptr->exp < 0) p_ptr->exp = 0;
40 if (p_ptr->max_exp < 0) p_ptr->max_exp = 0;
41 if (p_ptr->max_max_exp < 0) p_ptr->max_max_exp = 0;
43 /* Hack -- upper limit */
44 if (p_ptr->exp > PY_MAX_EXP) p_ptr->exp = PY_MAX_EXP;
45 if (p_ptr->max_exp > PY_MAX_EXP) p_ptr->max_exp = PY_MAX_EXP;
46 if (p_ptr->max_max_exp > PY_MAX_EXP) p_ptr->max_max_exp = PY_MAX_EXP;
48 /* Hack -- maintain "max" experience */
49 if (p_ptr->exp > p_ptr->max_exp) p_ptr->max_exp = p_ptr->exp;
51 /* Hack -- maintain "max max" experience */
52 if (p_ptr->max_exp > p_ptr->max_max_exp) p_ptr->max_max_exp = p_ptr->max_exp;
54 /* Redraw experience */
55 p_ptr->redraw |= (PR_EXP);
59 /* Lose levels while possible */
60 while ((p_ptr->lev > 1) &&
61 (p_ptr->exp < ((android ? player_exp_a : player_exp)[p_ptr->lev - 2] * p_ptr->expfact / 100L)))
65 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
66 p_ptr->redraw |= (PR_LEV | PR_TITLE);
67 p_ptr->window |= (PW_PLAYER);
72 /* Gain levels while possible */
73 while ((p_ptr->lev < PY_MAX_LEVEL) &&
74 (p_ptr->exp >= ((android ? player_exp_a : player_exp)[p_ptr->lev-1] * p_ptr->expfact / 100L)))
79 /* Save the highest level */
80 if (p_ptr->lev > p_ptr->max_plv)
82 p_ptr->max_plv = p_ptr->lev;
84 if ((p_ptr->pclass == CLASS_CHAOS_WARRIOR) ||
85 (p_ptr->muta2 & MUT2_CHAOS_GIFT))
89 if (p_ptr->prace == RACE_BEASTMAN)
91 if (one_in_(5)) level_mutation = TRUE;
93 level_inc_stat = TRUE;
95 do_cmd_write_nikki(NIKKI_LEVELUP, p_ptr->lev, NULL);
100 msg_format(_("レベル %d にようこそ。", "Welcome to level %d."), p_ptr->lev);
102 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
103 p_ptr->redraw |= (PR_LEV | PR_TITLE | PR_EXP);
104 p_ptr->window |= (PW_PLAYER | PW_SPELL | PW_INVEN);
114 if(!(p_ptr->max_plv % 10))
123 cnv_stat(p_ptr->stat_max[0], tmp);
124 prt(format(_(" a) 腕力 (現在値 %s)", " a) Str (cur %s)"), tmp), 2, 14);
125 cnv_stat(p_ptr->stat_max[1], tmp);
126 prt(format(_(" b) 知能 (現在値 %s)", " a) Int (cur %s)"), tmp), 3, 14);
127 cnv_stat(p_ptr->stat_max[2], tmp);
128 prt(format(_(" c) 賢さ (現在値 %s)", " a) Wis (cur %s)"), tmp), 4, 14);
129 cnv_stat(p_ptr->stat_max[3], tmp);
130 prt(format(_(" d) 器用 (現在値 %s)", " a) Dex (cur %s)"), tmp), 5, 14);
131 cnv_stat(p_ptr->stat_max[4], tmp);
132 prt(format(_(" e) 耐久 (現在値 %s)", " a) Con (cur %s)"), tmp), 6, 14);
133 cnv_stat(p_ptr->stat_max[5], tmp);
134 prt(format(_(" f) 魅力 (現在値 %s)", " a) Chr (cur %s)"), tmp), 7, 14);
137 prt(_(" どの能力値を上げますか?", " Which stat do you want to raise?"), 1, 14);
142 if ((choice >= 'a') && (choice <= 'f')) break;
144 for(n = 0; n < A_MAX; n++)
145 if (n != choice - 'a')
147 if (get_check(_("よろしいですか?", "Are you sure? "))) break;
149 do_inc_stat(choice - 'a');
152 else if(!(p_ptr->max_plv % 2))
153 do_inc_stat(randint0(6));
158 msg_print(_("あなたは変わった気がする...", "You feel different..."));
159 (void)gain_random_mutation(0);
160 level_mutation = FALSE;
164 * 報酬でレベルが上ると再帰的に check_experience() が
169 gain_level_reward(0);
170 level_reward = FALSE;
173 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
174 p_ptr->redraw |= (PR_LEV | PR_TITLE);
175 p_ptr->window |= (PW_PLAYER | PW_SPELL);
179 /* Load an autopick preference file */
180 if (old_lev != p_ptr->lev) autopick_load_pref(FALSE);
185 * @brief モンスターを倒した際の財宝svalを返す
186 * @param r_idx 倒したモンスターの種族ID
189 * Hack -- Return the "automatic coin type" of a monster race
190 * Used to allocate proper treasure when "Creeping coins" die
191 * Note the use of actual "monster names"
193 static OBJECT_SUBTYPE_VALUE get_coin_type(MONRACE_IDX r_idx)
195 /* Analyze monsters */
198 case MON_COPPER_COINS: return 2;
199 case MON_SILVER_COINS: return 5;
200 case MON_GOLD_COINS: return 10;
201 case MON_MITHRIL_COINS:
202 case MON_MITHRIL_GOLEM: return 16;
203 case MON_ADAMANT_COINS: return 17;
213 * @brief クエストを達成状態にする /
214 * @param quest_num 達成状態にしたいクエストのID
217 void complete_quest(QUEST_IDX quest_num)
219 quest_type* const q_ptr = &quest[quest_num];
223 case QUEST_TYPE_RANDOM:
224 if (record_rand_quest) do_cmd_write_nikki(NIKKI_RAND_QUEST_C, quest_num, NULL);
227 if (record_fix_quest) do_cmd_write_nikki(NIKKI_FIX_QUEST_C, quest_num, NULL);
231 q_ptr->status = QUEST_STATUS_COMPLETED;
232 q_ptr->complev = (byte)p_ptr->lev;
234 q_ptr->comptime = playtime;
236 if (!(q_ptr->flags & QUEST_FLAG_SILENT))
238 play_music(TERM_XTRA_MUSIC_BASIC, MUSIC_BASIC_QUEST_CLEAR);
239 msg_print(_("クエストを達成した!", "You just completed your quest!"));
245 * @brief 現在フロアに残っている敵モンスターの数を返す /
246 * @return 現在の敵モンスターの数
248 static MONSTER_NUMBER count_all_hostile_monsters(void)
251 MONSTER_NUMBER number_mon = 0;
253 for (x = 0; x < cur_wid; ++ x)
255 for (y = 0; y < cur_hgt; ++ y)
257 MONSTER_IDX m_idx = cave[y][x].m_idx;
259 if (m_idx > 0 && is_hostile(&m_list[m_idx]))
270 * @brief 特定の敵を倒した際にクエスト達成処理 /
271 * Check for "Quest" completion when a quest monster is killed or charmed.
272 * @param m_ptr 撃破したモンスターの構造体参照ポインタ
275 void check_quest_completion(monster_type *m_ptr)
280 bool create_stairs = FALSE;
290 quest_num = p_ptr->inside_quest;
292 /* Search for an active quest on this dungeon level */
297 for (i = max_q_idx - 1; i > 0; i--)
299 quest_type* const q_ptr = &quest[i];
301 /* Quest is not active */
302 if (q_ptr->status != QUEST_STATUS_TAKEN)
305 /* Quest is not a dungeon quest */
306 if (q_ptr->flags & QUEST_FLAG_PRESET)
309 /* Quest is not on this level */
310 if ((q_ptr->level != dun_level) &&
311 (q_ptr->type != QUEST_TYPE_KILL_ANY_LEVEL))
314 /* Not a "kill monster" quest */
315 if ((q_ptr->type == QUEST_TYPE_FIND_ARTIFACT) ||
316 (q_ptr->type == QUEST_TYPE_FIND_EXIT))
319 /* Interesting quest */
320 if ((q_ptr->type == QUEST_TYPE_KILL_NUMBER) ||
321 (q_ptr->type == QUEST_TYPE_TOWER) ||
322 (q_ptr->type == QUEST_TYPE_KILL_ALL))
325 /* Interesting quest */
326 if (((q_ptr->type == QUEST_TYPE_KILL_LEVEL) ||
327 (q_ptr->type == QUEST_TYPE_KILL_ANY_LEVEL) ||
328 (q_ptr->type == QUEST_TYPE_RANDOM)) &&
329 (q_ptr->r_idx == m_ptr->r_idx))
336 /* Handle the current quest */
337 if (quest_num && (quest[quest_num].status == QUEST_STATUS_TAKEN))
340 quest_type* const q_ptr = &quest[quest_num];
344 case QUEST_TYPE_KILL_NUMBER:
348 if (q_ptr->cur_num >= q_ptr->num_mon)
350 complete_quest(quest_num);
356 case QUEST_TYPE_KILL_ALL:
358 if (!is_hostile(m_ptr)) break;
360 if (count_all_hostile_monsters() == 1)
362 if (q_ptr->flags & QUEST_FLAG_SILENT)
364 q_ptr->status = QUEST_STATUS_FINISHED;
368 complete_quest(quest_num);
373 case QUEST_TYPE_KILL_LEVEL:
374 case QUEST_TYPE_RANDOM:
376 /* Only count valid monsters */
377 if (q_ptr->r_idx != m_ptr->r_idx)
382 if (q_ptr->cur_num >= q_ptr->max_num)
384 complete_quest(quest_num);
386 if (!(q_ptr->flags & QUEST_FLAG_PRESET))
388 create_stairs = TRUE;
389 p_ptr->inside_quest = 0;
392 /* Finish the two main quests without rewarding */
393 if ((quest_num == QUEST_OBERON) || (quest_num == QUEST_SERPENT))
395 q_ptr->status = QUEST_STATUS_FINISHED;
398 if (q_ptr->type == QUEST_TYPE_RANDOM)
401 q_ptr->status = QUEST_STATUS_FINISHED;
406 case QUEST_TYPE_KILL_ANY_LEVEL:
409 if (q_ptr->cur_num >= q_ptr->max_num)
411 complete_quest(quest_num);
416 case QUEST_TYPE_TOWER:
418 if (!is_hostile(m_ptr)) break;
420 if (count_all_hostile_monsters() == 1)
422 q_ptr->status = QUEST_STATUS_STAGE_COMPLETED;
424 if((quest[QUEST_TOWER1].status == QUEST_STATUS_STAGE_COMPLETED) &&
425 (quest[QUEST_TOWER2].status == QUEST_STATUS_STAGE_COMPLETED) &&
426 (quest[QUEST_TOWER3].status == QUEST_STATUS_STAGE_COMPLETED))
429 complete_quest(QUEST_TOWER1);
437 /* Create a magical staircase */
443 while (cave_perma_bold(y, x) || cave[y][x].o_idx || (cave[y][x].info & CAVE_OBJECT) )
445 /* Pick a location */
446 scatter(&ny, &nx, y, x, 1, 0);
452 /* Explain the staircase */
453 msg_print(_("魔法の階段が現れた...", "A magical staircase appears..."));
455 /* Create stairs down */
456 cave_set_feat(y, x, feat_down_stair);
458 /* Remember to update everything */
459 p_ptr->update |= (PU_FLOW);
469 for (i = 0; i < (dun_level / 15)+1; i++)
474 /* Make a great object */
475 make_object(o_ptr, AM_GOOD | AM_GREAT);
476 (void)drop_near(o_ptr, -1, y, x);
482 * @brief 特定のアーティファクトを入手した際のクエスト達成処理 /
483 * Check for "Quest" completion when a quest monster is killed or charmed.
484 * @param o_ptr 入手したオブジェクトの構造体参照ポインタ
487 void check_find_art_quest_completion(object_type *o_ptr)
490 /* Check if completed a quest */
491 for (i = 0; i < max_q_idx; i++)
493 if((quest[i].type == QUEST_TYPE_FIND_ARTIFACT) &&
494 (quest[i].status == QUEST_STATUS_TAKEN) &&
495 (quest[i].k_idx == o_ptr->name1))
504 * @brief モンスターを撃破した際の述語メッセージを返す /
505 * Return monster death string
506 * @param r_ptr 撃破されたモンスターの種族情報を持つ構造体の参照ポインタ
507 * @return 撃破されたモンスターの述語
509 concptr extract_note_dies(MONRACE_IDX r_idx)
511 monster_race *r_ptr = &r_info[r_idx];
512 /* Some monsters get "destroyed" */
513 if (!monster_living(r_idx))
517 for (i = 0; i < 4; i++)
519 if (r_ptr->blow[i].method == RBM_EXPLODE)
521 return _("は爆発して粉々になった。", " explodes into tiny shreds.");
524 return _("を倒した。", " is destroyed.");
527 /* Assume a default death */
528 return _("は死んだ。", " dies.");
533 * @brief モンスターが死亡した時の処理 /
534 * Handle the "death" of a monster.
535 * @param m_idx 死亡したモンスターのID
536 * @param drop_item TRUEならばモンスターのドロップ処理を行う
537 * @return 撃破されたモンスターの述語
540 * Disperse treasures centered at the monster location based on the
541 * various flags contained in the monster flags fields.
542 * Check for "Quest" completion when a quest monster is killed.
543 * Note that only the player can induce "monster_death()" on Uniques.
544 * Thus (for now) all Quest monsters should be Uniques.
545 * Note that monsters can now carry objects, and when a monster dies,
546 * it drops all of its objects, which may disappear in crowded rooms.
549 void monster_death(MONSTER_IDX m_idx, bool drop_item)
558 monster_type *m_ptr = &m_list[m_idx];
559 monster_race *r_ptr = &r_info[m_ptr->r_idx];
561 bool visible = ((m_ptr->ml && !p_ptr->image) || (r_ptr->flags1 & RF1_UNIQUE));
565 bool do_gold = (!(r_ptr->flags1 & RF1_ONLY_ITEM));
566 bool do_item = (!(r_ptr->flags1 & RF1_ONLY_GOLD));
567 bool cloned = (m_ptr->smart & SM_CLONED) ? TRUE : FALSE;
568 int force_coin = get_coin_type(m_ptr->r_idx);
573 bool drop_chosen_item = drop_item && !cloned && !p_ptr->inside_arena
574 && !p_ptr->inside_battle && !is_pet(m_ptr);
576 /* The caster is dead? */
577 if (world_monster && world_monster == m_idx) world_monster = 0;
579 /* Notice changes in view */
580 if (r_ptr->flags7 & (RF7_LITE_MASK | RF7_DARK_MASK))
582 /* Update some things */
583 p_ptr->update |= (PU_MON_LITE);
589 if (record_named_pet && is_pet(m_ptr) && m_ptr->nickname)
591 GAME_TEXT m_name[MAX_NLEN];
593 monster_desc(m_name, m_ptr, MD_INDEF_VISIBLE);
594 do_cmd_write_nikki(NIKKI_NAMED_PET, 3, m_name);
597 /* Let monsters explode! */
598 for (i = 0; i < 4; i++)
600 if (r_ptr->blow[i].method == RBM_EXPLODE)
602 BIT_FLAGS flg = PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL;
603 EFFECT_ID typ = mbe_info[r_ptr->blow[i].effect].explode_type;
604 DICE_NUMBER d_dice = r_ptr->blow[i].d_dice;
605 DICE_SID d_side = r_ptr->blow[i].d_side;
606 HIT_POINT damage = damroll(d_dice, d_side);
608 project(m_idx, 3, y, x, damage, typ, flg, -1);
613 if (m_ptr->mflag2 & MFLAG2_CHAMELEON)
615 choose_new_monster(m_idx, TRUE, MON_CHAMELEON);
616 r_ptr = &r_info[m_ptr->r_idx];
619 /* Check for quest completion */
620 check_quest_completion(m_ptr);
622 /* Handle the possibility of player vanquishing arena combatant -KMW- */
623 if (p_ptr->inside_arena && !is_pet(m_ptr))
625 p_ptr->exit_bldg = TRUE;
627 if (p_ptr->arena_number > MAX_ARENA_MONS)
629 msg_print(_("素晴らしい!君こそ真の勝利者だ。", "You are a Genuine Champion!"));
633 msg_print(_("勝利!チャンピオンへの道を進んでいる。", "Victorious! You're on your way to becoming Champion."));
636 if (arena_info[p_ptr->arena_number].tval)
640 /* Prepare to make a prize */
641 object_prep(q_ptr, lookup_kind(arena_info[p_ptr->arena_number].tval, arena_info[p_ptr->arena_number].sval));
642 apply_magic(q_ptr, object_level, AM_NO_FIXED_ART);
643 (void)drop_near(q_ptr, -1, y, x);
646 if (p_ptr->arena_number > MAX_ARENA_MONS) p_ptr->arena_number++;
647 p_ptr->arena_number++;
650 GAME_TEXT m_name[MAX_NLEN];
652 /* Extract monster name */
653 monster_desc(m_name, m_ptr, MD_IGNORE_HALLU | MD_ASSUME_VISIBLE | MD_INDEF_VISIBLE);
655 do_cmd_write_nikki(NIKKI_ARENA, p_ptr->arena_number, m_name);
659 if (m_idx == p_ptr->riding)
661 if (rakuba(-1, FALSE))
663 msg_print(_("地面に落とされた。", "You have fallen from your riding pet."));
667 /* Drop a dead corpse? */
668 if (one_in_(r_ptr->flags1 & RF1_UNIQUE ? 1 : 4) &&
669 (r_ptr->flags9 & (RF9_DROP_CORPSE | RF9_DROP_SKELETON)) &&
670 !(p_ptr->inside_arena || p_ptr->inside_battle || cloned || ((m_ptr->r_idx == today_mon) && is_pet(m_ptr))))
672 /* Assume skeleton */
676 * We cannot drop a skeleton? Note, if we are in this check,
677 * we *know* we can drop at least a corpse or a skeleton
679 if (!(r_ptr->flags9 & RF9_DROP_SKELETON))
681 else if ((r_ptr->flags9 & RF9_DROP_CORPSE) && (r_ptr->flags1 & RF1_UNIQUE))
684 /* Else, a corpse is more likely unless we did a "lot" of damage */
685 else if (r_ptr->flags9 & RF9_DROP_CORPSE)
687 /* Lots of damage in one blow */
688 if ((0 - ((m_ptr->maxhp) / 4)) > m_ptr->hp)
690 if (one_in_(5)) corpse = TRUE;
694 if (!one_in_(5)) corpse = TRUE;
699 /* Prepare to make an object */
700 object_prep(q_ptr, lookup_kind(TV_CORPSE, (corpse ? SV_CORPSE : SV_SKELETON)));
702 apply_magic(q_ptr, object_level, AM_NO_FIXED_ART);
704 q_ptr->pval = m_ptr->r_idx;
705 (void)drop_near(q_ptr, -1, y, x);
708 /* Drop objects being carried */
709 monster_drop_carried_objects(m_ptr);
711 if (r_ptr->flags1 & RF1_DROP_GOOD) mo_mode |= AM_GOOD;
712 if (r_ptr->flags1 & RF1_DROP_GREAT) mo_mode |= AM_GREAT;
714 switch (m_ptr->r_idx)
716 case MON_PINK_HORROR:
717 /* Pink horrors are replaced with 2 Blue horrors */
718 if (!(p_ptr->inside_arena || p_ptr->inside_battle))
722 for (i = 0; i < 2; i++)
724 POSITION wy = y, wx = x;
725 bool pet = is_pet(m_ptr);
728 if (pet) mode |= PM_FORCE_PET;
730 if (summon_specific((pet ? -1 : m_idx), wy, wx, 100, SUMMON_BLUE_HORROR, mode, '\0'))
732 if (player_can_see_bold(wy, wx)) notice = TRUE;
736 if (notice) msg_print(_("ピンク・ホラーは分裂した!", "The Pink horror divides!"));
740 case MON_BLOODLETTER:
741 /* Bloodletters of Khorne may drop a blade of chaos */
742 if (drop_chosen_item && (randint1(100) < 15))
746 /* Prepare to make a Blade of Chaos */
747 object_prep(q_ptr, lookup_kind(TV_SWORD, SV_BLADE_OF_CHAOS));
749 apply_magic(q_ptr, object_level, AM_NO_FIXED_ART | mo_mode);
750 (void)drop_near(q_ptr, -1, y, x);
755 if (drop_chosen_item && (dun_level > 9))
760 /* Activate restriction */
761 if ((dun_level > 49) && one_in_(5))
762 get_obj_num_hook = kind_is_good_book;
764 get_obj_num_hook = kind_is_book;
767 make_object(q_ptr, mo_mode);
768 (void)drop_near(q_ptr, -1, y, x);
774 * Mega^3-hack: killing a 'Warrior of the Dawn' is likely to
775 * spawn another in the fallen one's place!
777 if (!p_ptr->inside_arena && !p_ptr->inside_battle)
781 POSITION wy = y, wx = x;
783 bool pet = is_pet(m_ptr);
787 scatter(&wy, &wx, y, x, 20, 0);
789 while (!(in_bounds(wy, wx) && cave_empty_bold2(wy, wx)) && --attempts);
794 if (pet) mode |= PM_FORCE_PET;
796 if (summon_specific((pet ? -1 : m_idx), wy, wx, 100, SUMMON_DAWN, mode, '\0'))
798 if (player_can_see_bold(wy, wx))
799 msg_print(_("新たな戦士が現れた!", "A new warrior steps forth!"));
807 /* One more ultra-hack: An Unmaker goes out with a big bang! */
809 BIT_FLAGS flg = PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL;
810 (void)project(m_idx, 6, y, x, 100, GF_CHAOS, flg, -1);
814 case MON_UNICORN_ORD:
817 /* Reward for "lazy" player */
818 if (p_ptr->pseikaku == SEIKAKU_NAMAKE)
820 ARTIFACT_IDX a_idx = 0;
821 artifact_type *a_ptr = NULL;
823 if (!drop_chosen_item) break;
830 a_idx = ART_NAMAKE_HAMMER;
833 a_idx = ART_NAMAKE_BOW;
836 a_idx = ART_NAMAKE_ARMOR;
840 a_ptr = &a_info[a_idx];
842 while (a_ptr->cur_num);
844 /* Create the artifact */
845 if (create_named_art(a_idx, y, x))
849 /* Hack -- Memorize location of artifact in saved floors */
850 if (character_dungeon) a_ptr->floor_id = p_ptr->floor_id;
852 else if (!preserve_mode) a_ptr->cur_num = 1;
857 if (!drop_chosen_item) break;
860 /* Mega-Hack -- Prepare to make "Grond" */
861 object_prep(q_ptr, lookup_kind(TV_HAFTED, SV_GROND));
863 /* Mega-Hack -- Mark this item as "Grond" */
864 q_ptr->name1 = ART_GROND;
866 /* Mega-Hack -- Actually create "Grond" */
867 apply_magic(q_ptr, -1, AM_GOOD | AM_GREAT);
868 (void)drop_near(q_ptr, -1, y, x);
871 /* Mega-Hack -- Prepare to make "Chaos" */
872 object_prep(q_ptr, lookup_kind(TV_CROWN, SV_CHAOS));
874 /* Mega-Hack -- Mark this item as "Chaos" */
875 q_ptr->name1 = ART_CHAOS;
877 /* Mega-Hack -- Actually create "Chaos" */
878 apply_magic(q_ptr, -1, AM_GOOD | AM_GREAT);
879 (void)drop_near(q_ptr, -1, y, x);
882 case MON_B_DEATH_SWORD:
883 if (drop_chosen_item)
887 /* Prepare to make a broken sword */
888 object_prep(q_ptr, lookup_kind(TV_SWORD, randint1(2)));
889 (void)drop_near(q_ptr, -1, y, x);
895 if (drop_chosen_item && ((m_ptr->r_idx == MON_A_GOLD) ||
896 ((m_ptr->r_idx == MON_A_SILVER) && (r_ptr->r_akills % 5 == 0))))
900 /* Prepare to make a Can of Toys */
901 object_prep(q_ptr, lookup_kind(TV_CHEST, SV_CHEST_KANDUME));
903 apply_magic(q_ptr, object_level, AM_NO_FIXED_ART);
904 (void)drop_near(q_ptr, -1, y, x);
910 BIT_FLAGS flg = PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL;
911 (void)project(m_idx, 3, y, x, damroll(20, 10), GF_FIRE, flg, -1);
916 if (!drop_chosen_item) break;
918 switch (r_ptr->d_char)
926 /* Activate restriction */
927 get_obj_num_hook = kind_is_cloak;
930 make_object(q_ptr, mo_mode);
931 (void)drop_near(q_ptr, -1, y, x);
941 /* Activate restriction */
942 get_obj_num_hook = kind_is_polearm;
944 /* Make a poleweapon */
945 make_object(q_ptr, mo_mode);
946 (void)drop_near(q_ptr, -1, y, x);
956 /* Activate restriction */
957 get_obj_num_hook = kind_is_armor;
959 /* Make a hard armor */
960 make_object(q_ptr, mo_mode);
961 (void)drop_near(q_ptr, -1, y, x);
971 /* Activate restriction */
972 get_obj_num_hook = kind_is_hafted;
974 /* Make a hafted weapon */
975 make_object(q_ptr, mo_mode);
976 (void)drop_near(q_ptr, -1, y, x);
981 if (m_ptr->r_idx != MON_STORMBRINGER)
986 /* Activate restriction */
987 get_obj_num_hook = kind_is_sword;
990 make_object(q_ptr, mo_mode);
991 (void)drop_near(q_ptr, -1, y, x);
998 /* Mega-Hack -- drop fixed items */
999 if (drop_chosen_item)
1001 ARTIFACT_IDX a_idx = 0;
1004 for(i = 0; i < 4; i++)
1006 if(!r_ptr->artifact_id[i]) break;
1007 a_idx = r_ptr->artifact_id[i];
1008 chance = r_ptr->artifact_percent[i];
1011 if ((a_idx > 0) && ((randint0(100) < chance) || p_ptr->wizard))
1013 artifact_type *a_ptr = &a_info[a_idx];
1015 if (!a_ptr->cur_num)
1017 /* Create the artifact */
1018 if (create_named_art(a_idx, y, x))
1022 /* Hack -- Memorize location of artifact in saved floors */
1023 if (character_dungeon) a_ptr->floor_id = p_ptr->floor_id;
1025 else if (!preserve_mode) a_ptr->cur_num = 1;
1029 if ((r_ptr->flags7 & RF7_GUARDIAN) && (d_info[dungeon_type].final_guardian == m_ptr->r_idx))
1031 KIND_OBJECT_IDX k_idx = d_info[dungeon_type].final_object ? d_info[dungeon_type].final_object
1032 : lookup_kind(TV_SCROLL, SV_SCROLL_ACQUIREMENT);
1034 if (d_info[dungeon_type].final_artifact)
1036 a_idx = d_info[dungeon_type].final_artifact;
1037 artifact_type *a_ptr = &a_info[a_idx];
1039 if (!a_ptr->cur_num)
1041 /* Create the artifact */
1042 if (create_named_art(a_idx, y, x))
1046 /* Hack -- Memorize location of artifact in saved floors */
1047 if (character_dungeon) a_ptr->floor_id = p_ptr->floor_id;
1049 else if (!preserve_mode) a_ptr->cur_num = 1;
1051 /* Prevent rewarding both artifact and "default" object */
1052 if (!d_info[dungeon_type].final_object) k_idx = 0;
1060 /* Prepare to make a reward */
1061 object_prep(q_ptr, k_idx);
1063 apply_magic(q_ptr, object_level, AM_NO_FIXED_ART | AM_GOOD);
1064 (void)drop_near(q_ptr, -1, y, x);
1066 msg_format(_("あなたは%sを制覇した!", "You have conquered %s!"),d_name+d_info[dungeon_type].name);
1070 /* Determine how much we can drop */
1071 if ((r_ptr->flags1 & RF1_DROP_60) && (randint0(100) < 60)) number++;
1072 if ((r_ptr->flags1 & RF1_DROP_90) && (randint0(100) < 90)) number++;
1073 if (r_ptr->flags1 & RF1_DROP_1D2) number += damroll(1, 2);
1074 if (r_ptr->flags1 & RF1_DROP_2D2) number += damroll(2, 2);
1075 if (r_ptr->flags1 & RF1_DROP_3D2) number += damroll(3, 2);
1076 if (r_ptr->flags1 & RF1_DROP_4D2) number += damroll(4, 2);
1078 if (cloned && !(r_ptr->flags1 & RF1_UNIQUE))
1079 number = 0; /* Clones drop no stuff unless Cloning Pits */
1081 if (is_pet(m_ptr) || p_ptr->inside_battle || p_ptr->inside_arena)
1082 number = 0; /* Pets drop no stuff */
1083 if (!drop_item && (r_ptr->d_char != '$')) number = 0;
1085 if((r_ptr->flags2 & (RF2_MULTIPLY)) && (r_ptr->r_akills > 1024))
1086 number = 0; /* Limit of Multiply monster drop */
1088 /* Hack -- handle creeping coins */
1089 coin_type = force_coin;
1091 /* Average dungeon and monster levels */
1092 object_level = (dun_level + r_ptr->level) / 2;
1094 /* Drop some objects */
1095 for (j = 0; j < number; j++)
1101 if (do_gold && (!do_item || (randint0(100) < 50)))
1103 /* Make some gold */
1104 if (!make_gold(q_ptr)) continue;
1112 /* Make an object */
1113 if (!make_object(q_ptr, mo_mode)) continue;
1117 (void)drop_near(q_ptr, -1, y, x);
1120 /* Reset the object level */
1121 object_level = base_level;
1123 /* Reset "coin" type */
1127 /* Take note of any dropped treasure */
1128 if (visible && (dump_item || dump_gold))
1130 /* Take notes on treasure */
1131 lore_treasure(m_idx, dump_item, dump_gold);
1134 /* Only process "Quest Monsters" */
1135 if (!(r_ptr->flags1 & RF1_QUESTOR)) return;
1136 if (p_ptr->inside_battle) return;
1139 if ((m_ptr->r_idx == MON_SERPENT) && !cloned)
1142 p_ptr->total_winner = TRUE;
1144 /* Redraw the "title" */
1145 p_ptr->redraw |= (PR_TITLE);
1147 play_music(TERM_XTRA_MUSIC_BASIC, MUSIC_BASIC_FINAL_QUEST_CLEAR);
1149 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, _("見事に変愚蛮怒の勝利者となった!", "become *WINNER* of Hengband finely!"));
1151 if ((p_ptr->pclass == CLASS_CHAOS_WARRIOR) || (p_ptr->muta2 & MUT2_CHAOS_GIFT))
1153 msg_format(_("%sからの声が響いた。", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
1154 msg_print(_("『よくやった、定命の者よ!』", "'Thou art donst well, mortal!'"));
1157 /* Congratulations */
1158 msg_print(_("*** おめでとう ***", "*** CONGRATULATIONS ***"));
1159 msg_print(_("あなたはゲームをコンプリートしました。", "You have won the game!"));
1160 msg_print(_("準備が整ったら引退(自殺コマンド)しても結構です。", "You may retire (commit suicide) when you are ready."));
1165 * @brief モンスターに与えたダメージの修正処理 /
1166 * Modify the physical damage done to the monster.
1167 * @param m_ptr ダメージを受けるモンスターの構造体参照ポインタ
1168 * @param dam ダメージ基本値
1169 * @param is_psy_spear 攻撃手段が光の剣ならばTRUE
1170 * @return 修正を行った結果のダメージ量
1173 * (for example when it's invulnerable or shielded)
1174 * ToDo: Accept a damage-type to calculate the modified damage from
1175 * things like fire, frost, lightning, poison, ... attacks.
1176 * "type" is not yet used and should be 0.
1179 HIT_POINT mon_damage_mod(monster_type *m_ptr, HIT_POINT dam, bool is_psy_spear)
1181 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1183 if ((r_ptr->flagsr & RFR_RES_ALL) && dam > 0)
1186 if ((dam == 0) && one_in_(3)) dam = 1;
1189 if (MON_INVULNER(m_ptr))
1193 if (!p_ptr->blind && is_seen(m_ptr))
1195 msg_print(_("バリアを切り裂いた!", "The barrier is penetrated!"));
1198 else if (!one_in_(PENETRATE_INVULNERABILITY))
1208 * @brief モンスターに与えたダメージを元に経験値を加算する /
1209 * Calculate experience point to be get
1210 * @param dam 与えたダメージ量
1211 * @param m_ptr ダメージを与えたモンスターの構造体参照ポインタ
1215 * Even the 64 bit operation is not big enough to avoid overflaw
1216 * unless we carefully choose orders of multiplication and division.
1217 * Get the coefficient first, and multiply (potentially huge) base
1218 * experience point of a monster later.
1221 static void get_exp_from_mon(HIT_POINT dam, monster_type *m_ptr)
1223 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1230 if (!m_ptr->r_idx) return;
1231 if (is_pet(m_ptr) || p_ptr->inside_battle) return;
1234 * - Ratio of monster's level to player's level effects
1235 * - Varying speed effects
1236 * - Get a fraction in proportion of damage point
1238 new_exp = r_ptr->level * SPEED_TO_ENERGY(m_ptr->mspeed) * dam;
1241 div_l = (p_ptr->max_plv+2) * SPEED_TO_ENERGY(r_ptr->speed);
1243 /* Use (average maxhp * 2) as a denominator */
1244 if (!(r_ptr->flags1 & RF1_FORCE_MAXHP))
1245 s64b_mul(&div_h, &div_l, 0, r_ptr->hdice * (ironman_nightmare ? 2 : 1) * (r_ptr->hside + 1));
1247 s64b_mul(&div_h, &div_l, 0, r_ptr->hdice * (ironman_nightmare ? 2 : 1) * r_ptr->hside * 2);
1249 /* Special penalty in the wilderness */
1250 if (!dun_level && (!(r_ptr->flags8 & RF8_WILD_ONLY) || !(r_ptr->flags1 & RF1_UNIQUE)))
1251 s64b_mul(&div_h, &div_l, 0, 5);
1253 /* Do division first to prevent overflaw */
1254 s64b_div(&new_exp, &new_exp_frac, div_h, div_l);
1256 /* Special penalty for mutiply-monster */
1257 if ((r_ptr->flags2 & RF2_MULTIPLY) || (m_ptr->r_idx == MON_DAWN))
1259 int monnum_penarty = r_ptr->r_akills / 400;
1260 if (monnum_penarty > 8) monnum_penarty = 8;
1262 while (monnum_penarty--)
1265 s64b_RSHIFT(new_exp, new_exp_frac, 2);
1269 /* Special penalty for rest_and_shoot exp scum */
1270 if ((m_ptr->dealt_damage > m_ptr->max_maxhp) && (m_ptr->hp >= 0))
1272 int over_damage = m_ptr->dealt_damage / m_ptr->max_maxhp;
1273 if (over_damage > 32) over_damage = 32;
1275 while (over_damage--)
1278 s64b_mul(&new_exp, &new_exp_frac, 0, 9);
1279 s64b_div(&new_exp, &new_exp_frac, 0, 10);
1283 /* Finally multiply base experience point of the monster */
1284 s64b_mul(&new_exp, &new_exp_frac, 0, r_ptr->mexp);
1286 /* Gain experience */
1287 gain_exp_64(new_exp, new_exp_frac);
1292 * @brief モンスターのHPをダメージに応じて減算する /
1293 * Decreases monsters hit points, handling monster death.
1294 * @param dam 与えたダメージ量
1295 * @param m_idx ダメージを与えたモンスターのID
1296 * @param fear ダメージによってモンスターが恐慌状態に陥ったならばTRUEを返す
1297 * @param note モンスターが倒された際の特別なメッセージ述語
1301 * We return TRUE if the monster has been killed (and deleted).
1302 * We announce monster death (using an optional "death message"
1303 * if given, and a otherwise a generic killed/destroyed message).
1304 * Only "physical attacks" can induce the "You have slain" message.
1305 * Missile and Spell attacks will induce the "dies" message, or
1306 * various "specialized" messages. Note that "You have destroyed"
1307 * and "is destroyed" are synonyms for "You have slain" and "dies".
1308 * Hack -- unseen monsters yield "You have killed it." message.
1309 * Added fear (DGK) and check whether to print fear messages -CWS
1310 * Made name, sex, and capitalization generic -BEN-
1311 * As always, the "ghost" processing is a total hack.
1312 * Hack -- we "delay" fear messages by passing around a "fear" flag.
1313 * Consider decreasing monster experience over time, say,
1314 * by using "(m_exp * m_lev * (m_lev)) / (p_lev * (m_lev + n_killed))"
1315 * instead of simply "(m_exp * m_lev) / (p_lev)", to make the first
1316 * monster worth more than subsequent monsters. This would also need
1317 * to induce changes in the monster recall code.
1320 bool mon_take_hit(MONSTER_IDX m_idx, HIT_POINT dam, bool *fear, concptr note)
1322 monster_type *m_ptr = &m_list[m_idx];
1323 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1324 monster_type exp_mon;
1326 /* Innocent until proven otherwise */
1327 bool innocent = TRUE, thief = FALSE;
1331 (void)COPY(&exp_mon, m_ptr, monster_type);
1333 expdam = (m_ptr->hp > dam) ? dam : m_ptr->hp;
1335 get_exp_from_mon(expdam, &exp_mon);
1337 /* Genocided by chaos patron */
1338 if (!m_ptr->r_idx) m_idx = 0;
1340 /* Redraw (later) if needed */
1341 if (p_ptr->health_who == m_idx) p_ptr->redraw |= (PR_HEALTH);
1342 if (p_ptr->riding == m_idx) p_ptr->redraw |= (PR_UHEALTH);
1344 (void)set_monster_csleep(m_idx, 0);
1346 /* Hack - Cancel any special player stealth magics. -LM- */
1347 if (p_ptr->special_defense & NINJA_S_STEALTH)
1349 set_superstealth(FALSE);
1352 /* Genocided by chaos patron */
1353 if (!m_idx) return TRUE;
1356 m_ptr->dealt_damage += dam;
1358 if(m_ptr->dealt_damage > m_ptr->max_maxhp * 100) m_ptr->dealt_damage = m_ptr->max_maxhp * 100;
1362 msg_format( _("合計%d/%dのダメージを与えた。","You do %d (out of %d) damage."), m_ptr->dealt_damage, m_ptr->maxhp);
1365 /* It is dead now */
1368 GAME_TEXT m_name[MAX_NLEN];
1370 if (r_info[m_ptr->r_idx].flags7 & RF7_TANUKI)
1372 /* You might have unmasked Tanuki first time */
1373 r_ptr = &r_info[m_ptr->r_idx];
1374 m_ptr->ap_r_idx = m_ptr->r_idx;
1375 if (r_ptr->r_sights < MAX_SHORT) r_ptr->r_sights++;
1378 if (m_ptr->mflag2 & MFLAG2_CHAMELEON)
1380 /* You might have unmasked Chameleon first time */
1381 r_ptr = real_r_ptr(m_ptr);
1382 if (r_ptr->r_sights < MAX_SHORT) r_ptr->r_sights++;
1385 if (!(m_ptr->smart & SM_CLONED))
1387 /* When the player kills a Unique, it stays dead */
1388 if (r_ptr->flags1 & RF1_UNIQUE)
1392 /* Mega-Hack -- Banor & Lupart */
1393 if ((m_ptr->r_idx == MON_BANOR) || (m_ptr->r_idx == MON_LUPART))
1395 r_info[MON_BANORLUPART].max_num = 0;
1396 r_info[MON_BANORLUPART].r_pkills++;
1397 r_info[MON_BANORLUPART].r_akills++;
1398 if (r_info[MON_BANORLUPART].r_tkills < MAX_SHORT) r_info[MON_BANORLUPART].r_tkills++;
1400 else if (m_ptr->r_idx == MON_BANORLUPART)
1402 r_info[MON_BANOR].max_num = 0;
1403 r_info[MON_BANOR].r_pkills++;
1404 r_info[MON_BANOR].r_akills++;
1405 if (r_info[MON_BANOR].r_tkills < MAX_SHORT) r_info[MON_BANOR].r_tkills++;
1406 r_info[MON_LUPART].max_num = 0;
1407 r_info[MON_LUPART].r_pkills++;
1408 r_info[MON_LUPART].r_akills++;
1409 if (r_info[MON_LUPART].r_tkills < MAX_SHORT) r_info[MON_LUPART].r_tkills++;
1413 /* When the player kills a Nazgul, it stays dead */
1414 else if (r_ptr->flags7 & RF7_NAZGUL) r_ptr->max_num--;
1417 /* Count all monsters killed */
1418 if (r_ptr->r_akills < MAX_SHORT) r_ptr->r_akills++;
1420 /* Recall even invisible uniques or winners */
1421 if ((m_ptr->ml && !p_ptr->image) || (r_ptr->flags1 & RF1_UNIQUE))
1423 /* Count kills this life */
1424 if ((m_ptr->mflag2 & MFLAG2_KAGE) && (r_info[MON_KAGE].r_pkills < MAX_SHORT)) r_info[MON_KAGE].r_pkills++;
1425 else if (r_ptr->r_pkills < MAX_SHORT) r_ptr->r_pkills++;
1427 /* Count kills in all lives */
1428 if ((m_ptr->mflag2 & MFLAG2_KAGE) && (r_info[MON_KAGE].r_tkills < MAX_SHORT)) r_info[MON_KAGE].r_tkills++;
1429 else if (r_ptr->r_tkills < MAX_SHORT) r_ptr->r_tkills++;
1431 /* Hack -- Auto-recall */
1432 monster_race_track(m_ptr->ap_r_idx);
1435 /* Extract monster name */
1436 monster_desc(m_name, m_ptr, MD_TRUE_NAME);
1438 /* Don't kill Amberites */
1439 if ((r_ptr->flags3 & RF3_AMBERITE) && one_in_(2))
1441 int curses = 1 + randint1(3);
1442 bool stop_ty = FALSE;
1445 msg_format(_("%^sは恐ろしい血の呪いをあなたにかけた!", "%^s puts a terrible blood curse on you!"), m_name);
1446 curse_equipment(100, 50);
1450 stop_ty = activate_ty_curse(stop_ty, &count);
1455 if (r_ptr->flags2 & RF2_CAN_SPEAK)
1457 char line_got[1024];
1458 if (!get_rnd_line(_("mondeath_j.txt", "mondeath.txt"), m_ptr->r_idx, line_got))
1460 msg_format("%^s %s", m_name, line_got);
1464 if (m_ptr->r_idx == MON_SERPENT)
1466 screen_dump = make_screen_dump();
1471 if (!(d_info[dungeon_type].flags1 & DF1_BEGINNER))
1473 if (!dun_level && !ambush_flag && !p_ptr->inside_arena)
1475 chg_virtue(V_VALOUR, -1);
1477 else if (r_ptr->level > dun_level)
1479 if (randint1(10) <= (r_ptr->level - dun_level))
1480 chg_virtue(V_VALOUR, 1);
1482 if (r_ptr->level > 60)
1484 chg_virtue(V_VALOUR, 1);
1486 if (r_ptr->level >= 2 * (p_ptr->lev+1))
1487 chg_virtue(V_VALOUR, 2);
1490 if (r_ptr->flags1 & RF1_UNIQUE)
1492 if (r_ptr->flags3 & (RF3_EVIL | RF3_GOOD)) chg_virtue(V_HARMONY, 2);
1494 if (r_ptr->flags3 & RF3_GOOD)
1496 chg_virtue(V_UNLIFE, 2);
1497 chg_virtue(V_VITALITY, -2);
1500 if (one_in_(3)) chg_virtue(V_INDIVIDUALISM, -1);
1503 if (m_ptr->r_idx == MON_BEGGAR || m_ptr->r_idx == MON_LEPER)
1505 chg_virtue(V_COMPASSION, -1);
1508 if ((r_ptr->flags3 & RF3_GOOD) && ((r_ptr->level) / 10 + (3 * dun_level) >= randint1(100)))
1509 chg_virtue(V_UNLIFE, 1);
1511 if (r_ptr->d_char == 'A')
1513 if (r_ptr->flags1 & RF1_UNIQUE)
1514 chg_virtue(V_FAITH, -2);
1515 else if ((r_ptr->level) / 10 + (3 * dun_level) >= randint1(100))
1517 if (r_ptr->flags3 & RF3_GOOD) chg_virtue(V_FAITH, -1);
1518 else chg_virtue(V_FAITH, 1);
1521 else if (r_ptr->flags3 & RF3_DEMON)
1523 if (r_ptr->flags1 & RF1_UNIQUE)
1524 chg_virtue(V_FAITH, 2);
1525 else if ((r_ptr->level) / 10 + (3 * dun_level) >= randint1(100))
1526 chg_virtue(V_FAITH, 1);
1529 if ((r_ptr->flags3 & RF3_UNDEAD) && (r_ptr->flags1 & RF1_UNIQUE))
1530 chg_virtue(V_VITALITY, 2);
1532 if (r_ptr->r_deaths)
1534 if (r_ptr->flags1 & RF1_UNIQUE)
1536 chg_virtue(V_HONOUR, 10);
1538 else if ((r_ptr->level) / 10 + (2 * dun_level) >= randint1(100))
1540 chg_virtue(V_HONOUR, 1);
1543 if ((r_ptr->flags2 & RF2_MULTIPLY) && (r_ptr->r_akills > 1000) && one_in_(10))
1545 chg_virtue(V_VALOUR, -1);
1548 for (i = 0; i < 4; i++)
1550 if (r_ptr->blow[i].d_dice != 0) innocent = FALSE; /* Murderer! */
1552 if ((r_ptr->blow[i].effect == RBE_EAT_ITEM)
1553 || (r_ptr->blow[i].effect == RBE_EAT_GOLD))
1555 thief = TRUE; /* Thief! */
1558 /* The new law says it is illegal to live in the dungeon */
1559 if (r_ptr->level != 0) innocent = FALSE;
1563 if (r_ptr->flags1 & RF1_UNIQUE)
1564 chg_virtue(V_JUSTICE, 3);
1565 else if (1+((r_ptr->level) / 10 + (2 * dun_level)) >= randint1(100))
1566 chg_virtue(V_JUSTICE, 1);
1570 chg_virtue (V_JUSTICE, -1);
1573 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)))
1575 if (one_in_(4)) chg_virtue(V_NATURE, -1);
1578 if ((r_ptr->flags1 & RF1_UNIQUE) && record_destroy_uniq)
1581 sprintf(note_buf, "%s%s", r_name + r_ptr->name, (m_ptr->smart & SM_CLONED) ? _("(クローン)", "(Clone)") : "");
1582 do_cmd_write_nikki(NIKKI_UNIQUE, 0, note_buf);
1588 /* Death by Missile/Spell attack */
1591 msg_format("%^s%s", m_name, note);
1594 /* Death by physical attack -- invisible monster */
1595 else if (!m_ptr->ml)
1598 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
1599 msg_format("せっかくだから%sを殺した。", m_name);
1601 msg_format("%sを殺した。", m_name);
1603 msg_format("You have killed %s.", m_name);
1608 /* Death by Physical attack -- non-living monster */
1609 else if (!monster_living(m_ptr->r_idx))
1611 bool explode = FALSE;
1613 for (i = 0; i < 4; i++)
1615 if (r_ptr->blow[i].method == RBM_EXPLODE) explode = TRUE;
1618 /* Special note at death */
1620 msg_format(_("%sは爆発して粉々になった。", "%^s explodes into tiny shreds."), m_name);
1624 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
1625 msg_format("せっかくだから%sを倒した。", m_name);
1627 msg_format("%sを倒した。", m_name);
1629 msg_format("You have destroyed %s.", m_name);
1634 /* Death by Physical attack -- living monster */
1638 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
1639 msg_format("せっかくだから%sを葬り去った。", m_name);
1641 msg_format("%sを葬り去った。", m_name);
1643 msg_format("You have slain %s.", m_name);
1647 if ((r_ptr->flags1 & RF1_UNIQUE) && !(m_ptr->smart & SM_CLONED) && !vanilla_town)
1649 for (i = 0; i < MAX_KUBI; i++)
1651 if ((kubi_r_idx[i] == m_ptr->r_idx) && !(m_ptr->mflag2 & MFLAG2_CHAMELEON))
1653 msg_format(_("%sの首には賞金がかかっている。", "There is a price on %s's head."), m_name);
1659 /* Generate treasure */
1660 monster_death(m_idx, TRUE);
1662 /* Mega hack : replace IKETA to BIKETAL */
1663 if ((m_ptr->r_idx == MON_IKETA) && !(p_ptr->inside_arena || p_ptr->inside_battle))
1665 POSITION dummy_y = m_ptr->fy;
1666 POSITION dummy_x = m_ptr->fx;
1667 BIT_FLAGS mode = 0L;
1668 if (is_pet(m_ptr)) mode |= PM_FORCE_PET;
1669 delete_monster_idx(m_idx);
1670 if (summon_named_creature(0, dummy_y, dummy_x, MON_BIKETAL, mode))
1672 msg_print(_("「ハァッハッハッハ!!私がバイケタルだ!!」", "Uwa-hahaha! *I* am Biketal!"));
1677 delete_monster_idx(m_idx);
1680 get_exp_from_mon((long)exp_mon.max_maxhp*2, &exp_mon);
1685 /* Monster is dead */
1692 /* Mega-Hack -- Pain cancels fear */
1693 if (MON_MONFEAR(m_ptr) && (dam > 0))
1696 if (set_monster_monfear(m_idx, MON_MONFEAR(m_ptr) - randint1(dam)))
1703 /* Sometimes a monster gets scared by damage */
1704 if (!MON_MONFEAR(m_ptr) && !(r_ptr->flags3 & (RF3_NO_FEAR)))
1706 /* Percentage of fully healthy */
1707 int percentage = (100L * m_ptr->hp) / m_ptr->maxhp;
1710 * Run (sometimes) if at 10% or less of max hit points,
1711 * or (usually) when hit for half its current hit points
1713 if ((randint1(10) >= percentage) || ((dam >= m_ptr->hp) && (randint0(100) < 80)))
1715 /* Hack -- note fear */
1718 /* Hack -- Add some timed fear */
1719 (void)set_monster_monfear(m_idx, (randint1(10) +
1720 (((dam >= m_ptr->hp) && (percentage > 7)) ?
1721 20 : ((11 - percentage) * 5))));
1733 * @brief 現在のコンソール表示の縦横を返す。 /
1734 * Get term size and calculate screen size
1735 * @param wid_p コンソールの表示幅文字数を返す
1736 * @param hgt_p コンソールの表示行数を返す
1739 void get_screen_size(TERM_LEN *wid_p, TERM_LEN *hgt_p)
1741 Term_get_size(wid_p, hgt_p);
1742 *hgt_p -= ROW_MAP + 2;
1743 *wid_p -= COL_MAP + 2;
1744 if (use_bigtile) *wid_p /= 2;
1749 * @brief コンソール上におけるマップ表示の左上位置を返す /
1750 * Calculates current boundaries Called below and from "do_cmd_locate()".
1753 void panel_bounds_center(void)
1757 get_screen_size(&wid, &hgt);
1759 panel_row_max = panel_row_min + hgt - 1;
1760 panel_row_prt = panel_row_min - 1;
1761 panel_col_max = panel_col_min + wid - 1;
1762 panel_col_prt = panel_col_min - 13;
1767 * @brief コンソールのリサイズに合わせてマップを再描画する /
1768 * Map resizing whenever the main term changes size
1771 void resize_map(void)
1773 /* Only if the dungeon exists */
1774 if (!character_dungeon) return;
1776 /* Mega-Hack -- no panel yet */
1780 /* Reset the panels */
1781 panel_row_min = cur_hgt;
1782 panel_col_min = cur_wid;
1786 p_ptr->update |= (PU_TORCH | PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
1787 p_ptr->update |= (PU_UN_VIEW | PU_UN_LITE);
1788 p_ptr->update |= (PU_VIEW | PU_LITE | PU_MON_LITE);
1789 p_ptr->update |= (PU_MONSTERS);
1790 p_ptr->redraw |= (PR_WIPE | PR_BASIC | PR_EXTRA | PR_MAP | PR_EQUIPPY);
1797 * Place the cursor on the player
1799 if (can_save) move_cursor_relative(p_ptr->y, p_ptr->x);
1805 * @brief コンソールを再描画する /
1806 * Redraw a term when it is resized
1809 void redraw_window(void)
1811 /* Only if the dungeon exists */
1812 if (!character_dungeon) return;
1814 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_SPELL | PW_PLAYER);
1815 p_ptr->window |= (PW_MESSAGE | PW_OVERHEAD | PW_DUNGEON | PW_MONSTER | PW_OBJECT);
1823 * @brief フォーカスを当てるべきマップ描画の基準座標を指定する(サブルーチン)
1824 * @param dy 変更先のフロアY座標
1825 * @param dx 変更先のフロアX座標
1826 * Handle a request to change the current panel
1827 * Return TRUE if the panel was changed.
1828 * Also used in do_cmd_locate
1829 * @return 実際に再描画が必要だった場合TRUEを返す
1831 bool change_panel(POSITION dy, POSITION dx)
1836 get_screen_size(&wid, &hgt);
1838 /* Apply the motion */
1839 y = panel_row_min + dy * hgt / 2;
1840 x = panel_col_min + dx * wid / 2;
1842 /* Verify the row */
1843 if (y > cur_hgt - hgt) y = cur_hgt - hgt;
1846 /* Verify the col */
1847 if (x > cur_wid - wid) x = cur_wid - wid;
1850 /* Handle "changes" */
1851 if ((y != panel_row_min) || (x != panel_col_min))
1853 /* Save the new panel info */
1857 /* Recalculate the boundaries */
1858 panel_bounds_center();
1860 p_ptr->update |= (PU_MONSTERS);
1861 p_ptr->redraw |= (PR_MAP);
1873 * @brief フォーカスを当てるべきマップ描画の基準座標を指定する
1874 * @param y 変更先のフロアY座標
1875 * @param x 変更先のフロアX座標
1877 * Handle a request to change the current panel
1878 * Return TRUE if the panel was changed.
1879 * Also used in do_cmd_locate
1880 * @return 実際に再描画が必要だった場合TRUEを返す
1882 static bool change_panel_xy(POSITION y, POSITION x)
1884 POSITION dy = 0, dx = 0;
1887 get_screen_size(&wid, &hgt);
1889 if (y < panel_row_min) dy = -1;
1890 if (y > panel_row_max) dy = 1;
1891 if (x < panel_col_min) dx = -1;
1892 if (x > panel_col_max) dx = 1;
1894 if (!dy && !dx) return (FALSE);
1896 return change_panel(dy, dx);
1901 * @brief マップ描画のフォーカスを当てるべき座標を更新する
1903 * Given an row (y) and col (x), this routine detects when a move
1904 * off the screen has occurred and figures new borders. -RAK-
1905 * "Update" forces a "full update" to take place.
1906 * The map is reprinted if necessary, and "TRUE" is returned.
1907 * @return 実際に再描画が必要だった場合TRUEを返す
1909 void verify_panel(void)
1911 POSITION y = p_ptr->y;
1912 POSITION x = p_ptr->x;
1920 get_screen_size(&wid, &hgt);
1922 max_prow_min = cur_hgt - hgt;
1923 max_pcol_min = cur_wid - wid;
1925 /* Bounds checking */
1926 if (max_prow_min < 0) max_prow_min = 0;
1927 if (max_pcol_min < 0) max_pcol_min = 0;
1929 /* Center on player */
1930 if (center_player && (center_running || !running))
1932 /* Center vertically */
1933 prow_min = y - hgt / 2;
1934 if (prow_min < 0) prow_min = 0;
1935 else if (prow_min > max_prow_min) prow_min = max_prow_min;
1937 /* Center horizontally */
1938 pcol_min = x - wid / 2;
1939 if (pcol_min < 0) pcol_min = 0;
1940 else if (pcol_min > max_pcol_min) pcol_min = max_pcol_min;
1944 prow_min = panel_row_min;
1945 pcol_min = panel_col_min;
1947 /* Scroll screen when 2 grids from top/bottom edge */
1948 if (y > panel_row_max - 2)
1950 while (y > prow_min + hgt-1 - 2)
1952 prow_min += (hgt / 2);
1956 if (y < panel_row_min + 2)
1958 while (y < prow_min + 2)
1960 prow_min -= (hgt / 2);
1964 if (prow_min > max_prow_min) prow_min = max_prow_min;
1965 if (prow_min < 0) prow_min = 0;
1967 /* Scroll screen when 4 grids from left/right edge */
1968 if (x > panel_col_max - 4)
1970 while (x > pcol_min + wid-1 - 4)
1972 pcol_min += (wid / 2);
1976 if (x < panel_col_min + 4)
1978 while (x < pcol_min + 4)
1980 pcol_min -= (wid / 2);
1984 if (pcol_min > max_pcol_min) pcol_min = max_pcol_min;
1985 if (pcol_min < 0) pcol_min = 0;
1988 /* Check for "no change" */
1989 if ((prow_min == panel_row_min) && (pcol_min == panel_col_min)) return;
1991 /* Save the new panel info */
1992 panel_row_min = prow_min;
1993 panel_col_min = pcol_min;
1995 /* Hack -- optional disturb on "panel change" */
1996 if (disturb_panel && !center_player) disturb(FALSE, FALSE);
1998 /* Recalculate the boundaries */
1999 panel_bounds_center();
2001 p_ptr->update |= (PU_MONSTERS);
2002 p_ptr->redraw |= (PR_MAP);
2003 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
2008 * Monster health description
2010 concptr look_mon_desc(monster_type *m_ptr, BIT_FLAGS mode)
2012 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
2019 /* Determine if the monster is "living" */
2020 living = monster_living(m_ptr->ap_r_idx);
2022 /* Calculate a health "percentage" */
2023 perc = m_ptr->maxhp > 0 ? 100L * m_ptr->hp / m_ptr->maxhp : 0;
2025 /* Healthy monsters */
2026 if (m_ptr->hp >= m_ptr->maxhp)
2028 desc = living ? _("無傷", "unhurt") : _("無ダメージ", "undamaged");
2031 else if (perc >= 60)
2033 desc = living ? _("軽傷", "somewhat wounded") : _("小ダメージ", "somewhat damaged");
2036 else if (perc >= 25)
2038 desc = living ? _("負傷", "wounded") : _("中ダメージ", "damaged");
2041 else if (perc >= 10)
2043 desc = living ? _("重傷", "badly wounded") : _("大ダメージ", "badly damaged");
2048 desc = living ? _("半死半生", "almost dead") : _("倒れかけ", "almost destroyed");
2051 /* Need attitude information? */
2054 /* Full information is not needed */
2057 else if (is_pet(m_ptr))
2059 attitude = _(", ペット", ", pet");
2061 else if (is_friendly(m_ptr))
2063 attitude = _(", 友好的", ", friendly");
2067 attitude = _("", "");
2070 /* Clone monster? */
2071 if (m_ptr->smart & SM_CLONED)
2080 /* Display monster's level --- idea borrowed from ToME */
2081 if (ap_r_ptr->r_tkills && !(m_ptr->mflag2 & MFLAG2_KAGE))
2083 return format(_("レベル%d, %s%s%s", "Level %d, %s%s%s"), ap_r_ptr->level, desc, attitude, clone);
2087 return format(_("レベル???, %s%s%s", "Level ???, %s%s%s"), desc, attitude, clone);
2094 /*** Targeting Code ***/
2098 * Determine is a monster makes a reasonable target
2100 * The concept of "targeting" was stolen from "Morgul" (?)
2102 * The player can target any location, or any "target-able" monster.
2104 * Currently, a monster is "target_able" if it is visible, and if
2105 * the player can hit it with a projection, and the player is not
2106 * hallucinating. This allows use of "use closest target" macros.
2108 * Future versions may restrict the ability to target "trappers"
2109 * and "mimics", but the semantics is a little bit weird.
2111 bool target_able(MONSTER_IDX m_idx)
2113 monster_type *m_ptr = &m_list[m_idx];
2115 /* Monster must be alive */
2116 if (!m_ptr->r_idx) return (FALSE);
2118 /* Hack -- no targeting hallucinations */
2119 if (p_ptr->image) return (FALSE);
2121 /* Monster must be visible */
2122 if (!m_ptr->ml) return (FALSE);
2124 if (p_ptr->riding && (p_ptr->riding == m_idx)) return (TRUE);
2126 /* Monster must be projectable */
2127 if (!projectable(p_ptr->y, p_ptr->x, m_ptr->fy, m_ptr->fx)) return (FALSE);
2129 /* Hack -- Never target trappers */
2130 /* if (CLEAR_ATTR && (CLEAR_CHAR)) return (FALSE); */
2140 * Update (if necessary) and verify (if possible) the target.
2142 * We return TRUE if the target is "okay" and FALSE otherwise.
2144 bool target_okay(void)
2146 /* Accept stationary targets */
2147 if (target_who < 0) return (TRUE);
2149 /* Check moving targets */
2152 /* Accept reasonable targets */
2153 if (target_able(target_who))
2155 monster_type *m_ptr = &m_list[target_who];
2157 /* Acquire monster location */
2158 target_row = m_ptr->fy;
2159 target_col = m_ptr->fx;
2166 /* Assume no target */
2172 * Sorting hook -- comp function -- by "distance to player"
2174 * We use "u" and "v" to point to arrays of "x" and "y" positions,
2175 * and sort the arrays by double-distance to the player.
2177 static bool ang_sort_comp_distance(vptr u, vptr v, int a, int b)
2179 POSITION *x = (POSITION*)(u);
2180 POSITION *y = (POSITION*)(v);
2182 POSITION da, db, kx, ky;
2184 /* Absolute distance components */
2185 kx = x[a]; kx -= p_ptr->x; kx = ABS(kx);
2186 ky = y[a]; ky -= p_ptr->y; ky = ABS(ky);
2188 /* Approximate Double Distance to the first point */
2189 da = ((kx > ky) ? (kx + kx + ky) : (ky + ky + kx));
2191 /* Absolute distance components */
2192 kx = x[b]; kx -= p_ptr->x; kx = ABS(kx);
2193 ky = y[b]; ky -= p_ptr->y; ky = ABS(ky);
2195 /* Approximate Double Distance to the first point */
2196 db = ((kx > ky) ? (kx + kx + ky) : (ky + ky + kx));
2198 /* Compare the distances */
2204 * Sorting hook -- comp function -- by importance level of grids
2206 * We use "u" and "v" to point to arrays of "x" and "y" positions,
2207 * and sort the arrays by level of monster
2209 static bool ang_sort_comp_importance(vptr u, vptr v, int a, int b)
2211 POSITION *x = (POSITION*)(u);
2212 POSITION *y = (POSITION*)(v);
2213 cave_type *ca_ptr = &cave[y[a]][x[a]];
2214 cave_type *cb_ptr = &cave[y[b]][x[b]];
2215 monster_type *ma_ptr = &m_list[ca_ptr->m_idx];
2216 monster_type *mb_ptr = &m_list[cb_ptr->m_idx];
2217 monster_race *ap_ra_ptr, *ap_rb_ptr;
2219 /* The player grid */
2220 if (y[a] == p_ptr->y && x[a] == p_ptr->x) return TRUE;
2221 if (y[b] == p_ptr->y && x[b] == p_ptr->x) return FALSE;
2223 /* Extract monster race */
2224 if (ca_ptr->m_idx && ma_ptr->ml) ap_ra_ptr = &r_info[ma_ptr->ap_r_idx];
2225 else ap_ra_ptr = NULL;
2226 if (cb_ptr->m_idx && mb_ptr->ml) ap_rb_ptr = &r_info[mb_ptr->ap_r_idx];
2227 else ap_rb_ptr = NULL;
2229 if (ap_ra_ptr && !ap_rb_ptr) return TRUE;
2230 if (!ap_ra_ptr && ap_rb_ptr) return FALSE;
2232 /* Compare two monsters */
2233 if (ap_ra_ptr && ap_rb_ptr)
2235 /* Unique monsters first */
2236 if ((ap_ra_ptr->flags1 & RF1_UNIQUE) && !(ap_rb_ptr->flags1 & RF1_UNIQUE)) return TRUE;
2237 if (!(ap_ra_ptr->flags1 & RF1_UNIQUE) && (ap_rb_ptr->flags1 & RF1_UNIQUE)) return FALSE;
2239 /* Shadowers first (あやしい影) */
2240 if ((ma_ptr->mflag2 & MFLAG2_KAGE) && !(mb_ptr->mflag2 & MFLAG2_KAGE)) return TRUE;
2241 if (!(ma_ptr->mflag2 & MFLAG2_KAGE) && (mb_ptr->mflag2 & MFLAG2_KAGE)) return FALSE;
2243 /* Unknown monsters first */
2244 if (!ap_ra_ptr->r_tkills && ap_rb_ptr->r_tkills) return TRUE;
2245 if (ap_ra_ptr->r_tkills && !ap_rb_ptr->r_tkills) return FALSE;
2247 /* Higher level monsters first (if known) */
2248 if (ap_ra_ptr->r_tkills && ap_rb_ptr->r_tkills)
2250 if (ap_ra_ptr->level > ap_rb_ptr->level) return TRUE;
2251 if (ap_ra_ptr->level < ap_rb_ptr->level) return FALSE;
2254 /* Sort by index if all conditions are same */
2255 if (ma_ptr->ap_r_idx > mb_ptr->ap_r_idx) return TRUE;
2256 if (ma_ptr->ap_r_idx < mb_ptr->ap_r_idx) return FALSE;
2259 /* An object get higher priority */
2260 if (cave[y[a]][x[a]].o_idx && !cave[y[b]][x[b]].o_idx) return TRUE;
2261 if (!cave[y[a]][x[a]].o_idx && cave[y[b]][x[b]].o_idx) return FALSE;
2263 /* Priority from the terrain */
2264 if (f_info[ca_ptr->feat].priority > f_info[cb_ptr->feat].priority) return TRUE;
2265 if (f_info[ca_ptr->feat].priority < f_info[cb_ptr->feat].priority) return FALSE;
2267 /* If all conditions are same, compare distance */
2268 return ang_sort_comp_distance(u, v, a, b);
2273 * Sorting hook -- swap function -- by "distance to player"
2275 * We use "u" and "v" to point to arrays of "x" and "y" positions,
2276 * and sort the arrays by distance to the player.
2278 static void ang_sort_swap_distance(vptr u, vptr v, int a, int b)
2280 POSITION *x = (POSITION*)(u);
2281 POSITION *y = (POSITION*)(v);
2299 * Hack -- help "select" a location (see below)
2301 static POSITION_IDX target_pick(POSITION y1, POSITION x1, POSITION dy, POSITION dx)
2304 POSITION x2, y2, x3, y3, x4, y4;
2305 POSITION_IDX b_i = -1, b_v = 9999;
2308 /* Scan the locations */
2309 for (i = 0; i < temp_n; i++)
2315 /* Directed distance */
2319 /* Verify quadrant */
2320 if (dx && (x3 * dx <= 0)) continue;
2321 if (dy && (y3 * dy <= 0)) continue;
2323 /* Absolute distance */
2327 /* Verify quadrant */
2328 if (dy && !dx && (x4 > y4)) continue;
2329 if (dx && !dy && (y4 > x4)) continue;
2331 /* Approximate Double Distance */
2332 v = ((x4 > y4) ? (x4 + x4 + y4) : (y4 + y4 + x4));
2334 /* Penalize location */
2337 if ((b_i >= 0) && (v >= b_v)) continue;
2347 * Hack -- determine if a given location is "interesting"
2349 static bool target_set_accept(POSITION y, POSITION x)
2352 OBJECT_IDX this_o_idx, next_o_idx = 0;
2355 if (!(in_bounds(y, x))) return (FALSE);
2357 /* Player grid is always interesting */
2358 if (player_bold(y, x)) return (TRUE);
2360 /* Handle hallucination */
2361 if (p_ptr->image) return (FALSE);
2363 /* Examine the grid */
2364 c_ptr = &cave[y][x];
2366 /* Visible monsters */
2369 monster_type *m_ptr = &m_list[c_ptr->m_idx];
2371 /* Visible monsters */
2372 if (m_ptr->ml) return (TRUE);
2375 /* Scan all objects in the grid */
2376 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
2379 o_ptr = &o_list[this_o_idx];
2381 /* Acquire next object */
2382 next_o_idx = o_ptr->next_o_idx;
2384 /* Memorized object */
2385 if (o_ptr->marked & OM_FOUND) return (TRUE);
2388 /* Interesting memorized features */
2389 if (c_ptr->info & (CAVE_MARK))
2391 /* Notice object features */
2392 if (c_ptr->info & CAVE_OBJECT) return (TRUE);
2394 /* Feature code (applying "mimic" field) */
2395 if (have_flag(f_info[get_feat_mimic(c_ptr)].flags, FF_NOTICE)) return TRUE;
2403 * Prepare the "temp" array for "target_set"
2405 * Return the number of target_able monsters in the set.
2407 static void target_set_prepare(BIT_FLAGS mode)
2410 POSITION min_hgt, max_hgt, min_wid, max_wid;
2412 if (mode & TARGET_KILL)
2415 min_hgt = MAX((p_ptr->y - MAX_RANGE), 0);
2416 max_hgt = MIN((p_ptr->y + MAX_RANGE), cur_hgt - 1);
2417 min_wid = MAX((p_ptr->x - MAX_RANGE), 0);
2418 max_wid = MIN((p_ptr->x + MAX_RANGE), cur_wid - 1);
2420 else /* not targetting */
2423 min_hgt = panel_row_min;
2424 max_hgt = panel_row_max;
2425 min_wid = panel_col_min;
2426 max_wid = panel_col_max;
2429 /* Reset "temp" array */
2432 /* Scan the current panel */
2433 for (y = min_hgt; y <= max_hgt; y++)
2435 for (x = min_wid; x <= max_wid; x++)
2439 /* Require "interesting" contents */
2440 if (!target_set_accept(y, x)) continue;
2442 c_ptr = &cave[y][x];
2444 /* Require target_able monsters for "TARGET_KILL" */
2445 if ((mode & (TARGET_KILL)) && !target_able(c_ptr->m_idx)) continue;
2447 if ((mode & (TARGET_KILL)) && !target_pet && is_pet(&m_list[c_ptr->m_idx])) continue;
2449 /* Save the location */
2456 /* Set the sort hooks */
2457 if (mode & (TARGET_KILL))
2459 /* Target the nearest monster for shooting */
2460 ang_sort_comp = ang_sort_comp_distance;
2461 ang_sort_swap = ang_sort_swap_distance;
2465 /* Look important grids first in Look command */
2466 ang_sort_comp = ang_sort_comp_importance;
2467 ang_sort_swap = ang_sort_swap_distance;
2470 /* Sort the positions */
2471 ang_sort(temp_x, temp_y, temp_n);
2473 if (p_ptr->riding && target_pet && (temp_n > 1) && (mode & (TARGET_KILL)))
2478 temp_y[0] = temp_y[1];
2481 temp_x[0] = temp_x[1];
2486 void target_set_prepare_look(void){
2487 target_set_prepare(TARGET_LOOK);
2492 * Evaluate number of kill needed to gain level
2494 static void evaluate_monster_exp(char *buf, monster_type *m_ptr)
2496 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
2498 s32b exp_mon, exp_adv;
2499 u32b exp_mon_frac, exp_adv_frac;
2501 if ((p_ptr->lev >= PY_MAX_LEVEL) || (p_ptr->prace == RACE_ANDROID))
2506 else if (!ap_r_ptr->r_tkills || (m_ptr->mflag2 & MFLAG2_KAGE))
2516 /* The monster's experience point (assuming average monster speed) */
2517 exp_mon = ap_r_ptr->mexp * ap_r_ptr->level;
2519 s64b_div(&exp_mon, &exp_mon_frac, 0, (p_ptr->max_plv + 2));
2522 /* Total experience value for next level */
2523 exp_adv = player_exp[p_ptr->lev -1] * p_ptr->expfact;
2525 s64b_div(&exp_adv, &exp_adv_frac, 0, 100);
2527 /* Experience value need to get */
2528 s64b_sub(&exp_adv, &exp_adv_frac, p_ptr->exp, p_ptr->exp_frac);
2531 /* You need to kill at least one monster to get any experience */
2532 s64b_add(&exp_adv, &exp_adv_frac, exp_mon, exp_mon_frac);
2533 s64b_sub(&exp_adv, &exp_adv_frac, 0, 1);
2535 /* Extract number of monsters needed */
2536 s64b_div(&exp_adv, &exp_adv_frac, exp_mon, exp_mon_frac);
2538 /* If 999 or more monsters needed, only display "999". */
2539 num = MIN(999, exp_adv_frac);
2541 /* Display the number */
2542 sprintf(buf,"%03ld", (long int)num);
2546 bool show_gold_on_floor = FALSE;
2549 * Examine a grid, return a keypress.
2551 * The "mode" argument contains the "TARGET_LOOK" bit flag, which
2552 * indicates that the "space" key should scan through the contents
2553 * of the grid, instead of simply returning immediately. This lets
2554 * the "look" command get complete information, without making the
2555 * "target" command annoying.
2557 * The "info" argument contains the "commands" which should be shown
2558 * inside the "[xxx]" text. This string must never be empty, or grids
2559 * containing monsters will be displayed with an extra comma.
2561 * Note that if a monster is in the grid, we update both the monster
2562 * recall info and the health bar info to track that monster.
2564 * Eventually, we may allow multiple objects per grid, or objects
2565 * and terrain features in the same grid.
2567 * This function must handle blindness/hallucination.
2569 static char target_set_aux(POSITION y, POSITION x, BIT_FLAGS mode, concptr info)
2571 cave_type *c_ptr = &cave[y][x];
2572 OBJECT_IDX this_o_idx, next_o_idx = 0;
2573 concptr s1 = "", s2 = "", s3 = "", x_info = "";
2576 feature_type *f_ptr;
2577 char query = '\001';
2578 char out_val[MAX_NLEN+80];
2579 OBJECT_IDX floor_list[23];
2580 ITEM_NUMBER floor_num = 0;
2582 /* Scan all objects in the grid */
2585 floor_num = scan_floor(floor_list, y, x, 0x02);
2589 x_info = _("x物 ", "x,");
2593 /* Hack -- under the player */
2594 if (player_bold(y, x))
2607 s1 = _("ターゲット:", "Target:");
2610 /* Hack -- hallucination */
2613 concptr name = _("何か奇妙な物", "something strange");
2615 /* Display a message */
2617 sprintf(out_val, "%s%s%s%s [%s]", s1, name, s2, s3, info);
2619 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, name, info);
2623 move_cursor_relative(y, x);
2626 /* Stop on everything but "return" */
2627 if ((query != '\r') && (query != '\n')) return query;
2629 /* Repeat forever */
2634 /* Actual monsters */
2635 if (c_ptr->m_idx && m_list[c_ptr->m_idx].ml)
2637 monster_type *m_ptr = &m_list[c_ptr->m_idx];
2638 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
2639 GAME_TEXT m_name[MAX_NLEN];
2640 bool recall = FALSE;
2645 monster_desc(m_name, m_ptr, MD_INDEF_VISIBLE);
2646 monster_race_track(m_ptr->ap_r_idx);
2647 health_track(c_ptr->m_idx);
2660 /* Recall on screen */
2661 screen_roff(m_ptr->ap_r_idx, 0);
2663 /* Hack -- Complete the prompt (again) */
2664 Term_addstr(-1, TERM_WHITE, format(_(" [r思 %s%s]", " [r,%s%s]"), x_info, info));
2671 /* Normal commands */
2672 if (query != 'r') break;
2677 /* Cleare recall text and repeat */
2683 /* Describe, and prompt for recall */
2684 evaluate_monster_exp(acount, m_ptr);
2687 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);
2689 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);
2695 move_cursor_relative(y, x);
2700 /* Normal commands */
2701 if (query != 'r') break;
2707 /* Always stop at "normal" keys */
2708 if ((query != '\r') && (query != '\n') && (query != ' ') && (query != 'x')) return query;
2710 /* Sometimes stop at "space" key */
2711 if ((query == ' ') && !(mode & (TARGET_LOOK))) return query;
2713 /* Change the intro */
2714 s1 = _("それは", "It is ");
2716 /* Hack -- take account of gender */
2717 if (ap_r_ptr->flags1 & (RF1_FEMALE)) s1 = _("彼女は", "She is ");
2718 else if (ap_r_ptr->flags1 & (RF1_MALE)) s1 = _("彼は", "He is ");
2720 /* Use a preposition */
2729 /* Scan all objects being carried */
2730 for (this_o_idx = m_ptr->hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
2732 GAME_TEXT o_name[MAX_NLEN];
2735 o_ptr = &o_list[this_o_idx];
2737 /* Acquire next object */
2738 next_o_idx = o_ptr->next_o_idx;
2740 /* Obtain an object description */
2741 object_desc(o_name, o_ptr, 0);
2744 sprintf(out_val, "%s%s%s%s[%s]", s1, o_name, s2, s3, info);
2746 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, o_name, info);
2750 move_cursor_relative(y, x);
2753 /* Always stop at "normal" keys */
2754 if ((query != '\r') && (query != '\n') && (query != ' ') && (query != 'x')) return query;
2756 /* Sometimes stop at "space" key */
2757 if ((query == ' ') && !(mode & (TARGET_LOOK))) return query;
2759 /* Change the intro */
2760 s2 = _("をまた", "also carrying ");
2763 /* Use a preposition */
2780 GAME_TEXT o_name[MAX_NLEN];
2783 o_ptr = &o_list[floor_list[0]];
2785 object_desc(o_name, o_ptr, 0);
2788 sprintf(out_val, "%s%s%s%s[%s]", s1, o_name, s2, s3, info);
2790 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, o_name, info);
2794 move_cursor_relative(y, x);
2803 /* Provide one cushion before item listing */
2806 /* Display rough information about items */
2808 sprintf(out_val, "%s %d個のアイテム%s%s ['x'で一覧, %s]", s1, (int)floor_num, s2, s3, info);
2810 sprintf(out_val, "%s%s%sa pile of %d items [x,%s]", s1, s2, s3, (int)floor_num, info);
2814 move_cursor_relative(y, x);
2819 /* No request for listing */
2820 if (query != 'x' && query != ' ') return query;
2824 /** Display list of items **/
2826 /* Continue scrolling list if requested */
2834 show_gold_on_floor = TRUE;
2835 (void)show_floor(0, y, x, &min_width);
2836 show_gold_on_floor = FALSE;
2840 sprintf(out_val, "%s %d個のアイテム%s%s [Enterで次へ, %s]", s1, (int)floor_num, s2, s3, info);
2842 sprintf(out_val, "%s%s%sa pile of %d items [Enter,%s]", s1, s2, s3, (int)floor_num, info);
2849 /* Exit unless 'Enter' */
2850 if (query != '\n' && query != '\r')
2855 /* Get the object being moved. */
2856 o_idx = c_ptr->o_idx;
2858 /* Only rotate a pile of two or more objects. */
2859 if (!(o_idx && o_list[o_idx].next_o_idx)) continue;
2861 /* Remove the first object from the list. */
2862 excise_object_idx(o_idx);
2864 /* Find end of the list. */
2866 while (o_list[i].next_o_idx)
2867 i = o_list[i].next_o_idx;
2869 /* Add after the last object. */
2870 o_list[i].next_o_idx = o_idx;
2872 /* Loop and re-display the list */
2879 /* Scan all objects in the grid */
2880 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
2883 o_ptr = &o_list[this_o_idx];
2885 /* Acquire next object */
2886 next_o_idx = o_ptr->next_o_idx;
2888 if (o_ptr->marked & OM_FOUND)
2890 GAME_TEXT o_name[MAX_NLEN];
2895 /* Obtain an object description */
2896 object_desc(o_name, o_ptr, 0);
2899 sprintf(out_val, "%s%s%s%s[%s]", s1, o_name, s2, s3, info);
2901 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, o_name, info);
2905 move_cursor_relative(y, x);
2908 /* Always stop at "normal" keys */
2909 if ((query != '\r') && (query != '\n') && (query != ' ') && (query != 'x')) return query;
2911 /* Sometimes stop at "space" key */
2912 if ((query == ' ') && !(mode & TARGET_LOOK)) return query;
2914 /* Change the intro */
2915 s1 = _("それは", "It is ");
2918 if (o_ptr->number != 1) s1 = _("それらは", "They are ");
2932 /* Feature code (applying "mimic" field) */
2933 feat = get_feat_mimic(c_ptr);
2935 /* Require knowledge about grid, or ability to see grid */
2936 if (!(c_ptr->info & CAVE_MARK) && !player_can_see_bold(y, x))
2938 /* Forget feature */
2942 f_ptr = &f_info[feat];
2944 /* Terrain feature if needed */
2945 if (boring || have_flag(f_ptr->flags, FF_REMEMBER))
2949 /* Hack -- special handling for quest entrances */
2950 if (have_flag(f_ptr->flags, FF_QUEST_ENTER))
2952 /* Set the quest number temporary */
2953 IDX old_quest = p_ptr->inside_quest;
2956 /* Clear the text */
2957 for (j = 0; j < 10; j++) quest_text[j][0] = '\0';
2958 quest_text_line = 0;
2960 p_ptr->inside_quest = c_ptr->special;
2962 /* Get the quest text */
2963 init_flags = INIT_NAME_ONLY;
2965 process_dungeon_file("q_info.txt", 0, 0, 0, 0);
2967 name = format(_("クエスト「%s」(%d階相当)", "the entrance to the quest '%s'(level %d)"),
2968 quest[c_ptr->special].name, quest[c_ptr->special].level);
2970 /* Reset the old quest number */
2971 p_ptr->inside_quest = old_quest;
2974 /* Hack -- special handling for building doors */
2975 else if (have_flag(f_ptr->flags, FF_BLDG) && !p_ptr->inside_arena)
2977 name = building[f_ptr->subtype].name;
2979 else if (have_flag(f_ptr->flags, FF_ENTRANCE))
2981 name = format(_("%s(%d階相当)", "%s(level %d)"), d_text + d_info[c_ptr->special].text, d_info[c_ptr->special].mindepth);
2983 else if (have_flag(f_ptr->flags, FF_TOWN))
2985 name = town[c_ptr->special].name;
2987 else if (p_ptr->wild_mode && (feat == feat_floor))
2989 name = _("道", "road");
2993 name = f_name + f_ptr->name;
2999 ((!have_flag(f_ptr->flags, FF_MOVE) && !have_flag(f_ptr->flags, FF_CAN_FLY)) ||
3000 (!have_flag(f_ptr->flags, FF_LOS) && !have_flag(f_ptr->flags, FF_TREE)) ||
3001 have_flag(f_ptr->flags, FF_TOWN)))
3003 s2 = _("の中", "in ");
3006 /* Hack -- special introduction for store & building doors -KMW- */
3007 if (have_flag(f_ptr->flags, FF_STORE) ||
3008 have_flag(f_ptr->flags, FF_QUEST_ENTER) ||
3009 (have_flag(f_ptr->flags, FF_BLDG) && !p_ptr->inside_arena) ||
3010 have_flag(f_ptr->flags, FF_ENTRANCE))
3015 else if (have_flag(f_ptr->flags, FF_FLOOR) ||
3016 have_flag(f_ptr->flags, FF_TOWN) ||
3017 have_flag(f_ptr->flags, FF_SHALLOW) ||
3018 have_flag(f_ptr->flags, FF_DEEP))
3024 /* Pick proper indefinite article */
3025 s3 = (is_a_vowel(name[0])) ? "an " : "a ";
3029 /* Display a message */
3033 if (c_ptr->mimic) sprintf(f_idx_str, "%d/%d", c_ptr->feat, c_ptr->mimic);
3034 else sprintf(f_idx_str, "%d", c_ptr->feat);
3036 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]);
3038 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);
3043 sprintf(out_val, "%s%s%s%s[%s]", s1, name, s2, s3, info);
3045 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, name, info);
3049 move_cursor_relative(y, x);
3052 /* Always stop at "normal" keys */
3053 if ((query != '\r') && (query != '\n') && (query != ' ')) return query;
3056 /* Stop on everything but "return" */
3057 if ((query != '\r') && (query != '\n')) return query;
3059 /* Repeat forever */
3065 * Handle "target" and "look".
3067 * Note that this code can be called from "get_aim_dir()".
3069 * All locations must be on the current panel. Consider the use of
3070 * "panel_bounds()" to allow "off-panel" targets, perhaps by using
3071 * some form of "scrolling" the map around the cursor.
3072 * That is, consider the possibility of "auto-scrolling" the screen
3073 * while the cursor moves around. This may require changes in the
3074 * "update_monster()" code to allow "visibility" even if off panel, and
3075 * may require dynamic recalculation of the "temp" grid set.
3077 * Hack -- targeting/observing an "outer border grid" may induce
3078 * problems, so this is not currently allowed.
3080 * The player can use the direction keys to move among "interesting"
3081 * grids in a heuristic manner, or the "space", "+", and "-" keys to
3082 * move through the "interesting" grids in a sequential manner, or
3083 * can enter "location" mode, and use the direction keys to move one
3084 * grid at a time in any direction. The "t" (set target) command will
3085 * only target a monster (as opposed to a location) if the monster is
3086 * target_able and the "interesting" mode is being used.
3088 * The current grid is described using the "look" method above, and
3089 * a new command may be entered at any time, but note that if the
3090 * "TARGET_LOOK" bit flag is set (or if we are in "location" mode,
3091 * where "space" has no obvious meaning) then "space" will scan
3092 * through the description of the current grid until done, instead
3093 * of immediately jumping to the next "interesting" grid. This
3094 * allows the "target" command to retain its old semantics.
3096 * The "*", "+", and "-" keys may always be used to jump immediately
3097 * to the next (or previous) interesting grid, in the proper mode.
3099 * The "return" key may always be used to scan through a complete
3100 * grid description (forever).
3102 * This command will cancel any old target, even if used from
3103 * inside the "look" command.
3105 bool target_set(BIT_FLAGS mode)
3108 POSITION y = p_ptr->y;
3109 POSITION x = p_ptr->x;
3119 get_screen_size(&wid, &hgt);
3124 if (rogue_like_commands)
3133 /* Prepare the "temp" array */
3134 target_set_prepare(mode);
3136 /* Start near the player */
3142 /* Interesting grids */
3149 change_panel_xy(y, x);
3151 if (!(mode & TARGET_LOOK)) prt_path(y, x);
3154 c_ptr = &cave[y][x];
3157 if (target_able(c_ptr->m_idx))
3159 strcpy(info, _("q止 t決 p自 o現 +次 -前", "q,t,p,o,+,-,<dir>"));
3162 /* Dis-allow target */
3165 strcpy(info, _("q止 p自 o現 +次 -前", "q,p,o,+,-,<dir>"));
3171 sprintf(cheatinfo, " LOS:%d, PROJECTABLE:%d",
3172 los(p_ptr->y, p_ptr->x, y, x), projectable(p_ptr->y, p_ptr->x, y, x));
3173 strcat(info, cheatinfo);
3176 /* Describe and Prompt */
3178 query = target_set_aux(y, x, mode, info);
3182 /* Assume no "direction" */
3187 if (query == '\r') query = 't';
3205 if (target_able(c_ptr->m_idx))
3207 health_track(c_ptr->m_idx);
3208 target_who = c_ptr->m_idx;
3227 if (!expand_list) done = TRUE;
3237 if (!expand_list) done = TRUE;
3244 /* Recenter the map around the player */
3246 p_ptr->update |= (PU_MONSTERS);
3247 p_ptr->redraw |= (PR_MAP);
3248 p_ptr->window |= (PW_OVERHEAD);
3251 /* Recalculate interesting grids */
3252 target_set_prepare(mode);
3271 if(query == same_key)
3276 if (!expand_list) done = TRUE;
3281 /* Extract the action (if any) */
3282 d = get_keymap_dir(query);
3289 /* Hack -- move around */
3292 /* Modified to scroll to monster */
3293 POSITION y2 = panel_row_min;
3294 POSITION x2 = panel_col_min;
3296 /* Find a new monster */
3297 i = target_pick(temp_y[m], temp_x[m], ddy[d], ddx[d]);
3299 /* Request to target past last interesting grid */
3300 while (flag && (i < 0))
3302 /* Note the change */
3303 if (change_panel(ddy[d], ddx[d]))
3308 /* Recalculate interesting grids */
3309 target_set_prepare(mode);
3311 /* Look at interesting grids */
3314 /* Find a new monster */
3315 i = target_pick(v, u, ddy[d], ddx[d]);
3321 /* Nothing interesting */
3324 POSITION dx = ddx[d];
3325 POSITION dy = ddy[d];
3327 /* Restore previous position */
3330 panel_bounds_center();
3332 p_ptr->update |= (PU_MONSTERS);
3333 p_ptr->redraw |= (PR_MAP);
3334 p_ptr->window |= (PW_OVERHEAD);
3337 /* Recalculate interesting grids */
3338 target_set_prepare(mode);
3340 /* Look at boring grids */
3347 /* Do not move horizontally if unnecessary */
3348 if (((x < panel_col_min + wid / 2) && (dx > 0)) ||
3349 ((x > panel_col_min + wid / 2) && (dx < 0)))
3354 /* Do not move vertically if unnecessary */
3355 if (((y < panel_row_min + hgt / 2) && (dy > 0)) ||
3356 ((y > panel_row_min + hgt / 2) && (dy < 0)))
3361 /* Apply the motion */
3362 if ((y >= panel_row_min+hgt) || (y < panel_row_min) ||
3363 (x >= panel_col_min+wid) || (x < panel_col_min))
3365 if (change_panel(dy, dx)) target_set_prepare(mode);
3368 /* Slide into legality */
3369 if (x >= cur_wid-1) x = cur_wid - 2;
3370 else if (x <= 0) x = 1;
3372 /* Slide into legality */
3373 if (y >= cur_hgt-1) y = cur_hgt- 2;
3374 else if (y <= 0) y = 1;
3383 /* Arbitrary grids */
3386 bool move_fast = FALSE;
3388 if (!(mode & TARGET_LOOK)) prt_path(y, x);
3391 c_ptr = &cave[y][x];
3393 /* Default prompt */
3394 strcpy(info, _("q止 t決 p自 m近 +次 -前", "q,t,p,m,+,-,<dir>"));
3399 sprintf(cheatinfo, " LOS:%d, PROJECTABLE:%d",
3400 los(p_ptr->y, p_ptr->x, y, x),
3401 projectable(p_ptr->y, p_ptr->x, y, x));
3402 strcat(info, cheatinfo);
3405 /* Describe and Prompt (enable "TARGET_LOOK") */
3406 while ((query = target_set_aux(y, x, mode | TARGET_LOOK, info)) == 0);
3408 /* Assume no direction */
3413 if (query == '\r') query = 't';
3416 /* Analyze the keypress */
3440 /* Recenter the map around the player */
3442 p_ptr->update |= (PU_MONSTERS);
3443 p_ptr->redraw |= (PR_MAP);
3444 p_ptr->window |= (PW_OVERHEAD);
3447 /* Recalculate interesting grids */
3448 target_set_prepare(mode);
3470 /* Pick a nearby monster */
3471 for (i = 0; i < temp_n; i++)
3473 t = distance(y, x, temp_y[i], temp_x[i]);
3483 /* Nothing interesting */
3484 if (bd == 999) flag = FALSE;
3491 /* Extract the action (if any) */
3492 d = get_keymap_dir(query);
3494 /* XTRA HACK MOVEFAST */
3495 if (isupper(query)) move_fast = TRUE;
3502 /* Handle "direction" */
3505 POSITION dx = ddx[d];
3506 POSITION dy = ddy[d];
3508 /* XTRA HACK MOVEFAST */
3511 int mag = MIN(wid / 2, hgt / 2);
3521 /* Do not move horizontally if unnecessary */
3522 if (((x < panel_col_min + wid / 2) && (dx > 0)) ||
3523 ((x > panel_col_min + wid / 2) && (dx < 0)))
3528 /* Do not move vertically if unnecessary */
3529 if (((y < panel_row_min + hgt / 2) && (dy > 0)) ||
3530 ((y > panel_row_min + hgt / 2) && (dy < 0)))
3535 /* Apply the motion */
3536 if ((y >= panel_row_min + hgt) || (y < panel_row_min) ||
3537 (x >= panel_col_min + wid) || (x < panel_col_min))
3539 if (change_panel(dy, dx)) target_set_prepare(mode);
3542 /* Slide into legality */
3543 if (x >= cur_wid-1) x = cur_wid - 2;
3544 else if (x <= 0) x = 1;
3546 /* Slide into legality */
3547 if (y >= cur_hgt-1) y = cur_hgt- 2;
3548 else if (y <= 0) y = 1;
3556 /* Clear the top line */
3559 /* Recenter the map around the player */
3561 p_ptr->update |= (PU_MONSTERS);
3562 p_ptr->redraw |= (PR_MAP);
3563 p_ptr->window |= (PW_OVERHEAD);
3566 /* Failure to set target */
3567 if (!target_who) return (FALSE);
3575 * Get an "aiming direction" from the user.
3577 * The "dir" is loaded with 1,2,3,4,6,7,8,9 for "actual direction", and
3578 * "0" for "current target", and "-1" for "entry aborted".
3580 * Note that "Force Target", if set, will pre-empt user interaction,
3581 * if there is a usable target already set.
3583 * Note that confusion over-rides any (explicit?) user choice.
3585 bool get_aim_dir(DIRECTION *dp)
3594 /* Global direction */
3597 /* Hack -- auto-target if requested */
3598 if (use_old_target && target_okay()) dir = 5;
3600 if (repeat_pull(&code))
3605 if (!(code == 5 && !target_okay()))
3607 /* return (TRUE); */
3608 dir = (DIRECTION)code;
3611 *dp = (DIRECTION)code;
3613 /* Ask until satisfied */
3616 /* Choose a prompt */
3619 p = _("方向 ('*'でターゲット選択, ESCで中断)? ", "Direction ('*' to choose a target, Escape to cancel)? ");
3623 p = _("方向 ('5'でターゲットへ, '*'でターゲット再選択, ESCで中断)? ", "Direction ('5' for target, '*' to re-target, Escape to cancel)? ");
3626 /* Get a command (or Cancel) */
3627 if (!get_com(p, &command, TRUE)) break;
3631 if (command == '\r') command = 't';
3634 /* Convert various keys to "standard" keys */
3637 /* Use current target */
3648 /* Set new target */
3653 if (target_set(TARGET_KILL)) dir = 5;
3659 /* Extract the action (if any) */
3660 dir = get_keymap_dir(command);
3666 /* Verify requested targets */
3667 if ((dir == 5) && !target_okay()) dir = 0;
3676 project_length = 0; /* reset to default */
3680 /* Save the direction */
3683 /* Check for confusion */
3684 if (p_ptr->confused)
3686 /* Random direction */
3687 dir = ddd[randint0(8)];
3690 /* Notice confusion */
3691 if (command_dir != dir)
3694 msg_print(_("あなたは混乱している。", "You are confused."));
3697 /* Save direction */
3700 /* repeat_push(dir); */
3701 repeat_push((COMMAND_CODE)command_dir);
3703 /* A "valid" direction was entered */
3708 bool get_direction(DIRECTION *dp, bool allow_under, bool with_steed)
3716 /* Global direction */
3719 if (repeat_pull(&code))
3721 dir = (DIRECTION)code;
3722 /* return (TRUE); */
3724 *dp = (DIRECTION)code;
3728 prompt = _("方向 ('.'足元, ESCで中断)? ", "Direction ('.' at feet, Escape to cancel)? ");
3732 prompt = _("方向 (ESCで中断)? ", "Direction (Escape to cancel)? ");
3735 /* Get a direction */
3740 /* Get a command (or Cancel) */
3741 if (!get_com(prompt, &ch, TRUE)) break;
3744 if ((allow_under) && ((ch == '5') || (ch == '-') || (ch == '.')))
3750 /* Look up the direction */
3751 dir = get_keymap_dir(ch);
3757 /* Prevent weirdness */
3758 if ((dir == 5) && (!allow_under)) dir = 0;
3761 if (!dir) return (FALSE);
3763 /* Save desired direction */
3766 /* Apply "confusion" */
3767 if (p_ptr->confused)
3769 /* Standard confusion */
3770 if (randint0(100) < 75)
3772 /* Random direction */
3773 dir = ddd[randint0(8)];
3776 else if (p_ptr->riding && with_steed)
3778 monster_type *m_ptr = &m_list[p_ptr->riding];
3779 monster_race *r_ptr = &r_info[m_ptr->r_idx];
3781 if (MON_CONFUSED(m_ptr))
3783 /* Standard confusion */
3784 if (randint0(100) < 75)
3786 /* Random direction */
3787 dir = ddd[randint0(8)];
3790 else if ((r_ptr->flags1 & RF1_RAND_50) && (r_ptr->flags1 & RF1_RAND_25) && (randint0(100) < 50))
3792 /* Random direction */
3793 dir = ddd[randint0(8)];
3795 else if ((r_ptr->flags1 & RF1_RAND_50) && (randint0(100) < 25))
3797 /* Random direction */
3798 dir = ddd[randint0(8)];
3802 /* Notice confusion */
3803 if (command_dir != dir)
3805 if (p_ptr->confused)
3808 msg_print(_("あなたは混乱している。", "You are confused."));
3812 GAME_TEXT m_name[MAX_NLEN];
3813 monster_type *m_ptr = &m_list[p_ptr->riding];
3815 monster_desc(m_name, m_ptr, 0);
3816 if (MON_CONFUSED(m_ptr))
3818 msg_format(_("%sは混乱している。", "%^s is confusing."), m_name);
3822 msg_format(_("%sは思い通りに動いてくれない。", "You cannot control %s."), m_name);
3827 /* Save direction */
3830 /* repeat_push(dir); */
3831 repeat_push((COMMAND_CODE)command_dir);
3838 * @brief 進行方向を指定する(騎乗対象の混乱の影響を受ける) / Request a "movement" direction (1,2,3,4,6,7,8,9) from the user,
3839 * and place it into "command_dir", unless we already have one.
3841 * This function should be used for all "repeatable" commands, such as
3842 * run, walk, open, close, bash, disarm, spike, tunnel, etc, as well
3843 * as all commands which must reference a grid adjacent to the player,
3844 * and which may not reference the grid under the player. Note that,
3845 * for example, it is no longer possible to "disarm" or "open" chests
3846 * in the same grid as the player.
3848 * Direction "5" is illegal and will (cleanly) abort the command.
3850 * This function tracks and uses the "global direction", and uses
3851 * that as the "desired direction", to which "confusion" is applied.
3853 bool get_rep_dir(DIRECTION *dp, bool under)
3861 /* Global direction */
3864 if (repeat_pull(&code))
3866 dir = (DIRECTION)code;
3867 /* return (TRUE); */
3869 *dp = (DIRECTION)code;
3873 prompt = _("方向 ('.'足元, ESCで中断)? ", "Direction ('.' at feet, Escape to cancel)? ");
3877 prompt = _("方向 (ESCで中断)? ", "Direction (Escape to cancel)? ");
3880 /* Get a direction */
3885 /* Get a command (or Cancel) */
3886 if (!get_com(prompt, &ch, TRUE)) break;
3889 if ((under) && ((ch == '5') || (ch == '-') || (ch == '.')))
3895 /* Look up the direction */
3896 dir = get_keymap_dir(ch);
3902 /* Prevent weirdness */
3903 if ((dir == 5) && (!under)) dir = 0;
3906 if (!dir) return (FALSE);
3908 /* Save desired direction */
3911 /* Apply "confusion" */
3912 if (p_ptr->confused)
3914 /* Standard confusion */
3915 if (randint0(100) < 75)
3917 /* Random direction */
3918 dir = ddd[randint0(8)];
3921 else if (p_ptr->riding)
3923 monster_type *m_ptr = &m_list[p_ptr->riding];
3924 monster_race *r_ptr = &r_info[m_ptr->r_idx];
3926 if (MON_CONFUSED(m_ptr))
3928 /* Standard confusion */
3929 if (randint0(100) < 75)
3931 /* Random direction */
3932 dir = ddd[randint0(8)];
3935 else if ((r_ptr->flags1 & RF1_RAND_50) && (r_ptr->flags1 & RF1_RAND_25) && (randint0(100) < 50))
3937 /* Random direction */
3938 dir = ddd[randint0(8)];
3940 else if ((r_ptr->flags1 & RF1_RAND_50) && (randint0(100) < 25))
3942 /* Random direction */
3943 dir = ddd[randint0(8)];
3947 /* Notice confusion */
3948 if (command_dir != dir)
3950 if (p_ptr->confused)
3953 msg_print(_("あなたは混乱している。", "You are confused."));
3957 GAME_TEXT m_name[MAX_NLEN];
3958 monster_type *m_ptr = &m_list[p_ptr->riding];
3960 monster_desc(m_name, m_ptr, 0);
3961 if (MON_CONFUSED(m_ptr))
3963 msg_format(_("%sは混乱している。", "%^s is confusing."), m_name);
3967 msg_format(_("%sは思い通りに動いてくれない。", "You cannot control %s."), m_name);
3972 /* Save direction */
3975 /* repeat_push(dir); */
3976 repeat_push((COMMAND_CODE)command_dir);
3982 void gain_level_reward(int chosen_reward)
3986 char wrath_reason[32] = "";
3987 int nasty_chance = 6;
3988 OBJECT_TYPE_VALUE dummy = 0;
3989 OBJECT_SUBTYPE_VALUE dummy2 = 0;
3991 concptr reward = NULL;
3992 GAME_TEXT o_name[MAX_NLEN];
3998 if (multi_rew) return;
3999 else multi_rew = TRUE;
4003 if (p_ptr->lev == 13) nasty_chance = 2;
4004 else if (!(p_ptr->lev % 13)) nasty_chance = 3;
4005 else if (!(p_ptr->lev % 14)) nasty_chance = 12;
4007 if (one_in_(nasty_chance))
4008 type = randint1(20); /* Allow the 'nasty' effects */
4010 type = randint1(15) + 5; /* Or disallow them */
4012 if (type < 1) type = 1;
4013 if (type > 20) type = 20;
4017 sprintf(wrath_reason, _("%sの怒り", "the Wrath of %s"), chaos_patrons[p_ptr->chaos_patron]);
4019 effect = chaos_rewards[p_ptr->chaos_patron][type];
4021 if (one_in_(6) && !chosen_reward)
4023 msg_format(_("%^sは褒美としてあなたを突然変異させた。", "%^s rewards you with a mutation!"), chaos_patrons[p_ptr->chaos_patron]);
4024 (void)gain_random_mutation(0);
4025 reward = _("変異した。", "mutation");
4029 switch (chosen_reward ? chosen_reward : effect)
4034 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4035 msg_print(_("「汝、新たなる姿を必要とせり!」", "'Thou needst a new form, mortal!'"));
4038 reward = _("変異した。", "polymorphing");
4043 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4044 msg_print(_("「汝は良く行いたり!続けよ!」", "'Well done, mortal! Lead on!'"));
4046 if (p_ptr->prace == RACE_ANDROID)
4048 msg_print(_("しかし何も起こらなかった。", "But, nothing happen."));
4050 else if (p_ptr->exp < PY_MAX_EXP)
4052 s32b ee = (p_ptr->exp / 2) + 10;
4053 if (ee > 100000L) ee = 100000L;
4054 msg_print(_("更に経験を積んだような気がする。", "You feel more experienced."));
4057 reward = _("経験値を得た", "experience");
4063 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4064 msg_print(_("「下僕よ、汝それに値せず。」", "'Thou didst not deserve that, slave.'"));
4066 if (p_ptr->prace == RACE_ANDROID)
4068 msg_print(_("しかし何も起こらなかった。", "But, nothing happen."));
4072 lose_exp(p_ptr->exp / 6);
4073 reward = _("経験値を失った。", "losing experience");
4079 msg_format("%sの声がささやいた:",
4080 chaos_patrons[p_ptr->chaos_patron]);
4082 msg_format("The voice of %s whispers:",
4083 chaos_patrons[p_ptr->chaos_patron]);
4086 msg_print(_("「我が与えし物を賢明に使うべし。」", "'Use my gift wisely.'"));
4088 acquirement(p_ptr->y, p_ptr->x, 1, FALSE, FALSE, FALSE);
4089 reward = _("上質なアイテムを手に入れた。", "a good item");
4094 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4095 msg_print(_("「我が与えし物を賢明に使うべし。」", "'Use my gift wisely.'"));
4097 acquirement(p_ptr->y, p_ptr->x, 1, TRUE, FALSE, FALSE);
4098 reward = _("高級品のアイテムを手に入れた。", "an excellent item");
4103 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4104 msg_print(_("「汝の行いは貴き剣に値せり。」", "'Thy deed hath earned thee a worthy blade.'"));
4107 switch (randint1(p_ptr->lev))
4113 dummy2 = SV_MAIN_GAUCHE;
4122 dummy2 = SV_SMALL_SWORD;
4125 dummy2 = SV_BASILLARD;
4127 case 11: case 12: case 13:
4128 dummy2 = SV_SHORT_SWORD;
4134 dummy2 = SV_CUTLASS;
4137 dummy2 = SV_WAKIZASHI;
4140 dummy2 = SV_KHOPESH;
4146 dummy2 = SV_BROAD_SWORD;
4149 dummy2 = SV_LONG_SWORD;
4152 dummy2 = SV_SCIMITAR;
4155 dummy2 = SV_NINJATO;
4161 dummy2 = SV_BASTARD_SWORD;
4164 dummy2 = SV_GREAT_SCIMITAR;
4167 dummy2 = SV_CLAYMORE;
4170 dummy2 = SV_ESPADON;
4173 dummy2 = SV_TWO_HANDED_SWORD;
4176 dummy2 = SV_FLAMBERGE;
4179 dummy2 = SV_NO_DACHI;
4182 dummy2 = SV_EXECUTIONERS_SWORD;
4185 dummy2 = SV_ZWEIHANDER;
4188 dummy2 = SV_HAYABUSA;
4191 dummy2 = SV_BLADE_OF_CHAOS;
4194 object_prep(q_ptr, lookup_kind(dummy, dummy2));
4195 q_ptr->to_h = 3 + randint1(dun_level) % 10;
4196 q_ptr->to_d = 3 + randint1(dun_level) % 10;
4197 one_resistance(q_ptr);
4198 q_ptr->name2 = EGO_CHAOTIC;
4199 (void)drop_near(q_ptr, -1, p_ptr->y, p_ptr->x);
4200 reward = _("(混沌)の武器を手に入れた。", "chaos weapon");
4205 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4206 msg_print(_("「汝の行いは貴き報いに値せり。」", "'Thy deed hath earned thee a worthy reward.'"));
4208 acquirement(p_ptr->y, p_ptr->x, randint1(2) + 1, FALSE, FALSE, FALSE);
4209 reward = _("上質なアイテムを手に入れた。", "good items");
4214 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4215 msg_print(_("「下僕よ、汝の献身への我が惜しみ無き報いを見るがよい。」", "'Behold, mortal, how generously I reward thy loyalty.'"));
4217 acquirement(p_ptr->y, p_ptr->x, randint1(2) + 1, TRUE, FALSE, FALSE);
4218 reward = _("高級品のアイテムを手に入れた。", "excellent items");
4223 msg_format("%sの声が轟き渡った:", chaos_patrons[p_ptr->chaos_patron]);
4225 msg_format("The voice of %s thunders:", chaos_patrons[p_ptr->chaos_patron]);
4228 msg_print(_("「下僕よ、汝傲慢なり。」", "'Thou art growing arrogant, mortal.'"));
4230 (void)activate_ty_curse(FALSE, &count);
4231 reward = _("禍々しい呪いをかけられた。", "cursing");
4236 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4237 msg_print(_("「我が下僕たちよ、かの傲慢なる者を倒すべし!」", "'My pets, destroy the arrogant mortal!'"));
4239 for (dummy = 0; dummy < randint1(5) + 1; dummy++)
4241 (void)summon_specific(0, p_ptr->y, p_ptr->x, dun_level, 0, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET), '\0');
4243 reward = _("モンスターを召喚された。", "summoning hostile monsters");
4249 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4250 msg_print(_("「汝、より強き敵を必要とせり!」", "'Thou needst worthier opponents!'"));
4252 activate_hi_summon(p_ptr->y, p_ptr->x, FALSE);
4253 reward = _("モンスターを召喚された。", "summoning many hostile monsters");
4259 msg_format("%sの声が響き渡った:",
4260 chaos_patrons[p_ptr->chaos_patron]);
4262 msg_format("The voice of %s booms out:",
4263 chaos_patrons[p_ptr->chaos_patron]);
4266 msg_print(_("「死と破壊こそ我が喜びなり!」", "'Death and destruction! This pleaseth me!'"));
4269 reward = _("カオスの力が渦巻いた。", "calling chaos");
4275 msg_format("%sの声が鳴り響いた:",
4276 chaos_patrons[p_ptr->chaos_patron]);
4278 msg_format("The voice of %s rings out:",
4279 chaos_patrons[p_ptr->chaos_patron]);
4282 msg_print(_("「留まるのだ、下僕よ。余が汝の肉体を鍛えん。」", "'Stay, mortal, and let me mold thee.'"));
4284 if (one_in_(3) && !(chaos_stats[p_ptr->chaos_patron] < 0))
4285 do_inc_stat(chaos_stats[p_ptr->chaos_patron]);
4287 do_inc_stat(randint0(6));
4288 reward = _("能力値が上がった。", "increasing a stat");
4294 msg_format("%sの声が響き渡った:",
4295 chaos_patrons[p_ptr->chaos_patron]);
4297 msg_format("The voice of %s booms out:",
4298 chaos_patrons[p_ptr->chaos_patron]);
4301 msg_print(_("「下僕よ、余は汝に飽みたり。」", "'I grow tired of thee, mortal.'"));
4303 if (one_in_(3) && !(chaos_stats[p_ptr->chaos_patron] < 0))
4304 do_dec_stat(chaos_stats[p_ptr->chaos_patron]);
4306 (void)do_dec_stat(randint0(6));
4307 reward = _("能力値が下がった。", "decreasing a stat");
4314 msg_format("%sの声が轟き渡った:",
4315 chaos_patrons[p_ptr->chaos_patron]);
4317 msg_format("The voice of %s thunders:",
4318 chaos_patrons[p_ptr->chaos_patron]);
4321 msg_print(_("「汝、謙虚たることを学ぶべし!」", "'Thou needst a lesson in humility, mortal!'"));
4322 msg_print(_("あなたは以前より弱くなった!", "You feel less powerful!"));
4324 for (dummy = 0; dummy < A_MAX; dummy++)
4326 (void)dec_stat(dummy, 10 + randint1(15), TRUE);
4328 reward = _("全能力値が下がった。", "decreasing all stats");
4333 msg_format(_("%sの力が触れるのを感じた。", "You feel the power of %s touch you."),
4334 chaos_patrons[p_ptr->chaos_patron]);
4336 reward = _("傷が変化した。", "polymorphing wounds");
4341 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4343 msg_print(_("「我がささやかなる賜物を受けとるがよい!」", "'Receive this modest gift from me!'"));
4345 for (dummy = 0; dummy < A_MAX; dummy++)
4347 (void)do_inc_stat(dummy);
4349 reward = _("全能力値が上がった。", "increasing all stats");
4354 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4355 msg_print(_("「苦しむがよい、無能な愚か者よ!」", "'Suffer, pathetic fool!'"));
4357 fire_ball(GF_DISINTEGRATE, 0, p_ptr->lev * 4, 4);
4358 take_hit(DAMAGE_NOESCAPE, p_ptr->lev * 4, wrath_reason, -1);
4359 reward = _("分解の球が発生した。", "generating disintegration ball");
4364 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4365 (void)restore_level();
4366 (void)restore_all_status();
4367 (void)true_healing(5000);
4368 reward = _("体力が回復した。", "healing");
4373 if (!buki_motteruka(INVEN_RARM) && !buki_motteruka(INVEN_LARM)) break;
4374 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4375 msg_print(_("「汝、武器に頼ることなかれ。」", "'Thou reliest too much on thy weapon.'"));
4378 if (buki_motteruka(INVEN_LARM))
4381 if (buki_motteruka(INVEN_RARM) && one_in_(2)) dummy = INVEN_RARM;
4383 object_desc(o_name, &inventory[dummy], OD_NAME_ONLY);
4384 (void)curse_weapon(FALSE, dummy);
4385 reward = format(_("%sが破壊された。", "destroying %s"), o_name);
4390 if (!inventory[INVEN_BODY].k_idx) break;
4391 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4392 msg_print(_("「汝、防具に頼ることなかれ。」", "'Thou reliest too much on thine equipment.'"));
4394 object_desc(o_name, &inventory[INVEN_BODY], OD_NAME_ONLY);
4395 (void)curse_armor();
4396 reward = format(_("%sが破壊された。", "destroying %s"), o_name);
4400 msg_format(_("%sの声がささやいた:", "The voice of %s whispers:"), chaos_patrons[p_ptr->chaos_patron]);
4401 msg_print(_("「我を怒りしめた罪を償うべし。」", "'Now thou shalt pay for annoying me.'"));
4403 switch (randint1(4))
4406 (void)activate_ty_curse(FALSE, &count);
4407 reward = _("禍々しい呪いをかけられた。", "cursing");
4410 activate_hi_summon(p_ptr->y, p_ptr->x, FALSE);
4411 reward = _("モンスターを召喚された。", "summoning hostile monsters");
4416 if (!buki_motteruka(INVEN_RARM) && !buki_motteruka(INVEN_LARM)) break;
4418 if (buki_motteruka(INVEN_LARM))
4421 if (buki_motteruka(INVEN_RARM) && one_in_(2)) dummy = INVEN_RARM;
4423 object_desc(o_name, &inventory[dummy], OD_NAME_ONLY);
4424 (void)curse_weapon(FALSE, dummy);
4425 reward = format(_("%sが破壊された。", "destroying %s"), o_name);
4429 if (!inventory[INVEN_BODY].k_idx) break;
4430 object_desc(o_name, &inventory[INVEN_BODY], OD_NAME_ONLY);
4431 (void)curse_armor();
4432 reward = format(_("%sが破壊された。", "destroying %s"), o_name);
4436 for (dummy = 0; dummy < A_MAX; dummy++)
4438 (void)dec_stat(dummy, 10 + randint1(15), TRUE);
4440 reward = _("全能力値が下がった。", "decreasing all stats");
4447 msg_format(_("%sの声が轟き渡った:", "The voice of %s thunders:"), chaos_patrons[p_ptr->chaos_patron]);
4448 msg_print(_("「死ぬがよい、下僕よ!」", "'Die, mortal!'"));
4450 take_hit(DAMAGE_LOSELIFE, p_ptr->lev * 4, wrath_reason, -1);
4451 for (dummy = 0; dummy < A_MAX; dummy++)
4453 (void)dec_stat(dummy, 10 + randint1(15), FALSE);
4455 activate_hi_summon(p_ptr->y, p_ptr->x, FALSE);
4456 (void)activate_ty_curse(FALSE, &count);
4461 if (buki_motteruka(INVEN_RARM))
4464 if (buki_motteruka(INVEN_LARM) && one_in_(2)) dummy = INVEN_LARM;
4466 else if (buki_motteruka(INVEN_LARM)) dummy = INVEN_LARM;
4468 if (dummy) (void)curse_weapon(FALSE, dummy);
4470 if (one_in_(2)) (void)curse_armor();
4475 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4476 msg_print(_("「死と破壊こそ我が喜びなり!」", "'Death and destruction! This pleaseth me!'"));
4478 (void)destroy_area(p_ptr->y, p_ptr->x, 25, FALSE);
4479 reward = _("ダンジョンが*破壊*された。", "*destruct*ing dungeon");
4484 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4485 msg_print(_("「我、汝の敵を抹殺せん!」", "'Let me relieve thee of thine oppressors!'"));
4486 (void)symbol_genocide(0, FALSE);
4487 reward = _("モンスターが抹殺された。", "genociding monsters");
4492 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4493 msg_print(_("「我、汝の敵を抹殺せん!」", "'Let me relieve thee of thine oppressors!'"));
4495 (void)mass_genocide(0, FALSE);
4496 reward = _("モンスターが抹殺された。", "genociding nearby monsters");
4501 msg_format(_("%sの力が敵を攻撃するのを感じた!", "You can feel the power of %s assault your enemies!"), chaos_patrons[p_ptr->chaos_patron]);
4502 (void)dispel_monsters(p_ptr->lev * 4);
4507 msg_format(_("%sはあなたを無視した。", "%s ignores you."), chaos_patrons[p_ptr->chaos_patron]);
4512 msg_format(_("%sは褒美として悪魔の使いをよこした!", "%s rewards you with a demonic servant!"),chaos_patrons[p_ptr->chaos_patron]);
4514 if (!summon_specific(-1, p_ptr->y, p_ptr->x, dun_level, SUMMON_DEMON, PM_FORCE_PET, '\0'))
4515 msg_print(_("何も現れなかった...", "Nobody ever turns up..."));
4517 reward = _("悪魔がペットになった。", "a demonic servant");
4522 msg_format(_("%sは褒美として使いをよこした!", "%s rewards you with a servant!"),chaos_patrons[p_ptr->chaos_patron]);
4524 if (!summon_specific(-1, p_ptr->y, p_ptr->x, dun_level, 0, PM_FORCE_PET, '\0'))
4525 msg_print(_("何も現れなかった...", "Nobody ever turns up..."));
4527 reward = _("モンスターがペットになった。", "a servant");
4532 msg_format(_("%sは褒美としてアンデッドの使いをよこした。", "%s rewards you with an undead servant!"),chaos_patrons[p_ptr->chaos_patron]);
4534 if (!summon_specific(-1, p_ptr->y, p_ptr->x, dun_level, SUMMON_UNDEAD, PM_FORCE_PET, '\0'))
4535 msg_print(_("何も現れなかった...", "Nobody ever turns up..."));
4537 reward = _("アンデッドがペットになった。", "an undead servant");
4542 msg_format(_("%sの声がどもった:", "The voice of %s stammers:"),
4544 chaos_patrons[p_ptr->chaos_patron]);
4545 msg_format(_("「あー、あー、答えは %d/%d。質問は何?」", "'Uh... uh... the answer's %d/%d, what's the question?'"), type, effect);
4551 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, format(_("パトロンの報酬で%s", "The patron rewards you with %s."), reward));
4557 * XAngband: determine if a given location is "interesting"
4558 * based on target_set_accept function.
4560 static bool tgt_pt_accept(POSITION y, POSITION x)
4565 if (!(in_bounds(y, x))) return (FALSE);
4567 /* Player grid is always interesting */
4568 if ((y == p_ptr->y) && (x == p_ptr->x)) return (TRUE);
4570 /* Handle hallucination */
4571 if (p_ptr->image) return (FALSE);
4573 /* Examine the grid */
4574 c_ptr = &cave[y][x];
4576 /* Interesting memorized features */
4577 if (c_ptr->info & (CAVE_MARK))
4580 if (cave_have_flag_grid(c_ptr, FF_LESS)) return (TRUE);
4581 if (cave_have_flag_grid(c_ptr, FF_MORE)) return (TRUE);
4583 /* Notice quest features */
4584 if (cave_have_flag_grid(c_ptr, FF_QUEST_ENTER)) return (TRUE);
4585 if (cave_have_flag_grid(c_ptr, FF_QUEST_EXIT)) return (TRUE);
4593 * XAngband: Prepare the "temp" array for "tget_pt"
4594 * based on target_set_prepare funciton.
4596 static void tgt_pt_prepare(void)
4600 /* Reset "temp" array */
4603 if (!expand_list) return;
4605 /* Scan the current panel */
4606 for (y = 1; y < cur_hgt; y++)
4608 for (x = 1; x < cur_wid; x++)
4610 /* Require "interesting" contents */
4611 if (!tgt_pt_accept(y, x)) continue;
4613 /* Save the location */
4620 /* Target the nearest monster for shooting */
4621 ang_sort_comp = ang_sort_comp_distance;
4622 ang_sort_swap = ang_sort_swap_distance;
4624 /* Sort the positions */
4625 ang_sort(temp_x, temp_y, temp_n);
4629 * old -- from PsiAngband.
4631 bool tgt_pt(POSITION *x_ptr, POSITION *y_ptr)
4636 bool success = FALSE;
4640 get_screen_size(&wid, &hgt);
4650 msg_print(_("場所を選んでスペースキーを押して下さい。", "Select a point and press space."));
4651 msg_flag = FALSE; /* prevents "-more-" message. */
4653 while ((ch != ESCAPE) && !success)
4655 bool move_fast = FALSE;
4657 move_cursor_relative(y, x);
4669 if (player_bold(y, x)) ch = 0;
4672 else success = TRUE;
4676 /* XAngband: Move cursor to stairs */
4679 if (expand_list && temp_n)
4682 int cx = (panel_col_min + panel_col_max) / 2;
4683 int cy = (panel_row_min + panel_row_max) / 2;
4687 /* Skip stairs which have defferent distance */
4688 for (; n < temp_n; ++ n)
4690 cave_type *c_ptr = &cave[temp_y[n]][temp_x[n]];
4692 if (cave_have_flag_grid(c_ptr, FF_STAIRS) &&
4693 cave_have_flag_grid(c_ptr, ch == '>' ? FF_MORE : FF_LESS))
4700 if (n == temp_n) /* Loop out taget list */
4705 verify_panel(); /* Move cursor to player */
4707 p_ptr->update |= (PU_MONSTERS);
4709 p_ptr->redraw |= (PR_MAP);
4711 p_ptr->window |= (PW_OVERHEAD);
4714 else /* move cursor to next stair and change panel */
4719 dy = 2 * (y - cy) / hgt;
4720 dx = 2 * (x - cx) / wid;
4721 if (dy || dx) change_panel(dy, dx);
4727 /* Look up the direction */
4728 d = get_keymap_dir(ch);
4730 /* XTRA HACK MOVEFAST */
4731 if (isupper(ch)) move_fast = TRUE;
4733 /* Handle "direction" */
4739 /* XTRA HACK MOVEFAST */
4742 int mag = MIN(wid / 2, hgt / 2);
4752 /* Do not move horizontally if unnecessary */
4753 if (((x < panel_col_min + wid / 2) && (dx > 0)) ||
4754 ((x > panel_col_min + wid / 2) && (dx < 0)))
4759 /* Do not move vertically if unnecessary */
4760 if (((y < panel_row_min + hgt / 2) && (dy > 0)) ||
4761 ((y > panel_row_min + hgt / 2) && (dy < 0)))
4766 /* Apply the motion */
4767 if ((y >= panel_row_min + hgt) || (y < panel_row_min) ||
4768 (x >= panel_col_min + wid) || (x < panel_col_min))
4770 /* if (change_panel(dy, dx)) target_set_prepare(mode); */
4771 change_panel(dy, dx);
4774 /* Slide into legality */
4775 if (x >= cur_wid-1) x = cur_wid - 2;
4776 else if (x <= 0) x = 1;
4778 /* Slide into legality */
4779 if (y >= cur_hgt-1) y = cur_hgt- 2;
4780 else if (y <= 0) y = 1;
4787 /* Clear the top line */
4790 /* Recenter the map around the player */
4793 p_ptr->update |= (PU_MONSTERS);
4795 p_ptr->redraw |= (PR_MAP);
4797 p_ptr->window |= (PW_OVERHEAD);
4806 bool get_hack_dir(DIRECTION *dp)
4814 /* Global direction */
4817 /* (No auto-targeting) */
4819 /* Ask until satisfied */
4822 /* Choose a prompt */
4825 p = _("方向 ('*'でターゲット選択, ESCで中断)? ", "Direction ('*' to choose a target, Escape to cancel)? ");
4829 p = _("方向 ('5'でターゲットへ, '*'でターゲット再選択, ESCで中断)? ", "Direction ('5' for target, '*' to re-target, Escape to cancel)? ");
4832 /* Get a command (or Cancel) */
4833 if (!get_com(p, &command, TRUE)) break;
4837 if (command == '\r') command = 't';
4840 /* Convert various keys to "standard" keys */
4843 /* Use current target */
4854 /* Set new target */
4859 if (target_set(TARGET_KILL)) dir = 5;
4865 /* Look up the direction */
4866 dir = get_keymap_dir(command);
4872 /* Verify requested targets */
4873 if ((dir == 5) && !target_okay()) dir = 0;
4880 if (!dir) return (FALSE);
4882 /* Save the direction */
4885 /* Check for confusion */
4886 if (p_ptr->confused)
4888 /* Random direction */
4889 dir = ddd[randint0(8)];
4892 /* Notice confusion */
4893 if (command_dir != dir)
4896 msg_print(_("あなたは混乱している。", "You are confused."));
4899 /* Save direction */
4902 /* A "valid" direction was entered */
4908 * @brief 射撃武器の攻撃に必要な基本消費エネルギーを返す/Return bow energy
4909 * @param sval 射撃武器のアイテム副分類ID
4910 * @return 消費する基本エネルギー
4912 ENERGY bow_energy(OBJECT_SUBTYPE_VALUE sval)
4914 ENERGY energy = 10000;
4916 /* Analyze the launcher */
4919 /* Sling and ammo */
4926 /* Short Bow and Arrow */
4933 /* Long Bow and Arrow */
4940 /* Bow of irresponsiblity and Arrow */
4947 /* Light Crossbow and Bolt */
4954 /* Heavy Crossbow and Bolt */
4969 int bow_tmul(OBJECT_SUBTYPE_VALUE sval)
4973 /* Analyze the launcher */
4976 /* Sling and ammo */
4983 /* Short Bow and Arrow */
4990 /* Long Bow and Arrow */
4997 /* Bow of irresponsiblity and Arrow */
5004 /* Light Crossbow and Bolt */
5011 /* Heavy Crossbow and Bolt */
5024 * Display a rumor and apply its effects
5027 IDX rumor_num(char *zz, IDX max_idx)
5029 if (strcmp(zz, "*") == 0) return randint1(max_idx - 1);
5030 return (IDX)atoi(zz);
5033 concptr rumor_bind_name(char *base, concptr fullname)
5037 s = strstr(base, "{Name}");
5041 v = format("%s%s%s", base, fullname, (s + 6));
5051 void display_rumor(bool ex)
5059 if (randint0(3) == 0) section = 1;
5062 err = _(get_rnd_line_jonly("rumors_j.txt", section, Rumor, 10),
5063 get_rnd_line("rumors.txt", section, Rumor));
5064 if (err) strcpy(Rumor, _("嘘の噂もある。", "Some rumors are wrong."));
5068 if (strncmp(Rumor, "R:", 2) == 0)
5071 concptr rumor_msg = NULL;
5072 concptr rumor_eff_format = NULL;
5073 char fullname[1024] = "";
5075 if (tokenize(Rumor + 2, 3, zz, TOKENIZE_CHECKQUOTE) == 3)
5077 if (strcmp(zz[0], "ARTIFACT") == 0)
5081 object_type *q_ptr = &forge;
5082 artifact_type *a_ptr;
5086 a_idx = rumor_num(zz[1], max_a_idx);
5088 a_ptr = &a_info[a_idx];
5089 if (a_ptr->name) break;
5092 k_idx = lookup_kind(a_ptr->tval, a_ptr->sval);
5093 object_prep(q_ptr, k_idx);
5094 q_ptr->name1 = a_idx;
5095 q_ptr->ident = IDENT_STORE;
5096 object_desc(fullname, q_ptr, OD_NAME_ONLY);
5098 else if (strcmp(zz[0], "MONSTER") == 0)
5101 monster_race *r_ptr;
5105 r_idx = rumor_num(zz[1], max_r_idx);
5106 r_ptr = &r_info[r_idx];
5107 if (r_ptr->name) break;
5110 strcpy(fullname, r_name + r_ptr->name);
5112 /* Remember this monster */
5113 if (!r_ptr->r_sights)
5118 else if (strcmp(zz[0], "DUNGEON") == 0)
5121 dungeon_info_type *d_ptr;
5125 d_idx = rumor_num(zz[1], max_d_idx);
5126 d_ptr = &d_info[d_idx];
5127 if (d_ptr->name) break;
5130 strcpy(fullname, d_name + d_ptr->name);
5132 if (!max_dlv[d_idx])
5134 max_dlv[d_idx] = d_ptr->mindepth;
5135 rumor_eff_format = _("%sに帰還できるようになった。", "You can recall to %s.");
5138 else if (strcmp(zz[0], "TOWN") == 0)
5145 t_idx = rumor_num(zz[1], NO_TOWN);
5146 if (town[t_idx].name) break;
5149 strcpy(fullname, town[t_idx].name);
5151 visit = (1L << (t_idx - 1));
5152 if ((t_idx != SECRET_TOWN) && !(p_ptr->visit & visit))
5154 p_ptr->visit |= visit;
5155 rumor_eff_format = _("%sに行ったことがある気がする。", "You feel you have been to %s.");
5159 rumor_msg = rumor_bind_name(zz[2], fullname);
5160 msg_print(rumor_msg);
5161 if (rumor_eff_format)
5164 msg_format(rumor_eff_format, fullname);
5169 if (err) msg_print(_("この情報は間違っている。", "This information is wrong."));
5173 msg_format("%s", Rumor);