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.
17 #define REWARD_CHANCE 10
21 * @brief プレイヤーの経験値について整合性のためのチェックと調整を行う /
22 * Advance experience levels and print experience
25 void check_experience(void)
27 bool level_reward = FALSE;
28 bool level_mutation = FALSE;
29 bool level_inc_stat = FALSE;
30 bool android = (p_ptr->prace == RACE_ANDROID ? TRUE : FALSE);
31 PLAYER_LEVEL old_lev = p_ptr->lev;
33 /* Hack -- lower limit */
34 if (p_ptr->exp < 0) p_ptr->exp = 0;
35 if (p_ptr->max_exp < 0) p_ptr->max_exp = 0;
36 if (p_ptr->max_max_exp < 0) p_ptr->max_max_exp = 0;
38 /* Hack -- upper limit */
39 if (p_ptr->exp > PY_MAX_EXP) p_ptr->exp = PY_MAX_EXP;
40 if (p_ptr->max_exp > PY_MAX_EXP) p_ptr->max_exp = PY_MAX_EXP;
41 if (p_ptr->max_max_exp > PY_MAX_EXP) p_ptr->max_max_exp = PY_MAX_EXP;
43 /* Hack -- maintain "max" experience */
44 if (p_ptr->exp > p_ptr->max_exp) p_ptr->max_exp = p_ptr->exp;
46 /* Hack -- maintain "max max" experience */
47 if (p_ptr->max_exp > p_ptr->max_max_exp) p_ptr->max_max_exp = p_ptr->max_exp;
49 /* Redraw experience */
50 p_ptr->redraw |= (PR_EXP);
56 /* Lose levels while possible */
57 while ((p_ptr->lev > 1) &&
58 (p_ptr->exp < ((android ? player_exp_a : player_exp)[p_ptr->lev - 2] * p_ptr->expfact / 100L)))
63 /* Update some stuff */
64 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
66 /* Redraw some stuff */
67 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);
114 p_ptr->window |= (PW_PLAYER | PW_SPELL | PW_INVEN);
126 if(!(p_ptr->max_plv % 10))
136 cnv_stat(p_ptr->stat_max[0], tmp);
137 prt(format(" a) 腕力 (現在値 %s)", tmp), 2, 14);
138 cnv_stat(p_ptr->stat_max[1], tmp);
139 prt(format(" b) 知能 (現在値 %s)", tmp), 3, 14);
140 cnv_stat(p_ptr->stat_max[2], tmp);
141 prt(format(" c) 賢さ (現在値 %s)", tmp), 4, 14);
142 cnv_stat(p_ptr->stat_max[3], tmp);
143 prt(format(" d) 器用 (現在値 %s)", tmp), 5, 14);
144 cnv_stat(p_ptr->stat_max[4], tmp);
145 prt(format(" e) 耐久 (現在値 %s)", tmp), 6, 14);
146 cnv_stat(p_ptr->stat_max[5], tmp);
147 prt(format(" f) 魅力 (現在値 %s)", tmp), 7, 14);
149 prt(" どの能力値を上げますか?", 1, 14);
151 cnv_stat(p_ptr->stat_max[0], tmp);
152 prt(format(" a) Str (cur %s)", tmp), 2, 14);
153 cnv_stat(p_ptr->stat_max[1], tmp);
154 prt(format(" b) Int (cur %s)", tmp), 3, 14);
155 cnv_stat(p_ptr->stat_max[2], tmp);
156 prt(format(" c) Wis (cur %s)", tmp), 4, 14);
157 cnv_stat(p_ptr->stat_max[3], tmp);
158 prt(format(" d) Dex (cur %s)", tmp), 5, 14);
159 cnv_stat(p_ptr->stat_max[4], tmp);
160 prt(format(" e) Con (cur %s)", tmp), 6, 14);
161 cnv_stat(p_ptr->stat_max[5], tmp);
162 prt(format(" f) Chr (cur %s)", tmp), 7, 14);
164 prt(" Which stat do you want to raise?", 1, 14);
169 if ((choice >= 'a') && (choice <= 'f')) break;
171 for(n = 0; n < 6; n++)
172 if (n != choice - 'a')
174 if (get_check(_("よろしいですか?", "Are you sure? "))) break;
176 do_inc_stat(choice - 'a');
179 else if(!(p_ptr->max_plv % 2))
180 do_inc_stat(randint0(6));
185 msg_print(_("あなたは変わった気がする...", "You feel different..."));
186 (void)gain_random_mutation(0);
187 level_mutation = FALSE;
191 * 報酬でレベルが上ると再帰的に check_experience() が
196 gain_level_reward(0);
197 level_reward = FALSE;
200 /* Update some stuff */
201 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
203 /* Redraw some stuff */
204 p_ptr->redraw |= (PR_LEV | PR_TITLE);
207 p_ptr->window |= (PW_PLAYER | PW_SPELL);
213 /* Load an autopick preference file */
214 if (old_lev != p_ptr->lev) autopick_load_pref(FALSE);
219 * @brief モンスターを倒した際の財宝svalを返す
220 * @param r_idx 倒したモンスターの種族ID
223 * Hack -- Return the "automatic coin type" of a monster race
224 * Used to allocate proper treasure when "Creeping coins" die
225 * XXX XXX XXX Note the use of actual "monster names"
227 static int get_coin_type(MONRACE_IDX r_idx)
229 /* Analyze monsters */
232 case MON_COPPER_COINS: return 2;
233 case MON_SILVER_COINS: return 5;
234 case MON_GOLD_COINS: return 10;
235 case MON_MITHRIL_COINS:
236 case MON_MITHRIL_GOLEM: return 16;
237 case MON_ADAMANT_COINS: return 17;
246 * @brief オブジェクトがクロークかどうかを判定する /
247 * Hack -- determine if a template is Cloak
248 * @param k_idx 判定したいオブジェクトのベースアイテムID
249 * @return オブジェクトがクロークならばTRUEを返す
251 static bool kind_is_cloak(KIND_OBJECT_IDX k_idx)
253 object_kind *k_ptr = &k_info[k_idx];
255 /* Analyze the item type */
256 if (k_ptr->tval == TV_CLOAK)
261 /* Assume not good */
267 * @brief オブジェクトが竿状武器かどうかを判定する /
268 * Hack -- determine if a template is Polearm
269 * @param k_idx 判定したいオブジェクトのベースアイテムID
270 * @return オブジェクトが竿状武器ならばTRUEを返す
272 static bool kind_is_polearm(KIND_OBJECT_IDX k_idx)
274 object_kind *k_ptr = &k_info[k_idx];
276 /* Analyze the item type */
277 if (k_ptr->tval == TV_POLEARM)
282 /* Assume not good */
288 * @brief オブジェクトが剣かどうかを判定する /
289 * Hack -- determine if a template is Sword
290 * @param k_idx 判定したいオブジェクトのベースアイテムID
291 * @return オブジェクトが剣ならばTRUEを返す
293 static bool kind_is_sword(KIND_OBJECT_IDX k_idx)
295 object_kind *k_ptr = &k_info[k_idx];
297 /* Analyze the item type */
298 if ((k_ptr->tval == TV_SWORD) && (k_ptr->sval > 2))
303 /* Assume not good */
309 * @brief オブジェクトが魔法書かどうかを判定する /
310 * Hack -- determine if a template is Book
311 * @param k_idx 判定したいオブジェクトのベースアイテムID
312 * @return オブジェクトが魔法書ならばTRUEを返す
314 static bool kind_is_book(KIND_OBJECT_IDX k_idx)
316 object_kind *k_ptr = &k_info[k_idx];
318 /* Analyze the item type */
319 if ((k_ptr->tval >= TV_LIFE_BOOK) && (k_ptr->tval <= TV_CRUSADE_BOOK))
324 /* Assume not good */
330 * @brief オブジェクトがベースアイテム時点でGOODかどうかを判定する /
331 * Hack -- determine if a template is Good book
332 * @param k_idx 判定したいオブジェクトのベースアイテムID
333 * @return オブジェクトがベースアイテム時点でGOODなアイテムならばTRUEを返す
335 static bool kind_is_good_book(KIND_OBJECT_IDX k_idx)
337 object_kind *k_ptr = &k_info[k_idx];
339 /* Analyze the item type */
340 if ((k_ptr->tval >= TV_LIFE_BOOK) && (k_ptr->tval <= TV_CRUSADE_BOOK) && (k_ptr->tval != TV_ARCANE_BOOK) && (k_ptr->sval > 1))
345 /* Assume not good */
351 * @brief オブジェクトが鎧かどうかを判定する /
352 * Hack -- determine if a template is Armor
353 * @param k_idx 判定したいオブジェクトのベースアイテムID
354 * @return オブジェクトが鎧ならばTRUEを返す
356 static bool kind_is_armor(KIND_OBJECT_IDX k_idx)
358 object_kind *k_ptr = &k_info[k_idx];
360 /* Analyze the item type */
361 if (k_ptr->tval == TV_HARD_ARMOR)
366 /* Assume not good */
372 * @brief オブジェクトが打撃武器かどうかを判定する /
373 * Hack -- determine if a template is hafted weapon
374 * @param k_idx 判定したいオブジェクトのベースアイテムID
375 * @return オブジェクトが打撃武器ならばTRUEを返す
377 static bool kind_is_hafted(KIND_OBJECT_IDX k_idx)
379 object_kind *k_ptr = &k_info[k_idx];
381 /* Analyze the item type */
382 if (k_ptr->tval == TV_HAFTED)
387 /* Assume not good */
392 * @brief クエストを達成状態にする /
393 * @param quest_num 達成状態にしたいクエストのID
396 void complete_quest(QUEST_IDX quest_num)
398 quest_type* const q_ptr = &quest[quest_num];
402 case QUEST_TYPE_RANDOM:
403 if (record_rand_quest) do_cmd_write_nikki(NIKKI_RAND_QUEST_C, quest_num, NULL);
406 if (record_fix_quest) do_cmd_write_nikki(NIKKI_FIX_QUEST_C, quest_num, NULL);
410 q_ptr->status = QUEST_STATUS_COMPLETED;
411 q_ptr->complev = (byte)p_ptr->lev;
413 q_ptr->comptime = playtime;
415 if (!(q_ptr->flags & QUEST_FLAG_SILENT))
417 play_music(TERM_XTRA_MUSIC_BASIC, MUSIC_BASIC_QUEST_CLEAR);
418 msg_print(_("クエストを達成した!", "You just completed your quest!"));
424 * @brief 現在フロアに残っている敵モンスターの数を返す /
425 * @return 現在の敵モンスターの数
427 static MONSTER_NUMBER count_all_hostile_monsters(void)
430 MONSTER_NUMBER number_mon = 0;
432 for (x = 0; x < cur_wid; ++ x)
434 for (y = 0; y < cur_hgt; ++ y)
436 MONSTER_IDX m_idx = cave[y][x].m_idx;
438 if (m_idx > 0 && is_hostile(&m_list[m_idx]))
449 * @brief 特定の敵を倒した際にクエスト達成処理 /
450 * Check for "Quest" completion when a quest monster is killed or charmed.
451 * @param m_ptr 撃破したモンスターの構造体参照ポインタ
454 void check_quest_completion(monster_type *m_ptr)
459 bool create_stairs = FALSE;
465 /* Get the location */
470 quest_num = p_ptr->inside_quest;
472 /* Search for an active quest on this dungeon level */
477 for (i = max_q_idx - 1; i > 0; i--)
479 quest_type* const q_ptr = &quest[i];
481 /* Quest is not active */
482 if (q_ptr->status != QUEST_STATUS_TAKEN)
485 /* Quest is not a dungeon quest */
486 if (q_ptr->flags & QUEST_FLAG_PRESET)
489 /* Quest is not on this level */
490 if ((q_ptr->level != dun_level) &&
491 (q_ptr->type != QUEST_TYPE_KILL_ANY_LEVEL))
494 /* Not a "kill monster" quest */
495 if ((q_ptr->type == QUEST_TYPE_FIND_ARTIFACT) ||
496 (q_ptr->type == QUEST_TYPE_FIND_EXIT))
499 /* Interesting quest */
500 if ((q_ptr->type == QUEST_TYPE_KILL_NUMBER) ||
501 (q_ptr->type == QUEST_TYPE_TOWER) ||
502 (q_ptr->type == QUEST_TYPE_KILL_ALL))
505 /* Interesting quest */
506 if (((q_ptr->type == QUEST_TYPE_KILL_LEVEL) ||
507 (q_ptr->type == QUEST_TYPE_KILL_ANY_LEVEL) ||
508 (q_ptr->type == QUEST_TYPE_RANDOM)) &&
509 (q_ptr->r_idx == m_ptr->r_idx))
516 /* Handle the current quest */
517 if (quest_num && (quest[quest_num].status == QUEST_STATUS_TAKEN))
520 quest_type* const q_ptr = &quest[quest_num];
524 case QUEST_TYPE_KILL_NUMBER:
528 if (q_ptr->cur_num >= q_ptr->num_mon)
530 complete_quest(quest_num);
536 case QUEST_TYPE_KILL_ALL:
538 if (!is_hostile(m_ptr)) break;
540 if (count_all_hostile_monsters() == 1)
542 if (q_ptr->flags & QUEST_FLAG_SILENT)
544 q_ptr->status = QUEST_STATUS_FINISHED;
548 complete_quest(quest_num);
553 case QUEST_TYPE_KILL_LEVEL:
554 case QUEST_TYPE_RANDOM:
556 /* Only count valid monsters */
557 if (q_ptr->r_idx != m_ptr->r_idx)
562 if (q_ptr->cur_num >= q_ptr->max_num)
564 complete_quest(quest_num);
566 if (!(q_ptr->flags & QUEST_FLAG_PRESET))
568 create_stairs = TRUE;
569 p_ptr->inside_quest = 0;
572 /* Finish the two main quests without rewarding */
573 if ((quest_num == QUEST_OBERON) || (quest_num == QUEST_SERPENT))
575 q_ptr->status = QUEST_STATUS_FINISHED;
578 if (q_ptr->type == QUEST_TYPE_RANDOM)
581 q_ptr->status = QUEST_STATUS_FINISHED;
586 case QUEST_TYPE_KILL_ANY_LEVEL:
589 if (q_ptr->cur_num >= q_ptr->max_num)
591 complete_quest(quest_num);
596 case QUEST_TYPE_TOWER:
598 if (!is_hostile(m_ptr)) break;
600 if (count_all_hostile_monsters() == 1)
602 q_ptr->status = QUEST_STATUS_STAGE_COMPLETED;
604 if((quest[QUEST_TOWER1].status == QUEST_STATUS_STAGE_COMPLETED) &&
605 (quest[QUEST_TOWER2].status == QUEST_STATUS_STAGE_COMPLETED) &&
606 (quest[QUEST_TOWER3].status == QUEST_STATUS_STAGE_COMPLETED))
609 complete_quest(QUEST_TOWER1);
617 /* Create a magical staircase */
623 while (cave_perma_bold(y, x) || cave[y][x].o_idx || (cave[y][x].info & CAVE_OBJECT) )
625 /* Pick a location */
626 scatter(&ny, &nx, y, x, 1, 0);
632 /* Explain the staircase */
633 msg_print(_("魔法の階段が現れた...", "A magical staircase appears..."));
635 /* Create stairs down */
636 cave_set_feat(y, x, feat_down_stair);
638 /* Remember to update everything */
639 p_ptr->update |= (PU_FLOW);
649 for (i = 0; i < (dun_level / 15)+1; i++)
651 /* Get local object */
654 /* Wipe the object */
657 /* Make a great object */
658 make_object(o_ptr, AM_GOOD | AM_GREAT);
660 /* Drop it in the dungeon */
661 (void)drop_near(o_ptr, -1, y, x);
667 * @brief 特定のアーティファクトを入手した際のクエスト達成処理 /
668 * Check for "Quest" completion when a quest monster is killed or charmed.
669 * @param o_ptr 入手したオブジェクトの構造体参照ポインタ
672 void check_find_art_quest_completion(object_type *o_ptr)
675 /* Check if completed a quest */
676 for (i = 0; i < max_q_idx; i++)
678 if((quest[i].type == QUEST_TYPE_FIND_ARTIFACT) &&
679 (quest[i].status == QUEST_STATUS_TAKEN) &&
680 (quest[i].k_idx == o_ptr->name1))
689 * @brief モンスターを撃破した際の述語メッセージを返す /
690 * Return monster death string
691 * @param r_ptr 撃破されたモンスターの種族情報を持つ構造体の参照ポインタ
692 * @return 撃破されたモンスターの述語
694 cptr extract_note_dies(monster_race *r_ptr)
696 /* Some monsters get "destroyed" */
697 if (!monster_living(r_ptr))
701 for (i = 0; i < 4; i++)
703 if (r_ptr->blow[i].method == RBM_EXPLODE)
705 return _("は爆発して粉々になった。", " explodes into tiny shreds.");
708 return _("を倒した。", " is destroyed.");
711 /* Assume a default death */
712 return _("は死んだ。", " dies.");
717 * @brief モンスターが死亡した時の処理 /
718 * Handle the "death" of a monster.
719 * @param m_idx 死亡したモンスターのID
720 * @param drop_item TRUEならばモンスターのドロップ処理を行う
721 * @return 撃破されたモンスターの述語
724 * Disperse treasures centered at the monster location based on the
725 * various flags contained in the monster flags fields.
726 * Check for "Quest" completion when a quest monster is killed.
727 * Note that only the player can induce "monster_death()" on Uniques.
728 * Thus (for now) all Quest monsters should be Uniques.
729 * Note that monsters can now carry objects, and when a monster dies,
730 * it drops all of its objects, which may disappear in crowded rooms.
733 void monster_death(MONSTER_IDX m_idx, bool drop_item)
742 monster_type *m_ptr = &m_list[m_idx];
744 monster_race *r_ptr = &r_info[m_ptr->r_idx];
746 bool visible = ((m_ptr->ml && !p_ptr->image) || (r_ptr->flags1 & RF1_UNIQUE));
750 bool do_gold = (!(r_ptr->flags1 & RF1_ONLY_ITEM));
751 bool do_item = (!(r_ptr->flags1 & RF1_ONLY_GOLD));
752 bool cloned = (m_ptr->smart & SM_CLONED) ? TRUE : FALSE;
753 int force_coin = get_coin_type(m_ptr->r_idx);
758 bool drop_chosen_item = drop_item && !cloned && !p_ptr->inside_arena
759 && !p_ptr->inside_battle && !is_pet(m_ptr);
761 /* The caster is dead? */
762 if (world_monster && world_monster == m_idx) world_monster = 0;
764 /* Notice changes in view */
765 if (r_ptr->flags7 & (RF7_LITE_MASK | RF7_DARK_MASK))
767 /* Update some things */
768 p_ptr->update |= (PU_MON_LITE);
771 /* Get the location */
775 if (record_named_pet && is_pet(m_ptr) && m_ptr->nickname)
779 monster_desc(m_name, m_ptr, MD_INDEF_VISIBLE);
780 do_cmd_write_nikki(NIKKI_NAMED_PET, 3, m_name);
783 /* Let monsters explode! */
784 for (i = 0; i < 4; i++)
786 if (r_ptr->blow[i].method == RBM_EXPLODE)
788 BIT_FLAGS flg = PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL;
789 EFFECT_ID typ = mbe_info[r_ptr->blow[i].effect].explode_type;
790 DICE_NUMBER d_dice = r_ptr->blow[i].d_dice;
791 DICE_SID d_side = r_ptr->blow[i].d_side;
792 HIT_POINT damage = damroll(d_dice, d_side);
794 project(m_idx, 3, y, x, damage, typ, flg, -1);
799 if (m_ptr->mflag2 & MFLAG2_CHAMELEON)
801 choose_new_monster(m_idx, TRUE, MON_CHAMELEON);
802 r_ptr = &r_info[m_ptr->r_idx];
805 /* Check for quest completion */
806 check_quest_completion(m_ptr);
808 /* Handle the possibility of player vanquishing arena combatant -KMW- */
809 if (p_ptr->inside_arena && !is_pet(m_ptr))
811 p_ptr->exit_bldg = TRUE;
813 if (p_ptr->arena_number > MAX_ARENA_MONS)
815 msg_print(_("素晴らしい!君こそ真の勝利者だ。", "You are a Genuine Champion!"));
819 msg_print(_("勝利!チャンピオンへの道を進んでいる。", "Victorious! You're on your way to becoming Champion."));
822 if (arena_info[p_ptr->arena_number].tval)
824 /* Get local object */
827 /* Prepare to make a prize */
828 object_prep(q_ptr, lookup_kind(arena_info[p_ptr->arena_number].tval, arena_info[p_ptr->arena_number].sval));
830 apply_magic(q_ptr, object_level, AM_NO_FIXED_ART);
832 /* Drop it in the dungeon */
833 (void)drop_near(q_ptr, -1, y, x);
836 if (p_ptr->arena_number > MAX_ARENA_MONS) p_ptr->arena_number++;
837 p_ptr->arena_number++;
842 /* Extract monster name */
843 monster_desc(m_name, m_ptr, MD_IGNORE_HALLU | MD_ASSUME_VISIBLE | MD_INDEF_VISIBLE);
845 do_cmd_write_nikki(NIKKI_ARENA, p_ptr->arena_number, m_name);
849 if (m_idx == p_ptr->riding)
851 if (rakuba(-1, FALSE))
853 msg_print(_("地面に落とされた。", "You have fallen from your riding pet."));
857 /* Drop a dead corpse? */
858 if (one_in_(r_ptr->flags1 & RF1_UNIQUE ? 1 : 4) &&
859 (r_ptr->flags9 & (RF9_DROP_CORPSE | RF9_DROP_SKELETON)) &&
860 !(p_ptr->inside_arena || p_ptr->inside_battle || cloned || ((m_ptr->r_idx == today_mon) && is_pet(m_ptr))))
862 /* Assume skeleton */
866 * We cannot drop a skeleton? Note, if we are in this check,
867 * we *know* we can drop at least a corpse or a skeleton
869 if (!(r_ptr->flags9 & RF9_DROP_SKELETON))
871 else if ((r_ptr->flags9 & RF9_DROP_CORPSE) && (r_ptr->flags1 & RF1_UNIQUE))
874 /* Else, a corpse is more likely unless we did a "lot" of damage */
875 else if (r_ptr->flags9 & RF9_DROP_CORPSE)
877 /* Lots of damage in one blow */
878 if ((0 - ((m_ptr->maxhp) / 4)) > m_ptr->hp)
880 if (one_in_(5)) corpse = TRUE;
884 if (!one_in_(5)) corpse = TRUE;
888 /* Get local object */
891 /* Prepare to make an object */
892 object_prep(q_ptr, lookup_kind(TV_CORPSE, (corpse ? SV_CORPSE : SV_SKELETON)));
894 apply_magic(q_ptr, object_level, AM_NO_FIXED_ART);
896 q_ptr->pval = m_ptr->r_idx;
898 /* Drop it in the dungeon */
899 (void)drop_near(q_ptr, -1, y, x);
902 /* Drop objects being carried */
903 monster_drop_carried_objects(m_ptr);
905 if (r_ptr->flags1 & RF1_DROP_GOOD) mo_mode |= AM_GOOD;
906 if (r_ptr->flags1 & RF1_DROP_GREAT) mo_mode |= AM_GREAT;
908 switch (m_ptr->r_idx)
910 case MON_PINK_HORROR:
911 /* Pink horrors are replaced with 2 Blue horrors */
912 if (!(p_ptr->inside_arena || p_ptr->inside_battle))
916 for (i = 0; i < 2; i++)
919 bool pet = is_pet(m_ptr);
922 if (pet) mode |= PM_FORCE_PET;
924 if (summon_specific((pet ? -1 : m_idx), wy, wx, 100, SUMMON_BLUE_HORROR, mode))
926 if (player_can_see_bold(wy, wx))
932 msg_print(_("ピンク・ホラーは分裂した!", "The Pink horror divides!"));
936 case MON_BLOODLETTER:
937 /* Bloodletters of Khorne may drop a blade of chaos */
938 if (drop_chosen_item && (randint1(100) < 15))
940 /* Get local object */
943 /* Prepare to make a Blade of Chaos */
944 object_prep(q_ptr, lookup_kind(TV_SWORD, SV_BLADE_OF_CHAOS));
946 apply_magic(q_ptr, object_level, AM_NO_FIXED_ART | mo_mode);
948 /* Drop it in the dungeon */
949 (void)drop_near(q_ptr, -1, y, x);
954 if (drop_chosen_item && (dun_level > 9))
956 /* Get local object */
959 /* Wipe the object */
962 /* Activate restriction */
963 if ((dun_level > 49) && one_in_(5))
964 get_obj_num_hook = kind_is_good_book;
966 get_obj_num_hook = kind_is_book;
969 make_object(q_ptr, mo_mode);
971 /* Drop it in the dungeon */
972 (void)drop_near(q_ptr, -1, y, x);
978 * Mega^3-hack: killing a 'Warrior of the Dawn' is likely to
979 * spawn another in the fallen one's place!
981 if (!p_ptr->inside_arena && !p_ptr->inside_battle)
985 POSITION wy = y, wx = x;
987 bool pet = is_pet(m_ptr);
991 scatter(&wy, &wx, y, x, 20, 0);
993 while (!(in_bounds(wy, wx) && cave_empty_bold2(wy, wx)) && --attempts);
998 if (pet) mode |= PM_FORCE_PET;
1000 if (summon_specific((pet ? -1 : m_idx), wy, wx, 100, SUMMON_DAWN, mode))
1002 if (player_can_see_bold(wy, wx))
1003 msg_print(_("新たな戦士が現れた!", "A new warrior steps forth!"));
1011 /* One more ultra-hack: An Unmaker goes out with a big bang! */
1013 BIT_FLAGS flg = PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL;
1014 (void)project(m_idx, 6, y, x, 100, GF_CHAOS, flg, -1);
1018 case MON_UNICORN_ORD:
1021 /* Reward for "lazy" player */
1022 if (p_ptr->pseikaku == SEIKAKU_NAMAKE)
1024 ARTIFACT_IDX a_idx = 0;
1025 artifact_type *a_ptr = NULL;
1027 if (!drop_chosen_item) break;
1031 switch (randint0(3))
1034 a_idx = ART_NAMAKE_HAMMER;
1037 a_idx = ART_NAMAKE_BOW;
1040 a_idx = ART_NAMAKE_ARMOR;
1044 a_ptr = &a_info[a_idx];
1046 while (a_ptr->cur_num);
1048 /* Create the artifact */
1049 if (create_named_art(a_idx, y, x))
1053 /* Hack -- Memorize location of artifact in saved floors */
1054 if (character_dungeon) a_ptr->floor_id = p_ptr->floor_id;
1056 else if (!preserve_mode) a_ptr->cur_num = 1;
1061 if (!drop_chosen_item) break;
1063 /* Get local object */
1066 /* Mega-Hack -- Prepare to make "Grond" */
1067 object_prep(q_ptr, lookup_kind(TV_HAFTED, SV_GROND));
1069 /* Mega-Hack -- Mark this item as "Grond" */
1070 q_ptr->name1 = ART_GROND;
1072 /* Mega-Hack -- Actually create "Grond" */
1073 apply_magic(q_ptr, -1, AM_GOOD | AM_GREAT);
1075 /* Drop it in the dungeon */
1076 (void)drop_near(q_ptr, -1, y, x);
1078 /* Get local object */
1081 /* Mega-Hack -- Prepare to make "Chaos" */
1082 object_prep(q_ptr, lookup_kind(TV_CROWN, SV_CHAOS));
1084 /* Mega-Hack -- Mark this item as "Chaos" */
1085 q_ptr->name1 = ART_CHAOS;
1087 /* Mega-Hack -- Actually create "Chaos" */
1088 apply_magic(q_ptr, -1, AM_GOOD | AM_GREAT);
1090 /* Drop it in the dungeon */
1091 (void)drop_near(q_ptr, -1, y, x);
1094 case MON_B_DEATH_SWORD:
1095 if (drop_chosen_item)
1097 /* Get local object */
1100 /* Prepare to make a broken sword */
1101 object_prep(q_ptr, lookup_kind(TV_SWORD, randint1(2)));
1103 /* Drop it in the dungeon */
1104 (void)drop_near(q_ptr, -1, y, x);
1110 if (drop_chosen_item && ((m_ptr->r_idx == MON_A_GOLD) ||
1111 ((m_ptr->r_idx == MON_A_SILVER) && (r_ptr->r_akills % 5 == 0))))
1113 /* Get local object */
1116 /* Prepare to make a Can of Toys */
1117 object_prep(q_ptr, lookup_kind(TV_CHEST, SV_CHEST_KANDUME));
1119 apply_magic(q_ptr, object_level, AM_NO_FIXED_ART);
1121 /* Drop it in the dungeon */
1122 (void)drop_near(q_ptr, -1, y, x);
1128 BIT_FLAGS flg = PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL;
1129 (void)project(m_idx, 3, y, x, damroll(20, 10), GF_FIRE, flg, -1);
1134 if (!drop_chosen_item) break;
1136 switch (r_ptr->d_char)
1141 /* Get local object */
1144 /* Wipe the object */
1147 /* Activate restriction */
1148 get_obj_num_hook = kind_is_cloak;
1151 make_object(q_ptr, mo_mode);
1153 /* Drop it in the dungeon */
1154 (void)drop_near(q_ptr, -1, y, x);
1161 /* Get local object */
1164 /* Wipe the object */
1167 /* Activate restriction */
1168 get_obj_num_hook = kind_is_polearm;
1170 /* Make a poleweapon */
1171 make_object(q_ptr, mo_mode);
1173 /* Drop it in the dungeon */
1174 (void)drop_near(q_ptr, -1, y, x);
1181 /* Get local object */
1184 /* Wipe the object */
1187 /* Activate restriction */
1188 get_obj_num_hook = kind_is_armor;
1190 /* Make a hard armor */
1191 make_object(q_ptr, mo_mode);
1193 /* Drop it in the dungeon */
1194 (void)drop_near(q_ptr, -1, y, x);
1201 /* Get local object */
1204 /* Wipe the object */
1207 /* Activate restriction */
1208 get_obj_num_hook = kind_is_hafted;
1210 /* Make a hafted weapon */
1211 make_object(q_ptr, mo_mode);
1213 /* Drop it in the dungeon */
1214 (void)drop_near(q_ptr, -1, y, x);
1219 if (m_ptr->r_idx != MON_STORMBRINGER)
1221 /* Get local object */
1224 /* Wipe the object */
1227 /* Activate restriction */
1228 get_obj_num_hook = kind_is_sword;
1231 make_object(q_ptr, mo_mode);
1233 /* Drop it in the dungeon */
1234 (void)drop_near(q_ptr, -1, y, x);
1241 /* Mega-Hack -- drop fixed items */
1242 if (drop_chosen_item)
1244 ARTIFACT_IDX a_idx = 0;
1247 for(i = 0; i < 4; i++)
1249 if(!r_ptr->artifact_id[i]) break;
1250 a_idx = r_ptr->artifact_id[i];
1251 chance = r_ptr->artifact_percent[i];
1254 if ((a_idx > 0) && ((randint0(100) < chance) || p_ptr->wizard))
1256 artifact_type *a_ptr = &a_info[a_idx];
1258 if (!a_ptr->cur_num)
1260 /* Create the artifact */
1261 if (create_named_art(a_idx, y, x))
1265 /* Hack -- Memorize location of artifact in saved floors */
1266 if (character_dungeon) a_ptr->floor_id = p_ptr->floor_id;
1268 else if (!preserve_mode) a_ptr->cur_num = 1;
1272 if ((r_ptr->flags7 & RF7_GUARDIAN) && (d_info[dungeon_type].final_guardian == m_ptr->r_idx))
1274 KIND_OBJECT_IDX k_idx = d_info[dungeon_type].final_object ? d_info[dungeon_type].final_object
1275 : lookup_kind(TV_SCROLL, SV_SCROLL_ACQUIREMENT);
1277 if (d_info[dungeon_type].final_artifact)
1279 a_idx = d_info[dungeon_type].final_artifact;
1280 artifact_type *a_ptr = &a_info[a_idx];
1282 if (!a_ptr->cur_num)
1284 /* Create the artifact */
1285 if (create_named_art(a_idx, y, x))
1289 /* Hack -- Memorize location of artifact in saved floors */
1290 if (character_dungeon) a_ptr->floor_id = p_ptr->floor_id;
1292 else if (!preserve_mode) a_ptr->cur_num = 1;
1294 /* Prevent rewarding both artifact and "default" object */
1295 if (!d_info[dungeon_type].final_object) k_idx = 0;
1301 /* Get local object */
1304 /* Prepare to make a reward */
1305 object_prep(q_ptr, k_idx);
1307 apply_magic(q_ptr, object_level, AM_NO_FIXED_ART | AM_GOOD);
1309 /* Drop it in the dungeon */
1310 (void)drop_near(q_ptr, -1, y, x);
1312 msg_format(_("あなたは%sを制覇した!", "You have conquered %s!"),d_name+d_info[dungeon_type].name);
1316 /* Determine how much we can drop */
1317 if ((r_ptr->flags1 & RF1_DROP_60) && (randint0(100) < 60)) number++;
1318 if ((r_ptr->flags1 & RF1_DROP_90) && (randint0(100) < 90)) number++;
1319 if (r_ptr->flags1 & RF1_DROP_1D2) number += damroll(1, 2);
1320 if (r_ptr->flags1 & RF1_DROP_2D2) number += damroll(2, 2);
1321 if (r_ptr->flags1 & RF1_DROP_3D2) number += damroll(3, 2);
1322 if (r_ptr->flags1 & RF1_DROP_4D2) number += damroll(4, 2);
1324 if (cloned && !(r_ptr->flags1 & RF1_UNIQUE))
1325 number = 0; /* Clones drop no stuff unless Cloning Pits */
1327 if (is_pet(m_ptr) || p_ptr->inside_battle || p_ptr->inside_arena)
1328 number = 0; /* Pets drop no stuff */
1329 if (!drop_item && (r_ptr->d_char != '$')) number = 0;
1331 if((r_ptr->flags2 & (RF2_MULTIPLY)) && (r_ptr->r_akills > 1024))
1332 number = 0; /* Limit of Multiply monster drop */
1334 /* Hack -- handle creeping coins */
1335 coin_type = force_coin;
1337 /* Average dungeon and monster levels */
1338 object_level = (dun_level + r_ptr->level) / 2;
1340 /* Drop some objects */
1341 for (j = 0; j < number; j++)
1343 /* Get local object */
1346 /* Wipe the object */
1350 if (do_gold && (!do_item || (randint0(100) < 50)))
1352 /* Make some gold */
1353 if (!make_gold(q_ptr)) continue;
1362 /* Make an object */
1363 if (!make_object(q_ptr, mo_mode)) continue;
1369 /* Drop it in the dungeon */
1370 (void)drop_near(q_ptr, -1, y, x);
1373 /* Reset the object level */
1374 object_level = base_level;
1376 /* Reset "coin" type */
1380 /* Take note of any dropped treasure */
1381 if (visible && (dump_item || dump_gold))
1383 /* Take notes on treasure */
1384 lore_treasure(m_idx, dump_item, dump_gold);
1387 /* Only process "Quest Monsters" */
1388 if (!(r_ptr->flags1 & RF1_QUESTOR)) return;
1389 if (p_ptr->inside_battle) return;
1392 if ((m_ptr->r_idx == MON_SERPENT) && !cloned)
1395 p_ptr->total_winner = TRUE;
1397 /* Redraw the "title" */
1398 p_ptr->redraw |= (PR_TITLE);
1400 play_music(TERM_XTRA_MUSIC_BASIC, MUSIC_BASIC_FINAL_QUEST_CLEAR);
1402 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, _("見事に変愚蛮怒の勝利者となった!", "become *WINNER* of Hengband finely!"));
1404 if ((p_ptr->pclass == CLASS_CHAOS_WARRIOR) || (p_ptr->muta2 & MUT2_CHAOS_GIFT))
1406 msg_format(_("%sからの声が響いた。", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
1407 msg_print(_("『よくやった、定命の者よ!』", "'Thou art donst well, mortal!'"));
1410 /* Congratulations */
1411 msg_print(_("*** おめでとう ***", "*** CONGRATULATIONS ***"));
1412 msg_print(_("あなたはゲームをコンプリートしました。", "You have won the game!"));
1413 msg_print(_("準備が整ったら引退(自殺コマンド)しても結構です。", "You may retire (commit suicide) when you are ready."));
1418 * @brief モンスターに与えたダメージの修正処理 /
1419 * Modify the physical damage done to the monster.
1420 * @param m_ptr ダメージを受けるモンスターの構造体参照ポインタ
1421 * @param dam ダメージ基本値
1422 * @param is_psy_spear 攻撃手段が光の剣ならばTRUE
1423 * @return 修正を行った結果のダメージ量
1426 * (for example when it's invulnerable or shielded)
1427 * ToDo: Accept a damage-type to calculate the modified damage from
1428 * things like fire, frost, lightning, poison, ... attacks.
1429 * "type" is not yet used and should be 0.
1432 HIT_POINT mon_damage_mod(monster_type *m_ptr, HIT_POINT dam, bool is_psy_spear)
1434 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1436 if ((r_ptr->flagsr & RFR_RES_ALL) && dam > 0)
1439 if ((dam == 0) && one_in_(3)) dam = 1;
1442 if (MON_INVULNER(m_ptr))
1446 if (!p_ptr->blind && is_seen(m_ptr))
1448 msg_print(_("バリアを切り裂いた!", "The barrier is penetrated!"));
1451 else if (!one_in_(PENETRATE_INVULNERABILITY))
1461 * @brief モンスターに与えたダメージを元に経験値を加算する /
1462 * Calculate experience point to be get
1463 * @param dam 与えたダメージ量
1464 * @param m_ptr ダメージを与えたモンスターの構造体参照ポインタ
1468 * Even the 64 bit operation is not big enough to avoid overflaw
1469 * unless we carefully choose orders of multiplication and division.
1470 * Get the coefficient first, and multiply (potentially huge) base
1471 * experience point of a monster later.
1474 static void get_exp_from_mon(HIT_POINT dam, monster_type *m_ptr)
1476 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1483 if (!m_ptr->r_idx) return;
1484 if (is_pet(m_ptr) || p_ptr->inside_battle) return;
1487 * - Ratio of monster's level to player's level effects
1488 * - Varying speed effects
1489 * - Get a fraction in proportion of damage point
1491 new_exp = r_ptr->level * SPEED_TO_ENERGY(m_ptr->mspeed) * dam;
1494 div_l = (p_ptr->max_plv+2) * SPEED_TO_ENERGY(r_ptr->speed);
1496 /* Use (average maxhp * 2) as a denominator */
1497 if (!(r_ptr->flags1 & RF1_FORCE_MAXHP))
1498 s64b_mul(&div_h, &div_l, 0, r_ptr->hdice * (ironman_nightmare ? 2 : 1) * (r_ptr->hside + 1));
1500 s64b_mul(&div_h, &div_l, 0, r_ptr->hdice * (ironman_nightmare ? 2 : 1) * r_ptr->hside * 2);
1502 /* Special penalty in the wilderness */
1503 if (!dun_level && (!(r_ptr->flags8 & RF8_WILD_ONLY) || !(r_ptr->flags1 & RF1_UNIQUE)))
1504 s64b_mul(&div_h, &div_l, 0, 5);
1506 /* Do division first to prevent overflaw */
1507 s64b_div(&new_exp, &new_exp_frac, div_h, div_l);
1509 /* Special penalty for mutiply-monster */
1510 if ((r_ptr->flags2 & RF2_MULTIPLY) || (m_ptr->r_idx == MON_DAWN))
1512 int monnum_penarty = r_ptr->r_akills / 400;
1513 if (monnum_penarty > 8) monnum_penarty = 8;
1515 while (monnum_penarty--)
1518 s64b_RSHIFT(new_exp, new_exp_frac, 2);
1522 /* Special penalty for rest_and_shoot exp scum */
1523 if ((m_ptr->dealt_damage > m_ptr->max_maxhp) && (m_ptr->hp >= 0))
1525 int over_damage = m_ptr->dealt_damage / m_ptr->max_maxhp;
1526 if (over_damage > 32) over_damage = 32;
1528 while (over_damage--)
1531 s64b_mul(&new_exp, &new_exp_frac, 0, 9);
1532 s64b_div(&new_exp, &new_exp_frac, 0, 10);
1536 /* Finally multiply base experience point of the monster */
1537 s64b_mul(&new_exp, &new_exp_frac, 0, r_ptr->mexp);
1539 /* Gain experience */
1540 gain_exp_64(new_exp, new_exp_frac);
1545 * @brief モンスターのHPをダメージに応じて減算する /
1546 * Decreases monsters hit points, handling monster death.
1547 * @param dam 与えたダメージ量
1548 * @param m_idx ダメージを与えたモンスターのID
1549 * @param fear ダメージによってモンスターが恐慌状態に陥ったならばTRUEを返す
1550 * @param note モンスターが倒された際の特別なメッセージ述語
1554 * We return TRUE if the monster has been killed (and deleted).
1555 * We announce monster death (using an optional "death message"
1556 * if given, and a otherwise a generic killed/destroyed message).
1557 * Only "physical attacks" can induce the "You have slain" message.
1558 * Missile and Spell attacks will induce the "dies" message, or
1559 * various "specialized" messages. Note that "You have destroyed"
1560 * and "is destroyed" are synonyms for "You have slain" and "dies".
1561 * Hack -- unseen monsters yield "You have killed it." message.
1562 * Added fear (DGK) and check whether to print fear messages -CWS
1563 * Made name, sex, and capitalization generic -BEN-
1564 * As always, the "ghost" processing is a total hack.
1565 * Hack -- we "delay" fear messages by passing around a "fear" flag.
1566 * XXX XXX XXX Consider decreasing monster experience over time, say,
1567 * by using "(m_exp * m_lev * (m_lev)) / (p_lev * (m_lev + n_killed))"
1568 * instead of simply "(m_exp * m_lev) / (p_lev)", to make the first
1569 * monster worth more than subsequent monsters. This would also need
1570 * to induce changes in the monster recall code.
1573 bool mon_take_hit(MONSTER_IDX m_idx, HIT_POINT dam, bool *fear, cptr note)
1575 monster_type *m_ptr = &m_list[m_idx];
1576 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1578 monster_type exp_mon;
1580 /* Innocent until proven otherwise */
1581 bool innocent = TRUE, thief = FALSE;
1585 (void)COPY(&exp_mon, m_ptr, monster_type);
1587 expdam = (m_ptr->hp > dam) ? dam : m_ptr->hp;
1589 get_exp_from_mon(expdam, &exp_mon);
1591 /* Genocided by chaos patron */
1592 if (!m_ptr->r_idx) m_idx = 0;
1594 /* Redraw (later) if needed */
1595 if (p_ptr->health_who == m_idx) p_ptr->redraw |= (PR_HEALTH);
1596 if (p_ptr->riding == m_idx) p_ptr->redraw |= (PR_UHEALTH);
1599 (void)set_monster_csleep(m_idx, 0);
1601 /* Hack - Cancel any special player stealth magics. -LM- */
1602 if (p_ptr->special_defense & NINJA_S_STEALTH)
1604 set_superstealth(FALSE);
1607 /* Genocided by chaos patron */
1608 if (!m_idx) return TRUE;
1613 m_ptr->dealt_damage += dam;
1614 if(m_ptr->dealt_damage > m_ptr->max_maxhp * 100) m_ptr->dealt_damage = m_ptr->max_maxhp * 100;
1617 msg_format( _("合計%d/%dのダメージを与えた。","You do %d (out of %d) damage."),
1618 m_ptr->dealt_damage, m_ptr->maxhp);
1621 /* It is dead now */
1626 if (r_info[m_ptr->r_idx].flags7 & RF7_TANUKI)
1628 /* You might have unmasked Tanuki first time */
1629 r_ptr = &r_info[m_ptr->r_idx];
1630 m_ptr->ap_r_idx = m_ptr->r_idx;
1631 if (r_ptr->r_sights < MAX_SHORT) r_ptr->r_sights++;
1634 if (m_ptr->mflag2 & MFLAG2_CHAMELEON)
1636 /* You might have unmasked Chameleon first time */
1637 r_ptr = real_r_ptr(m_ptr);
1638 if (r_ptr->r_sights < MAX_SHORT) r_ptr->r_sights++;
1641 if (!(m_ptr->smart & SM_CLONED))
1643 /* When the player kills a Unique, it stays dead */
1644 if (r_ptr->flags1 & RF1_UNIQUE)
1648 /* Mega-Hack -- Banor & Lupart */
1649 if ((m_ptr->r_idx == MON_BANOR) || (m_ptr->r_idx == MON_LUPART))
1651 r_info[MON_BANORLUPART].max_num = 0;
1652 r_info[MON_BANORLUPART].r_pkills++;
1653 r_info[MON_BANORLUPART].r_akills++;
1654 if (r_info[MON_BANORLUPART].r_tkills < MAX_SHORT) r_info[MON_BANORLUPART].r_tkills++;
1656 else if (m_ptr->r_idx == MON_BANORLUPART)
1658 r_info[MON_BANOR].max_num = 0;
1659 r_info[MON_BANOR].r_pkills++;
1660 r_info[MON_BANOR].r_akills++;
1661 if (r_info[MON_BANOR].r_tkills < MAX_SHORT) r_info[MON_BANOR].r_tkills++;
1662 r_info[MON_LUPART].max_num = 0;
1663 r_info[MON_LUPART].r_pkills++;
1664 r_info[MON_LUPART].r_akills++;
1665 if (r_info[MON_LUPART].r_tkills < MAX_SHORT) r_info[MON_LUPART].r_tkills++;
1669 /* When the player kills a Nazgul, it stays dead */
1670 else if (r_ptr->flags7 & RF7_NAZGUL) r_ptr->max_num--;
1673 /* Count all monsters killed */
1674 if (r_ptr->r_akills < MAX_SHORT) r_ptr->r_akills++;
1676 /* Recall even invisible uniques or winners */
1677 if ((m_ptr->ml && !p_ptr->image) || (r_ptr->flags1 & RF1_UNIQUE))
1679 /* Count kills this life */
1680 if ((m_ptr->mflag2 & MFLAG2_KAGE) && (r_info[MON_KAGE].r_pkills < MAX_SHORT)) r_info[MON_KAGE].r_pkills++;
1681 else if (r_ptr->r_pkills < MAX_SHORT) r_ptr->r_pkills++;
1683 /* Count kills in all lives */
1684 if ((m_ptr->mflag2 & MFLAG2_KAGE) && (r_info[MON_KAGE].r_tkills < MAX_SHORT)) r_info[MON_KAGE].r_tkills++;
1685 else if (r_ptr->r_tkills < MAX_SHORT) r_ptr->r_tkills++;
1687 /* Hack -- Auto-recall */
1688 monster_race_track(m_ptr->ap_r_idx);
1691 /* Extract monster name */
1692 monster_desc(m_name, m_ptr, MD_TRUE_NAME);
1694 /* Don't kill Amberites */
1695 if ((r_ptr->flags3 & RF3_AMBERITE) && one_in_(2))
1697 int curses = 1 + randint1(3);
1698 bool stop_ty = FALSE;
1701 msg_format(_("%^sは恐ろしい血の呪いをあなたにかけた!", "%^s puts a terrible blood curse on you!"), m_name);
1702 curse_equipment(100, 50);
1706 stop_ty = activate_ty_curse(stop_ty, &count);
1711 if (r_ptr->flags2 & RF2_CAN_SPEAK)
1713 char line_got[1024];
1715 /* Dump a message */
1716 if (!get_rnd_line(_("mondeath_j.txt", "mondeath.txt"), m_ptr->r_idx, line_got))
1718 msg_format("%^s %s", m_name, line_got);
1721 if (m_ptr->r_idx == MON_SERPENT)
1723 /* Make screen dump */
1724 screen_dump = make_screen_dump();
1729 if (!(d_info[dungeon_type].flags1 & DF1_BEGINNER))
1731 if (!dun_level && !ambush_flag && !p_ptr->inside_arena)
1733 chg_virtue(V_VALOUR, -1);
1735 else if (r_ptr->level > dun_level)
1737 if (randint1(10) <= (r_ptr->level - dun_level))
1738 chg_virtue(V_VALOUR, 1);
1740 if (r_ptr->level > 60)
1742 chg_virtue(V_VALOUR, 1);
1744 if (r_ptr->level >= 2 * (p_ptr->lev+1))
1745 chg_virtue(V_VALOUR, 2);
1748 if (r_ptr->flags1 & RF1_UNIQUE)
1750 if (r_ptr->flags3 & (RF3_EVIL | RF3_GOOD)) chg_virtue(V_HARMONY, 2);
1752 if (r_ptr->flags3 & RF3_GOOD)
1754 chg_virtue(V_UNLIFE, 2);
1755 chg_virtue(V_VITALITY, -2);
1758 if (one_in_(3)) chg_virtue(V_INDIVIDUALISM, -1);
1761 if (m_ptr->r_idx == MON_BEGGAR || m_ptr->r_idx == MON_LEPER)
1763 chg_virtue(V_COMPASSION, -1);
1766 if ((r_ptr->flags3 & RF3_GOOD) &&
1767 ((r_ptr->level) / 10 + (3 * dun_level) >= randint1(100)))
1768 chg_virtue(V_UNLIFE, 1);
1770 if (r_ptr->d_char == 'A')
1772 if (r_ptr->flags1 & RF1_UNIQUE)
1773 chg_virtue(V_FAITH, -2);
1774 else if ((r_ptr->level) / 10 + (3 * dun_level) >= randint1(100))
1776 if (r_ptr->flags3 & RF3_GOOD) chg_virtue(V_FAITH, -1);
1777 else chg_virtue(V_FAITH, 1);
1780 else if (r_ptr->flags3 & RF3_DEMON)
1782 if (r_ptr->flags1 & RF1_UNIQUE)
1783 chg_virtue(V_FAITH, 2);
1784 else if ((r_ptr->level) / 10 + (3 * dun_level) >= randint1(100))
1785 chg_virtue(V_FAITH, 1);
1788 if ((r_ptr->flags3 & RF3_UNDEAD) && (r_ptr->flags1 & RF1_UNIQUE))
1789 chg_virtue(V_VITALITY, 2);
1791 if (r_ptr->r_deaths)
1793 if (r_ptr->flags1 & RF1_UNIQUE)
1795 chg_virtue(V_HONOUR, 10);
1797 else if ((r_ptr->level) / 10 + (2 * dun_level) >= randint1(100))
1799 chg_virtue(V_HONOUR, 1);
1802 if ((r_ptr->flags2 & RF2_MULTIPLY) && (r_ptr->r_akills > 1000) && one_in_(10))
1804 chg_virtue(V_VALOUR, -1);
1807 for (i = 0; i < 4; i++)
1809 if (r_ptr->blow[i].d_dice != 0) innocent = FALSE; /* Murderer! */
1811 if ((r_ptr->blow[i].effect == RBE_EAT_ITEM)
1812 || (r_ptr->blow[i].effect == RBE_EAT_GOLD))
1814 thief = TRUE; /* Thief! */
1817 /* The new law says it is illegal to live in the dungeon */
1818 if (r_ptr->level != 0) innocent = FALSE;
1822 if (r_ptr->flags1 & RF1_UNIQUE)
1823 chg_virtue(V_JUSTICE, 3);
1824 else if (1+((r_ptr->level) / 10 + (2 * dun_level))
1826 chg_virtue(V_JUSTICE, 1);
1830 chg_virtue (V_JUSTICE, -1);
1833 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)))
1835 if (one_in_(4)) chg_virtue(V_NATURE, -1);
1838 if ((r_ptr->flags1 & RF1_UNIQUE) && record_destroy_uniq)
1842 sprintf(note_buf, "%s%s", r_name + r_ptr->name, (m_ptr->smart & SM_CLONED) ? "(クローン)" : "");
1844 sprintf(note_buf, "%s%s", r_name + r_ptr->name, (m_ptr->smart & SM_CLONED) ? "(Clone)" : "");
1846 do_cmd_write_nikki(NIKKI_UNIQUE, 0, note_buf);
1852 /* Death by Missile/Spell attack */
1855 msg_format("%^s%s", m_name, note);
1858 /* Death by physical attack -- invisible monster */
1859 else if (!m_ptr->ml)
1862 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
1863 msg_format("せっかくだから%sを殺した。", m_name);
1865 msg_format("%sを殺した。", m_name);
1867 msg_format("You have killed %s.", m_name);
1872 /* Death by Physical attack -- non-living monster */
1873 else if (!monster_living(r_ptr))
1875 bool explode = FALSE;
1877 for (i = 0; i < 4; i++)
1879 if (r_ptr->blow[i].method == RBM_EXPLODE) explode = TRUE;
1882 /* Special note at death */
1884 msg_format(_("%sは爆発して粉々になった。", "%^s explodes into tiny shreds."), m_name);
1888 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
1889 msg_format("せっかくだから%sを倒した。", m_name);
1891 msg_format("%sを倒した。", m_name);
1893 msg_format("You have destroyed %s.", m_name);
1898 /* Death by Physical attack -- living monster */
1902 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
1903 msg_format("せっかくだから%sを葬り去った。", m_name);
1905 msg_format("%sを葬り去った。", m_name);
1907 msg_format("You have slain %s.", m_name);
1911 if ((r_ptr->flags1 & RF1_UNIQUE) && !(m_ptr->smart & SM_CLONED) && !vanilla_town)
1913 for (i = 0; i < MAX_KUBI; i++)
1915 if ((kubi_r_idx[i] == m_ptr->r_idx) && !(m_ptr->mflag2 & MFLAG2_CHAMELEON))
1917 msg_format(_("%sの首には賞金がかかっている。", "There is a price on %s's head."), m_name);
1923 /* Generate treasure */
1924 monster_death(m_idx, TRUE);
1926 /* Mega hack : replace IKETA to BIKETAL */
1927 if ((m_ptr->r_idx == MON_IKETA) &&
1928 !(p_ptr->inside_arena || p_ptr->inside_battle))
1930 int dummy_y = m_ptr->fy;
1931 int dummy_x = m_ptr->fx;
1932 BIT_FLAGS mode = 0L;
1934 if (is_pet(m_ptr)) mode |= PM_FORCE_PET;
1936 /* Delete the monster */
1937 delete_monster_idx(m_idx);
1939 if (summon_named_creature(0, dummy_y, dummy_x, MON_BIKETAL, mode))
1941 msg_print(_("「ハァッハッハッハ!!私がバイケタルだ!!」", "Uwa-hahaha! *I* am Biketal!"));
1946 /* Delete the monster */
1947 delete_monster_idx(m_idx);
1950 get_exp_from_mon((long)exp_mon.max_maxhp*2, &exp_mon);
1955 /* Monster is dead */
1962 /* Mega-Hack -- Pain cancels fear */
1963 if (MON_MONFEAR(m_ptr) && (dam > 0))
1966 if (set_monster_monfear(m_idx, MON_MONFEAR(m_ptr) - randint1(dam)))
1973 /* Sometimes a monster gets scared by damage */
1974 if (!MON_MONFEAR(m_ptr) && !(r_ptr->flags3 & (RF3_NO_FEAR)))
1976 /* Percentage of fully healthy */
1977 int percentage = (100L * m_ptr->hp) / m_ptr->maxhp;
1980 * Run (sometimes) if at 10% or less of max hit points,
1981 * or (usually) when hit for half its current hit points
1983 if ((randint1(10) >= percentage) ||
1984 ((dam >= m_ptr->hp) && (randint0(100) < 80)))
1986 /* Hack -- note fear */
1989 /* XXX XXX XXX Hack -- Add some timed fear */
1990 (void)set_monster_monfear(m_idx, (randint1(10) +
1991 (((dam >= m_ptr->hp) && (percentage > 7)) ?
1992 20 : ((11 - percentage) * 5))));
1999 if (p_ptr->riding && (p_ptr->riding == m_idx) && (dam > 0))
2003 /* Extract monster name */
2004 monster_desc(m_name, m_ptr, 0);
2006 if (m_ptr->hp > m_ptr->maxhp/3) dam = (dam + 1) / 2;
2007 if (rakuba((dam > 200) ? 200 : dam, FALSE))
2009 msg_format(_("%^sに振り落とされた!", "%^s has thrown you off!"), m_name);
2020 * @brief 現在のコンソール表示の縦横を返す。 /
2021 * Get term size and calculate screen size
2022 * @param wid_p コンソールの表示幅文字数を返す
2023 * @param hgt_p コンソールの表示行数を返す
2026 void get_screen_size(TERM_LEN *wid_p, TERM_LEN *hgt_p)
2028 Term_get_size(wid_p, hgt_p);
2029 *hgt_p -= ROW_MAP + 2;
2030 *wid_p -= COL_MAP + 2;
2031 if (use_bigtile) *wid_p /= 2;
2036 * @brief コンソール上におけるマップ表示の左上位置を返す /
2037 * Calculates current boundaries Called below and from "do_cmd_locate()".
2040 void panel_bounds_center(void)
2045 get_screen_size(&wid, &hgt);
2047 panel_row_max = panel_row_min + hgt - 1;
2048 panel_row_prt = panel_row_min - 1;
2049 panel_col_max = panel_col_min + wid - 1;
2050 panel_col_prt = panel_col_min - 13;
2055 * @brief コンソールのリサイズに合わせてマップを再描画する /
2056 * Map resizing whenever the main term changes size
2059 void resize_map(void)
2061 /* Only if the dungeon exists */
2062 if (!character_dungeon) return;
2064 /* Mega-Hack -- no panel yet */
2068 /* Reset the panels */
2069 panel_row_min = cur_hgt;
2070 panel_col_min = cur_wid;
2075 p_ptr->update |= (PU_TORCH | PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
2077 /* Forget lite/view */
2078 p_ptr->update |= (PU_UN_VIEW | PU_UN_LITE);
2080 /* Update lite/view */
2081 p_ptr->update |= (PU_VIEW | PU_LITE | PU_MON_LITE);
2083 /* Update monsters */
2084 p_ptr->update |= (PU_MONSTERS);
2086 /* Redraw everything */
2087 p_ptr->redraw |= (PR_WIPE | PR_BASIC | PR_EXTRA | PR_MAP | PR_EQUIPPY);
2089 /* Hack -- update */
2097 * Place the cursor on the player
2099 if (can_save) move_cursor_relative(p_ptr->y, p_ptr->x);
2106 * @brief コンソールを再描画する /
2107 * Redraw a term when it is resized
2110 void redraw_window(void)
2112 /* Only if the dungeon exists */
2113 if (!character_dungeon) return;
2116 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_SPELL | PW_PLAYER);
2119 p_ptr->window |= (PW_MESSAGE | PW_OVERHEAD | PW_DUNGEON | PW_MONSTER | PW_OBJECT);
2121 /* Hack -- update */
2130 * @brief フォーカスを当てるべきマップ描画の基準座標を指定する(サブルーチン)
2131 * @param dy 変更先のフロアY座標
2132 * @param dx 変更先のフロアX座標
2133 * Handle a request to change the current panel
2134 * Return TRUE if the panel was changed.
2135 * Also used in do_cmd_locate
2136 * @return 実際に再描画が必要だった場合TRUEを返す
2138 bool change_panel(POSITION dy, POSITION dx)
2144 get_screen_size(&wid, &hgt);
2146 /* Apply the motion */
2147 y = panel_row_min + dy * hgt / 2;
2148 x = panel_col_min + dx * wid / 2;
2150 /* Verify the row */
2151 if (y > cur_hgt - hgt) y = cur_hgt - hgt;
2154 /* Verify the col */
2155 if (x > cur_wid - wid) x = cur_wid - wid;
2158 /* Handle "changes" */
2159 if ((y != panel_row_min) || (x != panel_col_min))
2161 /* Save the new panel info */
2165 /* Recalculate the boundaries */
2166 panel_bounds_center();
2169 p_ptr->update |= (PU_MONSTERS);
2172 p_ptr->redraw |= (PR_MAP);
2186 * @brief フォーカスを当てるべきマップ描画の基準座標を指定する
2187 * @param y 変更先のフロアY座標
2188 * @param x 変更先のフロアX座標
2190 * Handle a request to change the current panel
2191 * Return TRUE if the panel was changed.
2192 * Also used in do_cmd_locate
2193 * @return 実際に再描画が必要だった場合TRUEを返す
2195 static bool change_panel_xy(POSITION y, POSITION x)
2197 POSITION dy = 0, dx = 0;
2201 get_screen_size(&wid, &hgt);
2203 if (y < panel_row_min) dy = -1;
2204 if (y > panel_row_max) dy = 1;
2205 if (x < panel_col_min) dx = -1;
2206 if (x > panel_col_max) dx = 1;
2208 if (!dy && !dx) return (FALSE);
2210 return change_panel(dy, dx);
2215 * @brief マップ描画のフォーカスを当てるべき座標を更新する
2217 * Given an row (y) and col (x), this routine detects when a move
2218 * off the screen has occurred and figures new borders. -RAK-
2219 * "Update" forces a "full update" to take place.
2220 * The map is reprinted if necessary, and "TRUE" is returned.
2221 * @return 実際に再描画が必要だった場合TRUEを返す
2223 void verify_panel(void)
2225 POSITION y = p_ptr->y;
2226 POSITION x = p_ptr->x;
2235 get_screen_size(&wid, &hgt);
2237 max_prow_min = cur_hgt - hgt;
2238 max_pcol_min = cur_wid - wid;
2240 /* Bounds checking */
2241 if (max_prow_min < 0) max_prow_min = 0;
2242 if (max_pcol_min < 0) max_pcol_min = 0;
2244 /* Center on player */
2245 if (center_player && (center_running || !running))
2247 /* Center vertically */
2248 prow_min = y - hgt / 2;
2249 if (prow_min < 0) prow_min = 0;
2250 else if (prow_min > max_prow_min) prow_min = max_prow_min;
2252 /* Center horizontally */
2253 pcol_min = x - wid / 2;
2254 if (pcol_min < 0) pcol_min = 0;
2255 else if (pcol_min > max_pcol_min) pcol_min = max_pcol_min;
2259 prow_min = panel_row_min;
2260 pcol_min = panel_col_min;
2262 /* Scroll screen when 2 grids from top/bottom edge */
2263 if (y > panel_row_max - 2)
2265 while (y > prow_min + hgt-1 - 2)
2267 prow_min += (hgt / 2);
2271 if (y < panel_row_min + 2)
2273 while (y < prow_min + 2)
2275 prow_min -= (hgt / 2);
2279 if (prow_min > max_prow_min) prow_min = max_prow_min;
2280 if (prow_min < 0) prow_min = 0;
2282 /* Scroll screen when 4 grids from left/right edge */
2283 if (x > panel_col_max - 4)
2285 while (x > pcol_min + wid-1 - 4)
2287 pcol_min += (wid / 2);
2291 if (x < panel_col_min + 4)
2293 while (x < pcol_min + 4)
2295 pcol_min -= (wid / 2);
2299 if (pcol_min > max_pcol_min) pcol_min = max_pcol_min;
2300 if (pcol_min < 0) pcol_min = 0;
2303 /* Check for "no change" */
2304 if ((prow_min == panel_row_min) && (pcol_min == panel_col_min)) return;
2306 /* Save the new panel info */
2307 panel_row_min = prow_min;
2308 panel_col_min = pcol_min;
2310 /* Hack -- optional disturb on "panel change" */
2311 if (disturb_panel && !center_player) disturb(0, 0);
2313 /* Recalculate the boundaries */
2314 panel_bounds_center();
2317 p_ptr->update |= (PU_MONSTERS);
2320 p_ptr->redraw |= (PR_MAP);
2323 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
2328 * Monster health description
2330 cptr look_mon_desc(monster_type *m_ptr, BIT_FLAGS mode)
2332 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
2339 /* Determine if the monster is "living" */
2340 living = monster_living(ap_r_ptr);
2342 /* Calculate a health "percentage" */
2343 perc = 100L * m_ptr->hp / m_ptr->maxhp;
2345 /* Healthy monsters */
2346 if (m_ptr->hp >= m_ptr->maxhp)
2350 desc = living ? "無傷" : "無ダメージ";
2352 desc = living ? "unhurt" : "undamaged";
2357 else if (perc >= 60)
2360 desc = living ? "軽傷" : "小ダメージ";
2362 desc = living ? "somewhat wounded" : "somewhat damaged";
2367 else if (perc >= 25)
2370 desc = living ? "負傷" : "中ダメージ";
2372 desc = living ? "wounded" : "damaged";
2377 else if (perc >= 10)
2380 desc = living ? "重傷" : "大ダメージ";
2382 desc = living ? "badly wounded" : "badly damaged";
2390 desc = living ? "半死半生" : "倒れかけ";
2392 desc = living ? "almost dead" : "almost destroyed";
2397 /* Need attitude information? */
2400 /* Full information is not needed */
2403 else if (is_pet(m_ptr))
2405 attitude = _(", ペット", ", pet");
2407 else if (is_friendly(m_ptr))
2409 attitude = _(", 友好的", ", friendly");
2413 attitude = _("", "");
2417 /* Clone monster? */
2418 if (m_ptr->smart & SM_CLONED)
2427 /* Display monster's level --- idea borrowed from ToME */
2428 if (ap_r_ptr->r_tkills && !(m_ptr->mflag2 & MFLAG2_KAGE))
2430 return format(_("レベル%d, %s%s%s", "Level %d, %s%s%s"), ap_r_ptr->level, desc, attitude, clone);
2434 return format(_("レベル???, %s%s%s", "Level ???, %s%s%s"), desc, attitude, clone);
2441 * Angband sorting algorithm -- quick sort in place
2443 * Note that the details of the data we are sorting is hidden,
2444 * and we rely on the "ang_sort_comp()" and "ang_sort_swap()"
2445 * function hooks to interact with the data, which is given as
2446 * two pointers, and which may have any user-defined form.
2448 void ang_sort_aux(vptr u, vptr v, int p, int q)
2466 while (!(*ang_sort_comp)(u, v, b, z)) b--;
2469 while (!(*ang_sort_comp)(u, v, z, a)) a++;
2471 /* Done partition */
2475 (*ang_sort_swap)(u, v, a, b);
2481 /* Recurse left side */
2482 ang_sort_aux(u, v, p, b);
2484 /* Recurse right side */
2485 ang_sort_aux(u, v, b+1, q);
2490 * Angband sorting algorithm -- quick sort in place
2492 * Note that the details of the data we are sorting is hidden,
2493 * and we rely on the "ang_sort_comp()" and "ang_sort_swap()"
2494 * function hooks to interact with the data, which is given as
2495 * two pointers, and which may have any user-defined form.
2497 void ang_sort(vptr u, vptr v, int n)
2499 /* Sort the array */
2500 ang_sort_aux(u, v, 0, n-1);
2505 /*** Targeting Code ***/
2509 * Determine is a monster makes a reasonable target
2511 * The concept of "targeting" was stolen from "Morgul" (?)
2513 * The player can target any location, or any "target-able" monster.
2515 * Currently, a monster is "target_able" if it is visible, and if
2516 * the player can hit it with a projection, and the player is not
2517 * hallucinating. This allows use of "use closest target" macros.
2519 * Future versions may restrict the ability to target "trappers"
2520 * and "mimics", but the semantics is a little bit weird.
2522 bool target_able(MONSTER_IDX m_idx)
2524 monster_type *m_ptr = &m_list[m_idx];
2526 /* Monster must be alive */
2527 if (!m_ptr->r_idx) return (FALSE);
2529 /* Hack -- no targeting hallucinations */
2530 if (p_ptr->image) return (FALSE);
2532 /* Monster must be visible */
2533 if (!m_ptr->ml) return (FALSE);
2535 if (p_ptr->riding && (p_ptr->riding == m_idx)) return (TRUE);
2537 /* Monster must be projectable */
2538 if (!projectable(p_ptr->y, p_ptr->x, m_ptr->fy, m_ptr->fx)) return (FALSE);
2540 /* XXX XXX XXX Hack -- Never target trappers */
2541 /* if (CLEAR_ATTR && (CLEAR_CHAR)) return (FALSE); */
2551 * Update (if necessary) and verify (if possible) the target.
2553 * We return TRUE if the target is "okay" and FALSE otherwise.
2555 bool target_okay(void)
2557 /* Accept stationary targets */
2558 if (target_who < 0) return (TRUE);
2560 /* Check moving targets */
2563 /* Accept reasonable targets */
2564 if (target_able(target_who))
2566 monster_type *m_ptr = &m_list[target_who];
2568 /* Acquire monster location */
2569 target_row = m_ptr->fy;
2570 target_col = m_ptr->fx;
2577 /* Assume no target */
2583 * Sorting hook -- comp function -- by "distance to player"
2585 * We use "u" and "v" to point to arrays of "x" and "y" positions,
2586 * and sort the arrays by double-distance to the player.
2588 static bool ang_sort_comp_distance(vptr u, vptr v, int a, int b)
2590 POSITION *x = (POSITION*)(u);
2591 POSITION *y = (POSITION*)(v);
2593 POSITION da, db, kx, ky;
2595 /* Absolute distance components */
2596 kx = x[a]; kx -= p_ptr->x; kx = ABS(kx);
2597 ky = y[a]; ky -= p_ptr->y; ky = ABS(ky);
2599 /* Approximate Double Distance to the first point */
2600 da = ((kx > ky) ? (kx + kx + ky) : (ky + ky + kx));
2602 /* Absolute distance components */
2603 kx = x[b]; kx -= p_ptr->x; kx = ABS(kx);
2604 ky = y[b]; ky -= p_ptr->y; ky = ABS(ky);
2606 /* Approximate Double Distance to the first point */
2607 db = ((kx > ky) ? (kx + kx + ky) : (ky + ky + kx));
2609 /* Compare the distances */
2615 * Sorting hook -- comp function -- by importance level of grids
2617 * We use "u" and "v" to point to arrays of "x" and "y" positions,
2618 * and sort the arrays by level of monster
2620 static bool ang_sort_comp_importance(vptr u, vptr v, int a, int b)
2622 POSITION *x = (POSITION*)(u);
2623 POSITION *y = (POSITION*)(v);
2624 cave_type *ca_ptr = &cave[y[a]][x[a]];
2625 cave_type *cb_ptr = &cave[y[b]][x[b]];
2626 monster_type *ma_ptr = &m_list[ca_ptr->m_idx];
2627 monster_type *mb_ptr = &m_list[cb_ptr->m_idx];
2628 monster_race *ap_ra_ptr, *ap_rb_ptr;
2630 /* The player grid */
2631 if (y[a] == p_ptr->y && x[a] == p_ptr->x) return TRUE;
2632 if (y[b] == p_ptr->y && x[b] == p_ptr->x) return FALSE;
2634 /* Extract monster race */
2635 if (ca_ptr->m_idx && ma_ptr->ml) ap_ra_ptr = &r_info[ma_ptr->ap_r_idx];
2636 else ap_ra_ptr = NULL;
2637 if (cb_ptr->m_idx && mb_ptr->ml) ap_rb_ptr = &r_info[mb_ptr->ap_r_idx];
2638 else ap_rb_ptr = NULL;
2640 if (ap_ra_ptr && !ap_rb_ptr) return TRUE;
2641 if (!ap_ra_ptr && ap_rb_ptr) return FALSE;
2643 /* Compare two monsters */
2644 if (ap_ra_ptr && ap_rb_ptr)
2646 /* Unique monsters first */
2647 if ((ap_ra_ptr->flags1 & RF1_UNIQUE) && !(ap_rb_ptr->flags1 & RF1_UNIQUE)) return TRUE;
2648 if (!(ap_ra_ptr->flags1 & RF1_UNIQUE) && (ap_rb_ptr->flags1 & RF1_UNIQUE)) return FALSE;
2650 /* Shadowers first (あやしい影) */
2651 if ((ma_ptr->mflag2 & MFLAG2_KAGE) && !(mb_ptr->mflag2 & MFLAG2_KAGE)) return TRUE;
2652 if (!(ma_ptr->mflag2 & MFLAG2_KAGE) && (mb_ptr->mflag2 & MFLAG2_KAGE)) return FALSE;
2654 /* Unknown monsters first */
2655 if (!ap_ra_ptr->r_tkills && ap_rb_ptr->r_tkills) return TRUE;
2656 if (ap_ra_ptr->r_tkills && !ap_rb_ptr->r_tkills) return FALSE;
2658 /* Higher level monsters first (if known) */
2659 if (ap_ra_ptr->r_tkills && ap_rb_ptr->r_tkills)
2661 if (ap_ra_ptr->level > ap_rb_ptr->level) return TRUE;
2662 if (ap_ra_ptr->level < ap_rb_ptr->level) return FALSE;
2665 /* Sort by index if all conditions are same */
2666 if (ma_ptr->ap_r_idx > mb_ptr->ap_r_idx) return TRUE;
2667 if (ma_ptr->ap_r_idx < mb_ptr->ap_r_idx) return FALSE;
2670 /* An object get higher priority */
2671 if (cave[y[a]][x[a]].o_idx && !cave[y[b]][x[b]].o_idx) return TRUE;
2672 if (!cave[y[a]][x[a]].o_idx && cave[y[b]][x[b]].o_idx) return FALSE;
2674 /* Priority from the terrain */
2675 if (f_info[ca_ptr->feat].priority > f_info[cb_ptr->feat].priority) return TRUE;
2676 if (f_info[ca_ptr->feat].priority < f_info[cb_ptr->feat].priority) return FALSE;
2678 /* If all conditions are same, compare distance */
2679 return ang_sort_comp_distance(u, v, a, b);
2684 * Sorting hook -- swap function -- by "distance to player"
2686 * We use "u" and "v" to point to arrays of "x" and "y" positions,
2687 * and sort the arrays by distance to the player.
2689 static void ang_sort_swap_distance(vptr u, vptr v, int a, int b)
2691 POSITION *x = (POSITION*)(u);
2692 POSITION *y = (POSITION*)(v);
2710 * Hack -- help "select" a location (see below)
2712 static POSITION_IDX target_pick(POSITION y1, POSITION x1, POSITION dy, POSITION dx)
2715 POSITION x2, y2, x3, y3, x4, y4;
2716 POSITION_IDX b_i = -1, b_v = 9999;
2719 /* Scan the locations */
2720 for (i = 0; i < temp_n; i++)
2726 /* Directed distance */
2730 /* Verify quadrant */
2731 if (dx && (x3 * dx <= 0)) continue;
2732 if (dy && (y3 * dy <= 0)) continue;
2734 /* Absolute distance */
2738 /* Verify quadrant */
2739 if (dy && !dx && (x4 > y4)) continue;
2740 if (dx && !dy && (y4 > x4)) continue;
2742 /* Approximate Double Distance */
2743 v = ((x4 > y4) ? (x4 + x4 + y4) : (y4 + y4 + x4));
2745 /* XXX XXX XXX Penalize location */
2748 if ((b_i >= 0) && (v >= b_v)) continue;
2760 * Hack -- determine if a given location is "interesting"
2762 static bool target_set_accept(POSITION y, POSITION x)
2765 OBJECT_IDX this_o_idx, next_o_idx = 0;
2768 if (!(in_bounds(y, x))) return (FALSE);
2770 /* Player grid is always interesting */
2771 if (player_bold(y, x)) return (TRUE);
2773 /* Handle hallucination */
2774 if (p_ptr->image) return (FALSE);
2776 /* Examine the grid */
2777 c_ptr = &cave[y][x];
2779 /* Visible monsters */
2782 monster_type *m_ptr = &m_list[c_ptr->m_idx];
2784 /* Visible monsters */
2785 if (m_ptr->ml) return (TRUE);
2788 /* Scan all objects in the grid */
2789 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
2793 /* Acquire object */
2794 o_ptr = &o_list[this_o_idx];
2796 /* Acquire next object */
2797 next_o_idx = o_ptr->next_o_idx;
2799 /* Memorized object */
2800 if (o_ptr->marked & OM_FOUND) return (TRUE);
2803 /* Interesting memorized features */
2804 if (c_ptr->info & (CAVE_MARK))
2806 /* Notice object features */
2807 if (c_ptr->info & CAVE_OBJECT) return (TRUE);
2809 /* Feature code (applying "mimic" field) */
2810 if (have_flag(f_info[get_feat_mimic(c_ptr)].flags, FF_NOTICE)) return TRUE;
2819 * Prepare the "temp" array for "target_set"
2821 * Return the number of target_able monsters in the set.
2823 static void target_set_prepare(BIT_FLAGS mode)
2826 int min_hgt, max_hgt, min_wid, max_wid;
2828 if (mode & TARGET_KILL)
2831 min_hgt = MAX((p_ptr->y - MAX_RANGE), 0);
2832 max_hgt = MIN((p_ptr->y + MAX_RANGE), cur_hgt - 1);
2833 min_wid = MAX((p_ptr->x - MAX_RANGE), 0);
2834 max_wid = MIN((p_ptr->x + MAX_RANGE), cur_wid - 1);
2836 else /* not targetting */
2839 min_hgt = panel_row_min;
2840 max_hgt = panel_row_max;
2841 min_wid = panel_col_min;
2842 max_wid = panel_col_max;
2845 /* Reset "temp" array */
2848 /* Scan the current panel */
2849 for (y = min_hgt; y <= max_hgt; y++)
2851 for (x = min_wid; x <= max_wid; x++)
2855 /* Require "interesting" contents */
2856 if (!target_set_accept(y, x)) continue;
2858 c_ptr = &cave[y][x];
2860 /* Require target_able monsters for "TARGET_KILL" */
2861 if ((mode & (TARGET_KILL)) && !target_able(c_ptr->m_idx)) continue;
2863 if ((mode & (TARGET_KILL)) && !target_pet && is_pet(&m_list[c_ptr->m_idx])) continue;
2865 /* Save the location */
2872 /* Set the sort hooks */
2873 if (mode & (TARGET_KILL))
2875 /* Target the nearest monster for shooting */
2876 ang_sort_comp = ang_sort_comp_distance;
2877 ang_sort_swap = ang_sort_swap_distance;
2881 /* Look important grids first in Look command */
2882 ang_sort_comp = ang_sort_comp_importance;
2883 ang_sort_swap = ang_sort_swap_distance;
2886 /* Sort the positions */
2887 ang_sort(temp_x, temp_y, temp_n);
2889 if (p_ptr->riding && target_pet && (temp_n > 1) && (mode & (TARGET_KILL)))
2894 temp_y[0] = temp_y[1];
2897 temp_x[0] = temp_x[1];
2902 void target_set_prepare_look(void){
2903 target_set_prepare(TARGET_LOOK);
2908 * Evaluate number of kill needed to gain level
2910 static void evaluate_monster_exp(char *buf, monster_type *m_ptr)
2912 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
2914 s32b exp_mon, exp_adv;
2915 u32b exp_mon_frac, exp_adv_frac;
2917 if ((p_ptr->lev >= PY_MAX_LEVEL) || (p_ptr->prace == RACE_ANDROID))
2922 else if (!ap_r_ptr->r_tkills || (m_ptr->mflag2 & MFLAG2_KAGE))
2932 /* The monster's experience point (assuming average monster speed) */
2933 exp_mon = ap_r_ptr->mexp * ap_r_ptr->level;
2935 s64b_div(&exp_mon, &exp_mon_frac, 0, (p_ptr->max_plv + 2));
2938 /* Total experience value for next level */
2939 exp_adv = player_exp[p_ptr->lev -1] * p_ptr->expfact;
2941 s64b_div(&exp_adv, &exp_adv_frac, 0, 100);
2943 /* Experience value need to get */
2944 s64b_sub(&exp_adv, &exp_adv_frac, p_ptr->exp, p_ptr->exp_frac);
2947 /* You need to kill at least one monster to get any experience */
2948 s64b_add(&exp_adv, &exp_adv_frac, exp_mon, exp_mon_frac);
2949 s64b_sub(&exp_adv, &exp_adv_frac, 0, 1);
2951 /* Extract number of monsters needed */
2952 s64b_div(&exp_adv, &exp_adv_frac, exp_mon, exp_mon_frac);
2954 /* If 999 or more monsters needed, only display "999". */
2955 num = MIN(999, exp_adv_frac);
2957 /* Display the number */
2958 sprintf(buf,"%03ld", (long int)num);
2962 bool show_gold_on_floor = FALSE;
2965 * Examine a grid, return a keypress.
2967 * The "mode" argument contains the "TARGET_LOOK" bit flag, which
2968 * indicates that the "space" key should scan through the contents
2969 * of the grid, instead of simply returning immediately. This lets
2970 * the "look" command get complete information, without making the
2971 * "target" command annoying.
2973 * The "info" argument contains the "commands" which should be shown
2974 * inside the "[xxx]" text. This string must never be empty, or grids
2975 * containing monsters will be displayed with an extra comma.
2977 * Note that if a monster is in the grid, we update both the monster
2978 * recall info and the health bar info to track that monster.
2980 * Eventually, we may allow multiple objects per grid, or objects
2981 * and terrain features in the same grid. XXX XXX XXX
2983 * This function must handle blindness/hallucination.
2985 static char target_set_aux(POSITION y, POSITION x, BIT_FLAGS mode, cptr info)
2987 cave_type *c_ptr = &cave[y][x];
2988 OBJECT_IDX this_o_idx, next_o_idx = 0;
2989 cptr s1 = "", s2 = "", s3 = "", x_info = "";
2992 feature_type *f_ptr;
2993 char query = '\001';
2994 char out_val[MAX_NLEN+80];
2996 #ifdef ALLOW_EASY_FLOOR
2997 OBJECT_IDX floor_list[23];
2998 ITEM_NUMBER floor_num = 0;
3000 /* Scan all objects in the grid */
3003 floor_num = scan_floor(floor_list, y, x, 0x02);
3007 x_info = _("x物 ", "x,");
3011 #endif /* ALLOW_EASY_FLOOR */
3013 /* Hack -- under the player */
3014 if (player_bold(y, x))
3030 s1 = _("ターゲット:", "Target:");
3033 /* Hack -- hallucination */
3036 cptr name = _("何か奇妙な物", "something strange");
3038 /* Display a message */
3040 sprintf(out_val, "%s%s%s%s [%s]", s1, name, s2, s3, info);
3042 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, name, info);
3046 move_cursor_relative(y, x);
3049 /* Stop on everything but "return" */
3050 if ((query != '\r') && (query != '\n')) return query;
3052 /* Repeat forever */
3057 /* Actual monsters */
3058 if (c_ptr->m_idx && m_list[c_ptr->m_idx].ml)
3060 monster_type *m_ptr = &m_list[c_ptr->m_idx];
3061 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
3063 bool recall = FALSE;
3068 /* Get the monster name ("a kobold") */
3069 monster_desc(m_name, m_ptr, MD_INDEF_VISIBLE);
3071 /* Hack -- track this monster race */
3072 monster_race_track(m_ptr->ap_r_idx);
3074 /* Hack -- health bar for this monster */
3075 health_track(c_ptr->m_idx);
3077 /* Hack -- handle stuff */
3091 /* Recall on screen */
3092 screen_roff(m_ptr->ap_r_idx, 0);
3094 /* Hack -- Complete the prompt (again) */
3095 Term_addstr(-1, TERM_WHITE, format(_(" [r思 %s%s]", " [r,%s%s]"), x_info, info));
3103 /* Normal commands */
3104 if (query != 'r') break;
3109 /* Cleare recall text and repeat */
3115 /* Describe, and prompt for recall */
3116 evaluate_monster_exp(acount, m_ptr);
3119 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);
3121 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);
3127 move_cursor_relative(y, x);
3132 /* Normal commands */
3133 if (query != 'r') break;
3139 /* Always stop at "normal" keys */
3140 if ((query != '\r') && (query != '\n') && (query != ' ') && (query != 'x')) return query;
3142 /* Sometimes stop at "space" key */
3143 if ((query == ' ') && !(mode & (TARGET_LOOK))) return query;
3145 /* Change the intro */
3146 s1 = _("それは", "It is ");
3148 /* Hack -- take account of gender */
3149 if (ap_r_ptr->flags1 & (RF1_FEMALE)) s1 = _("彼女は", "She is ");
3150 else if (ap_r_ptr->flags1 & (RF1_MALE)) s1 = _("彼は", "He is ");
3152 /* Use a preposition */
3161 /* Scan all objects being carried */
3162 for (this_o_idx = m_ptr->hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
3164 char o_name[MAX_NLEN];
3168 /* Acquire object */
3169 o_ptr = &o_list[this_o_idx];
3171 /* Acquire next object */
3172 next_o_idx = o_ptr->next_o_idx;
3174 /* Obtain an object description */
3175 object_desc(o_name, o_ptr, 0);
3177 /* Describe the object */
3179 sprintf(out_val, "%s%s%s%s[%s]", s1, o_name, s2, s3, info);
3181 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, o_name, info);
3185 move_cursor_relative(y, x);
3188 /* Always stop at "normal" keys */
3189 if ((query != '\r') && (query != '\n') && (query != ' ') && (query != 'x')) return query;
3191 /* Sometimes stop at "space" key */
3192 if ((query == ' ') && !(mode & (TARGET_LOOK))) return query;
3194 /* Change the intro */
3195 s2 = _("をまた", "also carrying ");
3198 /* Use a preposition */
3208 #ifdef ALLOW_EASY_FLOOR
3217 char o_name[MAX_NLEN];
3221 /* Acquire object */
3222 o_ptr = &o_list[floor_list[0]];
3224 /* Describe the object */
3225 object_desc(o_name, o_ptr, 0);
3228 sprintf(out_val, "%s%s%s%s[%s]",
3229 s1, o_name, s2, s3, info);
3231 sprintf(out_val, "%s%s%s%s [%s]",
3232 s1, s2, s3, o_name, info);
3236 move_cursor_relative(y, x);
3245 /* Provide one cushion before item listing */
3248 /* Display rough information about items */
3250 sprintf(out_val, "%s %d個のアイテム%s%s ['x'で一覧, %s]",
3251 s1, (int)floor_num, s2, s3, info);
3253 sprintf(out_val, "%s%s%sa pile of %d items [x,%s]",
3254 s1, s2, s3, (int)floor_num, info);
3258 move_cursor_relative(y, x);
3263 /* No request for listing */
3264 if (query != 'x' && query != ' ') return query;
3268 /** Display list of items **/
3270 /* Continue scrolling list if requested */
3280 show_gold_on_floor = TRUE;
3281 (void)show_floor(0, y, x, &min_width);
3282 show_gold_on_floor = FALSE;
3286 sprintf(out_val, "%s %d個のアイテム%s%s [Enterで次へ, %s]",
3287 s1, (int)floor_num, s2, s3, info);
3289 sprintf(out_val, "%s%s%sa pile of %d items [Enter,%s]",
3290 s1, s2, s3, (int)floor_num, info);
3301 /* Exit unless 'Enter' */
3302 if (query != '\n' && query != '\r')
3307 /* Get the object being moved. */
3308 o_idx = c_ptr->o_idx;
3310 /* Only rotate a pile of two or more objects. */
3311 if (!(o_idx && o_list[o_idx].next_o_idx)) continue;
3313 /* Remove the first object from the list. */
3314 excise_object_idx(o_idx);
3316 /* Find end of the list. */
3318 while (o_list[i].next_o_idx)
3319 i = o_list[i].next_o_idx;
3321 /* Add after the last object. */
3322 o_list[i].next_o_idx = o_idx;
3324 /* Loop and re-display the list */
3330 #endif /* ALLOW_EASY_FLOOR */
3333 /* Scan all objects in the grid */
3334 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
3338 /* Acquire object */
3339 o_ptr = &o_list[this_o_idx];
3341 /* Acquire next object */
3342 next_o_idx = o_ptr->next_o_idx;
3345 if (o_ptr->marked & OM_FOUND)
3347 char o_name[MAX_NLEN];
3352 /* Obtain an object description */
3353 object_desc(o_name, o_ptr, 0);
3355 /* Describe the object */
3357 sprintf(out_val, "%s%s%s%s[%s]", s1, o_name, s2, s3, info);
3359 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, o_name, info);
3363 move_cursor_relative(y, x);
3366 /* Always stop at "normal" keys */
3367 if ((query != '\r') && (query != '\n') && (query != ' ') && (query != 'x')) return query;
3369 /* Sometimes stop at "space" key */
3370 if ((query == ' ') && !(mode & TARGET_LOOK)) return query;
3372 /* Change the intro */
3373 s1 = _("それは", "It is ");
3376 if (o_ptr->number != 1) s1 = _("それらは", "They are ");
3390 /* Feature code (applying "mimic" field) */
3391 feat = get_feat_mimic(c_ptr);
3393 /* Require knowledge about grid, or ability to see grid */
3394 if (!(c_ptr->info & CAVE_MARK) && !player_can_see_bold(y, x))
3396 /* Forget feature */
3400 f_ptr = &f_info[feat];
3402 /* Terrain feature if needed */
3403 if (boring || have_flag(f_ptr->flags, FF_REMEMBER))
3407 /* Hack -- special handling for quest entrances */
3408 if (have_flag(f_ptr->flags, FF_QUEST_ENTER))
3410 /* Set the quest number temporary */
3411 IDX old_quest = p_ptr->inside_quest;
3414 /* Clear the text */
3415 for (j = 0; j < 10; j++) quest_text[j][0] = '\0';
3416 quest_text_line = 0;
3418 p_ptr->inside_quest = c_ptr->special;
3420 /* Get the quest text */
3421 init_flags = INIT_NAME_ONLY;
3423 process_dungeon_file("q_info.txt", 0, 0, 0, 0);
3425 name = format(_("クエスト「%s」(%d階相当)", "the entrance to the quest '%s'(level %d)"),
3426 quest[c_ptr->special].name, quest[c_ptr->special].level);
3428 /* Reset the old quest number */
3429 p_ptr->inside_quest = old_quest;
3432 /* Hack -- special handling for building doors */
3433 else if (have_flag(f_ptr->flags, FF_BLDG) && !p_ptr->inside_arena)
3435 name = building[f_ptr->subtype].name;
3437 else if (have_flag(f_ptr->flags, FF_ENTRANCE))
3439 name = format(_("%s(%d階相当)", "%s(level %d)"), d_text + d_info[c_ptr->special].text, d_info[c_ptr->special].mindepth);
3441 else if (have_flag(f_ptr->flags, FF_TOWN))
3443 name = town[c_ptr->special].name;
3445 else if (p_ptr->wild_mode && (feat == feat_floor))
3447 name = _("道", "road");
3451 name = f_name + f_ptr->name;
3457 ((!have_flag(f_ptr->flags, FF_MOVE) && !have_flag(f_ptr->flags, FF_CAN_FLY)) ||
3458 (!have_flag(f_ptr->flags, FF_LOS) && !have_flag(f_ptr->flags, FF_TREE)) ||
3459 have_flag(f_ptr->flags, FF_TOWN)))
3461 s2 = _("の中", "in ");
3464 /* Hack -- special introduction for store & building doors -KMW- */
3465 if (have_flag(f_ptr->flags, FF_STORE) ||
3466 have_flag(f_ptr->flags, FF_QUEST_ENTER) ||
3467 (have_flag(f_ptr->flags, FF_BLDG) && !p_ptr->inside_arena) ||
3468 have_flag(f_ptr->flags, FF_ENTRANCE))
3477 else if (have_flag(f_ptr->flags, FF_FLOOR) ||
3478 have_flag(f_ptr->flags, FF_TOWN) ||
3479 have_flag(f_ptr->flags, FF_SHALLOW) ||
3480 have_flag(f_ptr->flags, FF_DEEP))
3486 /* Pick proper indefinite article */
3487 s3 = (is_a_vowel(name[0])) ? "an " : "a ";
3491 /* Display a message */
3495 if (c_ptr->mimic) sprintf(f_idx_str, "%d/%d", c_ptr->feat, c_ptr->mimic);
3496 else sprintf(f_idx_str, "%d", c_ptr->feat);
3498 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]);
3500 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);
3505 sprintf(out_val, "%s%s%s%s[%s]", s1, name, s2, s3, info);
3507 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, name, info);
3511 move_cursor_relative(y, x);
3514 /* Always stop at "normal" keys */
3515 if ((query != '\r') && (query != '\n') && (query != ' ')) return query;
3518 /* Stop on everything but "return" */
3519 if ((query != '\r') && (query != '\n')) return query;
3521 /* Repeat forever */
3527 * Handle "target" and "look".
3529 * Note that this code can be called from "get_aim_dir()".
3531 * All locations must be on the current panel. Consider the use of
3532 * "panel_bounds()" to allow "off-panel" targets, perhaps by using
3533 * some form of "scrolling" the map around the cursor. XXX XXX XXX
3534 * That is, consider the possibility of "auto-scrolling" the screen
3535 * while the cursor moves around. This may require changes in the
3536 * "update_mon()" code to allow "visibility" even if off panel, and
3537 * may require dynamic recalculation of the "temp" grid set.
3539 * Hack -- targeting/observing an "outer border grid" may induce
3540 * problems, so this is not currently allowed.
3542 * The player can use the direction keys to move among "interesting"
3543 * grids in a heuristic manner, or the "space", "+", and "-" keys to
3544 * move through the "interesting" grids in a sequential manner, or
3545 * can enter "location" mode, and use the direction keys to move one
3546 * grid at a time in any direction. The "t" (set target) command will
3547 * only target a monster (as opposed to a location) if the monster is
3548 * target_able and the "interesting" mode is being used.
3550 * The current grid is described using the "look" method above, and
3551 * a new command may be entered at any time, but note that if the
3552 * "TARGET_LOOK" bit flag is set (or if we are in "location" mode,
3553 * where "space" has no obvious meaning) then "space" will scan
3554 * through the description of the current grid until done, instead
3555 * of immediately jumping to the next "interesting" grid. This
3556 * allows the "target" command to retain its old semantics.
3558 * The "*", "+", and "-" keys may always be used to jump immediately
3559 * to the next (or previous) interesting grid, in the proper mode.
3561 * The "return" key may always be used to scan through a complete
3562 * grid description (forever).
3564 * This command will cancel any old target, even if used from
3565 * inside the "look" command.
3567 bool target_set(BIT_FLAGS mode)
3570 POSITION y = p_ptr->y;
3571 POSITION x = p_ptr->x;
3584 get_screen_size(&wid, &hgt);
3590 /* Cancel tracking */
3591 /* health_track(0); */
3593 if (rogue_like_commands)
3602 /* Prepare the "temp" array */
3603 target_set_prepare(mode);
3605 /* Start near the player */
3611 /* Interesting grids */
3618 change_panel_xy(y, x);
3620 if (!(mode & TARGET_LOOK)) prt_path(y, x);
3623 c_ptr = &cave[y][x];
3626 if (target_able(c_ptr->m_idx))
3628 strcpy(info, _("q止 t決 p自 o現 +次 -前", "q,t,p,o,+,-,<dir>"));
3631 /* Dis-allow target */
3634 strcpy(info, _("q止 p自 o現 +次 -前", "q,p,o,+,-,<dir>"));
3640 sprintf(cheatinfo, " LOS:%d, PROJECTABLE:%d",
3641 los(p_ptr->y, p_ptr->x, y, x),
3642 projectable(p_ptr->y, p_ptr->x, y, x));
3643 strcat(info, cheatinfo);
3646 /* Describe and Prompt */
3648 query = target_set_aux(y, x, mode, info);
3652 /* Cancel tracking */
3653 /* health_track(0); */
3655 /* Assume no "direction" */
3660 if (query == '\r') query = 't';
3678 if (target_able(c_ptr->m_idx))
3680 health_track(c_ptr->m_idx);
3681 target_who = c_ptr->m_idx;
3700 if (!expand_list) done = TRUE;
3710 if (!expand_list) done = TRUE;
3717 /* Recenter the map around the player */
3721 p_ptr->update |= (PU_MONSTERS);
3724 p_ptr->redraw |= (PR_MAP);
3727 p_ptr->window |= (PW_OVERHEAD);
3732 /* Recalculate interesting grids */
3733 target_set_prepare(mode);
3752 if(query == same_key)
3757 if (!expand_list) done = TRUE;
3762 /* Extract the action (if any) */
3763 d = get_keymap_dir(query);
3770 /* Hack -- move around */
3773 /* Modified to scroll to monster */
3774 POSITION y2 = panel_row_min;
3775 POSITION x2 = panel_col_min;
3777 /* Find a new monster */
3778 i = target_pick(temp_y[m], temp_x[m], ddy[d], ddx[d]);
3780 /* Request to target past last interesting grid */
3781 while (flag && (i < 0))
3783 /* Note the change */
3784 if (change_panel(ddy[d], ddx[d]))
3789 /* Recalculate interesting grids */
3790 target_set_prepare(mode);
3792 /* Look at interesting grids */
3795 /* Find a new monster */
3796 i = target_pick(v, u, ddy[d], ddx[d]);
3802 /* Nothing interesting */
3808 /* Restore previous position */
3811 panel_bounds_center();
3814 p_ptr->update |= (PU_MONSTERS);
3817 p_ptr->redraw |= (PR_MAP);
3820 p_ptr->window |= (PW_OVERHEAD);
3825 /* Recalculate interesting grids */
3826 target_set_prepare(mode);
3828 /* Look at boring grids */
3835 /* Do not move horizontally if unnecessary */
3836 if (((x < panel_col_min + wid / 2) && (dx > 0)) ||
3837 ((x > panel_col_min + wid / 2) && (dx < 0)))
3842 /* Do not move vertically if unnecessary */
3843 if (((y < panel_row_min + hgt / 2) && (dy > 0)) ||
3844 ((y > panel_row_min + hgt / 2) && (dy < 0)))
3849 /* Apply the motion */
3850 if ((y >= panel_row_min+hgt) || (y < panel_row_min) ||
3851 (x >= panel_col_min+wid) || (x < panel_col_min))
3853 if (change_panel(dy, dx)) target_set_prepare(mode);
3856 /* Slide into legality */
3857 if (x >= cur_wid-1) x = cur_wid - 2;
3858 else if (x <= 0) x = 1;
3860 /* Slide into legality */
3861 if (y >= cur_hgt-1) y = cur_hgt- 2;
3862 else if (y <= 0) y = 1;
3871 /* Arbitrary grids */
3874 bool move_fast = FALSE;
3876 if (!(mode & TARGET_LOOK)) prt_path(y, x);
3879 c_ptr = &cave[y][x];
3881 /* Default prompt */
3882 strcpy(info, _("q止 t決 p自 m近 +次 -前", "q,t,p,m,+,-,<dir>"));
3887 sprintf(cheatinfo, " LOS:%d, PROJECTABLE:%d",
3888 los(p_ptr->y, p_ptr->x, y, x),
3889 projectable(p_ptr->y, p_ptr->x, y, x));
3890 strcat(info, cheatinfo);
3893 /* Describe and Prompt (enable "TARGET_LOOK") */
3894 while ((query = target_set_aux(y, x, mode | TARGET_LOOK, info)) == 0);
3896 /* Cancel tracking */
3897 /* health_track(0); */
3899 /* Assume no direction */
3904 if (query == '\r') query = 't';
3907 /* Analyze the keypress */
3931 /* Recenter the map around the player */
3935 p_ptr->update |= (PU_MONSTERS);
3938 p_ptr->redraw |= (PR_MAP);
3941 p_ptr->window |= (PW_OVERHEAD);
3946 /* Recalculate interesting grids */
3947 target_set_prepare(mode);
3969 /* Pick a nearby monster */
3970 for (i = 0; i < temp_n; i++)
3972 t = distance(y, x, temp_y[i], temp_x[i]);
3982 /* Nothing interesting */
3983 if (bd == 999) flag = FALSE;
3990 /* Extract the action (if any) */
3991 d = get_keymap_dir(query);
3993 /* XTRA HACK MOVEFAST */
3994 if (isupper(query)) move_fast = TRUE;
4001 /* Handle "direction" */
4007 /* XTRA HACK MOVEFAST */
4010 int mag = MIN(wid / 2, hgt / 2);
4020 /* Do not move horizontally if unnecessary */
4021 if (((x < panel_col_min + wid / 2) && (dx > 0)) ||
4022 ((x > panel_col_min + wid / 2) && (dx < 0)))
4027 /* Do not move vertically if unnecessary */
4028 if (((y < panel_row_min + hgt / 2) && (dy > 0)) ||
4029 ((y > panel_row_min + hgt / 2) && (dy < 0)))
4034 /* Apply the motion */
4035 if ((y >= panel_row_min + hgt) || (y < panel_row_min) ||
4036 (x >= panel_col_min + wid) || (x < panel_col_min))
4038 if (change_panel(dy, dx)) target_set_prepare(mode);
4041 /* Slide into legality */
4042 if (x >= cur_wid-1) x = cur_wid - 2;
4043 else if (x <= 0) x = 1;
4045 /* Slide into legality */
4046 if (y >= cur_hgt-1) y = cur_hgt- 2;
4047 else if (y <= 0) y = 1;
4055 /* Clear the top line */
4058 /* Recenter the map around the player */
4062 p_ptr->update |= (PU_MONSTERS);
4065 p_ptr->redraw |= (PR_MAP);
4068 p_ptr->window |= (PW_OVERHEAD);
4073 /* Failure to set target */
4074 if (!target_who) return (FALSE);
4082 * Get an "aiming direction" from the user.
4084 * The "dir" is loaded with 1,2,3,4,6,7,8,9 for "actual direction", and
4085 * "0" for "current target", and "-1" for "entry aborted".
4087 * Note that "Force Target", if set, will pre-empt user interaction,
4088 * if there is a usable target already set.
4090 * Note that confusion over-rides any (explicit?) user choice.
4092 bool get_aim_dir(DIRECTION *dp)
4102 /* Global direction */
4105 /* Hack -- auto-target if requested */
4106 if (use_old_target && target_okay()) dir = 5;
4108 #ifdef ALLOW_REPEAT /* TNB */
4110 if (repeat_pull(&code))
4115 if (!(code == 5 && !target_okay()))
4117 /* return (TRUE); */
4118 dir = (DIRECTION)code;
4121 *dp = (DIRECTION)code;
4123 #endif /* ALLOW_REPEAT -- TNB */
4125 /* Ask until satisfied */
4128 /* Choose a prompt */
4131 p = _("方向 ('*'でターゲット選択, ESCで中断)? ", "Direction ('*' to choose a target, Escape to cancel)? ");
4135 p = _("方向 ('5'でターゲットへ, '*'でターゲット再選択, ESCで中断)? ", "Direction ('5' for target, '*' to re-target, Escape to cancel)? ");
4138 /* Get a command (or Cancel) */
4139 if (!get_com(p, &command, TRUE)) break;
4143 if (command == '\r') command = 't';
4146 /* Convert various keys to "standard" keys */
4149 /* Use current target */
4160 /* Set new target */
4165 if (target_set(TARGET_KILL)) dir = 5;
4171 /* Extract the action (if any) */
4172 dir = get_keymap_dir(command);
4178 /* Verify requested targets */
4179 if ((dir == 5) && !target_okay()) dir = 0;
4188 project_length = 0; /* reset to default */
4192 /* Save the direction */
4195 /* Check for confusion */
4196 if (p_ptr->confused)
4199 /* Random direction */
4200 dir = ddd[randint0(8)];
4203 /* Notice confusion */
4204 if (command_dir != dir)
4207 msg_print(_("あなたは混乱している。", "You are confused."));
4210 /* Save direction */
4213 #ifdef ALLOW_REPEAT /* TNB */
4215 /* repeat_push(dir); */
4216 repeat_push((COMMAND_CODE)command_dir);
4218 #endif /* ALLOW_REPEAT -- TNB */
4220 /* A "valid" direction was entered */
4227 * Request a "movement" direction (1,2,3,4,6,7,8,9) from the user,
4228 * and place it into "command_dir", unless we already have one.
4230 * This function should be used for all "repeatable" commands, such as
4231 * run, walk, open, close, bash, disarm, spike, tunnel, etc, as well
4232 * as all commands which must reference a grid adjacent to the player,
4233 * and which may not reference the grid under the player. Note that,
4234 * for example, it is no longer possible to "disarm" or "open" chests
4235 * in the same grid as the player.
4237 * Direction "5" is illegal and will (cleanly) abort the command.
4239 * This function tracks and uses the "global direction", and uses
4240 * that as the "desired direction", to which "confusion" is applied.
4242 bool get_rep_dir(DIRECTION *dp, bool under)
4251 /* Global direction */
4254 #ifdef ALLOW_REPEAT /* TNB */
4256 if (repeat_pull(&code))
4258 dir = (DIRECTION)code;
4259 /* return (TRUE); */
4261 *dp = (DIRECTION)code;
4263 #endif /* ALLOW_REPEAT -- TNB */
4267 prompt = _("方向 ('.'足元, ESCで中断)? ", "Direction ('.' at feet, Escape to cancel)? ");
4271 prompt = _("方向 (ESCで中断)? ", "Direction (Escape to cancel)? ");
4274 /* Get a direction */
4279 /* Get a command (or Cancel) */
4280 if (!get_com(prompt, &ch, TRUE)) break;
4283 if ((under) && ((ch == '5') || (ch == '-') || (ch == '.')))
4289 /* Look up the direction */
4290 dir = get_keymap_dir(ch);
4297 /* Prevent weirdness */
4298 if ((dir == 5) && (!under)) dir = 0;
4301 if (!dir) return (FALSE);
4303 /* Save desired direction */
4306 /* Apply "confusion" */
4307 if (p_ptr->confused)
4309 /* Standard confusion */
4310 if (randint0(100) < 75)
4312 /* Random direction */
4313 dir = ddd[randint0(8)];
4316 else if (p_ptr->riding)
4318 monster_type *m_ptr = &m_list[p_ptr->riding];
4319 monster_race *r_ptr = &r_info[m_ptr->r_idx];
4321 if (MON_CONFUSED(m_ptr))
4323 /* Standard confusion */
4324 if (randint0(100) < 75)
4326 /* Random direction */
4327 dir = ddd[randint0(8)];
4330 else if ((r_ptr->flags1 & RF1_RAND_50) && (r_ptr->flags1 & RF1_RAND_25) && (randint0(100) < 50))
4332 /* Random direction */
4333 dir = ddd[randint0(8)];
4335 else if ((r_ptr->flags1 & RF1_RAND_50) && (randint0(100) < 25))
4337 /* Random direction */
4338 dir = ddd[randint0(8)];
4342 /* Notice confusion */
4343 if (command_dir != dir)
4345 if (p_ptr->confused)
4348 msg_print(_("あなたは混乱している。", "You are confused."));
4353 monster_type *m_ptr = &m_list[p_ptr->riding];
4355 monster_desc(m_name, m_ptr, 0);
4356 if (MON_CONFUSED(m_ptr))
4358 msg_format(_("%sは混乱している。", "%^s is confusing."), m_name);
4362 msg_format(_("%sは思い通りに動いてくれない。", "You cannot control %s."), m_name);
4367 /* Save direction */
4370 #ifdef ALLOW_REPEAT /* TNB */
4372 /* repeat_push(dir); */
4373 repeat_push((COMMAND_CODE)command_dir);
4375 #endif /* ALLOW_REPEAT -- TNB */
4382 bool get_rep_dir2(DIRECTION *dp)
4390 /* Global direction */
4393 #ifdef ALLOW_REPEAT /* TNB */
4395 if (repeat_pull(&code))
4397 dir = (DIRECTION)code;
4398 /* return (TRUE); */
4400 *dp = (DIRECTION)code;
4402 #endif /* ALLOW_REPEAT -- TNB */
4404 /* Get a direction */
4409 /* Get a command (or Cancel) */
4410 if (!get_com(_("方向 (ESCで中断)? ", "Direction (Escape to cancel)? "), &ch, TRUE)) break;
4412 /* Look up the direction */
4413 dir = get_keymap_dir(ch);
4419 /* Prevent weirdness */
4420 if (dir == 5) dir = 0;
4423 if (!dir) return (FALSE);
4425 /* Save desired direction */
4428 /* Apply "confusion" */
4429 if (p_ptr->confused)
4431 /* Standard confusion */
4432 if (randint0(100) < 75)
4434 /* Random direction */
4435 dir = ddd[randint0(8)];
4439 /* Notice confusion */
4440 if (command_dir != dir)
4443 msg_print(_("あなたは混乱している。", "You are confused."));
4446 /* Save direction */
4449 #ifdef ALLOW_REPEAT /* TNB */
4451 /* repeat_push(dir); */
4452 repeat_push((COMMAND_CODE)command_dir);
4454 #endif /* ALLOW_REPEAT -- TNB */
4460 void gain_level_reward(int chosen_reward)
4464 char wrath_reason[32] = "";
4465 int nasty_chance = 6;
4466 OBJECT_TYPE_VALUE dummy = 0;
4467 OBJECT_SUBTYPE_VALUE dummy2 = 0;
4470 char o_name[MAX_NLEN];
4476 if (multi_rew) return;
4477 else multi_rew = TRUE;
4481 if (p_ptr->lev == 13) nasty_chance = 2;
4482 else if (!(p_ptr->lev % 13)) nasty_chance = 3;
4483 else if (!(p_ptr->lev % 14)) nasty_chance = 12;
4485 if (one_in_(nasty_chance))
4486 type = randint1(20); /* Allow the 'nasty' effects */
4488 type = randint1(15) + 5; /* Or disallow them */
4490 if (type < 1) type = 1;
4491 if (type > 20) type = 20;
4495 sprintf(wrath_reason, _("%sの怒り", "the Wrath of %s"), chaos_patrons[p_ptr->chaos_patron]);
4497 effect = chaos_rewards[p_ptr->chaos_patron][type];
4499 if (one_in_(6) && !chosen_reward)
4501 msg_format(_("%^sは褒美としてあなたを突然変異させた。", "%^s rewards you with a mutation!"), chaos_patrons[p_ptr->chaos_patron]);
4502 (void)gain_random_mutation(0);
4503 reward = _("変異した。", "mutation");
4507 switch (chosen_reward ? chosen_reward : effect)
4512 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4513 msg_print(_("「汝、新たなる姿を必要とせり!」", "'Thou needst a new form, mortal!'"));
4516 reward = _("変異した。", "polymorphing");
4521 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4522 msg_print(_("「汝は良く行いたり!続けよ!」", "'Well done, mortal! Lead on!'"));
4524 if (p_ptr->prace == RACE_ANDROID)
4526 msg_print(_("しかし何も起こらなかった。", "But, nothing happen."));
4528 else if (p_ptr->exp < PY_MAX_EXP)
4530 s32b ee = (p_ptr->exp / 2) + 10;
4531 if (ee > 100000L) ee = 100000L;
4532 msg_print(_("更に経験を積んだような気がする。", "You feel more experienced."));
4535 reward = _("経験値を得た", "experience");
4541 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4542 msg_print(_("「下僕よ、汝それに値せず。」", "'Thou didst not deserve that, slave.'"));
4544 if (p_ptr->prace == RACE_ANDROID)
4546 msg_print(_("しかし何も起こらなかった。", "But, nothing happen."));
4550 lose_exp(p_ptr->exp / 6);
4551 reward = _("経験値を失った。", "losing experience");
4557 msg_format("%sの声がささやいた:",
4558 chaos_patrons[p_ptr->chaos_patron]);
4560 msg_format("The voice of %s whispers:",
4561 chaos_patrons[p_ptr->chaos_patron]);
4564 msg_print(_("「我が与えし物を賢明に使うべし。」", "'Use my gift wisely.'"));
4566 acquirement(p_ptr->y, p_ptr->x, 1, FALSE, FALSE, FALSE);
4567 reward = _("上質なアイテムを手に入れた。", "a good item");
4572 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4573 msg_print(_("「我が与えし物を賢明に使うべし。」", "'Use my gift wisely.'"));
4575 acquirement(p_ptr->y, p_ptr->x, 1, TRUE, FALSE, FALSE);
4576 reward = _("高級品のアイテムを手に入れた。", "an excellent item");
4581 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4582 msg_print(_("「汝の行いは貴き剣に値せり。」", "'Thy deed hath earned thee a worthy blade.'"));
4584 /* Get local object */
4587 switch (randint1(p_ptr->lev))
4593 dummy2 = SV_MAIN_GAUCHE;
4602 dummy2 = SV_SMALL_SWORD;
4605 dummy2 = SV_BASILLARD;
4607 case 11: case 12: case 13:
4608 dummy2 = SV_SHORT_SWORD;
4614 dummy2 = SV_CUTLASS;
4617 dummy2 = SV_WAKIZASHI;
4620 dummy2 = SV_KHOPESH;
4626 dummy2 = SV_BROAD_SWORD;
4629 dummy2 = SV_LONG_SWORD;
4632 dummy2 = SV_SCIMITAR;
4635 dummy2 = SV_NINJATO;
4641 dummy2 = SV_BASTARD_SWORD;
4644 dummy2 = SV_GREAT_SCIMITAR;
4647 dummy2 = SV_CLAYMORE;
4650 dummy2 = SV_ESPADON;
4653 dummy2 = SV_TWO_HANDED_SWORD;
4656 dummy2 = SV_FLAMBERGE;
4659 dummy2 = SV_NO_DACHI;
4662 dummy2 = SV_EXECUTIONERS_SWORD;
4665 dummy2 = SV_ZWEIHANDER;
4668 dummy2 = SV_HAYABUSA;
4671 dummy2 = SV_BLADE_OF_CHAOS;
4674 object_prep(q_ptr, lookup_kind(dummy, dummy2));
4675 q_ptr->to_h = 3 + randint1(dun_level) % 10;
4676 q_ptr->to_d = 3 + randint1(dun_level) % 10;
4677 one_resistance(q_ptr);
4678 q_ptr->name2 = EGO_CHAOTIC;
4680 /* Drop it in the dungeon */
4681 (void)drop_near(q_ptr, -1, p_ptr->y, p_ptr->x);
4682 reward = _("(混沌)の武器を手に入れた。", "chaos weapon");
4687 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4688 msg_print(_("「汝の行いは貴き報いに値せり。」", "'Thy deed hath earned thee a worthy reward.'"));
4690 acquirement(p_ptr->y, p_ptr->x, randint1(2) + 1, FALSE, FALSE, FALSE);
4691 reward = _("上質なアイテムを手に入れた。", "good items");
4696 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4697 msg_print(_("「下僕よ、汝の献身への我が惜しみ無き報いを見るがよい。」", "'Behold, mortal, how generously I reward thy loyalty.'"));
4699 acquirement(p_ptr->y, p_ptr->x, randint1(2) + 1, TRUE, FALSE, FALSE);
4700 reward = _("高級品のアイテムを手に入れた。", "excellent items");
4705 msg_format("%sの声が轟き渡った:", chaos_patrons[p_ptr->chaos_patron]);
4707 msg_format("The voice of %s thunders:", chaos_patrons[p_ptr->chaos_patron]);
4710 msg_print(_("「下僕よ、汝傲慢なり。」", "'Thou art growing arrogant, mortal.'"));
4712 (void)activate_ty_curse(FALSE, &count);
4713 reward = _("禍々しい呪いをかけられた。", "cursing");
4718 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4719 msg_print(_("「我が下僕たちよ、かの傲慢なる者を倒すべし!」", "'My pets, destroy the arrogant mortal!'"));
4721 for (dummy = 0; dummy < randint1(5) + 1; dummy++)
4723 (void)summon_specific(0, p_ptr->y, p_ptr->x, dun_level, 0, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET));
4725 reward = _("モンスターを召喚された。", "summoning hostile monsters");
4731 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4732 msg_print(_("「汝、より強き敵を必要とせり!」", "'Thou needst worthier opponents!'"));
4734 activate_hi_summon(p_ptr->y, p_ptr->x, FALSE);
4735 reward = _("モンスターを召喚された。", "summoning many hostile monsters");
4741 msg_format("%sの声が響き渡った:",
4742 chaos_patrons[p_ptr->chaos_patron]);
4744 msg_format("The voice of %s booms out:",
4745 chaos_patrons[p_ptr->chaos_patron]);
4748 msg_print(_("「死と破壊こそ我が喜びなり!」", "'Death and destruction! This pleaseth me!'"));
4751 reward = _("カオスの力が渦巻いた。", "calling chaos");
4757 msg_format("%sの声が鳴り響いた:",
4758 chaos_patrons[p_ptr->chaos_patron]);
4760 msg_format("The voice of %s rings out:",
4761 chaos_patrons[p_ptr->chaos_patron]);
4764 msg_print(_("「留まるのだ、下僕よ。余が汝の肉体を鍛えん。」", "'Stay, mortal, and let me mold thee.'"));
4766 if (one_in_(3) && !(chaos_stats[p_ptr->chaos_patron] < 0))
4767 do_inc_stat(chaos_stats[p_ptr->chaos_patron]);
4769 do_inc_stat(randint0(6));
4770 reward = _("能力値が上がった。", "increasing a stat");
4776 msg_format("%sの声が響き渡った:",
4777 chaos_patrons[p_ptr->chaos_patron]);
4779 msg_format("The voice of %s booms out:",
4780 chaos_patrons[p_ptr->chaos_patron]);
4783 msg_print(_("「下僕よ、余は汝に飽みたり。」", "'I grow tired of thee, mortal.'"));
4785 if (one_in_(3) && !(chaos_stats[p_ptr->chaos_patron] < 0))
4786 do_dec_stat(chaos_stats[p_ptr->chaos_patron]);
4788 (void)do_dec_stat(randint0(6));
4789 reward = _("能力値が下がった。", "decreasing a stat");
4796 msg_format("%sの声が轟き渡った:",
4797 chaos_patrons[p_ptr->chaos_patron]);
4799 msg_format("The voice of %s thunders:",
4800 chaos_patrons[p_ptr->chaos_patron]);
4803 msg_print(_("「汝、謙虚たることを学ぶべし!」", "'Thou needst a lesson in humility, mortal!'"));
4804 msg_print(_("あなたは以前より弱くなった!", "You feel less powerful!"));
4806 for (dummy = 0; dummy < 6; dummy++)
4808 (void)dec_stat(dummy, 10 + randint1(15), TRUE);
4810 reward = _("全能力値が下がった。", "decreasing all stats");
4815 msg_format(_("%sの力が触れるのを感じた。", "You feel the power of %s touch you."),
4816 chaos_patrons[p_ptr->chaos_patron]);
4818 reward = _("傷が変化した。", "polymorphing wounds");
4823 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4825 msg_print(_("「我がささやかなる賜物を受けとるがよい!」", "'Receive this modest gift from me!'"));
4827 for (dummy = 0; dummy < 6; dummy++)
4829 (void)do_inc_stat(dummy);
4831 reward = _("全能力値が上がった。", "increasing all stats");
4836 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4837 msg_print(_("「苦しむがよい、無能な愚か者よ!」", "'Suffer, pathetic fool!'"));
4839 fire_ball(GF_DISINTEGRATE, 0, p_ptr->lev * 4, 4);
4840 take_hit(DAMAGE_NOESCAPE, p_ptr->lev * 4, wrath_reason, -1);
4841 reward = _("分解の球が発生した。", "generating disintegration ball");
4846 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4847 (void)restore_level();
4848 (void)restore_all_status();
4849 (void)true_healing(5000);
4850 reward = _("体力が回復した。", "healing");
4855 if (!buki_motteruka(INVEN_RARM) && !buki_motteruka(INVEN_LARM)) break;
4856 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4857 msg_print(_("「汝、武器に頼ることなかれ。」", "'Thou reliest too much on thy weapon.'"));
4860 if (buki_motteruka(INVEN_LARM))
4863 if (buki_motteruka(INVEN_RARM) && one_in_(2)) dummy = INVEN_RARM;
4865 object_desc(o_name, &inventory[dummy], OD_NAME_ONLY);
4866 (void)curse_weapon(FALSE, dummy);
4867 reward = format(_("%sが破壊された。", "destroying %s"), o_name);
4872 if (!inventory[INVEN_BODY].k_idx) break;
4873 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4874 msg_print(_("「汝、防具に頼ることなかれ。」", "'Thou reliest too much on thine equipment.'"));
4876 object_desc(o_name, &inventory[INVEN_BODY], OD_NAME_ONLY);
4877 (void)curse_armor();
4878 reward = format(_("%sが破壊された。", "destroying %s"), o_name);
4882 msg_format(_("%sの声がささやいた:", "The voice of %s whispers:"), chaos_patrons[p_ptr->chaos_patron]);
4883 msg_print(_("「我を怒りしめた罪を償うべし。」", "'Now thou shalt pay for annoying me.'"));
4885 switch (randint1(4))
4888 (void)activate_ty_curse(FALSE, &count);
4889 reward = _("禍々しい呪いをかけられた。", "cursing");
4892 activate_hi_summon(p_ptr->y, p_ptr->x, FALSE);
4893 reward = _("モンスターを召喚された。", "summoning hostile monsters");
4898 if (!buki_motteruka(INVEN_RARM) && !buki_motteruka(INVEN_LARM)) break;
4900 if (buki_motteruka(INVEN_LARM))
4903 if (buki_motteruka(INVEN_RARM) && one_in_(2)) dummy = INVEN_RARM;
4905 object_desc(o_name, &inventory[dummy], OD_NAME_ONLY);
4906 (void)curse_weapon(FALSE, dummy);
4907 reward = format(_("%sが破壊された。", "destroying %s"), o_name);
4911 if (!inventory[INVEN_BODY].k_idx) break;
4912 object_desc(o_name, &inventory[INVEN_BODY], OD_NAME_ONLY);
4913 (void)curse_armor();
4914 reward = format(_("%sが破壊された。", "destroying %s"), o_name);
4918 for (dummy = 0; dummy < 6; dummy++)
4920 (void)dec_stat(dummy, 10 + randint1(15), TRUE);
4922 reward = _("全能力値が下がった。", "decreasing all stats");
4929 msg_format(_("%sの声が轟き渡った:", "The voice of %s thunders:"), chaos_patrons[p_ptr->chaos_patron]);
4930 msg_print(_("「死ぬがよい、下僕よ!」", "'Die, mortal!'"));
4932 take_hit(DAMAGE_LOSELIFE, p_ptr->lev * 4, wrath_reason, -1);
4933 for (dummy = 0; dummy < 6; dummy++)
4935 (void)dec_stat(dummy, 10 + randint1(15), FALSE);
4937 activate_hi_summon(p_ptr->y, p_ptr->x, FALSE);
4938 (void)activate_ty_curse(FALSE, &count);
4943 if (buki_motteruka(INVEN_RARM))
4946 if (buki_motteruka(INVEN_LARM) && one_in_(2)) dummy = INVEN_LARM;
4948 else if (buki_motteruka(INVEN_LARM)) dummy = INVEN_LARM;
4950 if (dummy) (void)curse_weapon(FALSE, dummy);
4952 if (one_in_(2)) (void)curse_armor();
4957 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4958 msg_print(_("「死と破壊こそ我が喜びなり!」", "'Death and destruction! This pleaseth me!'"));
4960 (void)destroy_area(p_ptr->y, p_ptr->x, 25, FALSE);
4961 reward = _("ダンジョンが*破壊*された。", "*destruct*ing dungeon");
4966 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4967 msg_print(_("「我、汝の敵を抹殺せん!」", "'Let me relieve thee of thine oppressors!'"));
4968 (void)symbol_genocide(0, FALSE);
4969 reward = _("モンスターが抹殺された。", "genociding monsters");
4974 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4975 msg_print(_("「我、汝の敵を抹殺せん!」", "'Let me relieve thee of thine oppressors!'"));
4977 (void)mass_genocide(0, FALSE);
4978 reward = _("モンスターが抹殺された。", "genociding nearby monsters");
4983 msg_format(_("%sの力が敵を攻撃するのを感じた!", "You can feel the power of %s assault your enemies!"), chaos_patrons[p_ptr->chaos_patron]);
4984 (void)dispel_monsters(p_ptr->lev * 4);
4989 msg_format(_("%sはあなたを無視した。", "%s ignores you."), chaos_patrons[p_ptr->chaos_patron]);
4994 msg_format(_("%sは褒美として悪魔の使いをよこした!", "%s rewards you with a demonic servant!"),chaos_patrons[p_ptr->chaos_patron]);
4996 if (!summon_specific(-1, p_ptr->y, p_ptr->x, dun_level, SUMMON_DEMON, PM_FORCE_PET))
4997 msg_print(_("何も現れなかった...", "Nobody ever turns up..."));
4999 reward = _("悪魔がペットになった。", "a demonic servant");
5004 msg_format(_("%sは褒美として使いをよこした!", "%s rewards you with a servant!"),chaos_patrons[p_ptr->chaos_patron]);
5006 if (!summon_specific(-1, p_ptr->y, p_ptr->x, dun_level, 0, PM_FORCE_PET))
5007 msg_print(_("何も現れなかった...", "Nobody ever turns up..."));
5009 reward = _("モンスターがペットになった。", "a servant");
5014 msg_format(_("%sは褒美としてアンデッドの使いをよこした。", "%s rewards you with an undead servant!"),chaos_patrons[p_ptr->chaos_patron]);
5016 if (!summon_specific(-1, p_ptr->y, p_ptr->x, dun_level, SUMMON_UNDEAD, PM_FORCE_PET))
5017 msg_print(_("何も現れなかった...", "Nobody ever turns up..."));
5019 reward = _("アンデッドがペットになった。", "an undead servant");
5024 msg_format(_("%sの声がどもった:", "The voice of %s stammers:"),
5026 chaos_patrons[p_ptr->chaos_patron]);
5027 msg_format(_("「あー、あー、答えは %d/%d。質問は何?」", "'Uh... uh... the answer's %d/%d, what's the question?'"), type, effect);
5033 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, format(_("パトロンの報酬で%s", "The patron rewards you with %s."), reward));
5039 * XAngband: determine if a given location is "interesting"
5040 * based on target_set_accept function.
5042 static bool tgt_pt_accept(POSITION y, POSITION x)
5047 if (!(in_bounds(y, x))) return (FALSE);
5049 /* Player grid is always interesting */
5050 if ((y == p_ptr->y) && (x == p_ptr->x)) return (TRUE);
5052 /* Handle hallucination */
5053 if (p_ptr->image) return (FALSE);
5055 /* Examine the grid */
5056 c_ptr = &cave[y][x];
5058 /* Interesting memorized features */
5059 if (c_ptr->info & (CAVE_MARK))
5062 if (cave_have_flag_grid(c_ptr, FF_LESS)) return (TRUE);
5063 if (cave_have_flag_grid(c_ptr, FF_MORE)) return (TRUE);
5065 /* Notice quest features */
5066 if (cave_have_flag_grid(c_ptr, FF_QUEST_ENTER)) return (TRUE);
5067 if (cave_have_flag_grid(c_ptr, FF_QUEST_EXIT)) return (TRUE);
5076 * XAngband: Prepare the "temp" array for "tget_pt"
5077 * based on target_set_prepare funciton.
5079 static void tgt_pt_prepare(void)
5083 /* Reset "temp" array */
5086 if (!expand_list) return;
5088 /* Scan the current panel */
5089 for (y = 1; y < cur_hgt; y++)
5091 for (x = 1; x < cur_wid; x++)
5093 /* Require "interesting" contents */
5094 if (!tgt_pt_accept(y, x)) continue;
5096 /* Save the location */
5103 /* Target the nearest monster for shooting */
5104 ang_sort_comp = ang_sort_comp_distance;
5105 ang_sort_swap = ang_sort_swap_distance;
5107 /* Sort the positions */
5108 ang_sort(temp_x, temp_y, temp_n);
5112 * old -- from PsiAngband.
5114 bool tgt_pt(POSITION *x_ptr, POSITION *y_ptr)
5119 bool success = FALSE;
5124 get_screen_size(&wid, &hgt);
5134 msg_print(_("場所を選んでスペースキーを押して下さい。", "Select a point and press space."));
5135 msg_flag = FALSE; /* prevents "-more-" message. */
5137 while ((ch != ESCAPE) && !success)
5139 bool move_fast = FALSE;
5141 move_cursor_relative(y, x);
5153 if (player_bold(y, x)) ch = 0;
5156 else success = TRUE;
5160 /* XAngband: Move cursor to stairs */
5163 if (expand_list && temp_n)
5166 int cx = (panel_col_min + panel_col_max) / 2;
5167 int cy = (panel_row_min + panel_row_max) / 2;
5171 /* Skip stairs which have defferent distance */
5172 for (; n < temp_n; ++ n)
5174 cave_type *c_ptr = &cave[temp_y[n]][temp_x[n]];
5176 if (cave_have_flag_grid(c_ptr, FF_STAIRS) &&
5177 cave_have_flag_grid(c_ptr, ch == '>' ? FF_MORE : FF_LESS))
5184 if (n == temp_n) /* Loop out taget list */
5189 verify_panel(); /* Move cursor to player */
5192 p_ptr->update |= (PU_MONSTERS);
5195 p_ptr->redraw |= (PR_MAP);
5198 p_ptr->window |= (PW_OVERHEAD);
5203 else /* move cursor to next stair and change panel */
5208 dy = 2 * (y - cy) / hgt;
5209 dx = 2 * (x - cx) / wid;
5210 if (dy || dx) change_panel(dy, dx);
5216 /* Look up the direction */
5217 d = get_keymap_dir(ch);
5219 /* XTRA HACK MOVEFAST */
5220 if (isupper(ch)) move_fast = TRUE;
5222 /* Handle "direction" */
5228 /* XTRA HACK MOVEFAST */
5231 int mag = MIN(wid / 2, hgt / 2);
5241 /* Do not move horizontally if unnecessary */
5242 if (((x < panel_col_min + wid / 2) && (dx > 0)) ||
5243 ((x > panel_col_min + wid / 2) && (dx < 0)))
5248 /* Do not move vertically if unnecessary */
5249 if (((y < panel_row_min + hgt / 2) && (dy > 0)) ||
5250 ((y > panel_row_min + hgt / 2) && (dy < 0)))
5255 /* Apply the motion */
5256 if ((y >= panel_row_min + hgt) || (y < panel_row_min) ||
5257 (x >= panel_col_min + wid) || (x < panel_col_min))
5259 /* if (change_panel(dy, dx)) target_set_prepare(mode); */
5260 change_panel(dy, dx);
5263 /* Slide into legality */
5264 if (x >= cur_wid-1) x = cur_wid - 2;
5265 else if (x <= 0) x = 1;
5267 /* Slide into legality */
5268 if (y >= cur_hgt-1) y = cur_hgt- 2;
5269 else if (y <= 0) y = 1;
5276 /* Clear the top line */
5279 /* Recenter the map around the player */
5283 p_ptr->update |= (PU_MONSTERS);
5286 p_ptr->redraw |= (PR_MAP);
5289 p_ptr->window |= (PW_OVERHEAD);
5300 bool get_hack_dir(DIRECTION *dp)
5309 /* Global direction */
5312 /* (No auto-targeting) */
5314 /* Ask until satisfied */
5317 /* Choose a prompt */
5320 p = _("方向 ('*'でターゲット選択, ESCで中断)? ", "Direction ('*' to choose a target, Escape to cancel)? ");
5324 p = _("方向 ('5'でターゲットへ, '*'でターゲット再選択, ESCで中断)? ", "Direction ('5' for target, '*' to re-target, Escape to cancel)? ");
5327 /* Get a command (or Cancel) */
5328 if (!get_com(p, &command, TRUE)) break;
5332 if (command == '\r') command = 't';
5335 /* Convert various keys to "standard" keys */
5338 /* Use current target */
5349 /* Set new target */
5354 if (target_set(TARGET_KILL)) dir = 5;
5360 /* Look up the direction */
5361 dir = get_keymap_dir(command);
5367 /* Verify requested targets */
5368 if ((dir == 5) && !target_okay()) dir = 0;
5375 if (!dir) return (FALSE);
5377 /* Save the direction */
5380 /* Check for confusion */
5381 if (p_ptr->confused)
5384 /* Random direction */
5385 dir = ddd[randint0(8)];
5388 /* Notice confusion */
5389 if (command_dir != dir)
5392 msg_print(_("あなたは混乱している。", "You are confused."));
5395 /* Save direction */
5398 /* A "valid" direction was entered */
5404 * エネルギーの増加量10d5を速く計算するための関数
5407 #define Go_no_JuuJou 5*5*5*5*5*5*5*5*5*5
5409 s16b gain_energy(void)
5412 s32b energy_result = 10;
5415 tmp = randint0(Go_no_JuuJou);
5417 for (i = 0; i < 9; i ++){
5418 energy_result += tmp % 5;
5422 return (s16b)(energy_result + tmp);
5427 * @brief 射撃武器の攻撃に必要な基本消費エネルギーを返す/Return bow energy
5428 * @param sval 射撃武器のアイテム副分類ID
5429 * @return 消費する基本エネルギー
5431 ENERGY bow_energy(OBJECT_SUBTYPE_VALUE sval)
5433 ENERGY energy = 10000;
5435 /* Analyze the launcher */
5438 /* Sling and ammo */
5445 /* Short Bow and Arrow */
5452 /* Long Bow and Arrow */
5459 /* Bow of irresponsiblity and Arrow */
5466 /* Light Crossbow and Bolt */
5473 /* Heavy Crossbow and Bolt */
5488 int bow_tmul(OBJECT_SUBTYPE_VALUE sval)
5492 /* Analyze the launcher */
5495 /* Sling and ammo */
5502 /* Short Bow and Arrow */
5509 /* Long Bow and Arrow */
5516 /* Bow of irresponsiblity and Arrow */
5523 /* Light Crossbow and Bolt */
5530 /* Heavy Crossbow and Bolt */
5542 * Return alignment title
5544 cptr your_alignment(void)
5547 if (p_ptr->align > 150) return "大善";
5548 else if (p_ptr->align > 50) return "中善";
5549 else if (p_ptr->align > 10) return "小善";
5550 else if (p_ptr->align > -11) return "中立";
5551 else if (p_ptr->align > -51) return "小悪";
5552 else if (p_ptr->align > -151) return "中悪";
5555 if (p_ptr->align > 150) return "Lawful";
5556 else if (p_ptr->align > 50) return "Good";
5557 else if (p_ptr->align > 10) return "Neutral Good";
5558 else if (p_ptr->align > -11) return "Neutral";
5559 else if (p_ptr->align > -51) return "Neutral Evil";
5560 else if (p_ptr->align > -151) return "Evil";
5561 else return "Chaotic";
5567 * Return proficiency level of weapons and misc. skills (except riding)
5569 int weapon_exp_level(int weapon_exp)
5571 if (weapon_exp < WEAPON_EXP_BEGINNER) return EXP_LEVEL_UNSKILLED;
5572 else if (weapon_exp < WEAPON_EXP_SKILLED) return EXP_LEVEL_BEGINNER;
5573 else if (weapon_exp < WEAPON_EXP_EXPERT) return EXP_LEVEL_SKILLED;
5574 else if (weapon_exp < WEAPON_EXP_MASTER) return EXP_LEVEL_EXPERT;
5575 else return EXP_LEVEL_MASTER;
5580 * Return proficiency level of riding
5582 int riding_exp_level(int riding_exp)
5584 if (riding_exp < RIDING_EXP_BEGINNER) return EXP_LEVEL_UNSKILLED;
5585 else if (riding_exp < RIDING_EXP_SKILLED) return EXP_LEVEL_BEGINNER;
5586 else if (riding_exp < RIDING_EXP_EXPERT) return EXP_LEVEL_SKILLED;
5587 else if (riding_exp < RIDING_EXP_MASTER) return EXP_LEVEL_EXPERT;
5588 else return EXP_LEVEL_MASTER;
5593 * Return proficiency level of spells
5595 int spell_exp_level(int spell_exp)
5597 if (spell_exp < SPELL_EXP_BEGINNER) return EXP_LEVEL_UNSKILLED;
5598 else if (spell_exp < SPELL_EXP_SKILLED) return EXP_LEVEL_BEGINNER;
5599 else if (spell_exp < SPELL_EXP_EXPERT) return EXP_LEVEL_SKILLED;
5600 else if (spell_exp < SPELL_EXP_MASTER) return EXP_LEVEL_EXPERT;
5601 else return EXP_LEVEL_MASTER;
5606 * Display a rumor and apply its effects
5609 IDX rumor_num(char *zz, IDX max_idx)
5611 if (strcmp(zz, "*") == 0) return randint1(max_idx - 1);
5612 return (IDX)atoi(zz);
5615 cptr rumor_bind_name(char *base, cptr fullname)
5619 s = strstr(base, "{Name}");
5623 v = format("%s%s%s", base, fullname, (s + 6));
5633 void display_rumor(bool ex)
5641 if (randint0(3) == 0) section = 1;
5644 err = _(get_rnd_line_jonly("rumors_j.txt", section, Rumor, 10),
5645 get_rnd_line("rumors.txt", section, Rumor));
5646 if (err) strcpy(Rumor, _("嘘の噂もある。", "Some rumors are wrong."));
5650 if (strncmp(Rumor, "R:", 2) == 0)
5653 cptr rumor_msg = NULL;
5654 cptr rumor_eff_format = NULL;
5655 char fullname[1024] = "";
5657 if (tokenize(Rumor + 2, 3, zz, TOKENIZE_CHECKQUOTE) == 3)
5659 if (strcmp(zz[0], "ARTIFACT") == 0)
5663 object_type *q_ptr = &forge;
5664 artifact_type *a_ptr;
5668 a_idx = rumor_num(zz[1], max_a_idx);
5670 a_ptr = &a_info[a_idx];
5671 if (a_ptr->name) break;
5674 k_idx = lookup_kind(a_ptr->tval, a_ptr->sval);
5675 object_prep(q_ptr, k_idx);
5676 q_ptr->name1 = a_idx;
5677 q_ptr->ident = IDENT_STORE;
5678 object_desc(fullname, q_ptr, OD_NAME_ONLY);
5680 else if (strcmp(zz[0], "MONSTER") == 0)
5683 monster_race *r_ptr;
5687 r_idx = rumor_num(zz[1], max_r_idx);
5688 r_ptr = &r_info[r_idx];
5689 if (r_ptr->name) break;
5692 strcpy(fullname, r_name + r_ptr->name);
5694 /* Remember this monster */
5695 if (!r_ptr->r_sights)
5700 else if (strcmp(zz[0], "DUNGEON") == 0)
5703 dungeon_info_type *d_ptr;
5707 d_idx = rumor_num(zz[1], max_d_idx);
5708 d_ptr = &d_info[d_idx];
5709 if (d_ptr->name) break;
5712 strcpy(fullname, d_name + d_ptr->name);
5714 if (!max_dlv[d_idx])
5716 max_dlv[d_idx] = d_ptr->mindepth;
5717 rumor_eff_format = _("%sに帰還できるようになった。", "You can recall to %s.");
5720 else if (strcmp(zz[0], "TOWN") == 0)
5727 t_idx = rumor_num(zz[1], NO_TOWN);
5728 if (town[t_idx].name) break;
5731 strcpy(fullname, town[t_idx].name);
5733 visit = (1L << (t_idx - 1));
5734 if ((t_idx != SECRET_TOWN) && !(p_ptr->visit & visit))
5736 p_ptr->visit |= visit;
5737 rumor_eff_format = _("%sに行ったことがある気がする。", "You feel you have been to %s.");
5741 rumor_msg = rumor_bind_name(zz[2], fullname);
5742 msg_print(rumor_msg);
5743 if (rumor_eff_format)
5746 msg_format(rumor_eff_format, fullname);
5751 if (err) msg_print(_("この情報は間違っている。", "This information is wrong."));
5755 msg_format("%s", Rumor);