3 /* Purpose: effects of various "objects" */
6 * Copyright (c) 1989 James E. Wilson, Robert A. Koeneke
8 * This software may be copied and distributed for educational, research, and
9 * not for profit purposes provided that this copyright and statement are
10 * included in all such copies.
15 #define REWARD_CHANCE 10
19 * Advance experience levels and print experience
21 void check_experience(void)
24 bool level_reward = FALSE;
25 bool level_mutation = FALSE;
26 bool level_inc_stat = FALSE;
27 bool android = (p_ptr->prace == RACE_ANDROID ? TRUE : FALSE);
30 /* Note current level */
33 /* Hack -- lower limit */
34 if (p_ptr->exp < 0) p_ptr->exp = 0;
36 /* Hack -- lower limit */
37 if (p_ptr->max_exp < 0) p_ptr->max_exp = 0;
39 /* Hack -- upper limit */
40 if (p_ptr->exp > PY_MAX_EXP) p_ptr->exp = PY_MAX_EXP;
42 /* Hack -- upper limit */
43 if (p_ptr->max_exp > PY_MAX_EXP) p_ptr->max_exp = PY_MAX_EXP;
45 /* Hack -- maintain "max" experience */
46 if (p_ptr->exp > p_ptr->max_exp) p_ptr->max_exp = p_ptr->exp;
48 /* Redraw experience */
49 p_ptr->redraw |= (PR_EXP);
55 /* Lose levels while possible */
56 while ((p_ptr->lev > 1) &&
57 (p_ptr->exp < ((android ? player_exp_a : player_exp)[p_ptr->lev - 2] * p_ptr->expfact / 100L)))
63 /* Update some stuff */
64 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
66 /* Redraw some stuff */
67 p_ptr->redraw |= (PR_LEV | PR_TITLE);
70 p_ptr->window |= (PW_PLAYER);
77 /* Gain levels while possible */
78 while ((p_ptr->lev < PY_MAX_LEVEL) &&
79 (p_ptr->exp >= ((android ? player_exp_a : player_exp)[p_ptr->lev-1] * p_ptr->expfact / 100L)))
85 /* Save the highest level */
86 if (p_ptr->lev > p_ptr->max_plv)
88 p_ptr->max_plv = p_ptr->lev;
90 if ((p_ptr->pclass == CLASS_CHAOS_WARRIOR) ||
91 (p_ptr->muta2 & MUT2_CHAOS_GIFT))
95 if (p_ptr->prace == RACE_BEASTMAN)
97 if (one_in_(5)) level_mutation = TRUE;
99 level_inc_stat = TRUE;
101 do_cmd_write_nikki(NIKKI_LEVELUP, p_ptr->lev, NULL);
109 msg_format("¥ì¥Ù¥ë %d ¤Ë¤è¤¦¤³¤½¡£", p_ptr->lev);
111 msg_format("Welcome to level %d.", p_ptr->lev);
114 /* Update some stuff */
115 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
117 /* Redraw some stuff */
118 p_ptr->redraw |= (PR_LEV | PR_TITLE);
121 p_ptr->window |= (PW_PLAYER | PW_SPELL);
123 /* HP¤ÈMP¤Î¾å¾ºÎ̤òɽ¼¨ */
133 if(!(p_ptr->max_plv % 10))
143 cnv_stat(p_ptr->stat_max[0], tmp);
144 prt(format(" a) ÏÓÎÏ (¸½ºßÃÍ %s)", tmp), 2, 14);
145 cnv_stat(p_ptr->stat_max[1], tmp);
146 prt(format(" b) ÃÎǽ (¸½ºßÃÍ %s)", tmp), 3, 14);
147 cnv_stat(p_ptr->stat_max[2], tmp);
148 prt(format(" c) ¸¤µ (¸½ºßÃÍ %s)", tmp), 4, 14);
149 cnv_stat(p_ptr->stat_max[3], tmp);
150 prt(format(" d) ´ïÍÑ (¸½ºßÃÍ %s)", tmp), 5, 14);
151 cnv_stat(p_ptr->stat_max[4], tmp);
152 prt(format(" e) ÂÑµ× (¸½ºßÃÍ %s)", tmp), 6, 14);
153 cnv_stat(p_ptr->stat_max[5], tmp);
154 prt(format(" f) Ì¥ÎÏ (¸½ºßÃÍ %s)", tmp), 7, 14);
156 prt(" ¤É¤ÎǽÎÏÃͤò¾å¤²¤Þ¤¹¤«¡©", 1, 14);
158 cnv_stat(p_ptr->stat_max[0], tmp);
159 prt(format(" a) Str (cur %s)", tmp), 2, 14);
160 cnv_stat(p_ptr->stat_max[1], tmp);
161 prt(format(" b) Int (cur %s)", tmp), 3, 14);
162 cnv_stat(p_ptr->stat_max[2], tmp);
163 prt(format(" c) Wis (cur %s)", tmp), 4, 14);
164 cnv_stat(p_ptr->stat_max[3], tmp);
165 prt(format(" d) Dex (cur %s)", tmp), 5, 14);
166 cnv_stat(p_ptr->stat_max[4], tmp);
167 prt(format(" e) Con (cur %s)", tmp), 6, 14);
168 cnv_stat(p_ptr->stat_max[5], tmp);
169 prt(format(" f) Chr (cur %s)", tmp), 7, 14);
171 prt(" Which stat do you want to raise?", 1, 14);
176 if ((choice >= 'a') && (choice <= 'f')) break;
178 for(n = 0; n < 6; n++)
179 if (n != choice - 'a')
182 if (get_check("¤è¤í¤·¤¤¤Ç¤¹¤«¡©")) break;
184 if (get_check("Are you sure? ")) break;
187 do_inc_stat(choice - 'a');
190 else if(!(p_ptr->max_plv % 2))
191 do_inc_stat(randint0(6));
197 msg_print("¤¢¤Ê¤¿¤ÏÊѤï¤Ã¤¿µ¤¤¬¤¹¤ë...");
199 msg_print("You feel different...");
202 (void)gain_random_mutation(0);
203 level_mutation = FALSE;
207 * Ê󽷤ǥì¥Ù¥ë¤¬¾å¤ë¤ÈºÆµ¢Åª¤Ë check_experience() ¤¬
208 * ¸Æ¤Ð¤ì¤ë¤Î¤Ç½çÈÖ¤òºÇ¸å¤Ë¤¹¤ë¡£
212 gain_level_reward(0);
213 level_reward = FALSE;
216 /* Update some stuff */
217 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
219 /* Redraw some stuff */
220 p_ptr->redraw |= (PR_LEV | PR_TITLE);
223 p_ptr->window |= (PW_PLAYER | PW_SPELL);
232 * Hack -- Return the "automatic coin type" of a monster race
233 * Used to allocate proper treasure when "Creeping coins" die
235 * XXX XXX XXX Note the use of actual "monster names"
237 static int get_coin_type(int r_idx)
239 monster_race *r_ptr = &r_info[r_idx];
241 /* Analyze "coin" monsters */
242 if (r_ptr->d_char == '$')
244 /* Look for textual clues */
247 case MON_COPPER_COINS: return (2);
248 case MON_SILVER_COINS: return (5);
249 case MON_GOLD_COINS: return (10);
250 case MON_MITHRIL_COINS: return (16);
251 case MON_ADAMANT_COINS: return (17);
261 * Hack -- determine if a template is Cloak
263 static bool kind_is_cloak(int k_idx)
265 object_kind *k_ptr = &k_info[k_idx];
267 /* Analyze the item type */
268 if (k_ptr->tval == TV_CLOAK)
273 /* Assume not good */
279 * Hack -- determine if a template is Polearm
281 static bool kind_is_polearm(int k_idx)
283 object_kind *k_ptr = &k_info[k_idx];
285 /* Analyze the item type */
286 if (k_ptr->tval == TV_POLEARM)
291 /* Assume not good */
297 * Hack -- determine if a template is Sword
299 static bool kind_is_sword(int k_idx)
301 object_kind *k_ptr = &k_info[k_idx];
303 /* Analyze the item type */
304 if ((k_ptr->tval == TV_SWORD) && (k_ptr->sval > 2))
309 /* Assume not good */
315 * Hack -- determine if a template is Book
317 static bool kind_is_book(int k_idx)
319 object_kind *k_ptr = &k_info[k_idx];
321 /* Analyze the item type */
322 if ((k_ptr->tval >= TV_LIFE_BOOK) && (k_ptr->tval <= TV_CRUSADE_BOOK))
327 /* Assume not good */
333 * Hack -- determine if a template is Good book
335 static bool kind_is_good_book(int k_idx)
337 object_kind *k_ptr = &k_info[k_idx];
339 /* Analyze the item type */
340 if ((k_ptr->tval >= TV_LIFE_BOOK) && (k_ptr->tval <= TV_CRUSADE_BOOK) && (k_ptr->tval != TV_ARCANE_BOOK) && (k_ptr->sval > 1))
345 /* Assume not good */
351 * Hack -- determine if a template is Armor
353 static bool kind_is_armor(int k_idx)
355 object_kind *k_ptr = &k_info[k_idx];
357 /* Analyze the item type */
358 if (k_ptr->tval == TV_HARD_ARMOR)
363 /* Assume not good */
369 * Check for "Quest" completion when a quest monster is killed or charmed.
371 void check_quest_completion(monster_type *m_ptr)
373 int i, j, y, x, ny, nx, i2, j2;
377 bool create_stairs = FALSE;
383 /* Get the location */
388 quest_num = p_ptr->inside_quest;
390 /* Search for an active quest on this dungeon level */
393 for (i = max_quests - 1; i > 0; i--)
395 /* Quest is not active */
396 if (quest[i].status != QUEST_STATUS_TAKEN)
399 /* Quest is not a dungeon quest */
400 if (quest[i].flags & QUEST_FLAG_PRESET)
403 /* Quest is not on this level */
404 if ((quest[i].level != dun_level) &&
405 (quest[i].type != QUEST_TYPE_KILL_ANY_LEVEL))
408 /* Not a "kill monster" quest */
409 if ((quest[i].type == QUEST_TYPE_FIND_ARTIFACT) ||
410 (quest[i].type == QUEST_TYPE_FIND_EXIT))
413 /* Interesting quest */
414 if ((quest[i].type == QUEST_TYPE_KILL_NUMBER) ||
415 (quest[i].type == QUEST_TYPE_KILL_ALL))
418 /* Interesting quest */
419 if (((quest[i].type == QUEST_TYPE_KILL_LEVEL) ||
420 (quest[i].type == QUEST_TYPE_KILL_ANY_LEVEL) ||
421 (quest[i].type == QUEST_TYPE_RANDOM)) &&
422 (quest[i].r_idx == m_ptr->r_idx))
429 /* Handle the current quest */
430 if (quest_num && (quest[quest_num].status == QUEST_STATUS_TAKEN))
435 switch (quest[i].type)
437 case QUEST_TYPE_KILL_NUMBER:
441 if (quest[i].cur_num >= quest[i].num_mon)
443 if (record_fix_quest) do_cmd_write_nikki(NIKKI_FIX_QUEST_C, i, NULL);
444 /* completed quest */
445 quest[i].status = QUEST_STATUS_COMPLETED;
446 quest[i].complev = (byte)p_ptr->lev;
448 if (!(quest[i].flags & QUEST_FLAG_SILENT))
451 msg_print("¥¯¥¨¥¹¥È¤òãÀ®¤·¤¿¡ª");
453 msg_print("You just completed your quest!");
459 quest[i].cur_num = 0;
463 case QUEST_TYPE_KILL_ALL:
467 if (!is_hostile(m_ptr)) break;
469 /* Count all hostile monsters */
470 for (i2 = 0; i2 < cur_wid; ++i2)
471 for (j2 = 0; j2 < cur_hgt; j2++)
472 if (cave[j2][i2].m_idx > 0)
473 if (is_hostile(&m_list[cave[j2][i2].m_idx]))
476 if ((number_mon - 1) == 0)
478 if (record_fix_quest) do_cmd_write_nikki(NIKKI_FIX_QUEST_C, i, NULL);
480 if (quest[i].flags & QUEST_FLAG_SILENT)
482 quest[i].status = QUEST_STATUS_FINISHED;
486 quest[i].status = QUEST_STATUS_COMPLETED;
487 quest[i].complev = (byte)p_ptr->lev;
489 msg_print("¥¯¥¨¥¹¥È¤òãÀ®¤·¤¿¡ª");
491 msg_print("You just completed your quest!");
499 case QUEST_TYPE_KILL_LEVEL:
500 case QUEST_TYPE_RANDOM:
502 /* Only count valid monsters */
503 if (quest[i].r_idx != m_ptr->r_idx)
508 if (quest[i].cur_num >= quest[i].max_num)
510 if (record_fix_quest && (quest[i].type == QUEST_TYPE_KILL_LEVEL)) do_cmd_write_nikki(NIKKI_FIX_QUEST_C, i, NULL);
511 if (record_rand_quest && (quest[i].type == QUEST_TYPE_RANDOM)) do_cmd_write_nikki(NIKKI_RAND_QUEST_C, i, NULL);
512 /* completed quest */
513 quest[i].status = QUEST_STATUS_COMPLETED;
514 quest[i].complev = (byte)p_ptr->lev;
515 if (!(quest[i].flags & QUEST_FLAG_PRESET))
517 create_stairs = TRUE;
518 p_ptr->inside_quest = 0;
521 if (!quest[i].flags & QUEST_FLAG_SILENT)
524 msg_print("¥¯¥¨¥¹¥È¤òãÀ®¤·¤¿¡ª");
526 msg_print("You just completed your quest!");
532 /* Finish the two main quests without rewarding */
533 if ((i == QUEST_OBERON) || (i == QUEST_SERPENT))
535 quest[i].status = QUEST_STATUS_FINISHED;
538 if (quest[i].type == QUEST_TYPE_RANDOM)
541 quest[i].status = QUEST_STATUS_FINISHED;
546 case QUEST_TYPE_KILL_ANY_LEVEL:
549 if (quest[i].cur_num >= quest[i].max_num)
551 if (record_fix_quest) do_cmd_write_nikki(NIKKI_FIX_QUEST_C, i, NULL);
552 /* completed quest */
553 quest[i].status = QUEST_STATUS_COMPLETED;
554 quest[i].complev = (byte)p_ptr->lev;
556 if (!quest[i].flags & QUEST_FLAG_SILENT)
559 msg_print("¥¯¥¨¥¹¥È¤òãÀ®¤·¤¿¡ª");
561 msg_print("You just completed your quest!");
566 quest[i].cur_num = 0;
573 /* Create a magical staircase */
577 while (cave_perma_bold(y, x) || cave[y][x].o_idx)
579 /* Pick a location */
580 scatter(&ny, &nx, y, x, 1, 0);
586 /* Explain the staircase */
588 msg_print("ËâË¡¤Î³¬Ãʤ¬¸½¤ì¤¿...");
590 msg_print("A magical staircase appears...");
594 /* Create stairs down */
595 cave_set_feat(y, x, FEAT_MORE);
597 /* Delete invisible trap */
598 cave[y][x].info &= ~(CAVE_TRAP);
600 /* Remember to update everything */
601 p_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MONSTERS);
609 for (j = 0; j < (dun_level / 15)+1; j++)
611 /* Get local object */
614 /* Wipe the object */
617 /* Make a great object */
618 make_object(q_ptr, TRUE, TRUE);
620 /* Drop it in the dungeon */
621 (void)drop_near(q_ptr, -1, y, x);
627 * Handle the "death" of a monster.
629 * Disperse treasures centered at the monster location based on the
630 * various flags contained in the monster flags fields.
632 * Check for "Quest" completion when a quest monster is killed.
634 * Note that only the player can induce "monster_death()" on Uniques.
635 * Thus (for now) all Quest monsters should be Uniques.
637 * Note that monsters can now carry objects, and when a monster dies,
638 * it drops all of its objects, which may disappear in crowded rooms.
640 void monster_death(int m_idx, bool drop_item)
649 monster_type *m_ptr = &m_list[m_idx];
651 monster_race *r_ptr = &r_info[m_ptr->r_idx];
653 bool visible = (m_ptr->ml || (r_ptr->flags1 & RF1_UNIQUE));
655 bool good = (r_ptr->flags1 & RF1_DROP_GOOD) ? TRUE : FALSE;
656 bool great = (r_ptr->flags1 & RF1_DROP_GREAT) ? TRUE : FALSE;
658 bool do_gold = (!(r_ptr->flags1 & RF1_ONLY_ITEM));
659 bool do_item = (!(r_ptr->flags1 & RF1_ONLY_GOLD));
661 int force_coin = get_coin_type(m_ptr->r_idx);
667 if (world_monster) world_monster = FALSE;
669 /* Notice changes in view */
670 if (r_ptr->flags7 & (RF7_HAS_LITE_1 | RF7_HAS_LITE_2 | RF7_SELF_LITE_1 | RF7_SELF_LITE_2))
672 /* Update some things */
673 p_ptr->update |= (PU_MON_LITE);
676 /* Get the location */
680 if (m_ptr->smart & SM_CLONED)
683 if (record_named_pet && is_pet(m_ptr) && m_ptr->nickname)
687 monster_desc(m_name, m_ptr, 0x08);
688 do_cmd_write_nikki(NIKKI_NAMED_PET, 3, m_name);
691 /* Let monsters explode! */
692 for (i = 0; i < 4; i++)
694 if ((r_ptr->blow[i].method == RBM_EXPLODE) || (m_ptr->r_idx == MON_ROLENTO))
696 int flg = PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL;
697 int typ = GF_MISSILE;
698 int d_dice = r_ptr->blow[i].d_dice;
699 int d_side = r_ptr->blow[i].d_side;
700 int damage = damroll(d_dice, d_side);
702 switch (r_ptr->blow[i].effect)
704 case RBE_HURT: typ = GF_MISSILE; break;
705 case RBE_POISON: typ = GF_POIS; break;
706 case RBE_UN_BONUS: typ = GF_DISENCHANT; break;
707 case RBE_UN_POWER: typ = GF_MISSILE; break; /* ToDo: Apply the correct effects */
708 case RBE_EAT_GOLD: typ = GF_MISSILE; break;
709 case RBE_EAT_ITEM: typ = GF_MISSILE; break;
710 case RBE_EAT_FOOD: typ = GF_MISSILE; break;
711 case RBE_EAT_LITE: typ = GF_MISSILE; break;
712 case RBE_ACID: typ = GF_ACID; break;
713 case RBE_ELEC: typ = GF_ELEC; break;
714 case RBE_FIRE: typ = GF_FIRE; break;
715 case RBE_COLD: typ = GF_COLD; break;
716 case RBE_BLIND: typ = GF_MISSILE; break;
717 case RBE_CONFUSE: typ = GF_CONFUSION; break;
718 case RBE_TERRIFY: typ = GF_MISSILE; break;
719 case RBE_PARALYZE: typ = GF_MISSILE; break;
720 case RBE_LOSE_STR: typ = GF_MISSILE; break;
721 case RBE_LOSE_DEX: typ = GF_MISSILE; break;
722 case RBE_LOSE_CON: typ = GF_MISSILE; break;
723 case RBE_LOSE_INT: typ = GF_MISSILE; break;
724 case RBE_LOSE_WIS: typ = GF_MISSILE; break;
725 case RBE_LOSE_CHR: typ = GF_MISSILE; break;
726 case RBE_LOSE_ALL: typ = GF_MISSILE; break;
727 case RBE_SHATTER: typ = GF_ROCKET; break;
728 case RBE_EXP_10: typ = GF_MISSILE; break;
729 case RBE_EXP_20: typ = GF_MISSILE; break;
730 case RBE_EXP_40: typ = GF_MISSILE; break;
731 case RBE_EXP_80: typ = GF_MISSILE; break;
732 case RBE_DISEASE: typ = GF_POIS; break;
733 case RBE_TIME: typ = GF_TIME; break;
734 case RBE_EXP_VAMP: typ = GF_MISSILE; break;
735 case RBE_DR_MANA: typ = GF_MANA; break;
736 case RBE_SUPERHURT: typ = GF_MISSILE; break;
738 if (m_ptr->r_idx == MON_ROLENTO)
741 damage = damroll(20,10);
744 project(m_idx, 3, y, x, damage, typ, flg, -1);
749 if (m_ptr->mflag2 & MFLAG_CHAMELEON)
751 choose_new_monster(m_idx, TRUE, MON_CHAMELEON);
752 r_ptr = &r_info[m_ptr->r_idx];
755 /* Check for quest completion */
756 check_quest_completion(m_ptr);
758 /* Handle the possibility of player vanquishing arena combatant -KMW- */
759 if (p_ptr->inside_arena && !is_pet(m_ptr))
763 /* Extract monster name */
764 monster_desc(m_name, m_ptr, 0);
766 p_ptr->exit_bldg = TRUE;
768 if (p_ptr->arena_number > MAX_ARENA_MONS)
771 msg_print("ÁÇÀ²¤é¤·¤¤¡ª·¯¤³¤½¿¿¤Î¾¡Íø¼Ô¤À¡£");
773 msg_print("You are a Genuine Champion!");
779 msg_print("¾¡Íø¡ª¥Á¥ã¥ó¥Ô¥ª¥ó¤Ø¤ÎÆ»¤ò¿Ê¤ó¤Ç¤¤¤ë¡£");
781 msg_print("Victorious! You're on your way to becoming Champion.");
785 if (arena_shouhin[p_ptr->arena_number])
787 /* Get local object */
790 /* Prepare to make a Blade of Chaos */
791 object_prep(q_ptr, lookup_kind(k_info[arena_shouhin[p_ptr->arena_number]].tval, k_info[arena_shouhin[p_ptr->arena_number]].sval));
793 apply_magic(q_ptr, object_level, FALSE, FALSE, FALSE, FALSE);
795 /* Drop it in the dungeon */
796 (void)drop_near(q_ptr, -1, y, x);
799 if (p_ptr->arena_number > MAX_ARENA_MONS) p_ptr->arena_number++;
800 p_ptr->arena_number++;
801 if (record_arena) do_cmd_write_nikki(NIKKI_ARENA, p_ptr->arena_number, m_name);
804 if (m_idx == p_ptr->riding)
806 if (rakuba(-1, FALSE))
809 msg_print("ÃÏÌ̤ËÍî¤È¤µ¤ì¤¿¡£");
811 msg_print("You have fallen from your riding pet.");
816 /* Drop a dead corpse? */
817 if (one_in_(r_ptr->flags1 & RF1_UNIQUE ? 1 : 4) &&
818 ((r_ptr->flags9 & RF9_DROP_CORPSE) ||
819 (r_ptr->flags9 & RF9_DROP_SKELETON)) &&
820 !(p_ptr->inside_arena || p_ptr->inside_battle || (m_ptr->smart & SM_CLONED) || ((m_ptr->r_idx == today_mon) && is_pet(m_ptr))))
822 /* Assume skeleton */
826 * We cannot drop a skeleton? Note, if we are in this check,
827 * we *know* we can drop at least a corpse or a skeleton
829 if (!(r_ptr->flags9 & RF9_DROP_SKELETON))
831 else if ((r_ptr->flags9 & RF9_DROP_CORPSE) && (r_ptr->flags1 && RF1_UNIQUE))
834 /* Else, a corpse is more likely unless we did a "lot" of damage */
835 else if (r_ptr->flags9 & RF9_DROP_CORPSE)
837 /* Lots of damage in one blow */
838 if ((0 - ((m_ptr->maxhp) / 4)) > m_ptr->hp)
840 if (one_in_(5)) corpse = TRUE;
844 if (!one_in_(5)) corpse = TRUE;
848 /* Get local object */
851 /* Prepare to make an object */
852 object_prep(q_ptr, lookup_kind(TV_CORPSE, (corpse ? SV_CORPSE : SV_SKELETON)));
854 apply_magic(q_ptr, object_level, FALSE, FALSE, FALSE, FALSE);
856 q_ptr->pval = m_ptr->r_idx;
858 /* Drop it in the dungeon */
859 (void)drop_near(q_ptr, -1, y, x);
862 /* Drop objects being carried */
863 monster_drop_carried_objects(m_ptr);
866 * Mega^3-hack: killing a 'Warrior of the Dawn' is likely to
867 * spawn another in the fallen one's place!
869 if (m_ptr->r_idx == MON_DAWN &&
870 !(p_ptr->inside_arena || p_ptr->inside_battle))
874 int wy = py, wx = px;
876 bool pet = is_pet(m_ptr);
880 scatter(&wy, &wx, py, px, 20, 0);
882 while (!(in_bounds(wy, wx) && cave_floor_bold(wy, wx)) && --attempts);
887 if (pet) mode |= PM_FORCE_PET;
889 if (summon_specific((pet ? -1 : m_idx), wy, wx, 100, SUMMON_DAWN, mode))
891 if (player_can_see_bold(wy, wx))
893 msg_print("¿·¤¿¤ÊÀï»Î¤¬¸½¤ì¤¿¡ª");
895 msg_print("A new warrior steps forth!");
903 /* Pink horrors are replaced with 2 Blue horrors */
904 else if (m_ptr->r_idx == MON_PINK_HORROR &&
905 !(p_ptr->inside_arena || p_ptr->inside_battle))
909 for (i = 0; i < 2; i++)
912 bool pet = is_pet(m_ptr);
915 if (pet) mode |= PM_FORCE_PET;
917 if (summon_specific((pet ? -1 : m_idx), wy, wx, 100, SUMMON_BLUE_HORROR, mode))
919 if (player_can_see_bold(wy, wx))
926 msg_print("¥Ô¥ó¥¯¡¦¥Û¥é¡¼¤ÏʬÎö¤·¤¿¡ª");
928 msg_print("The Pink horror divides!");
932 /* One more ultra-hack: An Unmaker goes out with a big bang! */
933 else if (m_ptr->r_idx == MON_UNMAKER)
936 int flg = PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL;
937 (void)project(m_idx, 6, y, x, 100, GF_CHAOS, flg, -1);
940 /* Bloodletters of Khorne may drop a blade of chaos */
941 else if (m_ptr->r_idx == MON_BLOODLETTER &&
943 (randint1(100) < 15) &&
944 !(p_ptr->inside_arena || p_ptr->inside_battle))
946 /* Get local object */
949 /* Prepare to make a Blade of Chaos */
950 object_prep(q_ptr, lookup_kind(TV_SWORD, SV_BLADE_OF_CHAOS));
952 apply_magic(q_ptr, object_level, FALSE, FALSE, FALSE, FALSE);
954 /* Drop it in the dungeon */
955 (void)drop_near(q_ptr, -1, y, x);
958 else if (m_ptr->r_idx == MON_RAAL &&
960 !(p_ptr->inside_arena || p_ptr->inside_battle))
962 /* Get local object */
965 /* Wipe the object */
968 /* Activate restriction */
969 if ((dun_level > 49) && one_in_(5))
970 get_obj_num_hook = kind_is_good_book;
972 get_obj_num_hook = kind_is_book;
974 /* Prepare allocation table */
977 /* Make a great object */
978 make_object(q_ptr, FALSE, FALSE);
980 /* Drop it in the dungeon */
981 (void)drop_near(q_ptr, -1, y, x);
984 else if (m_ptr->r_idx == MON_B_DEATH_SWORD &&
985 !(p_ptr->inside_arena || p_ptr->inside_battle))
987 /* Get local object */
990 /* Prepare to make a Blade of Chaos */
991 object_prep(q_ptr, lookup_kind(TV_SWORD, randint1(2)));
993 /* Drop it in the dungeon */
994 (void)drop_near(q_ptr, -1, y, x);
997 else if ((r_ptr->d_char == '|') && !(m_ptr->r_idx == MON_STORMBRINGER) &&
998 !(p_ptr->inside_arena || p_ptr->inside_battle))
1000 /* Get local object */
1003 /* Wipe the object */
1006 /* Activate restriction */
1007 get_obj_num_hook = kind_is_sword;
1009 /* Prepare allocation table */
1012 /* Make a great object */
1013 make_object(q_ptr, FALSE, FALSE);
1015 /* Drop it in the dungeon */
1016 (void)drop_near(q_ptr, -1, y, x);
1019 else if ((r_ptr->d_char == '(') && (dun_level > 0) &&
1020 !(p_ptr->inside_arena || p_ptr->inside_battle))
1022 /* Get local object */
1025 /* Wipe the object */
1028 /* Activate restriction */
1029 get_obj_num_hook = kind_is_cloak;
1031 /* Prepare allocation table */
1034 /* Make a great object */
1035 make_object(q_ptr, FALSE, FALSE);
1037 /* Drop it in the dungeon */
1038 (void)drop_near(q_ptr, -1, y, x);
1041 else if ((r_ptr->d_char == '/') && (dun_level > 4) &&
1042 !(p_ptr->inside_arena || p_ptr->inside_battle))
1044 /* Get local object */
1047 /* Wipe the object */
1050 /* Activate restriction */
1051 get_obj_num_hook = kind_is_polearm;
1053 /* Prepare allocation table */
1056 /* Make a great object */
1057 make_object(q_ptr, FALSE, FALSE);
1059 /* Drop it in the dungeon */
1060 (void)drop_near(q_ptr, -1, y, x);
1063 else if ((r_ptr->d_char == '[') && (dun_level > 19) &&
1064 !(p_ptr->inside_arena || p_ptr->inside_battle))
1066 /* Get local object */
1069 /* Wipe the object */
1072 /* Activate restriction */
1073 get_obj_num_hook = kind_is_armor;
1075 /* Prepare allocation table */
1078 /* Make a great object */
1079 make_object(q_ptr, FALSE, FALSE);
1081 /* Drop it in the dungeon */
1082 (void)drop_near(q_ptr, -1, y, x);
1085 else if ((m_ptr->r_idx == MON_A_GOLD || (m_ptr->r_idx == MON_A_SILVER && !((r_ptr->r_pkills+1)%5))) && !(p_ptr->inside_arena || p_ptr->inside_battle))
1087 /* Get local object */
1090 /* Prepare to make a Blade of Chaos */
1091 object_prep(q_ptr, lookup_kind(TV_CHEST, 50));
1093 apply_magic(q_ptr, object_level, FALSE, FALSE, FALSE, FALSE);
1095 /* Drop it in the dungeon */
1096 (void)drop_near(q_ptr, -1, y, x);
1098 /* Mega-Hack -- drop "winner" treasures */
1101 if (m_ptr->r_idx == MON_SERPENT)
1104 /* Get local object */
1107 /* Mega-Hack -- Prepare to make "Grond" */
1108 object_prep(q_ptr, lookup_kind(TV_HAFTED, SV_GROND));
1110 /* Mega-Hack -- Mark this item as "Grond" */
1111 q_ptr->name1 = ART_GROND;
1113 /* Mega-Hack -- Actually create "Grond" */
1114 apply_magic(q_ptr, -1, TRUE, TRUE, TRUE, FALSE);
1116 /* Drop it in the dungeon */
1117 (void)drop_near(q_ptr, -1, y, x);
1119 /* Get local object */
1122 /* Mega-Hack -- Prepare to make "Morgoth" */
1123 object_prep(q_ptr, lookup_kind(TV_CROWN, SV_MORGOTH));
1125 /* Mega-Hack -- Mark this item as "Morgoth" */
1126 q_ptr->name1 = ART_CHAOS;
1128 /* Mega-Hack -- Actually create "Morgoth" */
1129 apply_magic(q_ptr, -1, TRUE, TRUE, TRUE, FALSE);
1131 /* Drop it in the dungeon */
1132 (void)drop_near(q_ptr, -1, y, x);
1139 switch (m_ptr->r_idx)
1154 case MON_UNICORN_ORD:
1157 if (p_ptr->pseikaku == SEIKAKU_NAMAKE)
1161 switch (randint0(3))
1164 a_idx = ART_NAMAKE_HAMMER;
1167 a_idx = ART_NAMAKE_BOW;
1170 a_idx = ART_NAMAKE_ARMOR;
1174 while (a_info[a_idx].cur_num);
1185 case MON_STORMBRINGER:
1186 a_idx = ART_STORMBRINGER;
1191 a_idx = ART_CRIMSON;
1201 a_idx = ART_KUSANAGI;
1231 a_idx = ART_WEREWINDLE;
1239 a_idx = ART_GRAYSWANDIR;
1250 a_idx = ART_TWILIGHT;
1255 a_idx = ART_ELENDIL;
1270 a_idx = ART_DESTINY;
1275 a_idx = ART_ZANTETSU;
1290 a_idx = ART_WINBLOWS;
1294 case MON_LUNGORTHIN:
1299 case MON_JACK_SHADOWS:
1305 a_idx = ART_STONEMASK;
1310 a_idx = ART_SOULCRUSH;
1315 a_idx = ART_EXCALIBUR_J;
1320 a_idx = ART_SHUTEN_DOJI;
1325 a_idx = ART_GOTHMOG;
1335 if ((a_idx > 0) && ((randint0(100) < chance) || (wizard)))
1337 if (a_info[a_idx].cur_num == 0)
1339 /* Create the artifact */
1340 create_named_art(a_idx, y, x);
1342 a_info[a_idx].cur_num = 1;
1347 if ((r_ptr->flags7 & RF7_GUARDIAN) && !p_ptr->inside_battle && (d_info[dungeon_type].final_guardian == m_ptr->r_idx))
1349 int k_idx = 198; /* Acquirement */;
1351 if (d_info[dungeon_type].final_object)
1352 k_idx = d_info[dungeon_type].final_object;
1354 if (d_info[dungeon_type].final_artifact)
1356 int a_idx = d_info[dungeon_type].final_artifact;
1357 if (a_info[a_idx].cur_num == 0)
1359 /* Create the artifact */
1360 create_named_art(a_idx, y, x);
1362 a_info[a_idx].cur_num = 1;
1369 /* Get local object */
1372 /* Prepare to make a reward */
1373 object_prep(q_ptr, k_idx);
1375 apply_magic(q_ptr, object_level, FALSE, TRUE, FALSE, FALSE);
1377 /* Drop it in the dungeon */
1378 (void)drop_near(q_ptr, -1, y, x);
1381 msg_format("¤¢¤Ê¤¿¤Ï%s¤òÀ©ÇƤ·¤¿¡ª",d_name+d_info[dungeon_type].name);
1383 msg_format("You have conquered %s!",d_name+d_info[dungeon_type].name);
1387 /* Determine how much we can drop */
1388 if ((r_ptr->flags1 & RF1_DROP_60) && (randint0(100) < 60)) number++;
1389 if ((r_ptr->flags1 & RF1_DROP_90) && (randint0(100) < 90)) number++;
1390 if (r_ptr->flags1 & RF1_DROP_1D2) number += damroll(1, 2);
1391 if (r_ptr->flags1 & RF1_DROP_2D2) number += damroll(2, 2);
1392 if (r_ptr->flags1 & RF1_DROP_3D2) number += damroll(3, 2);
1393 if (r_ptr->flags1 & RF1_DROP_4D2) number += damroll(4, 2);
1395 if (cloned && !(r_ptr->flags1 & RF1_UNIQUE))
1396 number = 0; /* Clones drop no stuff unless Cloning Pits */
1398 if (is_pet(m_ptr) || p_ptr->inside_battle || p_ptr->inside_arena)
1399 number = 0; /* Pets drop no stuff */
1400 if (!drop_item && (r_ptr->d_char != '$')) number = 0;
1402 /* Hack -- handle creeping coins */
1403 coin_type = force_coin;
1405 /* Average dungeon and monster levels */
1406 object_level = (dun_level + r_ptr->level) / 2;
1408 /* Drop some objects */
1409 for (j = 0; j < number; j++)
1411 /* Get local object */
1414 /* Wipe the object */
1418 if (do_gold && (!do_item || (randint0(100) < 50)))
1420 /* Make some gold */
1421 if (!make_gold(q_ptr)) continue;
1430 /* Make an object */
1431 if (!make_object(q_ptr, good, great)) continue;
1437 /* Drop it in the dungeon */
1438 (void)drop_near(q_ptr, -1, y, x);
1441 /* Reset the object level */
1442 object_level = base_level;
1444 /* Reset "coin" type */
1448 /* Take note of any dropped treasure */
1449 if (visible && (dump_item || dump_gold))
1451 /* Take notes on treasure */
1452 lore_treasure(m_idx, dump_item, dump_gold);
1455 /* Only process "Quest Monsters" */
1456 if (!(r_ptr->flags1 & RF1_QUESTOR)) return;
1457 if (p_ptr->inside_battle) return;
1460 if (m_ptr->r_idx == MON_SERPENT)
1463 total_winner = TRUE;
1465 /* Redraw the "title" */
1466 p_ptr->redraw |= (PR_TITLE);
1469 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, "¸«»ö¤ËÊѶòÈÚÅܤξ¡Íø¼Ô¤È¤Ê¤Ã¤¿¡ª");
1471 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, "become *WINNER* of Hengband finly!");
1474 if (p_ptr->pclass == CLASS_CHAOS_WARRIOR)
1477 msg_format("%s¤«¤é¤ÎÀ¼¤¬¶Á¤¤¤¿¡£", chaos_patrons[p_ptr->chaos_patron]);
1478 msg_print("¡Ø¤è¤¯¤ä¤Ã¤¿¡¢ÄêÌ¿¤Î¼Ô¤è¡ª¡Ù");
1480 msg_format("The voice of %s booms out:", chaos_patrons[p_ptr->chaos_patron]);
1481 msg_print("'Thou art donst well, mortal!'");
1485 /* Congratulations */
1487 msg_print("*** ¤ª¤á¤Ç¤È¤¦ ***");
1489 msg_print("*** CONGRATULATIONS ***");
1493 msg_print("¤¢¤Ê¤¿¤Ï¥²¡¼¥à¤ò¥³¥ó¥×¥ê¡¼¥È¤·¤Þ¤·¤¿¡£");
1495 msg_print("You have won the game!");
1499 msg_print("½àÈ÷¤¬À°¤Ã¤¿¤é°úÂà(¼«»¦¥³¥Þ¥ó¥É)¤·¤Æ¤â·ë¹½¤Ç¤¹¡£");
1501 msg_print("You may retire (commit suicide) when you are ready.");
1508 * Modify the physical damage done to the monster.
1509 * (for example when it's invulnerable or shielded)
1511 * ToDo: Accept a damage-type to calculate the modified damage from
1512 * things like fire, frost, lightning, poison, ... attacks.
1514 * "type" is not yet used and should be 0.
1516 int mon_damage_mod(monster_type *m_ptr, int dam, bool is_psy_spear)
1518 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1520 if ((r_ptr->flags3 & RF3_RES_ALL) && dam > 0)
1523 if((dam == 0) && one_in_(3)) dam = 1;
1526 if (m_ptr->invulner)
1530 if(!p_ptr->blind && m_ptr->ml)
1533 msg_print("¥Ð¥ê¥¢¤òÀÚ¤êÎö¤¤¤¿¡ª");
1535 msg_print("The barrier is penetrated!");
1539 else if (!one_in_(PENETRATE_INVULNERABILITY))
1547 static void get_exp_from_mon(int dam, monster_type *m_ptr)
1549 s32b div, new_exp, new_exp_frac;
1550 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1551 int monnum_penarty = 0;
1553 if (!m_ptr->r_idx) return;
1554 if (is_pet(m_ptr) || p_ptr->inside_battle) return;
1558 u32b m_exp_h, m_exp_l;
1560 if ((r_ptr->flags2 & RF2_MULTIPLY) || (m_ptr->r_idx == MON_DAWN))
1562 monnum_penarty = r_ptr->r_pkills / 400;
1563 if (monnum_penarty > 8) monnum_penarty = 8;
1565 if (r_ptr->flags1 & RF1_UNIQUE)
1567 m_exp = (long)r_ptr->mexp * r_ptr->level;
1568 div = (p_ptr->max_plv+2);
1572 m_exp = (long)r_ptr->mexp * r_ptr->level * extract_energy[m_ptr->mspeed];
1573 div = (p_ptr->max_plv+2) * extract_energy[r_ptr->speed];
1575 m_exp_h = m_exp/0x10000L;
1576 m_exp_l = m_exp%0x10000L;
1579 m_exp_h += m_exp_l / 0x10000L;
1580 m_exp_l %= 0x10000L;
1582 /* real monster maxhp have effect on EXP */
1583 if(!(r_ptr->flags1 & RF1_FORCE_MAXHP))
1585 u32b maxhp = m_ptr->max_maxhp*2;
1588 m_exp_h += m_exp_l / 0x10000L;
1589 m_exp_l %= 0x10000L;
1591 div *= r_ptr->hdice * (r_ptr->hside + 1);
1593 if (!dun_level && (!(r_ptr->flags8 & RF8_WILD_ONLY) || !(r_ptr->flags1 & RF1_UNIQUE))) div *= 5;
1594 div_h = div/0x10000L;
1595 div_l = div%0x10000L;
1596 div_h *= (m_ptr->max_maxhp*2);
1597 div_l *= (m_ptr->max_maxhp*2);
1598 div_h += div_l / 0x10000L;
1601 while (monnum_penarty)
1605 div_h += div_l / 0x10000L;
1610 m_exp_l = (0x7fffffff & (m_exp_h << 16)) | m_exp_l;
1611 m_exp_h = m_exp_h >> 15;
1612 div_l = (0x7fffffff & (div_h << 16)) | div_l;
1613 div_h = div_h >> 15;
1615 #define M_INT_GREATER63(h1,l1,h2,l2) ( (h1>h2)||( (h1==h2)&&(l1>=l2)))
1616 #define M_INT_SUB63(h1,l1, h2,l2) {h1-=h2;if(l1<l2){l1+=0x80000000;h1--;}l1-=l2;}
1617 #define M_INT_LSHIFT63(h1,l1) {h1=(h1<<1)|(l1>>30);l1=(l1<<1)&0x7fffffff;}
1618 #define M_INT_RSHIFT63(h1,l1) {l1=(l1>>1)|(h1<<30);h1>>=1;}
1619 #define M_INT_DIV63(h1,l1,h2,l2,result) \
1623 while( M_INT_GREATER63(h1,l1, h2, l2) ){M_INT_LSHIFT63(h2, l2); bit<<=1;} \
1624 for(bit>>=1; bit>=1; bit>>=1){ \
1625 M_INT_RSHIFT63(h2, l2); \
1626 if(M_INT_GREATER63(h1, l1, h2, l2)) \
1627 {result|=bit;M_INT_SUB63(h1, l1, h2, l2);} \
1631 /* Give some experience for the kill */
1632 M_INT_DIV63(m_exp_h, m_exp_l, div_h, div_l, new_exp);
1634 /* Handle fractional experience */
1635 /* multiply 0x10000L to remainder */
1636 m_exp_h = (m_exp_h<<16) | (m_exp_l>>15);
1638 M_INT_DIV63(m_exp_h, m_exp_l, div_h, div_l, new_exp_frac);
1639 new_exp_frac += p_ptr->exp_frac;
1640 /* Keep track of experience */
1641 if (new_exp_frac >= 0x10000L)
1644 p_ptr->exp_frac = (u16b)(new_exp_frac - 0x10000L);
1648 p_ptr->exp_frac = (u16b)new_exp_frac;
1651 /* Gain experience */
1659 * Decreases monsters hit points, handling monster death.
1661 * We return TRUE if the monster has been killed (and deleted).
1663 * We announce monster death (using an optional "death message"
1664 * if given, and a otherwise a generic killed/destroyed message).
1666 * Only "physical attacks" can induce the "You have slain" message.
1667 * Missile and Spell attacks will induce the "dies" message, or
1668 * various "specialized" messages. Note that "You have destroyed"
1669 * and "is destroyed" are synonyms for "You have slain" and "dies".
1671 * Hack -- unseen monsters yield "You have killed it." message.
1673 * Added fear (DGK) and check whether to print fear messages -CWS
1675 * Made name, sex, and capitalization generic -BEN-
1677 * As always, the "ghost" processing is a total hack.
1679 * Hack -- we "delay" fear messages by passing around a "fear" flag.
1681 * XXX XXX XXX Consider decreasing monster experience over time, say,
1682 * by using "(m_exp * m_lev * (m_lev)) / (p_lev * (m_lev + n_killed))"
1683 * instead of simply "(m_exp * m_lev) / (p_lev)", to make the first
1684 * monster worth more than subsequent monsters. This would also need
1685 * to induce changes in the monster recall code.
1687 bool mon_take_hit(int m_idx, int dam, bool *fear, cptr note)
1689 monster_type *m_ptr = &m_list[m_idx];
1690 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1692 monster_type exp_mon;
1694 /* Innocent until proven otherwise */
1695 bool innocent = TRUE, thief = FALSE;
1699 COPY(&exp_mon, m_ptr, monster_type);
1700 if (!(r_ptr->flags7 & RF7_KILL_EXP))
1702 expdam = (m_ptr->hp > dam) ? dam : m_ptr->hp;
1703 if (r_ptr->flags6 & RF6_HEAL) expdam = (expdam+1) * 2 / 3;
1705 get_exp_from_mon(expdam, &exp_mon);
1708 /* Redraw (later) if needed */
1709 if (p_ptr->health_who == m_idx) p_ptr->redraw |= (PR_HEALTH);
1710 if (p_ptr->riding == m_idx) p_ptr->redraw |= (PR_UHEALTH);
1715 /* Hack - Cancel any special player stealth magics. -LM- */
1716 if (p_ptr->special_defense & NINJA_S_STEALTH)
1718 set_superstealth(FALSE);
1724 /* It is dead now */
1729 if (r_info[m_ptr->r_idx].flags7 & RF7_TANUKI)
1731 r_ptr = &r_info[m_ptr->r_idx];
1732 m_ptr->ap_r_idx = m_ptr->r_idx;
1733 if (r_ptr->r_sights < MAX_SHORT) r_ptr->r_sights++;
1736 /* Extract monster name */
1737 monster_desc(m_name, m_ptr, 0x100);
1739 /* Don't kill Amberites */
1740 if ((r_ptr->flags3 & RF3_AMBERITE) && one_in_(2))
1742 int curses = 1 + randint1(3);
1743 bool stop_ty = FALSE;
1747 msg_format("%^s¤Ï¶²¤í¤·¤¤·ì¤Î¼ö¤¤¤ò¤¢¤Ê¤¿¤Ë¤«¤±¤¿¡ª", m_name);
1749 msg_format("%^s puts a terrible blood curse on you!", m_name);
1752 curse_equipment(100, 50);
1756 stop_ty = activate_ty_curse(stop_ty, &count);
1761 if (r_ptr->flags2 & RF2_CAN_SPEAK)
1763 char line_got[1024];
1765 /* Dump a message */
1767 if (!get_rnd_line("mondeath_j.txt", m_ptr->r_idx, line_got))
1769 if (!get_rnd_line("mondeath.txt", m_ptr->r_idx, line_got))
1772 msg_format("%^s %s", m_name, line_got);
1775 if (m_ptr->r_idx == MON_SERPENT)
1777 /* Make screen dump */
1778 screen_dump = make_screen_dump();
1783 if (!(d_info[dungeon_type].flags1 & DF1_BEGINNER))
1785 if (!dun_level && !ambush_flag && !p_ptr->inside_arena)
1787 chg_virtue(V_VALOUR, -1);
1789 else if (r_ptr->level > dun_level)
1791 if (randint1(10) <= (r_ptr->level - dun_level))
1792 chg_virtue(V_VALOUR, 1);
1794 if (r_ptr->level > 60)
1796 chg_virtue(V_VALOUR, 1);
1798 if (r_ptr->level >= 2 * (p_ptr->lev+1))
1799 chg_virtue(V_VALOUR, 2);
1802 if ((r_ptr->flags1 & RF1_UNIQUE) && ((r_ptr->flags3 & RF3_EVIL) ||
1803 (r_ptr->flags3 & RF3_GOOD)))
1805 chg_virtue(V_HARMONY, 2);
1807 if ((r_ptr->flags1 & RF1_UNIQUE) && (r_ptr->flags3 & RF3_GOOD))
1809 chg_virtue(V_UNLIFE, 2);
1810 chg_virtue(V_VITALITY, -2);
1813 if ((r_ptr->flags1 & RF1_UNIQUE) && one_in_(3))
1814 chg_virtue(V_INDIVIDUALISM, -1);
1816 if (m_ptr->r_idx == MON_BEGGAR || m_ptr->r_idx == MON_LEPER)
1818 chg_virtue(V_COMPASSION, -1);
1821 if ((r_ptr->flags3 & RF3_GOOD) &&
1822 ((r_ptr->level) / 10 + (3 * dun_level) >= randint1(100)))
1824 chg_virtue(V_UNLIFE, 1);
1826 if (r_ptr->d_char == 'A')
1828 if (r_ptr->flags1 & RF1_UNIQUE)
1829 chg_virtue(V_FAITH, -2);
1830 else if ((r_ptr->level) / 10 + (3 * dun_level) >= randint1(100))
1832 if (r_ptr->flags3 & RF3_GOOD) chg_virtue(V_FAITH, -1);
1833 else chg_virtue(V_FAITH, 1);
1836 else if (r_ptr->flags3 & RF3_DEMON)
1838 if (r_ptr->flags1 & RF1_UNIQUE)
1839 chg_virtue(V_FAITH, 2);
1840 else if ((r_ptr->level) / 10 + (3 * dun_level) >= randint1(100))
1841 chg_virtue(V_FAITH, 1);
1844 if ((r_ptr->flags3 & RF3_UNDEAD) && (r_ptr->flags1 & RF1_UNIQUE))
1845 chg_virtue(V_VITALITY, 2);
1847 if (r_ptr->r_deaths)
1849 if (r_ptr->flags1 & RF1_UNIQUE)
1851 chg_virtue(V_HONOUR, 10);
1853 else if ((r_ptr->level) / 10 + (2 * dun_level) >= randint1(100))
1855 chg_virtue(V_HONOUR, 1);
1858 if ((r_ptr->flags2 & RF2_MULTIPLY) && (r_ptr->r_pkills > 1000) && one_in_(10))
1860 chg_virtue(V_VALOUR, -1);
1863 for (i = 0; i < 4; i++)
1865 if(r_ptr->blow[i].d_dice != 0) innocent = FALSE; /* Murderer! */
1867 if ((r_ptr->blow[i].effect == RBE_EAT_ITEM)
1868 || (r_ptr->blow[i].effect == RBE_EAT_GOLD))
1870 thief = TRUE; /* Thief! */
1873 /* The new law says it is illegal to live in the dungeon */
1874 if (r_ptr->level != 0) innocent = FALSE;
1878 if (r_ptr->flags1 & RF1_UNIQUE)
1879 chg_virtue(V_JUSTICE, 3);
1880 else if (1+((r_ptr->level) / 10 + (2 * dun_level))
1883 chg_virtue(V_JUSTICE, 1);
1887 chg_virtue (V_JUSTICE, -1);
1890 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)))
1892 if (one_in_(4)) chg_virtue(V_NATURE, -1);
1895 if((r_ptr->flags1 & RF1_UNIQUE) && record_destroy_uniq)
1896 do_cmd_write_nikki(NIKKI_UNIQUE, 0, r_name + r_ptr->name);
1901 /* Death by Missile/Spell attack */
1904 msg_format("%^s%s", m_name, note);
1907 /* Death by physical attack -- invisible monster */
1908 else if (!m_ptr->ml)
1911 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
1912 msg_format("¤»¤Ã¤«¤¯¤À¤«¤é%s¤ò»¦¤·¤¿¡£", m_name);
1914 msg_format("%s¤ò»¦¤·¤¿¡£", m_name);
1916 msg_format("You have killed %s.", m_name);
1921 /* Death by Physical attack -- non-living monster */
1922 else if (!monster_living(r_ptr))
1925 bool explode = FALSE;
1927 for (i = 0; i < 4; i++)
1929 if (r_ptr->blow[i].method == RBM_EXPLODE) explode = TRUE;
1932 /* Special note at death */
1935 msg_format("%s¤ÏÇúȯ¤·¤ÆÊ´¡¹¤Ë¤Ê¤Ã¤¿¡£", m_name);
1937 msg_format("%s explodes into tiny shreds.", m_name);
1942 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
1943 msg_format("¤»¤Ã¤«¤¯¤À¤«¤é%s¤òÅݤ·¤¿¡£", m_name);
1945 msg_format("%s¤òÅݤ·¤¿¡£", m_name);
1947 msg_format("You have destroyed %s.", m_name);
1952 /* Death by Physical attack -- living monster */
1956 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
1957 msg_format("¤»¤Ã¤«¤¯¤À¤«¤é%s¤òÁò¤êµî¤Ã¤¿¡£", m_name);
1959 msg_format("%s¤òÁò¤êµî¤Ã¤¿¡£", m_name);
1961 msg_format("You have slain %s.", m_name);
1965 if (r_ptr->flags1 & RF1_UNIQUE && !(m_ptr->smart & SM_CLONED))
1967 for (i = 0; i < MAX_KUBI; i++)
1969 if ((kubi_r_idx[i] == m_ptr->r_idx) && !(m_ptr->mflag2 & MFLAG_CHAMELEON))
1972 msg_format("%s¤Î¼ó¤Ë¤Ï¾Þ¶â¤¬¤«¤«¤Ã¤Æ¤¤¤ë¡£", m_name);
1974 msg_format("There is a price on %s's head.", m_name);
1981 if (r_ptr->flags7 & RF7_KILL_EXP)
1982 get_exp_from_mon((long)m_ptr->max_maxhp*2, &exp_mon);
1984 get_exp_from_mon(((long)m_ptr->max_maxhp+1L) * 9L / 10L, &exp_mon);
1986 /* Generate treasure */
1987 monster_death(m_idx, TRUE);
1988 if (m_ptr->mflag2 & MFLAG_CHAMELEON)
1990 if (r_ptr->flags1 & RF1_UNIQUE)
1991 r_ptr = &r_info[MON_CHAMELEON_K];
1993 r_ptr = &r_info[MON_CHAMELEON];
1994 if (r_ptr->r_sights < MAX_SHORT) r_ptr->r_sights++;
1997 /* When the player kills a Unique, it stays dead */
1998 if (r_ptr->flags1 & RF1_UNIQUE && !(m_ptr->smart & SM_CLONED))
2001 /* When the player kills a Nazgul, it stays dead */
2002 if (r_ptr->flags7 & RF7_UNIQUE_7) r_ptr->max_num--;
2004 /* Recall even invisible uniques or winners */
2005 if (m_ptr->ml || (r_ptr->flags1 & RF1_UNIQUE))
2007 /* Count kills this life */
2008 if ((m_ptr->mflag2 & MFLAG_KAGE) && (r_info[MON_KAGE].r_pkills < MAX_SHORT)) r_info[MON_KAGE].r_pkills++;
2009 else if (r_ptr->r_pkills < MAX_SHORT) r_ptr->r_pkills++;
2011 /* Count kills in all lives */
2012 if ((m_ptr->mflag2 & MFLAG_KAGE) && (r_info[MON_KAGE].r_tkills < MAX_SHORT)) r_info[MON_KAGE].r_tkills++;
2013 else if (r_ptr->r_tkills < MAX_SHORT) r_ptr->r_tkills++;
2015 /* Hack -- Auto-recall */
2016 monster_race_track(m_ptr->ap_r_idx);
2019 if ((m_ptr->r_idx == MON_BANOR) || (m_ptr->r_idx == MON_LUPART))
2021 r_info[MON_BANORLUPART].max_num = 0;
2022 r_info[MON_BANORLUPART].r_pkills++;
2023 if (r_info[MON_BANORLUPART].r_tkills < MAX_SHORT) r_info[MON_BANORLUPART].r_tkills++;
2026 if (m_ptr->r_idx == MON_BANORLUPART)
2028 r_info[MON_BANOR].max_num = 0;
2029 r_info[MON_BANOR].r_pkills++;
2030 if (r_info[MON_BANOR].r_tkills < MAX_SHORT) r_info[MON_BANOR].r_tkills++;
2031 r_info[MON_LUPART].max_num = 0;
2032 r_info[MON_LUPART].r_pkills++;
2033 if (r_info[MON_LUPART].r_tkills < MAX_SHORT) r_info[MON_LUPART].r_tkills++;
2036 /* Mega hack : replace IKETA to BIKETAL */
2037 if ((m_ptr->r_idx == MON_IKETA) &&
2038 !(p_ptr->inside_arena || p_ptr->inside_battle))
2040 int dummy_y = m_ptr->fy;
2041 int dummy_x = m_ptr->fx;
2044 if (is_pet(m_ptr)) mode |= PM_FORCE_PET;
2046 /* Delete the monster */
2047 delete_monster_idx(m_idx);
2049 if (summon_named_creature(0, dummy_y, dummy_x, MON_BIKETAL, mode))
2052 msg_print("¡Ö¥Ï¥¡¥Ã¥Ï¥Ã¥Ï¥Ã¥Ï¡ª¡ª»ä¤¬¥Ð¥¤¥±¥¿¥ë¤À¡ª¡ª¡×");
2054 msg_print("Uwa-hahaha! *I* am Biketal!");
2060 /* Delete the monster */
2061 delete_monster_idx(m_idx);
2067 /* Monster is dead */
2074 /* Mega-Hack -- Pain cancels fear */
2075 if (m_ptr->monfear && (dam > 0))
2077 int tmp = randint1(dam);
2079 /* Cure a little fear */
2080 if (tmp < m_ptr->monfear)
2083 m_ptr->monfear -= tmp;
2086 /* Cure all the fear */
2097 /* Sometimes a monster gets scared by damage */
2098 if (!m_ptr->monfear && !(r_ptr->flags3 & (RF3_NO_FEAR)))
2102 /* Percentage of fully healthy */
2103 percentage = (100L * m_ptr->hp) / m_ptr->maxhp;
2106 * Run (sometimes) if at 10% or less of max hit points,
2107 * or (usually) when hit for half its current hit points
2109 if (((percentage <= 10) && (randint0(10) < percentage)) ||
2110 ((dam >= m_ptr->hp) && (randint0(100) < 80)))
2112 /* Hack -- note fear */
2115 /* XXX XXX XXX Hack -- Add some timed fear */
2116 m_ptr->monfear = (randint1(10) +
2117 (((dam >= m_ptr->hp) && (percentage > 7)) ?
2118 20 : ((11 - percentage) * 5)));
2125 if (p_ptr->riding && (p_ptr->riding == m_idx) && (dam > 0))
2129 /* Extract monster name */
2130 monster_desc(m_name, m_ptr, 0);
2132 if (m_ptr->hp > m_ptr->maxhp/3) dam = (dam + 1) / 2;
2133 if (rakuba((dam > 200) ? 200 : dam, FALSE))
2136 msg_format("%^s¤Ë¿¶¤êÍî¤È¤µ¤ì¤¿¡ª", m_name);
2138 msg_format("%^s has thrown you off!", m_name);
2150 * Get term size and calculate screen size
2152 void get_screen_size(int *wid_p, int *hgt_p)
2154 Term_get_size(wid_p, hgt_p);
2155 *hgt_p -= ROW_MAP + 2;
2156 *wid_p -= COL_MAP + 2;
2157 if (use_bigtile) *wid_p /= 2;
2162 * Calculates current boundaries
2163 * Called below and from "do_cmd_locate()".
2165 void panel_bounds_center(void)
2170 get_screen_size(&wid, &hgt);
2172 panel_row_max = panel_row_min + hgt - 1;
2173 panel_row_prt = panel_row_min - 1;
2174 panel_col_max = panel_col_min + wid - 1;
2175 panel_col_prt = panel_col_min - 13;
2180 * Map resizing whenever the main term changes size
2182 void resize_map(void)
2184 /* Only if the dungeon exists */
2185 if (!character_dungeon) return;
2187 /* Mega-Hack -- no panel yet */
2191 /* Reset the panels */
2192 panel_row_min = cur_hgt;
2193 panel_col_min = cur_wid;
2198 p_ptr->update |= (PU_TORCH | PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
2200 /* Forget lite/view */
2201 p_ptr->update |= (PU_UN_VIEW | PU_UN_LITE);
2203 /* Update lite/view */
2204 p_ptr->update |= (PU_VIEW | PU_LITE | PU_MON_LITE);
2206 /* Update monsters */
2207 p_ptr->update |= (PU_MONSTERS);
2209 /* Redraw everything */
2210 p_ptr->redraw |= (PR_WIPE | PR_BASIC | PR_EXTRA | PR_MAP | PR_EQUIPPY);
2212 /* Hack -- update */
2220 * Place the cursor on the player
2222 if (can_save) move_cursor_relative(py, px);
2229 * Redraw a term when it is resized
2231 void redraw_window(void)
2233 /* Only if the dungeon exists */
2234 if (!character_dungeon) return;
2236 /* Hack - Activate term zero for the redraw */
2237 Term_activate(&term_screen[0]);
2239 /* Hack -- react to changes */
2240 Term_xtra(TERM_XTRA_REACT, 0);
2243 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_SPELL | PW_PLAYER);
2246 p_ptr->window |= (PW_MESSAGE | PW_OVERHEAD | PW_DUNGEON | PW_MONSTER | PW_OBJECT);
2248 /* Hack -- update */
2260 * Handle a request to change the current panel
2262 * Return TRUE if the panel was changed.
2264 * Also used in do_cmd_locate
2266 bool change_panel(int dy, int dx)
2272 get_screen_size(&wid, &hgt);
2274 /* Apply the motion */
2275 y = panel_row_min + dy * hgt / 2;
2276 x = panel_col_min + dx * wid / 2;
2278 /* Verify the row */
2279 if (y > cur_hgt - hgt) y = cur_hgt - hgt;
2282 /* Verify the col */
2283 if (x > cur_wid - wid) x = cur_wid - wid;
2286 /* Handle "changes" */
2287 if ((y != panel_row_min) || (x != panel_col_min))
2289 /* Save the new panel info */
2293 /* Recalculate the boundaries */
2294 panel_bounds_center();
2297 p_ptr->update |= (PU_MONSTERS);
2300 p_ptr->redraw |= (PR_MAP);
2315 * Given an row (y) and col (x), this routine detects when a move
2316 * off the screen has occurred and figures new borders. -RAK-
2318 * "Update" forces a "full update" to take place.
2320 * The map is reprinted if necessary, and "TRUE" is returned.
2322 void verify_panel(void)
2334 get_screen_size(&wid, &hgt);
2336 max_prow_min = cur_hgt - hgt;
2337 max_pcol_min = cur_wid - wid;
2339 /* Bounds checking */
2340 if (max_prow_min < 0) max_prow_min = 0;
2341 if (max_pcol_min < 0) max_pcol_min = 0;
2343 /* Center on player */
2344 if (center_player && (center_running || !running))
2346 /* Center vertically */
2347 prow_min = y - hgt / 2;
2348 if (prow_min < 0) prow_min = 0;
2349 else if (prow_min > max_prow_min) prow_min = max_prow_min;
2351 /* Center horizontally */
2352 pcol_min = x - wid / 2;
2353 if (pcol_min < 0) pcol_min = 0;
2354 else if (pcol_min > max_pcol_min) pcol_min = max_pcol_min;
2358 prow_min = panel_row_min;
2359 pcol_min = panel_col_min;
2361 /* Scroll screen when 2 grids from top/bottom edge */
2362 if (y > panel_row_max - 2)
2364 while (y > prow_min + hgt-1 - 2)
2366 prow_min += (hgt / 2);
2370 if (y < panel_row_min + 2)
2372 while (y < prow_min + 2)
2374 prow_min -= (hgt / 2);
2378 if (prow_min > max_prow_min) prow_min = max_prow_min;
2379 if (prow_min < 0) prow_min = 0;
2381 /* Scroll screen when 4 grids from left/right edge */
2382 if (x > panel_col_max - 4)
2384 while (x > pcol_min + wid-1 - 4)
2386 pcol_min += (wid / 2);
2390 if (x < panel_col_min + 4)
2392 while (x < pcol_min + 4)
2394 pcol_min -= (wid / 2);
2398 if (pcol_min > max_pcol_min) pcol_min = max_pcol_min;
2399 if (pcol_min < 0) pcol_min = 0;
2402 /* Check for "no change" */
2403 if ((prow_min == panel_row_min) && (pcol_min == panel_col_min)) return;
2405 /* Save the new panel info */
2406 panel_row_min = prow_min;
2407 panel_col_min = pcol_min;
2409 /* Hack -- optional disturb on "panel change" */
2410 if (disturb_panel && !center_player) disturb(0, 0);
2412 /* Recalculate the boundaries */
2413 panel_bounds_center();
2416 p_ptr->update |= (PU_MONSTERS);
2419 p_ptr->redraw |= (PR_MAP);
2422 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
2427 * Monster health description
2429 cptr look_mon_desc(int m_idx)
2431 monster_type *m_ptr = &m_list[m_idx];
2432 monster_race *r_ptr = &r_info[m_ptr->r_idx];
2437 /* Determine if the monster is "living" */
2438 living = monster_living(r_ptr);
2440 /* Calculate a health "percentage" */
2441 perc = 100L * m_ptr->hp / m_ptr->maxhp;
2443 /* Healthy monsters */
2444 if (m_ptr->hp >= m_ptr->maxhp)
2448 desc = living ? "̵½ý" : "̵¥À¥á¡¼¥¸";
2450 desc = living ? "unhurt" : "undamaged";
2455 else if (perc >= 60)
2458 desc = living ? "·Ú½ý" : "¾®¥À¥á¡¼¥¸";
2460 desc = living ? "somewhat wounded" : "somewhat damaged";
2465 else if (perc >= 25)
2468 desc = living ? "Éé½ý" : "Ãæ¥À¥á¡¼¥¸";
2470 desc = living ? "wounded" : "damaged";
2475 else if (perc >= 10)
2478 desc = living ? "½Å½ý" : "Âç¥À¥á¡¼¥¸";
2480 desc = living ? "badly wounded" : "badly damaged";
2488 desc = living ? "Ⱦ»àȾÀ¸" : "Åݤ줫¤±";
2490 desc = living ? "almost dead" : "almost destroyed";
2494 /* Display monster's level --- idea borrowed from ToME */
2495 if (r_ptr->r_tkills)
2498 return format("¥ì¥Ù¥ë%d, %s", r_ptr->level, desc);
2500 return format("Level %d, %s", r_ptr->level, desc);
2506 return format("¥ì¥Ù¥ë???, %s", desc);
2508 return format("Level ???, %s", desc);
2516 * Angband sorting algorithm -- quick sort in place
2518 * Note that the details of the data we are sorting is hidden,
2519 * and we rely on the "ang_sort_comp()" and "ang_sort_swap()"
2520 * function hooks to interact with the data, which is given as
2521 * two pointers, and which may have any user-defined form.
2523 void ang_sort_aux(vptr u, vptr v, int p, int q)
2541 while (!(*ang_sort_comp)(u, v, b, z)) b--;
2544 while (!(*ang_sort_comp)(u, v, z, a)) a++;
2546 /* Done partition */
2550 (*ang_sort_swap)(u, v, a, b);
2556 /* Recurse left side */
2557 ang_sort_aux(u, v, p, b);
2559 /* Recurse right side */
2560 ang_sort_aux(u, v, b+1, q);
2565 * Angband sorting algorithm -- quick sort in place
2567 * Note that the details of the data we are sorting is hidden,
2568 * and we rely on the "ang_sort_comp()" and "ang_sort_swap()"
2569 * function hooks to interact with the data, which is given as
2570 * two pointers, and which may have any user-defined form.
2572 void ang_sort(vptr u, vptr v, int n)
2574 /* Sort the array */
2575 ang_sort_aux(u, v, 0, n-1);
2580 /*** Targeting Code ***/
2584 * Determine is a monster makes a reasonable target
2586 * The concept of "targeting" was stolen from "Morgul" (?)
2588 * The player can target any location, or any "target-able" monster.
2590 * Currently, a monster is "target_able" if it is visible, and if
2591 * the player can hit it with a projection, and the player is not
2592 * hallucinating. This allows use of "use closest target" macros.
2594 * Future versions may restrict the ability to target "trappers"
2595 * and "mimics", but the semantics is a little bit weird.
2597 bool target_able(int m_idx)
2599 monster_type *m_ptr = &m_list[m_idx];
2601 /* Monster must be alive */
2602 if (!m_ptr->r_idx) return (FALSE);
2604 /* Hack -- no targeting hallucinations */
2605 if (p_ptr->image) return (FALSE);
2607 /* Monster must be visible */
2608 if (!m_ptr->ml) return (FALSE);
2610 if (p_ptr->riding && (p_ptr->riding == m_idx)) return (TRUE);
2612 /* Monster must be projectable */
2613 if (!projectable(py, px, m_ptr->fy, m_ptr->fx)) return (FALSE);
2615 /* XXX XXX XXX Hack -- Never target trappers */
2616 /* if (CLEAR_ATTR && (CLEAR_CHAR)) return (FALSE); */
2626 * Update (if necessary) and verify (if possible) the target.
2628 * We return TRUE if the target is "okay" and FALSE otherwise.
2630 bool target_okay(void)
2632 /* Accept stationary targets */
2633 if (target_who < 0) return (TRUE);
2635 /* Check moving targets */
2638 /* Accept reasonable targets */
2639 if (target_able(target_who))
2641 monster_type *m_ptr = &m_list[target_who];
2643 /* Acquire monster location */
2644 target_row = m_ptr->fy;
2645 target_col = m_ptr->fx;
2652 /* Assume no target */
2659 * Sorting hook -- comp function -- by "distance to player"
2661 * We use "u" and "v" to point to arrays of "x" and "y" positions,
2662 * and sort the arrays by double-distance to the player.
2664 static bool ang_sort_comp_distance(vptr u, vptr v, int a, int b)
2666 byte *x = (byte*)(u);
2667 byte *y = (byte*)(v);
2671 /* Absolute distance components */
2672 kx = x[a]; kx -= px; kx = ABS(kx);
2673 ky = y[a]; ky -= py; ky = ABS(ky);
2675 /* Approximate Double Distance to the first point */
2676 da = ((kx > ky) ? (kx + kx + ky) : (ky + ky + kx));
2678 /* Absolute distance components */
2679 kx = x[b]; kx -= px; kx = ABS(kx);
2680 ky = y[b]; ky -= py; ky = ABS(ky);
2682 /* Approximate Double Distance to the first point */
2683 db = ((kx > ky) ? (kx + kx + ky) : (ky + ky + kx));
2685 /* Compare the distances */
2691 * Sorting hook -- swap function -- by "distance to player"
2693 * We use "u" and "v" to point to arrays of "x" and "y" positions,
2694 * and sort the arrays by distance to the player.
2696 static void ang_sort_swap_distance(vptr u, vptr v, int a, int b)
2698 byte *x = (byte*)(u);
2699 byte *y = (byte*)(v);
2717 * Hack -- help "select" a location (see below)
2719 static s16b target_pick(int y1, int x1, int dy, int dx)
2723 int x2, y2, x3, y3, x4, y4;
2725 int b_i = -1, b_v = 9999;
2728 /* Scan the locations */
2729 for (i = 0; i < temp_n; i++)
2735 /* Directed distance */
2739 /* Verify quadrant */
2740 if (dx && (x3 * dx <= 0)) continue;
2741 if (dy && (y3 * dy <= 0)) continue;
2743 /* Absolute distance */
2747 /* Verify quadrant */
2748 if (dy && !dx && (x4 > y4)) continue;
2749 if (dx && !dy && (y4 > x4)) continue;
2751 /* Approximate Double Distance */
2752 v = ((x4 > y4) ? (x4 + x4 + y4) : (y4 + y4 + x4));
2754 /* XXX XXX XXX Penalize location */
2757 if ((b_i >= 0) && (v >= b_v)) continue;
2769 * Hack -- determine if a given location is "interesting"
2771 static bool target_set_accept(int y, int x)
2775 s16b this_o_idx, next_o_idx = 0;
2778 if (!(in_bounds(y, x))) return (FALSE);
2780 /* Player grid is always interesting */
2781 if ((y == py) && (x == px)) return (TRUE);
2784 /* Handle hallucination */
2785 if (p_ptr->image) return (FALSE);
2788 /* Examine the grid */
2789 c_ptr = &cave[y][x];
2791 /* Visible monsters */
2794 monster_type *m_ptr = &m_list[c_ptr->m_idx];
2796 /* Visible monsters */
2797 if (m_ptr->ml) return (TRUE);
2800 /* Scan all objects in the grid */
2801 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
2805 /* Acquire object */
2806 o_ptr = &o_list[this_o_idx];
2808 /* Acquire next object */
2809 next_o_idx = o_ptr->next_o_idx;
2811 /* Memorized object */
2812 if (o_ptr->marked) return (TRUE);
2815 /* Interesting memorized features */
2816 if (c_ptr->info & (CAVE_MARK))
2819 if (c_ptr->feat == FEAT_GLYPH) return (TRUE);
2820 if (c_ptr->feat == FEAT_MINOR_GLYPH) return (TRUE);
2821 if (c_ptr->feat == FEAT_MIRROR) return (TRUE);
2823 /* Notice the Pattern */
2824 if ((c_ptr->feat <= FEAT_PATTERN_XTRA2) &&
2825 (c_ptr->feat >= FEAT_PATTERN_START))
2829 if (c_ptr->feat == FEAT_OPEN) return (TRUE);
2830 if (c_ptr->feat == FEAT_BROKEN) return (TRUE);
2833 if (c_ptr->feat == FEAT_LESS) return (TRUE);
2834 if (c_ptr->feat == FEAT_MORE) return (TRUE);
2835 if (c_ptr->feat == FEAT_LESS_LESS) return (TRUE);
2836 if (c_ptr->feat == FEAT_MORE_MORE) return (TRUE);
2839 if ((c_ptr->feat >= FEAT_SHOP_HEAD) &&
2840 (c_ptr->feat <= FEAT_SHOP_TAIL)) return (TRUE);
2842 if (c_ptr->feat == FEAT_MUSEUM) return (TRUE);
2844 /* Notice buildings -KMW- */
2845 if ((c_ptr->feat >= FEAT_BLDG_HEAD) &&
2846 (c_ptr->feat <= FEAT_BLDG_TAIL)) return (TRUE);
2849 if (is_trap(c_ptr->feat)) return (TRUE);
2852 if ((c_ptr->feat >= FEAT_DOOR_HEAD) &&
2853 (c_ptr->feat <= FEAT_DOOR_TAIL)) return (TRUE);
2856 /* I think FEAT_RUBBLEs should not be "interesting" */
2858 if (c_ptr->feat == FEAT_RUBBLE) return (TRUE);
2860 /* Notice veins with treasure */
2861 if (c_ptr->feat == FEAT_MAGMA_K) return (TRUE);
2862 if (c_ptr->feat == FEAT_QUARTZ_K) return (TRUE);
2864 /* Notice quest features */
2865 if (c_ptr->feat == FEAT_QUEST_ENTER) return (TRUE);
2866 if (c_ptr->feat == FEAT_QUEST_EXIT) return (TRUE);
2867 if (c_ptr->feat == FEAT_QUEST_DOWN) return (TRUE);
2868 if (c_ptr->feat == FEAT_QUEST_UP) return (TRUE);
2869 if (c_ptr->feat == FEAT_TOWN) return (TRUE);
2870 if (c_ptr->feat == FEAT_ENTRANCE) return (TRUE);
2879 * Prepare the "temp" array for "target_set"
2881 * Return the number of target_able monsters in the set.
2883 static void target_set_prepare(int mode)
2887 /* Reset "temp" array */
2890 /* Scan the current panel */
2891 for (y = panel_row_min; y <= panel_row_max; y++)
2893 for (x = panel_col_min; x <= panel_col_max; x++)
2897 /* Require line of sight, unless "look" is "expanded" */
2898 if (!expand_look && !player_has_los_bold(y, x)) continue;
2900 /* Require "interesting" contents */
2901 if (!target_set_accept(y, x)) continue;
2903 c_ptr = &cave[y][x];
2905 /* Require target_able monsters for "TARGET_KILL" */
2906 if ((mode & (TARGET_KILL)) && !target_able(c_ptr->m_idx)) continue;
2908 if ((mode & (TARGET_KILL)) && !target_pet && is_pet(&m_list[c_ptr->m_idx])) continue;
2910 /* Save the location */
2917 /* Set the sort hooks */
2918 ang_sort_comp = ang_sort_comp_distance;
2919 ang_sort_swap = ang_sort_swap_distance;
2921 /* Sort the positions */
2922 ang_sort(temp_x, temp_y, temp_n);
2924 if (p_ptr->riding && target_pet && (temp_n > 1) && (mode & (TARGET_KILL)))
2929 temp_y[0] = temp_y[1];
2932 temp_x[0] = temp_x[1];
2939 * Examine a grid, return a keypress.
2941 * The "mode" argument contains the "TARGET_LOOK" bit flag, which
2942 * indicates that the "space" key should scan through the contents
2943 * of the grid, instead of simply returning immediately. This lets
2944 * the "look" command get complete information, without making the
2945 * "target" command annoying.
2947 * The "info" argument contains the "commands" which should be shown
2948 * inside the "[xxx]" text. This string must never be empty, or grids
2949 * containing monsters will be displayed with an extra comma.
2951 * Note that if a monster is in the grid, we update both the monster
2952 * recall info and the health bar info to track that monster.
2954 * Eventually, we may allow multiple objects per grid, or objects
2955 * and terrain features in the same grid. XXX XXX XXX
2957 * This function must handle blindness/hallucination.
2959 static int target_set_aux(int y, int x, int mode, cptr info)
2961 cave_type *c_ptr = &cave[y][x];
2963 s16b this_o_idx, next_o_idx = 0;
2973 char out_val[MAX_NLEN+80];
2976 /* Repeat forever */
2995 /* Hack -- under the player */
2996 if ((y == py) && (x == px))
3020 /* Hack -- hallucination */
3024 cptr name = "²¿¤«´ñ̯¤Êʪ";
3026 cptr name = "something strange";
3030 /* Display a message */
3032 sprintf(out_val, "%s%s%s%s [%s]", s1, name, s2, s3, info);
3034 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, name, info);
3038 move_cursor_relative(y, x);
3041 /* Stop on everything but "return" */
3042 if ((query != '\r') && (query != '\n')) break;
3044 /* Repeat forever */
3049 /* Actual monsters */
3052 monster_type *m_ptr = &m_list[c_ptr->m_idx];
3053 monster_race *r_ptr = &r_info[m_ptr->r_idx];
3058 bool recall = FALSE;
3065 /* Get the monster name ("a kobold") */
3066 monster_desc(m_name, m_ptr, 0x08);
3068 /* Hack -- track this monster race */
3069 monster_race_track(m_ptr->ap_r_idx);
3071 /* Hack -- health bar for this monster */
3072 health_track(c_ptr->m_idx);
3074 /* Hack -- handle stuff */
3086 /* Recall on screen */
3087 screen_roff(m_ptr->ap_r_idx, 0);
3089 /* Hack -- Complete the prompt (again) */
3091 Term_addstr(-1, TERM_WHITE, format(" [r»× %s]", info));
3093 Term_addstr(-1, TERM_WHITE, format(" [r,%s]", info));
3110 if (p_ptr->riding && (p_ptr->riding == c_ptr->m_idx))
3113 tekitou = "(¥Ú¥Ã¥È)";
3123 if (is_pet(m_ptr) && (p_ptr->riding != c_ptr->m_idx))
3125 attitude = " (¥Ú¥Ã¥È) ";
3127 attitude = " (pet) ";
3130 else if (is_friendly(m_ptr))
3132 attitude = " (ͧ¹¥Åª) ";
3134 attitude = " (friendly) ";
3145 /* Describe, and prompt for recall */
3147 #define M_INT_GREATER(h1,l1,h2,l2) ( (h1>h2)||( (h1==h2)&&(l1>=l2)))
3148 #define M_INT_SUB(h1,l1, h2,l2) {h1-=h2;if(l1<l2){l1+=0x10000;h1--;}l1-=l2;}
3149 #define M_INT_ADD(h1,l1, h2,l2) {h1+=h2;l1+=l2;if(l1>=0x10000L){l1&=0xFFFF;h1++;}}
3150 #define M_INT_LSHIFT(h1,l1) {h1=(h1<<1)|(l1>>15);l1=(l1<<1)&0xffff;}
3151 #define M_INT_RSHIFT(h1,l1) {l1=(l1>>1)|((h1&1)<<15);h1>>=1;}
3152 #define M_INT_MULT(h1,l1,mul,h2,l2) {l2=(l1*mul)&0xffff;h2=((l1*mul)>>16)+h1*mul;}
3156 u32b exp_mon= (r_ptr->mexp)*(r_ptr->level);
3157 u32b exp_mon_h= exp_mon / (p_ptr->max_plv+2);
3158 u32b exp_mon_l= ((exp_mon % (p_ptr->max_plv+2))*0x10000/(p_ptr->max_plv+2))&0xFFFF;
3160 u32b exp_adv_h = player_exp[p_ptr->lev -1] * p_ptr->expfact /100;
3161 u32b exp_adv_l = ((player_exp[p_ptr->lev -1]%100) * p_ptr->expfact *0x10000/100)&0xFFFF;
3163 M_INT_SUB(exp_adv_h, exp_adv_l, p_ptr->exp, p_ptr->exp_frac);
3164 if ((p_ptr->lev>=PY_MAX_LEVEL) || (p_ptr->prace == RACE_ANDROID))
3165 sprintf(acount,"[**]");
3166 else if (!r_ptr->r_tkills || (m_ptr->mflag2 & MFLAG_KAGE))
3167 sprintf(acount,"[??]");
3168 else if (M_INT_GREATER(exp_mon_h, exp_mon_l, exp_adv_h, exp_adv_l))
3169 sprintf(acount,"[001]");
3172 M_INT_MULT(exp_mon_h, exp_mon_l, 1000,tmp_h, tmp_l);
3173 if( M_INT_GREATER(exp_adv_h, exp_adv_l, tmp_h, tmp_l) )
3174 sprintf(acount,"[999]");
3178 M_INT_ADD(exp_adv_h, exp_adv_l, exp_mon_h, exp_mon_l);
3179 M_INT_SUB(exp_adv_h, exp_adv_l, 0, 1);
3180 while(M_INT_GREATER(exp_adv_h, exp_adv_l, exp_mon_h,exp_mon_l))
3182 M_INT_LSHIFT(exp_mon_h,exp_mon_l);
3185 M_INT_RSHIFT(exp_mon_h,exp_mon_l);bit>>=1;
3186 for(;bit>=1;bit>>=1)
3188 if(M_INT_GREATER(exp_adv_h,exp_adv_l,exp_mon_h,exp_mon_l))
3191 M_INT_SUB(exp_adv_h,exp_adv_l,exp_mon_h,exp_mon_l);
3193 M_INT_RSHIFT(exp_mon_h,exp_mon_l);
3195 sprintf(acount,"[%03d]",result);
3200 "%s%s%s(%s)%s%s%s%s%s[r»× %s]",
3201 acount, s1, m_name, look_mon_desc(c_ptr->m_idx), tekitou, s2, s3,
3203 "%s%s%s%s%s(%s)%s%s%s[r, %s]",
3204 acount, s1, s2, s3, m_name, look_mon_desc(c_ptr->m_idx), tekitou,
3206 (m_ptr->smart & SM_CLONED ? " (clone)": ""),
3213 move_cursor_relative(y, x);
3219 /* Normal commands */
3220 if (query != 'r') break;
3226 /* Always stop at "normal" keys */
3227 if ((query != '\r') && (query != '\n') && (query != ' ')) break;
3229 /* Sometimes stop at "space" key */
3230 if ((query == ' ') && !(mode & (TARGET_LOOK))) break;
3232 /* Change the intro */
3240 /* Hack -- take account of gender */
3242 if (r_ptr->flags1 & (RF1_FEMALE)) s1 = "Èà½÷¤Ï";
3244 if (r_ptr->flags1 & (RF1_FEMALE)) s1 = "She is ";
3248 else if (r_ptr->flags1 & (RF1_MALE)) s1 = "Èà¤Ï";
3250 else if (r_ptr->flags1 & (RF1_MALE)) s1 = "He is ";
3254 /* Use a preposition */
3263 /* Scan all objects being carried */
3264 for (this_o_idx = m_ptr->hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
3266 char o_name[MAX_NLEN];
3270 /* Acquire object */
3271 o_ptr = &o_list[this_o_idx];
3273 /* Acquire next object */
3274 next_o_idx = o_ptr->next_o_idx;
3276 /* Obtain an object description */
3277 object_desc(o_name, o_ptr, TRUE, 3);
3279 /* Describe the object */
3281 sprintf(out_val, "%s%s%s%s[%s]", s1, o_name, s2, s3, info);
3283 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, o_name, info);
3287 move_cursor_relative(y, x);
3290 /* Always stop at "normal" keys */
3291 if ((query != '\r') && (query != '\n') && (query != ' ')) break;
3293 /* Sometimes stop at "space" key */
3294 if ((query == ' ') && !(mode & (TARGET_LOOK))) break;
3296 /* Change the intro */
3300 s2 = "also carrying ";
3306 if (this_o_idx) break;
3308 /* Use a preposition */
3320 #ifdef ALLOW_EASY_FLOOR
3322 /* Scan all objects in the grid */
3325 int floor_list[23], floor_num;
3328 floor_num = scan_floor(floor_list, y, x, 0x02);
3339 char o_name[MAX_NLEN];
3343 /* Acquire object */
3344 o_ptr = &o_list[floor_list[0]];
3346 /* Describe the object */
3347 object_desc(o_name, o_ptr, TRUE, 3);
3351 sprintf(out_val, "%s%s%s%s[%s]",
3352 s1, o_name, s2, s3, info);
3354 sprintf(out_val, "%s%s%s%s [%s]",
3355 s1, s2, s3, o_name, info);
3363 sprintf(out_val, "%s %d¸Ä¤Î¥¢¥¤¥Æ¥à%s%s ['x'¤Ç°ìÍ÷, %s]",
3364 s1, floor_num, s2, s3, info);
3366 sprintf(out_val, "%s%s%sa pile of %d items [x,%s]",
3367 s1, s2, s3, floor_num, info);
3373 move_cursor_relative(y, x);
3378 /* Display list of items (query == "el", not "won") */
3379 if (floor_num == 1 || query != 'x')
3393 (void)show_floor(0, y, x, &min_width);
3397 prt("Enter¤Ç¼¡¤Ø¡¢Â¾¤Î¥¡¼¤ò²¡¤¹¤È¥²¡¼¥à¤ËÌá¤ê¤Þ¤¹", 0, 0);
3399 prt("Hit Enter to scroll, Hit any other key to continue", 0, 0);
3408 /* Exit unless 'Enter' */
3409 if (query != '\n' && query != '\r') break;
3411 /* Get the object being moved. */
3412 c_ptr = &cave[y][x];
3413 o_idx = c_ptr->o_idx;
3415 /* Only rotate a pile of two or more objects. */
3416 if (o_idx && o_list[o_idx].next_o_idx)
3419 /* Remove the first object from the list. */
3420 excise_object_idx(o_idx);
3422 /* Find end of the list. */
3424 while (o_list[i].next_o_idx)
3425 i = o_list[i].next_o_idx;
3427 /* Add after the last object. */
3428 o_list[i].next_o_idx = o_idx;
3438 #endif /* ALLOW_EASY_FLOOR */
3441 /* Scan all objects in the grid */
3442 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
3446 /* Acquire object */
3447 o_ptr = &o_list[this_o_idx];
3449 /* Acquire next object */
3450 next_o_idx = o_ptr->next_o_idx;
3455 char o_name[MAX_NLEN];
3460 /* Obtain an object description */
3461 object_desc(o_name, o_ptr, TRUE, 3);
3463 /* Describe the object */
3465 sprintf(out_val, "%s%s%s%s[%s]", s1, o_name, s2, s3, info);
3467 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, o_name, info);
3471 move_cursor_relative(y, x);
3474 /* Always stop at "normal" keys */
3475 if ((query != '\r') && (query != '\n') && (query != ' ')) break;
3477 /* Sometimes stop at "space" key */
3478 if ((query == ' ') && !(mode & TARGET_LOOK)) break;
3480 /* Change the intro */
3490 if (o_ptr->number != 1) s1 = "¤½¤ì¤é¤Ï";
3492 if (o_ptr->number != 1) s1 = "They are ";
3508 if (this_o_idx) break;
3512 feat = c_ptr->mimic;
3516 feat = f_info[c_ptr->feat].mimic;
3519 /* Require knowledge about grid, or ability to see grid */
3520 if (!(c_ptr->info & CAVE_MARK) && !player_can_see_bold(y, x))
3522 /* Forget feature */
3526 /* Terrain feature if needed */
3527 if (boring || (feat > FEAT_INVIS))
3531 /* Hack -- special handling for building doors */
3532 if ((feat >= FEAT_BLDG_HEAD) && (feat <= FEAT_BLDG_TAIL))
3534 name = building[feat - FEAT_BLDG_HEAD].name;
3536 else if (feat == FEAT_ENTRANCE)
3539 name = format("%s(%d³¬ÁêÅö)", d_text + d_info[c_ptr->special].text, d_info[c_ptr->special].mindepth);
3541 name = format("%s(level %d)", d_text + d_info[c_ptr->special].text, d_info[c_ptr->special].mindepth);
3544 else if (feat == FEAT_TOWN)
3546 name = town[c_ptr->special].name;
3548 else if (p_ptr->wild_mode && (feat == FEAT_FLOOR))
3558 name = f_name + f_info[feat].name;
3563 if (*s2 && ((feat >= FEAT_MINOR_GLYPH) &&
3564 (feat <= FEAT_PATTERN_XTRA2)))
3573 else if (*s2 && ((feat >= FEAT_DOOR_HEAD) &&
3574 (feat <= FEAT_PERM_SOLID)))
3583 else if (*s2 && (feat == FEAT_TOWN))
3593 /* Hack -- special introduction for store & building doors -KMW- */
3594 if (((feat >= FEAT_SHOP_HEAD) && (feat <= FEAT_SHOP_TAIL)) ||
3595 ((feat >= FEAT_BLDG_HEAD) && (feat <= FEAT_BLDG_TAIL)) ||
3596 (feat == FEAT_MUSEUM) ||
3597 (feat == FEAT_ENTRANCE))
3606 else if ((feat == FEAT_TOWN) || (feat == FEAT_FLOOR) || (feat == FEAT_DIRT) || (feat == FEAT_FLOWER))
3614 /* Pick proper indefinite article */
3616 s3 = (is_a_vowel(name[0])) ? "an " : "a ";
3620 /* Display a message */
3623 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);
3625 sprintf(out_val, "%s%s%s%s [%s] %x %d %d %d %d", s1, s2, s3, name, info, c_ptr->info, c_ptr->feat, c_ptr->dist, c_ptr->cost, c_ptr->when);
3629 sprintf(out_val, "%s%s%s%s[%s]", s1, name, s2, s3, info);
3631 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, name, info);
3635 move_cursor_relative(y, x);
3638 /* Always stop at "normal" keys */
3639 if ((query != '\r') && (query != '\n') && (query != ' ')) break;
3642 /* Stop on everything but "return" */
3643 if ((query != '\r') && (query != '\n')) break;
3652 * Handle "target" and "look".
3654 * Note that this code can be called from "get_aim_dir()".
3656 * All locations must be on the current panel. Consider the use of
3657 * "panel_bounds()" to allow "off-panel" targets, perhaps by using
3658 * some form of "scrolling" the map around the cursor. XXX XXX XXX
3659 * That is, consider the possibility of "auto-scrolling" the screen
3660 * while the cursor moves around. This may require changes in the
3661 * "update_mon()" code to allow "visibility" even if off panel, and
3662 * may require dynamic recalculation of the "temp" grid set.
3664 * Hack -- targeting/observing an "outer border grid" may induce
3665 * problems, so this is not currently allowed.
3667 * The player can use the direction keys to move among "interesting"
3668 * grids in a heuristic manner, or the "space", "+", and "-" keys to
3669 * move through the "interesting" grids in a sequential manner, or
3670 * can enter "location" mode, and use the direction keys to move one
3671 * grid at a time in any direction. The "t" (set target) command will
3672 * only target a monster (as opposed to a location) if the monster is
3673 * target_able and the "interesting" mode is being used.
3675 * The current grid is described using the "look" method above, and
3676 * a new command may be entered at any time, but note that if the
3677 * "TARGET_LOOK" bit flag is set (or if we are in "location" mode,
3678 * where "space" has no obvious meaning) then "space" will scan
3679 * through the description of the current grid until done, instead
3680 * of immediately jumping to the next "interesting" grid. This
3681 * allows the "target" command to retain its old semantics.
3683 * The "*", "+", and "-" keys may always be used to jump immediately
3684 * to the next (or previous) interesting grid, in the proper mode.
3686 * The "return" key may always be used to scan through a complete
3687 * grid description (forever).
3689 * This command will cancel any old target, even if used from
3690 * inside the "look" command.
3692 bool target_set(int mode)
3711 get_screen_size(&wid, &hgt);
3717 /* Cancel tracking */
3718 /* health_track(0); */
3721 /* Prepare the "temp" array */
3722 target_set_prepare(mode);
3724 /* Start near the player */
3730 /* Interesting grids */
3736 if (!(mode & TARGET_LOOK)) prt_path(y, x);
3739 c_ptr = &cave[y][x];
3742 if (target_able(c_ptr->m_idx))
3745 strcpy(info, "q»ß t·è p¼« o¸½ +¼¡ -Á°");
3747 strcpy(info, "q,t,p,o,+,-,<dir>");
3752 /* Dis-allow target */
3756 strcpy(info, "q»ß p¼« o¸½ +¼¡ -Á°");
3758 strcpy(info, "q,p,o,+,-,<dir>");
3763 /* Describe and Prompt */
3764 query = target_set_aux(y, x, mode, info);
3766 /* Cancel tracking */
3767 /* health_track(0); */
3769 /* Assume no "direction" */
3774 if (query == '\r') query = 't';
3792 if (target_able(c_ptr->m_idx))
3794 health_track(c_ptr->m_idx);
3795 target_who = c_ptr->m_idx;
3814 if (!expand_list) done = TRUE;
3824 if (!expand_list) done = TRUE;
3831 /* Recenter the map around the player */
3835 p_ptr->update |= (PU_MONSTERS);
3838 p_ptr->redraw |= (PR_MAP);
3841 p_ptr->window |= (PW_OVERHEAD);
3846 /* Recalculate interesting grids */
3847 target_set_prepare(mode);
3866 /* Extract the action (if any) */
3867 d = get_keymap_dir(query);
3874 /* Hack -- move around */
3877 /* Modified to scroll to monster */
3878 int y2 = panel_row_min;
3879 int x2 = panel_col_min;
3881 /* Find a new monster */
3882 i = target_pick(temp_y[m], temp_x[m], ddy[d], ddx[d]);
3884 /* Request to target past last interesting grid */
3885 while (flag && (i < 0))
3887 /* Note the change */
3888 if (change_panel(ddy[d], ddx[d]))
3893 /* Recalculate interesting grids */
3894 target_set_prepare(mode);
3896 /* Look at interesting grids */
3899 /* Find a new monster */
3900 i = target_pick(v, u, ddy[d], ddx[d]);
3906 /* Nothing interesting */
3912 /* Restore previous position */
3915 panel_bounds_center();
3918 p_ptr->update |= (PU_MONSTERS);
3921 p_ptr->redraw |= (PR_MAP);
3924 p_ptr->window |= (PW_OVERHEAD);
3929 /* Recalculate interesting grids */
3930 target_set_prepare(mode);
3932 /* Look at boring grids */
3939 /* Do not move horizontally if unnecessary */
3940 if (((x < panel_col_min + wid / 2) && (dx > 0)) ||
3941 ((x > panel_col_min + wid / 2) && (dx < 0)))
3946 /* Do not move vertically if unnecessary */
3947 if (((y < panel_row_min + hgt / 2) && (dy > 0)) ||
3948 ((y > panel_row_min + hgt / 2) && (dy < 0)))
3953 /* Apply the motion */
3954 if ((y >= panel_row_min+hgt) || (y < panel_row_min) ||
3955 (x >= panel_col_min+wid) || (x < panel_col_min))
3957 if (change_panel(dy, dx)) target_set_prepare(mode);
3960 /* Slide into legality */
3961 if (x >= cur_wid-1) x = cur_wid - 2;
3962 else if (x <= 0) x = 1;
3964 /* Slide into legality */
3965 if (y >= cur_hgt-1) y = cur_hgt- 2;
3966 else if (y <= 0) y = 1;
3975 /* Arbitrary grids */
3978 if (!(mode & TARGET_LOOK)) prt_path(y, x);
3981 c_ptr = &cave[y][x];
3983 /* Default prompt */
3985 strcpy(info, "q»ß t·è p¼« m¶á +¼¡ -Á°");
3987 strcpy(info, "q,t,p,m,+,-,<dir>");
3991 /* Describe and Prompt (enable "TARGET_LOOK") */
3992 query = target_set_aux(y, x, mode | TARGET_LOOK, info);
3994 /* Cancel tracking */
3995 /* health_track(0); */
3997 /* Assume no direction */
4002 if (query == '\r') query = 't';
4005 /* Analyze the keypress */
4029 /* Recenter the map around the player */
4033 p_ptr->update |= (PU_MONSTERS);
4036 p_ptr->redraw |= (PR_MAP);
4039 p_ptr->window |= (PW_OVERHEAD);
4044 /* Recalculate interesting grids */
4045 target_set_prepare(mode);
4067 /* Pick a nearby monster */
4068 for (i = 0; i < temp_n; i++)
4070 t = distance(y, x, temp_y[i], temp_x[i]);
4080 /* Nothing interesting */
4081 if (bd == 999) flag = FALSE;
4088 /* Extract the action (if any) */
4089 d = get_keymap_dir(query);
4096 /* Handle "direction" */
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->ap_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 int get_chaos_patron(void)
4570 return ((p_ptr->age + p_ptr->sc) % MAX_PATRON);
4574 void gain_level_reward(int chosen_reward)
4578 char wrath_reason[32] = "";
4579 int nasty_chance = 6;
4580 int dummy = 0, dummy2 = 0;
4583 char o_name[MAX_NLEN];
4589 if (multi_rew) return;
4590 else multi_rew = TRUE;
4594 if (p_ptr->lev == 13) nasty_chance = 2;
4595 else if (!(p_ptr->lev % 13)) nasty_chance = 3;
4596 else if (!(p_ptr->lev % 14)) nasty_chance = 12;
4598 if (one_in_(nasty_chance))
4599 type = randint1(20); /* Allow the 'nasty' effects */
4601 type = randint1(15) + 5; /* Or disallow them */
4603 if (type < 1) type = 1;
4604 if (type > 20) type = 20;
4609 sprintf(wrath_reason, "%s¤ÎÅܤê",
4610 chaos_patrons[p_ptr->chaos_patron]);
4612 sprintf(wrath_reason, "the Wrath of %s",
4613 chaos_patrons[p_ptr->chaos_patron]);
4617 effect = chaos_rewards[p_ptr->chaos_patron][type];
4619 if (one_in_(6) && !chosen_reward)
4622 msg_format("%^s¤ÏË«Èþ¤È¤·¤Æ¤¢¤Ê¤¿¤òÆÍÁ³ÊÑ°Û¤µ¤»¤¿¡£",
4623 chaos_patrons[p_ptr->chaos_patron]);
4625 msg_format("%^s rewards you with a mutation!",
4626 chaos_patrons[p_ptr->chaos_patron]);
4629 (void)gain_random_mutation(0);
4631 reward = "ÊÑ°Û¤·¤¿¡£";
4633 reward = "mutation";
4638 switch (chosen_reward ? chosen_reward : effect)
4642 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
4643 chaos_patrons[p_ptr->chaos_patron]);
4645 msg_format("The voice of %s booms out:",
4646 chaos_patrons[p_ptr->chaos_patron]);
4650 msg_print("¡ÖÆò¡¢¿·¤¿¤Ê¤ë»Ñ¤òɬÍפȤ»¤ê¡ª¡×");
4652 msg_print("'Thou needst a new form, mortal!'");
4657 reward = "ÊÑ°Û¤·¤¿¡£";
4659 reward = "polymorphing";
4664 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
4665 chaos_patrons[p_ptr->chaos_patron]);
4667 msg_format("The voice of %s booms out:",
4668 chaos_patrons[p_ptr->chaos_patron]);
4672 msg_print("¡ÖÆò¤ÏÎɤ¯¹Ô¤¤¤¿¤ê¡ªÂ³¤±¤è¡ª¡×");
4674 msg_print("'Well done, mortal! Lead on!'");
4677 if (p_ptr->prace == RACE_ANDROID)
4680 msg_print("¤·¤«¤·²¿¤âµ¯¤³¤é¤Ê¤«¤Ã¤¿¡£");
4682 msg_print("But, nothing happen.");
4685 else if (p_ptr->exp < PY_MAX_EXP)
4687 s32b ee = (p_ptr->exp / 2) + 10;
4688 if (ee > 100000L) ee = 100000L;
4690 msg_print("¹¹¤Ë·Ð¸³¤òÀѤó¤À¤è¤¦¤Êµ¤¤¬¤¹¤ë¡£");
4692 msg_print("You feel more experienced.");
4697 reward = "·Ð¸³ÃͤòÆÀ¤¿";
4699 reward = "experience";
4705 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
4706 chaos_patrons[p_ptr->chaos_patron]);
4708 msg_format("The voice of %s booms out:",
4709 chaos_patrons[p_ptr->chaos_patron]);
4713 msg_print("¡Ö²¼Ëͤ衢Æò¤½¤ì¤ËÃͤ»¤º¡£¡×");
4715 msg_print("'Thou didst not deserve that, slave.'");
4718 if (p_ptr->prace == RACE_ANDROID)
4721 msg_print("¤·¤«¤·²¿¤âµ¯¤³¤é¤Ê¤«¤Ã¤¿¡£");
4723 msg_print("But, nothing happen.");
4728 lose_exp(p_ptr->exp / 6);
4730 reward = "·Ð¸³Ãͤò¼º¤Ã¤¿¡£";
4732 reward = "losing experience";
4738 msg_format("%s¤ÎÀ¼¤¬¤µ¤µ¤ä¤¤¤¿:",
4739 chaos_patrons[p_ptr->chaos_patron]);
4741 msg_format("The voice of %s whispers:",
4742 chaos_patrons[p_ptr->chaos_patron]);
4746 msg_print("¡Ö²æ¤¬Í¿¤¨¤·Êª¤ò¸ÌÀ¤Ë»È¤¦¤Ù¤·¡£¡×");
4748 msg_print("'Use my gift wisely.'");
4751 acquirement(py, px, 1, FALSE, FALSE);
4753 reward = "¾å¼Á¤Ê¥¢¥¤¥Æ¥à¤ò¼ê¤ËÆþ¤ì¤¿¡£";
4755 reward = "a good item";
4760 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
4761 chaos_patrons[p_ptr->chaos_patron]);
4763 msg_format("The voice of %s booms out:",
4764 chaos_patrons[p_ptr->chaos_patron]);
4768 msg_print("¡Ö²æ¤¬Í¿¤¨¤·Êª¤ò¸ÌÀ¤Ë»È¤¦¤Ù¤·¡£¡×");
4770 msg_print("'Use my gift wisely.'");
4773 acquirement(py, px, 1, TRUE, FALSE);
4775 reward = "¹âµéÉʤΥ¢¥¤¥Æ¥à¤ò¼ê¤ËÆþ¤ì¤¿¡£";
4777 reward = "an excellent item";
4782 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
4783 chaos_patrons[p_ptr->chaos_patron]);
4785 msg_format("The voice of %s booms out:",
4786 chaos_patrons[p_ptr->chaos_patron]);
4790 msg_print("¡ÖÆò¤Î¹Ô¤¤¤Ïµ®¤·õ¤ËÃͤ»¤ê¡£¡×");
4792 msg_print("'Thy deed hath earned thee a worthy blade.'");
4795 /* Get local object */
4798 switch (randint1(p_ptr->lev))
4804 dummy2 = SV_MAIN_GAUCHE;
4813 dummy2 = SV_SMALL_SWORD;
4816 dummy2 = SV_BASILLARD;
4818 case 11: case 12: case 13:
4819 dummy2 = SV_SHORT_SWORD;
4825 dummy2 = SV_CUTLASS;
4828 dummy2 = SV_WAKIZASHI;
4831 dummy2 = SV_KHOPESH;
4837 dummy2 = SV_BROAD_SWORD;
4840 dummy2 = SV_LONG_SWORD;
4843 dummy2 = SV_SCIMITAR;
4846 dummy2 = SV_NINJATO;
4852 dummy2 = SV_BASTARD_SWORD;
4855 dummy2 = SV_GREAT_SCIMITAR;
4858 dummy2 = SV_CLAYMORE;
4861 dummy2 = SV_ESPADON;
4864 dummy2 = SV_TWO_HANDED_SWORD;
4867 dummy2 = SV_FLAMBERGE;
4870 dummy2 = SV_NO_DACHI;
4873 dummy2 = SV_EXECUTIONERS_SWORD;
4876 dummy2 = SV_ZWEIHANDER;
4879 dummy2 = SV_HAYABUSA;
4882 dummy2 = SV_BLADE_OF_CHAOS;
4885 object_prep(q_ptr, lookup_kind(dummy, dummy2));
4886 q_ptr->to_h = 3 + randint1(dun_level) % 10;
4887 q_ptr->to_d = 3 + randint1(dun_level) % 10;
4888 one_resistance(q_ptr);
4889 q_ptr->name2 = EGO_CHAOTIC;
4891 /* Drop it in the dungeon */
4892 (void)drop_near(q_ptr, -1, py, px);
4894 reward = "(º®ÆÙ)¤ÎÉð´ï¤ò¼ê¤ËÆþ¤ì¤¿¡£";
4896 reward = "chaos weapon";
4901 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
4902 chaos_patrons[p_ptr->chaos_patron]);
4904 msg_format("The voice of %s booms out:",
4905 chaos_patrons[p_ptr->chaos_patron]);
4909 msg_print("¡ÖÆò¤Î¹Ô¤¤¤Ïµ®¤Ê󤤤ËÃͤ»¤ê¡£¡×");
4911 msg_print("'Thy deed hath earned thee a worthy reward.'");
4914 acquirement(py, px, randint1(2) + 1, FALSE, FALSE);
4916 reward = "¾å¼Á¤Ê¥¢¥¤¥Æ¥à¤ò¼ê¤ËÆþ¤ì¤¿¡£";
4918 reward = "good items";
4923 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
4924 chaos_patrons[p_ptr->chaos_patron]);
4926 msg_format("The voice of %s booms out:",
4927 chaos_patrons[p_ptr->chaos_patron]);
4931 msg_print("¡Ö²¼Ëͤ衢Æò¤Î¸¥¿È¤Ø¤Î²æ¤¬Àˤ·¤ß̵¤Ê󤤤ò¸«¤ë¤¬¤è¤¤¡£¡×");
4933 msg_print("'Behold, mortal, how generously I reward thy loyalty.'");
4936 acquirement(py, px, randint1(2) + 1, TRUE, FALSE);
4938 reward = "¹âµéÉʤΥ¢¥¤¥Æ¥à¤ò¼ê¤ËÆþ¤ì¤¿¡£";
4940 reward = "excellent items";
4945 msg_format("%s¤ÎÀ¼¤¬¹ì¤ÅϤä¿:",
4946 chaos_patrons[p_ptr->chaos_patron]);
4948 msg_format("The voice of %s thunders:",
4949 chaos_patrons[p_ptr->chaos_patron]);
4953 msg_print("¡Ö²¼Ëͤ衢ÆòÐþËý¤Ê¤ê¡£¡×");
4955 msg_print("'Thou art growing arrogant, mortal.'");
4958 (void)activate_ty_curse(FALSE, &count);
4960 reward = "²Ò¡¹¤·¤¤¼ö¤¤¤ò¤«¤±¤é¤ì¤¿¡£";
4967 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
4968 chaos_patrons[p_ptr->chaos_patron]);
4970 msg_format("The voice of %s booms out:",
4971 chaos_patrons[p_ptr->chaos_patron]);
4975 msg_print("¡Ö²æ¤¬²¼Ëͤ¿¤Á¤è¡¢¤«¤ÎÐþËý¤Ê¤ë¼Ô¤òÅݤ¹¤Ù¤·¡ª¡×");
4977 msg_print("'My pets, destroy the arrogant mortal!'");
4980 for (dummy = 0; dummy < randint1(5) + 1; dummy++)
4982 (void)summon_specific(0, py, px, dun_level, 0, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET));
4985 reward = "¥â¥ó¥¹¥¿¡¼¤ò¾¤´¤µ¤ì¤¿¡£";
4987 reward = "summoning hostile monsters";
4992 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
4993 chaos_patrons[p_ptr->chaos_patron]);
4995 msg_format("The voice of %s booms out:",
4996 chaos_patrons[p_ptr->chaos_patron]);
5000 msg_print("¡ÖÆò¡¢¤è¤ê¶¯¤Å¨¤òɬÍפȤ»¤ê¡ª¡×");
5002 msg_print("'Thou needst worthier opponents!'");
5005 activate_hi_summon(py, px, FALSE);
5007 reward = "¥â¥ó¥¹¥¿¡¼¤ò¾¤´¤µ¤ì¤¿¡£";
5009 reward = "summoning many hostile monsters";
5014 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5015 chaos_patrons[p_ptr->chaos_patron]);
5017 msg_format("The voice of %s booms out:",
5018 chaos_patrons[p_ptr->chaos_patron]);
5022 msg_print("¡Ö»à¤ÈÇ˲õ¤³¤½²æ¤¬´î¤Ó¤Ê¤ê¡ª¡×");
5024 msg_print("'Death and destruction! This pleaseth me!'");
5029 reward = "¥«¥ª¥¹¤ÎÎϤ¬±²´¬¤¤¤¿¡£";
5031 reward = "calling chaos";
5036 msg_format("%s¤ÎÀ¼¤¬ÌĤê¶Á¤¤¤¿:",
5037 chaos_patrons[p_ptr->chaos_patron]);
5039 msg_format("The voice of %s rings out:",
5040 chaos_patrons[p_ptr->chaos_patron]);
5044 msg_print("¡Öα¤Þ¤ë¤Î¤À¡¢²¼Ëͤ衣;¤¬Æò¤ÎÆùÂΤòÃ䨤󡣡×");
5046 msg_print("'Stay, mortal, and let me mold thee.'");
5049 if (one_in_(3) && !(chaos_stats[p_ptr->chaos_patron] < 0))
5050 do_inc_stat(chaos_stats[p_ptr->chaos_patron]);
5052 do_inc_stat(randint0(6));
5054 reward = "ǽÎÏÃͤ¬¾å¤¬¤Ã¤¿¡£";
5056 reward = "increasing a stat";
5061 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5062 chaos_patrons[p_ptr->chaos_patron]);
5064 msg_format("The voice of %s booms out:",
5065 chaos_patrons[p_ptr->chaos_patron]);
5069 msg_print("¡Ö²¼Ëͤ衢;¤ÏÆò¤ËË°¤ß¤¿¤ê¡£¡×");
5071 msg_print("'I grow tired of thee, mortal.'");
5074 if (one_in_(3) && !(chaos_stats[p_ptr->chaos_patron] < 0))
5075 do_dec_stat(chaos_stats[p_ptr->chaos_patron]);
5077 (void)do_dec_stat(randint0(6));
5079 reward = "ǽÎÏÃͤ¬²¼¤¬¤Ã¤¿¡£";
5081 reward = "decreasing a stat";
5086 msg_format("%s¤ÎÀ¼¤¬¹ì¤ÅϤä¿:",
5087 chaos_patrons[p_ptr->chaos_patron]);
5089 msg_format("The voice of %s thunders:",
5090 chaos_patrons[p_ptr->chaos_patron]);
5094 msg_print("¡ÖÆò¡¢¸¬µõ¤¿¤ë¤³¤È¤ò³Ø¤Ö¤Ù¤·¡ª¡×");
5095 msg_print("¤¢¤Ê¤¿¤Ï°ÊÁ°¤è¤ê¼å¤¯¤Ê¤Ã¤¿¡ª");
5097 msg_print("'Thou needst a lesson in humility, mortal!'");
5098 msg_print("You feel less powerful!");
5101 for (dummy = 0; dummy < 6; dummy++)
5103 (void)dec_stat(dummy, 10 + randint1(15), TRUE);
5106 reward = "Á´Ç½ÎÏÃͤ¬²¼¤¬¤Ã¤¿¡£";
5108 reward = "decreasing all stats";
5113 msg_format("%s¤ÎÎϤ¬¿¨¤ì¤ë¤Î¤ò´¶¤¸¤¿¡£",
5115 msg_format("You feel the power of %s touch you.",
5118 chaos_patrons[p_ptr->chaos_patron]);
5121 reward = "½ý¤¬ÊѲ½¤·¤¿¡£";
5123 reward = "polymorphing wounds";
5128 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5129 chaos_patrons[p_ptr->chaos_patron]);
5131 msg_format("The voice of %s booms out:",
5132 chaos_patrons[p_ptr->chaos_patron]);
5136 msg_print("¡Ö²æ¤¬¤µ¤µ¤ä¤«¤Ê¤ë»òʪ¤ò¼õ¤±¤È¤ë¤¬¤è¤¤¡ª¡×");
5138 msg_print("'Receive this modest gift from me!'");
5141 for (dummy = 0; dummy < 6; dummy++)
5143 (void)do_inc_stat(dummy);
5146 reward = "Á´Ç½ÎÏÃͤ¬¾å¤¬¤Ã¤¿¡£";
5148 reward = "increasing all stats";
5153 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5154 chaos_patrons[p_ptr->chaos_patron]);
5156 msg_format("The voice of %s booms out:",
5157 chaos_patrons[p_ptr->chaos_patron]);
5161 msg_print("¡Ö¶ì¤·¤à¤¬¤è¤¤¡¢ÌµÇ½¤Ê¶ò¤«¼Ô¤è¡ª¡×");
5163 msg_print("'Suffer, pathetic fool!'");
5166 fire_ball(GF_DISINTEGRATE, 0, p_ptr->lev * 4, 4);
5167 take_hit(DAMAGE_NOESCAPE, p_ptr->lev * 4, wrath_reason, -1);
5169 reward = "ʬ²ò¤Îµå¤¬È¯À¸¤·¤¿¡£";
5171 reward = "generating disintegration ball";
5176 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5177 chaos_patrons[p_ptr->chaos_patron]);
5179 msg_format("The voice of %s booms out:",
5180 chaos_patrons[p_ptr->chaos_patron]);
5184 msg_print("¡Öᴤ뤬¤è¤¤¡¢²æ¤¬²¼Ëͤ衪¡×");
5186 msg_print("'Rise, my servant!'");
5190 (void)set_poisoned(0);
5192 (void)set_confused(0);
5197 for (dummy = 0; dummy < 6; dummy++)
5199 (void)do_res_stat(dummy);
5202 reward = "ÂÎÎϤ¬²óÉü¤·¤¿¡£";
5208 if (!buki_motteruka(INVEN_RARM)) break;
5210 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5211 chaos_patrons[p_ptr->chaos_patron]);
5213 msg_format("The voice of %s booms out:",
5214 chaos_patrons[p_ptr->chaos_patron]);
5218 msg_print("¡ÖÆò¡¢Éð´ï¤ËÍê¤ë¤³¤È¤Ê¤«¤ì¡£¡×");
5220 msg_print("'Thou reliest too much on thy weapon.'");
5223 object_desc(o_name, &inventory[INVEN_RARM], TRUE, 0);
5224 (void)curse_weapon(FALSE, INVEN_RARM);
5226 reward = format("%s¤¬Ç˲õ¤µ¤ì¤¿¡£", o_name);
5228 reward = format("destroying %s", o_name);
5232 if (!inventory[INVEN_BODY].k_idx) break;
5234 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5235 chaos_patrons[p_ptr->chaos_patron]);
5237 msg_format("The voice of %s booms out:",
5238 chaos_patrons[p_ptr->chaos_patron]);
5242 msg_print("¡ÖÆò¡¢Ëɶñ¤ËÍê¤ë¤³¤È¤Ê¤«¤ì¡£¡×");
5244 msg_print("'Thou reliest too much on thine equipment.'");
5247 object_desc(o_name, &inventory[INVEN_BODY], TRUE, 0);
5248 (void)curse_armor();
5250 reward = format("%s¤¬Ç˲õ¤µ¤ì¤¿¡£", o_name);
5252 reward = format("destroying %s", o_name);
5257 msg_format("%s¤ÎÀ¼¤¬¤µ¤µ¤ä¤¤¤¿:",
5258 chaos_patrons[p_ptr->chaos_patron]);
5260 msg_format("The voice of %s whispers:",
5261 chaos_patrons[p_ptr->chaos_patron]);
5265 msg_print("¡Ö²æ¤òÅܤꤷ¤á¤¿ºá¤ò½þ¤¦¤Ù¤·¡£¡×");
5267 msg_print("'Now thou shalt pay for annoying me.'");
5270 switch (randint1(4))
5273 (void)activate_ty_curse(FALSE, &count);
5275 reward = "²Ò¡¹¤·¤¤¼ö¤¤¤ò¤«¤±¤é¤ì¤¿¡£";
5281 activate_hi_summon(py, px, FALSE);
5283 reward = "¥â¥ó¥¹¥¿¡¼¤ò¾¤´¤µ¤ì¤¿¡£";
5285 reward = "summoning hostile monsters";
5291 if (!buki_motteruka(INVEN_RARM)) break;
5292 object_desc(o_name, &inventory[INVEN_RARM], TRUE, 0);
5293 (void)curse_weapon(FALSE, INVEN_RARM);
5295 reward = format("%s¤¬Ç˲õ¤µ¤ì¤¿¡£", o_name);
5297 reward = format("destroying %s", o_name);
5302 if (!inventory[INVEN_BODY].k_idx) break;
5303 object_desc(o_name, &inventory[INVEN_BODY], TRUE, 0);
5304 (void)curse_armor();
5306 reward = format("%s¤¬Ç˲õ¤µ¤ì¤¿¡£", o_name);
5308 reward = format("destroying %s", o_name);
5313 for (dummy = 0; dummy < 6; dummy++)
5315 (void)dec_stat(dummy, 10 + randint1(15), TRUE);
5318 reward = "Á´Ç½ÎÏÃͤ¬²¼¤¬¤Ã¤¿¡£";
5320 reward = "decreasing all stats";
5327 msg_format("%s¤ÎÀ¼¤¬¹ì¤ÅϤä¿:",
5329 msg_format("The voice of %s thunders:",
5332 chaos_patrons[p_ptr->chaos_patron]);
5334 msg_print("¡Ö»à¤Ì¤¬¤è¤¤¡¢²¼Ëͤ衪¡×");
5336 msg_print("'Die, mortal!'");
5339 take_hit(DAMAGE_LOSELIFE, p_ptr->lev * 4, wrath_reason, -1);
5340 for (dummy = 0; dummy < 6; dummy++)
5342 (void)dec_stat(dummy, 10 + randint1(15), FALSE);
5344 activate_hi_summon(py, px, FALSE);
5345 (void)activate_ty_curse(FALSE, &count);
5346 if (one_in_(2)) (void)curse_weapon(FALSE, INVEN_RARM);
5347 if (one_in_(2)) (void)curse_armor();
5351 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5352 chaos_patrons[p_ptr->chaos_patron]);
5354 msg_format("The voice of %s booms out:",
5355 chaos_patrons[p_ptr->chaos_patron]);
5359 msg_print("¡Ö»à¤ÈÇ˲õ¤³¤½²æ¤¬´î¤Ó¤Ê¤ê¡ª¡×");
5361 msg_print("'Death and destruction! This pleaseth me!'");
5364 destroy_area(py, px, 25, TRUE);
5366 reward = "¥À¥ó¥¸¥ç¥ó¤¬*Ç˲õ*¤µ¤ì¤¿¡£";
5368 reward = "*destruct*ing dungeon";
5373 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5374 chaos_patrons[p_ptr->chaos_patron]);
5376 msg_format("The voice of %s booms out:",
5377 chaos_patrons[p_ptr->chaos_patron]);
5381 msg_print("¡Ö²æ¡¢Æò¤ÎŨ¤òËõ»¦¤»¤ó¡ª¡×");
5383 msg_print("'Let me relieve thee of thine oppressors!'");
5386 (void)symbol_genocide(0, FALSE);
5388 reward = "¥â¥ó¥¹¥¿¡¼¤¬Ëõ»¦¤µ¤ì¤¿¡£";
5390 reward = "genociding monsters";
5395 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5396 chaos_patrons[p_ptr->chaos_patron]);
5398 msg_format("The voice of %s booms out:",
5399 chaos_patrons[p_ptr->chaos_patron]);
5403 msg_print("¡Ö²æ¡¢Æò¤ÎŨ¤òËõ»¦¤»¤ó¡ª¡×");
5405 msg_print("'Let me relieve thee of thine oppressors!'");
5408 (void)mass_genocide(0, FALSE);
5410 reward = "¥â¥ó¥¹¥¿¡¼¤¬Ëõ»¦¤µ¤ì¤¿¡£";
5412 reward = "genociding nearby monsters";
5417 msg_format("%s¤ÎÎϤ¬Å¨¤ò¹¶·â¤¹¤ë¤Î¤ò´¶¤¸¤¿¡ª",
5418 chaos_patrons[p_ptr->chaos_patron]);
5420 msg_format("You can feel the power of %s assault your enemies!",
5421 chaos_patrons[p_ptr->chaos_patron]);
5424 (void)dispel_monsters(p_ptr->lev * 4);
5428 msg_format("%s¤Ï¤¢¤Ê¤¿¤ò̵»ë¤·¤¿¡£",
5429 chaos_patrons[p_ptr->chaos_patron]);
5431 msg_format("%s ignores you.",
5432 chaos_patrons[p_ptr->chaos_patron]);
5438 msg_format("%s¤ÏË«Èþ¤È¤·¤Æ°Ëâ¤Î»È¤¤¤ò¤è¤³¤·¤¿¡ª",chaos_patrons[p_ptr->chaos_patron]);
5440 msg_format("%s rewards you with a demonic servant!",chaos_patrons[p_ptr->chaos_patron]);
5443 if (!summon_specific(-1, py, px, dun_level, SUMMON_DEMON, PM_FORCE_PET))
5445 msg_print("²¿¤â¸½¤ì¤Ê¤«¤Ã¤¿...");
5447 msg_print("Nobody ever turns up...");
5451 reward = "°Ë⤬¥Ú¥Ã¥È¤Ë¤Ê¤Ã¤¿¡£";
5453 reward = "a demonic servant";
5459 msg_format("%s¤ÏË«Èþ¤È¤·¤Æ»È¤¤¤ò¤è¤³¤·¤¿¡ª",chaos_patrons[p_ptr->chaos_patron]);
5461 msg_format("%s rewards you with a servant!",chaos_patrons[p_ptr->chaos_patron]);
5464 if (!summon_specific(-1, py, px, dun_level, 0, PM_FORCE_PET))
5466 msg_print("²¿¤â¸½¤ì¤Ê¤«¤Ã¤¿...");
5468 msg_print("Nobody ever turns up...");
5472 reward = "¥â¥ó¥¹¥¿¡¼¤¬¥Ú¥Ã¥È¤Ë¤Ê¤Ã¤¿¡£";
5474 reward = "a servant";
5480 msg_format("%s¤ÏË«Èþ¤È¤·¤Æ¥¢¥ó¥Ç¥Ã¥É¤Î»È¤¤¤ò¤è¤³¤·¤¿¡£",chaos_patrons[p_ptr->chaos_patron]);
5482 msg_format("%s rewards you with an undead servant!",chaos_patrons[p_ptr->chaos_patron]);
5485 if (!summon_specific(-1, py, px, dun_level, SUMMON_UNDEAD, PM_FORCE_PET))
5487 msg_print("²¿¤â¸½¤ì¤Ê¤«¤Ã¤¿...");
5489 msg_print("Nobody ever turns up...");
5493 reward = "¥¢¥ó¥Ç¥Ã¥É¤¬¥Ú¥Ã¥È¤Ë¤Ê¤Ã¤¿¡£";
5495 reward = "an undead servant";
5501 msg_format("%s¤ÎÀ¼¤¬¤É¤â¤Ã¤¿:",
5503 msg_format("The voice of %s stammers:",
5506 chaos_patrons[p_ptr->chaos_patron]);
5508 msg_format("¡Ö¤¢¡¼¡¢¤¢¡¼¡¢Åú¤¨¤Ï %d/%d¡£¼ÁÌä¤Ï²¿¡©¡×", type, effect);
5510 msg_format("'Uh... uh... the answer's %d/%d, what's the question?'", type, effect);
5518 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, format("¥Ñ¥È¥í¥ó¤ÎÊó½·¤Ç%s", reward));
5520 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, format("The patron rewards you with %s.", reward));
5527 * old -- from PsiAngband.
5529 bool tgt_pt(int *x_ptr, int *y_ptr)
5533 bool success = FALSE;
5538 get_screen_size(&wid, &hgt);
5544 msg_print("¾ì½ê¤òÁª¤ó¤Ç¥¹¥Ú¡¼¥¹¥¡¼¤ò²¡¤·¤Æ²¼¤µ¤¤¡£");
5546 msg_print("Select a point and press space.");
5548 msg_flag = FALSE; /* prevents "-more-" message. */
5550 while ((ch != ESCAPE) && !success)
5552 bool move_fast = FALSE;
5554 move_cursor_relative(y, x);
5566 if (x == px && y == py) ch = 0;
5569 else success = TRUE;
5573 /* Look up the direction */
5574 d = get_keymap_dir(ch);
5576 /* XTRA HACK MOVEFAST */
5577 if (isupper(ch)) move_fast = TRUE;
5579 /* Handle "direction" */
5585 /* XTRA HACK MOVEFAST */
5595 /* Do not move horizontally if unnecessary */
5596 if (((x < panel_col_min + wid / 2) && (dx > 0)) ||
5597 ((x > panel_col_min + wid / 2) && (dx < 0)))
5602 /* Do not move vertically if unnecessary */
5603 if (((y < panel_row_min + hgt / 2) && (dy > 0)) ||
5604 ((y > panel_row_min + hgt / 2) && (dy < 0)))
5609 /* Apply the motion */
5610 if ((y >= panel_row_min + hgt) || (y < panel_row_min) ||
5611 (x >= panel_col_min + wid) || (x < panel_col_min))
5613 /* if (change_panel(dy, dx)) target_set_prepare(mode); */
5614 change_panel(dy, dx);
5617 /* Slide into legality */
5618 if (x >= cur_wid-1) x = cur_wid - 2;
5619 else if (x <= 0) x = 1;
5621 /* Slide into legality */
5622 if (y >= cur_hgt-1) y = cur_hgt- 2;
5623 else if (y <= 0) y = 1;
5630 /* Clear the top line */
5633 /* Recenter the map around the player */
5637 p_ptr->update |= (PU_MONSTERS);
5640 p_ptr->redraw |= (PR_MAP);
5643 p_ptr->window |= (PW_OVERHEAD);
5654 bool get_hack_dir(int *dp)
5664 /* Global direction */
5667 /* (No auto-targeting) */
5669 /* Ask until satisfied */
5672 /* Choose a prompt */
5676 p = "Êý¸þ ('*'¤Ç¥¿¡¼¥²¥Ã¥ÈÁªÂò, ESC¤ÇÃæÃÇ)? ";
5678 p = "Direction ('*' to choose a target, Escape to cancel)? ";
5685 p = "Êý¸þ ('5'¤Ç¥¿¡¼¥²¥Ã¥È¤Ø, '*'¤Ç¥¿¡¼¥²¥Ã¥ÈºÆÁªÂò, ESC¤ÇÃæÃÇ)? ";
5687 p = "Direction ('5' for target, '*' to re-target, Escape to cancel)? ";
5692 /* Get a command (or Cancel) */
5693 if (!get_com(p, &command, TRUE)) break;
5697 if (command == '\r') command = 't';
5700 /* Convert various keys to "standard" keys */
5703 /* Use current target */
5714 /* Set new target */
5719 if (target_set(TARGET_KILL)) dir = 5;
5725 /* Look up the direction */
5726 dir = get_keymap_dir(command);
5732 /* Verify requested targets */
5733 if ((dir == 5) && !target_okay()) dir = 0;
5740 if (!dir) return (FALSE);
5742 /* Save the direction */
5745 /* Check for confusion */
5746 if (p_ptr->confused)
5749 /* Random direction */
5750 dir = ddd[randint0(8)];
5753 /* Notice confusion */
5754 if (command_dir != dir)
5758 msg_print("¤¢¤Ê¤¿¤Ïº®Í𤷤Ƥ¤¤ë¡£");
5760 msg_print("You are confused.");
5765 /* Save direction */
5768 /* A "valid" direction was entered */
5774 * ¥¨¥Í¥ë¥®¡¼¤ÎÁý²ÃÎÌ10d5¤ò®¤¯·×»»¤¹¤ë¤¿¤á¤Î´Ø¿ô
5777 #define Go_no_JuuJou 5*5*5*5*5*5*5*5*5*5
5779 s16b gain_energy(void)
5782 s32b energy_result = 10;
5785 tmp = randint0(Go_no_JuuJou);
5787 for (i = 0; i < 9; i ++){
5788 energy_result += tmp % 5;
5792 return (s16b)(energy_result + tmp);
5799 s16b bow_energy(int sval)
5803 /* Analyze the launcher */
5806 /* Sling and ammo */
5813 /* Short Bow and Arrow */
5820 /* Long Bow and Arrow */
5827 /* Bow of irresponsiblity and Arrow */
5834 /* Light Crossbow and Bolt */
5841 /* Heavy Crossbow and Bolt */
5856 int bow_tmul(int sval)
5860 /* Analyze the launcher */
5863 /* Sling and ammo */
5870 /* Short Bow and Arrow */
5877 /* Long Bow and Arrow */
5884 /* Bow of irresponsiblity and Arrow */
5891 /* Light Crossbow and Bolt */
5898 /* Heavy Crossbow and Bolt */
5910 * Return alignment title
5912 cptr your_alignment(void)
5915 if (p_ptr->align > 150) return "ÂçÁ±";
5916 else if (p_ptr->align > 50) return "ÃæÁ±";
5917 else if (p_ptr->align > 10) return "¾®Á±";
5918 else if (p_ptr->align > -11) return "ÃæΩ";
5919 else if (p_ptr->align > -51) return "¾®°";
5920 else if (p_ptr->align > -151) return "Ãæ°";
5923 if (p_ptr->align > 150) return "Lawful";
5924 else if (p_ptr->align > 50) return "Good";
5925 else if (p_ptr->align > 10) return "Neutral Good";
5926 else if (p_ptr->align > -11) return "Neutral";
5927 else if (p_ptr->align > -51) return "Neutral Evil";
5928 else if (p_ptr->align > -151) return "Evil";
5929 else return "Chaotic";