3 * @brief 雑多なその他の処理2 / effects of various "objects"
6 * Copyright (c) 1989 James E. Wilson, Robert A. Koeneke\n
7 * This software may be copied and distributed for educational, research, and\n
8 * not for profit purposes provided that this copyright and statement are\n
9 * included in all such copies.\n
10 * 2014 Deskull rearranged comment for Doxygen.
16 #include "object-curse.h"
18 #define REWARD_CHANCE 10
22 * @brief プレイヤーの経験値について整合性のためのチェックと調整を行う /
23 * Advance experience levels and print experience
26 void check_experience(void)
28 bool level_reward = FALSE;
29 bool level_mutation = FALSE;
30 bool level_inc_stat = FALSE;
31 bool android = (p_ptr->prace == RACE_ANDROID ? TRUE : FALSE);
32 PLAYER_LEVEL old_lev = p_ptr->lev;
34 /* Hack -- lower limit */
35 if (p_ptr->exp < 0) p_ptr->exp = 0;
36 if (p_ptr->max_exp < 0) p_ptr->max_exp = 0;
37 if (p_ptr->max_max_exp < 0) p_ptr->max_max_exp = 0;
39 /* Hack -- upper limit */
40 if (p_ptr->exp > PY_MAX_EXP) p_ptr->exp = PY_MAX_EXP;
41 if (p_ptr->max_exp > PY_MAX_EXP) p_ptr->max_exp = PY_MAX_EXP;
42 if (p_ptr->max_max_exp > PY_MAX_EXP) p_ptr->max_max_exp = PY_MAX_EXP;
44 /* Hack -- maintain "max" experience */
45 if (p_ptr->exp > p_ptr->max_exp) p_ptr->max_exp = p_ptr->exp;
47 /* Hack -- maintain "max max" experience */
48 if (p_ptr->max_exp > p_ptr->max_max_exp) p_ptr->max_max_exp = p_ptr->max_exp;
50 /* Redraw experience */
51 p_ptr->redraw |= (PR_EXP);
57 /* Lose levels while possible */
58 while ((p_ptr->lev > 1) &&
59 (p_ptr->exp < ((android ? player_exp_a : player_exp)[p_ptr->lev - 2] * p_ptr->expfact / 100L)))
64 /* Update some stuff */
65 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
67 /* Redraw some stuff */
68 p_ptr->redraw |= (PR_LEV | PR_TITLE);
71 p_ptr->window |= (PW_PLAYER);
78 /* Gain levels while possible */
79 while ((p_ptr->lev < PY_MAX_LEVEL) &&
80 (p_ptr->exp >= ((android ? player_exp_a : player_exp)[p_ptr->lev-1] * p_ptr->expfact / 100L)))
85 /* Save the highest level */
86 if (p_ptr->lev > p_ptr->max_plv)
88 p_ptr->max_plv = p_ptr->lev;
90 if ((p_ptr->pclass == CLASS_CHAOS_WARRIOR) ||
91 (p_ptr->muta2 & MUT2_CHAOS_GIFT))
95 if (p_ptr->prace == RACE_BEASTMAN)
97 if (one_in_(5)) level_mutation = TRUE;
99 level_inc_stat = TRUE;
101 do_cmd_write_nikki(NIKKI_LEVELUP, p_ptr->lev, NULL);
106 msg_format(_("レベル %d にようこそ。", "Welcome to level %d."), p_ptr->lev);
108 /* Update some stuff */
109 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
111 /* Redraw some stuff */
112 p_ptr->redraw |= (PR_LEV | PR_TITLE | PR_EXP);
115 p_ptr->window |= (PW_PLAYER | PW_SPELL | PW_INVEN);
127 if(!(p_ptr->max_plv % 10))
137 cnv_stat(p_ptr->stat_max[0], tmp);
138 prt(format(" a) 腕力 (現在値 %s)", tmp), 2, 14);
139 cnv_stat(p_ptr->stat_max[1], tmp);
140 prt(format(" b) 知能 (現在値 %s)", tmp), 3, 14);
141 cnv_stat(p_ptr->stat_max[2], tmp);
142 prt(format(" c) 賢さ (現在値 %s)", tmp), 4, 14);
143 cnv_stat(p_ptr->stat_max[3], tmp);
144 prt(format(" d) 器用 (現在値 %s)", tmp), 5, 14);
145 cnv_stat(p_ptr->stat_max[4], tmp);
146 prt(format(" e) 耐久 (現在値 %s)", tmp), 6, 14);
147 cnv_stat(p_ptr->stat_max[5], tmp);
148 prt(format(" f) 魅力 (現在値 %s)", tmp), 7, 14);
150 prt(" どの能力値を上げますか?", 1, 14);
152 cnv_stat(p_ptr->stat_max[0], tmp);
153 prt(format(" a) Str (cur %s)", tmp), 2, 14);
154 cnv_stat(p_ptr->stat_max[1], tmp);
155 prt(format(" b) Int (cur %s)", tmp), 3, 14);
156 cnv_stat(p_ptr->stat_max[2], tmp);
157 prt(format(" c) Wis (cur %s)", tmp), 4, 14);
158 cnv_stat(p_ptr->stat_max[3], tmp);
159 prt(format(" d) Dex (cur %s)", tmp), 5, 14);
160 cnv_stat(p_ptr->stat_max[4], tmp);
161 prt(format(" e) Con (cur %s)", tmp), 6, 14);
162 cnv_stat(p_ptr->stat_max[5], tmp);
163 prt(format(" f) Chr (cur %s)", tmp), 7, 14);
165 prt(" Which stat do you want to raise?", 1, 14);
170 if ((choice >= 'a') && (choice <= 'f')) break;
172 for(n = 0; n < 6; n++)
173 if (n != choice - 'a')
175 if (get_check(_("よろしいですか?", "Are you sure? "))) break;
177 do_inc_stat(choice - 'a');
180 else if(!(p_ptr->max_plv % 2))
181 do_inc_stat(randint0(6));
186 msg_print(_("あなたは変わった気がする...", "You feel different..."));
187 (void)gain_random_mutation(0);
188 level_mutation = FALSE;
192 * 報酬でレベルが上ると再帰的に check_experience() が
197 gain_level_reward(0);
198 level_reward = FALSE;
201 /* Update some stuff */
202 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
204 /* Redraw some stuff */
205 p_ptr->redraw |= (PR_LEV | PR_TITLE);
208 p_ptr->window |= (PW_PLAYER | PW_SPELL);
214 /* Load an autopick preference file */
215 if (old_lev != p_ptr->lev) autopick_load_pref(FALSE);
220 * @brief モンスターを倒した際の財宝svalを返す
221 * @param r_idx 倒したモンスターの種族ID
224 * Hack -- Return the "automatic coin type" of a monster race
225 * Used to allocate proper treasure when "Creeping coins" die
226 * XXX XXX XXX Note the use of actual "monster names"
228 static int get_coin_type(MONRACE_IDX r_idx)
230 /* Analyze monsters */
233 case MON_COPPER_COINS: return 2;
234 case MON_SILVER_COINS: return 5;
235 case MON_GOLD_COINS: return 10;
236 case MON_MITHRIL_COINS:
237 case MON_MITHRIL_GOLEM: return 16;
238 case MON_ADAMANT_COINS: return 17;
247 * @brief オブジェクトがクロークかどうかを判定する /
248 * Hack -- determine if a template is Cloak
249 * @param k_idx 判定したいオブジェクトのベースアイテムID
250 * @return オブジェクトがクロークならばTRUEを返す
252 static bool kind_is_cloak(KIND_OBJECT_IDX k_idx)
254 object_kind *k_ptr = &k_info[k_idx];
256 /* Analyze the item type */
257 if (k_ptr->tval == TV_CLOAK)
262 /* Assume not good */
268 * @brief オブジェクトが竿状武器かどうかを判定する /
269 * Hack -- determine if a template is Polearm
270 * @param k_idx 判定したいオブジェクトのベースアイテムID
271 * @return オブジェクトが竿状武器ならばTRUEを返す
273 static bool kind_is_polearm(KIND_OBJECT_IDX k_idx)
275 object_kind *k_ptr = &k_info[k_idx];
277 /* Analyze the item type */
278 if (k_ptr->tval == TV_POLEARM)
283 /* Assume not good */
289 * @brief オブジェクトが剣かどうかを判定する /
290 * Hack -- determine if a template is Sword
291 * @param k_idx 判定したいオブジェクトのベースアイテムID
292 * @return オブジェクトが剣ならばTRUEを返す
294 static bool kind_is_sword(KIND_OBJECT_IDX k_idx)
296 object_kind *k_ptr = &k_info[k_idx];
298 /* Analyze the item type */
299 if ((k_ptr->tval == TV_SWORD) && (k_ptr->sval > 2))
304 /* Assume not good */
310 * @brief オブジェクトが魔法書かどうかを判定する /
311 * Hack -- determine if a template is Book
312 * @param k_idx 判定したいオブジェクトのベースアイテムID
313 * @return オブジェクトが魔法書ならばTRUEを返す
315 static bool kind_is_book(KIND_OBJECT_IDX k_idx)
317 object_kind *k_ptr = &k_info[k_idx];
319 /* Analyze the item type */
320 if ((k_ptr->tval >= TV_LIFE_BOOK) && (k_ptr->tval <= TV_CRUSADE_BOOK))
325 /* Assume not good */
331 * @brief オブジェクトがベースアイテム時点でGOODかどうかを判定する /
332 * Hack -- determine if a template is Good book
333 * @param k_idx 判定したいオブジェクトのベースアイテムID
334 * @return オブジェクトがベースアイテム時点でGOODなアイテムならばTRUEを返す
336 static bool kind_is_good_book(KIND_OBJECT_IDX k_idx)
338 object_kind *k_ptr = &k_info[k_idx];
340 /* Analyze the item type */
341 if ((k_ptr->tval >= TV_LIFE_BOOK) && (k_ptr->tval <= TV_CRUSADE_BOOK) && (k_ptr->tval != TV_ARCANE_BOOK) && (k_ptr->sval > 1))
346 /* Assume not good */
352 * @brief オブジェクトが鎧かどうかを判定する /
353 * Hack -- determine if a template is Armor
354 * @param k_idx 判定したいオブジェクトのベースアイテムID
355 * @return オブジェクトが鎧ならばTRUEを返す
357 static bool kind_is_armor(KIND_OBJECT_IDX k_idx)
359 object_kind *k_ptr = &k_info[k_idx];
361 /* Analyze the item type */
362 if (k_ptr->tval == TV_HARD_ARMOR)
367 /* Assume not good */
373 * @brief オブジェクトが打撃武器かどうかを判定する /
374 * Hack -- determine if a template is hafted weapon
375 * @param k_idx 判定したいオブジェクトのベースアイテムID
376 * @return オブジェクトが打撃武器ならばTRUEを返す
378 static bool kind_is_hafted(KIND_OBJECT_IDX k_idx)
380 object_kind *k_ptr = &k_info[k_idx];
382 /* Analyze the item type */
383 if (k_ptr->tval == TV_HAFTED)
388 /* Assume not good */
393 * @brief クエストを達成状態にする /
394 * @param quest_num 達成状態にしたいクエストのID
397 void complete_quest(QUEST_IDX quest_num)
399 quest_type* const q_ptr = &quest[quest_num];
403 case QUEST_TYPE_RANDOM:
404 if (record_rand_quest) do_cmd_write_nikki(NIKKI_RAND_QUEST_C, quest_num, NULL);
407 if (record_fix_quest) do_cmd_write_nikki(NIKKI_FIX_QUEST_C, quest_num, NULL);
411 q_ptr->status = QUEST_STATUS_COMPLETED;
412 q_ptr->complev = (byte)p_ptr->lev;
414 q_ptr->comptime = playtime;
416 if (!(q_ptr->flags & QUEST_FLAG_SILENT))
418 play_music(TERM_XTRA_MUSIC_BASIC, MUSIC_BASIC_QUEST_CLEAR);
419 msg_print(_("クエストを達成した!", "You just completed your quest!"));
425 * @brief 現在フロアに残っている敵モンスターの数を返す /
426 * @return 現在の敵モンスターの数
428 static MONSTER_NUMBER count_all_hostile_monsters(void)
431 MONSTER_NUMBER number_mon = 0;
433 for (x = 0; x < cur_wid; ++ x)
435 for (y = 0; y < cur_hgt; ++ y)
437 MONSTER_IDX m_idx = cave[y][x].m_idx;
439 if (m_idx > 0 && is_hostile(&m_list[m_idx]))
450 * @brief 特定の敵を倒した際にクエスト達成処理 /
451 * Check for "Quest" completion when a quest monster is killed or charmed.
452 * @param m_ptr 撃破したモンスターの構造体参照ポインタ
455 void check_quest_completion(monster_type *m_ptr)
460 bool create_stairs = FALSE;
466 /* Get the location */
471 quest_num = p_ptr->inside_quest;
473 /* Search for an active quest on this dungeon level */
478 for (i = max_q_idx - 1; i > 0; i--)
480 quest_type* const q_ptr = &quest[i];
482 /* Quest is not active */
483 if (q_ptr->status != QUEST_STATUS_TAKEN)
486 /* Quest is not a dungeon quest */
487 if (q_ptr->flags & QUEST_FLAG_PRESET)
490 /* Quest is not on this level */
491 if ((q_ptr->level != dun_level) &&
492 (q_ptr->type != QUEST_TYPE_KILL_ANY_LEVEL))
495 /* Not a "kill monster" quest */
496 if ((q_ptr->type == QUEST_TYPE_FIND_ARTIFACT) ||
497 (q_ptr->type == QUEST_TYPE_FIND_EXIT))
500 /* Interesting quest */
501 if ((q_ptr->type == QUEST_TYPE_KILL_NUMBER) ||
502 (q_ptr->type == QUEST_TYPE_TOWER) ||
503 (q_ptr->type == QUEST_TYPE_KILL_ALL))
506 /* Interesting quest */
507 if (((q_ptr->type == QUEST_TYPE_KILL_LEVEL) ||
508 (q_ptr->type == QUEST_TYPE_KILL_ANY_LEVEL) ||
509 (q_ptr->type == QUEST_TYPE_RANDOM)) &&
510 (q_ptr->r_idx == m_ptr->r_idx))
517 /* Handle the current quest */
518 if (quest_num && (quest[quest_num].status == QUEST_STATUS_TAKEN))
521 quest_type* const q_ptr = &quest[quest_num];
525 case QUEST_TYPE_KILL_NUMBER:
529 if (q_ptr->cur_num >= q_ptr->num_mon)
531 complete_quest(quest_num);
537 case QUEST_TYPE_KILL_ALL:
539 if (!is_hostile(m_ptr)) break;
541 if (count_all_hostile_monsters() == 1)
543 if (q_ptr->flags & QUEST_FLAG_SILENT)
545 q_ptr->status = QUEST_STATUS_FINISHED;
549 complete_quest(quest_num);
554 case QUEST_TYPE_KILL_LEVEL:
555 case QUEST_TYPE_RANDOM:
557 /* Only count valid monsters */
558 if (q_ptr->r_idx != m_ptr->r_idx)
563 if (q_ptr->cur_num >= q_ptr->max_num)
565 complete_quest(quest_num);
567 if (!(q_ptr->flags & QUEST_FLAG_PRESET))
569 create_stairs = TRUE;
570 p_ptr->inside_quest = 0;
573 /* Finish the two main quests without rewarding */
574 if ((quest_num == QUEST_OBERON) || (quest_num == QUEST_SERPENT))
576 q_ptr->status = QUEST_STATUS_FINISHED;
579 if (q_ptr->type == QUEST_TYPE_RANDOM)
582 q_ptr->status = QUEST_STATUS_FINISHED;
587 case QUEST_TYPE_KILL_ANY_LEVEL:
590 if (q_ptr->cur_num >= q_ptr->max_num)
592 complete_quest(quest_num);
597 case QUEST_TYPE_TOWER:
599 if (!is_hostile(m_ptr)) break;
601 if (count_all_hostile_monsters() == 1)
603 q_ptr->status = QUEST_STATUS_STAGE_COMPLETED;
605 if((quest[QUEST_TOWER1].status == QUEST_STATUS_STAGE_COMPLETED) &&
606 (quest[QUEST_TOWER2].status == QUEST_STATUS_STAGE_COMPLETED) &&
607 (quest[QUEST_TOWER3].status == QUEST_STATUS_STAGE_COMPLETED))
610 complete_quest(QUEST_TOWER1);
618 /* Create a magical staircase */
624 while (cave_perma_bold(y, x) || cave[y][x].o_idx || (cave[y][x].info & CAVE_OBJECT) )
626 /* Pick a location */
627 scatter(&ny, &nx, y, x, 1, 0);
633 /* Explain the staircase */
634 msg_print(_("魔法の階段が現れた...", "A magical staircase appears..."));
636 /* Create stairs down */
637 cave_set_feat(y, x, feat_down_stair);
639 /* Remember to update everything */
640 p_ptr->update |= (PU_FLOW);
650 for (i = 0; i < (dun_level / 15)+1; i++)
652 /* Get local object */
655 /* Wipe the object */
658 /* Make a great object */
659 make_object(o_ptr, AM_GOOD | AM_GREAT);
661 /* Drop it in the dungeon */
662 (void)drop_near(o_ptr, -1, y, x);
668 * @brief 特定のアーティファクトを入手した際のクエスト達成処理 /
669 * Check for "Quest" completion when a quest monster is killed or charmed.
670 * @param o_ptr 入手したオブジェクトの構造体参照ポインタ
673 void check_find_art_quest_completion(object_type *o_ptr)
676 /* Check if completed a quest */
677 for (i = 0; i < max_q_idx; i++)
679 if((quest[i].type == QUEST_TYPE_FIND_ARTIFACT) &&
680 (quest[i].status == QUEST_STATUS_TAKEN) &&
681 (quest[i].k_idx == o_ptr->name1))
690 * @brief モンスターを撃破した際の述語メッセージを返す /
691 * Return monster death string
692 * @param r_ptr 撃破されたモンスターの種族情報を持つ構造体の参照ポインタ
693 * @return 撃破されたモンスターの述語
695 cptr extract_note_dies(monster_race *r_ptr)
697 /* Some monsters get "destroyed" */
698 if (!monster_living(r_ptr))
702 for (i = 0; i < 4; i++)
704 if (r_ptr->blow[i].method == RBM_EXPLODE)
706 return _("は爆発して粉々になった。", " explodes into tiny shreds.");
709 return _("を倒した。", " is destroyed.");
712 /* Assume a default death */
713 return _("は死んだ。", " dies.");
718 * @brief モンスターが死亡した時の処理 /
719 * Handle the "death" of a monster.
720 * @param m_idx 死亡したモンスターのID
721 * @param drop_item TRUEならばモンスターのドロップ処理を行う
722 * @return 撃破されたモンスターの述語
725 * Disperse treasures centered at the monster location based on the
726 * various flags contained in the monster flags fields.
727 * Check for "Quest" completion when a quest monster is killed.
728 * Note that only the player can induce "monster_death()" on Uniques.
729 * Thus (for now) all Quest monsters should be Uniques.
730 * Note that monsters can now carry objects, and when a monster dies,
731 * it drops all of its objects, which may disappear in crowded rooms.
734 void monster_death(MONSTER_IDX m_idx, bool drop_item)
743 monster_type *m_ptr = &m_list[m_idx];
745 monster_race *r_ptr = &r_info[m_ptr->r_idx];
747 bool visible = ((m_ptr->ml && !p_ptr->image) || (r_ptr->flags1 & RF1_UNIQUE));
751 bool do_gold = (!(r_ptr->flags1 & RF1_ONLY_ITEM));
752 bool do_item = (!(r_ptr->flags1 & RF1_ONLY_GOLD));
753 bool cloned = (m_ptr->smart & SM_CLONED) ? TRUE : FALSE;
754 int force_coin = get_coin_type(m_ptr->r_idx);
759 bool drop_chosen_item = drop_item && !cloned && !p_ptr->inside_arena
760 && !p_ptr->inside_battle && !is_pet(m_ptr);
762 /* The caster is dead? */
763 if (world_monster && world_monster == m_idx) world_monster = 0;
765 /* Notice changes in view */
766 if (r_ptr->flags7 & (RF7_LITE_MASK | RF7_DARK_MASK))
768 /* Update some things */
769 p_ptr->update |= (PU_MON_LITE);
772 /* Get the location */
776 if (record_named_pet && is_pet(m_ptr) && m_ptr->nickname)
780 monster_desc(m_name, m_ptr, MD_INDEF_VISIBLE);
781 do_cmd_write_nikki(NIKKI_NAMED_PET, 3, m_name);
784 /* Let monsters explode! */
785 for (i = 0; i < 4; i++)
787 if (r_ptr->blow[i].method == RBM_EXPLODE)
789 BIT_FLAGS flg = PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL;
790 EFFECT_ID typ = mbe_info[r_ptr->blow[i].effect].explode_type;
791 DICE_NUMBER d_dice = r_ptr->blow[i].d_dice;
792 DICE_SID d_side = r_ptr->blow[i].d_side;
793 HIT_POINT damage = damroll(d_dice, d_side);
795 project(m_idx, 3, y, x, damage, typ, flg, -1);
800 if (m_ptr->mflag2 & MFLAG2_CHAMELEON)
802 choose_new_monster(m_idx, TRUE, MON_CHAMELEON);
803 r_ptr = &r_info[m_ptr->r_idx];
806 /* Check for quest completion */
807 check_quest_completion(m_ptr);
809 /* Handle the possibility of player vanquishing arena combatant -KMW- */
810 if (p_ptr->inside_arena && !is_pet(m_ptr))
812 p_ptr->exit_bldg = TRUE;
814 if (p_ptr->arena_number > MAX_ARENA_MONS)
816 msg_print(_("素晴らしい!君こそ真の勝利者だ。", "You are a Genuine Champion!"));
820 msg_print(_("勝利!チャンピオンへの道を進んでいる。", "Victorious! You're on your way to becoming Champion."));
823 if (arena_info[p_ptr->arena_number].tval)
825 /* Get local object */
828 /* Prepare to make a prize */
829 object_prep(q_ptr, lookup_kind(arena_info[p_ptr->arena_number].tval, arena_info[p_ptr->arena_number].sval));
831 apply_magic(q_ptr, object_level, AM_NO_FIXED_ART);
833 /* Drop it in the dungeon */
834 (void)drop_near(q_ptr, -1, y, x);
837 if (p_ptr->arena_number > MAX_ARENA_MONS) p_ptr->arena_number++;
838 p_ptr->arena_number++;
843 /* Extract monster name */
844 monster_desc(m_name, m_ptr, MD_IGNORE_HALLU | MD_ASSUME_VISIBLE | MD_INDEF_VISIBLE);
846 do_cmd_write_nikki(NIKKI_ARENA, p_ptr->arena_number, m_name);
850 if (m_idx == p_ptr->riding)
852 if (rakuba(-1, FALSE))
854 msg_print(_("地面に落とされた。", "You have fallen from your riding pet."));
858 /* Drop a dead corpse? */
859 if (one_in_(r_ptr->flags1 & RF1_UNIQUE ? 1 : 4) &&
860 (r_ptr->flags9 & (RF9_DROP_CORPSE | RF9_DROP_SKELETON)) &&
861 !(p_ptr->inside_arena || p_ptr->inside_battle || cloned || ((m_ptr->r_idx == today_mon) && is_pet(m_ptr))))
863 /* Assume skeleton */
867 * We cannot drop a skeleton? Note, if we are in this check,
868 * we *know* we can drop at least a corpse or a skeleton
870 if (!(r_ptr->flags9 & RF9_DROP_SKELETON))
872 else if ((r_ptr->flags9 & RF9_DROP_CORPSE) && (r_ptr->flags1 & RF1_UNIQUE))
875 /* Else, a corpse is more likely unless we did a "lot" of damage */
876 else if (r_ptr->flags9 & RF9_DROP_CORPSE)
878 /* Lots of damage in one blow */
879 if ((0 - ((m_ptr->maxhp) / 4)) > m_ptr->hp)
881 if (one_in_(5)) corpse = TRUE;
885 if (!one_in_(5)) corpse = TRUE;
889 /* Get local object */
892 /* Prepare to make an object */
893 object_prep(q_ptr, lookup_kind(TV_CORPSE, (corpse ? SV_CORPSE : SV_SKELETON)));
895 apply_magic(q_ptr, object_level, AM_NO_FIXED_ART);
897 q_ptr->pval = m_ptr->r_idx;
899 /* Drop it in the dungeon */
900 (void)drop_near(q_ptr, -1, y, x);
903 /* Drop objects being carried */
904 monster_drop_carried_objects(m_ptr);
906 if (r_ptr->flags1 & RF1_DROP_GOOD) mo_mode |= AM_GOOD;
907 if (r_ptr->flags1 & RF1_DROP_GREAT) mo_mode |= AM_GREAT;
909 switch (m_ptr->r_idx)
911 case MON_PINK_HORROR:
912 /* Pink horrors are replaced with 2 Blue horrors */
913 if (!(p_ptr->inside_arena || p_ptr->inside_battle))
917 for (i = 0; i < 2; i++)
920 bool pet = is_pet(m_ptr);
923 if (pet) mode |= PM_FORCE_PET;
925 if (summon_specific((pet ? -1 : m_idx), wy, wx, 100, SUMMON_BLUE_HORROR, mode))
927 if (player_can_see_bold(wy, wx))
933 msg_print(_("ピンク・ホラーは分裂した!", "The Pink horror divides!"));
937 case MON_BLOODLETTER:
938 /* Bloodletters of Khorne may drop a blade of chaos */
939 if (drop_chosen_item && (randint1(100) < 15))
941 /* Get local object */
944 /* Prepare to make a Blade of Chaos */
945 object_prep(q_ptr, lookup_kind(TV_SWORD, SV_BLADE_OF_CHAOS));
947 apply_magic(q_ptr, object_level, AM_NO_FIXED_ART | mo_mode);
949 /* Drop it in the dungeon */
950 (void)drop_near(q_ptr, -1, y, x);
955 if (drop_chosen_item && (dun_level > 9))
957 /* Get local object */
960 /* Wipe the object */
963 /* Activate restriction */
964 if ((dun_level > 49) && one_in_(5))
965 get_obj_num_hook = kind_is_good_book;
967 get_obj_num_hook = kind_is_book;
970 make_object(q_ptr, mo_mode);
972 /* Drop it in the dungeon */
973 (void)drop_near(q_ptr, -1, y, x);
979 * Mega^3-hack: killing a 'Warrior of the Dawn' is likely to
980 * spawn another in the fallen one's place!
982 if (!p_ptr->inside_arena && !p_ptr->inside_battle)
986 POSITION wy = y, wx = x;
988 bool pet = is_pet(m_ptr);
992 scatter(&wy, &wx, y, x, 20, 0);
994 while (!(in_bounds(wy, wx) && cave_empty_bold2(wy, wx)) && --attempts);
999 if (pet) mode |= PM_FORCE_PET;
1001 if (summon_specific((pet ? -1 : m_idx), wy, wx, 100, SUMMON_DAWN, mode))
1003 if (player_can_see_bold(wy, wx))
1004 msg_print(_("新たな戦士が現れた!", "A new warrior steps forth!"));
1012 /* One more ultra-hack: An Unmaker goes out with a big bang! */
1014 BIT_FLAGS flg = PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL;
1015 (void)project(m_idx, 6, y, x, 100, GF_CHAOS, flg, -1);
1019 case MON_UNICORN_ORD:
1022 /* Reward for "lazy" player */
1023 if (p_ptr->pseikaku == SEIKAKU_NAMAKE)
1025 ARTIFACT_IDX a_idx = 0;
1026 artifact_type *a_ptr = NULL;
1028 if (!drop_chosen_item) break;
1032 switch (randint0(3))
1035 a_idx = ART_NAMAKE_HAMMER;
1038 a_idx = ART_NAMAKE_BOW;
1041 a_idx = ART_NAMAKE_ARMOR;
1045 a_ptr = &a_info[a_idx];
1047 while (a_ptr->cur_num);
1049 /* Create the artifact */
1050 if (create_named_art(a_idx, y, x))
1054 /* Hack -- Memorize location of artifact in saved floors */
1055 if (character_dungeon) a_ptr->floor_id = p_ptr->floor_id;
1057 else if (!preserve_mode) a_ptr->cur_num = 1;
1062 if (!drop_chosen_item) break;
1064 /* Get local object */
1067 /* Mega-Hack -- Prepare to make "Grond" */
1068 object_prep(q_ptr, lookup_kind(TV_HAFTED, SV_GROND));
1070 /* Mega-Hack -- Mark this item as "Grond" */
1071 q_ptr->name1 = ART_GROND;
1073 /* Mega-Hack -- Actually create "Grond" */
1074 apply_magic(q_ptr, -1, AM_GOOD | AM_GREAT);
1076 /* Drop it in the dungeon */
1077 (void)drop_near(q_ptr, -1, y, x);
1079 /* Get local object */
1082 /* Mega-Hack -- Prepare to make "Chaos" */
1083 object_prep(q_ptr, lookup_kind(TV_CROWN, SV_CHAOS));
1085 /* Mega-Hack -- Mark this item as "Chaos" */
1086 q_ptr->name1 = ART_CHAOS;
1088 /* Mega-Hack -- Actually create "Chaos" */
1089 apply_magic(q_ptr, -1, AM_GOOD | AM_GREAT);
1091 /* Drop it in the dungeon */
1092 (void)drop_near(q_ptr, -1, y, x);
1095 case MON_B_DEATH_SWORD:
1096 if (drop_chosen_item)
1098 /* Get local object */
1101 /* Prepare to make a broken sword */
1102 object_prep(q_ptr, lookup_kind(TV_SWORD, randint1(2)));
1104 /* Drop it in the dungeon */
1105 (void)drop_near(q_ptr, -1, y, x);
1111 if (drop_chosen_item && ((m_ptr->r_idx == MON_A_GOLD) ||
1112 ((m_ptr->r_idx == MON_A_SILVER) && (r_ptr->r_akills % 5 == 0))))
1114 /* Get local object */
1117 /* Prepare to make a Can of Toys */
1118 object_prep(q_ptr, lookup_kind(TV_CHEST, SV_CHEST_KANDUME));
1120 apply_magic(q_ptr, object_level, AM_NO_FIXED_ART);
1122 /* Drop it in the dungeon */
1123 (void)drop_near(q_ptr, -1, y, x);
1129 BIT_FLAGS flg = PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL;
1130 (void)project(m_idx, 3, y, x, damroll(20, 10), GF_FIRE, flg, -1);
1135 if (!drop_chosen_item) break;
1137 switch (r_ptr->d_char)
1142 /* Get local object */
1145 /* Wipe the object */
1148 /* Activate restriction */
1149 get_obj_num_hook = kind_is_cloak;
1152 make_object(q_ptr, mo_mode);
1154 /* Drop it in the dungeon */
1155 (void)drop_near(q_ptr, -1, y, x);
1162 /* Get local object */
1165 /* Wipe the object */
1168 /* Activate restriction */
1169 get_obj_num_hook = kind_is_polearm;
1171 /* Make a poleweapon */
1172 make_object(q_ptr, mo_mode);
1174 /* Drop it in the dungeon */
1175 (void)drop_near(q_ptr, -1, y, x);
1182 /* Get local object */
1185 /* Wipe the object */
1188 /* Activate restriction */
1189 get_obj_num_hook = kind_is_armor;
1191 /* Make a hard armor */
1192 make_object(q_ptr, mo_mode);
1194 /* Drop it in the dungeon */
1195 (void)drop_near(q_ptr, -1, y, x);
1202 /* Get local object */
1205 /* Wipe the object */
1208 /* Activate restriction */
1209 get_obj_num_hook = kind_is_hafted;
1211 /* Make a hafted weapon */
1212 make_object(q_ptr, mo_mode);
1214 /* Drop it in the dungeon */
1215 (void)drop_near(q_ptr, -1, y, x);
1220 if (m_ptr->r_idx != MON_STORMBRINGER)
1222 /* Get local object */
1225 /* Wipe the object */
1228 /* Activate restriction */
1229 get_obj_num_hook = kind_is_sword;
1232 make_object(q_ptr, mo_mode);
1234 /* Drop it in the dungeon */
1235 (void)drop_near(q_ptr, -1, y, x);
1242 /* Mega-Hack -- drop fixed items */
1243 if (drop_chosen_item)
1245 ARTIFACT_IDX a_idx = 0;
1248 for(i = 0; i < 4; i++)
1250 if(!r_ptr->artifact_id[i]) break;
1251 a_idx = r_ptr->artifact_id[i];
1252 chance = r_ptr->artifact_percent[i];
1255 if ((a_idx > 0) && ((randint0(100) < chance) || p_ptr->wizard))
1257 artifact_type *a_ptr = &a_info[a_idx];
1259 if (!a_ptr->cur_num)
1261 /* Create the artifact */
1262 if (create_named_art(a_idx, y, x))
1266 /* Hack -- Memorize location of artifact in saved floors */
1267 if (character_dungeon) a_ptr->floor_id = p_ptr->floor_id;
1269 else if (!preserve_mode) a_ptr->cur_num = 1;
1273 if ((r_ptr->flags7 & RF7_GUARDIAN) && (d_info[dungeon_type].final_guardian == m_ptr->r_idx))
1275 KIND_OBJECT_IDX k_idx = d_info[dungeon_type].final_object ? d_info[dungeon_type].final_object
1276 : lookup_kind(TV_SCROLL, SV_SCROLL_ACQUIREMENT);
1278 if (d_info[dungeon_type].final_artifact)
1280 a_idx = d_info[dungeon_type].final_artifact;
1281 artifact_type *a_ptr = &a_info[a_idx];
1283 if (!a_ptr->cur_num)
1285 /* Create the artifact */
1286 if (create_named_art(a_idx, y, x))
1290 /* Hack -- Memorize location of artifact in saved floors */
1291 if (character_dungeon) a_ptr->floor_id = p_ptr->floor_id;
1293 else if (!preserve_mode) a_ptr->cur_num = 1;
1295 /* Prevent rewarding both artifact and "default" object */
1296 if (!d_info[dungeon_type].final_object) k_idx = 0;
1302 /* Get local object */
1305 /* Prepare to make a reward */
1306 object_prep(q_ptr, k_idx);
1308 apply_magic(q_ptr, object_level, AM_NO_FIXED_ART | AM_GOOD);
1310 /* Drop it in the dungeon */
1311 (void)drop_near(q_ptr, -1, y, x);
1313 msg_format(_("あなたは%sを制覇した!", "You have conquered %s!"),d_name+d_info[dungeon_type].name);
1317 /* Determine how much we can drop */
1318 if ((r_ptr->flags1 & RF1_DROP_60) && (randint0(100) < 60)) number++;
1319 if ((r_ptr->flags1 & RF1_DROP_90) && (randint0(100) < 90)) number++;
1320 if (r_ptr->flags1 & RF1_DROP_1D2) number += damroll(1, 2);
1321 if (r_ptr->flags1 & RF1_DROP_2D2) number += damroll(2, 2);
1322 if (r_ptr->flags1 & RF1_DROP_3D2) number += damroll(3, 2);
1323 if (r_ptr->flags1 & RF1_DROP_4D2) number += damroll(4, 2);
1325 if (cloned && !(r_ptr->flags1 & RF1_UNIQUE))
1326 number = 0; /* Clones drop no stuff unless Cloning Pits */
1328 if (is_pet(m_ptr) || p_ptr->inside_battle || p_ptr->inside_arena)
1329 number = 0; /* Pets drop no stuff */
1330 if (!drop_item && (r_ptr->d_char != '$')) number = 0;
1332 if((r_ptr->flags2 & (RF2_MULTIPLY)) && (r_ptr->r_akills > 1024))
1333 number = 0; /* Limit of Multiply monster drop */
1335 /* Hack -- handle creeping coins */
1336 coin_type = force_coin;
1338 /* Average dungeon and monster levels */
1339 object_level = (dun_level + r_ptr->level) / 2;
1341 /* Drop some objects */
1342 for (j = 0; j < number; j++)
1344 /* Get local object */
1347 /* Wipe the object */
1351 if (do_gold && (!do_item || (randint0(100) < 50)))
1353 /* Make some gold */
1354 if (!make_gold(q_ptr)) continue;
1362 /* Make an object */
1363 if (!make_object(q_ptr, mo_mode)) continue;
1368 /* Drop it in the dungeon */
1369 (void)drop_near(q_ptr, -1, y, x);
1372 /* Reset the object level */
1373 object_level = base_level;
1375 /* Reset "coin" type */
1379 /* Take note of any dropped treasure */
1380 if (visible && (dump_item || dump_gold))
1382 /* Take notes on treasure */
1383 lore_treasure(m_idx, dump_item, dump_gold);
1386 /* Only process "Quest Monsters" */
1387 if (!(r_ptr->flags1 & RF1_QUESTOR)) return;
1388 if (p_ptr->inside_battle) return;
1391 if ((m_ptr->r_idx == MON_SERPENT) && !cloned)
1394 p_ptr->total_winner = TRUE;
1396 /* Redraw the "title" */
1397 p_ptr->redraw |= (PR_TITLE);
1399 play_music(TERM_XTRA_MUSIC_BASIC, MUSIC_BASIC_FINAL_QUEST_CLEAR);
1401 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, _("見事に変愚蛮怒の勝利者となった!", "become *WINNER* of Hengband finely!"));
1403 if ((p_ptr->pclass == CLASS_CHAOS_WARRIOR) || (p_ptr->muta2 & MUT2_CHAOS_GIFT))
1405 msg_format(_("%sからの声が響いた。", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
1406 msg_print(_("『よくやった、定命の者よ!』", "'Thou art donst well, mortal!'"));
1409 /* Congratulations */
1410 msg_print(_("*** おめでとう ***", "*** CONGRATULATIONS ***"));
1411 msg_print(_("あなたはゲームをコンプリートしました。", "You have won the game!"));
1412 msg_print(_("準備が整ったら引退(自殺コマンド)しても結構です。", "You may retire (commit suicide) when you are ready."));
1417 * @brief モンスターに与えたダメージの修正処理 /
1418 * Modify the physical damage done to the monster.
1419 * @param m_ptr ダメージを受けるモンスターの構造体参照ポインタ
1420 * @param dam ダメージ基本値
1421 * @param is_psy_spear 攻撃手段が光の剣ならばTRUE
1422 * @return 修正を行った結果のダメージ量
1425 * (for example when it's invulnerable or shielded)
1426 * ToDo: Accept a damage-type to calculate the modified damage from
1427 * things like fire, frost, lightning, poison, ... attacks.
1428 * "type" is not yet used and should be 0.
1431 HIT_POINT mon_damage_mod(monster_type *m_ptr, HIT_POINT dam, bool is_psy_spear)
1433 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1435 if ((r_ptr->flagsr & RFR_RES_ALL) && dam > 0)
1438 if ((dam == 0) && one_in_(3)) dam = 1;
1441 if (MON_INVULNER(m_ptr))
1445 if (!p_ptr->blind && is_seen(m_ptr))
1447 msg_print(_("バリアを切り裂いた!", "The barrier is penetrated!"));
1450 else if (!one_in_(PENETRATE_INVULNERABILITY))
1460 * @brief モンスターに与えたダメージを元に経験値を加算する /
1461 * Calculate experience point to be get
1462 * @param dam 与えたダメージ量
1463 * @param m_ptr ダメージを与えたモンスターの構造体参照ポインタ
1467 * Even the 64 bit operation is not big enough to avoid overflaw
1468 * unless we carefully choose orders of multiplication and division.
1469 * Get the coefficient first, and multiply (potentially huge) base
1470 * experience point of a monster later.
1473 static void get_exp_from_mon(HIT_POINT dam, monster_type *m_ptr)
1475 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1482 if (!m_ptr->r_idx) return;
1483 if (is_pet(m_ptr) || p_ptr->inside_battle) return;
1486 * - Ratio of monster's level to player's level effects
1487 * - Varying speed effects
1488 * - Get a fraction in proportion of damage point
1490 new_exp = r_ptr->level * SPEED_TO_ENERGY(m_ptr->mspeed) * dam;
1493 div_l = (p_ptr->max_plv+2) * SPEED_TO_ENERGY(r_ptr->speed);
1495 /* Use (average maxhp * 2) as a denominator */
1496 if (!(r_ptr->flags1 & RF1_FORCE_MAXHP))
1497 s64b_mul(&div_h, &div_l, 0, r_ptr->hdice * (ironman_nightmare ? 2 : 1) * (r_ptr->hside + 1));
1499 s64b_mul(&div_h, &div_l, 0, r_ptr->hdice * (ironman_nightmare ? 2 : 1) * r_ptr->hside * 2);
1501 /* Special penalty in the wilderness */
1502 if (!dun_level && (!(r_ptr->flags8 & RF8_WILD_ONLY) || !(r_ptr->flags1 & RF1_UNIQUE)))
1503 s64b_mul(&div_h, &div_l, 0, 5);
1505 /* Do division first to prevent overflaw */
1506 s64b_div(&new_exp, &new_exp_frac, div_h, div_l);
1508 /* Special penalty for mutiply-monster */
1509 if ((r_ptr->flags2 & RF2_MULTIPLY) || (m_ptr->r_idx == MON_DAWN))
1511 int monnum_penarty = r_ptr->r_akills / 400;
1512 if (monnum_penarty > 8) monnum_penarty = 8;
1514 while (monnum_penarty--)
1517 s64b_RSHIFT(new_exp, new_exp_frac, 2);
1521 /* Special penalty for rest_and_shoot exp scum */
1522 if ((m_ptr->dealt_damage > m_ptr->max_maxhp) && (m_ptr->hp >= 0))
1524 int over_damage = m_ptr->dealt_damage / m_ptr->max_maxhp;
1525 if (over_damage > 32) over_damage = 32;
1527 while (over_damage--)
1530 s64b_mul(&new_exp, &new_exp_frac, 0, 9);
1531 s64b_div(&new_exp, &new_exp_frac, 0, 10);
1535 /* Finally multiply base experience point of the monster */
1536 s64b_mul(&new_exp, &new_exp_frac, 0, r_ptr->mexp);
1538 /* Gain experience */
1539 gain_exp_64(new_exp, new_exp_frac);
1544 * @brief モンスターのHPをダメージに応じて減算する /
1545 * Decreases monsters hit points, handling monster death.
1546 * @param dam 与えたダメージ量
1547 * @param m_idx ダメージを与えたモンスターのID
1548 * @param fear ダメージによってモンスターが恐慌状態に陥ったならばTRUEを返す
1549 * @param note モンスターが倒された際の特別なメッセージ述語
1553 * We return TRUE if the monster has been killed (and deleted).
1554 * We announce monster death (using an optional "death message"
1555 * if given, and a otherwise a generic killed/destroyed message).
1556 * Only "physical attacks" can induce the "You have slain" message.
1557 * Missile and Spell attacks will induce the "dies" message, or
1558 * various "specialized" messages. Note that "You have destroyed"
1559 * and "is destroyed" are synonyms for "You have slain" and "dies".
1560 * Hack -- unseen monsters yield "You have killed it." message.
1561 * Added fear (DGK) and check whether to print fear messages -CWS
1562 * Made name, sex, and capitalization generic -BEN-
1563 * As always, the "ghost" processing is a total hack.
1564 * Hack -- we "delay" fear messages by passing around a "fear" flag.
1565 * XXX XXX XXX Consider decreasing monster experience over time, say,
1566 * by using "(m_exp * m_lev * (m_lev)) / (p_lev * (m_lev + n_killed))"
1567 * instead of simply "(m_exp * m_lev) / (p_lev)", to make the first
1568 * monster worth more than subsequent monsters. This would also need
1569 * to induce changes in the monster recall code.
1572 bool mon_take_hit(MONSTER_IDX m_idx, HIT_POINT dam, bool *fear, cptr note)
1574 monster_type *m_ptr = &m_list[m_idx];
1575 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1577 monster_type exp_mon;
1579 /* Innocent until proven otherwise */
1580 bool innocent = TRUE, thief = FALSE;
1584 (void)COPY(&exp_mon, m_ptr, monster_type);
1586 expdam = (m_ptr->hp > dam) ? dam : m_ptr->hp;
1588 get_exp_from_mon(expdam, &exp_mon);
1590 /* Genocided by chaos patron */
1591 if (!m_ptr->r_idx) m_idx = 0;
1593 /* Redraw (later) if needed */
1594 if (p_ptr->health_who == m_idx) p_ptr->redraw |= (PR_HEALTH);
1595 if (p_ptr->riding == m_idx) p_ptr->redraw |= (PR_UHEALTH);
1598 (void)set_monster_csleep(m_idx, 0);
1600 /* Hack - Cancel any special player stealth magics. -LM- */
1601 if (p_ptr->special_defense & NINJA_S_STEALTH)
1603 set_superstealth(FALSE);
1606 /* Genocided by chaos patron */
1607 if (!m_idx) return TRUE;
1612 m_ptr->dealt_damage += dam;
1613 if(m_ptr->dealt_damage > m_ptr->max_maxhp * 100) m_ptr->dealt_damage = m_ptr->max_maxhp * 100;
1616 msg_format( _("合計%d/%dのダメージを与えた。","You do %d (out of %d) damage."),
1617 m_ptr->dealt_damage, m_ptr->maxhp);
1620 /* It is dead now */
1625 if (r_info[m_ptr->r_idx].flags7 & RF7_TANUKI)
1627 /* You might have unmasked Tanuki first time */
1628 r_ptr = &r_info[m_ptr->r_idx];
1629 m_ptr->ap_r_idx = m_ptr->r_idx;
1630 if (r_ptr->r_sights < MAX_SHORT) r_ptr->r_sights++;
1633 if (m_ptr->mflag2 & MFLAG2_CHAMELEON)
1635 /* You might have unmasked Chameleon first time */
1636 r_ptr = real_r_ptr(m_ptr);
1637 if (r_ptr->r_sights < MAX_SHORT) r_ptr->r_sights++;
1640 if (!(m_ptr->smart & SM_CLONED))
1642 /* When the player kills a Unique, it stays dead */
1643 if (r_ptr->flags1 & RF1_UNIQUE)
1647 /* Mega-Hack -- Banor & Lupart */
1648 if ((m_ptr->r_idx == MON_BANOR) || (m_ptr->r_idx == MON_LUPART))
1650 r_info[MON_BANORLUPART].max_num = 0;
1651 r_info[MON_BANORLUPART].r_pkills++;
1652 r_info[MON_BANORLUPART].r_akills++;
1653 if (r_info[MON_BANORLUPART].r_tkills < MAX_SHORT) r_info[MON_BANORLUPART].r_tkills++;
1655 else if (m_ptr->r_idx == MON_BANORLUPART)
1657 r_info[MON_BANOR].max_num = 0;
1658 r_info[MON_BANOR].r_pkills++;
1659 r_info[MON_BANOR].r_akills++;
1660 if (r_info[MON_BANOR].r_tkills < MAX_SHORT) r_info[MON_BANOR].r_tkills++;
1661 r_info[MON_LUPART].max_num = 0;
1662 r_info[MON_LUPART].r_pkills++;
1663 r_info[MON_LUPART].r_akills++;
1664 if (r_info[MON_LUPART].r_tkills < MAX_SHORT) r_info[MON_LUPART].r_tkills++;
1668 /* When the player kills a Nazgul, it stays dead */
1669 else if (r_ptr->flags7 & RF7_NAZGUL) r_ptr->max_num--;
1672 /* Count all monsters killed */
1673 if (r_ptr->r_akills < MAX_SHORT) r_ptr->r_akills++;
1675 /* Recall even invisible uniques or winners */
1676 if ((m_ptr->ml && !p_ptr->image) || (r_ptr->flags1 & RF1_UNIQUE))
1678 /* Count kills this life */
1679 if ((m_ptr->mflag2 & MFLAG2_KAGE) && (r_info[MON_KAGE].r_pkills < MAX_SHORT)) r_info[MON_KAGE].r_pkills++;
1680 else if (r_ptr->r_pkills < MAX_SHORT) r_ptr->r_pkills++;
1682 /* Count kills in all lives */
1683 if ((m_ptr->mflag2 & MFLAG2_KAGE) && (r_info[MON_KAGE].r_tkills < MAX_SHORT)) r_info[MON_KAGE].r_tkills++;
1684 else if (r_ptr->r_tkills < MAX_SHORT) r_ptr->r_tkills++;
1686 /* Hack -- Auto-recall */
1687 monster_race_track(m_ptr->ap_r_idx);
1690 /* Extract monster name */
1691 monster_desc(m_name, m_ptr, MD_TRUE_NAME);
1693 /* Don't kill Amberites */
1694 if ((r_ptr->flags3 & RF3_AMBERITE) && one_in_(2))
1696 int curses = 1 + randint1(3);
1697 bool stop_ty = FALSE;
1700 msg_format(_("%^sは恐ろしい血の呪いをあなたにかけた!", "%^s puts a terrible blood curse on you!"), m_name);
1701 curse_equipment(100, 50);
1705 stop_ty = activate_ty_curse(stop_ty, &count);
1710 if (r_ptr->flags2 & RF2_CAN_SPEAK)
1712 char line_got[1024];
1714 /* Dump a message */
1715 if (!get_rnd_line(_("mondeath_j.txt", "mondeath.txt"), m_ptr->r_idx, line_got))
1717 msg_format("%^s %s", m_name, line_got);
1720 if (m_ptr->r_idx == MON_SERPENT)
1722 /* Make screen dump */
1723 screen_dump = make_screen_dump();
1728 if (!(d_info[dungeon_type].flags1 & DF1_BEGINNER))
1730 if (!dun_level && !ambush_flag && !p_ptr->inside_arena)
1732 chg_virtue(V_VALOUR, -1);
1734 else if (r_ptr->level > dun_level)
1736 if (randint1(10) <= (r_ptr->level - dun_level))
1737 chg_virtue(V_VALOUR, 1);
1739 if (r_ptr->level > 60)
1741 chg_virtue(V_VALOUR, 1);
1743 if (r_ptr->level >= 2 * (p_ptr->lev+1))
1744 chg_virtue(V_VALOUR, 2);
1747 if (r_ptr->flags1 & RF1_UNIQUE)
1749 if (r_ptr->flags3 & (RF3_EVIL | RF3_GOOD)) chg_virtue(V_HARMONY, 2);
1751 if (r_ptr->flags3 & RF3_GOOD)
1753 chg_virtue(V_UNLIFE, 2);
1754 chg_virtue(V_VITALITY, -2);
1757 if (one_in_(3)) chg_virtue(V_INDIVIDUALISM, -1);
1760 if (m_ptr->r_idx == MON_BEGGAR || m_ptr->r_idx == MON_LEPER)
1762 chg_virtue(V_COMPASSION, -1);
1765 if ((r_ptr->flags3 & RF3_GOOD) &&
1766 ((r_ptr->level) / 10 + (3 * dun_level) >= randint1(100)))
1767 chg_virtue(V_UNLIFE, 1);
1769 if (r_ptr->d_char == 'A')
1771 if (r_ptr->flags1 & RF1_UNIQUE)
1772 chg_virtue(V_FAITH, -2);
1773 else if ((r_ptr->level) / 10 + (3 * dun_level) >= randint1(100))
1775 if (r_ptr->flags3 & RF3_GOOD) chg_virtue(V_FAITH, -1);
1776 else chg_virtue(V_FAITH, 1);
1779 else if (r_ptr->flags3 & RF3_DEMON)
1781 if (r_ptr->flags1 & RF1_UNIQUE)
1782 chg_virtue(V_FAITH, 2);
1783 else if ((r_ptr->level) / 10 + (3 * dun_level) >= randint1(100))
1784 chg_virtue(V_FAITH, 1);
1787 if ((r_ptr->flags3 & RF3_UNDEAD) && (r_ptr->flags1 & RF1_UNIQUE))
1788 chg_virtue(V_VITALITY, 2);
1790 if (r_ptr->r_deaths)
1792 if (r_ptr->flags1 & RF1_UNIQUE)
1794 chg_virtue(V_HONOUR, 10);
1796 else if ((r_ptr->level) / 10 + (2 * dun_level) >= randint1(100))
1798 chg_virtue(V_HONOUR, 1);
1801 if ((r_ptr->flags2 & RF2_MULTIPLY) && (r_ptr->r_akills > 1000) && one_in_(10))
1803 chg_virtue(V_VALOUR, -1);
1806 for (i = 0; i < 4; i++)
1808 if (r_ptr->blow[i].d_dice != 0) innocent = FALSE; /* Murderer! */
1810 if ((r_ptr->blow[i].effect == RBE_EAT_ITEM)
1811 || (r_ptr->blow[i].effect == RBE_EAT_GOLD))
1813 thief = TRUE; /* Thief! */
1816 /* The new law says it is illegal to live in the dungeon */
1817 if (r_ptr->level != 0) innocent = FALSE;
1821 if (r_ptr->flags1 & RF1_UNIQUE)
1822 chg_virtue(V_JUSTICE, 3);
1823 else if (1+((r_ptr->level) / 10 + (2 * dun_level))
1825 chg_virtue(V_JUSTICE, 1);
1829 chg_virtue (V_JUSTICE, -1);
1832 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)))
1834 if (one_in_(4)) chg_virtue(V_NATURE, -1);
1837 if ((r_ptr->flags1 & RF1_UNIQUE) && record_destroy_uniq)
1841 sprintf(note_buf, "%s%s", r_name + r_ptr->name, (m_ptr->smart & SM_CLONED) ? "(クローン)" : "");
1843 sprintf(note_buf, "%s%s", r_name + r_ptr->name, (m_ptr->smart & SM_CLONED) ? "(Clone)" : "");
1845 do_cmd_write_nikki(NIKKI_UNIQUE, 0, note_buf);
1851 /* Death by Missile/Spell attack */
1854 msg_format("%^s%s", m_name, note);
1857 /* Death by physical attack -- invisible monster */
1858 else if (!m_ptr->ml)
1861 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
1862 msg_format("せっかくだから%sを殺した。", m_name);
1864 msg_format("%sを殺した。", m_name);
1866 msg_format("You have killed %s.", m_name);
1871 /* Death by Physical attack -- non-living monster */
1872 else if (!monster_living(r_ptr))
1874 bool explode = FALSE;
1876 for (i = 0; i < 4; i++)
1878 if (r_ptr->blow[i].method == RBM_EXPLODE) explode = TRUE;
1881 /* Special note at death */
1883 msg_format(_("%sは爆発して粉々になった。", "%^s explodes into tiny shreds."), m_name);
1887 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
1888 msg_format("せっかくだから%sを倒した。", m_name);
1890 msg_format("%sを倒した。", m_name);
1892 msg_format("You have destroyed %s.", m_name);
1897 /* Death by Physical attack -- living monster */
1901 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
1902 msg_format("せっかくだから%sを葬り去った。", m_name);
1904 msg_format("%sを葬り去った。", m_name);
1906 msg_format("You have slain %s.", m_name);
1910 if ((r_ptr->flags1 & RF1_UNIQUE) && !(m_ptr->smart & SM_CLONED) && !vanilla_town)
1912 for (i = 0; i < MAX_KUBI; i++)
1914 if ((kubi_r_idx[i] == m_ptr->r_idx) && !(m_ptr->mflag2 & MFLAG2_CHAMELEON))
1916 msg_format(_("%sの首には賞金がかかっている。", "There is a price on %s's head."), m_name);
1922 /* Generate treasure */
1923 monster_death(m_idx, TRUE);
1925 /* Mega hack : replace IKETA to BIKETAL */
1926 if ((m_ptr->r_idx == MON_IKETA) &&
1927 !(p_ptr->inside_arena || p_ptr->inside_battle))
1929 int dummy_y = m_ptr->fy;
1930 int dummy_x = m_ptr->fx;
1931 BIT_FLAGS mode = 0L;
1933 if (is_pet(m_ptr)) mode |= PM_FORCE_PET;
1935 /* Delete the monster */
1936 delete_monster_idx(m_idx);
1938 if (summon_named_creature(0, dummy_y, dummy_x, MON_BIKETAL, mode))
1940 msg_print(_("「ハァッハッハッハ!!私がバイケタルだ!!」", "Uwa-hahaha! *I* am Biketal!"));
1945 /* Delete the monster */
1946 delete_monster_idx(m_idx);
1949 get_exp_from_mon((long)exp_mon.max_maxhp*2, &exp_mon);
1954 /* Monster is dead */
1961 /* Mega-Hack -- Pain cancels fear */
1962 if (MON_MONFEAR(m_ptr) && (dam > 0))
1965 if (set_monster_monfear(m_idx, MON_MONFEAR(m_ptr) - randint1(dam)))
1972 /* Sometimes a monster gets scared by damage */
1973 if (!MON_MONFEAR(m_ptr) && !(r_ptr->flags3 & (RF3_NO_FEAR)))
1975 /* Percentage of fully healthy */
1976 int percentage = (100L * m_ptr->hp) / m_ptr->maxhp;
1979 * Run (sometimes) if at 10% or less of max hit points,
1980 * or (usually) when hit for half its current hit points
1982 if ((randint1(10) >= percentage) ||
1983 ((dam >= m_ptr->hp) && (randint0(100) < 80)))
1985 /* Hack -- note fear */
1988 /* XXX XXX XXX Hack -- Add some timed fear */
1989 (void)set_monster_monfear(m_idx, (randint1(10) +
1990 (((dam >= m_ptr->hp) && (percentage > 7)) ?
1991 20 : ((11 - percentage) * 5))));
1998 if (p_ptr->riding && (p_ptr->riding == m_idx) && (dam > 0))
2002 /* Extract monster name */
2003 monster_desc(m_name, m_ptr, 0);
2005 if (m_ptr->hp > m_ptr->maxhp/3) dam = (dam + 1) / 2;
2006 if (rakuba((dam > 200) ? 200 : dam, FALSE))
2008 msg_format(_("%^sに振り落とされた!", "%^s has thrown you off!"), m_name);
2019 * @brief 現在のコンソール表示の縦横を返す。 /
2020 * Get term size and calculate screen size
2021 * @param wid_p コンソールの表示幅文字数を返す
2022 * @param hgt_p コンソールの表示行数を返す
2025 void get_screen_size(TERM_LEN *wid_p, TERM_LEN *hgt_p)
2027 Term_get_size(wid_p, hgt_p);
2028 *hgt_p -= ROW_MAP + 2;
2029 *wid_p -= COL_MAP + 2;
2030 if (use_bigtile) *wid_p /= 2;
2035 * @brief コンソール上におけるマップ表示の左上位置を返す /
2036 * Calculates current boundaries Called below and from "do_cmd_locate()".
2039 void panel_bounds_center(void)
2044 get_screen_size(&wid, &hgt);
2046 panel_row_max = panel_row_min + hgt - 1;
2047 panel_row_prt = panel_row_min - 1;
2048 panel_col_max = panel_col_min + wid - 1;
2049 panel_col_prt = panel_col_min - 13;
2054 * @brief コンソールのリサイズに合わせてマップを再描画する /
2055 * Map resizing whenever the main term changes size
2058 void resize_map(void)
2060 /* Only if the dungeon exists */
2061 if (!character_dungeon) return;
2063 /* Mega-Hack -- no panel yet */
2067 /* Reset the panels */
2068 panel_row_min = cur_hgt;
2069 panel_col_min = cur_wid;
2074 p_ptr->update |= (PU_TORCH | PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
2076 /* Forget lite/view */
2077 p_ptr->update |= (PU_UN_VIEW | PU_UN_LITE);
2079 /* Update lite/view */
2080 p_ptr->update |= (PU_VIEW | PU_LITE | PU_MON_LITE);
2082 /* Update monsters */
2083 p_ptr->update |= (PU_MONSTERS);
2085 /* Redraw everything */
2086 p_ptr->redraw |= (PR_WIPE | PR_BASIC | PR_EXTRA | PR_MAP | PR_EQUIPPY);
2088 /* Hack -- update */
2096 * Place the cursor on the player
2098 if (can_save) move_cursor_relative(p_ptr->y, p_ptr->x);
2105 * @brief コンソールを再描画する /
2106 * Redraw a term when it is resized
2109 void redraw_window(void)
2111 /* Only if the dungeon exists */
2112 if (!character_dungeon) return;
2115 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_SPELL | PW_PLAYER);
2118 p_ptr->window |= (PW_MESSAGE | PW_OVERHEAD | PW_DUNGEON | PW_MONSTER | PW_OBJECT);
2120 /* Hack -- update */
2129 * @brief フォーカスを当てるべきマップ描画の基準座標を指定する(サブルーチン)
2130 * @param dy 変更先のフロアY座標
2131 * @param dx 変更先のフロアX座標
2132 * Handle a request to change the current panel
2133 * Return TRUE if the panel was changed.
2134 * Also used in do_cmd_locate
2135 * @return 実際に再描画が必要だった場合TRUEを返す
2137 bool change_panel(POSITION dy, POSITION dx)
2143 get_screen_size(&wid, &hgt);
2145 /* Apply the motion */
2146 y = panel_row_min + dy * hgt / 2;
2147 x = panel_col_min + dx * wid / 2;
2149 /* Verify the row */
2150 if (y > cur_hgt - hgt) y = cur_hgt - hgt;
2153 /* Verify the col */
2154 if (x > cur_wid - wid) x = cur_wid - wid;
2157 /* Handle "changes" */
2158 if ((y != panel_row_min) || (x != panel_col_min))
2160 /* Save the new panel info */
2164 /* Recalculate the boundaries */
2165 panel_bounds_center();
2168 p_ptr->update |= (PU_MONSTERS);
2171 p_ptr->redraw |= (PR_MAP);
2185 * @brief フォーカスを当てるべきマップ描画の基準座標を指定する
2186 * @param y 変更先のフロアY座標
2187 * @param x 変更先のフロアX座標
2189 * Handle a request to change the current panel
2190 * Return TRUE if the panel was changed.
2191 * Also used in do_cmd_locate
2192 * @return 実際に再描画が必要だった場合TRUEを返す
2194 static bool change_panel_xy(POSITION y, POSITION x)
2196 POSITION dy = 0, dx = 0;
2200 get_screen_size(&wid, &hgt);
2202 if (y < panel_row_min) dy = -1;
2203 if (y > panel_row_max) dy = 1;
2204 if (x < panel_col_min) dx = -1;
2205 if (x > panel_col_max) dx = 1;
2207 if (!dy && !dx) return (FALSE);
2209 return change_panel(dy, dx);
2214 * @brief マップ描画のフォーカスを当てるべき座標を更新する
2216 * Given an row (y) and col (x), this routine detects when a move
2217 * off the screen has occurred and figures new borders. -RAK-
2218 * "Update" forces a "full update" to take place.
2219 * The map is reprinted if necessary, and "TRUE" is returned.
2220 * @return 実際に再描画が必要だった場合TRUEを返す
2222 void verify_panel(void)
2224 POSITION y = p_ptr->y;
2225 POSITION x = p_ptr->x;
2234 get_screen_size(&wid, &hgt);
2236 max_prow_min = cur_hgt - hgt;
2237 max_pcol_min = cur_wid - wid;
2239 /* Bounds checking */
2240 if (max_prow_min < 0) max_prow_min = 0;
2241 if (max_pcol_min < 0) max_pcol_min = 0;
2243 /* Center on player */
2244 if (center_player && (center_running || !running))
2246 /* Center vertically */
2247 prow_min = y - hgt / 2;
2248 if (prow_min < 0) prow_min = 0;
2249 else if (prow_min > max_prow_min) prow_min = max_prow_min;
2251 /* Center horizontally */
2252 pcol_min = x - wid / 2;
2253 if (pcol_min < 0) pcol_min = 0;
2254 else if (pcol_min > max_pcol_min) pcol_min = max_pcol_min;
2258 prow_min = panel_row_min;
2259 pcol_min = panel_col_min;
2261 /* Scroll screen when 2 grids from top/bottom edge */
2262 if (y > panel_row_max - 2)
2264 while (y > prow_min + hgt-1 - 2)
2266 prow_min += (hgt / 2);
2270 if (y < panel_row_min + 2)
2272 while (y < prow_min + 2)
2274 prow_min -= (hgt / 2);
2278 if (prow_min > max_prow_min) prow_min = max_prow_min;
2279 if (prow_min < 0) prow_min = 0;
2281 /* Scroll screen when 4 grids from left/right edge */
2282 if (x > panel_col_max - 4)
2284 while (x > pcol_min + wid-1 - 4)
2286 pcol_min += (wid / 2);
2290 if (x < panel_col_min + 4)
2292 while (x < pcol_min + 4)
2294 pcol_min -= (wid / 2);
2298 if (pcol_min > max_pcol_min) pcol_min = max_pcol_min;
2299 if (pcol_min < 0) pcol_min = 0;
2302 /* Check for "no change" */
2303 if ((prow_min == panel_row_min) && (pcol_min == panel_col_min)) return;
2305 /* Save the new panel info */
2306 panel_row_min = prow_min;
2307 panel_col_min = pcol_min;
2309 /* Hack -- optional disturb on "panel change" */
2310 if (disturb_panel && !center_player) disturb(0, 0);
2312 /* Recalculate the boundaries */
2313 panel_bounds_center();
2316 p_ptr->update |= (PU_MONSTERS);
2319 p_ptr->redraw |= (PR_MAP);
2322 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
2327 * Monster health description
2329 cptr look_mon_desc(monster_type *m_ptr, BIT_FLAGS mode)
2331 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
2338 /* Determine if the monster is "living" */
2339 living = monster_living(ap_r_ptr);
2341 /* Calculate a health "percentage" */
2342 perc = 100L * m_ptr->hp / m_ptr->maxhp;
2344 /* Healthy monsters */
2345 if (m_ptr->hp >= m_ptr->maxhp)
2349 desc = living ? "無傷" : "無ダメージ";
2351 desc = living ? "unhurt" : "undamaged";
2356 else if (perc >= 60)
2359 desc = living ? "軽傷" : "小ダメージ";
2361 desc = living ? "somewhat wounded" : "somewhat damaged";
2366 else if (perc >= 25)
2369 desc = living ? "負傷" : "中ダメージ";
2371 desc = living ? "wounded" : "damaged";
2376 else if (perc >= 10)
2379 desc = living ? "重傷" : "大ダメージ";
2381 desc = living ? "badly wounded" : "badly damaged";
2389 desc = living ? "半死半生" : "倒れかけ";
2391 desc = living ? "almost dead" : "almost destroyed";
2396 /* Need attitude information? */
2399 /* Full information is not needed */
2402 else if (is_pet(m_ptr))
2404 attitude = _(", ペット", ", pet");
2406 else if (is_friendly(m_ptr))
2408 attitude = _(", 友好的", ", friendly");
2412 attitude = _("", "");
2416 /* Clone monster? */
2417 if (m_ptr->smart & SM_CLONED)
2426 /* Display monster's level --- idea borrowed from ToME */
2427 if (ap_r_ptr->r_tkills && !(m_ptr->mflag2 & MFLAG2_KAGE))
2429 return format(_("レベル%d, %s%s%s", "Level %d, %s%s%s"), ap_r_ptr->level, desc, attitude, clone);
2433 return format(_("レベル???, %s%s%s", "Level ???, %s%s%s"), desc, attitude, clone);
2440 * Angband sorting algorithm -- quick sort in place
2442 * Note that the details of the data we are sorting is hidden,
2443 * and we rely on the "ang_sort_comp()" and "ang_sort_swap()"
2444 * function hooks to interact with the data, which is given as
2445 * two pointers, and which may have any user-defined form.
2447 void ang_sort_aux(vptr u, vptr v, int p, int q)
2465 while (!(*ang_sort_comp)(u, v, b, z)) b--;
2468 while (!(*ang_sort_comp)(u, v, z, a)) a++;
2470 /* Done partition */
2474 (*ang_sort_swap)(u, v, a, b);
2480 /* Recurse left side */
2481 ang_sort_aux(u, v, p, b);
2483 /* Recurse right side */
2484 ang_sort_aux(u, v, b+1, q);
2489 * Angband sorting algorithm -- quick sort in place
2491 * Note that the details of the data we are sorting is hidden,
2492 * and we rely on the "ang_sort_comp()" and "ang_sort_swap()"
2493 * function hooks to interact with the data, which is given as
2494 * two pointers, and which may have any user-defined form.
2496 void ang_sort(vptr u, vptr v, int n)
2498 /* Sort the array */
2499 ang_sort_aux(u, v, 0, n-1);
2504 /*** Targeting Code ***/
2508 * Determine is a monster makes a reasonable target
2510 * The concept of "targeting" was stolen from "Morgul" (?)
2512 * The player can target any location, or any "target-able" monster.
2514 * Currently, a monster is "target_able" if it is visible, and if
2515 * the player can hit it with a projection, and the player is not
2516 * hallucinating. This allows use of "use closest target" macros.
2518 * Future versions may restrict the ability to target "trappers"
2519 * and "mimics", but the semantics is a little bit weird.
2521 bool target_able(MONSTER_IDX m_idx)
2523 monster_type *m_ptr = &m_list[m_idx];
2525 /* Monster must be alive */
2526 if (!m_ptr->r_idx) return (FALSE);
2528 /* Hack -- no targeting hallucinations */
2529 if (p_ptr->image) return (FALSE);
2531 /* Monster must be visible */
2532 if (!m_ptr->ml) return (FALSE);
2534 if (p_ptr->riding && (p_ptr->riding == m_idx)) return (TRUE);
2536 /* Monster must be projectable */
2537 if (!projectable(p_ptr->y, p_ptr->x, m_ptr->fy, m_ptr->fx)) return (FALSE);
2539 /* XXX XXX XXX Hack -- Never target trappers */
2540 /* if (CLEAR_ATTR && (CLEAR_CHAR)) return (FALSE); */
2550 * Update (if necessary) and verify (if possible) the target.
2552 * We return TRUE if the target is "okay" and FALSE otherwise.
2554 bool target_okay(void)
2556 /* Accept stationary targets */
2557 if (target_who < 0) return (TRUE);
2559 /* Check moving targets */
2562 /* Accept reasonable targets */
2563 if (target_able(target_who))
2565 monster_type *m_ptr = &m_list[target_who];
2567 /* Acquire monster location */
2568 target_row = m_ptr->fy;
2569 target_col = m_ptr->fx;
2576 /* Assume no target */
2582 * Sorting hook -- comp function -- by "distance to player"
2584 * We use "u" and "v" to point to arrays of "x" and "y" positions,
2585 * and sort the arrays by double-distance to the player.
2587 static bool ang_sort_comp_distance(vptr u, vptr v, int a, int b)
2589 POSITION *x = (POSITION*)(u);
2590 POSITION *y = (POSITION*)(v);
2592 POSITION da, db, kx, ky;
2594 /* Absolute distance components */
2595 kx = x[a]; kx -= p_ptr->x; kx = ABS(kx);
2596 ky = y[a]; ky -= p_ptr->y; ky = ABS(ky);
2598 /* Approximate Double Distance to the first point */
2599 da = ((kx > ky) ? (kx + kx + ky) : (ky + ky + kx));
2601 /* Absolute distance components */
2602 kx = x[b]; kx -= p_ptr->x; kx = ABS(kx);
2603 ky = y[b]; ky -= p_ptr->y; ky = ABS(ky);
2605 /* Approximate Double Distance to the first point */
2606 db = ((kx > ky) ? (kx + kx + ky) : (ky + ky + kx));
2608 /* Compare the distances */
2614 * Sorting hook -- comp function -- by importance level of grids
2616 * We use "u" and "v" to point to arrays of "x" and "y" positions,
2617 * and sort the arrays by level of monster
2619 static bool ang_sort_comp_importance(vptr u, vptr v, int a, int b)
2621 POSITION *x = (POSITION*)(u);
2622 POSITION *y = (POSITION*)(v);
2623 cave_type *ca_ptr = &cave[y[a]][x[a]];
2624 cave_type *cb_ptr = &cave[y[b]][x[b]];
2625 monster_type *ma_ptr = &m_list[ca_ptr->m_idx];
2626 monster_type *mb_ptr = &m_list[cb_ptr->m_idx];
2627 monster_race *ap_ra_ptr, *ap_rb_ptr;
2629 /* The player grid */
2630 if (y[a] == p_ptr->y && x[a] == p_ptr->x) return TRUE;
2631 if (y[b] == p_ptr->y && x[b] == p_ptr->x) return FALSE;
2633 /* Extract monster race */
2634 if (ca_ptr->m_idx && ma_ptr->ml) ap_ra_ptr = &r_info[ma_ptr->ap_r_idx];
2635 else ap_ra_ptr = NULL;
2636 if (cb_ptr->m_idx && mb_ptr->ml) ap_rb_ptr = &r_info[mb_ptr->ap_r_idx];
2637 else ap_rb_ptr = NULL;
2639 if (ap_ra_ptr && !ap_rb_ptr) return TRUE;
2640 if (!ap_ra_ptr && ap_rb_ptr) return FALSE;
2642 /* Compare two monsters */
2643 if (ap_ra_ptr && ap_rb_ptr)
2645 /* Unique monsters first */
2646 if ((ap_ra_ptr->flags1 & RF1_UNIQUE) && !(ap_rb_ptr->flags1 & RF1_UNIQUE)) return TRUE;
2647 if (!(ap_ra_ptr->flags1 & RF1_UNIQUE) && (ap_rb_ptr->flags1 & RF1_UNIQUE)) return FALSE;
2649 /* Shadowers first (あやしい影) */
2650 if ((ma_ptr->mflag2 & MFLAG2_KAGE) && !(mb_ptr->mflag2 & MFLAG2_KAGE)) return TRUE;
2651 if (!(ma_ptr->mflag2 & MFLAG2_KAGE) && (mb_ptr->mflag2 & MFLAG2_KAGE)) return FALSE;
2653 /* Unknown monsters first */
2654 if (!ap_ra_ptr->r_tkills && ap_rb_ptr->r_tkills) return TRUE;
2655 if (ap_ra_ptr->r_tkills && !ap_rb_ptr->r_tkills) return FALSE;
2657 /* Higher level monsters first (if known) */
2658 if (ap_ra_ptr->r_tkills && ap_rb_ptr->r_tkills)
2660 if (ap_ra_ptr->level > ap_rb_ptr->level) return TRUE;
2661 if (ap_ra_ptr->level < ap_rb_ptr->level) return FALSE;
2664 /* Sort by index if all conditions are same */
2665 if (ma_ptr->ap_r_idx > mb_ptr->ap_r_idx) return TRUE;
2666 if (ma_ptr->ap_r_idx < mb_ptr->ap_r_idx) return FALSE;
2669 /* An object get higher priority */
2670 if (cave[y[a]][x[a]].o_idx && !cave[y[b]][x[b]].o_idx) return TRUE;
2671 if (!cave[y[a]][x[a]].o_idx && cave[y[b]][x[b]].o_idx) return FALSE;
2673 /* Priority from the terrain */
2674 if (f_info[ca_ptr->feat].priority > f_info[cb_ptr->feat].priority) return TRUE;
2675 if (f_info[ca_ptr->feat].priority < f_info[cb_ptr->feat].priority) return FALSE;
2677 /* If all conditions are same, compare distance */
2678 return ang_sort_comp_distance(u, v, a, b);
2683 * Sorting hook -- swap function -- by "distance to player"
2685 * We use "u" and "v" to point to arrays of "x" and "y" positions,
2686 * and sort the arrays by distance to the player.
2688 static void ang_sort_swap_distance(vptr u, vptr v, int a, int b)
2690 POSITION *x = (POSITION*)(u);
2691 POSITION *y = (POSITION*)(v);
2709 * Hack -- help "select" a location (see below)
2711 static POSITION_IDX target_pick(POSITION y1, POSITION x1, POSITION dy, POSITION dx)
2714 POSITION x2, y2, x3, y3, x4, y4;
2715 POSITION_IDX b_i = -1, b_v = 9999;
2718 /* Scan the locations */
2719 for (i = 0; i < temp_n; i++)
2725 /* Directed distance */
2729 /* Verify quadrant */
2730 if (dx && (x3 * dx <= 0)) continue;
2731 if (dy && (y3 * dy <= 0)) continue;
2733 /* Absolute distance */
2737 /* Verify quadrant */
2738 if (dy && !dx && (x4 > y4)) continue;
2739 if (dx && !dy && (y4 > x4)) continue;
2741 /* Approximate Double Distance */
2742 v = ((x4 > y4) ? (x4 + x4 + y4) : (y4 + y4 + x4));
2744 /* XXX XXX XXX Penalize location */
2747 if ((b_i >= 0) && (v >= b_v)) continue;
2759 * Hack -- determine if a given location is "interesting"
2761 static bool target_set_accept(POSITION y, POSITION x)
2764 OBJECT_IDX this_o_idx, next_o_idx = 0;
2767 if (!(in_bounds(y, x))) return (FALSE);
2769 /* Player grid is always interesting */
2770 if (player_bold(y, x)) return (TRUE);
2772 /* Handle hallucination */
2773 if (p_ptr->image) return (FALSE);
2775 /* Examine the grid */
2776 c_ptr = &cave[y][x];
2778 /* Visible monsters */
2781 monster_type *m_ptr = &m_list[c_ptr->m_idx];
2783 /* Visible monsters */
2784 if (m_ptr->ml) return (TRUE);
2787 /* Scan all objects in the grid */
2788 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
2792 /* Acquire object */
2793 o_ptr = &o_list[this_o_idx];
2795 /* Acquire next object */
2796 next_o_idx = o_ptr->next_o_idx;
2798 /* Memorized object */
2799 if (o_ptr->marked & OM_FOUND) return (TRUE);
2802 /* Interesting memorized features */
2803 if (c_ptr->info & (CAVE_MARK))
2805 /* Notice object features */
2806 if (c_ptr->info & CAVE_OBJECT) return (TRUE);
2808 /* Feature code (applying "mimic" field) */
2809 if (have_flag(f_info[get_feat_mimic(c_ptr)].flags, FF_NOTICE)) return TRUE;
2818 * Prepare the "temp" array for "target_set"
2820 * Return the number of target_able monsters in the set.
2822 static void target_set_prepare(BIT_FLAGS mode)
2825 POSITION min_hgt, max_hgt, min_wid, max_wid;
2827 if (mode & TARGET_KILL)
2830 min_hgt = MAX((p_ptr->y - MAX_RANGE), 0);
2831 max_hgt = MIN((p_ptr->y + MAX_RANGE), cur_hgt - 1);
2832 min_wid = MAX((p_ptr->x - MAX_RANGE), 0);
2833 max_wid = MIN((p_ptr->x + MAX_RANGE), cur_wid - 1);
2835 else /* not targetting */
2838 min_hgt = panel_row_min;
2839 max_hgt = panel_row_max;
2840 min_wid = panel_col_min;
2841 max_wid = panel_col_max;
2844 /* Reset "temp" array */
2847 /* Scan the current panel */
2848 for (y = min_hgt; y <= max_hgt; y++)
2850 for (x = min_wid; x <= max_wid; x++)
2854 /* Require "interesting" contents */
2855 if (!target_set_accept(y, x)) continue;
2857 c_ptr = &cave[y][x];
2859 /* Require target_able monsters for "TARGET_KILL" */
2860 if ((mode & (TARGET_KILL)) && !target_able(c_ptr->m_idx)) continue;
2862 if ((mode & (TARGET_KILL)) && !target_pet && is_pet(&m_list[c_ptr->m_idx])) continue;
2864 /* Save the location */
2871 /* Set the sort hooks */
2872 if (mode & (TARGET_KILL))
2874 /* Target the nearest monster for shooting */
2875 ang_sort_comp = ang_sort_comp_distance;
2876 ang_sort_swap = ang_sort_swap_distance;
2880 /* Look important grids first in Look command */
2881 ang_sort_comp = ang_sort_comp_importance;
2882 ang_sort_swap = ang_sort_swap_distance;
2885 /* Sort the positions */
2886 ang_sort(temp_x, temp_y, temp_n);
2888 if (p_ptr->riding && target_pet && (temp_n > 1) && (mode & (TARGET_KILL)))
2893 temp_y[0] = temp_y[1];
2896 temp_x[0] = temp_x[1];
2901 void target_set_prepare_look(void){
2902 target_set_prepare(TARGET_LOOK);
2907 * Evaluate number of kill needed to gain level
2909 static void evaluate_monster_exp(char *buf, monster_type *m_ptr)
2911 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
2913 s32b exp_mon, exp_adv;
2914 u32b exp_mon_frac, exp_adv_frac;
2916 if ((p_ptr->lev >= PY_MAX_LEVEL) || (p_ptr->prace == RACE_ANDROID))
2921 else if (!ap_r_ptr->r_tkills || (m_ptr->mflag2 & MFLAG2_KAGE))
2931 /* The monster's experience point (assuming average monster speed) */
2932 exp_mon = ap_r_ptr->mexp * ap_r_ptr->level;
2934 s64b_div(&exp_mon, &exp_mon_frac, 0, (p_ptr->max_plv + 2));
2937 /* Total experience value for next level */
2938 exp_adv = player_exp[p_ptr->lev -1] * p_ptr->expfact;
2940 s64b_div(&exp_adv, &exp_adv_frac, 0, 100);
2942 /* Experience value need to get */
2943 s64b_sub(&exp_adv, &exp_adv_frac, p_ptr->exp, p_ptr->exp_frac);
2946 /* You need to kill at least one monster to get any experience */
2947 s64b_add(&exp_adv, &exp_adv_frac, exp_mon, exp_mon_frac);
2948 s64b_sub(&exp_adv, &exp_adv_frac, 0, 1);
2950 /* Extract number of monsters needed */
2951 s64b_div(&exp_adv, &exp_adv_frac, exp_mon, exp_mon_frac);
2953 /* If 999 or more monsters needed, only display "999". */
2954 num = MIN(999, exp_adv_frac);
2956 /* Display the number */
2957 sprintf(buf,"%03ld", (long int)num);
2961 bool show_gold_on_floor = FALSE;
2964 * Examine a grid, return a keypress.
2966 * The "mode" argument contains the "TARGET_LOOK" bit flag, which
2967 * indicates that the "space" key should scan through the contents
2968 * of the grid, instead of simply returning immediately. This lets
2969 * the "look" command get complete information, without making the
2970 * "target" command annoying.
2972 * The "info" argument contains the "commands" which should be shown
2973 * inside the "[xxx]" text. This string must never be empty, or grids
2974 * containing monsters will be displayed with an extra comma.
2976 * Note that if a monster is in the grid, we update both the monster
2977 * recall info and the health bar info to track that monster.
2979 * Eventually, we may allow multiple objects per grid, or objects
2980 * and terrain features in the same grid. XXX XXX XXX
2982 * This function must handle blindness/hallucination.
2984 static char target_set_aux(POSITION y, POSITION x, BIT_FLAGS mode, cptr info)
2986 cave_type *c_ptr = &cave[y][x];
2987 OBJECT_IDX this_o_idx, next_o_idx = 0;
2988 cptr s1 = "", s2 = "", s3 = "", x_info = "";
2991 feature_type *f_ptr;
2992 char query = '\001';
2993 char out_val[MAX_NLEN+80];
2995 #ifdef ALLOW_EASY_FLOOR
2996 OBJECT_IDX floor_list[23];
2997 ITEM_NUMBER floor_num = 0;
2999 /* Scan all objects in the grid */
3002 floor_num = scan_floor(floor_list, y, x, 0x02);
3006 x_info = _("x物 ", "x,");
3010 #endif /* ALLOW_EASY_FLOOR */
3012 /* Hack -- under the player */
3013 if (player_bold(y, x))
3029 s1 = _("ターゲット:", "Target:");
3032 /* Hack -- hallucination */
3035 cptr name = _("何か奇妙な物", "something strange");
3037 /* Display a message */
3039 sprintf(out_val, "%s%s%s%s [%s]", s1, name, s2, s3, info);
3041 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, name, info);
3045 move_cursor_relative(y, x);
3048 /* Stop on everything but "return" */
3049 if ((query != '\r') && (query != '\n')) return query;
3051 /* Repeat forever */
3056 /* Actual monsters */
3057 if (c_ptr->m_idx && m_list[c_ptr->m_idx].ml)
3059 monster_type *m_ptr = &m_list[c_ptr->m_idx];
3060 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
3062 bool recall = FALSE;
3067 /* Get the monster name ("a kobold") */
3068 monster_desc(m_name, m_ptr, MD_INDEF_VISIBLE);
3070 /* Hack -- track this monster race */
3071 monster_race_track(m_ptr->ap_r_idx);
3073 /* Hack -- health bar for this monster */
3074 health_track(c_ptr->m_idx);
3076 /* Hack -- handle stuff */
3090 /* Recall on screen */
3091 screen_roff(m_ptr->ap_r_idx, 0);
3093 /* Hack -- Complete the prompt (again) */
3094 Term_addstr(-1, TERM_WHITE, format(_(" [r思 %s%s]", " [r,%s%s]"), x_info, info));
3102 /* Normal commands */
3103 if (query != 'r') break;
3108 /* Cleare recall text and repeat */
3114 /* Describe, and prompt for recall */
3115 evaluate_monster_exp(acount, m_ptr);
3118 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);
3120 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);
3126 move_cursor_relative(y, x);
3131 /* Normal commands */
3132 if (query != 'r') break;
3138 /* Always stop at "normal" keys */
3139 if ((query != '\r') && (query != '\n') && (query != ' ') && (query != 'x')) return query;
3141 /* Sometimes stop at "space" key */
3142 if ((query == ' ') && !(mode & (TARGET_LOOK))) return query;
3144 /* Change the intro */
3145 s1 = _("それは", "It is ");
3147 /* Hack -- take account of gender */
3148 if (ap_r_ptr->flags1 & (RF1_FEMALE)) s1 = _("彼女は", "She is ");
3149 else if (ap_r_ptr->flags1 & (RF1_MALE)) s1 = _("彼は", "He is ");
3151 /* Use a preposition */
3160 /* Scan all objects being carried */
3161 for (this_o_idx = m_ptr->hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
3163 char o_name[MAX_NLEN];
3167 /* Acquire object */
3168 o_ptr = &o_list[this_o_idx];
3170 /* Acquire next object */
3171 next_o_idx = o_ptr->next_o_idx;
3173 /* Obtain an object description */
3174 object_desc(o_name, o_ptr, 0);
3176 /* Describe the object */
3178 sprintf(out_val, "%s%s%s%s[%s]", s1, o_name, s2, s3, info);
3180 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, o_name, info);
3184 move_cursor_relative(y, x);
3187 /* Always stop at "normal" keys */
3188 if ((query != '\r') && (query != '\n') && (query != ' ') && (query != 'x')) return query;
3190 /* Sometimes stop at "space" key */
3191 if ((query == ' ') && !(mode & (TARGET_LOOK))) return query;
3193 /* Change the intro */
3194 s2 = _("をまた", "also carrying ");
3197 /* Use a preposition */
3207 #ifdef ALLOW_EASY_FLOOR
3216 char o_name[MAX_NLEN];
3220 /* Acquire object */
3221 o_ptr = &o_list[floor_list[0]];
3223 /* Describe the object */
3224 object_desc(o_name, o_ptr, 0);
3227 sprintf(out_val, "%s%s%s%s[%s]",
3228 s1, o_name, s2, s3, info);
3230 sprintf(out_val, "%s%s%s%s [%s]",
3231 s1, s2, s3, o_name, info);
3235 move_cursor_relative(y, x);
3244 /* Provide one cushion before item listing */
3247 /* Display rough information about items */
3249 sprintf(out_val, "%s %d個のアイテム%s%s ['x'で一覧, %s]",
3250 s1, (int)floor_num, s2, s3, info);
3252 sprintf(out_val, "%s%s%sa pile of %d items [x,%s]",
3253 s1, s2, s3, (int)floor_num, info);
3257 move_cursor_relative(y, x);
3262 /* No request for listing */
3263 if (query != 'x' && query != ' ') return query;
3267 /** Display list of items **/
3269 /* Continue scrolling list if requested */
3279 show_gold_on_floor = TRUE;
3280 (void)show_floor(0, y, x, &min_width);
3281 show_gold_on_floor = FALSE;
3285 sprintf(out_val, "%s %d個のアイテム%s%s [Enterで次へ, %s]",
3286 s1, (int)floor_num, s2, s3, info);
3288 sprintf(out_val, "%s%s%sa pile of %d items [Enter,%s]",
3289 s1, s2, s3, (int)floor_num, info);
3300 /* Exit unless 'Enter' */
3301 if (query != '\n' && query != '\r')
3306 /* Get the object being moved. */
3307 o_idx = c_ptr->o_idx;
3309 /* Only rotate a pile of two or more objects. */
3310 if (!(o_idx && o_list[o_idx].next_o_idx)) continue;
3312 /* Remove the first object from the list. */
3313 excise_object_idx(o_idx);
3315 /* Find end of the list. */
3317 while (o_list[i].next_o_idx)
3318 i = o_list[i].next_o_idx;
3320 /* Add after the last object. */
3321 o_list[i].next_o_idx = o_idx;
3323 /* Loop and re-display the list */
3329 #endif /* ALLOW_EASY_FLOOR */
3332 /* Scan all objects in the grid */
3333 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
3337 /* Acquire object */
3338 o_ptr = &o_list[this_o_idx];
3340 /* Acquire next object */
3341 next_o_idx = o_ptr->next_o_idx;
3344 if (o_ptr->marked & OM_FOUND)
3346 char o_name[MAX_NLEN];
3351 /* Obtain an object description */
3352 object_desc(o_name, o_ptr, 0);
3354 /* Describe the object */
3356 sprintf(out_val, "%s%s%s%s[%s]", s1, o_name, s2, s3, info);
3358 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, o_name, info);
3362 move_cursor_relative(y, x);
3365 /* Always stop at "normal" keys */
3366 if ((query != '\r') && (query != '\n') && (query != ' ') && (query != 'x')) return query;
3368 /* Sometimes stop at "space" key */
3369 if ((query == ' ') && !(mode & TARGET_LOOK)) return query;
3371 /* Change the intro */
3372 s1 = _("それは", "It is ");
3375 if (o_ptr->number != 1) s1 = _("それらは", "They are ");
3389 /* Feature code (applying "mimic" field) */
3390 feat = get_feat_mimic(c_ptr);
3392 /* Require knowledge about grid, or ability to see grid */
3393 if (!(c_ptr->info & CAVE_MARK) && !player_can_see_bold(y, x))
3395 /* Forget feature */
3399 f_ptr = &f_info[feat];
3401 /* Terrain feature if needed */
3402 if (boring || have_flag(f_ptr->flags, FF_REMEMBER))
3406 /* Hack -- special handling for quest entrances */
3407 if (have_flag(f_ptr->flags, FF_QUEST_ENTER))
3409 /* Set the quest number temporary */
3410 IDX old_quest = p_ptr->inside_quest;
3413 /* Clear the text */
3414 for (j = 0; j < 10; j++) quest_text[j][0] = '\0';
3415 quest_text_line = 0;
3417 p_ptr->inside_quest = c_ptr->special;
3419 /* Get the quest text */
3420 init_flags = INIT_NAME_ONLY;
3422 process_dungeon_file("q_info.txt", 0, 0, 0, 0);
3424 name = format(_("クエスト「%s」(%d階相当)", "the entrance to the quest '%s'(level %d)"),
3425 quest[c_ptr->special].name, quest[c_ptr->special].level);
3427 /* Reset the old quest number */
3428 p_ptr->inside_quest = old_quest;
3431 /* Hack -- special handling for building doors */
3432 else if (have_flag(f_ptr->flags, FF_BLDG) && !p_ptr->inside_arena)
3434 name = building[f_ptr->subtype].name;
3436 else if (have_flag(f_ptr->flags, FF_ENTRANCE))
3438 name = format(_("%s(%d階相当)", "%s(level %d)"), d_text + d_info[c_ptr->special].text, d_info[c_ptr->special].mindepth);
3440 else if (have_flag(f_ptr->flags, FF_TOWN))
3442 name = town[c_ptr->special].name;
3444 else if (p_ptr->wild_mode && (feat == feat_floor))
3446 name = _("道", "road");
3450 name = f_name + f_ptr->name;
3456 ((!have_flag(f_ptr->flags, FF_MOVE) && !have_flag(f_ptr->flags, FF_CAN_FLY)) ||
3457 (!have_flag(f_ptr->flags, FF_LOS) && !have_flag(f_ptr->flags, FF_TREE)) ||
3458 have_flag(f_ptr->flags, FF_TOWN)))
3460 s2 = _("の中", "in ");
3463 /* Hack -- special introduction for store & building doors -KMW- */
3464 if (have_flag(f_ptr->flags, FF_STORE) ||
3465 have_flag(f_ptr->flags, FF_QUEST_ENTER) ||
3466 (have_flag(f_ptr->flags, FF_BLDG) && !p_ptr->inside_arena) ||
3467 have_flag(f_ptr->flags, FF_ENTRANCE))
3476 else if (have_flag(f_ptr->flags, FF_FLOOR) ||
3477 have_flag(f_ptr->flags, FF_TOWN) ||
3478 have_flag(f_ptr->flags, FF_SHALLOW) ||
3479 have_flag(f_ptr->flags, FF_DEEP))
3485 /* Pick proper indefinite article */
3486 s3 = (is_a_vowel(name[0])) ? "an " : "a ";
3490 /* Display a message */
3494 if (c_ptr->mimic) sprintf(f_idx_str, "%d/%d", c_ptr->feat, c_ptr->mimic);
3495 else sprintf(f_idx_str, "%d", c_ptr->feat);
3497 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]);
3499 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);
3504 sprintf(out_val, "%s%s%s%s[%s]", s1, name, s2, s3, info);
3506 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, name, info);
3510 move_cursor_relative(y, x);
3513 /* Always stop at "normal" keys */
3514 if ((query != '\r') && (query != '\n') && (query != ' ')) return query;
3517 /* Stop on everything but "return" */
3518 if ((query != '\r') && (query != '\n')) return query;
3520 /* Repeat forever */
3526 * Handle "target" and "look".
3528 * Note that this code can be called from "get_aim_dir()".
3530 * All locations must be on the current panel. Consider the use of
3531 * "panel_bounds()" to allow "off-panel" targets, perhaps by using
3532 * some form of "scrolling" the map around the cursor. XXX XXX XXX
3533 * That is, consider the possibility of "auto-scrolling" the screen
3534 * while the cursor moves around. This may require changes in the
3535 * "update_mon()" code to allow "visibility" even if off panel, and
3536 * may require dynamic recalculation of the "temp" grid set.
3538 * Hack -- targeting/observing an "outer border grid" may induce
3539 * problems, so this is not currently allowed.
3541 * The player can use the direction keys to move among "interesting"
3542 * grids in a heuristic manner, or the "space", "+", and "-" keys to
3543 * move through the "interesting" grids in a sequential manner, or
3544 * can enter "location" mode, and use the direction keys to move one
3545 * grid at a time in any direction. The "t" (set target) command will
3546 * only target a monster (as opposed to a location) if the monster is
3547 * target_able and the "interesting" mode is being used.
3549 * The current grid is described using the "look" method above, and
3550 * a new command may be entered at any time, but note that if the
3551 * "TARGET_LOOK" bit flag is set (or if we are in "location" mode,
3552 * where "space" has no obvious meaning) then "space" will scan
3553 * through the description of the current grid until done, instead
3554 * of immediately jumping to the next "interesting" grid. This
3555 * allows the "target" command to retain its old semantics.
3557 * The "*", "+", and "-" keys may always be used to jump immediately
3558 * to the next (or previous) interesting grid, in the proper mode.
3560 * The "return" key may always be used to scan through a complete
3561 * grid description (forever).
3563 * This command will cancel any old target, even if used from
3564 * inside the "look" command.
3566 bool target_set(BIT_FLAGS mode)
3569 POSITION y = p_ptr->y;
3570 POSITION x = p_ptr->x;
3583 get_screen_size(&wid, &hgt);
3589 /* Cancel tracking */
3590 /* health_track(0); */
3592 if (rogue_like_commands)
3601 /* Prepare the "temp" array */
3602 target_set_prepare(mode);
3604 /* Start near the player */
3610 /* Interesting grids */
3617 change_panel_xy(y, x);
3619 if (!(mode & TARGET_LOOK)) prt_path(y, x);
3622 c_ptr = &cave[y][x];
3625 if (target_able(c_ptr->m_idx))
3627 strcpy(info, _("q止 t決 p自 o現 +次 -前", "q,t,p,o,+,-,<dir>"));
3630 /* Dis-allow target */
3633 strcpy(info, _("q止 p自 o現 +次 -前", "q,p,o,+,-,<dir>"));
3639 sprintf(cheatinfo, " LOS:%d, PROJECTABLE:%d",
3640 los(p_ptr->y, p_ptr->x, y, x),
3641 projectable(p_ptr->y, p_ptr->x, y, x));
3642 strcat(info, cheatinfo);
3645 /* Describe and Prompt */
3647 query = target_set_aux(y, x, mode, info);
3651 /* Cancel tracking */
3652 /* health_track(0); */
3654 /* Assume no "direction" */
3659 if (query == '\r') query = 't';
3677 if (target_able(c_ptr->m_idx))
3679 health_track(c_ptr->m_idx);
3680 target_who = c_ptr->m_idx;
3699 if (!expand_list) done = TRUE;
3709 if (!expand_list) done = TRUE;
3716 /* Recenter the map around the player */
3720 p_ptr->update |= (PU_MONSTERS);
3723 p_ptr->redraw |= (PR_MAP);
3726 p_ptr->window |= (PW_OVERHEAD);
3731 /* Recalculate interesting grids */
3732 target_set_prepare(mode);
3751 if(query == same_key)
3756 if (!expand_list) done = TRUE;
3761 /* Extract the action (if any) */
3762 d = get_keymap_dir(query);
3769 /* Hack -- move around */
3772 /* Modified to scroll to monster */
3773 POSITION y2 = panel_row_min;
3774 POSITION x2 = panel_col_min;
3776 /* Find a new monster */
3777 i = target_pick(temp_y[m], temp_x[m], ddy[d], ddx[d]);
3779 /* Request to target past last interesting grid */
3780 while (flag && (i < 0))
3782 /* Note the change */
3783 if (change_panel(ddy[d], ddx[d]))
3788 /* Recalculate interesting grids */
3789 target_set_prepare(mode);
3791 /* Look at interesting grids */
3794 /* Find a new monster */
3795 i = target_pick(v, u, ddy[d], ddx[d]);
3801 /* Nothing interesting */
3807 /* Restore previous position */
3810 panel_bounds_center();
3813 p_ptr->update |= (PU_MONSTERS);
3816 p_ptr->redraw |= (PR_MAP);
3819 p_ptr->window |= (PW_OVERHEAD);
3824 /* Recalculate interesting grids */
3825 target_set_prepare(mode);
3827 /* Look at boring grids */
3834 /* Do not move horizontally if unnecessary */
3835 if (((x < panel_col_min + wid / 2) && (dx > 0)) ||
3836 ((x > panel_col_min + wid / 2) && (dx < 0)))
3841 /* Do not move vertically if unnecessary */
3842 if (((y < panel_row_min + hgt / 2) && (dy > 0)) ||
3843 ((y > panel_row_min + hgt / 2) && (dy < 0)))
3848 /* Apply the motion */
3849 if ((y >= panel_row_min+hgt) || (y < panel_row_min) ||
3850 (x >= panel_col_min+wid) || (x < panel_col_min))
3852 if (change_panel(dy, dx)) target_set_prepare(mode);
3855 /* Slide into legality */
3856 if (x >= cur_wid-1) x = cur_wid - 2;
3857 else if (x <= 0) x = 1;
3859 /* Slide into legality */
3860 if (y >= cur_hgt-1) y = cur_hgt- 2;
3861 else if (y <= 0) y = 1;
3870 /* Arbitrary grids */
3873 bool move_fast = FALSE;
3875 if (!(mode & TARGET_LOOK)) prt_path(y, x);
3878 c_ptr = &cave[y][x];
3880 /* Default prompt */
3881 strcpy(info, _("q止 t決 p自 m近 +次 -前", "q,t,p,m,+,-,<dir>"));
3886 sprintf(cheatinfo, " LOS:%d, PROJECTABLE:%d",
3887 los(p_ptr->y, p_ptr->x, y, x),
3888 projectable(p_ptr->y, p_ptr->x, y, x));
3889 strcat(info, cheatinfo);
3892 /* Describe and Prompt (enable "TARGET_LOOK") */
3893 while ((query = target_set_aux(y, x, mode | TARGET_LOOK, info)) == 0);
3895 /* Cancel tracking */
3896 /* health_track(0); */
3898 /* Assume no direction */
3903 if (query == '\r') query = 't';
3906 /* Analyze the keypress */
3930 /* Recenter the map around the player */
3934 p_ptr->update |= (PU_MONSTERS);
3937 p_ptr->redraw |= (PR_MAP);
3940 p_ptr->window |= (PW_OVERHEAD);
3945 /* Recalculate interesting grids */
3946 target_set_prepare(mode);
3968 /* Pick a nearby monster */
3969 for (i = 0; i < temp_n; i++)
3971 t = distance(y, x, temp_y[i], temp_x[i]);
3981 /* Nothing interesting */
3982 if (bd == 999) flag = FALSE;
3989 /* Extract the action (if any) */
3990 d = get_keymap_dir(query);
3992 /* XTRA HACK MOVEFAST */
3993 if (isupper(query)) move_fast = TRUE;
4000 /* Handle "direction" */
4006 /* XTRA HACK MOVEFAST */
4009 int mag = MIN(wid / 2, hgt / 2);
4019 /* Do not move horizontally if unnecessary */
4020 if (((x < panel_col_min + wid / 2) && (dx > 0)) ||
4021 ((x > panel_col_min + wid / 2) && (dx < 0)))
4026 /* Do not move vertically if unnecessary */
4027 if (((y < panel_row_min + hgt / 2) && (dy > 0)) ||
4028 ((y > panel_row_min + hgt / 2) && (dy < 0)))
4033 /* Apply the motion */
4034 if ((y >= panel_row_min + hgt) || (y < panel_row_min) ||
4035 (x >= panel_col_min + wid) || (x < panel_col_min))
4037 if (change_panel(dy, dx)) target_set_prepare(mode);
4040 /* Slide into legality */
4041 if (x >= cur_wid-1) x = cur_wid - 2;
4042 else if (x <= 0) x = 1;
4044 /* Slide into legality */
4045 if (y >= cur_hgt-1) y = cur_hgt- 2;
4046 else if (y <= 0) y = 1;
4054 /* Clear the top line */
4057 /* Recenter the map around the player */
4061 p_ptr->update |= (PU_MONSTERS);
4064 p_ptr->redraw |= (PR_MAP);
4067 p_ptr->window |= (PW_OVERHEAD);
4072 /* Failure to set target */
4073 if (!target_who) return (FALSE);
4081 * Get an "aiming direction" from the user.
4083 * The "dir" is loaded with 1,2,3,4,6,7,8,9 for "actual direction", and
4084 * "0" for "current target", and "-1" for "entry aborted".
4086 * Note that "Force Target", if set, will pre-empt user interaction,
4087 * if there is a usable target already set.
4089 * Note that confusion over-rides any (explicit?) user choice.
4091 bool get_aim_dir(DIRECTION *dp)
4101 /* Global direction */
4104 /* Hack -- auto-target if requested */
4105 if (use_old_target && target_okay()) dir = 5;
4107 #ifdef ALLOW_REPEAT /* TNB */
4109 if (repeat_pull(&code))
4114 if (!(code == 5 && !target_okay()))
4116 /* return (TRUE); */
4117 dir = (DIRECTION)code;
4120 *dp = (DIRECTION)code;
4122 #endif /* ALLOW_REPEAT -- TNB */
4124 /* Ask until satisfied */
4127 /* Choose a prompt */
4130 p = _("方向 ('*'でターゲット選択, ESCで中断)? ", "Direction ('*' to choose a target, Escape to cancel)? ");
4134 p = _("方向 ('5'でターゲットへ, '*'でターゲット再選択, ESCで中断)? ", "Direction ('5' for target, '*' to re-target, Escape to cancel)? ");
4137 /* Get a command (or Cancel) */
4138 if (!get_com(p, &command, TRUE)) break;
4142 if (command == '\r') command = 't';
4145 /* Convert various keys to "standard" keys */
4148 /* Use current target */
4159 /* Set new target */
4164 if (target_set(TARGET_KILL)) dir = 5;
4170 /* Extract the action (if any) */
4171 dir = get_keymap_dir(command);
4177 /* Verify requested targets */
4178 if ((dir == 5) && !target_okay()) dir = 0;
4187 project_length = 0; /* reset to default */
4191 /* Save the direction */
4194 /* Check for confusion */
4195 if (p_ptr->confused)
4197 /* Random direction */
4198 dir = ddd[randint0(8)];
4201 /* Notice confusion */
4202 if (command_dir != dir)
4205 msg_print(_("あなたは混乱している。", "You are confused."));
4208 /* Save direction */
4211 #ifdef ALLOW_REPEAT /* TNB */
4213 /* repeat_push(dir); */
4214 repeat_push((COMMAND_CODE)command_dir);
4216 #endif /* ALLOW_REPEAT -- TNB */
4218 /* A "valid" direction was entered */
4225 * Request a "movement" direction (1,2,3,4,6,7,8,9) from the user,
4226 * and place it into "command_dir", unless we already have one.
4228 * This function should be used for all "repeatable" commands, such as
4229 * run, walk, open, close, bash, disarm, spike, tunnel, etc, as well
4230 * as all commands which must reference a grid adjacent to the player,
4231 * and which may not reference the grid under the player. Note that,
4232 * for example, it is no longer possible to "disarm" or "open" chests
4233 * in the same grid as the player.
4235 * Direction "5" is illegal and will (cleanly) abort the command.
4237 * This function tracks and uses the "global direction", and uses
4238 * that as the "desired direction", to which "confusion" is applied.
4240 bool get_rep_dir(DIRECTION *dp, bool under)
4249 /* Global direction */
4252 #ifdef ALLOW_REPEAT /* TNB */
4254 if (repeat_pull(&code))
4256 dir = (DIRECTION)code;
4257 /* return (TRUE); */
4259 *dp = (DIRECTION)code;
4261 #endif /* ALLOW_REPEAT -- TNB */
4265 prompt = _("方向 ('.'足元, ESCで中断)? ", "Direction ('.' at feet, Escape to cancel)? ");
4269 prompt = _("方向 (ESCで中断)? ", "Direction (Escape to cancel)? ");
4272 /* Get a direction */
4277 /* Get a command (or Cancel) */
4278 if (!get_com(prompt, &ch, TRUE)) break;
4281 if ((under) && ((ch == '5') || (ch == '-') || (ch == '.')))
4287 /* Look up the direction */
4288 dir = get_keymap_dir(ch);
4295 /* Prevent weirdness */
4296 if ((dir == 5) && (!under)) dir = 0;
4299 if (!dir) return (FALSE);
4301 /* Save desired direction */
4304 /* Apply "confusion" */
4305 if (p_ptr->confused)
4307 /* Standard confusion */
4308 if (randint0(100) < 75)
4310 /* Random direction */
4311 dir = ddd[randint0(8)];
4314 else if (p_ptr->riding)
4316 monster_type *m_ptr = &m_list[p_ptr->riding];
4317 monster_race *r_ptr = &r_info[m_ptr->r_idx];
4319 if (MON_CONFUSED(m_ptr))
4321 /* Standard confusion */
4322 if (randint0(100) < 75)
4324 /* Random direction */
4325 dir = ddd[randint0(8)];
4328 else if ((r_ptr->flags1 & RF1_RAND_50) && (r_ptr->flags1 & RF1_RAND_25) && (randint0(100) < 50))
4330 /* Random direction */
4331 dir = ddd[randint0(8)];
4333 else if ((r_ptr->flags1 & RF1_RAND_50) && (randint0(100) < 25))
4335 /* Random direction */
4336 dir = ddd[randint0(8)];
4340 /* Notice confusion */
4341 if (command_dir != dir)
4343 if (p_ptr->confused)
4346 msg_print(_("あなたは混乱している。", "You are confused."));
4351 monster_type *m_ptr = &m_list[p_ptr->riding];
4353 monster_desc(m_name, m_ptr, 0);
4354 if (MON_CONFUSED(m_ptr))
4356 msg_format(_("%sは混乱している。", "%^s is confusing."), m_name);
4360 msg_format(_("%sは思い通りに動いてくれない。", "You cannot control %s."), m_name);
4365 /* Save direction */
4368 #ifdef ALLOW_REPEAT /* TNB */
4370 /* repeat_push(dir); */
4371 repeat_push((COMMAND_CODE)command_dir);
4373 #endif /* ALLOW_REPEAT -- TNB */
4380 bool get_rep_dir2(DIRECTION *dp)
4388 /* Global direction */
4391 #ifdef ALLOW_REPEAT /* TNB */
4393 if (repeat_pull(&code))
4395 dir = (DIRECTION)code;
4396 /* return (TRUE); */
4398 *dp = (DIRECTION)code;
4400 #endif /* ALLOW_REPEAT -- TNB */
4402 /* Get a direction */
4407 /* Get a command (or Cancel) */
4408 if (!get_com(_("方向 (ESCで中断)? ", "Direction (Escape to cancel)? "), &ch, TRUE)) break;
4410 /* Look up the direction */
4411 dir = get_keymap_dir(ch);
4417 /* Prevent weirdness */
4418 if (dir == 5) dir = 0;
4421 if (!dir) return (FALSE);
4423 /* Save desired direction */
4426 /* Apply "confusion" */
4427 if (p_ptr->confused)
4429 /* Standard confusion */
4430 if (randint0(100) < 75)
4432 /* Random direction */
4433 dir = ddd[randint0(8)];
4437 /* Notice confusion */
4438 if (command_dir != dir)
4441 msg_print(_("あなたは混乱している。", "You are confused."));
4444 /* Save direction */
4447 #ifdef ALLOW_REPEAT /* TNB */
4449 /* repeat_push(dir); */
4450 repeat_push((COMMAND_CODE)command_dir);
4452 #endif /* ALLOW_REPEAT -- TNB */
4458 void gain_level_reward(int chosen_reward)
4462 char wrath_reason[32] = "";
4463 int nasty_chance = 6;
4464 OBJECT_TYPE_VALUE dummy = 0;
4465 OBJECT_SUBTYPE_VALUE dummy2 = 0;
4468 char o_name[MAX_NLEN];
4474 if (multi_rew) return;
4475 else multi_rew = TRUE;
4479 if (p_ptr->lev == 13) nasty_chance = 2;
4480 else if (!(p_ptr->lev % 13)) nasty_chance = 3;
4481 else if (!(p_ptr->lev % 14)) nasty_chance = 12;
4483 if (one_in_(nasty_chance))
4484 type = randint1(20); /* Allow the 'nasty' effects */
4486 type = randint1(15) + 5; /* Or disallow them */
4488 if (type < 1) type = 1;
4489 if (type > 20) type = 20;
4493 sprintf(wrath_reason, _("%sの怒り", "the Wrath of %s"), chaos_patrons[p_ptr->chaos_patron]);
4495 effect = chaos_rewards[p_ptr->chaos_patron][type];
4497 if (one_in_(6) && !chosen_reward)
4499 msg_format(_("%^sは褒美としてあなたを突然変異させた。", "%^s rewards you with a mutation!"), chaos_patrons[p_ptr->chaos_patron]);
4500 (void)gain_random_mutation(0);
4501 reward = _("変異した。", "mutation");
4505 switch (chosen_reward ? chosen_reward : effect)
4510 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4511 msg_print(_("「汝、新たなる姿を必要とせり!」", "'Thou needst a new form, mortal!'"));
4514 reward = _("変異した。", "polymorphing");
4519 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4520 msg_print(_("「汝は良く行いたり!続けよ!」", "'Well done, mortal! Lead on!'"));
4522 if (p_ptr->prace == RACE_ANDROID)
4524 msg_print(_("しかし何も起こらなかった。", "But, nothing happen."));
4526 else if (p_ptr->exp < PY_MAX_EXP)
4528 s32b ee = (p_ptr->exp / 2) + 10;
4529 if (ee > 100000L) ee = 100000L;
4530 msg_print(_("更に経験を積んだような気がする。", "You feel more experienced."));
4533 reward = _("経験値を得た", "experience");
4539 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4540 msg_print(_("「下僕よ、汝それに値せず。」", "'Thou didst not deserve that, slave.'"));
4542 if (p_ptr->prace == RACE_ANDROID)
4544 msg_print(_("しかし何も起こらなかった。", "But, nothing happen."));
4548 lose_exp(p_ptr->exp / 6);
4549 reward = _("経験値を失った。", "losing experience");
4555 msg_format("%sの声がささやいた:",
4556 chaos_patrons[p_ptr->chaos_patron]);
4558 msg_format("The voice of %s whispers:",
4559 chaos_patrons[p_ptr->chaos_patron]);
4562 msg_print(_("「我が与えし物を賢明に使うべし。」", "'Use my gift wisely.'"));
4564 acquirement(p_ptr->y, p_ptr->x, 1, FALSE, FALSE, FALSE);
4565 reward = _("上質なアイテムを手に入れた。", "a good item");
4570 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4571 msg_print(_("「我が与えし物を賢明に使うべし。」", "'Use my gift wisely.'"));
4573 acquirement(p_ptr->y, p_ptr->x, 1, TRUE, FALSE, FALSE);
4574 reward = _("高級品のアイテムを手に入れた。", "an excellent item");
4579 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4580 msg_print(_("「汝の行いは貴き剣に値せり。」", "'Thy deed hath earned thee a worthy blade.'"));
4582 /* Get local object */
4585 switch (randint1(p_ptr->lev))
4591 dummy2 = SV_MAIN_GAUCHE;
4600 dummy2 = SV_SMALL_SWORD;
4603 dummy2 = SV_BASILLARD;
4605 case 11: case 12: case 13:
4606 dummy2 = SV_SHORT_SWORD;
4612 dummy2 = SV_CUTLASS;
4615 dummy2 = SV_WAKIZASHI;
4618 dummy2 = SV_KHOPESH;
4624 dummy2 = SV_BROAD_SWORD;
4627 dummy2 = SV_LONG_SWORD;
4630 dummy2 = SV_SCIMITAR;
4633 dummy2 = SV_NINJATO;
4639 dummy2 = SV_BASTARD_SWORD;
4642 dummy2 = SV_GREAT_SCIMITAR;
4645 dummy2 = SV_CLAYMORE;
4648 dummy2 = SV_ESPADON;
4651 dummy2 = SV_TWO_HANDED_SWORD;
4654 dummy2 = SV_FLAMBERGE;
4657 dummy2 = SV_NO_DACHI;
4660 dummy2 = SV_EXECUTIONERS_SWORD;
4663 dummy2 = SV_ZWEIHANDER;
4666 dummy2 = SV_HAYABUSA;
4669 dummy2 = SV_BLADE_OF_CHAOS;
4672 object_prep(q_ptr, lookup_kind(dummy, dummy2));
4673 q_ptr->to_h = 3 + randint1(dun_level) % 10;
4674 q_ptr->to_d = 3 + randint1(dun_level) % 10;
4675 one_resistance(q_ptr);
4676 q_ptr->name2 = EGO_CHAOTIC;
4678 /* Drop it in the dungeon */
4679 (void)drop_near(q_ptr, -1, p_ptr->y, p_ptr->x);
4680 reward = _("(混沌)の武器を手に入れた。", "chaos weapon");
4685 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4686 msg_print(_("「汝の行いは貴き報いに値せり。」", "'Thy deed hath earned thee a worthy reward.'"));
4688 acquirement(p_ptr->y, p_ptr->x, randint1(2) + 1, FALSE, FALSE, FALSE);
4689 reward = _("上質なアイテムを手に入れた。", "good items");
4694 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4695 msg_print(_("「下僕よ、汝の献身への我が惜しみ無き報いを見るがよい。」", "'Behold, mortal, how generously I reward thy loyalty.'"));
4697 acquirement(p_ptr->y, p_ptr->x, randint1(2) + 1, TRUE, FALSE, FALSE);
4698 reward = _("高級品のアイテムを手に入れた。", "excellent items");
4703 msg_format("%sの声が轟き渡った:", chaos_patrons[p_ptr->chaos_patron]);
4705 msg_format("The voice of %s thunders:", chaos_patrons[p_ptr->chaos_patron]);
4708 msg_print(_("「下僕よ、汝傲慢なり。」", "'Thou art growing arrogant, mortal.'"));
4710 (void)activate_ty_curse(FALSE, &count);
4711 reward = _("禍々しい呪いをかけられた。", "cursing");
4716 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4717 msg_print(_("「我が下僕たちよ、かの傲慢なる者を倒すべし!」", "'My pets, destroy the arrogant mortal!'"));
4719 for (dummy = 0; dummy < randint1(5) + 1; dummy++)
4721 (void)summon_specific(0, p_ptr->y, p_ptr->x, dun_level, 0, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET));
4723 reward = _("モンスターを召喚された。", "summoning hostile monsters");
4729 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4730 msg_print(_("「汝、より強き敵を必要とせり!」", "'Thou needst worthier opponents!'"));
4732 activate_hi_summon(p_ptr->y, p_ptr->x, FALSE);
4733 reward = _("モンスターを召喚された。", "summoning many hostile monsters");
4739 msg_format("%sの声が響き渡った:",
4740 chaos_patrons[p_ptr->chaos_patron]);
4742 msg_format("The voice of %s booms out:",
4743 chaos_patrons[p_ptr->chaos_patron]);
4746 msg_print(_("「死と破壊こそ我が喜びなり!」", "'Death and destruction! This pleaseth me!'"));
4749 reward = _("カオスの力が渦巻いた。", "calling chaos");
4755 msg_format("%sの声が鳴り響いた:",
4756 chaos_patrons[p_ptr->chaos_patron]);
4758 msg_format("The voice of %s rings out:",
4759 chaos_patrons[p_ptr->chaos_patron]);
4762 msg_print(_("「留まるのだ、下僕よ。余が汝の肉体を鍛えん。」", "'Stay, mortal, and let me mold thee.'"));
4764 if (one_in_(3) && !(chaos_stats[p_ptr->chaos_patron] < 0))
4765 do_inc_stat(chaos_stats[p_ptr->chaos_patron]);
4767 do_inc_stat(randint0(6));
4768 reward = _("能力値が上がった。", "increasing a stat");
4774 msg_format("%sの声が響き渡った:",
4775 chaos_patrons[p_ptr->chaos_patron]);
4777 msg_format("The voice of %s booms out:",
4778 chaos_patrons[p_ptr->chaos_patron]);
4781 msg_print(_("「下僕よ、余は汝に飽みたり。」", "'I grow tired of thee, mortal.'"));
4783 if (one_in_(3) && !(chaos_stats[p_ptr->chaos_patron] < 0))
4784 do_dec_stat(chaos_stats[p_ptr->chaos_patron]);
4786 (void)do_dec_stat(randint0(6));
4787 reward = _("能力値が下がった。", "decreasing a stat");
4794 msg_format("%sの声が轟き渡った:",
4795 chaos_patrons[p_ptr->chaos_patron]);
4797 msg_format("The voice of %s thunders:",
4798 chaos_patrons[p_ptr->chaos_patron]);
4801 msg_print(_("「汝、謙虚たることを学ぶべし!」", "'Thou needst a lesson in humility, mortal!'"));
4802 msg_print(_("あなたは以前より弱くなった!", "You feel less powerful!"));
4804 for (dummy = 0; dummy < 6; dummy++)
4806 (void)dec_stat(dummy, 10 + randint1(15), TRUE);
4808 reward = _("全能力値が下がった。", "decreasing all stats");
4813 msg_format(_("%sの力が触れるのを感じた。", "You feel the power of %s touch you."),
4814 chaos_patrons[p_ptr->chaos_patron]);
4816 reward = _("傷が変化した。", "polymorphing wounds");
4821 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4823 msg_print(_("「我がささやかなる賜物を受けとるがよい!」", "'Receive this modest gift from me!'"));
4825 for (dummy = 0; dummy < 6; dummy++)
4827 (void)do_inc_stat(dummy);
4829 reward = _("全能力値が上がった。", "increasing all stats");
4834 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4835 msg_print(_("「苦しむがよい、無能な愚か者よ!」", "'Suffer, pathetic fool!'"));
4837 fire_ball(GF_DISINTEGRATE, 0, p_ptr->lev * 4, 4);
4838 take_hit(DAMAGE_NOESCAPE, p_ptr->lev * 4, wrath_reason, -1);
4839 reward = _("分解の球が発生した。", "generating disintegration ball");
4844 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4845 (void)restore_level();
4846 (void)restore_all_status();
4847 (void)true_healing(5000);
4848 reward = _("体力が回復した。", "healing");
4853 if (!buki_motteruka(INVEN_RARM) && !buki_motteruka(INVEN_LARM)) break;
4854 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4855 msg_print(_("「汝、武器に頼ることなかれ。」", "'Thou reliest too much on thy weapon.'"));
4858 if (buki_motteruka(INVEN_LARM))
4861 if (buki_motteruka(INVEN_RARM) && one_in_(2)) dummy = INVEN_RARM;
4863 object_desc(o_name, &inventory[dummy], OD_NAME_ONLY);
4864 (void)curse_weapon(FALSE, dummy);
4865 reward = format(_("%sが破壊された。", "destroying %s"), o_name);
4870 if (!inventory[INVEN_BODY].k_idx) break;
4871 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4872 msg_print(_("「汝、防具に頼ることなかれ。」", "'Thou reliest too much on thine equipment.'"));
4874 object_desc(o_name, &inventory[INVEN_BODY], OD_NAME_ONLY);
4875 (void)curse_armor();
4876 reward = format(_("%sが破壊された。", "destroying %s"), o_name);
4880 msg_format(_("%sの声がささやいた:", "The voice of %s whispers:"), chaos_patrons[p_ptr->chaos_patron]);
4881 msg_print(_("「我を怒りしめた罪を償うべし。」", "'Now thou shalt pay for annoying me.'"));
4883 switch (randint1(4))
4886 (void)activate_ty_curse(FALSE, &count);
4887 reward = _("禍々しい呪いをかけられた。", "cursing");
4890 activate_hi_summon(p_ptr->y, p_ptr->x, FALSE);
4891 reward = _("モンスターを召喚された。", "summoning hostile monsters");
4896 if (!buki_motteruka(INVEN_RARM) && !buki_motteruka(INVEN_LARM)) break;
4898 if (buki_motteruka(INVEN_LARM))
4901 if (buki_motteruka(INVEN_RARM) && one_in_(2)) dummy = INVEN_RARM;
4903 object_desc(o_name, &inventory[dummy], OD_NAME_ONLY);
4904 (void)curse_weapon(FALSE, dummy);
4905 reward = format(_("%sが破壊された。", "destroying %s"), o_name);
4909 if (!inventory[INVEN_BODY].k_idx) break;
4910 object_desc(o_name, &inventory[INVEN_BODY], OD_NAME_ONLY);
4911 (void)curse_armor();
4912 reward = format(_("%sが破壊された。", "destroying %s"), o_name);
4916 for (dummy = 0; dummy < 6; dummy++)
4918 (void)dec_stat(dummy, 10 + randint1(15), TRUE);
4920 reward = _("全能力値が下がった。", "decreasing all stats");
4927 msg_format(_("%sの声が轟き渡った:", "The voice of %s thunders:"), chaos_patrons[p_ptr->chaos_patron]);
4928 msg_print(_("「死ぬがよい、下僕よ!」", "'Die, mortal!'"));
4930 take_hit(DAMAGE_LOSELIFE, p_ptr->lev * 4, wrath_reason, -1);
4931 for (dummy = 0; dummy < 6; dummy++)
4933 (void)dec_stat(dummy, 10 + randint1(15), FALSE);
4935 activate_hi_summon(p_ptr->y, p_ptr->x, FALSE);
4936 (void)activate_ty_curse(FALSE, &count);
4941 if (buki_motteruka(INVEN_RARM))
4944 if (buki_motteruka(INVEN_LARM) && one_in_(2)) dummy = INVEN_LARM;
4946 else if (buki_motteruka(INVEN_LARM)) dummy = INVEN_LARM;
4948 if (dummy) (void)curse_weapon(FALSE, dummy);
4950 if (one_in_(2)) (void)curse_armor();
4955 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4956 msg_print(_("「死と破壊こそ我が喜びなり!」", "'Death and destruction! This pleaseth me!'"));
4958 (void)destroy_area(p_ptr->y, p_ptr->x, 25, FALSE);
4959 reward = _("ダンジョンが*破壊*された。", "*destruct*ing dungeon");
4964 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4965 msg_print(_("「我、汝の敵を抹殺せん!」", "'Let me relieve thee of thine oppressors!'"));
4966 (void)symbol_genocide(0, FALSE);
4967 reward = _("モンスターが抹殺された。", "genociding monsters");
4972 msg_format(_("%sの声が響き渡った:", "The voice of %s booms out:"), chaos_patrons[p_ptr->chaos_patron]);
4973 msg_print(_("「我、汝の敵を抹殺せん!」", "'Let me relieve thee of thine oppressors!'"));
4975 (void)mass_genocide(0, FALSE);
4976 reward = _("モンスターが抹殺された。", "genociding nearby monsters");
4981 msg_format(_("%sの力が敵を攻撃するのを感じた!", "You can feel the power of %s assault your enemies!"), chaos_patrons[p_ptr->chaos_patron]);
4982 (void)dispel_monsters(p_ptr->lev * 4);
4987 msg_format(_("%sはあなたを無視した。", "%s ignores you."), chaos_patrons[p_ptr->chaos_patron]);
4992 msg_format(_("%sは褒美として悪魔の使いをよこした!", "%s rewards you with a demonic servant!"),chaos_patrons[p_ptr->chaos_patron]);
4994 if (!summon_specific(-1, p_ptr->y, p_ptr->x, dun_level, SUMMON_DEMON, PM_FORCE_PET))
4995 msg_print(_("何も現れなかった...", "Nobody ever turns up..."));
4997 reward = _("悪魔がペットになった。", "a demonic servant");
5002 msg_format(_("%sは褒美として使いをよこした!", "%s rewards you with a servant!"),chaos_patrons[p_ptr->chaos_patron]);
5004 if (!summon_specific(-1, p_ptr->y, p_ptr->x, dun_level, 0, PM_FORCE_PET))
5005 msg_print(_("何も現れなかった...", "Nobody ever turns up..."));
5007 reward = _("モンスターがペットになった。", "a servant");
5012 msg_format(_("%sは褒美としてアンデッドの使いをよこした。", "%s rewards you with an undead servant!"),chaos_patrons[p_ptr->chaos_patron]);
5014 if (!summon_specific(-1, p_ptr->y, p_ptr->x, dun_level, SUMMON_UNDEAD, PM_FORCE_PET))
5015 msg_print(_("何も現れなかった...", "Nobody ever turns up..."));
5017 reward = _("アンデッドがペットになった。", "an undead servant");
5022 msg_format(_("%sの声がどもった:", "The voice of %s stammers:"),
5024 chaos_patrons[p_ptr->chaos_patron]);
5025 msg_format(_("「あー、あー、答えは %d/%d。質問は何?」", "'Uh... uh... the answer's %d/%d, what's the question?'"), type, effect);
5031 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, format(_("パトロンの報酬で%s", "The patron rewards you with %s."), reward));
5037 * XAngband: determine if a given location is "interesting"
5038 * based on target_set_accept function.
5040 static bool tgt_pt_accept(POSITION y, POSITION x)
5045 if (!(in_bounds(y, x))) return (FALSE);
5047 /* Player grid is always interesting */
5048 if ((y == p_ptr->y) && (x == p_ptr->x)) return (TRUE);
5050 /* Handle hallucination */
5051 if (p_ptr->image) return (FALSE);
5053 /* Examine the grid */
5054 c_ptr = &cave[y][x];
5056 /* Interesting memorized features */
5057 if (c_ptr->info & (CAVE_MARK))
5060 if (cave_have_flag_grid(c_ptr, FF_LESS)) return (TRUE);
5061 if (cave_have_flag_grid(c_ptr, FF_MORE)) return (TRUE);
5063 /* Notice quest features */
5064 if (cave_have_flag_grid(c_ptr, FF_QUEST_ENTER)) return (TRUE);
5065 if (cave_have_flag_grid(c_ptr, FF_QUEST_EXIT)) return (TRUE);
5074 * XAngband: Prepare the "temp" array for "tget_pt"
5075 * based on target_set_prepare funciton.
5077 static void tgt_pt_prepare(void)
5081 /* Reset "temp" array */
5084 if (!expand_list) return;
5086 /* Scan the current panel */
5087 for (y = 1; y < cur_hgt; y++)
5089 for (x = 1; x < cur_wid; x++)
5091 /* Require "interesting" contents */
5092 if (!tgt_pt_accept(y, x)) continue;
5094 /* Save the location */
5101 /* Target the nearest monster for shooting */
5102 ang_sort_comp = ang_sort_comp_distance;
5103 ang_sort_swap = ang_sort_swap_distance;
5105 /* Sort the positions */
5106 ang_sort(temp_x, temp_y, temp_n);
5110 * old -- from PsiAngband.
5112 bool tgt_pt(POSITION *x_ptr, POSITION *y_ptr)
5117 bool success = FALSE;
5122 get_screen_size(&wid, &hgt);
5132 msg_print(_("場所を選んでスペースキーを押して下さい。", "Select a point and press space."));
5133 msg_flag = FALSE; /* prevents "-more-" message. */
5135 while ((ch != ESCAPE) && !success)
5137 bool move_fast = FALSE;
5139 move_cursor_relative(y, x);
5151 if (player_bold(y, x)) ch = 0;
5154 else success = TRUE;
5158 /* XAngband: Move cursor to stairs */
5161 if (expand_list && temp_n)
5164 int cx = (panel_col_min + panel_col_max) / 2;
5165 int cy = (panel_row_min + panel_row_max) / 2;
5169 /* Skip stairs which have defferent distance */
5170 for (; n < temp_n; ++ n)
5172 cave_type *c_ptr = &cave[temp_y[n]][temp_x[n]];
5174 if (cave_have_flag_grid(c_ptr, FF_STAIRS) &&
5175 cave_have_flag_grid(c_ptr, ch == '>' ? FF_MORE : FF_LESS))
5182 if (n == temp_n) /* Loop out taget list */
5187 verify_panel(); /* Move cursor to player */
5190 p_ptr->update |= (PU_MONSTERS);
5193 p_ptr->redraw |= (PR_MAP);
5196 p_ptr->window |= (PW_OVERHEAD);
5201 else /* move cursor to next stair and change panel */
5206 dy = 2 * (y - cy) / hgt;
5207 dx = 2 * (x - cx) / wid;
5208 if (dy || dx) change_panel(dy, dx);
5214 /* Look up the direction */
5215 d = get_keymap_dir(ch);
5217 /* XTRA HACK MOVEFAST */
5218 if (isupper(ch)) move_fast = TRUE;
5220 /* Handle "direction" */
5226 /* XTRA HACK MOVEFAST */
5229 int mag = MIN(wid / 2, hgt / 2);
5239 /* Do not move horizontally if unnecessary */
5240 if (((x < panel_col_min + wid / 2) && (dx > 0)) ||
5241 ((x > panel_col_min + wid / 2) && (dx < 0)))
5246 /* Do not move vertically if unnecessary */
5247 if (((y < panel_row_min + hgt / 2) && (dy > 0)) ||
5248 ((y > panel_row_min + hgt / 2) && (dy < 0)))
5253 /* Apply the motion */
5254 if ((y >= panel_row_min + hgt) || (y < panel_row_min) ||
5255 (x >= panel_col_min + wid) || (x < panel_col_min))
5257 /* if (change_panel(dy, dx)) target_set_prepare(mode); */
5258 change_panel(dy, dx);
5261 /* Slide into legality */
5262 if (x >= cur_wid-1) x = cur_wid - 2;
5263 else if (x <= 0) x = 1;
5265 /* Slide into legality */
5266 if (y >= cur_hgt-1) y = cur_hgt- 2;
5267 else if (y <= 0) y = 1;
5274 /* Clear the top line */
5277 /* Recenter the map around the player */
5281 p_ptr->update |= (PU_MONSTERS);
5284 p_ptr->redraw |= (PR_MAP);
5287 p_ptr->window |= (PW_OVERHEAD);
5298 bool get_hack_dir(DIRECTION *dp)
5307 /* Global direction */
5310 /* (No auto-targeting) */
5312 /* Ask until satisfied */
5315 /* Choose a prompt */
5318 p = _("方向 ('*'でターゲット選択, ESCで中断)? ", "Direction ('*' to choose a target, Escape to cancel)? ");
5322 p = _("方向 ('5'でターゲットへ, '*'でターゲット再選択, ESCで中断)? ", "Direction ('5' for target, '*' to re-target, Escape to cancel)? ");
5325 /* Get a command (or Cancel) */
5326 if (!get_com(p, &command, TRUE)) break;
5330 if (command == '\r') command = 't';
5333 /* Convert various keys to "standard" keys */
5336 /* Use current target */
5347 /* Set new target */
5352 if (target_set(TARGET_KILL)) dir = 5;
5358 /* Look up the direction */
5359 dir = get_keymap_dir(command);
5365 /* Verify requested targets */
5366 if ((dir == 5) && !target_okay()) dir = 0;
5373 if (!dir) return (FALSE);
5375 /* Save the direction */
5378 /* Check for confusion */
5379 if (p_ptr->confused)
5381 /* Random direction */
5382 dir = ddd[randint0(8)];
5385 /* Notice confusion */
5386 if (command_dir != dir)
5389 msg_print(_("あなたは混乱している。", "You are confused."));
5392 /* Save direction */
5395 /* A "valid" direction was entered */
5401 * エネルギーの増加量10d5を速く計算するための関数
5404 #define Go_no_JuuJou 5*5*5*5*5*5*5*5*5*5
5406 s16b gain_energy(void)
5409 s32b energy_result = 10;
5412 tmp = randint0(Go_no_JuuJou);
5414 for (i = 0; i < 9; i ++){
5415 energy_result += tmp % 5;
5419 return (s16b)(energy_result + tmp);
5424 * @brief 射撃武器の攻撃に必要な基本消費エネルギーを返す/Return bow energy
5425 * @param sval 射撃武器のアイテム副分類ID
5426 * @return 消費する基本エネルギー
5428 ENERGY bow_energy(OBJECT_SUBTYPE_VALUE sval)
5430 ENERGY energy = 10000;
5432 /* Analyze the launcher */
5435 /* Sling and ammo */
5442 /* Short Bow and Arrow */
5449 /* Long Bow and Arrow */
5456 /* Bow of irresponsiblity and Arrow */
5463 /* Light Crossbow and Bolt */
5470 /* Heavy Crossbow and Bolt */
5485 int bow_tmul(OBJECT_SUBTYPE_VALUE sval)
5489 /* Analyze the launcher */
5492 /* Sling and ammo */
5499 /* Short Bow and Arrow */
5506 /* Long Bow and Arrow */
5513 /* Bow of irresponsiblity and Arrow */
5520 /* Light Crossbow and Bolt */
5527 /* Heavy Crossbow and Bolt */
5539 * Return alignment title
5541 cptr your_alignment(void)
5544 if (p_ptr->align > 150) return "大善";
5545 else if (p_ptr->align > 50) return "中善";
5546 else if (p_ptr->align > 10) return "小善";
5547 else if (p_ptr->align > -11) return "中立";
5548 else if (p_ptr->align > -51) return "小悪";
5549 else if (p_ptr->align > -151) return "中悪";
5552 if (p_ptr->align > 150) return "Lawful";
5553 else if (p_ptr->align > 50) return "Good";
5554 else if (p_ptr->align > 10) return "Neutral Good";
5555 else if (p_ptr->align > -11) return "Neutral";
5556 else if (p_ptr->align > -51) return "Neutral Evil";
5557 else if (p_ptr->align > -151) return "Evil";
5558 else return "Chaotic";
5564 * Return proficiency level of weapons and misc. skills (except riding)
5566 int weapon_exp_level(int weapon_exp)
5568 if (weapon_exp < WEAPON_EXP_BEGINNER) return EXP_LEVEL_UNSKILLED;
5569 else if (weapon_exp < WEAPON_EXP_SKILLED) return EXP_LEVEL_BEGINNER;
5570 else if (weapon_exp < WEAPON_EXP_EXPERT) return EXP_LEVEL_SKILLED;
5571 else if (weapon_exp < WEAPON_EXP_MASTER) return EXP_LEVEL_EXPERT;
5572 else return EXP_LEVEL_MASTER;
5577 * Return proficiency level of riding
5579 int riding_exp_level(int riding_exp)
5581 if (riding_exp < RIDING_EXP_BEGINNER) return EXP_LEVEL_UNSKILLED;
5582 else if (riding_exp < RIDING_EXP_SKILLED) return EXP_LEVEL_BEGINNER;
5583 else if (riding_exp < RIDING_EXP_EXPERT) return EXP_LEVEL_SKILLED;
5584 else if (riding_exp < RIDING_EXP_MASTER) return EXP_LEVEL_EXPERT;
5585 else return EXP_LEVEL_MASTER;
5590 * Return proficiency level of spells
5592 int spell_exp_level(int spell_exp)
5594 if (spell_exp < SPELL_EXP_BEGINNER) return EXP_LEVEL_UNSKILLED;
5595 else if (spell_exp < SPELL_EXP_SKILLED) return EXP_LEVEL_BEGINNER;
5596 else if (spell_exp < SPELL_EXP_EXPERT) return EXP_LEVEL_SKILLED;
5597 else if (spell_exp < SPELL_EXP_MASTER) return EXP_LEVEL_EXPERT;
5598 else return EXP_LEVEL_MASTER;
5603 * Display a rumor and apply its effects
5606 IDX rumor_num(char *zz, IDX max_idx)
5608 if (strcmp(zz, "*") == 0) return randint1(max_idx - 1);
5609 return (IDX)atoi(zz);
5612 cptr rumor_bind_name(char *base, cptr fullname)
5616 s = strstr(base, "{Name}");
5620 v = format("%s%s%s", base, fullname, (s + 6));
5630 void display_rumor(bool ex)
5638 if (randint0(3) == 0) section = 1;
5641 err = _(get_rnd_line_jonly("rumors_j.txt", section, Rumor, 10),
5642 get_rnd_line("rumors.txt", section, Rumor));
5643 if (err) strcpy(Rumor, _("嘘の噂もある。", "Some rumors are wrong."));
5647 if (strncmp(Rumor, "R:", 2) == 0)
5650 cptr rumor_msg = NULL;
5651 cptr rumor_eff_format = NULL;
5652 char fullname[1024] = "";
5654 if (tokenize(Rumor + 2, 3, zz, TOKENIZE_CHECKQUOTE) == 3)
5656 if (strcmp(zz[0], "ARTIFACT") == 0)
5660 object_type *q_ptr = &forge;
5661 artifact_type *a_ptr;
5665 a_idx = rumor_num(zz[1], max_a_idx);
5667 a_ptr = &a_info[a_idx];
5668 if (a_ptr->name) break;
5671 k_idx = lookup_kind(a_ptr->tval, a_ptr->sval);
5672 object_prep(q_ptr, k_idx);
5673 q_ptr->name1 = a_idx;
5674 q_ptr->ident = IDENT_STORE;
5675 object_desc(fullname, q_ptr, OD_NAME_ONLY);
5677 else if (strcmp(zz[0], "MONSTER") == 0)
5680 monster_race *r_ptr;
5684 r_idx = rumor_num(zz[1], max_r_idx);
5685 r_ptr = &r_info[r_idx];
5686 if (r_ptr->name) break;
5689 strcpy(fullname, r_name + r_ptr->name);
5691 /* Remember this monster */
5692 if (!r_ptr->r_sights)
5697 else if (strcmp(zz[0], "DUNGEON") == 0)
5700 dungeon_info_type *d_ptr;
5704 d_idx = rumor_num(zz[1], max_d_idx);
5705 d_ptr = &d_info[d_idx];
5706 if (d_ptr->name) break;
5709 strcpy(fullname, d_name + d_ptr->name);
5711 if (!max_dlv[d_idx])
5713 max_dlv[d_idx] = d_ptr->mindepth;
5714 rumor_eff_format = _("%sに帰還できるようになった。", "You can recall to %s.");
5717 else if (strcmp(zz[0], "TOWN") == 0)
5724 t_idx = rumor_num(zz[1], NO_TOWN);
5725 if (town[t_idx].name) break;
5728 strcpy(fullname, town[t_idx].name);
5730 visit = (1L << (t_idx - 1));
5731 if ((t_idx != SECRET_TOWN) && !(p_ptr->visit & visit))
5733 p_ptr->visit |= visit;
5734 rumor_eff_format = _("%sに行ったことがある気がする。", "You feel you have been to %s.");
5738 rumor_msg = rumor_bind_name(zz[2], fullname);
5739 msg_print(rumor_msg);
5740 if (rumor_eff_format)
5743 msg_format(rumor_eff_format, fullname);
5748 if (err) msg_print(_("この情報は間違っている。", "This information is wrong."));
5752 msg_format("%s", Rumor);