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 /* don't teleport on a trap. */
271 if (have_flag(f_ptr->flags, FF_HIT_TRAP)) return FALSE;
273 if (!(mode & TELEPORT_PASSIVE))
275 if (!player_can_enter(c_ptr->feat, 0)) return FALSE;
277 if (have_flag(f_ptr->flags, FF_WATER) && have_flag(f_ptr->flags, FF_DEEP))
279 if (!p_ptr->levitation && !p_ptr->can_swim) return FALSE;
282 if (have_flag(f_ptr->flags, FF_LAVA) && !p_ptr->immune_fire && !IS_INVULN())
284 /* Always forbid deep lava */
285 if (have_flag(f_ptr->flags, FF_DEEP)) return FALSE;
287 /* Forbid shallow lava when the player don't have levitation */
288 if (!p_ptr->levitation) return FALSE;
298 * Teleport the player to a location up to "dis" grids away.
300 * If no such spaces are readily available, the distance may increase.
301 * Try very hard to move the player at least a quarter that distance.
303 * There was a nasty tendency for a long time; which was causing the
304 * player to "bounce" between two or three different spots because
305 * these are the only spots that are "far enough" way to satisfy the
308 * But this tendency is now removed; in the new algorithm, a list of
309 * candidates is selected first, which includes at least 50% of all
310 * floor grids within the distance, and any single grid in this list
311 * of candidates has equal possibility to be choosen as a destination.
314 #define MAX_TELEPORT_DISTANCE 200
316 bool teleport_player_aux(int dis, u32b mode)
318 int candidates_at[MAX_TELEPORT_DISTANCE + 1];
319 int total_candidates, cur_candidates;
320 int y = 0, x = 0, min, pick, i;
322 int left = MAX(1, px - dis);
323 int right = MIN(cur_wid - 2, px + dis);
324 int top = MAX(1, py - dis);
325 int bottom = MIN(cur_hgt - 2, py + dis);
327 if (p_ptr->wild_mode) return FALSE;
329 if (p_ptr->anti_tele && !(mode & TELEPORT_NONMAGICAL))
332 msg_print("ÉԻ׵ĤÊÎϤ¬¥Æ¥ì¥Ý¡¼¥È¤òËɤ¤¤À¡ª");
334 msg_print("A mysterious force prevents you from teleporting!");
340 /* Initialize counters */
341 total_candidates = 0;
342 for (i = 0; i <= MAX_TELEPORT_DISTANCE; i++)
343 candidates_at[i] = 0;
345 /* Limit the distance */
346 if (dis > MAX_TELEPORT_DISTANCE) dis = MAX_TELEPORT_DISTANCE;
348 /* Search valid locations */
349 for (y = top; y <= bottom; y++)
351 for (x = left; x <= right; x++)
355 /* Skip illegal locations */
356 if (!cave_player_teleportable_bold(y, x, mode)) continue;
358 /* Calculate distance */
359 d = distance(py, px, y, x);
361 /* Skip too far locations */
362 if (d > dis) continue;
364 /* Count the total number of candidates */
367 /* Count the number of candidates in this circumference */
372 /* No valid location! */
373 if (0 == total_candidates) return FALSE;
375 /* Fix the minimum distance */
376 for (cur_candidates = 0, min = dis; min >= 0; min--)
378 cur_candidates += candidates_at[min];
380 /* 50% of all candidates will have an equal chance to be choosen. */
381 if (cur_candidates && (cur_candidates >= total_candidates / 2)) break;
384 /* Pick up a single location randomly */
385 pick = randint1(cur_candidates);
387 /* Search again the choosen location */
388 for (y = top; y <= bottom; y++)
390 for (x = left; x <= right; x++)
394 /* Skip illegal locations */
395 if (!cave_player_teleportable_bold(y, x, mode)) continue;
397 /* Calculate distance */
398 d = distance(py, px, y, x);
400 /* Skip too far locations */
401 if (d > dis) continue;
403 /* Skip too close locations */
404 if (d < min) continue;
406 /* This grid was picked up? */
415 if (player_bold(y, x)) return FALSE;
418 sound(SOUND_TELEPORT);
421 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
422 msg_format("¡Ø¤³¤Ã¤Á¤À¤¡¡¢%s¡Ù", player_name);
425 /* Move the player */
426 (void)move_player_effect(y, x, MPE_FORGET_FLOW | MPE_HANDLE_STUFF | MPE_DONT_PICKUP);
431 void teleport_player(int dis, u32b mode)
435 /* Save the old location */
439 if (!teleport_player_aux(dis, mode)) return;
441 /* Monsters with teleport ability may follow the player */
442 for (xx = -1; xx < 2; xx++)
444 for (yy = -1; yy < 2; yy++)
446 int tmp_m_idx = cave[oy+yy][ox+xx].m_idx;
448 /* A monster except your mount may follow */
449 if (tmp_m_idx && (p_ptr->riding != tmp_m_idx))
451 monster_type *m_ptr = &m_list[tmp_m_idx];
452 monster_race *r_ptr = &r_info[m_ptr->r_idx];
455 * The latter limitation is to avoid
456 * totally unkillable suckers...
458 if ((r_ptr->flags6 & RF6_TPORT) &&
459 !(r_ptr->flagsr & RFR_RES_TELE))
461 if (!MON_CSLEEP(m_ptr)) teleport_monster_to(tmp_m_idx, py, px, r_ptr->level, 0L);
469 void teleport_player_away(int m_idx, int dis)
473 /* Save the old location */
477 if (!teleport_player_aux(dis, TELEPORT_PASSIVE)) return;
479 /* Monsters with teleport ability may follow the player */
480 for (xx = -1; xx < 2; xx++)
482 for (yy = -1; yy < 2; yy++)
484 int tmp_m_idx = cave[oy+yy][ox+xx].m_idx;
486 /* A monster except your mount or caster may follow */
487 if (tmp_m_idx && (p_ptr->riding != tmp_m_idx) && (m_idx != tmp_m_idx))
489 monster_type *m_ptr = &m_list[tmp_m_idx];
490 monster_race *r_ptr = &r_info[m_ptr->r_idx];
493 * The latter limitation is to avoid
494 * totally unkillable suckers...
496 if ((r_ptr->flags6 & RF6_TPORT) &&
497 !(r_ptr->flagsr & RFR_RES_TELE))
499 if (!MON_CSLEEP(m_ptr)) teleport_monster_to(tmp_m_idx, py, px, r_ptr->level, 0L);
508 * Teleport player to a grid near the given location
510 * This function is slightly obsessive about correctness.
511 * This function allows teleporting into vaults (!)
513 void teleport_player_to(int ny, int nx, u32b mode)
515 int y, x, dis = 0, ctr = 0;
517 if (p_ptr->anti_tele && !(mode & TELEPORT_NONMAGICAL))
520 msg_print("ÉԻ׵ĤÊÎϤ¬¥Æ¥ì¥Ý¡¼¥È¤òËɤ¤¤À¡ª");
522 msg_print("A mysterious force prevents you from teleporting!");
528 /* Find a usable location */
531 /* Pick a nearby legal location */
534 y = rand_spread(ny, dis);
535 x = rand_spread(nx, dis);
536 if (in_bounds(y, x)) break;
539 /* Accept any grid when wizard mode */
540 if (p_ptr->wizard && !(mode & TELEPORT_PASSIVE) && (!cave[y][x].m_idx || (cave[y][x].m_idx == p_ptr->riding))) break;
542 /* Accept teleportable floor grids */
543 if (cave_player_teleportable_bold(y, x, mode)) break;
545 /* Occasionally advance the distance */
546 if (++ctr > (4 * dis * dis + 4 * dis + 1))
554 sound(SOUND_TELEPORT);
556 /* Move the player */
557 (void)move_player_effect(y, x, MPE_FORGET_FLOW | MPE_HANDLE_STUFF | MPE_DONT_PICKUP);
561 void teleport_away_followable(int m_idx)
563 monster_type *m_ptr = &m_list[m_idx];
564 int oldfy = m_ptr->fy;
565 int oldfx = m_ptr->fx;
566 bool old_ml = m_ptr->ml;
567 int old_cdis = m_ptr->cdis;
569 teleport_away(m_idx, MAX_SIGHT * 2 + 5, 0L);
571 if (old_ml && (old_cdis <= MAX_SIGHT) && !world_monster && !p_ptr->inside_battle && los(py, px, oldfy, oldfx))
575 if ((p_ptr->muta1 & MUT1_VTELEPORT) || (p_ptr->pclass == CLASS_IMITATOR)) follow = TRUE;
578 u32b flgs[TR_FLAG_SIZE];
582 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
584 o_ptr = &inventory[i];
585 if (o_ptr->k_idx && !object_is_cursed(o_ptr))
587 object_flags(o_ptr, flgs);
588 if (have_flag(flgs, TR_TELEPORT))
600 if (get_check_strict("¤Ä¤¤¤Æ¤¤¤¤Þ¤¹¤«¡©", CHECK_OKAY_CANCEL))
602 if (get_check_strict("Do you follow it? ", CHECK_OKAY_CANCEL))
607 teleport_player(200, TELEPORT_PASSIVE);
611 msg_print("Failed!");
614 else teleport_player_to(m_ptr->fy, m_ptr->fx, 0L);
615 p_ptr->energy_need += ENERGY_NEED();
623 * Teleport the player one level up or down (random when legal)
624 * Note: If m_idx <= 0, target is player.
626 void teleport_level(int m_idx)
632 if (m_idx <= 0) /* To player */
635 strcpy(m_name, "¤¢¤Ê¤¿");
637 strcpy(m_name, "you");
640 else /* To monster */
642 monster_type *m_ptr = &m_list[m_idx];
644 /* Get the monster name (or "it") */
645 monster_desc(m_name, m_ptr, 0);
647 see_m = is_seen(m_ptr);
650 /* No effect in some case */
651 if (TELE_LEVEL_IS_INEFF(m_idx))
654 if (see_m) msg_print("¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡£");
656 if (see_m) msg_print("There is no effect.");
662 if ((m_idx <= 0) && p_ptr->anti_tele) /* To player */
665 msg_print("ÉԻ׵ĤÊÎϤ¬¥Æ¥ì¥Ý¡¼¥È¤òËɤ¤¤À¡ª");
667 msg_print("A mysterious force prevents you from teleporting!");
672 /* Choose up or down */
673 if (randint0(100) < 50) go_up = TRUE;
676 if ((m_idx <= 0) && p_ptr->wizard)
678 if (get_check("Force to go up? ")) go_up = TRUE;
679 else if (get_check("Force to go down? ")) go_up = FALSE;
683 if ((ironman_downward && (m_idx <= 0)) || (dun_level <= d_info[dungeon_type].mindepth))
686 if (see_m) msg_format("%^s¤Ï¾²¤òÆͤÇˤäÆÄÀ¤ó¤Ç¤¤¤¯¡£", m_name);
688 if (see_m) msg_format("%^s sink%s through the floor.", m_name, (m_idx <= 0) ? "" : "s");
690 if (m_idx <= 0) /* To player */
694 dungeon_type = p_ptr->recall_dungeon;
699 if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, 1, NULL);
701 if (autosave_l) do_cmd_save_game(TRUE);
705 dun_level = d_info[dungeon_type].mindepth;
706 prepare_change_floor_mode(CFM_RAND_PLACE);
710 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN | CFM_RAND_PLACE | CFM_RAND_CONNECT);
714 p_ptr->leaving = TRUE;
719 else if (quest_number(dun_level) || (dun_level >= d_info[dungeon_type].maxdepth))
722 if (see_m) msg_format("%^s¤ÏÅ·°æ¤òÆͤÇˤäÆÃè¤ØÉ⤤¤Æ¤¤¤¯¡£", m_name);
724 if (see_m) msg_format("%^s rise%s up through the ceiling.", m_name, (m_idx <= 0) ? "" : "s");
728 if (m_idx <= 0) /* To player */
730 if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, -1, NULL);
732 if (autosave_l) do_cmd_save_game(TRUE);
734 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_UP | CFM_RAND_PLACE | CFM_RAND_CONNECT);
739 p_ptr->inside_quest = 0;
740 p_ptr->leaving = TRUE;
746 if (see_m) msg_format("%^s¤ÏÅ·°æ¤òÆͤÇˤäÆÃè¤ØÉ⤤¤Æ¤¤¤¯¡£", m_name);
748 if (see_m) msg_format("%^s rise%s up through the ceiling.", m_name, (m_idx <= 0) ? "" : "s");
752 if (m_idx <= 0) /* To player */
754 if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, -1, NULL);
756 if (autosave_l) do_cmd_save_game(TRUE);
758 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_UP | CFM_RAND_PLACE | CFM_RAND_CONNECT);
761 p_ptr->leaving = TRUE;
767 if (see_m) msg_format("%^s¤Ï¾²¤òÆͤÇˤäÆÄÀ¤ó¤Ç¤¤¤¯¡£", m_name);
769 if (see_m) msg_format("%^s sink%s through the floor.", m_name, (m_idx <= 0) ? "" : "s");
772 if (m_idx <= 0) /* To player */
774 /* Never reach this code on the surface */
775 /* if (!dun_level) dungeon_type = p_ptr->recall_dungeon; */
777 if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, 1, NULL);
779 if (autosave_l) do_cmd_save_game(TRUE);
781 prepare_change_floor_mode(CFM_SAVE_FLOORS | CFM_DOWN | CFM_RAND_PLACE | CFM_RAND_CONNECT);
784 p_ptr->leaving = TRUE;
788 /* Monster level teleportation is simple deleting now */
791 monster_type *m_ptr = &m_list[m_idx];
793 /* Check for quest completion */
794 check_quest_completion(m_ptr);
796 if (record_named_pet && is_pet(m_ptr) && m_ptr->nickname)
800 monster_desc(m2_name, m_ptr, MD_INDEF_VISIBLE);
801 do_cmd_write_nikki(NIKKI_NAMED_PET, RECORD_NAMED_PET_TELE_LEVEL, m2_name);
804 delete_monster_idx(m_idx);
808 sound(SOUND_TPLEVEL);
813 int choose_dungeon(cptr note, int y, int x)
819 /* Hack -- No need to choose dungeon in some case */
820 if (lite_town || vanilla_town || ironman_downward)
822 if (max_dlv[DUNGEON_ANGBAND]) return DUNGEON_ANGBAND;
826 msg_format("¤Þ¤À%s¤ËÆþ¤Ã¤¿¤³¤È¤Ï¤Ê¤¤¡£", d_name + d_info[DUNGEON_ANGBAND].name);
828 msg_format("You haven't entered %s yet.", d_name + d_info[DUNGEON_ANGBAND].name);
835 /* Allocate the "dun" array */
836 C_MAKE(dun, max_d_idx, s16b);
839 for(i = 1; i < max_d_idx; i++)
844 if (!d_info[i].maxdepth) continue;
845 if (!max_dlv[i]) continue;
846 if (d_info[i].final_guardian)
848 if (!r_info[d_info[i].final_guardian].max_num) seiha = TRUE;
850 else if (max_dlv[i] == d_info[i].maxdepth) seiha = TRUE;
853 sprintf(buf," %c) %c%-12s : ºÇÂç %d ³¬", 'a'+num, seiha ? '!' : ' ', d_name + d_info[i].name, max_dlv[i]);
855 sprintf(buf," %c) %c%-16s : Max level %d", 'a'+num, seiha ? '!' : ' ', d_name + d_info[i].name, max_dlv[i]);
857 prt(buf, y + num, x);
864 prt(" Áª¤Ù¤ë¥À¥ó¥¸¥ç¥ó¤¬¤Ê¤¤¡£", y, x);
866 prt(" No dungeon is available.", y, x);
871 prt(format("¤É¤Î¥À¥ó¥¸¥ç¥ó%s¤·¤Þ¤¹¤«:", note), 0, 0);
873 prt(format("Which dungeon do you %s?: ", note), 0, 0);
878 if ((i == ESCAPE) || !num)
880 /* Free the "dun" array */
881 C_KILL(dun, max_d_idx, s16b);
886 if (i >= 'a' && i <('a'+num))
888 select_dungeon = dun[i-'a'];
895 /* Free the "dun" array */
896 C_KILL(dun, max_d_idx, s16b);
898 return select_dungeon;
903 * Recall the player to town or dungeon
905 bool recall_player(int turns)
908 * TODO: Recall the player to the last
909 * visited town when in the wilderness
913 if (p_ptr->inside_arena || ironman_downward)
916 msg_print("²¿¤âµ¯¤³¤é¤Ê¤«¤Ã¤¿¡£");
918 msg_print("Nothing happens.");
924 if (dun_level && (max_dlv[dungeon_type] > dun_level) && !p_ptr->inside_quest && !p_ptr->word_recall)
927 if (get_check("¤³¤³¤ÏºÇ¿¼Åþ㳬¤è¤êÀõ¤¤³¬¤Ç¤¹¡£¤³¤Î³¬¤ËÌá¤Ã¤ÆÍè¤Þ¤¹¤«¡© "))
929 if (get_check("Reset recall depth? "))
932 max_dlv[dungeon_type] = dun_level;
935 do_cmd_write_nikki(NIKKI_TRUMP, dungeon_type, "µ¢´Ô¤Î¤È¤¤Ë");
937 do_cmd_write_nikki(NIKKI_TRUMP, dungeon_type, "when recall from dungeon");
942 if (!p_ptr->word_recall)
948 select_dungeon = choose_dungeon("¤Ëµ¢´Ô", 2, 14);
950 select_dungeon = choose_dungeon("recall", 2, 14);
952 if (!select_dungeon) return FALSE;
953 p_ptr->recall_dungeon = select_dungeon;
955 p_ptr->word_recall = turns;
957 msg_print("²ó¤ê¤ÎÂ絤¤¬Ä¥¤ê¤Ä¤á¤Æ¤¤¿...");
959 msg_print("The air about you becomes charged...");
962 p_ptr->redraw |= (PR_STATUS);
966 p_ptr->word_recall = 0;
968 msg_print("Ä¥¤ê¤Ä¤á¤¿Â絤¤¬Î®¤ìµî¤Ã¤¿...");
970 msg_print("A tension leaves the air around you...");
973 p_ptr->redraw |= (PR_STATUS);
979 bool word_of_recall(void)
981 return(recall_player(randint0(21) + 15));
985 bool reset_recall(void)
987 int select_dungeon, dummy = 0;
992 select_dungeon = choose_dungeon("¤ò¥»¥Ã¥È", 2, 14);
994 select_dungeon = choose_dungeon("reset", 2, 14);
998 if (ironman_downward)
1001 msg_print("²¿¤âµ¯¤³¤é¤Ê¤«¤Ã¤¿¡£");
1003 msg_print("Nothing happens.");
1009 if (!select_dungeon) return FALSE;
1012 sprintf(ppp, "²¿³¬¤Ë¥»¥Ã¥È¤·¤Þ¤¹¤« (%d-%d):", d_info[select_dungeon].mindepth, max_dlv[select_dungeon]);
1014 sprintf(ppp, "Reset to which level (%d-%d): ", d_info[select_dungeon].mindepth, max_dlv[select_dungeon]);
1019 sprintf(tmp_val, "%d", MAX(dun_level, 1));
1021 /* Ask for a level */
1022 if (get_string(ppp, tmp_val, 10))
1024 /* Extract request */
1025 dummy = atoi(tmp_val);
1028 if (dummy < 1) dummy = 1;
1031 if (dummy > max_dlv[select_dungeon]) dummy = max_dlv[select_dungeon];
1032 if (dummy < d_info[select_dungeon].mindepth) dummy = d_info[select_dungeon].mindepth;
1034 max_dlv[select_dungeon] = dummy;
1036 if (record_maxdepth)
1038 do_cmd_write_nikki(NIKKI_TRUMP, select_dungeon, "¥Õ¥í¥¢¡¦¥ê¥»¥Ã¥È¤Ç");
1040 do_cmd_write_nikki(NIKKI_TRUMP, select_dungeon, "using a scroll of reset recall");
1042 /* Accept request */
1044 msg_format("%s¤Îµ¢´Ô¥ì¥Ù¥ë¤ò %d ³¬¤Ë¥»¥Ã¥È¡£", d_name+d_info[select_dungeon].name, dummy, dummy * 50);
1046 msg_format("Recall depth set to level %d (%d').", dummy, dummy * 50);
1059 * Apply disenchantment to the player's stuff
1061 * XXX XXX XXX This function is also called from the "melee" code
1063 * Return "TRUE" if the player notices anything
1065 bool apply_disenchant(int mode)
1069 char o_name[MAX_NLEN];
1070 int to_h, to_d, to_a, pval;
1072 /* Pick a random slot */
1073 switch (randint1(8))
1075 case 1: t = INVEN_RARM; break;
1076 case 2: t = INVEN_LARM; break;
1077 case 3: t = INVEN_BOW; break;
1078 case 4: t = INVEN_BODY; break;
1079 case 5: t = INVEN_OUTER; break;
1080 case 6: t = INVEN_HEAD; break;
1081 case 7: t = INVEN_HANDS; break;
1082 case 8: t = INVEN_FEET; break;
1086 o_ptr = &inventory[t];
1088 /* No item, nothing happens */
1089 if (!o_ptr->k_idx) return (FALSE);
1091 /* Disenchant equipments only -- No disenchant on monster ball */
1092 if (!object_is_weapon_armour_ammo(o_ptr))
1095 /* Nothing to disenchant */
1096 if ((o_ptr->to_h <= 0) && (o_ptr->to_d <= 0) && (o_ptr->to_a <= 0) && (o_ptr->pval <= 1))
1098 /* Nothing to notice */
1103 /* Describe the object */
1104 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
1107 /* Artifacts have 71% chance to resist */
1108 if (object_is_artifact(o_ptr) && (randint0(100) < 71))
1112 msg_format("%s(%c)¤ÏÎô²½¤òÄ·¤ÍÊÖ¤·¤¿¡ª",o_name, index_to_label(t) );
1114 msg_format("Your %s (%c) resist%s disenchantment!",
1115 o_name, index_to_label(t),
1116 ((o_ptr->number != 1) ? "" : "s"));
1125 /* Memorize old value */
1131 /* Disenchant tohit */
1132 if (o_ptr->to_h > 0) o_ptr->to_h--;
1133 if ((o_ptr->to_h > 5) && (randint0(100) < 20)) o_ptr->to_h--;
1135 /* Disenchant todam */
1136 if (o_ptr->to_d > 0) o_ptr->to_d--;
1137 if ((o_ptr->to_d > 5) && (randint0(100) < 20)) o_ptr->to_d--;
1139 /* Disenchant toac */
1140 if (o_ptr->to_a > 0) o_ptr->to_a--;
1141 if ((o_ptr->to_a > 5) && (randint0(100) < 20)) o_ptr->to_a--;
1143 /* Disenchant pval (occasionally) */
1144 /* Unless called from wild_magic() */
1145 if ((o_ptr->pval > 1) && one_in_(13) && !(mode & 0x01)) o_ptr->pval--;
1147 if ((to_h != o_ptr->to_h) || (to_d != o_ptr->to_d) ||
1148 (to_a != o_ptr->to_a) || (pval != o_ptr->pval))
1152 msg_format("%s(%c)¤ÏÎô²½¤·¤Æ¤·¤Þ¤Ã¤¿¡ª",
1153 o_name, index_to_label(t) );
1155 msg_format("Your %s (%c) %s disenchanted!",
1156 o_name, index_to_label(t),
1157 ((o_ptr->number != 1) ? "were" : "was"));
1160 chg_virtue(V_HARMONY, 1);
1161 chg_virtue(V_ENCHANT, -2);
1163 /* Recalculate bonuses */
1164 p_ptr->update |= (PU_BONUS);
1167 p_ptr->window |= (PW_EQUIP | PW_PLAYER);
1177 void mutate_player(void)
1179 int max1, cur1, max2, cur2, ii, jj, i;
1181 /* Pick a pair of stats */
1183 for (jj = ii; jj == ii; jj = randint0(6)) /* loop */;
1185 max1 = p_ptr->stat_max[ii];
1186 cur1 = p_ptr->stat_cur[ii];
1187 max2 = p_ptr->stat_max[jj];
1188 cur2 = p_ptr->stat_cur[jj];
1190 p_ptr->stat_max[ii] = max2;
1191 p_ptr->stat_cur[ii] = cur2;
1192 p_ptr->stat_max[jj] = max1;
1193 p_ptr->stat_cur[jj] = cur1;
1197 if(p_ptr->stat_max[i] > p_ptr->stat_max_max[i]) p_ptr->stat_max[i] = p_ptr->stat_max_max[i];
1198 if(p_ptr->stat_cur[i] > p_ptr->stat_max_max[i]) p_ptr->stat_cur[i] = p_ptr->stat_max_max[i];
1201 p_ptr->update |= (PU_BONUS);
1208 void apply_nexus(monster_type *m_ptr)
1210 switch (randint1(7))
1212 case 1: case 2: case 3:
1214 teleport_player(200, TELEPORT_PASSIVE);
1220 teleport_player_to(m_ptr->fy, m_ptr->fx, TELEPORT_PASSIVE);
1226 if (randint0(100) < p_ptr->skill_sav)
1229 msg_print("¤·¤«¤·¸úÎϤòÄ·¤ÍÊÖ¤·¤¿¡ª");
1231 msg_print("You resist the effects!");
1237 /* Teleport Level */
1244 if (randint0(100) < p_ptr->skill_sav)
1247 msg_print("¤·¤«¤·¸úÎϤòÄ·¤ÍÊÖ¤·¤¿¡ª");
1249 msg_print("You resist the effects!");
1256 msg_print("ÂΤ¬¤Í¤¸¤ì»Ï¤á¤¿...");
1258 msg_print("Your body starts to scramble...");
1269 * Charge a lite (torch or latern)
1271 void phlogiston(void)
1274 object_type * o_ptr = &inventory[INVEN_LITE];
1277 if ((o_ptr->tval == TV_LITE) && (o_ptr->sval == SV_LITE_LANTERN))
1279 max_flog = FUEL_LAMP;
1283 else if ((o_ptr->tval == TV_LITE) && (o_ptr->sval == SV_LITE_TORCH))
1285 max_flog = FUEL_TORCH;
1288 /* No torch to refill */
1292 msg_print("dzÁǤò¾ÃÈñ¤¹¤ë¥¢¥¤¥Æ¥à¤òÁõÈ÷¤·¤Æ¤¤¤Þ¤»¤ó¡£");
1294 msg_print("You are not wielding anything which uses phlogiston.");
1300 if (o_ptr->xtra4 >= max_flog)
1303 msg_print("¤³¤Î¥¢¥¤¥Æ¥à¤Ë¤Ï¤³¤ì°Ê¾ådzÁǤòÊä½¼¤Ç¤¤Þ¤»¤ó¡£");
1305 msg_print("No more phlogiston can be put in this item.");
1312 o_ptr->xtra4 += (max_flog / 2);
1316 msg_print("¾ÈÌÀÍÑ¥¢¥¤¥Æ¥à¤ËdzÁǤòÊä½¼¤·¤¿¡£");
1318 msg_print("You add phlogiston to your light item.");
1323 if (o_ptr->xtra4 >= max_flog)
1325 o_ptr->xtra4 = max_flog;
1327 msg_print("¾ÈÌÀÍÑ¥¢¥¤¥Æ¥à¤ÏËþ¥¿¥ó¤Ë¤Ê¤Ã¤¿¡£");
1329 msg_print("Your light item is full.");
1334 /* Recalculate torch */
1335 p_ptr->update |= (PU_TORCH);
1340 * Brand the current weapon
1342 void brand_weapon(int brand_type)
1349 /* Assume enchant weapon */
1350 item_tester_hook = object_allow_enchant_melee_weapon;
1351 item_tester_no_ryoute = TRUE;
1355 q = "¤É¤ÎÉð´ï¤ò¶¯²½¤·¤Þ¤¹¤«? ";
1356 s = "¶¯²½¤Ç¤¤ëÉð´ï¤¬¤Ê¤¤¡£";
1358 q = "Enchant which weapon? ";
1359 s = "You have nothing to enchant.";
1362 if (!get_item(&item, q, s, (USE_EQUIP))) return;
1364 /* Get the item (in the pack) */
1367 o_ptr = &inventory[item];
1370 /* Get the item (on the floor) */
1373 o_ptr = &o_list[0 - item];
1377 /* you can never modify artifacts / ego-items */
1378 /* you can never modify cursed items */
1379 /* TY: You _can_ modify broken items (if you're silly enough) */
1380 if (o_ptr->k_idx && !object_is_artifact(o_ptr) && !object_is_ego(o_ptr) &&
1381 !object_is_cursed(o_ptr) &&
1382 !((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DOKUBARI)) &&
1383 !((o_ptr->tval == TV_POLEARM) && (o_ptr->sval == SV_DEATH_SCYTHE)) &&
1384 !((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DIAMOND_EDGE)))
1388 /* Let's get the name before it is changed... */
1389 char o_name[MAX_NLEN];
1390 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
1395 if (o_ptr->tval == TV_SWORD)
1398 act = "¤Ï±Ô¤µ¤òÁý¤·¤¿¡ª";
1400 act = "becomes very sharp!";
1403 o_ptr->name2 = EGO_SHARPNESS;
1404 o_ptr->pval = m_bonus(5, dun_level) + 1;
1406 if ((o_ptr->sval == SV_HAYABUSA) && (o_ptr->pval > 2))
1412 act = "¤ÏÇ˲õÎϤòÁý¤·¤¿¡ª";
1414 act = "seems very powerful.";
1417 o_ptr->name2 = EGO_EARTHQUAKES;
1418 o_ptr->pval = m_bonus(3, dun_level);
1423 act = "¤Ï¿Í´Ö¤Î·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
1425 act = "seems to be looking for humans!";
1428 o_ptr->name2 = EGO_SLAY_HUMAN;
1432 act = "¤ÏÅÅ·â¤Ëʤ¤ï¤ì¤¿¡ª";
1434 act = "covered with lightning!";
1437 o_ptr->name2 = EGO_BRAND_ELEC;
1441 act = "¤Ï»À¤Ëʤ¤ï¤ì¤¿¡ª";
1443 act = "coated with acid!";
1446 o_ptr->name2 = EGO_BRAND_ACID;
1450 act = "¤Ï¼Ù°¤Ê¤ë²øʪ¤òµá¤á¤Æ¤¤¤ë¡ª";
1452 act = "seems to be looking for evil monsters!";
1455 o_ptr->name2 = EGO_SLAY_EVIL;
1459 act = "¤Ï°ÛÀ¤³¦¤Î½»¿Í¤ÎÆùÂΤòµá¤á¤Æ¤¤¤ë¡ª";
1461 act = "seems to be looking for demons!";
1464 o_ptr->name2 = EGO_SLAY_DEMON;
1468 act = "¤Ï»Ó¤òµá¤á¤Æ¤¤¤ë¡ª";
1470 act = "seems to be looking for undead!";
1473 o_ptr->name2 = EGO_SLAY_UNDEAD;
1477 act = "¤Ïưʪ¤Î·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
1479 act = "seems to be looking for animals!";
1482 o_ptr->name2 = EGO_SLAY_ANIMAL;
1486 act = "¤Ï¥É¥é¥´¥ó¤Î·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
1488 act = "seems to be looking for dragons!";
1491 o_ptr->name2 = EGO_SLAY_DRAGON;
1495 act = "¤Ï¥È¥í¥ë¤Î·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
1497 act = "seems to be looking for troll!s";
1500 o_ptr->name2 = EGO_SLAY_TROLL;
1504 act = "¤Ï¥ª¡¼¥¯¤Î·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
1506 act = "seems to be looking for orcs!";
1509 o_ptr->name2 = EGO_SLAY_ORC;
1513 act = "¤Ïµð¿Í¤Î·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
1515 act = "seems to be looking for giants!";
1518 o_ptr->name2 = EGO_SLAY_GIANT;
1522 act = "¤ÏÈó¾ï¤ËÉÔ°ÂÄê¤Ë¤Ê¤Ã¤¿¤è¤¦¤À¡£";
1524 act = "seems very unstable now.";
1527 o_ptr->name2 = EGO_TRUMP;
1528 o_ptr->pval = randint1(2);
1532 act = "¤Ï·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
1534 act = "thirsts for blood!";
1537 o_ptr->name2 = EGO_VAMPIRIC;
1541 act = "¤ÏÆǤËʤ¤ï¤ì¤¿¡£";
1543 act = "is coated with poison.";
1546 o_ptr->name2 = EGO_BRAND_POIS;
1550 act = "¤Ï½ã¥í¥°¥ë¥¹¤Ë°û¤ß¹þ¤Þ¤ì¤¿¡£";
1552 act = "is engulfed in raw Logrus!";
1555 o_ptr->name2 = EGO_CHAOTIC;
1559 act = "¤Ï±ê¤Î¥·¡¼¥ë¥É¤Ëʤ¤ï¤ì¤¿¡ª";
1561 act = "is covered in a fiery shield!";
1564 o_ptr->name2 = EGO_BRAND_FIRE;
1568 act = "¤Ï¿¼¤¯Î䤿¤¤¥Ö¥ë¡¼¤Ëµ±¤¤¤¿¡ª";
1570 act = "glows deep, icy blue!";
1573 o_ptr->name2 = EGO_BRAND_COLD;
1578 msg_format("¤¢¤Ê¤¿¤Î%s%s", o_name, act);
1580 msg_format("Your %s %s", o_name, act);
1584 enchant(o_ptr, randint0(3) + 4, ENCH_TOHIT | ENCH_TODAM);
1586 o_ptr->discount = 99;
1587 chg_virtue(V_ENCHANT, 2);
1591 if (flush_failure) flush();
1594 msg_print("°ÀÉղä˼ºÇÔ¤·¤¿¡£");
1596 msg_print("The Branding failed.");
1599 chg_virtue(V_ENCHANT, -2);
1606 * Vanish all walls in this floor
1608 static bool vanish_dungeon(void)
1612 feature_type *f_ptr;
1613 monster_type *m_ptr;
1616 /* Prevent vasishing of quest levels and town */
1617 if ((p_ptr->inside_quest && is_fixed_quest_idx(p_ptr->inside_quest)) || !dun_level)
1622 /* Scan all normal grids */
1623 for (y = 1; y < cur_hgt - 1; y++)
1625 for (x = 1; x < cur_wid - 1; x++)
1627 c_ptr = &cave[y][x];
1629 /* Seeing true feature code (ignore mimic) */
1630 f_ptr = &f_info[c_ptr->feat];
1632 /* Lose room and vault */
1633 c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1635 m_ptr = &m_list[c_ptr->m_idx];
1638 if (c_ptr->m_idx && MON_CSLEEP(m_ptr))
1640 /* Reset sleep counter */
1641 (void)set_monster_csleep(c_ptr->m_idx, 0);
1643 /* Notice the "waking up" */
1646 /* Acquire the monster name */
1647 monster_desc(m_name, m_ptr, 0);
1649 /* Dump a message */
1651 msg_format("%^s¤¬Ìܤò³Ð¤Þ¤·¤¿¡£", m_name);
1653 msg_format("%^s wakes up.", m_name);
1658 /* Process all walls, doors and patterns */
1659 if (have_flag(f_ptr->flags, FF_HURT_DISI)) cave_alter_feat(y, x, FF_HURT_DISI);
1663 /* Special boundary walls -- Top and bottom */
1664 for (x = 0; x < cur_wid; x++)
1666 c_ptr = &cave[0][x];
1667 f_ptr = &f_info[c_ptr->mimic];
1669 /* Lose room and vault */
1670 c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1672 /* Set boundary mimic if needed */
1673 if (c_ptr->mimic && have_flag(f_ptr->flags, FF_HURT_DISI))
1675 c_ptr->mimic = feat_state(c_ptr->mimic, FF_HURT_DISI);
1677 /* Check for change to boring grid */
1678 if (!have_flag(f_info[c_ptr->mimic].flags, FF_REMEMBER)) c_ptr->info &= ~(CAVE_MARK);
1681 c_ptr = &cave[cur_hgt - 1][x];
1682 f_ptr = &f_info[c_ptr->mimic];
1684 /* Lose room and vault */
1685 c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1687 /* Set boundary mimic if needed */
1688 if (c_ptr->mimic && have_flag(f_ptr->flags, FF_HURT_DISI))
1690 c_ptr->mimic = feat_state(c_ptr->mimic, FF_HURT_DISI);
1692 /* Check for change to boring grid */
1693 if (!have_flag(f_info[c_ptr->mimic].flags, FF_REMEMBER)) c_ptr->info &= ~(CAVE_MARK);
1697 /* Special boundary walls -- Left and right */
1698 for (y = 1; y < (cur_hgt - 1); y++)
1700 c_ptr = &cave[y][0];
1701 f_ptr = &f_info[c_ptr->mimic];
1703 /* Lose room and vault */
1704 c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1706 /* Set boundary mimic if needed */
1707 if (c_ptr->mimic && have_flag(f_ptr->flags, FF_HURT_DISI))
1709 c_ptr->mimic = feat_state(c_ptr->mimic, FF_HURT_DISI);
1711 /* Check for change to boring grid */
1712 if (!have_flag(f_info[c_ptr->mimic].flags, FF_REMEMBER)) c_ptr->info &= ~(CAVE_MARK);
1715 c_ptr = &cave[y][cur_wid - 1];
1716 f_ptr = &f_info[c_ptr->mimic];
1718 /* Lose room and vault */
1719 c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1721 /* Set boundary mimic if needed */
1722 if (c_ptr->mimic && have_flag(f_ptr->flags, FF_HURT_DISI))
1724 c_ptr->mimic = feat_state(c_ptr->mimic, FF_HURT_DISI);
1726 /* Check for change to boring grid */
1727 if (!have_flag(f_info[c_ptr->mimic].flags, FF_REMEMBER)) c_ptr->info &= ~(CAVE_MARK);
1731 /* Mega-Hack -- Forget the view and lite */
1732 p_ptr->update |= (PU_UN_VIEW | PU_UN_LITE);
1735 p_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MON_LITE);
1737 /* Update the monsters */
1738 p_ptr->update |= (PU_MONSTERS);
1741 p_ptr->redraw |= (PR_MAP);
1744 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
1750 void call_the_(void)
1754 bool do_call = TRUE;
1756 for (i = 0; i < 9; i++)
1758 c_ptr = &cave[py + ddy_ddd[i]][px + ddx_ddd[i]];
1760 if (!cave_have_flag_grid(c_ptr, FF_PROJECT))
1762 if (!c_ptr->mimic || !have_flag(f_info[c_ptr->mimic].flags, FF_PROJECT) ||
1763 !permanent_wall(&f_info[c_ptr->feat]))
1773 for (i = 1; i < 10; i++)
1775 if (i - 5) fire_ball(GF_ROCKET, i, 175, 2);
1778 for (i = 1; i < 10; i++)
1780 if (i - 5) fire_ball(GF_MANA, i, 175, 3);
1783 for (i = 1; i < 10; i++)
1785 if (i - 5) fire_ball(GF_NUKE, i, 175, 4);
1789 /* Prevent destruction of quest levels and town */
1790 else if ((p_ptr->inside_quest && is_fixed_quest_idx(p_ptr->inside_quest)) || !dun_level)
1793 msg_print("ÃÏÌ̤¬Íɤ줿¡£");
1795 msg_print("The ground trembles.");
1802 msg_format("¤¢¤Ê¤¿¤Ï%s¤òÊɤ˶᤹¤®¤ë¾ì½ê¤Ç¾§¤¨¤Æ¤·¤Þ¤Ã¤¿¡ª",
1803 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "µ§¤ê" : "¼öʸ"));
1804 msg_print("Â礤ÊÇúȯ²»¤¬¤¢¤Ã¤¿¡ª");
1806 msg_format("You %s the %s too close to a wall!",
1807 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "recite" : "cast"),
1808 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "prayer" : "spell"));
1809 msg_print("There is a loud explosion!");
1815 if (!vanish_dungeon()) msg_print("¥À¥ó¥¸¥ç¥ó¤Ï°ì½ÖÀŤޤêÊ֤ä¿¡£");
1817 if (!vanish_dungeon()) msg_print("The dungeon silences a moment.");
1822 if (destroy_area(py, px, 15 + p_ptr->lev + randint0(11), FALSE))
1824 msg_print("¥À¥ó¥¸¥ç¥ó¤¬Êø²õ¤·¤¿...");
1826 msg_print("The dungeon collapses...");
1831 msg_print("¥À¥ó¥¸¥ç¥ó¤ÏÂ礤¯Íɤ줿¡£");
1833 msg_print("The dungeon trembles.");
1838 take_hit(DAMAGE_NOESCAPE, 100 + randint1(150), "¼«»¦Åª¤Êµõ̵¾·Íè", -1);
1840 take_hit(DAMAGE_NOESCAPE, 100 + randint1(150), "a suicidal Call the Void", -1);
1847 * Fetch an item (teleport it right underneath the caster)
1849 void fetch(int dir, int wgt, bool require_los)
1854 char o_name[MAX_NLEN];
1856 /* Check to see if an object is already there */
1857 if (cave[py][px].o_idx)
1860 msg_print("¼«Ê¬¤Î¤β¼¤Ë¤¢¤ëʪ¤Ï¼è¤ì¤Þ¤»¤ó¡£");
1862 msg_print("You can't fetch when you're already standing on something.");
1869 if (dir == 5 && target_okay())
1874 if (distance(py, px, ty, tx) > MAX_RANGE)
1877 msg_print("¤½¤ó¤Ê¤Ë±ó¤¯¤Ë¤¢¤ëʪ¤Ï¼è¤ì¤Þ¤»¤ó¡ª");
1879 msg_print("You can't fetch something that far away!");
1885 c_ptr = &cave[ty][tx];
1887 /* We need an item to fetch */
1891 msg_print("¤½¤³¤Ë¤Ï²¿¤â¤¢¤ê¤Þ¤»¤ó¡£");
1893 msg_print("There is no object at this place.");
1899 /* No fetching from vault */
1900 if (c_ptr->info & CAVE_ICKY)
1903 msg_print("¥¢¥¤¥Æ¥à¤¬¥³¥ó¥È¥í¡¼¥ë¤ò³°¤ì¤ÆÍî¤Á¤¿¡£");
1905 msg_print("The item slips from your control.");
1911 /* We need to see the item */
1914 if (!player_has_los_bold(ty, tx))
1917 msg_print("¤½¤³¤Ï¤¢¤Ê¤¿¤Î»ë³¦¤ËÆþ¤Ã¤Æ¤¤¤Þ¤»¤ó¡£");
1919 msg_print("You have no direct line of sight to that location.");
1924 else if (!projectable(py, px, ty, tx))
1927 msg_print("¤½¤³¤ÏÊɤθþ¤³¤¦¤Ç¤¹¡£");
1929 msg_print("You have no direct line of sight to that location.");
1938 /* Use a direction */
1939 ty = py; /* Where to drop the item */
1946 c_ptr = &cave[ty][tx];
1948 if ((distance(py, px, ty, tx) > MAX_RANGE) ||
1949 !cave_have_flag_bold(ty, tx, FF_PROJECT)) return;
1951 while (!c_ptr->o_idx);
1954 o_ptr = &o_list[c_ptr->o_idx];
1956 if (o_ptr->weight > wgt)
1958 /* Too heavy to 'fetch' */
1960 msg_print("¤½¤Î¥¢¥¤¥Æ¥à¤Ï½Å²á¤®¤Þ¤¹¡£");
1962 msg_print("The object is too heavy.");
1969 c_ptr->o_idx = o_ptr->next_o_idx;
1970 cave[py][px].o_idx = i; /* 'move' it */
1971 o_ptr->next_o_idx = 0;
1972 o_ptr->iy = (byte)py;
1973 o_ptr->ix = (byte)px;
1975 object_desc(o_name, o_ptr, OD_NAME_ONLY);
1977 msg_format("%^s¤¬¤¢¤Ê¤¿¤Î¸µ¤ËÈô¤ó¤Ç¤¤¿¡£", o_name);
1979 msg_format("%^s flies through the air to your feet.", o_name);
1984 p_ptr->redraw |= PR_MAP;
1988 void alter_reality(void)
1990 /* Ironman option */
1991 if (p_ptr->inside_arena || ironman_downward)
1994 msg_print("²¿¤âµ¯¤³¤é¤Ê¤«¤Ã¤¿¡£");
1996 msg_print("Nothing happens.");
2001 if (!p_ptr->alter_reality)
2003 int turns = randint0(21) + 15;
2005 p_ptr->alter_reality = turns;
2007 msg_print("²ó¤ê¤Î·Ê¿§¤¬ÊѤï¤ê»Ï¤á¤¿...");
2009 msg_print("The view around you begins to change...");
2012 p_ptr->redraw |= (PR_STATUS);
2016 p_ptr->alter_reality = 0;
2018 msg_print("·Ê¿§¤¬¸µ¤ËÌá¤Ã¤¿...");
2020 msg_print("The view around you got back...");
2023 p_ptr->redraw |= (PR_STATUS);
2030 * Leave a "glyph of warding" which prevents monster movement
2032 bool warding_glyph(void)
2035 if (!cave_clean_bold(py, px))
2038 msg_print("¾²¾å¤Î¥¢¥¤¥Æ¥à¤¬¼öʸ¤òÄ·¤ÍÊÖ¤·¤¿¡£");
2040 msg_print("The object resists the spell.");
2046 /* Create a glyph */
2047 cave[py][px].info |= CAVE_OBJECT;
2048 cave[py][px].mimic = feat_glyph;
2059 bool place_mirror(void)
2062 if (!cave_clean_bold(py, px))
2065 msg_print("¾²¾å¤Î¥¢¥¤¥Æ¥à¤¬¼öʸ¤òÄ·¤ÍÊÖ¤·¤¿¡£");
2067 msg_print("The object resists the spell.");
2073 /* Create a mirror */
2074 cave[py][px].info |= CAVE_OBJECT;
2075 cave[py][px].mimic = feat_mirror;
2077 /* Turn on the light */
2078 cave[py][px].info |= CAVE_GLOW;
2086 update_local_illumination(py, px);
2093 * Leave an "explosive rune" which prevents monster movement
2095 bool explosive_rune(void)
2098 if (!cave_clean_bold(py, px))
2101 msg_print("¾²¾å¤Î¥¢¥¤¥Æ¥à¤¬¼öʸ¤òÄ·¤ÍÊÖ¤·¤¿¡£");
2103 msg_print("The object resists the spell.");
2109 /* Create a glyph */
2110 cave[py][px].info |= CAVE_OBJECT;
2111 cave[py][px].mimic = feat_explosive_rune;
2124 * Identify everything being carried.
2125 * Done by a potion of "self knowledge".
2127 void identify_pack(void)
2131 /* Simply identify and know every item */
2132 for (i = 0; i < INVEN_TOTAL; i++)
2134 object_type *o_ptr = &inventory[i];
2136 /* Skip non-objects */
2137 if (!o_ptr->k_idx) continue;
2140 identify_item(o_ptr);
2142 /* Auto-inscription */
2143 autopick_alter_item(i, FALSE);
2149 * Used by the "enchant" function (chance of failure)
2150 * (modified for Zangband, we need better stuff there...) -- TY
2152 static int enchant_table[16] =
2154 0, 10, 50, 100, 200,
2155 300, 400, 500, 650, 800,
2156 950, 987, 993, 995, 998,
2162 * Removes curses from items in inventory
2164 * Note that Items which are "Perma-Cursed" (The One Ring,
2165 * The Crown of Morgoth) can NEVER be uncursed.
2167 * Note that if "all" is FALSE, then Items which are
2168 * "Heavy-Cursed" (Mormegil, Calris, and Weapons of Morgul)
2169 * will not be uncursed.
2171 static int remove_curse_aux(int all)
2175 /* Attempt to uncurse items being worn */
2176 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
2178 object_type *o_ptr = &inventory[i];
2180 /* Skip non-objects */
2181 if (!o_ptr->k_idx) continue;
2183 /* Uncursed already */
2184 if (!object_is_cursed(o_ptr)) continue;
2186 /* Heavily Cursed Items need a special spell */
2187 if (!all && (o_ptr->curse_flags & TRC_HEAVY_CURSE)) continue;
2189 /* Perma-Cursed Items can NEVER be uncursed */
2190 if (o_ptr->curse_flags & TRC_PERMA_CURSE)
2193 o_ptr->curse_flags &= (TRC_CURSED | TRC_HEAVY_CURSE | TRC_PERMA_CURSE);
2198 o_ptr->curse_flags = 0L;
2200 /* Hack -- Assume felt */
2201 o_ptr->ident |= (IDENT_SENSE);
2204 o_ptr->feeling = FEEL_NONE;
2206 /* Recalculate the bonuses */
2207 p_ptr->update |= (PU_BONUS);
2210 p_ptr->window |= (PW_EQUIP);
2212 /* Count the uncursings */
2216 /* Return "something uncursed" */
2222 * Remove most curses
2224 bool remove_curse(void)
2226 return (remove_curse_aux(FALSE));
2232 bool remove_all_curse(void)
2234 return (remove_curse_aux(TRUE));
2239 * Turns an object into gold, gain some of its value in a shop
2248 char o_name[MAX_NLEN];
2249 char out_val[MAX_NLEN+40];
2253 /* Hack -- force destruction */
2254 if (command_arg > 0) force = TRUE;
2258 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò¶â¤ËÊѤ¨¤Þ¤¹¤«¡©";
2259 s = "¶â¤ËÊѤ¨¤é¤ì¤ëʪ¤¬¤¢¤ê¤Þ¤»¤ó¡£";
2261 q = "Turn which item to gold? ";
2262 s = "You have nothing to turn to gold.";
2265 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return (FALSE);
2267 /* Get the item (in the pack) */
2270 o_ptr = &inventory[item];
2273 /* Get the item (on the floor) */
2276 o_ptr = &o_list[0 - item];
2280 /* See how many items */
2281 if (o_ptr->number > 1)
2283 /* Get a quantity */
2284 amt = get_quantity(NULL, o_ptr->number);
2286 /* Allow user abort */
2287 if (amt <= 0) return FALSE;
2291 /* Describe the object */
2292 old_number = o_ptr->number;
2293 o_ptr->number = amt;
2294 object_desc(o_name, o_ptr, 0);
2295 o_ptr->number = old_number;
2297 /* Verify unless quantity given */
2300 if (confirm_destroy || (object_value(o_ptr) > 0))
2302 /* Make a verification */
2304 sprintf(out_val, "ËÜÅö¤Ë%s¤ò¶â¤ËÊѤ¨¤Þ¤¹¤«¡©", o_name);
2306 sprintf(out_val, "Really turn %s to gold? ", o_name);
2309 if (!get_check(out_val)) return FALSE;
2313 /* Artifacts cannot be destroyed */
2314 if (!can_player_destroy_object(o_ptr))
2318 msg_format("%s¤ò¶â¤ËÊѤ¨¤ë¤³¤È¤Ë¼ºÇÔ¤·¤¿¡£", o_name);
2320 msg_format("You fail to turn %s to gold!", o_name);
2327 price = object_value_real(o_ptr);
2333 msg_format("%s¤ò¥Ë¥»¤Î¶â¤ËÊѤ¨¤¿¡£", o_name);
2335 msg_format("You turn %s to fool's gold.", o_name);
2343 if (amt > 1) price *= amt;
2345 if (price > 30000) price = 30000;
2347 msg_format("%s¤ò¡ð%d ¤Î¶â¤ËÊѤ¨¤¿¡£", o_name, price);
2349 msg_format("You turn %s to %ld coins worth of gold.", o_name, price);
2355 p_ptr->redraw |= (PR_GOLD);
2358 p_ptr->window |= (PW_PLAYER);
2362 /* Eliminate the item (from the pack) */
2365 inven_item_increase(item, -amt);
2366 inven_item_describe(item);
2367 inven_item_optimize(item);
2370 /* Eliminate the item (from the floor) */
2373 floor_item_increase(0 - item, -amt);
2374 floor_item_describe(0 - item);
2375 floor_item_optimize(0 - item);
2383 * Break the curse of an item
2385 static void break_curse(object_type *o_ptr)
2387 if (object_is_cursed(o_ptr) && !(o_ptr->curse_flags & TRC_PERMA_CURSE) && !(o_ptr->curse_flags & TRC_HEAVY_CURSE) && (randint0(100) < 25))
2390 msg_print("¤«¤±¤é¤ì¤Æ¤¤¤¿¼ö¤¤¤¬ÂǤÁÇˤé¤ì¤¿¡ª");
2392 msg_print("The curse is broken!");
2395 o_ptr->curse_flags = 0L;
2397 o_ptr->ident |= (IDENT_SENSE);
2399 o_ptr->feeling = FEEL_NONE;
2405 * Enchants a plus onto an item. -RAK-
2407 * Revamped! Now takes item pointer, number of times to try enchanting,
2408 * and a flag of what to try enchanting. Artifacts resist enchantment
2409 * some of the time, and successful enchantment to at least +0 might
2410 * break a curse on the item. -CFT-
2412 * Note that an item can technically be enchanted all the way to +15 if
2413 * you wait a very, very, long time. Going from +9 to +10 only works
2414 * about 5% of the time, and from +10 to +11 only about 1% of the time.
2416 * Note that this function can now be used on "piles" of items, and
2417 * the larger the pile, the lower the chance of success.
2419 bool enchant(object_type *o_ptr, int n, int eflag)
2421 int i, chance, prob;
2423 bool a = object_is_artifact(o_ptr);
2424 bool force = (eflag & ENCH_FORCE);
2427 /* Large piles resist enchantment */
2428 prob = o_ptr->number * 100;
2430 /* Missiles are easy to enchant */
2431 if ((o_ptr->tval == TV_BOLT) ||
2432 (o_ptr->tval == TV_ARROW) ||
2433 (o_ptr->tval == TV_SHOT))
2439 for (i = 0; i < n; i++)
2441 /* Hack -- Roll for pile resistance */
2442 if (!force && randint0(prob) >= 100) continue;
2444 /* Enchant to hit */
2445 if (eflag & ENCH_TOHIT)
2447 if (o_ptr->to_h < 0) chance = 0;
2448 else if (o_ptr->to_h > 15) chance = 1000;
2449 else chance = enchant_table[o_ptr->to_h];
2451 if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50))))
2456 /* only when you get it above -1 -CFT */
2457 if (o_ptr->to_h >= 0)
2462 /* Enchant to damage */
2463 if (eflag & ENCH_TODAM)
2465 if (o_ptr->to_d < 0) chance = 0;
2466 else if (o_ptr->to_d > 15) chance = 1000;
2467 else chance = enchant_table[o_ptr->to_d];
2469 if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50))))
2474 /* only when you get it above -1 -CFT */
2475 if (o_ptr->to_d >= 0)
2480 /* Enchant to armor class */
2481 if (eflag & ENCH_TOAC)
2483 if (o_ptr->to_a < 0) chance = 0;
2484 else if (o_ptr->to_a > 15) chance = 1000;
2485 else chance = enchant_table[o_ptr->to_a];
2487 if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50))))
2492 /* only when you get it above -1 -CFT */
2493 if (o_ptr->to_a >= 0)
2500 if (!res) return (FALSE);
2502 /* Recalculate bonuses */
2503 p_ptr->update |= (PU_BONUS);
2505 /* Combine / Reorder the pack (later) */
2506 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
2509 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
2520 * Enchant an item (in the inventory or on the floor)
2521 * Note that "num_ac" requires armour, else weapon
2522 * Returns TRUE if attempted, FALSE if cancelled
2524 bool enchant_spell(int num_hit, int num_dam, int num_ac)
2529 char o_name[MAX_NLEN];
2533 /* Assume enchant weapon */
2534 item_tester_hook = object_allow_enchant_weapon;
2535 item_tester_no_ryoute = TRUE;
2537 /* Enchant armor if requested */
2538 if (num_ac) item_tester_hook = object_is_armour;
2542 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò¶¯²½¤·¤Þ¤¹¤«? ";
2543 s = "¶¯²½¤Ç¤¤ë¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
2545 q = "Enchant which item? ";
2546 s = "You have nothing to enchant.";
2549 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2551 /* Get the item (in the pack) */
2554 o_ptr = &inventory[item];
2557 /* Get the item (on the floor) */
2560 o_ptr = &o_list[0 - item];
2565 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2569 msg_format("%s ¤ÏÌÀ¤ë¤¯µ±¤¤¤¿¡ª",
2572 msg_format("%s %s glow%s brightly!",
2573 ((item >= 0) ? "Your" : "The"), o_name,
2574 ((o_ptr->number > 1) ? "" : "s"));
2579 if (enchant(o_ptr, num_hit, ENCH_TOHIT)) okay = TRUE;
2580 if (enchant(o_ptr, num_dam, ENCH_TODAM)) okay = TRUE;
2581 if (enchant(o_ptr, num_ac, ENCH_TOAC)) okay = TRUE;
2587 if (flush_failure) flush();
2591 msg_print("¶¯²½¤Ë¼ºÇÔ¤·¤¿¡£");
2593 msg_print("The enchantment failed.");
2596 if (one_in_(3)) chg_virtue(V_ENCHANT, -1);
2599 chg_virtue(V_ENCHANT, 1);
2603 /* Something happened */
2609 * Check if an object is nameless weapon or armour
2611 static bool item_tester_hook_nameless_weapon_armour(object_type *o_ptr)
2613 /* Require weapon or armour */
2614 if (!object_is_weapon_armour_ammo(o_ptr)) return FALSE;
2616 /* Require nameless object if the object is well known */
2617 if (object_is_known(o_ptr) && !object_is_nameless(o_ptr))
2624 bool artifact_scroll(void)
2629 char o_name[MAX_NLEN];
2633 item_tester_no_ryoute = TRUE;
2635 /* Enchant weapon/armour */
2636 item_tester_hook = item_tester_hook_nameless_weapon_armour;
2640 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò¶¯²½¤·¤Þ¤¹¤«? ";
2641 s = "¶¯²½¤Ç¤¤ë¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
2643 q = "Enchant which item? ";
2644 s = "You have nothing to enchant.";
2647 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2649 /* Get the item (in the pack) */
2652 o_ptr = &inventory[item];
2655 /* Get the item (on the floor) */
2658 o_ptr = &o_list[0 - item];
2663 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
2667 msg_format("%s ¤ÏâÁ¤¤¸÷¤òȯ¤·¤¿¡ª",o_name);
2669 msg_format("%s %s radiate%s a blinding light!",
2670 ((item >= 0) ? "Your" : "The"), o_name,
2671 ((o_ptr->number > 1) ? "" : "s"));
2674 if (object_is_artifact(o_ptr))
2677 msg_format("%s¤Ï´û¤ËÅÁÀâ¤Î¥¢¥¤¥Æ¥à¤Ç¤¹¡ª", o_name );
2679 msg_format("The %s %s already %s!",
2680 o_name, ((o_ptr->number > 1) ? "are" : "is"),
2681 ((o_ptr->number > 1) ? "artifacts" : "an artifact"));
2687 else if (object_is_ego(o_ptr))
2690 msg_format("%s¤Ï´û¤Ë̾¤Î¤¢¤ë¥¢¥¤¥Æ¥à¤Ç¤¹¡ª", o_name );
2692 msg_format("The %s %s already %s!",
2693 o_name, ((o_ptr->number > 1) ? "are" : "is"),
2694 ((o_ptr->number > 1) ? "ego items" : "an ego item"));
2700 else if (o_ptr->xtra3)
2703 msg_format("%s¤Ï´û¤Ë¶¯²½¤µ¤ì¤Æ¤¤¤Þ¤¹¡ª", o_name );
2705 msg_format("The %s %s already %s!",
2706 o_name, ((o_ptr->number > 1) ? "are" : "is"),
2707 ((o_ptr->number > 1) ? "customized items" : "a customized item"));
2713 if (o_ptr->number > 1)
2716 msg_print("Ê£¿ô¤Î¥¢¥¤¥Æ¥à¤ËËâË¡¤ò¤«¤±¤ë¤À¤±¤Î¥¨¥Í¥ë¥®¡¼¤Ï¤¢¤ê¤Þ¤»¤ó¡ª");
2717 msg_format("%d ¸Ä¤Î%s¤¬²õ¤ì¤¿¡ª",(o_ptr->number)-1, o_name);
2719 msg_print("Not enough enough energy to enchant more than one object!");
2720 msg_format("%d of your %s %s destroyed!",(o_ptr->number)-1, o_name, (o_ptr->number>2?"were":"was"));
2725 inven_item_increase(item, 1-(o_ptr->number));
2729 floor_item_increase(0-item, 1-(o_ptr->number));
2732 okay = create_artifact(o_ptr, TRUE);
2739 if (flush_failure) flush();
2743 msg_print("¶¯²½¤Ë¼ºÇÔ¤·¤¿¡£");
2745 msg_print("The enchantment failed.");
2748 if (one_in_(3)) chg_virtue(V_ENCHANT, -1);
2751 chg_virtue(V_ENCHANT, 1);
2755 /* Something happened */
2761 * Identify an object
2763 bool identify_item(object_type *o_ptr)
2765 bool old_known = FALSE;
2766 char o_name[MAX_NLEN];
2769 object_desc(o_name, o_ptr, 0);
2771 if (o_ptr->ident & IDENT_KNOWN)
2774 if (!(o_ptr->ident & (IDENT_MENTAL)))
2776 if (object_is_artifact(o_ptr) || one_in_(5))
2777 chg_virtue(V_KNOWLEDGE, 1);
2780 /* Identify it fully */
2781 object_aware(o_ptr);
2782 object_known(o_ptr);
2784 /* Player touches it */
2785 o_ptr->marked |= OM_TOUCHED;
2787 /* Recalculate bonuses */
2788 p_ptr->update |= (PU_BONUS);
2790 /* Combine / Reorder the pack (later) */
2791 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
2794 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
2796 strcpy(record_o_name, o_name);
2800 object_desc(o_name, o_ptr, OD_NAME_ONLY);
2802 if(record_fix_art && !old_known && object_is_fixed_artifact(o_ptr))
2803 do_cmd_write_nikki(NIKKI_ART, 0, o_name);
2804 if(record_rand_art && !old_known && o_ptr->art_name)
2805 do_cmd_write_nikki(NIKKI_ART, 0, o_name);
2811 static bool item_tester_hook_identify(object_type *o_ptr)
2813 return (bool)!object_is_known(o_ptr);
2816 static bool item_tester_hook_identify_weapon_armour(object_type *o_ptr)
2818 if (object_is_known(o_ptr))
2820 return object_is_weapon_armour_ammo(o_ptr);
2824 * Identify an object in the inventory (or on the floor)
2825 * This routine does *not* automatically combine objects.
2826 * Returns TRUE if something was identified, else FALSE.
2828 bool ident_spell(bool only_equip)
2832 char o_name[MAX_NLEN];
2836 item_tester_no_ryoute = TRUE;
2839 item_tester_hook = item_tester_hook_identify_weapon_armour;
2841 item_tester_hook = item_tester_hook_identify;
2846 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò´ÕÄꤷ¤Þ¤¹¤«? ";
2848 q = "Identify which item? ";
2854 item_tester_hook = object_is_weapon_armour_ammo;
2856 item_tester_hook = NULL;
2859 q = "¤¹¤Ù¤Æ´ÕÄêºÑ¤ß¤Ç¤¹¡£ ";
2861 q = "All items are identified. ";
2867 s = "´ÕÄꤹ¤ë¤Ù¤¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
2869 s = "You have nothing to identify.";
2872 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2874 /* Get the item (in the pack) */
2877 o_ptr = &inventory[item];
2880 /* Get the item (on the floor) */
2883 o_ptr = &o_list[0 - item];
2887 old_known = identify_item(o_ptr);
2890 object_desc(o_name, o_ptr, 0);
2893 if (item >= INVEN_RARM)
2896 msg_format("%^s: %s(%c)¡£", describe_use(item), o_name, index_to_label(item));
2898 msg_format("%^s: %s (%c).", describe_use(item), o_name, index_to_label(item));
2904 msg_format("¥¶¥Ã¥¯Ãæ: %s(%c)¡£", o_name, index_to_label(item));
2906 msg_format("In your pack: %s (%c).", o_name, index_to_label(item));
2912 msg_format("¾²¾å: %s¡£", o_name);
2914 msg_format("On the ground: %s.", o_name);
2918 /* Auto-inscription/destroy */
2919 autopick_alter_item(item, (bool)(destroy_identify && !old_known));
2921 /* Something happened */
2927 * Mundanify an object in the inventory (or on the floor)
2928 * This routine does *not* automatically combine objects.
2929 * Returns TRUE if something was mundanified, else FALSE.
2931 bool mundane_spell(bool only_equip)
2937 if (only_equip) item_tester_hook = object_is_weapon_armour_ammo;
2938 item_tester_no_ryoute = TRUE;
2942 q = "¤É¤ì¤ò»È¤¤¤Þ¤¹¤«¡©";
2943 s = "»È¤¨¤ë¤â¤Î¤¬¤¢¤ê¤Þ¤»¤ó¡£";
2945 q = "Use which item? ";
2946 s = "You have nothing you can use.";
2949 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2951 /* Get the item (in the pack) */
2954 o_ptr = &inventory[item];
2957 /* Get the item (on the floor) */
2960 o_ptr = &o_list[0 - item];
2965 msg_print("¤Þ¤Ð¤æ¤¤Á®¸÷¤¬Áö¤Ã¤¿¡ª");
2967 msg_print("There is a bright flash of light!");
2970 byte iy = o_ptr->iy; /* Y-position on map, or zero */
2971 byte ix = o_ptr->ix; /* X-position on map, or zero */
2972 s16b next_o_idx = o_ptr->next_o_idx; /* Next object in stack (if any) */
2973 byte marked = o_ptr->marked; /* Object is marked */
2974 s16b weight = o_ptr->number * o_ptr->weight;
2975 u16b inscription = o_ptr->inscription;
2978 object_prep(o_ptr, o_ptr->k_idx);
2982 o_ptr->next_o_idx = next_o_idx;
2983 o_ptr->marked = marked;
2984 o_ptr->inscription = inscription;
2985 if (item >= 0) p_ptr->total_weight += (o_ptr->weight - weight);
2989 /* Something happened */
2995 static bool item_tester_hook_identify_fully(object_type *o_ptr)
2997 return (bool)(!object_is_known(o_ptr) || !(o_ptr->ident & IDENT_MENTAL));
3000 static bool item_tester_hook_identify_fully_weapon_armour(object_type *o_ptr)
3002 if (!item_tester_hook_identify_fully(o_ptr))
3004 return object_is_weapon_armour_ammo(o_ptr);
3008 * Fully "identify" an object in the inventory -BEN-
3009 * This routine returns TRUE if an item was identified.
3011 bool identify_fully(bool only_equip)
3015 char o_name[MAX_NLEN];
3019 item_tester_no_ryoute = TRUE;
3021 item_tester_hook = item_tester_hook_identify_fully_weapon_armour;
3023 item_tester_hook = item_tester_hook_identify_fully;
3028 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò*´ÕÄê*¤·¤Þ¤¹¤«? ";
3030 q = "*Identify* which item? ";
3036 item_tester_hook = object_is_weapon_armour_ammo;
3038 item_tester_hook = NULL;
3041 q = "¤¹¤Ù¤Æ*´ÕÄê*ºÑ¤ß¤Ç¤¹¡£ ";
3043 q = "All items are *identified*. ";
3049 s = "*´ÕÄê*¤¹¤ë¤Ù¤¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
3051 s = "You have nothing to *identify*.";
3054 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
3056 /* Get the item (in the pack) */
3059 o_ptr = &inventory[item];
3062 /* Get the item (on the floor) */
3065 o_ptr = &o_list[0 - item];
3069 old_known = identify_item(o_ptr);
3071 /* Mark the item as fully known */
3072 o_ptr->ident |= (IDENT_MENTAL);
3078 object_desc(o_name, o_ptr, 0);
3081 if (item >= INVEN_RARM)
3084 msg_format("%^s: %s(%c)¡£", describe_use(item), o_name, index_to_label(item));
3086 msg_format("%^s: %s (%c).", describe_use(item), o_name, index_to_label(item));
3094 msg_format("¥¶¥Ã¥¯Ãæ: %s(%c)¡£", o_name, index_to_label(item));
3096 msg_format("In your pack: %s (%c).", o_name, index_to_label(item));
3102 msg_format("¾²¾å: %s¡£", o_name);
3104 msg_format("On the ground: %s.", o_name);
3108 /* Describe it fully */
3109 (void)screen_object(o_ptr, 0L);
3111 /* Auto-inscription/destroy */
3112 autopick_alter_item(item, (bool)(destroy_identify && !old_known));
3122 * Hook for "get_item()". Determine if something is rechargable.
3124 bool item_tester_hook_recharge(object_type *o_ptr)
3126 /* Recharge staffs */
3127 if (o_ptr->tval == TV_STAFF) return (TRUE);
3129 /* Recharge wands */
3130 if (o_ptr->tval == TV_WAND) return (TRUE);
3132 /* Hack -- Recharge rods */
3133 if (o_ptr->tval == TV_ROD) return (TRUE);
3141 * Recharge a wand/staff/rod from the pack or on the floor.
3142 * This function has been rewritten in Oangband and ZAngband.
3144 * Sorcery/Arcane -- Recharge --> recharge(plev * 4)
3145 * Chaos -- Arcane Binding --> recharge(90)
3147 * Scroll of recharging --> recharge(130)
3148 * Artifact activation/Thingol --> recharge(130)
3150 * It is harder to recharge high level, and highly charged wands,
3151 * staffs, and rods. The more wands in a stack, the more easily and
3152 * strongly they recharge. Staffs, however, each get fewer charges if
3155 * XXX XXX XXX Beware of "sliding index errors".
3157 bool recharge(int power)
3160 int recharge_strength, recharge_amount;
3169 char o_name[MAX_NLEN];
3171 /* Only accept legal items */
3172 item_tester_hook = item_tester_hook_recharge;
3176 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ËËâÎϤò½¼Å¶¤·¤Þ¤¹¤«? ";
3177 s = "ËâÎϤò½¼Å¶¤¹¤Ù¤¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
3179 q = "Recharge which item? ";
3180 s = "You have nothing to recharge.";
3183 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return (FALSE);
3185 /* Get the item (in the pack) */
3188 o_ptr = &inventory[item];
3191 /* Get the item (on the floor) */
3194 o_ptr = &o_list[0 - item];
3197 /* Get the object kind. */
3198 k_ptr = &k_info[o_ptr->k_idx];
3200 /* Extract the object "level" */
3201 lev = k_info[o_ptr->k_idx].level;
3204 /* Recharge a rod */
3205 if (o_ptr->tval == TV_ROD)
3207 /* Extract a recharge strength by comparing object level to power. */
3208 recharge_strength = ((power > lev/2) ? (power - lev/2) : 0) / 5;
3212 if (one_in_(recharge_strength))
3214 /* Activate the failure code. */
3221 /* Recharge amount */
3222 recharge_amount = (power * damroll(3, 2));
3224 /* Recharge by that amount */
3225 if (o_ptr->timeout > recharge_amount)
3226 o_ptr->timeout -= recharge_amount;
3233 /* Recharge wand/staff */
3236 /* Extract a recharge strength by comparing object level to power.
3237 * Divide up a stack of wands' charges to calculate charge penalty.
3239 if ((o_ptr->tval == TV_WAND) && (o_ptr->number > 1))
3240 recharge_strength = (100 + power - lev -
3241 (8 * o_ptr->pval / o_ptr->number)) / 15;
3243 /* All staffs, unstacked wands. */
3244 else recharge_strength = (100 + power - lev -
3245 (8 * o_ptr->pval)) / 15;
3248 if (recharge_strength < 0) recharge_strength = 0;
3251 if (one_in_(recharge_strength))
3253 /* Activate the failure code. */
3257 /* If the spell didn't backfire, recharge the wand or staff. */
3260 /* Recharge based on the standard number of charges. */
3261 recharge_amount = randint1(1 + k_ptr->pval / 2);
3263 /* Multiple wands in a stack increase recharging somewhat. */
3264 if ((o_ptr->tval == TV_WAND) && (o_ptr->number > 1))
3267 (randint1(recharge_amount * (o_ptr->number - 1))) / 2;
3268 if (recharge_amount < 1) recharge_amount = 1;
3269 if (recharge_amount > 12) recharge_amount = 12;
3272 /* But each staff in a stack gets fewer additional charges,
3273 * although always at least one.
3275 if ((o_ptr->tval == TV_STAFF) && (o_ptr->number > 1))
3277 recharge_amount /= o_ptr->number;
3278 if (recharge_amount < 1) recharge_amount = 1;
3281 /* Recharge the wand or staff. */
3282 o_ptr->pval += recharge_amount;
3285 /* Hack -- we no longer "know" the item */
3286 o_ptr->ident &= ~(IDENT_KNOWN);
3288 /* Hack -- we no longer think the item is empty */
3289 o_ptr->ident &= ~(IDENT_EMPTY);
3294 /* Inflict the penalties for failing a recharge. */
3297 /* Artifacts are never destroyed. */
3298 if (object_is_fixed_artifact(o_ptr))
3300 object_desc(o_name, o_ptr, OD_NAME_ONLY);
3302 msg_format("ËâÎϤ¬µÕή¤·¤¿¡ª%s¤Ï´°Á´¤ËËâÎϤò¼º¤Ã¤¿¡£", o_name);
3304 msg_format("The recharging backfires - %s is completely drained!", o_name);
3308 /* Artifact rods. */
3309 if ((o_ptr->tval == TV_ROD) && (o_ptr->timeout < 10000))
3310 o_ptr->timeout = (o_ptr->timeout + 100) * 2;
3312 /* Artifact wands and staffs. */
3313 else if ((o_ptr->tval == TV_WAND) || (o_ptr->tval == TV_STAFF))
3318 /* Get the object description */
3319 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
3321 /*** Determine Seriousness of Failure ***/
3323 /* Mages recharge objects more safely. */
3324 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)
3326 /* 10% chance to blow up one rod, otherwise draining. */
3327 if (o_ptr->tval == TV_ROD)
3329 if (one_in_(10)) fail_type = 2;
3332 /* 75% chance to blow up one wand, otherwise draining. */
3333 else if (o_ptr->tval == TV_WAND)
3335 if (!one_in_(3)) fail_type = 2;
3338 /* 50% chance to blow up one staff, otherwise no effect. */
3339 else if (o_ptr->tval == TV_STAFF)
3341 if (one_in_(2)) fail_type = 2;
3346 /* All other classes get no special favors. */
3349 /* 33% chance to blow up one rod, otherwise draining. */
3350 if (o_ptr->tval == TV_ROD)
3352 if (one_in_(3)) fail_type = 2;
3355 /* 20% chance of the entire stack, else destroy one wand. */
3356 else if (o_ptr->tval == TV_WAND)
3358 if (one_in_(5)) fail_type = 3;
3361 /* Blow up one staff. */
3362 else if (o_ptr->tval == TV_STAFF)
3368 /*** Apply draining and destruction. ***/
3370 /* Drain object or stack of objects. */
3373 if (o_ptr->tval == TV_ROD)
3376 msg_print("ËâÎϤ¬µÕÊ®¼Í¤·¤Æ¡¢¥í¥Ã¥É¤«¤é¤µ¤é¤ËËâÎϤòµÛ¤¤¼è¤Ã¤Æ¤·¤Þ¤Ã¤¿¡ª");
3378 msg_print("The recharge backfires, draining the rod further!");
3381 if (o_ptr->timeout < 10000)
3382 o_ptr->timeout = (o_ptr->timeout + 100) * 2;
3384 else if (o_ptr->tval == TV_WAND)
3387 msg_format("%s¤ÏÇË»¤òÌȤ줿¤¬¡¢ËâÎϤ¬Á´¤Æ¼º¤ï¤ì¤¿¡£", o_name);
3389 msg_format("You save your %s from destruction, but all charges are lost.", o_name);
3394 /* Staffs aren't drained. */
3397 /* Destroy an object or one in a stack of objects. */
3400 if (o_ptr->number > 1)
3402 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬°ìËܲõ¤ì¤¿¡ª", o_name);
3404 msg_format("Wild magic consumes one of your %s!", o_name);
3409 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬²õ¤ì¤¿¡ª", o_name);
3411 msg_format("Wild magic consumes your %s!", o_name);
3415 /* Reduce rod stack maximum timeout, drain wands. */
3416 if (o_ptr->tval == TV_ROD) o_ptr->timeout = (o_ptr->number - 1) * k_ptr->pval;
3417 if (o_ptr->tval == TV_WAND) o_ptr->pval = 0;
3419 /* Reduce and describe inventory */
3422 inven_item_increase(item, -1);
3423 inven_item_describe(item);
3424 inven_item_optimize(item);
3427 /* Reduce and describe floor item */
3430 floor_item_increase(0 - item, -1);
3431 floor_item_describe(0 - item);
3432 floor_item_optimize(0 - item);
3436 /* Destroy all members of a stack of objects. */
3439 if (o_ptr->number > 1)
3441 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬Á´¤Æ²õ¤ì¤¿¡ª", o_name);
3443 msg_format("Wild magic consumes all your %s!", o_name);
3448 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬²õ¤ì¤¿¡ª", o_name);
3450 msg_format("Wild magic consumes your %s!", o_name);
3455 /* Reduce and describe inventory */
3458 inven_item_increase(item, -999);
3459 inven_item_describe(item);
3460 inven_item_optimize(item);
3463 /* Reduce and describe floor item */
3466 floor_item_increase(0 - item, -999);
3467 floor_item_describe(0 - item);
3468 floor_item_optimize(0 - item);
3474 /* Combine / Reorder the pack (later) */
3475 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
3478 p_ptr->window |= (PW_INVEN);
3480 /* Something was done */
3488 bool bless_weapon(void)
3492 u32b flgs[TR_FLAG_SIZE];
3493 char o_name[MAX_NLEN];
3496 item_tester_no_ryoute = TRUE;
3498 /* Bless only weapons */
3499 item_tester_hook = object_is_weapon;
3503 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò½ËÊ¡¤·¤Þ¤¹¤«¡©";
3504 s = "½ËÊ¡¤Ç¤¤ëÉð´ï¤¬¤¢¤ê¤Þ¤»¤ó¡£";
3506 q = "Bless which weapon? ";
3507 s = "You have weapon to bless.";
3510 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR)))
3513 /* Get the item (in the pack) */
3516 o_ptr = &inventory[item];
3519 /* Get the item (on the floor) */
3522 o_ptr = &o_list[0 - item];
3527 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
3529 /* Extract the flags */
3530 object_flags(o_ptr, flgs);
3532 if (object_is_cursed(o_ptr))
3534 if (((o_ptr->curse_flags & TRC_HEAVY_CURSE) && (randint1(100) < 33)) ||
3535 have_flag(flgs, TR_ADD_L_CURSE) ||
3536 have_flag(flgs, TR_ADD_H_CURSE) ||
3537 (o_ptr->curse_flags & TRC_PERMA_CURSE))
3540 msg_format("%s¤òʤ¤¦¹õ¤¤¥ª¡¼¥é¤Ï½ËÊ¡¤òÄ·¤ÍÊÖ¤·¤¿¡ª",
3543 msg_format("The black aura on %s %s disrupts the blessing!",
3544 ((item >= 0) ? "your" : "the"), o_name);
3551 msg_format("%s ¤«¤é¼Ù°¤Ê¥ª¡¼¥é¤¬¾Ã¤¨¤¿¡£",
3554 msg_format("A malignant aura leaves %s %s.",
3555 ((item >= 0) ? "your" : "the"), o_name);
3560 o_ptr->curse_flags = 0L;
3562 /* Hack -- Assume felt */
3563 o_ptr->ident |= (IDENT_SENSE);
3566 o_ptr->feeling = FEEL_NONE;
3568 /* Recalculate the bonuses */
3569 p_ptr->update |= (PU_BONUS);
3572 p_ptr->window |= (PW_EQUIP);
3576 * Next, we try to bless it. Artifacts have a 1/3 chance of
3577 * being blessed, otherwise, the operation simply disenchants
3578 * them, godly power negating the magic. Ok, the explanation
3579 * is silly, but otherwise priests would always bless every
3580 * artifact weapon they find. Ego weapons and normal weapons
3581 * can be blessed automatically.
3583 if (have_flag(flgs, TR_BLESSED))
3586 msg_format("%s ¤Ï´û¤Ë½ËÊ¡¤µ¤ì¤Æ¤¤¤ë¡£",
3589 msg_format("%s %s %s blessed already.",
3590 ((item >= 0) ? "Your" : "The"), o_name,
3591 ((o_ptr->number > 1) ? "were" : "was"));
3597 if (!(object_is_artifact(o_ptr) || object_is_ego(o_ptr)) || one_in_(3))
3601 msg_format("%s¤Ïµ±¤¤¤¿¡ª",
3604 msg_format("%s %s shine%s!",
3605 ((item >= 0) ? "Your" : "The"), o_name,
3606 ((o_ptr->number > 1) ? "" : "s"));
3609 add_flag(o_ptr->art_flags, TR_BLESSED);
3610 o_ptr->discount = 99;
3614 bool dis_happened = FALSE;
3617 msg_print("¤½¤ÎÉð´ï¤Ï½ËÊ¡¤ò·ù¤Ã¤Æ¤¤¤ë¡ª");
3619 msg_print("The weapon resists your blessing!");
3623 /* Disenchant tohit */
3624 if (o_ptr->to_h > 0)
3627 dis_happened = TRUE;
3630 if ((o_ptr->to_h > 5) && (randint0(100) < 33)) o_ptr->to_h--;
3632 /* Disenchant todam */
3633 if (o_ptr->to_d > 0)
3636 dis_happened = TRUE;
3639 if ((o_ptr->to_d > 5) && (randint0(100) < 33)) o_ptr->to_d--;
3641 /* Disenchant toac */
3642 if (o_ptr->to_a > 0)
3645 dis_happened = TRUE;
3648 if ((o_ptr->to_a > 5) && (randint0(100) < 33)) o_ptr->to_a--;
3653 msg_print("¼þ°Ï¤¬ËÞÍǤÊÊ·°Ïµ¤¤ÇËþ¤Á¤¿...");
3655 msg_print("There is a static feeling in the air...");
3659 msg_format("%s ¤ÏÎô²½¤·¤¿¡ª",
3662 msg_format("%s %s %s disenchanted!",
3663 ((item >= 0) ? "Your" : "The"), o_name,
3664 ((o_ptr->number > 1) ? "were" : "was"));
3670 /* Recalculate bonuses */
3671 p_ptr->update |= (PU_BONUS);
3674 p_ptr->window |= (PW_EQUIP | PW_PLAYER);
3685 bool pulish_shield(void)
3689 u32b flgs[TR_FLAG_SIZE];
3690 char o_name[MAX_NLEN];
3693 item_tester_no_ryoute = TRUE;
3694 /* Assume enchant weapon */
3695 item_tester_tval = TV_SHIELD;
3699 q = "¤É¤Î½â¤òËᤤޤ¹¤«¡©";
3700 s = "Ë᤯½â¤¬¤¢¤ê¤Þ¤»¤ó¡£";
3702 q = "Pulish which weapon? ";
3703 s = "You have weapon to pulish.";
3706 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR)))
3709 /* Get the item (in the pack) */
3712 o_ptr = &inventory[item];
3715 /* Get the item (on the floor) */
3718 o_ptr = &o_list[0 - item];
3723 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
3725 /* Extract the flags */
3726 object_flags(o_ptr, flgs);
3728 if (o_ptr->k_idx && !object_is_artifact(o_ptr) && !object_is_ego(o_ptr) &&
3729 !object_is_cursed(o_ptr) && (o_ptr->sval != SV_MIRROR_SHIELD))
3732 msg_format("%s¤Ïµ±¤¤¤¿¡ª", o_name);
3734 msg_format("%s %s shine%s!",
3735 ((item >= 0) ? "Your" : "The"), o_name,
3736 ((o_ptr->number > 1) ? "" : "s"));
3738 o_ptr->name2 = EGO_REFLECTION;
3739 enchant(o_ptr, randint0(3) + 4, ENCH_TOAC);
3741 o_ptr->discount = 99;
3742 chg_virtue(V_ENCHANT, 2);
3748 if (flush_failure) flush();
3751 msg_print("¼ºÇÔ¤·¤¿¡£");
3753 msg_print("Failed.");
3756 chg_virtue(V_ENCHANT, -2);
3765 * Potions "smash open" and cause an area effect when
3766 * (1) they are shattered while in the player's inventory,
3767 * due to cold (etc) attacks;
3768 * (2) they are thrown at a monster, or obstacle;
3769 * (3) they are shattered by a "cold ball" or other such spell
3770 * while lying on the floor.
3773 * who --- who caused the potion to shatter (0=player)
3774 * potions that smash on the floor are assumed to
3775 * be caused by no-one (who = 1), as are those that
3776 * shatter inside the player inventory.
3777 * (Not anymore -- I changed this; TY)
3778 * y, x --- coordinates of the potion (or player if
3779 * the potion was in her inventory);
3780 * o_ptr --- pointer to the potion object.
3782 bool potion_smash_effect(int who, int y, int x, int k_idx)
3789 object_kind *k_ptr = &k_info[k_idx];
3791 switch (k_ptr->sval)
3793 case SV_POTION_SALT_WATER:
3794 case SV_POTION_SLIME_MOLD:
3795 case SV_POTION_LOSE_MEMORIES:
3796 case SV_POTION_DEC_STR:
3797 case SV_POTION_DEC_INT:
3798 case SV_POTION_DEC_WIS:
3799 case SV_POTION_DEC_DEX:
3800 case SV_POTION_DEC_CON:
3801 case SV_POTION_DEC_CHR:
3802 case SV_POTION_WATER: /* perhaps a 'water' attack? */
3803 case SV_POTION_APPLE_JUICE:
3806 case SV_POTION_INFRAVISION:
3807 case SV_POTION_DETECT_INVIS:
3808 case SV_POTION_SLOW_POISON:
3809 case SV_POTION_CURE_POISON:
3810 case SV_POTION_BOLDNESS:
3811 case SV_POTION_RESIST_HEAT:
3812 case SV_POTION_RESIST_COLD:
3813 case SV_POTION_HEROISM:
3814 case SV_POTION_BESERK_STRENGTH:
3815 case SV_POTION_RES_STR:
3816 case SV_POTION_RES_INT:
3817 case SV_POTION_RES_WIS:
3818 case SV_POTION_RES_DEX:
3819 case SV_POTION_RES_CON:
3820 case SV_POTION_RES_CHR:
3821 case SV_POTION_INC_STR:
3822 case SV_POTION_INC_INT:
3823 case SV_POTION_INC_WIS:
3824 case SV_POTION_INC_DEX:
3825 case SV_POTION_INC_CON:
3826 case SV_POTION_INC_CHR:
3827 case SV_POTION_AUGMENTATION:
3828 case SV_POTION_ENLIGHTENMENT:
3829 case SV_POTION_STAR_ENLIGHTENMENT:
3830 case SV_POTION_SELF_KNOWLEDGE:
3831 case SV_POTION_EXPERIENCE:
3832 case SV_POTION_RESISTANCE:
3833 case SV_POTION_INVULNERABILITY:
3834 case SV_POTION_NEW_LIFE:
3835 /* All of the above potions have no effect when shattered */
3837 case SV_POTION_SLOWNESS:
3842 case SV_POTION_POISON:
3847 case SV_POTION_BLINDNESS:
3851 case SV_POTION_CONFUSION: /* Booze */
3855 case SV_POTION_SLEEP:
3859 case SV_POTION_RUINATION:
3860 case SV_POTION_DETONATIONS:
3862 dam = damroll(25, 25);
3865 case SV_POTION_DEATH:
3866 dt = GF_DEATH_RAY; /* !! */
3867 dam = k_ptr->level * 10;
3871 case SV_POTION_SPEED:
3874 case SV_POTION_CURE_LIGHT:
3876 dam = damroll(2, 3);
3878 case SV_POTION_CURE_SERIOUS:
3880 dam = damroll(4, 3);
3882 case SV_POTION_CURE_CRITICAL:
3883 case SV_POTION_CURING:
3885 dam = damroll(6, 3);
3887 case SV_POTION_HEALING:
3889 dam = damroll(10, 10);
3891 case SV_POTION_RESTORE_EXP:
3896 case SV_POTION_LIFE:
3898 dam = damroll(50, 50);
3901 case SV_POTION_STAR_HEALING:
3903 dam = damroll(50, 50);
3906 case SV_POTION_RESTORE_MANA: /* MANA */
3908 dam = damroll(10, 10);
3915 (void)project(who, radius, y, x, dam, dt,
3916 (PROJECT_JUMP | PROJECT_ITEM | PROJECT_KILL), -1);
3918 /* XXX those potions that explode need to become "known" */
3924 * Hack -- Display all known spells in a window
3926 * XXX XXX XXX Need to analyze size of the window.
3928 * XXX XXX XXX Need more color coding.
3930 void display_spell_list(void)
3935 const magic_type *s_ptr;
3943 /* They have too many spells to list */
3944 if (p_ptr->pclass == CLASS_SORCERER) return;
3945 if (p_ptr->pclass == CLASS_RED_MAGE) return;
3948 if (p_ptr->pclass == CLASS_SNIPER)
3950 display_snipe_list();
3954 /* mind.c type classes */
3955 if ((p_ptr->pclass == CLASS_MINDCRAFTER) ||
3956 (p_ptr->pclass == CLASS_BERSERKER) ||
3957 (p_ptr->pclass == CLASS_NINJA) ||
3958 (p_ptr->pclass == CLASS_MIRROR_MASTER) ||
3959 (p_ptr->pclass == CLASS_FORCETRAINER))
3965 int plev = p_ptr->lev;
3971 bool use_hp = FALSE;
3973 /* Display a list of spells */
3976 put_str("̾Á°", y, x + 5);
3977 put_str("Lv MP ¼ºÎ¨ ¸ú²Ì", y, x + 35);
3979 put_str("Name", y, x + 5);
3980 put_str("Lv Mana Fail Info", y, x + 35);
3983 switch(p_ptr->pclass)
3985 case CLASS_MINDCRAFTER: use_mind = MIND_MINDCRAFTER;break;
3986 case CLASS_FORCETRAINER: use_mind = MIND_KI;break;
3987 case CLASS_BERSERKER: use_mind = MIND_BERSERKER; use_hp = TRUE; break;
3988 case CLASS_MIRROR_MASTER: use_mind = MIND_MIRROR_MASTER; break;
3989 case CLASS_NINJA: use_mind = MIND_NINJUTSU; use_hp = TRUE; break;
3990 default: use_mind = 0;break;
3993 /* Dump the spells */
3994 for (i = 0; i < MAX_MIND_POWERS; i++)
3996 byte a = TERM_WHITE;
3998 /* Access the available spell */
3999 spell = mind_powers[use_mind].info[i];
4000 if (spell.min_lev > plev) break;
4002 /* Get the failure rate */
4003 chance = spell.fail;
4005 /* Reduce failure rate by "effective" level adjustment */
4006 chance -= 3 * (p_ptr->lev - spell.min_lev);
4008 /* Reduce failure rate by INT/WIS adjustment */
4009 chance -= 3 * (adj_mag_stat[p_ptr->stat_ind[mp_ptr->spell_stat]] - 1);
4013 /* Not enough mana to cast */
4014 if (spell.mana_cost > p_ptr->csp)
4016 chance += 5 * (spell.mana_cost - p_ptr->csp);
4022 /* Not enough hp to cast */
4023 if (spell.mana_cost > p_ptr->chp)
4030 /* Extract the minimum failure rate */
4031 minfail = adj_mag_fail[p_ptr->stat_ind[mp_ptr->spell_stat]];
4033 /* Minimum failure rate */
4034 if (chance < minfail) chance = minfail;
4036 /* Stunning makes spells harder */
4037 if (p_ptr->stun > 50) chance += 25;
4038 else if (p_ptr->stun) chance += 15;
4040 /* Always a 5 percent chance of working */
4041 if (chance > 95) chance = 95;
4044 mindcraft_info(comment, use_mind, i);
4046 /* Dump the spell */
4047 sprintf(psi_desc, " %c) %-30s%2d %4d %3d%%%s",
4049 spell.min_lev, spell.mana_cost, chance, comment);
4051 Term_putstr(x, y + i + 1, -1, a, psi_desc);
4056 /* Cannot read spellbooks */
4057 if (REALM_NONE == p_ptr->realm1) return;
4059 /* Normal spellcaster with books */
4062 for (j = 0; j < ((p_ptr->realm2 > REALM_NONE) ? 2 : 1); j++)
4066 /* Reset vertical */
4069 /* Vertical location */
4070 y = (j < 3) ? 0 : (m[j - 3] + 2);
4072 /* Horizontal location */
4076 for (i = 0; i < 32; i++)
4078 byte a = TERM_WHITE;
4080 /* Access the spell */
4081 if (!is_magic((j < 1) ? p_ptr->realm1 : p_ptr->realm2))
4083 s_ptr = &technic_info[((j < 1) ? p_ptr->realm1 : p_ptr->realm2) - MIN_TECHNIC][i % 32];
4087 s_ptr = &mp_ptr->info[((j < 1) ? p_ptr->realm1 : p_ptr->realm2) - 1][i % 32];
4090 strcpy(name, do_spell((j < 1) ? p_ptr->realm1 : p_ptr->realm2, i % 32, SPELL_NAME));
4093 if (s_ptr->slevel >= 99)
4097 strcpy(name, "(ȽÆÉÉÔǽ)");
4099 strcpy(name, "(illegible)");
4109 ((p_ptr->spell_forgotten1 & (1L << i))) :
4110 ((p_ptr->spell_forgotten2 & (1L << (i % 32)))))
4117 else if (!((j < 1) ?
4118 (p_ptr->spell_learned1 & (1L << i)) :
4119 (p_ptr->spell_learned2 & (1L << (i % 32)))))
4126 else if (!((j < 1) ?
4127 (p_ptr->spell_worked1 & (1L << i)) :
4128 (p_ptr->spell_worked2 & (1L << (i % 32)))))
4134 /* Dump the spell --(-- */
4135 sprintf(out_val, "%c/%c) %-20.20s",
4136 I2A(n / 8), I2A(n % 8), name);
4141 /* Dump onto the window */
4142 Term_putstr(x, m[j], -1, a, out_val);
4152 * Returns experience of a spell
4154 s16b experience_of_spell(int spell, int use_realm)
4156 if (p_ptr->pclass == CLASS_SORCERER) return SPELL_EXP_MASTER;
4157 else if (p_ptr->pclass == CLASS_RED_MAGE) return SPELL_EXP_SKILLED;
4158 else if (use_realm == p_ptr->realm1) return p_ptr->spell_exp[spell];
4159 else if (use_realm == p_ptr->realm2) return p_ptr->spell_exp[spell + 32];
4165 * Modify mana consumption rate using spell exp and p_ptr->dec_mana
4167 int mod_need_mana(int need_mana, int spell, int realm)
4169 #define MANA_CONST 2400
4171 #define DEC_MANA_DIV 3
4174 if ((realm > REALM_NONE) && (realm <= MAX_REALM))
4177 * need_mana defaults if spell exp equals SPELL_EXP_EXPERT and !p_ptr->dec_mana.
4178 * MANA_CONST is used to calculate need_mana effected from spell proficiency.
4180 need_mana = need_mana * (MANA_CONST + SPELL_EXP_EXPERT - experience_of_spell(spell, realm)) + (MANA_CONST - 1);
4181 need_mana *= p_ptr->dec_mana ? DEC_MANA_DIV : MANA_DIV;
4182 need_mana /= MANA_CONST * MANA_DIV;
4183 if (need_mana < 1) need_mana = 1;
4186 /* Non-realm magic */
4189 if (p_ptr->dec_mana) need_mana = (need_mana + 1) * DEC_MANA_DIV / MANA_DIV;
4201 * Modify spell fail rate
4202 * Using p_ptr->to_m_chance, p_ptr->dec_mana, p_ptr->easy_spell and p_ptr->heavy_spell
4204 int mod_spell_chance_1(int chance)
4206 chance += p_ptr->to_m_chance;
4208 if (p_ptr->heavy_spell) chance += 20;
4210 if (p_ptr->dec_mana && p_ptr->easy_spell) chance -= 4;
4211 else if (p_ptr->easy_spell) chance -= 3;
4212 else if (p_ptr->dec_mana) chance -= 2;
4219 * Modify spell fail rate (as "suffix" process)
4220 * Using p_ptr->dec_mana, p_ptr->easy_spell and p_ptr->heavy_spell
4221 * Note: variable "chance" cannot be negative.
4223 int mod_spell_chance_2(int chance)
4225 if (p_ptr->dec_mana) chance--;
4227 if (p_ptr->heavy_spell) chance += 5;
4229 return MAX(chance, 0);
4234 * Returns spell chance of failure for spell -RAK-
4236 s16b spell_chance(int spell, int use_realm)
4238 int chance, minfail;
4239 const magic_type *s_ptr;
4241 int penalty = (mp_ptr->spell_stat == A_WIS) ? 10 : 4;
4244 /* Paranoia -- must be literate */
4245 if (!mp_ptr->spell_book) return (100);
4247 if (use_realm == REALM_HISSATSU) return 0;
4249 /* Access the spell */
4250 if (!is_magic(use_realm))
4252 s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
4256 s_ptr = &mp_ptr->info[use_realm - 1][spell];
4259 /* Extract the base spell failure rate */
4260 chance = s_ptr->sfail;
4262 /* Reduce failure rate by "effective" level adjustment */
4263 chance -= 3 * (p_ptr->lev - s_ptr->slevel);
4265 /* Reduce failure rate by INT/WIS adjustment */
4266 chance -= 3 * (adj_mag_stat[p_ptr->stat_ind[mp_ptr->spell_stat]] - 1);
4269 chance += (MAX(r_info[m_list[p_ptr->riding].r_idx].level - p_ptr->skill_exp[GINOU_RIDING] / 100 - 10, 0));
4271 /* Extract mana consumption rate */
4272 need_mana = mod_need_mana(s_ptr->smana, spell, use_realm);
4274 /* Not enough mana to cast */
4275 if (need_mana > p_ptr->csp)
4277 chance += 5 * (need_mana - p_ptr->csp);
4280 if ((use_realm != p_ptr->realm1) && ((p_ptr->pclass == CLASS_MAGE) || (p_ptr->pclass == CLASS_PRIEST))) chance += 5;
4282 /* Extract the minimum failure rate */
4283 minfail = adj_mag_fail[p_ptr->stat_ind[mp_ptr->spell_stat]];
4286 * Non mage/priest characters never get too good
4287 * (added high mage, mindcrafter)
4289 if (mp_ptr->spell_xtra & MAGIC_FAIL_5PERCENT)
4291 if (minfail < 5) minfail = 5;
4294 /* Hack -- Priest prayer penalty for "edged" weapons -DGK */
4295 if (((p_ptr->pclass == CLASS_PRIEST) || (p_ptr->pclass == CLASS_SORCERER)) && p_ptr->icky_wield[0]) chance += 25;
4296 if (((p_ptr->pclass == CLASS_PRIEST) || (p_ptr->pclass == CLASS_SORCERER)) && p_ptr->icky_wield[1]) chance += 25;
4298 chance = mod_spell_chance_1(chance);
4300 /* Goodness or evilness gives a penalty to failure rate */
4304 if ((p_ptr->align > 50) || (p_ptr->align < -50)) chance += penalty;
4306 case REALM_LIFE: case REALM_CRUSADE:
4307 if (p_ptr->align < -20) chance += penalty;
4309 case REALM_DEATH: case REALM_DAEMON: case REALM_HEX:
4310 if (p_ptr->align > 20) chance += penalty;
4314 /* Minimum failure rate */
4315 if (chance < minfail) chance = minfail;
4317 /* Stunning makes spells harder */
4318 if (p_ptr->stun > 50) chance += 25;
4319 else if (p_ptr->stun) chance += 15;
4321 /* Always a 5 percent chance of working */
4322 if (chance > 95) chance = 95;
4324 if ((use_realm == p_ptr->realm1) || (use_realm == p_ptr->realm2)
4325 || (p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE))
4327 s16b exp = experience_of_spell(spell, use_realm);
4328 if (exp >= SPELL_EXP_EXPERT) chance--;
4329 if (exp >= SPELL_EXP_MASTER) chance--;
4332 /* Return the chance */
4333 return mod_spell_chance_2(chance);
4339 * Determine if a spell is "okay" for the player to cast or study
4340 * The spell must be legible, not forgotten, and also, to cast,
4341 * it must be known, and to study, it must not be known.
4343 bool spell_okay(int spell, bool learned, bool study_pray, int use_realm)
4345 const magic_type *s_ptr;
4347 /* Access the spell */
4348 if (!is_magic(use_realm))
4350 s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
4354 s_ptr = &mp_ptr->info[use_realm - 1][spell];
4357 /* Spell is illegal */
4358 if (s_ptr->slevel > p_ptr->lev) return (FALSE);
4360 /* Spell is forgotten */
4361 if ((use_realm == p_ptr->realm2) ?
4362 (p_ptr->spell_forgotten2 & (1L << spell)) :
4363 (p_ptr->spell_forgotten1 & (1L << spell)))
4369 if (p_ptr->pclass == CLASS_SORCERER) return (TRUE);
4370 if (p_ptr->pclass == CLASS_RED_MAGE) return (TRUE);
4372 /* Spell is learned */
4373 if ((use_realm == p_ptr->realm2) ?
4374 (p_ptr->spell_learned2 & (1L << spell)) :
4375 (p_ptr->spell_learned1 & (1L << spell)))
4378 return (!study_pray);
4381 /* Okay to study, not to cast */
4387 * Print a list of spells (for browsing or casting or viewing)
4389 void print_spells(int target_spell, byte *spells, int num, int y, int x, int use_realm)
4391 int i, spell, exp_level, increment = 64;
4392 const magic_type *s_ptr;
4403 if (((use_realm <= REALM_NONE) || (use_realm > MAX_REALM)) && p_ptr->wizard)
4405 msg_print("·Ù¹ð¡ª print_spell ¤¬Îΰè¤Ê¤·¤Ë¸Æ¤Ð¤ì¤¿");
4407 msg_print("Warning! print_spells called with null realm");
4411 /* Title the list */
4413 if (use_realm == REALM_HISSATSU)
4415 strcpy(buf," Lv MP");
4417 strcpy(buf," Lv SP");
4421 strcpy(buf,"½ÏÎýÅÙ Lv MP ¼ºÎ¨ ¸ú²Ì");
4423 strcpy(buf,"Profic Lv SP Fail Effect");
4427 put_str("̾Á°", y, x + 5);
4428 put_str(buf, y, x + 29);
4430 put_str("Name", y, x + 5);
4431 put_str(buf, y, x + 29);
4434 if ((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE)) increment = 0;
4435 else if (use_realm == p_ptr->realm1) increment = 0;
4436 else if (use_realm == p_ptr->realm2) increment = 32;
4438 /* Dump the spells */
4439 for (i = 0; i < num; i++)
4441 /* Access the spell */
4444 /* Access the spell */
4445 if (!is_magic(use_realm))
4447 s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
4451 s_ptr = &mp_ptr->info[use_realm - 1][spell];
4454 if (use_realm == REALM_HISSATSU)
4455 need_mana = s_ptr->smana;
4458 s16b exp = experience_of_spell(spell, use_realm);
4460 /* Extract mana consumption rate */
4461 need_mana = mod_need_mana(s_ptr->smana, spell, use_realm);
4463 if ((increment == 64) || (s_ptr->slevel >= 99)) exp_level = EXP_LEVEL_UNSKILLED;
4464 else exp_level = spell_exp_level(exp);
4467 if (!increment && (exp_level == EXP_LEVEL_MASTER)) max = TRUE;
4468 else if ((increment == 32) && (exp_level >= EXP_LEVEL_EXPERT)) max = TRUE;
4469 else if (s_ptr->slevel >= 99) max = TRUE;
4470 else if ((p_ptr->pclass == CLASS_RED_MAGE) && (exp_level >= EXP_LEVEL_SKILLED)) max = TRUE;
4472 strncpy(ryakuji, exp_level_str[exp_level], 4);
4477 if (use_menu && target_spell)
4479 if (i == (target_spell-1))
4481 strcpy(out_val, " ¡Õ ");
4483 strcpy(out_val, " > ");
4486 strcpy(out_val, " ");
4488 else sprintf(out_val, " %c) ", I2A(i));
4489 /* Skip illegible spells */
4490 if (s_ptr->slevel >= 99)
4493 strcat(out_val, format("%-30s", "(ȽÆÉÉÔǽ)"));
4495 strcat(out_val, format("%-30s", "(illegible)"));
4498 c_prt(TERM_L_DARK, out_val, y + i + 1, x);
4502 /* XXX XXX Could label spells above the players level */
4504 /* Get extra info */
4505 strcpy(info, do_spell(use_realm, spell, SPELL_INFO));
4510 /* Assume spell is known and tried */
4511 line_attr = TERM_WHITE;
4513 /* Analyze the spell */
4514 if ((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE))
4516 if (s_ptr->slevel > p_ptr->max_plv)
4521 comment = "unknown";
4524 line_attr = TERM_L_BLUE;
4526 else if (s_ptr->slevel > p_ptr->lev)
4531 comment = "forgotten";
4534 line_attr = TERM_YELLOW;
4537 else if ((use_realm != p_ptr->realm1) && (use_realm != p_ptr->realm2))
4542 comment = "unknown";
4545 line_attr = TERM_L_BLUE;
4547 else if ((use_realm == p_ptr->realm1) ?
4548 ((p_ptr->spell_forgotten1 & (1L << spell))) :
4549 ((p_ptr->spell_forgotten2 & (1L << spell))))
4554 comment = "forgotten";
4557 line_attr = TERM_YELLOW;
4559 else if (!((use_realm == p_ptr->realm1) ?
4560 (p_ptr->spell_learned1 & (1L << spell)) :
4561 (p_ptr->spell_learned2 & (1L << spell))))
4566 comment = "unknown";
4569 line_attr = TERM_L_BLUE;
4571 else if (!((use_realm == p_ptr->realm1) ?
4572 (p_ptr->spell_worked1 & (1L << spell)) :
4573 (p_ptr->spell_worked2 & (1L << spell))))
4578 comment = "untried";
4581 line_attr = TERM_L_GREEN;
4584 /* Dump the spell --(-- */
4585 if (use_realm == REALM_HISSATSU)
4587 strcat(out_val, format("%-25s %2d %4d",
4588 do_spell(use_realm, spell, SPELL_NAME), /* realm, spell */
4589 s_ptr->slevel, need_mana));
4593 strcat(out_val, format("%-25s%c%-4s %2d %4d %3d%% %s",
4594 do_spell(use_realm, spell, SPELL_NAME), /* realm, spell */
4595 (max ? '!' : ' '), ryakuji,
4596 s_ptr->slevel, need_mana, spell_chance(spell, use_realm), comment));
4598 c_prt(line_attr, out_val, y + i + 1, x);
4601 /* Clear the bottom line */
4602 prt("", y + i + 1, x);
4607 * Note that amulets, rods, and high-level spell books are immune
4608 * to "inventory damage" of any kind. Also sling ammo and shovels.
4613 * Does a given class of objects (usually) hate acid?
4614 * Note that acid can either melt or corrode something.
4616 bool hates_acid(object_type *o_ptr)
4618 /* Analyze the type */
4619 switch (o_ptr->tval)
4621 /* Wearable items */
4641 /* Staffs/Scrolls are wood/paper */
4654 /* Junk is useless */
4668 * Does a given object (usually) hate electricity?
4670 bool hates_elec(object_type *o_ptr)
4672 switch (o_ptr->tval)
4686 * Does a given object (usually) hate fire?
4687 * Hafted/Polearm weapons have wooden shafts.
4688 * Arrows/Bows are mostly wooden.
4690 bool hates_fire(object_type *o_ptr)
4692 /* Analyze the type */
4693 switch (o_ptr->tval)
4711 case TV_SORCERY_BOOK:
4712 case TV_NATURE_BOOK:
4716 case TV_ARCANE_BOOK:
4718 case TV_DAEMON_BOOK:
4719 case TV_CRUSADE_BOOK:
4721 case TV_HISSATSU_BOOK:
4733 /* Staffs/Scrolls burn */
4746 * Does a given object (usually) hate cold?
4748 bool hates_cold(object_type *o_ptr)
4750 switch (o_ptr->tval)
4767 int set_acid_destroy(object_type *o_ptr)
4769 u32b flgs[TR_FLAG_SIZE];
4770 if (!hates_acid(o_ptr)) return (FALSE);
4771 object_flags(o_ptr, flgs);
4772 if (have_flag(flgs, TR_IGNORE_ACID)) return (FALSE);
4780 int set_elec_destroy(object_type *o_ptr)
4782 u32b flgs[TR_FLAG_SIZE];
4783 if (!hates_elec(o_ptr)) return (FALSE);
4784 object_flags(o_ptr, flgs);
4785 if (have_flag(flgs, TR_IGNORE_ELEC)) return (FALSE);
4793 int set_fire_destroy(object_type *o_ptr)
4795 u32b flgs[TR_FLAG_SIZE];
4796 if (!hates_fire(o_ptr)) return (FALSE);
4797 object_flags(o_ptr, flgs);
4798 if (have_flag(flgs, TR_IGNORE_FIRE)) return (FALSE);
4806 int set_cold_destroy(object_type *o_ptr)
4808 u32b flgs[TR_FLAG_SIZE];
4809 if (!hates_cold(o_ptr)) return (FALSE);
4810 object_flags(o_ptr, flgs);
4811 if (have_flag(flgs, TR_IGNORE_COLD)) return (FALSE);
4817 * Destroys a type of item on a given percent chance
4818 * Note that missiles are no longer necessarily all destroyed
4819 * Destruction taken from "melee.c" code for "stealing".
4820 * New-style wands and rods handled correctly. -LM-
4821 * Returns number of items destroyed.
4823 int inven_damage(inven_func typ, int perc)
4827 char o_name[MAX_NLEN];
4829 if (CHECK_MULTISHADOW()) return 0;
4831 if (p_ptr->inside_arena) return 0;
4833 /* Count the casualties */
4836 /* Scan through the slots backwards */
4837 for (i = 0; i < INVEN_PACK; i++)
4839 o_ptr = &inventory[i];
4841 /* Skip non-objects */
4842 if (!o_ptr->k_idx) continue;
4844 /* Hack -- for now, skip artifacts */
4845 if (object_is_artifact(o_ptr)) continue;
4847 /* Give this item slot a shot at death */
4850 /* Count the casualties */
4851 for (amt = j = 0; j < o_ptr->number; ++j)
4853 if (randint0(100) < perc) amt++;
4856 /* Some casualities */
4859 /* Get a description */
4860 object_desc(o_name, o_ptr, OD_OMIT_PREFIX);
4864 msg_format("%s(%c)¤¬%s²õ¤ì¤Æ¤·¤Þ¤Ã¤¿¡ª",
4866 msg_format("%sour %s (%c) %s destroyed!",
4870 o_name, index_to_label(i),
4871 ((o_ptr->number > 1) ?
4872 ((amt == o_ptr->number) ? "Á´Éô" :
4873 (amt > 1 ? "²¿¸Ä¤«" : "°ì¸Ä")) : "") );
4875 ((o_ptr->number > 1) ?
4876 ((amt == o_ptr->number) ? "All of y" :
4877 (amt > 1 ? "Some of y" : "One of y")) : "Y"),
4878 o_name, index_to_label(i),
4879 ((amt > 1) ? "were" : "was"));
4883 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
4884 msg_print("¤ä¤ê¤ä¤¬¤Ã¤¿¤Ê¡ª");
4887 /* Potions smash open */
4888 if (object_is_potion(o_ptr))
4890 (void)potion_smash_effect(0, py, px, o_ptr->k_idx);
4893 /* Reduce the charges of rods/wands */
4894 reduce_charges(o_ptr, amt);
4896 /* Destroy "amt" items */
4897 inven_item_increase(i, -amt);
4898 inven_item_optimize(i);
4900 /* Count the casualties */
4906 /* Return the casualty count */
4912 * Acid has hit the player, attempt to affect some armor.
4914 * Note that the "base armor" of an object never changes.
4916 * If any armor is damaged (or resists), the player takes less damage.
4918 static int minus_ac(void)
4920 object_type *o_ptr = NULL;
4921 u32b flgs[TR_FLAG_SIZE];
4922 char o_name[MAX_NLEN];
4925 /* Pick a (possibly empty) inventory slot */
4926 switch (randint1(7))
4928 case 1: o_ptr = &inventory[INVEN_RARM]; break;
4929 case 2: o_ptr = &inventory[INVEN_LARM]; break;
4930 case 3: o_ptr = &inventory[INVEN_BODY]; break;
4931 case 4: o_ptr = &inventory[INVEN_OUTER]; break;
4932 case 5: o_ptr = &inventory[INVEN_HANDS]; break;
4933 case 6: o_ptr = &inventory[INVEN_HEAD]; break;
4934 case 7: o_ptr = &inventory[INVEN_FEET]; break;
4937 /* Nothing to damage */
4938 if (!o_ptr->k_idx) return (FALSE);
4940 if (!object_is_armour(o_ptr)) return (FALSE);
4942 /* No damage left to be done */
4943 if (o_ptr->ac + o_ptr->to_a <= 0) return (FALSE);
4947 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
4949 /* Extract the flags */
4950 object_flags(o_ptr, flgs);
4952 /* Object resists */
4953 if (have_flag(flgs, TR_IGNORE_ACID))
4956 msg_format("¤·¤«¤·%s¤Ë¤Ï¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡ª", o_name);
4958 msg_format("Your %s is unaffected!", o_name);
4967 msg_format("%s¤¬¥À¥á¡¼¥¸¤ò¼õ¤±¤¿¡ª", o_name);
4969 msg_format("Your %s is damaged!", o_name);
4973 /* Damage the item */
4976 /* Calculate bonuses */
4977 p_ptr->update |= (PU_BONUS);
4980 p_ptr->window |= (PW_EQUIP | PW_PLAYER);
4984 /* Item was damaged */
4990 * Hurt the player with Acid
4992 int acid_dam(int dam, cptr kb_str, int monspell, bool aura)
4995 int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
4996 bool double_resist = IS_OPPOSE_ACID();
4998 /* Total Immunity */
4999 if (p_ptr->immune_acid || (dam <= 0))
5001 learn_spell(monspell);
5005 /* Vulnerability (Ouch!) */
5006 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
5007 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
5009 /* Resist the damage */
5010 if (p_ptr->resist_acid) dam = (dam + 2) / 3;
5011 if (double_resist) dam = (dam + 2) / 3;
5013 if (aura || !CHECK_MULTISHADOW())
5015 if ((!(double_resist || p_ptr->resist_acid)) &&
5016 one_in_(HURT_CHANCE))
5017 (void)do_dec_stat(A_CHR);
5019 /* If any armor gets hit, defend the player */
5020 if (minus_ac()) dam = (dam + 1) / 2;
5024 get_damage = take_hit(aura ? DAMAGE_NOESCAPE : DAMAGE_ATTACK, dam, kb_str, monspell);
5026 /* Inventory damage */
5027 if (!aura && !(double_resist && p_ptr->resist_acid))
5028 inven_damage(set_acid_destroy, inv);
5034 * Hurt the player with electricity
5036 int elec_dam(int dam, cptr kb_str, int monspell, bool aura)
5039 int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
5040 bool double_resist = IS_OPPOSE_ELEC();
5042 /* Total immunity */
5043 if (p_ptr->immune_elec || (dam <= 0))
5045 learn_spell(monspell);
5049 /* Vulnerability (Ouch!) */
5050 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
5051 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
5052 if (prace_is_(RACE_ANDROID)) dam += dam / 3;
5054 /* Resist the damage */
5055 if (p_ptr->resist_elec) dam = (dam + 2) / 3;
5056 if (double_resist) dam = (dam + 2) / 3;
5058 if (aura || !CHECK_MULTISHADOW())
5060 if ((!(double_resist || p_ptr->resist_elec)) &&
5061 one_in_(HURT_CHANCE))
5062 (void)do_dec_stat(A_DEX);
5066 get_damage = take_hit(aura ? DAMAGE_NOESCAPE : DAMAGE_ATTACK, dam, kb_str, monspell);
5068 /* Inventory damage */
5069 if (!aura && !(double_resist && p_ptr->resist_elec))
5070 inven_damage(set_elec_destroy, inv);
5077 * Hurt the player with Fire
5079 int fire_dam(int dam, cptr kb_str, int monspell, bool aura)
5082 int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
5083 bool double_resist = IS_OPPOSE_FIRE();
5085 /* Totally immune */
5086 if (p_ptr->immune_fire || (dam <= 0))
5088 learn_spell(monspell);
5092 /* Vulnerability (Ouch!) */
5093 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
5094 if (prace_is_(RACE_ENT)) dam += dam / 3;
5095 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
5097 /* Resist the damage */
5098 if (p_ptr->resist_fire) dam = (dam + 2) / 3;
5099 if (double_resist) dam = (dam + 2) / 3;
5101 if (aura || !CHECK_MULTISHADOW())
5103 if ((!(double_resist || p_ptr->resist_fire)) &&
5104 one_in_(HURT_CHANCE))
5105 (void)do_dec_stat(A_STR);
5109 get_damage = take_hit(aura ? DAMAGE_NOESCAPE : DAMAGE_ATTACK, dam, kb_str, monspell);
5111 /* Inventory damage */
5112 if (!aura && !(double_resist && p_ptr->resist_fire))
5113 inven_damage(set_fire_destroy, inv);
5120 * Hurt the player with Cold
5122 int cold_dam(int dam, cptr kb_str, int monspell, bool aura)
5125 int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
5126 bool double_resist = IS_OPPOSE_COLD();
5128 /* Total immunity */
5129 if (p_ptr->immune_cold || (dam <= 0))
5131 learn_spell(monspell);
5135 /* Vulnerability (Ouch!) */
5136 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
5137 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
5139 /* Resist the damage */
5140 if (p_ptr->resist_cold) dam = (dam + 2) / 3;
5141 if (double_resist) dam = (dam + 2) / 3;
5143 if (aura || !CHECK_MULTISHADOW())
5145 if ((!(double_resist || p_ptr->resist_cold)) &&
5146 one_in_(HURT_CHANCE))
5147 (void)do_dec_stat(A_STR);
5151 get_damage = take_hit(aura ? DAMAGE_NOESCAPE : DAMAGE_ATTACK, dam, kb_str, monspell);
5153 /* Inventory damage */
5154 if (!aura && !(double_resist && p_ptr->resist_cold))
5155 inven_damage(set_cold_destroy, inv);
5161 bool rustproof(void)
5165 char o_name[MAX_NLEN];
5168 item_tester_no_ryoute = TRUE;
5169 /* Select a piece of armour */
5170 item_tester_hook = object_is_armour;
5174 q = "¤É¤ÎËɶñ¤Ë»¬»ß¤á¤ò¤·¤Þ¤¹¤«¡©";
5175 s = "»¬»ß¤á¤Ç¤¤ë¤â¤Î¤¬¤¢¤ê¤Þ¤»¤ó¡£";
5177 q = "Rustproof which piece of armour? ";
5178 s = "You have nothing to rustproof.";
5181 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return FALSE;
5183 /* Get the item (in the pack) */
5186 o_ptr = &inventory[item];
5189 /* Get the item (on the floor) */
5192 o_ptr = &o_list[0 - item];
5197 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
5199 add_flag(o_ptr->art_flags, TR_IGNORE_ACID);
5201 if ((o_ptr->to_a < 0) && !object_is_cursed(o_ptr))
5204 msg_format("%s¤Ï¿·ÉÊƱÍͤˤʤä¿¡ª",o_name);
5206 msg_format("%s %s look%s as good as new!",
5207 ((item >= 0) ? "Your" : "The"), o_name,
5208 ((o_ptr->number > 1) ? "" : "s"));
5215 msg_format("%s¤ÏÉå¿©¤·¤Ê¤¯¤Ê¤Ã¤¿¡£", o_name);
5217 msg_format("%s %s %s now protected against corrosion.",
5218 ((item >= 0) ? "Your" : "The"), o_name,
5219 ((o_ptr->number > 1) ? "are" : "is"));
5230 * Curse the players armor
5232 bool curse_armor(void)
5237 char o_name[MAX_NLEN];
5240 /* Curse the body armor */
5241 o_ptr = &inventory[INVEN_BODY];
5243 /* Nothing to curse */
5244 if (!o_ptr->k_idx) return (FALSE);
5248 object_desc(o_name, o_ptr, OD_OMIT_PREFIX);
5250 /* Attempt a saving throw for artifacts */
5251 if (object_is_artifact(o_ptr) && (randint0(100) < 50))
5255 msg_format("%s¤¬%s¤òÊñ¤ß¹þ¤â¤¦¤È¤·¤¿¤¬¡¢%s¤Ï¤½¤ì¤òÄ·¤ÍÊÖ¤·¤¿¡ª",
5256 "¶²ÉݤΰŹõ¥ª¡¼¥é", "Ëɶñ", o_name);
5258 msg_format("A %s tries to %s, but your %s resists the effects!",
5259 "terrible black aura", "surround your armor", o_name);
5264 /* not artifact or failed save... */
5269 msg_format("¶²ÉݤΰŹõ¥ª¡¼¥é¤¬¤¢¤Ê¤¿¤Î%s¤òÊñ¤ß¹þ¤ó¤À¡ª", o_name);
5271 msg_format("A terrible black aura blasts your %s!", o_name);
5274 chg_virtue(V_ENCHANT, -5);
5276 /* Blast the armor */
5278 o_ptr->name2 = EGO_BLASTED;
5279 o_ptr->to_a = 0 - randint1(5) - randint1(5);
5286 for (i = 0; i < TR_FLAG_SIZE; i++)
5287 o_ptr->art_flags[i] = 0;
5290 o_ptr->curse_flags = TRC_CURSED;
5293 o_ptr->ident |= (IDENT_BROKEN);
5295 /* Recalculate bonuses */
5296 p_ptr->update |= (PU_BONUS);
5298 /* Recalculate mana */
5299 p_ptr->update |= (PU_MANA);
5302 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
5310 * Curse the players weapon
5312 bool curse_weapon_object(bool force, object_type *o_ptr)
5315 char o_name[MAX_NLEN];
5317 /* Nothing to curse */
5318 if (!o_ptr->k_idx) return (FALSE);
5321 object_desc(o_name, o_ptr, OD_OMIT_PREFIX);
5323 /* Attempt a saving throw */
5324 if (object_is_artifact(o_ptr) && (randint0(100) < 50) && !force)
5328 msg_format("%s¤¬%s¤òÊñ¤ß¹þ¤â¤¦¤È¤·¤¿¤¬¡¢%s¤Ï¤½¤ì¤òÄ·¤ÍÊÖ¤·¤¿¡ª",
5329 "¶²ÉݤΰŹõ¥ª¡¼¥é", "Éð´ï", o_name);
5331 msg_format("A %s tries to %s, but your %s resists the effects!",
5332 "terrible black aura", "surround your weapon", o_name);
5336 /* not artifact or failed save... */
5341 if (!force) msg_format("¶²ÉݤΰŹõ¥ª¡¼¥é¤¬¤¢¤Ê¤¿¤Î%s¤òÊñ¤ß¹þ¤ó¤À¡ª", o_name);
5343 if (!force) msg_format("A terrible black aura blasts your %s!", o_name);
5345 chg_virtue(V_ENCHANT, -5);
5347 /* Shatter the weapon */
5349 o_ptr->name2 = EGO_SHATTERED;
5350 o_ptr->to_h = 0 - randint1(5) - randint1(5);
5351 o_ptr->to_d = 0 - randint1(5) - randint1(5);
5357 for (i = 0; i < TR_FLAG_SIZE; i++)
5358 o_ptr->art_flags[i] = 0;
5361 o_ptr->curse_flags = TRC_CURSED;
5364 o_ptr->ident |= (IDENT_BROKEN);
5366 /* Recalculate bonuses */
5367 p_ptr->update |= (PU_BONUS);
5369 /* Recalculate mana */
5370 p_ptr->update |= (PU_MANA);
5373 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
5380 bool curse_weapon(bool force, int slot)
5382 /* Curse the weapon */
5383 return curse_weapon_object(force, &inventory[slot]);
5388 * Enchant some bolts
5390 bool brand_bolts(void)
5394 /* Use the first acceptable bolts */
5395 for (i = 0; i < INVEN_PACK; i++)
5397 object_type *o_ptr = &inventory[i];
5399 /* Skip non-bolts */
5400 if (o_ptr->tval != TV_BOLT) continue;
5402 /* Skip artifacts and ego-items */
5403 if (object_is_artifact(o_ptr) || object_is_ego(o_ptr))
5406 /* Skip cursed/broken items */
5407 if (object_is_cursed(o_ptr) || object_is_broken(o_ptr)) continue;
5410 if (randint0(100) < 75) continue;
5414 msg_print("¥¯¥í¥¹¥Ü¥¦¤ÎÌ𤬱ê¤Î¥ª¡¼¥é¤ËÊñ¤Þ¤ì¤¿¡ª");
5416 msg_print("Your bolts are covered in a fiery aura!");
5421 o_ptr->name2 = EGO_FLAME;
5424 enchant(o_ptr, randint0(3) + 4, ENCH_TOHIT | ENCH_TODAM);
5431 if (flush_failure) flush();
5435 msg_print("±ê¤Ç¶¯²½¤¹¤ë¤Î¤Ë¼ºÇÔ¤·¤¿¡£");
5437 msg_print("The fiery enchantment failed.");
5447 * Helper function -- return a "nearby" race for polymorphing
5449 * Note that this function is one of the more "dangerous" ones...
5451 static s16b poly_r_idx(int r_idx)
5453 monster_race *r_ptr = &r_info[r_idx];
5455 int i, r, lev1, lev2;
5457 /* Hack -- Uniques/Questors never polymorph */
5458 if ((r_ptr->flags1 & RF1_UNIQUE) ||
5459 (r_ptr->flags1 & RF1_QUESTOR))
5462 /* Allowable range of "levels" for resulting monster */
5463 lev1 = r_ptr->level - ((randint1(20) / randint1(9)) + 1);
5464 lev2 = r_ptr->level + ((randint1(20) / randint1(9)) + 1);
5466 /* Pick a (possibly new) non-unique race */
5467 for (i = 0; i < 1000; i++)
5469 /* Pick a new race, using a level calculation */
5470 r = get_mon_num((dun_level + r_ptr->level) / 2 + 5);
5472 /* Handle failure */
5478 /* Ignore unique monsters */
5479 if (r_ptr->flags1 & RF1_UNIQUE) continue;
5481 /* Ignore monsters with incompatible levels */
5482 if ((r_ptr->level < lev1) || (r_ptr->level > lev2)) continue;
5484 /* Use that index */
5496 bool polymorph_monster(int y, int x)
5498 cave_type *c_ptr = &cave[y][x];
5499 monster_type *m_ptr = &m_list[c_ptr->m_idx];
5500 bool polymorphed = FALSE;
5502 int old_r_idx = m_ptr->r_idx;
5503 bool targeted = (target_who == c_ptr->m_idx) ? TRUE : FALSE;
5504 bool health_tracked = (p_ptr->health_who == c_ptr->m_idx) ? TRUE : FALSE;
5505 monster_type back_m;
5507 if (p_ptr->inside_arena || p_ptr->inside_battle) return (FALSE);
5509 if ((p_ptr->riding == c_ptr->m_idx) || (m_ptr->mflag2 & MFLAG2_KAGE)) return (FALSE);
5511 /* Memorize the monster before polymorphing */
5514 /* Pick a "new" monster race */
5515 new_r_idx = poly_r_idx(old_r_idx);
5517 /* Handle polymorph */
5518 if (new_r_idx != old_r_idx)
5521 bool preserve_hold_objects = back_m.hold_o_idx ? TRUE : FALSE;
5522 s16b this_o_idx, next_o_idx = 0;
5524 /* Get the monsters attitude */
5525 if (is_friendly(m_ptr)) mode |= PM_FORCE_FRIENDLY;
5526 if (is_pet(m_ptr)) mode |= PM_FORCE_PET;
5527 if (m_ptr->mflag2 & MFLAG2_NOPET) mode |= PM_NO_PET;
5529 /* Mega-hack -- ignore held objects */
5530 m_ptr->hold_o_idx = 0;
5532 /* "Kill" the "old" monster */
5533 delete_monster_idx(c_ptr->m_idx);
5535 /* Create a new monster (no groups) */
5536 if (place_monster_aux(0, y, x, new_r_idx, mode))
5538 m_list[hack_m_idx_ii].nickname = back_m.nickname;
5539 m_list[hack_m_idx_ii].parent_m_idx = back_m.parent_m_idx;
5540 m_list[hack_m_idx_ii].hold_o_idx = back_m.hold_o_idx;
5547 /* Placing the new monster failed */
5548 if (place_monster_aux(0, y, x, old_r_idx, (mode | PM_NO_KAGE | PM_IGNORE_TERRAIN)))
5550 m_list[hack_m_idx_ii] = back_m;
5552 /* Re-initialize monster process */
5555 else preserve_hold_objects = FALSE;
5558 /* Mega-hack -- preserve held objects */
5559 if (preserve_hold_objects)
5561 for (this_o_idx = back_m.hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
5563 /* Acquire object */
5564 object_type *o_ptr = &o_list[this_o_idx];
5566 /* Acquire next object */
5567 next_o_idx = o_ptr->next_o_idx;
5569 /* Held by new monster */
5570 o_ptr->held_m_idx = hack_m_idx_ii;
5573 else if (back_m.hold_o_idx) /* Failed (paranoia) */
5575 /* Delete objects */
5576 for (this_o_idx = back_m.hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
5578 /* Acquire next object */
5579 next_o_idx = o_list[this_o_idx].next_o_idx;
5581 /* Delete the object */
5582 delete_object_idx(this_o_idx);
5586 if (targeted) target_who = hack_m_idx_ii;
5587 if (health_tracked) health_track(hack_m_idx_ii);
5597 static bool dimension_door_aux(int x, int y)
5599 int plev = p_ptr->lev;
5601 p_ptr->energy_need += (s16b)((s32b)(60 - plev) * ENERGY_NEED() / 100L);
5603 if (!cave_player_teleportable_bold(y, x, 0L) ||
5604 (distance(y, x, py, px) > plev / 2 + 10) ||
5605 (!randint0(plev / 10 + 10)))
5607 p_ptr->energy_need += (s16b)((s32b)(60 - plev) * ENERGY_NEED() / 100L);
5608 teleport_player((plev + 2) * 2, TELEPORT_PASSIVE);
5615 teleport_player_to(y, x, 0L);
5626 bool dimension_door(void)
5630 /* Rerutn FALSE if cancelled */
5631 if (!tgt_pt(&x, &y)) return FALSE;
5633 if (dimension_door_aux(x, y)) return TRUE;
5636 msg_print("ÀºÎ¤«¤éʪ¼Á³¦¤ËÌá¤ë»þ¤¦¤Þ¤¯¤¤¤«¤Ê¤«¤Ã¤¿¡ª");
5638 msg_print("You fail to exit the astral plane correctly!");
5646 * Mirror Master's Dimension Door
5648 bool mirror_tunnel(void)
5652 /* Rerutn FALSE if cancelled */
5653 if (!tgt_pt(&x, &y)) return FALSE;
5655 if (dimension_door_aux(x, y)) return TRUE;
5658 msg_print("¶À¤ÎÀ¤³¦¤ò¤¦¤Þ¤¯Ä̤ì¤Ê¤«¤Ã¤¿¡ª");
5660 msg_print("You fail to pass the mirror plane correctly!");
5667 bool eat_magic(int power)
5669 object_type * o_ptr;
5672 int recharge_strength = 0;
5678 char o_name[MAX_NLEN];
5680 item_tester_hook = item_tester_hook_recharge;
5684 q = "¤É¤Î¥¢¥¤¥Æ¥à¤«¤éËâÎϤòµÛ¼ý¤·¤Þ¤¹¤«¡©";
5685 s = "ËâÎϤòµÛ¼ý¤Ç¤¤ë¥¢¥¤¥Æ¥à¤¬¤¢¤ê¤Þ¤»¤ó¡£";
5687 q = "Drain which item? ";
5688 s = "You have nothing to drain.";
5691 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return FALSE;
5695 o_ptr = &inventory[item];
5699 o_ptr = &o_list[0 - item];
5702 k_ptr = &k_info[o_ptr->k_idx];
5703 lev = k_info[o_ptr->k_idx].level;
5705 if (o_ptr->tval == TV_ROD)
5707 recharge_strength = ((power > lev/2) ? (power - lev/2) : 0) / 5;
5710 if (one_in_(recharge_strength))
5712 /* Activate the failure code. */
5717 if (o_ptr->timeout > (o_ptr->number - 1) * k_ptr->pval)
5720 msg_print("½¼Å¶Ãæ¤Î¥í¥Ã¥É¤«¤éËâÎϤòµÛ¼ý¤¹¤ë¤³¤È¤Ï¤Ç¤¤Þ¤»¤ó¡£");
5722 msg_print("You can't absorb energy from a discharged rod.");
5729 o_ptr->timeout += k_ptr->pval;
5735 /* All staffs, wands. */
5736 recharge_strength = (100 + power - lev) / 15;
5739 if (recharge_strength < 0) recharge_strength = 0;
5742 if (one_in_(recharge_strength))
5744 /* Activate the failure code. */
5749 if (o_ptr->pval > 0)
5751 p_ptr->csp += lev / 2;
5754 /* XXX Hack -- unstack if necessary */
5755 if ((o_ptr->tval == TV_STAFF) && (item >= 0) && (o_ptr->number > 1))
5760 /* Get local object */
5763 /* Obtain a local object */
5764 object_copy(q_ptr, o_ptr);
5766 /* Modify quantity */
5769 /* Restore the charges */
5772 /* Unstack the used item */
5774 p_ptr->total_weight -= q_ptr->weight;
5775 item = inven_carry(q_ptr);
5779 msg_print("¾ó¤ò¤Þ¤È¤á¤Ê¤ª¤·¤¿¡£");
5781 msg_print("You unstack your staff.");
5789 msg_print("µÛ¼ý¤Ç¤¤ëËâÎϤ¬¤¢¤ê¤Þ¤»¤ó¡ª");
5791 msg_print("There's no energy there to absorb!");
5795 if (!o_ptr->pval) o_ptr->ident |= IDENT_EMPTY;
5799 /* Inflict the penalties for failing a recharge. */
5802 /* Artifacts are never destroyed. */
5803 if (object_is_fixed_artifact(o_ptr))
5805 object_desc(o_name, o_ptr, OD_NAME_ONLY);
5807 msg_format("ËâÎϤ¬µÕή¤·¤¿¡ª%s¤Ï´°Á´¤ËËâÎϤò¼º¤Ã¤¿¡£", o_name);
5809 msg_format("The recharging backfires - %s is completely drained!", o_name);
5813 /* Artifact rods. */
5814 if (o_ptr->tval == TV_ROD)
5815 o_ptr->timeout = k_ptr->pval * o_ptr->number;
5817 /* Artifact wands and staffs. */
5818 else if ((o_ptr->tval == TV_WAND) || (o_ptr->tval == TV_STAFF))
5823 /* Get the object description */
5824 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
5826 /*** Determine Seriousness of Failure ***/
5828 /* Mages recharge objects more safely. */
5829 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)
5831 /* 10% chance to blow up one rod, otherwise draining. */
5832 if (o_ptr->tval == TV_ROD)
5834 if (one_in_(10)) fail_type = 2;
5837 /* 75% chance to blow up one wand, otherwise draining. */
5838 else if (o_ptr->tval == TV_WAND)
5840 if (!one_in_(3)) fail_type = 2;
5843 /* 50% chance to blow up one staff, otherwise no effect. */
5844 else if (o_ptr->tval == TV_STAFF)
5846 if (one_in_(2)) fail_type = 2;
5851 /* All other classes get no special favors. */
5854 /* 33% chance to blow up one rod, otherwise draining. */
5855 if (o_ptr->tval == TV_ROD)
5857 if (one_in_(3)) fail_type = 2;
5860 /* 20% chance of the entire stack, else destroy one wand. */
5861 else if (o_ptr->tval == TV_WAND)
5863 if (one_in_(5)) fail_type = 3;
5866 /* Blow up one staff. */
5867 else if (o_ptr->tval == TV_STAFF)
5873 /*** Apply draining and destruction. ***/
5875 /* Drain object or stack of objects. */
5878 if (o_ptr->tval == TV_ROD)
5881 msg_print("¥í¥Ã¥É¤ÏÇË»¤òÌȤ줿¤¬¡¢ËâÎϤÏÁ´¤Æ¼º¤Ê¤ï¤ì¤¿¡£");
5883 msg_format("You save your rod from destruction, but all charges are lost.", o_name);
5886 o_ptr->timeout = k_ptr->pval * o_ptr->number;
5888 else if (o_ptr->tval == TV_WAND)
5891 msg_format("%s¤ÏÇË»¤òÌȤ줿¤¬¡¢ËâÎϤ¬Á´¤Æ¼º¤ï¤ì¤¿¡£", o_name);
5893 msg_format("You save your %s from destruction, but all charges are lost.", o_name);
5898 /* Staffs aren't drained. */
5901 /* Destroy an object or one in a stack of objects. */
5904 if (o_ptr->number > 1)
5907 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬°ìËܲõ¤ì¤¿¡ª", o_name);
5909 msg_format("Wild magic consumes one of your %s!", o_name);
5912 /* Reduce rod stack maximum timeout, drain wands. */
5913 if (o_ptr->tval == TV_ROD) o_ptr->timeout = MIN(o_ptr->timeout, k_ptr->pval * (o_ptr->number - 1));
5914 else if (o_ptr->tval == TV_WAND) o_ptr->pval = o_ptr->pval * (o_ptr->number - 1) / o_ptr->number;
5919 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬²¿Ëܤ«²õ¤ì¤¿¡ª", o_name);
5921 msg_format("Wild magic consumes your %s!", o_name);
5924 /* Reduce and describe inventory */
5927 inven_item_increase(item, -1);
5928 inven_item_describe(item);
5929 inven_item_optimize(item);
5932 /* Reduce and describe floor item */
5935 floor_item_increase(0 - item, -1);
5936 floor_item_describe(0 - item);
5937 floor_item_optimize(0 - item);
5941 /* Destroy all members of a stack of objects. */
5944 if (o_ptr->number > 1)
5946 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬Á´¤Æ²õ¤ì¤¿¡ª", o_name);
5948 msg_format("Wild magic consumes all your %s!", o_name);
5953 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬²õ¤ì¤¿¡ª", o_name);
5955 msg_format("Wild magic consumes your %s!", o_name);
5960 /* Reduce and describe inventory */
5963 inven_item_increase(item, -999);
5964 inven_item_describe(item);
5965 inven_item_optimize(item);
5968 /* Reduce and describe floor item */
5971 floor_item_increase(0 - item, -999);
5972 floor_item_describe(0 - item);
5973 floor_item_optimize(0 - item);
5979 if (p_ptr->csp > p_ptr->msp)
5981 p_ptr->csp = p_ptr->msp;
5984 /* Redraw mana and hp */
5985 p_ptr->redraw |= (PR_MANA);
5987 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
5988 p_ptr->window |= (PW_INVEN);
5994 bool summon_kin_player(int level, int y, int x, u32b mode)
5996 bool pet = (bool)(mode & PM_FORCE_PET);
5997 if (!pet) mode |= PM_NO_PET;
5999 switch (p_ptr->mimic_form)
6002 switch (p_ptr->prace)
6006 case RACE_BARBARIAN:
6009 summon_kin_type = 'p';
6019 case RACE_MIND_FLAYER:
6022 summon_kin_type = 'h';
6025 summon_kin_type = 'o';
6027 case RACE_HALF_TROLL:
6028 summon_kin_type = 'T';
6030 case RACE_HALF_OGRE:
6031 summon_kin_type = 'O';
6033 case RACE_HALF_GIANT:
6034 case RACE_HALF_TITAN:
6036 summon_kin_type = 'P';
6039 summon_kin_type = 'y';
6042 summon_kin_type = 'K';
6045 summon_kin_type = 'k';
6048 if (one_in_(13)) summon_kin_type = 'U';
6049 else summon_kin_type = 'u';
6051 case RACE_DRACONIAN:
6052 summon_kin_type = 'd';
6056 summon_kin_type = 'g';
6059 if (one_in_(13)) summon_kin_type = 'L';
6060 else summon_kin_type = 's';
6063 summon_kin_type = 'z';
6066 summon_kin_type = 'V';
6069 summon_kin_type = 'G';
6072 summon_kin_type = 'I';
6075 summon_kin_type = '#';
6078 summon_kin_type = 'A';
6081 summon_kin_type = 'U';
6084 summon_kin_type = 'p';
6089 if (one_in_(13)) summon_kin_type = 'U';
6090 else summon_kin_type = 'u';
6092 case MIMIC_DEMON_LORD:
6093 summon_kin_type = 'U';
6096 summon_kin_type = 'V';
6099 return summon_specific((pet ? -1 : 0), y, x, level, SUMMON_KIN, mode);