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 < A_MAX; 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 OBJECT_SUBTYPE_VALUE 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;
288 quest_num = p_ptr->inside_quest;
290 /* Search for an active quest on this dungeon level */
295 for (i = max_q_idx - 1; i > 0; i--)
297 quest_type* const q_ptr = &quest[i];
299 /* Quest is not active */
300 if (q_ptr->status != QUEST_STATUS_TAKEN)
303 /* Quest is not a dungeon quest */
304 if (q_ptr->flags & QUEST_FLAG_PRESET)
307 /* Quest is not on this level */
308 if ((q_ptr->level != dun_level) &&
309 (q_ptr->type != QUEST_TYPE_KILL_ANY_LEVEL))
312 /* Not a "kill monster" quest */
313 if ((q_ptr->type == QUEST_TYPE_FIND_ARTIFACT) ||
314 (q_ptr->type == QUEST_TYPE_FIND_EXIT))
317 /* Interesting quest */
318 if ((q_ptr->type == QUEST_TYPE_KILL_NUMBER) ||
319 (q_ptr->type == QUEST_TYPE_TOWER) ||
320 (q_ptr->type == QUEST_TYPE_KILL_ALL))
323 /* Interesting quest */
324 if (((q_ptr->type == QUEST_TYPE_KILL_LEVEL) ||
325 (q_ptr->type == QUEST_TYPE_KILL_ANY_LEVEL) ||
326 (q_ptr->type == QUEST_TYPE_RANDOM)) &&
327 (q_ptr->r_idx == m_ptr->r_idx))
334 /* Handle the current quest */
335 if (quest_num && (quest[quest_num].status == QUEST_STATUS_TAKEN))
338 quest_type* const q_ptr = &quest[quest_num];
342 case QUEST_TYPE_KILL_NUMBER:
346 if (q_ptr->cur_num >= q_ptr->num_mon)
348 complete_quest(quest_num);
354 case QUEST_TYPE_KILL_ALL:
356 if (!is_hostile(m_ptr)) break;
358 if (count_all_hostile_monsters() == 1)
360 if (q_ptr->flags & QUEST_FLAG_SILENT)
362 q_ptr->status = QUEST_STATUS_FINISHED;
366 complete_quest(quest_num);
371 case QUEST_TYPE_KILL_LEVEL:
372 case QUEST_TYPE_RANDOM:
374 /* Only count valid monsters */
375 if (q_ptr->r_idx != m_ptr->r_idx)
380 if (q_ptr->cur_num >= q_ptr->max_num)
382 complete_quest(quest_num);
384 if (!(q_ptr->flags & QUEST_FLAG_PRESET))
386 create_stairs = TRUE;
387 p_ptr->inside_quest = 0;
390 /* Finish the two main quests without rewarding */
391 if ((quest_num == QUEST_OBERON) || (quest_num == QUEST_SERPENT))
393 q_ptr->status = QUEST_STATUS_FINISHED;
396 if (q_ptr->type == QUEST_TYPE_RANDOM)
399 q_ptr->status = QUEST_STATUS_FINISHED;
404 case QUEST_TYPE_KILL_ANY_LEVEL:
407 if (q_ptr->cur_num >= q_ptr->max_num)
409 complete_quest(quest_num);
414 case QUEST_TYPE_TOWER:
416 if (!is_hostile(m_ptr)) break;
418 if (count_all_hostile_monsters() == 1)
420 q_ptr->status = QUEST_STATUS_STAGE_COMPLETED;
422 if((quest[QUEST_TOWER1].status == QUEST_STATUS_STAGE_COMPLETED) &&
423 (quest[QUEST_TOWER2].status == QUEST_STATUS_STAGE_COMPLETED) &&
424 (quest[QUEST_TOWER3].status == QUEST_STATUS_STAGE_COMPLETED))
427 complete_quest(QUEST_TOWER1);
435 /* Create a magical staircase */
441 while (cave_perma_bold(y, x) || cave[y][x].o_idx || (cave[y][x].info & CAVE_OBJECT) )
443 /* Pick a location */
444 scatter(&ny, &nx, y, x, 1, 0);
450 /* Explain the staircase */
451 msg_print(_("魔法の階段が現れた...", "A magical staircase appears..."));
453 /* Create stairs down */
454 cave_set_feat(y, x, feat_down_stair);
456 /* Remember to update everything */
457 p_ptr->update |= (PU_FLOW);
467 for (i = 0; i < (dun_level / 15)+1; i++)
472 /* Make a great object */
473 make_object(o_ptr, AM_GOOD | AM_GREAT);
474 (void)drop_near(o_ptr, -1, y, x);
480 * @brief 特定のアーティファクトを入手した際のクエスト達成処理 /
481 * Check for "Quest" completion when a quest monster is killed or charmed.
482 * @param o_ptr 入手したオブジェクトの構造体参照ポインタ
485 void check_find_art_quest_completion(object_type *o_ptr)
488 /* Check if completed a quest */
489 for (i = 0; i < max_q_idx; i++)
491 if((quest[i].type == QUEST_TYPE_FIND_ARTIFACT) &&
492 (quest[i].status == QUEST_STATUS_TAKEN) &&
493 (quest[i].k_idx == o_ptr->name1))
502 * @brief モンスターを撃破した際の述語メッセージを返す /
503 * Return monster death string
504 * @param r_ptr 撃破されたモンスターの種族情報を持つ構造体の参照ポインタ
505 * @return 撃破されたモンスターの述語
507 cptr extract_note_dies(MONRACE_IDX r_idx)
509 monster_race *r_ptr = &r_info[r_idx];
510 /* Some monsters get "destroyed" */
511 if (!monster_living(r_idx))
515 for (i = 0; i < 4; i++)
517 if (r_ptr->blow[i].method == RBM_EXPLODE)
519 return _("は爆発して粉々になった。", " explodes into tiny shreds.");
522 return _("を倒した。", " is destroyed.");
525 /* Assume a default death */
526 return _("は死んだ。", " dies.");
531 * @brief モンスターが死亡した時の処理 /
532 * Handle the "death" of a monster.
533 * @param m_idx 死亡したモンスターのID
534 * @param drop_item TRUEならばモンスターのドロップ処理を行う
535 * @return 撃破されたモンスターの述語
538 * Disperse treasures centered at the monster location based on the
539 * various flags contained in the monster flags fields.
540 * Check for "Quest" completion when a quest monster is killed.
541 * Note that only the player can induce "monster_death()" on Uniques.
542 * Thus (for now) all Quest monsters should be Uniques.
543 * Note that monsters can now carry objects, and when a monster dies,
544 * it drops all of its objects, which may disappear in crowded rooms.
547 void monster_death(MONSTER_IDX m_idx, bool drop_item)
556 monster_type *m_ptr = &m_list[m_idx];
557 monster_race *r_ptr = &r_info[m_ptr->r_idx];
559 bool visible = ((m_ptr->ml && !p_ptr->image) || (r_ptr->flags1 & RF1_UNIQUE));
563 bool do_gold = (!(r_ptr->flags1 & RF1_ONLY_ITEM));
564 bool do_item = (!(r_ptr->flags1 & RF1_ONLY_GOLD));
565 bool cloned = (m_ptr->smart & SM_CLONED) ? TRUE : FALSE;
566 int force_coin = get_coin_type(m_ptr->r_idx);
571 bool drop_chosen_item = drop_item && !cloned && !p_ptr->inside_arena
572 && !p_ptr->inside_battle && !is_pet(m_ptr);
574 /* The caster is dead? */
575 if (world_monster && world_monster == m_idx) world_monster = 0;
577 /* Notice changes in view */
578 if (r_ptr->flags7 & (RF7_LITE_MASK | RF7_DARK_MASK))
580 /* Update some things */
581 p_ptr->update |= (PU_MON_LITE);
587 if (record_named_pet && is_pet(m_ptr) && m_ptr->nickname)
589 GAME_TEXT m_name[MAX_NLEN];
591 monster_desc(m_name, m_ptr, MD_INDEF_VISIBLE);
592 do_cmd_write_nikki(NIKKI_NAMED_PET, 3, m_name);
595 /* Let monsters explode! */
596 for (i = 0; i < 4; i++)
598 if (r_ptr->blow[i].method == RBM_EXPLODE)
600 BIT_FLAGS flg = PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL;
601 EFFECT_ID typ = mbe_info[r_ptr->blow[i].effect].explode_type;
602 DICE_NUMBER d_dice = r_ptr->blow[i].d_dice;
603 DICE_SID d_side = r_ptr->blow[i].d_side;
604 HIT_POINT damage = damroll(d_dice, d_side);
606 project(m_idx, 3, y, x, damage, typ, flg, -1);
611 if (m_ptr->mflag2 & MFLAG2_CHAMELEON)
613 choose_new_monster(m_idx, TRUE, MON_CHAMELEON);
614 r_ptr = &r_info[m_ptr->r_idx];
617 /* Check for quest completion */
618 check_quest_completion(m_ptr);
620 /* Handle the possibility of player vanquishing arena combatant -KMW- */
621 if (p_ptr->inside_arena && !is_pet(m_ptr))
623 p_ptr->exit_bldg = TRUE;
625 if (p_ptr->arena_number > MAX_ARENA_MONS)
627 msg_print(_("素晴らしい!君こそ真の勝利者だ。", "You are a Genuine Champion!"));
631 msg_print(_("勝利!チャンピオンへの道を進んでいる。", "Victorious! You're on your way to becoming Champion."));
634 if (arena_info[p_ptr->arena_number].tval)
638 /* Prepare to make a prize */
639 object_prep(q_ptr, lookup_kind(arena_info[p_ptr->arena_number].tval, arena_info[p_ptr->arena_number].sval));
640 apply_magic(q_ptr, object_level, AM_NO_FIXED_ART);
641 (void)drop_near(q_ptr, -1, y, x);
644 if (p_ptr->arena_number > MAX_ARENA_MONS) p_ptr->arena_number++;
645 p_ptr->arena_number++;
648 GAME_TEXT m_name[MAX_NLEN];
650 /* Extract monster name */
651 monster_desc(m_name, m_ptr, MD_IGNORE_HALLU | MD_ASSUME_VISIBLE | MD_INDEF_VISIBLE);
653 do_cmd_write_nikki(NIKKI_ARENA, p_ptr->arena_number, m_name);
657 if (m_idx == p_ptr->riding)
659 if (rakuba(-1, FALSE))
661 msg_print(_("地面に落とされた。", "You have fallen from your riding pet."));
665 /* Drop a dead corpse? */
666 if (one_in_(r_ptr->flags1 & RF1_UNIQUE ? 1 : 4) &&
667 (r_ptr->flags9 & (RF9_DROP_CORPSE | RF9_DROP_SKELETON)) &&
668 !(p_ptr->inside_arena || p_ptr->inside_battle || cloned || ((m_ptr->r_idx == today_mon) && is_pet(m_ptr))))
670 /* Assume skeleton */
674 * We cannot drop a skeleton? Note, if we are in this check,
675 * we *know* we can drop at least a corpse or a skeleton
677 if (!(r_ptr->flags9 & RF9_DROP_SKELETON))
679 else if ((r_ptr->flags9 & RF9_DROP_CORPSE) && (r_ptr->flags1 & RF1_UNIQUE))
682 /* Else, a corpse is more likely unless we did a "lot" of damage */
683 else if (r_ptr->flags9 & RF9_DROP_CORPSE)
685 /* Lots of damage in one blow */
686 if ((0 - ((m_ptr->maxhp) / 4)) > m_ptr->hp)
688 if (one_in_(5)) corpse = TRUE;
692 if (!one_in_(5)) corpse = TRUE;
697 /* Prepare to make an object */
698 object_prep(q_ptr, lookup_kind(TV_CORPSE, (corpse ? SV_CORPSE : SV_SKELETON)));
700 apply_magic(q_ptr, object_level, AM_NO_FIXED_ART);
702 q_ptr->pval = m_ptr->r_idx;
703 (void)drop_near(q_ptr, -1, y, x);
706 /* Drop objects being carried */
707 monster_drop_carried_objects(m_ptr);
709 if (r_ptr->flags1 & RF1_DROP_GOOD) mo_mode |= AM_GOOD;
710 if (r_ptr->flags1 & RF1_DROP_GREAT) mo_mode |= AM_GREAT;
712 switch (m_ptr->r_idx)
714 case MON_PINK_HORROR:
715 /* Pink horrors are replaced with 2 Blue horrors */
716 if (!(p_ptr->inside_arena || p_ptr->inside_battle))
720 for (i = 0; i < 2; i++)
722 POSITION wy = y, wx = x;
723 bool pet = is_pet(m_ptr);
726 if (pet) mode |= PM_FORCE_PET;
728 if (summon_specific((pet ? -1 : m_idx), wy, wx, 100, SUMMON_BLUE_HORROR, mode, '\0'))
730 if (player_can_see_bold(wy, wx)) notice = TRUE;
734 if (notice) msg_print(_("ピンク・ホラーは分裂した!", "The Pink horror divides!"));
738 case MON_BLOODLETTER:
739 /* Bloodletters of Khorne may drop a blade of chaos */
740 if (drop_chosen_item && (randint1(100) < 15))
744 /* Prepare to make a Blade of Chaos */
745 object_prep(q_ptr, lookup_kind(TV_SWORD, SV_BLADE_OF_CHAOS));
747 apply_magic(q_ptr, object_level, AM_NO_FIXED_ART | mo_mode);
748 (void)drop_near(q_ptr, -1, y, x);
753 if (drop_chosen_item && (dun_level > 9))
758 /* Activate restriction */
759 if ((dun_level > 49) && one_in_(5))
760 get_obj_num_hook = kind_is_good_book;
762 get_obj_num_hook = kind_is_book;
765 make_object(q_ptr, mo_mode);
766 (void)drop_near(q_ptr, -1, y, x);
772 * Mega^3-hack: killing a 'Warrior of the Dawn' is likely to
773 * spawn another in the fallen one's place!
775 if (!p_ptr->inside_arena && !p_ptr->inside_battle)
779 POSITION wy = y, wx = x;
781 bool pet = is_pet(m_ptr);
785 scatter(&wy, &wx, y, x, 20, 0);
787 while (!(in_bounds(wy, wx) && cave_empty_bold2(wy, wx)) && --attempts);
792 if (pet) mode |= PM_FORCE_PET;
794 if (summon_specific((pet ? -1 : m_idx), wy, wx, 100, SUMMON_DAWN, mode, '\0'))
796 if (player_can_see_bold(wy, wx))
797 msg_print(_("新たな戦士が現れた!", "A new warrior steps forth!"));
805 /* One more ultra-hack: An Unmaker goes out with a big bang! */
807 BIT_FLAGS flg = PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL;
808 (void)project(m_idx, 6, y, x, 100, GF_CHAOS, flg, -1);
812 case MON_UNICORN_ORD:
815 /* Reward for "lazy" player */
816 if (p_ptr->pseikaku == SEIKAKU_NAMAKE)
818 ARTIFACT_IDX a_idx = 0;
819 artifact_type *a_ptr = NULL;
821 if (!drop_chosen_item) break;
828 a_idx = ART_NAMAKE_HAMMER;
831 a_idx = ART_NAMAKE_BOW;
834 a_idx = ART_NAMAKE_ARMOR;
838 a_ptr = &a_info[a_idx];
840 while (a_ptr->cur_num);
842 /* Create the artifact */
843 if (create_named_art(a_idx, y, x))
847 /* Hack -- Memorize location of artifact in saved floors */
848 if (character_dungeon) a_ptr->floor_id = p_ptr->floor_id;
850 else if (!preserve_mode) a_ptr->cur_num = 1;
855 if (!drop_chosen_item) break;
858 /* Mega-Hack -- Prepare to make "Grond" */
859 object_prep(q_ptr, lookup_kind(TV_HAFTED, SV_GROND));
861 /* Mega-Hack -- Mark this item as "Grond" */
862 q_ptr->name1 = ART_GROND;
864 /* Mega-Hack -- Actually create "Grond" */
865 apply_magic(q_ptr, -1, AM_GOOD | AM_GREAT);
866 (void)drop_near(q_ptr, -1, y, x);
869 /* Mega-Hack -- Prepare to make "Chaos" */
870 object_prep(q_ptr, lookup_kind(TV_CROWN, SV_CHAOS));
872 /* Mega-Hack -- Mark this item as "Chaos" */
873 q_ptr->name1 = ART_CHAOS;
875 /* Mega-Hack -- Actually create "Chaos" */
876 apply_magic(q_ptr, -1, AM_GOOD | AM_GREAT);
877 (void)drop_near(q_ptr, -1, y, x);
880 case MON_B_DEATH_SWORD:
881 if (drop_chosen_item)
885 /* Prepare to make a broken sword */
886 object_prep(q_ptr, lookup_kind(TV_SWORD, randint1(2)));
887 (void)drop_near(q_ptr, -1, y, x);
893 if (drop_chosen_item && ((m_ptr->r_idx == MON_A_GOLD) ||
894 ((m_ptr->r_idx == MON_A_SILVER) && (r_ptr->r_akills % 5 == 0))))
898 /* Prepare to make a Can of Toys */
899 object_prep(q_ptr, lookup_kind(TV_CHEST, SV_CHEST_KANDUME));
901 apply_magic(q_ptr, object_level, AM_NO_FIXED_ART);
902 (void)drop_near(q_ptr, -1, y, x);
908 BIT_FLAGS flg = PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL;
909 (void)project(m_idx, 3, y, x, damroll(20, 10), GF_FIRE, flg, -1);
914 if (!drop_chosen_item) break;
916 switch (r_ptr->d_char)
924 /* Activate restriction */
925 get_obj_num_hook = kind_is_cloak;
928 make_object(q_ptr, mo_mode);
929 (void)drop_near(q_ptr, -1, y, x);
939 /* Activate restriction */
940 get_obj_num_hook = kind_is_polearm;
942 /* Make a poleweapon */
943 make_object(q_ptr, mo_mode);
944 (void)drop_near(q_ptr, -1, y, x);
954 /* Activate restriction */
955 get_obj_num_hook = kind_is_armor;
957 /* Make a hard armor */
958 make_object(q_ptr, mo_mode);
959 (void)drop_near(q_ptr, -1, y, x);
969 /* Activate restriction */
970 get_obj_num_hook = kind_is_hafted;
972 /* Make a hafted weapon */
973 make_object(q_ptr, mo_mode);
974 (void)drop_near(q_ptr, -1, y, x);
979 if (m_ptr->r_idx != MON_STORMBRINGER)
984 /* Activate restriction */
985 get_obj_num_hook = kind_is_sword;
988 make_object(q_ptr, mo_mode);
989 (void)drop_near(q_ptr, -1, y, x);
996 /* Mega-Hack -- drop fixed items */
997 if (drop_chosen_item)
999 ARTIFACT_IDX a_idx = 0;
1002 for(i = 0; i < 4; i++)
1004 if(!r_ptr->artifact_id[i]) break;
1005 a_idx = r_ptr->artifact_id[i];
1006 chance = r_ptr->artifact_percent[i];
1009 if ((a_idx > 0) && ((randint0(100) < chance) || p_ptr->wizard))
1011 artifact_type *a_ptr = &a_info[a_idx];
1013 if (!a_ptr->cur_num)
1015 /* Create the artifact */
1016 if (create_named_art(a_idx, y, x))
1020 /* Hack -- Memorize location of artifact in saved floors */
1021 if (character_dungeon) a_ptr->floor_id = p_ptr->floor_id;
1023 else if (!preserve_mode) a_ptr->cur_num = 1;
1027 if ((r_ptr->flags7 & RF7_GUARDIAN) && (d_info[dungeon_type].final_guardian == m_ptr->r_idx))
1029 KIND_OBJECT_IDX k_idx = d_info[dungeon_type].final_object ? d_info[dungeon_type].final_object
1030 : lookup_kind(TV_SCROLL, SV_SCROLL_ACQUIREMENT);
1032 if (d_info[dungeon_type].final_artifact)
1034 a_idx = d_info[dungeon_type].final_artifact;
1035 artifact_type *a_ptr = &a_info[a_idx];
1037 if (!a_ptr->cur_num)
1039 /* Create the artifact */
1040 if (create_named_art(a_idx, y, x))
1044 /* Hack -- Memorize location of artifact in saved floors */
1045 if (character_dungeon) a_ptr->floor_id = p_ptr->floor_id;
1047 else if (!preserve_mode) a_ptr->cur_num = 1;
1049 /* Prevent rewarding both artifact and "default" object */
1050 if (!d_info[dungeon_type].final_object) k_idx = 0;
1058 /* Prepare to make a reward */
1059 object_prep(q_ptr, k_idx);
1061 apply_magic(q_ptr, object_level, AM_NO_FIXED_ART | AM_GOOD);
1062 (void)drop_near(q_ptr, -1, y, x);
1064 msg_format(_("あなたは%sを制覇した!", "You have conquered %s!"),d_name+d_info[dungeon_type].name);
1068 /* Determine how much we can drop */
1069 if ((r_ptr->flags1 & RF1_DROP_60) && (randint0(100) < 60)) number++;
1070 if ((r_ptr->flags1 & RF1_DROP_90) && (randint0(100) < 90)) number++;
1071 if (r_ptr->flags1 & RF1_DROP_1D2) number += damroll(1, 2);
1072 if (r_ptr->flags1 & RF1_DROP_2D2) number += damroll(2, 2);
1073 if (r_ptr->flags1 & RF1_DROP_3D2) number += damroll(3, 2);
1074 if (r_ptr->flags1 & RF1_DROP_4D2) number += damroll(4, 2);
1076 if (cloned && !(r_ptr->flags1 & RF1_UNIQUE))
1077 number = 0; /* Clones drop no stuff unless Cloning Pits */
1079 if (is_pet(m_ptr) || p_ptr->inside_battle || p_ptr->inside_arena)
1080 number = 0; /* Pets drop no stuff */
1081 if (!drop_item && (r_ptr->d_char != '$')) number = 0;
1083 if((r_ptr->flags2 & (RF2_MULTIPLY)) && (r_ptr->r_akills > 1024))
1084 number = 0; /* Limit of Multiply monster drop */
1086 /* Hack -- handle creeping coins */
1087 coin_type = force_coin;
1089 /* Average dungeon and monster levels */
1090 object_level = (dun_level + r_ptr->level) / 2;
1092 /* Drop some objects */
1093 for (j = 0; j < number; j++)
1099 if (do_gold && (!do_item || (randint0(100) < 50)))
1101 /* Make some gold */
1102 if (!make_gold(q_ptr)) continue;
1110 /* Make an object */
1111 if (!make_object(q_ptr, mo_mode)) continue;
1115 (void)drop_near(q_ptr, -1, y, x);
1118 /* Reset the object level */
1119 object_level = base_level;
1121 /* Reset "coin" type */
1125 /* Take note of any dropped treasure */
1126 if (visible && (dump_item || dump_gold))
1128 /* Take notes on treasure */
1129 lore_treasure(m_idx, dump_item, dump_gold);
1132 /* Only process "Quest Monsters" */
1133 if (!(r_ptr->flags1 & RF1_QUESTOR)) return;
1134 if (p_ptr->inside_battle) return;
1137 if ((m_ptr->r_idx == MON_SERPENT) && !cloned)
1140 p_ptr->total_winner = TRUE;
1142 /* Redraw the "title" */
1143 p_ptr->redraw |= (PR_TITLE);
1145 play_music(TERM_XTRA_MUSIC_BASIC, MUSIC_BASIC_FINAL_QUEST_CLEAR);
1147 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, _("見事に変愚蛮怒の勝利者となった!", "become *WINNER* of Hengband finely!"));
1149 if ((p_ptr->pclass == CLASS_CHAOS_WARRIOR) || (p_ptr->muta2 & MUT2_CHAOS_GIFT))
1151 msg_format(_("%sからの声が響いた。", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
1152 msg_print(_("『よくやった、定命の者よ!』", "'Thou art donst well, mortal!'"));
1155 /* Congratulations */
1156 msg_print(_("*** おめでとう ***", "*** CONGRATULATIONS ***"));
1157 msg_print(_("あなたはゲームをコンプリートしました。", "You have won the game!"));
1158 msg_print(_("準備が整ったら引退(自殺コマンド)しても結構です。", "You may retire (commit suicide) when you are ready."));
1163 * @brief モンスターに与えたダメージの修正処理 /
1164 * Modify the physical damage done to the monster.
1165 * @param m_ptr ダメージを受けるモンスターの構造体参照ポインタ
1166 * @param dam ダメージ基本値
1167 * @param is_psy_spear 攻撃手段が光の剣ならばTRUE
1168 * @return 修正を行った結果のダメージ量
1171 * (for example when it's invulnerable or shielded)
1172 * ToDo: Accept a damage-type to calculate the modified damage from
1173 * things like fire, frost, lightning, poison, ... attacks.
1174 * "type" is not yet used and should be 0.
1177 HIT_POINT mon_damage_mod(monster_type *m_ptr, HIT_POINT dam, bool is_psy_spear)
1179 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1181 if ((r_ptr->flagsr & RFR_RES_ALL) && dam > 0)
1184 if ((dam == 0) && one_in_(3)) dam = 1;
1187 if (MON_INVULNER(m_ptr))
1191 if (!p_ptr->blind && is_seen(m_ptr))
1193 msg_print(_("バリアを切り裂いた!", "The barrier is penetrated!"));
1196 else if (!one_in_(PENETRATE_INVULNERABILITY))
1206 * @brief モンスターに与えたダメージを元に経験値を加算する /
1207 * Calculate experience point to be get
1208 * @param dam 与えたダメージ量
1209 * @param m_ptr ダメージを与えたモンスターの構造体参照ポインタ
1213 * Even the 64 bit operation is not big enough to avoid overflaw
1214 * unless we carefully choose orders of multiplication and division.
1215 * Get the coefficient first, and multiply (potentially huge) base
1216 * experience point of a monster later.
1219 static void get_exp_from_mon(HIT_POINT dam, monster_type *m_ptr)
1221 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1228 if (!m_ptr->r_idx) return;
1229 if (is_pet(m_ptr) || p_ptr->inside_battle) return;
1232 * - Ratio of monster's level to player's level effects
1233 * - Varying speed effects
1234 * - Get a fraction in proportion of damage point
1236 new_exp = r_ptr->level * SPEED_TO_ENERGY(m_ptr->mspeed) * dam;
1239 div_l = (p_ptr->max_plv+2) * SPEED_TO_ENERGY(r_ptr->speed);
1241 /* Use (average maxhp * 2) as a denominator */
1242 if (!(r_ptr->flags1 & RF1_FORCE_MAXHP))
1243 s64b_mul(&div_h, &div_l, 0, r_ptr->hdice * (ironman_nightmare ? 2 : 1) * (r_ptr->hside + 1));
1245 s64b_mul(&div_h, &div_l, 0, r_ptr->hdice * (ironman_nightmare ? 2 : 1) * r_ptr->hside * 2);
1247 /* Special penalty in the wilderness */
1248 if (!dun_level && (!(r_ptr->flags8 & RF8_WILD_ONLY) || !(r_ptr->flags1 & RF1_UNIQUE)))
1249 s64b_mul(&div_h, &div_l, 0, 5);
1251 /* Do division first to prevent overflaw */
1252 s64b_div(&new_exp, &new_exp_frac, div_h, div_l);
1254 /* Special penalty for mutiply-monster */
1255 if ((r_ptr->flags2 & RF2_MULTIPLY) || (m_ptr->r_idx == MON_DAWN))
1257 int monnum_penarty = r_ptr->r_akills / 400;
1258 if (monnum_penarty > 8) monnum_penarty = 8;
1260 while (monnum_penarty--)
1263 s64b_RSHIFT(new_exp, new_exp_frac, 2);
1267 /* Special penalty for rest_and_shoot exp scum */
1268 if ((m_ptr->dealt_damage > m_ptr->max_maxhp) && (m_ptr->hp >= 0))
1270 int over_damage = m_ptr->dealt_damage / m_ptr->max_maxhp;
1271 if (over_damage > 32) over_damage = 32;
1273 while (over_damage--)
1276 s64b_mul(&new_exp, &new_exp_frac, 0, 9);
1277 s64b_div(&new_exp, &new_exp_frac, 0, 10);
1281 /* Finally multiply base experience point of the monster */
1282 s64b_mul(&new_exp, &new_exp_frac, 0, r_ptr->mexp);
1284 /* Gain experience */
1285 gain_exp_64(new_exp, new_exp_frac);
1290 * @brief モンスターのHPをダメージに応じて減算する /
1291 * Decreases monsters hit points, handling monster death.
1292 * @param dam 与えたダメージ量
1293 * @param m_idx ダメージを与えたモンスターのID
1294 * @param fear ダメージによってモンスターが恐慌状態に陥ったならばTRUEを返す
1295 * @param note モンスターが倒された際の特別なメッセージ述語
1299 * We return TRUE if the monster has been killed (and deleted).
1300 * We announce monster death (using an optional "death message"
1301 * if given, and a otherwise a generic killed/destroyed message).
1302 * Only "physical attacks" can induce the "You have slain" message.
1303 * Missile and Spell attacks will induce the "dies" message, or
1304 * various "specialized" messages. Note that "You have destroyed"
1305 * and "is destroyed" are synonyms for "You have slain" and "dies".
1306 * Hack -- unseen monsters yield "You have killed it." message.
1307 * Added fear (DGK) and check whether to print fear messages -CWS
1308 * Made name, sex, and capitalization generic -BEN-
1309 * As always, the "ghost" processing is a total hack.
1310 * Hack -- we "delay" fear messages by passing around a "fear" flag.
1311 * Consider decreasing monster experience over time, say,
1312 * by using "(m_exp * m_lev * (m_lev)) / (p_lev * (m_lev + n_killed))"
1313 * instead of simply "(m_exp * m_lev) / (p_lev)", to make the first
1314 * monster worth more than subsequent monsters. This would also need
1315 * to induce changes in the monster recall code.
1318 bool mon_take_hit(MONSTER_IDX m_idx, HIT_POINT dam, bool *fear, cptr note)
1320 monster_type *m_ptr = &m_list[m_idx];
1321 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1322 monster_type exp_mon;
1324 /* Innocent until proven otherwise */
1325 bool innocent = TRUE, thief = FALSE;
1329 (void)COPY(&exp_mon, m_ptr, monster_type);
1331 expdam = (m_ptr->hp > dam) ? dam : m_ptr->hp;
1333 get_exp_from_mon(expdam, &exp_mon);
1335 /* Genocided by chaos patron */
1336 if (!m_ptr->r_idx) m_idx = 0;
1338 /* Redraw (later) if needed */
1339 if (p_ptr->health_who == m_idx) p_ptr->redraw |= (PR_HEALTH);
1340 if (p_ptr->riding == m_idx) p_ptr->redraw |= (PR_UHEALTH);
1342 (void)set_monster_csleep(m_idx, 0);
1344 /* Hack - Cancel any special player stealth magics. -LM- */
1345 if (p_ptr->special_defense & NINJA_S_STEALTH)
1347 set_superstealth(FALSE);
1350 /* Genocided by chaos patron */
1351 if (!m_idx) return TRUE;
1354 m_ptr->dealt_damage += dam;
1356 if(m_ptr->dealt_damage > m_ptr->max_maxhp * 100) m_ptr->dealt_damage = m_ptr->max_maxhp * 100;
1360 msg_format( _("合計%d/%dのダメージを与えた。","You do %d (out of %d) damage."), m_ptr->dealt_damage, m_ptr->maxhp);
1363 /* It is dead now */
1366 GAME_TEXT m_name[MAX_NLEN];
1368 if (r_info[m_ptr->r_idx].flags7 & RF7_TANUKI)
1370 /* You might have unmasked Tanuki first time */
1371 r_ptr = &r_info[m_ptr->r_idx];
1372 m_ptr->ap_r_idx = m_ptr->r_idx;
1373 if (r_ptr->r_sights < MAX_SHORT) r_ptr->r_sights++;
1376 if (m_ptr->mflag2 & MFLAG2_CHAMELEON)
1378 /* You might have unmasked Chameleon first time */
1379 r_ptr = real_r_ptr(m_ptr);
1380 if (r_ptr->r_sights < MAX_SHORT) r_ptr->r_sights++;
1383 if (!(m_ptr->smart & SM_CLONED))
1385 /* When the player kills a Unique, it stays dead */
1386 if (r_ptr->flags1 & RF1_UNIQUE)
1390 /* Mega-Hack -- Banor & Lupart */
1391 if ((m_ptr->r_idx == MON_BANOR) || (m_ptr->r_idx == MON_LUPART))
1393 r_info[MON_BANORLUPART].max_num = 0;
1394 r_info[MON_BANORLUPART].r_pkills++;
1395 r_info[MON_BANORLUPART].r_akills++;
1396 if (r_info[MON_BANORLUPART].r_tkills < MAX_SHORT) r_info[MON_BANORLUPART].r_tkills++;
1398 else if (m_ptr->r_idx == MON_BANORLUPART)
1400 r_info[MON_BANOR].max_num = 0;
1401 r_info[MON_BANOR].r_pkills++;
1402 r_info[MON_BANOR].r_akills++;
1403 if (r_info[MON_BANOR].r_tkills < MAX_SHORT) r_info[MON_BANOR].r_tkills++;
1404 r_info[MON_LUPART].max_num = 0;
1405 r_info[MON_LUPART].r_pkills++;
1406 r_info[MON_LUPART].r_akills++;
1407 if (r_info[MON_LUPART].r_tkills < MAX_SHORT) r_info[MON_LUPART].r_tkills++;
1411 /* When the player kills a Nazgul, it stays dead */
1412 else if (r_ptr->flags7 & RF7_NAZGUL) r_ptr->max_num--;
1415 /* Count all monsters killed */
1416 if (r_ptr->r_akills < MAX_SHORT) r_ptr->r_akills++;
1418 /* Recall even invisible uniques or winners */
1419 if ((m_ptr->ml && !p_ptr->image) || (r_ptr->flags1 & RF1_UNIQUE))
1421 /* Count kills this life */
1422 if ((m_ptr->mflag2 & MFLAG2_KAGE) && (r_info[MON_KAGE].r_pkills < MAX_SHORT)) r_info[MON_KAGE].r_pkills++;
1423 else if (r_ptr->r_pkills < MAX_SHORT) r_ptr->r_pkills++;
1425 /* Count kills in all lives */
1426 if ((m_ptr->mflag2 & MFLAG2_KAGE) && (r_info[MON_KAGE].r_tkills < MAX_SHORT)) r_info[MON_KAGE].r_tkills++;
1427 else if (r_ptr->r_tkills < MAX_SHORT) r_ptr->r_tkills++;
1429 /* Hack -- Auto-recall */
1430 monster_race_track(m_ptr->ap_r_idx);
1433 /* Extract monster name */
1434 monster_desc(m_name, m_ptr, MD_TRUE_NAME);
1436 /* Don't kill Amberites */
1437 if ((r_ptr->flags3 & RF3_AMBERITE) && one_in_(2))
1439 int curses = 1 + randint1(3);
1440 bool stop_ty = FALSE;
1443 msg_format(_("%^sは恐ろしい血の呪いをあなたにかけた!", "%^s puts a terrible blood curse on you!"), m_name);
1444 curse_equipment(100, 50);
1448 stop_ty = activate_ty_curse(stop_ty, &count);
1453 if (r_ptr->flags2 & RF2_CAN_SPEAK)
1455 char line_got[1024];
1456 if (!get_rnd_line(_("mondeath_j.txt", "mondeath.txt"), m_ptr->r_idx, line_got))
1458 msg_format("%^s %s", m_name, line_got);
1462 if (m_ptr->r_idx == MON_SERPENT)
1464 screen_dump = make_screen_dump();
1469 if (!(d_info[dungeon_type].flags1 & DF1_BEGINNER))
1471 if (!dun_level && !ambush_flag && !p_ptr->inside_arena)
1473 chg_virtue(V_VALOUR, -1);
1475 else if (r_ptr->level > dun_level)
1477 if (randint1(10) <= (r_ptr->level - dun_level))
1478 chg_virtue(V_VALOUR, 1);
1480 if (r_ptr->level > 60)
1482 chg_virtue(V_VALOUR, 1);
1484 if (r_ptr->level >= 2 * (p_ptr->lev+1))
1485 chg_virtue(V_VALOUR, 2);
1488 if (r_ptr->flags1 & RF1_UNIQUE)
1490 if (r_ptr->flags3 & (RF3_EVIL | RF3_GOOD)) chg_virtue(V_HARMONY, 2);
1492 if (r_ptr->flags3 & RF3_GOOD)
1494 chg_virtue(V_UNLIFE, 2);
1495 chg_virtue(V_VITALITY, -2);
1498 if (one_in_(3)) chg_virtue(V_INDIVIDUALISM, -1);
1501 if (m_ptr->r_idx == MON_BEGGAR || m_ptr->r_idx == MON_LEPER)
1503 chg_virtue(V_COMPASSION, -1);
1506 if ((r_ptr->flags3 & RF3_GOOD) && ((r_ptr->level) / 10 + (3 * dun_level) >= randint1(100)))
1507 chg_virtue(V_UNLIFE, 1);
1509 if (r_ptr->d_char == 'A')
1511 if (r_ptr->flags1 & RF1_UNIQUE)
1512 chg_virtue(V_FAITH, -2);
1513 else if ((r_ptr->level) / 10 + (3 * dun_level) >= randint1(100))
1515 if (r_ptr->flags3 & RF3_GOOD) chg_virtue(V_FAITH, -1);
1516 else chg_virtue(V_FAITH, 1);
1519 else if (r_ptr->flags3 & RF3_DEMON)
1521 if (r_ptr->flags1 & RF1_UNIQUE)
1522 chg_virtue(V_FAITH, 2);
1523 else if ((r_ptr->level) / 10 + (3 * dun_level) >= randint1(100))
1524 chg_virtue(V_FAITH, 1);
1527 if ((r_ptr->flags3 & RF3_UNDEAD) && (r_ptr->flags1 & RF1_UNIQUE))
1528 chg_virtue(V_VITALITY, 2);
1530 if (r_ptr->r_deaths)
1532 if (r_ptr->flags1 & RF1_UNIQUE)
1534 chg_virtue(V_HONOUR, 10);
1536 else if ((r_ptr->level) / 10 + (2 * dun_level) >= randint1(100))
1538 chg_virtue(V_HONOUR, 1);
1541 if ((r_ptr->flags2 & RF2_MULTIPLY) && (r_ptr->r_akills > 1000) && one_in_(10))
1543 chg_virtue(V_VALOUR, -1);
1546 for (i = 0; i < 4; i++)
1548 if (r_ptr->blow[i].d_dice != 0) innocent = FALSE; /* Murderer! */
1550 if ((r_ptr->blow[i].effect == RBE_EAT_ITEM)
1551 || (r_ptr->blow[i].effect == RBE_EAT_GOLD))
1553 thief = TRUE; /* Thief! */
1556 /* The new law says it is illegal to live in the dungeon */
1557 if (r_ptr->level != 0) innocent = FALSE;
1561 if (r_ptr->flags1 & RF1_UNIQUE)
1562 chg_virtue(V_JUSTICE, 3);
1563 else if (1+((r_ptr->level) / 10 + (2 * dun_level)) >= randint1(100))
1564 chg_virtue(V_JUSTICE, 1);
1568 chg_virtue (V_JUSTICE, -1);
1571 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)))
1573 if (one_in_(4)) chg_virtue(V_NATURE, -1);
1576 if ((r_ptr->flags1 & RF1_UNIQUE) && record_destroy_uniq)
1579 sprintf(note_buf, "%s%s", r_name + r_ptr->name, (m_ptr->smart & SM_CLONED) ? _("(クローン)", "(Clone)") : "");
1580 do_cmd_write_nikki(NIKKI_UNIQUE, 0, note_buf);
1586 /* Death by Missile/Spell attack */
1589 msg_format("%^s%s", m_name, note);
1592 /* Death by physical attack -- invisible monster */
1593 else if (!m_ptr->ml)
1596 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
1597 msg_format("せっかくだから%sを殺した。", m_name);
1599 msg_format("%sを殺した。", m_name);
1601 msg_format("You have killed %s.", m_name);
1606 /* Death by Physical attack -- non-living monster */
1607 else if (!monster_living(m_ptr->r_idx))
1609 bool explode = FALSE;
1611 for (i = 0; i < 4; i++)
1613 if (r_ptr->blow[i].method == RBM_EXPLODE) explode = TRUE;
1616 /* Special note at death */
1618 msg_format(_("%sは爆発して粉々になった。", "%^s explodes into tiny shreds."), m_name);
1622 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
1623 msg_format("せっかくだから%sを倒した。", m_name);
1625 msg_format("%sを倒した。", m_name);
1627 msg_format("You have destroyed %s.", m_name);
1632 /* Death by Physical attack -- living monster */
1636 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
1637 msg_format("せっかくだから%sを葬り去った。", m_name);
1639 msg_format("%sを葬り去った。", m_name);
1641 msg_format("You have slain %s.", m_name);
1645 if ((r_ptr->flags1 & RF1_UNIQUE) && !(m_ptr->smart & SM_CLONED) && !vanilla_town)
1647 for (i = 0; i < MAX_KUBI; i++)
1649 if ((kubi_r_idx[i] == m_ptr->r_idx) && !(m_ptr->mflag2 & MFLAG2_CHAMELEON))
1651 msg_format(_("%sの首には賞金がかかっている。", "There is a price on %s's head."), m_name);
1657 /* Generate treasure */
1658 monster_death(m_idx, TRUE);
1660 /* Mega hack : replace IKETA to BIKETAL */
1661 if ((m_ptr->r_idx == MON_IKETA) && !(p_ptr->inside_arena || p_ptr->inside_battle))
1663 POSITION dummy_y = m_ptr->fy;
1664 POSITION dummy_x = m_ptr->fx;
1665 BIT_FLAGS mode = 0L;
1666 if (is_pet(m_ptr)) mode |= PM_FORCE_PET;
1667 delete_monster_idx(m_idx);
1668 if (summon_named_creature(0, dummy_y, dummy_x, MON_BIKETAL, mode))
1670 msg_print(_("「ハァッハッハッハ!!私がバイケタルだ!!」", "Uwa-hahaha! *I* am Biketal!"));
1675 delete_monster_idx(m_idx);
1678 get_exp_from_mon((long)exp_mon.max_maxhp*2, &exp_mon);
1683 /* Monster is dead */
1690 /* Mega-Hack -- Pain cancels fear */
1691 if (MON_MONFEAR(m_ptr) && (dam > 0))
1694 if (set_monster_monfear(m_idx, MON_MONFEAR(m_ptr) - randint1(dam)))
1701 /* Sometimes a monster gets scared by damage */
1702 if (!MON_MONFEAR(m_ptr) && !(r_ptr->flags3 & (RF3_NO_FEAR)))
1704 /* Percentage of fully healthy */
1705 int percentage = (100L * m_ptr->hp) / m_ptr->maxhp;
1708 * Run (sometimes) if at 10% or less of max hit points,
1709 * or (usually) when hit for half its current hit points
1711 if ((randint1(10) >= percentage) || ((dam >= m_ptr->hp) && (randint0(100) < 80)))
1713 /* Hack -- note fear */
1716 /* Hack -- Add some timed fear */
1717 (void)set_monster_monfear(m_idx, (randint1(10) +
1718 (((dam >= m_ptr->hp) && (percentage > 7)) ?
1719 20 : ((11 - percentage) * 5))));
1731 * @brief 現在のコンソール表示の縦横を返す。 /
1732 * Get term size and calculate screen size
1733 * @param wid_p コンソールの表示幅文字数を返す
1734 * @param hgt_p コンソールの表示行数を返す
1737 void get_screen_size(TERM_LEN *wid_p, TERM_LEN *hgt_p)
1739 Term_get_size(wid_p, hgt_p);
1740 *hgt_p -= ROW_MAP + 2;
1741 *wid_p -= COL_MAP + 2;
1742 if (use_bigtile) *wid_p /= 2;
1747 * @brief コンソール上におけるマップ表示の左上位置を返す /
1748 * Calculates current boundaries Called below and from "do_cmd_locate()".
1751 void panel_bounds_center(void)
1755 get_screen_size(&wid, &hgt);
1757 panel_row_max = panel_row_min + hgt - 1;
1758 panel_row_prt = panel_row_min - 1;
1759 panel_col_max = panel_col_min + wid - 1;
1760 panel_col_prt = panel_col_min - 13;
1765 * @brief コンソールのリサイズに合わせてマップを再描画する /
1766 * Map resizing whenever the main term changes size
1769 void resize_map(void)
1771 /* Only if the dungeon exists */
1772 if (!character_dungeon) return;
1774 /* Mega-Hack -- no panel yet */
1778 /* Reset the panels */
1779 panel_row_min = cur_hgt;
1780 panel_col_min = cur_wid;
1784 p_ptr->update |= (PU_TORCH | PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
1785 p_ptr->update |= (PU_UN_VIEW | PU_UN_LITE);
1786 p_ptr->update |= (PU_VIEW | PU_LITE | PU_MON_LITE);
1787 p_ptr->update |= (PU_MONSTERS);
1788 p_ptr->redraw |= (PR_WIPE | PR_BASIC | PR_EXTRA | PR_MAP | PR_EQUIPPY);
1795 * Place the cursor on the player
1797 if (can_save) move_cursor_relative(p_ptr->y, p_ptr->x);
1803 * @brief コンソールを再描画する /
1804 * Redraw a term when it is resized
1807 void redraw_window(void)
1809 /* Only if the dungeon exists */
1810 if (!character_dungeon) return;
1812 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_SPELL | PW_PLAYER);
1813 p_ptr->window |= (PW_MESSAGE | PW_OVERHEAD | PW_DUNGEON | PW_MONSTER | PW_OBJECT);
1821 * @brief フォーカスを当てるべきマップ描画の基準座標を指定する(サブルーチン)
1822 * @param dy 変更先のフロアY座標
1823 * @param dx 変更先のフロアX座標
1824 * Handle a request to change the current panel
1825 * Return TRUE if the panel was changed.
1826 * Also used in do_cmd_locate
1827 * @return 実際に再描画が必要だった場合TRUEを返す
1829 bool change_panel(POSITION dy, POSITION dx)
1834 get_screen_size(&wid, &hgt);
1836 /* Apply the motion */
1837 y = panel_row_min + dy * hgt / 2;
1838 x = panel_col_min + dx * wid / 2;
1840 /* Verify the row */
1841 if (y > cur_hgt - hgt) y = cur_hgt - hgt;
1844 /* Verify the col */
1845 if (x > cur_wid - wid) x = cur_wid - wid;
1848 /* Handle "changes" */
1849 if ((y != panel_row_min) || (x != panel_col_min))
1851 /* Save the new panel info */
1855 /* Recalculate the boundaries */
1856 panel_bounds_center();
1858 p_ptr->update |= (PU_MONSTERS);
1859 p_ptr->redraw |= (PR_MAP);
1871 * @brief フォーカスを当てるべきマップ描画の基準座標を指定する
1872 * @param y 変更先のフロアY座標
1873 * @param x 変更先のフロアX座標
1875 * Handle a request to change the current panel
1876 * Return TRUE if the panel was changed.
1877 * Also used in do_cmd_locate
1878 * @return 実際に再描画が必要だった場合TRUEを返す
1880 static bool change_panel_xy(POSITION y, POSITION x)
1882 POSITION dy = 0, dx = 0;
1885 get_screen_size(&wid, &hgt);
1887 if (y < panel_row_min) dy = -1;
1888 if (y > panel_row_max) dy = 1;
1889 if (x < panel_col_min) dx = -1;
1890 if (x > panel_col_max) dx = 1;
1892 if (!dy && !dx) return (FALSE);
1894 return change_panel(dy, dx);
1899 * @brief マップ描画のフォーカスを当てるべき座標を更新する
1901 * Given an row (y) and col (x), this routine detects when a move
1902 * off the screen has occurred and figures new borders. -RAK-
1903 * "Update" forces a "full update" to take place.
1904 * The map is reprinted if necessary, and "TRUE" is returned.
1905 * @return 実際に再描画が必要だった場合TRUEを返す
1907 void verify_panel(void)
1909 POSITION y = p_ptr->y;
1910 POSITION x = p_ptr->x;
1918 get_screen_size(&wid, &hgt);
1920 max_prow_min = cur_hgt - hgt;
1921 max_pcol_min = cur_wid - wid;
1923 /* Bounds checking */
1924 if (max_prow_min < 0) max_prow_min = 0;
1925 if (max_pcol_min < 0) max_pcol_min = 0;
1927 /* Center on player */
1928 if (center_player && (center_running || !running))
1930 /* Center vertically */
1931 prow_min = y - hgt / 2;
1932 if (prow_min < 0) prow_min = 0;
1933 else if (prow_min > max_prow_min) prow_min = max_prow_min;
1935 /* Center horizontally */
1936 pcol_min = x - wid / 2;
1937 if (pcol_min < 0) pcol_min = 0;
1938 else if (pcol_min > max_pcol_min) pcol_min = max_pcol_min;
1942 prow_min = panel_row_min;
1943 pcol_min = panel_col_min;
1945 /* Scroll screen when 2 grids from top/bottom edge */
1946 if (y > panel_row_max - 2)
1948 while (y > prow_min + hgt-1 - 2)
1950 prow_min += (hgt / 2);
1954 if (y < panel_row_min + 2)
1956 while (y < prow_min + 2)
1958 prow_min -= (hgt / 2);
1962 if (prow_min > max_prow_min) prow_min = max_prow_min;
1963 if (prow_min < 0) prow_min = 0;
1965 /* Scroll screen when 4 grids from left/right edge */
1966 if (x > panel_col_max - 4)
1968 while (x > pcol_min + wid-1 - 4)
1970 pcol_min += (wid / 2);
1974 if (x < panel_col_min + 4)
1976 while (x < pcol_min + 4)
1978 pcol_min -= (wid / 2);
1982 if (pcol_min > max_pcol_min) pcol_min = max_pcol_min;
1983 if (pcol_min < 0) pcol_min = 0;
1986 /* Check for "no change" */
1987 if ((prow_min == panel_row_min) && (pcol_min == panel_col_min)) return;
1989 /* Save the new panel info */
1990 panel_row_min = prow_min;
1991 panel_col_min = pcol_min;
1993 /* Hack -- optional disturb on "panel change" */
1994 if (disturb_panel && !center_player) disturb(FALSE, FALSE);
1996 /* Recalculate the boundaries */
1997 panel_bounds_center();
1999 p_ptr->update |= (PU_MONSTERS);
2000 p_ptr->redraw |= (PR_MAP);
2001 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
2006 * Monster health description
2008 cptr look_mon_desc(monster_type *m_ptr, BIT_FLAGS mode)
2010 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
2017 /* Determine if the monster is "living" */
2018 living = monster_living(m_ptr->ap_r_idx);
2020 /* Calculate a health "percentage" */
2021 perc = m_ptr->maxhp > 0 ? 100L * m_ptr->hp / m_ptr->maxhp : 0;
2023 /* Healthy monsters */
2024 if (m_ptr->hp >= m_ptr->maxhp)
2026 desc = living ? _("無傷", "unhurt") : _("無ダメージ", "undamaged");
2029 else if (perc >= 60)
2031 desc = living ? _("軽傷", "somewhat wounded") : _("小ダメージ", "somewhat damaged");
2034 else if (perc >= 25)
2036 desc = living ? _("負傷", "wounded") : _("中ダメージ", "damaged");
2039 else if (perc >= 10)
2041 desc = living ? _("重傷", "badly wounded") : _("大ダメージ", "badly damaged");
2046 desc = living ? _("半死半生", "almost dead") : _("倒れかけ", "almost destroyed");
2049 /* Need attitude information? */
2052 /* Full information is not needed */
2055 else if (is_pet(m_ptr))
2057 attitude = _(", ペット", ", pet");
2059 else if (is_friendly(m_ptr))
2061 attitude = _(", 友好的", ", friendly");
2065 attitude = _("", "");
2068 /* Clone monster? */
2069 if (m_ptr->smart & SM_CLONED)
2078 /* Display monster's level --- idea borrowed from ToME */
2079 if (ap_r_ptr->r_tkills && !(m_ptr->mflag2 & MFLAG2_KAGE))
2081 return format(_("レベル%d, %s%s%s", "Level %d, %s%s%s"), ap_r_ptr->level, desc, attitude, clone);
2085 return format(_("レベル???, %s%s%s", "Level ???, %s%s%s"), desc, attitude, clone);
2093 * Angband sorting algorithm -- quick sort in place
2095 * Note that the details of the data we are sorting is hidden,
2096 * and we rely on the "ang_sort_comp()" and "ang_sort_swap()"
2097 * function hooks to interact with the data, which is given as
2098 * two pointers, and which may have any user-defined form.
2100 void ang_sort_aux(vptr u, vptr v, int p, int q)
2118 while (!(*ang_sort_comp)(u, v, b, z)) b--;
2121 while (!(*ang_sort_comp)(u, v, z, a)) a++;
2123 /* Done partition */
2127 (*ang_sort_swap)(u, v, a, b);
2133 /* Recurse left side */
2134 ang_sort_aux(u, v, p, b);
2136 /* Recurse right side */
2137 ang_sort_aux(u, v, b+1, q);
2142 * Angband sorting algorithm -- quick sort in place
2144 * Note that the details of the data we are sorting is hidden,
2145 * and we rely on the "ang_sort_comp()" and "ang_sort_swap()"
2146 * function hooks to interact with the data, which is given as
2147 * two pointers, and which may have any user-defined form.
2149 void ang_sort(vptr u, vptr v, int n)
2151 /* Sort the array */
2152 ang_sort_aux(u, v, 0, n-1);
2157 /*** Targeting Code ***/
2161 * Determine is a monster makes a reasonable target
2163 * The concept of "targeting" was stolen from "Morgul" (?)
2165 * The player can target any location, or any "target-able" monster.
2167 * Currently, a monster is "target_able" if it is visible, and if
2168 * the player can hit it with a projection, and the player is not
2169 * hallucinating. This allows use of "use closest target" macros.
2171 * Future versions may restrict the ability to target "trappers"
2172 * and "mimics", but the semantics is a little bit weird.
2174 bool target_able(MONSTER_IDX m_idx)
2176 monster_type *m_ptr = &m_list[m_idx];
2178 /* Monster must be alive */
2179 if (!m_ptr->r_idx) return (FALSE);
2181 /* Hack -- no targeting hallucinations */
2182 if (p_ptr->image) return (FALSE);
2184 /* Monster must be visible */
2185 if (!m_ptr->ml) return (FALSE);
2187 if (p_ptr->riding && (p_ptr->riding == m_idx)) return (TRUE);
2189 /* Monster must be projectable */
2190 if (!projectable(p_ptr->y, p_ptr->x, m_ptr->fy, m_ptr->fx)) return (FALSE);
2192 /* Hack -- Never target trappers */
2193 /* if (CLEAR_ATTR && (CLEAR_CHAR)) return (FALSE); */
2203 * Update (if necessary) and verify (if possible) the target.
2205 * We return TRUE if the target is "okay" and FALSE otherwise.
2207 bool target_okay(void)
2209 /* Accept stationary targets */
2210 if (target_who < 0) return (TRUE);
2212 /* Check moving targets */
2215 /* Accept reasonable targets */
2216 if (target_able(target_who))
2218 monster_type *m_ptr = &m_list[target_who];
2220 /* Acquire monster location */
2221 target_row = m_ptr->fy;
2222 target_col = m_ptr->fx;
2229 /* Assume no target */
2235 * Sorting hook -- comp function -- by "distance to player"
2237 * We use "u" and "v" to point to arrays of "x" and "y" positions,
2238 * and sort the arrays by double-distance to the player.
2240 static bool ang_sort_comp_distance(vptr u, vptr v, int a, int b)
2242 POSITION *x = (POSITION*)(u);
2243 POSITION *y = (POSITION*)(v);
2245 POSITION da, db, kx, ky;
2247 /* Absolute distance components */
2248 kx = x[a]; kx -= p_ptr->x; kx = ABS(kx);
2249 ky = y[a]; ky -= p_ptr->y; ky = ABS(ky);
2251 /* Approximate Double Distance to the first point */
2252 da = ((kx > ky) ? (kx + kx + ky) : (ky + ky + kx));
2254 /* Absolute distance components */
2255 kx = x[b]; kx -= p_ptr->x; kx = ABS(kx);
2256 ky = y[b]; ky -= p_ptr->y; ky = ABS(ky);
2258 /* Approximate Double Distance to the first point */
2259 db = ((kx > ky) ? (kx + kx + ky) : (ky + ky + kx));
2261 /* Compare the distances */
2267 * Sorting hook -- comp function -- by importance level of grids
2269 * We use "u" and "v" to point to arrays of "x" and "y" positions,
2270 * and sort the arrays by level of monster
2272 static bool ang_sort_comp_importance(vptr u, vptr v, int a, int b)
2274 POSITION *x = (POSITION*)(u);
2275 POSITION *y = (POSITION*)(v);
2276 cave_type *ca_ptr = &cave[y[a]][x[a]];
2277 cave_type *cb_ptr = &cave[y[b]][x[b]];
2278 monster_type *ma_ptr = &m_list[ca_ptr->m_idx];
2279 monster_type *mb_ptr = &m_list[cb_ptr->m_idx];
2280 monster_race *ap_ra_ptr, *ap_rb_ptr;
2282 /* The player grid */
2283 if (y[a] == p_ptr->y && x[a] == p_ptr->x) return TRUE;
2284 if (y[b] == p_ptr->y && x[b] == p_ptr->x) return FALSE;
2286 /* Extract monster race */
2287 if (ca_ptr->m_idx && ma_ptr->ml) ap_ra_ptr = &r_info[ma_ptr->ap_r_idx];
2288 else ap_ra_ptr = NULL;
2289 if (cb_ptr->m_idx && mb_ptr->ml) ap_rb_ptr = &r_info[mb_ptr->ap_r_idx];
2290 else ap_rb_ptr = NULL;
2292 if (ap_ra_ptr && !ap_rb_ptr) return TRUE;
2293 if (!ap_ra_ptr && ap_rb_ptr) return FALSE;
2295 /* Compare two monsters */
2296 if (ap_ra_ptr && ap_rb_ptr)
2298 /* Unique monsters first */
2299 if ((ap_ra_ptr->flags1 & RF1_UNIQUE) && !(ap_rb_ptr->flags1 & RF1_UNIQUE)) return TRUE;
2300 if (!(ap_ra_ptr->flags1 & RF1_UNIQUE) && (ap_rb_ptr->flags1 & RF1_UNIQUE)) return FALSE;
2302 /* Shadowers first (あやしい影) */
2303 if ((ma_ptr->mflag2 & MFLAG2_KAGE) && !(mb_ptr->mflag2 & MFLAG2_KAGE)) return TRUE;
2304 if (!(ma_ptr->mflag2 & MFLAG2_KAGE) && (mb_ptr->mflag2 & MFLAG2_KAGE)) return FALSE;
2306 /* Unknown monsters first */
2307 if (!ap_ra_ptr->r_tkills && ap_rb_ptr->r_tkills) return TRUE;
2308 if (ap_ra_ptr->r_tkills && !ap_rb_ptr->r_tkills) return FALSE;
2310 /* Higher level monsters first (if known) */
2311 if (ap_ra_ptr->r_tkills && ap_rb_ptr->r_tkills)
2313 if (ap_ra_ptr->level > ap_rb_ptr->level) return TRUE;
2314 if (ap_ra_ptr->level < ap_rb_ptr->level) return FALSE;
2317 /* Sort by index if all conditions are same */
2318 if (ma_ptr->ap_r_idx > mb_ptr->ap_r_idx) return TRUE;
2319 if (ma_ptr->ap_r_idx < mb_ptr->ap_r_idx) return FALSE;
2322 /* An object get higher priority */
2323 if (cave[y[a]][x[a]].o_idx && !cave[y[b]][x[b]].o_idx) return TRUE;
2324 if (!cave[y[a]][x[a]].o_idx && cave[y[b]][x[b]].o_idx) return FALSE;
2326 /* Priority from the terrain */
2327 if (f_info[ca_ptr->feat].priority > f_info[cb_ptr->feat].priority) return TRUE;
2328 if (f_info[ca_ptr->feat].priority < f_info[cb_ptr->feat].priority) return FALSE;
2330 /* If all conditions are same, compare distance */
2331 return ang_sort_comp_distance(u, v, a, b);
2336 * Sorting hook -- swap function -- by "distance to player"
2338 * We use "u" and "v" to point to arrays of "x" and "y" positions,
2339 * and sort the arrays by distance to the player.
2341 static void ang_sort_swap_distance(vptr u, vptr v, int a, int b)
2343 POSITION *x = (POSITION*)(u);
2344 POSITION *y = (POSITION*)(v);
2362 * Hack -- help "select" a location (see below)
2364 static POSITION_IDX target_pick(POSITION y1, POSITION x1, POSITION dy, POSITION dx)
2367 POSITION x2, y2, x3, y3, x4, y4;
2368 POSITION_IDX b_i = -1, b_v = 9999;
2371 /* Scan the locations */
2372 for (i = 0; i < temp_n; i++)
2378 /* Directed distance */
2382 /* Verify quadrant */
2383 if (dx && (x3 * dx <= 0)) continue;
2384 if (dy && (y3 * dy <= 0)) continue;
2386 /* Absolute distance */
2390 /* Verify quadrant */
2391 if (dy && !dx && (x4 > y4)) continue;
2392 if (dx && !dy && (y4 > x4)) continue;
2394 /* Approximate Double Distance */
2395 v = ((x4 > y4) ? (x4 + x4 + y4) : (y4 + y4 + x4));
2397 /* Penalize location */
2400 if ((b_i >= 0) && (v >= b_v)) continue;
2410 * Hack -- determine if a given location is "interesting"
2412 static bool target_set_accept(POSITION y, POSITION x)
2415 OBJECT_IDX this_o_idx, next_o_idx = 0;
2418 if (!(in_bounds(y, x))) return (FALSE);
2420 /* Player grid is always interesting */
2421 if (player_bold(y, x)) return (TRUE);
2423 /* Handle hallucination */
2424 if (p_ptr->image) return (FALSE);
2426 /* Examine the grid */
2427 c_ptr = &cave[y][x];
2429 /* Visible monsters */
2432 monster_type *m_ptr = &m_list[c_ptr->m_idx];
2434 /* Visible monsters */
2435 if (m_ptr->ml) return (TRUE);
2438 /* Scan all objects in the grid */
2439 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
2442 o_ptr = &o_list[this_o_idx];
2444 /* Acquire next object */
2445 next_o_idx = o_ptr->next_o_idx;
2447 /* Memorized object */
2448 if (o_ptr->marked & OM_FOUND) return (TRUE);
2451 /* Interesting memorized features */
2452 if (c_ptr->info & (CAVE_MARK))
2454 /* Notice object features */
2455 if (c_ptr->info & CAVE_OBJECT) return (TRUE);
2457 /* Feature code (applying "mimic" field) */
2458 if (have_flag(f_info[get_feat_mimic(c_ptr)].flags, FF_NOTICE)) return TRUE;
2466 * Prepare the "temp" array for "target_set"
2468 * Return the number of target_able monsters in the set.
2470 static void target_set_prepare(BIT_FLAGS mode)
2473 POSITION min_hgt, max_hgt, min_wid, max_wid;
2475 if (mode & TARGET_KILL)
2478 min_hgt = MAX((p_ptr->y - MAX_RANGE), 0);
2479 max_hgt = MIN((p_ptr->y + MAX_RANGE), cur_hgt - 1);
2480 min_wid = MAX((p_ptr->x - MAX_RANGE), 0);
2481 max_wid = MIN((p_ptr->x + MAX_RANGE), cur_wid - 1);
2483 else /* not targetting */
2486 min_hgt = panel_row_min;
2487 max_hgt = panel_row_max;
2488 min_wid = panel_col_min;
2489 max_wid = panel_col_max;
2492 /* Reset "temp" array */
2495 /* Scan the current panel */
2496 for (y = min_hgt; y <= max_hgt; y++)
2498 for (x = min_wid; x <= max_wid; x++)
2502 /* Require "interesting" contents */
2503 if (!target_set_accept(y, x)) continue;
2505 c_ptr = &cave[y][x];
2507 /* Require target_able monsters for "TARGET_KILL" */
2508 if ((mode & (TARGET_KILL)) && !target_able(c_ptr->m_idx)) continue;
2510 if ((mode & (TARGET_KILL)) && !target_pet && is_pet(&m_list[c_ptr->m_idx])) continue;
2512 /* Save the location */
2519 /* Set the sort hooks */
2520 if (mode & (TARGET_KILL))
2522 /* Target the nearest monster for shooting */
2523 ang_sort_comp = ang_sort_comp_distance;
2524 ang_sort_swap = ang_sort_swap_distance;
2528 /* Look important grids first in Look command */
2529 ang_sort_comp = ang_sort_comp_importance;
2530 ang_sort_swap = ang_sort_swap_distance;
2533 /* Sort the positions */
2534 ang_sort(temp_x, temp_y, temp_n);
2536 if (p_ptr->riding && target_pet && (temp_n > 1) && (mode & (TARGET_KILL)))
2541 temp_y[0] = temp_y[1];
2544 temp_x[0] = temp_x[1];
2549 void target_set_prepare_look(void){
2550 target_set_prepare(TARGET_LOOK);
2555 * Evaluate number of kill needed to gain level
2557 static void evaluate_monster_exp(char *buf, monster_type *m_ptr)
2559 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
2561 s32b exp_mon, exp_adv;
2562 u32b exp_mon_frac, exp_adv_frac;
2564 if ((p_ptr->lev >= PY_MAX_LEVEL) || (p_ptr->prace == RACE_ANDROID))
2569 else if (!ap_r_ptr->r_tkills || (m_ptr->mflag2 & MFLAG2_KAGE))
2579 /* The monster's experience point (assuming average monster speed) */
2580 exp_mon = ap_r_ptr->mexp * ap_r_ptr->level;
2582 s64b_div(&exp_mon, &exp_mon_frac, 0, (p_ptr->max_plv + 2));
2585 /* Total experience value for next level */
2586 exp_adv = player_exp[p_ptr->lev -1] * p_ptr->expfact;
2588 s64b_div(&exp_adv, &exp_adv_frac, 0, 100);
2590 /* Experience value need to get */
2591 s64b_sub(&exp_adv, &exp_adv_frac, p_ptr->exp, p_ptr->exp_frac);
2594 /* You need to kill at least one monster to get any experience */
2595 s64b_add(&exp_adv, &exp_adv_frac, exp_mon, exp_mon_frac);
2596 s64b_sub(&exp_adv, &exp_adv_frac, 0, 1);
2598 /* Extract number of monsters needed */
2599 s64b_div(&exp_adv, &exp_adv_frac, exp_mon, exp_mon_frac);
2601 /* If 999 or more monsters needed, only display "999". */
2602 num = MIN(999, exp_adv_frac);
2604 /* Display the number */
2605 sprintf(buf,"%03ld", (long int)num);
2609 bool show_gold_on_floor = FALSE;
2612 * Examine a grid, return a keypress.
2614 * The "mode" argument contains the "TARGET_LOOK" bit flag, which
2615 * indicates that the "space" key should scan through the contents
2616 * of the grid, instead of simply returning immediately. This lets
2617 * the "look" command get complete information, without making the
2618 * "target" command annoying.
2620 * The "info" argument contains the "commands" which should be shown
2621 * inside the "[xxx]" text. This string must never be empty, or grids
2622 * containing monsters will be displayed with an extra comma.
2624 * Note that if a monster is in the grid, we update both the monster
2625 * recall info and the health bar info to track that monster.
2627 * Eventually, we may allow multiple objects per grid, or objects
2628 * and terrain features in the same grid.
2630 * This function must handle blindness/hallucination.
2632 static char target_set_aux(POSITION y, POSITION x, BIT_FLAGS mode, cptr info)
2634 cave_type *c_ptr = &cave[y][x];
2635 OBJECT_IDX this_o_idx, next_o_idx = 0;
2636 cptr s1 = "", s2 = "", s3 = "", x_info = "";
2639 feature_type *f_ptr;
2640 char query = '\001';
2641 char out_val[MAX_NLEN+80];
2642 OBJECT_IDX floor_list[23];
2643 ITEM_NUMBER floor_num = 0;
2645 /* Scan all objects in the grid */
2648 floor_num = scan_floor(floor_list, y, x, 0x02);
2652 x_info = _("x物 ", "x,");
2656 /* Hack -- under the player */
2657 if (player_bold(y, x))
2670 s1 = _("ターゲット:", "Target:");
2673 /* Hack -- hallucination */
2676 cptr name = _("何か奇妙な物", "something strange");
2678 /* Display a message */
2680 sprintf(out_val, "%s%s%s%s [%s]", s1, name, s2, s3, info);
2682 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, name, info);
2686 move_cursor_relative(y, x);
2689 /* Stop on everything but "return" */
2690 if ((query != '\r') && (query != '\n')) return query;
2692 /* Repeat forever */
2697 /* Actual monsters */
2698 if (c_ptr->m_idx && m_list[c_ptr->m_idx].ml)
2700 monster_type *m_ptr = &m_list[c_ptr->m_idx];
2701 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
2702 GAME_TEXT m_name[MAX_NLEN];
2703 bool recall = FALSE;
2708 monster_desc(m_name, m_ptr, MD_INDEF_VISIBLE);
2709 monster_race_track(m_ptr->ap_r_idx);
2710 health_track(c_ptr->m_idx);
2723 /* Recall on screen */
2724 screen_roff(m_ptr->ap_r_idx, 0);
2726 /* Hack -- Complete the prompt (again) */
2727 Term_addstr(-1, TERM_WHITE, format(_(" [r思 %s%s]", " [r,%s%s]"), x_info, info));
2734 /* Normal commands */
2735 if (query != 'r') break;
2740 /* Cleare recall text and repeat */
2746 /* Describe, and prompt for recall */
2747 evaluate_monster_exp(acount, m_ptr);
2750 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);
2752 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);
2758 move_cursor_relative(y, x);
2763 /* Normal commands */
2764 if (query != 'r') break;
2770 /* Always stop at "normal" keys */
2771 if ((query != '\r') && (query != '\n') && (query != ' ') && (query != 'x')) return query;
2773 /* Sometimes stop at "space" key */
2774 if ((query == ' ') && !(mode & (TARGET_LOOK))) return query;
2776 /* Change the intro */
2777 s1 = _("それは", "It is ");
2779 /* Hack -- take account of gender */
2780 if (ap_r_ptr->flags1 & (RF1_FEMALE)) s1 = _("彼女は", "She is ");
2781 else if (ap_r_ptr->flags1 & (RF1_MALE)) s1 = _("彼は", "He is ");
2783 /* Use a preposition */
2792 /* Scan all objects being carried */
2793 for (this_o_idx = m_ptr->hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
2795 GAME_TEXT o_name[MAX_NLEN];
2798 o_ptr = &o_list[this_o_idx];
2800 /* Acquire next object */
2801 next_o_idx = o_ptr->next_o_idx;
2803 /* Obtain an object description */
2804 object_desc(o_name, o_ptr, 0);
2807 sprintf(out_val, "%s%s%s%s[%s]", s1, o_name, s2, s3, info);
2809 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, o_name, info);
2813 move_cursor_relative(y, x);
2816 /* Always stop at "normal" keys */
2817 if ((query != '\r') && (query != '\n') && (query != ' ') && (query != 'x')) return query;
2819 /* Sometimes stop at "space" key */
2820 if ((query == ' ') && !(mode & (TARGET_LOOK))) return query;
2822 /* Change the intro */
2823 s2 = _("をまた", "also carrying ");
2826 /* Use a preposition */
2843 GAME_TEXT o_name[MAX_NLEN];
2846 o_ptr = &o_list[floor_list[0]];
2848 object_desc(o_name, o_ptr, 0);
2851 sprintf(out_val, "%s%s%s%s[%s]", s1, o_name, s2, s3, info);
2853 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, o_name, info);
2857 move_cursor_relative(y, x);
2866 /* Provide one cushion before item listing */
2869 /* Display rough information about items */
2871 sprintf(out_val, "%s %d個のアイテム%s%s ['x'で一覧, %s]", s1, (int)floor_num, s2, s3, info);
2873 sprintf(out_val, "%s%s%sa pile of %d items [x,%s]", s1, s2, s3, (int)floor_num, info);
2877 move_cursor_relative(y, x);
2882 /* No request for listing */
2883 if (query != 'x' && query != ' ') return query;
2887 /** Display list of items **/
2889 /* Continue scrolling list if requested */
2897 show_gold_on_floor = TRUE;
2898 (void)show_floor(0, y, x, &min_width);
2899 show_gold_on_floor = FALSE;
2903 sprintf(out_val, "%s %d個のアイテム%s%s [Enterで次へ, %s]", s1, (int)floor_num, s2, s3, info);
2905 sprintf(out_val, "%s%s%sa pile of %d items [Enter,%s]", s1, s2, s3, (int)floor_num, info);
2912 /* Exit unless 'Enter' */
2913 if (query != '\n' && query != '\r')
2918 /* Get the object being moved. */
2919 o_idx = c_ptr->o_idx;
2921 /* Only rotate a pile of two or more objects. */
2922 if (!(o_idx && o_list[o_idx].next_o_idx)) continue;
2924 /* Remove the first object from the list. */
2925 excise_object_idx(o_idx);
2927 /* Find end of the list. */
2929 while (o_list[i].next_o_idx)
2930 i = o_list[i].next_o_idx;
2932 /* Add after the last object. */
2933 o_list[i].next_o_idx = o_idx;
2935 /* Loop and re-display the list */
2942 /* Scan all objects in the grid */
2943 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
2946 o_ptr = &o_list[this_o_idx];
2948 /* Acquire next object */
2949 next_o_idx = o_ptr->next_o_idx;
2951 if (o_ptr->marked & OM_FOUND)
2953 GAME_TEXT o_name[MAX_NLEN];
2958 /* Obtain an object description */
2959 object_desc(o_name, o_ptr, 0);
2962 sprintf(out_val, "%s%s%s%s[%s]", s1, o_name, s2, s3, info);
2964 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, o_name, info);
2968 move_cursor_relative(y, x);
2971 /* Always stop at "normal" keys */
2972 if ((query != '\r') && (query != '\n') && (query != ' ') && (query != 'x')) return query;
2974 /* Sometimes stop at "space" key */
2975 if ((query == ' ') && !(mode & TARGET_LOOK)) return query;
2977 /* Change the intro */
2978 s1 = _("それは", "It is ");
2981 if (o_ptr->number != 1) s1 = _("それらは", "They are ");
2995 /* Feature code (applying "mimic" field) */
2996 feat = get_feat_mimic(c_ptr);
2998 /* Require knowledge about grid, or ability to see grid */
2999 if (!(c_ptr->info & CAVE_MARK) && !player_can_see_bold(y, x))
3001 /* Forget feature */
3005 f_ptr = &f_info[feat];
3007 /* Terrain feature if needed */
3008 if (boring || have_flag(f_ptr->flags, FF_REMEMBER))
3012 /* Hack -- special handling for quest entrances */
3013 if (have_flag(f_ptr->flags, FF_QUEST_ENTER))
3015 /* Set the quest number temporary */
3016 IDX old_quest = p_ptr->inside_quest;
3019 /* Clear the text */
3020 for (j = 0; j < 10; j++) quest_text[j][0] = '\0';
3021 quest_text_line = 0;
3023 p_ptr->inside_quest = c_ptr->special;
3025 /* Get the quest text */
3026 init_flags = INIT_NAME_ONLY;
3028 process_dungeon_file("q_info.txt", 0, 0, 0, 0);
3030 name = format(_("クエスト「%s」(%d階相当)", "the entrance to the quest '%s'(level %d)"),
3031 quest[c_ptr->special].name, quest[c_ptr->special].level);
3033 /* Reset the old quest number */
3034 p_ptr->inside_quest = old_quest;
3037 /* Hack -- special handling for building doors */
3038 else if (have_flag(f_ptr->flags, FF_BLDG) && !p_ptr->inside_arena)
3040 name = building[f_ptr->subtype].name;
3042 else if (have_flag(f_ptr->flags, FF_ENTRANCE))
3044 name = format(_("%s(%d階相当)", "%s(level %d)"), d_text + d_info[c_ptr->special].text, d_info[c_ptr->special].mindepth);
3046 else if (have_flag(f_ptr->flags, FF_TOWN))
3048 name = town[c_ptr->special].name;
3050 else if (p_ptr->wild_mode && (feat == feat_floor))
3052 name = _("道", "road");
3056 name = f_name + f_ptr->name;
3062 ((!have_flag(f_ptr->flags, FF_MOVE) && !have_flag(f_ptr->flags, FF_CAN_FLY)) ||
3063 (!have_flag(f_ptr->flags, FF_LOS) && !have_flag(f_ptr->flags, FF_TREE)) ||
3064 have_flag(f_ptr->flags, FF_TOWN)))
3066 s2 = _("の中", "in ");
3069 /* Hack -- special introduction for store & building doors -KMW- */
3070 if (have_flag(f_ptr->flags, FF_STORE) ||
3071 have_flag(f_ptr->flags, FF_QUEST_ENTER) ||
3072 (have_flag(f_ptr->flags, FF_BLDG) && !p_ptr->inside_arena) ||
3073 have_flag(f_ptr->flags, FF_ENTRANCE))
3078 else if (have_flag(f_ptr->flags, FF_FLOOR) ||
3079 have_flag(f_ptr->flags, FF_TOWN) ||
3080 have_flag(f_ptr->flags, FF_SHALLOW) ||
3081 have_flag(f_ptr->flags, FF_DEEP))
3087 /* Pick proper indefinite article */
3088 s3 = (is_a_vowel(name[0])) ? "an " : "a ";
3092 /* Display a message */
3096 if (c_ptr->mimic) sprintf(f_idx_str, "%d/%d", c_ptr->feat, c_ptr->mimic);
3097 else sprintf(f_idx_str, "%d", c_ptr->feat);
3099 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]);
3101 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);
3106 sprintf(out_val, "%s%s%s%s[%s]", s1, name, s2, s3, info);
3108 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, name, info);
3112 move_cursor_relative(y, x);
3115 /* Always stop at "normal" keys */
3116 if ((query != '\r') && (query != '\n') && (query != ' ')) return query;
3119 /* Stop on everything but "return" */
3120 if ((query != '\r') && (query != '\n')) return query;
3122 /* Repeat forever */
3128 * Handle "target" and "look".
3130 * Note that this code can be called from "get_aim_dir()".
3132 * All locations must be on the current panel. Consider the use of
3133 * "panel_bounds()" to allow "off-panel" targets, perhaps by using
3134 * some form of "scrolling" the map around the cursor.
3135 * That is, consider the possibility of "auto-scrolling" the screen
3136 * while the cursor moves around. This may require changes in the
3137 * "update_monster()" code to allow "visibility" even if off panel, and
3138 * may require dynamic recalculation of the "temp" grid set.
3140 * Hack -- targeting/observing an "outer border grid" may induce
3141 * problems, so this is not currently allowed.
3143 * The player can use the direction keys to move among "interesting"
3144 * grids in a heuristic manner, or the "space", "+", and "-" keys to
3145 * move through the "interesting" grids in a sequential manner, or
3146 * can enter "location" mode, and use the direction keys to move one
3147 * grid at a time in any direction. The "t" (set target) command will
3148 * only target a monster (as opposed to a location) if the monster is
3149 * target_able and the "interesting" mode is being used.
3151 * The current grid is described using the "look" method above, and
3152 * a new command may be entered at any time, but note that if the
3153 * "TARGET_LOOK" bit flag is set (or if we are in "location" mode,
3154 * where "space" has no obvious meaning) then "space" will scan
3155 * through the description of the current grid until done, instead
3156 * of immediately jumping to the next "interesting" grid. This
3157 * allows the "target" command to retain its old semantics.
3159 * The "*", "+", and "-" keys may always be used to jump immediately
3160 * to the next (or previous) interesting grid, in the proper mode.
3162 * The "return" key may always be used to scan through a complete
3163 * grid description (forever).
3165 * This command will cancel any old target, even if used from
3166 * inside the "look" command.
3168 bool target_set(BIT_FLAGS mode)
3171 POSITION y = p_ptr->y;
3172 POSITION x = p_ptr->x;
3182 get_screen_size(&wid, &hgt);
3187 if (rogue_like_commands)
3196 /* Prepare the "temp" array */
3197 target_set_prepare(mode);
3199 /* Start near the player */
3205 /* Interesting grids */
3212 change_panel_xy(y, x);
3214 if (!(mode & TARGET_LOOK)) prt_path(y, x);
3217 c_ptr = &cave[y][x];
3220 if (target_able(c_ptr->m_idx))
3222 strcpy(info, _("q止 t決 p自 o現 +次 -前", "q,t,p,o,+,-,<dir>"));
3225 /* Dis-allow target */
3228 strcpy(info, _("q止 p自 o現 +次 -前", "q,p,o,+,-,<dir>"));
3234 sprintf(cheatinfo, " LOS:%d, PROJECTABLE:%d",
3235 los(p_ptr->y, p_ptr->x, y, x), projectable(p_ptr->y, p_ptr->x, y, x));
3236 strcat(info, cheatinfo);
3239 /* Describe and Prompt */
3241 query = target_set_aux(y, x, mode, info);
3245 /* Assume no "direction" */
3250 if (query == '\r') query = 't';
3268 if (target_able(c_ptr->m_idx))
3270 health_track(c_ptr->m_idx);
3271 target_who = c_ptr->m_idx;
3290 if (!expand_list) done = TRUE;
3300 if (!expand_list) done = TRUE;
3307 /* Recenter the map around the player */
3309 p_ptr->update |= (PU_MONSTERS);
3310 p_ptr->redraw |= (PR_MAP);
3311 p_ptr->window |= (PW_OVERHEAD);
3314 /* Recalculate interesting grids */
3315 target_set_prepare(mode);
3334 if(query == same_key)
3339 if (!expand_list) done = TRUE;
3344 /* Extract the action (if any) */
3345 d = get_keymap_dir(query);
3352 /* Hack -- move around */
3355 /* Modified to scroll to monster */
3356 POSITION y2 = panel_row_min;
3357 POSITION x2 = panel_col_min;
3359 /* Find a new monster */
3360 i = target_pick(temp_y[m], temp_x[m], ddy[d], ddx[d]);
3362 /* Request to target past last interesting grid */
3363 while (flag && (i < 0))
3365 /* Note the change */
3366 if (change_panel(ddy[d], ddx[d]))
3371 /* Recalculate interesting grids */
3372 target_set_prepare(mode);
3374 /* Look at interesting grids */
3377 /* Find a new monster */
3378 i = target_pick(v, u, ddy[d], ddx[d]);
3384 /* Nothing interesting */
3387 POSITION dx = ddx[d];
3388 POSITION dy = ddy[d];
3390 /* Restore previous position */
3393 panel_bounds_center();
3395 p_ptr->update |= (PU_MONSTERS);
3396 p_ptr->redraw |= (PR_MAP);
3397 p_ptr->window |= (PW_OVERHEAD);
3400 /* Recalculate interesting grids */
3401 target_set_prepare(mode);
3403 /* Look at boring grids */
3410 /* Do not move horizontally if unnecessary */
3411 if (((x < panel_col_min + wid / 2) && (dx > 0)) ||
3412 ((x > panel_col_min + wid / 2) && (dx < 0)))
3417 /* Do not move vertically if unnecessary */
3418 if (((y < panel_row_min + hgt / 2) && (dy > 0)) ||
3419 ((y > panel_row_min + hgt / 2) && (dy < 0)))
3424 /* Apply the motion */
3425 if ((y >= panel_row_min+hgt) || (y < panel_row_min) ||
3426 (x >= panel_col_min+wid) || (x < panel_col_min))
3428 if (change_panel(dy, dx)) target_set_prepare(mode);
3431 /* Slide into legality */
3432 if (x >= cur_wid-1) x = cur_wid - 2;
3433 else if (x <= 0) x = 1;
3435 /* Slide into legality */
3436 if (y >= cur_hgt-1) y = cur_hgt- 2;
3437 else if (y <= 0) y = 1;
3446 /* Arbitrary grids */
3449 bool move_fast = FALSE;
3451 if (!(mode & TARGET_LOOK)) prt_path(y, x);
3454 c_ptr = &cave[y][x];
3456 /* Default prompt */
3457 strcpy(info, _("q止 t決 p自 m近 +次 -前", "q,t,p,m,+,-,<dir>"));
3462 sprintf(cheatinfo, " LOS:%d, PROJECTABLE:%d",
3463 los(p_ptr->y, p_ptr->x, y, x),
3464 projectable(p_ptr->y, p_ptr->x, y, x));
3465 strcat(info, cheatinfo);
3468 /* Describe and Prompt (enable "TARGET_LOOK") */
3469 while ((query = target_set_aux(y, x, mode | TARGET_LOOK, info)) == 0);
3471 /* Assume no direction */
3476 if (query == '\r') query = 't';
3479 /* Analyze the keypress */
3503 /* Recenter the map around the player */
3505 p_ptr->update |= (PU_MONSTERS);
3506 p_ptr->redraw |= (PR_MAP);
3507 p_ptr->window |= (PW_OVERHEAD);
3510 /* Recalculate interesting grids */
3511 target_set_prepare(mode);
3533 /* Pick a nearby monster */
3534 for (i = 0; i < temp_n; i++)
3536 t = distance(y, x, temp_y[i], temp_x[i]);
3546 /* Nothing interesting */
3547 if (bd == 999) flag = FALSE;
3554 /* Extract the action (if any) */
3555 d = get_keymap_dir(query);
3557 /* XTRA HACK MOVEFAST */
3558 if (isupper(query)) move_fast = TRUE;
3565 /* Handle "direction" */
3568 POSITION dx = ddx[d];
3569 POSITION dy = ddy[d];
3571 /* XTRA HACK MOVEFAST */
3574 int mag = MIN(wid / 2, hgt / 2);
3584 /* Do not move horizontally if unnecessary */
3585 if (((x < panel_col_min + wid / 2) && (dx > 0)) ||
3586 ((x > panel_col_min + wid / 2) && (dx < 0)))
3591 /* Do not move vertically if unnecessary */
3592 if (((y < panel_row_min + hgt / 2) && (dy > 0)) ||
3593 ((y > panel_row_min + hgt / 2) && (dy < 0)))
3598 /* Apply the motion */
3599 if ((y >= panel_row_min + hgt) || (y < panel_row_min) ||
3600 (x >= panel_col_min + wid) || (x < panel_col_min))
3602 if (change_panel(dy, dx)) target_set_prepare(mode);
3605 /* Slide into legality */
3606 if (x >= cur_wid-1) x = cur_wid - 2;
3607 else if (x <= 0) x = 1;
3609 /* Slide into legality */
3610 if (y >= cur_hgt-1) y = cur_hgt- 2;
3611 else if (y <= 0) y = 1;
3619 /* Clear the top line */
3622 /* Recenter the map around the player */
3624 p_ptr->update |= (PU_MONSTERS);
3625 p_ptr->redraw |= (PR_MAP);
3626 p_ptr->window |= (PW_OVERHEAD);
3629 /* Failure to set target */
3630 if (!target_who) return (FALSE);
3638 * Get an "aiming direction" from the user.
3640 * The "dir" is loaded with 1,2,3,4,6,7,8,9 for "actual direction", and
3641 * "0" for "current target", and "-1" for "entry aborted".
3643 * Note that "Force Target", if set, will pre-empt user interaction,
3644 * if there is a usable target already set.
3646 * Note that confusion over-rides any (explicit?) user choice.
3648 bool get_aim_dir(DIRECTION *dp)
3657 /* Global direction */
3660 /* Hack -- auto-target if requested */
3661 if (use_old_target && target_okay()) dir = 5;
3663 if (repeat_pull(&code))
3668 if (!(code == 5 && !target_okay()))
3670 /* return (TRUE); */
3671 dir = (DIRECTION)code;
3674 *dp = (DIRECTION)code;
3676 /* Ask until satisfied */
3679 /* Choose a prompt */
3682 p = _("方向 ('*'でターゲット選択, ESCで中断)? ", "Direction ('*' to choose a target, Escape to cancel)? ");
3686 p = _("方向 ('5'でターゲットへ, '*'でターゲット再選択, ESCで中断)? ", "Direction ('5' for target, '*' to re-target, Escape to cancel)? ");
3689 /* Get a command (or Cancel) */
3690 if (!get_com(p, &command, TRUE)) break;
3694 if (command == '\r') command = 't';
3697 /* Convert various keys to "standard" keys */
3700 /* Use current target */
3711 /* Set new target */
3716 if (target_set(TARGET_KILL)) dir = 5;
3722 /* Extract the action (if any) */
3723 dir = get_keymap_dir(command);
3729 /* Verify requested targets */
3730 if ((dir == 5) && !target_okay()) dir = 0;
3739 project_length = 0; /* reset to default */
3743 /* Save the direction */
3746 /* Check for confusion */
3747 if (p_ptr->confused)
3749 /* Random direction */
3750 dir = ddd[randint0(8)];
3753 /* Notice confusion */
3754 if (command_dir != dir)
3757 msg_print(_("あなたは混乱している。", "You are confused."));
3760 /* Save direction */
3763 /* repeat_push(dir); */
3764 repeat_push((COMMAND_CODE)command_dir);
3766 /* A "valid" direction was entered */
3771 bool get_direction(DIRECTION *dp, bool allow_under, bool with_steed)
3779 /* Global direction */
3782 if (repeat_pull(&code))
3784 dir = (DIRECTION)code;
3785 /* return (TRUE); */
3787 *dp = (DIRECTION)code;
3791 prompt = _("方向 ('.'足元, ESCで中断)? ", "Direction ('.' at feet, Escape to cancel)? ");
3795 prompt = _("方向 (ESCで中断)? ", "Direction (Escape to cancel)? ");
3798 /* Get a direction */
3803 /* Get a command (or Cancel) */
3804 if (!get_com(prompt, &ch, TRUE)) break;
3807 if ((allow_under) && ((ch == '5') || (ch == '-') || (ch == '.')))
3813 /* Look up the direction */
3814 dir = get_keymap_dir(ch);
3820 /* Prevent weirdness */
3821 if ((dir == 5) && (!allow_under)) dir = 0;
3824 if (!dir) return (FALSE);
3826 /* Save desired direction */
3829 /* Apply "confusion" */
3830 if (p_ptr->confused)
3832 /* Standard confusion */
3833 if (randint0(100) < 75)
3835 /* Random direction */
3836 dir = ddd[randint0(8)];
3839 else if (p_ptr->riding && with_steed)
3841 monster_type *m_ptr = &m_list[p_ptr->riding];
3842 monster_race *r_ptr = &r_info[m_ptr->r_idx];
3844 if (MON_CONFUSED(m_ptr))
3846 /* Standard confusion */
3847 if (randint0(100) < 75)
3849 /* Random direction */
3850 dir = ddd[randint0(8)];
3853 else if ((r_ptr->flags1 & RF1_RAND_50) && (r_ptr->flags1 & RF1_RAND_25) && (randint0(100) < 50))
3855 /* Random direction */
3856 dir = ddd[randint0(8)];
3858 else if ((r_ptr->flags1 & RF1_RAND_50) && (randint0(100) < 25))
3860 /* Random direction */
3861 dir = ddd[randint0(8)];
3865 /* Notice confusion */
3866 if (command_dir != dir)
3868 if (p_ptr->confused)
3871 msg_print(_("あなたは混乱している。", "You are confused."));
3875 GAME_TEXT m_name[MAX_NLEN];
3876 monster_type *m_ptr = &m_list[p_ptr->riding];
3878 monster_desc(m_name, m_ptr, 0);
3879 if (MON_CONFUSED(m_ptr))
3881 msg_format(_("%sは混乱している。", "%^s is confusing."), m_name);
3885 msg_format(_("%sは思い通りに動いてくれない。", "You cannot control %s."), m_name);
3890 /* Save direction */
3893 /* repeat_push(dir); */
3894 repeat_push((COMMAND_CODE)command_dir);
3901 * @brief 進行方向を指定する(騎乗対象の混乱の影響を受ける) / Request a "movement" direction (1,2,3,4,6,7,8,9) from the user,
3902 * and place it into "command_dir", unless we already have one.
3904 * This function should be used for all "repeatable" commands, such as
3905 * run, walk, open, close, bash, disarm, spike, tunnel, etc, as well
3906 * as all commands which must reference a grid adjacent to the player,
3907 * and which may not reference the grid under the player. Note that,
3908 * for example, it is no longer possible to "disarm" or "open" chests
3909 * in the same grid as the player.
3911 * Direction "5" is illegal and will (cleanly) abort the command.
3913 * This function tracks and uses the "global direction", and uses
3914 * that as the "desired direction", to which "confusion" is applied.
3916 bool get_rep_dir(DIRECTION *dp, bool under)
3924 /* Global direction */
3927 if (repeat_pull(&code))
3929 dir = (DIRECTION)code;
3930 /* return (TRUE); */
3932 *dp = (DIRECTION)code;
3936 prompt = _("方向 ('.'足元, ESCで中断)? ", "Direction ('.' at feet, Escape to cancel)? ");
3940 prompt = _("方向 (ESCで中断)? ", "Direction (Escape to cancel)? ");
3943 /* Get a direction */
3948 /* Get a command (or Cancel) */
3949 if (!get_com(prompt, &ch, TRUE)) break;
3952 if ((under) && ((ch == '5') || (ch == '-') || (ch == '.')))
3958 /* Look up the direction */
3959 dir = get_keymap_dir(ch);
3965 /* Prevent weirdness */
3966 if ((dir == 5) && (!under)) dir = 0;
3969 if (!dir) return (FALSE);
3971 /* Save desired direction */
3974 /* Apply "confusion" */
3975 if (p_ptr->confused)
3977 /* Standard confusion */
3978 if (randint0(100) < 75)
3980 /* Random direction */
3981 dir = ddd[randint0(8)];
3984 else if (p_ptr->riding)
3986 monster_type *m_ptr = &m_list[p_ptr->riding];
3987 monster_race *r_ptr = &r_info[m_ptr->r_idx];
3989 if (MON_CONFUSED(m_ptr))
3991 /* Standard confusion */
3992 if (randint0(100) < 75)
3994 /* Random direction */
3995 dir = ddd[randint0(8)];
3998 else if ((r_ptr->flags1 & RF1_RAND_50) && (r_ptr->flags1 & RF1_RAND_25) && (randint0(100) < 50))
4000 /* Random direction */
4001 dir = ddd[randint0(8)];
4003 else if ((r_ptr->flags1 & RF1_RAND_50) && (randint0(100) < 25))
4005 /* Random direction */
4006 dir = ddd[randint0(8)];
4010 /* Notice confusion */
4011 if (command_dir != dir)
4013 if (p_ptr->confused)
4016 msg_print(_("あなたは混乱している。", "You are confused."));
4020 GAME_TEXT m_name[MAX_NLEN];
4021 monster_type *m_ptr = &m_list[p_ptr->riding];
4023 monster_desc(m_name, m_ptr, 0);
4024 if (MON_CONFUSED(m_ptr))
4026 msg_format(_("%sは混乱している。", "%^s is confusing."), m_name);
4030 msg_format(_("%sは思い通りに動いてくれない。", "You cannot control %s."), m_name);
4035 /* Save direction */
4038 /* repeat_push(dir); */
4039 repeat_push((COMMAND_CODE)command_dir);
4045 void gain_level_reward(int chosen_reward)
4049 char wrath_reason[32] = "";
4050 int nasty_chance = 6;
4051 OBJECT_TYPE_VALUE dummy = 0;
4052 OBJECT_SUBTYPE_VALUE dummy2 = 0;
4055 GAME_TEXT o_name[MAX_NLEN];
4061 if (multi_rew) return;
4062 else multi_rew = TRUE;
4066 if (p_ptr->lev == 13) nasty_chance = 2;
4067 else if (!(p_ptr->lev % 13)) nasty_chance = 3;
4068 else if (!(p_ptr->lev % 14)) nasty_chance = 12;
4070 if (one_in_(nasty_chance))
4071 type = randint1(20); /* Allow the 'nasty' effects */
4073 type = randint1(15) + 5; /* Or disallow them */
4075 if (type < 1) type = 1;
4076 if (type > 20) type = 20;
4080 sprintf(wrath_reason, _("%sの怒り", "the Wrath of %s"), chaos_patrons[p_ptr->chaos_patron]);
4082 effect = chaos_rewards[p_ptr->chaos_patron][type];
4084 if (one_in_(6) && !chosen_reward)
4086 msg_format(_("%^sは褒美としてあなたを突然変異させた。", "%^s rewards you with a mutation!"), chaos_patrons[p_ptr->chaos_patron]);
4087 (void)gain_random_mutation(0);
4088 reward = _("変異した。", "mutation");
4092 switch (chosen_reward ? chosen_reward : effect)
4097 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4098 msg_print(_("「汝、新たなる姿を必要とせり!」", "'Thou needst a new form, mortal!'"));
4101 reward = _("変異した。", "polymorphing");
4106 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4107 msg_print(_("「汝は良く行いたり!続けよ!」", "'Well done, mortal! Lead on!'"));
4109 if (p_ptr->prace == RACE_ANDROID)
4111 msg_print(_("しかし何も起こらなかった。", "But, nothing happen."));
4113 else if (p_ptr->exp < PY_MAX_EXP)
4115 s32b ee = (p_ptr->exp / 2) + 10;
4116 if (ee > 100000L) ee = 100000L;
4117 msg_print(_("更に経験を積んだような気がする。", "You feel more experienced."));
4120 reward = _("経験値を得た", "experience");
4126 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4127 msg_print(_("「下僕よ、汝それに値せず。」", "'Thou didst not deserve that, slave.'"));
4129 if (p_ptr->prace == RACE_ANDROID)
4131 msg_print(_("しかし何も起こらなかった。", "But, nothing happen."));
4135 lose_exp(p_ptr->exp / 6);
4136 reward = _("経験値を失った。", "losing experience");
4142 msg_format("%sの声がささやいた:",
4143 chaos_patrons[p_ptr->chaos_patron]);
4145 msg_format("The voice of %s whispers:",
4146 chaos_patrons[p_ptr->chaos_patron]);
4149 msg_print(_("「我が与えし物を賢明に使うべし。」", "'Use my gift wisely.'"));
4151 acquirement(p_ptr->y, p_ptr->x, 1, FALSE, FALSE, FALSE);
4152 reward = _("上質なアイテムを手に入れた。", "a good item");
4157 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4158 msg_print(_("「我が与えし物を賢明に使うべし。」", "'Use my gift wisely.'"));
4160 acquirement(p_ptr->y, p_ptr->x, 1, TRUE, FALSE, FALSE);
4161 reward = _("高級品のアイテムを手に入れた。", "an excellent item");
4166 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4167 msg_print(_("「汝の行いは貴き剣に値せり。」", "'Thy deed hath earned thee a worthy blade.'"));
4170 switch (randint1(p_ptr->lev))
4176 dummy2 = SV_MAIN_GAUCHE;
4185 dummy2 = SV_SMALL_SWORD;
4188 dummy2 = SV_BASILLARD;
4190 case 11: case 12: case 13:
4191 dummy2 = SV_SHORT_SWORD;
4197 dummy2 = SV_CUTLASS;
4200 dummy2 = SV_WAKIZASHI;
4203 dummy2 = SV_KHOPESH;
4209 dummy2 = SV_BROAD_SWORD;
4212 dummy2 = SV_LONG_SWORD;
4215 dummy2 = SV_SCIMITAR;
4218 dummy2 = SV_NINJATO;
4224 dummy2 = SV_BASTARD_SWORD;
4227 dummy2 = SV_GREAT_SCIMITAR;
4230 dummy2 = SV_CLAYMORE;
4233 dummy2 = SV_ESPADON;
4236 dummy2 = SV_TWO_HANDED_SWORD;
4239 dummy2 = SV_FLAMBERGE;
4242 dummy2 = SV_NO_DACHI;
4245 dummy2 = SV_EXECUTIONERS_SWORD;
4248 dummy2 = SV_ZWEIHANDER;
4251 dummy2 = SV_HAYABUSA;
4254 dummy2 = SV_BLADE_OF_CHAOS;
4257 object_prep(q_ptr, lookup_kind(dummy, dummy2));
4258 q_ptr->to_h = 3 + randint1(dun_level) % 10;
4259 q_ptr->to_d = 3 + randint1(dun_level) % 10;
4260 one_resistance(q_ptr);
4261 q_ptr->name2 = EGO_CHAOTIC;
4262 (void)drop_near(q_ptr, -1, p_ptr->y, p_ptr->x);
4263 reward = _("(混沌)の武器を手に入れた。", "chaos weapon");
4268 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4269 msg_print(_("「汝の行いは貴き報いに値せり。」", "'Thy deed hath earned thee a worthy reward.'"));
4271 acquirement(p_ptr->y, p_ptr->x, randint1(2) + 1, FALSE, FALSE, FALSE);
4272 reward = _("上質なアイテムを手に入れた。", "good items");
4277 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4278 msg_print(_("「下僕よ、汝の献身への我が惜しみ無き報いを見るがよい。」", "'Behold, mortal, how generously I reward thy loyalty.'"));
4280 acquirement(p_ptr->y, p_ptr->x, randint1(2) + 1, TRUE, FALSE, FALSE);
4281 reward = _("高級品のアイテムを手に入れた。", "excellent items");
4286 msg_format("%sの声が轟き渡った:", chaos_patrons[p_ptr->chaos_patron]);
4288 msg_format("The voice of %s thunders:", chaos_patrons[p_ptr->chaos_patron]);
4291 msg_print(_("「下僕よ、汝傲慢なり。」", "'Thou art growing arrogant, mortal.'"));
4293 (void)activate_ty_curse(FALSE, &count);
4294 reward = _("禍々しい呪いをかけられた。", "cursing");
4299 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4300 msg_print(_("「我が下僕たちよ、かの傲慢なる者を倒すべし!」", "'My pets, destroy the arrogant mortal!'"));
4302 for (dummy = 0; dummy < randint1(5) + 1; dummy++)
4304 (void)summon_specific(0, p_ptr->y, p_ptr->x, dun_level, 0, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET), '\0');
4306 reward = _("モンスターを召喚された。", "summoning hostile monsters");
4312 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4313 msg_print(_("「汝、より強き敵を必要とせり!」", "'Thou needst worthier opponents!'"));
4315 activate_hi_summon(p_ptr->y, p_ptr->x, FALSE);
4316 reward = _("モンスターを召喚された。", "summoning many hostile monsters");
4322 msg_format("%sの声が響き渡った:",
4323 chaos_patrons[p_ptr->chaos_patron]);
4325 msg_format("The voice of %s booms out:",
4326 chaos_patrons[p_ptr->chaos_patron]);
4329 msg_print(_("「死と破壊こそ我が喜びなり!」", "'Death and destruction! This pleaseth me!'"));
4332 reward = _("カオスの力が渦巻いた。", "calling chaos");
4338 msg_format("%sの声が鳴り響いた:",
4339 chaos_patrons[p_ptr->chaos_patron]);
4341 msg_format("The voice of %s rings out:",
4342 chaos_patrons[p_ptr->chaos_patron]);
4345 msg_print(_("「留まるのだ、下僕よ。余が汝の肉体を鍛えん。」", "'Stay, mortal, and let me mold thee.'"));
4347 if (one_in_(3) && !(chaos_stats[p_ptr->chaos_patron] < 0))
4348 do_inc_stat(chaos_stats[p_ptr->chaos_patron]);
4350 do_inc_stat(randint0(6));
4351 reward = _("能力値が上がった。", "increasing a stat");
4357 msg_format("%sの声が響き渡った:",
4358 chaos_patrons[p_ptr->chaos_patron]);
4360 msg_format("The voice of %s booms out:",
4361 chaos_patrons[p_ptr->chaos_patron]);
4364 msg_print(_("「下僕よ、余は汝に飽みたり。」", "'I grow tired of thee, mortal.'"));
4366 if (one_in_(3) && !(chaos_stats[p_ptr->chaos_patron] < 0))
4367 do_dec_stat(chaos_stats[p_ptr->chaos_patron]);
4369 (void)do_dec_stat(randint0(6));
4370 reward = _("能力値が下がった。", "decreasing a stat");
4377 msg_format("%sの声が轟き渡った:",
4378 chaos_patrons[p_ptr->chaos_patron]);
4380 msg_format("The voice of %s thunders:",
4381 chaos_patrons[p_ptr->chaos_patron]);
4384 msg_print(_("「汝、謙虚たることを学ぶべし!」", "'Thou needst a lesson in humility, mortal!'"));
4385 msg_print(_("あなたは以前より弱くなった!", "You feel less powerful!"));
4387 for (dummy = 0; dummy < A_MAX; dummy++)
4389 (void)dec_stat(dummy, 10 + randint1(15), TRUE);
4391 reward = _("全能力値が下がった。", "decreasing all stats");
4396 msg_format(_("%sの力が触れるのを感じた。", "You feel the power of %s touch you."),
4397 chaos_patrons[p_ptr->chaos_patron]);
4399 reward = _("傷が変化した。", "polymorphing wounds");
4404 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4406 msg_print(_("「我がささやかなる賜物を受けとるがよい!」", "'Receive this modest gift from me!'"));
4408 for (dummy = 0; dummy < A_MAX; dummy++)
4410 (void)do_inc_stat(dummy);
4412 reward = _("全能力値が上がった。", "increasing all stats");
4417 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4418 msg_print(_("「苦しむがよい、無能な愚か者よ!」", "'Suffer, pathetic fool!'"));
4420 fire_ball(GF_DISINTEGRATE, 0, p_ptr->lev * 4, 4);
4421 take_hit(DAMAGE_NOESCAPE, p_ptr->lev * 4, wrath_reason, -1);
4422 reward = _("分解の球が発生した。", "generating disintegration ball");
4427 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4428 (void)restore_level();
4429 (void)restore_all_status();
4430 (void)true_healing(5000);
4431 reward = _("体力が回復した。", "healing");
4436 if (!buki_motteruka(INVEN_RARM) && !buki_motteruka(INVEN_LARM)) break;
4437 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4438 msg_print(_("「汝、武器に頼ることなかれ。」", "'Thou reliest too much on thy weapon.'"));
4441 if (buki_motteruka(INVEN_LARM))
4444 if (buki_motteruka(INVEN_RARM) && one_in_(2)) dummy = INVEN_RARM;
4446 object_desc(o_name, &inventory[dummy], OD_NAME_ONLY);
4447 (void)curse_weapon(FALSE, dummy);
4448 reward = format(_("%sが破壊された。", "destroying %s"), o_name);
4453 if (!inventory[INVEN_BODY].k_idx) break;
4454 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4455 msg_print(_("「汝、防具に頼ることなかれ。」", "'Thou reliest too much on thine equipment.'"));
4457 object_desc(o_name, &inventory[INVEN_BODY], OD_NAME_ONLY);
4458 (void)curse_armor();
4459 reward = format(_("%sが破壊された。", "destroying %s"), o_name);
4463 msg_format(_("%sの声がささやいた:", "The voice of %s whispers:"), chaos_patrons[p_ptr->chaos_patron]);
4464 msg_print(_("「我を怒りしめた罪を償うべし。」", "'Now thou shalt pay for annoying me.'"));
4466 switch (randint1(4))
4469 (void)activate_ty_curse(FALSE, &count);
4470 reward = _("禍々しい呪いをかけられた。", "cursing");
4473 activate_hi_summon(p_ptr->y, p_ptr->x, FALSE);
4474 reward = _("モンスターを召喚された。", "summoning hostile monsters");
4479 if (!buki_motteruka(INVEN_RARM) && !buki_motteruka(INVEN_LARM)) break;
4481 if (buki_motteruka(INVEN_LARM))
4484 if (buki_motteruka(INVEN_RARM) && one_in_(2)) dummy = INVEN_RARM;
4486 object_desc(o_name, &inventory[dummy], OD_NAME_ONLY);
4487 (void)curse_weapon(FALSE, dummy);
4488 reward = format(_("%sが破壊された。", "destroying %s"), o_name);
4492 if (!inventory[INVEN_BODY].k_idx) break;
4493 object_desc(o_name, &inventory[INVEN_BODY], OD_NAME_ONLY);
4494 (void)curse_armor();
4495 reward = format(_("%sが破壊された。", "destroying %s"), o_name);
4499 for (dummy = 0; dummy < A_MAX; dummy++)
4501 (void)dec_stat(dummy, 10 + randint1(15), TRUE);
4503 reward = _("全能力値が下がった。", "decreasing all stats");
4510 msg_format(_("%sの声が轟き渡った:", "The voice of %s thunders:"), chaos_patrons[p_ptr->chaos_patron]);
4511 msg_print(_("「死ぬがよい、下僕よ!」", "'Die, mortal!'"));
4513 take_hit(DAMAGE_LOSELIFE, p_ptr->lev * 4, wrath_reason, -1);
4514 for (dummy = 0; dummy < A_MAX; dummy++)
4516 (void)dec_stat(dummy, 10 + randint1(15), FALSE);
4518 activate_hi_summon(p_ptr->y, p_ptr->x, FALSE);
4519 (void)activate_ty_curse(FALSE, &count);
4524 if (buki_motteruka(INVEN_RARM))
4527 if (buki_motteruka(INVEN_LARM) && one_in_(2)) dummy = INVEN_LARM;
4529 else if (buki_motteruka(INVEN_LARM)) dummy = INVEN_LARM;
4531 if (dummy) (void)curse_weapon(FALSE, dummy);
4533 if (one_in_(2)) (void)curse_armor();
4538 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4539 msg_print(_("「死と破壊こそ我が喜びなり!」", "'Death and destruction! This pleaseth me!'"));
4541 (void)destroy_area(p_ptr->y, p_ptr->x, 25, FALSE);
4542 reward = _("ダンジョンが*破壊*された。", "*destruct*ing dungeon");
4547 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4548 msg_print(_("「我、汝の敵を抹殺せん!」", "'Let me relieve thee of thine oppressors!'"));
4549 (void)symbol_genocide(0, FALSE);
4550 reward = _("モンスターが抹殺された。", "genociding monsters");
4555 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4556 msg_print(_("「我、汝の敵を抹殺せん!」", "'Let me relieve thee of thine oppressors!'"));
4558 (void)mass_genocide(0, FALSE);
4559 reward = _("モンスターが抹殺された。", "genociding nearby monsters");
4564 msg_format(_("%sの力が敵を攻撃するのを感じた!", "You can feel the power of %s assault your enemies!"), chaos_patrons[p_ptr->chaos_patron]);
4565 (void)dispel_monsters(p_ptr->lev * 4);
4570 msg_format(_("%sはあなたを無視した。", "%s ignores you."), chaos_patrons[p_ptr->chaos_patron]);
4575 msg_format(_("%sは褒美として悪魔の使いをよこした!", "%s rewards you with a demonic servant!"),chaos_patrons[p_ptr->chaos_patron]);
4577 if (!summon_specific(-1, p_ptr->y, p_ptr->x, dun_level, SUMMON_DEMON, PM_FORCE_PET, '\0'))
4578 msg_print(_("何も現れなかった...", "Nobody ever turns up..."));
4580 reward = _("悪魔がペットになった。", "a demonic servant");
4585 msg_format(_("%sは褒美として使いをよこした!", "%s rewards you with a servant!"),chaos_patrons[p_ptr->chaos_patron]);
4587 if (!summon_specific(-1, p_ptr->y, p_ptr->x, dun_level, 0, PM_FORCE_PET, '\0'))
4588 msg_print(_("何も現れなかった...", "Nobody ever turns up..."));
4590 reward = _("モンスターがペットになった。", "a servant");
4595 msg_format(_("%sは褒美としてアンデッドの使いをよこした。", "%s rewards you with an undead servant!"),chaos_patrons[p_ptr->chaos_patron]);
4597 if (!summon_specific(-1, p_ptr->y, p_ptr->x, dun_level, SUMMON_UNDEAD, PM_FORCE_PET, '\0'))
4598 msg_print(_("何も現れなかった...", "Nobody ever turns up..."));
4600 reward = _("アンデッドがペットになった。", "an undead servant");
4605 msg_format(_("%sの声がどもった:", "The voice of %s stammers:"),
4607 chaos_patrons[p_ptr->chaos_patron]);
4608 msg_format(_("「あー、あー、答えは %d/%d。質問は何?」", "'Uh... uh... the answer's %d/%d, what's the question?'"), type, effect);
4614 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, format(_("パトロンの報酬で%s", "The patron rewards you with %s."), reward));
4620 * XAngband: determine if a given location is "interesting"
4621 * based on target_set_accept function.
4623 static bool tgt_pt_accept(POSITION y, POSITION x)
4628 if (!(in_bounds(y, x))) return (FALSE);
4630 /* Player grid is always interesting */
4631 if ((y == p_ptr->y) && (x == p_ptr->x)) return (TRUE);
4633 /* Handle hallucination */
4634 if (p_ptr->image) return (FALSE);
4636 /* Examine the grid */
4637 c_ptr = &cave[y][x];
4639 /* Interesting memorized features */
4640 if (c_ptr->info & (CAVE_MARK))
4643 if (cave_have_flag_grid(c_ptr, FF_LESS)) return (TRUE);
4644 if (cave_have_flag_grid(c_ptr, FF_MORE)) return (TRUE);
4646 /* Notice quest features */
4647 if (cave_have_flag_grid(c_ptr, FF_QUEST_ENTER)) return (TRUE);
4648 if (cave_have_flag_grid(c_ptr, FF_QUEST_EXIT)) return (TRUE);
4656 * XAngband: Prepare the "temp" array for "tget_pt"
4657 * based on target_set_prepare funciton.
4659 static void tgt_pt_prepare(void)
4663 /* Reset "temp" array */
4666 if (!expand_list) return;
4668 /* Scan the current panel */
4669 for (y = 1; y < cur_hgt; y++)
4671 for (x = 1; x < cur_wid; x++)
4673 /* Require "interesting" contents */
4674 if (!tgt_pt_accept(y, x)) continue;
4676 /* Save the location */
4683 /* Target the nearest monster for shooting */
4684 ang_sort_comp = ang_sort_comp_distance;
4685 ang_sort_swap = ang_sort_swap_distance;
4687 /* Sort the positions */
4688 ang_sort(temp_x, temp_y, temp_n);
4692 * old -- from PsiAngband.
4694 bool tgt_pt(POSITION *x_ptr, POSITION *y_ptr)
4699 bool success = FALSE;
4703 get_screen_size(&wid, &hgt);
4713 msg_print(_("場所を選んでスペースキーを押して下さい。", "Select a point and press space."));
4714 msg_flag = FALSE; /* prevents "-more-" message. */
4716 while ((ch != ESCAPE) && !success)
4718 bool move_fast = FALSE;
4720 move_cursor_relative(y, x);
4732 if (player_bold(y, x)) ch = 0;
4735 else success = TRUE;
4739 /* XAngband: Move cursor to stairs */
4742 if (expand_list && temp_n)
4745 int cx = (panel_col_min + panel_col_max) / 2;
4746 int cy = (panel_row_min + panel_row_max) / 2;
4750 /* Skip stairs which have defferent distance */
4751 for (; n < temp_n; ++ n)
4753 cave_type *c_ptr = &cave[temp_y[n]][temp_x[n]];
4755 if (cave_have_flag_grid(c_ptr, FF_STAIRS) &&
4756 cave_have_flag_grid(c_ptr, ch == '>' ? FF_MORE : FF_LESS))
4763 if (n == temp_n) /* Loop out taget list */
4768 verify_panel(); /* Move cursor to player */
4770 p_ptr->update |= (PU_MONSTERS);
4772 p_ptr->redraw |= (PR_MAP);
4774 p_ptr->window |= (PW_OVERHEAD);
4777 else /* move cursor to next stair and change panel */
4782 dy = 2 * (y - cy) / hgt;
4783 dx = 2 * (x - cx) / wid;
4784 if (dy || dx) change_panel(dy, dx);
4790 /* Look up the direction */
4791 d = get_keymap_dir(ch);
4793 /* XTRA HACK MOVEFAST */
4794 if (isupper(ch)) move_fast = TRUE;
4796 /* Handle "direction" */
4802 /* XTRA HACK MOVEFAST */
4805 int mag = MIN(wid / 2, hgt / 2);
4815 /* Do not move horizontally if unnecessary */
4816 if (((x < panel_col_min + wid / 2) && (dx > 0)) ||
4817 ((x > panel_col_min + wid / 2) && (dx < 0)))
4822 /* Do not move vertically if unnecessary */
4823 if (((y < panel_row_min + hgt / 2) && (dy > 0)) ||
4824 ((y > panel_row_min + hgt / 2) && (dy < 0)))
4829 /* Apply the motion */
4830 if ((y >= panel_row_min + hgt) || (y < panel_row_min) ||
4831 (x >= panel_col_min + wid) || (x < panel_col_min))
4833 /* if (change_panel(dy, dx)) target_set_prepare(mode); */
4834 change_panel(dy, dx);
4837 /* Slide into legality */
4838 if (x >= cur_wid-1) x = cur_wid - 2;
4839 else if (x <= 0) x = 1;
4841 /* Slide into legality */
4842 if (y >= cur_hgt-1) y = cur_hgt- 2;
4843 else if (y <= 0) y = 1;
4850 /* Clear the top line */
4853 /* Recenter the map around the player */
4856 p_ptr->update |= (PU_MONSTERS);
4858 p_ptr->redraw |= (PR_MAP);
4860 p_ptr->window |= (PW_OVERHEAD);
4869 bool get_hack_dir(DIRECTION *dp)
4877 /* Global direction */
4880 /* (No auto-targeting) */
4882 /* Ask until satisfied */
4885 /* Choose a prompt */
4888 p = _("方向 ('*'でターゲット選択, ESCで中断)? ", "Direction ('*' to choose a target, Escape to cancel)? ");
4892 p = _("方向 ('5'でターゲットへ, '*'でターゲット再選択, ESCで中断)? ", "Direction ('5' for target, '*' to re-target, Escape to cancel)? ");
4895 /* Get a command (or Cancel) */
4896 if (!get_com(p, &command, TRUE)) break;
4900 if (command == '\r') command = 't';
4903 /* Convert various keys to "standard" keys */
4906 /* Use current target */
4917 /* Set new target */
4922 if (target_set(TARGET_KILL)) dir = 5;
4928 /* Look up the direction */
4929 dir = get_keymap_dir(command);
4935 /* Verify requested targets */
4936 if ((dir == 5) && !target_okay()) dir = 0;
4943 if (!dir) return (FALSE);
4945 /* Save the direction */
4948 /* Check for confusion */
4949 if (p_ptr->confused)
4951 /* Random direction */
4952 dir = ddd[randint0(8)];
4955 /* Notice confusion */
4956 if (command_dir != dir)
4959 msg_print(_("あなたは混乱している。", "You are confused."));
4962 /* Save direction */
4965 /* A "valid" direction was entered */
4971 * @brief 射撃武器の攻撃に必要な基本消費エネルギーを返す/Return bow energy
4972 * @param sval 射撃武器のアイテム副分類ID
4973 * @return 消費する基本エネルギー
4975 ENERGY bow_energy(OBJECT_SUBTYPE_VALUE sval)
4977 ENERGY energy = 10000;
4979 /* Analyze the launcher */
4982 /* Sling and ammo */
4989 /* Short Bow and Arrow */
4996 /* Long Bow and Arrow */
5003 /* Bow of irresponsiblity and Arrow */
5010 /* Light Crossbow and Bolt */
5017 /* Heavy Crossbow and Bolt */
5032 int bow_tmul(OBJECT_SUBTYPE_VALUE sval)
5036 /* Analyze the launcher */
5039 /* Sling and ammo */
5046 /* Short Bow and Arrow */
5053 /* Long Bow and Arrow */
5060 /* Bow of irresponsiblity and Arrow */
5067 /* Light Crossbow and Bolt */
5074 /* Heavy Crossbow and Bolt */
5087 * Display a rumor and apply its effects
5090 IDX rumor_num(char *zz, IDX max_idx)
5092 if (strcmp(zz, "*") == 0) return randint1(max_idx - 1);
5093 return (IDX)atoi(zz);
5096 cptr rumor_bind_name(char *base, cptr fullname)
5100 s = strstr(base, "{Name}");
5104 v = format("%s%s%s", base, fullname, (s + 6));
5114 void display_rumor(bool ex)
5122 if (randint0(3) == 0) section = 1;
5125 err = _(get_rnd_line_jonly("rumors_j.txt", section, Rumor, 10),
5126 get_rnd_line("rumors.txt", section, Rumor));
5127 if (err) strcpy(Rumor, _("嘘の噂もある。", "Some rumors are wrong."));
5131 if (strncmp(Rumor, "R:", 2) == 0)
5134 cptr rumor_msg = NULL;
5135 cptr rumor_eff_format = NULL;
5136 char fullname[1024] = "";
5138 if (tokenize(Rumor + 2, 3, zz, TOKENIZE_CHECKQUOTE) == 3)
5140 if (strcmp(zz[0], "ARTIFACT") == 0)
5144 object_type *q_ptr = &forge;
5145 artifact_type *a_ptr;
5149 a_idx = rumor_num(zz[1], max_a_idx);
5151 a_ptr = &a_info[a_idx];
5152 if (a_ptr->name) break;
5155 k_idx = lookup_kind(a_ptr->tval, a_ptr->sval);
5156 object_prep(q_ptr, k_idx);
5157 q_ptr->name1 = a_idx;
5158 q_ptr->ident = IDENT_STORE;
5159 object_desc(fullname, q_ptr, OD_NAME_ONLY);
5161 else if (strcmp(zz[0], "MONSTER") == 0)
5164 monster_race *r_ptr;
5168 r_idx = rumor_num(zz[1], max_r_idx);
5169 r_ptr = &r_info[r_idx];
5170 if (r_ptr->name) break;
5173 strcpy(fullname, r_name + r_ptr->name);
5175 /* Remember this monster */
5176 if (!r_ptr->r_sights)
5181 else if (strcmp(zz[0], "DUNGEON") == 0)
5184 dungeon_info_type *d_ptr;
5188 d_idx = rumor_num(zz[1], max_d_idx);
5189 d_ptr = &d_info[d_idx];
5190 if (d_ptr->name) break;
5193 strcpy(fullname, d_name + d_ptr->name);
5195 if (!max_dlv[d_idx])
5197 max_dlv[d_idx] = d_ptr->mindepth;
5198 rumor_eff_format = _("%sに帰還できるようになった。", "You can recall to %s.");
5201 else if (strcmp(zz[0], "TOWN") == 0)
5208 t_idx = rumor_num(zz[1], NO_TOWN);
5209 if (town[t_idx].name) break;
5212 strcpy(fullname, town[t_idx].name);
5214 visit = (1L << (t_idx - 1));
5215 if ((t_idx != SECRET_TOWN) && !(p_ptr->visit & visit))
5217 p_ptr->visit |= visit;
5218 rumor_eff_format = _("%sに行ったことがある気がする。", "You feel you have been to %s.");
5222 rumor_msg = rumor_bind_name(zz[2], fullname);
5223 msg_print(rumor_msg);
5224 if (rumor_eff_format)
5227 msg_format(rumor_eff_format, fullname);
5232 if (err) msg_print(_("この情報は間違っている。", "This information is wrong."));
5236 msg_format("%s", Rumor);