4 * Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke
6 * This software may be copied and distributed for educational, research,
7 * and not for profit purposes provided that this copyright and statement
8 * are included in all such copies. Other copyrights may also apply.
11 /* Purpose: effects of various "objects" */
15 #define REWARD_CHANCE 10
19 * Advance experience levels and print experience
21 void check_experience(void)
23 bool level_reward = FALSE;
24 bool level_mutation = FALSE;
25 bool level_inc_stat = FALSE;
26 bool android = (p_ptr->prace == RACE_ANDROID ? TRUE : FALSE);
29 /* Hack -- lower limit */
30 if (p_ptr->exp < 0) p_ptr->exp = 0;
32 /* Hack -- lower limit */
33 if (p_ptr->max_exp < 0) p_ptr->max_exp = 0;
35 /* Hack -- upper limit */
36 if (p_ptr->exp > PY_MAX_EXP) p_ptr->exp = PY_MAX_EXP;
38 /* Hack -- upper limit */
39 if (p_ptr->max_exp > PY_MAX_EXP) p_ptr->max_exp = PY_MAX_EXP;
41 /* Hack -- maintain "max" experience */
42 if (p_ptr->exp > p_ptr->max_exp) p_ptr->max_exp = p_ptr->exp;
44 /* Redraw experience */
45 p_ptr->redraw |= (PR_EXP);
51 /* Lose levels while possible */
52 while ((p_ptr->lev > 1) &&
53 (p_ptr->exp < ((android ? player_exp_a : player_exp)[p_ptr->lev - 2] * p_ptr->expfact / 100L)))
58 /* Update some stuff */
59 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
61 /* Redraw some stuff */
62 p_ptr->redraw |= (PR_LEV | PR_TITLE);
65 p_ptr->window |= (PW_PLAYER);
72 /* Gain levels while possible */
73 while ((p_ptr->lev < PY_MAX_LEVEL) &&
74 (p_ptr->exp >= ((android ? player_exp_a : player_exp)[p_ptr->lev-1] * p_ptr->expfact / 100L)))
79 /* Save the highest level */
80 if (p_ptr->lev > p_ptr->max_plv)
82 p_ptr->max_plv = p_ptr->lev;
84 if ((p_ptr->pclass == CLASS_CHAOS_WARRIOR) ||
85 (p_ptr->muta2 & MUT2_CHAOS_GIFT))
89 if (p_ptr->prace == RACE_BEASTMAN)
91 if (one_in_(5)) level_mutation = TRUE;
93 level_inc_stat = TRUE;
95 do_cmd_write_nikki(NIKKI_LEVELUP, p_ptr->lev, NULL);
103 msg_format("¥ì¥Ù¥ë %d ¤Ë¤è¤¦¤³¤½¡£", p_ptr->lev);
105 msg_format("Welcome to level %d.", p_ptr->lev);
108 /* Update some stuff */
109 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
111 /* Redraw some stuff */
112 p_ptr->redraw |= (PR_LEV | PR_TITLE);
115 p_ptr->window |= (PW_PLAYER | PW_SPELL);
117 /* HP¤ÈMP¤Î¾å¾ºÎ̤òɽ¼¨ */
127 if(!(p_ptr->max_plv % 10))
137 cnv_stat(p_ptr->stat_max[0], tmp);
138 prt(format(" a) ÏÓÎÏ (¸½ºßÃÍ %s)", tmp), 2, 14);
139 cnv_stat(p_ptr->stat_max[1], tmp);
140 prt(format(" b) ÃÎǽ (¸½ºßÃÍ %s)", tmp), 3, 14);
141 cnv_stat(p_ptr->stat_max[2], tmp);
142 prt(format(" c) ¸¤µ (¸½ºßÃÍ %s)", tmp), 4, 14);
143 cnv_stat(p_ptr->stat_max[3], tmp);
144 prt(format(" d) ´ïÍÑ (¸½ºßÃÍ %s)", tmp), 5, 14);
145 cnv_stat(p_ptr->stat_max[4], tmp);
146 prt(format(" e) ÂÑµ× (¸½ºßÃÍ %s)", tmp), 6, 14);
147 cnv_stat(p_ptr->stat_max[5], tmp);
148 prt(format(" f) Ì¥ÎÏ (¸½ºßÃÍ %s)", tmp), 7, 14);
150 prt(" ¤É¤ÎǽÎÏÃͤò¾å¤²¤Þ¤¹¤«¡©", 1, 14);
152 cnv_stat(p_ptr->stat_max[0], tmp);
153 prt(format(" a) Str (cur %s)", tmp), 2, 14);
154 cnv_stat(p_ptr->stat_max[1], tmp);
155 prt(format(" b) Int (cur %s)", tmp), 3, 14);
156 cnv_stat(p_ptr->stat_max[2], tmp);
157 prt(format(" c) Wis (cur %s)", tmp), 4, 14);
158 cnv_stat(p_ptr->stat_max[3], tmp);
159 prt(format(" d) Dex (cur %s)", tmp), 5, 14);
160 cnv_stat(p_ptr->stat_max[4], tmp);
161 prt(format(" e) Con (cur %s)", tmp), 6, 14);
162 cnv_stat(p_ptr->stat_max[5], tmp);
163 prt(format(" f) Chr (cur %s)", tmp), 7, 14);
165 prt(" Which stat do you want to raise?", 1, 14);
170 if ((choice >= 'a') && (choice <= 'f')) break;
172 for(n = 0; n < 6; n++)
173 if (n != choice - 'a')
176 if (get_check("¤è¤í¤·¤¤¤Ç¤¹¤«¡©")) break;
178 if (get_check("Are you sure? ")) break;
181 do_inc_stat(choice - 'a');
184 else if(!(p_ptr->max_plv % 2))
185 do_inc_stat(randint0(6));
191 msg_print("¤¢¤Ê¤¿¤ÏÊѤï¤Ã¤¿µ¤¤¬¤¹¤ë...");
193 msg_print("You feel different...");
196 (void)gain_random_mutation(0);
197 level_mutation = FALSE;
201 * Ê󽷤ǥì¥Ù¥ë¤¬¾å¤ë¤ÈºÆµ¢Åª¤Ë check_experience() ¤¬
202 * ¸Æ¤Ð¤ì¤ë¤Î¤Ç½çÈÖ¤òºÇ¸å¤Ë¤¹¤ë¡£
206 gain_level_reward(0);
207 level_reward = FALSE;
210 /* Update some stuff */
211 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
213 /* Redraw some stuff */
214 p_ptr->redraw |= (PR_LEV | PR_TITLE);
217 p_ptr->window |= (PW_PLAYER | PW_SPELL);
226 * Hack -- Return the "automatic coin type" of a monster race
227 * Used to allocate proper treasure when "Creeping coins" die
229 * XXX XXX XXX Note the use of actual "monster names"
231 static int get_coin_type(int r_idx)
233 monster_race *r_ptr = &r_info[r_idx];
235 /* Analyze "coin" monsters */
236 if (r_ptr->d_char == '$')
238 /* Look for textual clues */
241 case MON_COPPER_COINS: return (2);
242 case MON_SILVER_COINS: return (5);
243 case MON_GOLD_COINS: return (10);
244 case MON_MITHRIL_COINS: return (16);
245 case MON_ADAMANT_COINS: return (17);
255 * Hack -- determine if a template is Cloak
257 static bool kind_is_cloak(int k_idx)
259 object_kind *k_ptr = &k_info[k_idx];
261 /* Analyze the item type */
262 if (k_ptr->tval == TV_CLOAK)
267 /* Assume not good */
273 * Hack -- determine if a template is Polearm
275 static bool kind_is_polearm(int k_idx)
277 object_kind *k_ptr = &k_info[k_idx];
279 /* Analyze the item type */
280 if (k_ptr->tval == TV_POLEARM)
285 /* Assume not good */
291 * Hack -- determine if a template is Sword
293 static bool kind_is_sword(int k_idx)
295 object_kind *k_ptr = &k_info[k_idx];
297 /* Analyze the item type */
298 if ((k_ptr->tval == TV_SWORD) && (k_ptr->sval > 2))
303 /* Assume not good */
309 * Hack -- determine if a template is Book
311 static bool kind_is_book(int k_idx)
313 object_kind *k_ptr = &k_info[k_idx];
315 /* Analyze the item type */
316 if ((k_ptr->tval >= TV_LIFE_BOOK) && (k_ptr->tval <= TV_CRUSADE_BOOK))
321 /* Assume not good */
327 * Hack -- determine if a template is Good book
329 static bool kind_is_good_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) && (k_ptr->tval != TV_ARCANE_BOOK) && (k_ptr->sval > 1))
339 /* Assume not good */
345 * Hack -- determine if a template is Armor
347 static bool kind_is_armor(int k_idx)
349 object_kind *k_ptr = &k_info[k_idx];
351 /* Analyze the item type */
352 if (k_ptr->tval == TV_HARD_ARMOR)
357 /* Assume not good */
363 * Check for "Quest" completion when a quest monster is killed or charmed.
365 void check_quest_completion(monster_type *m_ptr)
367 int i, j, y, x, ny, nx, i2, j2;
371 bool create_stairs = FALSE;
377 /* Get the location */
382 quest_num = p_ptr->inside_quest;
384 /* Search for an active quest on this dungeon level */
387 for (i = max_quests - 1; i > 0; i--)
389 /* Quest is not active */
390 if (quest[i].status != QUEST_STATUS_TAKEN)
393 /* Quest is not a dungeon quest */
394 if (quest[i].flags & QUEST_FLAG_PRESET)
397 /* Quest is not on this level */
398 if ((quest[i].level != dun_level) &&
399 (quest[i].type != QUEST_TYPE_KILL_ANY_LEVEL))
402 /* Not a "kill monster" quest */
403 if ((quest[i].type == QUEST_TYPE_FIND_ARTIFACT) ||
404 (quest[i].type == QUEST_TYPE_FIND_EXIT))
407 /* Interesting quest */
408 if ((quest[i].type == QUEST_TYPE_KILL_NUMBER) ||
409 (quest[i].type == QUEST_TYPE_KILL_ALL))
412 /* Interesting quest */
413 if (((quest[i].type == QUEST_TYPE_KILL_LEVEL) ||
414 (quest[i].type == QUEST_TYPE_KILL_ANY_LEVEL) ||
415 (quest[i].type == QUEST_TYPE_RANDOM)) &&
416 (quest[i].r_idx == m_ptr->r_idx))
423 /* Handle the current quest */
424 if (quest_num && (quest[quest_num].status == QUEST_STATUS_TAKEN))
429 switch (quest[i].type)
431 case QUEST_TYPE_KILL_NUMBER:
435 if (quest[i].cur_num >= quest[i].num_mon)
437 if (record_fix_quest) do_cmd_write_nikki(NIKKI_FIX_QUEST_C, i, NULL);
438 /* completed quest */
439 quest[i].status = QUEST_STATUS_COMPLETED;
440 quest[i].complev = (byte)p_ptr->lev;
442 if (!(quest[i].flags & QUEST_FLAG_SILENT))
445 msg_print("¥¯¥¨¥¹¥È¤òãÀ®¤·¤¿¡ª");
447 msg_print("You just completed your quest!");
453 quest[i].cur_num = 0;
457 case QUEST_TYPE_KILL_ALL:
461 if (!is_hostile(m_ptr)) break;
463 /* Count all hostile monsters */
464 for (i2 = 0; i2 < cur_wid; ++i2)
465 for (j2 = 0; j2 < cur_hgt; j2++)
466 if (cave[j2][i2].m_idx > 0)
467 if (is_hostile(&m_list[cave[j2][i2].m_idx]))
470 if ((number_mon - 1) == 0)
472 if (record_fix_quest) do_cmd_write_nikki(NIKKI_FIX_QUEST_C, i, NULL);
474 if (quest[i].flags & QUEST_FLAG_SILENT)
476 quest[i].status = QUEST_STATUS_FINISHED;
480 quest[i].status = QUEST_STATUS_COMPLETED;
481 quest[i].complev = (byte)p_ptr->lev;
483 msg_print("¥¯¥¨¥¹¥È¤òãÀ®¤·¤¿¡ª");
485 msg_print("You just completed your quest!");
493 case QUEST_TYPE_KILL_LEVEL:
494 case QUEST_TYPE_RANDOM:
496 /* Only count valid monsters */
497 if (quest[i].r_idx != m_ptr->r_idx)
502 if (quest[i].cur_num >= quest[i].max_num)
504 if (record_fix_quest && (quest[i].type == QUEST_TYPE_KILL_LEVEL)) do_cmd_write_nikki(NIKKI_FIX_QUEST_C, i, NULL);
505 if (record_rand_quest && (quest[i].type == QUEST_TYPE_RANDOM)) do_cmd_write_nikki(NIKKI_RAND_QUEST_C, i, NULL);
506 /* completed quest */
507 quest[i].status = QUEST_STATUS_COMPLETED;
508 quest[i].complev = (byte)p_ptr->lev;
509 if (!(quest[i].flags & QUEST_FLAG_PRESET))
511 create_stairs = TRUE;
512 p_ptr->inside_quest = 0;
515 if (!(quest[i].flags & QUEST_FLAG_SILENT))
518 msg_print("¥¯¥¨¥¹¥È¤òãÀ®¤·¤¿¡ª");
520 msg_print("You just completed your quest!");
526 /* Finish the two main quests without rewarding */
527 if ((i == QUEST_OBERON) || (i == QUEST_SERPENT))
529 quest[i].status = QUEST_STATUS_FINISHED;
532 if (quest[i].type == QUEST_TYPE_RANDOM)
535 quest[i].status = QUEST_STATUS_FINISHED;
540 case QUEST_TYPE_KILL_ANY_LEVEL:
543 if (quest[i].cur_num >= quest[i].max_num)
545 if (record_fix_quest) do_cmd_write_nikki(NIKKI_FIX_QUEST_C, i, NULL);
546 /* completed quest */
547 quest[i].status = QUEST_STATUS_COMPLETED;
548 quest[i].complev = (byte)p_ptr->lev;
550 if (!(quest[i].flags & QUEST_FLAG_SILENT))
553 msg_print("¥¯¥¨¥¹¥È¤òãÀ®¤·¤¿¡ª");
555 msg_print("You just completed your quest!");
560 quest[i].cur_num = 0;
567 /* Create a magical staircase */
571 while (cave_perma_bold(y, x) || cave[y][x].o_idx || (cave[y][x].info & CAVE_OBJECT) )
573 /* Pick a location */
574 scatter(&ny, &nx, y, x, 1, 0);
580 /* Explain the staircase */
582 msg_print("ËâË¡¤Î³¬Ãʤ¬¸½¤ì¤¿...");
584 msg_print("A magical staircase appears...");
588 /* Create stairs down */
589 cave_set_feat(y, x, FEAT_MORE);
591 /* Remember to update everything */
592 p_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MONSTERS);
600 for (j = 0; j < (dun_level / 15)+1; j++)
602 /* Get local object */
605 /* Wipe the object */
608 /* Make a great object */
609 make_object(q_ptr, AM_GOOD | AM_GREAT);
611 /* Drop it in the dungeon */
612 (void)drop_near(q_ptr, -1, y, x);
618 * Handle the "death" of a monster.
620 * Disperse treasures centered at the monster location based on the
621 * various flags contained in the monster flags fields.
623 * Check for "Quest" completion when a quest monster is killed.
625 * Note that only the player can induce "monster_death()" on Uniques.
626 * Thus (for now) all Quest monsters should be Uniques.
628 * Note that monsters can now carry objects, and when a monster dies,
629 * it drops all of its objects, which may disappear in crowded rooms.
631 void monster_death(int m_idx, bool drop_item)
640 monster_type *m_ptr = &m_list[m_idx];
642 monster_race *r_ptr = &r_info[m_ptr->r_idx];
644 bool visible = (m_ptr->ml || (r_ptr->flags1 & RF1_UNIQUE));
648 bool do_gold = (!(r_ptr->flags1 & RF1_ONLY_ITEM));
649 bool do_item = (!(r_ptr->flags1 & RF1_ONLY_GOLD));
651 int force_coin = get_coin_type(m_ptr->r_idx);
656 bool drop_chosen_item = drop_item && !cloned && !p_ptr->inside_arena
657 && !p_ptr->inside_battle && !is_pet(m_ptr);
660 if (world_monster) world_monster = FALSE;
662 /* Notice changes in view */
663 if (r_ptr->flags7 & (RF7_HAS_LITE_1 | RF7_HAS_LITE_2 | RF7_SELF_LITE_1 | RF7_SELF_LITE_2))
665 /* Update some things */
666 p_ptr->update |= (PU_MON_LITE);
669 /* Get the location */
673 if (m_ptr->smart & SM_CLONED)
676 if (record_named_pet && is_pet(m_ptr) && m_ptr->nickname)
680 monster_desc(m_name, m_ptr, 0x08);
681 do_cmd_write_nikki(NIKKI_NAMED_PET, 3, m_name);
684 /* Let monsters explode! */
685 for (i = 0; i < 4; i++)
687 if (r_ptr->blow[i].method == RBM_EXPLODE)
689 int flg = PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL;
690 int typ = mbe_info[r_ptr->blow[i].effect].explode_type;
691 int d_dice = r_ptr->blow[i].d_dice;
692 int d_side = r_ptr->blow[i].d_side;
693 int damage = damroll(d_dice, d_side);
695 project(m_idx, 3, y, x, damage, typ, flg, -1);
700 if (m_ptr->mflag2 & MFLAG2_CHAMELEON)
702 choose_new_monster(m_idx, TRUE, MON_CHAMELEON);
703 r_ptr = &r_info[m_ptr->r_idx];
706 /* Check for quest completion */
707 check_quest_completion(m_ptr);
709 /* Handle the possibility of player vanquishing arena combatant -KMW- */
710 if (p_ptr->inside_arena && !is_pet(m_ptr))
714 /* Extract monster name */
715 monster_desc(m_name, m_ptr, 0);
717 p_ptr->exit_bldg = TRUE;
719 if (p_ptr->arena_number > MAX_ARENA_MONS)
722 msg_print("ÁÇÀ²¤é¤·¤¤¡ª·¯¤³¤½¿¿¤Î¾¡Íø¼Ô¤À¡£");
724 msg_print("You are a Genuine Champion!");
730 msg_print("¾¡Íø¡ª¥Á¥ã¥ó¥Ô¥ª¥ó¤Ø¤ÎÆ»¤ò¿Ê¤ó¤Ç¤¤¤ë¡£");
732 msg_print("Victorious! You're on your way to becoming Champion.");
736 if (arena_info[p_ptr->arena_number].tval)
738 /* Get local object */
741 /* Prepare to make a prize */
742 object_prep(q_ptr, lookup_kind(arena_info[p_ptr->arena_number].tval, arena_info[p_ptr->arena_number].sval));
744 apply_magic(q_ptr, object_level, AM_NO_FIXED_ART);
746 /* Drop it in the dungeon */
747 (void)drop_near(q_ptr, -1, y, x);
750 if (p_ptr->arena_number > MAX_ARENA_MONS) p_ptr->arena_number++;
751 p_ptr->arena_number++;
752 if (record_arena) do_cmd_write_nikki(NIKKI_ARENA, p_ptr->arena_number, m_name);
755 if (m_idx == p_ptr->riding)
757 if (rakuba(-1, FALSE))
760 msg_print("ÃÏÌ̤ËÍî¤È¤µ¤ì¤¿¡£");
762 msg_print("You have fallen from your riding pet.");
767 /* Drop a dead corpse? */
768 if (one_in_(r_ptr->flags1 & RF1_UNIQUE ? 1 : 4) &&
769 ((r_ptr->flags9 & RF9_DROP_CORPSE) ||
770 (r_ptr->flags9 & RF9_DROP_SKELETON)) &&
771 !(p_ptr->inside_arena || p_ptr->inside_battle || (m_ptr->smart & SM_CLONED) || ((m_ptr->r_idx == today_mon) && is_pet(m_ptr))))
773 /* Assume skeleton */
777 * We cannot drop a skeleton? Note, if we are in this check,
778 * we *know* we can drop at least a corpse or a skeleton
780 if (!(r_ptr->flags9 & RF9_DROP_SKELETON))
782 else if ((r_ptr->flags9 & RF9_DROP_CORPSE) && (r_ptr->flags1 && RF1_UNIQUE))
785 /* Else, a corpse is more likely unless we did a "lot" of damage */
786 else if (r_ptr->flags9 & RF9_DROP_CORPSE)
788 /* Lots of damage in one blow */
789 if ((0 - ((m_ptr->maxhp) / 4)) > m_ptr->hp)
791 if (one_in_(5)) corpse = TRUE;
795 if (!one_in_(5)) corpse = TRUE;
799 /* Get local object */
802 /* Prepare to make an object */
803 object_prep(q_ptr, lookup_kind(TV_CORPSE, (corpse ? SV_CORPSE : SV_SKELETON)));
805 apply_magic(q_ptr, object_level, AM_NO_FIXED_ART);
807 q_ptr->pval = m_ptr->r_idx;
809 /* Drop it in the dungeon */
810 (void)drop_near(q_ptr, -1, y, x);
813 /* Drop objects being carried */
814 monster_drop_carried_objects(m_ptr);
816 if (r_ptr->flags1 & RF1_DROP_GOOD) mo_mode |= AM_GOOD;
817 if (r_ptr->flags1 & RF1_DROP_GREAT) mo_mode |= AM_GREAT;
819 switch (m_ptr->r_idx)
821 case MON_PINK_HORROR:
822 /* Pink horrors are replaced with 2 Blue horrors */
823 if (!(p_ptr->inside_arena || p_ptr->inside_battle))
827 for (i = 0; i < 2; i++)
830 bool pet = is_pet(m_ptr);
833 if (pet) mode |= PM_FORCE_PET;
835 if (summon_specific((pet ? -1 : m_idx), wy, wx, 100, SUMMON_BLUE_HORROR, mode))
837 if (player_can_see_bold(wy, wx))
844 msg_print("¥Ô¥ó¥¯¡¦¥Û¥é¡¼¤ÏʬÎö¤·¤¿¡ª");
846 msg_print("The Pink horror divides!");
851 case MON_BLOODLETTER:
852 /* Bloodletters of Khorne may drop a blade of chaos */
853 if (drop_chosen_item && (randint1(100) < 15))
855 /* Get local object */
858 /* Prepare to make a Blade of Chaos */
859 object_prep(q_ptr, lookup_kind(TV_SWORD, SV_BLADE_OF_CHAOS));
861 apply_magic(q_ptr, object_level, AM_NO_FIXED_ART | mo_mode);
863 /* Drop it in the dungeon */
864 (void)drop_near(q_ptr, -1, y, x);
869 if (drop_chosen_item && (dun_level > 9))
871 /* Get local object */
874 /* Wipe the object */
877 /* Activate restriction */
878 if ((dun_level > 49) && one_in_(5))
879 get_obj_num_hook = kind_is_good_book;
881 get_obj_num_hook = kind_is_book;
883 /* Prepare allocation table */
887 make_object(q_ptr, mo_mode);
889 /* Drop it in the dungeon */
890 (void)drop_near(q_ptr, -1, y, x);
896 * Mega^3-hack: killing a 'Warrior of the Dawn' is likely to
897 * spawn another in the fallen one's place!
899 if (!p_ptr->inside_arena && !p_ptr->inside_battle)
903 int wy = py, wx = px;
905 bool pet = is_pet(m_ptr);
909 scatter(&wy, &wx, py, px, 20, 0);
911 while (!(in_bounds(wy, wx) && cave_floor_bold(wy, wx)) && --attempts);
916 if (pet) mode |= PM_FORCE_PET;
918 if (summon_specific((pet ? -1 : m_idx), wy, wx, 100, SUMMON_DAWN, mode))
920 if (player_can_see_bold(wy, wx))
922 msg_print("¿·¤¿¤ÊÀï»Î¤¬¸½¤ì¤¿¡ª");
924 msg_print("A new warrior steps forth!");
934 /* One more ultra-hack: An Unmaker goes out with a big bang! */
936 int flg = PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL;
937 (void)project(m_idx, 6, y, x, 100, GF_CHAOS, flg, -1);
941 case MON_UNICORN_ORD:
944 /* Reward for "lazy" player */
945 if (p_ptr->pseikaku == SEIKAKU_NAMAKE)
949 if (!drop_chosen_item) break;
956 a_idx = ART_NAMAKE_HAMMER;
959 a_idx = ART_NAMAKE_BOW;
962 a_idx = ART_NAMAKE_ARMOR;
966 while (a_info[a_idx].cur_num);
968 if (a_info[a_idx].cur_num == 0)
970 /* Create the artifact */
971 create_named_art(a_idx, y, x);
972 a_info[a_idx].cur_num = 1;
978 if (!drop_chosen_item) break;
980 /* Get local object */
983 /* Mega-Hack -- Prepare to make "Grond" */
984 object_prep(q_ptr, lookup_kind(TV_HAFTED, SV_GROND));
986 /* Mega-Hack -- Mark this item as "Grond" */
987 q_ptr->name1 = ART_GROND;
989 /* Mega-Hack -- Actually create "Grond" */
990 apply_magic(q_ptr, -1, AM_GOOD | AM_GREAT);
992 /* Drop it in the dungeon */
993 (void)drop_near(q_ptr, -1, y, x);
995 /* Get local object */
998 /* Mega-Hack -- Prepare to make "Chaos" */
999 object_prep(q_ptr, lookup_kind(TV_CROWN, SV_CHAOS));
1001 /* Mega-Hack -- Mark this item as "Chaos" */
1002 q_ptr->name1 = ART_CHAOS;
1004 /* Mega-Hack -- Actually create "Chaos" */
1005 apply_magic(q_ptr, -1, AM_GOOD | AM_GREAT);
1007 /* Drop it in the dungeon */
1008 (void)drop_near(q_ptr, -1, y, x);
1011 case MON_B_DEATH_SWORD:
1012 if (drop_chosen_item)
1014 /* Get local object */
1017 /* Prepare to make a broken sword */
1018 object_prep(q_ptr, lookup_kind(TV_SWORD, randint1(2)));
1020 /* Drop it in the dungeon */
1021 (void)drop_near(q_ptr, -1, y, x);
1027 if (drop_chosen_item && ((m_ptr->r_idx == MON_A_GOLD) ||
1028 ((m_ptr->r_idx == MON_A_SILVER) && !((r_ptr->r_pkills + 1) % 5))))
1030 /* Get local object */
1033 /* Prepare to make a Can of Toys */
1034 object_prep(q_ptr, lookup_kind(TV_CHEST, SV_CHEST_KANDUME));
1036 apply_magic(q_ptr, object_level, AM_NO_FIXED_ART);
1038 /* Drop it in the dungeon */
1039 (void)drop_near(q_ptr, -1, y, x);
1045 int flg = PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL;
1046 (void)project(m_idx, 3, y, x, damroll(20, 10), GF_FIRE, flg, -1);
1051 if (!drop_chosen_item) break;
1053 switch (r_ptr->d_char)
1058 /* Get local object */
1061 /* Wipe the object */
1064 /* Activate restriction */
1065 get_obj_num_hook = kind_is_cloak;
1067 /* Prepare allocation table */
1071 make_object(q_ptr, mo_mode);
1073 /* Drop it in the dungeon */
1074 (void)drop_near(q_ptr, -1, y, x);
1081 /* Get local object */
1084 /* Wipe the object */
1087 /* Activate restriction */
1088 get_obj_num_hook = kind_is_polearm;
1090 /* Prepare allocation table */
1093 /* Make a poleweapon */
1094 make_object(q_ptr, mo_mode);
1096 /* Drop it in the dungeon */
1097 (void)drop_near(q_ptr, -1, y, x);
1104 /* Get local object */
1107 /* Wipe the object */
1110 /* Activate restriction */
1111 get_obj_num_hook = kind_is_armor;
1113 /* Prepare allocation table */
1116 /* Make a hard armor */
1117 make_object(q_ptr, mo_mode);
1119 /* Drop it in the dungeon */
1120 (void)drop_near(q_ptr, -1, y, x);
1125 if (m_ptr->r_idx != MON_STORMBRINGER)
1127 /* Get local object */
1130 /* Wipe the object */
1133 /* Activate restriction */
1134 get_obj_num_hook = kind_is_sword;
1136 /* Prepare allocation table */
1140 make_object(q_ptr, mo_mode);
1142 /* Drop it in the dungeon */
1143 (void)drop_near(q_ptr, -1, y, x);
1150 /* Mega-Hack -- drop fixed items */
1151 if (drop_chosen_item)
1156 switch (m_ptr->r_idx)
1176 case MON_STORMBRINGER:
1177 a_idx = ART_STORMBRINGER;
1182 a_idx = ART_CRIMSON;
1192 a_idx = ART_KUSANAGI;
1222 a_idx = ART_WEREWINDLE;
1230 a_idx = ART_GRAYSWANDIR;
1241 a_idx = ART_TWILIGHT;
1246 a_idx = ART_ELENDIL;
1261 a_idx = ART_DESTINY;
1266 a_idx = ART_ZANTETSU;
1281 a_idx = ART_WINBLOWS;
1285 case MON_LUNGORTHIN:
1290 case MON_JACK_SHADOWS:
1296 a_idx = ART_STONEMASK;
1301 a_idx = ART_SOULCRUSH;
1306 a_idx = ART_EXCALIBUR_J;
1311 a_idx = ART_SHUTEN_DOJI;
1316 a_idx = ART_GOTHMOG;
1326 if ((a_idx > 0) && ((randint0(100) < chance) || p_ptr->wizard))
1328 if (a_info[a_idx].cur_num == 0)
1330 /* Create the artifact */
1331 create_named_art(a_idx, y, x);
1332 a_info[a_idx].cur_num = 1;
1336 if ((r_ptr->flags7 & RF7_GUARDIAN) && (d_info[dungeon_type].final_guardian == m_ptr->r_idx))
1338 int k_idx = d_info[dungeon_type].final_object ? d_info[dungeon_type].final_object
1339 : lookup_kind(TV_SCROLL, SV_SCROLL_ACQUIREMENT);
1341 if (d_info[dungeon_type].final_artifact)
1343 int a_idx = d_info[dungeon_type].final_artifact;
1344 if (!a_info[a_idx].cur_num)
1346 /* Create the artifact */
1347 create_named_art(a_idx, y, x);
1348 a_info[a_idx].cur_num = 1;
1350 /* Prevent rewarding both artifact and "default" object */
1351 if (!d_info[dungeon_type].final_object) k_idx = 0;
1357 /* Get local object */
1360 /* Prepare to make a reward */
1361 object_prep(q_ptr, k_idx);
1363 apply_magic(q_ptr, object_level, AM_NO_FIXED_ART | AM_GOOD);
1365 /* Drop it in the dungeon */
1366 (void)drop_near(q_ptr, -1, y, x);
1369 msg_format("¤¢¤Ê¤¿¤Ï%s¤òÀ©ÇƤ·¤¿¡ª",d_name+d_info[dungeon_type].name);
1371 msg_format("You have conquered %s!",d_name+d_info[dungeon_type].name);
1376 /* Determine how much we can drop */
1377 if ((r_ptr->flags1 & RF1_DROP_60) && (randint0(100) < 60)) number++;
1378 if ((r_ptr->flags1 & RF1_DROP_90) && (randint0(100) < 90)) number++;
1379 if (r_ptr->flags1 & RF1_DROP_1D2) number += damroll(1, 2);
1380 if (r_ptr->flags1 & RF1_DROP_2D2) number += damroll(2, 2);
1381 if (r_ptr->flags1 & RF1_DROP_3D2) number += damroll(3, 2);
1382 if (r_ptr->flags1 & RF1_DROP_4D2) number += damroll(4, 2);
1384 if (cloned && !(r_ptr->flags1 & RF1_UNIQUE))
1385 number = 0; /* Clones drop no stuff unless Cloning Pits */
1387 if (is_pet(m_ptr) || p_ptr->inside_battle || p_ptr->inside_arena)
1388 number = 0; /* Pets drop no stuff */
1389 if (!drop_item && (r_ptr->d_char != '$')) number = 0;
1391 /* Hack -- handle creeping coins */
1392 coin_type = force_coin;
1394 /* Average dungeon and monster levels */
1395 object_level = (dun_level + r_ptr->level) / 2;
1397 /* Drop some objects */
1398 for (j = 0; j < number; j++)
1400 /* Get local object */
1403 /* Wipe the object */
1407 if (do_gold && (!do_item || (randint0(100) < 50)))
1409 /* Make some gold */
1410 if (!make_gold(q_ptr)) continue;
1419 /* Make an object */
1420 if (!make_object(q_ptr, mo_mode)) continue;
1426 /* Drop it in the dungeon */
1427 (void)drop_near(q_ptr, -1, y, x);
1430 /* Reset the object level */
1431 object_level = base_level;
1433 /* Reset "coin" type */
1437 /* Take note of any dropped treasure */
1438 if (visible && (dump_item || dump_gold))
1440 /* Take notes on treasure */
1441 lore_treasure(m_idx, dump_item, dump_gold);
1444 /* Only process "Quest Monsters" */
1445 if (!(r_ptr->flags1 & RF1_QUESTOR)) return;
1446 if (p_ptr->inside_battle) return;
1449 if ((m_ptr->r_idx == MON_SERPENT) && !cloned)
1452 p_ptr->total_winner = TRUE;
1454 /* Redraw the "title" */
1455 p_ptr->redraw |= (PR_TITLE);
1458 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, "¸«»ö¤ËÊѶòÈÚÅܤξ¡Íø¼Ô¤È¤Ê¤Ã¤¿¡ª");
1460 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, "become *WINNER* of Hengband finely!");
1463 if ((p_ptr->pclass == CLASS_CHAOS_WARRIOR) || (p_ptr->muta2 & MUT2_CHAOS_GIFT))
1466 msg_format("%s¤«¤é¤ÎÀ¼¤¬¶Á¤¤¤¿¡£", chaos_patrons[p_ptr->chaos_patron]);
1467 msg_print("¡Ø¤è¤¯¤ä¤Ã¤¿¡¢ÄêÌ¿¤Î¼Ô¤è¡ª¡Ù");
1469 msg_format("The voice of %s booms out:", chaos_patrons[p_ptr->chaos_patron]);
1470 msg_print("'Thou art donst well, mortal!'");
1474 /* Congratulations */
1476 msg_print("*** ¤ª¤á¤Ç¤È¤¦ ***");
1478 msg_print("*** CONGRATULATIONS ***");
1482 msg_print("¤¢¤Ê¤¿¤Ï¥²¡¼¥à¤ò¥³¥ó¥×¥ê¡¼¥È¤·¤Þ¤·¤¿¡£");
1484 msg_print("You have won the game!");
1488 msg_print("½àÈ÷¤¬À°¤Ã¤¿¤é°úÂà(¼«»¦¥³¥Þ¥ó¥É)¤·¤Æ¤â·ë¹½¤Ç¤¹¡£");
1490 msg_print("You may retire (commit suicide) when you are ready.");
1496 * Modify the physical damage done to the monster.
1497 * (for example when it's invulnerable or shielded)
1499 * ToDo: Accept a damage-type to calculate the modified damage from
1500 * things like fire, frost, lightning, poison, ... attacks.
1502 * "type" is not yet used and should be 0.
1504 int mon_damage_mod(monster_type *m_ptr, int dam, bool is_psy_spear)
1506 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1508 if ((r_ptr->flags3 & RF3_RES_ALL) && dam > 0)
1511 if((dam == 0) && one_in_(3)) dam = 1;
1514 if (m_ptr->invulner)
1518 if(!p_ptr->blind && m_ptr->ml)
1521 msg_print("¥Ð¥ê¥¢¤òÀÚ¤êÎö¤¤¤¿¡ª");
1523 msg_print("The barrier is penetrated!");
1527 else if (!one_in_(PENETRATE_INVULNERABILITY))
1535 static void get_exp_from_mon(int dam, monster_type *m_ptr)
1537 s32b div, new_exp, new_exp_frac;
1538 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1539 int monnum_penarty = 0;
1541 if (!m_ptr->r_idx) return;
1542 if (is_pet(m_ptr) || p_ptr->inside_battle) return;
1546 u32b m_exp_h, m_exp_l;
1548 if ((r_ptr->flags2 & RF2_MULTIPLY) || (m_ptr->r_idx == MON_DAWN))
1550 monnum_penarty = r_ptr->r_pkills / 400;
1551 if (monnum_penarty > 8) monnum_penarty = 8;
1553 if (r_ptr->flags1 & RF1_UNIQUE)
1555 m_exp = (long)r_ptr->mexp * r_ptr->level;
1556 div = (p_ptr->max_plv+2);
1560 m_exp = (long)r_ptr->mexp * r_ptr->level * SPEED_TO_ENERGY(m_ptr->mspeed);
1561 div = (p_ptr->max_plv+2) * SPEED_TO_ENERGY(r_ptr->speed);
1563 m_exp_h = m_exp/0x10000L;
1564 m_exp_l = m_exp%0x10000L;
1567 m_exp_h += m_exp_l / 0x10000L;
1568 m_exp_l %= 0x10000L;
1570 /* real monster maxhp have effect on EXP */
1571 if(!(r_ptr->flags1 & RF1_FORCE_MAXHP))
1573 u32b maxhp = m_ptr->max_maxhp*2;
1576 m_exp_h += m_exp_l / 0x10000L;
1577 m_exp_l %= 0x10000L;
1579 div *= r_ptr->hdice * (r_ptr->hside + 1);
1581 if (!dun_level && (!(r_ptr->flags8 & RF8_WILD_ONLY) || !(r_ptr->flags1 & RF1_UNIQUE))) div *= 5;
1582 div_h = div/0x10000L;
1583 div_l = div%0x10000L;
1584 div_h *= (m_ptr->max_maxhp*2);
1585 div_l *= (m_ptr->max_maxhp*2);
1586 div_h += div_l / 0x10000L;
1589 while (monnum_penarty)
1593 div_h += div_l / 0x10000L;
1598 m_exp_l = (0x7fffffff & (m_exp_h << 16)) | m_exp_l;
1599 m_exp_h = m_exp_h >> 15;
1600 div_l = (0x7fffffff & (div_h << 16)) | div_l;
1601 div_h = div_h >> 15;
1603 #define M_INT_GREATER63(h1,l1,h2,l2) ( (h1>h2)||( (h1==h2)&&(l1>=l2)))
1604 #define M_INT_SUB63(h1,l1, h2,l2) {h1-=h2;if(l1<l2){l1+=0x80000000;h1--;}l1-=l2;}
1605 #define M_INT_LSHIFT63(h1,l1) {h1=(h1<<1)|(l1>>30);l1=(l1<<1)&0x7fffffff;}
1606 #define M_INT_RSHIFT63(h1,l1) {l1=(l1>>1)|(h1<<30);h1>>=1;}
1607 #define M_INT_DIV63(h1,l1,h2,l2,result) \
1611 while( M_INT_GREATER63(h1,l1, h2, l2) ){M_INT_LSHIFT63(h2, l2); bit<<=1;} \
1612 for(bit>>=1; bit>=1; bit>>=1){ \
1613 M_INT_RSHIFT63(h2, l2); \
1614 if(M_INT_GREATER63(h1, l1, h2, l2)) \
1615 {result|=bit;M_INT_SUB63(h1, l1, h2, l2);} \
1619 /* Give some experience for the kill */
1620 M_INT_DIV63(m_exp_h, m_exp_l, div_h, div_l, new_exp);
1622 /* Handle fractional experience */
1623 /* multiply 0x10000L to remainder */
1624 m_exp_h = (m_exp_h<<16) | (m_exp_l>>15);
1626 M_INT_DIV63(m_exp_h, m_exp_l, div_h, div_l, new_exp_frac);
1627 new_exp_frac += p_ptr->exp_frac;
1628 /* Keep track of experience */
1629 if (new_exp_frac >= 0x10000L)
1632 p_ptr->exp_frac = (u16b)(new_exp_frac - 0x10000L);
1636 p_ptr->exp_frac = (u16b)new_exp_frac;
1639 /* Gain experience */
1647 * Decreases monsters hit points, handling monster death.
1649 * We return TRUE if the monster has been killed (and deleted).
1651 * We announce monster death (using an optional "death message"
1652 * if given, and a otherwise a generic killed/destroyed message).
1654 * Only "physical attacks" can induce the "You have slain" message.
1655 * Missile and Spell attacks will induce the "dies" message, or
1656 * various "specialized" messages. Note that "You have destroyed"
1657 * and "is destroyed" are synonyms for "You have slain" and "dies".
1659 * Hack -- unseen monsters yield "You have killed it." message.
1661 * Added fear (DGK) and check whether to print fear messages -CWS
1663 * Made name, sex, and capitalization generic -BEN-
1665 * As always, the "ghost" processing is a total hack.
1667 * Hack -- we "delay" fear messages by passing around a "fear" flag.
1669 * XXX XXX XXX Consider decreasing monster experience over time, say,
1670 * by using "(m_exp * m_lev * (m_lev)) / (p_lev * (m_lev + n_killed))"
1671 * instead of simply "(m_exp * m_lev) / (p_lev)", to make the first
1672 * monster worth more than subsequent monsters. This would also need
1673 * to induce changes in the monster recall code.
1675 bool mon_take_hit(int m_idx, int dam, bool *fear, cptr note)
1677 monster_type *m_ptr = &m_list[m_idx];
1678 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1680 monster_type exp_mon;
1682 /* Innocent until proven otherwise */
1683 bool innocent = TRUE, thief = FALSE;
1687 COPY(&exp_mon, m_ptr, monster_type);
1688 if (!(r_ptr->flags7 & RF7_KILL_EXP))
1690 expdam = (m_ptr->hp > dam) ? dam : m_ptr->hp;
1691 if (r_ptr->flags6 & RF6_HEAL) expdam = (expdam+1) * 2 / 3;
1693 get_exp_from_mon(expdam, &exp_mon);
1696 /* Redraw (later) if needed */
1697 if (p_ptr->health_who == m_idx) p_ptr->redraw |= (PR_HEALTH);
1698 if (p_ptr->riding == m_idx) p_ptr->redraw |= (PR_UHEALTH);
1703 /* Hack - Cancel any special player stealth magics. -LM- */
1704 if (p_ptr->special_defense & NINJA_S_STEALTH)
1706 set_superstealth(FALSE);
1712 /* It is dead now */
1717 if (r_info[m_ptr->r_idx].flags7 & RF7_TANUKI)
1719 /* You might have unmasked Tanuki first time */
1720 r_ptr = &r_info[m_ptr->r_idx];
1721 m_ptr->ap_r_idx = m_ptr->r_idx;
1722 if (r_ptr->r_sights < MAX_SHORT) r_ptr->r_sights++;
1725 if (m_ptr->mflag2 & MFLAG2_CHAMELEON)
1727 /* You might have unmasked Chameleon first time */
1728 r_ptr = real_r_ptr(m_ptr);
1729 if (r_ptr->r_sights < MAX_SHORT) r_ptr->r_sights++;
1732 /* When the player kills a Unique, it stays dead */
1733 if (r_ptr->flags1 & RF1_UNIQUE && !(m_ptr->smart & SM_CLONED))
1736 /* When the player kills a Nazgul, it stays dead */
1737 if (r_ptr->flags7 & RF7_UNIQUE_7) r_ptr->max_num--;
1739 /* Recall even invisible uniques or winners */
1740 if (m_ptr->ml || (r_ptr->flags1 & RF1_UNIQUE))
1742 /* Count kills this life */
1743 if ((m_ptr->mflag2 & MFLAG2_KAGE) && (r_info[MON_KAGE].r_pkills < MAX_SHORT)) r_info[MON_KAGE].r_pkills++;
1744 else if (r_ptr->r_pkills < MAX_SHORT) r_ptr->r_pkills++;
1746 /* Count kills in all lives */
1747 if ((m_ptr->mflag2 & MFLAG2_KAGE) && (r_info[MON_KAGE].r_tkills < MAX_SHORT)) r_info[MON_KAGE].r_tkills++;
1748 else if (r_ptr->r_tkills < MAX_SHORT) r_ptr->r_tkills++;
1750 /* Hack -- Auto-recall */
1751 monster_race_track(m_ptr->ap_r_idx);
1754 /* Extract monster name */
1755 monster_desc(m_name, m_ptr, 0x100);
1757 /* Don't kill Amberites */
1758 if ((r_ptr->flags3 & RF3_AMBERITE) && one_in_(2))
1760 int curses = 1 + randint1(3);
1761 bool stop_ty = FALSE;
1765 msg_format("%^s¤Ï¶²¤í¤·¤¤·ì¤Î¼ö¤¤¤ò¤¢¤Ê¤¿¤Ë¤«¤±¤¿¡ª", m_name);
1767 msg_format("%^s puts a terrible blood curse on you!", m_name);
1770 curse_equipment(100, 50);
1774 stop_ty = activate_ty_curse(stop_ty, &count);
1779 if (r_ptr->flags2 & RF2_CAN_SPEAK)
1781 char line_got[1024];
1783 /* Dump a message */
1785 if (!get_rnd_line("mondeath_j.txt", m_ptr->r_idx, line_got))
1787 if (!get_rnd_line("mondeath.txt", m_ptr->r_idx, line_got))
1790 msg_format("%^s %s", m_name, line_got);
1793 if (m_ptr->r_idx == MON_SERPENT)
1795 /* Make screen dump */
1796 screen_dump = make_screen_dump();
1801 if (!(d_info[dungeon_type].flags1 & DF1_BEGINNER))
1803 if (!dun_level && !ambush_flag && !p_ptr->inside_arena)
1805 chg_virtue(V_VALOUR, -1);
1807 else if (r_ptr->level > dun_level)
1809 if (randint1(10) <= (r_ptr->level - dun_level))
1810 chg_virtue(V_VALOUR, 1);
1812 if (r_ptr->level > 60)
1814 chg_virtue(V_VALOUR, 1);
1816 if (r_ptr->level >= 2 * (p_ptr->lev+1))
1817 chg_virtue(V_VALOUR, 2);
1820 if ((r_ptr->flags1 & RF1_UNIQUE) && ((r_ptr->flags3 & RF3_EVIL) ||
1821 (r_ptr->flags3 & RF3_GOOD)))
1823 chg_virtue(V_HARMONY, 2);
1825 if ((r_ptr->flags1 & RF1_UNIQUE) && (r_ptr->flags3 & RF3_GOOD))
1827 chg_virtue(V_UNLIFE, 2);
1828 chg_virtue(V_VITALITY, -2);
1831 if ((r_ptr->flags1 & RF1_UNIQUE) && one_in_(3))
1832 chg_virtue(V_INDIVIDUALISM, -1);
1834 if (m_ptr->r_idx == MON_BEGGAR || m_ptr->r_idx == MON_LEPER)
1836 chg_virtue(V_COMPASSION, -1);
1839 if ((r_ptr->flags3 & RF3_GOOD) &&
1840 ((r_ptr->level) / 10 + (3 * dun_level) >= randint1(100)))
1842 chg_virtue(V_UNLIFE, 1);
1844 if (r_ptr->d_char == 'A')
1846 if (r_ptr->flags1 & RF1_UNIQUE)
1847 chg_virtue(V_FAITH, -2);
1848 else if ((r_ptr->level) / 10 + (3 * dun_level) >= randint1(100))
1850 if (r_ptr->flags3 & RF3_GOOD) chg_virtue(V_FAITH, -1);
1851 else chg_virtue(V_FAITH, 1);
1854 else if (r_ptr->flags3 & RF3_DEMON)
1856 if (r_ptr->flags1 & RF1_UNIQUE)
1857 chg_virtue(V_FAITH, 2);
1858 else if ((r_ptr->level) / 10 + (3 * dun_level) >= randint1(100))
1859 chg_virtue(V_FAITH, 1);
1862 if ((r_ptr->flags3 & RF3_UNDEAD) && (r_ptr->flags1 & RF1_UNIQUE))
1863 chg_virtue(V_VITALITY, 2);
1865 if (r_ptr->r_deaths)
1867 if (r_ptr->flags1 & RF1_UNIQUE)
1869 chg_virtue(V_HONOUR, 10);
1871 else if ((r_ptr->level) / 10 + (2 * dun_level) >= randint1(100))
1873 chg_virtue(V_HONOUR, 1);
1876 if ((r_ptr->flags2 & RF2_MULTIPLY) && (r_ptr->r_pkills > 1000) && one_in_(10))
1878 chg_virtue(V_VALOUR, -1);
1881 for (i = 0; i < 4; i++)
1883 if(r_ptr->blow[i].d_dice != 0) innocent = FALSE; /* Murderer! */
1885 if ((r_ptr->blow[i].effect == RBE_EAT_ITEM)
1886 || (r_ptr->blow[i].effect == RBE_EAT_GOLD))
1888 thief = TRUE; /* Thief! */
1891 /* The new law says it is illegal to live in the dungeon */
1892 if (r_ptr->level != 0) innocent = FALSE;
1896 if (r_ptr->flags1 & RF1_UNIQUE)
1897 chg_virtue(V_JUSTICE, 3);
1898 else if (1+((r_ptr->level) / 10 + (2 * dun_level))
1901 chg_virtue(V_JUSTICE, 1);
1905 chg_virtue (V_JUSTICE, -1);
1908 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)))
1910 if (one_in_(4)) chg_virtue(V_NATURE, -1);
1913 if ((r_ptr->flags1 & RF1_UNIQUE) && record_destroy_uniq)
1917 sprintf(m_name, "%s%s", r_name + r_ptr->name, (m_ptr->smart & SM_CLONED) ? "(¥¯¥í¡¼¥ó)" : "");
1919 sprintf(m_name, "%s%s", r_name + r_ptr->name, (m_ptr->smart & SM_CLONED) ? "(Clone)" : "");
1921 do_cmd_write_nikki(NIKKI_UNIQUE, 0, m_name);
1927 /* Death by Missile/Spell attack */
1930 msg_format("%^s%s", m_name, note);
1933 /* Death by physical attack -- invisible monster */
1934 else if (!m_ptr->ml)
1937 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
1938 msg_format("¤»¤Ã¤«¤¯¤À¤«¤é%s¤ò»¦¤·¤¿¡£", m_name);
1940 msg_format("%s¤ò»¦¤·¤¿¡£", m_name);
1942 msg_format("You have killed %s.", m_name);
1947 /* Death by Physical attack -- non-living monster */
1948 else if (!monster_living(r_ptr))
1951 bool explode = FALSE;
1953 for (i = 0; i < 4; i++)
1955 if (r_ptr->blow[i].method == RBM_EXPLODE) explode = TRUE;
1958 /* Special note at death */
1961 msg_format("%s¤ÏÇúȯ¤·¤ÆÊ´¡¹¤Ë¤Ê¤Ã¤¿¡£", m_name);
1963 msg_format("%s explodes into tiny shreds.", m_name);
1968 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
1969 msg_format("¤»¤Ã¤«¤¯¤À¤«¤é%s¤òÅݤ·¤¿¡£", m_name);
1971 msg_format("%s¤òÅݤ·¤¿¡£", m_name);
1973 msg_format("You have destroyed %s.", m_name);
1978 /* Death by Physical attack -- living monster */
1982 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
1983 msg_format("¤»¤Ã¤«¤¯¤À¤«¤é%s¤òÁò¤êµî¤Ã¤¿¡£", m_name);
1985 msg_format("%s¤òÁò¤êµî¤Ã¤¿¡£", m_name);
1987 msg_format("You have slain %s.", m_name);
1991 if (r_ptr->flags1 & RF1_UNIQUE && !(m_ptr->smart & SM_CLONED))
1993 for (i = 0; i < MAX_KUBI; i++)
1995 if ((kubi_r_idx[i] == m_ptr->r_idx) && !(m_ptr->mflag2 & MFLAG2_CHAMELEON))
1998 msg_format("%s¤Î¼ó¤Ë¤Ï¾Þ¶â¤¬¤«¤«¤Ã¤Æ¤¤¤ë¡£", m_name);
2000 msg_format("There is a price on %s's head.", m_name);
2007 /* Generate treasure */
2008 monster_death(m_idx, TRUE);
2009 if ((m_ptr->r_idx == MON_BANOR) || (m_ptr->r_idx == MON_LUPART))
2011 r_info[MON_BANORLUPART].max_num = 0;
2012 r_info[MON_BANORLUPART].r_pkills++;
2013 if (r_info[MON_BANORLUPART].r_tkills < MAX_SHORT) r_info[MON_BANORLUPART].r_tkills++;
2016 if (m_ptr->r_idx == MON_BANORLUPART)
2018 r_info[MON_BANOR].max_num = 0;
2019 r_info[MON_BANOR].r_pkills++;
2020 if (r_info[MON_BANOR].r_tkills < MAX_SHORT) r_info[MON_BANOR].r_tkills++;
2021 r_info[MON_LUPART].max_num = 0;
2022 r_info[MON_LUPART].r_pkills++;
2023 if (r_info[MON_LUPART].r_tkills < MAX_SHORT) r_info[MON_LUPART].r_tkills++;
2026 /* Mega hack : replace IKETA to BIKETAL */
2027 if ((m_ptr->r_idx == MON_IKETA) &&
2028 !(p_ptr->inside_arena || p_ptr->inside_battle))
2030 int dummy_y = m_ptr->fy;
2031 int dummy_x = m_ptr->fx;
2034 if (is_pet(m_ptr)) mode |= PM_FORCE_PET;
2036 /* Delete the monster */
2037 delete_monster_idx(m_idx);
2039 if (summon_named_creature(0, dummy_y, dummy_x, MON_BIKETAL, mode))
2042 msg_print("¡Ö¥Ï¥¡¥Ã¥Ï¥Ã¥Ï¥Ã¥Ï¡ª¡ª»ä¤¬¥Ð¥¤¥±¥¿¥ë¤À¡ª¡ª¡×");
2044 msg_print("Uwa-hahaha! *I* am Biketal!");
2050 /* Delete the monster */
2051 delete_monster_idx(m_idx);
2054 /* Prevent bug of chaos patron's reward */
2055 if (r_ptr->flags7 & RF7_KILL_EXP)
2056 get_exp_from_mon((long)m_ptr->max_maxhp*2, &exp_mon);
2058 get_exp_from_mon(((long)m_ptr->max_maxhp+1L) * 9L / 10L, &exp_mon);
2063 /* Monster is dead */
2070 /* Mega-Hack -- Pain cancels fear */
2071 if (m_ptr->monfear && (dam > 0))
2073 int tmp = randint1(dam);
2075 /* Cure a little fear */
2076 if (tmp < m_ptr->monfear)
2079 m_ptr->monfear -= tmp;
2082 /* Cure all the fear */
2093 /* Sometimes a monster gets scared by damage */
2094 if (!m_ptr->monfear && !(r_ptr->flags3 & (RF3_NO_FEAR)))
2098 /* Percentage of fully healthy */
2099 percentage = (100L * m_ptr->hp) / m_ptr->maxhp;
2102 * Run (sometimes) if at 10% or less of max hit points,
2103 * or (usually) when hit for half its current hit points
2105 if ((randint1(10) >= percentage) ||
2106 ((dam >= m_ptr->hp) && (randint0(100) < 80)))
2108 /* Hack -- note fear */
2111 /* XXX XXX XXX Hack -- Add some timed fear */
2112 m_ptr->monfear = (randint1(10) +
2113 (((dam >= m_ptr->hp) && (percentage > 7)) ?
2114 20 : ((11 - percentage) * 5)));
2121 if (p_ptr->riding && (p_ptr->riding == m_idx) && (dam > 0))
2125 /* Extract monster name */
2126 monster_desc(m_name, m_ptr, 0);
2128 if (m_ptr->hp > m_ptr->maxhp/3) dam = (dam + 1) / 2;
2129 if (rakuba((dam > 200) ? 200 : dam, FALSE))
2132 msg_format("%^s¤Ë¿¶¤êÍî¤È¤µ¤ì¤¿¡ª", m_name);
2134 msg_format("%^s has thrown you off!", m_name);
2146 * Get term size and calculate screen size
2148 void get_screen_size(int *wid_p, int *hgt_p)
2150 Term_get_size(wid_p, hgt_p);
2151 *hgt_p -= ROW_MAP + 2;
2152 *wid_p -= COL_MAP + 2;
2153 if (use_bigtile) *wid_p /= 2;
2158 * Calculates current boundaries
2159 * Called below and from "do_cmd_locate()".
2161 void panel_bounds_center(void)
2166 get_screen_size(&wid, &hgt);
2168 panel_row_max = panel_row_min + hgt - 1;
2169 panel_row_prt = panel_row_min - 1;
2170 panel_col_max = panel_col_min + wid - 1;
2171 panel_col_prt = panel_col_min - 13;
2176 * Map resizing whenever the main term changes size
2178 void resize_map(void)
2180 /* Only if the dungeon exists */
2181 if (!character_dungeon) return;
2183 /* Mega-Hack -- no panel yet */
2187 /* Reset the panels */
2188 panel_row_min = cur_hgt;
2189 panel_col_min = cur_wid;
2194 p_ptr->update |= (PU_TORCH | PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
2196 /* Forget lite/view */
2197 p_ptr->update |= (PU_UN_VIEW | PU_UN_LITE);
2199 /* Update lite/view */
2200 p_ptr->update |= (PU_VIEW | PU_LITE | PU_MON_LITE);
2202 /* Update monsters */
2203 p_ptr->update |= (PU_MONSTERS);
2205 /* Redraw everything */
2206 p_ptr->redraw |= (PR_WIPE | PR_BASIC | PR_EXTRA | PR_MAP | PR_EQUIPPY);
2208 /* Hack -- update */
2216 * Place the cursor on the player
2218 if (can_save) move_cursor_relative(py, px);
2225 * Redraw a term when it is resized
2227 void redraw_window(void)
2229 /* Only if the dungeon exists */
2230 if (!character_dungeon) return;
2232 /* Hack - Activate term zero for the redraw */
2233 Term_activate(&term_screen[0]);
2235 /* Hack -- react to changes */
2236 Term_xtra(TERM_XTRA_REACT, 0);
2239 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_SPELL | PW_PLAYER);
2242 p_ptr->window |= (PW_MESSAGE | PW_OVERHEAD | PW_DUNGEON | PW_MONSTER | PW_OBJECT);
2244 /* Hack -- update */
2256 * Handle a request to change the current panel
2258 * Return TRUE if the panel was changed.
2260 * Also used in do_cmd_locate
2262 bool change_panel(int dy, int dx)
2268 get_screen_size(&wid, &hgt);
2270 /* Apply the motion */
2271 y = panel_row_min + dy * hgt / 2;
2272 x = panel_col_min + dx * wid / 2;
2274 /* Verify the row */
2275 if (y > cur_hgt - hgt) y = cur_hgt - hgt;
2278 /* Verify the col */
2279 if (x > cur_wid - wid) x = cur_wid - wid;
2282 /* Handle "changes" */
2283 if ((y != panel_row_min) || (x != panel_col_min))
2285 /* Save the new panel info */
2289 /* Recalculate the boundaries */
2290 panel_bounds_center();
2293 p_ptr->update |= (PU_MONSTERS);
2296 p_ptr->redraw |= (PR_MAP);
2311 * Given an row (y) and col (x), this routine detects when a move
2312 * off the screen has occurred and figures new borders. -RAK-
2314 * "Update" forces a "full update" to take place.
2316 * The map is reprinted if necessary, and "TRUE" is returned.
2318 void verify_panel(void)
2330 get_screen_size(&wid, &hgt);
2332 max_prow_min = cur_hgt - hgt;
2333 max_pcol_min = cur_wid - wid;
2335 /* Bounds checking */
2336 if (max_prow_min < 0) max_prow_min = 0;
2337 if (max_pcol_min < 0) max_pcol_min = 0;
2339 /* Center on player */
2340 if (center_player && (center_running || !running))
2342 /* Center vertically */
2343 prow_min = y - hgt / 2;
2344 if (prow_min < 0) prow_min = 0;
2345 else if (prow_min > max_prow_min) prow_min = max_prow_min;
2347 /* Center horizontally */
2348 pcol_min = x - wid / 2;
2349 if (pcol_min < 0) pcol_min = 0;
2350 else if (pcol_min > max_pcol_min) pcol_min = max_pcol_min;
2354 prow_min = panel_row_min;
2355 pcol_min = panel_col_min;
2357 /* Scroll screen when 2 grids from top/bottom edge */
2358 if (y > panel_row_max - 2)
2360 while (y > prow_min + hgt-1 - 2)
2362 prow_min += (hgt / 2);
2366 if (y < panel_row_min + 2)
2368 while (y < prow_min + 2)
2370 prow_min -= (hgt / 2);
2374 if (prow_min > max_prow_min) prow_min = max_prow_min;
2375 if (prow_min < 0) prow_min = 0;
2377 /* Scroll screen when 4 grids from left/right edge */
2378 if (x > panel_col_max - 4)
2380 while (x > pcol_min + wid-1 - 4)
2382 pcol_min += (wid / 2);
2386 if (x < panel_col_min + 4)
2388 while (x < pcol_min + 4)
2390 pcol_min -= (wid / 2);
2394 if (pcol_min > max_pcol_min) pcol_min = max_pcol_min;
2395 if (pcol_min < 0) pcol_min = 0;
2398 /* Check for "no change" */
2399 if ((prow_min == panel_row_min) && (pcol_min == panel_col_min)) return;
2401 /* Save the new panel info */
2402 panel_row_min = prow_min;
2403 panel_col_min = pcol_min;
2405 /* Hack -- optional disturb on "panel change" */
2406 if (disturb_panel && !center_player) disturb(0, 0);
2408 /* Recalculate the boundaries */
2409 panel_bounds_center();
2412 p_ptr->update |= (PU_MONSTERS);
2415 p_ptr->redraw |= (PR_MAP);
2418 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
2423 * Monster health description
2425 cptr look_mon_desc(monster_type *m_ptr, u32b mode)
2427 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
2434 /* Determine if the monster is "living" */
2435 living = monster_living(ap_r_ptr);
2437 /* Calculate a health "percentage" */
2438 perc = 100L * m_ptr->hp / m_ptr->maxhp;
2440 /* Healthy monsters */
2441 if (m_ptr->hp >= m_ptr->maxhp)
2445 desc = living ? "̵½ý" : "̵¥À¥á¡¼¥¸";
2447 desc = living ? "unhurt" : "undamaged";
2452 else if (perc >= 60)
2455 desc = living ? "·Ú½ý" : "¾®¥À¥á¡¼¥¸";
2457 desc = living ? "somewhat wounded" : "somewhat damaged";
2462 else if (perc >= 25)
2465 desc = living ? "Éé½ý" : "Ãæ¥À¥á¡¼¥¸";
2467 desc = living ? "wounded" : "damaged";
2472 else if (perc >= 10)
2475 desc = living ? "½Å½ý" : "Âç¥À¥á¡¼¥¸";
2477 desc = living ? "badly wounded" : "badly damaged";
2485 desc = living ? "Ⱦ»àȾÀ¸" : "Åݤ줫¤±";
2487 desc = living ? "almost dead" : "almost destroyed";
2492 /* Need attitude information? */
2495 /* Full information is not needed */
2498 else if (is_pet(m_ptr))
2501 attitude = ", ¥Ú¥Ã¥È";
2506 else if (is_friendly(m_ptr))
2509 attitude = ", ͧ¹¥Åª";
2511 attitude = ", friendly";
2524 /* Clone monster? */
2525 if (m_ptr->smart & SM_CLONED)
2534 /* Display monster's level --- idea borrowed from ToME */
2535 if (ap_r_ptr->r_tkills && !(m_ptr->mflag2 & MFLAG2_KAGE))
2538 return format("¥ì¥Ù¥ë%d, %s%s%s", ap_r_ptr->level, desc, attitude, clone);
2540 return format("Level %d, %s%s%s", ap_r_ptr->level, desc, attitude, clone);
2546 return format("¥ì¥Ù¥ë???, %s%s%s", desc, attitude, clone);
2548 return format("Level ???, %s%s%s", desc, attitude, clone);
2556 * Angband sorting algorithm -- quick sort in place
2558 * Note that the details of the data we are sorting is hidden,
2559 * and we rely on the "ang_sort_comp()" and "ang_sort_swap()"
2560 * function hooks to interact with the data, which is given as
2561 * two pointers, and which may have any user-defined form.
2563 void ang_sort_aux(vptr u, vptr v, int p, int q)
2581 while (!(*ang_sort_comp)(u, v, b, z)) b--;
2584 while (!(*ang_sort_comp)(u, v, z, a)) a++;
2586 /* Done partition */
2590 (*ang_sort_swap)(u, v, a, b);
2596 /* Recurse left side */
2597 ang_sort_aux(u, v, p, b);
2599 /* Recurse right side */
2600 ang_sort_aux(u, v, b+1, q);
2605 * Angband sorting algorithm -- quick sort in place
2607 * Note that the details of the data we are sorting is hidden,
2608 * and we rely on the "ang_sort_comp()" and "ang_sort_swap()"
2609 * function hooks to interact with the data, which is given as
2610 * two pointers, and which may have any user-defined form.
2612 void ang_sort(vptr u, vptr v, int n)
2614 /* Sort the array */
2615 ang_sort_aux(u, v, 0, n-1);
2620 /*** Targeting Code ***/
2624 * Determine is a monster makes a reasonable target
2626 * The concept of "targeting" was stolen from "Morgul" (?)
2628 * The player can target any location, or any "target-able" monster.
2630 * Currently, a monster is "target_able" if it is visible, and if
2631 * the player can hit it with a projection, and the player is not
2632 * hallucinating. This allows use of "use closest target" macros.
2634 * Future versions may restrict the ability to target "trappers"
2635 * and "mimics", but the semantics is a little bit weird.
2637 bool target_able(int m_idx)
2639 monster_type *m_ptr = &m_list[m_idx];
2641 /* Monster must be alive */
2642 if (!m_ptr->r_idx) return (FALSE);
2644 /* Hack -- no targeting hallucinations */
2645 if (p_ptr->image) return (FALSE);
2647 /* Monster must be visible */
2648 if (!m_ptr->ml) return (FALSE);
2650 if (p_ptr->riding && (p_ptr->riding == m_idx)) return (TRUE);
2652 /* Monster must be projectable */
2653 if (!projectable(py, px, m_ptr->fy, m_ptr->fx)) return (FALSE);
2655 /* XXX XXX XXX Hack -- Never target trappers */
2656 /* if (CLEAR_ATTR && (CLEAR_CHAR)) return (FALSE); */
2666 * Update (if necessary) and verify (if possible) the target.
2668 * We return TRUE if the target is "okay" and FALSE otherwise.
2670 bool target_okay(void)
2672 /* Accept stationary targets */
2673 if (target_who < 0) return (TRUE);
2675 /* Check moving targets */
2678 /* Accept reasonable targets */
2679 if (target_able(target_who))
2681 monster_type *m_ptr = &m_list[target_who];
2683 /* Acquire monster location */
2684 target_row = m_ptr->fy;
2685 target_col = m_ptr->fx;
2692 /* Assume no target */
2699 * Sorting hook -- comp function -- by "distance to player"
2701 * We use "u" and "v" to point to arrays of "x" and "y" positions,
2702 * and sort the arrays by double-distance to the player.
2704 static bool ang_sort_comp_distance(vptr u, vptr v, int a, int b)
2706 byte *x = (byte*)(u);
2707 byte *y = (byte*)(v);
2711 /* Absolute distance components */
2712 kx = x[a]; kx -= px; kx = ABS(kx);
2713 ky = y[a]; ky -= py; ky = ABS(ky);
2715 /* Approximate Double Distance to the first point */
2716 da = ((kx > ky) ? (kx + kx + ky) : (ky + ky + kx));
2718 /* Absolute distance components */
2719 kx = x[b]; kx -= px; kx = ABS(kx);
2720 ky = y[b]; ky -= py; ky = ABS(ky);
2722 /* Approximate Double Distance to the first point */
2723 db = ((kx > ky) ? (kx + kx + ky) : (ky + ky + kx));
2725 /* Compare the distances */
2731 * Sorting hook -- swap function -- by "distance to player"
2733 * We use "u" and "v" to point to arrays of "x" and "y" positions,
2734 * and sort the arrays by distance to the player.
2736 static void ang_sort_swap_distance(vptr u, vptr v, int a, int b)
2738 byte *x = (byte*)(u);
2739 byte *y = (byte*)(v);
2757 * Hack -- help "select" a location (see below)
2759 static s16b target_pick(int y1, int x1, int dy, int dx)
2763 int x2, y2, x3, y3, x4, y4;
2765 int b_i = -1, b_v = 9999;
2768 /* Scan the locations */
2769 for (i = 0; i < temp_n; i++)
2775 /* Directed distance */
2779 /* Verify quadrant */
2780 if (dx && (x3 * dx <= 0)) continue;
2781 if (dy && (y3 * dy <= 0)) continue;
2783 /* Absolute distance */
2787 /* Verify quadrant */
2788 if (dy && !dx && (x4 > y4)) continue;
2789 if (dx && !dy && (y4 > x4)) continue;
2791 /* Approximate Double Distance */
2792 v = ((x4 > y4) ? (x4 + x4 + y4) : (y4 + y4 + x4));
2794 /* XXX XXX XXX Penalize location */
2797 if ((b_i >= 0) && (v >= b_v)) continue;
2809 * Hack -- determine if a given location is "interesting"
2811 static bool target_set_accept(int y, int x)
2815 s16b this_o_idx, next_o_idx = 0;
2818 if (!(in_bounds(y, x))) return (FALSE);
2820 /* Player grid is always interesting */
2821 if ((y == py) && (x == px)) return (TRUE);
2824 /* Handle hallucination */
2825 if (p_ptr->image) return (FALSE);
2828 /* Examine the grid */
2829 c_ptr = &cave[y][x];
2831 /* Visible monsters */
2834 monster_type *m_ptr = &m_list[c_ptr->m_idx];
2836 /* Visible monsters */
2837 if (m_ptr->ml) return (TRUE);
2840 /* Scan all objects in the grid */
2841 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
2845 /* Acquire object */
2846 o_ptr = &o_list[this_o_idx];
2848 /* Acquire next object */
2849 next_o_idx = o_ptr->next_o_idx;
2851 /* Memorized object */
2852 if (o_ptr->marked) return (TRUE);
2855 /* Interesting memorized features */
2856 if (c_ptr->info & (CAVE_MARK))
2860 /* Feature code (applying "mimic" field) */
2861 feat = c_ptr->mimic ? c_ptr->mimic : f_info[c_ptr->feat].mimic;
2864 if (c_ptr->info & CAVE_OBJECT) return (TRUE);
2866 /* Notice the Pattern */
2867 if ((feat <= FEAT_PATTERN_XTRA2) &&
2868 (feat >= FEAT_PATTERN_START))
2872 if (feat == FEAT_OPEN) return (TRUE);
2873 if (feat == FEAT_BROKEN) return (TRUE);
2876 if (feat == FEAT_LESS) return (TRUE);
2877 if (feat == FEAT_MORE) return (TRUE);
2878 if (feat == FEAT_LESS_LESS) return (TRUE);
2879 if (feat == FEAT_MORE_MORE) return (TRUE);
2882 if ((feat >= FEAT_SHOP_HEAD) &&
2883 (feat <= FEAT_SHOP_TAIL)) return (TRUE);
2885 if (feat == FEAT_MUSEUM) return (TRUE);
2887 /* Notice buildings -KMW- */
2888 if ((feat >= FEAT_BLDG_HEAD) &&
2889 (feat <= FEAT_BLDG_TAIL)) return (TRUE);
2892 if (is_trap(feat)) return (TRUE);
2895 if ((feat >= FEAT_DOOR_HEAD) &&
2896 (feat <= FEAT_DOOR_TAIL)) return (TRUE);
2900 /* I think FEAT_RUBBLEs should not be "interesting" */
2901 if (feat == FEAT_RUBBLE) return (TRUE);
2903 /* Notice veins with treasure */
2904 /* Now veins with treasure are too many */
2905 if (feat == FEAT_MAGMA_K) return (TRUE);
2906 if (feat == FEAT_QUARTZ_K) return (TRUE);
2909 /* Notice quest features */
2910 if (feat == FEAT_QUEST_ENTER) return (TRUE);
2911 if (feat == FEAT_QUEST_EXIT) return (TRUE);
2912 if (feat == FEAT_QUEST_DOWN) return (TRUE);
2913 if (feat == FEAT_QUEST_UP) return (TRUE);
2914 if (feat == FEAT_TOWN) return (TRUE);
2915 if (feat == FEAT_ENTRANCE) return (TRUE);
2924 * Prepare the "temp" array for "target_set"
2926 * Return the number of target_able monsters in the set.
2928 static void target_set_prepare(int mode)
2932 /* Reset "temp" array */
2935 /* Scan the current panel */
2936 for (y = panel_row_min; y <= panel_row_max; y++)
2938 for (x = panel_col_min; x <= panel_col_max; x++)
2942 /* Require line of sight, unless "look" is "expanded" */
2943 if (!expand_look && !player_has_los_bold(y, x)) continue;
2945 /* Require "interesting" contents */
2946 if (!target_set_accept(y, x)) continue;
2948 c_ptr = &cave[y][x];
2950 /* Require target_able monsters for "TARGET_KILL" */
2951 if ((mode & (TARGET_KILL)) && !target_able(c_ptr->m_idx)) continue;
2953 if ((mode & (TARGET_KILL)) && !target_pet && is_pet(&m_list[c_ptr->m_idx])) continue;
2955 /* Save the location */
2962 /* Set the sort hooks */
2963 ang_sort_comp = ang_sort_comp_distance;
2964 ang_sort_swap = ang_sort_swap_distance;
2966 /* Sort the positions */
2967 ang_sort(temp_x, temp_y, temp_n);
2969 if (p_ptr->riding && target_pet && (temp_n > 1) && (mode & (TARGET_KILL)))
2974 temp_y[0] = temp_y[1];
2977 temp_x[0] = temp_x[1];
2984 * Evaluate number of kill needed to gain level
2986 static void evaluate_monster_exp(char *buf, monster_type *m_ptr)
2988 #define M_INT_GREATER(h1,l1,h2,l2) ( (h1>h2)||( (h1==h2)&&(l1>=l2)))
2989 #define M_INT_SUB(h1,l1, h2,l2) {h1-=h2;if(l1<l2){l1+=0x10000;h1--;}l1-=l2;}
2990 #define M_INT_ADD(h1,l1, h2,l2) {h1+=h2;l1+=l2;if(l1>=0x10000L){l1&=0xFFFF;h1++;}}
2991 #define M_INT_LSHIFT(h1,l1) {h1=(h1<<1)|(l1>>15);l1=(l1<<1)&0xffff;}
2992 #define M_INT_RSHIFT(h1,l1) {l1=(l1>>1)|((h1&1)<<15);h1>>=1;}
2993 #define M_INT_MULT(h1,l1,mul,h2,l2) {l2=(l1*mul)&0xffff;h2=((l1*mul)>>16)+h1*mul;}
2995 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
2999 u32b exp_mon= (ap_r_ptr->mexp)*(ap_r_ptr->level);
3000 u32b exp_mon_h= exp_mon / (p_ptr->max_plv+2);
3001 u32b exp_mon_l= ((exp_mon % (p_ptr->max_plv+2))*0x10000/(p_ptr->max_plv+2))&0xFFFF;
3003 u32b exp_adv_h = player_exp[p_ptr->lev -1] * p_ptr->expfact /100;
3004 u32b exp_adv_l = ((player_exp[p_ptr->lev -1]%100) * p_ptr->expfact *0x10000/100)&0xFFFF;
3006 M_INT_SUB(exp_adv_h, exp_adv_l, p_ptr->exp, p_ptr->exp_frac);
3007 if ((p_ptr->lev>=PY_MAX_LEVEL) || (p_ptr->prace == RACE_ANDROID))
3009 else if (!ap_r_ptr->r_tkills || (m_ptr->mflag2 & MFLAG2_KAGE))
3011 else if (M_INT_GREATER(exp_mon_h, exp_mon_l, exp_adv_h, exp_adv_l))
3015 M_INT_MULT(exp_mon_h, exp_mon_l, 1000,tmp_h, tmp_l);
3016 if( M_INT_GREATER(exp_adv_h, exp_adv_l, tmp_h, tmp_l) )
3021 M_INT_ADD(exp_adv_h, exp_adv_l, exp_mon_h, exp_mon_l);
3022 M_INT_SUB(exp_adv_h, exp_adv_l, 0, 1);
3023 while(M_INT_GREATER(exp_adv_h, exp_adv_l, exp_mon_h,exp_mon_l))
3025 M_INT_LSHIFT(exp_mon_h,exp_mon_l);
3028 M_INT_RSHIFT(exp_mon_h,exp_mon_l);bit>>=1;
3029 for(;bit>=1;bit>>=1)
3031 if(M_INT_GREATER(exp_adv_h,exp_adv_l,exp_mon_h,exp_mon_l))
3034 M_INT_SUB(exp_adv_h,exp_adv_l,exp_mon_h,exp_mon_l);
3036 M_INT_RSHIFT(exp_mon_h,exp_mon_l);
3038 sprintf(buf,"%03d",result);
3045 * Examine a grid, return a keypress.
3047 * The "mode" argument contains the "TARGET_LOOK" bit flag, which
3048 * indicates that the "space" key should scan through the contents
3049 * of the grid, instead of simply returning immediately. This lets
3050 * the "look" command get complete information, without making the
3051 * "target" command annoying.
3053 * The "info" argument contains the "commands" which should be shown
3054 * inside the "[xxx]" text. This string must never be empty, or grids
3055 * containing monsters will be displayed with an extra comma.
3057 * Note that if a monster is in the grid, we update both the monster
3058 * recall info and the health bar info to track that monster.
3060 * Eventually, we may allow multiple objects per grid, or objects
3061 * and terrain features in the same grid. XXX XXX XXX
3063 * This function must handle blindness/hallucination.
3065 static int target_set_aux(int y, int x, int mode, cptr info)
3067 cave_type *c_ptr = &cave[y][x];
3068 s16b this_o_idx, next_o_idx = 0;
3069 cptr s1 = "", s2 = "", s3 = "", x_info = "";
3073 char out_val[MAX_NLEN+80];
3075 #ifdef ALLOW_EASY_FLOOR
3076 int floor_list[23], floor_num = 0;
3078 /* Scan all objects in the grid */
3081 floor_num = scan_floor(floor_list, y, x, 0x02);
3093 #endif /* ALLOW_EASY_FLOOR */
3095 /* Hack -- under the player */
3096 if ((y == py) && (x == px))
3119 /* Hack -- hallucination */
3123 cptr name = "²¿¤«´ñ̯¤Êʪ";
3125 cptr name = "something strange";
3129 /* Display a message */
3131 sprintf(out_val, "%s%s%s%s [%s]", s1, name, s2, s3, info);
3133 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, name, info);
3137 move_cursor_relative(y, x);
3140 /* Stop on everything but "return" */
3141 if ((query != '\r') && (query != '\n')) return query;
3143 /* Repeat forever */
3148 /* Actual monsters */
3149 if (c_ptr->m_idx && m_list[c_ptr->m_idx].ml)
3151 monster_type *m_ptr = &m_list[c_ptr->m_idx];
3152 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
3154 bool recall = FALSE;
3159 /* Get the monster name ("a kobold") */
3160 monster_desc(m_name, m_ptr, 0x08);
3162 /* Hack -- track this monster race */
3163 monster_race_track(m_ptr->ap_r_idx);
3165 /* Hack -- health bar for this monster */
3166 health_track(c_ptr->m_idx);
3168 /* Hack -- handle stuff */
3182 /* Recall on screen */
3183 screen_roff(m_ptr->ap_r_idx, 0);
3185 /* Hack -- Complete the prompt (again) */
3187 Term_addstr(-1, TERM_WHITE, format(" [r»× %s%s]", x_info, info));
3189 Term_addstr(-1, TERM_WHITE, format(" [r,%s%s]", x_info, info));
3198 /* Normal commands */
3199 if (query != 'r') break;
3204 /* Cleare recall text and repeat */
3210 /* Describe, and prompt for recall */
3211 evaluate_monster_exp(acount, m_ptr);
3214 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);
3216 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);
3222 move_cursor_relative(y, x);
3227 /* Normal commands */
3228 if (query != 'r') break;
3234 /* Always stop at "normal" keys */
3235 if ((query != '\r') && (query != '\n') && (query != ' ') && (query != 'x')) return query;
3237 /* Sometimes stop at "space" key */
3238 if ((query == ' ') && !(mode & (TARGET_LOOK))) return query;
3240 /* Change the intro */
3248 /* Hack -- take account of gender */
3250 if (ap_r_ptr->flags1 & (RF1_FEMALE)) s1 = "Èà½÷¤Ï";
3252 if (ap_r_ptr->flags1 & (RF1_FEMALE)) s1 = "She is ";
3256 else if (ap_r_ptr->flags1 & (RF1_MALE)) s1 = "Èà¤Ï";
3258 else if (ap_r_ptr->flags1 & (RF1_MALE)) s1 = "He is ";
3262 /* Use a preposition */
3271 /* Scan all objects being carried */
3272 for (this_o_idx = m_ptr->hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
3274 char o_name[MAX_NLEN];
3278 /* Acquire object */
3279 o_ptr = &o_list[this_o_idx];
3281 /* Acquire next object */
3282 next_o_idx = o_ptr->next_o_idx;
3284 /* Obtain an object description */
3285 object_desc(o_name, o_ptr, TRUE, 3);
3287 /* Describe the object */
3289 sprintf(out_val, "%s%s%s%s[%s]", s1, o_name, s2, s3, info);
3291 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, o_name, info);
3295 move_cursor_relative(y, x);
3298 /* Always stop at "normal" keys */
3299 if ((query != '\r') && (query != '\n') && (query != ' ') && (query != 'x')) return query;
3301 /* Sometimes stop at "space" key */
3302 if ((query == ' ') && !(mode & (TARGET_LOOK))) return query;
3304 /* Change the intro */
3308 s2 = "also carrying ";
3312 /* Use a preposition */
3322 #ifdef ALLOW_EASY_FLOOR
3331 char o_name[MAX_NLEN];
3335 /* Acquire object */
3336 o_ptr = &o_list[floor_list[0]];
3338 /* Describe the object */
3339 object_desc(o_name, o_ptr, TRUE, 3);
3343 sprintf(out_val, "%s%s%s%s[%s]",
3344 s1, o_name, s2, s3, info);
3346 sprintf(out_val, "%s%s%s%s [%s]",
3347 s1, s2, s3, o_name, info);
3351 move_cursor_relative(y, x);
3360 /* Provide one cushion before item listing */
3363 /* Display rough information about items */
3365 sprintf(out_val, "%s %d¸Ä¤Î¥¢¥¤¥Æ¥à%s%s ['x'¤Ç°ìÍ÷, %s]",
3366 s1, floor_num, s2, s3, info);
3368 sprintf(out_val, "%s%s%sa pile of %d items [x,%s]",
3369 s1, s2, s3, floor_num, info);
3373 move_cursor_relative(y, x);
3378 /* No request for listing */
3379 if (query != 'x' && query != ' ') return query;
3383 /** Display list of items **/
3385 /* Continue scrolling list if requested */
3394 (void)show_floor(0, y, x, &min_width);
3398 sprintf(out_val, "%s %d¸Ä¤Î¥¢¥¤¥Æ¥à%s%s [Enter¤Ç¼¡¤Ø, %s]",
3399 s1, floor_num, s2, s3, info);
3401 sprintf(out_val, "%s%s%sa pile of %d items [Enter,%s]",
3402 s1, s2, s3, floor_num, info);
3413 /* Exit unless 'Enter' */
3414 if (query != '\n' && query != '\r')
3419 /* Get the object being moved. */
3420 o_idx = c_ptr->o_idx;
3422 /* Only rotate a pile of two or more objects. */
3423 if (!(o_idx && o_list[o_idx].next_o_idx)) continue;
3425 /* Remove the first object from the list. */
3426 excise_object_idx(o_idx);
3428 /* Find end of the list. */
3430 while (o_list[i].next_o_idx)
3431 i = o_list[i].next_o_idx;
3433 /* Add after the last object. */
3434 o_list[i].next_o_idx = o_idx;
3436 /* Loop and re-display the list */
3442 #endif /* ALLOW_EASY_FLOOR */
3445 /* Scan all objects in the grid */
3446 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
3450 /* Acquire object */
3451 o_ptr = &o_list[this_o_idx];
3453 /* Acquire next object */
3454 next_o_idx = o_ptr->next_o_idx;
3459 char o_name[MAX_NLEN];
3464 /* Obtain an object description */
3465 object_desc(o_name, o_ptr, TRUE, 3);
3467 /* Describe the object */
3469 sprintf(out_val, "%s%s%s%s[%s]", s1, o_name, s2, s3, info);
3471 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, o_name, info);
3475 move_cursor_relative(y, x);
3478 /* Always stop at "normal" keys */
3479 if ((query != '\r') && (query != '\n') && (query != ' ') && (query != 'x')) return query;
3481 /* Sometimes stop at "space" key */
3482 if ((query == ' ') && !(mode & TARGET_LOOK)) return query;
3484 /* Change the intro */
3494 if (o_ptr->number != 1) s1 = "¤½¤ì¤é¤Ï";
3496 if (o_ptr->number != 1) s1 = "They are ";
3512 /* Feature code (applying "mimic" field) */
3513 feat = c_ptr->mimic ? c_ptr->mimic : f_info[c_ptr->feat].mimic;
3515 /* Require knowledge about grid, or ability to see grid */
3516 if (!(c_ptr->info & CAVE_MARK) && !player_can_see_bold(y, x))
3518 /* Forget feature */
3522 /* Terrain feature if needed */
3523 if (boring || (feat > FEAT_INVIS))
3527 /* Hack -- special handling for building doors */
3528 if ((feat >= FEAT_BLDG_HEAD) && (feat <= FEAT_BLDG_TAIL))
3530 name = building[feat - FEAT_BLDG_HEAD].name;
3532 else if (feat == FEAT_ENTRANCE)
3535 name = format("%s(%d³¬ÁêÅö)", d_text + d_info[c_ptr->special].text, d_info[c_ptr->special].mindepth);
3537 name = format("%s(level %d)", d_text + d_info[c_ptr->special].text, d_info[c_ptr->special].mindepth);
3540 else if (feat == FEAT_TOWN)
3542 name = town[c_ptr->special].name;
3544 else if (p_ptr->wild_mode && (feat == FEAT_FLOOR))
3554 name = f_name + f_info[feat].name;
3559 if (*s2 && ((feat >= FEAT_MINOR_GLYPH) &&
3560 (feat <= FEAT_PATTERN_XTRA2)))
3569 else if (*s2 && ((feat >= FEAT_DOOR_HEAD) &&
3570 (feat <= FEAT_PERM_SOLID)))
3579 else if (*s2 && (feat == FEAT_TOWN))
3589 /* Hack -- special introduction for store & building doors -KMW- */
3590 if (((feat >= FEAT_SHOP_HEAD) && (feat <= FEAT_SHOP_TAIL)) ||
3591 ((feat >= FEAT_BLDG_HEAD) && (feat <= FEAT_BLDG_TAIL)) ||
3592 (feat == FEAT_MUSEUM) ||
3593 (feat == FEAT_ENTRANCE))
3602 else if ((feat == FEAT_TOWN) || (feat == FEAT_FLOOR) || (feat == FEAT_DIRT) || (feat == FEAT_FLOWER))
3610 /* Pick proper indefinite article */
3612 s3 = (is_a_vowel(name[0])) ? "an " : "a ";
3616 /* Display a message */
3619 sprintf(out_val, "%s%s%s%s[%s] %x %d %d %d %d (%d,%d)", s1, name, s2, s3, info, c_ptr->info, c_ptr->feat, c_ptr->dist, c_ptr->cost, c_ptr->when, x, y);
3621 sprintf(out_val, "%s%s%s%s [%s] %x %d %d %d %d (%d,%d)", s1, s2, s3, name, info, c_ptr->info, c_ptr->feat, c_ptr->dist, c_ptr->cost, c_ptr->when, x, y);
3625 sprintf(out_val, "%s%s%s%s[%s]", s1, name, s2, s3, info);
3627 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, name, info);
3631 move_cursor_relative(y, x);
3634 /* Always stop at "normal" keys */
3635 if ((query != '\r') && (query != '\n') && (query != ' ')) return query;
3638 /* Stop on everything but "return" */
3639 if ((query != '\r') && (query != '\n')) return query;
3641 /* Repeat forever */
3647 * Handle "target" and "look".
3649 * Note that this code can be called from "get_aim_dir()".
3651 * All locations must be on the current panel. Consider the use of
3652 * "panel_bounds()" to allow "off-panel" targets, perhaps by using
3653 * some form of "scrolling" the map around the cursor. XXX XXX XXX
3654 * That is, consider the possibility of "auto-scrolling" the screen
3655 * while the cursor moves around. This may require changes in the
3656 * "update_mon()" code to allow "visibility" even if off panel, and
3657 * may require dynamic recalculation of the "temp" grid set.
3659 * Hack -- targeting/observing an "outer border grid" may induce
3660 * problems, so this is not currently allowed.
3662 * The player can use the direction keys to move among "interesting"
3663 * grids in a heuristic manner, or the "space", "+", and "-" keys to
3664 * move through the "interesting" grids in a sequential manner, or
3665 * can enter "location" mode, and use the direction keys to move one
3666 * grid at a time in any direction. The "t" (set target) command will
3667 * only target a monster (as opposed to a location) if the monster is
3668 * target_able and the "interesting" mode is being used.
3670 * The current grid is described using the "look" method above, and
3671 * a new command may be entered at any time, but note that if the
3672 * "TARGET_LOOK" bit flag is set (or if we are in "location" mode,
3673 * where "space" has no obvious meaning) then "space" will scan
3674 * through the description of the current grid until done, instead
3675 * of immediately jumping to the next "interesting" grid. This
3676 * allows the "target" command to retain its old semantics.
3678 * The "*", "+", and "-" keys may always be used to jump immediately
3679 * to the next (or previous) interesting grid, in the proper mode.
3681 * The "return" key may always be used to scan through a complete
3682 * grid description (forever).
3684 * This command will cancel any old target, even if used from
3685 * inside the "look" command.
3687 bool target_set(int mode)
3707 get_screen_size(&wid, &hgt);
3713 /* Cancel tracking */
3714 /* health_track(0); */
3717 /* Prepare the "temp" array */
3718 target_set_prepare(mode);
3720 /* Start near the player */
3726 /* Interesting grids */
3732 if (!(mode & TARGET_LOOK)) prt_path(y, x);
3735 c_ptr = &cave[y][x];
3738 if (target_able(c_ptr->m_idx))
3741 strcpy(info, "q»ß t·è p¼« o¸½ +¼¡ -Á°");
3743 strcpy(info, "q,t,p,o,+,-,<dir>");
3748 /* Dis-allow target */
3752 strcpy(info, "q»ß p¼« o¸½ +¼¡ -Á°");
3754 strcpy(info, "q,p,o,+,-,<dir>");
3759 /* Describe and Prompt */
3760 while (!(query = target_set_aux(y, x, mode, info)));
3762 /* Cancel tracking */
3763 /* health_track(0); */
3765 /* Assume no "direction" */
3770 if (query == '\r') query = 't';
3788 if (target_able(c_ptr->m_idx))
3790 health_track(c_ptr->m_idx);
3791 target_who = c_ptr->m_idx;
3810 if (!expand_list) done = TRUE;
3820 if (!expand_list) done = TRUE;
3827 /* Recenter the map around the player */
3831 p_ptr->update |= (PU_MONSTERS);
3834 p_ptr->redraw |= (PR_MAP);
3837 p_ptr->window |= (PW_OVERHEAD);
3842 /* Recalculate interesting grids */
3843 target_set_prepare(mode);
3862 /* Extract the action (if any) */
3863 d = get_keymap_dir(query);
3870 /* Hack -- move around */
3873 /* Modified to scroll to monster */
3874 int y2 = panel_row_min;
3875 int x2 = panel_col_min;
3877 /* Find a new monster */
3878 i = target_pick(temp_y[m], temp_x[m], ddy[d], ddx[d]);
3880 /* Request to target past last interesting grid */
3881 while (flag && (i < 0))
3883 /* Note the change */
3884 if (change_panel(ddy[d], ddx[d]))
3889 /* Recalculate interesting grids */
3890 target_set_prepare(mode);
3892 /* Look at interesting grids */
3895 /* Find a new monster */
3896 i = target_pick(v, u, ddy[d], ddx[d]);
3902 /* Nothing interesting */
3908 /* Restore previous position */
3911 panel_bounds_center();
3914 p_ptr->update |= (PU_MONSTERS);
3917 p_ptr->redraw |= (PR_MAP);
3920 p_ptr->window |= (PW_OVERHEAD);
3925 /* Recalculate interesting grids */
3926 target_set_prepare(mode);
3928 /* Look at boring grids */
3935 /* Do not move horizontally if unnecessary */
3936 if (((x < panel_col_min + wid / 2) && (dx > 0)) ||
3937 ((x > panel_col_min + wid / 2) && (dx < 0)))
3942 /* Do not move vertically if unnecessary */
3943 if (((y < panel_row_min + hgt / 2) && (dy > 0)) ||
3944 ((y > panel_row_min + hgt / 2) && (dy < 0)))
3949 /* Apply the motion */
3950 if ((y >= panel_row_min+hgt) || (y < panel_row_min) ||
3951 (x >= panel_col_min+wid) || (x < panel_col_min))
3953 if (change_panel(dy, dx)) target_set_prepare(mode);
3956 /* Slide into legality */
3957 if (x >= cur_wid-1) x = cur_wid - 2;
3958 else if (x <= 0) x = 1;
3960 /* Slide into legality */
3961 if (y >= cur_hgt-1) y = cur_hgt- 2;
3962 else if (y <= 0) y = 1;
3971 /* Arbitrary grids */
3974 bool move_fast = FALSE;
3976 if (!(mode & TARGET_LOOK)) prt_path(y, x);
3979 c_ptr = &cave[y][x];
3981 /* Default prompt */
3983 strcpy(info, "q»ß t·è p¼« m¶á +¼¡ -Á°");
3985 strcpy(info, "q,t,p,m,+,-,<dir>");
3989 /* Describe and Prompt (enable "TARGET_LOOK") */
3990 while (!(query = target_set_aux(y, x, mode | TARGET_LOOK, info)));
3992 /* Cancel tracking */
3993 /* health_track(0); */
3995 /* Assume no direction */
4000 if (query == '\r') query = 't';
4003 /* Analyze the keypress */
4027 /* Recenter the map around the player */
4031 p_ptr->update |= (PU_MONSTERS);
4034 p_ptr->redraw |= (PR_MAP);
4037 p_ptr->window |= (PW_OVERHEAD);
4042 /* Recalculate interesting grids */
4043 target_set_prepare(mode);
4065 /* Pick a nearby monster */
4066 for (i = 0; i < temp_n; i++)
4068 t = distance(y, x, temp_y[i], temp_x[i]);
4078 /* Nothing interesting */
4079 if (bd == 999) flag = FALSE;
4086 /* Extract the action (if any) */
4087 d = get_keymap_dir(query);
4089 /* XTRA HACK MOVEFAST */
4090 if (isupper(query)) move_fast = TRUE;
4097 /* Handle "direction" */
4103 /* XTRA HACK MOVEFAST */
4106 int mag = MIN(wid / 2, hgt / 2);
4116 /* Do not move horizontally if unnecessary */
4117 if (((x < panel_col_min + wid / 2) && (dx > 0)) ||
4118 ((x > panel_col_min + wid / 2) && (dx < 0)))
4123 /* Do not move vertically if unnecessary */
4124 if (((y < panel_row_min + hgt / 2) && (dy > 0)) ||
4125 ((y > panel_row_min + hgt / 2) && (dy < 0)))
4130 /* Apply the motion */
4131 if ((y >= panel_row_min + hgt) || (y < panel_row_min) ||
4132 (x >= panel_col_min + wid) || (x < panel_col_min))
4134 if (change_panel(dy, dx)) target_set_prepare(mode);
4137 /* Slide into legality */
4138 if (x >= cur_wid-1) x = cur_wid - 2;
4139 else if (x <= 0) x = 1;
4141 /* Slide into legality */
4142 if (y >= cur_hgt-1) y = cur_hgt- 2;
4143 else if (y <= 0) y = 1;
4151 /* Clear the top line */
4154 /* Recenter the map around the player */
4158 p_ptr->update |= (PU_MONSTERS);
4161 p_ptr->redraw |= (PR_MAP);
4164 p_ptr->window |= (PW_OVERHEAD);
4169 /* Failure to set target */
4170 if (!target_who) return (FALSE);
4178 * Get an "aiming direction" from the user.
4180 * The "dir" is loaded with 1,2,3,4,6,7,8,9 for "actual direction", and
4181 * "0" for "current target", and "-1" for "entry aborted".
4183 * Note that "Force Target", if set, will pre-empt user interaction,
4184 * if there is a usable target already set.
4186 * Note that confusion over-rides any (explicit?) user choice.
4188 bool get_aim_dir(int *dp)
4199 /* Global direction */
4202 /* Hack -- auto-target if requested */
4203 if (use_old_target && target_okay()) dir = 5;
4205 #ifdef ALLOW_REPEAT /* TNB */
4207 if (repeat_pull(dp))
4212 if (!(*dp == 5 && !target_okay()))
4214 /* return (TRUE); */
4219 #endif /* ALLOW_REPEAT -- TNB */
4221 /* Ask until satisfied */
4224 /* Choose a prompt */
4228 p = "Êý¸þ ('*'¤Ç¥¿¡¼¥²¥Ã¥ÈÁªÂò, ESC¤ÇÃæÃÇ)? ";
4230 p = "Direction ('*' to choose a target, Escape to cancel)? ";
4237 p = "Êý¸þ ('5'¤Ç¥¿¡¼¥²¥Ã¥È¤Ø, '*'¤Ç¥¿¡¼¥²¥Ã¥ÈºÆÁªÂò, ESC¤ÇÃæÃÇ)? ";
4239 p = "Direction ('5' for target, '*' to re-target, Escape to cancel)? ";
4244 /* Get a command (or Cancel) */
4245 if (!get_com(p, &command, TRUE)) break;
4249 if (command == '\r') command = 't';
4252 /* Convert various keys to "standard" keys */
4255 /* Use current target */
4266 /* Set new target */
4271 if (target_set(TARGET_KILL)) dir = 5;
4277 /* Extract the action (if any) */
4278 dir = get_keymap_dir(command);
4284 /* Verify requested targets */
4285 if ((dir == 5) && !target_okay()) dir = 0;
4294 project_length = 0; /* reset to default */
4298 /* Save the direction */
4301 /* Check for confusion */
4302 if (p_ptr->confused)
4305 /* Random direction */
4306 dir = ddd[randint0(8)];
4309 /* Notice confusion */
4310 if (command_dir != dir)
4314 msg_print("¤¢¤Ê¤¿¤Ïº®Í𤷤Ƥ¤¤ë¡£");
4316 msg_print("You are confused.");
4321 /* Save direction */
4324 #ifdef ALLOW_REPEAT /* TNB */
4326 /* repeat_push(dir); */
4327 repeat_push(command_dir);
4329 #endif /* ALLOW_REPEAT -- TNB */
4331 /* A "valid" direction was entered */
4338 * Request a "movement" direction (1,2,3,4,6,7,8,9) from the user,
4339 * and place it into "command_dir", unless we already have one.
4341 * This function should be used for all "repeatable" commands, such as
4342 * run, walk, open, close, bash, disarm, spike, tunnel, etc, as well
4343 * as all commands which must reference a grid adjacent to the player,
4344 * and which may not reference the grid under the player. Note that,
4345 * for example, it is no longer possible to "disarm" or "open" chests
4346 * in the same grid as the player.
4348 * Direction "5" is illegal and will (cleanly) abort the command.
4350 * This function tracks and uses the "global direction", and uses
4351 * that as the "desired direction", to which "confusion" is applied.
4353 bool get_rep_dir(int *dp, bool under)
4360 /* Global direction */
4363 #ifdef ALLOW_REPEAT /* TNB */
4365 if (repeat_pull(dp))
4368 /* return (TRUE); */
4371 #endif /* ALLOW_REPEAT -- TNB */
4373 /* Get a direction */
4378 /* Get a command (or Cancel) */
4380 if (!get_com("Êý¸þ (ESC¤ÇÃæÃÇ)? ", &ch, TRUE)) break;
4382 if (!get_com("Direction (Escape to cancel)? ", &ch, TRUE)) break;
4386 /* Look up the direction */
4387 dir = get_keymap_dir(ch);
4393 /* Prevent weirdness */
4394 if ((dir == 5) && (!under)) dir = 0;
4397 if (!dir) return (FALSE);
4399 /* Save desired direction */
4402 /* Apply "confusion" */
4403 if (p_ptr->confused)
4405 /* Standard confusion */
4406 if (randint0(100) < 75)
4408 /* Random direction */
4409 dir = ddd[randint0(8)];
4412 else if (p_ptr->riding)
4414 monster_type *m_ptr = &m_list[p_ptr->riding];
4415 monster_race *r_ptr = &r_info[m_ptr->r_idx];
4417 if (m_ptr->confused)
4419 /* Standard confusion */
4420 if (randint0(100) < 75)
4422 /* Random direction */
4423 dir = ddd[randint0(8)];
4426 else if ((r_ptr->flags1 & RF1_RAND_50) && (r_ptr->flags1 & RF1_RAND_25) && (randint0(100) < 50))
4428 /* Random direction */
4429 dir = ddd[randint0(8)];
4431 else if ((r_ptr->flags1 & RF1_RAND_50) && (randint0(100) < 25))
4433 /* Random direction */
4434 dir = ddd[randint0(8)];
4438 /* Notice confusion */
4439 if (command_dir != dir)
4441 if (p_ptr->confused)
4445 msg_print("¤¢¤Ê¤¿¤Ïº®Í𤷤Ƥ¤¤ë¡£");
4447 msg_print("You are confused.");
4453 monster_type *m_ptr = &m_list[p_ptr->riding];
4455 monster_desc(m_name, m_ptr, 0);
4456 if (m_ptr->confused)
4459 msg_format("%s¤Ïº®Í𤷤Ƥ¤¤ë¡£", m_name);
4461 msg_format("%^s is confusing.", m_name);
4468 msg_format("%s¤Ï»×¤¤Ä̤ê¤ËÆ°¤¤¤Æ¤¯¤ì¤Ê¤¤¡£", m_name);
4470 msg_format("You cannot control %s.", m_name);
4476 /* Save direction */
4479 #ifdef ALLOW_REPEAT /* TNB */
4481 /* repeat_push(dir); */
4482 repeat_push(command_dir);
4484 #endif /* ALLOW_REPEAT -- TNB */
4491 bool get_rep_dir2(int *dp)
4498 /* Global direction */
4501 #ifdef ALLOW_REPEAT /* TNB */
4503 if (repeat_pull(dp))
4506 /* return (TRUE); */
4509 #endif /* ALLOW_REPEAT -- TNB */
4511 /* Get a direction */
4516 /* Get a command (or Cancel) */
4518 if (!get_com("Êý¸þ (ESC¤ÇÃæÃÇ)? ", &ch, TRUE)) break;
4520 if (!get_com("Direction (Escape to cancel)? ", &ch, TRUE)) break;
4524 /* Look up the direction */
4525 dir = get_keymap_dir(ch);
4531 /* Prevent weirdness */
4532 if (dir == 5) dir = 0;
4535 if (!dir) return (FALSE);
4537 /* Save desired direction */
4540 /* Apply "confusion" */
4541 if (p_ptr->confused)
4543 /* Standard confusion */
4544 if (randint0(100) < 75)
4546 /* Random direction */
4547 dir = ddd[randint0(8)];
4551 /* Notice confusion */
4552 if (command_dir != dir)
4556 msg_print("¤¢¤Ê¤¿¤Ïº®Í𤷤Ƥ¤¤ë¡£");
4558 msg_print("You are confused.");
4563 /* Save direction */
4566 #ifdef ALLOW_REPEAT /* TNB */
4568 /* repeat_push(dir); */
4569 repeat_push(command_dir);
4571 #endif /* ALLOW_REPEAT -- TNB */
4578 int get_chaos_patron(void)
4580 return ((p_ptr->age + p_ptr->sc) % MAX_PATRON);
4584 void gain_level_reward(int chosen_reward)
4588 char wrath_reason[32] = "";
4589 int nasty_chance = 6;
4590 int dummy = 0, dummy2 = 0;
4593 char o_name[MAX_NLEN];
4599 if (multi_rew) return;
4600 else multi_rew = TRUE;
4604 if (p_ptr->lev == 13) nasty_chance = 2;
4605 else if (!(p_ptr->lev % 13)) nasty_chance = 3;
4606 else if (!(p_ptr->lev % 14)) nasty_chance = 12;
4608 if (one_in_(nasty_chance))
4609 type = randint1(20); /* Allow the 'nasty' effects */
4611 type = randint1(15) + 5; /* Or disallow them */
4613 if (type < 1) type = 1;
4614 if (type > 20) type = 20;
4619 sprintf(wrath_reason, "%s¤ÎÅܤê",
4620 chaos_patrons[p_ptr->chaos_patron]);
4622 sprintf(wrath_reason, "the Wrath of %s",
4623 chaos_patrons[p_ptr->chaos_patron]);
4627 effect = chaos_rewards[p_ptr->chaos_patron][type];
4629 if (one_in_(6) && !chosen_reward)
4632 msg_format("%^s¤ÏË«Èþ¤È¤·¤Æ¤¢¤Ê¤¿¤òÆÍÁ³ÊÑ°Û¤µ¤»¤¿¡£",
4633 chaos_patrons[p_ptr->chaos_patron]);
4635 msg_format("%^s rewards you with a mutation!",
4636 chaos_patrons[p_ptr->chaos_patron]);
4639 (void)gain_random_mutation(0);
4641 reward = "ÊÑ°Û¤·¤¿¡£";
4643 reward = "mutation";
4648 switch (chosen_reward ? chosen_reward : effect)
4652 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
4653 chaos_patrons[p_ptr->chaos_patron]);
4655 msg_format("The voice of %s booms out:",
4656 chaos_patrons[p_ptr->chaos_patron]);
4660 msg_print("¡ÖÆò¡¢¿·¤¿¤Ê¤ë»Ñ¤òɬÍפȤ»¤ê¡ª¡×");
4662 msg_print("'Thou needst a new form, mortal!'");
4667 reward = "ÊÑ°Û¤·¤¿¡£";
4669 reward = "polymorphing";
4674 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
4675 chaos_patrons[p_ptr->chaos_patron]);
4677 msg_format("The voice of %s booms out:",
4678 chaos_patrons[p_ptr->chaos_patron]);
4682 msg_print("¡ÖÆò¤ÏÎɤ¯¹Ô¤¤¤¿¤ê¡ªÂ³¤±¤è¡ª¡×");
4684 msg_print("'Well done, mortal! Lead on!'");
4687 if (p_ptr->prace == RACE_ANDROID)
4690 msg_print("¤·¤«¤·²¿¤âµ¯¤³¤é¤Ê¤«¤Ã¤¿¡£");
4692 msg_print("But, nothing happen.");
4695 else if (p_ptr->exp < PY_MAX_EXP)
4697 s32b ee = (p_ptr->exp / 2) + 10;
4698 if (ee > 100000L) ee = 100000L;
4700 msg_print("¹¹¤Ë·Ð¸³¤òÀѤó¤À¤è¤¦¤Êµ¤¤¬¤¹¤ë¡£");
4702 msg_print("You feel more experienced.");
4707 reward = "·Ð¸³ÃͤòÆÀ¤¿";
4709 reward = "experience";
4715 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
4716 chaos_patrons[p_ptr->chaos_patron]);
4718 msg_format("The voice of %s booms out:",
4719 chaos_patrons[p_ptr->chaos_patron]);
4723 msg_print("¡Ö²¼Ëͤ衢Æò¤½¤ì¤ËÃͤ»¤º¡£¡×");
4725 msg_print("'Thou didst not deserve that, slave.'");
4728 if (p_ptr->prace == RACE_ANDROID)
4731 msg_print("¤·¤«¤·²¿¤âµ¯¤³¤é¤Ê¤«¤Ã¤¿¡£");
4733 msg_print("But, nothing happen.");
4738 lose_exp(p_ptr->exp / 6);
4740 reward = "·Ð¸³Ãͤò¼º¤Ã¤¿¡£";
4742 reward = "losing experience";
4748 msg_format("%s¤ÎÀ¼¤¬¤µ¤µ¤ä¤¤¤¿:",
4749 chaos_patrons[p_ptr->chaos_patron]);
4751 msg_format("The voice of %s whispers:",
4752 chaos_patrons[p_ptr->chaos_patron]);
4756 msg_print("¡Ö²æ¤¬Í¿¤¨¤·Êª¤ò¸ÌÀ¤Ë»È¤¦¤Ù¤·¡£¡×");
4758 msg_print("'Use my gift wisely.'");
4761 acquirement(py, px, 1, FALSE, FALSE);
4763 reward = "¾å¼Á¤Ê¥¢¥¤¥Æ¥à¤ò¼ê¤ËÆþ¤ì¤¿¡£";
4765 reward = "a good item";
4770 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
4771 chaos_patrons[p_ptr->chaos_patron]);
4773 msg_format("The voice of %s booms out:",
4774 chaos_patrons[p_ptr->chaos_patron]);
4778 msg_print("¡Ö²æ¤¬Í¿¤¨¤·Êª¤ò¸ÌÀ¤Ë»È¤¦¤Ù¤·¡£¡×");
4780 msg_print("'Use my gift wisely.'");
4783 acquirement(py, px, 1, TRUE, FALSE);
4785 reward = "¹âµéÉʤΥ¢¥¤¥Æ¥à¤ò¼ê¤ËÆþ¤ì¤¿¡£";
4787 reward = "an excellent item";
4792 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
4793 chaos_patrons[p_ptr->chaos_patron]);
4795 msg_format("The voice of %s booms out:",
4796 chaos_patrons[p_ptr->chaos_patron]);
4800 msg_print("¡ÖÆò¤Î¹Ô¤¤¤Ïµ®¤·õ¤ËÃͤ»¤ê¡£¡×");
4802 msg_print("'Thy deed hath earned thee a worthy blade.'");
4805 /* Get local object */
4808 switch (randint1(p_ptr->lev))
4814 dummy2 = SV_MAIN_GAUCHE;
4823 dummy2 = SV_SMALL_SWORD;
4826 dummy2 = SV_BASILLARD;
4828 case 11: case 12: case 13:
4829 dummy2 = SV_SHORT_SWORD;
4835 dummy2 = SV_CUTLASS;
4838 dummy2 = SV_WAKIZASHI;
4841 dummy2 = SV_KHOPESH;
4847 dummy2 = SV_BROAD_SWORD;
4850 dummy2 = SV_LONG_SWORD;
4853 dummy2 = SV_SCIMITAR;
4856 dummy2 = SV_NINJATO;
4862 dummy2 = SV_BASTARD_SWORD;
4865 dummy2 = SV_GREAT_SCIMITAR;
4868 dummy2 = SV_CLAYMORE;
4871 dummy2 = SV_ESPADON;
4874 dummy2 = SV_TWO_HANDED_SWORD;
4877 dummy2 = SV_FLAMBERGE;
4880 dummy2 = SV_NO_DACHI;
4883 dummy2 = SV_EXECUTIONERS_SWORD;
4886 dummy2 = SV_ZWEIHANDER;
4889 dummy2 = SV_HAYABUSA;
4892 dummy2 = SV_BLADE_OF_CHAOS;
4895 object_prep(q_ptr, lookup_kind(dummy, dummy2));
4896 q_ptr->to_h = 3 + randint1(dun_level) % 10;
4897 q_ptr->to_d = 3 + randint1(dun_level) % 10;
4898 one_resistance(q_ptr);
4899 q_ptr->name2 = EGO_CHAOTIC;
4901 /* Drop it in the dungeon */
4902 (void)drop_near(q_ptr, -1, py, px);
4904 reward = "(º®ÆÙ)¤ÎÉð´ï¤ò¼ê¤ËÆþ¤ì¤¿¡£";
4906 reward = "chaos weapon";
4911 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
4912 chaos_patrons[p_ptr->chaos_patron]);
4914 msg_format("The voice of %s booms out:",
4915 chaos_patrons[p_ptr->chaos_patron]);
4919 msg_print("¡ÖÆò¤Î¹Ô¤¤¤Ïµ®¤Ê󤤤ËÃͤ»¤ê¡£¡×");
4921 msg_print("'Thy deed hath earned thee a worthy reward.'");
4924 acquirement(py, px, randint1(2) + 1, FALSE, FALSE);
4926 reward = "¾å¼Á¤Ê¥¢¥¤¥Æ¥à¤ò¼ê¤ËÆþ¤ì¤¿¡£";
4928 reward = "good items";
4933 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
4934 chaos_patrons[p_ptr->chaos_patron]);
4936 msg_format("The voice of %s booms out:",
4937 chaos_patrons[p_ptr->chaos_patron]);
4941 msg_print("¡Ö²¼Ëͤ衢Æò¤Î¸¥¿È¤Ø¤Î²æ¤¬Àˤ·¤ß̵¤Ê󤤤ò¸«¤ë¤¬¤è¤¤¡£¡×");
4943 msg_print("'Behold, mortal, how generously I reward thy loyalty.'");
4946 acquirement(py, px, randint1(2) + 1, TRUE, FALSE);
4948 reward = "¹âµéÉʤΥ¢¥¤¥Æ¥à¤ò¼ê¤ËÆþ¤ì¤¿¡£";
4950 reward = "excellent items";
4955 msg_format("%s¤ÎÀ¼¤¬¹ì¤ÅϤä¿:",
4956 chaos_patrons[p_ptr->chaos_patron]);
4958 msg_format("The voice of %s thunders:",
4959 chaos_patrons[p_ptr->chaos_patron]);
4963 msg_print("¡Ö²¼Ëͤ衢ÆòÐþËý¤Ê¤ê¡£¡×");
4965 msg_print("'Thou art growing arrogant, mortal.'");
4968 (void)activate_ty_curse(FALSE, &count);
4970 reward = "²Ò¡¹¤·¤¤¼ö¤¤¤ò¤«¤±¤é¤ì¤¿¡£";
4977 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
4978 chaos_patrons[p_ptr->chaos_patron]);
4980 msg_format("The voice of %s booms out:",
4981 chaos_patrons[p_ptr->chaos_patron]);
4985 msg_print("¡Ö²æ¤¬²¼Ëͤ¿¤Á¤è¡¢¤«¤ÎÐþËý¤Ê¤ë¼Ô¤òÅݤ¹¤Ù¤·¡ª¡×");
4987 msg_print("'My pets, destroy the arrogant mortal!'");
4990 for (dummy = 0; dummy < randint1(5) + 1; dummy++)
4992 (void)summon_specific(0, py, px, dun_level, 0, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET));
4995 reward = "¥â¥ó¥¹¥¿¡¼¤ò¾¤´¤µ¤ì¤¿¡£";
4997 reward = "summoning hostile monsters";
5002 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5003 chaos_patrons[p_ptr->chaos_patron]);
5005 msg_format("The voice of %s booms out:",
5006 chaos_patrons[p_ptr->chaos_patron]);
5010 msg_print("¡ÖÆò¡¢¤è¤ê¶¯¤Å¨¤òɬÍפȤ»¤ê¡ª¡×");
5012 msg_print("'Thou needst worthier opponents!'");
5015 activate_hi_summon(py, px, FALSE);
5017 reward = "¥â¥ó¥¹¥¿¡¼¤ò¾¤´¤µ¤ì¤¿¡£";
5019 reward = "summoning many hostile monsters";
5024 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5025 chaos_patrons[p_ptr->chaos_patron]);
5027 msg_format("The voice of %s booms out:",
5028 chaos_patrons[p_ptr->chaos_patron]);
5032 msg_print("¡Ö»à¤ÈÇ˲õ¤³¤½²æ¤¬´î¤Ó¤Ê¤ê¡ª¡×");
5034 msg_print("'Death and destruction! This pleaseth me!'");
5039 reward = "¥«¥ª¥¹¤ÎÎϤ¬±²´¬¤¤¤¿¡£";
5041 reward = "calling chaos";
5046 msg_format("%s¤ÎÀ¼¤¬ÌĤê¶Á¤¤¤¿:",
5047 chaos_patrons[p_ptr->chaos_patron]);
5049 msg_format("The voice of %s rings out:",
5050 chaos_patrons[p_ptr->chaos_patron]);
5054 msg_print("¡Öα¤Þ¤ë¤Î¤À¡¢²¼Ëͤ衣;¤¬Æò¤ÎÆùÂΤòÃ䨤󡣡×");
5056 msg_print("'Stay, mortal, and let me mold thee.'");
5059 if (one_in_(3) && !(chaos_stats[p_ptr->chaos_patron] < 0))
5060 do_inc_stat(chaos_stats[p_ptr->chaos_patron]);
5062 do_inc_stat(randint0(6));
5064 reward = "ǽÎÏÃͤ¬¾å¤¬¤Ã¤¿¡£";
5066 reward = "increasing a stat";
5071 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5072 chaos_patrons[p_ptr->chaos_patron]);
5074 msg_format("The voice of %s booms out:",
5075 chaos_patrons[p_ptr->chaos_patron]);
5079 msg_print("¡Ö²¼Ëͤ衢;¤ÏÆò¤ËË°¤ß¤¿¤ê¡£¡×");
5081 msg_print("'I grow tired of thee, mortal.'");
5084 if (one_in_(3) && !(chaos_stats[p_ptr->chaos_patron] < 0))
5085 do_dec_stat(chaos_stats[p_ptr->chaos_patron]);
5087 (void)do_dec_stat(randint0(6));
5089 reward = "ǽÎÏÃͤ¬²¼¤¬¤Ã¤¿¡£";
5091 reward = "decreasing a stat";
5096 msg_format("%s¤ÎÀ¼¤¬¹ì¤ÅϤä¿:",
5097 chaos_patrons[p_ptr->chaos_patron]);
5099 msg_format("The voice of %s thunders:",
5100 chaos_patrons[p_ptr->chaos_patron]);
5104 msg_print("¡ÖÆò¡¢¸¬µõ¤¿¤ë¤³¤È¤ò³Ø¤Ö¤Ù¤·¡ª¡×");
5105 msg_print("¤¢¤Ê¤¿¤Ï°ÊÁ°¤è¤ê¼å¤¯¤Ê¤Ã¤¿¡ª");
5107 msg_print("'Thou needst a lesson in humility, mortal!'");
5108 msg_print("You feel less powerful!");
5111 for (dummy = 0; dummy < 6; dummy++)
5113 (void)dec_stat(dummy, 10 + randint1(15), TRUE);
5116 reward = "Á´Ç½ÎÏÃͤ¬²¼¤¬¤Ã¤¿¡£";
5118 reward = "decreasing all stats";
5123 msg_format("%s¤ÎÎϤ¬¿¨¤ì¤ë¤Î¤ò´¶¤¸¤¿¡£",
5125 msg_format("You feel the power of %s touch you.",
5128 chaos_patrons[p_ptr->chaos_patron]);
5131 reward = "½ý¤¬ÊѲ½¤·¤¿¡£";
5133 reward = "polymorphing wounds";
5138 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5139 chaos_patrons[p_ptr->chaos_patron]);
5141 msg_format("The voice of %s booms out:",
5142 chaos_patrons[p_ptr->chaos_patron]);
5146 msg_print("¡Ö²æ¤¬¤µ¤µ¤ä¤«¤Ê¤ë»òʪ¤ò¼õ¤±¤È¤ë¤¬¤è¤¤¡ª¡×");
5148 msg_print("'Receive this modest gift from me!'");
5151 for (dummy = 0; dummy < 6; dummy++)
5153 (void)do_inc_stat(dummy);
5156 reward = "Á´Ç½ÎÏÃͤ¬¾å¤¬¤Ã¤¿¡£";
5158 reward = "increasing all stats";
5163 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5164 chaos_patrons[p_ptr->chaos_patron]);
5166 msg_format("The voice of %s booms out:",
5167 chaos_patrons[p_ptr->chaos_patron]);
5171 msg_print("¡Ö¶ì¤·¤à¤¬¤è¤¤¡¢ÌµÇ½¤Ê¶ò¤«¼Ô¤è¡ª¡×");
5173 msg_print("'Suffer, pathetic fool!'");
5176 fire_ball(GF_DISINTEGRATE, 0, p_ptr->lev * 4, 4);
5177 take_hit(DAMAGE_NOESCAPE, p_ptr->lev * 4, wrath_reason, -1);
5179 reward = "ʬ²ò¤Îµå¤¬È¯À¸¤·¤¿¡£";
5181 reward = "generating disintegration ball";
5186 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5187 chaos_patrons[p_ptr->chaos_patron]);
5189 msg_format("The voice of %s booms out:",
5190 chaos_patrons[p_ptr->chaos_patron]);
5194 msg_print("¡Öᴤ뤬¤è¤¤¡¢²æ¤¬²¼Ëͤ衪¡×");
5196 msg_print("'Rise, my servant!'");
5200 (void)set_poisoned(0);
5202 (void)set_confused(0);
5207 for (dummy = 0; dummy < 6; dummy++)
5209 (void)do_res_stat(dummy);
5212 reward = "ÂÎÎϤ¬²óÉü¤·¤¿¡£";
5218 if (!buki_motteruka(INVEN_RARM)) break;
5220 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5221 chaos_patrons[p_ptr->chaos_patron]);
5223 msg_format("The voice of %s booms out:",
5224 chaos_patrons[p_ptr->chaos_patron]);
5228 msg_print("¡ÖÆò¡¢Éð´ï¤ËÍê¤ë¤³¤È¤Ê¤«¤ì¡£¡×");
5230 msg_print("'Thou reliest too much on thy weapon.'");
5233 object_desc(o_name, &inventory[INVEN_RARM], TRUE, 0);
5234 (void)curse_weapon(FALSE, INVEN_RARM);
5236 reward = format("%s¤¬Ç˲õ¤µ¤ì¤¿¡£", o_name);
5238 reward = format("destroying %s", o_name);
5242 if (!inventory[INVEN_BODY].k_idx) break;
5244 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5245 chaos_patrons[p_ptr->chaos_patron]);
5247 msg_format("The voice of %s booms out:",
5248 chaos_patrons[p_ptr->chaos_patron]);
5252 msg_print("¡ÖÆò¡¢Ëɶñ¤ËÍê¤ë¤³¤È¤Ê¤«¤ì¡£¡×");
5254 msg_print("'Thou reliest too much on thine equipment.'");
5257 object_desc(o_name, &inventory[INVEN_BODY], TRUE, 0);
5258 (void)curse_armor();
5260 reward = format("%s¤¬Ç˲õ¤µ¤ì¤¿¡£", o_name);
5262 reward = format("destroying %s", o_name);
5267 msg_format("%s¤ÎÀ¼¤¬¤µ¤µ¤ä¤¤¤¿:",
5268 chaos_patrons[p_ptr->chaos_patron]);
5270 msg_format("The voice of %s whispers:",
5271 chaos_patrons[p_ptr->chaos_patron]);
5275 msg_print("¡Ö²æ¤òÅܤꤷ¤á¤¿ºá¤ò½þ¤¦¤Ù¤·¡£¡×");
5277 msg_print("'Now thou shalt pay for annoying me.'");
5280 switch (randint1(4))
5283 (void)activate_ty_curse(FALSE, &count);
5285 reward = "²Ò¡¹¤·¤¤¼ö¤¤¤ò¤«¤±¤é¤ì¤¿¡£";
5291 activate_hi_summon(py, px, FALSE);
5293 reward = "¥â¥ó¥¹¥¿¡¼¤ò¾¤´¤µ¤ì¤¿¡£";
5295 reward = "summoning hostile monsters";
5301 if (!buki_motteruka(INVEN_RARM)) break;
5302 object_desc(o_name, &inventory[INVEN_RARM], TRUE, 0);
5303 (void)curse_weapon(FALSE, INVEN_RARM);
5305 reward = format("%s¤¬Ç˲õ¤µ¤ì¤¿¡£", o_name);
5307 reward = format("destroying %s", o_name);
5312 if (!inventory[INVEN_BODY].k_idx) break;
5313 object_desc(o_name, &inventory[INVEN_BODY], TRUE, 0);
5314 (void)curse_armor();
5316 reward = format("%s¤¬Ç˲õ¤µ¤ì¤¿¡£", o_name);
5318 reward = format("destroying %s", o_name);
5323 for (dummy = 0; dummy < 6; dummy++)
5325 (void)dec_stat(dummy, 10 + randint1(15), TRUE);
5328 reward = "Á´Ç½ÎÏÃͤ¬²¼¤¬¤Ã¤¿¡£";
5330 reward = "decreasing all stats";
5337 msg_format("%s¤ÎÀ¼¤¬¹ì¤ÅϤä¿:",
5339 msg_format("The voice of %s thunders:",
5342 chaos_patrons[p_ptr->chaos_patron]);
5344 msg_print("¡Ö»à¤Ì¤¬¤è¤¤¡¢²¼Ëͤ衪¡×");
5346 msg_print("'Die, mortal!'");
5349 take_hit(DAMAGE_LOSELIFE, p_ptr->lev * 4, wrath_reason, -1);
5350 for (dummy = 0; dummy < 6; dummy++)
5352 (void)dec_stat(dummy, 10 + randint1(15), FALSE);
5354 activate_hi_summon(py, px, FALSE);
5355 (void)activate_ty_curse(FALSE, &count);
5356 if (one_in_(2)) (void)curse_weapon(FALSE, INVEN_RARM);
5357 if (one_in_(2)) (void)curse_armor();
5361 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5362 chaos_patrons[p_ptr->chaos_patron]);
5364 msg_format("The voice of %s booms out:",
5365 chaos_patrons[p_ptr->chaos_patron]);
5369 msg_print("¡Ö»à¤ÈÇ˲õ¤³¤½²æ¤¬´î¤Ó¤Ê¤ê¡ª¡×");
5371 msg_print("'Death and destruction! This pleaseth me!'");
5374 (void)destroy_area(py, px, 25, FALSE);
5376 reward = "¥À¥ó¥¸¥ç¥ó¤¬*Ç˲õ*¤µ¤ì¤¿¡£";
5378 reward = "*destruct*ing dungeon";
5383 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5384 chaos_patrons[p_ptr->chaos_patron]);
5386 msg_format("The voice of %s booms out:",
5387 chaos_patrons[p_ptr->chaos_patron]);
5391 msg_print("¡Ö²æ¡¢Æò¤ÎŨ¤òËõ»¦¤»¤ó¡ª¡×");
5393 msg_print("'Let me relieve thee of thine oppressors!'");
5396 (void)symbol_genocide(0, FALSE);
5398 reward = "¥â¥ó¥¹¥¿¡¼¤¬Ëõ»¦¤µ¤ì¤¿¡£";
5400 reward = "genociding monsters";
5405 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5406 chaos_patrons[p_ptr->chaos_patron]);
5408 msg_format("The voice of %s booms out:",
5409 chaos_patrons[p_ptr->chaos_patron]);
5413 msg_print("¡Ö²æ¡¢Æò¤ÎŨ¤òËõ»¦¤»¤ó¡ª¡×");
5415 msg_print("'Let me relieve thee of thine oppressors!'");
5418 (void)mass_genocide(0, FALSE);
5420 reward = "¥â¥ó¥¹¥¿¡¼¤¬Ëõ»¦¤µ¤ì¤¿¡£";
5422 reward = "genociding nearby monsters";
5427 msg_format("%s¤ÎÎϤ¬Å¨¤ò¹¶·â¤¹¤ë¤Î¤ò´¶¤¸¤¿¡ª",
5428 chaos_patrons[p_ptr->chaos_patron]);
5430 msg_format("You can feel the power of %s assault your enemies!",
5431 chaos_patrons[p_ptr->chaos_patron]);
5434 (void)dispel_monsters(p_ptr->lev * 4);
5438 msg_format("%s¤Ï¤¢¤Ê¤¿¤ò̵»ë¤·¤¿¡£",
5439 chaos_patrons[p_ptr->chaos_patron]);
5441 msg_format("%s ignores you.",
5442 chaos_patrons[p_ptr->chaos_patron]);
5448 msg_format("%s¤ÏË«Èþ¤È¤·¤Æ°Ëâ¤Î»È¤¤¤ò¤è¤³¤·¤¿¡ª",chaos_patrons[p_ptr->chaos_patron]);
5450 msg_format("%s rewards you with a demonic servant!",chaos_patrons[p_ptr->chaos_patron]);
5453 if (!summon_specific(-1, py, px, dun_level, SUMMON_DEMON, PM_FORCE_PET))
5455 msg_print("²¿¤â¸½¤ì¤Ê¤«¤Ã¤¿...");
5457 msg_print("Nobody ever turns up...");
5461 reward = "°Ë⤬¥Ú¥Ã¥È¤Ë¤Ê¤Ã¤¿¡£";
5463 reward = "a demonic servant";
5469 msg_format("%s¤ÏË«Èþ¤È¤·¤Æ»È¤¤¤ò¤è¤³¤·¤¿¡ª",chaos_patrons[p_ptr->chaos_patron]);
5471 msg_format("%s rewards you with a servant!",chaos_patrons[p_ptr->chaos_patron]);
5474 if (!summon_specific(-1, py, px, dun_level, 0, PM_FORCE_PET))
5476 msg_print("²¿¤â¸½¤ì¤Ê¤«¤Ã¤¿...");
5478 msg_print("Nobody ever turns up...");
5482 reward = "¥â¥ó¥¹¥¿¡¼¤¬¥Ú¥Ã¥È¤Ë¤Ê¤Ã¤¿¡£";
5484 reward = "a servant";
5490 msg_format("%s¤ÏË«Èþ¤È¤·¤Æ¥¢¥ó¥Ç¥Ã¥É¤Î»È¤¤¤ò¤è¤³¤·¤¿¡£",chaos_patrons[p_ptr->chaos_patron]);
5492 msg_format("%s rewards you with an undead servant!",chaos_patrons[p_ptr->chaos_patron]);
5495 if (!summon_specific(-1, py, px, dun_level, SUMMON_UNDEAD, PM_FORCE_PET))
5497 msg_print("²¿¤â¸½¤ì¤Ê¤«¤Ã¤¿...");
5499 msg_print("Nobody ever turns up...");
5503 reward = "¥¢¥ó¥Ç¥Ã¥É¤¬¥Ú¥Ã¥È¤Ë¤Ê¤Ã¤¿¡£";
5505 reward = "an undead servant";
5511 msg_format("%s¤ÎÀ¼¤¬¤É¤â¤Ã¤¿:",
5513 msg_format("The voice of %s stammers:",
5516 chaos_patrons[p_ptr->chaos_patron]);
5518 msg_format("¡Ö¤¢¡¼¡¢¤¢¡¼¡¢Åú¤¨¤Ï %d/%d¡£¼ÁÌä¤Ï²¿¡©¡×", type, effect);
5520 msg_format("'Uh... uh... the answer's %d/%d, what's the question?'", type, effect);
5528 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, format("¥Ñ¥È¥í¥ó¤ÎÊó½·¤Ç%s", reward));
5530 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, format("The patron rewards you with %s.", reward));
5537 * old -- from PsiAngband.
5539 bool tgt_pt(int *x_ptr, int *y_ptr)
5543 bool success = FALSE;
5548 get_screen_size(&wid, &hgt);
5554 msg_print("¾ì½ê¤òÁª¤ó¤Ç¥¹¥Ú¡¼¥¹¥¡¼¤ò²¡¤·¤Æ²¼¤µ¤¤¡£");
5556 msg_print("Select a point and press space.");
5558 msg_flag = FALSE; /* prevents "-more-" message. */
5560 while ((ch != ESCAPE) && !success)
5562 bool move_fast = FALSE;
5564 move_cursor_relative(y, x);
5576 if (x == px && y == py) ch = 0;
5579 else success = TRUE;
5583 /* Look up the direction */
5584 d = get_keymap_dir(ch);
5586 /* XTRA HACK MOVEFAST */
5587 if (isupper(ch)) move_fast = TRUE;
5589 /* Handle "direction" */
5595 /* XTRA HACK MOVEFAST */
5598 int mag = MIN(wid / 2, hgt / 2);
5608 /* Do not move horizontally if unnecessary */
5609 if (((x < panel_col_min + wid / 2) && (dx > 0)) ||
5610 ((x > panel_col_min + wid / 2) && (dx < 0)))
5615 /* Do not move vertically if unnecessary */
5616 if (((y < panel_row_min + hgt / 2) && (dy > 0)) ||
5617 ((y > panel_row_min + hgt / 2) && (dy < 0)))
5622 /* Apply the motion */
5623 if ((y >= panel_row_min + hgt) || (y < panel_row_min) ||
5624 (x >= panel_col_min + wid) || (x < panel_col_min))
5626 /* if (change_panel(dy, dx)) target_set_prepare(mode); */
5627 change_panel(dy, dx);
5630 /* Slide into legality */
5631 if (x >= cur_wid-1) x = cur_wid - 2;
5632 else if (x <= 0) x = 1;
5634 /* Slide into legality */
5635 if (y >= cur_hgt-1) y = cur_hgt- 2;
5636 else if (y <= 0) y = 1;
5643 /* Clear the top line */
5646 /* Recenter the map around the player */
5650 p_ptr->update |= (PU_MONSTERS);
5653 p_ptr->redraw |= (PR_MAP);
5656 p_ptr->window |= (PW_OVERHEAD);
5667 bool get_hack_dir(int *dp)
5677 /* Global direction */
5680 /* (No auto-targeting) */
5682 /* Ask until satisfied */
5685 /* Choose a prompt */
5689 p = "Êý¸þ ('*'¤Ç¥¿¡¼¥²¥Ã¥ÈÁªÂò, ESC¤ÇÃæÃÇ)? ";
5691 p = "Direction ('*' to choose a target, Escape to cancel)? ";
5698 p = "Êý¸þ ('5'¤Ç¥¿¡¼¥²¥Ã¥È¤Ø, '*'¤Ç¥¿¡¼¥²¥Ã¥ÈºÆÁªÂò, ESC¤ÇÃæÃÇ)? ";
5700 p = "Direction ('5' for target, '*' to re-target, Escape to cancel)? ";
5705 /* Get a command (or Cancel) */
5706 if (!get_com(p, &command, TRUE)) break;
5710 if (command == '\r') command = 't';
5713 /* Convert various keys to "standard" keys */
5716 /* Use current target */
5727 /* Set new target */
5732 if (target_set(TARGET_KILL)) dir = 5;
5738 /* Look up the direction */
5739 dir = get_keymap_dir(command);
5745 /* Verify requested targets */
5746 if ((dir == 5) && !target_okay()) dir = 0;
5753 if (!dir) return (FALSE);
5755 /* Save the direction */
5758 /* Check for confusion */
5759 if (p_ptr->confused)
5762 /* Random direction */
5763 dir = ddd[randint0(8)];
5766 /* Notice confusion */
5767 if (command_dir != dir)
5771 msg_print("¤¢¤Ê¤¿¤Ïº®Í𤷤Ƥ¤¤ë¡£");
5773 msg_print("You are confused.");
5778 /* Save direction */
5781 /* A "valid" direction was entered */
5787 * ¥¨¥Í¥ë¥®¡¼¤ÎÁý²ÃÎÌ10d5¤ò®¤¯·×»»¤¹¤ë¤¿¤á¤Î´Ø¿ô
5790 #define Go_no_JuuJou 5*5*5*5*5*5*5*5*5*5
5792 s16b gain_energy(void)
5795 s32b energy_result = 10;
5798 tmp = randint0(Go_no_JuuJou);
5800 for (i = 0; i < 9; i ++){
5801 energy_result += tmp % 5;
5805 return (s16b)(energy_result + tmp);
5812 s16b bow_energy(int sval)
5816 /* Analyze the launcher */
5819 /* Sling and ammo */
5826 /* Short Bow and Arrow */
5833 /* Long Bow and Arrow */
5840 /* Bow of irresponsiblity and Arrow */
5847 /* Light Crossbow and Bolt */
5854 /* Heavy Crossbow and Bolt */
5869 int bow_tmul(int sval)
5873 /* Analyze the launcher */
5876 /* Sling and ammo */
5883 /* Short Bow and Arrow */
5890 /* Long Bow and Arrow */
5897 /* Bow of irresponsiblity and Arrow */
5904 /* Light Crossbow and Bolt */
5911 /* Heavy Crossbow and Bolt */
5923 * Return alignment title
5925 cptr your_alignment(void)
5928 if (p_ptr->align > 150) return "ÂçÁ±";
5929 else if (p_ptr->align > 50) return "ÃæÁ±";
5930 else if (p_ptr->align > 10) return "¾®Á±";
5931 else if (p_ptr->align > -11) return "ÃæΩ";
5932 else if (p_ptr->align > -51) return "¾®°";
5933 else if (p_ptr->align > -151) return "Ãæ°";
5936 if (p_ptr->align > 150) return "Lawful";
5937 else if (p_ptr->align > 50) return "Good";
5938 else if (p_ptr->align > 10) return "Neutral Good";
5939 else if (p_ptr->align > -11) return "Neutral";
5940 else if (p_ptr->align > -51) return "Neutral Evil";
5941 else if (p_ptr->align > -151) return "Evil";
5942 else return "Chaotic";
5948 * Return proficiency level of weapons and misc. skills (except riding)
5950 int weapon_exp_level(int weapon_exp)
5952 if (weapon_exp < WEAPON_EXP_BEGINNER) return EXP_LEVEL_UNSKILLED;
5953 else if (weapon_exp < WEAPON_EXP_SKILLED) return EXP_LEVEL_BEGINNER;
5954 else if (weapon_exp < WEAPON_EXP_EXPERT) return EXP_LEVEL_SKILLED;
5955 else if (weapon_exp < WEAPON_EXP_MASTER) return EXP_LEVEL_EXPERT;
5956 else return EXP_LEVEL_MASTER;
5961 * Return proficiency level of riding
5963 int riding_exp_level(int riding_exp)
5965 if (riding_exp < RIDING_EXP_BEGINNER) return EXP_LEVEL_UNSKILLED;
5966 else if (riding_exp < RIDING_EXP_SKILLED) return EXP_LEVEL_BEGINNER;
5967 else if (riding_exp < RIDING_EXP_EXPERT) return EXP_LEVEL_SKILLED;
5968 else if (riding_exp < RIDING_EXP_MASTER) return EXP_LEVEL_EXPERT;
5969 else return EXP_LEVEL_MASTER;
5974 * Return proficiency level of spells
5976 int spell_exp_level(int spell_exp)
5978 if (spell_exp < SPELL_EXP_BEGINNER) return EXP_LEVEL_UNSKILLED;
5979 else if (spell_exp < SPELL_EXP_SKILLED) return EXP_LEVEL_BEGINNER;
5980 else if (spell_exp < SPELL_EXP_EXPERT) return EXP_LEVEL_SKILLED;
5981 else if (spell_exp < SPELL_EXP_MASTER) return EXP_LEVEL_EXPERT;
5982 else return EXP_LEVEL_MASTER;