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;
32 /* Hack -- lower limit */
33 if (p_ptr->max_exp < 0) p_ptr->max_exp = 0;
35 /* Hack -- upper limit */
36 if (p_ptr->exp > PY_MAX_EXP) p_ptr->exp = PY_MAX_EXP;
38 /* Hack -- upper limit */
39 if (p_ptr->max_exp > PY_MAX_EXP) p_ptr->max_exp = PY_MAX_EXP;
41 /* Hack -- maintain "max" experience */
42 if (p_ptr->exp > p_ptr->max_exp) p_ptr->max_exp = p_ptr->exp;
44 /* Redraw experience */
45 p_ptr->redraw |= (PR_EXP);
51 /* Lose levels while possible */
52 while ((p_ptr->lev > 1) &&
53 (p_ptr->exp < ((android ? player_exp_a : player_exp)[p_ptr->lev - 2] * p_ptr->expfact / 100L)))
58 /* Update some stuff */
59 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
61 /* Redraw some stuff */
62 p_ptr->redraw |= (PR_LEV | PR_TITLE);
65 p_ptr->window |= (PW_PLAYER);
72 /* Gain levels while possible */
73 while ((p_ptr->lev < PY_MAX_LEVEL) &&
74 (p_ptr->exp >= ((android ? player_exp_a : player_exp)[p_ptr->lev-1] * p_ptr->expfact / 100L)))
79 /* Save the highest level */
80 if (p_ptr->lev > p_ptr->max_plv)
82 p_ptr->max_plv = p_ptr->lev;
84 if ((p_ptr->pclass == CLASS_CHAOS_WARRIOR) ||
85 (p_ptr->muta2 & MUT2_CHAOS_GIFT))
89 if (p_ptr->prace == RACE_BEASTMAN)
91 if (one_in_(5)) level_mutation = TRUE;
93 level_inc_stat = TRUE;
95 do_cmd_write_nikki(NIKKI_LEVELUP, p_ptr->lev, NULL);
103 msg_format("¥ì¥Ù¥ë %d ¤Ë¤è¤¦¤³¤½¡£", p_ptr->lev);
105 msg_format("Welcome to level %d.", p_ptr->lev);
108 /* Update some stuff */
109 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
111 /* Redraw some stuff */
112 p_ptr->redraw |= (PR_LEV | PR_TITLE);
115 p_ptr->window |= (PW_PLAYER | PW_SPELL);
117 /* HP¤ÈMP¤Î¾å¾ºÎ̤òɽ¼¨ */
127 if(!(p_ptr->max_plv % 10))
137 cnv_stat(p_ptr->stat_max[0], tmp);
138 prt(format(" a) ÏÓÎÏ (¸½ºßÃÍ %s)", tmp), 2, 14);
139 cnv_stat(p_ptr->stat_max[1], tmp);
140 prt(format(" b) ÃÎǽ (¸½ºßÃÍ %s)", tmp), 3, 14);
141 cnv_stat(p_ptr->stat_max[2], tmp);
142 prt(format(" c) ¸¤µ (¸½ºßÃÍ %s)", tmp), 4, 14);
143 cnv_stat(p_ptr->stat_max[3], tmp);
144 prt(format(" d) ´ïÍÑ (¸½ºßÃÍ %s)", tmp), 5, 14);
145 cnv_stat(p_ptr->stat_max[4], tmp);
146 prt(format(" e) ÂÑµ× (¸½ºßÃÍ %s)", tmp), 6, 14);
147 cnv_stat(p_ptr->stat_max[5], tmp);
148 prt(format(" f) Ì¥ÎÏ (¸½ºßÃÍ %s)", tmp), 7, 14);
150 prt(" ¤É¤ÎǽÎÏÃͤò¾å¤²¤Þ¤¹¤«¡©", 1, 14);
152 cnv_stat(p_ptr->stat_max[0], tmp);
153 prt(format(" a) Str (cur %s)", tmp), 2, 14);
154 cnv_stat(p_ptr->stat_max[1], tmp);
155 prt(format(" b) Int (cur %s)", tmp), 3, 14);
156 cnv_stat(p_ptr->stat_max[2], tmp);
157 prt(format(" c) Wis (cur %s)", tmp), 4, 14);
158 cnv_stat(p_ptr->stat_max[3], tmp);
159 prt(format(" d) Dex (cur %s)", tmp), 5, 14);
160 cnv_stat(p_ptr->stat_max[4], tmp);
161 prt(format(" e) Con (cur %s)", tmp), 6, 14);
162 cnv_stat(p_ptr->stat_max[5], tmp);
163 prt(format(" f) Chr (cur %s)", tmp), 7, 14);
165 prt(" Which stat do you want to raise?", 1, 14);
170 if ((choice >= 'a') && (choice <= 'f')) break;
172 for(n = 0; n < 6; n++)
173 if (n != choice - 'a')
176 if (get_check("¤è¤í¤·¤¤¤Ç¤¹¤«¡©")) break;
178 if (get_check("Are you sure? ")) break;
181 do_inc_stat(choice - 'a');
184 else if(!(p_ptr->max_plv % 2))
185 do_inc_stat(randint0(6));
191 msg_print("¤¢¤Ê¤¿¤ÏÊѤï¤Ã¤¿µ¤¤¬¤¹¤ë...");
193 msg_print("You feel different...");
196 (void)gain_random_mutation(0);
197 level_mutation = FALSE;
201 * Ê󽷤ǥì¥Ù¥ë¤¬¾å¤ë¤ÈºÆµ¢Åª¤Ë check_experience() ¤¬
202 * ¸Æ¤Ð¤ì¤ë¤Î¤Ç½çÈÖ¤òºÇ¸å¤Ë¤¹¤ë¡£
206 gain_level_reward(0);
207 level_reward = FALSE;
210 /* Update some stuff */
211 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
213 /* Redraw some stuff */
214 p_ptr->redraw |= (PR_LEV | PR_TITLE);
217 p_ptr->window |= (PW_PLAYER | PW_SPELL);
226 * Hack -- Return the "automatic coin type" of a monster race
227 * Used to allocate proper treasure when "Creeping coins" die
229 * XXX XXX XXX Note the use of actual "monster names"
231 static int get_coin_type(int r_idx)
233 monster_race *r_ptr = &r_info[r_idx];
235 /* Analyze "coin" monsters */
236 if (r_ptr->d_char == '$')
238 /* Look for textual clues */
241 case MON_COPPER_COINS: return (2);
242 case MON_SILVER_COINS: return (5);
243 case MON_GOLD_COINS: return (10);
244 case MON_MITHRIL_COINS: return (16);
245 case MON_ADAMANT_COINS: return (17);
255 * Hack -- determine if a template is Cloak
257 static bool kind_is_cloak(int k_idx)
259 object_kind *k_ptr = &k_info[k_idx];
261 /* Analyze the item type */
262 if (k_ptr->tval == TV_CLOAK)
267 /* Assume not good */
273 * Hack -- determine if a template is Polearm
275 static bool kind_is_polearm(int k_idx)
277 object_kind *k_ptr = &k_info[k_idx];
279 /* Analyze the item type */
280 if (k_ptr->tval == TV_POLEARM)
285 /* Assume not good */
291 * Hack -- determine if a template is Sword
293 static bool kind_is_sword(int k_idx)
295 object_kind *k_ptr = &k_info[k_idx];
297 /* Analyze the item type */
298 if ((k_ptr->tval == TV_SWORD) && (k_ptr->sval > 2))
303 /* Assume not good */
309 * Hack -- determine if a template is Book
311 static bool kind_is_book(int k_idx)
313 object_kind *k_ptr = &k_info[k_idx];
315 /* Analyze the item type */
316 if ((k_ptr->tval >= TV_LIFE_BOOK) && (k_ptr->tval <= TV_CRUSADE_BOOK))
321 /* Assume not good */
327 * Hack -- determine if a template is Good book
329 static bool kind_is_good_book(int k_idx)
331 object_kind *k_ptr = &k_info[k_idx];
333 /* Analyze the item type */
334 if ((k_ptr->tval >= TV_LIFE_BOOK) && (k_ptr->tval <= TV_CRUSADE_BOOK) && (k_ptr->tval != TV_ARCANE_BOOK) && (k_ptr->sval > 1))
339 /* Assume not good */
345 * Hack -- determine if a template is Armor
347 static bool kind_is_armor(int k_idx)
349 object_kind *k_ptr = &k_info[k_idx];
351 /* Analyze the item type */
352 if (k_ptr->tval == TV_HARD_ARMOR)
357 /* Assume not good */
363 * Check for "Quest" completion when a quest monster is killed or charmed.
365 void check_quest_completion(monster_type *m_ptr)
367 int i, j, y, x, ny, nx, i2, j2;
371 bool create_stairs = FALSE;
377 /* Get the location */
382 quest_num = p_ptr->inside_quest;
384 /* Search for an active quest on this dungeon level */
387 for (i = max_quests - 1; i > 0; i--)
389 /* Quest is not active */
390 if (quest[i].status != QUEST_STATUS_TAKEN)
393 /* Quest is not a dungeon quest */
394 if (quest[i].flags & QUEST_FLAG_PRESET)
397 /* Quest is not on this level */
398 if ((quest[i].level != dun_level) &&
399 (quest[i].type != QUEST_TYPE_KILL_ANY_LEVEL))
402 /* Not a "kill monster" quest */
403 if ((quest[i].type == QUEST_TYPE_FIND_ARTIFACT) ||
404 (quest[i].type == QUEST_TYPE_FIND_EXIT))
407 /* Interesting quest */
408 if ((quest[i].type == QUEST_TYPE_KILL_NUMBER) ||
409 (quest[i].type == QUEST_TYPE_KILL_ALL))
412 /* Interesting quest */
413 if (((quest[i].type == QUEST_TYPE_KILL_LEVEL) ||
414 (quest[i].type == QUEST_TYPE_KILL_ANY_LEVEL) ||
415 (quest[i].type == QUEST_TYPE_RANDOM)) &&
416 (quest[i].r_idx == m_ptr->r_idx))
423 /* Handle the current quest */
424 if (quest_num && (quest[quest_num].status == QUEST_STATUS_TAKEN))
429 switch (quest[i].type)
431 case QUEST_TYPE_KILL_NUMBER:
435 if (quest[i].cur_num >= quest[i].num_mon)
437 if (record_fix_quest) do_cmd_write_nikki(NIKKI_FIX_QUEST_C, i, NULL);
438 /* completed quest */
439 quest[i].status = QUEST_STATUS_COMPLETED;
440 quest[i].complev = (byte)p_ptr->lev;
442 if (!(quest[i].flags & QUEST_FLAG_SILENT))
445 msg_print("¥¯¥¨¥¹¥È¤òãÀ®¤·¤¿¡ª");
447 msg_print("You just completed your quest!");
453 quest[i].cur_num = 0;
457 case QUEST_TYPE_KILL_ALL:
461 if (!is_hostile(m_ptr)) break;
463 /* Count all hostile monsters */
464 for (i2 = 0; i2 < cur_wid; ++i2)
465 for (j2 = 0; j2 < cur_hgt; j2++)
466 if (cave[j2][i2].m_idx > 0)
467 if (is_hostile(&m_list[cave[j2][i2].m_idx]))
470 if ((number_mon - 1) == 0)
472 if (record_fix_quest) do_cmd_write_nikki(NIKKI_FIX_QUEST_C, i, NULL);
474 if (quest[i].flags & QUEST_FLAG_SILENT)
476 quest[i].status = QUEST_STATUS_FINISHED;
480 quest[i].status = QUEST_STATUS_COMPLETED;
481 quest[i].complev = (byte)p_ptr->lev;
483 msg_print("¥¯¥¨¥¹¥È¤òãÀ®¤·¤¿¡ª");
485 msg_print("You just completed your quest!");
493 case QUEST_TYPE_KILL_LEVEL:
494 case QUEST_TYPE_RANDOM:
496 /* Only count valid monsters */
497 if (quest[i].r_idx != m_ptr->r_idx)
502 if (quest[i].cur_num >= quest[i].max_num)
504 if (record_fix_quest && (quest[i].type == QUEST_TYPE_KILL_LEVEL)) do_cmd_write_nikki(NIKKI_FIX_QUEST_C, i, NULL);
505 if (record_rand_quest && (quest[i].type == QUEST_TYPE_RANDOM)) do_cmd_write_nikki(NIKKI_RAND_QUEST_C, i, NULL);
506 /* completed quest */
507 quest[i].status = QUEST_STATUS_COMPLETED;
508 quest[i].complev = (byte)p_ptr->lev;
509 if (!(quest[i].flags & QUEST_FLAG_PRESET))
511 create_stairs = TRUE;
512 p_ptr->inside_quest = 0;
515 if (!(quest[i].flags & QUEST_FLAG_SILENT))
518 msg_print("¥¯¥¨¥¹¥È¤òãÀ®¤·¤¿¡ª");
520 msg_print("You just completed your quest!");
526 /* Finish the two main quests without rewarding */
527 if ((i == QUEST_OBERON) || (i == QUEST_SERPENT))
529 quest[i].status = QUEST_STATUS_FINISHED;
532 if (quest[i].type == QUEST_TYPE_RANDOM)
535 quest[i].status = QUEST_STATUS_FINISHED;
540 case QUEST_TYPE_KILL_ANY_LEVEL:
543 if (quest[i].cur_num >= quest[i].max_num)
545 if (record_fix_quest) do_cmd_write_nikki(NIKKI_FIX_QUEST_C, i, NULL);
546 /* completed quest */
547 quest[i].status = QUEST_STATUS_COMPLETED;
548 quest[i].complev = (byte)p_ptr->lev;
550 if (!(quest[i].flags & QUEST_FLAG_SILENT))
553 msg_print("¥¯¥¨¥¹¥È¤òãÀ®¤·¤¿¡ª");
555 msg_print("You just completed your quest!");
560 quest[i].cur_num = 0;
567 /* Create a magical staircase */
571 while (cave_perma_bold(y, x) || cave[y][x].o_idx || (cave[y][x].info & CAVE_OBJECT) )
573 /* Pick a location */
574 scatter(&ny, &nx, y, x, 1, 0);
580 /* Explain the staircase */
582 msg_print("ËâË¡¤Î³¬Ãʤ¬¸½¤ì¤¿...");
584 msg_print("A magical staircase appears...");
588 /* Create stairs down */
589 cave_set_feat(y, x, FEAT_MORE);
591 /* Remember to update everything */
592 p_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MONSTERS | PU_MON_LITE);
600 for (j = 0; j < (dun_level / 15)+1; j++)
602 /* Get local object */
605 /* Wipe the object */
608 /* Make a great object */
609 make_object(q_ptr, AM_GOOD | AM_GREAT);
611 /* Drop it in the dungeon */
612 (void)drop_near(q_ptr, -1, y, x);
619 * Return monster death string
621 cptr extract_note_dies(monster_race *r_ptr)
623 /* Some monsters get "destroyed" */
624 if (!monster_living(r_ptr))
628 for (i = 0; i < 4; i++)
630 if (r_ptr->blow[i].method == RBM_EXPLODE)
633 return "¤ÏÇúȯ¤·¤ÆÊ´¡¹¤Ë¤Ê¤Ã¤¿¡£";
635 return " explodes into tiny shreds.";
643 return " is destroyed.";
647 /* Assume a default death */
657 * Handle the "death" of a monster.
659 * Disperse treasures centered at the monster location based on the
660 * various flags contained in the monster flags fields.
662 * Check for "Quest" completion when a quest monster is killed.
664 * Note that only the player can induce "monster_death()" on Uniques.
665 * Thus (for now) all Quest monsters should be Uniques.
667 * Note that monsters can now carry objects, and when a monster dies,
668 * it drops all of its objects, which may disappear in crowded rooms.
670 void monster_death(int m_idx, bool drop_item)
679 monster_type *m_ptr = &m_list[m_idx];
681 monster_race *r_ptr = &r_info[m_ptr->r_idx];
683 bool visible = (m_ptr->ml || (r_ptr->flags1 & RF1_UNIQUE));
687 bool do_gold = (!(r_ptr->flags1 & RF1_ONLY_ITEM));
688 bool do_item = (!(r_ptr->flags1 & RF1_ONLY_GOLD));
690 int force_coin = get_coin_type(m_ptr->r_idx);
695 bool drop_chosen_item = drop_item && !cloned && !p_ptr->inside_arena
696 && !p_ptr->inside_battle && !is_pet(m_ptr);
699 if (world_monster) world_monster = FALSE;
701 /* Notice changes in view */
702 if (r_ptr->flags7 & (RF7_LITE_MASK | RF7_DARK_MASK))
704 /* Update some things */
705 p_ptr->update |= (PU_MON_LITE);
708 /* Get the location */
712 if (m_ptr->smart & SM_CLONED)
715 if (record_named_pet && is_pet(m_ptr) && m_ptr->nickname)
719 monster_desc(m_name, m_ptr, MD_INDEF_VISIBLE);
720 do_cmd_write_nikki(NIKKI_NAMED_PET, 3, m_name);
723 /* Let monsters explode! */
724 for (i = 0; i < 4; i++)
726 if (r_ptr->blow[i].method == RBM_EXPLODE)
728 int flg = PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL;
729 int typ = mbe_info[r_ptr->blow[i].effect].explode_type;
730 int d_dice = r_ptr->blow[i].d_dice;
731 int d_side = r_ptr->blow[i].d_side;
732 int damage = damroll(d_dice, d_side);
734 project(m_idx, 3, y, x, damage, typ, flg, -1);
739 if (m_ptr->mflag2 & MFLAG2_CHAMELEON)
741 choose_new_monster(m_idx, TRUE, MON_CHAMELEON);
742 r_ptr = &r_info[m_ptr->r_idx];
745 /* Check for quest completion */
746 check_quest_completion(m_ptr);
748 /* Handle the possibility of player vanquishing arena combatant -KMW- */
749 if (p_ptr->inside_arena && !is_pet(m_ptr))
751 p_ptr->exit_bldg = TRUE;
753 if (p_ptr->arena_number > MAX_ARENA_MONS)
756 msg_print("ÁÇÀ²¤é¤·¤¤¡ª·¯¤³¤½¿¿¤Î¾¡Íø¼Ô¤À¡£");
758 msg_print("You are a Genuine Champion!");
764 msg_print("¾¡Íø¡ª¥Á¥ã¥ó¥Ô¥ª¥ó¤Ø¤ÎÆ»¤ò¿Ê¤ó¤Ç¤¤¤ë¡£");
766 msg_print("Victorious! You're on your way to becoming Champion.");
770 if (arena_info[p_ptr->arena_number].tval)
772 /* Get local object */
775 /* Prepare to make a prize */
776 object_prep(q_ptr, lookup_kind(arena_info[p_ptr->arena_number].tval, arena_info[p_ptr->arena_number].sval));
778 apply_magic(q_ptr, object_level, AM_NO_FIXED_ART);
780 /* Drop it in the dungeon */
781 (void)drop_near(q_ptr, -1, y, x);
784 if (p_ptr->arena_number > MAX_ARENA_MONS) p_ptr->arena_number++;
785 p_ptr->arena_number++;
790 /* Extract monster name */
791 monster_desc(m_name, m_ptr, MD_IGNORE_HALLU | MD_ASSUME_VISIBLE | MD_INDEF_VISIBLE);
793 do_cmd_write_nikki(NIKKI_ARENA, p_ptr->arena_number, m_name);
797 if (m_idx == p_ptr->riding)
799 if (rakuba(-1, FALSE))
802 msg_print("ÃÏÌ̤ËÍî¤È¤µ¤ì¤¿¡£");
804 msg_print("You have fallen from your riding pet.");
809 /* Drop a dead corpse? */
810 if (one_in_(r_ptr->flags1 & RF1_UNIQUE ? 1 : 4) &&
811 ((r_ptr->flags9 & RF9_DROP_CORPSE) ||
812 (r_ptr->flags9 & RF9_DROP_SKELETON)) &&
813 !(p_ptr->inside_arena || p_ptr->inside_battle || (m_ptr->smart & SM_CLONED) || ((m_ptr->r_idx == today_mon) && is_pet(m_ptr))))
815 /* Assume skeleton */
819 * We cannot drop a skeleton? Note, if we are in this check,
820 * we *know* we can drop at least a corpse or a skeleton
822 if (!(r_ptr->flags9 & RF9_DROP_SKELETON))
824 else if ((r_ptr->flags9 & RF9_DROP_CORPSE) && (r_ptr->flags1 && RF1_UNIQUE))
827 /* Else, a corpse is more likely unless we did a "lot" of damage */
828 else if (r_ptr->flags9 & RF9_DROP_CORPSE)
830 /* Lots of damage in one blow */
831 if ((0 - ((m_ptr->maxhp) / 4)) > m_ptr->hp)
833 if (one_in_(5)) corpse = TRUE;
837 if (!one_in_(5)) corpse = TRUE;
841 /* Get local object */
844 /* Prepare to make an object */
845 object_prep(q_ptr, lookup_kind(TV_CORPSE, (corpse ? SV_CORPSE : SV_SKELETON)));
847 apply_magic(q_ptr, object_level, AM_NO_FIXED_ART);
849 q_ptr->pval = m_ptr->r_idx;
851 /* Drop it in the dungeon */
852 (void)drop_near(q_ptr, -1, y, x);
855 /* Drop objects being carried */
856 monster_drop_carried_objects(m_ptr);
858 if (r_ptr->flags1 & RF1_DROP_GOOD) mo_mode |= AM_GOOD;
859 if (r_ptr->flags1 & RF1_DROP_GREAT) mo_mode |= AM_GREAT;
861 switch (m_ptr->r_idx)
863 case MON_PINK_HORROR:
864 /* Pink horrors are replaced with 2 Blue horrors */
865 if (!(p_ptr->inside_arena || p_ptr->inside_battle))
869 for (i = 0; i < 2; i++)
872 bool pet = is_pet(m_ptr);
875 if (pet) mode |= PM_FORCE_PET;
877 if (summon_specific((pet ? -1 : m_idx), wy, wx, 100, SUMMON_BLUE_HORROR, mode))
879 if (player_can_see_bold(wy, wx))
886 msg_print("¥Ô¥ó¥¯¡¦¥Û¥é¡¼¤ÏʬÎö¤·¤¿¡ª");
888 msg_print("The Pink horror divides!");
893 case MON_BLOODLETTER:
894 /* Bloodletters of Khorne may drop a blade of chaos */
895 if (drop_chosen_item && (randint1(100) < 15))
897 /* Get local object */
900 /* Prepare to make a Blade of Chaos */
901 object_prep(q_ptr, lookup_kind(TV_SWORD, SV_BLADE_OF_CHAOS));
903 apply_magic(q_ptr, object_level, AM_NO_FIXED_ART | mo_mode);
905 /* Drop it in the dungeon */
906 (void)drop_near(q_ptr, -1, y, x);
911 if (drop_chosen_item && (dun_level > 9))
913 /* Get local object */
916 /* Wipe the object */
919 /* Activate restriction */
920 if ((dun_level > 49) && one_in_(5))
921 get_obj_num_hook = kind_is_good_book;
923 get_obj_num_hook = kind_is_book;
925 /* Prepare allocation table */
929 make_object(q_ptr, mo_mode);
931 /* Drop it in the dungeon */
932 (void)drop_near(q_ptr, -1, y, x);
938 * Mega^3-hack: killing a 'Warrior of the Dawn' is likely to
939 * spawn another in the fallen one's place!
941 if (!p_ptr->inside_arena && !p_ptr->inside_battle)
945 int wy = py, wx = px;
947 bool pet = is_pet(m_ptr);
951 scatter(&wy, &wx, py, px, 20, 0);
953 while (!(in_bounds(wy, wx) && cave_floor_bold(wy, wx)) && --attempts);
958 if (pet) mode |= PM_FORCE_PET;
960 if (summon_specific((pet ? -1 : m_idx), wy, wx, 100, SUMMON_DAWN, mode))
962 if (player_can_see_bold(wy, wx))
964 msg_print("¿·¤¿¤ÊÀï»Î¤¬¸½¤ì¤¿¡ª");
966 msg_print("A new warrior steps forth!");
976 /* One more ultra-hack: An Unmaker goes out with a big bang! */
978 int flg = PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL;
979 (void)project(m_idx, 6, y, x, 100, GF_CHAOS, flg, -1);
983 case MON_UNICORN_ORD:
986 /* Reward for "lazy" player */
987 if (p_ptr->pseikaku == SEIKAKU_NAMAKE)
991 if (!drop_chosen_item) break;
998 a_idx = ART_NAMAKE_HAMMER;
1001 a_idx = ART_NAMAKE_BOW;
1004 a_idx = ART_NAMAKE_ARMOR;
1008 while (a_info[a_idx].cur_num);
1010 if (a_info[a_idx].cur_num == 0)
1012 /* Create the artifact */
1013 create_named_art(a_idx, y, x);
1014 a_info[a_idx].cur_num = 1;
1020 if (!drop_chosen_item) break;
1022 /* Get local object */
1025 /* Mega-Hack -- Prepare to make "Grond" */
1026 object_prep(q_ptr, lookup_kind(TV_HAFTED, SV_GROND));
1028 /* Mega-Hack -- Mark this item as "Grond" */
1029 q_ptr->name1 = ART_GROND;
1031 /* Mega-Hack -- Actually create "Grond" */
1032 apply_magic(q_ptr, -1, AM_GOOD | AM_GREAT);
1034 /* Drop it in the dungeon */
1035 (void)drop_near(q_ptr, -1, y, x);
1037 /* Get local object */
1040 /* Mega-Hack -- Prepare to make "Chaos" */
1041 object_prep(q_ptr, lookup_kind(TV_CROWN, SV_CHAOS));
1043 /* Mega-Hack -- Mark this item as "Chaos" */
1044 q_ptr->name1 = ART_CHAOS;
1046 /* Mega-Hack -- Actually create "Chaos" */
1047 apply_magic(q_ptr, -1, AM_GOOD | AM_GREAT);
1049 /* Drop it in the dungeon */
1050 (void)drop_near(q_ptr, -1, y, x);
1053 case MON_B_DEATH_SWORD:
1054 if (drop_chosen_item)
1056 /* Get local object */
1059 /* Prepare to make a broken sword */
1060 object_prep(q_ptr, lookup_kind(TV_SWORD, randint1(2)));
1062 /* Drop it in the dungeon */
1063 (void)drop_near(q_ptr, -1, y, x);
1069 if (drop_chosen_item && ((m_ptr->r_idx == MON_A_GOLD) ||
1070 ((m_ptr->r_idx == MON_A_SILVER) && !((r_ptr->r_pkills + 1) % 5))))
1072 /* Get local object */
1075 /* Prepare to make a Can of Toys */
1076 object_prep(q_ptr, lookup_kind(TV_CHEST, SV_CHEST_KANDUME));
1078 apply_magic(q_ptr, object_level, AM_NO_FIXED_ART);
1080 /* Drop it in the dungeon */
1081 (void)drop_near(q_ptr, -1, y, x);
1087 int flg = PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL;
1088 (void)project(m_idx, 3, y, x, damroll(20, 10), GF_FIRE, flg, -1);
1093 if (!drop_chosen_item) break;
1095 switch (r_ptr->d_char)
1100 /* Get local object */
1103 /* Wipe the object */
1106 /* Activate restriction */
1107 get_obj_num_hook = kind_is_cloak;
1109 /* Prepare allocation table */
1113 make_object(q_ptr, mo_mode);
1115 /* Drop it in the dungeon */
1116 (void)drop_near(q_ptr, -1, y, x);
1123 /* Get local object */
1126 /* Wipe the object */
1129 /* Activate restriction */
1130 get_obj_num_hook = kind_is_polearm;
1132 /* Prepare allocation table */
1135 /* Make a poleweapon */
1136 make_object(q_ptr, mo_mode);
1138 /* Drop it in the dungeon */
1139 (void)drop_near(q_ptr, -1, y, x);
1146 /* Get local object */
1149 /* Wipe the object */
1152 /* Activate restriction */
1153 get_obj_num_hook = kind_is_armor;
1155 /* Prepare allocation table */
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);
1167 if (m_ptr->r_idx != MON_STORMBRINGER)
1169 /* Get local object */
1172 /* Wipe the object */
1175 /* Activate restriction */
1176 get_obj_num_hook = kind_is_sword;
1178 /* Prepare allocation table */
1182 make_object(q_ptr, mo_mode);
1184 /* Drop it in the dungeon */
1185 (void)drop_near(q_ptr, -1, y, x);
1192 /* Mega-Hack -- drop fixed items */
1193 if (drop_chosen_item)
1198 switch (m_ptr->r_idx)
1218 case MON_STORMBRINGER:
1219 a_idx = ART_STORMBRINGER;
1224 a_idx = ART_CRIMSON;
1234 a_idx = ART_KUSANAGI;
1264 a_idx = ART_WEREWINDLE;
1272 a_idx = ART_GRAYSWANDIR;
1283 a_idx = ART_TWILIGHT;
1288 a_idx = ART_ELENDIL;
1303 a_idx = ART_DESTINY;
1308 a_idx = ART_ZANTETSU;
1323 a_idx = ART_WINBLOWS;
1327 case MON_LUNGORTHIN:
1332 case MON_JACK_SHADOWS:
1338 a_idx = ART_STONEMASK;
1343 a_idx = ART_SOULCRUSH;
1348 a_idx = ART_EXCALIBUR_J;
1353 a_idx = ART_SHUTEN_DOJI;
1358 a_idx = ART_GOTHMOG;
1368 if ((a_idx > 0) && ((randint0(100) < chance) || p_ptr->wizard))
1370 if (a_info[a_idx].cur_num == 0)
1372 /* Create the artifact */
1373 create_named_art(a_idx, y, x);
1374 a_info[a_idx].cur_num = 1;
1378 if ((r_ptr->flags7 & RF7_GUARDIAN) && (d_info[dungeon_type].final_guardian == m_ptr->r_idx))
1380 int k_idx = d_info[dungeon_type].final_object ? d_info[dungeon_type].final_object
1381 : lookup_kind(TV_SCROLL, SV_SCROLL_ACQUIREMENT);
1383 if (d_info[dungeon_type].final_artifact)
1385 int a_idx = d_info[dungeon_type].final_artifact;
1386 if (!a_info[a_idx].cur_num)
1388 /* Create the artifact */
1389 create_named_art(a_idx, y, x);
1390 a_info[a_idx].cur_num = 1;
1392 /* Prevent rewarding both artifact and "default" object */
1393 if (!d_info[dungeon_type].final_object) k_idx = 0;
1399 /* Get local object */
1402 /* Prepare to make a reward */
1403 object_prep(q_ptr, k_idx);
1405 apply_magic(q_ptr, object_level, AM_NO_FIXED_ART | AM_GOOD);
1407 /* Drop it in the dungeon */
1408 (void)drop_near(q_ptr, -1, y, x);
1411 msg_format("¤¢¤Ê¤¿¤Ï%s¤òÀ©ÇƤ·¤¿¡ª",d_name+d_info[dungeon_type].name);
1413 msg_format("You have conquered %s!",d_name+d_info[dungeon_type].name);
1418 /* Determine how much we can drop */
1419 if ((r_ptr->flags1 & RF1_DROP_60) && (randint0(100) < 60)) number++;
1420 if ((r_ptr->flags1 & RF1_DROP_90) && (randint0(100) < 90)) number++;
1421 if (r_ptr->flags1 & RF1_DROP_1D2) number += damroll(1, 2);
1422 if (r_ptr->flags1 & RF1_DROP_2D2) number += damroll(2, 2);
1423 if (r_ptr->flags1 & RF1_DROP_3D2) number += damroll(3, 2);
1424 if (r_ptr->flags1 & RF1_DROP_4D2) number += damroll(4, 2);
1426 if (cloned && !(r_ptr->flags1 & RF1_UNIQUE))
1427 number = 0; /* Clones drop no stuff unless Cloning Pits */
1429 if (is_pet(m_ptr) || p_ptr->inside_battle || p_ptr->inside_arena)
1430 number = 0; /* Pets drop no stuff */
1431 if (!drop_item && (r_ptr->d_char != '$')) number = 0;
1433 /* Hack -- handle creeping coins */
1434 coin_type = force_coin;
1436 /* Average dungeon and monster levels */
1437 object_level = (dun_level + r_ptr->level) / 2;
1439 /* Drop some objects */
1440 for (j = 0; j < number; j++)
1442 /* Get local object */
1445 /* Wipe the object */
1449 if (do_gold && (!do_item || (randint0(100) < 50)))
1451 /* Make some gold */
1452 if (!make_gold(q_ptr)) continue;
1461 /* Make an object */
1462 if (!make_object(q_ptr, mo_mode)) continue;
1468 /* Drop it in the dungeon */
1469 (void)drop_near(q_ptr, -1, y, x);
1472 /* Reset the object level */
1473 object_level = base_level;
1475 /* Reset "coin" type */
1479 /* Take note of any dropped treasure */
1480 if (visible && (dump_item || dump_gold))
1482 /* Take notes on treasure */
1483 lore_treasure(m_idx, dump_item, dump_gold);
1486 /* Only process "Quest Monsters" */
1487 if (!(r_ptr->flags1 & RF1_QUESTOR)) return;
1488 if (p_ptr->inside_battle) return;
1491 if ((m_ptr->r_idx == MON_SERPENT) && !cloned)
1494 p_ptr->total_winner = TRUE;
1496 /* Redraw the "title" */
1497 p_ptr->redraw |= (PR_TITLE);
1500 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, "¸«»ö¤ËÊѶòÈÚÅܤξ¡Íø¼Ô¤È¤Ê¤Ã¤¿¡ª");
1502 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, "become *WINNER* of Hengband finely!");
1505 if ((p_ptr->pclass == CLASS_CHAOS_WARRIOR) || (p_ptr->muta2 & MUT2_CHAOS_GIFT))
1508 msg_format("%s¤«¤é¤ÎÀ¼¤¬¶Á¤¤¤¿¡£", chaos_patrons[p_ptr->chaos_patron]);
1509 msg_print("¡Ø¤è¤¯¤ä¤Ã¤¿¡¢ÄêÌ¿¤Î¼Ô¤è¡ª¡Ù");
1511 msg_format("The voice of %s booms out:", chaos_patrons[p_ptr->chaos_patron]);
1512 msg_print("'Thou art donst well, mortal!'");
1516 /* Congratulations */
1518 msg_print("*** ¤ª¤á¤Ç¤È¤¦ ***");
1520 msg_print("*** CONGRATULATIONS ***");
1524 msg_print("¤¢¤Ê¤¿¤Ï¥²¡¼¥à¤ò¥³¥ó¥×¥ê¡¼¥È¤·¤Þ¤·¤¿¡£");
1526 msg_print("You have won the game!");
1530 msg_print("½àÈ÷¤¬À°¤Ã¤¿¤é°úÂà(¼«»¦¥³¥Þ¥ó¥É)¤·¤Æ¤â·ë¹½¤Ç¤¹¡£");
1532 msg_print("You may retire (commit suicide) when you are ready.");
1538 * Modify the physical damage done to the monster.
1539 * (for example when it's invulnerable or shielded)
1541 * ToDo: Accept a damage-type to calculate the modified damage from
1542 * things like fire, frost, lightning, poison, ... attacks.
1544 * "type" is not yet used and should be 0.
1546 int mon_damage_mod(monster_type *m_ptr, int dam, bool is_psy_spear)
1548 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1550 if ((r_ptr->flagsr & RFR_RES_ALL) && dam > 0)
1553 if((dam == 0) && one_in_(3)) dam = 1;
1556 if (m_ptr->invulner)
1560 if(!p_ptr->blind && m_ptr->ml)
1563 msg_print("¥Ð¥ê¥¢¤òÀÚ¤êÎö¤¤¤¿¡ª");
1565 msg_print("The barrier is penetrated!");
1569 else if (!one_in_(PENETRATE_INVULNERABILITY))
1577 static void get_exp_from_mon(int dam, monster_type *m_ptr)
1579 s32b div, new_exp, new_exp_frac;
1580 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1581 int monnum_penarty = 0;
1583 if (!m_ptr->r_idx) return;
1584 if (is_pet(m_ptr) || p_ptr->inside_battle) return;
1588 u32b m_exp_h, m_exp_l;
1590 if ((r_ptr->flags2 & RF2_MULTIPLY) || (m_ptr->r_idx == MON_DAWN))
1592 monnum_penarty = r_ptr->r_pkills / 400;
1593 if (monnum_penarty > 8) monnum_penarty = 8;
1595 if (r_ptr->flags1 & RF1_UNIQUE)
1597 m_exp = (long)r_ptr->mexp * r_ptr->level;
1598 div = (p_ptr->max_plv+2);
1602 m_exp = (long)r_ptr->mexp * r_ptr->level * SPEED_TO_ENERGY(m_ptr->mspeed);
1603 div = (p_ptr->max_plv+2) * SPEED_TO_ENERGY(r_ptr->speed);
1605 m_exp_h = m_exp/0x10000L;
1606 m_exp_l = m_exp%0x10000L;
1609 m_exp_h += m_exp_l / 0x10000L;
1610 m_exp_l %= 0x10000L;
1612 /* real monster maxhp have effect on EXP */
1613 if(!(r_ptr->flags1 & RF1_FORCE_MAXHP))
1615 u32b maxhp = m_ptr->max_maxhp*2;
1618 m_exp_h += m_exp_l / 0x10000L;
1619 m_exp_l %= 0x10000L;
1621 div *= r_ptr->hdice * (r_ptr->hside + 1);
1623 if (!dun_level && (!(r_ptr->flags8 & RF8_WILD_ONLY) || !(r_ptr->flags1 & RF1_UNIQUE))) div *= 5;
1624 div_h = div/0x10000L;
1625 div_l = div%0x10000L;
1626 div_h *= (m_ptr->max_maxhp*2);
1627 div_l *= (m_ptr->max_maxhp*2);
1628 div_h += div_l / 0x10000L;
1631 while (monnum_penarty)
1635 div_h += div_l / 0x10000L;
1640 m_exp_l = (0x7fffffff & (m_exp_h << 16)) | m_exp_l;
1641 m_exp_h = m_exp_h >> 15;
1642 div_l = (0x7fffffff & (div_h << 16)) | div_l;
1643 div_h = div_h >> 15;
1645 #define M_INT_GREATER63(h1,l1,h2,l2) ( (h1>h2)||( (h1==h2)&&(l1>=l2)))
1646 #define M_INT_SUB63(h1,l1, h2,l2) {h1-=h2;if(l1<l2){l1+=0x80000000;h1--;}l1-=l2;}
1647 #define M_INT_LSHIFT63(h1,l1) {h1=(h1<<1)|(l1>>30);l1=(l1<<1)&0x7fffffff;}
1648 #define M_INT_RSHIFT63(h1,l1) {l1=(l1>>1)|(h1<<30);h1>>=1;}
1649 #define M_INT_DIV63(h1,l1,h2,l2,result) \
1653 while( M_INT_GREATER63(h1,l1, h2, l2) ){M_INT_LSHIFT63(h2, l2); bit<<=1;} \
1654 for(bit>>=1; bit>=1; bit>>=1){ \
1655 M_INT_RSHIFT63(h2, l2); \
1656 if(M_INT_GREATER63(h1, l1, h2, l2)) \
1657 {result|=bit;M_INT_SUB63(h1, l1, h2, l2);} \
1661 /* Give some experience for the kill */
1662 M_INT_DIV63(m_exp_h, m_exp_l, div_h, div_l, new_exp);
1664 /* Handle fractional experience */
1665 /* multiply 0x10000L to remainder */
1666 m_exp_h = (m_exp_h<<16) | (m_exp_l>>15);
1668 M_INT_DIV63(m_exp_h, m_exp_l, div_h, div_l, new_exp_frac);
1669 new_exp_frac += p_ptr->exp_frac;
1670 /* Keep track of experience */
1671 if (new_exp_frac >= 0x10000L)
1674 p_ptr->exp_frac = (u16b)(new_exp_frac - 0x10000L);
1678 p_ptr->exp_frac = (u16b)new_exp_frac;
1681 /* Gain experience */
1689 * Decreases monsters hit points, handling monster death.
1691 * We return TRUE if the monster has been killed (and deleted).
1693 * We announce monster death (using an optional "death message"
1694 * if given, and a otherwise a generic killed/destroyed message).
1696 * Only "physical attacks" can induce the "You have slain" message.
1697 * Missile and Spell attacks will induce the "dies" message, or
1698 * various "specialized" messages. Note that "You have destroyed"
1699 * and "is destroyed" are synonyms for "You have slain" and "dies".
1701 * Hack -- unseen monsters yield "You have killed it." message.
1703 * Added fear (DGK) and check whether to print fear messages -CWS
1705 * Made name, sex, and capitalization generic -BEN-
1707 * As always, the "ghost" processing is a total hack.
1709 * Hack -- we "delay" fear messages by passing around a "fear" flag.
1711 * XXX XXX XXX Consider decreasing monster experience over time, say,
1712 * by using "(m_exp * m_lev * (m_lev)) / (p_lev * (m_lev + n_killed))"
1713 * instead of simply "(m_exp * m_lev) / (p_lev)", to make the first
1714 * monster worth more than subsequent monsters. This would also need
1715 * to induce changes in the monster recall code.
1717 bool mon_take_hit(int m_idx, int dam, bool *fear, cptr note)
1719 monster_type *m_ptr = &m_list[m_idx];
1720 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1722 monster_type exp_mon;
1724 /* Innocent until proven otherwise */
1725 bool innocent = TRUE, thief = FALSE;
1729 COPY(&exp_mon, m_ptr, monster_type);
1730 if (!(r_ptr->flags7 & RF7_KILL_EXP))
1732 expdam = (m_ptr->hp > dam) ? dam : m_ptr->hp;
1733 if (r_ptr->flags6 & RF6_HEAL) expdam = (expdam+1) * 2 / 3;
1735 get_exp_from_mon(expdam, &exp_mon);
1738 /* Redraw (later) if needed */
1739 if (p_ptr->health_who == m_idx) p_ptr->redraw |= (PR_HEALTH);
1740 if (p_ptr->riding == m_idx) p_ptr->redraw |= (PR_UHEALTH);
1745 if (r_ptr->flags7 & RF7_HAS_LD_MASK) p_ptr->update |= (PU_MON_LITE);
1747 /* Hack - Cancel any special player stealth magics. -LM- */
1748 if (p_ptr->special_defense & NINJA_S_STEALTH)
1750 set_superstealth(FALSE);
1756 /* It is dead now */
1761 if (r_info[m_ptr->r_idx].flags7 & RF7_TANUKI)
1763 /* You might have unmasked Tanuki first time */
1764 r_ptr = &r_info[m_ptr->r_idx];
1765 m_ptr->ap_r_idx = m_ptr->r_idx;
1766 if (r_ptr->r_sights < MAX_SHORT) r_ptr->r_sights++;
1769 if (m_ptr->mflag2 & MFLAG2_CHAMELEON)
1771 /* You might have unmasked Chameleon first time */
1772 r_ptr = real_r_ptr(m_ptr);
1773 if (r_ptr->r_sights < MAX_SHORT) r_ptr->r_sights++;
1776 /* When the player kills a Unique, it stays dead */
1777 if (r_ptr->flags1 & RF1_UNIQUE && !(m_ptr->smart & SM_CLONED))
1780 /* When the player kills a Nazgul, it stays dead */
1781 if (r_ptr->flags7 & RF7_UNIQUE_7) r_ptr->max_num--;
1783 /* Recall even invisible uniques or winners */
1784 if (m_ptr->ml || (r_ptr->flags1 & RF1_UNIQUE))
1786 /* Count kills this life */
1787 if ((m_ptr->mflag2 & MFLAG2_KAGE) && (r_info[MON_KAGE].r_pkills < MAX_SHORT)) r_info[MON_KAGE].r_pkills++;
1788 else if (r_ptr->r_pkills < MAX_SHORT) r_ptr->r_pkills++;
1790 /* Count kills in all lives */
1791 if ((m_ptr->mflag2 & MFLAG2_KAGE) && (r_info[MON_KAGE].r_tkills < MAX_SHORT)) r_info[MON_KAGE].r_tkills++;
1792 else if (r_ptr->r_tkills < MAX_SHORT) r_ptr->r_tkills++;
1794 /* Hack -- Auto-recall */
1795 monster_race_track(m_ptr->ap_r_idx);
1798 /* Extract monster name */
1799 monster_desc(m_name, m_ptr, MD_TRUE_NAME);
1801 /* Don't kill Amberites */
1802 if ((r_ptr->flags3 & RF3_AMBERITE) && one_in_(2))
1804 int curses = 1 + randint1(3);
1805 bool stop_ty = FALSE;
1809 msg_format("%^s¤Ï¶²¤í¤·¤¤·ì¤Î¼ö¤¤¤ò¤¢¤Ê¤¿¤Ë¤«¤±¤¿¡ª", m_name);
1811 msg_format("%^s puts a terrible blood curse on you!", m_name);
1814 curse_equipment(100, 50);
1818 stop_ty = activate_ty_curse(stop_ty, &count);
1823 if (r_ptr->flags2 & RF2_CAN_SPEAK)
1825 char line_got[1024];
1827 /* Dump a message */
1829 if (!get_rnd_line("mondeath_j.txt", m_ptr->r_idx, line_got))
1831 if (!get_rnd_line("mondeath.txt", m_ptr->r_idx, line_got))
1834 msg_format("%^s %s", m_name, line_got);
1837 if (m_ptr->r_idx == MON_SERPENT)
1839 /* Make screen dump */
1840 screen_dump = make_screen_dump();
1845 if (!(d_info[dungeon_type].flags1 & DF1_BEGINNER))
1847 if (!dun_level && !ambush_flag && !p_ptr->inside_arena)
1849 chg_virtue(V_VALOUR, -1);
1851 else if (r_ptr->level > dun_level)
1853 if (randint1(10) <= (r_ptr->level - dun_level))
1854 chg_virtue(V_VALOUR, 1);
1856 if (r_ptr->level > 60)
1858 chg_virtue(V_VALOUR, 1);
1860 if (r_ptr->level >= 2 * (p_ptr->lev+1))
1861 chg_virtue(V_VALOUR, 2);
1864 if ((r_ptr->flags1 & RF1_UNIQUE) && ((r_ptr->flags3 & RF3_EVIL) ||
1865 (r_ptr->flags3 & RF3_GOOD)))
1867 chg_virtue(V_HARMONY, 2);
1869 if ((r_ptr->flags1 & RF1_UNIQUE) && (r_ptr->flags3 & RF3_GOOD))
1871 chg_virtue(V_UNLIFE, 2);
1872 chg_virtue(V_VITALITY, -2);
1875 if ((r_ptr->flags1 & RF1_UNIQUE) && one_in_(3))
1876 chg_virtue(V_INDIVIDUALISM, -1);
1878 if (m_ptr->r_idx == MON_BEGGAR || m_ptr->r_idx == MON_LEPER)
1880 chg_virtue(V_COMPASSION, -1);
1883 if ((r_ptr->flags3 & RF3_GOOD) &&
1884 ((r_ptr->level) / 10 + (3 * dun_level) >= randint1(100)))
1886 chg_virtue(V_UNLIFE, 1);
1888 if (r_ptr->d_char == 'A')
1890 if (r_ptr->flags1 & RF1_UNIQUE)
1891 chg_virtue(V_FAITH, -2);
1892 else if ((r_ptr->level) / 10 + (3 * dun_level) >= randint1(100))
1894 if (r_ptr->flags3 & RF3_GOOD) chg_virtue(V_FAITH, -1);
1895 else chg_virtue(V_FAITH, 1);
1898 else if (r_ptr->flags3 & RF3_DEMON)
1900 if (r_ptr->flags1 & RF1_UNIQUE)
1901 chg_virtue(V_FAITH, 2);
1902 else if ((r_ptr->level) / 10 + (3 * dun_level) >= randint1(100))
1903 chg_virtue(V_FAITH, 1);
1906 if ((r_ptr->flags3 & RF3_UNDEAD) && (r_ptr->flags1 & RF1_UNIQUE))
1907 chg_virtue(V_VITALITY, 2);
1909 if (r_ptr->r_deaths)
1911 if (r_ptr->flags1 & RF1_UNIQUE)
1913 chg_virtue(V_HONOUR, 10);
1915 else if ((r_ptr->level) / 10 + (2 * dun_level) >= randint1(100))
1917 chg_virtue(V_HONOUR, 1);
1920 if ((r_ptr->flags2 & RF2_MULTIPLY) && (r_ptr->r_pkills > 1000) && one_in_(10))
1922 chg_virtue(V_VALOUR, -1);
1925 for (i = 0; i < 4; i++)
1927 if(r_ptr->blow[i].d_dice != 0) innocent = FALSE; /* Murderer! */
1929 if ((r_ptr->blow[i].effect == RBE_EAT_ITEM)
1930 || (r_ptr->blow[i].effect == RBE_EAT_GOLD))
1932 thief = TRUE; /* Thief! */
1935 /* The new law says it is illegal to live in the dungeon */
1936 if (r_ptr->level != 0) innocent = FALSE;
1940 if (r_ptr->flags1 & RF1_UNIQUE)
1941 chg_virtue(V_JUSTICE, 3);
1942 else if (1+((r_ptr->level) / 10 + (2 * dun_level))
1945 chg_virtue(V_JUSTICE, 1);
1949 chg_virtue (V_JUSTICE, -1);
1952 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)))
1954 if (one_in_(4)) chg_virtue(V_NATURE, -1);
1957 if ((r_ptr->flags1 & RF1_UNIQUE) && record_destroy_uniq)
1961 sprintf(m_name, "%s%s", r_name + r_ptr->name, (m_ptr->smart & SM_CLONED) ? "(¥¯¥í¡¼¥ó)" : "");
1963 sprintf(m_name, "%s%s", r_name + r_ptr->name, (m_ptr->smart & SM_CLONED) ? "(Clone)" : "");
1965 do_cmd_write_nikki(NIKKI_UNIQUE, 0, m_name);
1971 /* Death by Missile/Spell attack */
1974 msg_format("%^s%s", m_name, note);
1977 /* Death by physical attack -- invisible monster */
1978 else if (!m_ptr->ml)
1981 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
1982 msg_format("¤»¤Ã¤«¤¯¤À¤«¤é%s¤ò»¦¤·¤¿¡£", m_name);
1984 msg_format("%s¤ò»¦¤·¤¿¡£", m_name);
1986 msg_format("You have killed %s.", m_name);
1991 /* Death by Physical attack -- non-living monster */
1992 else if (!monster_living(r_ptr))
1995 bool explode = FALSE;
1997 for (i = 0; i < 4; i++)
1999 if (r_ptr->blow[i].method == RBM_EXPLODE) explode = TRUE;
2002 /* Special note at death */
2005 msg_format("%s¤ÏÇúȯ¤·¤ÆÊ´¡¹¤Ë¤Ê¤Ã¤¿¡£", m_name);
2007 msg_format("%s explodes into tiny shreds.", m_name);
2012 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
2013 msg_format("¤»¤Ã¤«¤¯¤À¤«¤é%s¤òÅݤ·¤¿¡£", m_name);
2015 msg_format("%s¤òÅݤ·¤¿¡£", m_name);
2017 msg_format("You have destroyed %s.", m_name);
2022 /* Death by Physical attack -- living monster */
2026 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
2027 msg_format("¤»¤Ã¤«¤¯¤À¤«¤é%s¤òÁò¤êµî¤Ã¤¿¡£", m_name);
2029 msg_format("%s¤òÁò¤êµî¤Ã¤¿¡£", m_name);
2031 msg_format("You have slain %s.", m_name);
2035 if (r_ptr->flags1 & RF1_UNIQUE && !(m_ptr->smart & SM_CLONED))
2037 for (i = 0; i < MAX_KUBI; i++)
2039 if ((kubi_r_idx[i] == m_ptr->r_idx) && !(m_ptr->mflag2 & MFLAG2_CHAMELEON))
2042 msg_format("%s¤Î¼ó¤Ë¤Ï¾Þ¶â¤¬¤«¤«¤Ã¤Æ¤¤¤ë¡£", m_name);
2044 msg_format("There is a price on %s's head.", m_name);
2051 /* Generate treasure */
2052 monster_death(m_idx, TRUE);
2053 if ((m_ptr->r_idx == MON_BANOR) || (m_ptr->r_idx == MON_LUPART))
2055 r_info[MON_BANORLUPART].max_num = 0;
2056 r_info[MON_BANORLUPART].r_pkills++;
2057 if (r_info[MON_BANORLUPART].r_tkills < MAX_SHORT) r_info[MON_BANORLUPART].r_tkills++;
2060 if (m_ptr->r_idx == MON_BANORLUPART)
2062 r_info[MON_BANOR].max_num = 0;
2063 r_info[MON_BANOR].r_pkills++;
2064 if (r_info[MON_BANOR].r_tkills < MAX_SHORT) r_info[MON_BANOR].r_tkills++;
2065 r_info[MON_LUPART].max_num = 0;
2066 r_info[MON_LUPART].r_pkills++;
2067 if (r_info[MON_LUPART].r_tkills < MAX_SHORT) r_info[MON_LUPART].r_tkills++;
2070 /* Mega hack : replace IKETA to BIKETAL */
2071 if ((m_ptr->r_idx == MON_IKETA) &&
2072 !(p_ptr->inside_arena || p_ptr->inside_battle))
2074 int dummy_y = m_ptr->fy;
2075 int dummy_x = m_ptr->fx;
2078 if (is_pet(m_ptr)) mode |= PM_FORCE_PET;
2080 /* Delete the monster */
2081 delete_monster_idx(m_idx);
2083 if (summon_named_creature(0, dummy_y, dummy_x, MON_BIKETAL, mode))
2086 msg_print("¡Ö¥Ï¥¡¥Ã¥Ï¥Ã¥Ï¥Ã¥Ï¡ª¡ª»ä¤¬¥Ð¥¤¥±¥¿¥ë¤À¡ª¡ª¡×");
2088 msg_print("Uwa-hahaha! *I* am Biketal!");
2094 /* Delete the monster */
2095 delete_monster_idx(m_idx);
2098 /* Prevent bug of chaos patron's reward */
2099 if (r_ptr->flags7 & RF7_KILL_EXP)
2100 get_exp_from_mon((long)exp_mon.max_maxhp*2, &exp_mon);
2102 get_exp_from_mon(((long)exp_mon.max_maxhp+1L) * 9L / 10L, &exp_mon);
2107 /* Monster is dead */
2114 /* Mega-Hack -- Pain cancels fear */
2115 if (m_ptr->monfear && (dam > 0))
2117 int tmp = randint1(dam);
2119 /* Cure a little fear */
2120 if (tmp < m_ptr->monfear)
2123 m_ptr->monfear -= tmp;
2126 /* Cure all the fear */
2137 /* Sometimes a monster gets scared by damage */
2138 if (!m_ptr->monfear && !(r_ptr->flags3 & (RF3_NO_FEAR)))
2142 /* Percentage of fully healthy */
2143 percentage = (100L * m_ptr->hp) / m_ptr->maxhp;
2146 * Run (sometimes) if at 10% or less of max hit points,
2147 * or (usually) when hit for half its current hit points
2149 if ((randint1(10) >= percentage) ||
2150 ((dam >= m_ptr->hp) && (randint0(100) < 80)))
2152 /* Hack -- note fear */
2155 /* XXX XXX XXX Hack -- Add some timed fear */
2156 m_ptr->monfear = (randint1(10) +
2157 (((dam >= m_ptr->hp) && (percentage > 7)) ?
2158 20 : ((11 - percentage) * 5)));
2165 if (p_ptr->riding && (p_ptr->riding == m_idx) && (dam > 0))
2169 /* Extract monster name */
2170 monster_desc(m_name, m_ptr, 0);
2172 if (m_ptr->hp > m_ptr->maxhp/3) dam = (dam + 1) / 2;
2173 if (rakuba((dam > 200) ? 200 : dam, FALSE))
2176 msg_format("%^s¤Ë¿¶¤êÍî¤È¤µ¤ì¤¿¡ª", m_name);
2178 msg_format("%^s has thrown you off!", m_name);
2190 * Get term size and calculate screen size
2192 void get_screen_size(int *wid_p, int *hgt_p)
2194 Term_get_size(wid_p, hgt_p);
2195 *hgt_p -= ROW_MAP + 2;
2196 *wid_p -= COL_MAP + 2;
2197 if (use_bigtile) *wid_p /= 2;
2202 * Calculates current boundaries
2203 * Called below and from "do_cmd_locate()".
2205 void panel_bounds_center(void)
2210 get_screen_size(&wid, &hgt);
2212 panel_row_max = panel_row_min + hgt - 1;
2213 panel_row_prt = panel_row_min - 1;
2214 panel_col_max = panel_col_min + wid - 1;
2215 panel_col_prt = panel_col_min - 13;
2220 * Map resizing whenever the main term changes size
2222 void resize_map(void)
2224 /* Only if the dungeon exists */
2225 if (!character_dungeon) return;
2227 /* Mega-Hack -- no panel yet */
2231 /* Reset the panels */
2232 panel_row_min = cur_hgt;
2233 panel_col_min = cur_wid;
2238 p_ptr->update |= (PU_TORCH | PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
2240 /* Forget lite/view */
2241 p_ptr->update |= (PU_UN_VIEW | PU_UN_LITE);
2243 /* Update lite/view */
2244 p_ptr->update |= (PU_VIEW | PU_LITE | PU_MON_LITE);
2246 /* Update monsters */
2247 p_ptr->update |= (PU_MONSTERS);
2249 /* Redraw everything */
2250 p_ptr->redraw |= (PR_WIPE | PR_BASIC | PR_EXTRA | PR_MAP | PR_EQUIPPY);
2252 /* Hack -- update */
2260 * Place the cursor on the player
2262 if (can_save) move_cursor_relative(py, px);
2269 * Redraw a term when it is resized
2271 void redraw_window(void)
2273 /* Only if the dungeon exists */
2274 if (!character_dungeon) return;
2276 /* Hack - Activate term zero for the redraw */
2277 Term_activate(&term_screen[0]);
2279 /* Hack -- react to changes */
2280 Term_xtra(TERM_XTRA_REACT, 0);
2283 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_SPELL | PW_PLAYER);
2286 p_ptr->window |= (PW_MESSAGE | PW_OVERHEAD | PW_DUNGEON | PW_MONSTER | PW_OBJECT);
2288 /* Hack -- update */
2300 * Handle a request to change the current panel
2302 * Return TRUE if the panel was changed.
2304 * Also used in do_cmd_locate
2306 bool change_panel(int dy, int dx)
2312 get_screen_size(&wid, &hgt);
2314 /* Apply the motion */
2315 y = panel_row_min + dy * hgt / 2;
2316 x = panel_col_min + dx * wid / 2;
2318 /* Verify the row */
2319 if (y > cur_hgt - hgt) y = cur_hgt - hgt;
2322 /* Verify the col */
2323 if (x > cur_wid - wid) x = cur_wid - wid;
2326 /* Handle "changes" */
2327 if ((y != panel_row_min) || (x != panel_col_min))
2329 /* Save the new panel info */
2333 /* Recalculate the boundaries */
2334 panel_bounds_center();
2337 p_ptr->update |= (PU_MONSTERS);
2340 p_ptr->redraw |= (PR_MAP);
2355 * Given an row (y) and col (x), this routine detects when a move
2356 * off the screen has occurred and figures new borders. -RAK-
2358 * "Update" forces a "full update" to take place.
2360 * The map is reprinted if necessary, and "TRUE" is returned.
2362 void verify_panel(void)
2374 get_screen_size(&wid, &hgt);
2376 max_prow_min = cur_hgt - hgt;
2377 max_pcol_min = cur_wid - wid;
2379 /* Bounds checking */
2380 if (max_prow_min < 0) max_prow_min = 0;
2381 if (max_pcol_min < 0) max_pcol_min = 0;
2383 /* Center on player */
2384 if (center_player && (center_running || !running))
2386 /* Center vertically */
2387 prow_min = y - hgt / 2;
2388 if (prow_min < 0) prow_min = 0;
2389 else if (prow_min > max_prow_min) prow_min = max_prow_min;
2391 /* Center horizontally */
2392 pcol_min = x - wid / 2;
2393 if (pcol_min < 0) pcol_min = 0;
2394 else if (pcol_min > max_pcol_min) pcol_min = max_pcol_min;
2398 prow_min = panel_row_min;
2399 pcol_min = panel_col_min;
2401 /* Scroll screen when 2 grids from top/bottom edge */
2402 if (y > panel_row_max - 2)
2404 while (y > prow_min + hgt-1 - 2)
2406 prow_min += (hgt / 2);
2410 if (y < panel_row_min + 2)
2412 while (y < prow_min + 2)
2414 prow_min -= (hgt / 2);
2418 if (prow_min > max_prow_min) prow_min = max_prow_min;
2419 if (prow_min < 0) prow_min = 0;
2421 /* Scroll screen when 4 grids from left/right edge */
2422 if (x > panel_col_max - 4)
2424 while (x > pcol_min + wid-1 - 4)
2426 pcol_min += (wid / 2);
2430 if (x < panel_col_min + 4)
2432 while (x < pcol_min + 4)
2434 pcol_min -= (wid / 2);
2438 if (pcol_min > max_pcol_min) pcol_min = max_pcol_min;
2439 if (pcol_min < 0) pcol_min = 0;
2442 /* Check for "no change" */
2443 if ((prow_min == panel_row_min) && (pcol_min == panel_col_min)) return;
2445 /* Save the new panel info */
2446 panel_row_min = prow_min;
2447 panel_col_min = pcol_min;
2449 /* Hack -- optional disturb on "panel change" */
2450 if (disturb_panel && !center_player) disturb(0, 0);
2452 /* Recalculate the boundaries */
2453 panel_bounds_center();
2456 p_ptr->update |= (PU_MONSTERS);
2459 p_ptr->redraw |= (PR_MAP);
2462 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
2467 * Monster health description
2469 cptr look_mon_desc(monster_type *m_ptr, u32b mode)
2471 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
2478 /* Determine if the monster is "living" */
2479 living = monster_living(ap_r_ptr);
2481 /* Calculate a health "percentage" */
2482 perc = 100L * m_ptr->hp / m_ptr->maxhp;
2484 /* Healthy monsters */
2485 if (m_ptr->hp >= m_ptr->maxhp)
2489 desc = living ? "̵½ý" : "̵¥À¥á¡¼¥¸";
2491 desc = living ? "unhurt" : "undamaged";
2496 else if (perc >= 60)
2499 desc = living ? "·Ú½ý" : "¾®¥À¥á¡¼¥¸";
2501 desc = living ? "somewhat wounded" : "somewhat damaged";
2506 else if (perc >= 25)
2509 desc = living ? "Éé½ý" : "Ãæ¥À¥á¡¼¥¸";
2511 desc = living ? "wounded" : "damaged";
2516 else if (perc >= 10)
2519 desc = living ? "½Å½ý" : "Âç¥À¥á¡¼¥¸";
2521 desc = living ? "badly wounded" : "badly damaged";
2529 desc = living ? "Ⱦ»àȾÀ¸" : "Åݤ줫¤±";
2531 desc = living ? "almost dead" : "almost destroyed";
2536 /* Need attitude information? */
2539 /* Full information is not needed */
2542 else if (is_pet(m_ptr))
2545 attitude = ", ¥Ú¥Ã¥È";
2550 else if (is_friendly(m_ptr))
2553 attitude = ", ͧ¹¥Åª";
2555 attitude = ", friendly";
2568 /* Clone monster? */
2569 if (m_ptr->smart & SM_CLONED)
2578 /* Display monster's level --- idea borrowed from ToME */
2579 if (ap_r_ptr->r_tkills && !(m_ptr->mflag2 & MFLAG2_KAGE))
2582 return format("¥ì¥Ù¥ë%d, %s%s%s", ap_r_ptr->level, desc, attitude, clone);
2584 return format("Level %d, %s%s%s", ap_r_ptr->level, desc, attitude, clone);
2590 return format("¥ì¥Ù¥ë???, %s%s%s", desc, attitude, clone);
2592 return format("Level ???, %s%s%s", desc, attitude, clone);
2600 * Angband sorting algorithm -- quick sort in place
2602 * Note that the details of the data we are sorting is hidden,
2603 * and we rely on the "ang_sort_comp()" and "ang_sort_swap()"
2604 * function hooks to interact with the data, which is given as
2605 * two pointers, and which may have any user-defined form.
2607 void ang_sort_aux(vptr u, vptr v, int p, int q)
2625 while (!(*ang_sort_comp)(u, v, b, z)) b--;
2628 while (!(*ang_sort_comp)(u, v, z, a)) a++;
2630 /* Done partition */
2634 (*ang_sort_swap)(u, v, a, b);
2640 /* Recurse left side */
2641 ang_sort_aux(u, v, p, b);
2643 /* Recurse right side */
2644 ang_sort_aux(u, v, b+1, q);
2649 * Angband sorting algorithm -- quick sort in place
2651 * Note that the details of the data we are sorting is hidden,
2652 * and we rely on the "ang_sort_comp()" and "ang_sort_swap()"
2653 * function hooks to interact with the data, which is given as
2654 * two pointers, and which may have any user-defined form.
2656 void ang_sort(vptr u, vptr v, int n)
2658 /* Sort the array */
2659 ang_sort_aux(u, v, 0, n-1);
2664 /*** Targeting Code ***/
2668 * Determine is a monster makes a reasonable target
2670 * The concept of "targeting" was stolen from "Morgul" (?)
2672 * The player can target any location, or any "target-able" monster.
2674 * Currently, a monster is "target_able" if it is visible, and if
2675 * the player can hit it with a projection, and the player is not
2676 * hallucinating. This allows use of "use closest target" macros.
2678 * Future versions may restrict the ability to target "trappers"
2679 * and "mimics", but the semantics is a little bit weird.
2681 bool target_able(int m_idx)
2683 monster_type *m_ptr = &m_list[m_idx];
2685 /* Monster must be alive */
2686 if (!m_ptr->r_idx) return (FALSE);
2688 /* Hack -- no targeting hallucinations */
2689 if (p_ptr->image) return (FALSE);
2691 /* Monster must be visible */
2692 if (!m_ptr->ml) return (FALSE);
2694 if (p_ptr->riding && (p_ptr->riding == m_idx)) return (TRUE);
2696 /* Monster must be projectable */
2697 if (!projectable(py, px, m_ptr->fy, m_ptr->fx)) return (FALSE);
2699 /* XXX XXX XXX Hack -- Never target trappers */
2700 /* if (CLEAR_ATTR && (CLEAR_CHAR)) return (FALSE); */
2710 * Update (if necessary) and verify (if possible) the target.
2712 * We return TRUE if the target is "okay" and FALSE otherwise.
2714 bool target_okay(void)
2716 /* Accept stationary targets */
2717 if (target_who < 0) return (TRUE);
2719 /* Check moving targets */
2722 /* Accept reasonable targets */
2723 if (target_able(target_who))
2725 monster_type *m_ptr = &m_list[target_who];
2727 /* Acquire monster location */
2728 target_row = m_ptr->fy;
2729 target_col = m_ptr->fx;
2736 /* Assume no target */
2743 * Sorting hook -- comp function -- by "distance to player"
2745 * We use "u" and "v" to point to arrays of "x" and "y" positions,
2746 * and sort the arrays by double-distance to the player.
2748 static bool ang_sort_comp_distance(vptr u, vptr v, int a, int b)
2750 byte *x = (byte*)(u);
2751 byte *y = (byte*)(v);
2755 /* Absolute distance components */
2756 kx = x[a]; kx -= px; kx = ABS(kx);
2757 ky = y[a]; ky -= py; ky = ABS(ky);
2759 /* Approximate Double Distance to the first point */
2760 da = ((kx > ky) ? (kx + kx + ky) : (ky + ky + kx));
2762 /* Absolute distance components */
2763 kx = x[b]; kx -= px; kx = ABS(kx);
2764 ky = y[b]; ky -= py; ky = ABS(ky);
2766 /* Approximate Double Distance to the first point */
2767 db = ((kx > ky) ? (kx + kx + ky) : (ky + ky + kx));
2769 /* Compare the distances */
2775 * Sorting hook -- swap function -- by "distance to player"
2777 * We use "u" and "v" to point to arrays of "x" and "y" positions,
2778 * and sort the arrays by distance to the player.
2780 static void ang_sort_swap_distance(vptr u, vptr v, int a, int b)
2782 byte *x = (byte*)(u);
2783 byte *y = (byte*)(v);
2801 * Hack -- help "select" a location (see below)
2803 static s16b target_pick(int y1, int x1, int dy, int dx)
2807 int x2, y2, x3, y3, x4, y4;
2809 int b_i = -1, b_v = 9999;
2812 /* Scan the locations */
2813 for (i = 0; i < temp_n; i++)
2819 /* Directed distance */
2823 /* Verify quadrant */
2824 if (dx && (x3 * dx <= 0)) continue;
2825 if (dy && (y3 * dy <= 0)) continue;
2827 /* Absolute distance */
2831 /* Verify quadrant */
2832 if (dy && !dx && (x4 > y4)) continue;
2833 if (dx && !dy && (y4 > x4)) continue;
2835 /* Approximate Double Distance */
2836 v = ((x4 > y4) ? (x4 + x4 + y4) : (y4 + y4 + x4));
2838 /* XXX XXX XXX Penalize location */
2841 if ((b_i >= 0) && (v >= b_v)) continue;
2853 * Hack -- determine if a given location is "interesting"
2855 static bool target_set_accept(int y, int x)
2859 s16b this_o_idx, next_o_idx = 0;
2862 if (!(in_bounds(y, x))) return (FALSE);
2864 /* Player grid is always interesting */
2865 if (player_bold(y, x)) return (TRUE);
2868 /* Handle hallucination */
2869 if (p_ptr->image) return (FALSE);
2872 /* Examine the grid */
2873 c_ptr = &cave[y][x];
2875 /* Visible monsters */
2878 monster_type *m_ptr = &m_list[c_ptr->m_idx];
2880 /* Visible monsters */
2881 if (m_ptr->ml) return (TRUE);
2884 /* Scan all objects in the grid */
2885 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
2889 /* Acquire object */
2890 o_ptr = &o_list[this_o_idx];
2892 /* Acquire next object */
2893 next_o_idx = o_ptr->next_o_idx;
2895 /* Memorized object */
2896 if (o_ptr->marked) return (TRUE);
2899 /* Interesting memorized features */
2900 if (c_ptr->info & (CAVE_MARK))
2904 /* Feature code (applying "mimic" field) */
2905 feat = c_ptr->mimic ? c_ptr->mimic : f_info[c_ptr->feat].mimic;
2908 if (c_ptr->info & CAVE_OBJECT) return (TRUE);
2910 /* Notice the Pattern */
2911 if ((feat <= FEAT_PATTERN_XTRA2) &&
2912 (feat >= FEAT_PATTERN_START))
2916 if (feat == FEAT_OPEN) return (TRUE);
2917 if (feat == FEAT_BROKEN) return (TRUE);
2920 if (feat == FEAT_LESS) return (TRUE);
2921 if (feat == FEAT_MORE) return (TRUE);
2922 if (feat == FEAT_LESS_LESS) return (TRUE);
2923 if (feat == FEAT_MORE_MORE) return (TRUE);
2926 if ((feat >= FEAT_SHOP_HEAD) &&
2927 (feat <= FEAT_SHOP_TAIL)) return (TRUE);
2929 if (feat == FEAT_MUSEUM) return (TRUE);
2931 /* Notice buildings -KMW- */
2932 if ((feat >= FEAT_BLDG_HEAD) &&
2933 (feat <= FEAT_BLDG_TAIL)) return (TRUE);
2936 if (is_trap(feat)) return (TRUE);
2939 if ((feat >= FEAT_DOOR_HEAD) &&
2940 (feat <= FEAT_DOOR_TAIL)) return (TRUE);
2944 /* I think FEAT_RUBBLEs should not be "interesting" */
2945 if (feat == FEAT_RUBBLE) return (TRUE);
2947 /* Notice veins with treasure */
2948 /* Now veins with treasure are too many */
2949 if (feat == FEAT_MAGMA_K) return (TRUE);
2950 if (feat == FEAT_QUARTZ_K) return (TRUE);
2953 /* Notice quest features */
2954 if (feat == FEAT_QUEST_ENTER) return (TRUE);
2955 if (feat == FEAT_QUEST_EXIT) return (TRUE);
2956 if (feat == FEAT_QUEST_DOWN) return (TRUE);
2957 if (feat == FEAT_QUEST_UP) return (TRUE);
2958 if (feat == FEAT_TOWN) return (TRUE);
2959 if (feat == FEAT_ENTRANCE) return (TRUE);
2968 * Prepare the "temp" array for "target_set"
2970 * Return the number of target_able monsters in the set.
2972 static void target_set_prepare(int mode)
2976 /* Reset "temp" array */
2979 /* Scan the current panel */
2980 for (y = panel_row_min; y <= panel_row_max; y++)
2982 for (x = panel_col_min; x <= panel_col_max; x++)
2986 /* Require line of sight, unless "look" is "expanded" */
2987 if (!expand_look && !player_has_los_bold(y, x)) continue;
2989 /* Require "interesting" contents */
2990 if (!target_set_accept(y, x)) continue;
2992 c_ptr = &cave[y][x];
2994 /* Require target_able monsters for "TARGET_KILL" */
2995 if ((mode & (TARGET_KILL)) && !target_able(c_ptr->m_idx)) continue;
2997 if ((mode & (TARGET_KILL)) && !target_pet && is_pet(&m_list[c_ptr->m_idx])) continue;
2999 /* Save the location */
3006 /* Set the sort hooks */
3007 ang_sort_comp = ang_sort_comp_distance;
3008 ang_sort_swap = ang_sort_swap_distance;
3010 /* Sort the positions */
3011 ang_sort(temp_x, temp_y, temp_n);
3013 if (p_ptr->riding && target_pet && (temp_n > 1) && (mode & (TARGET_KILL)))
3018 temp_y[0] = temp_y[1];
3021 temp_x[0] = temp_x[1];
3028 * Evaluate number of kill needed to gain level
3030 static void evaluate_monster_exp(char *buf, monster_type *m_ptr)
3032 #define M_INT_GREATER(h1,l1,h2,l2) ( (h1>h2)||( (h1==h2)&&(l1>=l2)))
3033 #define M_INT_SUB(h1,l1, h2,l2) {h1-=h2;if(l1<l2){l1+=0x10000;h1--;}l1-=l2;}
3034 #define M_INT_ADD(h1,l1, h2,l2) {h1+=h2;l1+=l2;if(l1>=0x10000L){l1&=0xFFFF;h1++;}}
3035 #define M_INT_LSHIFT(h1,l1) {h1=(h1<<1)|(l1>>15);l1=(l1<<1)&0xffff;}
3036 #define M_INT_RSHIFT(h1,l1) {l1=(l1>>1)|((h1&1)<<15);h1>>=1;}
3037 #define M_INT_MULT(h1,l1,mul,h2,l2) {l2=(l1*mul)&0xffff;h2=((l1*mul)>>16)+h1*mul;}
3039 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
3043 u32b exp_mon= (ap_r_ptr->mexp)*(ap_r_ptr->level);
3044 u32b exp_mon_h= exp_mon / (p_ptr->max_plv+2);
3045 u32b exp_mon_l= ((exp_mon % (p_ptr->max_plv+2))*0x10000/(p_ptr->max_plv+2))&0xFFFF;
3047 u32b exp_adv_h = player_exp[p_ptr->lev -1] * p_ptr->expfact /100;
3048 u32b exp_adv_l = ((player_exp[p_ptr->lev -1]%100) * p_ptr->expfact *0x10000/100)&0xFFFF;
3050 M_INT_SUB(exp_adv_h, exp_adv_l, p_ptr->exp, p_ptr->exp_frac);
3051 if ((p_ptr->lev>=PY_MAX_LEVEL) || (p_ptr->prace == RACE_ANDROID))
3053 else if (!ap_r_ptr->r_tkills || (m_ptr->mflag2 & MFLAG2_KAGE))
3055 else if (M_INT_GREATER(exp_mon_h, exp_mon_l, exp_adv_h, exp_adv_l))
3059 M_INT_MULT(exp_mon_h, exp_mon_l, 1000,tmp_h, tmp_l);
3060 if( M_INT_GREATER(exp_adv_h, exp_adv_l, tmp_h, tmp_l) )
3065 M_INT_ADD(exp_adv_h, exp_adv_l, exp_mon_h, exp_mon_l);
3066 M_INT_SUB(exp_adv_h, exp_adv_l, 0, 1);
3067 while(M_INT_GREATER(exp_adv_h, exp_adv_l, exp_mon_h,exp_mon_l))
3069 M_INT_LSHIFT(exp_mon_h,exp_mon_l);
3072 M_INT_RSHIFT(exp_mon_h,exp_mon_l);bit>>=1;
3073 for(;bit>=1;bit>>=1)
3075 if(M_INT_GREATER(exp_adv_h,exp_adv_l,exp_mon_h,exp_mon_l))
3078 M_INT_SUB(exp_adv_h,exp_adv_l,exp_mon_h,exp_mon_l);
3080 M_INT_RSHIFT(exp_mon_h,exp_mon_l);
3082 sprintf(buf,"%03d",result);
3089 * Examine a grid, return a keypress.
3091 * The "mode" argument contains the "TARGET_LOOK" bit flag, which
3092 * indicates that the "space" key should scan through the contents
3093 * of the grid, instead of simply returning immediately. This lets
3094 * the "look" command get complete information, without making the
3095 * "target" command annoying.
3097 * The "info" argument contains the "commands" which should be shown
3098 * inside the "[xxx]" text. This string must never be empty, or grids
3099 * containing monsters will be displayed with an extra comma.
3101 * Note that if a monster is in the grid, we update both the monster
3102 * recall info and the health bar info to track that monster.
3104 * Eventually, we may allow multiple objects per grid, or objects
3105 * and terrain features in the same grid. XXX XXX XXX
3107 * This function must handle blindness/hallucination.
3109 static int target_set_aux(int y, int x, int mode, cptr info)
3111 cave_type *c_ptr = &cave[y][x];
3112 s16b this_o_idx, next_o_idx = 0;
3113 cptr s1 = "", s2 = "", s3 = "", x_info = "";
3117 char out_val[MAX_NLEN+80];
3119 #ifdef ALLOW_EASY_FLOOR
3120 int floor_list[23], floor_num = 0;
3122 /* Scan all objects in the grid */
3125 floor_num = scan_floor(floor_list, y, x, 0x02);
3137 #endif /* ALLOW_EASY_FLOOR */
3139 /* Hack -- under the player */
3140 if (player_bold(y, x))
3163 /* Hack -- hallucination */
3167 cptr name = "²¿¤«´ñ̯¤Êʪ";
3169 cptr name = "something strange";
3173 /* Display a message */
3175 sprintf(out_val, "%s%s%s%s [%s]", s1, name, s2, s3, info);
3177 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, name, info);
3181 move_cursor_relative(y, x);
3184 /* Stop on everything but "return" */
3185 if ((query != '\r') && (query != '\n')) return query;
3187 /* Repeat forever */
3192 /* Actual monsters */
3193 if (c_ptr->m_idx && m_list[c_ptr->m_idx].ml)
3195 monster_type *m_ptr = &m_list[c_ptr->m_idx];
3196 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
3198 bool recall = FALSE;
3203 /* Get the monster name ("a kobold") */
3204 monster_desc(m_name, m_ptr, MD_INDEF_VISIBLE);
3206 /* Hack -- track this monster race */
3207 monster_race_track(m_ptr->ap_r_idx);
3209 /* Hack -- health bar for this monster */
3210 health_track(c_ptr->m_idx);
3212 /* Hack -- handle stuff */
3226 /* Recall on screen */
3227 screen_roff(m_ptr->ap_r_idx, 0);
3229 /* Hack -- Complete the prompt (again) */
3231 Term_addstr(-1, TERM_WHITE, format(" [r»× %s%s]", x_info, info));
3233 Term_addstr(-1, TERM_WHITE, format(" [r,%s%s]", x_info, info));
3242 /* Normal commands */
3243 if (query != 'r') break;
3248 /* Cleare recall text and repeat */
3254 /* Describe, and prompt for recall */
3255 evaluate_monster_exp(acount, m_ptr);
3258 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);
3260 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);
3266 move_cursor_relative(y, x);
3271 /* Normal commands */
3272 if (query != 'r') break;
3278 /* Always stop at "normal" keys */
3279 if ((query != '\r') && (query != '\n') && (query != ' ') && (query != 'x')) return query;
3281 /* Sometimes stop at "space" key */
3282 if ((query == ' ') && !(mode & (TARGET_LOOK))) return query;
3284 /* Change the intro */
3292 /* Hack -- take account of gender */
3294 if (ap_r_ptr->flags1 & (RF1_FEMALE)) s1 = "Èà½÷¤Ï";
3296 if (ap_r_ptr->flags1 & (RF1_FEMALE)) s1 = "She is ";
3300 else if (ap_r_ptr->flags1 & (RF1_MALE)) s1 = "Èà¤Ï";
3302 else if (ap_r_ptr->flags1 & (RF1_MALE)) s1 = "He is ";
3306 /* Use a preposition */
3315 /* Scan all objects being carried */
3316 for (this_o_idx = m_ptr->hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
3318 char o_name[MAX_NLEN];
3322 /* Acquire object */
3323 o_ptr = &o_list[this_o_idx];
3325 /* Acquire next object */
3326 next_o_idx = o_ptr->next_o_idx;
3328 /* Obtain an object description */
3329 object_desc(o_name, o_ptr, TRUE, 3);
3331 /* Describe the object */
3333 sprintf(out_val, "%s%s%s%s[%s]", s1, o_name, s2, s3, info);
3335 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, o_name, info);
3339 move_cursor_relative(y, x);
3342 /* Always stop at "normal" keys */
3343 if ((query != '\r') && (query != '\n') && (query != ' ') && (query != 'x')) return query;
3345 /* Sometimes stop at "space" key */
3346 if ((query == ' ') && !(mode & (TARGET_LOOK))) return query;
3348 /* Change the intro */
3352 s2 = "also carrying ";
3356 /* Use a preposition */
3366 #ifdef ALLOW_EASY_FLOOR
3375 char o_name[MAX_NLEN];
3379 /* Acquire object */
3380 o_ptr = &o_list[floor_list[0]];
3382 /* Describe the object */
3383 object_desc(o_name, o_ptr, TRUE, 3);
3387 sprintf(out_val, "%s%s%s%s[%s]",
3388 s1, o_name, s2, s3, info);
3390 sprintf(out_val, "%s%s%s%s [%s]",
3391 s1, s2, s3, o_name, info);
3395 move_cursor_relative(y, x);
3404 /* Provide one cushion before item listing */
3407 /* Display rough information about items */
3409 sprintf(out_val, "%s %d¸Ä¤Î¥¢¥¤¥Æ¥à%s%s ['x'¤Ç°ìÍ÷, %s]",
3410 s1, floor_num, s2, s3, info);
3412 sprintf(out_val, "%s%s%sa pile of %d items [x,%s]",
3413 s1, s2, s3, floor_num, info);
3417 move_cursor_relative(y, x);
3422 /* No request for listing */
3423 if (query != 'x' && query != ' ') return query;
3427 /** Display list of items **/
3429 /* Continue scrolling list if requested */
3438 (void)show_floor(0, y, x, &min_width);
3442 sprintf(out_val, "%s %d¸Ä¤Î¥¢¥¤¥Æ¥à%s%s [Enter¤Ç¼¡¤Ø, %s]",
3443 s1, floor_num, s2, s3, info);
3445 sprintf(out_val, "%s%s%sa pile of %d items [Enter,%s]",
3446 s1, s2, s3, floor_num, info);
3457 /* Exit unless 'Enter' */
3458 if (query != '\n' && query != '\r')
3463 /* Get the object being moved. */
3464 o_idx = c_ptr->o_idx;
3466 /* Only rotate a pile of two or more objects. */
3467 if (!(o_idx && o_list[o_idx].next_o_idx)) continue;
3469 /* Remove the first object from the list. */
3470 excise_object_idx(o_idx);
3472 /* Find end of the list. */
3474 while (o_list[i].next_o_idx)
3475 i = o_list[i].next_o_idx;
3477 /* Add after the last object. */
3478 o_list[i].next_o_idx = o_idx;
3480 /* Loop and re-display the list */
3486 #endif /* ALLOW_EASY_FLOOR */
3489 /* Scan all objects in the grid */
3490 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
3494 /* Acquire object */
3495 o_ptr = &o_list[this_o_idx];
3497 /* Acquire next object */
3498 next_o_idx = o_ptr->next_o_idx;
3503 char o_name[MAX_NLEN];
3508 /* Obtain an object description */
3509 object_desc(o_name, o_ptr, TRUE, 3);
3511 /* Describe the object */
3513 sprintf(out_val, "%s%s%s%s[%s]", s1, o_name, s2, s3, info);
3515 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, o_name, info);
3519 move_cursor_relative(y, x);
3522 /* Always stop at "normal" keys */
3523 if ((query != '\r') && (query != '\n') && (query != ' ') && (query != 'x')) return query;
3525 /* Sometimes stop at "space" key */
3526 if ((query == ' ') && !(mode & TARGET_LOOK)) return query;
3528 /* Change the intro */
3538 if (o_ptr->number != 1) s1 = "¤½¤ì¤é¤Ï";
3540 if (o_ptr->number != 1) s1 = "They are ";
3556 /* Feature code (applying "mimic" field) */
3557 feat = c_ptr->mimic ? c_ptr->mimic : f_info[c_ptr->feat].mimic;
3559 /* Require knowledge about grid, or ability to see grid */
3560 if (!(c_ptr->info & CAVE_MARK) && !player_can_see_bold(y, x))
3562 /* Forget feature */
3566 /* Terrain feature if needed */
3567 if (boring || (feat > FEAT_INVIS))
3571 /* Hack -- special handling for building doors */
3572 if ((feat >= FEAT_BLDG_HEAD) && (feat <= FEAT_BLDG_TAIL))
3574 name = building[feat - FEAT_BLDG_HEAD].name;
3576 else if (feat == FEAT_ENTRANCE)
3579 name = format("%s(%d³¬ÁêÅö)", d_text + d_info[c_ptr->special].text, d_info[c_ptr->special].mindepth);
3581 name = format("%s(level %d)", d_text + d_info[c_ptr->special].text, d_info[c_ptr->special].mindepth);
3584 else if (feat == FEAT_TOWN)
3586 name = town[c_ptr->special].name;
3588 else if (p_ptr->wild_mode && (feat == FEAT_FLOOR))
3598 name = f_name + f_info[feat].name;
3603 if (*s2 && ((feat >= FEAT_MINOR_GLYPH) &&
3604 (feat <= FEAT_PATTERN_XTRA2)))
3613 else if (*s2 && ((feat >= FEAT_DOOR_HEAD) &&
3614 (feat <= FEAT_PERM_SOLID)))
3623 else if (*s2 && (feat == FEAT_TOWN))
3633 /* Hack -- special introduction for store & building doors -KMW- */
3634 if (((feat >= FEAT_SHOP_HEAD) && (feat <= FEAT_SHOP_TAIL)) ||
3635 ((feat >= FEAT_BLDG_HEAD) && (feat <= FEAT_BLDG_TAIL)) ||
3636 (feat == FEAT_MUSEUM) ||
3637 (feat == FEAT_ENTRANCE))
3646 else if ((feat == FEAT_TOWN) || (feat == FEAT_FLOOR) || (feat == FEAT_DIRT) || (feat == FEAT_FLOWER))
3654 /* Pick proper indefinite article */
3656 s3 = (is_a_vowel(name[0])) ? "an " : "a ";
3660 /* Display a message */
3663 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);
3665 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);
3669 sprintf(out_val, "%s%s%s%s[%s]", s1, name, s2, s3, info);
3671 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, name, info);
3675 move_cursor_relative(y, x);
3678 /* Always stop at "normal" keys */
3679 if ((query != '\r') && (query != '\n') && (query != ' ')) return query;
3682 /* Stop on everything but "return" */
3683 if ((query != '\r') && (query != '\n')) return query;
3685 /* Repeat forever */
3691 * Handle "target" and "look".
3693 * Note that this code can be called from "get_aim_dir()".
3695 * All locations must be on the current panel. Consider the use of
3696 * "panel_bounds()" to allow "off-panel" targets, perhaps by using
3697 * some form of "scrolling" the map around the cursor. XXX XXX XXX
3698 * That is, consider the possibility of "auto-scrolling" the screen
3699 * while the cursor moves around. This may require changes in the
3700 * "update_mon()" code to allow "visibility" even if off panel, and
3701 * may require dynamic recalculation of the "temp" grid set.
3703 * Hack -- targeting/observing an "outer border grid" may induce
3704 * problems, so this is not currently allowed.
3706 * The player can use the direction keys to move among "interesting"
3707 * grids in a heuristic manner, or the "space", "+", and "-" keys to
3708 * move through the "interesting" grids in a sequential manner, or
3709 * can enter "location" mode, and use the direction keys to move one
3710 * grid at a time in any direction. The "t" (set target) command will
3711 * only target a monster (as opposed to a location) if the monster is
3712 * target_able and the "interesting" mode is being used.
3714 * The current grid is described using the "look" method above, and
3715 * a new command may be entered at any time, but note that if the
3716 * "TARGET_LOOK" bit flag is set (or if we are in "location" mode,
3717 * where "space" has no obvious meaning) then "space" will scan
3718 * through the description of the current grid until done, instead
3719 * of immediately jumping to the next "interesting" grid. This
3720 * allows the "target" command to retain its old semantics.
3722 * The "*", "+", and "-" keys may always be used to jump immediately
3723 * to the next (or previous) interesting grid, in the proper mode.
3725 * The "return" key may always be used to scan through a complete
3726 * grid description (forever).
3728 * This command will cancel any old target, even if used from
3729 * inside the "look" command.
3731 bool target_set(int mode)
3751 get_screen_size(&wid, &hgt);
3757 /* Cancel tracking */
3758 /* health_track(0); */
3761 /* Prepare the "temp" array */
3762 target_set_prepare(mode);
3764 /* Start near the player */
3770 /* Interesting grids */
3776 if (!(mode & TARGET_LOOK)) prt_path(y, x);
3779 c_ptr = &cave[y][x];
3782 if (target_able(c_ptr->m_idx))
3785 strcpy(info, "q»ß t·è p¼« o¸½ +¼¡ -Á°");
3787 strcpy(info, "q,t,p,o,+,-,<dir>");
3792 /* Dis-allow target */
3796 strcpy(info, "q»ß p¼« o¸½ +¼¡ -Á°");
3798 strcpy(info, "q,p,o,+,-,<dir>");
3803 /* Describe and Prompt */
3804 while (!(query = target_set_aux(y, x, mode, info)));
3806 /* Cancel tracking */
3807 /* health_track(0); */
3809 /* Assume no "direction" */
3814 if (query == '\r') query = 't';
3832 if (target_able(c_ptr->m_idx))
3834 health_track(c_ptr->m_idx);
3835 target_who = c_ptr->m_idx;
3854 if (!expand_list) done = TRUE;
3864 if (!expand_list) done = TRUE;
3871 /* Recenter the map around the player */
3875 p_ptr->update |= (PU_MONSTERS);
3878 p_ptr->redraw |= (PR_MAP);
3881 p_ptr->window |= (PW_OVERHEAD);
3886 /* Recalculate interesting grids */
3887 target_set_prepare(mode);
3906 /* Extract the action (if any) */
3907 d = get_keymap_dir(query);
3914 /* Hack -- move around */
3917 /* Modified to scroll to monster */
3918 int y2 = panel_row_min;
3919 int x2 = panel_col_min;
3921 /* Find a new monster */
3922 i = target_pick(temp_y[m], temp_x[m], ddy[d], ddx[d]);
3924 /* Request to target past last interesting grid */
3925 while (flag && (i < 0))
3927 /* Note the change */
3928 if (change_panel(ddy[d], ddx[d]))
3933 /* Recalculate interesting grids */
3934 target_set_prepare(mode);
3936 /* Look at interesting grids */
3939 /* Find a new monster */
3940 i = target_pick(v, u, ddy[d], ddx[d]);
3946 /* Nothing interesting */
3952 /* Restore previous position */
3955 panel_bounds_center();
3958 p_ptr->update |= (PU_MONSTERS);
3961 p_ptr->redraw |= (PR_MAP);
3964 p_ptr->window |= (PW_OVERHEAD);
3969 /* Recalculate interesting grids */
3970 target_set_prepare(mode);
3972 /* Look at boring grids */
3979 /* Do not move horizontally if unnecessary */
3980 if (((x < panel_col_min + wid / 2) && (dx > 0)) ||
3981 ((x > panel_col_min + wid / 2) && (dx < 0)))
3986 /* Do not move vertically if unnecessary */
3987 if (((y < panel_row_min + hgt / 2) && (dy > 0)) ||
3988 ((y > panel_row_min + hgt / 2) && (dy < 0)))
3993 /* Apply the motion */
3994 if ((y >= panel_row_min+hgt) || (y < panel_row_min) ||
3995 (x >= panel_col_min+wid) || (x < panel_col_min))
3997 if (change_panel(dy, dx)) target_set_prepare(mode);
4000 /* Slide into legality */
4001 if (x >= cur_wid-1) x = cur_wid - 2;
4002 else if (x <= 0) x = 1;
4004 /* Slide into legality */
4005 if (y >= cur_hgt-1) y = cur_hgt- 2;
4006 else if (y <= 0) y = 1;
4015 /* Arbitrary grids */
4018 bool move_fast = FALSE;
4020 if (!(mode & TARGET_LOOK)) prt_path(y, x);
4023 c_ptr = &cave[y][x];
4025 /* Default prompt */
4027 strcpy(info, "q»ß t·è p¼« m¶á +¼¡ -Á°");
4029 strcpy(info, "q,t,p,m,+,-,<dir>");
4033 /* Describe and Prompt (enable "TARGET_LOOK") */
4034 while (!(query = target_set_aux(y, x, mode | TARGET_LOOK, info)));
4036 /* Cancel tracking */
4037 /* health_track(0); */
4039 /* Assume no direction */
4044 if (query == '\r') query = 't';
4047 /* Analyze the keypress */
4071 /* Recenter the map around the player */
4075 p_ptr->update |= (PU_MONSTERS);
4078 p_ptr->redraw |= (PR_MAP);
4081 p_ptr->window |= (PW_OVERHEAD);
4086 /* Recalculate interesting grids */
4087 target_set_prepare(mode);
4109 /* Pick a nearby monster */
4110 for (i = 0; i < temp_n; i++)
4112 t = distance(y, x, temp_y[i], temp_x[i]);
4122 /* Nothing interesting */
4123 if (bd == 999) flag = FALSE;
4130 /* Extract the action (if any) */
4131 d = get_keymap_dir(query);
4133 /* XTRA HACK MOVEFAST */
4134 if (isupper(query)) move_fast = TRUE;
4141 /* Handle "direction" */
4147 /* XTRA HACK MOVEFAST */
4150 int mag = MIN(wid / 2, hgt / 2);
4160 /* Do not move horizontally if unnecessary */
4161 if (((x < panel_col_min + wid / 2) && (dx > 0)) ||
4162 ((x > panel_col_min + wid / 2) && (dx < 0)))
4167 /* Do not move vertically if unnecessary */
4168 if (((y < panel_row_min + hgt / 2) && (dy > 0)) ||
4169 ((y > panel_row_min + hgt / 2) && (dy < 0)))
4174 /* Apply the motion */
4175 if ((y >= panel_row_min + hgt) || (y < panel_row_min) ||
4176 (x >= panel_col_min + wid) || (x < panel_col_min))
4178 if (change_panel(dy, dx)) target_set_prepare(mode);
4181 /* Slide into legality */
4182 if (x >= cur_wid-1) x = cur_wid - 2;
4183 else if (x <= 0) x = 1;
4185 /* Slide into legality */
4186 if (y >= cur_hgt-1) y = cur_hgt- 2;
4187 else if (y <= 0) y = 1;
4195 /* Clear the top line */
4198 /* Recenter the map around the player */
4202 p_ptr->update |= (PU_MONSTERS);
4205 p_ptr->redraw |= (PR_MAP);
4208 p_ptr->window |= (PW_OVERHEAD);
4213 /* Failure to set target */
4214 if (!target_who) return (FALSE);
4222 * Get an "aiming direction" from the user.
4224 * The "dir" is loaded with 1,2,3,4,6,7,8,9 for "actual direction", and
4225 * "0" for "current target", and "-1" for "entry aborted".
4227 * Note that "Force Target", if set, will pre-empt user interaction,
4228 * if there is a usable target already set.
4230 * Note that confusion over-rides any (explicit?) user choice.
4232 bool get_aim_dir(int *dp)
4243 /* Global direction */
4246 /* Hack -- auto-target if requested */
4247 if (use_old_target && target_okay()) dir = 5;
4249 #ifdef ALLOW_REPEAT /* TNB */
4251 if (repeat_pull(dp))
4256 if (!(*dp == 5 && !target_okay()))
4258 /* return (TRUE); */
4263 #endif /* ALLOW_REPEAT -- TNB */
4265 /* Ask until satisfied */
4268 /* Choose a prompt */
4272 p = "Êý¸þ ('*'¤Ç¥¿¡¼¥²¥Ã¥ÈÁªÂò, ESC¤ÇÃæÃÇ)? ";
4274 p = "Direction ('*' to choose a target, Escape to cancel)? ";
4281 p = "Êý¸þ ('5'¤Ç¥¿¡¼¥²¥Ã¥È¤Ø, '*'¤Ç¥¿¡¼¥²¥Ã¥ÈºÆÁªÂò, ESC¤ÇÃæÃÇ)? ";
4283 p = "Direction ('5' for target, '*' to re-target, Escape to cancel)? ";
4288 /* Get a command (or Cancel) */
4289 if (!get_com(p, &command, TRUE)) break;
4293 if (command == '\r') command = 't';
4296 /* Convert various keys to "standard" keys */
4299 /* Use current target */
4310 /* Set new target */
4315 if (target_set(TARGET_KILL)) dir = 5;
4321 /* Extract the action (if any) */
4322 dir = get_keymap_dir(command);
4328 /* Verify requested targets */
4329 if ((dir == 5) && !target_okay()) dir = 0;
4338 project_length = 0; /* reset to default */
4342 /* Save the direction */
4345 /* Check for confusion */
4346 if (p_ptr->confused)
4349 /* Random direction */
4350 dir = ddd[randint0(8)];
4353 /* Notice confusion */
4354 if (command_dir != dir)
4358 msg_print("¤¢¤Ê¤¿¤Ïº®Í𤷤Ƥ¤¤ë¡£");
4360 msg_print("You are confused.");
4365 /* Save direction */
4368 #ifdef ALLOW_REPEAT /* TNB */
4370 /* repeat_push(dir); */
4371 repeat_push(command_dir);
4373 #endif /* ALLOW_REPEAT -- TNB */
4375 /* A "valid" direction was entered */
4382 * Request a "movement" direction (1,2,3,4,6,7,8,9) from the user,
4383 * and place it into "command_dir", unless we already have one.
4385 * This function should be used for all "repeatable" commands, such as
4386 * run, walk, open, close, bash, disarm, spike, tunnel, etc, as well
4387 * as all commands which must reference a grid adjacent to the player,
4388 * and which may not reference the grid under the player. Note that,
4389 * for example, it is no longer possible to "disarm" or "open" chests
4390 * in the same grid as the player.
4392 * Direction "5" is illegal and will (cleanly) abort the command.
4394 * This function tracks and uses the "global direction", and uses
4395 * that as the "desired direction", to which "confusion" is applied.
4397 bool get_rep_dir(int *dp, bool under)
4404 /* Global direction */
4407 #ifdef ALLOW_REPEAT /* TNB */
4409 if (repeat_pull(dp))
4412 /* return (TRUE); */
4415 #endif /* ALLOW_REPEAT -- TNB */
4417 /* Get a direction */
4422 /* Get a command (or Cancel) */
4424 if (!get_com("Êý¸þ (ESC¤ÇÃæÃÇ)? ", &ch, TRUE)) break;
4426 if (!get_com("Direction (Escape to cancel)? ", &ch, TRUE)) break;
4430 /* Look up the direction */
4431 dir = get_keymap_dir(ch);
4437 /* Prevent weirdness */
4438 if ((dir == 5) && (!under)) dir = 0;
4441 if (!dir) return (FALSE);
4443 /* Save desired direction */
4446 /* Apply "confusion" */
4447 if (p_ptr->confused)
4449 /* Standard confusion */
4450 if (randint0(100) < 75)
4452 /* Random direction */
4453 dir = ddd[randint0(8)];
4456 else if (p_ptr->riding)
4458 monster_type *m_ptr = &m_list[p_ptr->riding];
4459 monster_race *r_ptr = &r_info[m_ptr->r_idx];
4461 if (m_ptr->confused)
4463 /* Standard confusion */
4464 if (randint0(100) < 75)
4466 /* Random direction */
4467 dir = ddd[randint0(8)];
4470 else if ((r_ptr->flags1 & RF1_RAND_50) && (r_ptr->flags1 & RF1_RAND_25) && (randint0(100) < 50))
4472 /* Random direction */
4473 dir = ddd[randint0(8)];
4475 else if ((r_ptr->flags1 & RF1_RAND_50) && (randint0(100) < 25))
4477 /* Random direction */
4478 dir = ddd[randint0(8)];
4482 /* Notice confusion */
4483 if (command_dir != dir)
4485 if (p_ptr->confused)
4489 msg_print("¤¢¤Ê¤¿¤Ïº®Í𤷤Ƥ¤¤ë¡£");
4491 msg_print("You are confused.");
4497 monster_type *m_ptr = &m_list[p_ptr->riding];
4499 monster_desc(m_name, m_ptr, 0);
4500 if (m_ptr->confused)
4503 msg_format("%s¤Ïº®Í𤷤Ƥ¤¤ë¡£", m_name);
4505 msg_format("%^s is confusing.", m_name);
4512 msg_format("%s¤Ï»×¤¤Ä̤ê¤ËÆ°¤¤¤Æ¤¯¤ì¤Ê¤¤¡£", m_name);
4514 msg_format("You cannot control %s.", m_name);
4520 /* Save direction */
4523 #ifdef ALLOW_REPEAT /* TNB */
4525 /* repeat_push(dir); */
4526 repeat_push(command_dir);
4528 #endif /* ALLOW_REPEAT -- TNB */
4535 bool get_rep_dir2(int *dp)
4542 /* Global direction */
4545 #ifdef ALLOW_REPEAT /* TNB */
4547 if (repeat_pull(dp))
4550 /* return (TRUE); */
4553 #endif /* ALLOW_REPEAT -- TNB */
4555 /* Get a direction */
4560 /* Get a command (or Cancel) */
4562 if (!get_com("Êý¸þ (ESC¤ÇÃæÃÇ)? ", &ch, TRUE)) break;
4564 if (!get_com("Direction (Escape to cancel)? ", &ch, TRUE)) break;
4568 /* Look up the direction */
4569 dir = get_keymap_dir(ch);
4575 /* Prevent weirdness */
4576 if (dir == 5) dir = 0;
4579 if (!dir) return (FALSE);
4581 /* Save desired direction */
4584 /* Apply "confusion" */
4585 if (p_ptr->confused)
4587 /* Standard confusion */
4588 if (randint0(100) < 75)
4590 /* Random direction */
4591 dir = ddd[randint0(8)];
4595 /* Notice confusion */
4596 if (command_dir != dir)
4600 msg_print("¤¢¤Ê¤¿¤Ïº®Í𤷤Ƥ¤¤ë¡£");
4602 msg_print("You are confused.");
4607 /* Save direction */
4610 #ifdef ALLOW_REPEAT /* TNB */
4612 /* repeat_push(dir); */
4613 repeat_push(command_dir);
4615 #endif /* ALLOW_REPEAT -- TNB */
4622 int get_chaos_patron(void)
4624 return ((p_ptr->age + p_ptr->sc) % MAX_PATRON);
4628 void gain_level_reward(int chosen_reward)
4632 char wrath_reason[32] = "";
4633 int nasty_chance = 6;
4634 int dummy = 0, dummy2 = 0;
4637 char o_name[MAX_NLEN];
4643 if (multi_rew) return;
4644 else multi_rew = TRUE;
4648 if (p_ptr->lev == 13) nasty_chance = 2;
4649 else if (!(p_ptr->lev % 13)) nasty_chance = 3;
4650 else if (!(p_ptr->lev % 14)) nasty_chance = 12;
4652 if (one_in_(nasty_chance))
4653 type = randint1(20); /* Allow the 'nasty' effects */
4655 type = randint1(15) + 5; /* Or disallow them */
4657 if (type < 1) type = 1;
4658 if (type > 20) type = 20;
4663 sprintf(wrath_reason, "%s¤ÎÅܤê",
4664 chaos_patrons[p_ptr->chaos_patron]);
4666 sprintf(wrath_reason, "the Wrath of %s",
4667 chaos_patrons[p_ptr->chaos_patron]);
4671 effect = chaos_rewards[p_ptr->chaos_patron][type];
4673 if (one_in_(6) && !chosen_reward)
4676 msg_format("%^s¤ÏË«Èþ¤È¤·¤Æ¤¢¤Ê¤¿¤òÆÍÁ³ÊÑ°Û¤µ¤»¤¿¡£",
4677 chaos_patrons[p_ptr->chaos_patron]);
4679 msg_format("%^s rewards you with a mutation!",
4680 chaos_patrons[p_ptr->chaos_patron]);
4683 (void)gain_random_mutation(0);
4685 reward = "ÊÑ°Û¤·¤¿¡£";
4687 reward = "mutation";
4692 switch (chosen_reward ? chosen_reward : effect)
4696 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
4697 chaos_patrons[p_ptr->chaos_patron]);
4699 msg_format("The voice of %s booms out:",
4700 chaos_patrons[p_ptr->chaos_patron]);
4704 msg_print("¡ÖÆò¡¢¿·¤¿¤Ê¤ë»Ñ¤òɬÍפȤ»¤ê¡ª¡×");
4706 msg_print("'Thou needst a new form, mortal!'");
4711 reward = "ÊÑ°Û¤·¤¿¡£";
4713 reward = "polymorphing";
4718 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
4719 chaos_patrons[p_ptr->chaos_patron]);
4721 msg_format("The voice of %s booms out:",
4722 chaos_patrons[p_ptr->chaos_patron]);
4726 msg_print("¡ÖÆò¤ÏÎɤ¯¹Ô¤¤¤¿¤ê¡ªÂ³¤±¤è¡ª¡×");
4728 msg_print("'Well done, mortal! Lead on!'");
4731 if (p_ptr->prace == RACE_ANDROID)
4734 msg_print("¤·¤«¤·²¿¤âµ¯¤³¤é¤Ê¤«¤Ã¤¿¡£");
4736 msg_print("But, nothing happen.");
4739 else if (p_ptr->exp < PY_MAX_EXP)
4741 s32b ee = (p_ptr->exp / 2) + 10;
4742 if (ee > 100000L) ee = 100000L;
4744 msg_print("¹¹¤Ë·Ð¸³¤òÀѤó¤À¤è¤¦¤Êµ¤¤¬¤¹¤ë¡£");
4746 msg_print("You feel more experienced.");
4751 reward = "·Ð¸³ÃͤòÆÀ¤¿";
4753 reward = "experience";
4759 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
4760 chaos_patrons[p_ptr->chaos_patron]);
4762 msg_format("The voice of %s booms out:",
4763 chaos_patrons[p_ptr->chaos_patron]);
4767 msg_print("¡Ö²¼Ëͤ衢Æò¤½¤ì¤ËÃͤ»¤º¡£¡×");
4769 msg_print("'Thou didst not deserve that, slave.'");
4772 if (p_ptr->prace == RACE_ANDROID)
4775 msg_print("¤·¤«¤·²¿¤âµ¯¤³¤é¤Ê¤«¤Ã¤¿¡£");
4777 msg_print("But, nothing happen.");
4782 lose_exp(p_ptr->exp / 6);
4784 reward = "·Ð¸³Ãͤò¼º¤Ã¤¿¡£";
4786 reward = "losing experience";
4792 msg_format("%s¤ÎÀ¼¤¬¤µ¤µ¤ä¤¤¤¿:",
4793 chaos_patrons[p_ptr->chaos_patron]);
4795 msg_format("The voice of %s whispers:",
4796 chaos_patrons[p_ptr->chaos_patron]);
4800 msg_print("¡Ö²æ¤¬Í¿¤¨¤·Êª¤ò¸ÌÀ¤Ë»È¤¦¤Ù¤·¡£¡×");
4802 msg_print("'Use my gift wisely.'");
4805 acquirement(py, px, 1, FALSE, FALSE);
4807 reward = "¾å¼Á¤Ê¥¢¥¤¥Æ¥à¤ò¼ê¤ËÆþ¤ì¤¿¡£";
4809 reward = "a good item";
4814 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
4815 chaos_patrons[p_ptr->chaos_patron]);
4817 msg_format("The voice of %s booms out:",
4818 chaos_patrons[p_ptr->chaos_patron]);
4822 msg_print("¡Ö²æ¤¬Í¿¤¨¤·Êª¤ò¸ÌÀ¤Ë»È¤¦¤Ù¤·¡£¡×");
4824 msg_print("'Use my gift wisely.'");
4827 acquirement(py, px, 1, TRUE, FALSE);
4829 reward = "¹âµéÉʤΥ¢¥¤¥Æ¥à¤ò¼ê¤ËÆþ¤ì¤¿¡£";
4831 reward = "an excellent item";
4836 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
4837 chaos_patrons[p_ptr->chaos_patron]);
4839 msg_format("The voice of %s booms out:",
4840 chaos_patrons[p_ptr->chaos_patron]);
4844 msg_print("¡ÖÆò¤Î¹Ô¤¤¤Ïµ®¤·õ¤ËÃͤ»¤ê¡£¡×");
4846 msg_print("'Thy deed hath earned thee a worthy blade.'");
4849 /* Get local object */
4852 switch (randint1(p_ptr->lev))
4858 dummy2 = SV_MAIN_GAUCHE;
4867 dummy2 = SV_SMALL_SWORD;
4870 dummy2 = SV_BASILLARD;
4872 case 11: case 12: case 13:
4873 dummy2 = SV_SHORT_SWORD;
4879 dummy2 = SV_CUTLASS;
4882 dummy2 = SV_WAKIZASHI;
4885 dummy2 = SV_KHOPESH;
4891 dummy2 = SV_BROAD_SWORD;
4894 dummy2 = SV_LONG_SWORD;
4897 dummy2 = SV_SCIMITAR;
4900 dummy2 = SV_NINJATO;
4906 dummy2 = SV_BASTARD_SWORD;
4909 dummy2 = SV_GREAT_SCIMITAR;
4912 dummy2 = SV_CLAYMORE;
4915 dummy2 = SV_ESPADON;
4918 dummy2 = SV_TWO_HANDED_SWORD;
4921 dummy2 = SV_FLAMBERGE;
4924 dummy2 = SV_NO_DACHI;
4927 dummy2 = SV_EXECUTIONERS_SWORD;
4930 dummy2 = SV_ZWEIHANDER;
4933 dummy2 = SV_HAYABUSA;
4936 dummy2 = SV_BLADE_OF_CHAOS;
4939 object_prep(q_ptr, lookup_kind(dummy, dummy2));
4940 q_ptr->to_h = 3 + randint1(dun_level) % 10;
4941 q_ptr->to_d = 3 + randint1(dun_level) % 10;
4942 one_resistance(q_ptr);
4943 q_ptr->name2 = EGO_CHAOTIC;
4945 /* Drop it in the dungeon */
4946 (void)drop_near(q_ptr, -1, py, px);
4948 reward = "(º®ÆÙ)¤ÎÉð´ï¤ò¼ê¤ËÆþ¤ì¤¿¡£";
4950 reward = "chaos weapon";
4955 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
4956 chaos_patrons[p_ptr->chaos_patron]);
4958 msg_format("The voice of %s booms out:",
4959 chaos_patrons[p_ptr->chaos_patron]);
4963 msg_print("¡ÖÆò¤Î¹Ô¤¤¤Ïµ®¤Ê󤤤ËÃͤ»¤ê¡£¡×");
4965 msg_print("'Thy deed hath earned thee a worthy reward.'");
4968 acquirement(py, px, randint1(2) + 1, FALSE, FALSE);
4970 reward = "¾å¼Á¤Ê¥¢¥¤¥Æ¥à¤ò¼ê¤ËÆþ¤ì¤¿¡£";
4972 reward = "good items";
4977 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
4978 chaos_patrons[p_ptr->chaos_patron]);
4980 msg_format("The voice of %s booms out:",
4981 chaos_patrons[p_ptr->chaos_patron]);
4985 msg_print("¡Ö²¼Ëͤ衢Æò¤Î¸¥¿È¤Ø¤Î²æ¤¬Àˤ·¤ß̵¤Ê󤤤ò¸«¤ë¤¬¤è¤¤¡£¡×");
4987 msg_print("'Behold, mortal, how generously I reward thy loyalty.'");
4990 acquirement(py, px, randint1(2) + 1, TRUE, FALSE);
4992 reward = "¹âµéÉʤΥ¢¥¤¥Æ¥à¤ò¼ê¤ËÆþ¤ì¤¿¡£";
4994 reward = "excellent items";
4999 msg_format("%s¤ÎÀ¼¤¬¹ì¤ÅϤä¿:",
5000 chaos_patrons[p_ptr->chaos_patron]);
5002 msg_format("The voice of %s thunders:",
5003 chaos_patrons[p_ptr->chaos_patron]);
5007 msg_print("¡Ö²¼Ëͤ衢ÆòÐþËý¤Ê¤ê¡£¡×");
5009 msg_print("'Thou art growing arrogant, mortal.'");
5012 (void)activate_ty_curse(FALSE, &count);
5014 reward = "²Ò¡¹¤·¤¤¼ö¤¤¤ò¤«¤±¤é¤ì¤¿¡£";
5021 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5022 chaos_patrons[p_ptr->chaos_patron]);
5024 msg_format("The voice of %s booms out:",
5025 chaos_patrons[p_ptr->chaos_patron]);
5029 msg_print("¡Ö²æ¤¬²¼Ëͤ¿¤Á¤è¡¢¤«¤ÎÐþËý¤Ê¤ë¼Ô¤òÅݤ¹¤Ù¤·¡ª¡×");
5031 msg_print("'My pets, destroy the arrogant mortal!'");
5034 for (dummy = 0; dummy < randint1(5) + 1; dummy++)
5036 (void)summon_specific(0, py, px, dun_level, 0, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET));
5039 reward = "¥â¥ó¥¹¥¿¡¼¤ò¾¤´¤µ¤ì¤¿¡£";
5041 reward = "summoning hostile monsters";
5046 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5047 chaos_patrons[p_ptr->chaos_patron]);
5049 msg_format("The voice of %s booms out:",
5050 chaos_patrons[p_ptr->chaos_patron]);
5054 msg_print("¡ÖÆò¡¢¤è¤ê¶¯¤Å¨¤òɬÍפȤ»¤ê¡ª¡×");
5056 msg_print("'Thou needst worthier opponents!'");
5059 activate_hi_summon(py, px, FALSE);
5061 reward = "¥â¥ó¥¹¥¿¡¼¤ò¾¤´¤µ¤ì¤¿¡£";
5063 reward = "summoning many hostile monsters";
5068 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5069 chaos_patrons[p_ptr->chaos_patron]);
5071 msg_format("The voice of %s booms out:",
5072 chaos_patrons[p_ptr->chaos_patron]);
5076 msg_print("¡Ö»à¤ÈÇ˲õ¤³¤½²æ¤¬´î¤Ó¤Ê¤ê¡ª¡×");
5078 msg_print("'Death and destruction! This pleaseth me!'");
5083 reward = "¥«¥ª¥¹¤ÎÎϤ¬±²´¬¤¤¤¿¡£";
5085 reward = "calling chaos";
5090 msg_format("%s¤ÎÀ¼¤¬ÌĤê¶Á¤¤¤¿:",
5091 chaos_patrons[p_ptr->chaos_patron]);
5093 msg_format("The voice of %s rings out:",
5094 chaos_patrons[p_ptr->chaos_patron]);
5098 msg_print("¡Öα¤Þ¤ë¤Î¤À¡¢²¼Ëͤ衣;¤¬Æò¤ÎÆùÂΤòÃ䨤󡣡×");
5100 msg_print("'Stay, mortal, and let me mold thee.'");
5103 if (one_in_(3) && !(chaos_stats[p_ptr->chaos_patron] < 0))
5104 do_inc_stat(chaos_stats[p_ptr->chaos_patron]);
5106 do_inc_stat(randint0(6));
5108 reward = "ǽÎÏÃͤ¬¾å¤¬¤Ã¤¿¡£";
5110 reward = "increasing a stat";
5115 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5116 chaos_patrons[p_ptr->chaos_patron]);
5118 msg_format("The voice of %s booms out:",
5119 chaos_patrons[p_ptr->chaos_patron]);
5123 msg_print("¡Ö²¼Ëͤ衢;¤ÏÆò¤ËË°¤ß¤¿¤ê¡£¡×");
5125 msg_print("'I grow tired of thee, mortal.'");
5128 if (one_in_(3) && !(chaos_stats[p_ptr->chaos_patron] < 0))
5129 do_dec_stat(chaos_stats[p_ptr->chaos_patron]);
5131 (void)do_dec_stat(randint0(6));
5133 reward = "ǽÎÏÃͤ¬²¼¤¬¤Ã¤¿¡£";
5135 reward = "decreasing a stat";
5140 msg_format("%s¤ÎÀ¼¤¬¹ì¤ÅϤä¿:",
5141 chaos_patrons[p_ptr->chaos_patron]);
5143 msg_format("The voice of %s thunders:",
5144 chaos_patrons[p_ptr->chaos_patron]);
5148 msg_print("¡ÖÆò¡¢¸¬µõ¤¿¤ë¤³¤È¤ò³Ø¤Ö¤Ù¤·¡ª¡×");
5149 msg_print("¤¢¤Ê¤¿¤Ï°ÊÁ°¤è¤ê¼å¤¯¤Ê¤Ã¤¿¡ª");
5151 msg_print("'Thou needst a lesson in humility, mortal!'");
5152 msg_print("You feel less powerful!");
5155 for (dummy = 0; dummy < 6; dummy++)
5157 (void)dec_stat(dummy, 10 + randint1(15), TRUE);
5160 reward = "Á´Ç½ÎÏÃͤ¬²¼¤¬¤Ã¤¿¡£";
5162 reward = "decreasing all stats";
5167 msg_format("%s¤ÎÎϤ¬¿¨¤ì¤ë¤Î¤ò´¶¤¸¤¿¡£",
5169 msg_format("You feel the power of %s touch you.",
5172 chaos_patrons[p_ptr->chaos_patron]);
5175 reward = "½ý¤¬ÊѲ½¤·¤¿¡£";
5177 reward = "polymorphing wounds";
5182 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5183 chaos_patrons[p_ptr->chaos_patron]);
5185 msg_format("The voice of %s booms out:",
5186 chaos_patrons[p_ptr->chaos_patron]);
5190 msg_print("¡Ö²æ¤¬¤µ¤µ¤ä¤«¤Ê¤ë»òʪ¤ò¼õ¤±¤È¤ë¤¬¤è¤¤¡ª¡×");
5192 msg_print("'Receive this modest gift from me!'");
5195 for (dummy = 0; dummy < 6; dummy++)
5197 (void)do_inc_stat(dummy);
5200 reward = "Á´Ç½ÎÏÃͤ¬¾å¤¬¤Ã¤¿¡£";
5202 reward = "increasing all stats";
5207 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5208 chaos_patrons[p_ptr->chaos_patron]);
5210 msg_format("The voice of %s booms out:",
5211 chaos_patrons[p_ptr->chaos_patron]);
5215 msg_print("¡Ö¶ì¤·¤à¤¬¤è¤¤¡¢ÌµÇ½¤Ê¶ò¤«¼Ô¤è¡ª¡×");
5217 msg_print("'Suffer, pathetic fool!'");
5220 fire_ball(GF_DISINTEGRATE, 0, p_ptr->lev * 4, 4);
5221 take_hit(DAMAGE_NOESCAPE, p_ptr->lev * 4, wrath_reason, -1);
5223 reward = "ʬ²ò¤Îµå¤¬È¯À¸¤·¤¿¡£";
5225 reward = "generating disintegration ball";
5230 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5231 chaos_patrons[p_ptr->chaos_patron]);
5233 msg_format("The voice of %s booms out:",
5234 chaos_patrons[p_ptr->chaos_patron]);
5238 msg_print("¡Öᴤ뤬¤è¤¤¡¢²æ¤¬²¼Ëͤ衪¡×");
5240 msg_print("'Rise, my servant!'");
5244 (void)set_poisoned(0);
5246 (void)set_confused(0);
5251 for (dummy = 0; dummy < 6; dummy++)
5253 (void)do_res_stat(dummy);
5256 reward = "ÂÎÎϤ¬²óÉü¤·¤¿¡£";
5262 if (!buki_motteruka(INVEN_RARM)) break;
5264 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5265 chaos_patrons[p_ptr->chaos_patron]);
5267 msg_format("The voice of %s booms out:",
5268 chaos_patrons[p_ptr->chaos_patron]);
5272 msg_print("¡ÖÆò¡¢Éð´ï¤ËÍê¤ë¤³¤È¤Ê¤«¤ì¡£¡×");
5274 msg_print("'Thou reliest too much on thy weapon.'");
5277 object_desc(o_name, &inventory[INVEN_RARM], TRUE, 0);
5278 (void)curse_weapon(FALSE, INVEN_RARM);
5280 reward = format("%s¤¬Ç˲õ¤µ¤ì¤¿¡£", o_name);
5282 reward = format("destroying %s", o_name);
5286 if (!inventory[INVEN_BODY].k_idx) break;
5288 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5289 chaos_patrons[p_ptr->chaos_patron]);
5291 msg_format("The voice of %s booms out:",
5292 chaos_patrons[p_ptr->chaos_patron]);
5296 msg_print("¡ÖÆò¡¢Ëɶñ¤ËÍê¤ë¤³¤È¤Ê¤«¤ì¡£¡×");
5298 msg_print("'Thou reliest too much on thine equipment.'");
5301 object_desc(o_name, &inventory[INVEN_BODY], TRUE, 0);
5302 (void)curse_armor();
5304 reward = format("%s¤¬Ç˲õ¤µ¤ì¤¿¡£", o_name);
5306 reward = format("destroying %s", o_name);
5311 msg_format("%s¤ÎÀ¼¤¬¤µ¤µ¤ä¤¤¤¿:",
5312 chaos_patrons[p_ptr->chaos_patron]);
5314 msg_format("The voice of %s whispers:",
5315 chaos_patrons[p_ptr->chaos_patron]);
5319 msg_print("¡Ö²æ¤òÅܤꤷ¤á¤¿ºá¤ò½þ¤¦¤Ù¤·¡£¡×");
5321 msg_print("'Now thou shalt pay for annoying me.'");
5324 switch (randint1(4))
5327 (void)activate_ty_curse(FALSE, &count);
5329 reward = "²Ò¡¹¤·¤¤¼ö¤¤¤ò¤«¤±¤é¤ì¤¿¡£";
5335 activate_hi_summon(py, px, FALSE);
5337 reward = "¥â¥ó¥¹¥¿¡¼¤ò¾¤´¤µ¤ì¤¿¡£";
5339 reward = "summoning hostile monsters";
5345 if (!buki_motteruka(INVEN_RARM)) break;
5346 object_desc(o_name, &inventory[INVEN_RARM], TRUE, 0);
5347 (void)curse_weapon(FALSE, INVEN_RARM);
5349 reward = format("%s¤¬Ç˲õ¤µ¤ì¤¿¡£", o_name);
5351 reward = format("destroying %s", o_name);
5356 if (!inventory[INVEN_BODY].k_idx) break;
5357 object_desc(o_name, &inventory[INVEN_BODY], TRUE, 0);
5358 (void)curse_armor();
5360 reward = format("%s¤¬Ç˲õ¤µ¤ì¤¿¡£", o_name);
5362 reward = format("destroying %s", o_name);
5367 for (dummy = 0; dummy < 6; dummy++)
5369 (void)dec_stat(dummy, 10 + randint1(15), TRUE);
5372 reward = "Á´Ç½ÎÏÃͤ¬²¼¤¬¤Ã¤¿¡£";
5374 reward = "decreasing all stats";
5381 msg_format("%s¤ÎÀ¼¤¬¹ì¤ÅϤä¿:",
5383 msg_format("The voice of %s thunders:",
5386 chaos_patrons[p_ptr->chaos_patron]);
5388 msg_print("¡Ö»à¤Ì¤¬¤è¤¤¡¢²¼Ëͤ衪¡×");
5390 msg_print("'Die, mortal!'");
5393 take_hit(DAMAGE_LOSELIFE, p_ptr->lev * 4, wrath_reason, -1);
5394 for (dummy = 0; dummy < 6; dummy++)
5396 (void)dec_stat(dummy, 10 + randint1(15), FALSE);
5398 activate_hi_summon(py, px, FALSE);
5399 (void)activate_ty_curse(FALSE, &count);
5400 if (one_in_(2)) (void)curse_weapon(FALSE, INVEN_RARM);
5401 if (one_in_(2)) (void)curse_armor();
5405 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5406 chaos_patrons[p_ptr->chaos_patron]);
5408 msg_format("The voice of %s booms out:",
5409 chaos_patrons[p_ptr->chaos_patron]);
5413 msg_print("¡Ö»à¤ÈÇ˲õ¤³¤½²æ¤¬´î¤Ó¤Ê¤ê¡ª¡×");
5415 msg_print("'Death and destruction! This pleaseth me!'");
5418 (void)destroy_area(py, px, 25, FALSE);
5420 reward = "¥À¥ó¥¸¥ç¥ó¤¬*Ç˲õ*¤µ¤ì¤¿¡£";
5422 reward = "*destruct*ing dungeon";
5427 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5428 chaos_patrons[p_ptr->chaos_patron]);
5430 msg_format("The voice of %s booms out:",
5431 chaos_patrons[p_ptr->chaos_patron]);
5435 msg_print("¡Ö²æ¡¢Æò¤ÎŨ¤òËõ»¦¤»¤ó¡ª¡×");
5437 msg_print("'Let me relieve thee of thine oppressors!'");
5440 (void)symbol_genocide(0, FALSE);
5442 reward = "¥â¥ó¥¹¥¿¡¼¤¬Ëõ»¦¤µ¤ì¤¿¡£";
5444 reward = "genociding monsters";
5449 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5450 chaos_patrons[p_ptr->chaos_patron]);
5452 msg_format("The voice of %s booms out:",
5453 chaos_patrons[p_ptr->chaos_patron]);
5457 msg_print("¡Ö²æ¡¢Æò¤ÎŨ¤òËõ»¦¤»¤ó¡ª¡×");
5459 msg_print("'Let me relieve thee of thine oppressors!'");
5462 (void)mass_genocide(0, FALSE);
5464 reward = "¥â¥ó¥¹¥¿¡¼¤¬Ëõ»¦¤µ¤ì¤¿¡£";
5466 reward = "genociding nearby monsters";
5471 msg_format("%s¤ÎÎϤ¬Å¨¤ò¹¶·â¤¹¤ë¤Î¤ò´¶¤¸¤¿¡ª",
5472 chaos_patrons[p_ptr->chaos_patron]);
5474 msg_format("You can feel the power of %s assault your enemies!",
5475 chaos_patrons[p_ptr->chaos_patron]);
5478 (void)dispel_monsters(p_ptr->lev * 4);
5482 msg_format("%s¤Ï¤¢¤Ê¤¿¤ò̵»ë¤·¤¿¡£",
5483 chaos_patrons[p_ptr->chaos_patron]);
5485 msg_format("%s ignores you.",
5486 chaos_patrons[p_ptr->chaos_patron]);
5492 msg_format("%s¤ÏË«Èþ¤È¤·¤Æ°Ëâ¤Î»È¤¤¤ò¤è¤³¤·¤¿¡ª",chaos_patrons[p_ptr->chaos_patron]);
5494 msg_format("%s rewards you with a demonic servant!",chaos_patrons[p_ptr->chaos_patron]);
5497 if (!summon_specific(-1, py, px, dun_level, SUMMON_DEMON, PM_FORCE_PET))
5499 msg_print("²¿¤â¸½¤ì¤Ê¤«¤Ã¤¿...");
5501 msg_print("Nobody ever turns up...");
5505 reward = "°Ë⤬¥Ú¥Ã¥È¤Ë¤Ê¤Ã¤¿¡£";
5507 reward = "a demonic servant";
5513 msg_format("%s¤ÏË«Èþ¤È¤·¤Æ»È¤¤¤ò¤è¤³¤·¤¿¡ª",chaos_patrons[p_ptr->chaos_patron]);
5515 msg_format("%s rewards you with a servant!",chaos_patrons[p_ptr->chaos_patron]);
5518 if (!summon_specific(-1, py, px, dun_level, 0, PM_FORCE_PET))
5520 msg_print("²¿¤â¸½¤ì¤Ê¤«¤Ã¤¿...");
5522 msg_print("Nobody ever turns up...");
5526 reward = "¥â¥ó¥¹¥¿¡¼¤¬¥Ú¥Ã¥È¤Ë¤Ê¤Ã¤¿¡£";
5528 reward = "a servant";
5534 msg_format("%s¤ÏË«Èþ¤È¤·¤Æ¥¢¥ó¥Ç¥Ã¥É¤Î»È¤¤¤ò¤è¤³¤·¤¿¡£",chaos_patrons[p_ptr->chaos_patron]);
5536 msg_format("%s rewards you with an undead servant!",chaos_patrons[p_ptr->chaos_patron]);
5539 if (!summon_specific(-1, py, px, dun_level, SUMMON_UNDEAD, PM_FORCE_PET))
5541 msg_print("²¿¤â¸½¤ì¤Ê¤«¤Ã¤¿...");
5543 msg_print("Nobody ever turns up...");
5547 reward = "¥¢¥ó¥Ç¥Ã¥É¤¬¥Ú¥Ã¥È¤Ë¤Ê¤Ã¤¿¡£";
5549 reward = "an undead servant";
5555 msg_format("%s¤ÎÀ¼¤¬¤É¤â¤Ã¤¿:",
5557 msg_format("The voice of %s stammers:",
5560 chaos_patrons[p_ptr->chaos_patron]);
5562 msg_format("¡Ö¤¢¡¼¡¢¤¢¡¼¡¢Åú¤¨¤Ï %d/%d¡£¼ÁÌä¤Ï²¿¡©¡×", type, effect);
5564 msg_format("'Uh... uh... the answer's %d/%d, what's the question?'", type, effect);
5572 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, format("¥Ñ¥È¥í¥ó¤ÎÊó½·¤Ç%s", reward));
5574 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, format("The patron rewards you with %s.", reward));
5581 * old -- from PsiAngband.
5583 bool tgt_pt(int *x_ptr, int *y_ptr)
5587 bool success = FALSE;
5592 get_screen_size(&wid, &hgt);
5598 msg_print("¾ì½ê¤òÁª¤ó¤Ç¥¹¥Ú¡¼¥¹¥¡¼¤ò²¡¤·¤Æ²¼¤µ¤¤¡£");
5600 msg_print("Select a point and press space.");
5602 msg_flag = FALSE; /* prevents "-more-" message. */
5604 while ((ch != ESCAPE) && !success)
5606 bool move_fast = FALSE;
5608 move_cursor_relative(y, x);
5620 if (player_bold(y, x)) ch = 0;
5623 else success = TRUE;
5627 /* Look up the direction */
5628 d = get_keymap_dir(ch);
5630 /* XTRA HACK MOVEFAST */
5631 if (isupper(ch)) move_fast = TRUE;
5633 /* Handle "direction" */
5639 /* XTRA HACK MOVEFAST */
5642 int mag = MIN(wid / 2, hgt / 2);
5652 /* Do not move horizontally if unnecessary */
5653 if (((x < panel_col_min + wid / 2) && (dx > 0)) ||
5654 ((x > panel_col_min + wid / 2) && (dx < 0)))
5659 /* Do not move vertically if unnecessary */
5660 if (((y < panel_row_min + hgt / 2) && (dy > 0)) ||
5661 ((y > panel_row_min + hgt / 2) && (dy < 0)))
5666 /* Apply the motion */
5667 if ((y >= panel_row_min + hgt) || (y < panel_row_min) ||
5668 (x >= panel_col_min + wid) || (x < panel_col_min))
5670 /* if (change_panel(dy, dx)) target_set_prepare(mode); */
5671 change_panel(dy, dx);
5674 /* Slide into legality */
5675 if (x >= cur_wid-1) x = cur_wid - 2;
5676 else if (x <= 0) x = 1;
5678 /* Slide into legality */
5679 if (y >= cur_hgt-1) y = cur_hgt- 2;
5680 else if (y <= 0) y = 1;
5687 /* Clear the top line */
5690 /* Recenter the map around the player */
5694 p_ptr->update |= (PU_MONSTERS);
5697 p_ptr->redraw |= (PR_MAP);
5700 p_ptr->window |= (PW_OVERHEAD);
5711 bool get_hack_dir(int *dp)
5721 /* Global direction */
5724 /* (No auto-targeting) */
5726 /* Ask until satisfied */
5729 /* Choose a prompt */
5733 p = "Êý¸þ ('*'¤Ç¥¿¡¼¥²¥Ã¥ÈÁªÂò, ESC¤ÇÃæÃÇ)? ";
5735 p = "Direction ('*' to choose a target, Escape to cancel)? ";
5742 p = "Êý¸þ ('5'¤Ç¥¿¡¼¥²¥Ã¥È¤Ø, '*'¤Ç¥¿¡¼¥²¥Ã¥ÈºÆÁªÂò, ESC¤ÇÃæÃÇ)? ";
5744 p = "Direction ('5' for target, '*' to re-target, Escape to cancel)? ";
5749 /* Get a command (or Cancel) */
5750 if (!get_com(p, &command, TRUE)) break;
5754 if (command == '\r') command = 't';
5757 /* Convert various keys to "standard" keys */
5760 /* Use current target */
5771 /* Set new target */
5776 if (target_set(TARGET_KILL)) dir = 5;
5782 /* Look up the direction */
5783 dir = get_keymap_dir(command);
5789 /* Verify requested targets */
5790 if ((dir == 5) && !target_okay()) dir = 0;
5797 if (!dir) return (FALSE);
5799 /* Save the direction */
5802 /* Check for confusion */
5803 if (p_ptr->confused)
5806 /* Random direction */
5807 dir = ddd[randint0(8)];
5810 /* Notice confusion */
5811 if (command_dir != dir)
5815 msg_print("¤¢¤Ê¤¿¤Ïº®Í𤷤Ƥ¤¤ë¡£");
5817 msg_print("You are confused.");
5822 /* Save direction */
5825 /* A "valid" direction was entered */
5831 * ¥¨¥Í¥ë¥®¡¼¤ÎÁý²ÃÎÌ10d5¤ò®¤¯·×»»¤¹¤ë¤¿¤á¤Î´Ø¿ô
5834 #define Go_no_JuuJou 5*5*5*5*5*5*5*5*5*5
5836 s16b gain_energy(void)
5839 s32b energy_result = 10;
5842 tmp = randint0(Go_no_JuuJou);
5844 for (i = 0; i < 9; i ++){
5845 energy_result += tmp % 5;
5849 return (s16b)(energy_result + tmp);
5856 s16b bow_energy(int sval)
5860 /* Analyze the launcher */
5863 /* Sling and ammo */
5870 /* Short Bow and Arrow */
5877 /* Long Bow and Arrow */
5884 /* Bow of irresponsiblity and Arrow */
5891 /* Light Crossbow and Bolt */
5898 /* Heavy Crossbow and Bolt */
5913 int bow_tmul(int sval)
5917 /* Analyze the launcher */
5920 /* Sling and ammo */
5927 /* Short Bow and Arrow */
5934 /* Long Bow and Arrow */
5941 /* Bow of irresponsiblity and Arrow */
5948 /* Light Crossbow and Bolt */
5955 /* Heavy Crossbow and Bolt */
5967 * Return alignment title
5969 cptr your_alignment(void)
5972 if (p_ptr->align > 150) return "ÂçÁ±";
5973 else if (p_ptr->align > 50) return "ÃæÁ±";
5974 else if (p_ptr->align > 10) return "¾®Á±";
5975 else if (p_ptr->align > -11) return "ÃæΩ";
5976 else if (p_ptr->align > -51) return "¾®°";
5977 else if (p_ptr->align > -151) return "Ãæ°";
5980 if (p_ptr->align > 150) return "Lawful";
5981 else if (p_ptr->align > 50) return "Good";
5982 else if (p_ptr->align > 10) return "Neutral Good";
5983 else if (p_ptr->align > -11) return "Neutral";
5984 else if (p_ptr->align > -51) return "Neutral Evil";
5985 else if (p_ptr->align > -151) return "Evil";
5986 else return "Chaotic";
5992 * Return proficiency level of weapons and misc. skills (except riding)
5994 int weapon_exp_level(int weapon_exp)
5996 if (weapon_exp < WEAPON_EXP_BEGINNER) return EXP_LEVEL_UNSKILLED;
5997 else if (weapon_exp < WEAPON_EXP_SKILLED) return EXP_LEVEL_BEGINNER;
5998 else if (weapon_exp < WEAPON_EXP_EXPERT) return EXP_LEVEL_SKILLED;
5999 else if (weapon_exp < WEAPON_EXP_MASTER) return EXP_LEVEL_EXPERT;
6000 else return EXP_LEVEL_MASTER;
6005 * Return proficiency level of riding
6007 int riding_exp_level(int riding_exp)
6009 if (riding_exp < RIDING_EXP_BEGINNER) return EXP_LEVEL_UNSKILLED;
6010 else if (riding_exp < RIDING_EXP_SKILLED) return EXP_LEVEL_BEGINNER;
6011 else if (riding_exp < RIDING_EXP_EXPERT) return EXP_LEVEL_SKILLED;
6012 else if (riding_exp < RIDING_EXP_MASTER) return EXP_LEVEL_EXPERT;
6013 else return EXP_LEVEL_MASTER;
6018 * Return proficiency level of spells
6020 int spell_exp_level(int spell_exp)
6022 if (spell_exp < SPELL_EXP_BEGINNER) return EXP_LEVEL_UNSKILLED;
6023 else if (spell_exp < SPELL_EXP_SKILLED) return EXP_LEVEL_BEGINNER;
6024 else if (spell_exp < SPELL_EXP_EXPERT) return EXP_LEVEL_SKILLED;
6025 else if (spell_exp < SPELL_EXP_MASTER) return EXP_LEVEL_EXPERT;
6026 else return EXP_LEVEL_MASTER;