3 /* Purpose: effects of various "objects" */
6 * Copyright (c) 1989 James E. Wilson, Robert A. Koeneke
8 * This software may be copied and distributed for educational, research, and
9 * not for profit purposes provided that this copyright and statement are
10 * included in all such copies.
15 #define REWARD_CHANCE 10
19 * Advance experience levels and print experience
21 void check_experience(void)
24 bool level_reward = FALSE;
25 bool level_mutation = FALSE;
26 bool level_inc_stat = FALSE;
27 bool android = (p_ptr->prace == RACE_ANDROID ? TRUE : FALSE);
30 /* Note current level */
33 /* Hack -- lower limit */
34 if (p_ptr->exp < 0) p_ptr->exp = 0;
36 /* Hack -- lower limit */
37 if (p_ptr->max_exp < 0) p_ptr->max_exp = 0;
39 /* Hack -- upper limit */
40 if (p_ptr->exp > PY_MAX_EXP) p_ptr->exp = PY_MAX_EXP;
42 /* Hack -- upper limit */
43 if (p_ptr->max_exp > PY_MAX_EXP) p_ptr->max_exp = PY_MAX_EXP;
45 /* Hack -- maintain "max" experience */
46 if (p_ptr->exp > p_ptr->max_exp) p_ptr->max_exp = p_ptr->exp;
48 /* Redraw experience */
49 p_ptr->redraw |= (PR_EXP);
55 /* Lose levels while possible */
56 while ((p_ptr->lev > 1) &&
57 (p_ptr->exp < ((android ? player_exp_a : player_exp)[p_ptr->lev - 2] * p_ptr->expfact / 100L)))
63 /* Update some stuff */
64 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
66 /* Redraw some stuff */
67 p_ptr->redraw |= (PR_LEV | PR_TITLE);
70 p_ptr->window |= (PW_PLAYER);
77 /* Gain levels while possible */
78 while ((p_ptr->lev < PY_MAX_LEVEL) &&
79 (p_ptr->exp >= ((android ? player_exp_a : player_exp)[p_ptr->lev-1] * p_ptr->expfact / 100L)))
85 /* Save the highest level */
86 if (p_ptr->lev > p_ptr->max_plv)
88 p_ptr->max_plv = p_ptr->lev;
90 if ((p_ptr->pclass == CLASS_CHAOS_WARRIOR) ||
91 (p_ptr->muta2 & MUT2_CHAOS_GIFT))
95 if (p_ptr->prace == RACE_BEASTMAN)
97 if (randint(5) == 1) level_mutation = TRUE;
99 level_inc_stat = TRUE;
101 do_cmd_write_nikki(NIKKI_LEVELUP, p_ptr->lev, NULL);
109 msg_format("¥ì¥Ù¥ë %d ¤Ë¤è¤¦¤³¤½¡£", p_ptr->lev);
111 msg_format("Welcome to level %d.", p_ptr->lev);
114 /* Update some stuff */
115 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
117 /* Redraw some stuff */
118 p_ptr->redraw |= (PR_LEV | PR_TITLE);
121 p_ptr->window |= (PW_PLAYER | PW_SPELL);
134 gain_level_reward(0);
135 level_reward = FALSE;
140 if(!(p_ptr->max_plv % 10))
150 cnv_stat(p_ptr->stat_max[0], tmp);
151 prt(format(" a) ÏÓÎÏ (¸½ºßÃÍ %s)", tmp), 2, 14);
152 cnv_stat(p_ptr->stat_max[1], tmp);
153 prt(format(" b) ÃÎǽ (¸½ºßÃÍ %s)", tmp), 3, 14);
154 cnv_stat(p_ptr->stat_max[2], tmp);
155 prt(format(" c) ¸¤µ (¸½ºßÃÍ %s)", tmp), 4, 14);
156 cnv_stat(p_ptr->stat_max[3], tmp);
157 prt(format(" d) ´ïÍÑ (¸½ºßÃÍ %s)", tmp), 5, 14);
158 cnv_stat(p_ptr->stat_max[4], tmp);
159 prt(format(" e) ÂÑµ× (¸½ºßÃÍ %s)", tmp), 6, 14);
160 cnv_stat(p_ptr->stat_max[5], tmp);
161 prt(format(" f) Ì¥ÎÏ (¸½ºßÃÍ %s)", tmp), 7, 14);
163 prt(" ¤É¤ÎǽÎÏÃͤò¾å¤²¤Þ¤¹¤«¡©", 1, 14);
165 cnv_stat(p_ptr->stat_max[0], tmp);
166 prt(format(" a) Str (cur %s)", tmp), 2, 14);
167 cnv_stat(p_ptr->stat_max[1], tmp);
168 prt(format(" b) Int (cur %s)", tmp), 3, 14);
169 cnv_stat(p_ptr->stat_max[2], tmp);
170 prt(format(" c) Wis (cur %s)", tmp), 4, 14);
171 cnv_stat(p_ptr->stat_max[3], tmp);
172 prt(format(" d) Dex (cur %s)", tmp), 5, 14);
173 cnv_stat(p_ptr->stat_max[4], tmp);
174 prt(format(" e) Con (cur %s)", tmp), 6, 14);
175 cnv_stat(p_ptr->stat_max[5], tmp);
176 prt(format(" f) Chr (cur %s)", tmp), 7, 14);
178 prt(" Which stat do you want to raise?", 1, 14);
183 if ((choice >= 'a') && (choice <= 'f')) break;
185 for(n = 0; n < 6; n++)
186 if (n != choice - 'a')
189 if (get_check("¤è¤í¤·¤¤¤Ç¤¹¤«¡©")) break;
191 if (get_check("Are you sure? ")) break;
194 do_inc_stat(choice - 'a');
197 else if(!(p_ptr->max_plv % 2))
198 do_inc_stat(rand_int(6));
204 msg_print("¤¢¤Ê¤¿¤ÏÊѤï¤Ã¤¿µ¤¤¬¤¹¤ë...");
206 msg_print("You feel different...");
209 (void)gain_random_mutation(0);
210 level_mutation = FALSE;
213 /* Update some stuff */
214 p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
216 /* Redraw some stuff */
217 p_ptr->redraw |= (PR_LEV | PR_TITLE);
220 p_ptr->window |= (PW_PLAYER | PW_SPELL);
229 * Hack -- Return the "automatic coin type" of a monster race
230 * Used to allocate proper treasure when "Creeping coins" die
232 * XXX XXX XXX Note the use of actual "monster names"
234 static int get_coin_type(int r_idx)
236 monster_race *r_ptr = &r_info[r_idx];
238 /* Analyze "coin" monsters */
239 if (r_ptr->d_char == '$')
241 /* Look for textual clues */
244 case MON_COPPER_COINS: return (2);
245 case MON_SILVER_COINS: return (5);
246 case MON_GOLD_COINS: return (10);
247 case MON_MITHRIL_COINS: return (16);
248 case MON_ADAMANT_COINS: return (17);
258 * Hack -- determine if a template is Cloak
260 static bool kind_is_cloak(int k_idx)
262 object_kind *k_ptr = &k_info[k_idx];
264 /* Analyze the item type */
265 if (k_ptr->tval == TV_CLOAK)
270 /* Assume not good */
276 * Hack -- determine if a template is Polearm
278 static bool kind_is_polearm(int k_idx)
280 object_kind *k_ptr = &k_info[k_idx];
282 /* Analyze the item type */
283 if (k_ptr->tval == TV_POLEARM)
288 /* Assume not good */
294 * Hack -- determine if a template is Sword
296 static bool kind_is_sword(int k_idx)
298 object_kind *k_ptr = &k_info[k_idx];
300 /* Analyze the item type */
301 if ((k_ptr->tval == TV_SWORD) && (k_ptr->sval > 2))
306 /* Assume not good */
312 * Hack -- determine if a template is Book
314 static bool kind_is_book(int k_idx)
316 object_kind *k_ptr = &k_info[k_idx];
318 /* Analyze the item type */
319 if ((k_ptr->tval >= TV_LIFE_BOOK) && (k_ptr->tval <= TV_DAEMON_BOOK))
324 /* Assume not good */
330 * Hack -- determine if a template is Good book
332 static bool kind_is_good_book(int k_idx)
334 object_kind *k_ptr = &k_info[k_idx];
336 /* Analyze the item type */
337 if ((k_ptr->tval >= TV_LIFE_BOOK) && (k_ptr->tval <= TV_DAEMON_BOOK) && (k_ptr->tval != TV_ARCANE_BOOK) && (k_ptr->sval > 1))
342 /* Assume not good */
348 * Hack -- determine if a template is Armor
350 static bool kind_is_armor(int k_idx)
352 object_kind *k_ptr = &k_info[k_idx];
354 /* Analyze the item type */
355 if (k_ptr->tval == TV_HARD_ARMOR)
360 /* Assume not good */
366 * Check for "Quest" completion when a quest monster is killed or charmed.
368 void check_quest_completion(monster_type *m_ptr)
370 int i, j, y, x, ny, nx, i2, j2;
374 bool create_stairs = FALSE;
380 /* Get the location */
385 quest_num = p_ptr->inside_quest;
387 /* Search for an active quest on this dungeon level */
390 for (i = max_quests - 1; i > 0; i--)
392 /* Quest is not active */
393 if (quest[i].status != QUEST_STATUS_TAKEN)
396 /* Quest is not a dungeon quest */
397 if (quest[i].flags & QUEST_FLAG_PRESET)
400 /* Quest is not on this level */
401 if ((quest[i].level != dun_level) &&
402 (quest[i].type != QUEST_TYPE_KILL_ANY_LEVEL))
405 /* Not a "kill monster" quest */
406 if ((quest[i].type == QUEST_TYPE_FIND_ARTIFACT) ||
407 (quest[i].type == QUEST_TYPE_FIND_EXIT))
410 /* Interesting quest */
411 if ((quest[i].type == QUEST_TYPE_KILL_NUMBER) ||
412 (quest[i].type == QUEST_TYPE_KILL_ALL))
415 /* Interesting quest */
416 if (((quest[i].type == QUEST_TYPE_KILL_LEVEL) ||
417 (quest[i].type == QUEST_TYPE_KILL_ANY_LEVEL) ||
418 (quest[i].type == QUEST_TYPE_RANDOM)) &&
419 (quest[i].r_idx == m_ptr->r_idx))
426 /* Handle the current quest */
427 if (quest_num && (quest[quest_num].status == QUEST_STATUS_TAKEN))
432 switch (quest[i].type)
434 case QUEST_TYPE_KILL_NUMBER:
438 if (quest[i].cur_num >= quest[i].num_mon)
440 if (record_fix_quest) do_cmd_write_nikki(NIKKI_FIX_QUEST_C, i, NULL);
441 /* completed quest */
442 quest[i].status = QUEST_STATUS_COMPLETED;
443 quest[i].complev = p_ptr->lev;
445 if (!(quest[i].flags & QUEST_FLAG_SILENT))
448 msg_print("¥¯¥¨¥¹¥È¤òãÀ®¤·¤¿¡ª");
450 msg_print("You just completed your quest!");
456 quest[i].cur_num = 0;
460 case QUEST_TYPE_KILL_ALL:
464 if (!is_hostile(m_ptr)) break;
466 /* Count all hostile monsters */
467 for (i2 = 0; i2 < cur_wid; ++i2)
468 for (j2 = 0; j2 < cur_hgt; j2++)
469 if (cave[j2][i2].m_idx > 0)
470 if (is_hostile(&m_list[cave[j2][i2].m_idx]))
473 if ((number_mon - 1) == 0)
475 if (record_fix_quest) do_cmd_write_nikki(NIKKI_FIX_QUEST_C, i, NULL);
477 if (quest[i].flags & QUEST_FLAG_SILENT)
479 quest[i].status = QUEST_STATUS_FINISHED;
483 quest[i].status = QUEST_STATUS_COMPLETED;
484 quest[i].complev = p_ptr->lev;
486 msg_print("¥¯¥¨¥¹¥È¤òãÀ®¤·¤¿¡ª");
488 msg_print("You just completed your quest!");
496 case QUEST_TYPE_KILL_LEVEL:
497 case QUEST_TYPE_RANDOM:
499 /* Only count valid monsters */
500 if (quest[i].r_idx != m_ptr->r_idx)
505 if (quest[i].cur_num >= quest[i].max_num)
507 if (record_fix_quest && (quest[i].type == QUEST_TYPE_KILL_LEVEL)) do_cmd_write_nikki(NIKKI_FIX_QUEST_C, i, NULL);
508 if (record_rand_quest && (quest[i].type == QUEST_TYPE_RANDOM)) do_cmd_write_nikki(NIKKI_RAND_QUEST_C, i, NULL);
509 /* completed quest */
510 quest[i].status = QUEST_STATUS_COMPLETED;
511 quest[i].complev = p_ptr->lev;
512 if (!(quest[i].flags & QUEST_FLAG_PRESET))
514 create_stairs = TRUE;
515 p_ptr->inside_quest = 0;
518 if (!quest[i].flags & QUEST_FLAG_SILENT)
521 msg_print("¥¯¥¨¥¹¥È¤òãÀ®¤·¤¿¡ª");
523 msg_print("You just completed your quest!");
529 /* Finish the two main quests without rewarding */
530 if ((i == QUEST_OBERON) || (i == QUEST_SERPENT))
532 quest[i].status = QUEST_STATUS_FINISHED;
535 if (quest[i].type == QUEST_TYPE_RANDOM)
538 quest[i].status = QUEST_STATUS_FINISHED;
543 case QUEST_TYPE_KILL_ANY_LEVEL:
546 if (quest[i].cur_num >= quest[i].max_num)
548 if (record_fix_quest) do_cmd_write_nikki(NIKKI_FIX_QUEST_C, i, NULL);
549 /* completed quest */
550 quest[i].status = QUEST_STATUS_COMPLETED;
551 quest[i].complev = p_ptr->lev;
553 if (!quest[i].flags & QUEST_FLAG_SILENT)
556 msg_print("¥¯¥¨¥¹¥È¤òãÀ®¤·¤¿¡ª");
558 msg_print("You just completed your quest!");
563 quest[i].cur_num = 0;
570 /* Create a magical staircase */
574 while (cave_perma_bold(y, x) || cave[y][x].o_idx)
576 /* Pick a location */
577 scatter(&ny, &nx, y, x, 1, 0);
583 /* Explain the staircase */
585 msg_print("ËâË¡¤Î³¬Ãʤ¬¸½¤ì¤¿...");
587 msg_print("A magical staircase appears...");
591 /* Create stairs down */
592 cave_set_feat(y, x, FEAT_MORE);
594 /* Delete invisible trap */
595 cave[y][x].info &= ~(CAVE_TRAP);
597 /* Remember to update everything */
598 p_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MONSTERS);
606 for (j = 0; j < (dun_level / 15)+1; j++)
608 /* Get local object */
611 /* Wipe the object */
614 /* Make a great object */
615 make_object(q_ptr, TRUE, TRUE);
618 q_ptr->python = object_create_callback(q_ptr);
619 #endif /* USE_SCRIPT */
621 /* Drop it in the dungeon */
622 (void)drop_near(q_ptr, -1, y, x);
628 * Handle the "death" of a monster.
630 * Disperse treasures centered at the monster location based on the
631 * various flags contained in the monster flags fields.
633 * Check for "Quest" completion when a quest monster is killed.
635 * Note that only the player can induce "monster_death()" on Uniques.
636 * Thus (for now) all Quest monsters should be Uniques.
638 * Note that monsters can now carry objects, and when a monster dies,
639 * it drops all of its objects, which may disappear in crowded rooms.
641 void monster_death(int m_idx, bool drop_item)
650 monster_type *m_ptr = &m_list[m_idx];
652 monster_race *r_ptr = &r_info[m_ptr->r_idx];
654 bool visible = (m_ptr->ml || (r_ptr->flags1 & RF1_UNIQUE));
656 bool good = (r_ptr->flags1 & RF1_DROP_GOOD) ? TRUE : FALSE;
657 bool great = (r_ptr->flags1 & RF1_DROP_GREAT) ? TRUE : FALSE;
659 bool do_gold = (!(r_ptr->flags1 & RF1_ONLY_ITEM));
660 bool do_item = (!(r_ptr->flags1 & RF1_ONLY_GOLD));
662 int force_coin = get_coin_type(m_ptr->r_idx);
668 if (world_monster) world_monster = FALSE;
670 /* Notice changes in view */
671 if (r_ptr->flags7 & (RF7_HAS_LITE_1 | RF7_HAS_LITE_2 | RF7_SELF_LITE_1 | RF7_SELF_LITE_2))
673 /* Update some things */
674 p_ptr->update |= (PU_MON_LITE);
677 /* Get the location */
681 if (m_ptr->smart & SM_CLONED)
684 if (record_named_pet && is_pet(m_ptr) && m_ptr->nickname)
688 monster_desc(m_name, m_ptr, 0x08);
689 do_cmd_write_nikki(NIKKI_NAMED_PET, 3, m_name);
692 /* Let monsters explode! */
693 for (i = 0; i < 4; i++)
695 if ((r_ptr->blow[i].method == RBM_EXPLODE) || (m_ptr->r_idx == MON_ROLENTO))
697 int flg = PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL;
698 int typ = GF_MISSILE;
699 int d_dice = r_ptr->blow[i].d_dice;
700 int d_side = r_ptr->blow[i].d_side;
701 int damage = damroll(d_dice, d_side);
703 switch (r_ptr->blow[i].effect)
705 case RBE_HURT: typ = GF_MISSILE; break;
706 case RBE_POISON: typ = GF_POIS; break;
707 case RBE_UN_BONUS: typ = GF_DISENCHANT; break;
708 case RBE_UN_POWER: typ = GF_MISSILE; break; /* ToDo: Apply the correct effects */
709 case RBE_EAT_GOLD: typ = GF_MISSILE; break;
710 case RBE_EAT_ITEM: typ = GF_MISSILE; break;
711 case RBE_EAT_FOOD: typ = GF_MISSILE; break;
712 case RBE_EAT_LITE: typ = GF_MISSILE; break;
713 case RBE_ACID: typ = GF_ACID; break;
714 case RBE_ELEC: typ = GF_ELEC; break;
715 case RBE_FIRE: typ = GF_FIRE; break;
716 case RBE_COLD: typ = GF_COLD; break;
717 case RBE_BLIND: typ = GF_MISSILE; break;
718 case RBE_CONFUSE: typ = GF_CONFUSION; break;
719 case RBE_TERRIFY: typ = GF_MISSILE; break;
720 case RBE_PARALYZE: typ = GF_MISSILE; break;
721 case RBE_LOSE_STR: typ = GF_MISSILE; break;
722 case RBE_LOSE_DEX: typ = GF_MISSILE; break;
723 case RBE_LOSE_CON: typ = GF_MISSILE; break;
724 case RBE_LOSE_INT: typ = GF_MISSILE; break;
725 case RBE_LOSE_WIS: typ = GF_MISSILE; break;
726 case RBE_LOSE_CHR: typ = GF_MISSILE; break;
727 case RBE_LOSE_ALL: typ = GF_MISSILE; break;
728 case RBE_SHATTER: typ = GF_ROCKET; break;
729 case RBE_EXP_10: typ = GF_MISSILE; break;
730 case RBE_EXP_20: typ = GF_MISSILE; break;
731 case RBE_EXP_40: typ = GF_MISSILE; break;
732 case RBE_EXP_80: typ = GF_MISSILE; break;
733 case RBE_DISEASE: typ = GF_POIS; break;
734 case RBE_TIME: typ = GF_TIME; break;
735 case RBE_EXP_VAMP: typ = GF_MISSILE; break;
736 case RBE_DR_MANA: typ = GF_MANA; break;
737 case RBE_SUPERHURT: typ = GF_MISSILE; break;
739 if (m_ptr->r_idx == MON_ROLENTO)
742 damage = damroll(20,10);
745 project(m_idx, 3, y, x, damage, typ, flg, -1);
750 if (m_ptr->mflag2 & MFLAG_CHAMELEON)
752 choose_new_monster(m_idx, TRUE, MON_CHAMELEON);
753 r_ptr = &r_info[m_ptr->r_idx];
756 /* Check for quest completion */
757 check_quest_completion(m_ptr);
759 /* Handle the possibility of player vanquishing arena combatant -KMW- */
760 if (p_ptr->inside_arena && !is_pet(m_ptr))
764 /* Extract monster name */
765 monster_desc(m_name, m_ptr, 0);
767 p_ptr->exit_bldg = TRUE;
769 if (p_ptr->arena_number > MAX_ARENA_MONS)
772 msg_print("ÁÇÀ²¤é¤·¤¤¡ª·¯¤³¤½¿¿¤Î¾¡Íø¼Ô¤À¡£");
774 msg_print("You are a Genuine Champion!");
780 msg_print("¾¡Íø¡ª¥Á¥ã¥ó¥Ô¥ª¥ó¤Ø¤ÎÆ»¤ò¿Ê¤ó¤Ç¤¤¤ë¡£");
782 msg_print("Victorious! You're on your way to becoming Champion.");
786 if (arena_shouhin[p_ptr->arena_number])
788 /* Get local object */
791 /* Prepare to make a Blade of Chaos */
792 object_prep(q_ptr, lookup_kind(k_info[arena_shouhin[p_ptr->arena_number]].tval, k_info[arena_shouhin[p_ptr->arena_number]].sval));
794 apply_magic(q_ptr, object_level, FALSE, FALSE, FALSE, FALSE);
797 q_ptr->python = object_create_callback(q_ptr);
798 #endif /* USE_SCRIPT */
800 /* Drop it in the dungeon */
801 (void)drop_near(q_ptr, -1, y, x);
804 if (p_ptr->arena_number > MAX_ARENA_MONS) p_ptr->arena_number++;
805 p_ptr->arena_number++;
806 if (record_arena) do_cmd_write_nikki(NIKKI_ARENA, p_ptr->arena_number, m_name);
809 if (m_idx == p_ptr->riding)
811 if (rakuba(-1, FALSE))
814 msg_print("ÃÏÌ̤ËÍî¤È¤µ¤ì¤¿¡£");
816 msg_print("You have fallen from your riding pet.");
821 /* Drop a dead corpse? */
822 if ((randint(r_ptr->flags1 & RF1_UNIQUE ? 1 : 4) == 1) &&
823 ((r_ptr->flags9 & RF9_DROP_CORPSE) ||
824 (r_ptr->flags9 & RF9_DROP_SKELETON)) &&
825 !(p_ptr->inside_arena || p_ptr->inside_battle || ((m_ptr->r_idx == today_mon) && is_pet(m_ptr))))
827 /* Assume skeleton */
831 * We cannot drop a skeleton? Note, if we are in this check,
832 * we *know* we can drop at least a corpse or a skeleton
834 if (!(r_ptr->flags9 & RF9_DROP_SKELETON))
836 else if ((r_ptr->flags9 & RF9_DROP_CORPSE) && (r_ptr->flags1 && RF1_UNIQUE))
839 /* Else, a corpse is more likely unless we did a "lot" of damage */
840 else if (r_ptr->flags9 & RF9_DROP_CORPSE)
842 /* Lots of damage in one blow */
843 if ((0 - ((m_ptr->maxhp) / 4)) > m_ptr->hp)
845 if (randint(5) == 1) corpse = TRUE;
849 if (randint(5) != 1) corpse = TRUE;
853 /* Get local object */
856 /* Prepare to make a Blade of Chaos */
857 object_prep(q_ptr, lookup_kind(TV_CORPSE, (corpse ? SV_CORPSE : SV_SKELETON)));
859 apply_magic(q_ptr, object_level, FALSE, FALSE, FALSE, FALSE);
861 q_ptr->pval = m_ptr->r_idx;
864 q_ptr->python = object_create_callback(q_ptr);
865 #endif /* USE_SCRIPT */
867 /* Drop it in the dungeon */
868 (void)drop_near(q_ptr, -1, y, x);
871 /* Drop objects being carried */
872 monster_drop_carried_objects(m_ptr);
875 * Mega^3-hack: killing a 'Warrior of the Dawn' is likely to
876 * spawn another in the fallen one's place!
878 if (m_ptr->r_idx == MON_DAWN &&
879 !(p_ptr->inside_arena || p_ptr->inside_battle))
883 int wy = py, wx = px;
885 bool pet = is_pet(m_ptr);
889 scatter(&wy, &wx, py, px, 20, 0);
891 while (!(in_bounds(wy, wx) && cave_floor_bold(wy, wx)) && --attempts);
895 if (summon_specific((pet ? -1 : 0), wy, wx, 100, SUMMON_DAWN, FALSE, is_friendly(m_ptr), pet, FALSE, FALSE))
897 if (player_can_see_bold(wy, wx))
899 msg_print("¿·¤¿¤ÊÀï»Î¤¬¸½¤ì¤¿¡ª");
901 msg_print("A new warrior steps forth!");
909 /* Pink horrors are replaced with 2 Blue horrors */
910 else if (m_ptr->r_idx == MON_PINK_HORROR &&
911 !(p_ptr->inside_arena || p_ptr->inside_battle))
915 for (i = 0; i < 2; i++)
918 bool pet = is_pet(m_ptr);
920 if (summon_specific((pet ? -1 : 0), wy, wx, 100, SUMMON_BLUE_HORROR, FALSE, is_friendly(m_ptr), pet, FALSE, FALSE))
922 if (player_can_see_bold(wy, wx))
929 msg_print("¥Ô¥ó¥¯¡¦¥Û¥é¡¼¤ÏʬÎö¤·¤¿¡ª");
931 msg_print("The Pink horror divides!");
935 /* One more ultra-hack: An Unmaker goes out with a big bang! */
936 else if (m_ptr->r_idx == MON_UNMAKER)
939 int flg = PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL;
940 (void)project(m_idx, 6, y, x, 100, GF_CHAOS, flg, -1);
943 /* Bloodletters of Khorne may drop a blade of chaos */
944 else if (m_ptr->r_idx == MON_BLOODLETTER &&
946 (randint(100) < 15) &&
947 !(p_ptr->inside_arena || p_ptr->inside_battle))
949 /* Get local object */
952 /* Prepare to make a Blade of Chaos */
953 object_prep(q_ptr, lookup_kind(TV_SWORD, SV_BLADE_OF_CHAOS));
955 apply_magic(q_ptr, object_level, FALSE, FALSE, FALSE, FALSE);
958 q_ptr->python = object_create_callback(q_ptr);
959 #endif /* USE_SCRIPT */
961 /* Drop it in the dungeon */
962 (void)drop_near(q_ptr, -1, y, x);
965 else if (m_ptr->r_idx == MON_RAAL &&
967 !(p_ptr->inside_arena || p_ptr->inside_battle))
969 /* Get local object */
972 /* Wipe the object */
975 /* Activate restriction */
976 if ((dun_level > 49) && one_in_(5))
977 get_obj_num_hook = kind_is_good_book;
979 get_obj_num_hook = kind_is_book;
981 /* Prepare allocation table */
984 /* Make a great object */
985 make_object(q_ptr, FALSE, FALSE);
988 q_ptr->python = object_create_callback(q_ptr);
989 #endif /* USE_SCRIPT */
991 /* Drop it in the dungeon */
992 (void)drop_near(q_ptr, -1, y, x);
995 else if (m_ptr->r_idx == MON_B_DEATH_SWORD &&
996 !(p_ptr->inside_arena || p_ptr->inside_battle))
998 /* Get local object */
1001 /* Prepare to make a Blade of Chaos */
1002 object_prep(q_ptr, lookup_kind(TV_SWORD, randint(2)));
1005 q_ptr->python = object_create_callback(q_ptr);
1006 #endif /* USE_SCRIPT */
1008 /* Drop it in the dungeon */
1009 (void)drop_near(q_ptr, -1, y, x);
1012 else if ((r_ptr->d_char == '|') && !(r_ptr->flags1 & RF1_DROP_CHOSEN) &&
1013 !(p_ptr->inside_arena || p_ptr->inside_battle))
1015 /* Get local object */
1018 /* Wipe the object */
1021 /* Activate restriction */
1022 get_obj_num_hook = kind_is_sword;
1024 /* Prepare allocation table */
1027 /* Make a great object */
1028 make_object(q_ptr, FALSE, FALSE);
1031 q_ptr->python = object_create_callback(q_ptr);
1032 #endif /* USE_SCRIPT */
1034 /* Drop it in the dungeon */
1035 (void)drop_near(q_ptr, -1, y, x);
1038 else if ((r_ptr->d_char == '(') && (dun_level > 0) &&
1039 !(p_ptr->inside_arena || p_ptr->inside_battle))
1041 /* Get local object */
1044 /* Wipe the object */
1047 /* Activate restriction */
1048 get_obj_num_hook = kind_is_cloak;
1050 /* Prepare allocation table */
1053 /* Make a great object */
1054 make_object(q_ptr, FALSE, FALSE);
1057 q_ptr->python = object_create_callback(q_ptr);
1058 #endif /* USE_SCRIPT */
1060 /* Drop it in the dungeon */
1061 (void)drop_near(q_ptr, -1, y, x);
1064 else if ((r_ptr->d_char == '/') && (dun_level > 4) &&
1065 !(p_ptr->inside_arena || p_ptr->inside_battle))
1067 /* Get local object */
1070 /* Wipe the object */
1073 /* Activate restriction */
1074 get_obj_num_hook = kind_is_polearm;
1076 /* Prepare allocation table */
1079 /* Make a great object */
1080 make_object(q_ptr, FALSE, FALSE);
1083 q_ptr->python = object_create_callback(q_ptr);
1084 #endif /* USE_SCRIPT */
1086 /* Drop it in the dungeon */
1087 (void)drop_near(q_ptr, -1, y, x);
1090 else if ((r_ptr->d_char == '[') && (dun_level > 19) &&
1091 !(p_ptr->inside_arena || p_ptr->inside_battle))
1093 /* Get local object */
1096 /* Wipe the object */
1099 /* Activate restriction */
1100 get_obj_num_hook = kind_is_armor;
1102 /* Prepare allocation table */
1105 /* Make a great object */
1106 make_object(q_ptr, FALSE, FALSE);
1109 q_ptr->python = object_create_callback(q_ptr);
1110 #endif /* USE_SCRIPT */
1112 /* Drop it in the dungeon */
1113 (void)drop_near(q_ptr, -1, y, x);
1116 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))
1118 /* Get local object */
1121 /* Prepare to make a Blade of Chaos */
1122 object_prep(q_ptr, lookup_kind(TV_CHEST, 50));
1124 apply_magic(q_ptr, object_level, FALSE, FALSE, FALSE, FALSE);
1127 q_ptr->python = object_create_callback(q_ptr);
1128 #endif /* USE_SCRIPT */
1130 /* Drop it in the dungeon */
1131 (void)drop_near(q_ptr, -1, y, x);
1133 /* Mega-Hack -- drop "winner" treasures */
1134 else if (r_ptr->flags1 & RF1_DROP_CHOSEN)
1136 if (m_ptr->r_idx == MON_SERPENT)
1139 /* Get local object */
1142 /* Mega-Hack -- Prepare to make "Grond" */
1143 object_prep(q_ptr, lookup_kind(TV_HAFTED, SV_GROND));
1145 /* Mega-Hack -- Mark this item as "Grond" */
1146 q_ptr->name1 = ART_GROND;
1148 /* Mega-Hack -- Actually create "Grond" */
1149 apply_magic(q_ptr, -1, TRUE, TRUE, TRUE, FALSE);
1152 q_ptr->python = object_create_callback(q_ptr);
1153 #endif /* USE_SCRIPT */
1155 /* Drop it in the dungeon */
1156 (void)drop_near(q_ptr, -1, y, x);
1158 /* Get local object */
1161 /* Mega-Hack -- Prepare to make "Morgoth" */
1162 object_prep(q_ptr, lookup_kind(TV_CROWN, SV_MORGOTH));
1164 /* Mega-Hack -- Mark this item as "Morgoth" */
1165 q_ptr->name1 = ART_MORGOTH;
1167 /* Mega-Hack -- Actually create "Morgoth" */
1168 apply_magic(q_ptr, -1, TRUE, TRUE, TRUE, FALSE);
1171 q_ptr->python = object_create_callback(q_ptr);
1172 #endif /* USE_SCRIPT */
1174 /* Drop it in the dungeon */
1175 (void)drop_near(q_ptr, -1, y, x);
1182 if (m_ptr->r_idx == MON_OBERON)
1184 if (randint(3) == 1)
1195 else if ((m_ptr->r_idx == MON_UNICORN_ORD ||
1196 m_ptr->r_idx == MON_MORGOTH ||
1197 m_ptr->r_idx == MON_ONE_RING)
1198 && (p_ptr->pseikaku == SEIKAKU_NAMAKE))
1204 a_idx = ART_NAMAKE_HAMMER;
1207 else if (one_in_(2))
1209 a_idx = ART_NAMAKE_BOW;
1214 a_idx = ART_NAMAKE_ARMOR;
1218 while (a_info[a_idx].cur_num);
1220 else if (m_ptr->r_idx == MON_GHB)
1225 else if (m_ptr->r_idx == MON_STORMBRINGER)
1227 a_idx = ART_STORMBRINGER;
1230 else if (m_ptr->r_idx == MON_ECHIZEN)
1232 a_idx = ART_CRIMSON;
1235 else if (m_ptr->r_idx == MON_GANDALF)
1240 else if (m_ptr->r_idx == MON_OROCHI)
1242 a_idx = ART_KUSANAGI;
1245 else if (m_ptr->r_idx == MON_DWORKIN)
1250 else if (m_ptr->r_idx == MON_SAURON)
1252 if (randint(10) == 1)
1263 else if (m_ptr->r_idx == MON_BRAND)
1265 if (randint(3) != 1)
1272 a_idx = ART_ANGUIREL;
1276 else if (m_ptr->r_idx == MON_CORWIN)
1278 if (randint(3) != 1)
1280 a_idx = ART_GRAYSWANDIR;
1289 else if (m_ptr->r_idx == MON_SURTUR)
1291 a_idx = ART_MORMEGIL;
1294 else if (m_ptr->r_idx == MON_SARUMAN)
1296 a_idx = ART_ELENDIL;
1299 else if (m_ptr->r_idx == MON_FIONA)
1301 a_idx = ART_BELANGIL;
1304 else if (m_ptr->r_idx == MON_JULIAN)
1306 a_idx = ART_CELEBORN;
1309 else if (m_ptr->r_idx == MON_KLING)
1314 else if (m_ptr->r_idx == MON_GOEMON)
1316 a_idx = ART_ZANTETSU;
1319 else if (m_ptr->r_idx == MON_HAGEN)
1321 a_idx = ART_NIMLOTH;
1324 else if (m_ptr->r_idx == MON_CAIN)
1326 a_idx = ART_ANGRIST;
1329 else if (m_ptr->r_idx == MON_BULLGATES)
1331 a_idx = ART_WINBLOWS;
1334 else if (m_ptr->r_idx == MON_LUNGORTHIN)
1339 else if (m_ptr->r_idx == MON_JACK_SHADOWS)
1344 else if (m_ptr->r_idx == MON_DIO)
1346 a_idx = ART_STONEMASK;
1349 else if (m_ptr->r_idx == MON_BELD)
1351 a_idx = ART_SOULCRUSH;
1354 else if (m_ptr->r_idx == MON_PIP)
1356 a_idx = ART_EXCALIBUR_J;
1360 else if (m_ptr->r_idx == MON_SHUTEN)
1362 a_idx = ART_SHUTEN_DOJI;
1366 else if (m_ptr->r_idx == MON_GOTHMOG)
1368 a_idx = ART_GOTHMOG;
1372 else if (m_ptr->r_idx == MON_FUNDIN)
1378 if ((a_idx > 0) && ((randint(99) < chance) || (wizard)))
1380 if (a_info[a_idx].cur_num == 0)
1382 /* Create the artifact */
1383 create_named_art(a_idx, y, x);
1385 a_info[a_idx].cur_num = 1;
1390 if ((r_ptr->flags7 & RF7_GUARDIAN) && !p_ptr->inside_battle && (d_info[dungeon_type].final_guardian == m_ptr->r_idx))
1392 if (d_info[dungeon_type].final_artifact)
1394 byte a_idx = d_info[dungeon_type].final_artifact;
1395 if (a_info[a_idx].cur_num == 0)
1397 /* Create the artifact */
1398 create_named_art(a_idx, y, x);
1400 a_info[a_idx].cur_num = 1;
1407 if (d_info[dungeon_type].final_object)
1408 k_idx = d_info[dungeon_type].final_object;
1409 else k_idx = 198;/* Acquirement */
1411 /* Get local object */
1414 /* Prepare to make a reward */
1415 object_prep(q_ptr, k_idx);
1417 apply_magic(q_ptr, object_level, FALSE, TRUE, FALSE, FALSE);
1420 q_ptr->python = object_create_callback(q_ptr);
1421 #endif /* USE_SCRIPT */
1423 /* Drop it in the dungeon */
1424 (void)drop_near(q_ptr, -1, y, x);
1427 msg_format("¤¢¤Ê¤¿¤Ï%s¤òÀ©ÇƤ·¤¿¡ª",d_name+d_info[dungeon_type].name);
1429 msg_format("You have conquered %s!",d_name+d_info[dungeon_type].name);
1433 /* Determine how much we can drop */
1434 if ((r_ptr->flags1 & RF1_DROP_60) && (rand_int(100) < 60)) number++;
1435 if ((r_ptr->flags1 & RF1_DROP_90) && (rand_int(100) < 90)) number++;
1436 if (r_ptr->flags1 & RF1_DROP_1D2) number += damroll(1, 2);
1437 if (r_ptr->flags1 & RF1_DROP_2D2) number += damroll(2, 2);
1438 if (r_ptr->flags1 & RF1_DROP_3D2) number += damroll(3, 2);
1439 if (r_ptr->flags1 & RF1_DROP_4D2) number += damroll(4, 2);
1441 if (cloned) number = 0; /* Clones drop no stuff */
1442 if (is_pet(m_ptr) || p_ptr->inside_battle || p_ptr->inside_arena) number = 0; /* Pets drop no stuff */
1443 if (!drop_item && (r_ptr->d_char != '$')) number = 0;
1445 /* Hack -- handle creeping coins */
1446 coin_type = force_coin;
1448 /* Average dungeon and monster levels */
1449 object_level = (dun_level + r_ptr->level) / 2;
1451 /* Drop some objects */
1452 for (j = 0; j < number; j++)
1454 /* Get local object */
1457 /* Wipe the object */
1461 if (do_gold && (!do_item || (rand_int(100) < 50)))
1463 /* Make some gold */
1464 if (!make_gold(q_ptr)) continue;
1473 /* Make an object */
1474 if (!make_object(q_ptr, good, great)) continue;
1481 q_ptr->python = object_create_callback(q_ptr);
1482 #endif /* USE_SCRIPT */
1484 /* Drop it in the dungeon */
1485 (void)drop_near(q_ptr, -1, y, x);
1488 /* Reset the object level */
1489 object_level = base_level;
1491 /* Reset "coin" type */
1495 /* Take note of any dropped treasure */
1496 if (visible && (dump_item || dump_gold))
1498 /* Take notes on treasure */
1499 lore_treasure(m_idx, dump_item, dump_gold);
1503 kill_monster_callback(m_idx);
1504 #endif /* USE_SCRIPT */
1506 /* Only process "Quest Monsters" */
1507 if (!(r_ptr->flags1 & RF1_QUESTOR)) return;
1508 if (p_ptr->inside_battle) return;
1511 if (m_ptr->r_idx == MON_SERPENT)
1514 total_winner = TRUE;
1516 /* Redraw the "title" */
1517 p_ptr->redraw |= (PR_TITLE);
1520 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, "¸«»ö¤ËÊѶòÈÚÅܤξ¡Íø¼Ô¤È¤Ê¤Ã¤¿¡ª");
1522 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, "become *WINNER* of Hengband finly!");
1525 if (p_ptr->pclass == CLASS_CHAOS_WARRIOR)
1528 msg_format("%s¤«¤é¤ÎÀ¼¤¬¶Á¤¤¤¿¡£", chaos_patrons[p_ptr->chaos_patron]);
1529 msg_print("¡Ø¤è¤¯¤ä¤Ã¤¿¡¢ÄêÌ¿¤Î¼Ô¤è¡ª¡Ù");
1531 msg_format("The voice of %s booms out:", chaos_patrons[p_ptr->chaos_patron]);
1532 msg_print("'Thou art donst well, mortal!'");
1536 /* Congratulations */
1538 msg_print("*** ¤ª¤á¤Ç¤È¤¦ ***");
1540 msg_print("*** CONGRATULATIONS ***");
1544 msg_print("¤¢¤Ê¤¿¤Ï¥²¡¼¥à¤ò¥³¥ó¥×¥ê¡¼¥È¤·¤Þ¤·¤¿¡£");
1546 msg_print("You have won the game!");
1550 msg_print("½àÈ÷¤¬À°¤Ã¤¿¤é°úÂà(¼«»¦¥³¥Þ¥ó¥É)¤·¤Æ¤â·ë¹½¤Ç¤¹¡£");
1552 msg_print("You may retire (commit suicide) when you are ready.");
1559 * Modify the physical damage done to the monster.
1560 * (for example when it's invulnerable or shielded)
1562 * ToDo: Accept a damage-type to calculate the modified damage from
1563 * things like fire, frost, lightning, poison, ... attacks.
1565 * "type" is not yet used and should be 0.
1567 int mon_damage_mod(monster_type *m_ptr, int dam, bool is_psy_spear)
1569 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1571 if ((r_ptr->flags3 & RF3_RES_ALL) && dam > 0)
1574 if((dam == 0) && (randint(3) == 1)) dam = 1;
1577 if (m_ptr->invulner)
1581 if(!p_ptr->blind && m_ptr->ml)
1584 msg_print("¥Ð¥ê¥¢¤òÀÚ¤êÎö¤¤¤¿¡ª");
1586 msg_print("The barrier is penetrated!");
1590 else if (!(randint(PENETRATE_INVULNERABILITY) == 1))
1598 static void get_exp_from_mon(int dam, monster_type *m_ptr)
1600 s32b div, new_exp, new_exp_frac;
1601 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1602 int monnum_penarty = 0;
1604 if (!m_ptr->r_idx) return;
1605 if (is_pet(m_ptr) || p_ptr->inside_battle) return;
1609 u32b m_exp_h, m_exp_l;
1611 if ((r_ptr->flags2 & RF2_MULTIPLY) || (m_ptr->r_idx == MON_DAWN))
1613 monnum_penarty = r_ptr->r_pkills / 400;
1614 if (monnum_penarty > 8) monnum_penarty = 8;
1616 if (r_ptr->flags1 & RF1_UNIQUE)
1618 m_exp = (long)r_ptr->mexp * r_ptr->level;
1619 div = (p_ptr->max_plv+2);
1623 m_exp = (long)r_ptr->mexp * r_ptr->level * extract_energy[m_ptr->mspeed];
1624 div = (p_ptr->max_plv+2) * extract_energy[r_ptr->speed];
1626 m_exp_h = m_exp/0x10000L;
1627 m_exp_l = m_exp%0x10000L;
1630 m_exp_h += m_exp_l / 0x10000L;
1631 m_exp_l %= 0x10000L;
1633 /* real monster maxhp have effect on EXP */
1634 if(!(r_ptr->flags1 & RF1_FORCE_MAXHP))
1636 u32b maxhp = m_ptr->max_maxhp*2;
1639 m_exp_h += m_exp_l / 0x10000L;
1640 m_exp_l %= 0x10000L;
1642 div *= r_ptr->hdice * (r_ptr->hside + 1);
1644 if (!dun_level && ((r_ptr->flags8 & RF8_DUNGEON) || !(r_ptr->flags1 & RF1_UNIQUE))) div *= 5;
1645 div_h = div/0x10000L;
1646 div_l = div%0x10000L;
1647 div_h *= (m_ptr->max_maxhp*2);
1648 div_l *= (m_ptr->max_maxhp*2);
1649 div_h += div_l / 0x10000L;
1652 while (monnum_penarty)
1656 div_h += div_l / 0x10000L;
1661 m_exp_l = (0x7fffffff & (m_exp_h << 16)) | m_exp_l;
1662 m_exp_h = m_exp_h >> 15;
1663 div_l = (0x7fffffff & (div_h << 16)) | div_l;
1664 div_h = div_h >> 15;
1666 #define M_INT_GREATER63(h1,l1,h2,l2) ( (h1>h2)||( (h1==h2)&&(l1>=l2)))
1667 #define M_INT_SUB63(h1,l1, h2,l2) {h1-=h2;if(l1<l2){l1+=0x80000000;h1--;}l1-=l2;}
1668 #define M_INT_LSHIFT63(h1,l1) {h1=(h1<<1)|(l1>>30);l1=(l1<<1)&0x7fffffff;}
1669 #define M_INT_RSHIFT63(h1,l1) {l1=(l1>>1)|(h1<<30);h1>>=1;}
1670 #define M_INT_DIV63(h1,l1,h2,l2,result) \
1674 while( M_INT_GREATER63(h1,l1, h2, l2) ){M_INT_LSHIFT63(h2, l2); bit<<=1;} \
1675 for(bit>>=1; bit>=1; bit>>=1){ \
1676 M_INT_RSHIFT63(h2, l2); \
1677 if(M_INT_GREATER63(h1, l1, h2, l2)) \
1678 {result|=bit;M_INT_SUB63(h1, l1, h2, l2);} \
1682 /* Give some experience for the kill */
1683 M_INT_DIV63(m_exp_h, m_exp_l, div_h, div_l, new_exp);
1685 /* Handle fractional experience */
1686 /* multiply 0x10000L to remainder */
1687 m_exp_h = (m_exp_h<<16) | (m_exp_l>>15);
1689 M_INT_DIV63(m_exp_h, m_exp_l, div_h, div_l, new_exp_frac);
1690 new_exp_frac += p_ptr->exp_frac;
1691 /* Keep track of experience */
1692 if (new_exp_frac >= 0x10000L)
1695 p_ptr->exp_frac = (u16b)(new_exp_frac - 0x10000L);
1699 p_ptr->exp_frac = (u16b)new_exp_frac;
1702 /* Gain experience */
1710 * Decreases monsters hit points, handling monster death.
1712 * We return TRUE if the monster has been killed (and deleted).
1714 * We announce monster death (using an optional "death message"
1715 * if given, and a otherwise a generic killed/destroyed message).
1717 * Only "physical attacks" can induce the "You have slain" message.
1718 * Missile and Spell attacks will induce the "dies" message, or
1719 * various "specialized" messages. Note that "You have destroyed"
1720 * and "is destroyed" are synonyms for "You have slain" and "dies".
1722 * Hack -- unseen monsters yield "You have killed it." message.
1724 * Added fear (DGK) and check whether to print fear messages -CWS
1726 * Made name, sex, and capitalization generic -BEN-
1728 * As always, the "ghost" processing is a total hack.
1730 * Hack -- we "delay" fear messages by passing around a "fear" flag.
1732 * XXX XXX XXX Consider decreasing monster experience over time, say,
1733 * by using "(m_exp * m_lev * (m_lev)) / (p_lev * (m_lev + n_killed))"
1734 * instead of simply "(m_exp * m_lev) / (p_lev)", to make the first
1735 * monster worth more than subsequent monsters. This would also need
1736 * to induce changes in the monster recall code.
1738 bool mon_take_hit(int m_idx, int dam, bool *fear, cptr note)
1740 monster_type *m_ptr = &m_list[m_idx];
1741 monster_race *r_ptr = &r_info[m_ptr->r_idx];
1743 monster_type exp_mon;
1745 /* Innocent until proven otherwise */
1746 bool innocent = TRUE, thief = FALSE;
1750 COPY(&exp_mon, m_ptr, monster_type);
1751 if (!(r_ptr->flags7 & RF7_KILL_EXP))
1753 expdam = (m_ptr->hp > dam) ? dam : m_ptr->hp;
1754 if (r_ptr->flags6 & RF6_HEAL) expdam = (expdam+1) * 2 / 3;
1756 get_exp_from_mon(expdam, &exp_mon);
1759 /* Redraw (later) if needed */
1760 if (p_ptr->health_who == m_idx) p_ptr->redraw |= (PR_HEALTH);
1761 if (p_ptr->riding == m_idx) p_ptr->redraw |= (PR_UHEALTH);
1766 /* Hack - Cancel any special player stealth magics. -LM- */
1767 if (p_ptr->special_defense & NINJA_S_STEALTH)
1769 set_superstealth(FALSE);
1775 /* It is dead now */
1780 /* Extract monster name */
1781 monster_desc(m_name, m_ptr, 0x100);
1783 /* Don't kill Amberites */
1784 if ((r_ptr->flags3 & RF3_AMBERITE) && (randint(2) == 1))
1786 int curses = 1 + randint(3);
1787 bool stop_ty = FALSE;
1791 msg_format("%^s¤Ï¶²¤í¤·¤¤·ì¤Î¼ö¤¤¤ò¤¢¤Ê¤¿¤Ë¤«¤±¤¿¡ª", m_name);
1793 msg_format("%^s puts a terrible blood curse on you!", m_name);
1796 curse_equipment(100, 50);
1800 stop_ty = activate_ty_curse(stop_ty, &count);
1805 if (r_ptr->flags2 & RF2_CAN_SPEAK)
1807 char line_got[1024];
1809 /* Dump a message */
1811 if (!get_rnd_line("mondeath_j.txt", m_ptr->r_idx, line_got))
1813 if (!get_rnd_line("mondeath.txt", m_ptr->r_idx, line_got))
1816 msg_format("%^s %s", m_name, line_got);
1819 if (!(d_info[dungeon_type].flags1 & DF1_BEGINNER))
1821 if (!dun_level && !ambush_flag && !p_ptr->inside_arena)
1823 chg_virtue(V_VALOUR, -1);
1825 else if (r_ptr->level > dun_level)
1827 if (randint(10) <= (r_ptr->level - dun_level))
1828 chg_virtue(V_VALOUR, 1);
1830 if (r_ptr->level > 60)
1832 chg_virtue(V_VALOUR, 1);
1834 if (r_ptr->level >= 2 * (p_ptr->lev+1))
1835 chg_virtue(V_VALOUR, 2);
1838 if ((r_ptr->flags1 & RF1_UNIQUE) && ((r_ptr->flags3 & RF3_EVIL) ||
1839 (r_ptr->flags3 & RF3_GOOD)))
1841 chg_virtue(V_HARMONY, 2);
1843 if ((r_ptr->flags1 & RF1_UNIQUE) && (r_ptr->flags3 & RF3_GOOD))
1845 chg_virtue(V_UNLIFE, 2);
1846 chg_virtue(V_VITALITY, -2);
1849 if ((r_ptr->flags1 & RF1_UNIQUE) & (randint(3)==1))
1850 chg_virtue(V_INDIVIDUALISM, -1);
1852 if (m_ptr->r_idx == MON_BEGGAR || m_ptr->r_idx == MON_LEPER)
1854 chg_virtue(V_COMPASSION, -1);
1857 if ((r_ptr->flags3 & RF3_GOOD) &&
1858 ((r_ptr->level) / 10 + (3 * dun_level) >= randint(100)))
1860 chg_virtue(V_UNLIFE, 1);
1862 if (r_ptr->d_char == 'A')
1864 if (r_ptr->flags1 & RF1_UNIQUE)
1865 chg_virtue(V_FAITH, -2);
1866 else if ((r_ptr->level) / 10 + (3 * dun_level) >= randint(100))
1868 if (r_ptr->flags3 & RF3_GOOD) chg_virtue(V_FAITH, -1);
1869 else chg_virtue(V_FAITH, 1);
1872 else if (r_ptr->flags3 & RF3_DEMON)
1874 if (r_ptr->flags1 & RF1_UNIQUE)
1875 chg_virtue(V_FAITH, 2);
1876 else if ((r_ptr->level) / 10 + (3 * dun_level) >= randint(100))
1877 chg_virtue(V_FAITH, 1);
1880 if ((r_ptr->flags3 & RF3_UNDEAD) && (r_ptr->flags1 & RF1_UNIQUE))
1881 chg_virtue(V_VITALITY, 2);
1883 if (r_ptr->r_deaths)
1885 if (r_ptr->flags1 & RF1_UNIQUE)
1887 chg_virtue(V_HONOUR, 10);
1889 else if ((r_ptr->level) / 10 + (2 * dun_level) >= randint(100))
1891 chg_virtue(V_HONOUR, 1);
1894 if ((r_ptr->flags2 & RF2_MULTIPLY) && (r_ptr->r_pkills > 1000) && one_in_(10))
1896 chg_virtue(V_VALOUR, -1);
1899 for (i = 0; i < 4; i++)
1901 if(r_ptr->blow[i].d_dice != 0) innocent = FALSE; /* Murderer! */
1903 if ((r_ptr->blow[i].effect == RBE_EAT_ITEM)
1904 || (r_ptr->blow[i].effect == RBE_EAT_GOLD))
1906 thief = TRUE; /* Thief! */
1909 /* The new law says it is illegal to live in the dungeon */
1910 if (r_ptr->level != 0) innocent = FALSE;
1914 if (r_ptr->flags1 & RF1_UNIQUE)
1915 chg_virtue(V_JUSTICE, 3);
1916 else if (1+((r_ptr->level) / 10 + (2 * dun_level))
1919 chg_virtue(V_JUSTICE, 1);
1923 chg_virtue (V_JUSTICE, -1);
1926 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)))
1928 if (randint(4)==1) chg_virtue(V_NATURE, -1);
1931 if((r_ptr->flags1 & RF1_UNIQUE) && record_destroy_uniq)
1932 do_cmd_write_nikki(NIKKI_UNIQUE, 0, r_name + r_ptr->name);
1937 /* Death by Missile/Spell attack */
1940 msg_format("%^s%s", m_name, note);
1943 /* Death by physical attack -- invisible monster */
1944 else if (!m_ptr->ml)
1947 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
1948 msg_format("¤»¤Ã¤«¤¯¤À¤«¤é%s¤ò»¦¤·¤¿¡£", m_name);
1950 msg_format("%s¤ò»¦¤·¤¿¡£", m_name);
1952 msg_format("You have killed %s.", m_name);
1957 /* Death by Physical attack -- non-living monster */
1958 else if (!monster_living(r_ptr))
1961 bool explode = FALSE;
1963 for (i = 0; i < 4; i++)
1965 if (r_ptr->blow[i].method == RBM_EXPLODE) explode = TRUE;
1968 /* Special note at death */
1971 msg_format("%s¤ÏÇúȯ¤·¤ÆÊ´¡¹¤Ë¤Ê¤Ã¤¿¡£", m_name);
1973 msg_format("%s explodes into tiny shreds.", m_name);
1978 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
1979 msg_format("¤»¤Ã¤«¤¯¤À¤«¤é%s¤òÅݤ·¤¿¡£", m_name);
1981 msg_format("%s¤òÅݤ·¤¿¡£", m_name);
1983 msg_format("You have destroyed %s.", m_name);
1988 /* Death by Physical attack -- living monster */
1992 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
1993 msg_format("¤»¤Ã¤«¤¯¤À¤«¤é%s¤òÁò¤êµî¤Ã¤¿¡£", m_name);
1995 msg_format("%s¤òÁò¤êµî¤Ã¤¿¡£", m_name);
1997 msg_format("You have slain %s.", m_name);
2001 if (r_ptr->flags1 & RF1_UNIQUE)
2003 for (i = 0; i < MAX_KUBI; i++)
2005 if ((kubi_r_idx[i] == m_ptr->r_idx) && !(m_ptr->mflag2 & MFLAG_CHAMELEON))
2008 msg_format("%s¤Î¼ó¤Ë¤Ï¾Þ¶â¤¬¤«¤«¤Ã¤Æ¤¤¤ë¡£", m_name);
2010 msg_format("There is a price on %s's head.", m_name);
2017 if (r_ptr->flags7 & RF7_KILL_EXP)
2018 get_exp_from_mon((long)m_ptr->max_maxhp*2, &exp_mon);
2020 get_exp_from_mon(((long)m_ptr->max_maxhp+1L) * 9L / 10L, &exp_mon);
2022 /* Generate treasure */
2023 monster_death(m_idx, TRUE);
2024 if (m_ptr->mflag2 & MFLAG_CHAMELEON)
2026 if (r_ptr->flags1 & RF1_UNIQUE)
2027 r_ptr = &r_info[MON_CHAMELEON_K];
2029 r_ptr = &r_info[MON_CHAMELEON];
2030 if (r_ptr->r_sights < MAX_SHORT) r_ptr->r_sights++;
2033 /* When the player kills a Unique, it stays dead */
2034 if (r_ptr->flags1 & RF1_UNIQUE) r_ptr->max_num = 0;
2036 /* When the player kills a Nazgul, it stays dead */
2037 if (r_ptr->flags7 & RF7_UNIQUE_7) r_ptr->max_num--;
2039 /* Recall even invisible uniques or winners */
2040 if (m_ptr->ml || (r_ptr->flags1 & RF1_UNIQUE))
2042 /* Count kills this life */
2043 if ((m_ptr->mflag2 & MFLAG_KAGE) && (r_info[MON_KAGE].r_pkills < MAX_SHORT)) r_info[MON_KAGE].r_pkills++;
2044 else if (r_ptr->r_pkills < MAX_SHORT) r_ptr->r_pkills++;
2046 /* Count kills in all lives */
2047 if ((m_ptr->mflag2 & MFLAG_KAGE) && (r_info[MON_KAGE].r_tkills < MAX_SHORT)) r_info[MON_KAGE].r_tkills++;
2048 else if (r_ptr->r_tkills < MAX_SHORT) r_ptr->r_tkills++;
2050 /* Hack -- Auto-recall */
2051 monster_race_track((m_ptr->mflag2 & MFLAG_KAGE), m_ptr->r_idx);
2054 if ((m_ptr->r_idx == MON_BANOR) || (m_ptr->r_idx == MON_LUPART))
2056 r_info[MON_BANORLUPART].max_num = 0;
2057 r_info[MON_BANORLUPART].r_pkills++;
2058 if (r_info[MON_BANORLUPART].r_tkills < MAX_SHORT) r_info[MON_BANORLUPART].r_tkills++;
2061 if (m_ptr->r_idx == MON_BANORLUPART)
2063 r_info[MON_BANOR].max_num = 0;
2064 r_info[MON_BANOR].r_pkills++;
2065 if (r_info[MON_BANOR].r_tkills < MAX_SHORT) r_info[MON_BANOR].r_tkills++;
2066 r_info[MON_LUPART].max_num = 0;
2067 r_info[MON_LUPART].r_pkills++;
2068 if (r_info[MON_LUPART].r_tkills < MAX_SHORT) r_info[MON_LUPART].r_tkills++;
2071 /* Mega hack : replace IKETA to BIKETAL */
2072 if ((m_ptr->r_idx == MON_IKETA) &&
2073 !(p_ptr->inside_arena || p_ptr->inside_battle))
2075 int dummy_y = m_ptr->fy;
2076 int dummy_x = m_ptr->fx;
2077 bool friend = is_friendly(m_ptr);
2078 bool pet = is_pet(m_ptr);
2080 /* Delete the monster */
2081 delete_monster_idx(m_idx);
2083 if (summon_named_creature(dummy_y, dummy_x, MON_BIKETAL, FALSE, FALSE, friend, pet))
2086 msg_print("¡Ö¥Ï¥¡¥Ã¥Ï¥Ã¥Ï¥Ã¥Ï¡ª¡ª»ä¤¬¥Ð¥¤¥±¥¿¥ë¤À¡ª¡ª¡×");
2088 msg_print("Uwa-hahaha! *I* am Biketal!");
2094 /* Delete the monster */
2095 delete_monster_idx(m_idx);
2101 /* Monster is dead */
2108 /* Mega-Hack -- Pain cancels fear */
2109 if (m_ptr->monfear && (dam > 0))
2111 int tmp = randint(dam);
2113 /* Cure a little fear */
2114 if (tmp < m_ptr->monfear)
2117 m_ptr->monfear -= tmp;
2120 /* Cure all the fear */
2131 /* Sometimes a monster gets scared by damage */
2132 if (!m_ptr->monfear && !(r_ptr->flags3 & (RF3_NO_FEAR)))
2136 /* Percentage of fully healthy */
2137 percentage = (100L * m_ptr->hp) / m_ptr->maxhp;
2140 * Run (sometimes) if at 10% or less of max hit points,
2141 * or (usually) when hit for half its current hit points
2143 if (((percentage <= 10) && (rand_int(10) < percentage)) ||
2144 ((dam >= m_ptr->hp) && (rand_int(100) < 80)))
2146 /* Hack -- note fear */
2149 /* XXX XXX XXX Hack -- Add some timed fear */
2150 m_ptr->monfear = (randint(10) +
2151 (((dam >= m_ptr->hp) && (percentage > 7)) ?
2152 20 : ((11 - percentage) * 5)));
2159 if (p_ptr->riding && (p_ptr->riding == m_idx) && (dam > 0))
2163 /* Extract monster name */
2164 monster_desc(m_name, m_ptr, 0);
2166 if (m_ptr->hp > m_ptr->maxhp/3) dam = (dam + 1) / 2;
2167 if (rakuba((dam > 200) ? 200 : dam, FALSE))
2170 msg_format("%^s¤Ë¿¶¤êÍî¤È¤µ¤ì¤¿¡ª", m_name);
2172 msg_format("%^s has thrown you off!", m_name);
2185 * Calculates current boundaries
2186 * Called below and from "do_cmd_locate()".
2188 void panel_bounds(void)
2190 panel_row_min = panel_row * (SCREEN_HGT / 2);
2191 panel_row_max = panel_row_min + SCREEN_HGT - 1;
2192 panel_row_prt = panel_row_min - 1;
2193 panel_col_min = panel_col * (SCREEN_WID / 2);
2194 panel_col_max = panel_col_min + SCREEN_WID - 1;
2195 panel_col_prt = panel_col_min - 13;
2200 * Calculates current boundaries
2201 * Called below and from "do_cmd_locate()".
2202 * Modified for "centering player on screen"
2204 void panel_bounds_center(void)
2206 panel_row = panel_row_min / (SCREEN_HGT / 2);
2207 panel_row_max = panel_row_min + SCREEN_HGT - 1;
2208 panel_row_prt = panel_row_min - 1;
2209 panel_col = panel_col_min / (SCREEN_WID / 2);
2210 panel_col_max = panel_col_min + SCREEN_WID - 1;
2211 panel_col_prt = panel_col_min - 13;
2216 * Handle a request to change the current panel
2218 * Return TRUE if the panel was changed.
2220 * Also used in do_cmd_locate
2222 bool change_panel(int dy, int dx)
2224 /* Apply the motion */
2225 int y = panel_row_min + dy * (SCREEN_HGT / 2);
2226 int x = panel_col_min + dx * (SCREEN_WID / 2);
2228 /* Verify the row */
2229 if (y > max_panel_rows * (SCREEN_HGT / 2)) y = max_panel_rows * (SCREEN_HGT / 2);
2230 else if (y < 0) y = 0;
2232 /* Verify the col */
2233 if (x > max_panel_cols * (SCREEN_WID / 2)) x = max_panel_cols * (SCREEN_WID / 2);
2234 else if (x < 0) x = 0;
2236 /* Handle "changes" */
2237 if ((y != panel_row_min) || (x != panel_col_min))
2239 /* Save the new panel info */
2243 /* Recalculate the boundaries */
2244 panel_bounds_center();
2247 p_ptr->update |= (PU_MONSTERS);
2250 p_ptr->redraw |= (PR_MAP);
2265 * Given an row (y) and col (x), this routine detects when a move
2266 * off the screen has occurred and figures new borders. -RAK-
2268 * "Update" forces a "full update" to take place.
2270 * The map is reprinted if necessary, and "TRUE" is returned.
2272 void verify_panel(void)
2277 /* Center on player */
2278 if (center_player && (center_running || !running))
2283 int max_prow_min = max_panel_rows * (SCREEN_HGT / 2);
2284 int max_pcol_min = max_panel_cols * (SCREEN_WID / 2);
2286 /* Center vertically */
2287 prow_min = y - SCREEN_HGT / 2;
2288 if (prow_min > max_prow_min) prow_min = max_prow_min;
2289 else if (prow_min < 0) prow_min = 0;
2291 /* Center horizontally */
2292 pcol_min = x - SCREEN_WID / 2;
2293 if (pcol_min > max_pcol_min) pcol_min = max_pcol_min;
2294 else if (pcol_min < 0) pcol_min = 0;
2296 /* Check for "no change" */
2297 if ((prow_min == panel_row_min) && (pcol_min == panel_col_min)) return;
2299 /* Save the new panel info */
2300 panel_row_min = prow_min;
2301 panel_col_min = pcol_min;
2303 /* Recalculate the boundaries */
2304 panel_bounds_center();
2309 int prow = panel_row;
2310 int pcol = panel_col;
2312 /* Scroll screen when 2 grids from top/bottom edge */
2313 if ((y < panel_row_min + 2) || (y > panel_row_max - 2))
2315 prow = ((y - SCREEN_HGT / 4) / (SCREEN_HGT / 2));
2316 if (prow > max_panel_rows) prow = max_panel_rows;
2317 else if (prow < 0) prow = 0;
2320 /* Scroll screen when 4 grids from left/right edge */
2321 if ((x < panel_col_min + 4) || (x > panel_col_max - 4))
2323 pcol = ((x - SCREEN_WID / 4) / (SCREEN_WID / 2));
2324 if (pcol > max_panel_cols) pcol = max_panel_cols;
2325 else if (pcol < 0) pcol = 0;
2328 /* Check for "no change" */
2329 if ((prow == panel_row) && (pcol == panel_col)) return;
2331 /* Hack -- optional disturb on "panel change" */
2332 if (disturb_panel && !center_player) disturb(0, 0);
2334 /* Save the new panel info */
2338 /* Recalculate the boundaries */
2343 p_ptr->update |= (PU_MONSTERS);
2346 p_ptr->redraw |= (PR_MAP);
2349 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
2354 * Monster health description
2356 cptr look_mon_desc(int m_idx)
2358 monster_type *m_ptr = &m_list[m_idx];
2359 monster_race *r_ptr = &r_info[m_ptr->r_idx];
2364 /* Determine if the monster is "living" */
2365 living = monster_living(r_ptr);
2368 /* Healthy monsters */
2369 if (m_ptr->hp >= m_ptr->maxhp)
2373 return (living ? "̵½ý" : "̵¥À¥á¡¼¥¸");
2375 return (living ? "unhurt" : "undamaged");
2381 /* Calculate a health "percentage" */
2382 perc = 100L * m_ptr->hp / m_ptr->maxhp;
2387 return (living ? "·Ú½ý" : "¾®¥À¥á¡¼¥¸");
2389 return (living ? "somewhat wounded" : "somewhat damaged");
2397 return (living ? "Éé½ý" : "Ãæ¥À¥á¡¼¥¸");
2399 return (living ? "wounded" : "damaged");
2407 return (living ? "½Å½ý" : "Âç¥À¥á¡¼¥¸");
2409 return (living ? "badly wounded" : "badly damaged");
2415 return (living ? "Ⱦ»àȾÀ¸" : "Åݤ줫¤±");
2417 return (living ? "almost dead" : "almost destroyed");
2425 * Angband sorting algorithm -- quick sort in place
2427 * Note that the details of the data we are sorting is hidden,
2428 * and we rely on the "ang_sort_comp()" and "ang_sort_swap()"
2429 * function hooks to interact with the data, which is given as
2430 * two pointers, and which may have any user-defined form.
2432 void ang_sort_aux(vptr u, vptr v, int p, int q)
2450 while (!(*ang_sort_comp)(u, v, b, z)) b--;
2453 while (!(*ang_sort_comp)(u, v, z, a)) a++;
2455 /* Done partition */
2459 (*ang_sort_swap)(u, v, a, b);
2465 /* Recurse left side */
2466 ang_sort_aux(u, v, p, b);
2468 /* Recurse right side */
2469 ang_sort_aux(u, v, b+1, q);
2474 * Angband sorting algorithm -- quick sort in place
2476 * Note that the details of the data we are sorting is hidden,
2477 * and we rely on the "ang_sort_comp()" and "ang_sort_swap()"
2478 * function hooks to interact with the data, which is given as
2479 * two pointers, and which may have any user-defined form.
2481 void ang_sort(vptr u, vptr v, int n)
2483 /* Sort the array */
2484 ang_sort_aux(u, v, 0, n-1);
2489 /*** Targeting Code ***/
2493 * Determine is a monster makes a reasonable target
2495 * The concept of "targeting" was stolen from "Morgul" (?)
2497 * The player can target any location, or any "target-able" monster.
2499 * Currently, a monster is "target_able" if it is visible, and if
2500 * the player can hit it with a projection, and the player is not
2501 * hallucinating. This allows use of "use closest target" macros.
2503 * Future versions may restrict the ability to target "trappers"
2504 * and "mimics", but the semantics is a little bit weird.
2506 bool target_able(int m_idx)
2508 monster_type *m_ptr = &m_list[m_idx];
2510 /* Monster must be alive */
2511 if (!m_ptr->r_idx) return (FALSE);
2513 /* Hack -- no targeting hallucinations */
2514 if (p_ptr->image) return (FALSE);
2516 /* Monster must be visible */
2517 if (!m_ptr->ml) return (FALSE);
2519 if (p_ptr->riding && (p_ptr->riding == m_idx)) return (TRUE);
2521 /* Monster must be projectable */
2522 if (!projectable(py, px, m_ptr->fy, m_ptr->fx)) return (FALSE);
2524 /* XXX XXX XXX Hack -- Never target trappers */
2525 /* if (CLEAR_ATTR && (CLEAR_CHAR)) return (FALSE); */
2535 * Update (if necessary) and verify (if possible) the target.
2537 * We return TRUE if the target is "okay" and FALSE otherwise.
2539 bool target_okay(void)
2541 /* Accept stationary targets */
2542 if (target_who < 0) return (TRUE);
2544 /* Check moving targets */
2547 /* Accept reasonable targets */
2548 if (target_able(target_who))
2550 monster_type *m_ptr = &m_list[target_who];
2552 /* Acquire monster location */
2553 target_row = m_ptr->fy;
2554 target_col = m_ptr->fx;
2561 /* Assume no target */
2568 * Sorting hook -- comp function -- by "distance to player"
2570 * We use "u" and "v" to point to arrays of "x" and "y" positions,
2571 * and sort the arrays by double-distance to the player.
2573 static bool ang_sort_comp_distance(vptr u, vptr v, int a, int b)
2575 byte *x = (byte*)(u);
2576 byte *y = (byte*)(v);
2580 /* Absolute distance components */
2581 kx = x[a]; kx -= px; kx = ABS(kx);
2582 ky = y[a]; ky -= py; ky = ABS(ky);
2584 /* Approximate Double Distance to the first point */
2585 da = ((kx > ky) ? (kx + kx + ky) : (ky + ky + kx));
2587 /* Absolute distance components */
2588 kx = x[b]; kx -= px; kx = ABS(kx);
2589 ky = y[b]; ky -= py; ky = ABS(ky);
2591 /* Approximate Double Distance to the first point */
2592 db = ((kx > ky) ? (kx + kx + ky) : (ky + ky + kx));
2594 /* Compare the distances */
2600 * Sorting hook -- swap function -- by "distance to player"
2602 * We use "u" and "v" to point to arrays of "x" and "y" positions,
2603 * and sort the arrays by distance to the player.
2605 static void ang_sort_swap_distance(vptr u, vptr v, int a, int b)
2607 byte *x = (byte*)(u);
2608 byte *y = (byte*)(v);
2626 * Hack -- help "select" a location (see below)
2628 static s16b target_pick(int y1, int x1, int dy, int dx)
2632 int x2, y2, x3, y3, x4, y4;
2634 int b_i = -1, b_v = 9999;
2637 /* Scan the locations */
2638 for (i = 0; i < temp_n; i++)
2644 /* Directed distance */
2648 /* Verify quadrant */
2649 if (dx && (x3 * dx <= 0)) continue;
2650 if (dy && (y3 * dy <= 0)) continue;
2652 /* Absolute distance */
2656 /* Verify quadrant */
2657 if (dy && !dx && (x4 > y4)) continue;
2658 if (dx && !dy && (y4 > x4)) continue;
2660 /* Approximate Double Distance */
2661 v = ((x4 > y4) ? (x4 + x4 + y4) : (y4 + y4 + x4));
2663 /* XXX XXX XXX Penalize location */
2666 if ((b_i >= 0) && (v >= b_v)) continue;
2678 * Hack -- determine if a given location is "interesting"
2680 static bool target_set_accept(int y, int x)
2684 s16b this_o_idx, next_o_idx = 0;
2687 /* Player grid is always interesting */
2688 if ((y == py) && (x == px)) return (TRUE);
2691 /* Handle hallucination */
2692 if (p_ptr->image) return (FALSE);
2695 /* Examine the grid */
2696 c_ptr = &cave[y][x];
2698 /* Visible monsters */
2701 monster_type *m_ptr = &m_list[c_ptr->m_idx];
2703 /* Visible monsters */
2704 if (m_ptr->ml) return (TRUE);
2707 /* Scan all objects in the grid */
2708 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
2712 /* Acquire object */
2713 o_ptr = &o_list[this_o_idx];
2715 /* Acquire next object */
2716 next_o_idx = o_ptr->next_o_idx;
2718 /* Memorized object */
2719 if (o_ptr->marked) return (TRUE);
2722 /* Interesting memorized features */
2723 if (c_ptr->info & (CAVE_MARK))
2726 if (c_ptr->feat == FEAT_GLYPH) return (TRUE);
2727 if (c_ptr->feat == FEAT_MINOR_GLYPH) return (TRUE);
2728 if (c_ptr->feat == FEAT_MIRROR) return (TRUE);
2730 /* Notice the Pattern */
2731 if ((c_ptr->feat <= FEAT_PATTERN_XTRA2) &&
2732 (c_ptr->feat >= FEAT_PATTERN_START))
2736 if (c_ptr->feat == FEAT_OPEN) return (TRUE);
2737 if (c_ptr->feat == FEAT_BROKEN) return (TRUE);
2740 if (c_ptr->feat == FEAT_LESS) return (TRUE);
2741 if (c_ptr->feat == FEAT_MORE) return (TRUE);
2742 if (c_ptr->feat == FEAT_LESS_LESS) return (TRUE);
2743 if (c_ptr->feat == FEAT_MORE_MORE) return (TRUE);
2746 if ((c_ptr->feat >= FEAT_SHOP_HEAD) &&
2747 (c_ptr->feat <= FEAT_SHOP_TAIL)) return (TRUE);
2749 if (c_ptr->feat == FEAT_MUSEUM) return (TRUE);
2751 /* Notice buildings -KMW- */
2752 if ((c_ptr->feat >= FEAT_BLDG_HEAD) &&
2753 (c_ptr->feat <= FEAT_BLDG_TAIL)) return (TRUE);
2756 if (is_trap(c_ptr->feat)) return (TRUE);
2759 if ((c_ptr->feat >= FEAT_DOOR_HEAD) &&
2760 (c_ptr->feat <= FEAT_DOOR_TAIL)) return (TRUE);
2763 if (c_ptr->feat == FEAT_RUBBLE) return (TRUE);
2765 /* Notice veins with treasure */
2766 if (c_ptr->feat == FEAT_MAGMA_K) return (TRUE);
2767 if (c_ptr->feat == FEAT_QUARTZ_K) return (TRUE);
2769 /* Notice quest features */
2770 if (c_ptr->feat == FEAT_QUEST_ENTER) return (TRUE);
2771 if (c_ptr->feat == FEAT_QUEST_EXIT) return (TRUE);
2772 if (c_ptr->feat == FEAT_QUEST_DOWN) return (TRUE);
2773 if (c_ptr->feat == FEAT_QUEST_UP) return (TRUE);
2774 if (c_ptr->feat == FEAT_TOWN) return (TRUE);
2775 if (c_ptr->feat == FEAT_ENTRANCE) return (TRUE);
2784 * Prepare the "temp" array for "target_set"
2786 * Return the number of target_able monsters in the set.
2788 static void target_set_prepare(int mode)
2792 /* Reset "temp" array */
2795 /* Scan the current panel */
2796 for (y = panel_row_min; y <= panel_row_max; y++)
2798 for (x = panel_col_min; x <= panel_col_max; x++)
2800 cave_type *c_ptr = &cave[y][x];
2802 /* Require line of sight, unless "look" is "expanded" */
2803 if (!expand_look && !player_has_los_bold(y, x)) continue;
2805 /* Require "interesting" contents */
2806 if (!target_set_accept(y, x)) continue;
2808 /* Require target_able monsters for "TARGET_KILL" */
2809 if ((mode & (TARGET_KILL)) && !target_able(c_ptr->m_idx)) continue;
2811 if ((mode & (TARGET_KILL)) && !target_pet && is_pet(&m_list[c_ptr->m_idx])) continue;
2813 /* Save the location */
2820 /* Set the sort hooks */
2821 ang_sort_comp = ang_sort_comp_distance;
2822 ang_sort_swap = ang_sort_swap_distance;
2824 /* Sort the positions */
2825 ang_sort(temp_x, temp_y, temp_n);
2827 if (p_ptr->riding && target_pet && (temp_n > 1) && (mode & (TARGET_KILL)))
2832 temp_y[0] = temp_y[1];
2835 temp_x[0] = temp_x[1];
2842 * Examine a grid, return a keypress.
2844 * The "mode" argument contains the "TARGET_LOOK" bit flag, which
2845 * indicates that the "space" key should scan through the contents
2846 * of the grid, instead of simply returning immediately. This lets
2847 * the "look" command get complete information, without making the
2848 * "target" command annoying.
2850 * The "info" argument contains the "commands" which should be shown
2851 * inside the "[xxx]" text. This string must never be empty, or grids
2852 * containing monsters will be displayed with an extra comma.
2854 * Note that if a monster is in the grid, we update both the monster
2855 * recall info and the health bar info to track that monster.
2857 * Eventually, we may allow multiple objects per grid, or objects
2858 * and terrain features in the same grid. XXX XXX XXX
2860 * This function must handle blindness/hallucination.
2862 static int target_set_aux(int y, int x, int mode, cptr info)
2864 cave_type *c_ptr = &cave[y][x];
2866 s16b this_o_idx, next_o_idx = 0;
2876 char out_val[MAX_NLEN+80];
2879 /* Repeat forever */
2898 /* Hack -- under the player */
2899 if ((y == py) && (x == px))
2923 /* Hack -- hallucination */
2927 cptr name = "²¿¤«´ñ̯¤Êʪ";
2929 cptr name = "something strange";
2933 /* Display a message */
2935 sprintf(out_val, "%s%s%s%s [%s]", s1, name, s2, s3, info);
2937 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, name, info);
2941 move_cursor_relative(y, x);
2944 /* Stop on everything but "return" */
2945 if ((query != '\r') && (query != '\n')) break;
2947 /* Repeat forever */
2952 /* Actual monsters */
2955 monster_type *m_ptr = &m_list[c_ptr->m_idx];
2956 monster_race *r_ptr = &r_info[m_ptr->r_idx];
2961 bool recall = FALSE;
2968 /* Get the monster name ("a kobold") */
2969 monster_desc(m_name, m_ptr, 0x08);
2971 /* Hack -- track this monster race */
2972 monster_race_track((m_ptr->mflag2 & MFLAG_KAGE), m_ptr->r_idx);
2974 /* Hack -- health bar for this monster */
2975 health_track(c_ptr->m_idx);
2977 /* Hack -- handle stuff */
2989 /* Recall on screen */
2990 if (m_ptr->mflag2 & MFLAG_KAGE) screen_roff(MON_KAGE,0);
2991 else screen_roff(m_ptr->r_idx, 0);
2993 /* Hack -- Complete the prompt (again) */
2995 Term_addstr(-1, TERM_WHITE, format(" [r»× %s]", info));
2997 Term_addstr(-1, TERM_WHITE, format(" [r,%s]", info));
3014 if (p_ptr->riding && (p_ptr->riding == c_ptr->m_idx))
3017 tekitou = "(¥Ú¥Ã¥È)";
3027 if (is_pet(m_ptr) && (p_ptr->riding != c_ptr->m_idx))
3029 attitude = " (¥Ú¥Ã¥È) ";
3031 attitude = " (pet) ";
3034 else if (is_friendly(m_ptr))
3036 attitude = " (ͧ¹¥Åª) ";
3038 attitude = " (friendly) ";
3049 /* Describe, and prompt for recall */
3051 #define M_INT_GREATER(h1,l1,h2,l2) ( (h1>h2)||( (h1==h2)&&(l1>=l2)))
3052 #define M_INT_SUB(h1,l1, h2,l2) {h1-=h2;if(l1<l2){l1+=0x10000;h1--;}l1-=l2;}
3053 #define M_INT_ADD(h1,l1, h2,l2) {h1+=h2;l1+=l2;if(l1>=0x10000L){l1&=0xFFFF;h1++;}}
3054 #define M_INT_LSHIFT(h1,l1) {h1=(h1<<1)|(l1>>15);l1=(l1<<1)&0xffff;}
3055 #define M_INT_RSHIFT(h1,l1) {l1=(l1>>1)|((h1&1)<<15);h1>>=1;}
3056 #define M_INT_MULT(h1,l1,mul,h2,l2) {l2=(l1*mul)&0xffff;h2=((l1*mul)>>16)+h1*mul;}
3060 u32b exp_mon= (r_ptr->mexp)*(r_ptr->level);
3061 u32b exp_mon_h= exp_mon / (p_ptr->max_plv+2);
3062 u32b exp_mon_l= ((exp_mon % (p_ptr->max_plv+2))*0x10000/(p_ptr->max_plv+2))&0xFFFF;
3064 u32b exp_adv_h = player_exp[p_ptr->lev -1] * p_ptr->expfact /100;
3065 u32b exp_adv_l = ((player_exp[p_ptr->lev -1]%100) * p_ptr->expfact *0x10000/100)&0xFFFF;
3067 M_INT_SUB(exp_adv_h, exp_adv_l, p_ptr->exp, p_ptr->exp_frac);
3068 if ((p_ptr->lev>=PY_MAX_LEVEL) || (p_ptr->prace == RACE_ANDROID))
3069 sprintf(acount,"[**]");
3070 else if (!r_ptr->r_tkills || (m_ptr->mflag2 & MFLAG_KAGE))
3071 sprintf(acount,"[??]");
3072 else if (M_INT_GREATER(exp_mon_h, exp_mon_l, exp_adv_h, exp_adv_l))
3073 sprintf(acount,"[001]");
3076 M_INT_MULT(exp_mon_h, exp_mon_l, 1000,tmp_h, tmp_l);
3077 if( M_INT_GREATER(exp_adv_h, exp_adv_l, tmp_h, tmp_l) )
3078 sprintf(acount,"[999]");
3082 M_INT_ADD(exp_adv_h, exp_adv_l, exp_mon_h, exp_mon_l);
3083 M_INT_SUB(exp_adv_h, exp_adv_l, 0, 1);
3084 while(M_INT_GREATER(exp_adv_h, exp_adv_l, exp_mon_h,exp_mon_l))
3086 M_INT_LSHIFT(exp_mon_h,exp_mon_l);
3089 M_INT_RSHIFT(exp_mon_h,exp_mon_l);bit>>=1;
3090 for(;bit>=1;bit>>=1)
3092 if(M_INT_GREATER(exp_adv_h,exp_adv_l,exp_mon_h,exp_mon_l))
3095 M_INT_SUB(exp_adv_h,exp_adv_l,exp_mon_h,exp_mon_l);
3097 M_INT_RSHIFT(exp_mon_h,exp_mon_l);
3099 sprintf(acount,"[%03d]",result);
3104 "%s%s%s(%s)%s%s%s%s%s[r»× %s]",
3105 acount, s1, m_name, look_mon_desc(c_ptr->m_idx), tekitou, s2, s3,
3107 "%s%s%s%s%s(%s)%s%s%s[r, %s]",
3108 acount, s1, s2, s3, m_name, look_mon_desc(c_ptr->m_idx), tekitou,
3110 (m_ptr->smart & SM_CLONED ? " (clone)": ""),
3117 move_cursor_relative(y, x);
3123 /* Normal commands */
3124 if (query != 'r') break;
3130 /* Always stop at "normal" keys */
3131 if ((query != '\r') && (query != '\n') && (query != ' ')) break;
3133 /* Sometimes stop at "space" key */
3134 if ((query == ' ') && !(mode & (TARGET_LOOK))) break;
3136 /* Change the intro */
3144 /* Hack -- take account of gender */
3146 if (r_ptr->flags1 & (RF1_FEMALE)) s1 = "Èà½÷¤Ï";
3148 if (r_ptr->flags1 & (RF1_FEMALE)) s1 = "She is ";
3152 else if (r_ptr->flags1 & (RF1_MALE)) s1 = "Èà¤Ï";
3154 else if (r_ptr->flags1 & (RF1_MALE)) s1 = "He is ";
3158 /* Use a preposition */
3167 /* Scan all objects being carried */
3168 for (this_o_idx = m_ptr->hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
3170 char o_name[MAX_NLEN];
3174 /* Acquire object */
3175 o_ptr = &o_list[this_o_idx];
3177 /* Acquire next object */
3178 next_o_idx = o_ptr->next_o_idx;
3180 /* Obtain an object description */
3181 object_desc(o_name, o_ptr, TRUE, 3);
3183 /* Describe the object */
3185 sprintf(out_val, "%s%s%s%s[%s]", s1, o_name, s2, s3, info);
3187 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, o_name, info);
3191 move_cursor_relative(y, x);
3194 /* Always stop at "normal" keys */
3195 if ((query != '\r') && (query != '\n') && (query != ' ')) break;
3197 /* Sometimes stop at "space" key */
3198 if ((query == ' ') && !(mode & (TARGET_LOOK))) break;
3200 /* Change the intro */
3204 s2 = "also carrying ";
3210 if (this_o_idx) break;
3212 /* Use a preposition */
3224 #ifdef ALLOW_EASY_FLOOR
3226 /* Scan all objects in the grid */
3229 int floor_list[23], floor_num;
3231 if (scan_floor(floor_list, &floor_num, y, x, 0x02))
3240 char o_name[MAX_NLEN];
3244 /* Acquire object */
3245 o_ptr = &o_list[floor_list[0]];
3247 /* Describe the object */
3248 object_desc(o_name, o_ptr, TRUE, 3);
3252 sprintf(out_val, "%s%s%s%s[%s]",
3253 s1, o_name, s2, s3, info);
3255 sprintf(out_val, "%s%s%s%s [%s]",
3256 s1, s2, s3, o_name, info);
3264 sprintf(out_val, "%s %d¸Ä¤Î¥¢¥¤¥Æ¥à%s%s ['x'¤Ç°ìÍ÷, %s]",
3265 s1, floor_num, s2, s3, info);
3267 sprintf(out_val, "%s%s%sa pile of %d items [x,%s]",
3268 s1, s2, s3, floor_num, info);
3274 move_cursor_relative(y, x);
3279 /* Display list of items (query == "el", not "won") */
3280 if ((floor_num > 1) && (query == 'x'))
3286 (void)show_floor(0, y, x);
3290 prt("²¿¤«¥¡¼¤ò²¡¤¹¤È¥²¡¼¥à¤ËÌá¤ê¤Þ¤¹", 0, 0);
3292 prt("Hit any key to continue", 0, 0);
3314 #endif /* ALLOW_EASY_FLOOR */
3317 /* Scan all objects in the grid */
3318 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
3322 /* Acquire object */
3323 o_ptr = &o_list[this_o_idx];
3325 /* Acquire next object */
3326 next_o_idx = o_ptr->next_o_idx;
3331 char o_name[MAX_NLEN];
3336 /* Obtain an object description */
3337 object_desc(o_name, o_ptr, TRUE, 3);
3339 /* Describe the object */
3341 sprintf(out_val, "%s%s%s%s[%s]", s1, o_name, s2, s3, info);
3343 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, o_name, info);
3347 move_cursor_relative(y, x);
3350 /* Always stop at "normal" keys */
3351 if ((query != '\r') && (query != '\n') && (query != ' ')) break;
3353 /* Sometimes stop at "space" key */
3354 if ((query == ' ') && !(mode & TARGET_LOOK)) break;
3356 /* Change the intro */
3366 if (o_ptr->number != 1) s1 = "¤½¤ì¤é¤Ï";
3368 if (o_ptr->number != 1) s1 = "They are ";
3384 if (this_o_idx) break;
3388 feat = c_ptr->mimic;
3392 feat = f_info[c_ptr->feat].mimic;
3395 /* Require knowledge about grid, or ability to see grid */
3396 if (!(c_ptr->info & CAVE_MARK) && !player_can_see_bold(y, x))
3398 /* Forget feature */
3402 /* Terrain feature if needed */
3403 if (boring || (feat > FEAT_INVIS))
3407 /* Hack -- special handling for building doors */
3408 if ((feat >= FEAT_BLDG_HEAD) && (feat <= FEAT_BLDG_TAIL))
3410 name = building[feat - FEAT_BLDG_HEAD].name;
3412 else if (feat == FEAT_ENTRANCE)
3415 name = format("%s(%d³¬ÁêÅö)", d_text + d_info[c_ptr->special].text, d_info[c_ptr->special].mindepth);
3417 name = format("%s(level %d)", d_text + d_info[c_ptr->special].text, d_info[c_ptr->special].mindepth);
3420 else if (feat == FEAT_TOWN)
3422 name = town[c_ptr->special].name;
3424 else if (p_ptr->wild_mode && (feat == FEAT_FLOOR))
3434 name = f_name + f_info[feat].name;
3437 /* Hack -- handle unknown grids */
3439 if (feat == FEAT_NONE) name = "̤ÃΤÎÃÏ·Á";
3441 if (feat == FEAT_NONE) name = "unknown grid";
3446 if (*s2 && ((feat >= FEAT_MINOR_GLYPH) &&
3447 (feat <= FEAT_PATTERN_XTRA2)))
3456 else if (*s2 && ((feat >= FEAT_DOOR_HEAD) &&
3457 (feat <= FEAT_PERM_SOLID)))
3466 else if (*s2 && (feat == FEAT_TOWN))
3476 /* Hack -- special introduction for store & building doors -KMW- */
3477 if (((feat >= FEAT_SHOP_HEAD) && (feat <= FEAT_SHOP_TAIL)) ||
3478 ((feat >= FEAT_BLDG_HEAD) && (feat <= FEAT_BLDG_TAIL)) ||
3479 (feat == FEAT_MUSEUM) ||
3480 (feat == FEAT_ENTRANCE))
3489 else if ((feat == FEAT_TOWN) || (feat == FEAT_FLOOR) || (feat == FEAT_DIRT) || (feat == FEAT_FLOWER))
3495 /* Pick proper indefinite article */
3497 s3 = (is_a_vowel(name[0])) ? "an " : "a ";
3501 /* Display a message */
3504 sprintf(out_val, "%s%s%s%s[%s] %x %d %d %d %d", s1, name, s2, s3, info, c_ptr->info, c_ptr->feat, c_ptr->dist, c_ptr->cost, c_ptr->when);
3506 sprintf(out_val, "%s%s%s%s [%s] %x %d %d %d %d", s1, s2, s3, name, info, c_ptr->info, c_ptr->feat, c_ptr->dist, c_ptr->cost, c_ptr->when);
3510 sprintf(out_val, "%s%s%s%s[%s]", s1, name, s2, s3, info);
3512 sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, name, info);
3516 move_cursor_relative(y, x);
3519 /* Always stop at "normal" keys */
3520 if ((query != '\r') && (query != '\n') && (query != ' ')) break;
3523 /* Stop on everything but "return" */
3524 if ((query != '\r') && (query != '\n')) break;
3533 * Handle "target" and "look".
3535 * Note that this code can be called from "get_aim_dir()".
3537 * All locations must be on the current panel. Consider the use of
3538 * "panel_bounds()" to allow "off-panel" targets, perhaps by using
3539 * some form of "scrolling" the map around the cursor. XXX XXX XXX
3540 * That is, consider the possibility of "auto-scrolling" the screen
3541 * while the cursor moves around. This may require changes in the
3542 * "update_mon()" code to allow "visibility" even if off panel, and
3543 * may require dynamic recalculation of the "temp" grid set.
3545 * Hack -- targeting/observing an "outer border grid" may induce
3546 * problems, so this is not currently allowed.
3548 * The player can use the direction keys to move among "interesting"
3549 * grids in a heuristic manner, or the "space", "+", and "-" keys to
3550 * move through the "interesting" grids in a sequential manner, or
3551 * can enter "location" mode, and use the direction keys to move one
3552 * grid at a time in any direction. The "t" (set target) command will
3553 * only target a monster (as opposed to a location) if the monster is
3554 * target_able and the "interesting" mode is being used.
3556 * The current grid is described using the "look" method above, and
3557 * a new command may be entered at any time, but note that if the
3558 * "TARGET_LOOK" bit flag is set (or if we are in "location" mode,
3559 * where "space" has no obvious meaning) then "space" will scan
3560 * through the description of the current grid until done, instead
3561 * of immediately jumping to the next "interesting" grid. This
3562 * allows the "target" command to retain its old semantics.
3564 * The "*", "+", and "-" keys may always be used to jump immediately
3565 * to the next (or previous) interesting grid, in the proper mode.
3567 * The "return" key may always be used to scan through a complete
3568 * grid description (forever).
3570 * This command will cancel any old target, even if used from
3571 * inside the "look" command.
3573 bool target_set(int mode)
3594 /* Cancel tracking */
3595 /* health_track(0); */
3598 /* Prepare the "temp" array */
3599 target_set_prepare(mode);
3601 /* Start near the player */
3607 /* Interesting grids */
3613 if (!(mode & TARGET_LOOK)) prt_path(y, x);
3616 c_ptr = &cave[y][x];
3619 if (target_able(c_ptr->m_idx))
3622 strcpy(info, "q»ß t·è p¼« o¸½ +¼¡ -Á°");
3624 strcpy(info, "q,t,p,o,+,-,<dir>");
3629 /* Dis-allow target */
3633 strcpy(info, "q»ß p¼« o¸½ +¼¡ -Á°");
3635 strcpy(info, "q,p,o,+,-,<dir>");
3640 /* Describe and Prompt */
3641 query = target_set_aux(y, x, mode, info);
3643 /* Cancel tracking */
3644 /* health_track(0); */
3646 /* Assume no "direction" */
3651 if (query == '\r') query = 't';
3669 if (target_able(c_ptr->m_idx))
3671 health_track(c_ptr->m_idx);
3672 target_who = c_ptr->m_idx;
3691 if (!expand_list) done = TRUE;
3701 if (!expand_list) done = TRUE;
3708 /* Recenter the map around the player */
3712 p_ptr->update |= (PU_MONSTERS);
3715 p_ptr->redraw |= (PR_MAP);
3718 p_ptr->window |= (PW_OVERHEAD);
3723 /* Recalculate interesting grids */
3724 target_set_prepare(mode);
3743 /* Extract the action (if any) */
3744 d = get_keymap_dir(query);
3751 /* Hack -- move around */
3754 /* Modified to scroll to monster */
3755 int y2 = panel_row_min;
3756 int x2 = panel_col_min;
3758 /* Find a new monster */
3759 i = target_pick(temp_y[m], temp_x[m], ddy[d], ddx[d]);
3761 /* Request to target past last interesting grid */
3762 while (flag && (i < 0))
3764 /* Note the change */
3765 if (change_panel(ddy[d], ddx[d]))
3770 /* Recalculate interesting grids */
3771 target_set_prepare(mode);
3773 /* Look at interesting grids */
3776 /* Find a new monster */
3777 i = target_pick(v, u, ddy[d], ddx[d]);
3783 /* Nothing interesting */
3789 /* Restore previous position */
3792 panel_bounds_center();
3795 p_ptr->update |= (PU_MONSTERS);
3798 p_ptr->redraw |= (PR_MAP);
3801 p_ptr->window |= (PW_OVERHEAD);
3806 /* Recalculate interesting grids */
3807 target_set_prepare(mode);
3809 /* Look at boring grids */
3816 /* Do not move horizontally if unnecessary */
3817 if (((x < panel_col_min + SCREEN_WID / 2) && (dx > 0)) ||
3818 ((x > panel_col_min + SCREEN_WID / 2) && (dx < 0)))
3823 /* Do not move vertically if unnecessary */
3824 if (((y < panel_row_min + SCREEN_HGT / 2) && (dy > 0)) ||
3825 ((y > panel_row_min + SCREEN_HGT / 2) && (dy < 0)))
3830 /* Apply the motion */
3831 if ((y >= panel_row_min+SCREEN_HGT) || (y < panel_row_min) ||
3832 (x >= panel_col_min+SCREEN_WID) || (x < panel_col_min))
3834 if (change_panel(dy, dx)) target_set_prepare(mode);
3837 /* Slide into legality */
3838 if (x >= cur_wid-1) x = cur_wid - 2;
3839 else if (x <= 0) x = 1;
3841 /* Slide into legality */
3842 if (y >= cur_hgt-1) y = cur_hgt- 2;
3843 else if (y <= 0) y = 1;
3852 /* Arbitrary grids */
3855 if (!(mode & TARGET_LOOK)) prt_path(y, x);
3858 c_ptr = &cave[y][x];
3860 /* Default prompt */
3862 strcpy(info, "q»ß t·è p¼« m¶á +¼¡ -Á°");
3864 strcpy(info, "q,t,p,m,+,-,<dir>");
3868 /* Describe and Prompt (enable "TARGET_LOOK") */
3869 query = target_set_aux(y, x, mode | TARGET_LOOK, info);
3871 /* Cancel tracking */
3872 /* health_track(0); */
3874 /* Assume no direction */
3879 if (query == '\r') query = 't';
3882 /* Analyze the keypress */
3906 /* Recenter the map around the player */
3910 p_ptr->update |= (PU_MONSTERS);
3913 p_ptr->redraw |= (PR_MAP);
3916 p_ptr->window |= (PW_OVERHEAD);
3921 /* Recalculate interesting grids */
3922 target_set_prepare(mode);
3944 /* Pick a nearby monster */
3945 for (i = 0; i < temp_n; i++)
3947 t = distance(y, x, temp_y[i], temp_x[i]);
3957 /* Nothing interesting */
3958 if (bd == 999) flag = FALSE;
3965 /* Extract the action (if any) */
3966 d = get_keymap_dir(query);
3973 /* Handle "direction" */
3983 /* Do not move horizontally if unnecessary */
3984 if (((x < panel_col_min + SCREEN_WID / 2) && (dx > 0)) ||
3985 ((x > panel_col_min + SCREEN_WID / 2) && (dx < 0)))
3990 /* Do not move vertically if unnecessary */
3991 if (((y < panel_row_min + SCREEN_HGT / 2) && (dy > 0)) ||
3992 ((y > panel_row_min + SCREEN_HGT / 2) && (dy < 0)))
3997 /* Apply the motion */
3998 if ((y >= panel_row_min + SCREEN_HGT) || (y < panel_row_min) ||
3999 (x >= panel_col_min + SCREEN_WID) || (x < panel_col_min))
4001 if (change_panel(dy, dx)) target_set_prepare(mode);
4004 /* Slide into legality */
4005 if (x >= cur_wid-1) x = cur_wid - 2;
4006 else if (x <= 0) x = 1;
4008 /* Slide into legality */
4009 if (y >= cur_hgt-1) y = cur_hgt- 2;
4010 else if (y <= 0) y = 1;
4018 /* Clear the top line */
4021 /* Recenter the map around the player */
4025 p_ptr->update |= (PU_MONSTERS);
4028 p_ptr->redraw |= (PR_MAP);
4031 p_ptr->window |= (PW_OVERHEAD);
4036 /* Failure to set target */
4037 if (!target_who) return (FALSE);
4045 * Get an "aiming direction" from the user.
4047 * The "dir" is loaded with 1,2,3,4,6,7,8,9 for "actual direction", and
4048 * "0" for "current target", and "-1" for "entry aborted".
4050 * Note that "Force Target", if set, will pre-empt user interaction,
4051 * if there is a usable target already set.
4053 * Note that confusion over-rides any (explicit?) user choice.
4055 bool get_aim_dir(int *dp)
4066 /* Global direction */
4069 /* Hack -- auto-target if requested */
4070 if (use_old_target && target_okay()) dir = 5;
4072 #ifdef ALLOW_REPEAT /* TNB */
4074 if (repeat_pull(dp))
4079 if (!(*dp == 5 && !target_okay()))
4086 #endif /* ALLOW_REPEAT -- TNB */
4088 /* Ask until satisfied */
4091 /* Choose a prompt */
4095 p = "Êý¸þ ('*'¤Ç¥¿¡¼¥²¥Ã¥ÈÁªÂò, ESC¤ÇÃæÃÇ)? ";
4097 p = "Direction ('*' to choose a target, Escape to cancel)? ";
4104 p = "Êý¸þ ('5'¤Ç¥¿¡¼¥²¥Ã¥È¤Ø, '*'¤Ç¥¿¡¼¥²¥Ã¥ÈºÆÁªÂò, ESC¤ÇÃæÃÇ)? ";
4106 p = "Direction ('5' for target, '*' to re-target, Escape to cancel)? ";
4111 /* Get a command (or Cancel) */
4112 if (!get_com(p, &command, TRUE)) break;
4116 if (command == '\r') command = 't';
4119 /* Convert various keys to "standard" keys */
4122 /* Use current target */
4133 /* Set new target */
4138 if (target_set(TARGET_KILL)) dir = 5;
4144 /* Extract the action (if any) */
4145 dir = get_keymap_dir(command);
4151 /* Verify requested targets */
4152 if ((dir == 5) && !target_okay()) dir = 0;
4161 project_length = 0; /* reset to default */
4165 /* Save the direction */
4168 /* Check for confusion */
4169 if (p_ptr->confused)
4172 /* Random direction */
4173 dir = ddd[rand_int(8)];
4176 /* Notice confusion */
4177 if (command_dir != dir)
4181 msg_print("¤¢¤Ê¤¿¤Ïº®Í𤷤Ƥ¤¤ë¡£");
4183 msg_print("You are confused.");
4188 /* Save direction */
4191 #ifdef ALLOW_REPEAT /* TNB */
4193 // repeat_push(dir);
4194 repeat_push(command_dir);
4196 #endif /* ALLOW_REPEAT -- TNB */
4198 /* A "valid" direction was entered */
4205 * Request a "movement" direction (1,2,3,4,6,7,8,9) from the user,
4206 * and place it into "command_dir", unless we already have one.
4208 * This function should be used for all "repeatable" commands, such as
4209 * run, walk, open, close, bash, disarm, spike, tunnel, etc, as well
4210 * as all commands which must reference a grid adjacent to the player,
4211 * and which may not reference the grid under the player. Note that,
4212 * for example, it is no longer possible to "disarm" or "open" chests
4213 * in the same grid as the player.
4215 * Direction "5" is illegal and will (cleanly) abort the command.
4217 * This function tracks and uses the "global direction", and uses
4218 * that as the "desired direction", to which "confusion" is applied.
4220 bool get_rep_dir(int *dp, bool under)
4227 /* Global direction */
4230 #ifdef ALLOW_REPEAT /* TNB */
4232 if (repeat_pull(dp))
4238 #endif /* ALLOW_REPEAT -- TNB */
4240 /* Get a direction */
4245 /* Get a command (or Cancel) */
4247 if (!get_com("Êý¸þ (ESC¤ÇÃæÃÇ)? ", &ch, TRUE)) break;
4249 if (!get_com("Direction (Escape to cancel)? ", &ch, TRUE)) break;
4253 /* Look up the direction */
4254 dir = get_keymap_dir(ch);
4260 /* Prevent weirdness */
4261 if ((dir == 5) && (!under)) dir = 0;
4264 if (!dir) return (FALSE);
4266 /* Save desired direction */
4269 /* Apply "confusion" */
4270 if (p_ptr->confused)
4272 /* Standard confusion */
4273 if (rand_int(100) < 75)
4275 /* Random direction */
4276 dir = ddd[rand_int(8)];
4279 else if (p_ptr->riding)
4281 monster_type *m_ptr = &m_list[p_ptr->riding];
4282 monster_race *r_ptr = &r_info[m_ptr->r_idx];
4284 if (m_ptr->confused)
4286 /* Standard confusion */
4287 if (rand_int(100) < 75)
4289 /* Random direction */
4290 dir = ddd[rand_int(8)];
4293 else if ((r_ptr->flags1 & RF1_RAND_50) && (r_ptr->flags1 & RF1_RAND_25) && (rand_int(100) < 50))
4295 /* Random direction */
4296 dir = ddd[rand_int(8)];
4298 else if ((r_ptr->flags1 & RF1_RAND_50) && (rand_int(100) < 25))
4300 /* Random direction */
4301 dir = ddd[rand_int(8)];
4305 /* Notice confusion */
4306 if (command_dir != dir)
4308 if (p_ptr->confused)
4312 msg_print("¤¢¤Ê¤¿¤Ïº®Í𤷤Ƥ¤¤ë¡£");
4314 msg_print("You are confused.");
4320 monster_type *m_ptr = &m_list[p_ptr->riding];
4322 monster_desc(m_name, m_ptr, 0);
4323 if (m_ptr->confused)
4326 msg_format("%s¤Ïº®Í𤷤Ƥ¤¤ë¡£", m_name);
4328 msg_format("%^s is confusing.", m_name);
4335 msg_format("%s¤Ï»×¤¤Ä̤ê¤ËÆ°¤¤¤Æ¤¯¤ì¤Ê¤¤¡£", m_name);
4337 msg_format("You cannot control %s.", m_name);
4343 /* Save direction */
4346 #ifdef ALLOW_REPEAT /* TNB */
4348 // repeat_push(dir);
4349 repeat_push(command_dir);
4351 #endif /* ALLOW_REPEAT -- TNB */
4358 bool get_rep_dir2(int *dp)
4365 /* Global direction */
4368 #ifdef ALLOW_REPEAT /* TNB */
4370 if (repeat_pull(dp))
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) dir = 0;
4402 if (!dir) return (FALSE);
4404 /* Save desired direction */
4407 /* Apply "confusion" */
4408 if (p_ptr->confused)
4410 /* Standard confusion */
4411 if (rand_int(100) < 75)
4413 /* Random direction */
4414 dir = ddd[rand_int(8)];
4418 /* Notice confusion */
4419 if (command_dir != dir)
4423 msg_print("¤¢¤Ê¤¿¤Ïº®Í𤷤Ƥ¤¤ë¡£");
4425 msg_print("You are confused.");
4430 /* Save direction */
4433 #ifdef ALLOW_REPEAT /* TNB */
4435 // repeat_push(dir);
4436 repeat_push(command_dir);
4438 #endif /* ALLOW_REPEAT -- TNB */
4445 int get_chaos_patron(void)
4447 return ((p_ptr->age + p_ptr->sc) % MAX_PATRON);
4451 void gain_level_reward(int chosen_reward)
4455 char wrath_reason[32] = "";
4456 int nasty_chance = 6;
4457 int dummy = 0, dummy2 = 0;
4460 char o_name[MAX_NLEN];
4466 if (multi_rew) return;
4467 else multi_rew = TRUE;
4471 if (p_ptr->lev == 13) nasty_chance = 2;
4472 else if (!(p_ptr->lev % 13)) nasty_chance = 3;
4473 else if (!(p_ptr->lev % 14)) nasty_chance = 12;
4475 if (randint(nasty_chance) == 1)
4476 type = randint(20); /* Allow the 'nasty' effects */
4478 type = randint(15) + 5; /* Or disallow them */
4480 if (type < 1) type = 1;
4481 if (type > 20) type = 20;
4486 sprintf(wrath_reason, "%s¤ÎÅܤê",
4487 chaos_patrons[p_ptr->chaos_patron]);
4489 sprintf(wrath_reason, "the Wrath of %s",
4490 chaos_patrons[p_ptr->chaos_patron]);
4494 effect = chaos_rewards[p_ptr->chaos_patron][type];
4496 if ((randint(6) == 1) && !chosen_reward)
4499 msg_format("%^s¤ÏË«Èþ¤È¤·¤Æ¤¢¤Ê¤¿¤òÆÍÁ³ÊÑ°Û¤µ¤»¤¿¡£",
4500 chaos_patrons[p_ptr->chaos_patron]);
4502 msg_format("%^s rewards you with a mutation!",
4503 chaos_patrons[p_ptr->chaos_patron]);
4506 (void)gain_random_mutation(0);
4508 reward = "ÊÑ°Û¤·¤¿¡£";
4510 reward = "mutation";
4515 switch (chosen_reward ? chosen_reward : effect)
4519 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
4520 chaos_patrons[p_ptr->chaos_patron]);
4522 msg_format("The voice of %s booms out:",
4523 chaos_patrons[p_ptr->chaos_patron]);
4527 msg_print("¡ÖÆò¡¢¿·¤¿¤Ê¤ë»Ñ¤òɬÍפȤ»¤ê¡ª¡×");
4529 msg_print("'Thou needst a new form, mortal!'");
4534 reward = "ÊÑ°Û¤·¤¿¡£";
4536 reward = "polymorphing";
4541 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
4542 chaos_patrons[p_ptr->chaos_patron]);
4544 msg_format("The voice of %s booms out:",
4545 chaos_patrons[p_ptr->chaos_patron]);
4549 msg_print("¡ÖÆò¤ÏÎɤ¯¹Ô¤¤¤¿¤ê¡ªÂ³¤±¤è¡ª¡×");
4551 msg_print("'Well done, mortal! Lead on!'");
4554 if (p_ptr->prace == RACE_ANDROID)
4556 msg_print("¤·¤«¤·²¿¤âµ¯¤³¤é¤Ê¤«¤Ã¤¿¡£");
4558 else if (p_ptr->exp < PY_MAX_EXP)
4560 s32b ee = (p_ptr->exp / 2) + 10;
4561 if (ee > 100000L) ee = 100000L;
4563 msg_print("¹¹¤Ë·Ð¸³¤òÀѤó¤À¤è¤¦¤Êµ¤¤¬¤¹¤ë¡£");
4565 msg_print("You feel more experienced.");
4570 reward = "·Ð¸³ÃͤòÆÀ¤¿";
4572 reward = "experience";
4578 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
4579 chaos_patrons[p_ptr->chaos_patron]);
4581 msg_format("The voice of %s booms out:",
4582 chaos_patrons[p_ptr->chaos_patron]);
4586 msg_print("¡Ö²¼Ëͤ衢Æò¤½¤ì¤ËÃͤ»¤º¡£¡×");
4588 msg_print("'Thou didst not deserve that, slave.'");
4591 if (p_ptr->prace == RACE_ANDROID)
4593 msg_print("¤·¤«¤·²¿¤âµ¯¤³¤é¤Ê¤«¤Ã¤¿¡£");
4597 lose_exp(p_ptr->exp / 6);
4599 reward = "·Ð¸³Ãͤò¼º¤Ã¤¿¡£";
4601 reward = "losing experience";
4607 msg_format("%s¤ÎÀ¼¤¬¤µ¤µ¤ä¤¤¤¿:",
4608 chaos_patrons[p_ptr->chaos_patron]);
4610 msg_format("The voice of %s whispers:",
4611 chaos_patrons[p_ptr->chaos_patron]);
4615 msg_print("¡Ö²æ¤¬Í¿¤¨¤·Êª¤ò¸ÌÀ¤Ë»È¤¦¤Ù¤·¡£¡×");
4617 msg_print("'Use my gift wisely.'");
4620 acquirement(py, px, 1, FALSE, FALSE);
4622 reward = "¾å¼Á¤Ê¥¢¥¤¥Æ¥à¤ò¼ê¤ËÆþ¤ì¤¿¡£";
4624 reward = "a good item";
4629 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
4630 chaos_patrons[p_ptr->chaos_patron]);
4632 msg_format("The voice of %s booms out:",
4633 chaos_patrons[p_ptr->chaos_patron]);
4637 msg_print("¡Ö²æ¤¬Í¿¤¨¤·Êª¤ò¸ÌÀ¤Ë»È¤¦¤Ù¤·¡£¡×");
4639 msg_print("'Use my gift wisely.'");
4642 acquirement(py, px, 1, TRUE, FALSE);
4644 reward = "¹âµéÉʤΥ¢¥¤¥Æ¥à¤ò¼ê¤ËÆþ¤ì¤¿¡£";
4646 reward = "an excellent item";
4651 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
4652 chaos_patrons[p_ptr->chaos_patron]);
4654 msg_format("The voice of %s booms out:",
4655 chaos_patrons[p_ptr->chaos_patron]);
4659 msg_print("¡ÖÆò¤Î¹Ô¤¤¤Ïµ®¤·õ¤ËÃͤ»¤ê¡£¡×");
4661 msg_print("'Thy deed hath earned thee a worthy blade.'");
4664 /* Get local object */
4667 switch (randint(p_ptr->lev))
4673 dummy2 = SV_MAIN_GAUCHE;
4682 dummy2 = SV_SMALL_SWORD;
4685 dummy2 = SV_BASILLARD;
4687 case 11: case 12: case 13:
4688 dummy2 = SV_SHORT_SWORD;
4694 dummy2 = SV_CUTLASS;
4697 dummy2 = SV_WAKIZASHI;
4700 dummy2 = SV_KHOPESH;
4706 dummy2 = SV_BROAD_SWORD;
4709 dummy2 = SV_LONG_SWORD;
4712 dummy2 = SV_SCIMITAR;
4715 dummy2 = SV_NINJATO;
4721 dummy2 = SV_BASTARD_SWORD;
4724 dummy2 = SV_GREAT_SCIMITAR;
4727 dummy2 = SV_CLAYMORE;
4730 dummy2 = SV_ESPADON;
4733 dummy2 = SV_TWO_HANDED_SWORD;
4736 dummy2 = SV_FLAMBERGE;
4739 dummy2 = SV_NO_DACHI;
4742 dummy2 = SV_EXECUTIONERS_SWORD;
4745 dummy2 = SV_ZWEIHANDER;
4748 dummy2 = SV_HAYABUSA;
4751 dummy2 = SV_BLADE_OF_CHAOS;
4754 object_prep(q_ptr, lookup_kind(dummy, dummy2));
4755 q_ptr->to_h = 3 + randint(dun_level) % 10;
4756 q_ptr->to_d = 3 + randint(dun_level) % 10;
4757 random_resistance(q_ptr, FALSE, randint(34) + 4);
4758 q_ptr->name2 = EGO_CHAOTIC;
4761 q_ptr->python = object_create_callback(q_ptr);
4762 #endif /* USE_SCRIPT */
4764 /* Drop it in the dungeon */
4765 (void)drop_near(q_ptr, -1, py, px);
4767 reward = "(º®ÆÙ)¤ÎÉð´ï¤ò¼ê¤ËÆþ¤ì¤¿¡£";
4769 reward = "chaos weapon";
4774 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
4775 chaos_patrons[p_ptr->chaos_patron]);
4777 msg_format("The voice of %s booms out:",
4778 chaos_patrons[p_ptr->chaos_patron]);
4782 msg_print("¡ÖÆò¤Î¹Ô¤¤¤Ïµ®¤Ê󤤤ËÃͤ»¤ê¡£¡×");
4784 msg_print("'Thy deed hath earned thee a worthy reward.'");
4787 acquirement(py, px, randint(2) + 1, FALSE, FALSE);
4789 reward = "¾å¼Á¤Ê¥¢¥¤¥Æ¥à¤ò¼ê¤ËÆþ¤ì¤¿¡£";
4791 reward = "good items";
4796 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
4797 chaos_patrons[p_ptr->chaos_patron]);
4799 msg_format("The voice of %s booms out:",
4800 chaos_patrons[p_ptr->chaos_patron]);
4804 msg_print("¡Ö²¼Ëͤ衢Æò¤Î¸¥¿È¤Ø¤Î²æ¤¬Àˤ·¤ß̵¤Ê󤤤ò¸«¤ë¤¬¤è¤¤¡£¡×");
4806 msg_print("'Behold, mortal, how generously I reward thy loyalty.'");
4809 acquirement(py, px, randint(2) + 1, TRUE, FALSE);
4811 reward = "¹âµéÉʤΥ¢¥¤¥Æ¥à¤ò¼ê¤ËÆþ¤ì¤¿¡£";
4813 reward = "excellent items";
4818 msg_format("%s¤ÎÀ¼¤¬¹ì¤ÅϤä¿:",
4819 chaos_patrons[p_ptr->chaos_patron]);
4821 msg_format("The voice of %s thunders:",
4822 chaos_patrons[p_ptr->chaos_patron]);
4826 msg_print("¡Ö²¼Ëͤ衢ÆòÐþËý¤Ê¤ê¡£¡×");
4828 msg_print("'Thou art growing arrogant, mortal.'");
4831 (void)activate_ty_curse(FALSE, &count);
4833 reward = "²Ò¡¹¤·¤¤¼ö¤¤¤ò¤«¤±¤é¤ì¤¿¡£";
4840 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
4841 chaos_patrons[p_ptr->chaos_patron]);
4843 msg_format("The voice of %s booms out:",
4844 chaos_patrons[p_ptr->chaos_patron]);
4848 msg_print("¡Ö²æ¤¬²¼Ëͤ¿¤Á¤è¡¢¤«¤ÎÐþËý¤Ê¤ë¼Ô¤òÅݤ¹¤Ù¤·¡ª¡×");
4850 msg_print("'My pets, destroy the arrogant mortal!'");
4853 for (dummy = 0; dummy < randint(5) + 1; dummy++)
4855 (void)summon_specific(0, py, px, dun_level, 0, TRUE, FALSE, FALSE, TRUE, TRUE);
4858 reward = "¥â¥ó¥¹¥¿¡¼¤ò¾¤´¤µ¤ì¤¿¡£";
4860 reward = "summoning hostile monsters";
4865 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
4866 chaos_patrons[p_ptr->chaos_patron]);
4868 msg_format("The voice of %s booms out:",
4869 chaos_patrons[p_ptr->chaos_patron]);
4873 msg_print("¡ÖÆò¡¢¤è¤ê¶¯¤Å¨¤òɬÍפȤ»¤ê¡ª¡×");
4875 msg_print("'Thou needst worthier opponents!'");
4878 activate_hi_summon(py, px, FALSE);
4880 reward = "¥â¥ó¥¹¥¿¡¼¤ò¾¤´¤µ¤ì¤¿¡£";
4882 reward = "summoning many hostile monsters";
4887 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
4888 chaos_patrons[p_ptr->chaos_patron]);
4890 msg_format("The voice of %s booms out:",
4891 chaos_patrons[p_ptr->chaos_patron]);
4895 msg_print("¡Ö»à¤ÈÇ˲õ¤³¤½²æ¤¬´î¤Ó¤Ê¤ê¡ª¡×");
4897 msg_print("'Death and destruction! This pleaseth me!'");
4902 reward = "¥«¥ª¥¹¤ÎÎϤ¬±²´¬¤¤¤¿¡£";
4904 reward = "calling chaos";
4909 msg_format("%s¤ÎÀ¼¤¬ÌĤê¶Á¤¤¤¿:",
4910 chaos_patrons[p_ptr->chaos_patron]);
4912 msg_format("The voice of %s rings out:",
4913 chaos_patrons[p_ptr->chaos_patron]);
4917 msg_print("¡Öα¤Þ¤ë¤Î¤À¡¢²¼Ëͤ衣;¤¬Æò¤ÎÆùÂΤòÃ䨤󡣡×");
4919 msg_print("'Stay, mortal, and let me mold thee.'");
4922 if ((randint(3) == 1) && !(chaos_stats[p_ptr->chaos_patron] < 0))
4923 do_inc_stat(chaos_stats[p_ptr->chaos_patron]);
4925 do_inc_stat(rand_int(6));
4927 reward = "ǽÎÏÃͤ¬¾å¤¬¤Ã¤¿¡£";
4929 reward = "increasing a stat";
4934 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
4935 chaos_patrons[p_ptr->chaos_patron]);
4937 msg_format("The voice of %s booms out:",
4938 chaos_patrons[p_ptr->chaos_patron]);
4942 msg_print("¡Ö²¼Ëͤ衢;¤ÏÆò¤ËË°¤ß¤¿¤ê¡£¡×");
4944 msg_print("'I grow tired of thee, mortal.'");
4947 if ((randint(3) == 1) && !(chaos_stats[p_ptr->chaos_patron] < 0))
4948 do_dec_stat(chaos_stats[p_ptr->chaos_patron]);
4950 (void)do_dec_stat(rand_int(6));
4952 reward = "ǽÎÏÃͤ¬²¼¤¬¤Ã¤¿¡£";
4954 reward = "decreasing a stat";
4959 msg_format("%s¤ÎÀ¼¤¬¹ì¤ÅϤä¿:",
4960 chaos_patrons[p_ptr->chaos_patron]);
4962 msg_format("The voice of %s thunders:",
4963 chaos_patrons[p_ptr->chaos_patron]);
4967 msg_print("¡ÖÆò¡¢¸¬µõ¤¿¤ë¤³¤È¤ò³Ø¤Ö¤Ù¤·¡ª¡×");
4968 msg_print("¤¢¤Ê¤¿¤Ï°ÊÁ°¤è¤ê¼å¤¯¤Ê¤Ã¤¿¡ª");
4970 msg_print("'Thou needst a lesson in humility, mortal!'");
4971 msg_print("You feel less powerful!");
4974 for (dummy = 0; dummy < 6; dummy++)
4976 (void)dec_stat(dummy, 10 + randint(15), TRUE);
4979 reward = "Á´Ç½ÎÏÃͤ¬²¼¤¬¤Ã¤¿¡£";
4981 reward = "decreasing all stats";
4986 msg_format("%s¤ÎÎϤ¬¿¨¤ì¤ë¤Î¤ò´¶¤¸¤¿¡£",
4988 msg_format("You feel the power of %s touch you.",
4991 chaos_patrons[p_ptr->chaos_patron]);
4994 reward = "½ý¤¬ÊѲ½¤·¤¿¡£";
4996 reward = "polymorphing wounds";
5001 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5002 chaos_patrons[p_ptr->chaos_patron]);
5004 msg_format("The voice of %s booms out:",
5005 chaos_patrons[p_ptr->chaos_patron]);
5009 msg_print("¡Ö²æ¤¬¤µ¤µ¤ä¤«¤Ê¤ë»òʪ¤ò¼õ¤±¤È¤ë¤¬¤è¤¤¡ª¡×");
5011 msg_print("'Receive this modest gift from me!'");
5014 for (dummy = 0; dummy < 6; dummy++)
5016 (void)do_inc_stat(dummy);
5019 reward = "Á´Ç½ÎÏÃͤ¬¾å¤¬¤Ã¤¿¡£";
5021 reward = "increasing all stats";
5026 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5027 chaos_patrons[p_ptr->chaos_patron]);
5029 msg_format("The voice of %s booms out:",
5030 chaos_patrons[p_ptr->chaos_patron]);
5034 msg_print("¡Ö¶ì¤·¤à¤¬¤è¤¤¡¢ÌµÇ½¤Ê¶ò¤«¼Ô¤è¡ª¡×");
5036 msg_print("'Suffer, pathetic fool!'");
5039 fire_ball(GF_DISINTEGRATE, 0, p_ptr->lev * 4, 4);
5040 take_hit(DAMAGE_NOESCAPE, p_ptr->lev * 4, wrath_reason, -1);
5042 reward = "ʬ²ò¤Îµå¤¬È¯À¸¤·¤¿¡£";
5044 reward = "generating disintegration ball";
5049 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5050 chaos_patrons[p_ptr->chaos_patron]);
5052 msg_format("The voice of %s booms out:",
5053 chaos_patrons[p_ptr->chaos_patron]);
5057 msg_print("¡Öᴤ뤬¤è¤¤¡¢²æ¤¬²¼Ëͤ衪¡×");
5059 msg_print("'Rise, my servant!'");
5063 (void)set_poisoned(0);
5065 (void)set_confused(0);
5070 for (dummy = 0; dummy < 6; dummy++)
5072 (void)do_res_stat(dummy);
5075 reward = "ÂÎÎϤ¬²óÉü¤·¤¿¡£";
5081 if (!buki_motteruka(INVEN_RARM)) break;
5083 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5084 chaos_patrons[p_ptr->chaos_patron]);
5086 msg_format("The voice of %s booms out:",
5087 chaos_patrons[p_ptr->chaos_patron]);
5091 msg_print("¡ÖÆò¡¢Éð´ï¤ËÍê¤ë¤³¤È¤Ê¤«¤ì¡£¡×");
5093 msg_print("'Thou reliest too much on thy weapon.'");
5096 object_desc(o_name, &inventory[INVEN_RARM], TRUE, 0);
5097 (void)curse_weapon(FALSE, INVEN_RARM);
5099 reward = format("%s¤¬Ç˲õ¤µ¤ì¤¿¡£", o_name);
5101 reward = format("destroying %s", o_name);
5105 if (!inventory[INVEN_BODY].k_idx) break;
5107 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5108 chaos_patrons[p_ptr->chaos_patron]);
5110 msg_format("The voice of %s booms out:",
5111 chaos_patrons[p_ptr->chaos_patron]);
5115 msg_print("¡ÖÆò¡¢Ëɶñ¤ËÍê¤ë¤³¤È¤Ê¤«¤ì¡£¡×");
5117 msg_print("'Thou reliest too much on thine equipment.'");
5120 object_desc(o_name, &inventory[INVEN_BODY], TRUE, 0);
5121 (void)curse_armor();
5123 reward = format("%s¤¬Ç˲õ¤µ¤ì¤¿¡£", o_name);
5125 reward = format("destroying %s", o_name);
5130 msg_format("%s¤ÎÀ¼¤¬¤µ¤µ¤ä¤¤¤¿:",
5131 chaos_patrons[p_ptr->chaos_patron]);
5133 msg_format("The voice of %s whispers:",
5134 chaos_patrons[p_ptr->chaos_patron]);
5138 msg_print("¡Ö²æ¤òÅܤꤷ¤á¤¿ºá¤ò½þ¤¦¤Ù¤·¡£¡×");
5140 msg_print("'Now thou shalt pay for annoying me.'");
5146 (void)activate_ty_curse(FALSE, &count);
5148 reward = "²Ò¡¹¤·¤¤¼ö¤¤¤ò¤«¤±¤é¤ì¤¿¡£";
5154 activate_hi_summon(py, px, FALSE);
5156 reward = "¥â¥ó¥¹¥¿¡¼¤ò¾¤´¤µ¤ì¤¿¡£";
5158 reward = "summoning hostile monsters";
5162 if (randint(2) == 1)
5164 if (!buki_motteruka(INVEN_RARM)) break;
5165 object_desc(o_name, &inventory[INVEN_RARM], TRUE, 0);
5166 (void)curse_weapon(FALSE, INVEN_RARM);
5167 reward = format("%s¤¬Ç˲õ¤µ¤ì¤¿¡£", o_name);
5171 if (!inventory[INVEN_BODY].k_idx) break;
5172 object_desc(o_name, &inventory[INVEN_BODY], TRUE, 0);
5173 (void)curse_armor();
5174 reward = format("%s¤¬Ç˲õ¤µ¤ì¤¿¡£", o_name);
5178 for (dummy = 0; dummy < 6; dummy++)
5180 (void)dec_stat(dummy, 10 + randint(15), TRUE);
5183 reward = "Á´Ç½ÎÏÃͤ¬²¼¤¬¤Ã¤¿¡£";
5185 reward = "decreasing all stats";
5192 msg_format("%s¤ÎÀ¼¤¬¹ì¤ÅϤä¿:",
5194 msg_format("The voice of %s thunders:",
5197 chaos_patrons[p_ptr->chaos_patron]);
5199 msg_print("¡Ö»à¤Ì¤¬¤è¤¤¡¢²¼Ëͤ衪¡×");
5201 msg_print("'Die, mortal!'");
5204 take_hit(DAMAGE_LOSELIFE, p_ptr->lev * 4, wrath_reason, -1);
5205 for (dummy = 0; dummy < 6; dummy++)
5207 (void)dec_stat(dummy, 10 + randint(15), FALSE);
5209 activate_hi_summon(py, px, FALSE);
5210 (void)activate_ty_curse(FALSE, &count);
5211 if (randint(2) == 1) (void)curse_weapon(FALSE, INVEN_RARM);
5212 if (randint(2) == 1) (void)curse_armor();
5216 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5217 chaos_patrons[p_ptr->chaos_patron]);
5219 msg_format("The voice of %s booms out:",
5220 chaos_patrons[p_ptr->chaos_patron]);
5224 msg_print("¡Ö»à¤ÈÇ˲õ¤³¤½²æ¤¬´î¤Ó¤Ê¤ê¡ª¡×");
5226 msg_print("'Death and destruction! This pleaseth me!'");
5229 destroy_area(py, px, 25, TRUE);
5231 reward = "¥À¥ó¥¸¥ç¥ó¤¬*Ç˲õ*¤µ¤ì¤¿¡£";
5233 reward = "*destruct*ing dungeon";
5238 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5239 chaos_patrons[p_ptr->chaos_patron]);
5241 msg_format("The voice of %s booms out:",
5242 chaos_patrons[p_ptr->chaos_patron]);
5246 msg_print("¡Ö²æ¡¢Æò¤ÎŨ¤òËõ»¦¤»¤ó¡ª¡×");
5248 msg_print("'Let me relieve thee of thine oppressors!'");
5251 (void)symbol_genocide(0, FALSE);
5253 reward = "¥â¥ó¥¹¥¿¡¼¤¬Ëõ»¦¤µ¤ì¤¿¡£";
5255 reward = "genociding monsters";
5260 msg_format("%s¤ÎÀ¼¤¬¶Á¤ÅϤä¿:",
5261 chaos_patrons[p_ptr->chaos_patron]);
5263 msg_format("The voice of %s booms out:",
5264 chaos_patrons[p_ptr->chaos_patron]);
5268 msg_print("¡Ö²æ¡¢Æò¤ÎŨ¤òËõ»¦¤»¤ó¡ª¡×");
5270 msg_print("'Let me relieve thee of thine oppressors!'");
5273 (void)mass_genocide(0, FALSE);
5275 reward = "¥â¥ó¥¹¥¿¡¼¤¬Ëõ»¦¤µ¤ì¤¿¡£";
5277 reward = "genociding nearby monsters";
5282 msg_format("%s¤ÎÎϤ¬Å¨¤ò¹¶·â¤¹¤ë¤Î¤ò´¶¤¸¤¿¡ª",
5283 chaos_patrons[p_ptr->chaos_patron]);
5285 msg_format("You can feel the power of %s assault your enemies!",
5286 chaos_patrons[p_ptr->chaos_patron]);
5289 (void)dispel_monsters(p_ptr->lev * 4);
5293 msg_format("%s¤Ï¤¢¤Ê¤¿¤ò̵»ë¤·¤¿¡£",
5294 chaos_patrons[p_ptr->chaos_patron]);
5296 msg_format("%s ignores you.",
5297 chaos_patrons[p_ptr->chaos_patron]);
5303 msg_format("%s¤ÏË«Èþ¤È¤·¤Æ°Ëâ¤Î»È¤¤¤ò¤è¤³¤·¤¿¡ª",chaos_patrons[p_ptr->chaos_patron]);
5305 msg_format("%s rewards you with a demonic servant!",chaos_patrons[p_ptr->chaos_patron]);
5308 if (!summon_specific(-1, py, px, dun_level, SUMMON_DEMON, FALSE, TRUE, TRUE, FALSE, FALSE))
5310 msg_print("²¿¤â¸½¤ì¤Ê¤«¤Ã¤¿...");
5312 msg_print("Nobody ever turns up...");
5316 reward = "°Ë⤬¥Ú¥Ã¥È¤Ë¤Ê¤Ã¤¿¡£";
5318 reward = "a demonic servant";
5324 msg_format("%s¤ÏË«Èþ¤È¤·¤Æ»È¤¤¤ò¤è¤³¤·¤¿¡ª",chaos_patrons[p_ptr->chaos_patron]);
5326 msg_format("%s rewards you with a servant!",chaos_patrons[p_ptr->chaos_patron]);
5329 if (!summon_specific(-1, py, px, dun_level, 0, FALSE, TRUE, TRUE, FALSE, FALSE))
5331 msg_print("²¿¤â¸½¤ì¤Ê¤«¤Ã¤¿...");
5333 msg_print("Nobody ever turns up...");
5337 reward = "¥â¥ó¥¹¥¿¡¼¤¬¥Ú¥Ã¥È¤Ë¤Ê¤Ã¤¿¡£";
5339 reward = "a servant";
5345 msg_format("%s¤ÏË«Èþ¤È¤·¤Æ¥¢¥ó¥Ç¥Ã¥É¤Î»È¤¤¤ò¤è¤³¤·¤¿¡£",chaos_patrons[p_ptr->chaos_patron]);
5347 msg_format("%s rewards you with an undead servant!",chaos_patrons[p_ptr->chaos_patron]);
5350 if (!summon_specific(-1, py, px, dun_level, SUMMON_UNDEAD, FALSE, TRUE, TRUE, FALSE, FALSE))
5352 msg_print("²¿¤â¸½¤ì¤Ê¤«¤Ã¤¿...");
5354 msg_print("Nobody ever turns up...");
5358 reward = "¥¢¥ó¥Ç¥Ã¥É¤¬¥Ú¥Ã¥È¤Ë¤Ê¤Ã¤¿¡£";
5360 reward = "an undead servant";
5366 msg_format("%s¤ÎÀ¼¤¬¤É¤â¤Ã¤¿:",
5368 msg_format("The voice of %s stammers:",
5371 chaos_patrons[p_ptr->chaos_patron]);
5373 msg_format("¡Ö¤¢¡¼¡¢¤¢¡¼¡¢Åú¤¨¤Ï %d/%d¡£¼ÁÌä¤Ï²¿¡©¡×", type, effect);
5375 msg_format("'Uh... uh... the answer's %d/%d, what's the question?'", type, effect);
5383 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, format("¥Ñ¥È¥í¥ó¤ÎÊó½·¤Ç%s", reward));
5385 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, format("The patron rewards you with %s.", reward));
5392 * old -- from PsiAngband.
5394 bool tgt_pt(int *x_ptr, int *y_ptr)
5398 bool success = FALSE;
5404 msg_print("¾ì½ê¤òÁª¤ó¤Ç¥¹¥Ú¡¼¥¹¥¡¼¤ò²¡¤·¤Æ²¼¤µ¤¤¡£");
5406 msg_print("Select a point and press space.");
5408 msg_flag = FALSE; /* prevents "-more-" message. */
5410 while ((ch != ESCAPE) && !success)
5412 bool move_fast = FALSE;
5414 move_cursor_relative(y, x);
5426 if (x == px && y == py) ch = 0;
5429 else success = TRUE;
5433 /* Look up the direction */
5434 d = get_keymap_dir(ch);
5436 /* XTRA HACK MOVEFAST */
5437 if (isupper(ch)) move_fast = TRUE;
5439 /* Handle "direction" */
5445 /* XTRA HACK MOVEFAST */
5448 x += dx * SCREEN_WID / 2;
5449 y += dy * SCREEN_HGT / 2;
5455 /* Do not move horizontally if unnecessary */
5456 if (((x < panel_col_min + SCREEN_WID / 2) && (dx > 0)) ||
5457 ((x > panel_col_min + SCREEN_WID / 2) && (dx < 0)))
5462 /* Do not move vertically if unnecessary */
5463 if (((y < panel_row_min + SCREEN_HGT / 2) && (dy > 0)) ||
5464 ((y > panel_row_min + SCREEN_HGT / 2) && (dy < 0)))
5469 /* Apply the motion */
5470 if ((y >= panel_row_min + SCREEN_HGT) || (y < panel_row_min) ||
5471 (x >= panel_col_min + SCREEN_WID) || (x < panel_col_min))
5473 /* if (change_panel(dy, dx)) target_set_prepare(mode); */
5474 change_panel(dy, dx);
5477 /* Slide into legality */
5478 if (x >= cur_wid-1) x = cur_wid - 2;
5479 else if (x <= 0) x = 1;
5481 /* Slide into legality */
5482 if (y >= cur_hgt-1) y = cur_hgt- 2;
5483 else if (y <= 0) y = 1;
5490 /* Clear the top line */
5493 /* Recenter the map around the player */
5497 p_ptr->update |= (PU_MONSTERS);
5500 p_ptr->redraw |= (PR_MAP);
5503 p_ptr->window |= (PW_OVERHEAD);
5514 bool get_hack_dir(int *dp)
5524 /* Global direction */
5527 /* (No auto-targeting) */
5529 /* Ask until satisfied */
5532 /* Choose a prompt */
5536 p = "Êý¸þ ('*'¤Ç¥¿¡¼¥²¥Ã¥ÈÁªÂò, ESC¤ÇÃæÃÇ)? ";
5538 p = "Direction ('*' to choose a target, Escape to cancel)? ";
5545 p = "Êý¸þ ('5'¤Ç¥¿¡¼¥²¥Ã¥È¤Ø, '*'¤Ç¥¿¡¼¥²¥Ã¥ÈºÆÁªÂò, ESC¤ÇÃæÃÇ)? ";
5547 p = "Direction ('5' for target, '*' to re-target, Escape to cancel)? ";
5552 /* Get a command (or Cancel) */
5553 if (!get_com(p, &command, TRUE)) break;
5557 if (command == '\r') command = 't';
5560 /* Convert various keys to "standard" keys */
5563 /* Use current target */
5574 /* Set new target */
5579 if (target_set(TARGET_KILL)) dir = 5;
5585 /* Look up the direction */
5586 dir = get_keymap_dir(command);
5592 /* Verify requested targets */
5593 if ((dir == 5) && !target_okay()) dir = 0;
5600 if (!dir) return (FALSE);
5602 /* Save the direction */
5605 /* Check for confusion */
5606 if (p_ptr->confused)
5609 /* Random direction */
5610 dir = ddd[rand_int(8)];
5613 /* Notice confusion */
5614 if (command_dir != dir)
5618 msg_print("¤¢¤Ê¤¿¤Ïº®Í𤷤Ƥ¤¤ë¡£");
5620 msg_print("You are confused.");
5625 /* Save direction */
5628 /* A "valid" direction was entered */