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 #define REWARD_CHANCE 10
24 * @brief プレイヤーの経験値について整合性のためのチェックと調整を行う /
25 * Advance experience levels and print experience
28 void check_experience(void)
30 bool level_reward = FALSE;
31 bool level_mutation = FALSE;
32 bool level_inc_stat = FALSE;
33 bool android = (p_ptr->prace == RACE_ANDROID ? TRUE : FALSE);
34 PLAYER_LEVEL old_lev = p_ptr->lev;
36 /* Hack -- lower limit */
37 if (p_ptr->exp < 0) p_ptr->exp = 0;
38 if (p_ptr->max_exp < 0) p_ptr->max_exp = 0;
39 if (p_ptr->max_max_exp < 0) p_ptr->max_max_exp = 0;
41 /* Hack -- upper limit */
42 if (p_ptr->exp > PY_MAX_EXP) p_ptr->exp = PY_MAX_EXP;
43 if (p_ptr->max_exp > PY_MAX_EXP) p_ptr->max_exp = PY_MAX_EXP;
44 if (p_ptr->max_max_exp > PY_MAX_EXP) p_ptr->max_max_exp = PY_MAX_EXP;
46 /* Hack -- maintain "max" experience */
47 if (p_ptr->exp > p_ptr->max_exp) p_ptr->max_exp = p_ptr->exp;
49 /* Hack -- maintain "max max" experience */
50 if (p_ptr->max_exp > p_ptr->max_max_exp) p_ptr->max_max_exp = p_ptr->max_exp;
52 /* Redraw experience */
53 p_ptr->redraw |= (PR_EXP);
57 /* Lose levels while possible */
58 while ((p_ptr->lev > 1) &&
59 (p_ptr->exp < ((android ? player_exp_a : player_exp)[p_ptr->lev - 2] * p_ptr->expfact / 100L)))
63 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
64 p_ptr->redraw |= (PR_LEV | PR_TITLE);
65 p_ptr->window |= (PW_PLAYER);
70 /* Gain levels while possible */
71 while ((p_ptr->lev < PY_MAX_LEVEL) &&
72 (p_ptr->exp >= ((android ? player_exp_a : player_exp)[p_ptr->lev-1] * p_ptr->expfact / 100L)))
77 /* Save the highest level */
78 if (p_ptr->lev > p_ptr->max_plv)
80 p_ptr->max_plv = p_ptr->lev;
82 if ((p_ptr->pclass == CLASS_CHAOS_WARRIOR) ||
83 (p_ptr->muta2 & MUT2_CHAOS_GIFT))
87 if (p_ptr->prace == RACE_BEASTMAN)
89 if (one_in_(5)) level_mutation = TRUE;
91 level_inc_stat = TRUE;
93 do_cmd_write_nikki(NIKKI_LEVELUP, p_ptr->lev, NULL);
98 msg_format(_("レベル %d にようこそ。", "Welcome to level %d."), p_ptr->lev);
100 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
101 p_ptr->redraw |= (PR_LEV | PR_TITLE | PR_EXP);
102 p_ptr->window |= (PW_PLAYER | PW_SPELL | PW_INVEN);
112 if(!(p_ptr->max_plv % 10))
121 cnv_stat(p_ptr->stat_max[0], tmp);
122 prt(format(_(" a) 腕力 (現在値 %s)", " a) Str (cur %s)"), tmp), 2, 14);
123 cnv_stat(p_ptr->stat_max[1], tmp);
124 prt(format(_(" b) 知能 (現在値 %s)", " a) Int (cur %s)"), tmp), 3, 14);
125 cnv_stat(p_ptr->stat_max[2], tmp);
126 prt(format(_(" c) 賢さ (現在値 %s)", " a) Wis (cur %s)"), tmp), 4, 14);
127 cnv_stat(p_ptr->stat_max[3], tmp);
128 prt(format(_(" d) 器用 (現在値 %s)", " a) Dex (cur %s)"), tmp), 5, 14);
129 cnv_stat(p_ptr->stat_max[4], tmp);
130 prt(format(_(" e) 耐久 (現在値 %s)", " a) Con (cur %s)"), tmp), 6, 14);
131 cnv_stat(p_ptr->stat_max[5], tmp);
132 prt(format(_(" f) 魅力 (現在値 %s)", " a) Chr (cur %s)"), tmp), 7, 14);
135 prt(_(" どの能力値を上げますか?", " Which stat do you want to raise?"), 1, 14);
140 if ((choice >= 'a') && (choice <= 'f')) break;
142 for(n = 0; n < 6; n++)
143 if (n != choice - 'a')
145 if (get_check(_("よろしいですか?", "Are you sure? "))) break;
147 do_inc_stat(choice - 'a');
150 else if(!(p_ptr->max_plv % 2))
151 do_inc_stat(randint0(6));
156 msg_print(_("あなたは変わった気がする...", "You feel different..."));
157 (void)gain_random_mutation(0);
158 level_mutation = FALSE;
162 * 報酬でレベルが上ると再帰的に check_experience() が
167 gain_level_reward(0);
168 level_reward = FALSE;
171 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
172 p_ptr->redraw |= (PR_LEV | PR_TITLE);
173 p_ptr->window |= (PW_PLAYER | PW_SPELL);
177 /* Load an autopick preference file */
178 if (old_lev != p_ptr->lev) autopick_load_pref(FALSE);
183 * @brief モンスターを倒した際の財宝svalを返す
184 * @param r_idx 倒したモンスターの種族ID
187 * Hack -- Return the "automatic coin type" of a monster race
188 * Used to allocate proper treasure when "Creeping coins" die
189 * Note the use of actual "monster names"
191 static int get_coin_type(MONRACE_IDX r_idx)
193 /* Analyze monsters */
196 case MON_COPPER_COINS: return 2;
197 case MON_SILVER_COINS: return 5;
198 case MON_GOLD_COINS: return 10;
199 case MON_MITHRIL_COINS:
200 case MON_MITHRIL_GOLEM: return 16;
201 case MON_ADAMANT_COINS: return 17;
211 * @brief クエストを達成状態にする /
212 * @param quest_num 達成状態にしたいクエストのID
215 void complete_quest(QUEST_IDX quest_num)
217 quest_type* const q_ptr = &quest[quest_num];
221 case QUEST_TYPE_RANDOM:
222 if (record_rand_quest) do_cmd_write_nikki(NIKKI_RAND_QUEST_C, quest_num, NULL);
225 if (record_fix_quest) do_cmd_write_nikki(NIKKI_FIX_QUEST_C, quest_num, NULL);
229 q_ptr->status = QUEST_STATUS_COMPLETED;
230 q_ptr->complev = (byte)p_ptr->lev;
232 q_ptr->comptime = playtime;
234 if (!(q_ptr->flags & QUEST_FLAG_SILENT))
236 play_music(TERM_XTRA_MUSIC_BASIC, MUSIC_BASIC_QUEST_CLEAR);
237 msg_print(_("クエストを達成した!", "You just completed your quest!"));
243 * @brief 現在フロアに残っている敵モンスターの数を返す /
244 * @return 現在の敵モンスターの数
246 static MONSTER_NUMBER count_all_hostile_monsters(void)
249 MONSTER_NUMBER number_mon = 0;
251 for (x = 0; x < cur_wid; ++ x)
253 for (y = 0; y < cur_hgt; ++ y)
255 MONSTER_IDX m_idx = cave[y][x].m_idx;
257 if (m_idx > 0 && is_hostile(&m_list[m_idx]))
268 * @brief 特定の敵を倒した際にクエスト達成処理 /
269 * Check for "Quest" completion when a quest monster is killed or charmed.
270 * @param m_ptr 撃破したモンスターの構造体参照ポインタ
273 void check_quest_completion(monster_type *m_ptr)
278 bool create_stairs = FALSE;
284 /* Get the location */
289 quest_num = p_ptr->inside_quest;
291 /* Search for an active quest on this dungeon level */
296 for (i = max_q_idx - 1; i > 0; i--)
298 quest_type* const q_ptr = &quest[i];
300 /* Quest is not active */
301 if (q_ptr->status != QUEST_STATUS_TAKEN)
304 /* Quest is not a dungeon quest */
305 if (q_ptr->flags & QUEST_FLAG_PRESET)
308 /* Quest is not on this level */
309 if ((q_ptr->level != dun_level) &&
310 (q_ptr->type != QUEST_TYPE_KILL_ANY_LEVEL))
313 /* Not a "kill monster" quest */
314 if ((q_ptr->type == QUEST_TYPE_FIND_ARTIFACT) ||
315 (q_ptr->type == QUEST_TYPE_FIND_EXIT))
318 /* Interesting quest */
319 if ((q_ptr->type == QUEST_TYPE_KILL_NUMBER) ||
320 (q_ptr->type == QUEST_TYPE_TOWER) ||
321 (q_ptr->type == QUEST_TYPE_KILL_ALL))
324 /* Interesting quest */
325 if (((q_ptr->type == QUEST_TYPE_KILL_LEVEL) ||
326 (q_ptr->type == QUEST_TYPE_KILL_ANY_LEVEL) ||
327 (q_ptr->type == QUEST_TYPE_RANDOM)) &&
328 (q_ptr->r_idx == m_ptr->r_idx))
335 /* Handle the current quest */
336 if (quest_num && (quest[quest_num].status == QUEST_STATUS_TAKEN))
339 quest_type* const q_ptr = &quest[quest_num];
343 case QUEST_TYPE_KILL_NUMBER:
347 if (q_ptr->cur_num >= q_ptr->num_mon)
349 complete_quest(quest_num);
355 case QUEST_TYPE_KILL_ALL:
357 if (!is_hostile(m_ptr)) break;
359 if (count_all_hostile_monsters() == 1)
361 if (q_ptr->flags & QUEST_FLAG_SILENT)
363 q_ptr->status = QUEST_STATUS_FINISHED;
367 complete_quest(quest_num);
372 case QUEST_TYPE_KILL_LEVEL:
373 case QUEST_TYPE_RANDOM:
375 /* Only count valid monsters */
376 if (q_ptr->r_idx != m_ptr->r_idx)
381 if (q_ptr->cur_num >= q_ptr->max_num)
383 complete_quest(quest_num);
385 if (!(q_ptr->flags & QUEST_FLAG_PRESET))
387 create_stairs = TRUE;
388 p_ptr->inside_quest = 0;
391 /* Finish the two main quests without rewarding */
392 if ((quest_num == QUEST_OBERON) || (quest_num == QUEST_SERPENT))
394 q_ptr->status = QUEST_STATUS_FINISHED;
397 if (q_ptr->type == QUEST_TYPE_RANDOM)
400 q_ptr->status = QUEST_STATUS_FINISHED;
405 case QUEST_TYPE_KILL_ANY_LEVEL:
408 if (q_ptr->cur_num >= q_ptr->max_num)
410 complete_quest(quest_num);
415 case QUEST_TYPE_TOWER:
417 if (!is_hostile(m_ptr)) break;
419 if (count_all_hostile_monsters() == 1)
421 q_ptr->status = QUEST_STATUS_STAGE_COMPLETED;
423 if((quest[QUEST_TOWER1].status == QUEST_STATUS_STAGE_COMPLETED) &&
424 (quest[QUEST_TOWER2].status == QUEST_STATUS_STAGE_COMPLETED) &&
425 (quest[QUEST_TOWER3].status == QUEST_STATUS_STAGE_COMPLETED))
428 complete_quest(QUEST_TOWER1);
436 /* Create a magical staircase */
442 while (cave_perma_bold(y, x) || cave[y][x].o_idx || (cave[y][x].info & CAVE_OBJECT) )
444 /* Pick a location */
445 scatter(&ny, &nx, y, x, 1, 0);
451 /* Explain the staircase */
452 msg_print(_("魔法の階段が現れた...", "A magical staircase appears..."));
454 /* Create stairs down */
455 cave_set_feat(y, x, feat_down_stair);
457 /* Remember to update everything */
458 p_ptr->update |= (PU_FLOW);
468 for (i = 0; i < (dun_level / 15)+1; i++)
473 /* Make a great object */
474 make_object(o_ptr, AM_GOOD | AM_GREAT);
476 /* Drop it in the dungeon */
477 (void)drop_near(o_ptr, -1, y, x);
483 * @brief 特定のアーティファクトを入手した際のクエスト達成処理 /
484 * Check for "Quest" completion when a quest monster is killed or charmed.
485 * @param o_ptr 入手したオブジェクトの構造体参照ポインタ
488 void check_find_art_quest_completion(object_type *o_ptr)
491 /* Check if completed a quest */
492 for (i = 0; i < max_q_idx; i++)
494 if((quest[i].type == QUEST_TYPE_FIND_ARTIFACT) &&
495 (quest[i].status == QUEST_STATUS_TAKEN) &&
496 (quest[i].k_idx == o_ptr->name1))
505 * @brief モンスターを撃破した際の述語メッセージを返す /
506 * Return monster death string
507 * @param r_ptr 撃破されたモンスターの種族情報を持つ構造体の参照ポインタ
508 * @return 撃破されたモンスターの述語
510 cptr extract_note_dies(MONRACE_IDX r_idx)
512 monster_race *r_ptr = &r_info[r_idx];
513 /* Some monsters get "destroyed" */
514 if (!monster_living(r_idx))
518 for (i = 0; i < 4; i++)
520 if (r_ptr->blow[i].method == RBM_EXPLODE)
522 return _("は爆発して粉々になった。", " explodes into tiny shreds.");
525 return _("を倒した。", " is destroyed.");
528 /* Assume a default death */
529 return _("は死んだ。", " dies.");
534 * @brief モンスターが死亡した時の処理 /
535 * Handle the "death" of a monster.
536 * @param m_idx 死亡したモンスターのID
537 * @param drop_item TRUEならばモンスターのドロップ処理を行う
538 * @return 撃破されたモンスターの述語
541 * Disperse treasures centered at the monster location based on the
542 * various flags contained in the monster flags fields.
543 * Check for "Quest" completion when a quest monster is killed.
544 * Note that only the player can induce "monster_death()" on Uniques.
545 * Thus (for now) all Quest monsters should be Uniques.
546 * Note that monsters can now carry objects, and when a monster dies,
547 * it drops all of its objects, which may disappear in crowded rooms.
550 void monster_death(MONSTER_IDX m_idx, bool drop_item)
559 monster_type *m_ptr = &m_list[m_idx];
560 monster_race *r_ptr = &r_info[m_ptr->r_idx];
562 bool visible = ((m_ptr->ml && !p_ptr->image) || (r_ptr->flags1 & RF1_UNIQUE));
566 bool do_gold = (!(r_ptr->flags1 & RF1_ONLY_ITEM));
567 bool do_item = (!(r_ptr->flags1 & RF1_ONLY_GOLD));
568 bool cloned = (m_ptr->smart & SM_CLONED) ? TRUE : FALSE;
569 int force_coin = get_coin_type(m_ptr->r_idx);
574 bool drop_chosen_item = drop_item && !cloned && !p_ptr->inside_arena
575 && !p_ptr->inside_battle && !is_pet(m_ptr);
577 /* The caster is dead? */
578 if (world_monster && world_monster == m_idx) world_monster = 0;
580 /* Notice changes in view */
581 if (r_ptr->flags7 & (RF7_LITE_MASK | RF7_DARK_MASK))
583 /* Update some things */
584 p_ptr->update |= (PU_MON_LITE);
587 /* Get the location */
591 if (record_named_pet && is_pet(m_ptr) && m_ptr->nickname)
595 monster_desc(m_name, m_ptr, MD_INDEF_VISIBLE);
596 do_cmd_write_nikki(NIKKI_NAMED_PET, 3, m_name);
599 /* Let monsters explode! */
600 for (i = 0; i < 4; i++)
602 if (r_ptr->blow[i].method == RBM_EXPLODE)
604 BIT_FLAGS flg = PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL;
605 EFFECT_ID typ = mbe_info[r_ptr->blow[i].effect].explode_type;
606 DICE_NUMBER d_dice = r_ptr->blow[i].d_dice;
607 DICE_SID d_side = r_ptr->blow[i].d_side;
608 HIT_POINT damage = damroll(d_dice, d_side);
610 project(m_idx, 3, y, x, damage, typ, flg, -1);
615 if (m_ptr->mflag2 & MFLAG2_CHAMELEON)
617 choose_new_monster(m_idx, TRUE, MON_CHAMELEON);
618 r_ptr = &r_info[m_ptr->r_idx];
621 /* Check for quest completion */
622 check_quest_completion(m_ptr);
624 /* Handle the possibility of player vanquishing arena combatant -KMW- */
625 if (p_ptr->inside_arena && !is_pet(m_ptr))
627 p_ptr->exit_bldg = TRUE;
629 if (p_ptr->arena_number > MAX_ARENA_MONS)
631 msg_print(_("素晴らしい!君こそ真の勝利者だ。", "You are a Genuine Champion!"));
635 msg_print(_("勝利!チャンピオンへの道を進んでいる。", "Victorious! You're on your way to becoming Champion."));
638 if (arena_info[p_ptr->arena_number].tval)
642 /* Prepare to make a prize */
643 object_prep(q_ptr, lookup_kind(arena_info[p_ptr->arena_number].tval, arena_info[p_ptr->arena_number].sval));
644 apply_magic(q_ptr, object_level, AM_NO_FIXED_ART);
646 /* Drop it in the dungeon */
647 (void)drop_near(q_ptr, -1, y, x);
650 if (p_ptr->arena_number > MAX_ARENA_MONS) p_ptr->arena_number++;
651 p_ptr->arena_number++;
656 /* Extract monster name */
657 monster_desc(m_name, m_ptr, MD_IGNORE_HALLU | MD_ASSUME_VISIBLE | MD_INDEF_VISIBLE);
659 do_cmd_write_nikki(NIKKI_ARENA, p_ptr->arena_number, m_name);
663 if (m_idx == p_ptr->riding)
665 if (rakuba(-1, FALSE))
667 msg_print(_("地面に落とされた。", "You have fallen from your riding pet."));
671 /* Drop a dead corpse? */
672 if (one_in_(r_ptr->flags1 & RF1_UNIQUE ? 1 : 4) &&
673 (r_ptr->flags9 & (RF9_DROP_CORPSE | RF9_DROP_SKELETON)) &&
674 !(p_ptr->inside_arena || p_ptr->inside_battle || cloned || ((m_ptr->r_idx == today_mon) && is_pet(m_ptr))))
676 /* Assume skeleton */
680 * We cannot drop a skeleton? Note, if we are in this check,
681 * we *know* we can drop at least a corpse or a skeleton
683 if (!(r_ptr->flags9 & RF9_DROP_SKELETON))
685 else if ((r_ptr->flags9 & RF9_DROP_CORPSE) && (r_ptr->flags1 & RF1_UNIQUE))
688 /* Else, a corpse is more likely unless we did a "lot" of damage */
689 else if (r_ptr->flags9 & RF9_DROP_CORPSE)
691 /* Lots of damage in one blow */
692 if ((0 - ((m_ptr->maxhp) / 4)) > m_ptr->hp)
694 if (one_in_(5)) corpse = TRUE;
698 if (!one_in_(5)) corpse = TRUE;
703 /* Prepare to make an object */
704 object_prep(q_ptr, lookup_kind(TV_CORPSE, (corpse ? SV_CORPSE : SV_SKELETON)));
706 apply_magic(q_ptr, object_level, AM_NO_FIXED_ART);
708 q_ptr->pval = m_ptr->r_idx;
710 /* Drop it in the dungeon */
711 (void)drop_near(q_ptr, -1, y, x);
714 /* Drop objects being carried */
715 monster_drop_carried_objects(m_ptr);
717 if (r_ptr->flags1 & RF1_DROP_GOOD) mo_mode |= AM_GOOD;
718 if (r_ptr->flags1 & RF1_DROP_GREAT) mo_mode |= AM_GREAT;
720 switch (m_ptr->r_idx)
722 case MON_PINK_HORROR:
723 /* Pink horrors are replaced with 2 Blue horrors */
724 if (!(p_ptr->inside_arena || p_ptr->inside_battle))
728 for (i = 0; i < 2; i++)
730 POSITION wy = y, wx = x;
731 bool pet = is_pet(m_ptr);
734 if (pet) mode |= PM_FORCE_PET;
736 if (summon_specific((pet ? -1 : m_idx), wy, wx, 100, SUMMON_BLUE_HORROR, mode))
738 if (player_can_see_bold(wy, wx)) notice = TRUE;
742 if (notice) msg_print(_("ピンク・ホラーは分裂した!", "The Pink horror divides!"));
746 case MON_BLOODLETTER:
747 /* Bloodletters of Khorne may drop a blade of chaos */
748 if (drop_chosen_item && (randint1(100) < 15))
752 /* Prepare to make a Blade of Chaos */
753 object_prep(q_ptr, lookup_kind(TV_SWORD, SV_BLADE_OF_CHAOS));
755 apply_magic(q_ptr, object_level, AM_NO_FIXED_ART | mo_mode);
757 /* Drop it in the dungeon */
758 (void)drop_near(q_ptr, -1, y, x);
763 if (drop_chosen_item && (dun_level > 9))
768 /* Activate restriction */
769 if ((dun_level > 49) && one_in_(5))
770 get_obj_num_hook = kind_is_good_book;
772 get_obj_num_hook = kind_is_book;
775 make_object(q_ptr, mo_mode);
777 /* Drop it in the dungeon */
778 (void)drop_near(q_ptr, -1, y, x);
784 * Mega^3-hack: killing a 'Warrior of the Dawn' is likely to
785 * spawn another in the fallen one's place!
787 if (!p_ptr->inside_arena && !p_ptr->inside_battle)
791 POSITION wy = y, wx = x;
793 bool pet = is_pet(m_ptr);
797 scatter(&wy, &wx, y, x, 20, 0);
799 while (!(in_bounds(wy, wx) && cave_empty_bold2(wy, wx)) && --attempts);
804 if (pet) mode |= PM_FORCE_PET;
806 if (summon_specific((pet ? -1 : m_idx), wy, wx, 100, SUMMON_DAWN, mode))
808 if (player_can_see_bold(wy, wx))
809 msg_print(_("新たな戦士が現れた!", "A new warrior steps forth!"));
817 /* One more ultra-hack: An Unmaker goes out with a big bang! */
819 BIT_FLAGS flg = PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL;
820 (void)project(m_idx, 6, y, x, 100, GF_CHAOS, flg, -1);
824 case MON_UNICORN_ORD:
827 /* Reward for "lazy" player */
828 if (p_ptr->pseikaku == SEIKAKU_NAMAKE)
830 ARTIFACT_IDX a_idx = 0;
831 artifact_type *a_ptr = NULL;
833 if (!drop_chosen_item) break;
840 a_idx = ART_NAMAKE_HAMMER;
843 a_idx = ART_NAMAKE_BOW;
846 a_idx = ART_NAMAKE_ARMOR;
850 a_ptr = &a_info[a_idx];
852 while (a_ptr->cur_num);
854 /* Create the artifact */
855 if (create_named_art(a_idx, y, x))
859 /* Hack -- Memorize location of artifact in saved floors */
860 if (character_dungeon) a_ptr->floor_id = p_ptr->floor_id;
862 else if (!preserve_mode) a_ptr->cur_num = 1;
867 if (!drop_chosen_item) break;
870 /* Mega-Hack -- Prepare to make "Grond" */
871 object_prep(q_ptr, lookup_kind(TV_HAFTED, SV_GROND));
873 /* Mega-Hack -- Mark this item as "Grond" */
874 q_ptr->name1 = ART_GROND;
876 /* Mega-Hack -- Actually create "Grond" */
877 apply_magic(q_ptr, -1, AM_GOOD | AM_GREAT);
879 /* Drop it in the dungeon */
880 (void)drop_near(q_ptr, -1, y, x);
883 /* Mega-Hack -- Prepare to make "Chaos" */
884 object_prep(q_ptr, lookup_kind(TV_CROWN, SV_CHAOS));
886 /* Mega-Hack -- Mark this item as "Chaos" */
887 q_ptr->name1 = ART_CHAOS;
889 /* Mega-Hack -- Actually create "Chaos" */
890 apply_magic(q_ptr, -1, AM_GOOD | AM_GREAT);
892 /* Drop it in the dungeon */
893 (void)drop_near(q_ptr, -1, y, x);
896 case MON_B_DEATH_SWORD:
897 if (drop_chosen_item)
901 /* Prepare to make a broken sword */
902 object_prep(q_ptr, lookup_kind(TV_SWORD, randint1(2)));
904 /* Drop it in the dungeon */
905 (void)drop_near(q_ptr, -1, y, x);
911 if (drop_chosen_item && ((m_ptr->r_idx == MON_A_GOLD) ||
912 ((m_ptr->r_idx == MON_A_SILVER) && (r_ptr->r_akills % 5 == 0))))
916 /* Prepare to make a Can of Toys */
917 object_prep(q_ptr, lookup_kind(TV_CHEST, SV_CHEST_KANDUME));
919 apply_magic(q_ptr, object_level, AM_NO_FIXED_ART);
921 /* Drop it in the dungeon */
922 (void)drop_near(q_ptr, -1, y, x);
928 BIT_FLAGS flg = PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL;
929 (void)project(m_idx, 3, y, x, damroll(20, 10), GF_FIRE, flg, -1);
934 if (!drop_chosen_item) break;
936 switch (r_ptr->d_char)
944 /* Activate restriction */
945 get_obj_num_hook = kind_is_cloak;
948 make_object(q_ptr, mo_mode);
950 /* Drop it in the dungeon */
951 (void)drop_near(q_ptr, -1, y, x);
961 /* Activate restriction */
962 get_obj_num_hook = kind_is_polearm;
964 /* Make a poleweapon */
965 make_object(q_ptr, mo_mode);
967 /* Drop it in the dungeon */
968 (void)drop_near(q_ptr, -1, y, x);
978 /* Activate restriction */
979 get_obj_num_hook = kind_is_armor;
981 /* Make a hard armor */
982 make_object(q_ptr, mo_mode);
984 /* Drop it in the dungeon */
985 (void)drop_near(q_ptr, -1, y, x);
995 /* Activate restriction */
996 get_obj_num_hook = kind_is_hafted;
998 /* Make a hafted weapon */
999 make_object(q_ptr, mo_mode);
1001 /* Drop it in the dungeon */
1002 (void)drop_near(q_ptr, -1, y, x);
1007 if (m_ptr->r_idx != MON_STORMBRINGER)
1012 /* Activate restriction */
1013 get_obj_num_hook = kind_is_sword;
1016 make_object(q_ptr, mo_mode);
1018 /* Drop it in the dungeon */
1019 (void)drop_near(q_ptr, -1, y, x);
1026 /* Mega-Hack -- drop fixed items */
1027 if (drop_chosen_item)
1029 ARTIFACT_IDX a_idx = 0;
1032 for(i = 0; i < 4; i++)
1034 if(!r_ptr->artifact_id[i]) break;
1035 a_idx = r_ptr->artifact_id[i];
1036 chance = r_ptr->artifact_percent[i];
1039 if ((a_idx > 0) && ((randint0(100) < chance) || p_ptr->wizard))
1041 artifact_type *a_ptr = &a_info[a_idx];
1043 if (!a_ptr->cur_num)
1045 /* Create the artifact */
1046 if (create_named_art(a_idx, y, x))
1050 /* Hack -- Memorize location of artifact in saved floors */
1051 if (character_dungeon) a_ptr->floor_id = p_ptr->floor_id;
1053 else if (!preserve_mode) a_ptr->cur_num = 1;
1057 if ((r_ptr->flags7 & RF7_GUARDIAN) && (d_info[dungeon_type].final_guardian == m_ptr->r_idx))
1059 KIND_OBJECT_IDX k_idx = d_info[dungeon_type].final_object ? d_info[dungeon_type].final_object
1060 : lookup_kind(TV_SCROLL, SV_SCROLL_ACQUIREMENT);
1062 if (d_info[dungeon_type].final_artifact)
1064 a_idx = d_info[dungeon_type].final_artifact;
1065 artifact_type *a_ptr = &a_info[a_idx];
1067 if (!a_ptr->cur_num)
1069 /* Create the artifact */
1070 if (create_named_art(a_idx, y, x))
1074 /* Hack -- Memorize location of artifact in saved floors */
1075 if (character_dungeon) a_ptr->floor_id = p_ptr->floor_id;
1077 else if (!preserve_mode) a_ptr->cur_num = 1;
1079 /* Prevent rewarding both artifact and "default" object */
1080 if (!d_info[dungeon_type].final_object) k_idx = 0;
1088 /* Prepare to make a reward */
1089 object_prep(q_ptr, k_idx);
1091 apply_magic(q_ptr, object_level, AM_NO_FIXED_ART | AM_GOOD);
1093 /* Drop it in the dungeon */
1094 (void)drop_near(q_ptr, -1, y, x);
1096 msg_format(_("あなたは%sを制覇した!", "You have conquered %s!"),d_name+d_info[dungeon_type].name);
1100 /* Determine how much we can drop */
1101 if ((r_ptr->flags1 & RF1_DROP_60) && (randint0(100) < 60)) number++;
1102 if ((r_ptr->flags1 & RF1_DROP_90) && (randint0(100) < 90)) number++;
1103 if (r_ptr->flags1 & RF1_DROP_1D2) number += damroll(1, 2);
1104 if (r_ptr->flags1 & RF1_DROP_2D2) number += damroll(2, 2);
1105 if (r_ptr->flags1 & RF1_DROP_3D2) number += damroll(3, 2);
1106 if (r_ptr->flags1 & RF1_DROP_4D2) number += damroll(4, 2);
1108 if (cloned && !(r_ptr->flags1 & RF1_UNIQUE))
1109 number = 0; /* Clones drop no stuff unless Cloning Pits */
1111 if (is_pet(m_ptr) || p_ptr->inside_battle || p_ptr->inside_arena)
1112 number = 0; /* Pets drop no stuff */
1113 if (!drop_item && (r_ptr->d_char != '$')) number = 0;
1115 if((r_ptr->flags2 & (RF2_MULTIPLY)) && (r_ptr->r_akills > 1024))
1116 number = 0; /* Limit of Multiply monster drop */
1118 /* Hack -- handle creeping coins */
1119 coin_type = force_coin;
1121 /* Average dungeon and monster levels */
1122 object_level = (dun_level + r_ptr->level) / 2;
1124 /* Drop some objects */
1125 for (j = 0; j < number; j++)
1131 if (do_gold && (!do_item || (randint0(100) < 50)))
1133 /* Make some gold */
1134 if (!make_gold(q_ptr)) continue;
1142 /* Make an object */
1143 if (!make_object(q_ptr, mo_mode)) continue;
1148 /* Drop it in the dungeon */
1149 (void)drop_near(q_ptr, -1, y, x);
1152 /* Reset the object level */
1153 object_level = base_level;
1155 /* Reset "coin" type */
1159 /* Take note of any dropped treasure */
1160 if (visible && (dump_item || dump_gold))
1162 /* Take notes on treasure */
1163 lore_treasure(m_idx, dump_item, dump_gold);
1166 /* Only process "Quest Monsters" */
1167 if (!(r_ptr->flags1 & RF1_QUESTOR)) return;
1168 if (p_ptr->inside_battle) return;
1171 if ((m_ptr->r_idx == MON_SERPENT) && !cloned)
1174 p_ptr->total_winner = TRUE;
1176 /* Redraw the "title" */
1177 p_ptr->redraw |= (PR_TITLE);
1179 play_music(TERM_XTRA_MUSIC_BASIC, MUSIC_BASIC_FINAL_QUEST_CLEAR);
1181 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, _("見事に変愚蛮怒の勝利者となった!", "become *WINNER* of Hengband finely!"));
1183 if ((p_ptr->pclass == CLASS_CHAOS_WARRIOR) || (p_ptr->muta2 & MUT2_CHAOS_GIFT))
1185 msg_format(_("%sからの声が響いた。", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
1186 msg_print(_("『よくやった、定命の者よ!』", "'Thou art donst well, mortal!'"));
1189 /* Congratulations */
1190 msg_print(_("*** おめでとう ***", "*** CONGRATULATIONS ***"));
1191 msg_print(_("あなたはゲームをコンプリートしました。", "You have won the game!"));
1192 msg_print(_("準備が整ったら引退(自殺コマンド)しても結構です。", "You may retire (commit suicide) when you are ready."));
1197 * @brief モンスターに与えたダメージの修正処理 /
1198 * Modify the physical damage done to the monster.
1199 * @param m_ptr ダメージを受けるモンスターの構造体参照ポインタ
1200 * @param dam ダメージ基本値
1201 * @param is_psy_spear 攻撃手段が光の剣ならばTRUE
1202 * @return 修正を行った結果のダメージ量
1205 * (for example when it's invulnerable or shielded)
1206 * ToDo: Accept a damage-type to calculate the modified damage from
1207 * things like fire, frost, lightning, poison, ... attacks.
1208 * "type" is not yet used and should be 0.
1211 HIT_POINT mon_damage_mod(monster_type *m_ptr, HIT_POINT dam, bool is_psy_spear)
1213 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1215 if ((r_ptr->flagsr & RFR_RES_ALL) && dam > 0)
1218 if ((dam == 0) && one_in_(3)) dam = 1;
1221 if (MON_INVULNER(m_ptr))
1225 if (!p_ptr->blind && is_seen(m_ptr))
1227 msg_print(_("バリアを切り裂いた!", "The barrier is penetrated!"));
1230 else if (!one_in_(PENETRATE_INVULNERABILITY))
1240 * @brief モンスターに与えたダメージを元に経験値を加算する /
1241 * Calculate experience point to be get
1242 * @param dam 与えたダメージ量
1243 * @param m_ptr ダメージを与えたモンスターの構造体参照ポインタ
1247 * Even the 64 bit operation is not big enough to avoid overflaw
1248 * unless we carefully choose orders of multiplication and division.
1249 * Get the coefficient first, and multiply (potentially huge) base
1250 * experience point of a monster later.
1253 static void get_exp_from_mon(HIT_POINT dam, monster_type *m_ptr)
1255 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1262 if (!m_ptr->r_idx) return;
1263 if (is_pet(m_ptr) || p_ptr->inside_battle) return;
1266 * - Ratio of monster's level to player's level effects
1267 * - Varying speed effects
1268 * - Get a fraction in proportion of damage point
1270 new_exp = r_ptr->level * SPEED_TO_ENERGY(m_ptr->mspeed) * dam;
1273 div_l = (p_ptr->max_plv+2) * SPEED_TO_ENERGY(r_ptr->speed);
1275 /* Use (average maxhp * 2) as a denominator */
1276 if (!(r_ptr->flags1 & RF1_FORCE_MAXHP))
1277 s64b_mul(&div_h, &div_l, 0, r_ptr->hdice * (ironman_nightmare ? 2 : 1) * (r_ptr->hside + 1));
1279 s64b_mul(&div_h, &div_l, 0, r_ptr->hdice * (ironman_nightmare ? 2 : 1) * r_ptr->hside * 2);
1281 /* Special penalty in the wilderness */
1282 if (!dun_level && (!(r_ptr->flags8 & RF8_WILD_ONLY) || !(r_ptr->flags1 & RF1_UNIQUE)))
1283 s64b_mul(&div_h, &div_l, 0, 5);
1285 /* Do division first to prevent overflaw */
1286 s64b_div(&new_exp, &new_exp_frac, div_h, div_l);
1288 /* Special penalty for mutiply-monster */
1289 if ((r_ptr->flags2 & RF2_MULTIPLY) || (m_ptr->r_idx == MON_DAWN))
1291 int monnum_penarty = r_ptr->r_akills / 400;
1292 if (monnum_penarty > 8) monnum_penarty = 8;
1294 while (monnum_penarty--)
1297 s64b_RSHIFT(new_exp, new_exp_frac, 2);
1301 /* Special penalty for rest_and_shoot exp scum */
1302 if ((m_ptr->dealt_damage > m_ptr->max_maxhp) && (m_ptr->hp >= 0))
1304 int over_damage = m_ptr->dealt_damage / m_ptr->max_maxhp;
1305 if (over_damage > 32) over_damage = 32;
1307 while (over_damage--)
1310 s64b_mul(&new_exp, &new_exp_frac, 0, 9);
1311 s64b_div(&new_exp, &new_exp_frac, 0, 10);
1315 /* Finally multiply base experience point of the monster */
1316 s64b_mul(&new_exp, &new_exp_frac, 0, r_ptr->mexp);
1318 /* Gain experience */
1319 gain_exp_64(new_exp, new_exp_frac);
1324 * @brief モンスターのHPをダメージに応じて減算する /
1325 * Decreases monsters hit points, handling monster death.
1326 * @param dam 与えたダメージ量
1327 * @param m_idx ダメージを与えたモンスターのID
1328 * @param fear ダメージによってモンスターが恐慌状態に陥ったならばTRUEを返す
1329 * @param note モンスターが倒された際の特別なメッセージ述語
1333 * We return TRUE if the monster has been killed (and deleted).
1334 * We announce monster death (using an optional "death message"
1335 * if given, and a otherwise a generic killed/destroyed message).
1336 * Only "physical attacks" can induce the "You have slain" message.
1337 * Missile and Spell attacks will induce the "dies" message, or
1338 * various "specialized" messages. Note that "You have destroyed"
1339 * and "is destroyed" are synonyms for "You have slain" and "dies".
1340 * Hack -- unseen monsters yield "You have killed it." message.
1341 * Added fear (DGK) and check whether to print fear messages -CWS
1342 * Made name, sex, and capitalization generic -BEN-
1343 * As always, the "ghost" processing is a total hack.
1344 * Hack -- we "delay" fear messages by passing around a "fear" flag.
1345 * Consider decreasing monster experience over time, say,
1346 * by using "(m_exp * m_lev * (m_lev)) / (p_lev * (m_lev + n_killed))"
1347 * instead of simply "(m_exp * m_lev) / (p_lev)", to make the first
1348 * monster worth more than subsequent monsters. This would also need
1349 * to induce changes in the monster recall code.
1352 bool mon_take_hit(MONSTER_IDX m_idx, HIT_POINT dam, bool *fear, cptr note)
1354 monster_type *m_ptr = &m_list[m_idx];
1355 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1356 monster_type exp_mon;
1358 /* Innocent until proven otherwise */
1359 bool innocent = TRUE, thief = FALSE;
1363 (void)COPY(&exp_mon, m_ptr, monster_type);
1365 expdam = (m_ptr->hp > dam) ? dam : m_ptr->hp;
1367 get_exp_from_mon(expdam, &exp_mon);
1369 /* Genocided by chaos patron */
1370 if (!m_ptr->r_idx) m_idx = 0;
1372 /* Redraw (later) if needed */
1373 if (p_ptr->health_who == m_idx) p_ptr->redraw |= (PR_HEALTH);
1374 if (p_ptr->riding == m_idx) p_ptr->redraw |= (PR_UHEALTH);
1376 (void)set_monster_csleep(m_idx, 0);
1378 /* Hack - Cancel any special player stealth magics. -LM- */
1379 if (p_ptr->special_defense & NINJA_S_STEALTH)
1381 set_superstealth(FALSE);
1384 /* Genocided by chaos patron */
1385 if (!m_idx) return TRUE;
1388 m_ptr->dealt_damage += dam;
1390 if(m_ptr->dealt_damage > m_ptr->max_maxhp * 100) m_ptr->dealt_damage = m_ptr->max_maxhp * 100;
1394 msg_format( _("合計%d/%dのダメージを与えた。","You do %d (out of %d) damage."), m_ptr->dealt_damage, m_ptr->maxhp);
1397 /* It is dead now */
1402 if (r_info[m_ptr->r_idx].flags7 & RF7_TANUKI)
1404 /* You might have unmasked Tanuki first time */
1405 r_ptr = &r_info[m_ptr->r_idx];
1406 m_ptr->ap_r_idx = m_ptr->r_idx;
1407 if (r_ptr->r_sights < MAX_SHORT) r_ptr->r_sights++;
1410 if (m_ptr->mflag2 & MFLAG2_CHAMELEON)
1412 /* You might have unmasked Chameleon first time */
1413 r_ptr = real_r_ptr(m_ptr);
1414 if (r_ptr->r_sights < MAX_SHORT) r_ptr->r_sights++;
1417 if (!(m_ptr->smart & SM_CLONED))
1419 /* When the player kills a Unique, it stays dead */
1420 if (r_ptr->flags1 & RF1_UNIQUE)
1424 /* Mega-Hack -- Banor & Lupart */
1425 if ((m_ptr->r_idx == MON_BANOR) || (m_ptr->r_idx == MON_LUPART))
1427 r_info[MON_BANORLUPART].max_num = 0;
1428 r_info[MON_BANORLUPART].r_pkills++;
1429 r_info[MON_BANORLUPART].r_akills++;
1430 if (r_info[MON_BANORLUPART].r_tkills < MAX_SHORT) r_info[MON_BANORLUPART].r_tkills++;
1432 else if (m_ptr->r_idx == MON_BANORLUPART)
1434 r_info[MON_BANOR].max_num = 0;
1435 r_info[MON_BANOR].r_pkills++;
1436 r_info[MON_BANOR].r_akills++;
1437 if (r_info[MON_BANOR].r_tkills < MAX_SHORT) r_info[MON_BANOR].r_tkills++;
1438 r_info[MON_LUPART].max_num = 0;
1439 r_info[MON_LUPART].r_pkills++;
1440 r_info[MON_LUPART].r_akills++;
1441 if (r_info[MON_LUPART].r_tkills < MAX_SHORT) r_info[MON_LUPART].r_tkills++;
1445 /* When the player kills a Nazgul, it stays dead */
1446 else if (r_ptr->flags7 & RF7_NAZGUL) r_ptr->max_num--;
1449 /* Count all monsters killed */
1450 if (r_ptr->r_akills < MAX_SHORT) r_ptr->r_akills++;
1452 /* Recall even invisible uniques or winners */
1453 if ((m_ptr->ml && !p_ptr->image) || (r_ptr->flags1 & RF1_UNIQUE))
1455 /* Count kills this life */
1456 if ((m_ptr->mflag2 & MFLAG2_KAGE) && (r_info[MON_KAGE].r_pkills < MAX_SHORT)) r_info[MON_KAGE].r_pkills++;
1457 else if (r_ptr->r_pkills < MAX_SHORT) r_ptr->r_pkills++;
1459 /* Count kills in all lives */
1460 if ((m_ptr->mflag2 & MFLAG2_KAGE) && (r_info[MON_KAGE].r_tkills < MAX_SHORT)) r_info[MON_KAGE].r_tkills++;
1461 else if (r_ptr->r_tkills < MAX_SHORT) r_ptr->r_tkills++;
1463 /* Hack -- Auto-recall */
1464 monster_race_track(m_ptr->ap_r_idx);
1467 /* Extract monster name */
1468 monster_desc(m_name, m_ptr, MD_TRUE_NAME);
1470 /* Don't kill Amberites */
1471 if ((r_ptr->flags3 & RF3_AMBERITE) && one_in_(2))
1473 int curses = 1 + randint1(3);
1474 bool stop_ty = FALSE;
1477 msg_format(_("%^sは恐ろしい血の呪いをあなたにかけた!", "%^s puts a terrible blood curse on you!"), m_name);
1478 curse_equipment(100, 50);
1482 stop_ty = activate_ty_curse(stop_ty, &count);
1487 if (r_ptr->flags2 & RF2_CAN_SPEAK)
1489 char line_got[1024];
1491 /* Dump a message */
1492 if (!get_rnd_line(_("mondeath_j.txt", "mondeath.txt"), m_ptr->r_idx, line_got))
1494 msg_format("%^s %s", m_name, line_got);
1498 if (m_ptr->r_idx == MON_SERPENT)
1500 screen_dump = make_screen_dump();
1505 if (!(d_info[dungeon_type].flags1 & DF1_BEGINNER))
1507 if (!dun_level && !ambush_flag && !p_ptr->inside_arena)
1509 chg_virtue(V_VALOUR, -1);
1511 else if (r_ptr->level > dun_level)
1513 if (randint1(10) <= (r_ptr->level - dun_level))
1514 chg_virtue(V_VALOUR, 1);
1516 if (r_ptr->level > 60)
1518 chg_virtue(V_VALOUR, 1);
1520 if (r_ptr->level >= 2 * (p_ptr->lev+1))
1521 chg_virtue(V_VALOUR, 2);
1524 if (r_ptr->flags1 & RF1_UNIQUE)
1526 if (r_ptr->flags3 & (RF3_EVIL | RF3_GOOD)) chg_virtue(V_HARMONY, 2);
1528 if (r_ptr->flags3 & RF3_GOOD)
1530 chg_virtue(V_UNLIFE, 2);
1531 chg_virtue(V_VITALITY, -2);
1534 if (one_in_(3)) chg_virtue(V_INDIVIDUALISM, -1);
1537 if (m_ptr->r_idx == MON_BEGGAR || m_ptr->r_idx == MON_LEPER)
1539 chg_virtue(V_COMPASSION, -1);
1542 if ((r_ptr->flags3 & RF3_GOOD) && ((r_ptr->level) / 10 + (3 * dun_level) >= randint1(100)))
1543 chg_virtue(V_UNLIFE, 1);
1545 if (r_ptr->d_char == 'A')
1547 if (r_ptr->flags1 & RF1_UNIQUE)
1548 chg_virtue(V_FAITH, -2);
1549 else if ((r_ptr->level) / 10 + (3 * dun_level) >= randint1(100))
1551 if (r_ptr->flags3 & RF3_GOOD) chg_virtue(V_FAITH, -1);
1552 else chg_virtue(V_FAITH, 1);
1555 else if (r_ptr->flags3 & RF3_DEMON)
1557 if (r_ptr->flags1 & RF1_UNIQUE)
1558 chg_virtue(V_FAITH, 2);
1559 else if ((r_ptr->level) / 10 + (3 * dun_level) >= randint1(100))
1560 chg_virtue(V_FAITH, 1);
1563 if ((r_ptr->flags3 & RF3_UNDEAD) && (r_ptr->flags1 & RF1_UNIQUE))
1564 chg_virtue(V_VITALITY, 2);
1566 if (r_ptr->r_deaths)
1568 if (r_ptr->flags1 & RF1_UNIQUE)
1570 chg_virtue(V_HONOUR, 10);
1572 else if ((r_ptr->level) / 10 + (2 * dun_level) >= randint1(100))
1574 chg_virtue(V_HONOUR, 1);
1577 if ((r_ptr->flags2 & RF2_MULTIPLY) && (r_ptr->r_akills > 1000) && one_in_(10))
1579 chg_virtue(V_VALOUR, -1);
1582 for (i = 0; i < 4; i++)
1584 if (r_ptr->blow[i].d_dice != 0) innocent = FALSE; /* Murderer! */
1586 if ((r_ptr->blow[i].effect == RBE_EAT_ITEM)
1587 || (r_ptr->blow[i].effect == RBE_EAT_GOLD))
1589 thief = TRUE; /* Thief! */
1592 /* The new law says it is illegal to live in the dungeon */
1593 if (r_ptr->level != 0) innocent = FALSE;
1597 if (r_ptr->flags1 & RF1_UNIQUE)
1598 chg_virtue(V_JUSTICE, 3);
1599 else if (1+((r_ptr->level) / 10 + (2 * dun_level)) >= randint1(100))
1600 chg_virtue(V_JUSTICE, 1);
1604 chg_virtue (V_JUSTICE, -1);
1607 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)))
1609 if (one_in_(4)) chg_virtue(V_NATURE, -1);
1612 if ((r_ptr->flags1 & RF1_UNIQUE) && record_destroy_uniq)
1615 sprintf(note_buf, "%s%s", r_name + r_ptr->name, (m_ptr->smart & SM_CLONED) ? _("(クローン)", "(Clone)") : "");
1616 do_cmd_write_nikki(NIKKI_UNIQUE, 0, note_buf);
1622 /* Death by Missile/Spell attack */
1625 msg_format("%^s%s", m_name, note);
1628 /* Death by physical attack -- invisible monster */
1629 else if (!m_ptr->ml)
1632 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
1633 msg_format("せっかくだから%sを殺した。", m_name);
1635 msg_format("%sを殺した。", m_name);
1637 msg_format("You have killed %s.", m_name);
1642 /* Death by Physical attack -- non-living monster */
1643 else if (!monster_living(m_ptr->r_idx))
1645 bool explode = FALSE;
1647 for (i = 0; i < 4; i++)
1649 if (r_ptr->blow[i].method == RBM_EXPLODE) explode = TRUE;
1652 /* Special note at death */
1654 msg_format(_("%sは爆発して粉々になった。", "%^s explodes into tiny shreds."), m_name);
1658 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
1659 msg_format("せっかくだから%sを倒した。", m_name);
1661 msg_format("%sを倒した。", m_name);
1663 msg_format("You have destroyed %s.", m_name);
1668 /* Death by Physical attack -- living monster */
1672 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
1673 msg_format("せっかくだから%sを葬り去った。", m_name);
1675 msg_format("%sを葬り去った。", m_name);
1677 msg_format("You have slain %s.", m_name);
1681 if ((r_ptr->flags1 & RF1_UNIQUE) && !(m_ptr->smart & SM_CLONED) && !vanilla_town)
1683 for (i = 0; i < MAX_KUBI; i++)
1685 if ((kubi_r_idx[i] == m_ptr->r_idx) && !(m_ptr->mflag2 & MFLAG2_CHAMELEON))
1687 msg_format(_("%sの首には賞金がかかっている。", "There is a price on %s's head."), m_name);
1693 /* Generate treasure */
1694 monster_death(m_idx, TRUE);
1696 /* Mega hack : replace IKETA to BIKETAL */
1697 if ((m_ptr->r_idx == MON_IKETA) && !(p_ptr->inside_arena || p_ptr->inside_battle))
1699 POSITION dummy_y = m_ptr->fy;
1700 POSITION dummy_x = m_ptr->fx;
1701 BIT_FLAGS mode = 0L;
1702 if (is_pet(m_ptr)) mode |= PM_FORCE_PET;
1703 delete_monster_idx(m_idx);
1704 if (summon_named_creature(0, dummy_y, dummy_x, MON_BIKETAL, mode))
1706 msg_print(_("「ハァッハッハッハ!!私がバイケタルだ!!」", "Uwa-hahaha! *I* am Biketal!"));
1711 delete_monster_idx(m_idx);
1714 get_exp_from_mon((long)exp_mon.max_maxhp*2, &exp_mon);
1719 /* Monster is dead */
1726 /* Mega-Hack -- Pain cancels fear */
1727 if (MON_MONFEAR(m_ptr) && (dam > 0))
1730 if (set_monster_monfear(m_idx, MON_MONFEAR(m_ptr) - randint1(dam)))
1737 /* Sometimes a monster gets scared by damage */
1738 if (!MON_MONFEAR(m_ptr) && !(r_ptr->flags3 & (RF3_NO_FEAR)))
1740 /* Percentage of fully healthy */
1741 int percentage = (100L * m_ptr->hp) / m_ptr->maxhp;
1744 * Run (sometimes) if at 10% or less of max hit points,
1745 * or (usually) when hit for half its current hit points
1747 if ((randint1(10) >= percentage) || ((dam >= m_ptr->hp) && (randint0(100) < 80)))
1749 /* Hack -- note fear */
1752 /* Hack -- Add some timed fear */
1753 (void)set_monster_monfear(m_idx, (randint1(10) +
1754 (((dam >= m_ptr->hp) && (percentage > 7)) ?
1755 20 : ((11 - percentage) * 5))));
1767 * @brief 現在のコンソール表示の縦横を返す。 /
1768 * Get term size and calculate screen size
1769 * @param wid_p コンソールの表示幅文字数を返す
1770 * @param hgt_p コンソールの表示行数を返す
1773 void get_screen_size(TERM_LEN *wid_p, TERM_LEN *hgt_p)
1775 Term_get_size(wid_p, hgt_p);
1776 *hgt_p -= ROW_MAP + 2;
1777 *wid_p -= COL_MAP + 2;
1778 if (use_bigtile) *wid_p /= 2;
1783 * @brief コンソール上におけるマップ表示の左上位置を返す /
1784 * Calculates current boundaries Called below and from "do_cmd_locate()".
1787 void panel_bounds_center(void)
1791 get_screen_size(&wid, &hgt);
1793 panel_row_max = panel_row_min + hgt - 1;
1794 panel_row_prt = panel_row_min - 1;
1795 panel_col_max = panel_col_min + wid - 1;
1796 panel_col_prt = panel_col_min - 13;
1801 * @brief コンソールのリサイズに合わせてマップを再描画する /
1802 * Map resizing whenever the main term changes size
1805 void resize_map(void)
1807 /* Only if the dungeon exists */
1808 if (!character_dungeon) return;
1810 /* Mega-Hack -- no panel yet */
1814 /* Reset the panels */
1815 panel_row_min = cur_hgt;
1816 panel_col_min = cur_wid;
1820 p_ptr->update |= (PU_TORCH | PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
1822 /* Forget lite/view */
1823 p_ptr->update |= (PU_UN_VIEW | PU_UN_LITE);
1825 /* Update lite/view */
1826 p_ptr->update |= (PU_VIEW | PU_LITE | PU_MON_LITE);
1828 /* Update monsters */
1829 p_ptr->update |= (PU_MONSTERS);
1831 /* Redraw everything */
1832 p_ptr->redraw |= (PR_WIPE | PR_BASIC | PR_EXTRA | PR_MAP | PR_EQUIPPY);
1834 /* Hack -- update */
1840 * Place the cursor on the player
1842 if (can_save) move_cursor_relative(p_ptr->y, p_ptr->x);
1849 * @brief コンソールを再描画する /
1850 * Redraw a term when it is resized
1853 void redraw_window(void)
1855 /* Only if the dungeon exists */
1856 if (!character_dungeon) return;
1858 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_SPELL | PW_PLAYER);
1859 p_ptr->window |= (PW_MESSAGE | PW_OVERHEAD | PW_DUNGEON | PW_MONSTER | PW_OBJECT);
1861 /* Hack -- update */
1868 * @brief フォーカスを当てるべきマップ描画の基準座標を指定する(サブルーチン)
1869 * @param dy 変更先のフロアY座標
1870 * @param dx 変更先のフロアX座標
1871 * Handle a request to change the current panel
1872 * Return TRUE if the panel was changed.
1873 * Also used in do_cmd_locate
1874 * @return 実際に再描画が必要だった場合TRUEを返す
1876 bool change_panel(POSITION dy, POSITION dx)
1881 get_screen_size(&wid, &hgt);
1883 /* Apply the motion */
1884 y = panel_row_min + dy * hgt / 2;
1885 x = panel_col_min + dx * wid / 2;
1887 /* Verify the row */
1888 if (y > cur_hgt - hgt) y = cur_hgt - hgt;
1891 /* Verify the col */
1892 if (x > cur_wid - wid) x = cur_wid - wid;
1895 /* Handle "changes" */
1896 if ((y != panel_row_min) || (x != panel_col_min))
1898 /* Save the new panel info */
1902 /* Recalculate the boundaries */
1903 panel_bounds_center();
1905 p_ptr->update |= (PU_MONSTERS);
1907 p_ptr->redraw |= (PR_MAP);
1919 * @brief フォーカスを当てるべきマップ描画の基準座標を指定する
1920 * @param y 変更先のフロアY座標
1921 * @param x 変更先のフロアX座標
1923 * Handle a request to change the current panel
1924 * Return TRUE if the panel was changed.
1925 * Also used in do_cmd_locate
1926 * @return 実際に再描画が必要だった場合TRUEを返す
1928 static bool change_panel_xy(POSITION y, POSITION x)
1930 POSITION dy = 0, dx = 0;
1933 get_screen_size(&wid, &hgt);
1935 if (y < panel_row_min) dy = -1;
1936 if (y > panel_row_max) dy = 1;
1937 if (x < panel_col_min) dx = -1;
1938 if (x > panel_col_max) dx = 1;
1940 if (!dy && !dx) return (FALSE);
1942 return change_panel(dy, dx);
1947 * @brief マップ描画のフォーカスを当てるべき座標を更新する
1949 * Given an row (y) and col (x), this routine detects when a move
1950 * off the screen has occurred and figures new borders. -RAK-
1951 * "Update" forces a "full update" to take place.
1952 * The map is reprinted if necessary, and "TRUE" is returned.
1953 * @return 実際に再描画が必要だった場合TRUEを返す
1955 void verify_panel(void)
1957 POSITION y = p_ptr->y;
1958 POSITION x = p_ptr->x;
1966 get_screen_size(&wid, &hgt);
1968 max_prow_min = cur_hgt - hgt;
1969 max_pcol_min = cur_wid - wid;
1971 /* Bounds checking */
1972 if (max_prow_min < 0) max_prow_min = 0;
1973 if (max_pcol_min < 0) max_pcol_min = 0;
1975 /* Center on player */
1976 if (center_player && (center_running || !running))
1978 /* Center vertically */
1979 prow_min = y - hgt / 2;
1980 if (prow_min < 0) prow_min = 0;
1981 else if (prow_min > max_prow_min) prow_min = max_prow_min;
1983 /* Center horizontally */
1984 pcol_min = x - wid / 2;
1985 if (pcol_min < 0) pcol_min = 0;
1986 else if (pcol_min > max_pcol_min) pcol_min = max_pcol_min;
1990 prow_min = panel_row_min;
1991 pcol_min = panel_col_min;
1993 /* Scroll screen when 2 grids from top/bottom edge */
1994 if (y > panel_row_max - 2)
1996 while (y > prow_min + hgt-1 - 2)
1998 prow_min += (hgt / 2);
2002 if (y < panel_row_min + 2)
2004 while (y < prow_min + 2)
2006 prow_min -= (hgt / 2);
2010 if (prow_min > max_prow_min) prow_min = max_prow_min;
2011 if (prow_min < 0) prow_min = 0;
2013 /* Scroll screen when 4 grids from left/right edge */
2014 if (x > panel_col_max - 4)
2016 while (x > pcol_min + wid-1 - 4)
2018 pcol_min += (wid / 2);
2022 if (x < panel_col_min + 4)
2024 while (x < pcol_min + 4)
2026 pcol_min -= (wid / 2);
2030 if (pcol_min > max_pcol_min) pcol_min = max_pcol_min;
2031 if (pcol_min < 0) pcol_min = 0;
2034 /* Check for "no change" */
2035 if ((prow_min == panel_row_min) && (pcol_min == panel_col_min)) return;
2037 /* Save the new panel info */
2038 panel_row_min = prow_min;
2039 panel_col_min = pcol_min;
2041 /* Hack -- optional disturb on "panel change" */
2042 if (disturb_panel && !center_player) disturb(FALSE, FALSE);
2044 /* Recalculate the boundaries */
2045 panel_bounds_center();
2047 p_ptr->update |= (PU_MONSTERS);
2048 p_ptr->redraw |= (PR_MAP);
2049 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
2054 * Monster health description
2056 cptr look_mon_desc(monster_type *m_ptr, BIT_FLAGS mode)
2058 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
2065 /* Determine if the monster is "living" */
2066 living = monster_living(m_ptr->ap_r_idx);
2068 /* Calculate a health "percentage" */
2069 perc = 100L * m_ptr->hp / m_ptr->maxhp;
2071 /* Healthy monsters */
2072 if (m_ptr->hp >= m_ptr->maxhp)
2074 desc = living ? _("無傷", "unhurt") : _("無ダメージ", "undamaged");
2077 else if (perc >= 60)
2079 desc = living ? _("軽傷", "somewhat wounded") : _("小ダメージ", "somewhat damaged");
2082 else if (perc >= 25)
2084 desc = living ? _("負傷", "wounded") : _("中ダメージ", "damaged");
2087 else if (perc >= 10)
2089 desc = living ? _("重傷", "badly wounded") : _("大ダメージ", "badly damaged");
2094 desc = living ? _("半死半生", "almost dead") : _("倒れかけ", "almost destroyed");
2097 /* Need attitude information? */
2100 /* Full information is not needed */
2103 else if (is_pet(m_ptr))
2105 attitude = _(", ペット", ", pet");
2107 else if (is_friendly(m_ptr))
2109 attitude = _(", 友好的", ", friendly");
2113 attitude = _("", "");
2116 /* Clone monster? */
2117 if (m_ptr->smart & SM_CLONED)
2126 /* Display monster's level --- idea borrowed from ToME */
2127 if (ap_r_ptr->r_tkills && !(m_ptr->mflag2 & MFLAG2_KAGE))
2129 return format(_("レベル%d, %s%s%s", "Level %d, %s%s%s"), ap_r_ptr->level, desc, attitude, clone);
2133 return format(_("レベル???, %s%s%s", "Level ???, %s%s%s"), desc, attitude, clone);
2141 * Angband sorting algorithm -- quick sort in place
2143 * Note that the details of the data we are sorting is hidden,
2144 * and we rely on the "ang_sort_comp()" and "ang_sort_swap()"
2145 * function hooks to interact with the data, which is given as
2146 * two pointers, and which may have any user-defined form.
2148 void ang_sort_aux(vptr u, vptr v, int p, int q)
2166 while (!(*ang_sort_comp)(u, v, b, z)) b--;
2169 while (!(*ang_sort_comp)(u, v, z, a)) a++;
2171 /* Done partition */
2175 (*ang_sort_swap)(u, v, a, b);
2181 /* Recurse left side */
2182 ang_sort_aux(u, v, p, b);
2184 /* Recurse right side */
2185 ang_sort_aux(u, v, b+1, q);
2190 * Angband sorting algorithm -- quick sort in place
2192 * Note that the details of the data we are sorting is hidden,
2193 * and we rely on the "ang_sort_comp()" and "ang_sort_swap()"
2194 * function hooks to interact with the data, which is given as
2195 * two pointers, and which may have any user-defined form.
2197 void ang_sort(vptr u, vptr v, int n)
2199 /* Sort the array */
2200 ang_sort_aux(u, v, 0, n-1);
2205 /*** Targeting Code ***/
2209 * Determine is a monster makes a reasonable target
2211 * The concept of "targeting" was stolen from "Morgul" (?)
2213 * The player can target any location, or any "target-able" monster.
2215 * Currently, a monster is "target_able" if it is visible, and if
2216 * the player can hit it with a projection, and the player is not
2217 * hallucinating. This allows use of "use closest target" macros.
2219 * Future versions may restrict the ability to target "trappers"
2220 * and "mimics", but the semantics is a little bit weird.
2222 bool target_able(MONSTER_IDX m_idx)
2224 monster_type *m_ptr = &m_list[m_idx];
2226 /* Monster must be alive */
2227 if (!m_ptr->r_idx) return (FALSE);
2229 /* Hack -- no targeting hallucinations */
2230 if (p_ptr->image) return (FALSE);
2232 /* Monster must be visible */
2233 if (!m_ptr->ml) return (FALSE);
2235 if (p_ptr->riding && (p_ptr->riding == m_idx)) return (TRUE);
2237 /* Monster must be projectable */
2238 if (!projectable(p_ptr->y, p_ptr->x, m_ptr->fy, m_ptr->fx)) return (FALSE);
2240 /* Hack -- Never target trappers */
2241 /* if (CLEAR_ATTR && (CLEAR_CHAR)) return (FALSE); */
2251 * Update (if necessary) and verify (if possible) the target.
2253 * We return TRUE if the target is "okay" and FALSE otherwise.
2255 bool target_okay(void)
2257 /* Accept stationary targets */
2258 if (target_who < 0) return (TRUE);
2260 /* Check moving targets */
2263 /* Accept reasonable targets */
2264 if (target_able(target_who))
2266 monster_type *m_ptr = &m_list[target_who];
2268 /* Acquire monster location */
2269 target_row = m_ptr->fy;
2270 target_col = m_ptr->fx;
2277 /* Assume no target */
2283 * Sorting hook -- comp function -- by "distance to player"
2285 * We use "u" and "v" to point to arrays of "x" and "y" positions,
2286 * and sort the arrays by double-distance to the player.
2288 static bool ang_sort_comp_distance(vptr u, vptr v, int a, int b)
2290 POSITION *x = (POSITION*)(u);
2291 POSITION *y = (POSITION*)(v);
2293 POSITION da, db, kx, ky;
2295 /* Absolute distance components */
2296 kx = x[a]; kx -= p_ptr->x; kx = ABS(kx);
2297 ky = y[a]; ky -= p_ptr->y; ky = ABS(ky);
2299 /* Approximate Double Distance to the first point */
2300 da = ((kx > ky) ? (kx + kx + ky) : (ky + ky + kx));
2302 /* Absolute distance components */
2303 kx = x[b]; kx -= p_ptr->x; kx = ABS(kx);
2304 ky = y[b]; ky -= p_ptr->y; ky = ABS(ky);
2306 /* Approximate Double Distance to the first point */
2307 db = ((kx > ky) ? (kx + kx + ky) : (ky + ky + kx));
2309 /* Compare the distances */
2315 * Sorting hook -- comp function -- by importance level of grids
2317 * We use "u" and "v" to point to arrays of "x" and "y" positions,
2318 * and sort the arrays by level of monster
2320 static bool ang_sort_comp_importance(vptr u, vptr v, int a, int b)
2322 POSITION *x = (POSITION*)(u);
2323 POSITION *y = (POSITION*)(v);
2324 cave_type *ca_ptr = &cave[y[a]][x[a]];
2325 cave_type *cb_ptr = &cave[y[b]][x[b]];
2326 monster_type *ma_ptr = &m_list[ca_ptr->m_idx];
2327 monster_type *mb_ptr = &m_list[cb_ptr->m_idx];
2328 monster_race *ap_ra_ptr, *ap_rb_ptr;
2330 /* The player grid */
2331 if (y[a] == p_ptr->y && x[a] == p_ptr->x) return TRUE;
2332 if (y[b] == p_ptr->y && x[b] == p_ptr->x) return FALSE;
2334 /* Extract monster race */
2335 if (ca_ptr->m_idx && ma_ptr->ml) ap_ra_ptr = &r_info[ma_ptr->ap_r_idx];
2336 else ap_ra_ptr = NULL;
2337 if (cb_ptr->m_idx && mb_ptr->ml) ap_rb_ptr = &r_info[mb_ptr->ap_r_idx];
2338 else ap_rb_ptr = NULL;
2340 if (ap_ra_ptr && !ap_rb_ptr) return TRUE;
2341 if (!ap_ra_ptr && ap_rb_ptr) return FALSE;
2343 /* Compare two monsters */
2344 if (ap_ra_ptr && ap_rb_ptr)
2346 /* Unique monsters first */
2347 if ((ap_ra_ptr->flags1 & RF1_UNIQUE) && !(ap_rb_ptr->flags1 & RF1_UNIQUE)) return TRUE;
2348 if (!(ap_ra_ptr->flags1 & RF1_UNIQUE) && (ap_rb_ptr->flags1 & RF1_UNIQUE)) return FALSE;
2350 /* Shadowers first (あやしい影) */
2351 if ((ma_ptr->mflag2 & MFLAG2_KAGE) && !(mb_ptr->mflag2 & MFLAG2_KAGE)) return TRUE;
2352 if (!(ma_ptr->mflag2 & MFLAG2_KAGE) && (mb_ptr->mflag2 & MFLAG2_KAGE)) return FALSE;
2354 /* Unknown monsters first */
2355 if (!ap_ra_ptr->r_tkills && ap_rb_ptr->r_tkills) return TRUE;
2356 if (ap_ra_ptr->r_tkills && !ap_rb_ptr->r_tkills) return FALSE;
2358 /* Higher level monsters first (if known) */
2359 if (ap_ra_ptr->r_tkills && ap_rb_ptr->r_tkills)
2361 if (ap_ra_ptr->level > ap_rb_ptr->level) return TRUE;
2362 if (ap_ra_ptr->level < ap_rb_ptr->level) return FALSE;
2365 /* Sort by index if all conditions are same */
2366 if (ma_ptr->ap_r_idx > mb_ptr->ap_r_idx) return TRUE;
2367 if (ma_ptr->ap_r_idx < mb_ptr->ap_r_idx) return FALSE;
2370 /* An object get higher priority */
2371 if (cave[y[a]][x[a]].o_idx && !cave[y[b]][x[b]].o_idx) return TRUE;
2372 if (!cave[y[a]][x[a]].o_idx && cave[y[b]][x[b]].o_idx) return FALSE;
2374 /* Priority from the terrain */
2375 if (f_info[ca_ptr->feat].priority > f_info[cb_ptr->feat].priority) return TRUE;
2376 if (f_info[ca_ptr->feat].priority < f_info[cb_ptr->feat].priority) return FALSE;
2378 /* If all conditions are same, compare distance */
2379 return ang_sort_comp_distance(u, v, a, b);
2384 * Sorting hook -- swap function -- by "distance to player"
2386 * We use "u" and "v" to point to arrays of "x" and "y" positions,
2387 * and sort the arrays by distance to the player.
2389 static void ang_sort_swap_distance(vptr u, vptr v, int a, int b)
2391 POSITION *x = (POSITION*)(u);
2392 POSITION *y = (POSITION*)(v);
2410 * Hack -- help "select" a location (see below)
2412 static POSITION_IDX target_pick(POSITION y1, POSITION x1, POSITION dy, POSITION dx)
2415 POSITION x2, y2, x3, y3, x4, y4;
2416 POSITION_IDX b_i = -1, b_v = 9999;
2419 /* Scan the locations */
2420 for (i = 0; i < temp_n; i++)
2426 /* Directed distance */
2430 /* Verify quadrant */
2431 if (dx && (x3 * dx <= 0)) continue;
2432 if (dy && (y3 * dy <= 0)) continue;
2434 /* Absolute distance */
2438 /* Verify quadrant */
2439 if (dy && !dx && (x4 > y4)) continue;
2440 if (dx && !dy && (y4 > x4)) continue;
2442 /* Approximate Double Distance */
2443 v = ((x4 > y4) ? (x4 + x4 + y4) : (y4 + y4 + x4));
2445 /* Penalize location */
2448 if ((b_i >= 0) && (v >= b_v)) continue;
2458 * Hack -- determine if a given location is "interesting"
2460 static bool target_set_accept(POSITION y, POSITION x)
2463 OBJECT_IDX this_o_idx, next_o_idx = 0;
2466 if (!(in_bounds(y, x))) return (FALSE);
2468 /* Player grid is always interesting */
2469 if (player_bold(y, x)) return (TRUE);
2471 /* Handle hallucination */
2472 if (p_ptr->image) return (FALSE);
2474 /* Examine the grid */
2475 c_ptr = &cave[y][x];
2477 /* Visible monsters */
2480 monster_type *m_ptr = &m_list[c_ptr->m_idx];
2482 /* Visible monsters */
2483 if (m_ptr->ml) return (TRUE);
2486 /* Scan all objects in the grid */
2487 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
2490 o_ptr = &o_list[this_o_idx];
2492 /* Acquire next object */
2493 next_o_idx = o_ptr->next_o_idx;
2495 /* Memorized object */
2496 if (o_ptr->marked & OM_FOUND) return (TRUE);
2499 /* Interesting memorized features */
2500 if (c_ptr->info & (CAVE_MARK))
2502 /* Notice object features */
2503 if (c_ptr->info & CAVE_OBJECT) return (TRUE);
2505 /* Feature code (applying "mimic" field) */
2506 if (have_flag(f_info[get_feat_mimic(c_ptr)].flags, FF_NOTICE)) return TRUE;
2514 * Prepare the "temp" array for "target_set"
2516 * Return the number of target_able monsters in the set.
2518 static void target_set_prepare(BIT_FLAGS mode)
2521 POSITION min_hgt, max_hgt, min_wid, max_wid;
2523 if (mode & TARGET_KILL)
2526 min_hgt = MAX((p_ptr->y - MAX_RANGE), 0);
2527 max_hgt = MIN((p_ptr->y + MAX_RANGE), cur_hgt - 1);
2528 min_wid = MAX((p_ptr->x - MAX_RANGE), 0);
2529 max_wid = MIN((p_ptr->x + MAX_RANGE), cur_wid - 1);
2531 else /* not targetting */
2534 min_hgt = panel_row_min;
2535 max_hgt = panel_row_max;
2536 min_wid = panel_col_min;
2537 max_wid = panel_col_max;
2540 /* Reset "temp" array */
2543 /* Scan the current panel */
2544 for (y = min_hgt; y <= max_hgt; y++)
2546 for (x = min_wid; x <= max_wid; x++)
2550 /* Require "interesting" contents */
2551 if (!target_set_accept(y, x)) continue;
2553 c_ptr = &cave[y][x];
2555 /* Require target_able monsters for "TARGET_KILL" */
2556 if ((mode & (TARGET_KILL)) && !target_able(c_ptr->m_idx)) continue;
2558 if ((mode & (TARGET_KILL)) && !target_pet && is_pet(&m_list[c_ptr->m_idx])) continue;
2560 /* Save the location */
2567 /* Set the sort hooks */
2568 if (mode & (TARGET_KILL))
2570 /* Target the nearest monster for shooting */
2571 ang_sort_comp = ang_sort_comp_distance;
2572 ang_sort_swap = ang_sort_swap_distance;
2576 /* Look important grids first in Look command */
2577 ang_sort_comp = ang_sort_comp_importance;
2578 ang_sort_swap = ang_sort_swap_distance;
2581 /* Sort the positions */
2582 ang_sort(temp_x, temp_y, temp_n);
2584 if (p_ptr->riding && target_pet && (temp_n > 1) && (mode & (TARGET_KILL)))
2589 temp_y[0] = temp_y[1];
2592 temp_x[0] = temp_x[1];
2597 void target_set_prepare_look(void){
2598 target_set_prepare(TARGET_LOOK);
2603 * Evaluate number of kill needed to gain level
2605 static void evaluate_monster_exp(char *buf, monster_type *m_ptr)
2607 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
2609 s32b exp_mon, exp_adv;
2610 u32b exp_mon_frac, exp_adv_frac;
2612 if ((p_ptr->lev >= PY_MAX_LEVEL) || (p_ptr->prace == RACE_ANDROID))
2617 else if (!ap_r_ptr->r_tkills || (m_ptr->mflag2 & MFLAG2_KAGE))
2627 /* The monster's experience point (assuming average monster speed) */
2628 exp_mon = ap_r_ptr->mexp * ap_r_ptr->level;
2630 s64b_div(&exp_mon, &exp_mon_frac, 0, (p_ptr->max_plv + 2));
2633 /* Total experience value for next level */
2634 exp_adv = player_exp[p_ptr->lev -1] * p_ptr->expfact;
2636 s64b_div(&exp_adv, &exp_adv_frac, 0, 100);
2638 /* Experience value need to get */
2639 s64b_sub(&exp_adv, &exp_adv_frac, p_ptr->exp, p_ptr->exp_frac);
2642 /* You need to kill at least one monster to get any experience */
2643 s64b_add(&exp_adv, &exp_adv_frac, exp_mon, exp_mon_frac);
2644 s64b_sub(&exp_adv, &exp_adv_frac, 0, 1);
2646 /* Extract number of monsters needed */
2647 s64b_div(&exp_adv, &exp_adv_frac, exp_mon, exp_mon_frac);
2649 /* If 999 or more monsters needed, only display "999". */
2650 num = MIN(999, exp_adv_frac);
2652 /* Display the number */
2653 sprintf(buf,"%03ld", (long int)num);
2657 bool show_gold_on_floor = FALSE;
2660 * Examine a grid, return a keypress.
2662 * The "mode" argument contains the "TARGET_LOOK" bit flag, which
2663 * indicates that the "space" key should scan through the contents
2664 * of the grid, instead of simply returning immediately. This lets
2665 * the "look" command get complete information, without making the
2666 * "target" command annoying.
2668 * The "info" argument contains the "commands" which should be shown
2669 * inside the "[xxx]" text. This string must never be empty, or grids
2670 * containing monsters will be displayed with an extra comma.
2672 * Note that if a monster is in the grid, we update both the monster
2673 * recall info and the health bar info to track that monster.
2675 * Eventually, we may allow multiple objects per grid, or objects
2676 * and terrain features in the same grid.
2678 * This function must handle blindness/hallucination.
2680 static char target_set_aux(POSITION y, POSITION x, BIT_FLAGS mode, cptr info)
2682 cave_type *c_ptr = &cave[y][x];
2683 OBJECT_IDX this_o_idx, next_o_idx = 0;
2684 cptr s1 = "", s2 = "", s3 = "", x_info = "";
2687 feature_type *f_ptr;
2688 char query = '\001';
2689 char out_val[MAX_NLEN+80];
2690 OBJECT_IDX floor_list[23];
2691 ITEM_NUMBER floor_num = 0;
2693 /* Scan all objects in the grid */
2696 floor_num = scan_floor(floor_list, y, x, 0x02);
2700 x_info = _("x物 ", "x,");
2704 /* Hack -- under the player */
2705 if (player_bold(y, x))
2721 s1 = _("ターゲット:", "Target:");
2724 /* Hack -- hallucination */
2727 cptr name = _("何か奇妙な物", "something strange");
2729 /* Display a message */
2731 sprintf(out_val, "%s%s%s%s [%s]", s1, name, s2, s3, info);
2733 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, name, info);
2737 move_cursor_relative(y, x);
2740 /* Stop on everything but "return" */
2741 if ((query != '\r') && (query != '\n')) return query;
2743 /* Repeat forever */
2748 /* Actual monsters */
2749 if (c_ptr->m_idx && m_list[c_ptr->m_idx].ml)
2751 monster_type *m_ptr = &m_list[c_ptr->m_idx];
2752 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
2754 bool recall = FALSE;
2759 /* Get the monster name ("a kobold") */
2760 monster_desc(m_name, m_ptr, MD_INDEF_VISIBLE);
2762 /* Hack -- track this monster race */
2763 monster_race_track(m_ptr->ap_r_idx);
2765 /* Hack -- health bar for this monster */
2766 health_track(c_ptr->m_idx);
2780 /* Recall on screen */
2781 screen_roff(m_ptr->ap_r_idx, 0);
2783 /* Hack -- Complete the prompt (again) */
2784 Term_addstr(-1, TERM_WHITE, format(_(" [r思 %s%s]", " [r,%s%s]"), x_info, info));
2792 /* Normal commands */
2793 if (query != 'r') break;
2798 /* Cleare recall text and repeat */
2804 /* Describe, and prompt for recall */
2805 evaluate_monster_exp(acount, m_ptr);
2808 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);
2810 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);
2816 move_cursor_relative(y, x);
2821 /* Normal commands */
2822 if (query != 'r') break;
2828 /* Always stop at "normal" keys */
2829 if ((query != '\r') && (query != '\n') && (query != ' ') && (query != 'x')) return query;
2831 /* Sometimes stop at "space" key */
2832 if ((query == ' ') && !(mode & (TARGET_LOOK))) return query;
2834 /* Change the intro */
2835 s1 = _("それは", "It is ");
2837 /* Hack -- take account of gender */
2838 if (ap_r_ptr->flags1 & (RF1_FEMALE)) s1 = _("彼女は", "She is ");
2839 else if (ap_r_ptr->flags1 & (RF1_MALE)) s1 = _("彼は", "He is ");
2841 /* Use a preposition */
2850 /* Scan all objects being carried */
2851 for (this_o_idx = m_ptr->hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
2853 char o_name[MAX_NLEN];
2856 o_ptr = &o_list[this_o_idx];
2858 /* Acquire next object */
2859 next_o_idx = o_ptr->next_o_idx;
2861 /* Obtain an object description */
2862 object_desc(o_name, o_ptr, 0);
2865 sprintf(out_val, "%s%s%s%s[%s]", s1, o_name, s2, s3, info);
2867 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, o_name, info);
2871 move_cursor_relative(y, x);
2874 /* Always stop at "normal" keys */
2875 if ((query != '\r') && (query != '\n') && (query != ' ') && (query != 'x')) return query;
2877 /* Sometimes stop at "space" key */
2878 if ((query == ' ') && !(mode & (TARGET_LOOK))) return query;
2880 /* Change the intro */
2881 s2 = _("をまた", "also carrying ");
2884 /* Use a preposition */
2901 char o_name[MAX_NLEN];
2904 o_ptr = &o_list[floor_list[0]];
2906 object_desc(o_name, o_ptr, 0);
2909 sprintf(out_val, "%s%s%s%s[%s]", s1, o_name, s2, s3, info);
2911 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, o_name, info);
2915 move_cursor_relative(y, x);
2924 /* Provide one cushion before item listing */
2927 /* Display rough information about items */
2929 sprintf(out_val, "%s %d個のアイテム%s%s ['x'で一覧, %s]", s1, (int)floor_num, s2, s3, info);
2931 sprintf(out_val, "%s%s%sa pile of %d items [x,%s]", s1, s2, s3, (int)floor_num, info);
2935 move_cursor_relative(y, x);
2940 /* No request for listing */
2941 if (query != 'x' && query != ' ') return query;
2945 /** Display list of items **/
2947 /* Continue scrolling list if requested */
2955 show_gold_on_floor = TRUE;
2956 (void)show_floor(0, y, x, &min_width);
2957 show_gold_on_floor = FALSE;
2961 sprintf(out_val, "%s %d個のアイテム%s%s [Enterで次へ, %s]", s1, (int)floor_num, s2, s3, info);
2963 sprintf(out_val, "%s%s%sa pile of %d items [Enter,%s]", s1, s2, s3, (int)floor_num, info);
2970 /* Exit unless 'Enter' */
2971 if (query != '\n' && query != '\r')
2976 /* Get the object being moved. */
2977 o_idx = c_ptr->o_idx;
2979 /* Only rotate a pile of two or more objects. */
2980 if (!(o_idx && o_list[o_idx].next_o_idx)) continue;
2982 /* Remove the first object from the list. */
2983 excise_object_idx(o_idx);
2985 /* Find end of the list. */
2987 while (o_list[i].next_o_idx)
2988 i = o_list[i].next_o_idx;
2990 /* Add after the last object. */
2991 o_list[i].next_o_idx = o_idx;
2993 /* Loop and re-display the list */
3000 /* Scan all objects in the grid */
3001 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
3004 o_ptr = &o_list[this_o_idx];
3006 /* Acquire next object */
3007 next_o_idx = o_ptr->next_o_idx;
3010 if (o_ptr->marked & OM_FOUND)
3012 char o_name[MAX_NLEN];
3017 /* Obtain an object description */
3018 object_desc(o_name, o_ptr, 0);
3021 sprintf(out_val, "%s%s%s%s[%s]", s1, o_name, s2, s3, info);
3023 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, o_name, info);
3027 move_cursor_relative(y, x);
3030 /* Always stop at "normal" keys */
3031 if ((query != '\r') && (query != '\n') && (query != ' ') && (query != 'x')) return query;
3033 /* Sometimes stop at "space" key */
3034 if ((query == ' ') && !(mode & TARGET_LOOK)) return query;
3036 /* Change the intro */
3037 s1 = _("それは", "It is ");
3040 if (o_ptr->number != 1) s1 = _("それらは", "They are ");
3054 /* Feature code (applying "mimic" field) */
3055 feat = get_feat_mimic(c_ptr);
3057 /* Require knowledge about grid, or ability to see grid */
3058 if (!(c_ptr->info & CAVE_MARK) && !player_can_see_bold(y, x))
3060 /* Forget feature */
3064 f_ptr = &f_info[feat];
3066 /* Terrain feature if needed */
3067 if (boring || have_flag(f_ptr->flags, FF_REMEMBER))
3071 /* Hack -- special handling for quest entrances */
3072 if (have_flag(f_ptr->flags, FF_QUEST_ENTER))
3074 /* Set the quest number temporary */
3075 IDX old_quest = p_ptr->inside_quest;
3078 /* Clear the text */
3079 for (j = 0; j < 10; j++) quest_text[j][0] = '\0';
3080 quest_text_line = 0;
3082 p_ptr->inside_quest = c_ptr->special;
3084 /* Get the quest text */
3085 init_flags = INIT_NAME_ONLY;
3087 process_dungeon_file("q_info.txt", 0, 0, 0, 0);
3089 name = format(_("クエスト「%s」(%d階相当)", "the entrance to the quest '%s'(level %d)"),
3090 quest[c_ptr->special].name, quest[c_ptr->special].level);
3092 /* Reset the old quest number */
3093 p_ptr->inside_quest = old_quest;
3096 /* Hack -- special handling for building doors */
3097 else if (have_flag(f_ptr->flags, FF_BLDG) && !p_ptr->inside_arena)
3099 name = building[f_ptr->subtype].name;
3101 else if (have_flag(f_ptr->flags, FF_ENTRANCE))
3103 name = format(_("%s(%d階相当)", "%s(level %d)"), d_text + d_info[c_ptr->special].text, d_info[c_ptr->special].mindepth);
3105 else if (have_flag(f_ptr->flags, FF_TOWN))
3107 name = town[c_ptr->special].name;
3109 else if (p_ptr->wild_mode && (feat == feat_floor))
3111 name = _("道", "road");
3115 name = f_name + f_ptr->name;
3121 ((!have_flag(f_ptr->flags, FF_MOVE) && !have_flag(f_ptr->flags, FF_CAN_FLY)) ||
3122 (!have_flag(f_ptr->flags, FF_LOS) && !have_flag(f_ptr->flags, FF_TREE)) ||
3123 have_flag(f_ptr->flags, FF_TOWN)))
3125 s2 = _("の中", "in ");
3128 /* Hack -- special introduction for store & building doors -KMW- */
3129 if (have_flag(f_ptr->flags, FF_STORE) ||
3130 have_flag(f_ptr->flags, FF_QUEST_ENTER) ||
3131 (have_flag(f_ptr->flags, FF_BLDG) && !p_ptr->inside_arena) ||
3132 have_flag(f_ptr->flags, FF_ENTRANCE))
3141 else if (have_flag(f_ptr->flags, FF_FLOOR) ||
3142 have_flag(f_ptr->flags, FF_TOWN) ||
3143 have_flag(f_ptr->flags, FF_SHALLOW) ||
3144 have_flag(f_ptr->flags, FF_DEEP))
3150 /* Pick proper indefinite article */
3151 s3 = (is_a_vowel(name[0])) ? "an " : "a ";
3155 /* Display a message */
3159 if (c_ptr->mimic) sprintf(f_idx_str, "%d/%d", c_ptr->feat, c_ptr->mimic);
3160 else sprintf(f_idx_str, "%d", c_ptr->feat);
3162 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]);
3164 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);
3169 sprintf(out_val, "%s%s%s%s[%s]", s1, name, s2, s3, info);
3171 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, name, info);
3175 move_cursor_relative(y, x);
3178 /* Always stop at "normal" keys */
3179 if ((query != '\r') && (query != '\n') && (query != ' ')) return query;
3182 /* Stop on everything but "return" */
3183 if ((query != '\r') && (query != '\n')) return query;
3185 /* Repeat forever */
3191 * Handle "target" and "look".
3193 * Note that this code can be called from "get_aim_dir()".
3195 * All locations must be on the current panel. Consider the use of
3196 * "panel_bounds()" to allow "off-panel" targets, perhaps by using
3197 * some form of "scrolling" the map around the cursor.
3198 * That is, consider the possibility of "auto-scrolling" the screen
3199 * while the cursor moves around. This may require changes in the
3200 * "update_monster()" code to allow "visibility" even if off panel, and
3201 * may require dynamic recalculation of the "temp" grid set.
3203 * Hack -- targeting/observing an "outer border grid" may induce
3204 * problems, so this is not currently allowed.
3206 * The player can use the direction keys to move among "interesting"
3207 * grids in a heuristic manner, or the "space", "+", and "-" keys to
3208 * move through the "interesting" grids in a sequential manner, or
3209 * can enter "location" mode, and use the direction keys to move one
3210 * grid at a time in any direction. The "t" (set target) command will
3211 * only target a monster (as opposed to a location) if the monster is
3212 * target_able and the "interesting" mode is being used.
3214 * The current grid is described using the "look" method above, and
3215 * a new command may be entered at any time, but note that if the
3216 * "TARGET_LOOK" bit flag is set (or if we are in "location" mode,
3217 * where "space" has no obvious meaning) then "space" will scan
3218 * through the description of the current grid until done, instead
3219 * of immediately jumping to the next "interesting" grid. This
3220 * allows the "target" command to retain its old semantics.
3222 * The "*", "+", and "-" keys may always be used to jump immediately
3223 * to the next (or previous) interesting grid, in the proper mode.
3225 * The "return" key may always be used to scan through a complete
3226 * grid description (forever).
3228 * This command will cancel any old target, even if used from
3229 * inside the "look" command.
3231 bool target_set(BIT_FLAGS mode)
3234 POSITION y = p_ptr->y;
3235 POSITION x = p_ptr->x;
3247 get_screen_size(&wid, &hgt);
3253 /* Cancel tracking */
3254 /* health_track(0); */
3256 if (rogue_like_commands)
3265 /* Prepare the "temp" array */
3266 target_set_prepare(mode);
3268 /* Start near the player */
3274 /* Interesting grids */
3281 change_panel_xy(y, x);
3283 if (!(mode & TARGET_LOOK)) prt_path(y, x);
3286 c_ptr = &cave[y][x];
3289 if (target_able(c_ptr->m_idx))
3291 strcpy(info, _("q止 t決 p自 o現 +次 -前", "q,t,p,o,+,-,<dir>"));
3294 /* Dis-allow target */
3297 strcpy(info, _("q止 p自 o現 +次 -前", "q,p,o,+,-,<dir>"));
3303 sprintf(cheatinfo, " LOS:%d, PROJECTABLE:%d",
3304 los(p_ptr->y, p_ptr->x, y, x),
3305 projectable(p_ptr->y, p_ptr->x, y, x));
3306 strcat(info, cheatinfo);
3309 /* Describe and Prompt */
3311 query = target_set_aux(y, x, mode, info);
3315 /* Cancel tracking */
3316 /* health_track(0); */
3318 /* Assume no "direction" */
3323 if (query == '\r') query = 't';
3341 if (target_able(c_ptr->m_idx))
3343 health_track(c_ptr->m_idx);
3344 target_who = c_ptr->m_idx;
3363 if (!expand_list) done = TRUE;
3373 if (!expand_list) done = TRUE;
3380 /* Recenter the map around the player */
3383 p_ptr->update |= (PU_MONSTERS);
3385 p_ptr->redraw |= (PR_MAP);
3387 p_ptr->window |= (PW_OVERHEAD);
3390 /* Recalculate interesting grids */
3391 target_set_prepare(mode);
3410 if(query == same_key)
3415 if (!expand_list) done = TRUE;
3420 /* Extract the action (if any) */
3421 d = get_keymap_dir(query);
3428 /* Hack -- move around */
3431 /* Modified to scroll to monster */
3432 POSITION y2 = panel_row_min;
3433 POSITION x2 = panel_col_min;
3435 /* Find a new monster */
3436 i = target_pick(temp_y[m], temp_x[m], ddy[d], ddx[d]);
3438 /* Request to target past last interesting grid */
3439 while (flag && (i < 0))
3441 /* Note the change */
3442 if (change_panel(ddy[d], ddx[d]))
3447 /* Recalculate interesting grids */
3448 target_set_prepare(mode);
3450 /* Look at interesting grids */
3453 /* Find a new monster */
3454 i = target_pick(v, u, ddy[d], ddx[d]);
3460 /* Nothing interesting */
3466 /* Restore previous position */
3469 panel_bounds_center();
3471 p_ptr->update |= (PU_MONSTERS);
3473 p_ptr->redraw |= (PR_MAP);
3475 p_ptr->window |= (PW_OVERHEAD);
3478 /* Recalculate interesting grids */
3479 target_set_prepare(mode);
3481 /* Look at boring grids */
3488 /* Do not move horizontally if unnecessary */
3489 if (((x < panel_col_min + wid / 2) && (dx > 0)) ||
3490 ((x > panel_col_min + wid / 2) && (dx < 0)))
3495 /* Do not move vertically if unnecessary */
3496 if (((y < panel_row_min + hgt / 2) && (dy > 0)) ||
3497 ((y > panel_row_min + hgt / 2) && (dy < 0)))
3502 /* Apply the motion */
3503 if ((y >= panel_row_min+hgt) || (y < panel_row_min) ||
3504 (x >= panel_col_min+wid) || (x < panel_col_min))
3506 if (change_panel(dy, dx)) target_set_prepare(mode);
3509 /* Slide into legality */
3510 if (x >= cur_wid-1) x = cur_wid - 2;
3511 else if (x <= 0) x = 1;
3513 /* Slide into legality */
3514 if (y >= cur_hgt-1) y = cur_hgt- 2;
3515 else if (y <= 0) y = 1;
3524 /* Arbitrary grids */
3527 bool move_fast = FALSE;
3529 if (!(mode & TARGET_LOOK)) prt_path(y, x);
3532 c_ptr = &cave[y][x];
3534 /* Default prompt */
3535 strcpy(info, _("q止 t決 p自 m近 +次 -前", "q,t,p,m,+,-,<dir>"));
3540 sprintf(cheatinfo, " LOS:%d, PROJECTABLE:%d",
3541 los(p_ptr->y, p_ptr->x, y, x),
3542 projectable(p_ptr->y, p_ptr->x, y, x));
3543 strcat(info, cheatinfo);
3546 /* Describe and Prompt (enable "TARGET_LOOK") */
3547 while ((query = target_set_aux(y, x, mode | TARGET_LOOK, info)) == 0);
3549 /* Cancel tracking */
3550 /* health_track(0); */
3552 /* Assume no direction */
3557 if (query == '\r') query = 't';
3560 /* Analyze the keypress */
3584 /* Recenter the map around the player */
3587 p_ptr->update |= (PU_MONSTERS);
3589 p_ptr->redraw |= (PR_MAP);
3591 p_ptr->window |= (PW_OVERHEAD);
3594 /* Recalculate interesting grids */
3595 target_set_prepare(mode);
3617 /* Pick a nearby monster */
3618 for (i = 0; i < temp_n; i++)
3620 t = distance(y, x, temp_y[i], temp_x[i]);
3630 /* Nothing interesting */
3631 if (bd == 999) flag = FALSE;
3638 /* Extract the action (if any) */
3639 d = get_keymap_dir(query);
3641 /* XTRA HACK MOVEFAST */
3642 if (isupper(query)) move_fast = TRUE;
3649 /* Handle "direction" */
3655 /* XTRA HACK MOVEFAST */
3658 int mag = MIN(wid / 2, hgt / 2);
3668 /* Do not move horizontally if unnecessary */
3669 if (((x < panel_col_min + wid / 2) && (dx > 0)) ||
3670 ((x > panel_col_min + wid / 2) && (dx < 0)))
3675 /* Do not move vertically if unnecessary */
3676 if (((y < panel_row_min + hgt / 2) && (dy > 0)) ||
3677 ((y > panel_row_min + hgt / 2) && (dy < 0)))
3682 /* Apply the motion */
3683 if ((y >= panel_row_min + hgt) || (y < panel_row_min) ||
3684 (x >= panel_col_min + wid) || (x < panel_col_min))
3686 if (change_panel(dy, dx)) target_set_prepare(mode);
3689 /* Slide into legality */
3690 if (x >= cur_wid-1) x = cur_wid - 2;
3691 else if (x <= 0) x = 1;
3693 /* Slide into legality */
3694 if (y >= cur_hgt-1) y = cur_hgt- 2;
3695 else if (y <= 0) y = 1;
3703 /* Clear the top line */
3706 /* Recenter the map around the player */
3709 p_ptr->update |= (PU_MONSTERS);
3711 p_ptr->redraw |= (PR_MAP);
3713 p_ptr->window |= (PW_OVERHEAD);
3716 /* Failure to set target */
3717 if (!target_who) return (FALSE);
3725 * Get an "aiming direction" from the user.
3727 * The "dir" is loaded with 1,2,3,4,6,7,8,9 for "actual direction", and
3728 * "0" for "current target", and "-1" for "entry aborted".
3730 * Note that "Force Target", if set, will pre-empt user interaction,
3731 * if there is a usable target already set.
3733 * Note that confusion over-rides any (explicit?) user choice.
3735 bool get_aim_dir(DIRECTION *dp)
3744 /* Global direction */
3747 /* Hack -- auto-target if requested */
3748 if (use_old_target && target_okay()) dir = 5;
3750 if (repeat_pull(&code))
3755 if (!(code == 5 && !target_okay()))
3757 /* return (TRUE); */
3758 dir = (DIRECTION)code;
3761 *dp = (DIRECTION)code;
3763 /* Ask until satisfied */
3766 /* Choose a prompt */
3769 p = _("方向 ('*'でターゲット選択, ESCで中断)? ", "Direction ('*' to choose a target, Escape to cancel)? ");
3773 p = _("方向 ('5'でターゲットへ, '*'でターゲット再選択, ESCで中断)? ", "Direction ('5' for target, '*' to re-target, Escape to cancel)? ");
3776 /* Get a command (or Cancel) */
3777 if (!get_com(p, &command, TRUE)) break;
3781 if (command == '\r') command = 't';
3784 /* Convert various keys to "standard" keys */
3787 /* Use current target */
3798 /* Set new target */
3803 if (target_set(TARGET_KILL)) dir = 5;
3809 /* Extract the action (if any) */
3810 dir = get_keymap_dir(command);
3816 /* Verify requested targets */
3817 if ((dir == 5) && !target_okay()) dir = 0;
3826 project_length = 0; /* reset to default */
3830 /* Save the direction */
3833 /* Check for confusion */
3834 if (p_ptr->confused)
3836 /* Random direction */
3837 dir = ddd[randint0(8)];
3840 /* Notice confusion */
3841 if (command_dir != dir)
3844 msg_print(_("あなたは混乱している。", "You are confused."));
3847 /* Save direction */
3850 /* repeat_push(dir); */
3851 repeat_push((COMMAND_CODE)command_dir);
3853 /* A "valid" direction was entered */
3858 bool get_direction(DIRECTION *dp, bool allow_under, bool with_steed)
3866 /* Global direction */
3869 if (repeat_pull(&code))
3871 dir = (DIRECTION)code;
3872 /* return (TRUE); */
3874 *dp = (DIRECTION)code;
3878 prompt = _("方向 ('.'足元, ESCで中断)? ", "Direction ('.' at feet, Escape to cancel)? ");
3882 prompt = _("方向 (ESCで中断)? ", "Direction (Escape to cancel)? ");
3885 /* Get a direction */
3890 /* Get a command (or Cancel) */
3891 if (!get_com(prompt, &ch, TRUE)) break;
3894 if ((allow_under) && ((ch == '5') || (ch == '-') || (ch == '.')))
3900 /* Look up the direction */
3901 dir = get_keymap_dir(ch);
3907 /* Prevent weirdness */
3908 if ((dir == 5) && (!allow_under)) dir = 0;
3911 if (!dir) return (FALSE);
3913 /* Save desired direction */
3916 /* Apply "confusion" */
3917 if (p_ptr->confused)
3919 /* Standard confusion */
3920 if (randint0(100) < 75)
3922 /* Random direction */
3923 dir = ddd[randint0(8)];
3926 else if (p_ptr->riding && with_steed)
3928 monster_type *m_ptr = &m_list[p_ptr->riding];
3929 monster_race *r_ptr = &r_info[m_ptr->r_idx];
3931 if (MON_CONFUSED(m_ptr))
3933 /* Standard confusion */
3934 if (randint0(100) < 75)
3936 /* Random direction */
3937 dir = ddd[randint0(8)];
3940 else if ((r_ptr->flags1 & RF1_RAND_50) && (r_ptr->flags1 & RF1_RAND_25) && (randint0(100) < 50))
3942 /* Random direction */
3943 dir = ddd[randint0(8)];
3945 else if ((r_ptr->flags1 & RF1_RAND_50) && (randint0(100) < 25))
3947 /* Random direction */
3948 dir = ddd[randint0(8)];
3952 /* Notice confusion */
3953 if (command_dir != dir)
3955 if (p_ptr->confused)
3958 msg_print(_("あなたは混乱している。", "You are confused."));
3963 monster_type *m_ptr = &m_list[p_ptr->riding];
3965 monster_desc(m_name, m_ptr, 0);
3966 if (MON_CONFUSED(m_ptr))
3968 msg_format(_("%sは混乱している。", "%^s is confusing."), m_name);
3972 msg_format(_("%sは思い通りに動いてくれない。", "You cannot control %s."), m_name);
3977 /* Save direction */
3980 /* repeat_push(dir); */
3981 repeat_push((COMMAND_CODE)command_dir);
3988 * @brief 進行方向を指定する(騎乗対象の混乱の影響を受ける) / Request a "movement" direction (1,2,3,4,6,7,8,9) from the user,
3989 * and place it into "command_dir", unless we already have one.
3991 * This function should be used for all "repeatable" commands, such as
3992 * run, walk, open, close, bash, disarm, spike, tunnel, etc, as well
3993 * as all commands which must reference a grid adjacent to the player,
3994 * and which may not reference the grid under the player. Note that,
3995 * for example, it is no longer possible to "disarm" or "open" chests
3996 * in the same grid as the player.
3998 * Direction "5" is illegal and will (cleanly) abort the command.
4000 * This function tracks and uses the "global direction", and uses
4001 * that as the "desired direction", to which "confusion" is applied.
4003 bool get_rep_dir(DIRECTION *dp, bool under)
4011 /* Global direction */
4014 if (repeat_pull(&code))
4016 dir = (DIRECTION)code;
4017 /* return (TRUE); */
4019 *dp = (DIRECTION)code;
4023 prompt = _("方向 ('.'足元, ESCで中断)? ", "Direction ('.' at feet, Escape to cancel)? ");
4027 prompt = _("方向 (ESCで中断)? ", "Direction (Escape to cancel)? ");
4030 /* Get a direction */
4035 /* Get a command (or Cancel) */
4036 if (!get_com(prompt, &ch, TRUE)) break;
4039 if ((under) && ((ch == '5') || (ch == '-') || (ch == '.')))
4045 /* Look up the direction */
4046 dir = get_keymap_dir(ch);
4052 /* Prevent weirdness */
4053 if ((dir == 5) && (!under)) dir = 0;
4056 if (!dir) return (FALSE);
4058 /* Save desired direction */
4061 /* Apply "confusion" */
4062 if (p_ptr->confused)
4064 /* Standard confusion */
4065 if (randint0(100) < 75)
4067 /* Random direction */
4068 dir = ddd[randint0(8)];
4071 else if (p_ptr->riding)
4073 monster_type *m_ptr = &m_list[p_ptr->riding];
4074 monster_race *r_ptr = &r_info[m_ptr->r_idx];
4076 if (MON_CONFUSED(m_ptr))
4078 /* Standard confusion */
4079 if (randint0(100) < 75)
4081 /* Random direction */
4082 dir = ddd[randint0(8)];
4085 else if ((r_ptr->flags1 & RF1_RAND_50) && (r_ptr->flags1 & RF1_RAND_25) && (randint0(100) < 50))
4087 /* Random direction */
4088 dir = ddd[randint0(8)];
4090 else if ((r_ptr->flags1 & RF1_RAND_50) && (randint0(100) < 25))
4092 /* Random direction */
4093 dir = ddd[randint0(8)];
4097 /* Notice confusion */
4098 if (command_dir != dir)
4100 if (p_ptr->confused)
4103 msg_print(_("あなたは混乱している。", "You are confused."));
4108 monster_type *m_ptr = &m_list[p_ptr->riding];
4110 monster_desc(m_name, m_ptr, 0);
4111 if (MON_CONFUSED(m_ptr))
4113 msg_format(_("%sは混乱している。", "%^s is confusing."), m_name);
4117 msg_format(_("%sは思い通りに動いてくれない。", "You cannot control %s."), m_name);
4122 /* Save direction */
4125 /* repeat_push(dir); */
4126 repeat_push((COMMAND_CODE)command_dir);
4132 void gain_level_reward(int chosen_reward)
4136 char wrath_reason[32] = "";
4137 int nasty_chance = 6;
4138 OBJECT_TYPE_VALUE dummy = 0;
4139 OBJECT_SUBTYPE_VALUE dummy2 = 0;
4142 char o_name[MAX_NLEN];
4148 if (multi_rew) return;
4149 else multi_rew = TRUE;
4153 if (p_ptr->lev == 13) nasty_chance = 2;
4154 else if (!(p_ptr->lev % 13)) nasty_chance = 3;
4155 else if (!(p_ptr->lev % 14)) nasty_chance = 12;
4157 if (one_in_(nasty_chance))
4158 type = randint1(20); /* Allow the 'nasty' effects */
4160 type = randint1(15) + 5; /* Or disallow them */
4162 if (type < 1) type = 1;
4163 if (type > 20) type = 20;
4167 sprintf(wrath_reason, _("%sの怒り", "the Wrath of %s"), chaos_patrons[p_ptr->chaos_patron]);
4169 effect = chaos_rewards[p_ptr->chaos_patron][type];
4171 if (one_in_(6) && !chosen_reward)
4173 msg_format(_("%^sは褒美としてあなたを突然変異させた。", "%^s rewards you with a mutation!"), chaos_patrons[p_ptr->chaos_patron]);
4174 (void)gain_random_mutation(0);
4175 reward = _("変異した。", "mutation");
4179 switch (chosen_reward ? chosen_reward : effect)
4184 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4185 msg_print(_("「汝、新たなる姿を必要とせり!」", "'Thou needst a new form, mortal!'"));
4188 reward = _("変異した。", "polymorphing");
4193 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4194 msg_print(_("「汝は良く行いたり!続けよ!」", "'Well done, mortal! Lead on!'"));
4196 if (p_ptr->prace == RACE_ANDROID)
4198 msg_print(_("しかし何も起こらなかった。", "But, nothing happen."));
4200 else if (p_ptr->exp < PY_MAX_EXP)
4202 s32b ee = (p_ptr->exp / 2) + 10;
4203 if (ee > 100000L) ee = 100000L;
4204 msg_print(_("更に経験を積んだような気がする。", "You feel more experienced."));
4207 reward = _("経験値を得た", "experience");
4213 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4214 msg_print(_("「下僕よ、汝それに値せず。」", "'Thou didst not deserve that, slave.'"));
4216 if (p_ptr->prace == RACE_ANDROID)
4218 msg_print(_("しかし何も起こらなかった。", "But, nothing happen."));
4222 lose_exp(p_ptr->exp / 6);
4223 reward = _("経験値を失った。", "losing experience");
4229 msg_format("%sの声がささやいた:",
4230 chaos_patrons[p_ptr->chaos_patron]);
4232 msg_format("The voice of %s whispers:",
4233 chaos_patrons[p_ptr->chaos_patron]);
4236 msg_print(_("「我が与えし物を賢明に使うべし。」", "'Use my gift wisely.'"));
4238 acquirement(p_ptr->y, p_ptr->x, 1, FALSE, FALSE, FALSE);
4239 reward = _("上質なアイテムを手に入れた。", "a good item");
4244 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4245 msg_print(_("「我が与えし物を賢明に使うべし。」", "'Use my gift wisely.'"));
4247 acquirement(p_ptr->y, p_ptr->x, 1, TRUE, FALSE, FALSE);
4248 reward = _("高級品のアイテムを手に入れた。", "an excellent item");
4253 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4254 msg_print(_("「汝の行いは貴き剣に値せり。」", "'Thy deed hath earned thee a worthy blade.'"));
4257 switch (randint1(p_ptr->lev))
4263 dummy2 = SV_MAIN_GAUCHE;
4272 dummy2 = SV_SMALL_SWORD;
4275 dummy2 = SV_BASILLARD;
4277 case 11: case 12: case 13:
4278 dummy2 = SV_SHORT_SWORD;
4284 dummy2 = SV_CUTLASS;
4287 dummy2 = SV_WAKIZASHI;
4290 dummy2 = SV_KHOPESH;
4296 dummy2 = SV_BROAD_SWORD;
4299 dummy2 = SV_LONG_SWORD;
4302 dummy2 = SV_SCIMITAR;
4305 dummy2 = SV_NINJATO;
4311 dummy2 = SV_BASTARD_SWORD;
4314 dummy2 = SV_GREAT_SCIMITAR;
4317 dummy2 = SV_CLAYMORE;
4320 dummy2 = SV_ESPADON;
4323 dummy2 = SV_TWO_HANDED_SWORD;
4326 dummy2 = SV_FLAMBERGE;
4329 dummy2 = SV_NO_DACHI;
4332 dummy2 = SV_EXECUTIONERS_SWORD;
4335 dummy2 = SV_ZWEIHANDER;
4338 dummy2 = SV_HAYABUSA;
4341 dummy2 = SV_BLADE_OF_CHAOS;
4344 object_prep(q_ptr, lookup_kind(dummy, dummy2));
4345 q_ptr->to_h = 3 + randint1(dun_level) % 10;
4346 q_ptr->to_d = 3 + randint1(dun_level) % 10;
4347 one_resistance(q_ptr);
4348 q_ptr->name2 = EGO_CHAOTIC;
4350 /* Drop it in the dungeon */
4351 (void)drop_near(q_ptr, -1, p_ptr->y, p_ptr->x);
4352 reward = _("(混沌)の武器を手に入れた。", "chaos weapon");
4357 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4358 msg_print(_("「汝の行いは貴き報いに値せり。」", "'Thy deed hath earned thee a worthy reward.'"));
4360 acquirement(p_ptr->y, p_ptr->x, randint1(2) + 1, FALSE, FALSE, FALSE);
4361 reward = _("上質なアイテムを手に入れた。", "good items");
4366 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4367 msg_print(_("「下僕よ、汝の献身への我が惜しみ無き報いを見るがよい。」", "'Behold, mortal, how generously I reward thy loyalty.'"));
4369 acquirement(p_ptr->y, p_ptr->x, randint1(2) + 1, TRUE, FALSE, FALSE);
4370 reward = _("高級品のアイテムを手に入れた。", "excellent items");
4375 msg_format("%sの声が轟き渡った:", chaos_patrons[p_ptr->chaos_patron]);
4377 msg_format("The voice of %s thunders:", chaos_patrons[p_ptr->chaos_patron]);
4380 msg_print(_("「下僕よ、汝傲慢なり。」", "'Thou art growing arrogant, mortal.'"));
4382 (void)activate_ty_curse(FALSE, &count);
4383 reward = _("禍々しい呪いをかけられた。", "cursing");
4388 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4389 msg_print(_("「我が下僕たちよ、かの傲慢なる者を倒すべし!」", "'My pets, destroy the arrogant mortal!'"));
4391 for (dummy = 0; dummy < randint1(5) + 1; dummy++)
4393 (void)summon_specific(0, p_ptr->y, p_ptr->x, dun_level, 0, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET));
4395 reward = _("モンスターを召喚された。", "summoning hostile monsters");
4401 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4402 msg_print(_("「汝、より強き敵を必要とせり!」", "'Thou needst worthier opponents!'"));
4404 activate_hi_summon(p_ptr->y, p_ptr->x, FALSE);
4405 reward = _("モンスターを召喚された。", "summoning many hostile monsters");
4411 msg_format("%sの声が響き渡った:",
4412 chaos_patrons[p_ptr->chaos_patron]);
4414 msg_format("The voice of %s booms out:",
4415 chaos_patrons[p_ptr->chaos_patron]);
4418 msg_print(_("「死と破壊こそ我が喜びなり!」", "'Death and destruction! This pleaseth me!'"));
4421 reward = _("カオスの力が渦巻いた。", "calling chaos");
4427 msg_format("%sの声が鳴り響いた:",
4428 chaos_patrons[p_ptr->chaos_patron]);
4430 msg_format("The voice of %s rings out:",
4431 chaos_patrons[p_ptr->chaos_patron]);
4434 msg_print(_("「留まるのだ、下僕よ。余が汝の肉体を鍛えん。」", "'Stay, mortal, and let me mold thee.'"));
4436 if (one_in_(3) && !(chaos_stats[p_ptr->chaos_patron] < 0))
4437 do_inc_stat(chaos_stats[p_ptr->chaos_patron]);
4439 do_inc_stat(randint0(6));
4440 reward = _("能力値が上がった。", "increasing a stat");
4446 msg_format("%sの声が響き渡った:",
4447 chaos_patrons[p_ptr->chaos_patron]);
4449 msg_format("The voice of %s booms out:",
4450 chaos_patrons[p_ptr->chaos_patron]);
4453 msg_print(_("「下僕よ、余は汝に飽みたり。」", "'I grow tired of thee, mortal.'"));
4455 if (one_in_(3) && !(chaos_stats[p_ptr->chaos_patron] < 0))
4456 do_dec_stat(chaos_stats[p_ptr->chaos_patron]);
4458 (void)do_dec_stat(randint0(6));
4459 reward = _("能力値が下がった。", "decreasing a stat");
4466 msg_format("%sの声が轟き渡った:",
4467 chaos_patrons[p_ptr->chaos_patron]);
4469 msg_format("The voice of %s thunders:",
4470 chaos_patrons[p_ptr->chaos_patron]);
4473 msg_print(_("「汝、謙虚たることを学ぶべし!」", "'Thou needst a lesson in humility, mortal!'"));
4474 msg_print(_("あなたは以前より弱くなった!", "You feel less powerful!"));
4476 for (dummy = 0; dummy < 6; dummy++)
4478 (void)dec_stat(dummy, 10 + randint1(15), TRUE);
4480 reward = _("全能力値が下がった。", "decreasing all stats");
4485 msg_format(_("%sの力が触れるのを感じた。", "You feel the power of %s touch you."),
4486 chaos_patrons[p_ptr->chaos_patron]);
4488 reward = _("傷が変化した。", "polymorphing wounds");
4493 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4495 msg_print(_("「我がささやかなる賜物を受けとるがよい!」", "'Receive this modest gift from me!'"));
4497 for (dummy = 0; dummy < 6; dummy++)
4499 (void)do_inc_stat(dummy);
4501 reward = _("全能力値が上がった。", "increasing all stats");
4506 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4507 msg_print(_("「苦しむがよい、無能な愚か者よ!」", "'Suffer, pathetic fool!'"));
4509 fire_ball(GF_DISINTEGRATE, 0, p_ptr->lev * 4, 4);
4510 take_hit(DAMAGE_NOESCAPE, p_ptr->lev * 4, wrath_reason, -1);
4511 reward = _("分解の球が発生した。", "generating disintegration ball");
4516 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4517 (void)restore_level();
4518 (void)restore_all_status();
4519 (void)true_healing(5000);
4520 reward = _("体力が回復した。", "healing");
4525 if (!buki_motteruka(INVEN_RARM) && !buki_motteruka(INVEN_LARM)) break;
4526 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4527 msg_print(_("「汝、武器に頼ることなかれ。」", "'Thou reliest too much on thy weapon.'"));
4530 if (buki_motteruka(INVEN_LARM))
4533 if (buki_motteruka(INVEN_RARM) && one_in_(2)) dummy = INVEN_RARM;
4535 object_desc(o_name, &inventory[dummy], OD_NAME_ONLY);
4536 (void)curse_weapon(FALSE, dummy);
4537 reward = format(_("%sが破壊された。", "destroying %s"), o_name);
4542 if (!inventory[INVEN_BODY].k_idx) break;
4543 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4544 msg_print(_("「汝、防具に頼ることなかれ。」", "'Thou reliest too much on thine equipment.'"));
4546 object_desc(o_name, &inventory[INVEN_BODY], OD_NAME_ONLY);
4547 (void)curse_armor();
4548 reward = format(_("%sが破壊された。", "destroying %s"), o_name);
4552 msg_format(_("%sの声がささやいた:", "The voice of %s whispers:"), chaos_patrons[p_ptr->chaos_patron]);
4553 msg_print(_("「我を怒りしめた罪を償うべし。」", "'Now thou shalt pay for annoying me.'"));
4555 switch (randint1(4))
4558 (void)activate_ty_curse(FALSE, &count);
4559 reward = _("禍々しい呪いをかけられた。", "cursing");
4562 activate_hi_summon(p_ptr->y, p_ptr->x, FALSE);
4563 reward = _("モンスターを召喚された。", "summoning hostile monsters");
4568 if (!buki_motteruka(INVEN_RARM) && !buki_motteruka(INVEN_LARM)) break;
4570 if (buki_motteruka(INVEN_LARM))
4573 if (buki_motteruka(INVEN_RARM) && one_in_(2)) dummy = INVEN_RARM;
4575 object_desc(o_name, &inventory[dummy], OD_NAME_ONLY);
4576 (void)curse_weapon(FALSE, dummy);
4577 reward = format(_("%sが破壊された。", "destroying %s"), o_name);
4581 if (!inventory[INVEN_BODY].k_idx) break;
4582 object_desc(o_name, &inventory[INVEN_BODY], OD_NAME_ONLY);
4583 (void)curse_armor();
4584 reward = format(_("%sが破壊された。", "destroying %s"), o_name);
4588 for (dummy = 0; dummy < 6; dummy++)
4590 (void)dec_stat(dummy, 10 + randint1(15), TRUE);
4592 reward = _("全能力値が下がった。", "decreasing all stats");
4599 msg_format(_("%sの声が轟き渡った:", "The voice of %s thunders:"), chaos_patrons[p_ptr->chaos_patron]);
4600 msg_print(_("「死ぬがよい、下僕よ!」", "'Die, mortal!'"));
4602 take_hit(DAMAGE_LOSELIFE, p_ptr->lev * 4, wrath_reason, -1);
4603 for (dummy = 0; dummy < 6; dummy++)
4605 (void)dec_stat(dummy, 10 + randint1(15), FALSE);
4607 activate_hi_summon(p_ptr->y, p_ptr->x, FALSE);
4608 (void)activate_ty_curse(FALSE, &count);
4613 if (buki_motteruka(INVEN_RARM))
4616 if (buki_motteruka(INVEN_LARM) && one_in_(2)) dummy = INVEN_LARM;
4618 else if (buki_motteruka(INVEN_LARM)) dummy = INVEN_LARM;
4620 if (dummy) (void)curse_weapon(FALSE, dummy);
4622 if (one_in_(2)) (void)curse_armor();
4627 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4628 msg_print(_("「死と破壊こそ我が喜びなり!」", "'Death and destruction! This pleaseth me!'"));
4630 (void)destroy_area(p_ptr->y, p_ptr->x, 25, FALSE);
4631 reward = _("ダンジョンが*破壊*された。", "*destruct*ing dungeon");
4636 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4637 msg_print(_("「我、汝の敵を抹殺せん!」", "'Let me relieve thee of thine oppressors!'"));
4638 (void)symbol_genocide(0, FALSE);
4639 reward = _("モンスターが抹殺された。", "genociding monsters");
4644 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4645 msg_print(_("「我、汝の敵を抹殺せん!」", "'Let me relieve thee of thine oppressors!'"));
4647 (void)mass_genocide(0, FALSE);
4648 reward = _("モンスターが抹殺された。", "genociding nearby monsters");
4653 msg_format(_("%sの力が敵を攻撃するのを感じた!", "You can feel the power of %s assault your enemies!"), chaos_patrons[p_ptr->chaos_patron]);
4654 (void)dispel_monsters(p_ptr->lev * 4);
4659 msg_format(_("%sはあなたを無視した。", "%s ignores you."), chaos_patrons[p_ptr->chaos_patron]);
4664 msg_format(_("%sは褒美として悪魔の使いをよこした!", "%s rewards you with a demonic servant!"),chaos_patrons[p_ptr->chaos_patron]);
4666 if (!summon_specific(-1, p_ptr->y, p_ptr->x, dun_level, SUMMON_DEMON, PM_FORCE_PET))
4667 msg_print(_("何も現れなかった...", "Nobody ever turns up..."));
4669 reward = _("悪魔がペットになった。", "a demonic servant");
4674 msg_format(_("%sは褒美として使いをよこした!", "%s rewards you with a servant!"),chaos_patrons[p_ptr->chaos_patron]);
4676 if (!summon_specific(-1, p_ptr->y, p_ptr->x, dun_level, 0, PM_FORCE_PET))
4677 msg_print(_("何も現れなかった...", "Nobody ever turns up..."));
4679 reward = _("モンスターがペットになった。", "a servant");
4684 msg_format(_("%sは褒美としてアンデッドの使いをよこした。", "%s rewards you with an undead servant!"),chaos_patrons[p_ptr->chaos_patron]);
4686 if (!summon_specific(-1, p_ptr->y, p_ptr->x, dun_level, SUMMON_UNDEAD, PM_FORCE_PET))
4687 msg_print(_("何も現れなかった...", "Nobody ever turns up..."));
4689 reward = _("アンデッドがペットになった。", "an undead servant");
4694 msg_format(_("%sの声がどもった:", "The voice of %s stammers:"),
4696 chaos_patrons[p_ptr->chaos_patron]);
4697 msg_format(_("「あー、あー、答えは %d/%d。質問は何?」", "'Uh... uh... the answer's %d/%d, what's the question?'"), type, effect);
4703 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, format(_("パトロンの報酬で%s", "The patron rewards you with %s."), reward));
4709 * XAngband: determine if a given location is "interesting"
4710 * based on target_set_accept function.
4712 static bool tgt_pt_accept(POSITION y, POSITION x)
4717 if (!(in_bounds(y, x))) return (FALSE);
4719 /* Player grid is always interesting */
4720 if ((y == p_ptr->y) && (x == p_ptr->x)) return (TRUE);
4722 /* Handle hallucination */
4723 if (p_ptr->image) return (FALSE);
4725 /* Examine the grid */
4726 c_ptr = &cave[y][x];
4728 /* Interesting memorized features */
4729 if (c_ptr->info & (CAVE_MARK))
4732 if (cave_have_flag_grid(c_ptr, FF_LESS)) return (TRUE);
4733 if (cave_have_flag_grid(c_ptr, FF_MORE)) return (TRUE);
4735 /* Notice quest features */
4736 if (cave_have_flag_grid(c_ptr, FF_QUEST_ENTER)) return (TRUE);
4737 if (cave_have_flag_grid(c_ptr, FF_QUEST_EXIT)) return (TRUE);
4745 * XAngband: Prepare the "temp" array for "tget_pt"
4746 * based on target_set_prepare funciton.
4748 static void tgt_pt_prepare(void)
4752 /* Reset "temp" array */
4755 if (!expand_list) return;
4757 /* Scan the current panel */
4758 for (y = 1; y < cur_hgt; y++)
4760 for (x = 1; x < cur_wid; x++)
4762 /* Require "interesting" contents */
4763 if (!tgt_pt_accept(y, x)) continue;
4765 /* Save the location */
4772 /* Target the nearest monster for shooting */
4773 ang_sort_comp = ang_sort_comp_distance;
4774 ang_sort_swap = ang_sort_swap_distance;
4776 /* Sort the positions */
4777 ang_sort(temp_x, temp_y, temp_n);
4781 * old -- from PsiAngband.
4783 bool tgt_pt(POSITION *x_ptr, POSITION *y_ptr)
4788 bool success = FALSE;
4792 get_screen_size(&wid, &hgt);
4802 msg_print(_("場所を選んでスペースキーを押して下さい。", "Select a point and press space."));
4803 msg_flag = FALSE; /* prevents "-more-" message. */
4805 while ((ch != ESCAPE) && !success)
4807 bool move_fast = FALSE;
4809 move_cursor_relative(y, x);
4821 if (player_bold(y, x)) ch = 0;
4824 else success = TRUE;
4828 /* XAngband: Move cursor to stairs */
4831 if (expand_list && temp_n)
4834 int cx = (panel_col_min + panel_col_max) / 2;
4835 int cy = (panel_row_min + panel_row_max) / 2;
4839 /* Skip stairs which have defferent distance */
4840 for (; n < temp_n; ++ n)
4842 cave_type *c_ptr = &cave[temp_y[n]][temp_x[n]];
4844 if (cave_have_flag_grid(c_ptr, FF_STAIRS) &&
4845 cave_have_flag_grid(c_ptr, ch == '>' ? FF_MORE : FF_LESS))
4852 if (n == temp_n) /* Loop out taget list */
4857 verify_panel(); /* Move cursor to player */
4859 p_ptr->update |= (PU_MONSTERS);
4861 p_ptr->redraw |= (PR_MAP);
4863 p_ptr->window |= (PW_OVERHEAD);
4866 else /* move cursor to next stair and change panel */
4871 dy = 2 * (y - cy) / hgt;
4872 dx = 2 * (x - cx) / wid;
4873 if (dy || dx) change_panel(dy, dx);
4879 /* Look up the direction */
4880 d = get_keymap_dir(ch);
4882 /* XTRA HACK MOVEFAST */
4883 if (isupper(ch)) move_fast = TRUE;
4885 /* Handle "direction" */
4891 /* XTRA HACK MOVEFAST */
4894 int mag = MIN(wid / 2, hgt / 2);
4904 /* Do not move horizontally if unnecessary */
4905 if (((x < panel_col_min + wid / 2) && (dx > 0)) ||
4906 ((x > panel_col_min + wid / 2) && (dx < 0)))
4911 /* Do not move vertically if unnecessary */
4912 if (((y < panel_row_min + hgt / 2) && (dy > 0)) ||
4913 ((y > panel_row_min + hgt / 2) && (dy < 0)))
4918 /* Apply the motion */
4919 if ((y >= panel_row_min + hgt) || (y < panel_row_min) ||
4920 (x >= panel_col_min + wid) || (x < panel_col_min))
4922 /* if (change_panel(dy, dx)) target_set_prepare(mode); */
4923 change_panel(dy, dx);
4926 /* Slide into legality */
4927 if (x >= cur_wid-1) x = cur_wid - 2;
4928 else if (x <= 0) x = 1;
4930 /* Slide into legality */
4931 if (y >= cur_hgt-1) y = cur_hgt- 2;
4932 else if (y <= 0) y = 1;
4939 /* Clear the top line */
4942 /* Recenter the map around the player */
4945 p_ptr->update |= (PU_MONSTERS);
4947 p_ptr->redraw |= (PR_MAP);
4949 p_ptr->window |= (PW_OVERHEAD);
4958 bool get_hack_dir(DIRECTION *dp)
4966 /* Global direction */
4969 /* (No auto-targeting) */
4971 /* Ask until satisfied */
4974 /* Choose a prompt */
4977 p = _("方向 ('*'でターゲット選択, ESCで中断)? ", "Direction ('*' to choose a target, Escape to cancel)? ");
4981 p = _("方向 ('5'でターゲットへ, '*'でターゲット再選択, ESCで中断)? ", "Direction ('5' for target, '*' to re-target, Escape to cancel)? ");
4984 /* Get a command (or Cancel) */
4985 if (!get_com(p, &command, TRUE)) break;
4989 if (command == '\r') command = 't';
4992 /* Convert various keys to "standard" keys */
4995 /* Use current target */
5006 /* Set new target */
5011 if (target_set(TARGET_KILL)) dir = 5;
5017 /* Look up the direction */
5018 dir = get_keymap_dir(command);
5024 /* Verify requested targets */
5025 if ((dir == 5) && !target_okay()) dir = 0;
5032 if (!dir) return (FALSE);
5034 /* Save the direction */
5037 /* Check for confusion */
5038 if (p_ptr->confused)
5040 /* Random direction */
5041 dir = ddd[randint0(8)];
5044 /* Notice confusion */
5045 if (command_dir != dir)
5048 msg_print(_("あなたは混乱している。", "You are confused."));
5051 /* Save direction */
5054 /* A "valid" direction was entered */
5060 * エネルギーの増加量10d5を速く計算するための関数
5063 #define Go_no_JuuJou 5*5*5*5*5*5*5*5*5*5
5065 s16b gain_energy(void)
5068 s32b energy_result = 10;
5071 tmp = randint0(Go_no_JuuJou);
5073 for (i = 0; i < 9; i ++){
5074 energy_result += tmp % 5;
5078 return (s16b)(energy_result + tmp);
5083 * @brief 射撃武器の攻撃に必要な基本消費エネルギーを返す/Return bow energy
5084 * @param sval 射撃武器のアイテム副分類ID
5085 * @return 消費する基本エネルギー
5087 ENERGY bow_energy(OBJECT_SUBTYPE_VALUE sval)
5089 ENERGY energy = 10000;
5091 /* Analyze the launcher */
5094 /* Sling and ammo */
5101 /* Short Bow and Arrow */
5108 /* Long Bow and Arrow */
5115 /* Bow of irresponsiblity and Arrow */
5122 /* Light Crossbow and Bolt */
5129 /* Heavy Crossbow and Bolt */
5144 int bow_tmul(OBJECT_SUBTYPE_VALUE sval)
5148 /* Analyze the launcher */
5151 /* Sling and ammo */
5158 /* Short Bow and Arrow */
5165 /* Long Bow and Arrow */
5172 /* Bow of irresponsiblity and Arrow */
5179 /* Light Crossbow and Bolt */
5186 /* Heavy Crossbow and Bolt */
5198 * Return alignment title
5200 cptr your_alignment(void)
5203 if (p_ptr->align > 150) return "大善";
5204 else if (p_ptr->align > 50) return "中善";
5205 else if (p_ptr->align > 10) return "小善";
5206 else if (p_ptr->align > -11) return "中立";
5207 else if (p_ptr->align > -51) return "小悪";
5208 else if (p_ptr->align > -151) return "中悪";
5211 if (p_ptr->align > 150) return "Lawful";
5212 else if (p_ptr->align > 50) return "Good";
5213 else if (p_ptr->align > 10) return "Neutral Good";
5214 else if (p_ptr->align > -11) return "Neutral";
5215 else if (p_ptr->align > -51) return "Neutral Evil";
5216 else if (p_ptr->align > -151) return "Evil";
5217 else return "Chaotic";
5223 * Return proficiency level of weapons and misc. skills (except riding)
5225 int weapon_exp_level(int weapon_exp)
5227 if (weapon_exp < WEAPON_EXP_BEGINNER) return EXP_LEVEL_UNSKILLED;
5228 else if (weapon_exp < WEAPON_EXP_SKILLED) return EXP_LEVEL_BEGINNER;
5229 else if (weapon_exp < WEAPON_EXP_EXPERT) return EXP_LEVEL_SKILLED;
5230 else if (weapon_exp < WEAPON_EXP_MASTER) return EXP_LEVEL_EXPERT;
5231 else return EXP_LEVEL_MASTER;
5236 * Return proficiency level of riding
5238 int riding_exp_level(int riding_exp)
5240 if (riding_exp < RIDING_EXP_BEGINNER) return EXP_LEVEL_UNSKILLED;
5241 else if (riding_exp < RIDING_EXP_SKILLED) return EXP_LEVEL_BEGINNER;
5242 else if (riding_exp < RIDING_EXP_EXPERT) return EXP_LEVEL_SKILLED;
5243 else if (riding_exp < RIDING_EXP_MASTER) return EXP_LEVEL_EXPERT;
5244 else return EXP_LEVEL_MASTER;
5249 * Return proficiency level of spells
5251 int spell_exp_level(int spell_exp)
5253 if (spell_exp < SPELL_EXP_BEGINNER) return EXP_LEVEL_UNSKILLED;
5254 else if (spell_exp < SPELL_EXP_SKILLED) return EXP_LEVEL_BEGINNER;
5255 else if (spell_exp < SPELL_EXP_EXPERT) return EXP_LEVEL_SKILLED;
5256 else if (spell_exp < SPELL_EXP_MASTER) return EXP_LEVEL_EXPERT;
5257 else return EXP_LEVEL_MASTER;
5262 * Display a rumor and apply its effects
5265 IDX rumor_num(char *zz, IDX max_idx)
5267 if (strcmp(zz, "*") == 0) return randint1(max_idx - 1);
5268 return (IDX)atoi(zz);
5271 cptr rumor_bind_name(char *base, cptr fullname)
5275 s = strstr(base, "{Name}");
5279 v = format("%s%s%s", base, fullname, (s + 6));
5289 void display_rumor(bool ex)
5297 if (randint0(3) == 0) section = 1;
5300 err = _(get_rnd_line_jonly("rumors_j.txt", section, Rumor, 10),
5301 get_rnd_line("rumors.txt", section, Rumor));
5302 if (err) strcpy(Rumor, _("嘘の噂もある。", "Some rumors are wrong."));
5306 if (strncmp(Rumor, "R:", 2) == 0)
5309 cptr rumor_msg = NULL;
5310 cptr rumor_eff_format = NULL;
5311 char fullname[1024] = "";
5313 if (tokenize(Rumor + 2, 3, zz, TOKENIZE_CHECKQUOTE) == 3)
5315 if (strcmp(zz[0], "ARTIFACT") == 0)
5319 object_type *q_ptr = &forge;
5320 artifact_type *a_ptr;
5324 a_idx = rumor_num(zz[1], max_a_idx);
5326 a_ptr = &a_info[a_idx];
5327 if (a_ptr->name) break;
5330 k_idx = lookup_kind(a_ptr->tval, a_ptr->sval);
5331 object_prep(q_ptr, k_idx);
5332 q_ptr->name1 = a_idx;
5333 q_ptr->ident = IDENT_STORE;
5334 object_desc(fullname, q_ptr, OD_NAME_ONLY);
5336 else if (strcmp(zz[0], "MONSTER") == 0)
5339 monster_race *r_ptr;
5343 r_idx = rumor_num(zz[1], max_r_idx);
5344 r_ptr = &r_info[r_idx];
5345 if (r_ptr->name) break;
5348 strcpy(fullname, r_name + r_ptr->name);
5350 /* Remember this monster */
5351 if (!r_ptr->r_sights)
5356 else if (strcmp(zz[0], "DUNGEON") == 0)
5359 dungeon_info_type *d_ptr;
5363 d_idx = rumor_num(zz[1], max_d_idx);
5364 d_ptr = &d_info[d_idx];
5365 if (d_ptr->name) break;
5368 strcpy(fullname, d_name + d_ptr->name);
5370 if (!max_dlv[d_idx])
5372 max_dlv[d_idx] = d_ptr->mindepth;
5373 rumor_eff_format = _("%sに帰還できるようになった。", "You can recall to %s.");
5376 else if (strcmp(zz[0], "TOWN") == 0)
5383 t_idx = rumor_num(zz[1], NO_TOWN);
5384 if (town[t_idx].name) break;
5387 strcpy(fullname, town[t_idx].name);
5389 visit = (1L << (t_idx - 1));
5390 if ((t_idx != SECRET_TOWN) && !(p_ptr->visit & visit))
5392 p_ptr->visit |= visit;
5393 rumor_eff_format = _("%sに行ったことがある気がする。", "You feel you have been to %s.");
5397 rumor_msg = rumor_bind_name(zz[2], fullname);
5398 msg_print(rumor_msg);
5399 if (rumor_eff_format)
5402 msg_format(rumor_eff_format, fullname);
5407 if (err) msg_print(_("この情報は間違っている。", "This information is wrong."));
5411 msg_format("%s", Rumor);