4 * Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke
6 * This software may be copied and distributed for educational, research,
7 * and not for profit purposes provided that this copyright and statement
8 * are included in all such copies. Other copyrights may also apply.
11 /* Purpose: effects of various "objects" */
15 #define REWARD_CHANCE 10
19 * Advance experience levels and print experience
21 void check_experience(void)
23 bool level_reward = FALSE;
24 bool level_mutation = FALSE;
25 bool level_inc_stat = FALSE;
26 bool android = (p_ptr->prace == RACE_ANDROID ? TRUE : FALSE);
29 /* Hack -- lower limit */
30 if (p_ptr->exp < 0) p_ptr->exp = 0;
31 if (p_ptr->max_exp < 0) p_ptr->max_exp = 0;
32 if (p_ptr->max_max_exp < 0) p_ptr->max_max_exp = 0;
34 /* Hack -- upper limit */
35 if (p_ptr->exp > PY_MAX_EXP) p_ptr->exp = PY_MAX_EXP;
36 if (p_ptr->max_exp > PY_MAX_EXP) p_ptr->max_exp = PY_MAX_EXP;
37 if (p_ptr->max_max_exp > PY_MAX_EXP) p_ptr->max_max_exp = PY_MAX_EXP;
39 /* Hack -- maintain "max" experience */
40 if (p_ptr->exp > p_ptr->max_exp) p_ptr->max_exp = p_ptr->exp;
42 /* Hack -- maintain "max max" experience */
43 if (p_ptr->max_exp > p_ptr->max_max_exp) p_ptr->max_max_exp = p_ptr->max_exp;
45 /* Redraw experience */
46 p_ptr->redraw |= (PR_EXP);
52 /* Lose levels while possible */
53 while ((p_ptr->lev > 1) &&
54 (p_ptr->exp < ((android ? player_exp_a : player_exp)[p_ptr->lev - 2] * p_ptr->expfact / 100L)))
59 /* Update some stuff */
60 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
62 /* Redraw some stuff */
63 p_ptr->redraw |= (PR_LEV | PR_TITLE);
66 p_ptr->window |= (PW_PLAYER);
73 /* Gain levels while possible */
74 while ((p_ptr->lev < PY_MAX_LEVEL) &&
75 (p_ptr->exp >= ((android ? player_exp_a : player_exp)[p_ptr->lev-1] * p_ptr->expfact / 100L)))
80 /* Save the highest level */
81 if (p_ptr->lev > p_ptr->max_plv)
83 p_ptr->max_plv = p_ptr->lev;
85 if ((p_ptr->pclass == CLASS_CHAOS_WARRIOR) ||
86 (p_ptr->muta2 & MUT2_CHAOS_GIFT))
90 if (p_ptr->prace == RACE_BEASTMAN)
92 if (one_in_(5)) level_mutation = TRUE;
94 level_inc_stat = TRUE;
96 do_cmd_write_nikki(NIKKI_LEVELUP, p_ptr->lev, NULL);
104 msg_format("¥ì¥Ù¥ë %d ¤Ë¤è¤¦¤³¤½¡£", p_ptr->lev);
106 msg_format("Welcome to level %d.", p_ptr->lev);
109 /* Update some stuff */
110 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
112 /* Redraw some stuff */
113 p_ptr->redraw |= (PR_LEV | PR_TITLE);
116 p_ptr->window |= (PW_PLAYER | PW_SPELL);
118 /* HP¤ÈMP¤Î¾å¾ºÎ̤òɽ¼¨ */
128 if(!(p_ptr->max_plv % 10))
138 cnv_stat(p_ptr->stat_max[0], tmp);
139 prt(format(" a) ÏÓÎÏ (¸½ºßÃÍ %s)", tmp), 2, 14);
140 cnv_stat(p_ptr->stat_max[1], tmp);
141 prt(format(" b) ÃÎǽ (¸½ºßÃÍ %s)", tmp), 3, 14);
142 cnv_stat(p_ptr->stat_max[2], tmp);
143 prt(format(" c) ¸¤µ (¸½ºßÃÍ %s)", tmp), 4, 14);
144 cnv_stat(p_ptr->stat_max[3], tmp);
145 prt(format(" d) ´ïÍÑ (¸½ºßÃÍ %s)", tmp), 5, 14);
146 cnv_stat(p_ptr->stat_max[4], tmp);
147 prt(format(" e) ÂÑµ× (¸½ºßÃÍ %s)", tmp), 6, 14);
148 cnv_stat(p_ptr->stat_max[5], tmp);
149 prt(format(" f) Ì¥ÎÏ (¸½ºßÃÍ %s)", tmp), 7, 14);
151 prt(" ¤É¤ÎǽÎÏÃͤò¾å¤²¤Þ¤¹¤«¡©", 1, 14);
153 cnv_stat(p_ptr->stat_max[0], tmp);
154 prt(format(" a) Str (cur %s)", tmp), 2, 14);
155 cnv_stat(p_ptr->stat_max[1], tmp);
156 prt(format(" b) Int (cur %s)", tmp), 3, 14);
157 cnv_stat(p_ptr->stat_max[2], tmp);
158 prt(format(" c) Wis (cur %s)", tmp), 4, 14);
159 cnv_stat(p_ptr->stat_max[3], tmp);
160 prt(format(" d) Dex (cur %s)", tmp), 5, 14);
161 cnv_stat(p_ptr->stat_max[4], tmp);
162 prt(format(" e) Con (cur %s)", tmp), 6, 14);
163 cnv_stat(p_ptr->stat_max[5], tmp);
164 prt(format(" f) Chr (cur %s)", tmp), 7, 14);
166 prt(" Which stat do you want to raise?", 1, 14);
171 if ((choice >= 'a') && (choice <= 'f')) break;
173 for(n = 0; n < 6; n++)
174 if (n != choice - 'a')
177 if (get_check("¤è¤í¤·¤¤¤Ç¤¹¤«¡©")) break;
179 if (get_check("Are you sure? ")) break;
182 do_inc_stat(choice - 'a');
185 else if(!(p_ptr->max_plv % 2))
186 do_inc_stat(randint0(6));
192 msg_print("¤¢¤Ê¤¿¤ÏÊѤï¤Ã¤¿µ¤¤¬¤¹¤ë...");
194 msg_print("You feel different...");
197 (void)gain_random_mutation(0);
198 level_mutation = FALSE;
202 * Ê󽷤ǥì¥Ù¥ë¤¬¾å¤ë¤ÈºÆµ¢Åª¤Ë check_experience() ¤¬
203 * ¸Æ¤Ð¤ì¤ë¤Î¤Ç½çÈÖ¤òºÇ¸å¤Ë¤¹¤ë¡£
207 gain_level_reward(0);
208 level_reward = FALSE;
211 /* Update some stuff */
212 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
214 /* Redraw some stuff */
215 p_ptr->redraw |= (PR_LEV | PR_TITLE);
218 p_ptr->window |= (PW_PLAYER | PW_SPELL);
227 * Hack -- Return the "automatic coin type" of a monster race
228 * Used to allocate proper treasure when "Creeping coins" die
230 * XXX XXX XXX Note the use of actual "monster names"
232 static int get_coin_type(int r_idx)
234 /* Analyze monsters */
237 case MON_COPPER_COINS: return 2;
238 case MON_SILVER_COINS: return 5;
239 case MON_GOLD_COINS: return 10;
240 case MON_MITHRIL_COINS:
241 case MON_MITHRIL_GOLEM: return 16;
242 case MON_ADAMANT_COINS: return 17;
251 * Hack -- determine if a template is Cloak
253 static bool kind_is_cloak(int k_idx)
255 object_kind *k_ptr = &k_info[k_idx];
257 /* Analyze the item type */
258 if (k_ptr->tval == TV_CLOAK)
263 /* Assume not good */
269 * Hack -- determine if a template is Polearm
271 static bool kind_is_polearm(int k_idx)
273 object_kind *k_ptr = &k_info[k_idx];
275 /* Analyze the item type */
276 if (k_ptr->tval == TV_POLEARM)
281 /* Assume not good */
287 * Hack -- determine if a template is Sword
289 static bool kind_is_sword(int k_idx)
291 object_kind *k_ptr = &k_info[k_idx];
293 /* Analyze the item type */
294 if ((k_ptr->tval == TV_SWORD) && (k_ptr->sval > 2))
299 /* Assume not good */
305 * Hack -- determine if a template is Book
307 static bool kind_is_book(int k_idx)
309 object_kind *k_ptr = &k_info[k_idx];
311 /* Analyze the item type */
312 if ((k_ptr->tval >= TV_LIFE_BOOK) && (k_ptr->tval <= TV_CRUSADE_BOOK))
317 /* Assume not good */
323 * Hack -- determine if a template is Good book
325 static bool kind_is_good_book(int k_idx)
327 object_kind *k_ptr = &k_info[k_idx];
329 /* Analyze the item type */
330 if ((k_ptr->tval >= TV_LIFE_BOOK) && (k_ptr->tval <= TV_CRUSADE_BOOK) && (k_ptr->tval != TV_ARCANE_BOOK) && (k_ptr->sval > 1))
335 /* Assume not good */
341 * Hack -- determine if a template is Armor
343 static bool kind_is_armor(int k_idx)
345 object_kind *k_ptr = &k_info[k_idx];
347 /* Analyze the item type */
348 if (k_ptr->tval == TV_HARD_ARMOR)
353 /* Assume not good */
359 * Check for "Quest" completion when a quest monster is killed or charmed.
361 void check_quest_completion(monster_type *m_ptr)
363 int i, j, y, x, ny, nx, i2, j2;
367 bool create_stairs = FALSE;
373 /* Get the location */
378 quest_num = p_ptr->inside_quest;
380 /* Search for an active quest on this dungeon level */
383 for (i = max_quests - 1; i > 0; i--)
385 /* Quest is not active */
386 if (quest[i].status != QUEST_STATUS_TAKEN)
389 /* Quest is not a dungeon quest */
390 if (quest[i].flags & QUEST_FLAG_PRESET)
393 /* Quest is not on this level */
394 if ((quest[i].level != dun_level) &&
395 (quest[i].type != QUEST_TYPE_KILL_ANY_LEVEL))
398 /* Not a "kill monster" quest */
399 if ((quest[i].type == QUEST_TYPE_FIND_ARTIFACT) ||
400 (quest[i].type == QUEST_TYPE_FIND_EXIT))
403 /* Interesting quest */
404 if ((quest[i].type == QUEST_TYPE_KILL_NUMBER) ||
405 (quest[i].type == QUEST_TYPE_KILL_ALL))
408 /* Interesting quest */
409 if (((quest[i].type == QUEST_TYPE_KILL_LEVEL) ||
410 (quest[i].type == QUEST_TYPE_KILL_ANY_LEVEL) ||
411 (quest[i].type == QUEST_TYPE_RANDOM)) &&
412 (quest[i].r_idx == m_ptr->r_idx))
419 /* Handle the current quest */
420 if (quest_num && (quest[quest_num].status == QUEST_STATUS_TAKEN))
425 switch (quest[i].type)
427 case QUEST_TYPE_KILL_NUMBER:
431 if (quest[i].cur_num >= quest[i].num_mon)
433 if (record_fix_quest) do_cmd_write_nikki(NIKKI_FIX_QUEST_C, i, NULL);
434 /* completed quest */
435 quest[i].status = QUEST_STATUS_COMPLETED;
436 quest[i].complev = (byte)p_ptr->lev;
438 if (!(quest[i].flags & QUEST_FLAG_SILENT))
441 msg_print("¥¯¥¨¥¹¥È¤òãÀ®¤·¤¿¡ª");
443 msg_print("You just completed your quest!");
449 quest[i].cur_num = 0;
453 case QUEST_TYPE_KILL_ALL:
457 if (!is_hostile(m_ptr)) break;
459 /* Count all hostile monsters */
460 for (i2 = 0; i2 < cur_wid; ++i2)
461 for (j2 = 0; j2 < cur_hgt; j2++)
462 if (cave[j2][i2].m_idx > 0)
463 if (is_hostile(&m_list[cave[j2][i2].m_idx]))
466 if ((number_mon - 1) == 0)
468 if (record_fix_quest) do_cmd_write_nikki(NIKKI_FIX_QUEST_C, i, NULL);
470 if (quest[i].flags & QUEST_FLAG_SILENT)
472 quest[i].status = QUEST_STATUS_FINISHED;
476 quest[i].status = QUEST_STATUS_COMPLETED;
477 quest[i].complev = (byte)p_ptr->lev;
479 msg_print("¥¯¥¨¥¹¥È¤òãÀ®¤·¤¿¡ª");
481 msg_print("You just completed your quest!");
489 case QUEST_TYPE_KILL_LEVEL:
490 case QUEST_TYPE_RANDOM:
492 /* Only count valid monsters */
493 if (quest[i].r_idx != m_ptr->r_idx)
498 if (quest[i].cur_num >= quest[i].max_num)
500 if (record_fix_quest && (quest[i].type == QUEST_TYPE_KILL_LEVEL)) do_cmd_write_nikki(NIKKI_FIX_QUEST_C, i, NULL);
501 if (record_rand_quest && (quest[i].type == QUEST_TYPE_RANDOM)) do_cmd_write_nikki(NIKKI_RAND_QUEST_C, i, NULL);
502 /* completed quest */
503 quest[i].status = QUEST_STATUS_COMPLETED;
504 quest[i].complev = (byte)p_ptr->lev;
505 if (!(quest[i].flags & QUEST_FLAG_PRESET))
507 create_stairs = TRUE;
508 p_ptr->inside_quest = 0;
511 if (!(quest[i].flags & QUEST_FLAG_SILENT))
514 msg_print("¥¯¥¨¥¹¥È¤òãÀ®¤·¤¿¡ª");
516 msg_print("You just completed your quest!");
522 /* Finish the two main quests without rewarding */
523 if ((i == QUEST_OBERON) || (i == QUEST_SERPENT))
525 quest[i].status = QUEST_STATUS_FINISHED;
528 if (quest[i].type == QUEST_TYPE_RANDOM)
531 quest[i].status = QUEST_STATUS_FINISHED;
536 case QUEST_TYPE_KILL_ANY_LEVEL:
539 if (quest[i].cur_num >= quest[i].max_num)
541 if (record_fix_quest) do_cmd_write_nikki(NIKKI_FIX_QUEST_C, i, NULL);
542 /* completed quest */
543 quest[i].status = QUEST_STATUS_COMPLETED;
544 quest[i].complev = (byte)p_ptr->lev;
546 if (!(quest[i].flags & QUEST_FLAG_SILENT))
549 msg_print("¥¯¥¨¥¹¥È¤òãÀ®¤·¤¿¡ª");
551 msg_print("You just completed your quest!");
556 quest[i].cur_num = 0;
563 /* Create a magical staircase */
567 while (cave_perma_bold(y, x) || cave[y][x].o_idx || (cave[y][x].info & CAVE_OBJECT) )
569 /* Pick a location */
570 scatter(&ny, &nx, y, x, 1, 0);
576 /* Explain the staircase */
578 msg_print("ËâË¡¤Î³¬Ãʤ¬¸½¤ì¤¿...");
580 msg_print("A magical staircase appears...");
584 /* Create stairs down */
585 cave_set_feat(y, x, FEAT_MORE);
587 /* Remember to update everything */
588 p_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MONSTERS | PU_MON_LITE);
596 for (j = 0; j < (dun_level / 15)+1; j++)
598 /* Get local object */
601 /* Wipe the object */
604 /* Make a great object */
605 make_object(q_ptr, AM_GOOD | AM_GREAT);
607 /* Drop it in the dungeon */
608 (void)drop_near(q_ptr, -1, y, x);
615 * Return monster death string
617 cptr extract_note_dies(monster_race *r_ptr)
619 /* Some monsters get "destroyed" */
620 if (!monster_living(r_ptr))
624 for (i = 0; i < 4; i++)
626 if (r_ptr->blow[i].method == RBM_EXPLODE)
629 return "¤ÏÇúȯ¤·¤ÆÊ´¡¹¤Ë¤Ê¤Ã¤¿¡£";
631 return " explodes into tiny shreds.";
639 return " is destroyed.";
643 /* Assume a default death */
653 * Handle the "death" of a monster.
655 * Disperse treasures centered at the monster location based on the
656 * various flags contained in the monster flags fields.
658 * Check for "Quest" completion when a quest monster is killed.
660 * Note that only the player can induce "monster_death()" on Uniques.
661 * Thus (for now) all Quest monsters should be Uniques.
663 * Note that monsters can now carry objects, and when a monster dies,
664 * it drops all of its objects, which may disappear in crowded rooms.
666 void monster_death(int m_idx, bool drop_item)
675 monster_type *m_ptr = &m_list[m_idx];
677 monster_race *r_ptr = &r_info[m_ptr->r_idx];
679 bool visible = (m_ptr->ml || (r_ptr->flags1 & RF1_UNIQUE));
683 bool do_gold = (!(r_ptr->flags1 & RF1_ONLY_ITEM));
684 bool do_item = (!(r_ptr->flags1 & RF1_ONLY_GOLD));
685 bool cloned = (m_ptr->smart & SM_CLONED) ? TRUE : FALSE;
686 int force_coin = get_coin_type(m_ptr->r_idx);
691 bool drop_chosen_item = drop_item && !cloned && !p_ptr->inside_arena
692 && !p_ptr->inside_battle && !is_pet(m_ptr);
695 if (world_monster) world_monster = FALSE;
697 /* Notice changes in view */
698 if (r_ptr->flags7 & (RF7_LITE_MASK | RF7_DARK_MASK))
700 /* Update some things */
701 p_ptr->update |= (PU_MON_LITE);
704 /* Get the location */
708 if (record_named_pet && is_pet(m_ptr) && m_ptr->nickname)
712 monster_desc(m_name, m_ptr, MD_INDEF_VISIBLE);
713 do_cmd_write_nikki(NIKKI_NAMED_PET, 3, m_name);
716 /* Let monsters explode! */
717 for (i = 0; i < 4; i++)
719 if (r_ptr->blow[i].method == RBM_EXPLODE)
721 int flg = PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL;
722 int typ = mbe_info[r_ptr->blow[i].effect].explode_type;
723 int d_dice = r_ptr->blow[i].d_dice;
724 int d_side = r_ptr->blow[i].d_side;
725 int damage = damroll(d_dice, d_side);
727 project(m_idx, 3, y, x, damage, typ, flg, -1);
732 if (m_ptr->mflag2 & MFLAG2_CHAMELEON)
734 choose_new_monster(m_idx, TRUE, MON_CHAMELEON);
735 r_ptr = &r_info[m_ptr->r_idx];
738 /* Check for quest completion */
739 check_quest_completion(m_ptr);
741 /* Handle the possibility of player vanquishing arena combatant -KMW- */
742 if (p_ptr->inside_arena && !is_pet(m_ptr))
744 p_ptr->exit_bldg = TRUE;
746 if (p_ptr->arena_number > MAX_ARENA_MONS)
749 msg_print("ÁÇÀ²¤é¤·¤¤¡ª·¯¤³¤½¿¿¤Î¾¡Íø¼Ô¤À¡£");
751 msg_print("You are a Genuine Champion!");
757 msg_print("¾¡Íø¡ª¥Á¥ã¥ó¥Ô¥ª¥ó¤Ø¤ÎÆ»¤ò¿Ê¤ó¤Ç¤¤¤ë¡£");
759 msg_print("Victorious! You're on your way to becoming Champion.");
763 if (arena_info[p_ptr->arena_number].tval)
765 /* Get local object */
768 /* Prepare to make a prize */
769 object_prep(q_ptr, lookup_kind(arena_info[p_ptr->arena_number].tval, arena_info[p_ptr->arena_number].sval));
771 apply_magic(q_ptr, object_level, AM_NO_FIXED_ART);
773 /* Drop it in the dungeon */
774 (void)drop_near(q_ptr, -1, y, x);
777 if (p_ptr->arena_number > MAX_ARENA_MONS) p_ptr->arena_number++;
778 p_ptr->arena_number++;
783 /* Extract monster name */
784 monster_desc(m_name, m_ptr, MD_IGNORE_HALLU | MD_ASSUME_VISIBLE | MD_INDEF_VISIBLE);
786 do_cmd_write_nikki(NIKKI_ARENA, p_ptr->arena_number, m_name);
790 if (m_idx == p_ptr->riding)
792 if (rakuba(-1, FALSE))
795 msg_print("ÃÏÌ̤ËÍî¤È¤µ¤ì¤¿¡£");
797 msg_print("You have fallen from your riding pet.");
802 /* Drop a dead corpse? */
803 if (one_in_(r_ptr->flags1 & RF1_UNIQUE ? 1 : 4) &&
804 ((r_ptr->flags9 & RF9_DROP_CORPSE) ||
805 (r_ptr->flags9 & RF9_DROP_SKELETON)) &&
806 !(p_ptr->inside_arena || p_ptr->inside_battle || cloned || ((m_ptr->r_idx == today_mon) && is_pet(m_ptr))))
808 /* Assume skeleton */
812 * We cannot drop a skeleton? Note, if we are in this check,
813 * we *know* we can drop at least a corpse or a skeleton
815 if (!(r_ptr->flags9 & RF9_DROP_SKELETON))
817 else if ((r_ptr->flags9 & RF9_DROP_CORPSE) && (r_ptr->flags1 && RF1_UNIQUE))
820 /* Else, a corpse is more likely unless we did a "lot" of damage */
821 else if (r_ptr->flags9 & RF9_DROP_CORPSE)
823 /* Lots of damage in one blow */
824 if ((0 - ((m_ptr->maxhp) / 4)) > m_ptr->hp)
826 if (one_in_(5)) corpse = TRUE;
830 if (!one_in_(5)) corpse = TRUE;
834 /* Get local object */
837 /* Prepare to make an object */
838 object_prep(q_ptr, lookup_kind(TV_CORPSE, (corpse ? SV_CORPSE : SV_SKELETON)));
840 apply_magic(q_ptr, object_level, AM_NO_FIXED_ART);
842 q_ptr->pval = m_ptr->r_idx;
844 /* Drop it in the dungeon */
845 (void)drop_near(q_ptr, -1, y, x);
848 /* Drop objects being carried */
849 monster_drop_carried_objects(m_ptr);
851 if (r_ptr->flags1 & RF1_DROP_GOOD) mo_mode |= AM_GOOD;
852 if (r_ptr->flags1 & RF1_DROP_GREAT) mo_mode |= AM_GREAT;
854 switch (m_ptr->r_idx)
856 case MON_PINK_HORROR:
857 /* Pink horrors are replaced with 2 Blue horrors */
858 if (!(p_ptr->inside_arena || p_ptr->inside_battle))
862 for (i = 0; i < 2; i++)
865 bool pet = is_pet(m_ptr);
868 if (pet) mode |= PM_FORCE_PET;
870 if (summon_specific((pet ? -1 : m_idx), wy, wx, 100, SUMMON_BLUE_HORROR, mode))
872 if (player_can_see_bold(wy, wx))
879 msg_print("¥Ô¥ó¥¯¡¦¥Û¥é¡¼¤ÏʬÎö¤·¤¿¡ª");
881 msg_print("The Pink horror divides!");
886 case MON_BLOODLETTER:
887 /* Bloodletters of Khorne may drop a blade of chaos */
888 if (drop_chosen_item && (randint1(100) < 15))
890 /* Get local object */
893 /* Prepare to make a Blade of Chaos */
894 object_prep(q_ptr, lookup_kind(TV_SWORD, SV_BLADE_OF_CHAOS));
896 apply_magic(q_ptr, object_level, AM_NO_FIXED_ART | mo_mode);
898 /* Drop it in the dungeon */
899 (void)drop_near(q_ptr, -1, y, x);
904 if (drop_chosen_item && (dun_level > 9))
906 /* Get local object */
909 /* Wipe the object */
912 /* Activate restriction */
913 if ((dun_level > 49) && one_in_(5))
914 get_obj_num_hook = kind_is_good_book;
916 get_obj_num_hook = kind_is_book;
918 /* Prepare allocation table */
922 make_object(q_ptr, mo_mode);
924 /* Drop it in the dungeon */
925 (void)drop_near(q_ptr, -1, y, x);
931 * Mega^3-hack: killing a 'Warrior of the Dawn' is likely to
932 * spawn another in the fallen one's place!
934 if (!p_ptr->inside_arena && !p_ptr->inside_battle)
938 int wy = py, wx = px;
940 bool pet = is_pet(m_ptr);
944 scatter(&wy, &wx, py, px, 20, 0);
946 while (!(in_bounds(wy, wx) && cave_empty_bold2(wy, wx)) && --attempts);
951 if (pet) mode |= PM_FORCE_PET;
953 if (summon_specific((pet ? -1 : m_idx), wy, wx, 100, SUMMON_DAWN, mode))
955 if (player_can_see_bold(wy, wx))
957 msg_print("¿·¤¿¤ÊÀï»Î¤¬¸½¤ì¤¿¡ª");
959 msg_print("A new warrior steps forth!");
969 /* One more ultra-hack: An Unmaker goes out with a big bang! */
971 int flg = PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL;
972 (void)project(m_idx, 6, y, x, 100, GF_CHAOS, flg, -1);
976 case MON_UNICORN_ORD:
979 /* Reward for "lazy" player */
980 if (p_ptr->pseikaku == SEIKAKU_NAMAKE)
984 if (!drop_chosen_item) break;
991 a_idx = ART_NAMAKE_HAMMER;
994 a_idx = ART_NAMAKE_BOW;
997 a_idx = ART_NAMAKE_ARMOR;
1001 while (a_info[a_idx].cur_num);
1003 if (a_info[a_idx].cur_num == 0)
1005 /* Create the artifact */
1006 create_named_art(a_idx, y, x);
1007 a_info[a_idx].cur_num = 1;
1013 if (!drop_chosen_item) break;
1015 /* Get local object */
1018 /* Mega-Hack -- Prepare to make "Grond" */
1019 object_prep(q_ptr, lookup_kind(TV_HAFTED, SV_GROND));
1021 /* Mega-Hack -- Mark this item as "Grond" */
1022 q_ptr->name1 = ART_GROND;
1024 /* Mega-Hack -- Actually create "Grond" */
1025 apply_magic(q_ptr, -1, AM_GOOD | AM_GREAT);
1027 /* Drop it in the dungeon */
1028 (void)drop_near(q_ptr, -1, y, x);
1030 /* Get local object */
1033 /* Mega-Hack -- Prepare to make "Chaos" */
1034 object_prep(q_ptr, lookup_kind(TV_CROWN, SV_CHAOS));
1036 /* Mega-Hack -- Mark this item as "Chaos" */
1037 q_ptr->name1 = ART_CHAOS;
1039 /* Mega-Hack -- Actually create "Chaos" */
1040 apply_magic(q_ptr, -1, AM_GOOD | AM_GREAT);
1042 /* Drop it in the dungeon */
1043 (void)drop_near(q_ptr, -1, y, x);
1046 case MON_B_DEATH_SWORD:
1047 if (drop_chosen_item)
1049 /* Get local object */
1052 /* Prepare to make a broken sword */
1053 object_prep(q_ptr, lookup_kind(TV_SWORD, randint1(2)));
1055 /* Drop it in the dungeon */
1056 (void)drop_near(q_ptr, -1, y, x);
1062 if (drop_chosen_item && ((m_ptr->r_idx == MON_A_GOLD) ||
1063 ((m_ptr->r_idx == MON_A_SILVER) && (r_ptr->r_pkills % 5 == 0))))
1065 /* Get local object */
1068 /* Prepare to make a Can of Toys */
1069 object_prep(q_ptr, lookup_kind(TV_CHEST, SV_CHEST_KANDUME));
1071 apply_magic(q_ptr, object_level, AM_NO_FIXED_ART);
1073 /* Drop it in the dungeon */
1074 (void)drop_near(q_ptr, -1, y, x);
1080 int flg = PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL;
1081 (void)project(m_idx, 3, y, x, damroll(20, 10), GF_FIRE, flg, -1);
1086 if (!drop_chosen_item) break;
1088 switch (r_ptr->d_char)
1093 /* Get local object */
1096 /* Wipe the object */
1099 /* Activate restriction */
1100 get_obj_num_hook = kind_is_cloak;
1102 /* Prepare allocation table */
1106 make_object(q_ptr, mo_mode);
1108 /* Drop it in the dungeon */
1109 (void)drop_near(q_ptr, -1, y, x);
1116 /* Get local object */
1119 /* Wipe the object */
1122 /* Activate restriction */
1123 get_obj_num_hook = kind_is_polearm;
1125 /* Prepare allocation table */
1128 /* Make a poleweapon */
1129 make_object(q_ptr, mo_mode);
1131 /* Drop it in the dungeon */
1132 (void)drop_near(q_ptr, -1, y, x);
1139 /* Get local object */
1142 /* Wipe the object */
1145 /* Activate restriction */
1146 get_obj_num_hook = kind_is_armor;
1148 /* Prepare allocation table */
1151 /* Make a hard armor */
1152 make_object(q_ptr, mo_mode);
1154 /* Drop it in the dungeon */
1155 (void)drop_near(q_ptr, -1, y, x);
1160 if (m_ptr->r_idx != MON_STORMBRINGER)
1162 /* Get local object */
1165 /* Wipe the object */
1168 /* Activate restriction */
1169 get_obj_num_hook = kind_is_sword;
1171 /* Prepare allocation table */
1175 make_object(q_ptr, mo_mode);
1177 /* Drop it in the dungeon */
1178 (void)drop_near(q_ptr, -1, y, x);
1185 /* Mega-Hack -- drop fixed items */
1186 if (drop_chosen_item)
1191 switch (m_ptr->r_idx)
1211 case MON_STORMBRINGER:
1212 a_idx = ART_STORMBRINGER;
1217 a_idx = ART_CRIMSON;
1227 a_idx = ART_KUSANAGI;
1257 a_idx = ART_WEREWINDLE;
1265 a_idx = ART_GRAYSWANDIR;
1276 a_idx = ART_TWILIGHT;
1281 a_idx = ART_ELENDIL;
1296 a_idx = ART_DESTINY;
1301 a_idx = ART_ZANTETSU;
1316 a_idx = ART_WINBLOWS;
1320 case MON_LUNGORTHIN:
1325 case MON_JACK_SHADOWS:
1331 a_idx = ART_STONEMASK;
1336 a_idx = ART_SOULCRUSH;
1341 a_idx = ART_EXCALIBUR_J;
1346 a_idx = ART_SHUTEN_DOJI;
1351 a_idx = ART_GOTHMOG;
1361 if ((a_idx > 0) && ((randint0(100) < chance) || p_ptr->wizard))
1363 if (a_info[a_idx].cur_num == 0)
1365 /* Create the artifact */
1366 create_named_art(a_idx, y, x);
1367 a_info[a_idx].cur_num = 1;
1371 if ((r_ptr->flags7 & RF7_GUARDIAN) && (d_info[dungeon_type].final_guardian == m_ptr->r_idx))
1373 int k_idx = d_info[dungeon_type].final_object ? d_info[dungeon_type].final_object
1374 : lookup_kind(TV_SCROLL, SV_SCROLL_ACQUIREMENT);
1376 if (d_info[dungeon_type].final_artifact)
1378 int a_idx = d_info[dungeon_type].final_artifact;
1379 if (!a_info[a_idx].cur_num)
1381 /* Create the artifact */
1382 create_named_art(a_idx, y, x);
1383 a_info[a_idx].cur_num = 1;
1385 /* Prevent rewarding both artifact and "default" object */
1386 if (!d_info[dungeon_type].final_object) k_idx = 0;
1392 /* Get local object */
1395 /* Prepare to make a reward */
1396 object_prep(q_ptr, k_idx);
1398 apply_magic(q_ptr, object_level, AM_NO_FIXED_ART | AM_GOOD);
1400 /* Drop it in the dungeon */
1401 (void)drop_near(q_ptr, -1, y, x);
1404 msg_format("¤¢¤Ê¤¿¤Ï%s¤òÀ©ÇƤ·¤¿¡ª",d_name+d_info[dungeon_type].name);
1406 msg_format("You have conquered %s!",d_name+d_info[dungeon_type].name);
1411 /* Determine how much we can drop */
1412 if ((r_ptr->flags1 & RF1_DROP_60) && (randint0(100) < 60)) number++;
1413 if ((r_ptr->flags1 & RF1_DROP_90) && (randint0(100) < 90)) number++;
1414 if (r_ptr->flags1 & RF1_DROP_1D2) number += damroll(1, 2);
1415 if (r_ptr->flags1 & RF1_DROP_2D2) number += damroll(2, 2);
1416 if (r_ptr->flags1 & RF1_DROP_3D2) number += damroll(3, 2);
1417 if (r_ptr->flags1 & RF1_DROP_4D2) number += damroll(4, 2);
1419 if (cloned && !(r_ptr->flags1 & RF1_UNIQUE))
1420 number = 0; /* Clones drop no stuff unless Cloning Pits */
1422 if (is_pet(m_ptr) || p_ptr->inside_battle || p_ptr->inside_arena)
1423 number = 0; /* Pets drop no stuff */
1424 if (!drop_item && (r_ptr->d_char != '$')) number = 0;
1426 /* Hack -- handle creeping coins */
1427 coin_type = force_coin;
1429 /* Average dungeon and monster levels */
1430 object_level = (dun_level + r_ptr->level) / 2;
1432 /* Drop some objects */
1433 for (j = 0; j < number; j++)
1435 /* Get local object */
1438 /* Wipe the object */
1442 if (do_gold && (!do_item || (randint0(100) < 50)))
1444 /* Make some gold */
1445 if (!make_gold(q_ptr)) continue;
1454 /* Make an object */
1455 if (!make_object(q_ptr, mo_mode)) continue;
1461 /* Drop it in the dungeon */
1462 (void)drop_near(q_ptr, -1, y, x);
1465 /* Reset the object level */
1466 object_level = base_level;
1468 /* Reset "coin" type */
1472 /* Take note of any dropped treasure */
1473 if (visible && (dump_item || dump_gold))
1475 /* Take notes on treasure */
1476 lore_treasure(m_idx, dump_item, dump_gold);
1479 /* Only process "Quest Monsters" */
1480 if (!(r_ptr->flags1 & RF1_QUESTOR)) return;
1481 if (p_ptr->inside_battle) return;
1484 if ((m_ptr->r_idx == MON_SERPENT) && !cloned)
1487 p_ptr->total_winner = TRUE;
1489 /* Redraw the "title" */
1490 p_ptr->redraw |= (PR_TITLE);
1493 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, "¸«»ö¤ËÊѶòÈÚÅܤξ¡Íø¼Ô¤È¤Ê¤Ã¤¿¡ª");
1495 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, "become *WINNER* of Hengband finely!");
1498 if ((p_ptr->pclass == CLASS_CHAOS_WARRIOR) || (p_ptr->muta2 & MUT2_CHAOS_GIFT))
1501 msg_format("%s¤«¤é¤ÎÀ¼¤¬¶Á¤¤¤¿¡£", chaos_patrons[p_ptr->chaos_patron]);
1502 msg_print("¡Ø¤è¤¯¤ä¤Ã¤¿¡¢ÄêÌ¿¤Î¼Ô¤è¡ª¡Ù");
1504 msg_format("The voice of %s booms out:", chaos_patrons[p_ptr->chaos_patron]);
1505 msg_print("'Thou art donst well, mortal!'");
1509 /* Congratulations */
1511 msg_print("*** ¤ª¤á¤Ç¤È¤¦ ***");
1513 msg_print("*** CONGRATULATIONS ***");
1517 msg_print("¤¢¤Ê¤¿¤Ï¥²¡¼¥à¤ò¥³¥ó¥×¥ê¡¼¥È¤·¤Þ¤·¤¿¡£");
1519 msg_print("You have won the game!");
1523 msg_print("½àÈ÷¤¬À°¤Ã¤¿¤é°úÂà(¼«»¦¥³¥Þ¥ó¥É)¤·¤Æ¤â·ë¹½¤Ç¤¹¡£");
1525 msg_print("You may retire (commit suicide) when you are ready.");
1531 * Modify the physical damage done to the monster.
1532 * (for example when it's invulnerable or shielded)
1534 * ToDo: Accept a damage-type to calculate the modified damage from
1535 * things like fire, frost, lightning, poison, ... attacks.
1537 * "type" is not yet used and should be 0.
1539 int mon_damage_mod(monster_type *m_ptr, int dam, bool is_psy_spear)
1541 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1543 if ((r_ptr->flagsr & RFR_RES_ALL) && dam > 0)
1546 if((dam == 0) && one_in_(3)) dam = 1;
1549 if (m_ptr->invulner)
1553 if(!p_ptr->blind && m_ptr->ml)
1556 msg_print("¥Ð¥ê¥¢¤òÀÚ¤êÎö¤¤¤¿¡ª");
1558 msg_print("The barrier is penetrated!");
1562 else if (!one_in_(PENETRATE_INVULNERABILITY))
1570 static void get_exp_from_mon(int dam, monster_type *m_ptr)
1572 s32b div, new_exp, new_exp_frac;
1573 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1574 int monnum_penarty = 0;
1576 if (!m_ptr->r_idx) return;
1577 if (is_pet(m_ptr) || p_ptr->inside_battle) return;
1581 u32b m_exp_h, m_exp_l;
1583 if ((r_ptr->flags2 & RF2_MULTIPLY) || (m_ptr->r_idx == MON_DAWN))
1585 monnum_penarty = r_ptr->r_pkills / 400;
1586 if (monnum_penarty > 8) monnum_penarty = 8;
1588 if (r_ptr->flags1 & RF1_UNIQUE)
1590 m_exp = (long)r_ptr->mexp * r_ptr->level;
1591 div = (p_ptr->max_plv+2);
1595 m_exp = (long)r_ptr->mexp * r_ptr->level * SPEED_TO_ENERGY(m_ptr->mspeed);
1596 div = (p_ptr->max_plv+2) * SPEED_TO_ENERGY(r_ptr->speed);
1598 m_exp_h = m_exp/0x10000L;
1599 m_exp_l = m_exp%0x10000L;
1602 m_exp_h += m_exp_l / 0x10000L;
1603 m_exp_l %= 0x10000L;
1605 /* real monster maxhp have effect on EXP */
1606 if(!(r_ptr->flags1 & RF1_FORCE_MAXHP))
1608 u32b maxhp = m_ptr->max_maxhp*2;
1611 m_exp_h += m_exp_l / 0x10000L;
1612 m_exp_l %= 0x10000L;
1614 div *= r_ptr->hdice * (r_ptr->hside + 1);
1616 if (!dun_level && (!(r_ptr->flags8 & RF8_WILD_ONLY) || !(r_ptr->flags1 & RF1_UNIQUE))) div *= 5;
1617 div_h = div/0x10000L;
1618 div_l = div%0x10000L;
1619 div_h *= (m_ptr->max_maxhp*2);
1620 div_l *= (m_ptr->max_maxhp*2);
1621 div_h += div_l / 0x10000L;
1624 while (monnum_penarty)
1628 div_h += div_l / 0x10000L;
1633 m_exp_l = (0x7fffffff & (m_exp_h << 16)) | m_exp_l;
1634 m_exp_h = m_exp_h >> 15;
1635 div_l = (0x7fffffff & (div_h << 16)) | div_l;
1636 div_h = div_h >> 15;
1638 #define M_INT_GREATER63(h1,l1,h2,l2) ( (h1>h2)||( (h1==h2)&&(l1>=l2)))
1639 #define M_INT_SUB63(h1,l1, h2,l2) {h1-=h2;if(l1<l2){l1+=0x80000000;h1--;}l1-=l2;}
1640 #define M_INT_LSHIFT63(h1,l1) {h1=(h1<<1)|(l1>>30);l1=(l1<<1)&0x7fffffff;}
1641 #define M_INT_RSHIFT63(h1,l1) {l1=(l1>>1)|(h1<<30);h1>>=1;}
1642 #define M_INT_DIV63(h1,l1,h2,l2,result) \
1646 while( M_INT_GREATER63(h1,l1, h2, l2) ){M_INT_LSHIFT63(h2, l2); bit<<=1;} \
1647 for(bit>>=1; bit>=1; bit>>=1){ \
1648 M_INT_RSHIFT63(h2, l2); \
1649 if(M_INT_GREATER63(h1, l1, h2, l2)) \
1650 {result|=bit;M_INT_SUB63(h1, l1, h2, l2);} \
1654 /* Give some experience for the kill */
1655 M_INT_DIV63(m_exp_h, m_exp_l, div_h, div_l, new_exp);
1657 /* Handle fractional experience */
1658 /* multiply 0x10000L to remainder */
1659 m_exp_h = (m_exp_h<<16) | (m_exp_l>>15);
1661 M_INT_DIV63(m_exp_h, m_exp_l, div_h, div_l, new_exp_frac);
1662 new_exp_frac += p_ptr->exp_frac;
1663 /* Keep track of experience */
1664 if (new_exp_frac >= 0x10000L)
1667 p_ptr->exp_frac = (u16b)(new_exp_frac - 0x10000L);
1671 p_ptr->exp_frac = (u16b)new_exp_frac;
1674 /* Gain experience */
1682 * Decreases monsters hit points, handling monster death.
1684 * We return TRUE if the monster has been killed (and deleted).
1686 * We announce monster death (using an optional "death message"
1687 * if given, and a otherwise a generic killed/destroyed message).
1689 * Only "physical attacks" can induce the "You have slain" message.
1690 * Missile and Spell attacks will induce the "dies" message, or
1691 * various "specialized" messages. Note that "You have destroyed"
1692 * and "is destroyed" are synonyms for "You have slain" and "dies".
1694 * Hack -- unseen monsters yield "You have killed it." message.
1696 * Added fear (DGK) and check whether to print fear messages -CWS
1698 * Made name, sex, and capitalization generic -BEN-
1700 * As always, the "ghost" processing is a total hack.
1702 * Hack -- we "delay" fear messages by passing around a "fear" flag.
1704 * XXX XXX XXX Consider decreasing monster experience over time, say,
1705 * by using "(m_exp * m_lev * (m_lev)) / (p_lev * (m_lev + n_killed))"
1706 * instead of simply "(m_exp * m_lev) / (p_lev)", to make the first
1707 * monster worth more than subsequent monsters. This would also need
1708 * to induce changes in the monster recall code.
1710 bool mon_take_hit(int m_idx, int dam, bool *fear, cptr note)
1712 monster_type *m_ptr = &m_list[m_idx];
1713 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1715 monster_type exp_mon;
1717 /* Innocent until proven otherwise */
1718 bool innocent = TRUE, thief = FALSE;
1722 COPY(&exp_mon, m_ptr, monster_type);
1723 if (!(r_ptr->flags7 & RF7_KILL_EXP))
1725 expdam = (m_ptr->hp > dam) ? dam : m_ptr->hp;
1726 if (r_ptr->flags6 & RF6_HEAL) expdam = (expdam+1) * 2 / 3;
1728 get_exp_from_mon(expdam, &exp_mon);
1731 /* Redraw (later) if needed */
1732 if (p_ptr->health_who == m_idx) p_ptr->redraw |= (PR_HEALTH);
1733 if (p_ptr->riding == m_idx) p_ptr->redraw |= (PR_UHEALTH);
1738 if (r_ptr->flags7 & RF7_HAS_LD_MASK) p_ptr->update |= (PU_MON_LITE);
1740 /* Hack - Cancel any special player stealth magics. -LM- */
1741 if (p_ptr->special_defense & NINJA_S_STEALTH)
1743 set_superstealth(FALSE);
1749 /* It is dead now */
1754 if (r_info[m_ptr->r_idx].flags7 & RF7_TANUKI)
1756 /* You might have unmasked Tanuki first time */
1757 r_ptr = &r_info[m_ptr->r_idx];
1758 m_ptr->ap_r_idx = m_ptr->r_idx;
1759 if (r_ptr->r_sights < MAX_SHORT) r_ptr->r_sights++;
1762 if (m_ptr->mflag2 & MFLAG2_CHAMELEON)
1764 /* You might have unmasked Chameleon first time */
1765 r_ptr = real_r_ptr(m_ptr);
1766 if (r_ptr->r_sights < MAX_SHORT) r_ptr->r_sights++;
1769 if (!(m_ptr->smart & SM_CLONED))
1771 /* When the player kills a Unique, it stays dead */
1772 if (r_ptr->flags1 & RF1_UNIQUE)
1776 /* Mega-Hack -- Banor & Lupart */
1777 if ((m_ptr->r_idx == MON_BANOR) || (m_ptr->r_idx == MON_LUPART))
1779 r_info[MON_BANORLUPART].max_num = 0;
1780 r_info[MON_BANORLUPART].r_pkills++;
1781 if (r_info[MON_BANORLUPART].r_tkills < MAX_SHORT) r_info[MON_BANORLUPART].r_tkills++;
1783 else if (m_ptr->r_idx == MON_BANORLUPART)
1785 r_info[MON_BANOR].max_num = 0;
1786 r_info[MON_BANOR].r_pkills++;
1787 if (r_info[MON_BANOR].r_tkills < MAX_SHORT) r_info[MON_BANOR].r_tkills++;
1788 r_info[MON_LUPART].max_num = 0;
1789 r_info[MON_LUPART].r_pkills++;
1790 if (r_info[MON_LUPART].r_tkills < MAX_SHORT) r_info[MON_LUPART].r_tkills++;
1794 /* When the player kills a Nazgul, it stays dead */
1795 else if (r_ptr->flags7 & RF7_NAZGUL) r_ptr->max_num--;
1798 /* Recall even invisible uniques or winners */
1799 if (m_ptr->ml || (r_ptr->flags1 & RF1_UNIQUE))
1801 /* Count kills this life */
1802 if ((m_ptr->mflag2 & MFLAG2_KAGE) && (r_info[MON_KAGE].r_pkills < MAX_SHORT)) r_info[MON_KAGE].r_pkills++;
1803 else if (r_ptr->r_pkills < MAX_SHORT) r_ptr->r_pkills++;
1805 /* Count kills in all lives */
1806 if ((m_ptr->mflag2 & MFLAG2_KAGE) && (r_info[MON_KAGE].r_tkills < MAX_SHORT)) r_info[MON_KAGE].r_tkills++;
1807 else if (r_ptr->r_tkills < MAX_SHORT) r_ptr->r_tkills++;
1809 /* Hack -- Auto-recall */
1810 monster_race_track(m_ptr->ap_r_idx);
1813 /* Extract monster name */
1814 monster_desc(m_name, m_ptr, MD_TRUE_NAME);
1816 /* Don't kill Amberites */
1817 if ((r_ptr->flags3 & RF3_AMBERITE) && one_in_(2))
1819 int curses = 1 + randint1(3);
1820 bool stop_ty = FALSE;
1824 msg_format("%^s¤Ï¶²¤í¤·¤¤·ì¤Î¼ö¤¤¤ò¤¢¤Ê¤¿¤Ë¤«¤±¤¿¡ª", m_name);
1826 msg_format("%^s puts a terrible blood curse on you!", m_name);
1829 curse_equipment(100, 50);
1833 stop_ty = activate_ty_curse(stop_ty, &count);
1838 if (r_ptr->flags2 & RF2_CAN_SPEAK)
1840 char line_got[1024];
1842 /* Dump a message */
1844 if (!get_rnd_line("mondeath_j.txt", m_ptr->r_idx, line_got))
1846 if (!get_rnd_line("mondeath.txt", m_ptr->r_idx, line_got))
1849 msg_format("%^s %s", m_name, line_got);
1852 if (m_ptr->r_idx == MON_SERPENT)
1854 /* Make screen dump */
1855 screen_dump = make_screen_dump();
1860 if (!(d_info[dungeon_type].flags1 & DF1_BEGINNER))
1862 if (!dun_level && !ambush_flag && !p_ptr->inside_arena)
1864 chg_virtue(V_VALOUR, -1);
1866 else if (r_ptr->level > dun_level)
1868 if (randint1(10) <= (r_ptr->level - dun_level))
1869 chg_virtue(V_VALOUR, 1);
1871 if (r_ptr->level > 60)
1873 chg_virtue(V_VALOUR, 1);
1875 if (r_ptr->level >= 2 * (p_ptr->lev+1))
1876 chg_virtue(V_VALOUR, 2);
1879 if (r_ptr->flags1 & RF1_UNIQUE)
1881 if (r_ptr->flags3 & (RF3_EVIL | RF3_GOOD)) chg_virtue(V_HARMONY, 2);
1883 if (r_ptr->flags3 & RF3_GOOD)
1885 chg_virtue(V_UNLIFE, 2);
1886 chg_virtue(V_VITALITY, -2);
1889 if (one_in_(3)) chg_virtue(V_INDIVIDUALISM, -1);
1892 if (m_ptr->r_idx == MON_BEGGAR || m_ptr->r_idx == MON_LEPER)
1894 chg_virtue(V_COMPASSION, -1);
1897 if ((r_ptr->flags3 & RF3_GOOD) &&
1898 ((r_ptr->level) / 10 + (3 * dun_level) >= randint1(100)))
1899 chg_virtue(V_UNLIFE, 1);
1901 if (r_ptr->d_char == 'A')
1903 if (r_ptr->flags1 & RF1_UNIQUE)
1904 chg_virtue(V_FAITH, -2);
1905 else if ((r_ptr->level) / 10 + (3 * dun_level) >= randint1(100))
1907 if (r_ptr->flags3 & RF3_GOOD) chg_virtue(V_FAITH, -1);
1908 else chg_virtue(V_FAITH, 1);
1911 else if (r_ptr->flags3 & RF3_DEMON)
1913 if (r_ptr->flags1 & RF1_UNIQUE)
1914 chg_virtue(V_FAITH, 2);
1915 else if ((r_ptr->level) / 10 + (3 * dun_level) >= randint1(100))
1916 chg_virtue(V_FAITH, 1);
1919 if ((r_ptr->flags3 & RF3_UNDEAD) && (r_ptr->flags1 & RF1_UNIQUE))
1920 chg_virtue(V_VITALITY, 2);
1922 if (r_ptr->r_deaths)
1924 if (r_ptr->flags1 & RF1_UNIQUE)
1926 chg_virtue(V_HONOUR, 10);
1928 else if ((r_ptr->level) / 10 + (2 * dun_level) >= randint1(100))
1930 chg_virtue(V_HONOUR, 1);
1933 if ((r_ptr->flags2 & RF2_MULTIPLY) && (r_ptr->r_pkills > 1000) && one_in_(10))
1935 chg_virtue(V_VALOUR, -1);
1938 for (i = 0; i < 4; i++)
1940 if (r_ptr->blow[i].d_dice != 0) innocent = FALSE; /* Murderer! */
1942 if ((r_ptr->blow[i].effect == RBE_EAT_ITEM)
1943 || (r_ptr->blow[i].effect == RBE_EAT_GOLD))
1945 thief = TRUE; /* Thief! */
1948 /* The new law says it is illegal to live in the dungeon */
1949 if (r_ptr->level != 0) innocent = FALSE;
1953 if (r_ptr->flags1 & RF1_UNIQUE)
1954 chg_virtue(V_JUSTICE, 3);
1955 else if (1+((r_ptr->level) / 10 + (2 * dun_level))
1957 chg_virtue(V_JUSTICE, 1);
1961 chg_virtue (V_JUSTICE, -1);
1964 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)))
1966 if (one_in_(4)) chg_virtue(V_NATURE, -1);
1969 if ((r_ptr->flags1 & RF1_UNIQUE) && record_destroy_uniq)
1973 sprintf(m_name, "%s%s", r_name + r_ptr->name, (m_ptr->smart & SM_CLONED) ? "(¥¯¥í¡¼¥ó)" : "");
1975 sprintf(m_name, "%s%s", r_name + r_ptr->name, (m_ptr->smart & SM_CLONED) ? "(Clone)" : "");
1977 do_cmd_write_nikki(NIKKI_UNIQUE, 0, m_name);
1983 /* Death by Missile/Spell attack */
1986 msg_format("%^s%s", m_name, note);
1989 /* Death by physical attack -- invisible monster */
1990 else if (!m_ptr->ml)
1993 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
1994 msg_format("¤»¤Ã¤«¤¯¤À¤«¤é%s¤ò»¦¤·¤¿¡£", m_name);
1996 msg_format("%s¤ò»¦¤·¤¿¡£", m_name);
1998 msg_format("You have killed %s.", m_name);
2003 /* Death by Physical attack -- non-living monster */
2004 else if (!monster_living(r_ptr))
2007 bool explode = FALSE;
2009 for (i = 0; i < 4; i++)
2011 if (r_ptr->blow[i].method == RBM_EXPLODE) explode = TRUE;
2014 /* Special note at death */
2017 msg_format("%s¤ÏÇúȯ¤·¤ÆÊ´¡¹¤Ë¤Ê¤Ã¤¿¡£", m_name);
2019 msg_format("%s explodes into tiny shreds.", m_name);
2024 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
2025 msg_format("¤»¤Ã¤«¤¯¤À¤«¤é%s¤òÅݤ·¤¿¡£", m_name);
2027 msg_format("%s¤òÅݤ·¤¿¡£", m_name);
2029 msg_format("You have destroyed %s.", m_name);
2034 /* Death by Physical attack -- living monster */
2038 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
2039 msg_format("¤»¤Ã¤«¤¯¤À¤«¤é%s¤òÁò¤êµî¤Ã¤¿¡£", m_name);
2041 msg_format("%s¤òÁò¤êµî¤Ã¤¿¡£", m_name);
2043 msg_format("You have slain %s.", m_name);
2047 if ((r_ptr->flags1 & RF1_UNIQUE) && !(m_ptr->smart & SM_CLONED) && !vanilla_town)
2049 for (i = 0; i < MAX_KUBI; i++)
2051 if ((kubi_r_idx[i] == m_ptr->r_idx) && !(m_ptr->mflag2 & MFLAG2_CHAMELEON))
2054 msg_format("%s¤Î¼ó¤Ë¤Ï¾Þ¶â¤¬¤«¤«¤Ã¤Æ¤¤¤ë¡£", m_name);
2056 msg_format("There is a price on %s's head.", m_name);
2063 /* Generate treasure */
2064 monster_death(m_idx, TRUE);
2066 /* Mega hack : replace IKETA to BIKETAL */
2067 if ((m_ptr->r_idx == MON_IKETA) &&
2068 !(p_ptr->inside_arena || p_ptr->inside_battle))
2070 int dummy_y = m_ptr->fy;
2071 int dummy_x = m_ptr->fx;
2074 if (is_pet(m_ptr)) mode |= PM_FORCE_PET;
2076 /* Delete the monster */
2077 delete_monster_idx(m_idx);
2079 if (summon_named_creature(0, dummy_y, dummy_x, MON_BIKETAL, mode))
2082 msg_print("¡Ö¥Ï¥¡¥Ã¥Ï¥Ã¥Ï¥Ã¥Ï¡ª¡ª»ä¤¬¥Ð¥¤¥±¥¿¥ë¤À¡ª¡ª¡×");
2084 msg_print("Uwa-hahaha! *I* am Biketal!");
2090 /* Delete the monster */
2091 delete_monster_idx(m_idx);
2094 /* Prevent bug of chaos patron's reward */
2095 if (r_ptr->flags7 & RF7_KILL_EXP)
2096 get_exp_from_mon((long)exp_mon.max_maxhp*2, &exp_mon);
2098 get_exp_from_mon(((long)exp_mon.max_maxhp+1L) * 9L / 10L, &exp_mon);
2103 /* Monster is dead */
2110 /* Mega-Hack -- Pain cancels fear */
2111 if (m_ptr->monfear && (dam > 0))
2113 int tmp = randint1(dam);
2115 /* Cure a little fear */
2116 if (tmp < m_ptr->monfear)
2119 m_ptr->monfear -= tmp;
2122 /* Cure all the fear */
2133 /* Sometimes a monster gets scared by damage */
2134 if (!m_ptr->monfear && !(r_ptr->flags3 & (RF3_NO_FEAR)))
2138 /* Percentage of fully healthy */
2139 percentage = (100L * m_ptr->hp) / m_ptr->maxhp;
2142 * Run (sometimes) if at 10% or less of max hit points,
2143 * or (usually) when hit for half its current hit points
2145 if ((randint1(10) >= percentage) ||
2146 ((dam >= m_ptr->hp) && (randint0(100) < 80)))
2148 /* Hack -- note fear */
2151 /* XXX XXX XXX Hack -- Add some timed fear */
2152 m_ptr->monfear = (randint1(10) +
2153 (((dam >= m_ptr->hp) && (percentage > 7)) ?
2154 20 : ((11 - percentage) * 5)));
2161 if (p_ptr->riding && (p_ptr->riding == m_idx) && (dam > 0))
2165 /* Extract monster name */
2166 monster_desc(m_name, m_ptr, 0);
2168 if (m_ptr->hp > m_ptr->maxhp/3) dam = (dam + 1) / 2;
2169 if (rakuba((dam > 200) ? 200 : dam, FALSE))
2172 msg_format("%^s¤Ë¿¶¤êÍî¤È¤µ¤ì¤¿¡ª", m_name);
2174 msg_format("%^s has thrown you off!", m_name);
2186 * Get term size and calculate screen size
2188 void get_screen_size(int *wid_p, int *hgt_p)
2190 Term_get_size(wid_p, hgt_p);
2191 *hgt_p -= ROW_MAP + 2;
2192 *wid_p -= COL_MAP + 2;
2193 if (use_bigtile) *wid_p /= 2;
2198 * Calculates current boundaries
2199 * Called below and from "do_cmd_locate()".
2201 void panel_bounds_center(void)
2206 get_screen_size(&wid, &hgt);
2208 panel_row_max = panel_row_min + hgt - 1;
2209 panel_row_prt = panel_row_min - 1;
2210 panel_col_max = panel_col_min + wid - 1;
2211 panel_col_prt = panel_col_min - 13;
2216 * Map resizing whenever the main term changes size
2218 void resize_map(void)
2220 /* Only if the dungeon exists */
2221 if (!character_dungeon) return;
2223 /* Mega-Hack -- no panel yet */
2227 /* Reset the panels */
2228 panel_row_min = cur_hgt;
2229 panel_col_min = cur_wid;
2234 p_ptr->update |= (PU_TORCH | PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
2236 /* Forget lite/view */
2237 p_ptr->update |= (PU_UN_VIEW | PU_UN_LITE);
2239 /* Update lite/view */
2240 p_ptr->update |= (PU_VIEW | PU_LITE | PU_MON_LITE);
2242 /* Update monsters */
2243 p_ptr->update |= (PU_MONSTERS);
2245 /* Redraw everything */
2246 p_ptr->redraw |= (PR_WIPE | PR_BASIC | PR_EXTRA | PR_MAP | PR_EQUIPPY);
2248 /* Hack -- update */
2256 * Place the cursor on the player
2258 if (can_save) move_cursor_relative(py, px);
2265 * Redraw a term when it is resized
2267 void redraw_window(void)
2269 /* Only if the dungeon exists */
2270 if (!character_dungeon) return;
2272 /* Hack - Activate term zero for the redraw */
2273 Term_activate(&term_screen[0]);
2275 /* Hack -- react to changes */
2276 Term_xtra(TERM_XTRA_REACT, 0);
2279 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_SPELL | PW_PLAYER);
2282 p_ptr->window |= (PW_MESSAGE | PW_OVERHEAD | PW_DUNGEON | PW_MONSTER | PW_OBJECT);
2284 /* Hack -- update */
2296 * Handle a request to change the current panel
2298 * Return TRUE if the panel was changed.
2300 * Also used in do_cmd_locate
2302 bool change_panel(int dy, int dx)
2308 get_screen_size(&wid, &hgt);
2310 /* Apply the motion */
2311 y = panel_row_min + dy * hgt / 2;
2312 x = panel_col_min + dx * wid / 2;
2314 /* Verify the row */
2315 if (y > cur_hgt - hgt) y = cur_hgt - hgt;
2318 /* Verify the col */
2319 if (x > cur_wid - wid) x = cur_wid - wid;
2322 /* Handle "changes" */
2323 if ((y != panel_row_min) || (x != panel_col_min))
2325 /* Save the new panel info */
2329 /* Recalculate the boundaries */
2330 panel_bounds_center();
2333 p_ptr->update |= (PU_MONSTERS);
2336 p_ptr->redraw |= (PR_MAP);
2351 * Given an row (y) and col (x), this routine detects when a move
2352 * off the screen has occurred and figures new borders. -RAK-
2354 * "Update" forces a "full update" to take place.
2356 * The map is reprinted if necessary, and "TRUE" is returned.
2358 void verify_panel(void)
2370 get_screen_size(&wid, &hgt);
2372 max_prow_min = cur_hgt - hgt;
2373 max_pcol_min = cur_wid - wid;
2375 /* Bounds checking */
2376 if (max_prow_min < 0) max_prow_min = 0;
2377 if (max_pcol_min < 0) max_pcol_min = 0;
2379 /* Center on player */
2380 if (center_player && (center_running || !running))
2382 /* Center vertically */
2383 prow_min = y - hgt / 2;
2384 if (prow_min < 0) prow_min = 0;
2385 else if (prow_min > max_prow_min) prow_min = max_prow_min;
2387 /* Center horizontally */
2388 pcol_min = x - wid / 2;
2389 if (pcol_min < 0) pcol_min = 0;
2390 else if (pcol_min > max_pcol_min) pcol_min = max_pcol_min;
2394 prow_min = panel_row_min;
2395 pcol_min = panel_col_min;
2397 /* Scroll screen when 2 grids from top/bottom edge */
2398 if (y > panel_row_max - 2)
2400 while (y > prow_min + hgt-1 - 2)
2402 prow_min += (hgt / 2);
2406 if (y < panel_row_min + 2)
2408 while (y < prow_min + 2)
2410 prow_min -= (hgt / 2);
2414 if (prow_min > max_prow_min) prow_min = max_prow_min;
2415 if (prow_min < 0) prow_min = 0;
2417 /* Scroll screen when 4 grids from left/right edge */
2418 if (x > panel_col_max - 4)
2420 while (x > pcol_min + wid-1 - 4)
2422 pcol_min += (wid / 2);
2426 if (x < panel_col_min + 4)
2428 while (x < pcol_min + 4)
2430 pcol_min -= (wid / 2);
2434 if (pcol_min > max_pcol_min) pcol_min = max_pcol_min;
2435 if (pcol_min < 0) pcol_min = 0;
2438 /* Check for "no change" */
2439 if ((prow_min == panel_row_min) && (pcol_min == panel_col_min)) return;
2441 /* Save the new panel info */
2442 panel_row_min = prow_min;
2443 panel_col_min = pcol_min;
2445 /* Hack -- optional disturb on "panel change" */
2446 if (disturb_panel && !center_player) disturb(0, 0);
2448 /* Recalculate the boundaries */
2449 panel_bounds_center();
2452 p_ptr->update |= (PU_MONSTERS);
2455 p_ptr->redraw |= (PR_MAP);
2458 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
2463 * Monster health description
2465 cptr look_mon_desc(monster_type *m_ptr, u32b mode)
2467 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
2474 /* Determine if the monster is "living" */
2475 living = monster_living(ap_r_ptr);
2477 /* Calculate a health "percentage" */
2478 perc = 100L * m_ptr->hp / m_ptr->maxhp;
2480 /* Healthy monsters */
2481 if (m_ptr->hp >= m_ptr->maxhp)
2485 desc = living ? "̵½ý" : "̵¥À¥á¡¼¥¸";
2487 desc = living ? "unhurt" : "undamaged";
2492 else if (perc >= 60)
2495 desc = living ? "·Ú½ý" : "¾®¥À¥á¡¼¥¸";
2497 desc = living ? "somewhat wounded" : "somewhat damaged";
2502 else if (perc >= 25)
2505 desc = living ? "Éé½ý" : "Ãæ¥À¥á¡¼¥¸";
2507 desc = living ? "wounded" : "damaged";
2512 else if (perc >= 10)
2515 desc = living ? "½Å½ý" : "Âç¥À¥á¡¼¥¸";
2517 desc = living ? "badly wounded" : "badly damaged";
2525 desc = living ? "Ⱦ»àȾÀ¸" : "Åݤ줫¤±";
2527 desc = living ? "almost dead" : "almost destroyed";
2532 /* Need attitude information? */
2535 /* Full information is not needed */
2538 else if (is_pet(m_ptr))
2541 attitude = ", ¥Ú¥Ã¥È";
2546 else if (is_friendly(m_ptr))
2549 attitude = ", ͧ¹¥Åª";
2551 attitude = ", friendly";
2564 /* Clone monster? */
2565 if (m_ptr->smart & SM_CLONED)
2574 /* Display monster's level --- idea borrowed from ToME */
2575 if (ap_r_ptr->r_tkills && !(m_ptr->mflag2 & MFLAG2_KAGE))
2578 return format("¥ì¥Ù¥ë%d, %s%s%s", ap_r_ptr->level, desc, attitude, clone);
2580 return format("Level %d, %s%s%s", ap_r_ptr->level, desc, attitude, clone);
2586 return format("¥ì¥Ù¥ë???, %s%s%s", desc, attitude, clone);
2588 return format("Level ???, %s%s%s", desc, attitude, clone);
2596 * Angband sorting algorithm -- quick sort in place
2598 * Note that the details of the data we are sorting is hidden,
2599 * and we rely on the "ang_sort_comp()" and "ang_sort_swap()"
2600 * function hooks to interact with the data, which is given as
2601 * two pointers, and which may have any user-defined form.
2603 void ang_sort_aux(vptr u, vptr v, int p, int q)
2621 while (!(*ang_sort_comp)(u, v, b, z)) b--;
2624 while (!(*ang_sort_comp)(u, v, z, a)) a++;
2626 /* Done partition */
2630 (*ang_sort_swap)(u, v, a, b);
2636 /* Recurse left side */
2637 ang_sort_aux(u, v, p, b);
2639 /* Recurse right side */
2640 ang_sort_aux(u, v, b+1, q);
2645 * Angband sorting algorithm -- quick sort in place
2647 * Note that the details of the data we are sorting is hidden,
2648 * and we rely on the "ang_sort_comp()" and "ang_sort_swap()"
2649 * function hooks to interact with the data, which is given as
2650 * two pointers, and which may have any user-defined form.
2652 void ang_sort(vptr u, vptr v, int n)
2654 /* Sort the array */
2655 ang_sort_aux(u, v, 0, n-1);
2660 /*** Targeting Code ***/
2664 * Determine is a monster makes a reasonable target
2666 * The concept of "targeting" was stolen from "Morgul" (?)
2668 * The player can target any location, or any "target-able" monster.
2670 * Currently, a monster is "target_able" if it is visible, and if
2671 * the player can hit it with a projection, and the player is not
2672 * hallucinating. This allows use of "use closest target" macros.
2674 * Future versions may restrict the ability to target "trappers"
2675 * and "mimics", but the semantics is a little bit weird.
2677 bool target_able(int m_idx)
2679 monster_type *m_ptr = &m_list[m_idx];
2681 /* Monster must be alive */
2682 if (!m_ptr->r_idx) return (FALSE);
2684 /* Hack -- no targeting hallucinations */
2685 if (p_ptr->image) return (FALSE);
2687 /* Monster must be visible */
2688 if (!m_ptr->ml) return (FALSE);
2690 if (p_ptr->riding && (p_ptr->riding == m_idx)) return (TRUE);
2692 /* Monster must be projectable */
2693 if (!projectable(py, px, m_ptr->fy, m_ptr->fx)) return (FALSE);
2695 /* XXX XXX XXX Hack -- Never target trappers */
2696 /* if (CLEAR_ATTR && (CLEAR_CHAR)) return (FALSE); */
2706 * Update (if necessary) and verify (if possible) the target.
2708 * We return TRUE if the target is "okay" and FALSE otherwise.
2710 bool target_okay(void)
2712 /* Accept stationary targets */
2713 if (target_who < 0) return (TRUE);
2715 /* Check moving targets */
2718 /* Accept reasonable targets */
2719 if (target_able(target_who))
2721 monster_type *m_ptr = &m_list[target_who];
2723 /* Acquire monster location */
2724 target_row = m_ptr->fy;
2725 target_col = m_ptr->fx;
2732 /* Assume no target */
2739 * Sorting hook -- comp function -- by "distance to player"
2741 * We use "u" and "v" to point to arrays of "x" and "y" positions,
2742 * and sort the arrays by double-distance to the player.
2744 static bool ang_sort_comp_distance(vptr u, vptr v, int a, int b)
2746 byte *x = (byte*)(u);
2747 byte *y = (byte*)(v);
2751 /* Absolute distance components */
2752 kx = x[a]; kx -= px; kx = ABS(kx);
2753 ky = y[a]; ky -= py; ky = ABS(ky);
2755 /* Approximate Double Distance to the first point */
2756 da = ((kx > ky) ? (kx + kx + ky) : (ky + ky + kx));
2758 /* Absolute distance components */
2759 kx = x[b]; kx -= px; kx = ABS(kx);
2760 ky = y[b]; ky -= py; ky = ABS(ky);
2762 /* Approximate Double Distance to the first point */
2763 db = ((kx > ky) ? (kx + kx + ky) : (ky + ky + kx));
2765 /* Compare the distances */
2771 * Sorting hook -- swap function -- by "distance to player"
2773 * We use "u" and "v" to point to arrays of "x" and "y" positions,
2774 * and sort the arrays by distance to the player.
2776 static void ang_sort_swap_distance(vptr u, vptr v, int a, int b)
2778 byte *x = (byte*)(u);
2779 byte *y = (byte*)(v);
2797 * Hack -- help "select" a location (see below)
2799 static s16b target_pick(int y1, int x1, int dy, int dx)
2803 int x2, y2, x3, y3, x4, y4;
2805 int b_i = -1, b_v = 9999;
2808 /* Scan the locations */
2809 for (i = 0; i < temp_n; i++)
2815 /* Directed distance */
2819 /* Verify quadrant */
2820 if (dx && (x3 * dx <= 0)) continue;
2821 if (dy && (y3 * dy <= 0)) continue;
2823 /* Absolute distance */
2827 /* Verify quadrant */
2828 if (dy && !dx && (x4 > y4)) continue;
2829 if (dx && !dy && (y4 > x4)) continue;
2831 /* Approximate Double Distance */
2832 v = ((x4 > y4) ? (x4 + x4 + y4) : (y4 + y4 + x4));
2834 /* XXX XXX XXX Penalize location */
2837 if ((b_i >= 0) && (v >= b_v)) continue;
2849 * Hack -- determine if a given location is "interesting"
2851 static bool target_set_accept(int y, int x)
2855 s16b this_o_idx, next_o_idx = 0;
2858 if (!(in_bounds(y, x))) return (FALSE);
2860 /* Player grid is always interesting */
2861 if (player_bold(y, x)) return (TRUE);
2864 /* Handle hallucination */
2865 if (p_ptr->image) return (FALSE);
2868 /* Examine the grid */
2869 c_ptr = &cave[y][x];
2871 /* Visible monsters */
2874 monster_type *m_ptr = &m_list[c_ptr->m_idx];
2876 /* Visible monsters */
2877 if (m_ptr->ml) return (TRUE);
2880 /* Scan all objects in the grid */
2881 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
2885 /* Acquire object */
2886 o_ptr = &o_list[this_o_idx];
2888 /* Acquire next object */
2889 next_o_idx = o_ptr->next_o_idx;
2891 /* Memorized object */
2892 if (o_ptr->marked) return (TRUE);
2895 /* Interesting memorized features */
2896 if (c_ptr->info & (CAVE_MARK))
2900 /* Feature code (applying "mimic" field) */
2901 feat = f_info[c_ptr->mimic ? c_ptr->mimic : c_ptr->feat].mimic;
2904 if (c_ptr->info & CAVE_OBJECT) return (TRUE);
2906 /* Notice the Pattern */
2907 if ((feat <= FEAT_PATTERN_XTRA2) &&
2908 (feat >= FEAT_PATTERN_START))
2912 if (feat == FEAT_OPEN) return (TRUE);
2913 if (feat == FEAT_BROKEN) return (TRUE);
2916 if (feat == FEAT_LESS) return (TRUE);
2917 if (feat == FEAT_MORE) return (TRUE);
2918 if (feat == FEAT_LESS_LESS) return (TRUE);
2919 if (feat == FEAT_MORE_MORE) return (TRUE);
2922 if ((feat >= FEAT_SHOP_HEAD) &&
2923 (feat <= FEAT_SHOP_TAIL)) return (TRUE);
2925 if (feat == FEAT_MUSEUM) return (TRUE);
2927 /* Notice buildings -KMW- */
2928 if ((feat >= FEAT_BLDG_HEAD) &&
2929 (feat <= FEAT_BLDG_TAIL)) return (TRUE);
2932 if (is_trap(feat)) return (TRUE);
2935 if ((feat >= FEAT_DOOR_HEAD) &&
2936 (feat <= FEAT_DOOR_TAIL)) return (TRUE);
2940 /* I think FEAT_RUBBLEs should not be "interesting" */
2941 if (feat == FEAT_RUBBLE) return (TRUE);
2943 /* Notice veins with treasure */
2944 /* Now veins with treasure are too many */
2945 if (feat == FEAT_MAGMA_K) return (TRUE);
2946 if (feat == FEAT_QUARTZ_K) return (TRUE);
2949 /* Notice quest features */
2950 if (feat == FEAT_QUEST_ENTER) return (TRUE);
2951 if (feat == FEAT_QUEST_EXIT) return (TRUE);
2952 if (feat == FEAT_QUEST_DOWN) return (TRUE);
2953 if (feat == FEAT_QUEST_UP) return (TRUE);
2954 if (feat == FEAT_TOWN) return (TRUE);
2955 if (feat == FEAT_ENTRANCE) return (TRUE);
2964 * Prepare the "temp" array for "target_set"
2966 * Return the number of target_able monsters in the set.
2968 static void target_set_prepare(int mode)
2972 /* Reset "temp" array */
2975 /* Scan the current panel */
2976 for (y = panel_row_min; y <= panel_row_max; y++)
2978 for (x = panel_col_min; x <= panel_col_max; x++)
2982 /* Require "interesting" contents */
2983 if (!target_set_accept(y, x)) continue;
2985 c_ptr = &cave[y][x];
2987 /* Require target_able monsters for "TARGET_KILL" */
2988 if ((mode & (TARGET_KILL)) && !target_able(c_ptr->m_idx)) continue;
2990 if ((mode & (TARGET_KILL)) && !target_pet && is_pet(&m_list[c_ptr->m_idx])) continue;
2992 /* Save the location */
2999 /* Set the sort hooks */
3000 ang_sort_comp = ang_sort_comp_distance;
3001 ang_sort_swap = ang_sort_swap_distance;
3003 /* Sort the positions */
3004 ang_sort(temp_x, temp_y, temp_n);
3006 if (p_ptr->riding && target_pet && (temp_n > 1) && (mode & (TARGET_KILL)))
3011 temp_y[0] = temp_y[1];
3014 temp_x[0] = temp_x[1];
3021 * Evaluate number of kill needed to gain level
3023 static void evaluate_monster_exp(char *buf, monster_type *m_ptr)
3025 #define M_INT_GREATER(h1,l1,h2,l2) ( (h1>h2)||( (h1==h2)&&(l1>=l2)))
3026 #define M_INT_SUB(h1,l1, h2,l2) {h1-=h2;if(l1<l2){l1+=0x10000;h1--;}l1-=l2;}
3027 #define M_INT_ADD(h1,l1, h2,l2) {h1+=h2;l1+=l2;if(l1>=0x10000L){l1&=0xFFFF;h1++;}}
3028 #define M_INT_LSHIFT(h1,l1) {h1=(h1<<1)|(l1>>15);l1=(l1<<1)&0xffff;}
3029 #define M_INT_RSHIFT(h1,l1) {l1=(l1>>1)|((h1&1)<<15);h1>>=1;}
3030 #define M_INT_MULT(h1,l1,mul,h2,l2) {l2=(l1*mul)&0xffff;h2=((l1*mul)>>16)+h1*mul;}
3032 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
3036 u32b exp_mon= (ap_r_ptr->mexp)*(ap_r_ptr->level);
3037 u32b exp_mon_h= exp_mon / (p_ptr->max_plv+2);
3038 u32b exp_mon_l= ((exp_mon % (p_ptr->max_plv+2))*0x10000/(p_ptr->max_plv+2))&0xFFFF;
3040 u32b exp_adv_h = player_exp[p_ptr->lev -1] * p_ptr->expfact /100;
3041 u32b exp_adv_l = ((player_exp[p_ptr->lev -1]%100) * p_ptr->expfact *0x10000/100)&0xFFFF;
3043 M_INT_SUB(exp_adv_h, exp_adv_l, p_ptr->exp, p_ptr->exp_frac);
3044 if ((p_ptr->lev>=PY_MAX_LEVEL) || (p_ptr->prace == RACE_ANDROID))
3046 else if (!ap_r_ptr->r_tkills || (m_ptr->mflag2 & MFLAG2_KAGE))
3048 else if (M_INT_GREATER(exp_mon_h, exp_mon_l, exp_adv_h, exp_adv_l))
3052 M_INT_MULT(exp_mon_h, exp_mon_l, 1000,tmp_h, tmp_l);
3053 if( M_INT_GREATER(exp_adv_h, exp_adv_l, tmp_h, tmp_l) )
3058 M_INT_ADD(exp_adv_h, exp_adv_l, exp_mon_h, exp_mon_l);
3059 M_INT_SUB(exp_adv_h, exp_adv_l, 0, 1);
3060 while(M_INT_GREATER(exp_adv_h, exp_adv_l, exp_mon_h,exp_mon_l))
3062 M_INT_LSHIFT(exp_mon_h,exp_mon_l);
3065 M_INT_RSHIFT(exp_mon_h,exp_mon_l);bit>>=1;
3066 for(;bit>=1;bit>>=1)
3068 if(M_INT_GREATER(exp_adv_h,exp_adv_l,exp_mon_h,exp_mon_l))
3071 M_INT_SUB(exp_adv_h,exp_adv_l,exp_mon_h,exp_mon_l);
3073 M_INT_RSHIFT(exp_mon_h,exp_mon_l);
3075 sprintf(buf,"%03d",result);
3082 * Examine a grid, return a keypress.
3084 * The "mode" argument contains the "TARGET_LOOK" bit flag, which
3085 * indicates that the "space" key should scan through the contents
3086 * of the grid, instead of simply returning immediately. This lets
3087 * the "look" command get complete information, without making the
3088 * "target" command annoying.
3090 * The "info" argument contains the "commands" which should be shown
3091 * inside the "[xxx]" text. This string must never be empty, or grids
3092 * containing monsters will be displayed with an extra comma.
3094 * Note that if a monster is in the grid, we update both the monster
3095 * recall info and the health bar info to track that monster.
3097 * Eventually, we may allow multiple objects per grid, or objects
3098 * and terrain features in the same grid. XXX XXX XXX
3100 * This function must handle blindness/hallucination.
3102 static int target_set_aux(int y, int x, int mode, cptr info)
3104 cave_type *c_ptr = &cave[y][x];
3105 s16b this_o_idx, next_o_idx = 0;
3106 cptr s1 = "", s2 = "", s3 = "", x_info = "";
3110 char out_val[MAX_NLEN+80];
3112 #ifdef ALLOW_EASY_FLOOR
3113 int floor_list[23], floor_num = 0;
3115 /* Scan all objects in the grid */
3118 floor_num = scan_floor(floor_list, y, x, 0x02);
3130 #endif /* ALLOW_EASY_FLOOR */
3132 /* Hack -- under the player */
3133 if (player_bold(y, x))
3156 /* Hack -- hallucination */
3160 cptr name = "²¿¤«´ñ̯¤Êʪ";
3162 cptr name = "something strange";
3166 /* Display a message */
3168 sprintf(out_val, "%s%s%s%s [%s]", s1, name, s2, s3, info);
3170 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, name, info);
3174 move_cursor_relative(y, x);
3177 /* Stop on everything but "return" */
3178 if ((query != '\r') && (query != '\n')) return query;
3180 /* Repeat forever */
3185 /* Actual monsters */
3186 if (c_ptr->m_idx && m_list[c_ptr->m_idx].ml)
3188 monster_type *m_ptr = &m_list[c_ptr->m_idx];
3189 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
3191 bool recall = FALSE;
3196 /* Get the monster name ("a kobold") */
3197 monster_desc(m_name, m_ptr, MD_INDEF_VISIBLE);
3199 /* Hack -- track this monster race */
3200 monster_race_track(m_ptr->ap_r_idx);
3202 /* Hack -- health bar for this monster */
3203 health_track(c_ptr->m_idx);
3205 /* Hack -- handle stuff */
3219 /* Recall on screen */
3220 screen_roff(m_ptr->ap_r_idx, 0);
3222 /* Hack -- Complete the prompt (again) */
3224 Term_addstr(-1, TERM_WHITE, format(" [r»× %s%s]", x_info, info));
3226 Term_addstr(-1, TERM_WHITE, format(" [r,%s%s]", x_info, info));
3235 /* Normal commands */
3236 if (query != 'r') break;
3241 /* Cleare recall text and repeat */
3247 /* Describe, and prompt for recall */
3248 evaluate_monster_exp(acount, m_ptr);
3251 sprintf(out_val, "[%s]%s%s(%s)%s%s [r»× %s%s]", acount, s1, m_name, look_mon_desc(m_ptr, 0x01), s2, s3, x_info, info);
3253 sprintf(out_val, "[%s]%s%s%s%s(%s) [r, %s%s]", acount, s1, s2, s3, m_name, look_mon_desc(m_ptr, 0x01), x_info, info);
3259 move_cursor_relative(y, x);
3264 /* Normal commands */
3265 if (query != 'r') break;
3271 /* Always stop at "normal" keys */
3272 if ((query != '\r') && (query != '\n') && (query != ' ') && (query != 'x')) return query;
3274 /* Sometimes stop at "space" key */
3275 if ((query == ' ') && !(mode & (TARGET_LOOK))) return query;
3277 /* Change the intro */
3285 /* Hack -- take account of gender */
3287 if (ap_r_ptr->flags1 & (RF1_FEMALE)) s1 = "Èà½÷¤Ï";
3289 if (ap_r_ptr->flags1 & (RF1_FEMALE)) s1 = "She is ";
3293 else if (ap_r_ptr->flags1 & (RF1_MALE)) s1 = "Èà¤Ï";
3295 else if (ap_r_ptr->flags1 & (RF1_MALE)) s1 = "He is ";
3299 /* Use a preposition */
3308 /* Scan all objects being carried */
3309 for (this_o_idx = m_ptr->hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
3311 char o_name[MAX_NLEN];
3315 /* Acquire object */
3316 o_ptr = &o_list[this_o_idx];
3318 /* Acquire next object */
3319 next_o_idx = o_ptr->next_o_idx;
3321 /* Obtain an object description */
3322 object_desc(o_name, o_ptr, TRUE, 3);
3324 /* Describe the object */
3326 sprintf(out_val, "%s%s%s%s[%s]", s1, o_name, s2, s3, info);
3328 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, o_name, info);
3332 move_cursor_relative(y, x);
3335 /* Always stop at "normal" keys */
3336 if ((query != '\r') && (query != '\n') && (query != ' ') && (query != 'x')) return query;
3338 /* Sometimes stop at "space" key */
3339 if ((query == ' ') && !(mode & (TARGET_LOOK))) return query;
3341 /* Change the intro */
3345 s2 = "also carrying ";
3349 /* Use a preposition */
3359 #ifdef ALLOW_EASY_FLOOR
3368 char o_name[MAX_NLEN];
3372 /* Acquire object */
3373 o_ptr = &o_list[floor_list[0]];
3375 /* Describe the object */
3376 object_desc(o_name, o_ptr, TRUE, 3);
3380 sprintf(out_val, "%s%s%s%s[%s]",
3381 s1, o_name, s2, s3, info);
3383 sprintf(out_val, "%s%s%s%s [%s]",
3384 s1, s2, s3, o_name, info);
3388 move_cursor_relative(y, x);
3397 /* Provide one cushion before item listing */
3400 /* Display rough information about items */
3402 sprintf(out_val, "%s %d¸Ä¤Î¥¢¥¤¥Æ¥à%s%s ['x'¤Ç°ìÍ÷, %s]",
3403 s1, floor_num, s2, s3, info);
3405 sprintf(out_val, "%s%s%sa pile of %d items [x,%s]",
3406 s1, s2, s3, floor_num, info);
3410 move_cursor_relative(y, x);
3415 /* No request for listing */
3416 if (query != 'x' && query != ' ') return query;
3420 /** Display list of items **/
3422 /* Continue scrolling list if requested */
3431 (void)show_floor(0, y, x, &min_width);
3435 sprintf(out_val, "%s %d¸Ä¤Î¥¢¥¤¥Æ¥à%s%s [Enter¤Ç¼¡¤Ø, %s]",
3436 s1, floor_num, s2, s3, info);
3438 sprintf(out_val, "%s%s%sa pile of %d items [Enter,%s]",
3439 s1, s2, s3, floor_num, info);
3450 /* Exit unless 'Enter' */
3451 if (query != '\n' && query != '\r')
3456 /* Get the object being moved. */
3457 o_idx = c_ptr->o_idx;
3459 /* Only rotate a pile of two or more objects. */
3460 if (!(o_idx && o_list[o_idx].next_o_idx)) continue;
3462 /* Remove the first object from the list. */
3463 excise_object_idx(o_idx);
3465 /* Find end of the list. */
3467 while (o_list[i].next_o_idx)
3468 i = o_list[i].next_o_idx;
3470 /* Add after the last object. */
3471 o_list[i].next_o_idx = o_idx;
3473 /* Loop and re-display the list */
3479 #endif /* ALLOW_EASY_FLOOR */
3482 /* Scan all objects in the grid */
3483 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
3487 /* Acquire object */
3488 o_ptr = &o_list[this_o_idx];
3490 /* Acquire next object */
3491 next_o_idx = o_ptr->next_o_idx;
3496 char o_name[MAX_NLEN];
3501 /* Obtain an object description */
3502 object_desc(o_name, o_ptr, TRUE, 3);
3504 /* Describe the object */
3506 sprintf(out_val, "%s%s%s%s[%s]", s1, o_name, s2, s3, info);
3508 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, o_name, info);
3512 move_cursor_relative(y, x);
3515 /* Always stop at "normal" keys */
3516 if ((query != '\r') && (query != '\n') && (query != ' ') && (query != 'x')) return query;
3518 /* Sometimes stop at "space" key */
3519 if ((query == ' ') && !(mode & TARGET_LOOK)) return query;
3521 /* Change the intro */
3531 if (o_ptr->number != 1) s1 = "¤½¤ì¤é¤Ï";
3533 if (o_ptr->number != 1) s1 = "They are ";
3549 /* Feature code (applying "mimic" field) */
3550 feat = f_info[c_ptr->mimic ? c_ptr->mimic : c_ptr->feat].mimic;
3552 /* Require knowledge about grid, or ability to see grid */
3553 if (!(c_ptr->info & CAVE_MARK) && !player_can_see_bold(y, x))
3555 /* Forget feature */
3559 /* Terrain feature if needed */
3560 if (boring || (feat > FEAT_INVIS))
3564 /* Hack -- special handling for building doors */
3565 if ((feat >= FEAT_BLDG_HEAD) && (feat <= FEAT_BLDG_TAIL))
3567 name = building[feat - FEAT_BLDG_HEAD].name;
3569 else if (feat == FEAT_ENTRANCE)
3572 name = format("%s(%d³¬ÁêÅö)", d_text + d_info[c_ptr->special].text, d_info[c_ptr->special].mindepth);
3574 name = format("%s(level %d)", d_text + d_info[c_ptr->special].text, d_info[c_ptr->special].mindepth);
3577 else if (feat == FEAT_TOWN)
3579 name = town[c_ptr->special].name;
3581 else if (p_ptr->wild_mode && (feat == FEAT_FLOOR))
3591 name = f_name + f_info[feat].name;
3596 if (*s2 && ((feat >= FEAT_MINOR_GLYPH) &&
3597 (feat <= FEAT_PATTERN_XTRA2)))
3606 else if (*s2 && ((feat >= FEAT_DOOR_HEAD) &&
3607 (feat <= FEAT_PERM_SOLID)))
3616 else if (*s2 && (feat == FEAT_TOWN))
3626 /* Hack -- special introduction for store & building doors -KMW- */
3627 if (((feat >= FEAT_SHOP_HEAD) && (feat <= FEAT_SHOP_TAIL)) ||
3628 ((feat >= FEAT_BLDG_HEAD) && (feat <= FEAT_BLDG_TAIL)) ||
3629 (feat == FEAT_MUSEUM) ||
3630 (feat == FEAT_ENTRANCE))
3639 else if ((feat == FEAT_TOWN) || (feat == FEAT_FLOOR) || (feat == FEAT_DIRT) || (feat == FEAT_FLOWER))
3647 /* Pick proper indefinite article */
3649 s3 = (is_a_vowel(name[0])) ? "an " : "a ";
3653 /* Display a message */
3656 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);
3658 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);
3662 sprintf(out_val, "%s%s%s%s[%s]", s1, name, s2, s3, info);
3664 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, name, info);
3668 move_cursor_relative(y, x);
3671 /* Always stop at "normal" keys */
3672 if ((query != '\r') && (query != '\n') && (query != ' ')) return query;
3675 /* Stop on everything but "return" */
3676 if ((query != '\r') && (query != '\n')) return query;
3678 /* Repeat forever */
3684 * Handle "target" and "look".
3686 * Note that this code can be called from "get_aim_dir()".
3688 * All locations must be on the current panel. Consider the use of
3689 * "panel_bounds()" to allow "off-panel" targets, perhaps by using
3690 * some form of "scrolling" the map around the cursor. XXX XXX XXX
3691 * That is, consider the possibility of "auto-scrolling" the screen
3692 * while the cursor moves around. This may require changes in the
3693 * "update_mon()" code to allow "visibility" even if off panel, and
3694 * may require dynamic recalculation of the "temp" grid set.
3696 * Hack -- targeting/observing an "outer border grid" may induce
3697 * problems, so this is not currently allowed.
3699 * The player can use the direction keys to move among "interesting"
3700 * grids in a heuristic manner, or the "space", "+", and "-" keys to
3701 * move through the "interesting" grids in a sequential manner, or
3702 * can enter "location" mode, and use the direction keys to move one
3703 * grid at a time in any direction. The "t" (set target) command will
3704 * only target a monster (as opposed to a location) if the monster is
3705 * target_able and the "interesting" mode is being used.
3707 * The current grid is described using the "look" method above, and
3708 * a new command may be entered at any time, but note that if the
3709 * "TARGET_LOOK" bit flag is set (or if we are in "location" mode,
3710 * where "space" has no obvious meaning) then "space" will scan
3711 * through the description of the current grid until done, instead
3712 * of immediately jumping to the next "interesting" grid. This
3713 * allows the "target" command to retain its old semantics.
3715 * The "*", "+", and "-" keys may always be used to jump immediately
3716 * to the next (or previous) interesting grid, in the proper mode.
3718 * The "return" key may always be used to scan through a complete
3719 * grid description (forever).
3721 * This command will cancel any old target, even if used from
3722 * inside the "look" command.
3724 bool target_set(int mode)
3744 get_screen_size(&wid, &hgt);
3750 /* Cancel tracking */
3751 /* health_track(0); */
3754 /* Prepare the "temp" array */
3755 target_set_prepare(mode);
3757 /* Start near the player */
3763 /* Interesting grids */
3769 if (!(mode & TARGET_LOOK)) prt_path(y, x);
3772 c_ptr = &cave[y][x];
3775 if (target_able(c_ptr->m_idx))
3778 strcpy(info, "q»ß t·è p¼« o¸½ +¼¡ -Á°");
3780 strcpy(info, "q,t,p,o,+,-,<dir>");
3785 /* Dis-allow target */
3789 strcpy(info, "q»ß p¼« o¸½ +¼¡ -Á°");
3791 strcpy(info, "q,p,o,+,-,<dir>");
3796 /* Describe and Prompt */
3797 while (!(query = target_set_aux(y, x, mode, info)));
3799 /* Cancel tracking */
3800 /* health_track(0); */
3802 /* Assume no "direction" */
3807 if (query == '\r') query = 't';
3825 if (target_able(c_ptr->m_idx))
3827 health_track(c_ptr->m_idx);
3828 target_who = c_ptr->m_idx;
3847 if (!expand_list) done = TRUE;
3857 if (!expand_list) done = TRUE;
3864 /* Recenter the map around the player */
3868 p_ptr->update |= (PU_MONSTERS);
3871 p_ptr->redraw |= (PR_MAP);
3874 p_ptr->window |= (PW_OVERHEAD);
3879 /* Recalculate interesting grids */
3880 target_set_prepare(mode);
3899 /* Extract the action (if any) */
3900 d = get_keymap_dir(query);
3907 /* Hack -- move around */
3910 /* Modified to scroll to monster */
3911 int y2 = panel_row_min;
3912 int x2 = panel_col_min;
3914 /* Find a new monster */
3915 i = target_pick(temp_y[m], temp_x[m], ddy[d], ddx[d]);
3917 /* Request to target past last interesting grid */
3918 while (flag && (i < 0))
3920 /* Note the change */
3921 if (change_panel(ddy[d], ddx[d]))
3926 /* Recalculate interesting grids */
3927 target_set_prepare(mode);
3929 /* Look at interesting grids */
3932 /* Find a new monster */
3933 i = target_pick(v, u, ddy[d], ddx[d]);
3939 /* Nothing interesting */
3945 /* Restore previous position */
3948 panel_bounds_center();
3951 p_ptr->update |= (PU_MONSTERS);
3954 p_ptr->redraw |= (PR_MAP);
3957 p_ptr->window |= (PW_OVERHEAD);
3962 /* Recalculate interesting grids */
3963 target_set_prepare(mode);
3965 /* Look at boring grids */
3972 /* Do not move horizontally if unnecessary */
3973 if (((x < panel_col_min + wid / 2) && (dx > 0)) ||
3974 ((x > panel_col_min + wid / 2) && (dx < 0)))
3979 /* Do not move vertically if unnecessary */
3980 if (((y < panel_row_min + hgt / 2) && (dy > 0)) ||
3981 ((y > panel_row_min + hgt / 2) && (dy < 0)))
3986 /* Apply the motion */
3987 if ((y >= panel_row_min+hgt) || (y < panel_row_min) ||
3988 (x >= panel_col_min+wid) || (x < panel_col_min))
3990 if (change_panel(dy, dx)) target_set_prepare(mode);
3993 /* Slide into legality */
3994 if (x >= cur_wid-1) x = cur_wid - 2;
3995 else if (x <= 0) x = 1;
3997 /* Slide into legality */
3998 if (y >= cur_hgt-1) y = cur_hgt- 2;
3999 else if (y <= 0) y = 1;
4008 /* Arbitrary grids */
4011 bool move_fast = FALSE;
4013 if (!(mode & TARGET_LOOK)) prt_path(y, x);
4016 c_ptr = &cave[y][x];
4018 /* Default prompt */
4020 strcpy(info, "q»ß t·è p¼« m¶á +¼¡ -Á°");
4022 strcpy(info, "q,t,p,m,+,-,<dir>");
4026 /* Describe and Prompt (enable "TARGET_LOOK") */
4027 while (!(query = target_set_aux(y, x, mode | TARGET_LOOK, info)));
4029 /* Cancel tracking */
4030 /* health_track(0); */
4032 /* Assume no direction */
4037 if (query == '\r') query = 't';
4040 /* Analyze the keypress */
4064 /* Recenter the map around the player */
4068 p_ptr->update |= (PU_MONSTERS);
4071 p_ptr->redraw |= (PR_MAP);
4074 p_ptr->window |= (PW_OVERHEAD);
4079 /* Recalculate interesting grids */
4080 target_set_prepare(mode);
4102 /* Pick a nearby monster */
4103 for (i = 0; i < temp_n; i++)
4105 t = distance(y, x, temp_y[i], temp_x[i]);
4115 /* Nothing interesting */
4116 if (bd == 999) flag = FALSE;
4123 /* Extract the action (if any) */
4124 d = get_keymap_dir(query);
4126 /* XTRA HACK MOVEFAST */
4127 if (isupper(query)) move_fast = TRUE;
4134 /* Handle "direction" */
4140 /* XTRA HACK MOVEFAST */
4143 int mag = MIN(wid / 2, hgt / 2);
4153 /* Do not move horizontally if unnecessary */
4154 if (((x < panel_col_min + wid / 2) && (dx > 0)) ||
4155 ((x > panel_col_min + wid / 2) && (dx < 0)))
4160 /* Do not move vertically if unnecessary */
4161 if (((y < panel_row_min + hgt / 2) && (dy > 0)) ||
4162 ((y > panel_row_min + hgt / 2) && (dy < 0)))
4167 /* Apply the motion */
4168 if ((y >= panel_row_min + hgt) || (y < panel_row_min) ||
4169 (x >= panel_col_min + wid) || (x < panel_col_min))
4171 if (change_panel(dy, dx)) target_set_prepare(mode);
4174 /* Slide into legality */
4175 if (x >= cur_wid-1) x = cur_wid - 2;
4176 else if (x <= 0) x = 1;
4178 /* Slide into legality */
4179 if (y >= cur_hgt-1) y = cur_hgt- 2;
4180 else if (y <= 0) y = 1;
4188 /* Clear the top line */
4191 /* Recenter the map around the player */
4195 p_ptr->update |= (PU_MONSTERS);
4198 p_ptr->redraw |= (PR_MAP);
4201 p_ptr->window |= (PW_OVERHEAD);
4206 /* Failure to set target */
4207 if (!target_who) return (FALSE);
4215 * Get an "aiming direction" from the user.
4217 * The "dir" is loaded with 1,2,3,4,6,7,8,9 for "actual direction", and
4218 * "0" for "current target", and "-1" for "entry aborted".
4220 * Note that "Force Target", if set, will pre-empt user interaction,
4221 * if there is a usable target already set.
4223 * Note that confusion over-rides any (explicit?) user choice.
4225 bool get_aim_dir(int *dp)
4236 /* Global direction */
4239 /* Hack -- auto-target if requested */
4240 if (use_old_target && target_okay()) dir = 5;
4242 #ifdef ALLOW_REPEAT /* TNB */
4244 if (repeat_pull(dp))
4249 if (!(*dp == 5 && !target_okay()))
4251 /* return (TRUE); */
4256 #endif /* ALLOW_REPEAT -- TNB */
4258 /* Ask until satisfied */
4261 /* Choose a prompt */
4265 p = "Êý¸þ ('*'¤Ç¥¿¡¼¥²¥Ã¥ÈÁªÂò, ESC¤ÇÃæÃÇ)? ";
4267 p = "Direction ('*' to choose a target, Escape to cancel)? ";
4274 p = "Êý¸þ ('5'¤Ç¥¿¡¼¥²¥Ã¥È¤Ø, '*'¤Ç¥¿¡¼¥²¥Ã¥ÈºÆÁªÂò, ESC¤ÇÃæÃÇ)? ";
4276 p = "Direction ('5' for target, '*' to re-target, Escape to cancel)? ";
4281 /* Get a command (or Cancel) */
4282 if (!get_com(p, &command, TRUE)) break;
4286 if (command == '\r') command = 't';
4289 /* Convert various keys to "standard" keys */
4292 /* Use current target */
4303 /* Set new target */
4308 if (target_set(TARGET_KILL)) dir = 5;
4314 /* Extract the action (if any) */
4315 dir = get_keymap_dir(command);
4321 /* Verify requested targets */
4322 if ((dir == 5) && !target_okay()) dir = 0;
4331 project_length = 0; /* reset to default */
4335 /* Save the direction */
4338 /* Check for confusion */
4339 if (p_ptr->confused)
4342 /* Random direction */
4343 dir = ddd[randint0(8)];
4346 /* Notice confusion */
4347 if (command_dir != dir)
4351 msg_print("¤¢¤Ê¤¿¤Ïº®Í𤷤Ƥ¤¤ë¡£");
4353 msg_print("You are confused.");
4358 /* Save direction */
4361 #ifdef ALLOW_REPEAT /* TNB */
4363 /* repeat_push(dir); */
4364 repeat_push(command_dir);
4366 #endif /* ALLOW_REPEAT -- TNB */
4368 /* A "valid" direction was entered */
4375 * Request a "movement" direction (1,2,3,4,6,7,8,9) from the user,
4376 * and place it into "command_dir", unless we already have one.
4378 * This function should be used for all "repeatable" commands, such as
4379 * run, walk, open, close, bash, disarm, spike, tunnel, etc, as well
4380 * as all commands which must reference a grid adjacent to the player,
4381 * and which may not reference the grid under the player. Note that,
4382 * for example, it is no longer possible to "disarm" or "open" chests
4383 * in the same grid as the player.
4385 * Direction "5" is illegal and will (cleanly) abort the command.
4387 * This function tracks and uses the "global direction", and uses
4388 * that as the "desired direction", to which "confusion" is applied.
4390 bool get_rep_dir(int *dp, bool under)
4397 /* Global direction */
4400 #ifdef ALLOW_REPEAT /* TNB */
4402 if (repeat_pull(dp))
4405 /* return (TRUE); */
4408 #endif /* ALLOW_REPEAT -- TNB */
4410 /* Get a direction */
4415 /* Get a command (or Cancel) */
4417 if (!get_com("Êý¸þ (ESC¤ÇÃæÃÇ)? ", &ch, TRUE)) break;
4419 if (!get_com("Direction (Escape to cancel)? ", &ch, TRUE)) break;
4423 /* Look up the direction */
4424 dir = get_keymap_dir(ch);
4430 /* Prevent weirdness */
4431 if ((dir == 5) && (!under)) dir = 0;
4434 if (!dir) return (FALSE);
4436 /* Save desired direction */
4439 /* Apply "confusion" */
4440 if (p_ptr->confused)
4442 /* Standard confusion */
4443 if (randint0(100) < 75)
4445 /* Random direction */
4446 dir = ddd[randint0(8)];
4449 else if (p_ptr->riding)
4451 monster_type *m_ptr = &m_list[p_ptr->riding];
4452 monster_race *r_ptr = &r_info[m_ptr->r_idx];
4454 if (m_ptr->confused)
4456 /* Standard confusion */
4457 if (randint0(100) < 75)
4459 /* Random direction */
4460 dir = ddd[randint0(8)];
4463 else if ((r_ptr->flags1 & RF1_RAND_50) && (r_ptr->flags1 & RF1_RAND_25) && (randint0(100) < 50))
4465 /* Random direction */
4466 dir = ddd[randint0(8)];
4468 else if ((r_ptr->flags1 & RF1_RAND_50) && (randint0(100) < 25))
4470 /* Random direction */
4471 dir = ddd[randint0(8)];
4475 /* Notice confusion */
4476 if (command_dir != dir)
4478 if (p_ptr->confused)
4482 msg_print("¤¢¤Ê¤¿¤Ïº®Í𤷤Ƥ¤¤ë¡£");
4484 msg_print("You are confused.");
4490 monster_type *m_ptr = &m_list[p_ptr->riding];
4492 monster_desc(m_name, m_ptr, 0);
4493 if (m_ptr->confused)
4496 msg_format("%s¤Ïº®Í𤷤Ƥ¤¤ë¡£", m_name);
4498 msg_format("%^s is confusing.", m_name);
4505 msg_format("%s¤Ï»×¤¤Ä̤ê¤ËÆ°¤¤¤Æ¤¯¤ì¤Ê¤¤¡£", m_name);
4507 msg_format("You cannot control %s.", m_name);
4513 /* Save direction */
4516 #ifdef ALLOW_REPEAT /* TNB */
4518 /* repeat_push(dir); */
4519 repeat_push(command_dir);
4521 #endif /* ALLOW_REPEAT -- TNB */
4528 bool get_rep_dir2(int *dp)
4535 /* Global direction */
4538 #ifdef ALLOW_REPEAT /* TNB */
4540 if (repeat_pull(dp))
4543 /* return (TRUE); */
4546 #endif /* ALLOW_REPEAT -- TNB */
4548 /* Get a direction */
4553 /* Get a command (or Cancel) */
4555 if (!get_com("Êý¸þ (ESC¤ÇÃæÃÇ)? ", &ch, TRUE)) break;
4557 if (!get_com("Direction (Escape to cancel)? ", &ch, TRUE)) break;
4561 /* Look up the direction */
4562 dir = get_keymap_dir(ch);
4568 /* Prevent weirdness */
4569 if (dir == 5) dir = 0;
4572 if (!dir) return (FALSE);
4574 /* Save desired direction */
4577 /* Apply "confusion" */
4578 if (p_ptr->confused)
4580 /* Standard confusion */
4581 if (randint0(100) < 75)
4583 /* Random direction */
4584 dir = ddd[randint0(8)];
4588 /* Notice confusion */
4589 if (command_dir != dir)
4593 msg_print("¤¢¤Ê¤¿¤Ïº®Í𤷤Ƥ¤¤ë¡£");
4595 msg_print("You are confused.");
4600 /* Save direction */
4603 #ifdef ALLOW_REPEAT /* TNB */
4605 /* repeat_push(dir); */
4606 repeat_push(command_dir);
4608 #endif /* ALLOW_REPEAT -- TNB */
4615 int get_chaos_patron(void)
4617 return ((p_ptr->age + p_ptr->sc) % MAX_PATRON);
4621 void gain_level_reward(int chosen_reward)
4625 char wrath_reason[32] = "";
4626 int nasty_chance = 6;
4627 int dummy = 0, dummy2 = 0;
4630 char o_name[MAX_NLEN];
4636 if (multi_rew) return;
4637 else multi_rew = TRUE;
4641 if (p_ptr->lev == 13) nasty_chance = 2;
4642 else if (!(p_ptr->lev % 13)) nasty_chance = 3;
4643 else if (!(p_ptr->lev % 14)) nasty_chance = 12;
4645 if (one_in_(nasty_chance))
4646 type = randint1(20); /* Allow the 'nasty' effects */
4648 type = randint1(15) + 5; /* Or disallow them */
4650 if (type < 1) type = 1;
4651 if (type > 20) type = 20;
4656 sprintf(wrath_reason, "%s¤ÎÅܤê",
4657 chaos_patrons[p_ptr->chaos_patron]);
4659 sprintf(wrath_reason, "the Wrath of %s",
4660 chaos_patrons[p_ptr->chaos_patron]);
4664 effect = chaos_rewards[p_ptr->chaos_patron][type];
4666 if (one_in_(6) && !chosen_reward)
4669 msg_format("%^s¤ÏË«Èþ¤È¤·¤Æ¤¢¤Ê¤¿¤òÆÍÁ³ÊÑ°Û¤µ¤»¤¿¡£",
4670 chaos_patrons[p_ptr->chaos_patron]);
4672 msg_format("%^s rewards you with a mutation!",
4673 chaos_patrons[p_ptr->chaos_patron]);
4676 (void)gain_random_mutation(0);
4678 reward = "ÊÑ°Û¤·¤¿¡£";
4680 reward = "mutation";
4685 switch (chosen_reward ? chosen_reward : effect)
4689 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
4690 chaos_patrons[p_ptr->chaos_patron]);
4692 msg_format("The voice of %s booms out:",
4693 chaos_patrons[p_ptr->chaos_patron]);
4697 msg_print("¡ÖÆò¡¢¿·¤¿¤Ê¤ë»Ñ¤òɬÍפȤ»¤ê¡ª¡×");
4699 msg_print("'Thou needst a new form, mortal!'");
4704 reward = "ÊÑ°Û¤·¤¿¡£";
4706 reward = "polymorphing";
4711 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
4712 chaos_patrons[p_ptr->chaos_patron]);
4714 msg_format("The voice of %s booms out:",
4715 chaos_patrons[p_ptr->chaos_patron]);
4719 msg_print("¡ÖÆò¤ÏÎɤ¯¹Ô¤¤¤¿¤ê¡ªÂ³¤±¤è¡ª¡×");
4721 msg_print("'Well done, mortal! Lead on!'");
4724 if (p_ptr->prace == RACE_ANDROID)
4727 msg_print("¤·¤«¤·²¿¤âµ¯¤³¤é¤Ê¤«¤Ã¤¿¡£");
4729 msg_print("But, nothing happen.");
4732 else if (p_ptr->exp < PY_MAX_EXP)
4734 s32b ee = (p_ptr->exp / 2) + 10;
4735 if (ee > 100000L) ee = 100000L;
4737 msg_print("¹¹¤Ë·Ð¸³¤òÀѤó¤À¤è¤¦¤Êµ¤¤¬¤¹¤ë¡£");
4739 msg_print("You feel more experienced.");
4744 reward = "·Ð¸³ÃͤòÆÀ¤¿";
4746 reward = "experience";
4752 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
4753 chaos_patrons[p_ptr->chaos_patron]);
4755 msg_format("The voice of %s booms out:",
4756 chaos_patrons[p_ptr->chaos_patron]);
4760 msg_print("¡Ö²¼Ëͤ衢Æò¤½¤ì¤ËÃͤ»¤º¡£¡×");
4762 msg_print("'Thou didst not deserve that, slave.'");
4765 if (p_ptr->prace == RACE_ANDROID)
4768 msg_print("¤·¤«¤·²¿¤âµ¯¤³¤é¤Ê¤«¤Ã¤¿¡£");
4770 msg_print("But, nothing happen.");
4775 lose_exp(p_ptr->exp / 6);
4777 reward = "·Ð¸³Ãͤò¼º¤Ã¤¿¡£";
4779 reward = "losing experience";
4785 msg_format("%s¤ÎÀ¼¤¬¤µ¤µ¤ä¤¤¤¿:",
4786 chaos_patrons[p_ptr->chaos_patron]);
4788 msg_format("The voice of %s whispers:",
4789 chaos_patrons[p_ptr->chaos_patron]);
4793 msg_print("¡Ö²æ¤¬Í¿¤¨¤·Êª¤ò¸ÌÀ¤Ë»È¤¦¤Ù¤·¡£¡×");
4795 msg_print("'Use my gift wisely.'");
4798 acquirement(py, px, 1, FALSE, FALSE);
4800 reward = "¾å¼Á¤Ê¥¢¥¤¥Æ¥à¤ò¼ê¤ËÆþ¤ì¤¿¡£";
4802 reward = "a good item";
4807 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
4808 chaos_patrons[p_ptr->chaos_patron]);
4810 msg_format("The voice of %s booms out:",
4811 chaos_patrons[p_ptr->chaos_patron]);
4815 msg_print("¡Ö²æ¤¬Í¿¤¨¤·Êª¤ò¸ÌÀ¤Ë»È¤¦¤Ù¤·¡£¡×");
4817 msg_print("'Use my gift wisely.'");
4820 acquirement(py, px, 1, TRUE, FALSE);
4822 reward = "¹âµéÉʤΥ¢¥¤¥Æ¥à¤ò¼ê¤ËÆþ¤ì¤¿¡£";
4824 reward = "an excellent item";
4829 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
4830 chaos_patrons[p_ptr->chaos_patron]);
4832 msg_format("The voice of %s booms out:",
4833 chaos_patrons[p_ptr->chaos_patron]);
4837 msg_print("¡ÖÆò¤Î¹Ô¤¤¤Ïµ®¤·õ¤ËÃͤ»¤ê¡£¡×");
4839 msg_print("'Thy deed hath earned thee a worthy blade.'");
4842 /* Get local object */
4845 switch (randint1(p_ptr->lev))
4851 dummy2 = SV_MAIN_GAUCHE;
4860 dummy2 = SV_SMALL_SWORD;
4863 dummy2 = SV_BASILLARD;
4865 case 11: case 12: case 13:
4866 dummy2 = SV_SHORT_SWORD;
4872 dummy2 = SV_CUTLASS;
4875 dummy2 = SV_WAKIZASHI;
4878 dummy2 = SV_KHOPESH;
4884 dummy2 = SV_BROAD_SWORD;
4887 dummy2 = SV_LONG_SWORD;
4890 dummy2 = SV_SCIMITAR;
4893 dummy2 = SV_NINJATO;
4899 dummy2 = SV_BASTARD_SWORD;
4902 dummy2 = SV_GREAT_SCIMITAR;
4905 dummy2 = SV_CLAYMORE;
4908 dummy2 = SV_ESPADON;
4911 dummy2 = SV_TWO_HANDED_SWORD;
4914 dummy2 = SV_FLAMBERGE;
4917 dummy2 = SV_NO_DACHI;
4920 dummy2 = SV_EXECUTIONERS_SWORD;
4923 dummy2 = SV_ZWEIHANDER;
4926 dummy2 = SV_HAYABUSA;
4929 dummy2 = SV_BLADE_OF_CHAOS;
4932 object_prep(q_ptr, lookup_kind(dummy, dummy2));
4933 q_ptr->to_h = 3 + randint1(dun_level) % 10;
4934 q_ptr->to_d = 3 + randint1(dun_level) % 10;
4935 one_resistance(q_ptr);
4936 q_ptr->name2 = EGO_CHAOTIC;
4938 /* Drop it in the dungeon */
4939 (void)drop_near(q_ptr, -1, py, px);
4941 reward = "(º®ÆÙ)¤ÎÉð´ï¤ò¼ê¤ËÆþ¤ì¤¿¡£";
4943 reward = "chaos weapon";
4948 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
4949 chaos_patrons[p_ptr->chaos_patron]);
4951 msg_format("The voice of %s booms out:",
4952 chaos_patrons[p_ptr->chaos_patron]);
4956 msg_print("¡ÖÆò¤Î¹Ô¤¤¤Ïµ®¤Ê󤤤ËÃͤ»¤ê¡£¡×");
4958 msg_print("'Thy deed hath earned thee a worthy reward.'");
4961 acquirement(py, px, randint1(2) + 1, FALSE, FALSE);
4963 reward = "¾å¼Á¤Ê¥¢¥¤¥Æ¥à¤ò¼ê¤ËÆþ¤ì¤¿¡£";
4965 reward = "good items";
4970 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
4971 chaos_patrons[p_ptr->chaos_patron]);
4973 msg_format("The voice of %s booms out:",
4974 chaos_patrons[p_ptr->chaos_patron]);
4978 msg_print("¡Ö²¼Ëͤ衢Æò¤Î¸¥¿È¤Ø¤Î²æ¤¬Àˤ·¤ß̵¤Ê󤤤ò¸«¤ë¤¬¤è¤¤¡£¡×");
4980 msg_print("'Behold, mortal, how generously I reward thy loyalty.'");
4983 acquirement(py, px, randint1(2) + 1, TRUE, FALSE);
4985 reward = "¹âµéÉʤΥ¢¥¤¥Æ¥à¤ò¼ê¤ËÆþ¤ì¤¿¡£";
4987 reward = "excellent items";
4992 msg_format("%s¤ÎÀ¼¤¬¹ì¤ÅϤä¿:",
4993 chaos_patrons[p_ptr->chaos_patron]);
4995 msg_format("The voice of %s thunders:",
4996 chaos_patrons[p_ptr->chaos_patron]);
5000 msg_print("¡Ö²¼Ëͤ衢ÆòÐþËý¤Ê¤ê¡£¡×");
5002 msg_print("'Thou art growing arrogant, mortal.'");
5005 (void)activate_ty_curse(FALSE, &count);
5007 reward = "²Ò¡¹¤·¤¤¼ö¤¤¤ò¤«¤±¤é¤ì¤¿¡£";
5014 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5015 chaos_patrons[p_ptr->chaos_patron]);
5017 msg_format("The voice of %s booms out:",
5018 chaos_patrons[p_ptr->chaos_patron]);
5022 msg_print("¡Ö²æ¤¬²¼Ëͤ¿¤Á¤è¡¢¤«¤ÎÐþËý¤Ê¤ë¼Ô¤òÅݤ¹¤Ù¤·¡ª¡×");
5024 msg_print("'My pets, destroy the arrogant mortal!'");
5027 for (dummy = 0; dummy < randint1(5) + 1; dummy++)
5029 (void)summon_specific(0, py, px, dun_level, 0, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET));
5032 reward = "¥â¥ó¥¹¥¿¡¼¤ò¾¤´¤µ¤ì¤¿¡£";
5034 reward = "summoning hostile monsters";
5039 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5040 chaos_patrons[p_ptr->chaos_patron]);
5042 msg_format("The voice of %s booms out:",
5043 chaos_patrons[p_ptr->chaos_patron]);
5047 msg_print("¡ÖÆò¡¢¤è¤ê¶¯¤Å¨¤òɬÍפȤ»¤ê¡ª¡×");
5049 msg_print("'Thou needst worthier opponents!'");
5052 activate_hi_summon(py, px, FALSE);
5054 reward = "¥â¥ó¥¹¥¿¡¼¤ò¾¤´¤µ¤ì¤¿¡£";
5056 reward = "summoning many hostile monsters";
5061 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5062 chaos_patrons[p_ptr->chaos_patron]);
5064 msg_format("The voice of %s booms out:",
5065 chaos_patrons[p_ptr->chaos_patron]);
5069 msg_print("¡Ö»à¤ÈÇ˲õ¤³¤½²æ¤¬´î¤Ó¤Ê¤ê¡ª¡×");
5071 msg_print("'Death and destruction! This pleaseth me!'");
5076 reward = "¥«¥ª¥¹¤ÎÎϤ¬±²´¬¤¤¤¿¡£";
5078 reward = "calling chaos";
5083 msg_format("%s¤ÎÀ¼¤¬ÌĤê¶Á¤¤¤¿:",
5084 chaos_patrons[p_ptr->chaos_patron]);
5086 msg_format("The voice of %s rings out:",
5087 chaos_patrons[p_ptr->chaos_patron]);
5091 msg_print("¡Öα¤Þ¤ë¤Î¤À¡¢²¼Ëͤ衣;¤¬Æò¤ÎÆùÂΤòÃ䨤󡣡×");
5093 msg_print("'Stay, mortal, and let me mold thee.'");
5096 if (one_in_(3) && !(chaos_stats[p_ptr->chaos_patron] < 0))
5097 do_inc_stat(chaos_stats[p_ptr->chaos_patron]);
5099 do_inc_stat(randint0(6));
5101 reward = "ǽÎÏÃͤ¬¾å¤¬¤Ã¤¿¡£";
5103 reward = "increasing a stat";
5108 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5109 chaos_patrons[p_ptr->chaos_patron]);
5111 msg_format("The voice of %s booms out:",
5112 chaos_patrons[p_ptr->chaos_patron]);
5116 msg_print("¡Ö²¼Ëͤ衢;¤ÏÆò¤ËË°¤ß¤¿¤ê¡£¡×");
5118 msg_print("'I grow tired of thee, mortal.'");
5121 if (one_in_(3) && !(chaos_stats[p_ptr->chaos_patron] < 0))
5122 do_dec_stat(chaos_stats[p_ptr->chaos_patron]);
5124 (void)do_dec_stat(randint0(6));
5126 reward = "ǽÎÏÃͤ¬²¼¤¬¤Ã¤¿¡£";
5128 reward = "decreasing a stat";
5133 msg_format("%s¤ÎÀ¼¤¬¹ì¤ÅϤä¿:",
5134 chaos_patrons[p_ptr->chaos_patron]);
5136 msg_format("The voice of %s thunders:",
5137 chaos_patrons[p_ptr->chaos_patron]);
5141 msg_print("¡ÖÆò¡¢¸¬µõ¤¿¤ë¤³¤È¤ò³Ø¤Ö¤Ù¤·¡ª¡×");
5142 msg_print("¤¢¤Ê¤¿¤Ï°ÊÁ°¤è¤ê¼å¤¯¤Ê¤Ã¤¿¡ª");
5144 msg_print("'Thou needst a lesson in humility, mortal!'");
5145 msg_print("You feel less powerful!");
5148 for (dummy = 0; dummy < 6; dummy++)
5150 (void)dec_stat(dummy, 10 + randint1(15), TRUE);
5153 reward = "Á´Ç½ÎÏÃͤ¬²¼¤¬¤Ã¤¿¡£";
5155 reward = "decreasing all stats";
5160 msg_format("%s¤ÎÎϤ¬¿¨¤ì¤ë¤Î¤ò´¶¤¸¤¿¡£",
5162 msg_format("You feel the power of %s touch you.",
5165 chaos_patrons[p_ptr->chaos_patron]);
5168 reward = "½ý¤¬ÊѲ½¤·¤¿¡£";
5170 reward = "polymorphing wounds";
5175 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5176 chaos_patrons[p_ptr->chaos_patron]);
5178 msg_format("The voice of %s booms out:",
5179 chaos_patrons[p_ptr->chaos_patron]);
5183 msg_print("¡Ö²æ¤¬¤µ¤µ¤ä¤«¤Ê¤ë»òʪ¤ò¼õ¤±¤È¤ë¤¬¤è¤¤¡ª¡×");
5185 msg_print("'Receive this modest gift from me!'");
5188 for (dummy = 0; dummy < 6; dummy++)
5190 (void)do_inc_stat(dummy);
5193 reward = "Á´Ç½ÎÏÃͤ¬¾å¤¬¤Ã¤¿¡£";
5195 reward = "increasing all stats";
5200 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5201 chaos_patrons[p_ptr->chaos_patron]);
5203 msg_format("The voice of %s booms out:",
5204 chaos_patrons[p_ptr->chaos_patron]);
5208 msg_print("¡Ö¶ì¤·¤à¤¬¤è¤¤¡¢ÌµÇ½¤Ê¶ò¤«¼Ô¤è¡ª¡×");
5210 msg_print("'Suffer, pathetic fool!'");
5213 fire_ball(GF_DISINTEGRATE, 0, p_ptr->lev * 4, 4);
5214 take_hit(DAMAGE_NOESCAPE, p_ptr->lev * 4, wrath_reason, -1);
5216 reward = "ʬ²ò¤Îµå¤¬È¯À¸¤·¤¿¡£";
5218 reward = "generating disintegration ball";
5223 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5224 chaos_patrons[p_ptr->chaos_patron]);
5226 msg_format("The voice of %s booms out:",
5227 chaos_patrons[p_ptr->chaos_patron]);
5231 msg_print("¡Öᴤ뤬¤è¤¤¡¢²æ¤¬²¼Ëͤ衪¡×");
5233 msg_print("'Rise, my servant!'");
5237 (void)set_poisoned(0);
5239 (void)set_confused(0);
5244 for (dummy = 0; dummy < 6; dummy++)
5246 (void)do_res_stat(dummy);
5249 reward = "ÂÎÎϤ¬²óÉü¤·¤¿¡£";
5255 if (!buki_motteruka(INVEN_RARM)) break;
5257 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5258 chaos_patrons[p_ptr->chaos_patron]);
5260 msg_format("The voice of %s booms out:",
5261 chaos_patrons[p_ptr->chaos_patron]);
5265 msg_print("¡ÖÆò¡¢Éð´ï¤ËÍê¤ë¤³¤È¤Ê¤«¤ì¡£¡×");
5267 msg_print("'Thou reliest too much on thy weapon.'");
5270 object_desc(o_name, &inventory[INVEN_RARM], TRUE, 0);
5271 (void)curse_weapon(FALSE, INVEN_RARM);
5273 reward = format("%s¤¬Ç˲õ¤µ¤ì¤¿¡£", o_name);
5275 reward = format("destroying %s", o_name);
5279 if (!inventory[INVEN_BODY].k_idx) break;
5281 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5282 chaos_patrons[p_ptr->chaos_patron]);
5284 msg_format("The voice of %s booms out:",
5285 chaos_patrons[p_ptr->chaos_patron]);
5289 msg_print("¡ÖÆò¡¢Ëɶñ¤ËÍê¤ë¤³¤È¤Ê¤«¤ì¡£¡×");
5291 msg_print("'Thou reliest too much on thine equipment.'");
5294 object_desc(o_name, &inventory[INVEN_BODY], TRUE, 0);
5295 (void)curse_armor();
5297 reward = format("%s¤¬Ç˲õ¤µ¤ì¤¿¡£", o_name);
5299 reward = format("destroying %s", o_name);
5304 msg_format("%s¤ÎÀ¼¤¬¤µ¤µ¤ä¤¤¤¿:",
5305 chaos_patrons[p_ptr->chaos_patron]);
5307 msg_format("The voice of %s whispers:",
5308 chaos_patrons[p_ptr->chaos_patron]);
5312 msg_print("¡Ö²æ¤òÅܤꤷ¤á¤¿ºá¤ò½þ¤¦¤Ù¤·¡£¡×");
5314 msg_print("'Now thou shalt pay for annoying me.'");
5317 switch (randint1(4))
5320 (void)activate_ty_curse(FALSE, &count);
5322 reward = "²Ò¡¹¤·¤¤¼ö¤¤¤ò¤«¤±¤é¤ì¤¿¡£";
5328 activate_hi_summon(py, px, FALSE);
5330 reward = "¥â¥ó¥¹¥¿¡¼¤ò¾¤´¤µ¤ì¤¿¡£";
5332 reward = "summoning hostile monsters";
5338 if (!buki_motteruka(INVEN_RARM)) break;
5339 object_desc(o_name, &inventory[INVEN_RARM], TRUE, 0);
5340 (void)curse_weapon(FALSE, INVEN_RARM);
5342 reward = format("%s¤¬Ç˲õ¤µ¤ì¤¿¡£", o_name);
5344 reward = format("destroying %s", o_name);
5349 if (!inventory[INVEN_BODY].k_idx) break;
5350 object_desc(o_name, &inventory[INVEN_BODY], TRUE, 0);
5351 (void)curse_armor();
5353 reward = format("%s¤¬Ç˲õ¤µ¤ì¤¿¡£", o_name);
5355 reward = format("destroying %s", o_name);
5360 for (dummy = 0; dummy < 6; dummy++)
5362 (void)dec_stat(dummy, 10 + randint1(15), TRUE);
5365 reward = "Á´Ç½ÎÏÃͤ¬²¼¤¬¤Ã¤¿¡£";
5367 reward = "decreasing all stats";
5374 msg_format("%s¤ÎÀ¼¤¬¹ì¤ÅϤä¿:",
5376 msg_format("The voice of %s thunders:",
5379 chaos_patrons[p_ptr->chaos_patron]);
5381 msg_print("¡Ö»à¤Ì¤¬¤è¤¤¡¢²¼Ëͤ衪¡×");
5383 msg_print("'Die, mortal!'");
5386 take_hit(DAMAGE_LOSELIFE, p_ptr->lev * 4, wrath_reason, -1);
5387 for (dummy = 0; dummy < 6; dummy++)
5389 (void)dec_stat(dummy, 10 + randint1(15), FALSE);
5391 activate_hi_summon(py, px, FALSE);
5392 (void)activate_ty_curse(FALSE, &count);
5393 if (one_in_(2)) (void)curse_weapon(FALSE, INVEN_RARM);
5394 if (one_in_(2)) (void)curse_armor();
5398 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5399 chaos_patrons[p_ptr->chaos_patron]);
5401 msg_format("The voice of %s booms out:",
5402 chaos_patrons[p_ptr->chaos_patron]);
5406 msg_print("¡Ö»à¤ÈÇ˲õ¤³¤½²æ¤¬´î¤Ó¤Ê¤ê¡ª¡×");
5408 msg_print("'Death and destruction! This pleaseth me!'");
5411 (void)destroy_area(py, px, 25, FALSE);
5413 reward = "¥À¥ó¥¸¥ç¥ó¤¬*Ç˲õ*¤µ¤ì¤¿¡£";
5415 reward = "*destruct*ing dungeon";
5420 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5421 chaos_patrons[p_ptr->chaos_patron]);
5423 msg_format("The voice of %s booms out:",
5424 chaos_patrons[p_ptr->chaos_patron]);
5428 msg_print("¡Ö²æ¡¢Æò¤ÎŨ¤òËõ»¦¤»¤ó¡ª¡×");
5430 msg_print("'Let me relieve thee of thine oppressors!'");
5433 (void)symbol_genocide(0, FALSE);
5435 reward = "¥â¥ó¥¹¥¿¡¼¤¬Ëõ»¦¤µ¤ì¤¿¡£";
5437 reward = "genociding monsters";
5442 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5443 chaos_patrons[p_ptr->chaos_patron]);
5445 msg_format("The voice of %s booms out:",
5446 chaos_patrons[p_ptr->chaos_patron]);
5450 msg_print("¡Ö²æ¡¢Æò¤ÎŨ¤òËõ»¦¤»¤ó¡ª¡×");
5452 msg_print("'Let me relieve thee of thine oppressors!'");
5455 (void)mass_genocide(0, FALSE);
5457 reward = "¥â¥ó¥¹¥¿¡¼¤¬Ëõ»¦¤µ¤ì¤¿¡£";
5459 reward = "genociding nearby monsters";
5464 msg_format("%s¤ÎÎϤ¬Å¨¤ò¹¶·â¤¹¤ë¤Î¤ò´¶¤¸¤¿¡ª",
5465 chaos_patrons[p_ptr->chaos_patron]);
5467 msg_format("You can feel the power of %s assault your enemies!",
5468 chaos_patrons[p_ptr->chaos_patron]);
5471 (void)dispel_monsters(p_ptr->lev * 4);
5475 msg_format("%s¤Ï¤¢¤Ê¤¿¤ò̵»ë¤·¤¿¡£",
5476 chaos_patrons[p_ptr->chaos_patron]);
5478 msg_format("%s ignores you.",
5479 chaos_patrons[p_ptr->chaos_patron]);
5485 msg_format("%s¤ÏË«Èþ¤È¤·¤Æ°Ëâ¤Î»È¤¤¤ò¤è¤³¤·¤¿¡ª",chaos_patrons[p_ptr->chaos_patron]);
5487 msg_format("%s rewards you with a demonic servant!",chaos_patrons[p_ptr->chaos_patron]);
5490 if (!summon_specific(-1, py, px, dun_level, SUMMON_DEMON, PM_FORCE_PET))
5492 msg_print("²¿¤â¸½¤ì¤Ê¤«¤Ã¤¿...");
5494 msg_print("Nobody ever turns up...");
5498 reward = "°Ë⤬¥Ú¥Ã¥È¤Ë¤Ê¤Ã¤¿¡£";
5500 reward = "a demonic servant";
5506 msg_format("%s¤ÏË«Èþ¤È¤·¤Æ»È¤¤¤ò¤è¤³¤·¤¿¡ª",chaos_patrons[p_ptr->chaos_patron]);
5508 msg_format("%s rewards you with a servant!",chaos_patrons[p_ptr->chaos_patron]);
5511 if (!summon_specific(-1, py, px, dun_level, 0, PM_FORCE_PET))
5513 msg_print("²¿¤â¸½¤ì¤Ê¤«¤Ã¤¿...");
5515 msg_print("Nobody ever turns up...");
5519 reward = "¥â¥ó¥¹¥¿¡¼¤¬¥Ú¥Ã¥È¤Ë¤Ê¤Ã¤¿¡£";
5521 reward = "a servant";
5527 msg_format("%s¤ÏË«Èþ¤È¤·¤Æ¥¢¥ó¥Ç¥Ã¥É¤Î»È¤¤¤ò¤è¤³¤·¤¿¡£",chaos_patrons[p_ptr->chaos_patron]);
5529 msg_format("%s rewards you with an undead servant!",chaos_patrons[p_ptr->chaos_patron]);
5532 if (!summon_specific(-1, py, px, dun_level, SUMMON_UNDEAD, PM_FORCE_PET))
5534 msg_print("²¿¤â¸½¤ì¤Ê¤«¤Ã¤¿...");
5536 msg_print("Nobody ever turns up...");
5540 reward = "¥¢¥ó¥Ç¥Ã¥É¤¬¥Ú¥Ã¥È¤Ë¤Ê¤Ã¤¿¡£";
5542 reward = "an undead servant";
5548 msg_format("%s¤ÎÀ¼¤¬¤É¤â¤Ã¤¿:",
5550 msg_format("The voice of %s stammers:",
5553 chaos_patrons[p_ptr->chaos_patron]);
5555 msg_format("¡Ö¤¢¡¼¡¢¤¢¡¼¡¢Åú¤¨¤Ï %d/%d¡£¼ÁÌä¤Ï²¿¡©¡×", type, effect);
5557 msg_format("'Uh... uh... the answer's %d/%d, what's the question?'", type, effect);
5565 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, format("¥Ñ¥È¥í¥ó¤ÎÊó½·¤Ç%s", reward));
5567 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, format("The patron rewards you with %s.", reward));
5574 * old -- from PsiAngband.
5576 bool tgt_pt(int *x_ptr, int *y_ptr)
5580 bool success = FALSE;
5585 get_screen_size(&wid, &hgt);
5591 msg_print("¾ì½ê¤òÁª¤ó¤Ç¥¹¥Ú¡¼¥¹¥¡¼¤ò²¡¤·¤Æ²¼¤µ¤¤¡£");
5593 msg_print("Select a point and press space.");
5595 msg_flag = FALSE; /* prevents "-more-" message. */
5597 while ((ch != ESCAPE) && !success)
5599 bool move_fast = FALSE;
5601 move_cursor_relative(y, x);
5613 if (player_bold(y, x)) ch = 0;
5616 else success = TRUE;
5620 /* Look up the direction */
5621 d = get_keymap_dir(ch);
5623 /* XTRA HACK MOVEFAST */
5624 if (isupper(ch)) move_fast = TRUE;
5626 /* Handle "direction" */
5632 /* XTRA HACK MOVEFAST */
5635 int mag = MIN(wid / 2, hgt / 2);
5645 /* Do not move horizontally if unnecessary */
5646 if (((x < panel_col_min + wid / 2) && (dx > 0)) ||
5647 ((x > panel_col_min + wid / 2) && (dx < 0)))
5652 /* Do not move vertically if unnecessary */
5653 if (((y < panel_row_min + hgt / 2) && (dy > 0)) ||
5654 ((y > panel_row_min + hgt / 2) && (dy < 0)))
5659 /* Apply the motion */
5660 if ((y >= panel_row_min + hgt) || (y < panel_row_min) ||
5661 (x >= panel_col_min + wid) || (x < panel_col_min))
5663 /* if (change_panel(dy, dx)) target_set_prepare(mode); */
5664 change_panel(dy, dx);
5667 /* Slide into legality */
5668 if (x >= cur_wid-1) x = cur_wid - 2;
5669 else if (x <= 0) x = 1;
5671 /* Slide into legality */
5672 if (y >= cur_hgt-1) y = cur_hgt- 2;
5673 else if (y <= 0) y = 1;
5680 /* Clear the top line */
5683 /* Recenter the map around the player */
5687 p_ptr->update |= (PU_MONSTERS);
5690 p_ptr->redraw |= (PR_MAP);
5693 p_ptr->window |= (PW_OVERHEAD);
5704 bool get_hack_dir(int *dp)
5714 /* Global direction */
5717 /* (No auto-targeting) */
5719 /* Ask until satisfied */
5722 /* Choose a prompt */
5726 p = "Êý¸þ ('*'¤Ç¥¿¡¼¥²¥Ã¥ÈÁªÂò, ESC¤ÇÃæÃÇ)? ";
5728 p = "Direction ('*' to choose a target, Escape to cancel)? ";
5735 p = "Êý¸þ ('5'¤Ç¥¿¡¼¥²¥Ã¥È¤Ø, '*'¤Ç¥¿¡¼¥²¥Ã¥ÈºÆÁªÂò, ESC¤ÇÃæÃÇ)? ";
5737 p = "Direction ('5' for target, '*' to re-target, Escape to cancel)? ";
5742 /* Get a command (or Cancel) */
5743 if (!get_com(p, &command, TRUE)) break;
5747 if (command == '\r') command = 't';
5750 /* Convert various keys to "standard" keys */
5753 /* Use current target */
5764 /* Set new target */
5769 if (target_set(TARGET_KILL)) dir = 5;
5775 /* Look up the direction */
5776 dir = get_keymap_dir(command);
5782 /* Verify requested targets */
5783 if ((dir == 5) && !target_okay()) dir = 0;
5790 if (!dir) return (FALSE);
5792 /* Save the direction */
5795 /* Check for confusion */
5796 if (p_ptr->confused)
5799 /* Random direction */
5800 dir = ddd[randint0(8)];
5803 /* Notice confusion */
5804 if (command_dir != dir)
5808 msg_print("¤¢¤Ê¤¿¤Ïº®Í𤷤Ƥ¤¤ë¡£");
5810 msg_print("You are confused.");
5815 /* Save direction */
5818 /* A "valid" direction was entered */
5824 * ¥¨¥Í¥ë¥®¡¼¤ÎÁý²ÃÎÌ10d5¤ò®¤¯·×»»¤¹¤ë¤¿¤á¤Î´Ø¿ô
5827 #define Go_no_JuuJou 5*5*5*5*5*5*5*5*5*5
5829 s16b gain_energy(void)
5832 s32b energy_result = 10;
5835 tmp = randint0(Go_no_JuuJou);
5837 for (i = 0; i < 9; i ++){
5838 energy_result += tmp % 5;
5842 return (s16b)(energy_result + tmp);
5849 s16b bow_energy(int sval)
5853 /* Analyze the launcher */
5856 /* Sling and ammo */
5863 /* Short Bow and Arrow */
5870 /* Long Bow and Arrow */
5877 /* Bow of irresponsiblity and Arrow */
5884 /* Light Crossbow and Bolt */
5891 /* Heavy Crossbow and Bolt */
5906 int bow_tmul(int sval)
5910 /* Analyze the launcher */
5913 /* Sling and ammo */
5920 /* Short Bow and Arrow */
5927 /* Long Bow and Arrow */
5934 /* Bow of irresponsiblity and Arrow */
5941 /* Light Crossbow and Bolt */
5948 /* Heavy Crossbow and Bolt */
5960 * Return alignment title
5962 cptr your_alignment(void)
5965 if (p_ptr->align > 150) return "ÂçÁ±";
5966 else if (p_ptr->align > 50) return "ÃæÁ±";
5967 else if (p_ptr->align > 10) return "¾®Á±";
5968 else if (p_ptr->align > -11) return "ÃæΩ";
5969 else if (p_ptr->align > -51) return "¾®°";
5970 else if (p_ptr->align > -151) return "Ãæ°";
5973 if (p_ptr->align > 150) return "Lawful";
5974 else if (p_ptr->align > 50) return "Good";
5975 else if (p_ptr->align > 10) return "Neutral Good";
5976 else if (p_ptr->align > -11) return "Neutral";
5977 else if (p_ptr->align > -51) return "Neutral Evil";
5978 else if (p_ptr->align > -151) return "Evil";
5979 else return "Chaotic";
5985 * Return proficiency level of weapons and misc. skills (except riding)
5987 int weapon_exp_level(int weapon_exp)
5989 if (weapon_exp < WEAPON_EXP_BEGINNER) return EXP_LEVEL_UNSKILLED;
5990 else if (weapon_exp < WEAPON_EXP_SKILLED) return EXP_LEVEL_BEGINNER;
5991 else if (weapon_exp < WEAPON_EXP_EXPERT) return EXP_LEVEL_SKILLED;
5992 else if (weapon_exp < WEAPON_EXP_MASTER) return EXP_LEVEL_EXPERT;
5993 else return EXP_LEVEL_MASTER;
5998 * Return proficiency level of riding
6000 int riding_exp_level(int riding_exp)
6002 if (riding_exp < RIDING_EXP_BEGINNER) return EXP_LEVEL_UNSKILLED;
6003 else if (riding_exp < RIDING_EXP_SKILLED) return EXP_LEVEL_BEGINNER;
6004 else if (riding_exp < RIDING_EXP_EXPERT) return EXP_LEVEL_SKILLED;
6005 else if (riding_exp < RIDING_EXP_MASTER) return EXP_LEVEL_EXPERT;
6006 else return EXP_LEVEL_MASTER;
6011 * Return proficiency level of spells
6013 int spell_exp_level(int spell_exp)
6015 if (spell_exp < SPELL_EXP_BEGINNER) return EXP_LEVEL_UNSKILLED;
6016 else if (spell_exp < SPELL_EXP_SKILLED) return EXP_LEVEL_BEGINNER;
6017 else if (spell_exp < SPELL_EXP_EXPERT) return EXP_LEVEL_SKILLED;
6018 else if (spell_exp < SPELL_EXP_MASTER) return EXP_LEVEL_EXPERT;
6019 else return EXP_LEVEL_MASTER;