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 #define REWARD_CHANCE 10
20 * @brief ¥×¥ì¥¤¥ä¡¼¤Î·Ð¸³ÃͤˤĤ¤¤ÆÀ°¹çÀ¤Î¤¿¤á¤Î¥Á¥§¥Ã¥¯¤ÈÄ´À°¤ò¹Ô¤¦ /
21 * Advance experience levels and print experience
24 void check_experience(void)
26 bool level_reward = FALSE;
27 bool level_mutation = FALSE;
28 bool level_inc_stat = FALSE;
29 bool android = (p_ptr->prace == RACE_ANDROID ? TRUE : FALSE);
30 int old_lev = p_ptr->lev;
32 /* Hack -- lower limit */
33 if (p_ptr->exp < 0) p_ptr->exp = 0;
34 if (p_ptr->max_exp < 0) p_ptr->max_exp = 0;
35 if (p_ptr->max_max_exp < 0) p_ptr->max_max_exp = 0;
37 /* Hack -- upper limit */
38 if (p_ptr->exp > PY_MAX_EXP) p_ptr->exp = PY_MAX_EXP;
39 if (p_ptr->max_exp > PY_MAX_EXP) p_ptr->max_exp = PY_MAX_EXP;
40 if (p_ptr->max_max_exp > PY_MAX_EXP) p_ptr->max_max_exp = PY_MAX_EXP;
42 /* Hack -- maintain "max" experience */
43 if (p_ptr->exp > p_ptr->max_exp) p_ptr->max_exp = p_ptr->exp;
45 /* Hack -- maintain "max max" experience */
46 if (p_ptr->max_exp > p_ptr->max_max_exp) p_ptr->max_max_exp = p_ptr->max_exp;
48 /* Redraw experience */
49 p_ptr->redraw |= (PR_EXP);
55 /* Lose levels while possible */
56 while ((p_ptr->lev > 1) &&
57 (p_ptr->exp < ((android ? player_exp_a : player_exp)[p_ptr->lev - 2] * p_ptr->expfact / 100L)))
62 /* Update some stuff */
63 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
65 /* Redraw some stuff */
66 p_ptr->redraw |= (PR_LEV | PR_TITLE);
69 p_ptr->window |= (PW_PLAYER);
76 /* Gain levels while possible */
77 while ((p_ptr->lev < PY_MAX_LEVEL) &&
78 (p_ptr->exp >= ((android ? player_exp_a : player_exp)[p_ptr->lev-1] * p_ptr->expfact / 100L)))
83 /* Save the highest level */
84 if (p_ptr->lev > p_ptr->max_plv)
86 p_ptr->max_plv = p_ptr->lev;
88 if ((p_ptr->pclass == CLASS_CHAOS_WARRIOR) ||
89 (p_ptr->muta2 & MUT2_CHAOS_GIFT))
93 if (p_ptr->prace == RACE_BEASTMAN)
95 if (one_in_(5)) level_mutation = TRUE;
97 level_inc_stat = TRUE;
99 do_cmd_write_nikki(NIKKI_LEVELUP, p_ptr->lev, NULL);
107 msg_format("¥ì¥Ù¥ë %d ¤Ë¤è¤¦¤³¤½¡£", p_ptr->lev);
109 msg_format("Welcome to level %d.", p_ptr->lev);
113 /* Update some stuff */
114 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
116 /* Redraw some stuff */
117 p_ptr->redraw |= (PR_LEV | PR_TITLE | PR_EXP);
120 p_ptr->window |= (PW_PLAYER | PW_SPELL | PW_INVEN);
122 /* HP¤ÈMP¤Î¾å¾ºÎ̤òɽ¼¨ */
132 if(!(p_ptr->max_plv % 10))
142 cnv_stat(p_ptr->stat_max[0], tmp);
143 prt(format(" a) ÏÓÎÏ (¸½ºßÃÍ %s)", tmp), 2, 14);
144 cnv_stat(p_ptr->stat_max[1], tmp);
145 prt(format(" b) ÃÎǽ (¸½ºßÃÍ %s)", tmp), 3, 14);
146 cnv_stat(p_ptr->stat_max[2], tmp);
147 prt(format(" c) ¸¤µ (¸½ºßÃÍ %s)", tmp), 4, 14);
148 cnv_stat(p_ptr->stat_max[3], tmp);
149 prt(format(" d) ´ïÍÑ (¸½ºßÃÍ %s)", tmp), 5, 14);
150 cnv_stat(p_ptr->stat_max[4], tmp);
151 prt(format(" e) ÂÑµ× (¸½ºßÃÍ %s)", tmp), 6, 14);
152 cnv_stat(p_ptr->stat_max[5], tmp);
153 prt(format(" f) Ì¥ÎÏ (¸½ºßÃÍ %s)", tmp), 7, 14);
155 prt(" ¤É¤ÎǽÎÏÃͤò¾å¤²¤Þ¤¹¤«¡©", 1, 14);
157 cnv_stat(p_ptr->stat_max[0], tmp);
158 prt(format(" a) Str (cur %s)", tmp), 2, 14);
159 cnv_stat(p_ptr->stat_max[1], tmp);
160 prt(format(" b) Int (cur %s)", tmp), 3, 14);
161 cnv_stat(p_ptr->stat_max[2], tmp);
162 prt(format(" c) Wis (cur %s)", tmp), 4, 14);
163 cnv_stat(p_ptr->stat_max[3], tmp);
164 prt(format(" d) Dex (cur %s)", tmp), 5, 14);
165 cnv_stat(p_ptr->stat_max[4], tmp);
166 prt(format(" e) Con (cur %s)", tmp), 6, 14);
167 cnv_stat(p_ptr->stat_max[5], tmp);
168 prt(format(" f) Chr (cur %s)", tmp), 7, 14);
170 prt(" Which stat do you want to raise?", 1, 14);
175 if ((choice >= 'a') && (choice <= 'f')) break;
177 for(n = 0; n < 6; n++)
178 if (n != choice - 'a')
181 if (get_check("¤è¤í¤·¤¤¤Ç¤¹¤«¡©")) break;
183 if (get_check("Are you sure? ")) break;
186 do_inc_stat(choice - 'a');
189 else if(!(p_ptr->max_plv % 2))
190 do_inc_stat(randint0(6));
196 msg_print("¤¢¤Ê¤¿¤ÏÊѤï¤Ã¤¿µ¤¤¬¤¹¤ë...");
198 msg_print("You feel different...");
201 (void)gain_random_mutation(0);
202 level_mutation = FALSE;
206 * Ê󽷤ǥì¥Ù¥ë¤¬¾å¤ë¤ÈºÆµ¢Åª¤Ë check_experience() ¤¬
207 * ¸Æ¤Ð¤ì¤ë¤Î¤Ç½çÈÖ¤òºÇ¸å¤Ë¤¹¤ë¡£
211 gain_level_reward(0);
212 level_reward = FALSE;
215 /* Update some stuff */
216 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
218 /* Redraw some stuff */
219 p_ptr->redraw |= (PR_LEV | PR_TITLE);
222 p_ptr->window |= (PW_PLAYER | PW_SPELL);
228 /* Load an autopick preference file */
229 if (old_lev != p_ptr->lev) autopick_load_pref(FALSE);
234 * @brief ¥â¥ó¥¹¥¿¡¼¤òÅݤ·¤¿ºÝ¤ÎºâÊõsval¤òÊÖ¤¹
235 * @param r_idx Åݤ·¤¿¥â¥ó¥¹¥¿¡¼¤Î¼ï²ID
238 * Hack -- Return the "automatic coin type" of a monster race
239 * Used to allocate proper treasure when "Creeping coins" die
240 * XXX XXX XXX Note the use of actual "monster names"
242 static int get_coin_type(int r_idx)
244 /* Analyze monsters */
247 case MON_COPPER_COINS: return 2;
248 case MON_SILVER_COINS: return 5;
249 case MON_GOLD_COINS: return 10;
250 case MON_MITHRIL_COINS:
251 case MON_MITHRIL_GOLEM: return 16;
252 case MON_ADAMANT_COINS: return 17;
261 * @brief ¥ª¥Ö¥¸¥§¥¯¥È¤¬¥¯¥í¡¼¥¯¤«¤É¤¦¤«¤òȽÄꤹ¤ë /
262 * Hack -- determine if a template is Cloak
263 * @param k_idx ȽÄꤷ¤¿¤¤¥ª¥Ö¥¸¥§¥¯¥È¤Î¥Ù¡¼¥¹¥¢¥¤¥Æ¥àID
264 * @return ¥ª¥Ö¥¸¥§¥¯¥È¤¬¥¯¥í¡¼¥¯¤Ê¤é¤ÐTRUE¤òÊÖ¤¹
266 static bool kind_is_cloak(int k_idx)
268 object_kind *k_ptr = &k_info[k_idx];
270 /* Analyze the item type */
271 if (k_ptr->tval == TV_CLOAK)
276 /* Assume not good */
282 * @brief ¥ª¥Ö¥¸¥§¥¯¥È¤¬´È¾õÉð´ï¤«¤É¤¦¤«¤òȽÄꤹ¤ë /
283 * Hack -- determine if a template is Polearm
284 * @param k_idx ȽÄꤷ¤¿¤¤¥ª¥Ö¥¸¥§¥¯¥È¤Î¥Ù¡¼¥¹¥¢¥¤¥Æ¥àID
285 * @return ¥ª¥Ö¥¸¥§¥¯¥È¤¬´È¾õÉð´ï¤Ê¤é¤ÐTRUE¤òÊÖ¤¹
287 static bool kind_is_polearm(int k_idx)
289 object_kind *k_ptr = &k_info[k_idx];
291 /* Analyze the item type */
292 if (k_ptr->tval == TV_POLEARM)
297 /* Assume not good */
303 * @brief ¥ª¥Ö¥¸¥§¥¯¥È¤¬·õ¤«¤É¤¦¤«¤òȽÄꤹ¤ë /
304 * Hack -- determine if a template is Sword
305 * @param k_idx ȽÄꤷ¤¿¤¤¥ª¥Ö¥¸¥§¥¯¥È¤Î¥Ù¡¼¥¹¥¢¥¤¥Æ¥àID
306 * @return ¥ª¥Ö¥¸¥§¥¯¥È¤¬·õ¤Ê¤é¤ÐTRUE¤òÊÖ¤¹
308 static bool kind_is_sword(int k_idx)
310 object_kind *k_ptr = &k_info[k_idx];
312 /* Analyze the item type */
313 if ((k_ptr->tval == TV_SWORD) && (k_ptr->sval > 2))
318 /* Assume not good */
324 * @brief ¥ª¥Ö¥¸¥§¥¯¥È¤¬ËâË¡½ñ¤«¤É¤¦¤«¤òȽÄꤹ¤ë /
325 * Hack -- determine if a template is Book
326 * @param k_idx ȽÄꤷ¤¿¤¤¥ª¥Ö¥¸¥§¥¯¥È¤Î¥Ù¡¼¥¹¥¢¥¤¥Æ¥àID
327 * @return ¥ª¥Ö¥¸¥§¥¯¥È¤¬ËâË¡½ñ¤Ê¤é¤ÐTRUE¤òÊÖ¤¹
329 static bool kind_is_book(int k_idx)
331 object_kind *k_ptr = &k_info[k_idx];
333 /* Analyze the item type */
334 if ((k_ptr->tval >= TV_LIFE_BOOK) && (k_ptr->tval <= TV_CRUSADE_BOOK))
339 /* Assume not good */
345 * @brief ¥ª¥Ö¥¸¥§¥¯¥È¤¬¥Ù¡¼¥¹¥¢¥¤¥Æ¥à»þÅÀ¤ÇGOOD¤«¤É¤¦¤«¤òȽÄꤹ¤ë /
346 * Hack -- determine if a template is Good book
347 * @param k_idx ȽÄꤷ¤¿¤¤¥ª¥Ö¥¸¥§¥¯¥È¤Î¥Ù¡¼¥¹¥¢¥¤¥Æ¥àID
348 * @return ¥ª¥Ö¥¸¥§¥¯¥È¤¬¥Ù¡¼¥¹¥¢¥¤¥Æ¥à»þÅÀ¤ÇGOOD¤Ê¥¢¥¤¥Æ¥à¤Ê¤é¤ÐTRUE¤òÊÖ¤¹
350 static bool kind_is_good_book(int k_idx)
352 object_kind *k_ptr = &k_info[k_idx];
354 /* Analyze the item type */
355 if ((k_ptr->tval >= TV_LIFE_BOOK) && (k_ptr->tval <= TV_CRUSADE_BOOK) && (k_ptr->tval != TV_ARCANE_BOOK) && (k_ptr->sval > 1))
360 /* Assume not good */
366 * @brief ¥ª¥Ö¥¸¥§¥¯¥È¤¬³»¤«¤É¤¦¤«¤òȽÄꤹ¤ë /
367 * Hack -- determine if a template is Armor
368 * @param k_idx ȽÄꤷ¤¿¤¤¥ª¥Ö¥¸¥§¥¯¥È¤Î¥Ù¡¼¥¹¥¢¥¤¥Æ¥àID
369 * @return ¥ª¥Ö¥¸¥§¥¯¥È¤¬³»¤Ê¤é¤ÐTRUE¤òÊÖ¤¹
371 static bool kind_is_armor(int k_idx)
373 object_kind *k_ptr = &k_info[k_idx];
375 /* Analyze the item type */
376 if (k_ptr->tval == TV_HARD_ARMOR)
381 /* Assume not good */
387 * @brief ¥ª¥Ö¥¸¥§¥¯¥È¤¬ÂÇ·âÉð´ï¤«¤É¤¦¤«¤òȽÄꤹ¤ë /
388 * Hack -- determine if a template is hafted weapon
389 * @param k_idx ȽÄꤷ¤¿¤¤¥ª¥Ö¥¸¥§¥¯¥È¤Î¥Ù¡¼¥¹¥¢¥¤¥Æ¥àID
390 * @return ¥ª¥Ö¥¸¥§¥¯¥È¤¬ÂÇ·âÉð´ï¤Ê¤é¤ÐTRUE¤òÊÖ¤¹
392 static bool kind_is_hafted(int k_idx)
394 object_kind *k_ptr = &k_info[k_idx];
396 /* Analyze the item type */
397 if (k_ptr->tval == TV_HAFTED)
402 /* Assume not good */
407 * @brief ¥¯¥¨¥¹¥È¤òãÀ®¾õÂ֤ˤ¹¤ë /
408 * @param quest_num ãÀ®¾õÂ֤ˤ·¤¿¤¤¥¯¥¨¥¹¥È¤ÎID
411 void complete_quest(int quest_num)
413 quest_type* const q_ptr = &quest[quest_num];
417 case QUEST_TYPE_RANDOM:
418 if (record_rand_quest) do_cmd_write_nikki(NIKKI_RAND_QUEST_C, quest_num, NULL);
421 if (record_fix_quest) do_cmd_write_nikki(NIKKI_FIX_QUEST_C, quest_num, NULL);
425 q_ptr->status = QUEST_STATUS_COMPLETED;
426 q_ptr->complev = (byte)p_ptr->lev;
428 q_ptr->comptime = playtime;
430 if (!(q_ptr->flags & QUEST_FLAG_SILENT))
432 msg_print(_("¥¯¥¨¥¹¥È¤òãÀ®¤·¤¿¡ª", "You just completed your quest!"));
438 * @brief ¸½ºß¥Õ¥í¥¢¤Ë»Ä¤Ã¤Æ¤¤¤ëŨ¥â¥ó¥¹¥¿¡¼¤Î¿ô¤òÊÖ¤¹ /
439 * @return ¸½ºß¤ÎŨ¥â¥ó¥¹¥¿¡¼¤Î¿ô
441 static int count_all_hostile_monsters(void)
446 for (x = 0; x < cur_wid; ++ x)
448 for (y = 0; y < cur_hgt; ++ y)
450 int m_idx = cave[y][x].m_idx;
452 if (m_idx > 0 && is_hostile(&m_list[m_idx]))
463 * @brief ÆÃÄê¤ÎŨ¤òÅݤ·¤¿ºÝ¤Ë¥¯¥¨¥¹¥ÈãÀ®½èÍý /
464 * Check for "Quest" completion when a quest monster is killed or charmed.
465 * @param m_ptr ·âÇˤ·¤¿¥â¥ó¥¹¥¿¡¼¤Î¹½Â¤Âλ²¾È¥Ý¥¤¥ó¥¿
468 void check_quest_completion(monster_type *m_ptr)
474 bool create_stairs = FALSE;
480 /* Get the location */
485 quest_num = p_ptr->inside_quest;
487 /* Search for an active quest on this dungeon level */
492 for (i = max_quests - 1; i > 0; i--)
494 quest_type* const q_ptr = &quest[i];
496 /* Quest is not active */
497 if (q_ptr->status != QUEST_STATUS_TAKEN)
500 /* Quest is not a dungeon quest */
501 if (q_ptr->flags & QUEST_FLAG_PRESET)
504 /* Quest is not on this level */
505 if ((q_ptr->level != dun_level) &&
506 (q_ptr->type != QUEST_TYPE_KILL_ANY_LEVEL))
509 /* Not a "kill monster" quest */
510 if ((q_ptr->type == QUEST_TYPE_FIND_ARTIFACT) ||
511 (q_ptr->type == QUEST_TYPE_FIND_EXIT))
514 /* Interesting quest */
515 if ((q_ptr->type == QUEST_TYPE_KILL_NUMBER) ||
516 (q_ptr->type == QUEST_TYPE_TOWER) ||
517 (q_ptr->type == QUEST_TYPE_KILL_ALL))
520 /* Interesting quest */
521 if (((q_ptr->type == QUEST_TYPE_KILL_LEVEL) ||
522 (q_ptr->type == QUEST_TYPE_KILL_ANY_LEVEL) ||
523 (q_ptr->type == QUEST_TYPE_RANDOM)) &&
524 (q_ptr->r_idx == m_ptr->r_idx))
531 /* Handle the current quest */
532 if (quest_num && (quest[quest_num].status == QUEST_STATUS_TAKEN))
535 quest_type* const q_ptr = &quest[quest_num];
539 case QUEST_TYPE_KILL_NUMBER:
543 if (q_ptr->cur_num >= q_ptr->num_mon)
545 complete_quest(quest_num);
551 case QUEST_TYPE_KILL_ALL:
553 if (!is_hostile(m_ptr)) break;
555 if (count_all_hostile_monsters() == 1)
557 if (q_ptr->flags & QUEST_FLAG_SILENT)
559 q_ptr->status = QUEST_STATUS_FINISHED;
563 complete_quest(quest_num);
568 case QUEST_TYPE_KILL_LEVEL:
569 case QUEST_TYPE_RANDOM:
571 /* Only count valid monsters */
572 if (q_ptr->r_idx != m_ptr->r_idx)
577 if (q_ptr->cur_num >= q_ptr->max_num)
579 complete_quest(quest_num);
581 if (!(q_ptr->flags & QUEST_FLAG_PRESET))
583 create_stairs = TRUE;
584 p_ptr->inside_quest = 0;
587 /* Finish the two main quests without rewarding */
588 if ((quest_num == QUEST_OBERON) || (quest_num == QUEST_SERPENT))
590 q_ptr->status = QUEST_STATUS_FINISHED;
593 if (q_ptr->type == QUEST_TYPE_RANDOM)
596 q_ptr->status = QUEST_STATUS_FINISHED;
601 case QUEST_TYPE_KILL_ANY_LEVEL:
604 if (q_ptr->cur_num >= q_ptr->max_num)
606 complete_quest(quest_num);
611 case QUEST_TYPE_TOWER:
613 if (!is_hostile(m_ptr)) break;
615 if (count_all_hostile_monsters() == 1)
617 q_ptr->status = QUEST_STATUS_STAGE_COMPLETED;
619 if((quest[QUEST_TOWER1].status == QUEST_STATUS_STAGE_COMPLETED) &&
620 (quest[QUEST_TOWER2].status == QUEST_STATUS_STAGE_COMPLETED) &&
621 (quest[QUEST_TOWER3].status == QUEST_STATUS_STAGE_COMPLETED))
624 complete_quest(QUEST_TOWER1);
632 /* Create a magical staircase */
638 while (cave_perma_bold(y, x) || cave[y][x].o_idx || (cave[y][x].info & CAVE_OBJECT) )
640 /* Pick a location */
641 scatter(&ny, &nx, y, x, 1, 0);
647 /* Explain the staircase */
649 msg_print("ËâË¡¤Î³¬Ãʤ¬¸½¤ì¤¿...");
651 msg_print("A magical staircase appears...");
655 /* Create stairs down */
656 cave_set_feat(y, x, feat_down_stair);
658 /* Remember to update everything */
659 p_ptr->update |= (PU_FLOW);
669 for (i = 0; i < (dun_level / 15)+1; i++)
671 /* Get local object */
674 /* Wipe the object */
677 /* Make a great object */
678 make_object(q_ptr, AM_GOOD | AM_GREAT);
680 /* Drop it in the dungeon */
681 (void)drop_near(q_ptr, -1, y, x);
687 * @brief ÆÃÄê¤Î¥¢¡¼¥Æ¥£¥Õ¥¡¥¯¥È¤òÆþ¼ê¤·¤¿ºÝ¤Î¥¯¥¨¥¹¥ÈãÀ®½èÍý /
688 * Check for "Quest" completion when a quest monster is killed or charmed.
689 * @param o_ptr Æþ¼ê¤·¤¿¥ª¥Ö¥¸¥§¥¯¥È¤Î¹½Â¤Âλ²¾È¥Ý¥¤¥ó¥¿
692 void check_find_art_quest_completion(object_type *o_ptr)
695 /* Check if completed a quest */
696 for (i = 0; i < max_quests; i++)
698 if ((quest[i].type == QUEST_TYPE_FIND_ARTIFACT) &&
699 (quest[i].status == QUEST_STATUS_TAKEN) &&
700 (quest[i].k_idx == o_ptr->name1))
709 * @brief ¥â¥ó¥¹¥¿¡¼¤ò·âÇˤ·¤¿ºÝ¤Î½Ò¸ì¥á¥Ã¥»¡¼¥¸¤òÊÖ¤¹ /
710 * Return monster death string
711 * @param r_ptr ·âÇˤµ¤ì¤¿¥â¥ó¥¹¥¿¡¼¤Î¼ï²¾ðÊó¤ò»ý¤Ä¹½Â¤ÂΤλ²¾È¥Ý¥¤¥ó¥¿
712 * @return ·âÇˤµ¤ì¤¿¥â¥ó¥¹¥¿¡¼¤Î½Ò¸ì
714 cptr extract_note_dies(monster_race *r_ptr)
716 /* Some monsters get "destroyed" */
717 if (!monster_living(r_ptr))
721 for (i = 0; i < 4; i++)
723 if (r_ptr->blow[i].method == RBM_EXPLODE)
726 return "¤ÏÇúȯ¤·¤ÆÊ´¡¹¤Ë¤Ê¤Ã¤¿¡£";
728 return " explodes into tiny shreds.";
736 return " is destroyed.";
740 /* Assume a default death */
750 * @brief ¥â¥ó¥¹¥¿¡¼¤¬»àË´¤·¤¿»þ¤Î½èÍý /
751 * Handle the "death" of a monster.
752 * @param m_idx »àË´¤·¤¿¥â¥ó¥¹¥¿¡¼¤ÎID
753 * @param drop_item TRUE¤Ê¤é¤Ð¥â¥ó¥¹¥¿¡¼¤Î¥É¥í¥Ã¥×½èÍý¤ò¹Ô¤¦
754 * @return ·âÇˤµ¤ì¤¿¥â¥ó¥¹¥¿¡¼¤Î½Ò¸ì
757 * Disperse treasures centered at the monster location based on the
758 * various flags contained in the monster flags fields.
759 * Check for "Quest" completion when a quest monster is killed.
760 * Note that only the player can induce "monster_death()" on Uniques.
761 * Thus (for now) all Quest monsters should be Uniques.
762 * Note that monsters can now carry objects, and when a monster dies,
763 * it drops all of its objects, which may disappear in crowded rooms.
766 void monster_death(int m_idx, bool drop_item)
775 monster_type *m_ptr = &m_list[m_idx];
777 monster_race *r_ptr = &r_info[m_ptr->r_idx];
779 bool visible = ((m_ptr->ml && !p_ptr->image) || (r_ptr->flags1 & RF1_UNIQUE));
783 bool do_gold = (!(r_ptr->flags1 & RF1_ONLY_ITEM));
784 bool do_item = (!(r_ptr->flags1 & RF1_ONLY_GOLD));
785 bool cloned = (m_ptr->smart & SM_CLONED) ? TRUE : FALSE;
786 int force_coin = get_coin_type(m_ptr->r_idx);
791 bool drop_chosen_item = drop_item && !cloned && !p_ptr->inside_arena
792 && !p_ptr->inside_battle && !is_pet(m_ptr);
794 /* The caster is dead? */
795 if (world_monster && world_monster == m_idx) world_monster = 0;
797 /* Notice changes in view */
798 if (r_ptr->flags7 & (RF7_LITE_MASK | RF7_DARK_MASK))
800 /* Update some things */
801 p_ptr->update |= (PU_MON_LITE);
804 /* Get the location */
808 if (record_named_pet && is_pet(m_ptr) && m_ptr->nickname)
812 monster_desc(m_name, m_ptr, MD_INDEF_VISIBLE);
813 do_cmd_write_nikki(NIKKI_NAMED_PET, 3, m_name);
816 /* Let monsters explode! */
817 for (i = 0; i < 4; i++)
819 if (r_ptr->blow[i].method == RBM_EXPLODE)
821 int flg = PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL;
822 int typ = mbe_info[r_ptr->blow[i].effect].explode_type;
823 int d_dice = r_ptr->blow[i].d_dice;
824 int d_side = r_ptr->blow[i].d_side;
825 int damage = damroll(d_dice, d_side);
827 project(m_idx, 3, y, x, damage, typ, flg, -1);
832 if (m_ptr->mflag2 & MFLAG2_CHAMELEON)
834 choose_new_monster(m_idx, TRUE, MON_CHAMELEON);
835 r_ptr = &r_info[m_ptr->r_idx];
838 /* Check for quest completion */
839 check_quest_completion(m_ptr);
841 /* Handle the possibility of player vanquishing arena combatant -KMW- */
842 if (p_ptr->inside_arena && !is_pet(m_ptr))
844 p_ptr->exit_bldg = TRUE;
846 if (p_ptr->arena_number > MAX_ARENA_MONS)
849 msg_print("ÁÇÀ²¤é¤·¤¤¡ª·¯¤³¤½¿¿¤Î¾¡Íø¼Ô¤À¡£");
851 msg_print("You are a Genuine Champion!");
857 msg_print("¾¡Íø¡ª¥Á¥ã¥ó¥Ô¥ª¥ó¤Ø¤ÎÆ»¤ò¿Ê¤ó¤Ç¤¤¤ë¡£");
859 msg_print("Victorious! You're on your way to becoming Champion.");
863 if (arena_info[p_ptr->arena_number].tval)
865 /* Get local object */
868 /* Prepare to make a prize */
869 object_prep(q_ptr, lookup_kind(arena_info[p_ptr->arena_number].tval, arena_info[p_ptr->arena_number].sval));
871 apply_magic(q_ptr, object_level, AM_NO_FIXED_ART);
873 /* Drop it in the dungeon */
874 (void)drop_near(q_ptr, -1, y, x);
877 if (p_ptr->arena_number > MAX_ARENA_MONS) p_ptr->arena_number++;
878 p_ptr->arena_number++;
883 /* Extract monster name */
884 monster_desc(m_name, m_ptr, MD_IGNORE_HALLU | MD_ASSUME_VISIBLE | MD_INDEF_VISIBLE);
886 do_cmd_write_nikki(NIKKI_ARENA, p_ptr->arena_number, m_name);
890 if (m_idx == p_ptr->riding)
892 if (rakuba(-1, FALSE))
895 msg_print("ÃÏÌ̤ËÍî¤È¤µ¤ì¤¿¡£");
897 msg_print("You have fallen from your riding pet.");
902 /* Drop a dead corpse? */
903 if (one_in_(r_ptr->flags1 & RF1_UNIQUE ? 1 : 4) &&
904 (r_ptr->flags9 & (RF9_DROP_CORPSE | RF9_DROP_SKELETON)) &&
905 !(p_ptr->inside_arena || p_ptr->inside_battle || cloned || ((m_ptr->r_idx == today_mon) && is_pet(m_ptr))))
907 /* Assume skeleton */
911 * We cannot drop a skeleton? Note, if we are in this check,
912 * we *know* we can drop at least a corpse or a skeleton
914 if (!(r_ptr->flags9 & RF9_DROP_SKELETON))
916 else if ((r_ptr->flags9 & RF9_DROP_CORPSE) && (r_ptr->flags1 & RF1_UNIQUE))
919 /* Else, a corpse is more likely unless we did a "lot" of damage */
920 else if (r_ptr->flags9 & RF9_DROP_CORPSE)
922 /* Lots of damage in one blow */
923 if ((0 - ((m_ptr->maxhp) / 4)) > m_ptr->hp)
925 if (one_in_(5)) corpse = TRUE;
929 if (!one_in_(5)) corpse = TRUE;
933 /* Get local object */
936 /* Prepare to make an object */
937 object_prep(q_ptr, lookup_kind(TV_CORPSE, (corpse ? SV_CORPSE : SV_SKELETON)));
939 apply_magic(q_ptr, object_level, AM_NO_FIXED_ART);
941 q_ptr->pval = m_ptr->r_idx;
943 /* Drop it in the dungeon */
944 (void)drop_near(q_ptr, -1, y, x);
947 /* Drop objects being carried */
948 monster_drop_carried_objects(m_ptr);
950 if (r_ptr->flags1 & RF1_DROP_GOOD) mo_mode |= AM_GOOD;
951 if (r_ptr->flags1 & RF1_DROP_GREAT) mo_mode |= AM_GREAT;
953 switch (m_ptr->r_idx)
955 case MON_PINK_HORROR:
956 /* Pink horrors are replaced with 2 Blue horrors */
957 if (!(p_ptr->inside_arena || p_ptr->inside_battle))
961 for (i = 0; i < 2; i++)
964 bool pet = is_pet(m_ptr);
967 if (pet) mode |= PM_FORCE_PET;
969 if (summon_specific((pet ? -1 : m_idx), wy, wx, 100, SUMMON_BLUE_HORROR, mode))
971 if (player_can_see_bold(wy, wx))
978 msg_print("¥Ô¥ó¥¯¡¦¥Û¥é¡¼¤ÏʬÎö¤·¤¿¡ª");
980 msg_print("The Pink horror divides!");
985 case MON_BLOODLETTER:
986 /* Bloodletters of Khorne may drop a blade of chaos */
987 if (drop_chosen_item && (randint1(100) < 15))
989 /* Get local object */
992 /* Prepare to make a Blade of Chaos */
993 object_prep(q_ptr, lookup_kind(TV_SWORD, SV_BLADE_OF_CHAOS));
995 apply_magic(q_ptr, object_level, AM_NO_FIXED_ART | mo_mode);
997 /* Drop it in the dungeon */
998 (void)drop_near(q_ptr, -1, y, x);
1003 if (drop_chosen_item && (dun_level > 9))
1005 /* Get local object */
1008 /* Wipe the object */
1011 /* Activate restriction */
1012 if ((dun_level > 49) && one_in_(5))
1013 get_obj_num_hook = kind_is_good_book;
1015 get_obj_num_hook = kind_is_book;
1018 make_object(q_ptr, mo_mode);
1020 /* Drop it in the dungeon */
1021 (void)drop_near(q_ptr, -1, y, x);
1027 * Mega^3-hack: killing a 'Warrior of the Dawn' is likely to
1028 * spawn another in the fallen one's place!
1030 if (!p_ptr->inside_arena && !p_ptr->inside_battle)
1036 bool pet = is_pet(m_ptr);
1040 scatter(&wy, &wx, y, x, 20, 0);
1042 while (!(in_bounds(wy, wx) && cave_empty_bold2(wy, wx)) && --attempts);
1047 if (pet) mode |= PM_FORCE_PET;
1049 if (summon_specific((pet ? -1 : m_idx), wy, wx, 100, SUMMON_DAWN, mode))
1051 if (player_can_see_bold(wy, wx))
1053 msg_print("¿·¤¿¤ÊÀï»Î¤¬¸½¤ì¤¿¡ª");
1055 msg_print("A new warrior steps forth!");
1065 /* One more ultra-hack: An Unmaker goes out with a big bang! */
1067 int flg = PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL;
1068 (void)project(m_idx, 6, y, x, 100, GF_CHAOS, flg, -1);
1072 case MON_UNICORN_ORD:
1075 /* Reward for "lazy" player */
1076 if (p_ptr->pseikaku == SEIKAKU_NAMAKE)
1079 artifact_type *a_ptr = NULL;
1081 if (!drop_chosen_item) break;
1085 switch (randint0(3))
1088 a_idx = ART_NAMAKE_HAMMER;
1091 a_idx = ART_NAMAKE_BOW;
1094 a_idx = ART_NAMAKE_ARMOR;
1098 a_ptr = &a_info[a_idx];
1100 while (a_ptr->cur_num);
1102 /* Create the artifact */
1103 if (create_named_art(a_idx, y, x))
1107 /* Hack -- Memorize location of artifact in saved floors */
1108 if (character_dungeon) a_ptr->floor_id = p_ptr->floor_id;
1110 else if (!preserve_mode) a_ptr->cur_num = 1;
1115 if (!drop_chosen_item) break;
1117 /* Get local object */
1120 /* Mega-Hack -- Prepare to make "Grond" */
1121 object_prep(q_ptr, lookup_kind(TV_HAFTED, SV_GROND));
1123 /* Mega-Hack -- Mark this item as "Grond" */
1124 q_ptr->name1 = ART_GROND;
1126 /* Mega-Hack -- Actually create "Grond" */
1127 apply_magic(q_ptr, -1, AM_GOOD | AM_GREAT);
1129 /* Drop it in the dungeon */
1130 (void)drop_near(q_ptr, -1, y, x);
1132 /* Get local object */
1135 /* Mega-Hack -- Prepare to make "Chaos" */
1136 object_prep(q_ptr, lookup_kind(TV_CROWN, SV_CHAOS));
1138 /* Mega-Hack -- Mark this item as "Chaos" */
1139 q_ptr->name1 = ART_CHAOS;
1141 /* Mega-Hack -- Actually create "Chaos" */
1142 apply_magic(q_ptr, -1, AM_GOOD | AM_GREAT);
1144 /* Drop it in the dungeon */
1145 (void)drop_near(q_ptr, -1, y, x);
1148 case MON_B_DEATH_SWORD:
1149 if (drop_chosen_item)
1151 /* Get local object */
1154 /* Prepare to make a broken sword */
1155 object_prep(q_ptr, lookup_kind(TV_SWORD, randint1(2)));
1157 /* Drop it in the dungeon */
1158 (void)drop_near(q_ptr, -1, y, x);
1164 if (drop_chosen_item && ((m_ptr->r_idx == MON_A_GOLD) ||
1165 ((m_ptr->r_idx == MON_A_SILVER) && (r_ptr->r_akills % 5 == 0))))
1167 /* Get local object */
1170 /* Prepare to make a Can of Toys */
1171 object_prep(q_ptr, lookup_kind(TV_CHEST, SV_CHEST_KANDUME));
1173 apply_magic(q_ptr, object_level, AM_NO_FIXED_ART);
1175 /* Drop it in the dungeon */
1176 (void)drop_near(q_ptr, -1, y, x);
1182 int flg = PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL;
1183 (void)project(m_idx, 3, y, x, damroll(20, 10), GF_FIRE, flg, -1);
1188 if (!drop_chosen_item) break;
1190 switch (r_ptr->d_char)
1195 /* Get local object */
1198 /* Wipe the object */
1201 /* Activate restriction */
1202 get_obj_num_hook = kind_is_cloak;
1205 make_object(q_ptr, mo_mode);
1207 /* Drop it in the dungeon */
1208 (void)drop_near(q_ptr, -1, y, x);
1215 /* Get local object */
1218 /* Wipe the object */
1221 /* Activate restriction */
1222 get_obj_num_hook = kind_is_polearm;
1224 /* Make a poleweapon */
1225 make_object(q_ptr, mo_mode);
1227 /* Drop it in the dungeon */
1228 (void)drop_near(q_ptr, -1, y, x);
1235 /* Get local object */
1238 /* Wipe the object */
1241 /* Activate restriction */
1242 get_obj_num_hook = kind_is_armor;
1244 /* Make a hard armor */
1245 make_object(q_ptr, mo_mode);
1247 /* Drop it in the dungeon */
1248 (void)drop_near(q_ptr, -1, y, x);
1255 /* Get local object */
1258 /* Wipe the object */
1261 /* Activate restriction */
1262 get_obj_num_hook = kind_is_hafted;
1264 /* Make a hafted weapon */
1265 make_object(q_ptr, mo_mode);
1267 /* Drop it in the dungeon */
1268 (void)drop_near(q_ptr, -1, y, x);
1273 if (m_ptr->r_idx != MON_STORMBRINGER)
1275 /* Get local object */
1278 /* Wipe the object */
1281 /* Activate restriction */
1282 get_obj_num_hook = kind_is_sword;
1285 make_object(q_ptr, mo_mode);
1287 /* Drop it in the dungeon */
1288 (void)drop_near(q_ptr, -1, y, x);
1295 /* Mega-Hack -- drop fixed items */
1296 if (drop_chosen_item)
1301 switch (m_ptr->r_idx)
1321 case MON_STORMBRINGER:
1322 a_idx = ART_STORMBRINGER;
1327 a_idx = ART_CRIMSON;
1337 a_idx = ART_KUSANAGI;
1367 a_idx = ART_WEREWINDLE;
1375 a_idx = ART_GRAYSWANDIR;
1388 a_idx = ART_TWILIGHT;
1393 a_idx = ART_ORB_OF_FATE;
1399 a_idx = ART_ELENDIL;
1414 a_idx = ART_DESTINY;
1419 a_idx = ART_ZANTETSU;
1434 a_idx = ART_WINBLOWS;
1438 case MON_LUNGORTHIN:
1443 case MON_JACK_SHADOWS:
1449 a_idx = ART_STONEMASK;
1454 a_idx = ART_SOULCRUSH;
1459 a_idx = ART_EXCALIBUR_J;
1464 a_idx = ART_SHUTEN_DOJI;
1469 a_idx = ART_GOTHMOG;
1478 case MON_ROBIN_HOOD:
1479 a_idx = ART_ROBIN_HOOD;
1484 a_idx = ART_NANACHO;
1490 if ((a_idx > 0) && ((randint0(100) < chance) || p_ptr->wizard))
1492 artifact_type *a_ptr = &a_info[a_idx];
1494 if (!a_ptr->cur_num)
1496 /* Create the artifact */
1497 if (create_named_art(a_idx, y, x))
1501 /* Hack -- Memorize location of artifact in saved floors */
1502 if (character_dungeon) a_ptr->floor_id = p_ptr->floor_id;
1504 else if (!preserve_mode) a_ptr->cur_num = 1;
1508 if ((r_ptr->flags7 & RF7_GUARDIAN) && (d_info[dungeon_type].final_guardian == m_ptr->r_idx))
1510 int k_idx = d_info[dungeon_type].final_object ? d_info[dungeon_type].final_object
1511 : lookup_kind(TV_SCROLL, SV_SCROLL_ACQUIREMENT);
1513 if (d_info[dungeon_type].final_artifact)
1515 int a_idx = d_info[dungeon_type].final_artifact;
1516 artifact_type *a_ptr = &a_info[a_idx];
1518 if (!a_ptr->cur_num)
1520 /* Create the artifact */
1521 if (create_named_art(a_idx, y, x))
1525 /* Hack -- Memorize location of artifact in saved floors */
1526 if (character_dungeon) a_ptr->floor_id = p_ptr->floor_id;
1528 else if (!preserve_mode) a_ptr->cur_num = 1;
1530 /* Prevent rewarding both artifact and "default" object */
1531 if (!d_info[dungeon_type].final_object) k_idx = 0;
1537 /* Get local object */
1540 /* Prepare to make a reward */
1541 object_prep(q_ptr, k_idx);
1543 apply_magic(q_ptr, object_level, AM_NO_FIXED_ART | AM_GOOD);
1545 /* Drop it in the dungeon */
1546 (void)drop_near(q_ptr, -1, y, x);
1549 msg_format("¤¢¤Ê¤¿¤Ï%s¤òÀ©ÇƤ·¤¿¡ª",d_name+d_info[dungeon_type].name);
1551 msg_format("You have conquered %s!",d_name+d_info[dungeon_type].name);
1556 /* Determine how much we can drop */
1557 if ((r_ptr->flags1 & RF1_DROP_60) && (randint0(100) < 60)) number++;
1558 if ((r_ptr->flags1 & RF1_DROP_90) && (randint0(100) < 90)) number++;
1559 if (r_ptr->flags1 & RF1_DROP_1D2) number += damroll(1, 2);
1560 if (r_ptr->flags1 & RF1_DROP_2D2) number += damroll(2, 2);
1561 if (r_ptr->flags1 & RF1_DROP_3D2) number += damroll(3, 2);
1562 if (r_ptr->flags1 & RF1_DROP_4D2) number += damroll(4, 2);
1564 if (cloned && !(r_ptr->flags1 & RF1_UNIQUE))
1565 number = 0; /* Clones drop no stuff unless Cloning Pits */
1567 if (is_pet(m_ptr) || p_ptr->inside_battle || p_ptr->inside_arena)
1568 number = 0; /* Pets drop no stuff */
1569 if (!drop_item && (r_ptr->d_char != '$')) number = 0;
1571 if((r_ptr->flags2 & (RF2_MULTIPLY)) && (r_ptr->r_akills > 1024))
1572 number = 0; /* Limit of Multiply monster drop */
1574 /* Hack -- handle creeping coins */
1575 coin_type = force_coin;
1577 /* Average dungeon and monster levels */
1578 object_level = (dun_level + r_ptr->level) / 2;
1580 /* Drop some objects */
1581 for (j = 0; j < number; j++)
1583 /* Get local object */
1586 /* Wipe the object */
1590 if (do_gold && (!do_item || (randint0(100) < 50)))
1592 /* Make some gold */
1593 if (!make_gold(q_ptr)) continue;
1602 /* Make an object */
1603 if (!make_object(q_ptr, mo_mode)) continue;
1609 /* Drop it in the dungeon */
1610 (void)drop_near(q_ptr, -1, y, x);
1613 /* Reset the object level */
1614 object_level = base_level;
1616 /* Reset "coin" type */
1620 /* Take note of any dropped treasure */
1621 if (visible && (dump_item || dump_gold))
1623 /* Take notes on treasure */
1624 lore_treasure(m_idx, dump_item, dump_gold);
1627 /* Only process "Quest Monsters" */
1628 if (!(r_ptr->flags1 & RF1_QUESTOR)) return;
1629 if (p_ptr->inside_battle) return;
1632 if ((m_ptr->r_idx == MON_SERPENT) && !cloned)
1635 p_ptr->total_winner = TRUE;
1637 /* Redraw the "title" */
1638 p_ptr->redraw |= (PR_TITLE);
1641 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, "¸«»ö¤ËÊѶòÈÚÅܤξ¡Íø¼Ô¤È¤Ê¤Ã¤¿¡ª");
1643 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, "become *WINNER* of Hengband finely!");
1646 if ((p_ptr->pclass == CLASS_CHAOS_WARRIOR) || (p_ptr->muta2 & MUT2_CHAOS_GIFT))
1649 msg_format("%s¤«¤é¤ÎÀ¼¤¬¶Á¤¤¤¿¡£", chaos_patrons[p_ptr->chaos_patron]);
1650 msg_print("¡Ø¤è¤¯¤ä¤Ã¤¿¡¢ÄêÌ¿¤Î¼Ô¤è¡ª¡Ù");
1652 msg_format("The voice of %s booms out:", chaos_patrons[p_ptr->chaos_patron]);
1653 msg_print("'Thou art donst well, mortal!'");
1657 /* Congratulations */
1659 msg_print("*** ¤ª¤á¤Ç¤È¤¦ ***");
1661 msg_print("*** CONGRATULATIONS ***");
1665 msg_print("¤¢¤Ê¤¿¤Ï¥²¡¼¥à¤ò¥³¥ó¥×¥ê¡¼¥È¤·¤Þ¤·¤¿¡£");
1667 msg_print("You have won the game!");
1671 msg_print("½àÈ÷¤¬À°¤Ã¤¿¤é°úÂà(¼«»¦¥³¥Þ¥ó¥É)¤·¤Æ¤â·ë¹½¤Ç¤¹¡£");
1673 msg_print("You may retire (commit suicide) when you are ready.");
1679 * @brief ¥â¥ó¥¹¥¿¡¼¤ËÍ¿¤¨¤¿¥À¥á¡¼¥¸¤Î½¤Àµ½èÍý /
1680 * Modify the physical damage done to the monster.
1681 * @param m_ptr ¥À¥á¡¼¥¸¤ò¼õ¤±¤ë¥â¥ó¥¹¥¿¡¼¤Î¹½Â¤Âλ²¾È¥Ý¥¤¥ó¥¿
1682 * @param dam ¥À¥á¡¼¥¸´ðËÜÃÍ
1683 * @param is_psy_spear ¹¶·â¼êÃʤ¬¸÷¤Î·õ¤Ê¤é¤ÐTRUE
1684 * @return ½¤Àµ¤ò¹Ô¤Ã¤¿·ë²Ì¤Î¥À¥á¡¼¥¸ÎÌ
1687 * (for example when it's invulnerable or shielded)
1688 * ToDo: Accept a damage-type to calculate the modified damage from
1689 * things like fire, frost, lightning, poison, ... attacks.
1690 * "type" is not yet used and should be 0.
1693 int mon_damage_mod(monster_type *m_ptr, int dam, bool is_psy_spear)
1695 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1697 if ((r_ptr->flagsr & RFR_RES_ALL) && dam > 0)
1700 if ((dam == 0) && one_in_(3)) dam = 1;
1703 if (MON_INVULNER(m_ptr))
1707 if (!p_ptr->blind && is_seen(m_ptr))
1710 msg_print("¥Ð¥ê¥¢¤òÀÚ¤êÎö¤¤¤¿¡ª");
1712 msg_print("The barrier is penetrated!");
1716 else if (!one_in_(PENETRATE_INVULNERABILITY))
1726 * @brief ¥â¥ó¥¹¥¿¡¼¤ËÍ¿¤¨¤¿¥À¥á¡¼¥¸¤ò¸µ¤Ë·Ð¸³Ãͤò²Ã»»¤¹¤ë /
1727 * Calculate experience point to be get
1728 * @param dam Í¿¤¨¤¿¥À¥á¡¼¥¸ÎÌ
1729 * @param m_ptr ¥À¥á¡¼¥¸¤òÍ¿¤¨¤¿¥â¥ó¥¹¥¿¡¼¤Î¹½Â¤Âλ²¾È¥Ý¥¤¥ó¥¿
1733 * Even the 64 bit operation is not big enough to avoid overflaw
1734 * unless we carefully choose orders of multiplication and division.
1735 * Get the coefficient first, and multiply (potentially huge) base
1736 * experience point of a monster later.
1739 static void get_exp_from_mon(int dam, monster_type *m_ptr)
1741 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1748 if (!m_ptr->r_idx) return;
1749 if (is_pet(m_ptr) || p_ptr->inside_battle) return;
1752 * - Ratio of monster's level to player's level effects
1753 * - Varying speed effects
1754 * - Get a fraction in proportion of damage point
1756 new_exp = r_ptr->level * SPEED_TO_ENERGY(m_ptr->mspeed) * dam;
1759 div_l = (p_ptr->max_plv+2) * SPEED_TO_ENERGY(r_ptr->speed);
1761 /* Use (average maxhp * 2) as a denominator */
1762 if (!(r_ptr->flags1 & RF1_FORCE_MAXHP))
1763 s64b_mul(&div_h, &div_l, 0, r_ptr->hdice * (ironman_nightmare ? 2 : 1) * (r_ptr->hside + 1));
1765 s64b_mul(&div_h, &div_l, 0, r_ptr->hdice * (ironman_nightmare ? 2 : 1) * r_ptr->hside * 2);
1767 /* Special penalty in the wilderness */
1768 if (!dun_level && (!(r_ptr->flags8 & RF8_WILD_ONLY) || !(r_ptr->flags1 & RF1_UNIQUE)))
1769 s64b_mul(&div_h, &div_l, 0, 5);
1771 /* Do division first to prevent overflaw */
1772 s64b_div(&new_exp, &new_exp_frac, div_h, div_l);
1774 /* Special penalty for mutiply-monster */
1775 if ((r_ptr->flags2 & RF2_MULTIPLY) || (m_ptr->r_idx == MON_DAWN))
1777 int monnum_penarty = r_ptr->r_akills / 400;
1778 if (monnum_penarty > 8) monnum_penarty = 8;
1780 while (monnum_penarty--)
1783 s64b_RSHIFT(new_exp, new_exp_frac, 2);
1787 /* Special penalty for rest_and_shoot exp scum */
1788 if ((m_ptr->dealt_damage > (u32b)m_ptr->max_maxhp) && (m_ptr->hp >= 0))
1790 int over_damage = m_ptr->dealt_damage / m_ptr->max_maxhp;
1791 if (over_damage > 32) over_damage = 32;
1793 while (over_damage--)
1796 s64b_mul(&new_exp, &new_exp_frac, 0, 9);
1797 s64b_div(&new_exp, &new_exp_frac, 0, 10);
1801 /* Finally multiply base experience point of the monster */
1802 s64b_mul(&new_exp, &new_exp_frac, 0, r_ptr->mexp);
1804 /* Gain experience */
1805 gain_exp_64(new_exp, new_exp_frac);
1810 * @brief ¥â¥ó¥¹¥¿¡¼¤ÎHP¤ò¥À¥á¡¼¥¸¤Ë±þ¤¸¤Æ¸º»»¤¹¤ë /
1811 * Decreases monsters hit points, handling monster death.
1812 * @param dam Í¿¤¨¤¿¥À¥á¡¼¥¸ÎÌ
1813 * @param m_idx ¥À¥á¡¼¥¸¤òÍ¿¤¨¤¿¥â¥ó¥¹¥¿¡¼¤ÎID
1814 * @param fear ¥À¥á¡¼¥¸¤Ë¤è¤Ã¤Æ¥â¥ó¥¹¥¿¡¼¤¬¶²¹²¾õÂ֤˴٤俤ʤé¤ÐTRUE¤òÊÖ¤¹
1815 * @param note ¥â¥ó¥¹¥¿¡¼¤¬Åݤµ¤ì¤¿ºÝ¤ÎÆÃÊ̤ʥá¥Ã¥»¡¼¥¸½Ò¸ì
1819 * We return TRUE if the monster has been killed (and deleted).
1820 * We announce monster death (using an optional "death message"
1821 * if given, and a otherwise a generic killed/destroyed message).
1822 * Only "physical attacks" can induce the "You have slain" message.
1823 * Missile and Spell attacks will induce the "dies" message, or
1824 * various "specialized" messages. Note that "You have destroyed"
1825 * and "is destroyed" are synonyms for "You have slain" and "dies".
1826 * Hack -- unseen monsters yield "You have killed it." message.
1827 * Added fear (DGK) and check whether to print fear messages -CWS
1828 * Made name, sex, and capitalization generic -BEN-
1829 * As always, the "ghost" processing is a total hack.
1830 * Hack -- we "delay" fear messages by passing around a "fear" flag.
1831 * XXX XXX XXX Consider decreasing monster experience over time, say,
1832 * by using "(m_exp * m_lev * (m_lev)) / (p_lev * (m_lev + n_killed))"
1833 * instead of simply "(m_exp * m_lev) / (p_lev)", to make the first
1834 * monster worth more than subsequent monsters. This would also need
1835 * to induce changes in the monster recall code.
1838 bool mon_take_hit(int m_idx, int dam, bool *fear, cptr note)
1840 monster_type *m_ptr = &m_list[m_idx];
1841 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1843 monster_type exp_mon;
1845 /* Innocent until proven otherwise */
1846 bool innocent = TRUE, thief = FALSE;
1851 (void)COPY(&exp_mon, m_ptr, monster_type);
1853 expdam = (m_ptr->hp > dam) ? dam : m_ptr->hp;
1855 get_exp_from_mon(expdam, &exp_mon);
1857 /* Genocided by chaos patron */
1858 if (!m_ptr->r_idx) m_idx = 0;
1860 /* Redraw (later) if needed */
1861 if (p_ptr->health_who == m_idx) p_ptr->redraw |= (PR_HEALTH);
1862 if (p_ptr->riding == m_idx) p_ptr->redraw |= (PR_UHEALTH);
1865 (void)set_monster_csleep(m_idx, 0);
1867 /* Hack - Cancel any special player stealth magics. -LM- */
1868 if (p_ptr->special_defense & NINJA_S_STEALTH)
1870 set_superstealth(FALSE);
1873 /* Genocided by chaos patron */
1874 if (!m_idx) return TRUE;
1876 /* Remember dealt_damage before this attack*/
1877 dealt_damage = m_ptr->dealt_damage;
1882 m_ptr->dealt_damage += dam;
1883 if(m_ptr->dealt_damage > (u32b)m_ptr->max_maxhp * 100) m_ptr->dealt_damage = m_ptr->max_maxhp * 100;
1886 msg_format( _("¹ç·×%d/%d¤Î¥À¥á¡¼¥¸¤òÍ¿¤¨¤¿¡£","You do %d (out of %d) damage."),
1887 m_ptr->dealt_damage, m_ptr->maxhp);
1890 /* It is dead now */
1895 if (r_info[m_ptr->r_idx].flags7 & RF7_TANUKI)
1897 /* You might have unmasked Tanuki first time */
1898 r_ptr = &r_info[m_ptr->r_idx];
1899 m_ptr->ap_r_idx = m_ptr->r_idx;
1900 if (r_ptr->r_sights < MAX_SHORT) r_ptr->r_sights++;
1903 if (m_ptr->mflag2 & MFLAG2_CHAMELEON)
1905 /* You might have unmasked Chameleon first time */
1906 r_ptr = real_r_ptr(m_ptr);
1907 if (r_ptr->r_sights < MAX_SHORT) r_ptr->r_sights++;
1910 if (!(m_ptr->smart & SM_CLONED))
1912 /* When the player kills a Unique, it stays dead */
1913 if (r_ptr->flags1 & RF1_UNIQUE)
1917 /* Mega-Hack -- Banor & Lupart */
1918 if ((m_ptr->r_idx == MON_BANOR) || (m_ptr->r_idx == MON_LUPART))
1920 r_info[MON_BANORLUPART].max_num = 0;
1921 r_info[MON_BANORLUPART].r_pkills++;
1922 r_info[MON_BANORLUPART].r_akills++;
1923 if (r_info[MON_BANORLUPART].r_tkills < MAX_SHORT) r_info[MON_BANORLUPART].r_tkills++;
1925 else if (m_ptr->r_idx == MON_BANORLUPART)
1927 r_info[MON_BANOR].max_num = 0;
1928 r_info[MON_BANOR].r_pkills++;
1929 r_info[MON_BANOR].r_akills++;
1930 if (r_info[MON_BANOR].r_tkills < MAX_SHORT) r_info[MON_BANOR].r_tkills++;
1931 r_info[MON_LUPART].max_num = 0;
1932 r_info[MON_LUPART].r_pkills++;
1933 r_info[MON_LUPART].r_akills++;
1934 if (r_info[MON_LUPART].r_tkills < MAX_SHORT) r_info[MON_LUPART].r_tkills++;
1938 /* When the player kills a Nazgul, it stays dead */
1939 else if (r_ptr->flags7 & RF7_NAZGUL) r_ptr->max_num--;
1942 /* Count all monsters killed */
1943 if (r_ptr->r_akills < MAX_SHORT) r_ptr->r_akills++;
1945 /* Recall even invisible uniques or winners */
1946 if ((m_ptr->ml && !p_ptr->image) || (r_ptr->flags1 & RF1_UNIQUE))
1948 /* Count kills this life */
1949 if ((m_ptr->mflag2 & MFLAG2_KAGE) && (r_info[MON_KAGE].r_pkills < MAX_SHORT)) r_info[MON_KAGE].r_pkills++;
1950 else if (r_ptr->r_pkills < MAX_SHORT) r_ptr->r_pkills++;
1952 /* Count kills in all lives */
1953 if ((m_ptr->mflag2 & MFLAG2_KAGE) && (r_info[MON_KAGE].r_tkills < MAX_SHORT)) r_info[MON_KAGE].r_tkills++;
1954 else if (r_ptr->r_tkills < MAX_SHORT) r_ptr->r_tkills++;
1956 /* Hack -- Auto-recall */
1957 monster_race_track(m_ptr->ap_r_idx);
1960 /* Extract monster name */
1961 monster_desc(m_name, m_ptr, MD_TRUE_NAME);
1963 /* Don't kill Amberites */
1964 if ((r_ptr->flags3 & RF3_AMBERITE) && one_in_(2))
1966 int curses = 1 + randint1(3);
1967 bool stop_ty = FALSE;
1971 msg_format("%^s¤Ï¶²¤í¤·¤¤·ì¤Î¼ö¤¤¤ò¤¢¤Ê¤¿¤Ë¤«¤±¤¿¡ª", m_name);
1973 msg_format("%^s puts a terrible blood curse on you!", m_name);
1976 curse_equipment(100, 50);
1980 stop_ty = activate_ty_curse(stop_ty, &count);
1985 if (r_ptr->flags2 & RF2_CAN_SPEAK)
1987 char line_got[1024];
1989 /* Dump a message */
1991 if (!get_rnd_line("mondeath_j.txt", m_ptr->r_idx, line_got))
1993 if (!get_rnd_line("mondeath.txt", m_ptr->r_idx, line_got))
1996 msg_format("%^s %s", m_name, line_got);
1999 if (m_ptr->r_idx == MON_SERPENT)
2001 /* Make screen dump */
2002 screen_dump = make_screen_dump();
2007 if (!(d_info[dungeon_type].flags1 & DF1_BEGINNER))
2009 if (!dun_level && !ambush_flag && !p_ptr->inside_arena)
2011 chg_virtue(V_VALOUR, -1);
2013 else if (r_ptr->level > dun_level)
2015 if (randint1(10) <= (r_ptr->level - dun_level))
2016 chg_virtue(V_VALOUR, 1);
2018 if (r_ptr->level > 60)
2020 chg_virtue(V_VALOUR, 1);
2022 if (r_ptr->level >= 2 * (p_ptr->lev+1))
2023 chg_virtue(V_VALOUR, 2);
2026 if (r_ptr->flags1 & RF1_UNIQUE)
2028 if (r_ptr->flags3 & (RF3_EVIL | RF3_GOOD)) chg_virtue(V_HARMONY, 2);
2030 if (r_ptr->flags3 & RF3_GOOD)
2032 chg_virtue(V_UNLIFE, 2);
2033 chg_virtue(V_VITALITY, -2);
2036 if (one_in_(3)) chg_virtue(V_INDIVIDUALISM, -1);
2039 if (m_ptr->r_idx == MON_BEGGAR || m_ptr->r_idx == MON_LEPER)
2041 chg_virtue(V_COMPASSION, -1);
2044 if ((r_ptr->flags3 & RF3_GOOD) &&
2045 ((r_ptr->level) / 10 + (3 * dun_level) >= randint1(100)))
2046 chg_virtue(V_UNLIFE, 1);
2048 if (r_ptr->d_char == 'A')
2050 if (r_ptr->flags1 & RF1_UNIQUE)
2051 chg_virtue(V_FAITH, -2);
2052 else if ((r_ptr->level) / 10 + (3 * dun_level) >= randint1(100))
2054 if (r_ptr->flags3 & RF3_GOOD) chg_virtue(V_FAITH, -1);
2055 else chg_virtue(V_FAITH, 1);
2058 else if (r_ptr->flags3 & RF3_DEMON)
2060 if (r_ptr->flags1 & RF1_UNIQUE)
2061 chg_virtue(V_FAITH, 2);
2062 else if ((r_ptr->level) / 10 + (3 * dun_level) >= randint1(100))
2063 chg_virtue(V_FAITH, 1);
2066 if ((r_ptr->flags3 & RF3_UNDEAD) && (r_ptr->flags1 & RF1_UNIQUE))
2067 chg_virtue(V_VITALITY, 2);
2069 if (r_ptr->r_deaths)
2071 if (r_ptr->flags1 & RF1_UNIQUE)
2073 chg_virtue(V_HONOUR, 10);
2075 else if ((r_ptr->level) / 10 + (2 * dun_level) >= randint1(100))
2077 chg_virtue(V_HONOUR, 1);
2080 if ((r_ptr->flags2 & RF2_MULTIPLY) && (r_ptr->r_akills > 1000) && one_in_(10))
2082 chg_virtue(V_VALOUR, -1);
2085 for (i = 0; i < 4; i++)
2087 if (r_ptr->blow[i].d_dice != 0) innocent = FALSE; /* Murderer! */
2089 if ((r_ptr->blow[i].effect == RBE_EAT_ITEM)
2090 || (r_ptr->blow[i].effect == RBE_EAT_GOLD))
2092 thief = TRUE; /* Thief! */
2095 /* The new law says it is illegal to live in the dungeon */
2096 if (r_ptr->level != 0) innocent = FALSE;
2100 if (r_ptr->flags1 & RF1_UNIQUE)
2101 chg_virtue(V_JUSTICE, 3);
2102 else if (1+((r_ptr->level) / 10 + (2 * dun_level))
2104 chg_virtue(V_JUSTICE, 1);
2108 chg_virtue (V_JUSTICE, -1);
2111 if ((r_ptr->flags3 & RF3_ANIMAL) && !(r_ptr->flags3 & RF3_EVIL) && !(r_ptr->flags4 & ~(RF4_NOMAGIC_MASK)) && !(r_ptr->flags5 & ~(RF5_NOMAGIC_MASK)) && !(r_ptr->flags6 & ~(RF6_NOMAGIC_MASK)))
2113 if (one_in_(4)) chg_virtue(V_NATURE, -1);
2116 if ((r_ptr->flags1 & RF1_UNIQUE) && record_destroy_uniq)
2120 sprintf(note_buf, "%s%s", r_name + r_ptr->name, (m_ptr->smart & SM_CLONED) ? "(¥¯¥í¡¼¥ó)" : "");
2122 sprintf(note_buf, "%s%s", r_name + r_ptr->name, (m_ptr->smart & SM_CLONED) ? "(Clone)" : "");
2124 do_cmd_write_nikki(NIKKI_UNIQUE, 0, note_buf);
2130 /* Death by Missile/Spell attack */
2133 msg_format("%^s%s", m_name, note);
2136 /* Death by physical attack -- invisible monster */
2137 else if (!m_ptr->ml)
2140 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
2141 msg_format("¤»¤Ã¤«¤¯¤À¤«¤é%s¤ò»¦¤·¤¿¡£", m_name);
2143 msg_format("%s¤ò»¦¤·¤¿¡£", m_name);
2145 msg_format("You have killed %s.", m_name);
2150 /* Death by Physical attack -- non-living monster */
2151 else if (!monster_living(r_ptr))
2154 bool explode = FALSE;
2156 for (i = 0; i < 4; i++)
2158 if (r_ptr->blow[i].method == RBM_EXPLODE) explode = TRUE;
2161 /* Special note at death */
2164 msg_format("%s¤ÏÇúȯ¤·¤ÆÊ´¡¹¤Ë¤Ê¤Ã¤¿¡£", m_name);
2166 msg_format("%^s explodes into tiny shreds.", m_name);
2171 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
2172 msg_format("¤»¤Ã¤«¤¯¤À¤«¤é%s¤òÅݤ·¤¿¡£", m_name);
2174 msg_format("%s¤òÅݤ·¤¿¡£", m_name);
2176 msg_format("You have destroyed %s.", m_name);
2181 /* Death by Physical attack -- living monster */
2185 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
2186 msg_format("¤»¤Ã¤«¤¯¤À¤«¤é%s¤òÁò¤êµî¤Ã¤¿¡£", m_name);
2188 msg_format("%s¤òÁò¤êµî¤Ã¤¿¡£", m_name);
2190 msg_format("You have slain %s.", m_name);
2194 if ((r_ptr->flags1 & RF1_UNIQUE) && !(m_ptr->smart & SM_CLONED) && !vanilla_town)
2196 for (i = 0; i < MAX_KUBI; i++)
2198 if ((kubi_r_idx[i] == m_ptr->r_idx) && !(m_ptr->mflag2 & MFLAG2_CHAMELEON))
2201 msg_format("%s¤Î¼ó¤Ë¤Ï¾Þ¶â¤¬¤«¤«¤Ã¤Æ¤¤¤ë¡£", m_name);
2203 msg_format("There is a price on %s's head.", m_name);
2210 /* Generate treasure */
2211 monster_death(m_idx, TRUE);
2213 /* Mega hack : replace IKETA to BIKETAL */
2214 if ((m_ptr->r_idx == MON_IKETA) &&
2215 !(p_ptr->inside_arena || p_ptr->inside_battle))
2217 int dummy_y = m_ptr->fy;
2218 int dummy_x = m_ptr->fx;
2221 if (is_pet(m_ptr)) mode |= PM_FORCE_PET;
2223 /* Delete the monster */
2224 delete_monster_idx(m_idx);
2226 if (summon_named_creature(0, dummy_y, dummy_x, MON_BIKETAL, mode))
2229 msg_print("¡Ö¥Ï¥¡¥Ã¥Ï¥Ã¥Ï¥Ã¥Ï¡ª¡ª»ä¤¬¥Ð¥¤¥±¥¿¥ë¤À¡ª¡ª¡×");
2231 msg_print("Uwa-hahaha! *I* am Biketal!");
2237 /* Delete the monster */
2238 delete_monster_idx(m_idx);
2241 get_exp_from_mon((long)exp_mon.max_maxhp*2, &exp_mon);
2246 /* Monster is dead */
2253 /* Mega-Hack -- Pain cancels fear */
2254 if (MON_MONFEAR(m_ptr) && (dam > 0))
2257 if (set_monster_monfear(m_idx, MON_MONFEAR(m_ptr) - randint1(dam)))
2264 /* Sometimes a monster gets scared by damage */
2265 if (!MON_MONFEAR(m_ptr) && !(r_ptr->flags3 & (RF3_NO_FEAR)))
2267 /* Percentage of fully healthy */
2268 int percentage = (100L * m_ptr->hp) / m_ptr->maxhp;
2271 * Run (sometimes) if at 10% or less of max hit points,
2272 * or (usually) when hit for half its current hit points
2274 if ((randint1(10) >= percentage) ||
2275 ((dam >= m_ptr->hp) && (randint0(100) < 80)))
2277 /* Hack -- note fear */
2280 /* XXX XXX XXX Hack -- Add some timed fear */
2281 (void)set_monster_monfear(m_idx, (randint1(10) +
2282 (((dam >= m_ptr->hp) && (percentage > 7)) ?
2283 20 : ((11 - percentage) * 5))));
2290 if (p_ptr->riding && (p_ptr->riding == m_idx) && (dam > 0))
2294 /* Extract monster name */
2295 monster_desc(m_name, m_ptr, 0);
2297 if (m_ptr->hp > m_ptr->maxhp/3) dam = (dam + 1) / 2;
2298 if (rakuba((dam > 200) ? 200 : dam, FALSE))
2301 msg_format("%^s¤Ë¿¶¤êÍî¤È¤µ¤ì¤¿¡ª", m_name);
2303 msg_format("%^s has thrown you off!", m_name);
2315 * @brief ¸½ºß¤Î¥³¥ó¥½¡¼¥ëɽ¼¨¤Î½Ä²£¤òÊÖ¤¹¡£ /
2316 * Get term size and calculate screen size
2317 * @param wid_p ¥³¥ó¥½¡¼¥ë¤Îɽ¼¨Éýʸ»ú¿ô¤òÊÖ¤¹
2318 * @param hgt_p ¥³¥ó¥½¡¼¥ë¤Îɽ¼¨¹Ô¿ô¤òÊÖ¤¹
2321 void get_screen_size(int *wid_p, int *hgt_p)
2323 Term_get_size(wid_p, hgt_p);
2324 *hgt_p -= ROW_MAP + 2;
2325 *wid_p -= COL_MAP + 2;
2326 if (use_bigtile) *wid_p /= 2;
2331 * @brief ¥³¥ó¥½¡¼¥ë¾å¤Ë¤ª¤±¤ë¥Þ¥Ã¥×ɽ¼¨¤Îº¸¾å°ÌÃÖ¤òÊÖ¤¹ /
2332 * Calculates current boundaries Called below and from "do_cmd_locate()".
2335 void panel_bounds_center(void)
2340 get_screen_size(&wid, &hgt);
2342 panel_row_max = panel_row_min + hgt - 1;
2343 panel_row_prt = panel_row_min - 1;
2344 panel_col_max = panel_col_min + wid - 1;
2345 panel_col_prt = panel_col_min - 13;
2350 * @brief ¥³¥ó¥½¡¼¥ë¤Î¥ê¥µ¥¤¥º¤Ë¹ç¤ï¤»¤Æ¥Þ¥Ã¥×¤òºÆÉÁ²è¤¹¤ë /
2351 * Map resizing whenever the main term changes size
2354 void resize_map(void)
2356 /* Only if the dungeon exists */
2357 if (!character_dungeon) return;
2359 /* Mega-Hack -- no panel yet */
2363 /* Reset the panels */
2364 panel_row_min = cur_hgt;
2365 panel_col_min = cur_wid;
2370 p_ptr->update |= (PU_TORCH | PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
2372 /* Forget lite/view */
2373 p_ptr->update |= (PU_UN_VIEW | PU_UN_LITE);
2375 /* Update lite/view */
2376 p_ptr->update |= (PU_VIEW | PU_LITE | PU_MON_LITE);
2378 /* Update monsters */
2379 p_ptr->update |= (PU_MONSTERS);
2381 /* Redraw everything */
2382 p_ptr->redraw |= (PR_WIPE | PR_BASIC | PR_EXTRA | PR_MAP | PR_EQUIPPY);
2384 /* Hack -- update */
2392 * Place the cursor on the player
2394 if (can_save) move_cursor_relative(py, px);
2401 * @brief ¥³¥ó¥½¡¼¥ë¤òºÆÉÁ²è¤¹¤ë /
2402 * Redraw a term when it is resized
2405 void redraw_window(void)
2407 /* Only if the dungeon exists */
2408 if (!character_dungeon) return;
2411 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_SPELL | PW_PLAYER);
2414 p_ptr->window |= (PW_MESSAGE | PW_OVERHEAD | PW_DUNGEON | PW_MONSTER | PW_OBJECT);
2416 /* Hack -- update */
2425 * @brief ¥Õ¥©¡¼¥«¥¹¤òÅö¤Æ¤ë¤Ù¤¥Þ¥Ã¥×ÉÁ²è¤Î´ð½àºÂɸ¤ò»ØÄꤹ¤ë¡Ê¥µ¥Ö¥ë¡¼¥Á¥ó¡Ë
2426 * @param dy Êѹ¹Àè¤Î¥Õ¥í¥¢YºÂɸ
2427 * @param dx Êѹ¹Àè¤Î¥Õ¥í¥¢XºÂɸ
2428 * Handle a request to change the current panel
2429 * Return TRUE if the panel was changed.
2430 * Also used in do_cmd_locate
2431 * @return ¼ÂºÝ¤ËºÆÉÁ²è¤¬É¬ÍפÀ¤Ã¤¿¾ì¹çTRUE¤òÊÖ¤¹
2433 bool change_panel(int dy, int dx)
2439 get_screen_size(&wid, &hgt);
2441 /* Apply the motion */
2442 y = panel_row_min + dy * hgt / 2;
2443 x = panel_col_min + dx * wid / 2;
2445 /* Verify the row */
2446 if (y > cur_hgt - hgt) y = cur_hgt - hgt;
2449 /* Verify the col */
2450 if (x > cur_wid - wid) x = cur_wid - wid;
2453 /* Handle "changes" */
2454 if ((y != panel_row_min) || (x != panel_col_min))
2456 /* Save the new panel info */
2460 /* Recalculate the boundaries */
2461 panel_bounds_center();
2464 p_ptr->update |= (PU_MONSTERS);
2467 p_ptr->redraw |= (PR_MAP);
2481 * @brief ¥Õ¥©¡¼¥«¥¹¤òÅö¤Æ¤ë¤Ù¤¥Þ¥Ã¥×ÉÁ²è¤Î´ð½àºÂɸ¤ò»ØÄꤹ¤ë
2482 * @param y Êѹ¹Àè¤Î¥Õ¥í¥¢YºÂɸ
2483 * @param x Êѹ¹Àè¤Î¥Õ¥í¥¢XºÂɸ
2485 * Handle a request to change the current panel
2486 * Return TRUE if the panel was changed.
2487 * Also used in do_cmd_locate
2488 * @return ¼ÂºÝ¤ËºÆÉÁ²è¤¬É¬ÍפÀ¤Ã¤¿¾ì¹çTRUE¤òÊÖ¤¹
2490 bool change_panel_xy(int y, int x)
2496 get_screen_size(&wid, &hgt);
2498 if (y < panel_row_min) dy = -1;
2499 if (y > panel_row_max) dy = 1;
2500 if (x < panel_col_min) dx = -1;
2501 if (x > panel_col_max) dx = 1;
2503 if (!dy && !dx) return (FALSE);
2505 return change_panel(dy, dx);
2510 * @brief ¥Þ¥Ã¥×ÉÁ²è¤Î¥Õ¥©¡¼¥«¥¹¤òÅö¤Æ¤ë¤Ù¤ºÂɸ¤ò¹¹¿·¤¹¤ë
2512 * Given an row (y) and col (x), this routine detects when a move
2513 * off the screen has occurred and figures new borders. -RAK-
2514 * "Update" forces a "full update" to take place.
2515 * The map is reprinted if necessary, and "TRUE" is returned.
2516 * @return ¼ÂºÝ¤ËºÆÉÁ²è¤¬É¬ÍפÀ¤Ã¤¿¾ì¹çTRUE¤òÊÖ¤¹
2518 void verify_panel(void)
2530 get_screen_size(&wid, &hgt);
2532 max_prow_min = cur_hgt - hgt;
2533 max_pcol_min = cur_wid - wid;
2535 /* Bounds checking */
2536 if (max_prow_min < 0) max_prow_min = 0;
2537 if (max_pcol_min < 0) max_pcol_min = 0;
2539 /* Center on player */
2540 if (center_player && (center_running || !running))
2542 /* Center vertically */
2543 prow_min = y - hgt / 2;
2544 if (prow_min < 0) prow_min = 0;
2545 else if (prow_min > max_prow_min) prow_min = max_prow_min;
2547 /* Center horizontally */
2548 pcol_min = x - wid / 2;
2549 if (pcol_min < 0) pcol_min = 0;
2550 else if (pcol_min > max_pcol_min) pcol_min = max_pcol_min;
2554 prow_min = panel_row_min;
2555 pcol_min = panel_col_min;
2557 /* Scroll screen when 2 grids from top/bottom edge */
2558 if (y > panel_row_max - 2)
2560 while (y > prow_min + hgt-1 - 2)
2562 prow_min += (hgt / 2);
2566 if (y < panel_row_min + 2)
2568 while (y < prow_min + 2)
2570 prow_min -= (hgt / 2);
2574 if (prow_min > max_prow_min) prow_min = max_prow_min;
2575 if (prow_min < 0) prow_min = 0;
2577 /* Scroll screen when 4 grids from left/right edge */
2578 if (x > panel_col_max - 4)
2580 while (x > pcol_min + wid-1 - 4)
2582 pcol_min += (wid / 2);
2586 if (x < panel_col_min + 4)
2588 while (x < pcol_min + 4)
2590 pcol_min -= (wid / 2);
2594 if (pcol_min > max_pcol_min) pcol_min = max_pcol_min;
2595 if (pcol_min < 0) pcol_min = 0;
2598 /* Check for "no change" */
2599 if ((prow_min == panel_row_min) && (pcol_min == panel_col_min)) return;
2601 /* Save the new panel info */
2602 panel_row_min = prow_min;
2603 panel_col_min = pcol_min;
2605 /* Hack -- optional disturb on "panel change" */
2606 if (disturb_panel && !center_player) disturb(0, 0);
2608 /* Recalculate the boundaries */
2609 panel_bounds_center();
2612 p_ptr->update |= (PU_MONSTERS);
2615 p_ptr->redraw |= (PR_MAP);
2618 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
2623 * Monster health description
2625 cptr look_mon_desc(monster_type *m_ptr, u32b mode)
2627 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
2634 /* Determine if the monster is "living" */
2635 living = monster_living(ap_r_ptr);
2637 /* Calculate a health "percentage" */
2638 perc = 100L * m_ptr->hp / m_ptr->maxhp;
2640 /* Healthy monsters */
2641 if (m_ptr->hp >= m_ptr->maxhp)
2645 desc = living ? "̵½ý" : "̵¥À¥á¡¼¥¸";
2647 desc = living ? "unhurt" : "undamaged";
2652 else if (perc >= 60)
2655 desc = living ? "·Ú½ý" : "¾®¥À¥á¡¼¥¸";
2657 desc = living ? "somewhat wounded" : "somewhat damaged";
2662 else if (perc >= 25)
2665 desc = living ? "Éé½ý" : "Ãæ¥À¥á¡¼¥¸";
2667 desc = living ? "wounded" : "damaged";
2672 else if (perc >= 10)
2675 desc = living ? "½Å½ý" : "Âç¥À¥á¡¼¥¸";
2677 desc = living ? "badly wounded" : "badly damaged";
2685 desc = living ? "Ⱦ»àȾÀ¸" : "Åݤ줫¤±";
2687 desc = living ? "almost dead" : "almost destroyed";
2692 /* Need attitude information? */
2695 /* Full information is not needed */
2698 else if (is_pet(m_ptr))
2701 attitude = ", ¥Ú¥Ã¥È";
2706 else if (is_friendly(m_ptr))
2709 attitude = ", ͧ¹¥Åª";
2711 attitude = ", friendly";
2724 /* Clone monster? */
2725 if (m_ptr->smart & SM_CLONED)
2734 /* Display monster's level --- idea borrowed from ToME */
2735 if (ap_r_ptr->r_tkills && !(m_ptr->mflag2 & MFLAG2_KAGE))
2738 return format("¥ì¥Ù¥ë%d, %s%s%s", ap_r_ptr->level, desc, attitude, clone);
2740 return format("Level %d, %s%s%s", ap_r_ptr->level, desc, attitude, clone);
2746 return format("¥ì¥Ù¥ë???, %s%s%s", desc, attitude, clone);
2748 return format("Level ???, %s%s%s", desc, attitude, clone);
2756 * Angband sorting algorithm -- quick sort in place
2758 * Note that the details of the data we are sorting is hidden,
2759 * and we rely on the "ang_sort_comp()" and "ang_sort_swap()"
2760 * function hooks to interact with the data, which is given as
2761 * two pointers, and which may have any user-defined form.
2763 void ang_sort_aux(vptr u, vptr v, int p, int q)
2781 while (!(*ang_sort_comp)(u, v, b, z)) b--;
2784 while (!(*ang_sort_comp)(u, v, z, a)) a++;
2786 /* Done partition */
2790 (*ang_sort_swap)(u, v, a, b);
2796 /* Recurse left side */
2797 ang_sort_aux(u, v, p, b);
2799 /* Recurse right side */
2800 ang_sort_aux(u, v, b+1, q);
2805 * Angband sorting algorithm -- quick sort in place
2807 * Note that the details of the data we are sorting is hidden,
2808 * and we rely on the "ang_sort_comp()" and "ang_sort_swap()"
2809 * function hooks to interact with the data, which is given as
2810 * two pointers, and which may have any user-defined form.
2812 void ang_sort(vptr u, vptr v, int n)
2814 /* Sort the array */
2815 ang_sort_aux(u, v, 0, n-1);
2820 /*** Targeting Code ***/
2824 * Determine is a monster makes a reasonable target
2826 * The concept of "targeting" was stolen from "Morgul" (?)
2828 * The player can target any location, or any "target-able" monster.
2830 * Currently, a monster is "target_able" if it is visible, and if
2831 * the player can hit it with a projection, and the player is not
2832 * hallucinating. This allows use of "use closest target" macros.
2834 * Future versions may restrict the ability to target "trappers"
2835 * and "mimics", but the semantics is a little bit weird.
2837 bool target_able(int m_idx)
2839 monster_type *m_ptr = &m_list[m_idx];
2841 /* Monster must be alive */
2842 if (!m_ptr->r_idx) return (FALSE);
2844 /* Hack -- no targeting hallucinations */
2845 if (p_ptr->image) return (FALSE);
2847 /* Monster must be visible */
2848 if (!m_ptr->ml) return (FALSE);
2850 if (p_ptr->riding && (p_ptr->riding == m_idx)) return (TRUE);
2852 /* Monster must be projectable */
2853 if (!projectable(py, px, m_ptr->fy, m_ptr->fx)) return (FALSE);
2855 /* XXX XXX XXX Hack -- Never target trappers */
2856 /* if (CLEAR_ATTR && (CLEAR_CHAR)) return (FALSE); */
2866 * Update (if necessary) and verify (if possible) the target.
2868 * We return TRUE if the target is "okay" and FALSE otherwise.
2870 bool target_okay(void)
2872 /* Accept stationary targets */
2873 if (target_who < 0) return (TRUE);
2875 /* Check moving targets */
2878 /* Accept reasonable targets */
2879 if (target_able(target_who))
2881 monster_type *m_ptr = &m_list[target_who];
2883 /* Acquire monster location */
2884 target_row = m_ptr->fy;
2885 target_col = m_ptr->fx;
2892 /* Assume no target */
2898 * Sorting hook -- comp function -- by "distance to player"
2900 * We use "u" and "v" to point to arrays of "x" and "y" positions,
2901 * and sort the arrays by double-distance to the player.
2903 static bool ang_sort_comp_distance(vptr u, vptr v, int a, int b)
2905 byte *x = (byte*)(u);
2906 byte *y = (byte*)(v);
2910 /* Absolute distance components */
2911 kx = x[a]; kx -= px; kx = ABS(kx);
2912 ky = y[a]; ky -= py; ky = ABS(ky);
2914 /* Approximate Double Distance to the first point */
2915 da = ((kx > ky) ? (kx + kx + ky) : (ky + ky + kx));
2917 /* Absolute distance components */
2918 kx = x[b]; kx -= px; kx = ABS(kx);
2919 ky = y[b]; ky -= py; ky = ABS(ky);
2921 /* Approximate Double Distance to the first point */
2922 db = ((kx > ky) ? (kx + kx + ky) : (ky + ky + kx));
2924 /* Compare the distances */
2930 * Sorting hook -- comp function -- by importance level of grids
2932 * We use "u" and "v" to point to arrays of "x" and "y" positions,
2933 * and sort the arrays by level of monster
2935 static bool ang_sort_comp_importance(vptr u, vptr v, int a, int b)
2937 byte *x = (byte*)(u);
2938 byte *y = (byte*)(v);
2939 cave_type *ca_ptr = &cave[y[a]][x[a]];
2940 cave_type *cb_ptr = &cave[y[b]][x[b]];
2941 monster_type *ma_ptr = &m_list[ca_ptr->m_idx];
2942 monster_type *mb_ptr = &m_list[cb_ptr->m_idx];
2943 monster_race *ap_ra_ptr, *ap_rb_ptr;
2945 /* The player grid */
2946 if (y[a] == py && x[a] == px) return TRUE;
2947 if (y[b] == py && x[b] == px) return FALSE;
2949 /* Extract monster race */
2950 if (ca_ptr->m_idx && ma_ptr->ml) ap_ra_ptr = &r_info[ma_ptr->ap_r_idx];
2951 else ap_ra_ptr = NULL;
2952 if (cb_ptr->m_idx && mb_ptr->ml) ap_rb_ptr = &r_info[mb_ptr->ap_r_idx];
2953 else ap_rb_ptr = NULL;
2955 if (ap_ra_ptr && !ap_rb_ptr) return TRUE;
2956 if (!ap_ra_ptr && ap_rb_ptr) return FALSE;
2958 /* Compare two monsters */
2959 if (ap_ra_ptr && ap_rb_ptr)
2961 /* Unique monsters first */
2962 if ((ap_ra_ptr->flags1 & RF1_UNIQUE) && !(ap_rb_ptr->flags1 & RF1_UNIQUE)) return TRUE;
2963 if (!(ap_ra_ptr->flags1 & RF1_UNIQUE) && (ap_rb_ptr->flags1 & RF1_UNIQUE)) return FALSE;
2965 /* Shadowers first (¤¢¤ä¤·¤¤±Æ) */
2966 if ((ma_ptr->mflag2 & MFLAG2_KAGE) && !(mb_ptr->mflag2 & MFLAG2_KAGE)) return TRUE;
2967 if (!(ma_ptr->mflag2 & MFLAG2_KAGE) && (mb_ptr->mflag2 & MFLAG2_KAGE)) return FALSE;
2969 /* Unknown monsters first */
2970 if (!ap_ra_ptr->r_tkills && ap_rb_ptr->r_tkills) return TRUE;
2971 if (ap_ra_ptr->r_tkills && !ap_rb_ptr->r_tkills) return FALSE;
2973 /* Higher level monsters first (if known) */
2974 if (ap_ra_ptr->r_tkills && ap_rb_ptr->r_tkills)
2976 if (ap_ra_ptr->level > ap_rb_ptr->level) return TRUE;
2977 if (ap_ra_ptr->level < ap_rb_ptr->level) return FALSE;
2980 /* Sort by index if all conditions are same */
2981 if (ma_ptr->ap_r_idx > mb_ptr->ap_r_idx) return TRUE;
2982 if (ma_ptr->ap_r_idx < mb_ptr->ap_r_idx) return FALSE;
2985 /* An object get higher priority */
2986 if (cave[y[a]][x[a]].o_idx && !cave[y[b]][x[b]].o_idx) return TRUE;
2987 if (!cave[y[a]][x[a]].o_idx && cave[y[b]][x[b]].o_idx) return FALSE;
2989 /* Priority from the terrain */
2990 if (f_info[ca_ptr->feat].priority > f_info[cb_ptr->feat].priority) return TRUE;
2991 if (f_info[ca_ptr->feat].priority < f_info[cb_ptr->feat].priority) return FALSE;
2993 /* If all conditions are same, compare distance */
2994 return ang_sort_comp_distance(u, v, a, b);
2999 * Sorting hook -- swap function -- by "distance to player"
3001 * We use "u" and "v" to point to arrays of "x" and "y" positions,
3002 * and sort the arrays by distance to the player.
3004 static void ang_sort_swap_distance(vptr u, vptr v, int a, int b)
3006 byte *x = (byte*)(u);
3007 byte *y = (byte*)(v);
3025 * Hack -- help "select" a location (see below)
3027 static s16b target_pick(int y1, int x1, int dy, int dx)
3031 int x2, y2, x3, y3, x4, y4;
3033 int b_i = -1, b_v = 9999;
3036 /* Scan the locations */
3037 for (i = 0; i < temp_n; i++)
3043 /* Directed distance */
3047 /* Verify quadrant */
3048 if (dx && (x3 * dx <= 0)) continue;
3049 if (dy && (y3 * dy <= 0)) continue;
3051 /* Absolute distance */
3055 /* Verify quadrant */
3056 if (dy && !dx && (x4 > y4)) continue;
3057 if (dx && !dy && (y4 > x4)) continue;
3059 /* Approximate Double Distance */
3060 v = ((x4 > y4) ? (x4 + x4 + y4) : (y4 + y4 + x4));
3062 /* XXX XXX XXX Penalize location */
3065 if ((b_i >= 0) && (v >= b_v)) continue;
3077 * Hack -- determine if a given location is "interesting"
3079 static bool target_set_accept(int y, int x)
3083 s16b this_o_idx, next_o_idx = 0;
3086 if (!(in_bounds(y, x))) return (FALSE);
3088 /* Player grid is always interesting */
3089 if (player_bold(y, x)) return (TRUE);
3092 /* Handle hallucination */
3093 if (p_ptr->image) return (FALSE);
3096 /* Examine the grid */
3097 c_ptr = &cave[y][x];
3099 /* Visible monsters */
3102 monster_type *m_ptr = &m_list[c_ptr->m_idx];
3104 /* Visible monsters */
3105 if (m_ptr->ml) return (TRUE);
3108 /* Scan all objects in the grid */
3109 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
3113 /* Acquire object */
3114 o_ptr = &o_list[this_o_idx];
3116 /* Acquire next object */
3117 next_o_idx = o_ptr->next_o_idx;
3119 /* Memorized object */
3120 if (o_ptr->marked & OM_FOUND) return (TRUE);
3123 /* Interesting memorized features */
3124 if (c_ptr->info & (CAVE_MARK))
3126 /* Notice object features */
3127 if (c_ptr->info & CAVE_OBJECT) return (TRUE);
3129 /* Feature code (applying "mimic" field) */
3130 if (have_flag(f_info[get_feat_mimic(c_ptr)].flags, FF_NOTICE)) return TRUE;
3139 * Prepare the "temp" array for "target_set"
3141 * Return the number of target_able monsters in the set.
3143 static void target_set_prepare(int mode)
3146 int min_hgt, max_hgt, min_wid, max_wid;
3148 if (mode & TARGET_KILL)
3151 min_hgt = MAX((py - MAX_RANGE), 0);
3152 max_hgt = MIN((py + MAX_RANGE), cur_hgt - 1);
3153 min_wid = MAX((px - MAX_RANGE), 0);
3154 max_wid = MIN((px + MAX_RANGE), cur_wid - 1);
3156 else /* not targetting */
3159 min_hgt = panel_row_min;
3160 max_hgt = panel_row_max;
3161 min_wid = panel_col_min;
3162 max_wid = panel_col_max;
3165 /* Reset "temp" array */
3168 /* Scan the current panel */
3169 for (y = min_hgt; y <= max_hgt; y++)
3171 for (x = min_wid; x <= max_wid; x++)
3175 /* Require "interesting" contents */
3176 if (!target_set_accept(y, x)) continue;
3178 c_ptr = &cave[y][x];
3180 /* Require target_able monsters for "TARGET_KILL" */
3181 if ((mode & (TARGET_KILL)) && !target_able(c_ptr->m_idx)) continue;
3183 if ((mode & (TARGET_KILL)) && !target_pet && is_pet(&m_list[c_ptr->m_idx])) continue;
3185 /* Save the location */
3192 /* Set the sort hooks */
3193 if (mode & (TARGET_KILL))
3195 /* Target the nearest monster for shooting */
3196 ang_sort_comp = ang_sort_comp_distance;
3197 ang_sort_swap = ang_sort_swap_distance;
3201 /* Look important grids first in Look command */
3202 ang_sort_comp = ang_sort_comp_importance;
3203 ang_sort_swap = ang_sort_swap_distance;
3206 /* Sort the positions */
3207 ang_sort(temp_x, temp_y, temp_n);
3209 if (p_ptr->riding && target_pet && (temp_n > 1) && (mode & (TARGET_KILL)))
3214 temp_y[0] = temp_y[1];
3217 temp_x[0] = temp_x[1];
3221 void target_set_prepare_look(){
3222 target_set_prepare(TARGET_LOOK);
3227 * Evaluate number of kill needed to gain level
3229 static void evaluate_monster_exp(char *buf, monster_type *m_ptr)
3231 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
3233 s32b exp_mon, exp_adv;
3234 u32b exp_mon_frac, exp_adv_frac;
3236 if ((p_ptr->lev >= PY_MAX_LEVEL) || (p_ptr->prace == RACE_ANDROID))
3241 else if (!ap_r_ptr->r_tkills || (m_ptr->mflag2 & MFLAG2_KAGE))
3251 /* The monster's experience point (assuming average monster speed) */
3252 exp_mon = ap_r_ptr->mexp * ap_r_ptr->level;
3254 s64b_div(&exp_mon, &exp_mon_frac, 0, (p_ptr->max_plv + 2));
3257 /* Total experience value for next level */
3258 exp_adv = player_exp[p_ptr->lev -1] * p_ptr->expfact;
3260 s64b_div(&exp_adv, &exp_adv_frac, 0, 100);
3262 /* Experience value need to get */
3263 s64b_sub(&exp_adv, &exp_adv_frac, p_ptr->exp, p_ptr->exp_frac);
3266 /* You need to kill at least one monster to get any experience */
3267 s64b_add(&exp_adv, &exp_adv_frac, exp_mon, exp_mon_frac);
3268 s64b_sub(&exp_adv, &exp_adv_frac, 0, 1);
3270 /* Extract number of monsters needed */
3271 s64b_div(&exp_adv, &exp_adv_frac, exp_mon, exp_mon_frac);
3273 /* If 999 or more monsters needed, only display "999". */
3274 num = MIN(999, exp_adv_frac);
3276 /* Display the number */
3277 sprintf(buf,"%03ld", (long int)num);
3281 bool show_gold_on_floor = FALSE;
3284 * Examine a grid, return a keypress.
3286 * The "mode" argument contains the "TARGET_LOOK" bit flag, which
3287 * indicates that the "space" key should scan through the contents
3288 * of the grid, instead of simply returning immediately. This lets
3289 * the "look" command get complete information, without making the
3290 * "target" command annoying.
3292 * The "info" argument contains the "commands" which should be shown
3293 * inside the "[xxx]" text. This string must never be empty, or grids
3294 * containing monsters will be displayed with an extra comma.
3296 * Note that if a monster is in the grid, we update both the monster
3297 * recall info and the health bar info to track that monster.
3299 * Eventually, we may allow multiple objects per grid, or objects
3300 * and terrain features in the same grid. XXX XXX XXX
3302 * This function must handle blindness/hallucination.
3304 static int target_set_aux(int y, int x, int mode, cptr info)
3306 cave_type *c_ptr = &cave[y][x];
3307 s16b this_o_idx, next_o_idx = 0;
3308 cptr s1 = "", s2 = "", s3 = "", x_info = "";
3311 feature_type *f_ptr;
3313 char out_val[MAX_NLEN+80];
3315 #ifdef ALLOW_EASY_FLOOR
3316 int floor_list[23], floor_num = 0;
3318 /* Scan all objects in the grid */
3321 floor_num = scan_floor(floor_list, y, x, 0x02);
3333 #endif /* ALLOW_EASY_FLOOR */
3335 /* Hack -- under the player */
3336 if (player_bold(y, x))
3359 /* Hack -- hallucination */
3363 cptr name = "²¿¤«´ñ̯¤Êʪ";
3365 cptr name = "something strange";
3369 /* Display a message */
3371 sprintf(out_val, "%s%s%s%s [%s]", s1, name, s2, s3, info);
3373 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, name, info);
3377 move_cursor_relative(y, x);
3380 /* Stop on everything but "return" */
3381 if ((query != '\r') && (query != '\n')) return query;
3383 /* Repeat forever */
3388 /* Actual monsters */
3389 if (c_ptr->m_idx && m_list[c_ptr->m_idx].ml)
3391 monster_type *m_ptr = &m_list[c_ptr->m_idx];
3392 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
3394 bool recall = FALSE;
3399 /* Get the monster name ("a kobold") */
3400 monster_desc(m_name, m_ptr, MD_INDEF_VISIBLE);
3402 /* Hack -- track this monster race */
3403 monster_race_track(m_ptr->ap_r_idx);
3405 /* Hack -- health bar for this monster */
3406 health_track(c_ptr->m_idx);
3408 /* Hack -- handle stuff */
3422 /* Recall on screen */
3423 screen_roff(m_ptr->ap_r_idx, 0);
3425 /* Hack -- Complete the prompt (again) */
3427 Term_addstr(-1, TERM_WHITE, format(" [r»× %s%s]", x_info, info));
3429 Term_addstr(-1, TERM_WHITE, format(" [r,%s%s]", x_info, info));
3438 /* Normal commands */
3439 if (query != 'r') break;
3444 /* Cleare recall text and repeat */
3450 /* Describe, and prompt for recall */
3451 evaluate_monster_exp(acount, m_ptr);
3454 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);
3456 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);
3462 move_cursor_relative(y, x);
3467 /* Normal commands */
3468 if (query != 'r') break;
3474 /* Always stop at "normal" keys */
3475 if ((query != '\r') && (query != '\n') && (query != ' ') && (query != 'x')) return query;
3477 /* Sometimes stop at "space" key */
3478 if ((query == ' ') && !(mode & (TARGET_LOOK))) return query;
3480 /* Change the intro */
3488 /* Hack -- take account of gender */
3490 if (ap_r_ptr->flags1 & (RF1_FEMALE)) s1 = "Èà½÷¤Ï";
3492 if (ap_r_ptr->flags1 & (RF1_FEMALE)) s1 = "She is ";
3496 else if (ap_r_ptr->flags1 & (RF1_MALE)) s1 = "Èà¤Ï";
3498 else if (ap_r_ptr->flags1 & (RF1_MALE)) s1 = "He is ";
3502 /* Use a preposition */
3511 /* Scan all objects being carried */
3512 for (this_o_idx = m_ptr->hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
3514 char o_name[MAX_NLEN];
3518 /* Acquire object */
3519 o_ptr = &o_list[this_o_idx];
3521 /* Acquire next object */
3522 next_o_idx = o_ptr->next_o_idx;
3524 /* Obtain an object description */
3525 object_desc(o_name, o_ptr, 0);
3527 /* Describe the object */
3529 sprintf(out_val, "%s%s%s%s[%s]", s1, o_name, s2, s3, info);
3531 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, o_name, info);
3535 move_cursor_relative(y, x);
3538 /* Always stop at "normal" keys */
3539 if ((query != '\r') && (query != '\n') && (query != ' ') && (query != 'x')) return query;
3541 /* Sometimes stop at "space" key */
3542 if ((query == ' ') && !(mode & (TARGET_LOOK))) return query;
3544 /* Change the intro */
3548 s2 = "also carrying ";
3552 /* Use a preposition */
3562 #ifdef ALLOW_EASY_FLOOR
3571 char o_name[MAX_NLEN];
3575 /* Acquire object */
3576 o_ptr = &o_list[floor_list[0]];
3578 /* Describe the object */
3579 object_desc(o_name, o_ptr, 0);
3583 sprintf(out_val, "%s%s%s%s[%s]",
3584 s1, o_name, s2, s3, info);
3586 sprintf(out_val, "%s%s%s%s [%s]",
3587 s1, s2, s3, o_name, info);
3591 move_cursor_relative(y, x);
3600 /* Provide one cushion before item listing */
3603 /* Display rough information about items */
3605 sprintf(out_val, "%s %d¸Ä¤Î¥¢¥¤¥Æ¥à%s%s ['x'¤Ç°ìÍ÷, %s]",
3606 s1, floor_num, s2, s3, info);
3608 sprintf(out_val, "%s%s%sa pile of %d items [x,%s]",
3609 s1, s2, s3, floor_num, info);
3613 move_cursor_relative(y, x);
3618 /* No request for listing */
3619 if (query != 'x' && query != ' ') return query;
3623 /** Display list of items **/
3625 /* Continue scrolling list if requested */
3634 show_gold_on_floor = TRUE;
3635 (void)show_floor(0, y, x, &min_width);
3636 show_gold_on_floor = FALSE;
3640 sprintf(out_val, "%s %d¸Ä¤Î¥¢¥¤¥Æ¥à%s%s [Enter¤Ç¼¡¤Ø, %s]",
3641 s1, floor_num, s2, s3, info);
3643 sprintf(out_val, "%s%s%sa pile of %d items [Enter,%s]",
3644 s1, s2, s3, floor_num, info);
3655 /* Exit unless 'Enter' */
3656 if (query != '\n' && query != '\r')
3661 /* Get the object being moved. */
3662 o_idx = c_ptr->o_idx;
3664 /* Only rotate a pile of two or more objects. */
3665 if (!(o_idx && o_list[o_idx].next_o_idx)) continue;
3667 /* Remove the first object from the list. */
3668 excise_object_idx(o_idx);
3670 /* Find end of the list. */
3672 while (o_list[i].next_o_idx)
3673 i = o_list[i].next_o_idx;
3675 /* Add after the last object. */
3676 o_list[i].next_o_idx = o_idx;
3678 /* Loop and re-display the list */
3684 #endif /* ALLOW_EASY_FLOOR */
3687 /* Scan all objects in the grid */
3688 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
3692 /* Acquire object */
3693 o_ptr = &o_list[this_o_idx];
3695 /* Acquire next object */
3696 next_o_idx = o_ptr->next_o_idx;
3699 if (o_ptr->marked & OM_FOUND)
3701 char o_name[MAX_NLEN];
3706 /* Obtain an object description */
3707 object_desc(o_name, o_ptr, 0);
3709 /* Describe the object */
3711 sprintf(out_val, "%s%s%s%s[%s]", s1, o_name, s2, s3, info);
3713 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, o_name, info);
3717 move_cursor_relative(y, x);
3720 /* Always stop at "normal" keys */
3721 if ((query != '\r') && (query != '\n') && (query != ' ') && (query != 'x')) return query;
3723 /* Sometimes stop at "space" key */
3724 if ((query == ' ') && !(mode & TARGET_LOOK)) return query;
3726 /* Change the intro */
3736 if (o_ptr->number != 1) s1 = "¤½¤ì¤é¤Ï";
3738 if (o_ptr->number != 1) s1 = "They are ";
3754 /* Feature code (applying "mimic" field) */
3755 feat = get_feat_mimic(c_ptr);
3757 /* Require knowledge about grid, or ability to see grid */
3758 if (!(c_ptr->info & CAVE_MARK) && !player_can_see_bold(y, x))
3760 /* Forget feature */
3764 f_ptr = &f_info[feat];
3766 /* Terrain feature if needed */
3767 if (boring || have_flag(f_ptr->flags, FF_REMEMBER))
3771 /* Hack -- special handling for quest entrances */
3772 if (have_flag(f_ptr->flags, FF_QUEST_ENTER))
3774 /* Set the quest number temporary */
3775 int old_quest = p_ptr->inside_quest;
3778 /* Clear the text */
3779 for (j = 0; j < 10; j++) quest_text[j][0] = '\0';
3780 quest_text_line = 0;
3782 p_ptr->inside_quest = c_ptr->special;
3784 /* Get the quest text */
3785 init_flags = INIT_NAME_ONLY;
3787 process_dungeon_file("q_info.txt", 0, 0, 0, 0);
3790 name = format("¥¯¥¨¥¹¥È¡Ö%s¡×(%d³¬ÁêÅö)", quest[c_ptr->special].name, quest[c_ptr->special].level);
3792 name = format("the entrance to the quest '%s'(level %d)", quest[c_ptr->special].name, quest[c_ptr->special].level);
3795 /* Reset the old quest number */
3796 p_ptr->inside_quest = old_quest;
3799 /* Hack -- special handling for building doors */
3800 else if (have_flag(f_ptr->flags, FF_BLDG) && !p_ptr->inside_arena)
3802 name = building[f_ptr->subtype].name;
3804 else if (have_flag(f_ptr->flags, FF_ENTRANCE))
3807 name = format("%s(%d³¬ÁêÅö)", d_text + d_info[c_ptr->special].text, d_info[c_ptr->special].mindepth);
3809 name = format("%s(level %d)", d_text + d_info[c_ptr->special].text, d_info[c_ptr->special].mindepth);
3812 else if (have_flag(f_ptr->flags, FF_TOWN))
3814 name = town[c_ptr->special].name;
3816 else if (p_ptr->wild_mode && (feat == feat_floor))
3826 name = f_name + f_ptr->name;
3832 ((!have_flag(f_ptr->flags, FF_MOVE) && !have_flag(f_ptr->flags, FF_CAN_FLY)) ||
3833 (!have_flag(f_ptr->flags, FF_LOS) && !have_flag(f_ptr->flags, FF_TREE)) ||
3834 have_flag(f_ptr->flags, FF_TOWN)))
3843 /* Hack -- special introduction for store & building doors -KMW- */
3844 if (have_flag(f_ptr->flags, FF_STORE) ||
3845 have_flag(f_ptr->flags, FF_QUEST_ENTER) ||
3846 (have_flag(f_ptr->flags, FF_BLDG) && !p_ptr->inside_arena) ||
3847 have_flag(f_ptr->flags, FF_ENTRANCE))
3856 else if (have_flag(f_ptr->flags, FF_FLOOR) ||
3857 have_flag(f_ptr->flags, FF_TOWN) ||
3858 have_flag(f_ptr->flags, FF_SHALLOW) ||
3859 have_flag(f_ptr->flags, FF_DEEP))
3865 /* Pick proper indefinite article */
3866 s3 = (is_a_vowel(name[0])) ? "an " : "a ";
3870 /* Display a message */
3874 if (c_ptr->mimic) sprintf(f_idx_str, "%d/%d", c_ptr->feat, c_ptr->mimic);
3875 else sprintf(f_idx_str, "%d", c_ptr->feat);
3877 sprintf(out_val, "%s%s%s%s[%s] %x %s %d %d %d (%d,%d) %d", s1, name, s2, s3, info, c_ptr->info, f_idx_str, c_ptr->dist, c_ptr->cost, c_ptr->when, y, x, travel.cost[y][x]);
3879 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, y, x);
3884 sprintf(out_val, "%s%s%s%s[%s]", s1, name, s2, s3, info);
3886 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, name, info);
3890 move_cursor_relative(y, x);
3893 /* Always stop at "normal" keys */
3894 if ((query != '\r') && (query != '\n') && (query != ' ')) return query;
3897 /* Stop on everything but "return" */
3898 if ((query != '\r') && (query != '\n')) return query;
3900 /* Repeat forever */
3906 * Handle "target" and "look".
3908 * Note that this code can be called from "get_aim_dir()".
3910 * All locations must be on the current panel. Consider the use of
3911 * "panel_bounds()" to allow "off-panel" targets, perhaps by using
3912 * some form of "scrolling" the map around the cursor. XXX XXX XXX
3913 * That is, consider the possibility of "auto-scrolling" the screen
3914 * while the cursor moves around. This may require changes in the
3915 * "update_mon()" code to allow "visibility" even if off panel, and
3916 * may require dynamic recalculation of the "temp" grid set.
3918 * Hack -- targeting/observing an "outer border grid" may induce
3919 * problems, so this is not currently allowed.
3921 * The player can use the direction keys to move among "interesting"
3922 * grids in a heuristic manner, or the "space", "+", and "-" keys to
3923 * move through the "interesting" grids in a sequential manner, or
3924 * can enter "location" mode, and use the direction keys to move one
3925 * grid at a time in any direction. The "t" (set target) command will
3926 * only target a monster (as opposed to a location) if the monster is
3927 * target_able and the "interesting" mode is being used.
3929 * The current grid is described using the "look" method above, and
3930 * a new command may be entered at any time, but note that if the
3931 * "TARGET_LOOK" bit flag is set (or if we are in "location" mode,
3932 * where "space" has no obvious meaning) then "space" will scan
3933 * through the description of the current grid until done, instead
3934 * of immediately jumping to the next "interesting" grid. This
3935 * allows the "target" command to retain its old semantics.
3937 * The "*", "+", and "-" keys may always be used to jump immediately
3938 * to the next (or previous) interesting grid, in the proper mode.
3940 * The "return" key may always be used to scan through a complete
3941 * grid description (forever).
3943 * This command will cancel any old target, even if used from
3944 * inside the "look" command.
3946 bool target_set(int mode)
3965 get_screen_size(&wid, &hgt);
3971 /* Cancel tracking */
3972 /* health_track(0); */
3975 /* Prepare the "temp" array */
3976 target_set_prepare(mode);
3978 /* Start near the player */
3984 /* Interesting grids */
3991 change_panel_xy(y, x);
3993 if (!(mode & TARGET_LOOK)) prt_path(y, x);
3996 c_ptr = &cave[y][x];
3999 if (target_able(c_ptr->m_idx))
4002 strcpy(info, "q»ß t·è p¼« o¸½ +¼¡ -Á°");
4004 strcpy(info, "q,t,p,o,+,-,<dir>");
4009 /* Dis-allow target */
4013 strcpy(info, "q»ß p¼« o¸½ +¼¡ -Á°");
4015 strcpy(info, "q,p,o,+,-,<dir>");
4020 /* Describe and Prompt */
4022 query = target_set_aux(y, x, mode, info);
4026 /* Cancel tracking */
4027 /* health_track(0); */
4029 /* Assume no "direction" */
4034 if (query == '\r') query = 't';
4052 if (target_able(c_ptr->m_idx))
4054 health_track(c_ptr->m_idx);
4055 target_who = c_ptr->m_idx;
4074 if (!expand_list) done = TRUE;
4084 if (!expand_list) done = TRUE;
4091 /* Recenter the map around the player */
4095 p_ptr->update |= (PU_MONSTERS);
4098 p_ptr->redraw |= (PR_MAP);
4101 p_ptr->window |= (PW_OVERHEAD);
4106 /* Recalculate interesting grids */
4107 target_set_prepare(mode);
4126 /* Extract the action (if any) */
4127 d = get_keymap_dir(query);
4134 /* Hack -- move around */
4137 /* Modified to scroll to monster */
4138 int y2 = panel_row_min;
4139 int x2 = panel_col_min;
4141 /* Find a new monster */
4142 i = target_pick(temp_y[m], temp_x[m], ddy[d], ddx[d]);
4144 /* Request to target past last interesting grid */
4145 while (flag && (i < 0))
4147 /* Note the change */
4148 if (change_panel(ddy[d], ddx[d]))
4153 /* Recalculate interesting grids */
4154 target_set_prepare(mode);
4156 /* Look at interesting grids */
4159 /* Find a new monster */
4160 i = target_pick(v, u, ddy[d], ddx[d]);
4166 /* Nothing interesting */
4172 /* Restore previous position */
4175 panel_bounds_center();
4178 p_ptr->update |= (PU_MONSTERS);
4181 p_ptr->redraw |= (PR_MAP);
4184 p_ptr->window |= (PW_OVERHEAD);
4189 /* Recalculate interesting grids */
4190 target_set_prepare(mode);
4192 /* Look at boring grids */
4199 /* Do not move horizontally if unnecessary */
4200 if (((x < panel_col_min + wid / 2) && (dx > 0)) ||
4201 ((x > panel_col_min + wid / 2) && (dx < 0)))
4206 /* Do not move vertically if unnecessary */
4207 if (((y < panel_row_min + hgt / 2) && (dy > 0)) ||
4208 ((y > panel_row_min + hgt / 2) && (dy < 0)))
4213 /* Apply the motion */
4214 if ((y >= panel_row_min+hgt) || (y < panel_row_min) ||
4215 (x >= panel_col_min+wid) || (x < panel_col_min))
4217 if (change_panel(dy, dx)) target_set_prepare(mode);
4220 /* Slide into legality */
4221 if (x >= cur_wid-1) x = cur_wid - 2;
4222 else if (x <= 0) x = 1;
4224 /* Slide into legality */
4225 if (y >= cur_hgt-1) y = cur_hgt- 2;
4226 else if (y <= 0) y = 1;
4235 /* Arbitrary grids */
4238 bool move_fast = FALSE;
4240 if (!(mode & TARGET_LOOK)) prt_path(y, x);
4243 c_ptr = &cave[y][x];
4245 /* Default prompt */
4247 strcpy(info, "q»ß t·è p¼« m¶á +¼¡ -Á°");
4249 strcpy(info, "q,t,p,m,+,-,<dir>");
4253 /* Describe and Prompt (enable "TARGET_LOOK") */
4254 while (!(query = target_set_aux(y, x, mode | TARGET_LOOK, info)));
4256 /* Cancel tracking */
4257 /* health_track(0); */
4259 /* Assume no direction */
4264 if (query == '\r') query = 't';
4267 /* Analyze the keypress */
4291 /* Recenter the map around the player */
4295 p_ptr->update |= (PU_MONSTERS);
4298 p_ptr->redraw |= (PR_MAP);
4301 p_ptr->window |= (PW_OVERHEAD);
4306 /* Recalculate interesting grids */
4307 target_set_prepare(mode);
4329 /* Pick a nearby monster */
4330 for (i = 0; i < temp_n; i++)
4332 t = distance(y, x, temp_y[i], temp_x[i]);
4342 /* Nothing interesting */
4343 if (bd == 999) flag = FALSE;
4350 /* Extract the action (if any) */
4351 d = get_keymap_dir(query);
4353 /* XTRA HACK MOVEFAST */
4354 if (isupper(query)) move_fast = TRUE;
4361 /* Handle "direction" */
4367 /* XTRA HACK MOVEFAST */
4370 int mag = MIN(wid / 2, hgt / 2);
4380 /* Do not move horizontally if unnecessary */
4381 if (((x < panel_col_min + wid / 2) && (dx > 0)) ||
4382 ((x > panel_col_min + wid / 2) && (dx < 0)))
4387 /* Do not move vertically if unnecessary */
4388 if (((y < panel_row_min + hgt / 2) && (dy > 0)) ||
4389 ((y > panel_row_min + hgt / 2) && (dy < 0)))
4394 /* Apply the motion */
4395 if ((y >= panel_row_min + hgt) || (y < panel_row_min) ||
4396 (x >= panel_col_min + wid) || (x < panel_col_min))
4398 if (change_panel(dy, dx)) target_set_prepare(mode);
4401 /* Slide into legality */
4402 if (x >= cur_wid-1) x = cur_wid - 2;
4403 else if (x <= 0) x = 1;
4405 /* Slide into legality */
4406 if (y >= cur_hgt-1) y = cur_hgt- 2;
4407 else if (y <= 0) y = 1;
4415 /* Clear the top line */
4418 /* Recenter the map around the player */
4422 p_ptr->update |= (PU_MONSTERS);
4425 p_ptr->redraw |= (PR_MAP);
4428 p_ptr->window |= (PW_OVERHEAD);
4433 /* Failure to set target */
4434 if (!target_who) return (FALSE);
4442 * Get an "aiming direction" from the user.
4444 * The "dir" is loaded with 1,2,3,4,6,7,8,9 for "actual direction", and
4445 * "0" for "current target", and "-1" for "entry aborted".
4447 * Note that "Force Target", if set, will pre-empt user interaction,
4448 * if there is a usable target already set.
4450 * Note that confusion over-rides any (explicit?) user choice.
4452 bool get_aim_dir(int *dp)
4463 /* Global direction */
4466 /* Hack -- auto-target if requested */
4467 if (use_old_target && target_okay()) dir = 5;
4469 #ifdef ALLOW_REPEAT /* TNB */
4471 if (repeat_pull(dp))
4476 if (!(*dp == 5 && !target_okay()))
4478 /* return (TRUE); */
4483 #endif /* ALLOW_REPEAT -- TNB */
4485 /* Ask until satisfied */
4488 /* Choose a prompt */
4492 p = "Êý¸þ ('*'¤Ç¥¿¡¼¥²¥Ã¥ÈÁªÂò, ESC¤ÇÃæÃÇ)? ";
4494 p = "Direction ('*' to choose a target, Escape to cancel)? ";
4501 p = "Êý¸þ ('5'¤Ç¥¿¡¼¥²¥Ã¥È¤Ø, '*'¤Ç¥¿¡¼¥²¥Ã¥ÈºÆÁªÂò, ESC¤ÇÃæÃÇ)? ";
4503 p = "Direction ('5' for target, '*' to re-target, Escape to cancel)? ";
4508 /* Get a command (or Cancel) */
4509 if (!get_com(p, &command, TRUE)) break;
4513 if (command == '\r') command = 't';
4516 /* Convert various keys to "standard" keys */
4519 /* Use current target */
4530 /* Set new target */
4535 if (target_set(TARGET_KILL)) dir = 5;
4541 /* Extract the action (if any) */
4542 dir = get_keymap_dir(command);
4548 /* Verify requested targets */
4549 if ((dir == 5) && !target_okay()) dir = 0;
4558 project_length = 0; /* reset to default */
4562 /* Save the direction */
4565 /* Check for confusion */
4566 if (p_ptr->confused)
4569 /* Random direction */
4570 dir = ddd[randint0(8)];
4573 /* Notice confusion */
4574 if (command_dir != dir)
4578 msg_print("¤¢¤Ê¤¿¤Ïº®Í𤷤Ƥ¤¤ë¡£");
4580 msg_print("You are confused.");
4585 /* Save direction */
4588 #ifdef ALLOW_REPEAT /* TNB */
4590 /* repeat_push(dir); */
4591 repeat_push(command_dir);
4593 #endif /* ALLOW_REPEAT -- TNB */
4595 /* A "valid" direction was entered */
4602 * Request a "movement" direction (1,2,3,4,6,7,8,9) from the user,
4603 * and place it into "command_dir", unless we already have one.
4605 * This function should be used for all "repeatable" commands, such as
4606 * run, walk, open, close, bash, disarm, spike, tunnel, etc, as well
4607 * as all commands which must reference a grid adjacent to the player,
4608 * and which may not reference the grid under the player. Note that,
4609 * for example, it is no longer possible to "disarm" or "open" chests
4610 * in the same grid as the player.
4612 * Direction "5" is illegal and will (cleanly) abort the command.
4614 * This function tracks and uses the "global direction", and uses
4615 * that as the "desired direction", to which "confusion" is applied.
4617 bool get_rep_dir(int *dp, bool under)
4625 /* Global direction */
4628 #ifdef ALLOW_REPEAT /* TNB */
4630 if (repeat_pull(dp))
4633 /* return (TRUE); */
4636 #endif /* ALLOW_REPEAT -- TNB */
4640 prompt = _("Êý¸þ ('.'¸µ, ESC¤ÇÃæÃÇ)? ", "Direction ('.' at feet, Escape to cancel)? ");
4644 prompt = _("Êý¸þ (ESC¤ÇÃæÃÇ)? ", "Direction (Escape to cancel)? ");
4647 /* Get a direction */
4652 /* Get a command (or Cancel) */
4653 if (!get_com(prompt, &ch, TRUE)) break;
4656 if ((under) && ((ch == '5') || (ch == '-') || (ch == '.')))
4662 /* Look up the direction */
4663 dir = get_keymap_dir(ch);
4670 /* Prevent weirdness */
4671 if ((dir == 5) && (!under)) dir = 0;
4674 if (!dir) return (FALSE);
4676 /* Save desired direction */
4679 /* Apply "confusion" */
4680 if (p_ptr->confused)
4682 /* Standard confusion */
4683 if (randint0(100) < 75)
4685 /* Random direction */
4686 dir = ddd[randint0(8)];
4689 else if (p_ptr->riding)
4691 monster_type *m_ptr = &m_list[p_ptr->riding];
4692 monster_race *r_ptr = &r_info[m_ptr->r_idx];
4694 if (MON_CONFUSED(m_ptr))
4696 /* Standard confusion */
4697 if (randint0(100) < 75)
4699 /* Random direction */
4700 dir = ddd[randint0(8)];
4703 else if ((r_ptr->flags1 & RF1_RAND_50) && (r_ptr->flags1 & RF1_RAND_25) && (randint0(100) < 50))
4705 /* Random direction */
4706 dir = ddd[randint0(8)];
4708 else if ((r_ptr->flags1 & RF1_RAND_50) && (randint0(100) < 25))
4710 /* Random direction */
4711 dir = ddd[randint0(8)];
4715 /* Notice confusion */
4716 if (command_dir != dir)
4718 if (p_ptr->confused)
4722 msg_print("¤¢¤Ê¤¿¤Ïº®Í𤷤Ƥ¤¤ë¡£");
4724 msg_print("You are confused.");
4730 monster_type *m_ptr = &m_list[p_ptr->riding];
4732 monster_desc(m_name, m_ptr, 0);
4733 if (MON_CONFUSED(m_ptr))
4736 msg_format("%s¤Ïº®Í𤷤Ƥ¤¤ë¡£", m_name);
4738 msg_format("%^s is confusing.", m_name);
4745 msg_format("%s¤Ï»×¤¤Ä̤ê¤ËÆ°¤¤¤Æ¤¯¤ì¤Ê¤¤¡£", m_name);
4747 msg_format("You cannot control %s.", m_name);
4753 /* Save direction */
4756 #ifdef ALLOW_REPEAT /* TNB */
4758 /* repeat_push(dir); */
4759 repeat_push(command_dir);
4761 #endif /* ALLOW_REPEAT -- TNB */
4768 bool get_rep_dir2(int *dp)
4775 /* Global direction */
4778 #ifdef ALLOW_REPEAT /* TNB */
4780 if (repeat_pull(dp))
4783 /* return (TRUE); */
4786 #endif /* ALLOW_REPEAT -- TNB */
4788 /* Get a direction */
4793 /* Get a command (or Cancel) */
4795 if (!get_com("Êý¸þ (ESC¤ÇÃæÃÇ)? ", &ch, TRUE)) break;
4797 if (!get_com("Direction (Escape to cancel)? ", &ch, TRUE)) break;
4801 /* Look up the direction */
4802 dir = get_keymap_dir(ch);
4808 /* Prevent weirdness */
4809 if (dir == 5) dir = 0;
4812 if (!dir) return (FALSE);
4814 /* Save desired direction */
4817 /* Apply "confusion" */
4818 if (p_ptr->confused)
4820 /* Standard confusion */
4821 if (randint0(100) < 75)
4823 /* Random direction */
4824 dir = ddd[randint0(8)];
4828 /* Notice confusion */
4829 if (command_dir != dir)
4833 msg_print("¤¢¤Ê¤¿¤Ïº®Í𤷤Ƥ¤¤ë¡£");
4835 msg_print("You are confused.");
4840 /* Save direction */
4843 #ifdef ALLOW_REPEAT /* TNB */
4845 /* repeat_push(dir); */
4846 repeat_push(command_dir);
4848 #endif /* ALLOW_REPEAT -- TNB */
4854 void gain_level_reward(int chosen_reward)
4858 char wrath_reason[32] = "";
4859 int nasty_chance = 6;
4860 int dummy = 0, dummy2 = 0;
4863 char o_name[MAX_NLEN];
4869 if (multi_rew) return;
4870 else multi_rew = TRUE;
4874 if (p_ptr->lev == 13) nasty_chance = 2;
4875 else if (!(p_ptr->lev % 13)) nasty_chance = 3;
4876 else if (!(p_ptr->lev % 14)) nasty_chance = 12;
4878 if (one_in_(nasty_chance))
4879 type = randint1(20); /* Allow the 'nasty' effects */
4881 type = randint1(15) + 5; /* Or disallow them */
4883 if (type < 1) type = 1;
4884 if (type > 20) type = 20;
4889 sprintf(wrath_reason, "%s¤ÎÅܤê",
4890 chaos_patrons[p_ptr->chaos_patron]);
4892 sprintf(wrath_reason, "the Wrath of %s",
4893 chaos_patrons[p_ptr->chaos_patron]);
4897 effect = chaos_rewards[p_ptr->chaos_patron][type];
4899 if (one_in_(6) && !chosen_reward)
4902 msg_format("%^s¤ÏË«Èþ¤È¤·¤Æ¤¢¤Ê¤¿¤òÆÍÁ³ÊÑ°Û¤µ¤»¤¿¡£",
4903 chaos_patrons[p_ptr->chaos_patron]);
4905 msg_format("%^s rewards you with a mutation!",
4906 chaos_patrons[p_ptr->chaos_patron]);
4909 (void)gain_random_mutation(0);
4911 reward = "ÊÑ°Û¤·¤¿¡£";
4913 reward = "mutation";
4918 switch (chosen_reward ? chosen_reward : effect)
4922 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
4923 chaos_patrons[p_ptr->chaos_patron]);
4925 msg_format("The voice of %s booms out:",
4926 chaos_patrons[p_ptr->chaos_patron]);
4930 msg_print("¡ÖÆò¡¢¿·¤¿¤Ê¤ë»Ñ¤òɬÍפȤ»¤ê¡ª¡×");
4932 msg_print("'Thou needst a new form, mortal!'");
4937 reward = "ÊÑ°Û¤·¤¿¡£";
4939 reward = "polymorphing";
4944 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
4945 chaos_patrons[p_ptr->chaos_patron]);
4947 msg_format("The voice of %s booms out:",
4948 chaos_patrons[p_ptr->chaos_patron]);
4952 msg_print("¡ÖÆò¤ÏÎɤ¯¹Ô¤¤¤¿¤ê¡ªÂ³¤±¤è¡ª¡×");
4954 msg_print("'Well done, mortal! Lead on!'");
4957 if (p_ptr->prace == RACE_ANDROID)
4960 msg_print("¤·¤«¤·²¿¤âµ¯¤³¤é¤Ê¤«¤Ã¤¿¡£");
4962 msg_print("But, nothing happen.");
4965 else if (p_ptr->exp < PY_MAX_EXP)
4967 s32b ee = (p_ptr->exp / 2) + 10;
4968 if (ee > 100000L) ee = 100000L;
4970 msg_print("¹¹¤Ë·Ð¸³¤òÀѤó¤À¤è¤¦¤Êµ¤¤¬¤¹¤ë¡£");
4972 msg_print("You feel more experienced.");
4977 reward = "·Ð¸³ÃͤòÆÀ¤¿";
4979 reward = "experience";
4985 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
4986 chaos_patrons[p_ptr->chaos_patron]);
4988 msg_format("The voice of %s booms out:",
4989 chaos_patrons[p_ptr->chaos_patron]);
4993 msg_print("¡Ö²¼Ëͤ衢Æò¤½¤ì¤ËÃͤ»¤º¡£¡×");
4995 msg_print("'Thou didst not deserve that, slave.'");
4998 if (p_ptr->prace == RACE_ANDROID)
5001 msg_print("¤·¤«¤·²¿¤âµ¯¤³¤é¤Ê¤«¤Ã¤¿¡£");
5003 msg_print("But, nothing happen.");
5008 lose_exp(p_ptr->exp / 6);
5010 reward = "·Ð¸³Ãͤò¼º¤Ã¤¿¡£";
5012 reward = "losing experience";
5018 msg_format("%s¤ÎÀ¼¤¬¤µ¤µ¤ä¤¤¤¿:",
5019 chaos_patrons[p_ptr->chaos_patron]);
5021 msg_format("The voice of %s whispers:",
5022 chaos_patrons[p_ptr->chaos_patron]);
5026 msg_print("¡Ö²æ¤¬Í¿¤¨¤·Êª¤ò¸ÌÀ¤Ë»È¤¦¤Ù¤·¡£¡×");
5028 msg_print("'Use my gift wisely.'");
5031 acquirement(py, px, 1, FALSE, FALSE, FALSE);
5033 reward = "¾å¼Á¤Ê¥¢¥¤¥Æ¥à¤ò¼ê¤ËÆþ¤ì¤¿¡£";
5035 reward = "a good item";
5040 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5041 chaos_patrons[p_ptr->chaos_patron]);
5043 msg_format("The voice of %s booms out:",
5044 chaos_patrons[p_ptr->chaos_patron]);
5048 msg_print("¡Ö²æ¤¬Í¿¤¨¤·Êª¤ò¸ÌÀ¤Ë»È¤¦¤Ù¤·¡£¡×");
5050 msg_print("'Use my gift wisely.'");
5053 acquirement(py, px, 1, TRUE, FALSE, FALSE);
5055 reward = "¹âµéÉʤΥ¢¥¤¥Æ¥à¤ò¼ê¤ËÆþ¤ì¤¿¡£";
5057 reward = "an excellent item";
5062 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5063 chaos_patrons[p_ptr->chaos_patron]);
5065 msg_format("The voice of %s booms out:",
5066 chaos_patrons[p_ptr->chaos_patron]);
5070 msg_print("¡ÖÆò¤Î¹Ô¤¤¤Ïµ®¤·õ¤ËÃͤ»¤ê¡£¡×");
5072 msg_print("'Thy deed hath earned thee a worthy blade.'");
5075 /* Get local object */
5078 switch (randint1(p_ptr->lev))
5084 dummy2 = SV_MAIN_GAUCHE;
5093 dummy2 = SV_SMALL_SWORD;
5096 dummy2 = SV_BASILLARD;
5098 case 11: case 12: case 13:
5099 dummy2 = SV_SHORT_SWORD;
5105 dummy2 = SV_CUTLASS;
5108 dummy2 = SV_WAKIZASHI;
5111 dummy2 = SV_KHOPESH;
5117 dummy2 = SV_BROAD_SWORD;
5120 dummy2 = SV_LONG_SWORD;
5123 dummy2 = SV_SCIMITAR;
5126 dummy2 = SV_NINJATO;
5132 dummy2 = SV_BASTARD_SWORD;
5135 dummy2 = SV_GREAT_SCIMITAR;
5138 dummy2 = SV_CLAYMORE;
5141 dummy2 = SV_ESPADON;
5144 dummy2 = SV_TWO_HANDED_SWORD;
5147 dummy2 = SV_FLAMBERGE;
5150 dummy2 = SV_NO_DACHI;
5153 dummy2 = SV_EXECUTIONERS_SWORD;
5156 dummy2 = SV_ZWEIHANDER;
5159 dummy2 = SV_HAYABUSA;
5162 dummy2 = SV_BLADE_OF_CHAOS;
5165 object_prep(q_ptr, lookup_kind(dummy, dummy2));
5166 q_ptr->to_h = 3 + randint1(dun_level) % 10;
5167 q_ptr->to_d = 3 + randint1(dun_level) % 10;
5168 one_resistance(q_ptr);
5169 q_ptr->name2 = EGO_CHAOTIC;
5171 /* Drop it in the dungeon */
5172 (void)drop_near(q_ptr, -1, py, px);
5174 reward = "(º®ÆÙ)¤ÎÉð´ï¤ò¼ê¤ËÆþ¤ì¤¿¡£";
5176 reward = "chaos weapon";
5181 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5182 chaos_patrons[p_ptr->chaos_patron]);
5184 msg_format("The voice of %s booms out:",
5185 chaos_patrons[p_ptr->chaos_patron]);
5189 msg_print("¡ÖÆò¤Î¹Ô¤¤¤Ïµ®¤Ê󤤤ËÃͤ»¤ê¡£¡×");
5191 msg_print("'Thy deed hath earned thee a worthy reward.'");
5194 acquirement(py, px, randint1(2) + 1, FALSE, FALSE, FALSE);
5196 reward = "¾å¼Á¤Ê¥¢¥¤¥Æ¥à¤ò¼ê¤ËÆþ¤ì¤¿¡£";
5198 reward = "good items";
5203 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5204 chaos_patrons[p_ptr->chaos_patron]);
5206 msg_format("The voice of %s booms out:",
5207 chaos_patrons[p_ptr->chaos_patron]);
5211 msg_print("¡Ö²¼Ëͤ衢Æò¤Î¸¥¿È¤Ø¤Î²æ¤¬Àˤ·¤ß̵¤Ê󤤤ò¸«¤ë¤¬¤è¤¤¡£¡×");
5213 msg_print("'Behold, mortal, how generously I reward thy loyalty.'");
5216 acquirement(py, px, randint1(2) + 1, TRUE, FALSE, FALSE);
5218 reward = "¹âµéÉʤΥ¢¥¤¥Æ¥à¤ò¼ê¤ËÆþ¤ì¤¿¡£";
5220 reward = "excellent items";
5225 msg_format("%s¤ÎÀ¼¤¬¹ì¤ÅϤä¿:",
5226 chaos_patrons[p_ptr->chaos_patron]);
5228 msg_format("The voice of %s thunders:",
5229 chaos_patrons[p_ptr->chaos_patron]);
5233 msg_print("¡Ö²¼Ëͤ衢ÆòÐþËý¤Ê¤ê¡£¡×");
5235 msg_print("'Thou art growing arrogant, mortal.'");
5238 (void)activate_ty_curse(FALSE, &count);
5240 reward = "²Ò¡¹¤·¤¤¼ö¤¤¤ò¤«¤±¤é¤ì¤¿¡£";
5247 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5248 chaos_patrons[p_ptr->chaos_patron]);
5250 msg_format("The voice of %s booms out:",
5251 chaos_patrons[p_ptr->chaos_patron]);
5255 msg_print("¡Ö²æ¤¬²¼Ëͤ¿¤Á¤è¡¢¤«¤ÎÐþËý¤Ê¤ë¼Ô¤òÅݤ¹¤Ù¤·¡ª¡×");
5257 msg_print("'My pets, destroy the arrogant mortal!'");
5260 for (dummy = 0; dummy < randint1(5) + 1; dummy++)
5262 (void)summon_specific(0, py, px, dun_level, 0, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET));
5265 reward = "¥â¥ó¥¹¥¿¡¼¤ò¾¤´¤µ¤ì¤¿¡£";
5267 reward = "summoning hostile monsters";
5272 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5273 chaos_patrons[p_ptr->chaos_patron]);
5275 msg_format("The voice of %s booms out:",
5276 chaos_patrons[p_ptr->chaos_patron]);
5280 msg_print("¡ÖÆò¡¢¤è¤ê¶¯¤Å¨¤òɬÍפȤ»¤ê¡ª¡×");
5282 msg_print("'Thou needst worthier opponents!'");
5285 activate_hi_summon(py, px, FALSE);
5287 reward = "¥â¥ó¥¹¥¿¡¼¤ò¾¤´¤µ¤ì¤¿¡£";
5289 reward = "summoning many hostile monsters";
5294 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5295 chaos_patrons[p_ptr->chaos_patron]);
5297 msg_format("The voice of %s booms out:",
5298 chaos_patrons[p_ptr->chaos_patron]);
5302 msg_print("¡Ö»à¤ÈÇ˲õ¤³¤½²æ¤¬´î¤Ó¤Ê¤ê¡ª¡×");
5304 msg_print("'Death and destruction! This pleaseth me!'");
5309 reward = "¥«¥ª¥¹¤ÎÎϤ¬±²´¬¤¤¤¿¡£";
5311 reward = "calling chaos";
5316 msg_format("%s¤ÎÀ¼¤¬ÌĤê¶Á¤¤¤¿:",
5317 chaos_patrons[p_ptr->chaos_patron]);
5319 msg_format("The voice of %s rings out:",
5320 chaos_patrons[p_ptr->chaos_patron]);
5324 msg_print("¡Öα¤Þ¤ë¤Î¤À¡¢²¼Ëͤ衣;¤¬Æò¤ÎÆùÂΤòÃ䨤󡣡×");
5326 msg_print("'Stay, mortal, and let me mold thee.'");
5329 if (one_in_(3) && !(chaos_stats[p_ptr->chaos_patron] < 0))
5330 do_inc_stat(chaos_stats[p_ptr->chaos_patron]);
5332 do_inc_stat(randint0(6));
5334 reward = "ǽÎÏÃͤ¬¾å¤¬¤Ã¤¿¡£";
5336 reward = "increasing a stat";
5341 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5342 chaos_patrons[p_ptr->chaos_patron]);
5344 msg_format("The voice of %s booms out:",
5345 chaos_patrons[p_ptr->chaos_patron]);
5349 msg_print("¡Ö²¼Ëͤ衢;¤ÏÆò¤ËË°¤ß¤¿¤ê¡£¡×");
5351 msg_print("'I grow tired of thee, mortal.'");
5354 if (one_in_(3) && !(chaos_stats[p_ptr->chaos_patron] < 0))
5355 do_dec_stat(chaos_stats[p_ptr->chaos_patron]);
5357 (void)do_dec_stat(randint0(6));
5359 reward = "ǽÎÏÃͤ¬²¼¤¬¤Ã¤¿¡£";
5361 reward = "decreasing a stat";
5366 msg_format("%s¤ÎÀ¼¤¬¹ì¤ÅϤä¿:",
5367 chaos_patrons[p_ptr->chaos_patron]);
5369 msg_format("The voice of %s thunders:",
5370 chaos_patrons[p_ptr->chaos_patron]);
5374 msg_print("¡ÖÆò¡¢¸¬µõ¤¿¤ë¤³¤È¤ò³Ø¤Ö¤Ù¤·¡ª¡×");
5375 msg_print("¤¢¤Ê¤¿¤Ï°ÊÁ°¤è¤ê¼å¤¯¤Ê¤Ã¤¿¡ª");
5377 msg_print("'Thou needst a lesson in humility, mortal!'");
5378 msg_print("You feel less powerful!");
5381 for (dummy = 0; dummy < 6; dummy++)
5383 (void)dec_stat(dummy, 10 + randint1(15), TRUE);
5386 reward = "Á´Ç½ÎÏÃͤ¬²¼¤¬¤Ã¤¿¡£";
5388 reward = "decreasing all stats";
5393 msg_format("%s¤ÎÎϤ¬¿¨¤ì¤ë¤Î¤ò´¶¤¸¤¿¡£",
5395 msg_format("You feel the power of %s touch you.",
5398 chaos_patrons[p_ptr->chaos_patron]);
5401 reward = "½ý¤¬ÊѲ½¤·¤¿¡£";
5403 reward = "polymorphing wounds";
5408 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5409 chaos_patrons[p_ptr->chaos_patron]);
5411 msg_format("The voice of %s booms out:",
5412 chaos_patrons[p_ptr->chaos_patron]);
5416 msg_print("¡Ö²æ¤¬¤µ¤µ¤ä¤«¤Ê¤ë»òʪ¤ò¼õ¤±¤È¤ë¤¬¤è¤¤¡ª¡×");
5418 msg_print("'Receive this modest gift from me!'");
5421 for (dummy = 0; dummy < 6; dummy++)
5423 (void)do_inc_stat(dummy);
5426 reward = "Á´Ç½ÎÏÃͤ¬¾å¤¬¤Ã¤¿¡£";
5428 reward = "increasing all stats";
5433 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5434 chaos_patrons[p_ptr->chaos_patron]);
5436 msg_format("The voice of %s booms out:",
5437 chaos_patrons[p_ptr->chaos_patron]);
5441 msg_print("¡Ö¶ì¤·¤à¤¬¤è¤¤¡¢ÌµÇ½¤Ê¶ò¤«¼Ô¤è¡ª¡×");
5443 msg_print("'Suffer, pathetic fool!'");
5446 fire_ball(GF_DISINTEGRATE, 0, p_ptr->lev * 4, 4);
5447 take_hit(DAMAGE_NOESCAPE, p_ptr->lev * 4, wrath_reason, -1);
5449 reward = "ʬ²ò¤Îµå¤¬È¯À¸¤·¤¿¡£";
5451 reward = "generating disintegration ball";
5456 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5457 chaos_patrons[p_ptr->chaos_patron]);
5459 msg_format("The voice of %s booms out:",
5460 chaos_patrons[p_ptr->chaos_patron]);
5464 msg_print("¡Öᴤ뤬¤è¤¤¡¢²æ¤¬²¼Ëͤ衪¡×");
5466 msg_print("'Rise, my servant!'");
5470 (void)set_poisoned(0);
5472 (void)set_confused(0);
5477 for (dummy = 0; dummy < 6; dummy++)
5479 (void)do_res_stat(dummy);
5482 reward = "ÂÎÎϤ¬²óÉü¤·¤¿¡£";
5488 if (!buki_motteruka(INVEN_RARM) && !buki_motteruka(INVEN_LARM)) break;
5490 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5491 chaos_patrons[p_ptr->chaos_patron]);
5493 msg_format("The voice of %s booms out:",
5494 chaos_patrons[p_ptr->chaos_patron]);
5498 msg_print("¡ÖÆò¡¢Éð´ï¤ËÍê¤ë¤³¤È¤Ê¤«¤ì¡£¡×");
5500 msg_print("'Thou reliest too much on thy weapon.'");
5504 if (buki_motteruka(INVEN_LARM))
5507 if (buki_motteruka(INVEN_RARM) && one_in_(2)) dummy = INVEN_RARM;
5509 object_desc(o_name, &inventory[dummy], OD_NAME_ONLY);
5510 (void)curse_weapon(FALSE, dummy);
5512 reward = format("%s¤¬Ç˲õ¤µ¤ì¤¿¡£", o_name);
5514 reward = format("destroying %s", o_name);
5518 if (!inventory[INVEN_BODY].k_idx) break;
5520 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5521 chaos_patrons[p_ptr->chaos_patron]);
5523 msg_format("The voice of %s booms out:",
5524 chaos_patrons[p_ptr->chaos_patron]);
5528 msg_print("¡ÖÆò¡¢Ëɶñ¤ËÍê¤ë¤³¤È¤Ê¤«¤ì¡£¡×");
5530 msg_print("'Thou reliest too much on thine equipment.'");
5533 object_desc(o_name, &inventory[INVEN_BODY], OD_NAME_ONLY);
5534 (void)curse_armor();
5536 reward = format("%s¤¬Ç˲õ¤µ¤ì¤¿¡£", o_name);
5538 reward = format("destroying %s", o_name);
5543 msg_format("%s¤ÎÀ¼¤¬¤µ¤µ¤ä¤¤¤¿:",
5544 chaos_patrons[p_ptr->chaos_patron]);
5546 msg_format("The voice of %s whispers:",
5547 chaos_patrons[p_ptr->chaos_patron]);
5551 msg_print("¡Ö²æ¤òÅܤꤷ¤á¤¿ºá¤ò½þ¤¦¤Ù¤·¡£¡×");
5553 msg_print("'Now thou shalt pay for annoying me.'");
5556 switch (randint1(4))
5559 (void)activate_ty_curse(FALSE, &count);
5561 reward = "²Ò¡¹¤·¤¤¼ö¤¤¤ò¤«¤±¤é¤ì¤¿¡£";
5567 activate_hi_summon(py, px, FALSE);
5569 reward = "¥â¥ó¥¹¥¿¡¼¤ò¾¤´¤µ¤ì¤¿¡£";
5571 reward = "summoning hostile monsters";
5577 if (!buki_motteruka(INVEN_RARM) && !buki_motteruka(INVEN_LARM)) break;
5579 if (buki_motteruka(INVEN_LARM))
5582 if (buki_motteruka(INVEN_RARM) && one_in_(2)) dummy = INVEN_RARM;
5584 object_desc(o_name, &inventory[dummy], OD_NAME_ONLY);
5585 (void)curse_weapon(FALSE, dummy);
5587 reward = format("%s¤¬Ç˲õ¤µ¤ì¤¿¡£", o_name);
5589 reward = format("destroying %s", o_name);
5594 if (!inventory[INVEN_BODY].k_idx) break;
5595 object_desc(o_name, &inventory[INVEN_BODY], OD_NAME_ONLY);
5596 (void)curse_armor();
5598 reward = format("%s¤¬Ç˲õ¤µ¤ì¤¿¡£", o_name);
5600 reward = format("destroying %s", o_name);
5605 for (dummy = 0; dummy < 6; dummy++)
5607 (void)dec_stat(dummy, 10 + randint1(15), TRUE);
5610 reward = "Á´Ç½ÎÏÃͤ¬²¼¤¬¤Ã¤¿¡£";
5612 reward = "decreasing all stats";
5619 msg_format("%s¤ÎÀ¼¤¬¹ì¤ÅϤä¿:",
5621 msg_format("The voice of %s thunders:",
5624 chaos_patrons[p_ptr->chaos_patron]);
5626 msg_print("¡Ö»à¤Ì¤¬¤è¤¤¡¢²¼Ëͤ衪¡×");
5628 msg_print("'Die, mortal!'");
5631 take_hit(DAMAGE_LOSELIFE, p_ptr->lev * 4, wrath_reason, -1);
5632 for (dummy = 0; dummy < 6; dummy++)
5634 (void)dec_stat(dummy, 10 + randint1(15), FALSE);
5636 activate_hi_summon(py, px, FALSE);
5637 (void)activate_ty_curse(FALSE, &count);
5642 if (buki_motteruka(INVEN_RARM))
5645 if (buki_motteruka(INVEN_LARM) && one_in_(2)) dummy = INVEN_LARM;
5647 else if (buki_motteruka(INVEN_LARM)) dummy = INVEN_LARM;
5649 if (dummy) (void)curse_weapon(FALSE, dummy);
5651 if (one_in_(2)) (void)curse_armor();
5655 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5656 chaos_patrons[p_ptr->chaos_patron]);
5658 msg_format("The voice of %s booms out:",
5659 chaos_patrons[p_ptr->chaos_patron]);
5663 msg_print("¡Ö»à¤ÈÇ˲õ¤³¤½²æ¤¬´î¤Ó¤Ê¤ê¡ª¡×");
5665 msg_print("'Death and destruction! This pleaseth me!'");
5668 (void)destroy_area(py, px, 25, FALSE);
5670 reward = "¥À¥ó¥¸¥ç¥ó¤¬*Ç˲õ*¤µ¤ì¤¿¡£";
5672 reward = "*destruct*ing dungeon";
5677 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5678 chaos_patrons[p_ptr->chaos_patron]);
5680 msg_format("The voice of %s booms out:",
5681 chaos_patrons[p_ptr->chaos_patron]);
5685 msg_print("¡Ö²æ¡¢Æò¤ÎŨ¤òËõ»¦¤»¤ó¡ª¡×");
5687 msg_print("'Let me relieve thee of thine oppressors!'");
5690 (void)symbol_genocide(0, FALSE);
5692 reward = "¥â¥ó¥¹¥¿¡¼¤¬Ëõ»¦¤µ¤ì¤¿¡£";
5694 reward = "genociding monsters";
5699 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5700 chaos_patrons[p_ptr->chaos_patron]);
5702 msg_format("The voice of %s booms out:",
5703 chaos_patrons[p_ptr->chaos_patron]);
5707 msg_print("¡Ö²æ¡¢Æò¤ÎŨ¤òËõ»¦¤»¤ó¡ª¡×");
5709 msg_print("'Let me relieve thee of thine oppressors!'");
5712 (void)mass_genocide(0, FALSE);
5714 reward = "¥â¥ó¥¹¥¿¡¼¤¬Ëõ»¦¤µ¤ì¤¿¡£";
5716 reward = "genociding nearby monsters";
5721 msg_format("%s¤ÎÎϤ¬Å¨¤ò¹¶·â¤¹¤ë¤Î¤ò´¶¤¸¤¿¡ª",
5722 chaos_patrons[p_ptr->chaos_patron]);
5724 msg_format("You can feel the power of %s assault your enemies!",
5725 chaos_patrons[p_ptr->chaos_patron]);
5728 (void)dispel_monsters(p_ptr->lev * 4);
5732 msg_format("%s¤Ï¤¢¤Ê¤¿¤ò̵»ë¤·¤¿¡£",
5733 chaos_patrons[p_ptr->chaos_patron]);
5735 msg_format("%s ignores you.",
5736 chaos_patrons[p_ptr->chaos_patron]);
5742 msg_format("%s¤ÏË«Èþ¤È¤·¤Æ°Ëâ¤Î»È¤¤¤ò¤è¤³¤·¤¿¡ª",chaos_patrons[p_ptr->chaos_patron]);
5744 msg_format("%s rewards you with a demonic servant!",chaos_patrons[p_ptr->chaos_patron]);
5747 if (!summon_specific(-1, py, px, dun_level, SUMMON_DEMON, PM_FORCE_PET))
5749 msg_print("²¿¤â¸½¤ì¤Ê¤«¤Ã¤¿...");
5751 msg_print("Nobody ever turns up...");
5755 reward = "°Ë⤬¥Ú¥Ã¥È¤Ë¤Ê¤Ã¤¿¡£";
5757 reward = "a demonic servant";
5763 msg_format("%s¤ÏË«Èþ¤È¤·¤Æ»È¤¤¤ò¤è¤³¤·¤¿¡ª",chaos_patrons[p_ptr->chaos_patron]);
5765 msg_format("%s rewards you with a servant!",chaos_patrons[p_ptr->chaos_patron]);
5768 if (!summon_specific(-1, py, px, dun_level, 0, PM_FORCE_PET))
5770 msg_print("²¿¤â¸½¤ì¤Ê¤«¤Ã¤¿...");
5772 msg_print("Nobody ever turns up...");
5776 reward = "¥â¥ó¥¹¥¿¡¼¤¬¥Ú¥Ã¥È¤Ë¤Ê¤Ã¤¿¡£";
5778 reward = "a servant";
5784 msg_format("%s¤ÏË«Èþ¤È¤·¤Æ¥¢¥ó¥Ç¥Ã¥É¤Î»È¤¤¤ò¤è¤³¤·¤¿¡£",chaos_patrons[p_ptr->chaos_patron]);
5786 msg_format("%s rewards you with an undead servant!",chaos_patrons[p_ptr->chaos_patron]);
5789 if (!summon_specific(-1, py, px, dun_level, SUMMON_UNDEAD, PM_FORCE_PET))
5791 msg_print("²¿¤â¸½¤ì¤Ê¤«¤Ã¤¿...");
5793 msg_print("Nobody ever turns up...");
5797 reward = "¥¢¥ó¥Ç¥Ã¥É¤¬¥Ú¥Ã¥È¤Ë¤Ê¤Ã¤¿¡£";
5799 reward = "an undead servant";
5805 msg_format("%s¤ÎÀ¼¤¬¤É¤â¤Ã¤¿:",
5807 msg_format("The voice of %s stammers:",
5810 chaos_patrons[p_ptr->chaos_patron]);
5812 msg_format("¡Ö¤¢¡¼¡¢¤¢¡¼¡¢Åú¤¨¤Ï %d/%d¡£¼ÁÌä¤Ï²¿¡©¡×", type, effect);
5814 msg_format("'Uh... uh... the answer's %d/%d, what's the question?'", type, effect);
5822 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, format("¥Ñ¥È¥í¥ó¤ÎÊó½·¤Ç%s", reward));
5824 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, format("The patron rewards you with %s.", reward));
5831 * XAngband: determine if a given location is "interesting"
5832 * based on target_set_accept function.
5834 static bool tgt_pt_accept(int y, int x)
5839 if (!(in_bounds(y, x))) return (FALSE);
5841 /* Player grid is always interesting */
5842 if ((y == py) && (x == px)) return (TRUE);
5844 /* Handle hallucination */
5845 if (p_ptr->image) return (FALSE);
5847 /* Examine the grid */
5848 c_ptr = &cave[y][x];
5850 /* Interesting memorized features */
5851 if (c_ptr->info & (CAVE_MARK))
5854 if (cave_have_flag_grid(c_ptr, FF_LESS)) return (TRUE);
5855 if (cave_have_flag_grid(c_ptr, FF_MORE)) return (TRUE);
5857 /* Notice quest features */
5858 if (cave_have_flag_grid(c_ptr, FF_QUEST_ENTER)) return (TRUE);
5859 if (cave_have_flag_grid(c_ptr, FF_QUEST_EXIT)) return (TRUE);
5868 * XAngband: Prepare the "temp" array for "tget_pt"
5869 * based on target_set_prepare funciton.
5871 static void tgt_pt_prepare(void)
5875 /* Reset "temp" array */
5878 if (!expand_list) return;
5880 /* Scan the current panel */
5881 for (y = 1; y < cur_hgt; y++)
5883 for (x = 1; x < cur_wid; x++)
5885 /* Require "interesting" contents */
5886 if (!tgt_pt_accept(y, x)) continue;
5888 /* Save the location */
5895 /* Target the nearest monster for shooting */
5896 ang_sort_comp = ang_sort_comp_distance;
5897 ang_sort_swap = ang_sort_swap_distance;
5899 /* Sort the positions */
5900 ang_sort(temp_x, temp_y, temp_n);
5904 * old -- from PsiAngband.
5906 bool tgt_pt(int *x_ptr, int *y_ptr)
5910 bool success = FALSE;
5915 get_screen_size(&wid, &hgt);
5927 msg_print("¾ì½ê¤òÁª¤ó¤Ç¥¹¥Ú¡¼¥¹¥¡¼¤ò²¡¤·¤Æ²¼¤µ¤¤¡£");
5929 msg_print("Select a point and press space.");
5931 msg_flag = FALSE; /* prevents "-more-" message. */
5933 while ((ch != ESCAPE) && !success)
5935 bool move_fast = FALSE;
5937 move_cursor_relative(y, x);
5949 if (player_bold(y, x)) ch = 0;
5952 else success = TRUE;
5956 /* XAngband: Move cursor to stairs */
5959 if (expand_list && temp_n)
5962 int cx = (panel_col_min + panel_col_max) / 2;
5963 int cy = (panel_row_min + panel_row_max) / 2;
5967 /* Skip stairs which have defferent distance */
5968 for (; n < temp_n; ++ n)
5970 cave_type *c_ptr = &cave[temp_y[n]][temp_x[n]];
5972 if (cave_have_flag_grid(c_ptr, FF_STAIRS) &&
5973 cave_have_flag_grid(c_ptr, ch == '>' ? FF_MORE : FF_LESS))
5980 if (n == temp_n) /* Loop out taget list */
5985 verify_panel(); /* Move cursor to player */
5988 p_ptr->update |= (PU_MONSTERS);
5991 p_ptr->redraw |= (PR_MAP);
5994 p_ptr->window |= (PW_OVERHEAD);
5999 else /* move cursor to next stair and change panel */
6004 dy = 2 * (y - cy) / hgt;
6005 dx = 2 * (x - cx) / wid;
6006 if (dy || dx) change_panel(dy, dx);
6012 /* Look up the direction */
6013 d = get_keymap_dir(ch);
6015 /* XTRA HACK MOVEFAST */
6016 if (isupper(ch)) move_fast = TRUE;
6018 /* Handle "direction" */
6024 /* XTRA HACK MOVEFAST */
6027 int mag = MIN(wid / 2, hgt / 2);
6037 /* Do not move horizontally if unnecessary */
6038 if (((x < panel_col_min + wid / 2) && (dx > 0)) ||
6039 ((x > panel_col_min + wid / 2) && (dx < 0)))
6044 /* Do not move vertically if unnecessary */
6045 if (((y < panel_row_min + hgt / 2) && (dy > 0)) ||
6046 ((y > panel_row_min + hgt / 2) && (dy < 0)))
6051 /* Apply the motion */
6052 if ((y >= panel_row_min + hgt) || (y < panel_row_min) ||
6053 (x >= panel_col_min + wid) || (x < panel_col_min))
6055 /* if (change_panel(dy, dx)) target_set_prepare(mode); */
6056 change_panel(dy, dx);
6059 /* Slide into legality */
6060 if (x >= cur_wid-1) x = cur_wid - 2;
6061 else if (x <= 0) x = 1;
6063 /* Slide into legality */
6064 if (y >= cur_hgt-1) y = cur_hgt- 2;
6065 else if (y <= 0) y = 1;
6072 /* Clear the top line */
6075 /* Recenter the map around the player */
6079 p_ptr->update |= (PU_MONSTERS);
6082 p_ptr->redraw |= (PR_MAP);
6085 p_ptr->window |= (PW_OVERHEAD);
6096 bool get_hack_dir(int *dp)
6106 /* Global direction */
6109 /* (No auto-targeting) */
6111 /* Ask until satisfied */
6114 /* Choose a prompt */
6118 p = "Êý¸þ ('*'¤Ç¥¿¡¼¥²¥Ã¥ÈÁªÂò, ESC¤ÇÃæÃÇ)? ";
6120 p = "Direction ('*' to choose a target, Escape to cancel)? ";
6127 p = "Êý¸þ ('5'¤Ç¥¿¡¼¥²¥Ã¥È¤Ø, '*'¤Ç¥¿¡¼¥²¥Ã¥ÈºÆÁªÂò, ESC¤ÇÃæÃÇ)? ";
6129 p = "Direction ('5' for target, '*' to re-target, Escape to cancel)? ";
6134 /* Get a command (or Cancel) */
6135 if (!get_com(p, &command, TRUE)) break;
6139 if (command == '\r') command = 't';
6142 /* Convert various keys to "standard" keys */
6145 /* Use current target */
6156 /* Set new target */
6161 if (target_set(TARGET_KILL)) dir = 5;
6167 /* Look up the direction */
6168 dir = get_keymap_dir(command);
6174 /* Verify requested targets */
6175 if ((dir == 5) && !target_okay()) dir = 0;
6182 if (!dir) return (FALSE);
6184 /* Save the direction */
6187 /* Check for confusion */
6188 if (p_ptr->confused)
6191 /* Random direction */
6192 dir = ddd[randint0(8)];
6195 /* Notice confusion */
6196 if (command_dir != dir)
6200 msg_print("¤¢¤Ê¤¿¤Ïº®Í𤷤Ƥ¤¤ë¡£");
6202 msg_print("You are confused.");
6207 /* Save direction */
6210 /* A "valid" direction was entered */
6216 * ¥¨¥Í¥ë¥®¡¼¤ÎÁý²ÃÎÌ10d5¤ò®¤¯·×»»¤¹¤ë¤¿¤á¤Î´Ø¿ô
6219 #define Go_no_JuuJou 5*5*5*5*5*5*5*5*5*5
6221 s16b gain_energy(void)
6224 s32b energy_result = 10;
6227 tmp = randint0(Go_no_JuuJou);
6229 for (i = 0; i < 9; i ++){
6230 energy_result += tmp % 5;
6234 return (s16b)(energy_result + tmp);
6241 s16b bow_energy(int sval)
6245 /* Analyze the launcher */
6248 /* Sling and ammo */
6255 /* Short Bow and Arrow */
6262 /* Long Bow and Arrow */
6269 /* Bow of irresponsiblity and Arrow */
6276 /* Light Crossbow and Bolt */
6283 /* Heavy Crossbow and Bolt */
6298 int bow_tmul(int sval)
6302 /* Analyze the launcher */
6305 /* Sling and ammo */
6312 /* Short Bow and Arrow */
6319 /* Long Bow and Arrow */
6326 /* Bow of irresponsiblity and Arrow */
6333 /* Light Crossbow and Bolt */
6340 /* Heavy Crossbow and Bolt */
6352 * Return alignment title
6354 cptr your_alignment(void)
6357 if (p_ptr->align > 150) return "ÂçÁ±";
6358 else if (p_ptr->align > 50) return "ÃæÁ±";
6359 else if (p_ptr->align > 10) return "¾®Á±";
6360 else if (p_ptr->align > -11) return "ÃæΩ";
6361 else if (p_ptr->align > -51) return "¾®°";
6362 else if (p_ptr->align > -151) return "Ãæ°";
6365 if (p_ptr->align > 150) return "Lawful";
6366 else if (p_ptr->align > 50) return "Good";
6367 else if (p_ptr->align > 10) return "Neutral Good";
6368 else if (p_ptr->align > -11) return "Neutral";
6369 else if (p_ptr->align > -51) return "Neutral Evil";
6370 else if (p_ptr->align > -151) return "Evil";
6371 else return "Chaotic";
6377 * Return proficiency level of weapons and misc. skills (except riding)
6379 int weapon_exp_level(int weapon_exp)
6381 if (weapon_exp < WEAPON_EXP_BEGINNER) return EXP_LEVEL_UNSKILLED;
6382 else if (weapon_exp < WEAPON_EXP_SKILLED) return EXP_LEVEL_BEGINNER;
6383 else if (weapon_exp < WEAPON_EXP_EXPERT) return EXP_LEVEL_SKILLED;
6384 else if (weapon_exp < WEAPON_EXP_MASTER) return EXP_LEVEL_EXPERT;
6385 else return EXP_LEVEL_MASTER;
6390 * Return proficiency level of riding
6392 int riding_exp_level(int riding_exp)
6394 if (riding_exp < RIDING_EXP_BEGINNER) return EXP_LEVEL_UNSKILLED;
6395 else if (riding_exp < RIDING_EXP_SKILLED) return EXP_LEVEL_BEGINNER;
6396 else if (riding_exp < RIDING_EXP_EXPERT) return EXP_LEVEL_SKILLED;
6397 else if (riding_exp < RIDING_EXP_MASTER) return EXP_LEVEL_EXPERT;
6398 else return EXP_LEVEL_MASTER;
6403 * Return proficiency level of spells
6405 int spell_exp_level(int spell_exp)
6407 if (spell_exp < SPELL_EXP_BEGINNER) return EXP_LEVEL_UNSKILLED;
6408 else if (spell_exp < SPELL_EXP_SKILLED) return EXP_LEVEL_BEGINNER;
6409 else if (spell_exp < SPELL_EXP_EXPERT) return EXP_LEVEL_SKILLED;
6410 else if (spell_exp < SPELL_EXP_MASTER) return EXP_LEVEL_EXPERT;
6411 else return EXP_LEVEL_MASTER;
6416 * Display a rumor and apply its effects
6419 int rumor_num(char *zz, int max_idx)
6421 if (strcmp(zz, "*") == 0) return randint1(max_idx - 1);
6425 cptr rumor_bind_name(char *base, cptr fullname)
6429 s = strstr(base, "{Name}");
6433 v = format("%s%s%s", base, fullname, (s + 6));
6443 void display_rumor(bool ex)
6451 if (randint0(3) == 0) section = 1;
6455 err = get_rnd_line_jonly("rumors_j.txt", section, Rumor, 10);
6456 if (err) strcpy(Rumor, "±³¤Î±½¤â¤¢¤ë¡£");
6458 err = get_rnd_line("rumors.txt", section, Rumor);
6459 if (err) strcpy(Rumor, "Some rumors are wrong.");
6464 if (strncmp(Rumor, "R:", 2) == 0)
6467 cptr rumor_msg = NULL;
6468 cptr rumor_eff_format = NULL;
6469 char fullname[1024] = "";
6471 if (tokenize(Rumor + 2, 3, zz, TOKENIZE_CHECKQUOTE) == 3)
6473 if (strcmp(zz[0], "ARTIFACT") == 0)
6477 object_type *q_ptr = &forge;
6478 artifact_type *a_ptr;
6482 a_idx = rumor_num(zz[1], max_a_idx);
6484 a_ptr = &a_info[a_idx];
6485 if (a_ptr->name) break;
6488 k_idx = lookup_kind(a_ptr->tval, a_ptr->sval);
6489 object_prep(q_ptr, k_idx);
6490 q_ptr->name1 = a_idx;
6491 q_ptr->ident = IDENT_STORE;
6492 object_desc(fullname, q_ptr, OD_NAME_ONLY);
6494 else if (strcmp(zz[0], "MONSTER") == 0)
6497 monster_race *r_ptr;
6501 r_idx = rumor_num(zz[1], max_r_idx);
6502 r_ptr = &r_info[r_idx];
6503 if (r_ptr->name) break;
6506 strcpy(fullname, r_name + r_ptr->name);
6508 /* Remember this monster */
6509 if (!r_ptr->r_sights)
6514 else if (strcmp(zz[0], "DUNGEON") == 0)
6517 dungeon_info_type *d_ptr;
6521 d_idx = rumor_num(zz[1], max_d_idx);
6522 d_ptr = &d_info[d_idx];
6523 if (d_ptr->name) break;
6526 strcpy(fullname, d_name + d_ptr->name);
6528 if (!max_dlv[d_idx])
6530 max_dlv[d_idx] = d_ptr->mindepth;
6531 rumor_eff_format = _("%s¤Ëµ¢´Ô¤Ç¤¤ë¤è¤¦¤Ë¤Ê¤Ã¤¿¡£", "You can recall to %s.");
6534 else if (strcmp(zz[0], "TOWN") == 0)
6541 t_idx = rumor_num(zz[1], NO_TOWN);
6542 if (town[t_idx].name) break;
6545 strcpy(fullname, town[t_idx].name);
6547 visit = (1L << (t_idx - 1));
6548 if ((t_idx != SECRET_TOWN) && !(p_ptr->visit & visit))
6550 p_ptr->visit |= visit;
6551 rumor_eff_format = _("%s¤Ë¹Ô¤Ã¤¿¤³¤È¤¬¤¢¤ëµ¤¤¬¤¹¤ë¡£", "You feel you have been to %s.");
6555 rumor_msg = rumor_bind_name(zz[2], fullname);
6556 msg_print(rumor_msg);
6557 if (rumor_eff_format)
6560 msg_format(rumor_eff_format, fullname);
6566 if (err) msg_print("¤³¤Î¾ðÊó¤Ï´Ö°ã¤Ã¤Æ¤¤¤ë¡£");
6568 if (err) msg_print("This information is wrong.");
6573 msg_format("%s", Rumor);