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);
1055 /* Mega-Hack -- drop "winner" treasures */
1058 if (m_ptr->r_idx == MON_SERPENT)
1060 /* Get local object */
1063 /* Mega-Hack -- Prepare to make "Grond" */
1064 object_prep(q_ptr, lookup_kind(TV_HAFTED, SV_GROND));
1066 /* Mega-Hack -- Mark this item as "Grond" */
1067 q_ptr->name1 = ART_GROND;
1069 /* Mega-Hack -- Actually create "Grond" */
1070 apply_magic(q_ptr, -1, TRUE, TRUE, TRUE, FALSE);
1072 /* Drop it in the dungeon */
1073 (void)drop_near(q_ptr, -1, y, x);
1075 /* Get local object */
1078 /* Mega-Hack -- Prepare to make "Chaos" */
1079 object_prep(q_ptr, lookup_kind(TV_CROWN, SV_CHAOS));
1081 /* Mega-Hack -- Mark this item as "Chaos" */
1082 q_ptr->name1 = ART_CHAOS;
1084 /* Mega-Hack -- Actually create "Chaos" */
1085 apply_magic(q_ptr, -1, TRUE, TRUE, TRUE, FALSE);
1087 /* Drop it in the dungeon */
1088 (void)drop_near(q_ptr, -1, y, x);
1095 switch (m_ptr->r_idx)
1110 case MON_UNICORN_ORD:
1113 if (p_ptr->pseikaku == SEIKAKU_NAMAKE)
1117 switch (randint0(3))
1120 a_idx = ART_NAMAKE_HAMMER;
1123 a_idx = ART_NAMAKE_BOW;
1126 a_idx = ART_NAMAKE_ARMOR;
1130 while (a_info[a_idx].cur_num);
1141 case MON_STORMBRINGER:
1142 a_idx = ART_STORMBRINGER;
1147 a_idx = ART_CRIMSON;
1157 a_idx = ART_KUSANAGI;
1187 a_idx = ART_WEREWINDLE;
1195 a_idx = ART_GRAYSWANDIR;
1206 a_idx = ART_TWILIGHT;
1211 a_idx = ART_ELENDIL;
1226 a_idx = ART_DESTINY;
1231 a_idx = ART_ZANTETSU;
1246 a_idx = ART_WINBLOWS;
1250 case MON_LUNGORTHIN:
1255 case MON_JACK_SHADOWS:
1261 a_idx = ART_STONEMASK;
1266 a_idx = ART_SOULCRUSH;
1271 a_idx = ART_EXCALIBUR_J;
1276 a_idx = ART_SHUTEN_DOJI;
1281 a_idx = ART_GOTHMOG;
1291 if ((a_idx > 0) && ((randint0(100) < chance) || (p_ptr->wizard)))
1293 if (a_info[a_idx].cur_num == 0)
1295 /* Create the artifact */
1296 create_named_art(a_idx, y, x);
1298 a_info[a_idx].cur_num = 1;
1304 if ((r_ptr->flags7 & RF7_GUARDIAN) && !p_ptr->inside_battle && (d_info[dungeon_type].final_guardian == m_ptr->r_idx) && !cloned)
1306 int k_idx = lookup_kind(TV_SCROLL, SV_SCROLL_ACQUIREMENT); /* Acquirement */;
1308 if (d_info[dungeon_type].final_object)
1309 k_idx = d_info[dungeon_type].final_object;
1311 if (d_info[dungeon_type].final_artifact)
1313 int a_idx = d_info[dungeon_type].final_artifact;
1314 if (a_info[a_idx].cur_num == 0)
1316 /* Create the artifact */
1317 create_named_art(a_idx, y, x);
1319 a_info[a_idx].cur_num = 1;
1326 /* Get local object */
1329 /* Prepare to make a reward */
1330 object_prep(q_ptr, k_idx);
1332 apply_magic(q_ptr, object_level, FALSE, TRUE, FALSE, FALSE);
1334 /* Drop it in the dungeon */
1335 (void)drop_near(q_ptr, -1, y, x);
1338 msg_format("¤¢¤Ê¤¿¤Ï%s¤òÀ©ÇƤ·¤¿¡ª",d_name+d_info[dungeon_type].name);
1340 msg_format("You have conquered %s!",d_name+d_info[dungeon_type].name);
1344 /* Determine how much we can drop */
1345 if ((r_ptr->flags1 & RF1_DROP_60) && (randint0(100) < 60)) number++;
1346 if ((r_ptr->flags1 & RF1_DROP_90) && (randint0(100) < 90)) number++;
1347 if (r_ptr->flags1 & RF1_DROP_1D2) number += damroll(1, 2);
1348 if (r_ptr->flags1 & RF1_DROP_2D2) number += damroll(2, 2);
1349 if (r_ptr->flags1 & RF1_DROP_3D2) number += damroll(3, 2);
1350 if (r_ptr->flags1 & RF1_DROP_4D2) number += damroll(4, 2);
1352 if (cloned && !(r_ptr->flags1 & RF1_UNIQUE))
1353 number = 0; /* Clones drop no stuff unless Cloning Pits */
1355 if (is_pet(m_ptr) || p_ptr->inside_battle || p_ptr->inside_arena)
1356 number = 0; /* Pets drop no stuff */
1357 if (!drop_item && (r_ptr->d_char != '$')) number = 0;
1359 /* Hack -- handle creeping coins */
1360 coin_type = force_coin;
1362 /* Average dungeon and monster levels */
1363 object_level = (dun_level + r_ptr->level) / 2;
1365 /* Drop some objects */
1366 for (j = 0; j < number; j++)
1368 /* Get local object */
1371 /* Wipe the object */
1375 if (do_gold && (!do_item || (randint0(100) < 50)))
1377 /* Make some gold */
1378 if (!make_gold(q_ptr)) continue;
1387 /* Make an object */
1388 if (!make_object(q_ptr, good, great)) continue;
1394 /* Drop it in the dungeon */
1395 (void)drop_near(q_ptr, -1, y, x);
1398 /* Reset the object level */
1399 object_level = base_level;
1401 /* Reset "coin" type */
1405 /* Take note of any dropped treasure */
1406 if (visible && (dump_item || dump_gold))
1408 /* Take notes on treasure */
1409 lore_treasure(m_idx, dump_item, dump_gold);
1412 /* Only process "Quest Monsters" */
1413 if (!(r_ptr->flags1 & RF1_QUESTOR)) return;
1414 if (p_ptr->inside_battle) return;
1417 if (m_ptr->r_idx == MON_SERPENT)
1420 p_ptr->total_winner = TRUE;
1422 /* Redraw the "title" */
1423 p_ptr->redraw |= (PR_TITLE);
1426 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, "¸«»ö¤ËÊѶòÈÚÅܤξ¡Íø¼Ô¤È¤Ê¤Ã¤¿¡ª");
1428 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, "become *WINNER* of Hengband finely!");
1431 if (p_ptr->pclass == CLASS_CHAOS_WARRIOR)
1434 msg_format("%s¤«¤é¤ÎÀ¼¤¬¶Á¤¤¤¿¡£", chaos_patrons[p_ptr->chaos_patron]);
1435 msg_print("¡Ø¤è¤¯¤ä¤Ã¤¿¡¢ÄêÌ¿¤Î¼Ô¤è¡ª¡Ù");
1437 msg_format("The voice of %s booms out:", chaos_patrons[p_ptr->chaos_patron]);
1438 msg_print("'Thou art donst well, mortal!'");
1442 /* Congratulations */
1444 msg_print("*** ¤ª¤á¤Ç¤È¤¦ ***");
1446 msg_print("*** CONGRATULATIONS ***");
1450 msg_print("¤¢¤Ê¤¿¤Ï¥²¡¼¥à¤ò¥³¥ó¥×¥ê¡¼¥È¤·¤Þ¤·¤¿¡£");
1452 msg_print("You have won the game!");
1456 msg_print("½àÈ÷¤¬À°¤Ã¤¿¤é°úÂà(¼«»¦¥³¥Þ¥ó¥É)¤·¤Æ¤â·ë¹½¤Ç¤¹¡£");
1458 msg_print("You may retire (commit suicide) when you are ready.");
1465 * Modify the physical damage done to the monster.
1466 * (for example when it's invulnerable or shielded)
1468 * ToDo: Accept a damage-type to calculate the modified damage from
1469 * things like fire, frost, lightning, poison, ... attacks.
1471 * "type" is not yet used and should be 0.
1473 int mon_damage_mod(monster_type *m_ptr, int dam, bool is_psy_spear)
1475 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1477 if ((r_ptr->flags3 & RF3_RES_ALL) && dam > 0)
1480 if((dam == 0) && one_in_(3)) dam = 1;
1483 if (m_ptr->invulner)
1487 if(!p_ptr->blind && m_ptr->ml)
1490 msg_print("¥Ð¥ê¥¢¤òÀÚ¤êÎö¤¤¤¿¡ª");
1492 msg_print("The barrier is penetrated!");
1496 else if (!one_in_(PENETRATE_INVULNERABILITY))
1504 static void get_exp_from_mon(int dam, monster_type *m_ptr)
1506 s32b div, new_exp, new_exp_frac;
1507 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1508 int monnum_penarty = 0;
1510 if (!m_ptr->r_idx) return;
1511 if (is_pet(m_ptr) || p_ptr->inside_battle) return;
1515 u32b m_exp_h, m_exp_l;
1517 if ((r_ptr->flags2 & RF2_MULTIPLY) || (m_ptr->r_idx == MON_DAWN))
1519 monnum_penarty = r_ptr->r_pkills / 400;
1520 if (monnum_penarty > 8) monnum_penarty = 8;
1522 if (r_ptr->flags1 & RF1_UNIQUE)
1524 m_exp = (long)r_ptr->mexp * r_ptr->level;
1525 div = (p_ptr->max_plv+2);
1529 m_exp = (long)r_ptr->mexp * r_ptr->level * SPEED_TO_ENERGY(m_ptr->mspeed);
1530 div = (p_ptr->max_plv+2) * SPEED_TO_ENERGY(r_ptr->speed);
1532 m_exp_h = m_exp/0x10000L;
1533 m_exp_l = m_exp%0x10000L;
1536 m_exp_h += m_exp_l / 0x10000L;
1537 m_exp_l %= 0x10000L;
1539 /* real monster maxhp have effect on EXP */
1540 if(!(r_ptr->flags1 & RF1_FORCE_MAXHP))
1542 u32b maxhp = m_ptr->max_maxhp*2;
1545 m_exp_h += m_exp_l / 0x10000L;
1546 m_exp_l %= 0x10000L;
1548 div *= r_ptr->hdice * (r_ptr->hside + 1);
1550 if (!dun_level && (!(r_ptr->flags8 & RF8_WILD_ONLY) || !(r_ptr->flags1 & RF1_UNIQUE))) div *= 5;
1551 div_h = div/0x10000L;
1552 div_l = div%0x10000L;
1553 div_h *= (m_ptr->max_maxhp*2);
1554 div_l *= (m_ptr->max_maxhp*2);
1555 div_h += div_l / 0x10000L;
1558 while (monnum_penarty)
1562 div_h += div_l / 0x10000L;
1567 m_exp_l = (0x7fffffff & (m_exp_h << 16)) | m_exp_l;
1568 m_exp_h = m_exp_h >> 15;
1569 div_l = (0x7fffffff & (div_h << 16)) | div_l;
1570 div_h = div_h >> 15;
1572 #define M_INT_GREATER63(h1,l1,h2,l2) ( (h1>h2)||( (h1==h2)&&(l1>=l2)))
1573 #define M_INT_SUB63(h1,l1, h2,l2) {h1-=h2;if(l1<l2){l1+=0x80000000;h1--;}l1-=l2;}
1574 #define M_INT_LSHIFT63(h1,l1) {h1=(h1<<1)|(l1>>30);l1=(l1<<1)&0x7fffffff;}
1575 #define M_INT_RSHIFT63(h1,l1) {l1=(l1>>1)|(h1<<30);h1>>=1;}
1576 #define M_INT_DIV63(h1,l1,h2,l2,result) \
1580 while( M_INT_GREATER63(h1,l1, h2, l2) ){M_INT_LSHIFT63(h2, l2); bit<<=1;} \
1581 for(bit>>=1; bit>=1; bit>>=1){ \
1582 M_INT_RSHIFT63(h2, l2); \
1583 if(M_INT_GREATER63(h1, l1, h2, l2)) \
1584 {result|=bit;M_INT_SUB63(h1, l1, h2, l2);} \
1588 /* Give some experience for the kill */
1589 M_INT_DIV63(m_exp_h, m_exp_l, div_h, div_l, new_exp);
1591 /* Handle fractional experience */
1592 /* multiply 0x10000L to remainder */
1593 m_exp_h = (m_exp_h<<16) | (m_exp_l>>15);
1595 M_INT_DIV63(m_exp_h, m_exp_l, div_h, div_l, new_exp_frac);
1596 new_exp_frac += p_ptr->exp_frac;
1597 /* Keep track of experience */
1598 if (new_exp_frac >= 0x10000L)
1601 p_ptr->exp_frac = (u16b)(new_exp_frac - 0x10000L);
1605 p_ptr->exp_frac = (u16b)new_exp_frac;
1608 /* Gain experience */
1616 * Decreases monsters hit points, handling monster death.
1618 * We return TRUE if the monster has been killed (and deleted).
1620 * We announce monster death (using an optional "death message"
1621 * if given, and a otherwise a generic killed/destroyed message).
1623 * Only "physical attacks" can induce the "You have slain" message.
1624 * Missile and Spell attacks will induce the "dies" message, or
1625 * various "specialized" messages. Note that "You have destroyed"
1626 * and "is destroyed" are synonyms for "You have slain" and "dies".
1628 * Hack -- unseen monsters yield "You have killed it." message.
1630 * Added fear (DGK) and check whether to print fear messages -CWS
1632 * Made name, sex, and capitalization generic -BEN-
1634 * As always, the "ghost" processing is a total hack.
1636 * Hack -- we "delay" fear messages by passing around a "fear" flag.
1638 * XXX XXX XXX Consider decreasing monster experience over time, say,
1639 * by using "(m_exp * m_lev * (m_lev)) / (p_lev * (m_lev + n_killed))"
1640 * instead of simply "(m_exp * m_lev) / (p_lev)", to make the first
1641 * monster worth more than subsequent monsters. This would also need
1642 * to induce changes in the monster recall code.
1644 bool mon_take_hit(int m_idx, int dam, bool *fear, cptr note)
1646 monster_type *m_ptr = &m_list[m_idx];
1647 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1649 monster_type exp_mon;
1651 /* Innocent until proven otherwise */
1652 bool innocent = TRUE, thief = FALSE;
1656 COPY(&exp_mon, m_ptr, monster_type);
1657 if (!(r_ptr->flags7 & RF7_KILL_EXP))
1659 expdam = (m_ptr->hp > dam) ? dam : m_ptr->hp;
1660 if (r_ptr->flags6 & RF6_HEAL) expdam = (expdam+1) * 2 / 3;
1662 get_exp_from_mon(expdam, &exp_mon);
1665 /* Redraw (later) if needed */
1666 if (p_ptr->health_who == m_idx) p_ptr->redraw |= (PR_HEALTH);
1667 if (p_ptr->riding == m_idx) p_ptr->redraw |= (PR_UHEALTH);
1672 /* Hack - Cancel any special player stealth magics. -LM- */
1673 if (p_ptr->special_defense & NINJA_S_STEALTH)
1675 set_superstealth(FALSE);
1681 /* It is dead now */
1686 if (r_info[m_ptr->r_idx].flags7 & RF7_TANUKI)
1688 /* You might have unmasked Tanuki first time */
1689 r_ptr = &r_info[m_ptr->r_idx];
1690 m_ptr->ap_r_idx = m_ptr->r_idx;
1691 if (r_ptr->r_sights < MAX_SHORT) r_ptr->r_sights++;
1694 if (m_ptr->mflag2 & MFLAG2_CHAMELEON)
1696 /* You might have unmasked Chameleon first time */
1697 r_ptr = real_r_ptr(m_ptr);
1698 if (r_ptr->r_sights < MAX_SHORT) r_ptr->r_sights++;
1701 /* When the player kills a Unique, it stays dead */
1702 if (r_ptr->flags1 & RF1_UNIQUE && !(m_ptr->smart & SM_CLONED))
1705 /* When the player kills a Nazgul, it stays dead */
1706 if (r_ptr->flags7 & RF7_UNIQUE_7) r_ptr->max_num--;
1708 /* Recall even invisible uniques or winners */
1709 if (m_ptr->ml || (r_ptr->flags1 & RF1_UNIQUE))
1711 /* Count kills this life */
1712 if ((m_ptr->mflag2 & MFLAG2_KAGE) && (r_info[MON_KAGE].r_pkills < MAX_SHORT)) r_info[MON_KAGE].r_pkills++;
1713 else if (r_ptr->r_pkills < MAX_SHORT) r_ptr->r_pkills++;
1715 /* Count kills in all lives */
1716 if ((m_ptr->mflag2 & MFLAG2_KAGE) && (r_info[MON_KAGE].r_tkills < MAX_SHORT)) r_info[MON_KAGE].r_tkills++;
1717 else if (r_ptr->r_tkills < MAX_SHORT) r_ptr->r_tkills++;
1719 /* Hack -- Auto-recall */
1720 monster_race_track(m_ptr->ap_r_idx);
1723 /* Extract monster name */
1724 monster_desc(m_name, m_ptr, 0x100);
1726 /* Don't kill Amberites */
1727 if ((r_ptr->flags3 & RF3_AMBERITE) && one_in_(2))
1729 int curses = 1 + randint1(3);
1730 bool stop_ty = FALSE;
1734 msg_format("%^s¤Ï¶²¤í¤·¤¤·ì¤Î¼ö¤¤¤ò¤¢¤Ê¤¿¤Ë¤«¤±¤¿¡ª", m_name);
1736 msg_format("%^s puts a terrible blood curse on you!", m_name);
1739 curse_equipment(100, 50);
1743 stop_ty = activate_ty_curse(stop_ty, &count);
1748 if (r_ptr->flags2 & RF2_CAN_SPEAK)
1750 char line_got[1024];
1752 /* Dump a message */
1754 if (!get_rnd_line("mondeath_j.txt", m_ptr->r_idx, line_got))
1756 if (!get_rnd_line("mondeath.txt", m_ptr->r_idx, line_got))
1759 msg_format("%^s %s", m_name, line_got);
1762 if (m_ptr->r_idx == MON_SERPENT)
1764 /* Make screen dump */
1765 screen_dump = make_screen_dump();
1770 if (!(d_info[dungeon_type].flags1 & DF1_BEGINNER))
1772 if (!dun_level && !ambush_flag && !p_ptr->inside_arena)
1774 chg_virtue(V_VALOUR, -1);
1776 else if (r_ptr->level > dun_level)
1778 if (randint1(10) <= (r_ptr->level - dun_level))
1779 chg_virtue(V_VALOUR, 1);
1781 if (r_ptr->level > 60)
1783 chg_virtue(V_VALOUR, 1);
1785 if (r_ptr->level >= 2 * (p_ptr->lev+1))
1786 chg_virtue(V_VALOUR, 2);
1789 if ((r_ptr->flags1 & RF1_UNIQUE) && ((r_ptr->flags3 & RF3_EVIL) ||
1790 (r_ptr->flags3 & RF3_GOOD)))
1792 chg_virtue(V_HARMONY, 2);
1794 if ((r_ptr->flags1 & RF1_UNIQUE) && (r_ptr->flags3 & RF3_GOOD))
1796 chg_virtue(V_UNLIFE, 2);
1797 chg_virtue(V_VITALITY, -2);
1800 if ((r_ptr->flags1 & RF1_UNIQUE) && one_in_(3))
1801 chg_virtue(V_INDIVIDUALISM, -1);
1803 if (m_ptr->r_idx == MON_BEGGAR || m_ptr->r_idx == MON_LEPER)
1805 chg_virtue(V_COMPASSION, -1);
1808 if ((r_ptr->flags3 & RF3_GOOD) &&
1809 ((r_ptr->level) / 10 + (3 * dun_level) >= randint1(100)))
1811 chg_virtue(V_UNLIFE, 1);
1813 if (r_ptr->d_char == 'A')
1815 if (r_ptr->flags1 & RF1_UNIQUE)
1816 chg_virtue(V_FAITH, -2);
1817 else if ((r_ptr->level) / 10 + (3 * dun_level) >= randint1(100))
1819 if (r_ptr->flags3 & RF3_GOOD) chg_virtue(V_FAITH, -1);
1820 else chg_virtue(V_FAITH, 1);
1823 else if (r_ptr->flags3 & RF3_DEMON)
1825 if (r_ptr->flags1 & RF1_UNIQUE)
1826 chg_virtue(V_FAITH, 2);
1827 else if ((r_ptr->level) / 10 + (3 * dun_level) >= randint1(100))
1828 chg_virtue(V_FAITH, 1);
1831 if ((r_ptr->flags3 & RF3_UNDEAD) && (r_ptr->flags1 & RF1_UNIQUE))
1832 chg_virtue(V_VITALITY, 2);
1834 if (r_ptr->r_deaths)
1836 if (r_ptr->flags1 & RF1_UNIQUE)
1838 chg_virtue(V_HONOUR, 10);
1840 else if ((r_ptr->level) / 10 + (2 * dun_level) >= randint1(100))
1842 chg_virtue(V_HONOUR, 1);
1845 if ((r_ptr->flags2 & RF2_MULTIPLY) && (r_ptr->r_pkills > 1000) && one_in_(10))
1847 chg_virtue(V_VALOUR, -1);
1850 for (i = 0; i < 4; i++)
1852 if(r_ptr->blow[i].d_dice != 0) innocent = FALSE; /* Murderer! */
1854 if ((r_ptr->blow[i].effect == RBE_EAT_ITEM)
1855 || (r_ptr->blow[i].effect == RBE_EAT_GOLD))
1857 thief = TRUE; /* Thief! */
1860 /* The new law says it is illegal to live in the dungeon */
1861 if (r_ptr->level != 0) innocent = FALSE;
1865 if (r_ptr->flags1 & RF1_UNIQUE)
1866 chg_virtue(V_JUSTICE, 3);
1867 else if (1+((r_ptr->level) / 10 + (2 * dun_level))
1870 chg_virtue(V_JUSTICE, 1);
1874 chg_virtue (V_JUSTICE, -1);
1877 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)))
1879 if (one_in_(4)) chg_virtue(V_NATURE, -1);
1882 if ((r_ptr->flags1 & RF1_UNIQUE) && record_destroy_uniq)
1886 sprintf(m_name, "%s%s", r_name + r_ptr->name, (m_ptr->smart & SM_CLONED) ? "(¥¯¥í¡¼¥ó)" : "");
1888 sprintf(m_name, "%s%s", r_name + r_ptr->name, (m_ptr->smart & SM_CLONED) ? "(Clone)" : "");
1890 do_cmd_write_nikki(NIKKI_UNIQUE, 0, m_name);
1896 /* Death by Missile/Spell attack */
1899 msg_format("%^s%s", m_name, note);
1902 /* Death by physical attack -- invisible monster */
1903 else if (!m_ptr->ml)
1906 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
1907 msg_format("¤»¤Ã¤«¤¯¤À¤«¤é%s¤ò»¦¤·¤¿¡£", m_name);
1909 msg_format("%s¤ò»¦¤·¤¿¡£", m_name);
1911 msg_format("You have killed %s.", m_name);
1916 /* Death by Physical attack -- non-living monster */
1917 else if (!monster_living(r_ptr))
1920 bool explode = FALSE;
1922 for (i = 0; i < 4; i++)
1924 if (r_ptr->blow[i].method == RBM_EXPLODE) explode = TRUE;
1927 /* Special note at death */
1930 msg_format("%s¤ÏÇúȯ¤·¤ÆÊ´¡¹¤Ë¤Ê¤Ã¤¿¡£", m_name);
1932 msg_format("%s explodes into tiny shreds.", m_name);
1937 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
1938 msg_format("¤»¤Ã¤«¤¯¤À¤«¤é%s¤òÅݤ·¤¿¡£", m_name);
1940 msg_format("%s¤òÅݤ·¤¿¡£", m_name);
1942 msg_format("You have destroyed %s.", m_name);
1947 /* Death by Physical attack -- living monster */
1951 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
1952 msg_format("¤»¤Ã¤«¤¯¤À¤«¤é%s¤òÁò¤êµî¤Ã¤¿¡£", m_name);
1954 msg_format("%s¤òÁò¤êµî¤Ã¤¿¡£", m_name);
1956 msg_format("You have slain %s.", m_name);
1960 if (r_ptr->flags1 & RF1_UNIQUE && !(m_ptr->smart & SM_CLONED))
1962 for (i = 0; i < MAX_KUBI; i++)
1964 if ((kubi_r_idx[i] == m_ptr->r_idx) && !(m_ptr->mflag2 & MFLAG2_CHAMELEON))
1967 msg_format("%s¤Î¼ó¤Ë¤Ï¾Þ¶â¤¬¤«¤«¤Ã¤Æ¤¤¤ë¡£", m_name);
1969 msg_format("There is a price on %s's head.", m_name);
1976 /* Generate treasure */
1977 monster_death(m_idx, TRUE);
1978 if ((m_ptr->r_idx == MON_BANOR) || (m_ptr->r_idx == MON_LUPART))
1980 r_info[MON_BANORLUPART].max_num = 0;
1981 r_info[MON_BANORLUPART].r_pkills++;
1982 if (r_info[MON_BANORLUPART].r_tkills < MAX_SHORT) r_info[MON_BANORLUPART].r_tkills++;
1985 if (m_ptr->r_idx == MON_BANORLUPART)
1987 r_info[MON_BANOR].max_num = 0;
1988 r_info[MON_BANOR].r_pkills++;
1989 if (r_info[MON_BANOR].r_tkills < MAX_SHORT) r_info[MON_BANOR].r_tkills++;
1990 r_info[MON_LUPART].max_num = 0;
1991 r_info[MON_LUPART].r_pkills++;
1992 if (r_info[MON_LUPART].r_tkills < MAX_SHORT) r_info[MON_LUPART].r_tkills++;
1995 /* Mega hack : replace IKETA to BIKETAL */
1996 if ((m_ptr->r_idx == MON_IKETA) &&
1997 !(p_ptr->inside_arena || p_ptr->inside_battle))
1999 int dummy_y = m_ptr->fy;
2000 int dummy_x = m_ptr->fx;
2003 if (is_pet(m_ptr)) mode |= PM_FORCE_PET;
2005 /* Delete the monster */
2006 delete_monster_idx(m_idx);
2008 if (summon_named_creature(0, dummy_y, dummy_x, MON_BIKETAL, mode))
2011 msg_print("¡Ö¥Ï¥¡¥Ã¥Ï¥Ã¥Ï¥Ã¥Ï¡ª¡ª»ä¤¬¥Ð¥¤¥±¥¿¥ë¤À¡ª¡ª¡×");
2013 msg_print("Uwa-hahaha! *I* am Biketal!");
2019 /* Delete the monster */
2020 delete_monster_idx(m_idx);
2023 /* Prevent bug of chaos patron's reward */
2024 if (r_ptr->flags7 & RF7_KILL_EXP)
2025 get_exp_from_mon((long)m_ptr->max_maxhp*2, &exp_mon);
2027 get_exp_from_mon(((long)m_ptr->max_maxhp+1L) * 9L / 10L, &exp_mon);
2032 /* Monster is dead */
2039 /* Mega-Hack -- Pain cancels fear */
2040 if (m_ptr->monfear && (dam > 0))
2042 int tmp = randint1(dam);
2044 /* Cure a little fear */
2045 if (tmp < m_ptr->monfear)
2048 m_ptr->monfear -= tmp;
2051 /* Cure all the fear */
2062 /* Sometimes a monster gets scared by damage */
2063 if (!m_ptr->monfear && !(r_ptr->flags3 & (RF3_NO_FEAR)))
2067 /* Percentage of fully healthy */
2068 percentage = (100L * m_ptr->hp) / m_ptr->maxhp;
2071 * Run (sometimes) if at 10% or less of max hit points,
2072 * or (usually) when hit for half its current hit points
2074 if ((randint1(10) >= percentage) ||
2075 ((dam >= m_ptr->hp) && (randint0(100) < 80)))
2077 /* Hack -- note fear */
2080 /* XXX XXX XXX Hack -- Add some timed fear */
2081 m_ptr->monfear = (randint1(10) +
2082 (((dam >= m_ptr->hp) && (percentage > 7)) ?
2083 20 : ((11 - percentage) * 5)));
2090 if (p_ptr->riding && (p_ptr->riding == m_idx) && (dam > 0))
2094 /* Extract monster name */
2095 monster_desc(m_name, m_ptr, 0);
2097 if (m_ptr->hp > m_ptr->maxhp/3) dam = (dam + 1) / 2;
2098 if (rakuba((dam > 200) ? 200 : dam, FALSE))
2101 msg_format("%^s¤Ë¿¶¤êÍî¤È¤µ¤ì¤¿¡ª", m_name);
2103 msg_format("%^s has thrown you off!", m_name);
2115 * Get term size and calculate screen size
2117 void get_screen_size(int *wid_p, int *hgt_p)
2119 Term_get_size(wid_p, hgt_p);
2120 *hgt_p -= ROW_MAP + 2;
2121 *wid_p -= COL_MAP + 2;
2122 if (use_bigtile) *wid_p /= 2;
2127 * Calculates current boundaries
2128 * Called below and from "do_cmd_locate()".
2130 void panel_bounds_center(void)
2135 get_screen_size(&wid, &hgt);
2137 panel_row_max = panel_row_min + hgt - 1;
2138 panel_row_prt = panel_row_min - 1;
2139 panel_col_max = panel_col_min + wid - 1;
2140 panel_col_prt = panel_col_min - 13;
2145 * Map resizing whenever the main term changes size
2147 void resize_map(void)
2149 /* Only if the dungeon exists */
2150 if (!character_dungeon) return;
2152 /* Mega-Hack -- no panel yet */
2156 /* Reset the panels */
2157 panel_row_min = cur_hgt;
2158 panel_col_min = cur_wid;
2163 p_ptr->update |= (PU_TORCH | PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
2165 /* Forget lite/view */
2166 p_ptr->update |= (PU_UN_VIEW | PU_UN_LITE);
2168 /* Update lite/view */
2169 p_ptr->update |= (PU_VIEW | PU_LITE | PU_MON_LITE);
2171 /* Update monsters */
2172 p_ptr->update |= (PU_MONSTERS);
2174 /* Redraw everything */
2175 p_ptr->redraw |= (PR_WIPE | PR_BASIC | PR_EXTRA | PR_MAP | PR_EQUIPPY);
2177 /* Hack -- update */
2185 * Place the cursor on the player
2187 if (can_save) move_cursor_relative(py, px);
2194 * Redraw a term when it is resized
2196 void redraw_window(void)
2198 /* Only if the dungeon exists */
2199 if (!character_dungeon) return;
2201 /* Hack - Activate term zero for the redraw */
2202 Term_activate(&term_screen[0]);
2204 /* Hack -- react to changes */
2205 Term_xtra(TERM_XTRA_REACT, 0);
2208 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_SPELL | PW_PLAYER);
2211 p_ptr->window |= (PW_MESSAGE | PW_OVERHEAD | PW_DUNGEON | PW_MONSTER | PW_OBJECT);
2213 /* Hack -- update */
2225 * Handle a request to change the current panel
2227 * Return TRUE if the panel was changed.
2229 * Also used in do_cmd_locate
2231 bool change_panel(int dy, int dx)
2237 get_screen_size(&wid, &hgt);
2239 /* Apply the motion */
2240 y = panel_row_min + dy * hgt / 2;
2241 x = panel_col_min + dx * wid / 2;
2243 /* Verify the row */
2244 if (y > cur_hgt - hgt) y = cur_hgt - hgt;
2247 /* Verify the col */
2248 if (x > cur_wid - wid) x = cur_wid - wid;
2251 /* Handle "changes" */
2252 if ((y != panel_row_min) || (x != panel_col_min))
2254 /* Save the new panel info */
2258 /* Recalculate the boundaries */
2259 panel_bounds_center();
2262 p_ptr->update |= (PU_MONSTERS);
2265 p_ptr->redraw |= (PR_MAP);
2280 * Given an row (y) and col (x), this routine detects when a move
2281 * off the screen has occurred and figures new borders. -RAK-
2283 * "Update" forces a "full update" to take place.
2285 * The map is reprinted if necessary, and "TRUE" is returned.
2287 void verify_panel(void)
2299 get_screen_size(&wid, &hgt);
2301 max_prow_min = cur_hgt - hgt;
2302 max_pcol_min = cur_wid - wid;
2304 /* Bounds checking */
2305 if (max_prow_min < 0) max_prow_min = 0;
2306 if (max_pcol_min < 0) max_pcol_min = 0;
2308 /* Center on player */
2309 if (center_player && (center_running || !running))
2311 /* Center vertically */
2312 prow_min = y - hgt / 2;
2313 if (prow_min < 0) prow_min = 0;
2314 else if (prow_min > max_prow_min) prow_min = max_prow_min;
2316 /* Center horizontally */
2317 pcol_min = x - wid / 2;
2318 if (pcol_min < 0) pcol_min = 0;
2319 else if (pcol_min > max_pcol_min) pcol_min = max_pcol_min;
2323 prow_min = panel_row_min;
2324 pcol_min = panel_col_min;
2326 /* Scroll screen when 2 grids from top/bottom edge */
2327 if (y > panel_row_max - 2)
2329 while (y > prow_min + hgt-1 - 2)
2331 prow_min += (hgt / 2);
2335 if (y < panel_row_min + 2)
2337 while (y < prow_min + 2)
2339 prow_min -= (hgt / 2);
2343 if (prow_min > max_prow_min) prow_min = max_prow_min;
2344 if (prow_min < 0) prow_min = 0;
2346 /* Scroll screen when 4 grids from left/right edge */
2347 if (x > panel_col_max - 4)
2349 while (x > pcol_min + wid-1 - 4)
2351 pcol_min += (wid / 2);
2355 if (x < panel_col_min + 4)
2357 while (x < pcol_min + 4)
2359 pcol_min -= (wid / 2);
2363 if (pcol_min > max_pcol_min) pcol_min = max_pcol_min;
2364 if (pcol_min < 0) pcol_min = 0;
2367 /* Check for "no change" */
2368 if ((prow_min == panel_row_min) && (pcol_min == panel_col_min)) return;
2370 /* Save the new panel info */
2371 panel_row_min = prow_min;
2372 panel_col_min = pcol_min;
2374 /* Hack -- optional disturb on "panel change" */
2375 if (disturb_panel && !center_player) disturb(0, 0);
2377 /* Recalculate the boundaries */
2378 panel_bounds_center();
2381 p_ptr->update |= (PU_MONSTERS);
2384 p_ptr->redraw |= (PR_MAP);
2387 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
2392 * Monster health description
2394 cptr look_mon_desc(int m_idx, u32b mode)
2396 monster_type *m_ptr = &m_list[m_idx];
2397 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
2404 /* Determine if the monster is "living" */
2405 living = monster_living(ap_r_ptr);
2407 /* Calculate a health "percentage" */
2408 perc = 100L * m_ptr->hp / m_ptr->maxhp;
2410 /* Healthy monsters */
2411 if (m_ptr->hp >= m_ptr->maxhp)
2415 desc = living ? "̵½ý" : "̵¥À¥á¡¼¥¸";
2417 desc = living ? "unhurt" : "undamaged";
2422 else if (perc >= 60)
2425 desc = living ? "·Ú½ý" : "¾®¥À¥á¡¼¥¸";
2427 desc = living ? "somewhat wounded" : "somewhat damaged";
2432 else if (perc >= 25)
2435 desc = living ? "Éé½ý" : "Ãæ¥À¥á¡¼¥¸";
2437 desc = living ? "wounded" : "damaged";
2442 else if (perc >= 10)
2445 desc = living ? "½Å½ý" : "Âç¥À¥á¡¼¥¸";
2447 desc = living ? "badly wounded" : "badly damaged";
2455 desc = living ? "Ⱦ»àȾÀ¸" : "Åݤ줫¤±";
2457 desc = living ? "almost dead" : "almost destroyed";
2462 /* Need attitude information? */
2465 /* Full information is not needed */
2468 else if (is_pet(m_ptr))
2471 attitude = ", ¥Ú¥Ã¥È";
2476 else if (is_friendly(m_ptr))
2479 attitude = ", ͧ¹¥Åª";
2481 attitude = ", friendly";
2494 /* Clone monster? */
2495 if (m_ptr->smart & SM_CLONED)
2504 /* Display monster's level --- idea borrowed from ToME */
2505 if (ap_r_ptr->r_tkills && !(m_ptr->mflag2 & MFLAG2_KAGE))
2508 return format("¥ì¥Ù¥ë%d, %s%s%s", ap_r_ptr->level, desc, attitude, clone);
2510 return format("Level %d, %s%s%s", ap_r_ptr->level, desc, attitude, clone);
2516 return format("¥ì¥Ù¥ë???, %s%s%s", desc, attitude, clone);
2518 return format("Level ???, %s%s%s", desc, attitude, clone);
2526 * Angband sorting algorithm -- quick sort in place
2528 * Note that the details of the data we are sorting is hidden,
2529 * and we rely on the "ang_sort_comp()" and "ang_sort_swap()"
2530 * function hooks to interact with the data, which is given as
2531 * two pointers, and which may have any user-defined form.
2533 void ang_sort_aux(vptr u, vptr v, int p, int q)
2551 while (!(*ang_sort_comp)(u, v, b, z)) b--;
2554 while (!(*ang_sort_comp)(u, v, z, a)) a++;
2556 /* Done partition */
2560 (*ang_sort_swap)(u, v, a, b);
2566 /* Recurse left side */
2567 ang_sort_aux(u, v, p, b);
2569 /* Recurse right side */
2570 ang_sort_aux(u, v, b+1, q);
2575 * Angband sorting algorithm -- quick sort in place
2577 * Note that the details of the data we are sorting is hidden,
2578 * and we rely on the "ang_sort_comp()" and "ang_sort_swap()"
2579 * function hooks to interact with the data, which is given as
2580 * two pointers, and which may have any user-defined form.
2582 void ang_sort(vptr u, vptr v, int n)
2584 /* Sort the array */
2585 ang_sort_aux(u, v, 0, n-1);
2590 /*** Targeting Code ***/
2594 * Determine is a monster makes a reasonable target
2596 * The concept of "targeting" was stolen from "Morgul" (?)
2598 * The player can target any location, or any "target-able" monster.
2600 * Currently, a monster is "target_able" if it is visible, and if
2601 * the player can hit it with a projection, and the player is not
2602 * hallucinating. This allows use of "use closest target" macros.
2604 * Future versions may restrict the ability to target "trappers"
2605 * and "mimics", but the semantics is a little bit weird.
2607 bool target_able(int m_idx)
2609 monster_type *m_ptr = &m_list[m_idx];
2611 /* Monster must be alive */
2612 if (!m_ptr->r_idx) return (FALSE);
2614 /* Hack -- no targeting hallucinations */
2615 if (p_ptr->image) return (FALSE);
2617 /* Monster must be visible */
2618 if (!m_ptr->ml) return (FALSE);
2620 if (p_ptr->riding && (p_ptr->riding == m_idx)) return (TRUE);
2622 /* Monster must be projectable */
2623 if (!projectable(py, px, m_ptr->fy, m_ptr->fx)) return (FALSE);
2625 /* XXX XXX XXX Hack -- Never target trappers */
2626 /* if (CLEAR_ATTR && (CLEAR_CHAR)) return (FALSE); */
2636 * Update (if necessary) and verify (if possible) the target.
2638 * We return TRUE if the target is "okay" and FALSE otherwise.
2640 bool target_okay(void)
2642 /* Accept stationary targets */
2643 if (target_who < 0) return (TRUE);
2645 /* Check moving targets */
2648 /* Accept reasonable targets */
2649 if (target_able(target_who))
2651 monster_type *m_ptr = &m_list[target_who];
2653 /* Acquire monster location */
2654 target_row = m_ptr->fy;
2655 target_col = m_ptr->fx;
2662 /* Assume no target */
2669 * Sorting hook -- comp function -- by "distance to player"
2671 * We use "u" and "v" to point to arrays of "x" and "y" positions,
2672 * and sort the arrays by double-distance to the player.
2674 static bool ang_sort_comp_distance(vptr u, vptr v, int a, int b)
2676 byte *x = (byte*)(u);
2677 byte *y = (byte*)(v);
2681 /* Absolute distance components */
2682 kx = x[a]; kx -= px; kx = ABS(kx);
2683 ky = y[a]; ky -= py; ky = ABS(ky);
2685 /* Approximate Double Distance to the first point */
2686 da = ((kx > ky) ? (kx + kx + ky) : (ky + ky + kx));
2688 /* Absolute distance components */
2689 kx = x[b]; kx -= px; kx = ABS(kx);
2690 ky = y[b]; ky -= py; ky = ABS(ky);
2692 /* Approximate Double Distance to the first point */
2693 db = ((kx > ky) ? (kx + kx + ky) : (ky + ky + kx));
2695 /* Compare the distances */
2701 * Sorting hook -- swap function -- by "distance to player"
2703 * We use "u" and "v" to point to arrays of "x" and "y" positions,
2704 * and sort the arrays by distance to the player.
2706 static void ang_sort_swap_distance(vptr u, vptr v, int a, int b)
2708 byte *x = (byte*)(u);
2709 byte *y = (byte*)(v);
2727 * Hack -- help "select" a location (see below)
2729 static s16b target_pick(int y1, int x1, int dy, int dx)
2733 int x2, y2, x3, y3, x4, y4;
2735 int b_i = -1, b_v = 9999;
2738 /* Scan the locations */
2739 for (i = 0; i < temp_n; i++)
2745 /* Directed distance */
2749 /* Verify quadrant */
2750 if (dx && (x3 * dx <= 0)) continue;
2751 if (dy && (y3 * dy <= 0)) continue;
2753 /* Absolute distance */
2757 /* Verify quadrant */
2758 if (dy && !dx && (x4 > y4)) continue;
2759 if (dx && !dy && (y4 > x4)) continue;
2761 /* Approximate Double Distance */
2762 v = ((x4 > y4) ? (x4 + x4 + y4) : (y4 + y4 + x4));
2764 /* XXX XXX XXX Penalize location */
2767 if ((b_i >= 0) && (v >= b_v)) continue;
2779 * Hack -- determine if a given location is "interesting"
2781 static bool target_set_accept(int y, int x)
2785 s16b this_o_idx, next_o_idx = 0;
2788 if (!(in_bounds(y, x))) return (FALSE);
2790 /* Player grid is always interesting */
2791 if ((y == py) && (x == px)) return (TRUE);
2794 /* Handle hallucination */
2795 if (p_ptr->image) return (FALSE);
2798 /* Examine the grid */
2799 c_ptr = &cave[y][x];
2801 /* Visible monsters */
2804 monster_type *m_ptr = &m_list[c_ptr->m_idx];
2806 /* Visible monsters */
2807 if (m_ptr->ml) return (TRUE);
2810 /* Scan all objects in the grid */
2811 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
2815 /* Acquire object */
2816 o_ptr = &o_list[this_o_idx];
2818 /* Acquire next object */
2819 next_o_idx = o_ptr->next_o_idx;
2821 /* Memorized object */
2822 if (o_ptr->marked) return (TRUE);
2825 /* Interesting memorized features */
2826 if (c_ptr->info & (CAVE_MARK))
2830 /* Feature code (applying "mimic" field) */
2831 feat = c_ptr->mimic ? c_ptr->mimic : f_info[c_ptr->feat].mimic;
2834 if (c_ptr->info & CAVE_OBJECT) return (TRUE);
2836 /* Notice the Pattern */
2837 if ((feat <= FEAT_PATTERN_XTRA2) &&
2838 (feat >= FEAT_PATTERN_START))
2842 if (feat == FEAT_OPEN) return (TRUE);
2843 if (feat == FEAT_BROKEN) return (TRUE);
2846 if (feat == FEAT_LESS) return (TRUE);
2847 if (feat == FEAT_MORE) return (TRUE);
2848 if (feat == FEAT_LESS_LESS) return (TRUE);
2849 if (feat == FEAT_MORE_MORE) return (TRUE);
2852 if ((feat >= FEAT_SHOP_HEAD) &&
2853 (feat <= FEAT_SHOP_TAIL)) return (TRUE);
2855 if (feat == FEAT_MUSEUM) return (TRUE);
2857 /* Notice buildings -KMW- */
2858 if ((feat >= FEAT_BLDG_HEAD) &&
2859 (feat <= FEAT_BLDG_TAIL)) return (TRUE);
2862 if (is_trap(feat)) return (TRUE);
2865 if ((feat >= FEAT_DOOR_HEAD) &&
2866 (feat <= FEAT_DOOR_TAIL)) return (TRUE);
2870 /* I think FEAT_RUBBLEs should not be "interesting" */
2871 if (feat == FEAT_RUBBLE) return (TRUE);
2873 /* Notice veins with treasure */
2874 /* Now veins with treasure are too many */
2875 if (feat == FEAT_MAGMA_K) return (TRUE);
2876 if (feat == FEAT_QUARTZ_K) return (TRUE);
2879 /* Notice quest features */
2880 if (feat == FEAT_QUEST_ENTER) return (TRUE);
2881 if (feat == FEAT_QUEST_EXIT) return (TRUE);
2882 if (feat == FEAT_QUEST_DOWN) return (TRUE);
2883 if (feat == FEAT_QUEST_UP) return (TRUE);
2884 if (feat == FEAT_TOWN) return (TRUE);
2885 if (feat == FEAT_ENTRANCE) return (TRUE);
2894 * Prepare the "temp" array for "target_set"
2896 * Return the number of target_able monsters in the set.
2898 static void target_set_prepare(int mode)
2902 /* Reset "temp" array */
2905 /* Scan the current panel */
2906 for (y = panel_row_min; y <= panel_row_max; y++)
2908 for (x = panel_col_min; x <= panel_col_max; x++)
2912 /* Require line of sight, unless "look" is "expanded" */
2913 if (!expand_look && !player_has_los_bold(y, x)) continue;
2915 /* Require "interesting" contents */
2916 if (!target_set_accept(y, x)) continue;
2918 c_ptr = &cave[y][x];
2920 /* Require target_able monsters for "TARGET_KILL" */
2921 if ((mode & (TARGET_KILL)) && !target_able(c_ptr->m_idx)) continue;
2923 if ((mode & (TARGET_KILL)) && !target_pet && is_pet(&m_list[c_ptr->m_idx])) continue;
2925 /* Save the location */
2932 /* Set the sort hooks */
2933 ang_sort_comp = ang_sort_comp_distance;
2934 ang_sort_swap = ang_sort_swap_distance;
2936 /* Sort the positions */
2937 ang_sort(temp_x, temp_y, temp_n);
2939 if (p_ptr->riding && target_pet && (temp_n > 1) && (mode & (TARGET_KILL)))
2944 temp_y[0] = temp_y[1];
2947 temp_x[0] = temp_x[1];
2954 * Evaluate number of kill needed to gain level
2956 static void evaluate_monster_exp(char *buf, monster_type *m_ptr)
2958 #define M_INT_GREATER(h1,l1,h2,l2) ( (h1>h2)||( (h1==h2)&&(l1>=l2)))
2959 #define M_INT_SUB(h1,l1, h2,l2) {h1-=h2;if(l1<l2){l1+=0x10000;h1--;}l1-=l2;}
2960 #define M_INT_ADD(h1,l1, h2,l2) {h1+=h2;l1+=l2;if(l1>=0x10000L){l1&=0xFFFF;h1++;}}
2961 #define M_INT_LSHIFT(h1,l1) {h1=(h1<<1)|(l1>>15);l1=(l1<<1)&0xffff;}
2962 #define M_INT_RSHIFT(h1,l1) {l1=(l1>>1)|((h1&1)<<15);h1>>=1;}
2963 #define M_INT_MULT(h1,l1,mul,h2,l2) {l2=(l1*mul)&0xffff;h2=((l1*mul)>>16)+h1*mul;}
2965 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
2969 u32b exp_mon= (ap_r_ptr->mexp)*(ap_r_ptr->level);
2970 u32b exp_mon_h= exp_mon / (p_ptr->max_plv+2);
2971 u32b exp_mon_l= ((exp_mon % (p_ptr->max_plv+2))*0x10000/(p_ptr->max_plv+2))&0xFFFF;
2973 u32b exp_adv_h = player_exp[p_ptr->lev -1] * p_ptr->expfact /100;
2974 u32b exp_adv_l = ((player_exp[p_ptr->lev -1]%100) * p_ptr->expfact *0x10000/100)&0xFFFF;
2976 M_INT_SUB(exp_adv_h, exp_adv_l, p_ptr->exp, p_ptr->exp_frac);
2977 if ((p_ptr->lev>=PY_MAX_LEVEL) || (p_ptr->prace == RACE_ANDROID))
2979 else if (!ap_r_ptr->r_tkills || (m_ptr->mflag2 & MFLAG2_KAGE))
2981 else if (M_INT_GREATER(exp_mon_h, exp_mon_l, exp_adv_h, exp_adv_l))
2985 M_INT_MULT(exp_mon_h, exp_mon_l, 1000,tmp_h, tmp_l);
2986 if( M_INT_GREATER(exp_adv_h, exp_adv_l, tmp_h, tmp_l) )
2991 M_INT_ADD(exp_adv_h, exp_adv_l, exp_mon_h, exp_mon_l);
2992 M_INT_SUB(exp_adv_h, exp_adv_l, 0, 1);
2993 while(M_INT_GREATER(exp_adv_h, exp_adv_l, exp_mon_h,exp_mon_l))
2995 M_INT_LSHIFT(exp_mon_h,exp_mon_l);
2998 M_INT_RSHIFT(exp_mon_h,exp_mon_l);bit>>=1;
2999 for(;bit>=1;bit>>=1)
3001 if(M_INT_GREATER(exp_adv_h,exp_adv_l,exp_mon_h,exp_mon_l))
3004 M_INT_SUB(exp_adv_h,exp_adv_l,exp_mon_h,exp_mon_l);
3006 M_INT_RSHIFT(exp_mon_h,exp_mon_l);
3008 sprintf(buf,"%03d",result);
3015 * Examine a grid, return a keypress.
3017 * The "mode" argument contains the "TARGET_LOOK" bit flag, which
3018 * indicates that the "space" key should scan through the contents
3019 * of the grid, instead of simply returning immediately. This lets
3020 * the "look" command get complete information, without making the
3021 * "target" command annoying.
3023 * The "info" argument contains the "commands" which should be shown
3024 * inside the "[xxx]" text. This string must never be empty, or grids
3025 * containing monsters will be displayed with an extra comma.
3027 * Note that if a monster is in the grid, we update both the monster
3028 * recall info and the health bar info to track that monster.
3030 * Eventually, we may allow multiple objects per grid, or objects
3031 * and terrain features in the same grid. XXX XXX XXX
3033 * This function must handle blindness/hallucination.
3035 static int target_set_aux(int y, int x, int mode, cptr info)
3037 cave_type *c_ptr = &cave[y][x];
3038 s16b this_o_idx, next_o_idx = 0;
3039 cptr s1 = "", s2 = "", s3 = "", x_info = "";
3043 char out_val[MAX_NLEN+80];
3045 #ifdef ALLOW_EASY_FLOOR
3046 int floor_list[23], floor_num = 0;
3048 /* Scan all objects in the grid */
3051 floor_num = scan_floor(floor_list, y, x, 0x02);
3063 #endif /* ALLOW_EASY_FLOOR */
3065 /* Hack -- under the player */
3066 if ((y == py) && (x == px))
3089 /* Hack -- hallucination */
3093 cptr name = "²¿¤«´ñ̯¤Êʪ";
3095 cptr name = "something strange";
3099 /* Display a message */
3101 sprintf(out_val, "%s%s%s%s [%s]", s1, name, s2, s3, info);
3103 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, name, info);
3107 move_cursor_relative(y, x);
3110 /* Stop on everything but "return" */
3111 if ((query != '\r') && (query != '\n')) return query;
3113 /* Repeat forever */
3118 /* Actual monsters */
3119 if (c_ptr->m_idx && m_list[c_ptr->m_idx].ml)
3121 monster_type *m_ptr = &m_list[c_ptr->m_idx];
3122 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
3124 bool recall = FALSE;
3129 /* Get the monster name ("a kobold") */
3130 monster_desc(m_name, m_ptr, 0x08);
3132 /* Hack -- track this monster race */
3133 monster_race_track(m_ptr->ap_r_idx);
3135 /* Hack -- health bar for this monster */
3136 health_track(c_ptr->m_idx);
3138 /* Hack -- handle stuff */
3152 /* Recall on screen */
3153 screen_roff(m_ptr->ap_r_idx, 0);
3155 /* Hack -- Complete the prompt (again) */
3157 Term_addstr(-1, TERM_WHITE, format(" [r»× %s%s]", x_info, info));
3159 Term_addstr(-1, TERM_WHITE, format(" [r,%s%s]", x_info, info));
3168 /* Normal commands */
3169 if (query != 'r') break;
3174 /* Cleare recall text and repeat */
3180 /* Describe, and prompt for recall */
3181 evaluate_monster_exp(acount, m_ptr);
3184 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);
3186 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);
3192 move_cursor_relative(y, x);
3197 /* Normal commands */
3198 if (query != 'r') break;
3204 /* Always stop at "normal" keys */
3205 if ((query != '\r') && (query != '\n') && (query != ' ') && (query != 'x')) return query;
3207 /* Sometimes stop at "space" key */
3208 if ((query == ' ') && !(mode & (TARGET_LOOK))) return query;
3210 /* Change the intro */
3218 /* Hack -- take account of gender */
3220 if (ap_r_ptr->flags1 & (RF1_FEMALE)) s1 = "Èà½÷¤Ï";
3222 if (ap_r_ptr->flags1 & (RF1_FEMALE)) s1 = "She is ";
3226 else if (ap_r_ptr->flags1 & (RF1_MALE)) s1 = "Èà¤Ï";
3228 else if (ap_r_ptr->flags1 & (RF1_MALE)) s1 = "He is ";
3232 /* Use a preposition */
3241 /* Scan all objects being carried */
3242 for (this_o_idx = m_ptr->hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
3244 char o_name[MAX_NLEN];
3248 /* Acquire object */
3249 o_ptr = &o_list[this_o_idx];
3251 /* Acquire next object */
3252 next_o_idx = o_ptr->next_o_idx;
3254 /* Obtain an object description */
3255 object_desc(o_name, o_ptr, TRUE, 3);
3257 /* Describe the object */
3259 sprintf(out_val, "%s%s%s%s[%s]", s1, o_name, s2, s3, info);
3261 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, o_name, info);
3265 move_cursor_relative(y, x);
3268 /* Always stop at "normal" keys */
3269 if ((query != '\r') && (query != '\n') && (query != ' ') && (query != 'x')) return query;
3271 /* Sometimes stop at "space" key */
3272 if ((query == ' ') && !(mode & (TARGET_LOOK))) return query;
3274 /* Change the intro */
3278 s2 = "also carrying ";
3282 /* Use a preposition */
3292 #ifdef ALLOW_EASY_FLOOR
3301 char o_name[MAX_NLEN];
3305 /* Acquire object */
3306 o_ptr = &o_list[floor_list[0]];
3308 /* Describe the object */
3309 object_desc(o_name, o_ptr, TRUE, 3);
3313 sprintf(out_val, "%s%s%s%s[%s]",
3314 s1, o_name, s2, s3, info);
3316 sprintf(out_val, "%s%s%s%s [%s]",
3317 s1, s2, s3, o_name, info);
3321 move_cursor_relative(y, x);
3330 /* Provide one cushion before item listing */
3333 /* Display rough information about items */
3335 sprintf(out_val, "%s %d¸Ä¤Î¥¢¥¤¥Æ¥à%s%s ['x'¤Ç°ìÍ÷, %s]",
3336 s1, floor_num, s2, s3, info);
3338 sprintf(out_val, "%s%s%sa pile of %d items [x,%s]",
3339 s1, s2, s3, floor_num, info);
3343 move_cursor_relative(y, x);
3348 /* No request for listing */
3349 if (query != 'x' && query != ' ') return query;
3353 /** Display list of items **/
3355 /* Continue scrolling list if requested */
3365 (void)show_floor(0, y, x, &min_width);
3369 sprintf(out_val, "%s %d¸Ä¤Î¥¢¥¤¥Æ¥à%s%s [Enter¤Ç¼¡¤Ø, %s]",
3370 s1, floor_num, s2, s3, info);
3372 sprintf(out_val, "%s%s%sa pile of %d items [Enter,%s]",
3373 s1, s2, s3, floor_num, info);
3384 /* Exit unless 'Enter' */
3385 if (query != '\n' && query != '\r')
3390 /* Get the object being moved. */
3391 c_ptr = &cave[y][x];
3392 o_idx = c_ptr->o_idx;
3394 /* Only rotate a pile of two or more objects. */
3395 if (!(o_idx && o_list[o_idx].next_o_idx)) continue;
3397 /* Remove the first object from the list. */
3398 excise_object_idx(o_idx);
3400 /* Find end of the list. */
3402 while (o_list[i].next_o_idx)
3403 i = o_list[i].next_o_idx;
3405 /* Add after the last object. */
3406 o_list[i].next_o_idx = o_idx;
3408 /* Loop and re-display the list */
3414 #endif /* ALLOW_EASY_FLOOR */
3417 /* Scan all objects in the grid */
3418 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
3422 /* Acquire object */
3423 o_ptr = &o_list[this_o_idx];
3425 /* Acquire next object */
3426 next_o_idx = o_ptr->next_o_idx;
3431 char o_name[MAX_NLEN];
3436 /* Obtain an object description */
3437 object_desc(o_name, o_ptr, TRUE, 3);
3439 /* Describe the object */
3441 sprintf(out_val, "%s%s%s%s[%s]", s1, o_name, s2, s3, info);
3443 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, o_name, info);
3447 move_cursor_relative(y, x);
3450 /* Always stop at "normal" keys */
3451 if ((query != '\r') && (query != '\n') && (query != ' ') && (query != 'x')) return query;
3453 /* Sometimes stop at "space" key */
3454 if ((query == ' ') && !(mode & TARGET_LOOK)) return query;
3456 /* Change the intro */
3466 if (o_ptr->number != 1) s1 = "¤½¤ì¤é¤Ï";
3468 if (o_ptr->number != 1) s1 = "They are ";
3484 /* Feature code (applying "mimic" field) */
3485 feat = c_ptr->mimic ? c_ptr->mimic : f_info[c_ptr->feat].mimic;
3487 /* Require knowledge about grid, or ability to see grid */
3488 if (!(c_ptr->info & CAVE_MARK) && !player_can_see_bold(y, x))
3490 /* Forget feature */
3494 /* Terrain feature if needed */
3495 if (boring || (feat > FEAT_INVIS))
3499 /* Hack -- special handling for building doors */
3500 if ((feat >= FEAT_BLDG_HEAD) && (feat <= FEAT_BLDG_TAIL))
3502 name = building[feat - FEAT_BLDG_HEAD].name;
3504 else if (feat == FEAT_ENTRANCE)
3507 name = format("%s(%d³¬ÁêÅö)", d_text + d_info[c_ptr->special].text, d_info[c_ptr->special].mindepth);
3509 name = format("%s(level %d)", d_text + d_info[c_ptr->special].text, d_info[c_ptr->special].mindepth);
3512 else if (feat == FEAT_TOWN)
3514 name = town[c_ptr->special].name;
3516 else if (p_ptr->wild_mode && (feat == FEAT_FLOOR))
3526 name = f_name + f_info[feat].name;
3531 if (*s2 && ((feat >= FEAT_MINOR_GLYPH) &&
3532 (feat <= FEAT_PATTERN_XTRA2)))
3541 else if (*s2 && ((feat >= FEAT_DOOR_HEAD) &&
3542 (feat <= FEAT_PERM_SOLID)))
3551 else if (*s2 && (feat == FEAT_TOWN))
3561 /* Hack -- special introduction for store & building doors -KMW- */
3562 if (((feat >= FEAT_SHOP_HEAD) && (feat <= FEAT_SHOP_TAIL)) ||
3563 ((feat >= FEAT_BLDG_HEAD) && (feat <= FEAT_BLDG_TAIL)) ||
3564 (feat == FEAT_MUSEUM) ||
3565 (feat == FEAT_ENTRANCE))
3574 else if ((feat == FEAT_TOWN) || (feat == FEAT_FLOOR) || (feat == FEAT_DIRT) || (feat == FEAT_FLOWER))
3582 /* Pick proper indefinite article */
3584 s3 = (is_a_vowel(name[0])) ? "an " : "a ";
3588 /* Display a message */
3591 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);
3593 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);
3597 sprintf(out_val, "%s%s%s%s[%s]", s1, name, s2, s3, info);
3599 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, name, info);
3603 move_cursor_relative(y, x);
3606 /* Always stop at "normal" keys */
3607 if ((query != '\r') && (query != '\n') && (query != ' ')) return query;
3610 /* Stop on everything but "return" */
3611 if ((query != '\r') && (query != '\n')) return query;
3613 /* Repeat forever */
3619 * Handle "target" and "look".
3621 * Note that this code can be called from "get_aim_dir()".
3623 * All locations must be on the current panel. Consider the use of
3624 * "panel_bounds()" to allow "off-panel" targets, perhaps by using
3625 * some form of "scrolling" the map around the cursor. XXX XXX XXX
3626 * That is, consider the possibility of "auto-scrolling" the screen
3627 * while the cursor moves around. This may require changes in the
3628 * "update_mon()" code to allow "visibility" even if off panel, and
3629 * may require dynamic recalculation of the "temp" grid set.
3631 * Hack -- targeting/observing an "outer border grid" may induce
3632 * problems, so this is not currently allowed.
3634 * The player can use the direction keys to move among "interesting"
3635 * grids in a heuristic manner, or the "space", "+", and "-" keys to
3636 * move through the "interesting" grids in a sequential manner, or
3637 * can enter "location" mode, and use the direction keys to move one
3638 * grid at a time in any direction. The "t" (set target) command will
3639 * only target a monster (as opposed to a location) if the monster is
3640 * target_able and the "interesting" mode is being used.
3642 * The current grid is described using the "look" method above, and
3643 * a new command may be entered at any time, but note that if the
3644 * "TARGET_LOOK" bit flag is set (or if we are in "location" mode,
3645 * where "space" has no obvious meaning) then "space" will scan
3646 * through the description of the current grid until done, instead
3647 * of immediately jumping to the next "interesting" grid. This
3648 * allows the "target" command to retain its old semantics.
3650 * The "*", "+", and "-" keys may always be used to jump immediately
3651 * to the next (or previous) interesting grid, in the proper mode.
3653 * The "return" key may always be used to scan through a complete
3654 * grid description (forever).
3656 * This command will cancel any old target, even if used from
3657 * inside the "look" command.
3659 bool target_set(int mode)
3679 get_screen_size(&wid, &hgt);
3685 /* Cancel tracking */
3686 /* health_track(0); */
3689 /* Prepare the "temp" array */
3690 target_set_prepare(mode);
3692 /* Start near the player */
3698 /* Interesting grids */
3704 if (!(mode & TARGET_LOOK)) prt_path(y, x);
3707 c_ptr = &cave[y][x];
3710 if (target_able(c_ptr->m_idx))
3713 strcpy(info, "q»ß t·è p¼« o¸½ +¼¡ -Á°");
3715 strcpy(info, "q,t,p,o,+,-,<dir>");
3720 /* Dis-allow target */
3724 strcpy(info, "q»ß p¼« o¸½ +¼¡ -Á°");
3726 strcpy(info, "q,p,o,+,-,<dir>");
3731 /* Describe and Prompt */
3732 while (!(query = target_set_aux(y, x, mode, info)));
3734 /* Cancel tracking */
3735 /* health_track(0); */
3737 /* Assume no "direction" */
3742 if (query == '\r') query = 't';
3760 if (target_able(c_ptr->m_idx))
3762 health_track(c_ptr->m_idx);
3763 target_who = c_ptr->m_idx;
3782 if (!expand_list) done = TRUE;
3792 if (!expand_list) done = TRUE;
3799 /* Recenter the map around the player */
3803 p_ptr->update |= (PU_MONSTERS);
3806 p_ptr->redraw |= (PR_MAP);
3809 p_ptr->window |= (PW_OVERHEAD);
3814 /* Recalculate interesting grids */
3815 target_set_prepare(mode);
3834 /* Extract the action (if any) */
3835 d = get_keymap_dir(query);
3842 /* Hack -- move around */
3845 /* Modified to scroll to monster */
3846 int y2 = panel_row_min;
3847 int x2 = panel_col_min;
3849 /* Find a new monster */
3850 i = target_pick(temp_y[m], temp_x[m], ddy[d], ddx[d]);
3852 /* Request to target past last interesting grid */
3853 while (flag && (i < 0))
3855 /* Note the change */
3856 if (change_panel(ddy[d], ddx[d]))
3861 /* Recalculate interesting grids */
3862 target_set_prepare(mode);
3864 /* Look at interesting grids */
3867 /* Find a new monster */
3868 i = target_pick(v, u, ddy[d], ddx[d]);
3874 /* Nothing interesting */
3880 /* Restore previous position */
3883 panel_bounds_center();
3886 p_ptr->update |= (PU_MONSTERS);
3889 p_ptr->redraw |= (PR_MAP);
3892 p_ptr->window |= (PW_OVERHEAD);
3897 /* Recalculate interesting grids */
3898 target_set_prepare(mode);
3900 /* Look at boring grids */
3907 /* Do not move horizontally if unnecessary */
3908 if (((x < panel_col_min + wid / 2) && (dx > 0)) ||
3909 ((x > panel_col_min + wid / 2) && (dx < 0)))
3914 /* Do not move vertically if unnecessary */
3915 if (((y < panel_row_min + hgt / 2) && (dy > 0)) ||
3916 ((y > panel_row_min + hgt / 2) && (dy < 0)))
3921 /* Apply the motion */
3922 if ((y >= panel_row_min+hgt) || (y < panel_row_min) ||
3923 (x >= panel_col_min+wid) || (x < panel_col_min))
3925 if (change_panel(dy, dx)) target_set_prepare(mode);
3928 /* Slide into legality */
3929 if (x >= cur_wid-1) x = cur_wid - 2;
3930 else if (x <= 0) x = 1;
3932 /* Slide into legality */
3933 if (y >= cur_hgt-1) y = cur_hgt- 2;
3934 else if (y <= 0) y = 1;
3943 /* Arbitrary grids */
3946 bool move_fast = FALSE;
3948 if (!(mode & TARGET_LOOK)) prt_path(y, x);
3951 c_ptr = &cave[y][x];
3953 /* Default prompt */
3955 strcpy(info, "q»ß t·è p¼« m¶á +¼¡ -Á°");
3957 strcpy(info, "q,t,p,m,+,-,<dir>");
3961 /* Describe and Prompt (enable "TARGET_LOOK") */
3962 while (!(query = target_set_aux(y, x, mode | TARGET_LOOK, info)));
3964 /* Cancel tracking */
3965 /* health_track(0); */
3967 /* Assume no direction */
3972 if (query == '\r') query = 't';
3975 /* Analyze the keypress */
3999 /* Recenter the map around the player */
4003 p_ptr->update |= (PU_MONSTERS);
4006 p_ptr->redraw |= (PR_MAP);
4009 p_ptr->window |= (PW_OVERHEAD);
4014 /* Recalculate interesting grids */
4015 target_set_prepare(mode);
4037 /* Pick a nearby monster */
4038 for (i = 0; i < temp_n; i++)
4040 t = distance(y, x, temp_y[i], temp_x[i]);
4050 /* Nothing interesting */
4051 if (bd == 999) flag = FALSE;
4058 /* Extract the action (if any) */
4059 d = get_keymap_dir(query);
4061 /* XTRA HACK MOVEFAST */
4062 if (isupper(query)) move_fast = TRUE;
4069 /* Handle "direction" */
4075 /* XTRA HACK MOVEFAST */
4078 int mag = MIN(wid / 2, hgt / 2);
4088 /* Do not move horizontally if unnecessary */
4089 if (((x < panel_col_min + wid / 2) && (dx > 0)) ||
4090 ((x > panel_col_min + wid / 2) && (dx < 0)))
4095 /* Do not move vertically if unnecessary */
4096 if (((y < panel_row_min + hgt / 2) && (dy > 0)) ||
4097 ((y > panel_row_min + hgt / 2) && (dy < 0)))
4102 /* Apply the motion */
4103 if ((y >= panel_row_min + hgt) || (y < panel_row_min) ||
4104 (x >= panel_col_min + wid) || (x < panel_col_min))
4106 if (change_panel(dy, dx)) target_set_prepare(mode);
4109 /* Slide into legality */
4110 if (x >= cur_wid-1) x = cur_wid - 2;
4111 else if (x <= 0) x = 1;
4113 /* Slide into legality */
4114 if (y >= cur_hgt-1) y = cur_hgt- 2;
4115 else if (y <= 0) y = 1;
4123 /* Clear the top line */
4126 /* Recenter the map around the player */
4130 p_ptr->update |= (PU_MONSTERS);
4133 p_ptr->redraw |= (PR_MAP);
4136 p_ptr->window |= (PW_OVERHEAD);
4141 /* Failure to set target */
4142 if (!target_who) return (FALSE);
4150 * Get an "aiming direction" from the user.
4152 * The "dir" is loaded with 1,2,3,4,6,7,8,9 for "actual direction", and
4153 * "0" for "current target", and "-1" for "entry aborted".
4155 * Note that "Force Target", if set, will pre-empt user interaction,
4156 * if there is a usable target already set.
4158 * Note that confusion over-rides any (explicit?) user choice.
4160 bool get_aim_dir(int *dp)
4171 /* Global direction */
4174 /* Hack -- auto-target if requested */
4175 if (use_old_target && target_okay()) dir = 5;
4177 #ifdef ALLOW_REPEAT /* TNB */
4179 if (repeat_pull(dp))
4184 if (!(*dp == 5 && !target_okay()))
4186 /* return (TRUE); */
4191 #endif /* ALLOW_REPEAT -- TNB */
4193 /* Ask until satisfied */
4196 /* Choose a prompt */
4200 p = "Êý¸þ ('*'¤Ç¥¿¡¼¥²¥Ã¥ÈÁªÂò, ESC¤ÇÃæÃÇ)? ";
4202 p = "Direction ('*' to choose a target, Escape to cancel)? ";
4209 p = "Êý¸þ ('5'¤Ç¥¿¡¼¥²¥Ã¥È¤Ø, '*'¤Ç¥¿¡¼¥²¥Ã¥ÈºÆÁªÂò, ESC¤ÇÃæÃÇ)? ";
4211 p = "Direction ('5' for target, '*' to re-target, Escape to cancel)? ";
4216 /* Get a command (or Cancel) */
4217 if (!get_com(p, &command, TRUE)) break;
4221 if (command == '\r') command = 't';
4224 /* Convert various keys to "standard" keys */
4227 /* Use current target */
4238 /* Set new target */
4243 if (target_set(TARGET_KILL)) dir = 5;
4249 /* Extract the action (if any) */
4250 dir = get_keymap_dir(command);
4256 /* Verify requested targets */
4257 if ((dir == 5) && !target_okay()) dir = 0;
4266 project_length = 0; /* reset to default */
4270 /* Save the direction */
4273 /* Check for confusion */
4274 if (p_ptr->confused)
4277 /* Random direction */
4278 dir = ddd[randint0(8)];
4281 /* Notice confusion */
4282 if (command_dir != dir)
4286 msg_print("¤¢¤Ê¤¿¤Ïº®Í𤷤Ƥ¤¤ë¡£");
4288 msg_print("You are confused.");
4293 /* Save direction */
4296 #ifdef ALLOW_REPEAT /* TNB */
4298 /* repeat_push(dir); */
4299 repeat_push(command_dir);
4301 #endif /* ALLOW_REPEAT -- TNB */
4303 /* A "valid" direction was entered */
4310 * Request a "movement" direction (1,2,3,4,6,7,8,9) from the user,
4311 * and place it into "command_dir", unless we already have one.
4313 * This function should be used for all "repeatable" commands, such as
4314 * run, walk, open, close, bash, disarm, spike, tunnel, etc, as well
4315 * as all commands which must reference a grid adjacent to the player,
4316 * and which may not reference the grid under the player. Note that,
4317 * for example, it is no longer possible to "disarm" or "open" chests
4318 * in the same grid as the player.
4320 * Direction "5" is illegal and will (cleanly) abort the command.
4322 * This function tracks and uses the "global direction", and uses
4323 * that as the "desired direction", to which "confusion" is applied.
4325 bool get_rep_dir(int *dp, bool under)
4332 /* Global direction */
4335 #ifdef ALLOW_REPEAT /* TNB */
4337 if (repeat_pull(dp))
4340 /* return (TRUE); */
4343 #endif /* ALLOW_REPEAT -- TNB */
4345 /* Get a direction */
4350 /* Get a command (or Cancel) */
4352 if (!get_com("Êý¸þ (ESC¤ÇÃæÃÇ)? ", &ch, TRUE)) break;
4354 if (!get_com("Direction (Escape to cancel)? ", &ch, TRUE)) break;
4358 /* Look up the direction */
4359 dir = get_keymap_dir(ch);
4365 /* Prevent weirdness */
4366 if ((dir == 5) && (!under)) dir = 0;
4369 if (!dir) return (FALSE);
4371 /* Save desired direction */
4374 /* Apply "confusion" */
4375 if (p_ptr->confused)
4377 /* Standard confusion */
4378 if (randint0(100) < 75)
4380 /* Random direction */
4381 dir = ddd[randint0(8)];
4384 else if (p_ptr->riding)
4386 monster_type *m_ptr = &m_list[p_ptr->riding];
4387 monster_race *r_ptr = &r_info[m_ptr->r_idx];
4389 if (m_ptr->confused)
4391 /* Standard confusion */
4392 if (randint0(100) < 75)
4394 /* Random direction */
4395 dir = ddd[randint0(8)];
4398 else if ((r_ptr->flags1 & RF1_RAND_50) && (r_ptr->flags1 & RF1_RAND_25) && (randint0(100) < 50))
4400 /* Random direction */
4401 dir = ddd[randint0(8)];
4403 else if ((r_ptr->flags1 & RF1_RAND_50) && (randint0(100) < 25))
4405 /* Random direction */
4406 dir = ddd[randint0(8)];
4410 /* Notice confusion */
4411 if (command_dir != dir)
4413 if (p_ptr->confused)
4417 msg_print("¤¢¤Ê¤¿¤Ïº®Í𤷤Ƥ¤¤ë¡£");
4419 msg_print("You are confused.");
4425 monster_type *m_ptr = &m_list[p_ptr->riding];
4427 monster_desc(m_name, m_ptr, 0);
4428 if (m_ptr->confused)
4431 msg_format("%s¤Ïº®Í𤷤Ƥ¤¤ë¡£", m_name);
4433 msg_format("%^s is confusing.", m_name);
4440 msg_format("%s¤Ï»×¤¤Ä̤ê¤ËÆ°¤¤¤Æ¤¯¤ì¤Ê¤¤¡£", m_name);
4442 msg_format("You cannot control %s.", m_name);
4448 /* Save direction */
4451 #ifdef ALLOW_REPEAT /* TNB */
4453 /* repeat_push(dir); */
4454 repeat_push(command_dir);
4456 #endif /* ALLOW_REPEAT -- TNB */
4463 bool get_rep_dir2(int *dp)
4470 /* Global direction */
4473 #ifdef ALLOW_REPEAT /* TNB */
4475 if (repeat_pull(dp))
4478 /* return (TRUE); */
4481 #endif /* ALLOW_REPEAT -- TNB */
4483 /* Get a direction */
4488 /* Get a command (or Cancel) */
4490 if (!get_com("Êý¸þ (ESC¤ÇÃæÃÇ)? ", &ch, TRUE)) break;
4492 if (!get_com("Direction (Escape to cancel)? ", &ch, TRUE)) break;
4496 /* Look up the direction */
4497 dir = get_keymap_dir(ch);
4503 /* Prevent weirdness */
4504 if (dir == 5) dir = 0;
4507 if (!dir) return (FALSE);
4509 /* Save desired direction */
4512 /* Apply "confusion" */
4513 if (p_ptr->confused)
4515 /* Standard confusion */
4516 if (randint0(100) < 75)
4518 /* Random direction */
4519 dir = ddd[randint0(8)];
4523 /* Notice confusion */
4524 if (command_dir != dir)
4528 msg_print("¤¢¤Ê¤¿¤Ïº®Í𤷤Ƥ¤¤ë¡£");
4530 msg_print("You are confused.");
4535 /* Save direction */
4538 #ifdef ALLOW_REPEAT /* TNB */
4540 /* repeat_push(dir); */
4541 repeat_push(command_dir);
4543 #endif /* ALLOW_REPEAT -- TNB */
4550 int get_chaos_patron(void)
4552 return ((p_ptr->age + p_ptr->sc) % MAX_PATRON);
4556 void gain_level_reward(int chosen_reward)
4560 char wrath_reason[32] = "";
4561 int nasty_chance = 6;
4562 int dummy = 0, dummy2 = 0;
4565 char o_name[MAX_NLEN];
4571 if (multi_rew) return;
4572 else multi_rew = TRUE;
4576 if (p_ptr->lev == 13) nasty_chance = 2;
4577 else if (!(p_ptr->lev % 13)) nasty_chance = 3;
4578 else if (!(p_ptr->lev % 14)) nasty_chance = 12;
4580 if (one_in_(nasty_chance))
4581 type = randint1(20); /* Allow the 'nasty' effects */
4583 type = randint1(15) + 5; /* Or disallow them */
4585 if (type < 1) type = 1;
4586 if (type > 20) type = 20;
4591 sprintf(wrath_reason, "%s¤ÎÅܤê",
4592 chaos_patrons[p_ptr->chaos_patron]);
4594 sprintf(wrath_reason, "the Wrath of %s",
4595 chaos_patrons[p_ptr->chaos_patron]);
4599 effect = chaos_rewards[p_ptr->chaos_patron][type];
4601 if (one_in_(6) && !chosen_reward)
4604 msg_format("%^s¤ÏË«Èþ¤È¤·¤Æ¤¢¤Ê¤¿¤òÆÍÁ³ÊÑ°Û¤µ¤»¤¿¡£",
4605 chaos_patrons[p_ptr->chaos_patron]);
4607 msg_format("%^s rewards you with a mutation!",
4608 chaos_patrons[p_ptr->chaos_patron]);
4611 (void)gain_random_mutation(0);
4613 reward = "ÊÑ°Û¤·¤¿¡£";
4615 reward = "mutation";
4620 switch (chosen_reward ? chosen_reward : effect)
4624 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
4625 chaos_patrons[p_ptr->chaos_patron]);
4627 msg_format("The voice of %s booms out:",
4628 chaos_patrons[p_ptr->chaos_patron]);
4632 msg_print("¡ÖÆò¡¢¿·¤¿¤Ê¤ë»Ñ¤òɬÍפȤ»¤ê¡ª¡×");
4634 msg_print("'Thou needst a new form, mortal!'");
4639 reward = "ÊÑ°Û¤·¤¿¡£";
4641 reward = "polymorphing";
4646 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
4647 chaos_patrons[p_ptr->chaos_patron]);
4649 msg_format("The voice of %s booms out:",
4650 chaos_patrons[p_ptr->chaos_patron]);
4654 msg_print("¡ÖÆò¤ÏÎɤ¯¹Ô¤¤¤¿¤ê¡ªÂ³¤±¤è¡ª¡×");
4656 msg_print("'Well done, mortal! Lead on!'");
4659 if (p_ptr->prace == RACE_ANDROID)
4662 msg_print("¤·¤«¤·²¿¤âµ¯¤³¤é¤Ê¤«¤Ã¤¿¡£");
4664 msg_print("But, nothing happen.");
4667 else if (p_ptr->exp < PY_MAX_EXP)
4669 s32b ee = (p_ptr->exp / 2) + 10;
4670 if (ee > 100000L) ee = 100000L;
4672 msg_print("¹¹¤Ë·Ð¸³¤òÀѤó¤À¤è¤¦¤Êµ¤¤¬¤¹¤ë¡£");
4674 msg_print("You feel more experienced.");
4679 reward = "·Ð¸³ÃͤòÆÀ¤¿";
4681 reward = "experience";
4687 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
4688 chaos_patrons[p_ptr->chaos_patron]);
4690 msg_format("The voice of %s booms out:",
4691 chaos_patrons[p_ptr->chaos_patron]);
4695 msg_print("¡Ö²¼Ëͤ衢Æò¤½¤ì¤ËÃͤ»¤º¡£¡×");
4697 msg_print("'Thou didst not deserve that, slave.'");
4700 if (p_ptr->prace == RACE_ANDROID)
4703 msg_print("¤·¤«¤·²¿¤âµ¯¤³¤é¤Ê¤«¤Ã¤¿¡£");
4705 msg_print("But, nothing happen.");
4710 lose_exp(p_ptr->exp / 6);
4712 reward = "·Ð¸³Ãͤò¼º¤Ã¤¿¡£";
4714 reward = "losing experience";
4720 msg_format("%s¤ÎÀ¼¤¬¤µ¤µ¤ä¤¤¤¿:",
4721 chaos_patrons[p_ptr->chaos_patron]);
4723 msg_format("The voice of %s whispers:",
4724 chaos_patrons[p_ptr->chaos_patron]);
4728 msg_print("¡Ö²æ¤¬Í¿¤¨¤·Êª¤ò¸ÌÀ¤Ë»È¤¦¤Ù¤·¡£¡×");
4730 msg_print("'Use my gift wisely.'");
4733 acquirement(py, px, 1, FALSE, FALSE);
4735 reward = "¾å¼Á¤Ê¥¢¥¤¥Æ¥à¤ò¼ê¤ËÆþ¤ì¤¿¡£";
4737 reward = "a good item";
4742 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
4743 chaos_patrons[p_ptr->chaos_patron]);
4745 msg_format("The voice of %s booms out:",
4746 chaos_patrons[p_ptr->chaos_patron]);
4750 msg_print("¡Ö²æ¤¬Í¿¤¨¤·Êª¤ò¸ÌÀ¤Ë»È¤¦¤Ù¤·¡£¡×");
4752 msg_print("'Use my gift wisely.'");
4755 acquirement(py, px, 1, TRUE, FALSE);
4757 reward = "¹âµéÉʤΥ¢¥¤¥Æ¥à¤ò¼ê¤ËÆþ¤ì¤¿¡£";
4759 reward = "an excellent item";
4764 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
4765 chaos_patrons[p_ptr->chaos_patron]);
4767 msg_format("The voice of %s booms out:",
4768 chaos_patrons[p_ptr->chaos_patron]);
4772 msg_print("¡ÖÆò¤Î¹Ô¤¤¤Ïµ®¤·õ¤ËÃͤ»¤ê¡£¡×");
4774 msg_print("'Thy deed hath earned thee a worthy blade.'");
4777 /* Get local object */
4780 switch (randint1(p_ptr->lev))
4786 dummy2 = SV_MAIN_GAUCHE;
4795 dummy2 = SV_SMALL_SWORD;
4798 dummy2 = SV_BASILLARD;
4800 case 11: case 12: case 13:
4801 dummy2 = SV_SHORT_SWORD;
4807 dummy2 = SV_CUTLASS;
4810 dummy2 = SV_WAKIZASHI;
4813 dummy2 = SV_KHOPESH;
4819 dummy2 = SV_BROAD_SWORD;
4822 dummy2 = SV_LONG_SWORD;
4825 dummy2 = SV_SCIMITAR;
4828 dummy2 = SV_NINJATO;
4834 dummy2 = SV_BASTARD_SWORD;
4837 dummy2 = SV_GREAT_SCIMITAR;
4840 dummy2 = SV_CLAYMORE;
4843 dummy2 = SV_ESPADON;
4846 dummy2 = SV_TWO_HANDED_SWORD;
4849 dummy2 = SV_FLAMBERGE;
4852 dummy2 = SV_NO_DACHI;
4855 dummy2 = SV_EXECUTIONERS_SWORD;
4858 dummy2 = SV_ZWEIHANDER;
4861 dummy2 = SV_HAYABUSA;
4864 dummy2 = SV_BLADE_OF_CHAOS;
4867 object_prep(q_ptr, lookup_kind(dummy, dummy2));
4868 q_ptr->to_h = 3 + randint1(dun_level) % 10;
4869 q_ptr->to_d = 3 + randint1(dun_level) % 10;
4870 one_resistance(q_ptr);
4871 q_ptr->name2 = EGO_CHAOTIC;
4873 /* Drop it in the dungeon */
4874 (void)drop_near(q_ptr, -1, py, px);
4876 reward = "(º®ÆÙ)¤ÎÉð´ï¤ò¼ê¤ËÆþ¤ì¤¿¡£";
4878 reward = "chaos weapon";
4883 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
4884 chaos_patrons[p_ptr->chaos_patron]);
4886 msg_format("The voice of %s booms out:",
4887 chaos_patrons[p_ptr->chaos_patron]);
4891 msg_print("¡ÖÆò¤Î¹Ô¤¤¤Ïµ®¤Ê󤤤ËÃͤ»¤ê¡£¡×");
4893 msg_print("'Thy deed hath earned thee a worthy reward.'");
4896 acquirement(py, px, randint1(2) + 1, FALSE, FALSE);
4898 reward = "¾å¼Á¤Ê¥¢¥¤¥Æ¥à¤ò¼ê¤ËÆþ¤ì¤¿¡£";
4900 reward = "good items";
4905 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
4906 chaos_patrons[p_ptr->chaos_patron]);
4908 msg_format("The voice of %s booms out:",
4909 chaos_patrons[p_ptr->chaos_patron]);
4913 msg_print("¡Ö²¼Ëͤ衢Æò¤Î¸¥¿È¤Ø¤Î²æ¤¬Àˤ·¤ß̵¤Ê󤤤ò¸«¤ë¤¬¤è¤¤¡£¡×");
4915 msg_print("'Behold, mortal, how generously I reward thy loyalty.'");
4918 acquirement(py, px, randint1(2) + 1, TRUE, FALSE);
4920 reward = "¹âµéÉʤΥ¢¥¤¥Æ¥à¤ò¼ê¤ËÆþ¤ì¤¿¡£";
4922 reward = "excellent items";
4927 msg_format("%s¤ÎÀ¼¤¬¹ì¤ÅϤä¿:",
4928 chaos_patrons[p_ptr->chaos_patron]);
4930 msg_format("The voice of %s thunders:",
4931 chaos_patrons[p_ptr->chaos_patron]);
4935 msg_print("¡Ö²¼Ëͤ衢ÆòÐþËý¤Ê¤ê¡£¡×");
4937 msg_print("'Thou art growing arrogant, mortal.'");
4940 (void)activate_ty_curse(FALSE, &count);
4942 reward = "²Ò¡¹¤·¤¤¼ö¤¤¤ò¤«¤±¤é¤ì¤¿¡£";
4949 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
4950 chaos_patrons[p_ptr->chaos_patron]);
4952 msg_format("The voice of %s booms out:",
4953 chaos_patrons[p_ptr->chaos_patron]);
4957 msg_print("¡Ö²æ¤¬²¼Ëͤ¿¤Á¤è¡¢¤«¤ÎÐþËý¤Ê¤ë¼Ô¤òÅݤ¹¤Ù¤·¡ª¡×");
4959 msg_print("'My pets, destroy the arrogant mortal!'");
4962 for (dummy = 0; dummy < randint1(5) + 1; dummy++)
4964 (void)summon_specific(0, py, px, dun_level, 0, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET));
4967 reward = "¥â¥ó¥¹¥¿¡¼¤ò¾¤´¤µ¤ì¤¿¡£";
4969 reward = "summoning hostile monsters";
4974 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
4975 chaos_patrons[p_ptr->chaos_patron]);
4977 msg_format("The voice of %s booms out:",
4978 chaos_patrons[p_ptr->chaos_patron]);
4982 msg_print("¡ÖÆò¡¢¤è¤ê¶¯¤Å¨¤òɬÍפȤ»¤ê¡ª¡×");
4984 msg_print("'Thou needst worthier opponents!'");
4987 activate_hi_summon(py, px, FALSE);
4989 reward = "¥â¥ó¥¹¥¿¡¼¤ò¾¤´¤µ¤ì¤¿¡£";
4991 reward = "summoning many hostile monsters";
4996 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
4997 chaos_patrons[p_ptr->chaos_patron]);
4999 msg_format("The voice of %s booms out:",
5000 chaos_patrons[p_ptr->chaos_patron]);
5004 msg_print("¡Ö»à¤ÈÇ˲õ¤³¤½²æ¤¬´î¤Ó¤Ê¤ê¡ª¡×");
5006 msg_print("'Death and destruction! This pleaseth me!'");
5011 reward = "¥«¥ª¥¹¤ÎÎϤ¬±²´¬¤¤¤¿¡£";
5013 reward = "calling chaos";
5018 msg_format("%s¤ÎÀ¼¤¬ÌĤê¶Á¤¤¤¿:",
5019 chaos_patrons[p_ptr->chaos_patron]);
5021 msg_format("The voice of %s rings out:",
5022 chaos_patrons[p_ptr->chaos_patron]);
5026 msg_print("¡Öα¤Þ¤ë¤Î¤À¡¢²¼Ëͤ衣;¤¬Æò¤ÎÆùÂΤòÃ䨤󡣡×");
5028 msg_print("'Stay, mortal, and let me mold thee.'");
5031 if (one_in_(3) && !(chaos_stats[p_ptr->chaos_patron] < 0))
5032 do_inc_stat(chaos_stats[p_ptr->chaos_patron]);
5034 do_inc_stat(randint0(6));
5036 reward = "ǽÎÏÃͤ¬¾å¤¬¤Ã¤¿¡£";
5038 reward = "increasing a stat";
5043 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5044 chaos_patrons[p_ptr->chaos_patron]);
5046 msg_format("The voice of %s booms out:",
5047 chaos_patrons[p_ptr->chaos_patron]);
5051 msg_print("¡Ö²¼Ëͤ衢;¤ÏÆò¤ËË°¤ß¤¿¤ê¡£¡×");
5053 msg_print("'I grow tired of thee, mortal.'");
5056 if (one_in_(3) && !(chaos_stats[p_ptr->chaos_patron] < 0))
5057 do_dec_stat(chaos_stats[p_ptr->chaos_patron]);
5059 (void)do_dec_stat(randint0(6));
5061 reward = "ǽÎÏÃͤ¬²¼¤¬¤Ã¤¿¡£";
5063 reward = "decreasing a stat";
5068 msg_format("%s¤ÎÀ¼¤¬¹ì¤ÅϤä¿:",
5069 chaos_patrons[p_ptr->chaos_patron]);
5071 msg_format("The voice of %s thunders:",
5072 chaos_patrons[p_ptr->chaos_patron]);
5076 msg_print("¡ÖÆò¡¢¸¬µõ¤¿¤ë¤³¤È¤ò³Ø¤Ö¤Ù¤·¡ª¡×");
5077 msg_print("¤¢¤Ê¤¿¤Ï°ÊÁ°¤è¤ê¼å¤¯¤Ê¤Ã¤¿¡ª");
5079 msg_print("'Thou needst a lesson in humility, mortal!'");
5080 msg_print("You feel less powerful!");
5083 for (dummy = 0; dummy < 6; dummy++)
5085 (void)dec_stat(dummy, 10 + randint1(15), TRUE);
5088 reward = "Á´Ç½ÎÏÃͤ¬²¼¤¬¤Ã¤¿¡£";
5090 reward = "decreasing all stats";
5095 msg_format("%s¤ÎÎϤ¬¿¨¤ì¤ë¤Î¤ò´¶¤¸¤¿¡£",
5097 msg_format("You feel the power of %s touch you.",
5100 chaos_patrons[p_ptr->chaos_patron]);
5103 reward = "½ý¤¬ÊѲ½¤·¤¿¡£";
5105 reward = "polymorphing wounds";
5110 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5111 chaos_patrons[p_ptr->chaos_patron]);
5113 msg_format("The voice of %s booms out:",
5114 chaos_patrons[p_ptr->chaos_patron]);
5118 msg_print("¡Ö²æ¤¬¤µ¤µ¤ä¤«¤Ê¤ë»òʪ¤ò¼õ¤±¤È¤ë¤¬¤è¤¤¡ª¡×");
5120 msg_print("'Receive this modest gift from me!'");
5123 for (dummy = 0; dummy < 6; dummy++)
5125 (void)do_inc_stat(dummy);
5128 reward = "Á´Ç½ÎÏÃͤ¬¾å¤¬¤Ã¤¿¡£";
5130 reward = "increasing all stats";
5135 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5136 chaos_patrons[p_ptr->chaos_patron]);
5138 msg_format("The voice of %s booms out:",
5139 chaos_patrons[p_ptr->chaos_patron]);
5143 msg_print("¡Ö¶ì¤·¤à¤¬¤è¤¤¡¢ÌµÇ½¤Ê¶ò¤«¼Ô¤è¡ª¡×");
5145 msg_print("'Suffer, pathetic fool!'");
5148 fire_ball(GF_DISINTEGRATE, 0, p_ptr->lev * 4, 4);
5149 take_hit(DAMAGE_NOESCAPE, p_ptr->lev * 4, wrath_reason, -1);
5151 reward = "ʬ²ò¤Îµå¤¬È¯À¸¤·¤¿¡£";
5153 reward = "generating disintegration ball";
5158 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5159 chaos_patrons[p_ptr->chaos_patron]);
5161 msg_format("The voice of %s booms out:",
5162 chaos_patrons[p_ptr->chaos_patron]);
5166 msg_print("¡Öᴤ뤬¤è¤¤¡¢²æ¤¬²¼Ëͤ衪¡×");
5168 msg_print("'Rise, my servant!'");
5172 (void)set_poisoned(0);
5174 (void)set_confused(0);
5179 for (dummy = 0; dummy < 6; dummy++)
5181 (void)do_res_stat(dummy);
5184 reward = "ÂÎÎϤ¬²óÉü¤·¤¿¡£";
5190 if (!buki_motteruka(INVEN_RARM)) break;
5192 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5193 chaos_patrons[p_ptr->chaos_patron]);
5195 msg_format("The voice of %s booms out:",
5196 chaos_patrons[p_ptr->chaos_patron]);
5200 msg_print("¡ÖÆò¡¢Éð´ï¤ËÍê¤ë¤³¤È¤Ê¤«¤ì¡£¡×");
5202 msg_print("'Thou reliest too much on thy weapon.'");
5205 object_desc(o_name, &inventory[INVEN_RARM], TRUE, 0);
5206 (void)curse_weapon(FALSE, INVEN_RARM);
5208 reward = format("%s¤¬Ç˲õ¤µ¤ì¤¿¡£", o_name);
5210 reward = format("destroying %s", o_name);
5214 if (!inventory[INVEN_BODY].k_idx) break;
5216 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5217 chaos_patrons[p_ptr->chaos_patron]);
5219 msg_format("The voice of %s booms out:",
5220 chaos_patrons[p_ptr->chaos_patron]);
5224 msg_print("¡ÖÆò¡¢Ëɶñ¤ËÍê¤ë¤³¤È¤Ê¤«¤ì¡£¡×");
5226 msg_print("'Thou reliest too much on thine equipment.'");
5229 object_desc(o_name, &inventory[INVEN_BODY], TRUE, 0);
5230 (void)curse_armor();
5232 reward = format("%s¤¬Ç˲õ¤µ¤ì¤¿¡£", o_name);
5234 reward = format("destroying %s", o_name);
5239 msg_format("%s¤ÎÀ¼¤¬¤µ¤µ¤ä¤¤¤¿:",
5240 chaos_patrons[p_ptr->chaos_patron]);
5242 msg_format("The voice of %s whispers:",
5243 chaos_patrons[p_ptr->chaos_patron]);
5247 msg_print("¡Ö²æ¤òÅܤꤷ¤á¤¿ºá¤ò½þ¤¦¤Ù¤·¡£¡×");
5249 msg_print("'Now thou shalt pay for annoying me.'");
5252 switch (randint1(4))
5255 (void)activate_ty_curse(FALSE, &count);
5257 reward = "²Ò¡¹¤·¤¤¼ö¤¤¤ò¤«¤±¤é¤ì¤¿¡£";
5263 activate_hi_summon(py, px, FALSE);
5265 reward = "¥â¥ó¥¹¥¿¡¼¤ò¾¤´¤µ¤ì¤¿¡£";
5267 reward = "summoning hostile monsters";
5273 if (!buki_motteruka(INVEN_RARM)) break;
5274 object_desc(o_name, &inventory[INVEN_RARM], TRUE, 0);
5275 (void)curse_weapon(FALSE, INVEN_RARM);
5277 reward = format("%s¤¬Ç˲õ¤µ¤ì¤¿¡£", o_name);
5279 reward = format("destroying %s", o_name);
5284 if (!inventory[INVEN_BODY].k_idx) break;
5285 object_desc(o_name, &inventory[INVEN_BODY], TRUE, 0);
5286 (void)curse_armor();
5288 reward = format("%s¤¬Ç˲õ¤µ¤ì¤¿¡£", o_name);
5290 reward = format("destroying %s", o_name);
5295 for (dummy = 0; dummy < 6; dummy++)
5297 (void)dec_stat(dummy, 10 + randint1(15), TRUE);
5300 reward = "Á´Ç½ÎÏÃͤ¬²¼¤¬¤Ã¤¿¡£";
5302 reward = "decreasing all stats";
5309 msg_format("%s¤ÎÀ¼¤¬¹ì¤ÅϤä¿:",
5311 msg_format("The voice of %s thunders:",
5314 chaos_patrons[p_ptr->chaos_patron]);
5316 msg_print("¡Ö»à¤Ì¤¬¤è¤¤¡¢²¼Ëͤ衪¡×");
5318 msg_print("'Die, mortal!'");
5321 take_hit(DAMAGE_LOSELIFE, p_ptr->lev * 4, wrath_reason, -1);
5322 for (dummy = 0; dummy < 6; dummy++)
5324 (void)dec_stat(dummy, 10 + randint1(15), FALSE);
5326 activate_hi_summon(py, px, FALSE);
5327 (void)activate_ty_curse(FALSE, &count);
5328 if (one_in_(2)) (void)curse_weapon(FALSE, INVEN_RARM);
5329 if (one_in_(2)) (void)curse_armor();
5333 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5334 chaos_patrons[p_ptr->chaos_patron]);
5336 msg_format("The voice of %s booms out:",
5337 chaos_patrons[p_ptr->chaos_patron]);
5341 msg_print("¡Ö»à¤ÈÇ˲õ¤³¤½²æ¤¬´î¤Ó¤Ê¤ê¡ª¡×");
5343 msg_print("'Death and destruction! This pleaseth me!'");
5346 destroy_area(py, px, 25);
5348 reward = "¥À¥ó¥¸¥ç¥ó¤¬*Ç˲õ*¤µ¤ì¤¿¡£";
5350 reward = "*destruct*ing dungeon";
5355 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5356 chaos_patrons[p_ptr->chaos_patron]);
5358 msg_format("The voice of %s booms out:",
5359 chaos_patrons[p_ptr->chaos_patron]);
5363 msg_print("¡Ö²æ¡¢Æò¤ÎŨ¤òËõ»¦¤»¤ó¡ª¡×");
5365 msg_print("'Let me relieve thee of thine oppressors!'");
5368 (void)symbol_genocide(0, FALSE);
5370 reward = "¥â¥ó¥¹¥¿¡¼¤¬Ëõ»¦¤µ¤ì¤¿¡£";
5372 reward = "genociding monsters";
5377 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5378 chaos_patrons[p_ptr->chaos_patron]);
5380 msg_format("The voice of %s booms out:",
5381 chaos_patrons[p_ptr->chaos_patron]);
5385 msg_print("¡Ö²æ¡¢Æò¤ÎŨ¤òËõ»¦¤»¤ó¡ª¡×");
5387 msg_print("'Let me relieve thee of thine oppressors!'");
5390 (void)mass_genocide(0, FALSE);
5392 reward = "¥â¥ó¥¹¥¿¡¼¤¬Ëõ»¦¤µ¤ì¤¿¡£";
5394 reward = "genociding nearby monsters";
5399 msg_format("%s¤ÎÎϤ¬Å¨¤ò¹¶·â¤¹¤ë¤Î¤ò´¶¤¸¤¿¡ª",
5400 chaos_patrons[p_ptr->chaos_patron]);
5402 msg_format("You can feel the power of %s assault your enemies!",
5403 chaos_patrons[p_ptr->chaos_patron]);
5406 (void)dispel_monsters(p_ptr->lev * 4);
5410 msg_format("%s¤Ï¤¢¤Ê¤¿¤ò̵»ë¤·¤¿¡£",
5411 chaos_patrons[p_ptr->chaos_patron]);
5413 msg_format("%s ignores you.",
5414 chaos_patrons[p_ptr->chaos_patron]);
5420 msg_format("%s¤ÏË«Èþ¤È¤·¤Æ°Ëâ¤Î»È¤¤¤ò¤è¤³¤·¤¿¡ª",chaos_patrons[p_ptr->chaos_patron]);
5422 msg_format("%s rewards you with a demonic servant!",chaos_patrons[p_ptr->chaos_patron]);
5425 if (!summon_specific(-1, py, px, dun_level, SUMMON_DEMON, PM_FORCE_PET))
5427 msg_print("²¿¤â¸½¤ì¤Ê¤«¤Ã¤¿...");
5429 msg_print("Nobody ever turns up...");
5433 reward = "°Ë⤬¥Ú¥Ã¥È¤Ë¤Ê¤Ã¤¿¡£";
5435 reward = "a demonic servant";
5441 msg_format("%s¤ÏË«Èþ¤È¤·¤Æ»È¤¤¤ò¤è¤³¤·¤¿¡ª",chaos_patrons[p_ptr->chaos_patron]);
5443 msg_format("%s rewards you with a servant!",chaos_patrons[p_ptr->chaos_patron]);
5446 if (!summon_specific(-1, py, px, dun_level, 0, PM_FORCE_PET))
5448 msg_print("²¿¤â¸½¤ì¤Ê¤«¤Ã¤¿...");
5450 msg_print("Nobody ever turns up...");
5454 reward = "¥â¥ó¥¹¥¿¡¼¤¬¥Ú¥Ã¥È¤Ë¤Ê¤Ã¤¿¡£";
5456 reward = "a servant";
5462 msg_format("%s¤ÏË«Èþ¤È¤·¤Æ¥¢¥ó¥Ç¥Ã¥É¤Î»È¤¤¤ò¤è¤³¤·¤¿¡£",chaos_patrons[p_ptr->chaos_patron]);
5464 msg_format("%s rewards you with an undead servant!",chaos_patrons[p_ptr->chaos_patron]);
5467 if (!summon_specific(-1, py, px, dun_level, SUMMON_UNDEAD, PM_FORCE_PET))
5469 msg_print("²¿¤â¸½¤ì¤Ê¤«¤Ã¤¿...");
5471 msg_print("Nobody ever turns up...");
5475 reward = "¥¢¥ó¥Ç¥Ã¥É¤¬¥Ú¥Ã¥È¤Ë¤Ê¤Ã¤¿¡£";
5477 reward = "an undead servant";
5483 msg_format("%s¤ÎÀ¼¤¬¤É¤â¤Ã¤¿:",
5485 msg_format("The voice of %s stammers:",
5488 chaos_patrons[p_ptr->chaos_patron]);
5490 msg_format("¡Ö¤¢¡¼¡¢¤¢¡¼¡¢Åú¤¨¤Ï %d/%d¡£¼ÁÌä¤Ï²¿¡©¡×", type, effect);
5492 msg_format("'Uh... uh... the answer's %d/%d, what's the question?'", type, effect);
5500 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, format("¥Ñ¥È¥í¥ó¤ÎÊó½·¤Ç%s", reward));
5502 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, format("The patron rewards you with %s.", reward));
5509 * old -- from PsiAngband.
5511 bool tgt_pt(int *x_ptr, int *y_ptr)
5515 bool success = FALSE;
5520 get_screen_size(&wid, &hgt);
5526 msg_print("¾ì½ê¤òÁª¤ó¤Ç¥¹¥Ú¡¼¥¹¥¡¼¤ò²¡¤·¤Æ²¼¤µ¤¤¡£");
5528 msg_print("Select a point and press space.");
5530 msg_flag = FALSE; /* prevents "-more-" message. */
5532 while ((ch != ESCAPE) && !success)
5534 bool move_fast = FALSE;
5536 move_cursor_relative(y, x);
5548 if (x == px && y == py) ch = 0;
5551 else success = TRUE;
5555 /* Look up the direction */
5556 d = get_keymap_dir(ch);
5558 /* XTRA HACK MOVEFAST */
5559 if (isupper(ch)) move_fast = TRUE;
5561 /* Handle "direction" */
5567 /* XTRA HACK MOVEFAST */
5570 int mag = MIN(wid / 2, hgt / 2);
5580 /* Do not move horizontally if unnecessary */
5581 if (((x < panel_col_min + wid / 2) && (dx > 0)) ||
5582 ((x > panel_col_min + wid / 2) && (dx < 0)))
5587 /* Do not move vertically if unnecessary */
5588 if (((y < panel_row_min + hgt / 2) && (dy > 0)) ||
5589 ((y > panel_row_min + hgt / 2) && (dy < 0)))
5594 /* Apply the motion */
5595 if ((y >= panel_row_min + hgt) || (y < panel_row_min) ||
5596 (x >= panel_col_min + wid) || (x < panel_col_min))
5598 /* if (change_panel(dy, dx)) target_set_prepare(mode); */
5599 change_panel(dy, dx);
5602 /* Slide into legality */
5603 if (x >= cur_wid-1) x = cur_wid - 2;
5604 else if (x <= 0) x = 1;
5606 /* Slide into legality */
5607 if (y >= cur_hgt-1) y = cur_hgt- 2;
5608 else if (y <= 0) y = 1;
5615 /* Clear the top line */
5618 /* Recenter the map around the player */
5622 p_ptr->update |= (PU_MONSTERS);
5625 p_ptr->redraw |= (PR_MAP);
5628 p_ptr->window |= (PW_OVERHEAD);
5639 bool get_hack_dir(int *dp)
5649 /* Global direction */
5652 /* (No auto-targeting) */
5654 /* Ask until satisfied */
5657 /* Choose a prompt */
5661 p = "Êý¸þ ('*'¤Ç¥¿¡¼¥²¥Ã¥ÈÁªÂò, ESC¤ÇÃæÃÇ)? ";
5663 p = "Direction ('*' to choose a target, Escape to cancel)? ";
5670 p = "Êý¸þ ('5'¤Ç¥¿¡¼¥²¥Ã¥È¤Ø, '*'¤Ç¥¿¡¼¥²¥Ã¥ÈºÆÁªÂò, ESC¤ÇÃæÃÇ)? ";
5672 p = "Direction ('5' for target, '*' to re-target, Escape to cancel)? ";
5677 /* Get a command (or Cancel) */
5678 if (!get_com(p, &command, TRUE)) break;
5682 if (command == '\r') command = 't';
5685 /* Convert various keys to "standard" keys */
5688 /* Use current target */
5699 /* Set new target */
5704 if (target_set(TARGET_KILL)) dir = 5;
5710 /* Look up the direction */
5711 dir = get_keymap_dir(command);
5717 /* Verify requested targets */
5718 if ((dir == 5) && !target_okay()) dir = 0;
5725 if (!dir) return (FALSE);
5727 /* Save the direction */
5730 /* Check for confusion */
5731 if (p_ptr->confused)
5734 /* Random direction */
5735 dir = ddd[randint0(8)];
5738 /* Notice confusion */
5739 if (command_dir != dir)
5743 msg_print("¤¢¤Ê¤¿¤Ïº®Í𤷤Ƥ¤¤ë¡£");
5745 msg_print("You are confused.");
5750 /* Save direction */
5753 /* A "valid" direction was entered */
5759 * ¥¨¥Í¥ë¥®¡¼¤ÎÁý²ÃÎÌ10d5¤ò®¤¯·×»»¤¹¤ë¤¿¤á¤Î´Ø¿ô
5762 #define Go_no_JuuJou 5*5*5*5*5*5*5*5*5*5
5764 s16b gain_energy(void)
5767 s32b energy_result = 10;
5770 tmp = randint0(Go_no_JuuJou);
5772 for (i = 0; i < 9; i ++){
5773 energy_result += tmp % 5;
5777 return (s16b)(energy_result + tmp);
5784 s16b bow_energy(int sval)
5788 /* Analyze the launcher */
5791 /* Sling and ammo */
5798 /* Short Bow and Arrow */
5805 /* Long Bow and Arrow */
5812 /* Bow of irresponsiblity and Arrow */
5819 /* Light Crossbow and Bolt */
5826 /* Heavy Crossbow and Bolt */
5841 int bow_tmul(int sval)
5845 /* Analyze the launcher */
5848 /* Sling and ammo */
5855 /* Short Bow and Arrow */
5862 /* Long Bow and Arrow */
5869 /* Bow of irresponsiblity and Arrow */
5876 /* Light Crossbow and Bolt */
5883 /* Heavy Crossbow and Bolt */
5895 * Return alignment title
5897 cptr your_alignment(void)
5900 if (p_ptr->align > 150) return "ÂçÁ±";
5901 else if (p_ptr->align > 50) return "ÃæÁ±";
5902 else if (p_ptr->align > 10) return "¾®Á±";
5903 else if (p_ptr->align > -11) return "ÃæΩ";
5904 else if (p_ptr->align > -51) return "¾®°";
5905 else if (p_ptr->align > -151) return "Ãæ°";
5908 if (p_ptr->align > 150) return "Lawful";
5909 else if (p_ptr->align > 50) return "Good";
5910 else if (p_ptr->align > 10) return "Neutral Good";
5911 else if (p_ptr->align > -11) return "Neutral";
5912 else if (p_ptr->align > -51) return "Neutral Evil";
5913 else if (p_ptr->align > -151) return "Evil";
5914 else return "Chaotic";
5920 * Return proficiency level of weapons and misc. skills (except riding)
5922 int weapon_exp_level(int weapon_exp)
5924 if (weapon_exp < WEAPON_EXP_BEGINNER) return EXP_LEVEL_UNSKILLED;
5925 else if (weapon_exp < WEAPON_EXP_SKILLED) return EXP_LEVEL_BEGINNER;
5926 else if (weapon_exp < WEAPON_EXP_EXPERT) return EXP_LEVEL_SKILLED;
5927 else if (weapon_exp < WEAPON_EXP_MASTER) return EXP_LEVEL_EXPERT;
5928 else return EXP_LEVEL_MASTER;
5933 * Return proficiency level of riding
5935 int riding_exp_level(int riding_exp)
5937 if (riding_exp < RIDING_EXP_BEGINNER) return EXP_LEVEL_UNSKILLED;
5938 else if (riding_exp < RIDING_EXP_SKILLED) return EXP_LEVEL_BEGINNER;
5939 else if (riding_exp < RIDING_EXP_EXPERT) return EXP_LEVEL_SKILLED;
5940 else if (riding_exp < RIDING_EXP_MASTER) return EXP_LEVEL_EXPERT;
5941 else return EXP_LEVEL_MASTER;
5946 * Return proficiency level of spells
5948 int spell_exp_level(int spell_exp)
5950 if (spell_exp < SPELL_EXP_BEGINNER) return EXP_LEVEL_UNSKILLED;
5951 else if (spell_exp < SPELL_EXP_SKILLED) return EXP_LEVEL_BEGINNER;
5952 else if (spell_exp < SPELL_EXP_EXPERT) return EXP_LEVEL_SKILLED;
5953 else if (spell_exp < SPELL_EXP_MASTER) return EXP_LEVEL_EXPERT;
5954 else return EXP_LEVEL_MASTER;