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)))
62 /* Update some stuff */
63 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
65 /* Redraw some stuff */
66 p_ptr->redraw |= (PR_LEV | PR_TITLE);
69 p_ptr->window |= (PW_PLAYER);
76 /* Gain levels while possible */
77 while ((p_ptr->lev < PY_MAX_LEVEL) &&
78 (p_ptr->exp >= ((android ? player_exp_a : player_exp)[p_ptr->lev-1] * p_ptr->expfact / 100L)))
83 /* Save the highest level */
84 if (p_ptr->lev > p_ptr->max_plv)
86 p_ptr->max_plv = p_ptr->lev;
88 if ((p_ptr->pclass == CLASS_CHAOS_WARRIOR) ||
89 (p_ptr->muta2 & MUT2_CHAOS_GIFT))
93 if (p_ptr->prace == RACE_BEASTMAN)
95 if (one_in_(5)) level_mutation = TRUE;
97 level_inc_stat = TRUE;
99 do_cmd_write_nikki(NIKKI_LEVELUP, p_ptr->lev, NULL);
107 msg_format("¥ì¥Ù¥ë %d ¤Ë¤è¤¦¤³¤½¡£", p_ptr->lev);
109 msg_format("Welcome to level %d.", p_ptr->lev);
112 /* Update some stuff */
113 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
115 /* Redraw some stuff */
116 p_ptr->redraw |= (PR_LEV | PR_TITLE);
119 p_ptr->window |= (PW_PLAYER | PW_SPELL);
121 /* HP¤ÈMP¤Î¾å¾ºÎ̤òɽ¼¨ */
131 if(!(p_ptr->max_plv % 10))
141 cnv_stat(p_ptr->stat_max[0], tmp);
142 prt(format(" a) ÏÓÎÏ (¸½ºßÃÍ %s)", tmp), 2, 14);
143 cnv_stat(p_ptr->stat_max[1], tmp);
144 prt(format(" b) ÃÎǽ (¸½ºßÃÍ %s)", tmp), 3, 14);
145 cnv_stat(p_ptr->stat_max[2], tmp);
146 prt(format(" c) ¸¤µ (¸½ºßÃÍ %s)", tmp), 4, 14);
147 cnv_stat(p_ptr->stat_max[3], tmp);
148 prt(format(" d) ´ïÍÑ (¸½ºßÃÍ %s)", tmp), 5, 14);
149 cnv_stat(p_ptr->stat_max[4], tmp);
150 prt(format(" e) ÂÑµ× (¸½ºßÃÍ %s)", tmp), 6, 14);
151 cnv_stat(p_ptr->stat_max[5], tmp);
152 prt(format(" f) Ì¥ÎÏ (¸½ºßÃÍ %s)", tmp), 7, 14);
154 prt(" ¤É¤ÎǽÎÏÃͤò¾å¤²¤Þ¤¹¤«¡©", 1, 14);
156 cnv_stat(p_ptr->stat_max[0], tmp);
157 prt(format(" a) Str (cur %s)", tmp), 2, 14);
158 cnv_stat(p_ptr->stat_max[1], tmp);
159 prt(format(" b) Int (cur %s)", tmp), 3, 14);
160 cnv_stat(p_ptr->stat_max[2], tmp);
161 prt(format(" c) Wis (cur %s)", tmp), 4, 14);
162 cnv_stat(p_ptr->stat_max[3], tmp);
163 prt(format(" d) Dex (cur %s)", tmp), 5, 14);
164 cnv_stat(p_ptr->stat_max[4], tmp);
165 prt(format(" e) Con (cur %s)", tmp), 6, 14);
166 cnv_stat(p_ptr->stat_max[5], tmp);
167 prt(format(" f) Chr (cur %s)", tmp), 7, 14);
169 prt(" Which stat do you want to raise?", 1, 14);
174 if ((choice >= 'a') && (choice <= 'f')) break;
176 for(n = 0; n < 6; n++)
177 if (n != choice - 'a')
180 if (get_check("¤è¤í¤·¤¤¤Ç¤¹¤«¡©")) break;
182 if (get_check("Are you sure? ")) break;
185 do_inc_stat(choice - 'a');
188 else if(!(p_ptr->max_plv % 2))
189 do_inc_stat(randint0(6));
195 msg_print("¤¢¤Ê¤¿¤ÏÊѤï¤Ã¤¿µ¤¤¬¤¹¤ë...");
197 msg_print("You feel different...");
200 (void)gain_random_mutation(0);
201 level_mutation = FALSE;
205 * Ê󽷤ǥì¥Ù¥ë¤¬¾å¤ë¤ÈºÆµ¢Åª¤Ë check_experience() ¤¬
206 * ¸Æ¤Ð¤ì¤ë¤Î¤Ç½çÈÖ¤òºÇ¸å¤Ë¤¹¤ë¡£
210 gain_level_reward(0);
211 level_reward = FALSE;
214 /* Update some stuff */
215 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
217 /* Redraw some stuff */
218 p_ptr->redraw |= (PR_LEV | PR_TITLE);
221 p_ptr->window |= (PW_PLAYER | PW_SPELL);
230 * Hack -- Return the "automatic coin type" of a monster race
231 * Used to allocate proper treasure when "Creeping coins" die
233 * XXX XXX XXX Note the use of actual "monster names"
235 static int get_coin_type(int r_idx)
237 monster_race *r_ptr = &r_info[r_idx];
239 /* Analyze "coin" monsters */
240 if (r_ptr->d_char == '$')
242 /* Look for textual clues */
245 case MON_COPPER_COINS: return (2);
246 case MON_SILVER_COINS: return (5);
247 case MON_GOLD_COINS: return (10);
248 case MON_MITHRIL_COINS: return (16);
249 case MON_ADAMANT_COINS: return (17);
259 * Hack -- determine if a template is Cloak
261 static bool kind_is_cloak(int k_idx)
263 object_kind *k_ptr = &k_info[k_idx];
265 /* Analyze the item type */
266 if (k_ptr->tval == TV_CLOAK)
271 /* Assume not good */
277 * Hack -- determine if a template is Polearm
279 static bool kind_is_polearm(int k_idx)
281 object_kind *k_ptr = &k_info[k_idx];
283 /* Analyze the item type */
284 if (k_ptr->tval == TV_POLEARM)
289 /* Assume not good */
295 * Hack -- determine if a template is Sword
297 static bool kind_is_sword(int k_idx)
299 object_kind *k_ptr = &k_info[k_idx];
301 /* Analyze the item type */
302 if ((k_ptr->tval == TV_SWORD) && (k_ptr->sval > 2))
307 /* Assume not good */
313 * Hack -- determine if a template is Book
315 static bool kind_is_book(int k_idx)
317 object_kind *k_ptr = &k_info[k_idx];
319 /* Analyze the item type */
320 if ((k_ptr->tval >= TV_LIFE_BOOK) && (k_ptr->tval <= TV_CRUSADE_BOOK))
325 /* Assume not good */
331 * Hack -- determine if a template is Good book
333 static bool kind_is_good_book(int k_idx)
335 object_kind *k_ptr = &k_info[k_idx];
337 /* Analyze the item type */
338 if ((k_ptr->tval >= TV_LIFE_BOOK) && (k_ptr->tval <= TV_CRUSADE_BOOK) && (k_ptr->tval != TV_ARCANE_BOOK) && (k_ptr->sval > 1))
343 /* Assume not good */
349 * Hack -- determine if a template is Armor
351 static bool kind_is_armor(int k_idx)
353 object_kind *k_ptr = &k_info[k_idx];
355 /* Analyze the item type */
356 if (k_ptr->tval == TV_HARD_ARMOR)
361 /* Assume not good */
367 * Check for "Quest" completion when a quest monster is killed or charmed.
369 void check_quest_completion(monster_type *m_ptr)
371 int i, j, y, x, ny, nx, i2, j2;
375 bool create_stairs = FALSE;
381 /* Get the location */
386 quest_num = p_ptr->inside_quest;
388 /* Search for an active quest on this dungeon level */
391 for (i = max_quests - 1; i > 0; i--)
393 /* Quest is not active */
394 if (quest[i].status != QUEST_STATUS_TAKEN)
397 /* Quest is not a dungeon quest */
398 if (quest[i].flags & QUEST_FLAG_PRESET)
401 /* Quest is not on this level */
402 if ((quest[i].level != dun_level) &&
403 (quest[i].type != QUEST_TYPE_KILL_ANY_LEVEL))
406 /* Not a "kill monster" quest */
407 if ((quest[i].type == QUEST_TYPE_FIND_ARTIFACT) ||
408 (quest[i].type == QUEST_TYPE_FIND_EXIT))
411 /* Interesting quest */
412 if ((quest[i].type == QUEST_TYPE_KILL_NUMBER) ||
413 (quest[i].type == QUEST_TYPE_KILL_ALL))
416 /* Interesting quest */
417 if (((quest[i].type == QUEST_TYPE_KILL_LEVEL) ||
418 (quest[i].type == QUEST_TYPE_KILL_ANY_LEVEL) ||
419 (quest[i].type == QUEST_TYPE_RANDOM)) &&
420 (quest[i].r_idx == m_ptr->r_idx))
427 /* Handle the current quest */
428 if (quest_num && (quest[quest_num].status == QUEST_STATUS_TAKEN))
433 switch (quest[i].type)
435 case QUEST_TYPE_KILL_NUMBER:
439 if (quest[i].cur_num >= quest[i].num_mon)
441 if (record_fix_quest) do_cmd_write_nikki(NIKKI_FIX_QUEST_C, i, NULL);
442 /* completed quest */
443 quest[i].status = QUEST_STATUS_COMPLETED;
444 quest[i].complev = (byte)p_ptr->lev;
446 if (!(quest[i].flags & QUEST_FLAG_SILENT))
449 msg_print("¥¯¥¨¥¹¥È¤òãÀ®¤·¤¿¡ª");
451 msg_print("You just completed your quest!");
457 quest[i].cur_num = 0;
461 case QUEST_TYPE_KILL_ALL:
465 if (!is_hostile(m_ptr)) break;
467 /* Count all hostile monsters */
468 for (i2 = 0; i2 < cur_wid; ++i2)
469 for (j2 = 0; j2 < cur_hgt; j2++)
470 if (cave[j2][i2].m_idx > 0)
471 if (is_hostile(&m_list[cave[j2][i2].m_idx]))
474 if ((number_mon - 1) == 0)
476 if (record_fix_quest) do_cmd_write_nikki(NIKKI_FIX_QUEST_C, i, NULL);
478 if (quest[i].flags & QUEST_FLAG_SILENT)
480 quest[i].status = QUEST_STATUS_FINISHED;
484 quest[i].status = QUEST_STATUS_COMPLETED;
485 quest[i].complev = (byte)p_ptr->lev;
487 msg_print("¥¯¥¨¥¹¥È¤òãÀ®¤·¤¿¡ª");
489 msg_print("You just completed your quest!");
497 case QUEST_TYPE_KILL_LEVEL:
498 case QUEST_TYPE_RANDOM:
500 /* Only count valid monsters */
501 if (quest[i].r_idx != m_ptr->r_idx)
506 if (quest[i].cur_num >= quest[i].max_num)
508 if (record_fix_quest && (quest[i].type == QUEST_TYPE_KILL_LEVEL)) do_cmd_write_nikki(NIKKI_FIX_QUEST_C, i, NULL);
509 if (record_rand_quest && (quest[i].type == QUEST_TYPE_RANDOM)) do_cmd_write_nikki(NIKKI_RAND_QUEST_C, i, NULL);
510 /* completed quest */
511 quest[i].status = QUEST_STATUS_COMPLETED;
512 quest[i].complev = (byte)p_ptr->lev;
513 if (!(quest[i].flags & QUEST_FLAG_PRESET))
515 create_stairs = TRUE;
516 p_ptr->inside_quest = 0;
519 if (!(quest[i].flags & QUEST_FLAG_SILENT))
522 msg_print("¥¯¥¨¥¹¥È¤òãÀ®¤·¤¿¡ª");
524 msg_print("You just completed your quest!");
530 /* Finish the two main quests without rewarding */
531 if ((i == QUEST_OBERON) || (i == QUEST_SERPENT))
533 quest[i].status = QUEST_STATUS_FINISHED;
536 if (quest[i].type == QUEST_TYPE_RANDOM)
539 quest[i].status = QUEST_STATUS_FINISHED;
544 case QUEST_TYPE_KILL_ANY_LEVEL:
547 if (quest[i].cur_num >= quest[i].max_num)
549 if (record_fix_quest) do_cmd_write_nikki(NIKKI_FIX_QUEST_C, i, NULL);
550 /* completed quest */
551 quest[i].status = QUEST_STATUS_COMPLETED;
552 quest[i].complev = (byte)p_ptr->lev;
554 if (!(quest[i].flags & QUEST_FLAG_SILENT))
557 msg_print("¥¯¥¨¥¹¥È¤òãÀ®¤·¤¿¡ª");
559 msg_print("You just completed your quest!");
564 quest[i].cur_num = 0;
571 /* Create a magical staircase */
575 while (cave_perma_bold(y, x) || cave[y][x].o_idx || (cave[y][x].info & CAVE_OBJECT) )
577 /* Pick a location */
578 scatter(&ny, &nx, y, x, 1, 0);
584 /* Explain the staircase */
586 msg_print("ËâË¡¤Î³¬Ãʤ¬¸½¤ì¤¿...");
588 msg_print("A magical staircase appears...");
592 /* Create stairs down */
593 cave_set_feat(y, x, FEAT_MORE);
595 /* Remember to update everything */
596 p_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MONSTERS);
604 for (j = 0; j < (dun_level / 15)+1; j++)
606 /* Get local object */
609 /* Wipe the object */
612 /* Make a great object */
613 make_object(q_ptr, TRUE, TRUE);
615 /* Drop it in the dungeon */
616 (void)drop_near(q_ptr, -1, y, x);
622 * Handle the "death" of a monster.
624 * Disperse treasures centered at the monster location based on the
625 * various flags contained in the monster flags fields.
627 * Check for "Quest" completion when a quest monster is killed.
629 * Note that only the player can induce "monster_death()" on Uniques.
630 * Thus (for now) all Quest monsters should be Uniques.
632 * Note that monsters can now carry objects, and when a monster dies,
633 * it drops all of its objects, which may disappear in crowded rooms.
635 void monster_death(int m_idx, bool drop_item)
644 monster_type *m_ptr = &m_list[m_idx];
646 monster_race *r_ptr = &r_info[m_ptr->r_idx];
648 bool visible = (m_ptr->ml || (r_ptr->flags1 & RF1_UNIQUE));
650 bool good = (r_ptr->flags1 & RF1_DROP_GOOD) ? TRUE : FALSE;
651 bool great = (r_ptr->flags1 & RF1_DROP_GREAT) ? TRUE : FALSE;
653 bool do_gold = (!(r_ptr->flags1 & RF1_ONLY_ITEM));
654 bool do_item = (!(r_ptr->flags1 & RF1_ONLY_GOLD));
656 int force_coin = get_coin_type(m_ptr->r_idx);
662 if (world_monster) world_monster = FALSE;
664 /* Notice changes in view */
665 if (r_ptr->flags7 & (RF7_HAS_LITE_1 | RF7_HAS_LITE_2 | RF7_SELF_LITE_1 | RF7_SELF_LITE_2))
667 /* Update some things */
668 p_ptr->update |= (PU_MON_LITE);
671 /* Get the location */
675 if (m_ptr->smart & SM_CLONED)
678 if (record_named_pet && is_pet(m_ptr) && m_ptr->nickname)
682 monster_desc(m_name, m_ptr, 0x08);
683 do_cmd_write_nikki(NIKKI_NAMED_PET, 3, m_name);
686 /* Let monsters explode! */
687 for (i = 0; i < 4; i++)
689 if ((r_ptr->blow[i].method == RBM_EXPLODE) || (m_ptr->r_idx == MON_ROLENTO))
691 int flg = PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL;
692 int typ = GF_MISSILE;
693 int d_dice = r_ptr->blow[i].d_dice;
694 int d_side = r_ptr->blow[i].d_side;
695 int damage = damroll(d_dice, d_side);
697 switch (r_ptr->blow[i].effect)
699 case RBE_HURT: typ = GF_MISSILE; break;
700 case RBE_POISON: typ = GF_POIS; break;
701 case RBE_UN_BONUS: typ = GF_DISENCHANT; break;
702 case RBE_UN_POWER: typ = GF_MISSILE; break; /* ToDo: Apply the correct effects */
703 case RBE_EAT_GOLD: typ = GF_MISSILE; break;
704 case RBE_EAT_ITEM: typ = GF_MISSILE; break;
705 case RBE_EAT_FOOD: typ = GF_MISSILE; break;
706 case RBE_EAT_LITE: typ = GF_MISSILE; break;
707 case RBE_ACID: typ = GF_ACID; break;
708 case RBE_ELEC: typ = GF_ELEC; break;
709 case RBE_FIRE: typ = GF_FIRE; break;
710 case RBE_COLD: typ = GF_COLD; break;
711 case RBE_BLIND: typ = GF_MISSILE; break;
712 case RBE_CONFUSE: typ = GF_CONFUSION; break;
713 case RBE_TERRIFY: typ = GF_MISSILE; break;
714 case RBE_PARALYZE: typ = GF_MISSILE; break;
715 case RBE_LOSE_STR: typ = GF_MISSILE; break;
716 case RBE_LOSE_DEX: typ = GF_MISSILE; break;
717 case RBE_LOSE_CON: typ = GF_MISSILE; break;
718 case RBE_LOSE_INT: typ = GF_MISSILE; break;
719 case RBE_LOSE_WIS: typ = GF_MISSILE; break;
720 case RBE_LOSE_CHR: typ = GF_MISSILE; break;
721 case RBE_LOSE_ALL: typ = GF_MISSILE; break;
722 case RBE_SHATTER: typ = GF_ROCKET; break;
723 case RBE_EXP_10: typ = GF_MISSILE; break;
724 case RBE_EXP_20: typ = GF_MISSILE; break;
725 case RBE_EXP_40: typ = GF_MISSILE; break;
726 case RBE_EXP_80: typ = GF_MISSILE; break;
727 case RBE_DISEASE: typ = GF_POIS; break;
728 case RBE_TIME: typ = GF_TIME; break;
729 case RBE_EXP_VAMP: typ = GF_MISSILE; break;
730 case RBE_DR_MANA: typ = GF_MANA; break;
731 case RBE_SUPERHURT: typ = GF_MISSILE; break;
733 if (m_ptr->r_idx == MON_ROLENTO)
736 damage = damroll(20,10);
739 project(m_idx, 3, y, x, damage, typ, flg, -1);
744 if (m_ptr->mflag2 & MFLAG_CHAMELEON)
746 choose_new_monster(m_idx, TRUE, MON_CHAMELEON);
747 r_ptr = &r_info[m_ptr->r_idx];
750 /* Check for quest completion */
751 check_quest_completion(m_ptr);
753 /* Handle the possibility of player vanquishing arena combatant -KMW- */
754 if (p_ptr->inside_arena && !is_pet(m_ptr))
758 /* Extract monster name */
759 monster_desc(m_name, m_ptr, 0);
761 p_ptr->exit_bldg = TRUE;
763 if (p_ptr->arena_number > MAX_ARENA_MONS)
766 msg_print("ÁÇÀ²¤é¤·¤¤¡ª·¯¤³¤½¿¿¤Î¾¡Íø¼Ô¤À¡£");
768 msg_print("You are a Genuine Champion!");
774 msg_print("¾¡Íø¡ª¥Á¥ã¥ó¥Ô¥ª¥ó¤Ø¤ÎÆ»¤ò¿Ê¤ó¤Ç¤¤¤ë¡£");
776 msg_print("Victorious! You're on your way to becoming Champion.");
780 if (arena_shouhin[p_ptr->arena_number])
782 /* Get local object */
785 /* Prepare to make a Blade of Chaos */
786 object_prep(q_ptr, lookup_kind(k_info[arena_shouhin[p_ptr->arena_number]].tval, k_info[arena_shouhin[p_ptr->arena_number]].sval));
788 apply_magic(q_ptr, object_level, FALSE, FALSE, FALSE, FALSE);
790 /* Drop it in the dungeon */
791 (void)drop_near(q_ptr, -1, y, x);
794 if (p_ptr->arena_number > MAX_ARENA_MONS) p_ptr->arena_number++;
795 p_ptr->arena_number++;
796 if (record_arena) do_cmd_write_nikki(NIKKI_ARENA, p_ptr->arena_number, m_name);
799 if (m_idx == p_ptr->riding)
801 if (rakuba(-1, FALSE))
804 msg_print("ÃÏÌ̤ËÍî¤È¤µ¤ì¤¿¡£");
806 msg_print("You have fallen from your riding pet.");
811 /* Drop a dead corpse? */
812 if (one_in_(r_ptr->flags1 & RF1_UNIQUE ? 1 : 4) &&
813 ((r_ptr->flags9 & RF9_DROP_CORPSE) ||
814 (r_ptr->flags9 & RF9_DROP_SKELETON)) &&
815 !(p_ptr->inside_arena || p_ptr->inside_battle || (m_ptr->smart & SM_CLONED) || ((m_ptr->r_idx == today_mon) && is_pet(m_ptr))))
817 /* Assume skeleton */
821 * We cannot drop a skeleton? Note, if we are in this check,
822 * we *know* we can drop at least a corpse or a skeleton
824 if (!(r_ptr->flags9 & RF9_DROP_SKELETON))
826 else if ((r_ptr->flags9 & RF9_DROP_CORPSE) && (r_ptr->flags1 && RF1_UNIQUE))
829 /* Else, a corpse is more likely unless we did a "lot" of damage */
830 else if (r_ptr->flags9 & RF9_DROP_CORPSE)
832 /* Lots of damage in one blow */
833 if ((0 - ((m_ptr->maxhp) / 4)) > m_ptr->hp)
835 if (one_in_(5)) corpse = TRUE;
839 if (!one_in_(5)) corpse = TRUE;
843 /* Get local object */
846 /* Prepare to make an object */
847 object_prep(q_ptr, lookup_kind(TV_CORPSE, (corpse ? SV_CORPSE : SV_SKELETON)));
849 apply_magic(q_ptr, object_level, FALSE, FALSE, FALSE, FALSE);
851 q_ptr->pval = m_ptr->r_idx;
853 /* Drop it in the dungeon */
854 (void)drop_near(q_ptr, -1, y, x);
857 /* Drop objects being carried */
858 monster_drop_carried_objects(m_ptr);
861 * Mega^3-hack: killing a 'Warrior of the Dawn' is likely to
862 * spawn another in the fallen one's place!
864 if (m_ptr->r_idx == MON_DAWN &&
865 !(p_ptr->inside_arena || p_ptr->inside_battle))
869 int wy = py, wx = px;
871 bool pet = is_pet(m_ptr);
875 scatter(&wy, &wx, py, px, 20, 0);
877 while (!(in_bounds(wy, wx) && cave_floor_bold(wy, wx)) && --attempts);
882 if (pet) mode |= PM_FORCE_PET;
884 if (summon_specific((pet ? -1 : m_idx), wy, wx, 100, SUMMON_DAWN, mode))
886 if (player_can_see_bold(wy, wx))
888 msg_print("¿·¤¿¤ÊÀï»Î¤¬¸½¤ì¤¿¡ª");
890 msg_print("A new warrior steps forth!");
898 /* Pink horrors are replaced with 2 Blue horrors */
899 else if (m_ptr->r_idx == MON_PINK_HORROR &&
900 !(p_ptr->inside_arena || p_ptr->inside_battle))
904 for (i = 0; i < 2; i++)
907 bool pet = is_pet(m_ptr);
910 if (pet) mode |= PM_FORCE_PET;
912 if (summon_specific((pet ? -1 : m_idx), wy, wx, 100, SUMMON_BLUE_HORROR, mode))
914 if (player_can_see_bold(wy, wx))
921 msg_print("¥Ô¥ó¥¯¡¦¥Û¥é¡¼¤ÏʬÎö¤·¤¿¡ª");
923 msg_print("The Pink horror divides!");
927 /* One more ultra-hack: An Unmaker goes out with a big bang! */
928 else if (m_ptr->r_idx == MON_UNMAKER)
931 int flg = PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL;
932 (void)project(m_idx, 6, y, x, 100, GF_CHAOS, flg, -1);
935 /* Bloodletters of Khorne may drop a blade of chaos */
936 else if (m_ptr->r_idx == MON_BLOODLETTER &&
938 (randint1(100) < 15) &&
939 !(p_ptr->inside_arena || p_ptr->inside_battle))
941 /* Get local object */
944 /* Prepare to make a Blade of Chaos */
945 object_prep(q_ptr, lookup_kind(TV_SWORD, SV_BLADE_OF_CHAOS));
947 apply_magic(q_ptr, object_level, FALSE, FALSE, FALSE, FALSE);
949 /* Drop it in the dungeon */
950 (void)drop_near(q_ptr, -1, y, x);
953 else if (m_ptr->r_idx == MON_RAAL &&
955 !(p_ptr->inside_arena || p_ptr->inside_battle))
957 /* Get local object */
960 /* Wipe the object */
963 /* Activate restriction */
964 if ((dun_level > 49) && one_in_(5))
965 get_obj_num_hook = kind_is_good_book;
967 get_obj_num_hook = kind_is_book;
969 /* Prepare allocation table */
972 /* Make a great object */
973 make_object(q_ptr, FALSE, FALSE);
975 /* Drop it in the dungeon */
976 (void)drop_near(q_ptr, -1, y, x);
979 else if (m_ptr->r_idx == MON_B_DEATH_SWORD &&
980 !(p_ptr->inside_arena || p_ptr->inside_battle))
982 /* Get local object */
985 /* Prepare to make a Blade of Chaos */
986 object_prep(q_ptr, lookup_kind(TV_SWORD, randint1(2)));
988 /* Drop it in the dungeon */
989 (void)drop_near(q_ptr, -1, y, x);
992 else if ((r_ptr->d_char == '|') && !(m_ptr->r_idx == MON_STORMBRINGER) &&
993 !(p_ptr->inside_arena || p_ptr->inside_battle))
995 /* Get local object */
998 /* Wipe the object */
1001 /* Activate restriction */
1002 get_obj_num_hook = kind_is_sword;
1004 /* Prepare allocation table */
1007 /* Make a great object */
1008 make_object(q_ptr, FALSE, FALSE);
1010 /* Drop it in the dungeon */
1011 (void)drop_near(q_ptr, -1, y, x);
1014 else if ((r_ptr->d_char == '(') && (dun_level > 0) &&
1015 !(p_ptr->inside_arena || p_ptr->inside_battle))
1017 /* Get local object */
1020 /* Wipe the object */
1023 /* Activate restriction */
1024 get_obj_num_hook = kind_is_cloak;
1026 /* Prepare allocation table */
1029 /* Make a great object */
1030 make_object(q_ptr, FALSE, FALSE);
1032 /* Drop it in the dungeon */
1033 (void)drop_near(q_ptr, -1, y, x);
1036 else if ((r_ptr->d_char == '/') && (dun_level > 4) &&
1037 !(p_ptr->inside_arena || p_ptr->inside_battle))
1039 /* Get local object */
1042 /* Wipe the object */
1045 /* Activate restriction */
1046 get_obj_num_hook = kind_is_polearm;
1048 /* Prepare allocation table */
1051 /* Make a great object */
1052 make_object(q_ptr, FALSE, FALSE);
1054 /* Drop it in the dungeon */
1055 (void)drop_near(q_ptr, -1, y, x);
1058 else if ((r_ptr->d_char == '[') && (dun_level > 19) &&
1059 !(p_ptr->inside_arena || p_ptr->inside_battle))
1061 /* Get local object */
1064 /* Wipe the object */
1067 /* Activate restriction */
1068 get_obj_num_hook = kind_is_armor;
1070 /* Prepare allocation table */
1073 /* Make a great object */
1074 make_object(q_ptr, FALSE, FALSE);
1076 /* Drop it in the dungeon */
1077 (void)drop_near(q_ptr, -1, y, x);
1080 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))
1082 /* Get local object */
1085 /* Prepare to make a Blade of Chaos */
1086 object_prep(q_ptr, lookup_kind(TV_CHEST, 50));
1088 apply_magic(q_ptr, object_level, FALSE, FALSE, FALSE, FALSE);
1090 /* Drop it in the dungeon */
1091 (void)drop_near(q_ptr, -1, y, x);
1093 /* Mega-Hack -- drop "winner" treasures */
1096 if (m_ptr->r_idx == MON_SERPENT)
1099 /* Get local object */
1102 /* Mega-Hack -- Prepare to make "Grond" */
1103 object_prep(q_ptr, lookup_kind(TV_HAFTED, SV_GROND));
1105 /* Mega-Hack -- Mark this item as "Grond" */
1106 q_ptr->name1 = ART_GROND;
1108 /* Mega-Hack -- Actually create "Grond" */
1109 apply_magic(q_ptr, -1, TRUE, TRUE, TRUE, FALSE);
1111 /* Drop it in the dungeon */
1112 (void)drop_near(q_ptr, -1, y, x);
1114 /* Get local object */
1117 /* Mega-Hack -- Prepare to make "Morgoth" */
1118 object_prep(q_ptr, lookup_kind(TV_CROWN, SV_MORGOTH));
1120 /* Mega-Hack -- Mark this item as "Morgoth" */
1121 q_ptr->name1 = ART_CHAOS;
1123 /* Mega-Hack -- Actually create "Morgoth" */
1124 apply_magic(q_ptr, -1, TRUE, TRUE, TRUE, FALSE);
1126 /* Drop it in the dungeon */
1127 (void)drop_near(q_ptr, -1, y, x);
1134 switch (m_ptr->r_idx)
1149 case MON_UNICORN_ORD:
1152 if (p_ptr->pseikaku == SEIKAKU_NAMAKE)
1156 switch (randint0(3))
1159 a_idx = ART_NAMAKE_HAMMER;
1162 a_idx = ART_NAMAKE_BOW;
1165 a_idx = ART_NAMAKE_ARMOR;
1169 while (a_info[a_idx].cur_num);
1180 case MON_STORMBRINGER:
1181 a_idx = ART_STORMBRINGER;
1186 a_idx = ART_CRIMSON;
1196 a_idx = ART_KUSANAGI;
1226 a_idx = ART_WEREWINDLE;
1234 a_idx = ART_GRAYSWANDIR;
1245 a_idx = ART_TWILIGHT;
1250 a_idx = ART_ELENDIL;
1265 a_idx = ART_DESTINY;
1270 a_idx = ART_ZANTETSU;
1285 a_idx = ART_WINBLOWS;
1289 case MON_LUNGORTHIN:
1294 case MON_JACK_SHADOWS:
1300 a_idx = ART_STONEMASK;
1305 a_idx = ART_SOULCRUSH;
1310 a_idx = ART_EXCALIBUR_J;
1315 a_idx = ART_SHUTEN_DOJI;
1320 a_idx = ART_GOTHMOG;
1330 if ((a_idx > 0) && ((randint0(100) < chance) || (p_ptr->wizard)))
1332 if (a_info[a_idx].cur_num == 0)
1334 /* Create the artifact */
1335 create_named_art(a_idx, y, x);
1337 a_info[a_idx].cur_num = 1;
1342 if ((r_ptr->flags7 & RF7_GUARDIAN) && !p_ptr->inside_battle && (d_info[dungeon_type].final_guardian == m_ptr->r_idx))
1344 int k_idx = 198; /* Acquirement */;
1346 if (d_info[dungeon_type].final_object)
1347 k_idx = d_info[dungeon_type].final_object;
1349 if (d_info[dungeon_type].final_artifact)
1351 int a_idx = d_info[dungeon_type].final_artifact;
1352 if (a_info[a_idx].cur_num == 0)
1354 /* Create the artifact */
1355 create_named_art(a_idx, y, x);
1357 a_info[a_idx].cur_num = 1;
1364 /* Get local object */
1367 /* Prepare to make a reward */
1368 object_prep(q_ptr, k_idx);
1370 apply_magic(q_ptr, object_level, FALSE, TRUE, FALSE, FALSE);
1372 /* Drop it in the dungeon */
1373 (void)drop_near(q_ptr, -1, y, x);
1376 msg_format("¤¢¤Ê¤¿¤Ï%s¤òÀ©ÇƤ·¤¿¡ª",d_name+d_info[dungeon_type].name);
1378 msg_format("You have conquered %s!",d_name+d_info[dungeon_type].name);
1382 /* Determine how much we can drop */
1383 if ((r_ptr->flags1 & RF1_DROP_60) && (randint0(100) < 60)) number++;
1384 if ((r_ptr->flags1 & RF1_DROP_90) && (randint0(100) < 90)) number++;
1385 if (r_ptr->flags1 & RF1_DROP_1D2) number += damroll(1, 2);
1386 if (r_ptr->flags1 & RF1_DROP_2D2) number += damroll(2, 2);
1387 if (r_ptr->flags1 & RF1_DROP_3D2) number += damroll(3, 2);
1388 if (r_ptr->flags1 & RF1_DROP_4D2) number += damroll(4, 2);
1390 if (cloned && !(r_ptr->flags1 & RF1_UNIQUE))
1391 number = 0; /* Clones drop no stuff unless Cloning Pits */
1393 if (is_pet(m_ptr) || p_ptr->inside_battle || p_ptr->inside_arena)
1394 number = 0; /* Pets drop no stuff */
1395 if (!drop_item && (r_ptr->d_char != '$')) number = 0;
1397 /* Hack -- handle creeping coins */
1398 coin_type = force_coin;
1400 /* Average dungeon and monster levels */
1401 object_level = (dun_level + r_ptr->level) / 2;
1403 /* Drop some objects */
1404 for (j = 0; j < number; j++)
1406 /* Get local object */
1409 /* Wipe the object */
1413 if (do_gold && (!do_item || (randint0(100) < 50)))
1415 /* Make some gold */
1416 if (!make_gold(q_ptr)) continue;
1425 /* Make an object */
1426 if (!make_object(q_ptr, good, great)) continue;
1432 /* Drop it in the dungeon */
1433 (void)drop_near(q_ptr, -1, y, x);
1436 /* Reset the object level */
1437 object_level = base_level;
1439 /* Reset "coin" type */
1443 /* Take note of any dropped treasure */
1444 if (visible && (dump_item || dump_gold))
1446 /* Take notes on treasure */
1447 lore_treasure(m_idx, dump_item, dump_gold);
1450 /* Only process "Quest Monsters" */
1451 if (!(r_ptr->flags1 & RF1_QUESTOR)) return;
1452 if (p_ptr->inside_battle) return;
1455 if (m_ptr->r_idx == MON_SERPENT)
1458 p_ptr->total_winner = TRUE;
1460 /* Redraw the "title" */
1461 p_ptr->redraw |= (PR_TITLE);
1464 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, "¸«»ö¤ËÊѶòÈÚÅܤξ¡Íø¼Ô¤È¤Ê¤Ã¤¿¡ª");
1466 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, "become *WINNER* of Hengband finely!");
1469 if (p_ptr->pclass == CLASS_CHAOS_WARRIOR)
1472 msg_format("%s¤«¤é¤ÎÀ¼¤¬¶Á¤¤¤¿¡£", chaos_patrons[p_ptr->chaos_patron]);
1473 msg_print("¡Ø¤è¤¯¤ä¤Ã¤¿¡¢ÄêÌ¿¤Î¼Ô¤è¡ª¡Ù");
1475 msg_format("The voice of %s booms out:", chaos_patrons[p_ptr->chaos_patron]);
1476 msg_print("'Thou art donst well, mortal!'");
1480 /* Congratulations */
1482 msg_print("*** ¤ª¤á¤Ç¤È¤¦ ***");
1484 msg_print("*** CONGRATULATIONS ***");
1488 msg_print("¤¢¤Ê¤¿¤Ï¥²¡¼¥à¤ò¥³¥ó¥×¥ê¡¼¥È¤·¤Þ¤·¤¿¡£");
1490 msg_print("You have won the game!");
1494 msg_print("½àÈ÷¤¬À°¤Ã¤¿¤é°úÂà(¼«»¦¥³¥Þ¥ó¥É)¤·¤Æ¤â·ë¹½¤Ç¤¹¡£");
1496 msg_print("You may retire (commit suicide) when you are ready.");
1503 * Modify the physical damage done to the monster.
1504 * (for example when it's invulnerable or shielded)
1506 * ToDo: Accept a damage-type to calculate the modified damage from
1507 * things like fire, frost, lightning, poison, ... attacks.
1509 * "type" is not yet used and should be 0.
1511 int mon_damage_mod(monster_type *m_ptr, int dam, bool is_psy_spear)
1513 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1515 if ((r_ptr->flags3 & RF3_RES_ALL) && dam > 0)
1518 if((dam == 0) && one_in_(3)) dam = 1;
1521 if (m_ptr->invulner)
1525 if(!p_ptr->blind && m_ptr->ml)
1528 msg_print("¥Ð¥ê¥¢¤òÀÚ¤êÎö¤¤¤¿¡ª");
1530 msg_print("The barrier is penetrated!");
1534 else if (!one_in_(PENETRATE_INVULNERABILITY))
1542 static void get_exp_from_mon(int dam, monster_type *m_ptr)
1544 s32b div, new_exp, new_exp_frac;
1545 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1546 int monnum_penarty = 0;
1548 if (!m_ptr->r_idx) return;
1549 if (is_pet(m_ptr) || p_ptr->inside_battle) return;
1553 u32b m_exp_h, m_exp_l;
1555 if ((r_ptr->flags2 & RF2_MULTIPLY) || (m_ptr->r_idx == MON_DAWN))
1557 monnum_penarty = r_ptr->r_pkills / 400;
1558 if (monnum_penarty > 8) monnum_penarty = 8;
1560 if (r_ptr->flags1 & RF1_UNIQUE)
1562 m_exp = (long)r_ptr->mexp * r_ptr->level;
1563 div = (p_ptr->max_plv+2);
1567 m_exp = (long)r_ptr->mexp * r_ptr->level * extract_energy[m_ptr->mspeed];
1568 div = (p_ptr->max_plv+2) * extract_energy[r_ptr->speed];
1570 m_exp_h = m_exp/0x10000L;
1571 m_exp_l = m_exp%0x10000L;
1574 m_exp_h += m_exp_l / 0x10000L;
1575 m_exp_l %= 0x10000L;
1577 /* real monster maxhp have effect on EXP */
1578 if(!(r_ptr->flags1 & RF1_FORCE_MAXHP))
1580 u32b maxhp = m_ptr->max_maxhp*2;
1583 m_exp_h += m_exp_l / 0x10000L;
1584 m_exp_l %= 0x10000L;
1586 div *= r_ptr->hdice * (r_ptr->hside + 1);
1588 if (!dun_level && (!(r_ptr->flags8 & RF8_WILD_ONLY) || !(r_ptr->flags1 & RF1_UNIQUE))) div *= 5;
1589 div_h = div/0x10000L;
1590 div_l = div%0x10000L;
1591 div_h *= (m_ptr->max_maxhp*2);
1592 div_l *= (m_ptr->max_maxhp*2);
1593 div_h += div_l / 0x10000L;
1596 while (monnum_penarty)
1600 div_h += div_l / 0x10000L;
1605 m_exp_l = (0x7fffffff & (m_exp_h << 16)) | m_exp_l;
1606 m_exp_h = m_exp_h >> 15;
1607 div_l = (0x7fffffff & (div_h << 16)) | div_l;
1608 div_h = div_h >> 15;
1610 #define M_INT_GREATER63(h1,l1,h2,l2) ( (h1>h2)||( (h1==h2)&&(l1>=l2)))
1611 #define M_INT_SUB63(h1,l1, h2,l2) {h1-=h2;if(l1<l2){l1+=0x80000000;h1--;}l1-=l2;}
1612 #define M_INT_LSHIFT63(h1,l1) {h1=(h1<<1)|(l1>>30);l1=(l1<<1)&0x7fffffff;}
1613 #define M_INT_RSHIFT63(h1,l1) {l1=(l1>>1)|(h1<<30);h1>>=1;}
1614 #define M_INT_DIV63(h1,l1,h2,l2,result) \
1618 while( M_INT_GREATER63(h1,l1, h2, l2) ){M_INT_LSHIFT63(h2, l2); bit<<=1;} \
1619 for(bit>>=1; bit>=1; bit>>=1){ \
1620 M_INT_RSHIFT63(h2, l2); \
1621 if(M_INT_GREATER63(h1, l1, h2, l2)) \
1622 {result|=bit;M_INT_SUB63(h1, l1, h2, l2);} \
1626 /* Give some experience for the kill */
1627 M_INT_DIV63(m_exp_h, m_exp_l, div_h, div_l, new_exp);
1629 /* Handle fractional experience */
1630 /* multiply 0x10000L to remainder */
1631 m_exp_h = (m_exp_h<<16) | (m_exp_l>>15);
1633 M_INT_DIV63(m_exp_h, m_exp_l, div_h, div_l, new_exp_frac);
1634 new_exp_frac += p_ptr->exp_frac;
1635 /* Keep track of experience */
1636 if (new_exp_frac >= 0x10000L)
1639 p_ptr->exp_frac = (u16b)(new_exp_frac - 0x10000L);
1643 p_ptr->exp_frac = (u16b)new_exp_frac;
1646 /* Gain experience */
1654 * Decreases monsters hit points, handling monster death.
1656 * We return TRUE if the monster has been killed (and deleted).
1658 * We announce monster death (using an optional "death message"
1659 * if given, and a otherwise a generic killed/destroyed message).
1661 * Only "physical attacks" can induce the "You have slain" message.
1662 * Missile and Spell attacks will induce the "dies" message, or
1663 * various "specialized" messages. Note that "You have destroyed"
1664 * and "is destroyed" are synonyms for "You have slain" and "dies".
1666 * Hack -- unseen monsters yield "You have killed it." message.
1668 * Added fear (DGK) and check whether to print fear messages -CWS
1670 * Made name, sex, and capitalization generic -BEN-
1672 * As always, the "ghost" processing is a total hack.
1674 * Hack -- we "delay" fear messages by passing around a "fear" flag.
1676 * XXX XXX XXX Consider decreasing monster experience over time, say,
1677 * by using "(m_exp * m_lev * (m_lev)) / (p_lev * (m_lev + n_killed))"
1678 * instead of simply "(m_exp * m_lev) / (p_lev)", to make the first
1679 * monster worth more than subsequent monsters. This would also need
1680 * to induce changes in the monster recall code.
1682 bool mon_take_hit(int m_idx, int dam, bool *fear, cptr note)
1684 monster_type *m_ptr = &m_list[m_idx];
1685 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1687 monster_type exp_mon;
1689 /* Innocent until proven otherwise */
1690 bool innocent = TRUE, thief = FALSE;
1694 COPY(&exp_mon, m_ptr, monster_type);
1695 if (!(r_ptr->flags7 & RF7_KILL_EXP))
1697 expdam = (m_ptr->hp > dam) ? dam : m_ptr->hp;
1698 if (r_ptr->flags6 & RF6_HEAL) expdam = (expdam+1) * 2 / 3;
1700 get_exp_from_mon(expdam, &exp_mon);
1703 /* Redraw (later) if needed */
1704 if (p_ptr->health_who == m_idx) p_ptr->redraw |= (PR_HEALTH);
1705 if (p_ptr->riding == m_idx) p_ptr->redraw |= (PR_UHEALTH);
1710 /* Hack - Cancel any special player stealth magics. -LM- */
1711 if (p_ptr->special_defense & NINJA_S_STEALTH)
1713 set_superstealth(FALSE);
1719 /* It is dead now */
1724 if (r_info[m_ptr->r_idx].flags7 & RF7_TANUKI)
1726 /* You might have unmasked Tanuki first time */
1727 r_ptr = &r_info[m_ptr->r_idx];
1728 m_ptr->ap_r_idx = m_ptr->r_idx;
1729 if (r_ptr->r_sights < MAX_SHORT) r_ptr->r_sights++;
1732 if (m_ptr->mflag2 & MFLAG_CHAMELEON)
1734 /* You might have unmasked Chameleon first time */
1735 if (r_ptr->flags1 & RF1_UNIQUE)
1736 r_ptr = &r_info[MON_CHAMELEON_K];
1738 r_ptr = &r_info[MON_CHAMELEON];
1739 if (r_ptr->r_sights < MAX_SHORT) r_ptr->r_sights++;
1742 /* When the player kills a Unique, it stays dead */
1743 if (r_ptr->flags1 & RF1_UNIQUE && !(m_ptr->smart & SM_CLONED))
1746 /* When the player kills a Nazgul, it stays dead */
1747 if (r_ptr->flags7 & RF7_UNIQUE_7) r_ptr->max_num--;
1749 /* Recall even invisible uniques or winners */
1750 if (m_ptr->ml || (r_ptr->flags1 & RF1_UNIQUE))
1752 /* Count kills this life */
1753 if ((m_ptr->mflag2 & MFLAG_KAGE) && (r_info[MON_KAGE].r_pkills < MAX_SHORT)) r_info[MON_KAGE].r_pkills++;
1754 else if (r_ptr->r_pkills < MAX_SHORT) r_ptr->r_pkills++;
1756 /* Count kills in all lives */
1757 if ((m_ptr->mflag2 & MFLAG_KAGE) && (r_info[MON_KAGE].r_tkills < MAX_SHORT)) r_info[MON_KAGE].r_tkills++;
1758 else if (r_ptr->r_tkills < MAX_SHORT) r_ptr->r_tkills++;
1760 /* Hack -- Auto-recall */
1761 monster_race_track(m_ptr->ap_r_idx);
1764 /* Extract monster name */
1765 monster_desc(m_name, m_ptr, 0x100);
1767 /* Don't kill Amberites */
1768 if ((r_ptr->flags3 & RF3_AMBERITE) && one_in_(2))
1770 int curses = 1 + randint1(3);
1771 bool stop_ty = FALSE;
1775 msg_format("%^s¤Ï¶²¤í¤·¤¤·ì¤Î¼ö¤¤¤ò¤¢¤Ê¤¿¤Ë¤«¤±¤¿¡ª", m_name);
1777 msg_format("%^s puts a terrible blood curse on you!", m_name);
1780 curse_equipment(100, 50);
1784 stop_ty = activate_ty_curse(stop_ty, &count);
1789 if (r_ptr->flags2 & RF2_CAN_SPEAK)
1791 char line_got[1024];
1793 /* Dump a message */
1795 if (!get_rnd_line("mondeath_j.txt", m_ptr->r_idx, line_got))
1797 if (!get_rnd_line("mondeath.txt", m_ptr->r_idx, line_got))
1800 msg_format("%^s %s", m_name, line_got);
1803 if (m_ptr->r_idx == MON_SERPENT)
1805 /* Make screen dump */
1806 screen_dump = make_screen_dump();
1811 if (!(d_info[dungeon_type].flags1 & DF1_BEGINNER))
1813 if (!dun_level && !ambush_flag && !p_ptr->inside_arena)
1815 chg_virtue(V_VALOUR, -1);
1817 else if (r_ptr->level > dun_level)
1819 if (randint1(10) <= (r_ptr->level - dun_level))
1820 chg_virtue(V_VALOUR, 1);
1822 if (r_ptr->level > 60)
1824 chg_virtue(V_VALOUR, 1);
1826 if (r_ptr->level >= 2 * (p_ptr->lev+1))
1827 chg_virtue(V_VALOUR, 2);
1830 if ((r_ptr->flags1 & RF1_UNIQUE) && ((r_ptr->flags3 & RF3_EVIL) ||
1831 (r_ptr->flags3 & RF3_GOOD)))
1833 chg_virtue(V_HARMONY, 2);
1835 if ((r_ptr->flags1 & RF1_UNIQUE) && (r_ptr->flags3 & RF3_GOOD))
1837 chg_virtue(V_UNLIFE, 2);
1838 chg_virtue(V_VITALITY, -2);
1841 if ((r_ptr->flags1 & RF1_UNIQUE) && one_in_(3))
1842 chg_virtue(V_INDIVIDUALISM, -1);
1844 if (m_ptr->r_idx == MON_BEGGAR || m_ptr->r_idx == MON_LEPER)
1846 chg_virtue(V_COMPASSION, -1);
1849 if ((r_ptr->flags3 & RF3_GOOD) &&
1850 ((r_ptr->level) / 10 + (3 * dun_level) >= randint1(100)))
1852 chg_virtue(V_UNLIFE, 1);
1854 if (r_ptr->d_char == 'A')
1856 if (r_ptr->flags1 & RF1_UNIQUE)
1857 chg_virtue(V_FAITH, -2);
1858 else if ((r_ptr->level) / 10 + (3 * dun_level) >= randint1(100))
1860 if (r_ptr->flags3 & RF3_GOOD) chg_virtue(V_FAITH, -1);
1861 else chg_virtue(V_FAITH, 1);
1864 else if (r_ptr->flags3 & RF3_DEMON)
1866 if (r_ptr->flags1 & RF1_UNIQUE)
1867 chg_virtue(V_FAITH, 2);
1868 else if ((r_ptr->level) / 10 + (3 * dun_level) >= randint1(100))
1869 chg_virtue(V_FAITH, 1);
1872 if ((r_ptr->flags3 & RF3_UNDEAD) && (r_ptr->flags1 & RF1_UNIQUE))
1873 chg_virtue(V_VITALITY, 2);
1875 if (r_ptr->r_deaths)
1877 if (r_ptr->flags1 & RF1_UNIQUE)
1879 chg_virtue(V_HONOUR, 10);
1881 else if ((r_ptr->level) / 10 + (2 * dun_level) >= randint1(100))
1883 chg_virtue(V_HONOUR, 1);
1886 if ((r_ptr->flags2 & RF2_MULTIPLY) && (r_ptr->r_pkills > 1000) && one_in_(10))
1888 chg_virtue(V_VALOUR, -1);
1891 for (i = 0; i < 4; i++)
1893 if(r_ptr->blow[i].d_dice != 0) innocent = FALSE; /* Murderer! */
1895 if ((r_ptr->blow[i].effect == RBE_EAT_ITEM)
1896 || (r_ptr->blow[i].effect == RBE_EAT_GOLD))
1898 thief = TRUE; /* Thief! */
1901 /* The new law says it is illegal to live in the dungeon */
1902 if (r_ptr->level != 0) innocent = FALSE;
1906 if (r_ptr->flags1 & RF1_UNIQUE)
1907 chg_virtue(V_JUSTICE, 3);
1908 else if (1+((r_ptr->level) / 10 + (2 * dun_level))
1911 chg_virtue(V_JUSTICE, 1);
1915 chg_virtue (V_JUSTICE, -1);
1918 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)))
1920 if (one_in_(4)) chg_virtue(V_NATURE, -1);
1923 if((r_ptr->flags1 & RF1_UNIQUE) && record_destroy_uniq)
1924 do_cmd_write_nikki(NIKKI_UNIQUE, 0, r_name + r_ptr->name);
1929 /* Death by Missile/Spell attack */
1932 msg_format("%^s%s", m_name, note);
1935 /* Death by physical attack -- invisible monster */
1936 else if (!m_ptr->ml)
1939 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
1940 msg_format("¤»¤Ã¤«¤¯¤À¤«¤é%s¤ò»¦¤·¤¿¡£", m_name);
1942 msg_format("%s¤ò»¦¤·¤¿¡£", m_name);
1944 msg_format("You have killed %s.", m_name);
1949 /* Death by Physical attack -- non-living monster */
1950 else if (!monster_living(r_ptr))
1953 bool explode = FALSE;
1955 for (i = 0; i < 4; i++)
1957 if (r_ptr->blow[i].method == RBM_EXPLODE) explode = TRUE;
1960 /* Special note at death */
1963 msg_format("%s¤ÏÇúȯ¤·¤ÆÊ´¡¹¤Ë¤Ê¤Ã¤¿¡£", m_name);
1965 msg_format("%s explodes into tiny shreds.", m_name);
1970 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
1971 msg_format("¤»¤Ã¤«¤¯¤À¤«¤é%s¤òÅݤ·¤¿¡£", m_name);
1973 msg_format("%s¤òÅݤ·¤¿¡£", m_name);
1975 msg_format("You have destroyed %s.", m_name);
1980 /* Death by Physical attack -- living monster */
1984 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
1985 msg_format("¤»¤Ã¤«¤¯¤À¤«¤é%s¤òÁò¤êµî¤Ã¤¿¡£", m_name);
1987 msg_format("%s¤òÁò¤êµî¤Ã¤¿¡£", m_name);
1989 msg_format("You have slain %s.", m_name);
1993 if (r_ptr->flags1 & RF1_UNIQUE && !(m_ptr->smart & SM_CLONED))
1995 for (i = 0; i < MAX_KUBI; i++)
1997 if ((kubi_r_idx[i] == m_ptr->r_idx) && !(m_ptr->mflag2 & MFLAG_CHAMELEON))
2000 msg_format("%s¤Î¼ó¤Ë¤Ï¾Þ¶â¤¬¤«¤«¤Ã¤Æ¤¤¤ë¡£", m_name);
2002 msg_format("There is a price on %s's head.", m_name);
2009 if (r_ptr->flags7 & RF7_KILL_EXP)
2010 get_exp_from_mon((long)m_ptr->max_maxhp*2, &exp_mon);
2012 get_exp_from_mon(((long)m_ptr->max_maxhp+1L) * 9L / 10L, &exp_mon);
2014 /* Generate treasure */
2015 monster_death(m_idx, TRUE);
2016 if ((m_ptr->r_idx == MON_BANOR) || (m_ptr->r_idx == MON_LUPART))
2018 r_info[MON_BANORLUPART].max_num = 0;
2019 r_info[MON_BANORLUPART].r_pkills++;
2020 if (r_info[MON_BANORLUPART].r_tkills < MAX_SHORT) r_info[MON_BANORLUPART].r_tkills++;
2023 if (m_ptr->r_idx == MON_BANORLUPART)
2025 r_info[MON_BANOR].max_num = 0;
2026 r_info[MON_BANOR].r_pkills++;
2027 if (r_info[MON_BANOR].r_tkills < MAX_SHORT) r_info[MON_BANOR].r_tkills++;
2028 r_info[MON_LUPART].max_num = 0;
2029 r_info[MON_LUPART].r_pkills++;
2030 if (r_info[MON_LUPART].r_tkills < MAX_SHORT) r_info[MON_LUPART].r_tkills++;
2033 /* Mega hack : replace IKETA to BIKETAL */
2034 if ((m_ptr->r_idx == MON_IKETA) &&
2035 !(p_ptr->inside_arena || p_ptr->inside_battle))
2037 int dummy_y = m_ptr->fy;
2038 int dummy_x = m_ptr->fx;
2041 if (is_pet(m_ptr)) mode |= PM_FORCE_PET;
2043 /* Delete the monster */
2044 delete_monster_idx(m_idx);
2046 if (summon_named_creature(0, dummy_y, dummy_x, MON_BIKETAL, mode))
2049 msg_print("¡Ö¥Ï¥¡¥Ã¥Ï¥Ã¥Ï¥Ã¥Ï¡ª¡ª»ä¤¬¥Ð¥¤¥±¥¿¥ë¤À¡ª¡ª¡×");
2051 msg_print("Uwa-hahaha! *I* am Biketal!");
2057 /* Delete the monster */
2058 delete_monster_idx(m_idx);
2064 /* Monster is dead */
2071 /* Mega-Hack -- Pain cancels fear */
2072 if (m_ptr->monfear && (dam > 0))
2074 int tmp = randint1(dam);
2076 /* Cure a little fear */
2077 if (tmp < m_ptr->monfear)
2080 m_ptr->monfear -= tmp;
2083 /* Cure all the fear */
2094 /* Sometimes a monster gets scared by damage */
2095 if (!m_ptr->monfear && !(r_ptr->flags3 & (RF3_NO_FEAR)))
2099 /* Percentage of fully healthy */
2100 percentage = (100L * m_ptr->hp) / m_ptr->maxhp;
2103 * Run (sometimes) if at 10% or less of max hit points,
2104 * or (usually) when hit for half its current hit points
2106 if ((randint1(10) >= percentage) ||
2107 ((dam >= m_ptr->hp) && (randint0(100) < 80)))
2109 /* Hack -- note fear */
2112 /* XXX XXX XXX Hack -- Add some timed fear */
2113 m_ptr->monfear = (randint1(10) +
2114 (((dam >= m_ptr->hp) && (percentage > 7)) ?
2115 20 : ((11 - percentage) * 5)));
2122 if (p_ptr->riding && (p_ptr->riding == m_idx) && (dam > 0))
2126 /* Extract monster name */
2127 monster_desc(m_name, m_ptr, 0);
2129 if (m_ptr->hp > m_ptr->maxhp/3) dam = (dam + 1) / 2;
2130 if (rakuba((dam > 200) ? 200 : dam, FALSE))
2133 msg_format("%^s¤Ë¿¶¤êÍî¤È¤µ¤ì¤¿¡ª", m_name);
2135 msg_format("%^s has thrown you off!", m_name);
2147 * Get term size and calculate screen size
2149 void get_screen_size(int *wid_p, int *hgt_p)
2151 Term_get_size(wid_p, hgt_p);
2152 *hgt_p -= ROW_MAP + 2;
2153 *wid_p -= COL_MAP + 2;
2154 if (use_bigtile) *wid_p /= 2;
2159 * Calculates current boundaries
2160 * Called below and from "do_cmd_locate()".
2162 void panel_bounds_center(void)
2167 get_screen_size(&wid, &hgt);
2169 panel_row_max = panel_row_min + hgt - 1;
2170 panel_row_prt = panel_row_min - 1;
2171 panel_col_max = panel_col_min + wid - 1;
2172 panel_col_prt = panel_col_min - 13;
2177 * Map resizing whenever the main term changes size
2179 void resize_map(void)
2181 /* Only if the dungeon exists */
2182 if (!character_dungeon) return;
2184 /* Mega-Hack -- no panel yet */
2188 /* Reset the panels */
2189 panel_row_min = cur_hgt;
2190 panel_col_min = cur_wid;
2195 p_ptr->update |= (PU_TORCH | PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
2197 /* Forget lite/view */
2198 p_ptr->update |= (PU_UN_VIEW | PU_UN_LITE);
2200 /* Update lite/view */
2201 p_ptr->update |= (PU_VIEW | PU_LITE | PU_MON_LITE);
2203 /* Update monsters */
2204 p_ptr->update |= (PU_MONSTERS);
2206 /* Redraw everything */
2207 p_ptr->redraw |= (PR_WIPE | PR_BASIC | PR_EXTRA | PR_MAP | PR_EQUIPPY);
2209 /* Hack -- update */
2217 * Place the cursor on the player
2219 if (can_save) move_cursor_relative(py, px);
2226 * Redraw a term when it is resized
2228 void redraw_window(void)
2230 /* Only if the dungeon exists */
2231 if (!character_dungeon) return;
2233 /* Hack - Activate term zero for the redraw */
2234 Term_activate(&term_screen[0]);
2236 /* Hack -- react to changes */
2237 Term_xtra(TERM_XTRA_REACT, 0);
2240 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_SPELL | PW_PLAYER);
2243 p_ptr->window |= (PW_MESSAGE | PW_OVERHEAD | PW_DUNGEON | PW_MONSTER | PW_OBJECT);
2245 /* Hack -- update */
2257 * Handle a request to change the current panel
2259 * Return TRUE if the panel was changed.
2261 * Also used in do_cmd_locate
2263 bool change_panel(int dy, int dx)
2269 get_screen_size(&wid, &hgt);
2271 /* Apply the motion */
2272 y = panel_row_min + dy * hgt / 2;
2273 x = panel_col_min + dx * wid / 2;
2275 /* Verify the row */
2276 if (y > cur_hgt - hgt) y = cur_hgt - hgt;
2279 /* Verify the col */
2280 if (x > cur_wid - wid) x = cur_wid - wid;
2283 /* Handle "changes" */
2284 if ((y != panel_row_min) || (x != panel_col_min))
2286 /* Save the new panel info */
2290 /* Recalculate the boundaries */
2291 panel_bounds_center();
2294 p_ptr->update |= (PU_MONSTERS);
2297 p_ptr->redraw |= (PR_MAP);
2312 * Given an row (y) and col (x), this routine detects when a move
2313 * off the screen has occurred and figures new borders. -RAK-
2315 * "Update" forces a "full update" to take place.
2317 * The map is reprinted if necessary, and "TRUE" is returned.
2319 void verify_panel(void)
2331 get_screen_size(&wid, &hgt);
2333 max_prow_min = cur_hgt - hgt;
2334 max_pcol_min = cur_wid - wid;
2336 /* Bounds checking */
2337 if (max_prow_min < 0) max_prow_min = 0;
2338 if (max_pcol_min < 0) max_pcol_min = 0;
2340 /* Center on player */
2341 if (center_player && (center_running || !running))
2343 /* Center vertically */
2344 prow_min = y - hgt / 2;
2345 if (prow_min < 0) prow_min = 0;
2346 else if (prow_min > max_prow_min) prow_min = max_prow_min;
2348 /* Center horizontally */
2349 pcol_min = x - wid / 2;
2350 if (pcol_min < 0) pcol_min = 0;
2351 else if (pcol_min > max_pcol_min) pcol_min = max_pcol_min;
2355 prow_min = panel_row_min;
2356 pcol_min = panel_col_min;
2358 /* Scroll screen when 2 grids from top/bottom edge */
2359 if (y > panel_row_max - 2)
2361 while (y > prow_min + hgt-1 - 2)
2363 prow_min += (hgt / 2);
2367 if (y < panel_row_min + 2)
2369 while (y < prow_min + 2)
2371 prow_min -= (hgt / 2);
2375 if (prow_min > max_prow_min) prow_min = max_prow_min;
2376 if (prow_min < 0) prow_min = 0;
2378 /* Scroll screen when 4 grids from left/right edge */
2379 if (x > panel_col_max - 4)
2381 while (x > pcol_min + wid-1 - 4)
2383 pcol_min += (wid / 2);
2387 if (x < panel_col_min + 4)
2389 while (x < pcol_min + 4)
2391 pcol_min -= (wid / 2);
2395 if (pcol_min > max_pcol_min) pcol_min = max_pcol_min;
2396 if (pcol_min < 0) pcol_min = 0;
2399 /* Check for "no change" */
2400 if ((prow_min == panel_row_min) && (pcol_min == panel_col_min)) return;
2402 /* Save the new panel info */
2403 panel_row_min = prow_min;
2404 panel_col_min = pcol_min;
2406 /* Hack -- optional disturb on "panel change" */
2407 if (disturb_panel && !center_player) disturb(0, 0);
2409 /* Recalculate the boundaries */
2410 panel_bounds_center();
2413 p_ptr->update |= (PU_MONSTERS);
2416 p_ptr->redraw |= (PR_MAP);
2419 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
2424 * Monster health description
2426 cptr look_mon_desc(int m_idx, u32b mode)
2428 monster_type *m_ptr = &m_list[m_idx];
2429 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
2436 /* Determine if the monster is "living" */
2437 living = monster_living(ap_r_ptr);
2439 /* Calculate a health "percentage" */
2440 perc = 100L * m_ptr->hp / m_ptr->maxhp;
2442 /* Healthy monsters */
2443 if (m_ptr->hp >= m_ptr->maxhp)
2447 desc = living ? "̵½ý" : "̵¥À¥á¡¼¥¸";
2449 desc = living ? "unhurt" : "undamaged";
2454 else if (perc >= 60)
2457 desc = living ? "·Ú½ý" : "¾®¥À¥á¡¼¥¸";
2459 desc = living ? "somewhat wounded" : "somewhat damaged";
2464 else if (perc >= 25)
2467 desc = living ? "Éé½ý" : "Ãæ¥À¥á¡¼¥¸";
2469 desc = living ? "wounded" : "damaged";
2474 else if (perc >= 10)
2477 desc = living ? "½Å½ý" : "Âç¥À¥á¡¼¥¸";
2479 desc = living ? "badly wounded" : "badly damaged";
2487 desc = living ? "Ⱦ»àȾÀ¸" : "Åݤ줫¤±";
2489 desc = living ? "almost dead" : "almost destroyed";
2494 /* Need attitude information? */
2497 /* Full information is not needed */
2500 else if (is_pet(m_ptr))
2503 attitude = ", ¥Ú¥Ã¥È";
2508 else if (is_friendly(m_ptr))
2511 attitude = ", ͧ¹¥Åª";
2513 attitude = ", friendly";
2526 /* Clone monster? */
2527 if (m_ptr->smart & SM_CLONED)
2536 /* Display monster's level --- idea borrowed from ToME */
2537 if (ap_r_ptr->r_tkills && !(m_ptr->mflag2 & MFLAG_KAGE))
2540 return format("¥ì¥Ù¥ë%d, %s%s%s", ap_r_ptr->level, desc, attitude, clone);
2542 return format("Level %d, %s%s%s", ap_r_ptr->level, desc, attitude, clone);
2548 return format("¥ì¥Ù¥ë???, %s%s%s", desc, attitude, clone);
2550 return format("Level ???, %s%s%s", desc, attitude, clone);
2558 * Angband sorting algorithm -- quick sort in place
2560 * Note that the details of the data we are sorting is hidden,
2561 * and we rely on the "ang_sort_comp()" and "ang_sort_swap()"
2562 * function hooks to interact with the data, which is given as
2563 * two pointers, and which may have any user-defined form.
2565 void ang_sort_aux(vptr u, vptr v, int p, int q)
2583 while (!(*ang_sort_comp)(u, v, b, z)) b--;
2586 while (!(*ang_sort_comp)(u, v, z, a)) a++;
2588 /* Done partition */
2592 (*ang_sort_swap)(u, v, a, b);
2598 /* Recurse left side */
2599 ang_sort_aux(u, v, p, b);
2601 /* Recurse right side */
2602 ang_sort_aux(u, v, b+1, q);
2607 * Angband sorting algorithm -- quick sort in place
2609 * Note that the details of the data we are sorting is hidden,
2610 * and we rely on the "ang_sort_comp()" and "ang_sort_swap()"
2611 * function hooks to interact with the data, which is given as
2612 * two pointers, and which may have any user-defined form.
2614 void ang_sort(vptr u, vptr v, int n)
2616 /* Sort the array */
2617 ang_sort_aux(u, v, 0, n-1);
2622 /*** Targeting Code ***/
2626 * Determine is a monster makes a reasonable target
2628 * The concept of "targeting" was stolen from "Morgul" (?)
2630 * The player can target any location, or any "target-able" monster.
2632 * Currently, a monster is "target_able" if it is visible, and if
2633 * the player can hit it with a projection, and the player is not
2634 * hallucinating. This allows use of "use closest target" macros.
2636 * Future versions may restrict the ability to target "trappers"
2637 * and "mimics", but the semantics is a little bit weird.
2639 bool target_able(int m_idx)
2641 monster_type *m_ptr = &m_list[m_idx];
2643 /* Monster must be alive */
2644 if (!m_ptr->r_idx) return (FALSE);
2646 /* Hack -- no targeting hallucinations */
2647 if (p_ptr->image) return (FALSE);
2649 /* Monster must be visible */
2650 if (!m_ptr->ml) return (FALSE);
2652 if (p_ptr->riding && (p_ptr->riding == m_idx)) return (TRUE);
2654 /* Monster must be projectable */
2655 if (!projectable(py, px, m_ptr->fy, m_ptr->fx)) return (FALSE);
2657 /* XXX XXX XXX Hack -- Never target trappers */
2658 /* if (CLEAR_ATTR && (CLEAR_CHAR)) return (FALSE); */
2668 * Update (if necessary) and verify (if possible) the target.
2670 * We return TRUE if the target is "okay" and FALSE otherwise.
2672 bool target_okay(void)
2674 /* Accept stationary targets */
2675 if (target_who < 0) return (TRUE);
2677 /* Check moving targets */
2680 /* Accept reasonable targets */
2681 if (target_able(target_who))
2683 monster_type *m_ptr = &m_list[target_who];
2685 /* Acquire monster location */
2686 target_row = m_ptr->fy;
2687 target_col = m_ptr->fx;
2694 /* Assume no target */
2701 * Sorting hook -- comp function -- by "distance to player"
2703 * We use "u" and "v" to point to arrays of "x" and "y" positions,
2704 * and sort the arrays by double-distance to the player.
2706 static bool ang_sort_comp_distance(vptr u, vptr v, int a, int b)
2708 byte *x = (byte*)(u);
2709 byte *y = (byte*)(v);
2713 /* Absolute distance components */
2714 kx = x[a]; kx -= px; kx = ABS(kx);
2715 ky = y[a]; ky -= py; ky = ABS(ky);
2717 /* Approximate Double Distance to the first point */
2718 da = ((kx > ky) ? (kx + kx + ky) : (ky + ky + kx));
2720 /* Absolute distance components */
2721 kx = x[b]; kx -= px; kx = ABS(kx);
2722 ky = y[b]; ky -= py; ky = ABS(ky);
2724 /* Approximate Double Distance to the first point */
2725 db = ((kx > ky) ? (kx + kx + ky) : (ky + ky + kx));
2727 /* Compare the distances */
2733 * Sorting hook -- swap function -- by "distance to player"
2735 * We use "u" and "v" to point to arrays of "x" and "y" positions,
2736 * and sort the arrays by distance to the player.
2738 static void ang_sort_swap_distance(vptr u, vptr v, int a, int b)
2740 byte *x = (byte*)(u);
2741 byte *y = (byte*)(v);
2759 * Hack -- help "select" a location (see below)
2761 static s16b target_pick(int y1, int x1, int dy, int dx)
2765 int x2, y2, x3, y3, x4, y4;
2767 int b_i = -1, b_v = 9999;
2770 /* Scan the locations */
2771 for (i = 0; i < temp_n; i++)
2777 /* Directed distance */
2781 /* Verify quadrant */
2782 if (dx && (x3 * dx <= 0)) continue;
2783 if (dy && (y3 * dy <= 0)) continue;
2785 /* Absolute distance */
2789 /* Verify quadrant */
2790 if (dy && !dx && (x4 > y4)) continue;
2791 if (dx && !dy && (y4 > x4)) continue;
2793 /* Approximate Double Distance */
2794 v = ((x4 > y4) ? (x4 + x4 + y4) : (y4 + y4 + x4));
2796 /* XXX XXX XXX Penalize location */
2799 if ((b_i >= 0) && (v >= b_v)) continue;
2811 * Hack -- determine if a given location is "interesting"
2813 static bool target_set_accept(int y, int x)
2817 s16b this_o_idx, next_o_idx = 0;
2820 if (!(in_bounds(y, x))) return (FALSE);
2822 /* Player grid is always interesting */
2823 if ((y == py) && (x == px)) return (TRUE);
2826 /* Handle hallucination */
2827 if (p_ptr->image) return (FALSE);
2830 /* Examine the grid */
2831 c_ptr = &cave[y][x];
2833 /* Visible monsters */
2836 monster_type *m_ptr = &m_list[c_ptr->m_idx];
2838 /* Visible monsters */
2839 if (m_ptr->ml) return (TRUE);
2842 /* Scan all objects in the grid */
2843 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
2847 /* Acquire object */
2848 o_ptr = &o_list[this_o_idx];
2850 /* Acquire next object */
2851 next_o_idx = o_ptr->next_o_idx;
2853 /* Memorized object */
2854 if (o_ptr->marked) return (TRUE);
2857 /* Interesting memorized features */
2858 if (c_ptr->info & (CAVE_MARK))
2862 /* Feature code (applying "mimic" field) */
2863 feat = c_ptr->mimic ? c_ptr->mimic : f_info[c_ptr->feat].mimic;
2866 if (c_ptr->info & CAVE_OBJECT) return (TRUE);
2868 /* Notice the Pattern */
2869 if ((feat <= FEAT_PATTERN_XTRA2) &&
2870 (feat >= FEAT_PATTERN_START))
2874 if (feat == FEAT_OPEN) return (TRUE);
2875 if (feat == FEAT_BROKEN) return (TRUE);
2878 if (feat == FEAT_LESS) return (TRUE);
2879 if (feat == FEAT_MORE) return (TRUE);
2880 if (feat == FEAT_LESS_LESS) return (TRUE);
2881 if (feat == FEAT_MORE_MORE) return (TRUE);
2884 if ((feat >= FEAT_SHOP_HEAD) &&
2885 (feat <= FEAT_SHOP_TAIL)) return (TRUE);
2887 if (feat == FEAT_MUSEUM) return (TRUE);
2889 /* Notice buildings -KMW- */
2890 if ((feat >= FEAT_BLDG_HEAD) &&
2891 (feat <= FEAT_BLDG_TAIL)) return (TRUE);
2894 if (is_trap(feat)) return (TRUE);
2897 if ((feat >= FEAT_DOOR_HEAD) &&
2898 (feat <= FEAT_DOOR_TAIL)) return (TRUE);
2902 /* I think FEAT_RUBBLEs should not be "interesting" */
2903 if (feat == FEAT_RUBBLE) return (TRUE);
2905 /* Notice veins with treasure */
2906 /* Now veins with treasure are too many */
2907 if (feat == FEAT_MAGMA_K) return (TRUE);
2908 if (feat == FEAT_QUARTZ_K) return (TRUE);
2911 /* Notice quest features */
2912 if (feat == FEAT_QUEST_ENTER) return (TRUE);
2913 if (feat == FEAT_QUEST_EXIT) return (TRUE);
2914 if (feat == FEAT_QUEST_DOWN) return (TRUE);
2915 if (feat == FEAT_QUEST_UP) return (TRUE);
2916 if (feat == FEAT_TOWN) return (TRUE);
2917 if (feat == FEAT_ENTRANCE) return (TRUE);
2926 * Prepare the "temp" array for "target_set"
2928 * Return the number of target_able monsters in the set.
2930 static void target_set_prepare(int mode)
2934 /* Reset "temp" array */
2937 /* Scan the current panel */
2938 for (y = panel_row_min; y <= panel_row_max; y++)
2940 for (x = panel_col_min; x <= panel_col_max; x++)
2944 /* Require line of sight, unless "look" is "expanded" */
2945 if (!expand_look && !player_has_los_bold(y, x)) continue;
2947 /* Require "interesting" contents */
2948 if (!target_set_accept(y, x)) continue;
2950 c_ptr = &cave[y][x];
2952 /* Require target_able monsters for "TARGET_KILL" */
2953 if ((mode & (TARGET_KILL)) && !target_able(c_ptr->m_idx)) continue;
2955 if ((mode & (TARGET_KILL)) && !target_pet && is_pet(&m_list[c_ptr->m_idx])) continue;
2957 /* Save the location */
2964 /* Set the sort hooks */
2965 ang_sort_comp = ang_sort_comp_distance;
2966 ang_sort_swap = ang_sort_swap_distance;
2968 /* Sort the positions */
2969 ang_sort(temp_x, temp_y, temp_n);
2971 if (p_ptr->riding && target_pet && (temp_n > 1) && (mode & (TARGET_KILL)))
2976 temp_y[0] = temp_y[1];
2979 temp_x[0] = temp_x[1];
2986 * Evaluate number of kill needed to gain level
2988 static void evaluate_monster_exp(char *buf, monster_type *m_ptr)
2990 #define M_INT_GREATER(h1,l1,h2,l2) ( (h1>h2)||( (h1==h2)&&(l1>=l2)))
2991 #define M_INT_SUB(h1,l1, h2,l2) {h1-=h2;if(l1<l2){l1+=0x10000;h1--;}l1-=l2;}
2992 #define M_INT_ADD(h1,l1, h2,l2) {h1+=h2;l1+=l2;if(l1>=0x10000L){l1&=0xFFFF;h1++;}}
2993 #define M_INT_LSHIFT(h1,l1) {h1=(h1<<1)|(l1>>15);l1=(l1<<1)&0xffff;}
2994 #define M_INT_RSHIFT(h1,l1) {l1=(l1>>1)|((h1&1)<<15);h1>>=1;}
2995 #define M_INT_MULT(h1,l1,mul,h2,l2) {l2=(l1*mul)&0xffff;h2=((l1*mul)>>16)+h1*mul;}
2997 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
3001 u32b exp_mon= (ap_r_ptr->mexp)*(ap_r_ptr->level);
3002 u32b exp_mon_h= exp_mon / (p_ptr->max_plv+2);
3003 u32b exp_mon_l= ((exp_mon % (p_ptr->max_plv+2))*0x10000/(p_ptr->max_plv+2))&0xFFFF;
3005 u32b exp_adv_h = player_exp[p_ptr->lev -1] * p_ptr->expfact /100;
3006 u32b exp_adv_l = ((player_exp[p_ptr->lev -1]%100) * p_ptr->expfact *0x10000/100)&0xFFFF;
3008 M_INT_SUB(exp_adv_h, exp_adv_l, p_ptr->exp, p_ptr->exp_frac);
3009 if ((p_ptr->lev>=PY_MAX_LEVEL) || (p_ptr->prace == RACE_ANDROID))
3011 else if (!ap_r_ptr->r_tkills || (m_ptr->mflag2 & MFLAG_KAGE))
3013 else if (M_INT_GREATER(exp_mon_h, exp_mon_l, exp_adv_h, exp_adv_l))
3017 M_INT_MULT(exp_mon_h, exp_mon_l, 1000,tmp_h, tmp_l);
3018 if( M_INT_GREATER(exp_adv_h, exp_adv_l, tmp_h, tmp_l) )
3023 M_INT_ADD(exp_adv_h, exp_adv_l, exp_mon_h, exp_mon_l);
3024 M_INT_SUB(exp_adv_h, exp_adv_l, 0, 1);
3025 while(M_INT_GREATER(exp_adv_h, exp_adv_l, exp_mon_h,exp_mon_l))
3027 M_INT_LSHIFT(exp_mon_h,exp_mon_l);
3030 M_INT_RSHIFT(exp_mon_h,exp_mon_l);bit>>=1;
3031 for(;bit>=1;bit>>=1)
3033 if(M_INT_GREATER(exp_adv_h,exp_adv_l,exp_mon_h,exp_mon_l))
3036 M_INT_SUB(exp_adv_h,exp_adv_l,exp_mon_h,exp_mon_l);
3038 M_INT_RSHIFT(exp_mon_h,exp_mon_l);
3040 sprintf(buf,"%03d",result);
3047 * Examine a grid, return a keypress.
3049 * The "mode" argument contains the "TARGET_LOOK" bit flag, which
3050 * indicates that the "space" key should scan through the contents
3051 * of the grid, instead of simply returning immediately. This lets
3052 * the "look" command get complete information, without making the
3053 * "target" command annoying.
3055 * The "info" argument contains the "commands" which should be shown
3056 * inside the "[xxx]" text. This string must never be empty, or grids
3057 * containing monsters will be displayed with an extra comma.
3059 * Note that if a monster is in the grid, we update both the monster
3060 * recall info and the health bar info to track that monster.
3062 * Eventually, we may allow multiple objects per grid, or objects
3063 * and terrain features in the same grid. XXX XXX XXX
3065 * This function must handle blindness/hallucination.
3067 static int target_set_aux(int y, int x, int mode, cptr info)
3069 cave_type *c_ptr = &cave[y][x];
3070 s16b this_o_idx, next_o_idx = 0;
3071 cptr s1 = "", s2 = "", s3 = "", x_info = "";
3075 char out_val[MAX_NLEN+80];
3077 #ifdef ALLOW_EASY_FLOOR
3078 int floor_list[23], floor_num = 0;
3080 /* Scan all objects in the grid */
3083 floor_num = scan_floor(floor_list, y, x, 0x02);
3095 #endif /* ALLOW_EASY_FLOOR */
3097 /* Hack -- under the player */
3098 if ((y == py) && (x == px))
3121 /* Hack -- hallucination */
3125 cptr name = "²¿¤«´ñ̯¤Êʪ";
3127 cptr name = "something strange";
3131 /* Display a message */
3133 sprintf(out_val, "%s%s%s%s [%s]", s1, name, s2, s3, info);
3135 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, name, info);
3139 move_cursor_relative(y, x);
3142 /* Stop on everything but "return" */
3143 if ((query != '\r') && (query != '\n')) return query;
3145 /* Repeat forever */
3150 /* Actual monsters */
3151 if (c_ptr->m_idx && m_list[c_ptr->m_idx].ml)
3153 monster_type *m_ptr = &m_list[c_ptr->m_idx];
3154 monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
3156 bool recall = FALSE;
3161 /* Get the monster name ("a kobold") */
3162 monster_desc(m_name, m_ptr, 0x08);
3164 /* Hack -- track this monster race */
3165 monster_race_track(m_ptr->ap_r_idx);
3167 /* Hack -- health bar for this monster */
3168 health_track(c_ptr->m_idx);
3170 /* Hack -- handle stuff */
3184 /* Recall on screen */
3185 screen_roff(m_ptr->ap_r_idx, 0);
3187 /* Hack -- Complete the prompt (again) */
3189 Term_addstr(-1, TERM_WHITE, format(" [r»× %s%s]", x_info, info));
3191 Term_addstr(-1, TERM_WHITE, format(" [r,%s%s]", x_info, info));
3200 /* Normal commands */
3201 if (query != 'r') break;
3206 /* Cleare recall text and repeat */
3212 /* Describe, and prompt for recall */
3213 evaluate_monster_exp(acount, m_ptr);
3216 sprintf(out_val, "[%s]%s%s(%s)%s%s [r»× %s%s]", acount, s1, m_name, look_mon_desc(c_ptr->m_idx, 0x01), s2, s3, x_info, info);
3218 sprintf(out_val, "[%s]%s%s%s%s(%s) [r, %s%s]", acount, s1, s2, s3, m_name, look_mon_desc(c_ptr->m_idx, 0x01), x_info, info);
3224 move_cursor_relative(y, x);
3229 /* Normal commands */
3230 if (query != 'r') break;
3236 /* Always stop at "normal" keys */
3237 if ((query != '\r') && (query != '\n') && (query != ' ') && (query != 'x')) return query;
3239 /* Sometimes stop at "space" key */
3240 if ((query == ' ') && !(mode & (TARGET_LOOK))) return query;
3242 /* Change the intro */
3250 /* Hack -- take account of gender */
3252 if (ap_r_ptr->flags1 & (RF1_FEMALE)) s1 = "Èà½÷¤Ï";
3254 if (ap_r_ptr->flags1 & (RF1_FEMALE)) s1 = "She is ";
3258 else if (ap_r_ptr->flags1 & (RF1_MALE)) s1 = "Èà¤Ï";
3260 else if (ap_r_ptr->flags1 & (RF1_MALE)) s1 = "He is ";
3264 /* Use a preposition */
3273 /* Scan all objects being carried */
3274 for (this_o_idx = m_ptr->hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
3276 char o_name[MAX_NLEN];
3280 /* Acquire object */
3281 o_ptr = &o_list[this_o_idx];
3283 /* Acquire next object */
3284 next_o_idx = o_ptr->next_o_idx;
3286 /* Obtain an object description */
3287 object_desc(o_name, o_ptr, TRUE, 3);
3289 /* Describe the object */
3291 sprintf(out_val, "%s%s%s%s[%s]", s1, o_name, s2, s3, info);
3293 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, o_name, info);
3297 move_cursor_relative(y, x);
3300 /* Always stop at "normal" keys */
3301 if ((query != '\r') && (query != '\n') && (query != ' ') && (query != 'x')) return query;
3303 /* Sometimes stop at "space" key */
3304 if ((query == ' ') && !(mode & (TARGET_LOOK))) return query;
3306 /* Change the intro */
3310 s2 = "also carrying ";
3314 /* Use a preposition */
3324 #ifdef ALLOW_EASY_FLOOR
3333 char o_name[MAX_NLEN];
3337 /* Acquire object */
3338 o_ptr = &o_list[floor_list[0]];
3340 /* Describe the object */
3341 object_desc(o_name, o_ptr, TRUE, 3);
3345 sprintf(out_val, "%s%s%s%s[%s]",
3346 s1, o_name, s2, s3, info);
3348 sprintf(out_val, "%s%s%s%s [%s]",
3349 s1, s2, s3, o_name, info);
3353 move_cursor_relative(y, x);
3362 /* Provide one cushion before item listing */
3365 /* Display rough information about items */
3367 sprintf(out_val, "%s %d¸Ä¤Î¥¢¥¤¥Æ¥à%s%s ['x'¤Ç°ìÍ÷, %s]",
3368 s1, floor_num, s2, s3, info);
3370 sprintf(out_val, "%s%s%sa pile of %d items [x,%s]",
3371 s1, s2, s3, floor_num, info);
3375 move_cursor_relative(y, x);
3380 /* No request for listing */
3381 if (query != 'x' && query != ' ') return query;
3385 /** Display list of items **/
3387 /* Continue scrolling list if requested */
3397 (void)show_floor(0, y, x, &min_width);
3401 sprintf(out_val, "%s %d¸Ä¤Î¥¢¥¤¥Æ¥à%s%s [Enter¤Ç¼¡¤Ø, %s]",
3402 s1, floor_num, s2, s3, info);
3404 sprintf(out_val, "%s%s%sa pile of %d items [Enter,%s]",
3405 s1, s2, s3, floor_num, info);
3416 /* Exit unless 'Enter' */
3417 if (query != '\n' && query != '\r')
3422 /* Get the object being moved. */
3423 c_ptr = &cave[y][x];
3424 o_idx = c_ptr->o_idx;
3426 /* Only rotate a pile of two or more objects. */
3427 if (!(o_idx && o_list[o_idx].next_o_idx)) continue;
3429 /* Remove the first object from the list. */
3430 excise_object_idx(o_idx);
3432 /* Find end of the list. */
3434 while (o_list[i].next_o_idx)
3435 i = o_list[i].next_o_idx;
3437 /* Add after the last object. */
3438 o_list[i].next_o_idx = o_idx;
3440 /* Loop and re-display the list */
3447 #endif /* ALLOW_EASY_FLOOR */
3450 /* Scan all objects in the grid */
3451 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
3455 /* Acquire object */
3456 o_ptr = &o_list[this_o_idx];
3458 /* Acquire next object */
3459 next_o_idx = o_ptr->next_o_idx;
3464 char o_name[MAX_NLEN];
3469 /* Obtain an object description */
3470 object_desc(o_name, o_ptr, TRUE, 3);
3472 /* Describe the object */
3474 sprintf(out_val, "%s%s%s%s[%s]", s1, o_name, s2, s3, info);
3476 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, o_name, info);
3480 move_cursor_relative(y, x);
3483 /* Always stop at "normal" keys */
3484 if ((query != '\r') && (query != '\n') && (query != ' ') && (query != 'x')) return query;
3486 /* Sometimes stop at "space" key */
3487 if ((query == ' ') && !(mode & TARGET_LOOK)) return query;
3489 /* Change the intro */
3499 if (o_ptr->number != 1) s1 = "¤½¤ì¤é¤Ï";
3501 if (o_ptr->number != 1) s1 = "They are ";
3517 /* Feature code (applying "mimic" field) */
3518 feat = c_ptr->mimic ? c_ptr->mimic : f_info[c_ptr->feat].mimic;
3520 /* Require knowledge about grid, or ability to see grid */
3521 if (!(c_ptr->info & CAVE_MARK) && !player_can_see_bold(y, x))
3523 /* Forget feature */
3527 /* Terrain feature if needed */
3528 if (boring || (feat > FEAT_INVIS))
3532 /* Hack -- special handling for building doors */
3533 if ((feat >= FEAT_BLDG_HEAD) && (feat <= FEAT_BLDG_TAIL))
3535 name = building[feat - FEAT_BLDG_HEAD].name;
3537 else if (feat == FEAT_ENTRANCE)
3540 name = format("%s(%d³¬ÁêÅö)", d_text + d_info[c_ptr->special].text, d_info[c_ptr->special].mindepth);
3542 name = format("%s(level %d)", d_text + d_info[c_ptr->special].text, d_info[c_ptr->special].mindepth);
3545 else if (feat == FEAT_TOWN)
3547 name = town[c_ptr->special].name;
3549 else if (p_ptr->wild_mode && (feat == FEAT_FLOOR))
3559 name = f_name + f_info[feat].name;
3564 if (*s2 && ((feat >= FEAT_MINOR_GLYPH) &&
3565 (feat <= FEAT_PATTERN_XTRA2)))
3574 else if (*s2 && ((feat >= FEAT_DOOR_HEAD) &&
3575 (feat <= FEAT_PERM_SOLID)))
3584 else if (*s2 && (feat == FEAT_TOWN))
3594 /* Hack -- special introduction for store & building doors -KMW- */
3595 if (((feat >= FEAT_SHOP_HEAD) && (feat <= FEAT_SHOP_TAIL)) ||
3596 ((feat >= FEAT_BLDG_HEAD) && (feat <= FEAT_BLDG_TAIL)) ||
3597 (feat == FEAT_MUSEUM) ||
3598 (feat == FEAT_ENTRANCE))
3607 else if ((feat == FEAT_TOWN) || (feat == FEAT_FLOOR) || (feat == FEAT_DIRT) || (feat == FEAT_FLOWER))
3615 /* Pick proper indefinite article */
3617 s3 = (is_a_vowel(name[0])) ? "an " : "a ";
3621 /* Display a message */
3624 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);
3626 sprintf(out_val, "%s%s%s%s [%s] %x %d %d %d %d (%d,%d)", s1, s2, s3, name, info, c_ptr->info, c_ptr->feat, c_ptr->dist, c_ptr->cost, c_ptr->when, x, y);
3630 sprintf(out_val, "%s%s%s%s[%s]", s1, name, s2, s3, info);
3632 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, name, info);
3636 move_cursor_relative(y, x);
3639 /* Always stop at "normal" keys */
3640 if ((query != '\r') && (query != '\n') && (query != ' ')) return query;
3643 /* Stop on everything but "return" */
3644 if ((query != '\r') && (query != '\n')) return query;
3646 /* Repeat forever */
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)
3712 get_screen_size(&wid, &hgt);
3718 /* Cancel tracking */
3719 /* health_track(0); */
3722 /* Prepare the "temp" array */
3723 target_set_prepare(mode);
3725 /* Start near the player */
3731 /* Interesting grids */
3737 if (!(mode & TARGET_LOOK)) prt_path(y, x);
3740 c_ptr = &cave[y][x];
3743 if (target_able(c_ptr->m_idx))
3746 strcpy(info, "q»ß t·è p¼« o¸½ +¼¡ -Á°");
3748 strcpy(info, "q,t,p,o,+,-,<dir>");
3753 /* Dis-allow target */
3757 strcpy(info, "q»ß p¼« o¸½ +¼¡ -Á°");
3759 strcpy(info, "q,p,o,+,-,<dir>");
3764 /* Describe and Prompt */
3765 while (!(query = target_set_aux(y, x, mode, info)));
3767 /* Cancel tracking */
3768 /* health_track(0); */
3770 /* Assume no "direction" */
3775 if (query == '\r') query = 't';
3793 if (target_able(c_ptr->m_idx))
3795 health_track(c_ptr->m_idx);
3796 target_who = c_ptr->m_idx;
3815 if (!expand_list) done = TRUE;
3825 if (!expand_list) done = TRUE;
3832 /* Recenter the map around the player */
3836 p_ptr->update |= (PU_MONSTERS);
3839 p_ptr->redraw |= (PR_MAP);
3842 p_ptr->window |= (PW_OVERHEAD);
3847 /* Recalculate interesting grids */
3848 target_set_prepare(mode);
3867 /* Extract the action (if any) */
3868 d = get_keymap_dir(query);
3875 /* Hack -- move around */
3878 /* Modified to scroll to monster */
3879 int y2 = panel_row_min;
3880 int x2 = panel_col_min;
3882 /* Find a new monster */
3883 i = target_pick(temp_y[m], temp_x[m], ddy[d], ddx[d]);
3885 /* Request to target past last interesting grid */
3886 while (flag && (i < 0))
3888 /* Note the change */
3889 if (change_panel(ddy[d], ddx[d]))
3894 /* Recalculate interesting grids */
3895 target_set_prepare(mode);
3897 /* Look at interesting grids */
3900 /* Find a new monster */
3901 i = target_pick(v, u, ddy[d], ddx[d]);
3907 /* Nothing interesting */
3913 /* Restore previous position */
3916 panel_bounds_center();
3919 p_ptr->update |= (PU_MONSTERS);
3922 p_ptr->redraw |= (PR_MAP);
3925 p_ptr->window |= (PW_OVERHEAD);
3930 /* Recalculate interesting grids */
3931 target_set_prepare(mode);
3933 /* Look at boring grids */
3940 /* Do not move horizontally if unnecessary */
3941 if (((x < panel_col_min + wid / 2) && (dx > 0)) ||
3942 ((x > panel_col_min + wid / 2) && (dx < 0)))
3947 /* Do not move vertically if unnecessary */
3948 if (((y < panel_row_min + hgt / 2) && (dy > 0)) ||
3949 ((y > panel_row_min + hgt / 2) && (dy < 0)))
3954 /* Apply the motion */
3955 if ((y >= panel_row_min+hgt) || (y < panel_row_min) ||
3956 (x >= panel_col_min+wid) || (x < panel_col_min))
3958 if (change_panel(dy, dx)) target_set_prepare(mode);
3961 /* Slide into legality */
3962 if (x >= cur_wid-1) x = cur_wid - 2;
3963 else if (x <= 0) x = 1;
3965 /* Slide into legality */
3966 if (y >= cur_hgt-1) y = cur_hgt- 2;
3967 else if (y <= 0) y = 1;
3976 /* Arbitrary grids */
3979 bool move_fast = FALSE;
3981 if (!(mode & TARGET_LOOK)) prt_path(y, x);
3984 c_ptr = &cave[y][x];
3986 /* Default prompt */
3988 strcpy(info, "q»ß t·è p¼« m¶á +¼¡ -Á°");
3990 strcpy(info, "q,t,p,m,+,-,<dir>");
3994 /* Describe and Prompt (enable "TARGET_LOOK") */
3995 while (!(query = target_set_aux(y, x, mode | TARGET_LOOK, info)));
3997 /* Cancel tracking */
3998 /* health_track(0); */
4000 /* Assume no direction */
4005 if (query == '\r') query = 't';
4008 /* Analyze the keypress */
4032 /* Recenter the map around the player */
4036 p_ptr->update |= (PU_MONSTERS);
4039 p_ptr->redraw |= (PR_MAP);
4042 p_ptr->window |= (PW_OVERHEAD);
4047 /* Recalculate interesting grids */
4048 target_set_prepare(mode);
4070 /* Pick a nearby monster */
4071 for (i = 0; i < temp_n; i++)
4073 t = distance(y, x, temp_y[i], temp_x[i]);
4083 /* Nothing interesting */
4084 if (bd == 999) flag = FALSE;
4091 /* Extract the action (if any) */
4092 d = get_keymap_dir(query);
4094 /* XTRA HACK MOVEFAST */
4095 if (isupper(query)) move_fast = TRUE;
4102 /* Handle "direction" */
4108 /* XTRA HACK MOVEFAST */
4111 int mag = MIN(wid / 2, hgt / 2);
4121 /* Do not move horizontally if unnecessary */
4122 if (((x < panel_col_min + wid / 2) && (dx > 0)) ||
4123 ((x > panel_col_min + wid / 2) && (dx < 0)))
4128 /* Do not move vertically if unnecessary */
4129 if (((y < panel_row_min + hgt / 2) && (dy > 0)) ||
4130 ((y > panel_row_min + hgt / 2) && (dy < 0)))
4135 /* Apply the motion */
4136 if ((y >= panel_row_min + hgt) || (y < panel_row_min) ||
4137 (x >= panel_col_min + wid) || (x < panel_col_min))
4139 if (change_panel(dy, dx)) target_set_prepare(mode);
4142 /* Slide into legality */
4143 if (x >= cur_wid-1) x = cur_wid - 2;
4144 else if (x <= 0) x = 1;
4146 /* Slide into legality */
4147 if (y >= cur_hgt-1) y = cur_hgt- 2;
4148 else if (y <= 0) y = 1;
4156 /* Clear the top line */
4159 /* Recenter the map around the player */
4163 p_ptr->update |= (PU_MONSTERS);
4166 p_ptr->redraw |= (PR_MAP);
4169 p_ptr->window |= (PW_OVERHEAD);
4174 /* Failure to set target */
4175 if (!target_who) return (FALSE);
4183 * Get an "aiming direction" from the user.
4185 * The "dir" is loaded with 1,2,3,4,6,7,8,9 for "actual direction", and
4186 * "0" for "current target", and "-1" for "entry aborted".
4188 * Note that "Force Target", if set, will pre-empt user interaction,
4189 * if there is a usable target already set.
4191 * Note that confusion over-rides any (explicit?) user choice.
4193 bool get_aim_dir(int *dp)
4204 /* Global direction */
4207 /* Hack -- auto-target if requested */
4208 if (use_old_target && target_okay()) dir = 5;
4210 #ifdef ALLOW_REPEAT /* TNB */
4212 if (repeat_pull(dp))
4217 if (!(*dp == 5 && !target_okay()))
4219 /* return (TRUE); */
4224 #endif /* ALLOW_REPEAT -- TNB */
4226 /* Ask until satisfied */
4229 /* Choose a prompt */
4233 p = "Êý¸þ ('*'¤Ç¥¿¡¼¥²¥Ã¥ÈÁªÂò, ESC¤ÇÃæÃÇ)? ";
4235 p = "Direction ('*' to choose a target, Escape to cancel)? ";
4242 p = "Êý¸þ ('5'¤Ç¥¿¡¼¥²¥Ã¥È¤Ø, '*'¤Ç¥¿¡¼¥²¥Ã¥ÈºÆÁªÂò, ESC¤ÇÃæÃÇ)? ";
4244 p = "Direction ('5' for target, '*' to re-target, Escape to cancel)? ";
4249 /* Get a command (or Cancel) */
4250 if (!get_com(p, &command, TRUE)) break;
4254 if (command == '\r') command = 't';
4257 /* Convert various keys to "standard" keys */
4260 /* Use current target */
4271 /* Set new target */
4276 if (target_set(TARGET_KILL)) dir = 5;
4282 /* Extract the action (if any) */
4283 dir = get_keymap_dir(command);
4289 /* Verify requested targets */
4290 if ((dir == 5) && !target_okay()) dir = 0;
4299 project_length = 0; /* reset to default */
4303 /* Save the direction */
4306 /* Check for confusion */
4307 if (p_ptr->confused)
4310 /* Random direction */
4311 dir = ddd[randint0(8)];
4314 /* Notice confusion */
4315 if (command_dir != dir)
4319 msg_print("¤¢¤Ê¤¿¤Ïº®Í𤷤Ƥ¤¤ë¡£");
4321 msg_print("You are confused.");
4326 /* Save direction */
4329 #ifdef ALLOW_REPEAT /* TNB */
4331 /* repeat_push(dir); */
4332 repeat_push(command_dir);
4334 #endif /* ALLOW_REPEAT -- TNB */
4336 /* A "valid" direction was entered */
4343 * Request a "movement" direction (1,2,3,4,6,7,8,9) from the user,
4344 * and place it into "command_dir", unless we already have one.
4346 * This function should be used for all "repeatable" commands, such as
4347 * run, walk, open, close, bash, disarm, spike, tunnel, etc, as well
4348 * as all commands which must reference a grid adjacent to the player,
4349 * and which may not reference the grid under the player. Note that,
4350 * for example, it is no longer possible to "disarm" or "open" chests
4351 * in the same grid as the player.
4353 * Direction "5" is illegal and will (cleanly) abort the command.
4355 * This function tracks and uses the "global direction", and uses
4356 * that as the "desired direction", to which "confusion" is applied.
4358 bool get_rep_dir(int *dp, bool under)
4365 /* Global direction */
4368 #ifdef ALLOW_REPEAT /* TNB */
4370 if (repeat_pull(dp))
4373 /* return (TRUE); */
4376 #endif /* ALLOW_REPEAT -- TNB */
4378 /* Get a direction */
4383 /* Get a command (or Cancel) */
4385 if (!get_com("Êý¸þ (ESC¤ÇÃæÃÇ)? ", &ch, TRUE)) break;
4387 if (!get_com("Direction (Escape to cancel)? ", &ch, TRUE)) break;
4391 /* Look up the direction */
4392 dir = get_keymap_dir(ch);
4398 /* Prevent weirdness */
4399 if ((dir == 5) && (!under)) dir = 0;
4402 if (!dir) return (FALSE);
4404 /* Save desired direction */
4407 /* Apply "confusion" */
4408 if (p_ptr->confused)
4410 /* Standard confusion */
4411 if (randint0(100) < 75)
4413 /* Random direction */
4414 dir = ddd[randint0(8)];
4417 else if (p_ptr->riding)
4419 monster_type *m_ptr = &m_list[p_ptr->riding];
4420 monster_race *r_ptr = &r_info[m_ptr->r_idx];
4422 if (m_ptr->confused)
4424 /* Standard confusion */
4425 if (randint0(100) < 75)
4427 /* Random direction */
4428 dir = ddd[randint0(8)];
4431 else if ((r_ptr->flags1 & RF1_RAND_50) && (r_ptr->flags1 & RF1_RAND_25) && (randint0(100) < 50))
4433 /* Random direction */
4434 dir = ddd[randint0(8)];
4436 else if ((r_ptr->flags1 & RF1_RAND_50) && (randint0(100) < 25))
4438 /* Random direction */
4439 dir = ddd[randint0(8)];
4443 /* Notice confusion */
4444 if (command_dir != dir)
4446 if (p_ptr->confused)
4450 msg_print("¤¢¤Ê¤¿¤Ïº®Í𤷤Ƥ¤¤ë¡£");
4452 msg_print("You are confused.");
4458 monster_type *m_ptr = &m_list[p_ptr->riding];
4460 monster_desc(m_name, m_ptr, 0);
4461 if (m_ptr->confused)
4464 msg_format("%s¤Ïº®Í𤷤Ƥ¤¤ë¡£", m_name);
4466 msg_format("%^s is confusing.", m_name);
4473 msg_format("%s¤Ï»×¤¤Ä̤ê¤ËÆ°¤¤¤Æ¤¯¤ì¤Ê¤¤¡£", m_name);
4475 msg_format("You cannot control %s.", m_name);
4481 /* Save direction */
4484 #ifdef ALLOW_REPEAT /* TNB */
4486 /* repeat_push(dir); */
4487 repeat_push(command_dir);
4489 #endif /* ALLOW_REPEAT -- TNB */
4496 bool get_rep_dir2(int *dp)
4503 /* Global direction */
4506 #ifdef ALLOW_REPEAT /* TNB */
4508 if (repeat_pull(dp))
4511 /* return (TRUE); */
4514 #endif /* ALLOW_REPEAT -- TNB */
4516 /* Get a direction */
4521 /* Get a command (or Cancel) */
4523 if (!get_com("Êý¸þ (ESC¤ÇÃæÃÇ)? ", &ch, TRUE)) break;
4525 if (!get_com("Direction (Escape to cancel)? ", &ch, TRUE)) break;
4529 /* Look up the direction */
4530 dir = get_keymap_dir(ch);
4536 /* Prevent weirdness */
4537 if (dir == 5) dir = 0;
4540 if (!dir) return (FALSE);
4542 /* Save desired direction */
4545 /* Apply "confusion" */
4546 if (p_ptr->confused)
4548 /* Standard confusion */
4549 if (randint0(100) < 75)
4551 /* Random direction */
4552 dir = ddd[randint0(8)];
4556 /* Notice confusion */
4557 if (command_dir != dir)
4561 msg_print("¤¢¤Ê¤¿¤Ïº®Í𤷤Ƥ¤¤ë¡£");
4563 msg_print("You are confused.");
4568 /* Save direction */
4571 #ifdef ALLOW_REPEAT /* TNB */
4573 /* repeat_push(dir); */
4574 repeat_push(command_dir);
4576 #endif /* ALLOW_REPEAT -- TNB */
4583 int get_chaos_patron(void)
4585 return ((p_ptr->age + p_ptr->sc) % MAX_PATRON);
4589 void gain_level_reward(int chosen_reward)
4593 char wrath_reason[32] = "";
4594 int nasty_chance = 6;
4595 int dummy = 0, dummy2 = 0;
4598 char o_name[MAX_NLEN];
4604 if (multi_rew) return;
4605 else multi_rew = TRUE;
4609 if (p_ptr->lev == 13) nasty_chance = 2;
4610 else if (!(p_ptr->lev % 13)) nasty_chance = 3;
4611 else if (!(p_ptr->lev % 14)) nasty_chance = 12;
4613 if (one_in_(nasty_chance))
4614 type = randint1(20); /* Allow the 'nasty' effects */
4616 type = randint1(15) + 5; /* Or disallow them */
4618 if (type < 1) type = 1;
4619 if (type > 20) type = 20;
4624 sprintf(wrath_reason, "%s¤ÎÅܤê",
4625 chaos_patrons[p_ptr->chaos_patron]);
4627 sprintf(wrath_reason, "the Wrath of %s",
4628 chaos_patrons[p_ptr->chaos_patron]);
4632 effect = chaos_rewards[p_ptr->chaos_patron][type];
4634 if (one_in_(6) && !chosen_reward)
4637 msg_format("%^s¤ÏË«Èþ¤È¤·¤Æ¤¢¤Ê¤¿¤òÆÍÁ³ÊÑ°Û¤µ¤»¤¿¡£",
4638 chaos_patrons[p_ptr->chaos_patron]);
4640 msg_format("%^s rewards you with a mutation!",
4641 chaos_patrons[p_ptr->chaos_patron]);
4644 (void)gain_random_mutation(0);
4646 reward = "ÊÑ°Û¤·¤¿¡£";
4648 reward = "mutation";
4653 switch (chosen_reward ? chosen_reward : effect)
4657 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
4658 chaos_patrons[p_ptr->chaos_patron]);
4660 msg_format("The voice of %s booms out:",
4661 chaos_patrons[p_ptr->chaos_patron]);
4665 msg_print("¡ÖÆò¡¢¿·¤¿¤Ê¤ë»Ñ¤òɬÍפȤ»¤ê¡ª¡×");
4667 msg_print("'Thou needst a new form, mortal!'");
4672 reward = "ÊÑ°Û¤·¤¿¡£";
4674 reward = "polymorphing";
4679 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
4680 chaos_patrons[p_ptr->chaos_patron]);
4682 msg_format("The voice of %s booms out:",
4683 chaos_patrons[p_ptr->chaos_patron]);
4687 msg_print("¡ÖÆò¤ÏÎɤ¯¹Ô¤¤¤¿¤ê¡ªÂ³¤±¤è¡ª¡×");
4689 msg_print("'Well done, mortal! Lead on!'");
4692 if (p_ptr->prace == RACE_ANDROID)
4695 msg_print("¤·¤«¤·²¿¤âµ¯¤³¤é¤Ê¤«¤Ã¤¿¡£");
4697 msg_print("But, nothing happen.");
4700 else if (p_ptr->exp < PY_MAX_EXP)
4702 s32b ee = (p_ptr->exp / 2) + 10;
4703 if (ee > 100000L) ee = 100000L;
4705 msg_print("¹¹¤Ë·Ð¸³¤òÀѤó¤À¤è¤¦¤Êµ¤¤¬¤¹¤ë¡£");
4707 msg_print("You feel more experienced.");
4712 reward = "·Ð¸³ÃͤòÆÀ¤¿";
4714 reward = "experience";
4720 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
4721 chaos_patrons[p_ptr->chaos_patron]);
4723 msg_format("The voice of %s booms out:",
4724 chaos_patrons[p_ptr->chaos_patron]);
4728 msg_print("¡Ö²¼Ëͤ衢Æò¤½¤ì¤ËÃͤ»¤º¡£¡×");
4730 msg_print("'Thou didst not deserve that, slave.'");
4733 if (p_ptr->prace == RACE_ANDROID)
4736 msg_print("¤·¤«¤·²¿¤âµ¯¤³¤é¤Ê¤«¤Ã¤¿¡£");
4738 msg_print("But, nothing happen.");
4743 lose_exp(p_ptr->exp / 6);
4745 reward = "·Ð¸³Ãͤò¼º¤Ã¤¿¡£";
4747 reward = "losing experience";
4753 msg_format("%s¤ÎÀ¼¤¬¤µ¤µ¤ä¤¤¤¿:",
4754 chaos_patrons[p_ptr->chaos_patron]);
4756 msg_format("The voice of %s whispers:",
4757 chaos_patrons[p_ptr->chaos_patron]);
4761 msg_print("¡Ö²æ¤¬Í¿¤¨¤·Êª¤ò¸ÌÀ¤Ë»È¤¦¤Ù¤·¡£¡×");
4763 msg_print("'Use my gift wisely.'");
4766 acquirement(py, px, 1, FALSE, FALSE);
4768 reward = "¾å¼Á¤Ê¥¢¥¤¥Æ¥à¤ò¼ê¤ËÆþ¤ì¤¿¡£";
4770 reward = "a good item";
4775 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
4776 chaos_patrons[p_ptr->chaos_patron]);
4778 msg_format("The voice of %s booms out:",
4779 chaos_patrons[p_ptr->chaos_patron]);
4783 msg_print("¡Ö²æ¤¬Í¿¤¨¤·Êª¤ò¸ÌÀ¤Ë»È¤¦¤Ù¤·¡£¡×");
4785 msg_print("'Use my gift wisely.'");
4788 acquirement(py, px, 1, TRUE, FALSE);
4790 reward = "¹âµéÉʤΥ¢¥¤¥Æ¥à¤ò¼ê¤ËÆþ¤ì¤¿¡£";
4792 reward = "an excellent item";
4797 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
4798 chaos_patrons[p_ptr->chaos_patron]);
4800 msg_format("The voice of %s booms out:",
4801 chaos_patrons[p_ptr->chaos_patron]);
4805 msg_print("¡ÖÆò¤Î¹Ô¤¤¤Ïµ®¤·õ¤ËÃͤ»¤ê¡£¡×");
4807 msg_print("'Thy deed hath earned thee a worthy blade.'");
4810 /* Get local object */
4813 switch (randint1(p_ptr->lev))
4819 dummy2 = SV_MAIN_GAUCHE;
4828 dummy2 = SV_SMALL_SWORD;
4831 dummy2 = SV_BASILLARD;
4833 case 11: case 12: case 13:
4834 dummy2 = SV_SHORT_SWORD;
4840 dummy2 = SV_CUTLASS;
4843 dummy2 = SV_WAKIZASHI;
4846 dummy2 = SV_KHOPESH;
4852 dummy2 = SV_BROAD_SWORD;
4855 dummy2 = SV_LONG_SWORD;
4858 dummy2 = SV_SCIMITAR;
4861 dummy2 = SV_NINJATO;
4867 dummy2 = SV_BASTARD_SWORD;
4870 dummy2 = SV_GREAT_SCIMITAR;
4873 dummy2 = SV_CLAYMORE;
4876 dummy2 = SV_ESPADON;
4879 dummy2 = SV_TWO_HANDED_SWORD;
4882 dummy2 = SV_FLAMBERGE;
4885 dummy2 = SV_NO_DACHI;
4888 dummy2 = SV_EXECUTIONERS_SWORD;
4891 dummy2 = SV_ZWEIHANDER;
4894 dummy2 = SV_HAYABUSA;
4897 dummy2 = SV_BLADE_OF_CHAOS;
4900 object_prep(q_ptr, lookup_kind(dummy, dummy2));
4901 q_ptr->to_h = 3 + randint1(dun_level) % 10;
4902 q_ptr->to_d = 3 + randint1(dun_level) % 10;
4903 one_resistance(q_ptr);
4904 q_ptr->name2 = EGO_CHAOTIC;
4906 /* Drop it in the dungeon */
4907 (void)drop_near(q_ptr, -1, py, px);
4909 reward = "(º®ÆÙ)¤ÎÉð´ï¤ò¼ê¤ËÆþ¤ì¤¿¡£";
4911 reward = "chaos weapon";
4916 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
4917 chaos_patrons[p_ptr->chaos_patron]);
4919 msg_format("The voice of %s booms out:",
4920 chaos_patrons[p_ptr->chaos_patron]);
4924 msg_print("¡ÖÆò¤Î¹Ô¤¤¤Ïµ®¤Ê󤤤ËÃͤ»¤ê¡£¡×");
4926 msg_print("'Thy deed hath earned thee a worthy reward.'");
4929 acquirement(py, px, randint1(2) + 1, FALSE, FALSE);
4931 reward = "¾å¼Á¤Ê¥¢¥¤¥Æ¥à¤ò¼ê¤ËÆþ¤ì¤¿¡£";
4933 reward = "good items";
4938 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
4939 chaos_patrons[p_ptr->chaos_patron]);
4941 msg_format("The voice of %s booms out:",
4942 chaos_patrons[p_ptr->chaos_patron]);
4946 msg_print("¡Ö²¼Ëͤ衢Æò¤Î¸¥¿È¤Ø¤Î²æ¤¬Àˤ·¤ß̵¤Ê󤤤ò¸«¤ë¤¬¤è¤¤¡£¡×");
4948 msg_print("'Behold, mortal, how generously I reward thy loyalty.'");
4951 acquirement(py, px, randint1(2) + 1, TRUE, FALSE);
4953 reward = "¹âµéÉʤΥ¢¥¤¥Æ¥à¤ò¼ê¤ËÆþ¤ì¤¿¡£";
4955 reward = "excellent items";
4960 msg_format("%s¤ÎÀ¼¤¬¹ì¤ÅϤä¿:",
4961 chaos_patrons[p_ptr->chaos_patron]);
4963 msg_format("The voice of %s thunders:",
4964 chaos_patrons[p_ptr->chaos_patron]);
4968 msg_print("¡Ö²¼Ëͤ衢ÆòÐþËý¤Ê¤ê¡£¡×");
4970 msg_print("'Thou art growing arrogant, mortal.'");
4973 (void)activate_ty_curse(FALSE, &count);
4975 reward = "²Ò¡¹¤·¤¤¼ö¤¤¤ò¤«¤±¤é¤ì¤¿¡£";
4982 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
4983 chaos_patrons[p_ptr->chaos_patron]);
4985 msg_format("The voice of %s booms out:",
4986 chaos_patrons[p_ptr->chaos_patron]);
4990 msg_print("¡Ö²æ¤¬²¼Ëͤ¿¤Á¤è¡¢¤«¤ÎÐþËý¤Ê¤ë¼Ô¤òÅݤ¹¤Ù¤·¡ª¡×");
4992 msg_print("'My pets, destroy the arrogant mortal!'");
4995 for (dummy = 0; dummy < randint1(5) + 1; dummy++)
4997 (void)summon_specific(0, py, px, dun_level, 0, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET));
5000 reward = "¥â¥ó¥¹¥¿¡¼¤ò¾¤´¤µ¤ì¤¿¡£";
5002 reward = "summoning hostile monsters";
5007 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5008 chaos_patrons[p_ptr->chaos_patron]);
5010 msg_format("The voice of %s booms out:",
5011 chaos_patrons[p_ptr->chaos_patron]);
5015 msg_print("¡ÖÆò¡¢¤è¤ê¶¯¤Å¨¤òɬÍפȤ»¤ê¡ª¡×");
5017 msg_print("'Thou needst worthier opponents!'");
5020 activate_hi_summon(py, px, FALSE);
5022 reward = "¥â¥ó¥¹¥¿¡¼¤ò¾¤´¤µ¤ì¤¿¡£";
5024 reward = "summoning many hostile monsters";
5029 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5030 chaos_patrons[p_ptr->chaos_patron]);
5032 msg_format("The voice of %s booms out:",
5033 chaos_patrons[p_ptr->chaos_patron]);
5037 msg_print("¡Ö»à¤ÈÇ˲õ¤³¤½²æ¤¬´î¤Ó¤Ê¤ê¡ª¡×");
5039 msg_print("'Death and destruction! This pleaseth me!'");
5044 reward = "¥«¥ª¥¹¤ÎÎϤ¬±²´¬¤¤¤¿¡£";
5046 reward = "calling chaos";
5051 msg_format("%s¤ÎÀ¼¤¬ÌĤê¶Á¤¤¤¿:",
5052 chaos_patrons[p_ptr->chaos_patron]);
5054 msg_format("The voice of %s rings out:",
5055 chaos_patrons[p_ptr->chaos_patron]);
5059 msg_print("¡Öα¤Þ¤ë¤Î¤À¡¢²¼Ëͤ衣;¤¬Æò¤ÎÆùÂΤòÃ䨤󡣡×");
5061 msg_print("'Stay, mortal, and let me mold thee.'");
5064 if (one_in_(3) && !(chaos_stats[p_ptr->chaos_patron] < 0))
5065 do_inc_stat(chaos_stats[p_ptr->chaos_patron]);
5067 do_inc_stat(randint0(6));
5069 reward = "ǽÎÏÃͤ¬¾å¤¬¤Ã¤¿¡£";
5071 reward = "increasing a stat";
5076 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5077 chaos_patrons[p_ptr->chaos_patron]);
5079 msg_format("The voice of %s booms out:",
5080 chaos_patrons[p_ptr->chaos_patron]);
5084 msg_print("¡Ö²¼Ëͤ衢;¤ÏÆò¤ËË°¤ß¤¿¤ê¡£¡×");
5086 msg_print("'I grow tired of thee, mortal.'");
5089 if (one_in_(3) && !(chaos_stats[p_ptr->chaos_patron] < 0))
5090 do_dec_stat(chaos_stats[p_ptr->chaos_patron]);
5092 (void)do_dec_stat(randint0(6));
5094 reward = "ǽÎÏÃͤ¬²¼¤¬¤Ã¤¿¡£";
5096 reward = "decreasing a stat";
5101 msg_format("%s¤ÎÀ¼¤¬¹ì¤ÅϤä¿:",
5102 chaos_patrons[p_ptr->chaos_patron]);
5104 msg_format("The voice of %s thunders:",
5105 chaos_patrons[p_ptr->chaos_patron]);
5109 msg_print("¡ÖÆò¡¢¸¬µõ¤¿¤ë¤³¤È¤ò³Ø¤Ö¤Ù¤·¡ª¡×");
5110 msg_print("¤¢¤Ê¤¿¤Ï°ÊÁ°¤è¤ê¼å¤¯¤Ê¤Ã¤¿¡ª");
5112 msg_print("'Thou needst a lesson in humility, mortal!'");
5113 msg_print("You feel less powerful!");
5116 for (dummy = 0; dummy < 6; dummy++)
5118 (void)dec_stat(dummy, 10 + randint1(15), TRUE);
5121 reward = "Á´Ç½ÎÏÃͤ¬²¼¤¬¤Ã¤¿¡£";
5123 reward = "decreasing all stats";
5128 msg_format("%s¤ÎÎϤ¬¿¨¤ì¤ë¤Î¤ò´¶¤¸¤¿¡£",
5130 msg_format("You feel the power of %s touch you.",
5133 chaos_patrons[p_ptr->chaos_patron]);
5136 reward = "½ý¤¬ÊѲ½¤·¤¿¡£";
5138 reward = "polymorphing wounds";
5143 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5144 chaos_patrons[p_ptr->chaos_patron]);
5146 msg_format("The voice of %s booms out:",
5147 chaos_patrons[p_ptr->chaos_patron]);
5151 msg_print("¡Ö²æ¤¬¤µ¤µ¤ä¤«¤Ê¤ë»òʪ¤ò¼õ¤±¤È¤ë¤¬¤è¤¤¡ª¡×");
5153 msg_print("'Receive this modest gift from me!'");
5156 for (dummy = 0; dummy < 6; dummy++)
5158 (void)do_inc_stat(dummy);
5161 reward = "Á´Ç½ÎÏÃͤ¬¾å¤¬¤Ã¤¿¡£";
5163 reward = "increasing all stats";
5168 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5169 chaos_patrons[p_ptr->chaos_patron]);
5171 msg_format("The voice of %s booms out:",
5172 chaos_patrons[p_ptr->chaos_patron]);
5176 msg_print("¡Ö¶ì¤·¤à¤¬¤è¤¤¡¢ÌµÇ½¤Ê¶ò¤«¼Ô¤è¡ª¡×");
5178 msg_print("'Suffer, pathetic fool!'");
5181 fire_ball(GF_DISINTEGRATE, 0, p_ptr->lev * 4, 4);
5182 take_hit(DAMAGE_NOESCAPE, p_ptr->lev * 4, wrath_reason, -1);
5184 reward = "ʬ²ò¤Îµå¤¬È¯À¸¤·¤¿¡£";
5186 reward = "generating disintegration ball";
5191 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5192 chaos_patrons[p_ptr->chaos_patron]);
5194 msg_format("The voice of %s booms out:",
5195 chaos_patrons[p_ptr->chaos_patron]);
5199 msg_print("¡Öᴤ뤬¤è¤¤¡¢²æ¤¬²¼Ëͤ衪¡×");
5201 msg_print("'Rise, my servant!'");
5205 (void)set_poisoned(0);
5207 (void)set_confused(0);
5212 for (dummy = 0; dummy < 6; dummy++)
5214 (void)do_res_stat(dummy);
5217 reward = "ÂÎÎϤ¬²óÉü¤·¤¿¡£";
5223 if (!buki_motteruka(INVEN_RARM)) break;
5225 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5226 chaos_patrons[p_ptr->chaos_patron]);
5228 msg_format("The voice of %s booms out:",
5229 chaos_patrons[p_ptr->chaos_patron]);
5233 msg_print("¡ÖÆò¡¢Éð´ï¤ËÍê¤ë¤³¤È¤Ê¤«¤ì¡£¡×");
5235 msg_print("'Thou reliest too much on thy weapon.'");
5238 object_desc(o_name, &inventory[INVEN_RARM], TRUE, 0);
5239 (void)curse_weapon(FALSE, INVEN_RARM);
5241 reward = format("%s¤¬Ç˲õ¤µ¤ì¤¿¡£", o_name);
5243 reward = format("destroying %s", o_name);
5247 if (!inventory[INVEN_BODY].k_idx) break;
5249 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5250 chaos_patrons[p_ptr->chaos_patron]);
5252 msg_format("The voice of %s booms out:",
5253 chaos_patrons[p_ptr->chaos_patron]);
5257 msg_print("¡ÖÆò¡¢Ëɶñ¤ËÍê¤ë¤³¤È¤Ê¤«¤ì¡£¡×");
5259 msg_print("'Thou reliest too much on thine equipment.'");
5262 object_desc(o_name, &inventory[INVEN_BODY], TRUE, 0);
5263 (void)curse_armor();
5265 reward = format("%s¤¬Ç˲õ¤µ¤ì¤¿¡£", o_name);
5267 reward = format("destroying %s", o_name);
5272 msg_format("%s¤ÎÀ¼¤¬¤µ¤µ¤ä¤¤¤¿:",
5273 chaos_patrons[p_ptr->chaos_patron]);
5275 msg_format("The voice of %s whispers:",
5276 chaos_patrons[p_ptr->chaos_patron]);
5280 msg_print("¡Ö²æ¤òÅܤꤷ¤á¤¿ºá¤ò½þ¤¦¤Ù¤·¡£¡×");
5282 msg_print("'Now thou shalt pay for annoying me.'");
5285 switch (randint1(4))
5288 (void)activate_ty_curse(FALSE, &count);
5290 reward = "²Ò¡¹¤·¤¤¼ö¤¤¤ò¤«¤±¤é¤ì¤¿¡£";
5296 activate_hi_summon(py, px, FALSE);
5298 reward = "¥â¥ó¥¹¥¿¡¼¤ò¾¤´¤µ¤ì¤¿¡£";
5300 reward = "summoning hostile monsters";
5306 if (!buki_motteruka(INVEN_RARM)) break;
5307 object_desc(o_name, &inventory[INVEN_RARM], TRUE, 0);
5308 (void)curse_weapon(FALSE, INVEN_RARM);
5310 reward = format("%s¤¬Ç˲õ¤µ¤ì¤¿¡£", o_name);
5312 reward = format("destroying %s", o_name);
5317 if (!inventory[INVEN_BODY].k_idx) break;
5318 object_desc(o_name, &inventory[INVEN_BODY], TRUE, 0);
5319 (void)curse_armor();
5321 reward = format("%s¤¬Ç˲õ¤µ¤ì¤¿¡£", o_name);
5323 reward = format("destroying %s", o_name);
5328 for (dummy = 0; dummy < 6; dummy++)
5330 (void)dec_stat(dummy, 10 + randint1(15), TRUE);
5333 reward = "Á´Ç½ÎÏÃͤ¬²¼¤¬¤Ã¤¿¡£";
5335 reward = "decreasing all stats";
5342 msg_format("%s¤ÎÀ¼¤¬¹ì¤ÅϤä¿:",
5344 msg_format("The voice of %s thunders:",
5347 chaos_patrons[p_ptr->chaos_patron]);
5349 msg_print("¡Ö»à¤Ì¤¬¤è¤¤¡¢²¼Ëͤ衪¡×");
5351 msg_print("'Die, mortal!'");
5354 take_hit(DAMAGE_LOSELIFE, p_ptr->lev * 4, wrath_reason, -1);
5355 for (dummy = 0; dummy < 6; dummy++)
5357 (void)dec_stat(dummy, 10 + randint1(15), FALSE);
5359 activate_hi_summon(py, px, FALSE);
5360 (void)activate_ty_curse(FALSE, &count);
5361 if (one_in_(2)) (void)curse_weapon(FALSE, INVEN_RARM);
5362 if (one_in_(2)) (void)curse_armor();
5366 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5367 chaos_patrons[p_ptr->chaos_patron]);
5369 msg_format("The voice of %s booms out:",
5370 chaos_patrons[p_ptr->chaos_patron]);
5374 msg_print("¡Ö»à¤ÈÇ˲õ¤³¤½²æ¤¬´î¤Ó¤Ê¤ê¡ª¡×");
5376 msg_print("'Death and destruction! This pleaseth me!'");
5379 destroy_area(py, px, 25, TRUE);
5381 reward = "¥À¥ó¥¸¥ç¥ó¤¬*Ç˲õ*¤µ¤ì¤¿¡£";
5383 reward = "*destruct*ing dungeon";
5388 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5389 chaos_patrons[p_ptr->chaos_patron]);
5391 msg_format("The voice of %s booms out:",
5392 chaos_patrons[p_ptr->chaos_patron]);
5396 msg_print("¡Ö²æ¡¢Æò¤ÎŨ¤òËõ»¦¤»¤ó¡ª¡×");
5398 msg_print("'Let me relieve thee of thine oppressors!'");
5401 (void)symbol_genocide(0, FALSE);
5403 reward = "¥â¥ó¥¹¥¿¡¼¤¬Ëõ»¦¤µ¤ì¤¿¡£";
5405 reward = "genociding monsters";
5410 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5411 chaos_patrons[p_ptr->chaos_patron]);
5413 msg_format("The voice of %s booms out:",
5414 chaos_patrons[p_ptr->chaos_patron]);
5418 msg_print("¡Ö²æ¡¢Æò¤ÎŨ¤òËõ»¦¤»¤ó¡ª¡×");
5420 msg_print("'Let me relieve thee of thine oppressors!'");
5423 (void)mass_genocide(0, FALSE);
5425 reward = "¥â¥ó¥¹¥¿¡¼¤¬Ëõ»¦¤µ¤ì¤¿¡£";
5427 reward = "genociding nearby monsters";
5432 msg_format("%s¤ÎÎϤ¬Å¨¤ò¹¶·â¤¹¤ë¤Î¤ò´¶¤¸¤¿¡ª",
5433 chaos_patrons[p_ptr->chaos_patron]);
5435 msg_format("You can feel the power of %s assault your enemies!",
5436 chaos_patrons[p_ptr->chaos_patron]);
5439 (void)dispel_monsters(p_ptr->lev * 4);
5443 msg_format("%s¤Ï¤¢¤Ê¤¿¤ò̵»ë¤·¤¿¡£",
5444 chaos_patrons[p_ptr->chaos_patron]);
5446 msg_format("%s ignores you.",
5447 chaos_patrons[p_ptr->chaos_patron]);
5453 msg_format("%s¤ÏË«Èþ¤È¤·¤Æ°Ëâ¤Î»È¤¤¤ò¤è¤³¤·¤¿¡ª",chaos_patrons[p_ptr->chaos_patron]);
5455 msg_format("%s rewards you with a demonic servant!",chaos_patrons[p_ptr->chaos_patron]);
5458 if (!summon_specific(-1, py, px, dun_level, SUMMON_DEMON, PM_FORCE_PET))
5460 msg_print("²¿¤â¸½¤ì¤Ê¤«¤Ã¤¿...");
5462 msg_print("Nobody ever turns up...");
5466 reward = "°Ë⤬¥Ú¥Ã¥È¤Ë¤Ê¤Ã¤¿¡£";
5468 reward = "a demonic servant";
5474 msg_format("%s¤ÏË«Èþ¤È¤·¤Æ»È¤¤¤ò¤è¤³¤·¤¿¡ª",chaos_patrons[p_ptr->chaos_patron]);
5476 msg_format("%s rewards you with a servant!",chaos_patrons[p_ptr->chaos_patron]);
5479 if (!summon_specific(-1, py, px, dun_level, 0, PM_FORCE_PET))
5481 msg_print("²¿¤â¸½¤ì¤Ê¤«¤Ã¤¿...");
5483 msg_print("Nobody ever turns up...");
5487 reward = "¥â¥ó¥¹¥¿¡¼¤¬¥Ú¥Ã¥È¤Ë¤Ê¤Ã¤¿¡£";
5489 reward = "a servant";
5495 msg_format("%s¤ÏË«Èþ¤È¤·¤Æ¥¢¥ó¥Ç¥Ã¥É¤Î»È¤¤¤ò¤è¤³¤·¤¿¡£",chaos_patrons[p_ptr->chaos_patron]);
5497 msg_format("%s rewards you with an undead servant!",chaos_patrons[p_ptr->chaos_patron]);
5500 if (!summon_specific(-1, py, px, dun_level, SUMMON_UNDEAD, PM_FORCE_PET))
5502 msg_print("²¿¤â¸½¤ì¤Ê¤«¤Ã¤¿...");
5504 msg_print("Nobody ever turns up...");
5508 reward = "¥¢¥ó¥Ç¥Ã¥É¤¬¥Ú¥Ã¥È¤Ë¤Ê¤Ã¤¿¡£";
5510 reward = "an undead servant";
5516 msg_format("%s¤ÎÀ¼¤¬¤É¤â¤Ã¤¿:",
5518 msg_format("The voice of %s stammers:",
5521 chaos_patrons[p_ptr->chaos_patron]);
5523 msg_format("¡Ö¤¢¡¼¡¢¤¢¡¼¡¢Åú¤¨¤Ï %d/%d¡£¼ÁÌä¤Ï²¿¡©¡×", type, effect);
5525 msg_format("'Uh... uh... the answer's %d/%d, what's the question?'", type, effect);
5533 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, format("¥Ñ¥È¥í¥ó¤ÎÊó½·¤Ç%s", reward));
5535 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, format("The patron rewards you with %s.", reward));
5542 * old -- from PsiAngband.
5544 bool tgt_pt(int *x_ptr, int *y_ptr)
5548 bool success = FALSE;
5553 get_screen_size(&wid, &hgt);
5559 msg_print("¾ì½ê¤òÁª¤ó¤Ç¥¹¥Ú¡¼¥¹¥¡¼¤ò²¡¤·¤Æ²¼¤µ¤¤¡£");
5561 msg_print("Select a point and press space.");
5563 msg_flag = FALSE; /* prevents "-more-" message. */
5565 while ((ch != ESCAPE) && !success)
5567 bool move_fast = FALSE;
5569 move_cursor_relative(y, x);
5581 if (x == px && y == py) ch = 0;
5584 else success = TRUE;
5588 /* Look up the direction */
5589 d = get_keymap_dir(ch);
5591 /* XTRA HACK MOVEFAST */
5592 if (isupper(ch)) move_fast = TRUE;
5594 /* Handle "direction" */
5600 /* XTRA HACK MOVEFAST */
5603 int mag = MIN(wid / 2, hgt / 2);
5613 /* Do not move horizontally if unnecessary */
5614 if (((x < panel_col_min + wid / 2) && (dx > 0)) ||
5615 ((x > panel_col_min + wid / 2) && (dx < 0)))
5620 /* Do not move vertically if unnecessary */
5621 if (((y < panel_row_min + hgt / 2) && (dy > 0)) ||
5622 ((y > panel_row_min + hgt / 2) && (dy < 0)))
5627 /* Apply the motion */
5628 if ((y >= panel_row_min + hgt) || (y < panel_row_min) ||
5629 (x >= panel_col_min + wid) || (x < panel_col_min))
5631 /* if (change_panel(dy, dx)) target_set_prepare(mode); */
5632 change_panel(dy, dx);
5635 /* Slide into legality */
5636 if (x >= cur_wid-1) x = cur_wid - 2;
5637 else if (x <= 0) x = 1;
5639 /* Slide into legality */
5640 if (y >= cur_hgt-1) y = cur_hgt- 2;
5641 else if (y <= 0) y = 1;
5648 /* Clear the top line */
5651 /* Recenter the map around the player */
5655 p_ptr->update |= (PU_MONSTERS);
5658 p_ptr->redraw |= (PR_MAP);
5661 p_ptr->window |= (PW_OVERHEAD);
5672 bool get_hack_dir(int *dp)
5682 /* Global direction */
5685 /* (No auto-targeting) */
5687 /* Ask until satisfied */
5690 /* Choose a prompt */
5694 p = "Êý¸þ ('*'¤Ç¥¿¡¼¥²¥Ã¥ÈÁªÂò, ESC¤ÇÃæÃÇ)? ";
5696 p = "Direction ('*' to choose a target, Escape to cancel)? ";
5703 p = "Êý¸þ ('5'¤Ç¥¿¡¼¥²¥Ã¥È¤Ø, '*'¤Ç¥¿¡¼¥²¥Ã¥ÈºÆÁªÂò, ESC¤ÇÃæÃÇ)? ";
5705 p = "Direction ('5' for target, '*' to re-target, Escape to cancel)? ";
5710 /* Get a command (or Cancel) */
5711 if (!get_com(p, &command, TRUE)) break;
5715 if (command == '\r') command = 't';
5718 /* Convert various keys to "standard" keys */
5721 /* Use current target */
5732 /* Set new target */
5737 if (target_set(TARGET_KILL)) dir = 5;
5743 /* Look up the direction */
5744 dir = get_keymap_dir(command);
5750 /* Verify requested targets */
5751 if ((dir == 5) && !target_okay()) dir = 0;
5758 if (!dir) return (FALSE);
5760 /* Save the direction */
5763 /* Check for confusion */
5764 if (p_ptr->confused)
5767 /* Random direction */
5768 dir = ddd[randint0(8)];
5771 /* Notice confusion */
5772 if (command_dir != dir)
5776 msg_print("¤¢¤Ê¤¿¤Ïº®Í𤷤Ƥ¤¤ë¡£");
5778 msg_print("You are confused.");
5783 /* Save direction */
5786 /* A "valid" direction was entered */
5792 * ¥¨¥Í¥ë¥®¡¼¤ÎÁý²ÃÎÌ10d5¤ò®¤¯·×»»¤¹¤ë¤¿¤á¤Î´Ø¿ô
5795 #define Go_no_JuuJou 5*5*5*5*5*5*5*5*5*5
5797 s16b gain_energy(void)
5800 s32b energy_result = 10;
5803 tmp = randint0(Go_no_JuuJou);
5805 for (i = 0; i < 9; i ++){
5806 energy_result += tmp % 5;
5810 return (s16b)(energy_result + tmp);
5817 s16b bow_energy(int sval)
5821 /* Analyze the launcher */
5824 /* Sling and ammo */
5831 /* Short Bow and Arrow */
5838 /* Long Bow and Arrow */
5845 /* Bow of irresponsiblity and Arrow */
5852 /* Light Crossbow and Bolt */
5859 /* Heavy Crossbow and Bolt */
5874 int bow_tmul(int sval)
5878 /* Analyze the launcher */
5881 /* Sling and ammo */
5888 /* Short Bow and Arrow */
5895 /* Long Bow and Arrow */
5902 /* Bow of irresponsiblity and Arrow */
5909 /* Light Crossbow and Bolt */
5916 /* Heavy Crossbow and Bolt */
5928 * Return alignment title
5930 cptr your_alignment(void)
5933 if (p_ptr->align > 150) return "ÂçÁ±";
5934 else if (p_ptr->align > 50) return "ÃæÁ±";
5935 else if (p_ptr->align > 10) return "¾®Á±";
5936 else if (p_ptr->align > -11) return "ÃæΩ";
5937 else if (p_ptr->align > -51) return "¾®°";
5938 else if (p_ptr->align > -151) return "Ãæ°";
5941 if (p_ptr->align > 150) return "Lawful";
5942 else if (p_ptr->align > 50) return "Good";
5943 else if (p_ptr->align > 10) return "Neutral Good";
5944 else if (p_ptr->align > -11) return "Neutral";
5945 else if (p_ptr->align > -51) return "Neutral Evil";
5946 else if (p_ptr->align > -151) return "Evil";
5947 else return "Chaotic";