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)
24 bool level_reward = FALSE;
25 bool level_mutation = FALSE;
26 bool level_inc_stat = FALSE;
27 bool android = (p_ptr->prace == RACE_ANDROID ? TRUE : FALSE);
30 /* Note current level */
33 /* Hack -- lower limit */
34 if (p_ptr->exp < 0) p_ptr->exp = 0;
36 /* Hack -- lower limit */
37 if (p_ptr->max_exp < 0) p_ptr->max_exp = 0;
39 /* Hack -- upper limit */
40 if (p_ptr->exp > PY_MAX_EXP) p_ptr->exp = PY_MAX_EXP;
42 /* Hack -- upper limit */
43 if (p_ptr->max_exp > PY_MAX_EXP) p_ptr->max_exp = PY_MAX_EXP;
45 /* Hack -- maintain "max" experience */
46 if (p_ptr->exp > p_ptr->max_exp) p_ptr->max_exp = p_ptr->exp;
48 /* Redraw experience */
49 p_ptr->redraw |= (PR_EXP);
55 /* Lose levels while possible */
56 while ((p_ptr->lev > 1) &&
57 (p_ptr->exp < ((android ? player_exp_a : player_exp)[p_ptr->lev - 2] * p_ptr->expfact / 100L)))
62 /* Update some stuff */
63 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
65 /* Redraw some stuff */
66 p_ptr->redraw |= (PR_LEV | PR_TITLE);
69 p_ptr->window |= (PW_PLAYER);
76 /* Gain levels while possible */
77 while ((p_ptr->lev < PY_MAX_LEVEL) &&
78 (p_ptr->exp >= ((android ? player_exp_a : player_exp)[p_ptr->lev-1] * p_ptr->expfact / 100L)))
83 /* Save the highest level */
84 if (p_ptr->lev > p_ptr->max_plv)
86 p_ptr->max_plv = p_ptr->lev;
88 if ((p_ptr->pclass == CLASS_CHAOS_WARRIOR) ||
89 (p_ptr->muta2 & MUT2_CHAOS_GIFT))
93 if (p_ptr->prace == RACE_BEASTMAN)
95 if (one_in_(5)) level_mutation = TRUE;
97 level_inc_stat = TRUE;
99 do_cmd_write_nikki(NIKKI_LEVELUP, p_ptr->lev, NULL);
107 msg_format("¥ì¥Ù¥ë %d ¤Ë¤è¤¦¤³¤½¡£", p_ptr->lev);
109 msg_format("Welcome to level %d.", p_ptr->lev);
112 /* Update some stuff */
113 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
115 /* Redraw some stuff */
116 p_ptr->redraw |= (PR_LEV | PR_TITLE);
119 p_ptr->window |= (PW_PLAYER | PW_SPELL);
121 /* HP¤ÈMP¤Î¾å¾ºÎ̤òɽ¼¨ */
131 if(!(p_ptr->max_plv % 10))
141 cnv_stat(p_ptr->stat_max[0], tmp);
142 prt(format(" a) ÏÓÎÏ (¸½ºßÃÍ %s)", tmp), 2, 14);
143 cnv_stat(p_ptr->stat_max[1], tmp);
144 prt(format(" b) ÃÎǽ (¸½ºßÃÍ %s)", tmp), 3, 14);
145 cnv_stat(p_ptr->stat_max[2], tmp);
146 prt(format(" c) ¸¤µ (¸½ºßÃÍ %s)", tmp), 4, 14);
147 cnv_stat(p_ptr->stat_max[3], tmp);
148 prt(format(" d) ´ïÍÑ (¸½ºßÃÍ %s)", tmp), 5, 14);
149 cnv_stat(p_ptr->stat_max[4], tmp);
150 prt(format(" e) ÂÑµ× (¸½ºßÃÍ %s)", tmp), 6, 14);
151 cnv_stat(p_ptr->stat_max[5], tmp);
152 prt(format(" f) Ì¥ÎÏ (¸½ºßÃÍ %s)", tmp), 7, 14);
154 prt(" ¤É¤ÎǽÎÏÃͤò¾å¤²¤Þ¤¹¤«¡©", 1, 14);
156 cnv_stat(p_ptr->stat_max[0], tmp);
157 prt(format(" a) Str (cur %s)", tmp), 2, 14);
158 cnv_stat(p_ptr->stat_max[1], tmp);
159 prt(format(" b) Int (cur %s)", tmp), 3, 14);
160 cnv_stat(p_ptr->stat_max[2], tmp);
161 prt(format(" c) Wis (cur %s)", tmp), 4, 14);
162 cnv_stat(p_ptr->stat_max[3], tmp);
163 prt(format(" d) Dex (cur %s)", tmp), 5, 14);
164 cnv_stat(p_ptr->stat_max[4], tmp);
165 prt(format(" e) Con (cur %s)", tmp), 6, 14);
166 cnv_stat(p_ptr->stat_max[5], tmp);
167 prt(format(" f) Chr (cur %s)", tmp), 7, 14);
169 prt(" Which stat do you want to raise?", 1, 14);
174 if ((choice >= 'a') && (choice <= 'f')) break;
176 for(n = 0; n < 6; n++)
177 if (n != choice - 'a')
180 if (get_check("¤è¤í¤·¤¤¤Ç¤¹¤«¡©")) break;
182 if (get_check("Are you sure? ")) break;
185 do_inc_stat(choice - 'a');
188 else if(!(p_ptr->max_plv % 2))
189 do_inc_stat(randint0(6));
195 msg_print("¤¢¤Ê¤¿¤ÏÊѤï¤Ã¤¿µ¤¤¬¤¹¤ë...");
197 msg_print("You feel different...");
200 (void)gain_random_mutation(0);
201 level_mutation = FALSE;
205 * Ê󽷤ǥì¥Ù¥ë¤¬¾å¤ë¤ÈºÆµ¢Åª¤Ë check_experience() ¤¬
206 * ¸Æ¤Ð¤ì¤ë¤Î¤Ç½çÈÖ¤òºÇ¸å¤Ë¤¹¤ë¡£
210 gain_level_reward(0);
211 level_reward = FALSE;
214 /* Update some stuff */
215 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
217 /* Redraw some stuff */
218 p_ptr->redraw |= (PR_LEV | PR_TITLE);
221 p_ptr->window |= (PW_PLAYER | PW_SPELL);
230 * Hack -- Return the "automatic coin type" of a monster race
231 * Used to allocate proper treasure when "Creeping coins" die
233 * XXX XXX XXX Note the use of actual "monster names"
235 static int get_coin_type(int r_idx)
237 monster_race *r_ptr = &r_info[r_idx];
239 /* Analyze "coin" monsters */
240 if (r_ptr->d_char == '$')
242 /* Look for textual clues */
245 case MON_COPPER_COINS: return (2);
246 case MON_SILVER_COINS: return (5);
247 case MON_GOLD_COINS: return (10);
248 case MON_MITHRIL_COINS: return (16);
249 case MON_ADAMANT_COINS: return (17);
259 * Hack -- determine if a template is Cloak
261 static bool kind_is_cloak(int k_idx)
263 object_kind *k_ptr = &k_info[k_idx];
265 /* Analyze the item type */
266 if (k_ptr->tval == TV_CLOAK)
271 /* Assume not good */
277 * Hack -- determine if a template is Polearm
279 static bool kind_is_polearm(int k_idx)
281 object_kind *k_ptr = &k_info[k_idx];
283 /* Analyze the item type */
284 if (k_ptr->tval == TV_POLEARM)
289 /* Assume not good */
295 * Hack -- determine if a template is Sword
297 static bool kind_is_sword(int k_idx)
299 object_kind *k_ptr = &k_info[k_idx];
301 /* Analyze the item type */
302 if ((k_ptr->tval == TV_SWORD) && (k_ptr->sval > 2))
307 /* Assume not good */
313 * Hack -- determine if a template is Book
315 static bool kind_is_book(int k_idx)
317 object_kind *k_ptr = &k_info[k_idx];
319 /* Analyze the item type */
320 if ((k_ptr->tval >= TV_LIFE_BOOK) && (k_ptr->tval <= TV_CRUSADE_BOOK))
325 /* Assume not good */
331 * Hack -- determine if a template is Good book
333 static bool kind_is_good_book(int k_idx)
335 object_kind *k_ptr = &k_info[k_idx];
337 /* Analyze the item type */
338 if ((k_ptr->tval >= TV_LIFE_BOOK) && (k_ptr->tval <= TV_CRUSADE_BOOK) && (k_ptr->tval != TV_ARCANE_BOOK) && (k_ptr->sval > 1))
343 /* Assume not good */
349 * Hack -- determine if a template is Armor
351 static bool kind_is_armor(int k_idx)
353 object_kind *k_ptr = &k_info[k_idx];
355 /* Analyze the item type */
356 if (k_ptr->tval == TV_HARD_ARMOR)
361 /* Assume not good */
367 * Check for "Quest" completion when a quest monster is killed or charmed.
369 void check_quest_completion(monster_type *m_ptr)
371 int i, j, y, x, ny, nx, i2, j2;
375 bool create_stairs = FALSE;
381 /* Get the location */
386 quest_num = p_ptr->inside_quest;
388 /* Search for an active quest on this dungeon level */
391 for (i = max_quests - 1; i > 0; i--)
393 /* Quest is not active */
394 if (quest[i].status != QUEST_STATUS_TAKEN)
397 /* Quest is not a dungeon quest */
398 if (quest[i].flags & QUEST_FLAG_PRESET)
401 /* Quest is not on this level */
402 if ((quest[i].level != dun_level) &&
403 (quest[i].type != QUEST_TYPE_KILL_ANY_LEVEL))
406 /* Not a "kill monster" quest */
407 if ((quest[i].type == QUEST_TYPE_FIND_ARTIFACT) ||
408 (quest[i].type == QUEST_TYPE_FIND_EXIT))
411 /* Interesting quest */
412 if ((quest[i].type == QUEST_TYPE_KILL_NUMBER) ||
413 (quest[i].type == QUEST_TYPE_KILL_ALL))
416 /* Interesting quest */
417 if (((quest[i].type == QUEST_TYPE_KILL_LEVEL) ||
418 (quest[i].type == QUEST_TYPE_KILL_ANY_LEVEL) ||
419 (quest[i].type == QUEST_TYPE_RANDOM)) &&
420 (quest[i].r_idx == m_ptr->r_idx))
427 /* Handle the current quest */
428 if (quest_num && (quest[quest_num].status == QUEST_STATUS_TAKEN))
433 switch (quest[i].type)
435 case QUEST_TYPE_KILL_NUMBER:
439 if (quest[i].cur_num >= quest[i].num_mon)
441 if (record_fix_quest) do_cmd_write_nikki(NIKKI_FIX_QUEST_C, i, NULL);
442 /* completed quest */
443 quest[i].status = QUEST_STATUS_COMPLETED;
444 quest[i].complev = (byte)p_ptr->lev;
446 if (!(quest[i].flags & QUEST_FLAG_SILENT))
449 msg_print("¥¯¥¨¥¹¥È¤òãÀ®¤·¤¿¡ª");
451 msg_print("You just completed your quest!");
457 quest[i].cur_num = 0;
461 case QUEST_TYPE_KILL_ALL:
465 if (!is_hostile(m_ptr)) break;
467 /* Count all hostile monsters */
468 for (i2 = 0; i2 < cur_wid; ++i2)
469 for (j2 = 0; j2 < cur_hgt; j2++)
470 if (cave[j2][i2].m_idx > 0)
471 if (is_hostile(&m_list[cave[j2][i2].m_idx]))
474 if ((number_mon - 1) == 0)
476 if (record_fix_quest) do_cmd_write_nikki(NIKKI_FIX_QUEST_C, i, NULL);
478 if (quest[i].flags & QUEST_FLAG_SILENT)
480 quest[i].status = QUEST_STATUS_FINISHED;
484 quest[i].status = QUEST_STATUS_COMPLETED;
485 quest[i].complev = (byte)p_ptr->lev;
487 msg_print("¥¯¥¨¥¹¥È¤òãÀ®¤·¤¿¡ª");
489 msg_print("You just completed your quest!");
497 case QUEST_TYPE_KILL_LEVEL:
498 case QUEST_TYPE_RANDOM:
500 /* Only count valid monsters */
501 if (quest[i].r_idx != m_ptr->r_idx)
506 if (quest[i].cur_num >= quest[i].max_num)
508 if (record_fix_quest && (quest[i].type == QUEST_TYPE_KILL_LEVEL)) do_cmd_write_nikki(NIKKI_FIX_QUEST_C, i, NULL);
509 if (record_rand_quest && (quest[i].type == QUEST_TYPE_RANDOM)) do_cmd_write_nikki(NIKKI_RAND_QUEST_C, i, NULL);
510 /* completed quest */
511 quest[i].status = QUEST_STATUS_COMPLETED;
512 quest[i].complev = (byte)p_ptr->lev;
513 if (!(quest[i].flags & QUEST_FLAG_PRESET))
515 create_stairs = TRUE;
516 p_ptr->inside_quest = 0;
519 if (!(quest[i].flags & QUEST_FLAG_SILENT))
522 msg_print("¥¯¥¨¥¹¥È¤òãÀ®¤·¤¿¡ª");
524 msg_print("You just completed your quest!");
530 /* Finish the two main quests without rewarding */
531 if ((i == QUEST_OBERON) || (i == QUEST_SERPENT))
533 quest[i].status = QUEST_STATUS_FINISHED;
536 if (quest[i].type == QUEST_TYPE_RANDOM)
539 quest[i].status = QUEST_STATUS_FINISHED;
544 case QUEST_TYPE_KILL_ANY_LEVEL:
547 if (quest[i].cur_num >= quest[i].max_num)
549 if (record_fix_quest) do_cmd_write_nikki(NIKKI_FIX_QUEST_C, i, NULL);
550 /* completed quest */
551 quest[i].status = QUEST_STATUS_COMPLETED;
552 quest[i].complev = (byte)p_ptr->lev;
554 if (!(quest[i].flags & QUEST_FLAG_SILENT))
557 msg_print("¥¯¥¨¥¹¥È¤òãÀ®¤·¤¿¡ª");
559 msg_print("You just completed your quest!");
564 quest[i].cur_num = 0;
571 /* Create a magical staircase */
575 while (cave_perma_bold(y, x) || cave[y][x].o_idx || (cave[y][x].info & CAVE_OBJECT) )
577 /* Pick a location */
578 scatter(&ny, &nx, y, x, 1, 0);
584 /* Explain the staircase */
586 msg_print("ËâË¡¤Î³¬Ãʤ¬¸½¤ì¤¿...");
588 msg_print("A magical staircase appears...");
592 /* Create stairs down */
593 cave_set_feat(y, x, FEAT_MORE);
595 /* Remember to update everything */
596 p_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MONSTERS);
604 for (j = 0; j < (dun_level / 15)+1; j++)
606 /* Get local object */
609 /* Wipe the object */
612 /* Make a great object */
613 make_object(q_ptr, TRUE, TRUE);
615 /* Drop it in the dungeon */
616 (void)drop_near(q_ptr, -1, y, x);
622 * Handle the "death" of a monster.
624 * Disperse treasures centered at the monster location based on the
625 * various flags contained in the monster flags fields.
627 * Check for "Quest" completion when a quest monster is killed.
629 * Note that only the player can induce "monster_death()" on Uniques.
630 * Thus (for now) all Quest monsters should be Uniques.
632 * Note that monsters can now carry objects, and when a monster dies,
633 * it drops all of its objects, which may disappear in crowded rooms.
635 void monster_death(int m_idx, bool drop_item)
644 monster_type *m_ptr = &m_list[m_idx];
646 monster_race *r_ptr = &r_info[m_ptr->r_idx];
648 bool visible = (m_ptr->ml || (r_ptr->flags1 & RF1_UNIQUE));
650 bool good = (r_ptr->flags1 & RF1_DROP_GOOD) ? TRUE : FALSE;
651 bool great = (r_ptr->flags1 & RF1_DROP_GREAT) ? TRUE : FALSE;
653 bool do_gold = (!(r_ptr->flags1 & RF1_ONLY_ITEM));
654 bool do_item = (!(r_ptr->flags1 & RF1_ONLY_GOLD));
656 int force_coin = get_coin_type(m_ptr->r_idx);
662 if (world_monster) world_monster = FALSE;
664 /* Notice changes in view */
665 if (r_ptr->flags7 & (RF7_HAS_LITE_1 | RF7_HAS_LITE_2 | RF7_SELF_LITE_1 | RF7_SELF_LITE_2))
667 /* Update some things */
668 p_ptr->update |= (PU_MON_LITE);
671 /* Get the location */
675 if (m_ptr->smart & SM_CLONED)
678 if (record_named_pet && is_pet(m_ptr) && m_ptr->nickname)
682 monster_desc(m_name, m_ptr, 0x08);
683 do_cmd_write_nikki(NIKKI_NAMED_PET, 3, m_name);
686 /* Let monsters explode! */
687 for (i = 0; i < 4; i++)
689 if ((r_ptr->blow[i].method == RBM_EXPLODE) || (m_ptr->r_idx == MON_ROLENTO))
691 int flg = PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL;
692 int typ = GF_MISSILE;
693 int d_dice = r_ptr->blow[i].d_dice;
694 int d_side = r_ptr->blow[i].d_side;
695 int damage = damroll(d_dice, d_side);
697 if (m_ptr->r_idx == MON_ROLENTO)
700 damage = damroll(20, 10);
702 else typ = mbe_info[r_ptr->blow[i].effect].explode_type;
704 project(m_idx, 3, y, x, damage, typ, flg, -1);
709 if (m_ptr->mflag2 & MFLAG_CHAMELEON)
711 choose_new_monster(m_idx, TRUE, MON_CHAMELEON);
712 r_ptr = &r_info[m_ptr->r_idx];
715 /* Check for quest completion */
716 check_quest_completion(m_ptr);
718 /* Handle the possibility of player vanquishing arena combatant -KMW- */
719 if (p_ptr->inside_arena && !is_pet(m_ptr))
723 /* Extract monster name */
724 monster_desc(m_name, m_ptr, 0);
726 p_ptr->exit_bldg = TRUE;
728 if (p_ptr->arena_number > MAX_ARENA_MONS)
731 msg_print("ÁÇÀ²¤é¤·¤¤¡ª·¯¤³¤½¿¿¤Î¾¡Íø¼Ô¤À¡£");
733 msg_print("You are a Genuine Champion!");
739 msg_print("¾¡Íø¡ª¥Á¥ã¥ó¥Ô¥ª¥ó¤Ø¤ÎÆ»¤ò¿Ê¤ó¤Ç¤¤¤ë¡£");
741 msg_print("Victorious! You're on your way to becoming Champion.");
745 if (arena_info[p_ptr->arena_number].tval)
747 /* Get local object */
750 /* Prepare to make a prize */
751 object_prep(q_ptr, lookup_kind(arena_info[p_ptr->arena_number].tval, arena_info[p_ptr->arena_number].sval));
753 apply_magic(q_ptr, object_level, FALSE, FALSE, FALSE, FALSE);
755 /* Drop it in the dungeon */
756 (void)drop_near(q_ptr, -1, y, x);
759 if (p_ptr->arena_number > MAX_ARENA_MONS) p_ptr->arena_number++;
760 p_ptr->arena_number++;
761 if (record_arena) do_cmd_write_nikki(NIKKI_ARENA, p_ptr->arena_number, m_name);
764 if (m_idx == p_ptr->riding)
766 if (rakuba(-1, FALSE))
769 msg_print("ÃÏÌ̤ËÍî¤È¤µ¤ì¤¿¡£");
771 msg_print("You have fallen from your riding pet.");
776 /* Drop a dead corpse? */
777 if (one_in_(r_ptr->flags1 & RF1_UNIQUE ? 1 : 4) &&
778 ((r_ptr->flags9 & RF9_DROP_CORPSE) ||
779 (r_ptr->flags9 & RF9_DROP_SKELETON)) &&
780 !(p_ptr->inside_arena || p_ptr->inside_battle || (m_ptr->smart & SM_CLONED) || ((m_ptr->r_idx == today_mon) && is_pet(m_ptr))))
782 /* Assume skeleton */
786 * We cannot drop a skeleton? Note, if we are in this check,
787 * we *know* we can drop at least a corpse or a skeleton
789 if (!(r_ptr->flags9 & RF9_DROP_SKELETON))
791 else if ((r_ptr->flags9 & RF9_DROP_CORPSE) && (r_ptr->flags1 && RF1_UNIQUE))
794 /* Else, a corpse is more likely unless we did a "lot" of damage */
795 else if (r_ptr->flags9 & RF9_DROP_CORPSE)
797 /* Lots of damage in one blow */
798 if ((0 - ((m_ptr->maxhp) / 4)) > m_ptr->hp)
800 if (one_in_(5)) corpse = TRUE;
804 if (!one_in_(5)) corpse = TRUE;
808 /* Get local object */
811 /* Prepare to make an object */
812 object_prep(q_ptr, lookup_kind(TV_CORPSE, (corpse ? SV_CORPSE : SV_SKELETON)));
814 apply_magic(q_ptr, object_level, FALSE, FALSE, FALSE, FALSE);
816 q_ptr->pval = m_ptr->r_idx;
818 /* Drop it in the dungeon */
819 (void)drop_near(q_ptr, -1, y, x);
822 /* Drop objects being carried */
823 monster_drop_carried_objects(m_ptr);
826 * Mega^3-hack: killing a 'Warrior of the Dawn' is likely to
827 * spawn another in the fallen one's place!
829 if (m_ptr->r_idx == MON_DAWN &&
830 !(p_ptr->inside_arena || p_ptr->inside_battle))
834 int wy = py, wx = px;
836 bool pet = is_pet(m_ptr);
840 scatter(&wy, &wx, py, px, 20, 0);
842 while (!(in_bounds(wy, wx) && cave_floor_bold(wy, wx)) && --attempts);
847 if (pet) mode |= PM_FORCE_PET;
849 if (summon_specific((pet ? -1 : m_idx), wy, wx, 100, SUMMON_DAWN, mode))
851 if (player_can_see_bold(wy, wx))
853 msg_print("¿·¤¿¤ÊÀï»Î¤¬¸½¤ì¤¿¡ª");
855 msg_print("A new warrior steps forth!");
863 /* Pink horrors are replaced with 2 Blue horrors */
864 else if (m_ptr->r_idx == MON_PINK_HORROR &&
865 !(p_ptr->inside_arena || p_ptr->inside_battle))
869 for (i = 0; i < 2; i++)
872 bool pet = is_pet(m_ptr);
875 if (pet) mode |= PM_FORCE_PET;
877 if (summon_specific((pet ? -1 : m_idx), wy, wx, 100, SUMMON_BLUE_HORROR, mode))
879 if (player_can_see_bold(wy, wx))
886 msg_print("¥Ô¥ó¥¯¡¦¥Û¥é¡¼¤ÏʬÎö¤·¤¿¡ª");
888 msg_print("The Pink horror divides!");
892 /* One more ultra-hack: An Unmaker goes out with a big bang! */
893 else if (m_ptr->r_idx == MON_UNMAKER)
896 int flg = PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL;
897 (void)project(m_idx, 6, y, x, 100, GF_CHAOS, flg, -1);
900 /* Bloodletters of Khorne may drop a blade of chaos */
901 else if (m_ptr->r_idx == MON_BLOODLETTER &&
903 (randint1(100) < 15) &&
904 !(p_ptr->inside_arena || p_ptr->inside_battle))
906 /* Get local object */
909 /* Prepare to make a Blade of Chaos */
910 object_prep(q_ptr, lookup_kind(TV_SWORD, SV_BLADE_OF_CHAOS));
912 apply_magic(q_ptr, object_level, FALSE, FALSE, FALSE, FALSE);
914 /* Drop it in the dungeon */
915 (void)drop_near(q_ptr, -1, y, x);
918 else if (m_ptr->r_idx == MON_RAAL &&
920 !(p_ptr->inside_arena || p_ptr->inside_battle))
922 /* Get local object */
925 /* Wipe the object */
928 /* Activate restriction */
929 if ((dun_level > 49) && one_in_(5))
930 get_obj_num_hook = kind_is_good_book;
932 get_obj_num_hook = kind_is_book;
934 /* Prepare allocation table */
938 make_object(q_ptr, FALSE, FALSE);
940 /* Drop it in the dungeon */
941 (void)drop_near(q_ptr, -1, y, x);
944 else if (m_ptr->r_idx == MON_B_DEATH_SWORD &&
945 !(p_ptr->inside_arena || p_ptr->inside_battle))
947 /* Get local object */
950 /* Prepare to make a broken sword */
951 object_prep(q_ptr, lookup_kind(TV_SWORD, randint1(2)));
953 /* Drop it in the dungeon */
954 (void)drop_near(q_ptr, -1, y, x);
957 else if ((r_ptr->d_char == '|') && !(m_ptr->r_idx == MON_STORMBRINGER) &&
958 !(p_ptr->inside_arena || p_ptr->inside_battle))
960 /* Get local object */
963 /* Wipe the object */
966 /* Activate restriction */
967 get_obj_num_hook = kind_is_sword;
969 /* Prepare allocation table */
973 make_object(q_ptr, FALSE, FALSE);
975 /* Drop it in the dungeon */
976 (void)drop_near(q_ptr, -1, y, x);
979 else if ((r_ptr->d_char == '(') && (dun_level > 0) &&
980 !(p_ptr->inside_arena || p_ptr->inside_battle))
982 /* Get local object */
985 /* Wipe the object */
988 /* Activate restriction */
989 get_obj_num_hook = kind_is_cloak;
991 /* Prepare allocation table */
995 make_object(q_ptr, FALSE, FALSE);
997 /* Drop it in the dungeon */
998 (void)drop_near(q_ptr, -1, y, x);
1001 else if ((r_ptr->d_char == '/') && (dun_level > 4) &&
1002 !(p_ptr->inside_arena || p_ptr->inside_battle))
1004 /* Get local object */
1007 /* Wipe the object */
1010 /* Activate restriction */
1011 get_obj_num_hook = kind_is_polearm;
1013 /* Prepare allocation table */
1016 /* Make a poleweapon */
1017 make_object(q_ptr, FALSE, FALSE);
1019 /* Drop it in the dungeon */
1020 (void)drop_near(q_ptr, -1, y, x);
1023 else if ((r_ptr->d_char == '[') && (dun_level > 19) &&
1024 !(p_ptr->inside_arena || p_ptr->inside_battle))
1026 /* Get local object */
1029 /* Wipe the object */
1032 /* Activate restriction */
1033 get_obj_num_hook = kind_is_armor;
1035 /* Prepare allocation table */
1038 /* Make a hard armor */
1039 make_object(q_ptr, FALSE, FALSE);
1041 /* Drop it in the dungeon */
1042 (void)drop_near(q_ptr, -1, y, x);
1045 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))
1047 /* Get local object */
1050 /* Prepare to make a Can of Toys */
1051 object_prep(q_ptr, lookup_kind(TV_CHEST, SV_CHEST_KANDUME));
1053 apply_magic(q_ptr, object_level, FALSE, FALSE, FALSE, FALSE);
1055 /* Drop it in the dungeon */
1056 (void)drop_near(q_ptr, -1, y, x);
1058 /* Mega-Hack -- drop "winner" treasures */
1061 if (m_ptr->r_idx == MON_SERPENT)
1063 /* Get local object */
1066 /* Mega-Hack -- Prepare to make "Grond" */
1067 object_prep(q_ptr, lookup_kind(TV_HAFTED, SV_GROND));
1069 /* Mega-Hack -- Mark this item as "Grond" */
1070 q_ptr->name1 = ART_GROND;
1072 /* Mega-Hack -- Actually create "Grond" */
1073 apply_magic(q_ptr, -1, TRUE, TRUE, TRUE, FALSE);
1075 /* Drop it in the dungeon */
1076 (void)drop_near(q_ptr, -1, y, x);
1078 /* Get local object */
1081 /* Mega-Hack -- Prepare to make "Chaos" */
1082 object_prep(q_ptr, lookup_kind(TV_CROWN, SV_CHAOS));
1084 /* Mega-Hack -- Mark this item as "Chaos" */
1085 q_ptr->name1 = ART_CHAOS;
1087 /* Mega-Hack -- Actually create "Chaos" */
1088 apply_magic(q_ptr, -1, TRUE, TRUE, TRUE, FALSE);
1090 /* Drop it in the dungeon */
1091 (void)drop_near(q_ptr, -1, y, x);
1098 switch (m_ptr->r_idx)
1113 case MON_UNICORN_ORD:
1116 if (p_ptr->pseikaku == SEIKAKU_NAMAKE)
1120 switch (randint0(3))
1123 a_idx = ART_NAMAKE_HAMMER;
1126 a_idx = ART_NAMAKE_BOW;
1129 a_idx = ART_NAMAKE_ARMOR;
1133 while (a_info[a_idx].cur_num);
1144 case MON_STORMBRINGER:
1145 a_idx = ART_STORMBRINGER;
1150 a_idx = ART_CRIMSON;
1160 a_idx = ART_KUSANAGI;
1190 a_idx = ART_WEREWINDLE;
1198 a_idx = ART_GRAYSWANDIR;
1209 a_idx = ART_TWILIGHT;
1214 a_idx = ART_ELENDIL;
1229 a_idx = ART_DESTINY;
1234 a_idx = ART_ZANTETSU;
1249 a_idx = ART_WINBLOWS;
1253 case MON_LUNGORTHIN:
1258 case MON_JACK_SHADOWS:
1264 a_idx = ART_STONEMASK;
1269 a_idx = ART_SOULCRUSH;
1274 a_idx = ART_EXCALIBUR_J;
1279 a_idx = ART_SHUTEN_DOJI;
1284 a_idx = ART_GOTHMOG;
1294 if ((a_idx > 0) && ((randint0(100) < chance) || (p_ptr->wizard)))
1296 if (a_info[a_idx].cur_num == 0)
1298 /* Create the artifact */
1299 create_named_art(a_idx, y, x);
1301 a_info[a_idx].cur_num = 1;
1306 if ((r_ptr->flags7 & RF7_GUARDIAN) && !p_ptr->inside_battle && (d_info[dungeon_type].final_guardian == m_ptr->r_idx))
1308 int k_idx = lookup_kind(TV_SCROLL, SV_SCROLL_ACQUIREMENT); /* Acquirement */;
1310 if (d_info[dungeon_type].final_object)
1311 k_idx = d_info[dungeon_type].final_object;
1313 if (d_info[dungeon_type].final_artifact)
1315 int a_idx = d_info[dungeon_type].final_artifact;
1316 if (a_info[a_idx].cur_num == 0)
1318 /* Create the artifact */
1319 create_named_art(a_idx, y, x);
1321 a_info[a_idx].cur_num = 1;
1328 /* Get local object */
1331 /* Prepare to make a reward */
1332 object_prep(q_ptr, k_idx);
1334 apply_magic(q_ptr, object_level, FALSE, TRUE, FALSE, FALSE);
1336 /* Drop it in the dungeon */
1337 (void)drop_near(q_ptr, -1, y, x);
1340 msg_format("¤¢¤Ê¤¿¤Ï%s¤òÀ©ÇƤ·¤¿¡ª",d_name+d_info[dungeon_type].name);
1342 msg_format("You have conquered %s!",d_name+d_info[dungeon_type].name);
1346 /* Determine how much we can drop */
1347 if ((r_ptr->flags1 & RF1_DROP_60) && (randint0(100) < 60)) number++;
1348 if ((r_ptr->flags1 & RF1_DROP_90) && (randint0(100) < 90)) number++;
1349 if (r_ptr->flags1 & RF1_DROP_1D2) number += damroll(1, 2);
1350 if (r_ptr->flags1 & RF1_DROP_2D2) number += damroll(2, 2);
1351 if (r_ptr->flags1 & RF1_DROP_3D2) number += damroll(3, 2);
1352 if (r_ptr->flags1 & RF1_DROP_4D2) number += damroll(4, 2);
1354 if (cloned && !(r_ptr->flags1 & RF1_UNIQUE))
1355 number = 0; /* Clones drop no stuff unless Cloning Pits */
1357 if (is_pet(m_ptr) || p_ptr->inside_battle || p_ptr->inside_arena)
1358 number = 0; /* Pets drop no stuff */
1359 if (!drop_item && (r_ptr->d_char != '$')) number = 0;
1361 /* Hack -- handle creeping coins */
1362 coin_type = force_coin;
1364 /* Average dungeon and monster levels */
1365 object_level = (dun_level + r_ptr->level) / 2;
1367 /* Drop some objects */
1368 for (j = 0; j < number; j++)
1370 /* Get local object */
1373 /* Wipe the object */
1377 if (do_gold && (!do_item || (randint0(100) < 50)))
1379 /* Make some gold */
1380 if (!make_gold(q_ptr)) continue;
1389 /* Make an object */
1390 if (!make_object(q_ptr, good, great)) continue;
1396 /* Drop it in the dungeon */
1397 (void)drop_near(q_ptr, -1, y, x);
1400 /* Reset the object level */
1401 object_level = base_level;
1403 /* Reset "coin" type */
1407 /* Take note of any dropped treasure */
1408 if (visible && (dump_item || dump_gold))
1410 /* Take notes on treasure */
1411 lore_treasure(m_idx, dump_item, dump_gold);
1414 /* Only process "Quest Monsters" */
1415 if (!(r_ptr->flags1 & RF1_QUESTOR)) return;
1416 if (p_ptr->inside_battle) return;
1419 if (m_ptr->r_idx == MON_SERPENT)
1422 p_ptr->total_winner = TRUE;
1424 /* Redraw the "title" */
1425 p_ptr->redraw |= (PR_TITLE);
1428 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, "¸«»ö¤ËÊѶòÈÚÅܤξ¡Íø¼Ô¤È¤Ê¤Ã¤¿¡ª");
1430 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, "become *WINNER* of Hengband finely!");
1433 if (p_ptr->pclass == CLASS_CHAOS_WARRIOR)
1436 msg_format("%s¤«¤é¤ÎÀ¼¤¬¶Á¤¤¤¿¡£", chaos_patrons[p_ptr->chaos_patron]);
1437 msg_print("¡Ø¤è¤¯¤ä¤Ã¤¿¡¢ÄêÌ¿¤Î¼Ô¤è¡ª¡Ù");
1439 msg_format("The voice of %s booms out:", chaos_patrons[p_ptr->chaos_patron]);
1440 msg_print("'Thou art donst well, mortal!'");
1444 /* Congratulations */
1446 msg_print("*** ¤ª¤á¤Ç¤È¤¦ ***");
1448 msg_print("*** CONGRATULATIONS ***");
1452 msg_print("¤¢¤Ê¤¿¤Ï¥²¡¼¥à¤ò¥³¥ó¥×¥ê¡¼¥È¤·¤Þ¤·¤¿¡£");
1454 msg_print("You have won the game!");
1458 msg_print("½àÈ÷¤¬À°¤Ã¤¿¤é°úÂà(¼«»¦¥³¥Þ¥ó¥É)¤·¤Æ¤â·ë¹½¤Ç¤¹¡£");
1460 msg_print("You may retire (commit suicide) when you are ready.");
1467 * Modify the physical damage done to the monster.
1468 * (for example when it's invulnerable or shielded)
1470 * ToDo: Accept a damage-type to calculate the modified damage from
1471 * things like fire, frost, lightning, poison, ... attacks.
1473 * "type" is not yet used and should be 0.
1475 int mon_damage_mod(monster_type *m_ptr, int dam, bool is_psy_spear)
1477 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1479 if ((r_ptr->flags3 & RF3_RES_ALL) && dam > 0)
1482 if((dam == 0) && one_in_(3)) dam = 1;
1485 if (m_ptr->invulner)
1489 if(!p_ptr->blind && m_ptr->ml)
1492 msg_print("¥Ð¥ê¥¢¤òÀÚ¤êÎö¤¤¤¿¡ª");
1494 msg_print("The barrier is penetrated!");
1498 else if (!one_in_(PENETRATE_INVULNERABILITY))
1506 static void get_exp_from_mon(int dam, monster_type *m_ptr)
1508 s32b div, new_exp, new_exp_frac;
1509 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1510 int monnum_penarty = 0;
1512 if (!m_ptr->r_idx) return;
1513 if (is_pet(m_ptr) || p_ptr->inside_battle) return;
1517 u32b m_exp_h, m_exp_l;
1519 if ((r_ptr->flags2 & RF2_MULTIPLY) || (m_ptr->r_idx == MON_DAWN))
1521 monnum_penarty = r_ptr->r_pkills / 400;
1522 if (monnum_penarty > 8) monnum_penarty = 8;
1524 if (r_ptr->flags1 & RF1_UNIQUE)
1526 m_exp = (long)r_ptr->mexp * r_ptr->level;
1527 div = (p_ptr->max_plv+2);
1531 m_exp = (long)r_ptr->mexp * r_ptr->level * extract_energy[m_ptr->mspeed];
1532 div = (p_ptr->max_plv+2) * extract_energy[r_ptr->speed];
1534 m_exp_h = m_exp/0x10000L;
1535 m_exp_l = m_exp%0x10000L;
1538 m_exp_h += m_exp_l / 0x10000L;
1539 m_exp_l %= 0x10000L;
1541 /* real monster maxhp have effect on EXP */
1542 if(!(r_ptr->flags1 & RF1_FORCE_MAXHP))
1544 u32b maxhp = m_ptr->max_maxhp*2;
1547 m_exp_h += m_exp_l / 0x10000L;
1548 m_exp_l %= 0x10000L;
1550 div *= r_ptr->hdice * (r_ptr->hside + 1);
1552 if (!dun_level && (!(r_ptr->flags8 & RF8_WILD_ONLY) || !(r_ptr->flags1 & RF1_UNIQUE))) div *= 5;
1553 div_h = div/0x10000L;
1554 div_l = div%0x10000L;
1555 div_h *= (m_ptr->max_maxhp*2);
1556 div_l *= (m_ptr->max_maxhp*2);
1557 div_h += div_l / 0x10000L;
1560 while (monnum_penarty)
1564 div_h += div_l / 0x10000L;
1569 m_exp_l = (0x7fffffff & (m_exp_h << 16)) | m_exp_l;
1570 m_exp_h = m_exp_h >> 15;
1571 div_l = (0x7fffffff & (div_h << 16)) | div_l;
1572 div_h = div_h >> 15;
1574 #define M_INT_GREATER63(h1,l1,h2,l2) ( (h1>h2)||( (h1==h2)&&(l1>=l2)))
1575 #define M_INT_SUB63(h1,l1, h2,l2) {h1-=h2;if(l1<l2){l1+=0x80000000;h1--;}l1-=l2;}
1576 #define M_INT_LSHIFT63(h1,l1) {h1=(h1<<1)|(l1>>30);l1=(l1<<1)&0x7fffffff;}
1577 #define M_INT_RSHIFT63(h1,l1) {l1=(l1>>1)|(h1<<30);h1>>=1;}
1578 #define M_INT_DIV63(h1,l1,h2,l2,result) \
1582 while( M_INT_GREATER63(h1,l1, h2, l2) ){M_INT_LSHIFT63(h2, l2); bit<<=1;} \
1583 for(bit>>=1; bit>=1; bit>>=1){ \
1584 M_INT_RSHIFT63(h2, l2); \
1585 if(M_INT_GREATER63(h1, l1, h2, l2)) \
1586 {result|=bit;M_INT_SUB63(h1, l1, h2, l2);} \
1590 /* Give some experience for the kill */
1591 M_INT_DIV63(m_exp_h, m_exp_l, div_h, div_l, new_exp);
1593 /* Handle fractional experience */
1594 /* multiply 0x10000L to remainder */
1595 m_exp_h = (m_exp_h<<16) | (m_exp_l>>15);
1597 M_INT_DIV63(m_exp_h, m_exp_l, div_h, div_l, new_exp_frac);
1598 new_exp_frac += p_ptr->exp_frac;
1599 /* Keep track of experience */
1600 if (new_exp_frac >= 0x10000L)
1603 p_ptr->exp_frac = (u16b)(new_exp_frac - 0x10000L);
1607 p_ptr->exp_frac = (u16b)new_exp_frac;
1610 /* Gain experience */
1618 * Decreases monsters hit points, handling monster death.
1620 * We return TRUE if the monster has been killed (and deleted).
1622 * We announce monster death (using an optional "death message"
1623 * if given, and a otherwise a generic killed/destroyed message).
1625 * Only "physical attacks" can induce the "You have slain" message.
1626 * Missile and Spell attacks will induce the "dies" message, or
1627 * various "specialized" messages. Note that "You have destroyed"
1628 * and "is destroyed" are synonyms for "You have slain" and "dies".
1630 * Hack -- unseen monsters yield "You have killed it." message.
1632 * Added fear (DGK) and check whether to print fear messages -CWS
1634 * Made name, sex, and capitalization generic -BEN-
1636 * As always, the "ghost" processing is a total hack.
1638 * Hack -- we "delay" fear messages by passing around a "fear" flag.
1640 * XXX XXX XXX Consider decreasing monster experience over time, say,
1641 * by using "(m_exp * m_lev * (m_lev)) / (p_lev * (m_lev + n_killed))"
1642 * instead of simply "(m_exp * m_lev) / (p_lev)", to make the first
1643 * monster worth more than subsequent monsters. This would also need
1644 * to induce changes in the monster recall code.
1646 bool mon_take_hit(int m_idx, int dam, bool *fear, cptr note)
1648 monster_type *m_ptr = &m_list[m_idx];
1649 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1651 monster_type exp_mon;
1653 /* Innocent until proven otherwise */
1654 bool innocent = TRUE, thief = FALSE;
1658 COPY(&exp_mon, m_ptr, monster_type);
1659 if (!(r_ptr->flags7 & RF7_KILL_EXP))
1661 expdam = (m_ptr->hp > dam) ? dam : m_ptr->hp;
1662 if (r_ptr->flags6 & RF6_HEAL) expdam = (expdam+1) * 2 / 3;
1664 get_exp_from_mon(expdam, &exp_mon);
1667 /* Redraw (later) if needed */
1668 if (p_ptr->health_who == m_idx) p_ptr->redraw |= (PR_HEALTH);
1669 if (p_ptr->riding == m_idx) p_ptr->redraw |= (PR_UHEALTH);
1674 /* Hack - Cancel any special player stealth magics. -LM- */
1675 if (p_ptr->special_defense & NINJA_S_STEALTH)
1677 set_superstealth(FALSE);
1683 /* It is dead now */
1688 if (r_info[m_ptr->r_idx].flags7 & RF7_TANUKI)
1690 /* You might have unmasked Tanuki first time */
1691 r_ptr = &r_info[m_ptr->r_idx];
1692 m_ptr->ap_r_idx = m_ptr->r_idx;
1693 if (r_ptr->r_sights < MAX_SHORT) r_ptr->r_sights++;
1696 if (m_ptr->mflag2 & MFLAG_CHAMELEON)
1698 /* You might have unmasked Chameleon first time */
1699 r_ptr = real_r_ptr(m_ptr);
1700 if (r_ptr->r_sights < MAX_SHORT) r_ptr->r_sights++;
1703 /* When the player kills a Unique, it stays dead */
1704 if (r_ptr->flags1 & RF1_UNIQUE && !(m_ptr->smart & SM_CLONED))
1707 /* When the player kills a Nazgul, it stays dead */
1708 if (r_ptr->flags7 & RF7_UNIQUE_7) r_ptr->max_num--;
1710 /* Recall even invisible uniques or winners */
1711 if (m_ptr->ml || (r_ptr->flags1 & RF1_UNIQUE))
1713 /* Count kills this life */
1714 if ((m_ptr->mflag2 & MFLAG_KAGE) && (r_info[MON_KAGE].r_pkills < MAX_SHORT)) r_info[MON_KAGE].r_pkills++;
1715 else if (r_ptr->r_pkills < MAX_SHORT) r_ptr->r_pkills++;
1717 /* Count kills in all lives */
1718 if ((m_ptr->mflag2 & MFLAG_KAGE) && (r_info[MON_KAGE].r_tkills < MAX_SHORT)) r_info[MON_KAGE].r_tkills++;
1719 else if (r_ptr->r_tkills < MAX_SHORT) r_ptr->r_tkills++;
1721 /* Hack -- Auto-recall */
1722 monster_race_track(m_ptr->ap_r_idx);
1725 /* Extract monster name */
1726 monster_desc(m_name, m_ptr, 0x100);
1728 /* Don't kill Amberites */
1729 if ((r_ptr->flags3 & RF3_AMBERITE) && one_in_(2))
1731 int curses = 1 + randint1(3);
1732 bool stop_ty = FALSE;
1736 msg_format("%^s¤Ï¶²¤í¤·¤¤·ì¤Î¼ö¤¤¤ò¤¢¤Ê¤¿¤Ë¤«¤±¤¿¡ª", m_name);
1738 msg_format("%^s puts a terrible blood curse on you!", m_name);
1741 curse_equipment(100, 50);
1745 stop_ty = activate_ty_curse(stop_ty, &count);
1750 if (r_ptr->flags2 & RF2_CAN_SPEAK)
1752 char line_got[1024];
1754 /* Dump a message */
1756 if (!get_rnd_line("mondeath_j.txt", m_ptr->r_idx, line_got))
1758 if (!get_rnd_line("mondeath.txt", m_ptr->r_idx, line_got))
1761 msg_format("%^s %s", m_name, line_got);
1764 if (m_ptr->r_idx == MON_SERPENT)
1766 /* Make screen dump */
1767 screen_dump = make_screen_dump();
1772 if (!(d_info[dungeon_type].flags1 & DF1_BEGINNER))
1774 if (!dun_level && !ambush_flag && !p_ptr->inside_arena)
1776 chg_virtue(V_VALOUR, -1);
1778 else if (r_ptr->level > dun_level)
1780 if (randint1(10) <= (r_ptr->level - dun_level))
1781 chg_virtue(V_VALOUR, 1);
1783 if (r_ptr->level > 60)
1785 chg_virtue(V_VALOUR, 1);
1787 if (r_ptr->level >= 2 * (p_ptr->lev+1))
1788 chg_virtue(V_VALOUR, 2);
1791 if ((r_ptr->flags1 & RF1_UNIQUE) && ((r_ptr->flags3 & RF3_EVIL) ||
1792 (r_ptr->flags3 & RF3_GOOD)))
1794 chg_virtue(V_HARMONY, 2);
1796 if ((r_ptr->flags1 & RF1_UNIQUE) && (r_ptr->flags3 & RF3_GOOD))
1798 chg_virtue(V_UNLIFE, 2);
1799 chg_virtue(V_VITALITY, -2);
1802 if ((r_ptr->flags1 & RF1_UNIQUE) && one_in_(3))
1803 chg_virtue(V_INDIVIDUALISM, -1);
1805 if (m_ptr->r_idx == MON_BEGGAR || m_ptr->r_idx == MON_LEPER)
1807 chg_virtue(V_COMPASSION, -1);
1810 if ((r_ptr->flags3 & RF3_GOOD) &&
1811 ((r_ptr->level) / 10 + (3 * dun_level) >= randint1(100)))
1813 chg_virtue(V_UNLIFE, 1);
1815 if (r_ptr->d_char == 'A')
1817 if (r_ptr->flags1 & RF1_UNIQUE)
1818 chg_virtue(V_FAITH, -2);
1819 else if ((r_ptr->level) / 10 + (3 * dun_level) >= randint1(100))
1821 if (r_ptr->flags3 & RF3_GOOD) chg_virtue(V_FAITH, -1);
1822 else chg_virtue(V_FAITH, 1);
1825 else if (r_ptr->flags3 & RF3_DEMON)
1827 if (r_ptr->flags1 & RF1_UNIQUE)
1828 chg_virtue(V_FAITH, 2);
1829 else if ((r_ptr->level) / 10 + (3 * dun_level) >= randint1(100))
1830 chg_virtue(V_FAITH, 1);
1833 if ((r_ptr->flags3 & RF3_UNDEAD) && (r_ptr->flags1 & RF1_UNIQUE))
1834 chg_virtue(V_VITALITY, 2);
1836 if (r_ptr->r_deaths)
1838 if (r_ptr->flags1 & RF1_UNIQUE)
1840 chg_virtue(V_HONOUR, 10);
1842 else if ((r_ptr->level) / 10 + (2 * dun_level) >= randint1(100))
1844 chg_virtue(V_HONOUR, 1);
1847 if ((r_ptr->flags2 & RF2_MULTIPLY) && (r_ptr->r_pkills > 1000) && one_in_(10))
1849 chg_virtue(V_VALOUR, -1);
1852 for (i = 0; i < 4; i++)
1854 if(r_ptr->blow[i].d_dice != 0) innocent = FALSE; /* Murderer! */
1856 if ((r_ptr->blow[i].effect == RBE_EAT_ITEM)
1857 || (r_ptr->blow[i].effect == RBE_EAT_GOLD))
1859 thief = TRUE; /* Thief! */
1862 /* The new law says it is illegal to live in the dungeon */
1863 if (r_ptr->level != 0) innocent = FALSE;
1867 if (r_ptr->flags1 & RF1_UNIQUE)
1868 chg_virtue(V_JUSTICE, 3);
1869 else if (1+((r_ptr->level) / 10 + (2 * dun_level))
1872 chg_virtue(V_JUSTICE, 1);
1876 chg_virtue (V_JUSTICE, -1);
1879 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)))
1881 if (one_in_(4)) chg_virtue(V_NATURE, -1);
1884 if((r_ptr->flags1 & RF1_UNIQUE) && record_destroy_uniq)
1885 do_cmd_write_nikki(NIKKI_UNIQUE, 0, r_name + r_ptr->name);
1890 /* Death by Missile/Spell attack */
1893 msg_format("%^s%s", m_name, note);
1896 /* Death by physical attack -- invisible monster */
1897 else if (!m_ptr->ml)
1900 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
1901 msg_format("¤»¤Ã¤«¤¯¤À¤«¤é%s¤ò»¦¤·¤¿¡£", m_name);
1903 msg_format("%s¤ò»¦¤·¤¿¡£", m_name);
1905 msg_format("You have killed %s.", m_name);
1910 /* Death by Physical attack -- non-living monster */
1911 else if (!monster_living(r_ptr))
1914 bool explode = FALSE;
1916 for (i = 0; i < 4; i++)
1918 if (r_ptr->blow[i].method == RBM_EXPLODE) explode = TRUE;
1921 /* Special note at death */
1924 msg_format("%s¤ÏÇúȯ¤·¤ÆÊ´¡¹¤Ë¤Ê¤Ã¤¿¡£", m_name);
1926 msg_format("%s explodes into tiny shreds.", m_name);
1931 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
1932 msg_format("¤»¤Ã¤«¤¯¤À¤«¤é%s¤òÅݤ·¤¿¡£", m_name);
1934 msg_format("%s¤òÅݤ·¤¿¡£", m_name);
1936 msg_format("You have destroyed %s.", m_name);
1941 /* Death by Physical attack -- living monster */
1945 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
1946 msg_format("¤»¤Ã¤«¤¯¤À¤«¤é%s¤òÁò¤êµî¤Ã¤¿¡£", m_name);
1948 msg_format("%s¤òÁò¤êµî¤Ã¤¿¡£", m_name);
1950 msg_format("You have slain %s.", m_name);
1954 if (r_ptr->flags1 & RF1_UNIQUE && !(m_ptr->smart & SM_CLONED))
1956 for (i = 0; i < MAX_KUBI; i++)
1958 if ((kubi_r_idx[i] == m_ptr->r_idx) && !(m_ptr->mflag2 & MFLAG_CHAMELEON))
1961 msg_format("%s¤Î¼ó¤Ë¤Ï¾Þ¶â¤¬¤«¤«¤Ã¤Æ¤¤¤ë¡£", m_name);
1963 msg_format("There is a price on %s's head.", m_name);
1970 if (r_ptr->flags7 & RF7_KILL_EXP)
1971 get_exp_from_mon((long)m_ptr->max_maxhp*2, &exp_mon);
1973 get_exp_from_mon(((long)m_ptr->max_maxhp+1L) * 9L / 10L, &exp_mon);
1975 /* Generate treasure */
1976 monster_death(m_idx, TRUE);
1977 if ((m_ptr->r_idx == MON_BANOR) || (m_ptr->r_idx == MON_LUPART))
1979 r_info[MON_BANORLUPART].max_num = 0;
1980 r_info[MON_BANORLUPART].r_pkills++;
1981 if (r_info[MON_BANORLUPART].r_tkills < MAX_SHORT) r_info[MON_BANORLUPART].r_tkills++;
1984 if (m_ptr->r_idx == MON_BANORLUPART)
1986 r_info[MON_BANOR].max_num = 0;
1987 r_info[MON_BANOR].r_pkills++;
1988 if (r_info[MON_BANOR].r_tkills < MAX_SHORT) r_info[MON_BANOR].r_tkills++;
1989 r_info[MON_LUPART].max_num = 0;
1990 r_info[MON_LUPART].r_pkills++;
1991 if (r_info[MON_LUPART].r_tkills < MAX_SHORT) r_info[MON_LUPART].r_tkills++;
1994 /* Mega hack : replace IKETA to BIKETAL */
1995 if ((m_ptr->r_idx == MON_IKETA) &&
1996 !(p_ptr->inside_arena || p_ptr->inside_battle))
1998 int dummy_y = m_ptr->fy;
1999 int dummy_x = m_ptr->fx;
2002 if (is_pet(m_ptr)) mode |= PM_FORCE_PET;
2004 /* Delete the monster */
2005 delete_monster_idx(m_idx);
2007 if (summon_named_creature(0, dummy_y, dummy_x, MON_BIKETAL, mode))
2010 msg_print("¡Ö¥Ï¥¡¥Ã¥Ï¥Ã¥Ï¥Ã¥Ï¡ª¡ª»ä¤¬¥Ð¥¤¥±¥¿¥ë¤À¡ª¡ª¡×");
2012 msg_print("Uwa-hahaha! *I* am Biketal!");
2018 /* Delete the monster */
2019 delete_monster_idx(m_idx);
2025 /* Monster is dead */
2032 /* Mega-Hack -- Pain cancels fear */
2033 if (m_ptr->monfear && (dam > 0))
2035 int tmp = randint1(dam);
2037 /* Cure a little fear */
2038 if (tmp < m_ptr->monfear)
2041 m_ptr->monfear -= tmp;
2044 /* Cure all the fear */
2055 /* Sometimes a monster gets scared by damage */
2056 if (!m_ptr->monfear && !(r_ptr->flags3 & (RF3_NO_FEAR)))
2060 /* Percentage of fully healthy */
2061 percentage = (100L * m_ptr->hp) / m_ptr->maxhp;
2064 * Run (sometimes) if at 10% or less of max hit points,
2065 * or (usually) when hit for half its current hit points
2067 if ((randint1(10) >= percentage) ||
2068 ((dam >= m_ptr->hp) && (randint0(100) < 80)))
2070 /* Hack -- note fear */
2073 /* XXX XXX XXX Hack -- Add some timed fear */
2074 m_ptr->monfear = (randint1(10) +
2075 (((dam >= m_ptr->hp) && (percentage > 7)) ?
2076 20 : ((11 - percentage) * 5)));
2083 if (p_ptr->riding && (p_ptr->riding == m_idx) && (dam > 0))
2087 /* Extract monster name */
2088 monster_desc(m_name, m_ptr, 0);
2090 if (m_ptr->hp > m_ptr->maxhp/3) dam = (dam + 1) / 2;
2091 if (rakuba((dam > 200) ? 200 : dam, FALSE))
2094 msg_format("%^s¤Ë¿¶¤êÍî¤È¤µ¤ì¤¿¡ª", m_name);
2096 msg_format("%^s has thrown you off!", m_name);
2108 * Get term size and calculate screen size
2110 void get_screen_size(int *wid_p, int *hgt_p)
2112 Term_get_size(wid_p, hgt_p);
2113 *hgt_p -= ROW_MAP + 2;
2114 *wid_p -= COL_MAP + 2;
2115 if (use_bigtile) *wid_p /= 2;
2120 * Calculates current boundaries
2121 * Called below and from "do_cmd_locate()".
2123 void panel_bounds_center(void)
2128 get_screen_size(&wid, &hgt);
2130 panel_row_max = panel_row_min + hgt - 1;
2131 panel_row_prt = panel_row_min - 1;
2132 panel_col_max = panel_col_min + wid - 1;
2133 panel_col_prt = panel_col_min - 13;
2138 * Map resizing whenever the main term changes size
2140 void resize_map(void)
2142 /* Only if the dungeon exists */
2143 if (!character_dungeon) return;
2145 /* Mega-Hack -- no panel yet */
2149 /* Reset the panels */
2150 panel_row_min = cur_hgt;
2151 panel_col_min = cur_wid;
2156 p_ptr->update |= (PU_TORCH | PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
2158 /* Forget lite/view */
2159 p_ptr->update |= (PU_UN_VIEW | PU_UN_LITE);
2161 /* Update lite/view */
2162 p_ptr->update |= (PU_VIEW | PU_LITE | PU_MON_LITE);
2164 /* Update monsters */
2165 p_ptr->update |= (PU_MONSTERS);
2167 /* Redraw everything */
2168 p_ptr->redraw |= (PR_WIPE | PR_BASIC | PR_EXTRA | PR_MAP | PR_EQUIPPY);
2170 /* Hack -- update */
2178 * Place the cursor on the player
2180 if (can_save) move_cursor_relative(py, px);
2187 * Redraw a term when it is resized
2189 void redraw_window(void)
2191 /* Only if the dungeon exists */
2192 if (!character_dungeon) return;
2194 /* Hack - Activate term zero for the redraw */
2195 Term_activate(&term_screen[0]);
2197 /* Hack -- react to changes */
2198 Term_xtra(TERM_XTRA_REACT, 0);
2201 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_SPELL | PW_PLAYER);
2204 p_ptr->window |= (PW_MESSAGE | PW_OVERHEAD | PW_DUNGEON | PW_MONSTER | PW_OBJECT);
2206 /* Hack -- update */
2218 * Handle a request to change the current panel
2220 * Return TRUE if the panel was changed.
2222 * Also used in do_cmd_locate
2224 bool change_panel(int dy, int dx)
2230 get_screen_size(&wid, &hgt);
2232 /* Apply the motion */
2233 y = panel_row_min + dy * hgt / 2;
2234 x = panel_col_min + dx * wid / 2;
2236 /* Verify the row */
2237 if (y > cur_hgt - hgt) y = cur_hgt - hgt;
2240 /* Verify the col */
2241 if (x > cur_wid - wid) x = cur_wid - wid;
2244 /* Handle "changes" */
2245 if ((y != panel_row_min) || (x != panel_col_min))
2247 /* Save the new panel info */
2251 /* Recalculate the boundaries */
2252 panel_bounds_center();
2255 p_ptr->update |= (PU_MONSTERS);
2258 p_ptr->redraw |= (PR_MAP);
2273 * Given an row (y) and col (x), this routine detects when a move
2274 * off the screen has occurred and figures new borders. -RAK-
2276 * "Update" forces a "full update" to take place.
2278 * The map is reprinted if necessary, and "TRUE" is returned.
2280 void verify_panel(void)
2292 get_screen_size(&wid, &hgt);
2294 max_prow_min = cur_hgt - hgt;
2295 max_pcol_min = cur_wid - wid;
2297 /* Bounds checking */
2298 if (max_prow_min < 0) max_prow_min = 0;
2299 if (max_pcol_min < 0) max_pcol_min = 0;
2301 /* Center on player */
2302 if (center_player && (center_running || !running))
2304 /* Center vertically */
2305 prow_min = y - hgt / 2;
2306 if (prow_min < 0) prow_min = 0;
2307 else if (prow_min > max_prow_min) prow_min = max_prow_min;
2309 /* Center horizontally */
2310 pcol_min = x - wid / 2;
2311 if (pcol_min < 0) pcol_min = 0;
2312 else if (pcol_min > max_pcol_min) pcol_min = max_pcol_min;
2316 prow_min = panel_row_min;
2317 pcol_min = panel_col_min;
2319 /* Scroll screen when 2 grids from top/bottom edge */
2320 if (y > panel_row_max - 2)
2322 while (y > prow_min + hgt-1 - 2)
2324 prow_min += (hgt / 2);
2328 if (y < panel_row_min + 2)
2330 while (y < prow_min + 2)
2332 prow_min -= (hgt / 2);
2336 if (prow_min > max_prow_min) prow_min = max_prow_min;
2337 if (prow_min < 0) prow_min = 0;
2339 /* Scroll screen when 4 grids from left/right edge */
2340 if (x > panel_col_max - 4)
2342 while (x > pcol_min + wid-1 - 4)
2344 pcol_min += (wid / 2);
2348 if (x < panel_col_min + 4)
2350 while (x < pcol_min + 4)
2352 pcol_min -= (wid / 2);
2356 if (pcol_min > max_pcol_min) pcol_min = max_pcol_min;
2357 if (pcol_min < 0) pcol_min = 0;
2360 /* Check for "no change" */
2361 if ((prow_min == panel_row_min) && (pcol_min == panel_col_min)) return;
2363 /* Save the new panel info */
2364 panel_row_min = prow_min;
2365 panel_col_min = pcol_min;
2367 /* Hack -- optional disturb on "panel change" */
2368 if (disturb_panel && !center_player) disturb(0, 0);
2370 /* Recalculate the boundaries */
2371 panel_bounds_center();
2374 p_ptr->update |= (PU_MONSTERS);
2377 p_ptr->redraw |= (PR_MAP);
2380 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
2385 * Monster health description
2387 cptr look_mon_desc(int m_idx, u32b mode)
2389 monster_type *m_ptr = &m_list[m_idx];
2390 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
2397 /* Determine if the monster is "living" */
2398 living = monster_living(ap_r_ptr);
2400 /* Calculate a health "percentage" */
2401 perc = 100L * m_ptr->hp / m_ptr->maxhp;
2403 /* Healthy monsters */
2404 if (m_ptr->hp >= m_ptr->maxhp)
2408 desc = living ? "̵½ý" : "̵¥À¥á¡¼¥¸";
2410 desc = living ? "unhurt" : "undamaged";
2415 else if (perc >= 60)
2418 desc = living ? "·Ú½ý" : "¾®¥À¥á¡¼¥¸";
2420 desc = living ? "somewhat wounded" : "somewhat damaged";
2425 else if (perc >= 25)
2428 desc = living ? "Éé½ý" : "Ãæ¥À¥á¡¼¥¸";
2430 desc = living ? "wounded" : "damaged";
2435 else if (perc >= 10)
2438 desc = living ? "½Å½ý" : "Âç¥À¥á¡¼¥¸";
2440 desc = living ? "badly wounded" : "badly damaged";
2448 desc = living ? "Ⱦ»àȾÀ¸" : "Åݤ줫¤±";
2450 desc = living ? "almost dead" : "almost destroyed";
2455 /* Need attitude information? */
2458 /* Full information is not needed */
2461 else if (is_pet(m_ptr))
2464 attitude = ", ¥Ú¥Ã¥È";
2469 else if (is_friendly(m_ptr))
2472 attitude = ", ͧ¹¥Åª";
2474 attitude = ", friendly";
2487 /* Clone monster? */
2488 if (m_ptr->smart & SM_CLONED)
2497 /* Display monster's level --- idea borrowed from ToME */
2498 if (ap_r_ptr->r_tkills && !(m_ptr->mflag2 & MFLAG_KAGE))
2501 return format("¥ì¥Ù¥ë%d, %s%s%s", ap_r_ptr->level, desc, attitude, clone);
2503 return format("Level %d, %s%s%s", ap_r_ptr->level, desc, attitude, clone);
2509 return format("¥ì¥Ù¥ë???, %s%s%s", desc, attitude, clone);
2511 return format("Level ???, %s%s%s", desc, attitude, clone);
2519 * Angband sorting algorithm -- quick sort in place
2521 * Note that the details of the data we are sorting is hidden,
2522 * and we rely on the "ang_sort_comp()" and "ang_sort_swap()"
2523 * function hooks to interact with the data, which is given as
2524 * two pointers, and which may have any user-defined form.
2526 void ang_sort_aux(vptr u, vptr v, int p, int q)
2544 while (!(*ang_sort_comp)(u, v, b, z)) b--;
2547 while (!(*ang_sort_comp)(u, v, z, a)) a++;
2549 /* Done partition */
2553 (*ang_sort_swap)(u, v, a, b);
2559 /* Recurse left side */
2560 ang_sort_aux(u, v, p, b);
2562 /* Recurse right side */
2563 ang_sort_aux(u, v, b+1, q);
2568 * Angband sorting algorithm -- quick sort in place
2570 * Note that the details of the data we are sorting is hidden,
2571 * and we rely on the "ang_sort_comp()" and "ang_sort_swap()"
2572 * function hooks to interact with the data, which is given as
2573 * two pointers, and which may have any user-defined form.
2575 void ang_sort(vptr u, vptr v, int n)
2577 /* Sort the array */
2578 ang_sort_aux(u, v, 0, n-1);
2583 /*** Targeting Code ***/
2587 * Determine is a monster makes a reasonable target
2589 * The concept of "targeting" was stolen from "Morgul" (?)
2591 * The player can target any location, or any "target-able" monster.
2593 * Currently, a monster is "target_able" if it is visible, and if
2594 * the player can hit it with a projection, and the player is not
2595 * hallucinating. This allows use of "use closest target" macros.
2597 * Future versions may restrict the ability to target "trappers"
2598 * and "mimics", but the semantics is a little bit weird.
2600 bool target_able(int m_idx)
2602 monster_type *m_ptr = &m_list[m_idx];
2604 /* Monster must be alive */
2605 if (!m_ptr->r_idx) return (FALSE);
2607 /* Hack -- no targeting hallucinations */
2608 if (p_ptr->image) return (FALSE);
2610 /* Monster must be visible */
2611 if (!m_ptr->ml) return (FALSE);
2613 if (p_ptr->riding && (p_ptr->riding == m_idx)) return (TRUE);
2615 /* Monster must be projectable */
2616 if (!projectable(py, px, m_ptr->fy, m_ptr->fx)) return (FALSE);
2618 /* XXX XXX XXX Hack -- Never target trappers */
2619 /* if (CLEAR_ATTR && (CLEAR_CHAR)) return (FALSE); */
2629 * Update (if necessary) and verify (if possible) the target.
2631 * We return TRUE if the target is "okay" and FALSE otherwise.
2633 bool target_okay(void)
2635 /* Accept stationary targets */
2636 if (target_who < 0) return (TRUE);
2638 /* Check moving targets */
2641 /* Accept reasonable targets */
2642 if (target_able(target_who))
2644 monster_type *m_ptr = &m_list[target_who];
2646 /* Acquire monster location */
2647 target_row = m_ptr->fy;
2648 target_col = m_ptr->fx;
2655 /* Assume no target */
2662 * Sorting hook -- comp function -- by "distance to player"
2664 * We use "u" and "v" to point to arrays of "x" and "y" positions,
2665 * and sort the arrays by double-distance to the player.
2667 static bool ang_sort_comp_distance(vptr u, vptr v, int a, int b)
2669 byte *x = (byte*)(u);
2670 byte *y = (byte*)(v);
2674 /* Absolute distance components */
2675 kx = x[a]; kx -= px; kx = ABS(kx);
2676 ky = y[a]; ky -= py; ky = ABS(ky);
2678 /* Approximate Double Distance to the first point */
2679 da = ((kx > ky) ? (kx + kx + ky) : (ky + ky + kx));
2681 /* Absolute distance components */
2682 kx = x[b]; kx -= px; kx = ABS(kx);
2683 ky = y[b]; ky -= py; ky = ABS(ky);
2685 /* Approximate Double Distance to the first point */
2686 db = ((kx > ky) ? (kx + kx + ky) : (ky + ky + kx));
2688 /* Compare the distances */
2694 * Sorting hook -- swap function -- by "distance to player"
2696 * We use "u" and "v" to point to arrays of "x" and "y" positions,
2697 * and sort the arrays by distance to the player.
2699 static void ang_sort_swap_distance(vptr u, vptr v, int a, int b)
2701 byte *x = (byte*)(u);
2702 byte *y = (byte*)(v);
2720 * Hack -- help "select" a location (see below)
2722 static s16b target_pick(int y1, int x1, int dy, int dx)
2726 int x2, y2, x3, y3, x4, y4;
2728 int b_i = -1, b_v = 9999;
2731 /* Scan the locations */
2732 for (i = 0; i < temp_n; i++)
2738 /* Directed distance */
2742 /* Verify quadrant */
2743 if (dx && (x3 * dx <= 0)) continue;
2744 if (dy && (y3 * dy <= 0)) continue;
2746 /* Absolute distance */
2750 /* Verify quadrant */
2751 if (dy && !dx && (x4 > y4)) continue;
2752 if (dx && !dy && (y4 > x4)) continue;
2754 /* Approximate Double Distance */
2755 v = ((x4 > y4) ? (x4 + x4 + y4) : (y4 + y4 + x4));
2757 /* XXX XXX XXX Penalize location */
2760 if ((b_i >= 0) && (v >= b_v)) continue;
2772 * Hack -- determine if a given location is "interesting"
2774 static bool target_set_accept(int y, int x)
2778 s16b this_o_idx, next_o_idx = 0;
2781 if (!(in_bounds(y, x))) return (FALSE);
2783 /* Player grid is always interesting */
2784 if ((y == py) && (x == px)) return (TRUE);
2787 /* Handle hallucination */
2788 if (p_ptr->image) return (FALSE);
2791 /* Examine the grid */
2792 c_ptr = &cave[y][x];
2794 /* Visible monsters */
2797 monster_type *m_ptr = &m_list[c_ptr->m_idx];
2799 /* Visible monsters */
2800 if (m_ptr->ml) return (TRUE);
2803 /* Scan all objects in the grid */
2804 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
2808 /* Acquire object */
2809 o_ptr = &o_list[this_o_idx];
2811 /* Acquire next object */
2812 next_o_idx = o_ptr->next_o_idx;
2814 /* Memorized object */
2815 if (o_ptr->marked) return (TRUE);
2818 /* Interesting memorized features */
2819 if (c_ptr->info & (CAVE_MARK))
2823 /* Feature code (applying "mimic" field) */
2824 feat = c_ptr->mimic ? c_ptr->mimic : f_info[c_ptr->feat].mimic;
2827 if (c_ptr->info & CAVE_OBJECT) return (TRUE);
2829 /* Notice the Pattern */
2830 if ((feat <= FEAT_PATTERN_XTRA2) &&
2831 (feat >= FEAT_PATTERN_START))
2835 if (feat == FEAT_OPEN) return (TRUE);
2836 if (feat == FEAT_BROKEN) return (TRUE);
2839 if (feat == FEAT_LESS) return (TRUE);
2840 if (feat == FEAT_MORE) return (TRUE);
2841 if (feat == FEAT_LESS_LESS) return (TRUE);
2842 if (feat == FEAT_MORE_MORE) return (TRUE);
2845 if ((feat >= FEAT_SHOP_HEAD) &&
2846 (feat <= FEAT_SHOP_TAIL)) return (TRUE);
2848 if (feat == FEAT_MUSEUM) return (TRUE);
2850 /* Notice buildings -KMW- */
2851 if ((feat >= FEAT_BLDG_HEAD) &&
2852 (feat <= FEAT_BLDG_TAIL)) return (TRUE);
2855 if (is_trap(feat)) return (TRUE);
2858 if ((feat >= FEAT_DOOR_HEAD) &&
2859 (feat <= FEAT_DOOR_TAIL)) return (TRUE);
2863 /* I think FEAT_RUBBLEs should not be "interesting" */
2864 if (feat == FEAT_RUBBLE) return (TRUE);
2866 /* Notice veins with treasure */
2867 /* Now veins with treasure are too many */
2868 if (feat == FEAT_MAGMA_K) return (TRUE);
2869 if (feat == FEAT_QUARTZ_K) return (TRUE);
2872 /* Notice quest features */
2873 if (feat == FEAT_QUEST_ENTER) return (TRUE);
2874 if (feat == FEAT_QUEST_EXIT) return (TRUE);
2875 if (feat == FEAT_QUEST_DOWN) return (TRUE);
2876 if (feat == FEAT_QUEST_UP) return (TRUE);
2877 if (feat == FEAT_TOWN) return (TRUE);
2878 if (feat == FEAT_ENTRANCE) return (TRUE);
2887 * Prepare the "temp" array for "target_set"
2889 * Return the number of target_able monsters in the set.
2891 static void target_set_prepare(int mode)
2895 /* Reset "temp" array */
2898 /* Scan the current panel */
2899 for (y = panel_row_min; y <= panel_row_max; y++)
2901 for (x = panel_col_min; x <= panel_col_max; x++)
2905 /* Require line of sight, unless "look" is "expanded" */
2906 if (!expand_look && !player_has_los_bold(y, x)) continue;
2908 /* Require "interesting" contents */
2909 if (!target_set_accept(y, x)) continue;
2911 c_ptr = &cave[y][x];
2913 /* Require target_able monsters for "TARGET_KILL" */
2914 if ((mode & (TARGET_KILL)) && !target_able(c_ptr->m_idx)) continue;
2916 if ((mode & (TARGET_KILL)) && !target_pet && is_pet(&m_list[c_ptr->m_idx])) continue;
2918 /* Save the location */
2925 /* Set the sort hooks */
2926 ang_sort_comp = ang_sort_comp_distance;
2927 ang_sort_swap = ang_sort_swap_distance;
2929 /* Sort the positions */
2930 ang_sort(temp_x, temp_y, temp_n);
2932 if (p_ptr->riding && target_pet && (temp_n > 1) && (mode & (TARGET_KILL)))
2937 temp_y[0] = temp_y[1];
2940 temp_x[0] = temp_x[1];
2947 * Evaluate number of kill needed to gain level
2949 static void evaluate_monster_exp(char *buf, monster_type *m_ptr)
2951 #define M_INT_GREATER(h1,l1,h2,l2) ( (h1>h2)||( (h1==h2)&&(l1>=l2)))
2952 #define M_INT_SUB(h1,l1, h2,l2) {h1-=h2;if(l1<l2){l1+=0x10000;h1--;}l1-=l2;}
2953 #define M_INT_ADD(h1,l1, h2,l2) {h1+=h2;l1+=l2;if(l1>=0x10000L){l1&=0xFFFF;h1++;}}
2954 #define M_INT_LSHIFT(h1,l1) {h1=(h1<<1)|(l1>>15);l1=(l1<<1)&0xffff;}
2955 #define M_INT_RSHIFT(h1,l1) {l1=(l1>>1)|((h1&1)<<15);h1>>=1;}
2956 #define M_INT_MULT(h1,l1,mul,h2,l2) {l2=(l1*mul)&0xffff;h2=((l1*mul)>>16)+h1*mul;}
2958 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
2962 u32b exp_mon= (ap_r_ptr->mexp)*(ap_r_ptr->level);
2963 u32b exp_mon_h= exp_mon / (p_ptr->max_plv+2);
2964 u32b exp_mon_l= ((exp_mon % (p_ptr->max_plv+2))*0x10000/(p_ptr->max_plv+2))&0xFFFF;
2966 u32b exp_adv_h = player_exp[p_ptr->lev -1] * p_ptr->expfact /100;
2967 u32b exp_adv_l = ((player_exp[p_ptr->lev -1]%100) * p_ptr->expfact *0x10000/100)&0xFFFF;
2969 M_INT_SUB(exp_adv_h, exp_adv_l, p_ptr->exp, p_ptr->exp_frac);
2970 if ((p_ptr->lev>=PY_MAX_LEVEL) || (p_ptr->prace == RACE_ANDROID))
2972 else if (!ap_r_ptr->r_tkills || (m_ptr->mflag2 & MFLAG_KAGE))
2974 else if (M_INT_GREATER(exp_mon_h, exp_mon_l, exp_adv_h, exp_adv_l))
2978 M_INT_MULT(exp_mon_h, exp_mon_l, 1000,tmp_h, tmp_l);
2979 if( M_INT_GREATER(exp_adv_h, exp_adv_l, tmp_h, tmp_l) )
2984 M_INT_ADD(exp_adv_h, exp_adv_l, exp_mon_h, exp_mon_l);
2985 M_INT_SUB(exp_adv_h, exp_adv_l, 0, 1);
2986 while(M_INT_GREATER(exp_adv_h, exp_adv_l, exp_mon_h,exp_mon_l))
2988 M_INT_LSHIFT(exp_mon_h,exp_mon_l);
2991 M_INT_RSHIFT(exp_mon_h,exp_mon_l);bit>>=1;
2992 for(;bit>=1;bit>>=1)
2994 if(M_INT_GREATER(exp_adv_h,exp_adv_l,exp_mon_h,exp_mon_l))
2997 M_INT_SUB(exp_adv_h,exp_adv_l,exp_mon_h,exp_mon_l);
2999 M_INT_RSHIFT(exp_mon_h,exp_mon_l);
3001 sprintf(buf,"%03d",result);
3008 * Examine a grid, return a keypress.
3010 * The "mode" argument contains the "TARGET_LOOK" bit flag, which
3011 * indicates that the "space" key should scan through the contents
3012 * of the grid, instead of simply returning immediately. This lets
3013 * the "look" command get complete information, without making the
3014 * "target" command annoying.
3016 * The "info" argument contains the "commands" which should be shown
3017 * inside the "[xxx]" text. This string must never be empty, or grids
3018 * containing monsters will be displayed with an extra comma.
3020 * Note that if a monster is in the grid, we update both the monster
3021 * recall info and the health bar info to track that monster.
3023 * Eventually, we may allow multiple objects per grid, or objects
3024 * and terrain features in the same grid. XXX XXX XXX
3026 * This function must handle blindness/hallucination.
3028 static int target_set_aux(int y, int x, int mode, cptr info)
3030 cave_type *c_ptr = &cave[y][x];
3031 s16b this_o_idx, next_o_idx = 0;
3032 cptr s1 = "", s2 = "", s3 = "", x_info = "";
3036 char out_val[MAX_NLEN+80];
3038 #ifdef ALLOW_EASY_FLOOR
3039 int floor_list[23], floor_num = 0;
3041 /* Scan all objects in the grid */
3044 floor_num = scan_floor(floor_list, y, x, 0x02);
3056 #endif /* ALLOW_EASY_FLOOR */
3058 /* Hack -- under the player */
3059 if ((y == py) && (x == px))
3082 /* Hack -- hallucination */
3086 cptr name = "²¿¤«´ñ̯¤Êʪ";
3088 cptr name = "something strange";
3092 /* Display a message */
3094 sprintf(out_val, "%s%s%s%s [%s]", s1, name, s2, s3, info);
3096 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, name, info);
3100 move_cursor_relative(y, x);
3103 /* Stop on everything but "return" */
3104 if ((query != '\r') && (query != '\n')) return query;
3106 /* Repeat forever */
3111 /* Actual monsters */
3112 if (c_ptr->m_idx && m_list[c_ptr->m_idx].ml)
3114 monster_type *m_ptr = &m_list[c_ptr->m_idx];
3115 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
3117 bool recall = FALSE;
3122 /* Get the monster name ("a kobold") */
3123 monster_desc(m_name, m_ptr, 0x08);
3125 /* Hack -- track this monster race */
3126 monster_race_track(m_ptr->ap_r_idx);
3128 /* Hack -- health bar for this monster */
3129 health_track(c_ptr->m_idx);
3131 /* Hack -- handle stuff */
3145 /* Recall on screen */
3146 screen_roff(m_ptr->ap_r_idx, 0);
3148 /* Hack -- Complete the prompt (again) */
3150 Term_addstr(-1, TERM_WHITE, format(" [r»× %s%s]", x_info, info));
3152 Term_addstr(-1, TERM_WHITE, format(" [r,%s%s]", x_info, info));
3161 /* Normal commands */
3162 if (query != 'r') break;
3167 /* Cleare recall text and repeat */
3173 /* Describe, and prompt for recall */
3174 evaluate_monster_exp(acount, m_ptr);
3177 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);
3179 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);
3185 move_cursor_relative(y, x);
3190 /* Normal commands */
3191 if (query != 'r') break;
3197 /* Always stop at "normal" keys */
3198 if ((query != '\r') && (query != '\n') && (query != ' ') && (query != 'x')) return query;
3200 /* Sometimes stop at "space" key */
3201 if ((query == ' ') && !(mode & (TARGET_LOOK))) return query;
3203 /* Change the intro */
3211 /* Hack -- take account of gender */
3213 if (ap_r_ptr->flags1 & (RF1_FEMALE)) s1 = "Èà½÷¤Ï";
3215 if (ap_r_ptr->flags1 & (RF1_FEMALE)) s1 = "She is ";
3219 else if (ap_r_ptr->flags1 & (RF1_MALE)) s1 = "Èà¤Ï";
3221 else if (ap_r_ptr->flags1 & (RF1_MALE)) s1 = "He is ";
3225 /* Use a preposition */
3234 /* Scan all objects being carried */
3235 for (this_o_idx = m_ptr->hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
3237 char o_name[MAX_NLEN];
3241 /* Acquire object */
3242 o_ptr = &o_list[this_o_idx];
3244 /* Acquire next object */
3245 next_o_idx = o_ptr->next_o_idx;
3247 /* Obtain an object description */
3248 object_desc(o_name, o_ptr, TRUE, 3);
3250 /* Describe the object */
3252 sprintf(out_val, "%s%s%s%s[%s]", s1, o_name, s2, s3, info);
3254 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, o_name, info);
3258 move_cursor_relative(y, x);
3261 /* Always stop at "normal" keys */
3262 if ((query != '\r') && (query != '\n') && (query != ' ') && (query != 'x')) return query;
3264 /* Sometimes stop at "space" key */
3265 if ((query == ' ') && !(mode & (TARGET_LOOK))) return query;
3267 /* Change the intro */
3271 s2 = "also carrying ";
3275 /* Use a preposition */
3285 #ifdef ALLOW_EASY_FLOOR
3294 char o_name[MAX_NLEN];
3298 /* Acquire object */
3299 o_ptr = &o_list[floor_list[0]];
3301 /* Describe the object */
3302 object_desc(o_name, o_ptr, TRUE, 3);
3306 sprintf(out_val, "%s%s%s%s[%s]",
3307 s1, o_name, s2, s3, info);
3309 sprintf(out_val, "%s%s%s%s [%s]",
3310 s1, s2, s3, o_name, info);
3314 move_cursor_relative(y, x);
3323 /* Provide one cushion before item listing */
3326 /* Display rough information about items */
3328 sprintf(out_val, "%s %d¸Ä¤Î¥¢¥¤¥Æ¥à%s%s ['x'¤Ç°ìÍ÷, %s]",
3329 s1, floor_num, s2, s3, info);
3331 sprintf(out_val, "%s%s%sa pile of %d items [x,%s]",
3332 s1, s2, s3, floor_num, info);
3336 move_cursor_relative(y, x);
3341 /* No request for listing */
3342 if (query != 'x' && query != ' ') return query;
3346 /** Display list of items **/
3348 /* Continue scrolling list if requested */
3358 (void)show_floor(0, y, x, &min_width);
3362 sprintf(out_val, "%s %d¸Ä¤Î¥¢¥¤¥Æ¥à%s%s [Enter¤Ç¼¡¤Ø, %s]",
3363 s1, floor_num, s2, s3, info);
3365 sprintf(out_val, "%s%s%sa pile of %d items [Enter,%s]",
3366 s1, s2, s3, floor_num, info);
3377 /* Exit unless 'Enter' */
3378 if (query != '\n' && query != '\r')
3383 /* Get the object being moved. */
3384 c_ptr = &cave[y][x];
3385 o_idx = c_ptr->o_idx;
3387 /* Only rotate a pile of two or more objects. */
3388 if (!(o_idx && o_list[o_idx].next_o_idx)) continue;
3390 /* Remove the first object from the list. */
3391 excise_object_idx(o_idx);
3393 /* Find end of the list. */
3395 while (o_list[i].next_o_idx)
3396 i = o_list[i].next_o_idx;
3398 /* Add after the last object. */
3399 o_list[i].next_o_idx = o_idx;
3401 /* Loop and re-display the list */
3408 #endif /* ALLOW_EASY_FLOOR */
3411 /* Scan all objects in the grid */
3412 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
3416 /* Acquire object */
3417 o_ptr = &o_list[this_o_idx];
3419 /* Acquire next object */
3420 next_o_idx = o_ptr->next_o_idx;
3425 char o_name[MAX_NLEN];
3430 /* Obtain an object description */
3431 object_desc(o_name, o_ptr, TRUE, 3);
3433 /* Describe the object */
3435 sprintf(out_val, "%s%s%s%s[%s]", s1, o_name, s2, s3, info);
3437 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, o_name, info);
3441 move_cursor_relative(y, x);
3444 /* Always stop at "normal" keys */
3445 if ((query != '\r') && (query != '\n') && (query != ' ') && (query != 'x')) return query;
3447 /* Sometimes stop at "space" key */
3448 if ((query == ' ') && !(mode & TARGET_LOOK)) return query;
3450 /* Change the intro */
3460 if (o_ptr->number != 1) s1 = "¤½¤ì¤é¤Ï";
3462 if (o_ptr->number != 1) s1 = "They are ";
3478 /* Feature code (applying "mimic" field) */
3479 feat = c_ptr->mimic ? c_ptr->mimic : f_info[c_ptr->feat].mimic;
3481 /* Require knowledge about grid, or ability to see grid */
3482 if (!(c_ptr->info & CAVE_MARK) && !player_can_see_bold(y, x))
3484 /* Forget feature */
3488 /* Terrain feature if needed */
3489 if (boring || (feat > FEAT_INVIS))
3493 /* Hack -- special handling for building doors */
3494 if ((feat >= FEAT_BLDG_HEAD) && (feat <= FEAT_BLDG_TAIL))
3496 name = building[feat - FEAT_BLDG_HEAD].name;
3498 else if (feat == FEAT_ENTRANCE)
3501 name = format("%s(%d³¬ÁêÅö)", d_text + d_info[c_ptr->special].text, d_info[c_ptr->special].mindepth);
3503 name = format("%s(level %d)", d_text + d_info[c_ptr->special].text, d_info[c_ptr->special].mindepth);
3506 else if (feat == FEAT_TOWN)
3508 name = town[c_ptr->special].name;
3510 else if (p_ptr->wild_mode && (feat == FEAT_FLOOR))
3520 name = f_name + f_info[feat].name;
3525 if (*s2 && ((feat >= FEAT_MINOR_GLYPH) &&
3526 (feat <= FEAT_PATTERN_XTRA2)))
3535 else if (*s2 && ((feat >= FEAT_DOOR_HEAD) &&
3536 (feat <= FEAT_PERM_SOLID)))
3545 else if (*s2 && (feat == FEAT_TOWN))
3555 /* Hack -- special introduction for store & building doors -KMW- */
3556 if (((feat >= FEAT_SHOP_HEAD) && (feat <= FEAT_SHOP_TAIL)) ||
3557 ((feat >= FEAT_BLDG_HEAD) && (feat <= FEAT_BLDG_TAIL)) ||
3558 (feat == FEAT_MUSEUM) ||
3559 (feat == FEAT_ENTRANCE))
3568 else if ((feat == FEAT_TOWN) || (feat == FEAT_FLOOR) || (feat == FEAT_DIRT) || (feat == FEAT_FLOWER))
3576 /* Pick proper indefinite article */
3578 s3 = (is_a_vowel(name[0])) ? "an " : "a ";
3582 /* Display a message */
3585 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);
3587 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);
3591 sprintf(out_val, "%s%s%s%s[%s]", s1, name, s2, s3, info);
3593 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, name, info);
3597 move_cursor_relative(y, x);
3600 /* Always stop at "normal" keys */
3601 if ((query != '\r') && (query != '\n') && (query != ' ')) return query;
3604 /* Stop on everything but "return" */
3605 if ((query != '\r') && (query != '\n')) return query;
3607 /* Repeat forever */
3613 * Handle "target" and "look".
3615 * Note that this code can be called from "get_aim_dir()".
3617 * All locations must be on the current panel. Consider the use of
3618 * "panel_bounds()" to allow "off-panel" targets, perhaps by using
3619 * some form of "scrolling" the map around the cursor. XXX XXX XXX
3620 * That is, consider the possibility of "auto-scrolling" the screen
3621 * while the cursor moves around. This may require changes in the
3622 * "update_mon()" code to allow "visibility" even if off panel, and
3623 * may require dynamic recalculation of the "temp" grid set.
3625 * Hack -- targeting/observing an "outer border grid" may induce
3626 * problems, so this is not currently allowed.
3628 * The player can use the direction keys to move among "interesting"
3629 * grids in a heuristic manner, or the "space", "+", and "-" keys to
3630 * move through the "interesting" grids in a sequential manner, or
3631 * can enter "location" mode, and use the direction keys to move one
3632 * grid at a time in any direction. The "t" (set target) command will
3633 * only target a monster (as opposed to a location) if the monster is
3634 * target_able and the "interesting" mode is being used.
3636 * The current grid is described using the "look" method above, and
3637 * a new command may be entered at any time, but note that if the
3638 * "TARGET_LOOK" bit flag is set (or if we are in "location" mode,
3639 * where "space" has no obvious meaning) then "space" will scan
3640 * through the description of the current grid until done, instead
3641 * of immediately jumping to the next "interesting" grid. This
3642 * allows the "target" command to retain its old semantics.
3644 * The "*", "+", and "-" keys may always be used to jump immediately
3645 * to the next (or previous) interesting grid, in the proper mode.
3647 * The "return" key may always be used to scan through a complete
3648 * grid description (forever).
3650 * This command will cancel any old target, even if used from
3651 * inside the "look" command.
3653 bool target_set(int mode)
3673 get_screen_size(&wid, &hgt);
3679 /* Cancel tracking */
3680 /* health_track(0); */
3683 /* Prepare the "temp" array */
3684 target_set_prepare(mode);
3686 /* Start near the player */
3692 /* Interesting grids */
3698 if (!(mode & TARGET_LOOK)) prt_path(y, x);
3701 c_ptr = &cave[y][x];
3704 if (target_able(c_ptr->m_idx))
3707 strcpy(info, "q»ß t·è p¼« o¸½ +¼¡ -Á°");
3709 strcpy(info, "q,t,p,o,+,-,<dir>");
3714 /* Dis-allow target */
3718 strcpy(info, "q»ß p¼« o¸½ +¼¡ -Á°");
3720 strcpy(info, "q,p,o,+,-,<dir>");
3725 /* Describe and Prompt */
3726 while (!(query = target_set_aux(y, x, mode, info)));
3728 /* Cancel tracking */
3729 /* health_track(0); */
3731 /* Assume no "direction" */
3736 if (query == '\r') query = 't';
3754 if (target_able(c_ptr->m_idx))
3756 health_track(c_ptr->m_idx);
3757 target_who = c_ptr->m_idx;
3776 if (!expand_list) done = TRUE;
3786 if (!expand_list) done = TRUE;
3793 /* Recenter the map around the player */
3797 p_ptr->update |= (PU_MONSTERS);
3800 p_ptr->redraw |= (PR_MAP);
3803 p_ptr->window |= (PW_OVERHEAD);
3808 /* Recalculate interesting grids */
3809 target_set_prepare(mode);
3828 /* Extract the action (if any) */
3829 d = get_keymap_dir(query);
3836 /* Hack -- move around */
3839 /* Modified to scroll to monster */
3840 int y2 = panel_row_min;
3841 int x2 = panel_col_min;
3843 /* Find a new monster */
3844 i = target_pick(temp_y[m], temp_x[m], ddy[d], ddx[d]);
3846 /* Request to target past last interesting grid */
3847 while (flag && (i < 0))
3849 /* Note the change */
3850 if (change_panel(ddy[d], ddx[d]))
3855 /* Recalculate interesting grids */
3856 target_set_prepare(mode);
3858 /* Look at interesting grids */
3861 /* Find a new monster */
3862 i = target_pick(v, u, ddy[d], ddx[d]);
3868 /* Nothing interesting */
3874 /* Restore previous position */
3877 panel_bounds_center();
3880 p_ptr->update |= (PU_MONSTERS);
3883 p_ptr->redraw |= (PR_MAP);
3886 p_ptr->window |= (PW_OVERHEAD);
3891 /* Recalculate interesting grids */
3892 target_set_prepare(mode);
3894 /* Look at boring grids */
3901 /* Do not move horizontally if unnecessary */
3902 if (((x < panel_col_min + wid / 2) && (dx > 0)) ||
3903 ((x > panel_col_min + wid / 2) && (dx < 0)))
3908 /* Do not move vertically if unnecessary */
3909 if (((y < panel_row_min + hgt / 2) && (dy > 0)) ||
3910 ((y > panel_row_min + hgt / 2) && (dy < 0)))
3915 /* Apply the motion */
3916 if ((y >= panel_row_min+hgt) || (y < panel_row_min) ||
3917 (x >= panel_col_min+wid) || (x < panel_col_min))
3919 if (change_panel(dy, dx)) target_set_prepare(mode);
3922 /* Slide into legality */
3923 if (x >= cur_wid-1) x = cur_wid - 2;
3924 else if (x <= 0) x = 1;
3926 /* Slide into legality */
3927 if (y >= cur_hgt-1) y = cur_hgt- 2;
3928 else if (y <= 0) y = 1;
3937 /* Arbitrary grids */
3940 bool move_fast = FALSE;
3942 if (!(mode & TARGET_LOOK)) prt_path(y, x);
3945 c_ptr = &cave[y][x];
3947 /* Default prompt */
3949 strcpy(info, "q»ß t·è p¼« m¶á +¼¡ -Á°");
3951 strcpy(info, "q,t,p,m,+,-,<dir>");
3955 /* Describe and Prompt (enable "TARGET_LOOK") */
3956 while (!(query = target_set_aux(y, x, mode | TARGET_LOOK, info)));
3958 /* Cancel tracking */
3959 /* health_track(0); */
3961 /* Assume no direction */
3966 if (query == '\r') query = 't';
3969 /* Analyze the keypress */
3993 /* Recenter the map around the player */
3997 p_ptr->update |= (PU_MONSTERS);
4000 p_ptr->redraw |= (PR_MAP);
4003 p_ptr->window |= (PW_OVERHEAD);
4008 /* Recalculate interesting grids */
4009 target_set_prepare(mode);
4031 /* Pick a nearby monster */
4032 for (i = 0; i < temp_n; i++)
4034 t = distance(y, x, temp_y[i], temp_x[i]);
4044 /* Nothing interesting */
4045 if (bd == 999) flag = FALSE;
4052 /* Extract the action (if any) */
4053 d = get_keymap_dir(query);
4055 /* XTRA HACK MOVEFAST */
4056 if (isupper(query)) move_fast = TRUE;
4063 /* Handle "direction" */
4069 /* XTRA HACK MOVEFAST */
4072 int mag = MIN(wid / 2, hgt / 2);
4082 /* Do not move horizontally if unnecessary */
4083 if (((x < panel_col_min + wid / 2) && (dx > 0)) ||
4084 ((x > panel_col_min + wid / 2) && (dx < 0)))
4089 /* Do not move vertically if unnecessary */
4090 if (((y < panel_row_min + hgt / 2) && (dy > 0)) ||
4091 ((y > panel_row_min + hgt / 2) && (dy < 0)))
4096 /* Apply the motion */
4097 if ((y >= panel_row_min + hgt) || (y < panel_row_min) ||
4098 (x >= panel_col_min + wid) || (x < panel_col_min))
4100 if (change_panel(dy, dx)) target_set_prepare(mode);
4103 /* Slide into legality */
4104 if (x >= cur_wid-1) x = cur_wid - 2;
4105 else if (x <= 0) x = 1;
4107 /* Slide into legality */
4108 if (y >= cur_hgt-1) y = cur_hgt- 2;
4109 else if (y <= 0) y = 1;
4117 /* Clear the top line */
4120 /* Recenter the map around the player */
4124 p_ptr->update |= (PU_MONSTERS);
4127 p_ptr->redraw |= (PR_MAP);
4130 p_ptr->window |= (PW_OVERHEAD);
4135 /* Failure to set target */
4136 if (!target_who) return (FALSE);
4144 * Get an "aiming direction" from the user.
4146 * The "dir" is loaded with 1,2,3,4,6,7,8,9 for "actual direction", and
4147 * "0" for "current target", and "-1" for "entry aborted".
4149 * Note that "Force Target", if set, will pre-empt user interaction,
4150 * if there is a usable target already set.
4152 * Note that confusion over-rides any (explicit?) user choice.
4154 bool get_aim_dir(int *dp)
4165 /* Global direction */
4168 /* Hack -- auto-target if requested */
4169 if (use_old_target && target_okay()) dir = 5;
4171 #ifdef ALLOW_REPEAT /* TNB */
4173 if (repeat_pull(dp))
4178 if (!(*dp == 5 && !target_okay()))
4180 /* return (TRUE); */
4185 #endif /* ALLOW_REPEAT -- TNB */
4187 /* Ask until satisfied */
4190 /* Choose a prompt */
4194 p = "Êý¸þ ('*'¤Ç¥¿¡¼¥²¥Ã¥ÈÁªÂò, ESC¤ÇÃæÃÇ)? ";
4196 p = "Direction ('*' to choose a target, Escape to cancel)? ";
4203 p = "Êý¸þ ('5'¤Ç¥¿¡¼¥²¥Ã¥È¤Ø, '*'¤Ç¥¿¡¼¥²¥Ã¥ÈºÆÁªÂò, ESC¤ÇÃæÃÇ)? ";
4205 p = "Direction ('5' for target, '*' to re-target, Escape to cancel)? ";
4210 /* Get a command (or Cancel) */
4211 if (!get_com(p, &command, TRUE)) break;
4215 if (command == '\r') command = 't';
4218 /* Convert various keys to "standard" keys */
4221 /* Use current target */
4232 /* Set new target */
4237 if (target_set(TARGET_KILL)) dir = 5;
4243 /* Extract the action (if any) */
4244 dir = get_keymap_dir(command);
4250 /* Verify requested targets */
4251 if ((dir == 5) && !target_okay()) dir = 0;
4260 project_length = 0; /* reset to default */
4264 /* Save the direction */
4267 /* Check for confusion */
4268 if (p_ptr->confused)
4271 /* Random direction */
4272 dir = ddd[randint0(8)];
4275 /* Notice confusion */
4276 if (command_dir != dir)
4280 msg_print("¤¢¤Ê¤¿¤Ïº®Í𤷤Ƥ¤¤ë¡£");
4282 msg_print("You are confused.");
4287 /* Save direction */
4290 #ifdef ALLOW_REPEAT /* TNB */
4292 /* repeat_push(dir); */
4293 repeat_push(command_dir);
4295 #endif /* ALLOW_REPEAT -- TNB */
4297 /* A "valid" direction was entered */
4304 * Request a "movement" direction (1,2,3,4,6,7,8,9) from the user,
4305 * and place it into "command_dir", unless we already have one.
4307 * This function should be used for all "repeatable" commands, such as
4308 * run, walk, open, close, bash, disarm, spike, tunnel, etc, as well
4309 * as all commands which must reference a grid adjacent to the player,
4310 * and which may not reference the grid under the player. Note that,
4311 * for example, it is no longer possible to "disarm" or "open" chests
4312 * in the same grid as the player.
4314 * Direction "5" is illegal and will (cleanly) abort the command.
4316 * This function tracks and uses the "global direction", and uses
4317 * that as the "desired direction", to which "confusion" is applied.
4319 bool get_rep_dir(int *dp, bool under)
4326 /* Global direction */
4329 #ifdef ALLOW_REPEAT /* TNB */
4331 if (repeat_pull(dp))
4334 /* return (TRUE); */
4337 #endif /* ALLOW_REPEAT -- TNB */
4339 /* Get a direction */
4344 /* Get a command (or Cancel) */
4346 if (!get_com("Êý¸þ (ESC¤ÇÃæÃÇ)? ", &ch, TRUE)) break;
4348 if (!get_com("Direction (Escape to cancel)? ", &ch, TRUE)) break;
4352 /* Look up the direction */
4353 dir = get_keymap_dir(ch);
4359 /* Prevent weirdness */
4360 if ((dir == 5) && (!under)) dir = 0;
4363 if (!dir) return (FALSE);
4365 /* Save desired direction */
4368 /* Apply "confusion" */
4369 if (p_ptr->confused)
4371 /* Standard confusion */
4372 if (randint0(100) < 75)
4374 /* Random direction */
4375 dir = ddd[randint0(8)];
4378 else if (p_ptr->riding)
4380 monster_type *m_ptr = &m_list[p_ptr->riding];
4381 monster_race *r_ptr = &r_info[m_ptr->r_idx];
4383 if (m_ptr->confused)
4385 /* Standard confusion */
4386 if (randint0(100) < 75)
4388 /* Random direction */
4389 dir = ddd[randint0(8)];
4392 else if ((r_ptr->flags1 & RF1_RAND_50) && (r_ptr->flags1 & RF1_RAND_25) && (randint0(100) < 50))
4394 /* Random direction */
4395 dir = ddd[randint0(8)];
4397 else if ((r_ptr->flags1 & RF1_RAND_50) && (randint0(100) < 25))
4399 /* Random direction */
4400 dir = ddd[randint0(8)];
4404 /* Notice confusion */
4405 if (command_dir != dir)
4407 if (p_ptr->confused)
4411 msg_print("¤¢¤Ê¤¿¤Ïº®Í𤷤Ƥ¤¤ë¡£");
4413 msg_print("You are confused.");
4419 monster_type *m_ptr = &m_list[p_ptr->riding];
4421 monster_desc(m_name, m_ptr, 0);
4422 if (m_ptr->confused)
4425 msg_format("%s¤Ïº®Í𤷤Ƥ¤¤ë¡£", m_name);
4427 msg_format("%^s is confusing.", m_name);
4434 msg_format("%s¤Ï»×¤¤Ä̤ê¤ËÆ°¤¤¤Æ¤¯¤ì¤Ê¤¤¡£", m_name);
4436 msg_format("You cannot control %s.", m_name);
4442 /* Save direction */
4445 #ifdef ALLOW_REPEAT /* TNB */
4447 /* repeat_push(dir); */
4448 repeat_push(command_dir);
4450 #endif /* ALLOW_REPEAT -- TNB */
4457 bool get_rep_dir2(int *dp)
4464 /* Global direction */
4467 #ifdef ALLOW_REPEAT /* TNB */
4469 if (repeat_pull(dp))
4472 /* return (TRUE); */
4475 #endif /* ALLOW_REPEAT -- TNB */
4477 /* Get a direction */
4482 /* Get a command (or Cancel) */
4484 if (!get_com("Êý¸þ (ESC¤ÇÃæÃÇ)? ", &ch, TRUE)) break;
4486 if (!get_com("Direction (Escape to cancel)? ", &ch, TRUE)) break;
4490 /* Look up the direction */
4491 dir = get_keymap_dir(ch);
4497 /* Prevent weirdness */
4498 if (dir == 5) dir = 0;
4501 if (!dir) return (FALSE);
4503 /* Save desired direction */
4506 /* Apply "confusion" */
4507 if (p_ptr->confused)
4509 /* Standard confusion */
4510 if (randint0(100) < 75)
4512 /* Random direction */
4513 dir = ddd[randint0(8)];
4517 /* Notice confusion */
4518 if (command_dir != dir)
4522 msg_print("¤¢¤Ê¤¿¤Ïº®Í𤷤Ƥ¤¤ë¡£");
4524 msg_print("You are confused.");
4529 /* Save direction */
4532 #ifdef ALLOW_REPEAT /* TNB */
4534 /* repeat_push(dir); */
4535 repeat_push(command_dir);
4537 #endif /* ALLOW_REPEAT -- TNB */
4544 int get_chaos_patron(void)
4546 return ((p_ptr->age + p_ptr->sc) % MAX_PATRON);
4550 void gain_level_reward(int chosen_reward)
4554 char wrath_reason[32] = "";
4555 int nasty_chance = 6;
4556 int dummy = 0, dummy2 = 0;
4559 char o_name[MAX_NLEN];
4565 if (multi_rew) return;
4566 else multi_rew = TRUE;
4570 if (p_ptr->lev == 13) nasty_chance = 2;
4571 else if (!(p_ptr->lev % 13)) nasty_chance = 3;
4572 else if (!(p_ptr->lev % 14)) nasty_chance = 12;
4574 if (one_in_(nasty_chance))
4575 type = randint1(20); /* Allow the 'nasty' effects */
4577 type = randint1(15) + 5; /* Or disallow them */
4579 if (type < 1) type = 1;
4580 if (type > 20) type = 20;
4585 sprintf(wrath_reason, "%s¤ÎÅܤê",
4586 chaos_patrons[p_ptr->chaos_patron]);
4588 sprintf(wrath_reason, "the Wrath of %s",
4589 chaos_patrons[p_ptr->chaos_patron]);
4593 effect = chaos_rewards[p_ptr->chaos_patron][type];
4595 if (one_in_(6) && !chosen_reward)
4598 msg_format("%^s¤ÏË«Èþ¤È¤·¤Æ¤¢¤Ê¤¿¤òÆÍÁ³ÊÑ°Û¤µ¤»¤¿¡£",
4599 chaos_patrons[p_ptr->chaos_patron]);
4601 msg_format("%^s rewards you with a mutation!",
4602 chaos_patrons[p_ptr->chaos_patron]);
4605 (void)gain_random_mutation(0);
4607 reward = "ÊÑ°Û¤·¤¿¡£";
4609 reward = "mutation";
4614 switch (chosen_reward ? chosen_reward : effect)
4618 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
4619 chaos_patrons[p_ptr->chaos_patron]);
4621 msg_format("The voice of %s booms out:",
4622 chaos_patrons[p_ptr->chaos_patron]);
4626 msg_print("¡ÖÆò¡¢¿·¤¿¤Ê¤ë»Ñ¤òɬÍפȤ»¤ê¡ª¡×");
4628 msg_print("'Thou needst a new form, mortal!'");
4633 reward = "ÊÑ°Û¤·¤¿¡£";
4635 reward = "polymorphing";
4640 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
4641 chaos_patrons[p_ptr->chaos_patron]);
4643 msg_format("The voice of %s booms out:",
4644 chaos_patrons[p_ptr->chaos_patron]);
4648 msg_print("¡ÖÆò¤ÏÎɤ¯¹Ô¤¤¤¿¤ê¡ªÂ³¤±¤è¡ª¡×");
4650 msg_print("'Well done, mortal! Lead on!'");
4653 if (p_ptr->prace == RACE_ANDROID)
4656 msg_print("¤·¤«¤·²¿¤âµ¯¤³¤é¤Ê¤«¤Ã¤¿¡£");
4658 msg_print("But, nothing happen.");
4661 else if (p_ptr->exp < PY_MAX_EXP)
4663 s32b ee = (p_ptr->exp / 2) + 10;
4664 if (ee > 100000L) ee = 100000L;
4666 msg_print("¹¹¤Ë·Ð¸³¤òÀѤó¤À¤è¤¦¤Êµ¤¤¬¤¹¤ë¡£");
4668 msg_print("You feel more experienced.");
4673 reward = "·Ð¸³ÃͤòÆÀ¤¿";
4675 reward = "experience";
4681 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
4682 chaos_patrons[p_ptr->chaos_patron]);
4684 msg_format("The voice of %s booms out:",
4685 chaos_patrons[p_ptr->chaos_patron]);
4689 msg_print("¡Ö²¼Ëͤ衢Æò¤½¤ì¤ËÃͤ»¤º¡£¡×");
4691 msg_print("'Thou didst not deserve that, slave.'");
4694 if (p_ptr->prace == RACE_ANDROID)
4697 msg_print("¤·¤«¤·²¿¤âµ¯¤³¤é¤Ê¤«¤Ã¤¿¡£");
4699 msg_print("But, nothing happen.");
4704 lose_exp(p_ptr->exp / 6);
4706 reward = "·Ð¸³Ãͤò¼º¤Ã¤¿¡£";
4708 reward = "losing experience";
4714 msg_format("%s¤ÎÀ¼¤¬¤µ¤µ¤ä¤¤¤¿:",
4715 chaos_patrons[p_ptr->chaos_patron]);
4717 msg_format("The voice of %s whispers:",
4718 chaos_patrons[p_ptr->chaos_patron]);
4722 msg_print("¡Ö²æ¤¬Í¿¤¨¤·Êª¤ò¸ÌÀ¤Ë»È¤¦¤Ù¤·¡£¡×");
4724 msg_print("'Use my gift wisely.'");
4727 acquirement(py, px, 1, FALSE, FALSE);
4729 reward = "¾å¼Á¤Ê¥¢¥¤¥Æ¥à¤ò¼ê¤ËÆþ¤ì¤¿¡£";
4731 reward = "a good item";
4736 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
4737 chaos_patrons[p_ptr->chaos_patron]);
4739 msg_format("The voice of %s booms out:",
4740 chaos_patrons[p_ptr->chaos_patron]);
4744 msg_print("¡Ö²æ¤¬Í¿¤¨¤·Êª¤ò¸ÌÀ¤Ë»È¤¦¤Ù¤·¡£¡×");
4746 msg_print("'Use my gift wisely.'");
4749 acquirement(py, px, 1, TRUE, FALSE);
4751 reward = "¹âµéÉʤΥ¢¥¤¥Æ¥à¤ò¼ê¤ËÆþ¤ì¤¿¡£";
4753 reward = "an excellent item";
4758 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
4759 chaos_patrons[p_ptr->chaos_patron]);
4761 msg_format("The voice of %s booms out:",
4762 chaos_patrons[p_ptr->chaos_patron]);
4766 msg_print("¡ÖÆò¤Î¹Ô¤¤¤Ïµ®¤·õ¤ËÃͤ»¤ê¡£¡×");
4768 msg_print("'Thy deed hath earned thee a worthy blade.'");
4771 /* Get local object */
4774 switch (randint1(p_ptr->lev))
4780 dummy2 = SV_MAIN_GAUCHE;
4789 dummy2 = SV_SMALL_SWORD;
4792 dummy2 = SV_BASILLARD;
4794 case 11: case 12: case 13:
4795 dummy2 = SV_SHORT_SWORD;
4801 dummy2 = SV_CUTLASS;
4804 dummy2 = SV_WAKIZASHI;
4807 dummy2 = SV_KHOPESH;
4813 dummy2 = SV_BROAD_SWORD;
4816 dummy2 = SV_LONG_SWORD;
4819 dummy2 = SV_SCIMITAR;
4822 dummy2 = SV_NINJATO;
4828 dummy2 = SV_BASTARD_SWORD;
4831 dummy2 = SV_GREAT_SCIMITAR;
4834 dummy2 = SV_CLAYMORE;
4837 dummy2 = SV_ESPADON;
4840 dummy2 = SV_TWO_HANDED_SWORD;
4843 dummy2 = SV_FLAMBERGE;
4846 dummy2 = SV_NO_DACHI;
4849 dummy2 = SV_EXECUTIONERS_SWORD;
4852 dummy2 = SV_ZWEIHANDER;
4855 dummy2 = SV_HAYABUSA;
4858 dummy2 = SV_BLADE_OF_CHAOS;
4861 object_prep(q_ptr, lookup_kind(dummy, dummy2));
4862 q_ptr->to_h = 3 + randint1(dun_level) % 10;
4863 q_ptr->to_d = 3 + randint1(dun_level) % 10;
4864 one_resistance(q_ptr);
4865 q_ptr->name2 = EGO_CHAOTIC;
4867 /* Drop it in the dungeon */
4868 (void)drop_near(q_ptr, -1, py, px);
4870 reward = "(º®ÆÙ)¤ÎÉð´ï¤ò¼ê¤ËÆþ¤ì¤¿¡£";
4872 reward = "chaos weapon";
4877 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
4878 chaos_patrons[p_ptr->chaos_patron]);
4880 msg_format("The voice of %s booms out:",
4881 chaos_patrons[p_ptr->chaos_patron]);
4885 msg_print("¡ÖÆò¤Î¹Ô¤¤¤Ïµ®¤Ê󤤤ËÃͤ»¤ê¡£¡×");
4887 msg_print("'Thy deed hath earned thee a worthy reward.'");
4890 acquirement(py, px, randint1(2) + 1, FALSE, FALSE);
4892 reward = "¾å¼Á¤Ê¥¢¥¤¥Æ¥à¤ò¼ê¤ËÆþ¤ì¤¿¡£";
4894 reward = "good items";
4899 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
4900 chaos_patrons[p_ptr->chaos_patron]);
4902 msg_format("The voice of %s booms out:",
4903 chaos_patrons[p_ptr->chaos_patron]);
4907 msg_print("¡Ö²¼Ëͤ衢Æò¤Î¸¥¿È¤Ø¤Î²æ¤¬Àˤ·¤ß̵¤Ê󤤤ò¸«¤ë¤¬¤è¤¤¡£¡×");
4909 msg_print("'Behold, mortal, how generously I reward thy loyalty.'");
4912 acquirement(py, px, randint1(2) + 1, TRUE, FALSE);
4914 reward = "¹âµéÉʤΥ¢¥¤¥Æ¥à¤ò¼ê¤ËÆþ¤ì¤¿¡£";
4916 reward = "excellent items";
4921 msg_format("%s¤ÎÀ¼¤¬¹ì¤ÅϤä¿:",
4922 chaos_patrons[p_ptr->chaos_patron]);
4924 msg_format("The voice of %s thunders:",
4925 chaos_patrons[p_ptr->chaos_patron]);
4929 msg_print("¡Ö²¼Ëͤ衢ÆòÐþËý¤Ê¤ê¡£¡×");
4931 msg_print("'Thou art growing arrogant, mortal.'");
4934 (void)activate_ty_curse(FALSE, &count);
4936 reward = "²Ò¡¹¤·¤¤¼ö¤¤¤ò¤«¤±¤é¤ì¤¿¡£";
4943 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
4944 chaos_patrons[p_ptr->chaos_patron]);
4946 msg_format("The voice of %s booms out:",
4947 chaos_patrons[p_ptr->chaos_patron]);
4951 msg_print("¡Ö²æ¤¬²¼Ëͤ¿¤Á¤è¡¢¤«¤ÎÐþËý¤Ê¤ë¼Ô¤òÅݤ¹¤Ù¤·¡ª¡×");
4953 msg_print("'My pets, destroy the arrogant mortal!'");
4956 for (dummy = 0; dummy < randint1(5) + 1; dummy++)
4958 (void)summon_specific(0, py, px, dun_level, 0, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET));
4961 reward = "¥â¥ó¥¹¥¿¡¼¤ò¾¤´¤µ¤ì¤¿¡£";
4963 reward = "summoning hostile monsters";
4968 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
4969 chaos_patrons[p_ptr->chaos_patron]);
4971 msg_format("The voice of %s booms out:",
4972 chaos_patrons[p_ptr->chaos_patron]);
4976 msg_print("¡ÖÆò¡¢¤è¤ê¶¯¤Å¨¤òɬÍפȤ»¤ê¡ª¡×");
4978 msg_print("'Thou needst worthier opponents!'");
4981 activate_hi_summon(py, px, FALSE);
4983 reward = "¥â¥ó¥¹¥¿¡¼¤ò¾¤´¤µ¤ì¤¿¡£";
4985 reward = "summoning many hostile monsters";
4990 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
4991 chaos_patrons[p_ptr->chaos_patron]);
4993 msg_format("The voice of %s booms out:",
4994 chaos_patrons[p_ptr->chaos_patron]);
4998 msg_print("¡Ö»à¤ÈÇ˲õ¤³¤½²æ¤¬´î¤Ó¤Ê¤ê¡ª¡×");
5000 msg_print("'Death and destruction! This pleaseth me!'");
5005 reward = "¥«¥ª¥¹¤ÎÎϤ¬±²´¬¤¤¤¿¡£";
5007 reward = "calling chaos";
5012 msg_format("%s¤ÎÀ¼¤¬ÌĤê¶Á¤¤¤¿:",
5013 chaos_patrons[p_ptr->chaos_patron]);
5015 msg_format("The voice of %s rings out:",
5016 chaos_patrons[p_ptr->chaos_patron]);
5020 msg_print("¡Öα¤Þ¤ë¤Î¤À¡¢²¼Ëͤ衣;¤¬Æò¤ÎÆùÂΤòÃ䨤󡣡×");
5022 msg_print("'Stay, mortal, and let me mold thee.'");
5025 if (one_in_(3) && !(chaos_stats[p_ptr->chaos_patron] < 0))
5026 do_inc_stat(chaos_stats[p_ptr->chaos_patron]);
5028 do_inc_stat(randint0(6));
5030 reward = "ǽÎÏÃͤ¬¾å¤¬¤Ã¤¿¡£";
5032 reward = "increasing a stat";
5037 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5038 chaos_patrons[p_ptr->chaos_patron]);
5040 msg_format("The voice of %s booms out:",
5041 chaos_patrons[p_ptr->chaos_patron]);
5045 msg_print("¡Ö²¼Ëͤ衢;¤ÏÆò¤ËË°¤ß¤¿¤ê¡£¡×");
5047 msg_print("'I grow tired of thee, mortal.'");
5050 if (one_in_(3) && !(chaos_stats[p_ptr->chaos_patron] < 0))
5051 do_dec_stat(chaos_stats[p_ptr->chaos_patron]);
5053 (void)do_dec_stat(randint0(6));
5055 reward = "ǽÎÏÃͤ¬²¼¤¬¤Ã¤¿¡£";
5057 reward = "decreasing a stat";
5062 msg_format("%s¤ÎÀ¼¤¬¹ì¤ÅϤä¿:",
5063 chaos_patrons[p_ptr->chaos_patron]);
5065 msg_format("The voice of %s thunders:",
5066 chaos_patrons[p_ptr->chaos_patron]);
5070 msg_print("¡ÖÆò¡¢¸¬µõ¤¿¤ë¤³¤È¤ò³Ø¤Ö¤Ù¤·¡ª¡×");
5071 msg_print("¤¢¤Ê¤¿¤Ï°ÊÁ°¤è¤ê¼å¤¯¤Ê¤Ã¤¿¡ª");
5073 msg_print("'Thou needst a lesson in humility, mortal!'");
5074 msg_print("You feel less powerful!");
5077 for (dummy = 0; dummy < 6; dummy++)
5079 (void)dec_stat(dummy, 10 + randint1(15), TRUE);
5082 reward = "Á´Ç½ÎÏÃͤ¬²¼¤¬¤Ã¤¿¡£";
5084 reward = "decreasing all stats";
5089 msg_format("%s¤ÎÎϤ¬¿¨¤ì¤ë¤Î¤ò´¶¤¸¤¿¡£",
5091 msg_format("You feel the power of %s touch you.",
5094 chaos_patrons[p_ptr->chaos_patron]);
5097 reward = "½ý¤¬ÊѲ½¤·¤¿¡£";
5099 reward = "polymorphing wounds";
5104 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5105 chaos_patrons[p_ptr->chaos_patron]);
5107 msg_format("The voice of %s booms out:",
5108 chaos_patrons[p_ptr->chaos_patron]);
5112 msg_print("¡Ö²æ¤¬¤µ¤µ¤ä¤«¤Ê¤ë»òʪ¤ò¼õ¤±¤È¤ë¤¬¤è¤¤¡ª¡×");
5114 msg_print("'Receive this modest gift from me!'");
5117 for (dummy = 0; dummy < 6; dummy++)
5119 (void)do_inc_stat(dummy);
5122 reward = "Á´Ç½ÎÏÃͤ¬¾å¤¬¤Ã¤¿¡£";
5124 reward = "increasing all stats";
5129 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5130 chaos_patrons[p_ptr->chaos_patron]);
5132 msg_format("The voice of %s booms out:",
5133 chaos_patrons[p_ptr->chaos_patron]);
5137 msg_print("¡Ö¶ì¤·¤à¤¬¤è¤¤¡¢ÌµÇ½¤Ê¶ò¤«¼Ô¤è¡ª¡×");
5139 msg_print("'Suffer, pathetic fool!'");
5142 fire_ball(GF_DISINTEGRATE, 0, p_ptr->lev * 4, 4);
5143 take_hit(DAMAGE_NOESCAPE, p_ptr->lev * 4, wrath_reason, -1);
5145 reward = "ʬ²ò¤Îµå¤¬È¯À¸¤·¤¿¡£";
5147 reward = "generating disintegration ball";
5152 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5153 chaos_patrons[p_ptr->chaos_patron]);
5155 msg_format("The voice of %s booms out:",
5156 chaos_patrons[p_ptr->chaos_patron]);
5160 msg_print("¡Öᴤ뤬¤è¤¤¡¢²æ¤¬²¼Ëͤ衪¡×");
5162 msg_print("'Rise, my servant!'");
5166 (void)set_poisoned(0);
5168 (void)set_confused(0);
5173 for (dummy = 0; dummy < 6; dummy++)
5175 (void)do_res_stat(dummy);
5178 reward = "ÂÎÎϤ¬²óÉü¤·¤¿¡£";
5184 if (!buki_motteruka(INVEN_RARM)) break;
5186 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5187 chaos_patrons[p_ptr->chaos_patron]);
5189 msg_format("The voice of %s booms out:",
5190 chaos_patrons[p_ptr->chaos_patron]);
5194 msg_print("¡ÖÆò¡¢Éð´ï¤ËÍê¤ë¤³¤È¤Ê¤«¤ì¡£¡×");
5196 msg_print("'Thou reliest too much on thy weapon.'");
5199 object_desc(o_name, &inventory[INVEN_RARM], TRUE, 0);
5200 (void)curse_weapon(FALSE, INVEN_RARM);
5202 reward = format("%s¤¬Ç˲õ¤µ¤ì¤¿¡£", o_name);
5204 reward = format("destroying %s", o_name);
5208 if (!inventory[INVEN_BODY].k_idx) break;
5210 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5211 chaos_patrons[p_ptr->chaos_patron]);
5213 msg_format("The voice of %s booms out:",
5214 chaos_patrons[p_ptr->chaos_patron]);
5218 msg_print("¡ÖÆò¡¢Ëɶñ¤ËÍê¤ë¤³¤È¤Ê¤«¤ì¡£¡×");
5220 msg_print("'Thou reliest too much on thine equipment.'");
5223 object_desc(o_name, &inventory[INVEN_BODY], TRUE, 0);
5224 (void)curse_armor();
5226 reward = format("%s¤¬Ç˲õ¤µ¤ì¤¿¡£", o_name);
5228 reward = format("destroying %s", o_name);
5233 msg_format("%s¤ÎÀ¼¤¬¤µ¤µ¤ä¤¤¤¿:",
5234 chaos_patrons[p_ptr->chaos_patron]);
5236 msg_format("The voice of %s whispers:",
5237 chaos_patrons[p_ptr->chaos_patron]);
5241 msg_print("¡Ö²æ¤òÅܤꤷ¤á¤¿ºá¤ò½þ¤¦¤Ù¤·¡£¡×");
5243 msg_print("'Now thou shalt pay for annoying me.'");
5246 switch (randint1(4))
5249 (void)activate_ty_curse(FALSE, &count);
5251 reward = "²Ò¡¹¤·¤¤¼ö¤¤¤ò¤«¤±¤é¤ì¤¿¡£";
5257 activate_hi_summon(py, px, FALSE);
5259 reward = "¥â¥ó¥¹¥¿¡¼¤ò¾¤´¤µ¤ì¤¿¡£";
5261 reward = "summoning hostile monsters";
5267 if (!buki_motteruka(INVEN_RARM)) break;
5268 object_desc(o_name, &inventory[INVEN_RARM], TRUE, 0);
5269 (void)curse_weapon(FALSE, INVEN_RARM);
5271 reward = format("%s¤¬Ç˲õ¤µ¤ì¤¿¡£", o_name);
5273 reward = format("destroying %s", o_name);
5278 if (!inventory[INVEN_BODY].k_idx) break;
5279 object_desc(o_name, &inventory[INVEN_BODY], TRUE, 0);
5280 (void)curse_armor();
5282 reward = format("%s¤¬Ç˲õ¤µ¤ì¤¿¡£", o_name);
5284 reward = format("destroying %s", o_name);
5289 for (dummy = 0; dummy < 6; dummy++)
5291 (void)dec_stat(dummy, 10 + randint1(15), TRUE);
5294 reward = "Á´Ç½ÎÏÃͤ¬²¼¤¬¤Ã¤¿¡£";
5296 reward = "decreasing all stats";
5303 msg_format("%s¤ÎÀ¼¤¬¹ì¤ÅϤä¿:",
5305 msg_format("The voice of %s thunders:",
5308 chaos_patrons[p_ptr->chaos_patron]);
5310 msg_print("¡Ö»à¤Ì¤¬¤è¤¤¡¢²¼Ëͤ衪¡×");
5312 msg_print("'Die, mortal!'");
5315 take_hit(DAMAGE_LOSELIFE, p_ptr->lev * 4, wrath_reason, -1);
5316 for (dummy = 0; dummy < 6; dummy++)
5318 (void)dec_stat(dummy, 10 + randint1(15), FALSE);
5320 activate_hi_summon(py, px, FALSE);
5321 (void)activate_ty_curse(FALSE, &count);
5322 if (one_in_(2)) (void)curse_weapon(FALSE, INVEN_RARM);
5323 if (one_in_(2)) (void)curse_armor();
5327 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5328 chaos_patrons[p_ptr->chaos_patron]);
5330 msg_format("The voice of %s booms out:",
5331 chaos_patrons[p_ptr->chaos_patron]);
5335 msg_print("¡Ö»à¤ÈÇ˲õ¤³¤½²æ¤¬´î¤Ó¤Ê¤ê¡ª¡×");
5337 msg_print("'Death and destruction! This pleaseth me!'");
5340 destroy_area(py, px, 25);
5342 reward = "¥À¥ó¥¸¥ç¥ó¤¬*Ç˲õ*¤µ¤ì¤¿¡£";
5344 reward = "*destruct*ing dungeon";
5349 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5350 chaos_patrons[p_ptr->chaos_patron]);
5352 msg_format("The voice of %s booms out:",
5353 chaos_patrons[p_ptr->chaos_patron]);
5357 msg_print("¡Ö²æ¡¢Æò¤ÎŨ¤òËõ»¦¤»¤ó¡ª¡×");
5359 msg_print("'Let me relieve thee of thine oppressors!'");
5362 (void)symbol_genocide(0, FALSE);
5364 reward = "¥â¥ó¥¹¥¿¡¼¤¬Ëõ»¦¤µ¤ì¤¿¡£";
5366 reward = "genociding monsters";
5371 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5372 chaos_patrons[p_ptr->chaos_patron]);
5374 msg_format("The voice of %s booms out:",
5375 chaos_patrons[p_ptr->chaos_patron]);
5379 msg_print("¡Ö²æ¡¢Æò¤ÎŨ¤òËõ»¦¤»¤ó¡ª¡×");
5381 msg_print("'Let me relieve thee of thine oppressors!'");
5384 (void)mass_genocide(0, FALSE);
5386 reward = "¥â¥ó¥¹¥¿¡¼¤¬Ëõ»¦¤µ¤ì¤¿¡£";
5388 reward = "genociding nearby monsters";
5393 msg_format("%s¤ÎÎϤ¬Å¨¤ò¹¶·â¤¹¤ë¤Î¤ò´¶¤¸¤¿¡ª",
5394 chaos_patrons[p_ptr->chaos_patron]);
5396 msg_format("You can feel the power of %s assault your enemies!",
5397 chaos_patrons[p_ptr->chaos_patron]);
5400 (void)dispel_monsters(p_ptr->lev * 4);
5404 msg_format("%s¤Ï¤¢¤Ê¤¿¤ò̵»ë¤·¤¿¡£",
5405 chaos_patrons[p_ptr->chaos_patron]);
5407 msg_format("%s ignores you.",
5408 chaos_patrons[p_ptr->chaos_patron]);
5414 msg_format("%s¤ÏË«Èþ¤È¤·¤Æ°Ëâ¤Î»È¤¤¤ò¤è¤³¤·¤¿¡ª",chaos_patrons[p_ptr->chaos_patron]);
5416 msg_format("%s rewards you with a demonic servant!",chaos_patrons[p_ptr->chaos_patron]);
5419 if (!summon_specific(-1, py, px, dun_level, SUMMON_DEMON, PM_FORCE_PET))
5421 msg_print("²¿¤â¸½¤ì¤Ê¤«¤Ã¤¿...");
5423 msg_print("Nobody ever turns up...");
5427 reward = "°Ë⤬¥Ú¥Ã¥È¤Ë¤Ê¤Ã¤¿¡£";
5429 reward = "a demonic servant";
5435 msg_format("%s¤ÏË«Èþ¤È¤·¤Æ»È¤¤¤ò¤è¤³¤·¤¿¡ª",chaos_patrons[p_ptr->chaos_patron]);
5437 msg_format("%s rewards you with a servant!",chaos_patrons[p_ptr->chaos_patron]);
5440 if (!summon_specific(-1, py, px, dun_level, 0, PM_FORCE_PET))
5442 msg_print("²¿¤â¸½¤ì¤Ê¤«¤Ã¤¿...");
5444 msg_print("Nobody ever turns up...");
5448 reward = "¥â¥ó¥¹¥¿¡¼¤¬¥Ú¥Ã¥È¤Ë¤Ê¤Ã¤¿¡£";
5450 reward = "a servant";
5456 msg_format("%s¤ÏË«Èþ¤È¤·¤Æ¥¢¥ó¥Ç¥Ã¥É¤Î»È¤¤¤ò¤è¤³¤·¤¿¡£",chaos_patrons[p_ptr->chaos_patron]);
5458 msg_format("%s rewards you with an undead servant!",chaos_patrons[p_ptr->chaos_patron]);
5461 if (!summon_specific(-1, py, px, dun_level, SUMMON_UNDEAD, PM_FORCE_PET))
5463 msg_print("²¿¤â¸½¤ì¤Ê¤«¤Ã¤¿...");
5465 msg_print("Nobody ever turns up...");
5469 reward = "¥¢¥ó¥Ç¥Ã¥É¤¬¥Ú¥Ã¥È¤Ë¤Ê¤Ã¤¿¡£";
5471 reward = "an undead servant";
5477 msg_format("%s¤ÎÀ¼¤¬¤É¤â¤Ã¤¿:",
5479 msg_format("The voice of %s stammers:",
5482 chaos_patrons[p_ptr->chaos_patron]);
5484 msg_format("¡Ö¤¢¡¼¡¢¤¢¡¼¡¢Åú¤¨¤Ï %d/%d¡£¼ÁÌä¤Ï²¿¡©¡×", type, effect);
5486 msg_format("'Uh... uh... the answer's %d/%d, what's the question?'", type, effect);
5494 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, format("¥Ñ¥È¥í¥ó¤ÎÊó½·¤Ç%s", reward));
5496 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, format("The patron rewards you with %s.", reward));
5503 * old -- from PsiAngband.
5505 bool tgt_pt(int *x_ptr, int *y_ptr)
5509 bool success = FALSE;
5514 get_screen_size(&wid, &hgt);
5520 msg_print("¾ì½ê¤òÁª¤ó¤Ç¥¹¥Ú¡¼¥¹¥¡¼¤ò²¡¤·¤Æ²¼¤µ¤¤¡£");
5522 msg_print("Select a point and press space.");
5524 msg_flag = FALSE; /* prevents "-more-" message. */
5526 while ((ch != ESCAPE) && !success)
5528 bool move_fast = FALSE;
5530 move_cursor_relative(y, x);
5542 if (x == px && y == py) ch = 0;
5545 else success = TRUE;
5549 /* Look up the direction */
5550 d = get_keymap_dir(ch);
5552 /* XTRA HACK MOVEFAST */
5553 if (isupper(ch)) move_fast = TRUE;
5555 /* Handle "direction" */
5561 /* XTRA HACK MOVEFAST */
5564 int mag = MIN(wid / 2, hgt / 2);
5574 /* Do not move horizontally if unnecessary */
5575 if (((x < panel_col_min + wid / 2) && (dx > 0)) ||
5576 ((x > panel_col_min + wid / 2) && (dx < 0)))
5581 /* Do not move vertically if unnecessary */
5582 if (((y < panel_row_min + hgt / 2) && (dy > 0)) ||
5583 ((y > panel_row_min + hgt / 2) && (dy < 0)))
5588 /* Apply the motion */
5589 if ((y >= panel_row_min + hgt) || (y < panel_row_min) ||
5590 (x >= panel_col_min + wid) || (x < panel_col_min))
5592 /* if (change_panel(dy, dx)) target_set_prepare(mode); */
5593 change_panel(dy, dx);
5596 /* Slide into legality */
5597 if (x >= cur_wid-1) x = cur_wid - 2;
5598 else if (x <= 0) x = 1;
5600 /* Slide into legality */
5601 if (y >= cur_hgt-1) y = cur_hgt- 2;
5602 else if (y <= 0) y = 1;
5609 /* Clear the top line */
5612 /* Recenter the map around the player */
5616 p_ptr->update |= (PU_MONSTERS);
5619 p_ptr->redraw |= (PR_MAP);
5622 p_ptr->window |= (PW_OVERHEAD);
5633 bool get_hack_dir(int *dp)
5643 /* Global direction */
5646 /* (No auto-targeting) */
5648 /* Ask until satisfied */
5651 /* Choose a prompt */
5655 p = "Êý¸þ ('*'¤Ç¥¿¡¼¥²¥Ã¥ÈÁªÂò, ESC¤ÇÃæÃÇ)? ";
5657 p = "Direction ('*' to choose a target, Escape to cancel)? ";
5664 p = "Êý¸þ ('5'¤Ç¥¿¡¼¥²¥Ã¥È¤Ø, '*'¤Ç¥¿¡¼¥²¥Ã¥ÈºÆÁªÂò, ESC¤ÇÃæÃÇ)? ";
5666 p = "Direction ('5' for target, '*' to re-target, Escape to cancel)? ";
5671 /* Get a command (or Cancel) */
5672 if (!get_com(p, &command, TRUE)) break;
5676 if (command == '\r') command = 't';
5679 /* Convert various keys to "standard" keys */
5682 /* Use current target */
5693 /* Set new target */
5698 if (target_set(TARGET_KILL)) dir = 5;
5704 /* Look up the direction */
5705 dir = get_keymap_dir(command);
5711 /* Verify requested targets */
5712 if ((dir == 5) && !target_okay()) dir = 0;
5719 if (!dir) return (FALSE);
5721 /* Save the direction */
5724 /* Check for confusion */
5725 if (p_ptr->confused)
5728 /* Random direction */
5729 dir = ddd[randint0(8)];
5732 /* Notice confusion */
5733 if (command_dir != dir)
5737 msg_print("¤¢¤Ê¤¿¤Ïº®Í𤷤Ƥ¤¤ë¡£");
5739 msg_print("You are confused.");
5744 /* Save direction */
5747 /* A "valid" direction was entered */
5753 * ¥¨¥Í¥ë¥®¡¼¤ÎÁý²ÃÎÌ10d5¤ò®¤¯·×»»¤¹¤ë¤¿¤á¤Î´Ø¿ô
5756 #define Go_no_JuuJou 5*5*5*5*5*5*5*5*5*5
5758 s16b gain_energy(void)
5761 s32b energy_result = 10;
5764 tmp = randint0(Go_no_JuuJou);
5766 for (i = 0; i < 9; i ++){
5767 energy_result += tmp % 5;
5771 return (s16b)(energy_result + tmp);
5778 s16b bow_energy(int sval)
5782 /* Analyze the launcher */
5785 /* Sling and ammo */
5792 /* Short Bow and Arrow */
5799 /* Long Bow and Arrow */
5806 /* Bow of irresponsiblity and Arrow */
5813 /* Light Crossbow and Bolt */
5820 /* Heavy Crossbow and Bolt */
5835 int bow_tmul(int sval)
5839 /* Analyze the launcher */
5842 /* Sling and ammo */
5849 /* Short Bow and Arrow */
5856 /* Long Bow and Arrow */
5863 /* Bow of irresponsiblity and Arrow */
5870 /* Light Crossbow and Bolt */
5877 /* Heavy Crossbow and Bolt */
5889 * Return alignment title
5891 cptr your_alignment(void)
5894 if (p_ptr->align > 150) return "ÂçÁ±";
5895 else if (p_ptr->align > 50) return "ÃæÁ±";
5896 else if (p_ptr->align > 10) return "¾®Á±";
5897 else if (p_ptr->align > -11) return "ÃæΩ";
5898 else if (p_ptr->align > -51) return "¾®°";
5899 else if (p_ptr->align > -151) return "Ãæ°";
5902 if (p_ptr->align > 150) return "Lawful";
5903 else if (p_ptr->align > 50) return "Good";
5904 else if (p_ptr->align > 10) return "Neutral Good";
5905 else if (p_ptr->align > -11) return "Neutral";
5906 else if (p_ptr->align > -51) return "Neutral Evil";
5907 else if (p_ptr->align > -151) return "Evil";
5908 else return "Chaotic";
5914 * Return proficiency level of weapons and misc. skills (except riding)
5916 int weapon_exp_level(int weapon_exp)
5918 if (weapon_exp < WEAPON_EXP_BEGINNER) return EXP_LEVEL_UNSKILLED;
5919 else if (weapon_exp < WEAPON_EXP_SKILLED) return EXP_LEVEL_BEGINNER;
5920 else if (weapon_exp < WEAPON_EXP_EXPERT) return EXP_LEVEL_SKILLED;
5921 else if (weapon_exp < WEAPON_EXP_MASTER) return EXP_LEVEL_EXPERT;
5922 else return EXP_LEVEL_MASTER;
5927 * Return proficiency level of riding
5929 int riding_exp_level(int riding_exp)
5931 if (riding_exp < RIDING_EXP_BEGINNER) return EXP_LEVEL_UNSKILLED;
5932 else if (riding_exp < RIDING_EXP_SKILLED) return EXP_LEVEL_BEGINNER;
5933 else if (riding_exp < RIDING_EXP_EXPERT) return EXP_LEVEL_SKILLED;
5934 else if (riding_exp < RIDING_EXP_MASTER) return EXP_LEVEL_EXPERT;
5935 else return EXP_LEVEL_MASTER;
5940 * Return proficiency level of spells
5942 int spell_exp_level(int spell_exp)
5944 if (spell_exp < SPELL_EXP_BEGINNER) return EXP_LEVEL_UNSKILLED;
5945 else if (spell_exp < SPELL_EXP_SKILLED) return EXP_LEVEL_BEGINNER;
5946 else if (spell_exp < SPELL_EXP_EXPERT) return EXP_LEVEL_SKILLED;
5947 else if (spell_exp < SPELL_EXP_MASTER) return EXP_LEVEL_EXPERT;
5948 else return EXP_LEVEL_MASTER;