4 * Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke
6 * This software may be copied and distributed for educational, research,
7 * and not for profit purposes provided that this copyright and statement
8 * are included in all such copies. Other copyrights may also apply.
11 /* Purpose: effects of various "objects" */
15 #define REWARD_CHANCE 10
19 * Advance experience levels and print experience
21 void check_experience(void)
23 bool level_reward = FALSE;
24 bool level_mutation = FALSE;
25 bool level_inc_stat = FALSE;
26 bool android = (p_ptr->prace == RACE_ANDROID ? TRUE : FALSE);
29 /* Hack -- lower limit */
30 if (p_ptr->exp < 0) p_ptr->exp = 0;
31 if (p_ptr->max_exp < 0) p_ptr->max_exp = 0;
32 if (p_ptr->max_max_exp < 0) p_ptr->max_max_exp = 0;
34 /* Hack -- upper limit */
35 if (p_ptr->exp > PY_MAX_EXP) p_ptr->exp = PY_MAX_EXP;
36 if (p_ptr->max_exp > PY_MAX_EXP) p_ptr->max_exp = PY_MAX_EXP;
37 if (p_ptr->max_max_exp > PY_MAX_EXP) p_ptr->max_max_exp = PY_MAX_EXP;
39 /* Hack -- maintain "max" experience */
40 if (p_ptr->exp > p_ptr->max_exp) p_ptr->max_exp = p_ptr->exp;
42 /* Hack -- maintain "max max" experience */
43 if (p_ptr->max_exp > p_ptr->max_max_exp) p_ptr->max_max_exp = p_ptr->max_exp;
45 /* Redraw experience */
46 p_ptr->redraw |= (PR_EXP);
52 /* Lose levels while possible */
53 while ((p_ptr->lev > 1) &&
54 (p_ptr->exp < ((android ? player_exp_a : player_exp)[p_ptr->lev - 2] * p_ptr->expfact / 100L)))
59 /* Update some stuff */
60 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
62 /* Redraw some stuff */
63 p_ptr->redraw |= (PR_LEV | PR_TITLE);
66 p_ptr->window |= (PW_PLAYER);
73 /* Gain levels while possible */
74 while ((p_ptr->lev < PY_MAX_LEVEL) &&
75 (p_ptr->exp >= ((android ? player_exp_a : player_exp)[p_ptr->lev-1] * p_ptr->expfact / 100L)))
80 /* Save the highest level */
81 if (p_ptr->lev > p_ptr->max_plv)
83 p_ptr->max_plv = p_ptr->lev;
85 if ((p_ptr->pclass == CLASS_CHAOS_WARRIOR) ||
86 (p_ptr->muta2 & MUT2_CHAOS_GIFT))
90 if (p_ptr->prace == RACE_BEASTMAN)
92 if (one_in_(5)) level_mutation = TRUE;
94 level_inc_stat = TRUE;
96 do_cmd_write_nikki(NIKKI_LEVELUP, p_ptr->lev, NULL);
104 msg_format("¥ì¥Ù¥ë %d ¤Ë¤è¤¦¤³¤½¡£", p_ptr->lev);
106 msg_format("Welcome to level %d.", p_ptr->lev);
110 /* Update some stuff */
111 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
113 /* Redraw some stuff */
114 p_ptr->redraw |= (PR_LEV | PR_TITLE | 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);
228 * Hack -- Return the "automatic coin type" of a monster race
229 * Used to allocate proper treasure when "Creeping coins" die
231 * XXX XXX XXX Note the use of actual "monster names"
233 static int get_coin_type(int r_idx)
235 /* Analyze monsters */
238 case MON_COPPER_COINS: return 2;
239 case MON_SILVER_COINS: return 5;
240 case MON_GOLD_COINS: return 10;
241 case MON_MITHRIL_COINS:
242 case MON_MITHRIL_GOLEM: return 16;
243 case MON_ADAMANT_COINS: return 17;
252 * Hack -- determine if a template is Cloak
254 static bool kind_is_cloak(int k_idx)
256 object_kind *k_ptr = &k_info[k_idx];
258 /* Analyze the item type */
259 if (k_ptr->tval == TV_CLOAK)
264 /* Assume not good */
270 * Hack -- determine if a template is Polearm
272 static bool kind_is_polearm(int k_idx)
274 object_kind *k_ptr = &k_info[k_idx];
276 /* Analyze the item type */
277 if (k_ptr->tval == TV_POLEARM)
282 /* Assume not good */
288 * Hack -- determine if a template is Sword
290 static bool kind_is_sword(int k_idx)
292 object_kind *k_ptr = &k_info[k_idx];
294 /* Analyze the item type */
295 if ((k_ptr->tval == TV_SWORD) && (k_ptr->sval > 2))
300 /* Assume not good */
306 * Hack -- determine if a template is Book
308 static bool kind_is_book(int k_idx)
310 object_kind *k_ptr = &k_info[k_idx];
312 /* Analyze the item type */
313 if ((k_ptr->tval >= TV_LIFE_BOOK) && (k_ptr->tval <= TV_CRUSADE_BOOK))
318 /* Assume not good */
324 * Hack -- determine if a template is Good book
326 static bool kind_is_good_book(int k_idx)
328 object_kind *k_ptr = &k_info[k_idx];
330 /* Analyze the item type */
331 if ((k_ptr->tval >= TV_LIFE_BOOK) && (k_ptr->tval <= TV_CRUSADE_BOOK) && (k_ptr->tval != TV_ARCANE_BOOK) && (k_ptr->sval > 1))
336 /* Assume not good */
342 * Hack -- determine if a template is Armor
344 static bool kind_is_armor(int k_idx)
346 object_kind *k_ptr = &k_info[k_idx];
348 /* Analyze the item type */
349 if (k_ptr->tval == TV_HARD_ARMOR)
354 /* Assume not good */
360 * Hack -- determine if a template is hafted weapon
362 static bool kind_is_hafted(int k_idx)
364 object_kind *k_ptr = &k_info[k_idx];
366 /* Analyze the item type */
367 if (k_ptr->tval == TV_HAFTED)
372 /* Assume not good */
378 * Check for "Quest" completion when a quest monster is killed or charmed.
380 void check_quest_completion(monster_type *m_ptr)
382 int i, j, y, x, ny, nx, i2, j2;
386 bool create_stairs = FALSE;
392 /* Get the location */
397 quest_num = p_ptr->inside_quest;
399 /* Search for an active quest on this dungeon level */
402 for (i = max_quests - 1; i > 0; i--)
404 /* Quest is not active */
405 if (quest[i].status != QUEST_STATUS_TAKEN)
408 /* Quest is not a dungeon quest */
409 if (quest[i].flags & QUEST_FLAG_PRESET)
412 /* Quest is not on this level */
413 if ((quest[i].level != dun_level) &&
414 (quest[i].type != QUEST_TYPE_KILL_ANY_LEVEL))
417 /* Not a "kill monster" quest */
418 if ((quest[i].type == QUEST_TYPE_FIND_ARTIFACT) ||
419 (quest[i].type == QUEST_TYPE_FIND_EXIT))
422 /* Interesting quest */
423 if ((quest[i].type == QUEST_TYPE_KILL_NUMBER) ||
424 (quest[i].type == QUEST_TYPE_KILL_ALL))
427 /* Interesting quest */
428 if (((quest[i].type == QUEST_TYPE_KILL_LEVEL) ||
429 (quest[i].type == QUEST_TYPE_KILL_ANY_LEVEL) ||
430 (quest[i].type == QUEST_TYPE_RANDOM)) &&
431 (quest[i].r_idx == m_ptr->r_idx))
438 /* Handle the current quest */
439 if (quest_num && (quest[quest_num].status == QUEST_STATUS_TAKEN))
444 switch (quest[i].type)
446 case QUEST_TYPE_KILL_NUMBER:
450 if (quest[i].cur_num >= quest[i].num_mon)
452 if (record_fix_quest) do_cmd_write_nikki(NIKKI_FIX_QUEST_C, i, NULL);
453 /* completed quest */
454 quest[i].status = QUEST_STATUS_COMPLETED;
455 quest[i].complev = (byte)p_ptr->lev;
457 if (!(quest[i].flags & QUEST_FLAG_SILENT))
460 msg_print("¥¯¥¨¥¹¥È¤òãÀ®¤·¤¿¡ª");
462 msg_print("You just completed your quest!");
468 quest[i].cur_num = 0;
472 case QUEST_TYPE_KILL_ALL:
476 if (!is_hostile(m_ptr)) break;
478 /* Count all hostile monsters */
479 for (i2 = 0; i2 < cur_wid; ++i2)
480 for (j2 = 0; j2 < cur_hgt; j2++)
481 if (cave[j2][i2].m_idx > 0)
482 if (is_hostile(&m_list[cave[j2][i2].m_idx]))
485 if ((number_mon - 1) == 0)
487 if (record_fix_quest) do_cmd_write_nikki(NIKKI_FIX_QUEST_C, i, NULL);
489 if (quest[i].flags & QUEST_FLAG_SILENT)
491 quest[i].status = QUEST_STATUS_FINISHED;
495 quest[i].status = QUEST_STATUS_COMPLETED;
496 quest[i].complev = (byte)p_ptr->lev;
498 msg_print("¥¯¥¨¥¹¥È¤òãÀ®¤·¤¿¡ª");
500 msg_print("You just completed your quest!");
508 case QUEST_TYPE_KILL_LEVEL:
509 case QUEST_TYPE_RANDOM:
511 /* Only count valid monsters */
512 if (quest[i].r_idx != m_ptr->r_idx)
517 if (quest[i].cur_num >= quest[i].max_num)
519 if (record_fix_quest && (quest[i].type == QUEST_TYPE_KILL_LEVEL)) do_cmd_write_nikki(NIKKI_FIX_QUEST_C, i, NULL);
520 if (record_rand_quest && (quest[i].type == QUEST_TYPE_RANDOM)) do_cmd_write_nikki(NIKKI_RAND_QUEST_C, i, NULL);
521 /* completed quest */
522 quest[i].status = QUEST_STATUS_COMPLETED;
523 quest[i].complev = (byte)p_ptr->lev;
524 if (!(quest[i].flags & QUEST_FLAG_PRESET))
526 create_stairs = TRUE;
527 p_ptr->inside_quest = 0;
530 if (!(quest[i].flags & QUEST_FLAG_SILENT))
533 msg_print("¥¯¥¨¥¹¥È¤òãÀ®¤·¤¿¡ª");
535 msg_print("You just completed your quest!");
541 /* Finish the two main quests without rewarding */
542 if ((i == QUEST_OBERON) || (i == QUEST_SERPENT))
544 quest[i].status = QUEST_STATUS_FINISHED;
547 if (quest[i].type == QUEST_TYPE_RANDOM)
550 quest[i].status = QUEST_STATUS_FINISHED;
555 case QUEST_TYPE_KILL_ANY_LEVEL:
558 if (quest[i].cur_num >= quest[i].max_num)
560 if (record_fix_quest) do_cmd_write_nikki(NIKKI_FIX_QUEST_C, i, NULL);
561 /* completed quest */
562 quest[i].status = QUEST_STATUS_COMPLETED;
563 quest[i].complev = (byte)p_ptr->lev;
565 if (!(quest[i].flags & QUEST_FLAG_SILENT))
568 msg_print("¥¯¥¨¥¹¥È¤òãÀ®¤·¤¿¡ª");
570 msg_print("You just completed your quest!");
575 quest[i].cur_num = 0;
582 /* Create a magical staircase */
586 while (cave_perma_bold(y, x) || cave[y][x].o_idx || (cave[y][x].info & CAVE_OBJECT) )
588 /* Pick a location */
589 scatter(&ny, &nx, y, x, 1, 0);
595 /* Explain the staircase */
597 msg_print("ËâË¡¤Î³¬Ãʤ¬¸½¤ì¤¿...");
599 msg_print("A magical staircase appears...");
603 /* Create stairs down */
604 cave_set_feat(y, x, FEAT_MORE);
606 /* Remember to update everything */
607 p_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MONSTERS | PU_MON_LITE);
615 for (j = 0; j < (dun_level / 15)+1; j++)
617 /* Get local object */
620 /* Wipe the object */
623 /* Make a great object */
624 make_object(q_ptr, AM_GOOD | AM_GREAT);
626 /* Drop it in the dungeon */
627 (void)drop_near(q_ptr, -1, y, x);
634 * Return monster death string
636 cptr extract_note_dies(monster_race *r_ptr)
638 /* Some monsters get "destroyed" */
639 if (!monster_living(r_ptr))
643 for (i = 0; i < 4; i++)
645 if (r_ptr->blow[i].method == RBM_EXPLODE)
648 return "¤ÏÇúȯ¤·¤ÆÊ´¡¹¤Ë¤Ê¤Ã¤¿¡£";
650 return " explodes into tiny shreds.";
658 return " is destroyed.";
662 /* Assume a default death */
672 * Handle the "death" of a monster.
674 * Disperse treasures centered at the monster location based on the
675 * various flags contained in the monster flags fields.
677 * Check for "Quest" completion when a quest monster is killed.
679 * Note that only the player can induce "monster_death()" on Uniques.
680 * Thus (for now) all Quest monsters should be Uniques.
682 * Note that monsters can now carry objects, and when a monster dies,
683 * it drops all of its objects, which may disappear in crowded rooms.
685 void monster_death(int m_idx, bool drop_item)
694 monster_type *m_ptr = &m_list[m_idx];
696 monster_race *r_ptr = &r_info[m_ptr->r_idx];
698 bool visible = (m_ptr->ml || (r_ptr->flags1 & RF1_UNIQUE));
702 bool do_gold = (!(r_ptr->flags1 & RF1_ONLY_ITEM));
703 bool do_item = (!(r_ptr->flags1 & RF1_ONLY_GOLD));
704 bool cloned = (m_ptr->smart & SM_CLONED) ? TRUE : FALSE;
705 int force_coin = get_coin_type(m_ptr->r_idx);
710 bool drop_chosen_item = drop_item && !cloned && !p_ptr->inside_arena
711 && !p_ptr->inside_battle && !is_pet(m_ptr);
713 /* The caster is dead? */
714 if (world_monster && world_monster == m_idx) world_monster = 0;
716 /* Notice changes in view */
717 if (r_ptr->flags7 & (RF7_LITE_MASK | RF7_DARK_MASK))
719 /* Update some things */
720 p_ptr->update |= (PU_MON_LITE);
723 /* Get the location */
727 if (record_named_pet && is_pet(m_ptr) && m_ptr->nickname)
731 monster_desc(m_name, m_ptr, MD_INDEF_VISIBLE);
732 do_cmd_write_nikki(NIKKI_NAMED_PET, 3, m_name);
735 /* Let monsters explode! */
736 for (i = 0; i < 4; i++)
738 if (r_ptr->blow[i].method == RBM_EXPLODE)
740 int flg = PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL;
741 int typ = mbe_info[r_ptr->blow[i].effect].explode_type;
742 int d_dice = r_ptr->blow[i].d_dice;
743 int d_side = r_ptr->blow[i].d_side;
744 int damage = damroll(d_dice, d_side);
746 project(m_idx, 3, y, x, damage, typ, flg, -1);
751 if (m_ptr->mflag2 & MFLAG2_CHAMELEON)
753 choose_new_monster(m_idx, TRUE, MON_CHAMELEON);
754 r_ptr = &r_info[m_ptr->r_idx];
757 /* Check for quest completion */
758 check_quest_completion(m_ptr);
760 /* Handle the possibility of player vanquishing arena combatant -KMW- */
761 if (p_ptr->inside_arena && !is_pet(m_ptr))
763 p_ptr->exit_bldg = TRUE;
765 if (p_ptr->arena_number > MAX_ARENA_MONS)
768 msg_print("ÁÇÀ²¤é¤·¤¤¡ª·¯¤³¤½¿¿¤Î¾¡Íø¼Ô¤À¡£");
770 msg_print("You are a Genuine Champion!");
776 msg_print("¾¡Íø¡ª¥Á¥ã¥ó¥Ô¥ª¥ó¤Ø¤ÎÆ»¤ò¿Ê¤ó¤Ç¤¤¤ë¡£");
778 msg_print("Victorious! You're on your way to becoming Champion.");
782 if (arena_info[p_ptr->arena_number].tval)
784 /* Get local object */
787 /* Prepare to make a prize */
788 object_prep(q_ptr, lookup_kind(arena_info[p_ptr->arena_number].tval, arena_info[p_ptr->arena_number].sval));
790 apply_magic(q_ptr, object_level, AM_NO_FIXED_ART);
792 /* Drop it in the dungeon */
793 (void)drop_near(q_ptr, -1, y, x);
796 if (p_ptr->arena_number > MAX_ARENA_MONS) p_ptr->arena_number++;
797 p_ptr->arena_number++;
802 /* Extract monster name */
803 monster_desc(m_name, m_ptr, MD_IGNORE_HALLU | MD_ASSUME_VISIBLE | MD_INDEF_VISIBLE);
805 do_cmd_write_nikki(NIKKI_ARENA, p_ptr->arena_number, m_name);
809 if (m_idx == p_ptr->riding)
811 if (rakuba(-1, FALSE))
814 msg_print("ÃÏÌ̤ËÍî¤È¤µ¤ì¤¿¡£");
816 msg_print("You have fallen from your riding pet.");
821 /* Drop a dead corpse? */
822 if (one_in_(r_ptr->flags1 & RF1_UNIQUE ? 1 : 4) &&
823 ((r_ptr->flags9 & RF9_DROP_CORPSE) ||
824 (r_ptr->flags9 & RF9_DROP_SKELETON)) &&
825 !(p_ptr->inside_arena || p_ptr->inside_battle || cloned || ((m_ptr->r_idx == today_mon) && is_pet(m_ptr))))
827 /* Assume skeleton */
831 * We cannot drop a skeleton? Note, if we are in this check,
832 * we *know* we can drop at least a corpse or a skeleton
834 if (!(r_ptr->flags9 & RF9_DROP_SKELETON))
836 else if ((r_ptr->flags9 & RF9_DROP_CORPSE) && (r_ptr->flags1 && RF1_UNIQUE))
839 /* Else, a corpse is more likely unless we did a "lot" of damage */
840 else if (r_ptr->flags9 & RF9_DROP_CORPSE)
842 /* Lots of damage in one blow */
843 if ((0 - ((m_ptr->maxhp) / 4)) > m_ptr->hp)
845 if (one_in_(5)) corpse = TRUE;
849 if (!one_in_(5)) corpse = TRUE;
853 /* Get local object */
856 /* Prepare to make an object */
857 object_prep(q_ptr, lookup_kind(TV_CORPSE, (corpse ? SV_CORPSE : SV_SKELETON)));
859 apply_magic(q_ptr, object_level, AM_NO_FIXED_ART);
861 q_ptr->pval = m_ptr->r_idx;
863 /* Drop it in the dungeon */
864 (void)drop_near(q_ptr, -1, y, x);
867 /* Drop objects being carried */
868 monster_drop_carried_objects(m_ptr);
870 if (r_ptr->flags1 & RF1_DROP_GOOD) mo_mode |= AM_GOOD;
871 if (r_ptr->flags1 & RF1_DROP_GREAT) mo_mode |= AM_GREAT;
873 switch (m_ptr->r_idx)
875 case MON_PINK_HORROR:
876 /* Pink horrors are replaced with 2 Blue horrors */
877 if (!(p_ptr->inside_arena || p_ptr->inside_battle))
881 for (i = 0; i < 2; i++)
884 bool pet = is_pet(m_ptr);
887 if (pet) mode |= PM_FORCE_PET;
889 if (summon_specific((pet ? -1 : m_idx), wy, wx, 100, SUMMON_BLUE_HORROR, mode))
891 if (player_can_see_bold(wy, wx))
898 msg_print("¥Ô¥ó¥¯¡¦¥Û¥é¡¼¤ÏʬÎö¤·¤¿¡ª");
900 msg_print("The Pink horror divides!");
905 case MON_BLOODLETTER:
906 /* Bloodletters of Khorne may drop a blade of chaos */
907 if (drop_chosen_item && (randint1(100) < 15))
909 /* Get local object */
912 /* Prepare to make a Blade of Chaos */
913 object_prep(q_ptr, lookup_kind(TV_SWORD, SV_BLADE_OF_CHAOS));
915 apply_magic(q_ptr, object_level, AM_NO_FIXED_ART | mo_mode);
917 /* Drop it in the dungeon */
918 (void)drop_near(q_ptr, -1, y, x);
923 if (drop_chosen_item && (dun_level > 9))
925 /* Get local object */
928 /* Wipe the object */
931 /* Activate restriction */
932 if ((dun_level > 49) && one_in_(5))
933 get_obj_num_hook = kind_is_good_book;
935 get_obj_num_hook = kind_is_book;
938 make_object(q_ptr, mo_mode);
940 /* Drop it in the dungeon */
941 (void)drop_near(q_ptr, -1, y, x);
947 * Mega^3-hack: killing a 'Warrior of the Dawn' is likely to
948 * spawn another in the fallen one's place!
950 if (!p_ptr->inside_arena && !p_ptr->inside_battle)
956 bool pet = is_pet(m_ptr);
960 scatter(&wy, &wx, y, x, 20, 0);
962 while (!(in_bounds(wy, wx) && cave_empty_bold2(wy, wx)) && --attempts);
967 if (pet) mode |= PM_FORCE_PET;
969 if (summon_specific((pet ? -1 : m_idx), wy, wx, 100, SUMMON_DAWN, mode))
971 if (player_can_see_bold(wy, wx))
973 msg_print("¿·¤¿¤ÊÀï»Î¤¬¸½¤ì¤¿¡ª");
975 msg_print("A new warrior steps forth!");
985 /* One more ultra-hack: An Unmaker goes out with a big bang! */
987 int flg = PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL;
988 (void)project(m_idx, 6, y, x, 100, GF_CHAOS, flg, -1);
992 case MON_UNICORN_ORD:
995 /* Reward for "lazy" player */
996 if (p_ptr->pseikaku == SEIKAKU_NAMAKE)
1000 if (!drop_chosen_item) break;
1004 switch (randint0(3))
1007 a_idx = ART_NAMAKE_HAMMER;
1010 a_idx = ART_NAMAKE_BOW;
1013 a_idx = ART_NAMAKE_ARMOR;
1017 while (a_info[a_idx].cur_num);
1019 if (a_info[a_idx].cur_num == 0)
1021 /* Create the artifact */
1022 create_named_art(a_idx, y, x);
1023 a_info[a_idx].cur_num = 1;
1029 if (!drop_chosen_item) break;
1031 /* Get local object */
1034 /* Mega-Hack -- Prepare to make "Grond" */
1035 object_prep(q_ptr, lookup_kind(TV_HAFTED, SV_GROND));
1037 /* Mega-Hack -- Mark this item as "Grond" */
1038 q_ptr->name1 = ART_GROND;
1040 /* Mega-Hack -- Actually create "Grond" */
1041 apply_magic(q_ptr, -1, AM_GOOD | AM_GREAT);
1043 /* Drop it in the dungeon */
1044 (void)drop_near(q_ptr, -1, y, x);
1046 /* Get local object */
1049 /* Mega-Hack -- Prepare to make "Chaos" */
1050 object_prep(q_ptr, lookup_kind(TV_CROWN, SV_CHAOS));
1052 /* Mega-Hack -- Mark this item as "Chaos" */
1053 q_ptr->name1 = ART_CHAOS;
1055 /* Mega-Hack -- Actually create "Chaos" */
1056 apply_magic(q_ptr, -1, AM_GOOD | AM_GREAT);
1058 /* Drop it in the dungeon */
1059 (void)drop_near(q_ptr, -1, y, x);
1062 case MON_B_DEATH_SWORD:
1063 if (drop_chosen_item)
1065 /* Get local object */
1068 /* Prepare to make a broken sword */
1069 object_prep(q_ptr, lookup_kind(TV_SWORD, randint1(2)));
1071 /* Drop it in the dungeon */
1072 (void)drop_near(q_ptr, -1, y, x);
1078 if (drop_chosen_item && ((m_ptr->r_idx == MON_A_GOLD) ||
1079 ((m_ptr->r_idx == MON_A_SILVER) && (r_ptr->r_pkills % 5 == 0))))
1081 /* Get local object */
1084 /* Prepare to make a Can of Toys */
1085 object_prep(q_ptr, lookup_kind(TV_CHEST, SV_CHEST_KANDUME));
1087 apply_magic(q_ptr, object_level, AM_NO_FIXED_ART);
1089 /* Drop it in the dungeon */
1090 (void)drop_near(q_ptr, -1, y, x);
1096 int flg = PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL;
1097 (void)project(m_idx, 3, y, x, damroll(20, 10), GF_FIRE, flg, -1);
1102 if (!drop_chosen_item) break;
1104 switch (r_ptr->d_char)
1109 /* Get local object */
1112 /* Wipe the object */
1115 /* Activate restriction */
1116 get_obj_num_hook = kind_is_cloak;
1119 make_object(q_ptr, mo_mode);
1121 /* Drop it in the dungeon */
1122 (void)drop_near(q_ptr, -1, y, x);
1129 /* Get local object */
1132 /* Wipe the object */
1135 /* Activate restriction */
1136 get_obj_num_hook = kind_is_polearm;
1138 /* Make a poleweapon */
1139 make_object(q_ptr, mo_mode);
1141 /* Drop it in the dungeon */
1142 (void)drop_near(q_ptr, -1, y, x);
1149 /* Get local object */
1152 /* Wipe the object */
1155 /* Activate restriction */
1156 get_obj_num_hook = kind_is_armor;
1158 /* Make a hard armor */
1159 make_object(q_ptr, mo_mode);
1161 /* Drop it in the dungeon */
1162 (void)drop_near(q_ptr, -1, y, x);
1169 /* Get local object */
1172 /* Wipe the object */
1175 /* Activate restriction */
1176 get_obj_num_hook = kind_is_hafted;
1178 /* Make a poleweapon */
1179 make_object(q_ptr, mo_mode);
1181 /* Drop it in the dungeon */
1182 (void)drop_near(q_ptr, -1, y, x);
1187 if (m_ptr->r_idx != MON_STORMBRINGER)
1189 /* Get local object */
1192 /* Wipe the object */
1195 /* Activate restriction */
1196 get_obj_num_hook = kind_is_sword;
1199 make_object(q_ptr, mo_mode);
1201 /* Drop it in the dungeon */
1202 (void)drop_near(q_ptr, -1, y, x);
1209 /* Mega-Hack -- drop fixed items */
1210 if (drop_chosen_item)
1215 switch (m_ptr->r_idx)
1235 case MON_STORMBRINGER:
1236 a_idx = ART_STORMBRINGER;
1241 a_idx = ART_CRIMSON;
1251 a_idx = ART_KUSANAGI;
1281 a_idx = ART_WEREWINDLE;
1289 a_idx = ART_GRAYSWANDIR;
1300 a_idx = ART_TWILIGHT;
1305 a_idx = ART_ELENDIL;
1320 a_idx = ART_DESTINY;
1325 a_idx = ART_ZANTETSU;
1340 a_idx = ART_WINBLOWS;
1344 case MON_LUNGORTHIN:
1349 case MON_JACK_SHADOWS:
1355 a_idx = ART_STONEMASK;
1360 a_idx = ART_SOULCRUSH;
1365 a_idx = ART_EXCALIBUR_J;
1370 a_idx = ART_SHUTEN_DOJI;
1375 a_idx = ART_GOTHMOG;
1385 if ((a_idx > 0) && ((randint0(100) < chance) || p_ptr->wizard))
1387 if (a_info[a_idx].cur_num == 0)
1389 /* Create the artifact */
1390 create_named_art(a_idx, y, x);
1391 a_info[a_idx].cur_num = 1;
1395 if ((r_ptr->flags7 & RF7_GUARDIAN) && (d_info[dungeon_type].final_guardian == m_ptr->r_idx))
1397 int k_idx = d_info[dungeon_type].final_object ? d_info[dungeon_type].final_object
1398 : lookup_kind(TV_SCROLL, SV_SCROLL_ACQUIREMENT);
1400 if (d_info[dungeon_type].final_artifact)
1402 int a_idx = d_info[dungeon_type].final_artifact;
1403 if (!a_info[a_idx].cur_num)
1405 /* Create the artifact */
1406 create_named_art(a_idx, y, x);
1407 a_info[a_idx].cur_num = 1;
1409 /* Prevent rewarding both artifact and "default" object */
1410 if (!d_info[dungeon_type].final_object) k_idx = 0;
1416 /* Get local object */
1419 /* Prepare to make a reward */
1420 object_prep(q_ptr, k_idx);
1422 apply_magic(q_ptr, object_level, AM_NO_FIXED_ART | AM_GOOD);
1424 /* Drop it in the dungeon */
1425 (void)drop_near(q_ptr, -1, y, x);
1428 msg_format("¤¢¤Ê¤¿¤Ï%s¤òÀ©ÇƤ·¤¿¡ª",d_name+d_info[dungeon_type].name);
1430 msg_format("You have conquered %s!",d_name+d_info[dungeon_type].name);
1435 /* Determine how much we can drop */
1436 if ((r_ptr->flags1 & RF1_DROP_60) && (randint0(100) < 60)) number++;
1437 if ((r_ptr->flags1 & RF1_DROP_90) && (randint0(100) < 90)) number++;
1438 if (r_ptr->flags1 & RF1_DROP_1D2) number += damroll(1, 2);
1439 if (r_ptr->flags1 & RF1_DROP_2D2) number += damroll(2, 2);
1440 if (r_ptr->flags1 & RF1_DROP_3D2) number += damroll(3, 2);
1441 if (r_ptr->flags1 & RF1_DROP_4D2) number += damroll(4, 2);
1443 if (cloned && !(r_ptr->flags1 & RF1_UNIQUE))
1444 number = 0; /* Clones drop no stuff unless Cloning Pits */
1446 if (is_pet(m_ptr) || p_ptr->inside_battle || p_ptr->inside_arena)
1447 number = 0; /* Pets drop no stuff */
1448 if (!drop_item && (r_ptr->d_char != '$')) number = 0;
1450 /* Hack -- handle creeping coins */
1451 coin_type = force_coin;
1453 /* Average dungeon and monster levels */
1454 object_level = (dun_level + r_ptr->level) / 2;
1456 /* Drop some objects */
1457 for (j = 0; j < number; j++)
1459 /* Get local object */
1462 /* Wipe the object */
1466 if (do_gold && (!do_item || (randint0(100) < 50)))
1468 /* Make some gold */
1469 if (!make_gold(q_ptr)) continue;
1478 /* Make an object */
1479 if (!make_object(q_ptr, mo_mode)) continue;
1485 /* Drop it in the dungeon */
1486 (void)drop_near(q_ptr, -1, y, x);
1489 /* Reset the object level */
1490 object_level = base_level;
1492 /* Reset "coin" type */
1496 /* Take note of any dropped treasure */
1497 if (visible && (dump_item || dump_gold))
1499 /* Take notes on treasure */
1500 lore_treasure(m_idx, dump_item, dump_gold);
1503 /* Only process "Quest Monsters" */
1504 if (!(r_ptr->flags1 & RF1_QUESTOR)) return;
1505 if (p_ptr->inside_battle) return;
1508 if ((m_ptr->r_idx == MON_SERPENT) && !cloned)
1511 p_ptr->total_winner = TRUE;
1513 /* Redraw the "title" */
1514 p_ptr->redraw |= (PR_TITLE);
1517 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, "¸«»ö¤ËÊѶòÈÚÅܤξ¡Íø¼Ô¤È¤Ê¤Ã¤¿¡ª");
1519 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, "become *WINNER* of Hengband finely!");
1522 if ((p_ptr->pclass == CLASS_CHAOS_WARRIOR) || (p_ptr->muta2 & MUT2_CHAOS_GIFT))
1525 msg_format("%s¤«¤é¤ÎÀ¼¤¬¶Á¤¤¤¿¡£", chaos_patrons[p_ptr->chaos_patron]);
1526 msg_print("¡Ø¤è¤¯¤ä¤Ã¤¿¡¢ÄêÌ¿¤Î¼Ô¤è¡ª¡Ù");
1528 msg_format("The voice of %s booms out:", chaos_patrons[p_ptr->chaos_patron]);
1529 msg_print("'Thou art donst well, mortal!'");
1533 /* Congratulations */
1535 msg_print("*** ¤ª¤á¤Ç¤È¤¦ ***");
1537 msg_print("*** CONGRATULATIONS ***");
1541 msg_print("¤¢¤Ê¤¿¤Ï¥²¡¼¥à¤ò¥³¥ó¥×¥ê¡¼¥È¤·¤Þ¤·¤¿¡£");
1543 msg_print("You have won the game!");
1547 msg_print("½àÈ÷¤¬À°¤Ã¤¿¤é°úÂà(¼«»¦¥³¥Þ¥ó¥É)¤·¤Æ¤â·ë¹½¤Ç¤¹¡£");
1549 msg_print("You may retire (commit suicide) when you are ready.");
1555 * Modify the physical damage done to the monster.
1556 * (for example when it's invulnerable or shielded)
1558 * ToDo: Accept a damage-type to calculate the modified damage from
1559 * things like fire, frost, lightning, poison, ... attacks.
1561 * "type" is not yet used and should be 0.
1563 int mon_damage_mod(monster_type *m_ptr, int dam, bool is_psy_spear)
1565 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1567 if ((r_ptr->flagsr & RFR_RES_ALL) && dam > 0)
1570 if((dam == 0) && one_in_(3)) dam = 1;
1573 if (m_ptr->invulner)
1577 if(!p_ptr->blind && m_ptr->ml)
1580 msg_print("¥Ð¥ê¥¢¤òÀÚ¤êÎö¤¤¤¿¡ª");
1582 msg_print("The barrier is penetrated!");
1586 else if (!one_in_(PENETRATE_INVULNERABILITY))
1596 * Calculate experience point to be get
1598 * Even the 64 bit operation is not big enough to avoid overflaw
1599 * unless we carefully choose orders of multiplication and division.
1601 * Get the coefficient first, and multiply (potentially huge) base
1602 * experience point of a monster later.
1604 static void get_exp_from_mon(int dam, monster_type *m_ptr)
1606 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1613 if (!m_ptr->r_idx) return;
1614 if (is_pet(m_ptr) || p_ptr->inside_battle) return;
1617 * - Ratio of monster's level to player's level effects
1618 * - Varying speed effects
1619 * - Get a fraction in proportion of damage point
1621 new_exp = r_ptr->level * SPEED_TO_ENERGY(m_ptr->mspeed) * dam;
1624 div_l = (p_ptr->max_plv+2) * SPEED_TO_ENERGY(r_ptr->speed);
1626 /* Use (average maxhp * 2) as a denominator */
1627 if (!(r_ptr->flags1 & RF1_FORCE_MAXHP))
1628 s64b_mul(&div_h, &div_l, 0, r_ptr->hdice * (r_ptr->hside + 1));
1630 s64b_mul(&div_h, &div_l, 0, r_ptr->hdice * r_ptr->hside * 2);
1632 /* Special penalty in the wilderness */
1633 if (!dun_level && (!(r_ptr->flags8 & RF8_WILD_ONLY) || !(r_ptr->flags1 & RF1_UNIQUE)))
1634 s64b_mul(&div_h, &div_l, 0, 5);
1636 /* Do division first to prevent overflaw */
1637 s64b_div(&new_exp, &new_exp_frac, div_h, div_l);
1639 /* Special penalty for mutiply-monster */
1640 if ((r_ptr->flags2 & RF2_MULTIPLY) || (m_ptr->r_idx == MON_DAWN))
1642 int monnum_penarty = r_ptr->r_pkills / 400;
1643 if (monnum_penarty > 8) monnum_penarty = 8;
1645 while (monnum_penarty--)
1648 s64b_RSHIFT(new_exp, new_exp_frac, 2);
1652 /* Finally multiply base experience point of the monster */
1653 s64b_mul(&new_exp, &new_exp_frac, 0, r_ptr->mexp);
1655 /* Gain experience */
1656 gain_exp_64(new_exp, new_exp_frac);
1661 * Decreases monsters hit points, handling monster death.
1663 * We return TRUE if the monster has been killed (and deleted).
1665 * We announce monster death (using an optional "death message"
1666 * if given, and a otherwise a generic killed/destroyed message).
1668 * Only "physical attacks" can induce the "You have slain" message.
1669 * Missile and Spell attacks will induce the "dies" message, or
1670 * various "specialized" messages. Note that "You have destroyed"
1671 * and "is destroyed" are synonyms for "You have slain" and "dies".
1673 * Hack -- unseen monsters yield "You have killed it." message.
1675 * Added fear (DGK) and check whether to print fear messages -CWS
1677 * Made name, sex, and capitalization generic -BEN-
1679 * As always, the "ghost" processing is a total hack.
1681 * Hack -- we "delay" fear messages by passing around a "fear" flag.
1683 * XXX XXX XXX Consider decreasing monster experience over time, say,
1684 * by using "(m_exp * m_lev * (m_lev)) / (p_lev * (m_lev + n_killed))"
1685 * instead of simply "(m_exp * m_lev) / (p_lev)", to make the first
1686 * monster worth more than subsequent monsters. This would also need
1687 * to induce changes in the monster recall code.
1689 bool mon_take_hit(int m_idx, int dam, bool *fear, cptr note)
1691 monster_type *m_ptr = &m_list[m_idx];
1692 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1694 monster_type exp_mon;
1696 /* Innocent until proven otherwise */
1697 bool innocent = TRUE, thief = FALSE;
1701 COPY(&exp_mon, m_ptr, monster_type);
1702 if (!(r_ptr->flags7 & RF7_KILL_EXP))
1704 expdam = (m_ptr->hp > dam) ? dam : m_ptr->hp;
1705 if (r_ptr->flags6 & RF6_HEAL) expdam = (expdam+1) * 2 / 3;
1707 get_exp_from_mon(expdam, &exp_mon);
1710 /* Redraw (later) if needed */
1711 if (p_ptr->health_who == m_idx) p_ptr->redraw |= (PR_HEALTH);
1712 if (p_ptr->riding == m_idx) p_ptr->redraw |= (PR_UHEALTH);
1717 if (r_ptr->flags7 & RF7_HAS_LD_MASK) p_ptr->update |= (PU_MON_LITE);
1719 /* Hack - Cancel any special player stealth magics. -LM- */
1720 if (p_ptr->special_defense & NINJA_S_STEALTH)
1722 set_superstealth(FALSE);
1728 /* It is dead now */
1733 if (r_info[m_ptr->r_idx].flags7 & RF7_TANUKI)
1735 /* You might have unmasked Tanuki first time */
1736 r_ptr = &r_info[m_ptr->r_idx];
1737 m_ptr->ap_r_idx = m_ptr->r_idx;
1738 if (r_ptr->r_sights < MAX_SHORT) r_ptr->r_sights++;
1741 if (m_ptr->mflag2 & MFLAG2_CHAMELEON)
1743 /* You might have unmasked Chameleon first time */
1744 r_ptr = real_r_ptr(m_ptr);
1745 if (r_ptr->r_sights < MAX_SHORT) r_ptr->r_sights++;
1748 if (!(m_ptr->smart & SM_CLONED))
1750 /* When the player kills a Unique, it stays dead */
1751 if (r_ptr->flags1 & RF1_UNIQUE)
1755 /* Mega-Hack -- Banor & Lupart */
1756 if ((m_ptr->r_idx == MON_BANOR) || (m_ptr->r_idx == MON_LUPART))
1758 r_info[MON_BANORLUPART].max_num = 0;
1759 r_info[MON_BANORLUPART].r_pkills++;
1760 if (r_info[MON_BANORLUPART].r_tkills < MAX_SHORT) r_info[MON_BANORLUPART].r_tkills++;
1762 else if (m_ptr->r_idx == MON_BANORLUPART)
1764 r_info[MON_BANOR].max_num = 0;
1765 r_info[MON_BANOR].r_pkills++;
1766 if (r_info[MON_BANOR].r_tkills < MAX_SHORT) r_info[MON_BANOR].r_tkills++;
1767 r_info[MON_LUPART].max_num = 0;
1768 r_info[MON_LUPART].r_pkills++;
1769 if (r_info[MON_LUPART].r_tkills < MAX_SHORT) r_info[MON_LUPART].r_tkills++;
1773 /* When the player kills a Nazgul, it stays dead */
1774 else if (r_ptr->flags7 & RF7_NAZGUL) r_ptr->max_num--;
1777 /* Recall even invisible uniques or winners */
1778 if (m_ptr->ml || (r_ptr->flags1 & RF1_UNIQUE))
1780 /* Count kills this life */
1781 if ((m_ptr->mflag2 & MFLAG2_KAGE) && (r_info[MON_KAGE].r_pkills < MAX_SHORT)) r_info[MON_KAGE].r_pkills++;
1782 else if (r_ptr->r_pkills < MAX_SHORT) r_ptr->r_pkills++;
1784 /* Count kills in all lives */
1785 if ((m_ptr->mflag2 & MFLAG2_KAGE) && (r_info[MON_KAGE].r_tkills < MAX_SHORT)) r_info[MON_KAGE].r_tkills++;
1786 else if (r_ptr->r_tkills < MAX_SHORT) r_ptr->r_tkills++;
1788 /* Hack -- Auto-recall */
1789 monster_race_track(m_ptr->ap_r_idx);
1792 /* Extract monster name */
1793 monster_desc(m_name, m_ptr, MD_TRUE_NAME);
1795 /* Don't kill Amberites */
1796 if ((r_ptr->flags3 & RF3_AMBERITE) && one_in_(2))
1798 int curses = 1 + randint1(3);
1799 bool stop_ty = FALSE;
1803 msg_format("%^s¤Ï¶²¤í¤·¤¤·ì¤Î¼ö¤¤¤ò¤¢¤Ê¤¿¤Ë¤«¤±¤¿¡ª", m_name);
1805 msg_format("%^s puts a terrible blood curse on you!", m_name);
1808 curse_equipment(100, 50);
1812 stop_ty = activate_ty_curse(stop_ty, &count);
1817 if (r_ptr->flags2 & RF2_CAN_SPEAK)
1819 char line_got[1024];
1821 /* Dump a message */
1823 if (!get_rnd_line("mondeath_j.txt", m_ptr->r_idx, line_got))
1825 if (!get_rnd_line("mondeath.txt", m_ptr->r_idx, line_got))
1828 msg_format("%^s %s", m_name, line_got);
1831 if (m_ptr->r_idx == MON_SERPENT)
1833 /* Make screen dump */
1834 screen_dump = make_screen_dump();
1839 if (!(d_info[dungeon_type].flags1 & DF1_BEGINNER))
1841 if (!dun_level && !ambush_flag && !p_ptr->inside_arena)
1843 chg_virtue(V_VALOUR, -1);
1845 else if (r_ptr->level > dun_level)
1847 if (randint1(10) <= (r_ptr->level - dun_level))
1848 chg_virtue(V_VALOUR, 1);
1850 if (r_ptr->level > 60)
1852 chg_virtue(V_VALOUR, 1);
1854 if (r_ptr->level >= 2 * (p_ptr->lev+1))
1855 chg_virtue(V_VALOUR, 2);
1858 if (r_ptr->flags1 & RF1_UNIQUE)
1860 if (r_ptr->flags3 & (RF3_EVIL | RF3_GOOD)) chg_virtue(V_HARMONY, 2);
1862 if (r_ptr->flags3 & RF3_GOOD)
1864 chg_virtue(V_UNLIFE, 2);
1865 chg_virtue(V_VITALITY, -2);
1868 if (one_in_(3)) chg_virtue(V_INDIVIDUALISM, -1);
1871 if (m_ptr->r_idx == MON_BEGGAR || m_ptr->r_idx == MON_LEPER)
1873 chg_virtue(V_COMPASSION, -1);
1876 if ((r_ptr->flags3 & RF3_GOOD) &&
1877 ((r_ptr->level) / 10 + (3 * dun_level) >= randint1(100)))
1878 chg_virtue(V_UNLIFE, 1);
1880 if (r_ptr->d_char == 'A')
1882 if (r_ptr->flags1 & RF1_UNIQUE)
1883 chg_virtue(V_FAITH, -2);
1884 else if ((r_ptr->level) / 10 + (3 * dun_level) >= randint1(100))
1886 if (r_ptr->flags3 & RF3_GOOD) chg_virtue(V_FAITH, -1);
1887 else chg_virtue(V_FAITH, 1);
1890 else if (r_ptr->flags3 & RF3_DEMON)
1892 if (r_ptr->flags1 & RF1_UNIQUE)
1893 chg_virtue(V_FAITH, 2);
1894 else if ((r_ptr->level) / 10 + (3 * dun_level) >= randint1(100))
1895 chg_virtue(V_FAITH, 1);
1898 if ((r_ptr->flags3 & RF3_UNDEAD) && (r_ptr->flags1 & RF1_UNIQUE))
1899 chg_virtue(V_VITALITY, 2);
1901 if (r_ptr->r_deaths)
1903 if (r_ptr->flags1 & RF1_UNIQUE)
1905 chg_virtue(V_HONOUR, 10);
1907 else if ((r_ptr->level) / 10 + (2 * dun_level) >= randint1(100))
1909 chg_virtue(V_HONOUR, 1);
1912 if ((r_ptr->flags2 & RF2_MULTIPLY) && (r_ptr->r_pkills > 1000) && one_in_(10))
1914 chg_virtue(V_VALOUR, -1);
1917 for (i = 0; i < 4; i++)
1919 if (r_ptr->blow[i].d_dice != 0) innocent = FALSE; /* Murderer! */
1921 if ((r_ptr->blow[i].effect == RBE_EAT_ITEM)
1922 || (r_ptr->blow[i].effect == RBE_EAT_GOLD))
1924 thief = TRUE; /* Thief! */
1927 /* The new law says it is illegal to live in the dungeon */
1928 if (r_ptr->level != 0) innocent = FALSE;
1932 if (r_ptr->flags1 & RF1_UNIQUE)
1933 chg_virtue(V_JUSTICE, 3);
1934 else if (1+((r_ptr->level) / 10 + (2 * dun_level))
1936 chg_virtue(V_JUSTICE, 1);
1940 chg_virtue (V_JUSTICE, -1);
1943 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)))
1945 if (one_in_(4)) chg_virtue(V_NATURE, -1);
1948 if ((r_ptr->flags1 & RF1_UNIQUE) && record_destroy_uniq)
1952 sprintf(note_buf, "%s%s", r_name + r_ptr->name, (m_ptr->smart & SM_CLONED) ? "(¥¯¥í¡¼¥ó)" : "");
1954 sprintf(note_buf, "%s%s", r_name + r_ptr->name, (m_ptr->smart & SM_CLONED) ? "(Clone)" : "");
1956 do_cmd_write_nikki(NIKKI_UNIQUE, 0, note_buf);
1962 /* Death by Missile/Spell attack */
1965 msg_format("%^s%s", m_name, note);
1968 /* Death by physical attack -- invisible monster */
1969 else if (!m_ptr->ml)
1972 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
1973 msg_format("¤»¤Ã¤«¤¯¤À¤«¤é%s¤ò»¦¤·¤¿¡£", m_name);
1975 msg_format("%s¤ò»¦¤·¤¿¡£", m_name);
1977 msg_format("You have killed %s.", m_name);
1982 /* Death by Physical attack -- non-living monster */
1983 else if (!monster_living(r_ptr))
1986 bool explode = FALSE;
1988 for (i = 0; i < 4; i++)
1990 if (r_ptr->blow[i].method == RBM_EXPLODE) explode = TRUE;
1993 /* Special note at death */
1996 msg_format("%s¤ÏÇúȯ¤·¤ÆÊ´¡¹¤Ë¤Ê¤Ã¤¿¡£", m_name);
1998 msg_format("%s explodes into tiny shreds.", m_name);
2003 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
2004 msg_format("¤»¤Ã¤«¤¯¤À¤«¤é%s¤òÅݤ·¤¿¡£", m_name);
2006 msg_format("%s¤òÅݤ·¤¿¡£", m_name);
2008 msg_format("You have destroyed %s.", m_name);
2013 /* Death by Physical attack -- living monster */
2017 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
2018 msg_format("¤»¤Ã¤«¤¯¤À¤«¤é%s¤òÁò¤êµî¤Ã¤¿¡£", m_name);
2020 msg_format("%s¤òÁò¤êµî¤Ã¤¿¡£", m_name);
2022 msg_format("You have slain %s.", m_name);
2026 if ((r_ptr->flags1 & RF1_UNIQUE) && !(m_ptr->smart & SM_CLONED) && !vanilla_town)
2028 for (i = 0; i < MAX_KUBI; i++)
2030 if ((kubi_r_idx[i] == m_ptr->r_idx) && !(m_ptr->mflag2 & MFLAG2_CHAMELEON))
2033 msg_format("%s¤Î¼ó¤Ë¤Ï¾Þ¶â¤¬¤«¤«¤Ã¤Æ¤¤¤ë¡£", m_name);
2035 msg_format("There is a price on %s's head.", m_name);
2042 /* Generate treasure */
2043 monster_death(m_idx, TRUE);
2045 /* Mega hack : replace IKETA to BIKETAL */
2046 if ((m_ptr->r_idx == MON_IKETA) &&
2047 !(p_ptr->inside_arena || p_ptr->inside_battle))
2049 int dummy_y = m_ptr->fy;
2050 int dummy_x = m_ptr->fx;
2053 if (is_pet(m_ptr)) mode |= PM_FORCE_PET;
2055 /* Delete the monster */
2056 delete_monster_idx(m_idx);
2058 if (summon_named_creature(0, dummy_y, dummy_x, MON_BIKETAL, mode))
2061 msg_print("¡Ö¥Ï¥¡¥Ã¥Ï¥Ã¥Ï¥Ã¥Ï¡ª¡ª»ä¤¬¥Ð¥¤¥±¥¿¥ë¤À¡ª¡ª¡×");
2063 msg_print("Uwa-hahaha! *I* am Biketal!");
2069 /* Delete the monster */
2070 delete_monster_idx(m_idx);
2073 /* Prevent bug of chaos patron's reward */
2074 if (r_ptr->flags7 & RF7_KILL_EXP)
2075 get_exp_from_mon((long)exp_mon.max_maxhp*2, &exp_mon);
2077 get_exp_from_mon(((long)exp_mon.max_maxhp+1L) * 9L / 10L, &exp_mon);
2082 /* Monster is dead */
2089 /* Mega-Hack -- Pain cancels fear */
2090 if (m_ptr->monfear && (dam > 0))
2092 int tmp = randint1(dam);
2094 /* Cure a little fear */
2095 if (tmp < m_ptr->monfear)
2098 m_ptr->monfear -= tmp;
2101 /* Cure all the fear */
2112 /* Sometimes a monster gets scared by damage */
2113 if (!m_ptr->monfear && !(r_ptr->flags3 & (RF3_NO_FEAR)))
2117 /* Percentage of fully healthy */
2118 percentage = (100L * m_ptr->hp) / m_ptr->maxhp;
2121 * Run (sometimes) if at 10% or less of max hit points,
2122 * or (usually) when hit for half its current hit points
2124 if ((randint1(10) >= percentage) ||
2125 ((dam >= m_ptr->hp) && (randint0(100) < 80)))
2127 /* Hack -- note fear */
2130 /* XXX XXX XXX Hack -- Add some timed fear */
2131 m_ptr->monfear = (randint1(10) +
2132 (((dam >= m_ptr->hp) && (percentage > 7)) ?
2133 20 : ((11 - percentage) * 5)));
2140 if (p_ptr->riding && (p_ptr->riding == m_idx) && (dam > 0))
2144 /* Extract monster name */
2145 monster_desc(m_name, m_ptr, 0);
2147 if (m_ptr->hp > m_ptr->maxhp/3) dam = (dam + 1) / 2;
2148 if (rakuba((dam > 200) ? 200 : dam, FALSE))
2151 msg_format("%^s¤Ë¿¶¤êÍî¤È¤µ¤ì¤¿¡ª", m_name);
2153 msg_format("%^s has thrown you off!", m_name);
2165 * Get term size and calculate screen size
2167 void get_screen_size(int *wid_p, int *hgt_p)
2169 Term_get_size(wid_p, hgt_p);
2170 *hgt_p -= ROW_MAP + 2;
2171 *wid_p -= COL_MAP + 2;
2172 if (use_bigtile) *wid_p /= 2;
2177 * Calculates current boundaries
2178 * Called below and from "do_cmd_locate()".
2180 void panel_bounds_center(void)
2185 get_screen_size(&wid, &hgt);
2187 panel_row_max = panel_row_min + hgt - 1;
2188 panel_row_prt = panel_row_min - 1;
2189 panel_col_max = panel_col_min + wid - 1;
2190 panel_col_prt = panel_col_min - 13;
2195 * Map resizing whenever the main term changes size
2197 void resize_map(void)
2199 /* Only if the dungeon exists */
2200 if (!character_dungeon) return;
2202 /* Mega-Hack -- no panel yet */
2206 /* Reset the panels */
2207 panel_row_min = cur_hgt;
2208 panel_col_min = cur_wid;
2213 p_ptr->update |= (PU_TORCH | PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
2215 /* Forget lite/view */
2216 p_ptr->update |= (PU_UN_VIEW | PU_UN_LITE);
2218 /* Update lite/view */
2219 p_ptr->update |= (PU_VIEW | PU_LITE | PU_MON_LITE);
2221 /* Update monsters */
2222 p_ptr->update |= (PU_MONSTERS);
2224 /* Redraw everything */
2225 p_ptr->redraw |= (PR_WIPE | PR_BASIC | PR_EXTRA | PR_MAP | PR_EQUIPPY);
2227 /* Hack -- update */
2235 * Place the cursor on the player
2237 if (can_save) move_cursor_relative(py, px);
2244 * Redraw a term when it is resized
2246 void redraw_window(void)
2248 /* Only if the dungeon exists */
2249 if (!character_dungeon) return;
2251 /* Hack - Activate term zero for the redraw */
2252 Term_activate(&term_screen[0]);
2254 /* Hack -- react to changes */
2255 Term_xtra(TERM_XTRA_REACT, 0);
2258 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_SPELL | PW_PLAYER);
2261 p_ptr->window |= (PW_MESSAGE | PW_OVERHEAD | PW_DUNGEON | PW_MONSTER | PW_OBJECT);
2263 /* Hack -- update */
2275 * Handle a request to change the current panel
2277 * Return TRUE if the panel was changed.
2279 * Also used in do_cmd_locate
2281 bool change_panel(int dy, int dx)
2287 get_screen_size(&wid, &hgt);
2289 /* Apply the motion */
2290 y = panel_row_min + dy * hgt / 2;
2291 x = panel_col_min + dx * wid / 2;
2293 /* Verify the row */
2294 if (y > cur_hgt - hgt) y = cur_hgt - hgt;
2297 /* Verify the col */
2298 if (x > cur_wid - wid) x = cur_wid - wid;
2301 /* Handle "changes" */
2302 if ((y != panel_row_min) || (x != panel_col_min))
2304 /* Save the new panel info */
2308 /* Recalculate the boundaries */
2309 panel_bounds_center();
2312 p_ptr->update |= (PU_MONSTERS);
2315 p_ptr->redraw |= (PR_MAP);
2330 * Given an row (y) and col (x), this routine detects when a move
2331 * off the screen has occurred and figures new borders. -RAK-
2333 * "Update" forces a "full update" to take place.
2335 * The map is reprinted if necessary, and "TRUE" is returned.
2337 void verify_panel(void)
2349 get_screen_size(&wid, &hgt);
2351 max_prow_min = cur_hgt - hgt;
2352 max_pcol_min = cur_wid - wid;
2354 /* Bounds checking */
2355 if (max_prow_min < 0) max_prow_min = 0;
2356 if (max_pcol_min < 0) max_pcol_min = 0;
2358 /* Center on player */
2359 if (center_player && (center_running || !running))
2361 /* Center vertically */
2362 prow_min = y - hgt / 2;
2363 if (prow_min < 0) prow_min = 0;
2364 else if (prow_min > max_prow_min) prow_min = max_prow_min;
2366 /* Center horizontally */
2367 pcol_min = x - wid / 2;
2368 if (pcol_min < 0) pcol_min = 0;
2369 else if (pcol_min > max_pcol_min) pcol_min = max_pcol_min;
2373 prow_min = panel_row_min;
2374 pcol_min = panel_col_min;
2376 /* Scroll screen when 2 grids from top/bottom edge */
2377 if (y > panel_row_max - 2)
2379 while (y > prow_min + hgt-1 - 2)
2381 prow_min += (hgt / 2);
2385 if (y < panel_row_min + 2)
2387 while (y < prow_min + 2)
2389 prow_min -= (hgt / 2);
2393 if (prow_min > max_prow_min) prow_min = max_prow_min;
2394 if (prow_min < 0) prow_min = 0;
2396 /* Scroll screen when 4 grids from left/right edge */
2397 if (x > panel_col_max - 4)
2399 while (x > pcol_min + wid-1 - 4)
2401 pcol_min += (wid / 2);
2405 if (x < panel_col_min + 4)
2407 while (x < pcol_min + 4)
2409 pcol_min -= (wid / 2);
2413 if (pcol_min > max_pcol_min) pcol_min = max_pcol_min;
2414 if (pcol_min < 0) pcol_min = 0;
2417 /* Check for "no change" */
2418 if ((prow_min == panel_row_min) && (pcol_min == panel_col_min)) return;
2420 /* Save the new panel info */
2421 panel_row_min = prow_min;
2422 panel_col_min = pcol_min;
2424 /* Hack -- optional disturb on "panel change" */
2425 if (disturb_panel && !center_player) disturb(0, 0);
2427 /* Recalculate the boundaries */
2428 panel_bounds_center();
2431 p_ptr->update |= (PU_MONSTERS);
2434 p_ptr->redraw |= (PR_MAP);
2437 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
2442 * Monster health description
2444 cptr look_mon_desc(monster_type *m_ptr, u32b mode)
2446 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
2453 /* Determine if the monster is "living" */
2454 living = monster_living(ap_r_ptr);
2456 /* Calculate a health "percentage" */
2457 perc = 100L * m_ptr->hp / m_ptr->maxhp;
2459 /* Healthy monsters */
2460 if (m_ptr->hp >= m_ptr->maxhp)
2464 desc = living ? "̵½ý" : "̵¥À¥á¡¼¥¸";
2466 desc = living ? "unhurt" : "undamaged";
2471 else if (perc >= 60)
2474 desc = living ? "·Ú½ý" : "¾®¥À¥á¡¼¥¸";
2476 desc = living ? "somewhat wounded" : "somewhat damaged";
2481 else if (perc >= 25)
2484 desc = living ? "Éé½ý" : "Ãæ¥À¥á¡¼¥¸";
2486 desc = living ? "wounded" : "damaged";
2491 else if (perc >= 10)
2494 desc = living ? "½Å½ý" : "Âç¥À¥á¡¼¥¸";
2496 desc = living ? "badly wounded" : "badly damaged";
2504 desc = living ? "Ⱦ»àȾÀ¸" : "Åݤ줫¤±";
2506 desc = living ? "almost dead" : "almost destroyed";
2511 /* Need attitude information? */
2514 /* Full information is not needed */
2517 else if (is_pet(m_ptr))
2520 attitude = ", ¥Ú¥Ã¥È";
2525 else if (is_friendly(m_ptr))
2528 attitude = ", ͧ¹¥Åª";
2530 attitude = ", friendly";
2543 /* Clone monster? */
2544 if (m_ptr->smart & SM_CLONED)
2553 /* Display monster's level --- idea borrowed from ToME */
2554 if (ap_r_ptr->r_tkills && !(m_ptr->mflag2 & MFLAG2_KAGE))
2557 return format("¥ì¥Ù¥ë%d, %s%s%s", ap_r_ptr->level, desc, attitude, clone);
2559 return format("Level %d, %s%s%s", ap_r_ptr->level, desc, attitude, clone);
2565 return format("¥ì¥Ù¥ë???, %s%s%s", desc, attitude, clone);
2567 return format("Level ???, %s%s%s", desc, attitude, clone);
2575 * Angband sorting algorithm -- quick sort in place
2577 * Note that the details of the data we are sorting is hidden,
2578 * and we rely on the "ang_sort_comp()" and "ang_sort_swap()"
2579 * function hooks to interact with the data, which is given as
2580 * two pointers, and which may have any user-defined form.
2582 void ang_sort_aux(vptr u, vptr v, int p, int q)
2600 while (!(*ang_sort_comp)(u, v, b, z)) b--;
2603 while (!(*ang_sort_comp)(u, v, z, a)) a++;
2605 /* Done partition */
2609 (*ang_sort_swap)(u, v, a, b);
2615 /* Recurse left side */
2616 ang_sort_aux(u, v, p, b);
2618 /* Recurse right side */
2619 ang_sort_aux(u, v, b+1, q);
2624 * Angband sorting algorithm -- quick sort in place
2626 * Note that the details of the data we are sorting is hidden,
2627 * and we rely on the "ang_sort_comp()" and "ang_sort_swap()"
2628 * function hooks to interact with the data, which is given as
2629 * two pointers, and which may have any user-defined form.
2631 void ang_sort(vptr u, vptr v, int n)
2633 /* Sort the array */
2634 ang_sort_aux(u, v, 0, n-1);
2639 /*** Targeting Code ***/
2643 * Determine is a monster makes a reasonable target
2645 * The concept of "targeting" was stolen from "Morgul" (?)
2647 * The player can target any location, or any "target-able" monster.
2649 * Currently, a monster is "target_able" if it is visible, and if
2650 * the player can hit it with a projection, and the player is not
2651 * hallucinating. This allows use of "use closest target" macros.
2653 * Future versions may restrict the ability to target "trappers"
2654 * and "mimics", but the semantics is a little bit weird.
2656 bool target_able(int m_idx)
2658 monster_type *m_ptr = &m_list[m_idx];
2660 /* Monster must be alive */
2661 if (!m_ptr->r_idx) return (FALSE);
2663 /* Hack -- no targeting hallucinations */
2664 if (p_ptr->image) return (FALSE);
2666 /* Monster must be visible */
2667 if (!m_ptr->ml) return (FALSE);
2669 if (p_ptr->riding && (p_ptr->riding == m_idx)) return (TRUE);
2671 /* Monster must be projectable */
2672 if (!projectable(py, px, m_ptr->fy, m_ptr->fx)) return (FALSE);
2674 /* XXX XXX XXX Hack -- Never target trappers */
2675 /* if (CLEAR_ATTR && (CLEAR_CHAR)) return (FALSE); */
2685 * Update (if necessary) and verify (if possible) the target.
2687 * We return TRUE if the target is "okay" and FALSE otherwise.
2689 bool target_okay(void)
2691 /* Accept stationary targets */
2692 if (target_who < 0) return (TRUE);
2694 /* Check moving targets */
2697 /* Accept reasonable targets */
2698 if (target_able(target_who))
2700 monster_type *m_ptr = &m_list[target_who];
2702 /* Acquire monster location */
2703 target_row = m_ptr->fy;
2704 target_col = m_ptr->fx;
2711 /* Assume no target */
2718 * Sorting hook -- comp function -- by "distance to player"
2720 * We use "u" and "v" to point to arrays of "x" and "y" positions,
2721 * and sort the arrays by double-distance to the player.
2723 static bool ang_sort_comp_distance(vptr u, vptr v, int a, int b)
2725 byte *x = (byte*)(u);
2726 byte *y = (byte*)(v);
2730 /* Absolute distance components */
2731 kx = x[a]; kx -= px; kx = ABS(kx);
2732 ky = y[a]; ky -= py; ky = ABS(ky);
2734 /* Approximate Double Distance to the first point */
2735 da = ((kx > ky) ? (kx + kx + ky) : (ky + ky + kx));
2737 /* Absolute distance components */
2738 kx = x[b]; kx -= px; kx = ABS(kx);
2739 ky = y[b]; ky -= py; ky = ABS(ky);
2741 /* Approximate Double Distance to the first point */
2742 db = ((kx > ky) ? (kx + kx + ky) : (ky + ky + kx));
2744 /* Compare the distances */
2750 * Sorting hook -- swap function -- by "distance to player"
2752 * We use "u" and "v" to point to arrays of "x" and "y" positions,
2753 * and sort the arrays by distance to the player.
2755 static void ang_sort_swap_distance(vptr u, vptr v, int a, int b)
2757 byte *x = (byte*)(u);
2758 byte *y = (byte*)(v);
2776 * Hack -- help "select" a location (see below)
2778 static s16b target_pick(int y1, int x1, int dy, int dx)
2782 int x2, y2, x3, y3, x4, y4;
2784 int b_i = -1, b_v = 9999;
2787 /* Scan the locations */
2788 for (i = 0; i < temp_n; i++)
2794 /* Directed distance */
2798 /* Verify quadrant */
2799 if (dx && (x3 * dx <= 0)) continue;
2800 if (dy && (y3 * dy <= 0)) continue;
2802 /* Absolute distance */
2806 /* Verify quadrant */
2807 if (dy && !dx && (x4 > y4)) continue;
2808 if (dx && !dy && (y4 > x4)) continue;
2810 /* Approximate Double Distance */
2811 v = ((x4 > y4) ? (x4 + x4 + y4) : (y4 + y4 + x4));
2813 /* XXX XXX XXX Penalize location */
2816 if ((b_i >= 0) && (v >= b_v)) continue;
2828 * Hack -- determine if a given location is "interesting"
2830 static bool target_set_accept(int y, int x)
2834 s16b this_o_idx, next_o_idx = 0;
2837 if (!(in_bounds(y, x))) return (FALSE);
2839 /* Player grid is always interesting */
2840 if (player_bold(y, x)) return (TRUE);
2843 /* Handle hallucination */
2844 if (p_ptr->image) return (FALSE);
2847 /* Examine the grid */
2848 c_ptr = &cave[y][x];
2850 /* Visible monsters */
2853 monster_type *m_ptr = &m_list[c_ptr->m_idx];
2855 /* Visible monsters */
2856 if (m_ptr->ml) return (TRUE);
2859 /* Scan all objects in the grid */
2860 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
2864 /* Acquire object */
2865 o_ptr = &o_list[this_o_idx];
2867 /* Acquire next object */
2868 next_o_idx = o_ptr->next_o_idx;
2870 /* Memorized object */
2871 if (o_ptr->marked) return (TRUE);
2874 /* Interesting memorized features */
2875 if (c_ptr->info & (CAVE_MARK))
2877 /* Notice object features */
2878 if (c_ptr->info & CAVE_OBJECT) return (TRUE);
2880 /* Feature code (applying "mimic" field) */
2881 if (have_flag(f_info[get_feat_mimic(c_ptr)].flags, FF_NOTICE)) return TRUE;
2890 * Prepare the "temp" array for "target_set"
2892 * Return the number of target_able monsters in the set.
2894 static void target_set_prepare(int mode)
2898 /* Reset "temp" array */
2901 /* Scan the current panel */
2902 for (y = panel_row_min; y <= panel_row_max; y++)
2904 for (x = panel_col_min; x <= panel_col_max; x++)
2908 /* Require "interesting" contents */
2909 if (!target_set_accept(y, x)) continue;
2911 c_ptr = &cave[y][x];
2913 /* Require target_able monsters for "TARGET_KILL" */
2914 if ((mode & (TARGET_KILL)) && !target_able(c_ptr->m_idx)) continue;
2916 if ((mode & (TARGET_KILL)) && !target_pet && is_pet(&m_list[c_ptr->m_idx])) continue;
2918 /* Save the location */
2925 /* Set the sort hooks */
2926 ang_sort_comp = ang_sort_comp_distance;
2927 ang_sort_swap = ang_sort_swap_distance;
2929 /* Sort the positions */
2930 ang_sort(temp_x, temp_y, temp_n);
2932 if (p_ptr->riding && target_pet && (temp_n > 1) && (mode & (TARGET_KILL)))
2937 temp_y[0] = temp_y[1];
2940 temp_x[0] = temp_x[1];
2947 * Evaluate number of kill needed to gain level
2949 static void evaluate_monster_exp(char *buf, monster_type *m_ptr)
2951 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
2953 s32b exp_mon, exp_adv;
2954 u32b exp_mon_frac, exp_adv_frac;
2956 if ((p_ptr->lev >= PY_MAX_LEVEL) || (p_ptr->prace == RACE_ANDROID))
2961 else if (!ap_r_ptr->r_tkills || (m_ptr->mflag2 & MFLAG2_KAGE))
2971 /* The monster's experience point (assuming average monster speed) */
2972 exp_mon = ap_r_ptr->mexp * ap_r_ptr->level;
2974 s64b_div(&exp_mon, &exp_mon_frac, 0, (p_ptr->max_plv + 2));
2977 /* Total experience value for next level */
2978 exp_adv = player_exp[p_ptr->lev -1] * p_ptr->expfact;
2980 s64b_div(&exp_adv, &exp_adv_frac, 0, 100);
2982 /* Experience value need to get */
2983 s64b_sub(&exp_adv, &exp_adv_frac, p_ptr->exp, p_ptr->exp_frac);
2986 /* You need to kill at least one monster to get any experience */
2987 s64b_add(&exp_adv, &exp_adv_frac, exp_mon, exp_mon_frac);
2988 s64b_sub(&exp_adv, &exp_adv_frac, 0, 1);
2990 /* Extract number of monsters needed */
2991 s64b_div(&exp_adv, &exp_adv_frac, exp_mon, exp_mon_frac);
2993 /* If 999 or more monsters needed, only display "999". */
2994 num = MIN(999, exp_adv_frac);
2996 /* Display the number */
2997 sprintf(buf,"%03ld", num);
3002 * Examine a grid, return a keypress.
3004 * The "mode" argument contains the "TARGET_LOOK" bit flag, which
3005 * indicates that the "space" key should scan through the contents
3006 * of the grid, instead of simply returning immediately. This lets
3007 * the "look" command get complete information, without making the
3008 * "target" command annoying.
3010 * The "info" argument contains the "commands" which should be shown
3011 * inside the "[xxx]" text. This string must never be empty, or grids
3012 * containing monsters will be displayed with an extra comma.
3014 * Note that if a monster is in the grid, we update both the monster
3015 * recall info and the health bar info to track that monster.
3017 * Eventually, we may allow multiple objects per grid, or objects
3018 * and terrain features in the same grid. XXX XXX XXX
3020 * This function must handle blindness/hallucination.
3022 static int target_set_aux(int y, int x, int mode, cptr info)
3024 cave_type *c_ptr = &cave[y][x];
3025 s16b this_o_idx, next_o_idx = 0;
3026 cptr s1 = "", s2 = "", s3 = "", x_info = "";
3029 feature_type *f_ptr;
3031 char out_val[MAX_NLEN+80];
3033 #ifdef ALLOW_EASY_FLOOR
3034 int floor_list[23], floor_num = 0;
3036 /* Scan all objects in the grid */
3039 floor_num = scan_floor(floor_list, y, x, 0x02);
3051 #endif /* ALLOW_EASY_FLOOR */
3053 /* Hack -- under the player */
3054 if (player_bold(y, x))
3077 /* Hack -- hallucination */
3081 cptr name = "²¿¤«´ñ̯¤Êʪ";
3083 cptr name = "something strange";
3087 /* Display a message */
3089 sprintf(out_val, "%s%s%s%s [%s]", s1, name, s2, s3, info);
3091 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, name, info);
3095 move_cursor_relative(y, x);
3098 /* Stop on everything but "return" */
3099 if ((query != '\r') && (query != '\n')) return query;
3101 /* Repeat forever */
3106 /* Actual monsters */
3107 if (c_ptr->m_idx && m_list[c_ptr->m_idx].ml)
3109 monster_type *m_ptr = &m_list[c_ptr->m_idx];
3110 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
3112 bool recall = FALSE;
3117 /* Get the monster name ("a kobold") */
3118 monster_desc(m_name, m_ptr, MD_INDEF_VISIBLE);
3120 /* Hack -- track this monster race */
3121 monster_race_track(m_ptr->ap_r_idx);
3123 /* Hack -- health bar for this monster */
3124 health_track(c_ptr->m_idx);
3126 /* Hack -- handle stuff */
3140 /* Recall on screen */
3141 screen_roff(m_ptr->ap_r_idx, 0);
3143 /* Hack -- Complete the prompt (again) */
3145 Term_addstr(-1, TERM_WHITE, format(" [r»× %s%s]", x_info, info));
3147 Term_addstr(-1, TERM_WHITE, format(" [r,%s%s]", x_info, info));
3156 /* Normal commands */
3157 if (query != 'r') break;
3162 /* Cleare recall text and repeat */
3168 /* Describe, and prompt for recall */
3169 evaluate_monster_exp(acount, m_ptr);
3172 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);
3174 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);
3180 move_cursor_relative(y, x);
3185 /* Normal commands */
3186 if (query != 'r') break;
3192 /* Always stop at "normal" keys */
3193 if ((query != '\r') && (query != '\n') && (query != ' ') && (query != 'x')) return query;
3195 /* Sometimes stop at "space" key */
3196 if ((query == ' ') && !(mode & (TARGET_LOOK))) return query;
3198 /* Change the intro */
3206 /* Hack -- take account of gender */
3208 if (ap_r_ptr->flags1 & (RF1_FEMALE)) s1 = "Èà½÷¤Ï";
3210 if (ap_r_ptr->flags1 & (RF1_FEMALE)) s1 = "She is ";
3214 else if (ap_r_ptr->flags1 & (RF1_MALE)) s1 = "Èà¤Ï";
3216 else if (ap_r_ptr->flags1 & (RF1_MALE)) s1 = "He is ";
3220 /* Use a preposition */
3229 /* Scan all objects being carried */
3230 for (this_o_idx = m_ptr->hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
3232 char o_name[MAX_NLEN];
3236 /* Acquire object */
3237 o_ptr = &o_list[this_o_idx];
3239 /* Acquire next object */
3240 next_o_idx = o_ptr->next_o_idx;
3242 /* Obtain an object description */
3243 object_desc(o_name, o_ptr, 0);
3245 /* Describe the object */
3247 sprintf(out_val, "%s%s%s%s[%s]", s1, o_name, s2, s3, info);
3249 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, o_name, info);
3253 move_cursor_relative(y, x);
3256 /* Always stop at "normal" keys */
3257 if ((query != '\r') && (query != '\n') && (query != ' ') && (query != 'x')) return query;
3259 /* Sometimes stop at "space" key */
3260 if ((query == ' ') && !(mode & (TARGET_LOOK))) return query;
3262 /* Change the intro */
3266 s2 = "also carrying ";
3270 /* Use a preposition */
3280 #ifdef ALLOW_EASY_FLOOR
3289 char o_name[MAX_NLEN];
3293 /* Acquire object */
3294 o_ptr = &o_list[floor_list[0]];
3296 /* Describe the object */
3297 object_desc(o_name, o_ptr, 0);
3301 sprintf(out_val, "%s%s%s%s[%s]",
3302 s1, o_name, s2, s3, info);
3304 sprintf(out_val, "%s%s%s%s [%s]",
3305 s1, s2, s3, o_name, info);
3309 move_cursor_relative(y, x);
3318 /* Provide one cushion before item listing */
3321 /* Display rough information about items */
3323 sprintf(out_val, "%s %d¸Ä¤Î¥¢¥¤¥Æ¥à%s%s ['x'¤Ç°ìÍ÷, %s]",
3324 s1, floor_num, s2, s3, info);
3326 sprintf(out_val, "%s%s%sa pile of %d items [x,%s]",
3327 s1, s2, s3, floor_num, info);
3331 move_cursor_relative(y, x);
3336 /* No request for listing */
3337 if (query != 'x' && query != ' ') return query;
3341 /** Display list of items **/
3343 /* Continue scrolling list if requested */
3352 (void)show_floor(0, y, x, &min_width);
3356 sprintf(out_val, "%s %d¸Ä¤Î¥¢¥¤¥Æ¥à%s%s [Enter¤Ç¼¡¤Ø, %s]",
3357 s1, floor_num, s2, s3, info);
3359 sprintf(out_val, "%s%s%sa pile of %d items [Enter,%s]",
3360 s1, s2, s3, floor_num, info);
3371 /* Exit unless 'Enter' */
3372 if (query != '\n' && query != '\r')
3377 /* Get the object being moved. */
3378 o_idx = c_ptr->o_idx;
3380 /* Only rotate a pile of two or more objects. */
3381 if (!(o_idx && o_list[o_idx].next_o_idx)) continue;
3383 /* Remove the first object from the list. */
3384 excise_object_idx(o_idx);
3386 /* Find end of the list. */
3388 while (o_list[i].next_o_idx)
3389 i = o_list[i].next_o_idx;
3391 /* Add after the last object. */
3392 o_list[i].next_o_idx = o_idx;
3394 /* Loop and re-display the list */
3400 #endif /* ALLOW_EASY_FLOOR */
3403 /* Scan all objects in the grid */
3404 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
3408 /* Acquire object */
3409 o_ptr = &o_list[this_o_idx];
3411 /* Acquire next object */
3412 next_o_idx = o_ptr->next_o_idx;
3417 char o_name[MAX_NLEN];
3422 /* Obtain an object description */
3423 object_desc(o_name, o_ptr, 0);
3425 /* Describe the object */
3427 sprintf(out_val, "%s%s%s%s[%s]", s1, o_name, s2, s3, info);
3429 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, o_name, info);
3433 move_cursor_relative(y, x);
3436 /* Always stop at "normal" keys */
3437 if ((query != '\r') && (query != '\n') && (query != ' ') && (query != 'x')) return query;
3439 /* Sometimes stop at "space" key */
3440 if ((query == ' ') && !(mode & TARGET_LOOK)) return query;
3442 /* Change the intro */
3452 if (o_ptr->number != 1) s1 = "¤½¤ì¤é¤Ï";
3454 if (o_ptr->number != 1) s1 = "They are ";
3470 /* Feature code (applying "mimic" field) */
3471 feat = get_feat_mimic(c_ptr);
3473 /* Require knowledge about grid, or ability to see grid */
3474 if (!(c_ptr->info & CAVE_MARK) && !player_can_see_bold(y, x))
3476 /* Forget feature */
3480 f_ptr = &f_info[feat];
3482 /* Terrain feature if needed */
3483 if (boring || (feat > FEAT_INVIS))
3487 /* Hack -- special handling for building doors */
3488 if (have_flag(f_ptr->flags, FF_BLDG))
3490 name = building[f_ptr->power].name;
3492 else if (have_flag(f_ptr->flags, FF_ENTRANCE))
3495 name = format("%s(%d³¬ÁêÅö)", d_text + d_info[c_ptr->special].text, d_info[c_ptr->special].mindepth);
3497 name = format("%s(level %d)", d_text + d_info[c_ptr->special].text, d_info[c_ptr->special].mindepth);
3500 else if (have_flag(f_ptr->flags, FF_TOWN))
3502 name = town[c_ptr->special].name;
3504 else if (p_ptr->wild_mode && (feat == FEAT_FLOOR))
3514 name = f_name + f_ptr->name;
3520 ((!have_flag(f_ptr->flags, FF_MOVE) && !have_flag(f_ptr->flags, FF_CAN_FLY)) ||
3521 (!have_flag(f_ptr->flags, FF_LOS) && !have_flag(f_ptr->flags, FF_TREE)) ||
3522 have_flag(f_ptr->flags, FF_TOWN)))
3531 /* Hack -- special introduction for store & building doors -KMW- */
3532 if (have_flag(f_ptr->flags, FF_STORE) ||
3533 have_flag(f_ptr->flags, FF_BLDG) ||
3534 have_flag(f_ptr->flags, FF_ENTRANCE))
3543 else if (have_flag(f_ptr->flags, FF_FLOOR) ||
3544 have_flag(f_ptr->flags, FF_TOWN) ||
3545 have_flag(f_ptr->flags, FF_SHALLOW) ||
3546 have_flag(f_ptr->flags, FF_DEEP))
3552 /* Pick proper indefinite article */
3553 s3 = (is_a_vowel(name[0])) ? "an " : "a ";
3557 /* Display a message */
3560 sprintf(out_val, "%s%s%s%s[%s] %x %d %d %d %d (%d,%d)", s1, name, s2, s3, info, c_ptr->info, c_ptr->feat, c_ptr->dist, c_ptr->cost, c_ptr->when, x, y);
3562 sprintf(out_val, "%s%s%s%s [%s] %x %d %d %d %d (%d,%d)", s1, s2, s3, name, info, c_ptr->info, c_ptr->feat, c_ptr->dist, c_ptr->cost, c_ptr->when, x, y);
3566 sprintf(out_val, "%s%s%s%s[%s]", s1, name, s2, s3, info);
3568 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, name, info);
3572 move_cursor_relative(y, x);
3575 /* Always stop at "normal" keys */
3576 if ((query != '\r') && (query != '\n') && (query != ' ')) return query;
3579 /* Stop on everything but "return" */
3580 if ((query != '\r') && (query != '\n')) return query;
3582 /* Repeat forever */
3588 * Handle "target" and "look".
3590 * Note that this code can be called from "get_aim_dir()".
3592 * All locations must be on the current panel. Consider the use of
3593 * "panel_bounds()" to allow "off-panel" targets, perhaps by using
3594 * some form of "scrolling" the map around the cursor. XXX XXX XXX
3595 * That is, consider the possibility of "auto-scrolling" the screen
3596 * while the cursor moves around. This may require changes in the
3597 * "update_mon()" code to allow "visibility" even if off panel, and
3598 * may require dynamic recalculation of the "temp" grid set.
3600 * Hack -- targeting/observing an "outer border grid" may induce
3601 * problems, so this is not currently allowed.
3603 * The player can use the direction keys to move among "interesting"
3604 * grids in a heuristic manner, or the "space", "+", and "-" keys to
3605 * move through the "interesting" grids in a sequential manner, or
3606 * can enter "location" mode, and use the direction keys to move one
3607 * grid at a time in any direction. The "t" (set target) command will
3608 * only target a monster (as opposed to a location) if the monster is
3609 * target_able and the "interesting" mode is being used.
3611 * The current grid is described using the "look" method above, and
3612 * a new command may be entered at any time, but note that if the
3613 * "TARGET_LOOK" bit flag is set (or if we are in "location" mode,
3614 * where "space" has no obvious meaning) then "space" will scan
3615 * through the description of the current grid until done, instead
3616 * of immediately jumping to the next "interesting" grid. This
3617 * allows the "target" command to retain its old semantics.
3619 * The "*", "+", and "-" keys may always be used to jump immediately
3620 * to the next (or previous) interesting grid, in the proper mode.
3622 * The "return" key may always be used to scan through a complete
3623 * grid description (forever).
3625 * This command will cancel any old target, even if used from
3626 * inside the "look" command.
3628 bool target_set(int mode)
3648 get_screen_size(&wid, &hgt);
3654 /* Cancel tracking */
3655 /* health_track(0); */
3658 /* Prepare the "temp" array */
3659 target_set_prepare(mode);
3661 /* Start near the player */
3667 /* Interesting grids */
3673 if (!(mode & TARGET_LOOK)) prt_path(y, x);
3676 c_ptr = &cave[y][x];
3679 if (target_able(c_ptr->m_idx))
3682 strcpy(info, "q»ß t·è p¼« o¸½ +¼¡ -Á°");
3684 strcpy(info, "q,t,p,o,+,-,<dir>");
3689 /* Dis-allow target */
3693 strcpy(info, "q»ß p¼« o¸½ +¼¡ -Á°");
3695 strcpy(info, "q,p,o,+,-,<dir>");
3700 /* Describe and Prompt */
3701 while (!(query = target_set_aux(y, x, mode, info)));
3703 /* Cancel tracking */
3704 /* health_track(0); */
3706 /* Assume no "direction" */
3711 if (query == '\r') query = 't';
3729 if (target_able(c_ptr->m_idx))
3731 health_track(c_ptr->m_idx);
3732 target_who = c_ptr->m_idx;
3751 if (!expand_list) done = TRUE;
3761 if (!expand_list) done = TRUE;
3768 /* Recenter the map around the player */
3772 p_ptr->update |= (PU_MONSTERS);
3775 p_ptr->redraw |= (PR_MAP);
3778 p_ptr->window |= (PW_OVERHEAD);
3783 /* Recalculate interesting grids */
3784 target_set_prepare(mode);
3803 /* Extract the action (if any) */
3804 d = get_keymap_dir(query);
3811 /* Hack -- move around */
3814 /* Modified to scroll to monster */
3815 int y2 = panel_row_min;
3816 int x2 = panel_col_min;
3818 /* Find a new monster */
3819 i = target_pick(temp_y[m], temp_x[m], ddy[d], ddx[d]);
3821 /* Request to target past last interesting grid */
3822 while (flag && (i < 0))
3824 /* Note the change */
3825 if (change_panel(ddy[d], ddx[d]))
3830 /* Recalculate interesting grids */
3831 target_set_prepare(mode);
3833 /* Look at interesting grids */
3836 /* Find a new monster */
3837 i = target_pick(v, u, ddy[d], ddx[d]);
3843 /* Nothing interesting */
3849 /* Restore previous position */
3852 panel_bounds_center();
3855 p_ptr->update |= (PU_MONSTERS);
3858 p_ptr->redraw |= (PR_MAP);
3861 p_ptr->window |= (PW_OVERHEAD);
3866 /* Recalculate interesting grids */
3867 target_set_prepare(mode);
3869 /* Look at boring grids */
3876 /* Do not move horizontally if unnecessary */
3877 if (((x < panel_col_min + wid / 2) && (dx > 0)) ||
3878 ((x > panel_col_min + wid / 2) && (dx < 0)))
3883 /* Do not move vertically if unnecessary */
3884 if (((y < panel_row_min + hgt / 2) && (dy > 0)) ||
3885 ((y > panel_row_min + hgt / 2) && (dy < 0)))
3890 /* Apply the motion */
3891 if ((y >= panel_row_min+hgt) || (y < panel_row_min) ||
3892 (x >= panel_col_min+wid) || (x < panel_col_min))
3894 if (change_panel(dy, dx)) target_set_prepare(mode);
3897 /* Slide into legality */
3898 if (x >= cur_wid-1) x = cur_wid - 2;
3899 else if (x <= 0) x = 1;
3901 /* Slide into legality */
3902 if (y >= cur_hgt-1) y = cur_hgt- 2;
3903 else if (y <= 0) y = 1;
3912 /* Arbitrary grids */
3915 bool move_fast = FALSE;
3917 if (!(mode & TARGET_LOOK)) prt_path(y, x);
3920 c_ptr = &cave[y][x];
3922 /* Default prompt */
3924 strcpy(info, "q»ß t·è p¼« m¶á +¼¡ -Á°");
3926 strcpy(info, "q,t,p,m,+,-,<dir>");
3930 /* Describe and Prompt (enable "TARGET_LOOK") */
3931 while (!(query = target_set_aux(y, x, mode | TARGET_LOOK, info)));
3933 /* Cancel tracking */
3934 /* health_track(0); */
3936 /* Assume no direction */
3941 if (query == '\r') query = 't';
3944 /* Analyze the keypress */
3968 /* Recenter the map around the player */
3972 p_ptr->update |= (PU_MONSTERS);
3975 p_ptr->redraw |= (PR_MAP);
3978 p_ptr->window |= (PW_OVERHEAD);
3983 /* Recalculate interesting grids */
3984 target_set_prepare(mode);
4006 /* Pick a nearby monster */
4007 for (i = 0; i < temp_n; i++)
4009 t = distance(y, x, temp_y[i], temp_x[i]);
4019 /* Nothing interesting */
4020 if (bd == 999) flag = FALSE;
4027 /* Extract the action (if any) */
4028 d = get_keymap_dir(query);
4030 /* XTRA HACK MOVEFAST */
4031 if (isupper(query)) move_fast = TRUE;
4038 /* Handle "direction" */
4044 /* XTRA HACK MOVEFAST */
4047 int mag = MIN(wid / 2, hgt / 2);
4057 /* Do not move horizontally if unnecessary */
4058 if (((x < panel_col_min + wid / 2) && (dx > 0)) ||
4059 ((x > panel_col_min + wid / 2) && (dx < 0)))
4064 /* Do not move vertically if unnecessary */
4065 if (((y < panel_row_min + hgt / 2) && (dy > 0)) ||
4066 ((y > panel_row_min + hgt / 2) && (dy < 0)))
4071 /* Apply the motion */
4072 if ((y >= panel_row_min + hgt) || (y < panel_row_min) ||
4073 (x >= panel_col_min + wid) || (x < panel_col_min))
4075 if (change_panel(dy, dx)) target_set_prepare(mode);
4078 /* Slide into legality */
4079 if (x >= cur_wid-1) x = cur_wid - 2;
4080 else if (x <= 0) x = 1;
4082 /* Slide into legality */
4083 if (y >= cur_hgt-1) y = cur_hgt- 2;
4084 else if (y <= 0) y = 1;
4092 /* Clear the top line */
4095 /* Recenter the map around the player */
4099 p_ptr->update |= (PU_MONSTERS);
4102 p_ptr->redraw |= (PR_MAP);
4105 p_ptr->window |= (PW_OVERHEAD);
4110 /* Failure to set target */
4111 if (!target_who) return (FALSE);
4119 * Get an "aiming direction" from the user.
4121 * The "dir" is loaded with 1,2,3,4,6,7,8,9 for "actual direction", and
4122 * "0" for "current target", and "-1" for "entry aborted".
4124 * Note that "Force Target", if set, will pre-empt user interaction,
4125 * if there is a usable target already set.
4127 * Note that confusion over-rides any (explicit?) user choice.
4129 bool get_aim_dir(int *dp)
4140 /* Global direction */
4143 /* Hack -- auto-target if requested */
4144 if (use_old_target && target_okay()) dir = 5;
4146 #ifdef ALLOW_REPEAT /* TNB */
4148 if (repeat_pull(dp))
4153 if (!(*dp == 5 && !target_okay()))
4155 /* return (TRUE); */
4160 #endif /* ALLOW_REPEAT -- TNB */
4162 /* Ask until satisfied */
4165 /* Choose a prompt */
4169 p = "Êý¸þ ('*'¤Ç¥¿¡¼¥²¥Ã¥ÈÁªÂò, ESC¤ÇÃæÃÇ)? ";
4171 p = "Direction ('*' to choose a target, Escape to cancel)? ";
4178 p = "Êý¸þ ('5'¤Ç¥¿¡¼¥²¥Ã¥È¤Ø, '*'¤Ç¥¿¡¼¥²¥Ã¥ÈºÆÁªÂò, ESC¤ÇÃæÃÇ)? ";
4180 p = "Direction ('5' for target, '*' to re-target, Escape to cancel)? ";
4185 /* Get a command (or Cancel) */
4186 if (!get_com(p, &command, TRUE)) break;
4190 if (command == '\r') command = 't';
4193 /* Convert various keys to "standard" keys */
4196 /* Use current target */
4207 /* Set new target */
4212 if (target_set(TARGET_KILL)) dir = 5;
4218 /* Extract the action (if any) */
4219 dir = get_keymap_dir(command);
4225 /* Verify requested targets */
4226 if ((dir == 5) && !target_okay()) dir = 0;
4235 project_length = 0; /* reset to default */
4239 /* Save the direction */
4242 /* Check for confusion */
4243 if (p_ptr->confused)
4246 /* Random direction */
4247 dir = ddd[randint0(8)];
4250 /* Notice confusion */
4251 if (command_dir != dir)
4255 msg_print("¤¢¤Ê¤¿¤Ïº®Í𤷤Ƥ¤¤ë¡£");
4257 msg_print("You are confused.");
4262 /* Save direction */
4265 #ifdef ALLOW_REPEAT /* TNB */
4267 /* repeat_push(dir); */
4268 repeat_push(command_dir);
4270 #endif /* ALLOW_REPEAT -- TNB */
4272 /* A "valid" direction was entered */
4279 * Request a "movement" direction (1,2,3,4,6,7,8,9) from the user,
4280 * and place it into "command_dir", unless we already have one.
4282 * This function should be used for all "repeatable" commands, such as
4283 * run, walk, open, close, bash, disarm, spike, tunnel, etc, as well
4284 * as all commands which must reference a grid adjacent to the player,
4285 * and which may not reference the grid under the player. Note that,
4286 * for example, it is no longer possible to "disarm" or "open" chests
4287 * in the same grid as the player.
4289 * Direction "5" is illegal and will (cleanly) abort the command.
4291 * This function tracks and uses the "global direction", and uses
4292 * that as the "desired direction", to which "confusion" is applied.
4294 bool get_rep_dir(int *dp, bool under)
4301 /* Global direction */
4304 #ifdef ALLOW_REPEAT /* TNB */
4306 if (repeat_pull(dp))
4309 /* return (TRUE); */
4312 #endif /* ALLOW_REPEAT -- TNB */
4314 /* Get a direction */
4319 /* Get a command (or Cancel) */
4321 if (!get_com("Êý¸þ (ESC¤ÇÃæÃÇ)? ", &ch, TRUE)) break;
4323 if (!get_com("Direction (Escape to cancel)? ", &ch, TRUE)) break;
4327 /* Look up the direction */
4328 dir = get_keymap_dir(ch);
4334 /* Prevent weirdness */
4335 if ((dir == 5) && (!under)) dir = 0;
4338 if (!dir) return (FALSE);
4340 /* Save desired direction */
4343 /* Apply "confusion" */
4344 if (p_ptr->confused)
4346 /* Standard confusion */
4347 if (randint0(100) < 75)
4349 /* Random direction */
4350 dir = ddd[randint0(8)];
4353 else if (p_ptr->riding)
4355 monster_type *m_ptr = &m_list[p_ptr->riding];
4356 monster_race *r_ptr = &r_info[m_ptr->r_idx];
4358 if (m_ptr->confused)
4360 /* Standard confusion */
4361 if (randint0(100) < 75)
4363 /* Random direction */
4364 dir = ddd[randint0(8)];
4367 else if ((r_ptr->flags1 & RF1_RAND_50) && (r_ptr->flags1 & RF1_RAND_25) && (randint0(100) < 50))
4369 /* Random direction */
4370 dir = ddd[randint0(8)];
4372 else if ((r_ptr->flags1 & RF1_RAND_50) && (randint0(100) < 25))
4374 /* Random direction */
4375 dir = ddd[randint0(8)];
4379 /* Notice confusion */
4380 if (command_dir != dir)
4382 if (p_ptr->confused)
4386 msg_print("¤¢¤Ê¤¿¤Ïº®Í𤷤Ƥ¤¤ë¡£");
4388 msg_print("You are confused.");
4394 monster_type *m_ptr = &m_list[p_ptr->riding];
4396 monster_desc(m_name, m_ptr, 0);
4397 if (m_ptr->confused)
4400 msg_format("%s¤Ïº®Í𤷤Ƥ¤¤ë¡£", m_name);
4402 msg_format("%^s is confusing.", m_name);
4409 msg_format("%s¤Ï»×¤¤Ä̤ê¤ËÆ°¤¤¤Æ¤¯¤ì¤Ê¤¤¡£", m_name);
4411 msg_format("You cannot control %s.", m_name);
4417 /* Save direction */
4420 #ifdef ALLOW_REPEAT /* TNB */
4422 /* repeat_push(dir); */
4423 repeat_push(command_dir);
4425 #endif /* ALLOW_REPEAT -- TNB */
4432 bool get_rep_dir2(int *dp)
4439 /* Global direction */
4442 #ifdef ALLOW_REPEAT /* TNB */
4444 if (repeat_pull(dp))
4447 /* return (TRUE); */
4450 #endif /* ALLOW_REPEAT -- TNB */
4452 /* Get a direction */
4457 /* Get a command (or Cancel) */
4459 if (!get_com("Êý¸þ (ESC¤ÇÃæÃÇ)? ", &ch, TRUE)) break;
4461 if (!get_com("Direction (Escape to cancel)? ", &ch, TRUE)) break;
4465 /* Look up the direction */
4466 dir = get_keymap_dir(ch);
4472 /* Prevent weirdness */
4473 if (dir == 5) dir = 0;
4476 if (!dir) return (FALSE);
4478 /* Save desired direction */
4481 /* Apply "confusion" */
4482 if (p_ptr->confused)
4484 /* Standard confusion */
4485 if (randint0(100) < 75)
4487 /* Random direction */
4488 dir = ddd[randint0(8)];
4492 /* Notice confusion */
4493 if (command_dir != dir)
4497 msg_print("¤¢¤Ê¤¿¤Ïº®Í𤷤Ƥ¤¤ë¡£");
4499 msg_print("You are confused.");
4504 /* Save direction */
4507 #ifdef ALLOW_REPEAT /* TNB */
4509 /* repeat_push(dir); */
4510 repeat_push(command_dir);
4512 #endif /* ALLOW_REPEAT -- TNB */
4519 void gain_level_reward(int chosen_reward)
4523 char wrath_reason[32] = "";
4524 int nasty_chance = 6;
4525 int dummy = 0, dummy2 = 0;
4528 char o_name[MAX_NLEN];
4534 if (multi_rew) return;
4535 else multi_rew = TRUE;
4539 if (p_ptr->lev == 13) nasty_chance = 2;
4540 else if (!(p_ptr->lev % 13)) nasty_chance = 3;
4541 else if (!(p_ptr->lev % 14)) nasty_chance = 12;
4543 if (one_in_(nasty_chance))
4544 type = randint1(20); /* Allow the 'nasty' effects */
4546 type = randint1(15) + 5; /* Or disallow them */
4548 if (type < 1) type = 1;
4549 if (type > 20) type = 20;
4554 sprintf(wrath_reason, "%s¤ÎÅܤê",
4555 chaos_patrons[p_ptr->chaos_patron]);
4557 sprintf(wrath_reason, "the Wrath of %s",
4558 chaos_patrons[p_ptr->chaos_patron]);
4562 effect = chaos_rewards[p_ptr->chaos_patron][type];
4564 if (one_in_(6) && !chosen_reward)
4567 msg_format("%^s¤ÏË«Èþ¤È¤·¤Æ¤¢¤Ê¤¿¤òÆÍÁ³ÊÑ°Û¤µ¤»¤¿¡£",
4568 chaos_patrons[p_ptr->chaos_patron]);
4570 msg_format("%^s rewards you with a mutation!",
4571 chaos_patrons[p_ptr->chaos_patron]);
4574 (void)gain_random_mutation(0);
4576 reward = "ÊÑ°Û¤·¤¿¡£";
4578 reward = "mutation";
4583 switch (chosen_reward ? chosen_reward : effect)
4587 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
4588 chaos_patrons[p_ptr->chaos_patron]);
4590 msg_format("The voice of %s booms out:",
4591 chaos_patrons[p_ptr->chaos_patron]);
4595 msg_print("¡ÖÆò¡¢¿·¤¿¤Ê¤ë»Ñ¤òɬÍפȤ»¤ê¡ª¡×");
4597 msg_print("'Thou needst a new form, mortal!'");
4602 reward = "ÊÑ°Û¤·¤¿¡£";
4604 reward = "polymorphing";
4609 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
4610 chaos_patrons[p_ptr->chaos_patron]);
4612 msg_format("The voice of %s booms out:",
4613 chaos_patrons[p_ptr->chaos_patron]);
4617 msg_print("¡ÖÆò¤ÏÎɤ¯¹Ô¤¤¤¿¤ê¡ªÂ³¤±¤è¡ª¡×");
4619 msg_print("'Well done, mortal! Lead on!'");
4622 if (p_ptr->prace == RACE_ANDROID)
4625 msg_print("¤·¤«¤·²¿¤âµ¯¤³¤é¤Ê¤«¤Ã¤¿¡£");
4627 msg_print("But, nothing happen.");
4630 else if (p_ptr->exp < PY_MAX_EXP)
4632 s32b ee = (p_ptr->exp / 2) + 10;
4633 if (ee > 100000L) ee = 100000L;
4635 msg_print("¹¹¤Ë·Ð¸³¤òÀѤó¤À¤è¤¦¤Êµ¤¤¬¤¹¤ë¡£");
4637 msg_print("You feel more experienced.");
4642 reward = "·Ð¸³ÃͤòÆÀ¤¿";
4644 reward = "experience";
4650 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
4651 chaos_patrons[p_ptr->chaos_patron]);
4653 msg_format("The voice of %s booms out:",
4654 chaos_patrons[p_ptr->chaos_patron]);
4658 msg_print("¡Ö²¼Ëͤ衢Æò¤½¤ì¤ËÃͤ»¤º¡£¡×");
4660 msg_print("'Thou didst not deserve that, slave.'");
4663 if (p_ptr->prace == RACE_ANDROID)
4666 msg_print("¤·¤«¤·²¿¤âµ¯¤³¤é¤Ê¤«¤Ã¤¿¡£");
4668 msg_print("But, nothing happen.");
4673 lose_exp(p_ptr->exp / 6);
4675 reward = "·Ð¸³Ãͤò¼º¤Ã¤¿¡£";
4677 reward = "losing experience";
4683 msg_format("%s¤ÎÀ¼¤¬¤µ¤µ¤ä¤¤¤¿:",
4684 chaos_patrons[p_ptr->chaos_patron]);
4686 msg_format("The voice of %s whispers:",
4687 chaos_patrons[p_ptr->chaos_patron]);
4691 msg_print("¡Ö²æ¤¬Í¿¤¨¤·Êª¤ò¸ÌÀ¤Ë»È¤¦¤Ù¤·¡£¡×");
4693 msg_print("'Use my gift wisely.'");
4696 acquirement(py, px, 1, FALSE, FALSE);
4698 reward = "¾å¼Á¤Ê¥¢¥¤¥Æ¥à¤ò¼ê¤ËÆþ¤ì¤¿¡£";
4700 reward = "a good item";
4705 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
4706 chaos_patrons[p_ptr->chaos_patron]);
4708 msg_format("The voice of %s booms out:",
4709 chaos_patrons[p_ptr->chaos_patron]);
4713 msg_print("¡Ö²æ¤¬Í¿¤¨¤·Êª¤ò¸ÌÀ¤Ë»È¤¦¤Ù¤·¡£¡×");
4715 msg_print("'Use my gift wisely.'");
4718 acquirement(py, px, 1, TRUE, FALSE);
4720 reward = "¹âµéÉʤΥ¢¥¤¥Æ¥à¤ò¼ê¤ËÆþ¤ì¤¿¡£";
4722 reward = "an excellent item";
4727 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
4728 chaos_patrons[p_ptr->chaos_patron]);
4730 msg_format("The voice of %s booms out:",
4731 chaos_patrons[p_ptr->chaos_patron]);
4735 msg_print("¡ÖÆò¤Î¹Ô¤¤¤Ïµ®¤·õ¤ËÃͤ»¤ê¡£¡×");
4737 msg_print("'Thy deed hath earned thee a worthy blade.'");
4740 /* Get local object */
4743 switch (randint1(p_ptr->lev))
4749 dummy2 = SV_MAIN_GAUCHE;
4758 dummy2 = SV_SMALL_SWORD;
4761 dummy2 = SV_BASILLARD;
4763 case 11: case 12: case 13:
4764 dummy2 = SV_SHORT_SWORD;
4770 dummy2 = SV_CUTLASS;
4773 dummy2 = SV_WAKIZASHI;
4776 dummy2 = SV_KHOPESH;
4782 dummy2 = SV_BROAD_SWORD;
4785 dummy2 = SV_LONG_SWORD;
4788 dummy2 = SV_SCIMITAR;
4791 dummy2 = SV_NINJATO;
4797 dummy2 = SV_BASTARD_SWORD;
4800 dummy2 = SV_GREAT_SCIMITAR;
4803 dummy2 = SV_CLAYMORE;
4806 dummy2 = SV_ESPADON;
4809 dummy2 = SV_TWO_HANDED_SWORD;
4812 dummy2 = SV_FLAMBERGE;
4815 dummy2 = SV_NO_DACHI;
4818 dummy2 = SV_EXECUTIONERS_SWORD;
4821 dummy2 = SV_ZWEIHANDER;
4824 dummy2 = SV_HAYABUSA;
4827 dummy2 = SV_BLADE_OF_CHAOS;
4830 object_prep(q_ptr, lookup_kind(dummy, dummy2));
4831 q_ptr->to_h = 3 + randint1(dun_level) % 10;
4832 q_ptr->to_d = 3 + randint1(dun_level) % 10;
4833 one_resistance(q_ptr);
4834 q_ptr->name2 = EGO_CHAOTIC;
4836 /* Drop it in the dungeon */
4837 (void)drop_near(q_ptr, -1, py, px);
4839 reward = "(º®ÆÙ)¤ÎÉð´ï¤ò¼ê¤ËÆþ¤ì¤¿¡£";
4841 reward = "chaos weapon";
4846 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
4847 chaos_patrons[p_ptr->chaos_patron]);
4849 msg_format("The voice of %s booms out:",
4850 chaos_patrons[p_ptr->chaos_patron]);
4854 msg_print("¡ÖÆò¤Î¹Ô¤¤¤Ïµ®¤Ê󤤤ËÃͤ»¤ê¡£¡×");
4856 msg_print("'Thy deed hath earned thee a worthy reward.'");
4859 acquirement(py, px, randint1(2) + 1, FALSE, FALSE);
4861 reward = "¾å¼Á¤Ê¥¢¥¤¥Æ¥à¤ò¼ê¤ËÆþ¤ì¤¿¡£";
4863 reward = "good items";
4868 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
4869 chaos_patrons[p_ptr->chaos_patron]);
4871 msg_format("The voice of %s booms out:",
4872 chaos_patrons[p_ptr->chaos_patron]);
4876 msg_print("¡Ö²¼Ëͤ衢Æò¤Î¸¥¿È¤Ø¤Î²æ¤¬Àˤ·¤ß̵¤Ê󤤤ò¸«¤ë¤¬¤è¤¤¡£¡×");
4878 msg_print("'Behold, mortal, how generously I reward thy loyalty.'");
4881 acquirement(py, px, randint1(2) + 1, TRUE, FALSE);
4883 reward = "¹âµéÉʤΥ¢¥¤¥Æ¥à¤ò¼ê¤ËÆþ¤ì¤¿¡£";
4885 reward = "excellent items";
4890 msg_format("%s¤ÎÀ¼¤¬¹ì¤ÅϤä¿:",
4891 chaos_patrons[p_ptr->chaos_patron]);
4893 msg_format("The voice of %s thunders:",
4894 chaos_patrons[p_ptr->chaos_patron]);
4898 msg_print("¡Ö²¼Ëͤ衢ÆòÐþËý¤Ê¤ê¡£¡×");
4900 msg_print("'Thou art growing arrogant, mortal.'");
4903 (void)activate_ty_curse(FALSE, &count);
4905 reward = "²Ò¡¹¤·¤¤¼ö¤¤¤ò¤«¤±¤é¤ì¤¿¡£";
4912 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
4913 chaos_patrons[p_ptr->chaos_patron]);
4915 msg_format("The voice of %s booms out:",
4916 chaos_patrons[p_ptr->chaos_patron]);
4920 msg_print("¡Ö²æ¤¬²¼Ëͤ¿¤Á¤è¡¢¤«¤ÎÐþËý¤Ê¤ë¼Ô¤òÅݤ¹¤Ù¤·¡ª¡×");
4922 msg_print("'My pets, destroy the arrogant mortal!'");
4925 for (dummy = 0; dummy < randint1(5) + 1; dummy++)
4927 (void)summon_specific(0, py, px, dun_level, 0, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET));
4930 reward = "¥â¥ó¥¹¥¿¡¼¤ò¾¤´¤µ¤ì¤¿¡£";
4932 reward = "summoning hostile monsters";
4937 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
4938 chaos_patrons[p_ptr->chaos_patron]);
4940 msg_format("The voice of %s booms out:",
4941 chaos_patrons[p_ptr->chaos_patron]);
4945 msg_print("¡ÖÆò¡¢¤è¤ê¶¯¤Å¨¤òɬÍפȤ»¤ê¡ª¡×");
4947 msg_print("'Thou needst worthier opponents!'");
4950 activate_hi_summon(py, px, FALSE);
4952 reward = "¥â¥ó¥¹¥¿¡¼¤ò¾¤´¤µ¤ì¤¿¡£";
4954 reward = "summoning many hostile monsters";
4959 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
4960 chaos_patrons[p_ptr->chaos_patron]);
4962 msg_format("The voice of %s booms out:",
4963 chaos_patrons[p_ptr->chaos_patron]);
4967 msg_print("¡Ö»à¤ÈÇ˲õ¤³¤½²æ¤¬´î¤Ó¤Ê¤ê¡ª¡×");
4969 msg_print("'Death and destruction! This pleaseth me!'");
4974 reward = "¥«¥ª¥¹¤ÎÎϤ¬±²´¬¤¤¤¿¡£";
4976 reward = "calling chaos";
4981 msg_format("%s¤ÎÀ¼¤¬ÌĤê¶Á¤¤¤¿:",
4982 chaos_patrons[p_ptr->chaos_patron]);
4984 msg_format("The voice of %s rings out:",
4985 chaos_patrons[p_ptr->chaos_patron]);
4989 msg_print("¡Öα¤Þ¤ë¤Î¤À¡¢²¼Ëͤ衣;¤¬Æò¤ÎÆùÂΤòÃ䨤󡣡×");
4991 msg_print("'Stay, mortal, and let me mold thee.'");
4994 if (one_in_(3) && !(chaos_stats[p_ptr->chaos_patron] < 0))
4995 do_inc_stat(chaos_stats[p_ptr->chaos_patron]);
4997 do_inc_stat(randint0(6));
4999 reward = "ǽÎÏÃͤ¬¾å¤¬¤Ã¤¿¡£";
5001 reward = "increasing a stat";
5006 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5007 chaos_patrons[p_ptr->chaos_patron]);
5009 msg_format("The voice of %s booms out:",
5010 chaos_patrons[p_ptr->chaos_patron]);
5014 msg_print("¡Ö²¼Ëͤ衢;¤ÏÆò¤ËË°¤ß¤¿¤ê¡£¡×");
5016 msg_print("'I grow tired of thee, mortal.'");
5019 if (one_in_(3) && !(chaos_stats[p_ptr->chaos_patron] < 0))
5020 do_dec_stat(chaos_stats[p_ptr->chaos_patron]);
5022 (void)do_dec_stat(randint0(6));
5024 reward = "ǽÎÏÃͤ¬²¼¤¬¤Ã¤¿¡£";
5026 reward = "decreasing a stat";
5031 msg_format("%s¤ÎÀ¼¤¬¹ì¤ÅϤä¿:",
5032 chaos_patrons[p_ptr->chaos_patron]);
5034 msg_format("The voice of %s thunders:",
5035 chaos_patrons[p_ptr->chaos_patron]);
5039 msg_print("¡ÖÆò¡¢¸¬µõ¤¿¤ë¤³¤È¤ò³Ø¤Ö¤Ù¤·¡ª¡×");
5040 msg_print("¤¢¤Ê¤¿¤Ï°ÊÁ°¤è¤ê¼å¤¯¤Ê¤Ã¤¿¡ª");
5042 msg_print("'Thou needst a lesson in humility, mortal!'");
5043 msg_print("You feel less powerful!");
5046 for (dummy = 0; dummy < 6; dummy++)
5048 (void)dec_stat(dummy, 10 + randint1(15), TRUE);
5051 reward = "Á´Ç½ÎÏÃͤ¬²¼¤¬¤Ã¤¿¡£";
5053 reward = "decreasing all stats";
5058 msg_format("%s¤ÎÎϤ¬¿¨¤ì¤ë¤Î¤ò´¶¤¸¤¿¡£",
5060 msg_format("You feel the power of %s touch you.",
5063 chaos_patrons[p_ptr->chaos_patron]);
5066 reward = "½ý¤¬ÊѲ½¤·¤¿¡£";
5068 reward = "polymorphing wounds";
5073 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5074 chaos_patrons[p_ptr->chaos_patron]);
5076 msg_format("The voice of %s booms out:",
5077 chaos_patrons[p_ptr->chaos_patron]);
5081 msg_print("¡Ö²æ¤¬¤µ¤µ¤ä¤«¤Ê¤ë»òʪ¤ò¼õ¤±¤È¤ë¤¬¤è¤¤¡ª¡×");
5083 msg_print("'Receive this modest gift from me!'");
5086 for (dummy = 0; dummy < 6; dummy++)
5088 (void)do_inc_stat(dummy);
5091 reward = "Á´Ç½ÎÏÃͤ¬¾å¤¬¤Ã¤¿¡£";
5093 reward = "increasing all stats";
5098 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5099 chaos_patrons[p_ptr->chaos_patron]);
5101 msg_format("The voice of %s booms out:",
5102 chaos_patrons[p_ptr->chaos_patron]);
5106 msg_print("¡Ö¶ì¤·¤à¤¬¤è¤¤¡¢ÌµÇ½¤Ê¶ò¤«¼Ô¤è¡ª¡×");
5108 msg_print("'Suffer, pathetic fool!'");
5111 fire_ball(GF_DISINTEGRATE, 0, p_ptr->lev * 4, 4);
5112 take_hit(DAMAGE_NOESCAPE, p_ptr->lev * 4, wrath_reason, -1);
5114 reward = "ʬ²ò¤Îµå¤¬È¯À¸¤·¤¿¡£";
5116 reward = "generating disintegration ball";
5121 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5122 chaos_patrons[p_ptr->chaos_patron]);
5124 msg_format("The voice of %s booms out:",
5125 chaos_patrons[p_ptr->chaos_patron]);
5129 msg_print("¡Öᴤ뤬¤è¤¤¡¢²æ¤¬²¼Ëͤ衪¡×");
5131 msg_print("'Rise, my servant!'");
5135 (void)set_poisoned(0);
5137 (void)set_confused(0);
5142 for (dummy = 0; dummy < 6; dummy++)
5144 (void)do_res_stat(dummy);
5147 reward = "ÂÎÎϤ¬²óÉü¤·¤¿¡£";
5153 if (!buki_motteruka(INVEN_RARM)) break;
5155 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5156 chaos_patrons[p_ptr->chaos_patron]);
5158 msg_format("The voice of %s booms out:",
5159 chaos_patrons[p_ptr->chaos_patron]);
5163 msg_print("¡ÖÆò¡¢Éð´ï¤ËÍê¤ë¤³¤È¤Ê¤«¤ì¡£¡×");
5165 msg_print("'Thou reliest too much on thy weapon.'");
5168 object_desc(o_name, &inventory[INVEN_RARM], OD_NAME_ONLY);
5169 (void)curse_weapon(FALSE, INVEN_RARM);
5171 reward = format("%s¤¬Ç˲õ¤µ¤ì¤¿¡£", o_name);
5173 reward = format("destroying %s", o_name);
5177 if (!inventory[INVEN_BODY].k_idx) break;
5179 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5180 chaos_patrons[p_ptr->chaos_patron]);
5182 msg_format("The voice of %s booms out:",
5183 chaos_patrons[p_ptr->chaos_patron]);
5187 msg_print("¡ÖÆò¡¢Ëɶñ¤ËÍê¤ë¤³¤È¤Ê¤«¤ì¡£¡×");
5189 msg_print("'Thou reliest too much on thine equipment.'");
5192 object_desc(o_name, &inventory[INVEN_BODY], OD_NAME_ONLY);
5193 (void)curse_armor();
5195 reward = format("%s¤¬Ç˲õ¤µ¤ì¤¿¡£", o_name);
5197 reward = format("destroying %s", o_name);
5202 msg_format("%s¤ÎÀ¼¤¬¤µ¤µ¤ä¤¤¤¿:",
5203 chaos_patrons[p_ptr->chaos_patron]);
5205 msg_format("The voice of %s whispers:",
5206 chaos_patrons[p_ptr->chaos_patron]);
5210 msg_print("¡Ö²æ¤òÅܤꤷ¤á¤¿ºá¤ò½þ¤¦¤Ù¤·¡£¡×");
5212 msg_print("'Now thou shalt pay for annoying me.'");
5215 switch (randint1(4))
5218 (void)activate_ty_curse(FALSE, &count);
5220 reward = "²Ò¡¹¤·¤¤¼ö¤¤¤ò¤«¤±¤é¤ì¤¿¡£";
5226 activate_hi_summon(py, px, FALSE);
5228 reward = "¥â¥ó¥¹¥¿¡¼¤ò¾¤´¤µ¤ì¤¿¡£";
5230 reward = "summoning hostile monsters";
5236 if (!buki_motteruka(INVEN_RARM)) break;
5237 object_desc(o_name, &inventory[INVEN_RARM], OD_NAME_ONLY);
5238 (void)curse_weapon(FALSE, INVEN_RARM);
5240 reward = format("%s¤¬Ç˲õ¤µ¤ì¤¿¡£", o_name);
5242 reward = format("destroying %s", o_name);
5247 if (!inventory[INVEN_BODY].k_idx) break;
5248 object_desc(o_name, &inventory[INVEN_BODY], OD_NAME_ONLY);
5249 (void)curse_armor();
5251 reward = format("%s¤¬Ç˲õ¤µ¤ì¤¿¡£", o_name);
5253 reward = format("destroying %s", o_name);
5258 for (dummy = 0; dummy < 6; dummy++)
5260 (void)dec_stat(dummy, 10 + randint1(15), TRUE);
5263 reward = "Á´Ç½ÎÏÃͤ¬²¼¤¬¤Ã¤¿¡£";
5265 reward = "decreasing all stats";
5272 msg_format("%s¤ÎÀ¼¤¬¹ì¤ÅϤä¿:",
5274 msg_format("The voice of %s thunders:",
5277 chaos_patrons[p_ptr->chaos_patron]);
5279 msg_print("¡Ö»à¤Ì¤¬¤è¤¤¡¢²¼Ëͤ衪¡×");
5281 msg_print("'Die, mortal!'");
5284 take_hit(DAMAGE_LOSELIFE, p_ptr->lev * 4, wrath_reason, -1);
5285 for (dummy = 0; dummy < 6; dummy++)
5287 (void)dec_stat(dummy, 10 + randint1(15), FALSE);
5289 activate_hi_summon(py, px, FALSE);
5290 (void)activate_ty_curse(FALSE, &count);
5291 if (one_in_(2)) (void)curse_weapon(FALSE, INVEN_RARM);
5292 if (one_in_(2)) (void)curse_armor();
5296 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5297 chaos_patrons[p_ptr->chaos_patron]);
5299 msg_format("The voice of %s booms out:",
5300 chaos_patrons[p_ptr->chaos_patron]);
5304 msg_print("¡Ö»à¤ÈÇ˲õ¤³¤½²æ¤¬´î¤Ó¤Ê¤ê¡ª¡×");
5306 msg_print("'Death and destruction! This pleaseth me!'");
5309 (void)destroy_area(py, px, 25, FALSE);
5311 reward = "¥À¥ó¥¸¥ç¥ó¤¬*Ç˲õ*¤µ¤ì¤¿¡£";
5313 reward = "*destruct*ing dungeon";
5318 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5319 chaos_patrons[p_ptr->chaos_patron]);
5321 msg_format("The voice of %s booms out:",
5322 chaos_patrons[p_ptr->chaos_patron]);
5326 msg_print("¡Ö²æ¡¢Æò¤ÎŨ¤òËõ»¦¤»¤ó¡ª¡×");
5328 msg_print("'Let me relieve thee of thine oppressors!'");
5331 (void)symbol_genocide(0, FALSE);
5333 reward = "¥â¥ó¥¹¥¿¡¼¤¬Ëõ»¦¤µ¤ì¤¿¡£";
5335 reward = "genociding monsters";
5340 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5341 chaos_patrons[p_ptr->chaos_patron]);
5343 msg_format("The voice of %s booms out:",
5344 chaos_patrons[p_ptr->chaos_patron]);
5348 msg_print("¡Ö²æ¡¢Æò¤ÎŨ¤òËõ»¦¤»¤ó¡ª¡×");
5350 msg_print("'Let me relieve thee of thine oppressors!'");
5353 (void)mass_genocide(0, FALSE);
5355 reward = "¥â¥ó¥¹¥¿¡¼¤¬Ëõ»¦¤µ¤ì¤¿¡£";
5357 reward = "genociding nearby monsters";
5362 msg_format("%s¤ÎÎϤ¬Å¨¤ò¹¶·â¤¹¤ë¤Î¤ò´¶¤¸¤¿¡ª",
5363 chaos_patrons[p_ptr->chaos_patron]);
5365 msg_format("You can feel the power of %s assault your enemies!",
5366 chaos_patrons[p_ptr->chaos_patron]);
5369 (void)dispel_monsters(p_ptr->lev * 4);
5373 msg_format("%s¤Ï¤¢¤Ê¤¿¤ò̵»ë¤·¤¿¡£",
5374 chaos_patrons[p_ptr->chaos_patron]);
5376 msg_format("%s ignores you.",
5377 chaos_patrons[p_ptr->chaos_patron]);
5383 msg_format("%s¤ÏË«Èþ¤È¤·¤Æ°Ëâ¤Î»È¤¤¤ò¤è¤³¤·¤¿¡ª",chaos_patrons[p_ptr->chaos_patron]);
5385 msg_format("%s rewards you with a demonic servant!",chaos_patrons[p_ptr->chaos_patron]);
5388 if (!summon_specific(-1, py, px, dun_level, SUMMON_DEMON, PM_FORCE_PET))
5390 msg_print("²¿¤â¸½¤ì¤Ê¤«¤Ã¤¿...");
5392 msg_print("Nobody ever turns up...");
5396 reward = "°Ë⤬¥Ú¥Ã¥È¤Ë¤Ê¤Ã¤¿¡£";
5398 reward = "a demonic servant";
5404 msg_format("%s¤ÏË«Èþ¤È¤·¤Æ»È¤¤¤ò¤è¤³¤·¤¿¡ª",chaos_patrons[p_ptr->chaos_patron]);
5406 msg_format("%s rewards you with a servant!",chaos_patrons[p_ptr->chaos_patron]);
5409 if (!summon_specific(-1, py, px, dun_level, 0, PM_FORCE_PET))
5411 msg_print("²¿¤â¸½¤ì¤Ê¤«¤Ã¤¿...");
5413 msg_print("Nobody ever turns up...");
5417 reward = "¥â¥ó¥¹¥¿¡¼¤¬¥Ú¥Ã¥È¤Ë¤Ê¤Ã¤¿¡£";
5419 reward = "a servant";
5425 msg_format("%s¤ÏË«Èþ¤È¤·¤Æ¥¢¥ó¥Ç¥Ã¥É¤Î»È¤¤¤ò¤è¤³¤·¤¿¡£",chaos_patrons[p_ptr->chaos_patron]);
5427 msg_format("%s rewards you with an undead servant!",chaos_patrons[p_ptr->chaos_patron]);
5430 if (!summon_specific(-1, py, px, dun_level, SUMMON_UNDEAD, PM_FORCE_PET))
5432 msg_print("²¿¤â¸½¤ì¤Ê¤«¤Ã¤¿...");
5434 msg_print("Nobody ever turns up...");
5438 reward = "¥¢¥ó¥Ç¥Ã¥É¤¬¥Ú¥Ã¥È¤Ë¤Ê¤Ã¤¿¡£";
5440 reward = "an undead servant";
5446 msg_format("%s¤ÎÀ¼¤¬¤É¤â¤Ã¤¿:",
5448 msg_format("The voice of %s stammers:",
5451 chaos_patrons[p_ptr->chaos_patron]);
5453 msg_format("¡Ö¤¢¡¼¡¢¤¢¡¼¡¢Åú¤¨¤Ï %d/%d¡£¼ÁÌä¤Ï²¿¡©¡×", type, effect);
5455 msg_format("'Uh... uh... the answer's %d/%d, what's the question?'", type, effect);
5463 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, format("¥Ñ¥È¥í¥ó¤ÎÊó½·¤Ç%s", reward));
5465 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, format("The patron rewards you with %s.", reward));
5472 * old -- from PsiAngband.
5474 bool tgt_pt(int *x_ptr, int *y_ptr)
5478 bool success = FALSE;
5483 get_screen_size(&wid, &hgt);
5489 msg_print("¾ì½ê¤òÁª¤ó¤Ç¥¹¥Ú¡¼¥¹¥¡¼¤ò²¡¤·¤Æ²¼¤µ¤¤¡£");
5491 msg_print("Select a point and press space.");
5493 msg_flag = FALSE; /* prevents "-more-" message. */
5495 while ((ch != ESCAPE) && !success)
5497 bool move_fast = FALSE;
5499 move_cursor_relative(y, x);
5511 if (player_bold(y, x)) ch = 0;
5514 else success = TRUE;
5518 /* Look up the direction */
5519 d = get_keymap_dir(ch);
5521 /* XTRA HACK MOVEFAST */
5522 if (isupper(ch)) move_fast = TRUE;
5524 /* Handle "direction" */
5530 /* XTRA HACK MOVEFAST */
5533 int mag = MIN(wid / 2, hgt / 2);
5543 /* Do not move horizontally if unnecessary */
5544 if (((x < panel_col_min + wid / 2) && (dx > 0)) ||
5545 ((x > panel_col_min + wid / 2) && (dx < 0)))
5550 /* Do not move vertically if unnecessary */
5551 if (((y < panel_row_min + hgt / 2) && (dy > 0)) ||
5552 ((y > panel_row_min + hgt / 2) && (dy < 0)))
5557 /* Apply the motion */
5558 if ((y >= panel_row_min + hgt) || (y < panel_row_min) ||
5559 (x >= panel_col_min + wid) || (x < panel_col_min))
5561 /* if (change_panel(dy, dx)) target_set_prepare(mode); */
5562 change_panel(dy, dx);
5565 /* Slide into legality */
5566 if (x >= cur_wid-1) x = cur_wid - 2;
5567 else if (x <= 0) x = 1;
5569 /* Slide into legality */
5570 if (y >= cur_hgt-1) y = cur_hgt- 2;
5571 else if (y <= 0) y = 1;
5578 /* Clear the top line */
5581 /* Recenter the map around the player */
5585 p_ptr->update |= (PU_MONSTERS);
5588 p_ptr->redraw |= (PR_MAP);
5591 p_ptr->window |= (PW_OVERHEAD);
5602 bool get_hack_dir(int *dp)
5612 /* Global direction */
5615 /* (No auto-targeting) */
5617 /* Ask until satisfied */
5620 /* Choose a prompt */
5624 p = "Êý¸þ ('*'¤Ç¥¿¡¼¥²¥Ã¥ÈÁªÂò, ESC¤ÇÃæÃÇ)? ";
5626 p = "Direction ('*' to choose a target, Escape to cancel)? ";
5633 p = "Êý¸þ ('5'¤Ç¥¿¡¼¥²¥Ã¥È¤Ø, '*'¤Ç¥¿¡¼¥²¥Ã¥ÈºÆÁªÂò, ESC¤ÇÃæÃÇ)? ";
5635 p = "Direction ('5' for target, '*' to re-target, Escape to cancel)? ";
5640 /* Get a command (or Cancel) */
5641 if (!get_com(p, &command, TRUE)) break;
5645 if (command == '\r') command = 't';
5648 /* Convert various keys to "standard" keys */
5651 /* Use current target */
5662 /* Set new target */
5667 if (target_set(TARGET_KILL)) dir = 5;
5673 /* Look up the direction */
5674 dir = get_keymap_dir(command);
5680 /* Verify requested targets */
5681 if ((dir == 5) && !target_okay()) dir = 0;
5688 if (!dir) return (FALSE);
5690 /* Save the direction */
5693 /* Check for confusion */
5694 if (p_ptr->confused)
5697 /* Random direction */
5698 dir = ddd[randint0(8)];
5701 /* Notice confusion */
5702 if (command_dir != dir)
5706 msg_print("¤¢¤Ê¤¿¤Ïº®Í𤷤Ƥ¤¤ë¡£");
5708 msg_print("You are confused.");
5713 /* Save direction */
5716 /* A "valid" direction was entered */
5722 * ¥¨¥Í¥ë¥®¡¼¤ÎÁý²ÃÎÌ10d5¤ò®¤¯·×»»¤¹¤ë¤¿¤á¤Î´Ø¿ô
5725 #define Go_no_JuuJou 5*5*5*5*5*5*5*5*5*5
5727 s16b gain_energy(void)
5730 s32b energy_result = 10;
5733 tmp = randint0(Go_no_JuuJou);
5735 for (i = 0; i < 9; i ++){
5736 energy_result += tmp % 5;
5740 return (s16b)(energy_result + tmp);
5747 s16b bow_energy(int sval)
5751 /* Analyze the launcher */
5754 /* Sling and ammo */
5761 /* Short Bow and Arrow */
5768 /* Long Bow and Arrow */
5775 /* Bow of irresponsiblity and Arrow */
5782 /* Light Crossbow and Bolt */
5789 /* Heavy Crossbow and Bolt */
5804 int bow_tmul(int sval)
5808 /* Analyze the launcher */
5811 /* Sling and ammo */
5818 /* Short Bow and Arrow */
5825 /* Long Bow and Arrow */
5832 /* Bow of irresponsiblity and Arrow */
5839 /* Light Crossbow and Bolt */
5846 /* Heavy Crossbow and Bolt */
5858 * Return alignment title
5860 cptr your_alignment(void)
5863 if (p_ptr->align > 150) return "ÂçÁ±";
5864 else if (p_ptr->align > 50) return "ÃæÁ±";
5865 else if (p_ptr->align > 10) return "¾®Á±";
5866 else if (p_ptr->align > -11) return "ÃæΩ";
5867 else if (p_ptr->align > -51) return "¾®°";
5868 else if (p_ptr->align > -151) return "Ãæ°";
5871 if (p_ptr->align > 150) return "Lawful";
5872 else if (p_ptr->align > 50) return "Good";
5873 else if (p_ptr->align > 10) return "Neutral Good";
5874 else if (p_ptr->align > -11) return "Neutral";
5875 else if (p_ptr->align > -51) return "Neutral Evil";
5876 else if (p_ptr->align > -151) return "Evil";
5877 else return "Chaotic";
5883 * Return proficiency level of weapons and misc. skills (except riding)
5885 int weapon_exp_level(int weapon_exp)
5887 if (weapon_exp < WEAPON_EXP_BEGINNER) return EXP_LEVEL_UNSKILLED;
5888 else if (weapon_exp < WEAPON_EXP_SKILLED) return EXP_LEVEL_BEGINNER;
5889 else if (weapon_exp < WEAPON_EXP_EXPERT) return EXP_LEVEL_SKILLED;
5890 else if (weapon_exp < WEAPON_EXP_MASTER) return EXP_LEVEL_EXPERT;
5891 else return EXP_LEVEL_MASTER;
5896 * Return proficiency level of riding
5898 int riding_exp_level(int riding_exp)
5900 if (riding_exp < RIDING_EXP_BEGINNER) return EXP_LEVEL_UNSKILLED;
5901 else if (riding_exp < RIDING_EXP_SKILLED) return EXP_LEVEL_BEGINNER;
5902 else if (riding_exp < RIDING_EXP_EXPERT) return EXP_LEVEL_SKILLED;
5903 else if (riding_exp < RIDING_EXP_MASTER) return EXP_LEVEL_EXPERT;
5904 else return EXP_LEVEL_MASTER;
5909 * Return proficiency level of spells
5911 int spell_exp_level(int spell_exp)
5913 if (spell_exp < SPELL_EXP_BEGINNER) return EXP_LEVEL_UNSKILLED;
5914 else if (spell_exp < SPELL_EXP_SKILLED) return EXP_LEVEL_BEGINNER;
5915 else if (spell_exp < SPELL_EXP_EXPERT) return EXP_LEVEL_SKILLED;
5916 else if (spell_exp < SPELL_EXP_MASTER) return EXP_LEVEL_EXPERT;
5917 else return EXP_LEVEL_MASTER;