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
23 * Teleport a monster, normally up to "dis" grids away.
25 * Attempt to move the monster at least "dis/2" grids away.
27 * But allow variation to prevent infinite loops.
29 bool teleport_away(int m_idx, int dis, bool dec_valour)
31 int oy, ox, d, i, min;
37 monster_type *m_ptr = &m_list[m_idx];
41 if (!m_ptr->r_idx) return (FALSE);
43 /* Save the old location */
47 /* Minimum distance */
51 (((p_ptr->chp * 10) / p_ptr->mhp) > 5) &&
52 (4+randint1(5) < ((p_ptr->chp * 10) / p_ptr->mhp)))
54 chg_virtue(V_VALOUR, -1);
62 /* Verify max distance */
63 if (dis > 200) dis = 200;
65 /* Try several locations */
66 for (i = 0; i < 500; i++)
68 /* Pick a (possibly illegal) location */
71 ny = rand_spread(oy, dis);
72 nx = rand_spread(ox, dis);
73 d = distance(oy, ox, ny, nx);
74 if ((d >= min) && (d <= dis)) break;
77 /* Ignore illegal locations */
78 if (!in_bounds(ny, nx)) continue;
80 /* Require "empty" floor space */
81 if (!cave_empty_bold(ny, nx)) continue;
83 /* Hack -- no teleport onto glyph of warding */
84 if (is_glyph_grid(&cave[ny][nx])) continue;
85 if (is_explosive_rune_grid(&cave[ny][nx])) continue;
87 /* ...nor onto the Pattern */
88 if ((cave[ny][nx].feat >= FEAT_PATTERN_START) &&
89 (cave[ny][nx].feat <= FEAT_PATTERN_XTRA2)) continue;
91 /* No teleporting into vaults and such */
92 if (!(p_ptr->inside_quest || p_ptr->inside_arena))
93 if (cave[ny][nx].info & CAVE_ICKY) continue;
95 /* This grid looks good */
102 /* Increase the maximum distance */
105 /* Decrease the minimum distance */
108 /* Stop after MAX_TRIES tries */
109 if (tries > MAX_TRIES) return (FALSE);
113 sound(SOUND_TPOTHER);
115 /* Update the new location */
116 cave[ny][nx].m_idx = m_idx;
118 /* Update the old location */
119 cave[oy][ox].m_idx = 0;
121 /* Move the monster */
125 /* Forget the counter target */
128 /* Update the monster (new location) */
129 update_mon(m_idx, TRUE);
131 /* Redraw the old grid */
134 /* Redraw the new grid */
137 if (r_info[m_ptr->r_idx].flags7 & (RF7_LITE_MASK | RF7_DARK_MASK))
138 p_ptr->update |= (PU_MON_LITE);
146 * Teleport monster next to a grid near the given location
148 void teleport_monster_to(int m_idx, int ty, int tx, int power)
150 int ny, nx, oy, ox, d, i, min;
154 monster_type *m_ptr = &m_list[m_idx];
158 if (!m_ptr->r_idx) return;
161 if (randint1(100) > power) return;
167 /* Save the old location */
171 /* Minimum distance */
174 /* Look until done */
175 while (look && --attempts)
177 /* Verify max distance */
178 if (dis > 200) dis = 200;
180 /* Try several locations */
181 for (i = 0; i < 500; i++)
185 /* Pick a (possibly illegal) location */
188 ny = rand_spread(ty, dis);
189 nx = rand_spread(tx, dis);
190 d = distance(ty, tx, ny, nx);
191 if ((d >= min) && (d <= dis)) break;
194 /* Ignore illegal locations */
195 if (!in_bounds(ny, nx)) continue;
197 /* Require "empty" floor space */
198 if (!cave_empty_bold(ny, nx)) continue;
200 c_ptr = &cave[ny][nx];
202 /* Hack -- no teleport onto glyph of warding */
203 if (is_glyph_grid(c_ptr)) continue;
204 if (is_explosive_rune_grid(c_ptr)) continue;
206 /* ...nor onto the Pattern */
207 if ((c_ptr->feat >= FEAT_PATTERN_START) &&
208 (c_ptr->feat <= FEAT_PATTERN_XTRA2)) continue;
210 /* No teleporting into vaults and such */
211 /* if (c_ptr->info & (CAVE_ICKY)) continue; */
213 /* This grid looks good */
220 /* Increase the maximum distance */
223 /* Decrease the minimum distance */
227 if (attempts < 1) return;
230 sound(SOUND_TPOTHER);
232 /* Update the new location */
233 cave[ny][nx].m_idx = m_idx;
235 /* Update the old location */
236 cave[oy][ox].m_idx = 0;
238 /* Move the monster */
242 /* Update the monster (new location) */
243 update_mon(m_idx, TRUE);
245 /* Redraw the old grid */
248 /* Redraw the new grid */
251 if (r_info[m_ptr->r_idx].flags7 & (RF7_LITE_MASK | RF7_DARK_MASK))
252 p_ptr->update |= (PU_MON_LITE);
257 * Teleport the player to a location up to "dis" grids away.
259 * If no such spaces are readily available, the distance may increase.
260 * Try very hard to move the player at least a quarter that distance.
262 * When long-range teleport effects are considered, there is a nasty
263 * tendency to "bounce" the player between two or three different spots
264 * because these are the only spots that are "far enough" way to satisfy
265 * the algorithm. Therefore, if the teleport distance is more than 50,
266 * we decrease the minimum acceptable distance to try to increase randomness.
269 static bool teleport_player_aux(int dis)
271 int d, i, min, ox, oy;
280 if (p_ptr->wild_mode) return FALSE;
282 if (p_ptr->anti_tele)
285 msg_print("ÉԻ׵ĤÊÎϤ¬¥Æ¥ì¥Ý¡¼¥È¤òËɤ¤¤À¡ª");
287 msg_print("A mysterious force prevents you from teleporting!");
293 if (dis > 200) dis = 200; /* To be on the safe side... */
295 /* Minimum distance */
296 min = dis / (dis > 50 ? 3 : 2);
298 /* Look until done */
303 /* Verify max distance */
304 if (dis > 200) dis = 200;
306 /* Try several locations */
307 for (i = 0; i < 500; i++)
309 /* Pick a (possibly illegal) location */
312 y = rand_spread(py, dis);
313 x = rand_spread(px, dis);
314 d = distance(py, px, y, x);
315 if ((d >= min) && (d <= dis)) break;
318 /* Ignore illegal locations */
319 if (!in_bounds(y, x)) continue;
321 /* Require "naked" floor space or trees */
322 if (!(cave_naked_bold(y, x) ||
323 (cave[y][x].feat == FEAT_TREES))) continue;
325 /* No teleporting into vaults and such */
326 if (cave[y][x].info & CAVE_ICKY) continue;
328 /* This grid looks good */
335 /* Increase the maximum distance */
338 /* Decrease the minimum distance */
341 /* Stop after MAX_TRIES tries */
342 if (tries > MAX_TRIES) return FALSE;
345 if (player_bold(y, x)) return FALSE;
348 sound(SOUND_TELEPORT);
351 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
352 msg_format("¡Ø¤³¤Ã¤Á¤À¤¡¡¢%s¡Ù", player_name);
355 /* Save the old location */
359 /* Move the player */
366 tmp = cave[py][px].m_idx;
367 cave[py][px].m_idx = cave[oy][ox].m_idx;
368 cave[oy][ox].m_idx = tmp;
369 m_list[p_ptr->riding].fy = py;
370 m_list[p_ptr->riding].fx = px;
371 update_mon(cave[py][px].m_idx, TRUE);
374 /* Redraw the old spot */
379 /* Redraw the new spot */
382 /* Check for new panel (redraw map) */
386 p_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MON_LITE);
388 /* Update the monsters */
389 p_ptr->update |= (PU_DISTANCE);
392 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
394 /* Handle stuff XXX XXX XXX */
400 void teleport_player(int dis)
404 /* Save the old location */
408 if (!teleport_player_aux(dis)) return;
410 /* Monsters with teleport ability may follow the player */
411 for (xx = -1; xx < 2; xx++)
413 for (yy = -1; yy < 2; yy++)
415 int tmp_m_idx = cave[oy+yy][ox+xx].m_idx;
417 /* A monster except your mount may follow */
418 if (tmp_m_idx && p_ptr->riding != tmp_m_idx)
420 monster_type *m_ptr = &m_list[tmp_m_idx];
421 monster_race *r_ptr = &r_info[m_ptr->r_idx];
424 * The latter limitation is to avoid
425 * totally unkillable suckers...
427 if ((r_ptr->flags6 & RF6_TPORT) &&
428 !(r_ptr->flagsr & RFR_RES_TELE))
430 if (!m_ptr->csleep) teleport_monster_to(tmp_m_idx, py, px, r_ptr->level);
438 void teleport_player_away(int m_idx, int dis)
442 /* Save the old location */
446 if (!teleport_player_aux(dis)) return;
448 /* Monsters with teleport ability may follow the player */
449 for (xx = -1; xx < 2; xx++)
451 for (yy = -1; yy < 2; yy++)
453 int tmp_m_idx = cave[oy+yy][ox+xx].m_idx;
455 /* A monster except your mount or caster may follow */
456 if (tmp_m_idx && (p_ptr->riding != tmp_m_idx) && (m_idx != tmp_m_idx))
458 monster_type *m_ptr = &m_list[tmp_m_idx];
459 monster_race *r_ptr = &r_info[m_ptr->r_idx];
462 * The latter limitation is to avoid
463 * totally unkillable suckers...
465 if ((r_ptr->flags6 & RF6_TPORT) &&
466 !(r_ptr->flagsr & RFR_RES_TELE))
468 if (!m_ptr->csleep) teleport_monster_to(tmp_m_idx, py, px, r_ptr->level);
477 * Teleport player to a grid near the given location
479 * This function is slightly obsessive about correctness.
480 * This function allows teleporting into vaults (!)
482 void teleport_player_to(int ny, int nx, bool no_tele)
484 int y, x, oy, ox, dis = 0, ctr = 0;
486 if (p_ptr->anti_tele && no_tele)
489 msg_print("ÉԻ׵ĤÊÎϤ¬¥Æ¥ì¥Ý¡¼¥È¤òËɤ¤¤À¡ª");
491 msg_print("A mysterious force prevents you from teleporting!");
497 /* Find a usable location */
500 /* Pick a nearby legal location */
503 y = rand_spread(ny, dis);
504 x = rand_spread(nx, dis);
505 if (in_bounds(y, x)) break;
508 /* Accept "naked" floor grids */
511 if (cave_naked_bold(y, x) || (((cave[y][x].feat == FEAT_DEEP_LAVA) || (cave[y][x].feat == FEAT_DEEP_WATER)) && !cave[y][x].m_idx)) break;
513 else if (cave_empty_bold(y, x) || player_bold(y, x)) break;
515 /* Occasionally advance the distance */
516 if (++ctr > (4 * dis * dis + 4 * dis + 1))
524 sound(SOUND_TELEPORT);
526 /* Save the old location */
530 /* Move the player */
537 tmp = cave[py][px].m_idx;
538 cave[py][px].m_idx = cave[oy][ox].m_idx;
539 cave[oy][ox].m_idx = tmp;
540 m_list[p_ptr->riding].fy = py;
541 m_list[p_ptr->riding].fx = px;
542 update_mon(cave[py][px].m_idx, TRUE);
547 /* Redraw the old spot */
550 /* Redraw the new spot */
553 /* Check for new panel (redraw map) */
557 p_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MON_LITE);
559 /* Update the monsters */
560 p_ptr->update |= (PU_DISTANCE);
563 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
565 /* Handle stuff XXX XXX XXX */
570 void teleport_away_followable(int m_idx)
572 monster_type *m_ptr = &m_list[m_idx];
573 int oldfy = m_ptr->fy;
574 int oldfx = m_ptr->fx;
575 bool old_ml = m_ptr->ml;
576 int old_cdis = m_ptr->cdis;
578 teleport_away(m_idx, MAX_SIGHT * 2 + 5, FALSE);
580 if (old_ml && (old_cdis <= MAX_SIGHT) && !world_monster && los(py, px, oldfy, oldfx))
584 if ((p_ptr->muta1 & MUT1_VTELEPORT) || (p_ptr->pclass == CLASS_IMITATOR)) follow = TRUE;
587 u32b flgs[TR_FLAG_SIZE];
591 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
593 o_ptr = &inventory[i];
594 if (o_ptr->k_idx && !cursed_p(o_ptr))
596 object_flags(o_ptr, flgs);
597 if (have_flag(flgs, TR_TELEPORT))
609 if (get_check_strict("¤Ä¤¤¤Æ¤¤¤¤Þ¤¹¤«¡©", CHECK_OKAY_CANCEL))
611 if (get_check_strict("Do you follow it? ", CHECK_OKAY_CANCEL))
616 teleport_player(200);
620 msg_print("Failed!");
623 else teleport_player_to(m_ptr->fy, m_ptr->fx, TRUE);
624 p_ptr->energy_need += ENERGY_NEED();
632 * Teleport the player one level up or down (random when legal)
633 * Note: If m_idx <= 0, target is player.
635 void teleport_level(int m_idx)
641 if (m_idx <= 0) /* To player */
644 strcpy(m_name, "¤¢¤Ê¤¿");
646 strcpy(m_name, "you");
649 else /* To monster */
651 monster_type *m_ptr = &m_list[m_idx];
653 /* Get the monster name (or "it") */
654 monster_desc(m_name, m_ptr, 0);
659 /* No effect in some case */
660 if (TELE_LEVEL_IS_INEFF(m_idx))
663 if (see_m) msg_print("¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡£");
665 if (see_m) msg_print("There is no effect.");
671 if ((m_idx <= 0) && p_ptr->anti_tele) /* To player */
674 msg_print("ÉԻ׵ĤÊÎϤ¬¥Æ¥ì¥Ý¡¼¥È¤òËɤ¤¤À¡ª");
676 msg_print("A mysterious force prevents you from teleporting!");
681 /* Choose up or down */
682 if (randint0(100) < 50) go_up = TRUE;
685 if ((m_idx <= 0) && p_ptr->wizard)
687 if (get_check("Force to go up? ")) go_up = TRUE;
688 else if (get_check("Force to go down? ")) go_up = FALSE;
692 if ((ironman_downward && (m_idx <= 0)) || (dun_level <= d_info[dungeon_type].mindepth))
695 if (see_m) msg_format("%^s¤Ï¾²¤òÆͤÇˤäÆÄÀ¤ó¤Ç¤¤¤¯¡£", m_name);
697 if (see_m) msg_format("%^s sink%s through the floor.", m_name, (m_idx <= 0) ? "" : "s");
699 if (m_idx <= 0) /* To player */
703 dungeon_type = p_ptr->recall_dungeon;
708 if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, 1, NULL);
710 if (autosave_l) do_cmd_save_game(TRUE);
714 dun_level = d_info[dungeon_type].mindepth;
715 prepare_change_floor_mode(CFM_RAND_PLACE | CFM_CLEAR_ALL);
719 prepare_change_floor_mode(CFM_DOWN | CFM_RAND_PLACE | CFM_RAND_CONNECT);
723 p_ptr->leaving = TRUE;
728 else if (quest_number(dun_level) || (dun_level >= d_info[dungeon_type].maxdepth))
731 if (see_m) msg_format("%^s¤ÏÅ·°æ¤òÆͤÇˤäÆÃè¤ØÉ⤤¤Æ¤¤¤¯¡£", m_name);
733 if (see_m) msg_format("%^s rise%s up through the ceiling.", m_name, (m_idx <= 0) ? "" : "s");
737 if (m_idx <= 0) /* To player */
739 if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, -1, NULL);
741 if (autosave_l) do_cmd_save_game(TRUE);
743 prepare_change_floor_mode(CFM_UP | CFM_RAND_PLACE | CFM_RAND_CONNECT);
748 p_ptr->inside_quest = 0;
749 p_ptr->leaving = TRUE;
755 if (see_m) msg_format("%^s¤ÏÅ·°æ¤òÆͤÇˤäÆÃè¤ØÉ⤤¤Æ¤¤¤¯¡£", m_name);
757 if (see_m) msg_format("%^s rise%s up through the ceiling.", m_name, (m_idx <= 0) ? "" : "s");
761 if (m_idx <= 0) /* To player */
763 if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, -1, NULL);
765 if (autosave_l) do_cmd_save_game(TRUE);
767 prepare_change_floor_mode(CFM_UP | CFM_RAND_PLACE | CFM_RAND_CONNECT);
770 p_ptr->leaving = TRUE;
776 if (see_m) msg_format("%^s¤Ï¾²¤òÆͤÇˤäÆÄÀ¤ó¤Ç¤¤¤¯¡£", m_name);
778 if (see_m) msg_format("%^s sink%s through the floor.", m_name, (m_idx <= 0) ? "" : "s");
781 if (m_idx <= 0) /* To player */
783 /* Never reach this code on the surface */
784 /* if (!dun_level) dungeon_type = p_ptr->recall_dungeon; */
786 if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, 1, NULL);
788 if (autosave_l) do_cmd_save_game(TRUE);
790 prepare_change_floor_mode(CFM_DOWN | CFM_RAND_PLACE | CFM_RAND_CONNECT);
793 p_ptr->leaving = TRUE;
797 /* Monster level teleportation is simple deleting now */
800 monster_type *m_ptr = &m_list[m_idx];
802 /* Check for quest completion */
803 check_quest_completion(m_ptr);
805 if (record_named_pet && is_pet(m_ptr) && m_ptr->nickname)
809 monster_desc(m2_name, m_ptr, MD_INDEF_VISIBLE);
810 do_cmd_write_nikki(NIKKI_NAMED_PET, 8, m2_name);
813 delete_monster_idx(m_idx);
817 sound(SOUND_TPLEVEL);
822 static int choose_dungeon(cptr note)
828 /* Allocate the "dun" array */
829 C_MAKE(dun, max_d_idx, s16b);
832 for(i = 1; i < max_d_idx; i++)
837 if (!d_info[i].maxdepth) continue;
838 if (!max_dlv[i]) continue;
839 if (d_info[i].final_guardian)
841 if (!r_info[d_info[i].final_guardian].max_num) seiha = TRUE;
843 else if (max_dlv[i] == d_info[i].maxdepth) seiha = TRUE;
846 sprintf(buf," %c) %c%-12s : ºÇÂç %d ³¬", 'a'+num, seiha ? '!' : ' ', d_name + d_info[i].name, max_dlv[i]);
848 sprintf(buf," %c) %c%-16s : Max level %d", 'a'+num, seiha ? '!' : ' ', d_name + d_info[i].name, max_dlv[i]);
854 prt(format("¤É¤Î¥À¥ó¥¸¥ç¥ó%s¤·¤Þ¤¹¤«:", note), 0, 0);
856 prt(format("Which dungeon do you %s?: ", note), 0, 0);
863 /* Free the "dun" array */
864 C_KILL(dun, max_d_idx, s16b);
869 if (i >= 'a' && i <('a'+num))
871 select_dungeon = dun[i-'a'];
878 /* Free the "dun" array */
879 C_KILL(dun, max_d_idx, s16b);
881 return select_dungeon;
886 * Recall the player to town or dungeon
888 bool recall_player(int turns)
891 * TODO: Recall the player to the last
892 * visited town when in the wilderness
896 if (p_ptr->inside_arena || ironman_downward)
899 msg_print("²¿¤âµ¯¤³¤é¤Ê¤«¤Ã¤¿¡£");
901 msg_print("Nothing happens.");
907 if (dun_level && (max_dlv[dungeon_type] > dun_level) && !p_ptr->inside_quest && !p_ptr->word_recall)
910 if (get_check("¤³¤³¤ÏºÇ¿¼Åþ㳬¤è¤êÀõ¤¤³¬¤Ç¤¹¡£¤³¤Î³¬¤ËÌá¤Ã¤ÆÍè¤Þ¤¹¤«¡© "))
912 if (get_check("Reset recall depth? "))
915 max_dlv[dungeon_type] = dun_level;
918 do_cmd_write_nikki(NIKKI_TRUMP, dungeon_type, "µ¢´Ô¤Î¤È¤¤Ë");
920 do_cmd_write_nikki(NIKKI_TRUMP, dungeon_type, "when recall from dungeon");
925 if (!p_ptr->word_recall)
931 select_dungeon = choose_dungeon("¤Ëµ¢´Ô");
933 select_dungeon = choose_dungeon("recall");
935 if (!select_dungeon) return FALSE;
936 p_ptr->recall_dungeon = select_dungeon;
938 p_ptr->word_recall = turns;
940 msg_print("²ó¤ê¤ÎÂ絤¤¬Ä¥¤ê¤Ä¤á¤Æ¤¤¿...");
942 msg_print("The air about you becomes charged...");
945 p_ptr->redraw |= (PR_STATUS);
949 p_ptr->word_recall = 0;
951 msg_print("Ä¥¤ê¤Ä¤á¤¿Â絤¤¬Î®¤ìµî¤Ã¤¿...");
953 msg_print("A tension leaves the air around you...");
956 p_ptr->redraw |= (PR_STATUS);
962 bool word_of_recall(void)
964 return(recall_player(randint0(21) + 15));
968 bool reset_recall(void)
970 int select_dungeon, dummy = 0;
975 select_dungeon = choose_dungeon("¤ò¥»¥Ã¥È");
977 select_dungeon = choose_dungeon("reset");
981 if (ironman_downward)
984 msg_print("²¿¤âµ¯¤³¤é¤Ê¤«¤Ã¤¿¡£");
986 msg_print("Nothing happens.");
992 if (!select_dungeon) return FALSE;
995 sprintf(ppp, "²¿³¬¤Ë¥»¥Ã¥È¤·¤Þ¤¹¤« (%d-%d):", d_info[select_dungeon].mindepth, max_dlv[select_dungeon]);
997 sprintf(ppp, "Reset to which level (%d-%d): ", d_info[select_dungeon].mindepth, max_dlv[select_dungeon]);
1002 sprintf(tmp_val, "%d", MAX(dun_level, 1));
1004 /* Ask for a level */
1005 if (get_string(ppp, tmp_val, 10))
1007 /* Extract request */
1008 dummy = atoi(tmp_val);
1011 if (dummy < 1) dummy = 1;
1014 if (dummy > max_dlv[select_dungeon]) dummy = max_dlv[select_dungeon];
1015 if (dummy < d_info[select_dungeon].mindepth) dummy = d_info[select_dungeon].mindepth;
1017 max_dlv[select_dungeon] = dummy;
1019 if (record_maxdepth)
1021 do_cmd_write_nikki(NIKKI_TRUMP, select_dungeon, "¥Õ¥í¥¢¡¦¥ê¥»¥Ã¥È¤Ç");
1023 do_cmd_write_nikki(NIKKI_TRUMP, select_dungeon, "using a scroll of reset recall");
1025 /* Accept request */
1027 msg_format("%s¤Îµ¢´Ô¥ì¥Ù¥ë¤ò %d ³¬¤Ë¥»¥Ã¥È¡£", d_name+d_info[select_dungeon].name, dummy, dummy * 50);
1029 msg_format("Recall depth set to level %d (%d').", dummy, dummy * 50);
1042 * Apply disenchantment to the player's stuff
1044 * XXX XXX XXX This function is also called from the "melee" code
1046 * Return "TRUE" if the player notices anything
1048 bool apply_disenchant(int mode)
1052 char o_name[MAX_NLEN];
1053 int to_h, to_d, to_a, pval;
1055 /* Pick a random slot */
1056 switch (randint1(8))
1058 case 1: t = INVEN_RARM; break;
1059 case 2: t = INVEN_LARM; break;
1060 case 3: t = INVEN_BOW; break;
1061 case 4: t = INVEN_BODY; break;
1062 case 5: t = INVEN_OUTER; break;
1063 case 6: t = INVEN_HEAD; break;
1064 case 7: t = INVEN_HANDS; break;
1065 case 8: t = INVEN_FEET; break;
1069 o_ptr = &inventory[t];
1071 /* No item, nothing happens */
1072 if (!o_ptr->k_idx) return (FALSE);
1074 /* Disenchant equipments only -- No disenchant on monster ball */
1075 if (o_ptr->tval < TV_BOW || TV_CARD < o_ptr->tval)
1078 /* Nothing to disenchant */
1079 if ((o_ptr->to_h <= 0) && (o_ptr->to_d <= 0) && (o_ptr->to_a <= 0) && (o_ptr->pval <= 1))
1081 /* Nothing to notice */
1086 /* Describe the object */
1087 object_desc(o_name, o_ptr, FALSE, 0);
1090 /* Artifacts have 71% chance to resist */
1091 if ((artifact_p(o_ptr) || o_ptr->art_name) && (randint0(100) < 71))
1095 msg_format("%s(%c)¤ÏÎô²½¤òÄ·¤ÍÊÖ¤·¤¿¡ª",o_name, index_to_label(t) );
1097 msg_format("Your %s (%c) resist%s disenchantment!",
1098 o_name, index_to_label(t),
1099 ((o_ptr->number != 1) ? "" : "s"));
1108 /* Memorize old value */
1114 /* Disenchant tohit */
1115 if (o_ptr->to_h > 0) o_ptr->to_h--;
1116 if ((o_ptr->to_h > 5) && (randint0(100) < 20)) o_ptr->to_h--;
1118 /* Disenchant todam */
1119 if (o_ptr->to_d > 0) o_ptr->to_d--;
1120 if ((o_ptr->to_d > 5) && (randint0(100) < 20)) o_ptr->to_d--;
1122 /* Disenchant toac */
1123 if (o_ptr->to_a > 0) o_ptr->to_a--;
1124 if ((o_ptr->to_a > 5) && (randint0(100) < 20)) o_ptr->to_a--;
1126 /* Disenchant pval (occasionally) */
1127 /* Unless called from wild_magic() */
1128 if ((o_ptr->pval > 1) && one_in_(13) && !(mode & 0x01)) o_ptr->pval--;
1130 if ((to_h != o_ptr->to_h) || (to_d != o_ptr->to_d) ||
1131 (to_a != o_ptr->to_a) || (pval != o_ptr->pval))
1135 msg_format("%s(%c)¤ÏÎô²½¤·¤Æ¤·¤Þ¤Ã¤¿¡ª",
1136 o_name, index_to_label(t) );
1138 msg_format("Your %s (%c) %s disenchanted!",
1139 o_name, index_to_label(t),
1140 ((o_ptr->number != 1) ? "were" : "was"));
1143 chg_virtue(V_HARMONY, 1);
1144 chg_virtue(V_ENCHANT, -2);
1146 /* Recalculate bonuses */
1147 p_ptr->update |= (PU_BONUS);
1150 p_ptr->window |= (PW_EQUIP | PW_PLAYER);
1160 void mutate_player(void)
1162 int max1, cur1, max2, cur2, ii, jj, i;
1164 /* Pick a pair of stats */
1166 for (jj = ii; jj == ii; jj = randint0(6)) /* loop */;
1168 max1 = p_ptr->stat_max[ii];
1169 cur1 = p_ptr->stat_cur[ii];
1170 max2 = p_ptr->stat_max[jj];
1171 cur2 = p_ptr->stat_cur[jj];
1173 p_ptr->stat_max[ii] = max2;
1174 p_ptr->stat_cur[ii] = cur2;
1175 p_ptr->stat_max[jj] = max1;
1176 p_ptr->stat_cur[jj] = cur1;
1180 if(p_ptr->stat_max[i] > p_ptr->stat_max_max[i]) p_ptr->stat_max[i] = p_ptr->stat_max_max[i];
1181 if(p_ptr->stat_cur[i] > p_ptr->stat_max_max[i]) p_ptr->stat_cur[i] = p_ptr->stat_max_max[i];
1184 p_ptr->update |= (PU_BONUS);
1191 void apply_nexus(monster_type *m_ptr)
1193 switch (randint1(7))
1195 case 1: case 2: case 3:
1197 teleport_player(200);
1203 teleport_player_to(m_ptr->fy, m_ptr->fx, TRUE);
1209 if (randint0(100) < p_ptr->skill_sav)
1212 msg_print("¤·¤«¤·¸úÎϤòÄ·¤ÍÊÖ¤·¤¿¡ª");
1214 msg_print("You resist the effects!");
1220 /* Teleport Level */
1227 if (randint0(100) < p_ptr->skill_sav)
1230 msg_print("¤·¤«¤·¸úÎϤòÄ·¤ÍÊÖ¤·¤¿¡ª");
1232 msg_print("You resist the effects!");
1239 msg_print("ÂΤ¬¤Í¤¸¤ì»Ï¤á¤¿...");
1241 msg_print("Your body starts to scramble...");
1252 * Charge a lite (torch or latern)
1254 void phlogiston(void)
1257 object_type * o_ptr = &inventory[INVEN_LITE];
1260 if ((o_ptr->tval == TV_LITE) && (o_ptr->sval == SV_LITE_LANTERN))
1262 max_flog = FUEL_LAMP;
1266 else if ((o_ptr->tval == TV_LITE) && (o_ptr->sval == SV_LITE_TORCH))
1268 max_flog = FUEL_TORCH;
1271 /* No torch to refill */
1275 msg_print("dzÁǤò¾ÃÈñ¤¹¤ë¥¢¥¤¥Æ¥à¤òÁõÈ÷¤·¤Æ¤¤¤Þ¤»¤ó¡£");
1277 msg_print("You are not wielding anything which uses phlogiston.");
1283 if (o_ptr->xtra4 >= max_flog)
1286 msg_print("¤³¤Î¥¢¥¤¥Æ¥à¤Ë¤Ï¤³¤ì°Ê¾ådzÁǤòÊä½¼¤Ç¤¤Þ¤»¤ó¡£");
1288 msg_print("No more phlogiston can be put in this item.");
1295 o_ptr->xtra4 += (max_flog / 2);
1299 msg_print("¾ÈÌÀÍÑ¥¢¥¤¥Æ¥à¤ËdzÁǤòÊä½¼¤·¤¿¡£");
1301 msg_print("You add phlogiston to your light item.");
1306 if (o_ptr->xtra4 >= max_flog)
1308 o_ptr->xtra4 = max_flog;
1310 msg_print("¾ÈÌÀÍÑ¥¢¥¤¥Æ¥à¤ÏËþ¥¿¥ó¤Ë¤Ê¤Ã¤¿¡£");
1312 msg_print("Your light item is full.");
1317 /* Recalculate torch */
1318 p_ptr->update |= (PU_TORCH);
1322 static bool item_tester_hook_weapon_nobow(object_type *o_ptr)
1324 switch (o_ptr->tval)
1334 if (o_ptr->sval != SV_DOKUBARI) return (TRUE);
1342 * Brand the current weapon
1344 void brand_weapon(int brand_type)
1351 /* Assume enchant weapon */
1352 item_tester_hook = item_tester_hook_weapon_nobow;
1353 item_tester_no_ryoute = TRUE;
1357 q = "¤É¤ÎÉð´ï¤ò¶¯²½¤·¤Þ¤¹¤«? ";
1358 s = "¶¯²½¤Ç¤¤ëÉð´ï¤¬¤Ê¤¤¡£";
1360 q = "Enchant which weapon? ";
1361 s = "You have nothing to enchant.";
1364 if (!get_item(&item, q, s, (USE_EQUIP))) return;
1366 /* Get the item (in the pack) */
1369 o_ptr = &inventory[item];
1372 /* Get the item (on the floor) */
1375 o_ptr = &o_list[0 - item];
1379 /* you can never modify artifacts / ego-items */
1380 /* you can never modify cursed items */
1381 /* TY: You _can_ modify broken items (if you're silly enough) */
1382 if (o_ptr->k_idx && !artifact_p(o_ptr) && !ego_item_p(o_ptr) &&
1383 !o_ptr->art_name && !cursed_p(o_ptr) &&
1384 !((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DOKUBARI)) &&
1385 !((o_ptr->tval == TV_POLEARM) && (o_ptr->sval == SV_DEATH_SCYTHE)) &&
1386 !((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DIAMOND_EDGE)))
1390 /* Let's get the name before it is changed... */
1391 char o_name[MAX_NLEN];
1392 object_desc(o_name, o_ptr, FALSE, 0);
1397 if (o_ptr->tval == TV_SWORD)
1400 act = "¤Ï±Ô¤µ¤òÁý¤·¤¿¡ª";
1402 act = "becomes very sharp!";
1405 o_ptr->name2 = EGO_SHARPNESS;
1406 o_ptr->pval = m_bonus(5, dun_level) + 1;
1408 if ((o_ptr->sval == SV_HAYABUSA) && (o_ptr->pval > 2))
1414 act = "¤ÏÇ˲õÎϤòÁý¤·¤¿¡ª";
1416 act = "seems very powerful.";
1419 o_ptr->name2 = EGO_EARTHQUAKES;
1420 o_ptr->pval = m_bonus(3, dun_level);
1425 act = "¤Ï¿Í´Ö¤Î·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
1427 act = "seems to be looking for humans!";
1430 o_ptr->name2 = EGO_SLAY_HUMAN;
1434 act = "¤ÏÅÅ·â¤Ëʤ¤ï¤ì¤¿¡ª";
1436 act = "covered with lightning!";
1439 o_ptr->name2 = EGO_BRAND_ELEC;
1443 act = "¤Ï»À¤Ëʤ¤ï¤ì¤¿¡ª";
1445 act = "coated with acid!";
1448 o_ptr->name2 = EGO_BRAND_ACID;
1452 act = "¤Ï¼Ù°¤Ê¤ë²øʪ¤òµá¤á¤Æ¤¤¤ë¡ª";
1454 act = "seems to be looking for evil monsters!";
1457 o_ptr->name2 = EGO_SLAY_EVIL;
1461 act = "¤Ï°ÛÀ¤³¦¤Î½»¿Í¤ÎÆùÂΤòµá¤á¤Æ¤¤¤ë¡ª";
1463 act = "seems to be looking for demons!";
1466 o_ptr->name2 = EGO_SLAY_DEMON;
1470 act = "¤Ï»Ó¤òµá¤á¤Æ¤¤¤ë¡ª";
1472 act = "seems to be looking for undead!";
1475 o_ptr->name2 = EGO_SLAY_UNDEAD;
1479 act = "¤Ïưʪ¤Î·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
1481 act = "seems to be looking for animals!";
1484 o_ptr->name2 = EGO_SLAY_ANIMAL;
1488 act = "¤Ï¥É¥é¥´¥ó¤Î·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
1490 act = "seems to be looking for dragons!";
1493 o_ptr->name2 = EGO_SLAY_DRAGON;
1497 act = "¤Ï¥È¥í¥ë¤Î·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
1499 act = "seems to be looking for troll!s";
1502 o_ptr->name2 = EGO_SLAY_TROLL;
1506 act = "¤Ï¥ª¡¼¥¯¤Î·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
1508 act = "seems to be looking for orcs!";
1511 o_ptr->name2 = EGO_SLAY_ORC;
1515 act = "¤Ïµð¿Í¤Î·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
1517 act = "seems to be looking for giants!";
1520 o_ptr->name2 = EGO_SLAY_GIANT;
1524 act = "¤ÏÈó¾ï¤ËÉÔ°ÂÄê¤Ë¤Ê¤Ã¤¿¤è¤¦¤À¡£";
1526 act = "seems very unstable now.";
1529 o_ptr->name2 = EGO_TRUMP;
1530 o_ptr->pval = randint1(2);
1534 act = "¤Ï·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
1536 act = "thirsts for blood!";
1539 o_ptr->name2 = EGO_VAMPIRIC;
1543 act = "¤ÏÆǤËʤ¤ï¤ì¤¿¡£";
1545 act = "is coated with poison.";
1548 o_ptr->name2 = EGO_BRAND_POIS;
1552 act = "¤Ï½ã¥í¥°¥ë¥¹¤Ë°û¤ß¹þ¤Þ¤ì¤¿¡£";
1554 act = "is engulfed in raw Logrus!";
1557 o_ptr->name2 = EGO_CHAOTIC;
1561 act = "¤Ï±ê¤Î¥·¡¼¥ë¥É¤Ëʤ¤ï¤ì¤¿¡ª";
1563 act = "is covered in a fiery shield!";
1566 o_ptr->name2 = EGO_BRAND_FIRE;
1570 act = "¤Ï¿¼¤¯Î䤿¤¤¥Ö¥ë¡¼¤Ëµ±¤¤¤¿¡ª";
1572 act = "glows deep, icy blue!";
1575 o_ptr->name2 = EGO_BRAND_COLD;
1580 msg_format("¤¢¤Ê¤¿¤Î%s%s", o_name, act);
1582 msg_format("Your %s %s", o_name, act);
1586 enchant(o_ptr, randint0(3) + 4, ENCH_TOHIT | ENCH_TODAM);
1588 o_ptr->discount = 99;
1589 chg_virtue(V_ENCHANT, 2);
1593 if (flush_failure) flush();
1596 msg_print("°ÀÉղä˼ºÇÔ¤·¤¿¡£");
1598 msg_print("The Branding failed.");
1601 chg_virtue(V_ENCHANT, -2);
1608 * Determine if a "feature" is a "vanishable"
1609 * Non-permanent walls, trees, mountains, or doors
1611 #define vanishable_feat(F) \
1612 ((!feat_floor(F) && (((F) < FEAT_PERM_EXTRA) || ((F) > FEAT_PERM_SOLID))) || \
1613 ((F) == FEAT_OPEN) || ((F) == FEAT_BROKEN))
1616 * Vanish all walls in this floor
1618 static bool vanish_dungeon(void)
1622 monster_type *m_ptr;
1626 /* Prevent vasishing of quest levels and town */
1627 if ((p_ptr->inside_quest && is_fixed_quest_idx(p_ptr->inside_quest)) || !dun_level)
1632 /* Scan all normal grids */
1633 for (y = 1; y < cur_hgt - 1; y++)
1635 for (x = 1; x < cur_wid - 1; x++)
1637 c_ptr = &cave[y][x];
1639 /* Seeing true feature code (ignore mimic) */
1642 /* Lose room and vault */
1643 c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1645 m_ptr = &m_list[c_ptr->m_idx];
1648 if (c_ptr->m_idx && m_ptr->csleep)
1650 /* Reset sleep counter */
1653 /* Notice the "waking up" */
1656 /* Acquire the monster name */
1657 monster_desc(m_name, m_ptr, 0);
1659 /* Dump a message */
1661 msg_format("%^s¤¬Ìܤò³Ð¤Þ¤·¤¿¡£", m_name);
1663 msg_format("%^s wakes up.", m_name);
1666 /* Redraw the health bar */
1667 if (p_ptr->health_who == c_ptr->m_idx) p_ptr->redraw |= (PR_HEALTH);
1668 if (p_ptr->riding == c_ptr->m_idx) p_ptr->redraw |= (PR_UHEALTH);
1672 /* Process all walls, doors and patterns */
1673 if (vanishable_feat(feat) || pattern_tile(y, x))
1676 cave_set_feat(y, x, floor_type[randint0(100)]);
1681 /* Special boundary walls -- Top and bottom */
1682 for (x = 0; x < cur_wid; x++)
1684 c_ptr = &cave[0][x];
1686 /* Lose room and vault */
1687 c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1689 /* Set boundary mimic if needed */
1690 if (c_ptr->mimic && vanishable_feat(c_ptr->mimic)) c_ptr->mimic = floor_type[randint0(100)];
1692 c_ptr = &cave[cur_hgt - 1][x];
1694 /* Lose room and vault */
1695 c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1697 /* Set boundary mimic if needed */
1698 if (c_ptr->mimic && vanishable_feat(c_ptr->mimic)) c_ptr->mimic = floor_type[randint0(100)];
1701 /* Special boundary walls -- Left and right */
1702 for (y = 1; y < (cur_hgt - 1); y++)
1704 c_ptr = &cave[y][0];
1706 /* Lose room and vault */
1707 c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1709 /* Set boundary mimic if needed */
1710 if (c_ptr->mimic && vanishable_feat(c_ptr->mimic)) c_ptr->mimic = floor_type[randint0(100)];
1712 c_ptr = &cave[y][cur_wid - 1];
1714 /* Lose room and vault */
1715 c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1717 /* Set boundary mimic if needed */
1718 if (c_ptr->mimic && vanishable_feat(c_ptr->mimic)) c_ptr->mimic = floor_type[randint0(100)];
1721 /* Mega-Hack -- Forget the view and lite */
1722 p_ptr->update |= (PU_UN_VIEW | PU_UN_LITE);
1725 p_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MON_LITE);
1727 /* Update the monsters */
1728 p_ptr->update |= (PU_MONSTERS);
1731 p_ptr->redraw |= (PR_MAP);
1734 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
1740 void call_the_(void)
1744 bool do_call = TRUE;
1746 for (i = 0; i < 9; i++)
1748 y = py + ddy_ddd[i];
1749 x = px + ddx_ddd[i];
1751 if (!cave_floor_bold(y, x) && !boundary_floor_bold(y, x))
1760 for (i = 1; i < 10; i++)
1762 if (i - 5) fire_ball(GF_ROCKET, i, 175, 2);
1765 for (i = 1; i < 10; i++)
1767 if (i - 5) fire_ball(GF_MANA, i, 175, 3);
1770 for (i = 1; i < 10; i++)
1772 if (i - 5) fire_ball(GF_NUKE, i, 175, 4);
1776 /* Prevent destruction of quest levels and town */
1777 else if ((p_ptr->inside_quest && is_fixed_quest_idx(p_ptr->inside_quest)) || !dun_level)
1780 msg_print("ÃÏÌ̤¬Íɤ줿¡£");
1782 msg_print("The ground trembles.");
1789 msg_format("¤¢¤Ê¤¿¤Ï%s¤òÊɤ˶᤹¤®¤ë¾ì½ê¤Ç¾§¤¨¤Æ¤·¤Þ¤Ã¤¿¡ª",
1790 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "µ§¤ê" : "¼öʸ"));
1791 msg_print("Â礤ÊÇúȯ²»¤¬¤¢¤Ã¤¿¡ª");
1793 msg_format("You %s the %s too close to a wall!",
1794 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "recite" : "cast"),
1795 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "prayer" : "spell"));
1796 msg_print("There is a loud explosion!");
1802 if (!vanish_dungeon()) msg_print("¥À¥ó¥¸¥ç¥ó¤Ï°ì½ÖÀŤޤêÊ֤ä¿¡£");
1804 if (!vanish_dungeon()) msg_print("The dungeon silences a moment.");
1809 if (destroy_area(py, px, 15 + p_ptr->lev + randint0(11), FALSE))
1811 msg_print("¥À¥ó¥¸¥ç¥ó¤¬Êø²õ¤·¤¿...");
1813 msg_print("The dungeon collapses...");
1818 msg_print("¥À¥ó¥¸¥ç¥ó¤ÏÂ礤¯Íɤ줿¡£");
1820 msg_print("The dungeon trembles.");
1825 take_hit(DAMAGE_NOESCAPE, 100 + randint1(150), "¼«»¦Åª¤Êµõ̵¾·Íè", -1);
1827 take_hit(DAMAGE_NOESCAPE, 100 + randint1(150), "a suicidal Call the Void", -1);
1834 * Fetch an item (teleport it right underneath the caster)
1836 void fetch(int dir, int wgt, bool require_los)
1841 char o_name[MAX_NLEN];
1843 /* Check to see if an object is already there */
1844 if (cave[py][px].o_idx)
1847 msg_print("¼«Ê¬¤Î¤β¼¤Ë¤¢¤ëʪ¤Ï¼è¤ì¤Þ¤»¤ó¡£");
1849 msg_print("You can't fetch when you're already standing on something.");
1856 if (dir == 5 && target_okay())
1861 if (distance(py, px, ty, tx) > MAX_RANGE)
1864 msg_print("¤½¤ó¤Ê¤Ë±ó¤¯¤Ë¤¢¤ëʪ¤Ï¼è¤ì¤Þ¤»¤ó¡ª");
1866 msg_print("You can't fetch something that far away!");
1872 c_ptr = &cave[ty][tx];
1874 /* We need an item to fetch */
1878 msg_print("¤½¤³¤Ë¤Ï²¿¤â¤¢¤ê¤Þ¤»¤ó¡£");
1880 msg_print("There is no object at this place.");
1886 /* No fetching from vault */
1887 if (c_ptr->info & CAVE_ICKY)
1890 msg_print("¥¢¥¤¥Æ¥à¤¬¥³¥ó¥È¥í¡¼¥ë¤ò³°¤ì¤ÆÍî¤Á¤¿¡£");
1892 msg_print("The item slips from your control.");
1898 /* We need to see the item */
1899 if (require_los && !player_has_los_bold(ty, tx))
1902 msg_print("¤½¤³¤Ï¤¢¤Ê¤¿¤Î»ë³¦¤ËÆþ¤Ã¤Æ¤¤¤Þ¤»¤ó¡£");
1904 msg_print("You have no direct line of sight to that location.");
1912 /* Use a direction */
1913 ty = py; /* Where to drop the item */
1920 c_ptr = &cave[ty][tx];
1922 if ((distance(py, px, ty, tx) > MAX_RANGE) ||
1923 !cave_floor_bold(ty, tx)) return;
1925 while (!c_ptr->o_idx);
1928 o_ptr = &o_list[c_ptr->o_idx];
1930 if (o_ptr->weight > wgt)
1932 /* Too heavy to 'fetch' */
1934 msg_print("¤½¤Î¥¢¥¤¥Æ¥à¤Ï½Å²á¤®¤Þ¤¹¡£");
1936 msg_print("The object is too heavy.");
1943 c_ptr->o_idx = o_ptr->next_o_idx;
1944 cave[py][px].o_idx = i; /* 'move' it */
1945 o_ptr->next_o_idx = 0;
1946 o_ptr->iy = (byte)py;
1947 o_ptr->ix = (byte)px;
1949 object_desc(o_name, o_ptr, TRUE, 0);
1951 msg_format("%^s¤¬¤¢¤Ê¤¿¤Î¸µ¤ËÈô¤ó¤Ç¤¤¿¡£", o_name);
1953 msg_format("%^s flies through the air to your feet.", o_name);
1958 p_ptr->redraw |= PR_MAP;
1962 void alter_reality(void)
1964 /* Ironman option */
1965 if (p_ptr->inside_arena || ironman_downward)
1968 msg_print("²¿¤âµ¯¤³¤é¤Ê¤«¤Ã¤¿¡£");
1970 msg_print("Nothing happens.");
1975 if (!p_ptr->alter_reality)
1977 int turns = randint0(21) + 15;
1979 p_ptr->alter_reality = turns;
1981 msg_print("²ó¤ê¤Î·Ê¿§¤¬ÊѤï¤ê»Ï¤á¤¿...");
1983 msg_print("The view around you begins to change...");
1986 p_ptr->redraw |= (PR_STATUS);
1990 p_ptr->alter_reality = 0;
1992 msg_print("·Ê¿§¤¬¸µ¤ËÌá¤Ã¤¿...");
1994 msg_print("The view around you got back...");
1997 p_ptr->redraw |= (PR_STATUS);
2004 * Leave a "glyph of warding" which prevents monster movement
2006 bool warding_glyph(void)
2009 if (!cave_clean_bold(py, px))
2012 msg_print("¾²¾å¤Î¥¢¥¤¥Æ¥à¤¬¼öʸ¤òÄ·¤ÍÊÖ¤·¤¿¡£");
2014 msg_print("The object resists the spell.");
2020 /* Create a glyph */
2021 cave[py][px].info |= CAVE_OBJECT;
2022 cave[py][px].mimic = FEAT_GLYPH;
2033 bool warding_mirror(void)
2036 if (!cave_clean_bold(py, px))
2039 msg_print("¾²¾å¤Î¥¢¥¤¥Æ¥à¤¬¼öʸ¤òÄ·¤ÍÊÖ¤·¤¿¡£");
2041 msg_print("The object resists the spell.");
2047 /* Create a mirror */
2048 cave[py][px].info |= CAVE_OBJECT;
2049 cave[py][px].mimic = FEAT_MIRROR;
2051 /* Turn on the light */
2052 cave[py][px].info |= CAVE_GLOW;
2065 * Leave an "explosive rune" which prevents monster movement
2067 bool explosive_rune(void)
2070 if (!cave_clean_bold(py, px))
2073 msg_print("¾²¾å¤Î¥¢¥¤¥Æ¥à¤¬¼öʸ¤òÄ·¤ÍÊÖ¤·¤¿¡£");
2075 msg_print("The object resists the spell.");
2081 /* Create a glyph */
2082 cave[py][px].info |= CAVE_OBJECT;
2083 cave[py][px].mimic = FEAT_MINOR_GLYPH;
2096 * Identify everything being carried.
2097 * Done by a potion of "self knowledge".
2099 void identify_pack(void)
2103 /* Simply identify and know every item */
2104 for (i = 0; i < INVEN_TOTAL; i++)
2106 object_type *o_ptr = &inventory[i];
2108 /* Skip non-objects */
2109 if (!o_ptr->k_idx) continue;
2112 identify_item(o_ptr);
2118 * Used by the "enchant" function (chance of failure)
2119 * (modified for Zangband, we need better stuff there...) -- TY
2121 static int enchant_table[16] =
2123 0, 10, 50, 100, 200,
2124 300, 400, 500, 650, 800,
2125 950, 987, 993, 995, 998,
2131 * Removes curses from items in inventory
2133 * Note that Items which are "Perma-Cursed" (The One Ring,
2134 * The Crown of Morgoth) can NEVER be uncursed.
2136 * Note that if "all" is FALSE, then Items which are
2137 * "Heavy-Cursed" (Mormegil, Calris, and Weapons of Morgul)
2138 * will not be uncursed.
2140 static int remove_curse_aux(int all)
2144 /* Attempt to uncurse items being worn */
2145 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
2147 object_type *o_ptr = &inventory[i];
2149 /* Skip non-objects */
2150 if (!o_ptr->k_idx) continue;
2152 /* Uncursed already */
2153 if (!cursed_p(o_ptr)) continue;
2155 /* Heavily Cursed Items need a special spell */
2156 if (!all && (o_ptr->curse_flags & TRC_HEAVY_CURSE)) continue;
2158 /* Perma-Cursed Items can NEVER be uncursed */
2159 if (o_ptr->curse_flags & TRC_PERMA_CURSE)
2162 o_ptr->curse_flags &= (TRC_CURSED | TRC_HEAVY_CURSE | TRC_PERMA_CURSE);
2167 o_ptr->curse_flags = 0L;
2169 /* Hack -- Assume felt */
2170 o_ptr->ident |= (IDENT_SENSE);
2173 o_ptr->feeling = FEEL_NONE;
2175 /* Recalculate the bonuses */
2176 p_ptr->update |= (PU_BONUS);
2179 p_ptr->window |= (PW_EQUIP);
2181 /* Count the uncursings */
2185 /* Return "something uncursed" */
2191 * Remove most curses
2193 bool remove_curse(void)
2195 return (remove_curse_aux(FALSE));
2201 bool remove_all_curse(void)
2203 return (remove_curse_aux(TRUE));
2208 * Turns an object into gold, gain some of its value in a shop
2217 char o_name[MAX_NLEN];
2218 char out_val[MAX_NLEN+40];
2222 /* Hack -- force destruction */
2223 if (command_arg > 0) force = TRUE;
2227 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò¶â¤ËÊѤ¨¤Þ¤¹¤«¡©";
2228 s = "¶â¤ËÊѤ¨¤é¤ì¤ëʪ¤¬¤¢¤ê¤Þ¤»¤ó¡£";
2230 q = "Turn which item to gold? ";
2231 s = "You have nothing to turn to gold.";
2234 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return (FALSE);
2236 /* Get the item (in the pack) */
2239 o_ptr = &inventory[item];
2242 /* Get the item (on the floor) */
2245 o_ptr = &o_list[0 - item];
2249 /* See how many items */
2250 if (o_ptr->number > 1)
2252 /* Get a quantity */
2253 amt = get_quantity(NULL, o_ptr->number);
2255 /* Allow user abort */
2256 if (amt <= 0) return FALSE;
2260 /* Describe the object */
2261 old_number = o_ptr->number;
2262 o_ptr->number = amt;
2263 object_desc(o_name, o_ptr, TRUE, 3);
2264 o_ptr->number = old_number;
2266 /* Verify unless quantity given */
2269 if (confirm_destroy || (object_value(o_ptr) > 0))
2271 /* Make a verification */
2273 sprintf(out_val, "ËÜÅö¤Ë%s¤ò¶â¤ËÊѤ¨¤Þ¤¹¤«¡©", o_name);
2275 sprintf(out_val, "Really turn %s to gold? ", o_name);
2278 if (!get_check(out_val)) return FALSE;
2282 /* Artifacts cannot be destroyed */
2283 if (!can_player_destroy_object(o_ptr))
2287 msg_format("%s¤ò¶â¤ËÊѤ¨¤ë¤³¤È¤Ë¼ºÇÔ¤·¤¿¡£", o_name);
2289 msg_format("You fail to turn %s to gold!", o_name);
2296 price = object_value_real(o_ptr);
2302 msg_format("%s¤ò¥Ë¥»¤Î¶â¤ËÊѤ¨¤¿¡£", o_name);
2304 msg_format("You turn %s to fool's gold.", o_name);
2312 if (amt > 1) price *= amt;
2314 if (price > 30000) price = 30000;
2316 msg_format("%s¤ò¡ð%d ¤Î¶â¤ËÊѤ¨¤¿¡£", o_name, price);
2318 msg_format("You turn %s to %ld coins worth of gold.", o_name, price);
2324 p_ptr->redraw |= (PR_GOLD);
2327 p_ptr->window |= (PW_PLAYER);
2331 /* Eliminate the item (from the pack) */
2334 inven_item_increase(item, -amt);
2335 inven_item_describe(item);
2336 inven_item_optimize(item);
2339 /* Eliminate the item (from the floor) */
2342 floor_item_increase(0 - item, -amt);
2343 floor_item_describe(0 - item);
2344 floor_item_optimize(0 - item);
2353 * Hook to specify "weapon"
2355 bool item_tester_hook_weapon(object_type *o_ptr)
2357 switch (o_ptr->tval)
2371 if (o_ptr->sval != SV_DOKUBARI) return (TRUE);
2378 static bool item_tester_hook_weapon2(object_type *o_ptr)
2380 switch (o_ptr->tval)
2400 * Hook to specify "armour"
2402 bool item_tester_hook_armour(object_type *o_ptr)
2404 switch (o_ptr->tval)
2425 * Check if an object is weapon or armour (but not arrow, bolt, or shot)
2427 bool item_tester_hook_weapon_armour(object_type *o_ptr)
2429 switch (o_ptr->tval)
2458 * Check if an object is nameless weapon or armour
2460 static bool item_tester_hook_nameless_weapon_armour(object_type *o_ptr)
2462 switch (o_ptr->tval)
2481 if (o_ptr->name1 || o_ptr->art_name || o_ptr->name2 || o_ptr->xtra3)
2483 if (object_known_p(o_ptr)) return FALSE;
2493 * Break the curse of an item
2495 static void break_curse(object_type *o_ptr)
2497 if (cursed_p(o_ptr) && !(o_ptr->curse_flags & TRC_PERMA_CURSE) && !(o_ptr->curse_flags & TRC_HEAVY_CURSE) && (randint0(100) < 25))
2500 msg_print("¤«¤±¤é¤ì¤Æ¤¤¤¿¼ö¤¤¤¬ÂǤÁÇˤé¤ì¤¿¡ª");
2502 msg_print("The curse is broken!");
2505 o_ptr->curse_flags = 0L;
2507 o_ptr->ident |= (IDENT_SENSE);
2509 o_ptr->feeling = FEEL_NONE;
2515 * Enchants a plus onto an item. -RAK-
2517 * Revamped! Now takes item pointer, number of times to try enchanting,
2518 * and a flag of what to try enchanting. Artifacts resist enchantment
2519 * some of the time, and successful enchantment to at least +0 might
2520 * break a curse on the item. -CFT-
2522 * Note that an item can technically be enchanted all the way to +15 if
2523 * you wait a very, very, long time. Going from +9 to +10 only works
2524 * about 5% of the time, and from +10 to +11 only about 1% of the time.
2526 * Note that this function can now be used on "piles" of items, and
2527 * the larger the pile, the lower the chance of success.
2529 bool enchant(object_type *o_ptr, int n, int eflag)
2531 int i, chance, prob;
2533 bool a = (artifact_p(o_ptr) || o_ptr->art_name);
2534 bool force = (eflag & ENCH_FORCE);
2537 /* Large piles resist enchantment */
2538 prob = o_ptr->number * 100;
2540 /* Missiles are easy to enchant */
2541 if ((o_ptr->tval == TV_BOLT) ||
2542 (o_ptr->tval == TV_ARROW) ||
2543 (o_ptr->tval == TV_SHOT))
2549 for (i = 0; i < n; i++)
2551 /* Hack -- Roll for pile resistance */
2552 if (!force && randint0(prob) >= 100) continue;
2554 /* Enchant to hit */
2555 if (eflag & ENCH_TOHIT)
2557 if (o_ptr->to_h < 0) chance = 0;
2558 else if (o_ptr->to_h > 15) chance = 1000;
2559 else chance = enchant_table[o_ptr->to_h];
2561 if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50))))
2566 /* only when you get it above -1 -CFT */
2567 if (o_ptr->to_h >= 0)
2572 /* Enchant to damage */
2573 if (eflag & ENCH_TODAM)
2575 if (o_ptr->to_d < 0) chance = 0;
2576 else if (o_ptr->to_d > 15) chance = 1000;
2577 else chance = enchant_table[o_ptr->to_d];
2579 if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50))))
2584 /* only when you get it above -1 -CFT */
2585 if (o_ptr->to_d >= 0)
2590 /* Enchant to armor class */
2591 if (eflag & ENCH_TOAC)
2593 if (o_ptr->to_a < 0) chance = 0;
2594 else if (o_ptr->to_a > 15) chance = 1000;
2595 else chance = enchant_table[o_ptr->to_a];
2597 if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50))))
2602 /* only when you get it above -1 -CFT */
2603 if (o_ptr->to_a >= 0)
2610 if (!res) return (FALSE);
2612 /* Recalculate bonuses */
2613 p_ptr->update |= (PU_BONUS);
2615 /* Combine / Reorder the pack (later) */
2616 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
2619 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
2630 * Enchant an item (in the inventory or on the floor)
2631 * Note that "num_ac" requires armour, else weapon
2632 * Returns TRUE if attempted, FALSE if cancelled
2634 bool enchant_spell(int num_hit, int num_dam, int num_ac)
2639 char o_name[MAX_NLEN];
2643 /* Assume enchant weapon */
2644 item_tester_hook = item_tester_hook_weapon;
2645 item_tester_no_ryoute = TRUE;
2647 /* Enchant armor if requested */
2648 if (num_ac) item_tester_hook = item_tester_hook_armour;
2652 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò¶¯²½¤·¤Þ¤¹¤«? ";
2653 s = "¶¯²½¤Ç¤¤ë¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
2655 q = "Enchant which item? ";
2656 s = "You have nothing to enchant.";
2659 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2661 /* Get the item (in the pack) */
2664 o_ptr = &inventory[item];
2667 /* Get the item (on the floor) */
2670 o_ptr = &o_list[0 - item];
2675 object_desc(o_name, o_ptr, FALSE, 0);
2679 msg_format("%s ¤ÏÌÀ¤ë¤¯µ±¤¤¤¿¡ª",
2682 msg_format("%s %s glow%s brightly!",
2683 ((item >= 0) ? "Your" : "The"), o_name,
2684 ((o_ptr->number > 1) ? "" : "s"));
2689 if (enchant(o_ptr, num_hit, ENCH_TOHIT)) okay = TRUE;
2690 if (enchant(o_ptr, num_dam, ENCH_TODAM)) okay = TRUE;
2691 if (enchant(o_ptr, num_ac, ENCH_TOAC)) okay = TRUE;
2697 if (flush_failure) flush();
2701 msg_print("¶¯²½¤Ë¼ºÇÔ¤·¤¿¡£");
2703 msg_print("The enchantment failed.");
2706 if (one_in_(3)) chg_virtue(V_ENCHANT, -1);
2709 chg_virtue(V_ENCHANT, 1);
2713 /* Something happened */
2718 bool artifact_scroll(void)
2723 char o_name[MAX_NLEN];
2727 item_tester_no_ryoute = TRUE;
2728 /* Enchant weapon/armour */
2729 item_tester_hook = item_tester_hook_nameless_weapon_armour;
2733 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò¶¯²½¤·¤Þ¤¹¤«? ";
2734 s = "¶¯²½¤Ç¤¤ë¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
2736 q = "Enchant which item? ";
2737 s = "You have nothing to enchant.";
2740 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2742 /* Get the item (in the pack) */
2745 o_ptr = &inventory[item];
2748 /* Get the item (on the floor) */
2751 o_ptr = &o_list[0 - item];
2756 object_desc(o_name, o_ptr, FALSE, 0);
2760 msg_format("%s ¤ÏâÁ¤¤¸÷¤òȯ¤·¤¿¡ª",o_name);
2762 msg_format("%s %s radiate%s a blinding light!",
2763 ((item >= 0) ? "Your" : "The"), o_name,
2764 ((o_ptr->number > 1) ? "" : "s"));
2767 if (o_ptr->name1 || o_ptr->art_name)
2770 msg_format("%s¤Ï´û¤ËÅÁÀâ¤Î¥¢¥¤¥Æ¥à¤Ç¤¹¡ª", o_name );
2772 msg_format("The %s %s already %s!",
2773 o_name, ((o_ptr->number > 1) ? "are" : "is"),
2774 ((o_ptr->number > 1) ? "artifacts" : "an artifact"));
2780 else if (o_ptr->name2)
2783 msg_format("%s¤Ï´û¤Ë̾¤Î¤¢¤ë¥¢¥¤¥Æ¥à¤Ç¤¹¡ª", o_name );
2785 msg_format("The %s %s already %s!",
2786 o_name, ((o_ptr->number > 1) ? "are" : "is"),
2787 ((o_ptr->number > 1) ? "ego items" : "an ego item"));
2793 else if (o_ptr->xtra3)
2796 msg_format("%s¤Ï´û¤Ë¶¯²½¤µ¤ì¤Æ¤¤¤Þ¤¹¡ª", o_name );
2798 msg_format("The %s %s already %s!",
2799 o_name, ((o_ptr->number > 1) ? "are" : "is"),
2800 ((o_ptr->number > 1) ? "customized items" : "a customized item"));
2806 if (o_ptr->number > 1)
2809 msg_print("Ê£¿ô¤Î¥¢¥¤¥Æ¥à¤ËËâË¡¤ò¤«¤±¤ë¤À¤±¤Î¥¨¥Í¥ë¥®¡¼¤Ï¤¢¤ê¤Þ¤»¤ó¡ª");
2810 msg_format("%d ¸Ä¤Î%s¤¬²õ¤ì¤¿¡ª",(o_ptr->number)-1, o_name);
2812 msg_print("Not enough enough energy to enchant more than one object!");
2813 msg_format("%d of your %s %s destroyed!",(o_ptr->number)-1, o_name, (o_ptr->number>2?"were":"was"));
2818 inven_item_increase(item, 1-(o_ptr->number));
2822 floor_item_increase(0-item, 1-(o_ptr->number));
2825 okay = create_artifact(o_ptr, TRUE);
2832 if (flush_failure) flush();
2836 msg_print("¶¯²½¤Ë¼ºÇÔ¤·¤¿¡£");
2838 msg_print("The enchantment failed.");
2841 if (one_in_(3)) chg_virtue(V_ENCHANT, -1);
2844 chg_virtue(V_ENCHANT, 1);
2848 /* Something happened */
2854 * Identify an object
2856 bool identify_item(object_type *o_ptr)
2858 bool old_known = FALSE;
2859 char o_name[MAX_NLEN];
2862 object_desc(o_name, o_ptr, TRUE, 3);
2864 if (o_ptr->ident & IDENT_KNOWN)
2867 if (!(o_ptr->ident & (IDENT_MENTAL)))
2869 if ((o_ptr->art_name) || (artifact_p(o_ptr)) || one_in_(5))
2870 chg_virtue(V_KNOWLEDGE, 1);
2873 /* Identify it fully */
2874 object_aware(o_ptr);
2875 object_known(o_ptr);
2877 /* Recalculate bonuses */
2878 p_ptr->update |= (PU_BONUS);
2880 /* Combine / Reorder the pack (later) */
2881 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
2884 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
2886 strcpy(record_o_name, o_name);
2890 object_desc(o_name, o_ptr, TRUE, 0);
2892 if(record_fix_art && !old_known && artifact_p(o_ptr))
2893 do_cmd_write_nikki(NIKKI_ART, 0, o_name);
2894 if(record_rand_art && !old_known && o_ptr->art_name)
2895 do_cmd_write_nikki(NIKKI_ART, 0, o_name);
2901 static bool item_tester_hook_identify(object_type *o_ptr)
2903 return (bool)!object_known_p(o_ptr);
2906 static bool item_tester_hook_identify_weapon_armour(object_type *o_ptr)
2908 if (object_known_p(o_ptr))
2910 return item_tester_hook_weapon_armour(o_ptr);
2914 * Identify an object in the inventory (or on the floor)
2915 * This routine does *not* automatically combine objects.
2916 * Returns TRUE if something was identified, else FALSE.
2918 bool ident_spell(bool only_equip)
2922 char o_name[MAX_NLEN];
2927 item_tester_no_ryoute = TRUE;
2930 item_tester_hook = item_tester_hook_identify_weapon_armour;
2932 item_tester_hook = item_tester_hook_identify;
2934 if (!can_get_item())
2938 item_tester_hook = item_tester_hook_weapon_armour;
2942 item_tester_hook = NULL;
2948 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò´ÕÄꤷ¤Þ¤¹¤«? ";
2949 s = "´ÕÄꤹ¤ë¤Ù¤¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
2951 q = "Identify which item? ";
2952 s = "You have nothing to identify.";
2955 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2957 /* Get the item (in the pack) */
2960 o_ptr = &inventory[item];
2963 /* Get the item (on the floor) */
2966 o_ptr = &o_list[0 - item];
2970 old_known = identify_item(o_ptr);
2973 object_desc(o_name, o_ptr, TRUE, 3);
2976 if (item >= INVEN_RARM)
2979 msg_format("%^s: %s(%c)¡£", describe_use(item), o_name, index_to_label(item));
2981 msg_format("%^s: %s (%c).", describe_use(item), o_name, index_to_label(item));
2987 msg_format("¥¶¥Ã¥¯Ãæ: %s(%c)¡£", o_name, index_to_label(item));
2989 msg_format("In your pack: %s (%c).", o_name, index_to_label(item));
2995 msg_format("¾²¾å: %s¡£", o_name);
2997 msg_format("On the ground: %s.", o_name);
3001 /* Auto-inscription/destroy */
3002 idx = is_autopick(o_ptr);
3003 auto_inscribe_item(item, idx);
3004 if (destroy_identify && !old_known)
3005 auto_destroy_item(item, idx);
3007 /* Something happened */
3013 * Mundanify an object in the inventory (or on the floor)
3014 * This routine does *not* automatically combine objects.
3015 * Returns TRUE if something was mundanified, else FALSE.
3017 bool mundane_spell(bool only_equip)
3023 if (only_equip) item_tester_hook = item_tester_hook_weapon_armour;
3024 item_tester_no_ryoute = TRUE;
3028 q = "¤É¤ì¤ò»È¤¤¤Þ¤¹¤«¡©";
3029 s = "»È¤¨¤ë¤â¤Î¤¬¤¢¤ê¤Þ¤»¤ó¡£";
3031 q = "Use which item? ";
3032 s = "You have nothing you can use.";
3035 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
3037 /* Get the item (in the pack) */
3040 o_ptr = &inventory[item];
3043 /* Get the item (on the floor) */
3046 o_ptr = &o_list[0 - item];
3051 msg_print("¤Þ¤Ð¤æ¤¤Á®¸÷¤¬Áö¤Ã¤¿¡ª");
3053 msg_print("There is a bright flash of light!");
3056 byte iy = o_ptr->iy; /* Y-position on map, or zero */
3057 byte ix = o_ptr->ix; /* X-position on map, or zero */
3058 s16b next_o_idx = o_ptr->next_o_idx; /* Next object in stack (if any) */
3059 byte marked = o_ptr->marked; /* Object is marked */
3060 s16b weight = o_ptr->number * o_ptr->weight;
3061 u16b inscription = o_ptr->inscription;
3064 object_prep(o_ptr, o_ptr->k_idx);
3068 o_ptr->next_o_idx = next_o_idx;
3069 o_ptr->marked = marked;
3070 o_ptr->inscription = inscription;
3071 if (item >= 0) p_ptr->total_weight += (o_ptr->weight - weight);
3075 /* Something happened */
3081 static bool item_tester_hook_identify_fully(object_type *o_ptr)
3083 return (bool)(!object_known_p(o_ptr) || !(o_ptr->ident & IDENT_MENTAL));
3086 static bool item_tester_hook_identify_fully_weapon_armour(object_type *o_ptr)
3088 if (!item_tester_hook_identify_fully(o_ptr))
3090 return item_tester_hook_weapon_armour(o_ptr);
3094 * Fully "identify" an object in the inventory -BEN-
3095 * This routine returns TRUE if an item was identified.
3097 bool identify_fully(bool only_equip)
3101 char o_name[MAX_NLEN];
3106 item_tester_no_ryoute = TRUE;
3108 item_tester_hook = item_tester_hook_identify_fully_weapon_armour;
3110 item_tester_hook = item_tester_hook_identify_fully;
3112 if (!can_get_item())
3115 item_tester_hook = item_tester_hook_weapon_armour;
3117 item_tester_hook = NULL;
3122 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò´ÕÄꤷ¤Þ¤¹¤«? ";
3123 s = "´ÕÄꤹ¤ë¤Ù¤¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
3125 q = "Identify which item? ";
3126 s = "You have nothing to identify.";
3129 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
3131 /* Get the item (in the pack) */
3134 o_ptr = &inventory[item];
3137 /* Get the item (on the floor) */
3140 o_ptr = &o_list[0 - item];
3144 old_known = identify_item(o_ptr);
3146 /* Mark the item as fully known */
3147 o_ptr->ident |= (IDENT_MENTAL);
3153 object_desc(o_name, o_ptr, TRUE, 3);
3156 if (item >= INVEN_RARM)
3159 msg_format("%^s: %s(%c)¡£", describe_use(item), o_name, index_to_label(item));
3161 msg_format("%^s: %s (%c).", describe_use(item), o_name, index_to_label(item));
3169 msg_format("¥¶¥Ã¥¯Ãæ: %s(%c)¡£", o_name, index_to_label(item));
3171 msg_format("In your pack: %s (%c).", o_name, index_to_label(item));
3177 msg_format("¾²¾å: %s¡£", o_name);
3179 msg_format("On the ground: %s.", o_name);
3183 /* Describe it fully */
3184 (void)screen_object(o_ptr, 0L);
3186 /* Auto-inscription/destroy */
3187 idx = is_autopick(o_ptr);
3188 auto_inscribe_item(item, idx);
3189 if (destroy_identify && !old_known)
3190 auto_destroy_item(item, idx);
3200 * Hook for "get_item()". Determine if something is rechargable.
3202 bool item_tester_hook_recharge(object_type *o_ptr)
3204 /* Recharge staffs */
3205 if (o_ptr->tval == TV_STAFF) return (TRUE);
3207 /* Recharge wands */
3208 if (o_ptr->tval == TV_WAND) return (TRUE);
3210 /* Hack -- Recharge rods */
3211 if (o_ptr->tval == TV_ROD) return (TRUE);
3219 * Recharge a wand/staff/rod from the pack or on the floor.
3220 * This function has been rewritten in Oangband and ZAngband.
3222 * Sorcery/Arcane -- Recharge --> recharge(plev * 4)
3223 * Chaos -- Arcane Binding --> recharge(90)
3225 * Scroll of recharging --> recharge(130)
3226 * Artifact activation/Thingol --> recharge(130)
3228 * It is harder to recharge high level, and highly charged wands,
3229 * staffs, and rods. The more wands in a stack, the more easily and
3230 * strongly they recharge. Staffs, however, each get fewer charges if
3233 * XXX XXX XXX Beware of "sliding index errors".
3235 bool recharge(int power)
3238 int recharge_strength, recharge_amount;
3247 char o_name[MAX_NLEN];
3249 /* Only accept legal items */
3250 item_tester_hook = item_tester_hook_recharge;
3254 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ËËâÎϤò½¼Å¶¤·¤Þ¤¹¤«? ";
3255 s = "ËâÎϤò½¼Å¶¤¹¤Ù¤¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
3257 q = "Recharge which item? ";
3258 s = "You have nothing to recharge.";
3261 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return (FALSE);
3263 /* Get the item (in the pack) */
3266 o_ptr = &inventory[item];
3269 /* Get the item (on the floor) */
3272 o_ptr = &o_list[0 - item];
3275 /* Get the object kind. */
3276 k_ptr = &k_info[o_ptr->k_idx];
3278 /* Extract the object "level" */
3279 lev = get_object_level(o_ptr);
3282 /* Recharge a rod */
3283 if (o_ptr->tval == TV_ROD)
3285 /* Extract a recharge strength by comparing object level to power. */
3286 recharge_strength = ((power > lev/2) ? (power - lev/2) : 0) / 5;
3290 if (one_in_(recharge_strength))
3292 /* Activate the failure code. */
3299 /* Recharge amount */
3300 recharge_amount = (power * damroll(3, 2));
3302 /* Recharge by that amount */
3303 if (o_ptr->timeout > recharge_amount)
3304 o_ptr->timeout -= recharge_amount;
3311 /* Recharge wand/staff */
3314 /* Extract a recharge strength by comparing object level to power.
3315 * Divide up a stack of wands' charges to calculate charge penalty.
3317 if ((o_ptr->tval == TV_WAND) && (o_ptr->number > 1))
3318 recharge_strength = (100 + power - lev -
3319 (8 * o_ptr->pval / o_ptr->number)) / 15;
3321 /* All staffs, unstacked wands. */
3322 else recharge_strength = (100 + power - lev -
3323 (8 * o_ptr->pval)) / 15;
3326 if (recharge_strength < 0) recharge_strength = 0;
3329 if (one_in_(recharge_strength))
3331 /* Activate the failure code. */
3335 /* If the spell didn't backfire, recharge the wand or staff. */
3338 /* Recharge based on the standard number of charges. */
3339 recharge_amount = randint1(1 + k_ptr->pval / 2);
3341 /* Multiple wands in a stack increase recharging somewhat. */
3342 if ((o_ptr->tval == TV_WAND) && (o_ptr->number > 1))
3345 (randint1(recharge_amount * (o_ptr->number - 1))) / 2;
3346 if (recharge_amount < 1) recharge_amount = 1;
3347 if (recharge_amount > 12) recharge_amount = 12;
3350 /* But each staff in a stack gets fewer additional charges,
3351 * although always at least one.
3353 if ((o_ptr->tval == TV_STAFF) && (o_ptr->number > 1))
3355 recharge_amount /= o_ptr->number;
3356 if (recharge_amount < 1) recharge_amount = 1;
3359 /* Recharge the wand or staff. */
3360 o_ptr->pval += recharge_amount;
3363 /* Hack -- we no longer "know" the item */
3364 o_ptr->ident &= ~(IDENT_KNOWN);
3366 /* Hack -- we no longer think the item is empty */
3367 o_ptr->ident &= ~(IDENT_EMPTY);
3372 /* Inflict the penalties for failing a recharge. */
3375 /* Artifacts are never destroyed. */
3376 if (artifact_p(o_ptr))
3378 object_desc(o_name, o_ptr, TRUE, 0);
3380 msg_format("ËâÎϤ¬µÕή¤·¤¿¡ª%s¤Ï´°Á´¤ËËâÎϤò¼º¤Ã¤¿¡£", o_name);
3382 msg_format("The recharging backfires - %s is completely drained!", o_name);
3386 /* Artifact rods. */
3387 if ((o_ptr->tval == TV_ROD) && (o_ptr->timeout < 10000))
3388 o_ptr->timeout = (o_ptr->timeout + 100) * 2;
3390 /* Artifact wands and staffs. */
3391 else if ((o_ptr->tval == TV_WAND) || (o_ptr->tval == TV_STAFF))
3396 /* Get the object description */
3397 object_desc(o_name, o_ptr, FALSE, 0);
3399 /*** Determine Seriousness of Failure ***/
3401 /* Mages recharge objects more safely. */
3402 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)
3404 /* 10% chance to blow up one rod, otherwise draining. */
3405 if (o_ptr->tval == TV_ROD)
3407 if (one_in_(10)) fail_type = 2;
3410 /* 75% chance to blow up one wand, otherwise draining. */
3411 else if (o_ptr->tval == TV_WAND)
3413 if (!one_in_(3)) fail_type = 2;
3416 /* 50% chance to blow up one staff, otherwise no effect. */
3417 else if (o_ptr->tval == TV_STAFF)
3419 if (one_in_(2)) fail_type = 2;
3424 /* All other classes get no special favors. */
3427 /* 33% chance to blow up one rod, otherwise draining. */
3428 if (o_ptr->tval == TV_ROD)
3430 if (one_in_(3)) fail_type = 2;
3433 /* 20% chance of the entire stack, else destroy one wand. */
3434 else if (o_ptr->tval == TV_WAND)
3436 if (one_in_(5)) fail_type = 3;
3439 /* Blow up one staff. */
3440 else if (o_ptr->tval == TV_STAFF)
3446 /*** Apply draining and destruction. ***/
3448 /* Drain object or stack of objects. */
3451 if (o_ptr->tval == TV_ROD)
3454 msg_print("ËâÎϤ¬µÕÊ®¼Í¤·¤Æ¡¢¥í¥Ã¥É¤«¤é¤µ¤é¤ËËâÎϤòµÛ¤¤¼è¤Ã¤Æ¤·¤Þ¤Ã¤¿¡ª");
3456 msg_print("The recharge backfires, draining the rod further!");
3459 if (o_ptr->timeout < 10000)
3460 o_ptr->timeout = (o_ptr->timeout + 100) * 2;
3462 else if (o_ptr->tval == TV_WAND)
3465 msg_format("%s¤ÏÇË»¤òÌȤ줿¤¬¡¢ËâÎϤ¬Á´¤Æ¼º¤ï¤ì¤¿¡£", o_name);
3467 msg_format("You save your %s from destruction, but all charges are lost.", o_name);
3472 /* Staffs aren't drained. */
3475 /* Destroy an object or one in a stack of objects. */
3478 if (o_ptr->number > 1)
3480 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬°ìËܲõ¤ì¤¿¡ª", o_name);
3482 msg_format("Wild magic consumes one of your %s!", o_name);
3487 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬²õ¤ì¤¿¡ª", o_name);
3489 msg_format("Wild magic consumes your %s!", o_name);
3493 /* Reduce rod stack maximum timeout, drain wands. */
3494 if (o_ptr->tval == TV_ROD) o_ptr->timeout = (o_ptr->number - 1) * k_ptr->pval;
3495 if (o_ptr->tval == TV_WAND) o_ptr->pval = 0;
3497 /* Reduce and describe inventory */
3500 inven_item_increase(item, -1);
3501 inven_item_describe(item);
3502 inven_item_optimize(item);
3505 /* Reduce and describe floor item */
3508 floor_item_increase(0 - item, -1);
3509 floor_item_describe(0 - item);
3510 floor_item_optimize(0 - item);
3514 /* Destroy all members of a stack of objects. */
3517 if (o_ptr->number > 1)
3519 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬Á´¤Æ²õ¤ì¤¿¡ª", o_name);
3521 msg_format("Wild magic consumes all your %s!", o_name);
3526 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬²õ¤ì¤¿¡ª", o_name);
3528 msg_format("Wild magic consumes your %s!", o_name);
3533 /* Reduce and describe inventory */
3536 inven_item_increase(item, -999);
3537 inven_item_describe(item);
3538 inven_item_optimize(item);
3541 /* Reduce and describe floor item */
3544 floor_item_increase(0 - item, -999);
3545 floor_item_describe(0 - item);
3546 floor_item_optimize(0 - item);
3552 /* Combine / Reorder the pack (later) */
3553 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
3556 p_ptr->window |= (PW_INVEN);
3558 /* Something was done */
3566 bool bless_weapon(void)
3570 u32b flgs[TR_FLAG_SIZE];
3571 char o_name[MAX_NLEN];
3574 item_tester_no_ryoute = TRUE;
3575 /* Assume enchant weapon */
3576 item_tester_hook = item_tester_hook_weapon2;
3580 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò½ËÊ¡¤·¤Þ¤¹¤«¡©";
3581 s = "½ËÊ¡¤Ç¤¤ëÉð´ï¤¬¤¢¤ê¤Þ¤»¤ó¡£";
3583 q = "Bless which weapon? ";
3584 s = "You have weapon to bless.";
3587 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR)))
3590 /* Get the item (in the pack) */
3593 o_ptr = &inventory[item];
3596 /* Get the item (on the floor) */
3599 o_ptr = &o_list[0 - item];
3604 object_desc(o_name, o_ptr, FALSE, 0);
3606 /* Extract the flags */
3607 object_flags(o_ptr, flgs);
3609 if (cursed_p(o_ptr))
3611 if (((o_ptr->curse_flags & TRC_HEAVY_CURSE) && (randint1(100) < 33)) ||
3612 (o_ptr->curse_flags & TRC_PERMA_CURSE))
3615 msg_format("%s¤òʤ¤¦¹õ¤¤¥ª¡¼¥é¤Ï½ËÊ¡¤òÄ·¤ÍÊÖ¤·¤¿¡ª",
3618 msg_format("The black aura on %s %s disrupts the blessing!",
3619 ((item >= 0) ? "your" : "the"), o_name);
3626 msg_format("%s ¤«¤é¼Ù°¤Ê¥ª¡¼¥é¤¬¾Ã¤¨¤¿¡£",
3629 msg_format("A malignant aura leaves %s %s.",
3630 ((item >= 0) ? "your" : "the"), o_name);
3635 o_ptr->curse_flags = 0L;
3637 /* Hack -- Assume felt */
3638 o_ptr->ident |= (IDENT_SENSE);
3641 o_ptr->feeling = FEEL_NONE;
3643 /* Recalculate the bonuses */
3644 p_ptr->update |= (PU_BONUS);
3647 p_ptr->window |= (PW_EQUIP);
3651 * Next, we try to bless it. Artifacts have a 1/3 chance of
3652 * being blessed, otherwise, the operation simply disenchants
3653 * them, godly power negating the magic. Ok, the explanation
3654 * is silly, but otherwise priests would always bless every
3655 * artifact weapon they find. Ego weapons and normal weapons
3656 * can be blessed automatically.
3658 if (have_flag(flgs, TR_BLESSED))
3661 msg_format("%s ¤Ï´û¤Ë½ËÊ¡¤µ¤ì¤Æ¤¤¤ë¡£",
3664 msg_format("%s %s %s blessed already.",
3665 ((item >= 0) ? "Your" : "The"), o_name,
3666 ((o_ptr->number > 1) ? "were" : "was"));
3672 if (!(o_ptr->art_name || o_ptr->name1 || o_ptr->name2) || one_in_(3))
3676 msg_format("%s¤Ïµ±¤¤¤¿¡ª",
3679 msg_format("%s %s shine%s!",
3680 ((item >= 0) ? "Your" : "The"), o_name,
3681 ((o_ptr->number > 1) ? "" : "s"));
3684 add_flag(o_ptr->art_flags, TR_BLESSED);
3685 o_ptr->discount = 99;
3689 bool dis_happened = FALSE;
3692 msg_print("¤½¤ÎÉð´ï¤Ï½ËÊ¡¤ò·ù¤Ã¤Æ¤¤¤ë¡ª");
3694 msg_print("The weapon resists your blessing!");
3698 /* Disenchant tohit */
3699 if (o_ptr->to_h > 0)
3702 dis_happened = TRUE;
3705 if ((o_ptr->to_h > 5) && (randint0(100) < 33)) o_ptr->to_h--;
3707 /* Disenchant todam */
3708 if (o_ptr->to_d > 0)
3711 dis_happened = TRUE;
3714 if ((o_ptr->to_d > 5) && (randint0(100) < 33)) o_ptr->to_d--;
3716 /* Disenchant toac */
3717 if (o_ptr->to_a > 0)
3720 dis_happened = TRUE;
3723 if ((o_ptr->to_a > 5) && (randint0(100) < 33)) o_ptr->to_a--;
3728 msg_print("¼þ°Ï¤¬ËÞÍǤÊÊ·°Ïµ¤¤ÇËþ¤Á¤¿...");
3730 msg_print("There is a static feeling in the air...");
3734 msg_format("%s ¤ÏÎô²½¤·¤¿¡ª",
3737 msg_format("%s %s %s disenchanted!",
3738 ((item >= 0) ? "Your" : "The"), o_name,
3739 ((o_ptr->number > 1) ? "were" : "was"));
3745 /* Recalculate bonuses */
3746 p_ptr->update |= (PU_BONUS);
3749 p_ptr->window |= (PW_EQUIP | PW_PLAYER);
3760 bool pulish_shield(void)
3764 u32b flgs[TR_FLAG_SIZE];
3765 char o_name[MAX_NLEN];
3768 item_tester_no_ryoute = TRUE;
3769 /* Assume enchant weapon */
3770 item_tester_tval = TV_SHIELD;
3774 q = "¤É¤Î½â¤òËᤤޤ¹¤«¡©";
3775 s = "Ë᤯½â¤¬¤¢¤ê¤Þ¤»¤ó¡£";
3777 q = "Pulish which weapon? ";
3778 s = "You have weapon to pulish.";
3781 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR)))
3784 /* Get the item (in the pack) */
3787 o_ptr = &inventory[item];
3790 /* Get the item (on the floor) */
3793 o_ptr = &o_list[0 - item];
3798 object_desc(o_name, o_ptr, FALSE, 0);
3800 /* Extract the flags */
3801 object_flags(o_ptr, flgs);
3803 if (o_ptr->k_idx && !artifact_p(o_ptr) && !ego_item_p(o_ptr) &&
3804 !o_ptr->art_name && !cursed_p(o_ptr) && (o_ptr->sval != SV_MIRROR_SHIELD))
3807 msg_format("%s¤Ïµ±¤¤¤¿¡ª", o_name);
3809 msg_format("%s %s shine%s!",
3810 ((item >= 0) ? "Your" : "The"), o_name,
3811 ((o_ptr->number > 1) ? "" : "s"));
3813 o_ptr->name2 = EGO_REFLECTION;
3814 enchant(o_ptr, randint0(3) + 4, ENCH_TOAC);
3816 o_ptr->discount = 99;
3817 chg_virtue(V_ENCHANT, 2);
3823 if (flush_failure) flush();
3826 msg_print("¼ºÇÔ¤·¤¿¡£");
3828 msg_print("Failed.");
3831 chg_virtue(V_ENCHANT, -2);
3840 * Potions "smash open" and cause an area effect when
3841 * (1) they are shattered while in the player's inventory,
3842 * due to cold (etc) attacks;
3843 * (2) they are thrown at a monster, or obstacle;
3844 * (3) they are shattered by a "cold ball" or other such spell
3845 * while lying on the floor.
3848 * who --- who caused the potion to shatter (0=player)
3849 * potions that smash on the floor are assumed to
3850 * be caused by no-one (who = 1), as are those that
3851 * shatter inside the player inventory.
3852 * (Not anymore -- I changed this; TY)
3853 * y, x --- coordinates of the potion (or player if
3854 * the potion was in her inventory);
3855 * o_ptr --- pointer to the potion object.
3857 bool potion_smash_effect(int who, int y, int x, int k_idx)
3864 object_kind *k_ptr = &k_info[k_idx];
3866 switch (k_ptr->sval)
3868 case SV_POTION_SALT_WATER:
3869 case SV_POTION_SLIME_MOLD:
3870 case SV_POTION_LOSE_MEMORIES:
3871 case SV_POTION_DEC_STR:
3872 case SV_POTION_DEC_INT:
3873 case SV_POTION_DEC_WIS:
3874 case SV_POTION_DEC_DEX:
3875 case SV_POTION_DEC_CON:
3876 case SV_POTION_DEC_CHR:
3877 case SV_POTION_WATER: /* perhaps a 'water' attack? */
3878 case SV_POTION_APPLE_JUICE:
3881 case SV_POTION_INFRAVISION:
3882 case SV_POTION_DETECT_INVIS:
3883 case SV_POTION_SLOW_POISON:
3884 case SV_POTION_CURE_POISON:
3885 case SV_POTION_BOLDNESS:
3886 case SV_POTION_RESIST_HEAT:
3887 case SV_POTION_RESIST_COLD:
3888 case SV_POTION_HEROISM:
3889 case SV_POTION_BESERK_STRENGTH:
3890 case SV_POTION_RES_STR:
3891 case SV_POTION_RES_INT:
3892 case SV_POTION_RES_WIS:
3893 case SV_POTION_RES_DEX:
3894 case SV_POTION_RES_CON:
3895 case SV_POTION_RES_CHR:
3896 case SV_POTION_INC_STR:
3897 case SV_POTION_INC_INT:
3898 case SV_POTION_INC_WIS:
3899 case SV_POTION_INC_DEX:
3900 case SV_POTION_INC_CON:
3901 case SV_POTION_INC_CHR:
3902 case SV_POTION_AUGMENTATION:
3903 case SV_POTION_ENLIGHTENMENT:
3904 case SV_POTION_STAR_ENLIGHTENMENT:
3905 case SV_POTION_SELF_KNOWLEDGE:
3906 case SV_POTION_EXPERIENCE:
3907 case SV_POTION_RESISTANCE:
3908 case SV_POTION_INVULNERABILITY:
3909 case SV_POTION_NEW_LIFE:
3910 /* All of the above potions have no effect when shattered */
3912 case SV_POTION_SLOWNESS:
3917 case SV_POTION_POISON:
3922 case SV_POTION_BLINDNESS:
3926 case SV_POTION_CONFUSION: /* Booze */
3930 case SV_POTION_SLEEP:
3934 case SV_POTION_RUINATION:
3935 case SV_POTION_DETONATIONS:
3937 dam = damroll(25, 25);
3940 case SV_POTION_DEATH:
3941 dt = GF_DEATH_RAY; /* !! */
3942 dam = k_ptr->level * 10;
3946 case SV_POTION_SPEED:
3949 case SV_POTION_CURE_LIGHT:
3951 dam = damroll(2, 3);
3953 case SV_POTION_CURE_SERIOUS:
3955 dam = damroll(4, 3);
3957 case SV_POTION_CURE_CRITICAL:
3958 case SV_POTION_CURING:
3960 dam = damroll(6, 3);
3962 case SV_POTION_HEALING:
3964 dam = damroll(10, 10);
3966 case SV_POTION_RESTORE_EXP:
3971 case SV_POTION_LIFE:
3973 dam = damroll(50, 50);
3976 case SV_POTION_STAR_HEALING:
3978 dam = damroll(50, 50);
3981 case SV_POTION_RESTORE_MANA: /* MANA */
3983 dam = damroll(10, 10);
3990 (void)project(who, radius, y, x, dam, dt,
3991 (PROJECT_JUMP | PROJECT_ITEM | PROJECT_KILL), -1);
3993 /* XXX those potions that explode need to become "known" */
3999 * Hack -- Display all known spells in a window
4001 * XXX XXX XXX Need to analyze size of the window.
4003 * XXX XXX XXX Need more color coding.
4005 void display_spell_list(void)
4018 /* They have too many spells to list */
4019 if (p_ptr->pclass == CLASS_SORCERER) return;
4020 if (p_ptr->pclass == CLASS_RED_MAGE) return;
4022 /* mind.c type classes */
4023 if ((p_ptr->pclass == CLASS_MINDCRAFTER) ||
4024 (p_ptr->pclass == CLASS_BERSERKER) ||
4025 (p_ptr->pclass == CLASS_NINJA) ||
4026 (p_ptr->pclass == CLASS_MIRROR_MASTER) ||
4027 (p_ptr->pclass == CLASS_FORCETRAINER))
4033 int plev = p_ptr->lev;
4039 bool use_hp = FALSE;
4041 /* Display a list of spells */
4044 put_str("̾Á°", y, x + 5);
4045 put_str("Lv MP ¼ºÎ¨ ¸ú²Ì", y, x + 35);
4047 put_str("Name", y, x + 5);
4048 put_str("Lv Mana Fail Info", y, x + 35);
4051 switch(p_ptr->pclass)
4053 case CLASS_MINDCRAFTER: use_mind = MIND_MINDCRAFTER;break;
4054 case CLASS_FORCETRAINER: use_mind = MIND_KI;break;
4055 case CLASS_BERSERKER: use_mind = MIND_BERSERKER; use_hp = TRUE; break;
4056 case CLASS_MIRROR_MASTER: use_mind = MIND_MIRROR_MASTER; break;
4057 case CLASS_NINJA: use_mind = MIND_NINJUTSU; use_hp = TRUE; break;
4058 default: use_mind = 0;break;
4061 /* Dump the spells */
4062 for (i = 0; i < MAX_MIND_POWERS; i++)
4064 byte a = TERM_WHITE;
4066 /* Access the available spell */
4067 spell = mind_powers[use_mind].info[i];
4068 if (spell.min_lev > plev) break;
4070 /* Get the failure rate */
4071 chance = spell.fail;
4073 /* Reduce failure rate by "effective" level adjustment */
4074 chance -= 3 * (p_ptr->lev - spell.min_lev);
4076 /* Reduce failure rate by INT/WIS adjustment */
4077 chance -= 3 * (adj_mag_stat[p_ptr->stat_ind[mp_ptr->spell_stat]] - 1);
4081 /* Not enough mana to cast */
4082 if (spell.mana_cost > p_ptr->csp)
4084 chance += 5 * (spell.mana_cost - p_ptr->csp);
4090 /* Not enough hp to cast */
4091 if (spell.mana_cost > p_ptr->chp)
4098 /* Extract the minimum failure rate */
4099 minfail = adj_mag_fail[p_ptr->stat_ind[mp_ptr->spell_stat]];
4101 /* Minimum failure rate */
4102 if (chance < minfail) chance = minfail;
4104 /* Stunning makes spells harder */
4105 if (p_ptr->stun > 50) chance += 25;
4106 else if (p_ptr->stun) chance += 15;
4108 /* Always a 5 percent chance of working */
4109 if (chance > 95) chance = 95;
4112 mindcraft_info(comment, use_mind, i);
4114 /* Dump the spell */
4115 sprintf(psi_desc, " %c) %-30s%2d %4d %3d%%%s",
4117 spell.min_lev, spell.mana_cost, chance, comment);
4119 Term_putstr(x, y + i + 1, -1, a, psi_desc);
4124 /* Cannot read spellbooks */
4125 if (REALM_NONE == p_ptr->realm1) return;
4127 /* Normal spellcaster with books */
4130 for (j = 0; j < ((p_ptr->realm2 > REALM_NONE) ? 2 : 1); j++)
4134 /* Reset vertical */
4137 /* Vertical location */
4138 y = (j < 3) ? 0 : (m[j - 3] + 2);
4140 /* Horizontal location */
4144 for (i = 0; i < 32; i++)
4146 byte a = TERM_WHITE;
4148 /* Access the spell */
4149 if (!is_magic((j < 1) ? p_ptr->realm1 : p_ptr->realm2))
4151 s_ptr = &technic_info[((j < 1) ? p_ptr->realm1 : p_ptr->realm2) - MIN_TECHNIC][i % 32];
4155 s_ptr = &mp_ptr->info[((j < 1) ? p_ptr->realm1 : p_ptr->realm2) - 1][i % 32];
4158 strcpy(name, spell_names[technic2magic((j < 1) ? p_ptr->realm1 : p_ptr->realm2)-1][i % 32]);
4161 if (s_ptr->slevel >= 99)
4165 strcpy(name, "(ȽÆÉÉÔǽ)");
4167 strcpy(name, "(illegible)");
4177 ((p_ptr->spell_forgotten1 & (1L << i))) :
4178 ((p_ptr->spell_forgotten2 & (1L << (i % 32)))))
4185 else if (!((j < 1) ?
4186 (p_ptr->spell_learned1 & (1L << i)) :
4187 (p_ptr->spell_learned2 & (1L << (i % 32)))))
4194 else if (!((j < 1) ?
4195 (p_ptr->spell_worked1 & (1L << i)) :
4196 (p_ptr->spell_worked2 & (1L << (i % 32)))))
4202 /* Dump the spell --(-- */
4203 sprintf(out_val, "%c/%c) %-20.20s",
4204 I2A(n / 8), I2A(n % 8), name);
4209 /* Dump onto the window */
4210 Term_putstr(x, m[j], -1, a, out_val);
4220 * Returns experience of a spell
4222 s16b experience_of_spell(int spell, int use_realm)
4224 if (p_ptr->pclass == CLASS_SORCERER) return SPELL_EXP_MASTER;
4225 else if (p_ptr->pclass == CLASS_RED_MAGE) return SPELL_EXP_SKILLED;
4226 else if (use_realm == p_ptr->realm1) return p_ptr->spell_exp[spell];
4227 else if (use_realm == p_ptr->realm2) return p_ptr->spell_exp[spell + 32];
4233 * Modify mana consumption rate using spell exp and p_ptr->dec_mana
4235 int mod_need_mana(int need_mana, int spell, int realm)
4237 #define MANA_CONST 2400
4239 #define DEC_MANA_DIV 3
4242 if ((realm > REALM_NONE) && (realm <= MAX_REALM))
4245 * need_mana defaults if spell exp equals SPELL_EXP_EXPERT and !p_ptr->dec_mana.
4246 * MANA_CONST is used to calculate need_mana effected from spell proficiency.
4248 need_mana = need_mana * (MANA_CONST + SPELL_EXP_EXPERT - experience_of_spell(spell, realm)) + (MANA_CONST - 1);
4249 need_mana *= p_ptr->dec_mana ? DEC_MANA_DIV : MANA_DIV;
4250 need_mana /= MANA_CONST * MANA_DIV;
4251 if (need_mana < 1) need_mana = 1;
4254 /* Non-realm magic */
4257 if (p_ptr->dec_mana) need_mana = (need_mana + 1) * DEC_MANA_DIV / MANA_DIV;
4269 * Modify spell fail rate
4270 * Using p_ptr->to_m_chance, p_ptr->dec_mana, p_ptr->easy_spell and p_ptr->heavy_spell
4272 int mod_spell_chance_1(int chance)
4274 chance += p_ptr->to_m_chance;
4276 if (p_ptr->heavy_spell) chance += 20;
4278 if (p_ptr->dec_mana && p_ptr->easy_spell) chance -= 4;
4279 else if (p_ptr->easy_spell) chance -= 3;
4280 else if (p_ptr->dec_mana) chance -= 2;
4287 * Modify spell fail rate (as "suffix" process)
4288 * Using p_ptr->dec_mana, p_ptr->easy_spell and p_ptr->heavy_spell
4289 * Note: variable "chance" cannot be negative.
4291 int mod_spell_chance_2(int chance)
4293 if (p_ptr->dec_mana) chance--;
4295 if (p_ptr->heavy_spell) chance += 5;
4297 return MAX(chance, 0);
4302 * Returns spell chance of failure for spell -RAK-
4304 s16b spell_chance(int spell, int use_realm)
4306 int chance, minfail;
4309 int penalty = (mp_ptr->spell_stat == A_WIS) ? 10 : 4;
4312 /* Paranoia -- must be literate */
4313 if (!mp_ptr->spell_book) return (100);
4315 if (use_realm == REALM_HISSATSU) return 0;
4317 /* Access the spell */
4318 if (!is_magic(use_realm))
4320 s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
4324 s_ptr = &mp_ptr->info[use_realm - 1][spell];
4327 /* Extract the base spell failure rate */
4328 chance = s_ptr->sfail;
4330 /* Reduce failure rate by "effective" level adjustment */
4331 chance -= 3 * (p_ptr->lev - s_ptr->slevel);
4333 /* Reduce failure rate by INT/WIS adjustment */
4334 chance -= 3 * (adj_mag_stat[p_ptr->stat_ind[mp_ptr->spell_stat]] - 1);
4337 chance += (MAX(r_info[m_list[p_ptr->riding].r_idx].level - p_ptr->skill_exp[GINOU_RIDING] / 100 - 10, 0));
4339 /* Extract mana consumption rate */
4340 need_mana = mod_need_mana(s_ptr->smana, spell, use_realm);
4342 /* Not enough mana to cast */
4343 if (need_mana > p_ptr->csp)
4345 chance += 5 * (need_mana - p_ptr->csp);
4348 if ((use_realm != p_ptr->realm1) && ((p_ptr->pclass == CLASS_MAGE) || (p_ptr->pclass == CLASS_PRIEST))) chance += 5;
4350 /* Extract the minimum failure rate */
4351 minfail = adj_mag_fail[p_ptr->stat_ind[mp_ptr->spell_stat]];
4354 * Non mage/priest characters never get too good
4355 * (added high mage, mindcrafter)
4357 if (mp_ptr->spell_xtra & MAGIC_FAIL_5PERCENT)
4359 if (minfail < 5) minfail = 5;
4362 /* Hack -- Priest prayer penalty for "edged" weapons -DGK */
4363 if (((p_ptr->pclass == CLASS_PRIEST) || (p_ptr->pclass == CLASS_SORCERER)) && p_ptr->icky_wield[0]) chance += 25;
4364 if (((p_ptr->pclass == CLASS_PRIEST) || (p_ptr->pclass == CLASS_SORCERER)) && p_ptr->icky_wield[1]) chance += 25;
4366 chance = mod_spell_chance_1(chance);
4368 if ((use_realm == REALM_NATURE) && ((p_ptr->align > 50) || (p_ptr->align < -50))) chance += penalty;
4369 if (((use_realm == REALM_LIFE) || (use_realm == REALM_CRUSADE)) && (p_ptr->align < -20)) chance += penalty;
4370 if (((use_realm == REALM_DEATH) || (use_realm == REALM_DAEMON)) && (p_ptr->align > 20)) chance += penalty;
4372 /* Minimum failure rate */
4373 if (chance < minfail) chance = minfail;
4375 /* Stunning makes spells harder */
4376 if (p_ptr->stun > 50) chance += 25;
4377 else if (p_ptr->stun) chance += 15;
4379 /* Always a 5 percent chance of working */
4380 if (chance > 95) chance = 95;
4382 if ((use_realm == p_ptr->realm1) || (use_realm == p_ptr->realm2)
4383 || (p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE))
4385 s16b exp = experience_of_spell(spell, use_realm);
4386 if (exp >= SPELL_EXP_EXPERT) chance--;
4387 if (exp >= SPELL_EXP_MASTER) chance--;
4390 /* Return the chance */
4391 return mod_spell_chance_2(chance);
4397 * Determine if a spell is "okay" for the player to cast or study
4398 * The spell must be legible, not forgotten, and also, to cast,
4399 * it must be known, and to study, it must not be known.
4401 bool spell_okay(int spell, bool learned, bool study_pray, int use_realm)
4405 /* Access the spell */
4406 if (!is_magic(use_realm))
4408 s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
4412 s_ptr = &mp_ptr->info[use_realm - 1][spell];
4415 /* Spell is illegal */
4416 if (s_ptr->slevel > p_ptr->lev) return (FALSE);
4418 /* Spell is forgotten */
4419 if ((use_realm == p_ptr->realm2) ?
4420 (p_ptr->spell_forgotten2 & (1L << spell)) :
4421 (p_ptr->spell_forgotten1 & (1L << spell)))
4427 if (p_ptr->pclass == CLASS_SORCERER) return (TRUE);
4428 if (p_ptr->pclass == CLASS_RED_MAGE) return (TRUE);
4430 /* Spell is learned */
4431 if ((use_realm == p_ptr->realm2) ?
4432 (p_ptr->spell_learned2 & (1L << spell)) :
4433 (p_ptr->spell_learned1 & (1L << spell)))
4436 return (!study_pray);
4439 /* Okay to study, not to cast */
4446 * Extra information on a spell -DRS-
4448 * We can use up to 14 characters of the buffer 'p'
4450 * The strings in this function were extracted from the code in the
4451 * functions "do_cmd_cast()" and "do_cmd_pray()" and may be dated.
4453 static void spell_info(char *p, int spell, int use_realm)
4455 int plev = p_ptr->lev;
4458 int orb = plev + (plev / ((p_ptr->pclass == CLASS_PRIEST ||
4459 p_ptr->pclass == CLASS_HIGH_MAGE ||
4460 p_ptr->pclass == CLASS_SORCERER) ? 2 : 4));
4462 int burst = plev + (plev / ((p_ptr->pclass == CLASS_MAGE ||
4463 p_ptr->pclass == CLASS_HIGH_MAGE ||
4464 p_ptr->pclass == CLASS_SORCERER) ? 2 : 4));
4466 cptr s_dam = "»½ý:";
4467 cptr s_dur = "´ü´Ö:";
4468 cptr s_range = "ÈÏ°Ï:";
4469 cptr s_heal = "²óÉü:";
4470 cptr s_random = "¥é¥ó¥À¥à";
4471 cptr s_delay = "ÃÙ±ä:";
4473 cptr s_dam = "dam ";
4474 cptr s_dur = "dur ";
4475 cptr s_range = "range ";
4476 cptr s_heal = "heal ";
4477 cptr s_random = "random";
4478 cptr s_delay = "delay ";
4483 /* Analyze the spell */
4486 case REALM_LIFE: /* Life */
4489 case 0: sprintf(p, " %s2d10", s_heal); break;
4490 case 1: sprintf(p, " %s12+d12", s_dur); break;
4491 case 2: sprintf(p, " %s%dd4", s_dam, 3 + ((plev - 1) / 5)); break;
4492 case 3: sprintf(p, " %s%d", s_dam, 10 + (plev / 2)); break;
4493 case 5: sprintf(p, " %s4d10", s_heal); break;
4494 case 9: sprintf(p, " %s%dd8", s_dam, 8 + ((plev - 1) / 5)); break;
4495 case 10: sprintf(p, " %s8d10", s_heal); break;
4496 case 11: sprintf(p, " %s20+d20", s_dur); break;
4497 case 14: sprintf(p, " %s300", s_heal); break;
4498 case 18: sprintf(p, " %sd%d", s_dam, 5 * plev); break;
4499 case 20: sprintf(p, " %s%dd15", s_dam, 5 + ((plev - 1) / 3)); break;
4500 case 21: sprintf(p, " %s15+d21", s_delay); break;
4501 case 29: sprintf(p, " %s2000", s_heal); break;
4502 case 31: sprintf(p, " %s%d+d%d", s_dur,(plev/2), (plev/2)); break;
4506 case REALM_SORCERY: /* Sorcery */
4509 case 1: sprintf(p, " %s10", s_range); break;
4510 case 3: sprintf(p, " %s%d", s_dam, 10 + (plev / 2)); break;
4511 case 5: sprintf(p, " %s%d", s_range, plev * 5); break;
4512 case 13: sprintf(p, " %s%d+d%d", s_dur, plev, plev + 20); break;
4513 case 18: sprintf(p, " %s25+d30", s_dur); break;
4514 case 22: sprintf(p, " %s15+d21", s_delay); break;
4515 case 23: sprintf(p, " %s%d", s_range, plev / 2 + 10); break;
4516 case 25: sprintf(p, " %s7d7+%d", s_dam, plev); break;
4518 case 26: sprintf(p, " ºÇÂç½ÅÎÌ:%d.%dkg", lbtokg1(plev * 15),lbtokg2(plev * 15)); break;
4520 case 26: sprintf(p, " max wgt %d", plev * 15 / 10); break;
4522 case 27: sprintf(p, " %s25+d30", s_dur); break;
4523 case 31: sprintf(p, " %s4+d4", s_dur); break;
4527 case REALM_NATURE: /* Nature */
4531 case 1: sprintf(p, " %s%dd4 ¼ÍÄø%d", s_dam, (3 + ((plev - 1) / 5)), plev/6+2); break;
4533 case 1: sprintf(p, " %s%dd4 rng %d", s_dam, (3 + ((plev - 1) / 5)), plev/6+2); break;
4535 case 4: sprintf(p, " %s%d", s_dam, 10 + (plev / 2)); break;
4536 case 6: sprintf(p, " %s20+d20", s_dur); break;
4537 case 7: sprintf(p, " %s2d8", s_heal); break;
4538 case 9: sprintf(p, " %s%dd8", s_dam, (3 + ((plev - 5) / 4))); break;
4539 case 11: sprintf(p, " %s%dd8", s_dam, (5 + ((plev - 5) / 4))); break;
4540 case 12: sprintf(p, " %s6d8", s_dam); break;
4541 case 15: sprintf(p, " %s500", s_heal); break;
4542 case 17: sprintf(p, " %s20+d30", s_dur); break;
4543 case 18: sprintf(p, " %s20+d20", s_dur); break;
4545 case 24: sprintf(p, " Ⱦ·Â:10"); break;
4547 case 24: sprintf(p, " rad 10"); break;
4549 case 26: sprintf(p, " %s%d", s_dam, 70 + plev * 3 / 2); break;
4550 case 27: sprintf(p, " %s%d", s_dam, 90 + plev * 3 / 2); break;
4551 case 28: sprintf(p, " %s%d", s_dam, 100 + plev * 3 / 2); break;
4552 case 29: sprintf(p, " %s75", s_dam); break;
4553 case 31: sprintf(p, " %s%d+%d", s_dam, 4 * plev, 100 + plev); break;
4557 case REALM_CHAOS: /* Chaos */
4560 case 0: sprintf(p, " %s%dd4", s_dam, 3 + ((plev - 1) / 5)); break;
4561 case 2: sprintf(p, " %s%d", s_dam, 10 + (plev / 2)); break;
4562 case 4: sprintf(p, " %s3d5+%d", s_dam, burst); break;
4563 case 5: sprintf(p, " %s%dd8", s_dam, (6 + ((plev - 5) / 4))); break;
4564 case 6: sprintf(p, " %s%dd8", s_dam, (8 + ((plev - 5) / 4))); break;
4565 case 7: sprintf(p, " %s%d", s_range, plev * 5); break;
4566 case 8: sprintf(p, " %s", s_random); break;
4567 case 9: sprintf(p, " %s%dd8", s_dam, (10 + ((plev - 5) / 4))); break;
4568 case 10: sprintf(p, " %s%d", s_dam, (60 + plev)/2); break;
4569 case 11: sprintf(p, " %s%dd8", s_dam, (11 + ((plev - 5) / 4))); break;
4570 case 12: sprintf(p, " %s%d", s_dam, 55 + plev); break;
4571 case 15: sprintf(p, " %s%d", s_dam, 99 + plev*2); break;
4572 case 17: sprintf(p, " %s%dd8", s_dam, (5 + (plev / 10))); break;
4573 case 19: sprintf(p, " %s%d", s_dam, 70 + plev); break;
4574 case 21: sprintf(p, " %s%d", s_dam, 120 + plev*2); break;
4575 case 24: sprintf(p, " %s%dd8", s_dam, (9 + (plev / 10))); break;
4577 case 25: sprintf(p, " %s³Æ%d", s_dam, plev * 2); break;
4579 case 25: sprintf(p, " dam %d each", plev * 2); break;
4581 case 26: sprintf(p, " %s%d", s_dam, 150 + plev*3/2); break;
4582 case 27: sprintf(p, " %s150 / 250", s_dam); break;
4583 case 29: sprintf(p, " %s%d", s_dam, 300 + (plev * 4)); break;
4584 case 30: sprintf(p, " %s%d", s_dam, p_ptr->chp); break;
4585 case 31: sprintf(p, " %s3 * 175", s_dam); break;
4589 case REALM_DEATH: /* Death */
4592 case 1: sprintf(p, " %s%dd3", s_dam, (3 + ((plev - 1) / 5))); break;
4593 case 3: sprintf(p, " %s%d", s_dam, 10 + (plev / 2)); break;
4594 case 5: sprintf(p, " %s20+d20", s_dur); break;
4595 case 8: sprintf(p, " %s3d6+%d", s_dam, burst); break;
4596 case 9: sprintf(p, " %s%dd8", s_dam, (8 + ((plev - 5) / 4))); break;
4597 case 10: sprintf(p, " %s%d", s_dam, 30+plev); break;
4599 case 13: sprintf(p, " »:%d+d%d", plev * 2, plev * 2); break;
4601 case 13: sprintf(p, " d %d+d%d", plev * 2, plev * 2); break;
4603 case 16: sprintf(p, " %s25+d25", s_dur); break;
4604 case 17: sprintf(p, " %s", s_random); break;
4605 case 18: sprintf(p, " %s%dd8", s_dam, (4 + ((plev - 5) / 4))); break;
4606 case 19: sprintf(p, " %s25+d25", s_dur); break;
4607 case 21: sprintf(p, " %s3*100", s_dam); break;
4608 case 22: sprintf(p, " %sd%d", s_dam, plev * 3); break;
4609 case 23: sprintf(p, " %s%d", s_dam, 100 + plev * 2); break;
4610 case 27: sprintf(p, " %s%d+d%d", s_dur,10+plev/2, 10+plev/2); break;
4611 case 30: sprintf(p, " %s666", s_dam); break;
4612 case 31: sprintf(p, " %s%d+d%d", s_dur, (plev / 2), (plev / 2)); break;
4616 case REALM_TRUMP: /* Trump */
4619 case 0: sprintf(p, " %s10", s_range); break;
4620 case 2: sprintf(p, " %s", s_random); break;
4621 case 4: sprintf(p, " %s%d", s_range, plev * 4); break;
4622 case 5: sprintf(p, " %s25+d30", s_dur); break;
4624 case 8: sprintf(p, " ºÇÂç½ÅÎÌ:%d.%d", lbtokg1(plev * 15 / 10),lbtokg2(plev * 15 / 10)); break;
4626 case 8: sprintf(p, " max wgt %d", plev * 15 / 10); break;
4628 case 13: sprintf(p, " %s%d", s_range, plev / 2 + 10); break;
4629 case 14: sprintf(p, " %s15+d21", s_delay); break;
4630 case 26: sprintf(p, " %s%d", s_heal, plev * 10 + 200); break;
4632 case 28: sprintf(p, " %s³Æ%d", s_dam, plev * 2); break;
4634 case 28: sprintf(p, " %s%d each", s_dam, plev * 2); break;
4639 case REALM_ARCANE: /* Arcane */
4642 case 0: sprintf(p, " %s%dd3", s_dam, 3 + ((plev - 1) / 5)); break;
4643 case 4: sprintf(p, " %s10", s_range); break;
4644 case 5: sprintf(p, " %s2d%d", s_dam, plev / 2); break;
4645 case 7: sprintf(p, " %s2d8", s_heal); break;
4649 case 17: sprintf(p, " %s20+d20", s_dur); break;
4650 case 18: sprintf(p, " %s4d8", s_heal); break;
4651 case 19: sprintf(p, " %s%d", s_range, plev * 5); break;
4652 case 21: sprintf(p, " %s6d8", s_dam); break;
4653 case 24: sprintf(p, " %s24+d24", s_dur); break;
4654 case 28: sprintf(p, " %s%d", s_dam, 75 + plev); break;
4655 case 30: sprintf(p, " %s15+d21", s_delay); break;
4656 case 31: sprintf(p, " %s25+d30", s_dur); break;
4660 case REALM_ENCHANT: /* Craft */
4663 case 0: sprintf(p, " %s100+d100", s_dur); break;
4664 case 1: sprintf(p, " %s80+d80", s_dur); break;
4670 case 18: sprintf(p, " %s20+d20", s_dur); break;
4671 case 5: sprintf(p, " %s25+d25", s_dur); break;
4672 case 8: sprintf(p, " %s24+d24", s_dur); break;
4673 case 11: sprintf(p, " %s25+d25", s_dur); break;
4674 case 13: sprintf(p, " %s%d+d25", s_dur, plev * 3); break;
4675 case 15: sprintf(p, " %s%d+d%d", s_dur, plev/2, plev/2); break;
4676 case 16: sprintf(p, " %s25+d30", s_dur); break;
4677 case 17: sprintf(p, " %s30+d20", s_dur); break;
4678 case 19: sprintf(p, " %s%d+d%d", s_dur, plev, plev+20); break;
4679 case 20: sprintf(p, " %s50+d50", s_dur); break;
4680 case 23: sprintf(p, " %s20+d20", s_dur); break;
4681 case 31: sprintf(p, " %s13+d13", s_dur); break;
4685 case REALM_DAEMON: /* Daemon */
4688 case 0: sprintf(p, " %s%dd4", s_dam, 3 + ((plev - 1) / 5)); break;
4689 case 2: sprintf(p, " %s12+d12", s_dur); break;
4690 case 3: sprintf(p, " %s20+d20", s_dur); break;
4691 case 5: sprintf(p, " %s%dd8", s_dam, (6 + ((plev - 5) / 4))); break;
4692 case 7: sprintf(p, " %s3d6+%d", s_dam, burst); break;
4693 case 10: sprintf(p, " %s20+d20", s_dur); break;
4694 case 11: sprintf(p, " %s%dd8", s_dam, (11 + ((plev - 5) / 4))); break;
4695 case 12: sprintf(p, " %s%d", s_dam, 55 + plev); break;
4696 case 14: sprintf(p, " %s%d", s_dam, 100 + plev*3/2); break;
4697 case 16: sprintf(p, " %s30+d25", s_dur); break;
4698 case 17: sprintf(p, " %s20+d20", s_dur); break;
4699 case 18: sprintf(p, " %s%d", s_dam, 55 + plev); break;
4700 case 19: sprintf(p, " %s%d", s_dam, 80 + plev*3/2); break;
4701 case 20: sprintf(p, " %s%d+d%d", s_dur,10+plev/2, 10+plev/2); break;
4702 case 21: sprintf(p, " %sd%d+d%d", s_dam, 2 * plev, 2 * plev); break;
4703 case 22: sprintf(p, " %s%d", s_dam, 100 + plev*2); break;
4704 case 24: sprintf(p, " %s25+d25", s_dur); break;
4705 case 25: sprintf(p, " %s20+d20", s_dur); break;
4706 case 26: sprintf(p, " %s%d+%d", s_dam, 25+plev/2, 25+plev/2); break;
4707 case 29: sprintf(p, " %s%d", s_dam, plev*15); break;
4708 case 30: sprintf(p, " %s600", s_dam); break;
4709 case 31: sprintf(p, " %s15+d15", s_dur); break;
4713 case REALM_CRUSADE: /* Crusade */
4716 case 0: sprintf(p, " %s%dd4", s_dam, 3 + ((plev - 1) / 5)); break;
4717 case 5: sprintf(p, " %s%d", s_range, 25+plev/2); break;
4719 case 6: sprintf(p, " %s³Æ%dd2", s_dam, 3+((plev-1)/9)); break;
4721 case 6: sprintf(p, " %s%dd2 each", s_dam, 3+((plev-1)/9)); break;
4723 case 9: sprintf(p, " %s3d6+%d", s_dam, orb); break;
4724 case 10: sprintf(p, " %sd%d", s_dam, plev); break;
4725 case 12: sprintf(p, " %s24+d24", s_dur); break;
4726 case 13: sprintf(p, " %sd25+%d", s_dur, 3 * plev); break;
4727 case 14: sprintf(p, " %s%d", s_dam, plev*5); break;
4729 case 15: sprintf(p, " »:d%d/²ó:100", 6 * plev); break;
4731 case 15: sprintf(p, " dam:d%d/h100", 6 * plev); break;
4733 case 18: sprintf(p, " %s18+d18", s_dur); break;
4734 case 19: sprintf(p, " %sd%d", s_dam, 4 * plev); break;
4735 case 20: sprintf(p, " %sd%d", s_dam, 4 * plev); break;
4736 case 22: sprintf(p, " %s%d", s_dam, 2 * plev+100); break;
4737 case 24: sprintf(p, " %s25+d25", s_dur); break;
4738 case 28: sprintf(p, " %s10+d10", s_dur); break;
4740 case 29: sprintf(p, " %s³Æ%d", s_dam, plev*3+25); break;
4742 case 29: sprintf(p, " %s%d each", s_dam, plev*3+25); break;
4745 case 30: sprintf(p, " ²ó100/»%d+%d", plev * 4, plev*11/2); break;
4747 case 30: sprintf(p, " h100/dm%d+%d", plev * 4, plev*11/2); break;
4752 case REALM_MUSIC: /* Music */
4755 case 2 : sprintf(p, " %s%dd4", s_dam, 4 + ((plev - 1) / 5)); break;
4756 case 4 : sprintf(p, " %s2d6", s_heal); break;
4757 case 9 : sprintf(p, " %sd%d", s_dam, plev * 3 / 2); break;
4758 case 13: sprintf(p, " %s%dd7", s_dam, 10 + (plev / 5)); break;
4759 case 20: sprintf(p, " %sd%d+d%d", s_dam, plev * 3, plev * 3); break;
4760 case 22: sprintf(p, " %s%dd10", s_dam, 15 + ((plev - 1) / 2)); break;
4761 case 27: sprintf(p, " %sd%d", s_dam, plev * 3); break;
4762 case 28: sprintf(p, " %s15d10", s_heal); break;
4763 case 30: sprintf(p, " %s%dd10", s_dam, 50 + plev); break;
4768 sprintf(p, "̤ÃΤΥ¿¥¤¥×: %d", use_realm);
4770 sprintf(p, "Unknown type: %d.", use_realm);
4777 * Print a list of spells (for browsing or casting or viewing)
4779 void print_spells(int target_spell, byte *spells, int num, int y, int x, int use_realm)
4781 int i, spell, exp_level, increment = 64;
4793 if (((use_realm <= REALM_NONE) || (use_realm > MAX_REALM)) && p_ptr->wizard)
4795 msg_print("·Ù¹ð¡ª print_spell ¤¬Îΰè¤Ê¤·¤Ë¸Æ¤Ð¤ì¤¿");
4797 msg_print("Warning! print_spells called with null realm");
4801 /* Title the list */
4803 if (use_realm == REALM_HISSATSU)
4805 strcpy(buf," Lv MP");
4807 strcpy(buf," Lv SP");
4811 strcpy(buf,"½ÏÎýÅÙ Lv MP ¼ºÎ¨ ¸ú²Ì");
4813 strcpy(buf,"Profic Lv SP Fail Effect");
4817 put_str("̾Á°", y, x + 5);
4818 put_str(buf, y, x + 29);
4820 put_str("Name", y, x + 5);
4821 put_str(buf, y, x + 29);
4824 if ((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE)) increment = 0;
4825 else if (use_realm == p_ptr->realm1) increment = 0;
4826 else if (use_realm == p_ptr->realm2) increment = 32;
4828 /* Dump the spells */
4829 for (i = 0; i < num; i++)
4831 /* Access the spell */
4834 /* Access the spell */
4835 if (!is_magic(use_realm))
4837 s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
4841 s_ptr = &mp_ptr->info[use_realm - 1][spell];
4844 if (use_realm == REALM_HISSATSU)
4845 need_mana = s_ptr->smana;
4848 s16b exp = experience_of_spell(spell, use_realm);
4850 /* Extract mana consumption rate */
4851 need_mana = mod_need_mana(s_ptr->smana, spell, use_realm);
4853 if ((increment == 64) || (s_ptr->slevel >= 99)) exp_level = EXP_LEVEL_UNSKILLED;
4854 else exp_level = spell_exp_level(exp);
4857 if (!increment && (exp_level == EXP_LEVEL_MASTER)) max = TRUE;
4858 else if ((increment == 32) && (exp_level >= EXP_LEVEL_EXPERT)) max = TRUE;
4859 else if (s_ptr->slevel >= 99) max = TRUE;
4860 else if ((p_ptr->pclass == CLASS_RED_MAGE) && (exp_level >= EXP_LEVEL_SKILLED)) max = TRUE;
4862 strncpy(ryakuji, exp_level_str[exp_level], 4);
4867 if (use_menu && target_spell)
4869 if (i == (target_spell-1))
4871 strcpy(out_val, " ¡Õ ");
4873 strcpy(out_val, " > ");
4876 strcpy(out_val, " ");
4878 else sprintf(out_val, " %c) ", I2A(i));
4879 /* Skip illegible spells */
4880 if (s_ptr->slevel >= 99)
4883 strcat(out_val, format("%-30s", "(ȽÆÉÉÔǽ)"));
4885 strcat(out_val, format("%-30s", "(illegible)"));
4888 c_prt(TERM_L_DARK, out_val, y + i + 1, x);
4892 /* XXX XXX Could label spells above the players level */
4894 /* Get extra info */
4895 spell_info(info, spell, use_realm);
4900 /* Assume spell is known and tried */
4901 line_attr = TERM_WHITE;
4903 /* Analyze the spell */
4904 if ((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE))
4906 if (s_ptr->slevel > p_ptr->max_plv)
4911 comment = " unknown";
4914 line_attr = TERM_L_BLUE;
4916 else if (s_ptr->slevel > p_ptr->lev)
4921 comment = " forgotten";
4924 line_attr = TERM_YELLOW;
4927 else if ((use_realm != p_ptr->realm1) && (use_realm != p_ptr->realm2))
4932 comment = " unknown";
4935 line_attr = TERM_L_BLUE;
4937 else if ((use_realm == p_ptr->realm1) ?
4938 ((p_ptr->spell_forgotten1 & (1L << spell))) :
4939 ((p_ptr->spell_forgotten2 & (1L << spell))))
4944 comment = " forgotten";
4947 line_attr = TERM_YELLOW;
4949 else if (!((use_realm == p_ptr->realm1) ?
4950 (p_ptr->spell_learned1 & (1L << spell)) :
4951 (p_ptr->spell_learned2 & (1L << spell))))
4956 comment = " unknown";
4959 line_attr = TERM_L_BLUE;
4961 else if (!((use_realm == p_ptr->realm1) ?
4962 (p_ptr->spell_worked1 & (1L << spell)) :
4963 (p_ptr->spell_worked2 & (1L << spell))))
4966 comment = " ̤·Ð¸³";
4968 comment = " untried";
4971 line_attr = TERM_L_GREEN;
4974 /* Dump the spell --(-- */
4975 if (use_realm == REALM_HISSATSU)
4977 strcat(out_val, format("%-25s %2d %4d",
4978 spell_names[technic2magic(use_realm)-1][spell], /* realm, spell */
4979 s_ptr->slevel, need_mana));
4983 strcat(out_val, format("%-25s%c%-4s %2d %4d %3d%%%s",
4984 spell_names[technic2magic(use_realm)-1][spell], /* realm, spell */
4985 (max ? '!' : ' '), ryakuji,
4986 s_ptr->slevel, need_mana, spell_chance(spell, use_realm), comment));
4988 c_prt(line_attr, out_val, y + i + 1, x);
4991 /* Clear the bottom line */
4992 prt("", y + i + 1, x);
4997 * Note that amulets, rods, and high-level spell books are immune
4998 * to "inventory damage" of any kind. Also sling ammo and shovels.
5003 * Does a given class of objects (usually) hate acid?
5004 * Note that acid can either melt or corrode something.
5006 bool hates_acid(object_type *o_ptr)
5008 /* Analyze the type */
5009 switch (o_ptr->tval)
5011 /* Wearable items */
5031 /* Staffs/Scrolls are wood/paper */
5044 /* Junk is useless */
5058 * Does a given object (usually) hate electricity?
5060 bool hates_elec(object_type *o_ptr)
5062 switch (o_ptr->tval)
5076 * Does a given object (usually) hate fire?
5077 * Hafted/Polearm weapons have wooden shafts.
5078 * Arrows/Bows are mostly wooden.
5080 bool hates_fire(object_type *o_ptr)
5082 /* Analyze the type */
5083 switch (o_ptr->tval)
5101 case TV_SORCERY_BOOK:
5102 case TV_NATURE_BOOK:
5106 case TV_ARCANE_BOOK:
5107 case TV_ENCHANT_BOOK:
5108 case TV_DAEMON_BOOK:
5109 case TV_CRUSADE_BOOK:
5111 case TV_HISSATSU_BOOK:
5122 /* Staffs/Scrolls burn */
5135 * Does a given object (usually) hate cold?
5137 bool hates_cold(object_type *o_ptr)
5139 switch (o_ptr->tval)
5156 int set_acid_destroy(object_type *o_ptr)
5158 u32b flgs[TR_FLAG_SIZE];
5159 if (!hates_acid(o_ptr)) return (FALSE);
5160 object_flags(o_ptr, flgs);
5161 if (have_flag(flgs, TR_IGNORE_ACID)) return (FALSE);
5169 int set_elec_destroy(object_type *o_ptr)
5171 u32b flgs[TR_FLAG_SIZE];
5172 if (!hates_elec(o_ptr)) return (FALSE);
5173 object_flags(o_ptr, flgs);
5174 if (have_flag(flgs, TR_IGNORE_ELEC)) return (FALSE);
5182 int set_fire_destroy(object_type *o_ptr)
5184 u32b flgs[TR_FLAG_SIZE];
5185 if (!hates_fire(o_ptr)) return (FALSE);
5186 object_flags(o_ptr, flgs);
5187 if (have_flag(flgs, TR_IGNORE_FIRE)) return (FALSE);
5195 int set_cold_destroy(object_type *o_ptr)
5197 u32b flgs[TR_FLAG_SIZE];
5198 if (!hates_cold(o_ptr)) return (FALSE);
5199 object_flags(o_ptr, flgs);
5200 if (have_flag(flgs, TR_IGNORE_COLD)) return (FALSE);
5206 * Destroys a type of item on a given percent chance
5207 * Note that missiles are no longer necessarily all destroyed
5208 * Destruction taken from "melee.c" code for "stealing".
5209 * New-style wands and rods handled correctly. -LM-
5210 * Returns number of items destroyed.
5212 int inven_damage(inven_func typ, int perc)
5216 char o_name[MAX_NLEN];
5218 /* Multishadow effects is determined by turn */
5219 if( p_ptr->multishadow && (turn & 1) )return 0;
5221 if (p_ptr->inside_arena) return 0;
5223 /* Count the casualties */
5226 /* Scan through the slots backwards */
5227 for (i = 0; i < INVEN_PACK; i++)
5229 o_ptr = &inventory[i];
5231 /* Skip non-objects */
5232 if (!o_ptr->k_idx) continue;
5234 /* Hack -- for now, skip artifacts */
5235 if (artifact_p(o_ptr) || o_ptr->art_name) continue;
5237 /* Give this item slot a shot at death */
5240 /* Count the casualties */
5241 for (amt = j = 0; j < o_ptr->number; ++j)
5243 if (randint0(100) < perc) amt++;
5246 /* Some casualities */
5249 /* Get a description */
5250 object_desc(o_name, o_ptr, FALSE, 3);
5254 msg_format("%s(%c)¤¬%s²õ¤ì¤Æ¤·¤Þ¤Ã¤¿¡ª",
5256 msg_format("%sour %s (%c) %s destroyed!",
5260 o_name, index_to_label(i),
5261 ((o_ptr->number > 1) ?
5262 ((amt == o_ptr->number) ? "Á´Éô" :
5263 (amt > 1 ? "²¿¸Ä¤«" : "°ì¸Ä")) : "") );
5265 ((o_ptr->number > 1) ?
5266 ((amt == o_ptr->number) ? "All of y" :
5267 (amt > 1 ? "Some of y" : "One of y")) : "Y"),
5268 o_name, index_to_label(i),
5269 ((amt > 1) ? "were" : "was"));
5273 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
5274 msg_print("¤ä¤ê¤ä¤¬¤Ã¤¿¤Ê¡ª");
5277 /* Potions smash open */
5278 if (object_is_potion(o_ptr))
5280 (void)potion_smash_effect(0, py, px, o_ptr->k_idx);
5283 /* Reduce the charges of rods/wands */
5284 reduce_charges(o_ptr, amt);
5286 /* Destroy "amt" items */
5287 inven_item_increase(i, -amt);
5288 inven_item_optimize(i);
5290 /* Count the casualties */
5296 /* Return the casualty count */
5302 * Acid has hit the player, attempt to affect some armor.
5304 * Note that the "base armor" of an object never changes.
5306 * If any armor is damaged (or resists), the player takes less damage.
5308 static int minus_ac(void)
5310 object_type *o_ptr = NULL;
5311 u32b flgs[TR_FLAG_SIZE];
5312 char o_name[MAX_NLEN];
5315 /* Pick a (possibly empty) inventory slot */
5316 switch (randint1(7))
5318 case 1: o_ptr = &inventory[INVEN_RARM]; break;
5319 case 2: o_ptr = &inventory[INVEN_LARM]; break;
5320 case 3: o_ptr = &inventory[INVEN_BODY]; break;
5321 case 4: o_ptr = &inventory[INVEN_OUTER]; break;
5322 case 5: o_ptr = &inventory[INVEN_HANDS]; break;
5323 case 6: o_ptr = &inventory[INVEN_HEAD]; break;
5324 case 7: o_ptr = &inventory[INVEN_FEET]; break;
5327 /* Nothing to damage */
5328 if (!o_ptr->k_idx) return (FALSE);
5330 if (o_ptr->tval < TV_BOOTS) return (FALSE);
5332 /* No damage left to be done */
5333 if (o_ptr->ac + o_ptr->to_a <= 0) return (FALSE);
5337 object_desc(o_name, o_ptr, FALSE, 0);
5339 /* Extract the flags */
5340 object_flags(o_ptr, flgs);
5342 /* Object resists */
5343 if (have_flag(flgs, TR_IGNORE_ACID))
5346 msg_format("¤·¤«¤·%s¤Ë¤Ï¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡ª", o_name);
5348 msg_format("Your %s is unaffected!", o_name);
5357 msg_format("%s¤¬¥À¥á¡¼¥¸¤ò¼õ¤±¤¿¡ª", o_name);
5359 msg_format("Your %s is damaged!", o_name);
5363 /* Damage the item */
5366 /* Calculate bonuses */
5367 p_ptr->update |= (PU_BONUS);
5370 p_ptr->window |= (PW_EQUIP | PW_PLAYER);
5374 /* Item was damaged */
5380 * Hurt the player with Acid
5382 int acid_dam(int dam, cptr kb_str, int monspell)
5385 int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
5386 bool double_resist = IS_OPPOSE_ACID();
5388 /* Total Immunity */
5389 if (p_ptr->immune_acid || (dam <= 0))
5391 learn_spell(monspell);
5395 /* Vulnerability (Ouch!) */
5396 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
5397 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
5399 /* Resist the damage */
5400 if (p_ptr->resist_acid) dam = (dam + 2) / 3;
5401 if (double_resist) dam = (dam + 2) / 3;
5403 if ((!(double_resist || p_ptr->resist_acid)) &&
5404 one_in_(HURT_CHANCE))
5405 (void)do_dec_stat(A_CHR);
5407 /* If any armor gets hit, defend the player */
5408 if (minus_ac()) dam = (dam + 1) / 2;
5411 get_damage=take_hit(DAMAGE_ATTACK, dam, kb_str, monspell);
5413 /* Inventory damage */
5414 if (!(double_resist && p_ptr->resist_acid))
5415 inven_damage(set_acid_destroy, inv);
5421 * Hurt the player with electricity
5423 int elec_dam(int dam, cptr kb_str, int monspell)
5426 int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
5427 bool double_resist = IS_OPPOSE_ELEC();
5429 /* Total immunity */
5430 if (p_ptr->immune_elec || (dam <= 0))
5432 learn_spell(monspell);
5436 /* Vulnerability (Ouch!) */
5437 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
5438 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
5439 if (prace_is_(RACE_ANDROID)) dam += dam / 3;
5441 /* Resist the damage */
5442 if (p_ptr->resist_elec) dam = (dam + 2) / 3;
5443 if (double_resist) dam = (dam + 2) / 3;
5445 if ((!(double_resist || p_ptr->resist_elec)) &&
5446 one_in_(HURT_CHANCE))
5447 (void)do_dec_stat(A_DEX);
5450 get_damage=take_hit(DAMAGE_ATTACK, dam, kb_str, monspell);
5452 /* Inventory damage */
5453 if (!(double_resist && p_ptr->resist_elec))
5454 inven_damage(set_elec_destroy, inv);
5461 * Hurt the player with Fire
5463 int fire_dam(int dam, cptr kb_str, int monspell)
5466 int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
5467 bool double_resist = IS_OPPOSE_FIRE();
5469 /* Totally immune */
5470 if (p_ptr->immune_fire || (dam <= 0))
5472 learn_spell(monspell);
5476 /* Vulnerability (Ouch!) */
5477 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
5478 if (prace_is_(RACE_ENT)) dam += dam / 3;
5479 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
5481 /* Resist the damage */
5482 if (p_ptr->resist_fire) dam = (dam + 2) / 3;
5483 if (double_resist) dam = (dam + 2) / 3;
5485 if ((!(double_resist || p_ptr->resist_fire)) &&
5486 one_in_(HURT_CHANCE))
5487 (void)do_dec_stat(A_STR);
5490 get_damage=take_hit(DAMAGE_ATTACK, dam, kb_str, monspell);
5492 /* Inventory damage */
5493 if (!(double_resist && p_ptr->resist_fire))
5494 inven_damage(set_fire_destroy, inv);
5501 * Hurt the player with Cold
5503 int cold_dam(int dam, cptr kb_str, int monspell)
5506 int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
5507 bool double_resist = IS_OPPOSE_COLD();
5509 /* Total immunity */
5510 if (p_ptr->immune_cold || (dam <= 0))
5512 learn_spell(monspell);
5516 /* Vulnerability (Ouch!) */
5517 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
5518 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
5520 /* Resist the damage */
5521 if (p_ptr->resist_cold) dam = (dam + 2) / 3;
5522 if (double_resist) dam = (dam + 2) / 3;
5524 if ((!(double_resist || p_ptr->resist_cold)) &&
5525 one_in_(HURT_CHANCE))
5526 (void)do_dec_stat(A_STR);
5529 get_damage=take_hit(DAMAGE_ATTACK, dam, kb_str, monspell);
5531 /* Inventory damage */
5532 if (!(double_resist && p_ptr->resist_cold))
5533 inven_damage(set_cold_destroy, inv);
5539 bool rustproof(void)
5543 char o_name[MAX_NLEN];
5546 item_tester_no_ryoute = TRUE;
5547 /* Select a piece of armour */
5548 item_tester_hook = item_tester_hook_armour;
5552 q = "¤É¤ÎËɶñ¤Ë»¬»ß¤á¤ò¤·¤Þ¤¹¤«¡©";
5553 s = "»¬»ß¤á¤Ç¤¤ë¤â¤Î¤¬¤¢¤ê¤Þ¤»¤ó¡£";
5555 q = "Rustproof which piece of armour? ";
5556 s = "You have nothing to rustproof.";
5559 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return FALSE;
5561 /* Get the item (in the pack) */
5564 o_ptr = &inventory[item];
5567 /* Get the item (on the floor) */
5570 o_ptr = &o_list[0 - item];
5575 object_desc(o_name, o_ptr, FALSE, 0);
5577 add_flag(o_ptr->art_flags, TR_IGNORE_ACID);
5579 if ((o_ptr->to_a < 0) && !cursed_p(o_ptr))
5582 msg_format("%s¤Ï¿·ÉÊƱÍͤˤʤä¿¡ª",o_name);
5584 msg_format("%s %s look%s as good as new!",
5585 ((item >= 0) ? "Your" : "The"), o_name,
5586 ((o_ptr->number > 1) ? "" : "s"));
5593 msg_format("%s¤ÏÉå¿©¤·¤Ê¤¯¤Ê¤Ã¤¿¡£", o_name);
5595 msg_format("%s %s %s now protected against corrosion.",
5596 ((item >= 0) ? "Your" : "The"), o_name,
5597 ((o_ptr->number > 1) ? "are" : "is"));
5608 * Curse the players armor
5610 bool curse_armor(void)
5615 char o_name[MAX_NLEN];
5618 /* Curse the body armor */
5619 o_ptr = &inventory[INVEN_BODY];
5621 /* Nothing to curse */
5622 if (!o_ptr->k_idx) return (FALSE);
5626 object_desc(o_name, o_ptr, FALSE, 3);
5628 /* Attempt a saving throw for artifacts */
5629 if ((o_ptr->art_name || artifact_p(o_ptr)) && (randint0(100) < 50))
5633 msg_format("%s¤¬%s¤òÊñ¤ß¹þ¤â¤¦¤È¤·¤¿¤¬¡¢%s¤Ï¤½¤ì¤òÄ·¤ÍÊÖ¤·¤¿¡ª",
5634 "¶²ÉݤΰŹõ¥ª¡¼¥é", "Ëɶñ", o_name);
5636 msg_format("A %s tries to %s, but your %s resists the effects!",
5637 "terrible black aura", "surround your armor", o_name);
5642 /* not artifact or failed save... */
5647 msg_format("¶²ÉݤΰŹõ¥ª¡¼¥é¤¬¤¢¤Ê¤¿¤Î%s¤òÊñ¤ß¹þ¤ó¤À¡ª", o_name);
5649 msg_format("A terrible black aura blasts your %s!", o_name);
5652 chg_virtue(V_ENCHANT, -5);
5654 /* Blast the armor */
5656 o_ptr->name2 = EGO_BLASTED;
5657 o_ptr->to_a = 0 - randint1(5) - randint1(5);
5664 for (i = 0; i < TR_FLAG_SIZE; i++)
5665 o_ptr->art_flags[i] = 0;
5668 o_ptr->curse_flags = TRC_CURSED;
5671 o_ptr->ident |= (IDENT_BROKEN);
5673 /* Recalculate bonuses */
5674 p_ptr->update |= (PU_BONUS);
5676 /* Recalculate mana */
5677 p_ptr->update |= (PU_MANA);
5680 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
5688 * Curse the players weapon
5690 bool curse_weapon(bool force, int slot)
5696 char o_name[MAX_NLEN];
5699 /* Curse the weapon */
5700 o_ptr = &inventory[slot];
5702 /* Nothing to curse */
5703 if (!o_ptr->k_idx) return (FALSE);
5707 object_desc(o_name, o_ptr, FALSE, 3);
5709 /* Attempt a saving throw */
5710 if ((artifact_p(o_ptr) || o_ptr->art_name) && (randint0(100) < 50) && !force)
5714 msg_format("%s¤¬%s¤òÊñ¤ß¹þ¤â¤¦¤È¤·¤¿¤¬¡¢%s¤Ï¤½¤ì¤òÄ·¤ÍÊÖ¤·¤¿¡ª",
5715 "¶²ÉݤΰŹõ¥ª¡¼¥é", "Éð´ï", o_name);
5717 msg_format("A %s tries to %s, but your %s resists the effects!",
5718 "terrible black aura", "surround your weapon", o_name);
5723 /* not artifact or failed save... */
5728 if (!force) msg_format("¶²ÉݤΰŹõ¥ª¡¼¥é¤¬¤¢¤Ê¤¿¤Î%s¤òÊñ¤ß¹þ¤ó¤À¡ª", o_name);
5730 if (!force) msg_format("A terrible black aura blasts your %s!", o_name);
5733 chg_virtue(V_ENCHANT, -5);
5735 /* Shatter the weapon */
5737 o_ptr->name2 = EGO_SHATTERED;
5738 o_ptr->to_h = 0 - randint1(5) - randint1(5);
5739 o_ptr->to_d = 0 - randint1(5) - randint1(5);
5745 for (i = 0; i < TR_FLAG_SIZE; i++)
5746 o_ptr->art_flags[i] = 0;
5750 o_ptr->curse_flags = TRC_CURSED;
5753 o_ptr->ident |= (IDENT_BROKEN);
5755 /* Recalculate bonuses */
5756 p_ptr->update |= (PU_BONUS);
5758 /* Recalculate mana */
5759 p_ptr->update |= (PU_MANA);
5762 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
5771 * Enchant some bolts
5773 bool brand_bolts(void)
5777 /* Use the first acceptable bolts */
5778 for (i = 0; i < INVEN_PACK; i++)
5780 object_type *o_ptr = &inventory[i];
5782 /* Skip non-bolts */
5783 if (o_ptr->tval != TV_BOLT) continue;
5785 /* Skip artifacts and ego-items */
5786 if (o_ptr->art_name || artifact_p(o_ptr) || ego_item_p(o_ptr))
5789 /* Skip cursed/broken items */
5790 if (cursed_p(o_ptr) || broken_p(o_ptr)) continue;
5793 if (randint0(100) < 75) continue;
5797 msg_print("¥¯¥í¥¹¥Ü¥¦¤ÎÌ𤬱ê¤Î¥ª¡¼¥é¤ËÊñ¤Þ¤ì¤¿¡ª");
5799 msg_print("Your bolts are covered in a fiery aura!");
5804 o_ptr->name2 = EGO_FLAME;
5807 enchant(o_ptr, randint0(3) + 4, ENCH_TOHIT | ENCH_TODAM);
5814 if (flush_failure) flush();
5818 msg_print("±ê¤Ç¶¯²½¤¹¤ë¤Î¤Ë¼ºÇÔ¤·¤¿¡£");
5820 msg_print("The fiery enchantment failed.");
5830 * Helper function -- return a "nearby" race for polymorphing
5832 * Note that this function is one of the more "dangerous" ones...
5834 static s16b poly_r_idx(int r_idx)
5836 monster_race *r_ptr = &r_info[r_idx];
5838 int i, r, lev1, lev2;
5840 /* Hack -- Uniques/Questors never polymorph */
5841 if ((r_ptr->flags1 & RF1_UNIQUE) ||
5842 (r_ptr->flags1 & RF1_QUESTOR))
5845 /* Allowable range of "levels" for resulting monster */
5846 lev1 = r_ptr->level - ((randint1(20) / randint1(9)) + 1);
5847 lev2 = r_ptr->level + ((randint1(20) / randint1(9)) + 1);
5849 /* Pick a (possibly new) non-unique race */
5850 for (i = 0; i < 1000; i++)
5852 /* Pick a new race, using a level calculation */
5853 r = get_mon_num((dun_level + r_ptr->level) / 2 + 5);
5855 /* Handle failure */
5861 /* Ignore unique monsters */
5862 if (r_ptr->flags1 & RF1_UNIQUE) continue;
5864 /* Ignore monsters with incompatible levels */
5865 if ((r_ptr->level < lev1) || (r_ptr->level > lev2)) continue;
5867 /* Use that index */
5879 bool polymorph_monster(int y, int x)
5881 cave_type *c_ptr = &cave[y][x];
5882 monster_type *m_ptr = &m_list[c_ptr->m_idx];
5883 bool polymorphed = FALSE;
5885 int old_r_idx = m_ptr->r_idx;
5886 bool targeted = (target_who == c_ptr->m_idx) ? TRUE : FALSE;
5887 bool health_tracked = (p_ptr->health_who == c_ptr->m_idx) ? TRUE : FALSE;
5888 monster_type back_m;
5890 if (p_ptr->inside_arena || p_ptr->inside_battle) return (FALSE);
5892 if ((p_ptr->riding == c_ptr->m_idx) || (m_ptr->mflag2 & MFLAG2_KAGE)) return (FALSE);
5894 /* Memorize the monster before polymorphing */
5897 /* Pick a "new" monster race */
5898 new_r_idx = poly_r_idx(old_r_idx);
5900 /* Handle polymorph */
5901 if (new_r_idx != old_r_idx)
5905 /* Get the monsters attitude */
5906 if (is_friendly(m_ptr)) mode |= PM_FORCE_FRIENDLY;
5907 if (is_pet(m_ptr)) mode |= PM_FORCE_PET;
5908 if (m_ptr->mflag2 & MFLAG2_NOPET) mode |= PM_NO_PET;
5910 /* "Kill" the "old" monster */
5911 delete_monster_idx(c_ptr->m_idx);
5913 /* Create a new monster (no groups) */
5914 if (place_monster_aux(0, y, x, new_r_idx, mode))
5921 /* Placing the new monster failed */
5922 if (place_monster_aux(0, y, x, old_r_idx, (mode | PM_NO_KAGE | PM_IGNORE_TERRAIN)))
5923 m_list[hack_m_idx_ii] = back_m;
5926 if (targeted) target_who = hack_m_idx_ii;
5927 if (health_tracked) health_track(hack_m_idx_ii);
5937 static bool dimension_door_aux(int x, int y)
5939 int plev = p_ptr->lev;
5941 p_ptr->energy_need += (s16b)((s32b)(60 - plev) * ENERGY_NEED() / 100L);
5943 if (!cave_empty_bold(y, x) || (cave[y][x].info & CAVE_ICKY) ||
5944 (distance(y, x, py, px) > plev / 2 + 10) ||
5945 (!randint0(plev / 10 + 10)))
5947 p_ptr->energy_need += (s16b)((s32b)(60 - plev) * ENERGY_NEED() / 100L);
5948 teleport_player((plev+2)*2);
5955 teleport_player_to(y, x, TRUE);
5966 bool dimension_door(void)
5970 /* Rerutn FALSE if cancelled */
5971 if (!tgt_pt(&x, &y)) return FALSE;
5973 if (dimension_door_aux(x, y)) return TRUE;
5976 msg_print("ÀºÎ¤«¤éʪ¼Á³¦¤ËÌá¤ë»þ¤¦¤Þ¤¯¤¤¤«¤Ê¤«¤Ã¤¿¡ª");
5978 msg_print("You fail to exit the astral plane correctly!");
5986 * Mirror Master's Dimension Door
5988 bool mirror_tunnel(void)
5992 /* Rerutn FALSE if cancelled */
5993 if (!tgt_pt(&x, &y)) return FALSE;
5995 if (dimension_door_aux(x, y)) return TRUE;
5998 msg_print("¶À¤ÎÀ¤³¦¤ò¤¦¤Þ¤¯Ä̤ì¤Ê¤«¤Ã¤¿¡ª");
6000 msg_print("You fail to pass the mirror plane correctly!");
6007 bool eat_magic(int power)
6009 object_type * o_ptr;
6012 int recharge_strength = 0;
6018 char o_name[MAX_NLEN];
6020 item_tester_hook = item_tester_hook_recharge;
6024 q = "¤É¤Î¥¢¥¤¥Æ¥à¤«¤éËâÎϤòµÛ¼ý¤·¤Þ¤¹¤«¡©";
6025 s = "ËâÎϤòµÛ¼ý¤Ç¤¤ë¥¢¥¤¥Æ¥à¤¬¤¢¤ê¤Þ¤»¤ó¡£";
6027 q = "Drain which item? ";
6028 s = "You have nothing to drain.";
6031 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return FALSE;
6035 o_ptr = &inventory[item];
6039 o_ptr = &o_list[0 - item];
6042 k_ptr = &k_info[o_ptr->k_idx];
6043 lev = get_object_level(o_ptr);
6045 if (o_ptr->tval == TV_ROD)
6047 recharge_strength = ((power > lev/2) ? (power - lev/2) : 0) / 5;
6050 if (one_in_(recharge_strength))
6052 /* Activate the failure code. */
6057 if (o_ptr->timeout > (o_ptr->number - 1) * k_ptr->pval)
6060 msg_print("½¼Å¶Ãæ¤Î¥í¥Ã¥É¤«¤éËâÎϤòµÛ¼ý¤¹¤ë¤³¤È¤Ï¤Ç¤¤Þ¤»¤ó¡£");
6062 msg_print("You can't absorb energy from a discharged rod.");
6069 o_ptr->timeout += k_ptr->pval;
6075 /* All staffs, wands. */
6076 recharge_strength = (100 + power - lev) / 15;
6079 if (recharge_strength < 0) recharge_strength = 0;
6082 if (one_in_(recharge_strength))
6084 /* Activate the failure code. */
6089 if (o_ptr->pval > 0)
6091 p_ptr->csp += lev / 2;
6094 /* XXX Hack -- unstack if necessary */
6095 if ((o_ptr->tval == TV_STAFF) && (item >= 0) && (o_ptr->number > 1))
6100 /* Get local object */
6103 /* Obtain a local object */
6104 object_copy(q_ptr, o_ptr);
6106 /* Modify quantity */
6109 /* Restore the charges */
6112 /* Unstack the used item */
6114 p_ptr->total_weight -= q_ptr->weight;
6115 item = inven_carry(q_ptr);
6119 msg_print("¾ó¤ò¤Þ¤È¤á¤Ê¤ª¤·¤¿¡£");
6121 msg_print("You unstack your staff.");
6129 msg_print("µÛ¼ý¤Ç¤¤ëËâÎϤ¬¤¢¤ê¤Þ¤»¤ó¡ª");
6131 msg_print("There's no energy there to absorb!");
6135 if (!o_ptr->pval) o_ptr->ident |= IDENT_EMPTY;
6139 /* Inflict the penalties for failing a recharge. */
6142 /* Artifacts are never destroyed. */
6143 if (artifact_p(o_ptr))
6145 object_desc(o_name, o_ptr, TRUE, 0);
6147 msg_format("ËâÎϤ¬µÕή¤·¤¿¡ª%s¤Ï´°Á´¤ËËâÎϤò¼º¤Ã¤¿¡£", o_name);
6149 msg_format("The recharging backfires - %s is completely drained!", o_name);
6153 /* Artifact rods. */
6154 if (o_ptr->tval == TV_ROD)
6155 o_ptr->timeout = k_ptr->pval * o_ptr->number;
6157 /* Artifact wands and staffs. */
6158 else if ((o_ptr->tval == TV_WAND) || (o_ptr->tval == TV_STAFF))
6163 /* Get the object description */
6164 object_desc(o_name, o_ptr, FALSE, 0);
6166 /*** Determine Seriousness of Failure ***/
6168 /* Mages recharge objects more safely. */
6169 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)
6171 /* 10% chance to blow up one rod, otherwise draining. */
6172 if (o_ptr->tval == TV_ROD)
6174 if (one_in_(10)) fail_type = 2;
6177 /* 75% chance to blow up one wand, otherwise draining. */
6178 else if (o_ptr->tval == TV_WAND)
6180 if (!one_in_(3)) fail_type = 2;
6183 /* 50% chance to blow up one staff, otherwise no effect. */
6184 else if (o_ptr->tval == TV_STAFF)
6186 if (one_in_(2)) fail_type = 2;
6191 /* All other classes get no special favors. */
6194 /* 33% chance to blow up one rod, otherwise draining. */
6195 if (o_ptr->tval == TV_ROD)
6197 if (one_in_(3)) fail_type = 2;
6200 /* 20% chance of the entire stack, else destroy one wand. */
6201 else if (o_ptr->tval == TV_WAND)
6203 if (one_in_(5)) fail_type = 3;
6206 /* Blow up one staff. */
6207 else if (o_ptr->tval == TV_STAFF)
6213 /*** Apply draining and destruction. ***/
6215 /* Drain object or stack of objects. */
6218 if (o_ptr->tval == TV_ROD)
6221 msg_print("¥í¥Ã¥É¤ÏÇË»¤òÌȤ줿¤¬¡¢ËâÎϤÏÁ´¤Æ¼º¤Ê¤ï¤ì¤¿¡£");
6223 msg_format("You save your rod from destruction, but all charges are lost.", o_name);
6226 o_ptr->timeout = k_ptr->pval * o_ptr->number;
6228 else if (o_ptr->tval == TV_WAND)
6231 msg_format("%s¤ÏÇË»¤òÌȤ줿¤¬¡¢ËâÎϤ¬Á´¤Æ¼º¤ï¤ì¤¿¡£", o_name);
6233 msg_format("You save your %s from destruction, but all charges are lost.", o_name);
6238 /* Staffs aren't drained. */
6241 /* Destroy an object or one in a stack of objects. */
6244 if (o_ptr->number > 1)
6247 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬°ìËܲõ¤ì¤¿¡ª", o_name);
6249 msg_format("Wild magic consumes one of your %s!", o_name);
6252 /* Reduce rod stack maximum timeout, drain wands. */
6253 if (o_ptr->tval == TV_ROD) o_ptr->timeout = MIN(o_ptr->timeout, k_ptr->pval * (o_ptr->number - 1));
6254 else if (o_ptr->tval == TV_WAND) o_ptr->pval = o_ptr->pval * (o_ptr->number - 1) / o_ptr->number;
6259 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬²¿Ëܤ«²õ¤ì¤¿¡ª", o_name);
6261 msg_format("Wild magic consumes your %s!", o_name);
6264 /* Reduce and describe inventory */
6267 inven_item_increase(item, -1);
6268 inven_item_describe(item);
6269 inven_item_optimize(item);
6272 /* Reduce and describe floor item */
6275 floor_item_increase(0 - item, -1);
6276 floor_item_describe(0 - item);
6277 floor_item_optimize(0 - item);
6281 /* Destroy all members of a stack of objects. */
6284 if (o_ptr->number > 1)
6286 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬Á´¤Æ²õ¤ì¤¿¡ª", o_name);
6288 msg_format("Wild magic consumes all your %s!", o_name);
6293 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬²õ¤ì¤¿¡ª", o_name);
6295 msg_format("Wild magic consumes your %s!", o_name);
6300 /* Reduce and describe inventory */
6303 inven_item_increase(item, -999);
6304 inven_item_describe(item);
6305 inven_item_optimize(item);
6308 /* Reduce and describe floor item */
6311 floor_item_increase(0 - item, -999);
6312 floor_item_describe(0 - item);
6313 floor_item_optimize(0 - item);
6319 if (p_ptr->csp > p_ptr->msp)
6321 p_ptr->csp = p_ptr->msp;
6324 /* Redraw mana and hp */
6325 p_ptr->redraw |= (PR_MANA);
6327 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
6328 p_ptr->window |= (PW_INVEN);
6334 bool summon_kin_player(int level, int y, int x, u32b mode)
6336 bool pet = (bool)(mode & PM_FORCE_PET);
6337 if (!pet) mode |= PM_NO_PET;
6339 switch (p_ptr->mimic_form)
6342 switch (p_ptr->prace)
6346 case RACE_BARBARIAN:
6349 summon_kin_type = 'p';
6359 case RACE_MIND_FLAYER:
6362 summon_kin_type = 'h';
6365 summon_kin_type = 'o';
6367 case RACE_HALF_TROLL:
6368 summon_kin_type = 'T';
6370 case RACE_HALF_OGRE:
6371 summon_kin_type = 'O';
6373 case RACE_HALF_GIANT:
6374 case RACE_HALF_TITAN:
6376 summon_kin_type = 'P';
6379 summon_kin_type = 'y';
6382 summon_kin_type = 'K';
6385 summon_kin_type = 'k';
6388 if (one_in_(13)) summon_kin_type = 'U';
6389 else summon_kin_type = 'u';
6391 case RACE_DRACONIAN:
6392 summon_kin_type = 'd';
6396 summon_kin_type = 'g';
6399 if (one_in_(13)) summon_kin_type = 'L';
6400 else summon_kin_type = 's';
6403 summon_kin_type = 'z';
6406 summon_kin_type = 'V';
6409 summon_kin_type = 'G';
6412 summon_kin_type = 'I';
6415 summon_kin_type = '#';
6418 summon_kin_type = 'A';
6421 summon_kin_type = 'U';
6424 summon_kin_type = 'p';
6429 if (one_in_(13)) summon_kin_type = 'U';
6430 else summon_kin_type = 'u';
6432 case MIMIC_DEMON_LORD:
6433 summon_kin_type = 'U';
6436 summon_kin_type = 'V';
6439 return summon_specific((pet ? -1 : 0), y, x, level, SUMMON_KIN, mode);