4 * Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke
6 * This software may be copied and distributed for educational, research,
7 * and not for profit purposes provided that this copyright and statement
8 * are included in all such copies. Other copyrights may also apply.
11 /* Purpose: Spell code (part 3) */
15 /* Maximum number of tries for teleporting */
18 /* 1/x chance of reducing stats (for elemental attacks) */
19 #define HURT_CHANCE 16
22 static bool cave_monster_teleportable_bold(int m_idx, int y, int x, u32b mode)
24 monster_type *m_ptr = &m_list[m_idx];
25 cave_type *c_ptr = &cave[y][x];
26 feature_type *f_ptr = &f_info[c_ptr->feat];
28 /* Require "teleportable" space */
29 if (!have_flag(f_ptr->flags, FF_TELEPORTABLE)) return FALSE;
31 if (c_ptr->m_idx && (c_ptr->m_idx != m_idx)) return FALSE;
32 if (player_bold(y, x)) return FALSE;
34 /* Hack -- no teleport onto glyph of warding */
35 if (is_glyph_grid(c_ptr)) return FALSE;
36 if (is_explosive_rune_grid(c_ptr)) return FALSE;
38 if (!(mode & TELEPORT_PASSIVE))
40 if (!monster_can_cross_terrain(c_ptr->feat, &r_info[m_ptr->r_idx], 0)) return FALSE;
48 * Teleport a monster, normally up to "dis" grids away.
50 * Attempt to move the monster at least "dis/2" grids away.
52 * But allow variation to prevent infinite loops.
54 bool teleport_away(int m_idx, int dis, u32b mode)
56 int oy, ox, d, i, min;
62 monster_type *m_ptr = &m_list[m_idx];
65 if (!m_ptr->r_idx) return (FALSE);
67 /* Save the old location */
71 /* Minimum distance */
74 if ((mode & TELEPORT_DEC_VALOUR) &&
75 (((p_ptr->chp * 10) / p_ptr->mhp) > 5) &&
76 (4+randint1(5) < ((p_ptr->chp * 10) / p_ptr->mhp)))
78 chg_virtue(V_VALOUR, -1);
86 /* Verify max distance */
87 if (dis > 200) dis = 200;
89 /* Try several locations */
90 for (i = 0; i < 500; i++)
92 /* Pick a (possibly illegal) location */
95 ny = rand_spread(oy, dis);
96 nx = rand_spread(ox, dis);
97 d = distance(oy, ox, ny, nx);
98 if ((d >= min) && (d <= dis)) break;
101 /* Ignore illegal locations */
102 if (!in_bounds(ny, nx)) continue;
104 if (!cave_monster_teleportable_bold(m_idx, ny, nx, mode)) continue;
106 /* No teleporting into vaults and such */
107 if (!(p_ptr->inside_quest || p_ptr->inside_arena))
108 if (cave[ny][nx].info & CAVE_ICKY) continue;
110 /* This grid looks good */
117 /* Increase the maximum distance */
120 /* Decrease the minimum distance */
123 /* Stop after MAX_TRIES tries */
124 if (tries > MAX_TRIES) return (FALSE);
128 sound(SOUND_TPOTHER);
130 /* Update the old location */
131 cave[oy][ox].m_idx = 0;
133 /* Update the new location */
134 cave[ny][nx].m_idx = m_idx;
136 /* Move the monster */
140 /* Forget the counter target */
143 /* Update the monster (new location) */
144 update_mon(m_idx, TRUE);
146 /* Redraw the old grid */
149 /* Redraw the new grid */
152 if (r_info[m_ptr->r_idx].flags7 & (RF7_LITE_MASK | RF7_DARK_MASK))
153 p_ptr->update |= (PU_MON_LITE);
161 * Teleport monster next to a grid near the given location
163 void teleport_monster_to(int m_idx, int ty, int tx, int power, u32b mode)
165 int ny, nx, oy, ox, d, i, min;
169 monster_type *m_ptr = &m_list[m_idx];
172 if (!m_ptr->r_idx) return;
175 if (randint1(100) > power) return;
181 /* Save the old location */
185 /* Minimum distance */
188 /* Look until done */
189 while (look && --attempts)
191 /* Verify max distance */
192 if (dis > 200) dis = 200;
194 /* Try several locations */
195 for (i = 0; i < 500; i++)
197 /* Pick a (possibly illegal) location */
200 ny = rand_spread(ty, dis);
201 nx = rand_spread(tx, dis);
202 d = distance(ty, tx, ny, nx);
203 if ((d >= min) && (d <= dis)) break;
206 /* Ignore illegal locations */
207 if (!in_bounds(ny, nx)) continue;
209 if (!cave_monster_teleportable_bold(m_idx, ny, nx, mode)) continue;
211 /* No teleporting into vaults and such */
212 /* if (cave[ny][nx].info & (CAVE_ICKY)) continue; */
214 /* This grid looks good */
221 /* Increase the maximum distance */
224 /* Decrease the minimum distance */
228 if (attempts < 1) return;
231 sound(SOUND_TPOTHER);
233 /* Update the old location */
234 cave[oy][ox].m_idx = 0;
236 /* Update the new location */
237 cave[ny][nx].m_idx = m_idx;
239 /* Move the monster */
243 /* Update the monster (new location) */
244 update_mon(m_idx, TRUE);
246 /* Redraw the old grid */
249 /* Redraw the new grid */
252 if (r_info[m_ptr->r_idx].flags7 & (RF7_LITE_MASK | RF7_DARK_MASK))
253 p_ptr->update |= (PU_MON_LITE);
257 bool cave_player_teleportable_bold(int y, int x, u32b mode)
259 cave_type *c_ptr = &cave[y][x];
260 feature_type *f_ptr = &f_info[c_ptr->feat];
262 /* Require "teleportable" space */
263 if (!have_flag(f_ptr->flags, FF_TELEPORTABLE)) return FALSE;
265 /* No magical teleporting into vaults and such */
266 if (!(mode & TELEPORT_NONMAGICAL) && (c_ptr->info & CAVE_ICKY)) return FALSE;
268 if (c_ptr->m_idx && (c_ptr->m_idx != p_ptr->riding)) return FALSE;
270 if (!(mode & TELEPORT_PASSIVE))
272 if (!player_can_enter(c_ptr->feat, 0)) return FALSE;
274 if (have_flag(f_ptr->flags, FF_WATER) && have_flag(f_ptr->flags, FF_DEEP))
276 if (!p_ptr->levitation && !p_ptr->can_swim) return FALSE;
279 if (have_flag(f_ptr->flags, FF_LAVA) && !p_ptr->immune_fire && !IS_INVULN())
281 /* Always forbid deep lava */
282 if (have_flag(f_ptr->flags, FF_DEEP)) return FALSE;
284 /* Forbid shallow lava when the player don't have levitation */
285 if (!p_ptr->levitation) return FALSE;
288 if (have_flag(f_ptr->flags, FF_HIT_TRAP))
290 if (!is_known_trap(c_ptr) || !trap_can_be_ignored(c_ptr->feat)) return FALSE;
299 * Teleport the player to a location up to "dis" grids away.
301 * If no such spaces are readily available, the distance may increase.
302 * Try very hard to move the player at least a quarter that distance.
304 * There was a nasty tendency for a long time; which was causing the
305 * player to "bounce" between two or three different spots because
306 * these are the only spots that are "far enough" way to satisfy the
309 * But this tendency is now removed; in the new algorithm, a list of
310 * candidates is selected first, which includes at least 50% of all
311 * floor grids within the distance, and any single grid in this list
312 * of candidates has equal possibility to be choosen as a destination.
315 #define MAX_TELEPORT_DISTANCE 200
317 bool teleport_player_aux(int dis, u32b mode)
319 int candidates_at[MAX_TELEPORT_DISTANCE + 1];
320 int total_candidates, cur_candidates;
321 int y = 0, x = 0, min, pick, i;
323 int left = MAX(1, px - dis);
324 int right = MIN(cur_wid - 2, px + dis);
325 int top = MAX(1, py - dis);
326 int bottom = MIN(cur_hgt - 2, py + dis);
328 if (p_ptr->wild_mode) return FALSE;
330 if (p_ptr->anti_tele && !(mode & TELEPORT_NONMAGICAL))
333 msg_print("ÉԻ׵ĤÊÎϤ¬¥Æ¥ì¥Ý¡¼¥È¤òËɤ¤¤À¡ª");
335 msg_print("A mysterious force prevents you from teleporting!");
341 /* Initialize counters */
342 total_candidates = 0;
343 for (i = 0; i <= MAX_TELEPORT_DISTANCE; i++)
344 candidates_at[i] = 0;
346 /* Limit the distance */
347 if (dis > MAX_TELEPORT_DISTANCE) dis = MAX_TELEPORT_DISTANCE;
349 /* Search valid locations */
350 for (y = top; y <= bottom; y++)
352 for (x = left; x <= right; x++)
356 /* Skip illegal locations */
357 if (!cave_player_teleportable_bold(y, x, mode)) continue;
359 /* Calculate distance */
360 d = distance(py, px, y, x);
362 /* Skip too far locations */
363 if (d > dis) continue;
365 /* Count the total number of candidates */
368 /* Count the number of candidates in this circumference */
373 /* No valid location! */
374 if (0 == total_candidates) return FALSE;
376 /* Fix the minimum distance */
377 for (cur_candidates = 0, min = dis; min >= 0; min--)
379 cur_candidates += candidates_at[min];
381 /* 50% of all candidates will have an equal chance to be choosen. */
382 if (cur_candidates && (cur_candidates >= total_candidates / 2)) break;
385 /* Pick up a single location randomly */
386 pick = randint1(cur_candidates);
388 /* Search again the choosen location */
389 for (y = top; y <= bottom; y++)
391 for (x = left; x <= right; x++)
395 /* Skip illegal locations */
396 if (!cave_player_teleportable_bold(y, x, mode)) continue;
398 /* Calculate distance */
399 d = distance(py, px, y, x);
401 /* Skip too far locations */
402 if (d > dis) continue;
404 /* Skip too close locations */
405 if (d < min) continue;
407 /* This grid was picked up? */
416 if (player_bold(y, x)) return FALSE;
419 sound(SOUND_TELEPORT);
422 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
423 msg_format("¡Ø¤³¤Ã¤Á¤À¤¡¡¢%s¡Ù", player_name);
426 /* Move the player */
427 (void)move_player_effect(y, x, MPE_FORGET_FLOW | MPE_HANDLE_STUFF | MPE_DONT_PICKUP);
432 void teleport_player(int dis, u32b mode)
436 /* Save the old location */
440 if (!teleport_player_aux(dis, mode)) return;
442 /* Monsters with teleport ability may follow the player */
443 for (xx = -1; xx < 2; xx++)
445 for (yy = -1; yy < 2; yy++)
447 int tmp_m_idx = cave[oy+yy][ox+xx].m_idx;
449 /* A monster except your mount may follow */
450 if (tmp_m_idx && (p_ptr->riding != tmp_m_idx))
452 monster_type *m_ptr = &m_list[tmp_m_idx];
453 monster_race *r_ptr = &r_info[m_ptr->r_idx];
456 * The latter limitation is to avoid
457 * totally unkillable suckers...
459 if ((r_ptr->flags6 & RF6_TPORT) &&
460 !(r_ptr->flagsr & RFR_RES_TELE))
462 if (!MON_CSLEEP(m_ptr)) teleport_monster_to(tmp_m_idx, py, px, r_ptr->level, 0L);
470 void teleport_player_away(int m_idx, int dis)
474 /* Save the old location */
478 if (!teleport_player_aux(dis, TELEPORT_PASSIVE)) return;
480 /* Monsters with teleport ability may follow the player */
481 for (xx = -1; xx < 2; xx++)
483 for (yy = -1; yy < 2; yy++)
485 int tmp_m_idx = cave[oy+yy][ox+xx].m_idx;
487 /* A monster except your mount or caster may follow */
488 if (tmp_m_idx && (p_ptr->riding != tmp_m_idx) && (m_idx != tmp_m_idx))
490 monster_type *m_ptr = &m_list[tmp_m_idx];
491 monster_race *r_ptr = &r_info[m_ptr->r_idx];
494 * The latter limitation is to avoid
495 * totally unkillable suckers...
497 if ((r_ptr->flags6 & RF6_TPORT) &&
498 !(r_ptr->flagsr & RFR_RES_TELE))
500 if (!MON_CSLEEP(m_ptr)) teleport_monster_to(tmp_m_idx, py, px, r_ptr->level, 0L);
509 * Teleport player to a grid near the given location
511 * This function is slightly obsessive about correctness.
512 * This function allows teleporting into vaults (!)
514 void teleport_player_to(int ny, int nx, u32b mode)
516 int y, x, dis = 0, ctr = 0;
518 if (p_ptr->anti_tele && !(mode & TELEPORT_NONMAGICAL))
521 msg_print("ÉԻ׵ĤÊÎϤ¬¥Æ¥ì¥Ý¡¼¥È¤òËɤ¤¤À¡ª");
523 msg_print("A mysterious force prevents you from teleporting!");
529 /* Find a usable location */
532 /* Pick a nearby legal location */
535 y = rand_spread(ny, dis);
536 x = rand_spread(nx, dis);
537 if (in_bounds(y, x)) break;
540 /* Accept any grid when wizard mode */
541 if (p_ptr->wizard && !(mode & TELEPORT_PASSIVE) && (!cave[y][x].m_idx || (cave[y][x].m_idx == p_ptr->riding))) break;
543 /* Accept teleportable floor grids */
544 if (cave_player_teleportable_bold(y, x, mode)) break;
546 /* Occasionally advance the distance */
547 if (++ctr > (4 * dis * dis + 4 * dis + 1))
555 sound(SOUND_TELEPORT);
557 /* Move the player */
558 (void)move_player_effect(y, x, MPE_FORGET_FLOW | MPE_HANDLE_STUFF | MPE_DONT_PICKUP);
562 void teleport_away_followable(int m_idx)
564 monster_type *m_ptr = &m_list[m_idx];
565 int oldfy = m_ptr->fy;
566 int oldfx = m_ptr->fx;
567 bool old_ml = m_ptr->ml;
568 int old_cdis = m_ptr->cdis;
570 teleport_away(m_idx, MAX_SIGHT * 2 + 5, 0L);
572 if (old_ml && (old_cdis <= MAX_SIGHT) && !world_monster && !p_ptr->inside_battle && los(py, px, oldfy, oldfx))
576 if ((p_ptr->muta1 & MUT1_VTELEPORT) || (p_ptr->pclass == CLASS_IMITATOR)) follow = TRUE;
579 u32b flgs[TR_FLAG_SIZE];
583 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
585 o_ptr = &inventory[i];
586 if (o_ptr->k_idx && !object_is_cursed(o_ptr))
588 object_flags(o_ptr, flgs);
589 if (have_flag(flgs, TR_TELEPORT))
601 if (get_check_strict("¤Ä¤¤¤Æ¤¤¤¤Þ¤¹¤«¡©", CHECK_OKAY_CANCEL))
603 if (get_check_strict("Do you follow it? ", CHECK_OKAY_CANCEL))
608 teleport_player(200, TELEPORT_PASSIVE);
612 msg_print("Failed!");
615 else teleport_player_to(m_ptr->fy, m_ptr->fx, 0L);
616 p_ptr->energy_need += ENERGY_NEED();
624 * Teleport the player one level up or down (random when legal)
625 * Note: If m_idx <= 0, target is player.
627 void teleport_level(int m_idx)
633 if (m_idx <= 0) /* To player */
636 strcpy(m_name, "¤¢¤Ê¤¿");
638 strcpy(m_name, "you");
641 else /* To monster */
643 monster_type *m_ptr = &m_list[m_idx];
645 /* Get the monster name (or "it") */
646 monster_desc(m_name, m_ptr, 0);
648 see_m = is_seen(m_ptr);
651 /* No effect in some case */
652 if (TELE_LEVEL_IS_INEFF(m_idx))
655 if (see_m) msg_print("¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡£");
657 if (see_m) msg_print("There is no effect.");
663 if ((m_idx <= 0) && p_ptr->anti_tele) /* To player */
666 msg_print("ÉԻ׵ĤÊÎϤ¬¥Æ¥ì¥Ý¡¼¥È¤òËɤ¤¤À¡ª");
668 msg_print("A mysterious force prevents you from teleporting!");
673 /* Choose up or down */
674 if (randint0(100) < 50) go_up = TRUE;
677 if ((m_idx <= 0) && p_ptr->wizard)
679 if (get_check("Force to go up? ")) go_up = TRUE;
680 else if (get_check("Force to go down? ")) go_up = FALSE;
684 if ((ironman_downward && (m_idx <= 0)) || (dun_level <= d_info[dungeon_type].mindepth))
687 if (see_m) msg_format("%^s¤Ï¾²¤òÆͤÇˤäÆÄÀ¤ó¤Ç¤¤¤¯¡£", m_name);
689 if (see_m) msg_format("%^s sink%s through the floor.", m_name, (m_idx <= 0) ? "" : "s");
691 if (m_idx <= 0) /* To player */
695 dungeon_type = p_ptr->recall_dungeon;
700 if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, 1, NULL);
702 if (autosave_l) do_cmd_save_game(TRUE);
706 dun_level = d_info[dungeon_type].mindepth;
707 prepare_change_floor_mode(CFM_RAND_PLACE);
711 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN | CFM_RAND_PLACE | CFM_RAND_CONNECT);
715 p_ptr->leaving = TRUE;
720 else if (quest_number(dun_level) || (dun_level >= d_info[dungeon_type].maxdepth))
723 if (see_m) msg_format("%^s¤ÏÅ·°æ¤òÆͤÇˤäÆÃè¤ØÉ⤤¤Æ¤¤¤¯¡£", m_name);
725 if (see_m) msg_format("%^s rise%s up through the ceiling.", m_name, (m_idx <= 0) ? "" : "s");
729 if (m_idx <= 0) /* To player */
731 if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, -1, NULL);
733 if (autosave_l) do_cmd_save_game(TRUE);
735 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_UP | CFM_RAND_PLACE | CFM_RAND_CONNECT);
740 p_ptr->inside_quest = 0;
741 p_ptr->leaving = TRUE;
747 if (see_m) msg_format("%^s¤ÏÅ·°æ¤òÆͤÇˤäÆÃè¤ØÉ⤤¤Æ¤¤¤¯¡£", m_name);
749 if (see_m) msg_format("%^s rise%s up through the ceiling.", m_name, (m_idx <= 0) ? "" : "s");
753 if (m_idx <= 0) /* To player */
755 if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, -1, NULL);
757 if (autosave_l) do_cmd_save_game(TRUE);
759 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_UP | CFM_RAND_PLACE | CFM_RAND_CONNECT);
762 p_ptr->leaving = TRUE;
768 if (see_m) msg_format("%^s¤Ï¾²¤òÆͤÇˤäÆÄÀ¤ó¤Ç¤¤¤¯¡£", m_name);
770 if (see_m) msg_format("%^s sink%s through the floor.", m_name, (m_idx <= 0) ? "" : "s");
773 if (m_idx <= 0) /* To player */
775 /* Never reach this code on the surface */
776 /* if (!dun_level) dungeon_type = p_ptr->recall_dungeon; */
778 if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, 1, NULL);
780 if (autosave_l) do_cmd_save_game(TRUE);
782 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN | CFM_RAND_PLACE | CFM_RAND_CONNECT);
785 p_ptr->leaving = TRUE;
789 /* Monster level teleportation is simple deleting now */
792 monster_type *m_ptr = &m_list[m_idx];
794 /* Check for quest completion */
795 check_quest_completion(m_ptr);
797 if (record_named_pet && is_pet(m_ptr) && m_ptr->nickname)
801 monster_desc(m2_name, m_ptr, MD_INDEF_VISIBLE);
802 do_cmd_write_nikki(NIKKI_NAMED_PET, RECORD_NAMED_PET_TELE_LEVEL, m2_name);
805 delete_monster_idx(m_idx);
809 sound(SOUND_TPLEVEL);
814 int choose_dungeon(cptr note, int y, int x)
820 /* Hack -- No need to choose dungeon in some case */
821 if (lite_town || vanilla_town || ironman_downward)
823 if (max_dlv[DUNGEON_ANGBAND]) return DUNGEON_ANGBAND;
827 msg_format("¤Þ¤À%s¤ËÆþ¤Ã¤¿¤³¤È¤Ï¤Ê¤¤¡£", d_name + d_info[DUNGEON_ANGBAND].name);
829 msg_format("You haven't entered %s yet.", d_name + d_info[DUNGEON_ANGBAND].name);
836 /* Allocate the "dun" array */
837 C_MAKE(dun, max_d_idx, s16b);
840 for(i = 1; i < max_d_idx; i++)
845 if (!d_info[i].maxdepth) continue;
846 if (!max_dlv[i]) continue;
847 if (d_info[i].final_guardian)
849 if (!r_info[d_info[i].final_guardian].max_num) seiha = TRUE;
851 else if (max_dlv[i] == d_info[i].maxdepth) seiha = TRUE;
854 sprintf(buf," %c) %c%-12s : ºÇÂç %d ³¬", 'a'+num, seiha ? '!' : ' ', d_name + d_info[i].name, max_dlv[i]);
856 sprintf(buf," %c) %c%-16s : Max level %d", 'a'+num, seiha ? '!' : ' ', d_name + d_info[i].name, max_dlv[i]);
858 prt(buf, y + num, x);
865 prt(" Áª¤Ù¤ë¥À¥ó¥¸¥ç¥ó¤¬¤Ê¤¤¡£", y, x);
867 prt(" No dungeon is available.", y, x);
872 prt(format("¤É¤Î¥À¥ó¥¸¥ç¥ó%s¤·¤Þ¤¹¤«:", note), 0, 0);
874 prt(format("Which dungeon do you %s?: ", note), 0, 0);
879 if ((i == ESCAPE) || !num)
881 /* Free the "dun" array */
882 C_KILL(dun, max_d_idx, s16b);
887 if (i >= 'a' && i <('a'+num))
889 select_dungeon = dun[i-'a'];
896 /* Free the "dun" array */
897 C_KILL(dun, max_d_idx, s16b);
899 return select_dungeon;
904 * Recall the player to town or dungeon
906 bool recall_player(int turns)
909 * TODO: Recall the player to the last
910 * visited town when in the wilderness
914 if (p_ptr->inside_arena || ironman_downward)
917 msg_print("²¿¤âµ¯¤³¤é¤Ê¤«¤Ã¤¿¡£");
919 msg_print("Nothing happens.");
925 if (dun_level && (max_dlv[dungeon_type] > dun_level) && !p_ptr->inside_quest && !p_ptr->word_recall)
928 if (get_check("¤³¤³¤ÏºÇ¿¼Åþ㳬¤è¤êÀõ¤¤³¬¤Ç¤¹¡£¤³¤Î³¬¤ËÌá¤Ã¤ÆÍè¤Þ¤¹¤«¡© "))
930 if (get_check("Reset recall depth? "))
933 max_dlv[dungeon_type] = dun_level;
936 do_cmd_write_nikki(NIKKI_TRUMP, dungeon_type, "µ¢´Ô¤Î¤È¤¤Ë");
938 do_cmd_write_nikki(NIKKI_TRUMP, dungeon_type, "when recall from dungeon");
943 if (!p_ptr->word_recall)
949 select_dungeon = choose_dungeon("¤Ëµ¢´Ô", 2, 14);
951 select_dungeon = choose_dungeon("recall", 2, 14);
953 if (!select_dungeon) return FALSE;
954 p_ptr->recall_dungeon = select_dungeon;
956 p_ptr->word_recall = turns;
958 msg_print("²ó¤ê¤ÎÂ絤¤¬Ä¥¤ê¤Ä¤á¤Æ¤¤¿...");
960 msg_print("The air about you becomes charged...");
963 p_ptr->redraw |= (PR_STATUS);
967 p_ptr->word_recall = 0;
969 msg_print("Ä¥¤ê¤Ä¤á¤¿Â絤¤¬Î®¤ìµî¤Ã¤¿...");
971 msg_print("A tension leaves the air around you...");
974 p_ptr->redraw |= (PR_STATUS);
980 bool word_of_recall(void)
982 return(recall_player(randint0(21) + 15));
986 bool reset_recall(void)
988 int select_dungeon, dummy = 0;
993 select_dungeon = choose_dungeon("¤ò¥»¥Ã¥È", 2, 14);
995 select_dungeon = choose_dungeon("reset", 2, 14);
999 if (ironman_downward)
1002 msg_print("²¿¤âµ¯¤³¤é¤Ê¤«¤Ã¤¿¡£");
1004 msg_print("Nothing happens.");
1010 if (!select_dungeon) return FALSE;
1013 sprintf(ppp, "²¿³¬¤Ë¥»¥Ã¥È¤·¤Þ¤¹¤« (%d-%d):", d_info[select_dungeon].mindepth, max_dlv[select_dungeon]);
1015 sprintf(ppp, "Reset to which level (%d-%d): ", d_info[select_dungeon].mindepth, max_dlv[select_dungeon]);
1020 sprintf(tmp_val, "%d", MAX(dun_level, 1));
1022 /* Ask for a level */
1023 if (get_string(ppp, tmp_val, 10))
1025 /* Extract request */
1026 dummy = atoi(tmp_val);
1029 if (dummy < 1) dummy = 1;
1032 if (dummy > max_dlv[select_dungeon]) dummy = max_dlv[select_dungeon];
1033 if (dummy < d_info[select_dungeon].mindepth) dummy = d_info[select_dungeon].mindepth;
1035 max_dlv[select_dungeon] = dummy;
1037 if (record_maxdepth)
1039 do_cmd_write_nikki(NIKKI_TRUMP, select_dungeon, "¥Õ¥í¥¢¡¦¥ê¥»¥Ã¥È¤Ç");
1041 do_cmd_write_nikki(NIKKI_TRUMP, select_dungeon, "using a scroll of reset recall");
1043 /* Accept request */
1045 msg_format("%s¤Îµ¢´Ô¥ì¥Ù¥ë¤ò %d ³¬¤Ë¥»¥Ã¥È¡£", d_name+d_info[select_dungeon].name, dummy, dummy * 50);
1047 msg_format("Recall depth set to level %d (%d').", dummy, dummy * 50);
1060 * Apply disenchantment to the player's stuff
1062 * XXX XXX XXX This function is also called from the "melee" code
1064 * Return "TRUE" if the player notices anything
1066 bool apply_disenchant(int mode)
1070 char o_name[MAX_NLEN];
1071 int to_h, to_d, to_a, pval;
1073 /* Pick a random slot */
1074 switch (randint1(8))
1076 case 1: t = INVEN_RARM; break;
1077 case 2: t = INVEN_LARM; break;
1078 case 3: t = INVEN_BOW; break;
1079 case 4: t = INVEN_BODY; break;
1080 case 5: t = INVEN_OUTER; break;
1081 case 6: t = INVEN_HEAD; break;
1082 case 7: t = INVEN_HANDS; break;
1083 case 8: t = INVEN_FEET; break;
1087 o_ptr = &inventory[t];
1089 /* No item, nothing happens */
1090 if (!o_ptr->k_idx) return (FALSE);
1092 /* Disenchant equipments only -- No disenchant on monster ball */
1093 if (!object_is_weapon_armour_ammo(o_ptr))
1096 /* Nothing to disenchant */
1097 if ((o_ptr->to_h <= 0) && (o_ptr->to_d <= 0) && (o_ptr->to_a <= 0) && (o_ptr->pval <= 1))
1099 /* Nothing to notice */
1104 /* Describe the object */
1105 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
1108 /* Artifacts have 71% chance to resist */
1109 if (object_is_artifact(o_ptr) && (randint0(100) < 71))
1113 msg_format("%s(%c)¤ÏÎô²½¤òÄ·¤ÍÊÖ¤·¤¿¡ª",o_name, index_to_label(t) );
1115 msg_format("Your %s (%c) resist%s disenchantment!",
1116 o_name, index_to_label(t),
1117 ((o_ptr->number != 1) ? "" : "s"));
1126 /* Memorize old value */
1132 /* Disenchant tohit */
1133 if (o_ptr->to_h > 0) o_ptr->to_h--;
1134 if ((o_ptr->to_h > 5) && (randint0(100) < 20)) o_ptr->to_h--;
1136 /* Disenchant todam */
1137 if (o_ptr->to_d > 0) o_ptr->to_d--;
1138 if ((o_ptr->to_d > 5) && (randint0(100) < 20)) o_ptr->to_d--;
1140 /* Disenchant toac */
1141 if (o_ptr->to_a > 0) o_ptr->to_a--;
1142 if ((o_ptr->to_a > 5) && (randint0(100) < 20)) o_ptr->to_a--;
1144 /* Disenchant pval (occasionally) */
1145 /* Unless called from wild_magic() */
1146 if ((o_ptr->pval > 1) && one_in_(13) && !(mode & 0x01)) o_ptr->pval--;
1148 if ((to_h != o_ptr->to_h) || (to_d != o_ptr->to_d) ||
1149 (to_a != o_ptr->to_a) || (pval != o_ptr->pval))
1153 msg_format("%s(%c)¤ÏÎô²½¤·¤Æ¤·¤Þ¤Ã¤¿¡ª",
1154 o_name, index_to_label(t) );
1156 msg_format("Your %s (%c) %s disenchanted!",
1157 o_name, index_to_label(t),
1158 ((o_ptr->number != 1) ? "were" : "was"));
1161 chg_virtue(V_HARMONY, 1);
1162 chg_virtue(V_ENCHANT, -2);
1164 /* Recalculate bonuses */
1165 p_ptr->update |= (PU_BONUS);
1168 p_ptr->window |= (PW_EQUIP | PW_PLAYER);
1178 void mutate_player(void)
1180 int max1, cur1, max2, cur2, ii, jj, i;
1182 /* Pick a pair of stats */
1184 for (jj = ii; jj == ii; jj = randint0(6)) /* loop */;
1186 max1 = p_ptr->stat_max[ii];
1187 cur1 = p_ptr->stat_cur[ii];
1188 max2 = p_ptr->stat_max[jj];
1189 cur2 = p_ptr->stat_cur[jj];
1191 p_ptr->stat_max[ii] = max2;
1192 p_ptr->stat_cur[ii] = cur2;
1193 p_ptr->stat_max[jj] = max1;
1194 p_ptr->stat_cur[jj] = cur1;
1198 if(p_ptr->stat_max[i] > p_ptr->stat_max_max[i]) p_ptr->stat_max[i] = p_ptr->stat_max_max[i];
1199 if(p_ptr->stat_cur[i] > p_ptr->stat_max_max[i]) p_ptr->stat_cur[i] = p_ptr->stat_max_max[i];
1202 p_ptr->update |= (PU_BONUS);
1209 void apply_nexus(monster_type *m_ptr)
1211 switch (randint1(7))
1213 case 1: case 2: case 3:
1215 teleport_player(200, TELEPORT_PASSIVE);
1221 teleport_player_to(m_ptr->fy, m_ptr->fx, TELEPORT_PASSIVE);
1227 if (randint0(100) < p_ptr->skill_sav)
1230 msg_print("¤·¤«¤·¸úÎϤòÄ·¤ÍÊÖ¤·¤¿¡ª");
1232 msg_print("You resist the effects!");
1238 /* Teleport Level */
1245 if (randint0(100) < p_ptr->skill_sav)
1248 msg_print("¤·¤«¤·¸úÎϤòÄ·¤ÍÊÖ¤·¤¿¡ª");
1250 msg_print("You resist the effects!");
1257 msg_print("ÂΤ¬¤Í¤¸¤ì»Ï¤á¤¿...");
1259 msg_print("Your body starts to scramble...");
1270 * Charge a lite (torch or latern)
1272 void phlogiston(void)
1275 object_type * o_ptr = &inventory[INVEN_LITE];
1278 if ((o_ptr->tval == TV_LITE) && (o_ptr->sval == SV_LITE_LANTERN))
1280 max_flog = FUEL_LAMP;
1284 else if ((o_ptr->tval == TV_LITE) && (o_ptr->sval == SV_LITE_TORCH))
1286 max_flog = FUEL_TORCH;
1289 /* No torch to refill */
1293 msg_print("dzÁǤò¾ÃÈñ¤¹¤ë¥¢¥¤¥Æ¥à¤òÁõÈ÷¤·¤Æ¤¤¤Þ¤»¤ó¡£");
1295 msg_print("You are not wielding anything which uses phlogiston.");
1301 if (o_ptr->xtra4 >= max_flog)
1304 msg_print("¤³¤Î¥¢¥¤¥Æ¥à¤Ë¤Ï¤³¤ì°Ê¾ådzÁǤòÊä½¼¤Ç¤¤Þ¤»¤ó¡£");
1306 msg_print("No more phlogiston can be put in this item.");
1313 o_ptr->xtra4 += (max_flog / 2);
1317 msg_print("¾ÈÌÀÍÑ¥¢¥¤¥Æ¥à¤ËdzÁǤòÊä½¼¤·¤¿¡£");
1319 msg_print("You add phlogiston to your light item.");
1324 if (o_ptr->xtra4 >= max_flog)
1326 o_ptr->xtra4 = max_flog;
1328 msg_print("¾ÈÌÀÍÑ¥¢¥¤¥Æ¥à¤ÏËþ¥¿¥ó¤Ë¤Ê¤Ã¤¿¡£");
1330 msg_print("Your light item is full.");
1335 /* Recalculate torch */
1336 p_ptr->update |= (PU_TORCH);
1341 * Brand the current weapon
1343 void brand_weapon(int brand_type)
1350 /* Assume enchant weapon */
1351 item_tester_hook = object_allow_enchant_melee_weapon;
1352 item_tester_no_ryoute = TRUE;
1356 q = "¤É¤ÎÉð´ï¤ò¶¯²½¤·¤Þ¤¹¤«? ";
1357 s = "¶¯²½¤Ç¤¤ëÉð´ï¤¬¤Ê¤¤¡£";
1359 q = "Enchant which weapon? ";
1360 s = "You have nothing to enchant.";
1363 if (!get_item(&item, q, s, (USE_EQUIP))) return;
1365 /* Get the item (in the pack) */
1368 o_ptr = &inventory[item];
1371 /* Get the item (on the floor) */
1374 o_ptr = &o_list[0 - item];
1378 /* you can never modify artifacts / ego-items */
1379 /* you can never modify cursed items */
1380 /* TY: You _can_ modify broken items (if you're silly enough) */
1381 if (o_ptr->k_idx && !object_is_artifact(o_ptr) && !object_is_ego(o_ptr) &&
1382 !object_is_cursed(o_ptr) &&
1383 !((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DOKUBARI)) &&
1384 !((o_ptr->tval == TV_POLEARM) && (o_ptr->sval == SV_DEATH_SCYTHE)) &&
1385 !((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DIAMOND_EDGE)))
1389 /* Let's get the name before it is changed... */
1390 char o_name[MAX_NLEN];
1391 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
1396 if (o_ptr->tval == TV_SWORD)
1399 act = "¤Ï±Ô¤µ¤òÁý¤·¤¿¡ª";
1401 act = "becomes very sharp!";
1404 o_ptr->name2 = EGO_SHARPNESS;
1405 o_ptr->pval = m_bonus(5, dun_level) + 1;
1407 if ((o_ptr->sval == SV_HAYABUSA) && (o_ptr->pval > 2))
1413 act = "¤ÏÇ˲õÎϤòÁý¤·¤¿¡ª";
1415 act = "seems very powerful.";
1418 o_ptr->name2 = EGO_EARTHQUAKES;
1419 o_ptr->pval = m_bonus(3, dun_level);
1424 act = "¤Ï¿Í´Ö¤Î·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
1426 act = "seems to be looking for humans!";
1429 o_ptr->name2 = EGO_SLAY_HUMAN;
1433 act = "¤ÏÅÅ·â¤Ëʤ¤ï¤ì¤¿¡ª";
1435 act = "covered with lightning!";
1438 o_ptr->name2 = EGO_BRAND_ELEC;
1442 act = "¤Ï»À¤Ëʤ¤ï¤ì¤¿¡ª";
1444 act = "coated with acid!";
1447 o_ptr->name2 = EGO_BRAND_ACID;
1451 act = "¤Ï¼Ù°¤Ê¤ë²øʪ¤òµá¤á¤Æ¤¤¤ë¡ª";
1453 act = "seems to be looking for evil monsters!";
1456 o_ptr->name2 = EGO_SLAY_EVIL;
1460 act = "¤Ï°ÛÀ¤³¦¤Î½»¿Í¤ÎÆùÂΤòµá¤á¤Æ¤¤¤ë¡ª";
1462 act = "seems to be looking for demons!";
1465 o_ptr->name2 = EGO_SLAY_DEMON;
1469 act = "¤Ï»Ó¤òµá¤á¤Æ¤¤¤ë¡ª";
1471 act = "seems to be looking for undead!";
1474 o_ptr->name2 = EGO_SLAY_UNDEAD;
1478 act = "¤Ïưʪ¤Î·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
1480 act = "seems to be looking for animals!";
1483 o_ptr->name2 = EGO_SLAY_ANIMAL;
1487 act = "¤Ï¥É¥é¥´¥ó¤Î·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
1489 act = "seems to be looking for dragons!";
1492 o_ptr->name2 = EGO_SLAY_DRAGON;
1496 act = "¤Ï¥È¥í¥ë¤Î·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
1498 act = "seems to be looking for troll!s";
1501 o_ptr->name2 = EGO_SLAY_TROLL;
1505 act = "¤Ï¥ª¡¼¥¯¤Î·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
1507 act = "seems to be looking for orcs!";
1510 o_ptr->name2 = EGO_SLAY_ORC;
1514 act = "¤Ïµð¿Í¤Î·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
1516 act = "seems to be looking for giants!";
1519 o_ptr->name2 = EGO_SLAY_GIANT;
1523 act = "¤ÏÈó¾ï¤ËÉÔ°ÂÄê¤Ë¤Ê¤Ã¤¿¤è¤¦¤À¡£";
1525 act = "seems very unstable now.";
1528 o_ptr->name2 = EGO_TRUMP;
1529 o_ptr->pval = randint1(2);
1533 act = "¤Ï·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
1535 act = "thirsts for blood!";
1538 o_ptr->name2 = EGO_VAMPIRIC;
1542 act = "¤ÏÆǤËʤ¤ï¤ì¤¿¡£";
1544 act = "is coated with poison.";
1547 o_ptr->name2 = EGO_BRAND_POIS;
1551 act = "¤Ï½ã¥í¥°¥ë¥¹¤Ë°û¤ß¹þ¤Þ¤ì¤¿¡£";
1553 act = "is engulfed in raw Logrus!";
1556 o_ptr->name2 = EGO_CHAOTIC;
1560 act = "¤Ï±ê¤Î¥·¡¼¥ë¥É¤Ëʤ¤ï¤ì¤¿¡ª";
1562 act = "is covered in a fiery shield!";
1565 o_ptr->name2 = EGO_BRAND_FIRE;
1569 act = "¤Ï¿¼¤¯Î䤿¤¤¥Ö¥ë¡¼¤Ëµ±¤¤¤¿¡ª";
1571 act = "glows deep, icy blue!";
1574 o_ptr->name2 = EGO_BRAND_COLD;
1579 msg_format("¤¢¤Ê¤¿¤Î%s%s", o_name, act);
1581 msg_format("Your %s %s", o_name, act);
1585 enchant(o_ptr, randint0(3) + 4, ENCH_TOHIT | ENCH_TODAM);
1587 o_ptr->discount = 99;
1588 chg_virtue(V_ENCHANT, 2);
1592 if (flush_failure) flush();
1595 msg_print("°ÀÉղä˼ºÇÔ¤·¤¿¡£");
1597 msg_print("The Branding failed.");
1600 chg_virtue(V_ENCHANT, -2);
1607 * Vanish all walls in this floor
1609 static bool vanish_dungeon(void)
1613 feature_type *f_ptr;
1614 monster_type *m_ptr;
1617 /* Prevent vasishing of quest levels and town */
1618 if ((p_ptr->inside_quest && is_fixed_quest_idx(p_ptr->inside_quest)) || !dun_level)
1623 /* Scan all normal grids */
1624 for (y = 1; y < cur_hgt - 1; y++)
1626 for (x = 1; x < cur_wid - 1; x++)
1628 c_ptr = &cave[y][x];
1630 /* Seeing true feature code (ignore mimic) */
1631 f_ptr = &f_info[c_ptr->feat];
1633 /* Lose room and vault */
1634 c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1636 m_ptr = &m_list[c_ptr->m_idx];
1639 if (c_ptr->m_idx && MON_CSLEEP(m_ptr))
1641 /* Reset sleep counter */
1642 (void)set_monster_csleep(c_ptr->m_idx, 0);
1644 /* Notice the "waking up" */
1647 /* Acquire the monster name */
1648 monster_desc(m_name, m_ptr, 0);
1650 /* Dump a message */
1652 msg_format("%^s¤¬Ìܤò³Ð¤Þ¤·¤¿¡£", m_name);
1654 msg_format("%^s wakes up.", m_name);
1659 /* Process all walls, doors and patterns */
1660 if (have_flag(f_ptr->flags, FF_HURT_DISI)) cave_alter_feat(y, x, FF_HURT_DISI);
1664 /* Special boundary walls -- Top and bottom */
1665 for (x = 0; x < cur_wid; x++)
1667 c_ptr = &cave[0][x];
1668 f_ptr = &f_info[c_ptr->mimic];
1670 /* Lose room and vault */
1671 c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1673 /* Set boundary mimic if needed */
1674 if (c_ptr->mimic && have_flag(f_ptr->flags, FF_HURT_DISI))
1676 c_ptr->mimic = feat_state(c_ptr->mimic, FF_HURT_DISI);
1678 /* Check for change to boring grid */
1679 if (!have_flag(f_info[c_ptr->mimic].flags, FF_REMEMBER)) c_ptr->info &= ~(CAVE_MARK);
1682 c_ptr = &cave[cur_hgt - 1][x];
1683 f_ptr = &f_info[c_ptr->mimic];
1685 /* Lose room and vault */
1686 c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1688 /* Set boundary mimic if needed */
1689 if (c_ptr->mimic && have_flag(f_ptr->flags, FF_HURT_DISI))
1691 c_ptr->mimic = feat_state(c_ptr->mimic, FF_HURT_DISI);
1693 /* Check for change to boring grid */
1694 if (!have_flag(f_info[c_ptr->mimic].flags, FF_REMEMBER)) c_ptr->info &= ~(CAVE_MARK);
1698 /* Special boundary walls -- Left and right */
1699 for (y = 1; y < (cur_hgt - 1); y++)
1701 c_ptr = &cave[y][0];
1702 f_ptr = &f_info[c_ptr->mimic];
1704 /* Lose room and vault */
1705 c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1707 /* Set boundary mimic if needed */
1708 if (c_ptr->mimic && have_flag(f_ptr->flags, FF_HURT_DISI))
1710 c_ptr->mimic = feat_state(c_ptr->mimic, FF_HURT_DISI);
1712 /* Check for change to boring grid */
1713 if (!have_flag(f_info[c_ptr->mimic].flags, FF_REMEMBER)) c_ptr->info &= ~(CAVE_MARK);
1716 c_ptr = &cave[y][cur_wid - 1];
1717 f_ptr = &f_info[c_ptr->mimic];
1719 /* Lose room and vault */
1720 c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1722 /* Set boundary mimic if needed */
1723 if (c_ptr->mimic && have_flag(f_ptr->flags, FF_HURT_DISI))
1725 c_ptr->mimic = feat_state(c_ptr->mimic, FF_HURT_DISI);
1727 /* Check for change to boring grid */
1728 if (!have_flag(f_info[c_ptr->mimic].flags, FF_REMEMBER)) c_ptr->info &= ~(CAVE_MARK);
1732 /* Mega-Hack -- Forget the view and lite */
1733 p_ptr->update |= (PU_UN_VIEW | PU_UN_LITE);
1736 p_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MON_LITE);
1738 /* Update the monsters */
1739 p_ptr->update |= (PU_MONSTERS);
1742 p_ptr->redraw |= (PR_MAP);
1745 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
1751 void call_the_(void)
1755 bool do_call = TRUE;
1757 for (i = 0; i < 9; i++)
1759 c_ptr = &cave[py + ddy_ddd[i]][px + ddx_ddd[i]];
1761 if (!cave_have_flag_grid(c_ptr, FF_PROJECT))
1763 if (!c_ptr->mimic || !have_flag(f_info[c_ptr->mimic].flags, FF_PROJECT) ||
1764 !permanent_wall(&f_info[c_ptr->feat]))
1774 for (i = 1; i < 10; i++)
1776 if (i - 5) fire_ball(GF_ROCKET, i, 175, 2);
1779 for (i = 1; i < 10; i++)
1781 if (i - 5) fire_ball(GF_MANA, i, 175, 3);
1784 for (i = 1; i < 10; i++)
1786 if (i - 5) fire_ball(GF_NUKE, i, 175, 4);
1790 /* Prevent destruction of quest levels and town */
1791 else if ((p_ptr->inside_quest && is_fixed_quest_idx(p_ptr->inside_quest)) || !dun_level)
1794 msg_print("ÃÏÌ̤¬Íɤ줿¡£");
1796 msg_print("The ground trembles.");
1803 msg_format("¤¢¤Ê¤¿¤Ï%s¤òÊɤ˶᤹¤®¤ë¾ì½ê¤Ç¾§¤¨¤Æ¤·¤Þ¤Ã¤¿¡ª",
1804 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "µ§¤ê" : "¼öʸ"));
1805 msg_print("Â礤ÊÇúȯ²»¤¬¤¢¤Ã¤¿¡ª");
1807 msg_format("You %s the %s too close to a wall!",
1808 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "recite" : "cast"),
1809 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "prayer" : "spell"));
1810 msg_print("There is a loud explosion!");
1816 if (!vanish_dungeon()) msg_print("¥À¥ó¥¸¥ç¥ó¤Ï°ì½ÖÀŤޤêÊ֤ä¿¡£");
1818 if (!vanish_dungeon()) msg_print("The dungeon silences a moment.");
1823 if (destroy_area(py, px, 15 + p_ptr->lev + randint0(11), FALSE))
1825 msg_print("¥À¥ó¥¸¥ç¥ó¤¬Êø²õ¤·¤¿...");
1827 msg_print("The dungeon collapses...");
1832 msg_print("¥À¥ó¥¸¥ç¥ó¤ÏÂ礤¯Íɤ줿¡£");
1834 msg_print("The dungeon trembles.");
1839 take_hit(DAMAGE_NOESCAPE, 100 + randint1(150), "¼«»¦Åª¤Êµõ̵¾·Íè", -1);
1841 take_hit(DAMAGE_NOESCAPE, 100 + randint1(150), "a suicidal Call the Void", -1);
1848 * Fetch an item (teleport it right underneath the caster)
1850 void fetch(int dir, int wgt, bool require_los)
1855 char o_name[MAX_NLEN];
1857 /* Check to see if an object is already there */
1858 if (cave[py][px].o_idx)
1861 msg_print("¼«Ê¬¤Î¤β¼¤Ë¤¢¤ëʪ¤Ï¼è¤ì¤Þ¤»¤ó¡£");
1863 msg_print("You can't fetch when you're already standing on something.");
1870 if (dir == 5 && target_okay())
1875 if (distance(py, px, ty, tx) > MAX_RANGE)
1878 msg_print("¤½¤ó¤Ê¤Ë±ó¤¯¤Ë¤¢¤ëʪ¤Ï¼è¤ì¤Þ¤»¤ó¡ª");
1880 msg_print("You can't fetch something that far away!");
1886 c_ptr = &cave[ty][tx];
1888 /* We need an item to fetch */
1892 msg_print("¤½¤³¤Ë¤Ï²¿¤â¤¢¤ê¤Þ¤»¤ó¡£");
1894 msg_print("There is no object at this place.");
1900 /* No fetching from vault */
1901 if (c_ptr->info & CAVE_ICKY)
1904 msg_print("¥¢¥¤¥Æ¥à¤¬¥³¥ó¥È¥í¡¼¥ë¤ò³°¤ì¤ÆÍî¤Á¤¿¡£");
1906 msg_print("The item slips from your control.");
1912 /* We need to see the item */
1915 if (!player_has_los_bold(ty, tx))
1918 msg_print("¤½¤³¤Ï¤¢¤Ê¤¿¤Î»ë³¦¤ËÆþ¤Ã¤Æ¤¤¤Þ¤»¤ó¡£");
1920 msg_print("You have no direct line of sight to that location.");
1925 else if (!projectable(py, px, ty, tx))
1928 msg_print("¤½¤³¤ÏÊɤθþ¤³¤¦¤Ç¤¹¡£");
1930 msg_print("You have no direct line of sight to that location.");
1939 /* Use a direction */
1940 ty = py; /* Where to drop the item */
1947 c_ptr = &cave[ty][tx];
1949 if ((distance(py, px, ty, tx) > MAX_RANGE) ||
1950 !cave_have_flag_bold(ty, tx, FF_PROJECT)) return;
1952 while (!c_ptr->o_idx);
1955 o_ptr = &o_list[c_ptr->o_idx];
1957 if (o_ptr->weight > wgt)
1959 /* Too heavy to 'fetch' */
1961 msg_print("¤½¤Î¥¢¥¤¥Æ¥à¤Ï½Å²á¤®¤Þ¤¹¡£");
1963 msg_print("The object is too heavy.");
1970 c_ptr->o_idx = o_ptr->next_o_idx;
1971 cave[py][px].o_idx = i; /* 'move' it */
1972 o_ptr->next_o_idx = 0;
1973 o_ptr->iy = (byte)py;
1974 o_ptr->ix = (byte)px;
1976 object_desc(o_name, o_ptr, OD_NAME_ONLY);
1978 msg_format("%^s¤¬¤¢¤Ê¤¿¤Î¸µ¤ËÈô¤ó¤Ç¤¤¿¡£", o_name);
1980 msg_format("%^s flies through the air to your feet.", o_name);
1985 p_ptr->redraw |= PR_MAP;
1989 void alter_reality(void)
1991 /* Ironman option */
1992 if (p_ptr->inside_arena || ironman_downward)
1995 msg_print("²¿¤âµ¯¤³¤é¤Ê¤«¤Ã¤¿¡£");
1997 msg_print("Nothing happens.");
2002 if (!p_ptr->alter_reality)
2004 int turns = randint0(21) + 15;
2006 p_ptr->alter_reality = turns;
2008 msg_print("²ó¤ê¤Î·Ê¿§¤¬ÊѤï¤ê»Ï¤á¤¿...");
2010 msg_print("The view around you begins to change...");
2013 p_ptr->redraw |= (PR_STATUS);
2017 p_ptr->alter_reality = 0;
2019 msg_print("·Ê¿§¤¬¸µ¤ËÌá¤Ã¤¿...");
2021 msg_print("The view around you got back...");
2024 p_ptr->redraw |= (PR_STATUS);
2031 * Leave a "glyph of warding" which prevents monster movement
2033 bool warding_glyph(void)
2036 if (!cave_clean_bold(py, px))
2039 msg_print("¾²¾å¤Î¥¢¥¤¥Æ¥à¤¬¼öʸ¤òÄ·¤ÍÊÖ¤·¤¿¡£");
2041 msg_print("The object resists the spell.");
2047 /* Create a glyph */
2048 cave[py][px].info |= CAVE_OBJECT;
2049 cave[py][px].mimic = feat_glyph;
2060 bool place_mirror(void)
2063 if (!cave_clean_bold(py, px))
2066 msg_print("¾²¾å¤Î¥¢¥¤¥Æ¥à¤¬¼öʸ¤òÄ·¤ÍÊÖ¤·¤¿¡£");
2068 msg_print("The object resists the spell.");
2074 /* Create a mirror */
2075 cave[py][px].info |= CAVE_OBJECT;
2076 cave[py][px].mimic = feat_mirror;
2078 /* Turn on the light */
2079 cave[py][px].info |= CAVE_GLOW;
2087 update_local_illumination(py, px);
2094 * Leave an "explosive rune" which prevents monster movement
2096 bool explosive_rune(void)
2099 if (!cave_clean_bold(py, px))
2102 msg_print("¾²¾å¤Î¥¢¥¤¥Æ¥à¤¬¼öʸ¤òÄ·¤ÍÊÖ¤·¤¿¡£");
2104 msg_print("The object resists the spell.");
2110 /* Create a glyph */
2111 cave[py][px].info |= CAVE_OBJECT;
2112 cave[py][px].mimic = feat_explosive_rune;
2125 * Identify everything being carried.
2126 * Done by a potion of "self knowledge".
2128 void identify_pack(void)
2132 /* Simply identify and know every item */
2133 for (i = 0; i < INVEN_TOTAL; i++)
2135 object_type *o_ptr = &inventory[i];
2137 /* Skip non-objects */
2138 if (!o_ptr->k_idx) continue;
2141 identify_item(o_ptr);
2143 /* Auto-inscription */
2144 autopick_alter_item(i, FALSE);
2150 * Used by the "enchant" function (chance of failure)
2151 * (modified for Zangband, we need better stuff there...) -- TY
2153 static int enchant_table[16] =
2155 0, 10, 50, 100, 200,
2156 300, 400, 500, 650, 800,
2157 950, 987, 993, 995, 998,
2163 * Removes curses from items in inventory
2165 * Note that Items which are "Perma-Cursed" (The One Ring,
2166 * The Crown of Morgoth) can NEVER be uncursed.
2168 * Note that if "all" is FALSE, then Items which are
2169 * "Heavy-Cursed" (Mormegil, Calris, and Weapons of Morgul)
2170 * will not be uncursed.
2172 static int remove_curse_aux(int all)
2176 /* Attempt to uncurse items being worn */
2177 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
2179 object_type *o_ptr = &inventory[i];
2181 /* Skip non-objects */
2182 if (!o_ptr->k_idx) continue;
2184 /* Uncursed already */
2185 if (!object_is_cursed(o_ptr)) continue;
2187 /* Heavily Cursed Items need a special spell */
2188 if (!all && (o_ptr->curse_flags & TRC_HEAVY_CURSE)) continue;
2190 /* Perma-Cursed Items can NEVER be uncursed */
2191 if (o_ptr->curse_flags & TRC_PERMA_CURSE)
2194 o_ptr->curse_flags &= (TRC_CURSED | TRC_HEAVY_CURSE | TRC_PERMA_CURSE);
2199 o_ptr->curse_flags = 0L;
2201 /* Hack -- Assume felt */
2202 o_ptr->ident |= (IDENT_SENSE);
2205 o_ptr->feeling = FEEL_NONE;
2207 /* Recalculate the bonuses */
2208 p_ptr->update |= (PU_BONUS);
2211 p_ptr->window |= (PW_EQUIP);
2213 /* Count the uncursings */
2217 /* Return "something uncursed" */
2223 * Remove most curses
2225 bool remove_curse(void)
2227 return (remove_curse_aux(FALSE));
2233 bool remove_all_curse(void)
2235 return (remove_curse_aux(TRUE));
2240 * Turns an object into gold, gain some of its value in a shop
2249 char o_name[MAX_NLEN];
2250 char out_val[MAX_NLEN+40];
2254 /* Hack -- force destruction */
2255 if (command_arg > 0) force = TRUE;
2259 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò¶â¤ËÊѤ¨¤Þ¤¹¤«¡©";
2260 s = "¶â¤ËÊѤ¨¤é¤ì¤ëʪ¤¬¤¢¤ê¤Þ¤»¤ó¡£";
2262 q = "Turn which item to gold? ";
2263 s = "You have nothing to turn to gold.";
2266 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return (FALSE);
2268 /* Get the item (in the pack) */
2271 o_ptr = &inventory[item];
2274 /* Get the item (on the floor) */
2277 o_ptr = &o_list[0 - item];
2281 /* See how many items */
2282 if (o_ptr->number > 1)
2284 /* Get a quantity */
2285 amt = get_quantity(NULL, o_ptr->number);
2287 /* Allow user abort */
2288 if (amt <= 0) return FALSE;
2292 /* Describe the object */
2293 old_number = o_ptr->number;
2294 o_ptr->number = amt;
2295 object_desc(o_name, o_ptr, 0);
2296 o_ptr->number = old_number;
2298 /* Verify unless quantity given */
2301 if (confirm_destroy || (object_value(o_ptr) > 0))
2303 /* Make a verification */
2305 sprintf(out_val, "ËÜÅö¤Ë%s¤ò¶â¤ËÊѤ¨¤Þ¤¹¤«¡©", o_name);
2307 sprintf(out_val, "Really turn %s to gold? ", o_name);
2310 if (!get_check(out_val)) return FALSE;
2314 /* Artifacts cannot be destroyed */
2315 if (!can_player_destroy_object(o_ptr))
2319 msg_format("%s¤ò¶â¤ËÊѤ¨¤ë¤³¤È¤Ë¼ºÇÔ¤·¤¿¡£", o_name);
2321 msg_format("You fail to turn %s to gold!", o_name);
2328 price = object_value_real(o_ptr);
2334 msg_format("%s¤ò¥Ë¥»¤Î¶â¤ËÊѤ¨¤¿¡£", o_name);
2336 msg_format("You turn %s to fool's gold.", o_name);
2344 if (amt > 1) price *= amt;
2346 if (price > 30000) price = 30000;
2348 msg_format("%s¤ò¡ð%d ¤Î¶â¤ËÊѤ¨¤¿¡£", o_name, price);
2350 msg_format("You turn %s to %ld coins worth of gold.", o_name, price);
2356 p_ptr->redraw |= (PR_GOLD);
2359 p_ptr->window |= (PW_PLAYER);
2363 /* Eliminate the item (from the pack) */
2366 inven_item_increase(item, -amt);
2367 inven_item_describe(item);
2368 inven_item_optimize(item);
2371 /* Eliminate the item (from the floor) */
2374 floor_item_increase(0 - item, -amt);
2375 floor_item_describe(0 - item);
2376 floor_item_optimize(0 - item);
2384 * Break the curse of an item
2386 static void break_curse(object_type *o_ptr)
2388 if (object_is_cursed(o_ptr) && !(o_ptr->curse_flags & TRC_PERMA_CURSE) && !(o_ptr->curse_flags & TRC_HEAVY_CURSE) && (randint0(100) < 25))
2391 msg_print("¤«¤±¤é¤ì¤Æ¤¤¤¿¼ö¤¤¤¬ÂǤÁÇˤé¤ì¤¿¡ª");
2393 msg_print("The curse is broken!");
2396 o_ptr->curse_flags = 0L;
2398 o_ptr->ident |= (IDENT_SENSE);
2400 o_ptr->feeling = FEEL_NONE;
2406 * Enchants a plus onto an item. -RAK-
2408 * Revamped! Now takes item pointer, number of times to try enchanting,
2409 * and a flag of what to try enchanting. Artifacts resist enchantment
2410 * some of the time, and successful enchantment to at least +0 might
2411 * break a curse on the item. -CFT-
2413 * Note that an item can technically be enchanted all the way to +15 if
2414 * you wait a very, very, long time. Going from +9 to +10 only works
2415 * about 5% of the time, and from +10 to +11 only about 1% of the time.
2417 * Note that this function can now be used on "piles" of items, and
2418 * the larger the pile, the lower the chance of success.
2420 bool enchant(object_type *o_ptr, int n, int eflag)
2422 int i, chance, prob;
2424 bool a = object_is_artifact(o_ptr);
2425 bool force = (eflag & ENCH_FORCE);
2428 /* Large piles resist enchantment */
2429 prob = o_ptr->number * 100;
2431 /* Missiles are easy to enchant */
2432 if ((o_ptr->tval == TV_BOLT) ||
2433 (o_ptr->tval == TV_ARROW) ||
2434 (o_ptr->tval == TV_SHOT))
2440 for (i = 0; i < n; i++)
2442 /* Hack -- Roll for pile resistance */
2443 if (!force && randint0(prob) >= 100) continue;
2445 /* Enchant to hit */
2446 if (eflag & ENCH_TOHIT)
2448 if (o_ptr->to_h < 0) chance = 0;
2449 else if (o_ptr->to_h > 15) chance = 1000;
2450 else chance = enchant_table[o_ptr->to_h];
2452 if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50))))
2457 /* only when you get it above -1 -CFT */
2458 if (o_ptr->to_h >= 0)
2463 /* Enchant to damage */
2464 if (eflag & ENCH_TODAM)
2466 if (o_ptr->to_d < 0) chance = 0;
2467 else if (o_ptr->to_d > 15) chance = 1000;
2468 else chance = enchant_table[o_ptr->to_d];
2470 if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50))))
2475 /* only when you get it above -1 -CFT */
2476 if (o_ptr->to_d >= 0)
2481 /* Enchant to armor class */
2482 if (eflag & ENCH_TOAC)
2484 if (o_ptr->to_a < 0) chance = 0;
2485 else if (o_ptr->to_a > 15) chance = 1000;
2486 else chance = enchant_table[o_ptr->to_a];
2488 if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50))))
2493 /* only when you get it above -1 -CFT */
2494 if (o_ptr->to_a >= 0)
2501 if (!res) return (FALSE);
2503 /* Recalculate bonuses */
2504 p_ptr->update |= (PU_BONUS);
2506 /* Combine / Reorder the pack (later) */
2507 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
2510 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
2521 * Enchant an item (in the inventory or on the floor)
2522 * Note that "num_ac" requires armour, else weapon
2523 * Returns TRUE if attempted, FALSE if cancelled
2525 bool enchant_spell(int num_hit, int num_dam, int num_ac)
2530 char o_name[MAX_NLEN];
2534 /* Assume enchant weapon */
2535 item_tester_hook = object_allow_enchant_weapon;
2536 item_tester_no_ryoute = TRUE;
2538 /* Enchant armor if requested */
2539 if (num_ac) item_tester_hook = object_is_armour;
2543 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò¶¯²½¤·¤Þ¤¹¤«? ";
2544 s = "¶¯²½¤Ç¤¤ë¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
2546 q = "Enchant which item? ";
2547 s = "You have nothing to enchant.";
2550 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2552 /* Get the item (in the pack) */
2555 o_ptr = &inventory[item];
2558 /* Get the item (on the floor) */
2561 o_ptr = &o_list[0 - item];
2566 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2570 msg_format("%s ¤ÏÌÀ¤ë¤¯µ±¤¤¤¿¡ª",
2573 msg_format("%s %s glow%s brightly!",
2574 ((item >= 0) ? "Your" : "The"), o_name,
2575 ((o_ptr->number > 1) ? "" : "s"));
2580 if (enchant(o_ptr, num_hit, ENCH_TOHIT)) okay = TRUE;
2581 if (enchant(o_ptr, num_dam, ENCH_TODAM)) okay = TRUE;
2582 if (enchant(o_ptr, num_ac, ENCH_TOAC)) okay = TRUE;
2588 if (flush_failure) flush();
2592 msg_print("¶¯²½¤Ë¼ºÇÔ¤·¤¿¡£");
2594 msg_print("The enchantment failed.");
2597 if (one_in_(3)) chg_virtue(V_ENCHANT, -1);
2600 chg_virtue(V_ENCHANT, 1);
2604 /* Something happened */
2610 * Check if an object is nameless weapon or armour
2612 static bool item_tester_hook_nameless_weapon_armour(object_type *o_ptr)
2614 /* Require weapon or armour */
2615 if (!object_is_weapon_armour_ammo(o_ptr)) return FALSE;
2617 /* Require nameless object if the object is well known */
2618 if (object_is_known(o_ptr) && !object_is_nameless(o_ptr))
2625 bool artifact_scroll(void)
2630 char o_name[MAX_NLEN];
2634 item_tester_no_ryoute = TRUE;
2636 /* Enchant weapon/armour */
2637 item_tester_hook = item_tester_hook_nameless_weapon_armour;
2641 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò¶¯²½¤·¤Þ¤¹¤«? ";
2642 s = "¶¯²½¤Ç¤¤ë¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
2644 q = "Enchant which item? ";
2645 s = "You have nothing to enchant.";
2648 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2650 /* Get the item (in the pack) */
2653 o_ptr = &inventory[item];
2656 /* Get the item (on the floor) */
2659 o_ptr = &o_list[0 - item];
2664 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2668 msg_format("%s ¤ÏâÁ¤¤¸÷¤òȯ¤·¤¿¡ª",o_name);
2670 msg_format("%s %s radiate%s a blinding light!",
2671 ((item >= 0) ? "Your" : "The"), o_name,
2672 ((o_ptr->number > 1) ? "" : "s"));
2675 if (object_is_artifact(o_ptr))
2678 msg_format("%s¤Ï´û¤ËÅÁÀâ¤Î¥¢¥¤¥Æ¥à¤Ç¤¹¡ª", o_name );
2680 msg_format("The %s %s already %s!",
2681 o_name, ((o_ptr->number > 1) ? "are" : "is"),
2682 ((o_ptr->number > 1) ? "artifacts" : "an artifact"));
2688 else if (object_is_ego(o_ptr))
2691 msg_format("%s¤Ï´û¤Ë̾¤Î¤¢¤ë¥¢¥¤¥Æ¥à¤Ç¤¹¡ª", o_name );
2693 msg_format("The %s %s already %s!",
2694 o_name, ((o_ptr->number > 1) ? "are" : "is"),
2695 ((o_ptr->number > 1) ? "ego items" : "an ego item"));
2701 else if (o_ptr->xtra3)
2704 msg_format("%s¤Ï´û¤Ë¶¯²½¤µ¤ì¤Æ¤¤¤Þ¤¹¡ª", o_name );
2706 msg_format("The %s %s already %s!",
2707 o_name, ((o_ptr->number > 1) ? "are" : "is"),
2708 ((o_ptr->number > 1) ? "customized items" : "a customized item"));
2714 if (o_ptr->number > 1)
2717 msg_print("Ê£¿ô¤Î¥¢¥¤¥Æ¥à¤ËËâË¡¤ò¤«¤±¤ë¤À¤±¤Î¥¨¥Í¥ë¥®¡¼¤Ï¤¢¤ê¤Þ¤»¤ó¡ª");
2718 msg_format("%d ¸Ä¤Î%s¤¬²õ¤ì¤¿¡ª",(o_ptr->number)-1, o_name);
2720 msg_print("Not enough enough energy to enchant more than one object!");
2721 msg_format("%d of your %s %s destroyed!",(o_ptr->number)-1, o_name, (o_ptr->number>2?"were":"was"));
2726 inven_item_increase(item, 1-(o_ptr->number));
2730 floor_item_increase(0-item, 1-(o_ptr->number));
2733 okay = create_artifact(o_ptr, TRUE);
2740 if (flush_failure) flush();
2744 msg_print("¶¯²½¤Ë¼ºÇÔ¤·¤¿¡£");
2746 msg_print("The enchantment failed.");
2749 if (one_in_(3)) chg_virtue(V_ENCHANT, -1);
2752 chg_virtue(V_ENCHANT, 1);
2756 /* Something happened */
2762 * Identify an object
2764 bool identify_item(object_type *o_ptr)
2766 bool old_known = FALSE;
2767 char o_name[MAX_NLEN];
2770 object_desc(o_name, o_ptr, 0);
2772 if (o_ptr->ident & IDENT_KNOWN)
2775 if (!(o_ptr->ident & (IDENT_MENTAL)))
2777 if (object_is_artifact(o_ptr) || one_in_(5))
2778 chg_virtue(V_KNOWLEDGE, 1);
2781 /* Identify it fully */
2782 object_aware(o_ptr);
2783 object_known(o_ptr);
2785 /* Player touches it */
2786 o_ptr->marked |= OM_TOUCHED;
2788 /* Recalculate bonuses */
2789 p_ptr->update |= (PU_BONUS);
2791 /* Combine / Reorder the pack (later) */
2792 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
2795 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
2797 strcpy(record_o_name, o_name);
2801 object_desc(o_name, o_ptr, OD_NAME_ONLY);
2803 if(record_fix_art && !old_known && object_is_fixed_artifact(o_ptr))
2804 do_cmd_write_nikki(NIKKI_ART, 0, o_name);
2805 if(record_rand_art && !old_known && o_ptr->art_name)
2806 do_cmd_write_nikki(NIKKI_ART, 0, o_name);
2812 static bool item_tester_hook_identify(object_type *o_ptr)
2814 return (bool)!object_is_known(o_ptr);
2817 static bool item_tester_hook_identify_weapon_armour(object_type *o_ptr)
2819 if (object_is_known(o_ptr))
2821 return object_is_weapon_armour_ammo(o_ptr);
2825 * Identify an object in the inventory (or on the floor)
2826 * This routine does *not* automatically combine objects.
2827 * Returns TRUE if something was identified, else FALSE.
2829 bool ident_spell(bool only_equip)
2833 char o_name[MAX_NLEN];
2837 item_tester_no_ryoute = TRUE;
2840 item_tester_hook = item_tester_hook_identify_weapon_armour;
2842 item_tester_hook = item_tester_hook_identify;
2847 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò´ÕÄꤷ¤Þ¤¹¤«? ";
2849 q = "Identify which item? ";
2855 item_tester_hook = object_is_weapon_armour_ammo;
2857 item_tester_hook = NULL;
2860 q = "¤¹¤Ù¤Æ´ÕÄêºÑ¤ß¤Ç¤¹¡£ ";
2862 q = "All items are identified. ";
2868 s = "´ÕÄꤹ¤ë¤Ù¤¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
2870 s = "You have nothing to identify.";
2873 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2875 /* Get the item (in the pack) */
2878 o_ptr = &inventory[item];
2881 /* Get the item (on the floor) */
2884 o_ptr = &o_list[0 - item];
2888 old_known = identify_item(o_ptr);
2891 object_desc(o_name, o_ptr, 0);
2894 if (item >= INVEN_RARM)
2897 msg_format("%^s: %s(%c)¡£", describe_use(item), o_name, index_to_label(item));
2899 msg_format("%^s: %s (%c).", describe_use(item), o_name, index_to_label(item));
2905 msg_format("¥¶¥Ã¥¯Ãæ: %s(%c)¡£", o_name, index_to_label(item));
2907 msg_format("In your pack: %s (%c).", o_name, index_to_label(item));
2913 msg_format("¾²¾å: %s¡£", o_name);
2915 msg_format("On the ground: %s.", o_name);
2919 /* Auto-inscription/destroy */
2920 autopick_alter_item(item, (bool)(destroy_identify && !old_known));
2922 /* Something happened */
2928 * Mundanify an object in the inventory (or on the floor)
2929 * This routine does *not* automatically combine objects.
2930 * Returns TRUE if something was mundanified, else FALSE.
2932 bool mundane_spell(bool only_equip)
2938 if (only_equip) item_tester_hook = object_is_weapon_armour_ammo;
2939 item_tester_no_ryoute = TRUE;
2943 q = "¤É¤ì¤ò»È¤¤¤Þ¤¹¤«¡©";
2944 s = "»È¤¨¤ë¤â¤Î¤¬¤¢¤ê¤Þ¤»¤ó¡£";
2946 q = "Use which item? ";
2947 s = "You have nothing you can use.";
2950 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2952 /* Get the item (in the pack) */
2955 o_ptr = &inventory[item];
2958 /* Get the item (on the floor) */
2961 o_ptr = &o_list[0 - item];
2966 msg_print("¤Þ¤Ð¤æ¤¤Á®¸÷¤¬Áö¤Ã¤¿¡ª");
2968 msg_print("There is a bright flash of light!");
2971 byte iy = o_ptr->iy; /* Y-position on map, or zero */
2972 byte ix = o_ptr->ix; /* X-position on map, or zero */
2973 s16b next_o_idx = o_ptr->next_o_idx; /* Next object in stack (if any) */
2974 byte marked = o_ptr->marked; /* Object is marked */
2975 s16b weight = o_ptr->number * o_ptr->weight;
2976 u16b inscription = o_ptr->inscription;
2979 object_prep(o_ptr, o_ptr->k_idx);
2983 o_ptr->next_o_idx = next_o_idx;
2984 o_ptr->marked = marked;
2985 o_ptr->inscription = inscription;
2986 if (item >= 0) p_ptr->total_weight += (o_ptr->weight - weight);
2990 /* Something happened */
2996 static bool item_tester_hook_identify_fully(object_type *o_ptr)
2998 return (bool)(!object_is_known(o_ptr) || !(o_ptr->ident & IDENT_MENTAL));
3001 static bool item_tester_hook_identify_fully_weapon_armour(object_type *o_ptr)
3003 if (!item_tester_hook_identify_fully(o_ptr))
3005 return object_is_weapon_armour_ammo(o_ptr);
3009 * Fully "identify" an object in the inventory -BEN-
3010 * This routine returns TRUE if an item was identified.
3012 bool identify_fully(bool only_equip)
3016 char o_name[MAX_NLEN];
3020 item_tester_no_ryoute = TRUE;
3022 item_tester_hook = item_tester_hook_identify_fully_weapon_armour;
3024 item_tester_hook = item_tester_hook_identify_fully;
3029 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò*´ÕÄê*¤·¤Þ¤¹¤«? ";
3031 q = "*Identify* which item? ";
3037 item_tester_hook = object_is_weapon_armour_ammo;
3039 item_tester_hook = NULL;
3042 q = "¤¹¤Ù¤Æ*´ÕÄê*ºÑ¤ß¤Ç¤¹¡£ ";
3044 q = "All items are *identified*. ";
3050 s = "*´ÕÄê*¤¹¤ë¤Ù¤¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
3052 s = "You have nothing to *identify*.";
3055 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
3057 /* Get the item (in the pack) */
3060 o_ptr = &inventory[item];
3063 /* Get the item (on the floor) */
3066 o_ptr = &o_list[0 - item];
3070 old_known = identify_item(o_ptr);
3072 /* Mark the item as fully known */
3073 o_ptr->ident |= (IDENT_MENTAL);
3079 object_desc(o_name, o_ptr, 0);
3082 if (item >= INVEN_RARM)
3085 msg_format("%^s: %s(%c)¡£", describe_use(item), o_name, index_to_label(item));
3087 msg_format("%^s: %s (%c).", describe_use(item), o_name, index_to_label(item));
3095 msg_format("¥¶¥Ã¥¯Ãæ: %s(%c)¡£", o_name, index_to_label(item));
3097 msg_format("In your pack: %s (%c).", o_name, index_to_label(item));
3103 msg_format("¾²¾å: %s¡£", o_name);
3105 msg_format("On the ground: %s.", o_name);
3109 /* Describe it fully */
3110 (void)screen_object(o_ptr, 0L);
3112 /* Auto-inscription/destroy */
3113 autopick_alter_item(item, (bool)(destroy_identify && !old_known));
3123 * Hook for "get_item()". Determine if something is rechargable.
3125 bool item_tester_hook_recharge(object_type *o_ptr)
3127 /* Recharge staffs */
3128 if (o_ptr->tval == TV_STAFF) return (TRUE);
3130 /* Recharge wands */
3131 if (o_ptr->tval == TV_WAND) return (TRUE);
3133 /* Hack -- Recharge rods */
3134 if (o_ptr->tval == TV_ROD) return (TRUE);
3142 * Recharge a wand/staff/rod from the pack or on the floor.
3143 * This function has been rewritten in Oangband and ZAngband.
3145 * Sorcery/Arcane -- Recharge --> recharge(plev * 4)
3146 * Chaos -- Arcane Binding --> recharge(90)
3148 * Scroll of recharging --> recharge(130)
3149 * Artifact activation/Thingol --> recharge(130)
3151 * It is harder to recharge high level, and highly charged wands,
3152 * staffs, and rods. The more wands in a stack, the more easily and
3153 * strongly they recharge. Staffs, however, each get fewer charges if
3156 * XXX XXX XXX Beware of "sliding index errors".
3158 bool recharge(int power)
3161 int recharge_strength, recharge_amount;
3170 char o_name[MAX_NLEN];
3172 /* Only accept legal items */
3173 item_tester_hook = item_tester_hook_recharge;
3177 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ËËâÎϤò½¼Å¶¤·¤Þ¤¹¤«? ";
3178 s = "ËâÎϤò½¼Å¶¤¹¤Ù¤¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
3180 q = "Recharge which item? ";
3181 s = "You have nothing to recharge.";
3184 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return (FALSE);
3186 /* Get the item (in the pack) */
3189 o_ptr = &inventory[item];
3192 /* Get the item (on the floor) */
3195 o_ptr = &o_list[0 - item];
3198 /* Get the object kind. */
3199 k_ptr = &k_info[o_ptr->k_idx];
3201 /* Extract the object "level" */
3202 lev = k_info[o_ptr->k_idx].level;
3205 /* Recharge a rod */
3206 if (o_ptr->tval == TV_ROD)
3208 /* Extract a recharge strength by comparing object level to power. */
3209 recharge_strength = ((power > lev/2) ? (power - lev/2) : 0) / 5;
3213 if (one_in_(recharge_strength))
3215 /* Activate the failure code. */
3222 /* Recharge amount */
3223 recharge_amount = (power * damroll(3, 2));
3225 /* Recharge by that amount */
3226 if (o_ptr->timeout > recharge_amount)
3227 o_ptr->timeout -= recharge_amount;
3234 /* Recharge wand/staff */
3237 /* Extract a recharge strength by comparing object level to power.
3238 * Divide up a stack of wands' charges to calculate charge penalty.
3240 if ((o_ptr->tval == TV_WAND) && (o_ptr->number > 1))
3241 recharge_strength = (100 + power - lev -
3242 (8 * o_ptr->pval / o_ptr->number)) / 15;
3244 /* All staffs, unstacked wands. */
3245 else recharge_strength = (100 + power - lev -
3246 (8 * o_ptr->pval)) / 15;
3249 if (recharge_strength < 0) recharge_strength = 0;
3252 if (one_in_(recharge_strength))
3254 /* Activate the failure code. */
3258 /* If the spell didn't backfire, recharge the wand or staff. */
3261 /* Recharge based on the standard number of charges. */
3262 recharge_amount = randint1(1 + k_ptr->pval / 2);
3264 /* Multiple wands in a stack increase recharging somewhat. */
3265 if ((o_ptr->tval == TV_WAND) && (o_ptr->number > 1))
3268 (randint1(recharge_amount * (o_ptr->number - 1))) / 2;
3269 if (recharge_amount < 1) recharge_amount = 1;
3270 if (recharge_amount > 12) recharge_amount = 12;
3273 /* But each staff in a stack gets fewer additional charges,
3274 * although always at least one.
3276 if ((o_ptr->tval == TV_STAFF) && (o_ptr->number > 1))
3278 recharge_amount /= o_ptr->number;
3279 if (recharge_amount < 1) recharge_amount = 1;
3282 /* Recharge the wand or staff. */
3283 o_ptr->pval += recharge_amount;
3286 /* Hack -- we no longer "know" the item */
3287 o_ptr->ident &= ~(IDENT_KNOWN);
3289 /* Hack -- we no longer think the item is empty */
3290 o_ptr->ident &= ~(IDENT_EMPTY);
3295 /* Inflict the penalties for failing a recharge. */
3298 /* Artifacts are never destroyed. */
3299 if (object_is_fixed_artifact(o_ptr))
3301 object_desc(o_name, o_ptr, OD_NAME_ONLY);
3303 msg_format("ËâÎϤ¬µÕή¤·¤¿¡ª%s¤Ï´°Á´¤ËËâÎϤò¼º¤Ã¤¿¡£", o_name);
3305 msg_format("The recharging backfires - %s is completely drained!", o_name);
3309 /* Artifact rods. */
3310 if ((o_ptr->tval == TV_ROD) && (o_ptr->timeout < 10000))
3311 o_ptr->timeout = (o_ptr->timeout + 100) * 2;
3313 /* Artifact wands and staffs. */
3314 else if ((o_ptr->tval == TV_WAND) || (o_ptr->tval == TV_STAFF))
3319 /* Get the object description */
3320 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
3322 /*** Determine Seriousness of Failure ***/
3324 /* Mages recharge objects more safely. */
3325 if (p_ptr->pclass == CLASS_MAGE || p_ptr->pclass == CLASS_HIGH_MAGE || p_ptr->pclass == CLASS_SORCERER || p_ptr->pclass == CLASS_MAGIC_EATER || p_ptr->pclass == CLASS_BLUE_MAGE)
3327 /* 10% chance to blow up one rod, otherwise draining. */
3328 if (o_ptr->tval == TV_ROD)
3330 if (one_in_(10)) fail_type = 2;
3333 /* 75% chance to blow up one wand, otherwise draining. */
3334 else if (o_ptr->tval == TV_WAND)
3336 if (!one_in_(3)) fail_type = 2;
3339 /* 50% chance to blow up one staff, otherwise no effect. */
3340 else if (o_ptr->tval == TV_STAFF)
3342 if (one_in_(2)) fail_type = 2;
3347 /* All other classes get no special favors. */
3350 /* 33% chance to blow up one rod, otherwise draining. */
3351 if (o_ptr->tval == TV_ROD)
3353 if (one_in_(3)) fail_type = 2;
3356 /* 20% chance of the entire stack, else destroy one wand. */
3357 else if (o_ptr->tval == TV_WAND)
3359 if (one_in_(5)) fail_type = 3;
3362 /* Blow up one staff. */
3363 else if (o_ptr->tval == TV_STAFF)
3369 /*** Apply draining and destruction. ***/
3371 /* Drain object or stack of objects. */
3374 if (o_ptr->tval == TV_ROD)
3377 msg_print("ËâÎϤ¬µÕÊ®¼Í¤·¤Æ¡¢¥í¥Ã¥É¤«¤é¤µ¤é¤ËËâÎϤòµÛ¤¤¼è¤Ã¤Æ¤·¤Þ¤Ã¤¿¡ª");
3379 msg_print("The recharge backfires, draining the rod further!");
3382 if (o_ptr->timeout < 10000)
3383 o_ptr->timeout = (o_ptr->timeout + 100) * 2;
3385 else if (o_ptr->tval == TV_WAND)
3388 msg_format("%s¤ÏÇË»¤òÌȤ줿¤¬¡¢ËâÎϤ¬Á´¤Æ¼º¤ï¤ì¤¿¡£", o_name);
3390 msg_format("You save your %s from destruction, but all charges are lost.", o_name);
3395 /* Staffs aren't drained. */
3398 /* Destroy an object or one in a stack of objects. */
3401 if (o_ptr->number > 1)
3403 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬°ìËܲõ¤ì¤¿¡ª", o_name);
3405 msg_format("Wild magic consumes one of your %s!", o_name);
3410 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬²õ¤ì¤¿¡ª", o_name);
3412 msg_format("Wild magic consumes your %s!", o_name);
3416 /* Reduce rod stack maximum timeout, drain wands. */
3417 if (o_ptr->tval == TV_ROD) o_ptr->timeout = (o_ptr->number - 1) * k_ptr->pval;
3418 if (o_ptr->tval == TV_WAND) o_ptr->pval = 0;
3420 /* Reduce and describe inventory */
3423 inven_item_increase(item, -1);
3424 inven_item_describe(item);
3425 inven_item_optimize(item);
3428 /* Reduce and describe floor item */
3431 floor_item_increase(0 - item, -1);
3432 floor_item_describe(0 - item);
3433 floor_item_optimize(0 - item);
3437 /* Destroy all members of a stack of objects. */
3440 if (o_ptr->number > 1)
3442 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬Á´¤Æ²õ¤ì¤¿¡ª", o_name);
3444 msg_format("Wild magic consumes all your %s!", o_name);
3449 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬²õ¤ì¤¿¡ª", o_name);
3451 msg_format("Wild magic consumes your %s!", o_name);
3456 /* Reduce and describe inventory */
3459 inven_item_increase(item, -999);
3460 inven_item_describe(item);
3461 inven_item_optimize(item);
3464 /* Reduce and describe floor item */
3467 floor_item_increase(0 - item, -999);
3468 floor_item_describe(0 - item);
3469 floor_item_optimize(0 - item);
3475 /* Combine / Reorder the pack (later) */
3476 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
3479 p_ptr->window |= (PW_INVEN);
3481 /* Something was done */
3489 bool bless_weapon(void)
3493 u32b flgs[TR_FLAG_SIZE];
3494 char o_name[MAX_NLEN];
3497 item_tester_no_ryoute = TRUE;
3499 /* Bless only weapons */
3500 item_tester_hook = object_is_weapon;
3504 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò½ËÊ¡¤·¤Þ¤¹¤«¡©";
3505 s = "½ËÊ¡¤Ç¤¤ëÉð´ï¤¬¤¢¤ê¤Þ¤»¤ó¡£";
3507 q = "Bless which weapon? ";
3508 s = "You have weapon to bless.";
3511 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR)))
3514 /* Get the item (in the pack) */
3517 o_ptr = &inventory[item];
3520 /* Get the item (on the floor) */
3523 o_ptr = &o_list[0 - item];
3528 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
3530 /* Extract the flags */
3531 object_flags(o_ptr, flgs);
3533 if (object_is_cursed(o_ptr))
3535 if (((o_ptr->curse_flags & TRC_HEAVY_CURSE) && (randint1(100) < 33)) ||
3536 (o_ptr->curse_flags & TRC_PERMA_CURSE))
3539 msg_format("%s¤òʤ¤¦¹õ¤¤¥ª¡¼¥é¤Ï½ËÊ¡¤òÄ·¤ÍÊÖ¤·¤¿¡ª",
3542 msg_format("The black aura on %s %s disrupts the blessing!",
3543 ((item >= 0) ? "your" : "the"), o_name);
3550 msg_format("%s ¤«¤é¼Ù°¤Ê¥ª¡¼¥é¤¬¾Ã¤¨¤¿¡£",
3553 msg_format("A malignant aura leaves %s %s.",
3554 ((item >= 0) ? "your" : "the"), o_name);
3559 o_ptr->curse_flags = 0L;
3561 /* Hack -- Assume felt */
3562 o_ptr->ident |= (IDENT_SENSE);
3565 o_ptr->feeling = FEEL_NONE;
3567 /* Recalculate the bonuses */
3568 p_ptr->update |= (PU_BONUS);
3571 p_ptr->window |= (PW_EQUIP);
3575 * Next, we try to bless it. Artifacts have a 1/3 chance of
3576 * being blessed, otherwise, the operation simply disenchants
3577 * them, godly power negating the magic. Ok, the explanation
3578 * is silly, but otherwise priests would always bless every
3579 * artifact weapon they find. Ego weapons and normal weapons
3580 * can be blessed automatically.
3582 if (have_flag(flgs, TR_BLESSED))
3585 msg_format("%s ¤Ï´û¤Ë½ËÊ¡¤µ¤ì¤Æ¤¤¤ë¡£",
3588 msg_format("%s %s %s blessed already.",
3589 ((item >= 0) ? "Your" : "The"), o_name,
3590 ((o_ptr->number > 1) ? "were" : "was"));
3596 if (!(object_is_artifact(o_ptr) || object_is_ego(o_ptr)) || one_in_(3))
3600 msg_format("%s¤Ïµ±¤¤¤¿¡ª",
3603 msg_format("%s %s shine%s!",
3604 ((item >= 0) ? "Your" : "The"), o_name,
3605 ((o_ptr->number > 1) ? "" : "s"));
3608 add_flag(o_ptr->art_flags, TR_BLESSED);
3609 o_ptr->discount = 99;
3613 bool dis_happened = FALSE;
3616 msg_print("¤½¤ÎÉð´ï¤Ï½ËÊ¡¤ò·ù¤Ã¤Æ¤¤¤ë¡ª");
3618 msg_print("The weapon resists your blessing!");
3622 /* Disenchant tohit */
3623 if (o_ptr->to_h > 0)
3626 dis_happened = TRUE;
3629 if ((o_ptr->to_h > 5) && (randint0(100) < 33)) o_ptr->to_h--;
3631 /* Disenchant todam */
3632 if (o_ptr->to_d > 0)
3635 dis_happened = TRUE;
3638 if ((o_ptr->to_d > 5) && (randint0(100) < 33)) o_ptr->to_d--;
3640 /* Disenchant toac */
3641 if (o_ptr->to_a > 0)
3644 dis_happened = TRUE;
3647 if ((o_ptr->to_a > 5) && (randint0(100) < 33)) o_ptr->to_a--;
3652 msg_print("¼þ°Ï¤¬ËÞÍǤÊÊ·°Ïµ¤¤ÇËþ¤Á¤¿...");
3654 msg_print("There is a static feeling in the air...");
3658 msg_format("%s ¤ÏÎô²½¤·¤¿¡ª",
3661 msg_format("%s %s %s disenchanted!",
3662 ((item >= 0) ? "Your" : "The"), o_name,
3663 ((o_ptr->number > 1) ? "were" : "was"));
3669 /* Recalculate bonuses */
3670 p_ptr->update |= (PU_BONUS);
3673 p_ptr->window |= (PW_EQUIP | PW_PLAYER);
3684 bool pulish_shield(void)
3688 u32b flgs[TR_FLAG_SIZE];
3689 char o_name[MAX_NLEN];
3692 item_tester_no_ryoute = TRUE;
3693 /* Assume enchant weapon */
3694 item_tester_tval = TV_SHIELD;
3698 q = "¤É¤Î½â¤òËᤤޤ¹¤«¡©";
3699 s = "Ë᤯½â¤¬¤¢¤ê¤Þ¤»¤ó¡£";
3701 q = "Pulish which weapon? ";
3702 s = "You have weapon to pulish.";
3705 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR)))
3708 /* Get the item (in the pack) */
3711 o_ptr = &inventory[item];
3714 /* Get the item (on the floor) */
3717 o_ptr = &o_list[0 - item];
3722 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
3724 /* Extract the flags */
3725 object_flags(o_ptr, flgs);
3727 if (o_ptr->k_idx && !object_is_artifact(o_ptr) && !object_is_ego(o_ptr) &&
3728 !object_is_cursed(o_ptr) && (o_ptr->sval != SV_MIRROR_SHIELD))
3731 msg_format("%s¤Ïµ±¤¤¤¿¡ª", o_name);
3733 msg_format("%s %s shine%s!",
3734 ((item >= 0) ? "Your" : "The"), o_name,
3735 ((o_ptr->number > 1) ? "" : "s"));
3737 o_ptr->name2 = EGO_REFLECTION;
3738 enchant(o_ptr, randint0(3) + 4, ENCH_TOAC);
3740 o_ptr->discount = 99;
3741 chg_virtue(V_ENCHANT, 2);
3747 if (flush_failure) flush();
3750 msg_print("¼ºÇÔ¤·¤¿¡£");
3752 msg_print("Failed.");
3755 chg_virtue(V_ENCHANT, -2);
3764 * Potions "smash open" and cause an area effect when
3765 * (1) they are shattered while in the player's inventory,
3766 * due to cold (etc) attacks;
3767 * (2) they are thrown at a monster, or obstacle;
3768 * (3) they are shattered by a "cold ball" or other such spell
3769 * while lying on the floor.
3772 * who --- who caused the potion to shatter (0=player)
3773 * potions that smash on the floor are assumed to
3774 * be caused by no-one (who = 1), as are those that
3775 * shatter inside the player inventory.
3776 * (Not anymore -- I changed this; TY)
3777 * y, x --- coordinates of the potion (or player if
3778 * the potion was in her inventory);
3779 * o_ptr --- pointer to the potion object.
3781 bool potion_smash_effect(int who, int y, int x, int k_idx)
3788 object_kind *k_ptr = &k_info[k_idx];
3790 switch (k_ptr->sval)
3792 case SV_POTION_SALT_WATER:
3793 case SV_POTION_SLIME_MOLD:
3794 case SV_POTION_LOSE_MEMORIES:
3795 case SV_POTION_DEC_STR:
3796 case SV_POTION_DEC_INT:
3797 case SV_POTION_DEC_WIS:
3798 case SV_POTION_DEC_DEX:
3799 case SV_POTION_DEC_CON:
3800 case SV_POTION_DEC_CHR:
3801 case SV_POTION_WATER: /* perhaps a 'water' attack? */
3802 case SV_POTION_APPLE_JUICE:
3805 case SV_POTION_INFRAVISION:
3806 case SV_POTION_DETECT_INVIS:
3807 case SV_POTION_SLOW_POISON:
3808 case SV_POTION_CURE_POISON:
3809 case SV_POTION_BOLDNESS:
3810 case SV_POTION_RESIST_HEAT:
3811 case SV_POTION_RESIST_COLD:
3812 case SV_POTION_HEROISM:
3813 case SV_POTION_BESERK_STRENGTH:
3814 case SV_POTION_RES_STR:
3815 case SV_POTION_RES_INT:
3816 case SV_POTION_RES_WIS:
3817 case SV_POTION_RES_DEX:
3818 case SV_POTION_RES_CON:
3819 case SV_POTION_RES_CHR:
3820 case SV_POTION_INC_STR:
3821 case SV_POTION_INC_INT:
3822 case SV_POTION_INC_WIS:
3823 case SV_POTION_INC_DEX:
3824 case SV_POTION_INC_CON:
3825 case SV_POTION_INC_CHR:
3826 case SV_POTION_AUGMENTATION:
3827 case SV_POTION_ENLIGHTENMENT:
3828 case SV_POTION_STAR_ENLIGHTENMENT:
3829 case SV_POTION_SELF_KNOWLEDGE:
3830 case SV_POTION_EXPERIENCE:
3831 case SV_POTION_RESISTANCE:
3832 case SV_POTION_INVULNERABILITY:
3833 case SV_POTION_NEW_LIFE:
3834 /* All of the above potions have no effect when shattered */
3836 case SV_POTION_SLOWNESS:
3841 case SV_POTION_POISON:
3846 case SV_POTION_BLINDNESS:
3850 case SV_POTION_CONFUSION: /* Booze */
3854 case SV_POTION_SLEEP:
3858 case SV_POTION_RUINATION:
3859 case SV_POTION_DETONATIONS:
3861 dam = damroll(25, 25);
3864 case SV_POTION_DEATH:
3865 dt = GF_DEATH_RAY; /* !! */
3866 dam = k_ptr->level * 10;
3870 case SV_POTION_SPEED:
3873 case SV_POTION_CURE_LIGHT:
3875 dam = damroll(2, 3);
3877 case SV_POTION_CURE_SERIOUS:
3879 dam = damroll(4, 3);
3881 case SV_POTION_CURE_CRITICAL:
3882 case SV_POTION_CURING:
3884 dam = damroll(6, 3);
3886 case SV_POTION_HEALING:
3888 dam = damroll(10, 10);
3890 case SV_POTION_RESTORE_EXP:
3895 case SV_POTION_LIFE:
3897 dam = damroll(50, 50);
3900 case SV_POTION_STAR_HEALING:
3902 dam = damroll(50, 50);
3905 case SV_POTION_RESTORE_MANA: /* MANA */
3907 dam = damroll(10, 10);
3914 (void)project(who, radius, y, x, dam, dt,
3915 (PROJECT_JUMP | PROJECT_ITEM | PROJECT_KILL), -1);
3917 /* XXX those potions that explode need to become "known" */
3923 * Hack -- Display all known spells in a window
3925 * XXX XXX XXX Need to analyze size of the window.
3927 * XXX XXX XXX Need more color coding.
3929 void display_spell_list(void)
3942 /* They have too many spells to list */
3943 if (p_ptr->pclass == CLASS_SORCERER) return;
3944 if (p_ptr->pclass == CLASS_RED_MAGE) return;
3946 /* mind.c type classes */
3947 if ((p_ptr->pclass == CLASS_MINDCRAFTER) ||
3948 (p_ptr->pclass == CLASS_BERSERKER) ||
3949 (p_ptr->pclass == CLASS_NINJA) ||
3950 (p_ptr->pclass == CLASS_MIRROR_MASTER) ||
3951 (p_ptr->pclass == CLASS_FORCETRAINER))
3957 int plev = p_ptr->lev;
3963 bool use_hp = FALSE;
3965 /* Display a list of spells */
3968 put_str("̾Á°", y, x + 5);
3969 put_str("Lv MP ¼ºÎ¨ ¸ú²Ì", y, x + 35);
3971 put_str("Name", y, x + 5);
3972 put_str("Lv Mana Fail Info", y, x + 35);
3975 switch(p_ptr->pclass)
3977 case CLASS_MINDCRAFTER: use_mind = MIND_MINDCRAFTER;break;
3978 case CLASS_FORCETRAINER: use_mind = MIND_KI;break;
3979 case CLASS_BERSERKER: use_mind = MIND_BERSERKER; use_hp = TRUE; break;
3980 case CLASS_MIRROR_MASTER: use_mind = MIND_MIRROR_MASTER; break;
3981 case CLASS_NINJA: use_mind = MIND_NINJUTSU; use_hp = TRUE; break;
3982 default: use_mind = 0;break;
3985 /* Dump the spells */
3986 for (i = 0; i < MAX_MIND_POWERS; i++)
3988 byte a = TERM_WHITE;
3990 /* Access the available spell */
3991 spell = mind_powers[use_mind].info[i];
3992 if (spell.min_lev > plev) break;
3994 /* Get the failure rate */
3995 chance = spell.fail;
3997 /* Reduce failure rate by "effective" level adjustment */
3998 chance -= 3 * (p_ptr->lev - spell.min_lev);
4000 /* Reduce failure rate by INT/WIS adjustment */
4001 chance -= 3 * (adj_mag_stat[p_ptr->stat_ind[mp_ptr->spell_stat]] - 1);
4005 /* Not enough mana to cast */
4006 if (spell.mana_cost > p_ptr->csp)
4008 chance += 5 * (spell.mana_cost - p_ptr->csp);
4014 /* Not enough hp to cast */
4015 if (spell.mana_cost > p_ptr->chp)
4022 /* Extract the minimum failure rate */
4023 minfail = adj_mag_fail[p_ptr->stat_ind[mp_ptr->spell_stat]];
4025 /* Minimum failure rate */
4026 if (chance < minfail) chance = minfail;
4028 /* Stunning makes spells harder */
4029 if (p_ptr->stun > 50) chance += 25;
4030 else if (p_ptr->stun) chance += 15;
4032 /* Always a 5 percent chance of working */
4033 if (chance > 95) chance = 95;
4036 mindcraft_info(comment, use_mind, i);
4038 /* Dump the spell */
4039 sprintf(psi_desc, " %c) %-30s%2d %4d %3d%%%s",
4041 spell.min_lev, spell.mana_cost, chance, comment);
4043 Term_putstr(x, y + i + 1, -1, a, psi_desc);
4048 /* Cannot read spellbooks */
4049 if (REALM_NONE == p_ptr->realm1) return;
4051 /* Normal spellcaster with books */
4054 for (j = 0; j < ((p_ptr->realm2 > REALM_NONE) ? 2 : 1); j++)
4058 /* Reset vertical */
4061 /* Vertical location */
4062 y = (j < 3) ? 0 : (m[j - 3] + 2);
4064 /* Horizontal location */
4068 for (i = 0; i < 32; i++)
4070 byte a = TERM_WHITE;
4072 /* Access the spell */
4073 if (!is_magic((j < 1) ? p_ptr->realm1 : p_ptr->realm2))
4075 s_ptr = &technic_info[((j < 1) ? p_ptr->realm1 : p_ptr->realm2) - MIN_TECHNIC][i % 32];
4079 s_ptr = &mp_ptr->info[((j < 1) ? p_ptr->realm1 : p_ptr->realm2) - 1][i % 32];
4082 strcpy(name, do_spell((j < 1) ? p_ptr->realm1 : p_ptr->realm2, i % 32, SPELL_NAME));
4085 if (s_ptr->slevel >= 99)
4089 strcpy(name, "(ȽÆÉÉÔǽ)");
4091 strcpy(name, "(illegible)");
4101 ((p_ptr->spell_forgotten1 & (1L << i))) :
4102 ((p_ptr->spell_forgotten2 & (1L << (i % 32)))))
4109 else if (!((j < 1) ?
4110 (p_ptr->spell_learned1 & (1L << i)) :
4111 (p_ptr->spell_learned2 & (1L << (i % 32)))))
4118 else if (!((j < 1) ?
4119 (p_ptr->spell_worked1 & (1L << i)) :
4120 (p_ptr->spell_worked2 & (1L << (i % 32)))))
4126 /* Dump the spell --(-- */
4127 sprintf(out_val, "%c/%c) %-20.20s",
4128 I2A(n / 8), I2A(n % 8), name);
4133 /* Dump onto the window */
4134 Term_putstr(x, m[j], -1, a, out_val);
4144 * Returns experience of a spell
4146 s16b experience_of_spell(int spell, int use_realm)
4148 if (p_ptr->pclass == CLASS_SORCERER) return SPELL_EXP_MASTER;
4149 else if (p_ptr->pclass == CLASS_RED_MAGE) return SPELL_EXP_SKILLED;
4150 else if (use_realm == p_ptr->realm1) return p_ptr->spell_exp[spell];
4151 else if (use_realm == p_ptr->realm2) return p_ptr->spell_exp[spell + 32];
4157 * Modify mana consumption rate using spell exp and p_ptr->dec_mana
4159 int mod_need_mana(int need_mana, int spell, int realm)
4161 #define MANA_CONST 2400
4163 #define DEC_MANA_DIV 3
4166 if ((realm > REALM_NONE) && (realm <= MAX_REALM))
4169 * need_mana defaults if spell exp equals SPELL_EXP_EXPERT and !p_ptr->dec_mana.
4170 * MANA_CONST is used to calculate need_mana effected from spell proficiency.
4172 need_mana = need_mana * (MANA_CONST + SPELL_EXP_EXPERT - experience_of_spell(spell, realm)) + (MANA_CONST - 1);
4173 need_mana *= p_ptr->dec_mana ? DEC_MANA_DIV : MANA_DIV;
4174 need_mana /= MANA_CONST * MANA_DIV;
4175 if (need_mana < 1) need_mana = 1;
4178 /* Non-realm magic */
4181 if (p_ptr->dec_mana) need_mana = (need_mana + 1) * DEC_MANA_DIV / MANA_DIV;
4193 * Modify spell fail rate
4194 * Using p_ptr->to_m_chance, p_ptr->dec_mana, p_ptr->easy_spell and p_ptr->heavy_spell
4196 int mod_spell_chance_1(int chance)
4198 chance += p_ptr->to_m_chance;
4200 if (p_ptr->heavy_spell) chance += 20;
4202 if (p_ptr->dec_mana && p_ptr->easy_spell) chance -= 4;
4203 else if (p_ptr->easy_spell) chance -= 3;
4204 else if (p_ptr->dec_mana) chance -= 2;
4211 * Modify spell fail rate (as "suffix" process)
4212 * Using p_ptr->dec_mana, p_ptr->easy_spell and p_ptr->heavy_spell
4213 * Note: variable "chance" cannot be negative.
4215 int mod_spell_chance_2(int chance)
4217 if (p_ptr->dec_mana) chance--;
4219 if (p_ptr->heavy_spell) chance += 5;
4221 return MAX(chance, 0);
4226 * Returns spell chance of failure for spell -RAK-
4228 s16b spell_chance(int spell, int use_realm)
4230 int chance, minfail;
4233 int penalty = (mp_ptr->spell_stat == A_WIS) ? 10 : 4;
4236 /* Paranoia -- must be literate */
4237 if (!mp_ptr->spell_book) return (100);
4239 if (use_realm == REALM_HISSATSU) return 0;
4241 /* Access the spell */
4242 if (!is_magic(use_realm))
4244 s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
4248 s_ptr = &mp_ptr->info[use_realm - 1][spell];
4251 /* Extract the base spell failure rate */
4252 chance = s_ptr->sfail;
4254 /* Reduce failure rate by "effective" level adjustment */
4255 chance -= 3 * (p_ptr->lev - s_ptr->slevel);
4257 /* Reduce failure rate by INT/WIS adjustment */
4258 chance -= 3 * (adj_mag_stat[p_ptr->stat_ind[mp_ptr->spell_stat]] - 1);
4261 chance += (MAX(r_info[m_list[p_ptr->riding].r_idx].level - p_ptr->skill_exp[GINOU_RIDING] / 100 - 10, 0));
4263 /* Extract mana consumption rate */
4264 need_mana = mod_need_mana(s_ptr->smana, spell, use_realm);
4266 /* Not enough mana to cast */
4267 if (need_mana > p_ptr->csp)
4269 chance += 5 * (need_mana - p_ptr->csp);
4272 if ((use_realm != p_ptr->realm1) && ((p_ptr->pclass == CLASS_MAGE) || (p_ptr->pclass == CLASS_PRIEST))) chance += 5;
4274 /* Extract the minimum failure rate */
4275 minfail = adj_mag_fail[p_ptr->stat_ind[mp_ptr->spell_stat]];
4278 * Non mage/priest characters never get too good
4279 * (added high mage, mindcrafter)
4281 if (mp_ptr->spell_xtra & MAGIC_FAIL_5PERCENT)
4283 if (minfail < 5) minfail = 5;
4286 /* Hack -- Priest prayer penalty for "edged" weapons -DGK */
4287 if (((p_ptr->pclass == CLASS_PRIEST) || (p_ptr->pclass == CLASS_SORCERER)) && p_ptr->icky_wield[0]) chance += 25;
4288 if (((p_ptr->pclass == CLASS_PRIEST) || (p_ptr->pclass == CLASS_SORCERER)) && p_ptr->icky_wield[1]) chance += 25;
4290 chance = mod_spell_chance_1(chance);
4292 if ((use_realm == REALM_NATURE) && ((p_ptr->align > 50) || (p_ptr->align < -50))) chance += penalty;
4293 if (((use_realm == REALM_LIFE) || (use_realm == REALM_CRUSADE)) && (p_ptr->align < -20)) chance += penalty;
4294 if (((use_realm == REALM_DEATH) || (use_realm == REALM_DAEMON)) && (p_ptr->align > 20)) chance += penalty;
4296 /* Minimum failure rate */
4297 if (chance < minfail) chance = minfail;
4299 /* Stunning makes spells harder */
4300 if (p_ptr->stun > 50) chance += 25;
4301 else if (p_ptr->stun) chance += 15;
4303 /* Always a 5 percent chance of working */
4304 if (chance > 95) chance = 95;
4306 if ((use_realm == p_ptr->realm1) || (use_realm == p_ptr->realm2)
4307 || (p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE))
4309 s16b exp = experience_of_spell(spell, use_realm);
4310 if (exp >= SPELL_EXP_EXPERT) chance--;
4311 if (exp >= SPELL_EXP_MASTER) chance--;
4314 /* Return the chance */
4315 return mod_spell_chance_2(chance);
4321 * Determine if a spell is "okay" for the player to cast or study
4322 * The spell must be legible, not forgotten, and also, to cast,
4323 * it must be known, and to study, it must not be known.
4325 bool spell_okay(int spell, bool learned, bool study_pray, int use_realm)
4329 /* Access the spell */
4330 if (!is_magic(use_realm))
4332 s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
4336 s_ptr = &mp_ptr->info[use_realm - 1][spell];
4339 /* Spell is illegal */
4340 if (s_ptr->slevel > p_ptr->lev) return (FALSE);
4342 /* Spell is forgotten */
4343 if ((use_realm == p_ptr->realm2) ?
4344 (p_ptr->spell_forgotten2 & (1L << spell)) :
4345 (p_ptr->spell_forgotten1 & (1L << spell)))
4351 if (p_ptr->pclass == CLASS_SORCERER) return (TRUE);
4352 if (p_ptr->pclass == CLASS_RED_MAGE) return (TRUE);
4354 /* Spell is learned */
4355 if ((use_realm == p_ptr->realm2) ?
4356 (p_ptr->spell_learned2 & (1L << spell)) :
4357 (p_ptr->spell_learned1 & (1L << spell)))
4360 return (!study_pray);
4363 /* Okay to study, not to cast */
4369 * Print a list of spells (for browsing or casting or viewing)
4371 void print_spells(int target_spell, byte *spells, int num, int y, int x, int use_realm)
4373 int i, spell, exp_level, increment = 64;
4385 if (((use_realm <= REALM_NONE) || (use_realm > MAX_REALM)) && p_ptr->wizard)
4387 msg_print("·Ù¹ð¡ª print_spell ¤¬Îΰè¤Ê¤·¤Ë¸Æ¤Ð¤ì¤¿");
4389 msg_print("Warning! print_spells called with null realm");
4393 /* Title the list */
4395 if (use_realm == REALM_HISSATSU)
4397 strcpy(buf," Lv MP");
4399 strcpy(buf," Lv SP");
4403 strcpy(buf,"½ÏÎýÅÙ Lv MP ¼ºÎ¨ ¸ú²Ì");
4405 strcpy(buf,"Profic Lv SP Fail Effect");
4409 put_str("̾Á°", y, x + 5);
4410 put_str(buf, y, x + 29);
4412 put_str("Name", y, x + 5);
4413 put_str(buf, y, x + 29);
4416 if ((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE)) increment = 0;
4417 else if (use_realm == p_ptr->realm1) increment = 0;
4418 else if (use_realm == p_ptr->realm2) increment = 32;
4420 /* Dump the spells */
4421 for (i = 0; i < num; i++)
4423 /* Access the spell */
4426 /* Access the spell */
4427 if (!is_magic(use_realm))
4429 s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
4433 s_ptr = &mp_ptr->info[use_realm - 1][spell];
4436 if (use_realm == REALM_HISSATSU)
4437 need_mana = s_ptr->smana;
4440 s16b exp = experience_of_spell(spell, use_realm);
4442 /* Extract mana consumption rate */
4443 need_mana = mod_need_mana(s_ptr->smana, spell, use_realm);
4445 if ((increment == 64) || (s_ptr->slevel >= 99)) exp_level = EXP_LEVEL_UNSKILLED;
4446 else exp_level = spell_exp_level(exp);
4449 if (!increment && (exp_level == EXP_LEVEL_MASTER)) max = TRUE;
4450 else if ((increment == 32) && (exp_level >= EXP_LEVEL_EXPERT)) max = TRUE;
4451 else if (s_ptr->slevel >= 99) max = TRUE;
4452 else if ((p_ptr->pclass == CLASS_RED_MAGE) && (exp_level >= EXP_LEVEL_SKILLED)) max = TRUE;
4454 strncpy(ryakuji, exp_level_str[exp_level], 4);
4459 if (use_menu && target_spell)
4461 if (i == (target_spell-1))
4463 strcpy(out_val, " ¡Õ ");
4465 strcpy(out_val, " > ");
4468 strcpy(out_val, " ");
4470 else sprintf(out_val, " %c) ", I2A(i));
4471 /* Skip illegible spells */
4472 if (s_ptr->slevel >= 99)
4475 strcat(out_val, format("%-30s", "(ȽÆÉÉÔǽ)"));
4477 strcat(out_val, format("%-30s", "(illegible)"));
4480 c_prt(TERM_L_DARK, out_val, y + i + 1, x);
4484 /* XXX XXX Could label spells above the players level */
4486 /* Get extra info */
4487 strcpy(info, do_spell(use_realm, spell, SPELL_INFO));
4492 /* Assume spell is known and tried */
4493 line_attr = TERM_WHITE;
4495 /* Analyze the spell */
4496 if ((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE))
4498 if (s_ptr->slevel > p_ptr->max_plv)
4503 comment = "unknown";
4506 line_attr = TERM_L_BLUE;
4508 else if (s_ptr->slevel > p_ptr->lev)
4513 comment = "forgotten";
4516 line_attr = TERM_YELLOW;
4519 else if ((use_realm != p_ptr->realm1) && (use_realm != p_ptr->realm2))
4524 comment = "unknown";
4527 line_attr = TERM_L_BLUE;
4529 else if ((use_realm == p_ptr->realm1) ?
4530 ((p_ptr->spell_forgotten1 & (1L << spell))) :
4531 ((p_ptr->spell_forgotten2 & (1L << spell))))
4536 comment = "forgotten";
4539 line_attr = TERM_YELLOW;
4541 else if (!((use_realm == p_ptr->realm1) ?
4542 (p_ptr->spell_learned1 & (1L << spell)) :
4543 (p_ptr->spell_learned2 & (1L << spell))))
4548 comment = "unknown";
4551 line_attr = TERM_L_BLUE;
4553 else if (!((use_realm == p_ptr->realm1) ?
4554 (p_ptr->spell_worked1 & (1L << spell)) :
4555 (p_ptr->spell_worked2 & (1L << spell))))
4560 comment = "untried";
4563 line_attr = TERM_L_GREEN;
4566 /* Dump the spell --(-- */
4567 if (use_realm == REALM_HISSATSU)
4569 strcat(out_val, format("%-25s %2d %4d",
4570 do_spell(use_realm, spell, SPELL_NAME), /* realm, spell */
4571 s_ptr->slevel, need_mana));
4575 strcat(out_val, format("%-25s%c%-4s %2d %4d %3d%% %s",
4576 do_spell(use_realm, spell, SPELL_NAME), /* realm, spell */
4577 (max ? '!' : ' '), ryakuji,
4578 s_ptr->slevel, need_mana, spell_chance(spell, use_realm), comment));
4580 c_prt(line_attr, out_val, y + i + 1, x);
4583 /* Clear the bottom line */
4584 prt("", y + i + 1, x);
4589 * Note that amulets, rods, and high-level spell books are immune
4590 * to "inventory damage" of any kind. Also sling ammo and shovels.
4595 * Does a given class of objects (usually) hate acid?
4596 * Note that acid can either melt or corrode something.
4598 bool hates_acid(object_type *o_ptr)
4600 /* Analyze the type */
4601 switch (o_ptr->tval)
4603 /* Wearable items */
4623 /* Staffs/Scrolls are wood/paper */
4636 /* Junk is useless */
4650 * Does a given object (usually) hate electricity?
4652 bool hates_elec(object_type *o_ptr)
4654 switch (o_ptr->tval)
4668 * Does a given object (usually) hate fire?
4669 * Hafted/Polearm weapons have wooden shafts.
4670 * Arrows/Bows are mostly wooden.
4672 bool hates_fire(object_type *o_ptr)
4674 /* Analyze the type */
4675 switch (o_ptr->tval)
4693 case TV_SORCERY_BOOK:
4694 case TV_NATURE_BOOK:
4698 case TV_ARCANE_BOOK:
4700 case TV_DAEMON_BOOK:
4701 case TV_CRUSADE_BOOK:
4703 case TV_HISSATSU_BOOK:
4714 /* Staffs/Scrolls burn */
4727 * Does a given object (usually) hate cold?
4729 bool hates_cold(object_type *o_ptr)
4731 switch (o_ptr->tval)
4748 int set_acid_destroy(object_type *o_ptr)
4750 u32b flgs[TR_FLAG_SIZE];
4751 if (!hates_acid(o_ptr)) return (FALSE);
4752 object_flags(o_ptr, flgs);
4753 if (have_flag(flgs, TR_IGNORE_ACID)) return (FALSE);
4761 int set_elec_destroy(object_type *o_ptr)
4763 u32b flgs[TR_FLAG_SIZE];
4764 if (!hates_elec(o_ptr)) return (FALSE);
4765 object_flags(o_ptr, flgs);
4766 if (have_flag(flgs, TR_IGNORE_ELEC)) return (FALSE);
4774 int set_fire_destroy(object_type *o_ptr)
4776 u32b flgs[TR_FLAG_SIZE];
4777 if (!hates_fire(o_ptr)) return (FALSE);
4778 object_flags(o_ptr, flgs);
4779 if (have_flag(flgs, TR_IGNORE_FIRE)) return (FALSE);
4787 int set_cold_destroy(object_type *o_ptr)
4789 u32b flgs[TR_FLAG_SIZE];
4790 if (!hates_cold(o_ptr)) return (FALSE);
4791 object_flags(o_ptr, flgs);
4792 if (have_flag(flgs, TR_IGNORE_COLD)) return (FALSE);
4798 * Destroys a type of item on a given percent chance
4799 * Note that missiles are no longer necessarily all destroyed
4800 * Destruction taken from "melee.c" code for "stealing".
4801 * New-style wands and rods handled correctly. -LM-
4802 * Returns number of items destroyed.
4804 int inven_damage(inven_func typ, int perc)
4808 char o_name[MAX_NLEN];
4810 if (CHECK_MULTISHADOW()) return 0;
4812 if (p_ptr->inside_arena) return 0;
4814 /* Count the casualties */
4817 /* Scan through the slots backwards */
4818 for (i = 0; i < INVEN_PACK; i++)
4820 o_ptr = &inventory[i];
4822 /* Skip non-objects */
4823 if (!o_ptr->k_idx) continue;
4825 /* Hack -- for now, skip artifacts */
4826 if (object_is_artifact(o_ptr)) continue;
4828 /* Give this item slot a shot at death */
4831 /* Count the casualties */
4832 for (amt = j = 0; j < o_ptr->number; ++j)
4834 if (randint0(100) < perc) amt++;
4837 /* Some casualities */
4840 /* Get a description */
4841 object_desc(o_name, o_ptr, OD_OMIT_PREFIX);
4845 msg_format("%s(%c)¤¬%s²õ¤ì¤Æ¤·¤Þ¤Ã¤¿¡ª",
4847 msg_format("%sour %s (%c) %s destroyed!",
4851 o_name, index_to_label(i),
4852 ((o_ptr->number > 1) ?
4853 ((amt == o_ptr->number) ? "Á´Éô" :
4854 (amt > 1 ? "²¿¸Ä¤«" : "°ì¸Ä")) : "") );
4856 ((o_ptr->number > 1) ?
4857 ((amt == o_ptr->number) ? "All of y" :
4858 (amt > 1 ? "Some of y" : "One of y")) : "Y"),
4859 o_name, index_to_label(i),
4860 ((amt > 1) ? "were" : "was"));
4864 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
4865 msg_print("¤ä¤ê¤ä¤¬¤Ã¤¿¤Ê¡ª");
4868 /* Potions smash open */
4869 if (object_is_potion(o_ptr))
4871 (void)potion_smash_effect(0, py, px, o_ptr->k_idx);
4874 /* Reduce the charges of rods/wands */
4875 reduce_charges(o_ptr, amt);
4877 /* Destroy "amt" items */
4878 inven_item_increase(i, -amt);
4879 inven_item_optimize(i);
4881 /* Count the casualties */
4887 /* Return the casualty count */
4893 * Acid has hit the player, attempt to affect some armor.
4895 * Note that the "base armor" of an object never changes.
4897 * If any armor is damaged (or resists), the player takes less damage.
4899 static int minus_ac(void)
4901 object_type *o_ptr = NULL;
4902 u32b flgs[TR_FLAG_SIZE];
4903 char o_name[MAX_NLEN];
4906 /* Pick a (possibly empty) inventory slot */
4907 switch (randint1(7))
4909 case 1: o_ptr = &inventory[INVEN_RARM]; break;
4910 case 2: o_ptr = &inventory[INVEN_LARM]; break;
4911 case 3: o_ptr = &inventory[INVEN_BODY]; break;
4912 case 4: o_ptr = &inventory[INVEN_OUTER]; break;
4913 case 5: o_ptr = &inventory[INVEN_HANDS]; break;
4914 case 6: o_ptr = &inventory[INVEN_HEAD]; break;
4915 case 7: o_ptr = &inventory[INVEN_FEET]; break;
4918 /* Nothing to damage */
4919 if (!o_ptr->k_idx) return (FALSE);
4921 if (!object_is_armour(o_ptr)) return (FALSE);
4923 /* No damage left to be done */
4924 if (o_ptr->ac + o_ptr->to_a <= 0) return (FALSE);
4928 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
4930 /* Extract the flags */
4931 object_flags(o_ptr, flgs);
4933 /* Object resists */
4934 if (have_flag(flgs, TR_IGNORE_ACID))
4937 msg_format("¤·¤«¤·%s¤Ë¤Ï¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡ª", o_name);
4939 msg_format("Your %s is unaffected!", o_name);
4948 msg_format("%s¤¬¥À¥á¡¼¥¸¤ò¼õ¤±¤¿¡ª", o_name);
4950 msg_format("Your %s is damaged!", o_name);
4954 /* Damage the item */
4957 /* Calculate bonuses */
4958 p_ptr->update |= (PU_BONUS);
4961 p_ptr->window |= (PW_EQUIP | PW_PLAYER);
4965 /* Item was damaged */
4971 * Hurt the player with Acid
4973 int acid_dam(int dam, cptr kb_str, int monspell)
4976 int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
4977 bool double_resist = IS_OPPOSE_ACID();
4979 /* Total Immunity */
4980 if (p_ptr->immune_acid || (dam <= 0))
4982 learn_spell(monspell);
4986 /* Vulnerability (Ouch!) */
4987 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
4988 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
4990 /* Resist the damage */
4991 if (p_ptr->resist_acid) dam = (dam + 2) / 3;
4992 if (double_resist) dam = (dam + 2) / 3;
4994 if (!CHECK_MULTISHADOW())
4996 if ((!(double_resist || p_ptr->resist_acid)) &&
4997 one_in_(HURT_CHANCE))
4998 (void)do_dec_stat(A_CHR);
5000 /* If any armor gets hit, defend the player */
5001 if (minus_ac()) dam = (dam + 1) / 2;
5005 get_damage = take_hit(DAMAGE_ATTACK, dam, kb_str, monspell);
5007 /* Inventory damage */
5008 if (!(double_resist && p_ptr->resist_acid))
5009 inven_damage(set_acid_destroy, inv);
5015 * Hurt the player with electricity
5017 int elec_dam(int dam, cptr kb_str, int monspell)
5020 int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
5021 bool double_resist = IS_OPPOSE_ELEC();
5023 /* Total immunity */
5024 if (p_ptr->immune_elec || (dam <= 0))
5026 learn_spell(monspell);
5030 /* Vulnerability (Ouch!) */
5031 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
5032 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
5033 if (prace_is_(RACE_ANDROID)) dam += dam / 3;
5035 /* Resist the damage */
5036 if (p_ptr->resist_elec) dam = (dam + 2) / 3;
5037 if (double_resist) dam = (dam + 2) / 3;
5039 if ((!(double_resist || p_ptr->resist_elec)) &&
5040 one_in_(HURT_CHANCE) && !CHECK_MULTISHADOW())
5041 (void)do_dec_stat(A_DEX);
5044 get_damage = take_hit(DAMAGE_ATTACK, dam, kb_str, monspell);
5046 /* Inventory damage */
5047 if (!(double_resist && p_ptr->resist_elec))
5048 inven_damage(set_elec_destroy, inv);
5055 * Hurt the player with Fire
5057 int fire_dam(int dam, cptr kb_str, int monspell)
5060 int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
5061 bool double_resist = IS_OPPOSE_FIRE();
5063 /* Totally immune */
5064 if (p_ptr->immune_fire || (dam <= 0))
5066 learn_spell(monspell);
5070 /* Vulnerability (Ouch!) */
5071 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
5072 if (prace_is_(RACE_ENT)) dam += dam / 3;
5073 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
5075 /* Resist the damage */
5076 if (p_ptr->resist_fire) dam = (dam + 2) / 3;
5077 if (double_resist) dam = (dam + 2) / 3;
5079 if ((!(double_resist || p_ptr->resist_fire)) &&
5080 one_in_(HURT_CHANCE) && !CHECK_MULTISHADOW())
5081 (void)do_dec_stat(A_STR);
5084 get_damage = take_hit(DAMAGE_ATTACK, dam, kb_str, monspell);
5086 /* Inventory damage */
5087 if (!(double_resist && p_ptr->resist_fire))
5088 inven_damage(set_fire_destroy, inv);
5095 * Hurt the player with Cold
5097 int cold_dam(int dam, cptr kb_str, int monspell)
5100 int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
5101 bool double_resist = IS_OPPOSE_COLD();
5103 /* Total immunity */
5104 if (p_ptr->immune_cold || (dam <= 0))
5106 learn_spell(monspell);
5110 /* Vulnerability (Ouch!) */
5111 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
5112 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
5114 /* Resist the damage */
5115 if (p_ptr->resist_cold) dam = (dam + 2) / 3;
5116 if (double_resist) dam = (dam + 2) / 3;
5118 if ((!(double_resist || p_ptr->resist_cold)) &&
5119 one_in_(HURT_CHANCE) && !CHECK_MULTISHADOW())
5120 (void)do_dec_stat(A_STR);
5123 get_damage = take_hit(DAMAGE_ATTACK, dam, kb_str, monspell);
5125 /* Inventory damage */
5126 if (!(double_resist && p_ptr->resist_cold))
5127 inven_damage(set_cold_destroy, inv);
5133 bool rustproof(void)
5137 char o_name[MAX_NLEN];
5140 item_tester_no_ryoute = TRUE;
5141 /* Select a piece of armour */
5142 item_tester_hook = object_is_armour;
5146 q = "¤É¤ÎËɶñ¤Ë»¬»ß¤á¤ò¤·¤Þ¤¹¤«¡©";
5147 s = "»¬»ß¤á¤Ç¤¤ë¤â¤Î¤¬¤¢¤ê¤Þ¤»¤ó¡£";
5149 q = "Rustproof which piece of armour? ";
5150 s = "You have nothing to rustproof.";
5153 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return FALSE;
5155 /* Get the item (in the pack) */
5158 o_ptr = &inventory[item];
5161 /* Get the item (on the floor) */
5164 o_ptr = &o_list[0 - item];
5169 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
5171 add_flag(o_ptr->art_flags, TR_IGNORE_ACID);
5173 if ((o_ptr->to_a < 0) && !object_is_cursed(o_ptr))
5176 msg_format("%s¤Ï¿·ÉÊƱÍͤˤʤä¿¡ª",o_name);
5178 msg_format("%s %s look%s as good as new!",
5179 ((item >= 0) ? "Your" : "The"), o_name,
5180 ((o_ptr->number > 1) ? "" : "s"));
5187 msg_format("%s¤ÏÉå¿©¤·¤Ê¤¯¤Ê¤Ã¤¿¡£", o_name);
5189 msg_format("%s %s %s now protected against corrosion.",
5190 ((item >= 0) ? "Your" : "The"), o_name,
5191 ((o_ptr->number > 1) ? "are" : "is"));
5202 * Curse the players armor
5204 bool curse_armor(void)
5209 char o_name[MAX_NLEN];
5212 /* Curse the body armor */
5213 o_ptr = &inventory[INVEN_BODY];
5215 /* Nothing to curse */
5216 if (!o_ptr->k_idx) return (FALSE);
5220 object_desc(o_name, o_ptr, OD_OMIT_PREFIX);
5222 /* Attempt a saving throw for artifacts */
5223 if (object_is_artifact(o_ptr) && (randint0(100) < 50))
5227 msg_format("%s¤¬%s¤òÊñ¤ß¹þ¤â¤¦¤È¤·¤¿¤¬¡¢%s¤Ï¤½¤ì¤òÄ·¤ÍÊÖ¤·¤¿¡ª",
5228 "¶²ÉݤΰŹõ¥ª¡¼¥é", "Ëɶñ", o_name);
5230 msg_format("A %s tries to %s, but your %s resists the effects!",
5231 "terrible black aura", "surround your armor", o_name);
5236 /* not artifact or failed save... */
5241 msg_format("¶²ÉݤΰŹõ¥ª¡¼¥é¤¬¤¢¤Ê¤¿¤Î%s¤òÊñ¤ß¹þ¤ó¤À¡ª", o_name);
5243 msg_format("A terrible black aura blasts your %s!", o_name);
5246 chg_virtue(V_ENCHANT, -5);
5248 /* Blast the armor */
5250 o_ptr->name2 = EGO_BLASTED;
5251 o_ptr->to_a = 0 - randint1(5) - randint1(5);
5258 for (i = 0; i < TR_FLAG_SIZE; i++)
5259 o_ptr->art_flags[i] = 0;
5262 o_ptr->curse_flags = TRC_CURSED;
5265 o_ptr->ident |= (IDENT_BROKEN);
5267 /* Recalculate bonuses */
5268 p_ptr->update |= (PU_BONUS);
5270 /* Recalculate mana */
5271 p_ptr->update |= (PU_MANA);
5274 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
5282 * Curse the players weapon
5284 bool curse_weapon(bool force, int slot)
5290 char o_name[MAX_NLEN];
5293 /* Curse the weapon */
5294 o_ptr = &inventory[slot];
5296 /* Nothing to curse */
5297 if (!o_ptr->k_idx) return (FALSE);
5301 object_desc(o_name, o_ptr, OD_OMIT_PREFIX);
5303 /* Attempt a saving throw */
5304 if (object_is_artifact(o_ptr) && (randint0(100) < 50) && !force)
5308 msg_format("%s¤¬%s¤òÊñ¤ß¹þ¤â¤¦¤È¤·¤¿¤¬¡¢%s¤Ï¤½¤ì¤òÄ·¤ÍÊÖ¤·¤¿¡ª",
5309 "¶²ÉݤΰŹõ¥ª¡¼¥é", "Éð´ï", o_name);
5311 msg_format("A %s tries to %s, but your %s resists the effects!",
5312 "terrible black aura", "surround your weapon", o_name);
5317 /* not artifact or failed save... */
5322 if (!force) msg_format("¶²ÉݤΰŹõ¥ª¡¼¥é¤¬¤¢¤Ê¤¿¤Î%s¤òÊñ¤ß¹þ¤ó¤À¡ª", o_name);
5324 if (!force) msg_format("A terrible black aura blasts your %s!", o_name);
5327 chg_virtue(V_ENCHANT, -5);
5329 /* Shatter the weapon */
5331 o_ptr->name2 = EGO_SHATTERED;
5332 o_ptr->to_h = 0 - randint1(5) - randint1(5);
5333 o_ptr->to_d = 0 - randint1(5) - randint1(5);
5339 for (i = 0; i < TR_FLAG_SIZE; i++)
5340 o_ptr->art_flags[i] = 0;
5344 o_ptr->curse_flags = TRC_CURSED;
5347 o_ptr->ident |= (IDENT_BROKEN);
5349 /* Recalculate bonuses */
5350 p_ptr->update |= (PU_BONUS);
5352 /* Recalculate mana */
5353 p_ptr->update |= (PU_MANA);
5356 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
5365 * Enchant some bolts
5367 bool brand_bolts(void)
5371 /* Use the first acceptable bolts */
5372 for (i = 0; i < INVEN_PACK; i++)
5374 object_type *o_ptr = &inventory[i];
5376 /* Skip non-bolts */
5377 if (o_ptr->tval != TV_BOLT) continue;
5379 /* Skip artifacts and ego-items */
5380 if (object_is_artifact(o_ptr) || object_is_ego(o_ptr))
5383 /* Skip cursed/broken items */
5384 if (object_is_cursed(o_ptr) || object_is_broken(o_ptr)) continue;
5387 if (randint0(100) < 75) continue;
5391 msg_print("¥¯¥í¥¹¥Ü¥¦¤ÎÌ𤬱ê¤Î¥ª¡¼¥é¤ËÊñ¤Þ¤ì¤¿¡ª");
5393 msg_print("Your bolts are covered in a fiery aura!");
5398 o_ptr->name2 = EGO_FLAME;
5401 enchant(o_ptr, randint0(3) + 4, ENCH_TOHIT | ENCH_TODAM);
5408 if (flush_failure) flush();
5412 msg_print("±ê¤Ç¶¯²½¤¹¤ë¤Î¤Ë¼ºÇÔ¤·¤¿¡£");
5414 msg_print("The fiery enchantment failed.");
5424 * Helper function -- return a "nearby" race for polymorphing
5426 * Note that this function is one of the more "dangerous" ones...
5428 static s16b poly_r_idx(int r_idx)
5430 monster_race *r_ptr = &r_info[r_idx];
5432 int i, r, lev1, lev2;
5434 /* Hack -- Uniques/Questors never polymorph */
5435 if ((r_ptr->flags1 & RF1_UNIQUE) ||
5436 (r_ptr->flags1 & RF1_QUESTOR))
5439 /* Allowable range of "levels" for resulting monster */
5440 lev1 = r_ptr->level - ((randint1(20) / randint1(9)) + 1);
5441 lev2 = r_ptr->level + ((randint1(20) / randint1(9)) + 1);
5443 /* Pick a (possibly new) non-unique race */
5444 for (i = 0; i < 1000; i++)
5446 /* Pick a new race, using a level calculation */
5447 r = get_mon_num((dun_level + r_ptr->level) / 2 + 5);
5449 /* Handle failure */
5455 /* Ignore unique monsters */
5456 if (r_ptr->flags1 & RF1_UNIQUE) continue;
5458 /* Ignore monsters with incompatible levels */
5459 if ((r_ptr->level < lev1) || (r_ptr->level > lev2)) continue;
5461 /* Use that index */
5473 bool polymorph_monster(int y, int x)
5475 cave_type *c_ptr = &cave[y][x];
5476 monster_type *m_ptr = &m_list[c_ptr->m_idx];
5477 bool polymorphed = FALSE;
5479 int old_r_idx = m_ptr->r_idx;
5480 bool targeted = (target_who == c_ptr->m_idx) ? TRUE : FALSE;
5481 bool health_tracked = (p_ptr->health_who == c_ptr->m_idx) ? TRUE : FALSE;
5482 monster_type back_m;
5484 if (p_ptr->inside_arena || p_ptr->inside_battle) return (FALSE);
5486 if ((p_ptr->riding == c_ptr->m_idx) || (m_ptr->mflag2 & MFLAG2_KAGE)) return (FALSE);
5488 /* Memorize the monster before polymorphing */
5491 /* Pick a "new" monster race */
5492 new_r_idx = poly_r_idx(old_r_idx);
5494 /* Handle polymorph */
5495 if (new_r_idx != old_r_idx)
5498 bool preserve_hold_objects = back_m.hold_o_idx ? TRUE : FALSE;
5499 s16b this_o_idx, next_o_idx = 0;
5501 /* Get the monsters attitude */
5502 if (is_friendly(m_ptr)) mode |= PM_FORCE_FRIENDLY;
5503 if (is_pet(m_ptr)) mode |= PM_FORCE_PET;
5504 if (m_ptr->mflag2 & MFLAG2_NOPET) mode |= PM_NO_PET;
5506 /* Mega-hack -- ignore held objects */
5507 m_ptr->hold_o_idx = 0;
5509 /* "Kill" the "old" monster */
5510 delete_monster_idx(c_ptr->m_idx);
5512 /* Create a new monster (no groups) */
5513 if (place_monster_aux(0, y, x, new_r_idx, mode))
5515 m_list[hack_m_idx_ii].nickname = back_m.nickname;
5516 m_list[hack_m_idx_ii].parent_m_idx = back_m.parent_m_idx;
5517 m_list[hack_m_idx_ii].hold_o_idx = back_m.hold_o_idx;
5524 /* Placing the new monster failed */
5525 if (place_monster_aux(0, y, x, old_r_idx, (mode | PM_NO_KAGE | PM_IGNORE_TERRAIN)))
5527 m_list[hack_m_idx_ii] = back_m;
5529 /* Re-initialize monster process */
5532 else preserve_hold_objects = FALSE;
5535 /* Mega-hack -- preserve held objects */
5536 if (preserve_hold_objects)
5538 for (this_o_idx = back_m.hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
5540 /* Acquire object */
5541 object_type *o_ptr = &o_list[this_o_idx];
5543 /* Acquire next object */
5544 next_o_idx = o_ptr->next_o_idx;
5546 /* Held by new monster */
5547 o_ptr->held_m_idx = hack_m_idx_ii;
5550 else if (back_m.hold_o_idx) /* Failed (paranoia) */
5552 /* Delete objects */
5553 for (this_o_idx = back_m.hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
5555 /* Acquire next object */
5556 next_o_idx = o_list[this_o_idx].next_o_idx;
5558 /* Delete the object */
5559 delete_object_idx(this_o_idx);
5563 if (targeted) target_who = hack_m_idx_ii;
5564 if (health_tracked) health_track(hack_m_idx_ii);
5574 static bool dimension_door_aux(int x, int y)
5576 int plev = p_ptr->lev;
5578 p_ptr->energy_need += (s16b)((s32b)(60 - plev) * ENERGY_NEED() / 100L);
5580 if (!cave_player_teleportable_bold(y, x, 0L) ||
5581 (distance(y, x, py, px) > plev / 2 + 10) ||
5582 (!randint0(plev / 10 + 10)))
5584 p_ptr->energy_need += (s16b)((s32b)(60 - plev) * ENERGY_NEED() / 100L);
5585 teleport_player((plev + 2) * 2, TELEPORT_PASSIVE);
5592 teleport_player_to(y, x, 0L);
5603 bool dimension_door(void)
5607 /* Rerutn FALSE if cancelled */
5608 if (!tgt_pt(&x, &y)) return FALSE;
5610 if (dimension_door_aux(x, y)) return TRUE;
5613 msg_print("ÀºÎ¤«¤éʪ¼Á³¦¤ËÌá¤ë»þ¤¦¤Þ¤¯¤¤¤«¤Ê¤«¤Ã¤¿¡ª");
5615 msg_print("You fail to exit the astral plane correctly!");
5623 * Mirror Master's Dimension Door
5625 bool mirror_tunnel(void)
5629 /* Rerutn FALSE if cancelled */
5630 if (!tgt_pt(&x, &y)) return FALSE;
5632 if (dimension_door_aux(x, y)) return TRUE;
5635 msg_print("¶À¤ÎÀ¤³¦¤ò¤¦¤Þ¤¯Ä̤ì¤Ê¤«¤Ã¤¿¡ª");
5637 msg_print("You fail to pass the mirror plane correctly!");
5644 bool eat_magic(int power)
5646 object_type * o_ptr;
5649 int recharge_strength = 0;
5655 char o_name[MAX_NLEN];
5657 item_tester_hook = item_tester_hook_recharge;
5661 q = "¤É¤Î¥¢¥¤¥Æ¥à¤«¤éËâÎϤòµÛ¼ý¤·¤Þ¤¹¤«¡©";
5662 s = "ËâÎϤòµÛ¼ý¤Ç¤¤ë¥¢¥¤¥Æ¥à¤¬¤¢¤ê¤Þ¤»¤ó¡£";
5664 q = "Drain which item? ";
5665 s = "You have nothing to drain.";
5668 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return FALSE;
5672 o_ptr = &inventory[item];
5676 o_ptr = &o_list[0 - item];
5679 k_ptr = &k_info[o_ptr->k_idx];
5680 lev = k_info[o_ptr->k_idx].level;
5682 if (o_ptr->tval == TV_ROD)
5684 recharge_strength = ((power > lev/2) ? (power - lev/2) : 0) / 5;
5687 if (one_in_(recharge_strength))
5689 /* Activate the failure code. */
5694 if (o_ptr->timeout > (o_ptr->number - 1) * k_ptr->pval)
5697 msg_print("½¼Å¶Ãæ¤Î¥í¥Ã¥É¤«¤éËâÎϤòµÛ¼ý¤¹¤ë¤³¤È¤Ï¤Ç¤¤Þ¤»¤ó¡£");
5699 msg_print("You can't absorb energy from a discharged rod.");
5706 o_ptr->timeout += k_ptr->pval;
5712 /* All staffs, wands. */
5713 recharge_strength = (100 + power - lev) / 15;
5716 if (recharge_strength < 0) recharge_strength = 0;
5719 if (one_in_(recharge_strength))
5721 /* Activate the failure code. */
5726 if (o_ptr->pval > 0)
5728 p_ptr->csp += lev / 2;
5731 /* XXX Hack -- unstack if necessary */
5732 if ((o_ptr->tval == TV_STAFF) && (item >= 0) && (o_ptr->number > 1))
5737 /* Get local object */
5740 /* Obtain a local object */
5741 object_copy(q_ptr, o_ptr);
5743 /* Modify quantity */
5746 /* Restore the charges */
5749 /* Unstack the used item */
5751 p_ptr->total_weight -= q_ptr->weight;
5752 item = inven_carry(q_ptr);
5756 msg_print("¾ó¤ò¤Þ¤È¤á¤Ê¤ª¤·¤¿¡£");
5758 msg_print("You unstack your staff.");
5766 msg_print("µÛ¼ý¤Ç¤¤ëËâÎϤ¬¤¢¤ê¤Þ¤»¤ó¡ª");
5768 msg_print("There's no energy there to absorb!");
5772 if (!o_ptr->pval) o_ptr->ident |= IDENT_EMPTY;
5776 /* Inflict the penalties for failing a recharge. */
5779 /* Artifacts are never destroyed. */
5780 if (object_is_fixed_artifact(o_ptr))
5782 object_desc(o_name, o_ptr, OD_NAME_ONLY);
5784 msg_format("ËâÎϤ¬µÕή¤·¤¿¡ª%s¤Ï´°Á´¤ËËâÎϤò¼º¤Ã¤¿¡£", o_name);
5786 msg_format("The recharging backfires - %s is completely drained!", o_name);
5790 /* Artifact rods. */
5791 if (o_ptr->tval == TV_ROD)
5792 o_ptr->timeout = k_ptr->pval * o_ptr->number;
5794 /* Artifact wands and staffs. */
5795 else if ((o_ptr->tval == TV_WAND) || (o_ptr->tval == TV_STAFF))
5800 /* Get the object description */
5801 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
5803 /*** Determine Seriousness of Failure ***/
5805 /* Mages recharge objects more safely. */
5806 if (p_ptr->pclass == CLASS_MAGE || p_ptr->pclass == CLASS_HIGH_MAGE || p_ptr->pclass == CLASS_SORCERER || p_ptr->pclass == CLASS_MAGIC_EATER || p_ptr->pclass == CLASS_BLUE_MAGE)
5808 /* 10% chance to blow up one rod, otherwise draining. */
5809 if (o_ptr->tval == TV_ROD)
5811 if (one_in_(10)) fail_type = 2;
5814 /* 75% chance to blow up one wand, otherwise draining. */
5815 else if (o_ptr->tval == TV_WAND)
5817 if (!one_in_(3)) fail_type = 2;
5820 /* 50% chance to blow up one staff, otherwise no effect. */
5821 else if (o_ptr->tval == TV_STAFF)
5823 if (one_in_(2)) fail_type = 2;
5828 /* All other classes get no special favors. */
5831 /* 33% chance to blow up one rod, otherwise draining. */
5832 if (o_ptr->tval == TV_ROD)
5834 if (one_in_(3)) fail_type = 2;
5837 /* 20% chance of the entire stack, else destroy one wand. */
5838 else if (o_ptr->tval == TV_WAND)
5840 if (one_in_(5)) fail_type = 3;
5843 /* Blow up one staff. */
5844 else if (o_ptr->tval == TV_STAFF)
5850 /*** Apply draining and destruction. ***/
5852 /* Drain object or stack of objects. */
5855 if (o_ptr->tval == TV_ROD)
5858 msg_print("¥í¥Ã¥É¤ÏÇË»¤òÌȤ줿¤¬¡¢ËâÎϤÏÁ´¤Æ¼º¤Ê¤ï¤ì¤¿¡£");
5860 msg_format("You save your rod from destruction, but all charges are lost.", o_name);
5863 o_ptr->timeout = k_ptr->pval * o_ptr->number;
5865 else if (o_ptr->tval == TV_WAND)
5868 msg_format("%s¤ÏÇË»¤òÌȤ줿¤¬¡¢ËâÎϤ¬Á´¤Æ¼º¤ï¤ì¤¿¡£", o_name);
5870 msg_format("You save your %s from destruction, but all charges are lost.", o_name);
5875 /* Staffs aren't drained. */
5878 /* Destroy an object or one in a stack of objects. */
5881 if (o_ptr->number > 1)
5884 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬°ìËܲõ¤ì¤¿¡ª", o_name);
5886 msg_format("Wild magic consumes one of your %s!", o_name);
5889 /* Reduce rod stack maximum timeout, drain wands. */
5890 if (o_ptr->tval == TV_ROD) o_ptr->timeout = MIN(o_ptr->timeout, k_ptr->pval * (o_ptr->number - 1));
5891 else if (o_ptr->tval == TV_WAND) o_ptr->pval = o_ptr->pval * (o_ptr->number - 1) / o_ptr->number;
5896 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬²¿Ëܤ«²õ¤ì¤¿¡ª", o_name);
5898 msg_format("Wild magic consumes your %s!", o_name);
5901 /* Reduce and describe inventory */
5904 inven_item_increase(item, -1);
5905 inven_item_describe(item);
5906 inven_item_optimize(item);
5909 /* Reduce and describe floor item */
5912 floor_item_increase(0 - item, -1);
5913 floor_item_describe(0 - item);
5914 floor_item_optimize(0 - item);
5918 /* Destroy all members of a stack of objects. */
5921 if (o_ptr->number > 1)
5923 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬Á´¤Æ²õ¤ì¤¿¡ª", o_name);
5925 msg_format("Wild magic consumes all your %s!", o_name);
5930 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬²õ¤ì¤¿¡ª", o_name);
5932 msg_format("Wild magic consumes your %s!", o_name);
5937 /* Reduce and describe inventory */
5940 inven_item_increase(item, -999);
5941 inven_item_describe(item);
5942 inven_item_optimize(item);
5945 /* Reduce and describe floor item */
5948 floor_item_increase(0 - item, -999);
5949 floor_item_describe(0 - item);
5950 floor_item_optimize(0 - item);
5956 if (p_ptr->csp > p_ptr->msp)
5958 p_ptr->csp = p_ptr->msp;
5961 /* Redraw mana and hp */
5962 p_ptr->redraw |= (PR_MANA);
5964 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
5965 p_ptr->window |= (PW_INVEN);
5971 bool summon_kin_player(int level, int y, int x, u32b mode)
5973 bool pet = (bool)(mode & PM_FORCE_PET);
5974 if (!pet) mode |= PM_NO_PET;
5976 switch (p_ptr->mimic_form)
5979 switch (p_ptr->prace)
5983 case RACE_BARBARIAN:
5986 summon_kin_type = 'p';
5996 case RACE_MIND_FLAYER:
5999 summon_kin_type = 'h';
6002 summon_kin_type = 'o';
6004 case RACE_HALF_TROLL:
6005 summon_kin_type = 'T';
6007 case RACE_HALF_OGRE:
6008 summon_kin_type = 'O';
6010 case RACE_HALF_GIANT:
6011 case RACE_HALF_TITAN:
6013 summon_kin_type = 'P';
6016 summon_kin_type = 'y';
6019 summon_kin_type = 'K';
6022 summon_kin_type = 'k';
6025 if (one_in_(13)) summon_kin_type = 'U';
6026 else summon_kin_type = 'u';
6028 case RACE_DRACONIAN:
6029 summon_kin_type = 'd';
6033 summon_kin_type = 'g';
6036 if (one_in_(13)) summon_kin_type = 'L';
6037 else summon_kin_type = 's';
6040 summon_kin_type = 'z';
6043 summon_kin_type = 'V';
6046 summon_kin_type = 'G';
6049 summon_kin_type = 'I';
6052 summon_kin_type = '#';
6055 summon_kin_type = 'A';
6058 summon_kin_type = 'U';
6061 summon_kin_type = 'p';
6066 if (one_in_(13)) summon_kin_type = 'U';
6067 else summon_kin_type = 'u';
6069 case MIMIC_DEMON_LORD:
6070 summon_kin_type = 'U';
6073 summon_kin_type = 'V';
6076 return summon_specific((pet ? -1 : 0), y, x, level, SUMMON_KIN, mode);