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);
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, TRUE, TRUE);
611 /* Drop it in the dungeon */
612 (void)drop_near(q_ptr, -1, y, x);
618 * Handle the "death" of a monster.
620 * Disperse treasures centered at the monster location based on the
621 * various flags contained in the monster flags fields.
623 * Check for "Quest" completion when a quest monster is killed.
625 * Note that only the player can induce "monster_death()" on Uniques.
626 * Thus (for now) all Quest monsters should be Uniques.
628 * Note that monsters can now carry objects, and when a monster dies,
629 * it drops all of its objects, which may disappear in crowded rooms.
631 void monster_death(int m_idx, bool drop_item)
640 monster_type *m_ptr = &m_list[m_idx];
642 monster_race *r_ptr = &r_info[m_ptr->r_idx];
644 bool visible = (m_ptr->ml || (r_ptr->flags1 & RF1_UNIQUE));
646 bool good = (r_ptr->flags1 & RF1_DROP_GOOD) ? TRUE : FALSE;
647 bool great = (r_ptr->flags1 & RF1_DROP_GREAT) ? TRUE : FALSE;
649 bool do_gold = (!(r_ptr->flags1 & RF1_ONLY_ITEM));
650 bool do_item = (!(r_ptr->flags1 & RF1_ONLY_GOLD));
652 int force_coin = get_coin_type(m_ptr->r_idx);
658 if (world_monster) world_monster = FALSE;
660 /* Notice changes in view */
661 if (r_ptr->flags7 & (RF7_HAS_LITE_1 | RF7_HAS_LITE_2 | RF7_SELF_LITE_1 | RF7_SELF_LITE_2))
663 /* Update some things */
664 p_ptr->update |= (PU_MON_LITE);
667 /* Get the location */
671 if (m_ptr->smart & SM_CLONED)
674 if (record_named_pet && is_pet(m_ptr) && m_ptr->nickname)
678 monster_desc(m_name, m_ptr, 0x08);
679 do_cmd_write_nikki(NIKKI_NAMED_PET, 3, m_name);
682 /* Let monsters explode! */
683 for (i = 0; i < 4; i++)
685 if ((r_ptr->blow[i].method == RBM_EXPLODE) || (m_ptr->r_idx == MON_ROLENTO))
687 int flg = PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL;
688 int typ = GF_MISSILE;
689 int d_dice = r_ptr->blow[i].d_dice;
690 int d_side = r_ptr->blow[i].d_side;
691 int damage = damroll(d_dice, d_side);
693 if (m_ptr->r_idx == MON_ROLENTO)
696 damage = damroll(20, 10);
698 else typ = mbe_info[r_ptr->blow[i].effect].explode_type;
700 project(m_idx, 3, y, x, damage, typ, flg, -1);
705 if (m_ptr->mflag2 & MFLAG2_CHAMELEON)
707 choose_new_monster(m_idx, TRUE, MON_CHAMELEON);
708 r_ptr = &r_info[m_ptr->r_idx];
711 /* Check for quest completion */
712 check_quest_completion(m_ptr);
714 /* Handle the possibility of player vanquishing arena combatant -KMW- */
715 if (p_ptr->inside_arena && !is_pet(m_ptr))
719 /* Extract monster name */
720 monster_desc(m_name, m_ptr, 0);
722 p_ptr->exit_bldg = TRUE;
724 if (p_ptr->arena_number > MAX_ARENA_MONS)
727 msg_print("ÁÇÀ²¤é¤·¤¤¡ª·¯¤³¤½¿¿¤Î¾¡Íø¼Ô¤À¡£");
729 msg_print("You are a Genuine Champion!");
735 msg_print("¾¡Íø¡ª¥Á¥ã¥ó¥Ô¥ª¥ó¤Ø¤ÎÆ»¤ò¿Ê¤ó¤Ç¤¤¤ë¡£");
737 msg_print("Victorious! You're on your way to becoming Champion.");
741 if (arena_info[p_ptr->arena_number].tval)
743 /* Get local object */
746 /* Prepare to make a prize */
747 object_prep(q_ptr, lookup_kind(arena_info[p_ptr->arena_number].tval, arena_info[p_ptr->arena_number].sval));
749 apply_magic(q_ptr, object_level, FALSE, FALSE, FALSE, FALSE);
751 /* Drop it in the dungeon */
752 (void)drop_near(q_ptr, -1, y, x);
755 if (p_ptr->arena_number > MAX_ARENA_MONS) p_ptr->arena_number++;
756 p_ptr->arena_number++;
757 if (record_arena) do_cmd_write_nikki(NIKKI_ARENA, p_ptr->arena_number, m_name);
760 if (m_idx == p_ptr->riding)
762 if (rakuba(-1, FALSE))
765 msg_print("ÃÏÌ̤ËÍî¤È¤µ¤ì¤¿¡£");
767 msg_print("You have fallen from your riding pet.");
772 /* Drop a dead corpse? */
773 if (one_in_(r_ptr->flags1 & RF1_UNIQUE ? 1 : 4) &&
774 ((r_ptr->flags9 & RF9_DROP_CORPSE) ||
775 (r_ptr->flags9 & RF9_DROP_SKELETON)) &&
776 !(p_ptr->inside_arena || p_ptr->inside_battle || (m_ptr->smart & SM_CLONED) || ((m_ptr->r_idx == today_mon) && is_pet(m_ptr))))
778 /* Assume skeleton */
782 * We cannot drop a skeleton? Note, if we are in this check,
783 * we *know* we can drop at least a corpse or a skeleton
785 if (!(r_ptr->flags9 & RF9_DROP_SKELETON))
787 else if ((r_ptr->flags9 & RF9_DROP_CORPSE) && (r_ptr->flags1 && RF1_UNIQUE))
790 /* Else, a corpse is more likely unless we did a "lot" of damage */
791 else if (r_ptr->flags9 & RF9_DROP_CORPSE)
793 /* Lots of damage in one blow */
794 if ((0 - ((m_ptr->maxhp) / 4)) > m_ptr->hp)
796 if (one_in_(5)) corpse = TRUE;
800 if (!one_in_(5)) corpse = TRUE;
804 /* Get local object */
807 /* Prepare to make an object */
808 object_prep(q_ptr, lookup_kind(TV_CORPSE, (corpse ? SV_CORPSE : SV_SKELETON)));
810 apply_magic(q_ptr, object_level, FALSE, FALSE, FALSE, FALSE);
812 q_ptr->pval = m_ptr->r_idx;
814 /* Drop it in the dungeon */
815 (void)drop_near(q_ptr, -1, y, x);
818 /* Drop objects being carried */
819 monster_drop_carried_objects(m_ptr);
822 * Mega^3-hack: killing a 'Warrior of the Dawn' is likely to
823 * spawn another in the fallen one's place!
825 if (m_ptr->r_idx == MON_DAWN &&
826 !(p_ptr->inside_arena || p_ptr->inside_battle))
830 int wy = py, wx = px;
832 bool pet = is_pet(m_ptr);
836 scatter(&wy, &wx, py, px, 20, 0);
838 while (!(in_bounds(wy, wx) && cave_floor_bold(wy, wx)) && --attempts);
843 if (pet) mode |= PM_FORCE_PET;
845 if (summon_specific((pet ? -1 : m_idx), wy, wx, 100, SUMMON_DAWN, mode))
847 if (player_can_see_bold(wy, wx))
849 msg_print("¿·¤¿¤ÊÀï»Î¤¬¸½¤ì¤¿¡ª");
851 msg_print("A new warrior steps forth!");
859 /* Pink horrors are replaced with 2 Blue horrors */
860 else if (m_ptr->r_idx == MON_PINK_HORROR &&
861 !(p_ptr->inside_arena || p_ptr->inside_battle))
865 for (i = 0; i < 2; i++)
868 bool pet = is_pet(m_ptr);
871 if (pet) mode |= PM_FORCE_PET;
873 if (summon_specific((pet ? -1 : m_idx), wy, wx, 100, SUMMON_BLUE_HORROR, mode))
875 if (player_can_see_bold(wy, wx))
882 msg_print("¥Ô¥ó¥¯¡¦¥Û¥é¡¼¤ÏʬÎö¤·¤¿¡ª");
884 msg_print("The Pink horror divides!");
888 /* One more ultra-hack: An Unmaker goes out with a big bang! */
889 else if (m_ptr->r_idx == MON_UNMAKER)
892 int flg = PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL;
893 (void)project(m_idx, 6, y, x, 100, GF_CHAOS, flg, -1);
896 /* Bloodletters of Khorne may drop a blade of chaos */
897 else if (m_ptr->r_idx == MON_BLOODLETTER &&
899 (randint1(100) < 15) &&
900 !(p_ptr->inside_arena || p_ptr->inside_battle))
902 /* Get local object */
905 /* Prepare to make a Blade of Chaos */
906 object_prep(q_ptr, lookup_kind(TV_SWORD, SV_BLADE_OF_CHAOS));
908 apply_magic(q_ptr, object_level, FALSE, FALSE, FALSE, FALSE);
910 /* Drop it in the dungeon */
911 (void)drop_near(q_ptr, -1, y, x);
914 else if (m_ptr->r_idx == MON_RAAL &&
916 !(p_ptr->inside_arena || p_ptr->inside_battle))
918 /* Get local object */
921 /* Wipe the object */
924 /* Activate restriction */
925 if ((dun_level > 49) && one_in_(5))
926 get_obj_num_hook = kind_is_good_book;
928 get_obj_num_hook = kind_is_book;
930 /* Prepare allocation table */
934 make_object(q_ptr, FALSE, FALSE);
936 /* Drop it in the dungeon */
937 (void)drop_near(q_ptr, -1, y, x);
940 else if (m_ptr->r_idx == MON_B_DEATH_SWORD &&
941 !(p_ptr->inside_arena || p_ptr->inside_battle))
943 /* Get local object */
946 /* Prepare to make a broken sword */
947 object_prep(q_ptr, lookup_kind(TV_SWORD, randint1(2)));
949 /* Drop it in the dungeon */
950 (void)drop_near(q_ptr, -1, y, x);
953 else if ((r_ptr->d_char == '|') && !(m_ptr->r_idx == MON_STORMBRINGER) &&
954 !(p_ptr->inside_arena || p_ptr->inside_battle))
956 /* Get local object */
959 /* Wipe the object */
962 /* Activate restriction */
963 get_obj_num_hook = kind_is_sword;
965 /* Prepare allocation table */
969 make_object(q_ptr, FALSE, FALSE);
971 /* Drop it in the dungeon */
972 (void)drop_near(q_ptr, -1, y, x);
975 else if ((r_ptr->d_char == '(') && (dun_level > 0) &&
976 !(p_ptr->inside_arena || p_ptr->inside_battle))
978 /* Get local object */
981 /* Wipe the object */
984 /* Activate restriction */
985 get_obj_num_hook = kind_is_cloak;
987 /* Prepare allocation table */
991 make_object(q_ptr, FALSE, FALSE);
993 /* Drop it in the dungeon */
994 (void)drop_near(q_ptr, -1, y, x);
997 else if ((r_ptr->d_char == '/') && (dun_level > 4) &&
998 !(p_ptr->inside_arena || p_ptr->inside_battle))
1000 /* Get local object */
1003 /* Wipe the object */
1006 /* Activate restriction */
1007 get_obj_num_hook = kind_is_polearm;
1009 /* Prepare allocation table */
1012 /* Make a poleweapon */
1013 make_object(q_ptr, FALSE, FALSE);
1015 /* Drop it in the dungeon */
1016 (void)drop_near(q_ptr, -1, y, x);
1019 else if ((r_ptr->d_char == '[') && (dun_level > 19) &&
1020 !(p_ptr->inside_arena || p_ptr->inside_battle))
1022 /* Get local object */
1025 /* Wipe the object */
1028 /* Activate restriction */
1029 get_obj_num_hook = kind_is_armor;
1031 /* Prepare allocation table */
1034 /* Make a hard armor */
1035 make_object(q_ptr, FALSE, FALSE);
1037 /* Drop it in the dungeon */
1038 (void)drop_near(q_ptr, -1, y, x);
1041 else if ((m_ptr->r_idx == MON_A_GOLD || (m_ptr->r_idx == MON_A_SILVER && !((r_ptr->r_pkills+1)%5))) && !(p_ptr->inside_arena || p_ptr->inside_battle))
1043 /* Get local object */
1046 /* Prepare to make a Can of Toys */
1047 object_prep(q_ptr, lookup_kind(TV_CHEST, SV_CHEST_KANDUME));
1049 apply_magic(q_ptr, object_level, FALSE, FALSE, FALSE, FALSE);
1051 /* Drop it in the dungeon */
1052 (void)drop_near(q_ptr, -1, y, x);
1054 /* Mega-Hack -- drop "winner" treasures */
1057 if (m_ptr->r_idx == MON_SERPENT)
1059 /* Get local object */
1062 /* Mega-Hack -- Prepare to make "Grond" */
1063 object_prep(q_ptr, lookup_kind(TV_HAFTED, SV_GROND));
1065 /* Mega-Hack -- Mark this item as "Grond" */
1066 q_ptr->name1 = ART_GROND;
1068 /* Mega-Hack -- Actually create "Grond" */
1069 apply_magic(q_ptr, -1, TRUE, TRUE, TRUE, FALSE);
1071 /* Drop it in the dungeon */
1072 (void)drop_near(q_ptr, -1, y, x);
1074 /* Get local object */
1077 /* Mega-Hack -- Prepare to make "Chaos" */
1078 object_prep(q_ptr, lookup_kind(TV_CROWN, SV_CHAOS));
1080 /* Mega-Hack -- Mark this item as "Chaos" */
1081 q_ptr->name1 = ART_CHAOS;
1083 /* Mega-Hack -- Actually create "Chaos" */
1084 apply_magic(q_ptr, -1, TRUE, TRUE, TRUE, FALSE);
1086 /* Drop it in the dungeon */
1087 (void)drop_near(q_ptr, -1, y, x);
1094 switch (m_ptr->r_idx)
1109 case MON_UNICORN_ORD:
1112 if (p_ptr->pseikaku == SEIKAKU_NAMAKE)
1116 switch (randint0(3))
1119 a_idx = ART_NAMAKE_HAMMER;
1122 a_idx = ART_NAMAKE_BOW;
1125 a_idx = ART_NAMAKE_ARMOR;
1129 while (a_info[a_idx].cur_num);
1140 case MON_STORMBRINGER:
1141 a_idx = ART_STORMBRINGER;
1146 a_idx = ART_CRIMSON;
1156 a_idx = ART_KUSANAGI;
1186 a_idx = ART_WEREWINDLE;
1194 a_idx = ART_GRAYSWANDIR;
1205 a_idx = ART_TWILIGHT;
1210 a_idx = ART_ELENDIL;
1225 a_idx = ART_DESTINY;
1230 a_idx = ART_ZANTETSU;
1245 a_idx = ART_WINBLOWS;
1249 case MON_LUNGORTHIN:
1254 case MON_JACK_SHADOWS:
1260 a_idx = ART_STONEMASK;
1265 a_idx = ART_SOULCRUSH;
1270 a_idx = ART_EXCALIBUR_J;
1275 a_idx = ART_SHUTEN_DOJI;
1280 a_idx = ART_GOTHMOG;
1290 if ((a_idx > 0) && ((randint0(100) < chance) || (p_ptr->wizard)))
1292 if (a_info[a_idx].cur_num == 0)
1294 /* Create the artifact */
1295 create_named_art(a_idx, y, x);
1297 a_info[a_idx].cur_num = 1;
1302 if ((r_ptr->flags7 & RF7_GUARDIAN) && !p_ptr->inside_battle && (d_info[dungeon_type].final_guardian == m_ptr->r_idx))
1304 int k_idx = lookup_kind(TV_SCROLL, SV_SCROLL_ACQUIREMENT); /* Acquirement */;
1306 if (d_info[dungeon_type].final_object)
1307 k_idx = d_info[dungeon_type].final_object;
1309 if (d_info[dungeon_type].final_artifact)
1311 int a_idx = d_info[dungeon_type].final_artifact;
1312 if (a_info[a_idx].cur_num == 0)
1314 /* Create the artifact */
1315 create_named_art(a_idx, y, x);
1317 a_info[a_idx].cur_num = 1;
1324 /* Get local object */
1327 /* Prepare to make a reward */
1328 object_prep(q_ptr, k_idx);
1330 apply_magic(q_ptr, object_level, FALSE, TRUE, FALSE, FALSE);
1332 /* Drop it in the dungeon */
1333 (void)drop_near(q_ptr, -1, y, x);
1336 msg_format("¤¢¤Ê¤¿¤Ï%s¤òÀ©ÇƤ·¤¿¡ª",d_name+d_info[dungeon_type].name);
1338 msg_format("You have conquered %s!",d_name+d_info[dungeon_type].name);
1342 /* Determine how much we can drop */
1343 if ((r_ptr->flags1 & RF1_DROP_60) && (randint0(100) < 60)) number++;
1344 if ((r_ptr->flags1 & RF1_DROP_90) && (randint0(100) < 90)) number++;
1345 if (r_ptr->flags1 & RF1_DROP_1D2) number += damroll(1, 2);
1346 if (r_ptr->flags1 & RF1_DROP_2D2) number += damroll(2, 2);
1347 if (r_ptr->flags1 & RF1_DROP_3D2) number += damroll(3, 2);
1348 if (r_ptr->flags1 & RF1_DROP_4D2) number += damroll(4, 2);
1350 if (cloned && !(r_ptr->flags1 & RF1_UNIQUE))
1351 number = 0; /* Clones drop no stuff unless Cloning Pits */
1353 if (is_pet(m_ptr) || p_ptr->inside_battle || p_ptr->inside_arena)
1354 number = 0; /* Pets drop no stuff */
1355 if (!drop_item && (r_ptr->d_char != '$')) number = 0;
1357 /* Hack -- handle creeping coins */
1358 coin_type = force_coin;
1360 /* Average dungeon and monster levels */
1361 object_level = (dun_level + r_ptr->level) / 2;
1363 /* Drop some objects */
1364 for (j = 0; j < number; j++)
1366 /* Get local object */
1369 /* Wipe the object */
1373 if (do_gold && (!do_item || (randint0(100) < 50)))
1375 /* Make some gold */
1376 if (!make_gold(q_ptr)) continue;
1385 /* Make an object */
1386 if (!make_object(q_ptr, good, great)) continue;
1392 /* Drop it in the dungeon */
1393 (void)drop_near(q_ptr, -1, y, x);
1396 /* Reset the object level */
1397 object_level = base_level;
1399 /* Reset "coin" type */
1403 /* Take note of any dropped treasure */
1404 if (visible && (dump_item || dump_gold))
1406 /* Take notes on treasure */
1407 lore_treasure(m_idx, dump_item, dump_gold);
1410 /* Only process "Quest Monsters" */
1411 if (!(r_ptr->flags1 & RF1_QUESTOR)) return;
1412 if (p_ptr->inside_battle) return;
1415 if (m_ptr->r_idx == MON_SERPENT)
1418 p_ptr->total_winner = TRUE;
1420 /* Redraw the "title" */
1421 p_ptr->redraw |= (PR_TITLE);
1424 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, "¸«»ö¤ËÊѶòÈÚÅܤξ¡Íø¼Ô¤È¤Ê¤Ã¤¿¡ª");
1426 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, "become *WINNER* of Hengband finely!");
1429 if (p_ptr->pclass == CLASS_CHAOS_WARRIOR)
1432 msg_format("%s¤«¤é¤ÎÀ¼¤¬¶Á¤¤¤¿¡£", chaos_patrons[p_ptr->chaos_patron]);
1433 msg_print("¡Ø¤è¤¯¤ä¤Ã¤¿¡¢ÄêÌ¿¤Î¼Ô¤è¡ª¡Ù");
1435 msg_format("The voice of %s booms out:", chaos_patrons[p_ptr->chaos_patron]);
1436 msg_print("'Thou art donst well, mortal!'");
1440 /* Congratulations */
1442 msg_print("*** ¤ª¤á¤Ç¤È¤¦ ***");
1444 msg_print("*** CONGRATULATIONS ***");
1448 msg_print("¤¢¤Ê¤¿¤Ï¥²¡¼¥à¤ò¥³¥ó¥×¥ê¡¼¥È¤·¤Þ¤·¤¿¡£");
1450 msg_print("You have won the game!");
1454 msg_print("½àÈ÷¤¬À°¤Ã¤¿¤é°úÂà(¼«»¦¥³¥Þ¥ó¥É)¤·¤Æ¤â·ë¹½¤Ç¤¹¡£");
1456 msg_print("You may retire (commit suicide) when you are ready.");
1463 * Modify the physical damage done to the monster.
1464 * (for example when it's invulnerable or shielded)
1466 * ToDo: Accept a damage-type to calculate the modified damage from
1467 * things like fire, frost, lightning, poison, ... attacks.
1469 * "type" is not yet used and should be 0.
1471 int mon_damage_mod(monster_type *m_ptr, int dam, bool is_psy_spear)
1473 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1475 if ((r_ptr->flags3 & RF3_RES_ALL) && dam > 0)
1478 if((dam == 0) && one_in_(3)) dam = 1;
1481 if (m_ptr->invulner)
1485 if(!p_ptr->blind && m_ptr->ml)
1488 msg_print("¥Ð¥ê¥¢¤òÀÚ¤êÎö¤¤¤¿¡ª");
1490 msg_print("The barrier is penetrated!");
1494 else if (!one_in_(PENETRATE_INVULNERABILITY))
1502 static void get_exp_from_mon(int dam, monster_type *m_ptr)
1504 s32b div, new_exp, new_exp_frac;
1505 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1506 int monnum_penarty = 0;
1508 if (!m_ptr->r_idx) return;
1509 if (is_pet(m_ptr) || p_ptr->inside_battle) return;
1513 u32b m_exp_h, m_exp_l;
1515 if ((r_ptr->flags2 & RF2_MULTIPLY) || (m_ptr->r_idx == MON_DAWN))
1517 monnum_penarty = r_ptr->r_pkills / 400;
1518 if (monnum_penarty > 8) monnum_penarty = 8;
1520 if (r_ptr->flags1 & RF1_UNIQUE)
1522 m_exp = (long)r_ptr->mexp * r_ptr->level;
1523 div = (p_ptr->max_plv+2);
1527 m_exp = (long)r_ptr->mexp * r_ptr->level * extract_energy[m_ptr->mspeed];
1528 div = (p_ptr->max_plv+2) * extract_energy[r_ptr->speed];
1530 m_exp_h = m_exp/0x10000L;
1531 m_exp_l = m_exp%0x10000L;
1534 m_exp_h += m_exp_l / 0x10000L;
1535 m_exp_l %= 0x10000L;
1537 /* real monster maxhp have effect on EXP */
1538 if(!(r_ptr->flags1 & RF1_FORCE_MAXHP))
1540 u32b maxhp = m_ptr->max_maxhp*2;
1543 m_exp_h += m_exp_l / 0x10000L;
1544 m_exp_l %= 0x10000L;
1546 div *= r_ptr->hdice * (r_ptr->hside + 1);
1548 if (!dun_level && (!(r_ptr->flags8 & RF8_WILD_ONLY) || !(r_ptr->flags1 & RF1_UNIQUE))) div *= 5;
1549 div_h = div/0x10000L;
1550 div_l = div%0x10000L;
1551 div_h *= (m_ptr->max_maxhp*2);
1552 div_l *= (m_ptr->max_maxhp*2);
1553 div_h += div_l / 0x10000L;
1556 while (monnum_penarty)
1560 div_h += div_l / 0x10000L;
1565 m_exp_l = (0x7fffffff & (m_exp_h << 16)) | m_exp_l;
1566 m_exp_h = m_exp_h >> 15;
1567 div_l = (0x7fffffff & (div_h << 16)) | div_l;
1568 div_h = div_h >> 15;
1570 #define M_INT_GREATER63(h1,l1,h2,l2) ( (h1>h2)||( (h1==h2)&&(l1>=l2)))
1571 #define M_INT_SUB63(h1,l1, h2,l2) {h1-=h2;if(l1<l2){l1+=0x80000000;h1--;}l1-=l2;}
1572 #define M_INT_LSHIFT63(h1,l1) {h1=(h1<<1)|(l1>>30);l1=(l1<<1)&0x7fffffff;}
1573 #define M_INT_RSHIFT63(h1,l1) {l1=(l1>>1)|(h1<<30);h1>>=1;}
1574 #define M_INT_DIV63(h1,l1,h2,l2,result) \
1578 while( M_INT_GREATER63(h1,l1, h2, l2) ){M_INT_LSHIFT63(h2, l2); bit<<=1;} \
1579 for(bit>>=1; bit>=1; bit>>=1){ \
1580 M_INT_RSHIFT63(h2, l2); \
1581 if(M_INT_GREATER63(h1, l1, h2, l2)) \
1582 {result|=bit;M_INT_SUB63(h1, l1, h2, l2);} \
1586 /* Give some experience for the kill */
1587 M_INT_DIV63(m_exp_h, m_exp_l, div_h, div_l, new_exp);
1589 /* Handle fractional experience */
1590 /* multiply 0x10000L to remainder */
1591 m_exp_h = (m_exp_h<<16) | (m_exp_l>>15);
1593 M_INT_DIV63(m_exp_h, m_exp_l, div_h, div_l, new_exp_frac);
1594 new_exp_frac += p_ptr->exp_frac;
1595 /* Keep track of experience */
1596 if (new_exp_frac >= 0x10000L)
1599 p_ptr->exp_frac = (u16b)(new_exp_frac - 0x10000L);
1603 p_ptr->exp_frac = (u16b)new_exp_frac;
1606 /* Gain experience */
1614 * Decreases monsters hit points, handling monster death.
1616 * We return TRUE if the monster has been killed (and deleted).
1618 * We announce monster death (using an optional "death message"
1619 * if given, and a otherwise a generic killed/destroyed message).
1621 * Only "physical attacks" can induce the "You have slain" message.
1622 * Missile and Spell attacks will induce the "dies" message, or
1623 * various "specialized" messages. Note that "You have destroyed"
1624 * and "is destroyed" are synonyms for "You have slain" and "dies".
1626 * Hack -- unseen monsters yield "You have killed it." message.
1628 * Added fear (DGK) and check whether to print fear messages -CWS
1630 * Made name, sex, and capitalization generic -BEN-
1632 * As always, the "ghost" processing is a total hack.
1634 * Hack -- we "delay" fear messages by passing around a "fear" flag.
1636 * XXX XXX XXX Consider decreasing monster experience over time, say,
1637 * by using "(m_exp * m_lev * (m_lev)) / (p_lev * (m_lev + n_killed))"
1638 * instead of simply "(m_exp * m_lev) / (p_lev)", to make the first
1639 * monster worth more than subsequent monsters. This would also need
1640 * to induce changes in the monster recall code.
1642 bool mon_take_hit(int m_idx, int dam, bool *fear, cptr note)
1644 monster_type *m_ptr = &m_list[m_idx];
1645 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1647 monster_type exp_mon;
1649 /* Innocent until proven otherwise */
1650 bool innocent = TRUE, thief = FALSE;
1654 COPY(&exp_mon, m_ptr, monster_type);
1655 if (!(r_ptr->flags7 & RF7_KILL_EXP))
1657 expdam = (m_ptr->hp > dam) ? dam : m_ptr->hp;
1658 if (r_ptr->flags6 & RF6_HEAL) expdam = (expdam+1) * 2 / 3;
1660 get_exp_from_mon(expdam, &exp_mon);
1663 /* Redraw (later) if needed */
1664 if (p_ptr->health_who == m_idx) p_ptr->redraw |= (PR_HEALTH);
1665 if (p_ptr->riding == m_idx) p_ptr->redraw |= (PR_UHEALTH);
1670 /* Hack - Cancel any special player stealth magics. -LM- */
1671 if (p_ptr->special_defense & NINJA_S_STEALTH)
1673 set_superstealth(FALSE);
1679 /* It is dead now */
1684 if (r_info[m_ptr->r_idx].flags7 & RF7_TANUKI)
1686 /* You might have unmasked Tanuki first time */
1687 r_ptr = &r_info[m_ptr->r_idx];
1688 m_ptr->ap_r_idx = m_ptr->r_idx;
1689 if (r_ptr->r_sights < MAX_SHORT) r_ptr->r_sights++;
1692 if (m_ptr->mflag2 & MFLAG2_CHAMELEON)
1694 /* You might have unmasked Chameleon first time */
1695 r_ptr = real_r_ptr(m_ptr);
1696 if (r_ptr->r_sights < MAX_SHORT) r_ptr->r_sights++;
1699 /* When the player kills a Unique, it stays dead */
1700 if (r_ptr->flags1 & RF1_UNIQUE && !(m_ptr->smart & SM_CLONED))
1703 /* When the player kills a Nazgul, it stays dead */
1704 if (r_ptr->flags7 & RF7_UNIQUE_7) r_ptr->max_num--;
1706 /* Recall even invisible uniques or winners */
1707 if (m_ptr->ml || (r_ptr->flags1 & RF1_UNIQUE))
1709 /* Count kills this life */
1710 if ((m_ptr->mflag2 & MFLAG2_KAGE) && (r_info[MON_KAGE].r_pkills < MAX_SHORT)) r_info[MON_KAGE].r_pkills++;
1711 else if (r_ptr->r_pkills < MAX_SHORT) r_ptr->r_pkills++;
1713 /* Count kills in all lives */
1714 if ((m_ptr->mflag2 & MFLAG2_KAGE) && (r_info[MON_KAGE].r_tkills < MAX_SHORT)) r_info[MON_KAGE].r_tkills++;
1715 else if (r_ptr->r_tkills < MAX_SHORT) r_ptr->r_tkills++;
1717 /* Hack -- Auto-recall */
1718 monster_race_track(m_ptr->ap_r_idx);
1721 /* Extract monster name */
1722 monster_desc(m_name, m_ptr, 0x100);
1724 /* Don't kill Amberites */
1725 if ((r_ptr->flags3 & RF3_AMBERITE) && one_in_(2))
1727 int curses = 1 + randint1(3);
1728 bool stop_ty = FALSE;
1732 msg_format("%^s¤Ï¶²¤í¤·¤¤·ì¤Î¼ö¤¤¤ò¤¢¤Ê¤¿¤Ë¤«¤±¤¿¡ª", m_name);
1734 msg_format("%^s puts a terrible blood curse on you!", m_name);
1737 curse_equipment(100, 50);
1741 stop_ty = activate_ty_curse(stop_ty, &count);
1746 if (r_ptr->flags2 & RF2_CAN_SPEAK)
1748 char line_got[1024];
1750 /* Dump a message */
1752 if (!get_rnd_line("mondeath_j.txt", m_ptr->r_idx, line_got))
1754 if (!get_rnd_line("mondeath.txt", m_ptr->r_idx, line_got))
1757 msg_format("%^s %s", m_name, line_got);
1760 if (m_ptr->r_idx == MON_SERPENT)
1762 /* Make screen dump */
1763 screen_dump = make_screen_dump();
1768 if (!(d_info[dungeon_type].flags1 & DF1_BEGINNER))
1770 if (!dun_level && !ambush_flag && !p_ptr->inside_arena)
1772 chg_virtue(V_VALOUR, -1);
1774 else if (r_ptr->level > dun_level)
1776 if (randint1(10) <= (r_ptr->level - dun_level))
1777 chg_virtue(V_VALOUR, 1);
1779 if (r_ptr->level > 60)
1781 chg_virtue(V_VALOUR, 1);
1783 if (r_ptr->level >= 2 * (p_ptr->lev+1))
1784 chg_virtue(V_VALOUR, 2);
1787 if ((r_ptr->flags1 & RF1_UNIQUE) && ((r_ptr->flags3 & RF3_EVIL) ||
1788 (r_ptr->flags3 & RF3_GOOD)))
1790 chg_virtue(V_HARMONY, 2);
1792 if ((r_ptr->flags1 & RF1_UNIQUE) && (r_ptr->flags3 & RF3_GOOD))
1794 chg_virtue(V_UNLIFE, 2);
1795 chg_virtue(V_VITALITY, -2);
1798 if ((r_ptr->flags1 & RF1_UNIQUE) && one_in_(3))
1799 chg_virtue(V_INDIVIDUALISM, -1);
1801 if (m_ptr->r_idx == MON_BEGGAR || m_ptr->r_idx == MON_LEPER)
1803 chg_virtue(V_COMPASSION, -1);
1806 if ((r_ptr->flags3 & RF3_GOOD) &&
1807 ((r_ptr->level) / 10 + (3 * dun_level) >= randint1(100)))
1809 chg_virtue(V_UNLIFE, 1);
1811 if (r_ptr->d_char == 'A')
1813 if (r_ptr->flags1 & RF1_UNIQUE)
1814 chg_virtue(V_FAITH, -2);
1815 else if ((r_ptr->level) / 10 + (3 * dun_level) >= randint1(100))
1817 if (r_ptr->flags3 & RF3_GOOD) chg_virtue(V_FAITH, -1);
1818 else chg_virtue(V_FAITH, 1);
1821 else if (r_ptr->flags3 & RF3_DEMON)
1823 if (r_ptr->flags1 & RF1_UNIQUE)
1824 chg_virtue(V_FAITH, 2);
1825 else if ((r_ptr->level) / 10 + (3 * dun_level) >= randint1(100))
1826 chg_virtue(V_FAITH, 1);
1829 if ((r_ptr->flags3 & RF3_UNDEAD) && (r_ptr->flags1 & RF1_UNIQUE))
1830 chg_virtue(V_VITALITY, 2);
1832 if (r_ptr->r_deaths)
1834 if (r_ptr->flags1 & RF1_UNIQUE)
1836 chg_virtue(V_HONOUR, 10);
1838 else if ((r_ptr->level) / 10 + (2 * dun_level) >= randint1(100))
1840 chg_virtue(V_HONOUR, 1);
1843 if ((r_ptr->flags2 & RF2_MULTIPLY) && (r_ptr->r_pkills > 1000) && one_in_(10))
1845 chg_virtue(V_VALOUR, -1);
1848 for (i = 0; i < 4; i++)
1850 if(r_ptr->blow[i].d_dice != 0) innocent = FALSE; /* Murderer! */
1852 if ((r_ptr->blow[i].effect == RBE_EAT_ITEM)
1853 || (r_ptr->blow[i].effect == RBE_EAT_GOLD))
1855 thief = TRUE; /* Thief! */
1858 /* The new law says it is illegal to live in the dungeon */
1859 if (r_ptr->level != 0) innocent = FALSE;
1863 if (r_ptr->flags1 & RF1_UNIQUE)
1864 chg_virtue(V_JUSTICE, 3);
1865 else if (1+((r_ptr->level) / 10 + (2 * dun_level))
1868 chg_virtue(V_JUSTICE, 1);
1872 chg_virtue (V_JUSTICE, -1);
1875 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)))
1877 if (one_in_(4)) chg_virtue(V_NATURE, -1);
1880 if ((r_ptr->flags1 & RF1_UNIQUE) && record_destroy_uniq)
1884 sprintf("%s%s", r_name + r_ptr->name, (m_ptr->smart & SM_CLONED) ? "(¥¯¥í¡¼¥ó)" : "");
1886 sprintf("%s%s", r_name + r_ptr->name, (m_ptr->smart & SM_CLONED) ? "(Clone)" : "");
1888 do_cmd_write_nikki(NIKKI_UNIQUE, 0, m_name);
1894 /* Death by Missile/Spell attack */
1897 msg_format("%^s%s", m_name, note);
1900 /* Death by physical attack -- invisible monster */
1901 else if (!m_ptr->ml)
1904 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
1905 msg_format("¤»¤Ã¤«¤¯¤À¤«¤é%s¤ò»¦¤·¤¿¡£", m_name);
1907 msg_format("%s¤ò»¦¤·¤¿¡£", m_name);
1909 msg_format("You have killed %s.", m_name);
1914 /* Death by Physical attack -- non-living monster */
1915 else if (!monster_living(r_ptr))
1918 bool explode = FALSE;
1920 for (i = 0; i < 4; i++)
1922 if (r_ptr->blow[i].method == RBM_EXPLODE) explode = TRUE;
1925 /* Special note at death */
1928 msg_format("%s¤ÏÇúȯ¤·¤ÆÊ´¡¹¤Ë¤Ê¤Ã¤¿¡£", m_name);
1930 msg_format("%s explodes into tiny shreds.", m_name);
1935 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
1936 msg_format("¤»¤Ã¤«¤¯¤À¤«¤é%s¤òÅݤ·¤¿¡£", m_name);
1938 msg_format("%s¤òÅݤ·¤¿¡£", m_name);
1940 msg_format("You have destroyed %s.", m_name);
1945 /* Death by Physical attack -- living monster */
1949 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
1950 msg_format("¤»¤Ã¤«¤¯¤À¤«¤é%s¤òÁò¤êµî¤Ã¤¿¡£", m_name);
1952 msg_format("%s¤òÁò¤êµî¤Ã¤¿¡£", m_name);
1954 msg_format("You have slain %s.", m_name);
1958 if (r_ptr->flags1 & RF1_UNIQUE && !(m_ptr->smart & SM_CLONED))
1960 for (i = 0; i < MAX_KUBI; i++)
1962 if ((kubi_r_idx[i] == m_ptr->r_idx) && !(m_ptr->mflag2 & MFLAG2_CHAMELEON))
1965 msg_format("%s¤Î¼ó¤Ë¤Ï¾Þ¶â¤¬¤«¤«¤Ã¤Æ¤¤¤ë¡£", m_name);
1967 msg_format("There is a price on %s's head.", m_name);
1974 if (r_ptr->flags7 & RF7_KILL_EXP)
1975 get_exp_from_mon((long)m_ptr->max_maxhp*2, &exp_mon);
1977 get_exp_from_mon(((long)m_ptr->max_maxhp+1L) * 9L / 10L, &exp_mon);
1979 /* Generate treasure */
1980 monster_death(m_idx, TRUE);
1981 if ((m_ptr->r_idx == MON_BANOR) || (m_ptr->r_idx == MON_LUPART))
1983 r_info[MON_BANORLUPART].max_num = 0;
1984 r_info[MON_BANORLUPART].r_pkills++;
1985 if (r_info[MON_BANORLUPART].r_tkills < MAX_SHORT) r_info[MON_BANORLUPART].r_tkills++;
1988 if (m_ptr->r_idx == MON_BANORLUPART)
1990 r_info[MON_BANOR].max_num = 0;
1991 r_info[MON_BANOR].r_pkills++;
1992 if (r_info[MON_BANOR].r_tkills < MAX_SHORT) r_info[MON_BANOR].r_tkills++;
1993 r_info[MON_LUPART].max_num = 0;
1994 r_info[MON_LUPART].r_pkills++;
1995 if (r_info[MON_LUPART].r_tkills < MAX_SHORT) r_info[MON_LUPART].r_tkills++;
1998 /* Mega hack : replace IKETA to BIKETAL */
1999 if ((m_ptr->r_idx == MON_IKETA) &&
2000 !(p_ptr->inside_arena || p_ptr->inside_battle))
2002 int dummy_y = m_ptr->fy;
2003 int dummy_x = m_ptr->fx;
2006 if (is_pet(m_ptr)) mode |= PM_FORCE_PET;
2008 /* Delete the monster */
2009 delete_monster_idx(m_idx);
2011 if (summon_named_creature(0, dummy_y, dummy_x, MON_BIKETAL, mode))
2014 msg_print("¡Ö¥Ï¥¡¥Ã¥Ï¥Ã¥Ï¥Ã¥Ï¡ª¡ª»ä¤¬¥Ð¥¤¥±¥¿¥ë¤À¡ª¡ª¡×");
2016 msg_print("Uwa-hahaha! *I* am Biketal!");
2022 /* Delete the monster */
2023 delete_monster_idx(m_idx);
2029 /* Monster is dead */
2036 /* Mega-Hack -- Pain cancels fear */
2037 if (m_ptr->monfear && (dam > 0))
2039 int tmp = randint1(dam);
2041 /* Cure a little fear */
2042 if (tmp < m_ptr->monfear)
2045 m_ptr->monfear -= tmp;
2048 /* Cure all the fear */
2059 /* Sometimes a monster gets scared by damage */
2060 if (!m_ptr->monfear && !(r_ptr->flags3 & (RF3_NO_FEAR)))
2064 /* Percentage of fully healthy */
2065 percentage = (100L * m_ptr->hp) / m_ptr->maxhp;
2068 * Run (sometimes) if at 10% or less of max hit points,
2069 * or (usually) when hit for half its current hit points
2071 if ((randint1(10) >= percentage) ||
2072 ((dam >= m_ptr->hp) && (randint0(100) < 80)))
2074 /* Hack -- note fear */
2077 /* XXX XXX XXX Hack -- Add some timed fear */
2078 m_ptr->monfear = (randint1(10) +
2079 (((dam >= m_ptr->hp) && (percentage > 7)) ?
2080 20 : ((11 - percentage) * 5)));
2087 if (p_ptr->riding && (p_ptr->riding == m_idx) && (dam > 0))
2091 /* Extract monster name */
2092 monster_desc(m_name, m_ptr, 0);
2094 if (m_ptr->hp > m_ptr->maxhp/3) dam = (dam + 1) / 2;
2095 if (rakuba((dam > 200) ? 200 : dam, FALSE))
2098 msg_format("%^s¤Ë¿¶¤êÍî¤È¤µ¤ì¤¿¡ª", m_name);
2100 msg_format("%^s has thrown you off!", m_name);
2112 * Get term size and calculate screen size
2114 void get_screen_size(int *wid_p, int *hgt_p)
2116 Term_get_size(wid_p, hgt_p);
2117 *hgt_p -= ROW_MAP + 2;
2118 *wid_p -= COL_MAP + 2;
2119 if (use_bigtile) *wid_p /= 2;
2124 * Calculates current boundaries
2125 * Called below and from "do_cmd_locate()".
2127 void panel_bounds_center(void)
2132 get_screen_size(&wid, &hgt);
2134 panel_row_max = panel_row_min + hgt - 1;
2135 panel_row_prt = panel_row_min - 1;
2136 panel_col_max = panel_col_min + wid - 1;
2137 panel_col_prt = panel_col_min - 13;
2142 * Map resizing whenever the main term changes size
2144 void resize_map(void)
2146 /* Only if the dungeon exists */
2147 if (!character_dungeon) return;
2149 /* Mega-Hack -- no panel yet */
2153 /* Reset the panels */
2154 panel_row_min = cur_hgt;
2155 panel_col_min = cur_wid;
2160 p_ptr->update |= (PU_TORCH | PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
2162 /* Forget lite/view */
2163 p_ptr->update |= (PU_UN_VIEW | PU_UN_LITE);
2165 /* Update lite/view */
2166 p_ptr->update |= (PU_VIEW | PU_LITE | PU_MON_LITE);
2168 /* Update monsters */
2169 p_ptr->update |= (PU_MONSTERS);
2171 /* Redraw everything */
2172 p_ptr->redraw |= (PR_WIPE | PR_BASIC | PR_EXTRA | PR_MAP | PR_EQUIPPY);
2174 /* Hack -- update */
2182 * Place the cursor on the player
2184 if (can_save) move_cursor_relative(py, px);
2191 * Redraw a term when it is resized
2193 void redraw_window(void)
2195 /* Only if the dungeon exists */
2196 if (!character_dungeon) return;
2198 /* Hack - Activate term zero for the redraw */
2199 Term_activate(&term_screen[0]);
2201 /* Hack -- react to changes */
2202 Term_xtra(TERM_XTRA_REACT, 0);
2205 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_SPELL | PW_PLAYER);
2208 p_ptr->window |= (PW_MESSAGE | PW_OVERHEAD | PW_DUNGEON | PW_MONSTER | PW_OBJECT);
2210 /* Hack -- update */
2222 * Handle a request to change the current panel
2224 * Return TRUE if the panel was changed.
2226 * Also used in do_cmd_locate
2228 bool change_panel(int dy, int dx)
2234 get_screen_size(&wid, &hgt);
2236 /* Apply the motion */
2237 y = panel_row_min + dy * hgt / 2;
2238 x = panel_col_min + dx * wid / 2;
2240 /* Verify the row */
2241 if (y > cur_hgt - hgt) y = cur_hgt - hgt;
2244 /* Verify the col */
2245 if (x > cur_wid - wid) x = cur_wid - wid;
2248 /* Handle "changes" */
2249 if ((y != panel_row_min) || (x != panel_col_min))
2251 /* Save the new panel info */
2255 /* Recalculate the boundaries */
2256 panel_bounds_center();
2259 p_ptr->update |= (PU_MONSTERS);
2262 p_ptr->redraw |= (PR_MAP);
2277 * Given an row (y) and col (x), this routine detects when a move
2278 * off the screen has occurred and figures new borders. -RAK-
2280 * "Update" forces a "full update" to take place.
2282 * The map is reprinted if necessary, and "TRUE" is returned.
2284 void verify_panel(void)
2296 get_screen_size(&wid, &hgt);
2298 max_prow_min = cur_hgt - hgt;
2299 max_pcol_min = cur_wid - wid;
2301 /* Bounds checking */
2302 if (max_prow_min < 0) max_prow_min = 0;
2303 if (max_pcol_min < 0) max_pcol_min = 0;
2305 /* Center on player */
2306 if (center_player && (center_running || !running))
2308 /* Center vertically */
2309 prow_min = y - hgt / 2;
2310 if (prow_min < 0) prow_min = 0;
2311 else if (prow_min > max_prow_min) prow_min = max_prow_min;
2313 /* Center horizontally */
2314 pcol_min = x - wid / 2;
2315 if (pcol_min < 0) pcol_min = 0;
2316 else if (pcol_min > max_pcol_min) pcol_min = max_pcol_min;
2320 prow_min = panel_row_min;
2321 pcol_min = panel_col_min;
2323 /* Scroll screen when 2 grids from top/bottom edge */
2324 if (y > panel_row_max - 2)
2326 while (y > prow_min + hgt-1 - 2)
2328 prow_min += (hgt / 2);
2332 if (y < panel_row_min + 2)
2334 while (y < prow_min + 2)
2336 prow_min -= (hgt / 2);
2340 if (prow_min > max_prow_min) prow_min = max_prow_min;
2341 if (prow_min < 0) prow_min = 0;
2343 /* Scroll screen when 4 grids from left/right edge */
2344 if (x > panel_col_max - 4)
2346 while (x > pcol_min + wid-1 - 4)
2348 pcol_min += (wid / 2);
2352 if (x < panel_col_min + 4)
2354 while (x < pcol_min + 4)
2356 pcol_min -= (wid / 2);
2360 if (pcol_min > max_pcol_min) pcol_min = max_pcol_min;
2361 if (pcol_min < 0) pcol_min = 0;
2364 /* Check for "no change" */
2365 if ((prow_min == panel_row_min) && (pcol_min == panel_col_min)) return;
2367 /* Save the new panel info */
2368 panel_row_min = prow_min;
2369 panel_col_min = pcol_min;
2371 /* Hack -- optional disturb on "panel change" */
2372 if (disturb_panel && !center_player) disturb(0, 0);
2374 /* Recalculate the boundaries */
2375 panel_bounds_center();
2378 p_ptr->update |= (PU_MONSTERS);
2381 p_ptr->redraw |= (PR_MAP);
2384 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
2389 * Monster health description
2391 cptr look_mon_desc(int m_idx, u32b mode)
2393 monster_type *m_ptr = &m_list[m_idx];
2394 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
2401 /* Determine if the monster is "living" */
2402 living = monster_living(ap_r_ptr);
2404 /* Calculate a health "percentage" */
2405 perc = 100L * m_ptr->hp / m_ptr->maxhp;
2407 /* Healthy monsters */
2408 if (m_ptr->hp >= m_ptr->maxhp)
2412 desc = living ? "̵½ý" : "̵¥À¥á¡¼¥¸";
2414 desc = living ? "unhurt" : "undamaged";
2419 else if (perc >= 60)
2422 desc = living ? "·Ú½ý" : "¾®¥À¥á¡¼¥¸";
2424 desc = living ? "somewhat wounded" : "somewhat damaged";
2429 else if (perc >= 25)
2432 desc = living ? "Éé½ý" : "Ãæ¥À¥á¡¼¥¸";
2434 desc = living ? "wounded" : "damaged";
2439 else if (perc >= 10)
2442 desc = living ? "½Å½ý" : "Âç¥À¥á¡¼¥¸";
2444 desc = living ? "badly wounded" : "badly damaged";
2452 desc = living ? "Ⱦ»àȾÀ¸" : "Åݤ줫¤±";
2454 desc = living ? "almost dead" : "almost destroyed";
2459 /* Need attitude information? */
2462 /* Full information is not needed */
2465 else if (is_pet(m_ptr))
2468 attitude = ", ¥Ú¥Ã¥È";
2473 else if (is_friendly(m_ptr))
2476 attitude = ", ͧ¹¥Åª";
2478 attitude = ", friendly";
2491 /* Clone monster? */
2492 if (m_ptr->smart & SM_CLONED)
2501 /* Display monster's level --- idea borrowed from ToME */
2502 if (ap_r_ptr->r_tkills && !(m_ptr->mflag2 & MFLAG2_KAGE))
2505 return format("¥ì¥Ù¥ë%d, %s%s%s", ap_r_ptr->level, desc, attitude, clone);
2507 return format("Level %d, %s%s%s", ap_r_ptr->level, desc, attitude, clone);
2513 return format("¥ì¥Ù¥ë???, %s%s%s", desc, attitude, clone);
2515 return format("Level ???, %s%s%s", desc, attitude, clone);
2523 * Angband sorting algorithm -- quick sort in place
2525 * Note that the details of the data we are sorting is hidden,
2526 * and we rely on the "ang_sort_comp()" and "ang_sort_swap()"
2527 * function hooks to interact with the data, which is given as
2528 * two pointers, and which may have any user-defined form.
2530 void ang_sort_aux(vptr u, vptr v, int p, int q)
2548 while (!(*ang_sort_comp)(u, v, b, z)) b--;
2551 while (!(*ang_sort_comp)(u, v, z, a)) a++;
2553 /* Done partition */
2557 (*ang_sort_swap)(u, v, a, b);
2563 /* Recurse left side */
2564 ang_sort_aux(u, v, p, b);
2566 /* Recurse right side */
2567 ang_sort_aux(u, v, b+1, q);
2572 * Angband sorting algorithm -- quick sort in place
2574 * Note that the details of the data we are sorting is hidden,
2575 * and we rely on the "ang_sort_comp()" and "ang_sort_swap()"
2576 * function hooks to interact with the data, which is given as
2577 * two pointers, and which may have any user-defined form.
2579 void ang_sort(vptr u, vptr v, int n)
2581 /* Sort the array */
2582 ang_sort_aux(u, v, 0, n-1);
2587 /*** Targeting Code ***/
2591 * Determine is a monster makes a reasonable target
2593 * The concept of "targeting" was stolen from "Morgul" (?)
2595 * The player can target any location, or any "target-able" monster.
2597 * Currently, a monster is "target_able" if it is visible, and if
2598 * the player can hit it with a projection, and the player is not
2599 * hallucinating. This allows use of "use closest target" macros.
2601 * Future versions may restrict the ability to target "trappers"
2602 * and "mimics", but the semantics is a little bit weird.
2604 bool target_able(int m_idx)
2606 monster_type *m_ptr = &m_list[m_idx];
2608 /* Monster must be alive */
2609 if (!m_ptr->r_idx) return (FALSE);
2611 /* Hack -- no targeting hallucinations */
2612 if (p_ptr->image) return (FALSE);
2614 /* Monster must be visible */
2615 if (!m_ptr->ml) return (FALSE);
2617 if (p_ptr->riding && (p_ptr->riding == m_idx)) return (TRUE);
2619 /* Monster must be projectable */
2620 if (!projectable(py, px, m_ptr->fy, m_ptr->fx)) return (FALSE);
2622 /* XXX XXX XXX Hack -- Never target trappers */
2623 /* if (CLEAR_ATTR && (CLEAR_CHAR)) return (FALSE); */
2633 * Update (if necessary) and verify (if possible) the target.
2635 * We return TRUE if the target is "okay" and FALSE otherwise.
2637 bool target_okay(void)
2639 /* Accept stationary targets */
2640 if (target_who < 0) return (TRUE);
2642 /* Check moving targets */
2645 /* Accept reasonable targets */
2646 if (target_able(target_who))
2648 monster_type *m_ptr = &m_list[target_who];
2650 /* Acquire monster location */
2651 target_row = m_ptr->fy;
2652 target_col = m_ptr->fx;
2659 /* Assume no target */
2666 * Sorting hook -- comp function -- by "distance to player"
2668 * We use "u" and "v" to point to arrays of "x" and "y" positions,
2669 * and sort the arrays by double-distance to the player.
2671 static bool ang_sort_comp_distance(vptr u, vptr v, int a, int b)
2673 byte *x = (byte*)(u);
2674 byte *y = (byte*)(v);
2678 /* Absolute distance components */
2679 kx = x[a]; kx -= px; kx = ABS(kx);
2680 ky = y[a]; ky -= py; ky = ABS(ky);
2682 /* Approximate Double Distance to the first point */
2683 da = ((kx > ky) ? (kx + kx + ky) : (ky + ky + kx));
2685 /* Absolute distance components */
2686 kx = x[b]; kx -= px; kx = ABS(kx);
2687 ky = y[b]; ky -= py; ky = ABS(ky);
2689 /* Approximate Double Distance to the first point */
2690 db = ((kx > ky) ? (kx + kx + ky) : (ky + ky + kx));
2692 /* Compare the distances */
2698 * Sorting hook -- swap function -- by "distance to player"
2700 * We use "u" and "v" to point to arrays of "x" and "y" positions,
2701 * and sort the arrays by distance to the player.
2703 static void ang_sort_swap_distance(vptr u, vptr v, int a, int b)
2705 byte *x = (byte*)(u);
2706 byte *y = (byte*)(v);
2724 * Hack -- help "select" a location (see below)
2726 static s16b target_pick(int y1, int x1, int dy, int dx)
2730 int x2, y2, x3, y3, x4, y4;
2732 int b_i = -1, b_v = 9999;
2735 /* Scan the locations */
2736 for (i = 0; i < temp_n; i++)
2742 /* Directed distance */
2746 /* Verify quadrant */
2747 if (dx && (x3 * dx <= 0)) continue;
2748 if (dy && (y3 * dy <= 0)) continue;
2750 /* Absolute distance */
2754 /* Verify quadrant */
2755 if (dy && !dx && (x4 > y4)) continue;
2756 if (dx && !dy && (y4 > x4)) continue;
2758 /* Approximate Double Distance */
2759 v = ((x4 > y4) ? (x4 + x4 + y4) : (y4 + y4 + x4));
2761 /* XXX XXX XXX Penalize location */
2764 if ((b_i >= 0) && (v >= b_v)) continue;
2776 * Hack -- determine if a given location is "interesting"
2778 static bool target_set_accept(int y, int x)
2782 s16b this_o_idx, next_o_idx = 0;
2785 if (!(in_bounds(y, x))) return (FALSE);
2787 /* Player grid is always interesting */
2788 if ((y == py) && (x == px)) return (TRUE);
2791 /* Handle hallucination */
2792 if (p_ptr->image) return (FALSE);
2795 /* Examine the grid */
2796 c_ptr = &cave[y][x];
2798 /* Visible monsters */
2801 monster_type *m_ptr = &m_list[c_ptr->m_idx];
2803 /* Visible monsters */
2804 if (m_ptr->ml) return (TRUE);
2807 /* Scan all objects in the grid */
2808 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
2812 /* Acquire object */
2813 o_ptr = &o_list[this_o_idx];
2815 /* Acquire next object */
2816 next_o_idx = o_ptr->next_o_idx;
2818 /* Memorized object */
2819 if (o_ptr->marked) return (TRUE);
2822 /* Interesting memorized features */
2823 if (c_ptr->info & (CAVE_MARK))
2827 /* Feature code (applying "mimic" field) */
2828 feat = c_ptr->mimic ? c_ptr->mimic : f_info[c_ptr->feat].mimic;
2831 if (c_ptr->info & CAVE_OBJECT) return (TRUE);
2833 /* Notice the Pattern */
2834 if ((feat <= FEAT_PATTERN_XTRA2) &&
2835 (feat >= FEAT_PATTERN_START))
2839 if (feat == FEAT_OPEN) return (TRUE);
2840 if (feat == FEAT_BROKEN) return (TRUE);
2843 if (feat == FEAT_LESS) return (TRUE);
2844 if (feat == FEAT_MORE) return (TRUE);
2845 if (feat == FEAT_LESS_LESS) return (TRUE);
2846 if (feat == FEAT_MORE_MORE) return (TRUE);
2849 if ((feat >= FEAT_SHOP_HEAD) &&
2850 (feat <= FEAT_SHOP_TAIL)) return (TRUE);
2852 if (feat == FEAT_MUSEUM) return (TRUE);
2854 /* Notice buildings -KMW- */
2855 if ((feat >= FEAT_BLDG_HEAD) &&
2856 (feat <= FEAT_BLDG_TAIL)) return (TRUE);
2859 if (is_trap(feat)) return (TRUE);
2862 if ((feat >= FEAT_DOOR_HEAD) &&
2863 (feat <= FEAT_DOOR_TAIL)) return (TRUE);
2867 /* I think FEAT_RUBBLEs should not be "interesting" */
2868 if (feat == FEAT_RUBBLE) return (TRUE);
2870 /* Notice veins with treasure */
2871 /* Now veins with treasure are too many */
2872 if (feat == FEAT_MAGMA_K) return (TRUE);
2873 if (feat == FEAT_QUARTZ_K) return (TRUE);
2876 /* Notice quest features */
2877 if (feat == FEAT_QUEST_ENTER) return (TRUE);
2878 if (feat == FEAT_QUEST_EXIT) return (TRUE);
2879 if (feat == FEAT_QUEST_DOWN) return (TRUE);
2880 if (feat == FEAT_QUEST_UP) return (TRUE);
2881 if (feat == FEAT_TOWN) return (TRUE);
2882 if (feat == FEAT_ENTRANCE) return (TRUE);
2891 * Prepare the "temp" array for "target_set"
2893 * Return the number of target_able monsters in the set.
2895 static void target_set_prepare(int mode)
2899 /* Reset "temp" array */
2902 /* Scan the current panel */
2903 for (y = panel_row_min; y <= panel_row_max; y++)
2905 for (x = panel_col_min; x <= panel_col_max; x++)
2909 /* Require line of sight, unless "look" is "expanded" */
2910 if (!expand_look && !player_has_los_bold(y, x)) continue;
2912 /* Require "interesting" contents */
2913 if (!target_set_accept(y, x)) continue;
2915 c_ptr = &cave[y][x];
2917 /* Require target_able monsters for "TARGET_KILL" */
2918 if ((mode & (TARGET_KILL)) && !target_able(c_ptr->m_idx)) continue;
2920 if ((mode & (TARGET_KILL)) && !target_pet && is_pet(&m_list[c_ptr->m_idx])) continue;
2922 /* Save the location */
2929 /* Set the sort hooks */
2930 ang_sort_comp = ang_sort_comp_distance;
2931 ang_sort_swap = ang_sort_swap_distance;
2933 /* Sort the positions */
2934 ang_sort(temp_x, temp_y, temp_n);
2936 if (p_ptr->riding && target_pet && (temp_n > 1) && (mode & (TARGET_KILL)))
2941 temp_y[0] = temp_y[1];
2944 temp_x[0] = temp_x[1];
2951 * Evaluate number of kill needed to gain level
2953 static void evaluate_monster_exp(char *buf, monster_type *m_ptr)
2955 #define M_INT_GREATER(h1,l1,h2,l2) ( (h1>h2)||( (h1==h2)&&(l1>=l2)))
2956 #define M_INT_SUB(h1,l1, h2,l2) {h1-=h2;if(l1<l2){l1+=0x10000;h1--;}l1-=l2;}
2957 #define M_INT_ADD(h1,l1, h2,l2) {h1+=h2;l1+=l2;if(l1>=0x10000L){l1&=0xFFFF;h1++;}}
2958 #define M_INT_LSHIFT(h1,l1) {h1=(h1<<1)|(l1>>15);l1=(l1<<1)&0xffff;}
2959 #define M_INT_RSHIFT(h1,l1) {l1=(l1>>1)|((h1&1)<<15);h1>>=1;}
2960 #define M_INT_MULT(h1,l1,mul,h2,l2) {l2=(l1*mul)&0xffff;h2=((l1*mul)>>16)+h1*mul;}
2962 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
2966 u32b exp_mon= (ap_r_ptr->mexp)*(ap_r_ptr->level);
2967 u32b exp_mon_h= exp_mon / (p_ptr->max_plv+2);
2968 u32b exp_mon_l= ((exp_mon % (p_ptr->max_plv+2))*0x10000/(p_ptr->max_plv+2))&0xFFFF;
2970 u32b exp_adv_h = player_exp[p_ptr->lev -1] * p_ptr->expfact /100;
2971 u32b exp_adv_l = ((player_exp[p_ptr->lev -1]%100) * p_ptr->expfact *0x10000/100)&0xFFFF;
2973 M_INT_SUB(exp_adv_h, exp_adv_l, p_ptr->exp, p_ptr->exp_frac);
2974 if ((p_ptr->lev>=PY_MAX_LEVEL) || (p_ptr->prace == RACE_ANDROID))
2976 else if (!ap_r_ptr->r_tkills || (m_ptr->mflag2 & MFLAG2_KAGE))
2978 else if (M_INT_GREATER(exp_mon_h, exp_mon_l, exp_adv_h, exp_adv_l))
2982 M_INT_MULT(exp_mon_h, exp_mon_l, 1000,tmp_h, tmp_l);
2983 if( M_INT_GREATER(exp_adv_h, exp_adv_l, tmp_h, tmp_l) )
2988 M_INT_ADD(exp_adv_h, exp_adv_l, exp_mon_h, exp_mon_l);
2989 M_INT_SUB(exp_adv_h, exp_adv_l, 0, 1);
2990 while(M_INT_GREATER(exp_adv_h, exp_adv_l, exp_mon_h,exp_mon_l))
2992 M_INT_LSHIFT(exp_mon_h,exp_mon_l);
2995 M_INT_RSHIFT(exp_mon_h,exp_mon_l);bit>>=1;
2996 for(;bit>=1;bit>>=1)
2998 if(M_INT_GREATER(exp_adv_h,exp_adv_l,exp_mon_h,exp_mon_l))
3001 M_INT_SUB(exp_adv_h,exp_adv_l,exp_mon_h,exp_mon_l);
3003 M_INT_RSHIFT(exp_mon_h,exp_mon_l);
3005 sprintf(buf,"%03d",result);
3012 * Examine a grid, return a keypress.
3014 * The "mode" argument contains the "TARGET_LOOK" bit flag, which
3015 * indicates that the "space" key should scan through the contents
3016 * of the grid, instead of simply returning immediately. This lets
3017 * the "look" command get complete information, without making the
3018 * "target" command annoying.
3020 * The "info" argument contains the "commands" which should be shown
3021 * inside the "[xxx]" text. This string must never be empty, or grids
3022 * containing monsters will be displayed with an extra comma.
3024 * Note that if a monster is in the grid, we update both the monster
3025 * recall info and the health bar info to track that monster.
3027 * Eventually, we may allow multiple objects per grid, or objects
3028 * and terrain features in the same grid. XXX XXX XXX
3030 * This function must handle blindness/hallucination.
3032 static int target_set_aux(int y, int x, int mode, cptr info)
3034 cave_type *c_ptr = &cave[y][x];
3035 s16b this_o_idx, next_o_idx = 0;
3036 cptr s1 = "", s2 = "", s3 = "", x_info = "";
3040 char out_val[MAX_NLEN+80];
3042 #ifdef ALLOW_EASY_FLOOR
3043 int floor_list[23], floor_num = 0;
3045 /* Scan all objects in the grid */
3048 floor_num = scan_floor(floor_list, y, x, 0x02);
3060 #endif /* ALLOW_EASY_FLOOR */
3062 /* Hack -- under the player */
3063 if ((y == py) && (x == px))
3086 /* Hack -- hallucination */
3090 cptr name = "²¿¤«´ñ̯¤Êʪ";
3092 cptr name = "something strange";
3096 /* Display a message */
3098 sprintf(out_val, "%s%s%s%s [%s]", s1, name, s2, s3, info);
3100 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, name, info);
3104 move_cursor_relative(y, x);
3107 /* Stop on everything but "return" */
3108 if ((query != '\r') && (query != '\n')) return query;
3110 /* Repeat forever */
3115 /* Actual monsters */
3116 if (c_ptr->m_idx && m_list[c_ptr->m_idx].ml)
3118 monster_type *m_ptr = &m_list[c_ptr->m_idx];
3119 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
3121 bool recall = FALSE;
3126 /* Get the monster name ("a kobold") */
3127 monster_desc(m_name, m_ptr, 0x08);
3129 /* Hack -- track this monster race */
3130 monster_race_track(m_ptr->ap_r_idx);
3132 /* Hack -- health bar for this monster */
3133 health_track(c_ptr->m_idx);
3135 /* Hack -- handle stuff */
3149 /* Recall on screen */
3150 screen_roff(m_ptr->ap_r_idx, 0);
3152 /* Hack -- Complete the prompt (again) */
3154 Term_addstr(-1, TERM_WHITE, format(" [r»× %s%s]", x_info, info));
3156 Term_addstr(-1, TERM_WHITE, format(" [r,%s%s]", x_info, info));
3165 /* Normal commands */
3166 if (query != 'r') break;
3171 /* Cleare recall text and repeat */
3177 /* Describe, and prompt for recall */
3178 evaluate_monster_exp(acount, m_ptr);
3181 sprintf(out_val, "[%s]%s%s(%s)%s%s [r»× %s%s]", acount, s1, m_name, look_mon_desc(c_ptr->m_idx, 0x01), s2, s3, x_info, info);
3183 sprintf(out_val, "[%s]%s%s%s%s(%s) [r, %s%s]", acount, s1, s2, s3, m_name, look_mon_desc(c_ptr->m_idx, 0x01), x_info, info);
3189 move_cursor_relative(y, x);
3194 /* Normal commands */
3195 if (query != 'r') break;
3201 /* Always stop at "normal" keys */
3202 if ((query != '\r') && (query != '\n') && (query != ' ') && (query != 'x')) return query;
3204 /* Sometimes stop at "space" key */
3205 if ((query == ' ') && !(mode & (TARGET_LOOK))) return query;
3207 /* Change the intro */
3215 /* Hack -- take account of gender */
3217 if (ap_r_ptr->flags1 & (RF1_FEMALE)) s1 = "Èà½÷¤Ï";
3219 if (ap_r_ptr->flags1 & (RF1_FEMALE)) s1 = "She is ";
3223 else if (ap_r_ptr->flags1 & (RF1_MALE)) s1 = "Èà¤Ï";
3225 else if (ap_r_ptr->flags1 & (RF1_MALE)) s1 = "He is ";
3229 /* Use a preposition */
3238 /* Scan all objects being carried */
3239 for (this_o_idx = m_ptr->hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
3241 char o_name[MAX_NLEN];
3245 /* Acquire object */
3246 o_ptr = &o_list[this_o_idx];
3248 /* Acquire next object */
3249 next_o_idx = o_ptr->next_o_idx;
3251 /* Obtain an object description */
3252 object_desc(o_name, o_ptr, TRUE, 3);
3254 /* Describe the object */
3256 sprintf(out_val, "%s%s%s%s[%s]", s1, o_name, s2, s3, info);
3258 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, o_name, info);
3262 move_cursor_relative(y, x);
3265 /* Always stop at "normal" keys */
3266 if ((query != '\r') && (query != '\n') && (query != ' ') && (query != 'x')) return query;
3268 /* Sometimes stop at "space" key */
3269 if ((query == ' ') && !(mode & (TARGET_LOOK))) return query;
3271 /* Change the intro */
3275 s2 = "also carrying ";
3279 /* Use a preposition */
3289 #ifdef ALLOW_EASY_FLOOR
3298 char o_name[MAX_NLEN];
3302 /* Acquire object */
3303 o_ptr = &o_list[floor_list[0]];
3305 /* Describe the object */
3306 object_desc(o_name, o_ptr, TRUE, 3);
3310 sprintf(out_val, "%s%s%s%s[%s]",
3311 s1, o_name, s2, s3, info);
3313 sprintf(out_val, "%s%s%s%s [%s]",
3314 s1, s2, s3, o_name, info);
3318 move_cursor_relative(y, x);
3327 /* Provide one cushion before item listing */
3330 /* Display rough information about items */
3332 sprintf(out_val, "%s %d¸Ä¤Î¥¢¥¤¥Æ¥à%s%s ['x'¤Ç°ìÍ÷, %s]",
3333 s1, floor_num, s2, s3, info);
3335 sprintf(out_val, "%s%s%sa pile of %d items [x,%s]",
3336 s1, s2, s3, floor_num, info);
3340 move_cursor_relative(y, x);
3345 /* No request for listing */
3346 if (query != 'x' && query != ' ') return query;
3350 /** Display list of items **/
3352 /* Continue scrolling list if requested */
3362 (void)show_floor(0, y, x, &min_width);
3366 sprintf(out_val, "%s %d¸Ä¤Î¥¢¥¤¥Æ¥à%s%s [Enter¤Ç¼¡¤Ø, %s]",
3367 s1, floor_num, s2, s3, info);
3369 sprintf(out_val, "%s%s%sa pile of %d items [Enter,%s]",
3370 s1, s2, s3, floor_num, info);
3381 /* Exit unless 'Enter' */
3382 if (query != '\n' && query != '\r')
3387 /* Get the object being moved. */
3388 c_ptr = &cave[y][x];
3389 o_idx = c_ptr->o_idx;
3391 /* Only rotate a pile of two or more objects. */
3392 if (!(o_idx && o_list[o_idx].next_o_idx)) continue;
3394 /* Remove the first object from the list. */
3395 excise_object_idx(o_idx);
3397 /* Find end of the list. */
3399 while (o_list[i].next_o_idx)
3400 i = o_list[i].next_o_idx;
3402 /* Add after the last object. */
3403 o_list[i].next_o_idx = o_idx;
3405 /* Loop and re-display the list */
3411 #endif /* ALLOW_EASY_FLOOR */
3414 /* Scan all objects in the grid */
3415 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
3419 /* Acquire object */
3420 o_ptr = &o_list[this_o_idx];
3422 /* Acquire next object */
3423 next_o_idx = o_ptr->next_o_idx;
3428 char o_name[MAX_NLEN];
3433 /* Obtain an object description */
3434 object_desc(o_name, o_ptr, TRUE, 3);
3436 /* Describe the object */
3438 sprintf(out_val, "%s%s%s%s[%s]", s1, o_name, s2, s3, info);
3440 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, o_name, info);
3444 move_cursor_relative(y, x);
3447 /* Always stop at "normal" keys */
3448 if ((query != '\r') && (query != '\n') && (query != ' ') && (query != 'x')) return query;
3450 /* Sometimes stop at "space" key */
3451 if ((query == ' ') && !(mode & TARGET_LOOK)) return query;
3453 /* Change the intro */
3463 if (o_ptr->number != 1) s1 = "¤½¤ì¤é¤Ï";
3465 if (o_ptr->number != 1) s1 = "They are ";
3481 /* Feature code (applying "mimic" field) */
3482 feat = c_ptr->mimic ? c_ptr->mimic : f_info[c_ptr->feat].mimic;
3484 /* Require knowledge about grid, or ability to see grid */
3485 if (!(c_ptr->info & CAVE_MARK) && !player_can_see_bold(y, x))
3487 /* Forget feature */
3491 /* Terrain feature if needed */
3492 if (boring || (feat > FEAT_INVIS))
3496 /* Hack -- special handling for building doors */
3497 if ((feat >= FEAT_BLDG_HEAD) && (feat <= FEAT_BLDG_TAIL))
3499 name = building[feat - FEAT_BLDG_HEAD].name;
3501 else if (feat == FEAT_ENTRANCE)
3504 name = format("%s(%d³¬ÁêÅö)", d_text + d_info[c_ptr->special].text, d_info[c_ptr->special].mindepth);
3506 name = format("%s(level %d)", d_text + d_info[c_ptr->special].text, d_info[c_ptr->special].mindepth);
3509 else if (feat == FEAT_TOWN)
3511 name = town[c_ptr->special].name;
3513 else if (p_ptr->wild_mode && (feat == FEAT_FLOOR))
3523 name = f_name + f_info[feat].name;
3528 if (*s2 && ((feat >= FEAT_MINOR_GLYPH) &&
3529 (feat <= FEAT_PATTERN_XTRA2)))
3538 else if (*s2 && ((feat >= FEAT_DOOR_HEAD) &&
3539 (feat <= FEAT_PERM_SOLID)))
3548 else if (*s2 && (feat == FEAT_TOWN))
3558 /* Hack -- special introduction for store & building doors -KMW- */
3559 if (((feat >= FEAT_SHOP_HEAD) && (feat <= FEAT_SHOP_TAIL)) ||
3560 ((feat >= FEAT_BLDG_HEAD) && (feat <= FEAT_BLDG_TAIL)) ||
3561 (feat == FEAT_MUSEUM) ||
3562 (feat == FEAT_ENTRANCE))
3571 else if ((feat == FEAT_TOWN) || (feat == FEAT_FLOOR) || (feat == FEAT_DIRT) || (feat == FEAT_FLOWER))
3579 /* Pick proper indefinite article */
3581 s3 = (is_a_vowel(name[0])) ? "an " : "a ";
3585 /* Display a message */
3588 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);
3590 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);
3594 sprintf(out_val, "%s%s%s%s[%s]", s1, name, s2, s3, info);
3596 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, name, info);
3600 move_cursor_relative(y, x);
3603 /* Always stop at "normal" keys */
3604 if ((query != '\r') && (query != '\n') && (query != ' ')) return query;
3607 /* Stop on everything but "return" */
3608 if ((query != '\r') && (query != '\n')) return query;
3610 /* Repeat forever */
3616 * Handle "target" and "look".
3618 * Note that this code can be called from "get_aim_dir()".
3620 * All locations must be on the current panel. Consider the use of
3621 * "panel_bounds()" to allow "off-panel" targets, perhaps by using
3622 * some form of "scrolling" the map around the cursor. XXX XXX XXX
3623 * That is, consider the possibility of "auto-scrolling" the screen
3624 * while the cursor moves around. This may require changes in the
3625 * "update_mon()" code to allow "visibility" even if off panel, and
3626 * may require dynamic recalculation of the "temp" grid set.
3628 * Hack -- targeting/observing an "outer border grid" may induce
3629 * problems, so this is not currently allowed.
3631 * The player can use the direction keys to move among "interesting"
3632 * grids in a heuristic manner, or the "space", "+", and "-" keys to
3633 * move through the "interesting" grids in a sequential manner, or
3634 * can enter "location" mode, and use the direction keys to move one
3635 * grid at a time in any direction. The "t" (set target) command will
3636 * only target a monster (as opposed to a location) if the monster is
3637 * target_able and the "interesting" mode is being used.
3639 * The current grid is described using the "look" method above, and
3640 * a new command may be entered at any time, but note that if the
3641 * "TARGET_LOOK" bit flag is set (or if we are in "location" mode,
3642 * where "space" has no obvious meaning) then "space" will scan
3643 * through the description of the current grid until done, instead
3644 * of immediately jumping to the next "interesting" grid. This
3645 * allows the "target" command to retain its old semantics.
3647 * The "*", "+", and "-" keys may always be used to jump immediately
3648 * to the next (or previous) interesting grid, in the proper mode.
3650 * The "return" key may always be used to scan through a complete
3651 * grid description (forever).
3653 * This command will cancel any old target, even if used from
3654 * inside the "look" command.
3656 bool target_set(int mode)
3676 get_screen_size(&wid, &hgt);
3682 /* Cancel tracking */
3683 /* health_track(0); */
3686 /* Prepare the "temp" array */
3687 target_set_prepare(mode);
3689 /* Start near the player */
3695 /* Interesting grids */
3701 if (!(mode & TARGET_LOOK)) prt_path(y, x);
3704 c_ptr = &cave[y][x];
3707 if (target_able(c_ptr->m_idx))
3710 strcpy(info, "q»ß t·è p¼« o¸½ +¼¡ -Á°");
3712 strcpy(info, "q,t,p,o,+,-,<dir>");
3717 /* Dis-allow target */
3721 strcpy(info, "q»ß p¼« o¸½ +¼¡ -Á°");
3723 strcpy(info, "q,p,o,+,-,<dir>");
3728 /* Describe and Prompt */
3729 while (!(query = target_set_aux(y, x, mode, info)));
3731 /* Cancel tracking */
3732 /* health_track(0); */
3734 /* Assume no "direction" */
3739 if (query == '\r') query = 't';
3757 if (target_able(c_ptr->m_idx))
3759 health_track(c_ptr->m_idx);
3760 target_who = c_ptr->m_idx;
3779 if (!expand_list) done = TRUE;
3789 if (!expand_list) done = TRUE;
3796 /* Recenter the map around the player */
3800 p_ptr->update |= (PU_MONSTERS);
3803 p_ptr->redraw |= (PR_MAP);
3806 p_ptr->window |= (PW_OVERHEAD);
3811 /* Recalculate interesting grids */
3812 target_set_prepare(mode);
3831 /* Extract the action (if any) */
3832 d = get_keymap_dir(query);
3839 /* Hack -- move around */
3842 /* Modified to scroll to monster */
3843 int y2 = panel_row_min;
3844 int x2 = panel_col_min;
3846 /* Find a new monster */
3847 i = target_pick(temp_y[m], temp_x[m], ddy[d], ddx[d]);
3849 /* Request to target past last interesting grid */
3850 while (flag && (i < 0))
3852 /* Note the change */
3853 if (change_panel(ddy[d], ddx[d]))
3858 /* Recalculate interesting grids */
3859 target_set_prepare(mode);
3861 /* Look at interesting grids */
3864 /* Find a new monster */
3865 i = target_pick(v, u, ddy[d], ddx[d]);
3871 /* Nothing interesting */
3877 /* Restore previous position */
3880 panel_bounds_center();
3883 p_ptr->update |= (PU_MONSTERS);
3886 p_ptr->redraw |= (PR_MAP);
3889 p_ptr->window |= (PW_OVERHEAD);
3894 /* Recalculate interesting grids */
3895 target_set_prepare(mode);
3897 /* Look at boring grids */
3904 /* Do not move horizontally if unnecessary */
3905 if (((x < panel_col_min + wid / 2) && (dx > 0)) ||
3906 ((x > panel_col_min + wid / 2) && (dx < 0)))
3911 /* Do not move vertically if unnecessary */
3912 if (((y < panel_row_min + hgt / 2) && (dy > 0)) ||
3913 ((y > panel_row_min + hgt / 2) && (dy < 0)))
3918 /* Apply the motion */
3919 if ((y >= panel_row_min+hgt) || (y < panel_row_min) ||
3920 (x >= panel_col_min+wid) || (x < panel_col_min))
3922 if (change_panel(dy, dx)) target_set_prepare(mode);
3925 /* Slide into legality */
3926 if (x >= cur_wid-1) x = cur_wid - 2;
3927 else if (x <= 0) x = 1;
3929 /* Slide into legality */
3930 if (y >= cur_hgt-1) y = cur_hgt- 2;
3931 else if (y <= 0) y = 1;
3940 /* Arbitrary grids */
3943 bool move_fast = FALSE;
3945 if (!(mode & TARGET_LOOK)) prt_path(y, x);
3948 c_ptr = &cave[y][x];
3950 /* Default prompt */
3952 strcpy(info, "q»ß t·è p¼« m¶á +¼¡ -Á°");
3954 strcpy(info, "q,t,p,m,+,-,<dir>");
3958 /* Describe and Prompt (enable "TARGET_LOOK") */
3959 while (!(query = target_set_aux(y, x, mode | TARGET_LOOK, info)));
3961 /* Cancel tracking */
3962 /* health_track(0); */
3964 /* Assume no direction */
3969 if (query == '\r') query = 't';
3972 /* Analyze the keypress */
3996 /* Recenter the map around the player */
4000 p_ptr->update |= (PU_MONSTERS);
4003 p_ptr->redraw |= (PR_MAP);
4006 p_ptr->window |= (PW_OVERHEAD);
4011 /* Recalculate interesting grids */
4012 target_set_prepare(mode);
4034 /* Pick a nearby monster */
4035 for (i = 0; i < temp_n; i++)
4037 t = distance(y, x, temp_y[i], temp_x[i]);
4047 /* Nothing interesting */
4048 if (bd == 999) flag = FALSE;
4055 /* Extract the action (if any) */
4056 d = get_keymap_dir(query);
4058 /* XTRA HACK MOVEFAST */
4059 if (isupper(query)) move_fast = TRUE;
4066 /* Handle "direction" */
4072 /* XTRA HACK MOVEFAST */
4075 int mag = MIN(wid / 2, hgt / 2);
4085 /* Do not move horizontally if unnecessary */
4086 if (((x < panel_col_min + wid / 2) && (dx > 0)) ||
4087 ((x > panel_col_min + wid / 2) && (dx < 0)))
4092 /* Do not move vertically if unnecessary */
4093 if (((y < panel_row_min + hgt / 2) && (dy > 0)) ||
4094 ((y > panel_row_min + hgt / 2) && (dy < 0)))
4099 /* Apply the motion */
4100 if ((y >= panel_row_min + hgt) || (y < panel_row_min) ||
4101 (x >= panel_col_min + wid) || (x < panel_col_min))
4103 if (change_panel(dy, dx)) target_set_prepare(mode);
4106 /* Slide into legality */
4107 if (x >= cur_wid-1) x = cur_wid - 2;
4108 else if (x <= 0) x = 1;
4110 /* Slide into legality */
4111 if (y >= cur_hgt-1) y = cur_hgt- 2;
4112 else if (y <= 0) y = 1;
4120 /* Clear the top line */
4123 /* Recenter the map around the player */
4127 p_ptr->update |= (PU_MONSTERS);
4130 p_ptr->redraw |= (PR_MAP);
4133 p_ptr->window |= (PW_OVERHEAD);
4138 /* Failure to set target */
4139 if (!target_who) return (FALSE);
4147 * Get an "aiming direction" from the user.
4149 * The "dir" is loaded with 1,2,3,4,6,7,8,9 for "actual direction", and
4150 * "0" for "current target", and "-1" for "entry aborted".
4152 * Note that "Force Target", if set, will pre-empt user interaction,
4153 * if there is a usable target already set.
4155 * Note that confusion over-rides any (explicit?) user choice.
4157 bool get_aim_dir(int *dp)
4168 /* Global direction */
4171 /* Hack -- auto-target if requested */
4172 if (use_old_target && target_okay()) dir = 5;
4174 #ifdef ALLOW_REPEAT /* TNB */
4176 if (repeat_pull(dp))
4181 if (!(*dp == 5 && !target_okay()))
4183 /* return (TRUE); */
4188 #endif /* ALLOW_REPEAT -- TNB */
4190 /* Ask until satisfied */
4193 /* Choose a prompt */
4197 p = "Êý¸þ ('*'¤Ç¥¿¡¼¥²¥Ã¥ÈÁªÂò, ESC¤ÇÃæÃÇ)? ";
4199 p = "Direction ('*' to choose a target, Escape to cancel)? ";
4206 p = "Êý¸þ ('5'¤Ç¥¿¡¼¥²¥Ã¥È¤Ø, '*'¤Ç¥¿¡¼¥²¥Ã¥ÈºÆÁªÂò, ESC¤ÇÃæÃÇ)? ";
4208 p = "Direction ('5' for target, '*' to re-target, Escape to cancel)? ";
4213 /* Get a command (or Cancel) */
4214 if (!get_com(p, &command, TRUE)) break;
4218 if (command == '\r') command = 't';
4221 /* Convert various keys to "standard" keys */
4224 /* Use current target */
4235 /* Set new target */
4240 if (target_set(TARGET_KILL)) dir = 5;
4246 /* Extract the action (if any) */
4247 dir = get_keymap_dir(command);
4253 /* Verify requested targets */
4254 if ((dir == 5) && !target_okay()) dir = 0;
4263 project_length = 0; /* reset to default */
4267 /* Save the direction */
4270 /* Check for confusion */
4271 if (p_ptr->confused)
4274 /* Random direction */
4275 dir = ddd[randint0(8)];
4278 /* Notice confusion */
4279 if (command_dir != dir)
4283 msg_print("¤¢¤Ê¤¿¤Ïº®Í𤷤Ƥ¤¤ë¡£");
4285 msg_print("You are confused.");
4290 /* Save direction */
4293 #ifdef ALLOW_REPEAT /* TNB */
4295 /* repeat_push(dir); */
4296 repeat_push(command_dir);
4298 #endif /* ALLOW_REPEAT -- TNB */
4300 /* A "valid" direction was entered */
4307 * Request a "movement" direction (1,2,3,4,6,7,8,9) from the user,
4308 * and place it into "command_dir", unless we already have one.
4310 * This function should be used for all "repeatable" commands, such as
4311 * run, walk, open, close, bash, disarm, spike, tunnel, etc, as well
4312 * as all commands which must reference a grid adjacent to the player,
4313 * and which may not reference the grid under the player. Note that,
4314 * for example, it is no longer possible to "disarm" or "open" chests
4315 * in the same grid as the player.
4317 * Direction "5" is illegal and will (cleanly) abort the command.
4319 * This function tracks and uses the "global direction", and uses
4320 * that as the "desired direction", to which "confusion" is applied.
4322 bool get_rep_dir(int *dp, bool under)
4329 /* Global direction */
4332 #ifdef ALLOW_REPEAT /* TNB */
4334 if (repeat_pull(dp))
4337 /* return (TRUE); */
4340 #endif /* ALLOW_REPEAT -- TNB */
4342 /* Get a direction */
4347 /* Get a command (or Cancel) */
4349 if (!get_com("Êý¸þ (ESC¤ÇÃæÃÇ)? ", &ch, TRUE)) break;
4351 if (!get_com("Direction (Escape to cancel)? ", &ch, TRUE)) break;
4355 /* Look up the direction */
4356 dir = get_keymap_dir(ch);
4362 /* Prevent weirdness */
4363 if ((dir == 5) && (!under)) dir = 0;
4366 if (!dir) return (FALSE);
4368 /* Save desired direction */
4371 /* Apply "confusion" */
4372 if (p_ptr->confused)
4374 /* Standard confusion */
4375 if (randint0(100) < 75)
4377 /* Random direction */
4378 dir = ddd[randint0(8)];
4381 else if (p_ptr->riding)
4383 monster_type *m_ptr = &m_list[p_ptr->riding];
4384 monster_race *r_ptr = &r_info[m_ptr->r_idx];
4386 if (m_ptr->confused)
4388 /* Standard confusion */
4389 if (randint0(100) < 75)
4391 /* Random direction */
4392 dir = ddd[randint0(8)];
4395 else if ((r_ptr->flags1 & RF1_RAND_50) && (r_ptr->flags1 & RF1_RAND_25) && (randint0(100) < 50))
4397 /* Random direction */
4398 dir = ddd[randint0(8)];
4400 else if ((r_ptr->flags1 & RF1_RAND_50) && (randint0(100) < 25))
4402 /* Random direction */
4403 dir = ddd[randint0(8)];
4407 /* Notice confusion */
4408 if (command_dir != dir)
4410 if (p_ptr->confused)
4414 msg_print("¤¢¤Ê¤¿¤Ïº®Í𤷤Ƥ¤¤ë¡£");
4416 msg_print("You are confused.");
4422 monster_type *m_ptr = &m_list[p_ptr->riding];
4424 monster_desc(m_name, m_ptr, 0);
4425 if (m_ptr->confused)
4428 msg_format("%s¤Ïº®Í𤷤Ƥ¤¤ë¡£", m_name);
4430 msg_format("%^s is confusing.", m_name);
4437 msg_format("%s¤Ï»×¤¤Ä̤ê¤ËÆ°¤¤¤Æ¤¯¤ì¤Ê¤¤¡£", m_name);
4439 msg_format("You cannot control %s.", m_name);
4445 /* Save direction */
4448 #ifdef ALLOW_REPEAT /* TNB */
4450 /* repeat_push(dir); */
4451 repeat_push(command_dir);
4453 #endif /* ALLOW_REPEAT -- TNB */
4460 bool get_rep_dir2(int *dp)
4467 /* Global direction */
4470 #ifdef ALLOW_REPEAT /* TNB */
4472 if (repeat_pull(dp))
4475 /* return (TRUE); */
4478 #endif /* ALLOW_REPEAT -- TNB */
4480 /* Get a direction */
4485 /* Get a command (or Cancel) */
4487 if (!get_com("Êý¸þ (ESC¤ÇÃæÃÇ)? ", &ch, TRUE)) break;
4489 if (!get_com("Direction (Escape to cancel)? ", &ch, TRUE)) break;
4493 /* Look up the direction */
4494 dir = get_keymap_dir(ch);
4500 /* Prevent weirdness */
4501 if (dir == 5) dir = 0;
4504 if (!dir) return (FALSE);
4506 /* Save desired direction */
4509 /* Apply "confusion" */
4510 if (p_ptr->confused)
4512 /* Standard confusion */
4513 if (randint0(100) < 75)
4515 /* Random direction */
4516 dir = ddd[randint0(8)];
4520 /* Notice confusion */
4521 if (command_dir != dir)
4525 msg_print("¤¢¤Ê¤¿¤Ïº®Í𤷤Ƥ¤¤ë¡£");
4527 msg_print("You are confused.");
4532 /* Save direction */
4535 #ifdef ALLOW_REPEAT /* TNB */
4537 /* repeat_push(dir); */
4538 repeat_push(command_dir);
4540 #endif /* ALLOW_REPEAT -- TNB */
4547 int get_chaos_patron(void)
4549 return ((p_ptr->age + p_ptr->sc) % MAX_PATRON);
4553 void gain_level_reward(int chosen_reward)
4557 char wrath_reason[32] = "";
4558 int nasty_chance = 6;
4559 int dummy = 0, dummy2 = 0;
4562 char o_name[MAX_NLEN];
4568 if (multi_rew) return;
4569 else multi_rew = TRUE;
4573 if (p_ptr->lev == 13) nasty_chance = 2;
4574 else if (!(p_ptr->lev % 13)) nasty_chance = 3;
4575 else if (!(p_ptr->lev % 14)) nasty_chance = 12;
4577 if (one_in_(nasty_chance))
4578 type = randint1(20); /* Allow the 'nasty' effects */
4580 type = randint1(15) + 5; /* Or disallow them */
4582 if (type < 1) type = 1;
4583 if (type > 20) type = 20;
4588 sprintf(wrath_reason, "%s¤ÎÅܤê",
4589 chaos_patrons[p_ptr->chaos_patron]);
4591 sprintf(wrath_reason, "the Wrath of %s",
4592 chaos_patrons[p_ptr->chaos_patron]);
4596 effect = chaos_rewards[p_ptr->chaos_patron][type];
4598 if (one_in_(6) && !chosen_reward)
4601 msg_format("%^s¤ÏË«Èþ¤È¤·¤Æ¤¢¤Ê¤¿¤òÆÍÁ³ÊÑ°Û¤µ¤»¤¿¡£",
4602 chaos_patrons[p_ptr->chaos_patron]);
4604 msg_format("%^s rewards you with a mutation!",
4605 chaos_patrons[p_ptr->chaos_patron]);
4608 (void)gain_random_mutation(0);
4610 reward = "ÊÑ°Û¤·¤¿¡£";
4612 reward = "mutation";
4617 switch (chosen_reward ? chosen_reward : effect)
4621 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
4622 chaos_patrons[p_ptr->chaos_patron]);
4624 msg_format("The voice of %s booms out:",
4625 chaos_patrons[p_ptr->chaos_patron]);
4629 msg_print("¡ÖÆò¡¢¿·¤¿¤Ê¤ë»Ñ¤òɬÍפȤ»¤ê¡ª¡×");
4631 msg_print("'Thou needst a new form, mortal!'");
4636 reward = "ÊÑ°Û¤·¤¿¡£";
4638 reward = "polymorphing";
4643 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
4644 chaos_patrons[p_ptr->chaos_patron]);
4646 msg_format("The voice of %s booms out:",
4647 chaos_patrons[p_ptr->chaos_patron]);
4651 msg_print("¡ÖÆò¤ÏÎɤ¯¹Ô¤¤¤¿¤ê¡ªÂ³¤±¤è¡ª¡×");
4653 msg_print("'Well done, mortal! Lead on!'");
4656 if (p_ptr->prace == RACE_ANDROID)
4659 msg_print("¤·¤«¤·²¿¤âµ¯¤³¤é¤Ê¤«¤Ã¤¿¡£");
4661 msg_print("But, nothing happen.");
4664 else if (p_ptr->exp < PY_MAX_EXP)
4666 s32b ee = (p_ptr->exp / 2) + 10;
4667 if (ee > 100000L) ee = 100000L;
4669 msg_print("¹¹¤Ë·Ð¸³¤òÀѤó¤À¤è¤¦¤Êµ¤¤¬¤¹¤ë¡£");
4671 msg_print("You feel more experienced.");
4676 reward = "·Ð¸³ÃͤòÆÀ¤¿";
4678 reward = "experience";
4684 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
4685 chaos_patrons[p_ptr->chaos_patron]);
4687 msg_format("The voice of %s booms out:",
4688 chaos_patrons[p_ptr->chaos_patron]);
4692 msg_print("¡Ö²¼Ëͤ衢Æò¤½¤ì¤ËÃͤ»¤º¡£¡×");
4694 msg_print("'Thou didst not deserve that, slave.'");
4697 if (p_ptr->prace == RACE_ANDROID)
4700 msg_print("¤·¤«¤·²¿¤âµ¯¤³¤é¤Ê¤«¤Ã¤¿¡£");
4702 msg_print("But, nothing happen.");
4707 lose_exp(p_ptr->exp / 6);
4709 reward = "·Ð¸³Ãͤò¼º¤Ã¤¿¡£";
4711 reward = "losing experience";
4717 msg_format("%s¤ÎÀ¼¤¬¤µ¤µ¤ä¤¤¤¿:",
4718 chaos_patrons[p_ptr->chaos_patron]);
4720 msg_format("The voice of %s whispers:",
4721 chaos_patrons[p_ptr->chaos_patron]);
4725 msg_print("¡Ö²æ¤¬Í¿¤¨¤·Êª¤ò¸ÌÀ¤Ë»È¤¦¤Ù¤·¡£¡×");
4727 msg_print("'Use my gift wisely.'");
4730 acquirement(py, px, 1, FALSE, FALSE);
4732 reward = "¾å¼Á¤Ê¥¢¥¤¥Æ¥à¤ò¼ê¤ËÆþ¤ì¤¿¡£";
4734 reward = "a good item";
4739 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
4740 chaos_patrons[p_ptr->chaos_patron]);
4742 msg_format("The voice of %s booms out:",
4743 chaos_patrons[p_ptr->chaos_patron]);
4747 msg_print("¡Ö²æ¤¬Í¿¤¨¤·Êª¤ò¸ÌÀ¤Ë»È¤¦¤Ù¤·¡£¡×");
4749 msg_print("'Use my gift wisely.'");
4752 acquirement(py, px, 1, TRUE, FALSE);
4754 reward = "¹âµéÉʤΥ¢¥¤¥Æ¥à¤ò¼ê¤ËÆþ¤ì¤¿¡£";
4756 reward = "an excellent item";
4761 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
4762 chaos_patrons[p_ptr->chaos_patron]);
4764 msg_format("The voice of %s booms out:",
4765 chaos_patrons[p_ptr->chaos_patron]);
4769 msg_print("¡ÖÆò¤Î¹Ô¤¤¤Ïµ®¤·õ¤ËÃͤ»¤ê¡£¡×");
4771 msg_print("'Thy deed hath earned thee a worthy blade.'");
4774 /* Get local object */
4777 switch (randint1(p_ptr->lev))
4783 dummy2 = SV_MAIN_GAUCHE;
4792 dummy2 = SV_SMALL_SWORD;
4795 dummy2 = SV_BASILLARD;
4797 case 11: case 12: case 13:
4798 dummy2 = SV_SHORT_SWORD;
4804 dummy2 = SV_CUTLASS;
4807 dummy2 = SV_WAKIZASHI;
4810 dummy2 = SV_KHOPESH;
4816 dummy2 = SV_BROAD_SWORD;
4819 dummy2 = SV_LONG_SWORD;
4822 dummy2 = SV_SCIMITAR;
4825 dummy2 = SV_NINJATO;
4831 dummy2 = SV_BASTARD_SWORD;
4834 dummy2 = SV_GREAT_SCIMITAR;
4837 dummy2 = SV_CLAYMORE;
4840 dummy2 = SV_ESPADON;
4843 dummy2 = SV_TWO_HANDED_SWORD;
4846 dummy2 = SV_FLAMBERGE;
4849 dummy2 = SV_NO_DACHI;
4852 dummy2 = SV_EXECUTIONERS_SWORD;
4855 dummy2 = SV_ZWEIHANDER;
4858 dummy2 = SV_HAYABUSA;
4861 dummy2 = SV_BLADE_OF_CHAOS;
4864 object_prep(q_ptr, lookup_kind(dummy, dummy2));
4865 q_ptr->to_h = 3 + randint1(dun_level) % 10;
4866 q_ptr->to_d = 3 + randint1(dun_level) % 10;
4867 one_resistance(q_ptr);
4868 q_ptr->name2 = EGO_CHAOTIC;
4870 /* Drop it in the dungeon */
4871 (void)drop_near(q_ptr, -1, py, px);
4873 reward = "(º®ÆÙ)¤ÎÉð´ï¤ò¼ê¤ËÆþ¤ì¤¿¡£";
4875 reward = "chaos weapon";
4880 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
4881 chaos_patrons[p_ptr->chaos_patron]);
4883 msg_format("The voice of %s booms out:",
4884 chaos_patrons[p_ptr->chaos_patron]);
4888 msg_print("¡ÖÆò¤Î¹Ô¤¤¤Ïµ®¤Ê󤤤ËÃͤ»¤ê¡£¡×");
4890 msg_print("'Thy deed hath earned thee a worthy reward.'");
4893 acquirement(py, px, randint1(2) + 1, FALSE, FALSE);
4895 reward = "¾å¼Á¤Ê¥¢¥¤¥Æ¥à¤ò¼ê¤ËÆþ¤ì¤¿¡£";
4897 reward = "good items";
4902 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
4903 chaos_patrons[p_ptr->chaos_patron]);
4905 msg_format("The voice of %s booms out:",
4906 chaos_patrons[p_ptr->chaos_patron]);
4910 msg_print("¡Ö²¼Ëͤ衢Æò¤Î¸¥¿È¤Ø¤Î²æ¤¬Àˤ·¤ß̵¤Ê󤤤ò¸«¤ë¤¬¤è¤¤¡£¡×");
4912 msg_print("'Behold, mortal, how generously I reward thy loyalty.'");
4915 acquirement(py, px, randint1(2) + 1, TRUE, FALSE);
4917 reward = "¹âµéÉʤΥ¢¥¤¥Æ¥à¤ò¼ê¤ËÆþ¤ì¤¿¡£";
4919 reward = "excellent items";
4924 msg_format("%s¤ÎÀ¼¤¬¹ì¤ÅϤä¿:",
4925 chaos_patrons[p_ptr->chaos_patron]);
4927 msg_format("The voice of %s thunders:",
4928 chaos_patrons[p_ptr->chaos_patron]);
4932 msg_print("¡Ö²¼Ëͤ衢ÆòÐþËý¤Ê¤ê¡£¡×");
4934 msg_print("'Thou art growing arrogant, mortal.'");
4937 (void)activate_ty_curse(FALSE, &count);
4939 reward = "²Ò¡¹¤·¤¤¼ö¤¤¤ò¤«¤±¤é¤ì¤¿¡£";
4946 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
4947 chaos_patrons[p_ptr->chaos_patron]);
4949 msg_format("The voice of %s booms out:",
4950 chaos_patrons[p_ptr->chaos_patron]);
4954 msg_print("¡Ö²æ¤¬²¼Ëͤ¿¤Á¤è¡¢¤«¤ÎÐþËý¤Ê¤ë¼Ô¤òÅݤ¹¤Ù¤·¡ª¡×");
4956 msg_print("'My pets, destroy the arrogant mortal!'");
4959 for (dummy = 0; dummy < randint1(5) + 1; dummy++)
4961 (void)summon_specific(0, py, px, dun_level, 0, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET));
4964 reward = "¥â¥ó¥¹¥¿¡¼¤ò¾¤´¤µ¤ì¤¿¡£";
4966 reward = "summoning hostile monsters";
4971 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
4972 chaos_patrons[p_ptr->chaos_patron]);
4974 msg_format("The voice of %s booms out:",
4975 chaos_patrons[p_ptr->chaos_patron]);
4979 msg_print("¡ÖÆò¡¢¤è¤ê¶¯¤Å¨¤òɬÍפȤ»¤ê¡ª¡×");
4981 msg_print("'Thou needst worthier opponents!'");
4984 activate_hi_summon(py, px, FALSE);
4986 reward = "¥â¥ó¥¹¥¿¡¼¤ò¾¤´¤µ¤ì¤¿¡£";
4988 reward = "summoning many hostile monsters";
4993 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
4994 chaos_patrons[p_ptr->chaos_patron]);
4996 msg_format("The voice of %s booms out:",
4997 chaos_patrons[p_ptr->chaos_patron]);
5001 msg_print("¡Ö»à¤ÈÇ˲õ¤³¤½²æ¤¬´î¤Ó¤Ê¤ê¡ª¡×");
5003 msg_print("'Death and destruction! This pleaseth me!'");
5008 reward = "¥«¥ª¥¹¤ÎÎϤ¬±²´¬¤¤¤¿¡£";
5010 reward = "calling chaos";
5015 msg_format("%s¤ÎÀ¼¤¬ÌĤê¶Á¤¤¤¿:",
5016 chaos_patrons[p_ptr->chaos_patron]);
5018 msg_format("The voice of %s rings out:",
5019 chaos_patrons[p_ptr->chaos_patron]);
5023 msg_print("¡Öα¤Þ¤ë¤Î¤À¡¢²¼Ëͤ衣;¤¬Æò¤ÎÆùÂΤòÃ䨤󡣡×");
5025 msg_print("'Stay, mortal, and let me mold thee.'");
5028 if (one_in_(3) && !(chaos_stats[p_ptr->chaos_patron] < 0))
5029 do_inc_stat(chaos_stats[p_ptr->chaos_patron]);
5031 do_inc_stat(randint0(6));
5033 reward = "ǽÎÏÃͤ¬¾å¤¬¤Ã¤¿¡£";
5035 reward = "increasing a stat";
5040 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5041 chaos_patrons[p_ptr->chaos_patron]);
5043 msg_format("The voice of %s booms out:",
5044 chaos_patrons[p_ptr->chaos_patron]);
5048 msg_print("¡Ö²¼Ëͤ衢;¤ÏÆò¤ËË°¤ß¤¿¤ê¡£¡×");
5050 msg_print("'I grow tired of thee, mortal.'");
5053 if (one_in_(3) && !(chaos_stats[p_ptr->chaos_patron] < 0))
5054 do_dec_stat(chaos_stats[p_ptr->chaos_patron]);
5056 (void)do_dec_stat(randint0(6));
5058 reward = "ǽÎÏÃͤ¬²¼¤¬¤Ã¤¿¡£";
5060 reward = "decreasing a stat";
5065 msg_format("%s¤ÎÀ¼¤¬¹ì¤ÅϤä¿:",
5066 chaos_patrons[p_ptr->chaos_patron]);
5068 msg_format("The voice of %s thunders:",
5069 chaos_patrons[p_ptr->chaos_patron]);
5073 msg_print("¡ÖÆò¡¢¸¬µõ¤¿¤ë¤³¤È¤ò³Ø¤Ö¤Ù¤·¡ª¡×");
5074 msg_print("¤¢¤Ê¤¿¤Ï°ÊÁ°¤è¤ê¼å¤¯¤Ê¤Ã¤¿¡ª");
5076 msg_print("'Thou needst a lesson in humility, mortal!'");
5077 msg_print("You feel less powerful!");
5080 for (dummy = 0; dummy < 6; dummy++)
5082 (void)dec_stat(dummy, 10 + randint1(15), TRUE);
5085 reward = "Á´Ç½ÎÏÃͤ¬²¼¤¬¤Ã¤¿¡£";
5087 reward = "decreasing all stats";
5092 msg_format("%s¤ÎÎϤ¬¿¨¤ì¤ë¤Î¤ò´¶¤¸¤¿¡£",
5094 msg_format("You feel the power of %s touch you.",
5097 chaos_patrons[p_ptr->chaos_patron]);
5100 reward = "½ý¤¬ÊѲ½¤·¤¿¡£";
5102 reward = "polymorphing wounds";
5107 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5108 chaos_patrons[p_ptr->chaos_patron]);
5110 msg_format("The voice of %s booms out:",
5111 chaos_patrons[p_ptr->chaos_patron]);
5115 msg_print("¡Ö²æ¤¬¤µ¤µ¤ä¤«¤Ê¤ë»òʪ¤ò¼õ¤±¤È¤ë¤¬¤è¤¤¡ª¡×");
5117 msg_print("'Receive this modest gift from me!'");
5120 for (dummy = 0; dummy < 6; dummy++)
5122 (void)do_inc_stat(dummy);
5125 reward = "Á´Ç½ÎÏÃͤ¬¾å¤¬¤Ã¤¿¡£";
5127 reward = "increasing all stats";
5132 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5133 chaos_patrons[p_ptr->chaos_patron]);
5135 msg_format("The voice of %s booms out:",
5136 chaos_patrons[p_ptr->chaos_patron]);
5140 msg_print("¡Ö¶ì¤·¤à¤¬¤è¤¤¡¢ÌµÇ½¤Ê¶ò¤«¼Ô¤è¡ª¡×");
5142 msg_print("'Suffer, pathetic fool!'");
5145 fire_ball(GF_DISINTEGRATE, 0, p_ptr->lev * 4, 4);
5146 take_hit(DAMAGE_NOESCAPE, p_ptr->lev * 4, wrath_reason, -1);
5148 reward = "ʬ²ò¤Îµå¤¬È¯À¸¤·¤¿¡£";
5150 reward = "generating disintegration ball";
5155 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5156 chaos_patrons[p_ptr->chaos_patron]);
5158 msg_format("The voice of %s booms out:",
5159 chaos_patrons[p_ptr->chaos_patron]);
5163 msg_print("¡Öᴤ뤬¤è¤¤¡¢²æ¤¬²¼Ëͤ衪¡×");
5165 msg_print("'Rise, my servant!'");
5169 (void)set_poisoned(0);
5171 (void)set_confused(0);
5176 for (dummy = 0; dummy < 6; dummy++)
5178 (void)do_res_stat(dummy);
5181 reward = "ÂÎÎϤ¬²óÉü¤·¤¿¡£";
5187 if (!buki_motteruka(INVEN_RARM)) break;
5189 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5190 chaos_patrons[p_ptr->chaos_patron]);
5192 msg_format("The voice of %s booms out:",
5193 chaos_patrons[p_ptr->chaos_patron]);
5197 msg_print("¡ÖÆò¡¢Éð´ï¤ËÍê¤ë¤³¤È¤Ê¤«¤ì¡£¡×");
5199 msg_print("'Thou reliest too much on thy weapon.'");
5202 object_desc(o_name, &inventory[INVEN_RARM], TRUE, 0);
5203 (void)curse_weapon(FALSE, INVEN_RARM);
5205 reward = format("%s¤¬Ç˲õ¤µ¤ì¤¿¡£", o_name);
5207 reward = format("destroying %s", o_name);
5211 if (!inventory[INVEN_BODY].k_idx) break;
5213 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5214 chaos_patrons[p_ptr->chaos_patron]);
5216 msg_format("The voice of %s booms out:",
5217 chaos_patrons[p_ptr->chaos_patron]);
5221 msg_print("¡ÖÆò¡¢Ëɶñ¤ËÍê¤ë¤³¤È¤Ê¤«¤ì¡£¡×");
5223 msg_print("'Thou reliest too much on thine equipment.'");
5226 object_desc(o_name, &inventory[INVEN_BODY], TRUE, 0);
5227 (void)curse_armor();
5229 reward = format("%s¤¬Ç˲õ¤µ¤ì¤¿¡£", o_name);
5231 reward = format("destroying %s", o_name);
5236 msg_format("%s¤ÎÀ¼¤¬¤µ¤µ¤ä¤¤¤¿:",
5237 chaos_patrons[p_ptr->chaos_patron]);
5239 msg_format("The voice of %s whispers:",
5240 chaos_patrons[p_ptr->chaos_patron]);
5244 msg_print("¡Ö²æ¤òÅܤꤷ¤á¤¿ºá¤ò½þ¤¦¤Ù¤·¡£¡×");
5246 msg_print("'Now thou shalt pay for annoying me.'");
5249 switch (randint1(4))
5252 (void)activate_ty_curse(FALSE, &count);
5254 reward = "²Ò¡¹¤·¤¤¼ö¤¤¤ò¤«¤±¤é¤ì¤¿¡£";
5260 activate_hi_summon(py, px, FALSE);
5262 reward = "¥â¥ó¥¹¥¿¡¼¤ò¾¤´¤µ¤ì¤¿¡£";
5264 reward = "summoning hostile monsters";
5270 if (!buki_motteruka(INVEN_RARM)) break;
5271 object_desc(o_name, &inventory[INVEN_RARM], TRUE, 0);
5272 (void)curse_weapon(FALSE, INVEN_RARM);
5274 reward = format("%s¤¬Ç˲õ¤µ¤ì¤¿¡£", o_name);
5276 reward = format("destroying %s", o_name);
5281 if (!inventory[INVEN_BODY].k_idx) break;
5282 object_desc(o_name, &inventory[INVEN_BODY], TRUE, 0);
5283 (void)curse_armor();
5285 reward = format("%s¤¬Ç˲õ¤µ¤ì¤¿¡£", o_name);
5287 reward = format("destroying %s", o_name);
5292 for (dummy = 0; dummy < 6; dummy++)
5294 (void)dec_stat(dummy, 10 + randint1(15), TRUE);
5297 reward = "Á´Ç½ÎÏÃͤ¬²¼¤¬¤Ã¤¿¡£";
5299 reward = "decreasing all stats";
5306 msg_format("%s¤ÎÀ¼¤¬¹ì¤ÅϤä¿:",
5308 msg_format("The voice of %s thunders:",
5311 chaos_patrons[p_ptr->chaos_patron]);
5313 msg_print("¡Ö»à¤Ì¤¬¤è¤¤¡¢²¼Ëͤ衪¡×");
5315 msg_print("'Die, mortal!'");
5318 take_hit(DAMAGE_LOSELIFE, p_ptr->lev * 4, wrath_reason, -1);
5319 for (dummy = 0; dummy < 6; dummy++)
5321 (void)dec_stat(dummy, 10 + randint1(15), FALSE);
5323 activate_hi_summon(py, px, FALSE);
5324 (void)activate_ty_curse(FALSE, &count);
5325 if (one_in_(2)) (void)curse_weapon(FALSE, INVEN_RARM);
5326 if (one_in_(2)) (void)curse_armor();
5330 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5331 chaos_patrons[p_ptr->chaos_patron]);
5333 msg_format("The voice of %s booms out:",
5334 chaos_patrons[p_ptr->chaos_patron]);
5338 msg_print("¡Ö»à¤ÈÇ˲õ¤³¤½²æ¤¬´î¤Ó¤Ê¤ê¡ª¡×");
5340 msg_print("'Death and destruction! This pleaseth me!'");
5343 destroy_area(py, px, 25);
5345 reward = "¥À¥ó¥¸¥ç¥ó¤¬*Ç˲õ*¤µ¤ì¤¿¡£";
5347 reward = "*destruct*ing dungeon";
5352 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5353 chaos_patrons[p_ptr->chaos_patron]);
5355 msg_format("The voice of %s booms out:",
5356 chaos_patrons[p_ptr->chaos_patron]);
5360 msg_print("¡Ö²æ¡¢Æò¤ÎŨ¤òËõ»¦¤»¤ó¡ª¡×");
5362 msg_print("'Let me relieve thee of thine oppressors!'");
5365 (void)symbol_genocide(0, FALSE);
5367 reward = "¥â¥ó¥¹¥¿¡¼¤¬Ëõ»¦¤µ¤ì¤¿¡£";
5369 reward = "genociding monsters";
5374 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5375 chaos_patrons[p_ptr->chaos_patron]);
5377 msg_format("The voice of %s booms out:",
5378 chaos_patrons[p_ptr->chaos_patron]);
5382 msg_print("¡Ö²æ¡¢Æò¤ÎŨ¤òËõ»¦¤»¤ó¡ª¡×");
5384 msg_print("'Let me relieve thee of thine oppressors!'");
5387 (void)mass_genocide(0, FALSE);
5389 reward = "¥â¥ó¥¹¥¿¡¼¤¬Ëõ»¦¤µ¤ì¤¿¡£";
5391 reward = "genociding nearby monsters";
5396 msg_format("%s¤ÎÎϤ¬Å¨¤ò¹¶·â¤¹¤ë¤Î¤ò´¶¤¸¤¿¡ª",
5397 chaos_patrons[p_ptr->chaos_patron]);
5399 msg_format("You can feel the power of %s assault your enemies!",
5400 chaos_patrons[p_ptr->chaos_patron]);
5403 (void)dispel_monsters(p_ptr->lev * 4);
5407 msg_format("%s¤Ï¤¢¤Ê¤¿¤ò̵»ë¤·¤¿¡£",
5408 chaos_patrons[p_ptr->chaos_patron]);
5410 msg_format("%s ignores you.",
5411 chaos_patrons[p_ptr->chaos_patron]);
5417 msg_format("%s¤ÏË«Èþ¤È¤·¤Æ°Ëâ¤Î»È¤¤¤ò¤è¤³¤·¤¿¡ª",chaos_patrons[p_ptr->chaos_patron]);
5419 msg_format("%s rewards you with a demonic servant!",chaos_patrons[p_ptr->chaos_patron]);
5422 if (!summon_specific(-1, py, px, dun_level, SUMMON_DEMON, PM_FORCE_PET))
5424 msg_print("²¿¤â¸½¤ì¤Ê¤«¤Ã¤¿...");
5426 msg_print("Nobody ever turns up...");
5430 reward = "°Ë⤬¥Ú¥Ã¥È¤Ë¤Ê¤Ã¤¿¡£";
5432 reward = "a demonic servant";
5438 msg_format("%s¤ÏË«Èþ¤È¤·¤Æ»È¤¤¤ò¤è¤³¤·¤¿¡ª",chaos_patrons[p_ptr->chaos_patron]);
5440 msg_format("%s rewards you with a servant!",chaos_patrons[p_ptr->chaos_patron]);
5443 if (!summon_specific(-1, py, px, dun_level, 0, PM_FORCE_PET))
5445 msg_print("²¿¤â¸½¤ì¤Ê¤«¤Ã¤¿...");
5447 msg_print("Nobody ever turns up...");
5451 reward = "¥â¥ó¥¹¥¿¡¼¤¬¥Ú¥Ã¥È¤Ë¤Ê¤Ã¤¿¡£";
5453 reward = "a servant";
5459 msg_format("%s¤ÏË«Èþ¤È¤·¤Æ¥¢¥ó¥Ç¥Ã¥É¤Î»È¤¤¤ò¤è¤³¤·¤¿¡£",chaos_patrons[p_ptr->chaos_patron]);
5461 msg_format("%s rewards you with an undead servant!",chaos_patrons[p_ptr->chaos_patron]);
5464 if (!summon_specific(-1, py, px, dun_level, SUMMON_UNDEAD, PM_FORCE_PET))
5466 msg_print("²¿¤â¸½¤ì¤Ê¤«¤Ã¤¿...");
5468 msg_print("Nobody ever turns up...");
5472 reward = "¥¢¥ó¥Ç¥Ã¥É¤¬¥Ú¥Ã¥È¤Ë¤Ê¤Ã¤¿¡£";
5474 reward = "an undead servant";
5480 msg_format("%s¤ÎÀ¼¤¬¤É¤â¤Ã¤¿:",
5482 msg_format("The voice of %s stammers:",
5485 chaos_patrons[p_ptr->chaos_patron]);
5487 msg_format("¡Ö¤¢¡¼¡¢¤¢¡¼¡¢Åú¤¨¤Ï %d/%d¡£¼ÁÌä¤Ï²¿¡©¡×", type, effect);
5489 msg_format("'Uh... uh... the answer's %d/%d, what's the question?'", type, effect);
5497 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, format("¥Ñ¥È¥í¥ó¤ÎÊó½·¤Ç%s", reward));
5499 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, format("The patron rewards you with %s.", reward));
5506 * old -- from PsiAngband.
5508 bool tgt_pt(int *x_ptr, int *y_ptr)
5512 bool success = FALSE;
5517 get_screen_size(&wid, &hgt);
5523 msg_print("¾ì½ê¤òÁª¤ó¤Ç¥¹¥Ú¡¼¥¹¥¡¼¤ò²¡¤·¤Æ²¼¤µ¤¤¡£");
5525 msg_print("Select a point and press space.");
5527 msg_flag = FALSE; /* prevents "-more-" message. */
5529 while ((ch != ESCAPE) && !success)
5531 bool move_fast = FALSE;
5533 move_cursor_relative(y, x);
5545 if (x == px && y == py) ch = 0;
5548 else success = TRUE;
5552 /* Look up the direction */
5553 d = get_keymap_dir(ch);
5555 /* XTRA HACK MOVEFAST */
5556 if (isupper(ch)) move_fast = TRUE;
5558 /* Handle "direction" */
5564 /* XTRA HACK MOVEFAST */
5567 int mag = MIN(wid / 2, hgt / 2);
5577 /* Do not move horizontally if unnecessary */
5578 if (((x < panel_col_min + wid / 2) && (dx > 0)) ||
5579 ((x > panel_col_min + wid / 2) && (dx < 0)))
5584 /* Do not move vertically if unnecessary */
5585 if (((y < panel_row_min + hgt / 2) && (dy > 0)) ||
5586 ((y > panel_row_min + hgt / 2) && (dy < 0)))
5591 /* Apply the motion */
5592 if ((y >= panel_row_min + hgt) || (y < panel_row_min) ||
5593 (x >= panel_col_min + wid) || (x < panel_col_min))
5595 /* if (change_panel(dy, dx)) target_set_prepare(mode); */
5596 change_panel(dy, dx);
5599 /* Slide into legality */
5600 if (x >= cur_wid-1) x = cur_wid - 2;
5601 else if (x <= 0) x = 1;
5603 /* Slide into legality */
5604 if (y >= cur_hgt-1) y = cur_hgt- 2;
5605 else if (y <= 0) y = 1;
5612 /* Clear the top line */
5615 /* Recenter the map around the player */
5619 p_ptr->update |= (PU_MONSTERS);
5622 p_ptr->redraw |= (PR_MAP);
5625 p_ptr->window |= (PW_OVERHEAD);
5636 bool get_hack_dir(int *dp)
5646 /* Global direction */
5649 /* (No auto-targeting) */
5651 /* Ask until satisfied */
5654 /* Choose a prompt */
5658 p = "Êý¸þ ('*'¤Ç¥¿¡¼¥²¥Ã¥ÈÁªÂò, ESC¤ÇÃæÃÇ)? ";
5660 p = "Direction ('*' to choose a target, Escape to cancel)? ";
5667 p = "Êý¸þ ('5'¤Ç¥¿¡¼¥²¥Ã¥È¤Ø, '*'¤Ç¥¿¡¼¥²¥Ã¥ÈºÆÁªÂò, ESC¤ÇÃæÃÇ)? ";
5669 p = "Direction ('5' for target, '*' to re-target, Escape to cancel)? ";
5674 /* Get a command (or Cancel) */
5675 if (!get_com(p, &command, TRUE)) break;
5679 if (command == '\r') command = 't';
5682 /* Convert various keys to "standard" keys */
5685 /* Use current target */
5696 /* Set new target */
5701 if (target_set(TARGET_KILL)) dir = 5;
5707 /* Look up the direction */
5708 dir = get_keymap_dir(command);
5714 /* Verify requested targets */
5715 if ((dir == 5) && !target_okay()) dir = 0;
5722 if (!dir) return (FALSE);
5724 /* Save the direction */
5727 /* Check for confusion */
5728 if (p_ptr->confused)
5731 /* Random direction */
5732 dir = ddd[randint0(8)];
5735 /* Notice confusion */
5736 if (command_dir != dir)
5740 msg_print("¤¢¤Ê¤¿¤Ïº®Í𤷤Ƥ¤¤ë¡£");
5742 msg_print("You are confused.");
5747 /* Save direction */
5750 /* A "valid" direction was entered */
5756 * ¥¨¥Í¥ë¥®¡¼¤ÎÁý²ÃÎÌ10d5¤ò®¤¯·×»»¤¹¤ë¤¿¤á¤Î´Ø¿ô
5759 #define Go_no_JuuJou 5*5*5*5*5*5*5*5*5*5
5761 s16b gain_energy(void)
5764 s32b energy_result = 10;
5767 tmp = randint0(Go_no_JuuJou);
5769 for (i = 0; i < 9; i ++){
5770 energy_result += tmp % 5;
5774 return (s16b)(energy_result + tmp);
5781 s16b bow_energy(int sval)
5785 /* Analyze the launcher */
5788 /* Sling and ammo */
5795 /* Short Bow and Arrow */
5802 /* Long Bow and Arrow */
5809 /* Bow of irresponsiblity and Arrow */
5816 /* Light Crossbow and Bolt */
5823 /* Heavy Crossbow and Bolt */
5838 int bow_tmul(int sval)
5842 /* Analyze the launcher */
5845 /* Sling and ammo */
5852 /* Short Bow and Arrow */
5859 /* Long Bow and Arrow */
5866 /* Bow of irresponsiblity and Arrow */
5873 /* Light Crossbow and Bolt */
5880 /* Heavy Crossbow and Bolt */
5892 * Return alignment title
5894 cptr your_alignment(void)
5897 if (p_ptr->align > 150) return "ÂçÁ±";
5898 else if (p_ptr->align > 50) return "ÃæÁ±";
5899 else if (p_ptr->align > 10) return "¾®Á±";
5900 else if (p_ptr->align > -11) return "ÃæΩ";
5901 else if (p_ptr->align > -51) return "¾®°";
5902 else if (p_ptr->align > -151) return "Ãæ°";
5905 if (p_ptr->align > 150) return "Lawful";
5906 else if (p_ptr->align > 50) return "Good";
5907 else if (p_ptr->align > 10) return "Neutral Good";
5908 else if (p_ptr->align > -11) return "Neutral";
5909 else if (p_ptr->align > -51) return "Neutral Evil";
5910 else if (p_ptr->align > -151) return "Evil";
5911 else return "Chaotic";
5917 * Return proficiency level of weapons and misc. skills (except riding)
5919 int weapon_exp_level(int weapon_exp)
5921 if (weapon_exp < WEAPON_EXP_BEGINNER) return EXP_LEVEL_UNSKILLED;
5922 else if (weapon_exp < WEAPON_EXP_SKILLED) return EXP_LEVEL_BEGINNER;
5923 else if (weapon_exp < WEAPON_EXP_EXPERT) return EXP_LEVEL_SKILLED;
5924 else if (weapon_exp < WEAPON_EXP_MASTER) return EXP_LEVEL_EXPERT;
5925 else return EXP_LEVEL_MASTER;
5930 * Return proficiency level of riding
5932 int riding_exp_level(int riding_exp)
5934 if (riding_exp < RIDING_EXP_BEGINNER) return EXP_LEVEL_UNSKILLED;
5935 else if (riding_exp < RIDING_EXP_SKILLED) return EXP_LEVEL_BEGINNER;
5936 else if (riding_exp < RIDING_EXP_EXPERT) return EXP_LEVEL_SKILLED;
5937 else if (riding_exp < RIDING_EXP_MASTER) return EXP_LEVEL_EXPERT;
5938 else return EXP_LEVEL_MASTER;
5943 * Return proficiency level of spells
5945 int spell_exp_level(int spell_exp)
5947 if (spell_exp < SPELL_EXP_BEGINNER) return EXP_LEVEL_UNSKILLED;
5948 else if (spell_exp < SPELL_EXP_SKILLED) return EXP_LEVEL_BEGINNER;
5949 else if (spell_exp < SPELL_EXP_EXPERT) return EXP_LEVEL_SKILLED;
5950 else if (spell_exp < SPELL_EXP_MASTER) return EXP_LEVEL_EXPERT;
5951 else return EXP_LEVEL_MASTER;