4 * Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke
6 * This software may be copied and distributed for educational, research,
7 * and not for profit purposes provided that this copyright and statement
8 * are included in all such copies. Other copyrights may also apply.
11 /* Purpose: effects of various "objects" */
15 #define REWARD_CHANCE 10
19 * Advance experience levels and print experience
21 void check_experience(void)
23 bool level_reward = FALSE;
24 bool level_mutation = FALSE;
25 bool level_inc_stat = FALSE;
26 bool android = (p_ptr->prace == RACE_ANDROID ? TRUE : FALSE);
27 int old_lev = p_ptr->lev;
29 /* Hack -- lower limit */
30 if (p_ptr->exp < 0) p_ptr->exp = 0;
31 if (p_ptr->max_exp < 0) p_ptr->max_exp = 0;
32 if (p_ptr->max_max_exp < 0) p_ptr->max_max_exp = 0;
34 /* Hack -- upper limit */
35 if (p_ptr->exp > PY_MAX_EXP) p_ptr->exp = PY_MAX_EXP;
36 if (p_ptr->max_exp > PY_MAX_EXP) p_ptr->max_exp = PY_MAX_EXP;
37 if (p_ptr->max_max_exp > PY_MAX_EXP) p_ptr->max_max_exp = PY_MAX_EXP;
39 /* Hack -- maintain "max" experience */
40 if (p_ptr->exp > p_ptr->max_exp) p_ptr->max_exp = p_ptr->exp;
42 /* Hack -- maintain "max max" experience */
43 if (p_ptr->max_exp > p_ptr->max_max_exp) p_ptr->max_max_exp = p_ptr->max_exp;
45 /* Redraw experience */
46 p_ptr->redraw |= (PR_EXP);
52 /* Lose levels while possible */
53 while ((p_ptr->lev > 1) &&
54 (p_ptr->exp < ((android ? player_exp_a : player_exp)[p_ptr->lev - 2] * p_ptr->expfact / 100L)))
59 /* Update some stuff */
60 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
62 /* Redraw some stuff */
63 p_ptr->redraw |= (PR_LEV | PR_TITLE);
66 p_ptr->window |= (PW_PLAYER);
73 /* Gain levels while possible */
74 while ((p_ptr->lev < PY_MAX_LEVEL) &&
75 (p_ptr->exp >= ((android ? player_exp_a : player_exp)[p_ptr->lev-1] * p_ptr->expfact / 100L)))
80 /* Save the highest level */
81 if (p_ptr->lev > p_ptr->max_plv)
83 p_ptr->max_plv = p_ptr->lev;
85 if ((p_ptr->pclass == CLASS_CHAOS_WARRIOR) ||
86 (p_ptr->muta2 & MUT2_CHAOS_GIFT))
90 if (p_ptr->prace == RACE_BEASTMAN)
92 if (one_in_(5)) level_mutation = TRUE;
94 level_inc_stat = TRUE;
96 do_cmd_write_nikki(NIKKI_LEVELUP, p_ptr->lev, NULL);
104 msg_format("¥ì¥Ù¥ë %d ¤Ë¤è¤¦¤³¤½¡£", p_ptr->lev);
106 msg_format("Welcome to level %d.", p_ptr->lev);
110 /* Update some stuff */
111 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
113 /* Redraw some stuff */
114 p_ptr->redraw |= (PR_LEV | PR_TITLE | PR_EXP);
117 p_ptr->window |= (PW_PLAYER | PW_SPELL | PW_INVEN);
119 /* HP¤ÈMP¤Î¾å¾ºÎ̤òɽ¼¨ */
129 if(!(p_ptr->max_plv % 10))
139 cnv_stat(p_ptr->stat_max[0], tmp);
140 prt(format(" a) ÏÓÎÏ (¸½ºßÃÍ %s)", tmp), 2, 14);
141 cnv_stat(p_ptr->stat_max[1], tmp);
142 prt(format(" b) ÃÎǽ (¸½ºßÃÍ %s)", tmp), 3, 14);
143 cnv_stat(p_ptr->stat_max[2], tmp);
144 prt(format(" c) ¸¤µ (¸½ºßÃÍ %s)", tmp), 4, 14);
145 cnv_stat(p_ptr->stat_max[3], tmp);
146 prt(format(" d) ´ïÍÑ (¸½ºßÃÍ %s)", tmp), 5, 14);
147 cnv_stat(p_ptr->stat_max[4], tmp);
148 prt(format(" e) ÂÑµ× (¸½ºßÃÍ %s)", tmp), 6, 14);
149 cnv_stat(p_ptr->stat_max[5], tmp);
150 prt(format(" f) Ì¥ÎÏ (¸½ºßÃÍ %s)", tmp), 7, 14);
152 prt(" ¤É¤ÎǽÎÏÃͤò¾å¤²¤Þ¤¹¤«¡©", 1, 14);
154 cnv_stat(p_ptr->stat_max[0], tmp);
155 prt(format(" a) Str (cur %s)", tmp), 2, 14);
156 cnv_stat(p_ptr->stat_max[1], tmp);
157 prt(format(" b) Int (cur %s)", tmp), 3, 14);
158 cnv_stat(p_ptr->stat_max[2], tmp);
159 prt(format(" c) Wis (cur %s)", tmp), 4, 14);
160 cnv_stat(p_ptr->stat_max[3], tmp);
161 prt(format(" d) Dex (cur %s)", tmp), 5, 14);
162 cnv_stat(p_ptr->stat_max[4], tmp);
163 prt(format(" e) Con (cur %s)", tmp), 6, 14);
164 cnv_stat(p_ptr->stat_max[5], tmp);
165 prt(format(" f) Chr (cur %s)", tmp), 7, 14);
167 prt(" Which stat do you want to raise?", 1, 14);
172 if ((choice >= 'a') && (choice <= 'f')) break;
174 for(n = 0; n < 6; n++)
175 if (n != choice - 'a')
178 if (get_check("¤è¤í¤·¤¤¤Ç¤¹¤«¡©")) break;
180 if (get_check("Are you sure? ")) break;
183 do_inc_stat(choice - 'a');
186 else if(!(p_ptr->max_plv % 2))
187 do_inc_stat(randint0(6));
193 msg_print("¤¢¤Ê¤¿¤ÏÊѤï¤Ã¤¿µ¤¤¬¤¹¤ë...");
195 msg_print("You feel different...");
198 (void)gain_random_mutation(0);
199 level_mutation = FALSE;
203 * Ê󽷤ǥì¥Ù¥ë¤¬¾å¤ë¤ÈºÆµ¢Åª¤Ë check_experience() ¤¬
204 * ¸Æ¤Ð¤ì¤ë¤Î¤Ç½çÈÖ¤òºÇ¸å¤Ë¤¹¤ë¡£
208 gain_level_reward(0);
209 level_reward = FALSE;
212 /* Update some stuff */
213 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
215 /* Redraw some stuff */
216 p_ptr->redraw |= (PR_LEV | PR_TITLE);
219 p_ptr->window |= (PW_PLAYER | PW_SPELL);
225 /* Load an autopick preference file */
226 if (old_lev != p_ptr->lev) autopick_load_pref(FALSE);
231 * Hack -- Return the "automatic coin type" of a monster race
232 * Used to allocate proper treasure when "Creeping coins" die
234 * XXX XXX XXX Note the use of actual "monster names"
236 static int get_coin_type(int r_idx)
238 /* Analyze monsters */
241 case MON_COPPER_COINS: return 2;
242 case MON_SILVER_COINS: return 5;
243 case MON_GOLD_COINS: return 10;
244 case MON_MITHRIL_COINS:
245 case MON_MITHRIL_GOLEM: return 16;
246 case MON_ADAMANT_COINS: return 17;
255 * Hack -- determine if a template is Cloak
257 static bool kind_is_cloak(int k_idx)
259 object_kind *k_ptr = &k_info[k_idx];
261 /* Analyze the item type */
262 if (k_ptr->tval == TV_CLOAK)
267 /* Assume not good */
273 * Hack -- determine if a template is Polearm
275 static bool kind_is_polearm(int k_idx)
277 object_kind *k_ptr = &k_info[k_idx];
279 /* Analyze the item type */
280 if (k_ptr->tval == TV_POLEARM)
285 /* Assume not good */
291 * Hack -- determine if a template is Sword
293 static bool kind_is_sword(int k_idx)
295 object_kind *k_ptr = &k_info[k_idx];
297 /* Analyze the item type */
298 if ((k_ptr->tval == TV_SWORD) && (k_ptr->sval > 2))
303 /* Assume not good */
309 * Hack -- determine if a template is Book
311 static bool kind_is_book(int k_idx)
313 object_kind *k_ptr = &k_info[k_idx];
315 /* Analyze the item type */
316 if ((k_ptr->tval >= TV_LIFE_BOOK) && (k_ptr->tval <= TV_CRUSADE_BOOK))
321 /* Assume not good */
327 * Hack -- determine if a template is Good book
329 static bool kind_is_good_book(int k_idx)
331 object_kind *k_ptr = &k_info[k_idx];
333 /* Analyze the item type */
334 if ((k_ptr->tval >= TV_LIFE_BOOK) && (k_ptr->tval <= TV_CRUSADE_BOOK) && (k_ptr->tval != TV_ARCANE_BOOK) && (k_ptr->sval > 1))
339 /* Assume not good */
345 * Hack -- determine if a template is Armor
347 static bool kind_is_armor(int k_idx)
349 object_kind *k_ptr = &k_info[k_idx];
351 /* Analyze the item type */
352 if (k_ptr->tval == TV_HARD_ARMOR)
357 /* Assume not good */
363 * Hack -- determine if a template is hafted weapon
365 static bool kind_is_hafted(int k_idx)
367 object_kind *k_ptr = &k_info[k_idx];
369 /* Analyze the item type */
370 if (k_ptr->tval == TV_HAFTED)
375 /* Assume not good */
381 * Check for "Quest" completion when a quest monster is killed or charmed.
383 void check_quest_completion(monster_type *m_ptr)
385 int i, j, y, x, ny, nx, i2, j2;
389 bool create_stairs = FALSE;
395 /* Get the location */
400 quest_num = p_ptr->inside_quest;
402 /* Search for an active quest on this dungeon level */
405 for (i = max_quests - 1; i > 0; i--)
407 /* Quest is not active */
408 if (quest[i].status != QUEST_STATUS_TAKEN)
411 /* Quest is not a dungeon quest */
412 if (quest[i].flags & QUEST_FLAG_PRESET)
415 /* Quest is not on this level */
416 if ((quest[i].level != dun_level) &&
417 (quest[i].type != QUEST_TYPE_KILL_ANY_LEVEL))
420 /* Not a "kill monster" quest */
421 if ((quest[i].type == QUEST_TYPE_FIND_ARTIFACT) ||
422 (quest[i].type == QUEST_TYPE_FIND_EXIT))
425 /* Interesting quest */
426 if ((quest[i].type == QUEST_TYPE_KILL_NUMBER) ||
427 (quest[i].type == QUEST_TYPE_KILL_ALL))
430 /* Interesting quest */
431 if (((quest[i].type == QUEST_TYPE_KILL_LEVEL) ||
432 (quest[i].type == QUEST_TYPE_KILL_ANY_LEVEL) ||
433 (quest[i].type == QUEST_TYPE_RANDOM)) &&
434 (quest[i].r_idx == m_ptr->r_idx))
441 /* Handle the current quest */
442 if (quest_num && (quest[quest_num].status == QUEST_STATUS_TAKEN))
447 switch (quest[i].type)
449 case QUEST_TYPE_KILL_NUMBER:
453 if (quest[i].cur_num >= quest[i].num_mon)
455 if (record_fix_quest) do_cmd_write_nikki(NIKKI_FIX_QUEST_C, i, NULL);
456 /* completed quest */
457 quest[i].status = QUEST_STATUS_COMPLETED;
458 quest[i].complev = (byte)p_ptr->lev;
460 if (!(quest[i].flags & QUEST_FLAG_SILENT))
463 msg_print("¥¯¥¨¥¹¥È¤òãÀ®¤·¤¿¡ª");
465 msg_print("You just completed your quest!");
471 quest[i].cur_num = 0;
475 case QUEST_TYPE_KILL_ALL:
479 if (!is_hostile(m_ptr)) break;
481 /* Count all hostile monsters */
482 for (i2 = 0; i2 < cur_wid; ++i2)
483 for (j2 = 0; j2 < cur_hgt; j2++)
484 if (cave[j2][i2].m_idx > 0)
485 if (is_hostile(&m_list[cave[j2][i2].m_idx]))
488 if ((number_mon - 1) == 0)
490 if (record_fix_quest) do_cmd_write_nikki(NIKKI_FIX_QUEST_C, i, NULL);
492 if (quest[i].flags & QUEST_FLAG_SILENT)
494 quest[i].status = QUEST_STATUS_FINISHED;
498 quest[i].status = QUEST_STATUS_COMPLETED;
499 quest[i].complev = (byte)p_ptr->lev;
501 msg_print("¥¯¥¨¥¹¥È¤òãÀ®¤·¤¿¡ª");
503 msg_print("You just completed your quest!");
511 case QUEST_TYPE_KILL_LEVEL:
512 case QUEST_TYPE_RANDOM:
514 /* Only count valid monsters */
515 if (quest[i].r_idx != m_ptr->r_idx)
520 if (quest[i].cur_num >= quest[i].max_num)
522 if (record_fix_quest && (quest[i].type == QUEST_TYPE_KILL_LEVEL)) do_cmd_write_nikki(NIKKI_FIX_QUEST_C, i, NULL);
523 if (record_rand_quest && (quest[i].type == QUEST_TYPE_RANDOM)) do_cmd_write_nikki(NIKKI_RAND_QUEST_C, i, NULL);
524 /* completed quest */
525 quest[i].status = QUEST_STATUS_COMPLETED;
526 quest[i].complev = (byte)p_ptr->lev;
527 if (!(quest[i].flags & QUEST_FLAG_PRESET))
529 create_stairs = TRUE;
530 p_ptr->inside_quest = 0;
533 if (!(quest[i].flags & QUEST_FLAG_SILENT))
536 msg_print("¥¯¥¨¥¹¥È¤òãÀ®¤·¤¿¡ª");
538 msg_print("You just completed your quest!");
544 /* Finish the two main quests without rewarding */
545 if ((i == QUEST_OBERON) || (i == QUEST_SERPENT))
547 quest[i].status = QUEST_STATUS_FINISHED;
550 if (quest[i].type == QUEST_TYPE_RANDOM)
553 quest[i].status = QUEST_STATUS_FINISHED;
558 case QUEST_TYPE_KILL_ANY_LEVEL:
561 if (quest[i].cur_num >= quest[i].max_num)
563 if (record_fix_quest) do_cmd_write_nikki(NIKKI_FIX_QUEST_C, i, NULL);
564 /* completed quest */
565 quest[i].status = QUEST_STATUS_COMPLETED;
566 quest[i].complev = (byte)p_ptr->lev;
568 if (!(quest[i].flags & QUEST_FLAG_SILENT))
571 msg_print("¥¯¥¨¥¹¥È¤òãÀ®¤·¤¿¡ª");
573 msg_print("You just completed your quest!");
578 quest[i].cur_num = 0;
585 /* Create a magical staircase */
589 while (cave_perma_bold(y, x) || cave[y][x].o_idx || (cave[y][x].info & CAVE_OBJECT) )
591 /* Pick a location */
592 scatter(&ny, &nx, y, x, 1, 0);
598 /* Explain the staircase */
600 msg_print("ËâË¡¤Î³¬Ãʤ¬¸½¤ì¤¿...");
602 msg_print("A magical staircase appears...");
606 /* Create stairs down */
607 cave_set_feat(y, x, FEAT_MORE);
609 /* Remember to update everything */
610 p_ptr->update |= (PU_FLOW);
618 for (j = 0; j < (dun_level / 15)+1; j++)
620 /* Get local object */
623 /* Wipe the object */
626 /* Make a great object */
627 make_object(q_ptr, AM_GOOD | AM_GREAT);
629 /* Drop it in the dungeon */
630 (void)drop_near(q_ptr, -1, y, x);
637 * Return monster death string
639 cptr extract_note_dies(monster_race *r_ptr)
641 /* Some monsters get "destroyed" */
642 if (!monster_living(r_ptr))
646 for (i = 0; i < 4; i++)
648 if (r_ptr->blow[i].method == RBM_EXPLODE)
651 return "¤ÏÇúȯ¤·¤ÆÊ´¡¹¤Ë¤Ê¤Ã¤¿¡£";
653 return " explodes into tiny shreds.";
661 return " is destroyed.";
665 /* Assume a default death */
675 * Handle the "death" of a monster.
677 * Disperse treasures centered at the monster location based on the
678 * various flags contained in the monster flags fields.
680 * Check for "Quest" completion when a quest monster is killed.
682 * Note that only the player can induce "monster_death()" on Uniques.
683 * Thus (for now) all Quest monsters should be Uniques.
685 * Note that monsters can now carry objects, and when a monster dies,
686 * it drops all of its objects, which may disappear in crowded rooms.
688 void monster_death(int m_idx, bool drop_item)
697 monster_type *m_ptr = &m_list[m_idx];
699 monster_race *r_ptr = &r_info[m_ptr->r_idx];
701 bool visible = (m_ptr->ml || (r_ptr->flags1 & RF1_UNIQUE));
705 bool do_gold = (!(r_ptr->flags1 & RF1_ONLY_ITEM));
706 bool do_item = (!(r_ptr->flags1 & RF1_ONLY_GOLD));
707 bool cloned = (m_ptr->smart & SM_CLONED) ? TRUE : FALSE;
708 int force_coin = get_coin_type(m_ptr->r_idx);
713 bool drop_chosen_item = drop_item && !cloned && !p_ptr->inside_arena
714 && !p_ptr->inside_battle && !is_pet(m_ptr);
716 /* The caster is dead? */
717 if (world_monster && world_monster == m_idx) world_monster = 0;
719 /* Notice changes in view */
720 if (r_ptr->flags7 & (RF7_LITE_MASK | RF7_DARK_MASK))
722 /* Update some things */
723 p_ptr->update |= (PU_MON_LITE);
726 /* Get the location */
730 if (record_named_pet && is_pet(m_ptr) && m_ptr->nickname)
734 monster_desc(m_name, m_ptr, MD_INDEF_VISIBLE);
735 do_cmd_write_nikki(NIKKI_NAMED_PET, 3, m_name);
738 /* Let monsters explode! */
739 for (i = 0; i < 4; i++)
741 if (r_ptr->blow[i].method == RBM_EXPLODE)
743 int flg = PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL;
744 int typ = mbe_info[r_ptr->blow[i].effect].explode_type;
745 int d_dice = r_ptr->blow[i].d_dice;
746 int d_side = r_ptr->blow[i].d_side;
747 int damage = damroll(d_dice, d_side);
749 project(m_idx, 3, y, x, damage, typ, flg, -1);
754 if (m_ptr->mflag2 & MFLAG2_CHAMELEON)
756 choose_new_monster(m_idx, TRUE, MON_CHAMELEON);
757 r_ptr = &r_info[m_ptr->r_idx];
760 /* Check for quest completion */
761 check_quest_completion(m_ptr);
763 /* Handle the possibility of player vanquishing arena combatant -KMW- */
764 if (p_ptr->inside_arena && !is_pet(m_ptr))
766 p_ptr->exit_bldg = TRUE;
768 if (p_ptr->arena_number > MAX_ARENA_MONS)
771 msg_print("ÁÇÀ²¤é¤·¤¤¡ª·¯¤³¤½¿¿¤Î¾¡Íø¼Ô¤À¡£");
773 msg_print("You are a Genuine Champion!");
779 msg_print("¾¡Íø¡ª¥Á¥ã¥ó¥Ô¥ª¥ó¤Ø¤ÎÆ»¤ò¿Ê¤ó¤Ç¤¤¤ë¡£");
781 msg_print("Victorious! You're on your way to becoming Champion.");
785 if (arena_info[p_ptr->arena_number].tval)
787 /* Get local object */
790 /* Prepare to make a prize */
791 object_prep(q_ptr, lookup_kind(arena_info[p_ptr->arena_number].tval, arena_info[p_ptr->arena_number].sval));
793 apply_magic(q_ptr, object_level, AM_NO_FIXED_ART);
795 /* Drop it in the dungeon */
796 (void)drop_near(q_ptr, -1, y, x);
799 if (p_ptr->arena_number > MAX_ARENA_MONS) p_ptr->arena_number++;
800 p_ptr->arena_number++;
805 /* Extract monster name */
806 monster_desc(m_name, m_ptr, MD_IGNORE_HALLU | MD_ASSUME_VISIBLE | MD_INDEF_VISIBLE);
808 do_cmd_write_nikki(NIKKI_ARENA, p_ptr->arena_number, m_name);
812 if (m_idx == p_ptr->riding)
814 if (rakuba(-1, FALSE))
817 msg_print("ÃÏÌ̤ËÍî¤È¤µ¤ì¤¿¡£");
819 msg_print("You have fallen from your riding pet.");
824 /* Drop a dead corpse? */
825 if (one_in_(r_ptr->flags1 & RF1_UNIQUE ? 1 : 4) &&
826 ((r_ptr->flags9 & RF9_DROP_CORPSE) ||
827 (r_ptr->flags9 & RF9_DROP_SKELETON)) &&
828 !(p_ptr->inside_arena || p_ptr->inside_battle || cloned || ((m_ptr->r_idx == today_mon) && is_pet(m_ptr))))
830 /* Assume skeleton */
834 * We cannot drop a skeleton? Note, if we are in this check,
835 * we *know* we can drop at least a corpse or a skeleton
837 if (!(r_ptr->flags9 & RF9_DROP_SKELETON))
839 else if ((r_ptr->flags9 & RF9_DROP_CORPSE) && (r_ptr->flags1 && RF1_UNIQUE))
842 /* Else, a corpse is more likely unless we did a "lot" of damage */
843 else if (r_ptr->flags9 & RF9_DROP_CORPSE)
845 /* Lots of damage in one blow */
846 if ((0 - ((m_ptr->maxhp) / 4)) > m_ptr->hp)
848 if (one_in_(5)) corpse = TRUE;
852 if (!one_in_(5)) corpse = TRUE;
856 /* Get local object */
859 /* Prepare to make an object */
860 object_prep(q_ptr, lookup_kind(TV_CORPSE, (corpse ? SV_CORPSE : SV_SKELETON)));
862 apply_magic(q_ptr, object_level, AM_NO_FIXED_ART);
864 q_ptr->pval = m_ptr->r_idx;
866 /* Drop it in the dungeon */
867 (void)drop_near(q_ptr, -1, y, x);
870 /* Drop objects being carried */
871 monster_drop_carried_objects(m_ptr);
873 if (r_ptr->flags1 & RF1_DROP_GOOD) mo_mode |= AM_GOOD;
874 if (r_ptr->flags1 & RF1_DROP_GREAT) mo_mode |= AM_GREAT;
876 switch (m_ptr->r_idx)
878 case MON_PINK_HORROR:
879 /* Pink horrors are replaced with 2 Blue horrors */
880 if (!(p_ptr->inside_arena || p_ptr->inside_battle))
884 for (i = 0; i < 2; i++)
887 bool pet = is_pet(m_ptr);
890 if (pet) mode |= PM_FORCE_PET;
892 if (summon_specific((pet ? -1 : m_idx), wy, wx, 100, SUMMON_BLUE_HORROR, mode))
894 if (player_can_see_bold(wy, wx))
901 msg_print("¥Ô¥ó¥¯¡¦¥Û¥é¡¼¤ÏʬÎö¤·¤¿¡ª");
903 msg_print("The Pink horror divides!");
908 case MON_BLOODLETTER:
909 /* Bloodletters of Khorne may drop a blade of chaos */
910 if (drop_chosen_item && (randint1(100) < 15))
912 /* Get local object */
915 /* Prepare to make a Blade of Chaos */
916 object_prep(q_ptr, lookup_kind(TV_SWORD, SV_BLADE_OF_CHAOS));
918 apply_magic(q_ptr, object_level, AM_NO_FIXED_ART | mo_mode);
920 /* Drop it in the dungeon */
921 (void)drop_near(q_ptr, -1, y, x);
926 if (drop_chosen_item && (dun_level > 9))
928 /* Get local object */
931 /* Wipe the object */
934 /* Activate restriction */
935 if ((dun_level > 49) && one_in_(5))
936 get_obj_num_hook = kind_is_good_book;
938 get_obj_num_hook = kind_is_book;
941 make_object(q_ptr, mo_mode);
943 /* Drop it in the dungeon */
944 (void)drop_near(q_ptr, -1, y, x);
950 * Mega^3-hack: killing a 'Warrior of the Dawn' is likely to
951 * spawn another in the fallen one's place!
953 if (!p_ptr->inside_arena && !p_ptr->inside_battle)
959 bool pet = is_pet(m_ptr);
963 scatter(&wy, &wx, y, x, 20, 0);
965 while (!(in_bounds(wy, wx) && cave_empty_bold2(wy, wx)) && --attempts);
970 if (pet) mode |= PM_FORCE_PET;
972 if (summon_specific((pet ? -1 : m_idx), wy, wx, 100, SUMMON_DAWN, mode))
974 if (player_can_see_bold(wy, wx))
976 msg_print("¿·¤¿¤ÊÀï»Î¤¬¸½¤ì¤¿¡ª");
978 msg_print("A new warrior steps forth!");
988 /* One more ultra-hack: An Unmaker goes out with a big bang! */
990 int flg = PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL;
991 (void)project(m_idx, 6, y, x, 100, GF_CHAOS, flg, -1);
995 case MON_UNICORN_ORD:
998 /* Reward for "lazy" player */
999 if (p_ptr->pseikaku == SEIKAKU_NAMAKE)
1003 if (!drop_chosen_item) break;
1007 switch (randint0(3))
1010 a_idx = ART_NAMAKE_HAMMER;
1013 a_idx = ART_NAMAKE_BOW;
1016 a_idx = ART_NAMAKE_ARMOR;
1020 while (a_info[a_idx].cur_num);
1022 if (a_info[a_idx].cur_num == 0)
1024 /* Create the artifact */
1025 create_named_art(a_idx, y, x);
1026 a_info[a_idx].cur_num = 1;
1032 if (!drop_chosen_item) break;
1034 /* Get local object */
1037 /* Mega-Hack -- Prepare to make "Grond" */
1038 object_prep(q_ptr, lookup_kind(TV_HAFTED, SV_GROND));
1040 /* Mega-Hack -- Mark this item as "Grond" */
1041 q_ptr->name1 = ART_GROND;
1043 /* Mega-Hack -- Actually create "Grond" */
1044 apply_magic(q_ptr, -1, AM_GOOD | AM_GREAT);
1046 /* Drop it in the dungeon */
1047 (void)drop_near(q_ptr, -1, y, x);
1049 /* Get local object */
1052 /* Mega-Hack -- Prepare to make "Chaos" */
1053 object_prep(q_ptr, lookup_kind(TV_CROWN, SV_CHAOS));
1055 /* Mega-Hack -- Mark this item as "Chaos" */
1056 q_ptr->name1 = ART_CHAOS;
1058 /* Mega-Hack -- Actually create "Chaos" */
1059 apply_magic(q_ptr, -1, AM_GOOD | AM_GREAT);
1061 /* Drop it in the dungeon */
1062 (void)drop_near(q_ptr, -1, y, x);
1065 case MON_B_DEATH_SWORD:
1066 if (drop_chosen_item)
1068 /* Get local object */
1071 /* Prepare to make a broken sword */
1072 object_prep(q_ptr, lookup_kind(TV_SWORD, randint1(2)));
1074 /* Drop it in the dungeon */
1075 (void)drop_near(q_ptr, -1, y, x);
1081 if (drop_chosen_item && ((m_ptr->r_idx == MON_A_GOLD) ||
1082 ((m_ptr->r_idx == MON_A_SILVER) && (r_ptr->r_pkills % 5 == 0))))
1084 /* Get local object */
1087 /* Prepare to make a Can of Toys */
1088 object_prep(q_ptr, lookup_kind(TV_CHEST, SV_CHEST_KANDUME));
1090 apply_magic(q_ptr, object_level, AM_NO_FIXED_ART);
1092 /* Drop it in the dungeon */
1093 (void)drop_near(q_ptr, -1, y, x);
1099 int flg = PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL;
1100 (void)project(m_idx, 3, y, x, damroll(20, 10), GF_FIRE, flg, -1);
1105 if (!drop_chosen_item) break;
1107 switch (r_ptr->d_char)
1112 /* Get local object */
1115 /* Wipe the object */
1118 /* Activate restriction */
1119 get_obj_num_hook = kind_is_cloak;
1122 make_object(q_ptr, mo_mode);
1124 /* Drop it in the dungeon */
1125 (void)drop_near(q_ptr, -1, y, x);
1132 /* Get local object */
1135 /* Wipe the object */
1138 /* Activate restriction */
1139 get_obj_num_hook = kind_is_polearm;
1141 /* Make a poleweapon */
1142 make_object(q_ptr, mo_mode);
1144 /* Drop it in the dungeon */
1145 (void)drop_near(q_ptr, -1, y, x);
1152 /* Get local object */
1155 /* Wipe the object */
1158 /* Activate restriction */
1159 get_obj_num_hook = kind_is_armor;
1161 /* Make a hard armor */
1162 make_object(q_ptr, mo_mode);
1164 /* Drop it in the dungeon */
1165 (void)drop_near(q_ptr, -1, y, x);
1172 /* Get local object */
1175 /* Wipe the object */
1178 /* Activate restriction */
1179 get_obj_num_hook = kind_is_hafted;
1181 /* Make a poleweapon */
1182 make_object(q_ptr, mo_mode);
1184 /* Drop it in the dungeon */
1185 (void)drop_near(q_ptr, -1, y, x);
1190 if (m_ptr->r_idx != MON_STORMBRINGER)
1192 /* Get local object */
1195 /* Wipe the object */
1198 /* Activate restriction */
1199 get_obj_num_hook = kind_is_sword;
1202 make_object(q_ptr, mo_mode);
1204 /* Drop it in the dungeon */
1205 (void)drop_near(q_ptr, -1, y, x);
1212 /* Mega-Hack -- drop fixed items */
1213 if (drop_chosen_item)
1218 switch (m_ptr->r_idx)
1238 case MON_STORMBRINGER:
1239 a_idx = ART_STORMBRINGER;
1244 a_idx = ART_CRIMSON;
1254 a_idx = ART_KUSANAGI;
1284 a_idx = ART_WEREWINDLE;
1292 a_idx = ART_GRAYSWANDIR;
1303 a_idx = ART_TWILIGHT;
1308 a_idx = ART_ELENDIL;
1323 a_idx = ART_DESTINY;
1328 a_idx = ART_ZANTETSU;
1343 a_idx = ART_WINBLOWS;
1347 case MON_LUNGORTHIN:
1352 case MON_JACK_SHADOWS:
1358 a_idx = ART_STONEMASK;
1363 a_idx = ART_SOULCRUSH;
1368 a_idx = ART_EXCALIBUR_J;
1373 a_idx = ART_SHUTEN_DOJI;
1378 a_idx = ART_GOTHMOG;
1388 if ((a_idx > 0) && ((randint0(100) < chance) || p_ptr->wizard))
1390 if (a_info[a_idx].cur_num == 0)
1392 /* Create the artifact */
1393 create_named_art(a_idx, y, x);
1394 a_info[a_idx].cur_num = 1;
1398 if ((r_ptr->flags7 & RF7_GUARDIAN) && (d_info[dungeon_type].final_guardian == m_ptr->r_idx))
1400 int k_idx = d_info[dungeon_type].final_object ? d_info[dungeon_type].final_object
1401 : lookup_kind(TV_SCROLL, SV_SCROLL_ACQUIREMENT);
1403 if (d_info[dungeon_type].final_artifact)
1405 int a_idx = d_info[dungeon_type].final_artifact;
1406 if (!a_info[a_idx].cur_num)
1408 /* Create the artifact */
1409 create_named_art(a_idx, y, x);
1410 a_info[a_idx].cur_num = 1;
1412 /* Prevent rewarding both artifact and "default" object */
1413 if (!d_info[dungeon_type].final_object) k_idx = 0;
1419 /* Get local object */
1422 /* Prepare to make a reward */
1423 object_prep(q_ptr, k_idx);
1425 apply_magic(q_ptr, object_level, AM_NO_FIXED_ART | AM_GOOD);
1427 /* Drop it in the dungeon */
1428 (void)drop_near(q_ptr, -1, y, x);
1431 msg_format("¤¢¤Ê¤¿¤Ï%s¤òÀ©ÇƤ·¤¿¡ª",d_name+d_info[dungeon_type].name);
1433 msg_format("You have conquered %s!",d_name+d_info[dungeon_type].name);
1438 /* Determine how much we can drop */
1439 if ((r_ptr->flags1 & RF1_DROP_60) && (randint0(100) < 60)) number++;
1440 if ((r_ptr->flags1 & RF1_DROP_90) && (randint0(100) < 90)) number++;
1441 if (r_ptr->flags1 & RF1_DROP_1D2) number += damroll(1, 2);
1442 if (r_ptr->flags1 & RF1_DROP_2D2) number += damroll(2, 2);
1443 if (r_ptr->flags1 & RF1_DROP_3D2) number += damroll(3, 2);
1444 if (r_ptr->flags1 & RF1_DROP_4D2) number += damroll(4, 2);
1446 if (cloned && !(r_ptr->flags1 & RF1_UNIQUE))
1447 number = 0; /* Clones drop no stuff unless Cloning Pits */
1449 if (is_pet(m_ptr) || p_ptr->inside_battle || p_ptr->inside_arena)
1450 number = 0; /* Pets drop no stuff */
1451 if (!drop_item && (r_ptr->d_char != '$')) number = 0;
1453 /* Hack -- handle creeping coins */
1454 coin_type = force_coin;
1456 /* Average dungeon and monster levels */
1457 object_level = (dun_level + r_ptr->level) / 2;
1459 /* Drop some objects */
1460 for (j = 0; j < number; j++)
1462 /* Get local object */
1465 /* Wipe the object */
1469 if (do_gold && (!do_item || (randint0(100) < 50)))
1471 /* Make some gold */
1472 if (!make_gold(q_ptr)) continue;
1481 /* Make an object */
1482 if (!make_object(q_ptr, mo_mode)) continue;
1488 /* Drop it in the dungeon */
1489 (void)drop_near(q_ptr, -1, y, x);
1492 /* Reset the object level */
1493 object_level = base_level;
1495 /* Reset "coin" type */
1499 /* Take note of any dropped treasure */
1500 if (visible && (dump_item || dump_gold))
1502 /* Take notes on treasure */
1503 lore_treasure(m_idx, dump_item, dump_gold);
1506 /* Only process "Quest Monsters" */
1507 if (!(r_ptr->flags1 & RF1_QUESTOR)) return;
1508 if (p_ptr->inside_battle) return;
1511 if ((m_ptr->r_idx == MON_SERPENT) && !cloned)
1514 p_ptr->total_winner = TRUE;
1516 /* Redraw the "title" */
1517 p_ptr->redraw |= (PR_TITLE);
1520 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, "¸«»ö¤ËÊѶòÈÚÅܤξ¡Íø¼Ô¤È¤Ê¤Ã¤¿¡ª");
1522 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, "become *WINNER* of Hengband finely!");
1525 if ((p_ptr->pclass == CLASS_CHAOS_WARRIOR) || (p_ptr->muta2 & MUT2_CHAOS_GIFT))
1528 msg_format("%s¤«¤é¤ÎÀ¼¤¬¶Á¤¤¤¿¡£", chaos_patrons[p_ptr->chaos_patron]);
1529 msg_print("¡Ø¤è¤¯¤ä¤Ã¤¿¡¢ÄêÌ¿¤Î¼Ô¤è¡ª¡Ù");
1531 msg_format("The voice of %s booms out:", chaos_patrons[p_ptr->chaos_patron]);
1532 msg_print("'Thou art donst well, mortal!'");
1536 /* Congratulations */
1538 msg_print("*** ¤ª¤á¤Ç¤È¤¦ ***");
1540 msg_print("*** CONGRATULATIONS ***");
1544 msg_print("¤¢¤Ê¤¿¤Ï¥²¡¼¥à¤ò¥³¥ó¥×¥ê¡¼¥È¤·¤Þ¤·¤¿¡£");
1546 msg_print("You have won the game!");
1550 msg_print("½àÈ÷¤¬À°¤Ã¤¿¤é°úÂà(¼«»¦¥³¥Þ¥ó¥É)¤·¤Æ¤â·ë¹½¤Ç¤¹¡£");
1552 msg_print("You may retire (commit suicide) when you are ready.");
1558 * Modify the physical damage done to the monster.
1559 * (for example when it's invulnerable or shielded)
1561 * ToDo: Accept a damage-type to calculate the modified damage from
1562 * things like fire, frost, lightning, poison, ... attacks.
1564 * "type" is not yet used and should be 0.
1566 int mon_damage_mod(monster_type *m_ptr, int dam, bool is_psy_spear)
1568 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1570 if ((r_ptr->flagsr & RFR_RES_ALL) && dam > 0)
1573 if((dam == 0) && one_in_(3)) dam = 1;
1576 if (m_ptr->invulner)
1580 if (!p_ptr->blind && is_seen(m_ptr))
1583 msg_print("¥Ð¥ê¥¢¤òÀÚ¤êÎö¤¤¤¿¡ª");
1585 msg_print("The barrier is penetrated!");
1589 else if (!one_in_(PENETRATE_INVULNERABILITY))
1599 * Calculate experience point to be get
1601 * Even the 64 bit operation is not big enough to avoid overflaw
1602 * unless we carefully choose orders of multiplication and division.
1604 * Get the coefficient first, and multiply (potentially huge) base
1605 * experience point of a monster later.
1607 static void get_exp_from_mon(int dam, monster_type *m_ptr)
1609 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1616 if (!m_ptr->r_idx) return;
1617 if (is_pet(m_ptr) || p_ptr->inside_battle) return;
1620 * - Ratio of monster's level to player's level effects
1621 * - Varying speed effects
1622 * - Get a fraction in proportion of damage point
1624 new_exp = r_ptr->level * SPEED_TO_ENERGY(m_ptr->mspeed) * dam;
1627 div_l = (p_ptr->max_plv+2) * SPEED_TO_ENERGY(r_ptr->speed);
1629 /* Use (average maxhp * 2) as a denominator */
1630 if (!(r_ptr->flags1 & RF1_FORCE_MAXHP))
1631 s64b_mul(&div_h, &div_l, 0, r_ptr->hdice * (r_ptr->hside + 1));
1633 s64b_mul(&div_h, &div_l, 0, r_ptr->hdice * r_ptr->hside * 2);
1635 /* Special penalty in the wilderness */
1636 if (!dun_level && (!(r_ptr->flags8 & RF8_WILD_ONLY) || !(r_ptr->flags1 & RF1_UNIQUE)))
1637 s64b_mul(&div_h, &div_l, 0, 5);
1639 /* Do division first to prevent overflaw */
1640 s64b_div(&new_exp, &new_exp_frac, div_h, div_l);
1642 /* Special penalty for mutiply-monster */
1643 if ((r_ptr->flags2 & RF2_MULTIPLY) || (m_ptr->r_idx == MON_DAWN))
1645 int monnum_penarty = r_ptr->r_pkills / 400;
1646 if (monnum_penarty > 8) monnum_penarty = 8;
1648 while (monnum_penarty--)
1651 s64b_RSHIFT(new_exp, new_exp_frac, 2);
1655 /* Finally multiply base experience point of the monster */
1656 s64b_mul(&new_exp, &new_exp_frac, 0, r_ptr->mexp);
1658 /* Gain experience */
1659 gain_exp_64(new_exp, new_exp_frac);
1664 * Decreases monsters hit points, handling monster death.
1666 * We return TRUE if the monster has been killed (and deleted).
1668 * We announce monster death (using an optional "death message"
1669 * if given, and a otherwise a generic killed/destroyed message).
1671 * Only "physical attacks" can induce the "You have slain" message.
1672 * Missile and Spell attacks will induce the "dies" message, or
1673 * various "specialized" messages. Note that "You have destroyed"
1674 * and "is destroyed" are synonyms for "You have slain" and "dies".
1676 * Hack -- unseen monsters yield "You have killed it." message.
1678 * Added fear (DGK) and check whether to print fear messages -CWS
1680 * Made name, sex, and capitalization generic -BEN-
1682 * As always, the "ghost" processing is a total hack.
1684 * Hack -- we "delay" fear messages by passing around a "fear" flag.
1686 * XXX XXX XXX Consider decreasing monster experience over time, say,
1687 * by using "(m_exp * m_lev * (m_lev)) / (p_lev * (m_lev + n_killed))"
1688 * instead of simply "(m_exp * m_lev) / (p_lev)", to make the first
1689 * monster worth more than subsequent monsters. This would also need
1690 * to induce changes in the monster recall code.
1692 bool mon_take_hit(int m_idx, int dam, bool *fear, cptr note)
1694 monster_type *m_ptr = &m_list[m_idx];
1695 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1697 monster_type exp_mon;
1699 /* Innocent until proven otherwise */
1700 bool innocent = TRUE, thief = FALSE;
1704 COPY(&exp_mon, m_ptr, monster_type);
1705 if (!(r_ptr->flags7 & RF7_KILL_EXP))
1707 expdam = (m_ptr->hp > dam) ? dam : m_ptr->hp;
1708 if (r_ptr->flags6 & RF6_HEAL) expdam = (expdam+1) * 2 / 3;
1710 get_exp_from_mon(expdam, &exp_mon);
1713 /* Redraw (later) if needed */
1714 if (p_ptr->health_who == m_idx) p_ptr->redraw |= (PR_HEALTH);
1715 if (p_ptr->riding == m_idx) p_ptr->redraw |= (PR_UHEALTH);
1721 if (!need_mproc(m_ptr)) mproc_remove(m_ptr->mproc_idx);
1722 if (r_ptr->flags7 & RF7_HAS_LD_MASK) p_ptr->update |= (PU_MON_LITE);
1725 /* Hack - Cancel any special player stealth magics. -LM- */
1726 if (p_ptr->special_defense & NINJA_S_STEALTH)
1728 set_superstealth(FALSE);
1734 /* It is dead now */
1739 if (r_info[m_ptr->r_idx].flags7 & RF7_TANUKI)
1741 /* You might have unmasked Tanuki first time */
1742 r_ptr = &r_info[m_ptr->r_idx];
1743 m_ptr->ap_r_idx = m_ptr->r_idx;
1744 if (r_ptr->r_sights < MAX_SHORT) r_ptr->r_sights++;
1747 if (m_ptr->mflag2 & MFLAG2_CHAMELEON)
1749 /* You might have unmasked Chameleon first time */
1750 r_ptr = real_r_ptr(m_ptr);
1751 if (r_ptr->r_sights < MAX_SHORT) r_ptr->r_sights++;
1754 if (!(m_ptr->smart & SM_CLONED))
1756 /* When the player kills a Unique, it stays dead */
1757 if (r_ptr->flags1 & RF1_UNIQUE)
1761 /* Mega-Hack -- Banor & Lupart */
1762 if ((m_ptr->r_idx == MON_BANOR) || (m_ptr->r_idx == MON_LUPART))
1764 r_info[MON_BANORLUPART].max_num = 0;
1765 r_info[MON_BANORLUPART].r_pkills++;
1766 if (r_info[MON_BANORLUPART].r_tkills < MAX_SHORT) r_info[MON_BANORLUPART].r_tkills++;
1768 else if (m_ptr->r_idx == MON_BANORLUPART)
1770 r_info[MON_BANOR].max_num = 0;
1771 r_info[MON_BANOR].r_pkills++;
1772 if (r_info[MON_BANOR].r_tkills < MAX_SHORT) r_info[MON_BANOR].r_tkills++;
1773 r_info[MON_LUPART].max_num = 0;
1774 r_info[MON_LUPART].r_pkills++;
1775 if (r_info[MON_LUPART].r_tkills < MAX_SHORT) r_info[MON_LUPART].r_tkills++;
1779 /* When the player kills a Nazgul, it stays dead */
1780 else if (r_ptr->flags7 & RF7_NAZGUL) r_ptr->max_num--;
1783 /* Recall even invisible uniques or winners */
1784 if (m_ptr->ml || (r_ptr->flags1 & RF1_UNIQUE))
1786 /* Count kills this life */
1787 if ((m_ptr->mflag2 & MFLAG2_KAGE) && (r_info[MON_KAGE].r_pkills < MAX_SHORT)) r_info[MON_KAGE].r_pkills++;
1788 else if (r_ptr->r_pkills < MAX_SHORT) r_ptr->r_pkills++;
1790 /* Count kills in all lives */
1791 if ((m_ptr->mflag2 & MFLAG2_KAGE) && (r_info[MON_KAGE].r_tkills < MAX_SHORT)) r_info[MON_KAGE].r_tkills++;
1792 else if (r_ptr->r_tkills < MAX_SHORT) r_ptr->r_tkills++;
1794 /* Hack -- Auto-recall */
1795 monster_race_track(m_ptr->ap_r_idx);
1798 /* Extract monster name */
1799 monster_desc(m_name, m_ptr, MD_TRUE_NAME);
1801 /* Don't kill Amberites */
1802 if ((r_ptr->flags3 & RF3_AMBERITE) && one_in_(2))
1804 int curses = 1 + randint1(3);
1805 bool stop_ty = FALSE;
1809 msg_format("%^s¤Ï¶²¤í¤·¤¤·ì¤Î¼ö¤¤¤ò¤¢¤Ê¤¿¤Ë¤«¤±¤¿¡ª", m_name);
1811 msg_format("%^s puts a terrible blood curse on you!", m_name);
1814 curse_equipment(100, 50);
1818 stop_ty = activate_ty_curse(stop_ty, &count);
1823 if (r_ptr->flags2 & RF2_CAN_SPEAK)
1825 char line_got[1024];
1827 /* Dump a message */
1829 if (!get_rnd_line("mondeath_j.txt", m_ptr->r_idx, line_got))
1831 if (!get_rnd_line("mondeath.txt", m_ptr->r_idx, line_got))
1834 msg_format("%^s %s", m_name, line_got);
1837 if (m_ptr->r_idx == MON_SERPENT)
1839 /* Make screen dump */
1840 screen_dump = make_screen_dump();
1845 if (!(d_info[dungeon_type].flags1 & DF1_BEGINNER))
1847 if (!dun_level && !ambush_flag && !p_ptr->inside_arena)
1849 chg_virtue(V_VALOUR, -1);
1851 else if (r_ptr->level > dun_level)
1853 if (randint1(10) <= (r_ptr->level - dun_level))
1854 chg_virtue(V_VALOUR, 1);
1856 if (r_ptr->level > 60)
1858 chg_virtue(V_VALOUR, 1);
1860 if (r_ptr->level >= 2 * (p_ptr->lev+1))
1861 chg_virtue(V_VALOUR, 2);
1864 if (r_ptr->flags1 & RF1_UNIQUE)
1866 if (r_ptr->flags3 & (RF3_EVIL | RF3_GOOD)) chg_virtue(V_HARMONY, 2);
1868 if (r_ptr->flags3 & RF3_GOOD)
1870 chg_virtue(V_UNLIFE, 2);
1871 chg_virtue(V_VITALITY, -2);
1874 if (one_in_(3)) chg_virtue(V_INDIVIDUALISM, -1);
1877 if (m_ptr->r_idx == MON_BEGGAR || m_ptr->r_idx == MON_LEPER)
1879 chg_virtue(V_COMPASSION, -1);
1882 if ((r_ptr->flags3 & RF3_GOOD) &&
1883 ((r_ptr->level) / 10 + (3 * dun_level) >= randint1(100)))
1884 chg_virtue(V_UNLIFE, 1);
1886 if (r_ptr->d_char == 'A')
1888 if (r_ptr->flags1 & RF1_UNIQUE)
1889 chg_virtue(V_FAITH, -2);
1890 else if ((r_ptr->level) / 10 + (3 * dun_level) >= randint1(100))
1892 if (r_ptr->flags3 & RF3_GOOD) chg_virtue(V_FAITH, -1);
1893 else chg_virtue(V_FAITH, 1);
1896 else if (r_ptr->flags3 & RF3_DEMON)
1898 if (r_ptr->flags1 & RF1_UNIQUE)
1899 chg_virtue(V_FAITH, 2);
1900 else if ((r_ptr->level) / 10 + (3 * dun_level) >= randint1(100))
1901 chg_virtue(V_FAITH, 1);
1904 if ((r_ptr->flags3 & RF3_UNDEAD) && (r_ptr->flags1 & RF1_UNIQUE))
1905 chg_virtue(V_VITALITY, 2);
1907 if (r_ptr->r_deaths)
1909 if (r_ptr->flags1 & RF1_UNIQUE)
1911 chg_virtue(V_HONOUR, 10);
1913 else if ((r_ptr->level) / 10 + (2 * dun_level) >= randint1(100))
1915 chg_virtue(V_HONOUR, 1);
1918 if ((r_ptr->flags2 & RF2_MULTIPLY) && (r_ptr->r_pkills > 1000) && one_in_(10))
1920 chg_virtue(V_VALOUR, -1);
1923 for (i = 0; i < 4; i++)
1925 if (r_ptr->blow[i].d_dice != 0) innocent = FALSE; /* Murderer! */
1927 if ((r_ptr->blow[i].effect == RBE_EAT_ITEM)
1928 || (r_ptr->blow[i].effect == RBE_EAT_GOLD))
1930 thief = TRUE; /* Thief! */
1933 /* The new law says it is illegal to live in the dungeon */
1934 if (r_ptr->level != 0) innocent = FALSE;
1938 if (r_ptr->flags1 & RF1_UNIQUE)
1939 chg_virtue(V_JUSTICE, 3);
1940 else if (1+((r_ptr->level) / 10 + (2 * dun_level))
1942 chg_virtue(V_JUSTICE, 1);
1946 chg_virtue (V_JUSTICE, -1);
1949 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)))
1951 if (one_in_(4)) chg_virtue(V_NATURE, -1);
1954 if ((r_ptr->flags1 & RF1_UNIQUE) && record_destroy_uniq)
1958 sprintf(note_buf, "%s%s", r_name + r_ptr->name, (m_ptr->smart & SM_CLONED) ? "(¥¯¥í¡¼¥ó)" : "");
1960 sprintf(note_buf, "%s%s", r_name + r_ptr->name, (m_ptr->smart & SM_CLONED) ? "(Clone)" : "");
1962 do_cmd_write_nikki(NIKKI_UNIQUE, 0, note_buf);
1968 /* Death by Missile/Spell attack */
1971 msg_format("%^s%s", m_name, note);
1974 /* Death by physical attack -- invisible monster */
1975 else if (!m_ptr->ml)
1978 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
1979 msg_format("¤»¤Ã¤«¤¯¤À¤«¤é%s¤ò»¦¤·¤¿¡£", m_name);
1981 msg_format("%s¤ò»¦¤·¤¿¡£", m_name);
1983 msg_format("You have killed %s.", m_name);
1988 /* Death by Physical attack -- non-living monster */
1989 else if (!monster_living(r_ptr))
1992 bool explode = FALSE;
1994 for (i = 0; i < 4; i++)
1996 if (r_ptr->blow[i].method == RBM_EXPLODE) explode = TRUE;
1999 /* Special note at death */
2002 msg_format("%s¤ÏÇúȯ¤·¤ÆÊ´¡¹¤Ë¤Ê¤Ã¤¿¡£", m_name);
2004 msg_format("%s explodes into tiny shreds.", m_name);
2009 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
2010 msg_format("¤»¤Ã¤«¤¯¤À¤«¤é%s¤òÅݤ·¤¿¡£", m_name);
2012 msg_format("%s¤òÅݤ·¤¿¡£", m_name);
2014 msg_format("You have destroyed %s.", m_name);
2019 /* Death by Physical attack -- living monster */
2023 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
2024 msg_format("¤»¤Ã¤«¤¯¤À¤«¤é%s¤òÁò¤êµî¤Ã¤¿¡£", m_name);
2026 msg_format("%s¤òÁò¤êµî¤Ã¤¿¡£", m_name);
2028 msg_format("You have slain %s.", m_name);
2032 if ((r_ptr->flags1 & RF1_UNIQUE) && !(m_ptr->smart & SM_CLONED) && !vanilla_town)
2034 for (i = 0; i < MAX_KUBI; i++)
2036 if ((kubi_r_idx[i] == m_ptr->r_idx) && !(m_ptr->mflag2 & MFLAG2_CHAMELEON))
2039 msg_format("%s¤Î¼ó¤Ë¤Ï¾Þ¶â¤¬¤«¤«¤Ã¤Æ¤¤¤ë¡£", m_name);
2041 msg_format("There is a price on %s's head.", m_name);
2048 /* Generate treasure */
2049 monster_death(m_idx, TRUE);
2051 /* Mega hack : replace IKETA to BIKETAL */
2052 if ((m_ptr->r_idx == MON_IKETA) &&
2053 !(p_ptr->inside_arena || p_ptr->inside_battle))
2055 int dummy_y = m_ptr->fy;
2056 int dummy_x = m_ptr->fx;
2059 if (is_pet(m_ptr)) mode |= PM_FORCE_PET;
2061 /* Delete the monster */
2062 delete_monster_idx(m_idx);
2064 if (summon_named_creature(0, dummy_y, dummy_x, MON_BIKETAL, mode))
2067 msg_print("¡Ö¥Ï¥¡¥Ã¥Ï¥Ã¥Ï¥Ã¥Ï¡ª¡ª»ä¤¬¥Ð¥¤¥±¥¿¥ë¤À¡ª¡ª¡×");
2069 msg_print("Uwa-hahaha! *I* am Biketal!");
2075 /* Delete the monster */
2076 delete_monster_idx(m_idx);
2079 /* Prevent bug of chaos patron's reward */
2080 if (r_ptr->flags7 & RF7_KILL_EXP)
2081 get_exp_from_mon((long)exp_mon.max_maxhp*2, &exp_mon);
2083 get_exp_from_mon(((long)exp_mon.max_maxhp+1L) * 9L / 10L, &exp_mon);
2088 /* Monster is dead */
2095 /* Mega-Hack -- Pain cancels fear */
2096 if (m_ptr->monfear && (dam > 0))
2098 int tmp = randint1(dam);
2100 /* Cure a little fear */
2101 if (tmp < m_ptr->monfear)
2104 m_ptr->monfear -= tmp;
2107 /* Cure all the fear */
2112 if (!need_mproc(m_ptr)) mproc_remove(m_ptr->mproc_idx);
2119 /* Sometimes a monster gets scared by damage */
2120 if (!m_ptr->monfear && !(r_ptr->flags3 & (RF3_NO_FEAR)))
2124 /* Percentage of fully healthy */
2125 percentage = (100L * m_ptr->hp) / m_ptr->maxhp;
2128 * Run (sometimes) if at 10% or less of max hit points,
2129 * or (usually) when hit for half its current hit points
2131 if ((randint1(10) >= percentage) ||
2132 ((dam >= m_ptr->hp) && (randint0(100) < 80)))
2134 /* Hack -- note fear */
2137 if (!m_ptr->mproc_idx) mproc_add(m_idx);
2139 /* XXX XXX XXX Hack -- Add some timed fear */
2140 m_ptr->monfear = (randint1(10) +
2141 (((dam >= m_ptr->hp) && (percentage > 7)) ?
2142 20 : ((11 - percentage) * 5)));
2149 if (p_ptr->riding && (p_ptr->riding == m_idx) && (dam > 0))
2153 /* Extract monster name */
2154 monster_desc(m_name, m_ptr, 0);
2156 if (m_ptr->hp > m_ptr->maxhp/3) dam = (dam + 1) / 2;
2157 if (rakuba((dam > 200) ? 200 : dam, FALSE))
2160 msg_format("%^s¤Ë¿¶¤êÍî¤È¤µ¤ì¤¿¡ª", m_name);
2162 msg_format("%^s has thrown you off!", m_name);
2174 * Get term size and calculate screen size
2176 void get_screen_size(int *wid_p, int *hgt_p)
2178 Term_get_size(wid_p, hgt_p);
2179 *hgt_p -= ROW_MAP + 2;
2180 *wid_p -= COL_MAP + 2;
2181 if (use_bigtile) *wid_p /= 2;
2186 * Calculates current boundaries
2187 * Called below and from "do_cmd_locate()".
2189 void panel_bounds_center(void)
2194 get_screen_size(&wid, &hgt);
2196 panel_row_max = panel_row_min + hgt - 1;
2197 panel_row_prt = panel_row_min - 1;
2198 panel_col_max = panel_col_min + wid - 1;
2199 panel_col_prt = panel_col_min - 13;
2204 * Map resizing whenever the main term changes size
2206 void resize_map(void)
2208 /* Only if the dungeon exists */
2209 if (!character_dungeon) return;
2211 /* Mega-Hack -- no panel yet */
2215 /* Reset the panels */
2216 panel_row_min = cur_hgt;
2217 panel_col_min = cur_wid;
2222 p_ptr->update |= (PU_TORCH | PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
2224 /* Forget lite/view */
2225 p_ptr->update |= (PU_UN_VIEW | PU_UN_LITE);
2227 /* Update lite/view */
2228 p_ptr->update |= (PU_VIEW | PU_LITE | PU_MON_LITE);
2230 /* Update monsters */
2231 p_ptr->update |= (PU_MONSTERS);
2233 /* Redraw everything */
2234 p_ptr->redraw |= (PR_WIPE | PR_BASIC | PR_EXTRA | PR_MAP | PR_EQUIPPY);
2236 /* Hack -- update */
2244 * Place the cursor on the player
2246 if (can_save) move_cursor_relative(py, px);
2253 * Redraw a term when it is resized
2255 void redraw_window(void)
2257 /* Only if the dungeon exists */
2258 if (!character_dungeon) return;
2260 /* Hack - Activate term zero for the redraw */
2261 Term_activate(&term_screen[0]);
2263 /* Hack -- react to changes */
2264 Term_xtra(TERM_XTRA_REACT, 0);
2267 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_SPELL | PW_PLAYER);
2270 p_ptr->window |= (PW_MESSAGE | PW_OVERHEAD | PW_DUNGEON | PW_MONSTER | PW_OBJECT);
2272 /* Hack -- update */
2284 * Handle a request to change the current panel
2286 * Return TRUE if the panel was changed.
2288 * Also used in do_cmd_locate
2290 bool change_panel(int dy, int dx)
2296 get_screen_size(&wid, &hgt);
2298 /* Apply the motion */
2299 y = panel_row_min + dy * hgt / 2;
2300 x = panel_col_min + dx * wid / 2;
2302 /* Verify the row */
2303 if (y > cur_hgt - hgt) y = cur_hgt - hgt;
2306 /* Verify the col */
2307 if (x > cur_wid - wid) x = cur_wid - wid;
2310 /* Handle "changes" */
2311 if ((y != panel_row_min) || (x != panel_col_min))
2313 /* Save the new panel info */
2317 /* Recalculate the boundaries */
2318 panel_bounds_center();
2321 p_ptr->update |= (PU_MONSTERS);
2324 p_ptr->redraw |= (PR_MAP);
2339 * Given an row (y) and col (x), this routine detects when a move
2340 * off the screen has occurred and figures new borders. -RAK-
2342 * "Update" forces a "full update" to take place.
2344 * The map is reprinted if necessary, and "TRUE" is returned.
2346 void verify_panel(void)
2358 get_screen_size(&wid, &hgt);
2360 max_prow_min = cur_hgt - hgt;
2361 max_pcol_min = cur_wid - wid;
2363 /* Bounds checking */
2364 if (max_prow_min < 0) max_prow_min = 0;
2365 if (max_pcol_min < 0) max_pcol_min = 0;
2367 /* Center on player */
2368 if (center_player && (center_running || !running))
2370 /* Center vertically */
2371 prow_min = y - hgt / 2;
2372 if (prow_min < 0) prow_min = 0;
2373 else if (prow_min > max_prow_min) prow_min = max_prow_min;
2375 /* Center horizontally */
2376 pcol_min = x - wid / 2;
2377 if (pcol_min < 0) pcol_min = 0;
2378 else if (pcol_min > max_pcol_min) pcol_min = max_pcol_min;
2382 prow_min = panel_row_min;
2383 pcol_min = panel_col_min;
2385 /* Scroll screen when 2 grids from top/bottom edge */
2386 if (y > panel_row_max - 2)
2388 while (y > prow_min + hgt-1 - 2)
2390 prow_min += (hgt / 2);
2394 if (y < panel_row_min + 2)
2396 while (y < prow_min + 2)
2398 prow_min -= (hgt / 2);
2402 if (prow_min > max_prow_min) prow_min = max_prow_min;
2403 if (prow_min < 0) prow_min = 0;
2405 /* Scroll screen when 4 grids from left/right edge */
2406 if (x > panel_col_max - 4)
2408 while (x > pcol_min + wid-1 - 4)
2410 pcol_min += (wid / 2);
2414 if (x < panel_col_min + 4)
2416 while (x < pcol_min + 4)
2418 pcol_min -= (wid / 2);
2422 if (pcol_min > max_pcol_min) pcol_min = max_pcol_min;
2423 if (pcol_min < 0) pcol_min = 0;
2426 /* Check for "no change" */
2427 if ((prow_min == panel_row_min) && (pcol_min == panel_col_min)) return;
2429 /* Save the new panel info */
2430 panel_row_min = prow_min;
2431 panel_col_min = pcol_min;
2433 /* Hack -- optional disturb on "panel change" */
2434 if (disturb_panel && !center_player) disturb(0, 0);
2436 /* Recalculate the boundaries */
2437 panel_bounds_center();
2440 p_ptr->update |= (PU_MONSTERS);
2443 p_ptr->redraw |= (PR_MAP);
2446 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
2451 * Monster health description
2453 cptr look_mon_desc(monster_type *m_ptr, u32b mode)
2455 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
2462 /* Determine if the monster is "living" */
2463 living = monster_living(ap_r_ptr);
2465 /* Calculate a health "percentage" */
2466 perc = 100L * m_ptr->hp / m_ptr->maxhp;
2468 /* Healthy monsters */
2469 if (m_ptr->hp >= m_ptr->maxhp)
2473 desc = living ? "̵½ý" : "̵¥À¥á¡¼¥¸";
2475 desc = living ? "unhurt" : "undamaged";
2480 else if (perc >= 60)
2483 desc = living ? "·Ú½ý" : "¾®¥À¥á¡¼¥¸";
2485 desc = living ? "somewhat wounded" : "somewhat damaged";
2490 else if (perc >= 25)
2493 desc = living ? "Éé½ý" : "Ãæ¥À¥á¡¼¥¸";
2495 desc = living ? "wounded" : "damaged";
2500 else if (perc >= 10)
2503 desc = living ? "½Å½ý" : "Âç¥À¥á¡¼¥¸";
2505 desc = living ? "badly wounded" : "badly damaged";
2513 desc = living ? "Ⱦ»àȾÀ¸" : "Åݤ줫¤±";
2515 desc = living ? "almost dead" : "almost destroyed";
2520 /* Need attitude information? */
2523 /* Full information is not needed */
2526 else if (is_pet(m_ptr))
2529 attitude = ", ¥Ú¥Ã¥È";
2534 else if (is_friendly(m_ptr))
2537 attitude = ", ͧ¹¥Åª";
2539 attitude = ", friendly";
2552 /* Clone monster? */
2553 if (m_ptr->smart & SM_CLONED)
2562 /* Display monster's level --- idea borrowed from ToME */
2563 if (ap_r_ptr->r_tkills && !(m_ptr->mflag2 & MFLAG2_KAGE))
2566 return format("¥ì¥Ù¥ë%d, %s%s%s", ap_r_ptr->level, desc, attitude, clone);
2568 return format("Level %d, %s%s%s", ap_r_ptr->level, desc, attitude, clone);
2574 return format("¥ì¥Ù¥ë???, %s%s%s", desc, attitude, clone);
2576 return format("Level ???, %s%s%s", desc, attitude, clone);
2584 * Angband sorting algorithm -- quick sort in place
2586 * Note that the details of the data we are sorting is hidden,
2587 * and we rely on the "ang_sort_comp()" and "ang_sort_swap()"
2588 * function hooks to interact with the data, which is given as
2589 * two pointers, and which may have any user-defined form.
2591 void ang_sort_aux(vptr u, vptr v, int p, int q)
2609 while (!(*ang_sort_comp)(u, v, b, z)) b--;
2612 while (!(*ang_sort_comp)(u, v, z, a)) a++;
2614 /* Done partition */
2618 (*ang_sort_swap)(u, v, a, b);
2624 /* Recurse left side */
2625 ang_sort_aux(u, v, p, b);
2627 /* Recurse right side */
2628 ang_sort_aux(u, v, b+1, q);
2633 * Angband sorting algorithm -- quick sort in place
2635 * Note that the details of the data we are sorting is hidden,
2636 * and we rely on the "ang_sort_comp()" and "ang_sort_swap()"
2637 * function hooks to interact with the data, which is given as
2638 * two pointers, and which may have any user-defined form.
2640 void ang_sort(vptr u, vptr v, int n)
2642 /* Sort the array */
2643 ang_sort_aux(u, v, 0, n-1);
2648 /*** Targeting Code ***/
2652 * Determine is a monster makes a reasonable target
2654 * The concept of "targeting" was stolen from "Morgul" (?)
2656 * The player can target any location, or any "target-able" monster.
2658 * Currently, a monster is "target_able" if it is visible, and if
2659 * the player can hit it with a projection, and the player is not
2660 * hallucinating. This allows use of "use closest target" macros.
2662 * Future versions may restrict the ability to target "trappers"
2663 * and "mimics", but the semantics is a little bit weird.
2665 bool target_able(int m_idx)
2667 monster_type *m_ptr = &m_list[m_idx];
2669 /* Monster must be alive */
2670 if (!m_ptr->r_idx) return (FALSE);
2672 /* Hack -- no targeting hallucinations */
2673 if (p_ptr->image) return (FALSE);
2675 /* Monster must be visible */
2676 if (!m_ptr->ml) return (FALSE);
2678 if (p_ptr->riding && (p_ptr->riding == m_idx)) return (TRUE);
2680 /* Monster must be projectable */
2681 if (!projectable(py, px, m_ptr->fy, m_ptr->fx)) return (FALSE);
2683 /* XXX XXX XXX Hack -- Never target trappers */
2684 /* if (CLEAR_ATTR && (CLEAR_CHAR)) return (FALSE); */
2694 * Update (if necessary) and verify (if possible) the target.
2696 * We return TRUE if the target is "okay" and FALSE otherwise.
2698 bool target_okay(void)
2700 /* Accept stationary targets */
2701 if (target_who < 0) return (TRUE);
2703 /* Check moving targets */
2706 /* Accept reasonable targets */
2707 if (target_able(target_who))
2709 monster_type *m_ptr = &m_list[target_who];
2711 /* Acquire monster location */
2712 target_row = m_ptr->fy;
2713 target_col = m_ptr->fx;
2720 /* Assume no target */
2727 * Sorting hook -- comp function -- by "distance to player"
2729 * We use "u" and "v" to point to arrays of "x" and "y" positions,
2730 * and sort the arrays by double-distance to the player.
2732 static bool ang_sort_comp_distance(vptr u, vptr v, int a, int b)
2734 byte *x = (byte*)(u);
2735 byte *y = (byte*)(v);
2739 /* Absolute distance components */
2740 kx = x[a]; kx -= px; kx = ABS(kx);
2741 ky = y[a]; ky -= py; ky = ABS(ky);
2743 /* Approximate Double Distance to the first point */
2744 da = ((kx > ky) ? (kx + kx + ky) : (ky + ky + kx));
2746 /* Absolute distance components */
2747 kx = x[b]; kx -= px; kx = ABS(kx);
2748 ky = y[b]; ky -= py; ky = ABS(ky);
2750 /* Approximate Double Distance to the first point */
2751 db = ((kx > ky) ? (kx + kx + ky) : (ky + ky + kx));
2753 /* Compare the distances */
2759 * Sorting hook -- swap function -- by "distance to player"
2761 * We use "u" and "v" to point to arrays of "x" and "y" positions,
2762 * and sort the arrays by distance to the player.
2764 static void ang_sort_swap_distance(vptr u, vptr v, int a, int b)
2766 byte *x = (byte*)(u);
2767 byte *y = (byte*)(v);
2785 * Hack -- help "select" a location (see below)
2787 static s16b target_pick(int y1, int x1, int dy, int dx)
2791 int x2, y2, x3, y3, x4, y4;
2793 int b_i = -1, b_v = 9999;
2796 /* Scan the locations */
2797 for (i = 0; i < temp_n; i++)
2803 /* Directed distance */
2807 /* Verify quadrant */
2808 if (dx && (x3 * dx <= 0)) continue;
2809 if (dy && (y3 * dy <= 0)) continue;
2811 /* Absolute distance */
2815 /* Verify quadrant */
2816 if (dy && !dx && (x4 > y4)) continue;
2817 if (dx && !dy && (y4 > x4)) continue;
2819 /* Approximate Double Distance */
2820 v = ((x4 > y4) ? (x4 + x4 + y4) : (y4 + y4 + x4));
2822 /* XXX XXX XXX Penalize location */
2825 if ((b_i >= 0) && (v >= b_v)) continue;
2837 * Hack -- determine if a given location is "interesting"
2839 static bool target_set_accept(int y, int x)
2843 s16b this_o_idx, next_o_idx = 0;
2846 if (!(in_bounds(y, x))) return (FALSE);
2848 /* Player grid is always interesting */
2849 if (player_bold(y, x)) return (TRUE);
2852 /* Handle hallucination */
2853 if (p_ptr->image) return (FALSE);
2856 /* Examine the grid */
2857 c_ptr = &cave[y][x];
2859 /* Visible monsters */
2862 monster_type *m_ptr = &m_list[c_ptr->m_idx];
2864 /* Visible monsters */
2865 if (m_ptr->ml) return (TRUE);
2868 /* Scan all objects in the grid */
2869 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
2873 /* Acquire object */
2874 o_ptr = &o_list[this_o_idx];
2876 /* Acquire next object */
2877 next_o_idx = o_ptr->next_o_idx;
2879 /* Memorized object */
2880 if (o_ptr->marked & OM_FOUND) return (TRUE);
2883 /* Interesting memorized features */
2884 if (c_ptr->info & (CAVE_MARK))
2886 /* Notice object features */
2887 if (c_ptr->info & CAVE_OBJECT) return (TRUE);
2889 /* Feature code (applying "mimic" field) */
2890 if (have_flag(f_info[get_feat_mimic(c_ptr)].flags, FF_NOTICE)) return TRUE;
2899 * Prepare the "temp" array for "target_set"
2901 * Return the number of target_able monsters in the set.
2903 static void target_set_prepare(int mode)
2907 /* Reset "temp" array */
2910 /* Scan the current panel */
2911 for (y = panel_row_min; y <= panel_row_max; y++)
2913 for (x = panel_col_min; x <= panel_col_max; x++)
2917 /* Require "interesting" contents */
2918 if (!target_set_accept(y, x)) continue;
2920 c_ptr = &cave[y][x];
2922 /* Require target_able monsters for "TARGET_KILL" */
2923 if ((mode & (TARGET_KILL)) && !target_able(c_ptr->m_idx)) continue;
2925 if ((mode & (TARGET_KILL)) && !target_pet && is_pet(&m_list[c_ptr->m_idx])) continue;
2927 /* Save the location */
2934 /* Set the sort hooks */
2935 ang_sort_comp = ang_sort_comp_distance;
2936 ang_sort_swap = ang_sort_swap_distance;
2938 /* Sort the positions */
2939 ang_sort(temp_x, temp_y, temp_n);
2941 if (p_ptr->riding && target_pet && (temp_n > 1) && (mode & (TARGET_KILL)))
2946 temp_y[0] = temp_y[1];
2949 temp_x[0] = temp_x[1];
2956 * Evaluate number of kill needed to gain level
2958 static void evaluate_monster_exp(char *buf, monster_type *m_ptr)
2960 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
2962 s32b exp_mon, exp_adv;
2963 u32b exp_mon_frac, exp_adv_frac;
2965 if ((p_ptr->lev >= PY_MAX_LEVEL) || (p_ptr->prace == RACE_ANDROID))
2970 else if (!ap_r_ptr->r_tkills || (m_ptr->mflag2 & MFLAG2_KAGE))
2980 /* The monster's experience point (assuming average monster speed) */
2981 exp_mon = ap_r_ptr->mexp * ap_r_ptr->level;
2983 s64b_div(&exp_mon, &exp_mon_frac, 0, (p_ptr->max_plv + 2));
2986 /* Total experience value for next level */
2987 exp_adv = player_exp[p_ptr->lev -1] * p_ptr->expfact;
2989 s64b_div(&exp_adv, &exp_adv_frac, 0, 100);
2991 /* Experience value need to get */
2992 s64b_sub(&exp_adv, &exp_adv_frac, p_ptr->exp, p_ptr->exp_frac);
2995 /* You need to kill at least one monster to get any experience */
2996 s64b_add(&exp_adv, &exp_adv_frac, exp_mon, exp_mon_frac);
2997 s64b_sub(&exp_adv, &exp_adv_frac, 0, 1);
2999 /* Extract number of monsters needed */
3000 s64b_div(&exp_adv, &exp_adv_frac, exp_mon, exp_mon_frac);
3002 /* If 999 or more monsters needed, only display "999". */
3003 num = MIN(999, exp_adv_frac);
3005 /* Display the number */
3006 sprintf(buf,"%03ld", num);
3011 * Examine a grid, return a keypress.
3013 * The "mode" argument contains the "TARGET_LOOK" bit flag, which
3014 * indicates that the "space" key should scan through the contents
3015 * of the grid, instead of simply returning immediately. This lets
3016 * the "look" command get complete information, without making the
3017 * "target" command annoying.
3019 * The "info" argument contains the "commands" which should be shown
3020 * inside the "[xxx]" text. This string must never be empty, or grids
3021 * containing monsters will be displayed with an extra comma.
3023 * Note that if a monster is in the grid, we update both the monster
3024 * recall info and the health bar info to track that monster.
3026 * Eventually, we may allow multiple objects per grid, or objects
3027 * and terrain features in the same grid. XXX XXX XXX
3029 * This function must handle blindness/hallucination.
3031 static int target_set_aux(int y, int x, int mode, cptr info)
3033 cave_type *c_ptr = &cave[y][x];
3034 s16b this_o_idx, next_o_idx = 0;
3035 cptr s1 = "", s2 = "", s3 = "", x_info = "";
3038 feature_type *f_ptr;
3040 char out_val[MAX_NLEN+80];
3042 #ifdef ALLOW_EASY_FLOOR
3043 int floor_list[23], floor_num = 0;
3045 /* Scan all objects in the grid */
3048 floor_num = scan_floor(floor_list, y, x, 0x02);
3060 #endif /* ALLOW_EASY_FLOOR */
3062 /* Hack -- under the player */
3063 if (player_bold(y, x))
3086 /* Hack -- hallucination */
3090 cptr name = "²¿¤«´ñ̯¤Êʪ";
3092 cptr name = "something strange";
3096 /* Display a message */
3098 sprintf(out_val, "%s%s%s%s [%s]", s1, name, s2, s3, info);
3100 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, name, info);
3104 move_cursor_relative(y, x);
3107 /* Stop on everything but "return" */
3108 if ((query != '\r') && (query != '\n')) return query;
3110 /* Repeat forever */
3115 /* Actual monsters */
3116 if (c_ptr->m_idx && m_list[c_ptr->m_idx].ml)
3118 monster_type *m_ptr = &m_list[c_ptr->m_idx];
3119 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
3121 bool recall = FALSE;
3126 /* Get the monster name ("a kobold") */
3127 monster_desc(m_name, m_ptr, MD_INDEF_VISIBLE);
3129 /* Hack -- track this monster race */
3130 monster_race_track(m_ptr->ap_r_idx);
3132 /* Hack -- health bar for this monster */
3133 health_track(c_ptr->m_idx);
3135 /* Hack -- handle stuff */
3149 /* Recall on screen */
3150 screen_roff(m_ptr->ap_r_idx, 0);
3152 /* Hack -- Complete the prompt (again) */
3154 Term_addstr(-1, TERM_WHITE, format(" [r»× %s%s]", x_info, info));
3156 Term_addstr(-1, TERM_WHITE, format(" [r,%s%s]", x_info, info));
3165 /* Normal commands */
3166 if (query != 'r') break;
3171 /* Cleare recall text and repeat */
3177 /* Describe, and prompt for recall */
3178 evaluate_monster_exp(acount, m_ptr);
3181 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);
3183 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);
3189 move_cursor_relative(y, x);
3194 /* Normal commands */
3195 if (query != 'r') break;
3201 /* Always stop at "normal" keys */
3202 if ((query != '\r') && (query != '\n') && (query != ' ') && (query != 'x')) return query;
3204 /* Sometimes stop at "space" key */
3205 if ((query == ' ') && !(mode & (TARGET_LOOK))) return query;
3207 /* Change the intro */
3215 /* Hack -- take account of gender */
3217 if (ap_r_ptr->flags1 & (RF1_FEMALE)) s1 = "Èà½÷¤Ï";
3219 if (ap_r_ptr->flags1 & (RF1_FEMALE)) s1 = "She is ";
3223 else if (ap_r_ptr->flags1 & (RF1_MALE)) s1 = "Èà¤Ï";
3225 else if (ap_r_ptr->flags1 & (RF1_MALE)) s1 = "He is ";
3229 /* Use a preposition */
3238 /* Scan all objects being carried */
3239 for (this_o_idx = m_ptr->hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
3241 char o_name[MAX_NLEN];
3245 /* Acquire object */
3246 o_ptr = &o_list[this_o_idx];
3248 /* Acquire next object */
3249 next_o_idx = o_ptr->next_o_idx;
3251 /* Obtain an object description */
3252 object_desc(o_name, o_ptr, 0);
3254 /* Describe the object */
3256 sprintf(out_val, "%s%s%s%s[%s]", s1, o_name, s2, s3, info);
3258 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, o_name, info);
3262 move_cursor_relative(y, x);
3265 /* Always stop at "normal" keys */
3266 if ((query != '\r') && (query != '\n') && (query != ' ') && (query != 'x')) return query;
3268 /* Sometimes stop at "space" key */
3269 if ((query == ' ') && !(mode & (TARGET_LOOK))) return query;
3271 /* Change the intro */
3275 s2 = "also carrying ";
3279 /* Use a preposition */
3289 #ifdef ALLOW_EASY_FLOOR
3298 char o_name[MAX_NLEN];
3302 /* Acquire object */
3303 o_ptr = &o_list[floor_list[0]];
3305 /* Describe the object */
3306 object_desc(o_name, o_ptr, 0);
3310 sprintf(out_val, "%s%s%s%s[%s]",
3311 s1, o_name, s2, s3, info);
3313 sprintf(out_val, "%s%s%s%s [%s]",
3314 s1, s2, s3, o_name, info);
3318 move_cursor_relative(y, x);
3327 /* Provide one cushion before item listing */
3330 /* Display rough information about items */
3332 sprintf(out_val, "%s %d¸Ä¤Î¥¢¥¤¥Æ¥à%s%s ['x'¤Ç°ìÍ÷, %s]",
3333 s1, floor_num, s2, s3, info);
3335 sprintf(out_val, "%s%s%sa pile of %d items [x,%s]",
3336 s1, s2, s3, floor_num, info);
3340 move_cursor_relative(y, x);
3345 /* No request for listing */
3346 if (query != 'x' && query != ' ') return query;
3350 /** Display list of items **/
3352 /* Continue scrolling list if requested */
3361 (void)show_floor(0, y, x, &min_width);
3365 sprintf(out_val, "%s %d¸Ä¤Î¥¢¥¤¥Æ¥à%s%s [Enter¤Ç¼¡¤Ø, %s]",
3366 s1, floor_num, s2, s3, info);
3368 sprintf(out_val, "%s%s%sa pile of %d items [Enter,%s]",
3369 s1, s2, s3, floor_num, info);
3380 /* Exit unless 'Enter' */
3381 if (query != '\n' && query != '\r')
3386 /* Get the object being moved. */
3387 o_idx = c_ptr->o_idx;
3389 /* Only rotate a pile of two or more objects. */
3390 if (!(o_idx && o_list[o_idx].next_o_idx)) continue;
3392 /* Remove the first object from the list. */
3393 excise_object_idx(o_idx);
3395 /* Find end of the list. */
3397 while (o_list[i].next_o_idx)
3398 i = o_list[i].next_o_idx;
3400 /* Add after the last object. */
3401 o_list[i].next_o_idx = o_idx;
3403 /* Loop and re-display the list */
3409 #endif /* ALLOW_EASY_FLOOR */
3412 /* Scan all objects in the grid */
3413 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
3417 /* Acquire object */
3418 o_ptr = &o_list[this_o_idx];
3420 /* Acquire next object */
3421 next_o_idx = o_ptr->next_o_idx;
3424 if (o_ptr->marked & OM_FOUND)
3426 char o_name[MAX_NLEN];
3431 /* Obtain an object description */
3432 object_desc(o_name, o_ptr, 0);
3434 /* Describe the object */
3436 sprintf(out_val, "%s%s%s%s[%s]", s1, o_name, s2, s3, info);
3438 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, o_name, info);
3442 move_cursor_relative(y, x);
3445 /* Always stop at "normal" keys */
3446 if ((query != '\r') && (query != '\n') && (query != ' ') && (query != 'x')) return query;
3448 /* Sometimes stop at "space" key */
3449 if ((query == ' ') && !(mode & TARGET_LOOK)) return query;
3451 /* Change the intro */
3461 if (o_ptr->number != 1) s1 = "¤½¤ì¤é¤Ï";
3463 if (o_ptr->number != 1) s1 = "They are ";
3479 /* Feature code (applying "mimic" field) */
3480 feat = get_feat_mimic(c_ptr);
3482 /* Require knowledge about grid, or ability to see grid */
3483 if (!(c_ptr->info & CAVE_MARK) && !player_can_see_bold(y, x))
3485 /* Forget feature */
3489 f_ptr = &f_info[feat];
3491 /* Terrain feature if needed */
3492 if (boring || have_flag(f_ptr->flags, FF_REMEMBER))
3496 /* Hack -- special handling for building doors */
3497 if (have_flag(f_ptr->flags, FF_BLDG) && !p_ptr->inside_arena)
3499 name = building[f_ptr->power].name;
3501 else if (have_flag(f_ptr->flags, FF_ENTRANCE))
3504 name = format("%s(%d³¬ÁêÅö)", d_text + d_info[c_ptr->special].text, d_info[c_ptr->special].mindepth);
3506 name = format("%s(level %d)", d_text + d_info[c_ptr->special].text, d_info[c_ptr->special].mindepth);
3509 else if (have_flag(f_ptr->flags, FF_TOWN))
3511 name = town[c_ptr->special].name;
3513 else if (p_ptr->wild_mode && (feat == FEAT_FLOOR))
3523 name = f_name + f_ptr->name;
3529 ((!have_flag(f_ptr->flags, FF_MOVE) && !have_flag(f_ptr->flags, FF_CAN_FLY)) ||
3530 (!have_flag(f_ptr->flags, FF_LOS) && !have_flag(f_ptr->flags, FF_TREE)) ||
3531 have_flag(f_ptr->flags, FF_TOWN)))
3540 /* Hack -- special introduction for store & building doors -KMW- */
3541 if (have_flag(f_ptr->flags, FF_STORE) ||
3542 (have_flag(f_ptr->flags, FF_BLDG) && !p_ptr->inside_arena) ||
3543 have_flag(f_ptr->flags, FF_ENTRANCE))
3552 else if (have_flag(f_ptr->flags, FF_FLOOR) ||
3553 have_flag(f_ptr->flags, FF_TOWN) ||
3554 have_flag(f_ptr->flags, FF_SHALLOW) ||
3555 have_flag(f_ptr->flags, FF_DEEP))
3561 /* Pick proper indefinite article */
3562 s3 = (is_a_vowel(name[0])) ? "an " : "a ";
3566 /* Display a message */
3570 if (c_ptr->mimic) sprintf(f_idx_str, "%d/%d", c_ptr->feat, c_ptr->mimic);
3571 else sprintf(f_idx_str, "%d", c_ptr->feat);
3573 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);
3575 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);
3580 sprintf(out_val, "%s%s%s%s[%s]", s1, name, s2, s3, info);
3582 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, name, info);
3586 move_cursor_relative(y, x);
3589 /* Always stop at "normal" keys */
3590 if ((query != '\r') && (query != '\n') && (query != ' ')) return query;
3593 /* Stop on everything but "return" */
3594 if ((query != '\r') && (query != '\n')) return query;
3596 /* Repeat forever */
3602 * Handle "target" and "look".
3604 * Note that this code can be called from "get_aim_dir()".
3606 * All locations must be on the current panel. Consider the use of
3607 * "panel_bounds()" to allow "off-panel" targets, perhaps by using
3608 * some form of "scrolling" the map around the cursor. XXX XXX XXX
3609 * That is, consider the possibility of "auto-scrolling" the screen
3610 * while the cursor moves around. This may require changes in the
3611 * "update_mon()" code to allow "visibility" even if off panel, and
3612 * may require dynamic recalculation of the "temp" grid set.
3614 * Hack -- targeting/observing an "outer border grid" may induce
3615 * problems, so this is not currently allowed.
3617 * The player can use the direction keys to move among "interesting"
3618 * grids in a heuristic manner, or the "space", "+", and "-" keys to
3619 * move through the "interesting" grids in a sequential manner, or
3620 * can enter "location" mode, and use the direction keys to move one
3621 * grid at a time in any direction. The "t" (set target) command will
3622 * only target a monster (as opposed to a location) if the monster is
3623 * target_able and the "interesting" mode is being used.
3625 * The current grid is described using the "look" method above, and
3626 * a new command may be entered at any time, but note that if the
3627 * "TARGET_LOOK" bit flag is set (or if we are in "location" mode,
3628 * where "space" has no obvious meaning) then "space" will scan
3629 * through the description of the current grid until done, instead
3630 * of immediately jumping to the next "interesting" grid. This
3631 * allows the "target" command to retain its old semantics.
3633 * The "*", "+", and "-" keys may always be used to jump immediately
3634 * to the next (or previous) interesting grid, in the proper mode.
3636 * The "return" key may always be used to scan through a complete
3637 * grid description (forever).
3639 * This command will cancel any old target, even if used from
3640 * inside the "look" command.
3642 bool target_set(int mode)
3662 get_screen_size(&wid, &hgt);
3668 /* Cancel tracking */
3669 /* health_track(0); */
3672 /* Prepare the "temp" array */
3673 target_set_prepare(mode);
3675 /* Start near the player */
3681 /* Interesting grids */
3687 if (!(mode & TARGET_LOOK)) prt_path(y, x);
3690 c_ptr = &cave[y][x];
3693 if (target_able(c_ptr->m_idx))
3696 strcpy(info, "q»ß t·è p¼« o¸½ +¼¡ -Á°");
3698 strcpy(info, "q,t,p,o,+,-,<dir>");
3703 /* Dis-allow target */
3707 strcpy(info, "q»ß p¼« o¸½ +¼¡ -Á°");
3709 strcpy(info, "q,p,o,+,-,<dir>");
3714 /* Describe and Prompt */
3715 while (!(query = target_set_aux(y, x, mode, info)));
3717 /* Cancel tracking */
3718 /* health_track(0); */
3720 /* Assume no "direction" */
3725 if (query == '\r') query = 't';
3743 if (target_able(c_ptr->m_idx))
3745 health_track(c_ptr->m_idx);
3746 target_who = c_ptr->m_idx;
3765 if (!expand_list) done = TRUE;
3775 if (!expand_list) done = TRUE;
3782 /* Recenter the map around the player */
3786 p_ptr->update |= (PU_MONSTERS);
3789 p_ptr->redraw |= (PR_MAP);
3792 p_ptr->window |= (PW_OVERHEAD);
3797 /* Recalculate interesting grids */
3798 target_set_prepare(mode);
3817 /* Extract the action (if any) */
3818 d = get_keymap_dir(query);
3825 /* Hack -- move around */
3828 /* Modified to scroll to monster */
3829 int y2 = panel_row_min;
3830 int x2 = panel_col_min;
3832 /* Find a new monster */
3833 i = target_pick(temp_y[m], temp_x[m], ddy[d], ddx[d]);
3835 /* Request to target past last interesting grid */
3836 while (flag && (i < 0))
3838 /* Note the change */
3839 if (change_panel(ddy[d], ddx[d]))
3844 /* Recalculate interesting grids */
3845 target_set_prepare(mode);
3847 /* Look at interesting grids */
3850 /* Find a new monster */
3851 i = target_pick(v, u, ddy[d], ddx[d]);
3857 /* Nothing interesting */
3863 /* Restore previous position */
3866 panel_bounds_center();
3869 p_ptr->update |= (PU_MONSTERS);
3872 p_ptr->redraw |= (PR_MAP);
3875 p_ptr->window |= (PW_OVERHEAD);
3880 /* Recalculate interesting grids */
3881 target_set_prepare(mode);
3883 /* Look at boring grids */
3890 /* Do not move horizontally if unnecessary */
3891 if (((x < panel_col_min + wid / 2) && (dx > 0)) ||
3892 ((x > panel_col_min + wid / 2) && (dx < 0)))
3897 /* Do not move vertically if unnecessary */
3898 if (((y < panel_row_min + hgt / 2) && (dy > 0)) ||
3899 ((y > panel_row_min + hgt / 2) && (dy < 0)))
3904 /* Apply the motion */
3905 if ((y >= panel_row_min+hgt) || (y < panel_row_min) ||
3906 (x >= panel_col_min+wid) || (x < panel_col_min))
3908 if (change_panel(dy, dx)) target_set_prepare(mode);
3911 /* Slide into legality */
3912 if (x >= cur_wid-1) x = cur_wid - 2;
3913 else if (x <= 0) x = 1;
3915 /* Slide into legality */
3916 if (y >= cur_hgt-1) y = cur_hgt- 2;
3917 else if (y <= 0) y = 1;
3926 /* Arbitrary grids */
3929 bool move_fast = FALSE;
3931 if (!(mode & TARGET_LOOK)) prt_path(y, x);
3934 c_ptr = &cave[y][x];
3936 /* Default prompt */
3938 strcpy(info, "q»ß t·è p¼« m¶á +¼¡ -Á°");
3940 strcpy(info, "q,t,p,m,+,-,<dir>");
3944 /* Describe and Prompt (enable "TARGET_LOOK") */
3945 while (!(query = target_set_aux(y, x, mode | TARGET_LOOK, info)));
3947 /* Cancel tracking */
3948 /* health_track(0); */
3950 /* Assume no direction */
3955 if (query == '\r') query = 't';
3958 /* Analyze the keypress */
3982 /* Recenter the map around the player */
3986 p_ptr->update |= (PU_MONSTERS);
3989 p_ptr->redraw |= (PR_MAP);
3992 p_ptr->window |= (PW_OVERHEAD);
3997 /* Recalculate interesting grids */
3998 target_set_prepare(mode);
4020 /* Pick a nearby monster */
4021 for (i = 0; i < temp_n; i++)
4023 t = distance(y, x, temp_y[i], temp_x[i]);
4033 /* Nothing interesting */
4034 if (bd == 999) flag = FALSE;
4041 /* Extract the action (if any) */
4042 d = get_keymap_dir(query);
4044 /* XTRA HACK MOVEFAST */
4045 if (isupper(query)) move_fast = TRUE;
4052 /* Handle "direction" */
4058 /* XTRA HACK MOVEFAST */
4061 int mag = MIN(wid / 2, hgt / 2);
4071 /* Do not move horizontally if unnecessary */
4072 if (((x < panel_col_min + wid / 2) && (dx > 0)) ||
4073 ((x > panel_col_min + wid / 2) && (dx < 0)))
4078 /* Do not move vertically if unnecessary */
4079 if (((y < panel_row_min + hgt / 2) && (dy > 0)) ||
4080 ((y > panel_row_min + hgt / 2) && (dy < 0)))
4085 /* Apply the motion */
4086 if ((y >= panel_row_min + hgt) || (y < panel_row_min) ||
4087 (x >= panel_col_min + wid) || (x < panel_col_min))
4089 if (change_panel(dy, dx)) target_set_prepare(mode);
4092 /* Slide into legality */
4093 if (x >= cur_wid-1) x = cur_wid - 2;
4094 else if (x <= 0) x = 1;
4096 /* Slide into legality */
4097 if (y >= cur_hgt-1) y = cur_hgt- 2;
4098 else if (y <= 0) y = 1;
4106 /* Clear the top line */
4109 /* Recenter the map around the player */
4113 p_ptr->update |= (PU_MONSTERS);
4116 p_ptr->redraw |= (PR_MAP);
4119 p_ptr->window |= (PW_OVERHEAD);
4124 /* Failure to set target */
4125 if (!target_who) return (FALSE);
4133 * Get an "aiming direction" from the user.
4135 * The "dir" is loaded with 1,2,3,4,6,7,8,9 for "actual direction", and
4136 * "0" for "current target", and "-1" for "entry aborted".
4138 * Note that "Force Target", if set, will pre-empt user interaction,
4139 * if there is a usable target already set.
4141 * Note that confusion over-rides any (explicit?) user choice.
4143 bool get_aim_dir(int *dp)
4154 /* Global direction */
4157 /* Hack -- auto-target if requested */
4158 if (use_old_target && target_okay()) dir = 5;
4160 #ifdef ALLOW_REPEAT /* TNB */
4162 if (repeat_pull(dp))
4167 if (!(*dp == 5 && !target_okay()))
4169 /* return (TRUE); */
4174 #endif /* ALLOW_REPEAT -- TNB */
4176 /* Ask until satisfied */
4179 /* Choose a prompt */
4183 p = "Êý¸þ ('*'¤Ç¥¿¡¼¥²¥Ã¥ÈÁªÂò, ESC¤ÇÃæÃÇ)? ";
4185 p = "Direction ('*' to choose a target, Escape to cancel)? ";
4192 p = "Êý¸þ ('5'¤Ç¥¿¡¼¥²¥Ã¥È¤Ø, '*'¤Ç¥¿¡¼¥²¥Ã¥ÈºÆÁªÂò, ESC¤ÇÃæÃÇ)? ";
4194 p = "Direction ('5' for target, '*' to re-target, Escape to cancel)? ";
4199 /* Get a command (or Cancel) */
4200 if (!get_com(p, &command, TRUE)) break;
4204 if (command == '\r') command = 't';
4207 /* Convert various keys to "standard" keys */
4210 /* Use current target */
4221 /* Set new target */
4226 if (target_set(TARGET_KILL)) dir = 5;
4232 /* Extract the action (if any) */
4233 dir = get_keymap_dir(command);
4239 /* Verify requested targets */
4240 if ((dir == 5) && !target_okay()) dir = 0;
4249 project_length = 0; /* reset to default */
4253 /* Save the direction */
4256 /* Check for confusion */
4257 if (p_ptr->confused)
4260 /* Random direction */
4261 dir = ddd[randint0(8)];
4264 /* Notice confusion */
4265 if (command_dir != dir)
4269 msg_print("¤¢¤Ê¤¿¤Ïº®Í𤷤Ƥ¤¤ë¡£");
4271 msg_print("You are confused.");
4276 /* Save direction */
4279 #ifdef ALLOW_REPEAT /* TNB */
4281 /* repeat_push(dir); */
4282 repeat_push(command_dir);
4284 #endif /* ALLOW_REPEAT -- TNB */
4286 /* A "valid" direction was entered */
4293 * Request a "movement" direction (1,2,3,4,6,7,8,9) from the user,
4294 * and place it into "command_dir", unless we already have one.
4296 * This function should be used for all "repeatable" commands, such as
4297 * run, walk, open, close, bash, disarm, spike, tunnel, etc, as well
4298 * as all commands which must reference a grid adjacent to the player,
4299 * and which may not reference the grid under the player. Note that,
4300 * for example, it is no longer possible to "disarm" or "open" chests
4301 * in the same grid as the player.
4303 * Direction "5" is illegal and will (cleanly) abort the command.
4305 * This function tracks and uses the "global direction", and uses
4306 * that as the "desired direction", to which "confusion" is applied.
4308 bool get_rep_dir(int *dp, bool under)
4315 /* Global direction */
4318 #ifdef ALLOW_REPEAT /* TNB */
4320 if (repeat_pull(dp))
4323 /* return (TRUE); */
4326 #endif /* ALLOW_REPEAT -- TNB */
4328 /* Get a direction */
4333 /* Get a command (or Cancel) */
4335 if (!get_com("Êý¸þ (ESC¤ÇÃæÃÇ)? ", &ch, TRUE)) break;
4337 if (!get_com("Direction (Escape to cancel)? ", &ch, TRUE)) break;
4341 /* Look up the direction */
4342 dir = get_keymap_dir(ch);
4348 /* Prevent weirdness */
4349 if ((dir == 5) && (!under)) dir = 0;
4352 if (!dir) return (FALSE);
4354 /* Save desired direction */
4357 /* Apply "confusion" */
4358 if (p_ptr->confused)
4360 /* Standard confusion */
4361 if (randint0(100) < 75)
4363 /* Random direction */
4364 dir = ddd[randint0(8)];
4367 else if (p_ptr->riding)
4369 monster_type *m_ptr = &m_list[p_ptr->riding];
4370 monster_race *r_ptr = &r_info[m_ptr->r_idx];
4372 if (m_ptr->confused)
4374 /* Standard confusion */
4375 if (randint0(100) < 75)
4377 /* Random direction */
4378 dir = ddd[randint0(8)];
4381 else if ((r_ptr->flags1 & RF1_RAND_50) && (r_ptr->flags1 & RF1_RAND_25) && (randint0(100) < 50))
4383 /* Random direction */
4384 dir = ddd[randint0(8)];
4386 else if ((r_ptr->flags1 & RF1_RAND_50) && (randint0(100) < 25))
4388 /* Random direction */
4389 dir = ddd[randint0(8)];
4393 /* Notice confusion */
4394 if (command_dir != dir)
4396 if (p_ptr->confused)
4400 msg_print("¤¢¤Ê¤¿¤Ïº®Í𤷤Ƥ¤¤ë¡£");
4402 msg_print("You are confused.");
4408 monster_type *m_ptr = &m_list[p_ptr->riding];
4410 monster_desc(m_name, m_ptr, 0);
4411 if (m_ptr->confused)
4414 msg_format("%s¤Ïº®Í𤷤Ƥ¤¤ë¡£", m_name);
4416 msg_format("%^s is confusing.", m_name);
4423 msg_format("%s¤Ï»×¤¤Ä̤ê¤ËÆ°¤¤¤Æ¤¯¤ì¤Ê¤¤¡£", m_name);
4425 msg_format("You cannot control %s.", m_name);
4431 /* Save direction */
4434 #ifdef ALLOW_REPEAT /* TNB */
4436 /* repeat_push(dir); */
4437 repeat_push(command_dir);
4439 #endif /* ALLOW_REPEAT -- TNB */
4446 bool get_rep_dir2(int *dp)
4453 /* Global direction */
4456 #ifdef ALLOW_REPEAT /* TNB */
4458 if (repeat_pull(dp))
4461 /* return (TRUE); */
4464 #endif /* ALLOW_REPEAT -- TNB */
4466 /* Get a direction */
4471 /* Get a command (or Cancel) */
4473 if (!get_com("Êý¸þ (ESC¤ÇÃæÃÇ)? ", &ch, TRUE)) break;
4475 if (!get_com("Direction (Escape to cancel)? ", &ch, TRUE)) break;
4479 /* Look up the direction */
4480 dir = get_keymap_dir(ch);
4486 /* Prevent weirdness */
4487 if (dir == 5) dir = 0;
4490 if (!dir) return (FALSE);
4492 /* Save desired direction */
4495 /* Apply "confusion" */
4496 if (p_ptr->confused)
4498 /* Standard confusion */
4499 if (randint0(100) < 75)
4501 /* Random direction */
4502 dir = ddd[randint0(8)];
4506 /* Notice confusion */
4507 if (command_dir != dir)
4511 msg_print("¤¢¤Ê¤¿¤Ïº®Í𤷤Ƥ¤¤ë¡£");
4513 msg_print("You are confused.");
4518 /* Save direction */
4521 #ifdef ALLOW_REPEAT /* TNB */
4523 /* repeat_push(dir); */
4524 repeat_push(command_dir);
4526 #endif /* ALLOW_REPEAT -- TNB */
4533 void gain_level_reward(int chosen_reward)
4537 char wrath_reason[32] = "";
4538 int nasty_chance = 6;
4539 int dummy = 0, dummy2 = 0;
4542 char o_name[MAX_NLEN];
4548 if (multi_rew) return;
4549 else multi_rew = TRUE;
4553 if (p_ptr->lev == 13) nasty_chance = 2;
4554 else if (!(p_ptr->lev % 13)) nasty_chance = 3;
4555 else if (!(p_ptr->lev % 14)) nasty_chance = 12;
4557 if (one_in_(nasty_chance))
4558 type = randint1(20); /* Allow the 'nasty' effects */
4560 type = randint1(15) + 5; /* Or disallow them */
4562 if (type < 1) type = 1;
4563 if (type > 20) type = 20;
4568 sprintf(wrath_reason, "%s¤ÎÅܤê",
4569 chaos_patrons[p_ptr->chaos_patron]);
4571 sprintf(wrath_reason, "the Wrath of %s",
4572 chaos_patrons[p_ptr->chaos_patron]);
4576 effect = chaos_rewards[p_ptr->chaos_patron][type];
4578 if (one_in_(6) && !chosen_reward)
4581 msg_format("%^s¤ÏË«Èþ¤È¤·¤Æ¤¢¤Ê¤¿¤òÆÍÁ³ÊÑ°Û¤µ¤»¤¿¡£",
4582 chaos_patrons[p_ptr->chaos_patron]);
4584 msg_format("%^s rewards you with a mutation!",
4585 chaos_patrons[p_ptr->chaos_patron]);
4588 (void)gain_random_mutation(0);
4590 reward = "ÊÑ°Û¤·¤¿¡£";
4592 reward = "mutation";
4597 switch (chosen_reward ? chosen_reward : effect)
4601 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
4602 chaos_patrons[p_ptr->chaos_patron]);
4604 msg_format("The voice of %s booms out:",
4605 chaos_patrons[p_ptr->chaos_patron]);
4609 msg_print("¡ÖÆò¡¢¿·¤¿¤Ê¤ë»Ñ¤òɬÍפȤ»¤ê¡ª¡×");
4611 msg_print("'Thou needst a new form, mortal!'");
4616 reward = "ÊÑ°Û¤·¤¿¡£";
4618 reward = "polymorphing";
4623 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
4624 chaos_patrons[p_ptr->chaos_patron]);
4626 msg_format("The voice of %s booms out:",
4627 chaos_patrons[p_ptr->chaos_patron]);
4631 msg_print("¡ÖÆò¤ÏÎɤ¯¹Ô¤¤¤¿¤ê¡ªÂ³¤±¤è¡ª¡×");
4633 msg_print("'Well done, mortal! Lead on!'");
4636 if (p_ptr->prace == RACE_ANDROID)
4639 msg_print("¤·¤«¤·²¿¤âµ¯¤³¤é¤Ê¤«¤Ã¤¿¡£");
4641 msg_print("But, nothing happen.");
4644 else if (p_ptr->exp < PY_MAX_EXP)
4646 s32b ee = (p_ptr->exp / 2) + 10;
4647 if (ee > 100000L) ee = 100000L;
4649 msg_print("¹¹¤Ë·Ð¸³¤òÀѤó¤À¤è¤¦¤Êµ¤¤¬¤¹¤ë¡£");
4651 msg_print("You feel more experienced.");
4656 reward = "·Ð¸³ÃͤòÆÀ¤¿";
4658 reward = "experience";
4664 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
4665 chaos_patrons[p_ptr->chaos_patron]);
4667 msg_format("The voice of %s booms out:",
4668 chaos_patrons[p_ptr->chaos_patron]);
4672 msg_print("¡Ö²¼Ëͤ衢Æò¤½¤ì¤ËÃͤ»¤º¡£¡×");
4674 msg_print("'Thou didst not deserve that, slave.'");
4677 if (p_ptr->prace == RACE_ANDROID)
4680 msg_print("¤·¤«¤·²¿¤âµ¯¤³¤é¤Ê¤«¤Ã¤¿¡£");
4682 msg_print("But, nothing happen.");
4687 lose_exp(p_ptr->exp / 6);
4689 reward = "·Ð¸³Ãͤò¼º¤Ã¤¿¡£";
4691 reward = "losing experience";
4697 msg_format("%s¤ÎÀ¼¤¬¤µ¤µ¤ä¤¤¤¿:",
4698 chaos_patrons[p_ptr->chaos_patron]);
4700 msg_format("The voice of %s whispers:",
4701 chaos_patrons[p_ptr->chaos_patron]);
4705 msg_print("¡Ö²æ¤¬Í¿¤¨¤·Êª¤ò¸ÌÀ¤Ë»È¤¦¤Ù¤·¡£¡×");
4707 msg_print("'Use my gift wisely.'");
4710 acquirement(py, px, 1, FALSE, FALSE);
4712 reward = "¾å¼Á¤Ê¥¢¥¤¥Æ¥à¤ò¼ê¤ËÆþ¤ì¤¿¡£";
4714 reward = "a good item";
4719 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
4720 chaos_patrons[p_ptr->chaos_patron]);
4722 msg_format("The voice of %s booms out:",
4723 chaos_patrons[p_ptr->chaos_patron]);
4727 msg_print("¡Ö²æ¤¬Í¿¤¨¤·Êª¤ò¸ÌÀ¤Ë»È¤¦¤Ù¤·¡£¡×");
4729 msg_print("'Use my gift wisely.'");
4732 acquirement(py, px, 1, TRUE, FALSE);
4734 reward = "¹âµéÉʤΥ¢¥¤¥Æ¥à¤ò¼ê¤ËÆþ¤ì¤¿¡£";
4736 reward = "an excellent item";
4741 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
4742 chaos_patrons[p_ptr->chaos_patron]);
4744 msg_format("The voice of %s booms out:",
4745 chaos_patrons[p_ptr->chaos_patron]);
4749 msg_print("¡ÖÆò¤Î¹Ô¤¤¤Ïµ®¤·õ¤ËÃͤ»¤ê¡£¡×");
4751 msg_print("'Thy deed hath earned thee a worthy blade.'");
4754 /* Get local object */
4757 switch (randint1(p_ptr->lev))
4763 dummy2 = SV_MAIN_GAUCHE;
4772 dummy2 = SV_SMALL_SWORD;
4775 dummy2 = SV_BASILLARD;
4777 case 11: case 12: case 13:
4778 dummy2 = SV_SHORT_SWORD;
4784 dummy2 = SV_CUTLASS;
4787 dummy2 = SV_WAKIZASHI;
4790 dummy2 = SV_KHOPESH;
4796 dummy2 = SV_BROAD_SWORD;
4799 dummy2 = SV_LONG_SWORD;
4802 dummy2 = SV_SCIMITAR;
4805 dummy2 = SV_NINJATO;
4811 dummy2 = SV_BASTARD_SWORD;
4814 dummy2 = SV_GREAT_SCIMITAR;
4817 dummy2 = SV_CLAYMORE;
4820 dummy2 = SV_ESPADON;
4823 dummy2 = SV_TWO_HANDED_SWORD;
4826 dummy2 = SV_FLAMBERGE;
4829 dummy2 = SV_NO_DACHI;
4832 dummy2 = SV_EXECUTIONERS_SWORD;
4835 dummy2 = SV_ZWEIHANDER;
4838 dummy2 = SV_HAYABUSA;
4841 dummy2 = SV_BLADE_OF_CHAOS;
4844 object_prep(q_ptr, lookup_kind(dummy, dummy2));
4845 q_ptr->to_h = 3 + randint1(dun_level) % 10;
4846 q_ptr->to_d = 3 + randint1(dun_level) % 10;
4847 one_resistance(q_ptr);
4848 q_ptr->name2 = EGO_CHAOTIC;
4850 /* Drop it in the dungeon */
4851 (void)drop_near(q_ptr, -1, py, px);
4853 reward = "(º®ÆÙ)¤ÎÉð´ï¤ò¼ê¤ËÆþ¤ì¤¿¡£";
4855 reward = "chaos weapon";
4860 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
4861 chaos_patrons[p_ptr->chaos_patron]);
4863 msg_format("The voice of %s booms out:",
4864 chaos_patrons[p_ptr->chaos_patron]);
4868 msg_print("¡ÖÆò¤Î¹Ô¤¤¤Ïµ®¤Ê󤤤ËÃͤ»¤ê¡£¡×");
4870 msg_print("'Thy deed hath earned thee a worthy reward.'");
4873 acquirement(py, px, randint1(2) + 1, FALSE, FALSE);
4875 reward = "¾å¼Á¤Ê¥¢¥¤¥Æ¥à¤ò¼ê¤ËÆþ¤ì¤¿¡£";
4877 reward = "good items";
4882 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
4883 chaos_patrons[p_ptr->chaos_patron]);
4885 msg_format("The voice of %s booms out:",
4886 chaos_patrons[p_ptr->chaos_patron]);
4890 msg_print("¡Ö²¼Ëͤ衢Æò¤Î¸¥¿È¤Ø¤Î²æ¤¬Àˤ·¤ß̵¤Ê󤤤ò¸«¤ë¤¬¤è¤¤¡£¡×");
4892 msg_print("'Behold, mortal, how generously I reward thy loyalty.'");
4895 acquirement(py, px, randint1(2) + 1, TRUE, FALSE);
4897 reward = "¹âµéÉʤΥ¢¥¤¥Æ¥à¤ò¼ê¤ËÆþ¤ì¤¿¡£";
4899 reward = "excellent items";
4904 msg_format("%s¤ÎÀ¼¤¬¹ì¤ÅϤä¿:",
4905 chaos_patrons[p_ptr->chaos_patron]);
4907 msg_format("The voice of %s thunders:",
4908 chaos_patrons[p_ptr->chaos_patron]);
4912 msg_print("¡Ö²¼Ëͤ衢ÆòÐþËý¤Ê¤ê¡£¡×");
4914 msg_print("'Thou art growing arrogant, mortal.'");
4917 (void)activate_ty_curse(FALSE, &count);
4919 reward = "²Ò¡¹¤·¤¤¼ö¤¤¤ò¤«¤±¤é¤ì¤¿¡£";
4926 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
4927 chaos_patrons[p_ptr->chaos_patron]);
4929 msg_format("The voice of %s booms out:",
4930 chaos_patrons[p_ptr->chaos_patron]);
4934 msg_print("¡Ö²æ¤¬²¼Ëͤ¿¤Á¤è¡¢¤«¤ÎÐþËý¤Ê¤ë¼Ô¤òÅݤ¹¤Ù¤·¡ª¡×");
4936 msg_print("'My pets, destroy the arrogant mortal!'");
4939 for (dummy = 0; dummy < randint1(5) + 1; dummy++)
4941 (void)summon_specific(0, py, px, dun_level, 0, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET));
4944 reward = "¥â¥ó¥¹¥¿¡¼¤ò¾¤´¤µ¤ì¤¿¡£";
4946 reward = "summoning hostile monsters";
4951 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
4952 chaos_patrons[p_ptr->chaos_patron]);
4954 msg_format("The voice of %s booms out:",
4955 chaos_patrons[p_ptr->chaos_patron]);
4959 msg_print("¡ÖÆò¡¢¤è¤ê¶¯¤Å¨¤òɬÍפȤ»¤ê¡ª¡×");
4961 msg_print("'Thou needst worthier opponents!'");
4964 activate_hi_summon(py, px, FALSE);
4966 reward = "¥â¥ó¥¹¥¿¡¼¤ò¾¤´¤µ¤ì¤¿¡£";
4968 reward = "summoning many hostile monsters";
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("'Death and destruction! This pleaseth me!'");
4988 reward = "¥«¥ª¥¹¤ÎÎϤ¬±²´¬¤¤¤¿¡£";
4990 reward = "calling chaos";
4995 msg_format("%s¤ÎÀ¼¤¬ÌĤê¶Á¤¤¤¿:",
4996 chaos_patrons[p_ptr->chaos_patron]);
4998 msg_format("The voice of %s rings out:",
4999 chaos_patrons[p_ptr->chaos_patron]);
5003 msg_print("¡Öα¤Þ¤ë¤Î¤À¡¢²¼Ëͤ衣;¤¬Æò¤ÎÆùÂΤòÃ䨤󡣡×");
5005 msg_print("'Stay, mortal, and let me mold thee.'");
5008 if (one_in_(3) && !(chaos_stats[p_ptr->chaos_patron] < 0))
5009 do_inc_stat(chaos_stats[p_ptr->chaos_patron]);
5011 do_inc_stat(randint0(6));
5013 reward = "ǽÎÏÃͤ¬¾å¤¬¤Ã¤¿¡£";
5015 reward = "increasing a stat";
5020 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5021 chaos_patrons[p_ptr->chaos_patron]);
5023 msg_format("The voice of %s booms out:",
5024 chaos_patrons[p_ptr->chaos_patron]);
5028 msg_print("¡Ö²¼Ëͤ衢;¤ÏÆò¤ËË°¤ß¤¿¤ê¡£¡×");
5030 msg_print("'I grow tired of thee, mortal.'");
5033 if (one_in_(3) && !(chaos_stats[p_ptr->chaos_patron] < 0))
5034 do_dec_stat(chaos_stats[p_ptr->chaos_patron]);
5036 (void)do_dec_stat(randint0(6));
5038 reward = "ǽÎÏÃͤ¬²¼¤¬¤Ã¤¿¡£";
5040 reward = "decreasing a stat";
5045 msg_format("%s¤ÎÀ¼¤¬¹ì¤ÅϤä¿:",
5046 chaos_patrons[p_ptr->chaos_patron]);
5048 msg_format("The voice of %s thunders:",
5049 chaos_patrons[p_ptr->chaos_patron]);
5053 msg_print("¡ÖÆò¡¢¸¬µõ¤¿¤ë¤³¤È¤ò³Ø¤Ö¤Ù¤·¡ª¡×");
5054 msg_print("¤¢¤Ê¤¿¤Ï°ÊÁ°¤è¤ê¼å¤¯¤Ê¤Ã¤¿¡ª");
5056 msg_print("'Thou needst a lesson in humility, mortal!'");
5057 msg_print("You feel less powerful!");
5060 for (dummy = 0; dummy < 6; dummy++)
5062 (void)dec_stat(dummy, 10 + randint1(15), TRUE);
5065 reward = "Á´Ç½ÎÏÃͤ¬²¼¤¬¤Ã¤¿¡£";
5067 reward = "decreasing all stats";
5072 msg_format("%s¤ÎÎϤ¬¿¨¤ì¤ë¤Î¤ò´¶¤¸¤¿¡£",
5074 msg_format("You feel the power of %s touch you.",
5077 chaos_patrons[p_ptr->chaos_patron]);
5080 reward = "½ý¤¬ÊѲ½¤·¤¿¡£";
5082 reward = "polymorphing wounds";
5087 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5088 chaos_patrons[p_ptr->chaos_patron]);
5090 msg_format("The voice of %s booms out:",
5091 chaos_patrons[p_ptr->chaos_patron]);
5095 msg_print("¡Ö²æ¤¬¤µ¤µ¤ä¤«¤Ê¤ë»òʪ¤ò¼õ¤±¤È¤ë¤¬¤è¤¤¡ª¡×");
5097 msg_print("'Receive this modest gift from me!'");
5100 for (dummy = 0; dummy < 6; dummy++)
5102 (void)do_inc_stat(dummy);
5105 reward = "Á´Ç½ÎÏÃͤ¬¾å¤¬¤Ã¤¿¡£";
5107 reward = "increasing all stats";
5112 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5113 chaos_patrons[p_ptr->chaos_patron]);
5115 msg_format("The voice of %s booms out:",
5116 chaos_patrons[p_ptr->chaos_patron]);
5120 msg_print("¡Ö¶ì¤·¤à¤¬¤è¤¤¡¢ÌµÇ½¤Ê¶ò¤«¼Ô¤è¡ª¡×");
5122 msg_print("'Suffer, pathetic fool!'");
5125 fire_ball(GF_DISINTEGRATE, 0, p_ptr->lev * 4, 4);
5126 take_hit(DAMAGE_NOESCAPE, p_ptr->lev * 4, wrath_reason, -1);
5128 reward = "ʬ²ò¤Îµå¤¬È¯À¸¤·¤¿¡£";
5130 reward = "generating disintegration ball";
5135 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5136 chaos_patrons[p_ptr->chaos_patron]);
5138 msg_format("The voice of %s booms out:",
5139 chaos_patrons[p_ptr->chaos_patron]);
5143 msg_print("¡Öᴤ뤬¤è¤¤¡¢²æ¤¬²¼Ëͤ衪¡×");
5145 msg_print("'Rise, my servant!'");
5149 (void)set_poisoned(0);
5151 (void)set_confused(0);
5156 for (dummy = 0; dummy < 6; dummy++)
5158 (void)do_res_stat(dummy);
5161 reward = "ÂÎÎϤ¬²óÉü¤·¤¿¡£";
5167 if (!buki_motteruka(INVEN_RARM) && !buki_motteruka(INVEN_LARM)) break;
5169 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5170 chaos_patrons[p_ptr->chaos_patron]);
5172 msg_format("The voice of %s booms out:",
5173 chaos_patrons[p_ptr->chaos_patron]);
5177 msg_print("¡ÖÆò¡¢Éð´ï¤ËÍê¤ë¤³¤È¤Ê¤«¤ì¡£¡×");
5179 msg_print("'Thou reliest too much on thy weapon.'");
5183 if (buki_motteruka(INVEN_LARM))
5186 if (buki_motteruka(INVEN_RARM) && one_in_(2)) dummy = INVEN_RARM;
5188 object_desc(o_name, &inventory[dummy], OD_NAME_ONLY);
5189 (void)curse_weapon(FALSE, dummy);
5191 reward = format("%s¤¬Ç˲õ¤µ¤ì¤¿¡£", o_name);
5193 reward = format("destroying %s", o_name);
5197 if (!inventory[INVEN_BODY].k_idx) break;
5199 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5200 chaos_patrons[p_ptr->chaos_patron]);
5202 msg_format("The voice of %s booms out:",
5203 chaos_patrons[p_ptr->chaos_patron]);
5207 msg_print("¡ÖÆò¡¢Ëɶñ¤ËÍê¤ë¤³¤È¤Ê¤«¤ì¡£¡×");
5209 msg_print("'Thou reliest too much on thine equipment.'");
5212 object_desc(o_name, &inventory[INVEN_BODY], OD_NAME_ONLY);
5213 (void)curse_armor();
5215 reward = format("%s¤¬Ç˲õ¤µ¤ì¤¿¡£", o_name);
5217 reward = format("destroying %s", o_name);
5222 msg_format("%s¤ÎÀ¼¤¬¤µ¤µ¤ä¤¤¤¿:",
5223 chaos_patrons[p_ptr->chaos_patron]);
5225 msg_format("The voice of %s whispers:",
5226 chaos_patrons[p_ptr->chaos_patron]);
5230 msg_print("¡Ö²æ¤òÅܤꤷ¤á¤¿ºá¤ò½þ¤¦¤Ù¤·¡£¡×");
5232 msg_print("'Now thou shalt pay for annoying me.'");
5235 switch (randint1(4))
5238 (void)activate_ty_curse(FALSE, &count);
5240 reward = "²Ò¡¹¤·¤¤¼ö¤¤¤ò¤«¤±¤é¤ì¤¿¡£";
5246 activate_hi_summon(py, px, FALSE);
5248 reward = "¥â¥ó¥¹¥¿¡¼¤ò¾¤´¤µ¤ì¤¿¡£";
5250 reward = "summoning hostile monsters";
5256 if (!buki_motteruka(INVEN_RARM) && !buki_motteruka(INVEN_LARM)) break;
5258 if (buki_motteruka(INVEN_LARM))
5261 if (buki_motteruka(INVEN_RARM) && one_in_(2)) dummy = INVEN_RARM;
5263 object_desc(o_name, &inventory[dummy], OD_NAME_ONLY);
5264 (void)curse_weapon(FALSE, dummy);
5266 reward = format("%s¤¬Ç˲õ¤µ¤ì¤¿¡£", o_name);
5268 reward = format("destroying %s", o_name);
5273 if (!inventory[INVEN_BODY].k_idx) break;
5274 object_desc(o_name, &inventory[INVEN_BODY], OD_NAME_ONLY);
5275 (void)curse_armor();
5277 reward = format("%s¤¬Ç˲õ¤µ¤ì¤¿¡£", o_name);
5279 reward = format("destroying %s", o_name);
5284 for (dummy = 0; dummy < 6; dummy++)
5286 (void)dec_stat(dummy, 10 + randint1(15), TRUE);
5289 reward = "Á´Ç½ÎÏÃͤ¬²¼¤¬¤Ã¤¿¡£";
5291 reward = "decreasing all stats";
5298 msg_format("%s¤ÎÀ¼¤¬¹ì¤ÅϤä¿:",
5300 msg_format("The voice of %s thunders:",
5303 chaos_patrons[p_ptr->chaos_patron]);
5305 msg_print("¡Ö»à¤Ì¤¬¤è¤¤¡¢²¼Ëͤ衪¡×");
5307 msg_print("'Die, mortal!'");
5310 take_hit(DAMAGE_LOSELIFE, p_ptr->lev * 4, wrath_reason, -1);
5311 for (dummy = 0; dummy < 6; dummy++)
5313 (void)dec_stat(dummy, 10 + randint1(15), FALSE);
5315 activate_hi_summon(py, px, FALSE);
5316 (void)activate_ty_curse(FALSE, &count);
5321 if (buki_motteruka(INVEN_RARM))
5324 if (buki_motteruka(INVEN_LARM) && one_in_(2)) dummy = INVEN_LARM;
5326 else if (buki_motteruka(INVEN_LARM)) dummy = INVEN_LARM;
5328 if (dummy) (void)curse_weapon(FALSE, dummy);
5330 if (one_in_(2)) (void)curse_armor();
5334 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5335 chaos_patrons[p_ptr->chaos_patron]);
5337 msg_format("The voice of %s booms out:",
5338 chaos_patrons[p_ptr->chaos_patron]);
5342 msg_print("¡Ö»à¤ÈÇ˲õ¤³¤½²æ¤¬´î¤Ó¤Ê¤ê¡ª¡×");
5344 msg_print("'Death and destruction! This pleaseth me!'");
5347 (void)destroy_area(py, px, 25, FALSE);
5349 reward = "¥À¥ó¥¸¥ç¥ó¤¬*Ç˲õ*¤µ¤ì¤¿¡£";
5351 reward = "*destruct*ing dungeon";
5356 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5357 chaos_patrons[p_ptr->chaos_patron]);
5359 msg_format("The voice of %s booms out:",
5360 chaos_patrons[p_ptr->chaos_patron]);
5364 msg_print("¡Ö²æ¡¢Æò¤ÎŨ¤òËõ»¦¤»¤ó¡ª¡×");
5366 msg_print("'Let me relieve thee of thine oppressors!'");
5369 (void)symbol_genocide(0, FALSE);
5371 reward = "¥â¥ó¥¹¥¿¡¼¤¬Ëõ»¦¤µ¤ì¤¿¡£";
5373 reward = "genociding monsters";
5378 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5379 chaos_patrons[p_ptr->chaos_patron]);
5381 msg_format("The voice of %s booms out:",
5382 chaos_patrons[p_ptr->chaos_patron]);
5386 msg_print("¡Ö²æ¡¢Æò¤ÎŨ¤òËõ»¦¤»¤ó¡ª¡×");
5388 msg_print("'Let me relieve thee of thine oppressors!'");
5391 (void)mass_genocide(0, FALSE);
5393 reward = "¥â¥ó¥¹¥¿¡¼¤¬Ëõ»¦¤µ¤ì¤¿¡£";
5395 reward = "genociding nearby monsters";
5400 msg_format("%s¤ÎÎϤ¬Å¨¤ò¹¶·â¤¹¤ë¤Î¤ò´¶¤¸¤¿¡ª",
5401 chaos_patrons[p_ptr->chaos_patron]);
5403 msg_format("You can feel the power of %s assault your enemies!",
5404 chaos_patrons[p_ptr->chaos_patron]);
5407 (void)dispel_monsters(p_ptr->lev * 4);
5411 msg_format("%s¤Ï¤¢¤Ê¤¿¤ò̵»ë¤·¤¿¡£",
5412 chaos_patrons[p_ptr->chaos_patron]);
5414 msg_format("%s ignores you.",
5415 chaos_patrons[p_ptr->chaos_patron]);
5421 msg_format("%s¤ÏË«Èþ¤È¤·¤Æ°Ëâ¤Î»È¤¤¤ò¤è¤³¤·¤¿¡ª",chaos_patrons[p_ptr->chaos_patron]);
5423 msg_format("%s rewards you with a demonic servant!",chaos_patrons[p_ptr->chaos_patron]);
5426 if (!summon_specific(-1, py, px, dun_level, SUMMON_DEMON, PM_FORCE_PET))
5428 msg_print("²¿¤â¸½¤ì¤Ê¤«¤Ã¤¿...");
5430 msg_print("Nobody ever turns up...");
5434 reward = "°Ë⤬¥Ú¥Ã¥È¤Ë¤Ê¤Ã¤¿¡£";
5436 reward = "a demonic servant";
5442 msg_format("%s¤ÏË«Èþ¤È¤·¤Æ»È¤¤¤ò¤è¤³¤·¤¿¡ª",chaos_patrons[p_ptr->chaos_patron]);
5444 msg_format("%s rewards you with a servant!",chaos_patrons[p_ptr->chaos_patron]);
5447 if (!summon_specific(-1, py, px, dun_level, 0, PM_FORCE_PET))
5449 msg_print("²¿¤â¸½¤ì¤Ê¤«¤Ã¤¿...");
5451 msg_print("Nobody ever turns up...");
5455 reward = "¥â¥ó¥¹¥¿¡¼¤¬¥Ú¥Ã¥È¤Ë¤Ê¤Ã¤¿¡£";
5457 reward = "a servant";
5463 msg_format("%s¤ÏË«Èþ¤È¤·¤Æ¥¢¥ó¥Ç¥Ã¥É¤Î»È¤¤¤ò¤è¤³¤·¤¿¡£",chaos_patrons[p_ptr->chaos_patron]);
5465 msg_format("%s rewards you with an undead servant!",chaos_patrons[p_ptr->chaos_patron]);
5468 if (!summon_specific(-1, py, px, dun_level, SUMMON_UNDEAD, PM_FORCE_PET))
5470 msg_print("²¿¤â¸½¤ì¤Ê¤«¤Ã¤¿...");
5472 msg_print("Nobody ever turns up...");
5476 reward = "¥¢¥ó¥Ç¥Ã¥É¤¬¥Ú¥Ã¥È¤Ë¤Ê¤Ã¤¿¡£";
5478 reward = "an undead servant";
5484 msg_format("%s¤ÎÀ¼¤¬¤É¤â¤Ã¤¿:",
5486 msg_format("The voice of %s stammers:",
5489 chaos_patrons[p_ptr->chaos_patron]);
5491 msg_format("¡Ö¤¢¡¼¡¢¤¢¡¼¡¢Åú¤¨¤Ï %d/%d¡£¼ÁÌä¤Ï²¿¡©¡×", type, effect);
5493 msg_format("'Uh... uh... the answer's %d/%d, what's the question?'", type, effect);
5501 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, format("¥Ñ¥È¥í¥ó¤ÎÊó½·¤Ç%s", reward));
5503 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, format("The patron rewards you with %s.", reward));
5510 * old -- from PsiAngband.
5512 bool tgt_pt(int *x_ptr, int *y_ptr)
5516 bool success = FALSE;
5521 get_screen_size(&wid, &hgt);
5527 msg_print("¾ì½ê¤òÁª¤ó¤Ç¥¹¥Ú¡¼¥¹¥¡¼¤ò²¡¤·¤Æ²¼¤µ¤¤¡£");
5529 msg_print("Select a point and press space.");
5531 msg_flag = FALSE; /* prevents "-more-" message. */
5533 while ((ch != ESCAPE) && !success)
5535 bool move_fast = FALSE;
5537 move_cursor_relative(y, x);
5549 if (player_bold(y, x)) ch = 0;
5552 else success = TRUE;
5556 /* Look up the direction */
5557 d = get_keymap_dir(ch);
5559 /* XTRA HACK MOVEFAST */
5560 if (isupper(ch)) move_fast = TRUE;
5562 /* Handle "direction" */
5568 /* XTRA HACK MOVEFAST */
5571 int mag = MIN(wid / 2, hgt / 2);
5581 /* Do not move horizontally if unnecessary */
5582 if (((x < panel_col_min + wid / 2) && (dx > 0)) ||
5583 ((x > panel_col_min + wid / 2) && (dx < 0)))
5588 /* Do not move vertically if unnecessary */
5589 if (((y < panel_row_min + hgt / 2) && (dy > 0)) ||
5590 ((y > panel_row_min + hgt / 2) && (dy < 0)))
5595 /* Apply the motion */
5596 if ((y >= panel_row_min + hgt) || (y < panel_row_min) ||
5597 (x >= panel_col_min + wid) || (x < panel_col_min))
5599 /* if (change_panel(dy, dx)) target_set_prepare(mode); */
5600 change_panel(dy, dx);
5603 /* Slide into legality */
5604 if (x >= cur_wid-1) x = cur_wid - 2;
5605 else if (x <= 0) x = 1;
5607 /* Slide into legality */
5608 if (y >= cur_hgt-1) y = cur_hgt- 2;
5609 else if (y <= 0) y = 1;
5616 /* Clear the top line */
5619 /* Recenter the map around the player */
5623 p_ptr->update |= (PU_MONSTERS);
5626 p_ptr->redraw |= (PR_MAP);
5629 p_ptr->window |= (PW_OVERHEAD);
5640 bool get_hack_dir(int *dp)
5650 /* Global direction */
5653 /* (No auto-targeting) */
5655 /* Ask until satisfied */
5658 /* Choose a prompt */
5662 p = "Êý¸þ ('*'¤Ç¥¿¡¼¥²¥Ã¥ÈÁªÂò, ESC¤ÇÃæÃÇ)? ";
5664 p = "Direction ('*' to choose a target, Escape to cancel)? ";
5671 p = "Êý¸þ ('5'¤Ç¥¿¡¼¥²¥Ã¥È¤Ø, '*'¤Ç¥¿¡¼¥²¥Ã¥ÈºÆÁªÂò, ESC¤ÇÃæÃÇ)? ";
5673 p = "Direction ('5' for target, '*' to re-target, Escape to cancel)? ";
5678 /* Get a command (or Cancel) */
5679 if (!get_com(p, &command, TRUE)) break;
5683 if (command == '\r') command = 't';
5686 /* Convert various keys to "standard" keys */
5689 /* Use current target */
5700 /* Set new target */
5705 if (target_set(TARGET_KILL)) dir = 5;
5711 /* Look up the direction */
5712 dir = get_keymap_dir(command);
5718 /* Verify requested targets */
5719 if ((dir == 5) && !target_okay()) dir = 0;
5726 if (!dir) return (FALSE);
5728 /* Save the direction */
5731 /* Check for confusion */
5732 if (p_ptr->confused)
5735 /* Random direction */
5736 dir = ddd[randint0(8)];
5739 /* Notice confusion */
5740 if (command_dir != dir)
5744 msg_print("¤¢¤Ê¤¿¤Ïº®Í𤷤Ƥ¤¤ë¡£");
5746 msg_print("You are confused.");
5751 /* Save direction */
5754 /* A "valid" direction was entered */
5760 * ¥¨¥Í¥ë¥®¡¼¤ÎÁý²ÃÎÌ10d5¤ò®¤¯·×»»¤¹¤ë¤¿¤á¤Î´Ø¿ô
5763 #define Go_no_JuuJou 5*5*5*5*5*5*5*5*5*5
5765 s16b gain_energy(void)
5768 s32b energy_result = 10;
5771 tmp = randint0(Go_no_JuuJou);
5773 for (i = 0; i < 9; i ++){
5774 energy_result += tmp % 5;
5778 return (s16b)(energy_result + tmp);
5785 s16b bow_energy(int sval)
5789 /* Analyze the launcher */
5792 /* Sling and ammo */
5799 /* Short Bow and Arrow */
5806 /* Long Bow and Arrow */
5813 /* Bow of irresponsiblity and Arrow */
5820 /* Light Crossbow and Bolt */
5827 /* Heavy Crossbow and Bolt */
5842 int bow_tmul(int sval)
5846 /* Analyze the launcher */
5849 /* Sling and ammo */
5856 /* Short Bow and Arrow */
5863 /* Long Bow and Arrow */
5870 /* Bow of irresponsiblity and Arrow */
5877 /* Light Crossbow and Bolt */
5884 /* Heavy Crossbow and Bolt */
5896 * Return alignment title
5898 cptr your_alignment(void)
5901 if (p_ptr->align > 150) return "ÂçÁ±";
5902 else if (p_ptr->align > 50) return "ÃæÁ±";
5903 else if (p_ptr->align > 10) return "¾®Á±";
5904 else if (p_ptr->align > -11) return "ÃæΩ";
5905 else if (p_ptr->align > -51) return "¾®°";
5906 else if (p_ptr->align > -151) return "Ãæ°";
5909 if (p_ptr->align > 150) return "Lawful";
5910 else if (p_ptr->align > 50) return "Good";
5911 else if (p_ptr->align > 10) return "Neutral Good";
5912 else if (p_ptr->align > -11) return "Neutral";
5913 else if (p_ptr->align > -51) return "Neutral Evil";
5914 else if (p_ptr->align > -151) return "Evil";
5915 else return "Chaotic";
5921 * Return proficiency level of weapons and misc. skills (except riding)
5923 int weapon_exp_level(int weapon_exp)
5925 if (weapon_exp < WEAPON_EXP_BEGINNER) return EXP_LEVEL_UNSKILLED;
5926 else if (weapon_exp < WEAPON_EXP_SKILLED) return EXP_LEVEL_BEGINNER;
5927 else if (weapon_exp < WEAPON_EXP_EXPERT) return EXP_LEVEL_SKILLED;
5928 else if (weapon_exp < WEAPON_EXP_MASTER) return EXP_LEVEL_EXPERT;
5929 else return EXP_LEVEL_MASTER;
5934 * Return proficiency level of riding
5936 int riding_exp_level(int riding_exp)
5938 if (riding_exp < RIDING_EXP_BEGINNER) return EXP_LEVEL_UNSKILLED;
5939 else if (riding_exp < RIDING_EXP_SKILLED) return EXP_LEVEL_BEGINNER;
5940 else if (riding_exp < RIDING_EXP_EXPERT) return EXP_LEVEL_SKILLED;
5941 else if (riding_exp < RIDING_EXP_MASTER) return EXP_LEVEL_EXPERT;
5942 else return EXP_LEVEL_MASTER;
5947 * Return proficiency level of spells
5949 int spell_exp_level(int spell_exp)
5951 if (spell_exp < SPELL_EXP_BEGINNER) return EXP_LEVEL_UNSKILLED;
5952 else if (spell_exp < SPELL_EXP_SKILLED) return EXP_LEVEL_BEGINNER;
5953 else if (spell_exp < SPELL_EXP_EXPERT) return EXP_LEVEL_SKILLED;
5954 else if (spell_exp < SPELL_EXP_MASTER) return EXP_LEVEL_EXPERT;
5955 else return EXP_LEVEL_MASTER;