3 * @brief 雑多なその他の処理2 / effects of various "objects"
6 * Copyright (c) 1989 James E. Wilson, Robert A. Koeneke\n
7 * This software may be copied and distributed for educational, research, and\n
8 * not for profit purposes provided that this copyright and statement are\n
9 * included in all such copies.\n
10 * 2014 Deskull rearranged comment for Doxygen.
16 #include "object-curse.h"
18 #define REWARD_CHANCE 10
22 * @brief プレイヤーの経験値について整合性のためのチェックと調整を行う /
23 * Advance experience levels and print experience
26 void check_experience(void)
28 bool level_reward = FALSE;
29 bool level_mutation = FALSE;
30 bool level_inc_stat = FALSE;
31 bool android = (p_ptr->prace == RACE_ANDROID ? TRUE : FALSE);
32 PLAYER_LEVEL old_lev = p_ptr->lev;
34 /* Hack -- lower limit */
35 if (p_ptr->exp < 0) p_ptr->exp = 0;
36 if (p_ptr->max_exp < 0) p_ptr->max_exp = 0;
37 if (p_ptr->max_max_exp < 0) p_ptr->max_max_exp = 0;
39 /* Hack -- upper limit */
40 if (p_ptr->exp > PY_MAX_EXP) p_ptr->exp = PY_MAX_EXP;
41 if (p_ptr->max_exp > PY_MAX_EXP) p_ptr->max_exp = PY_MAX_EXP;
42 if (p_ptr->max_max_exp > PY_MAX_EXP) p_ptr->max_max_exp = PY_MAX_EXP;
44 /* Hack -- maintain "max" experience */
45 if (p_ptr->exp > p_ptr->max_exp) p_ptr->max_exp = p_ptr->exp;
47 /* Hack -- maintain "max max" experience */
48 if (p_ptr->max_exp > p_ptr->max_max_exp) p_ptr->max_max_exp = p_ptr->max_exp;
50 /* Redraw experience */
51 p_ptr->redraw |= (PR_EXP);
57 /* Lose levels while possible */
58 while ((p_ptr->lev > 1) &&
59 (p_ptr->exp < ((android ? player_exp_a : player_exp)[p_ptr->lev - 2] * p_ptr->expfact / 100L)))
64 /* Update some stuff */
65 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
67 /* Redraw some stuff */
68 p_ptr->redraw |= (PR_LEV | PR_TITLE);
70 p_ptr->window |= (PW_PLAYER);
77 /* Gain levels while possible */
78 while ((p_ptr->lev < PY_MAX_LEVEL) &&
79 (p_ptr->exp >= ((android ? player_exp_a : player_exp)[p_ptr->lev-1] * p_ptr->expfact / 100L)))
84 /* Save the highest level */
85 if (p_ptr->lev > p_ptr->max_plv)
87 p_ptr->max_plv = p_ptr->lev;
89 if ((p_ptr->pclass == CLASS_CHAOS_WARRIOR) ||
90 (p_ptr->muta2 & MUT2_CHAOS_GIFT))
94 if (p_ptr->prace == RACE_BEASTMAN)
96 if (one_in_(5)) level_mutation = TRUE;
98 level_inc_stat = TRUE;
100 do_cmd_write_nikki(NIKKI_LEVELUP, p_ptr->lev, NULL);
105 msg_format(_("レベル %d にようこそ。", "Welcome to level %d."), p_ptr->lev);
107 /* Update some stuff */
108 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
110 /* Redraw some stuff */
111 p_ptr->redraw |= (PR_LEV | PR_TITLE | PR_EXP);
113 p_ptr->window |= (PW_PLAYER | PW_SPELL | PW_INVEN);
125 if(!(p_ptr->max_plv % 10))
135 cnv_stat(p_ptr->stat_max[0], tmp);
136 prt(format(" a) 腕力 (現在値 %s)", tmp), 2, 14);
137 cnv_stat(p_ptr->stat_max[1], tmp);
138 prt(format(" b) 知能 (現在値 %s)", tmp), 3, 14);
139 cnv_stat(p_ptr->stat_max[2], tmp);
140 prt(format(" c) 賢さ (現在値 %s)", tmp), 4, 14);
141 cnv_stat(p_ptr->stat_max[3], tmp);
142 prt(format(" d) 器用 (現在値 %s)", tmp), 5, 14);
143 cnv_stat(p_ptr->stat_max[4], tmp);
144 prt(format(" e) 耐久 (現在値 %s)", tmp), 6, 14);
145 cnv_stat(p_ptr->stat_max[5], tmp);
146 prt(format(" f) 魅力 (現在値 %s)", tmp), 7, 14);
148 prt(" どの能力値を上げますか?", 1, 14);
150 cnv_stat(p_ptr->stat_max[0], tmp);
151 prt(format(" a) Str (cur %s)", tmp), 2, 14);
152 cnv_stat(p_ptr->stat_max[1], tmp);
153 prt(format(" b) Int (cur %s)", tmp), 3, 14);
154 cnv_stat(p_ptr->stat_max[2], tmp);
155 prt(format(" c) Wis (cur %s)", tmp), 4, 14);
156 cnv_stat(p_ptr->stat_max[3], tmp);
157 prt(format(" d) Dex (cur %s)", tmp), 5, 14);
158 cnv_stat(p_ptr->stat_max[4], tmp);
159 prt(format(" e) Con (cur %s)", tmp), 6, 14);
160 cnv_stat(p_ptr->stat_max[5], tmp);
161 prt(format(" f) Chr (cur %s)", tmp), 7, 14);
163 prt(" Which stat do you want to raise?", 1, 14);
168 if ((choice >= 'a') && (choice <= 'f')) break;
170 for(n = 0; n < 6; n++)
171 if (n != choice - 'a')
173 if (get_check(_("よろしいですか?", "Are you sure? "))) break;
175 do_inc_stat(choice - 'a');
178 else if(!(p_ptr->max_plv % 2))
179 do_inc_stat(randint0(6));
184 msg_print(_("あなたは変わった気がする...", "You feel different..."));
185 (void)gain_random_mutation(0);
186 level_mutation = FALSE;
190 * 報酬でレベルが上ると再帰的に check_experience() が
195 gain_level_reward(0);
196 level_reward = FALSE;
199 /* Update some stuff */
200 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
202 /* Redraw some stuff */
203 p_ptr->redraw |= (PR_LEV | PR_TITLE);
205 p_ptr->window |= (PW_PLAYER | PW_SPELL);
211 /* Load an autopick preference file */
212 if (old_lev != p_ptr->lev) autopick_load_pref(FALSE);
217 * @brief モンスターを倒した際の財宝svalを返す
218 * @param r_idx 倒したモンスターの種族ID
221 * Hack -- Return the "automatic coin type" of a monster race
222 * Used to allocate proper treasure when "Creeping coins" die
223 * Note the use of actual "monster names"
225 static int get_coin_type(MONRACE_IDX r_idx)
227 /* Analyze monsters */
230 case MON_COPPER_COINS: return 2;
231 case MON_SILVER_COINS: return 5;
232 case MON_GOLD_COINS: return 10;
233 case MON_MITHRIL_COINS:
234 case MON_MITHRIL_GOLEM: return 16;
235 case MON_ADAMANT_COINS: return 17;
244 * @brief オブジェクトがクロークかどうかを判定する /
245 * Hack -- determine if a template is Cloak
246 * @param k_idx 判定したいオブジェクトのベースアイテムID
247 * @return オブジェクトがクロークならばTRUEを返す
249 static bool kind_is_cloak(KIND_OBJECT_IDX k_idx)
251 object_kind *k_ptr = &k_info[k_idx];
253 /* Analyze the item type */
254 if (k_ptr->tval == TV_CLOAK)
259 /* Assume not good */
265 * @brief オブジェクトが竿状武器かどうかを判定する /
266 * Hack -- determine if a template is Polearm
267 * @param k_idx 判定したいオブジェクトのベースアイテムID
268 * @return オブジェクトが竿状武器ならばTRUEを返す
270 static bool kind_is_polearm(KIND_OBJECT_IDX k_idx)
272 object_kind *k_ptr = &k_info[k_idx];
274 /* Analyze the item type */
275 if (k_ptr->tval == TV_POLEARM)
280 /* Assume not good */
286 * @brief オブジェクトが剣かどうかを判定する /
287 * Hack -- determine if a template is Sword
288 * @param k_idx 判定したいオブジェクトのベースアイテムID
289 * @return オブジェクトが剣ならばTRUEを返す
291 static bool kind_is_sword(KIND_OBJECT_IDX k_idx)
293 object_kind *k_ptr = &k_info[k_idx];
295 /* Analyze the item type */
296 if ((k_ptr->tval == TV_SWORD) && (k_ptr->sval > 2))
301 /* Assume not good */
307 * @brief オブジェクトが魔法書かどうかを判定する /
308 * Hack -- determine if a template is Book
309 * @param k_idx 判定したいオブジェクトのベースアイテムID
310 * @return オブジェクトが魔法書ならばTRUEを返す
312 static bool kind_is_book(KIND_OBJECT_IDX k_idx)
314 object_kind *k_ptr = &k_info[k_idx];
316 /* Analyze the item type */
317 if ((k_ptr->tval >= TV_LIFE_BOOK) && (k_ptr->tval <= TV_CRUSADE_BOOK))
322 /* Assume not good */
328 * @brief オブジェクトがベースアイテム時点でGOODかどうかを判定する /
329 * Hack -- determine if a template is Good book
330 * @param k_idx 判定したいオブジェクトのベースアイテムID
331 * @return オブジェクトがベースアイテム時点でGOODなアイテムならばTRUEを返す
333 static bool kind_is_good_book(KIND_OBJECT_IDX k_idx)
335 object_kind *k_ptr = &k_info[k_idx];
337 /* Analyze the item type */
338 if ((k_ptr->tval >= TV_LIFE_BOOK) && (k_ptr->tval <= TV_CRUSADE_BOOK) && (k_ptr->tval != TV_ARCANE_BOOK) && (k_ptr->sval > 1))
343 /* Assume not good */
349 * @brief オブジェクトが鎧かどうかを判定する /
350 * Hack -- determine if a template is Armor
351 * @param k_idx 判定したいオブジェクトのベースアイテムID
352 * @return オブジェクトが鎧ならばTRUEを返す
354 static bool kind_is_armor(KIND_OBJECT_IDX k_idx)
356 object_kind *k_ptr = &k_info[k_idx];
358 /* Analyze the item type */
359 if (k_ptr->tval == TV_HARD_ARMOR)
364 /* Assume not good */
370 * @brief オブジェクトが打撃武器かどうかを判定する /
371 * Hack -- determine if a template is hafted weapon
372 * @param k_idx 判定したいオブジェクトのベースアイテムID
373 * @return オブジェクトが打撃武器ならばTRUEを返す
375 static bool kind_is_hafted(KIND_OBJECT_IDX k_idx)
377 object_kind *k_ptr = &k_info[k_idx];
379 /* Analyze the item type */
380 if (k_ptr->tval == TV_HAFTED)
385 /* Assume not good */
390 * @brief クエストを達成状態にする /
391 * @param quest_num 達成状態にしたいクエストのID
394 void complete_quest(QUEST_IDX quest_num)
396 quest_type* const q_ptr = &quest[quest_num];
400 case QUEST_TYPE_RANDOM:
401 if (record_rand_quest) do_cmd_write_nikki(NIKKI_RAND_QUEST_C, quest_num, NULL);
404 if (record_fix_quest) do_cmd_write_nikki(NIKKI_FIX_QUEST_C, quest_num, NULL);
408 q_ptr->status = QUEST_STATUS_COMPLETED;
409 q_ptr->complev = (byte)p_ptr->lev;
411 q_ptr->comptime = playtime;
413 if (!(q_ptr->flags & QUEST_FLAG_SILENT))
415 play_music(TERM_XTRA_MUSIC_BASIC, MUSIC_BASIC_QUEST_CLEAR);
416 msg_print(_("クエストを達成した!", "You just completed your quest!"));
422 * @brief 現在フロアに残っている敵モンスターの数を返す /
423 * @return 現在の敵モンスターの数
425 static MONSTER_NUMBER count_all_hostile_monsters(void)
428 MONSTER_NUMBER number_mon = 0;
430 for (x = 0; x < cur_wid; ++ x)
432 for (y = 0; y < cur_hgt; ++ y)
434 MONSTER_IDX m_idx = cave[y][x].m_idx;
436 if (m_idx > 0 && is_hostile(&m_list[m_idx]))
447 * @brief 特定の敵を倒した際にクエスト達成処理 /
448 * Check for "Quest" completion when a quest monster is killed or charmed.
449 * @param m_ptr 撃破したモンスターの構造体参照ポインタ
452 void check_quest_completion(monster_type *m_ptr)
457 bool create_stairs = FALSE;
463 /* Get the location */
468 quest_num = p_ptr->inside_quest;
470 /* Search for an active quest on this dungeon level */
475 for (i = max_q_idx - 1; i > 0; i--)
477 quest_type* const q_ptr = &quest[i];
479 /* Quest is not active */
480 if (q_ptr->status != QUEST_STATUS_TAKEN)
483 /* Quest is not a dungeon quest */
484 if (q_ptr->flags & QUEST_FLAG_PRESET)
487 /* Quest is not on this level */
488 if ((q_ptr->level != dun_level) &&
489 (q_ptr->type != QUEST_TYPE_KILL_ANY_LEVEL))
492 /* Not a "kill monster" quest */
493 if ((q_ptr->type == QUEST_TYPE_FIND_ARTIFACT) ||
494 (q_ptr->type == QUEST_TYPE_FIND_EXIT))
497 /* Interesting quest */
498 if ((q_ptr->type == QUEST_TYPE_KILL_NUMBER) ||
499 (q_ptr->type == QUEST_TYPE_TOWER) ||
500 (q_ptr->type == QUEST_TYPE_KILL_ALL))
503 /* Interesting quest */
504 if (((q_ptr->type == QUEST_TYPE_KILL_LEVEL) ||
505 (q_ptr->type == QUEST_TYPE_KILL_ANY_LEVEL) ||
506 (q_ptr->type == QUEST_TYPE_RANDOM)) &&
507 (q_ptr->r_idx == m_ptr->r_idx))
514 /* Handle the current quest */
515 if (quest_num && (quest[quest_num].status == QUEST_STATUS_TAKEN))
518 quest_type* const q_ptr = &quest[quest_num];
522 case QUEST_TYPE_KILL_NUMBER:
526 if (q_ptr->cur_num >= q_ptr->num_mon)
528 complete_quest(quest_num);
534 case QUEST_TYPE_KILL_ALL:
536 if (!is_hostile(m_ptr)) break;
538 if (count_all_hostile_monsters() == 1)
540 if (q_ptr->flags & QUEST_FLAG_SILENT)
542 q_ptr->status = QUEST_STATUS_FINISHED;
546 complete_quest(quest_num);
551 case QUEST_TYPE_KILL_LEVEL:
552 case QUEST_TYPE_RANDOM:
554 /* Only count valid monsters */
555 if (q_ptr->r_idx != m_ptr->r_idx)
560 if (q_ptr->cur_num >= q_ptr->max_num)
562 complete_quest(quest_num);
564 if (!(q_ptr->flags & QUEST_FLAG_PRESET))
566 create_stairs = TRUE;
567 p_ptr->inside_quest = 0;
570 /* Finish the two main quests without rewarding */
571 if ((quest_num == QUEST_OBERON) || (quest_num == QUEST_SERPENT))
573 q_ptr->status = QUEST_STATUS_FINISHED;
576 if (q_ptr->type == QUEST_TYPE_RANDOM)
579 q_ptr->status = QUEST_STATUS_FINISHED;
584 case QUEST_TYPE_KILL_ANY_LEVEL:
587 if (q_ptr->cur_num >= q_ptr->max_num)
589 complete_quest(quest_num);
594 case QUEST_TYPE_TOWER:
596 if (!is_hostile(m_ptr)) break;
598 if (count_all_hostile_monsters() == 1)
600 q_ptr->status = QUEST_STATUS_STAGE_COMPLETED;
602 if((quest[QUEST_TOWER1].status == QUEST_STATUS_STAGE_COMPLETED) &&
603 (quest[QUEST_TOWER2].status == QUEST_STATUS_STAGE_COMPLETED) &&
604 (quest[QUEST_TOWER3].status == QUEST_STATUS_STAGE_COMPLETED))
607 complete_quest(QUEST_TOWER1);
615 /* Create a magical staircase */
621 while (cave_perma_bold(y, x) || cave[y][x].o_idx || (cave[y][x].info & CAVE_OBJECT) )
623 /* Pick a location */
624 scatter(&ny, &nx, y, x, 1, 0);
630 /* Explain the staircase */
631 msg_print(_("魔法の階段が現れた...", "A magical staircase appears..."));
633 /* Create stairs down */
634 cave_set_feat(y, x, feat_down_stair);
636 /* Remember to update everything */
637 p_ptr->update |= (PU_FLOW);
647 for (i = 0; i < (dun_level / 15)+1; i++)
649 /* Get local object */
652 /* Wipe the object */
655 /* Make a great object */
656 make_object(o_ptr, AM_GOOD | AM_GREAT);
658 /* Drop it in the dungeon */
659 (void)drop_near(o_ptr, -1, y, x);
665 * @brief 特定のアーティファクトを入手した際のクエスト達成処理 /
666 * Check for "Quest" completion when a quest monster is killed or charmed.
667 * @param o_ptr 入手したオブジェクトの構造体参照ポインタ
670 void check_find_art_quest_completion(object_type *o_ptr)
673 /* Check if completed a quest */
674 for (i = 0; i < max_q_idx; i++)
676 if((quest[i].type == QUEST_TYPE_FIND_ARTIFACT) &&
677 (quest[i].status == QUEST_STATUS_TAKEN) &&
678 (quest[i].k_idx == o_ptr->name1))
687 * @brief モンスターを撃破した際の述語メッセージを返す /
688 * Return monster death string
689 * @param r_ptr 撃破されたモンスターの種族情報を持つ構造体の参照ポインタ
690 * @return 撃破されたモンスターの述語
692 cptr extract_note_dies(monster_race *r_ptr)
694 /* Some monsters get "destroyed" */
695 if (!monster_living(r_ptr))
699 for (i = 0; i < 4; i++)
701 if (r_ptr->blow[i].method == RBM_EXPLODE)
703 return _("は爆発して粉々になった。", " explodes into tiny shreds.");
706 return _("を倒した。", " is destroyed.");
709 /* Assume a default death */
710 return _("は死んだ。", " dies.");
715 * @brief モンスターが死亡した時の処理 /
716 * Handle the "death" of a monster.
717 * @param m_idx 死亡したモンスターのID
718 * @param drop_item TRUEならばモンスターのドロップ処理を行う
719 * @return 撃破されたモンスターの述語
722 * Disperse treasures centered at the monster location based on the
723 * various flags contained in the monster flags fields.
724 * Check for "Quest" completion when a quest monster is killed.
725 * Note that only the player can induce "monster_death()" on Uniques.
726 * Thus (for now) all Quest monsters should be Uniques.
727 * Note that monsters can now carry objects, and when a monster dies,
728 * it drops all of its objects, which may disappear in crowded rooms.
731 void monster_death(MONSTER_IDX m_idx, bool drop_item)
740 monster_type *m_ptr = &m_list[m_idx];
742 monster_race *r_ptr = &r_info[m_ptr->r_idx];
744 bool visible = ((m_ptr->ml && !p_ptr->image) || (r_ptr->flags1 & RF1_UNIQUE));
748 bool do_gold = (!(r_ptr->flags1 & RF1_ONLY_ITEM));
749 bool do_item = (!(r_ptr->flags1 & RF1_ONLY_GOLD));
750 bool cloned = (m_ptr->smart & SM_CLONED) ? TRUE : FALSE;
751 int force_coin = get_coin_type(m_ptr->r_idx);
756 bool drop_chosen_item = drop_item && !cloned && !p_ptr->inside_arena
757 && !p_ptr->inside_battle && !is_pet(m_ptr);
759 /* The caster is dead? */
760 if (world_monster && world_monster == m_idx) world_monster = 0;
762 /* Notice changes in view */
763 if (r_ptr->flags7 & (RF7_LITE_MASK | RF7_DARK_MASK))
765 /* Update some things */
766 p_ptr->update |= (PU_MON_LITE);
769 /* Get the location */
773 if (record_named_pet && is_pet(m_ptr) && m_ptr->nickname)
777 monster_desc(m_name, m_ptr, MD_INDEF_VISIBLE);
778 do_cmd_write_nikki(NIKKI_NAMED_PET, 3, m_name);
781 /* Let monsters explode! */
782 for (i = 0; i < 4; i++)
784 if (r_ptr->blow[i].method == RBM_EXPLODE)
786 BIT_FLAGS flg = PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL;
787 EFFECT_ID typ = mbe_info[r_ptr->blow[i].effect].explode_type;
788 DICE_NUMBER d_dice = r_ptr->blow[i].d_dice;
789 DICE_SID d_side = r_ptr->blow[i].d_side;
790 HIT_POINT damage = damroll(d_dice, d_side);
792 project(m_idx, 3, y, x, damage, typ, flg, -1);
797 if (m_ptr->mflag2 & MFLAG2_CHAMELEON)
799 choose_new_monster(m_idx, TRUE, MON_CHAMELEON);
800 r_ptr = &r_info[m_ptr->r_idx];
803 /* Check for quest completion */
804 check_quest_completion(m_ptr);
806 /* Handle the possibility of player vanquishing arena combatant -KMW- */
807 if (p_ptr->inside_arena && !is_pet(m_ptr))
809 p_ptr->exit_bldg = TRUE;
811 if (p_ptr->arena_number > MAX_ARENA_MONS)
813 msg_print(_("素晴らしい!君こそ真の勝利者だ。", "You are a Genuine Champion!"));
817 msg_print(_("勝利!チャンピオンへの道を進んでいる。", "Victorious! You're on your way to becoming Champion."));
820 if (arena_info[p_ptr->arena_number].tval)
822 /* Get local object */
825 /* Prepare to make a prize */
826 object_prep(q_ptr, lookup_kind(arena_info[p_ptr->arena_number].tval, arena_info[p_ptr->arena_number].sval));
828 apply_magic(q_ptr, object_level, AM_NO_FIXED_ART);
830 /* Drop it in the dungeon */
831 (void)drop_near(q_ptr, -1, y, x);
834 if (p_ptr->arena_number > MAX_ARENA_MONS) p_ptr->arena_number++;
835 p_ptr->arena_number++;
840 /* Extract monster name */
841 monster_desc(m_name, m_ptr, MD_IGNORE_HALLU | MD_ASSUME_VISIBLE | MD_INDEF_VISIBLE);
843 do_cmd_write_nikki(NIKKI_ARENA, p_ptr->arena_number, m_name);
847 if (m_idx == p_ptr->riding)
849 if (rakuba(-1, FALSE))
851 msg_print(_("地面に落とされた。", "You have fallen from your riding pet."));
855 /* Drop a dead corpse? */
856 if (one_in_(r_ptr->flags1 & RF1_UNIQUE ? 1 : 4) &&
857 (r_ptr->flags9 & (RF9_DROP_CORPSE | RF9_DROP_SKELETON)) &&
858 !(p_ptr->inside_arena || p_ptr->inside_battle || cloned || ((m_ptr->r_idx == today_mon) && is_pet(m_ptr))))
860 /* Assume skeleton */
864 * We cannot drop a skeleton? Note, if we are in this check,
865 * we *know* we can drop at least a corpse or a skeleton
867 if (!(r_ptr->flags9 & RF9_DROP_SKELETON))
869 else if ((r_ptr->flags9 & RF9_DROP_CORPSE) && (r_ptr->flags1 & RF1_UNIQUE))
872 /* Else, a corpse is more likely unless we did a "lot" of damage */
873 else if (r_ptr->flags9 & RF9_DROP_CORPSE)
875 /* Lots of damage in one blow */
876 if ((0 - ((m_ptr->maxhp) / 4)) > m_ptr->hp)
878 if (one_in_(5)) corpse = TRUE;
882 if (!one_in_(5)) corpse = TRUE;
886 /* Get local object */
889 /* Prepare to make an object */
890 object_prep(q_ptr, lookup_kind(TV_CORPSE, (corpse ? SV_CORPSE : SV_SKELETON)));
892 apply_magic(q_ptr, object_level, AM_NO_FIXED_ART);
894 q_ptr->pval = m_ptr->r_idx;
896 /* Drop it in the dungeon */
897 (void)drop_near(q_ptr, -1, y, x);
900 /* Drop objects being carried */
901 monster_drop_carried_objects(m_ptr);
903 if (r_ptr->flags1 & RF1_DROP_GOOD) mo_mode |= AM_GOOD;
904 if (r_ptr->flags1 & RF1_DROP_GREAT) mo_mode |= AM_GREAT;
906 switch (m_ptr->r_idx)
908 case MON_PINK_HORROR:
909 /* Pink horrors are replaced with 2 Blue horrors */
910 if (!(p_ptr->inside_arena || p_ptr->inside_battle))
914 for (i = 0; i < 2; i++)
917 bool pet = is_pet(m_ptr);
920 if (pet) mode |= PM_FORCE_PET;
922 if (summon_specific((pet ? -1 : m_idx), wy, wx, 100, SUMMON_BLUE_HORROR, mode))
924 if (player_can_see_bold(wy, wx))
930 msg_print(_("ピンク・ホラーは分裂した!", "The Pink horror divides!"));
934 case MON_BLOODLETTER:
935 /* Bloodletters of Khorne may drop a blade of chaos */
936 if (drop_chosen_item && (randint1(100) < 15))
938 /* Get local object */
941 /* Prepare to make a Blade of Chaos */
942 object_prep(q_ptr, lookup_kind(TV_SWORD, SV_BLADE_OF_CHAOS));
944 apply_magic(q_ptr, object_level, AM_NO_FIXED_ART | mo_mode);
946 /* Drop it in the dungeon */
947 (void)drop_near(q_ptr, -1, y, x);
952 if (drop_chosen_item && (dun_level > 9))
954 /* Get local object */
957 /* Wipe the object */
960 /* Activate restriction */
961 if ((dun_level > 49) && one_in_(5))
962 get_obj_num_hook = kind_is_good_book;
964 get_obj_num_hook = kind_is_book;
967 make_object(q_ptr, mo_mode);
969 /* Drop it in the dungeon */
970 (void)drop_near(q_ptr, -1, y, x);
976 * Mega^3-hack: killing a 'Warrior of the Dawn' is likely to
977 * spawn another in the fallen one's place!
979 if (!p_ptr->inside_arena && !p_ptr->inside_battle)
983 POSITION wy = y, wx = x;
985 bool pet = is_pet(m_ptr);
989 scatter(&wy, &wx, y, x, 20, 0);
991 while (!(in_bounds(wy, wx) && cave_empty_bold2(wy, wx)) && --attempts);
996 if (pet) mode |= PM_FORCE_PET;
998 if (summon_specific((pet ? -1 : m_idx), wy, wx, 100, SUMMON_DAWN, mode))
1000 if (player_can_see_bold(wy, wx))
1001 msg_print(_("新たな戦士が現れた!", "A new warrior steps forth!"));
1009 /* One more ultra-hack: An Unmaker goes out with a big bang! */
1011 BIT_FLAGS flg = PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL;
1012 (void)project(m_idx, 6, y, x, 100, GF_CHAOS, flg, -1);
1016 case MON_UNICORN_ORD:
1019 /* Reward for "lazy" player */
1020 if (p_ptr->pseikaku == SEIKAKU_NAMAKE)
1022 ARTIFACT_IDX a_idx = 0;
1023 artifact_type *a_ptr = NULL;
1025 if (!drop_chosen_item) break;
1029 switch (randint0(3))
1032 a_idx = ART_NAMAKE_HAMMER;
1035 a_idx = ART_NAMAKE_BOW;
1038 a_idx = ART_NAMAKE_ARMOR;
1042 a_ptr = &a_info[a_idx];
1044 while (a_ptr->cur_num);
1046 /* Create the artifact */
1047 if (create_named_art(a_idx, y, x))
1051 /* Hack -- Memorize location of artifact in saved floors */
1052 if (character_dungeon) a_ptr->floor_id = p_ptr->floor_id;
1054 else if (!preserve_mode) a_ptr->cur_num = 1;
1059 if (!drop_chosen_item) break;
1061 /* Get local object */
1064 /* Mega-Hack -- Prepare to make "Grond" */
1065 object_prep(q_ptr, lookup_kind(TV_HAFTED, SV_GROND));
1067 /* Mega-Hack -- Mark this item as "Grond" */
1068 q_ptr->name1 = ART_GROND;
1070 /* Mega-Hack -- Actually create "Grond" */
1071 apply_magic(q_ptr, -1, AM_GOOD | AM_GREAT);
1073 /* Drop it in the dungeon */
1074 (void)drop_near(q_ptr, -1, y, x);
1076 /* Get local object */
1079 /* Mega-Hack -- Prepare to make "Chaos" */
1080 object_prep(q_ptr, lookup_kind(TV_CROWN, SV_CHAOS));
1082 /* Mega-Hack -- Mark this item as "Chaos" */
1083 q_ptr->name1 = ART_CHAOS;
1085 /* Mega-Hack -- Actually create "Chaos" */
1086 apply_magic(q_ptr, -1, AM_GOOD | AM_GREAT);
1088 /* Drop it in the dungeon */
1089 (void)drop_near(q_ptr, -1, y, x);
1092 case MON_B_DEATH_SWORD:
1093 if (drop_chosen_item)
1095 /* Get local object */
1098 /* Prepare to make a broken sword */
1099 object_prep(q_ptr, lookup_kind(TV_SWORD, randint1(2)));
1101 /* Drop it in the dungeon */
1102 (void)drop_near(q_ptr, -1, y, x);
1108 if (drop_chosen_item && ((m_ptr->r_idx == MON_A_GOLD) ||
1109 ((m_ptr->r_idx == MON_A_SILVER) && (r_ptr->r_akills % 5 == 0))))
1111 /* Get local object */
1114 /* Prepare to make a Can of Toys */
1115 object_prep(q_ptr, lookup_kind(TV_CHEST, SV_CHEST_KANDUME));
1117 apply_magic(q_ptr, object_level, AM_NO_FIXED_ART);
1119 /* Drop it in the dungeon */
1120 (void)drop_near(q_ptr, -1, y, x);
1126 BIT_FLAGS flg = PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL;
1127 (void)project(m_idx, 3, y, x, damroll(20, 10), GF_FIRE, flg, -1);
1132 if (!drop_chosen_item) break;
1134 switch (r_ptr->d_char)
1139 /* Get local object */
1142 /* Wipe the object */
1145 /* Activate restriction */
1146 get_obj_num_hook = kind_is_cloak;
1149 make_object(q_ptr, mo_mode);
1151 /* Drop it in the dungeon */
1152 (void)drop_near(q_ptr, -1, y, x);
1159 /* Get local object */
1162 /* Wipe the object */
1165 /* Activate restriction */
1166 get_obj_num_hook = kind_is_polearm;
1168 /* Make a poleweapon */
1169 make_object(q_ptr, mo_mode);
1171 /* Drop it in the dungeon */
1172 (void)drop_near(q_ptr, -1, y, x);
1179 /* Get local object */
1182 /* Wipe the object */
1185 /* Activate restriction */
1186 get_obj_num_hook = kind_is_armor;
1188 /* Make a hard armor */
1189 make_object(q_ptr, mo_mode);
1191 /* Drop it in the dungeon */
1192 (void)drop_near(q_ptr, -1, y, x);
1199 /* Get local object */
1202 /* Wipe the object */
1205 /* Activate restriction */
1206 get_obj_num_hook = kind_is_hafted;
1208 /* Make a hafted weapon */
1209 make_object(q_ptr, mo_mode);
1211 /* Drop it in the dungeon */
1212 (void)drop_near(q_ptr, -1, y, x);
1217 if (m_ptr->r_idx != MON_STORMBRINGER)
1219 /* Get local object */
1222 /* Wipe the object */
1225 /* Activate restriction */
1226 get_obj_num_hook = kind_is_sword;
1229 make_object(q_ptr, mo_mode);
1231 /* Drop it in the dungeon */
1232 (void)drop_near(q_ptr, -1, y, x);
1239 /* Mega-Hack -- drop fixed items */
1240 if (drop_chosen_item)
1242 ARTIFACT_IDX a_idx = 0;
1245 for(i = 0; i < 4; i++)
1247 if(!r_ptr->artifact_id[i]) break;
1248 a_idx = r_ptr->artifact_id[i];
1249 chance = r_ptr->artifact_percent[i];
1252 if ((a_idx > 0) && ((randint0(100) < chance) || p_ptr->wizard))
1254 artifact_type *a_ptr = &a_info[a_idx];
1256 if (!a_ptr->cur_num)
1258 /* Create the artifact */
1259 if (create_named_art(a_idx, y, x))
1263 /* Hack -- Memorize location of artifact in saved floors */
1264 if (character_dungeon) a_ptr->floor_id = p_ptr->floor_id;
1266 else if (!preserve_mode) a_ptr->cur_num = 1;
1270 if ((r_ptr->flags7 & RF7_GUARDIAN) && (d_info[dungeon_type].final_guardian == m_ptr->r_idx))
1272 KIND_OBJECT_IDX k_idx = d_info[dungeon_type].final_object ? d_info[dungeon_type].final_object
1273 : lookup_kind(TV_SCROLL, SV_SCROLL_ACQUIREMENT);
1275 if (d_info[dungeon_type].final_artifact)
1277 a_idx = d_info[dungeon_type].final_artifact;
1278 artifact_type *a_ptr = &a_info[a_idx];
1280 if (!a_ptr->cur_num)
1282 /* Create the artifact */
1283 if (create_named_art(a_idx, y, x))
1287 /* Hack -- Memorize location of artifact in saved floors */
1288 if (character_dungeon) a_ptr->floor_id = p_ptr->floor_id;
1290 else if (!preserve_mode) a_ptr->cur_num = 1;
1292 /* Prevent rewarding both artifact and "default" object */
1293 if (!d_info[dungeon_type].final_object) k_idx = 0;
1299 /* Get local object */
1302 /* Prepare to make a reward */
1303 object_prep(q_ptr, k_idx);
1305 apply_magic(q_ptr, object_level, AM_NO_FIXED_ART | AM_GOOD);
1307 /* Drop it in the dungeon */
1308 (void)drop_near(q_ptr, -1, y, x);
1310 msg_format(_("あなたは%sを制覇した!", "You have conquered %s!"),d_name+d_info[dungeon_type].name);
1314 /* Determine how much we can drop */
1315 if ((r_ptr->flags1 & RF1_DROP_60) && (randint0(100) < 60)) number++;
1316 if ((r_ptr->flags1 & RF1_DROP_90) && (randint0(100) < 90)) number++;
1317 if (r_ptr->flags1 & RF1_DROP_1D2) number += damroll(1, 2);
1318 if (r_ptr->flags1 & RF1_DROP_2D2) number += damroll(2, 2);
1319 if (r_ptr->flags1 & RF1_DROP_3D2) number += damroll(3, 2);
1320 if (r_ptr->flags1 & RF1_DROP_4D2) number += damroll(4, 2);
1322 if (cloned && !(r_ptr->flags1 & RF1_UNIQUE))
1323 number = 0; /* Clones drop no stuff unless Cloning Pits */
1325 if (is_pet(m_ptr) || p_ptr->inside_battle || p_ptr->inside_arena)
1326 number = 0; /* Pets drop no stuff */
1327 if (!drop_item && (r_ptr->d_char != '$')) number = 0;
1329 if((r_ptr->flags2 & (RF2_MULTIPLY)) && (r_ptr->r_akills > 1024))
1330 number = 0; /* Limit of Multiply monster drop */
1332 /* Hack -- handle creeping coins */
1333 coin_type = force_coin;
1335 /* Average dungeon and monster levels */
1336 object_level = (dun_level + r_ptr->level) / 2;
1338 /* Drop some objects */
1339 for (j = 0; j < number; j++)
1341 /* Get local object */
1344 /* Wipe the object */
1348 if (do_gold && (!do_item || (randint0(100) < 50)))
1350 /* Make some gold */
1351 if (!make_gold(q_ptr)) continue;
1359 /* Make an object */
1360 if (!make_object(q_ptr, mo_mode)) continue;
1365 /* Drop it in the dungeon */
1366 (void)drop_near(q_ptr, -1, y, x);
1369 /* Reset the object level */
1370 object_level = base_level;
1372 /* Reset "coin" type */
1376 /* Take note of any dropped treasure */
1377 if (visible && (dump_item || dump_gold))
1379 /* Take notes on treasure */
1380 lore_treasure(m_idx, dump_item, dump_gold);
1383 /* Only process "Quest Monsters" */
1384 if (!(r_ptr->flags1 & RF1_QUESTOR)) return;
1385 if (p_ptr->inside_battle) return;
1388 if ((m_ptr->r_idx == MON_SERPENT) && !cloned)
1391 p_ptr->total_winner = TRUE;
1393 /* Redraw the "title" */
1394 p_ptr->redraw |= (PR_TITLE);
1396 play_music(TERM_XTRA_MUSIC_BASIC, MUSIC_BASIC_FINAL_QUEST_CLEAR);
1398 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, _("見事に変愚蛮怒の勝利者となった!", "become *WINNER* of Hengband finely!"));
1400 if ((p_ptr->pclass == CLASS_CHAOS_WARRIOR) || (p_ptr->muta2 & MUT2_CHAOS_GIFT))
1402 msg_format(_("%sからの声が響いた。", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
1403 msg_print(_("『よくやった、定命の者よ!』", "'Thou art donst well, mortal!'"));
1406 /* Congratulations */
1407 msg_print(_("*** おめでとう ***", "*** CONGRATULATIONS ***"));
1408 msg_print(_("あなたはゲームをコンプリートしました。", "You have won the game!"));
1409 msg_print(_("準備が整ったら引退(自殺コマンド)しても結構です。", "You may retire (commit suicide) when you are ready."));
1414 * @brief モンスターに与えたダメージの修正処理 /
1415 * Modify the physical damage done to the monster.
1416 * @param m_ptr ダメージを受けるモンスターの構造体参照ポインタ
1417 * @param dam ダメージ基本値
1418 * @param is_psy_spear 攻撃手段が光の剣ならばTRUE
1419 * @return 修正を行った結果のダメージ量
1422 * (for example when it's invulnerable or shielded)
1423 * ToDo: Accept a damage-type to calculate the modified damage from
1424 * things like fire, frost, lightning, poison, ... attacks.
1425 * "type" is not yet used and should be 0.
1428 HIT_POINT mon_damage_mod(monster_type *m_ptr, HIT_POINT dam, bool is_psy_spear)
1430 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1432 if ((r_ptr->flagsr & RFR_RES_ALL) && dam > 0)
1435 if ((dam == 0) && one_in_(3)) dam = 1;
1438 if (MON_INVULNER(m_ptr))
1442 if (!p_ptr->blind && is_seen(m_ptr))
1444 msg_print(_("バリアを切り裂いた!", "The barrier is penetrated!"));
1447 else if (!one_in_(PENETRATE_INVULNERABILITY))
1457 * @brief モンスターに与えたダメージを元に経験値を加算する /
1458 * Calculate experience point to be get
1459 * @param dam 与えたダメージ量
1460 * @param m_ptr ダメージを与えたモンスターの構造体参照ポインタ
1464 * Even the 64 bit operation is not big enough to avoid overflaw
1465 * unless we carefully choose orders of multiplication and division.
1466 * Get the coefficient first, and multiply (potentially huge) base
1467 * experience point of a monster later.
1470 static void get_exp_from_mon(HIT_POINT dam, monster_type *m_ptr)
1472 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1479 if (!m_ptr->r_idx) return;
1480 if (is_pet(m_ptr) || p_ptr->inside_battle) return;
1483 * - Ratio of monster's level to player's level effects
1484 * - Varying speed effects
1485 * - Get a fraction in proportion of damage point
1487 new_exp = r_ptr->level * SPEED_TO_ENERGY(m_ptr->mspeed) * dam;
1490 div_l = (p_ptr->max_plv+2) * SPEED_TO_ENERGY(r_ptr->speed);
1492 /* Use (average maxhp * 2) as a denominator */
1493 if (!(r_ptr->flags1 & RF1_FORCE_MAXHP))
1494 s64b_mul(&div_h, &div_l, 0, r_ptr->hdice * (ironman_nightmare ? 2 : 1) * (r_ptr->hside + 1));
1496 s64b_mul(&div_h, &div_l, 0, r_ptr->hdice * (ironman_nightmare ? 2 : 1) * r_ptr->hside * 2);
1498 /* Special penalty in the wilderness */
1499 if (!dun_level && (!(r_ptr->flags8 & RF8_WILD_ONLY) || !(r_ptr->flags1 & RF1_UNIQUE)))
1500 s64b_mul(&div_h, &div_l, 0, 5);
1502 /* Do division first to prevent overflaw */
1503 s64b_div(&new_exp, &new_exp_frac, div_h, div_l);
1505 /* Special penalty for mutiply-monster */
1506 if ((r_ptr->flags2 & RF2_MULTIPLY) || (m_ptr->r_idx == MON_DAWN))
1508 int monnum_penarty = r_ptr->r_akills / 400;
1509 if (monnum_penarty > 8) monnum_penarty = 8;
1511 while (monnum_penarty--)
1514 s64b_RSHIFT(new_exp, new_exp_frac, 2);
1518 /* Special penalty for rest_and_shoot exp scum */
1519 if ((m_ptr->dealt_damage > m_ptr->max_maxhp) && (m_ptr->hp >= 0))
1521 int over_damage = m_ptr->dealt_damage / m_ptr->max_maxhp;
1522 if (over_damage > 32) over_damage = 32;
1524 while (over_damage--)
1527 s64b_mul(&new_exp, &new_exp_frac, 0, 9);
1528 s64b_div(&new_exp, &new_exp_frac, 0, 10);
1532 /* Finally multiply base experience point of the monster */
1533 s64b_mul(&new_exp, &new_exp_frac, 0, r_ptr->mexp);
1535 /* Gain experience */
1536 gain_exp_64(new_exp, new_exp_frac);
1541 * @brief モンスターのHPをダメージに応じて減算する /
1542 * Decreases monsters hit points, handling monster death.
1543 * @param dam 与えたダメージ量
1544 * @param m_idx ダメージを与えたモンスターのID
1545 * @param fear ダメージによってモンスターが恐慌状態に陥ったならばTRUEを返す
1546 * @param note モンスターが倒された際の特別なメッセージ述語
1550 * We return TRUE if the monster has been killed (and deleted).
1551 * We announce monster death (using an optional "death message"
1552 * if given, and a otherwise a generic killed/destroyed message).
1553 * Only "physical attacks" can induce the "You have slain" message.
1554 * Missile and Spell attacks will induce the "dies" message, or
1555 * various "specialized" messages. Note that "You have destroyed"
1556 * and "is destroyed" are synonyms for "You have slain" and "dies".
1557 * Hack -- unseen monsters yield "You have killed it." message.
1558 * Added fear (DGK) and check whether to print fear messages -CWS
1559 * Made name, sex, and capitalization generic -BEN-
1560 * As always, the "ghost" processing is a total hack.
1561 * Hack -- we "delay" fear messages by passing around a "fear" flag.
1562 * Consider decreasing monster experience over time, say,
1563 * by using "(m_exp * m_lev * (m_lev)) / (p_lev * (m_lev + n_killed))"
1564 * instead of simply "(m_exp * m_lev) / (p_lev)", to make the first
1565 * monster worth more than subsequent monsters. This would also need
1566 * to induce changes in the monster recall code.
1569 bool mon_take_hit(MONSTER_IDX m_idx, HIT_POINT dam, bool *fear, cptr note)
1571 monster_type *m_ptr = &m_list[m_idx];
1572 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1574 monster_type exp_mon;
1576 /* Innocent until proven otherwise */
1577 bool innocent = TRUE, thief = FALSE;
1581 (void)COPY(&exp_mon, m_ptr, monster_type);
1583 expdam = (m_ptr->hp > dam) ? dam : m_ptr->hp;
1585 get_exp_from_mon(expdam, &exp_mon);
1587 /* Genocided by chaos patron */
1588 if (!m_ptr->r_idx) m_idx = 0;
1590 /* Redraw (later) if needed */
1591 if (p_ptr->health_who == m_idx) p_ptr->redraw |= (PR_HEALTH);
1592 if (p_ptr->riding == m_idx) p_ptr->redraw |= (PR_UHEALTH);
1595 (void)set_monster_csleep(m_idx, 0);
1597 /* Hack - Cancel any special player stealth magics. -LM- */
1598 if (p_ptr->special_defense & NINJA_S_STEALTH)
1600 set_superstealth(FALSE);
1603 /* Genocided by chaos patron */
1604 if (!m_idx) return TRUE;
1609 m_ptr->dealt_damage += dam;
1610 if(m_ptr->dealt_damage > m_ptr->max_maxhp * 100) m_ptr->dealt_damage = m_ptr->max_maxhp * 100;
1613 msg_format( _("合計%d/%dのダメージを与えた。","You do %d (out of %d) damage."),
1614 m_ptr->dealt_damage, m_ptr->maxhp);
1617 /* It is dead now */
1622 if (r_info[m_ptr->r_idx].flags7 & RF7_TANUKI)
1624 /* You might have unmasked Tanuki first time */
1625 r_ptr = &r_info[m_ptr->r_idx];
1626 m_ptr->ap_r_idx = m_ptr->r_idx;
1627 if (r_ptr->r_sights < MAX_SHORT) r_ptr->r_sights++;
1630 if (m_ptr->mflag2 & MFLAG2_CHAMELEON)
1632 /* You might have unmasked Chameleon first time */
1633 r_ptr = real_r_ptr(m_ptr);
1634 if (r_ptr->r_sights < MAX_SHORT) r_ptr->r_sights++;
1637 if (!(m_ptr->smart & SM_CLONED))
1639 /* When the player kills a Unique, it stays dead */
1640 if (r_ptr->flags1 & RF1_UNIQUE)
1644 /* Mega-Hack -- Banor & Lupart */
1645 if ((m_ptr->r_idx == MON_BANOR) || (m_ptr->r_idx == MON_LUPART))
1647 r_info[MON_BANORLUPART].max_num = 0;
1648 r_info[MON_BANORLUPART].r_pkills++;
1649 r_info[MON_BANORLUPART].r_akills++;
1650 if (r_info[MON_BANORLUPART].r_tkills < MAX_SHORT) r_info[MON_BANORLUPART].r_tkills++;
1652 else if (m_ptr->r_idx == MON_BANORLUPART)
1654 r_info[MON_BANOR].max_num = 0;
1655 r_info[MON_BANOR].r_pkills++;
1656 r_info[MON_BANOR].r_akills++;
1657 if (r_info[MON_BANOR].r_tkills < MAX_SHORT) r_info[MON_BANOR].r_tkills++;
1658 r_info[MON_LUPART].max_num = 0;
1659 r_info[MON_LUPART].r_pkills++;
1660 r_info[MON_LUPART].r_akills++;
1661 if (r_info[MON_LUPART].r_tkills < MAX_SHORT) r_info[MON_LUPART].r_tkills++;
1665 /* When the player kills a Nazgul, it stays dead */
1666 else if (r_ptr->flags7 & RF7_NAZGUL) r_ptr->max_num--;
1669 /* Count all monsters killed */
1670 if (r_ptr->r_akills < MAX_SHORT) r_ptr->r_akills++;
1672 /* Recall even invisible uniques or winners */
1673 if ((m_ptr->ml && !p_ptr->image) || (r_ptr->flags1 & RF1_UNIQUE))
1675 /* Count kills this life */
1676 if ((m_ptr->mflag2 & MFLAG2_KAGE) && (r_info[MON_KAGE].r_pkills < MAX_SHORT)) r_info[MON_KAGE].r_pkills++;
1677 else if (r_ptr->r_pkills < MAX_SHORT) r_ptr->r_pkills++;
1679 /* Count kills in all lives */
1680 if ((m_ptr->mflag2 & MFLAG2_KAGE) && (r_info[MON_KAGE].r_tkills < MAX_SHORT)) r_info[MON_KAGE].r_tkills++;
1681 else if (r_ptr->r_tkills < MAX_SHORT) r_ptr->r_tkills++;
1683 /* Hack -- Auto-recall */
1684 monster_race_track(m_ptr->ap_r_idx);
1687 /* Extract monster name */
1688 monster_desc(m_name, m_ptr, MD_TRUE_NAME);
1690 /* Don't kill Amberites */
1691 if ((r_ptr->flags3 & RF3_AMBERITE) && one_in_(2))
1693 int curses = 1 + randint1(3);
1694 bool stop_ty = FALSE;
1697 msg_format(_("%^sは恐ろしい血の呪いをあなたにかけた!", "%^s puts a terrible blood curse on you!"), m_name);
1698 curse_equipment(100, 50);
1702 stop_ty = activate_ty_curse(stop_ty, &count);
1707 if (r_ptr->flags2 & RF2_CAN_SPEAK)
1709 char line_got[1024];
1711 /* Dump a message */
1712 if (!get_rnd_line(_("mondeath_j.txt", "mondeath.txt"), m_ptr->r_idx, line_got))
1714 msg_format("%^s %s", m_name, line_got);
1717 if (m_ptr->r_idx == MON_SERPENT)
1719 /* Make screen dump */
1720 screen_dump = make_screen_dump();
1725 if (!(d_info[dungeon_type].flags1 & DF1_BEGINNER))
1727 if (!dun_level && !ambush_flag && !p_ptr->inside_arena)
1729 chg_virtue(V_VALOUR, -1);
1731 else if (r_ptr->level > dun_level)
1733 if (randint1(10) <= (r_ptr->level - dun_level))
1734 chg_virtue(V_VALOUR, 1);
1736 if (r_ptr->level > 60)
1738 chg_virtue(V_VALOUR, 1);
1740 if (r_ptr->level >= 2 * (p_ptr->lev+1))
1741 chg_virtue(V_VALOUR, 2);
1744 if (r_ptr->flags1 & RF1_UNIQUE)
1746 if (r_ptr->flags3 & (RF3_EVIL | RF3_GOOD)) chg_virtue(V_HARMONY, 2);
1748 if (r_ptr->flags3 & RF3_GOOD)
1750 chg_virtue(V_UNLIFE, 2);
1751 chg_virtue(V_VITALITY, -2);
1754 if (one_in_(3)) chg_virtue(V_INDIVIDUALISM, -1);
1757 if (m_ptr->r_idx == MON_BEGGAR || m_ptr->r_idx == MON_LEPER)
1759 chg_virtue(V_COMPASSION, -1);
1762 if ((r_ptr->flags3 & RF3_GOOD) &&
1763 ((r_ptr->level) / 10 + (3 * dun_level) >= randint1(100)))
1764 chg_virtue(V_UNLIFE, 1);
1766 if (r_ptr->d_char == 'A')
1768 if (r_ptr->flags1 & RF1_UNIQUE)
1769 chg_virtue(V_FAITH, -2);
1770 else if ((r_ptr->level) / 10 + (3 * dun_level) >= randint1(100))
1772 if (r_ptr->flags3 & RF3_GOOD) chg_virtue(V_FAITH, -1);
1773 else chg_virtue(V_FAITH, 1);
1776 else if (r_ptr->flags3 & RF3_DEMON)
1778 if (r_ptr->flags1 & RF1_UNIQUE)
1779 chg_virtue(V_FAITH, 2);
1780 else if ((r_ptr->level) / 10 + (3 * dun_level) >= randint1(100))
1781 chg_virtue(V_FAITH, 1);
1784 if ((r_ptr->flags3 & RF3_UNDEAD) && (r_ptr->flags1 & RF1_UNIQUE))
1785 chg_virtue(V_VITALITY, 2);
1787 if (r_ptr->r_deaths)
1789 if (r_ptr->flags1 & RF1_UNIQUE)
1791 chg_virtue(V_HONOUR, 10);
1793 else if ((r_ptr->level) / 10 + (2 * dun_level) >= randint1(100))
1795 chg_virtue(V_HONOUR, 1);
1798 if ((r_ptr->flags2 & RF2_MULTIPLY) && (r_ptr->r_akills > 1000) && one_in_(10))
1800 chg_virtue(V_VALOUR, -1);
1803 for (i = 0; i < 4; i++)
1805 if (r_ptr->blow[i].d_dice != 0) innocent = FALSE; /* Murderer! */
1807 if ((r_ptr->blow[i].effect == RBE_EAT_ITEM)
1808 || (r_ptr->blow[i].effect == RBE_EAT_GOLD))
1810 thief = TRUE; /* Thief! */
1813 /* The new law says it is illegal to live in the dungeon */
1814 if (r_ptr->level != 0) innocent = FALSE;
1818 if (r_ptr->flags1 & RF1_UNIQUE)
1819 chg_virtue(V_JUSTICE, 3);
1820 else if (1+((r_ptr->level) / 10 + (2 * dun_level))
1822 chg_virtue(V_JUSTICE, 1);
1826 chg_virtue (V_JUSTICE, -1);
1829 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)))
1831 if (one_in_(4)) chg_virtue(V_NATURE, -1);
1834 if ((r_ptr->flags1 & RF1_UNIQUE) && record_destroy_uniq)
1838 sprintf(note_buf, "%s%s", r_name + r_ptr->name, (m_ptr->smart & SM_CLONED) ? "(クローン)" : "");
1840 sprintf(note_buf, "%s%s", r_name + r_ptr->name, (m_ptr->smart & SM_CLONED) ? "(Clone)" : "");
1842 do_cmd_write_nikki(NIKKI_UNIQUE, 0, note_buf);
1848 /* Death by Missile/Spell attack */
1851 msg_format("%^s%s", m_name, note);
1854 /* Death by physical attack -- invisible monster */
1855 else if (!m_ptr->ml)
1858 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
1859 msg_format("せっかくだから%sを殺した。", m_name);
1861 msg_format("%sを殺した。", m_name);
1863 msg_format("You have killed %s.", m_name);
1868 /* Death by Physical attack -- non-living monster */
1869 else if (!monster_living(r_ptr))
1871 bool explode = FALSE;
1873 for (i = 0; i < 4; i++)
1875 if (r_ptr->blow[i].method == RBM_EXPLODE) explode = TRUE;
1878 /* Special note at death */
1880 msg_format(_("%sは爆発して粉々になった。", "%^s explodes into tiny shreds."), m_name);
1884 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
1885 msg_format("せっかくだから%sを倒した。", m_name);
1887 msg_format("%sを倒した。", m_name);
1889 msg_format("You have destroyed %s.", m_name);
1894 /* Death by Physical attack -- living monster */
1898 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
1899 msg_format("せっかくだから%sを葬り去った。", m_name);
1901 msg_format("%sを葬り去った。", m_name);
1903 msg_format("You have slain %s.", m_name);
1907 if ((r_ptr->flags1 & RF1_UNIQUE) && !(m_ptr->smart & SM_CLONED) && !vanilla_town)
1909 for (i = 0; i < MAX_KUBI; i++)
1911 if ((kubi_r_idx[i] == m_ptr->r_idx) && !(m_ptr->mflag2 & MFLAG2_CHAMELEON))
1913 msg_format(_("%sの首には賞金がかかっている。", "There is a price on %s's head."), m_name);
1919 /* Generate treasure */
1920 monster_death(m_idx, TRUE);
1922 /* Mega hack : replace IKETA to BIKETAL */
1923 if ((m_ptr->r_idx == MON_IKETA) &&
1924 !(p_ptr->inside_arena || p_ptr->inside_battle))
1926 int dummy_y = m_ptr->fy;
1927 int dummy_x = m_ptr->fx;
1928 BIT_FLAGS mode = 0L;
1930 if (is_pet(m_ptr)) mode |= PM_FORCE_PET;
1933 delete_monster_idx(m_idx);
1935 if (summon_named_creature(0, dummy_y, dummy_x, MON_BIKETAL, mode))
1937 msg_print(_("「ハァッハッハッハ!!私がバイケタルだ!!」", "Uwa-hahaha! *I* am Biketal!"));
1943 delete_monster_idx(m_idx);
1946 get_exp_from_mon((long)exp_mon.max_maxhp*2, &exp_mon);
1951 /* Monster is dead */
1958 /* Mega-Hack -- Pain cancels fear */
1959 if (MON_MONFEAR(m_ptr) && (dam > 0))
1962 if (set_monster_monfear(m_idx, MON_MONFEAR(m_ptr) - randint1(dam)))
1969 /* Sometimes a monster gets scared by damage */
1970 if (!MON_MONFEAR(m_ptr) && !(r_ptr->flags3 & (RF3_NO_FEAR)))
1972 /* Percentage of fully healthy */
1973 int percentage = (100L * m_ptr->hp) / m_ptr->maxhp;
1976 * Run (sometimes) if at 10% or less of max hit points,
1977 * or (usually) when hit for half its current hit points
1979 if ((randint1(10) >= percentage) ||
1980 ((dam >= m_ptr->hp) && (randint0(100) < 80)))
1982 /* Hack -- note fear */
1985 /* Hack -- Add some timed fear */
1986 (void)set_monster_monfear(m_idx, (randint1(10) +
1987 (((dam >= m_ptr->hp) && (percentage > 7)) ?
1988 20 : ((11 - percentage) * 5))));
1995 if (p_ptr->riding && (p_ptr->riding == m_idx) && (dam > 0))
1999 /* Extract monster name */
2000 monster_desc(m_name, m_ptr, 0);
2002 if (m_ptr->hp > m_ptr->maxhp/3) dam = (dam + 1) / 2;
2003 if (rakuba((dam > 200) ? 200 : dam, FALSE))
2005 msg_format(_("%^sに振り落とされた!", "%^s has thrown you off!"), m_name);
2016 * @brief 現在のコンソール表示の縦横を返す。 /
2017 * Get term size and calculate screen size
2018 * @param wid_p コンソールの表示幅文字数を返す
2019 * @param hgt_p コンソールの表示行数を返す
2022 void get_screen_size(TERM_LEN *wid_p, TERM_LEN *hgt_p)
2024 Term_get_size(wid_p, hgt_p);
2025 *hgt_p -= ROW_MAP + 2;
2026 *wid_p -= COL_MAP + 2;
2027 if (use_bigtile) *wid_p /= 2;
2032 * @brief コンソール上におけるマップ表示の左上位置を返す /
2033 * Calculates current boundaries Called below and from "do_cmd_locate()".
2036 void panel_bounds_center(void)
2041 get_screen_size(&wid, &hgt);
2043 panel_row_max = panel_row_min + hgt - 1;
2044 panel_row_prt = panel_row_min - 1;
2045 panel_col_max = panel_col_min + wid - 1;
2046 panel_col_prt = panel_col_min - 13;
2051 * @brief コンソールのリサイズに合わせてマップを再描画する /
2052 * Map resizing whenever the main term changes size
2055 void resize_map(void)
2057 /* Only if the dungeon exists */
2058 if (!character_dungeon) return;
2060 /* Mega-Hack -- no panel yet */
2064 /* Reset the panels */
2065 panel_row_min = cur_hgt;
2066 panel_col_min = cur_wid;
2070 p_ptr->update |= (PU_TORCH | PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
2072 /* Forget lite/view */
2073 p_ptr->update |= (PU_UN_VIEW | PU_UN_LITE);
2075 /* Update lite/view */
2076 p_ptr->update |= (PU_VIEW | PU_LITE | PU_MON_LITE);
2078 /* Update monsters */
2079 p_ptr->update |= (PU_MONSTERS);
2081 /* Redraw everything */
2082 p_ptr->redraw |= (PR_WIPE | PR_BASIC | PR_EXTRA | PR_MAP | PR_EQUIPPY);
2084 /* Hack -- update */
2092 * Place the cursor on the player
2094 if (can_save) move_cursor_relative(p_ptr->y, p_ptr->x);
2101 * @brief コンソールを再描画する /
2102 * Redraw a term when it is resized
2105 void redraw_window(void)
2107 /* Only if the dungeon exists */
2108 if (!character_dungeon) return;
2110 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_SPELL | PW_PLAYER);
2112 p_ptr->window |= (PW_MESSAGE | PW_OVERHEAD | PW_DUNGEON | PW_MONSTER | PW_OBJECT);
2114 /* Hack -- update */
2123 * @brief フォーカスを当てるべきマップ描画の基準座標を指定する(サブルーチン)
2124 * @param dy 変更先のフロアY座標
2125 * @param dx 変更先のフロアX座標
2126 * Handle a request to change the current panel
2127 * Return TRUE if the panel was changed.
2128 * Also used in do_cmd_locate
2129 * @return 実際に再描画が必要だった場合TRUEを返す
2131 bool change_panel(POSITION dy, POSITION dx)
2137 get_screen_size(&wid, &hgt);
2139 /* Apply the motion */
2140 y = panel_row_min + dy * hgt / 2;
2141 x = panel_col_min + dx * wid / 2;
2143 /* Verify the row */
2144 if (y > cur_hgt - hgt) y = cur_hgt - hgt;
2147 /* Verify the col */
2148 if (x > cur_wid - wid) x = cur_wid - wid;
2151 /* Handle "changes" */
2152 if ((y != panel_row_min) || (x != panel_col_min))
2154 /* Save the new panel info */
2158 /* Recalculate the boundaries */
2159 panel_bounds_center();
2161 p_ptr->update |= (PU_MONSTERS);
2164 p_ptr->redraw |= (PR_MAP);
2178 * @brief フォーカスを当てるべきマップ描画の基準座標を指定する
2179 * @param y 変更先のフロアY座標
2180 * @param x 変更先のフロアX座標
2182 * Handle a request to change the current panel
2183 * Return TRUE if the panel was changed.
2184 * Also used in do_cmd_locate
2185 * @return 実際に再描画が必要だった場合TRUEを返す
2187 static bool change_panel_xy(POSITION y, POSITION x)
2189 POSITION dy = 0, dx = 0;
2193 get_screen_size(&wid, &hgt);
2195 if (y < panel_row_min) dy = -1;
2196 if (y > panel_row_max) dy = 1;
2197 if (x < panel_col_min) dx = -1;
2198 if (x > panel_col_max) dx = 1;
2200 if (!dy && !dx) return (FALSE);
2202 return change_panel(dy, dx);
2207 * @brief マップ描画のフォーカスを当てるべき座標を更新する
2209 * Given an row (y) and col (x), this routine detects when a move
2210 * off the screen has occurred and figures new borders. -RAK-
2211 * "Update" forces a "full update" to take place.
2212 * The map is reprinted if necessary, and "TRUE" is returned.
2213 * @return 実際に再描画が必要だった場合TRUEを返す
2215 void verify_panel(void)
2217 POSITION y = p_ptr->y;
2218 POSITION x = p_ptr->x;
2227 get_screen_size(&wid, &hgt);
2229 max_prow_min = cur_hgt - hgt;
2230 max_pcol_min = cur_wid - wid;
2232 /* Bounds checking */
2233 if (max_prow_min < 0) max_prow_min = 0;
2234 if (max_pcol_min < 0) max_pcol_min = 0;
2236 /* Center on player */
2237 if (center_player && (center_running || !running))
2239 /* Center vertically */
2240 prow_min = y - hgt / 2;
2241 if (prow_min < 0) prow_min = 0;
2242 else if (prow_min > max_prow_min) prow_min = max_prow_min;
2244 /* Center horizontally */
2245 pcol_min = x - wid / 2;
2246 if (pcol_min < 0) pcol_min = 0;
2247 else if (pcol_min > max_pcol_min) pcol_min = max_pcol_min;
2251 prow_min = panel_row_min;
2252 pcol_min = panel_col_min;
2254 /* Scroll screen when 2 grids from top/bottom edge */
2255 if (y > panel_row_max - 2)
2257 while (y > prow_min + hgt-1 - 2)
2259 prow_min += (hgt / 2);
2263 if (y < panel_row_min + 2)
2265 while (y < prow_min + 2)
2267 prow_min -= (hgt / 2);
2271 if (prow_min > max_prow_min) prow_min = max_prow_min;
2272 if (prow_min < 0) prow_min = 0;
2274 /* Scroll screen when 4 grids from left/right edge */
2275 if (x > panel_col_max - 4)
2277 while (x > pcol_min + wid-1 - 4)
2279 pcol_min += (wid / 2);
2283 if (x < panel_col_min + 4)
2285 while (x < pcol_min + 4)
2287 pcol_min -= (wid / 2);
2291 if (pcol_min > max_pcol_min) pcol_min = max_pcol_min;
2292 if (pcol_min < 0) pcol_min = 0;
2295 /* Check for "no change" */
2296 if ((prow_min == panel_row_min) && (pcol_min == panel_col_min)) return;
2298 /* Save the new panel info */
2299 panel_row_min = prow_min;
2300 panel_col_min = pcol_min;
2302 /* Hack -- optional disturb on "panel change" */
2303 if (disturb_panel && !center_player) disturb(0, 0);
2305 /* Recalculate the boundaries */
2306 panel_bounds_center();
2308 p_ptr->update |= (PU_MONSTERS);
2311 p_ptr->redraw |= (PR_MAP);
2313 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
2318 * Monster health description
2320 cptr look_mon_desc(monster_type *m_ptr, BIT_FLAGS mode)
2322 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
2329 /* Determine if the monster is "living" */
2330 living = monster_living(ap_r_ptr);
2332 /* Calculate a health "percentage" */
2333 perc = 100L * m_ptr->hp / m_ptr->maxhp;
2335 /* Healthy monsters */
2336 if (m_ptr->hp >= m_ptr->maxhp)
2340 desc = living ? "無傷" : "無ダメージ";
2342 desc = living ? "unhurt" : "undamaged";
2347 else if (perc >= 60)
2350 desc = living ? "軽傷" : "小ダメージ";
2352 desc = living ? "somewhat wounded" : "somewhat damaged";
2357 else if (perc >= 25)
2360 desc = living ? "負傷" : "中ダメージ";
2362 desc = living ? "wounded" : "damaged";
2367 else if (perc >= 10)
2370 desc = living ? "重傷" : "大ダメージ";
2372 desc = living ? "badly wounded" : "badly damaged";
2380 desc = living ? "半死半生" : "倒れかけ";
2382 desc = living ? "almost dead" : "almost destroyed";
2387 /* Need attitude information? */
2390 /* Full information is not needed */
2393 else if (is_pet(m_ptr))
2395 attitude = _(", ペット", ", pet");
2397 else if (is_friendly(m_ptr))
2399 attitude = _(", 友好的", ", friendly");
2403 attitude = _("", "");
2407 /* Clone monster? */
2408 if (m_ptr->smart & SM_CLONED)
2417 /* Display monster's level --- idea borrowed from ToME */
2418 if (ap_r_ptr->r_tkills && !(m_ptr->mflag2 & MFLAG2_KAGE))
2420 return format(_("レベル%d, %s%s%s", "Level %d, %s%s%s"), ap_r_ptr->level, desc, attitude, clone);
2424 return format(_("レベル???, %s%s%s", "Level ???, %s%s%s"), desc, attitude, clone);
2431 * Angband sorting algorithm -- quick sort in place
2433 * Note that the details of the data we are sorting is hidden,
2434 * and we rely on the "ang_sort_comp()" and "ang_sort_swap()"
2435 * function hooks to interact with the data, which is given as
2436 * two pointers, and which may have any user-defined form.
2438 void ang_sort_aux(vptr u, vptr v, int p, int q)
2456 while (!(*ang_sort_comp)(u, v, b, z)) b--;
2459 while (!(*ang_sort_comp)(u, v, z, a)) a++;
2461 /* Done partition */
2465 (*ang_sort_swap)(u, v, a, b);
2471 /* Recurse left side */
2472 ang_sort_aux(u, v, p, b);
2474 /* Recurse right side */
2475 ang_sort_aux(u, v, b+1, q);
2480 * Angband sorting algorithm -- quick sort in place
2482 * Note that the details of the data we are sorting is hidden,
2483 * and we rely on the "ang_sort_comp()" and "ang_sort_swap()"
2484 * function hooks to interact with the data, which is given as
2485 * two pointers, and which may have any user-defined form.
2487 void ang_sort(vptr u, vptr v, int n)
2489 /* Sort the array */
2490 ang_sort_aux(u, v, 0, n-1);
2495 /*** Targeting Code ***/
2499 * Determine is a monster makes a reasonable target
2501 * The concept of "targeting" was stolen from "Morgul" (?)
2503 * The player can target any location, or any "target-able" monster.
2505 * Currently, a monster is "target_able" if it is visible, and if
2506 * the player can hit it with a projection, and the player is not
2507 * hallucinating. This allows use of "use closest target" macros.
2509 * Future versions may restrict the ability to target "trappers"
2510 * and "mimics", but the semantics is a little bit weird.
2512 bool target_able(MONSTER_IDX m_idx)
2514 monster_type *m_ptr = &m_list[m_idx];
2516 /* Monster must be alive */
2517 if (!m_ptr->r_idx) return (FALSE);
2519 /* Hack -- no targeting hallucinations */
2520 if (p_ptr->image) return (FALSE);
2522 /* Monster must be visible */
2523 if (!m_ptr->ml) return (FALSE);
2525 if (p_ptr->riding && (p_ptr->riding == m_idx)) return (TRUE);
2527 /* Monster must be projectable */
2528 if (!projectable(p_ptr->y, p_ptr->x, m_ptr->fy, m_ptr->fx)) return (FALSE);
2530 /* Hack -- Never target trappers */
2531 /* if (CLEAR_ATTR && (CLEAR_CHAR)) return (FALSE); */
2541 * Update (if necessary) and verify (if possible) the target.
2543 * We return TRUE if the target is "okay" and FALSE otherwise.
2545 bool target_okay(void)
2547 /* Accept stationary targets */
2548 if (target_who < 0) return (TRUE);
2550 /* Check moving targets */
2553 /* Accept reasonable targets */
2554 if (target_able(target_who))
2556 monster_type *m_ptr = &m_list[target_who];
2558 /* Acquire monster location */
2559 target_row = m_ptr->fy;
2560 target_col = m_ptr->fx;
2567 /* Assume no target */
2573 * Sorting hook -- comp function -- by "distance to player"
2575 * We use "u" and "v" to point to arrays of "x" and "y" positions,
2576 * and sort the arrays by double-distance to the player.
2578 static bool ang_sort_comp_distance(vptr u, vptr v, int a, int b)
2580 POSITION *x = (POSITION*)(u);
2581 POSITION *y = (POSITION*)(v);
2583 POSITION da, db, kx, ky;
2585 /* Absolute distance components */
2586 kx = x[a]; kx -= p_ptr->x; kx = ABS(kx);
2587 ky = y[a]; ky -= p_ptr->y; ky = ABS(ky);
2589 /* Approximate Double Distance to the first point */
2590 da = ((kx > ky) ? (kx + kx + ky) : (ky + ky + kx));
2592 /* Absolute distance components */
2593 kx = x[b]; kx -= p_ptr->x; kx = ABS(kx);
2594 ky = y[b]; ky -= p_ptr->y; ky = ABS(ky);
2596 /* Approximate Double Distance to the first point */
2597 db = ((kx > ky) ? (kx + kx + ky) : (ky + ky + kx));
2599 /* Compare the distances */
2605 * Sorting hook -- comp function -- by importance level of grids
2607 * We use "u" and "v" to point to arrays of "x" and "y" positions,
2608 * and sort the arrays by level of monster
2610 static bool ang_sort_comp_importance(vptr u, vptr v, int a, int b)
2612 POSITION *x = (POSITION*)(u);
2613 POSITION *y = (POSITION*)(v);
2614 cave_type *ca_ptr = &cave[y[a]][x[a]];
2615 cave_type *cb_ptr = &cave[y[b]][x[b]];
2616 monster_type *ma_ptr = &m_list[ca_ptr->m_idx];
2617 monster_type *mb_ptr = &m_list[cb_ptr->m_idx];
2618 monster_race *ap_ra_ptr, *ap_rb_ptr;
2620 /* The player grid */
2621 if (y[a] == p_ptr->y && x[a] == p_ptr->x) return TRUE;
2622 if (y[b] == p_ptr->y && x[b] == p_ptr->x) return FALSE;
2624 /* Extract monster race */
2625 if (ca_ptr->m_idx && ma_ptr->ml) ap_ra_ptr = &r_info[ma_ptr->ap_r_idx];
2626 else ap_ra_ptr = NULL;
2627 if (cb_ptr->m_idx && mb_ptr->ml) ap_rb_ptr = &r_info[mb_ptr->ap_r_idx];
2628 else ap_rb_ptr = NULL;
2630 if (ap_ra_ptr && !ap_rb_ptr) return TRUE;
2631 if (!ap_ra_ptr && ap_rb_ptr) return FALSE;
2633 /* Compare two monsters */
2634 if (ap_ra_ptr && ap_rb_ptr)
2636 /* Unique monsters first */
2637 if ((ap_ra_ptr->flags1 & RF1_UNIQUE) && !(ap_rb_ptr->flags1 & RF1_UNIQUE)) return TRUE;
2638 if (!(ap_ra_ptr->flags1 & RF1_UNIQUE) && (ap_rb_ptr->flags1 & RF1_UNIQUE)) return FALSE;
2640 /* Shadowers first (あやしい影) */
2641 if ((ma_ptr->mflag2 & MFLAG2_KAGE) && !(mb_ptr->mflag2 & MFLAG2_KAGE)) return TRUE;
2642 if (!(ma_ptr->mflag2 & MFLAG2_KAGE) && (mb_ptr->mflag2 & MFLAG2_KAGE)) return FALSE;
2644 /* Unknown monsters first */
2645 if (!ap_ra_ptr->r_tkills && ap_rb_ptr->r_tkills) return TRUE;
2646 if (ap_ra_ptr->r_tkills && !ap_rb_ptr->r_tkills) return FALSE;
2648 /* Higher level monsters first (if known) */
2649 if (ap_ra_ptr->r_tkills && ap_rb_ptr->r_tkills)
2651 if (ap_ra_ptr->level > ap_rb_ptr->level) return TRUE;
2652 if (ap_ra_ptr->level < ap_rb_ptr->level) return FALSE;
2655 /* Sort by index if all conditions are same */
2656 if (ma_ptr->ap_r_idx > mb_ptr->ap_r_idx) return TRUE;
2657 if (ma_ptr->ap_r_idx < mb_ptr->ap_r_idx) return FALSE;
2660 /* An object get higher priority */
2661 if (cave[y[a]][x[a]].o_idx && !cave[y[b]][x[b]].o_idx) return TRUE;
2662 if (!cave[y[a]][x[a]].o_idx && cave[y[b]][x[b]].o_idx) return FALSE;
2664 /* Priority from the terrain */
2665 if (f_info[ca_ptr->feat].priority > f_info[cb_ptr->feat].priority) return TRUE;
2666 if (f_info[ca_ptr->feat].priority < f_info[cb_ptr->feat].priority) return FALSE;
2668 /* If all conditions are same, compare distance */
2669 return ang_sort_comp_distance(u, v, a, b);
2674 * Sorting hook -- swap function -- by "distance to player"
2676 * We use "u" and "v" to point to arrays of "x" and "y" positions,
2677 * and sort the arrays by distance to the player.
2679 static void ang_sort_swap_distance(vptr u, vptr v, int a, int b)
2681 POSITION *x = (POSITION*)(u);
2682 POSITION *y = (POSITION*)(v);
2700 * Hack -- help "select" a location (see below)
2702 static POSITION_IDX target_pick(POSITION y1, POSITION x1, POSITION dy, POSITION dx)
2705 POSITION x2, y2, x3, y3, x4, y4;
2706 POSITION_IDX b_i = -1, b_v = 9999;
2709 /* Scan the locations */
2710 for (i = 0; i < temp_n; i++)
2716 /* Directed distance */
2720 /* Verify quadrant */
2721 if (dx && (x3 * dx <= 0)) continue;
2722 if (dy && (y3 * dy <= 0)) continue;
2724 /* Absolute distance */
2728 /* Verify quadrant */
2729 if (dy && !dx && (x4 > y4)) continue;
2730 if (dx && !dy && (y4 > x4)) continue;
2732 /* Approximate Double Distance */
2733 v = ((x4 > y4) ? (x4 + x4 + y4) : (y4 + y4 + x4));
2735 /* Penalize location */
2738 if ((b_i >= 0) && (v >= b_v)) continue;
2750 * Hack -- determine if a given location is "interesting"
2752 static bool target_set_accept(POSITION y, POSITION x)
2755 OBJECT_IDX this_o_idx, next_o_idx = 0;
2758 if (!(in_bounds(y, x))) return (FALSE);
2760 /* Player grid is always interesting */
2761 if (player_bold(y, x)) return (TRUE);
2763 /* Handle hallucination */
2764 if (p_ptr->image) return (FALSE);
2766 /* Examine the grid */
2767 c_ptr = &cave[y][x];
2769 /* Visible monsters */
2772 monster_type *m_ptr = &m_list[c_ptr->m_idx];
2774 /* Visible monsters */
2775 if (m_ptr->ml) return (TRUE);
2778 /* Scan all objects in the grid */
2779 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
2783 /* Acquire object */
2784 o_ptr = &o_list[this_o_idx];
2786 /* Acquire next object */
2787 next_o_idx = o_ptr->next_o_idx;
2789 /* Memorized object */
2790 if (o_ptr->marked & OM_FOUND) return (TRUE);
2793 /* Interesting memorized features */
2794 if (c_ptr->info & (CAVE_MARK))
2796 /* Notice object features */
2797 if (c_ptr->info & CAVE_OBJECT) return (TRUE);
2799 /* Feature code (applying "mimic" field) */
2800 if (have_flag(f_info[get_feat_mimic(c_ptr)].flags, FF_NOTICE)) return TRUE;
2808 * Prepare the "temp" array for "target_set"
2810 * Return the number of target_able monsters in the set.
2812 static void target_set_prepare(BIT_FLAGS mode)
2815 POSITION min_hgt, max_hgt, min_wid, max_wid;
2817 if (mode & TARGET_KILL)
2820 min_hgt = MAX((p_ptr->y - MAX_RANGE), 0);
2821 max_hgt = MIN((p_ptr->y + MAX_RANGE), cur_hgt - 1);
2822 min_wid = MAX((p_ptr->x - MAX_RANGE), 0);
2823 max_wid = MIN((p_ptr->x + MAX_RANGE), cur_wid - 1);
2825 else /* not targetting */
2828 min_hgt = panel_row_min;
2829 max_hgt = panel_row_max;
2830 min_wid = panel_col_min;
2831 max_wid = panel_col_max;
2834 /* Reset "temp" array */
2837 /* Scan the current panel */
2838 for (y = min_hgt; y <= max_hgt; y++)
2840 for (x = min_wid; x <= max_wid; x++)
2844 /* Require "interesting" contents */
2845 if (!target_set_accept(y, x)) continue;
2847 c_ptr = &cave[y][x];
2849 /* Require target_able monsters for "TARGET_KILL" */
2850 if ((mode & (TARGET_KILL)) && !target_able(c_ptr->m_idx)) continue;
2852 if ((mode & (TARGET_KILL)) && !target_pet && is_pet(&m_list[c_ptr->m_idx])) continue;
2854 /* Save the location */
2861 /* Set the sort hooks */
2862 if (mode & (TARGET_KILL))
2864 /* Target the nearest monster for shooting */
2865 ang_sort_comp = ang_sort_comp_distance;
2866 ang_sort_swap = ang_sort_swap_distance;
2870 /* Look important grids first in Look command */
2871 ang_sort_comp = ang_sort_comp_importance;
2872 ang_sort_swap = ang_sort_swap_distance;
2875 /* Sort the positions */
2876 ang_sort(temp_x, temp_y, temp_n);
2878 if (p_ptr->riding && target_pet && (temp_n > 1) && (mode & (TARGET_KILL)))
2883 temp_y[0] = temp_y[1];
2886 temp_x[0] = temp_x[1];
2891 void target_set_prepare_look(void){
2892 target_set_prepare(TARGET_LOOK);
2897 * Evaluate number of kill needed to gain level
2899 static void evaluate_monster_exp(char *buf, monster_type *m_ptr)
2901 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
2903 s32b exp_mon, exp_adv;
2904 u32b exp_mon_frac, exp_adv_frac;
2906 if ((p_ptr->lev >= PY_MAX_LEVEL) || (p_ptr->prace == RACE_ANDROID))
2911 else if (!ap_r_ptr->r_tkills || (m_ptr->mflag2 & MFLAG2_KAGE))
2921 /* The monster's experience point (assuming average monster speed) */
2922 exp_mon = ap_r_ptr->mexp * ap_r_ptr->level;
2924 s64b_div(&exp_mon, &exp_mon_frac, 0, (p_ptr->max_plv + 2));
2927 /* Total experience value for next level */
2928 exp_adv = player_exp[p_ptr->lev -1] * p_ptr->expfact;
2930 s64b_div(&exp_adv, &exp_adv_frac, 0, 100);
2932 /* Experience value need to get */
2933 s64b_sub(&exp_adv, &exp_adv_frac, p_ptr->exp, p_ptr->exp_frac);
2936 /* You need to kill at least one monster to get any experience */
2937 s64b_add(&exp_adv, &exp_adv_frac, exp_mon, exp_mon_frac);
2938 s64b_sub(&exp_adv, &exp_adv_frac, 0, 1);
2940 /* Extract number of monsters needed */
2941 s64b_div(&exp_adv, &exp_adv_frac, exp_mon, exp_mon_frac);
2943 /* If 999 or more monsters needed, only display "999". */
2944 num = MIN(999, exp_adv_frac);
2946 /* Display the number */
2947 sprintf(buf,"%03ld", (long int)num);
2951 bool show_gold_on_floor = FALSE;
2954 * Examine a grid, return a keypress.
2956 * The "mode" argument contains the "TARGET_LOOK" bit flag, which
2957 * indicates that the "space" key should scan through the contents
2958 * of the grid, instead of simply returning immediately. This lets
2959 * the "look" command get complete information, without making the
2960 * "target" command annoying.
2962 * The "info" argument contains the "commands" which should be shown
2963 * inside the "[xxx]" text. This string must never be empty, or grids
2964 * containing monsters will be displayed with an extra comma.
2966 * Note that if a monster is in the grid, we update both the monster
2967 * recall info and the health bar info to track that monster.
2969 * Eventually, we may allow multiple objects per grid, or objects
2970 * and terrain features in the same grid.
2972 * This function must handle blindness/hallucination.
2974 static char target_set_aux(POSITION y, POSITION x, BIT_FLAGS mode, cptr info)
2976 cave_type *c_ptr = &cave[y][x];
2977 OBJECT_IDX this_o_idx, next_o_idx = 0;
2978 cptr s1 = "", s2 = "", s3 = "", x_info = "";
2981 feature_type *f_ptr;
2982 char query = '\001';
2983 char out_val[MAX_NLEN+80];
2985 #ifdef ALLOW_EASY_FLOOR
2986 OBJECT_IDX floor_list[23];
2987 ITEM_NUMBER floor_num = 0;
2989 /* Scan all objects in the grid */
2992 floor_num = scan_floor(floor_list, y, x, 0x02);
2996 x_info = _("x物 ", "x,");
3000 #endif /* ALLOW_EASY_FLOOR */
3002 /* Hack -- under the player */
3003 if (player_bold(y, x))
3019 s1 = _("ターゲット:", "Target:");
3022 /* Hack -- hallucination */
3025 cptr name = _("何か奇妙な物", "something strange");
3027 /* Display a message */
3029 sprintf(out_val, "%s%s%s%s [%s]", s1, name, s2, s3, info);
3031 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, name, info);
3035 move_cursor_relative(y, x);
3038 /* Stop on everything but "return" */
3039 if ((query != '\r') && (query != '\n')) return query;
3041 /* Repeat forever */
3046 /* Actual monsters */
3047 if (c_ptr->m_idx && m_list[c_ptr->m_idx].ml)
3049 monster_type *m_ptr = &m_list[c_ptr->m_idx];
3050 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
3052 bool recall = FALSE;
3057 /* Get the monster name ("a kobold") */
3058 monster_desc(m_name, m_ptr, MD_INDEF_VISIBLE);
3060 /* Hack -- track this monster race */
3061 monster_race_track(m_ptr->ap_r_idx);
3063 /* Hack -- health bar for this monster */
3064 health_track(c_ptr->m_idx);
3066 /* Hack -- handle stuff */
3080 /* Recall on screen */
3081 screen_roff(m_ptr->ap_r_idx, 0);
3083 /* Hack -- Complete the prompt (again) */
3084 Term_addstr(-1, TERM_WHITE, format(_(" [r思 %s%s]", " [r,%s%s]"), x_info, info));
3092 /* Normal commands */
3093 if (query != 'r') break;
3098 /* Cleare recall text and repeat */
3104 /* Describe, and prompt for recall */
3105 evaluate_monster_exp(acount, m_ptr);
3108 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);
3110 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);
3116 move_cursor_relative(y, x);
3121 /* Normal commands */
3122 if (query != 'r') break;
3128 /* Always stop at "normal" keys */
3129 if ((query != '\r') && (query != '\n') && (query != ' ') && (query != 'x')) return query;
3131 /* Sometimes stop at "space" key */
3132 if ((query == ' ') && !(mode & (TARGET_LOOK))) return query;
3134 /* Change the intro */
3135 s1 = _("それは", "It is ");
3137 /* Hack -- take account of gender */
3138 if (ap_r_ptr->flags1 & (RF1_FEMALE)) s1 = _("彼女は", "She is ");
3139 else if (ap_r_ptr->flags1 & (RF1_MALE)) s1 = _("彼は", "He is ");
3141 /* Use a preposition */
3150 /* Scan all objects being carried */
3151 for (this_o_idx = m_ptr->hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
3153 char o_name[MAX_NLEN];
3157 /* Acquire object */
3158 o_ptr = &o_list[this_o_idx];
3160 /* Acquire next object */
3161 next_o_idx = o_ptr->next_o_idx;
3163 /* Obtain an object description */
3164 object_desc(o_name, o_ptr, 0);
3166 /* Describe the object */
3168 sprintf(out_val, "%s%s%s%s[%s]", s1, o_name, s2, s3, info);
3170 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, o_name, info);
3174 move_cursor_relative(y, x);
3177 /* Always stop at "normal" keys */
3178 if ((query != '\r') && (query != '\n') && (query != ' ') && (query != 'x')) return query;
3180 /* Sometimes stop at "space" key */
3181 if ((query == ' ') && !(mode & (TARGET_LOOK))) return query;
3183 /* Change the intro */
3184 s2 = _("をまた", "also carrying ");
3187 /* Use a preposition */
3197 #ifdef ALLOW_EASY_FLOOR
3206 char o_name[MAX_NLEN];
3210 /* Acquire object */
3211 o_ptr = &o_list[floor_list[0]];
3213 /* Describe the object */
3214 object_desc(o_name, o_ptr, 0);
3217 sprintf(out_val, "%s%s%s%s[%s]",
3218 s1, o_name, s2, s3, info);
3220 sprintf(out_val, "%s%s%s%s [%s]",
3221 s1, s2, s3, o_name, info);
3225 move_cursor_relative(y, x);
3234 /* Provide one cushion before item listing */
3237 /* Display rough information about items */
3239 sprintf(out_val, "%s %d個のアイテム%s%s ['x'で一覧, %s]",
3240 s1, (int)floor_num, s2, s3, info);
3242 sprintf(out_val, "%s%s%sa pile of %d items [x,%s]",
3243 s1, s2, s3, (int)floor_num, info);
3247 move_cursor_relative(y, x);
3252 /* No request for listing */
3253 if (query != 'x' && query != ' ') return query;
3257 /** Display list of items **/
3259 /* Continue scrolling list if requested */
3269 show_gold_on_floor = TRUE;
3270 (void)show_floor(0, y, x, &min_width);
3271 show_gold_on_floor = FALSE;
3275 sprintf(out_val, "%s %d個のアイテム%s%s [Enterで次へ, %s]",
3276 s1, (int)floor_num, s2, s3, info);
3278 sprintf(out_val, "%s%s%sa pile of %d items [Enter,%s]",
3279 s1, s2, s3, (int)floor_num, info);
3290 /* Exit unless 'Enter' */
3291 if (query != '\n' && query != '\r')
3296 /* Get the object being moved. */
3297 o_idx = c_ptr->o_idx;
3299 /* Only rotate a pile of two or more objects. */
3300 if (!(o_idx && o_list[o_idx].next_o_idx)) continue;
3302 /* Remove the first object from the list. */
3303 excise_object_idx(o_idx);
3305 /* Find end of the list. */
3307 while (o_list[i].next_o_idx)
3308 i = o_list[i].next_o_idx;
3310 /* Add after the last object. */
3311 o_list[i].next_o_idx = o_idx;
3313 /* Loop and re-display the list */
3319 #endif /* ALLOW_EASY_FLOOR */
3322 /* Scan all objects in the grid */
3323 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
3327 /* Acquire object */
3328 o_ptr = &o_list[this_o_idx];
3330 /* Acquire next object */
3331 next_o_idx = o_ptr->next_o_idx;
3334 if (o_ptr->marked & OM_FOUND)
3336 char o_name[MAX_NLEN];
3341 /* Obtain an object description */
3342 object_desc(o_name, o_ptr, 0);
3344 /* Describe the object */
3346 sprintf(out_val, "%s%s%s%s[%s]", s1, o_name, s2, s3, info);
3348 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, o_name, info);
3352 move_cursor_relative(y, x);
3355 /* Always stop at "normal" keys */
3356 if ((query != '\r') && (query != '\n') && (query != ' ') && (query != 'x')) return query;
3358 /* Sometimes stop at "space" key */
3359 if ((query == ' ') && !(mode & TARGET_LOOK)) return query;
3361 /* Change the intro */
3362 s1 = _("それは", "It is ");
3365 if (o_ptr->number != 1) s1 = _("それらは", "They are ");
3379 /* Feature code (applying "mimic" field) */
3380 feat = get_feat_mimic(c_ptr);
3382 /* Require knowledge about grid, or ability to see grid */
3383 if (!(c_ptr->info & CAVE_MARK) && !player_can_see_bold(y, x))
3385 /* Forget feature */
3389 f_ptr = &f_info[feat];
3391 /* Terrain feature if needed */
3392 if (boring || have_flag(f_ptr->flags, FF_REMEMBER))
3396 /* Hack -- special handling for quest entrances */
3397 if (have_flag(f_ptr->flags, FF_QUEST_ENTER))
3399 /* Set the quest number temporary */
3400 IDX old_quest = p_ptr->inside_quest;
3403 /* Clear the text */
3404 for (j = 0; j < 10; j++) quest_text[j][0] = '\0';
3405 quest_text_line = 0;
3407 p_ptr->inside_quest = c_ptr->special;
3409 /* Get the quest text */
3410 init_flags = INIT_NAME_ONLY;
3412 process_dungeon_file("q_info.txt", 0, 0, 0, 0);
3414 name = format(_("クエスト「%s」(%d階相当)", "the entrance to the quest '%s'(level %d)"),
3415 quest[c_ptr->special].name, quest[c_ptr->special].level);
3417 /* Reset the old quest number */
3418 p_ptr->inside_quest = old_quest;
3421 /* Hack -- special handling for building doors */
3422 else if (have_flag(f_ptr->flags, FF_BLDG) && !p_ptr->inside_arena)
3424 name = building[f_ptr->subtype].name;
3426 else if (have_flag(f_ptr->flags, FF_ENTRANCE))
3428 name = format(_("%s(%d階相当)", "%s(level %d)"), d_text + d_info[c_ptr->special].text, d_info[c_ptr->special].mindepth);
3430 else if (have_flag(f_ptr->flags, FF_TOWN))
3432 name = town[c_ptr->special].name;
3434 else if (p_ptr->wild_mode && (feat == feat_floor))
3436 name = _("道", "road");
3440 name = f_name + f_ptr->name;
3446 ((!have_flag(f_ptr->flags, FF_MOVE) && !have_flag(f_ptr->flags, FF_CAN_FLY)) ||
3447 (!have_flag(f_ptr->flags, FF_LOS) && !have_flag(f_ptr->flags, FF_TREE)) ||
3448 have_flag(f_ptr->flags, FF_TOWN)))
3450 s2 = _("の中", "in ");
3453 /* Hack -- special introduction for store & building doors -KMW- */
3454 if (have_flag(f_ptr->flags, FF_STORE) ||
3455 have_flag(f_ptr->flags, FF_QUEST_ENTER) ||
3456 (have_flag(f_ptr->flags, FF_BLDG) && !p_ptr->inside_arena) ||
3457 have_flag(f_ptr->flags, FF_ENTRANCE))
3466 else if (have_flag(f_ptr->flags, FF_FLOOR) ||
3467 have_flag(f_ptr->flags, FF_TOWN) ||
3468 have_flag(f_ptr->flags, FF_SHALLOW) ||
3469 have_flag(f_ptr->flags, FF_DEEP))
3475 /* Pick proper indefinite article */
3476 s3 = (is_a_vowel(name[0])) ? "an " : "a ";
3480 /* Display a message */
3484 if (c_ptr->mimic) sprintf(f_idx_str, "%d/%d", c_ptr->feat, c_ptr->mimic);
3485 else sprintf(f_idx_str, "%d", c_ptr->feat);
3487 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]);
3489 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);
3494 sprintf(out_val, "%s%s%s%s[%s]", s1, name, s2, s3, info);
3496 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, name, info);
3500 move_cursor_relative(y, x);
3503 /* Always stop at "normal" keys */
3504 if ((query != '\r') && (query != '\n') && (query != ' ')) return query;
3507 /* Stop on everything but "return" */
3508 if ((query != '\r') && (query != '\n')) return query;
3510 /* Repeat forever */
3516 * Handle "target" and "look".
3518 * Note that this code can be called from "get_aim_dir()".
3520 * All locations must be on the current panel. Consider the use of
3521 * "panel_bounds()" to allow "off-panel" targets, perhaps by using
3522 * some form of "scrolling" the map around the cursor.
3523 * That is, consider the possibility of "auto-scrolling" the screen
3524 * while the cursor moves around. This may require changes in the
3525 * "update_mon()" code to allow "visibility" even if off panel, and
3526 * may require dynamic recalculation of the "temp" grid set.
3528 * Hack -- targeting/observing an "outer border grid" may induce
3529 * problems, so this is not currently allowed.
3531 * The player can use the direction keys to move among "interesting"
3532 * grids in a heuristic manner, or the "space", "+", and "-" keys to
3533 * move through the "interesting" grids in a sequential manner, or
3534 * can enter "location" mode, and use the direction keys to move one
3535 * grid at a time in any direction. The "t" (set target) command will
3536 * only target a monster (as opposed to a location) if the monster is
3537 * target_able and the "interesting" mode is being used.
3539 * The current grid is described using the "look" method above, and
3540 * a new command may be entered at any time, but note that if the
3541 * "TARGET_LOOK" bit flag is set (or if we are in "location" mode,
3542 * where "space" has no obvious meaning) then "space" will scan
3543 * through the description of the current grid until done, instead
3544 * of immediately jumping to the next "interesting" grid. This
3545 * allows the "target" command to retain its old semantics.
3547 * The "*", "+", and "-" keys may always be used to jump immediately
3548 * to the next (or previous) interesting grid, in the proper mode.
3550 * The "return" key may always be used to scan through a complete
3551 * grid description (forever).
3553 * This command will cancel any old target, even if used from
3554 * inside the "look" command.
3556 bool target_set(BIT_FLAGS mode)
3559 POSITION y = p_ptr->y;
3560 POSITION x = p_ptr->x;
3573 get_screen_size(&wid, &hgt);
3579 /* Cancel tracking */
3580 /* health_track(0); */
3582 if (rogue_like_commands)
3591 /* Prepare the "temp" array */
3592 target_set_prepare(mode);
3594 /* Start near the player */
3600 /* Interesting grids */
3607 change_panel_xy(y, x);
3609 if (!(mode & TARGET_LOOK)) prt_path(y, x);
3612 c_ptr = &cave[y][x];
3615 if (target_able(c_ptr->m_idx))
3617 strcpy(info, _("q止 t決 p自 o現 +次 -前", "q,t,p,o,+,-,<dir>"));
3620 /* Dis-allow target */
3623 strcpy(info, _("q止 p自 o現 +次 -前", "q,p,o,+,-,<dir>"));
3629 sprintf(cheatinfo, " LOS:%d, PROJECTABLE:%d",
3630 los(p_ptr->y, p_ptr->x, y, x),
3631 projectable(p_ptr->y, p_ptr->x, y, x));
3632 strcat(info, cheatinfo);
3635 /* Describe and Prompt */
3637 query = target_set_aux(y, x, mode, info);
3641 /* Cancel tracking */
3642 /* health_track(0); */
3644 /* Assume no "direction" */
3649 if (query == '\r') query = 't';
3667 if (target_able(c_ptr->m_idx))
3669 health_track(c_ptr->m_idx);
3670 target_who = c_ptr->m_idx;
3689 if (!expand_list) done = TRUE;
3699 if (!expand_list) done = TRUE;
3706 /* Recenter the map around the player */
3709 p_ptr->update |= (PU_MONSTERS);
3712 p_ptr->redraw |= (PR_MAP);
3714 p_ptr->window |= (PW_OVERHEAD);
3719 /* Recalculate interesting grids */
3720 target_set_prepare(mode);
3739 if(query == same_key)
3744 if (!expand_list) done = TRUE;
3749 /* Extract the action (if any) */
3750 d = get_keymap_dir(query);
3757 /* Hack -- move around */
3760 /* Modified to scroll to monster */
3761 POSITION y2 = panel_row_min;
3762 POSITION x2 = panel_col_min;
3764 /* Find a new monster */
3765 i = target_pick(temp_y[m], temp_x[m], ddy[d], ddx[d]);
3767 /* Request to target past last interesting grid */
3768 while (flag && (i < 0))
3770 /* Note the change */
3771 if (change_panel(ddy[d], ddx[d]))
3776 /* Recalculate interesting grids */
3777 target_set_prepare(mode);
3779 /* Look at interesting grids */
3782 /* Find a new monster */
3783 i = target_pick(v, u, ddy[d], ddx[d]);
3789 /* Nothing interesting */
3795 /* Restore previous position */
3798 panel_bounds_center();
3800 p_ptr->update |= (PU_MONSTERS);
3803 p_ptr->redraw |= (PR_MAP);
3805 p_ptr->window |= (PW_OVERHEAD);
3810 /* Recalculate interesting grids */
3811 target_set_prepare(mode);
3813 /* Look at boring grids */
3820 /* Do not move horizontally if unnecessary */
3821 if (((x < panel_col_min + wid / 2) && (dx > 0)) ||
3822 ((x > panel_col_min + wid / 2) && (dx < 0)))
3827 /* Do not move vertically if unnecessary */
3828 if (((y < panel_row_min + hgt / 2) && (dy > 0)) ||
3829 ((y > panel_row_min + hgt / 2) && (dy < 0)))
3834 /* Apply the motion */
3835 if ((y >= panel_row_min+hgt) || (y < panel_row_min) ||
3836 (x >= panel_col_min+wid) || (x < panel_col_min))
3838 if (change_panel(dy, dx)) target_set_prepare(mode);
3841 /* Slide into legality */
3842 if (x >= cur_wid-1) x = cur_wid - 2;
3843 else if (x <= 0) x = 1;
3845 /* Slide into legality */
3846 if (y >= cur_hgt-1) y = cur_hgt- 2;
3847 else if (y <= 0) y = 1;
3856 /* Arbitrary grids */
3859 bool move_fast = FALSE;
3861 if (!(mode & TARGET_LOOK)) prt_path(y, x);
3864 c_ptr = &cave[y][x];
3866 /* Default prompt */
3867 strcpy(info, _("q止 t決 p自 m近 +次 -前", "q,t,p,m,+,-,<dir>"));
3872 sprintf(cheatinfo, " LOS:%d, PROJECTABLE:%d",
3873 los(p_ptr->y, p_ptr->x, y, x),
3874 projectable(p_ptr->y, p_ptr->x, y, x));
3875 strcat(info, cheatinfo);
3878 /* Describe and Prompt (enable "TARGET_LOOK") */
3879 while ((query = target_set_aux(y, x, mode | TARGET_LOOK, info)) == 0);
3881 /* Cancel tracking */
3882 /* health_track(0); */
3884 /* Assume no direction */
3889 if (query == '\r') query = 't';
3892 /* Analyze the keypress */
3916 /* Recenter the map around the player */
3919 p_ptr->update |= (PU_MONSTERS);
3922 p_ptr->redraw |= (PR_MAP);
3924 p_ptr->window |= (PW_OVERHEAD);
3929 /* Recalculate interesting grids */
3930 target_set_prepare(mode);
3952 /* Pick a nearby monster */
3953 for (i = 0; i < temp_n; i++)
3955 t = distance(y, x, temp_y[i], temp_x[i]);
3965 /* Nothing interesting */
3966 if (bd == 999) flag = FALSE;
3973 /* Extract the action (if any) */
3974 d = get_keymap_dir(query);
3976 /* XTRA HACK MOVEFAST */
3977 if (isupper(query)) move_fast = TRUE;
3984 /* Handle "direction" */
3990 /* XTRA HACK MOVEFAST */
3993 int mag = MIN(wid / 2, hgt / 2);
4003 /* Do not move horizontally if unnecessary */
4004 if (((x < panel_col_min + wid / 2) && (dx > 0)) ||
4005 ((x > panel_col_min + wid / 2) && (dx < 0)))
4010 /* Do not move vertically if unnecessary */
4011 if (((y < panel_row_min + hgt / 2) && (dy > 0)) ||
4012 ((y > panel_row_min + hgt / 2) && (dy < 0)))
4017 /* Apply the motion */
4018 if ((y >= panel_row_min + hgt) || (y < panel_row_min) ||
4019 (x >= panel_col_min + wid) || (x < panel_col_min))
4021 if (change_panel(dy, dx)) target_set_prepare(mode);
4024 /* Slide into legality */
4025 if (x >= cur_wid-1) x = cur_wid - 2;
4026 else if (x <= 0) x = 1;
4028 /* Slide into legality */
4029 if (y >= cur_hgt-1) y = cur_hgt- 2;
4030 else if (y <= 0) y = 1;
4038 /* Clear the top line */
4041 /* Recenter the map around the player */
4044 p_ptr->update |= (PU_MONSTERS);
4047 p_ptr->redraw |= (PR_MAP);
4049 p_ptr->window |= (PW_OVERHEAD);
4054 /* Failure to set target */
4055 if (!target_who) return (FALSE);
4063 * Get an "aiming direction" from the user.
4065 * The "dir" is loaded with 1,2,3,4,6,7,8,9 for "actual direction", and
4066 * "0" for "current target", and "-1" for "entry aborted".
4068 * Note that "Force Target", if set, will pre-empt user interaction,
4069 * if there is a usable target already set.
4071 * Note that confusion over-rides any (explicit?) user choice.
4073 bool get_aim_dir(DIRECTION *dp)
4083 /* Global direction */
4086 /* Hack -- auto-target if requested */
4087 if (use_old_target && target_okay()) dir = 5;
4089 #ifdef ALLOW_REPEAT /* TNB */
4091 if (repeat_pull(&code))
4096 if (!(code == 5 && !target_okay()))
4098 /* return (TRUE); */
4099 dir = (DIRECTION)code;
4102 *dp = (DIRECTION)code;
4104 #endif /* ALLOW_REPEAT -- TNB */
4106 /* Ask until satisfied */
4109 /* Choose a prompt */
4112 p = _("方向 ('*'でターゲット選択, ESCで中断)? ", "Direction ('*' to choose a target, Escape to cancel)? ");
4116 p = _("方向 ('5'でターゲットへ, '*'でターゲット再選択, ESCで中断)? ", "Direction ('5' for target, '*' to re-target, Escape to cancel)? ");
4119 /* Get a command (or Cancel) */
4120 if (!get_com(p, &command, TRUE)) break;
4124 if (command == '\r') command = 't';
4127 /* Convert various keys to "standard" keys */
4130 /* Use current target */
4141 /* Set new target */
4146 if (target_set(TARGET_KILL)) dir = 5;
4152 /* Extract the action (if any) */
4153 dir = get_keymap_dir(command);
4159 /* Verify requested targets */
4160 if ((dir == 5) && !target_okay()) dir = 0;
4169 project_length = 0; /* reset to default */
4173 /* Save the direction */
4176 /* Check for confusion */
4177 if (p_ptr->confused)
4179 /* Random direction */
4180 dir = ddd[randint0(8)];
4183 /* Notice confusion */
4184 if (command_dir != dir)
4187 msg_print(_("あなたは混乱している。", "You are confused."));
4190 /* Save direction */
4193 #ifdef ALLOW_REPEAT /* TNB */
4195 /* repeat_push(dir); */
4196 repeat_push((COMMAND_CODE)command_dir);
4198 #endif /* ALLOW_REPEAT -- TNB */
4200 /* A "valid" direction was entered */
4207 * Request a "movement" direction (1,2,3,4,6,7,8,9) from the user,
4208 * and place it into "command_dir", unless we already have one.
4210 * This function should be used for all "repeatable" commands, such as
4211 * run, walk, open, close, bash, disarm, spike, tunnel, etc, as well
4212 * as all commands which must reference a grid adjacent to the player,
4213 * and which may not reference the grid under the player. Note that,
4214 * for example, it is no longer possible to "disarm" or "open" chests
4215 * in the same grid as the player.
4217 * Direction "5" is illegal and will (cleanly) abort the command.
4219 * This function tracks and uses the "global direction", and uses
4220 * that as the "desired direction", to which "confusion" is applied.
4222 bool get_rep_dir(DIRECTION *dp, bool under)
4231 /* Global direction */
4234 #ifdef ALLOW_REPEAT /* TNB */
4236 if (repeat_pull(&code))
4238 dir = (DIRECTION)code;
4239 /* return (TRUE); */
4241 *dp = (DIRECTION)code;
4243 #endif /* ALLOW_REPEAT -- TNB */
4247 prompt = _("方向 ('.'足元, ESCで中断)? ", "Direction ('.' at feet, Escape to cancel)? ");
4251 prompt = _("方向 (ESCで中断)? ", "Direction (Escape to cancel)? ");
4254 /* Get a direction */
4259 /* Get a command (or Cancel) */
4260 if (!get_com(prompt, &ch, TRUE)) break;
4263 if ((under) && ((ch == '5') || (ch == '-') || (ch == '.')))
4269 /* Look up the direction */
4270 dir = get_keymap_dir(ch);
4276 /* Prevent weirdness */
4277 if ((dir == 5) && (!under)) dir = 0;
4280 if (!dir) return (FALSE);
4282 /* Save desired direction */
4285 /* Apply "confusion" */
4286 if (p_ptr->confused)
4288 /* Standard confusion */
4289 if (randint0(100) < 75)
4291 /* Random direction */
4292 dir = ddd[randint0(8)];
4295 else if (p_ptr->riding)
4297 monster_type *m_ptr = &m_list[p_ptr->riding];
4298 monster_race *r_ptr = &r_info[m_ptr->r_idx];
4300 if (MON_CONFUSED(m_ptr))
4302 /* Standard confusion */
4303 if (randint0(100) < 75)
4305 /* Random direction */
4306 dir = ddd[randint0(8)];
4309 else if ((r_ptr->flags1 & RF1_RAND_50) && (r_ptr->flags1 & RF1_RAND_25) && (randint0(100) < 50))
4311 /* Random direction */
4312 dir = ddd[randint0(8)];
4314 else if ((r_ptr->flags1 & RF1_RAND_50) && (randint0(100) < 25))
4316 /* Random direction */
4317 dir = ddd[randint0(8)];
4321 /* Notice confusion */
4322 if (command_dir != dir)
4324 if (p_ptr->confused)
4327 msg_print(_("あなたは混乱している。", "You are confused."));
4332 monster_type *m_ptr = &m_list[p_ptr->riding];
4334 monster_desc(m_name, m_ptr, 0);
4335 if (MON_CONFUSED(m_ptr))
4337 msg_format(_("%sは混乱している。", "%^s is confusing."), m_name);
4341 msg_format(_("%sは思い通りに動いてくれない。", "You cannot control %s."), m_name);
4346 /* Save direction */
4349 #ifdef ALLOW_REPEAT /* TNB */
4351 /* repeat_push(dir); */
4352 repeat_push((COMMAND_CODE)command_dir);
4354 #endif /* ALLOW_REPEAT -- TNB */
4361 bool get_rep_dir2(DIRECTION *dp)
4369 /* Global direction */
4372 #ifdef ALLOW_REPEAT /* TNB */
4374 if (repeat_pull(&code))
4376 dir = (DIRECTION)code;
4377 /* return (TRUE); */
4379 *dp = (DIRECTION)code;
4381 #endif /* ALLOW_REPEAT -- TNB */
4383 /* Get a direction */
4388 /* Get a command (or Cancel) */
4389 if (!get_com(_("方向 (ESCで中断)? ", "Direction (Escape to cancel)? "), &ch, TRUE)) break;
4391 /* Look up the direction */
4392 dir = get_keymap_dir(ch);
4397 /* Prevent weirdness */
4398 if (dir == 5) dir = 0;
4401 if (!dir) return (FALSE);
4403 /* Save desired direction */
4406 /* Apply "confusion" */
4407 if (p_ptr->confused)
4409 /* Standard confusion */
4410 if (randint0(100) < 75)
4412 /* Random direction */
4413 dir = ddd[randint0(8)];
4417 /* Notice confusion */
4418 if (command_dir != dir)
4421 msg_print(_("あなたは混乱している。", "You are confused."));
4424 /* Save direction */
4427 #ifdef ALLOW_REPEAT /* TNB */
4429 /* repeat_push(dir); */
4430 repeat_push((COMMAND_CODE)command_dir);
4432 #endif /* ALLOW_REPEAT -- TNB */
4438 void gain_level_reward(int chosen_reward)
4442 char wrath_reason[32] = "";
4443 int nasty_chance = 6;
4444 OBJECT_TYPE_VALUE dummy = 0;
4445 OBJECT_SUBTYPE_VALUE dummy2 = 0;
4448 char o_name[MAX_NLEN];
4454 if (multi_rew) return;
4455 else multi_rew = TRUE;
4459 if (p_ptr->lev == 13) nasty_chance = 2;
4460 else if (!(p_ptr->lev % 13)) nasty_chance = 3;
4461 else if (!(p_ptr->lev % 14)) nasty_chance = 12;
4463 if (one_in_(nasty_chance))
4464 type = randint1(20); /* Allow the 'nasty' effects */
4466 type = randint1(15) + 5; /* Or disallow them */
4468 if (type < 1) type = 1;
4469 if (type > 20) type = 20;
4473 sprintf(wrath_reason, _("%sの怒り", "the Wrath of %s"), chaos_patrons[p_ptr->chaos_patron]);
4475 effect = chaos_rewards[p_ptr->chaos_patron][type];
4477 if (one_in_(6) && !chosen_reward)
4479 msg_format(_("%^sは褒美としてあなたを突然変異させた。", "%^s rewards you with a mutation!"), chaos_patrons[p_ptr->chaos_patron]);
4480 (void)gain_random_mutation(0);
4481 reward = _("変異した。", "mutation");
4485 switch (chosen_reward ? chosen_reward : effect)
4490 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4491 msg_print(_("「汝、新たなる姿を必要とせり!」", "'Thou needst a new form, mortal!'"));
4494 reward = _("変異した。", "polymorphing");
4499 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4500 msg_print(_("「汝は良く行いたり!続けよ!」", "'Well done, mortal! Lead on!'"));
4502 if (p_ptr->prace == RACE_ANDROID)
4504 msg_print(_("しかし何も起こらなかった。", "But, nothing happen."));
4506 else if (p_ptr->exp < PY_MAX_EXP)
4508 s32b ee = (p_ptr->exp / 2) + 10;
4509 if (ee > 100000L) ee = 100000L;
4510 msg_print(_("更に経験を積んだような気がする。", "You feel more experienced."));
4513 reward = _("経験値を得た", "experience");
4519 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4520 msg_print(_("「下僕よ、汝それに値せず。」", "'Thou didst not deserve that, slave.'"));
4522 if (p_ptr->prace == RACE_ANDROID)
4524 msg_print(_("しかし何も起こらなかった。", "But, nothing happen."));
4528 lose_exp(p_ptr->exp / 6);
4529 reward = _("経験値を失った。", "losing experience");
4535 msg_format("%sの声がささやいた:",
4536 chaos_patrons[p_ptr->chaos_patron]);
4538 msg_format("The voice of %s whispers:",
4539 chaos_patrons[p_ptr->chaos_patron]);
4542 msg_print(_("「我が与えし物を賢明に使うべし。」", "'Use my gift wisely.'"));
4544 acquirement(p_ptr->y, p_ptr->x, 1, FALSE, FALSE, FALSE);
4545 reward = _("上質なアイテムを手に入れた。", "a good item");
4550 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4551 msg_print(_("「我が与えし物を賢明に使うべし。」", "'Use my gift wisely.'"));
4553 acquirement(p_ptr->y, p_ptr->x, 1, TRUE, FALSE, FALSE);
4554 reward = _("高級品のアイテムを手に入れた。", "an excellent item");
4559 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4560 msg_print(_("「汝の行いは貴き剣に値せり。」", "'Thy deed hath earned thee a worthy blade.'"));
4562 /* Get local object */
4565 switch (randint1(p_ptr->lev))
4571 dummy2 = SV_MAIN_GAUCHE;
4580 dummy2 = SV_SMALL_SWORD;
4583 dummy2 = SV_BASILLARD;
4585 case 11: case 12: case 13:
4586 dummy2 = SV_SHORT_SWORD;
4592 dummy2 = SV_CUTLASS;
4595 dummy2 = SV_WAKIZASHI;
4598 dummy2 = SV_KHOPESH;
4604 dummy2 = SV_BROAD_SWORD;
4607 dummy2 = SV_LONG_SWORD;
4610 dummy2 = SV_SCIMITAR;
4613 dummy2 = SV_NINJATO;
4619 dummy2 = SV_BASTARD_SWORD;
4622 dummy2 = SV_GREAT_SCIMITAR;
4625 dummy2 = SV_CLAYMORE;
4628 dummy2 = SV_ESPADON;
4631 dummy2 = SV_TWO_HANDED_SWORD;
4634 dummy2 = SV_FLAMBERGE;
4637 dummy2 = SV_NO_DACHI;
4640 dummy2 = SV_EXECUTIONERS_SWORD;
4643 dummy2 = SV_ZWEIHANDER;
4646 dummy2 = SV_HAYABUSA;
4649 dummy2 = SV_BLADE_OF_CHAOS;
4652 object_prep(q_ptr, lookup_kind(dummy, dummy2));
4653 q_ptr->to_h = 3 + randint1(dun_level) % 10;
4654 q_ptr->to_d = 3 + randint1(dun_level) % 10;
4655 one_resistance(q_ptr);
4656 q_ptr->name2 = EGO_CHAOTIC;
4658 /* Drop it in the dungeon */
4659 (void)drop_near(q_ptr, -1, p_ptr->y, p_ptr->x);
4660 reward = _("(混沌)の武器を手に入れた。", "chaos weapon");
4665 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4666 msg_print(_("「汝の行いは貴き報いに値せり。」", "'Thy deed hath earned thee a worthy reward.'"));
4668 acquirement(p_ptr->y, p_ptr->x, randint1(2) + 1, FALSE, FALSE, FALSE);
4669 reward = _("上質なアイテムを手に入れた。", "good items");
4674 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4675 msg_print(_("「下僕よ、汝の献身への我が惜しみ無き報いを見るがよい。」", "'Behold, mortal, how generously I reward thy loyalty.'"));
4677 acquirement(p_ptr->y, p_ptr->x, randint1(2) + 1, TRUE, FALSE, FALSE);
4678 reward = _("高級品のアイテムを手に入れた。", "excellent items");
4683 msg_format("%sの声が轟き渡った:", chaos_patrons[p_ptr->chaos_patron]);
4685 msg_format("The voice of %s thunders:", chaos_patrons[p_ptr->chaos_patron]);
4688 msg_print(_("「下僕よ、汝傲慢なり。」", "'Thou art growing arrogant, mortal.'"));
4690 (void)activate_ty_curse(FALSE, &count);
4691 reward = _("禍々しい呪いをかけられた。", "cursing");
4696 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4697 msg_print(_("「我が下僕たちよ、かの傲慢なる者を倒すべし!」", "'My pets, destroy the arrogant mortal!'"));
4699 for (dummy = 0; dummy < randint1(5) + 1; dummy++)
4701 (void)summon_specific(0, p_ptr->y, p_ptr->x, dun_level, 0, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET));
4703 reward = _("モンスターを召喚された。", "summoning hostile monsters");
4709 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4710 msg_print(_("「汝、より強き敵を必要とせり!」", "'Thou needst worthier opponents!'"));
4712 activate_hi_summon(p_ptr->y, p_ptr->x, FALSE);
4713 reward = _("モンスターを召喚された。", "summoning many hostile monsters");
4719 msg_format("%sの声が響き渡った:",
4720 chaos_patrons[p_ptr->chaos_patron]);
4722 msg_format("The voice of %s booms out:",
4723 chaos_patrons[p_ptr->chaos_patron]);
4726 msg_print(_("「死と破壊こそ我が喜びなり!」", "'Death and destruction! This pleaseth me!'"));
4729 reward = _("カオスの力が渦巻いた。", "calling chaos");
4735 msg_format("%sの声が鳴り響いた:",
4736 chaos_patrons[p_ptr->chaos_patron]);
4738 msg_format("The voice of %s rings out:",
4739 chaos_patrons[p_ptr->chaos_patron]);
4742 msg_print(_("「留まるのだ、下僕よ。余が汝の肉体を鍛えん。」", "'Stay, mortal, and let me mold thee.'"));
4744 if (one_in_(3) && !(chaos_stats[p_ptr->chaos_patron] < 0))
4745 do_inc_stat(chaos_stats[p_ptr->chaos_patron]);
4747 do_inc_stat(randint0(6));
4748 reward = _("能力値が上がった。", "increasing a stat");
4754 msg_format("%sの声が響き渡った:",
4755 chaos_patrons[p_ptr->chaos_patron]);
4757 msg_format("The voice of %s booms out:",
4758 chaos_patrons[p_ptr->chaos_patron]);
4761 msg_print(_("「下僕よ、余は汝に飽みたり。」", "'I grow tired of thee, mortal.'"));
4763 if (one_in_(3) && !(chaos_stats[p_ptr->chaos_patron] < 0))
4764 do_dec_stat(chaos_stats[p_ptr->chaos_patron]);
4766 (void)do_dec_stat(randint0(6));
4767 reward = _("能力値が下がった。", "decreasing a stat");
4774 msg_format("%sの声が轟き渡った:",
4775 chaos_patrons[p_ptr->chaos_patron]);
4777 msg_format("The voice of %s thunders:",
4778 chaos_patrons[p_ptr->chaos_patron]);
4781 msg_print(_("「汝、謙虚たることを学ぶべし!」", "'Thou needst a lesson in humility, mortal!'"));
4782 msg_print(_("あなたは以前より弱くなった!", "You feel less powerful!"));
4784 for (dummy = 0; dummy < 6; dummy++)
4786 (void)dec_stat(dummy, 10 + randint1(15), TRUE);
4788 reward = _("全能力値が下がった。", "decreasing all stats");
4793 msg_format(_("%sの力が触れるのを感じた。", "You feel the power of %s touch you."),
4794 chaos_patrons[p_ptr->chaos_patron]);
4796 reward = _("傷が変化した。", "polymorphing wounds");
4801 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4803 msg_print(_("「我がささやかなる賜物を受けとるがよい!」", "'Receive this modest gift from me!'"));
4805 for (dummy = 0; dummy < 6; dummy++)
4807 (void)do_inc_stat(dummy);
4809 reward = _("全能力値が上がった。", "increasing all stats");
4814 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4815 msg_print(_("「苦しむがよい、無能な愚か者よ!」", "'Suffer, pathetic fool!'"));
4817 fire_ball(GF_DISINTEGRATE, 0, p_ptr->lev * 4, 4);
4818 take_hit(DAMAGE_NOESCAPE, p_ptr->lev * 4, wrath_reason, -1);
4819 reward = _("分解の球が発生した。", "generating disintegration ball");
4824 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4825 (void)restore_level();
4826 (void)restore_all_status();
4827 (void)true_healing(5000);
4828 reward = _("体力が回復した。", "healing");
4833 if (!buki_motteruka(INVEN_RARM) && !buki_motteruka(INVEN_LARM)) break;
4834 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4835 msg_print(_("「汝、武器に頼ることなかれ。」", "'Thou reliest too much on thy weapon.'"));
4838 if (buki_motteruka(INVEN_LARM))
4841 if (buki_motteruka(INVEN_RARM) && one_in_(2)) dummy = INVEN_RARM;
4843 object_desc(o_name, &inventory[dummy], OD_NAME_ONLY);
4844 (void)curse_weapon(FALSE, dummy);
4845 reward = format(_("%sが破壊された。", "destroying %s"), o_name);
4850 if (!inventory[INVEN_BODY].k_idx) break;
4851 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4852 msg_print(_("「汝、防具に頼ることなかれ。」", "'Thou reliest too much on thine equipment.'"));
4854 object_desc(o_name, &inventory[INVEN_BODY], OD_NAME_ONLY);
4855 (void)curse_armor();
4856 reward = format(_("%sが破壊された。", "destroying %s"), o_name);
4860 msg_format(_("%sの声がささやいた:", "The voice of %s whispers:"), chaos_patrons[p_ptr->chaos_patron]);
4861 msg_print(_("「我を怒りしめた罪を償うべし。」", "'Now thou shalt pay for annoying me.'"));
4863 switch (randint1(4))
4866 (void)activate_ty_curse(FALSE, &count);
4867 reward = _("禍々しい呪いをかけられた。", "cursing");
4870 activate_hi_summon(p_ptr->y, p_ptr->x, FALSE);
4871 reward = _("モンスターを召喚された。", "summoning hostile monsters");
4876 if (!buki_motteruka(INVEN_RARM) && !buki_motteruka(INVEN_LARM)) break;
4878 if (buki_motteruka(INVEN_LARM))
4881 if (buki_motteruka(INVEN_RARM) && one_in_(2)) dummy = INVEN_RARM;
4883 object_desc(o_name, &inventory[dummy], OD_NAME_ONLY);
4884 (void)curse_weapon(FALSE, dummy);
4885 reward = format(_("%sが破壊された。", "destroying %s"), o_name);
4889 if (!inventory[INVEN_BODY].k_idx) break;
4890 object_desc(o_name, &inventory[INVEN_BODY], OD_NAME_ONLY);
4891 (void)curse_armor();
4892 reward = format(_("%sが破壊された。", "destroying %s"), o_name);
4896 for (dummy = 0; dummy < 6; dummy++)
4898 (void)dec_stat(dummy, 10 + randint1(15), TRUE);
4900 reward = _("全能力値が下がった。", "decreasing all stats");
4907 msg_format(_("%sの声が轟き渡った:", "The voice of %s thunders:"), chaos_patrons[p_ptr->chaos_patron]);
4908 msg_print(_("「死ぬがよい、下僕よ!」", "'Die, mortal!'"));
4910 take_hit(DAMAGE_LOSELIFE, p_ptr->lev * 4, wrath_reason, -1);
4911 for (dummy = 0; dummy < 6; dummy++)
4913 (void)dec_stat(dummy, 10 + randint1(15), FALSE);
4915 activate_hi_summon(p_ptr->y, p_ptr->x, FALSE);
4916 (void)activate_ty_curse(FALSE, &count);
4921 if (buki_motteruka(INVEN_RARM))
4924 if (buki_motteruka(INVEN_LARM) && one_in_(2)) dummy = INVEN_LARM;
4926 else if (buki_motteruka(INVEN_LARM)) dummy = INVEN_LARM;
4928 if (dummy) (void)curse_weapon(FALSE, dummy);
4930 if (one_in_(2)) (void)curse_armor();
4935 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4936 msg_print(_("「死と破壊こそ我が喜びなり!」", "'Death and destruction! This pleaseth me!'"));
4938 (void)destroy_area(p_ptr->y, p_ptr->x, 25, FALSE);
4939 reward = _("ダンジョンが*破壊*された。", "*destruct*ing dungeon");
4944 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4945 msg_print(_("「我、汝の敵を抹殺せん!」", "'Let me relieve thee of thine oppressors!'"));
4946 (void)symbol_genocide(0, FALSE);
4947 reward = _("モンスターが抹殺された。", "genociding monsters");
4952 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4953 msg_print(_("「我、汝の敵を抹殺せん!」", "'Let me relieve thee of thine oppressors!'"));
4955 (void)mass_genocide(0, FALSE);
4956 reward = _("モンスターが抹殺された。", "genociding nearby monsters");
4961 msg_format(_("%sの力が敵を攻撃するのを感じた!", "You can feel the power of %s assault your enemies!"), chaos_patrons[p_ptr->chaos_patron]);
4962 (void)dispel_monsters(p_ptr->lev * 4);
4967 msg_format(_("%sはあなたを無視した。", "%s ignores you."), chaos_patrons[p_ptr->chaos_patron]);
4972 msg_format(_("%sは褒美として悪魔の使いをよこした!", "%s rewards you with a demonic servant!"),chaos_patrons[p_ptr->chaos_patron]);
4974 if (!summon_specific(-1, p_ptr->y, p_ptr->x, dun_level, SUMMON_DEMON, PM_FORCE_PET))
4975 msg_print(_("何も現れなかった...", "Nobody ever turns up..."));
4977 reward = _("悪魔がペットになった。", "a demonic servant");
4982 msg_format(_("%sは褒美として使いをよこした!", "%s rewards you with a servant!"),chaos_patrons[p_ptr->chaos_patron]);
4984 if (!summon_specific(-1, p_ptr->y, p_ptr->x, dun_level, 0, PM_FORCE_PET))
4985 msg_print(_("何も現れなかった...", "Nobody ever turns up..."));
4987 reward = _("モンスターがペットになった。", "a servant");
4992 msg_format(_("%sは褒美としてアンデッドの使いをよこした。", "%s rewards you with an undead servant!"),chaos_patrons[p_ptr->chaos_patron]);
4994 if (!summon_specific(-1, p_ptr->y, p_ptr->x, dun_level, SUMMON_UNDEAD, PM_FORCE_PET))
4995 msg_print(_("何も現れなかった...", "Nobody ever turns up..."));
4997 reward = _("アンデッドがペットになった。", "an undead servant");
5002 msg_format(_("%sの声がどもった:", "The voice of %s stammers:"),
5004 chaos_patrons[p_ptr->chaos_patron]);
5005 msg_format(_("「あー、あー、答えは %d/%d。質問は何?」", "'Uh... uh... the answer's %d/%d, what's the question?'"), type, effect);
5011 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, format(_("パトロンの報酬で%s", "The patron rewards you with %s."), reward));
5017 * XAngband: determine if a given location is "interesting"
5018 * based on target_set_accept function.
5020 static bool tgt_pt_accept(POSITION y, POSITION x)
5025 if (!(in_bounds(y, x))) return (FALSE);
5027 /* Player grid is always interesting */
5028 if ((y == p_ptr->y) && (x == p_ptr->x)) return (TRUE);
5030 /* Handle hallucination */
5031 if (p_ptr->image) return (FALSE);
5033 /* Examine the grid */
5034 c_ptr = &cave[y][x];
5036 /* Interesting memorized features */
5037 if (c_ptr->info & (CAVE_MARK))
5040 if (cave_have_flag_grid(c_ptr, FF_LESS)) return (TRUE);
5041 if (cave_have_flag_grid(c_ptr, FF_MORE)) return (TRUE);
5043 /* Notice quest features */
5044 if (cave_have_flag_grid(c_ptr, FF_QUEST_ENTER)) return (TRUE);
5045 if (cave_have_flag_grid(c_ptr, FF_QUEST_EXIT)) return (TRUE);
5053 * XAngband: Prepare the "temp" array for "tget_pt"
5054 * based on target_set_prepare funciton.
5056 static void tgt_pt_prepare(void)
5060 /* Reset "temp" array */
5063 if (!expand_list) return;
5065 /* Scan the current panel */
5066 for (y = 1; y < cur_hgt; y++)
5068 for (x = 1; x < cur_wid; x++)
5070 /* Require "interesting" contents */
5071 if (!tgt_pt_accept(y, x)) continue;
5073 /* Save the location */
5080 /* Target the nearest monster for shooting */
5081 ang_sort_comp = ang_sort_comp_distance;
5082 ang_sort_swap = ang_sort_swap_distance;
5084 /* Sort the positions */
5085 ang_sort(temp_x, temp_y, temp_n);
5089 * old -- from PsiAngband.
5091 bool tgt_pt(POSITION *x_ptr, POSITION *y_ptr)
5096 bool success = FALSE;
5101 get_screen_size(&wid, &hgt);
5111 msg_print(_("場所を選んでスペースキーを押して下さい。", "Select a point and press space."));
5112 msg_flag = FALSE; /* prevents "-more-" message. */
5114 while ((ch != ESCAPE) && !success)
5116 bool move_fast = FALSE;
5118 move_cursor_relative(y, x);
5130 if (player_bold(y, x)) ch = 0;
5133 else success = TRUE;
5137 /* XAngband: Move cursor to stairs */
5140 if (expand_list && temp_n)
5143 int cx = (panel_col_min + panel_col_max) / 2;
5144 int cy = (panel_row_min + panel_row_max) / 2;
5148 /* Skip stairs which have defferent distance */
5149 for (; n < temp_n; ++ n)
5151 cave_type *c_ptr = &cave[temp_y[n]][temp_x[n]];
5153 if (cave_have_flag_grid(c_ptr, FF_STAIRS) &&
5154 cave_have_flag_grid(c_ptr, ch == '>' ? FF_MORE : FF_LESS))
5161 if (n == temp_n) /* Loop out taget list */
5166 verify_panel(); /* Move cursor to player */
5168 p_ptr->update |= (PU_MONSTERS);
5171 p_ptr->redraw |= (PR_MAP);
5173 p_ptr->window |= (PW_OVERHEAD);
5178 else /* move cursor to next stair and change panel */
5183 dy = 2 * (y - cy) / hgt;
5184 dx = 2 * (x - cx) / wid;
5185 if (dy || dx) change_panel(dy, dx);
5191 /* Look up the direction */
5192 d = get_keymap_dir(ch);
5194 /* XTRA HACK MOVEFAST */
5195 if (isupper(ch)) move_fast = TRUE;
5197 /* Handle "direction" */
5203 /* XTRA HACK MOVEFAST */
5206 int mag = MIN(wid / 2, hgt / 2);
5216 /* Do not move horizontally if unnecessary */
5217 if (((x < panel_col_min + wid / 2) && (dx > 0)) ||
5218 ((x > panel_col_min + wid / 2) && (dx < 0)))
5223 /* Do not move vertically if unnecessary */
5224 if (((y < panel_row_min + hgt / 2) && (dy > 0)) ||
5225 ((y > panel_row_min + hgt / 2) && (dy < 0)))
5230 /* Apply the motion */
5231 if ((y >= panel_row_min + hgt) || (y < panel_row_min) ||
5232 (x >= panel_col_min + wid) || (x < panel_col_min))
5234 /* if (change_panel(dy, dx)) target_set_prepare(mode); */
5235 change_panel(dy, dx);
5238 /* Slide into legality */
5239 if (x >= cur_wid-1) x = cur_wid - 2;
5240 else if (x <= 0) x = 1;
5242 /* Slide into legality */
5243 if (y >= cur_hgt-1) y = cur_hgt- 2;
5244 else if (y <= 0) y = 1;
5251 /* Clear the top line */
5254 /* Recenter the map around the player */
5257 p_ptr->update |= (PU_MONSTERS);
5260 p_ptr->redraw |= (PR_MAP);
5262 p_ptr->window |= (PW_OVERHEAD);
5273 bool get_hack_dir(DIRECTION *dp)
5282 /* Global direction */
5285 /* (No auto-targeting) */
5287 /* Ask until satisfied */
5290 /* Choose a prompt */
5293 p = _("方向 ('*'でターゲット選択, ESCで中断)? ", "Direction ('*' to choose a target, Escape to cancel)? ");
5297 p = _("方向 ('5'でターゲットへ, '*'でターゲット再選択, ESCで中断)? ", "Direction ('5' for target, '*' to re-target, Escape to cancel)? ");
5300 /* Get a command (or Cancel) */
5301 if (!get_com(p, &command, TRUE)) break;
5305 if (command == '\r') command = 't';
5308 /* Convert various keys to "standard" keys */
5311 /* Use current target */
5322 /* Set new target */
5327 if (target_set(TARGET_KILL)) dir = 5;
5333 /* Look up the direction */
5334 dir = get_keymap_dir(command);
5340 /* Verify requested targets */
5341 if ((dir == 5) && !target_okay()) dir = 0;
5348 if (!dir) return (FALSE);
5350 /* Save the direction */
5353 /* Check for confusion */
5354 if (p_ptr->confused)
5356 /* Random direction */
5357 dir = ddd[randint0(8)];
5360 /* Notice confusion */
5361 if (command_dir != dir)
5364 msg_print(_("あなたは混乱している。", "You are confused."));
5367 /* Save direction */
5370 /* A "valid" direction was entered */
5376 * エネルギーの増加量10d5を速く計算するための関数
5379 #define Go_no_JuuJou 5*5*5*5*5*5*5*5*5*5
5381 s16b gain_energy(void)
5384 s32b energy_result = 10;
5387 tmp = randint0(Go_no_JuuJou);
5389 for (i = 0; i < 9; i ++){
5390 energy_result += tmp % 5;
5394 return (s16b)(energy_result + tmp);
5399 * @brief 射撃武器の攻撃に必要な基本消費エネルギーを返す/Return bow energy
5400 * @param sval 射撃武器のアイテム副分類ID
5401 * @return 消費する基本エネルギー
5403 ENERGY bow_energy(OBJECT_SUBTYPE_VALUE sval)
5405 ENERGY energy = 10000;
5407 /* Analyze the launcher */
5410 /* Sling and ammo */
5417 /* Short Bow and Arrow */
5424 /* Long Bow and Arrow */
5431 /* Bow of irresponsiblity and Arrow */
5438 /* Light Crossbow and Bolt */
5445 /* Heavy Crossbow and Bolt */
5460 int bow_tmul(OBJECT_SUBTYPE_VALUE sval)
5464 /* Analyze the launcher */
5467 /* Sling and ammo */
5474 /* Short Bow and Arrow */
5481 /* Long Bow and Arrow */
5488 /* Bow of irresponsiblity and Arrow */
5495 /* Light Crossbow and Bolt */
5502 /* Heavy Crossbow and Bolt */
5514 * Return alignment title
5516 cptr your_alignment(void)
5519 if (p_ptr->align > 150) return "大善";
5520 else if (p_ptr->align > 50) return "中善";
5521 else if (p_ptr->align > 10) return "小善";
5522 else if (p_ptr->align > -11) return "中立";
5523 else if (p_ptr->align > -51) return "小悪";
5524 else if (p_ptr->align > -151) return "中悪";
5527 if (p_ptr->align > 150) return "Lawful";
5528 else if (p_ptr->align > 50) return "Good";
5529 else if (p_ptr->align > 10) return "Neutral Good";
5530 else if (p_ptr->align > -11) return "Neutral";
5531 else if (p_ptr->align > -51) return "Neutral Evil";
5532 else if (p_ptr->align > -151) return "Evil";
5533 else return "Chaotic";
5539 * Return proficiency level of weapons and misc. skills (except riding)
5541 int weapon_exp_level(int weapon_exp)
5543 if (weapon_exp < WEAPON_EXP_BEGINNER) return EXP_LEVEL_UNSKILLED;
5544 else if (weapon_exp < WEAPON_EXP_SKILLED) return EXP_LEVEL_BEGINNER;
5545 else if (weapon_exp < WEAPON_EXP_EXPERT) return EXP_LEVEL_SKILLED;
5546 else if (weapon_exp < WEAPON_EXP_MASTER) return EXP_LEVEL_EXPERT;
5547 else return EXP_LEVEL_MASTER;
5552 * Return proficiency level of riding
5554 int riding_exp_level(int riding_exp)
5556 if (riding_exp < RIDING_EXP_BEGINNER) return EXP_LEVEL_UNSKILLED;
5557 else if (riding_exp < RIDING_EXP_SKILLED) return EXP_LEVEL_BEGINNER;
5558 else if (riding_exp < RIDING_EXP_EXPERT) return EXP_LEVEL_SKILLED;
5559 else if (riding_exp < RIDING_EXP_MASTER) return EXP_LEVEL_EXPERT;
5560 else return EXP_LEVEL_MASTER;
5565 * Return proficiency level of spells
5567 int spell_exp_level(int spell_exp)
5569 if (spell_exp < SPELL_EXP_BEGINNER) return EXP_LEVEL_UNSKILLED;
5570 else if (spell_exp < SPELL_EXP_SKILLED) return EXP_LEVEL_BEGINNER;
5571 else if (spell_exp < SPELL_EXP_EXPERT) return EXP_LEVEL_SKILLED;
5572 else if (spell_exp < SPELL_EXP_MASTER) return EXP_LEVEL_EXPERT;
5573 else return EXP_LEVEL_MASTER;
5578 * Display a rumor and apply its effects
5581 IDX rumor_num(char *zz, IDX max_idx)
5583 if (strcmp(zz, "*") == 0) return randint1(max_idx - 1);
5584 return (IDX)atoi(zz);
5587 cptr rumor_bind_name(char *base, cptr fullname)
5591 s = strstr(base, "{Name}");
5595 v = format("%s%s%s", base, fullname, (s + 6));
5605 void display_rumor(bool ex)
5613 if (randint0(3) == 0) section = 1;
5616 err = _(get_rnd_line_jonly("rumors_j.txt", section, Rumor, 10),
5617 get_rnd_line("rumors.txt", section, Rumor));
5618 if (err) strcpy(Rumor, _("嘘の噂もある。", "Some rumors are wrong."));
5622 if (strncmp(Rumor, "R:", 2) == 0)
5625 cptr rumor_msg = NULL;
5626 cptr rumor_eff_format = NULL;
5627 char fullname[1024] = "";
5629 if (tokenize(Rumor + 2, 3, zz, TOKENIZE_CHECKQUOTE) == 3)
5631 if (strcmp(zz[0], "ARTIFACT") == 0)
5635 object_type *q_ptr = &forge;
5636 artifact_type *a_ptr;
5640 a_idx = rumor_num(zz[1], max_a_idx);
5642 a_ptr = &a_info[a_idx];
5643 if (a_ptr->name) break;
5646 k_idx = lookup_kind(a_ptr->tval, a_ptr->sval);
5647 object_prep(q_ptr, k_idx);
5648 q_ptr->name1 = a_idx;
5649 q_ptr->ident = IDENT_STORE;
5650 object_desc(fullname, q_ptr, OD_NAME_ONLY);
5652 else if (strcmp(zz[0], "MONSTER") == 0)
5655 monster_race *r_ptr;
5659 r_idx = rumor_num(zz[1], max_r_idx);
5660 r_ptr = &r_info[r_idx];
5661 if (r_ptr->name) break;
5664 strcpy(fullname, r_name + r_ptr->name);
5666 /* Remember this monster */
5667 if (!r_ptr->r_sights)
5672 else if (strcmp(zz[0], "DUNGEON") == 0)
5675 dungeon_info_type *d_ptr;
5679 d_idx = rumor_num(zz[1], max_d_idx);
5680 d_ptr = &d_info[d_idx];
5681 if (d_ptr->name) break;
5684 strcpy(fullname, d_name + d_ptr->name);
5686 if (!max_dlv[d_idx])
5688 max_dlv[d_idx] = d_ptr->mindepth;
5689 rumor_eff_format = _("%sに帰還できるようになった。", "You can recall to %s.");
5692 else if (strcmp(zz[0], "TOWN") == 0)
5699 t_idx = rumor_num(zz[1], NO_TOWN);
5700 if (town[t_idx].name) break;
5703 strcpy(fullname, town[t_idx].name);
5705 visit = (1L << (t_idx - 1));
5706 if ((t_idx != SECRET_TOWN) && !(p_ptr->visit & visit))
5708 p_ptr->visit |= visit;
5709 rumor_eff_format = _("%sに行ったことがある気がする。", "You feel you have been to %s.");
5713 rumor_msg = rumor_bind_name(zz[2], fullname);
5714 msg_print(rumor_msg);
5715 if (rumor_eff_format)
5718 msg_format(rumor_eff_format, fullname);
5723 if (err) msg_print(_("この情報は間違っている。", "This information is wrong."));
5727 msg_format("%s", Rumor);