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_down_stair);
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 && !p_ptr->image) || (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 | RF9_DROP_SKELETON)) &&
827 !(p_ptr->inside_arena || p_ptr->inside_battle || cloned || ((m_ptr->r_idx == today_mon) && is_pet(m_ptr))))
829 /* Assume skeleton */
833 * We cannot drop a skeleton? Note, if we are in this check,
834 * we *know* we can drop at least a corpse or a skeleton
836 if (!(r_ptr->flags9 & RF9_DROP_SKELETON))
838 else if ((r_ptr->flags9 & RF9_DROP_CORPSE) && (r_ptr->flags1 & RF1_UNIQUE))
841 /* Else, a corpse is more likely unless we did a "lot" of damage */
842 else if (r_ptr->flags9 & RF9_DROP_CORPSE)
844 /* Lots of damage in one blow */
845 if ((0 - ((m_ptr->maxhp) / 4)) > m_ptr->hp)
847 if (one_in_(5)) corpse = TRUE;
851 if (!one_in_(5)) corpse = TRUE;
855 /* Get local object */
858 /* Prepare to make an object */
859 object_prep(q_ptr, lookup_kind(TV_CORPSE, (corpse ? SV_CORPSE : SV_SKELETON)));
861 apply_magic(q_ptr, object_level, AM_NO_FIXED_ART);
863 q_ptr->pval = m_ptr->r_idx;
865 /* Drop it in the dungeon */
866 (void)drop_near(q_ptr, -1, y, x);
869 /* Drop objects being carried */
870 monster_drop_carried_objects(m_ptr);
872 if (r_ptr->flags1 & RF1_DROP_GOOD) mo_mode |= AM_GOOD;
873 if (r_ptr->flags1 & RF1_DROP_GREAT) mo_mode |= AM_GREAT;
875 switch (m_ptr->r_idx)
877 case MON_PINK_HORROR:
878 /* Pink horrors are replaced with 2 Blue horrors */
879 if (!(p_ptr->inside_arena || p_ptr->inside_battle))
883 for (i = 0; i < 2; i++)
886 bool pet = is_pet(m_ptr);
889 if (pet) mode |= PM_FORCE_PET;
891 if (summon_specific((pet ? -1 : m_idx), wy, wx, 100, SUMMON_BLUE_HORROR, mode))
893 if (player_can_see_bold(wy, wx))
900 msg_print("¥Ô¥ó¥¯¡¦¥Û¥é¡¼¤ÏʬÎö¤·¤¿¡ª");
902 msg_print("The Pink horror divides!");
907 case MON_BLOODLETTER:
908 /* Bloodletters of Khorne may drop a blade of chaos */
909 if (drop_chosen_item && (randint1(100) < 15))
911 /* Get local object */
914 /* Prepare to make a Blade of Chaos */
915 object_prep(q_ptr, lookup_kind(TV_SWORD, SV_BLADE_OF_CHAOS));
917 apply_magic(q_ptr, object_level, AM_NO_FIXED_ART | mo_mode);
919 /* Drop it in the dungeon */
920 (void)drop_near(q_ptr, -1, y, x);
925 if (drop_chosen_item && (dun_level > 9))
927 /* Get local object */
930 /* Wipe the object */
933 /* Activate restriction */
934 if ((dun_level > 49) && one_in_(5))
935 get_obj_num_hook = kind_is_good_book;
937 get_obj_num_hook = kind_is_book;
940 make_object(q_ptr, mo_mode);
942 /* Drop it in the dungeon */
943 (void)drop_near(q_ptr, -1, y, x);
949 * Mega^3-hack: killing a 'Warrior of the Dawn' is likely to
950 * spawn another in the fallen one's place!
952 if (!p_ptr->inside_arena && !p_ptr->inside_battle)
958 bool pet = is_pet(m_ptr);
962 scatter(&wy, &wx, y, x, 20, 0);
964 while (!(in_bounds(wy, wx) && cave_empty_bold2(wy, wx)) && --attempts);
969 if (pet) mode |= PM_FORCE_PET;
971 if (summon_specific((pet ? -1 : m_idx), wy, wx, 100, SUMMON_DAWN, mode))
973 if (player_can_see_bold(wy, wx))
975 msg_print("¿·¤¿¤ÊÀï»Î¤¬¸½¤ì¤¿¡ª");
977 msg_print("A new warrior steps forth!");
987 /* One more ultra-hack: An Unmaker goes out with a big bang! */
989 int flg = PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL;
990 (void)project(m_idx, 6, y, x, 100, GF_CHAOS, flg, -1);
994 case MON_UNICORN_ORD:
997 /* Reward for "lazy" player */
998 if (p_ptr->pseikaku == SEIKAKU_NAMAKE)
1001 artifact_type *a_ptr = NULL;
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 a_ptr = &a_info[a_idx];
1022 while (a_ptr->cur_num);
1024 /* Create the artifact */
1025 if (create_named_art(a_idx, y, x))
1029 /* Hack -- Memorize location of artifact in saved floors */
1030 if (character_dungeon) a_ptr->floor_id = p_ptr->floor_id;
1032 else if (!preserve_mode) a_ptr->cur_num = 1;
1037 if (!drop_chosen_item) break;
1039 /* Get local object */
1042 /* Mega-Hack -- Prepare to make "Grond" */
1043 object_prep(q_ptr, lookup_kind(TV_HAFTED, SV_GROND));
1045 /* Mega-Hack -- Mark this item as "Grond" */
1046 q_ptr->name1 = ART_GROND;
1048 /* Mega-Hack -- Actually create "Grond" */
1049 apply_magic(q_ptr, -1, AM_GOOD | AM_GREAT);
1051 /* Drop it in the dungeon */
1052 (void)drop_near(q_ptr, -1, y, x);
1054 /* Get local object */
1057 /* Mega-Hack -- Prepare to make "Chaos" */
1058 object_prep(q_ptr, lookup_kind(TV_CROWN, SV_CHAOS));
1060 /* Mega-Hack -- Mark this item as "Chaos" */
1061 q_ptr->name1 = ART_CHAOS;
1063 /* Mega-Hack -- Actually create "Chaos" */
1064 apply_magic(q_ptr, -1, AM_GOOD | AM_GREAT);
1066 /* Drop it in the dungeon */
1067 (void)drop_near(q_ptr, -1, y, x);
1070 case MON_B_DEATH_SWORD:
1071 if (drop_chosen_item)
1073 /* Get local object */
1076 /* Prepare to make a broken sword */
1077 object_prep(q_ptr, lookup_kind(TV_SWORD, randint1(2)));
1079 /* Drop it in the dungeon */
1080 (void)drop_near(q_ptr, -1, y, x);
1086 if (drop_chosen_item && ((m_ptr->r_idx == MON_A_GOLD) ||
1087 ((m_ptr->r_idx == MON_A_SILVER) && (r_ptr->r_akills % 5 == 0))))
1089 /* Get local object */
1092 /* Prepare to make a Can of Toys */
1093 object_prep(q_ptr, lookup_kind(TV_CHEST, SV_CHEST_KANDUME));
1095 apply_magic(q_ptr, object_level, AM_NO_FIXED_ART);
1097 /* Drop it in the dungeon */
1098 (void)drop_near(q_ptr, -1, y, x);
1104 int flg = PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL;
1105 (void)project(m_idx, 3, y, x, damroll(20, 10), GF_FIRE, flg, -1);
1110 if (!drop_chosen_item) break;
1112 switch (r_ptr->d_char)
1117 /* Get local object */
1120 /* Wipe the object */
1123 /* Activate restriction */
1124 get_obj_num_hook = kind_is_cloak;
1127 make_object(q_ptr, mo_mode);
1129 /* Drop it in the dungeon */
1130 (void)drop_near(q_ptr, -1, y, x);
1137 /* Get local object */
1140 /* Wipe the object */
1143 /* Activate restriction */
1144 get_obj_num_hook = kind_is_polearm;
1146 /* Make a poleweapon */
1147 make_object(q_ptr, mo_mode);
1149 /* Drop it in the dungeon */
1150 (void)drop_near(q_ptr, -1, y, x);
1157 /* Get local object */
1160 /* Wipe the object */
1163 /* Activate restriction */
1164 get_obj_num_hook = kind_is_armor;
1166 /* Make a hard armor */
1167 make_object(q_ptr, mo_mode);
1169 /* Drop it in the dungeon */
1170 (void)drop_near(q_ptr, -1, y, x);
1177 /* Get local object */
1180 /* Wipe the object */
1183 /* Activate restriction */
1184 get_obj_num_hook = kind_is_hafted;
1186 /* Make a hafted weapon */
1187 make_object(q_ptr, mo_mode);
1189 /* Drop it in the dungeon */
1190 (void)drop_near(q_ptr, -1, y, x);
1195 if (m_ptr->r_idx != MON_STORMBRINGER)
1197 /* Get local object */
1200 /* Wipe the object */
1203 /* Activate restriction */
1204 get_obj_num_hook = kind_is_sword;
1207 make_object(q_ptr, mo_mode);
1209 /* Drop it in the dungeon */
1210 (void)drop_near(q_ptr, -1, y, x);
1217 /* Mega-Hack -- drop fixed items */
1218 if (drop_chosen_item)
1223 switch (m_ptr->r_idx)
1243 case MON_STORMBRINGER:
1244 a_idx = ART_STORMBRINGER;
1249 a_idx = ART_CRIMSON;
1259 a_idx = ART_KUSANAGI;
1289 a_idx = ART_WEREWINDLE;
1297 a_idx = ART_GRAYSWANDIR;
1308 a_idx = ART_TWILIGHT;
1313 a_idx = ART_ELENDIL;
1328 a_idx = ART_DESTINY;
1333 a_idx = ART_ZANTETSU;
1348 a_idx = ART_WINBLOWS;
1352 case MON_LUNGORTHIN:
1357 case MON_JACK_SHADOWS:
1363 a_idx = ART_STONEMASK;
1368 a_idx = ART_SOULCRUSH;
1373 a_idx = ART_EXCALIBUR_J;
1378 a_idx = ART_SHUTEN_DOJI;
1383 a_idx = ART_GOTHMOG;
1393 if ((a_idx > 0) && ((randint0(100) < chance) || p_ptr->wizard))
1395 artifact_type *a_ptr = &a_info[a_idx];
1397 if (!a_ptr->cur_num)
1399 /* Create the artifact */
1400 if (create_named_art(a_idx, y, x))
1404 /* Hack -- Memorize location of artifact in saved floors */
1405 if (character_dungeon) a_ptr->floor_id = p_ptr->floor_id;
1407 else if (!preserve_mode) a_ptr->cur_num = 1;
1411 if ((r_ptr->flags7 & RF7_GUARDIAN) && (d_info[dungeon_type].final_guardian == m_ptr->r_idx))
1413 int k_idx = d_info[dungeon_type].final_object ? d_info[dungeon_type].final_object
1414 : lookup_kind(TV_SCROLL, SV_SCROLL_ACQUIREMENT);
1416 if (d_info[dungeon_type].final_artifact)
1418 int a_idx = d_info[dungeon_type].final_artifact;
1419 artifact_type *a_ptr = &a_info[a_idx];
1421 if (!a_ptr->cur_num)
1423 /* Create the artifact */
1424 if (create_named_art(a_idx, y, x))
1428 /* Hack -- Memorize location of artifact in saved floors */
1429 if (character_dungeon) a_ptr->floor_id = p_ptr->floor_id;
1431 else if (!preserve_mode) a_ptr->cur_num = 1;
1433 /* Prevent rewarding both artifact and "default" object */
1434 if (!d_info[dungeon_type].final_object) k_idx = 0;
1440 /* Get local object */
1443 /* Prepare to make a reward */
1444 object_prep(q_ptr, k_idx);
1446 apply_magic(q_ptr, object_level, AM_NO_FIXED_ART | AM_GOOD);
1448 /* Drop it in the dungeon */
1449 (void)drop_near(q_ptr, -1, y, x);
1452 msg_format("¤¢¤Ê¤¿¤Ï%s¤òÀ©ÇƤ·¤¿¡ª",d_name+d_info[dungeon_type].name);
1454 msg_format("You have conquered %s!",d_name+d_info[dungeon_type].name);
1459 /* Determine how much we can drop */
1460 if ((r_ptr->flags1 & RF1_DROP_60) && (randint0(100) < 60)) number++;
1461 if ((r_ptr->flags1 & RF1_DROP_90) && (randint0(100) < 90)) number++;
1462 if (r_ptr->flags1 & RF1_DROP_1D2) number += damroll(1, 2);
1463 if (r_ptr->flags1 & RF1_DROP_2D2) number += damroll(2, 2);
1464 if (r_ptr->flags1 & RF1_DROP_3D2) number += damroll(3, 2);
1465 if (r_ptr->flags1 & RF1_DROP_4D2) number += damroll(4, 2);
1467 if (cloned && !(r_ptr->flags1 & RF1_UNIQUE))
1468 number = 0; /* Clones drop no stuff unless Cloning Pits */
1470 if (is_pet(m_ptr) || p_ptr->inside_battle || p_ptr->inside_arena)
1471 number = 0; /* Pets drop no stuff */
1472 if (!drop_item && (r_ptr->d_char != '$')) number = 0;
1474 /* Hack -- handle creeping coins */
1475 coin_type = force_coin;
1477 /* Average dungeon and monster levels */
1478 object_level = (dun_level + r_ptr->level) / 2;
1480 /* Drop some objects */
1481 for (j = 0; j < number; j++)
1483 /* Get local object */
1486 /* Wipe the object */
1490 if (do_gold && (!do_item || (randint0(100) < 50)))
1492 /* Make some gold */
1493 if (!make_gold(q_ptr)) continue;
1502 /* Make an object */
1503 if (!make_object(q_ptr, mo_mode)) continue;
1509 /* Drop it in the dungeon */
1510 (void)drop_near(q_ptr, -1, y, x);
1513 /* Reset the object level */
1514 object_level = base_level;
1516 /* Reset "coin" type */
1520 /* Take note of any dropped treasure */
1521 if (visible && (dump_item || dump_gold))
1523 /* Take notes on treasure */
1524 lore_treasure(m_idx, dump_item, dump_gold);
1527 /* Only process "Quest Monsters" */
1528 if (!(r_ptr->flags1 & RF1_QUESTOR)) return;
1529 if (p_ptr->inside_battle) return;
1532 if ((m_ptr->r_idx == MON_SERPENT) && !cloned)
1535 p_ptr->total_winner = TRUE;
1537 /* Redraw the "title" */
1538 p_ptr->redraw |= (PR_TITLE);
1541 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, "¸«»ö¤ËÊѶòÈÚÅܤξ¡Íø¼Ô¤È¤Ê¤Ã¤¿¡ª");
1543 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, "become *WINNER* of Hengband finely!");
1546 if ((p_ptr->pclass == CLASS_CHAOS_WARRIOR) || (p_ptr->muta2 & MUT2_CHAOS_GIFT))
1549 msg_format("%s¤«¤é¤ÎÀ¼¤¬¶Á¤¤¤¿¡£", chaos_patrons[p_ptr->chaos_patron]);
1550 msg_print("¡Ø¤è¤¯¤ä¤Ã¤¿¡¢ÄêÌ¿¤Î¼Ô¤è¡ª¡Ù");
1552 msg_format("The voice of %s booms out:", chaos_patrons[p_ptr->chaos_patron]);
1553 msg_print("'Thou art donst well, mortal!'");
1557 /* Congratulations */
1559 msg_print("*** ¤ª¤á¤Ç¤È¤¦ ***");
1561 msg_print("*** CONGRATULATIONS ***");
1565 msg_print("¤¢¤Ê¤¿¤Ï¥²¡¼¥à¤ò¥³¥ó¥×¥ê¡¼¥È¤·¤Þ¤·¤¿¡£");
1567 msg_print("You have won the game!");
1571 msg_print("½àÈ÷¤¬À°¤Ã¤¿¤é°úÂà(¼«»¦¥³¥Þ¥ó¥É)¤·¤Æ¤â·ë¹½¤Ç¤¹¡£");
1573 msg_print("You may retire (commit suicide) when you are ready.");
1579 * Modify the physical damage done to the monster.
1580 * (for example when it's invulnerable or shielded)
1582 * ToDo: Accept a damage-type to calculate the modified damage from
1583 * things like fire, frost, lightning, poison, ... attacks.
1585 * "type" is not yet used and should be 0.
1587 int mon_damage_mod(monster_type *m_ptr, int dam, bool is_psy_spear)
1589 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1591 if ((r_ptr->flagsr & RFR_RES_ALL) && dam > 0)
1594 if ((dam == 0) && one_in_(3)) dam = 1;
1597 if (MON_INVULNER(m_ptr))
1601 if (!p_ptr->blind && is_seen(m_ptr))
1604 msg_print("¥Ð¥ê¥¢¤òÀÚ¤êÎö¤¤¤¿¡ª");
1606 msg_print("The barrier is penetrated!");
1610 else if (!one_in_(PENETRATE_INVULNERABILITY))
1620 * Calculate experience point to be get
1622 * Even the 64 bit operation is not big enough to avoid overflaw
1623 * unless we carefully choose orders of multiplication and division.
1625 * Get the coefficient first, and multiply (potentially huge) base
1626 * experience point of a monster later.
1628 static void get_exp_from_mon(int dam, monster_type *m_ptr)
1630 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1637 if (!m_ptr->r_idx) return;
1638 if (is_pet(m_ptr) || p_ptr->inside_battle) return;
1641 * - Ratio of monster's level to player's level effects
1642 * - Varying speed effects
1643 * - Get a fraction in proportion of damage point
1645 new_exp = r_ptr->level * SPEED_TO_ENERGY(m_ptr->mspeed) * dam;
1648 div_l = (p_ptr->max_plv+2) * SPEED_TO_ENERGY(r_ptr->speed);
1650 /* Use (average maxhp * 2) as a denominator */
1651 if (!(r_ptr->flags1 & RF1_FORCE_MAXHP))
1652 s64b_mul(&div_h, &div_l, 0, r_ptr->hdice * (ironman_nightmare ? 2 : 1) * (r_ptr->hside + 1));
1654 s64b_mul(&div_h, &div_l, 0, r_ptr->hdice * (ironman_nightmare ? 2 : 1) * r_ptr->hside * 2);
1656 /* Special penalty in the wilderness */
1657 if (!dun_level && (!(r_ptr->flags8 & RF8_WILD_ONLY) || !(r_ptr->flags1 & RF1_UNIQUE)))
1658 s64b_mul(&div_h, &div_l, 0, 5);
1660 /* Do division first to prevent overflaw */
1661 s64b_div(&new_exp, &new_exp_frac, div_h, div_l);
1663 /* Special penalty for mutiply-monster */
1664 if ((r_ptr->flags2 & RF2_MULTIPLY) || (m_ptr->r_idx == MON_DAWN))
1666 int monnum_penarty = r_ptr->r_akills / 400;
1667 if (monnum_penarty > 8) monnum_penarty = 8;
1669 while (monnum_penarty--)
1672 s64b_RSHIFT(new_exp, new_exp_frac, 2);
1676 /* Finally multiply base experience point of the monster */
1677 s64b_mul(&new_exp, &new_exp_frac, 0, r_ptr->mexp);
1679 /* Gain experience */
1680 gain_exp_64(new_exp, new_exp_frac);
1685 * Decreases monsters hit points, handling monster death.
1687 * We return TRUE if the monster has been killed (and deleted).
1689 * We announce monster death (using an optional "death message"
1690 * if given, and a otherwise a generic killed/destroyed message).
1692 * Only "physical attacks" can induce the "You have slain" message.
1693 * Missile and Spell attacks will induce the "dies" message, or
1694 * various "specialized" messages. Note that "You have destroyed"
1695 * and "is destroyed" are synonyms for "You have slain" and "dies".
1697 * Hack -- unseen monsters yield "You have killed it." message.
1699 * Added fear (DGK) and check whether to print fear messages -CWS
1701 * Made name, sex, and capitalization generic -BEN-
1703 * As always, the "ghost" processing is a total hack.
1705 * Hack -- we "delay" fear messages by passing around a "fear" flag.
1707 * XXX XXX XXX Consider decreasing monster experience over time, say,
1708 * by using "(m_exp * m_lev * (m_lev)) / (p_lev * (m_lev + n_killed))"
1709 * instead of simply "(m_exp * m_lev) / (p_lev)", to make the first
1710 * monster worth more than subsequent monsters. This would also need
1711 * to induce changes in the monster recall code.
1713 bool mon_take_hit(int m_idx, int dam, bool *fear, cptr note)
1715 monster_type *m_ptr = &m_list[m_idx];
1716 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1718 monster_type exp_mon;
1720 /* Innocent until proven otherwise */
1721 bool innocent = TRUE, thief = FALSE;
1725 COPY(&exp_mon, m_ptr, monster_type);
1726 if (!(r_ptr->flags7 & RF7_KILL_EXP))
1728 expdam = (m_ptr->hp > dam) ? dam : m_ptr->hp;
1729 if (r_ptr->flags6 & RF6_HEAL) expdam = (expdam+1) * 2 / 3;
1731 get_exp_from_mon(expdam, &exp_mon);
1733 /* Genocided by chaos patron */
1734 if (!m_ptr->r_idx) m_idx = 0;
1737 /* Redraw (later) if needed */
1738 if (p_ptr->health_who == m_idx) p_ptr->redraw |= (PR_HEALTH);
1739 if (p_ptr->riding == m_idx) p_ptr->redraw |= (PR_UHEALTH);
1742 (void)set_monster_csleep(m_idx, 0);
1744 /* Hack - Cancel any special player stealth magics. -LM- */
1745 if (p_ptr->special_defense & NINJA_S_STEALTH)
1747 set_superstealth(FALSE);
1750 /* Genocided by chaos patron */
1751 if (!m_idx) return TRUE;
1756 /* It is dead now */
1761 if (r_info[m_ptr->r_idx].flags7 & RF7_TANUKI)
1763 /* You might have unmasked Tanuki first time */
1764 r_ptr = &r_info[m_ptr->r_idx];
1765 m_ptr->ap_r_idx = m_ptr->r_idx;
1766 if (r_ptr->r_sights < MAX_SHORT) r_ptr->r_sights++;
1769 if (m_ptr->mflag2 & MFLAG2_CHAMELEON)
1771 /* You might have unmasked Chameleon first time */
1772 r_ptr = real_r_ptr(m_ptr);
1773 if (r_ptr->r_sights < MAX_SHORT) r_ptr->r_sights++;
1776 if (!(m_ptr->smart & SM_CLONED))
1778 /* When the player kills a Unique, it stays dead */
1779 if (r_ptr->flags1 & RF1_UNIQUE)
1783 /* Mega-Hack -- Banor & Lupart */
1784 if ((m_ptr->r_idx == MON_BANOR) || (m_ptr->r_idx == MON_LUPART))
1786 r_info[MON_BANORLUPART].max_num = 0;
1787 r_info[MON_BANORLUPART].r_pkills++;
1788 r_info[MON_BANORLUPART].r_akills++;
1789 if (r_info[MON_BANORLUPART].r_tkills < MAX_SHORT) r_info[MON_BANORLUPART].r_tkills++;
1791 else if (m_ptr->r_idx == MON_BANORLUPART)
1793 r_info[MON_BANOR].max_num = 0;
1794 r_info[MON_BANOR].r_pkills++;
1795 r_info[MON_BANOR].r_akills++;
1796 if (r_info[MON_BANOR].r_tkills < MAX_SHORT) r_info[MON_BANOR].r_tkills++;
1797 r_info[MON_LUPART].max_num = 0;
1798 r_info[MON_LUPART].r_pkills++;
1799 r_info[MON_LUPART].r_akills++;
1800 if (r_info[MON_LUPART].r_tkills < MAX_SHORT) r_info[MON_LUPART].r_tkills++;
1804 /* When the player kills a Nazgul, it stays dead */
1805 else if (r_ptr->flags7 & RF7_NAZGUL) r_ptr->max_num--;
1808 /* Count all monsters killed */
1809 if (r_ptr->r_akills < MAX_SHORT) r_ptr->r_akills++;
1811 /* Recall even invisible uniques or winners */
1812 if ((m_ptr->ml && !p_ptr->image) || (r_ptr->flags1 & RF1_UNIQUE))
1814 /* Count kills this life */
1815 if ((m_ptr->mflag2 & MFLAG2_KAGE) && (r_info[MON_KAGE].r_pkills < MAX_SHORT)) r_info[MON_KAGE].r_pkills++;
1816 else if (r_ptr->r_pkills < MAX_SHORT) r_ptr->r_pkills++;
1818 /* Count kills in all lives */
1819 if ((m_ptr->mflag2 & MFLAG2_KAGE) && (r_info[MON_KAGE].r_tkills < MAX_SHORT)) r_info[MON_KAGE].r_tkills++;
1820 else if (r_ptr->r_tkills < MAX_SHORT) r_ptr->r_tkills++;
1822 /* Hack -- Auto-recall */
1823 monster_race_track(m_ptr->ap_r_idx);
1826 /* Extract monster name */
1827 monster_desc(m_name, m_ptr, MD_TRUE_NAME);
1829 /* Don't kill Amberites */
1830 if ((r_ptr->flags3 & RF3_AMBERITE) && one_in_(2))
1832 int curses = 1 + randint1(3);
1833 bool stop_ty = FALSE;
1837 msg_format("%^s¤Ï¶²¤í¤·¤¤·ì¤Î¼ö¤¤¤ò¤¢¤Ê¤¿¤Ë¤«¤±¤¿¡ª", m_name);
1839 msg_format("%^s puts a terrible blood curse on you!", m_name);
1842 curse_equipment(100, 50);
1846 stop_ty = activate_ty_curse(stop_ty, &count);
1851 if (r_ptr->flags2 & RF2_CAN_SPEAK)
1853 char line_got[1024];
1855 /* Dump a message */
1857 if (!get_rnd_line("mondeath_j.txt", m_ptr->r_idx, line_got))
1859 if (!get_rnd_line("mondeath.txt", m_ptr->r_idx, line_got))
1862 msg_format("%^s %s", m_name, line_got);
1865 if (m_ptr->r_idx == MON_SERPENT)
1867 /* Make screen dump */
1868 screen_dump = make_screen_dump();
1873 if (!(d_info[dungeon_type].flags1 & DF1_BEGINNER))
1875 if (!dun_level && !ambush_flag && !p_ptr->inside_arena)
1877 chg_virtue(V_VALOUR, -1);
1879 else if (r_ptr->level > dun_level)
1881 if (randint1(10) <= (r_ptr->level - dun_level))
1882 chg_virtue(V_VALOUR, 1);
1884 if (r_ptr->level > 60)
1886 chg_virtue(V_VALOUR, 1);
1888 if (r_ptr->level >= 2 * (p_ptr->lev+1))
1889 chg_virtue(V_VALOUR, 2);
1892 if (r_ptr->flags1 & RF1_UNIQUE)
1894 if (r_ptr->flags3 & (RF3_EVIL | RF3_GOOD)) chg_virtue(V_HARMONY, 2);
1896 if (r_ptr->flags3 & RF3_GOOD)
1898 chg_virtue(V_UNLIFE, 2);
1899 chg_virtue(V_VITALITY, -2);
1902 if (one_in_(3)) chg_virtue(V_INDIVIDUALISM, -1);
1905 if (m_ptr->r_idx == MON_BEGGAR || m_ptr->r_idx == MON_LEPER)
1907 chg_virtue(V_COMPASSION, -1);
1910 if ((r_ptr->flags3 & RF3_GOOD) &&
1911 ((r_ptr->level) / 10 + (3 * dun_level) >= randint1(100)))
1912 chg_virtue(V_UNLIFE, 1);
1914 if (r_ptr->d_char == 'A')
1916 if (r_ptr->flags1 & RF1_UNIQUE)
1917 chg_virtue(V_FAITH, -2);
1918 else if ((r_ptr->level) / 10 + (3 * dun_level) >= randint1(100))
1920 if (r_ptr->flags3 & RF3_GOOD) chg_virtue(V_FAITH, -1);
1921 else chg_virtue(V_FAITH, 1);
1924 else if (r_ptr->flags3 & RF3_DEMON)
1926 if (r_ptr->flags1 & RF1_UNIQUE)
1927 chg_virtue(V_FAITH, 2);
1928 else if ((r_ptr->level) / 10 + (3 * dun_level) >= randint1(100))
1929 chg_virtue(V_FAITH, 1);
1932 if ((r_ptr->flags3 & RF3_UNDEAD) && (r_ptr->flags1 & RF1_UNIQUE))
1933 chg_virtue(V_VITALITY, 2);
1935 if (r_ptr->r_deaths)
1937 if (r_ptr->flags1 & RF1_UNIQUE)
1939 chg_virtue(V_HONOUR, 10);
1941 else if ((r_ptr->level) / 10 + (2 * dun_level) >= randint1(100))
1943 chg_virtue(V_HONOUR, 1);
1946 if ((r_ptr->flags2 & RF2_MULTIPLY) && (r_ptr->r_akills > 1000) && one_in_(10))
1948 chg_virtue(V_VALOUR, -1);
1951 for (i = 0; i < 4; i++)
1953 if (r_ptr->blow[i].d_dice != 0) innocent = FALSE; /* Murderer! */
1955 if ((r_ptr->blow[i].effect == RBE_EAT_ITEM)
1956 || (r_ptr->blow[i].effect == RBE_EAT_GOLD))
1958 thief = TRUE; /* Thief! */
1961 /* The new law says it is illegal to live in the dungeon */
1962 if (r_ptr->level != 0) innocent = FALSE;
1966 if (r_ptr->flags1 & RF1_UNIQUE)
1967 chg_virtue(V_JUSTICE, 3);
1968 else if (1+((r_ptr->level) / 10 + (2 * dun_level))
1970 chg_virtue(V_JUSTICE, 1);
1974 chg_virtue (V_JUSTICE, -1);
1977 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)))
1979 if (one_in_(4)) chg_virtue(V_NATURE, -1);
1982 if ((r_ptr->flags1 & RF1_UNIQUE) && record_destroy_uniq)
1986 sprintf(note_buf, "%s%s", r_name + r_ptr->name, (m_ptr->smart & SM_CLONED) ? "(¥¯¥í¡¼¥ó)" : "");
1988 sprintf(note_buf, "%s%s", r_name + r_ptr->name, (m_ptr->smart & SM_CLONED) ? "(Clone)" : "");
1990 do_cmd_write_nikki(NIKKI_UNIQUE, 0, note_buf);
1996 /* Death by Missile/Spell attack */
1999 msg_format("%^s%s", m_name, note);
2002 /* Death by physical attack -- invisible monster */
2003 else if (!m_ptr->ml)
2006 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
2007 msg_format("¤»¤Ã¤«¤¯¤À¤«¤é%s¤ò»¦¤·¤¿¡£", m_name);
2009 msg_format("%s¤ò»¦¤·¤¿¡£", m_name);
2011 msg_format("You have killed %s.", m_name);
2016 /* Death by Physical attack -- non-living monster */
2017 else if (!monster_living(r_ptr))
2020 bool explode = FALSE;
2022 for (i = 0; i < 4; i++)
2024 if (r_ptr->blow[i].method == RBM_EXPLODE) explode = TRUE;
2027 /* Special note at death */
2030 msg_format("%s¤ÏÇúȯ¤·¤ÆÊ´¡¹¤Ë¤Ê¤Ã¤¿¡£", m_name);
2032 msg_format("%^s explodes into tiny shreds.", m_name);
2037 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
2038 msg_format("¤»¤Ã¤«¤¯¤À¤«¤é%s¤òÅݤ·¤¿¡£", m_name);
2040 msg_format("%s¤òÅݤ·¤¿¡£", m_name);
2042 msg_format("You have destroyed %s.", m_name);
2047 /* Death by Physical attack -- living monster */
2051 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
2052 msg_format("¤»¤Ã¤«¤¯¤À¤«¤é%s¤òÁò¤êµî¤Ã¤¿¡£", m_name);
2054 msg_format("%s¤òÁò¤êµî¤Ã¤¿¡£", m_name);
2056 msg_format("You have slain %s.", m_name);
2060 if ((r_ptr->flags1 & RF1_UNIQUE) && !(m_ptr->smart & SM_CLONED) && !vanilla_town)
2062 for (i = 0; i < MAX_KUBI; i++)
2064 if ((kubi_r_idx[i] == m_ptr->r_idx) && !(m_ptr->mflag2 & MFLAG2_CHAMELEON))
2067 msg_format("%s¤Î¼ó¤Ë¤Ï¾Þ¶â¤¬¤«¤«¤Ã¤Æ¤¤¤ë¡£", m_name);
2069 msg_format("There is a price on %s's head.", m_name);
2076 /* Generate treasure */
2077 monster_death(m_idx, TRUE);
2079 /* Mega hack : replace IKETA to BIKETAL */
2080 if ((m_ptr->r_idx == MON_IKETA) &&
2081 !(p_ptr->inside_arena || p_ptr->inside_battle))
2083 int dummy_y = m_ptr->fy;
2084 int dummy_x = m_ptr->fx;
2087 if (is_pet(m_ptr)) mode |= PM_FORCE_PET;
2089 /* Delete the monster */
2090 delete_monster_idx(m_idx);
2092 if (summon_named_creature(0, dummy_y, dummy_x, MON_BIKETAL, mode))
2095 msg_print("¡Ö¥Ï¥¡¥Ã¥Ï¥Ã¥Ï¥Ã¥Ï¡ª¡ª»ä¤¬¥Ð¥¤¥±¥¿¥ë¤À¡ª¡ª¡×");
2097 msg_print("Uwa-hahaha! *I* am Biketal!");
2103 /* Delete the monster */
2104 delete_monster_idx(m_idx);
2107 /* Prevent bug of chaos patron's reward */
2108 if (r_ptr->flags7 & RF7_KILL_EXP)
2109 get_exp_from_mon((long)exp_mon.max_maxhp*2, &exp_mon);
2111 get_exp_from_mon(((long)exp_mon.max_maxhp+1L) * 9L / 10L, &exp_mon);
2116 /* Monster is dead */
2123 /* Mega-Hack -- Pain cancels fear */
2124 if (MON_MONFEAR(m_ptr) && (dam > 0))
2127 if (set_monster_monfear(m_idx, MON_MONFEAR(m_ptr) - randint1(dam)))
2134 /* Sometimes a monster gets scared by damage */
2135 if (!MON_MONFEAR(m_ptr) && !(r_ptr->flags3 & (RF3_NO_FEAR)))
2137 /* Percentage of fully healthy */
2138 int percentage = (100L * m_ptr->hp) / m_ptr->maxhp;
2141 * Run (sometimes) if at 10% or less of max hit points,
2142 * or (usually) when hit for half its current hit points
2144 if ((randint1(10) >= percentage) ||
2145 ((dam >= m_ptr->hp) && (randint0(100) < 80)))
2147 /* Hack -- note fear */
2150 /* XXX XXX XXX Hack -- Add some timed fear */
2151 (void)set_monster_monfear(m_idx, (randint1(10) +
2152 (((dam >= m_ptr->hp) && (percentage > 7)) ?
2153 20 : ((11 - percentage) * 5))));
2160 if (p_ptr->riding && (p_ptr->riding == m_idx) && (dam > 0))
2164 /* Extract monster name */
2165 monster_desc(m_name, m_ptr, 0);
2167 if (m_ptr->hp > m_ptr->maxhp/3) dam = (dam + 1) / 2;
2168 if (rakuba((dam > 200) ? 200 : dam, FALSE))
2171 msg_format("%^s¤Ë¿¶¤êÍî¤È¤µ¤ì¤¿¡ª", m_name);
2173 msg_format("%^s has thrown you off!", m_name);
2185 * Get term size and calculate screen size
2187 void get_screen_size(int *wid_p, int *hgt_p)
2189 Term_get_size(wid_p, hgt_p);
2190 *hgt_p -= ROW_MAP + 2;
2191 *wid_p -= COL_MAP + 2;
2192 if (use_bigtile) *wid_p /= 2;
2197 * Calculates current boundaries
2198 * Called below and from "do_cmd_locate()".
2200 void panel_bounds_center(void)
2205 get_screen_size(&wid, &hgt);
2207 panel_row_max = panel_row_min + hgt - 1;
2208 panel_row_prt = panel_row_min - 1;
2209 panel_col_max = panel_col_min + wid - 1;
2210 panel_col_prt = panel_col_min - 13;
2215 * Map resizing whenever the main term changes size
2217 void resize_map(void)
2219 /* Only if the dungeon exists */
2220 if (!character_dungeon) return;
2222 /* Mega-Hack -- no panel yet */
2226 /* Reset the panels */
2227 panel_row_min = cur_hgt;
2228 panel_col_min = cur_wid;
2233 p_ptr->update |= (PU_TORCH | PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
2235 /* Forget lite/view */
2236 p_ptr->update |= (PU_UN_VIEW | PU_UN_LITE);
2238 /* Update lite/view */
2239 p_ptr->update |= (PU_VIEW | PU_LITE | PU_MON_LITE);
2241 /* Update monsters */
2242 p_ptr->update |= (PU_MONSTERS);
2244 /* Redraw everything */
2245 p_ptr->redraw |= (PR_WIPE | PR_BASIC | PR_EXTRA | PR_MAP | PR_EQUIPPY);
2247 /* Hack -- update */
2255 * Place the cursor on the player
2257 if (can_save) move_cursor_relative(py, px);
2264 * Redraw a term when it is resized
2266 void redraw_window(void)
2268 /* Only if the dungeon exists */
2269 if (!character_dungeon) return;
2272 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_SPELL | PW_PLAYER);
2275 p_ptr->window |= (PW_MESSAGE | PW_OVERHEAD | PW_DUNGEON | PW_MONSTER | PW_OBJECT);
2277 /* Hack -- update */
2286 * Handle a request to change the current panel
2288 * Return TRUE if the panel was changed.
2290 * Also used in do_cmd_locate
2292 bool change_panel(int dy, int dx)
2298 get_screen_size(&wid, &hgt);
2300 /* Apply the motion */
2301 y = panel_row_min + dy * hgt / 2;
2302 x = panel_col_min + dx * wid / 2;
2304 /* Verify the row */
2305 if (y > cur_hgt - hgt) y = cur_hgt - hgt;
2308 /* Verify the col */
2309 if (x > cur_wid - wid) x = cur_wid - wid;
2312 /* Handle "changes" */
2313 if ((y != panel_row_min) || (x != panel_col_min))
2315 /* Save the new panel info */
2319 /* Recalculate the boundaries */
2320 panel_bounds_center();
2323 p_ptr->update |= (PU_MONSTERS);
2326 p_ptr->redraw |= (PR_MAP);
2341 * Given an row (y) and col (x), this routine detects when a move
2342 * off the screen has occurred and figures new borders. -RAK-
2344 * "Update" forces a "full update" to take place.
2346 * The map is reprinted if necessary, and "TRUE" is returned.
2348 void verify_panel(void)
2360 get_screen_size(&wid, &hgt);
2362 max_prow_min = cur_hgt - hgt;
2363 max_pcol_min = cur_wid - wid;
2365 /* Bounds checking */
2366 if (max_prow_min < 0) max_prow_min = 0;
2367 if (max_pcol_min < 0) max_pcol_min = 0;
2369 /* Center on player */
2370 if (center_player && (center_running || !running))
2372 /* Center vertically */
2373 prow_min = y - hgt / 2;
2374 if (prow_min < 0) prow_min = 0;
2375 else if (prow_min > max_prow_min) prow_min = max_prow_min;
2377 /* Center horizontally */
2378 pcol_min = x - wid / 2;
2379 if (pcol_min < 0) pcol_min = 0;
2380 else if (pcol_min > max_pcol_min) pcol_min = max_pcol_min;
2384 prow_min = panel_row_min;
2385 pcol_min = panel_col_min;
2387 /* Scroll screen when 2 grids from top/bottom edge */
2388 if (y > panel_row_max - 2)
2390 while (y > prow_min + hgt-1 - 2)
2392 prow_min += (hgt / 2);
2396 if (y < panel_row_min + 2)
2398 while (y < prow_min + 2)
2400 prow_min -= (hgt / 2);
2404 if (prow_min > max_prow_min) prow_min = max_prow_min;
2405 if (prow_min < 0) prow_min = 0;
2407 /* Scroll screen when 4 grids from left/right edge */
2408 if (x > panel_col_max - 4)
2410 while (x > pcol_min + wid-1 - 4)
2412 pcol_min += (wid / 2);
2416 if (x < panel_col_min + 4)
2418 while (x < pcol_min + 4)
2420 pcol_min -= (wid / 2);
2424 if (pcol_min > max_pcol_min) pcol_min = max_pcol_min;
2425 if (pcol_min < 0) pcol_min = 0;
2428 /* Check for "no change" */
2429 if ((prow_min == panel_row_min) && (pcol_min == panel_col_min)) return;
2431 /* Save the new panel info */
2432 panel_row_min = prow_min;
2433 panel_col_min = pcol_min;
2435 /* Hack -- optional disturb on "panel change" */
2436 if (disturb_panel && !center_player) disturb(0, 0);
2438 /* Recalculate the boundaries */
2439 panel_bounds_center();
2442 p_ptr->update |= (PU_MONSTERS);
2445 p_ptr->redraw |= (PR_MAP);
2448 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
2453 * Monster health description
2455 cptr look_mon_desc(monster_type *m_ptr, u32b mode)
2457 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
2464 /* Determine if the monster is "living" */
2465 living = monster_living(ap_r_ptr);
2467 /* Calculate a health "percentage" */
2468 perc = 100L * m_ptr->hp / m_ptr->maxhp;
2470 /* Healthy monsters */
2471 if (m_ptr->hp >= m_ptr->maxhp)
2475 desc = living ? "̵½ý" : "̵¥À¥á¡¼¥¸";
2477 desc = living ? "unhurt" : "undamaged";
2482 else if (perc >= 60)
2485 desc = living ? "·Ú½ý" : "¾®¥À¥á¡¼¥¸";
2487 desc = living ? "somewhat wounded" : "somewhat damaged";
2492 else if (perc >= 25)
2495 desc = living ? "Éé½ý" : "Ãæ¥À¥á¡¼¥¸";
2497 desc = living ? "wounded" : "damaged";
2502 else if (perc >= 10)
2505 desc = living ? "½Å½ý" : "Âç¥À¥á¡¼¥¸";
2507 desc = living ? "badly wounded" : "badly damaged";
2515 desc = living ? "Ⱦ»àȾÀ¸" : "Åݤ줫¤±";
2517 desc = living ? "almost dead" : "almost destroyed";
2522 /* Need attitude information? */
2525 /* Full information is not needed */
2528 else if (is_pet(m_ptr))
2531 attitude = ", ¥Ú¥Ã¥È";
2536 else if (is_friendly(m_ptr))
2539 attitude = ", ͧ¹¥Åª";
2541 attitude = ", friendly";
2554 /* Clone monster? */
2555 if (m_ptr->smart & SM_CLONED)
2564 /* Display monster's level --- idea borrowed from ToME */
2565 if (ap_r_ptr->r_tkills && !(m_ptr->mflag2 & MFLAG2_KAGE))
2568 return format("¥ì¥Ù¥ë%d, %s%s%s", ap_r_ptr->level, desc, attitude, clone);
2570 return format("Level %d, %s%s%s", ap_r_ptr->level, desc, attitude, clone);
2576 return format("¥ì¥Ù¥ë???, %s%s%s", desc, attitude, clone);
2578 return format("Level ???, %s%s%s", desc, attitude, clone);
2586 * Angband sorting algorithm -- quick sort in place
2588 * Note that the details of the data we are sorting is hidden,
2589 * and we rely on the "ang_sort_comp()" and "ang_sort_swap()"
2590 * function hooks to interact with the data, which is given as
2591 * two pointers, and which may have any user-defined form.
2593 void ang_sort_aux(vptr u, vptr v, int p, int q)
2611 while (!(*ang_sort_comp)(u, v, b, z)) b--;
2614 while (!(*ang_sort_comp)(u, v, z, a)) a++;
2616 /* Done partition */
2620 (*ang_sort_swap)(u, v, a, b);
2626 /* Recurse left side */
2627 ang_sort_aux(u, v, p, b);
2629 /* Recurse right side */
2630 ang_sort_aux(u, v, b+1, q);
2635 * Angband sorting algorithm -- quick sort in place
2637 * Note that the details of the data we are sorting is hidden,
2638 * and we rely on the "ang_sort_comp()" and "ang_sort_swap()"
2639 * function hooks to interact with the data, which is given as
2640 * two pointers, and which may have any user-defined form.
2642 void ang_sort(vptr u, vptr v, int n)
2644 /* Sort the array */
2645 ang_sort_aux(u, v, 0, n-1);
2650 /*** Targeting Code ***/
2654 * Determine is a monster makes a reasonable target
2656 * The concept of "targeting" was stolen from "Morgul" (?)
2658 * The player can target any location, or any "target-able" monster.
2660 * Currently, a monster is "target_able" if it is visible, and if
2661 * the player can hit it with a projection, and the player is not
2662 * hallucinating. This allows use of "use closest target" macros.
2664 * Future versions may restrict the ability to target "trappers"
2665 * and "mimics", but the semantics is a little bit weird.
2667 bool target_able(int m_idx)
2669 monster_type *m_ptr = &m_list[m_idx];
2671 /* Monster must be alive */
2672 if (!m_ptr->r_idx) return (FALSE);
2674 /* Hack -- no targeting hallucinations */
2675 if (p_ptr->image) return (FALSE);
2677 /* Monster must be visible */
2678 if (!m_ptr->ml) return (FALSE);
2680 if (p_ptr->riding && (p_ptr->riding == m_idx)) return (TRUE);
2682 /* Monster must be projectable */
2683 if (!projectable(py, px, m_ptr->fy, m_ptr->fx)) return (FALSE);
2685 /* XXX XXX XXX Hack -- Never target trappers */
2686 /* if (CLEAR_ATTR && (CLEAR_CHAR)) return (FALSE); */
2696 * Update (if necessary) and verify (if possible) the target.
2698 * We return TRUE if the target is "okay" and FALSE otherwise.
2700 bool target_okay(void)
2702 /* Accept stationary targets */
2703 if (target_who < 0) return (TRUE);
2705 /* Check moving targets */
2708 /* Accept reasonable targets */
2709 if (target_able(target_who))
2711 monster_type *m_ptr = &m_list[target_who];
2713 /* Acquire monster location */
2714 target_row = m_ptr->fy;
2715 target_col = m_ptr->fx;
2722 /* Assume no target */
2728 * Sorting hook -- comp function -- by "distance to player"
2730 * We use "u" and "v" to point to arrays of "x" and "y" positions,
2731 * and sort the arrays by double-distance to the player.
2733 static bool ang_sort_comp_distance(vptr u, vptr v, int a, int b)
2735 byte *x = (byte*)(u);
2736 byte *y = (byte*)(v);
2740 /* Absolute distance components */
2741 kx = x[a]; kx -= px; kx = ABS(kx);
2742 ky = y[a]; ky -= py; ky = ABS(ky);
2744 /* Approximate Double Distance to the first point */
2745 da = ((kx > ky) ? (kx + kx + ky) : (ky + ky + kx));
2747 /* Absolute distance components */
2748 kx = x[b]; kx -= px; kx = ABS(kx);
2749 ky = y[b]; ky -= py; ky = ABS(ky);
2751 /* Approximate Double Distance to the first point */
2752 db = ((kx > ky) ? (kx + kx + ky) : (ky + ky + kx));
2754 /* Compare the distances */
2760 * Sorting hook -- comp function -- by importance level of grids
2762 * We use "u" and "v" to point to arrays of "x" and "y" positions,
2763 * and sort the arrays by level of monster
2765 static bool ang_sort_comp_importance(vptr u, vptr v, int a, int b)
2767 byte *x = (byte*)(u);
2768 byte *y = (byte*)(v);
2769 cave_type *ca_ptr = &cave[y[a]][x[a]];
2770 cave_type *cb_ptr = &cave[y[b]][x[b]];
2771 monster_type *ma_ptr = &m_list[ca_ptr->m_idx];
2772 monster_type *mb_ptr = &m_list[cb_ptr->m_idx];
2773 monster_race *ap_ra_ptr, *ap_rb_ptr;
2775 /* The player grid */
2776 if (y[a] == py && x[a] == px) return TRUE;
2777 if (y[b] == py && x[b] == px) return FALSE;
2779 /* Extract monster race */
2780 if (ca_ptr->m_idx && ma_ptr->ml) ap_ra_ptr = &r_info[ma_ptr->ap_r_idx];
2781 else ap_ra_ptr = NULL;
2782 if (cb_ptr->m_idx && mb_ptr->ml) ap_rb_ptr = &r_info[mb_ptr->ap_r_idx];
2783 else ap_rb_ptr = NULL;
2785 if (ap_ra_ptr && !ap_rb_ptr) return TRUE;
2786 if (!ap_ra_ptr && ap_rb_ptr) return FALSE;
2788 /* Compare two monsters */
2789 if (ap_ra_ptr && ap_rb_ptr)
2791 /* Unique monsters first */
2792 if ((ap_ra_ptr->flags1 & RF1_UNIQUE) && !(ap_rb_ptr->flags1 & RF1_UNIQUE)) return TRUE;
2793 if (!(ap_ra_ptr->flags1 & RF1_UNIQUE) && (ap_rb_ptr->flags1 & RF1_UNIQUE)) return FALSE;
2795 /* Shadowers first (¤¢¤ä¤·¤¤±Æ) */
2796 if ((ma_ptr->mflag2 & MFLAG2_KAGE) && !(mb_ptr->mflag2 & MFLAG2_KAGE)) return TRUE;
2797 if (!(ma_ptr->mflag2 & MFLAG2_KAGE) && (mb_ptr->mflag2 & MFLAG2_KAGE)) return FALSE;
2799 /* Unknown monsters first */
2800 if (!ap_ra_ptr->r_tkills && ap_rb_ptr->r_tkills) return TRUE;
2801 if (ap_ra_ptr->r_tkills && !ap_rb_ptr->r_tkills) return FALSE;
2803 /* Higher level monsters first (if known) */
2804 if (ap_ra_ptr->r_tkills && ap_rb_ptr->r_tkills)
2806 if (ap_ra_ptr->level > ap_rb_ptr->level) return TRUE;
2807 if (ap_ra_ptr->level < ap_rb_ptr->level) return FALSE;
2810 /* Sort by index if all conditions are same */
2811 if (ma_ptr->ap_r_idx > mb_ptr->ap_r_idx) return TRUE;
2812 if (ma_ptr->ap_r_idx < mb_ptr->ap_r_idx) return FALSE;
2815 /* An object get higher priority */
2816 if (cave[y[a]][x[a]].o_idx && !cave[y[b]][x[b]].o_idx) return TRUE;
2817 if (!cave[y[a]][x[a]].o_idx && cave[y[b]][x[b]].o_idx) return FALSE;
2819 /* Priority from the terrain */
2820 if (f_info[ca_ptr->feat].priority > f_info[cb_ptr->feat].priority) return TRUE;
2821 if (f_info[ca_ptr->feat].priority < f_info[cb_ptr->feat].priority) return FALSE;
2823 /* If all conditions are same, compare distance */
2824 return ang_sort_comp_distance(u, v, a, b);
2829 * Sorting hook -- swap function -- by "distance to player"
2831 * We use "u" and "v" to point to arrays of "x" and "y" positions,
2832 * and sort the arrays by distance to the player.
2834 static void ang_sort_swap_distance(vptr u, vptr v, int a, int b)
2836 byte *x = (byte*)(u);
2837 byte *y = (byte*)(v);
2855 * Hack -- help "select" a location (see below)
2857 static s16b target_pick(int y1, int x1, int dy, int dx)
2861 int x2, y2, x3, y3, x4, y4;
2863 int b_i = -1, b_v = 9999;
2866 /* Scan the locations */
2867 for (i = 0; i < temp_n; i++)
2873 /* Directed distance */
2877 /* Verify quadrant */
2878 if (dx && (x3 * dx <= 0)) continue;
2879 if (dy && (y3 * dy <= 0)) continue;
2881 /* Absolute distance */
2885 /* Verify quadrant */
2886 if (dy && !dx && (x4 > y4)) continue;
2887 if (dx && !dy && (y4 > x4)) continue;
2889 /* Approximate Double Distance */
2890 v = ((x4 > y4) ? (x4 + x4 + y4) : (y4 + y4 + x4));
2892 /* XXX XXX XXX Penalize location */
2895 if ((b_i >= 0) && (v >= b_v)) continue;
2907 * Hack -- determine if a given location is "interesting"
2909 static bool target_set_accept(int y, int x)
2913 s16b this_o_idx, next_o_idx = 0;
2916 if (!(in_bounds(y, x))) return (FALSE);
2918 /* Player grid is always interesting */
2919 if (player_bold(y, x)) return (TRUE);
2922 /* Handle hallucination */
2923 if (p_ptr->image) return (FALSE);
2926 /* Examine the grid */
2927 c_ptr = &cave[y][x];
2929 /* Visible monsters */
2932 monster_type *m_ptr = &m_list[c_ptr->m_idx];
2934 /* Visible monsters */
2935 if (m_ptr->ml) return (TRUE);
2938 /* Scan all objects in the grid */
2939 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
2943 /* Acquire object */
2944 o_ptr = &o_list[this_o_idx];
2946 /* Acquire next object */
2947 next_o_idx = o_ptr->next_o_idx;
2949 /* Memorized object */
2950 if (o_ptr->marked & OM_FOUND) return (TRUE);
2953 /* Interesting memorized features */
2954 if (c_ptr->info & (CAVE_MARK))
2956 /* Notice object features */
2957 if (c_ptr->info & CAVE_OBJECT) return (TRUE);
2959 /* Feature code (applying "mimic" field) */
2960 if (have_flag(f_info[get_feat_mimic(c_ptr)].flags, FF_NOTICE)) return TRUE;
2969 * Prepare the "temp" array for "target_set"
2971 * Return the number of target_able monsters in the set.
2973 static void target_set_prepare(int mode)
2977 /* Reset "temp" array */
2980 /* Scan the current panel */
2981 for (y = panel_row_min; y <= panel_row_max; y++)
2983 for (x = panel_col_min; x <= panel_col_max; x++)
2987 /* Require "interesting" contents */
2988 if (!target_set_accept(y, x)) continue;
2990 c_ptr = &cave[y][x];
2992 /* Require target_able monsters for "TARGET_KILL" */
2993 if ((mode & (TARGET_KILL)) && !target_able(c_ptr->m_idx)) continue;
2995 if ((mode & (TARGET_KILL)) && !target_pet && is_pet(&m_list[c_ptr->m_idx])) continue;
2997 /* Save the location */
3004 /* Set the sort hooks */
3005 if (mode & (TARGET_KILL))
3007 /* Target the nearest monster for shooting */
3008 ang_sort_comp = ang_sort_comp_distance;
3009 ang_sort_swap = ang_sort_swap_distance;
3013 /* Look important grids first in Look command */
3014 ang_sort_comp = ang_sort_comp_importance;
3015 ang_sort_swap = ang_sort_swap_distance;
3018 /* Sort the positions */
3019 ang_sort(temp_x, temp_y, temp_n);
3021 if (p_ptr->riding && target_pet && (temp_n > 1) && (mode & (TARGET_KILL)))
3026 temp_y[0] = temp_y[1];
3029 temp_x[0] = temp_x[1];
3036 * Evaluate number of kill needed to gain level
3038 static void evaluate_monster_exp(char *buf, monster_type *m_ptr)
3040 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
3042 s32b exp_mon, exp_adv;
3043 u32b exp_mon_frac, exp_adv_frac;
3045 if ((p_ptr->lev >= PY_MAX_LEVEL) || (p_ptr->prace == RACE_ANDROID))
3050 else if (!ap_r_ptr->r_tkills || (m_ptr->mflag2 & MFLAG2_KAGE))
3060 /* The monster's experience point (assuming average monster speed) */
3061 exp_mon = ap_r_ptr->mexp * ap_r_ptr->level;
3063 s64b_div(&exp_mon, &exp_mon_frac, 0, (p_ptr->max_plv + 2));
3066 /* Total experience value for next level */
3067 exp_adv = player_exp[p_ptr->lev -1] * p_ptr->expfact;
3069 s64b_div(&exp_adv, &exp_adv_frac, 0, 100);
3071 /* Experience value need to get */
3072 s64b_sub(&exp_adv, &exp_adv_frac, p_ptr->exp, p_ptr->exp_frac);
3075 /* You need to kill at least one monster to get any experience */
3076 s64b_add(&exp_adv, &exp_adv_frac, exp_mon, exp_mon_frac);
3077 s64b_sub(&exp_adv, &exp_adv_frac, 0, 1);
3079 /* Extract number of monsters needed */
3080 s64b_div(&exp_adv, &exp_adv_frac, exp_mon, exp_mon_frac);
3082 /* If 999 or more monsters needed, only display "999". */
3083 num = MIN(999, exp_adv_frac);
3085 /* Display the number */
3086 sprintf(buf,"%03ld", num);
3090 bool show_gold_on_floor = FALSE;
3093 * Examine a grid, return a keypress.
3095 * The "mode" argument contains the "TARGET_LOOK" bit flag, which
3096 * indicates that the "space" key should scan through the contents
3097 * of the grid, instead of simply returning immediately. This lets
3098 * the "look" command get complete information, without making the
3099 * "target" command annoying.
3101 * The "info" argument contains the "commands" which should be shown
3102 * inside the "[xxx]" text. This string must never be empty, or grids
3103 * containing monsters will be displayed with an extra comma.
3105 * Note that if a monster is in the grid, we update both the monster
3106 * recall info and the health bar info to track that monster.
3108 * Eventually, we may allow multiple objects per grid, or objects
3109 * and terrain features in the same grid. XXX XXX XXX
3111 * This function must handle blindness/hallucination.
3113 static int target_set_aux(int y, int x, int mode, cptr info)
3115 cave_type *c_ptr = &cave[y][x];
3116 s16b this_o_idx, next_o_idx = 0;
3117 cptr s1 = "", s2 = "", s3 = "", x_info = "";
3120 feature_type *f_ptr;
3122 char out_val[MAX_NLEN+80];
3124 #ifdef ALLOW_EASY_FLOOR
3125 int floor_list[23], floor_num = 0;
3127 /* Scan all objects in the grid */
3130 floor_num = scan_floor(floor_list, y, x, 0x02);
3142 #endif /* ALLOW_EASY_FLOOR */
3144 /* Hack -- under the player */
3145 if (player_bold(y, x))
3168 /* Hack -- hallucination */
3172 cptr name = "²¿¤«´ñ̯¤Êʪ";
3174 cptr name = "something strange";
3178 /* Display a message */
3180 sprintf(out_val, "%s%s%s%s [%s]", s1, name, s2, s3, info);
3182 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, name, info);
3186 move_cursor_relative(y, x);
3189 /* Stop on everything but "return" */
3190 if ((query != '\r') && (query != '\n')) return query;
3192 /* Repeat forever */
3197 /* Actual monsters */
3198 if (c_ptr->m_idx && m_list[c_ptr->m_idx].ml)
3200 monster_type *m_ptr = &m_list[c_ptr->m_idx];
3201 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
3203 bool recall = FALSE;
3208 /* Get the monster name ("a kobold") */
3209 monster_desc(m_name, m_ptr, MD_INDEF_VISIBLE);
3211 /* Hack -- track this monster race */
3212 monster_race_track(m_ptr->ap_r_idx);
3214 /* Hack -- health bar for this monster */
3215 health_track(c_ptr->m_idx);
3217 /* Hack -- handle stuff */
3231 /* Recall on screen */
3232 screen_roff(m_ptr->ap_r_idx, 0);
3234 /* Hack -- Complete the prompt (again) */
3236 Term_addstr(-1, TERM_WHITE, format(" [r»× %s%s]", x_info, info));
3238 Term_addstr(-1, TERM_WHITE, format(" [r,%s%s]", x_info, info));
3247 /* Normal commands */
3248 if (query != 'r') break;
3253 /* Cleare recall text and repeat */
3259 /* Describe, and prompt for recall */
3260 evaluate_monster_exp(acount, m_ptr);
3263 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);
3265 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);
3271 move_cursor_relative(y, x);
3276 /* Normal commands */
3277 if (query != 'r') break;
3283 /* Always stop at "normal" keys */
3284 if ((query != '\r') && (query != '\n') && (query != ' ') && (query != 'x')) return query;
3286 /* Sometimes stop at "space" key */
3287 if ((query == ' ') && !(mode & (TARGET_LOOK))) return query;
3289 /* Change the intro */
3297 /* Hack -- take account of gender */
3299 if (ap_r_ptr->flags1 & (RF1_FEMALE)) s1 = "Èà½÷¤Ï";
3301 if (ap_r_ptr->flags1 & (RF1_FEMALE)) s1 = "She is ";
3305 else if (ap_r_ptr->flags1 & (RF1_MALE)) s1 = "Èà¤Ï";
3307 else if (ap_r_ptr->flags1 & (RF1_MALE)) s1 = "He is ";
3311 /* Use a preposition */
3320 /* Scan all objects being carried */
3321 for (this_o_idx = m_ptr->hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
3323 char o_name[MAX_NLEN];
3327 /* Acquire object */
3328 o_ptr = &o_list[this_o_idx];
3330 /* Acquire next object */
3331 next_o_idx = o_ptr->next_o_idx;
3333 /* Obtain an object description */
3334 object_desc(o_name, o_ptr, 0);
3336 /* Describe the object */
3338 sprintf(out_val, "%s%s%s%s[%s]", s1, o_name, s2, s3, info);
3340 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, o_name, info);
3344 move_cursor_relative(y, x);
3347 /* Always stop at "normal" keys */
3348 if ((query != '\r') && (query != '\n') && (query != ' ') && (query != 'x')) return query;
3350 /* Sometimes stop at "space" key */
3351 if ((query == ' ') && !(mode & (TARGET_LOOK))) return query;
3353 /* Change the intro */
3357 s2 = "also carrying ";
3361 /* Use a preposition */
3371 #ifdef ALLOW_EASY_FLOOR
3380 char o_name[MAX_NLEN];
3384 /* Acquire object */
3385 o_ptr = &o_list[floor_list[0]];
3387 /* Describe the object */
3388 object_desc(o_name, o_ptr, 0);
3392 sprintf(out_val, "%s%s%s%s[%s]",
3393 s1, o_name, s2, s3, info);
3395 sprintf(out_val, "%s%s%s%s [%s]",
3396 s1, s2, s3, o_name, info);
3400 move_cursor_relative(y, x);
3409 /* Provide one cushion before item listing */
3412 /* Display rough information about items */
3414 sprintf(out_val, "%s %d¸Ä¤Î¥¢¥¤¥Æ¥à%s%s ['x'¤Ç°ìÍ÷, %s]",
3415 s1, floor_num, s2, s3, info);
3417 sprintf(out_val, "%s%s%sa pile of %d items [x,%s]",
3418 s1, s2, s3, floor_num, info);
3422 move_cursor_relative(y, x);
3427 /* No request for listing */
3428 if (query != 'x' && query != ' ') return query;
3432 /** Display list of items **/
3434 /* Continue scrolling list if requested */
3443 show_gold_on_floor = TRUE;
3444 (void)show_floor(0, y, x, &min_width);
3445 show_gold_on_floor = FALSE;
3449 sprintf(out_val, "%s %d¸Ä¤Î¥¢¥¤¥Æ¥à%s%s [Enter¤Ç¼¡¤Ø, %s]",
3450 s1, floor_num, s2, s3, info);
3452 sprintf(out_val, "%s%s%sa pile of %d items [Enter,%s]",
3453 s1, s2, s3, floor_num, info);
3464 /* Exit unless 'Enter' */
3465 if (query != '\n' && query != '\r')
3470 /* Get the object being moved. */
3471 o_idx = c_ptr->o_idx;
3473 /* Only rotate a pile of two or more objects. */
3474 if (!(o_idx && o_list[o_idx].next_o_idx)) continue;
3476 /* Remove the first object from the list. */
3477 excise_object_idx(o_idx);
3479 /* Find end of the list. */
3481 while (o_list[i].next_o_idx)
3482 i = o_list[i].next_o_idx;
3484 /* Add after the last object. */
3485 o_list[i].next_o_idx = o_idx;
3487 /* Loop and re-display the list */
3493 #endif /* ALLOW_EASY_FLOOR */
3496 /* Scan all objects in the grid */
3497 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
3501 /* Acquire object */
3502 o_ptr = &o_list[this_o_idx];
3504 /* Acquire next object */
3505 next_o_idx = o_ptr->next_o_idx;
3508 if (o_ptr->marked & OM_FOUND)
3510 char o_name[MAX_NLEN];
3515 /* Obtain an object description */
3516 object_desc(o_name, o_ptr, 0);
3518 /* Describe the object */
3520 sprintf(out_val, "%s%s%s%s[%s]", s1, o_name, s2, s3, info);
3522 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, o_name, info);
3526 move_cursor_relative(y, x);
3529 /* Always stop at "normal" keys */
3530 if ((query != '\r') && (query != '\n') && (query != ' ') && (query != 'x')) return query;
3532 /* Sometimes stop at "space" key */
3533 if ((query == ' ') && !(mode & TARGET_LOOK)) return query;
3535 /* Change the intro */
3545 if (o_ptr->number != 1) s1 = "¤½¤ì¤é¤Ï";
3547 if (o_ptr->number != 1) s1 = "They are ";
3563 /* Feature code (applying "mimic" field) */
3564 feat = get_feat_mimic(c_ptr);
3566 /* Require knowledge about grid, or ability to see grid */
3567 if (!(c_ptr->info & CAVE_MARK) && !player_can_see_bold(y, x))
3569 /* Forget feature */
3573 f_ptr = &f_info[feat];
3575 /* Terrain feature if needed */
3576 if (boring || have_flag(f_ptr->flags, FF_REMEMBER))
3580 /* Hack -- special handling for quest entrances */
3581 if (have_flag(f_ptr->flags, FF_QUEST_ENTER))
3583 /* Set the quest number temporary */
3584 int old_quest = p_ptr->inside_quest;
3587 /* Clear the text */
3588 for (j = 0; j < 10; j++) quest_text[j][0] = '\0';
3589 quest_text_line = 0;
3591 p_ptr->inside_quest = c_ptr->special;
3593 /* Get the quest text */
3594 init_flags = INIT_SHOW_TEXT;
3596 process_dungeon_file("q_info.txt", 0, 0, 0, 0);
3599 name = format("¥¯¥¨¥¹¥È¡Ö%s¡×(%d³¬ÁêÅö)", quest[c_ptr->special].name, quest[c_ptr->special].level);
3601 name = format("the entrance to the quest '%s'(level %d)", quest[c_ptr->special].name, quest[c_ptr->special].level);
3604 /* Reset the old quest number */
3605 p_ptr->inside_quest = old_quest;
3608 /* Hack -- special handling for building doors */
3609 else if (have_flag(f_ptr->flags, FF_BLDG) && !p_ptr->inside_arena)
3611 name = building[f_ptr->subtype].name;
3613 else if (have_flag(f_ptr->flags, FF_ENTRANCE))
3616 name = format("%s(%d³¬ÁêÅö)", d_text + d_info[c_ptr->special].text, d_info[c_ptr->special].mindepth);
3618 name = format("%s(level %d)", d_text + d_info[c_ptr->special].text, d_info[c_ptr->special].mindepth);
3621 else if (have_flag(f_ptr->flags, FF_TOWN))
3623 name = town[c_ptr->special].name;
3625 else if (p_ptr->wild_mode && (feat == feat_floor))
3635 name = f_name + f_ptr->name;
3641 ((!have_flag(f_ptr->flags, FF_MOVE) && !have_flag(f_ptr->flags, FF_CAN_FLY)) ||
3642 (!have_flag(f_ptr->flags, FF_LOS) && !have_flag(f_ptr->flags, FF_TREE)) ||
3643 have_flag(f_ptr->flags, FF_TOWN)))
3652 /* Hack -- special introduction for store & building doors -KMW- */
3653 if (have_flag(f_ptr->flags, FF_STORE) ||
3654 have_flag(f_ptr->flags, FF_QUEST_ENTER) ||
3655 (have_flag(f_ptr->flags, FF_BLDG) && !p_ptr->inside_arena) ||
3656 have_flag(f_ptr->flags, FF_ENTRANCE))
3665 else if (have_flag(f_ptr->flags, FF_FLOOR) ||
3666 have_flag(f_ptr->flags, FF_TOWN) ||
3667 have_flag(f_ptr->flags, FF_SHALLOW) ||
3668 have_flag(f_ptr->flags, FF_DEEP))
3674 /* Pick proper indefinite article */
3675 s3 = (is_a_vowel(name[0])) ? "an " : "a ";
3679 /* Display a message */
3683 if (c_ptr->mimic) sprintf(f_idx_str, "%d/%d", c_ptr->feat, c_ptr->mimic);
3684 else sprintf(f_idx_str, "%d", c_ptr->feat);
3686 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);
3688 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);
3693 sprintf(out_val, "%s%s%s%s[%s]", s1, name, s2, s3, info);
3695 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, name, info);
3699 move_cursor_relative(y, x);
3702 /* Always stop at "normal" keys */
3703 if ((query != '\r') && (query != '\n') && (query != ' ')) return query;
3706 /* Stop on everything but "return" */
3707 if ((query != '\r') && (query != '\n')) return query;
3709 /* Repeat forever */
3715 * Handle "target" and "look".
3717 * Note that this code can be called from "get_aim_dir()".
3719 * All locations must be on the current panel. Consider the use of
3720 * "panel_bounds()" to allow "off-panel" targets, perhaps by using
3721 * some form of "scrolling" the map around the cursor. XXX XXX XXX
3722 * That is, consider the possibility of "auto-scrolling" the screen
3723 * while the cursor moves around. This may require changes in the
3724 * "update_mon()" code to allow "visibility" even if off panel, and
3725 * may require dynamic recalculation of the "temp" grid set.
3727 * Hack -- targeting/observing an "outer border grid" may induce
3728 * problems, so this is not currently allowed.
3730 * The player can use the direction keys to move among "interesting"
3731 * grids in a heuristic manner, or the "space", "+", and "-" keys to
3732 * move through the "interesting" grids in a sequential manner, or
3733 * can enter "location" mode, and use the direction keys to move one
3734 * grid at a time in any direction. The "t" (set target) command will
3735 * only target a monster (as opposed to a location) if the monster is
3736 * target_able and the "interesting" mode is being used.
3738 * The current grid is described using the "look" method above, and
3739 * a new command may be entered at any time, but note that if the
3740 * "TARGET_LOOK" bit flag is set (or if we are in "location" mode,
3741 * where "space" has no obvious meaning) then "space" will scan
3742 * through the description of the current grid until done, instead
3743 * of immediately jumping to the next "interesting" grid. This
3744 * allows the "target" command to retain its old semantics.
3746 * The "*", "+", and "-" keys may always be used to jump immediately
3747 * to the next (or previous) interesting grid, in the proper mode.
3749 * The "return" key may always be used to scan through a complete
3750 * grid description (forever).
3752 * This command will cancel any old target, even if used from
3753 * inside the "look" command.
3755 bool target_set(int mode)
3775 get_screen_size(&wid, &hgt);
3781 /* Cancel tracking */
3782 /* health_track(0); */
3785 /* Prepare the "temp" array */
3786 target_set_prepare(mode);
3788 /* Start near the player */
3794 /* Interesting grids */
3800 if (!(mode & TARGET_LOOK)) prt_path(y, x);
3803 c_ptr = &cave[y][x];
3806 if (target_able(c_ptr->m_idx))
3809 strcpy(info, "q»ß t·è p¼« o¸½ +¼¡ -Á°");
3811 strcpy(info, "q,t,p,o,+,-,<dir>");
3816 /* Dis-allow target */
3820 strcpy(info, "q»ß p¼« o¸½ +¼¡ -Á°");
3822 strcpy(info, "q,p,o,+,-,<dir>");
3827 /* Describe and Prompt */
3828 while (!(query = target_set_aux(y, x, mode, info)));
3830 /* Cancel tracking */
3831 /* health_track(0); */
3833 /* Assume no "direction" */
3838 if (query == '\r') query = 't';
3856 if (target_able(c_ptr->m_idx))
3858 health_track(c_ptr->m_idx);
3859 target_who = c_ptr->m_idx;
3878 if (!expand_list) done = TRUE;
3888 if (!expand_list) done = TRUE;
3895 /* Recenter the map around the player */
3899 p_ptr->update |= (PU_MONSTERS);
3902 p_ptr->redraw |= (PR_MAP);
3905 p_ptr->window |= (PW_OVERHEAD);
3910 /* Recalculate interesting grids */
3911 target_set_prepare(mode);
3930 /* Extract the action (if any) */
3931 d = get_keymap_dir(query);
3938 /* Hack -- move around */
3941 /* Modified to scroll to monster */
3942 int y2 = panel_row_min;
3943 int x2 = panel_col_min;
3945 /* Find a new monster */
3946 i = target_pick(temp_y[m], temp_x[m], ddy[d], ddx[d]);
3948 /* Request to target past last interesting grid */
3949 while (flag && (i < 0))
3951 /* Note the change */
3952 if (change_panel(ddy[d], ddx[d]))
3957 /* Recalculate interesting grids */
3958 target_set_prepare(mode);
3960 /* Look at interesting grids */
3963 /* Find a new monster */
3964 i = target_pick(v, u, ddy[d], ddx[d]);
3970 /* Nothing interesting */
3976 /* Restore previous position */
3979 panel_bounds_center();
3982 p_ptr->update |= (PU_MONSTERS);
3985 p_ptr->redraw |= (PR_MAP);
3988 p_ptr->window |= (PW_OVERHEAD);
3993 /* Recalculate interesting grids */
3994 target_set_prepare(mode);
3996 /* Look at boring grids */
4003 /* Do not move horizontally if unnecessary */
4004 if (((x < panel_col_min + wid / 2) && (dx > 0)) ||
4005 ((x > panel_col_min + wid / 2) && (dx < 0)))
4010 /* Do not move vertically if unnecessary */
4011 if (((y < panel_row_min + hgt / 2) && (dy > 0)) ||
4012 ((y > panel_row_min + hgt / 2) && (dy < 0)))
4017 /* Apply the motion */
4018 if ((y >= panel_row_min+hgt) || (y < panel_row_min) ||
4019 (x >= panel_col_min+wid) || (x < panel_col_min))
4021 if (change_panel(dy, dx)) target_set_prepare(mode);
4024 /* Slide into legality */
4025 if (x >= cur_wid-1) x = cur_wid - 2;
4026 else if (x <= 0) x = 1;
4028 /* Slide into legality */
4029 if (y >= cur_hgt-1) y = cur_hgt- 2;
4030 else if (y <= 0) y = 1;
4039 /* Arbitrary grids */
4042 bool move_fast = FALSE;
4044 if (!(mode & TARGET_LOOK)) prt_path(y, x);
4047 c_ptr = &cave[y][x];
4049 /* Default prompt */
4051 strcpy(info, "q»ß t·è p¼« m¶á +¼¡ -Á°");
4053 strcpy(info, "q,t,p,m,+,-,<dir>");
4057 /* Describe and Prompt (enable "TARGET_LOOK") */
4058 while (!(query = target_set_aux(y, x, mode | TARGET_LOOK, info)));
4060 /* Cancel tracking */
4061 /* health_track(0); */
4063 /* Assume no direction */
4068 if (query == '\r') query = 't';
4071 /* Analyze the keypress */
4095 /* Recenter the map around the player */
4099 p_ptr->update |= (PU_MONSTERS);
4102 p_ptr->redraw |= (PR_MAP);
4105 p_ptr->window |= (PW_OVERHEAD);
4110 /* Recalculate interesting grids */
4111 target_set_prepare(mode);
4133 /* Pick a nearby monster */
4134 for (i = 0; i < temp_n; i++)
4136 t = distance(y, x, temp_y[i], temp_x[i]);
4146 /* Nothing interesting */
4147 if (bd == 999) flag = FALSE;
4154 /* Extract the action (if any) */
4155 d = get_keymap_dir(query);
4157 /* XTRA HACK MOVEFAST */
4158 if (isupper(query)) move_fast = TRUE;
4165 /* Handle "direction" */
4171 /* XTRA HACK MOVEFAST */
4174 int mag = MIN(wid / 2, hgt / 2);
4184 /* Do not move horizontally if unnecessary */
4185 if (((x < panel_col_min + wid / 2) && (dx > 0)) ||
4186 ((x > panel_col_min + wid / 2) && (dx < 0)))
4191 /* Do not move vertically if unnecessary */
4192 if (((y < panel_row_min + hgt / 2) && (dy > 0)) ||
4193 ((y > panel_row_min + hgt / 2) && (dy < 0)))
4198 /* Apply the motion */
4199 if ((y >= panel_row_min + hgt) || (y < panel_row_min) ||
4200 (x >= panel_col_min + wid) || (x < panel_col_min))
4202 if (change_panel(dy, dx)) target_set_prepare(mode);
4205 /* Slide into legality */
4206 if (x >= cur_wid-1) x = cur_wid - 2;
4207 else if (x <= 0) x = 1;
4209 /* Slide into legality */
4210 if (y >= cur_hgt-1) y = cur_hgt- 2;
4211 else if (y <= 0) y = 1;
4219 /* Clear the top line */
4222 /* Recenter the map around the player */
4226 p_ptr->update |= (PU_MONSTERS);
4229 p_ptr->redraw |= (PR_MAP);
4232 p_ptr->window |= (PW_OVERHEAD);
4237 /* Failure to set target */
4238 if (!target_who) return (FALSE);
4246 * Get an "aiming direction" from the user.
4248 * The "dir" is loaded with 1,2,3,4,6,7,8,9 for "actual direction", and
4249 * "0" for "current target", and "-1" for "entry aborted".
4251 * Note that "Force Target", if set, will pre-empt user interaction,
4252 * if there is a usable target already set.
4254 * Note that confusion over-rides any (explicit?) user choice.
4256 bool get_aim_dir(int *dp)
4267 /* Global direction */
4270 /* Hack -- auto-target if requested */
4271 if (use_old_target && target_okay()) dir = 5;
4273 #ifdef ALLOW_REPEAT /* TNB */
4275 if (repeat_pull(dp))
4280 if (!(*dp == 5 && !target_okay()))
4282 /* return (TRUE); */
4287 #endif /* ALLOW_REPEAT -- TNB */
4289 /* Ask until satisfied */
4292 /* Choose a prompt */
4296 p = "Êý¸þ ('*'¤Ç¥¿¡¼¥²¥Ã¥ÈÁªÂò, ESC¤ÇÃæÃÇ)? ";
4298 p = "Direction ('*' to choose a target, Escape to cancel)? ";
4305 p = "Êý¸þ ('5'¤Ç¥¿¡¼¥²¥Ã¥È¤Ø, '*'¤Ç¥¿¡¼¥²¥Ã¥ÈºÆÁªÂò, ESC¤ÇÃæÃÇ)? ";
4307 p = "Direction ('5' for target, '*' to re-target, Escape to cancel)? ";
4312 /* Get a command (or Cancel) */
4313 if (!get_com(p, &command, TRUE)) break;
4317 if (command == '\r') command = 't';
4320 /* Convert various keys to "standard" keys */
4323 /* Use current target */
4334 /* Set new target */
4339 if (target_set(TARGET_KILL)) dir = 5;
4345 /* Extract the action (if any) */
4346 dir = get_keymap_dir(command);
4352 /* Verify requested targets */
4353 if ((dir == 5) && !target_okay()) dir = 0;
4362 project_length = 0; /* reset to default */
4366 /* Save the direction */
4369 /* Check for confusion */
4370 if (p_ptr->confused)
4373 /* Random direction */
4374 dir = ddd[randint0(8)];
4377 /* Notice confusion */
4378 if (command_dir != dir)
4382 msg_print("¤¢¤Ê¤¿¤Ïº®Í𤷤Ƥ¤¤ë¡£");
4384 msg_print("You are confused.");
4389 /* Save direction */
4392 #ifdef ALLOW_REPEAT /* TNB */
4394 /* repeat_push(dir); */
4395 repeat_push(command_dir);
4397 #endif /* ALLOW_REPEAT -- TNB */
4399 /* A "valid" direction was entered */
4406 * Request a "movement" direction (1,2,3,4,6,7,8,9) from the user,
4407 * and place it into "command_dir", unless we already have one.
4409 * This function should be used for all "repeatable" commands, such as
4410 * run, walk, open, close, bash, disarm, spike, tunnel, etc, as well
4411 * as all commands which must reference a grid adjacent to the player,
4412 * and which may not reference the grid under the player. Note that,
4413 * for example, it is no longer possible to "disarm" or "open" chests
4414 * in the same grid as the player.
4416 * Direction "5" is illegal and will (cleanly) abort the command.
4418 * This function tracks and uses the "global direction", and uses
4419 * that as the "desired direction", to which "confusion" is applied.
4421 bool get_rep_dir(int *dp, bool under)
4428 /* Global direction */
4431 #ifdef ALLOW_REPEAT /* TNB */
4433 if (repeat_pull(dp))
4436 /* return (TRUE); */
4439 #endif /* ALLOW_REPEAT -- TNB */
4441 /* Get a direction */
4446 /* Get a command (or Cancel) */
4448 if (!get_com("Êý¸þ (ESC¤ÇÃæÃÇ)? ", &ch, TRUE)) break;
4450 if (!get_com("Direction (Escape to cancel)? ", &ch, TRUE)) break;
4454 /* Look up the direction */
4455 dir = get_keymap_dir(ch);
4461 /* Prevent weirdness */
4462 if ((dir == 5) && (!under)) dir = 0;
4465 if (!dir) return (FALSE);
4467 /* Save desired direction */
4470 /* Apply "confusion" */
4471 if (p_ptr->confused)
4473 /* Standard confusion */
4474 if (randint0(100) < 75)
4476 /* Random direction */
4477 dir = ddd[randint0(8)];
4480 else if (p_ptr->riding)
4482 monster_type *m_ptr = &m_list[p_ptr->riding];
4483 monster_race *r_ptr = &r_info[m_ptr->r_idx];
4485 if (MON_CONFUSED(m_ptr))
4487 /* Standard confusion */
4488 if (randint0(100) < 75)
4490 /* Random direction */
4491 dir = ddd[randint0(8)];
4494 else if ((r_ptr->flags1 & RF1_RAND_50) && (r_ptr->flags1 & RF1_RAND_25) && (randint0(100) < 50))
4496 /* Random direction */
4497 dir = ddd[randint0(8)];
4499 else if ((r_ptr->flags1 & RF1_RAND_50) && (randint0(100) < 25))
4501 /* Random direction */
4502 dir = ddd[randint0(8)];
4506 /* Notice confusion */
4507 if (command_dir != dir)
4509 if (p_ptr->confused)
4513 msg_print("¤¢¤Ê¤¿¤Ïº®Í𤷤Ƥ¤¤ë¡£");
4515 msg_print("You are confused.");
4521 monster_type *m_ptr = &m_list[p_ptr->riding];
4523 monster_desc(m_name, m_ptr, 0);
4524 if (MON_CONFUSED(m_ptr))
4527 msg_format("%s¤Ïº®Í𤷤Ƥ¤¤ë¡£", m_name);
4529 msg_format("%^s is confusing.", m_name);
4536 msg_format("%s¤Ï»×¤¤Ä̤ê¤ËÆ°¤¤¤Æ¤¯¤ì¤Ê¤¤¡£", m_name);
4538 msg_format("You cannot control %s.", m_name);
4544 /* Save direction */
4547 #ifdef ALLOW_REPEAT /* TNB */
4549 /* repeat_push(dir); */
4550 repeat_push(command_dir);
4552 #endif /* ALLOW_REPEAT -- TNB */
4559 bool get_rep_dir2(int *dp)
4566 /* Global direction */
4569 #ifdef ALLOW_REPEAT /* TNB */
4571 if (repeat_pull(dp))
4574 /* return (TRUE); */
4577 #endif /* ALLOW_REPEAT -- TNB */
4579 /* Get a direction */
4584 /* Get a command (or Cancel) */
4586 if (!get_com("Êý¸þ (ESC¤ÇÃæÃÇ)? ", &ch, TRUE)) break;
4588 if (!get_com("Direction (Escape to cancel)? ", &ch, TRUE)) break;
4592 /* Look up the direction */
4593 dir = get_keymap_dir(ch);
4599 /* Prevent weirdness */
4600 if (dir == 5) dir = 0;
4603 if (!dir) return (FALSE);
4605 /* Save desired direction */
4608 /* Apply "confusion" */
4609 if (p_ptr->confused)
4611 /* Standard confusion */
4612 if (randint0(100) < 75)
4614 /* Random direction */
4615 dir = ddd[randint0(8)];
4619 /* Notice confusion */
4620 if (command_dir != dir)
4624 msg_print("¤¢¤Ê¤¿¤Ïº®Í𤷤Ƥ¤¤ë¡£");
4626 msg_print("You are confused.");
4631 /* Save direction */
4634 #ifdef ALLOW_REPEAT /* TNB */
4636 /* repeat_push(dir); */
4637 repeat_push(command_dir);
4639 #endif /* ALLOW_REPEAT -- TNB */
4646 void gain_level_reward(int chosen_reward)
4650 char wrath_reason[32] = "";
4651 int nasty_chance = 6;
4652 int dummy = 0, dummy2 = 0;
4655 char o_name[MAX_NLEN];
4661 if (multi_rew) return;
4662 else multi_rew = TRUE;
4666 if (p_ptr->lev == 13) nasty_chance = 2;
4667 else if (!(p_ptr->lev % 13)) nasty_chance = 3;
4668 else if (!(p_ptr->lev % 14)) nasty_chance = 12;
4670 if (one_in_(nasty_chance))
4671 type = randint1(20); /* Allow the 'nasty' effects */
4673 type = randint1(15) + 5; /* Or disallow them */
4675 if (type < 1) type = 1;
4676 if (type > 20) type = 20;
4681 sprintf(wrath_reason, "%s¤ÎÅܤê",
4682 chaos_patrons[p_ptr->chaos_patron]);
4684 sprintf(wrath_reason, "the Wrath of %s",
4685 chaos_patrons[p_ptr->chaos_patron]);
4689 effect = chaos_rewards[p_ptr->chaos_patron][type];
4691 if (one_in_(6) && !chosen_reward)
4694 msg_format("%^s¤ÏË«Èþ¤È¤·¤Æ¤¢¤Ê¤¿¤òÆÍÁ³ÊÑ°Û¤µ¤»¤¿¡£",
4695 chaos_patrons[p_ptr->chaos_patron]);
4697 msg_format("%^s rewards you with a mutation!",
4698 chaos_patrons[p_ptr->chaos_patron]);
4701 (void)gain_random_mutation(0);
4703 reward = "ÊÑ°Û¤·¤¿¡£";
4705 reward = "mutation";
4710 switch (chosen_reward ? chosen_reward : effect)
4714 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
4715 chaos_patrons[p_ptr->chaos_patron]);
4717 msg_format("The voice of %s booms out:",
4718 chaos_patrons[p_ptr->chaos_patron]);
4722 msg_print("¡ÖÆò¡¢¿·¤¿¤Ê¤ë»Ñ¤òɬÍפȤ»¤ê¡ª¡×");
4724 msg_print("'Thou needst a new form, mortal!'");
4729 reward = "ÊÑ°Û¤·¤¿¡£";
4731 reward = "polymorphing";
4736 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
4737 chaos_patrons[p_ptr->chaos_patron]);
4739 msg_format("The voice of %s booms out:",
4740 chaos_patrons[p_ptr->chaos_patron]);
4744 msg_print("¡ÖÆò¤ÏÎɤ¯¹Ô¤¤¤¿¤ê¡ªÂ³¤±¤è¡ª¡×");
4746 msg_print("'Well done, mortal! Lead on!'");
4749 if (p_ptr->prace == RACE_ANDROID)
4752 msg_print("¤·¤«¤·²¿¤âµ¯¤³¤é¤Ê¤«¤Ã¤¿¡£");
4754 msg_print("But, nothing happen.");
4757 else if (p_ptr->exp < PY_MAX_EXP)
4759 s32b ee = (p_ptr->exp / 2) + 10;
4760 if (ee > 100000L) ee = 100000L;
4762 msg_print("¹¹¤Ë·Ð¸³¤òÀѤó¤À¤è¤¦¤Êµ¤¤¬¤¹¤ë¡£");
4764 msg_print("You feel more experienced.");
4769 reward = "·Ð¸³ÃͤòÆÀ¤¿";
4771 reward = "experience";
4777 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
4778 chaos_patrons[p_ptr->chaos_patron]);
4780 msg_format("The voice of %s booms out:",
4781 chaos_patrons[p_ptr->chaos_patron]);
4785 msg_print("¡Ö²¼Ëͤ衢Æò¤½¤ì¤ËÃͤ»¤º¡£¡×");
4787 msg_print("'Thou didst not deserve that, slave.'");
4790 if (p_ptr->prace == RACE_ANDROID)
4793 msg_print("¤·¤«¤·²¿¤âµ¯¤³¤é¤Ê¤«¤Ã¤¿¡£");
4795 msg_print("But, nothing happen.");
4800 lose_exp(p_ptr->exp / 6);
4802 reward = "·Ð¸³Ãͤò¼º¤Ã¤¿¡£";
4804 reward = "losing experience";
4810 msg_format("%s¤ÎÀ¼¤¬¤µ¤µ¤ä¤¤¤¿:",
4811 chaos_patrons[p_ptr->chaos_patron]);
4813 msg_format("The voice of %s whispers:",
4814 chaos_patrons[p_ptr->chaos_patron]);
4818 msg_print("¡Ö²æ¤¬Í¿¤¨¤·Êª¤ò¸ÌÀ¤Ë»È¤¦¤Ù¤·¡£¡×");
4820 msg_print("'Use my gift wisely.'");
4823 acquirement(py, px, 1, FALSE, FALSE);
4825 reward = "¾å¼Á¤Ê¥¢¥¤¥Æ¥à¤ò¼ê¤ËÆþ¤ì¤¿¡£";
4827 reward = "a good item";
4832 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
4833 chaos_patrons[p_ptr->chaos_patron]);
4835 msg_format("The voice of %s booms out:",
4836 chaos_patrons[p_ptr->chaos_patron]);
4840 msg_print("¡Ö²æ¤¬Í¿¤¨¤·Êª¤ò¸ÌÀ¤Ë»È¤¦¤Ù¤·¡£¡×");
4842 msg_print("'Use my gift wisely.'");
4845 acquirement(py, px, 1, TRUE, FALSE);
4847 reward = "¹âµéÉʤΥ¢¥¤¥Æ¥à¤ò¼ê¤ËÆþ¤ì¤¿¡£";
4849 reward = "an excellent item";
4854 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
4855 chaos_patrons[p_ptr->chaos_patron]);
4857 msg_format("The voice of %s booms out:",
4858 chaos_patrons[p_ptr->chaos_patron]);
4862 msg_print("¡ÖÆò¤Î¹Ô¤¤¤Ïµ®¤·õ¤ËÃͤ»¤ê¡£¡×");
4864 msg_print("'Thy deed hath earned thee a worthy blade.'");
4867 /* Get local object */
4870 switch (randint1(p_ptr->lev))
4876 dummy2 = SV_MAIN_GAUCHE;
4885 dummy2 = SV_SMALL_SWORD;
4888 dummy2 = SV_BASILLARD;
4890 case 11: case 12: case 13:
4891 dummy2 = SV_SHORT_SWORD;
4897 dummy2 = SV_CUTLASS;
4900 dummy2 = SV_WAKIZASHI;
4903 dummy2 = SV_KHOPESH;
4909 dummy2 = SV_BROAD_SWORD;
4912 dummy2 = SV_LONG_SWORD;
4915 dummy2 = SV_SCIMITAR;
4918 dummy2 = SV_NINJATO;
4924 dummy2 = SV_BASTARD_SWORD;
4927 dummy2 = SV_GREAT_SCIMITAR;
4930 dummy2 = SV_CLAYMORE;
4933 dummy2 = SV_ESPADON;
4936 dummy2 = SV_TWO_HANDED_SWORD;
4939 dummy2 = SV_FLAMBERGE;
4942 dummy2 = SV_NO_DACHI;
4945 dummy2 = SV_EXECUTIONERS_SWORD;
4948 dummy2 = SV_ZWEIHANDER;
4951 dummy2 = SV_HAYABUSA;
4954 dummy2 = SV_BLADE_OF_CHAOS;
4957 object_prep(q_ptr, lookup_kind(dummy, dummy2));
4958 q_ptr->to_h = 3 + randint1(dun_level) % 10;
4959 q_ptr->to_d = 3 + randint1(dun_level) % 10;
4960 one_resistance(q_ptr);
4961 q_ptr->name2 = EGO_CHAOTIC;
4963 /* Drop it in the dungeon */
4964 (void)drop_near(q_ptr, -1, py, px);
4966 reward = "(º®ÆÙ)¤ÎÉð´ï¤ò¼ê¤ËÆþ¤ì¤¿¡£";
4968 reward = "chaos weapon";
4973 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
4974 chaos_patrons[p_ptr->chaos_patron]);
4976 msg_format("The voice of %s booms out:",
4977 chaos_patrons[p_ptr->chaos_patron]);
4981 msg_print("¡ÖÆò¤Î¹Ô¤¤¤Ïµ®¤Ê󤤤ËÃͤ»¤ê¡£¡×");
4983 msg_print("'Thy deed hath earned thee a worthy reward.'");
4986 acquirement(py, px, randint1(2) + 1, FALSE, FALSE);
4988 reward = "¾å¼Á¤Ê¥¢¥¤¥Æ¥à¤ò¼ê¤ËÆþ¤ì¤¿¡£";
4990 reward = "good items";
4995 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
4996 chaos_patrons[p_ptr->chaos_patron]);
4998 msg_format("The voice of %s booms out:",
4999 chaos_patrons[p_ptr->chaos_patron]);
5003 msg_print("¡Ö²¼Ëͤ衢Æò¤Î¸¥¿È¤Ø¤Î²æ¤¬Àˤ·¤ß̵¤Ê󤤤ò¸«¤ë¤¬¤è¤¤¡£¡×");
5005 msg_print("'Behold, mortal, how generously I reward thy loyalty.'");
5008 acquirement(py, px, randint1(2) + 1, TRUE, FALSE);
5010 reward = "¹âµéÉʤΥ¢¥¤¥Æ¥à¤ò¼ê¤ËÆþ¤ì¤¿¡£";
5012 reward = "excellent items";
5017 msg_format("%s¤ÎÀ¼¤¬¹ì¤ÅϤä¿:",
5018 chaos_patrons[p_ptr->chaos_patron]);
5020 msg_format("The voice of %s thunders:",
5021 chaos_patrons[p_ptr->chaos_patron]);
5025 msg_print("¡Ö²¼Ëͤ衢ÆòÐþËý¤Ê¤ê¡£¡×");
5027 msg_print("'Thou art growing arrogant, mortal.'");
5030 (void)activate_ty_curse(FALSE, &count);
5032 reward = "²Ò¡¹¤·¤¤¼ö¤¤¤ò¤«¤±¤é¤ì¤¿¡£";
5039 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5040 chaos_patrons[p_ptr->chaos_patron]);
5042 msg_format("The voice of %s booms out:",
5043 chaos_patrons[p_ptr->chaos_patron]);
5047 msg_print("¡Ö²æ¤¬²¼Ëͤ¿¤Á¤è¡¢¤«¤ÎÐþËý¤Ê¤ë¼Ô¤òÅݤ¹¤Ù¤·¡ª¡×");
5049 msg_print("'My pets, destroy the arrogant mortal!'");
5052 for (dummy = 0; dummy < randint1(5) + 1; dummy++)
5054 (void)summon_specific(0, py, px, dun_level, 0, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET));
5057 reward = "¥â¥ó¥¹¥¿¡¼¤ò¾¤´¤µ¤ì¤¿¡£";
5059 reward = "summoning hostile monsters";
5064 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5065 chaos_patrons[p_ptr->chaos_patron]);
5067 msg_format("The voice of %s booms out:",
5068 chaos_patrons[p_ptr->chaos_patron]);
5072 msg_print("¡ÖÆò¡¢¤è¤ê¶¯¤Å¨¤òɬÍפȤ»¤ê¡ª¡×");
5074 msg_print("'Thou needst worthier opponents!'");
5077 activate_hi_summon(py, px, FALSE);
5079 reward = "¥â¥ó¥¹¥¿¡¼¤ò¾¤´¤µ¤ì¤¿¡£";
5081 reward = "summoning many hostile monsters";
5086 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5087 chaos_patrons[p_ptr->chaos_patron]);
5089 msg_format("The voice of %s booms out:",
5090 chaos_patrons[p_ptr->chaos_patron]);
5094 msg_print("¡Ö»à¤ÈÇ˲õ¤³¤½²æ¤¬´î¤Ó¤Ê¤ê¡ª¡×");
5096 msg_print("'Death and destruction! This pleaseth me!'");
5101 reward = "¥«¥ª¥¹¤ÎÎϤ¬±²´¬¤¤¤¿¡£";
5103 reward = "calling chaos";
5108 msg_format("%s¤ÎÀ¼¤¬ÌĤê¶Á¤¤¤¿:",
5109 chaos_patrons[p_ptr->chaos_patron]);
5111 msg_format("The voice of %s rings out:",
5112 chaos_patrons[p_ptr->chaos_patron]);
5116 msg_print("¡Öα¤Þ¤ë¤Î¤À¡¢²¼Ëͤ衣;¤¬Æò¤ÎÆùÂΤòÃ䨤󡣡×");
5118 msg_print("'Stay, mortal, and let me mold thee.'");
5121 if (one_in_(3) && !(chaos_stats[p_ptr->chaos_patron] < 0))
5122 do_inc_stat(chaos_stats[p_ptr->chaos_patron]);
5124 do_inc_stat(randint0(6));
5126 reward = "ǽÎÏÃͤ¬¾å¤¬¤Ã¤¿¡£";
5128 reward = "increasing a stat";
5133 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5134 chaos_patrons[p_ptr->chaos_patron]);
5136 msg_format("The voice of %s booms out:",
5137 chaos_patrons[p_ptr->chaos_patron]);
5141 msg_print("¡Ö²¼Ëͤ衢;¤ÏÆò¤ËË°¤ß¤¿¤ê¡£¡×");
5143 msg_print("'I grow tired of thee, mortal.'");
5146 if (one_in_(3) && !(chaos_stats[p_ptr->chaos_patron] < 0))
5147 do_dec_stat(chaos_stats[p_ptr->chaos_patron]);
5149 (void)do_dec_stat(randint0(6));
5151 reward = "ǽÎÏÃͤ¬²¼¤¬¤Ã¤¿¡£";
5153 reward = "decreasing a stat";
5158 msg_format("%s¤ÎÀ¼¤¬¹ì¤ÅϤä¿:",
5159 chaos_patrons[p_ptr->chaos_patron]);
5161 msg_format("The voice of %s thunders:",
5162 chaos_patrons[p_ptr->chaos_patron]);
5166 msg_print("¡ÖÆò¡¢¸¬µõ¤¿¤ë¤³¤È¤ò³Ø¤Ö¤Ù¤·¡ª¡×");
5167 msg_print("¤¢¤Ê¤¿¤Ï°ÊÁ°¤è¤ê¼å¤¯¤Ê¤Ã¤¿¡ª");
5169 msg_print("'Thou needst a lesson in humility, mortal!'");
5170 msg_print("You feel less powerful!");
5173 for (dummy = 0; dummy < 6; dummy++)
5175 (void)dec_stat(dummy, 10 + randint1(15), TRUE);
5178 reward = "Á´Ç½ÎÏÃͤ¬²¼¤¬¤Ã¤¿¡£";
5180 reward = "decreasing all stats";
5185 msg_format("%s¤ÎÎϤ¬¿¨¤ì¤ë¤Î¤ò´¶¤¸¤¿¡£",
5187 msg_format("You feel the power of %s touch you.",
5190 chaos_patrons[p_ptr->chaos_patron]);
5193 reward = "½ý¤¬ÊѲ½¤·¤¿¡£";
5195 reward = "polymorphing wounds";
5200 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5201 chaos_patrons[p_ptr->chaos_patron]);
5203 msg_format("The voice of %s booms out:",
5204 chaos_patrons[p_ptr->chaos_patron]);
5208 msg_print("¡Ö²æ¤¬¤µ¤µ¤ä¤«¤Ê¤ë»òʪ¤ò¼õ¤±¤È¤ë¤¬¤è¤¤¡ª¡×");
5210 msg_print("'Receive this modest gift from me!'");
5213 for (dummy = 0; dummy < 6; dummy++)
5215 (void)do_inc_stat(dummy);
5218 reward = "Á´Ç½ÎÏÃͤ¬¾å¤¬¤Ã¤¿¡£";
5220 reward = "increasing all stats";
5225 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5226 chaos_patrons[p_ptr->chaos_patron]);
5228 msg_format("The voice of %s booms out:",
5229 chaos_patrons[p_ptr->chaos_patron]);
5233 msg_print("¡Ö¶ì¤·¤à¤¬¤è¤¤¡¢ÌµÇ½¤Ê¶ò¤«¼Ô¤è¡ª¡×");
5235 msg_print("'Suffer, pathetic fool!'");
5238 fire_ball(GF_DISINTEGRATE, 0, p_ptr->lev * 4, 4);
5239 take_hit(DAMAGE_NOESCAPE, p_ptr->lev * 4, wrath_reason, -1);
5241 reward = "ʬ²ò¤Îµå¤¬È¯À¸¤·¤¿¡£";
5243 reward = "generating disintegration ball";
5248 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5249 chaos_patrons[p_ptr->chaos_patron]);
5251 msg_format("The voice of %s booms out:",
5252 chaos_patrons[p_ptr->chaos_patron]);
5256 msg_print("¡Öᴤ뤬¤è¤¤¡¢²æ¤¬²¼Ëͤ衪¡×");
5258 msg_print("'Rise, my servant!'");
5262 (void)set_poisoned(0);
5264 (void)set_confused(0);
5269 for (dummy = 0; dummy < 6; dummy++)
5271 (void)do_res_stat(dummy);
5274 reward = "ÂÎÎϤ¬²óÉü¤·¤¿¡£";
5280 if (!buki_motteruka(INVEN_RARM) && !buki_motteruka(INVEN_LARM)) break;
5282 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5283 chaos_patrons[p_ptr->chaos_patron]);
5285 msg_format("The voice of %s booms out:",
5286 chaos_patrons[p_ptr->chaos_patron]);
5290 msg_print("¡ÖÆò¡¢Éð´ï¤ËÍê¤ë¤³¤È¤Ê¤«¤ì¡£¡×");
5292 msg_print("'Thou reliest too much on thy weapon.'");
5296 if (buki_motteruka(INVEN_LARM))
5299 if (buki_motteruka(INVEN_RARM) && one_in_(2)) dummy = INVEN_RARM;
5301 object_desc(o_name, &inventory[dummy], OD_NAME_ONLY);
5302 (void)curse_weapon(FALSE, dummy);
5304 reward = format("%s¤¬Ç˲õ¤µ¤ì¤¿¡£", o_name);
5306 reward = format("destroying %s", o_name);
5310 if (!inventory[INVEN_BODY].k_idx) break;
5312 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5313 chaos_patrons[p_ptr->chaos_patron]);
5315 msg_format("The voice of %s booms out:",
5316 chaos_patrons[p_ptr->chaos_patron]);
5320 msg_print("¡ÖÆò¡¢Ëɶñ¤ËÍê¤ë¤³¤È¤Ê¤«¤ì¡£¡×");
5322 msg_print("'Thou reliest too much on thine equipment.'");
5325 object_desc(o_name, &inventory[INVEN_BODY], OD_NAME_ONLY);
5326 (void)curse_armor();
5328 reward = format("%s¤¬Ç˲õ¤µ¤ì¤¿¡£", o_name);
5330 reward = format("destroying %s", o_name);
5335 msg_format("%s¤ÎÀ¼¤¬¤µ¤µ¤ä¤¤¤¿:",
5336 chaos_patrons[p_ptr->chaos_patron]);
5338 msg_format("The voice of %s whispers:",
5339 chaos_patrons[p_ptr->chaos_patron]);
5343 msg_print("¡Ö²æ¤òÅܤꤷ¤á¤¿ºá¤ò½þ¤¦¤Ù¤·¡£¡×");
5345 msg_print("'Now thou shalt pay for annoying me.'");
5348 switch (randint1(4))
5351 (void)activate_ty_curse(FALSE, &count);
5353 reward = "²Ò¡¹¤·¤¤¼ö¤¤¤ò¤«¤±¤é¤ì¤¿¡£";
5359 activate_hi_summon(py, px, FALSE);
5361 reward = "¥â¥ó¥¹¥¿¡¼¤ò¾¤´¤µ¤ì¤¿¡£";
5363 reward = "summoning hostile monsters";
5369 if (!buki_motteruka(INVEN_RARM) && !buki_motteruka(INVEN_LARM)) break;
5371 if (buki_motteruka(INVEN_LARM))
5374 if (buki_motteruka(INVEN_RARM) && one_in_(2)) dummy = INVEN_RARM;
5376 object_desc(o_name, &inventory[dummy], OD_NAME_ONLY);
5377 (void)curse_weapon(FALSE, dummy);
5379 reward = format("%s¤¬Ç˲õ¤µ¤ì¤¿¡£", o_name);
5381 reward = format("destroying %s", o_name);
5386 if (!inventory[INVEN_BODY].k_idx) break;
5387 object_desc(o_name, &inventory[INVEN_BODY], OD_NAME_ONLY);
5388 (void)curse_armor();
5390 reward = format("%s¤¬Ç˲õ¤µ¤ì¤¿¡£", o_name);
5392 reward = format("destroying %s", o_name);
5397 for (dummy = 0; dummy < 6; dummy++)
5399 (void)dec_stat(dummy, 10 + randint1(15), TRUE);
5402 reward = "Á´Ç½ÎÏÃͤ¬²¼¤¬¤Ã¤¿¡£";
5404 reward = "decreasing all stats";
5411 msg_format("%s¤ÎÀ¼¤¬¹ì¤ÅϤä¿:",
5413 msg_format("The voice of %s thunders:",
5416 chaos_patrons[p_ptr->chaos_patron]);
5418 msg_print("¡Ö»à¤Ì¤¬¤è¤¤¡¢²¼Ëͤ衪¡×");
5420 msg_print("'Die, mortal!'");
5423 take_hit(DAMAGE_LOSELIFE, p_ptr->lev * 4, wrath_reason, -1);
5424 for (dummy = 0; dummy < 6; dummy++)
5426 (void)dec_stat(dummy, 10 + randint1(15), FALSE);
5428 activate_hi_summon(py, px, FALSE);
5429 (void)activate_ty_curse(FALSE, &count);
5434 if (buki_motteruka(INVEN_RARM))
5437 if (buki_motteruka(INVEN_LARM) && one_in_(2)) dummy = INVEN_LARM;
5439 else if (buki_motteruka(INVEN_LARM)) dummy = INVEN_LARM;
5441 if (dummy) (void)curse_weapon(FALSE, dummy);
5443 if (one_in_(2)) (void)curse_armor();
5447 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5448 chaos_patrons[p_ptr->chaos_patron]);
5450 msg_format("The voice of %s booms out:",
5451 chaos_patrons[p_ptr->chaos_patron]);
5455 msg_print("¡Ö»à¤ÈÇ˲õ¤³¤½²æ¤¬´î¤Ó¤Ê¤ê¡ª¡×");
5457 msg_print("'Death and destruction! This pleaseth me!'");
5460 (void)destroy_area(py, px, 25, FALSE);
5462 reward = "¥À¥ó¥¸¥ç¥ó¤¬*Ç˲õ*¤µ¤ì¤¿¡£";
5464 reward = "*destruct*ing dungeon";
5469 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5470 chaos_patrons[p_ptr->chaos_patron]);
5472 msg_format("The voice of %s booms out:",
5473 chaos_patrons[p_ptr->chaos_patron]);
5477 msg_print("¡Ö²æ¡¢Æò¤ÎŨ¤òËõ»¦¤»¤ó¡ª¡×");
5479 msg_print("'Let me relieve thee of thine oppressors!'");
5482 (void)symbol_genocide(0, FALSE);
5484 reward = "¥â¥ó¥¹¥¿¡¼¤¬Ëõ»¦¤µ¤ì¤¿¡£";
5486 reward = "genociding monsters";
5491 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5492 chaos_patrons[p_ptr->chaos_patron]);
5494 msg_format("The voice of %s booms out:",
5495 chaos_patrons[p_ptr->chaos_patron]);
5499 msg_print("¡Ö²æ¡¢Æò¤ÎŨ¤òËõ»¦¤»¤ó¡ª¡×");
5501 msg_print("'Let me relieve thee of thine oppressors!'");
5504 (void)mass_genocide(0, FALSE);
5506 reward = "¥â¥ó¥¹¥¿¡¼¤¬Ëõ»¦¤µ¤ì¤¿¡£";
5508 reward = "genociding nearby monsters";
5513 msg_format("%s¤ÎÎϤ¬Å¨¤ò¹¶·â¤¹¤ë¤Î¤ò´¶¤¸¤¿¡ª",
5514 chaos_patrons[p_ptr->chaos_patron]);
5516 msg_format("You can feel the power of %s assault your enemies!",
5517 chaos_patrons[p_ptr->chaos_patron]);
5520 (void)dispel_monsters(p_ptr->lev * 4);
5524 msg_format("%s¤Ï¤¢¤Ê¤¿¤ò̵»ë¤·¤¿¡£",
5525 chaos_patrons[p_ptr->chaos_patron]);
5527 msg_format("%s ignores you.",
5528 chaos_patrons[p_ptr->chaos_patron]);
5534 msg_format("%s¤ÏË«Èþ¤È¤·¤Æ°Ëâ¤Î»È¤¤¤ò¤è¤³¤·¤¿¡ª",chaos_patrons[p_ptr->chaos_patron]);
5536 msg_format("%s rewards you with a demonic servant!",chaos_patrons[p_ptr->chaos_patron]);
5539 if (!summon_specific(-1, py, px, dun_level, SUMMON_DEMON, PM_FORCE_PET))
5541 msg_print("²¿¤â¸½¤ì¤Ê¤«¤Ã¤¿...");
5543 msg_print("Nobody ever turns up...");
5547 reward = "°Ë⤬¥Ú¥Ã¥È¤Ë¤Ê¤Ã¤¿¡£";
5549 reward = "a demonic servant";
5555 msg_format("%s¤ÏË«Èþ¤È¤·¤Æ»È¤¤¤ò¤è¤³¤·¤¿¡ª",chaos_patrons[p_ptr->chaos_patron]);
5557 msg_format("%s rewards you with a servant!",chaos_patrons[p_ptr->chaos_patron]);
5560 if (!summon_specific(-1, py, px, dun_level, 0, PM_FORCE_PET))
5562 msg_print("²¿¤â¸½¤ì¤Ê¤«¤Ã¤¿...");
5564 msg_print("Nobody ever turns up...");
5568 reward = "¥â¥ó¥¹¥¿¡¼¤¬¥Ú¥Ã¥È¤Ë¤Ê¤Ã¤¿¡£";
5570 reward = "a servant";
5576 msg_format("%s¤ÏË«Èþ¤È¤·¤Æ¥¢¥ó¥Ç¥Ã¥É¤Î»È¤¤¤ò¤è¤³¤·¤¿¡£",chaos_patrons[p_ptr->chaos_patron]);
5578 msg_format("%s rewards you with an undead servant!",chaos_patrons[p_ptr->chaos_patron]);
5581 if (!summon_specific(-1, py, px, dun_level, SUMMON_UNDEAD, PM_FORCE_PET))
5583 msg_print("²¿¤â¸½¤ì¤Ê¤«¤Ã¤¿...");
5585 msg_print("Nobody ever turns up...");
5589 reward = "¥¢¥ó¥Ç¥Ã¥É¤¬¥Ú¥Ã¥È¤Ë¤Ê¤Ã¤¿¡£";
5591 reward = "an undead servant";
5597 msg_format("%s¤ÎÀ¼¤¬¤É¤â¤Ã¤¿:",
5599 msg_format("The voice of %s stammers:",
5602 chaos_patrons[p_ptr->chaos_patron]);
5604 msg_format("¡Ö¤¢¡¼¡¢¤¢¡¼¡¢Åú¤¨¤Ï %d/%d¡£¼ÁÌä¤Ï²¿¡©¡×", type, effect);
5606 msg_format("'Uh... uh... the answer's %d/%d, what's the question?'", type, effect);
5614 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, format("¥Ñ¥È¥í¥ó¤ÎÊó½·¤Ç%s", reward));
5616 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, format("The patron rewards you with %s.", reward));
5623 * old -- from PsiAngband.
5625 bool tgt_pt(int *x_ptr, int *y_ptr)
5629 bool success = FALSE;
5634 get_screen_size(&wid, &hgt);
5640 msg_print("¾ì½ê¤òÁª¤ó¤Ç¥¹¥Ú¡¼¥¹¥¡¼¤ò²¡¤·¤Æ²¼¤µ¤¤¡£");
5642 msg_print("Select a point and press space.");
5644 msg_flag = FALSE; /* prevents "-more-" message. */
5646 while ((ch != ESCAPE) && !success)
5648 bool move_fast = FALSE;
5650 move_cursor_relative(y, x);
5662 if (player_bold(y, x)) ch = 0;
5665 else success = TRUE;
5669 /* Look up the direction */
5670 d = get_keymap_dir(ch);
5672 /* XTRA HACK MOVEFAST */
5673 if (isupper(ch)) move_fast = TRUE;
5675 /* Handle "direction" */
5681 /* XTRA HACK MOVEFAST */
5684 int mag = MIN(wid / 2, hgt / 2);
5694 /* Do not move horizontally if unnecessary */
5695 if (((x < panel_col_min + wid / 2) && (dx > 0)) ||
5696 ((x > panel_col_min + wid / 2) && (dx < 0)))
5701 /* Do not move vertically if unnecessary */
5702 if (((y < panel_row_min + hgt / 2) && (dy > 0)) ||
5703 ((y > panel_row_min + hgt / 2) && (dy < 0)))
5708 /* Apply the motion */
5709 if ((y >= panel_row_min + hgt) || (y < panel_row_min) ||
5710 (x >= panel_col_min + wid) || (x < panel_col_min))
5712 /* if (change_panel(dy, dx)) target_set_prepare(mode); */
5713 change_panel(dy, dx);
5716 /* Slide into legality */
5717 if (x >= cur_wid-1) x = cur_wid - 2;
5718 else if (x <= 0) x = 1;
5720 /* Slide into legality */
5721 if (y >= cur_hgt-1) y = cur_hgt- 2;
5722 else if (y <= 0) y = 1;
5729 /* Clear the top line */
5732 /* Recenter the map around the player */
5736 p_ptr->update |= (PU_MONSTERS);
5739 p_ptr->redraw |= (PR_MAP);
5742 p_ptr->window |= (PW_OVERHEAD);
5753 bool get_hack_dir(int *dp)
5763 /* Global direction */
5766 /* (No auto-targeting) */
5768 /* Ask until satisfied */
5771 /* Choose a prompt */
5775 p = "Êý¸þ ('*'¤Ç¥¿¡¼¥²¥Ã¥ÈÁªÂò, ESC¤ÇÃæÃÇ)? ";
5777 p = "Direction ('*' to choose a target, Escape to cancel)? ";
5784 p = "Êý¸þ ('5'¤Ç¥¿¡¼¥²¥Ã¥È¤Ø, '*'¤Ç¥¿¡¼¥²¥Ã¥ÈºÆÁªÂò, ESC¤ÇÃæÃÇ)? ";
5786 p = "Direction ('5' for target, '*' to re-target, Escape to cancel)? ";
5791 /* Get a command (or Cancel) */
5792 if (!get_com(p, &command, TRUE)) break;
5796 if (command == '\r') command = 't';
5799 /* Convert various keys to "standard" keys */
5802 /* Use current target */
5813 /* Set new target */
5818 if (target_set(TARGET_KILL)) dir = 5;
5824 /* Look up the direction */
5825 dir = get_keymap_dir(command);
5831 /* Verify requested targets */
5832 if ((dir == 5) && !target_okay()) dir = 0;
5839 if (!dir) return (FALSE);
5841 /* Save the direction */
5844 /* Check for confusion */
5845 if (p_ptr->confused)
5848 /* Random direction */
5849 dir = ddd[randint0(8)];
5852 /* Notice confusion */
5853 if (command_dir != dir)
5857 msg_print("¤¢¤Ê¤¿¤Ïº®Í𤷤Ƥ¤¤ë¡£");
5859 msg_print("You are confused.");
5864 /* Save direction */
5867 /* A "valid" direction was entered */
5873 * ¥¨¥Í¥ë¥®¡¼¤ÎÁý²ÃÎÌ10d5¤ò®¤¯·×»»¤¹¤ë¤¿¤á¤Î´Ø¿ô
5876 #define Go_no_JuuJou 5*5*5*5*5*5*5*5*5*5
5878 s16b gain_energy(void)
5881 s32b energy_result = 10;
5884 tmp = randint0(Go_no_JuuJou);
5886 for (i = 0; i < 9; i ++){
5887 energy_result += tmp % 5;
5891 return (s16b)(energy_result + tmp);
5898 s16b bow_energy(int sval)
5902 /* Analyze the launcher */
5905 /* Sling and ammo */
5912 /* Short Bow and Arrow */
5919 /* Long Bow and Arrow */
5926 /* Bow of irresponsiblity and Arrow */
5933 /* Light Crossbow and Bolt */
5940 /* Heavy Crossbow and Bolt */
5955 int bow_tmul(int sval)
5959 /* Analyze the launcher */
5962 /* Sling and ammo */
5969 /* Short Bow and Arrow */
5976 /* Long Bow and Arrow */
5983 /* Bow of irresponsiblity and Arrow */
5990 /* Light Crossbow and Bolt */
5997 /* Heavy Crossbow and Bolt */
6009 * Return alignment title
6011 cptr your_alignment(void)
6014 if (p_ptr->align > 150) return "ÂçÁ±";
6015 else if (p_ptr->align > 50) return "ÃæÁ±";
6016 else if (p_ptr->align > 10) return "¾®Á±";
6017 else if (p_ptr->align > -11) return "ÃæΩ";
6018 else if (p_ptr->align > -51) return "¾®°";
6019 else if (p_ptr->align > -151) return "Ãæ°";
6022 if (p_ptr->align > 150) return "Lawful";
6023 else if (p_ptr->align > 50) return "Good";
6024 else if (p_ptr->align > 10) return "Neutral Good";
6025 else if (p_ptr->align > -11) return "Neutral";
6026 else if (p_ptr->align > -51) return "Neutral Evil";
6027 else if (p_ptr->align > -151) return "Evil";
6028 else return "Chaotic";
6034 * Return proficiency level of weapons and misc. skills (except riding)
6036 int weapon_exp_level(int weapon_exp)
6038 if (weapon_exp < WEAPON_EXP_BEGINNER) return EXP_LEVEL_UNSKILLED;
6039 else if (weapon_exp < WEAPON_EXP_SKILLED) return EXP_LEVEL_BEGINNER;
6040 else if (weapon_exp < WEAPON_EXP_EXPERT) return EXP_LEVEL_SKILLED;
6041 else if (weapon_exp < WEAPON_EXP_MASTER) return EXP_LEVEL_EXPERT;
6042 else return EXP_LEVEL_MASTER;
6047 * Return proficiency level of riding
6049 int riding_exp_level(int riding_exp)
6051 if (riding_exp < RIDING_EXP_BEGINNER) return EXP_LEVEL_UNSKILLED;
6052 else if (riding_exp < RIDING_EXP_SKILLED) return EXP_LEVEL_BEGINNER;
6053 else if (riding_exp < RIDING_EXP_EXPERT) return EXP_LEVEL_SKILLED;
6054 else if (riding_exp < RIDING_EXP_MASTER) return EXP_LEVEL_EXPERT;
6055 else return EXP_LEVEL_MASTER;
6060 * Return proficiency level of spells
6062 int spell_exp_level(int spell_exp)
6064 if (spell_exp < SPELL_EXP_BEGINNER) return EXP_LEVEL_UNSKILLED;
6065 else if (spell_exp < SPELL_EXP_SKILLED) return EXP_LEVEL_BEGINNER;
6066 else if (spell_exp < SPELL_EXP_EXPERT) return EXP_LEVEL_SKILLED;
6067 else if (spell_exp < SPELL_EXP_MASTER) return EXP_LEVEL_EXPERT;
6068 else return EXP_LEVEL_MASTER;