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);
27 int old_lev = p_ptr->lev;
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 | PR_EXP);
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);
225 /* Load an autopick preference file */
226 if (old_lev != p_ptr->lev) autopick_load_pref(FALSE);
231 * Hack -- Return the "automatic coin type" of a monster race
232 * Used to allocate proper treasure when "Creeping coins" die
234 * XXX XXX XXX Note the use of actual "monster names"
236 static int get_coin_type(int r_idx)
238 /* Analyze monsters */
241 case MON_COPPER_COINS: return 2;
242 case MON_SILVER_COINS: return 5;
243 case MON_GOLD_COINS: return 10;
244 case MON_MITHRIL_COINS:
245 case MON_MITHRIL_GOLEM: return 16;
246 case MON_ADAMANT_COINS: return 17;
255 * Hack -- determine if a template is Cloak
257 static bool kind_is_cloak(int k_idx)
259 object_kind *k_ptr = &k_info[k_idx];
261 /* Analyze the item type */
262 if (k_ptr->tval == TV_CLOAK)
267 /* Assume not good */
273 * Hack -- determine if a template is Polearm
275 static bool kind_is_polearm(int k_idx)
277 object_kind *k_ptr = &k_info[k_idx];
279 /* Analyze the item type */
280 if (k_ptr->tval == TV_POLEARM)
285 /* Assume not good */
291 * Hack -- determine if a template is Sword
293 static bool kind_is_sword(int k_idx)
295 object_kind *k_ptr = &k_info[k_idx];
297 /* Analyze the item type */
298 if ((k_ptr->tval == TV_SWORD) && (k_ptr->sval > 2))
303 /* Assume not good */
309 * Hack -- determine if a template is Book
311 static bool kind_is_book(int k_idx)
313 object_kind *k_ptr = &k_info[k_idx];
315 /* Analyze the item type */
316 if ((k_ptr->tval >= TV_LIFE_BOOK) && (k_ptr->tval <= TV_CRUSADE_BOOK))
321 /* Assume not good */
327 * Hack -- determine if a template is Good book
329 static bool kind_is_good_book(int k_idx)
331 object_kind *k_ptr = &k_info[k_idx];
333 /* Analyze the item type */
334 if ((k_ptr->tval >= TV_LIFE_BOOK) && (k_ptr->tval <= TV_CRUSADE_BOOK) && (k_ptr->tval != TV_ARCANE_BOOK) && (k_ptr->sval > 1))
339 /* Assume not good */
345 * Hack -- determine if a template is Armor
347 static bool kind_is_armor(int k_idx)
349 object_kind *k_ptr = &k_info[k_idx];
351 /* Analyze the item type */
352 if (k_ptr->tval == TV_HARD_ARMOR)
357 /* Assume not good */
363 * Hack -- determine if a template is hafted weapon
365 static bool kind_is_hafted(int k_idx)
367 object_kind *k_ptr = &k_info[k_idx];
369 /* Analyze the item type */
370 if (k_ptr->tval == TV_HAFTED)
375 /* Assume not good */
381 * Check for "Quest" completion when a quest monster is killed or charmed.
383 void check_quest_completion(monster_type *m_ptr)
385 int i, j, y, x, ny, nx, i2, j2;
389 bool create_stairs = FALSE;
395 /* Get the location */
400 quest_num = p_ptr->inside_quest;
402 /* Search for an active quest on this dungeon level */
405 for (i = max_quests - 1; i > 0; i--)
407 /* Quest is not active */
408 if (quest[i].status != QUEST_STATUS_TAKEN)
411 /* Quest is not a dungeon quest */
412 if (quest[i].flags & QUEST_FLAG_PRESET)
415 /* Quest is not on this level */
416 if ((quest[i].level != dun_level) &&
417 (quest[i].type != QUEST_TYPE_KILL_ANY_LEVEL))
420 /* Not a "kill monster" quest */
421 if ((quest[i].type == QUEST_TYPE_FIND_ARTIFACT) ||
422 (quest[i].type == QUEST_TYPE_FIND_EXIT))
425 /* Interesting quest */
426 if ((quest[i].type == QUEST_TYPE_KILL_NUMBER) ||
427 (quest[i].type == QUEST_TYPE_KILL_ALL))
430 /* Interesting quest */
431 if (((quest[i].type == QUEST_TYPE_KILL_LEVEL) ||
432 (quest[i].type == QUEST_TYPE_KILL_ANY_LEVEL) ||
433 (quest[i].type == QUEST_TYPE_RANDOM)) &&
434 (quest[i].r_idx == m_ptr->r_idx))
441 /* Handle the current quest */
442 if (quest_num && (quest[quest_num].status == QUEST_STATUS_TAKEN))
447 switch (quest[i].type)
449 case QUEST_TYPE_KILL_NUMBER:
453 if (quest[i].cur_num >= quest[i].num_mon)
455 if (record_fix_quest) do_cmd_write_nikki(NIKKI_FIX_QUEST_C, i, NULL);
456 /* completed quest */
457 quest[i].status = QUEST_STATUS_COMPLETED;
458 quest[i].complev = (byte)p_ptr->lev;
460 if (!(quest[i].flags & QUEST_FLAG_SILENT))
463 msg_print("¥¯¥¨¥¹¥È¤òãÀ®¤·¤¿¡ª");
465 msg_print("You just completed your quest!");
471 quest[i].cur_num = 0;
475 case QUEST_TYPE_KILL_ALL:
479 if (!is_hostile(m_ptr)) break;
481 /* Count all hostile monsters */
482 for (i2 = 0; i2 < cur_wid; ++i2)
483 for (j2 = 0; j2 < cur_hgt; j2++)
484 if (cave[j2][i2].m_idx > 0)
485 if (is_hostile(&m_list[cave[j2][i2].m_idx]))
488 if ((number_mon - 1) == 0)
490 if (record_fix_quest) do_cmd_write_nikki(NIKKI_FIX_QUEST_C, i, NULL);
492 if (quest[i].flags & QUEST_FLAG_SILENT)
494 quest[i].status = QUEST_STATUS_FINISHED;
498 quest[i].status = QUEST_STATUS_COMPLETED;
499 quest[i].complev = (byte)p_ptr->lev;
501 msg_print("¥¯¥¨¥¹¥È¤òãÀ®¤·¤¿¡ª");
503 msg_print("You just completed your quest!");
511 case QUEST_TYPE_KILL_LEVEL:
512 case QUEST_TYPE_RANDOM:
514 /* Only count valid monsters */
515 if (quest[i].r_idx != m_ptr->r_idx)
520 if (quest[i].cur_num >= quest[i].max_num)
522 if (record_fix_quest && (quest[i].type == QUEST_TYPE_KILL_LEVEL)) do_cmd_write_nikki(NIKKI_FIX_QUEST_C, i, NULL);
523 if (record_rand_quest && (quest[i].type == QUEST_TYPE_RANDOM)) do_cmd_write_nikki(NIKKI_RAND_QUEST_C, i, NULL);
524 /* completed quest */
525 quest[i].status = QUEST_STATUS_COMPLETED;
526 quest[i].complev = (byte)p_ptr->lev;
527 if (!(quest[i].flags & QUEST_FLAG_PRESET))
529 create_stairs = TRUE;
530 p_ptr->inside_quest = 0;
533 if (!(quest[i].flags & QUEST_FLAG_SILENT))
536 msg_print("¥¯¥¨¥¹¥È¤òãÀ®¤·¤¿¡ª");
538 msg_print("You just completed your quest!");
544 /* Finish the two main quests without rewarding */
545 if ((i == QUEST_OBERON) || (i == QUEST_SERPENT))
547 quest[i].status = QUEST_STATUS_FINISHED;
550 if (quest[i].type == QUEST_TYPE_RANDOM)
553 quest[i].status = QUEST_STATUS_FINISHED;
558 case QUEST_TYPE_KILL_ANY_LEVEL:
561 if (quest[i].cur_num >= quest[i].max_num)
563 if (record_fix_quest) do_cmd_write_nikki(NIKKI_FIX_QUEST_C, i, NULL);
564 /* completed quest */
565 quest[i].status = QUEST_STATUS_COMPLETED;
566 quest[i].complev = (byte)p_ptr->lev;
568 if (!(quest[i].flags & QUEST_FLAG_SILENT))
571 msg_print("¥¯¥¨¥¹¥È¤òãÀ®¤·¤¿¡ª");
573 msg_print("You just completed your quest!");
578 quest[i].cur_num = 0;
585 /* Create a magical staircase */
589 while (cave_perma_bold(y, x) || cave[y][x].o_idx || (cave[y][x].info & CAVE_OBJECT) )
591 /* Pick a location */
592 scatter(&ny, &nx, y, x, 1, 0);
598 /* Explain the staircase */
600 msg_print("ËâË¡¤Î³¬Ãʤ¬¸½¤ì¤¿...");
602 msg_print("A magical staircase appears...");
606 /* Create stairs down */
607 cave_set_feat(y, x, FEAT_MORE);
609 /* Remember to update everything */
610 p_ptr->update |= (PU_FLOW);
618 for (j = 0; j < (dun_level / 15)+1; j++)
620 /* Get local object */
623 /* Wipe the object */
626 /* Make a great object */
627 make_object(q_ptr, AM_GOOD | AM_GREAT);
629 /* Drop it in the dungeon */
630 (void)drop_near(q_ptr, -1, y, x);
637 * Return monster death string
639 cptr extract_note_dies(monster_race *r_ptr)
641 /* Some monsters get "destroyed" */
642 if (!monster_living(r_ptr))
646 for (i = 0; i < 4; i++)
648 if (r_ptr->blow[i].method == RBM_EXPLODE)
651 return "¤ÏÇúȯ¤·¤ÆÊ´¡¹¤Ë¤Ê¤Ã¤¿¡£";
653 return " explodes into tiny shreds.";
661 return " is destroyed.";
665 /* Assume a default death */
675 * Handle the "death" of a monster.
677 * Disperse treasures centered at the monster location based on the
678 * various flags contained in the monster flags fields.
680 * Check for "Quest" completion when a quest monster is killed.
682 * Note that only the player can induce "monster_death()" on Uniques.
683 * Thus (for now) all Quest monsters should be Uniques.
685 * Note that monsters can now carry objects, and when a monster dies,
686 * it drops all of its objects, which may disappear in crowded rooms.
688 void monster_death(int m_idx, bool drop_item)
697 monster_type *m_ptr = &m_list[m_idx];
699 monster_race *r_ptr = &r_info[m_ptr->r_idx];
701 bool visible = (m_ptr->ml || (r_ptr->flags1 & RF1_UNIQUE));
705 bool do_gold = (!(r_ptr->flags1 & RF1_ONLY_ITEM));
706 bool do_item = (!(r_ptr->flags1 & RF1_ONLY_GOLD));
707 bool cloned = (m_ptr->smart & SM_CLONED) ? TRUE : FALSE;
708 int force_coin = get_coin_type(m_ptr->r_idx);
713 bool drop_chosen_item = drop_item && !cloned && !p_ptr->inside_arena
714 && !p_ptr->inside_battle && !is_pet(m_ptr);
716 /* The caster is dead? */
717 if (world_monster && world_monster == m_idx) world_monster = 0;
719 /* Notice changes in view */
720 if (r_ptr->flags7 & (RF7_LITE_MASK | RF7_DARK_MASK))
722 /* Update some things */
723 p_ptr->update |= (PU_MON_LITE);
726 /* Get the location */
730 if (record_named_pet && is_pet(m_ptr) && m_ptr->nickname)
734 monster_desc(m_name, m_ptr, MD_INDEF_VISIBLE);
735 do_cmd_write_nikki(NIKKI_NAMED_PET, 3, m_name);
738 /* Let monsters explode! */
739 for (i = 0; i < 4; i++)
741 if (r_ptr->blow[i].method == RBM_EXPLODE)
743 int flg = PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL;
744 int typ = mbe_info[r_ptr->blow[i].effect].explode_type;
745 int d_dice = r_ptr->blow[i].d_dice;
746 int d_side = r_ptr->blow[i].d_side;
747 int damage = damroll(d_dice, d_side);
749 project(m_idx, 3, y, x, damage, typ, flg, -1);
754 if (m_ptr->mflag2 & MFLAG2_CHAMELEON)
756 choose_new_monster(m_idx, TRUE, MON_CHAMELEON);
757 r_ptr = &r_info[m_ptr->r_idx];
760 /* Check for quest completion */
761 check_quest_completion(m_ptr);
763 /* Handle the possibility of player vanquishing arena combatant -KMW- */
764 if (p_ptr->inside_arena && !is_pet(m_ptr))
766 p_ptr->exit_bldg = TRUE;
768 if (p_ptr->arena_number > MAX_ARENA_MONS)
771 msg_print("ÁÇÀ²¤é¤·¤¤¡ª·¯¤³¤½¿¿¤Î¾¡Íø¼Ô¤À¡£");
773 msg_print("You are a Genuine Champion!");
779 msg_print("¾¡Íø¡ª¥Á¥ã¥ó¥Ô¥ª¥ó¤Ø¤ÎÆ»¤ò¿Ê¤ó¤Ç¤¤¤ë¡£");
781 msg_print("Victorious! You're on your way to becoming Champion.");
785 if (arena_info[p_ptr->arena_number].tval)
787 /* Get local object */
790 /* Prepare to make a prize */
791 object_prep(q_ptr, lookup_kind(arena_info[p_ptr->arena_number].tval, arena_info[p_ptr->arena_number].sval));
793 apply_magic(q_ptr, object_level, AM_NO_FIXED_ART);
795 /* Drop it in the dungeon */
796 (void)drop_near(q_ptr, -1, y, x);
799 if (p_ptr->arena_number > MAX_ARENA_MONS) p_ptr->arena_number++;
800 p_ptr->arena_number++;
805 /* Extract monster name */
806 monster_desc(m_name, m_ptr, MD_IGNORE_HALLU | MD_ASSUME_VISIBLE | MD_INDEF_VISIBLE);
808 do_cmd_write_nikki(NIKKI_ARENA, p_ptr->arena_number, m_name);
812 if (m_idx == p_ptr->riding)
814 if (rakuba(-1, FALSE))
817 msg_print("ÃÏÌ̤ËÍî¤È¤µ¤ì¤¿¡£");
819 msg_print("You have fallen from your riding pet.");
824 /* Drop a dead corpse? */
825 if (one_in_(r_ptr->flags1 & RF1_UNIQUE ? 1 : 4) &&
826 ((r_ptr->flags9 & RF9_DROP_CORPSE) ||
827 (r_ptr->flags9 & RF9_DROP_SKELETON)) &&
828 !(p_ptr->inside_arena || p_ptr->inside_battle || cloned || ((m_ptr->r_idx == today_mon) && is_pet(m_ptr))))
830 /* Assume skeleton */
834 * We cannot drop a skeleton? Note, if we are in this check,
835 * we *know* we can drop at least a corpse or a skeleton
837 if (!(r_ptr->flags9 & RF9_DROP_SKELETON))
839 else if ((r_ptr->flags9 & RF9_DROP_CORPSE) && (r_ptr->flags1 && RF1_UNIQUE))
842 /* Else, a corpse is more likely unless we did a "lot" of damage */
843 else if (r_ptr->flags9 & RF9_DROP_CORPSE)
845 /* Lots of damage in one blow */
846 if ((0 - ((m_ptr->maxhp) / 4)) > m_ptr->hp)
848 if (one_in_(5)) corpse = TRUE;
852 if (!one_in_(5)) corpse = TRUE;
856 /* Get local object */
859 /* Prepare to make an object */
860 object_prep(q_ptr, lookup_kind(TV_CORPSE, (corpse ? SV_CORPSE : SV_SKELETON)));
862 apply_magic(q_ptr, object_level, AM_NO_FIXED_ART);
864 q_ptr->pval = m_ptr->r_idx;
866 /* Drop it in the dungeon */
867 (void)drop_near(q_ptr, -1, y, x);
870 /* Drop objects being carried */
871 monster_drop_carried_objects(m_ptr);
873 if (r_ptr->flags1 & RF1_DROP_GOOD) mo_mode |= AM_GOOD;
874 if (r_ptr->flags1 & RF1_DROP_GREAT) mo_mode |= AM_GREAT;
876 switch (m_ptr->r_idx)
878 case MON_PINK_HORROR:
879 /* Pink horrors are replaced with 2 Blue horrors */
880 if (!(p_ptr->inside_arena || p_ptr->inside_battle))
884 for (i = 0; i < 2; i++)
887 bool pet = is_pet(m_ptr);
890 if (pet) mode |= PM_FORCE_PET;
892 if (summon_specific((pet ? -1 : m_idx), wy, wx, 100, SUMMON_BLUE_HORROR, mode))
894 if (player_can_see_bold(wy, wx))
901 msg_print("¥Ô¥ó¥¯¡¦¥Û¥é¡¼¤ÏʬÎö¤·¤¿¡ª");
903 msg_print("The Pink horror divides!");
908 case MON_BLOODLETTER:
909 /* Bloodletters of Khorne may drop a blade of chaos */
910 if (drop_chosen_item && (randint1(100) < 15))
912 /* Get local object */
915 /* Prepare to make a Blade of Chaos */
916 object_prep(q_ptr, lookup_kind(TV_SWORD, SV_BLADE_OF_CHAOS));
918 apply_magic(q_ptr, object_level, AM_NO_FIXED_ART | mo_mode);
920 /* Drop it in the dungeon */
921 (void)drop_near(q_ptr, -1, y, x);
926 if (drop_chosen_item && (dun_level > 9))
928 /* Get local object */
931 /* Wipe the object */
934 /* Activate restriction */
935 if ((dun_level > 49) && one_in_(5))
936 get_obj_num_hook = kind_is_good_book;
938 get_obj_num_hook = kind_is_book;
941 make_object(q_ptr, mo_mode);
943 /* Drop it in the dungeon */
944 (void)drop_near(q_ptr, -1, y, x);
950 * Mega^3-hack: killing a 'Warrior of the Dawn' is likely to
951 * spawn another in the fallen one's place!
953 if (!p_ptr->inside_arena && !p_ptr->inside_battle)
959 bool pet = is_pet(m_ptr);
963 scatter(&wy, &wx, y, x, 20, 0);
965 while (!(in_bounds(wy, wx) && cave_empty_bold2(wy, wx)) && --attempts);
970 if (pet) mode |= PM_FORCE_PET;
972 if (summon_specific((pet ? -1 : m_idx), wy, wx, 100, SUMMON_DAWN, mode))
974 if (player_can_see_bold(wy, wx))
976 msg_print("¿·¤¿¤ÊÀï»Î¤¬¸½¤ì¤¿¡ª");
978 msg_print("A new warrior steps forth!");
988 /* One more ultra-hack: An Unmaker goes out with a big bang! */
990 int flg = PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL;
991 (void)project(m_idx, 6, y, x, 100, GF_CHAOS, flg, -1);
995 case MON_UNICORN_ORD:
998 /* Reward for "lazy" player */
999 if (p_ptr->pseikaku == SEIKAKU_NAMAKE)
1003 if (!drop_chosen_item) break;
1007 switch (randint0(3))
1010 a_idx = ART_NAMAKE_HAMMER;
1013 a_idx = ART_NAMAKE_BOW;
1016 a_idx = ART_NAMAKE_ARMOR;
1020 while (a_info[a_idx].cur_num);
1022 if (a_info[a_idx].cur_num == 0)
1024 /* Create the artifact */
1025 create_named_art(a_idx, y, x);
1026 a_info[a_idx].cur_num = 1;
1032 if (!drop_chosen_item) break;
1034 /* Get local object */
1037 /* Mega-Hack -- Prepare to make "Grond" */
1038 object_prep(q_ptr, lookup_kind(TV_HAFTED, SV_GROND));
1040 /* Mega-Hack -- Mark this item as "Grond" */
1041 q_ptr->name1 = ART_GROND;
1043 /* Mega-Hack -- Actually create "Grond" */
1044 apply_magic(q_ptr, -1, AM_GOOD | AM_GREAT);
1046 /* Drop it in the dungeon */
1047 (void)drop_near(q_ptr, -1, y, x);
1049 /* Get local object */
1052 /* Mega-Hack -- Prepare to make "Chaos" */
1053 object_prep(q_ptr, lookup_kind(TV_CROWN, SV_CHAOS));
1055 /* Mega-Hack -- Mark this item as "Chaos" */
1056 q_ptr->name1 = ART_CHAOS;
1058 /* Mega-Hack -- Actually create "Chaos" */
1059 apply_magic(q_ptr, -1, AM_GOOD | AM_GREAT);
1061 /* Drop it in the dungeon */
1062 (void)drop_near(q_ptr, -1, y, x);
1065 case MON_B_DEATH_SWORD:
1066 if (drop_chosen_item)
1068 /* Get local object */
1071 /* Prepare to make a broken sword */
1072 object_prep(q_ptr, lookup_kind(TV_SWORD, randint1(2)));
1074 /* Drop it in the dungeon */
1075 (void)drop_near(q_ptr, -1, y, x);
1081 if (drop_chosen_item && ((m_ptr->r_idx == MON_A_GOLD) ||
1082 ((m_ptr->r_idx == MON_A_SILVER) && (r_ptr->r_akills % 5 == 0))))
1084 /* Get local object */
1087 /* Prepare to make a Can of Toys */
1088 object_prep(q_ptr, lookup_kind(TV_CHEST, SV_CHEST_KANDUME));
1090 apply_magic(q_ptr, object_level, AM_NO_FIXED_ART);
1092 /* Drop it in the dungeon */
1093 (void)drop_near(q_ptr, -1, y, x);
1099 int flg = PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL;
1100 (void)project(m_idx, 3, y, x, damroll(20, 10), GF_FIRE, flg, -1);
1105 if (!drop_chosen_item) break;
1107 switch (r_ptr->d_char)
1112 /* Get local object */
1115 /* Wipe the object */
1118 /* Activate restriction */
1119 get_obj_num_hook = kind_is_cloak;
1122 make_object(q_ptr, mo_mode);
1124 /* Drop it in the dungeon */
1125 (void)drop_near(q_ptr, -1, y, x);
1132 /* Get local object */
1135 /* Wipe the object */
1138 /* Activate restriction */
1139 get_obj_num_hook = kind_is_polearm;
1141 /* Make a poleweapon */
1142 make_object(q_ptr, mo_mode);
1144 /* Drop it in the dungeon */
1145 (void)drop_near(q_ptr, -1, y, x);
1152 /* Get local object */
1155 /* Wipe the object */
1158 /* Activate restriction */
1159 get_obj_num_hook = kind_is_armor;
1161 /* Make a hard armor */
1162 make_object(q_ptr, mo_mode);
1164 /* Drop it in the dungeon */
1165 (void)drop_near(q_ptr, -1, y, x);
1172 /* Get local object */
1175 /* Wipe the object */
1178 /* Activate restriction */
1179 get_obj_num_hook = kind_is_hafted;
1181 /* Make a hafted weapon */
1182 make_object(q_ptr, mo_mode);
1184 /* Drop it in the dungeon */
1185 (void)drop_near(q_ptr, -1, y, x);
1190 if (m_ptr->r_idx != MON_STORMBRINGER)
1192 /* Get local object */
1195 /* Wipe the object */
1198 /* Activate restriction */
1199 get_obj_num_hook = kind_is_sword;
1202 make_object(q_ptr, mo_mode);
1204 /* Drop it in the dungeon */
1205 (void)drop_near(q_ptr, -1, y, x);
1212 /* Mega-Hack -- drop fixed items */
1213 if (drop_chosen_item)
1218 switch (m_ptr->r_idx)
1238 case MON_STORMBRINGER:
1239 a_idx = ART_STORMBRINGER;
1244 a_idx = ART_CRIMSON;
1254 a_idx = ART_KUSANAGI;
1284 a_idx = ART_WEREWINDLE;
1292 a_idx = ART_GRAYSWANDIR;
1303 a_idx = ART_TWILIGHT;
1308 a_idx = ART_ELENDIL;
1323 a_idx = ART_DESTINY;
1328 a_idx = ART_ZANTETSU;
1343 a_idx = ART_WINBLOWS;
1347 case MON_LUNGORTHIN:
1352 case MON_JACK_SHADOWS:
1358 a_idx = ART_STONEMASK;
1363 a_idx = ART_SOULCRUSH;
1368 a_idx = ART_EXCALIBUR_J;
1373 a_idx = ART_SHUTEN_DOJI;
1378 a_idx = ART_GOTHMOG;
1388 if ((a_idx > 0) && ((randint0(100) < chance) || p_ptr->wizard))
1390 if (a_info[a_idx].cur_num == 0)
1392 /* Create the artifact */
1393 create_named_art(a_idx, y, x);
1394 a_info[a_idx].cur_num = 1;
1398 if ((r_ptr->flags7 & RF7_GUARDIAN) && (d_info[dungeon_type].final_guardian == m_ptr->r_idx))
1400 int k_idx = d_info[dungeon_type].final_object ? d_info[dungeon_type].final_object
1401 : lookup_kind(TV_SCROLL, SV_SCROLL_ACQUIREMENT);
1403 if (d_info[dungeon_type].final_artifact)
1405 int a_idx = d_info[dungeon_type].final_artifact;
1406 if (!a_info[a_idx].cur_num)
1408 /* Create the artifact */
1409 create_named_art(a_idx, y, x);
1410 a_info[a_idx].cur_num = 1;
1412 /* Prevent rewarding both artifact and "default" object */
1413 if (!d_info[dungeon_type].final_object) k_idx = 0;
1419 /* Get local object */
1422 /* Prepare to make a reward */
1423 object_prep(q_ptr, k_idx);
1425 apply_magic(q_ptr, object_level, AM_NO_FIXED_ART | AM_GOOD);
1427 /* Drop it in the dungeon */
1428 (void)drop_near(q_ptr, -1, y, x);
1431 msg_format("¤¢¤Ê¤¿¤Ï%s¤òÀ©ÇƤ·¤¿¡ª",d_name+d_info[dungeon_type].name);
1433 msg_format("You have conquered %s!",d_name+d_info[dungeon_type].name);
1438 /* Determine how much we can drop */
1439 if ((r_ptr->flags1 & RF1_DROP_60) && (randint0(100) < 60)) number++;
1440 if ((r_ptr->flags1 & RF1_DROP_90) && (randint0(100) < 90)) number++;
1441 if (r_ptr->flags1 & RF1_DROP_1D2) number += damroll(1, 2);
1442 if (r_ptr->flags1 & RF1_DROP_2D2) number += damroll(2, 2);
1443 if (r_ptr->flags1 & RF1_DROP_3D2) number += damroll(3, 2);
1444 if (r_ptr->flags1 & RF1_DROP_4D2) number += damroll(4, 2);
1446 if (cloned && !(r_ptr->flags1 & RF1_UNIQUE))
1447 number = 0; /* Clones drop no stuff unless Cloning Pits */
1449 if (is_pet(m_ptr) || p_ptr->inside_battle || p_ptr->inside_arena)
1450 number = 0; /* Pets drop no stuff */
1451 if (!drop_item && (r_ptr->d_char != '$')) number = 0;
1453 /* Hack -- handle creeping coins */
1454 coin_type = force_coin;
1456 /* Average dungeon and monster levels */
1457 object_level = (dun_level + r_ptr->level) / 2;
1459 /* Drop some objects */
1460 for (j = 0; j < number; j++)
1462 /* Get local object */
1465 /* Wipe the object */
1469 if (do_gold && (!do_item || (randint0(100) < 50)))
1471 /* Make some gold */
1472 if (!make_gold(q_ptr)) continue;
1481 /* Make an object */
1482 if (!make_object(q_ptr, mo_mode)) continue;
1488 /* Drop it in the dungeon */
1489 (void)drop_near(q_ptr, -1, y, x);
1492 /* Reset the object level */
1493 object_level = base_level;
1495 /* Reset "coin" type */
1499 /* Take note of any dropped treasure */
1500 if (visible && (dump_item || dump_gold))
1502 /* Take notes on treasure */
1503 lore_treasure(m_idx, dump_item, dump_gold);
1506 /* Only process "Quest Monsters" */
1507 if (!(r_ptr->flags1 & RF1_QUESTOR)) return;
1508 if (p_ptr->inside_battle) return;
1511 if ((m_ptr->r_idx == MON_SERPENT) && !cloned)
1514 p_ptr->total_winner = TRUE;
1516 /* Redraw the "title" */
1517 p_ptr->redraw |= (PR_TITLE);
1520 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, "¸«»ö¤ËÊѶòÈÚÅܤξ¡Íø¼Ô¤È¤Ê¤Ã¤¿¡ª");
1522 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, "become *WINNER* of Hengband finely!");
1525 if ((p_ptr->pclass == CLASS_CHAOS_WARRIOR) || (p_ptr->muta2 & MUT2_CHAOS_GIFT))
1528 msg_format("%s¤«¤é¤ÎÀ¼¤¬¶Á¤¤¤¿¡£", chaos_patrons[p_ptr->chaos_patron]);
1529 msg_print("¡Ø¤è¤¯¤ä¤Ã¤¿¡¢ÄêÌ¿¤Î¼Ô¤è¡ª¡Ù");
1531 msg_format("The voice of %s booms out:", chaos_patrons[p_ptr->chaos_patron]);
1532 msg_print("'Thou art donst well, mortal!'");
1536 /* Congratulations */
1538 msg_print("*** ¤ª¤á¤Ç¤È¤¦ ***");
1540 msg_print("*** CONGRATULATIONS ***");
1544 msg_print("¤¢¤Ê¤¿¤Ï¥²¡¼¥à¤ò¥³¥ó¥×¥ê¡¼¥È¤·¤Þ¤·¤¿¡£");
1546 msg_print("You have won the game!");
1550 msg_print("½àÈ÷¤¬À°¤Ã¤¿¤é°úÂà(¼«»¦¥³¥Þ¥ó¥É)¤·¤Æ¤â·ë¹½¤Ç¤¹¡£");
1552 msg_print("You may retire (commit suicide) when you are ready.");
1558 * Modify the physical damage done to the monster.
1559 * (for example when it's invulnerable or shielded)
1561 * ToDo: Accept a damage-type to calculate the modified damage from
1562 * things like fire, frost, lightning, poison, ... attacks.
1564 * "type" is not yet used and should be 0.
1566 int mon_damage_mod(monster_type *m_ptr, int dam, bool is_psy_spear)
1568 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1570 if ((r_ptr->flagsr & RFR_RES_ALL) && dam > 0)
1573 if ((dam == 0) && one_in_(3)) dam = 1;
1576 if (MON_INVULNER(m_ptr))
1580 if (!p_ptr->blind && is_seen(m_ptr))
1583 msg_print("¥Ð¥ê¥¢¤òÀÚ¤êÎö¤¤¤¿¡ª");
1585 msg_print("The barrier is penetrated!");
1589 else if (!one_in_(PENETRATE_INVULNERABILITY))
1599 * Calculate experience point to be get
1601 * Even the 64 bit operation is not big enough to avoid overflaw
1602 * unless we carefully choose orders of multiplication and division.
1604 * Get the coefficient first, and multiply (potentially huge) base
1605 * experience point of a monster later.
1607 static void get_exp_from_mon(int dam, monster_type *m_ptr)
1609 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1616 if (!m_ptr->r_idx) return;
1617 if (is_pet(m_ptr) || p_ptr->inside_battle) return;
1620 * - Ratio of monster's level to player's level effects
1621 * - Varying speed effects
1622 * - Get a fraction in proportion of damage point
1624 new_exp = r_ptr->level * SPEED_TO_ENERGY(m_ptr->mspeed) * dam;
1627 div_l = (p_ptr->max_plv+2) * SPEED_TO_ENERGY(r_ptr->speed);
1629 /* Use (average maxhp * 2) as a denominator */
1630 if (!(r_ptr->flags1 & RF1_FORCE_MAXHP))
1631 s64b_mul(&div_h, &div_l, 0, r_ptr->hdice * (r_ptr->hside + 1));
1633 s64b_mul(&div_h, &div_l, 0, r_ptr->hdice * r_ptr->hside * 2);
1635 /* Special penalty in the wilderness */
1636 if (!dun_level && (!(r_ptr->flags8 & RF8_WILD_ONLY) || !(r_ptr->flags1 & RF1_UNIQUE)))
1637 s64b_mul(&div_h, &div_l, 0, 5);
1639 /* Do division first to prevent overflaw */
1640 s64b_div(&new_exp, &new_exp_frac, div_h, div_l);
1642 /* Special penalty for mutiply-monster */
1643 if ((r_ptr->flags2 & RF2_MULTIPLY) || (m_ptr->r_idx == MON_DAWN))
1645 int monnum_penarty = r_ptr->r_akills / 400;
1646 if (monnum_penarty > 8) monnum_penarty = 8;
1648 while (monnum_penarty--)
1651 s64b_RSHIFT(new_exp, new_exp_frac, 2);
1655 /* Finally multiply base experience point of the monster */
1656 s64b_mul(&new_exp, &new_exp_frac, 0, r_ptr->mexp);
1658 /* Gain experience */
1659 gain_exp_64(new_exp, new_exp_frac);
1664 * Decreases monsters hit points, handling monster death.
1666 * We return TRUE if the monster has been killed (and deleted).
1668 * We announce monster death (using an optional "death message"
1669 * if given, and a otherwise a generic killed/destroyed message).
1671 * Only "physical attacks" can induce the "You have slain" message.
1672 * Missile and Spell attacks will induce the "dies" message, or
1673 * various "specialized" messages. Note that "You have destroyed"
1674 * and "is destroyed" are synonyms for "You have slain" and "dies".
1676 * Hack -- unseen monsters yield "You have killed it." message.
1678 * Added fear (DGK) and check whether to print fear messages -CWS
1680 * Made name, sex, and capitalization generic -BEN-
1682 * As always, the "ghost" processing is a total hack.
1684 * Hack -- we "delay" fear messages by passing around a "fear" flag.
1686 * XXX XXX XXX Consider decreasing monster experience over time, say,
1687 * by using "(m_exp * m_lev * (m_lev)) / (p_lev * (m_lev + n_killed))"
1688 * instead of simply "(m_exp * m_lev) / (p_lev)", to make the first
1689 * monster worth more than subsequent monsters. This would also need
1690 * to induce changes in the monster recall code.
1692 bool mon_take_hit(int m_idx, int dam, bool *fear, cptr note)
1694 monster_type *m_ptr = &m_list[m_idx];
1695 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1697 monster_type exp_mon;
1699 /* Innocent until proven otherwise */
1700 bool innocent = TRUE, thief = FALSE;
1704 COPY(&exp_mon, m_ptr, monster_type);
1705 if (!(r_ptr->flags7 & RF7_KILL_EXP))
1707 expdam = (m_ptr->hp > dam) ? dam : m_ptr->hp;
1708 if (r_ptr->flags6 & RF6_HEAL) expdam = (expdam+1) * 2 / 3;
1710 get_exp_from_mon(expdam, &exp_mon);
1713 /* Redraw (later) if needed */
1714 if (p_ptr->health_who == m_idx) p_ptr->redraw |= (PR_HEALTH);
1715 if (p_ptr->riding == m_idx) p_ptr->redraw |= (PR_UHEALTH);
1718 (void)set_monster_csleep(m_idx, 0);
1720 /* Hack - Cancel any special player stealth magics. -LM- */
1721 if (p_ptr->special_defense & NINJA_S_STEALTH)
1723 set_superstealth(FALSE);
1729 /* It is dead now */
1734 if (r_info[m_ptr->r_idx].flags7 & RF7_TANUKI)
1736 /* You might have unmasked Tanuki first time */
1737 r_ptr = &r_info[m_ptr->r_idx];
1738 m_ptr->ap_r_idx = m_ptr->r_idx;
1739 if (r_ptr->r_sights < MAX_SHORT) r_ptr->r_sights++;
1742 if (m_ptr->mflag2 & MFLAG2_CHAMELEON)
1744 /* You might have unmasked Chameleon first time */
1745 r_ptr = real_r_ptr(m_ptr);
1746 if (r_ptr->r_sights < MAX_SHORT) r_ptr->r_sights++;
1749 if (!(m_ptr->smart & SM_CLONED))
1751 /* When the player kills a Unique, it stays dead */
1752 if (r_ptr->flags1 & RF1_UNIQUE)
1756 /* Mega-Hack -- Banor & Lupart */
1757 if ((m_ptr->r_idx == MON_BANOR) || (m_ptr->r_idx == MON_LUPART))
1759 r_info[MON_BANORLUPART].max_num = 0;
1760 r_info[MON_BANORLUPART].r_pkills++;
1761 r_info[MON_BANORLUPART].r_akills++;
1762 if (r_info[MON_BANORLUPART].r_tkills < MAX_SHORT) r_info[MON_BANORLUPART].r_tkills++;
1764 else if (m_ptr->r_idx == MON_BANORLUPART)
1766 r_info[MON_BANOR].max_num = 0;
1767 r_info[MON_BANOR].r_pkills++;
1768 r_info[MON_BANOR].r_akills++;
1769 if (r_info[MON_BANOR].r_tkills < MAX_SHORT) r_info[MON_BANOR].r_tkills++;
1770 r_info[MON_LUPART].max_num = 0;
1771 r_info[MON_LUPART].r_pkills++;
1772 r_info[MON_LUPART].r_akills++;
1773 if (r_info[MON_LUPART].r_tkills < MAX_SHORT) r_info[MON_LUPART].r_tkills++;
1777 /* When the player kills a Nazgul, it stays dead */
1778 else if (r_ptr->flags7 & RF7_NAZGUL) r_ptr->max_num--;
1781 /* Count all monsters killed */
1782 if (r_ptr->r_akills < MAX_SHORT) r_ptr->r_akills++;
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_akills > 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 (MON_MONFEAR(m_ptr) && (dam > 0))
2100 if (set_monster_monfear(m_idx, MON_MONFEAR(m_ptr) - randint1(dam)))
2107 /* Sometimes a monster gets scared by damage */
2108 if (!MON_MONFEAR(m_ptr) && !(r_ptr->flags3 & (RF3_NO_FEAR)))
2110 /* Percentage of fully healthy */
2111 int percentage = (100L * m_ptr->hp) / m_ptr->maxhp;
2114 * Run (sometimes) if at 10% or less of max hit points,
2115 * or (usually) when hit for half its current hit points
2117 if ((randint1(10) >= percentage) ||
2118 ((dam >= m_ptr->hp) && (randint0(100) < 80)))
2120 /* Hack -- note fear */
2123 /* XXX XXX XXX Hack -- Add some timed fear */
2124 (void)set_monster_monfear(m_idx, (randint1(10) +
2125 (((dam >= m_ptr->hp) && (percentage > 7)) ?
2126 20 : ((11 - percentage) * 5))));
2133 if (p_ptr->riding && (p_ptr->riding == m_idx) && (dam > 0))
2137 /* Extract monster name */
2138 monster_desc(m_name, m_ptr, 0);
2140 if (m_ptr->hp > m_ptr->maxhp/3) dam = (dam + 1) / 2;
2141 if (rakuba((dam > 200) ? 200 : dam, FALSE))
2144 msg_format("%^s¤Ë¿¶¤êÍî¤È¤µ¤ì¤¿¡ª", m_name);
2146 msg_format("%^s has thrown you off!", m_name);
2158 * Get term size and calculate screen size
2160 void get_screen_size(int *wid_p, int *hgt_p)
2162 Term_get_size(wid_p, hgt_p);
2163 *hgt_p -= ROW_MAP + 2;
2164 *wid_p -= COL_MAP + 2;
2165 if (use_bigtile) *wid_p /= 2;
2170 * Calculates current boundaries
2171 * Called below and from "do_cmd_locate()".
2173 void panel_bounds_center(void)
2178 get_screen_size(&wid, &hgt);
2180 panel_row_max = panel_row_min + hgt - 1;
2181 panel_row_prt = panel_row_min - 1;
2182 panel_col_max = panel_col_min + wid - 1;
2183 panel_col_prt = panel_col_min - 13;
2188 * Map resizing whenever the main term changes size
2190 void resize_map(void)
2192 /* Only if the dungeon exists */
2193 if (!character_dungeon) return;
2195 /* Mega-Hack -- no panel yet */
2199 /* Reset the panels */
2200 panel_row_min = cur_hgt;
2201 panel_col_min = cur_wid;
2206 p_ptr->update |= (PU_TORCH | PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
2208 /* Forget lite/view */
2209 p_ptr->update |= (PU_UN_VIEW | PU_UN_LITE);
2211 /* Update lite/view */
2212 p_ptr->update |= (PU_VIEW | PU_LITE | PU_MON_LITE);
2214 /* Update monsters */
2215 p_ptr->update |= (PU_MONSTERS);
2217 /* Redraw everything */
2218 p_ptr->redraw |= (PR_WIPE | PR_BASIC | PR_EXTRA | PR_MAP | PR_EQUIPPY);
2220 /* Hack -- update */
2228 * Place the cursor on the player
2230 if (can_save) move_cursor_relative(py, px);
2237 * Redraw a term when it is resized
2239 void redraw_window(void)
2241 /* Only if the dungeon exists */
2242 if (!character_dungeon) return;
2245 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_SPELL | PW_PLAYER);
2248 p_ptr->window |= (PW_MESSAGE | PW_OVERHEAD | PW_DUNGEON | PW_MONSTER | PW_OBJECT);
2250 /* Hack -- update */
2259 * Handle a request to change the current panel
2261 * Return TRUE if the panel was changed.
2263 * Also used in do_cmd_locate
2265 bool change_panel(int dy, int dx)
2271 get_screen_size(&wid, &hgt);
2273 /* Apply the motion */
2274 y = panel_row_min + dy * hgt / 2;
2275 x = panel_col_min + dx * wid / 2;
2277 /* Verify the row */
2278 if (y > cur_hgt - hgt) y = cur_hgt - hgt;
2281 /* Verify the col */
2282 if (x > cur_wid - wid) x = cur_wid - wid;
2285 /* Handle "changes" */
2286 if ((y != panel_row_min) || (x != panel_col_min))
2288 /* Save the new panel info */
2292 /* Recalculate the boundaries */
2293 panel_bounds_center();
2296 p_ptr->update |= (PU_MONSTERS);
2299 p_ptr->redraw |= (PR_MAP);
2314 * Given an row (y) and col (x), this routine detects when a move
2315 * off the screen has occurred and figures new borders. -RAK-
2317 * "Update" forces a "full update" to take place.
2319 * The map is reprinted if necessary, and "TRUE" is returned.
2321 void verify_panel(void)
2333 get_screen_size(&wid, &hgt);
2335 max_prow_min = cur_hgt - hgt;
2336 max_pcol_min = cur_wid - wid;
2338 /* Bounds checking */
2339 if (max_prow_min < 0) max_prow_min = 0;
2340 if (max_pcol_min < 0) max_pcol_min = 0;
2342 /* Center on player */
2343 if (center_player && (center_running || !running))
2345 /* Center vertically */
2346 prow_min = y - hgt / 2;
2347 if (prow_min < 0) prow_min = 0;
2348 else if (prow_min > max_prow_min) prow_min = max_prow_min;
2350 /* Center horizontally */
2351 pcol_min = x - wid / 2;
2352 if (pcol_min < 0) pcol_min = 0;
2353 else if (pcol_min > max_pcol_min) pcol_min = max_pcol_min;
2357 prow_min = panel_row_min;
2358 pcol_min = panel_col_min;
2360 /* Scroll screen when 2 grids from top/bottom edge */
2361 if (y > panel_row_max - 2)
2363 while (y > prow_min + hgt-1 - 2)
2365 prow_min += (hgt / 2);
2369 if (y < panel_row_min + 2)
2371 while (y < prow_min + 2)
2373 prow_min -= (hgt / 2);
2377 if (prow_min > max_prow_min) prow_min = max_prow_min;
2378 if (prow_min < 0) prow_min = 0;
2380 /* Scroll screen when 4 grids from left/right edge */
2381 if (x > panel_col_max - 4)
2383 while (x > pcol_min + wid-1 - 4)
2385 pcol_min += (wid / 2);
2389 if (x < panel_col_min + 4)
2391 while (x < pcol_min + 4)
2393 pcol_min -= (wid / 2);
2397 if (pcol_min > max_pcol_min) pcol_min = max_pcol_min;
2398 if (pcol_min < 0) pcol_min = 0;
2401 /* Check for "no change" */
2402 if ((prow_min == panel_row_min) && (pcol_min == panel_col_min)) return;
2404 /* Save the new panel info */
2405 panel_row_min = prow_min;
2406 panel_col_min = pcol_min;
2408 /* Hack -- optional disturb on "panel change" */
2409 if (disturb_panel && !center_player) disturb(0, 0);
2411 /* Recalculate the boundaries */
2412 panel_bounds_center();
2415 p_ptr->update |= (PU_MONSTERS);
2418 p_ptr->redraw |= (PR_MAP);
2421 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
2426 * Monster health description
2428 cptr look_mon_desc(monster_type *m_ptr, u32b mode)
2430 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
2437 /* Determine if the monster is "living" */
2438 living = monster_living(ap_r_ptr);
2440 /* Calculate a health "percentage" */
2441 perc = 100L * m_ptr->hp / m_ptr->maxhp;
2443 /* Healthy monsters */
2444 if (m_ptr->hp >= m_ptr->maxhp)
2448 desc = living ? "̵½ý" : "̵¥À¥á¡¼¥¸";
2450 desc = living ? "unhurt" : "undamaged";
2455 else if (perc >= 60)
2458 desc = living ? "·Ú½ý" : "¾®¥À¥á¡¼¥¸";
2460 desc = living ? "somewhat wounded" : "somewhat damaged";
2465 else if (perc >= 25)
2468 desc = living ? "Éé½ý" : "Ãæ¥À¥á¡¼¥¸";
2470 desc = living ? "wounded" : "damaged";
2475 else if (perc >= 10)
2478 desc = living ? "½Å½ý" : "Âç¥À¥á¡¼¥¸";
2480 desc = living ? "badly wounded" : "badly damaged";
2488 desc = living ? "Ⱦ»àȾÀ¸" : "Åݤ줫¤±";
2490 desc = living ? "almost dead" : "almost destroyed";
2495 /* Need attitude information? */
2498 /* Full information is not needed */
2501 else if (is_pet(m_ptr))
2504 attitude = ", ¥Ú¥Ã¥È";
2509 else if (is_friendly(m_ptr))
2512 attitude = ", ͧ¹¥Åª";
2514 attitude = ", friendly";
2527 /* Clone monster? */
2528 if (m_ptr->smart & SM_CLONED)
2537 /* Display monster's level --- idea borrowed from ToME */
2538 if (ap_r_ptr->r_tkills && !(m_ptr->mflag2 & MFLAG2_KAGE))
2541 return format("¥ì¥Ù¥ë%d, %s%s%s", ap_r_ptr->level, desc, attitude, clone);
2543 return format("Level %d, %s%s%s", ap_r_ptr->level, desc, attitude, clone);
2549 return format("¥ì¥Ù¥ë???, %s%s%s", desc, attitude, clone);
2551 return format("Level ???, %s%s%s", desc, attitude, clone);
2559 * Angband sorting algorithm -- quick sort in place
2561 * Note that the details of the data we are sorting is hidden,
2562 * and we rely on the "ang_sort_comp()" and "ang_sort_swap()"
2563 * function hooks to interact with the data, which is given as
2564 * two pointers, and which may have any user-defined form.
2566 void ang_sort_aux(vptr u, vptr v, int p, int q)
2584 while (!(*ang_sort_comp)(u, v, b, z)) b--;
2587 while (!(*ang_sort_comp)(u, v, z, a)) a++;
2589 /* Done partition */
2593 (*ang_sort_swap)(u, v, a, b);
2599 /* Recurse left side */
2600 ang_sort_aux(u, v, p, b);
2602 /* Recurse right side */
2603 ang_sort_aux(u, v, b+1, q);
2608 * Angband sorting algorithm -- quick sort in place
2610 * Note that the details of the data we are sorting is hidden,
2611 * and we rely on the "ang_sort_comp()" and "ang_sort_swap()"
2612 * function hooks to interact with the data, which is given as
2613 * two pointers, and which may have any user-defined form.
2615 void ang_sort(vptr u, vptr v, int n)
2617 /* Sort the array */
2618 ang_sort_aux(u, v, 0, n-1);
2623 /*** Targeting Code ***/
2627 * Determine is a monster makes a reasonable target
2629 * The concept of "targeting" was stolen from "Morgul" (?)
2631 * The player can target any location, or any "target-able" monster.
2633 * Currently, a monster is "target_able" if it is visible, and if
2634 * the player can hit it with a projection, and the player is not
2635 * hallucinating. This allows use of "use closest target" macros.
2637 * Future versions may restrict the ability to target "trappers"
2638 * and "mimics", but the semantics is a little bit weird.
2640 bool target_able(int m_idx)
2642 monster_type *m_ptr = &m_list[m_idx];
2644 /* Monster must be alive */
2645 if (!m_ptr->r_idx) return (FALSE);
2647 /* Hack -- no targeting hallucinations */
2648 if (p_ptr->image) return (FALSE);
2650 /* Monster must be visible */
2651 if (!m_ptr->ml) return (FALSE);
2653 if (p_ptr->riding && (p_ptr->riding == m_idx)) return (TRUE);
2655 /* Monster must be projectable */
2656 if (!projectable(py, px, m_ptr->fy, m_ptr->fx)) return (FALSE);
2658 /* XXX XXX XXX Hack -- Never target trappers */
2659 /* if (CLEAR_ATTR && (CLEAR_CHAR)) return (FALSE); */
2669 * Update (if necessary) and verify (if possible) the target.
2671 * We return TRUE if the target is "okay" and FALSE otherwise.
2673 bool target_okay(void)
2675 /* Accept stationary targets */
2676 if (target_who < 0) return (TRUE);
2678 /* Check moving targets */
2681 /* Accept reasonable targets */
2682 if (target_able(target_who))
2684 monster_type *m_ptr = &m_list[target_who];
2686 /* Acquire monster location */
2687 target_row = m_ptr->fy;
2688 target_col = m_ptr->fx;
2695 /* Assume no target */
2701 * Sorting hook -- comp function -- by "distance to player"
2703 * We use "u" and "v" to point to arrays of "x" and "y" positions,
2704 * and sort the arrays by double-distance to the player.
2706 static bool ang_sort_comp_distance(vptr u, vptr v, int a, int b)
2708 byte *x = (byte*)(u);
2709 byte *y = (byte*)(v);
2713 /* Absolute distance components */
2714 kx = x[a]; kx -= px; kx = ABS(kx);
2715 ky = y[a]; ky -= py; ky = ABS(ky);
2717 /* Approximate Double Distance to the first point */
2718 da = ((kx > ky) ? (kx + kx + ky) : (ky + ky + kx));
2720 /* Absolute distance components */
2721 kx = x[b]; kx -= px; kx = ABS(kx);
2722 ky = y[b]; ky -= py; ky = ABS(ky);
2724 /* Approximate Double Distance to the first point */
2725 db = ((kx > ky) ? (kx + kx + ky) : (ky + ky + kx));
2727 /* Compare the distances */
2733 * Sorting hook -- comp function -- by importance level of grids
2735 * We use "u" and "v" to point to arrays of "x" and "y" positions,
2736 * and sort the arrays by level of monster
2738 static bool ang_sort_comp_importance(vptr u, vptr v, int a, int b)
2740 byte *x = (byte*)(u);
2741 byte *y = (byte*)(v);
2742 cave_type *ca_ptr = &cave[y[a]][x[a]];
2743 cave_type *cb_ptr = &cave[y[b]][x[b]];
2744 monster_type *ma_ptr = &m_list[ca_ptr->m_idx];
2745 monster_type *mb_ptr = &m_list[cb_ptr->m_idx];
2746 monster_race *ap_ra_ptr, *ap_rb_ptr;
2748 /* The player grid */
2749 if (y[a] == py && x[a] == px) return TRUE;
2750 if (y[b] == py && x[b] == px) return FALSE;
2752 /* Extract monster race */
2753 if (ca_ptr->m_idx && ma_ptr->ml) ap_ra_ptr = &r_info[ma_ptr->ap_r_idx];
2754 else ap_ra_ptr = NULL;
2755 if (cb_ptr->m_idx && mb_ptr->ml) ap_rb_ptr = &r_info[mb_ptr->ap_r_idx];
2756 else ap_rb_ptr = NULL;
2758 if (ap_ra_ptr && !ap_rb_ptr) return TRUE;
2759 if (!ap_ra_ptr && ap_rb_ptr) return FALSE;
2761 /* Compare two monsters */
2762 if (ap_ra_ptr && ap_rb_ptr)
2764 /* Unique monsters first */
2765 if ((ap_ra_ptr->flags1 & RF1_UNIQUE) && !(ap_rb_ptr->flags1 & RF1_UNIQUE)) return TRUE;
2766 if (!(ap_ra_ptr->flags1 & RF1_UNIQUE) && (ap_rb_ptr->flags1 & RF1_UNIQUE)) return FALSE;
2768 /* Shadowers first (¤¢¤ä¤·¤¤±Æ) */
2769 if ((ma_ptr->mflag2 & MFLAG2_KAGE) && !(mb_ptr->mflag2 & MFLAG2_KAGE)) return TRUE;
2770 if (!(ma_ptr->mflag2 & MFLAG2_KAGE) && (mb_ptr->mflag2 & MFLAG2_KAGE)) return FALSE;
2772 /* Unknown monsters first */
2773 if (!ap_ra_ptr->r_tkills && ap_rb_ptr->r_tkills) return TRUE;
2774 if (ap_ra_ptr->r_tkills && !ap_rb_ptr->r_tkills) return FALSE;
2776 /* Higher level monsters first (if known) */
2777 if (ap_ra_ptr->r_tkills && ap_rb_ptr->r_tkills)
2779 if (ap_ra_ptr->level > ap_rb_ptr->level) return TRUE;
2780 if (ap_ra_ptr->level < ap_rb_ptr->level) return FALSE;
2783 /* Sort by index if all conditions are same */
2784 if (ma_ptr->ap_r_idx > mb_ptr->ap_r_idx) return TRUE;
2785 if (ma_ptr->ap_r_idx < mb_ptr->ap_r_idx) return FALSE;
2788 /* An object get higher priority */
2789 if (cave[y[a]][x[a]].o_idx && !cave[y[b]][x[b]].o_idx) return TRUE;
2790 if (!cave[y[a]][x[a]].o_idx && cave[y[b]][x[b]].o_idx) return FALSE;
2792 /* Priority from the terrain */
2793 if (f_info[ca_ptr->feat].priority > f_info[cb_ptr->feat].priority) return TRUE;
2794 if (f_info[ca_ptr->feat].priority < f_info[cb_ptr->feat].priority) return FALSE;
2796 /* If all conditions are same, compare distance */
2797 return ang_sort_comp_distance(u, v, a, b);
2802 * Sorting hook -- swap function -- by "distance to player"
2804 * We use "u" and "v" to point to arrays of "x" and "y" positions,
2805 * and sort the arrays by distance to the player.
2807 static void ang_sort_swap_distance(vptr u, vptr v, int a, int b)
2809 byte *x = (byte*)(u);
2810 byte *y = (byte*)(v);
2828 * Hack -- help "select" a location (see below)
2830 static s16b target_pick(int y1, int x1, int dy, int dx)
2834 int x2, y2, x3, y3, x4, y4;
2836 int b_i = -1, b_v = 9999;
2839 /* Scan the locations */
2840 for (i = 0; i < temp_n; i++)
2846 /* Directed distance */
2850 /* Verify quadrant */
2851 if (dx && (x3 * dx <= 0)) continue;
2852 if (dy && (y3 * dy <= 0)) continue;
2854 /* Absolute distance */
2858 /* Verify quadrant */
2859 if (dy && !dx && (x4 > y4)) continue;
2860 if (dx && !dy && (y4 > x4)) continue;
2862 /* Approximate Double Distance */
2863 v = ((x4 > y4) ? (x4 + x4 + y4) : (y4 + y4 + x4));
2865 /* XXX XXX XXX Penalize location */
2868 if ((b_i >= 0) && (v >= b_v)) continue;
2880 * Hack -- determine if a given location is "interesting"
2882 static bool target_set_accept(int y, int x)
2886 s16b this_o_idx, next_o_idx = 0;
2889 if (!(in_bounds(y, x))) return (FALSE);
2891 /* Player grid is always interesting */
2892 if (player_bold(y, x)) return (TRUE);
2895 /* Handle hallucination */
2896 if (p_ptr->image) return (FALSE);
2899 /* Examine the grid */
2900 c_ptr = &cave[y][x];
2902 /* Visible monsters */
2905 monster_type *m_ptr = &m_list[c_ptr->m_idx];
2907 /* Visible monsters */
2908 if (m_ptr->ml) return (TRUE);
2911 /* Scan all objects in the grid */
2912 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
2916 /* Acquire object */
2917 o_ptr = &o_list[this_o_idx];
2919 /* Acquire next object */
2920 next_o_idx = o_ptr->next_o_idx;
2922 /* Memorized object */
2923 if (o_ptr->marked & OM_FOUND) return (TRUE);
2926 /* Interesting memorized features */
2927 if (c_ptr->info & (CAVE_MARK))
2929 /* Notice object features */
2930 if (c_ptr->info & CAVE_OBJECT) return (TRUE);
2932 /* Feature code (applying "mimic" field) */
2933 if (have_flag(f_info[get_feat_mimic(c_ptr)].flags, FF_NOTICE)) return TRUE;
2942 * Prepare the "temp" array for "target_set"
2944 * Return the number of target_able monsters in the set.
2946 static void target_set_prepare(int mode)
2950 /* Reset "temp" array */
2953 /* Scan the current panel */
2954 for (y = panel_row_min; y <= panel_row_max; y++)
2956 for (x = panel_col_min; x <= panel_col_max; x++)
2960 /* Require "interesting" contents */
2961 if (!target_set_accept(y, x)) continue;
2963 c_ptr = &cave[y][x];
2965 /* Require target_able monsters for "TARGET_KILL" */
2966 if ((mode & (TARGET_KILL)) && !target_able(c_ptr->m_idx)) continue;
2968 if ((mode & (TARGET_KILL)) && !target_pet && is_pet(&m_list[c_ptr->m_idx])) continue;
2970 /* Save the location */
2977 /* Set the sort hooks */
2978 if (mode & (TARGET_KILL))
2980 /* Target the nearest monster for shooting */
2981 ang_sort_comp = ang_sort_comp_distance;
2982 ang_sort_swap = ang_sort_swap_distance;
2986 /* Look important grids first in Look command */
2987 ang_sort_comp = ang_sort_comp_importance;
2988 ang_sort_swap = ang_sort_swap_distance;
2991 /* Sort the positions */
2992 ang_sort(temp_x, temp_y, temp_n);
2994 if (p_ptr->riding && target_pet && (temp_n > 1) && (mode & (TARGET_KILL)))
2999 temp_y[0] = temp_y[1];
3002 temp_x[0] = temp_x[1];
3009 * Evaluate number of kill needed to gain level
3011 static void evaluate_monster_exp(char *buf, monster_type *m_ptr)
3013 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
3015 s32b exp_mon, exp_adv;
3016 u32b exp_mon_frac, exp_adv_frac;
3018 if ((p_ptr->lev >= PY_MAX_LEVEL) || (p_ptr->prace == RACE_ANDROID))
3023 else if (!ap_r_ptr->r_tkills || (m_ptr->mflag2 & MFLAG2_KAGE))
3033 /* The monster's experience point (assuming average monster speed) */
3034 exp_mon = ap_r_ptr->mexp * ap_r_ptr->level;
3036 s64b_div(&exp_mon, &exp_mon_frac, 0, (p_ptr->max_plv + 2));
3039 /* Total experience value for next level */
3040 exp_adv = player_exp[p_ptr->lev -1] * p_ptr->expfact;
3042 s64b_div(&exp_adv, &exp_adv_frac, 0, 100);
3044 /* Experience value need to get */
3045 s64b_sub(&exp_adv, &exp_adv_frac, p_ptr->exp, p_ptr->exp_frac);
3048 /* You need to kill at least one monster to get any experience */
3049 s64b_add(&exp_adv, &exp_adv_frac, exp_mon, exp_mon_frac);
3050 s64b_sub(&exp_adv, &exp_adv_frac, 0, 1);
3052 /* Extract number of monsters needed */
3053 s64b_div(&exp_adv, &exp_adv_frac, exp_mon, exp_mon_frac);
3055 /* If 999 or more monsters needed, only display "999". */
3056 num = MIN(999, exp_adv_frac);
3058 /* Display the number */
3059 sprintf(buf,"%03ld", num);
3064 * Examine a grid, return a keypress.
3066 * The "mode" argument contains the "TARGET_LOOK" bit flag, which
3067 * indicates that the "space" key should scan through the contents
3068 * of the grid, instead of simply returning immediately. This lets
3069 * the "look" command get complete information, without making the
3070 * "target" command annoying.
3072 * The "info" argument contains the "commands" which should be shown
3073 * inside the "[xxx]" text. This string must never be empty, or grids
3074 * containing monsters will be displayed with an extra comma.
3076 * Note that if a monster is in the grid, we update both the monster
3077 * recall info and the health bar info to track that monster.
3079 * Eventually, we may allow multiple objects per grid, or objects
3080 * and terrain features in the same grid. XXX XXX XXX
3082 * This function must handle blindness/hallucination.
3084 static int target_set_aux(int y, int x, int mode, cptr info)
3086 cave_type *c_ptr = &cave[y][x];
3087 s16b this_o_idx, next_o_idx = 0;
3088 cptr s1 = "", s2 = "", s3 = "", x_info = "";
3091 feature_type *f_ptr;
3093 char out_val[MAX_NLEN+80];
3095 #ifdef ALLOW_EASY_FLOOR
3096 int floor_list[23], floor_num = 0;
3098 /* Scan all objects in the grid */
3101 floor_num = scan_floor(floor_list, y, x, 0x02);
3113 #endif /* ALLOW_EASY_FLOOR */
3115 /* Hack -- under the player */
3116 if (player_bold(y, x))
3139 /* Hack -- hallucination */
3143 cptr name = "²¿¤«´ñ̯¤Êʪ";
3145 cptr name = "something strange";
3149 /* Display a message */
3151 sprintf(out_val, "%s%s%s%s [%s]", s1, name, s2, s3, info);
3153 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, name, info);
3157 move_cursor_relative(y, x);
3160 /* Stop on everything but "return" */
3161 if ((query != '\r') && (query != '\n')) return query;
3163 /* Repeat forever */
3168 /* Actual monsters */
3169 if (c_ptr->m_idx && m_list[c_ptr->m_idx].ml)
3171 monster_type *m_ptr = &m_list[c_ptr->m_idx];
3172 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
3174 bool recall = FALSE;
3179 /* Get the monster name ("a kobold") */
3180 monster_desc(m_name, m_ptr, MD_INDEF_VISIBLE);
3182 /* Hack -- track this monster race */
3183 monster_race_track(m_ptr->ap_r_idx);
3185 /* Hack -- health bar for this monster */
3186 health_track(c_ptr->m_idx);
3188 /* Hack -- handle stuff */
3202 /* Recall on screen */
3203 screen_roff(m_ptr->ap_r_idx, 0);
3205 /* Hack -- Complete the prompt (again) */
3207 Term_addstr(-1, TERM_WHITE, format(" [r»× %s%s]", x_info, info));
3209 Term_addstr(-1, TERM_WHITE, format(" [r,%s%s]", x_info, info));
3218 /* Normal commands */
3219 if (query != 'r') break;
3224 /* Cleare recall text and repeat */
3230 /* Describe, and prompt for recall */
3231 evaluate_monster_exp(acount, m_ptr);
3234 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);
3236 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);
3242 move_cursor_relative(y, x);
3247 /* Normal commands */
3248 if (query != 'r') break;
3254 /* Always stop at "normal" keys */
3255 if ((query != '\r') && (query != '\n') && (query != ' ') && (query != 'x')) return query;
3257 /* Sometimes stop at "space" key */
3258 if ((query == ' ') && !(mode & (TARGET_LOOK))) return query;
3260 /* Change the intro */
3268 /* Hack -- take account of gender */
3270 if (ap_r_ptr->flags1 & (RF1_FEMALE)) s1 = "Èà½÷¤Ï";
3272 if (ap_r_ptr->flags1 & (RF1_FEMALE)) s1 = "She is ";
3276 else if (ap_r_ptr->flags1 & (RF1_MALE)) s1 = "Èà¤Ï";
3278 else if (ap_r_ptr->flags1 & (RF1_MALE)) s1 = "He is ";
3282 /* Use a preposition */
3291 /* Scan all objects being carried */
3292 for (this_o_idx = m_ptr->hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
3294 char o_name[MAX_NLEN];
3298 /* Acquire object */
3299 o_ptr = &o_list[this_o_idx];
3301 /* Acquire next object */
3302 next_o_idx = o_ptr->next_o_idx;
3304 /* Obtain an object description */
3305 object_desc(o_name, o_ptr, 0);
3307 /* Describe the object */
3309 sprintf(out_val, "%s%s%s%s[%s]", s1, o_name, s2, s3, info);
3311 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, o_name, info);
3315 move_cursor_relative(y, x);
3318 /* Always stop at "normal" keys */
3319 if ((query != '\r') && (query != '\n') && (query != ' ') && (query != 'x')) return query;
3321 /* Sometimes stop at "space" key */
3322 if ((query == ' ') && !(mode & (TARGET_LOOK))) return query;
3324 /* Change the intro */
3328 s2 = "also carrying ";
3332 /* Use a preposition */
3342 #ifdef ALLOW_EASY_FLOOR
3351 char o_name[MAX_NLEN];
3355 /* Acquire object */
3356 o_ptr = &o_list[floor_list[0]];
3358 /* Describe the object */
3359 object_desc(o_name, o_ptr, 0);
3363 sprintf(out_val, "%s%s%s%s[%s]",
3364 s1, o_name, s2, s3, info);
3366 sprintf(out_val, "%s%s%s%s [%s]",
3367 s1, s2, s3, o_name, info);
3371 move_cursor_relative(y, x);
3380 /* Provide one cushion before item listing */
3383 /* Display rough information about items */
3385 sprintf(out_val, "%s %d¸Ä¤Î¥¢¥¤¥Æ¥à%s%s ['x'¤Ç°ìÍ÷, %s]",
3386 s1, floor_num, s2, s3, info);
3388 sprintf(out_val, "%s%s%sa pile of %d items [x,%s]",
3389 s1, s2, s3, floor_num, info);
3393 move_cursor_relative(y, x);
3398 /* No request for listing */
3399 if (query != 'x' && query != ' ') return query;
3403 /** Display list of items **/
3405 /* Continue scrolling list if requested */
3414 (void)show_floor(0, y, x, &min_width);
3418 sprintf(out_val, "%s %d¸Ä¤Î¥¢¥¤¥Æ¥à%s%s [Enter¤Ç¼¡¤Ø, %s]",
3419 s1, floor_num, s2, s3, info);
3421 sprintf(out_val, "%s%s%sa pile of %d items [Enter,%s]",
3422 s1, s2, s3, floor_num, info);
3433 /* Exit unless 'Enter' */
3434 if (query != '\n' && query != '\r')
3439 /* Get the object being moved. */
3440 o_idx = c_ptr->o_idx;
3442 /* Only rotate a pile of two or more objects. */
3443 if (!(o_idx && o_list[o_idx].next_o_idx)) continue;
3445 /* Remove the first object from the list. */
3446 excise_object_idx(o_idx);
3448 /* Find end of the list. */
3450 while (o_list[i].next_o_idx)
3451 i = o_list[i].next_o_idx;
3453 /* Add after the last object. */
3454 o_list[i].next_o_idx = o_idx;
3456 /* Loop and re-display the list */
3462 #endif /* ALLOW_EASY_FLOOR */
3465 /* Scan all objects in the grid */
3466 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
3470 /* Acquire object */
3471 o_ptr = &o_list[this_o_idx];
3473 /* Acquire next object */
3474 next_o_idx = o_ptr->next_o_idx;
3477 if (o_ptr->marked & OM_FOUND)
3479 char o_name[MAX_NLEN];
3484 /* Obtain an object description */
3485 object_desc(o_name, o_ptr, 0);
3487 /* Describe the object */
3489 sprintf(out_val, "%s%s%s%s[%s]", s1, o_name, s2, s3, info);
3491 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, o_name, info);
3495 move_cursor_relative(y, x);
3498 /* Always stop at "normal" keys */
3499 if ((query != '\r') && (query != '\n') && (query != ' ') && (query != 'x')) return query;
3501 /* Sometimes stop at "space" key */
3502 if ((query == ' ') && !(mode & TARGET_LOOK)) return query;
3504 /* Change the intro */
3514 if (o_ptr->number != 1) s1 = "¤½¤ì¤é¤Ï";
3516 if (o_ptr->number != 1) s1 = "They are ";
3532 /* Feature code (applying "mimic" field) */
3533 feat = get_feat_mimic(c_ptr);
3535 /* Require knowledge about grid, or ability to see grid */
3536 if (!(c_ptr->info & CAVE_MARK) && !player_can_see_bold(y, x))
3538 /* Forget feature */
3542 f_ptr = &f_info[feat];
3544 /* Terrain feature if needed */
3545 if (boring || have_flag(f_ptr->flags, FF_REMEMBER))
3549 /* Hack -- special handling for building doors */
3550 if (have_flag(f_ptr->flags, FF_BLDG) && !p_ptr->inside_arena)
3552 name = building[f_ptr->power].name;
3554 else if (have_flag(f_ptr->flags, FF_ENTRANCE))
3557 name = format("%s(%d³¬ÁêÅö)", d_text + d_info[c_ptr->special].text, d_info[c_ptr->special].mindepth);
3559 name = format("%s(level %d)", d_text + d_info[c_ptr->special].text, d_info[c_ptr->special].mindepth);
3562 else if (have_flag(f_ptr->flags, FF_TOWN))
3564 name = town[c_ptr->special].name;
3566 else if (p_ptr->wild_mode && (feat == FEAT_FLOOR))
3576 name = f_name + f_ptr->name;
3582 ((!have_flag(f_ptr->flags, FF_MOVE) && !have_flag(f_ptr->flags, FF_CAN_FLY)) ||
3583 (!have_flag(f_ptr->flags, FF_LOS) && !have_flag(f_ptr->flags, FF_TREE)) ||
3584 have_flag(f_ptr->flags, FF_TOWN)))
3593 /* Hack -- special introduction for store & building doors -KMW- */
3594 if (have_flag(f_ptr->flags, FF_STORE) ||
3595 (have_flag(f_ptr->flags, FF_BLDG) && !p_ptr->inside_arena) ||
3596 have_flag(f_ptr->flags, FF_ENTRANCE))
3605 else if (have_flag(f_ptr->flags, FF_FLOOR) ||
3606 have_flag(f_ptr->flags, FF_TOWN) ||
3607 have_flag(f_ptr->flags, FF_SHALLOW) ||
3608 have_flag(f_ptr->flags, FF_DEEP))
3614 /* Pick proper indefinite article */
3615 s3 = (is_a_vowel(name[0])) ? "an " : "a ";
3619 /* Display a message */
3623 if (c_ptr->mimic) sprintf(f_idx_str, "%d/%d", c_ptr->feat, c_ptr->mimic);
3624 else sprintf(f_idx_str, "%d", c_ptr->feat);
3626 sprintf(out_val, "%s%s%s%s[%s] %x %s %d %d %d (%d,%d)", s1, name, s2, s3, info, c_ptr->info, f_idx_str, c_ptr->dist, c_ptr->cost, c_ptr->when, y, x);
3628 sprintf(out_val, "%s%s%s%s [%s] %x %s %d %d %d (%d,%d)", s1, s2, s3, name, info, c_ptr->info, f_idx_str, c_ptr->dist, c_ptr->cost, c_ptr->when, y, x);
3633 sprintf(out_val, "%s%s%s%s[%s]", s1, name, s2, s3, info);
3635 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, name, info);
3639 move_cursor_relative(y, x);
3642 /* Always stop at "normal" keys */
3643 if ((query != '\r') && (query != '\n') && (query != ' ')) return query;
3646 /* Stop on everything but "return" */
3647 if ((query != '\r') && (query != '\n')) return query;
3649 /* Repeat forever */
3655 * Handle "target" and "look".
3657 * Note that this code can be called from "get_aim_dir()".
3659 * All locations must be on the current panel. Consider the use of
3660 * "panel_bounds()" to allow "off-panel" targets, perhaps by using
3661 * some form of "scrolling" the map around the cursor. XXX XXX XXX
3662 * That is, consider the possibility of "auto-scrolling" the screen
3663 * while the cursor moves around. This may require changes in the
3664 * "update_mon()" code to allow "visibility" even if off panel, and
3665 * may require dynamic recalculation of the "temp" grid set.
3667 * Hack -- targeting/observing an "outer border grid" may induce
3668 * problems, so this is not currently allowed.
3670 * The player can use the direction keys to move among "interesting"
3671 * grids in a heuristic manner, or the "space", "+", and "-" keys to
3672 * move through the "interesting" grids in a sequential manner, or
3673 * can enter "location" mode, and use the direction keys to move one
3674 * grid at a time in any direction. The "t" (set target) command will
3675 * only target a monster (as opposed to a location) if the monster is
3676 * target_able and the "interesting" mode is being used.
3678 * The current grid is described using the "look" method above, and
3679 * a new command may be entered at any time, but note that if the
3680 * "TARGET_LOOK" bit flag is set (or if we are in "location" mode,
3681 * where "space" has no obvious meaning) then "space" will scan
3682 * through the description of the current grid until done, instead
3683 * of immediately jumping to the next "interesting" grid. This
3684 * allows the "target" command to retain its old semantics.
3686 * The "*", "+", and "-" keys may always be used to jump immediately
3687 * to the next (or previous) interesting grid, in the proper mode.
3689 * The "return" key may always be used to scan through a complete
3690 * grid description (forever).
3692 * This command will cancel any old target, even if used from
3693 * inside the "look" command.
3695 bool target_set(int mode)
3715 get_screen_size(&wid, &hgt);
3721 /* Cancel tracking */
3722 /* health_track(0); */
3725 /* Prepare the "temp" array */
3726 target_set_prepare(mode);
3728 /* Start near the player */
3734 /* Interesting grids */
3740 if (!(mode & TARGET_LOOK)) prt_path(y, x);
3743 c_ptr = &cave[y][x];
3746 if (target_able(c_ptr->m_idx))
3749 strcpy(info, "q»ß t·è p¼« o¸½ +¼¡ -Á°");
3751 strcpy(info, "q,t,p,o,+,-,<dir>");
3756 /* Dis-allow target */
3760 strcpy(info, "q»ß p¼« o¸½ +¼¡ -Á°");
3762 strcpy(info, "q,p,o,+,-,<dir>");
3767 /* Describe and Prompt */
3768 while (!(query = target_set_aux(y, x, mode, info)));
3770 /* Cancel tracking */
3771 /* health_track(0); */
3773 /* Assume no "direction" */
3778 if (query == '\r') query = 't';
3796 if (target_able(c_ptr->m_idx))
3798 health_track(c_ptr->m_idx);
3799 target_who = c_ptr->m_idx;
3818 if (!expand_list) done = TRUE;
3828 if (!expand_list) done = TRUE;
3835 /* Recenter the map around the player */
3839 p_ptr->update |= (PU_MONSTERS);
3842 p_ptr->redraw |= (PR_MAP);
3845 p_ptr->window |= (PW_OVERHEAD);
3850 /* Recalculate interesting grids */
3851 target_set_prepare(mode);
3870 /* Extract the action (if any) */
3871 d = get_keymap_dir(query);
3878 /* Hack -- move around */
3881 /* Modified to scroll to monster */
3882 int y2 = panel_row_min;
3883 int x2 = panel_col_min;
3885 /* Find a new monster */
3886 i = target_pick(temp_y[m], temp_x[m], ddy[d], ddx[d]);
3888 /* Request to target past last interesting grid */
3889 while (flag && (i < 0))
3891 /* Note the change */
3892 if (change_panel(ddy[d], ddx[d]))
3897 /* Recalculate interesting grids */
3898 target_set_prepare(mode);
3900 /* Look at interesting grids */
3903 /* Find a new monster */
3904 i = target_pick(v, u, ddy[d], ddx[d]);
3910 /* Nothing interesting */
3916 /* Restore previous position */
3919 panel_bounds_center();
3922 p_ptr->update |= (PU_MONSTERS);
3925 p_ptr->redraw |= (PR_MAP);
3928 p_ptr->window |= (PW_OVERHEAD);
3933 /* Recalculate interesting grids */
3934 target_set_prepare(mode);
3936 /* Look at boring grids */
3943 /* Do not move horizontally if unnecessary */
3944 if (((x < panel_col_min + wid / 2) && (dx > 0)) ||
3945 ((x > panel_col_min + wid / 2) && (dx < 0)))
3950 /* Do not move vertically if unnecessary */
3951 if (((y < panel_row_min + hgt / 2) && (dy > 0)) ||
3952 ((y > panel_row_min + hgt / 2) && (dy < 0)))
3957 /* Apply the motion */
3958 if ((y >= panel_row_min+hgt) || (y < panel_row_min) ||
3959 (x >= panel_col_min+wid) || (x < panel_col_min))
3961 if (change_panel(dy, dx)) target_set_prepare(mode);
3964 /* Slide into legality */
3965 if (x >= cur_wid-1) x = cur_wid - 2;
3966 else if (x <= 0) x = 1;
3968 /* Slide into legality */
3969 if (y >= cur_hgt-1) y = cur_hgt- 2;
3970 else if (y <= 0) y = 1;
3979 /* Arbitrary grids */
3982 bool move_fast = FALSE;
3984 if (!(mode & TARGET_LOOK)) prt_path(y, x);
3987 c_ptr = &cave[y][x];
3989 /* Default prompt */
3991 strcpy(info, "q»ß t·è p¼« m¶á +¼¡ -Á°");
3993 strcpy(info, "q,t,p,m,+,-,<dir>");
3997 /* Describe and Prompt (enable "TARGET_LOOK") */
3998 while (!(query = target_set_aux(y, x, mode | TARGET_LOOK, info)));
4000 /* Cancel tracking */
4001 /* health_track(0); */
4003 /* Assume no direction */
4008 if (query == '\r') query = 't';
4011 /* Analyze the keypress */
4035 /* Recenter the map around the player */
4039 p_ptr->update |= (PU_MONSTERS);
4042 p_ptr->redraw |= (PR_MAP);
4045 p_ptr->window |= (PW_OVERHEAD);
4050 /* Recalculate interesting grids */
4051 target_set_prepare(mode);
4073 /* Pick a nearby monster */
4074 for (i = 0; i < temp_n; i++)
4076 t = distance(y, x, temp_y[i], temp_x[i]);
4086 /* Nothing interesting */
4087 if (bd == 999) flag = FALSE;
4094 /* Extract the action (if any) */
4095 d = get_keymap_dir(query);
4097 /* XTRA HACK MOVEFAST */
4098 if (isupper(query)) move_fast = TRUE;
4105 /* Handle "direction" */
4111 /* XTRA HACK MOVEFAST */
4114 int mag = MIN(wid / 2, hgt / 2);
4124 /* Do not move horizontally if unnecessary */
4125 if (((x < panel_col_min + wid / 2) && (dx > 0)) ||
4126 ((x > panel_col_min + wid / 2) && (dx < 0)))
4131 /* Do not move vertically if unnecessary */
4132 if (((y < panel_row_min + hgt / 2) && (dy > 0)) ||
4133 ((y > panel_row_min + hgt / 2) && (dy < 0)))
4138 /* Apply the motion */
4139 if ((y >= panel_row_min + hgt) || (y < panel_row_min) ||
4140 (x >= panel_col_min + wid) || (x < panel_col_min))
4142 if (change_panel(dy, dx)) target_set_prepare(mode);
4145 /* Slide into legality */
4146 if (x >= cur_wid-1) x = cur_wid - 2;
4147 else if (x <= 0) x = 1;
4149 /* Slide into legality */
4150 if (y >= cur_hgt-1) y = cur_hgt- 2;
4151 else if (y <= 0) y = 1;
4159 /* Clear the top line */
4162 /* Recenter the map around the player */
4166 p_ptr->update |= (PU_MONSTERS);
4169 p_ptr->redraw |= (PR_MAP);
4172 p_ptr->window |= (PW_OVERHEAD);
4177 /* Failure to set target */
4178 if (!target_who) return (FALSE);
4186 * Get an "aiming direction" from the user.
4188 * The "dir" is loaded with 1,2,3,4,6,7,8,9 for "actual direction", and
4189 * "0" for "current target", and "-1" for "entry aborted".
4191 * Note that "Force Target", if set, will pre-empt user interaction,
4192 * if there is a usable target already set.
4194 * Note that confusion over-rides any (explicit?) user choice.
4196 bool get_aim_dir(int *dp)
4207 /* Global direction */
4210 /* Hack -- auto-target if requested */
4211 if (use_old_target && target_okay()) dir = 5;
4213 #ifdef ALLOW_REPEAT /* TNB */
4215 if (repeat_pull(dp))
4220 if (!(*dp == 5 && !target_okay()))
4222 /* return (TRUE); */
4227 #endif /* ALLOW_REPEAT -- TNB */
4229 /* Ask until satisfied */
4232 /* Choose a prompt */
4236 p = "Êý¸þ ('*'¤Ç¥¿¡¼¥²¥Ã¥ÈÁªÂò, ESC¤ÇÃæÃÇ)? ";
4238 p = "Direction ('*' to choose a target, Escape to cancel)? ";
4245 p = "Êý¸þ ('5'¤Ç¥¿¡¼¥²¥Ã¥È¤Ø, '*'¤Ç¥¿¡¼¥²¥Ã¥ÈºÆÁªÂò, ESC¤ÇÃæÃÇ)? ";
4247 p = "Direction ('5' for target, '*' to re-target, Escape to cancel)? ";
4252 /* Get a command (or Cancel) */
4253 if (!get_com(p, &command, TRUE)) break;
4257 if (command == '\r') command = 't';
4260 /* Convert various keys to "standard" keys */
4263 /* Use current target */
4274 /* Set new target */
4279 if (target_set(TARGET_KILL)) dir = 5;
4285 /* Extract the action (if any) */
4286 dir = get_keymap_dir(command);
4292 /* Verify requested targets */
4293 if ((dir == 5) && !target_okay()) dir = 0;
4302 project_length = 0; /* reset to default */
4306 /* Save the direction */
4309 /* Check for confusion */
4310 if (p_ptr->confused)
4313 /* Random direction */
4314 dir = ddd[randint0(8)];
4317 /* Notice confusion */
4318 if (command_dir != dir)
4322 msg_print("¤¢¤Ê¤¿¤Ïº®Í𤷤Ƥ¤¤ë¡£");
4324 msg_print("You are confused.");
4329 /* Save direction */
4332 #ifdef ALLOW_REPEAT /* TNB */
4334 /* repeat_push(dir); */
4335 repeat_push(command_dir);
4337 #endif /* ALLOW_REPEAT -- TNB */
4339 /* A "valid" direction was entered */
4346 * Request a "movement" direction (1,2,3,4,6,7,8,9) from the user,
4347 * and place it into "command_dir", unless we already have one.
4349 * This function should be used for all "repeatable" commands, such as
4350 * run, walk, open, close, bash, disarm, spike, tunnel, etc, as well
4351 * as all commands which must reference a grid adjacent to the player,
4352 * and which may not reference the grid under the player. Note that,
4353 * for example, it is no longer possible to "disarm" or "open" chests
4354 * in the same grid as the player.
4356 * Direction "5" is illegal and will (cleanly) abort the command.
4358 * This function tracks and uses the "global direction", and uses
4359 * that as the "desired direction", to which "confusion" is applied.
4361 bool get_rep_dir(int *dp, bool under)
4368 /* Global direction */
4371 #ifdef ALLOW_REPEAT /* TNB */
4373 if (repeat_pull(dp))
4376 /* return (TRUE); */
4379 #endif /* ALLOW_REPEAT -- TNB */
4381 /* Get a direction */
4386 /* Get a command (or Cancel) */
4388 if (!get_com("Êý¸þ (ESC¤ÇÃæÃÇ)? ", &ch, TRUE)) break;
4390 if (!get_com("Direction (Escape to cancel)? ", &ch, TRUE)) break;
4394 /* Look up the direction */
4395 dir = get_keymap_dir(ch);
4401 /* Prevent weirdness */
4402 if ((dir == 5) && (!under)) dir = 0;
4405 if (!dir) return (FALSE);
4407 /* Save desired direction */
4410 /* Apply "confusion" */
4411 if (p_ptr->confused)
4413 /* Standard confusion */
4414 if (randint0(100) < 75)
4416 /* Random direction */
4417 dir = ddd[randint0(8)];
4420 else if (p_ptr->riding)
4422 monster_type *m_ptr = &m_list[p_ptr->riding];
4423 monster_race *r_ptr = &r_info[m_ptr->r_idx];
4425 if (MON_CONFUSED(m_ptr))
4427 /* Standard confusion */
4428 if (randint0(100) < 75)
4430 /* Random direction */
4431 dir = ddd[randint0(8)];
4434 else if ((r_ptr->flags1 & RF1_RAND_50) && (r_ptr->flags1 & RF1_RAND_25) && (randint0(100) < 50))
4436 /* Random direction */
4437 dir = ddd[randint0(8)];
4439 else if ((r_ptr->flags1 & RF1_RAND_50) && (randint0(100) < 25))
4441 /* Random direction */
4442 dir = ddd[randint0(8)];
4446 /* Notice confusion */
4447 if (command_dir != dir)
4449 if (p_ptr->confused)
4453 msg_print("¤¢¤Ê¤¿¤Ïº®Í𤷤Ƥ¤¤ë¡£");
4455 msg_print("You are confused.");
4461 monster_type *m_ptr = &m_list[p_ptr->riding];
4463 monster_desc(m_name, m_ptr, 0);
4464 if (MON_CONFUSED(m_ptr))
4467 msg_format("%s¤Ïº®Í𤷤Ƥ¤¤ë¡£", m_name);
4469 msg_format("%^s is confusing.", m_name);
4476 msg_format("%s¤Ï»×¤¤Ä̤ê¤ËÆ°¤¤¤Æ¤¯¤ì¤Ê¤¤¡£", m_name);
4478 msg_format("You cannot control %s.", m_name);
4484 /* Save direction */
4487 #ifdef ALLOW_REPEAT /* TNB */
4489 /* repeat_push(dir); */
4490 repeat_push(command_dir);
4492 #endif /* ALLOW_REPEAT -- TNB */
4499 bool get_rep_dir2(int *dp)
4506 /* Global direction */
4509 #ifdef ALLOW_REPEAT /* TNB */
4511 if (repeat_pull(dp))
4514 /* return (TRUE); */
4517 #endif /* ALLOW_REPEAT -- TNB */
4519 /* Get a direction */
4524 /* Get a command (or Cancel) */
4526 if (!get_com("Êý¸þ (ESC¤ÇÃæÃÇ)? ", &ch, TRUE)) break;
4528 if (!get_com("Direction (Escape to cancel)? ", &ch, TRUE)) break;
4532 /* Look up the direction */
4533 dir = get_keymap_dir(ch);
4539 /* Prevent weirdness */
4540 if (dir == 5) dir = 0;
4543 if (!dir) return (FALSE);
4545 /* Save desired direction */
4548 /* Apply "confusion" */
4549 if (p_ptr->confused)
4551 /* Standard confusion */
4552 if (randint0(100) < 75)
4554 /* Random direction */
4555 dir = ddd[randint0(8)];
4559 /* Notice confusion */
4560 if (command_dir != dir)
4564 msg_print("¤¢¤Ê¤¿¤Ïº®Í𤷤Ƥ¤¤ë¡£");
4566 msg_print("You are confused.");
4571 /* Save direction */
4574 #ifdef ALLOW_REPEAT /* TNB */
4576 /* repeat_push(dir); */
4577 repeat_push(command_dir);
4579 #endif /* ALLOW_REPEAT -- TNB */
4586 void gain_level_reward(int chosen_reward)
4590 char wrath_reason[32] = "";
4591 int nasty_chance = 6;
4592 int dummy = 0, dummy2 = 0;
4595 char o_name[MAX_NLEN];
4601 if (multi_rew) return;
4602 else multi_rew = TRUE;
4606 if (p_ptr->lev == 13) nasty_chance = 2;
4607 else if (!(p_ptr->lev % 13)) nasty_chance = 3;
4608 else if (!(p_ptr->lev % 14)) nasty_chance = 12;
4610 if (one_in_(nasty_chance))
4611 type = randint1(20); /* Allow the 'nasty' effects */
4613 type = randint1(15) + 5; /* Or disallow them */
4615 if (type < 1) type = 1;
4616 if (type > 20) type = 20;
4621 sprintf(wrath_reason, "%s¤ÎÅܤê",
4622 chaos_patrons[p_ptr->chaos_patron]);
4624 sprintf(wrath_reason, "the Wrath of %s",
4625 chaos_patrons[p_ptr->chaos_patron]);
4629 effect = chaos_rewards[p_ptr->chaos_patron][type];
4631 if (one_in_(6) && !chosen_reward)
4634 msg_format("%^s¤ÏË«Èþ¤È¤·¤Æ¤¢¤Ê¤¿¤òÆÍÁ³ÊÑ°Û¤µ¤»¤¿¡£",
4635 chaos_patrons[p_ptr->chaos_patron]);
4637 msg_format("%^s rewards you with a mutation!",
4638 chaos_patrons[p_ptr->chaos_patron]);
4641 (void)gain_random_mutation(0);
4643 reward = "ÊÑ°Û¤·¤¿¡£";
4645 reward = "mutation";
4650 switch (chosen_reward ? chosen_reward : effect)
4654 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
4655 chaos_patrons[p_ptr->chaos_patron]);
4657 msg_format("The voice of %s booms out:",
4658 chaos_patrons[p_ptr->chaos_patron]);
4662 msg_print("¡ÖÆò¡¢¿·¤¿¤Ê¤ë»Ñ¤òɬÍפȤ»¤ê¡ª¡×");
4664 msg_print("'Thou needst a new form, mortal!'");
4669 reward = "ÊÑ°Û¤·¤¿¡£";
4671 reward = "polymorphing";
4676 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
4677 chaos_patrons[p_ptr->chaos_patron]);
4679 msg_format("The voice of %s booms out:",
4680 chaos_patrons[p_ptr->chaos_patron]);
4684 msg_print("¡ÖÆò¤ÏÎɤ¯¹Ô¤¤¤¿¤ê¡ªÂ³¤±¤è¡ª¡×");
4686 msg_print("'Well done, mortal! Lead on!'");
4689 if (p_ptr->prace == RACE_ANDROID)
4692 msg_print("¤·¤«¤·²¿¤âµ¯¤³¤é¤Ê¤«¤Ã¤¿¡£");
4694 msg_print("But, nothing happen.");
4697 else if (p_ptr->exp < PY_MAX_EXP)
4699 s32b ee = (p_ptr->exp / 2) + 10;
4700 if (ee > 100000L) ee = 100000L;
4702 msg_print("¹¹¤Ë·Ð¸³¤òÀѤó¤À¤è¤¦¤Êµ¤¤¬¤¹¤ë¡£");
4704 msg_print("You feel more experienced.");
4709 reward = "·Ð¸³ÃͤòÆÀ¤¿";
4711 reward = "experience";
4717 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
4718 chaos_patrons[p_ptr->chaos_patron]);
4720 msg_format("The voice of %s booms out:",
4721 chaos_patrons[p_ptr->chaos_patron]);
4725 msg_print("¡Ö²¼Ëͤ衢Æò¤½¤ì¤ËÃͤ»¤º¡£¡×");
4727 msg_print("'Thou didst not deserve that, slave.'");
4730 if (p_ptr->prace == RACE_ANDROID)
4733 msg_print("¤·¤«¤·²¿¤âµ¯¤³¤é¤Ê¤«¤Ã¤¿¡£");
4735 msg_print("But, nothing happen.");
4740 lose_exp(p_ptr->exp / 6);
4742 reward = "·Ð¸³Ãͤò¼º¤Ã¤¿¡£";
4744 reward = "losing experience";
4750 msg_format("%s¤ÎÀ¼¤¬¤µ¤µ¤ä¤¤¤¿:",
4751 chaos_patrons[p_ptr->chaos_patron]);
4753 msg_format("The voice of %s whispers:",
4754 chaos_patrons[p_ptr->chaos_patron]);
4758 msg_print("¡Ö²æ¤¬Í¿¤¨¤·Êª¤ò¸ÌÀ¤Ë»È¤¦¤Ù¤·¡£¡×");
4760 msg_print("'Use my gift wisely.'");
4763 acquirement(py, px, 1, FALSE, FALSE);
4765 reward = "¾å¼Á¤Ê¥¢¥¤¥Æ¥à¤ò¼ê¤ËÆþ¤ì¤¿¡£";
4767 reward = "a good item";
4772 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
4773 chaos_patrons[p_ptr->chaos_patron]);
4775 msg_format("The voice of %s booms out:",
4776 chaos_patrons[p_ptr->chaos_patron]);
4780 msg_print("¡Ö²æ¤¬Í¿¤¨¤·Êª¤ò¸ÌÀ¤Ë»È¤¦¤Ù¤·¡£¡×");
4782 msg_print("'Use my gift wisely.'");
4785 acquirement(py, px, 1, TRUE, FALSE);
4787 reward = "¹âµéÉʤΥ¢¥¤¥Æ¥à¤ò¼ê¤ËÆþ¤ì¤¿¡£";
4789 reward = "an excellent item";
4794 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
4795 chaos_patrons[p_ptr->chaos_patron]);
4797 msg_format("The voice of %s booms out:",
4798 chaos_patrons[p_ptr->chaos_patron]);
4802 msg_print("¡ÖÆò¤Î¹Ô¤¤¤Ïµ®¤·õ¤ËÃͤ»¤ê¡£¡×");
4804 msg_print("'Thy deed hath earned thee a worthy blade.'");
4807 /* Get local object */
4810 switch (randint1(p_ptr->lev))
4816 dummy2 = SV_MAIN_GAUCHE;
4825 dummy2 = SV_SMALL_SWORD;
4828 dummy2 = SV_BASILLARD;
4830 case 11: case 12: case 13:
4831 dummy2 = SV_SHORT_SWORD;
4837 dummy2 = SV_CUTLASS;
4840 dummy2 = SV_WAKIZASHI;
4843 dummy2 = SV_KHOPESH;
4849 dummy2 = SV_BROAD_SWORD;
4852 dummy2 = SV_LONG_SWORD;
4855 dummy2 = SV_SCIMITAR;
4858 dummy2 = SV_NINJATO;
4864 dummy2 = SV_BASTARD_SWORD;
4867 dummy2 = SV_GREAT_SCIMITAR;
4870 dummy2 = SV_CLAYMORE;
4873 dummy2 = SV_ESPADON;
4876 dummy2 = SV_TWO_HANDED_SWORD;
4879 dummy2 = SV_FLAMBERGE;
4882 dummy2 = SV_NO_DACHI;
4885 dummy2 = SV_EXECUTIONERS_SWORD;
4888 dummy2 = SV_ZWEIHANDER;
4891 dummy2 = SV_HAYABUSA;
4894 dummy2 = SV_BLADE_OF_CHAOS;
4897 object_prep(q_ptr, lookup_kind(dummy, dummy2));
4898 q_ptr->to_h = 3 + randint1(dun_level) % 10;
4899 q_ptr->to_d = 3 + randint1(dun_level) % 10;
4900 one_resistance(q_ptr);
4901 q_ptr->name2 = EGO_CHAOTIC;
4903 /* Drop it in the dungeon */
4904 (void)drop_near(q_ptr, -1, py, px);
4906 reward = "(º®ÆÙ)¤ÎÉð´ï¤ò¼ê¤ËÆþ¤ì¤¿¡£";
4908 reward = "chaos weapon";
4913 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
4914 chaos_patrons[p_ptr->chaos_patron]);
4916 msg_format("The voice of %s booms out:",
4917 chaos_patrons[p_ptr->chaos_patron]);
4921 msg_print("¡ÖÆò¤Î¹Ô¤¤¤Ïµ®¤Ê󤤤ËÃͤ»¤ê¡£¡×");
4923 msg_print("'Thy deed hath earned thee a worthy reward.'");
4926 acquirement(py, px, randint1(2) + 1, FALSE, FALSE);
4928 reward = "¾å¼Á¤Ê¥¢¥¤¥Æ¥à¤ò¼ê¤ËÆþ¤ì¤¿¡£";
4930 reward = "good items";
4935 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
4936 chaos_patrons[p_ptr->chaos_patron]);
4938 msg_format("The voice of %s booms out:",
4939 chaos_patrons[p_ptr->chaos_patron]);
4943 msg_print("¡Ö²¼Ëͤ衢Æò¤Î¸¥¿È¤Ø¤Î²æ¤¬Àˤ·¤ß̵¤Ê󤤤ò¸«¤ë¤¬¤è¤¤¡£¡×");
4945 msg_print("'Behold, mortal, how generously I reward thy loyalty.'");
4948 acquirement(py, px, randint1(2) + 1, TRUE, FALSE);
4950 reward = "¹âµéÉʤΥ¢¥¤¥Æ¥à¤ò¼ê¤ËÆþ¤ì¤¿¡£";
4952 reward = "excellent items";
4957 msg_format("%s¤ÎÀ¼¤¬¹ì¤ÅϤä¿:",
4958 chaos_patrons[p_ptr->chaos_patron]);
4960 msg_format("The voice of %s thunders:",
4961 chaos_patrons[p_ptr->chaos_patron]);
4965 msg_print("¡Ö²¼Ëͤ衢ÆòÐþËý¤Ê¤ê¡£¡×");
4967 msg_print("'Thou art growing arrogant, mortal.'");
4970 (void)activate_ty_curse(FALSE, &count);
4972 reward = "²Ò¡¹¤·¤¤¼ö¤¤¤ò¤«¤±¤é¤ì¤¿¡£";
4979 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
4980 chaos_patrons[p_ptr->chaos_patron]);
4982 msg_format("The voice of %s booms out:",
4983 chaos_patrons[p_ptr->chaos_patron]);
4987 msg_print("¡Ö²æ¤¬²¼Ëͤ¿¤Á¤è¡¢¤«¤ÎÐþËý¤Ê¤ë¼Ô¤òÅݤ¹¤Ù¤·¡ª¡×");
4989 msg_print("'My pets, destroy the arrogant mortal!'");
4992 for (dummy = 0; dummy < randint1(5) + 1; dummy++)
4994 (void)summon_specific(0, py, px, dun_level, 0, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET));
4997 reward = "¥â¥ó¥¹¥¿¡¼¤ò¾¤´¤µ¤ì¤¿¡£";
4999 reward = "summoning hostile monsters";
5004 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5005 chaos_patrons[p_ptr->chaos_patron]);
5007 msg_format("The voice of %s booms out:",
5008 chaos_patrons[p_ptr->chaos_patron]);
5012 msg_print("¡ÖÆò¡¢¤è¤ê¶¯¤Å¨¤òɬÍפȤ»¤ê¡ª¡×");
5014 msg_print("'Thou needst worthier opponents!'");
5017 activate_hi_summon(py, px, FALSE);
5019 reward = "¥â¥ó¥¹¥¿¡¼¤ò¾¤´¤µ¤ì¤¿¡£";
5021 reward = "summoning many hostile monsters";
5026 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5027 chaos_patrons[p_ptr->chaos_patron]);
5029 msg_format("The voice of %s booms out:",
5030 chaos_patrons[p_ptr->chaos_patron]);
5034 msg_print("¡Ö»à¤ÈÇ˲õ¤³¤½²æ¤¬´î¤Ó¤Ê¤ê¡ª¡×");
5036 msg_print("'Death and destruction! This pleaseth me!'");
5041 reward = "¥«¥ª¥¹¤ÎÎϤ¬±²´¬¤¤¤¿¡£";
5043 reward = "calling chaos";
5048 msg_format("%s¤ÎÀ¼¤¬ÌĤê¶Á¤¤¤¿:",
5049 chaos_patrons[p_ptr->chaos_patron]);
5051 msg_format("The voice of %s rings out:",
5052 chaos_patrons[p_ptr->chaos_patron]);
5056 msg_print("¡Öα¤Þ¤ë¤Î¤À¡¢²¼Ëͤ衣;¤¬Æò¤ÎÆùÂΤòÃ䨤󡣡×");
5058 msg_print("'Stay, mortal, and let me mold thee.'");
5061 if (one_in_(3) && !(chaos_stats[p_ptr->chaos_patron] < 0))
5062 do_inc_stat(chaos_stats[p_ptr->chaos_patron]);
5064 do_inc_stat(randint0(6));
5066 reward = "ǽÎÏÃͤ¬¾å¤¬¤Ã¤¿¡£";
5068 reward = "increasing a stat";
5073 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5074 chaos_patrons[p_ptr->chaos_patron]);
5076 msg_format("The voice of %s booms out:",
5077 chaos_patrons[p_ptr->chaos_patron]);
5081 msg_print("¡Ö²¼Ëͤ衢;¤ÏÆò¤ËË°¤ß¤¿¤ê¡£¡×");
5083 msg_print("'I grow tired of thee, mortal.'");
5086 if (one_in_(3) && !(chaos_stats[p_ptr->chaos_patron] < 0))
5087 do_dec_stat(chaos_stats[p_ptr->chaos_patron]);
5089 (void)do_dec_stat(randint0(6));
5091 reward = "ǽÎÏÃͤ¬²¼¤¬¤Ã¤¿¡£";
5093 reward = "decreasing a stat";
5098 msg_format("%s¤ÎÀ¼¤¬¹ì¤ÅϤä¿:",
5099 chaos_patrons[p_ptr->chaos_patron]);
5101 msg_format("The voice of %s thunders:",
5102 chaos_patrons[p_ptr->chaos_patron]);
5106 msg_print("¡ÖÆò¡¢¸¬µõ¤¿¤ë¤³¤È¤ò³Ø¤Ö¤Ù¤·¡ª¡×");
5107 msg_print("¤¢¤Ê¤¿¤Ï°ÊÁ°¤è¤ê¼å¤¯¤Ê¤Ã¤¿¡ª");
5109 msg_print("'Thou needst a lesson in humility, mortal!'");
5110 msg_print("You feel less powerful!");
5113 for (dummy = 0; dummy < 6; dummy++)
5115 (void)dec_stat(dummy, 10 + randint1(15), TRUE);
5118 reward = "Á´Ç½ÎÏÃͤ¬²¼¤¬¤Ã¤¿¡£";
5120 reward = "decreasing all stats";
5125 msg_format("%s¤ÎÎϤ¬¿¨¤ì¤ë¤Î¤ò´¶¤¸¤¿¡£",
5127 msg_format("You feel the power of %s touch you.",
5130 chaos_patrons[p_ptr->chaos_patron]);
5133 reward = "½ý¤¬ÊѲ½¤·¤¿¡£";
5135 reward = "polymorphing wounds";
5140 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5141 chaos_patrons[p_ptr->chaos_patron]);
5143 msg_format("The voice of %s booms out:",
5144 chaos_patrons[p_ptr->chaos_patron]);
5148 msg_print("¡Ö²æ¤¬¤µ¤µ¤ä¤«¤Ê¤ë»òʪ¤ò¼õ¤±¤È¤ë¤¬¤è¤¤¡ª¡×");
5150 msg_print("'Receive this modest gift from me!'");
5153 for (dummy = 0; dummy < 6; dummy++)
5155 (void)do_inc_stat(dummy);
5158 reward = "Á´Ç½ÎÏÃͤ¬¾å¤¬¤Ã¤¿¡£";
5160 reward = "increasing all stats";
5165 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5166 chaos_patrons[p_ptr->chaos_patron]);
5168 msg_format("The voice of %s booms out:",
5169 chaos_patrons[p_ptr->chaos_patron]);
5173 msg_print("¡Ö¶ì¤·¤à¤¬¤è¤¤¡¢ÌµÇ½¤Ê¶ò¤«¼Ô¤è¡ª¡×");
5175 msg_print("'Suffer, pathetic fool!'");
5178 fire_ball(GF_DISINTEGRATE, 0, p_ptr->lev * 4, 4);
5179 take_hit(DAMAGE_NOESCAPE, p_ptr->lev * 4, wrath_reason, -1);
5181 reward = "ʬ²ò¤Îµå¤¬È¯À¸¤·¤¿¡£";
5183 reward = "generating disintegration ball";
5188 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5189 chaos_patrons[p_ptr->chaos_patron]);
5191 msg_format("The voice of %s booms out:",
5192 chaos_patrons[p_ptr->chaos_patron]);
5196 msg_print("¡Öᴤ뤬¤è¤¤¡¢²æ¤¬²¼Ëͤ衪¡×");
5198 msg_print("'Rise, my servant!'");
5202 (void)set_poisoned(0);
5204 (void)set_confused(0);
5209 for (dummy = 0; dummy < 6; dummy++)
5211 (void)do_res_stat(dummy);
5214 reward = "ÂÎÎϤ¬²óÉü¤·¤¿¡£";
5220 if (!buki_motteruka(INVEN_RARM) && !buki_motteruka(INVEN_LARM)) break;
5222 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5223 chaos_patrons[p_ptr->chaos_patron]);
5225 msg_format("The voice of %s booms out:",
5226 chaos_patrons[p_ptr->chaos_patron]);
5230 msg_print("¡ÖÆò¡¢Éð´ï¤ËÍê¤ë¤³¤È¤Ê¤«¤ì¡£¡×");
5232 msg_print("'Thou reliest too much on thy weapon.'");
5236 if (buki_motteruka(INVEN_LARM))
5239 if (buki_motteruka(INVEN_RARM) && one_in_(2)) dummy = INVEN_RARM;
5241 object_desc(o_name, &inventory[dummy], OD_NAME_ONLY);
5242 (void)curse_weapon(FALSE, dummy);
5244 reward = format("%s¤¬Ç˲õ¤µ¤ì¤¿¡£", o_name);
5246 reward = format("destroying %s", o_name);
5250 if (!inventory[INVEN_BODY].k_idx) break;
5252 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5253 chaos_patrons[p_ptr->chaos_patron]);
5255 msg_format("The voice of %s booms out:",
5256 chaos_patrons[p_ptr->chaos_patron]);
5260 msg_print("¡ÖÆò¡¢Ëɶñ¤ËÍê¤ë¤³¤È¤Ê¤«¤ì¡£¡×");
5262 msg_print("'Thou reliest too much on thine equipment.'");
5265 object_desc(o_name, &inventory[INVEN_BODY], OD_NAME_ONLY);
5266 (void)curse_armor();
5268 reward = format("%s¤¬Ç˲õ¤µ¤ì¤¿¡£", o_name);
5270 reward = format("destroying %s", o_name);
5275 msg_format("%s¤ÎÀ¼¤¬¤µ¤µ¤ä¤¤¤¿:",
5276 chaos_patrons[p_ptr->chaos_patron]);
5278 msg_format("The voice of %s whispers:",
5279 chaos_patrons[p_ptr->chaos_patron]);
5283 msg_print("¡Ö²æ¤òÅܤꤷ¤á¤¿ºá¤ò½þ¤¦¤Ù¤·¡£¡×");
5285 msg_print("'Now thou shalt pay for annoying me.'");
5288 switch (randint1(4))
5291 (void)activate_ty_curse(FALSE, &count);
5293 reward = "²Ò¡¹¤·¤¤¼ö¤¤¤ò¤«¤±¤é¤ì¤¿¡£";
5299 activate_hi_summon(py, px, FALSE);
5301 reward = "¥â¥ó¥¹¥¿¡¼¤ò¾¤´¤µ¤ì¤¿¡£";
5303 reward = "summoning hostile monsters";
5309 if (!buki_motteruka(INVEN_RARM) && !buki_motteruka(INVEN_LARM)) break;
5311 if (buki_motteruka(INVEN_LARM))
5314 if (buki_motteruka(INVEN_RARM) && one_in_(2)) dummy = INVEN_RARM;
5316 object_desc(o_name, &inventory[dummy], OD_NAME_ONLY);
5317 (void)curse_weapon(FALSE, dummy);
5319 reward = format("%s¤¬Ç˲õ¤µ¤ì¤¿¡£", o_name);
5321 reward = format("destroying %s", o_name);
5326 if (!inventory[INVEN_BODY].k_idx) break;
5327 object_desc(o_name, &inventory[INVEN_BODY], OD_NAME_ONLY);
5328 (void)curse_armor();
5330 reward = format("%s¤¬Ç˲õ¤µ¤ì¤¿¡£", o_name);
5332 reward = format("destroying %s", o_name);
5337 for (dummy = 0; dummy < 6; dummy++)
5339 (void)dec_stat(dummy, 10 + randint1(15), TRUE);
5342 reward = "Á´Ç½ÎÏÃͤ¬²¼¤¬¤Ã¤¿¡£";
5344 reward = "decreasing all stats";
5351 msg_format("%s¤ÎÀ¼¤¬¹ì¤ÅϤä¿:",
5353 msg_format("The voice of %s thunders:",
5356 chaos_patrons[p_ptr->chaos_patron]);
5358 msg_print("¡Ö»à¤Ì¤¬¤è¤¤¡¢²¼Ëͤ衪¡×");
5360 msg_print("'Die, mortal!'");
5363 take_hit(DAMAGE_LOSELIFE, p_ptr->lev * 4, wrath_reason, -1);
5364 for (dummy = 0; dummy < 6; dummy++)
5366 (void)dec_stat(dummy, 10 + randint1(15), FALSE);
5368 activate_hi_summon(py, px, FALSE);
5369 (void)activate_ty_curse(FALSE, &count);
5374 if (buki_motteruka(INVEN_RARM))
5377 if (buki_motteruka(INVEN_LARM) && one_in_(2)) dummy = INVEN_LARM;
5379 else if (buki_motteruka(INVEN_LARM)) dummy = INVEN_LARM;
5381 if (dummy) (void)curse_weapon(FALSE, dummy);
5383 if (one_in_(2)) (void)curse_armor();
5387 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5388 chaos_patrons[p_ptr->chaos_patron]);
5390 msg_format("The voice of %s booms out:",
5391 chaos_patrons[p_ptr->chaos_patron]);
5395 msg_print("¡Ö»à¤ÈÇ˲õ¤³¤½²æ¤¬´î¤Ó¤Ê¤ê¡ª¡×");
5397 msg_print("'Death and destruction! This pleaseth me!'");
5400 (void)destroy_area(py, px, 25, FALSE);
5402 reward = "¥À¥ó¥¸¥ç¥ó¤¬*Ç˲õ*¤µ¤ì¤¿¡£";
5404 reward = "*destruct*ing dungeon";
5409 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5410 chaos_patrons[p_ptr->chaos_patron]);
5412 msg_format("The voice of %s booms out:",
5413 chaos_patrons[p_ptr->chaos_patron]);
5417 msg_print("¡Ö²æ¡¢Æò¤ÎŨ¤òËõ»¦¤»¤ó¡ª¡×");
5419 msg_print("'Let me relieve thee of thine oppressors!'");
5422 (void)symbol_genocide(0, FALSE);
5424 reward = "¥â¥ó¥¹¥¿¡¼¤¬Ëõ»¦¤µ¤ì¤¿¡£";
5426 reward = "genociding monsters";
5431 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5432 chaos_patrons[p_ptr->chaos_patron]);
5434 msg_format("The voice of %s booms out:",
5435 chaos_patrons[p_ptr->chaos_patron]);
5439 msg_print("¡Ö²æ¡¢Æò¤ÎŨ¤òËõ»¦¤»¤ó¡ª¡×");
5441 msg_print("'Let me relieve thee of thine oppressors!'");
5444 (void)mass_genocide(0, FALSE);
5446 reward = "¥â¥ó¥¹¥¿¡¼¤¬Ëõ»¦¤µ¤ì¤¿¡£";
5448 reward = "genociding nearby monsters";
5453 msg_format("%s¤ÎÎϤ¬Å¨¤ò¹¶·â¤¹¤ë¤Î¤ò´¶¤¸¤¿¡ª",
5454 chaos_patrons[p_ptr->chaos_patron]);
5456 msg_format("You can feel the power of %s assault your enemies!",
5457 chaos_patrons[p_ptr->chaos_patron]);
5460 (void)dispel_monsters(p_ptr->lev * 4);
5464 msg_format("%s¤Ï¤¢¤Ê¤¿¤ò̵»ë¤·¤¿¡£",
5465 chaos_patrons[p_ptr->chaos_patron]);
5467 msg_format("%s ignores you.",
5468 chaos_patrons[p_ptr->chaos_patron]);
5474 msg_format("%s¤ÏË«Èþ¤È¤·¤Æ°Ëâ¤Î»È¤¤¤ò¤è¤³¤·¤¿¡ª",chaos_patrons[p_ptr->chaos_patron]);
5476 msg_format("%s rewards you with a demonic servant!",chaos_patrons[p_ptr->chaos_patron]);
5479 if (!summon_specific(-1, py, px, dun_level, SUMMON_DEMON, PM_FORCE_PET))
5481 msg_print("²¿¤â¸½¤ì¤Ê¤«¤Ã¤¿...");
5483 msg_print("Nobody ever turns up...");
5487 reward = "°Ë⤬¥Ú¥Ã¥È¤Ë¤Ê¤Ã¤¿¡£";
5489 reward = "a demonic servant";
5495 msg_format("%s¤ÏË«Èþ¤È¤·¤Æ»È¤¤¤ò¤è¤³¤·¤¿¡ª",chaos_patrons[p_ptr->chaos_patron]);
5497 msg_format("%s rewards you with a servant!",chaos_patrons[p_ptr->chaos_patron]);
5500 if (!summon_specific(-1, py, px, dun_level, 0, PM_FORCE_PET))
5502 msg_print("²¿¤â¸½¤ì¤Ê¤«¤Ã¤¿...");
5504 msg_print("Nobody ever turns up...");
5508 reward = "¥â¥ó¥¹¥¿¡¼¤¬¥Ú¥Ã¥È¤Ë¤Ê¤Ã¤¿¡£";
5510 reward = "a servant";
5516 msg_format("%s¤ÏË«Èþ¤È¤·¤Æ¥¢¥ó¥Ç¥Ã¥É¤Î»È¤¤¤ò¤è¤³¤·¤¿¡£",chaos_patrons[p_ptr->chaos_patron]);
5518 msg_format("%s rewards you with an undead servant!",chaos_patrons[p_ptr->chaos_patron]);
5521 if (!summon_specific(-1, py, px, dun_level, SUMMON_UNDEAD, PM_FORCE_PET))
5523 msg_print("²¿¤â¸½¤ì¤Ê¤«¤Ã¤¿...");
5525 msg_print("Nobody ever turns up...");
5529 reward = "¥¢¥ó¥Ç¥Ã¥É¤¬¥Ú¥Ã¥È¤Ë¤Ê¤Ã¤¿¡£";
5531 reward = "an undead servant";
5537 msg_format("%s¤ÎÀ¼¤¬¤É¤â¤Ã¤¿:",
5539 msg_format("The voice of %s stammers:",
5542 chaos_patrons[p_ptr->chaos_patron]);
5544 msg_format("¡Ö¤¢¡¼¡¢¤¢¡¼¡¢Åú¤¨¤Ï %d/%d¡£¼ÁÌä¤Ï²¿¡©¡×", type, effect);
5546 msg_format("'Uh... uh... the answer's %d/%d, what's the question?'", type, effect);
5554 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, format("¥Ñ¥È¥í¥ó¤ÎÊó½·¤Ç%s", reward));
5556 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, format("The patron rewards you with %s.", reward));
5563 * old -- from PsiAngband.
5565 bool tgt_pt(int *x_ptr, int *y_ptr)
5569 bool success = FALSE;
5574 get_screen_size(&wid, &hgt);
5580 msg_print("¾ì½ê¤òÁª¤ó¤Ç¥¹¥Ú¡¼¥¹¥¡¼¤ò²¡¤·¤Æ²¼¤µ¤¤¡£");
5582 msg_print("Select a point and press space.");
5584 msg_flag = FALSE; /* prevents "-more-" message. */
5586 while ((ch != ESCAPE) && !success)
5588 bool move_fast = FALSE;
5590 move_cursor_relative(y, x);
5602 if (player_bold(y, x)) ch = 0;
5605 else success = TRUE;
5609 /* Look up the direction */
5610 d = get_keymap_dir(ch);
5612 /* XTRA HACK MOVEFAST */
5613 if (isupper(ch)) move_fast = TRUE;
5615 /* Handle "direction" */
5621 /* XTRA HACK MOVEFAST */
5624 int mag = MIN(wid / 2, hgt / 2);
5634 /* Do not move horizontally if unnecessary */
5635 if (((x < panel_col_min + wid / 2) && (dx > 0)) ||
5636 ((x > panel_col_min + wid / 2) && (dx < 0)))
5641 /* Do not move vertically if unnecessary */
5642 if (((y < panel_row_min + hgt / 2) && (dy > 0)) ||
5643 ((y > panel_row_min + hgt / 2) && (dy < 0)))
5648 /* Apply the motion */
5649 if ((y >= panel_row_min + hgt) || (y < panel_row_min) ||
5650 (x >= panel_col_min + wid) || (x < panel_col_min))
5652 /* if (change_panel(dy, dx)) target_set_prepare(mode); */
5653 change_panel(dy, dx);
5656 /* Slide into legality */
5657 if (x >= cur_wid-1) x = cur_wid - 2;
5658 else if (x <= 0) x = 1;
5660 /* Slide into legality */
5661 if (y >= cur_hgt-1) y = cur_hgt- 2;
5662 else if (y <= 0) y = 1;
5669 /* Clear the top line */
5672 /* Recenter the map around the player */
5676 p_ptr->update |= (PU_MONSTERS);
5679 p_ptr->redraw |= (PR_MAP);
5682 p_ptr->window |= (PW_OVERHEAD);
5693 bool get_hack_dir(int *dp)
5703 /* Global direction */
5706 /* (No auto-targeting) */
5708 /* Ask until satisfied */
5711 /* Choose a prompt */
5715 p = "Êý¸þ ('*'¤Ç¥¿¡¼¥²¥Ã¥ÈÁªÂò, ESC¤ÇÃæÃÇ)? ";
5717 p = "Direction ('*' to choose a target, Escape to cancel)? ";
5724 p = "Êý¸þ ('5'¤Ç¥¿¡¼¥²¥Ã¥È¤Ø, '*'¤Ç¥¿¡¼¥²¥Ã¥ÈºÆÁªÂò, ESC¤ÇÃæÃÇ)? ";
5726 p = "Direction ('5' for target, '*' to re-target, Escape to cancel)? ";
5731 /* Get a command (or Cancel) */
5732 if (!get_com(p, &command, TRUE)) break;
5736 if (command == '\r') command = 't';
5739 /* Convert various keys to "standard" keys */
5742 /* Use current target */
5753 /* Set new target */
5758 if (target_set(TARGET_KILL)) dir = 5;
5764 /* Look up the direction */
5765 dir = get_keymap_dir(command);
5771 /* Verify requested targets */
5772 if ((dir == 5) && !target_okay()) dir = 0;
5779 if (!dir) return (FALSE);
5781 /* Save the direction */
5784 /* Check for confusion */
5785 if (p_ptr->confused)
5788 /* Random direction */
5789 dir = ddd[randint0(8)];
5792 /* Notice confusion */
5793 if (command_dir != dir)
5797 msg_print("¤¢¤Ê¤¿¤Ïº®Í𤷤Ƥ¤¤ë¡£");
5799 msg_print("You are confused.");
5804 /* Save direction */
5807 /* A "valid" direction was entered */
5813 * ¥¨¥Í¥ë¥®¡¼¤ÎÁý²ÃÎÌ10d5¤ò®¤¯·×»»¤¹¤ë¤¿¤á¤Î´Ø¿ô
5816 #define Go_no_JuuJou 5*5*5*5*5*5*5*5*5*5
5818 s16b gain_energy(void)
5821 s32b energy_result = 10;
5824 tmp = randint0(Go_no_JuuJou);
5826 for (i = 0; i < 9; i ++){
5827 energy_result += tmp % 5;
5831 return (s16b)(energy_result + tmp);
5838 s16b bow_energy(int sval)
5842 /* Analyze the launcher */
5845 /* Sling and ammo */
5852 /* Short Bow and Arrow */
5859 /* Long Bow and Arrow */
5866 /* Bow of irresponsiblity and Arrow */
5873 /* Light Crossbow and Bolt */
5880 /* Heavy Crossbow and Bolt */
5895 int bow_tmul(int sval)
5899 /* Analyze the launcher */
5902 /* Sling and ammo */
5909 /* Short Bow and Arrow */
5916 /* Long Bow and Arrow */
5923 /* Bow of irresponsiblity and Arrow */
5930 /* Light Crossbow and Bolt */
5937 /* Heavy Crossbow and Bolt */
5949 * Return alignment title
5951 cptr your_alignment(void)
5954 if (p_ptr->align > 150) return "ÂçÁ±";
5955 else if (p_ptr->align > 50) return "ÃæÁ±";
5956 else if (p_ptr->align > 10) return "¾®Á±";
5957 else if (p_ptr->align > -11) return "ÃæΩ";
5958 else if (p_ptr->align > -51) return "¾®°";
5959 else if (p_ptr->align > -151) return "Ãæ°";
5962 if (p_ptr->align > 150) return "Lawful";
5963 else if (p_ptr->align > 50) return "Good";
5964 else if (p_ptr->align > 10) return "Neutral Good";
5965 else if (p_ptr->align > -11) return "Neutral";
5966 else if (p_ptr->align > -51) return "Neutral Evil";
5967 else if (p_ptr->align > -151) return "Evil";
5968 else return "Chaotic";
5974 * Return proficiency level of weapons and misc. skills (except riding)
5976 int weapon_exp_level(int weapon_exp)
5978 if (weapon_exp < WEAPON_EXP_BEGINNER) return EXP_LEVEL_UNSKILLED;
5979 else if (weapon_exp < WEAPON_EXP_SKILLED) return EXP_LEVEL_BEGINNER;
5980 else if (weapon_exp < WEAPON_EXP_EXPERT) return EXP_LEVEL_SKILLED;
5981 else if (weapon_exp < WEAPON_EXP_MASTER) return EXP_LEVEL_EXPERT;
5982 else return EXP_LEVEL_MASTER;
5987 * Return proficiency level of riding
5989 int riding_exp_level(int riding_exp)
5991 if (riding_exp < RIDING_EXP_BEGINNER) return EXP_LEVEL_UNSKILLED;
5992 else if (riding_exp < RIDING_EXP_SKILLED) return EXP_LEVEL_BEGINNER;
5993 else if (riding_exp < RIDING_EXP_EXPERT) return EXP_LEVEL_SKILLED;
5994 else if (riding_exp < RIDING_EXP_MASTER) return EXP_LEVEL_EXPERT;
5995 else return EXP_LEVEL_MASTER;
6000 * Return proficiency level of spells
6002 int spell_exp_level(int spell_exp)
6004 if (spell_exp < SPELL_EXP_BEGINNER) return EXP_LEVEL_UNSKILLED;
6005 else if (spell_exp < SPELL_EXP_SKILLED) return EXP_LEVEL_BEGINNER;
6006 else if (spell_exp < SPELL_EXP_EXPERT) return EXP_LEVEL_SKILLED;
6007 else if (spell_exp < SPELL_EXP_MASTER) return EXP_LEVEL_EXPERT;
6008 else return EXP_LEVEL_MASTER;