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;
31 if (p_ptr->max_exp < 0) p_ptr->max_exp = 0;
32 if (p_ptr->max_max_exp < 0) p_ptr->max_max_exp = 0;
34 /* Hack -- upper limit */
35 if (p_ptr->exp > PY_MAX_EXP) p_ptr->exp = PY_MAX_EXP;
36 if (p_ptr->max_exp > PY_MAX_EXP) p_ptr->max_exp = PY_MAX_EXP;
37 if (p_ptr->max_max_exp > PY_MAX_EXP) p_ptr->max_max_exp = PY_MAX_EXP;
39 /* Hack -- maintain "max" experience */
40 if (p_ptr->exp > p_ptr->max_exp) p_ptr->max_exp = p_ptr->exp;
42 /* Hack -- maintain "max max" experience */
43 if (p_ptr->max_exp > p_ptr->max_max_exp) p_ptr->max_max_exp = p_ptr->max_exp;
45 /* Redraw experience */
46 p_ptr->redraw |= (PR_EXP);
52 /* Lose levels while possible */
53 while ((p_ptr->lev > 1) &&
54 (p_ptr->exp < ((android ? player_exp_a : player_exp)[p_ptr->lev - 2] * p_ptr->expfact / 100L)))
59 /* Update some stuff */
60 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
62 /* Redraw some stuff */
63 p_ptr->redraw |= (PR_LEV | PR_TITLE);
66 p_ptr->window |= (PW_PLAYER);
73 /* Gain levels while possible */
74 while ((p_ptr->lev < PY_MAX_LEVEL) &&
75 (p_ptr->exp >= ((android ? player_exp_a : player_exp)[p_ptr->lev-1] * p_ptr->expfact / 100L)))
80 /* Save the highest level */
81 if (p_ptr->lev > p_ptr->max_plv)
83 p_ptr->max_plv = p_ptr->lev;
85 if ((p_ptr->pclass == CLASS_CHAOS_WARRIOR) ||
86 (p_ptr->muta2 & MUT2_CHAOS_GIFT))
90 if (p_ptr->prace == RACE_BEASTMAN)
92 if (one_in_(5)) level_mutation = TRUE;
94 level_inc_stat = TRUE;
96 do_cmd_write_nikki(NIKKI_LEVELUP, p_ptr->lev, NULL);
104 msg_format("¥ì¥Ù¥ë %d ¤Ë¤è¤¦¤³¤½¡£", p_ptr->lev);
106 msg_format("Welcome to level %d.", p_ptr->lev);
110 /* Update some stuff */
111 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
113 /* Redraw some stuff */
114 p_ptr->redraw |= (PR_LEV | PR_TITLE);
117 p_ptr->window |= (PW_PLAYER | PW_SPELL | PW_INVEN);
119 /* HP¤ÈMP¤Î¾å¾ºÎ̤òɽ¼¨ */
129 if(!(p_ptr->max_plv % 10))
139 cnv_stat(p_ptr->stat_max[0], tmp);
140 prt(format(" a) ÏÓÎÏ (¸½ºßÃÍ %s)", tmp), 2, 14);
141 cnv_stat(p_ptr->stat_max[1], tmp);
142 prt(format(" b) ÃÎǽ (¸½ºßÃÍ %s)", tmp), 3, 14);
143 cnv_stat(p_ptr->stat_max[2], tmp);
144 prt(format(" c) ¸¤µ (¸½ºßÃÍ %s)", tmp), 4, 14);
145 cnv_stat(p_ptr->stat_max[3], tmp);
146 prt(format(" d) ´ïÍÑ (¸½ºßÃÍ %s)", tmp), 5, 14);
147 cnv_stat(p_ptr->stat_max[4], tmp);
148 prt(format(" e) ÂÑµ× (¸½ºßÃÍ %s)", tmp), 6, 14);
149 cnv_stat(p_ptr->stat_max[5], tmp);
150 prt(format(" f) Ì¥ÎÏ (¸½ºßÃÍ %s)", tmp), 7, 14);
152 prt(" ¤É¤ÎǽÎÏÃͤò¾å¤²¤Þ¤¹¤«¡©", 1, 14);
154 cnv_stat(p_ptr->stat_max[0], tmp);
155 prt(format(" a) Str (cur %s)", tmp), 2, 14);
156 cnv_stat(p_ptr->stat_max[1], tmp);
157 prt(format(" b) Int (cur %s)", tmp), 3, 14);
158 cnv_stat(p_ptr->stat_max[2], tmp);
159 prt(format(" c) Wis (cur %s)", tmp), 4, 14);
160 cnv_stat(p_ptr->stat_max[3], tmp);
161 prt(format(" d) Dex (cur %s)", tmp), 5, 14);
162 cnv_stat(p_ptr->stat_max[4], tmp);
163 prt(format(" e) Con (cur %s)", tmp), 6, 14);
164 cnv_stat(p_ptr->stat_max[5], tmp);
165 prt(format(" f) Chr (cur %s)", tmp), 7, 14);
167 prt(" Which stat do you want to raise?", 1, 14);
172 if ((choice >= 'a') && (choice <= 'f')) break;
174 for(n = 0; n < 6; n++)
175 if (n != choice - 'a')
178 if (get_check("¤è¤í¤·¤¤¤Ç¤¹¤«¡©")) break;
180 if (get_check("Are you sure? ")) break;
183 do_inc_stat(choice - 'a');
186 else if(!(p_ptr->max_plv % 2))
187 do_inc_stat(randint0(6));
193 msg_print("¤¢¤Ê¤¿¤ÏÊѤï¤Ã¤¿µ¤¤¬¤¹¤ë...");
195 msg_print("You feel different...");
198 (void)gain_random_mutation(0);
199 level_mutation = FALSE;
203 * Ê󽷤ǥì¥Ù¥ë¤¬¾å¤ë¤ÈºÆµ¢Åª¤Ë check_experience() ¤¬
204 * ¸Æ¤Ð¤ì¤ë¤Î¤Ç½çÈÖ¤òºÇ¸å¤Ë¤¹¤ë¡£
208 gain_level_reward(0);
209 level_reward = FALSE;
212 /* Update some stuff */
213 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
215 /* Redraw some stuff */
216 p_ptr->redraw |= (PR_LEV | PR_TITLE);
219 p_ptr->window |= (PW_PLAYER | PW_SPELL);
228 * Hack -- Return the "automatic coin type" of a monster race
229 * Used to allocate proper treasure when "Creeping coins" die
231 * XXX XXX XXX Note the use of actual "monster names"
233 static int get_coin_type(int r_idx)
235 /* Analyze monsters */
238 case MON_COPPER_COINS: return 2;
239 case MON_SILVER_COINS: return 5;
240 case MON_GOLD_COINS: return 10;
241 case MON_MITHRIL_COINS:
242 case MON_MITHRIL_GOLEM: return 16;
243 case MON_ADAMANT_COINS: return 17;
252 * Hack -- determine if a template is Cloak
254 static bool kind_is_cloak(int k_idx)
256 object_kind *k_ptr = &k_info[k_idx];
258 /* Analyze the item type */
259 if (k_ptr->tval == TV_CLOAK)
264 /* Assume not good */
270 * Hack -- determine if a template is Polearm
272 static bool kind_is_polearm(int k_idx)
274 object_kind *k_ptr = &k_info[k_idx];
276 /* Analyze the item type */
277 if (k_ptr->tval == TV_POLEARM)
282 /* Assume not good */
288 * Hack -- determine if a template is Sword
290 static bool kind_is_sword(int k_idx)
292 object_kind *k_ptr = &k_info[k_idx];
294 /* Analyze the item type */
295 if ((k_ptr->tval == TV_SWORD) && (k_ptr->sval > 2))
300 /* Assume not good */
306 * Hack -- determine if a template is Book
308 static bool kind_is_book(int k_idx)
310 object_kind *k_ptr = &k_info[k_idx];
312 /* Analyze the item type */
313 if ((k_ptr->tval >= TV_LIFE_BOOK) && (k_ptr->tval <= TV_CRUSADE_BOOK))
318 /* Assume not good */
324 * Hack -- determine if a template is Good book
326 static bool kind_is_good_book(int k_idx)
328 object_kind *k_ptr = &k_info[k_idx];
330 /* Analyze the item type */
331 if ((k_ptr->tval >= TV_LIFE_BOOK) && (k_ptr->tval <= TV_CRUSADE_BOOK) && (k_ptr->tval != TV_ARCANE_BOOK) && (k_ptr->sval > 1))
336 /* Assume not good */
342 * Hack -- determine if a template is Armor
344 static bool kind_is_armor(int k_idx)
346 object_kind *k_ptr = &k_info[k_idx];
348 /* Analyze the item type */
349 if (k_ptr->tval == TV_HARD_ARMOR)
354 /* Assume not good */
360 * Check for "Quest" completion when a quest monster is killed or charmed.
362 void check_quest_completion(monster_type *m_ptr)
364 int i, j, y, x, ny, nx, i2, j2;
368 bool create_stairs = FALSE;
374 /* Get the location */
379 quest_num = p_ptr->inside_quest;
381 /* Search for an active quest on this dungeon level */
384 for (i = max_quests - 1; i > 0; i--)
386 /* Quest is not active */
387 if (quest[i].status != QUEST_STATUS_TAKEN)
390 /* Quest is not a dungeon quest */
391 if (quest[i].flags & QUEST_FLAG_PRESET)
394 /* Quest is not on this level */
395 if ((quest[i].level != dun_level) &&
396 (quest[i].type != QUEST_TYPE_KILL_ANY_LEVEL))
399 /* Not a "kill monster" quest */
400 if ((quest[i].type == QUEST_TYPE_FIND_ARTIFACT) ||
401 (quest[i].type == QUEST_TYPE_FIND_EXIT))
404 /* Interesting quest */
405 if ((quest[i].type == QUEST_TYPE_KILL_NUMBER) ||
406 (quest[i].type == QUEST_TYPE_KILL_ALL))
409 /* Interesting quest */
410 if (((quest[i].type == QUEST_TYPE_KILL_LEVEL) ||
411 (quest[i].type == QUEST_TYPE_KILL_ANY_LEVEL) ||
412 (quest[i].type == QUEST_TYPE_RANDOM)) &&
413 (quest[i].r_idx == m_ptr->r_idx))
420 /* Handle the current quest */
421 if (quest_num && (quest[quest_num].status == QUEST_STATUS_TAKEN))
426 switch (quest[i].type)
428 case QUEST_TYPE_KILL_NUMBER:
432 if (quest[i].cur_num >= quest[i].num_mon)
434 if (record_fix_quest) do_cmd_write_nikki(NIKKI_FIX_QUEST_C, i, NULL);
435 /* completed quest */
436 quest[i].status = QUEST_STATUS_COMPLETED;
437 quest[i].complev = (byte)p_ptr->lev;
439 if (!(quest[i].flags & QUEST_FLAG_SILENT))
442 msg_print("¥¯¥¨¥¹¥È¤òãÀ®¤·¤¿¡ª");
444 msg_print("You just completed your quest!");
450 quest[i].cur_num = 0;
454 case QUEST_TYPE_KILL_ALL:
458 if (!is_hostile(m_ptr)) break;
460 /* Count all hostile monsters */
461 for (i2 = 0; i2 < cur_wid; ++i2)
462 for (j2 = 0; j2 < cur_hgt; j2++)
463 if (cave[j2][i2].m_idx > 0)
464 if (is_hostile(&m_list[cave[j2][i2].m_idx]))
467 if ((number_mon - 1) == 0)
469 if (record_fix_quest) do_cmd_write_nikki(NIKKI_FIX_QUEST_C, i, NULL);
471 if (quest[i].flags & QUEST_FLAG_SILENT)
473 quest[i].status = QUEST_STATUS_FINISHED;
477 quest[i].status = QUEST_STATUS_COMPLETED;
478 quest[i].complev = (byte)p_ptr->lev;
480 msg_print("¥¯¥¨¥¹¥È¤òãÀ®¤·¤¿¡ª");
482 msg_print("You just completed your quest!");
490 case QUEST_TYPE_KILL_LEVEL:
491 case QUEST_TYPE_RANDOM:
493 /* Only count valid monsters */
494 if (quest[i].r_idx != m_ptr->r_idx)
499 if (quest[i].cur_num >= quest[i].max_num)
501 if (record_fix_quest && (quest[i].type == QUEST_TYPE_KILL_LEVEL)) do_cmd_write_nikki(NIKKI_FIX_QUEST_C, i, NULL);
502 if (record_rand_quest && (quest[i].type == QUEST_TYPE_RANDOM)) do_cmd_write_nikki(NIKKI_RAND_QUEST_C, i, NULL);
503 /* completed quest */
504 quest[i].status = QUEST_STATUS_COMPLETED;
505 quest[i].complev = (byte)p_ptr->lev;
506 if (!(quest[i].flags & QUEST_FLAG_PRESET))
508 create_stairs = TRUE;
509 p_ptr->inside_quest = 0;
512 if (!(quest[i].flags & QUEST_FLAG_SILENT))
515 msg_print("¥¯¥¨¥¹¥È¤òãÀ®¤·¤¿¡ª");
517 msg_print("You just completed your quest!");
523 /* Finish the two main quests without rewarding */
524 if ((i == QUEST_OBERON) || (i == QUEST_SERPENT))
526 quest[i].status = QUEST_STATUS_FINISHED;
529 if (quest[i].type == QUEST_TYPE_RANDOM)
532 quest[i].status = QUEST_STATUS_FINISHED;
537 case QUEST_TYPE_KILL_ANY_LEVEL:
540 if (quest[i].cur_num >= quest[i].max_num)
542 if (record_fix_quest) do_cmd_write_nikki(NIKKI_FIX_QUEST_C, i, NULL);
543 /* completed quest */
544 quest[i].status = QUEST_STATUS_COMPLETED;
545 quest[i].complev = (byte)p_ptr->lev;
547 if (!(quest[i].flags & QUEST_FLAG_SILENT))
550 msg_print("¥¯¥¨¥¹¥È¤òãÀ®¤·¤¿¡ª");
552 msg_print("You just completed your quest!");
557 quest[i].cur_num = 0;
564 /* Create a magical staircase */
568 while (cave_perma_bold(y, x) || cave[y][x].o_idx || (cave[y][x].info & CAVE_OBJECT) )
570 /* Pick a location */
571 scatter(&ny, &nx, y, x, 1, 0);
577 /* Explain the staircase */
579 msg_print("ËâË¡¤Î³¬Ãʤ¬¸½¤ì¤¿...");
581 msg_print("A magical staircase appears...");
585 /* Create stairs down */
586 cave_set_feat(y, x, FEAT_MORE);
588 /* Remember to update everything */
589 p_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MONSTERS | PU_MON_LITE);
597 for (j = 0; j < (dun_level / 15)+1; j++)
599 /* Get local object */
602 /* Wipe the object */
605 /* Make a great object */
606 make_object(q_ptr, AM_GOOD | AM_GREAT);
608 /* Drop it in the dungeon */
609 (void)drop_near(q_ptr, -1, y, x);
616 * Return monster death string
618 cptr extract_note_dies(monster_race *r_ptr)
620 /* Some monsters get "destroyed" */
621 if (!monster_living(r_ptr))
625 for (i = 0; i < 4; i++)
627 if (r_ptr->blow[i].method == RBM_EXPLODE)
630 return "¤ÏÇúȯ¤·¤ÆÊ´¡¹¤Ë¤Ê¤Ã¤¿¡£";
632 return " explodes into tiny shreds.";
640 return " is destroyed.";
644 /* Assume a default death */
654 * Handle the "death" of a monster.
656 * Disperse treasures centered at the monster location based on the
657 * various flags contained in the monster flags fields.
659 * Check for "Quest" completion when a quest monster is killed.
661 * Note that only the player can induce "monster_death()" on Uniques.
662 * Thus (for now) all Quest monsters should be Uniques.
664 * Note that monsters can now carry objects, and when a monster dies,
665 * it drops all of its objects, which may disappear in crowded rooms.
667 void monster_death(int m_idx, bool drop_item)
676 monster_type *m_ptr = &m_list[m_idx];
678 monster_race *r_ptr = &r_info[m_ptr->r_idx];
680 bool visible = (m_ptr->ml || (r_ptr->flags1 & RF1_UNIQUE));
684 bool do_gold = (!(r_ptr->flags1 & RF1_ONLY_ITEM));
685 bool do_item = (!(r_ptr->flags1 & RF1_ONLY_GOLD));
686 bool cloned = (m_ptr->smart & SM_CLONED) ? TRUE : FALSE;
687 int force_coin = get_coin_type(m_ptr->r_idx);
692 bool drop_chosen_item = drop_item && !cloned && !p_ptr->inside_arena
693 && !p_ptr->inside_battle && !is_pet(m_ptr);
695 /* The caster is dead? */
696 if (world_monster && world_monster == m_idx) world_monster = 0;
698 /* Notice changes in view */
699 if (r_ptr->flags7 & (RF7_LITE_MASK | RF7_DARK_MASK))
701 /* Update some things */
702 p_ptr->update |= (PU_MON_LITE);
705 /* Get the location */
709 if (record_named_pet && is_pet(m_ptr) && m_ptr->nickname)
713 monster_desc(m_name, m_ptr, MD_INDEF_VISIBLE);
714 do_cmd_write_nikki(NIKKI_NAMED_PET, 3, m_name);
717 /* Let monsters explode! */
718 for (i = 0; i < 4; i++)
720 if (r_ptr->blow[i].method == RBM_EXPLODE)
722 int flg = PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL;
723 int typ = mbe_info[r_ptr->blow[i].effect].explode_type;
724 int d_dice = r_ptr->blow[i].d_dice;
725 int d_side = r_ptr->blow[i].d_side;
726 int damage = damroll(d_dice, d_side);
728 project(m_idx, 3, y, x, damage, typ, flg, -1);
733 if (m_ptr->mflag2 & MFLAG2_CHAMELEON)
735 choose_new_monster(m_idx, TRUE, MON_CHAMELEON);
736 r_ptr = &r_info[m_ptr->r_idx];
739 /* Check for quest completion */
740 check_quest_completion(m_ptr);
742 /* Handle the possibility of player vanquishing arena combatant -KMW- */
743 if (p_ptr->inside_arena && !is_pet(m_ptr))
745 p_ptr->exit_bldg = TRUE;
747 if (p_ptr->arena_number > MAX_ARENA_MONS)
750 msg_print("ÁÇÀ²¤é¤·¤¤¡ª·¯¤³¤½¿¿¤Î¾¡Íø¼Ô¤À¡£");
752 msg_print("You are a Genuine Champion!");
758 msg_print("¾¡Íø¡ª¥Á¥ã¥ó¥Ô¥ª¥ó¤Ø¤ÎÆ»¤ò¿Ê¤ó¤Ç¤¤¤ë¡£");
760 msg_print("Victorious! You're on your way to becoming Champion.");
764 if (arena_info[p_ptr->arena_number].tval)
766 /* Get local object */
769 /* Prepare to make a prize */
770 object_prep(q_ptr, lookup_kind(arena_info[p_ptr->arena_number].tval, arena_info[p_ptr->arena_number].sval));
772 apply_magic(q_ptr, object_level, AM_NO_FIXED_ART);
774 /* Drop it in the dungeon */
775 (void)drop_near(q_ptr, -1, y, x);
778 if (p_ptr->arena_number > MAX_ARENA_MONS) p_ptr->arena_number++;
779 p_ptr->arena_number++;
784 /* Extract monster name */
785 monster_desc(m_name, m_ptr, MD_IGNORE_HALLU | MD_ASSUME_VISIBLE | MD_INDEF_VISIBLE);
787 do_cmd_write_nikki(NIKKI_ARENA, p_ptr->arena_number, m_name);
791 if (m_idx == p_ptr->riding)
793 if (rakuba(-1, FALSE))
796 msg_print("ÃÏÌ̤ËÍî¤È¤µ¤ì¤¿¡£");
798 msg_print("You have fallen from your riding pet.");
803 /* Drop a dead corpse? */
804 if (one_in_(r_ptr->flags1 & RF1_UNIQUE ? 1 : 4) &&
805 ((r_ptr->flags9 & RF9_DROP_CORPSE) ||
806 (r_ptr->flags9 & RF9_DROP_SKELETON)) &&
807 !(p_ptr->inside_arena || p_ptr->inside_battle || cloned || ((m_ptr->r_idx == today_mon) && is_pet(m_ptr))))
809 /* Assume skeleton */
813 * We cannot drop a skeleton? Note, if we are in this check,
814 * we *know* we can drop at least a corpse or a skeleton
816 if (!(r_ptr->flags9 & RF9_DROP_SKELETON))
818 else if ((r_ptr->flags9 & RF9_DROP_CORPSE) && (r_ptr->flags1 && RF1_UNIQUE))
821 /* Else, a corpse is more likely unless we did a "lot" of damage */
822 else if (r_ptr->flags9 & RF9_DROP_CORPSE)
824 /* Lots of damage in one blow */
825 if ((0 - ((m_ptr->maxhp) / 4)) > m_ptr->hp)
827 if (one_in_(5)) corpse = TRUE;
831 if (!one_in_(5)) corpse = TRUE;
835 /* Get local object */
838 /* Prepare to make an object */
839 object_prep(q_ptr, lookup_kind(TV_CORPSE, (corpse ? SV_CORPSE : SV_SKELETON)));
841 apply_magic(q_ptr, object_level, AM_NO_FIXED_ART);
843 q_ptr->pval = m_ptr->r_idx;
845 /* Drop it in the dungeon */
846 (void)drop_near(q_ptr, -1, y, x);
849 /* Drop objects being carried */
850 monster_drop_carried_objects(m_ptr);
852 if (r_ptr->flags1 & RF1_DROP_GOOD) mo_mode |= AM_GOOD;
853 if (r_ptr->flags1 & RF1_DROP_GREAT) mo_mode |= AM_GREAT;
855 switch (m_ptr->r_idx)
857 case MON_PINK_HORROR:
858 /* Pink horrors are replaced with 2 Blue horrors */
859 if (!(p_ptr->inside_arena || p_ptr->inside_battle))
863 for (i = 0; i < 2; i++)
866 bool pet = is_pet(m_ptr);
869 if (pet) mode |= PM_FORCE_PET;
871 if (summon_specific((pet ? -1 : m_idx), wy, wx, 100, SUMMON_BLUE_HORROR, mode))
873 if (player_can_see_bold(wy, wx))
880 msg_print("¥Ô¥ó¥¯¡¦¥Û¥é¡¼¤ÏʬÎö¤·¤¿¡ª");
882 msg_print("The Pink horror divides!");
887 case MON_BLOODLETTER:
888 /* Bloodletters of Khorne may drop a blade of chaos */
889 if (drop_chosen_item && (randint1(100) < 15))
891 /* Get local object */
894 /* Prepare to make a Blade of Chaos */
895 object_prep(q_ptr, lookup_kind(TV_SWORD, SV_BLADE_OF_CHAOS));
897 apply_magic(q_ptr, object_level, AM_NO_FIXED_ART | mo_mode);
899 /* Drop it in the dungeon */
900 (void)drop_near(q_ptr, -1, y, x);
905 if (drop_chosen_item && (dun_level > 9))
907 /* Get local object */
910 /* Wipe the object */
913 /* Activate restriction */
914 if ((dun_level > 49) && one_in_(5))
915 get_obj_num_hook = kind_is_good_book;
917 get_obj_num_hook = kind_is_book;
920 make_object(q_ptr, mo_mode);
922 /* Drop it in the dungeon */
923 (void)drop_near(q_ptr, -1, y, x);
929 * Mega^3-hack: killing a 'Warrior of the Dawn' is likely to
930 * spawn another in the fallen one's place!
932 if (!p_ptr->inside_arena && !p_ptr->inside_battle)
938 bool pet = is_pet(m_ptr);
942 scatter(&wy, &wx, y, x, 20, 0);
944 while (!(in_bounds(wy, wx) && cave_empty_bold2(wy, wx)) && --attempts);
949 if (pet) mode |= PM_FORCE_PET;
951 if (summon_specific((pet ? -1 : m_idx), wy, wx, 100, SUMMON_DAWN, mode))
953 if (player_can_see_bold(wy, wx))
955 msg_print("¿·¤¿¤ÊÀï»Î¤¬¸½¤ì¤¿¡ª");
957 msg_print("A new warrior steps forth!");
967 /* One more ultra-hack: An Unmaker goes out with a big bang! */
969 int flg = PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL;
970 (void)project(m_idx, 6, y, x, 100, GF_CHAOS, flg, -1);
974 case MON_UNICORN_ORD:
977 /* Reward for "lazy" player */
978 if (p_ptr->pseikaku == SEIKAKU_NAMAKE)
982 if (!drop_chosen_item) break;
989 a_idx = ART_NAMAKE_HAMMER;
992 a_idx = ART_NAMAKE_BOW;
995 a_idx = ART_NAMAKE_ARMOR;
999 while (a_info[a_idx].cur_num);
1001 if (a_info[a_idx].cur_num == 0)
1003 /* Create the artifact */
1004 create_named_art(a_idx, y, x);
1005 a_info[a_idx].cur_num = 1;
1011 if (!drop_chosen_item) break;
1013 /* Get local object */
1016 /* Mega-Hack -- Prepare to make "Grond" */
1017 object_prep(q_ptr, lookup_kind(TV_HAFTED, SV_GROND));
1019 /* Mega-Hack -- Mark this item as "Grond" */
1020 q_ptr->name1 = ART_GROND;
1022 /* Mega-Hack -- Actually create "Grond" */
1023 apply_magic(q_ptr, -1, AM_GOOD | AM_GREAT);
1025 /* Drop it in the dungeon */
1026 (void)drop_near(q_ptr, -1, y, x);
1028 /* Get local object */
1031 /* Mega-Hack -- Prepare to make "Chaos" */
1032 object_prep(q_ptr, lookup_kind(TV_CROWN, SV_CHAOS));
1034 /* Mega-Hack -- Mark this item as "Chaos" */
1035 q_ptr->name1 = ART_CHAOS;
1037 /* Mega-Hack -- Actually create "Chaos" */
1038 apply_magic(q_ptr, -1, AM_GOOD | AM_GREAT);
1040 /* Drop it in the dungeon */
1041 (void)drop_near(q_ptr, -1, y, x);
1044 case MON_B_DEATH_SWORD:
1045 if (drop_chosen_item)
1047 /* Get local object */
1050 /* Prepare to make a broken sword */
1051 object_prep(q_ptr, lookup_kind(TV_SWORD, randint1(2)));
1053 /* Drop it in the dungeon */
1054 (void)drop_near(q_ptr, -1, y, x);
1060 if (drop_chosen_item && ((m_ptr->r_idx == MON_A_GOLD) ||
1061 ((m_ptr->r_idx == MON_A_SILVER) && (r_ptr->r_pkills % 5 == 0))))
1063 /* Get local object */
1066 /* Prepare to make a Can of Toys */
1067 object_prep(q_ptr, lookup_kind(TV_CHEST, SV_CHEST_KANDUME));
1069 apply_magic(q_ptr, object_level, AM_NO_FIXED_ART);
1071 /* Drop it in the dungeon */
1072 (void)drop_near(q_ptr, -1, y, x);
1078 int flg = PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL;
1079 (void)project(m_idx, 3, y, x, damroll(20, 10), GF_FIRE, flg, -1);
1084 if (!drop_chosen_item) break;
1086 switch (r_ptr->d_char)
1091 /* Get local object */
1094 /* Wipe the object */
1097 /* Activate restriction */
1098 get_obj_num_hook = kind_is_cloak;
1101 make_object(q_ptr, mo_mode);
1103 /* Drop it in the dungeon */
1104 (void)drop_near(q_ptr, -1, y, x);
1111 /* Get local object */
1114 /* Wipe the object */
1117 /* Activate restriction */
1118 get_obj_num_hook = kind_is_polearm;
1120 /* Make a poleweapon */
1121 make_object(q_ptr, mo_mode);
1123 /* Drop it in the dungeon */
1124 (void)drop_near(q_ptr, -1, y, x);
1131 /* Get local object */
1134 /* Wipe the object */
1137 /* Activate restriction */
1138 get_obj_num_hook = kind_is_armor;
1140 /* Make a hard armor */
1141 make_object(q_ptr, mo_mode);
1143 /* Drop it in the dungeon */
1144 (void)drop_near(q_ptr, -1, y, x);
1149 if (m_ptr->r_idx != MON_STORMBRINGER)
1151 /* Get local object */
1154 /* Wipe the object */
1157 /* Activate restriction */
1158 get_obj_num_hook = kind_is_sword;
1161 make_object(q_ptr, mo_mode);
1163 /* Drop it in the dungeon */
1164 (void)drop_near(q_ptr, -1, y, x);
1171 /* Mega-Hack -- drop fixed items */
1172 if (drop_chosen_item)
1177 switch (m_ptr->r_idx)
1197 case MON_STORMBRINGER:
1198 a_idx = ART_STORMBRINGER;
1203 a_idx = ART_CRIMSON;
1213 a_idx = ART_KUSANAGI;
1243 a_idx = ART_WEREWINDLE;
1251 a_idx = ART_GRAYSWANDIR;
1262 a_idx = ART_TWILIGHT;
1267 a_idx = ART_ELENDIL;
1282 a_idx = ART_DESTINY;
1287 a_idx = ART_ZANTETSU;
1302 a_idx = ART_WINBLOWS;
1306 case MON_LUNGORTHIN:
1311 case MON_JACK_SHADOWS:
1317 a_idx = ART_STONEMASK;
1322 a_idx = ART_SOULCRUSH;
1327 a_idx = ART_EXCALIBUR_J;
1332 a_idx = ART_SHUTEN_DOJI;
1337 a_idx = ART_GOTHMOG;
1347 if ((a_idx > 0) && ((randint0(100) < chance) || p_ptr->wizard))
1349 if (a_info[a_idx].cur_num == 0)
1351 /* Create the artifact */
1352 create_named_art(a_idx, y, x);
1353 a_info[a_idx].cur_num = 1;
1357 if ((r_ptr->flags7 & RF7_GUARDIAN) && (d_info[dungeon_type].final_guardian == m_ptr->r_idx))
1359 int k_idx = d_info[dungeon_type].final_object ? d_info[dungeon_type].final_object
1360 : lookup_kind(TV_SCROLL, SV_SCROLL_ACQUIREMENT);
1362 if (d_info[dungeon_type].final_artifact)
1364 int a_idx = d_info[dungeon_type].final_artifact;
1365 if (!a_info[a_idx].cur_num)
1367 /* Create the artifact */
1368 create_named_art(a_idx, y, x);
1369 a_info[a_idx].cur_num = 1;
1371 /* Prevent rewarding both artifact and "default" object */
1372 if (!d_info[dungeon_type].final_object) k_idx = 0;
1378 /* Get local object */
1381 /* Prepare to make a reward */
1382 object_prep(q_ptr, k_idx);
1384 apply_magic(q_ptr, object_level, AM_NO_FIXED_ART | AM_GOOD);
1386 /* Drop it in the dungeon */
1387 (void)drop_near(q_ptr, -1, y, x);
1390 msg_format("¤¢¤Ê¤¿¤Ï%s¤òÀ©ÇƤ·¤¿¡ª",d_name+d_info[dungeon_type].name);
1392 msg_format("You have conquered %s!",d_name+d_info[dungeon_type].name);
1397 /* Determine how much we can drop */
1398 if ((r_ptr->flags1 & RF1_DROP_60) && (randint0(100) < 60)) number++;
1399 if ((r_ptr->flags1 & RF1_DROP_90) && (randint0(100) < 90)) number++;
1400 if (r_ptr->flags1 & RF1_DROP_1D2) number += damroll(1, 2);
1401 if (r_ptr->flags1 & RF1_DROP_2D2) number += damroll(2, 2);
1402 if (r_ptr->flags1 & RF1_DROP_3D2) number += damroll(3, 2);
1403 if (r_ptr->flags1 & RF1_DROP_4D2) number += damroll(4, 2);
1405 if (cloned && !(r_ptr->flags1 & RF1_UNIQUE))
1406 number = 0; /* Clones drop no stuff unless Cloning Pits */
1408 if (is_pet(m_ptr) || p_ptr->inside_battle || p_ptr->inside_arena)
1409 number = 0; /* Pets drop no stuff */
1410 if (!drop_item && (r_ptr->d_char != '$')) number = 0;
1412 /* Hack -- handle creeping coins */
1413 coin_type = force_coin;
1415 /* Average dungeon and monster levels */
1416 object_level = (dun_level + r_ptr->level) / 2;
1418 /* Drop some objects */
1419 for (j = 0; j < number; j++)
1421 /* Get local object */
1424 /* Wipe the object */
1428 if (do_gold && (!do_item || (randint0(100) < 50)))
1430 /* Make some gold */
1431 if (!make_gold(q_ptr)) continue;
1440 /* Make an object */
1441 if (!make_object(q_ptr, mo_mode)) continue;
1447 /* Drop it in the dungeon */
1448 (void)drop_near(q_ptr, -1, y, x);
1451 /* Reset the object level */
1452 object_level = base_level;
1454 /* Reset "coin" type */
1458 /* Take note of any dropped treasure */
1459 if (visible && (dump_item || dump_gold))
1461 /* Take notes on treasure */
1462 lore_treasure(m_idx, dump_item, dump_gold);
1465 /* Only process "Quest Monsters" */
1466 if (!(r_ptr->flags1 & RF1_QUESTOR)) return;
1467 if (p_ptr->inside_battle) return;
1470 if ((m_ptr->r_idx == MON_SERPENT) && !cloned)
1473 p_ptr->total_winner = TRUE;
1475 /* Redraw the "title" */
1476 p_ptr->redraw |= (PR_TITLE);
1479 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, "¸«»ö¤ËÊѶòÈÚÅܤξ¡Íø¼Ô¤È¤Ê¤Ã¤¿¡ª");
1481 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, "become *WINNER* of Hengband finely!");
1484 if ((p_ptr->pclass == CLASS_CHAOS_WARRIOR) || (p_ptr->muta2 & MUT2_CHAOS_GIFT))
1487 msg_format("%s¤«¤é¤ÎÀ¼¤¬¶Á¤¤¤¿¡£", chaos_patrons[p_ptr->chaos_patron]);
1488 msg_print("¡Ø¤è¤¯¤ä¤Ã¤¿¡¢ÄêÌ¿¤Î¼Ô¤è¡ª¡Ù");
1490 msg_format("The voice of %s booms out:", chaos_patrons[p_ptr->chaos_patron]);
1491 msg_print("'Thou art donst well, mortal!'");
1495 /* Congratulations */
1497 msg_print("*** ¤ª¤á¤Ç¤È¤¦ ***");
1499 msg_print("*** CONGRATULATIONS ***");
1503 msg_print("¤¢¤Ê¤¿¤Ï¥²¡¼¥à¤ò¥³¥ó¥×¥ê¡¼¥È¤·¤Þ¤·¤¿¡£");
1505 msg_print("You have won the game!");
1509 msg_print("½àÈ÷¤¬À°¤Ã¤¿¤é°úÂà(¼«»¦¥³¥Þ¥ó¥É)¤·¤Æ¤â·ë¹½¤Ç¤¹¡£");
1511 msg_print("You may retire (commit suicide) when you are ready.");
1517 * Modify the physical damage done to the monster.
1518 * (for example when it's invulnerable or shielded)
1520 * ToDo: Accept a damage-type to calculate the modified damage from
1521 * things like fire, frost, lightning, poison, ... attacks.
1523 * "type" is not yet used and should be 0.
1525 int mon_damage_mod(monster_type *m_ptr, int dam, bool is_psy_spear)
1527 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1529 if ((r_ptr->flagsr & RFR_RES_ALL) && dam > 0)
1532 if((dam == 0) && one_in_(3)) dam = 1;
1535 if (m_ptr->invulner)
1539 if(!p_ptr->blind && m_ptr->ml)
1542 msg_print("¥Ð¥ê¥¢¤òÀÚ¤êÎö¤¤¤¿¡ª");
1544 msg_print("The barrier is penetrated!");
1548 else if (!one_in_(PENETRATE_INVULNERABILITY))
1556 static void get_exp_from_mon(int dam, monster_type *m_ptr)
1558 s32b div, new_exp, new_exp_frac;
1559 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1560 int monnum_penarty = 0;
1562 if (!m_ptr->r_idx) return;
1563 if (is_pet(m_ptr) || p_ptr->inside_battle) return;
1567 u32b m_exp_h, m_exp_l;
1569 if ((r_ptr->flags2 & RF2_MULTIPLY) || (m_ptr->r_idx == MON_DAWN))
1571 monnum_penarty = r_ptr->r_pkills / 400;
1572 if (monnum_penarty > 8) monnum_penarty = 8;
1574 if (r_ptr->flags1 & RF1_UNIQUE)
1576 m_exp = (long)r_ptr->mexp * r_ptr->level;
1577 div = (p_ptr->max_plv+2);
1581 m_exp = (long)r_ptr->mexp * r_ptr->level * SPEED_TO_ENERGY(m_ptr->mspeed);
1582 div = (p_ptr->max_plv+2) * SPEED_TO_ENERGY(r_ptr->speed);
1584 m_exp_h = m_exp/0x10000L;
1585 m_exp_l = m_exp%0x10000L;
1588 m_exp_h += m_exp_l / 0x10000L;
1589 m_exp_l %= 0x10000L;
1591 /* real monster maxhp have effect on EXP */
1592 if(!(r_ptr->flags1 & RF1_FORCE_MAXHP))
1594 u32b maxhp = m_ptr->max_maxhp*2;
1597 m_exp_h += m_exp_l / 0x10000L;
1598 m_exp_l %= 0x10000L;
1600 div *= r_ptr->hdice * (r_ptr->hside + 1);
1602 if (!dun_level && (!(r_ptr->flags8 & RF8_WILD_ONLY) || !(r_ptr->flags1 & RF1_UNIQUE))) div *= 5;
1603 div_h = div/0x10000L;
1604 div_l = div%0x10000L;
1605 div_h *= (m_ptr->max_maxhp*2);
1606 div_l *= (m_ptr->max_maxhp*2);
1607 div_h += div_l / 0x10000L;
1610 while (monnum_penarty)
1614 div_h += div_l / 0x10000L;
1619 m_exp_l = (0x7fffffff & (m_exp_h << 16)) | m_exp_l;
1620 m_exp_h = m_exp_h >> 15;
1621 div_l = (0x7fffffff & (div_h << 16)) | div_l;
1622 div_h = div_h >> 15;
1624 #define M_INT_GREATER63(h1,l1,h2,l2) ( (h1>h2)||( (h1==h2)&&(l1>=l2)))
1625 #define M_INT_SUB63(h1,l1, h2,l2) {h1-=h2;if(l1<l2){l1+=0x80000000;h1--;}l1-=l2;}
1626 #define M_INT_LSHIFT63(h1,l1) {h1=(h1<<1)|(l1>>30);l1=(l1<<1)&0x7fffffff;}
1627 #define M_INT_RSHIFT63(h1,l1) {l1=(l1>>1)|(h1<<30);h1>>=1;}
1628 #define M_INT_DIV63(h1,l1,h2,l2,result) \
1632 while( M_INT_GREATER63(h1,l1, h2, l2) ){M_INT_LSHIFT63(h2, l2); bit<<=1;} \
1633 for(bit>>=1; bit>=1; bit>>=1){ \
1634 M_INT_RSHIFT63(h2, l2); \
1635 if(M_INT_GREATER63(h1, l1, h2, l2)) \
1636 {result|=bit;M_INT_SUB63(h1, l1, h2, l2);} \
1640 /* Give some experience for the kill */
1641 M_INT_DIV63(m_exp_h, m_exp_l, div_h, div_l, new_exp);
1643 /* Handle fractional experience */
1644 /* multiply 0x10000L to remainder */
1645 m_exp_h = (m_exp_h<<16) | (m_exp_l>>15);
1647 M_INT_DIV63(m_exp_h, m_exp_l, div_h, div_l, new_exp_frac);
1648 new_exp_frac += p_ptr->exp_frac;
1649 /* Keep track of experience */
1650 if (new_exp_frac >= 0x10000L)
1653 p_ptr->exp_frac = (u16b)(new_exp_frac - 0x10000L);
1657 p_ptr->exp_frac = (u16b)new_exp_frac;
1660 /* Gain experience */
1668 * Decreases monsters hit points, handling monster death.
1670 * We return TRUE if the monster has been killed (and deleted).
1672 * We announce monster death (using an optional "death message"
1673 * if given, and a otherwise a generic killed/destroyed message).
1675 * Only "physical attacks" can induce the "You have slain" message.
1676 * Missile and Spell attacks will induce the "dies" message, or
1677 * various "specialized" messages. Note that "You have destroyed"
1678 * and "is destroyed" are synonyms for "You have slain" and "dies".
1680 * Hack -- unseen monsters yield "You have killed it." message.
1682 * Added fear (DGK) and check whether to print fear messages -CWS
1684 * Made name, sex, and capitalization generic -BEN-
1686 * As always, the "ghost" processing is a total hack.
1688 * Hack -- we "delay" fear messages by passing around a "fear" flag.
1690 * XXX XXX XXX Consider decreasing monster experience over time, say,
1691 * by using "(m_exp * m_lev * (m_lev)) / (p_lev * (m_lev + n_killed))"
1692 * instead of simply "(m_exp * m_lev) / (p_lev)", to make the first
1693 * monster worth more than subsequent monsters. This would also need
1694 * to induce changes in the monster recall code.
1696 bool mon_take_hit(int m_idx, int dam, bool *fear, cptr note)
1698 monster_type *m_ptr = &m_list[m_idx];
1699 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1701 monster_type exp_mon;
1703 /* Innocent until proven otherwise */
1704 bool innocent = TRUE, thief = FALSE;
1708 COPY(&exp_mon, m_ptr, monster_type);
1709 if (!(r_ptr->flags7 & RF7_KILL_EXP))
1711 expdam = (m_ptr->hp > dam) ? dam : m_ptr->hp;
1712 if (r_ptr->flags6 & RF6_HEAL) expdam = (expdam+1) * 2 / 3;
1714 get_exp_from_mon(expdam, &exp_mon);
1717 /* Redraw (later) if needed */
1718 if (p_ptr->health_who == m_idx) p_ptr->redraw |= (PR_HEALTH);
1719 if (p_ptr->riding == m_idx) p_ptr->redraw |= (PR_UHEALTH);
1724 if (r_ptr->flags7 & RF7_HAS_LD_MASK) p_ptr->update |= (PU_MON_LITE);
1726 /* Hack - Cancel any special player stealth magics. -LM- */
1727 if (p_ptr->special_defense & NINJA_S_STEALTH)
1729 set_superstealth(FALSE);
1735 /* It is dead now */
1740 if (r_info[m_ptr->r_idx].flags7 & RF7_TANUKI)
1742 /* You might have unmasked Tanuki first time */
1743 r_ptr = &r_info[m_ptr->r_idx];
1744 m_ptr->ap_r_idx = m_ptr->r_idx;
1745 if (r_ptr->r_sights < MAX_SHORT) r_ptr->r_sights++;
1748 if (m_ptr->mflag2 & MFLAG2_CHAMELEON)
1750 /* You might have unmasked Chameleon first time */
1751 r_ptr = real_r_ptr(m_ptr);
1752 if (r_ptr->r_sights < MAX_SHORT) r_ptr->r_sights++;
1755 if (!(m_ptr->smart & SM_CLONED))
1757 /* When the player kills a Unique, it stays dead */
1758 if (r_ptr->flags1 & RF1_UNIQUE)
1762 /* Mega-Hack -- Banor & Lupart */
1763 if ((m_ptr->r_idx == MON_BANOR) || (m_ptr->r_idx == MON_LUPART))
1765 r_info[MON_BANORLUPART].max_num = 0;
1766 r_info[MON_BANORLUPART].r_pkills++;
1767 if (r_info[MON_BANORLUPART].r_tkills < MAX_SHORT) r_info[MON_BANORLUPART].r_tkills++;
1769 else if (m_ptr->r_idx == MON_BANORLUPART)
1771 r_info[MON_BANOR].max_num = 0;
1772 r_info[MON_BANOR].r_pkills++;
1773 if (r_info[MON_BANOR].r_tkills < MAX_SHORT) r_info[MON_BANOR].r_tkills++;
1774 r_info[MON_LUPART].max_num = 0;
1775 r_info[MON_LUPART].r_pkills++;
1776 if (r_info[MON_LUPART].r_tkills < MAX_SHORT) r_info[MON_LUPART].r_tkills++;
1780 /* When the player kills a Nazgul, it stays dead */
1781 else if (r_ptr->flags7 & RF7_NAZGUL) r_ptr->max_num--;
1784 /* Recall even invisible uniques or winners */
1785 if (m_ptr->ml || (r_ptr->flags1 & RF1_UNIQUE))
1787 /* Count kills this life */
1788 if ((m_ptr->mflag2 & MFLAG2_KAGE) && (r_info[MON_KAGE].r_pkills < MAX_SHORT)) r_info[MON_KAGE].r_pkills++;
1789 else if (r_ptr->r_pkills < MAX_SHORT) r_ptr->r_pkills++;
1791 /* Count kills in all lives */
1792 if ((m_ptr->mflag2 & MFLAG2_KAGE) && (r_info[MON_KAGE].r_tkills < MAX_SHORT)) r_info[MON_KAGE].r_tkills++;
1793 else if (r_ptr->r_tkills < MAX_SHORT) r_ptr->r_tkills++;
1795 /* Hack -- Auto-recall */
1796 monster_race_track(m_ptr->ap_r_idx);
1799 /* Extract monster name */
1800 monster_desc(m_name, m_ptr, MD_TRUE_NAME);
1802 /* Don't kill Amberites */
1803 if ((r_ptr->flags3 & RF3_AMBERITE) && one_in_(2))
1805 int curses = 1 + randint1(3);
1806 bool stop_ty = FALSE;
1810 msg_format("%^s¤Ï¶²¤í¤·¤¤·ì¤Î¼ö¤¤¤ò¤¢¤Ê¤¿¤Ë¤«¤±¤¿¡ª", m_name);
1812 msg_format("%^s puts a terrible blood curse on you!", m_name);
1815 curse_equipment(100, 50);
1819 stop_ty = activate_ty_curse(stop_ty, &count);
1824 if (r_ptr->flags2 & RF2_CAN_SPEAK)
1826 char line_got[1024];
1828 /* Dump a message */
1830 if (!get_rnd_line("mondeath_j.txt", m_ptr->r_idx, line_got))
1832 if (!get_rnd_line("mondeath.txt", m_ptr->r_idx, line_got))
1835 msg_format("%^s %s", m_name, line_got);
1838 if (m_ptr->r_idx == MON_SERPENT)
1840 /* Make screen dump */
1841 screen_dump = make_screen_dump();
1846 if (!(d_info[dungeon_type].flags1 & DF1_BEGINNER))
1848 if (!dun_level && !ambush_flag && !p_ptr->inside_arena)
1850 chg_virtue(V_VALOUR, -1);
1852 else if (r_ptr->level > dun_level)
1854 if (randint1(10) <= (r_ptr->level - dun_level))
1855 chg_virtue(V_VALOUR, 1);
1857 if (r_ptr->level > 60)
1859 chg_virtue(V_VALOUR, 1);
1861 if (r_ptr->level >= 2 * (p_ptr->lev+1))
1862 chg_virtue(V_VALOUR, 2);
1865 if (r_ptr->flags1 & RF1_UNIQUE)
1867 if (r_ptr->flags3 & (RF3_EVIL | RF3_GOOD)) chg_virtue(V_HARMONY, 2);
1869 if (r_ptr->flags3 & RF3_GOOD)
1871 chg_virtue(V_UNLIFE, 2);
1872 chg_virtue(V_VITALITY, -2);
1875 if (one_in_(3)) chg_virtue(V_INDIVIDUALISM, -1);
1878 if (m_ptr->r_idx == MON_BEGGAR || m_ptr->r_idx == MON_LEPER)
1880 chg_virtue(V_COMPASSION, -1);
1883 if ((r_ptr->flags3 & RF3_GOOD) &&
1884 ((r_ptr->level) / 10 + (3 * dun_level) >= randint1(100)))
1885 chg_virtue(V_UNLIFE, 1);
1887 if (r_ptr->d_char == 'A')
1889 if (r_ptr->flags1 & RF1_UNIQUE)
1890 chg_virtue(V_FAITH, -2);
1891 else if ((r_ptr->level) / 10 + (3 * dun_level) >= randint1(100))
1893 if (r_ptr->flags3 & RF3_GOOD) chg_virtue(V_FAITH, -1);
1894 else chg_virtue(V_FAITH, 1);
1897 else if (r_ptr->flags3 & RF3_DEMON)
1899 if (r_ptr->flags1 & RF1_UNIQUE)
1900 chg_virtue(V_FAITH, 2);
1901 else if ((r_ptr->level) / 10 + (3 * dun_level) >= randint1(100))
1902 chg_virtue(V_FAITH, 1);
1905 if ((r_ptr->flags3 & RF3_UNDEAD) && (r_ptr->flags1 & RF1_UNIQUE))
1906 chg_virtue(V_VITALITY, 2);
1908 if (r_ptr->r_deaths)
1910 if (r_ptr->flags1 & RF1_UNIQUE)
1912 chg_virtue(V_HONOUR, 10);
1914 else if ((r_ptr->level) / 10 + (2 * dun_level) >= randint1(100))
1916 chg_virtue(V_HONOUR, 1);
1919 if ((r_ptr->flags2 & RF2_MULTIPLY) && (r_ptr->r_pkills > 1000) && one_in_(10))
1921 chg_virtue(V_VALOUR, -1);
1924 for (i = 0; i < 4; i++)
1926 if (r_ptr->blow[i].d_dice != 0) innocent = FALSE; /* Murderer! */
1928 if ((r_ptr->blow[i].effect == RBE_EAT_ITEM)
1929 || (r_ptr->blow[i].effect == RBE_EAT_GOLD))
1931 thief = TRUE; /* Thief! */
1934 /* The new law says it is illegal to live in the dungeon */
1935 if (r_ptr->level != 0) innocent = FALSE;
1939 if (r_ptr->flags1 & RF1_UNIQUE)
1940 chg_virtue(V_JUSTICE, 3);
1941 else if (1+((r_ptr->level) / 10 + (2 * dun_level))
1943 chg_virtue(V_JUSTICE, 1);
1947 chg_virtue (V_JUSTICE, -1);
1950 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)))
1952 if (one_in_(4)) chg_virtue(V_NATURE, -1);
1955 if ((r_ptr->flags1 & RF1_UNIQUE) && record_destroy_uniq)
1959 sprintf(note_buf, "%s%s", r_name + r_ptr->name, (m_ptr->smart & SM_CLONED) ? "(¥¯¥í¡¼¥ó)" : "");
1961 sprintf(note_buf, "%s%s", r_name + r_ptr->name, (m_ptr->smart & SM_CLONED) ? "(Clone)" : "");
1963 do_cmd_write_nikki(NIKKI_UNIQUE, 0, note_buf);
1969 /* Death by Missile/Spell attack */
1972 msg_format("%^s%s", m_name, note);
1975 /* Death by physical attack -- invisible monster */
1976 else if (!m_ptr->ml)
1979 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
1980 msg_format("¤»¤Ã¤«¤¯¤À¤«¤é%s¤ò»¦¤·¤¿¡£", m_name);
1982 msg_format("%s¤ò»¦¤·¤¿¡£", m_name);
1984 msg_format("You have killed %s.", m_name);
1989 /* Death by Physical attack -- non-living monster */
1990 else if (!monster_living(r_ptr))
1993 bool explode = FALSE;
1995 for (i = 0; i < 4; i++)
1997 if (r_ptr->blow[i].method == RBM_EXPLODE) explode = TRUE;
2000 /* Special note at death */
2003 msg_format("%s¤ÏÇúȯ¤·¤ÆÊ´¡¹¤Ë¤Ê¤Ã¤¿¡£", m_name);
2005 msg_format("%s explodes into tiny shreds.", m_name);
2010 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
2011 msg_format("¤»¤Ã¤«¤¯¤À¤«¤é%s¤òÅݤ·¤¿¡£", m_name);
2013 msg_format("%s¤òÅݤ·¤¿¡£", m_name);
2015 msg_format("You have destroyed %s.", m_name);
2020 /* Death by Physical attack -- living monster */
2024 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
2025 msg_format("¤»¤Ã¤«¤¯¤À¤«¤é%s¤òÁò¤êµî¤Ã¤¿¡£", m_name);
2027 msg_format("%s¤òÁò¤êµî¤Ã¤¿¡£", m_name);
2029 msg_format("You have slain %s.", m_name);
2033 if ((r_ptr->flags1 & RF1_UNIQUE) && !(m_ptr->smart & SM_CLONED) && !vanilla_town)
2035 for (i = 0; i < MAX_KUBI; i++)
2037 if ((kubi_r_idx[i] == m_ptr->r_idx) && !(m_ptr->mflag2 & MFLAG2_CHAMELEON))
2040 msg_format("%s¤Î¼ó¤Ë¤Ï¾Þ¶â¤¬¤«¤«¤Ã¤Æ¤¤¤ë¡£", m_name);
2042 msg_format("There is a price on %s's head.", m_name);
2049 /* Generate treasure */
2050 monster_death(m_idx, TRUE);
2052 /* Mega hack : replace IKETA to BIKETAL */
2053 if ((m_ptr->r_idx == MON_IKETA) &&
2054 !(p_ptr->inside_arena || p_ptr->inside_battle))
2056 int dummy_y = m_ptr->fy;
2057 int dummy_x = m_ptr->fx;
2060 if (is_pet(m_ptr)) mode |= PM_FORCE_PET;
2062 /* Delete the monster */
2063 delete_monster_idx(m_idx);
2065 if (summon_named_creature(0, dummy_y, dummy_x, MON_BIKETAL, mode))
2068 msg_print("¡Ö¥Ï¥¡¥Ã¥Ï¥Ã¥Ï¥Ã¥Ï¡ª¡ª»ä¤¬¥Ð¥¤¥±¥¿¥ë¤À¡ª¡ª¡×");
2070 msg_print("Uwa-hahaha! *I* am Biketal!");
2076 /* Delete the monster */
2077 delete_monster_idx(m_idx);
2080 /* Prevent bug of chaos patron's reward */
2081 if (r_ptr->flags7 & RF7_KILL_EXP)
2082 get_exp_from_mon((long)exp_mon.max_maxhp*2, &exp_mon);
2084 get_exp_from_mon(((long)exp_mon.max_maxhp+1L) * 9L / 10L, &exp_mon);
2089 /* Monster is dead */
2096 /* Mega-Hack -- Pain cancels fear */
2097 if (m_ptr->monfear && (dam > 0))
2099 int tmp = randint1(dam);
2101 /* Cure a little fear */
2102 if (tmp < m_ptr->monfear)
2105 m_ptr->monfear -= tmp;
2108 /* Cure all the fear */
2119 /* Sometimes a monster gets scared by damage */
2120 if (!m_ptr->monfear && !(r_ptr->flags3 & (RF3_NO_FEAR)))
2124 /* Percentage of fully healthy */
2125 percentage = (100L * m_ptr->hp) / m_ptr->maxhp;
2128 * Run (sometimes) if at 10% or less of max hit points,
2129 * or (usually) when hit for half its current hit points
2131 if ((randint1(10) >= percentage) ||
2132 ((dam >= m_ptr->hp) && (randint0(100) < 80)))
2134 /* Hack -- note fear */
2137 /* XXX XXX XXX Hack -- Add some timed fear */
2138 m_ptr->monfear = (randint1(10) +
2139 (((dam >= m_ptr->hp) && (percentage > 7)) ?
2140 20 : ((11 - percentage) * 5)));
2147 if (p_ptr->riding && (p_ptr->riding == m_idx) && (dam > 0))
2151 /* Extract monster name */
2152 monster_desc(m_name, m_ptr, 0);
2154 if (m_ptr->hp > m_ptr->maxhp/3) dam = (dam + 1) / 2;
2155 if (rakuba((dam > 200) ? 200 : dam, FALSE))
2158 msg_format("%^s¤Ë¿¶¤êÍî¤È¤µ¤ì¤¿¡ª", m_name);
2160 msg_format("%^s has thrown you off!", m_name);
2172 * Get term size and calculate screen size
2174 void get_screen_size(int *wid_p, int *hgt_p)
2176 Term_get_size(wid_p, hgt_p);
2177 *hgt_p -= ROW_MAP + 2;
2178 *wid_p -= COL_MAP + 2;
2179 if (use_bigtile) *wid_p /= 2;
2184 * Calculates current boundaries
2185 * Called below and from "do_cmd_locate()".
2187 void panel_bounds_center(void)
2192 get_screen_size(&wid, &hgt);
2194 panel_row_max = panel_row_min + hgt - 1;
2195 panel_row_prt = panel_row_min - 1;
2196 panel_col_max = panel_col_min + wid - 1;
2197 panel_col_prt = panel_col_min - 13;
2202 * Map resizing whenever the main term changes size
2204 void resize_map(void)
2206 /* Only if the dungeon exists */
2207 if (!character_dungeon) return;
2209 /* Mega-Hack -- no panel yet */
2213 /* Reset the panels */
2214 panel_row_min = cur_hgt;
2215 panel_col_min = cur_wid;
2220 p_ptr->update |= (PU_TORCH | PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
2222 /* Forget lite/view */
2223 p_ptr->update |= (PU_UN_VIEW | PU_UN_LITE);
2225 /* Update lite/view */
2226 p_ptr->update |= (PU_VIEW | PU_LITE | PU_MON_LITE);
2228 /* Update monsters */
2229 p_ptr->update |= (PU_MONSTERS);
2231 /* Redraw everything */
2232 p_ptr->redraw |= (PR_WIPE | PR_BASIC | PR_EXTRA | PR_MAP | PR_EQUIPPY);
2234 /* Hack -- update */
2242 * Place the cursor on the player
2244 if (can_save) move_cursor_relative(py, px);
2251 * Redraw a term when it is resized
2253 void redraw_window(void)
2255 /* Only if the dungeon exists */
2256 if (!character_dungeon) return;
2258 /* Hack - Activate term zero for the redraw */
2259 Term_activate(&term_screen[0]);
2261 /* Hack -- react to changes */
2262 Term_xtra(TERM_XTRA_REACT, 0);
2265 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_SPELL | PW_PLAYER);
2268 p_ptr->window |= (PW_MESSAGE | PW_OVERHEAD | PW_DUNGEON | PW_MONSTER | PW_OBJECT);
2270 /* Hack -- update */
2282 * Handle a request to change the current panel
2284 * Return TRUE if the panel was changed.
2286 * Also used in do_cmd_locate
2288 bool change_panel(int dy, int dx)
2294 get_screen_size(&wid, &hgt);
2296 /* Apply the motion */
2297 y = panel_row_min + dy * hgt / 2;
2298 x = panel_col_min + dx * wid / 2;
2300 /* Verify the row */
2301 if (y > cur_hgt - hgt) y = cur_hgt - hgt;
2304 /* Verify the col */
2305 if (x > cur_wid - wid) x = cur_wid - wid;
2308 /* Handle "changes" */
2309 if ((y != panel_row_min) || (x != panel_col_min))
2311 /* Save the new panel info */
2315 /* Recalculate the boundaries */
2316 panel_bounds_center();
2319 p_ptr->update |= (PU_MONSTERS);
2322 p_ptr->redraw |= (PR_MAP);
2337 * Given an row (y) and col (x), this routine detects when a move
2338 * off the screen has occurred and figures new borders. -RAK-
2340 * "Update" forces a "full update" to take place.
2342 * The map is reprinted if necessary, and "TRUE" is returned.
2344 void verify_panel(void)
2356 get_screen_size(&wid, &hgt);
2358 max_prow_min = cur_hgt - hgt;
2359 max_pcol_min = cur_wid - wid;
2361 /* Bounds checking */
2362 if (max_prow_min < 0) max_prow_min = 0;
2363 if (max_pcol_min < 0) max_pcol_min = 0;
2365 /* Center on player */
2366 if (center_player && (center_running || !running))
2368 /* Center vertically */
2369 prow_min = y - hgt / 2;
2370 if (prow_min < 0) prow_min = 0;
2371 else if (prow_min > max_prow_min) prow_min = max_prow_min;
2373 /* Center horizontally */
2374 pcol_min = x - wid / 2;
2375 if (pcol_min < 0) pcol_min = 0;
2376 else if (pcol_min > max_pcol_min) pcol_min = max_pcol_min;
2380 prow_min = panel_row_min;
2381 pcol_min = panel_col_min;
2383 /* Scroll screen when 2 grids from top/bottom edge */
2384 if (y > panel_row_max - 2)
2386 while (y > prow_min + hgt-1 - 2)
2388 prow_min += (hgt / 2);
2392 if (y < panel_row_min + 2)
2394 while (y < prow_min + 2)
2396 prow_min -= (hgt / 2);
2400 if (prow_min > max_prow_min) prow_min = max_prow_min;
2401 if (prow_min < 0) prow_min = 0;
2403 /* Scroll screen when 4 grids from left/right edge */
2404 if (x > panel_col_max - 4)
2406 while (x > pcol_min + wid-1 - 4)
2408 pcol_min += (wid / 2);
2412 if (x < panel_col_min + 4)
2414 while (x < pcol_min + 4)
2416 pcol_min -= (wid / 2);
2420 if (pcol_min > max_pcol_min) pcol_min = max_pcol_min;
2421 if (pcol_min < 0) pcol_min = 0;
2424 /* Check for "no change" */
2425 if ((prow_min == panel_row_min) && (pcol_min == panel_col_min)) return;
2427 /* Save the new panel info */
2428 panel_row_min = prow_min;
2429 panel_col_min = pcol_min;
2431 /* Hack -- optional disturb on "panel change" */
2432 if (disturb_panel && !center_player) disturb(0, 0);
2434 /* Recalculate the boundaries */
2435 panel_bounds_center();
2438 p_ptr->update |= (PU_MONSTERS);
2441 p_ptr->redraw |= (PR_MAP);
2444 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
2449 * Monster health description
2451 cptr look_mon_desc(monster_type *m_ptr, u32b mode)
2453 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
2460 /* Determine if the monster is "living" */
2461 living = monster_living(ap_r_ptr);
2463 /* Calculate a health "percentage" */
2464 perc = 100L * m_ptr->hp / m_ptr->maxhp;
2466 /* Healthy monsters */
2467 if (m_ptr->hp >= m_ptr->maxhp)
2471 desc = living ? "̵½ý" : "̵¥À¥á¡¼¥¸";
2473 desc = living ? "unhurt" : "undamaged";
2478 else if (perc >= 60)
2481 desc = living ? "·Ú½ý" : "¾®¥À¥á¡¼¥¸";
2483 desc = living ? "somewhat wounded" : "somewhat damaged";
2488 else if (perc >= 25)
2491 desc = living ? "Éé½ý" : "Ãæ¥À¥á¡¼¥¸";
2493 desc = living ? "wounded" : "damaged";
2498 else if (perc >= 10)
2501 desc = living ? "½Å½ý" : "Âç¥À¥á¡¼¥¸";
2503 desc = living ? "badly wounded" : "badly damaged";
2511 desc = living ? "Ⱦ»àȾÀ¸" : "Åݤ줫¤±";
2513 desc = living ? "almost dead" : "almost destroyed";
2518 /* Need attitude information? */
2521 /* Full information is not needed */
2524 else if (is_pet(m_ptr))
2527 attitude = ", ¥Ú¥Ã¥È";
2532 else if (is_friendly(m_ptr))
2535 attitude = ", ͧ¹¥Åª";
2537 attitude = ", friendly";
2550 /* Clone monster? */
2551 if (m_ptr->smart & SM_CLONED)
2560 /* Display monster's level --- idea borrowed from ToME */
2561 if (ap_r_ptr->r_tkills && !(m_ptr->mflag2 & MFLAG2_KAGE))
2564 return format("¥ì¥Ù¥ë%d, %s%s%s", ap_r_ptr->level, desc, attitude, clone);
2566 return format("Level %d, %s%s%s", ap_r_ptr->level, desc, attitude, clone);
2572 return format("¥ì¥Ù¥ë???, %s%s%s", desc, attitude, clone);
2574 return format("Level ???, %s%s%s", desc, attitude, clone);
2582 * Angband sorting algorithm -- quick sort in place
2584 * Note that the details of the data we are sorting is hidden,
2585 * and we rely on the "ang_sort_comp()" and "ang_sort_swap()"
2586 * function hooks to interact with the data, which is given as
2587 * two pointers, and which may have any user-defined form.
2589 void ang_sort_aux(vptr u, vptr v, int p, int q)
2607 while (!(*ang_sort_comp)(u, v, b, z)) b--;
2610 while (!(*ang_sort_comp)(u, v, z, a)) a++;
2612 /* Done partition */
2616 (*ang_sort_swap)(u, v, a, b);
2622 /* Recurse left side */
2623 ang_sort_aux(u, v, p, b);
2625 /* Recurse right side */
2626 ang_sort_aux(u, v, b+1, q);
2631 * Angband sorting algorithm -- quick sort in place
2633 * Note that the details of the data we are sorting is hidden,
2634 * and we rely on the "ang_sort_comp()" and "ang_sort_swap()"
2635 * function hooks to interact with the data, which is given as
2636 * two pointers, and which may have any user-defined form.
2638 void ang_sort(vptr u, vptr v, int n)
2640 /* Sort the array */
2641 ang_sort_aux(u, v, 0, n-1);
2646 /*** Targeting Code ***/
2650 * Determine is a monster makes a reasonable target
2652 * The concept of "targeting" was stolen from "Morgul" (?)
2654 * The player can target any location, or any "target-able" monster.
2656 * Currently, a monster is "target_able" if it is visible, and if
2657 * the player can hit it with a projection, and the player is not
2658 * hallucinating. This allows use of "use closest target" macros.
2660 * Future versions may restrict the ability to target "trappers"
2661 * and "mimics", but the semantics is a little bit weird.
2663 bool target_able(int m_idx)
2665 monster_type *m_ptr = &m_list[m_idx];
2667 /* Monster must be alive */
2668 if (!m_ptr->r_idx) return (FALSE);
2670 /* Hack -- no targeting hallucinations */
2671 if (p_ptr->image) return (FALSE);
2673 /* Monster must be visible */
2674 if (!m_ptr->ml) return (FALSE);
2676 if (p_ptr->riding && (p_ptr->riding == m_idx)) return (TRUE);
2678 /* Monster must be projectable */
2679 if (!projectable(py, px, m_ptr->fy, m_ptr->fx)) return (FALSE);
2681 /* XXX XXX XXX Hack -- Never target trappers */
2682 /* if (CLEAR_ATTR && (CLEAR_CHAR)) return (FALSE); */
2692 * Update (if necessary) and verify (if possible) the target.
2694 * We return TRUE if the target is "okay" and FALSE otherwise.
2696 bool target_okay(void)
2698 /* Accept stationary targets */
2699 if (target_who < 0) return (TRUE);
2701 /* Check moving targets */
2704 /* Accept reasonable targets */
2705 if (target_able(target_who))
2707 monster_type *m_ptr = &m_list[target_who];
2709 /* Acquire monster location */
2710 target_row = m_ptr->fy;
2711 target_col = m_ptr->fx;
2718 /* Assume no target */
2725 * Sorting hook -- comp function -- by "distance to player"
2727 * We use "u" and "v" to point to arrays of "x" and "y" positions,
2728 * and sort the arrays by double-distance to the player.
2730 static bool ang_sort_comp_distance(vptr u, vptr v, int a, int b)
2732 byte *x = (byte*)(u);
2733 byte *y = (byte*)(v);
2737 /* Absolute distance components */
2738 kx = x[a]; kx -= px; kx = ABS(kx);
2739 ky = y[a]; ky -= py; ky = ABS(ky);
2741 /* Approximate Double Distance to the first point */
2742 da = ((kx > ky) ? (kx + kx + ky) : (ky + ky + kx));
2744 /* Absolute distance components */
2745 kx = x[b]; kx -= px; kx = ABS(kx);
2746 ky = y[b]; ky -= py; ky = ABS(ky);
2748 /* Approximate Double Distance to the first point */
2749 db = ((kx > ky) ? (kx + kx + ky) : (ky + ky + kx));
2751 /* Compare the distances */
2757 * Sorting hook -- swap function -- by "distance to player"
2759 * We use "u" and "v" to point to arrays of "x" and "y" positions,
2760 * and sort the arrays by distance to the player.
2762 static void ang_sort_swap_distance(vptr u, vptr v, int a, int b)
2764 byte *x = (byte*)(u);
2765 byte *y = (byte*)(v);
2783 * Hack -- help "select" a location (see below)
2785 static s16b target_pick(int y1, int x1, int dy, int dx)
2789 int x2, y2, x3, y3, x4, y4;
2791 int b_i = -1, b_v = 9999;
2794 /* Scan the locations */
2795 for (i = 0; i < temp_n; i++)
2801 /* Directed distance */
2805 /* Verify quadrant */
2806 if (dx && (x3 * dx <= 0)) continue;
2807 if (dy && (y3 * dy <= 0)) continue;
2809 /* Absolute distance */
2813 /* Verify quadrant */
2814 if (dy && !dx && (x4 > y4)) continue;
2815 if (dx && !dy && (y4 > x4)) continue;
2817 /* Approximate Double Distance */
2818 v = ((x4 > y4) ? (x4 + x4 + y4) : (y4 + y4 + x4));
2820 /* XXX XXX XXX Penalize location */
2823 if ((b_i >= 0) && (v >= b_v)) continue;
2835 * Hack -- determine if a given location is "interesting"
2837 static bool target_set_accept(int y, int x)
2841 s16b this_o_idx, next_o_idx = 0;
2844 if (!(in_bounds(y, x))) return (FALSE);
2846 /* Player grid is always interesting */
2847 if (player_bold(y, x)) return (TRUE);
2850 /* Handle hallucination */
2851 if (p_ptr->image) return (FALSE);
2854 /* Examine the grid */
2855 c_ptr = &cave[y][x];
2857 /* Visible monsters */
2860 monster_type *m_ptr = &m_list[c_ptr->m_idx];
2862 /* Visible monsters */
2863 if (m_ptr->ml) return (TRUE);
2866 /* Scan all objects in the grid */
2867 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
2871 /* Acquire object */
2872 o_ptr = &o_list[this_o_idx];
2874 /* Acquire next object */
2875 next_o_idx = o_ptr->next_o_idx;
2877 /* Memorized object */
2878 if (o_ptr->marked) return (TRUE);
2881 /* Interesting memorized features */
2882 if (c_ptr->info & (CAVE_MARK))
2884 /* Feature code (applying "mimic" field) */
2885 byte feat = get_feat_mimic(c_ptr);
2888 if (c_ptr->info & CAVE_OBJECT) return (TRUE);
2890 /* Notice the Pattern */
2891 if ((feat <= FEAT_PATTERN_XTRA2) &&
2892 (feat >= FEAT_PATTERN_START))
2896 if (feat == FEAT_OPEN) return (TRUE);
2897 if (feat == FEAT_BROKEN) return (TRUE);
2900 if (feat == FEAT_LESS) return (TRUE);
2901 if (feat == FEAT_MORE) return (TRUE);
2902 if (feat == FEAT_LESS_LESS) return (TRUE);
2903 if (feat == FEAT_MORE_MORE) return (TRUE);
2906 if ((feat >= FEAT_SHOP_HEAD) &&
2907 (feat <= FEAT_SHOP_TAIL)) return (TRUE);
2909 if (feat == FEAT_MUSEUM) return (TRUE);
2911 /* Notice buildings -KMW- */
2912 if ((feat >= FEAT_BLDG_HEAD) &&
2913 (feat <= FEAT_BLDG_TAIL)) return (TRUE);
2916 if (is_trap(feat)) return (TRUE);
2919 if ((feat >= FEAT_DOOR_HEAD) &&
2920 (feat <= FEAT_DOOR_TAIL)) return (TRUE);
2924 /* I think FEAT_RUBBLEs should not be "interesting" */
2925 if (feat == FEAT_RUBBLE) return (TRUE);
2927 /* Notice veins with treasure */
2928 /* Now veins with treasure are too many */
2929 if (feat == FEAT_MAGMA_K) return (TRUE);
2930 if (feat == FEAT_QUARTZ_K) return (TRUE);
2933 /* Notice quest features */
2934 if (feat == FEAT_QUEST_ENTER) return (TRUE);
2935 if (feat == FEAT_QUEST_EXIT) return (TRUE);
2936 if (feat == FEAT_QUEST_DOWN) return (TRUE);
2937 if (feat == FEAT_QUEST_UP) return (TRUE);
2938 if (feat == FEAT_TOWN) return (TRUE);
2939 if (feat == FEAT_ENTRANCE) return (TRUE);
2948 * Prepare the "temp" array for "target_set"
2950 * Return the number of target_able monsters in the set.
2952 static void target_set_prepare(int mode)
2956 /* Reset "temp" array */
2959 /* Scan the current panel */
2960 for (y = panel_row_min; y <= panel_row_max; y++)
2962 for (x = panel_col_min; x <= panel_col_max; x++)
2966 /* Require "interesting" contents */
2967 if (!target_set_accept(y, x)) continue;
2969 c_ptr = &cave[y][x];
2971 /* Require target_able monsters for "TARGET_KILL" */
2972 if ((mode & (TARGET_KILL)) && !target_able(c_ptr->m_idx)) continue;
2974 if ((mode & (TARGET_KILL)) && !target_pet && is_pet(&m_list[c_ptr->m_idx])) continue;
2976 /* Save the location */
2983 /* Set the sort hooks */
2984 ang_sort_comp = ang_sort_comp_distance;
2985 ang_sort_swap = ang_sort_swap_distance;
2987 /* Sort the positions */
2988 ang_sort(temp_x, temp_y, temp_n);
2990 if (p_ptr->riding && target_pet && (temp_n > 1) && (mode & (TARGET_KILL)))
2995 temp_y[0] = temp_y[1];
2998 temp_x[0] = temp_x[1];
3005 * Evaluate number of kill needed to gain level
3007 static void evaluate_monster_exp(char *buf, monster_type *m_ptr)
3009 #define M_INT_GREATER(h1,l1,h2,l2) ( (h1>h2)||( (h1==h2)&&(l1>=l2)))
3010 #define M_INT_SUB(h1,l1, h2,l2) {h1-=h2;if(l1<l2){l1+=0x10000;h1--;}l1-=l2;}
3011 #define M_INT_ADD(h1,l1, h2,l2) {h1+=h2;l1+=l2;if(l1>=0x10000L){l1&=0xFFFF;h1++;}}
3012 #define M_INT_LSHIFT(h1,l1) {h1=(h1<<1)|(l1>>15);l1=(l1<<1)&0xffff;}
3013 #define M_INT_RSHIFT(h1,l1) {l1=(l1>>1)|((h1&1)<<15);h1>>=1;}
3014 #define M_INT_MULT(h1,l1,mul,h2,l2) {l2=(l1*mul)&0xffff;h2=((l1*mul)>>16)+h1*mul;}
3016 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
3020 u32b exp_mon= (ap_r_ptr->mexp)*(ap_r_ptr->level);
3021 u32b exp_mon_h= exp_mon / (p_ptr->max_plv+2);
3022 u32b exp_mon_l= ((exp_mon % (p_ptr->max_plv+2))*0x10000/(p_ptr->max_plv+2))&0xFFFF;
3024 u32b exp_adv_h = player_exp[p_ptr->lev -1] * p_ptr->expfact /100;
3025 u32b exp_adv_l = ((player_exp[p_ptr->lev -1]%100) * p_ptr->expfact *0x10000/100)&0xFFFF;
3027 M_INT_SUB(exp_adv_h, exp_adv_l, p_ptr->exp, p_ptr->exp_frac);
3028 if ((p_ptr->lev>=PY_MAX_LEVEL) || (p_ptr->prace == RACE_ANDROID))
3030 else if (!ap_r_ptr->r_tkills || (m_ptr->mflag2 & MFLAG2_KAGE))
3032 else if (M_INT_GREATER(exp_mon_h, exp_mon_l, exp_adv_h, exp_adv_l))
3036 M_INT_MULT(exp_mon_h, exp_mon_l, 1000,tmp_h, tmp_l);
3037 if( M_INT_GREATER(exp_adv_h, exp_adv_l, tmp_h, tmp_l) )
3042 M_INT_ADD(exp_adv_h, exp_adv_l, exp_mon_h, exp_mon_l);
3043 M_INT_SUB(exp_adv_h, exp_adv_l, 0, 1);
3044 while(M_INT_GREATER(exp_adv_h, exp_adv_l, exp_mon_h,exp_mon_l))
3046 M_INT_LSHIFT(exp_mon_h,exp_mon_l);
3049 M_INT_RSHIFT(exp_mon_h,exp_mon_l);bit>>=1;
3050 for(;bit>=1;bit>>=1)
3052 if(M_INT_GREATER(exp_adv_h,exp_adv_l,exp_mon_h,exp_mon_l))
3055 M_INT_SUB(exp_adv_h,exp_adv_l,exp_mon_h,exp_mon_l);
3057 M_INT_RSHIFT(exp_mon_h,exp_mon_l);
3059 sprintf(buf,"%03d",result);
3066 * Examine a grid, return a keypress.
3068 * The "mode" argument contains the "TARGET_LOOK" bit flag, which
3069 * indicates that the "space" key should scan through the contents
3070 * of the grid, instead of simply returning immediately. This lets
3071 * the "look" command get complete information, without making the
3072 * "target" command annoying.
3074 * The "info" argument contains the "commands" which should be shown
3075 * inside the "[xxx]" text. This string must never be empty, or grids
3076 * containing monsters will be displayed with an extra comma.
3078 * Note that if a monster is in the grid, we update both the monster
3079 * recall info and the health bar info to track that monster.
3081 * Eventually, we may allow multiple objects per grid, or objects
3082 * and terrain features in the same grid. XXX XXX XXX
3084 * This function must handle blindness/hallucination.
3086 static int target_set_aux(int y, int x, int mode, cptr info)
3088 cave_type *c_ptr = &cave[y][x];
3089 s16b this_o_idx, next_o_idx = 0;
3090 cptr s1 = "", s2 = "", s3 = "", x_info = "";
3094 char out_val[MAX_NLEN+80];
3096 #ifdef ALLOW_EASY_FLOOR
3097 int floor_list[23], floor_num = 0;
3099 /* Scan all objects in the grid */
3102 floor_num = scan_floor(floor_list, y, x, 0x02);
3114 #endif /* ALLOW_EASY_FLOOR */
3116 /* Hack -- under the player */
3117 if (player_bold(y, x))
3140 /* Hack -- hallucination */
3144 cptr name = "²¿¤«´ñ̯¤Êʪ";
3146 cptr name = "something strange";
3150 /* Display a message */
3152 sprintf(out_val, "%s%s%s%s [%s]", s1, name, s2, s3, info);
3154 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, name, info);
3158 move_cursor_relative(y, x);
3161 /* Stop on everything but "return" */
3162 if ((query != '\r') && (query != '\n')) return query;
3164 /* Repeat forever */
3169 /* Actual monsters */
3170 if (c_ptr->m_idx && m_list[c_ptr->m_idx].ml)
3172 monster_type *m_ptr = &m_list[c_ptr->m_idx];
3173 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
3175 bool recall = FALSE;
3180 /* Get the monster name ("a kobold") */
3181 monster_desc(m_name, m_ptr, MD_INDEF_VISIBLE);
3183 /* Hack -- track this monster race */
3184 monster_race_track(m_ptr->ap_r_idx);
3186 /* Hack -- health bar for this monster */
3187 health_track(c_ptr->m_idx);
3189 /* Hack -- handle stuff */
3203 /* Recall on screen */
3204 screen_roff(m_ptr->ap_r_idx, 0);
3206 /* Hack -- Complete the prompt (again) */
3208 Term_addstr(-1, TERM_WHITE, format(" [r»× %s%s]", x_info, info));
3210 Term_addstr(-1, TERM_WHITE, format(" [r,%s%s]", x_info, info));
3219 /* Normal commands */
3220 if (query != 'r') break;
3225 /* Cleare recall text and repeat */
3231 /* Describe, and prompt for recall */
3232 evaluate_monster_exp(acount, m_ptr);
3235 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);
3237 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);
3243 move_cursor_relative(y, x);
3248 /* Normal commands */
3249 if (query != 'r') break;
3255 /* Always stop at "normal" keys */
3256 if ((query != '\r') && (query != '\n') && (query != ' ') && (query != 'x')) return query;
3258 /* Sometimes stop at "space" key */
3259 if ((query == ' ') && !(mode & (TARGET_LOOK))) return query;
3261 /* Change the intro */
3269 /* Hack -- take account of gender */
3271 if (ap_r_ptr->flags1 & (RF1_FEMALE)) s1 = "Èà½÷¤Ï";
3273 if (ap_r_ptr->flags1 & (RF1_FEMALE)) s1 = "She is ";
3277 else if (ap_r_ptr->flags1 & (RF1_MALE)) s1 = "Èà¤Ï";
3279 else if (ap_r_ptr->flags1 & (RF1_MALE)) s1 = "He is ";
3283 /* Use a preposition */
3292 /* Scan all objects being carried */
3293 for (this_o_idx = m_ptr->hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
3295 char o_name[MAX_NLEN];
3299 /* Acquire object */
3300 o_ptr = &o_list[this_o_idx];
3302 /* Acquire next object */
3303 next_o_idx = o_ptr->next_o_idx;
3305 /* Obtain an object description */
3306 object_desc(o_name, o_ptr, 0);
3308 /* Describe the object */
3310 sprintf(out_val, "%s%s%s%s[%s]", s1, o_name, s2, s3, info);
3312 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, o_name, info);
3316 move_cursor_relative(y, x);
3319 /* Always stop at "normal" keys */
3320 if ((query != '\r') && (query != '\n') && (query != ' ') && (query != 'x')) return query;
3322 /* Sometimes stop at "space" key */
3323 if ((query == ' ') && !(mode & (TARGET_LOOK))) return query;
3325 /* Change the intro */
3329 s2 = "also carrying ";
3333 /* Use a preposition */
3343 #ifdef ALLOW_EASY_FLOOR
3352 char o_name[MAX_NLEN];
3356 /* Acquire object */
3357 o_ptr = &o_list[floor_list[0]];
3359 /* Describe the object */
3360 object_desc(o_name, o_ptr, 0);
3364 sprintf(out_val, "%s%s%s%s[%s]",
3365 s1, o_name, s2, s3, info);
3367 sprintf(out_val, "%s%s%s%s [%s]",
3368 s1, s2, s3, o_name, info);
3372 move_cursor_relative(y, x);
3381 /* Provide one cushion before item listing */
3384 /* Display rough information about items */
3386 sprintf(out_val, "%s %d¸Ä¤Î¥¢¥¤¥Æ¥à%s%s ['x'¤Ç°ìÍ÷, %s]",
3387 s1, floor_num, s2, s3, info);
3389 sprintf(out_val, "%s%s%sa pile of %d items [x,%s]",
3390 s1, s2, s3, floor_num, info);
3394 move_cursor_relative(y, x);
3399 /* No request for listing */
3400 if (query != 'x' && query != ' ') return query;
3404 /** Display list of items **/
3406 /* Continue scrolling list if requested */
3415 (void)show_floor(0, y, x, &min_width);
3419 sprintf(out_val, "%s %d¸Ä¤Î¥¢¥¤¥Æ¥à%s%s [Enter¤Ç¼¡¤Ø, %s]",
3420 s1, floor_num, s2, s3, info);
3422 sprintf(out_val, "%s%s%sa pile of %d items [Enter,%s]",
3423 s1, s2, s3, floor_num, info);
3434 /* Exit unless 'Enter' */
3435 if (query != '\n' && query != '\r')
3440 /* Get the object being moved. */
3441 o_idx = c_ptr->o_idx;
3443 /* Only rotate a pile of two or more objects. */
3444 if (!(o_idx && o_list[o_idx].next_o_idx)) continue;
3446 /* Remove the first object from the list. */
3447 excise_object_idx(o_idx);
3449 /* Find end of the list. */
3451 while (o_list[i].next_o_idx)
3452 i = o_list[i].next_o_idx;
3454 /* Add after the last object. */
3455 o_list[i].next_o_idx = o_idx;
3457 /* Loop and re-display the list */
3463 #endif /* ALLOW_EASY_FLOOR */
3466 /* Scan all objects in the grid */
3467 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
3471 /* Acquire object */
3472 o_ptr = &o_list[this_o_idx];
3474 /* Acquire next object */
3475 next_o_idx = o_ptr->next_o_idx;
3480 char o_name[MAX_NLEN];
3485 /* Obtain an object description */
3486 object_desc(o_name, o_ptr, 0);
3488 /* Describe the object */
3490 sprintf(out_val, "%s%s%s%s[%s]", s1, o_name, s2, s3, info);
3492 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, o_name, info);
3496 move_cursor_relative(y, x);
3499 /* Always stop at "normal" keys */
3500 if ((query != '\r') && (query != '\n') && (query != ' ') && (query != 'x')) return query;
3502 /* Sometimes stop at "space" key */
3503 if ((query == ' ') && !(mode & TARGET_LOOK)) return query;
3505 /* Change the intro */
3515 if (o_ptr->number != 1) s1 = "¤½¤ì¤é¤Ï";
3517 if (o_ptr->number != 1) s1 = "They are ";
3533 /* Feature code (applying "mimic" field) */
3534 feat = get_feat_mimic(c_ptr);
3536 /* Require knowledge about grid, or ability to see grid */
3537 if (!(c_ptr->info & CAVE_MARK) && !player_can_see_bold(y, x))
3539 /* Forget feature */
3543 /* Terrain feature if needed */
3544 if (boring || (feat > FEAT_INVIS))
3548 /* Hack -- special handling for building doors */
3549 if ((feat >= FEAT_BLDG_HEAD) && (feat <= FEAT_BLDG_TAIL))
3551 name = building[feat - FEAT_BLDG_HEAD].name;
3553 else if (feat == FEAT_ENTRANCE)
3556 name = format("%s(%d³¬ÁêÅö)", d_text + d_info[c_ptr->special].text, d_info[c_ptr->special].mindepth);
3558 name = format("%s(level %d)", d_text + d_info[c_ptr->special].text, d_info[c_ptr->special].mindepth);
3561 else if (feat == FEAT_TOWN)
3563 name = town[c_ptr->special].name;
3565 else if (p_ptr->wild_mode && (feat == FEAT_FLOOR))
3575 name = f_name + f_info[feat].name;
3580 if (*s2 && ((feat >= FEAT_MINOR_GLYPH) &&
3581 (feat <= FEAT_PATTERN_XTRA2)))
3590 else if (*s2 && ((feat >= FEAT_DOOR_HEAD) &&
3591 (feat <= FEAT_PERM_SOLID)))
3600 else if (*s2 && (feat == FEAT_TOWN))
3610 /* Hack -- special introduction for store & building doors -KMW- */
3611 if (((feat >= FEAT_SHOP_HEAD) && (feat <= FEAT_SHOP_TAIL)) ||
3612 ((feat >= FEAT_BLDG_HEAD) && (feat <= FEAT_BLDG_TAIL)) ||
3613 (feat == FEAT_MUSEUM) ||
3614 (feat == FEAT_ENTRANCE))
3623 else if ((feat == FEAT_TOWN) || (feat == FEAT_FLOOR) || (feat == FEAT_DIRT) || (feat == FEAT_FLOWER))
3631 /* Pick proper indefinite article */
3633 s3 = (is_a_vowel(name[0])) ? "an " : "a ";
3637 /* Display a message */
3640 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);
3642 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);
3646 sprintf(out_val, "%s%s%s%s[%s]", s1, name, s2, s3, info);
3648 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, name, info);
3652 move_cursor_relative(y, x);
3655 /* Always stop at "normal" keys */
3656 if ((query != '\r') && (query != '\n') && (query != ' ')) return query;
3659 /* Stop on everything but "return" */
3660 if ((query != '\r') && (query != '\n')) return query;
3662 /* Repeat forever */
3668 * Handle "target" and "look".
3670 * Note that this code can be called from "get_aim_dir()".
3672 * All locations must be on the current panel. Consider the use of
3673 * "panel_bounds()" to allow "off-panel" targets, perhaps by using
3674 * some form of "scrolling" the map around the cursor. XXX XXX XXX
3675 * That is, consider the possibility of "auto-scrolling" the screen
3676 * while the cursor moves around. This may require changes in the
3677 * "update_mon()" code to allow "visibility" even if off panel, and
3678 * may require dynamic recalculation of the "temp" grid set.
3680 * Hack -- targeting/observing an "outer border grid" may induce
3681 * problems, so this is not currently allowed.
3683 * The player can use the direction keys to move among "interesting"
3684 * grids in a heuristic manner, or the "space", "+", and "-" keys to
3685 * move through the "interesting" grids in a sequential manner, or
3686 * can enter "location" mode, and use the direction keys to move one
3687 * grid at a time in any direction. The "t" (set target) command will
3688 * only target a monster (as opposed to a location) if the monster is
3689 * target_able and the "interesting" mode is being used.
3691 * The current grid is described using the "look" method above, and
3692 * a new command may be entered at any time, but note that if the
3693 * "TARGET_LOOK" bit flag is set (or if we are in "location" mode,
3694 * where "space" has no obvious meaning) then "space" will scan
3695 * through the description of the current grid until done, instead
3696 * of immediately jumping to the next "interesting" grid. This
3697 * allows the "target" command to retain its old semantics.
3699 * The "*", "+", and "-" keys may always be used to jump immediately
3700 * to the next (or previous) interesting grid, in the proper mode.
3702 * The "return" key may always be used to scan through a complete
3703 * grid description (forever).
3705 * This command will cancel any old target, even if used from
3706 * inside the "look" command.
3708 bool target_set(int mode)
3728 get_screen_size(&wid, &hgt);
3734 /* Cancel tracking */
3735 /* health_track(0); */
3738 /* Prepare the "temp" array */
3739 target_set_prepare(mode);
3741 /* Start near the player */
3747 /* Interesting grids */
3753 if (!(mode & TARGET_LOOK)) prt_path(y, x);
3756 c_ptr = &cave[y][x];
3759 if (target_able(c_ptr->m_idx))
3762 strcpy(info, "q»ß t·è p¼« o¸½ +¼¡ -Á°");
3764 strcpy(info, "q,t,p,o,+,-,<dir>");
3769 /* Dis-allow target */
3773 strcpy(info, "q»ß p¼« o¸½ +¼¡ -Á°");
3775 strcpy(info, "q,p,o,+,-,<dir>");
3780 /* Describe and Prompt */
3781 while (!(query = target_set_aux(y, x, mode, info)));
3783 /* Cancel tracking */
3784 /* health_track(0); */
3786 /* Assume no "direction" */
3791 if (query == '\r') query = 't';
3809 if (target_able(c_ptr->m_idx))
3811 health_track(c_ptr->m_idx);
3812 target_who = c_ptr->m_idx;
3831 if (!expand_list) done = TRUE;
3841 if (!expand_list) done = TRUE;
3848 /* Recenter the map around the player */
3852 p_ptr->update |= (PU_MONSTERS);
3855 p_ptr->redraw |= (PR_MAP);
3858 p_ptr->window |= (PW_OVERHEAD);
3863 /* Recalculate interesting grids */
3864 target_set_prepare(mode);
3883 /* Extract the action (if any) */
3884 d = get_keymap_dir(query);
3891 /* Hack -- move around */
3894 /* Modified to scroll to monster */
3895 int y2 = panel_row_min;
3896 int x2 = panel_col_min;
3898 /* Find a new monster */
3899 i = target_pick(temp_y[m], temp_x[m], ddy[d], ddx[d]);
3901 /* Request to target past last interesting grid */
3902 while (flag && (i < 0))
3904 /* Note the change */
3905 if (change_panel(ddy[d], ddx[d]))
3910 /* Recalculate interesting grids */
3911 target_set_prepare(mode);
3913 /* Look at interesting grids */
3916 /* Find a new monster */
3917 i = target_pick(v, u, ddy[d], ddx[d]);
3923 /* Nothing interesting */
3929 /* Restore previous position */
3932 panel_bounds_center();
3935 p_ptr->update |= (PU_MONSTERS);
3938 p_ptr->redraw |= (PR_MAP);
3941 p_ptr->window |= (PW_OVERHEAD);
3946 /* Recalculate interesting grids */
3947 target_set_prepare(mode);
3949 /* Look at boring grids */
3956 /* Do not move horizontally if unnecessary */
3957 if (((x < panel_col_min + wid / 2) && (dx > 0)) ||
3958 ((x > panel_col_min + wid / 2) && (dx < 0)))
3963 /* Do not move vertically if unnecessary */
3964 if (((y < panel_row_min + hgt / 2) && (dy > 0)) ||
3965 ((y > panel_row_min + hgt / 2) && (dy < 0)))
3970 /* Apply the motion */
3971 if ((y >= panel_row_min+hgt) || (y < panel_row_min) ||
3972 (x >= panel_col_min+wid) || (x < panel_col_min))
3974 if (change_panel(dy, dx)) target_set_prepare(mode);
3977 /* Slide into legality */
3978 if (x >= cur_wid-1) x = cur_wid - 2;
3979 else if (x <= 0) x = 1;
3981 /* Slide into legality */
3982 if (y >= cur_hgt-1) y = cur_hgt- 2;
3983 else if (y <= 0) y = 1;
3992 /* Arbitrary grids */
3995 bool move_fast = FALSE;
3997 if (!(mode & TARGET_LOOK)) prt_path(y, x);
4000 c_ptr = &cave[y][x];
4002 /* Default prompt */
4004 strcpy(info, "q»ß t·è p¼« m¶á +¼¡ -Á°");
4006 strcpy(info, "q,t,p,m,+,-,<dir>");
4010 /* Describe and Prompt (enable "TARGET_LOOK") */
4011 while (!(query = target_set_aux(y, x, mode | TARGET_LOOK, info)));
4013 /* Cancel tracking */
4014 /* health_track(0); */
4016 /* Assume no direction */
4021 if (query == '\r') query = 't';
4024 /* Analyze the keypress */
4048 /* Recenter the map around the player */
4052 p_ptr->update |= (PU_MONSTERS);
4055 p_ptr->redraw |= (PR_MAP);
4058 p_ptr->window |= (PW_OVERHEAD);
4063 /* Recalculate interesting grids */
4064 target_set_prepare(mode);
4086 /* Pick a nearby monster */
4087 for (i = 0; i < temp_n; i++)
4089 t = distance(y, x, temp_y[i], temp_x[i]);
4099 /* Nothing interesting */
4100 if (bd == 999) flag = FALSE;
4107 /* Extract the action (if any) */
4108 d = get_keymap_dir(query);
4110 /* XTRA HACK MOVEFAST */
4111 if (isupper(query)) move_fast = TRUE;
4118 /* Handle "direction" */
4124 /* XTRA HACK MOVEFAST */
4127 int mag = MIN(wid / 2, hgt / 2);
4137 /* Do not move horizontally if unnecessary */
4138 if (((x < panel_col_min + wid / 2) && (dx > 0)) ||
4139 ((x > panel_col_min + wid / 2) && (dx < 0)))
4144 /* Do not move vertically if unnecessary */
4145 if (((y < panel_row_min + hgt / 2) && (dy > 0)) ||
4146 ((y > panel_row_min + hgt / 2) && (dy < 0)))
4151 /* Apply the motion */
4152 if ((y >= panel_row_min + hgt) || (y < panel_row_min) ||
4153 (x >= panel_col_min + wid) || (x < panel_col_min))
4155 if (change_panel(dy, dx)) target_set_prepare(mode);
4158 /* Slide into legality */
4159 if (x >= cur_wid-1) x = cur_wid - 2;
4160 else if (x <= 0) x = 1;
4162 /* Slide into legality */
4163 if (y >= cur_hgt-1) y = cur_hgt- 2;
4164 else if (y <= 0) y = 1;
4172 /* Clear the top line */
4175 /* Recenter the map around the player */
4179 p_ptr->update |= (PU_MONSTERS);
4182 p_ptr->redraw |= (PR_MAP);
4185 p_ptr->window |= (PW_OVERHEAD);
4190 /* Failure to set target */
4191 if (!target_who) return (FALSE);
4199 * Get an "aiming direction" from the user.
4201 * The "dir" is loaded with 1,2,3,4,6,7,8,9 for "actual direction", and
4202 * "0" for "current target", and "-1" for "entry aborted".
4204 * Note that "Force Target", if set, will pre-empt user interaction,
4205 * if there is a usable target already set.
4207 * Note that confusion over-rides any (explicit?) user choice.
4209 bool get_aim_dir(int *dp)
4220 /* Global direction */
4223 /* Hack -- auto-target if requested */
4224 if (use_old_target && target_okay()) dir = 5;
4226 #ifdef ALLOW_REPEAT /* TNB */
4228 if (repeat_pull(dp))
4233 if (!(*dp == 5 && !target_okay()))
4235 /* return (TRUE); */
4240 #endif /* ALLOW_REPEAT -- TNB */
4242 /* Ask until satisfied */
4245 /* Choose a prompt */
4249 p = "Êý¸þ ('*'¤Ç¥¿¡¼¥²¥Ã¥ÈÁªÂò, ESC¤ÇÃæÃÇ)? ";
4251 p = "Direction ('*' to choose a target, Escape to cancel)? ";
4258 p = "Êý¸þ ('5'¤Ç¥¿¡¼¥²¥Ã¥È¤Ø, '*'¤Ç¥¿¡¼¥²¥Ã¥ÈºÆÁªÂò, ESC¤ÇÃæÃÇ)? ";
4260 p = "Direction ('5' for target, '*' to re-target, Escape to cancel)? ";
4265 /* Get a command (or Cancel) */
4266 if (!get_com(p, &command, TRUE)) break;
4270 if (command == '\r') command = 't';
4273 /* Convert various keys to "standard" keys */
4276 /* Use current target */
4287 /* Set new target */
4292 if (target_set(TARGET_KILL)) dir = 5;
4298 /* Extract the action (if any) */
4299 dir = get_keymap_dir(command);
4305 /* Verify requested targets */
4306 if ((dir == 5) && !target_okay()) dir = 0;
4315 project_length = 0; /* reset to default */
4319 /* Save the direction */
4322 /* Check for confusion */
4323 if (p_ptr->confused)
4326 /* Random direction */
4327 dir = ddd[randint0(8)];
4330 /* Notice confusion */
4331 if (command_dir != dir)
4335 msg_print("¤¢¤Ê¤¿¤Ïº®Í𤷤Ƥ¤¤ë¡£");
4337 msg_print("You are confused.");
4342 /* Save direction */
4345 #ifdef ALLOW_REPEAT /* TNB */
4347 /* repeat_push(dir); */
4348 repeat_push(command_dir);
4350 #endif /* ALLOW_REPEAT -- TNB */
4352 /* A "valid" direction was entered */
4359 * Request a "movement" direction (1,2,3,4,6,7,8,9) from the user,
4360 * and place it into "command_dir", unless we already have one.
4362 * This function should be used for all "repeatable" commands, such as
4363 * run, walk, open, close, bash, disarm, spike, tunnel, etc, as well
4364 * as all commands which must reference a grid adjacent to the player,
4365 * and which may not reference the grid under the player. Note that,
4366 * for example, it is no longer possible to "disarm" or "open" chests
4367 * in the same grid as the player.
4369 * Direction "5" is illegal and will (cleanly) abort the command.
4371 * This function tracks and uses the "global direction", and uses
4372 * that as the "desired direction", to which "confusion" is applied.
4374 bool get_rep_dir(int *dp, bool under)
4381 /* Global direction */
4384 #ifdef ALLOW_REPEAT /* TNB */
4386 if (repeat_pull(dp))
4389 /* return (TRUE); */
4392 #endif /* ALLOW_REPEAT -- TNB */
4394 /* Get a direction */
4399 /* Get a command (or Cancel) */
4401 if (!get_com("Êý¸þ (ESC¤ÇÃæÃÇ)? ", &ch, TRUE)) break;
4403 if (!get_com("Direction (Escape to cancel)? ", &ch, TRUE)) break;
4407 /* Look up the direction */
4408 dir = get_keymap_dir(ch);
4414 /* Prevent weirdness */
4415 if ((dir == 5) && (!under)) dir = 0;
4418 if (!dir) return (FALSE);
4420 /* Save desired direction */
4423 /* Apply "confusion" */
4424 if (p_ptr->confused)
4426 /* Standard confusion */
4427 if (randint0(100) < 75)
4429 /* Random direction */
4430 dir = ddd[randint0(8)];
4433 else if (p_ptr->riding)
4435 monster_type *m_ptr = &m_list[p_ptr->riding];
4436 monster_race *r_ptr = &r_info[m_ptr->r_idx];
4438 if (m_ptr->confused)
4440 /* Standard confusion */
4441 if (randint0(100) < 75)
4443 /* Random direction */
4444 dir = ddd[randint0(8)];
4447 else if ((r_ptr->flags1 & RF1_RAND_50) && (r_ptr->flags1 & RF1_RAND_25) && (randint0(100) < 50))
4449 /* Random direction */
4450 dir = ddd[randint0(8)];
4452 else if ((r_ptr->flags1 & RF1_RAND_50) && (randint0(100) < 25))
4454 /* Random direction */
4455 dir = ddd[randint0(8)];
4459 /* Notice confusion */
4460 if (command_dir != dir)
4462 if (p_ptr->confused)
4466 msg_print("¤¢¤Ê¤¿¤Ïº®Í𤷤Ƥ¤¤ë¡£");
4468 msg_print("You are confused.");
4474 monster_type *m_ptr = &m_list[p_ptr->riding];
4476 monster_desc(m_name, m_ptr, 0);
4477 if (m_ptr->confused)
4480 msg_format("%s¤Ïº®Í𤷤Ƥ¤¤ë¡£", m_name);
4482 msg_format("%^s is confusing.", m_name);
4489 msg_format("%s¤Ï»×¤¤Ä̤ê¤ËÆ°¤¤¤Æ¤¯¤ì¤Ê¤¤¡£", m_name);
4491 msg_format("You cannot control %s.", m_name);
4497 /* Save direction */
4500 #ifdef ALLOW_REPEAT /* TNB */
4502 /* repeat_push(dir); */
4503 repeat_push(command_dir);
4505 #endif /* ALLOW_REPEAT -- TNB */
4512 bool get_rep_dir2(int *dp)
4519 /* Global direction */
4522 #ifdef ALLOW_REPEAT /* TNB */
4524 if (repeat_pull(dp))
4527 /* return (TRUE); */
4530 #endif /* ALLOW_REPEAT -- TNB */
4532 /* Get a direction */
4537 /* Get a command (or Cancel) */
4539 if (!get_com("Êý¸þ (ESC¤ÇÃæÃÇ)? ", &ch, TRUE)) break;
4541 if (!get_com("Direction (Escape to cancel)? ", &ch, TRUE)) break;
4545 /* Look up the direction */
4546 dir = get_keymap_dir(ch);
4552 /* Prevent weirdness */
4553 if (dir == 5) dir = 0;
4556 if (!dir) return (FALSE);
4558 /* Save desired direction */
4561 /* Apply "confusion" */
4562 if (p_ptr->confused)
4564 /* Standard confusion */
4565 if (randint0(100) < 75)
4567 /* Random direction */
4568 dir = ddd[randint0(8)];
4572 /* Notice confusion */
4573 if (command_dir != dir)
4577 msg_print("¤¢¤Ê¤¿¤Ïº®Í𤷤Ƥ¤¤ë¡£");
4579 msg_print("You are confused.");
4584 /* Save direction */
4587 #ifdef ALLOW_REPEAT /* TNB */
4589 /* repeat_push(dir); */
4590 repeat_push(command_dir);
4592 #endif /* ALLOW_REPEAT -- TNB */
4599 void gain_level_reward(int chosen_reward)
4603 char wrath_reason[32] = "";
4604 int nasty_chance = 6;
4605 int dummy = 0, dummy2 = 0;
4608 char o_name[MAX_NLEN];
4614 if (multi_rew) return;
4615 else multi_rew = TRUE;
4619 if (p_ptr->lev == 13) nasty_chance = 2;
4620 else if (!(p_ptr->lev % 13)) nasty_chance = 3;
4621 else if (!(p_ptr->lev % 14)) nasty_chance = 12;
4623 if (one_in_(nasty_chance))
4624 type = randint1(20); /* Allow the 'nasty' effects */
4626 type = randint1(15) + 5; /* Or disallow them */
4628 if (type < 1) type = 1;
4629 if (type > 20) type = 20;
4634 sprintf(wrath_reason, "%s¤ÎÅܤê",
4635 chaos_patrons[p_ptr->chaos_patron]);
4637 sprintf(wrath_reason, "the Wrath of %s",
4638 chaos_patrons[p_ptr->chaos_patron]);
4642 effect = chaos_rewards[p_ptr->chaos_patron][type];
4644 if (one_in_(6) && !chosen_reward)
4647 msg_format("%^s¤ÏË«Èþ¤È¤·¤Æ¤¢¤Ê¤¿¤òÆÍÁ³ÊÑ°Û¤µ¤»¤¿¡£",
4648 chaos_patrons[p_ptr->chaos_patron]);
4650 msg_format("%^s rewards you with a mutation!",
4651 chaos_patrons[p_ptr->chaos_patron]);
4654 (void)gain_random_mutation(0);
4656 reward = "ÊÑ°Û¤·¤¿¡£";
4658 reward = "mutation";
4663 switch (chosen_reward ? chosen_reward : effect)
4667 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
4668 chaos_patrons[p_ptr->chaos_patron]);
4670 msg_format("The voice of %s booms out:",
4671 chaos_patrons[p_ptr->chaos_patron]);
4675 msg_print("¡ÖÆò¡¢¿·¤¿¤Ê¤ë»Ñ¤òɬÍפȤ»¤ê¡ª¡×");
4677 msg_print("'Thou needst a new form, mortal!'");
4682 reward = "ÊÑ°Û¤·¤¿¡£";
4684 reward = "polymorphing";
4689 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
4690 chaos_patrons[p_ptr->chaos_patron]);
4692 msg_format("The voice of %s booms out:",
4693 chaos_patrons[p_ptr->chaos_patron]);
4697 msg_print("¡ÖÆò¤ÏÎɤ¯¹Ô¤¤¤¿¤ê¡ªÂ³¤±¤è¡ª¡×");
4699 msg_print("'Well done, mortal! Lead on!'");
4702 if (p_ptr->prace == RACE_ANDROID)
4705 msg_print("¤·¤«¤·²¿¤âµ¯¤³¤é¤Ê¤«¤Ã¤¿¡£");
4707 msg_print("But, nothing happen.");
4710 else if (p_ptr->exp < PY_MAX_EXP)
4712 s32b ee = (p_ptr->exp / 2) + 10;
4713 if (ee > 100000L) ee = 100000L;
4715 msg_print("¹¹¤Ë·Ð¸³¤òÀѤó¤À¤è¤¦¤Êµ¤¤¬¤¹¤ë¡£");
4717 msg_print("You feel more experienced.");
4722 reward = "·Ð¸³ÃͤòÆÀ¤¿";
4724 reward = "experience";
4730 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
4731 chaos_patrons[p_ptr->chaos_patron]);
4733 msg_format("The voice of %s booms out:",
4734 chaos_patrons[p_ptr->chaos_patron]);
4738 msg_print("¡Ö²¼Ëͤ衢Æò¤½¤ì¤ËÃͤ»¤º¡£¡×");
4740 msg_print("'Thou didst not deserve that, slave.'");
4743 if (p_ptr->prace == RACE_ANDROID)
4746 msg_print("¤·¤«¤·²¿¤âµ¯¤³¤é¤Ê¤«¤Ã¤¿¡£");
4748 msg_print("But, nothing happen.");
4753 lose_exp(p_ptr->exp / 6);
4755 reward = "·Ð¸³Ãͤò¼º¤Ã¤¿¡£";
4757 reward = "losing experience";
4763 msg_format("%s¤ÎÀ¼¤¬¤µ¤µ¤ä¤¤¤¿:",
4764 chaos_patrons[p_ptr->chaos_patron]);
4766 msg_format("The voice of %s whispers:",
4767 chaos_patrons[p_ptr->chaos_patron]);
4771 msg_print("¡Ö²æ¤¬Í¿¤¨¤·Êª¤ò¸ÌÀ¤Ë»È¤¦¤Ù¤·¡£¡×");
4773 msg_print("'Use my gift wisely.'");
4776 acquirement(py, px, 1, FALSE, FALSE);
4778 reward = "¾å¼Á¤Ê¥¢¥¤¥Æ¥à¤ò¼ê¤ËÆþ¤ì¤¿¡£";
4780 reward = "a good item";
4785 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
4786 chaos_patrons[p_ptr->chaos_patron]);
4788 msg_format("The voice of %s booms out:",
4789 chaos_patrons[p_ptr->chaos_patron]);
4793 msg_print("¡Ö²æ¤¬Í¿¤¨¤·Êª¤ò¸ÌÀ¤Ë»È¤¦¤Ù¤·¡£¡×");
4795 msg_print("'Use my gift wisely.'");
4798 acquirement(py, px, 1, TRUE, FALSE);
4800 reward = "¹âµéÉʤΥ¢¥¤¥Æ¥à¤ò¼ê¤ËÆþ¤ì¤¿¡£";
4802 reward = "an excellent item";
4807 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
4808 chaos_patrons[p_ptr->chaos_patron]);
4810 msg_format("The voice of %s booms out:",
4811 chaos_patrons[p_ptr->chaos_patron]);
4815 msg_print("¡ÖÆò¤Î¹Ô¤¤¤Ïµ®¤·õ¤ËÃͤ»¤ê¡£¡×");
4817 msg_print("'Thy deed hath earned thee a worthy blade.'");
4820 /* Get local object */
4823 switch (randint1(p_ptr->lev))
4829 dummy2 = SV_MAIN_GAUCHE;
4838 dummy2 = SV_SMALL_SWORD;
4841 dummy2 = SV_BASILLARD;
4843 case 11: case 12: case 13:
4844 dummy2 = SV_SHORT_SWORD;
4850 dummy2 = SV_CUTLASS;
4853 dummy2 = SV_WAKIZASHI;
4856 dummy2 = SV_KHOPESH;
4862 dummy2 = SV_BROAD_SWORD;
4865 dummy2 = SV_LONG_SWORD;
4868 dummy2 = SV_SCIMITAR;
4871 dummy2 = SV_NINJATO;
4877 dummy2 = SV_BASTARD_SWORD;
4880 dummy2 = SV_GREAT_SCIMITAR;
4883 dummy2 = SV_CLAYMORE;
4886 dummy2 = SV_ESPADON;
4889 dummy2 = SV_TWO_HANDED_SWORD;
4892 dummy2 = SV_FLAMBERGE;
4895 dummy2 = SV_NO_DACHI;
4898 dummy2 = SV_EXECUTIONERS_SWORD;
4901 dummy2 = SV_ZWEIHANDER;
4904 dummy2 = SV_HAYABUSA;
4907 dummy2 = SV_BLADE_OF_CHAOS;
4910 object_prep(q_ptr, lookup_kind(dummy, dummy2));
4911 q_ptr->to_h = 3 + randint1(dun_level) % 10;
4912 q_ptr->to_d = 3 + randint1(dun_level) % 10;
4913 one_resistance(q_ptr);
4914 q_ptr->name2 = EGO_CHAOTIC;
4916 /* Drop it in the dungeon */
4917 (void)drop_near(q_ptr, -1, py, px);
4919 reward = "(º®ÆÙ)¤ÎÉð´ï¤ò¼ê¤ËÆþ¤ì¤¿¡£";
4921 reward = "chaos weapon";
4926 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
4927 chaos_patrons[p_ptr->chaos_patron]);
4929 msg_format("The voice of %s booms out:",
4930 chaos_patrons[p_ptr->chaos_patron]);
4934 msg_print("¡ÖÆò¤Î¹Ô¤¤¤Ïµ®¤Ê󤤤ËÃͤ»¤ê¡£¡×");
4936 msg_print("'Thy deed hath earned thee a worthy reward.'");
4939 acquirement(py, px, randint1(2) + 1, FALSE, FALSE);
4941 reward = "¾å¼Á¤Ê¥¢¥¤¥Æ¥à¤ò¼ê¤ËÆþ¤ì¤¿¡£";
4943 reward = "good items";
4948 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
4949 chaos_patrons[p_ptr->chaos_patron]);
4951 msg_format("The voice of %s booms out:",
4952 chaos_patrons[p_ptr->chaos_patron]);
4956 msg_print("¡Ö²¼Ëͤ衢Æò¤Î¸¥¿È¤Ø¤Î²æ¤¬Àˤ·¤ß̵¤Ê󤤤ò¸«¤ë¤¬¤è¤¤¡£¡×");
4958 msg_print("'Behold, mortal, how generously I reward thy loyalty.'");
4961 acquirement(py, px, randint1(2) + 1, TRUE, FALSE);
4963 reward = "¹âµéÉʤΥ¢¥¤¥Æ¥à¤ò¼ê¤ËÆþ¤ì¤¿¡£";
4965 reward = "excellent items";
4970 msg_format("%s¤ÎÀ¼¤¬¹ì¤ÅϤä¿:",
4971 chaos_patrons[p_ptr->chaos_patron]);
4973 msg_format("The voice of %s thunders:",
4974 chaos_patrons[p_ptr->chaos_patron]);
4978 msg_print("¡Ö²¼Ëͤ衢ÆòÐþËý¤Ê¤ê¡£¡×");
4980 msg_print("'Thou art growing arrogant, mortal.'");
4983 (void)activate_ty_curse(FALSE, &count);
4985 reward = "²Ò¡¹¤·¤¤¼ö¤¤¤ò¤«¤±¤é¤ì¤¿¡£";
4992 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
4993 chaos_patrons[p_ptr->chaos_patron]);
4995 msg_format("The voice of %s booms out:",
4996 chaos_patrons[p_ptr->chaos_patron]);
5000 msg_print("¡Ö²æ¤¬²¼Ëͤ¿¤Á¤è¡¢¤«¤ÎÐþËý¤Ê¤ë¼Ô¤òÅݤ¹¤Ù¤·¡ª¡×");
5002 msg_print("'My pets, destroy the arrogant mortal!'");
5005 for (dummy = 0; dummy < randint1(5) + 1; dummy++)
5007 (void)summon_specific(0, py, px, dun_level, 0, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET));
5010 reward = "¥â¥ó¥¹¥¿¡¼¤ò¾¤´¤µ¤ì¤¿¡£";
5012 reward = "summoning hostile monsters";
5017 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5018 chaos_patrons[p_ptr->chaos_patron]);
5020 msg_format("The voice of %s booms out:",
5021 chaos_patrons[p_ptr->chaos_patron]);
5025 msg_print("¡ÖÆò¡¢¤è¤ê¶¯¤Å¨¤òɬÍפȤ»¤ê¡ª¡×");
5027 msg_print("'Thou needst worthier opponents!'");
5030 activate_hi_summon(py, px, FALSE);
5032 reward = "¥â¥ó¥¹¥¿¡¼¤ò¾¤´¤µ¤ì¤¿¡£";
5034 reward = "summoning many hostile monsters";
5039 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5040 chaos_patrons[p_ptr->chaos_patron]);
5042 msg_format("The voice of %s booms out:",
5043 chaos_patrons[p_ptr->chaos_patron]);
5047 msg_print("¡Ö»à¤ÈÇ˲õ¤³¤½²æ¤¬´î¤Ó¤Ê¤ê¡ª¡×");
5049 msg_print("'Death and destruction! This pleaseth me!'");
5054 reward = "¥«¥ª¥¹¤ÎÎϤ¬±²´¬¤¤¤¿¡£";
5056 reward = "calling chaos";
5061 msg_format("%s¤ÎÀ¼¤¬ÌĤê¶Á¤¤¤¿:",
5062 chaos_patrons[p_ptr->chaos_patron]);
5064 msg_format("The voice of %s rings out:",
5065 chaos_patrons[p_ptr->chaos_patron]);
5069 msg_print("¡Öα¤Þ¤ë¤Î¤À¡¢²¼Ëͤ衣;¤¬Æò¤ÎÆùÂΤòÃ䨤󡣡×");
5071 msg_print("'Stay, mortal, and let me mold thee.'");
5074 if (one_in_(3) && !(chaos_stats[p_ptr->chaos_patron] < 0))
5075 do_inc_stat(chaos_stats[p_ptr->chaos_patron]);
5077 do_inc_stat(randint0(6));
5079 reward = "ǽÎÏÃͤ¬¾å¤¬¤Ã¤¿¡£";
5081 reward = "increasing a stat";
5086 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5087 chaos_patrons[p_ptr->chaos_patron]);
5089 msg_format("The voice of %s booms out:",
5090 chaos_patrons[p_ptr->chaos_patron]);
5094 msg_print("¡Ö²¼Ëͤ衢;¤ÏÆò¤ËË°¤ß¤¿¤ê¡£¡×");
5096 msg_print("'I grow tired of thee, mortal.'");
5099 if (one_in_(3) && !(chaos_stats[p_ptr->chaos_patron] < 0))
5100 do_dec_stat(chaos_stats[p_ptr->chaos_patron]);
5102 (void)do_dec_stat(randint0(6));
5104 reward = "ǽÎÏÃͤ¬²¼¤¬¤Ã¤¿¡£";
5106 reward = "decreasing a stat";
5111 msg_format("%s¤ÎÀ¼¤¬¹ì¤ÅϤä¿:",
5112 chaos_patrons[p_ptr->chaos_patron]);
5114 msg_format("The voice of %s thunders:",
5115 chaos_patrons[p_ptr->chaos_patron]);
5119 msg_print("¡ÖÆò¡¢¸¬µõ¤¿¤ë¤³¤È¤ò³Ø¤Ö¤Ù¤·¡ª¡×");
5120 msg_print("¤¢¤Ê¤¿¤Ï°ÊÁ°¤è¤ê¼å¤¯¤Ê¤Ã¤¿¡ª");
5122 msg_print("'Thou needst a lesson in humility, mortal!'");
5123 msg_print("You feel less powerful!");
5126 for (dummy = 0; dummy < 6; dummy++)
5128 (void)dec_stat(dummy, 10 + randint1(15), TRUE);
5131 reward = "Á´Ç½ÎÏÃͤ¬²¼¤¬¤Ã¤¿¡£";
5133 reward = "decreasing all stats";
5138 msg_format("%s¤ÎÎϤ¬¿¨¤ì¤ë¤Î¤ò´¶¤¸¤¿¡£",
5140 msg_format("You feel the power of %s touch you.",
5143 chaos_patrons[p_ptr->chaos_patron]);
5146 reward = "½ý¤¬ÊѲ½¤·¤¿¡£";
5148 reward = "polymorphing wounds";
5153 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5154 chaos_patrons[p_ptr->chaos_patron]);
5156 msg_format("The voice of %s booms out:",
5157 chaos_patrons[p_ptr->chaos_patron]);
5161 msg_print("¡Ö²æ¤¬¤µ¤µ¤ä¤«¤Ê¤ë»òʪ¤ò¼õ¤±¤È¤ë¤¬¤è¤¤¡ª¡×");
5163 msg_print("'Receive this modest gift from me!'");
5166 for (dummy = 0; dummy < 6; dummy++)
5168 (void)do_inc_stat(dummy);
5171 reward = "Á´Ç½ÎÏÃͤ¬¾å¤¬¤Ã¤¿¡£";
5173 reward = "increasing all stats";
5178 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5179 chaos_patrons[p_ptr->chaos_patron]);
5181 msg_format("The voice of %s booms out:",
5182 chaos_patrons[p_ptr->chaos_patron]);
5186 msg_print("¡Ö¶ì¤·¤à¤¬¤è¤¤¡¢ÌµÇ½¤Ê¶ò¤«¼Ô¤è¡ª¡×");
5188 msg_print("'Suffer, pathetic fool!'");
5191 fire_ball(GF_DISINTEGRATE, 0, p_ptr->lev * 4, 4);
5192 take_hit(DAMAGE_NOESCAPE, p_ptr->lev * 4, wrath_reason, -1);
5194 reward = "ʬ²ò¤Îµå¤¬È¯À¸¤·¤¿¡£";
5196 reward = "generating disintegration ball";
5201 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5202 chaos_patrons[p_ptr->chaos_patron]);
5204 msg_format("The voice of %s booms out:",
5205 chaos_patrons[p_ptr->chaos_patron]);
5209 msg_print("¡Öᴤ뤬¤è¤¤¡¢²æ¤¬²¼Ëͤ衪¡×");
5211 msg_print("'Rise, my servant!'");
5215 (void)set_poisoned(0);
5217 (void)set_confused(0);
5222 for (dummy = 0; dummy < 6; dummy++)
5224 (void)do_res_stat(dummy);
5227 reward = "ÂÎÎϤ¬²óÉü¤·¤¿¡£";
5233 if (!buki_motteruka(INVEN_RARM)) break;
5235 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5236 chaos_patrons[p_ptr->chaos_patron]);
5238 msg_format("The voice of %s booms out:",
5239 chaos_patrons[p_ptr->chaos_patron]);
5243 msg_print("¡ÖÆò¡¢Éð´ï¤ËÍê¤ë¤³¤È¤Ê¤«¤ì¡£¡×");
5245 msg_print("'Thou reliest too much on thy weapon.'");
5248 object_desc(o_name, &inventory[INVEN_RARM], OD_NAME_ONLY);
5249 (void)curse_weapon(FALSE, INVEN_RARM);
5251 reward = format("%s¤¬Ç˲õ¤µ¤ì¤¿¡£", o_name);
5253 reward = format("destroying %s", o_name);
5257 if (!inventory[INVEN_BODY].k_idx) break;
5259 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5260 chaos_patrons[p_ptr->chaos_patron]);
5262 msg_format("The voice of %s booms out:",
5263 chaos_patrons[p_ptr->chaos_patron]);
5267 msg_print("¡ÖÆò¡¢Ëɶñ¤ËÍê¤ë¤³¤È¤Ê¤«¤ì¡£¡×");
5269 msg_print("'Thou reliest too much on thine equipment.'");
5272 object_desc(o_name, &inventory[INVEN_BODY], OD_NAME_ONLY);
5273 (void)curse_armor();
5275 reward = format("%s¤¬Ç˲õ¤µ¤ì¤¿¡£", o_name);
5277 reward = format("destroying %s", o_name);
5282 msg_format("%s¤ÎÀ¼¤¬¤µ¤µ¤ä¤¤¤¿:",
5283 chaos_patrons[p_ptr->chaos_patron]);
5285 msg_format("The voice of %s whispers:",
5286 chaos_patrons[p_ptr->chaos_patron]);
5290 msg_print("¡Ö²æ¤òÅܤꤷ¤á¤¿ºá¤ò½þ¤¦¤Ù¤·¡£¡×");
5292 msg_print("'Now thou shalt pay for annoying me.'");
5295 switch (randint1(4))
5298 (void)activate_ty_curse(FALSE, &count);
5300 reward = "²Ò¡¹¤·¤¤¼ö¤¤¤ò¤«¤±¤é¤ì¤¿¡£";
5306 activate_hi_summon(py, px, FALSE);
5308 reward = "¥â¥ó¥¹¥¿¡¼¤ò¾¤´¤µ¤ì¤¿¡£";
5310 reward = "summoning hostile monsters";
5316 if (!buki_motteruka(INVEN_RARM)) break;
5317 object_desc(o_name, &inventory[INVEN_RARM], OD_NAME_ONLY);
5318 (void)curse_weapon(FALSE, INVEN_RARM);
5320 reward = format("%s¤¬Ç˲õ¤µ¤ì¤¿¡£", o_name);
5322 reward = format("destroying %s", o_name);
5327 if (!inventory[INVEN_BODY].k_idx) break;
5328 object_desc(o_name, &inventory[INVEN_BODY], OD_NAME_ONLY);
5329 (void)curse_armor();
5331 reward = format("%s¤¬Ç˲õ¤µ¤ì¤¿¡£", o_name);
5333 reward = format("destroying %s", o_name);
5338 for (dummy = 0; dummy < 6; dummy++)
5340 (void)dec_stat(dummy, 10 + randint1(15), TRUE);
5343 reward = "Á´Ç½ÎÏÃͤ¬²¼¤¬¤Ã¤¿¡£";
5345 reward = "decreasing all stats";
5352 msg_format("%s¤ÎÀ¼¤¬¹ì¤ÅϤä¿:",
5354 msg_format("The voice of %s thunders:",
5357 chaos_patrons[p_ptr->chaos_patron]);
5359 msg_print("¡Ö»à¤Ì¤¬¤è¤¤¡¢²¼Ëͤ衪¡×");
5361 msg_print("'Die, mortal!'");
5364 take_hit(DAMAGE_LOSELIFE, p_ptr->lev * 4, wrath_reason, -1);
5365 for (dummy = 0; dummy < 6; dummy++)
5367 (void)dec_stat(dummy, 10 + randint1(15), FALSE);
5369 activate_hi_summon(py, px, FALSE);
5370 (void)activate_ty_curse(FALSE, &count);
5371 if (one_in_(2)) (void)curse_weapon(FALSE, INVEN_RARM);
5372 if (one_in_(2)) (void)curse_armor();
5376 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5377 chaos_patrons[p_ptr->chaos_patron]);
5379 msg_format("The voice of %s booms out:",
5380 chaos_patrons[p_ptr->chaos_patron]);
5384 msg_print("¡Ö»à¤ÈÇ˲õ¤³¤½²æ¤¬´î¤Ó¤Ê¤ê¡ª¡×");
5386 msg_print("'Death and destruction! This pleaseth me!'");
5389 (void)destroy_area(py, px, 25, FALSE);
5391 reward = "¥À¥ó¥¸¥ç¥ó¤¬*Ç˲õ*¤µ¤ì¤¿¡£";
5393 reward = "*destruct*ing dungeon";
5398 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5399 chaos_patrons[p_ptr->chaos_patron]);
5401 msg_format("The voice of %s booms out:",
5402 chaos_patrons[p_ptr->chaos_patron]);
5406 msg_print("¡Ö²æ¡¢Æò¤ÎŨ¤òËõ»¦¤»¤ó¡ª¡×");
5408 msg_print("'Let me relieve thee of thine oppressors!'");
5411 (void)symbol_genocide(0, FALSE);
5413 reward = "¥â¥ó¥¹¥¿¡¼¤¬Ëõ»¦¤µ¤ì¤¿¡£";
5415 reward = "genociding monsters";
5420 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5421 chaos_patrons[p_ptr->chaos_patron]);
5423 msg_format("The voice of %s booms out:",
5424 chaos_patrons[p_ptr->chaos_patron]);
5428 msg_print("¡Ö²æ¡¢Æò¤ÎŨ¤òËõ»¦¤»¤ó¡ª¡×");
5430 msg_print("'Let me relieve thee of thine oppressors!'");
5433 (void)mass_genocide(0, FALSE);
5435 reward = "¥â¥ó¥¹¥¿¡¼¤¬Ëõ»¦¤µ¤ì¤¿¡£";
5437 reward = "genociding nearby monsters";
5442 msg_format("%s¤ÎÎϤ¬Å¨¤ò¹¶·â¤¹¤ë¤Î¤ò´¶¤¸¤¿¡ª",
5443 chaos_patrons[p_ptr->chaos_patron]);
5445 msg_format("You can feel the power of %s assault your enemies!",
5446 chaos_patrons[p_ptr->chaos_patron]);
5449 (void)dispel_monsters(p_ptr->lev * 4);
5453 msg_format("%s¤Ï¤¢¤Ê¤¿¤ò̵»ë¤·¤¿¡£",
5454 chaos_patrons[p_ptr->chaos_patron]);
5456 msg_format("%s ignores you.",
5457 chaos_patrons[p_ptr->chaos_patron]);
5463 msg_format("%s¤ÏË«Èþ¤È¤·¤Æ°Ëâ¤Î»È¤¤¤ò¤è¤³¤·¤¿¡ª",chaos_patrons[p_ptr->chaos_patron]);
5465 msg_format("%s rewards you with a demonic servant!",chaos_patrons[p_ptr->chaos_patron]);
5468 if (!summon_specific(-1, py, px, dun_level, SUMMON_DEMON, PM_FORCE_PET))
5470 msg_print("²¿¤â¸½¤ì¤Ê¤«¤Ã¤¿...");
5472 msg_print("Nobody ever turns up...");
5476 reward = "°Ë⤬¥Ú¥Ã¥È¤Ë¤Ê¤Ã¤¿¡£";
5478 reward = "a demonic servant";
5484 msg_format("%s¤ÏË«Èþ¤È¤·¤Æ»È¤¤¤ò¤è¤³¤·¤¿¡ª",chaos_patrons[p_ptr->chaos_patron]);
5486 msg_format("%s rewards you with a servant!",chaos_patrons[p_ptr->chaos_patron]);
5489 if (!summon_specific(-1, py, px, dun_level, 0, PM_FORCE_PET))
5491 msg_print("²¿¤â¸½¤ì¤Ê¤«¤Ã¤¿...");
5493 msg_print("Nobody ever turns up...");
5497 reward = "¥â¥ó¥¹¥¿¡¼¤¬¥Ú¥Ã¥È¤Ë¤Ê¤Ã¤¿¡£";
5499 reward = "a servant";
5505 msg_format("%s¤ÏË«Èþ¤È¤·¤Æ¥¢¥ó¥Ç¥Ã¥É¤Î»È¤¤¤ò¤è¤³¤·¤¿¡£",chaos_patrons[p_ptr->chaos_patron]);
5507 msg_format("%s rewards you with an undead servant!",chaos_patrons[p_ptr->chaos_patron]);
5510 if (!summon_specific(-1, py, px, dun_level, SUMMON_UNDEAD, PM_FORCE_PET))
5512 msg_print("²¿¤â¸½¤ì¤Ê¤«¤Ã¤¿...");
5514 msg_print("Nobody ever turns up...");
5518 reward = "¥¢¥ó¥Ç¥Ã¥É¤¬¥Ú¥Ã¥È¤Ë¤Ê¤Ã¤¿¡£";
5520 reward = "an undead servant";
5526 msg_format("%s¤ÎÀ¼¤¬¤É¤â¤Ã¤¿:",
5528 msg_format("The voice of %s stammers:",
5531 chaos_patrons[p_ptr->chaos_patron]);
5533 msg_format("¡Ö¤¢¡¼¡¢¤¢¡¼¡¢Åú¤¨¤Ï %d/%d¡£¼ÁÌä¤Ï²¿¡©¡×", type, effect);
5535 msg_format("'Uh... uh... the answer's %d/%d, what's the question?'", type, effect);
5543 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, format("¥Ñ¥È¥í¥ó¤ÎÊó½·¤Ç%s", reward));
5545 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, format("The patron rewards you with %s.", reward));
5552 * old -- from PsiAngband.
5554 bool tgt_pt(int *x_ptr, int *y_ptr)
5558 bool success = FALSE;
5563 get_screen_size(&wid, &hgt);
5569 msg_print("¾ì½ê¤òÁª¤ó¤Ç¥¹¥Ú¡¼¥¹¥¡¼¤ò²¡¤·¤Æ²¼¤µ¤¤¡£");
5571 msg_print("Select a point and press space.");
5573 msg_flag = FALSE; /* prevents "-more-" message. */
5575 while ((ch != ESCAPE) && !success)
5577 bool move_fast = FALSE;
5579 move_cursor_relative(y, x);
5591 if (player_bold(y, x)) ch = 0;
5594 else success = TRUE;
5598 /* Look up the direction */
5599 d = get_keymap_dir(ch);
5601 /* XTRA HACK MOVEFAST */
5602 if (isupper(ch)) move_fast = TRUE;
5604 /* Handle "direction" */
5610 /* XTRA HACK MOVEFAST */
5613 int mag = MIN(wid / 2, hgt / 2);
5623 /* Do not move horizontally if unnecessary */
5624 if (((x < panel_col_min + wid / 2) && (dx > 0)) ||
5625 ((x > panel_col_min + wid / 2) && (dx < 0)))
5630 /* Do not move vertically if unnecessary */
5631 if (((y < panel_row_min + hgt / 2) && (dy > 0)) ||
5632 ((y > panel_row_min + hgt / 2) && (dy < 0)))
5637 /* Apply the motion */
5638 if ((y >= panel_row_min + hgt) || (y < panel_row_min) ||
5639 (x >= panel_col_min + wid) || (x < panel_col_min))
5641 /* if (change_panel(dy, dx)) target_set_prepare(mode); */
5642 change_panel(dy, dx);
5645 /* Slide into legality */
5646 if (x >= cur_wid-1) x = cur_wid - 2;
5647 else if (x <= 0) x = 1;
5649 /* Slide into legality */
5650 if (y >= cur_hgt-1) y = cur_hgt- 2;
5651 else if (y <= 0) y = 1;
5658 /* Clear the top line */
5661 /* Recenter the map around the player */
5665 p_ptr->update |= (PU_MONSTERS);
5668 p_ptr->redraw |= (PR_MAP);
5671 p_ptr->window |= (PW_OVERHEAD);
5682 bool get_hack_dir(int *dp)
5692 /* Global direction */
5695 /* (No auto-targeting) */
5697 /* Ask until satisfied */
5700 /* Choose a prompt */
5704 p = "Êý¸þ ('*'¤Ç¥¿¡¼¥²¥Ã¥ÈÁªÂò, ESC¤ÇÃæÃÇ)? ";
5706 p = "Direction ('*' to choose a target, Escape to cancel)? ";
5713 p = "Êý¸þ ('5'¤Ç¥¿¡¼¥²¥Ã¥È¤Ø, '*'¤Ç¥¿¡¼¥²¥Ã¥ÈºÆÁªÂò, ESC¤ÇÃæÃÇ)? ";
5715 p = "Direction ('5' for target, '*' to re-target, Escape to cancel)? ";
5720 /* Get a command (or Cancel) */
5721 if (!get_com(p, &command, TRUE)) break;
5725 if (command == '\r') command = 't';
5728 /* Convert various keys to "standard" keys */
5731 /* Use current target */
5742 /* Set new target */
5747 if (target_set(TARGET_KILL)) dir = 5;
5753 /* Look up the direction */
5754 dir = get_keymap_dir(command);
5760 /* Verify requested targets */
5761 if ((dir == 5) && !target_okay()) dir = 0;
5768 if (!dir) return (FALSE);
5770 /* Save the direction */
5773 /* Check for confusion */
5774 if (p_ptr->confused)
5777 /* Random direction */
5778 dir = ddd[randint0(8)];
5781 /* Notice confusion */
5782 if (command_dir != dir)
5786 msg_print("¤¢¤Ê¤¿¤Ïº®Í𤷤Ƥ¤¤ë¡£");
5788 msg_print("You are confused.");
5793 /* Save direction */
5796 /* A "valid" direction was entered */
5802 * ¥¨¥Í¥ë¥®¡¼¤ÎÁý²ÃÎÌ10d5¤ò®¤¯·×»»¤¹¤ë¤¿¤á¤Î´Ø¿ô
5805 #define Go_no_JuuJou 5*5*5*5*5*5*5*5*5*5
5807 s16b gain_energy(void)
5810 s32b energy_result = 10;
5813 tmp = randint0(Go_no_JuuJou);
5815 for (i = 0; i < 9; i ++){
5816 energy_result += tmp % 5;
5820 return (s16b)(energy_result + tmp);
5827 s16b bow_energy(int sval)
5831 /* Analyze the launcher */
5834 /* Sling and ammo */
5841 /* Short Bow and Arrow */
5848 /* Long Bow and Arrow */
5855 /* Bow of irresponsiblity and Arrow */
5862 /* Light Crossbow and Bolt */
5869 /* Heavy Crossbow and Bolt */
5884 int bow_tmul(int sval)
5888 /* Analyze the launcher */
5891 /* Sling and ammo */
5898 /* Short Bow and Arrow */
5905 /* Long Bow and Arrow */
5912 /* Bow of irresponsiblity and Arrow */
5919 /* Light Crossbow and Bolt */
5926 /* Heavy Crossbow and Bolt */
5938 * Return alignment title
5940 cptr your_alignment(void)
5943 if (p_ptr->align > 150) return "ÂçÁ±";
5944 else if (p_ptr->align > 50) return "ÃæÁ±";
5945 else if (p_ptr->align > 10) return "¾®Á±";
5946 else if (p_ptr->align > -11) return "ÃæΩ";
5947 else if (p_ptr->align > -51) return "¾®°";
5948 else if (p_ptr->align > -151) return "Ãæ°";
5951 if (p_ptr->align > 150) return "Lawful";
5952 else if (p_ptr->align > 50) return "Good";
5953 else if (p_ptr->align > 10) return "Neutral Good";
5954 else if (p_ptr->align > -11) return "Neutral";
5955 else if (p_ptr->align > -51) return "Neutral Evil";
5956 else if (p_ptr->align > -151) return "Evil";
5957 else return "Chaotic";
5963 * Return proficiency level of weapons and misc. skills (except riding)
5965 int weapon_exp_level(int weapon_exp)
5967 if (weapon_exp < WEAPON_EXP_BEGINNER) return EXP_LEVEL_UNSKILLED;
5968 else if (weapon_exp < WEAPON_EXP_SKILLED) return EXP_LEVEL_BEGINNER;
5969 else if (weapon_exp < WEAPON_EXP_EXPERT) return EXP_LEVEL_SKILLED;
5970 else if (weapon_exp < WEAPON_EXP_MASTER) return EXP_LEVEL_EXPERT;
5971 else return EXP_LEVEL_MASTER;
5976 * Return proficiency level of riding
5978 int riding_exp_level(int riding_exp)
5980 if (riding_exp < RIDING_EXP_BEGINNER) return EXP_LEVEL_UNSKILLED;
5981 else if (riding_exp < RIDING_EXP_SKILLED) return EXP_LEVEL_BEGINNER;
5982 else if (riding_exp < RIDING_EXP_EXPERT) return EXP_LEVEL_SKILLED;
5983 else if (riding_exp < RIDING_EXP_MASTER) return EXP_LEVEL_EXPERT;
5984 else return EXP_LEVEL_MASTER;
5989 * Return proficiency level of spells
5991 int spell_exp_level(int spell_exp)
5993 if (spell_exp < SPELL_EXP_BEGINNER) return EXP_LEVEL_UNSKILLED;
5994 else if (spell_exp < SPELL_EXP_SKILLED) return EXP_LEVEL_BEGINNER;
5995 else if (spell_exp < SPELL_EXP_EXPERT) return EXP_LEVEL_SKILLED;
5996 else if (spell_exp < SPELL_EXP_MASTER) return EXP_LEVEL_EXPERT;
5997 else return EXP_LEVEL_MASTER;