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);
110 /* Update some stuff */
111 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
113 /* Redraw some stuff */
114 p_ptr->redraw |= (PR_LEV | PR_TITLE | PR_EXP);
117 p_ptr->window |= (PW_PLAYER | PW_SPELL | PW_INVEN);
119 /* HP¤ÈMP¤Î¾å¾ºÎ̤òɽ¼¨ */
129 if(!(p_ptr->max_plv % 10))
139 cnv_stat(p_ptr->stat_max[0], tmp);
140 prt(format(" a) ÏÓÎÏ (¸½ºßÃÍ %s)", tmp), 2, 14);
141 cnv_stat(p_ptr->stat_max[1], tmp);
142 prt(format(" b) ÃÎǽ (¸½ºßÃÍ %s)", tmp), 3, 14);
143 cnv_stat(p_ptr->stat_max[2], tmp);
144 prt(format(" c) ¸¤µ (¸½ºßÃÍ %s)", tmp), 4, 14);
145 cnv_stat(p_ptr->stat_max[3], tmp);
146 prt(format(" d) ´ïÍÑ (¸½ºßÃÍ %s)", tmp), 5, 14);
147 cnv_stat(p_ptr->stat_max[4], tmp);
148 prt(format(" e) ÂÑµ× (¸½ºßÃÍ %s)", tmp), 6, 14);
149 cnv_stat(p_ptr->stat_max[5], tmp);
150 prt(format(" f) Ì¥ÎÏ (¸½ºßÃÍ %s)", tmp), 7, 14);
152 prt(" ¤É¤ÎǽÎÏÃͤò¾å¤²¤Þ¤¹¤«¡©", 1, 14);
154 cnv_stat(p_ptr->stat_max[0], tmp);
155 prt(format(" a) Str (cur %s)", tmp), 2, 14);
156 cnv_stat(p_ptr->stat_max[1], tmp);
157 prt(format(" b) Int (cur %s)", tmp), 3, 14);
158 cnv_stat(p_ptr->stat_max[2], tmp);
159 prt(format(" c) Wis (cur %s)", tmp), 4, 14);
160 cnv_stat(p_ptr->stat_max[3], tmp);
161 prt(format(" d) Dex (cur %s)", tmp), 5, 14);
162 cnv_stat(p_ptr->stat_max[4], tmp);
163 prt(format(" e) Con (cur %s)", tmp), 6, 14);
164 cnv_stat(p_ptr->stat_max[5], tmp);
165 prt(format(" f) Chr (cur %s)", tmp), 7, 14);
167 prt(" Which stat do you want to raise?", 1, 14);
172 if ((choice >= 'a') && (choice <= 'f')) break;
174 for(n = 0; n < 6; n++)
175 if (n != choice - 'a')
178 if (get_check("¤è¤í¤·¤¤¤Ç¤¹¤«¡©")) break;
180 if (get_check("Are you sure? ")) break;
183 do_inc_stat(choice - 'a');
186 else if(!(p_ptr->max_plv % 2))
187 do_inc_stat(randint0(6));
193 msg_print("¤¢¤Ê¤¿¤ÏÊѤï¤Ã¤¿µ¤¤¬¤¹¤ë...");
195 msg_print("You feel different...");
198 (void)gain_random_mutation(0);
199 level_mutation = FALSE;
203 * Ê󽷤ǥì¥Ù¥ë¤¬¾å¤ë¤ÈºÆµ¢Åª¤Ë check_experience() ¤¬
204 * ¸Æ¤Ð¤ì¤ë¤Î¤Ç½çÈÖ¤òºÇ¸å¤Ë¤¹¤ë¡£
208 gain_level_reward(0);
209 level_reward = FALSE;
212 /* Update some stuff */
213 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
215 /* Redraw some stuff */
216 p_ptr->redraw |= (PR_LEV | PR_TITLE);
219 p_ptr->window |= (PW_PLAYER | PW_SPELL);
228 * Hack -- Return the "automatic coin type" of a monster race
229 * Used to allocate proper treasure when "Creeping coins" die
231 * XXX XXX XXX Note the use of actual "monster names"
233 static int get_coin_type(int r_idx)
235 /* Analyze monsters */
238 case MON_COPPER_COINS: return 2;
239 case MON_SILVER_COINS: return 5;
240 case MON_GOLD_COINS: return 10;
241 case MON_MITHRIL_COINS:
242 case MON_MITHRIL_GOLEM: return 16;
243 case MON_ADAMANT_COINS: return 17;
252 * Hack -- determine if a template is Cloak
254 static bool kind_is_cloak(int k_idx)
256 object_kind *k_ptr = &k_info[k_idx];
258 /* Analyze the item type */
259 if (k_ptr->tval == TV_CLOAK)
264 /* Assume not good */
270 * Hack -- determine if a template is Polearm
272 static bool kind_is_polearm(int k_idx)
274 object_kind *k_ptr = &k_info[k_idx];
276 /* Analyze the item type */
277 if (k_ptr->tval == TV_POLEARM)
282 /* Assume not good */
288 * Hack -- determine if a template is Sword
290 static bool kind_is_sword(int k_idx)
292 object_kind *k_ptr = &k_info[k_idx];
294 /* Analyze the item type */
295 if ((k_ptr->tval == TV_SWORD) && (k_ptr->sval > 2))
300 /* Assume not good */
306 * Hack -- determine if a template is Book
308 static bool kind_is_book(int k_idx)
310 object_kind *k_ptr = &k_info[k_idx];
312 /* Analyze the item type */
313 if ((k_ptr->tval >= TV_LIFE_BOOK) && (k_ptr->tval <= TV_CRUSADE_BOOK))
318 /* Assume not good */
324 * Hack -- determine if a template is Good book
326 static bool kind_is_good_book(int k_idx)
328 object_kind *k_ptr = &k_info[k_idx];
330 /* Analyze the item type */
331 if ((k_ptr->tval >= TV_LIFE_BOOK) && (k_ptr->tval <= TV_CRUSADE_BOOK) && (k_ptr->tval != TV_ARCANE_BOOK) && (k_ptr->sval > 1))
336 /* Assume not good */
342 * Hack -- determine if a template is Armor
344 static bool kind_is_armor(int k_idx)
346 object_kind *k_ptr = &k_info[k_idx];
348 /* Analyze the item type */
349 if (k_ptr->tval == TV_HARD_ARMOR)
354 /* Assume not good */
360 * Hack -- determine if a template is hafted weapon
362 static bool kind_is_hafted(int k_idx)
364 object_kind *k_ptr = &k_info[k_idx];
366 /* Analyze the item type */
367 if (k_ptr->tval == TV_HAFTED)
372 /* Assume not good */
378 * Check for "Quest" completion when a quest monster is killed or charmed.
380 void check_quest_completion(monster_type *m_ptr)
382 int i, j, y, x, ny, nx, i2, j2;
386 bool create_stairs = FALSE;
392 /* Get the location */
397 quest_num = p_ptr->inside_quest;
399 /* Search for an active quest on this dungeon level */
402 for (i = max_quests - 1; i > 0; i--)
404 /* Quest is not active */
405 if (quest[i].status != QUEST_STATUS_TAKEN)
408 /* Quest is not a dungeon quest */
409 if (quest[i].flags & QUEST_FLAG_PRESET)
412 /* Quest is not on this level */
413 if ((quest[i].level != dun_level) &&
414 (quest[i].type != QUEST_TYPE_KILL_ANY_LEVEL))
417 /* Not a "kill monster" quest */
418 if ((quest[i].type == QUEST_TYPE_FIND_ARTIFACT) ||
419 (quest[i].type == QUEST_TYPE_FIND_EXIT))
422 /* Interesting quest */
423 if ((quest[i].type == QUEST_TYPE_KILL_NUMBER) ||
424 (quest[i].type == QUEST_TYPE_KILL_ALL))
427 /* Interesting quest */
428 if (((quest[i].type == QUEST_TYPE_KILL_LEVEL) ||
429 (quest[i].type == QUEST_TYPE_KILL_ANY_LEVEL) ||
430 (quest[i].type == QUEST_TYPE_RANDOM)) &&
431 (quest[i].r_idx == m_ptr->r_idx))
438 /* Handle the current quest */
439 if (quest_num && (quest[quest_num].status == QUEST_STATUS_TAKEN))
444 switch (quest[i].type)
446 case QUEST_TYPE_KILL_NUMBER:
450 if (quest[i].cur_num >= quest[i].num_mon)
452 if (record_fix_quest) do_cmd_write_nikki(NIKKI_FIX_QUEST_C, i, NULL);
453 /* completed quest */
454 quest[i].status = QUEST_STATUS_COMPLETED;
455 quest[i].complev = (byte)p_ptr->lev;
457 if (!(quest[i].flags & QUEST_FLAG_SILENT))
460 msg_print("¥¯¥¨¥¹¥È¤òãÀ®¤·¤¿¡ª");
462 msg_print("You just completed your quest!");
468 quest[i].cur_num = 0;
472 case QUEST_TYPE_KILL_ALL:
476 if (!is_hostile(m_ptr)) break;
478 /* Count all hostile monsters */
479 for (i2 = 0; i2 < cur_wid; ++i2)
480 for (j2 = 0; j2 < cur_hgt; j2++)
481 if (cave[j2][i2].m_idx > 0)
482 if (is_hostile(&m_list[cave[j2][i2].m_idx]))
485 if ((number_mon - 1) == 0)
487 if (record_fix_quest) do_cmd_write_nikki(NIKKI_FIX_QUEST_C, i, NULL);
489 if (quest[i].flags & QUEST_FLAG_SILENT)
491 quest[i].status = QUEST_STATUS_FINISHED;
495 quest[i].status = QUEST_STATUS_COMPLETED;
496 quest[i].complev = (byte)p_ptr->lev;
498 msg_print("¥¯¥¨¥¹¥È¤òãÀ®¤·¤¿¡ª");
500 msg_print("You just completed your quest!");
508 case QUEST_TYPE_KILL_LEVEL:
509 case QUEST_TYPE_RANDOM:
511 /* Only count valid monsters */
512 if (quest[i].r_idx != m_ptr->r_idx)
517 if (quest[i].cur_num >= quest[i].max_num)
519 if (record_fix_quest && (quest[i].type == QUEST_TYPE_KILL_LEVEL)) do_cmd_write_nikki(NIKKI_FIX_QUEST_C, i, NULL);
520 if (record_rand_quest && (quest[i].type == QUEST_TYPE_RANDOM)) do_cmd_write_nikki(NIKKI_RAND_QUEST_C, i, NULL);
521 /* completed quest */
522 quest[i].status = QUEST_STATUS_COMPLETED;
523 quest[i].complev = (byte)p_ptr->lev;
524 if (!(quest[i].flags & QUEST_FLAG_PRESET))
526 create_stairs = TRUE;
527 p_ptr->inside_quest = 0;
530 if (!(quest[i].flags & QUEST_FLAG_SILENT))
533 msg_print("¥¯¥¨¥¹¥È¤òãÀ®¤·¤¿¡ª");
535 msg_print("You just completed your quest!");
541 /* Finish the two main quests without rewarding */
542 if ((i == QUEST_OBERON) || (i == QUEST_SERPENT))
544 quest[i].status = QUEST_STATUS_FINISHED;
547 if (quest[i].type == QUEST_TYPE_RANDOM)
550 quest[i].status = QUEST_STATUS_FINISHED;
555 case QUEST_TYPE_KILL_ANY_LEVEL:
558 if (quest[i].cur_num >= quest[i].max_num)
560 if (record_fix_quest) do_cmd_write_nikki(NIKKI_FIX_QUEST_C, i, NULL);
561 /* completed quest */
562 quest[i].status = QUEST_STATUS_COMPLETED;
563 quest[i].complev = (byte)p_ptr->lev;
565 if (!(quest[i].flags & QUEST_FLAG_SILENT))
568 msg_print("¥¯¥¨¥¹¥È¤òãÀ®¤·¤¿¡ª");
570 msg_print("You just completed your quest!");
575 quest[i].cur_num = 0;
582 /* Create a magical staircase */
586 while (cave_perma_bold(y, x) || cave[y][x].o_idx || (cave[y][x].info & CAVE_OBJECT) )
588 /* Pick a location */
589 scatter(&ny, &nx, y, x, 1, 0);
595 /* Explain the staircase */
597 msg_print("ËâË¡¤Î³¬Ãʤ¬¸½¤ì¤¿...");
599 msg_print("A magical staircase appears...");
603 /* Create stairs down */
604 cave_set_feat(y, x, FEAT_MORE);
606 /* Remember to update everything */
607 p_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MONSTERS | PU_MON_LITE);
615 for (j = 0; j < (dun_level / 15)+1; j++)
617 /* Get local object */
620 /* Wipe the object */
623 /* Make a great object */
624 make_object(q_ptr, AM_GOOD | AM_GREAT);
626 /* Drop it in the dungeon */
627 (void)drop_near(q_ptr, -1, y, x);
634 * Return monster death string
636 cptr extract_note_dies(monster_race *r_ptr)
638 /* Some monsters get "destroyed" */
639 if (!monster_living(r_ptr))
643 for (i = 0; i < 4; i++)
645 if (r_ptr->blow[i].method == RBM_EXPLODE)
648 return "¤ÏÇúȯ¤·¤ÆÊ´¡¹¤Ë¤Ê¤Ã¤¿¡£";
650 return " explodes into tiny shreds.";
658 return " is destroyed.";
662 /* Assume a default death */
672 * Handle the "death" of a monster.
674 * Disperse treasures centered at the monster location based on the
675 * various flags contained in the monster flags fields.
677 * Check for "Quest" completion when a quest monster is killed.
679 * Note that only the player can induce "monster_death()" on Uniques.
680 * Thus (for now) all Quest monsters should be Uniques.
682 * Note that monsters can now carry objects, and when a monster dies,
683 * it drops all of its objects, which may disappear in crowded rooms.
685 void monster_death(int m_idx, bool drop_item)
694 monster_type *m_ptr = &m_list[m_idx];
696 monster_race *r_ptr = &r_info[m_ptr->r_idx];
698 bool visible = (m_ptr->ml || (r_ptr->flags1 & RF1_UNIQUE));
702 bool do_gold = (!(r_ptr->flags1 & RF1_ONLY_ITEM));
703 bool do_item = (!(r_ptr->flags1 & RF1_ONLY_GOLD));
704 bool cloned = (m_ptr->smart & SM_CLONED) ? TRUE : FALSE;
705 int force_coin = get_coin_type(m_ptr->r_idx);
710 bool drop_chosen_item = drop_item && !cloned && !p_ptr->inside_arena
711 && !p_ptr->inside_battle && !is_pet(m_ptr);
713 /* The caster is dead? */
714 if (world_monster && world_monster == m_idx) world_monster = 0;
716 /* Notice changes in view */
717 if (r_ptr->flags7 & (RF7_LITE_MASK | RF7_DARK_MASK))
719 /* Update some things */
720 p_ptr->update |= (PU_MON_LITE);
723 /* Get the location */
727 if (record_named_pet && is_pet(m_ptr) && m_ptr->nickname)
731 monster_desc(m_name, m_ptr, MD_INDEF_VISIBLE);
732 do_cmd_write_nikki(NIKKI_NAMED_PET, 3, m_name);
735 /* Let monsters explode! */
736 for (i = 0; i < 4; i++)
738 if (r_ptr->blow[i].method == RBM_EXPLODE)
740 int flg = PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL;
741 int typ = mbe_info[r_ptr->blow[i].effect].explode_type;
742 int d_dice = r_ptr->blow[i].d_dice;
743 int d_side = r_ptr->blow[i].d_side;
744 int damage = damroll(d_dice, d_side);
746 project(m_idx, 3, y, x, damage, typ, flg, -1);
751 if (m_ptr->mflag2 & MFLAG2_CHAMELEON)
753 choose_new_monster(m_idx, TRUE, MON_CHAMELEON);
754 r_ptr = &r_info[m_ptr->r_idx];
757 /* Check for quest completion */
758 check_quest_completion(m_ptr);
760 /* Handle the possibility of player vanquishing arena combatant -KMW- */
761 if (p_ptr->inside_arena && !is_pet(m_ptr))
763 p_ptr->exit_bldg = TRUE;
765 if (p_ptr->arena_number > MAX_ARENA_MONS)
768 msg_print("ÁÇÀ²¤é¤·¤¤¡ª·¯¤³¤½¿¿¤Î¾¡Íø¼Ô¤À¡£");
770 msg_print("You are a Genuine Champion!");
776 msg_print("¾¡Íø¡ª¥Á¥ã¥ó¥Ô¥ª¥ó¤Ø¤ÎÆ»¤ò¿Ê¤ó¤Ç¤¤¤ë¡£");
778 msg_print("Victorious! You're on your way to becoming Champion.");
782 if (arena_info[p_ptr->arena_number].tval)
784 /* Get local object */
787 /* Prepare to make a prize */
788 object_prep(q_ptr, lookup_kind(arena_info[p_ptr->arena_number].tval, arena_info[p_ptr->arena_number].sval));
790 apply_magic(q_ptr, object_level, AM_NO_FIXED_ART);
792 /* Drop it in the dungeon */
793 (void)drop_near(q_ptr, -1, y, x);
796 if (p_ptr->arena_number > MAX_ARENA_MONS) p_ptr->arena_number++;
797 p_ptr->arena_number++;
802 /* Extract monster name */
803 monster_desc(m_name, m_ptr, MD_IGNORE_HALLU | MD_ASSUME_VISIBLE | MD_INDEF_VISIBLE);
805 do_cmd_write_nikki(NIKKI_ARENA, p_ptr->arena_number, m_name);
809 if (m_idx == p_ptr->riding)
811 if (rakuba(-1, FALSE))
814 msg_print("ÃÏÌ̤ËÍî¤È¤µ¤ì¤¿¡£");
816 msg_print("You have fallen from your riding pet.");
821 /* Drop a dead corpse? */
822 if (one_in_(r_ptr->flags1 & RF1_UNIQUE ? 1 : 4) &&
823 ((r_ptr->flags9 & RF9_DROP_CORPSE) ||
824 (r_ptr->flags9 & RF9_DROP_SKELETON)) &&
825 !(p_ptr->inside_arena || p_ptr->inside_battle || cloned || ((m_ptr->r_idx == today_mon) && is_pet(m_ptr))))
827 /* Assume skeleton */
831 * We cannot drop a skeleton? Note, if we are in this check,
832 * we *know* we can drop at least a corpse or a skeleton
834 if (!(r_ptr->flags9 & RF9_DROP_SKELETON))
836 else if ((r_ptr->flags9 & RF9_DROP_CORPSE) && (r_ptr->flags1 && RF1_UNIQUE))
839 /* Else, a corpse is more likely unless we did a "lot" of damage */
840 else if (r_ptr->flags9 & RF9_DROP_CORPSE)
842 /* Lots of damage in one blow */
843 if ((0 - ((m_ptr->maxhp) / 4)) > m_ptr->hp)
845 if (one_in_(5)) corpse = TRUE;
849 if (!one_in_(5)) corpse = TRUE;
853 /* Get local object */
856 /* Prepare to make an object */
857 object_prep(q_ptr, lookup_kind(TV_CORPSE, (corpse ? SV_CORPSE : SV_SKELETON)));
859 apply_magic(q_ptr, object_level, AM_NO_FIXED_ART);
861 q_ptr->pval = m_ptr->r_idx;
863 /* Drop it in the dungeon */
864 (void)drop_near(q_ptr, -1, y, x);
867 /* Drop objects being carried */
868 monster_drop_carried_objects(m_ptr);
870 if (r_ptr->flags1 & RF1_DROP_GOOD) mo_mode |= AM_GOOD;
871 if (r_ptr->flags1 & RF1_DROP_GREAT) mo_mode |= AM_GREAT;
873 switch (m_ptr->r_idx)
875 case MON_PINK_HORROR:
876 /* Pink horrors are replaced with 2 Blue horrors */
877 if (!(p_ptr->inside_arena || p_ptr->inside_battle))
881 for (i = 0; i < 2; i++)
884 bool pet = is_pet(m_ptr);
887 if (pet) mode |= PM_FORCE_PET;
889 if (summon_specific((pet ? -1 : m_idx), wy, wx, 100, SUMMON_BLUE_HORROR, mode))
891 if (player_can_see_bold(wy, wx))
898 msg_print("¥Ô¥ó¥¯¡¦¥Û¥é¡¼¤ÏʬÎö¤·¤¿¡ª");
900 msg_print("The Pink horror divides!");
905 case MON_BLOODLETTER:
906 /* Bloodletters of Khorne may drop a blade of chaos */
907 if (drop_chosen_item && (randint1(100) < 15))
909 /* Get local object */
912 /* Prepare to make a Blade of Chaos */
913 object_prep(q_ptr, lookup_kind(TV_SWORD, SV_BLADE_OF_CHAOS));
915 apply_magic(q_ptr, object_level, AM_NO_FIXED_ART | mo_mode);
917 /* Drop it in the dungeon */
918 (void)drop_near(q_ptr, -1, y, x);
923 if (drop_chosen_item && (dun_level > 9))
925 /* Get local object */
928 /* Wipe the object */
931 /* Activate restriction */
932 if ((dun_level > 49) && one_in_(5))
933 get_obj_num_hook = kind_is_good_book;
935 get_obj_num_hook = kind_is_book;
938 make_object(q_ptr, mo_mode);
940 /* Drop it in the dungeon */
941 (void)drop_near(q_ptr, -1, y, x);
947 * Mega^3-hack: killing a 'Warrior of the Dawn' is likely to
948 * spawn another in the fallen one's place!
950 if (!p_ptr->inside_arena && !p_ptr->inside_battle)
956 bool pet = is_pet(m_ptr);
960 scatter(&wy, &wx, y, x, 20, 0);
962 while (!(in_bounds(wy, wx) && cave_empty_bold2(wy, wx)) && --attempts);
967 if (pet) mode |= PM_FORCE_PET;
969 if (summon_specific((pet ? -1 : m_idx), wy, wx, 100, SUMMON_DAWN, mode))
971 if (player_can_see_bold(wy, wx))
973 msg_print("¿·¤¿¤ÊÀï»Î¤¬¸½¤ì¤¿¡ª");
975 msg_print("A new warrior steps forth!");
985 /* One more ultra-hack: An Unmaker goes out with a big bang! */
987 int flg = PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL;
988 (void)project(m_idx, 6, y, x, 100, GF_CHAOS, flg, -1);
992 case MON_UNICORN_ORD:
995 /* Reward for "lazy" player */
996 if (p_ptr->pseikaku == SEIKAKU_NAMAKE)
1000 if (!drop_chosen_item) break;
1004 switch (randint0(3))
1007 a_idx = ART_NAMAKE_HAMMER;
1010 a_idx = ART_NAMAKE_BOW;
1013 a_idx = ART_NAMAKE_ARMOR;
1017 while (a_info[a_idx].cur_num);
1019 if (a_info[a_idx].cur_num == 0)
1021 /* Create the artifact */
1022 create_named_art(a_idx, y, x);
1023 a_info[a_idx].cur_num = 1;
1029 if (!drop_chosen_item) break;
1031 /* Get local object */
1034 /* Mega-Hack -- Prepare to make "Grond" */
1035 object_prep(q_ptr, lookup_kind(TV_HAFTED, SV_GROND));
1037 /* Mega-Hack -- Mark this item as "Grond" */
1038 q_ptr->name1 = ART_GROND;
1040 /* Mega-Hack -- Actually create "Grond" */
1041 apply_magic(q_ptr, -1, AM_GOOD | AM_GREAT);
1043 /* Drop it in the dungeon */
1044 (void)drop_near(q_ptr, -1, y, x);
1046 /* Get local object */
1049 /* Mega-Hack -- Prepare to make "Chaos" */
1050 object_prep(q_ptr, lookup_kind(TV_CROWN, SV_CHAOS));
1052 /* Mega-Hack -- Mark this item as "Chaos" */
1053 q_ptr->name1 = ART_CHAOS;
1055 /* Mega-Hack -- Actually create "Chaos" */
1056 apply_magic(q_ptr, -1, AM_GOOD | AM_GREAT);
1058 /* Drop it in the dungeon */
1059 (void)drop_near(q_ptr, -1, y, x);
1062 case MON_B_DEATH_SWORD:
1063 if (drop_chosen_item)
1065 /* Get local object */
1068 /* Prepare to make a broken sword */
1069 object_prep(q_ptr, lookup_kind(TV_SWORD, randint1(2)));
1071 /* Drop it in the dungeon */
1072 (void)drop_near(q_ptr, -1, y, x);
1078 if (drop_chosen_item && ((m_ptr->r_idx == MON_A_GOLD) ||
1079 ((m_ptr->r_idx == MON_A_SILVER) && (r_ptr->r_pkills % 5 == 0))))
1081 /* Get local object */
1084 /* Prepare to make a Can of Toys */
1085 object_prep(q_ptr, lookup_kind(TV_CHEST, SV_CHEST_KANDUME));
1087 apply_magic(q_ptr, object_level, AM_NO_FIXED_ART);
1089 /* Drop it in the dungeon */
1090 (void)drop_near(q_ptr, -1, y, x);
1096 int flg = PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL;
1097 (void)project(m_idx, 3, y, x, damroll(20, 10), GF_FIRE, flg, -1);
1102 if (!drop_chosen_item) break;
1104 switch (r_ptr->d_char)
1109 /* Get local object */
1112 /* Wipe the object */
1115 /* Activate restriction */
1116 get_obj_num_hook = kind_is_cloak;
1119 make_object(q_ptr, mo_mode);
1121 /* Drop it in the dungeon */
1122 (void)drop_near(q_ptr, -1, y, x);
1129 /* Get local object */
1132 /* Wipe the object */
1135 /* Activate restriction */
1136 get_obj_num_hook = kind_is_polearm;
1138 /* Make a poleweapon */
1139 make_object(q_ptr, mo_mode);
1141 /* Drop it in the dungeon */
1142 (void)drop_near(q_ptr, -1, y, x);
1149 /* Get local object */
1152 /* Wipe the object */
1155 /* Activate restriction */
1156 get_obj_num_hook = kind_is_armor;
1158 /* Make a hard armor */
1159 make_object(q_ptr, mo_mode);
1161 /* Drop it in the dungeon */
1162 (void)drop_near(q_ptr, -1, y, x);
1169 /* Get local object */
1172 /* Wipe the object */
1175 /* Activate restriction */
1176 get_obj_num_hook = kind_is_hafted;
1178 /* Make a poleweapon */
1179 make_object(q_ptr, mo_mode);
1181 /* Drop it in the dungeon */
1182 (void)drop_near(q_ptr, -1, y, x);
1187 if (m_ptr->r_idx != MON_STORMBRINGER)
1189 /* Get local object */
1192 /* Wipe the object */
1195 /* Activate restriction */
1196 get_obj_num_hook = kind_is_sword;
1199 make_object(q_ptr, mo_mode);
1201 /* Drop it in the dungeon */
1202 (void)drop_near(q_ptr, -1, y, x);
1209 /* Mega-Hack -- drop fixed items */
1210 if (drop_chosen_item)
1215 switch (m_ptr->r_idx)
1235 case MON_STORMBRINGER:
1236 a_idx = ART_STORMBRINGER;
1241 a_idx = ART_CRIMSON;
1251 a_idx = ART_KUSANAGI;
1281 a_idx = ART_WEREWINDLE;
1289 a_idx = ART_GRAYSWANDIR;
1300 a_idx = ART_TWILIGHT;
1305 a_idx = ART_ELENDIL;
1320 a_idx = ART_DESTINY;
1325 a_idx = ART_ZANTETSU;
1340 a_idx = ART_WINBLOWS;
1344 case MON_LUNGORTHIN:
1349 case MON_JACK_SHADOWS:
1355 a_idx = ART_STONEMASK;
1360 a_idx = ART_SOULCRUSH;
1365 a_idx = ART_EXCALIBUR_J;
1370 a_idx = ART_SHUTEN_DOJI;
1375 a_idx = ART_GOTHMOG;
1385 if ((a_idx > 0) && ((randint0(100) < chance) || p_ptr->wizard))
1387 if (a_info[a_idx].cur_num == 0)
1389 /* Create the artifact */
1390 create_named_art(a_idx, y, x);
1391 a_info[a_idx].cur_num = 1;
1395 if ((r_ptr->flags7 & RF7_GUARDIAN) && (d_info[dungeon_type].final_guardian == m_ptr->r_idx))
1397 int k_idx = d_info[dungeon_type].final_object ? d_info[dungeon_type].final_object
1398 : lookup_kind(TV_SCROLL, SV_SCROLL_ACQUIREMENT);
1400 if (d_info[dungeon_type].final_artifact)
1402 int a_idx = d_info[dungeon_type].final_artifact;
1403 if (!a_info[a_idx].cur_num)
1405 /* Create the artifact */
1406 create_named_art(a_idx, y, x);
1407 a_info[a_idx].cur_num = 1;
1409 /* Prevent rewarding both artifact and "default" object */
1410 if (!d_info[dungeon_type].final_object) k_idx = 0;
1416 /* Get local object */
1419 /* Prepare to make a reward */
1420 object_prep(q_ptr, k_idx);
1422 apply_magic(q_ptr, object_level, AM_NO_FIXED_ART | AM_GOOD);
1424 /* Drop it in the dungeon */
1425 (void)drop_near(q_ptr, -1, y, x);
1428 msg_format("¤¢¤Ê¤¿¤Ï%s¤òÀ©ÇƤ·¤¿¡ª",d_name+d_info[dungeon_type].name);
1430 msg_format("You have conquered %s!",d_name+d_info[dungeon_type].name);
1435 /* Determine how much we can drop */
1436 if ((r_ptr->flags1 & RF1_DROP_60) && (randint0(100) < 60)) number++;
1437 if ((r_ptr->flags1 & RF1_DROP_90) && (randint0(100) < 90)) number++;
1438 if (r_ptr->flags1 & RF1_DROP_1D2) number += damroll(1, 2);
1439 if (r_ptr->flags1 & RF1_DROP_2D2) number += damroll(2, 2);
1440 if (r_ptr->flags1 & RF1_DROP_3D2) number += damroll(3, 2);
1441 if (r_ptr->flags1 & RF1_DROP_4D2) number += damroll(4, 2);
1443 if (cloned && !(r_ptr->flags1 & RF1_UNIQUE))
1444 number = 0; /* Clones drop no stuff unless Cloning Pits */
1446 if (is_pet(m_ptr) || p_ptr->inside_battle || p_ptr->inside_arena)
1447 number = 0; /* Pets drop no stuff */
1448 if (!drop_item && (r_ptr->d_char != '$')) number = 0;
1450 /* Hack -- handle creeping coins */
1451 coin_type = force_coin;
1453 /* Average dungeon and monster levels */
1454 object_level = (dun_level + r_ptr->level) / 2;
1456 /* Drop some objects */
1457 for (j = 0; j < number; j++)
1459 /* Get local object */
1462 /* Wipe the object */
1466 if (do_gold && (!do_item || (randint0(100) < 50)))
1468 /* Make some gold */
1469 if (!make_gold(q_ptr)) continue;
1478 /* Make an object */
1479 if (!make_object(q_ptr, mo_mode)) continue;
1485 /* Drop it in the dungeon */
1486 (void)drop_near(q_ptr, -1, y, x);
1489 /* Reset the object level */
1490 object_level = base_level;
1492 /* Reset "coin" type */
1496 /* Take note of any dropped treasure */
1497 if (visible && (dump_item || dump_gold))
1499 /* Take notes on treasure */
1500 lore_treasure(m_idx, dump_item, dump_gold);
1503 /* Only process "Quest Monsters" */
1504 if (!(r_ptr->flags1 & RF1_QUESTOR)) return;
1505 if (p_ptr->inside_battle) return;
1508 if ((m_ptr->r_idx == MON_SERPENT) && !cloned)
1511 p_ptr->total_winner = TRUE;
1513 /* Redraw the "title" */
1514 p_ptr->redraw |= (PR_TITLE);
1517 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, "¸«»ö¤ËÊѶòÈÚÅܤξ¡Íø¼Ô¤È¤Ê¤Ã¤¿¡ª");
1519 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, "become *WINNER* of Hengband finely!");
1522 if ((p_ptr->pclass == CLASS_CHAOS_WARRIOR) || (p_ptr->muta2 & MUT2_CHAOS_GIFT))
1525 msg_format("%s¤«¤é¤ÎÀ¼¤¬¶Á¤¤¤¿¡£", chaos_patrons[p_ptr->chaos_patron]);
1526 msg_print("¡Ø¤è¤¯¤ä¤Ã¤¿¡¢ÄêÌ¿¤Î¼Ô¤è¡ª¡Ù");
1528 msg_format("The voice of %s booms out:", chaos_patrons[p_ptr->chaos_patron]);
1529 msg_print("'Thou art donst well, mortal!'");
1533 /* Congratulations */
1535 msg_print("*** ¤ª¤á¤Ç¤È¤¦ ***");
1537 msg_print("*** CONGRATULATIONS ***");
1541 msg_print("¤¢¤Ê¤¿¤Ï¥²¡¼¥à¤ò¥³¥ó¥×¥ê¡¼¥È¤·¤Þ¤·¤¿¡£");
1543 msg_print("You have won the game!");
1547 msg_print("½àÈ÷¤¬À°¤Ã¤¿¤é°úÂà(¼«»¦¥³¥Þ¥ó¥É)¤·¤Æ¤â·ë¹½¤Ç¤¹¡£");
1549 msg_print("You may retire (commit suicide) when you are ready.");
1555 * Modify the physical damage done to the monster.
1556 * (for example when it's invulnerable or shielded)
1558 * ToDo: Accept a damage-type to calculate the modified damage from
1559 * things like fire, frost, lightning, poison, ... attacks.
1561 * "type" is not yet used and should be 0.
1563 int mon_damage_mod(monster_type *m_ptr, int dam, bool is_psy_spear)
1565 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1567 if ((r_ptr->flagsr & RFR_RES_ALL) && dam > 0)
1570 if((dam == 0) && one_in_(3)) dam = 1;
1573 if (m_ptr->invulner)
1577 if(!p_ptr->blind && m_ptr->ml)
1580 msg_print("¥Ð¥ê¥¢¤òÀÚ¤êÎö¤¤¤¿¡ª");
1582 msg_print("The barrier is penetrated!");
1586 else if (!one_in_(PENETRATE_INVULNERABILITY))
1594 static void get_exp_from_mon(int dam, monster_type *m_ptr)
1596 s32b div, new_exp, new_exp_frac;
1597 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1598 int monnum_penarty = 0;
1600 if (!m_ptr->r_idx) return;
1601 if (is_pet(m_ptr) || p_ptr->inside_battle) return;
1605 u32b m_exp_h, m_exp_l;
1607 if ((r_ptr->flags2 & RF2_MULTIPLY) || (m_ptr->r_idx == MON_DAWN))
1609 monnum_penarty = r_ptr->r_pkills / 400;
1610 if (monnum_penarty > 8) monnum_penarty = 8;
1612 if (r_ptr->flags1 & RF1_UNIQUE)
1614 m_exp = (long)r_ptr->mexp * r_ptr->level;
1615 div = (p_ptr->max_plv+2);
1619 m_exp = (long)r_ptr->mexp * r_ptr->level * SPEED_TO_ENERGY(m_ptr->mspeed);
1620 div = (p_ptr->max_plv+2) * SPEED_TO_ENERGY(r_ptr->speed);
1622 m_exp_h = m_exp/0x10000L;
1623 m_exp_l = m_exp%0x10000L;
1626 m_exp_h += m_exp_l / 0x10000L;
1627 m_exp_l %= 0x10000L;
1629 /* real monster maxhp have effect on EXP */
1630 if(!(r_ptr->flags1 & RF1_FORCE_MAXHP))
1632 u32b maxhp = m_ptr->max_maxhp*2;
1635 m_exp_h += m_exp_l / 0x10000L;
1636 m_exp_l %= 0x10000L;
1638 div *= r_ptr->hdice * (r_ptr->hside + 1);
1640 if (!dun_level && (!(r_ptr->flags8 & RF8_WILD_ONLY) || !(r_ptr->flags1 & RF1_UNIQUE))) div *= 5;
1641 div_h = div/0x10000L;
1642 div_l = div%0x10000L;
1643 div_h *= (m_ptr->max_maxhp*2);
1644 div_l *= (m_ptr->max_maxhp*2);
1645 div_h += div_l / 0x10000L;
1648 while (monnum_penarty)
1652 div_h += div_l / 0x10000L;
1657 m_exp_l = (0x7fffffff & (m_exp_h << 16)) | m_exp_l;
1658 m_exp_h = m_exp_h >> 15;
1659 div_l = (0x7fffffff & (div_h << 16)) | div_l;
1660 div_h = div_h >> 15;
1662 #define M_INT_GREATER63(h1,l1,h2,l2) ( (h1>h2)||( (h1==h2)&&(l1>=l2)))
1663 #define M_INT_SUB63(h1,l1, h2,l2) {h1-=h2;if(l1<l2){l1+=0x80000000;h1--;}l1-=l2;}
1664 #define M_INT_LSHIFT63(h1,l1) {h1=(h1<<1)|(l1>>30);l1=(l1<<1)&0x7fffffff;}
1665 #define M_INT_RSHIFT63(h1,l1) {l1=(l1>>1)|(h1<<30);h1>>=1;}
1666 #define M_INT_DIV63(h1,l1,h2,l2,result) \
1670 while( M_INT_GREATER63(h1,l1, h2, l2) ){M_INT_LSHIFT63(h2, l2); bit<<=1;} \
1671 for(bit>>=1; bit>=1; bit>>=1){ \
1672 M_INT_RSHIFT63(h2, l2); \
1673 if(M_INT_GREATER63(h1, l1, h2, l2)) \
1674 {result|=bit;M_INT_SUB63(h1, l1, h2, l2);} \
1678 /* Give some experience for the kill */
1679 M_INT_DIV63(m_exp_h, m_exp_l, div_h, div_l, new_exp);
1681 /* Handle fractional experience */
1682 /* multiply 0x10000L to remainder */
1683 m_exp_h = (m_exp_h<<16) | (m_exp_l>>15);
1685 M_INT_DIV63(m_exp_h, m_exp_l, div_h, div_l, new_exp_frac);
1686 new_exp_frac += p_ptr->exp_frac;
1687 /* Keep track of experience */
1688 if (new_exp_frac >= 0x10000L)
1691 p_ptr->exp_frac = (u16b)(new_exp_frac - 0x10000L);
1695 p_ptr->exp_frac = (u16b)new_exp_frac;
1698 /* Gain experience */
1706 * Decreases monsters hit points, handling monster death.
1708 * We return TRUE if the monster has been killed (and deleted).
1710 * We announce monster death (using an optional "death message"
1711 * if given, and a otherwise a generic killed/destroyed message).
1713 * Only "physical attacks" can induce the "You have slain" message.
1714 * Missile and Spell attacks will induce the "dies" message, or
1715 * various "specialized" messages. Note that "You have destroyed"
1716 * and "is destroyed" are synonyms for "You have slain" and "dies".
1718 * Hack -- unseen monsters yield "You have killed it." message.
1720 * Added fear (DGK) and check whether to print fear messages -CWS
1722 * Made name, sex, and capitalization generic -BEN-
1724 * As always, the "ghost" processing is a total hack.
1726 * Hack -- we "delay" fear messages by passing around a "fear" flag.
1728 * XXX XXX XXX Consider decreasing monster experience over time, say,
1729 * by using "(m_exp * m_lev * (m_lev)) / (p_lev * (m_lev + n_killed))"
1730 * instead of simply "(m_exp * m_lev) / (p_lev)", to make the first
1731 * monster worth more than subsequent monsters. This would also need
1732 * to induce changes in the monster recall code.
1734 bool mon_take_hit(int m_idx, int dam, bool *fear, cptr note)
1736 monster_type *m_ptr = &m_list[m_idx];
1737 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1739 monster_type exp_mon;
1741 /* Innocent until proven otherwise */
1742 bool innocent = TRUE, thief = FALSE;
1746 COPY(&exp_mon, m_ptr, monster_type);
1747 if (!(r_ptr->flags7 & RF7_KILL_EXP))
1749 expdam = (m_ptr->hp > dam) ? dam : m_ptr->hp;
1750 if (r_ptr->flags6 & RF6_HEAL) expdam = (expdam+1) * 2 / 3;
1752 get_exp_from_mon(expdam, &exp_mon);
1755 /* Redraw (later) if needed */
1756 if (p_ptr->health_who == m_idx) p_ptr->redraw |= (PR_HEALTH);
1757 if (p_ptr->riding == m_idx) p_ptr->redraw |= (PR_UHEALTH);
1762 if (r_ptr->flags7 & RF7_HAS_LD_MASK) p_ptr->update |= (PU_MON_LITE);
1764 /* Hack - Cancel any special player stealth magics. -LM- */
1765 if (p_ptr->special_defense & NINJA_S_STEALTH)
1767 set_superstealth(FALSE);
1773 /* It is dead now */
1778 if (r_info[m_ptr->r_idx].flags7 & RF7_TANUKI)
1780 /* You might have unmasked Tanuki first time */
1781 r_ptr = &r_info[m_ptr->r_idx];
1782 m_ptr->ap_r_idx = m_ptr->r_idx;
1783 if (r_ptr->r_sights < MAX_SHORT) r_ptr->r_sights++;
1786 if (m_ptr->mflag2 & MFLAG2_CHAMELEON)
1788 /* You might have unmasked Chameleon first time */
1789 r_ptr = real_r_ptr(m_ptr);
1790 if (r_ptr->r_sights < MAX_SHORT) r_ptr->r_sights++;
1793 if (!(m_ptr->smart & SM_CLONED))
1795 /* When the player kills a Unique, it stays dead */
1796 if (r_ptr->flags1 & RF1_UNIQUE)
1800 /* Mega-Hack -- Banor & Lupart */
1801 if ((m_ptr->r_idx == MON_BANOR) || (m_ptr->r_idx == MON_LUPART))
1803 r_info[MON_BANORLUPART].max_num = 0;
1804 r_info[MON_BANORLUPART].r_pkills++;
1805 if (r_info[MON_BANORLUPART].r_tkills < MAX_SHORT) r_info[MON_BANORLUPART].r_tkills++;
1807 else if (m_ptr->r_idx == MON_BANORLUPART)
1809 r_info[MON_BANOR].max_num = 0;
1810 r_info[MON_BANOR].r_pkills++;
1811 if (r_info[MON_BANOR].r_tkills < MAX_SHORT) r_info[MON_BANOR].r_tkills++;
1812 r_info[MON_LUPART].max_num = 0;
1813 r_info[MON_LUPART].r_pkills++;
1814 if (r_info[MON_LUPART].r_tkills < MAX_SHORT) r_info[MON_LUPART].r_tkills++;
1818 /* When the player kills a Nazgul, it stays dead */
1819 else if (r_ptr->flags7 & RF7_NAZGUL) r_ptr->max_num--;
1822 /* Recall even invisible uniques or winners */
1823 if (m_ptr->ml || (r_ptr->flags1 & RF1_UNIQUE))
1825 /* Count kills this life */
1826 if ((m_ptr->mflag2 & MFLAG2_KAGE) && (r_info[MON_KAGE].r_pkills < MAX_SHORT)) r_info[MON_KAGE].r_pkills++;
1827 else if (r_ptr->r_pkills < MAX_SHORT) r_ptr->r_pkills++;
1829 /* Count kills in all lives */
1830 if ((m_ptr->mflag2 & MFLAG2_KAGE) && (r_info[MON_KAGE].r_tkills < MAX_SHORT)) r_info[MON_KAGE].r_tkills++;
1831 else if (r_ptr->r_tkills < MAX_SHORT) r_ptr->r_tkills++;
1833 /* Hack -- Auto-recall */
1834 monster_race_track(m_ptr->ap_r_idx);
1837 /* Extract monster name */
1838 monster_desc(m_name, m_ptr, MD_TRUE_NAME);
1840 /* Don't kill Amberites */
1841 if ((r_ptr->flags3 & RF3_AMBERITE) && one_in_(2))
1843 int curses = 1 + randint1(3);
1844 bool stop_ty = FALSE;
1848 msg_format("%^s¤Ï¶²¤í¤·¤¤·ì¤Î¼ö¤¤¤ò¤¢¤Ê¤¿¤Ë¤«¤±¤¿¡ª", m_name);
1850 msg_format("%^s puts a terrible blood curse on you!", m_name);
1853 curse_equipment(100, 50);
1857 stop_ty = activate_ty_curse(stop_ty, &count);
1862 if (r_ptr->flags2 & RF2_CAN_SPEAK)
1864 char line_got[1024];
1866 /* Dump a message */
1868 if (!get_rnd_line("mondeath_j.txt", m_ptr->r_idx, line_got))
1870 if (!get_rnd_line("mondeath.txt", m_ptr->r_idx, line_got))
1873 msg_format("%^s %s", m_name, line_got);
1876 if (m_ptr->r_idx == MON_SERPENT)
1878 /* Make screen dump */
1879 screen_dump = make_screen_dump();
1884 if (!(d_info[dungeon_type].flags1 & DF1_BEGINNER))
1886 if (!dun_level && !ambush_flag && !p_ptr->inside_arena)
1888 chg_virtue(V_VALOUR, -1);
1890 else if (r_ptr->level > dun_level)
1892 if (randint1(10) <= (r_ptr->level - dun_level))
1893 chg_virtue(V_VALOUR, 1);
1895 if (r_ptr->level > 60)
1897 chg_virtue(V_VALOUR, 1);
1899 if (r_ptr->level >= 2 * (p_ptr->lev+1))
1900 chg_virtue(V_VALOUR, 2);
1903 if (r_ptr->flags1 & RF1_UNIQUE)
1905 if (r_ptr->flags3 & (RF3_EVIL | RF3_GOOD)) chg_virtue(V_HARMONY, 2);
1907 if (r_ptr->flags3 & RF3_GOOD)
1909 chg_virtue(V_UNLIFE, 2);
1910 chg_virtue(V_VITALITY, -2);
1913 if (one_in_(3)) chg_virtue(V_INDIVIDUALISM, -1);
1916 if (m_ptr->r_idx == MON_BEGGAR || m_ptr->r_idx == MON_LEPER)
1918 chg_virtue(V_COMPASSION, -1);
1921 if ((r_ptr->flags3 & RF3_GOOD) &&
1922 ((r_ptr->level) / 10 + (3 * dun_level) >= randint1(100)))
1923 chg_virtue(V_UNLIFE, 1);
1925 if (r_ptr->d_char == 'A')
1927 if (r_ptr->flags1 & RF1_UNIQUE)
1928 chg_virtue(V_FAITH, -2);
1929 else if ((r_ptr->level) / 10 + (3 * dun_level) >= randint1(100))
1931 if (r_ptr->flags3 & RF3_GOOD) chg_virtue(V_FAITH, -1);
1932 else chg_virtue(V_FAITH, 1);
1935 else if (r_ptr->flags3 & RF3_DEMON)
1937 if (r_ptr->flags1 & RF1_UNIQUE)
1938 chg_virtue(V_FAITH, 2);
1939 else if ((r_ptr->level) / 10 + (3 * dun_level) >= randint1(100))
1940 chg_virtue(V_FAITH, 1);
1943 if ((r_ptr->flags3 & RF3_UNDEAD) && (r_ptr->flags1 & RF1_UNIQUE))
1944 chg_virtue(V_VITALITY, 2);
1946 if (r_ptr->r_deaths)
1948 if (r_ptr->flags1 & RF1_UNIQUE)
1950 chg_virtue(V_HONOUR, 10);
1952 else if ((r_ptr->level) / 10 + (2 * dun_level) >= randint1(100))
1954 chg_virtue(V_HONOUR, 1);
1957 if ((r_ptr->flags2 & RF2_MULTIPLY) && (r_ptr->r_pkills > 1000) && one_in_(10))
1959 chg_virtue(V_VALOUR, -1);
1962 for (i = 0; i < 4; i++)
1964 if (r_ptr->blow[i].d_dice != 0) innocent = FALSE; /* Murderer! */
1966 if ((r_ptr->blow[i].effect == RBE_EAT_ITEM)
1967 || (r_ptr->blow[i].effect == RBE_EAT_GOLD))
1969 thief = TRUE; /* Thief! */
1972 /* The new law says it is illegal to live in the dungeon */
1973 if (r_ptr->level != 0) innocent = FALSE;
1977 if (r_ptr->flags1 & RF1_UNIQUE)
1978 chg_virtue(V_JUSTICE, 3);
1979 else if (1+((r_ptr->level) / 10 + (2 * dun_level))
1981 chg_virtue(V_JUSTICE, 1);
1985 chg_virtue (V_JUSTICE, -1);
1988 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)))
1990 if (one_in_(4)) chg_virtue(V_NATURE, -1);
1993 if ((r_ptr->flags1 & RF1_UNIQUE) && record_destroy_uniq)
1997 sprintf(note_buf, "%s%s", r_name + r_ptr->name, (m_ptr->smart & SM_CLONED) ? "(¥¯¥í¡¼¥ó)" : "");
1999 sprintf(note_buf, "%s%s", r_name + r_ptr->name, (m_ptr->smart & SM_CLONED) ? "(Clone)" : "");
2001 do_cmd_write_nikki(NIKKI_UNIQUE, 0, note_buf);
2007 /* Death by Missile/Spell attack */
2010 msg_format("%^s%s", m_name, note);
2013 /* Death by physical attack -- invisible monster */
2014 else if (!m_ptr->ml)
2017 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
2018 msg_format("¤»¤Ã¤«¤¯¤À¤«¤é%s¤ò»¦¤·¤¿¡£", m_name);
2020 msg_format("%s¤ò»¦¤·¤¿¡£", m_name);
2022 msg_format("You have killed %s.", m_name);
2027 /* Death by Physical attack -- non-living monster */
2028 else if (!monster_living(r_ptr))
2031 bool explode = FALSE;
2033 for (i = 0; i < 4; i++)
2035 if (r_ptr->blow[i].method == RBM_EXPLODE) explode = TRUE;
2038 /* Special note at death */
2041 msg_format("%s¤ÏÇúȯ¤·¤ÆÊ´¡¹¤Ë¤Ê¤Ã¤¿¡£", m_name);
2043 msg_format("%s explodes into tiny shreds.", m_name);
2048 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
2049 msg_format("¤»¤Ã¤«¤¯¤À¤«¤é%s¤òÅݤ·¤¿¡£", m_name);
2051 msg_format("%s¤òÅݤ·¤¿¡£", m_name);
2053 msg_format("You have destroyed %s.", m_name);
2058 /* Death by Physical attack -- living monster */
2062 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
2063 msg_format("¤»¤Ã¤«¤¯¤À¤«¤é%s¤òÁò¤êµî¤Ã¤¿¡£", m_name);
2065 msg_format("%s¤òÁò¤êµî¤Ã¤¿¡£", m_name);
2067 msg_format("You have slain %s.", m_name);
2071 if ((r_ptr->flags1 & RF1_UNIQUE) && !(m_ptr->smart & SM_CLONED) && !vanilla_town)
2073 for (i = 0; i < MAX_KUBI; i++)
2075 if ((kubi_r_idx[i] == m_ptr->r_idx) && !(m_ptr->mflag2 & MFLAG2_CHAMELEON))
2078 msg_format("%s¤Î¼ó¤Ë¤Ï¾Þ¶â¤¬¤«¤«¤Ã¤Æ¤¤¤ë¡£", m_name);
2080 msg_format("There is a price on %s's head.", m_name);
2087 /* Generate treasure */
2088 monster_death(m_idx, TRUE);
2090 /* Mega hack : replace IKETA to BIKETAL */
2091 if ((m_ptr->r_idx == MON_IKETA) &&
2092 !(p_ptr->inside_arena || p_ptr->inside_battle))
2094 int dummy_y = m_ptr->fy;
2095 int dummy_x = m_ptr->fx;
2098 if (is_pet(m_ptr)) mode |= PM_FORCE_PET;
2100 /* Delete the monster */
2101 delete_monster_idx(m_idx);
2103 if (summon_named_creature(0, dummy_y, dummy_x, MON_BIKETAL, mode))
2106 msg_print("¡Ö¥Ï¥¡¥Ã¥Ï¥Ã¥Ï¥Ã¥Ï¡ª¡ª»ä¤¬¥Ð¥¤¥±¥¿¥ë¤À¡ª¡ª¡×");
2108 msg_print("Uwa-hahaha! *I* am Biketal!");
2114 /* Delete the monster */
2115 delete_monster_idx(m_idx);
2118 /* Prevent bug of chaos patron's reward */
2119 if (r_ptr->flags7 & RF7_KILL_EXP)
2120 get_exp_from_mon((long)exp_mon.max_maxhp*2, &exp_mon);
2122 get_exp_from_mon(((long)exp_mon.max_maxhp+1L) * 9L / 10L, &exp_mon);
2127 /* Monster is dead */
2134 /* Mega-Hack -- Pain cancels fear */
2135 if (m_ptr->monfear && (dam > 0))
2137 int tmp = randint1(dam);
2139 /* Cure a little fear */
2140 if (tmp < m_ptr->monfear)
2143 m_ptr->monfear -= tmp;
2146 /* Cure all the fear */
2157 /* Sometimes a monster gets scared by damage */
2158 if (!m_ptr->monfear && !(r_ptr->flags3 & (RF3_NO_FEAR)))
2162 /* Percentage of fully healthy */
2163 percentage = (100L * m_ptr->hp) / m_ptr->maxhp;
2166 * Run (sometimes) if at 10% or less of max hit points,
2167 * or (usually) when hit for half its current hit points
2169 if ((randint1(10) >= percentage) ||
2170 ((dam >= m_ptr->hp) && (randint0(100) < 80)))
2172 /* Hack -- note fear */
2175 /* XXX XXX XXX Hack -- Add some timed fear */
2176 m_ptr->monfear = (randint1(10) +
2177 (((dam >= m_ptr->hp) && (percentage > 7)) ?
2178 20 : ((11 - percentage) * 5)));
2185 if (p_ptr->riding && (p_ptr->riding == m_idx) && (dam > 0))
2189 /* Extract monster name */
2190 monster_desc(m_name, m_ptr, 0);
2192 if (m_ptr->hp > m_ptr->maxhp/3) dam = (dam + 1) / 2;
2193 if (rakuba((dam > 200) ? 200 : dam, FALSE))
2196 msg_format("%^s¤Ë¿¶¤êÍî¤È¤µ¤ì¤¿¡ª", m_name);
2198 msg_format("%^s has thrown you off!", m_name);
2210 * Get term size and calculate screen size
2212 void get_screen_size(int *wid_p, int *hgt_p)
2214 Term_get_size(wid_p, hgt_p);
2215 *hgt_p -= ROW_MAP + 2;
2216 *wid_p -= COL_MAP + 2;
2217 if (use_bigtile) *wid_p /= 2;
2222 * Calculates current boundaries
2223 * Called below and from "do_cmd_locate()".
2225 void panel_bounds_center(void)
2230 get_screen_size(&wid, &hgt);
2232 panel_row_max = panel_row_min + hgt - 1;
2233 panel_row_prt = panel_row_min - 1;
2234 panel_col_max = panel_col_min + wid - 1;
2235 panel_col_prt = panel_col_min - 13;
2240 * Map resizing whenever the main term changes size
2242 void resize_map(void)
2244 /* Only if the dungeon exists */
2245 if (!character_dungeon) return;
2247 /* Mega-Hack -- no panel yet */
2251 /* Reset the panels */
2252 panel_row_min = cur_hgt;
2253 panel_col_min = cur_wid;
2258 p_ptr->update |= (PU_TORCH | PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
2260 /* Forget lite/view */
2261 p_ptr->update |= (PU_UN_VIEW | PU_UN_LITE);
2263 /* Update lite/view */
2264 p_ptr->update |= (PU_VIEW | PU_LITE | PU_MON_LITE);
2266 /* Update monsters */
2267 p_ptr->update |= (PU_MONSTERS);
2269 /* Redraw everything */
2270 p_ptr->redraw |= (PR_WIPE | PR_BASIC | PR_EXTRA | PR_MAP | PR_EQUIPPY);
2272 /* Hack -- update */
2280 * Place the cursor on the player
2282 if (can_save) move_cursor_relative(py, px);
2289 * Redraw a term when it is resized
2291 void redraw_window(void)
2293 /* Only if the dungeon exists */
2294 if (!character_dungeon) return;
2296 /* Hack - Activate term zero for the redraw */
2297 Term_activate(&term_screen[0]);
2299 /* Hack -- react to changes */
2300 Term_xtra(TERM_XTRA_REACT, 0);
2303 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_SPELL | PW_PLAYER);
2306 p_ptr->window |= (PW_MESSAGE | PW_OVERHEAD | PW_DUNGEON | PW_MONSTER | PW_OBJECT);
2308 /* Hack -- update */
2320 * Handle a request to change the current panel
2322 * Return TRUE if the panel was changed.
2324 * Also used in do_cmd_locate
2326 bool change_panel(int dy, int dx)
2332 get_screen_size(&wid, &hgt);
2334 /* Apply the motion */
2335 y = panel_row_min + dy * hgt / 2;
2336 x = panel_col_min + dx * wid / 2;
2338 /* Verify the row */
2339 if (y > cur_hgt - hgt) y = cur_hgt - hgt;
2342 /* Verify the col */
2343 if (x > cur_wid - wid) x = cur_wid - wid;
2346 /* Handle "changes" */
2347 if ((y != panel_row_min) || (x != panel_col_min))
2349 /* Save the new panel info */
2353 /* Recalculate the boundaries */
2354 panel_bounds_center();
2357 p_ptr->update |= (PU_MONSTERS);
2360 p_ptr->redraw |= (PR_MAP);
2375 * Given an row (y) and col (x), this routine detects when a move
2376 * off the screen has occurred and figures new borders. -RAK-
2378 * "Update" forces a "full update" to take place.
2380 * The map is reprinted if necessary, and "TRUE" is returned.
2382 void verify_panel(void)
2394 get_screen_size(&wid, &hgt);
2396 max_prow_min = cur_hgt - hgt;
2397 max_pcol_min = cur_wid - wid;
2399 /* Bounds checking */
2400 if (max_prow_min < 0) max_prow_min = 0;
2401 if (max_pcol_min < 0) max_pcol_min = 0;
2403 /* Center on player */
2404 if (center_player && (center_running || !running))
2406 /* Center vertically */
2407 prow_min = y - hgt / 2;
2408 if (prow_min < 0) prow_min = 0;
2409 else if (prow_min > max_prow_min) prow_min = max_prow_min;
2411 /* Center horizontally */
2412 pcol_min = x - wid / 2;
2413 if (pcol_min < 0) pcol_min = 0;
2414 else if (pcol_min > max_pcol_min) pcol_min = max_pcol_min;
2418 prow_min = panel_row_min;
2419 pcol_min = panel_col_min;
2421 /* Scroll screen when 2 grids from top/bottom edge */
2422 if (y > panel_row_max - 2)
2424 while (y > prow_min + hgt-1 - 2)
2426 prow_min += (hgt / 2);
2430 if (y < panel_row_min + 2)
2432 while (y < prow_min + 2)
2434 prow_min -= (hgt / 2);
2438 if (prow_min > max_prow_min) prow_min = max_prow_min;
2439 if (prow_min < 0) prow_min = 0;
2441 /* Scroll screen when 4 grids from left/right edge */
2442 if (x > panel_col_max - 4)
2444 while (x > pcol_min + wid-1 - 4)
2446 pcol_min += (wid / 2);
2450 if (x < panel_col_min + 4)
2452 while (x < pcol_min + 4)
2454 pcol_min -= (wid / 2);
2458 if (pcol_min > max_pcol_min) pcol_min = max_pcol_min;
2459 if (pcol_min < 0) pcol_min = 0;
2462 /* Check for "no change" */
2463 if ((prow_min == panel_row_min) && (pcol_min == panel_col_min)) return;
2465 /* Save the new panel info */
2466 panel_row_min = prow_min;
2467 panel_col_min = pcol_min;
2469 /* Hack -- optional disturb on "panel change" */
2470 if (disturb_panel && !center_player) disturb(0, 0);
2472 /* Recalculate the boundaries */
2473 panel_bounds_center();
2476 p_ptr->update |= (PU_MONSTERS);
2479 p_ptr->redraw |= (PR_MAP);
2482 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
2487 * Monster health description
2489 cptr look_mon_desc(monster_type *m_ptr, u32b mode)
2491 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
2498 /* Determine if the monster is "living" */
2499 living = monster_living(ap_r_ptr);
2501 /* Calculate a health "percentage" */
2502 perc = 100L * m_ptr->hp / m_ptr->maxhp;
2504 /* Healthy monsters */
2505 if (m_ptr->hp >= m_ptr->maxhp)
2509 desc = living ? "̵½ý" : "̵¥À¥á¡¼¥¸";
2511 desc = living ? "unhurt" : "undamaged";
2516 else if (perc >= 60)
2519 desc = living ? "·Ú½ý" : "¾®¥À¥á¡¼¥¸";
2521 desc = living ? "somewhat wounded" : "somewhat damaged";
2526 else if (perc >= 25)
2529 desc = living ? "Éé½ý" : "Ãæ¥À¥á¡¼¥¸";
2531 desc = living ? "wounded" : "damaged";
2536 else if (perc >= 10)
2539 desc = living ? "½Å½ý" : "Âç¥À¥á¡¼¥¸";
2541 desc = living ? "badly wounded" : "badly damaged";
2549 desc = living ? "Ⱦ»àȾÀ¸" : "Åݤ줫¤±";
2551 desc = living ? "almost dead" : "almost destroyed";
2556 /* Need attitude information? */
2559 /* Full information is not needed */
2562 else if (is_pet(m_ptr))
2565 attitude = ", ¥Ú¥Ã¥È";
2570 else if (is_friendly(m_ptr))
2573 attitude = ", ͧ¹¥Åª";
2575 attitude = ", friendly";
2588 /* Clone monster? */
2589 if (m_ptr->smart & SM_CLONED)
2598 /* Display monster's level --- idea borrowed from ToME */
2599 if (ap_r_ptr->r_tkills && !(m_ptr->mflag2 & MFLAG2_KAGE))
2602 return format("¥ì¥Ù¥ë%d, %s%s%s", ap_r_ptr->level, desc, attitude, clone);
2604 return format("Level %d, %s%s%s", ap_r_ptr->level, desc, attitude, clone);
2610 return format("¥ì¥Ù¥ë???, %s%s%s", desc, attitude, clone);
2612 return format("Level ???, %s%s%s", desc, attitude, clone);
2620 * Angband sorting algorithm -- quick sort in place
2622 * Note that the details of the data we are sorting is hidden,
2623 * and we rely on the "ang_sort_comp()" and "ang_sort_swap()"
2624 * function hooks to interact with the data, which is given as
2625 * two pointers, and which may have any user-defined form.
2627 void ang_sort_aux(vptr u, vptr v, int p, int q)
2645 while (!(*ang_sort_comp)(u, v, b, z)) b--;
2648 while (!(*ang_sort_comp)(u, v, z, a)) a++;
2650 /* Done partition */
2654 (*ang_sort_swap)(u, v, a, b);
2660 /* Recurse left side */
2661 ang_sort_aux(u, v, p, b);
2663 /* Recurse right side */
2664 ang_sort_aux(u, v, b+1, q);
2669 * Angband sorting algorithm -- quick sort in place
2671 * Note that the details of the data we are sorting is hidden,
2672 * and we rely on the "ang_sort_comp()" and "ang_sort_swap()"
2673 * function hooks to interact with the data, which is given as
2674 * two pointers, and which may have any user-defined form.
2676 void ang_sort(vptr u, vptr v, int n)
2678 /* Sort the array */
2679 ang_sort_aux(u, v, 0, n-1);
2684 /*** Targeting Code ***/
2688 * Determine is a monster makes a reasonable target
2690 * The concept of "targeting" was stolen from "Morgul" (?)
2692 * The player can target any location, or any "target-able" monster.
2694 * Currently, a monster is "target_able" if it is visible, and if
2695 * the player can hit it with a projection, and the player is not
2696 * hallucinating. This allows use of "use closest target" macros.
2698 * Future versions may restrict the ability to target "trappers"
2699 * and "mimics", but the semantics is a little bit weird.
2701 bool target_able(int m_idx)
2703 monster_type *m_ptr = &m_list[m_idx];
2705 /* Monster must be alive */
2706 if (!m_ptr->r_idx) return (FALSE);
2708 /* Hack -- no targeting hallucinations */
2709 if (p_ptr->image) return (FALSE);
2711 /* Monster must be visible */
2712 if (!m_ptr->ml) return (FALSE);
2714 if (p_ptr->riding && (p_ptr->riding == m_idx)) return (TRUE);
2716 /* Monster must be projectable */
2717 if (!projectable(py, px, m_ptr->fy, m_ptr->fx)) return (FALSE);
2719 /* XXX XXX XXX Hack -- Never target trappers */
2720 /* if (CLEAR_ATTR && (CLEAR_CHAR)) return (FALSE); */
2730 * Update (if necessary) and verify (if possible) the target.
2732 * We return TRUE if the target is "okay" and FALSE otherwise.
2734 bool target_okay(void)
2736 /* Accept stationary targets */
2737 if (target_who < 0) return (TRUE);
2739 /* Check moving targets */
2742 /* Accept reasonable targets */
2743 if (target_able(target_who))
2745 monster_type *m_ptr = &m_list[target_who];
2747 /* Acquire monster location */
2748 target_row = m_ptr->fy;
2749 target_col = m_ptr->fx;
2756 /* Assume no target */
2763 * Sorting hook -- comp function -- by "distance to player"
2765 * We use "u" and "v" to point to arrays of "x" and "y" positions,
2766 * and sort the arrays by double-distance to the player.
2768 static bool ang_sort_comp_distance(vptr u, vptr v, int a, int b)
2770 byte *x = (byte*)(u);
2771 byte *y = (byte*)(v);
2775 /* Absolute distance components */
2776 kx = x[a]; kx -= px; kx = ABS(kx);
2777 ky = y[a]; ky -= py; ky = ABS(ky);
2779 /* Approximate Double Distance to the first point */
2780 da = ((kx > ky) ? (kx + kx + ky) : (ky + ky + kx));
2782 /* Absolute distance components */
2783 kx = x[b]; kx -= px; kx = ABS(kx);
2784 ky = y[b]; ky -= py; ky = ABS(ky);
2786 /* Approximate Double Distance to the first point */
2787 db = ((kx > ky) ? (kx + kx + ky) : (ky + ky + kx));
2789 /* Compare the distances */
2795 * Sorting hook -- swap function -- by "distance to player"
2797 * We use "u" and "v" to point to arrays of "x" and "y" positions,
2798 * and sort the arrays by distance to the player.
2800 static void ang_sort_swap_distance(vptr u, vptr v, int a, int b)
2802 byte *x = (byte*)(u);
2803 byte *y = (byte*)(v);
2821 * Hack -- help "select" a location (see below)
2823 static s16b target_pick(int y1, int x1, int dy, int dx)
2827 int x2, y2, x3, y3, x4, y4;
2829 int b_i = -1, b_v = 9999;
2832 /* Scan the locations */
2833 for (i = 0; i < temp_n; i++)
2839 /* Directed distance */
2843 /* Verify quadrant */
2844 if (dx && (x3 * dx <= 0)) continue;
2845 if (dy && (y3 * dy <= 0)) continue;
2847 /* Absolute distance */
2851 /* Verify quadrant */
2852 if (dy && !dx && (x4 > y4)) continue;
2853 if (dx && !dy && (y4 > x4)) continue;
2855 /* Approximate Double Distance */
2856 v = ((x4 > y4) ? (x4 + x4 + y4) : (y4 + y4 + x4));
2858 /* XXX XXX XXX Penalize location */
2861 if ((b_i >= 0) && (v >= b_v)) continue;
2873 * Hack -- determine if a given location is "interesting"
2875 static bool target_set_accept(int y, int x)
2879 s16b this_o_idx, next_o_idx = 0;
2882 if (!(in_bounds(y, x))) return (FALSE);
2884 /* Player grid is always interesting */
2885 if (player_bold(y, x)) return (TRUE);
2888 /* Handle hallucination */
2889 if (p_ptr->image) return (FALSE);
2892 /* Examine the grid */
2893 c_ptr = &cave[y][x];
2895 /* Visible monsters */
2898 monster_type *m_ptr = &m_list[c_ptr->m_idx];
2900 /* Visible monsters */
2901 if (m_ptr->ml) return (TRUE);
2904 /* Scan all objects in the grid */
2905 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
2909 /* Acquire object */
2910 o_ptr = &o_list[this_o_idx];
2912 /* Acquire next object */
2913 next_o_idx = o_ptr->next_o_idx;
2915 /* Memorized object */
2916 if (o_ptr->marked) return (TRUE);
2919 /* Interesting memorized features */
2920 if (c_ptr->info & (CAVE_MARK))
2922 /* Notice object features */
2923 if (c_ptr->info & CAVE_OBJECT) return (TRUE);
2925 /* Feature code (applying "mimic" field) */
2926 if (have_flag(f_info[get_feat_mimic(c_ptr)].flags, FF_NOTICE)) return TRUE;
2935 * Prepare the "temp" array for "target_set"
2937 * Return the number of target_able monsters in the set.
2939 static void target_set_prepare(int mode)
2943 /* Reset "temp" array */
2946 /* Scan the current panel */
2947 for (y = panel_row_min; y <= panel_row_max; y++)
2949 for (x = panel_col_min; x <= panel_col_max; x++)
2953 /* Require "interesting" contents */
2954 if (!target_set_accept(y, x)) continue;
2956 c_ptr = &cave[y][x];
2958 /* Require target_able monsters for "TARGET_KILL" */
2959 if ((mode & (TARGET_KILL)) && !target_able(c_ptr->m_idx)) continue;
2961 if ((mode & (TARGET_KILL)) && !target_pet && is_pet(&m_list[c_ptr->m_idx])) continue;
2963 /* Save the location */
2970 /* Set the sort hooks */
2971 ang_sort_comp = ang_sort_comp_distance;
2972 ang_sort_swap = ang_sort_swap_distance;
2974 /* Sort the positions */
2975 ang_sort(temp_x, temp_y, temp_n);
2977 if (p_ptr->riding && target_pet && (temp_n > 1) && (mode & (TARGET_KILL)))
2982 temp_y[0] = temp_y[1];
2985 temp_x[0] = temp_x[1];
2992 * Evaluate number of kill needed to gain level
2994 static void evaluate_monster_exp(char *buf, monster_type *m_ptr)
2996 #define M_INT_GREATER(h1,l1,h2,l2) ( (h1>h2)||( (h1==h2)&&(l1>=l2)))
2997 #define M_INT_SUB(h1,l1, h2,l2) {h1-=h2;if(l1<l2){l1+=0x10000;h1--;}l1-=l2;}
2998 #define M_INT_ADD(h1,l1, h2,l2) {h1+=h2;l1+=l2;if(l1>=0x10000L){l1&=0xFFFF;h1++;}}
2999 #define M_INT_LSHIFT(h1,l1) {h1=(h1<<1)|(l1>>15);l1=(l1<<1)&0xffff;}
3000 #define M_INT_RSHIFT(h1,l1) {l1=(l1>>1)|((h1&1)<<15);h1>>=1;}
3001 #define M_INT_MULT(h1,l1,mul,h2,l2) {l2=(l1*mul)&0xffff;h2=((l1*mul)>>16)+h1*mul;}
3003 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
3007 u32b exp_mon= (ap_r_ptr->mexp)*(ap_r_ptr->level);
3008 u32b exp_mon_h= exp_mon / (p_ptr->max_plv+2);
3009 u32b exp_mon_l= ((exp_mon % (p_ptr->max_plv+2))*0x10000/(p_ptr->max_plv+2))&0xFFFF;
3011 u32b exp_adv_h = player_exp[p_ptr->lev -1] * p_ptr->expfact /100;
3012 u32b exp_adv_l = ((player_exp[p_ptr->lev -1]%100) * p_ptr->expfact *0x10000/100)&0xFFFF;
3014 M_INT_SUB(exp_adv_h, exp_adv_l, p_ptr->exp, p_ptr->exp_frac);
3015 if ((p_ptr->lev>=PY_MAX_LEVEL) || (p_ptr->prace == RACE_ANDROID))
3017 else if (!ap_r_ptr->r_tkills || (m_ptr->mflag2 & MFLAG2_KAGE))
3019 else if (M_INT_GREATER(exp_mon_h, exp_mon_l, exp_adv_h, exp_adv_l))
3023 M_INT_MULT(exp_mon_h, exp_mon_l, 1000,tmp_h, tmp_l);
3024 if( M_INT_GREATER(exp_adv_h, exp_adv_l, tmp_h, tmp_l) )
3029 M_INT_ADD(exp_adv_h, exp_adv_l, exp_mon_h, exp_mon_l);
3030 M_INT_SUB(exp_adv_h, exp_adv_l, 0, 1);
3031 while(M_INT_GREATER(exp_adv_h, exp_adv_l, exp_mon_h,exp_mon_l))
3033 M_INT_LSHIFT(exp_mon_h,exp_mon_l);
3036 M_INT_RSHIFT(exp_mon_h,exp_mon_l);bit>>=1;
3037 for(;bit>=1;bit>>=1)
3039 if(M_INT_GREATER(exp_adv_h,exp_adv_l,exp_mon_h,exp_mon_l))
3042 M_INT_SUB(exp_adv_h,exp_adv_l,exp_mon_h,exp_mon_l);
3044 M_INT_RSHIFT(exp_mon_h,exp_mon_l);
3046 sprintf(buf,"%03d",result);
3053 * Examine a grid, return a keypress.
3055 * The "mode" argument contains the "TARGET_LOOK" bit flag, which
3056 * indicates that the "space" key should scan through the contents
3057 * of the grid, instead of simply returning immediately. This lets
3058 * the "look" command get complete information, without making the
3059 * "target" command annoying.
3061 * The "info" argument contains the "commands" which should be shown
3062 * inside the "[xxx]" text. This string must never be empty, or grids
3063 * containing monsters will be displayed with an extra comma.
3065 * Note that if a monster is in the grid, we update both the monster
3066 * recall info and the health bar info to track that monster.
3068 * Eventually, we may allow multiple objects per grid, or objects
3069 * and terrain features in the same grid. XXX XXX XXX
3071 * This function must handle blindness/hallucination.
3073 static int target_set_aux(int y, int x, int mode, cptr info)
3075 cave_type *c_ptr = &cave[y][x];
3076 s16b this_o_idx, next_o_idx = 0;
3077 cptr s1 = "", s2 = "", s3 = "", x_info = "";
3080 feature_type *f_ptr;
3082 char out_val[MAX_NLEN+80];
3084 #ifdef ALLOW_EASY_FLOOR
3085 int floor_list[23], floor_num = 0;
3087 /* Scan all objects in the grid */
3090 floor_num = scan_floor(floor_list, y, x, 0x02);
3102 #endif /* ALLOW_EASY_FLOOR */
3104 /* Hack -- under the player */
3105 if (player_bold(y, x))
3128 /* Hack -- hallucination */
3132 cptr name = "²¿¤«´ñ̯¤Êʪ";
3134 cptr name = "something strange";
3138 /* Display a message */
3140 sprintf(out_val, "%s%s%s%s [%s]", s1, name, s2, s3, info);
3142 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, name, info);
3146 move_cursor_relative(y, x);
3149 /* Stop on everything but "return" */
3150 if ((query != '\r') && (query != '\n')) return query;
3152 /* Repeat forever */
3157 /* Actual monsters */
3158 if (c_ptr->m_idx && m_list[c_ptr->m_idx].ml)
3160 monster_type *m_ptr = &m_list[c_ptr->m_idx];
3161 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
3163 bool recall = FALSE;
3168 /* Get the monster name ("a kobold") */
3169 monster_desc(m_name, m_ptr, MD_INDEF_VISIBLE);
3171 /* Hack -- track this monster race */
3172 monster_race_track(m_ptr->ap_r_idx);
3174 /* Hack -- health bar for this monster */
3175 health_track(c_ptr->m_idx);
3177 /* Hack -- handle stuff */
3191 /* Recall on screen */
3192 screen_roff(m_ptr->ap_r_idx, 0);
3194 /* Hack -- Complete the prompt (again) */
3196 Term_addstr(-1, TERM_WHITE, format(" [r»× %s%s]", x_info, info));
3198 Term_addstr(-1, TERM_WHITE, format(" [r,%s%s]", x_info, info));
3207 /* Normal commands */
3208 if (query != 'r') break;
3213 /* Cleare recall text and repeat */
3219 /* Describe, and prompt for recall */
3220 evaluate_monster_exp(acount, m_ptr);
3223 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);
3225 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);
3231 move_cursor_relative(y, x);
3236 /* Normal commands */
3237 if (query != 'r') break;
3243 /* Always stop at "normal" keys */
3244 if ((query != '\r') && (query != '\n') && (query != ' ') && (query != 'x')) return query;
3246 /* Sometimes stop at "space" key */
3247 if ((query == ' ') && !(mode & (TARGET_LOOK))) return query;
3249 /* Change the intro */
3257 /* Hack -- take account of gender */
3259 if (ap_r_ptr->flags1 & (RF1_FEMALE)) s1 = "Èà½÷¤Ï";
3261 if (ap_r_ptr->flags1 & (RF1_FEMALE)) s1 = "She is ";
3265 else if (ap_r_ptr->flags1 & (RF1_MALE)) s1 = "Èà¤Ï";
3267 else if (ap_r_ptr->flags1 & (RF1_MALE)) s1 = "He is ";
3271 /* Use a preposition */
3280 /* Scan all objects being carried */
3281 for (this_o_idx = m_ptr->hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
3283 char o_name[MAX_NLEN];
3287 /* Acquire object */
3288 o_ptr = &o_list[this_o_idx];
3290 /* Acquire next object */
3291 next_o_idx = o_ptr->next_o_idx;
3293 /* Obtain an object description */
3294 object_desc(o_name, o_ptr, 0);
3296 /* Describe the object */
3298 sprintf(out_val, "%s%s%s%s[%s]", s1, o_name, s2, s3, info);
3300 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, o_name, info);
3304 move_cursor_relative(y, x);
3307 /* Always stop at "normal" keys */
3308 if ((query != '\r') && (query != '\n') && (query != ' ') && (query != 'x')) return query;
3310 /* Sometimes stop at "space" key */
3311 if ((query == ' ') && !(mode & (TARGET_LOOK))) return query;
3313 /* Change the intro */
3317 s2 = "also carrying ";
3321 /* Use a preposition */
3331 #ifdef ALLOW_EASY_FLOOR
3340 char o_name[MAX_NLEN];
3344 /* Acquire object */
3345 o_ptr = &o_list[floor_list[0]];
3347 /* Describe the object */
3348 object_desc(o_name, o_ptr, 0);
3352 sprintf(out_val, "%s%s%s%s[%s]",
3353 s1, o_name, s2, s3, info);
3355 sprintf(out_val, "%s%s%s%s [%s]",
3356 s1, s2, s3, o_name, info);
3360 move_cursor_relative(y, x);
3369 /* Provide one cushion before item listing */
3372 /* Display rough information about items */
3374 sprintf(out_val, "%s %d¸Ä¤Î¥¢¥¤¥Æ¥à%s%s ['x'¤Ç°ìÍ÷, %s]",
3375 s1, floor_num, s2, s3, info);
3377 sprintf(out_val, "%s%s%sa pile of %d items [x,%s]",
3378 s1, s2, s3, floor_num, info);
3382 move_cursor_relative(y, x);
3387 /* No request for listing */
3388 if (query != 'x' && query != ' ') return query;
3392 /** Display list of items **/
3394 /* Continue scrolling list if requested */
3403 (void)show_floor(0, y, x, &min_width);
3407 sprintf(out_val, "%s %d¸Ä¤Î¥¢¥¤¥Æ¥à%s%s [Enter¤Ç¼¡¤Ø, %s]",
3408 s1, floor_num, s2, s3, info);
3410 sprintf(out_val, "%s%s%sa pile of %d items [Enter,%s]",
3411 s1, s2, s3, floor_num, info);
3422 /* Exit unless 'Enter' */
3423 if (query != '\n' && query != '\r')
3428 /* Get the object being moved. */
3429 o_idx = c_ptr->o_idx;
3431 /* Only rotate a pile of two or more objects. */
3432 if (!(o_idx && o_list[o_idx].next_o_idx)) continue;
3434 /* Remove the first object from the list. */
3435 excise_object_idx(o_idx);
3437 /* Find end of the list. */
3439 while (o_list[i].next_o_idx)
3440 i = o_list[i].next_o_idx;
3442 /* Add after the last object. */
3443 o_list[i].next_o_idx = o_idx;
3445 /* Loop and re-display the list */
3451 #endif /* ALLOW_EASY_FLOOR */
3454 /* Scan all objects in the grid */
3455 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
3459 /* Acquire object */
3460 o_ptr = &o_list[this_o_idx];
3462 /* Acquire next object */
3463 next_o_idx = o_ptr->next_o_idx;
3468 char o_name[MAX_NLEN];
3473 /* Obtain an object description */
3474 object_desc(o_name, o_ptr, 0);
3476 /* Describe the object */
3478 sprintf(out_val, "%s%s%s%s[%s]", s1, o_name, s2, s3, info);
3480 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, o_name, info);
3484 move_cursor_relative(y, x);
3487 /* Always stop at "normal" keys */
3488 if ((query != '\r') && (query != '\n') && (query != ' ') && (query != 'x')) return query;
3490 /* Sometimes stop at "space" key */
3491 if ((query == ' ') && !(mode & TARGET_LOOK)) return query;
3493 /* Change the intro */
3503 if (o_ptr->number != 1) s1 = "¤½¤ì¤é¤Ï";
3505 if (o_ptr->number != 1) s1 = "They are ";
3521 /* Feature code (applying "mimic" field) */
3522 feat = get_feat_mimic(c_ptr);
3524 /* Require knowledge about grid, or ability to see grid */
3525 if (!(c_ptr->info & CAVE_MARK) && !player_can_see_bold(y, x))
3527 /* Forget feature */
3531 f_ptr = &f_info[feat];
3533 /* Terrain feature if needed */
3534 if (boring || (feat > FEAT_INVIS))
3538 /* Hack -- special handling for building doors */
3539 if (have_flag(f_ptr->flags, FF_BLDG))
3541 name = building[f_ptr->power].name;
3543 else if (have_flag(f_ptr->flags, FF_ENTRANCE))
3546 name = format("%s(%d³¬ÁêÅö)", d_text + d_info[c_ptr->special].text, d_info[c_ptr->special].mindepth);
3548 name = format("%s(level %d)", d_text + d_info[c_ptr->special].text, d_info[c_ptr->special].mindepth);
3551 else if (have_flag(f_ptr->flags, FF_TOWN))
3553 name = town[c_ptr->special].name;
3555 else if (p_ptr->wild_mode && (feat == FEAT_FLOOR))
3565 name = f_name + f_ptr->name;
3571 (!have_flag(f_ptr->flags, FF_MOVE) ||
3572 (!have_flag(f_ptr->flags, FF_LOS) &&
3573 !have_flag(f_ptr->flags, FF_TREE)) ||
3574 have_flag(f_ptr->flags, FF_TOWN)))
3583 /* Hack -- special introduction for store & building doors -KMW- */
3584 if (have_flag(f_ptr->flags, FF_STORE) ||
3585 have_flag(f_ptr->flags, FF_BLDG) ||
3586 have_flag(f_ptr->flags, FF_ENTRANCE))
3595 else if (have_flag(f_ptr->flags, FF_FLOOR) || have_flag(f_ptr->flags, FF_TOWN))
3601 /* Pick proper indefinite article */
3602 s3 = (is_a_vowel(name[0])) ? "an " : "a ";
3606 /* Display a message */
3609 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);
3611 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);
3615 sprintf(out_val, "%s%s%s%s[%s]", s1, name, s2, s3, info);
3617 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, name, info);
3621 move_cursor_relative(y, x);
3624 /* Always stop at "normal" keys */
3625 if ((query != '\r') && (query != '\n') && (query != ' ')) return query;
3628 /* Stop on everything but "return" */
3629 if ((query != '\r') && (query != '\n')) return query;
3631 /* Repeat forever */
3637 * Handle "target" and "look".
3639 * Note that this code can be called from "get_aim_dir()".
3641 * All locations must be on the current panel. Consider the use of
3642 * "panel_bounds()" to allow "off-panel" targets, perhaps by using
3643 * some form of "scrolling" the map around the cursor. XXX XXX XXX
3644 * That is, consider the possibility of "auto-scrolling" the screen
3645 * while the cursor moves around. This may require changes in the
3646 * "update_mon()" code to allow "visibility" even if off panel, and
3647 * may require dynamic recalculation of the "temp" grid set.
3649 * Hack -- targeting/observing an "outer border grid" may induce
3650 * problems, so this is not currently allowed.
3652 * The player can use the direction keys to move among "interesting"
3653 * grids in a heuristic manner, or the "space", "+", and "-" keys to
3654 * move through the "interesting" grids in a sequential manner, or
3655 * can enter "location" mode, and use the direction keys to move one
3656 * grid at a time in any direction. The "t" (set target) command will
3657 * only target a monster (as opposed to a location) if the monster is
3658 * target_able and the "interesting" mode is being used.
3660 * The current grid is described using the "look" method above, and
3661 * a new command may be entered at any time, but note that if the
3662 * "TARGET_LOOK" bit flag is set (or if we are in "location" mode,
3663 * where "space" has no obvious meaning) then "space" will scan
3664 * through the description of the current grid until done, instead
3665 * of immediately jumping to the next "interesting" grid. This
3666 * allows the "target" command to retain its old semantics.
3668 * The "*", "+", and "-" keys may always be used to jump immediately
3669 * to the next (or previous) interesting grid, in the proper mode.
3671 * The "return" key may always be used to scan through a complete
3672 * grid description (forever).
3674 * This command will cancel any old target, even if used from
3675 * inside the "look" command.
3677 bool target_set(int mode)
3697 get_screen_size(&wid, &hgt);
3703 /* Cancel tracking */
3704 /* health_track(0); */
3707 /* Prepare the "temp" array */
3708 target_set_prepare(mode);
3710 /* Start near the player */
3716 /* Interesting grids */
3722 if (!(mode & TARGET_LOOK)) prt_path(y, x);
3725 c_ptr = &cave[y][x];
3728 if (target_able(c_ptr->m_idx))
3731 strcpy(info, "q»ß t·è p¼« o¸½ +¼¡ -Á°");
3733 strcpy(info, "q,t,p,o,+,-,<dir>");
3738 /* Dis-allow target */
3742 strcpy(info, "q»ß p¼« o¸½ +¼¡ -Á°");
3744 strcpy(info, "q,p,o,+,-,<dir>");
3749 /* Describe and Prompt */
3750 while (!(query = target_set_aux(y, x, mode, info)));
3752 /* Cancel tracking */
3753 /* health_track(0); */
3755 /* Assume no "direction" */
3760 if (query == '\r') query = 't';
3778 if (target_able(c_ptr->m_idx))
3780 health_track(c_ptr->m_idx);
3781 target_who = c_ptr->m_idx;
3800 if (!expand_list) done = TRUE;
3810 if (!expand_list) done = TRUE;
3817 /* Recenter the map around the player */
3821 p_ptr->update |= (PU_MONSTERS);
3824 p_ptr->redraw |= (PR_MAP);
3827 p_ptr->window |= (PW_OVERHEAD);
3832 /* Recalculate interesting grids */
3833 target_set_prepare(mode);
3852 /* Extract the action (if any) */
3853 d = get_keymap_dir(query);
3860 /* Hack -- move around */
3863 /* Modified to scroll to monster */
3864 int y2 = panel_row_min;
3865 int x2 = panel_col_min;
3867 /* Find a new monster */
3868 i = target_pick(temp_y[m], temp_x[m], ddy[d], ddx[d]);
3870 /* Request to target past last interesting grid */
3871 while (flag && (i < 0))
3873 /* Note the change */
3874 if (change_panel(ddy[d], ddx[d]))
3879 /* Recalculate interesting grids */
3880 target_set_prepare(mode);
3882 /* Look at interesting grids */
3885 /* Find a new monster */
3886 i = target_pick(v, u, ddy[d], ddx[d]);
3892 /* Nothing interesting */
3898 /* Restore previous position */
3901 panel_bounds_center();
3904 p_ptr->update |= (PU_MONSTERS);
3907 p_ptr->redraw |= (PR_MAP);
3910 p_ptr->window |= (PW_OVERHEAD);
3915 /* Recalculate interesting grids */
3916 target_set_prepare(mode);
3918 /* Look at boring grids */
3925 /* Do not move horizontally if unnecessary */
3926 if (((x < panel_col_min + wid / 2) && (dx > 0)) ||
3927 ((x > panel_col_min + wid / 2) && (dx < 0)))
3932 /* Do not move vertically if unnecessary */
3933 if (((y < panel_row_min + hgt / 2) && (dy > 0)) ||
3934 ((y > panel_row_min + hgt / 2) && (dy < 0)))
3939 /* Apply the motion */
3940 if ((y >= panel_row_min+hgt) || (y < panel_row_min) ||
3941 (x >= panel_col_min+wid) || (x < panel_col_min))
3943 if (change_panel(dy, dx)) target_set_prepare(mode);
3946 /* Slide into legality */
3947 if (x >= cur_wid-1) x = cur_wid - 2;
3948 else if (x <= 0) x = 1;
3950 /* Slide into legality */
3951 if (y >= cur_hgt-1) y = cur_hgt- 2;
3952 else if (y <= 0) y = 1;
3961 /* Arbitrary grids */
3964 bool move_fast = FALSE;
3966 if (!(mode & TARGET_LOOK)) prt_path(y, x);
3969 c_ptr = &cave[y][x];
3971 /* Default prompt */
3973 strcpy(info, "q»ß t·è p¼« m¶á +¼¡ -Á°");
3975 strcpy(info, "q,t,p,m,+,-,<dir>");
3979 /* Describe and Prompt (enable "TARGET_LOOK") */
3980 while (!(query = target_set_aux(y, x, mode | TARGET_LOOK, info)));
3982 /* Cancel tracking */
3983 /* health_track(0); */
3985 /* Assume no direction */
3990 if (query == '\r') query = 't';
3993 /* Analyze the keypress */
4017 /* Recenter the map around the player */
4021 p_ptr->update |= (PU_MONSTERS);
4024 p_ptr->redraw |= (PR_MAP);
4027 p_ptr->window |= (PW_OVERHEAD);
4032 /* Recalculate interesting grids */
4033 target_set_prepare(mode);
4055 /* Pick a nearby monster */
4056 for (i = 0; i < temp_n; i++)
4058 t = distance(y, x, temp_y[i], temp_x[i]);
4068 /* Nothing interesting */
4069 if (bd == 999) flag = FALSE;
4076 /* Extract the action (if any) */
4077 d = get_keymap_dir(query);
4079 /* XTRA HACK MOVEFAST */
4080 if (isupper(query)) move_fast = TRUE;
4087 /* Handle "direction" */
4093 /* XTRA HACK MOVEFAST */
4096 int mag = MIN(wid / 2, hgt / 2);
4106 /* Do not move horizontally if unnecessary */
4107 if (((x < panel_col_min + wid / 2) && (dx > 0)) ||
4108 ((x > panel_col_min + wid / 2) && (dx < 0)))
4113 /* Do not move vertically if unnecessary */
4114 if (((y < panel_row_min + hgt / 2) && (dy > 0)) ||
4115 ((y > panel_row_min + hgt / 2) && (dy < 0)))
4120 /* Apply the motion */
4121 if ((y >= panel_row_min + hgt) || (y < panel_row_min) ||
4122 (x >= panel_col_min + wid) || (x < panel_col_min))
4124 if (change_panel(dy, dx)) target_set_prepare(mode);
4127 /* Slide into legality */
4128 if (x >= cur_wid-1) x = cur_wid - 2;
4129 else if (x <= 0) x = 1;
4131 /* Slide into legality */
4132 if (y >= cur_hgt-1) y = cur_hgt- 2;
4133 else if (y <= 0) y = 1;
4141 /* Clear the top line */
4144 /* Recenter the map around the player */
4148 p_ptr->update |= (PU_MONSTERS);
4151 p_ptr->redraw |= (PR_MAP);
4154 p_ptr->window |= (PW_OVERHEAD);
4159 /* Failure to set target */
4160 if (!target_who) return (FALSE);
4168 * Get an "aiming direction" from the user.
4170 * The "dir" is loaded with 1,2,3,4,6,7,8,9 for "actual direction", and
4171 * "0" for "current target", and "-1" for "entry aborted".
4173 * Note that "Force Target", if set, will pre-empt user interaction,
4174 * if there is a usable target already set.
4176 * Note that confusion over-rides any (explicit?) user choice.
4178 bool get_aim_dir(int *dp)
4189 /* Global direction */
4192 /* Hack -- auto-target if requested */
4193 if (use_old_target && target_okay()) dir = 5;
4195 #ifdef ALLOW_REPEAT /* TNB */
4197 if (repeat_pull(dp))
4202 if (!(*dp == 5 && !target_okay()))
4204 /* return (TRUE); */
4209 #endif /* ALLOW_REPEAT -- TNB */
4211 /* Ask until satisfied */
4214 /* Choose a prompt */
4218 p = "Êý¸þ ('*'¤Ç¥¿¡¼¥²¥Ã¥ÈÁªÂò, ESC¤ÇÃæÃÇ)? ";
4220 p = "Direction ('*' to choose a target, Escape to cancel)? ";
4227 p = "Êý¸þ ('5'¤Ç¥¿¡¼¥²¥Ã¥È¤Ø, '*'¤Ç¥¿¡¼¥²¥Ã¥ÈºÆÁªÂò, ESC¤ÇÃæÃÇ)? ";
4229 p = "Direction ('5' for target, '*' to re-target, Escape to cancel)? ";
4234 /* Get a command (or Cancel) */
4235 if (!get_com(p, &command, TRUE)) break;
4239 if (command == '\r') command = 't';
4242 /* Convert various keys to "standard" keys */
4245 /* Use current target */
4256 /* Set new target */
4261 if (target_set(TARGET_KILL)) dir = 5;
4267 /* Extract the action (if any) */
4268 dir = get_keymap_dir(command);
4274 /* Verify requested targets */
4275 if ((dir == 5) && !target_okay()) dir = 0;
4284 project_length = 0; /* reset to default */
4288 /* Save the direction */
4291 /* Check for confusion */
4292 if (p_ptr->confused)
4295 /* Random direction */
4296 dir = ddd[randint0(8)];
4299 /* Notice confusion */
4300 if (command_dir != dir)
4304 msg_print("¤¢¤Ê¤¿¤Ïº®Í𤷤Ƥ¤¤ë¡£");
4306 msg_print("You are confused.");
4311 /* Save direction */
4314 #ifdef ALLOW_REPEAT /* TNB */
4316 /* repeat_push(dir); */
4317 repeat_push(command_dir);
4319 #endif /* ALLOW_REPEAT -- TNB */
4321 /* A "valid" direction was entered */
4328 * Request a "movement" direction (1,2,3,4,6,7,8,9) from the user,
4329 * and place it into "command_dir", unless we already have one.
4331 * This function should be used for all "repeatable" commands, such as
4332 * run, walk, open, close, bash, disarm, spike, tunnel, etc, as well
4333 * as all commands which must reference a grid adjacent to the player,
4334 * and which may not reference the grid under the player. Note that,
4335 * for example, it is no longer possible to "disarm" or "open" chests
4336 * in the same grid as the player.
4338 * Direction "5" is illegal and will (cleanly) abort the command.
4340 * This function tracks and uses the "global direction", and uses
4341 * that as the "desired direction", to which "confusion" is applied.
4343 bool get_rep_dir(int *dp, bool under)
4350 /* Global direction */
4353 #ifdef ALLOW_REPEAT /* TNB */
4355 if (repeat_pull(dp))
4358 /* return (TRUE); */
4361 #endif /* ALLOW_REPEAT -- TNB */
4363 /* Get a direction */
4368 /* Get a command (or Cancel) */
4370 if (!get_com("Êý¸þ (ESC¤ÇÃæÃÇ)? ", &ch, TRUE)) break;
4372 if (!get_com("Direction (Escape to cancel)? ", &ch, TRUE)) break;
4376 /* Look up the direction */
4377 dir = get_keymap_dir(ch);
4383 /* Prevent weirdness */
4384 if ((dir == 5) && (!under)) dir = 0;
4387 if (!dir) return (FALSE);
4389 /* Save desired direction */
4392 /* Apply "confusion" */
4393 if (p_ptr->confused)
4395 /* Standard confusion */
4396 if (randint0(100) < 75)
4398 /* Random direction */
4399 dir = ddd[randint0(8)];
4402 else if (p_ptr->riding)
4404 monster_type *m_ptr = &m_list[p_ptr->riding];
4405 monster_race *r_ptr = &r_info[m_ptr->r_idx];
4407 if (m_ptr->confused)
4409 /* Standard confusion */
4410 if (randint0(100) < 75)
4412 /* Random direction */
4413 dir = ddd[randint0(8)];
4416 else if ((r_ptr->flags1 & RF1_RAND_50) && (r_ptr->flags1 & RF1_RAND_25) && (randint0(100) < 50))
4418 /* Random direction */
4419 dir = ddd[randint0(8)];
4421 else if ((r_ptr->flags1 & RF1_RAND_50) && (randint0(100) < 25))
4423 /* Random direction */
4424 dir = ddd[randint0(8)];
4428 /* Notice confusion */
4429 if (command_dir != dir)
4431 if (p_ptr->confused)
4435 msg_print("¤¢¤Ê¤¿¤Ïº®Í𤷤Ƥ¤¤ë¡£");
4437 msg_print("You are confused.");
4443 monster_type *m_ptr = &m_list[p_ptr->riding];
4445 monster_desc(m_name, m_ptr, 0);
4446 if (m_ptr->confused)
4449 msg_format("%s¤Ïº®Í𤷤Ƥ¤¤ë¡£", m_name);
4451 msg_format("%^s is confusing.", m_name);
4458 msg_format("%s¤Ï»×¤¤Ä̤ê¤ËÆ°¤¤¤Æ¤¯¤ì¤Ê¤¤¡£", m_name);
4460 msg_format("You cannot control %s.", m_name);
4466 /* Save direction */
4469 #ifdef ALLOW_REPEAT /* TNB */
4471 /* repeat_push(dir); */
4472 repeat_push(command_dir);
4474 #endif /* ALLOW_REPEAT -- TNB */
4481 bool get_rep_dir2(int *dp)
4488 /* Global direction */
4491 #ifdef ALLOW_REPEAT /* TNB */
4493 if (repeat_pull(dp))
4496 /* return (TRUE); */
4499 #endif /* ALLOW_REPEAT -- TNB */
4501 /* Get a direction */
4506 /* Get a command (or Cancel) */
4508 if (!get_com("Êý¸þ (ESC¤ÇÃæÃÇ)? ", &ch, TRUE)) break;
4510 if (!get_com("Direction (Escape to cancel)? ", &ch, TRUE)) break;
4514 /* Look up the direction */
4515 dir = get_keymap_dir(ch);
4521 /* Prevent weirdness */
4522 if (dir == 5) dir = 0;
4525 if (!dir) return (FALSE);
4527 /* Save desired direction */
4530 /* Apply "confusion" */
4531 if (p_ptr->confused)
4533 /* Standard confusion */
4534 if (randint0(100) < 75)
4536 /* Random direction */
4537 dir = ddd[randint0(8)];
4541 /* Notice confusion */
4542 if (command_dir != dir)
4546 msg_print("¤¢¤Ê¤¿¤Ïº®Í𤷤Ƥ¤¤ë¡£");
4548 msg_print("You are confused.");
4553 /* Save direction */
4556 #ifdef ALLOW_REPEAT /* TNB */
4558 /* repeat_push(dir); */
4559 repeat_push(command_dir);
4561 #endif /* ALLOW_REPEAT -- TNB */
4568 void gain_level_reward(int chosen_reward)
4572 char wrath_reason[32] = "";
4573 int nasty_chance = 6;
4574 int dummy = 0, dummy2 = 0;
4577 char o_name[MAX_NLEN];
4583 if (multi_rew) return;
4584 else multi_rew = TRUE;
4588 if (p_ptr->lev == 13) nasty_chance = 2;
4589 else if (!(p_ptr->lev % 13)) nasty_chance = 3;
4590 else if (!(p_ptr->lev % 14)) nasty_chance = 12;
4592 if (one_in_(nasty_chance))
4593 type = randint1(20); /* Allow the 'nasty' effects */
4595 type = randint1(15) + 5; /* Or disallow them */
4597 if (type < 1) type = 1;
4598 if (type > 20) type = 20;
4603 sprintf(wrath_reason, "%s¤ÎÅܤê",
4604 chaos_patrons[p_ptr->chaos_patron]);
4606 sprintf(wrath_reason, "the Wrath of %s",
4607 chaos_patrons[p_ptr->chaos_patron]);
4611 effect = chaos_rewards[p_ptr->chaos_patron][type];
4613 if (one_in_(6) && !chosen_reward)
4616 msg_format("%^s¤ÏË«Èþ¤È¤·¤Æ¤¢¤Ê¤¿¤òÆÍÁ³ÊÑ°Û¤µ¤»¤¿¡£",
4617 chaos_patrons[p_ptr->chaos_patron]);
4619 msg_format("%^s rewards you with a mutation!",
4620 chaos_patrons[p_ptr->chaos_patron]);
4623 (void)gain_random_mutation(0);
4625 reward = "ÊÑ°Û¤·¤¿¡£";
4627 reward = "mutation";
4632 switch (chosen_reward ? chosen_reward : effect)
4636 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
4637 chaos_patrons[p_ptr->chaos_patron]);
4639 msg_format("The voice of %s booms out:",
4640 chaos_patrons[p_ptr->chaos_patron]);
4644 msg_print("¡ÖÆò¡¢¿·¤¿¤Ê¤ë»Ñ¤òɬÍפȤ»¤ê¡ª¡×");
4646 msg_print("'Thou needst a new form, mortal!'");
4651 reward = "ÊÑ°Û¤·¤¿¡£";
4653 reward = "polymorphing";
4658 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
4659 chaos_patrons[p_ptr->chaos_patron]);
4661 msg_format("The voice of %s booms out:",
4662 chaos_patrons[p_ptr->chaos_patron]);
4666 msg_print("¡ÖÆò¤ÏÎɤ¯¹Ô¤¤¤¿¤ê¡ªÂ³¤±¤è¡ª¡×");
4668 msg_print("'Well done, mortal! Lead on!'");
4671 if (p_ptr->prace == RACE_ANDROID)
4674 msg_print("¤·¤«¤·²¿¤âµ¯¤³¤é¤Ê¤«¤Ã¤¿¡£");
4676 msg_print("But, nothing happen.");
4679 else if (p_ptr->exp < PY_MAX_EXP)
4681 s32b ee = (p_ptr->exp / 2) + 10;
4682 if (ee > 100000L) ee = 100000L;
4684 msg_print("¹¹¤Ë·Ð¸³¤òÀѤó¤À¤è¤¦¤Êµ¤¤¬¤¹¤ë¡£");
4686 msg_print("You feel more experienced.");
4691 reward = "·Ð¸³ÃͤòÆÀ¤¿";
4693 reward = "experience";
4699 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
4700 chaos_patrons[p_ptr->chaos_patron]);
4702 msg_format("The voice of %s booms out:",
4703 chaos_patrons[p_ptr->chaos_patron]);
4707 msg_print("¡Ö²¼Ëͤ衢Æò¤½¤ì¤ËÃͤ»¤º¡£¡×");
4709 msg_print("'Thou didst not deserve that, slave.'");
4712 if (p_ptr->prace == RACE_ANDROID)
4715 msg_print("¤·¤«¤·²¿¤âµ¯¤³¤é¤Ê¤«¤Ã¤¿¡£");
4717 msg_print("But, nothing happen.");
4722 lose_exp(p_ptr->exp / 6);
4724 reward = "·Ð¸³Ãͤò¼º¤Ã¤¿¡£";
4726 reward = "losing experience";
4732 msg_format("%s¤ÎÀ¼¤¬¤µ¤µ¤ä¤¤¤¿:",
4733 chaos_patrons[p_ptr->chaos_patron]);
4735 msg_format("The voice of %s whispers:",
4736 chaos_patrons[p_ptr->chaos_patron]);
4740 msg_print("¡Ö²æ¤¬Í¿¤¨¤·Êª¤ò¸ÌÀ¤Ë»È¤¦¤Ù¤·¡£¡×");
4742 msg_print("'Use my gift wisely.'");
4745 acquirement(py, px, 1, FALSE, FALSE);
4747 reward = "¾å¼Á¤Ê¥¢¥¤¥Æ¥à¤ò¼ê¤ËÆþ¤ì¤¿¡£";
4749 reward = "a good item";
4754 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
4755 chaos_patrons[p_ptr->chaos_patron]);
4757 msg_format("The voice of %s booms out:",
4758 chaos_patrons[p_ptr->chaos_patron]);
4762 msg_print("¡Ö²æ¤¬Í¿¤¨¤·Êª¤ò¸ÌÀ¤Ë»È¤¦¤Ù¤·¡£¡×");
4764 msg_print("'Use my gift wisely.'");
4767 acquirement(py, px, 1, TRUE, FALSE);
4769 reward = "¹âµéÉʤΥ¢¥¤¥Æ¥à¤ò¼ê¤ËÆþ¤ì¤¿¡£";
4771 reward = "an excellent item";
4776 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
4777 chaos_patrons[p_ptr->chaos_patron]);
4779 msg_format("The voice of %s booms out:",
4780 chaos_patrons[p_ptr->chaos_patron]);
4784 msg_print("¡ÖÆò¤Î¹Ô¤¤¤Ïµ®¤·õ¤ËÃͤ»¤ê¡£¡×");
4786 msg_print("'Thy deed hath earned thee a worthy blade.'");
4789 /* Get local object */
4792 switch (randint1(p_ptr->lev))
4798 dummy2 = SV_MAIN_GAUCHE;
4807 dummy2 = SV_SMALL_SWORD;
4810 dummy2 = SV_BASILLARD;
4812 case 11: case 12: case 13:
4813 dummy2 = SV_SHORT_SWORD;
4819 dummy2 = SV_CUTLASS;
4822 dummy2 = SV_WAKIZASHI;
4825 dummy2 = SV_KHOPESH;
4831 dummy2 = SV_BROAD_SWORD;
4834 dummy2 = SV_LONG_SWORD;
4837 dummy2 = SV_SCIMITAR;
4840 dummy2 = SV_NINJATO;
4846 dummy2 = SV_BASTARD_SWORD;
4849 dummy2 = SV_GREAT_SCIMITAR;
4852 dummy2 = SV_CLAYMORE;
4855 dummy2 = SV_ESPADON;
4858 dummy2 = SV_TWO_HANDED_SWORD;
4861 dummy2 = SV_FLAMBERGE;
4864 dummy2 = SV_NO_DACHI;
4867 dummy2 = SV_EXECUTIONERS_SWORD;
4870 dummy2 = SV_ZWEIHANDER;
4873 dummy2 = SV_HAYABUSA;
4876 dummy2 = SV_BLADE_OF_CHAOS;
4879 object_prep(q_ptr, lookup_kind(dummy, dummy2));
4880 q_ptr->to_h = 3 + randint1(dun_level) % 10;
4881 q_ptr->to_d = 3 + randint1(dun_level) % 10;
4882 one_resistance(q_ptr);
4883 q_ptr->name2 = EGO_CHAOTIC;
4885 /* Drop it in the dungeon */
4886 (void)drop_near(q_ptr, -1, py, px);
4888 reward = "(º®ÆÙ)¤ÎÉð´ï¤ò¼ê¤ËÆþ¤ì¤¿¡£";
4890 reward = "chaos weapon";
4895 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
4896 chaos_patrons[p_ptr->chaos_patron]);
4898 msg_format("The voice of %s booms out:",
4899 chaos_patrons[p_ptr->chaos_patron]);
4903 msg_print("¡ÖÆò¤Î¹Ô¤¤¤Ïµ®¤Ê󤤤ËÃͤ»¤ê¡£¡×");
4905 msg_print("'Thy deed hath earned thee a worthy reward.'");
4908 acquirement(py, px, randint1(2) + 1, FALSE, FALSE);
4910 reward = "¾å¼Á¤Ê¥¢¥¤¥Æ¥à¤ò¼ê¤ËÆþ¤ì¤¿¡£";
4912 reward = "good items";
4917 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
4918 chaos_patrons[p_ptr->chaos_patron]);
4920 msg_format("The voice of %s booms out:",
4921 chaos_patrons[p_ptr->chaos_patron]);
4925 msg_print("¡Ö²¼Ëͤ衢Æò¤Î¸¥¿È¤Ø¤Î²æ¤¬Àˤ·¤ß̵¤Ê󤤤ò¸«¤ë¤¬¤è¤¤¡£¡×");
4927 msg_print("'Behold, mortal, how generously I reward thy loyalty.'");
4930 acquirement(py, px, randint1(2) + 1, TRUE, FALSE);
4932 reward = "¹âµéÉʤΥ¢¥¤¥Æ¥à¤ò¼ê¤ËÆþ¤ì¤¿¡£";
4934 reward = "excellent items";
4939 msg_format("%s¤ÎÀ¼¤¬¹ì¤ÅϤä¿:",
4940 chaos_patrons[p_ptr->chaos_patron]);
4942 msg_format("The voice of %s thunders:",
4943 chaos_patrons[p_ptr->chaos_patron]);
4947 msg_print("¡Ö²¼Ëͤ衢ÆòÐþËý¤Ê¤ê¡£¡×");
4949 msg_print("'Thou art growing arrogant, mortal.'");
4952 (void)activate_ty_curse(FALSE, &count);
4954 reward = "²Ò¡¹¤·¤¤¼ö¤¤¤ò¤«¤±¤é¤ì¤¿¡£";
4961 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
4962 chaos_patrons[p_ptr->chaos_patron]);
4964 msg_format("The voice of %s booms out:",
4965 chaos_patrons[p_ptr->chaos_patron]);
4969 msg_print("¡Ö²æ¤¬²¼Ëͤ¿¤Á¤è¡¢¤«¤ÎÐþËý¤Ê¤ë¼Ô¤òÅݤ¹¤Ù¤·¡ª¡×");
4971 msg_print("'My pets, destroy the arrogant mortal!'");
4974 for (dummy = 0; dummy < randint1(5) + 1; dummy++)
4976 (void)summon_specific(0, py, px, dun_level, 0, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET));
4979 reward = "¥â¥ó¥¹¥¿¡¼¤ò¾¤´¤µ¤ì¤¿¡£";
4981 reward = "summoning hostile monsters";
4986 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
4987 chaos_patrons[p_ptr->chaos_patron]);
4989 msg_format("The voice of %s booms out:",
4990 chaos_patrons[p_ptr->chaos_patron]);
4994 msg_print("¡ÖÆò¡¢¤è¤ê¶¯¤Å¨¤òɬÍפȤ»¤ê¡ª¡×");
4996 msg_print("'Thou needst worthier opponents!'");
4999 activate_hi_summon(py, px, FALSE);
5001 reward = "¥â¥ó¥¹¥¿¡¼¤ò¾¤´¤µ¤ì¤¿¡£";
5003 reward = "summoning many hostile monsters";
5008 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5009 chaos_patrons[p_ptr->chaos_patron]);
5011 msg_format("The voice of %s booms out:",
5012 chaos_patrons[p_ptr->chaos_patron]);
5016 msg_print("¡Ö»à¤ÈÇ˲õ¤³¤½²æ¤¬´î¤Ó¤Ê¤ê¡ª¡×");
5018 msg_print("'Death and destruction! This pleaseth me!'");
5023 reward = "¥«¥ª¥¹¤ÎÎϤ¬±²´¬¤¤¤¿¡£";
5025 reward = "calling chaos";
5030 msg_format("%s¤ÎÀ¼¤¬ÌĤê¶Á¤¤¤¿:",
5031 chaos_patrons[p_ptr->chaos_patron]);
5033 msg_format("The voice of %s rings out:",
5034 chaos_patrons[p_ptr->chaos_patron]);
5038 msg_print("¡Öα¤Þ¤ë¤Î¤À¡¢²¼Ëͤ衣;¤¬Æò¤ÎÆùÂΤòÃ䨤󡣡×");
5040 msg_print("'Stay, mortal, and let me mold thee.'");
5043 if (one_in_(3) && !(chaos_stats[p_ptr->chaos_patron] < 0))
5044 do_inc_stat(chaos_stats[p_ptr->chaos_patron]);
5046 do_inc_stat(randint0(6));
5048 reward = "ǽÎÏÃͤ¬¾å¤¬¤Ã¤¿¡£";
5050 reward = "increasing a stat";
5055 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5056 chaos_patrons[p_ptr->chaos_patron]);
5058 msg_format("The voice of %s booms out:",
5059 chaos_patrons[p_ptr->chaos_patron]);
5063 msg_print("¡Ö²¼Ëͤ衢;¤ÏÆò¤ËË°¤ß¤¿¤ê¡£¡×");
5065 msg_print("'I grow tired of thee, mortal.'");
5068 if (one_in_(3) && !(chaos_stats[p_ptr->chaos_patron] < 0))
5069 do_dec_stat(chaos_stats[p_ptr->chaos_patron]);
5071 (void)do_dec_stat(randint0(6));
5073 reward = "ǽÎÏÃͤ¬²¼¤¬¤Ã¤¿¡£";
5075 reward = "decreasing a stat";
5080 msg_format("%s¤ÎÀ¼¤¬¹ì¤ÅϤä¿:",
5081 chaos_patrons[p_ptr->chaos_patron]);
5083 msg_format("The voice of %s thunders:",
5084 chaos_patrons[p_ptr->chaos_patron]);
5088 msg_print("¡ÖÆò¡¢¸¬µõ¤¿¤ë¤³¤È¤ò³Ø¤Ö¤Ù¤·¡ª¡×");
5089 msg_print("¤¢¤Ê¤¿¤Ï°ÊÁ°¤è¤ê¼å¤¯¤Ê¤Ã¤¿¡ª");
5091 msg_print("'Thou needst a lesson in humility, mortal!'");
5092 msg_print("You feel less powerful!");
5095 for (dummy = 0; dummy < 6; dummy++)
5097 (void)dec_stat(dummy, 10 + randint1(15), TRUE);
5100 reward = "Á´Ç½ÎÏÃͤ¬²¼¤¬¤Ã¤¿¡£";
5102 reward = "decreasing all stats";
5107 msg_format("%s¤ÎÎϤ¬¿¨¤ì¤ë¤Î¤ò´¶¤¸¤¿¡£",
5109 msg_format("You feel the power of %s touch you.",
5112 chaos_patrons[p_ptr->chaos_patron]);
5115 reward = "½ý¤¬ÊѲ½¤·¤¿¡£";
5117 reward = "polymorphing wounds";
5122 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5123 chaos_patrons[p_ptr->chaos_patron]);
5125 msg_format("The voice of %s booms out:",
5126 chaos_patrons[p_ptr->chaos_patron]);
5130 msg_print("¡Ö²æ¤¬¤µ¤µ¤ä¤«¤Ê¤ë»òʪ¤ò¼õ¤±¤È¤ë¤¬¤è¤¤¡ª¡×");
5132 msg_print("'Receive this modest gift from me!'");
5135 for (dummy = 0; dummy < 6; dummy++)
5137 (void)do_inc_stat(dummy);
5140 reward = "Á´Ç½ÎÏÃͤ¬¾å¤¬¤Ã¤¿¡£";
5142 reward = "increasing all stats";
5147 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5148 chaos_patrons[p_ptr->chaos_patron]);
5150 msg_format("The voice of %s booms out:",
5151 chaos_patrons[p_ptr->chaos_patron]);
5155 msg_print("¡Ö¶ì¤·¤à¤¬¤è¤¤¡¢ÌµÇ½¤Ê¶ò¤«¼Ô¤è¡ª¡×");
5157 msg_print("'Suffer, pathetic fool!'");
5160 fire_ball(GF_DISINTEGRATE, 0, p_ptr->lev * 4, 4);
5161 take_hit(DAMAGE_NOESCAPE, p_ptr->lev * 4, wrath_reason, -1);
5163 reward = "ʬ²ò¤Îµå¤¬È¯À¸¤·¤¿¡£";
5165 reward = "generating disintegration ball";
5170 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5171 chaos_patrons[p_ptr->chaos_patron]);
5173 msg_format("The voice of %s booms out:",
5174 chaos_patrons[p_ptr->chaos_patron]);
5178 msg_print("¡Öᴤ뤬¤è¤¤¡¢²æ¤¬²¼Ëͤ衪¡×");
5180 msg_print("'Rise, my servant!'");
5184 (void)set_poisoned(0);
5186 (void)set_confused(0);
5191 for (dummy = 0; dummy < 6; dummy++)
5193 (void)do_res_stat(dummy);
5196 reward = "ÂÎÎϤ¬²óÉü¤·¤¿¡£";
5202 if (!buki_motteruka(INVEN_RARM)) break;
5204 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5205 chaos_patrons[p_ptr->chaos_patron]);
5207 msg_format("The voice of %s booms out:",
5208 chaos_patrons[p_ptr->chaos_patron]);
5212 msg_print("¡ÖÆò¡¢Éð´ï¤ËÍê¤ë¤³¤È¤Ê¤«¤ì¡£¡×");
5214 msg_print("'Thou reliest too much on thy weapon.'");
5217 object_desc(o_name, &inventory[INVEN_RARM], OD_NAME_ONLY);
5218 (void)curse_weapon(FALSE, INVEN_RARM);
5220 reward = format("%s¤¬Ç˲õ¤µ¤ì¤¿¡£", o_name);
5222 reward = format("destroying %s", o_name);
5226 if (!inventory[INVEN_BODY].k_idx) break;
5228 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5229 chaos_patrons[p_ptr->chaos_patron]);
5231 msg_format("The voice of %s booms out:",
5232 chaos_patrons[p_ptr->chaos_patron]);
5236 msg_print("¡ÖÆò¡¢Ëɶñ¤ËÍê¤ë¤³¤È¤Ê¤«¤ì¡£¡×");
5238 msg_print("'Thou reliest too much on thine equipment.'");
5241 object_desc(o_name, &inventory[INVEN_BODY], OD_NAME_ONLY);
5242 (void)curse_armor();
5244 reward = format("%s¤¬Ç˲õ¤µ¤ì¤¿¡£", o_name);
5246 reward = format("destroying %s", o_name);
5251 msg_format("%s¤ÎÀ¼¤¬¤µ¤µ¤ä¤¤¤¿:",
5252 chaos_patrons[p_ptr->chaos_patron]);
5254 msg_format("The voice of %s whispers:",
5255 chaos_patrons[p_ptr->chaos_patron]);
5259 msg_print("¡Ö²æ¤òÅܤꤷ¤á¤¿ºá¤ò½þ¤¦¤Ù¤·¡£¡×");
5261 msg_print("'Now thou shalt pay for annoying me.'");
5264 switch (randint1(4))
5267 (void)activate_ty_curse(FALSE, &count);
5269 reward = "²Ò¡¹¤·¤¤¼ö¤¤¤ò¤«¤±¤é¤ì¤¿¡£";
5275 activate_hi_summon(py, px, FALSE);
5277 reward = "¥â¥ó¥¹¥¿¡¼¤ò¾¤´¤µ¤ì¤¿¡£";
5279 reward = "summoning hostile monsters";
5285 if (!buki_motteruka(INVEN_RARM)) break;
5286 object_desc(o_name, &inventory[INVEN_RARM], OD_NAME_ONLY);
5287 (void)curse_weapon(FALSE, INVEN_RARM);
5289 reward = format("%s¤¬Ç˲õ¤µ¤ì¤¿¡£", o_name);
5291 reward = format("destroying %s", o_name);
5296 if (!inventory[INVEN_BODY].k_idx) break;
5297 object_desc(o_name, &inventory[INVEN_BODY], OD_NAME_ONLY);
5298 (void)curse_armor();
5300 reward = format("%s¤¬Ç˲õ¤µ¤ì¤¿¡£", o_name);
5302 reward = format("destroying %s", o_name);
5307 for (dummy = 0; dummy < 6; dummy++)
5309 (void)dec_stat(dummy, 10 + randint1(15), TRUE);
5312 reward = "Á´Ç½ÎÏÃͤ¬²¼¤¬¤Ã¤¿¡£";
5314 reward = "decreasing all stats";
5321 msg_format("%s¤ÎÀ¼¤¬¹ì¤ÅϤä¿:",
5323 msg_format("The voice of %s thunders:",
5326 chaos_patrons[p_ptr->chaos_patron]);
5328 msg_print("¡Ö»à¤Ì¤¬¤è¤¤¡¢²¼Ëͤ衪¡×");
5330 msg_print("'Die, mortal!'");
5333 take_hit(DAMAGE_LOSELIFE, p_ptr->lev * 4, wrath_reason, -1);
5334 for (dummy = 0; dummy < 6; dummy++)
5336 (void)dec_stat(dummy, 10 + randint1(15), FALSE);
5338 activate_hi_summon(py, px, FALSE);
5339 (void)activate_ty_curse(FALSE, &count);
5340 if (one_in_(2)) (void)curse_weapon(FALSE, INVEN_RARM);
5341 if (one_in_(2)) (void)curse_armor();
5345 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5346 chaos_patrons[p_ptr->chaos_patron]);
5348 msg_format("The voice of %s booms out:",
5349 chaos_patrons[p_ptr->chaos_patron]);
5353 msg_print("¡Ö»à¤ÈÇ˲õ¤³¤½²æ¤¬´î¤Ó¤Ê¤ê¡ª¡×");
5355 msg_print("'Death and destruction! This pleaseth me!'");
5358 (void)destroy_area(py, px, 25, FALSE);
5360 reward = "¥À¥ó¥¸¥ç¥ó¤¬*Ç˲õ*¤µ¤ì¤¿¡£";
5362 reward = "*destruct*ing dungeon";
5367 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5368 chaos_patrons[p_ptr->chaos_patron]);
5370 msg_format("The voice of %s booms out:",
5371 chaos_patrons[p_ptr->chaos_patron]);
5375 msg_print("¡Ö²æ¡¢Æò¤ÎŨ¤òËõ»¦¤»¤ó¡ª¡×");
5377 msg_print("'Let me relieve thee of thine oppressors!'");
5380 (void)symbol_genocide(0, FALSE);
5382 reward = "¥â¥ó¥¹¥¿¡¼¤¬Ëõ»¦¤µ¤ì¤¿¡£";
5384 reward = "genociding monsters";
5389 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5390 chaos_patrons[p_ptr->chaos_patron]);
5392 msg_format("The voice of %s booms out:",
5393 chaos_patrons[p_ptr->chaos_patron]);
5397 msg_print("¡Ö²æ¡¢Æò¤ÎŨ¤òËõ»¦¤»¤ó¡ª¡×");
5399 msg_print("'Let me relieve thee of thine oppressors!'");
5402 (void)mass_genocide(0, FALSE);
5404 reward = "¥â¥ó¥¹¥¿¡¼¤¬Ëõ»¦¤µ¤ì¤¿¡£";
5406 reward = "genociding nearby monsters";
5411 msg_format("%s¤ÎÎϤ¬Å¨¤ò¹¶·â¤¹¤ë¤Î¤ò´¶¤¸¤¿¡ª",
5412 chaos_patrons[p_ptr->chaos_patron]);
5414 msg_format("You can feel the power of %s assault your enemies!",
5415 chaos_patrons[p_ptr->chaos_patron]);
5418 (void)dispel_monsters(p_ptr->lev * 4);
5422 msg_format("%s¤Ï¤¢¤Ê¤¿¤ò̵»ë¤·¤¿¡£",
5423 chaos_patrons[p_ptr->chaos_patron]);
5425 msg_format("%s ignores you.",
5426 chaos_patrons[p_ptr->chaos_patron]);
5432 msg_format("%s¤ÏË«Èþ¤È¤·¤Æ°Ëâ¤Î»È¤¤¤ò¤è¤³¤·¤¿¡ª",chaos_patrons[p_ptr->chaos_patron]);
5434 msg_format("%s rewards you with a demonic servant!",chaos_patrons[p_ptr->chaos_patron]);
5437 if (!summon_specific(-1, py, px, dun_level, SUMMON_DEMON, PM_FORCE_PET))
5439 msg_print("²¿¤â¸½¤ì¤Ê¤«¤Ã¤¿...");
5441 msg_print("Nobody ever turns up...");
5445 reward = "°Ë⤬¥Ú¥Ã¥È¤Ë¤Ê¤Ã¤¿¡£";
5447 reward = "a demonic servant";
5453 msg_format("%s¤ÏË«Èþ¤È¤·¤Æ»È¤¤¤ò¤è¤³¤·¤¿¡ª",chaos_patrons[p_ptr->chaos_patron]);
5455 msg_format("%s rewards you with a servant!",chaos_patrons[p_ptr->chaos_patron]);
5458 if (!summon_specific(-1, py, px, dun_level, 0, PM_FORCE_PET))
5460 msg_print("²¿¤â¸½¤ì¤Ê¤«¤Ã¤¿...");
5462 msg_print("Nobody ever turns up...");
5466 reward = "¥â¥ó¥¹¥¿¡¼¤¬¥Ú¥Ã¥È¤Ë¤Ê¤Ã¤¿¡£";
5468 reward = "a servant";
5474 msg_format("%s¤ÏË«Èþ¤È¤·¤Æ¥¢¥ó¥Ç¥Ã¥É¤Î»È¤¤¤ò¤è¤³¤·¤¿¡£",chaos_patrons[p_ptr->chaos_patron]);
5476 msg_format("%s rewards you with an undead servant!",chaos_patrons[p_ptr->chaos_patron]);
5479 if (!summon_specific(-1, py, px, dun_level, SUMMON_UNDEAD, PM_FORCE_PET))
5481 msg_print("²¿¤â¸½¤ì¤Ê¤«¤Ã¤¿...");
5483 msg_print("Nobody ever turns up...");
5487 reward = "¥¢¥ó¥Ç¥Ã¥É¤¬¥Ú¥Ã¥È¤Ë¤Ê¤Ã¤¿¡£";
5489 reward = "an undead servant";
5495 msg_format("%s¤ÎÀ¼¤¬¤É¤â¤Ã¤¿:",
5497 msg_format("The voice of %s stammers:",
5500 chaos_patrons[p_ptr->chaos_patron]);
5502 msg_format("¡Ö¤¢¡¼¡¢¤¢¡¼¡¢Åú¤¨¤Ï %d/%d¡£¼ÁÌä¤Ï²¿¡©¡×", type, effect);
5504 msg_format("'Uh... uh... the answer's %d/%d, what's the question?'", type, effect);
5512 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, format("¥Ñ¥È¥í¥ó¤ÎÊó½·¤Ç%s", reward));
5514 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, format("The patron rewards you with %s.", reward));
5521 * old -- from PsiAngband.
5523 bool tgt_pt(int *x_ptr, int *y_ptr)
5527 bool success = FALSE;
5532 get_screen_size(&wid, &hgt);
5538 msg_print("¾ì½ê¤òÁª¤ó¤Ç¥¹¥Ú¡¼¥¹¥¡¼¤ò²¡¤·¤Æ²¼¤µ¤¤¡£");
5540 msg_print("Select a point and press space.");
5542 msg_flag = FALSE; /* prevents "-more-" message. */
5544 while ((ch != ESCAPE) && !success)
5546 bool move_fast = FALSE;
5548 move_cursor_relative(y, x);
5560 if (player_bold(y, x)) ch = 0;
5563 else success = TRUE;
5567 /* Look up the direction */
5568 d = get_keymap_dir(ch);
5570 /* XTRA HACK MOVEFAST */
5571 if (isupper(ch)) move_fast = TRUE;
5573 /* Handle "direction" */
5579 /* XTRA HACK MOVEFAST */
5582 int mag = MIN(wid / 2, hgt / 2);
5592 /* Do not move horizontally if unnecessary */
5593 if (((x < panel_col_min + wid / 2) && (dx > 0)) ||
5594 ((x > panel_col_min + wid / 2) && (dx < 0)))
5599 /* Do not move vertically if unnecessary */
5600 if (((y < panel_row_min + hgt / 2) && (dy > 0)) ||
5601 ((y > panel_row_min + hgt / 2) && (dy < 0)))
5606 /* Apply the motion */
5607 if ((y >= panel_row_min + hgt) || (y < panel_row_min) ||
5608 (x >= panel_col_min + wid) || (x < panel_col_min))
5610 /* if (change_panel(dy, dx)) target_set_prepare(mode); */
5611 change_panel(dy, dx);
5614 /* Slide into legality */
5615 if (x >= cur_wid-1) x = cur_wid - 2;
5616 else if (x <= 0) x = 1;
5618 /* Slide into legality */
5619 if (y >= cur_hgt-1) y = cur_hgt- 2;
5620 else if (y <= 0) y = 1;
5627 /* Clear the top line */
5630 /* Recenter the map around the player */
5634 p_ptr->update |= (PU_MONSTERS);
5637 p_ptr->redraw |= (PR_MAP);
5640 p_ptr->window |= (PW_OVERHEAD);
5651 bool get_hack_dir(int *dp)
5661 /* Global direction */
5664 /* (No auto-targeting) */
5666 /* Ask until satisfied */
5669 /* Choose a prompt */
5673 p = "Êý¸þ ('*'¤Ç¥¿¡¼¥²¥Ã¥ÈÁªÂò, ESC¤ÇÃæÃÇ)? ";
5675 p = "Direction ('*' to choose a target, Escape to cancel)? ";
5682 p = "Êý¸þ ('5'¤Ç¥¿¡¼¥²¥Ã¥È¤Ø, '*'¤Ç¥¿¡¼¥²¥Ã¥ÈºÆÁªÂò, ESC¤ÇÃæÃÇ)? ";
5684 p = "Direction ('5' for target, '*' to re-target, Escape to cancel)? ";
5689 /* Get a command (or Cancel) */
5690 if (!get_com(p, &command, TRUE)) break;
5694 if (command == '\r') command = 't';
5697 /* Convert various keys to "standard" keys */
5700 /* Use current target */
5711 /* Set new target */
5716 if (target_set(TARGET_KILL)) dir = 5;
5722 /* Look up the direction */
5723 dir = get_keymap_dir(command);
5729 /* Verify requested targets */
5730 if ((dir == 5) && !target_okay()) dir = 0;
5737 if (!dir) return (FALSE);
5739 /* Save the direction */
5742 /* Check for confusion */
5743 if (p_ptr->confused)
5746 /* Random direction */
5747 dir = ddd[randint0(8)];
5750 /* Notice confusion */
5751 if (command_dir != dir)
5755 msg_print("¤¢¤Ê¤¿¤Ïº®Í𤷤Ƥ¤¤ë¡£");
5757 msg_print("You are confused.");
5762 /* Save direction */
5765 /* A "valid" direction was entered */
5771 * ¥¨¥Í¥ë¥®¡¼¤ÎÁý²ÃÎÌ10d5¤ò®¤¯·×»»¤¹¤ë¤¿¤á¤Î´Ø¿ô
5774 #define Go_no_JuuJou 5*5*5*5*5*5*5*5*5*5
5776 s16b gain_energy(void)
5779 s32b energy_result = 10;
5782 tmp = randint0(Go_no_JuuJou);
5784 for (i = 0; i < 9; i ++){
5785 energy_result += tmp % 5;
5789 return (s16b)(energy_result + tmp);
5796 s16b bow_energy(int sval)
5800 /* Analyze the launcher */
5803 /* Sling and ammo */
5810 /* Short Bow and Arrow */
5817 /* Long Bow and Arrow */
5824 /* Bow of irresponsiblity and Arrow */
5831 /* Light Crossbow and Bolt */
5838 /* Heavy Crossbow and Bolt */
5853 int bow_tmul(int sval)
5857 /* Analyze the launcher */
5860 /* Sling and ammo */
5867 /* Short Bow and Arrow */
5874 /* Long Bow and Arrow */
5881 /* Bow of irresponsiblity and Arrow */
5888 /* Light Crossbow and Bolt */
5895 /* Heavy Crossbow and Bolt */
5907 * Return alignment title
5909 cptr your_alignment(void)
5912 if (p_ptr->align > 150) return "ÂçÁ±";
5913 else if (p_ptr->align > 50) return "ÃæÁ±";
5914 else if (p_ptr->align > 10) return "¾®Á±";
5915 else if (p_ptr->align > -11) return "ÃæΩ";
5916 else if (p_ptr->align > -51) return "¾®°";
5917 else if (p_ptr->align > -151) return "Ãæ°";
5920 if (p_ptr->align > 150) return "Lawful";
5921 else if (p_ptr->align > 50) return "Good";
5922 else if (p_ptr->align > 10) return "Neutral Good";
5923 else if (p_ptr->align > -11) return "Neutral";
5924 else if (p_ptr->align > -51) return "Neutral Evil";
5925 else if (p_ptr->align > -151) return "Evil";
5926 else return "Chaotic";
5932 * Return proficiency level of weapons and misc. skills (except riding)
5934 int weapon_exp_level(int weapon_exp)
5936 if (weapon_exp < WEAPON_EXP_BEGINNER) return EXP_LEVEL_UNSKILLED;
5937 else if (weapon_exp < WEAPON_EXP_SKILLED) return EXP_LEVEL_BEGINNER;
5938 else if (weapon_exp < WEAPON_EXP_EXPERT) return EXP_LEVEL_SKILLED;
5939 else if (weapon_exp < WEAPON_EXP_MASTER) return EXP_LEVEL_EXPERT;
5940 else return EXP_LEVEL_MASTER;
5945 * Return proficiency level of riding
5947 int riding_exp_level(int riding_exp)
5949 if (riding_exp < RIDING_EXP_BEGINNER) return EXP_LEVEL_UNSKILLED;
5950 else if (riding_exp < RIDING_EXP_SKILLED) return EXP_LEVEL_BEGINNER;
5951 else if (riding_exp < RIDING_EXP_EXPERT) return EXP_LEVEL_SKILLED;
5952 else if (riding_exp < RIDING_EXP_MASTER) return EXP_LEVEL_EXPERT;
5953 else return EXP_LEVEL_MASTER;
5958 * Return proficiency level of spells
5960 int spell_exp_level(int spell_exp)
5962 if (spell_exp < SPELL_EXP_BEGINNER) return EXP_LEVEL_UNSKILLED;
5963 else if (spell_exp < SPELL_EXP_SKILLED) return EXP_LEVEL_BEGINNER;
5964 else if (spell_exp < SPELL_EXP_EXPERT) return EXP_LEVEL_SKILLED;
5965 else if (spell_exp < SPELL_EXP_MASTER) return EXP_LEVEL_EXPERT;
5966 else return EXP_LEVEL_MASTER;