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 */
143 * Teleport monster next to a grid near the given location
145 void teleport_monster_to(int m_idx, int ty, int tx, int power)
147 int ny, nx, oy, ox, d, i, min;
151 monster_type *m_ptr = &m_list[m_idx];
155 if (!m_ptr->r_idx) return;
158 if (randint1(100) > power) return;
164 /* Save the old location */
168 /* Minimum distance */
171 /* Look until done */
172 while (look && --attempts)
174 /* Verify max distance */
175 if (dis > 200) dis = 200;
177 /* Try several locations */
178 for (i = 0; i < 500; i++)
182 /* Pick a (possibly illegal) location */
185 ny = rand_spread(ty, dis);
186 nx = rand_spread(tx, dis);
187 d = distance(ty, tx, ny, nx);
188 if ((d >= min) && (d <= dis)) break;
191 /* Ignore illegal locations */
192 if (!in_bounds(ny, nx)) continue;
194 /* Require "empty" floor space */
195 if (!cave_empty_bold(ny, nx)) continue;
197 c_ptr = &cave[ny][nx];
199 /* Hack -- no teleport onto glyph of warding */
200 if (is_glyph_grid(c_ptr)) continue;
201 if (is_explosive_rune_grid(c_ptr)) continue;
203 /* ...nor onto the Pattern */
204 if ((c_ptr->feat >= FEAT_PATTERN_START) &&
205 (c_ptr->feat <= FEAT_PATTERN_XTRA2)) continue;
207 /* No teleporting into vaults and such */
208 /* if (c_ptr->info & (CAVE_ICKY)) continue; */
210 /* This grid looks good */
217 /* Increase the maximum distance */
220 /* Decrease the minimum distance */
224 if (attempts < 1) return;
227 sound(SOUND_TPOTHER);
229 /* Update the new location */
230 cave[ny][nx].m_idx = m_idx;
232 /* Update the old location */
233 cave[oy][ox].m_idx = 0;
235 /* Move the monster */
239 /* Update the monster (new location) */
240 update_mon(m_idx, TRUE);
242 /* Redraw the old grid */
245 /* Redraw the new grid */
248 p_ptr->update |= (PU_MON_LITE);
253 * Teleport the player to a location up to "dis" grids away.
255 * If no such spaces are readily available, the distance may increase.
256 * Try very hard to move the player at least a quarter that distance.
258 * When long-range teleport effects are considered, there is a nasty
259 * tendency to "bounce" the player between two or three different spots
260 * because these are the only spots that are "far enough" way to satisfy
261 * the algorithm. Therefore, if the teleport distance is more than 50,
262 * we decrease the minimum acceptable distance to try to increase randomness.
265 void teleport_player(int dis)
267 int d, i, min, ox, oy;
278 if (p_ptr->wild_mode) return;
280 if (p_ptr->anti_tele)
283 msg_print("ÉԻ׵ĤÊÎϤ¬¥Æ¥ì¥Ý¡¼¥È¤òËɤ¤¤À¡ª");
285 msg_print("A mysterious force prevents you from teleporting!");
291 if (dis > 200) dis = 200; /* To be on the safe side... */
293 /* Minimum distance */
294 min = dis / (dis > 50 ? 3 : 2);
296 /* Look until done */
301 /* Verify max distance */
302 if (dis > 200) dis = 200;
304 /* Try several locations */
305 for (i = 0; i < 500; i++)
307 /* Pick a (possibly illegal) location */
310 y = rand_spread(py, dis);
311 x = rand_spread(px, dis);
312 d = distance(py, px, y, x);
313 if ((d >= min) && (d <= dis)) break;
316 /* Ignore illegal locations */
317 if (!in_bounds(y, x)) continue;
319 /* Require "naked" floor space or trees */
320 if (!(cave_naked_bold(y, x) ||
321 (cave[y][x].feat == FEAT_TREES))) continue;
323 /* No teleporting into vaults and such */
324 if (cave[y][x].info & CAVE_ICKY) continue;
326 /* This grid looks good */
333 /* Increase the maximum distance */
336 /* Decrease the minimum distance */
339 /* Stop after MAX_TRIES tries */
340 if (tries > MAX_TRIES) return;
344 sound(SOUND_TELEPORT);
347 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
348 msg_format("¡Ø¤³¤Ã¤Á¤À¤¡¡¢%s¡Ù", player_name);
351 /* Save the old location */
355 /* Move the player */
362 tmp = cave[py][px].m_idx;
363 cave[py][px].m_idx = cave[oy][ox].m_idx;
364 cave[oy][ox].m_idx = tmp;
365 m_list[p_ptr->riding].fy = py;
366 m_list[p_ptr->riding].fx = px;
367 update_mon(cave[py][px].m_idx, TRUE);
370 /* Redraw the old spot */
373 /* Monsters with teleport ability may follow the player */
374 for (xx = -1; xx < 2; xx++)
376 for (yy = -1; yy < 2; yy++)
378 int tmp_m_idx = cave[oy+yy][ox+xx].m_idx;
380 /* A monster except your mount may follow */
381 if (tmp_m_idx && p_ptr->riding != tmp_m_idx)
383 monster_type *m_ptr = &m_list[tmp_m_idx];
384 monster_race *r_ptr = &r_info[m_ptr->r_idx];
387 * The latter limitation is to avoid
388 * totally unkillable suckers...
390 if ((r_ptr->flags6 & RF6_TPORT) &&
391 !(r_ptr->flagsr & RFR_RES_TELE))
393 if (!m_ptr->csleep) teleport_monster_to(tmp_m_idx, py, px, r_ptr->level);
401 /* Redraw the new spot */
404 /* Check for new panel (redraw map) */
408 p_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MON_LITE);
410 /* Update the monsters */
411 p_ptr->update |= (PU_DISTANCE);
414 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
416 /* Handle stuff XXX XXX XXX */
423 * Teleport player to a grid near the given location
425 * This function is slightly obsessive about correctness.
426 * This function allows teleporting into vaults (!)
428 void teleport_player_to(int ny, int nx, bool no_tele)
430 int y, x, oy, ox, dis = 0, ctr = 0;
432 if (p_ptr->anti_tele && no_tele)
435 msg_print("ÉԻ׵ĤÊÎϤ¬¥Æ¥ì¥Ý¡¼¥È¤òËɤ¤¤À¡ª");
437 msg_print("A mysterious force prevents you from teleporting!");
443 /* Find a usable location */
446 /* Pick a nearby legal location */
449 y = rand_spread(ny, dis);
450 x = rand_spread(nx, dis);
451 if (in_bounds(y, x)) break;
454 /* Accept "naked" floor grids */
457 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;
459 else if (cave_empty_bold(y, x) || player_bold(y, x)) break;
461 /* Occasionally advance the distance */
462 if (++ctr > (4 * dis * dis + 4 * dis + 1))
470 sound(SOUND_TELEPORT);
472 /* Save the old location */
476 /* Move the player */
483 tmp = cave[py][px].m_idx;
484 cave[py][px].m_idx = cave[oy][ox].m_idx;
485 cave[oy][ox].m_idx = tmp;
486 m_list[p_ptr->riding].fy = py;
487 m_list[p_ptr->riding].fx = px;
488 update_mon(cave[py][px].m_idx, TRUE);
493 /* Redraw the old spot */
496 /* Redraw the new spot */
499 /* Check for new panel (redraw map) */
503 p_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MON_LITE);
505 /* Update the monsters */
506 p_ptr->update |= (PU_DISTANCE);
509 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
511 /* Handle stuff XXX XXX XXX */
518 * Teleport the player one level up or down (random when legal)
519 * Note: If m_idx <= 0, target is player.
521 void teleport_level(int m_idx)
527 if (m_idx <= 0) /* To player */
530 strcpy(m_name, "¤¢¤Ê¤¿");
532 strcpy(m_name, "you");
535 else /* To monster */
537 monster_type *m_ptr = &m_list[m_idx];
539 /* Get the monster name (or "it") */
540 monster_desc(m_name, m_ptr, 0);
545 /* No effect in some case */
546 if (TELE_LEVEL_IS_INEFF(m_idx))
549 if (see_m) msg_print("¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡£");
551 if (see_m) msg_print("There is no effect.");
557 if ((m_idx <= 0) && p_ptr->anti_tele) /* To player */
560 msg_print("ÉԻ׵ĤÊÎϤ¬¥Æ¥ì¥Ý¡¼¥È¤òËɤ¤¤À¡ª");
562 msg_print("A mysterious force prevents you from teleporting!");
567 /* Choose up or down */
568 if (randint0(100) < 50) go_up = TRUE;
571 if ((m_idx <= 0) && p_ptr->wizard)
573 if (get_check("Force to go up? ")) go_up = TRUE;
574 else if (get_check("Force to go down? ")) go_up = FALSE;
578 if ((ironman_downward && (m_idx <= 0)) || (dun_level <= d_info[dungeon_type].mindepth))
581 if (see_m) msg_format("%^s¤Ï¾²¤òÆͤÇˤäÆÄÀ¤ó¤Ç¤¤¤¯¡£", m_name);
583 if (see_m) msg_format("%^s sink%s through the floor.", m_name, (m_idx <= 0) ? "" : "s");
585 if (m_idx <= 0) /* To player */
589 dungeon_type = p_ptr->recall_dungeon;
594 if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, 1, NULL);
596 if (autosave_l) do_cmd_save_game(TRUE);
600 dun_level = d_info[dungeon_type].mindepth;
601 prepare_change_floor_mode(CFM_RAND_PLACE | CFM_CLEAR_ALL);
605 prepare_change_floor_mode(CFM_DOWN | CFM_RAND_PLACE | CFM_RAND_CONNECT);
609 p_ptr->leaving = TRUE;
614 else if (quest_number(dun_level) || (dun_level >= d_info[dungeon_type].maxdepth))
617 if (see_m) msg_format("%^s¤ÏÅ·°æ¤òÆͤÇˤäÆÃè¤ØÉ⤤¤Æ¤¤¤¯¡£", m_name);
619 if (see_m) msg_format("%^s rise%s up through the ceiling.", m_name, (m_idx <= 0) ? "" : "s");
623 if (m_idx <= 0) /* To player */
625 if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, -1, NULL);
627 if (autosave_l) do_cmd_save_game(TRUE);
629 prepare_change_floor_mode(CFM_UP | CFM_RAND_PLACE | CFM_RAND_CONNECT);
634 p_ptr->inside_quest = 0;
635 p_ptr->leaving = TRUE;
641 if (see_m) msg_format("%^s¤ÏÅ·°æ¤òÆͤÇˤäÆÃè¤ØÉ⤤¤Æ¤¤¤¯¡£", m_name);
643 if (see_m) msg_format("%^s rise%s up through the ceiling.", m_name, (m_idx <= 0) ? "" : "s");
647 if (m_idx <= 0) /* To player */
649 if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, -1, NULL);
651 if (autosave_l) do_cmd_save_game(TRUE);
653 prepare_change_floor_mode(CFM_UP | CFM_RAND_PLACE | CFM_RAND_CONNECT);
656 p_ptr->leaving = TRUE;
662 if (see_m) msg_format("%^s¤Ï¾²¤òÆͤÇˤäÆÄÀ¤ó¤Ç¤¤¤¯¡£", m_name);
664 if (see_m) msg_format("%^s sink%s through the floor.", m_name, (m_idx <= 0) ? "" : "s");
667 if (m_idx <= 0) /* To player */
669 /* Never reach this code on the surface */
670 /* if (!dun_level) dungeon_type = p_ptr->recall_dungeon; */
672 if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, 1, NULL);
674 if (autosave_l) do_cmd_save_game(TRUE);
676 prepare_change_floor_mode(CFM_DOWN | CFM_RAND_PLACE | CFM_RAND_CONNECT);
679 p_ptr->leaving = TRUE;
683 /* Monster level teleportation is simple deleting now */
686 monster_type *m_ptr = &m_list[m_idx];
688 /* Check for quest completion */
689 check_quest_completion(m_ptr);
691 delete_monster_idx(m_idx);
695 sound(SOUND_TPLEVEL);
700 int choose_dungeon(cptr note, int y, int x)
706 /* Hack -- No need to choose dungeon in some case */
707 if (lite_town || vanilla_town || ironman_downward)
709 if (max_dlv[DUNGEON_ANGBAND]) return DUNGEON_ANGBAND;
713 msg_format("¤Þ¤À%s¤ËÆþ¤Ã¤¿¤³¤È¤Ï¤Ê¤¤¡£", d_name + d_info[DUNGEON_ANGBAND].name);
715 msg_format("You haven't entered %s yet.", d_name + d_info[DUNGEON_ANGBAND].name);
722 /* Allocate the "dun" array */
723 C_MAKE(dun, max_d_idx, s16b);
726 for(i = 1; i < max_d_idx; i++)
731 if (!d_info[i].maxdepth) continue;
732 if (!max_dlv[i]) continue;
733 if (d_info[i].final_guardian)
735 if (!r_info[d_info[i].final_guardian].max_num) seiha = TRUE;
737 else if (max_dlv[i] == d_info[i].maxdepth) seiha = TRUE;
740 sprintf(buf," %c) %c%-12s : ºÇÂç %d ³¬", 'a'+num, seiha ? '!' : ' ', d_name + d_info[i].name, max_dlv[i]);
742 sprintf(buf," %c) %c%-16s : Max level %d", 'a'+num, seiha ? '!' : ' ', d_name + d_info[i].name, max_dlv[i]);
744 prt(buf, y + num, x);
751 prt(" Áª¤Ù¤ë¥À¥ó¥¸¥ç¥ó¤¬¤Ê¤¤¡£", y, x);
753 prt(" No dungeon is available.", y, x);
758 prt(format("¤É¤Î¥À¥ó¥¸¥ç¥ó%s¤·¤Þ¤¹¤«:", note), 0, 0);
760 prt(format("Which dungeon do you %s?: ", note), 0, 0);
765 if ((i == ESCAPE) || !num)
767 /* Free the "dun" array */
768 C_KILL(dun, max_d_idx, s16b);
773 if (i >= 'a' && i <('a'+num))
775 select_dungeon = dun[i-'a'];
782 /* Free the "dun" array */
783 C_KILL(dun, max_d_idx, s16b);
785 return select_dungeon;
790 * Recall the player to town or dungeon
792 bool recall_player(int turns)
795 * TODO: Recall the player to the last
796 * visited town when in the wilderness
800 if (p_ptr->inside_arena || ironman_downward)
803 msg_print("²¿¤âµ¯¤³¤é¤Ê¤«¤Ã¤¿¡£");
805 msg_print("Nothing happens.");
811 if (dun_level && (max_dlv[dungeon_type] > dun_level) && !p_ptr->inside_quest && !p_ptr->word_recall)
814 if (get_check("¤³¤³¤ÏºÇ¿¼Åþ㳬¤è¤êÀõ¤¤³¬¤Ç¤¹¡£¤³¤Î³¬¤ËÌá¤Ã¤ÆÍè¤Þ¤¹¤«¡© "))
816 if (get_check("Reset recall depth? "))
819 max_dlv[dungeon_type] = dun_level;
820 if (record_maxdeapth)
822 do_cmd_write_nikki(NIKKI_TRUMP, dungeon_type, "µ¢´Ô¤Î¤È¤¤Ë");
824 do_cmd_write_nikki(NIKKI_TRUMP, dungeon_type, "when recall from dungeon");
829 if (!p_ptr->word_recall)
835 select_dungeon = choose_dungeon("¤Ëµ¢´Ô", 2, 14);
837 select_dungeon = choose_dungeon("recall", 2, 14);
839 if (!select_dungeon) return FALSE;
840 p_ptr->recall_dungeon = select_dungeon;
842 p_ptr->word_recall = turns;
844 msg_print("²ó¤ê¤ÎÂ絤¤¬Ä¥¤ê¤Ä¤á¤Æ¤¤¿...");
846 msg_print("The air about you becomes charged...");
849 p_ptr->redraw |= (PR_STATUS);
853 p_ptr->word_recall = 0;
855 msg_print("Ä¥¤ê¤Ä¤á¤¿Â絤¤¬Î®¤ìµî¤Ã¤¿...");
857 msg_print("A tension leaves the air around you...");
860 p_ptr->redraw |= (PR_STATUS);
866 bool word_of_recall(void)
868 return(recall_player(randint0(21) + 15));
872 bool reset_recall(void)
874 int select_dungeon, dummy = 0;
879 select_dungeon = choose_dungeon("¤ò¥»¥Ã¥È", 2, 14);
881 select_dungeon = choose_dungeon("reset", 2, 14);
885 if (ironman_downward)
888 msg_print("²¿¤âµ¯¤³¤é¤Ê¤«¤Ã¤¿¡£");
890 msg_print("Nothing happens.");
896 if (!select_dungeon) return FALSE;
899 sprintf(ppp, "²¿³¬¤Ë¥»¥Ã¥È¤·¤Þ¤¹¤« (%d-%d):", d_info[select_dungeon].mindepth, max_dlv[select_dungeon]);
901 sprintf(ppp, "Reset to which level (%d-%d): ", d_info[select_dungeon].mindepth, max_dlv[select_dungeon]);
906 sprintf(tmp_val, "%d", MAX(dun_level, 1));
908 /* Ask for a level */
909 if (get_string(ppp, tmp_val, 10))
911 /* Extract request */
912 dummy = atoi(tmp_val);
915 if (dummy < 1) dummy = 1;
918 if (dummy > max_dlv[select_dungeon]) dummy = max_dlv[select_dungeon];
919 if (dummy < d_info[select_dungeon].mindepth) dummy = d_info[select_dungeon].mindepth;
921 max_dlv[select_dungeon] = dummy;
923 if (record_maxdeapth)
925 do_cmd_write_nikki(NIKKI_TRUMP, select_dungeon, "¥Õ¥í¥¢¡¦¥ê¥»¥Ã¥È¤Ç");
927 do_cmd_write_nikki(NIKKI_TRUMP, select_dungeon, "using a scroll of reset recall");
931 msg_format("%s¤Îµ¢´Ô¥ì¥Ù¥ë¤ò %d ³¬¤Ë¥»¥Ã¥È¡£", d_name+d_info[select_dungeon].name, dummy, dummy * 50);
933 msg_format("Recall depth set to level %d (%d').", dummy, dummy * 50);
946 * Apply disenchantment to the player's stuff
948 * XXX XXX XXX This function is also called from the "melee" code
950 * Return "TRUE" if the player notices anything
952 bool apply_disenchant(int mode)
956 char o_name[MAX_NLEN];
957 int to_h, to_d, to_a, pval;
959 /* Pick a random slot */
962 case 1: t = INVEN_RARM; break;
963 case 2: t = INVEN_LARM; break;
964 case 3: t = INVEN_BOW; break;
965 case 4: t = INVEN_BODY; break;
966 case 5: t = INVEN_OUTER; break;
967 case 6: t = INVEN_HEAD; break;
968 case 7: t = INVEN_HANDS; break;
969 case 8: t = INVEN_FEET; break;
973 o_ptr = &inventory[t];
975 /* No item, nothing happens */
976 if (!o_ptr->k_idx) return (FALSE);
979 /* Nothing to disenchant */
980 if ((o_ptr->to_h <= 0) && (o_ptr->to_d <= 0) && (o_ptr->to_a <= 0) && (o_ptr->pval <= 1))
982 /* Nothing to notice */
987 /* Describe the object */
988 object_desc(o_name, o_ptr, FALSE, 0);
991 /* Artifacts have 71% chance to resist */
992 if ((artifact_p(o_ptr) || o_ptr->art_name) && (randint0(100) < 71))
996 msg_format("%s(%c)¤ÏÎô²½¤òÄ·¤ÍÊÖ¤·¤¿¡ª",o_name, index_to_label(t) );
998 msg_format("Your %s (%c) resist%s disenchantment!",
999 o_name, index_to_label(t),
1000 ((o_ptr->number != 1) ? "" : "s"));
1009 /* Memorize old value */
1015 /* Disenchant tohit */
1016 if (o_ptr->to_h > 0) o_ptr->to_h--;
1017 if ((o_ptr->to_h > 5) && (randint0(100) < 20)) o_ptr->to_h--;
1019 /* Disenchant todam */
1020 if (o_ptr->to_d > 0) o_ptr->to_d--;
1021 if ((o_ptr->to_d > 5) && (randint0(100) < 20)) o_ptr->to_d--;
1023 /* Disenchant toac */
1024 if (o_ptr->to_a > 0) o_ptr->to_a--;
1025 if ((o_ptr->to_a > 5) && (randint0(100) < 20)) o_ptr->to_a--;
1027 /* Disenchant pval (occasionally) */
1028 /* Unless called from wild_magic() */
1029 if ((o_ptr->pval > 1) && one_in_(13) && !(mode & 0x01)) o_ptr->pval--;
1031 if ((to_h != o_ptr->to_h) || (to_d != o_ptr->to_d) ||
1032 (to_a != o_ptr->to_a) || (pval != o_ptr->pval))
1036 msg_format("%s(%c)¤ÏÎô²½¤·¤Æ¤·¤Þ¤Ã¤¿¡ª",
1037 o_name, index_to_label(t) );
1039 msg_format("Your %s (%c) %s disenchanted!",
1040 o_name, index_to_label(t),
1041 ((o_ptr->number != 1) ? "were" : "was"));
1044 chg_virtue(V_HARMONY, 1);
1045 chg_virtue(V_ENCHANT, -2);
1047 /* Recalculate bonuses */
1048 p_ptr->update |= (PU_BONUS);
1051 p_ptr->window |= (PW_EQUIP | PW_PLAYER);
1061 void mutate_player(void)
1063 int max1, cur1, max2, cur2, ii, jj, i;
1065 /* Pick a pair of stats */
1067 for (jj = ii; jj == ii; jj = randint0(6)) /* loop */;
1069 max1 = p_ptr->stat_max[ii];
1070 cur1 = p_ptr->stat_cur[ii];
1071 max2 = p_ptr->stat_max[jj];
1072 cur2 = p_ptr->stat_cur[jj];
1074 p_ptr->stat_max[ii] = max2;
1075 p_ptr->stat_cur[ii] = cur2;
1076 p_ptr->stat_max[jj] = max1;
1077 p_ptr->stat_cur[jj] = cur1;
1081 if(p_ptr->stat_max[i] > p_ptr->stat_max_max[i]) p_ptr->stat_max[i] = p_ptr->stat_max_max[i];
1082 if(p_ptr->stat_cur[i] > p_ptr->stat_max_max[i]) p_ptr->stat_cur[i] = p_ptr->stat_max_max[i];
1085 p_ptr->update |= (PU_BONUS);
1092 void apply_nexus(monster_type *m_ptr)
1094 switch (randint1(7))
1096 case 1: case 2: case 3:
1098 teleport_player(200);
1104 teleport_player_to(m_ptr->fy, m_ptr->fx, TRUE);
1110 if (randint0(100) < p_ptr->skill_sav)
1113 msg_print("¤·¤«¤·¸úÎϤòÄ·¤ÍÊÖ¤·¤¿¡ª");
1115 msg_print("You resist the effects!");
1121 /* Teleport Level */
1128 if (randint0(100) < p_ptr->skill_sav)
1131 msg_print("¤·¤«¤·¸úÎϤòÄ·¤ÍÊÖ¤·¤¿¡ª");
1133 msg_print("You resist the effects!");
1140 msg_print("ÂΤ¬¤Í¤¸¤ì»Ï¤á¤¿...");
1142 msg_print("Your body starts to scramble...");
1153 * Charge a lite (torch or latern)
1155 void phlogiston(void)
1158 object_type * o_ptr = &inventory[INVEN_LITE];
1161 if ((o_ptr->tval == TV_LITE) && (o_ptr->sval == SV_LITE_LANTERN))
1163 max_flog = FUEL_LAMP;
1167 else if ((o_ptr->tval == TV_LITE) && (o_ptr->sval == SV_LITE_TORCH))
1169 max_flog = FUEL_TORCH;
1172 /* No torch to refill */
1176 msg_print("dzÁǤò¾ÃÈñ¤¹¤ë¥¢¥¤¥Æ¥à¤òÁõÈ÷¤·¤Æ¤¤¤Þ¤»¤ó¡£");
1178 msg_print("You are not wielding anything which uses phlogiston.");
1184 if (o_ptr->xtra4 >= max_flog)
1187 msg_print("¤³¤Î¥¢¥¤¥Æ¥à¤Ë¤Ï¤³¤ì°Ê¾ådzÁǤòÊä½¼¤Ç¤¤Þ¤»¤ó¡£");
1189 msg_print("No more phlogiston can be put in this item.");
1196 o_ptr->xtra4 += (max_flog / 2);
1200 msg_print("¾ÈÌÀÍÑ¥¢¥¤¥Æ¥à¤ËdzÁǤòÊä½¼¤·¤¿¡£");
1202 msg_print("You add phlogiston to your light item.");
1207 if (o_ptr->xtra4 >= max_flog)
1209 o_ptr->xtra4 = max_flog;
1211 msg_print("¾ÈÌÀÍÑ¥¢¥¤¥Æ¥à¤ÏËþ¥¿¥ó¤Ë¤Ê¤Ã¤¿¡£");
1213 msg_print("Your light item is full.");
1218 /* Recalculate torch */
1219 p_ptr->update |= (PU_TORCH);
1223 static bool item_tester_hook_weapon_nobow(object_type *o_ptr)
1225 switch (o_ptr->tval)
1235 if (o_ptr->sval != SV_DOKUBARI) return (TRUE);
1243 * Brand the current weapon
1245 void brand_weapon(int brand_type)
1252 /* Assume enchant weapon */
1253 item_tester_hook = item_tester_hook_weapon_nobow;
1254 item_tester_no_ryoute = TRUE;
1258 q = "¤É¤ÎÉð´ï¤ò¶¯²½¤·¤Þ¤¹¤«? ";
1259 s = "¶¯²½¤Ç¤¤ëÉð´ï¤¬¤Ê¤¤¡£";
1261 q = "Enchant which weapon? ";
1262 s = "You have nothing to enchant.";
1265 if (!get_item(&item, q, s, (USE_EQUIP))) return;
1267 /* Get the item (in the pack) */
1270 o_ptr = &inventory[item];
1273 /* Get the item (on the floor) */
1276 o_ptr = &o_list[0 - item];
1280 /* you can never modify artifacts / ego-items */
1281 /* you can never modify cursed items */
1282 /* TY: You _can_ modify broken items (if you're silly enough) */
1283 if (o_ptr->k_idx && !artifact_p(o_ptr) && !ego_item_p(o_ptr) &&
1284 !o_ptr->art_name && !cursed_p(o_ptr) &&
1285 !((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DOKUBARI)) &&
1286 !((o_ptr->tval == TV_POLEARM) && (o_ptr->sval == SV_DEATH_SCYTHE)) &&
1287 !((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DIAMOND_EDGE)))
1291 /* Let's get the name before it is changed... */
1292 char o_name[MAX_NLEN];
1293 object_desc(o_name, o_ptr, FALSE, 0);
1298 if (o_ptr->tval == TV_SWORD)
1301 act = "¤Ï±Ô¤µ¤òÁý¤·¤¿¡ª";
1303 act = "becomes very sharp!";
1306 o_ptr->name2 = EGO_SHARPNESS;
1307 o_ptr->pval = m_bonus(5, dun_level) + 1;
1312 act = "¤ÏÇ˲õÎϤòÁý¤·¤¿¡ª";
1314 act = "seems very powerful.";
1317 o_ptr->name2 = EGO_EARTHQUAKES;
1318 o_ptr->pval = m_bonus(3, dun_level);
1323 act = "¤Ï¿Í´Ö¤Î·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
1325 act = "seems to be looking for humans!";
1328 o_ptr->name2 = EGO_SLAY_HUMAN;
1332 act = "¤ÏÅÅ·â¤Ëʤ¤ï¤ì¤¿¡ª";
1334 act = "covered with lightning!";
1337 o_ptr->name2 = EGO_BRAND_ELEC;
1341 act = "¤Ï»À¤Ëʤ¤ï¤ì¤¿¡ª";
1343 act = "coated with acid!";
1346 o_ptr->name2 = EGO_BRAND_ACID;
1350 act = "¤Ï¼Ù°¤Ê¤ë²øʪ¤òµá¤á¤Æ¤¤¤ë¡ª";
1352 act = "seems to be looking for evil monsters!";
1355 o_ptr->name2 = EGO_SLAY_EVIL;
1359 act = "¤Ï°ÛÀ¤³¦¤Î½»¿Í¤ÎÆùÂΤòµá¤á¤Æ¤¤¤ë¡ª";
1361 act = "seems to be looking for demons!";
1364 o_ptr->name2 = EGO_SLAY_DEMON;
1368 act = "¤Ï»Ó¤òµá¤á¤Æ¤¤¤ë¡ª";
1370 act = "seems to be looking for undead!";
1373 o_ptr->name2 = EGO_SLAY_UNDEAD;
1377 act = "¤Ïưʪ¤Î·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
1379 act = "seems to be looking for animals!";
1382 o_ptr->name2 = EGO_SLAY_ANIMAL;
1386 act = "¤Ï¥É¥é¥´¥ó¤Î·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
1388 act = "seems to be looking for dragons!";
1391 o_ptr->name2 = EGO_SLAY_DRAGON;
1395 act = "¤Ï¥È¥í¥ë¤Î·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
1397 act = "seems to be looking for troll!s";
1400 o_ptr->name2 = EGO_SLAY_TROLL;
1404 act = "¤Ï¥ª¡¼¥¯¤Î·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
1406 act = "seems to be looking for orcs!";
1409 o_ptr->name2 = EGO_SLAY_ORC;
1413 act = "¤Ïµð¿Í¤Î·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
1415 act = "seems to be looking for giants!";
1418 o_ptr->name2 = EGO_SLAY_GIANT;
1422 act = "¤ÏÈó¾ï¤ËÉÔ°ÂÄê¤Ë¤Ê¤Ã¤¿¤è¤¦¤À¡£";
1424 act = "seems very unstable now.";
1427 o_ptr->name2 = EGO_TRUMP;
1428 o_ptr->pval = randint1(2);
1432 act = "¤Ï·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
1434 act = "thirsts for blood!";
1437 o_ptr->name2 = EGO_VAMPIRIC;
1441 act = "¤ÏÆǤËʤ¤ï¤ì¤¿¡£";
1443 act = "is coated with poison.";
1446 o_ptr->name2 = EGO_BRAND_POIS;
1450 act = "¤Ï½ã¥í¥°¥ë¥¹¤Ë°û¤ß¹þ¤Þ¤ì¤¿¡£";
1452 act = "is engulfed in raw Logrus!";
1455 o_ptr->name2 = EGO_CHAOTIC;
1459 act = "¤Ï±ê¤Î¥·¡¼¥ë¥É¤Ëʤ¤ï¤ì¤¿¡ª";
1461 act = "is covered in a fiery shield!";
1464 o_ptr->name2 = EGO_BRAND_FIRE;
1468 act = "¤Ï¿¼¤¯Î䤿¤¤¥Ö¥ë¡¼¤Ëµ±¤¤¤¿¡ª";
1470 act = "glows deep, icy blue!";
1473 o_ptr->name2 = EGO_BRAND_COLD;
1478 msg_format("¤¢¤Ê¤¿¤Î%s%s", o_name, act);
1480 msg_format("Your %s %s", o_name, act);
1484 enchant(o_ptr, randint0(3) + 4, ENCH_TOHIT | ENCH_TODAM);
1486 o_ptr->discount = 99;
1487 chg_virtue(V_ENCHANT, 2);
1491 if (flush_failure) flush();
1494 msg_print("°ÀÉղä˼ºÇÔ¤·¤¿¡£");
1496 msg_print("The Branding failed.");
1499 chg_virtue(V_ENCHANT, -2);
1506 * Determine if a "feature" is a "vanishable"
1507 * Non-permanent walls, trees, mountains, or doors
1509 #define vanishable_feat(F) \
1510 ((!feat_floor(F) && (((F) < FEAT_PERM_EXTRA) || ((F) > FEAT_PERM_SOLID))) || \
1511 ((F) == FEAT_OPEN) || ((F) == FEAT_BROKEN))
1514 * Vanish all walls in this floor
1516 static bool vanish_dungeon(void)
1520 monster_type *m_ptr;
1524 /* Prevent vasishing of quest levels and town */
1525 if ((p_ptr->inside_quest && is_fixed_quest_idx(p_ptr->inside_quest)) || !dun_level)
1530 /* Scan all normal grids */
1531 for (y = 1; y < cur_hgt - 1; y++)
1533 for (x = 1; x < cur_wid - 1; x++)
1535 c_ptr = &cave[y][x];
1537 /* Seeing true feature code (ignore mimic) */
1540 /* Lose room and vault */
1541 c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1546 m_ptr = &m_list[c_ptr->m_idx];
1548 /* Reset sleep counter */
1551 if (r_info[m_ptr->r_idx].flags7 & RF7_HAS_LD_MASK) p_ptr->update |= (PU_MON_LITE);
1553 /* Notice the "waking up" */
1556 /* Acquire the monster name */
1557 monster_desc(m_name, m_ptr, 0);
1559 /* Dump a message */
1561 msg_format("%^s¤¬Ìܤò³Ð¤Þ¤·¤¿¡£", m_name);
1563 msg_format("%^s wakes up.", m_name);
1566 /* Redraw the health bar */
1567 if (p_ptr->health_who == c_ptr->m_idx) p_ptr->redraw |= (PR_HEALTH);
1568 if (p_ptr->riding == c_ptr->m_idx) p_ptr->redraw |= (PR_UHEALTH);
1572 /* Process all walls, doors and patterns */
1573 if (vanishable_feat(feat) || pattern_tile(y, x))
1576 cave_set_feat(y, x, floor_type[randint0(100)]);
1581 /* Special boundary walls -- Top and bottom */
1582 for (x = 0; x < cur_wid; x++)
1584 c_ptr = &cave[0][x];
1586 /* Lose room and vault */
1587 c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1589 /* Set boundary mimic if needed */
1590 if (c_ptr->mimic && vanishable_feat(c_ptr->mimic)) c_ptr->mimic = floor_type[randint0(100)];
1592 c_ptr = &cave[cur_hgt - 1][x];
1594 /* Lose room and vault */
1595 c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1597 /* Set boundary mimic if needed */
1598 if (c_ptr->mimic && vanishable_feat(c_ptr->mimic)) c_ptr->mimic = floor_type[randint0(100)];
1601 /* Special boundary walls -- Left and right */
1602 for (y = 1; y < (cur_hgt - 1); y++)
1604 c_ptr = &cave[y][0];
1606 /* Lose room and vault */
1607 c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1609 /* Set boundary mimic if needed */
1610 if (c_ptr->mimic && vanishable_feat(c_ptr->mimic)) c_ptr->mimic = floor_type[randint0(100)];
1612 c_ptr = &cave[y][cur_wid - 1];
1614 /* Lose room and vault */
1615 c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1617 /* Set boundary mimic if needed */
1618 if (c_ptr->mimic && vanishable_feat(c_ptr->mimic)) c_ptr->mimic = floor_type[randint0(100)];
1621 /* Mega-Hack -- Forget the view and lite */
1622 p_ptr->update |= (PU_UN_VIEW | PU_UN_LITE);
1625 p_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MON_LITE);
1627 /* Update the monsters */
1628 p_ptr->update |= (PU_MONSTERS);
1631 p_ptr->redraw |= (PR_MAP);
1634 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
1640 void call_the_(void)
1644 bool do_call = TRUE;
1646 for (i = 0; i < 9; i++)
1648 y = py + ddy_ddd[i];
1649 x = px + ddx_ddd[i];
1651 if (!cave_floor_bold(y, x) && !boundary_floor_bold(y, x))
1660 for (i = 1; i < 10; i++)
1662 if (i - 5) fire_ball(GF_ROCKET, i, 175, 2);
1665 for (i = 1; i < 10; i++)
1667 if (i - 5) fire_ball(GF_MANA, i, 175, 3);
1670 for (i = 1; i < 10; i++)
1672 if (i - 5) fire_ball(GF_NUKE, i, 175, 4);
1676 /* Prevent destruction of quest levels and town */
1677 else if ((p_ptr->inside_quest && is_fixed_quest_idx(p_ptr->inside_quest)) || !dun_level)
1680 msg_print("ÃÏÌ̤¬Íɤ줿¡£");
1682 msg_print("The ground trembles.");
1689 msg_format("¤¢¤Ê¤¿¤Ï%s¤òÊɤ˶᤹¤®¤ë¾ì½ê¤Ç¾§¤¨¤Æ¤·¤Þ¤Ã¤¿¡ª",
1690 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "µ§¤ê" : "¼öʸ"));
1691 msg_print("Â礤ÊÇúȯ²»¤¬¤¢¤Ã¤¿¡ª");
1693 msg_format("You %s the %s too close to a wall!",
1694 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "recite" : "cast"),
1695 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "prayer" : "spell"));
1696 msg_print("There is a loud explosion!");
1702 if (!vanish_dungeon()) msg_print("¥À¥ó¥¸¥ç¥ó¤Ï°ì½ÖÀŤޤêÊ֤ä¿¡£");
1704 if (!vanish_dungeon()) msg_print("The dungeon silences a moment.");
1709 if (destroy_area(py, px, 15 + p_ptr->lev + randint0(11), FALSE))
1711 msg_print("¥À¥ó¥¸¥ç¥ó¤¬Êø²õ¤·¤¿...");
1713 msg_print("The dungeon collapses...");
1718 msg_print("¥À¥ó¥¸¥ç¥ó¤ÏÂ礤¯Íɤ줿¡£");
1720 msg_print("The dungeon trembles.");
1725 take_hit(DAMAGE_NOESCAPE, 100 + randint1(150), "¼«»¦Åª¤Êµõ̵¾·Íè", -1);
1727 take_hit(DAMAGE_NOESCAPE, 100 + randint1(150), "a suicidal Call the Void", -1);
1734 * Fetch an item (teleport it right underneath the caster)
1736 void fetch(int dir, int wgt, bool require_los)
1741 char o_name[MAX_NLEN];
1743 /* Check to see if an object is already there */
1744 if (cave[py][px].o_idx)
1747 msg_print("¼«Ê¬¤Î¤β¼¤Ë¤¢¤ëʪ¤Ï¼è¤ì¤Þ¤»¤ó¡£");
1749 msg_print("You can't fetch when you're already standing on something.");
1756 if (dir == 5 && target_okay())
1761 if (distance(py, px, ty, tx) > MAX_RANGE)
1764 msg_print("¤½¤ó¤Ê¤Ë±ó¤¯¤Ë¤¢¤ëʪ¤Ï¼è¤ì¤Þ¤»¤ó¡ª");
1766 msg_print("You can't fetch something that far away!");
1772 c_ptr = &cave[ty][tx];
1774 /* We need an item to fetch */
1778 msg_print("¤½¤³¤Ë¤Ï²¿¤â¤¢¤ê¤Þ¤»¤ó¡£");
1780 msg_print("There is no object at this place.");
1786 /* No fetching from vault */
1787 if (c_ptr->info & CAVE_ICKY)
1790 msg_print("¥¢¥¤¥Æ¥à¤¬¥³¥ó¥È¥í¡¼¥ë¤ò³°¤ì¤ÆÍî¤Á¤¿¡£");
1792 msg_print("The item slips from your control.");
1798 /* We need to see the item */
1799 if (require_los && !player_has_los_bold(ty, tx))
1802 msg_print("¤½¤³¤Ï¤¢¤Ê¤¿¤Î»ë³¦¤ËÆþ¤Ã¤Æ¤¤¤Þ¤»¤ó¡£");
1804 msg_print("You have no direct line of sight to that location.");
1812 /* Use a direction */
1813 ty = py; /* Where to drop the item */
1820 c_ptr = &cave[ty][tx];
1822 if ((distance(py, px, ty, tx) > MAX_RANGE) ||
1823 !cave_floor_bold(ty, tx)) return;
1825 while (!c_ptr->o_idx);
1828 o_ptr = &o_list[c_ptr->o_idx];
1830 if (o_ptr->weight > wgt)
1832 /* Too heavy to 'fetch' */
1834 msg_print("¤½¤Î¥¢¥¤¥Æ¥à¤Ï½Å²á¤®¤Þ¤¹¡£");
1836 msg_print("The object is too heavy.");
1843 c_ptr->o_idx = o_ptr->next_o_idx;
1844 cave[py][px].o_idx = i; /* 'move' it */
1845 o_ptr->next_o_idx = 0;
1846 o_ptr->iy = (byte)py;
1847 o_ptr->ix = (byte)px;
1849 object_desc(o_name, o_ptr, TRUE, 0);
1851 msg_format("%^s¤¬¤¢¤Ê¤¿¤Î¸µ¤ËÈô¤ó¤Ç¤¤¿¡£", o_name);
1853 msg_format("%^s flies through the air to your feet.", o_name);
1858 p_ptr->redraw |= PR_MAP;
1862 void alter_reality(void)
1864 /* Ironman option */
1865 if (p_ptr->inside_arena || ironman_downward)
1868 msg_print("²¿¤âµ¯¤³¤é¤Ê¤«¤Ã¤¿¡£");
1870 msg_print("Nothing happens.");
1875 if (!p_ptr->alter_reality)
1877 int turns = randint0(21) + 15;
1879 p_ptr->alter_reality = turns;
1881 msg_print("²ó¤ê¤Î·Ê¿§¤¬ÊѤï¤ê»Ï¤á¤¿...");
1883 msg_print("The view around you begins to change...");
1886 p_ptr->redraw |= (PR_STATUS);
1890 p_ptr->alter_reality = 0;
1892 msg_print("·Ê¿§¤¬¸µ¤ËÌá¤Ã¤¿...");
1894 msg_print("The view around you got back...");
1897 p_ptr->redraw |= (PR_STATUS);
1904 * Leave a "glyph of warding" which prevents monster movement
1906 bool warding_glyph(void)
1909 if (!cave_clean_bold(py, px))
1912 msg_print("¾²¾å¤Î¥¢¥¤¥Æ¥à¤¬¼öʸ¤òÄ·¤ÍÊÖ¤·¤¿¡£");
1914 msg_print("The object resists the spell.");
1920 /* Create a glyph */
1921 cave[py][px].info |= CAVE_OBJECT;
1922 cave[py][px].mimic = FEAT_GLYPH;
1933 bool warding_mirror(void)
1936 if (!cave_clean_bold(py, px))
1939 msg_print("¾²¾å¤Î¥¢¥¤¥Æ¥à¤¬¼öʸ¤òÄ·¤ÍÊÖ¤·¤¿¡£");
1941 msg_print("The object resists the spell.");
1947 /* Create a mirror */
1948 cave[py][px].info |= CAVE_OBJECT;
1949 cave[py][px].mimic = FEAT_MIRROR;
1951 /* Turn on the light */
1952 cave[py][px].info |= CAVE_GLOW;
1965 * Leave an "explosive rune" which prevents monster movement
1967 bool explosive_rune(void)
1970 if (!cave_clean_bold(py, px))
1973 msg_print("¾²¾å¤Î¥¢¥¤¥Æ¥à¤¬¼öʸ¤òÄ·¤ÍÊÖ¤·¤¿¡£");
1975 msg_print("The object resists the spell.");
1981 /* Create a glyph */
1982 cave[py][px].info |= CAVE_OBJECT;
1983 cave[py][px].mimic = FEAT_MINOR_GLYPH;
1996 * Identify everything being carried.
1997 * Done by a potion of "self knowledge".
1999 void identify_pack(void)
2003 /* Simply identify and know every item */
2004 for (i = 0; i < INVEN_TOTAL; i++)
2006 object_type *o_ptr = &inventory[i];
2008 /* Skip non-objects */
2009 if (!o_ptr->k_idx) continue;
2012 identify_item(o_ptr);
2018 * Used by the "enchant" function (chance of failure)
2019 * (modified for Zangband, we need better stuff there...) -- TY
2021 static int enchant_table[16] =
2023 0, 10, 50, 100, 200,
2024 300, 400, 500, 650, 800,
2025 950, 987, 993, 995, 998,
2031 * Removes curses from items in inventory
2033 * Note that Items which are "Perma-Cursed" (The One Ring,
2034 * The Crown of Morgoth) can NEVER be uncursed.
2036 * Note that if "all" is FALSE, then Items which are
2037 * "Heavy-Cursed" (Mormegil, Calris, and Weapons of Morgul)
2038 * will not be uncursed.
2040 static int remove_curse_aux(int all)
2044 /* Attempt to uncurse items being worn */
2045 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
2047 object_type *o_ptr = &inventory[i];
2049 /* Skip non-objects */
2050 if (!o_ptr->k_idx) continue;
2052 /* Uncursed already */
2053 if (!cursed_p(o_ptr)) continue;
2055 /* Heavily Cursed Items need a special spell */
2056 if (!all && (o_ptr->curse_flags & TRC_HEAVY_CURSE)) continue;
2058 /* Perma-Cursed Items can NEVER be uncursed */
2059 if (o_ptr->curse_flags & TRC_PERMA_CURSE)
2062 o_ptr->curse_flags &= (TRC_CURSED | TRC_HEAVY_CURSE | TRC_PERMA_CURSE);
2067 o_ptr->curse_flags = 0L;
2069 /* Hack -- Assume felt */
2070 o_ptr->ident |= (IDENT_SENSE);
2073 o_ptr->feeling = FEEL_NONE;
2075 /* Recalculate the bonuses */
2076 p_ptr->update |= (PU_BONUS);
2079 p_ptr->window |= (PW_EQUIP);
2081 /* Count the uncursings */
2085 /* Return "something uncursed" */
2091 * Remove most curses
2093 bool remove_curse(void)
2095 return (remove_curse_aux(FALSE));
2101 bool remove_all_curse(void)
2103 return (remove_curse_aux(TRUE));
2108 * Turns an object into gold, gain some of its value in a shop
2117 char o_name[MAX_NLEN];
2118 char out_val[MAX_NLEN+40];
2122 /* Hack -- force destruction */
2123 if (command_arg > 0) force = TRUE;
2127 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò¶â¤ËÊѤ¨¤Þ¤¹¤«¡©";
2128 s = "¶â¤ËÊѤ¨¤é¤ì¤ëʪ¤¬¤¢¤ê¤Þ¤»¤ó¡£";
2130 q = "Turn which item to gold? ";
2131 s = "You have nothing to turn to gold.";
2134 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return (FALSE);
2136 /* Get the item (in the pack) */
2139 o_ptr = &inventory[item];
2142 /* Get the item (on the floor) */
2145 o_ptr = &o_list[0 - item];
2149 /* See how many items */
2150 if (o_ptr->number > 1)
2152 /* Get a quantity */
2153 amt = get_quantity(NULL, o_ptr->number);
2155 /* Allow user abort */
2156 if (amt <= 0) return FALSE;
2160 /* Describe the object */
2161 old_number = o_ptr->number;
2162 o_ptr->number = amt;
2163 object_desc(o_name, o_ptr, TRUE, 3);
2164 o_ptr->number = old_number;
2166 /* Verify unless quantity given */
2169 if (confirm_destroy || (object_value(o_ptr) > 0))
2171 /* Make a verification */
2173 sprintf(out_val, "ËÜÅö¤Ë%s¤ò¶â¤ËÊѤ¨¤Þ¤¹¤«¡©", o_name);
2175 sprintf(out_val, "Really turn %s to gold? ", o_name);
2178 if (!get_check(out_val)) return FALSE;
2182 /* Artifacts cannot be destroyed */
2183 if (!can_player_destroy_object(o_ptr))
2187 msg_format("%s¤ò¶â¤ËÊѤ¨¤ë¤³¤È¤Ë¼ºÇÔ¤·¤¿¡£", o_name);
2189 msg_format("You fail to turn %s to gold!", o_name);
2196 price = object_value_real(o_ptr);
2202 msg_format("%s¤ò¥Ë¥»¤Î¶â¤ËÊѤ¨¤¿¡£", o_name);
2204 msg_format("You turn %s to fool's gold.", o_name);
2212 if (amt > 1) price *= amt;
2214 if (price > 30000) price = 30000;
2216 msg_format("%s¤ò¡ð%d ¤Î¶â¤ËÊѤ¨¤¿¡£", o_name, price);
2218 msg_format("You turn %s to %ld coins worth of gold.", o_name, price);
2224 p_ptr->redraw |= (PR_GOLD);
2227 p_ptr->window |= (PW_PLAYER);
2231 /* Eliminate the item (from the pack) */
2234 inven_item_increase(item, -amt);
2235 inven_item_describe(item);
2236 inven_item_optimize(item);
2239 /* Eliminate the item (from the floor) */
2242 floor_item_increase(0 - item, -amt);
2243 floor_item_describe(0 - item);
2244 floor_item_optimize(0 - item);
2253 * Hook to specify "weapon"
2255 bool item_tester_hook_weapon(object_type *o_ptr)
2257 switch (o_ptr->tval)
2271 if (o_ptr->sval != SV_DOKUBARI) return (TRUE);
2278 static bool item_tester_hook_weapon2(object_type *o_ptr)
2280 switch (o_ptr->tval)
2300 * Hook to specify "armour"
2302 bool item_tester_hook_armour(object_type *o_ptr)
2304 switch (o_ptr->tval)
2325 * Check if an object is weapon or armour (but not arrow, bolt, or shot)
2327 bool item_tester_hook_weapon_armour(object_type *o_ptr)
2329 switch (o_ptr->tval)
2358 * Check if an object is nameless weapon or armour
2360 static bool item_tester_hook_nameless_weapon_armour(object_type *o_ptr)
2362 switch (o_ptr->tval)
2381 if (o_ptr->name1 || o_ptr->art_name || o_ptr->name2 || o_ptr->xtra3)
2383 if (object_known_p(o_ptr)) return FALSE;
2393 * Break the curse of an item
2395 static void break_curse(object_type *o_ptr)
2397 if (cursed_p(o_ptr) && !(o_ptr->curse_flags & TRC_PERMA_CURSE) && !(o_ptr->curse_flags & TRC_HEAVY_CURSE) && (randint0(100) < 25))
2400 msg_print("¤«¤±¤é¤ì¤Æ¤¤¤¿¼ö¤¤¤¬ÂǤÁÇˤé¤ì¤¿¡ª");
2402 msg_print("The curse is broken!");
2405 o_ptr->curse_flags = 0L;
2407 o_ptr->ident |= (IDENT_SENSE);
2409 o_ptr->feeling = FEEL_NONE;
2415 * Enchants a plus onto an item. -RAK-
2417 * Revamped! Now takes item pointer, number of times to try enchanting,
2418 * and a flag of what to try enchanting. Artifacts resist enchantment
2419 * some of the time, and successful enchantment to at least +0 might
2420 * break a curse on the item. -CFT-
2422 * Note that an item can technically be enchanted all the way to +15 if
2423 * you wait a very, very, long time. Going from +9 to +10 only works
2424 * about 5% of the time, and from +10 to +11 only about 1% of the time.
2426 * Note that this function can now be used on "piles" of items, and
2427 * the larger the pile, the lower the chance of success.
2429 bool enchant(object_type *o_ptr, int n, int eflag)
2431 int i, chance, prob;
2433 bool a = (artifact_p(o_ptr) || o_ptr->art_name);
2434 bool force = (eflag & ENCH_FORCE);
2437 /* Large piles resist enchantment */
2438 prob = o_ptr->number * 100;
2440 /* Missiles are easy to enchant */
2441 if ((o_ptr->tval == TV_BOLT) ||
2442 (o_ptr->tval == TV_ARROW) ||
2443 (o_ptr->tval == TV_SHOT))
2449 for (i = 0; i < n; i++)
2451 /* Hack -- Roll for pile resistance */
2452 if (!force && randint0(prob) >= 100) continue;
2454 /* Enchant to hit */
2455 if (eflag & ENCH_TOHIT)
2457 if (o_ptr->to_h < 0) chance = 0;
2458 else if (o_ptr->to_h > 15) chance = 1000;
2459 else chance = enchant_table[o_ptr->to_h];
2461 if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50))))
2466 /* only when you get it above -1 -CFT */
2467 if (o_ptr->to_h >= 0)
2472 /* Enchant to damage */
2473 if (eflag & ENCH_TODAM)
2475 if (o_ptr->to_d < 0) chance = 0;
2476 else if (o_ptr->to_d > 15) chance = 1000;
2477 else chance = enchant_table[o_ptr->to_d];
2479 if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50))))
2484 /* only when you get it above -1 -CFT */
2485 if (o_ptr->to_d >= 0)
2490 /* Enchant to armor class */
2491 if (eflag & ENCH_TOAC)
2493 if (o_ptr->to_a < 0) chance = 0;
2494 else if (o_ptr->to_a > 15) chance = 1000;
2495 else chance = enchant_table[o_ptr->to_a];
2497 if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50))))
2502 /* only when you get it above -1 -CFT */
2503 if (o_ptr->to_a >= 0)
2510 if (!res) return (FALSE);
2512 /* Recalculate bonuses */
2513 p_ptr->update |= (PU_BONUS);
2515 /* Combine / Reorder the pack (later) */
2516 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
2519 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
2530 * Enchant an item (in the inventory or on the floor)
2531 * Note that "num_ac" requires armour, else weapon
2532 * Returns TRUE if attempted, FALSE if cancelled
2534 bool enchant_spell(int num_hit, int num_dam, int num_ac)
2539 char o_name[MAX_NLEN];
2543 /* Assume enchant weapon */
2544 item_tester_hook = item_tester_hook_weapon;
2545 item_tester_no_ryoute = TRUE;
2547 /* Enchant armor if requested */
2548 if (num_ac) item_tester_hook = item_tester_hook_armour;
2552 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò¶¯²½¤·¤Þ¤¹¤«? ";
2553 s = "¶¯²½¤Ç¤¤ë¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
2555 q = "Enchant which item? ";
2556 s = "You have nothing to enchant.";
2559 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2561 /* Get the item (in the pack) */
2564 o_ptr = &inventory[item];
2567 /* Get the item (on the floor) */
2570 o_ptr = &o_list[0 - item];
2575 object_desc(o_name, o_ptr, FALSE, 0);
2579 msg_format("%s ¤ÏÌÀ¤ë¤¯µ±¤¤¤¿¡ª",
2582 msg_format("%s %s glow%s brightly!",
2583 ((item >= 0) ? "Your" : "The"), o_name,
2584 ((o_ptr->number > 1) ? "" : "s"));
2589 if (enchant(o_ptr, num_hit, ENCH_TOHIT)) okay = TRUE;
2590 if (enchant(o_ptr, num_dam, ENCH_TODAM)) okay = TRUE;
2591 if (enchant(o_ptr, num_ac, ENCH_TOAC)) okay = TRUE;
2597 if (flush_failure) flush();
2601 msg_print("¶¯²½¤Ë¼ºÇÔ¤·¤¿¡£");
2603 msg_print("The enchantment failed.");
2606 if (one_in_(3)) chg_virtue(V_ENCHANT, -1);
2609 chg_virtue(V_ENCHANT, 1);
2613 /* Something happened */
2618 bool artifact_scroll(void)
2623 char o_name[MAX_NLEN];
2627 item_tester_no_ryoute = TRUE;
2628 /* Enchant weapon/armour */
2629 item_tester_hook = item_tester_hook_nameless_weapon_armour;
2633 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò¶¯²½¤·¤Þ¤¹¤«? ";
2634 s = "¶¯²½¤Ç¤¤ë¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
2636 q = "Enchant which item? ";
2637 s = "You have nothing to enchant.";
2640 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2642 /* Get the item (in the pack) */
2645 o_ptr = &inventory[item];
2648 /* Get the item (on the floor) */
2651 o_ptr = &o_list[0 - item];
2656 object_desc(o_name, o_ptr, FALSE, 0);
2660 msg_format("%s ¤ÏâÁ¤¤¸÷¤òȯ¤·¤¿¡ª",o_name);
2662 msg_format("%s %s radiate%s a blinding light!",
2663 ((item >= 0) ? "Your" : "The"), o_name,
2664 ((o_ptr->number > 1) ? "" : "s"));
2667 if (o_ptr->name1 || o_ptr->art_name)
2670 msg_format("%s¤Ï´û¤ËÅÁÀâ¤Î¥¢¥¤¥Æ¥à¤Ç¤¹¡ª", o_name );
2672 msg_format("The %s %s already %s!",
2673 o_name, ((o_ptr->number > 1) ? "are" : "is"),
2674 ((o_ptr->number > 1) ? "artifacts" : "an artifact"));
2680 else if (o_ptr->name2)
2683 msg_format("%s¤Ï´û¤Ë̾¤Î¤¢¤ë¥¢¥¤¥Æ¥à¤Ç¤¹¡ª", o_name );
2685 msg_format("The %s %s already %s!",
2686 o_name, ((o_ptr->number > 1) ? "are" : "is"),
2687 ((o_ptr->number > 1) ? "ego items" : "an ego item"));
2693 else if (o_ptr->xtra3)
2696 msg_format("%s¤Ï´û¤Ë¶¯²½¤µ¤ì¤Æ¤¤¤Þ¤¹¡ª", o_name );
2698 msg_format("The %s %s already %s!",
2699 o_name, ((o_ptr->number > 1) ? "are" : "is"),
2700 ((o_ptr->number > 1) ? "customized items" : "a customized item"));
2706 if (o_ptr->number > 1)
2709 msg_print("Ê£¿ô¤Î¥¢¥¤¥Æ¥à¤ËËâË¡¤ò¤«¤±¤ë¤À¤±¤Î¥¨¥Í¥ë¥®¡¼¤Ï¤¢¤ê¤Þ¤»¤ó¡ª");
2710 msg_format("%d ¸Ä¤Î%s¤¬²õ¤ì¤¿¡ª",(o_ptr->number)-1, o_name);
2712 msg_print("Not enough enough energy to enchant more than one object!");
2713 msg_format("%d of your %s %s destroyed!",(o_ptr->number)-1, o_name, (o_ptr->number>2?"were":"was"));
2718 inven_item_increase(item, 1-(o_ptr->number));
2722 floor_item_increase(0-item, 1-(o_ptr->number));
2725 okay = create_artifact(o_ptr, TRUE);
2732 if (flush_failure) flush();
2736 msg_print("¶¯²½¤Ë¼ºÇÔ¤·¤¿¡£");
2738 msg_print("The enchantment failed.");
2741 if (one_in_(3)) chg_virtue(V_ENCHANT, -1);
2744 chg_virtue(V_ENCHANT, 1);
2748 /* Something happened */
2754 * Identify an object
2756 bool identify_item(object_type *o_ptr)
2758 bool old_known = FALSE;
2759 char o_name[MAX_NLEN];
2762 object_desc(o_name, o_ptr, TRUE, 3);
2764 if (o_ptr->ident & IDENT_KNOWN)
2767 if (!(o_ptr->ident & (IDENT_MENTAL)))
2769 if ((o_ptr->art_name) || (artifact_p(o_ptr)) || one_in_(5))
2770 chg_virtue(V_KNOWLEDGE, 1);
2773 /* Identify it fully */
2774 object_aware(o_ptr);
2775 object_known(o_ptr);
2777 /* Recalculate bonuses */
2778 p_ptr->update |= (PU_BONUS);
2780 /* Combine / Reorder the pack (later) */
2781 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
2784 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
2786 strcpy(record_o_name, o_name);
2790 object_desc(o_name, o_ptr, TRUE, 0);
2792 if(record_fix_art && !old_known && artifact_p(o_ptr))
2793 do_cmd_write_nikki(NIKKI_ART, 0, o_name);
2794 if(record_rand_art && !old_known && o_ptr->art_name)
2795 do_cmd_write_nikki(NIKKI_ART, 0, o_name);
2801 static bool item_tester_hook_identify(object_type *o_ptr)
2803 return (bool)!object_known_p(o_ptr);
2806 static bool item_tester_hook_identify_weapon_armour(object_type *o_ptr)
2808 if (object_known_p(o_ptr))
2810 return item_tester_hook_weapon_armour(o_ptr);
2814 * Identify an object in the inventory (or on the floor)
2815 * This routine does *not* automatically combine objects.
2816 * Returns TRUE if something was identified, else FALSE.
2818 bool ident_spell(bool only_equip)
2822 char o_name[MAX_NLEN];
2827 item_tester_no_ryoute = TRUE;
2830 item_tester_hook = item_tester_hook_identify_weapon_armour;
2832 item_tester_hook = item_tester_hook_identify;
2834 if (!can_get_item())
2838 item_tester_hook = item_tester_hook_weapon_armour;
2842 item_tester_hook = NULL;
2848 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò´ÕÄꤷ¤Þ¤¹¤«? ";
2849 s = "´ÕÄꤹ¤ë¤Ù¤¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
2851 q = "Identify which item? ";
2852 s = "You have nothing to identify.";
2855 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2857 /* Get the item (in the pack) */
2860 o_ptr = &inventory[item];
2863 /* Get the item (on the floor) */
2866 o_ptr = &o_list[0 - item];
2870 old_known = identify_item(o_ptr);
2873 object_desc(o_name, o_ptr, TRUE, 3);
2876 if (item >= INVEN_RARM)
2879 msg_format("%^s: %s(%c)¡£", describe_use(item), o_name, index_to_label(item));
2881 msg_format("%^s: %s (%c).", describe_use(item), o_name, index_to_label(item));
2887 msg_format("¥¶¥Ã¥¯Ãæ: %s(%c)¡£", o_name, index_to_label(item));
2889 msg_format("In your pack: %s (%c).", o_name, index_to_label(item));
2895 msg_format("¾²¾å: %s¡£", o_name);
2897 msg_format("On the ground: %s.", o_name);
2901 /* Auto-inscription/destroy */
2902 idx = is_autopick(o_ptr);
2903 auto_inscribe_item(item, idx);
2904 if (destroy_identify && !old_known)
2905 auto_destroy_item(item, idx);
2907 /* Something happened */
2913 * Mundanify an object in the inventory (or on the floor)
2914 * This routine does *not* automatically combine objects.
2915 * Returns TRUE if something was mundanified, else FALSE.
2917 bool mundane_spell(bool only_equip)
2923 if (only_equip) item_tester_hook = item_tester_hook_weapon_armour;
2924 item_tester_no_ryoute = TRUE;
2928 q = "¤É¤ì¤ò»È¤¤¤Þ¤¹¤«¡©";
2929 s = "»È¤¨¤ë¤â¤Î¤¬¤¢¤ê¤Þ¤»¤ó¡£";
2931 q = "Use which item? ";
2932 s = "You have nothing you can use.";
2935 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2937 /* Get the item (in the pack) */
2940 o_ptr = &inventory[item];
2943 /* Get the item (on the floor) */
2946 o_ptr = &o_list[0 - item];
2951 msg_print("¤Þ¤Ð¤æ¤¤Á®¸÷¤¬Áö¤Ã¤¿¡ª");
2953 msg_print("There is a bright flash of light!");
2956 byte iy = o_ptr->iy; /* Y-position on map, or zero */
2957 byte ix = o_ptr->ix; /* X-position on map, or zero */
2958 s16b next_o_idx = o_ptr->next_o_idx; /* Next object in stack (if any) */
2959 byte marked = o_ptr->marked; /* Object is marked */
2960 s16b weight = o_ptr->number * o_ptr->weight;
2961 u16b inscription = o_ptr->inscription;
2964 object_prep(o_ptr, o_ptr->k_idx);
2968 o_ptr->next_o_idx = next_o_idx;
2969 o_ptr->marked = marked;
2970 o_ptr->inscription = inscription;
2971 if (item >= 0) p_ptr->total_weight += (o_ptr->weight - weight);
2975 /* Something happened */
2981 static bool item_tester_hook_identify_fully(object_type *o_ptr)
2983 return (bool)(!object_known_p(o_ptr) || !(o_ptr->ident & IDENT_MENTAL));
2986 static bool item_tester_hook_identify_fully_weapon_armour(object_type *o_ptr)
2988 if (!item_tester_hook_identify_fully(o_ptr))
2990 return item_tester_hook_weapon_armour(o_ptr);
2994 * Fully "identify" an object in the inventory -BEN-
2995 * This routine returns TRUE if an item was identified.
2997 bool identify_fully(bool only_equip)
3001 char o_name[MAX_NLEN];
3006 item_tester_no_ryoute = TRUE;
3008 item_tester_hook = item_tester_hook_identify_fully_weapon_armour;
3010 item_tester_hook = item_tester_hook_identify_fully;
3012 if (!can_get_item())
3015 item_tester_hook = item_tester_hook_weapon_armour;
3017 item_tester_hook = NULL;
3022 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò´ÕÄꤷ¤Þ¤¹¤«? ";
3023 s = "´ÕÄꤹ¤ë¤Ù¤¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
3025 q = "Identify which item? ";
3026 s = "You have nothing to identify.";
3029 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
3031 /* Get the item (in the pack) */
3034 o_ptr = &inventory[item];
3037 /* Get the item (on the floor) */
3040 o_ptr = &o_list[0 - item];
3044 old_known = identify_item(o_ptr);
3046 /* Mark the item as fully known */
3047 o_ptr->ident |= (IDENT_MENTAL);
3053 object_desc(o_name, o_ptr, TRUE, 3);
3056 if (item >= INVEN_RARM)
3059 msg_format("%^s: %s(%c)¡£", describe_use(item), o_name, index_to_label(item));
3061 msg_format("%^s: %s (%c).", describe_use(item), o_name, index_to_label(item));
3069 msg_format("¥¶¥Ã¥¯Ãæ: %s(%c)¡£", o_name, index_to_label(item));
3071 msg_format("In your pack: %s (%c).", o_name, index_to_label(item));
3077 msg_format("¾²¾å: %s¡£", o_name);
3079 msg_format("On the ground: %s.", o_name);
3083 /* Describe it fully */
3084 (void)screen_object(o_ptr, TRUE);
3086 /* Auto-inscription/destroy */
3087 idx = is_autopick(o_ptr);
3088 auto_inscribe_item(item, idx);
3089 if (destroy_identify && !old_known)
3090 auto_destroy_item(item, idx);
3100 * Hook for "get_item()". Determine if something is rechargable.
3102 bool item_tester_hook_recharge(object_type *o_ptr)
3104 /* Recharge staffs */
3105 if (o_ptr->tval == TV_STAFF) return (TRUE);
3107 /* Recharge wands */
3108 if (o_ptr->tval == TV_WAND) return (TRUE);
3110 /* Hack -- Recharge rods */
3111 if (o_ptr->tval == TV_ROD) return (TRUE);
3119 * Recharge a wand/staff/rod from the pack or on the floor.
3120 * This function has been rewritten in Oangband and ZAngband.
3122 * Sorcery/Arcane -- Recharge --> recharge(plev * 4)
3123 * Chaos -- Arcane Binding --> recharge(90)
3125 * Scroll of recharging --> recharge(130)
3126 * Artifact activation/Thingol --> recharge(130)
3128 * It is harder to recharge high level, and highly charged wands,
3129 * staffs, and rods. The more wands in a stack, the more easily and
3130 * strongly they recharge. Staffs, however, each get fewer charges if
3133 * XXX XXX XXX Beware of "sliding index errors".
3135 bool recharge(int power)
3138 int recharge_strength, recharge_amount;
3147 char o_name[MAX_NLEN];
3149 /* Only accept legal items */
3150 item_tester_hook = item_tester_hook_recharge;
3154 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ËËâÎϤò½¼Å¶¤·¤Þ¤¹¤«? ";
3155 s = "ËâÎϤò½¼Å¶¤¹¤Ù¤¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
3157 q = "Recharge which item? ";
3158 s = "You have nothing to recharge.";
3161 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return (FALSE);
3163 /* Get the item (in the pack) */
3166 o_ptr = &inventory[item];
3169 /* Get the item (on the floor) */
3172 o_ptr = &o_list[0 - item];
3175 /* Get the object kind. */
3176 k_ptr = &k_info[o_ptr->k_idx];
3178 /* Extract the object "level" */
3179 lev = get_object_level(o_ptr);
3182 /* Recharge a rod */
3183 if (o_ptr->tval == TV_ROD)
3185 /* Extract a recharge strength by comparing object level to power. */
3186 recharge_strength = ((power > lev/2) ? (power - lev/2) : 0) / 5;
3190 if (one_in_(recharge_strength))
3192 /* Activate the failure code. */
3199 /* Recharge amount */
3200 recharge_amount = (power * damroll(3, 2));
3202 /* Recharge by that amount */
3203 if (o_ptr->timeout > recharge_amount)
3204 o_ptr->timeout -= recharge_amount;
3211 /* Recharge wand/staff */
3214 /* Extract a recharge strength by comparing object level to power.
3215 * Divide up a stack of wands' charges to calculate charge penalty.
3217 if ((o_ptr->tval == TV_WAND) && (o_ptr->number > 1))
3218 recharge_strength = (100 + power - lev -
3219 (8 * o_ptr->pval / o_ptr->number)) / 15;
3221 /* All staffs, unstacked wands. */
3222 else recharge_strength = (100 + power - lev -
3223 (8 * o_ptr->pval)) / 15;
3226 if (recharge_strength < 0) recharge_strength = 0;
3229 if (one_in_(recharge_strength))
3231 /* Activate the failure code. */
3235 /* If the spell didn't backfire, recharge the wand or staff. */
3238 /* Recharge based on the standard number of charges. */
3239 recharge_amount = randint1(1 + k_ptr->pval / 2);
3241 /* Multiple wands in a stack increase recharging somewhat. */
3242 if ((o_ptr->tval == TV_WAND) && (o_ptr->number > 1))
3245 (randint1(recharge_amount * (o_ptr->number - 1))) / 2;
3246 if (recharge_amount < 1) recharge_amount = 1;
3247 if (recharge_amount > 12) recharge_amount = 12;
3250 /* But each staff in a stack gets fewer additional charges,
3251 * although always at least one.
3253 if ((o_ptr->tval == TV_STAFF) && (o_ptr->number > 1))
3255 recharge_amount /= o_ptr->number;
3256 if (recharge_amount < 1) recharge_amount = 1;
3259 /* Recharge the wand or staff. */
3260 o_ptr->pval += recharge_amount;
3263 /* Hack -- we no longer "know" the item */
3264 o_ptr->ident &= ~(IDENT_KNOWN);
3266 /* Hack -- we no longer think the item is empty */
3267 o_ptr->ident &= ~(IDENT_EMPTY);
3272 /* Inflict the penalties for failing a recharge. */
3275 /* Artifacts are never destroyed. */
3276 if (artifact_p(o_ptr))
3278 object_desc(o_name, o_ptr, TRUE, 0);
3280 msg_format("ËâÎϤ¬µÕή¤·¤¿¡ª%s¤Ï´°Á´¤ËËâÎϤò¼º¤Ã¤¿¡£", o_name);
3282 msg_format("The recharging backfires - %s is completely drained!", o_name);
3286 /* Artifact rods. */
3287 if ((o_ptr->tval == TV_ROD) && (o_ptr->timeout < 10000))
3288 o_ptr->timeout = (o_ptr->timeout + 100) * 2;
3290 /* Artifact wands and staffs. */
3291 else if ((o_ptr->tval == TV_WAND) || (o_ptr->tval == TV_STAFF))
3296 /* Get the object description */
3297 object_desc(o_name, o_ptr, FALSE, 0);
3299 /*** Determine Seriousness of Failure ***/
3301 /* Mages recharge objects more safely. */
3302 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)
3304 /* 10% chance to blow up one rod, otherwise draining. */
3305 if (o_ptr->tval == TV_ROD)
3307 if (one_in_(10)) fail_type = 2;
3310 /* 75% chance to blow up one wand, otherwise draining. */
3311 else if (o_ptr->tval == TV_WAND)
3313 if (!one_in_(3)) fail_type = 2;
3316 /* 50% chance to blow up one staff, otherwise no effect. */
3317 else if (o_ptr->tval == TV_STAFF)
3319 if (one_in_(2)) fail_type = 2;
3324 /* All other classes get no special favors. */
3327 /* 33% chance to blow up one rod, otherwise draining. */
3328 if (o_ptr->tval == TV_ROD)
3330 if (one_in_(3)) fail_type = 2;
3333 /* 20% chance of the entire stack, else destroy one wand. */
3334 else if (o_ptr->tval == TV_WAND)
3336 if (one_in_(5)) fail_type = 3;
3339 /* Blow up one staff. */
3340 else if (o_ptr->tval == TV_STAFF)
3346 /*** Apply draining and destruction. ***/
3348 /* Drain object or stack of objects. */
3351 if (o_ptr->tval == TV_ROD)
3354 msg_print("ËâÎϤ¬µÕÊ®¼Í¤·¤Æ¡¢¥í¥Ã¥É¤«¤é¤µ¤é¤ËËâÎϤòµÛ¤¤¼è¤Ã¤Æ¤·¤Þ¤Ã¤¿¡ª");
3356 msg_print("The recharge backfires, draining the rod further!");
3359 if (o_ptr->timeout < 10000)
3360 o_ptr->timeout = (o_ptr->timeout + 100) * 2;
3362 else if (o_ptr->tval == TV_WAND)
3365 msg_format("%s¤ÏÇË»¤òÌȤ줿¤¬¡¢ËâÎϤ¬Á´¤Æ¼º¤ï¤ì¤¿¡£", o_name);
3367 msg_format("You save your %s from destruction, but all charges are lost.", o_name);
3372 /* Staffs aren't drained. */
3375 /* Destroy an object or one in a stack of objects. */
3378 if (o_ptr->number > 1)
3380 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬°ìËܲõ¤ì¤¿¡ª", o_name);
3382 msg_format("Wild magic consumes one of your %s!", o_name);
3387 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬²õ¤ì¤¿¡ª", o_name);
3389 msg_format("Wild magic consumes your %s!", o_name);
3393 /* Reduce rod stack maximum timeout, drain wands. */
3394 if (o_ptr->tval == TV_ROD) o_ptr->timeout = (o_ptr->number - 1) * k_ptr->pval;
3395 if (o_ptr->tval == TV_WAND) o_ptr->pval = 0;
3397 /* Reduce and describe inventory */
3400 inven_item_increase(item, -1);
3401 inven_item_describe(item);
3402 inven_item_optimize(item);
3405 /* Reduce and describe floor item */
3408 floor_item_increase(0 - item, -1);
3409 floor_item_describe(0 - item);
3410 floor_item_optimize(0 - item);
3414 /* Destroy all members of a stack of objects. */
3417 if (o_ptr->number > 1)
3419 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬Á´¤Æ²õ¤ì¤¿¡ª", o_name);
3421 msg_format("Wild magic consumes all your %s!", o_name);
3426 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬²õ¤ì¤¿¡ª", o_name);
3428 msg_format("Wild magic consumes your %s!", o_name);
3433 /* Reduce and describe inventory */
3436 inven_item_increase(item, -999);
3437 inven_item_describe(item);
3438 inven_item_optimize(item);
3441 /* Reduce and describe floor item */
3444 floor_item_increase(0 - item, -999);
3445 floor_item_describe(0 - item);
3446 floor_item_optimize(0 - item);
3452 /* Combine / Reorder the pack (later) */
3453 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
3456 p_ptr->window |= (PW_INVEN);
3458 /* Something was done */
3466 bool bless_weapon(void)
3470 u32b flgs[TR_FLAG_SIZE];
3471 char o_name[MAX_NLEN];
3474 item_tester_no_ryoute = TRUE;
3475 /* Assume enchant weapon */
3476 item_tester_hook = item_tester_hook_weapon2;
3480 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò½ËÊ¡¤·¤Þ¤¹¤«¡©";
3481 s = "½ËÊ¡¤Ç¤¤ëÉð´ï¤¬¤¢¤ê¤Þ¤»¤ó¡£";
3483 q = "Bless which weapon? ";
3484 s = "You have weapon to bless.";
3487 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR)))
3490 /* Get the item (in the pack) */
3493 o_ptr = &inventory[item];
3496 /* Get the item (on the floor) */
3499 o_ptr = &o_list[0 - item];
3504 object_desc(o_name, o_ptr, FALSE, 0);
3506 /* Extract the flags */
3507 object_flags(o_ptr, flgs);
3509 if (cursed_p(o_ptr))
3511 if (((o_ptr->curse_flags & TRC_HEAVY_CURSE) && (randint1(100) < 33)) ||
3512 (o_ptr->curse_flags & TRC_PERMA_CURSE))
3515 msg_format("%s¤òʤ¤¦¹õ¤¤¥ª¡¼¥é¤Ï½ËÊ¡¤òÄ·¤ÍÊÖ¤·¤¿¡ª",
3518 msg_format("The black aura on %s %s disrupts the blessing!",
3519 ((item >= 0) ? "your" : "the"), o_name);
3526 msg_format("%s ¤«¤é¼Ù°¤Ê¥ª¡¼¥é¤¬¾Ã¤¨¤¿¡£",
3529 msg_format("A malignant aura leaves %s %s.",
3530 ((item >= 0) ? "your" : "the"), o_name);
3535 o_ptr->curse_flags = 0L;
3537 /* Hack -- Assume felt */
3538 o_ptr->ident |= (IDENT_SENSE);
3541 o_ptr->feeling = FEEL_NONE;
3543 /* Recalculate the bonuses */
3544 p_ptr->update |= (PU_BONUS);
3547 p_ptr->window |= (PW_EQUIP);
3551 * Next, we try to bless it. Artifacts have a 1/3 chance of
3552 * being blessed, otherwise, the operation simply disenchants
3553 * them, godly power negating the magic. Ok, the explanation
3554 * is silly, but otherwise priests would always bless every
3555 * artifact weapon they find. Ego weapons and normal weapons
3556 * can be blessed automatically.
3558 if (have_flag(flgs, TR_BLESSED))
3561 msg_format("%s ¤Ï´û¤Ë½ËÊ¡¤µ¤ì¤Æ¤¤¤ë¡£",
3564 msg_format("%s %s %s blessed already.",
3565 ((item >= 0) ? "Your" : "The"), o_name,
3566 ((o_ptr->number > 1) ? "were" : "was"));
3572 if (!(o_ptr->art_name || o_ptr->name1 || o_ptr->name2) || one_in_(3))
3576 msg_format("%s¤Ïµ±¤¤¤¿¡ª",
3579 msg_format("%s %s shine%s!",
3580 ((item >= 0) ? "Your" : "The"), o_name,
3581 ((o_ptr->number > 1) ? "" : "s"));
3584 add_flag(o_ptr->art_flags, TR_BLESSED);
3585 o_ptr->discount = 99;
3589 bool dis_happened = FALSE;
3592 msg_print("¤½¤ÎÉð´ï¤Ï½ËÊ¡¤ò·ù¤Ã¤Æ¤¤¤ë¡ª");
3594 msg_print("The weapon resists your blessing!");
3598 /* Disenchant tohit */
3599 if (o_ptr->to_h > 0)
3602 dis_happened = TRUE;
3605 if ((o_ptr->to_h > 5) && (randint0(100) < 33)) o_ptr->to_h--;
3607 /* Disenchant todam */
3608 if (o_ptr->to_d > 0)
3611 dis_happened = TRUE;
3614 if ((o_ptr->to_d > 5) && (randint0(100) < 33)) o_ptr->to_d--;
3616 /* Disenchant toac */
3617 if (o_ptr->to_a > 0)
3620 dis_happened = TRUE;
3623 if ((o_ptr->to_a > 5) && (randint0(100) < 33)) o_ptr->to_a--;
3628 msg_print("¼þ°Ï¤¬ËÞÍǤÊÊ·°Ïµ¤¤ÇËþ¤Á¤¿...");
3630 msg_print("There is a static feeling in the air...");
3634 msg_format("%s ¤ÏÎô²½¤·¤¿¡ª",
3637 msg_format("%s %s %s disenchanted!",
3638 ((item >= 0) ? "Your" : "The"), o_name,
3639 ((o_ptr->number > 1) ? "were" : "was"));
3645 /* Recalculate bonuses */
3646 p_ptr->update |= (PU_BONUS);
3649 p_ptr->window |= (PW_EQUIP | PW_PLAYER);
3660 bool pulish_shield(void)
3664 u32b flgs[TR_FLAG_SIZE];
3665 char o_name[MAX_NLEN];
3668 item_tester_no_ryoute = TRUE;
3669 /* Assume enchant weapon */
3670 item_tester_tval = TV_SHIELD;
3674 q = "¤É¤Î½â¤òËᤤޤ¹¤«¡©";
3675 s = "Ë᤯½â¤¬¤¢¤ê¤Þ¤»¤ó¡£";
3677 q = "Pulish which weapon? ";
3678 s = "You have weapon to pulish.";
3681 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR)))
3684 /* Get the item (in the pack) */
3687 o_ptr = &inventory[item];
3690 /* Get the item (on the floor) */
3693 o_ptr = &o_list[0 - item];
3698 object_desc(o_name, o_ptr, FALSE, 0);
3700 /* Extract the flags */
3701 object_flags(o_ptr, flgs);
3703 if (o_ptr->k_idx && !artifact_p(o_ptr) && !ego_item_p(o_ptr) &&
3704 !o_ptr->art_name && !cursed_p(o_ptr) && (o_ptr->sval != SV_MIRROR_SHIELD))
3707 msg_format("%s¤Ïµ±¤¤¤¿¡ª", o_name);
3709 msg_format("%s %s shine%s!",
3710 ((item >= 0) ? "Your" : "The"), o_name,
3711 ((o_ptr->number > 1) ? "" : "s"));
3713 o_ptr->name2 = EGO_REFLECTION;
3714 enchant(o_ptr, randint0(3) + 4, ENCH_TOAC);
3716 o_ptr->discount = 99;
3717 chg_virtue(V_ENCHANT, 2);
3723 if (flush_failure) flush();
3726 msg_print("¼ºÇÔ¤·¤¿¡£");
3728 msg_print("Failed.");
3731 chg_virtue(V_ENCHANT, -2);
3740 * Potions "smash open" and cause an area effect when
3741 * (1) they are shattered while in the player's inventory,
3742 * due to cold (etc) attacks;
3743 * (2) they are thrown at a monster, or obstacle;
3744 * (3) they are shattered by a "cold ball" or other such spell
3745 * while lying on the floor.
3748 * who --- who caused the potion to shatter (0=player)
3749 * potions that smash on the floor are assumed to
3750 * be caused by no-one (who = 1), as are those that
3751 * shatter inside the player inventory.
3752 * (Not anymore -- I changed this; TY)
3753 * y, x --- coordinates of the potion (or player if
3754 * the potion was in her inventory);
3755 * o_ptr --- pointer to the potion object.
3757 bool potion_smash_effect(int who, int y, int x, int k_idx)
3764 object_kind *k_ptr = &k_info[k_idx];
3766 switch (k_ptr->sval)
3768 case SV_POTION_SALT_WATER:
3769 case SV_POTION_SLIME_MOLD:
3770 case SV_POTION_LOSE_MEMORIES:
3771 case SV_POTION_DEC_STR:
3772 case SV_POTION_DEC_INT:
3773 case SV_POTION_DEC_WIS:
3774 case SV_POTION_DEC_DEX:
3775 case SV_POTION_DEC_CON:
3776 case SV_POTION_DEC_CHR:
3777 case SV_POTION_WATER: /* perhaps a 'water' attack? */
3778 case SV_POTION_APPLE_JUICE:
3781 case SV_POTION_INFRAVISION:
3782 case SV_POTION_DETECT_INVIS:
3783 case SV_POTION_SLOW_POISON:
3784 case SV_POTION_CURE_POISON:
3785 case SV_POTION_BOLDNESS:
3786 case SV_POTION_RESIST_HEAT:
3787 case SV_POTION_RESIST_COLD:
3788 case SV_POTION_HEROISM:
3789 case SV_POTION_BESERK_STRENGTH:
3790 case SV_POTION_RES_STR:
3791 case SV_POTION_RES_INT:
3792 case SV_POTION_RES_WIS:
3793 case SV_POTION_RES_DEX:
3794 case SV_POTION_RES_CON:
3795 case SV_POTION_RES_CHR:
3796 case SV_POTION_INC_STR:
3797 case SV_POTION_INC_INT:
3798 case SV_POTION_INC_WIS:
3799 case SV_POTION_INC_DEX:
3800 case SV_POTION_INC_CON:
3801 case SV_POTION_INC_CHR:
3802 case SV_POTION_AUGMENTATION:
3803 case SV_POTION_ENLIGHTENMENT:
3804 case SV_POTION_STAR_ENLIGHTENMENT:
3805 case SV_POTION_SELF_KNOWLEDGE:
3806 case SV_POTION_EXPERIENCE:
3807 case SV_POTION_RESISTANCE:
3808 case SV_POTION_INVULNERABILITY:
3809 case SV_POTION_NEW_LIFE:
3810 /* All of the above potions have no effect when shattered */
3812 case SV_POTION_SLOWNESS:
3817 case SV_POTION_POISON:
3822 case SV_POTION_BLINDNESS:
3826 case SV_POTION_CONFUSION: /* Booze */
3830 case SV_POTION_SLEEP:
3834 case SV_POTION_RUINATION:
3835 case SV_POTION_DETONATIONS:
3837 dam = damroll(25, 25);
3840 case SV_POTION_DEATH:
3841 dt = GF_DEATH_RAY; /* !! */
3842 dam = k_ptr->level * 10;
3846 case SV_POTION_SPEED:
3849 case SV_POTION_CURE_LIGHT:
3851 dam = damroll(2, 3);
3853 case SV_POTION_CURE_SERIOUS:
3855 dam = damroll(4, 3);
3857 case SV_POTION_CURE_CRITICAL:
3858 case SV_POTION_CURING:
3860 dam = damroll(6, 3);
3862 case SV_POTION_HEALING:
3864 dam = damroll(10, 10);
3866 case SV_POTION_RESTORE_EXP:
3871 case SV_POTION_LIFE:
3873 dam = damroll(50, 50);
3876 case SV_POTION_STAR_HEALING:
3878 dam = damroll(50, 50);
3881 case SV_POTION_RESTORE_MANA: /* MANA */
3883 dam = damroll(10, 10);
3890 (void)project(who, radius, y, x, dam, dt,
3891 (PROJECT_JUMP | PROJECT_ITEM | PROJECT_KILL), -1);
3893 /* XXX those potions that explode need to become "known" */
3899 * Hack -- Display all known spells in a window
3901 * XXX XXX XXX Need to analyze size of the window.
3903 * XXX XXX XXX Need more color coding.
3905 void display_spell_list(void)
3918 /* They have too many spells to list */
3919 if (p_ptr->pclass == CLASS_SORCERER) return;
3920 if (p_ptr->pclass == CLASS_RED_MAGE) return;
3922 /* mind.c type classes */
3923 if ((p_ptr->pclass == CLASS_MINDCRAFTER) ||
3924 (p_ptr->pclass == CLASS_BERSERKER) ||
3925 (p_ptr->pclass == CLASS_NINJA) ||
3926 (p_ptr->pclass == CLASS_MIRROR_MASTER) ||
3927 (p_ptr->pclass == CLASS_FORCETRAINER))
3933 int plev = p_ptr->lev;
3939 bool use_hp = FALSE;
3941 /* Display a list of spells */
3944 put_str("̾Á°", y, x + 5);
3945 put_str("Lv MP ¼ºÎ¨ ¸ú²Ì", y, x + 35);
3947 put_str("Name", y, x + 5);
3948 put_str("Lv Mana Fail Info", y, x + 35);
3951 switch(p_ptr->pclass)
3953 case CLASS_MINDCRAFTER: use_mind = MIND_MINDCRAFTER;break;
3954 case CLASS_FORCETRAINER: use_mind = MIND_KI;break;
3955 case CLASS_BERSERKER: use_mind = MIND_BERSERKER; use_hp = TRUE; break;
3956 case CLASS_MIRROR_MASTER: use_mind = MIND_MIRROR_MASTER; break;
3957 case CLASS_NINJA: use_mind = MIND_NINJUTSU; use_hp = TRUE; break;
3958 default: use_mind = 0;break;
3961 /* Dump the spells */
3962 for (i = 0; i < MAX_MIND_POWERS; i++)
3964 byte a = TERM_WHITE;
3966 /* Access the available spell */
3967 spell = mind_powers[use_mind].info[i];
3968 if (spell.min_lev > plev) break;
3970 /* Get the failure rate */
3971 chance = spell.fail;
3973 /* Reduce failure rate by "effective" level adjustment */
3974 chance -= 3 * (p_ptr->lev - spell.min_lev);
3976 /* Reduce failure rate by INT/WIS adjustment */
3977 chance -= 3 * (adj_mag_stat[p_ptr->stat_ind[mp_ptr->spell_stat]] - 1);
3981 /* Not enough mana to cast */
3982 if (spell.mana_cost > p_ptr->csp)
3984 chance += 5 * (spell.mana_cost - p_ptr->csp);
3990 /* Not enough hp to cast */
3991 if (spell.mana_cost > p_ptr->chp)
3998 /* Extract the minimum failure rate */
3999 minfail = adj_mag_fail[p_ptr->stat_ind[mp_ptr->spell_stat]];
4001 /* Minimum failure rate */
4002 if (chance < minfail) chance = minfail;
4004 /* Stunning makes spells harder */
4005 if (p_ptr->stun > 50) chance += 25;
4006 else if (p_ptr->stun) chance += 15;
4008 /* Always a 5 percent chance of working */
4009 if (chance > 95) chance = 95;
4012 mindcraft_info(comment, use_mind, i);
4014 /* Dump the spell */
4015 sprintf(psi_desc, " %c) %-30s%2d %4d %3d%%%s",
4017 spell.min_lev, spell.mana_cost, chance, comment);
4019 Term_putstr(x, y + i + 1, -1, a, psi_desc);
4024 /* Cannot read spellbooks */
4025 if (REALM_NONE == p_ptr->realm1) return;
4027 /* Normal spellcaster with books */
4030 for (j = 0; j < ((p_ptr->realm2 > REALM_NONE) ? 2 : 1); j++)
4034 /* Reset vertical */
4037 /* Vertical location */
4038 y = (j < 3) ? 0 : (m[j - 3] + 2);
4040 /* Horizontal location */
4044 for (i = 0; i < 32; i++)
4046 byte a = TERM_WHITE;
4048 /* Access the spell */
4049 if (!is_magic((j < 1) ? p_ptr->realm1 : p_ptr->realm2))
4051 s_ptr = &technic_info[((j < 1) ? p_ptr->realm1 : p_ptr->realm2) - MIN_TECHNIC][i % 32];
4055 s_ptr = &mp_ptr->info[((j < 1) ? p_ptr->realm1 : p_ptr->realm2) - 1][i % 32];
4058 strcpy(name, spell_names[technic2magic((j < 1) ? p_ptr->realm1 : p_ptr->realm2)-1][i % 32]);
4061 if (s_ptr->slevel >= 99)
4065 strcpy(name, "(ȽÆÉÉÔǽ)");
4067 strcpy(name, "(illegible)");
4077 ((p_ptr->spell_forgotten1 & (1L << i))) :
4078 ((p_ptr->spell_forgotten2 & (1L << (i % 32)))))
4085 else if (!((j < 1) ?
4086 (p_ptr->spell_learned1 & (1L << i)) :
4087 (p_ptr->spell_learned2 & (1L << (i % 32)))))
4094 else if (!((j < 1) ?
4095 (p_ptr->spell_worked1 & (1L << i)) :
4096 (p_ptr->spell_worked2 & (1L << (i % 32)))))
4102 /* Dump the spell --(-- */
4103 sprintf(out_val, "%c/%c) %-20.20s",
4104 I2A(n / 8), I2A(n % 8), name);
4109 /* Dump onto the window */
4110 Term_putstr(x, m[j], -1, a, out_val);
4120 * Returns experience of a spell
4122 s16b experience_of_spell(int spell, int use_realm)
4124 if (p_ptr->pclass == CLASS_SORCERER) return SPELL_EXP_MASTER;
4125 else if (p_ptr->pclass == CLASS_RED_MAGE) return SPELL_EXP_SKILLED;
4126 else if (use_realm == p_ptr->realm1) return p_ptr->spell_exp[spell];
4127 else if (use_realm == p_ptr->realm2) return p_ptr->spell_exp[spell + 32];
4133 * Modify mana consumption rate using spell exp and p_ptr->dec_mana
4135 int mod_need_mana(int need_mana, int spell, int realm)
4137 #define MANA_CONST 2400
4139 #define DEC_MANA_DIV 3
4142 if ((realm > REALM_NONE) && (realm <= MAX_REALM))
4145 * need_mana defaults if spell exp equals SPELL_EXP_EXPERT and !p_ptr->dec_mana.
4146 * MANA_CONST is used to calculate need_mana effected from spell proficiency.
4148 need_mana = need_mana * (MANA_CONST + SPELL_EXP_EXPERT - experience_of_spell(spell, realm)) + (MANA_CONST - 1);
4149 need_mana *= p_ptr->dec_mana ? DEC_MANA_DIV : MANA_DIV;
4150 need_mana /= MANA_CONST * MANA_DIV;
4151 if (need_mana < 1) need_mana = 1;
4154 /* Non-realm magic */
4157 if (p_ptr->dec_mana) need_mana = (need_mana + 1) * DEC_MANA_DIV / MANA_DIV;
4169 * Modify spell fail rate
4170 * Using p_ptr->to_m_chance, p_ptr->dec_mana, p_ptr->easy_spell and p_ptr->heavy_spell
4172 int mod_spell_chance_1(int chance)
4174 chance += p_ptr->to_m_chance;
4176 if (p_ptr->heavy_spell) chance += 20;
4178 if (p_ptr->dec_mana && p_ptr->easy_spell) chance -= 4;
4179 else if (p_ptr->easy_spell) chance -= 3;
4180 else if (p_ptr->dec_mana) chance -= 2;
4187 * Modify spell fail rate (as "suffix" process)
4188 * Using p_ptr->dec_mana, p_ptr->easy_spell and p_ptr->heavy_spell
4189 * Note: variable "chance" cannot be negative.
4191 int mod_spell_chance_2(int chance)
4193 if (p_ptr->dec_mana) chance--;
4195 if (p_ptr->heavy_spell) chance += 5;
4197 return MAX(chance, 0);
4202 * Returns spell chance of failure for spell -RAK-
4204 s16b spell_chance(int spell, int use_realm)
4206 int chance, minfail;
4209 int penalty = (mp_ptr->spell_stat == A_WIS) ? 10 : 4;
4212 /* Paranoia -- must be literate */
4213 if (!mp_ptr->spell_book) return (100);
4215 if (use_realm == REALM_HISSATSU) return 0;
4217 /* Access the spell */
4218 if (!is_magic(use_realm))
4220 s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
4224 s_ptr = &mp_ptr->info[use_realm - 1][spell];
4227 /* Extract the base spell failure rate */
4228 chance = s_ptr->sfail;
4230 /* Reduce failure rate by "effective" level adjustment */
4231 chance -= 3 * (p_ptr->lev - s_ptr->slevel);
4233 /* Reduce failure rate by INT/WIS adjustment */
4234 chance -= 3 * (adj_mag_stat[p_ptr->stat_ind[mp_ptr->spell_stat]] - 1);
4237 chance += (MAX(r_info[m_list[p_ptr->riding].r_idx].level - p_ptr->skill_exp[GINOU_RIDING] / 100 - 10, 0));
4239 /* Extract mana consumption rate */
4240 need_mana = mod_need_mana(s_ptr->smana, spell, use_realm);
4242 /* Not enough mana to cast */
4243 if (need_mana > p_ptr->csp)
4245 chance += 5 * (need_mana - p_ptr->csp);
4248 if ((use_realm != p_ptr->realm1) && ((p_ptr->pclass == CLASS_MAGE) || (p_ptr->pclass == CLASS_PRIEST))) chance += 5;
4250 /* Extract the minimum failure rate */
4251 minfail = adj_mag_fail[p_ptr->stat_ind[mp_ptr->spell_stat]];
4254 * Non mage/priest characters never get too good
4255 * (added high mage, mindcrafter)
4257 if (mp_ptr->spell_xtra & MAGIC_FAIL_5PERCENT)
4259 if (minfail < 5) minfail = 5;
4262 /* Hack -- Priest prayer penalty for "edged" weapons -DGK */
4263 if (((p_ptr->pclass == CLASS_PRIEST) || (p_ptr->pclass == CLASS_SORCERER)) && p_ptr->icky_wield[0]) chance += 25;
4264 if (((p_ptr->pclass == CLASS_PRIEST) || (p_ptr->pclass == CLASS_SORCERER)) && p_ptr->icky_wield[1]) chance += 25;
4266 chance = mod_spell_chance_1(chance);
4268 if ((use_realm == REALM_NATURE) && ((p_ptr->align > 50) || (p_ptr->align < -50))) chance += penalty;
4269 if (((use_realm == REALM_LIFE) || (use_realm == REALM_CRUSADE)) && (p_ptr->align < -20)) chance += penalty;
4270 if (((use_realm == REALM_DEATH) || (use_realm == REALM_DAEMON)) && (p_ptr->align > 20)) chance += penalty;
4272 /* Minimum failure rate */
4273 if (chance < minfail) chance = minfail;
4275 /* Stunning makes spells harder */
4276 if (p_ptr->stun > 50) chance += 25;
4277 else if (p_ptr->stun) chance += 15;
4279 /* Always a 5 percent chance of working */
4280 if (chance > 95) chance = 95;
4282 if ((use_realm == p_ptr->realm1) || (use_realm == p_ptr->realm2)
4283 || (p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE))
4285 s16b exp = experience_of_spell(spell, use_realm);
4286 if (exp >= SPELL_EXP_EXPERT) chance--;
4287 if (exp >= SPELL_EXP_MASTER) chance--;
4290 /* Return the chance */
4291 return mod_spell_chance_2(chance);
4297 * Determine if a spell is "okay" for the player to cast or study
4298 * The spell must be legible, not forgotten, and also, to cast,
4299 * it must be known, and to study, it must not be known.
4301 bool spell_okay(int spell, bool learned, bool study_pray, int use_realm)
4305 /* Access the spell */
4306 if (!is_magic(use_realm))
4308 s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
4312 s_ptr = &mp_ptr->info[use_realm - 1][spell];
4315 /* Spell is illegal */
4316 if (s_ptr->slevel > p_ptr->lev) return (FALSE);
4318 /* Spell is forgotten */
4319 if ((use_realm == p_ptr->realm2) ?
4320 (p_ptr->spell_forgotten2 & (1L << spell)) :
4321 (p_ptr->spell_forgotten1 & (1L << spell)))
4327 if (p_ptr->pclass == CLASS_SORCERER) return (TRUE);
4328 if (p_ptr->pclass == CLASS_RED_MAGE) return (TRUE);
4330 /* Spell is learned */
4331 if ((use_realm == p_ptr->realm2) ?
4332 (p_ptr->spell_learned2 & (1L << spell)) :
4333 (p_ptr->spell_learned1 & (1L << spell)))
4336 return (!study_pray);
4339 /* Okay to study, not to cast */
4346 * Extra information on a spell -DRS-
4348 * We can use up to 14 characters of the buffer 'p'
4350 * The strings in this function were extracted from the code in the
4351 * functions "do_cmd_cast()" and "do_cmd_pray()" and may be dated.
4353 static void spell_info(char *p, int spell, int use_realm)
4355 int plev = p_ptr->lev;
4358 int orb = plev + (plev / ((p_ptr->pclass == CLASS_PRIEST ||
4359 p_ptr->pclass == CLASS_HIGH_MAGE ||
4360 p_ptr->pclass == CLASS_SORCERER) ? 2 : 4));
4362 int burst = plev + (plev / ((p_ptr->pclass == CLASS_MAGE ||
4363 p_ptr->pclass == CLASS_HIGH_MAGE ||
4364 p_ptr->pclass == CLASS_SORCERER) ? 2 : 4));
4366 cptr s_dam = "»½ý:";
4367 cptr s_dur = "´ü´Ö:";
4368 cptr s_range = "ÈÏ°Ï:";
4369 cptr s_heal = "²óÉü:";
4370 cptr s_random = "¥é¥ó¥À¥à";
4371 cptr s_delay = "ÃÙ±ä:";
4373 cptr s_dam = "dam ";
4374 cptr s_dur = "dur ";
4375 cptr s_range = "range ";
4376 cptr s_heal = "heal ";
4377 cptr s_random = "random";
4378 cptr s_delay = "delay ";
4383 /* Analyze the spell */
4386 case REALM_LIFE: /* Life */
4389 case 0: sprintf(p, " %s2d10", s_heal); break;
4390 case 1: sprintf(p, " %s12+d12", s_dur); break;
4391 case 2: sprintf(p, " %s%dd4", s_dam, 3 + ((plev - 1) / 5)); break;
4392 case 3: sprintf(p, " %s%d", s_dam, 10 + (plev / 2)); break;
4393 case 5: sprintf(p, " %s4d10", s_heal); break;
4394 case 9: sprintf(p, " %s%dd8", s_dam, 8 + ((plev - 1) / 5)); break;
4395 case 10: sprintf(p, " %s8d10", s_heal); break;
4396 case 11: sprintf(p, " %s20+d20", s_dur); break;
4397 case 14: sprintf(p, " %s300", s_heal); break;
4398 case 18: sprintf(p, " %sd%d", s_dam, 5 * plev); break;
4399 case 20: sprintf(p, " %s%dd15", s_dam, 5 + ((plev - 1) / 3)); break;
4400 case 21: sprintf(p, " %s15+d21", s_delay); break;
4401 case 29: sprintf(p, " %s2000", s_heal); break;
4402 case 31: sprintf(p, " %s%d+d%d", s_dur,(plev/2), (plev/2)); break;
4406 case REALM_SORCERY: /* Sorcery */
4409 case 1: sprintf(p, " %s10", s_range); break;
4410 case 3: sprintf(p, " %s%d", s_dam, 10 + (plev / 2)); break;
4411 case 5: sprintf(p, " %s%d", s_range, plev * 5); break;
4412 case 13: sprintf(p, " %s%d+d%d", s_dur, plev, plev + 20); break;
4413 case 18: sprintf(p, " %s25+d30", s_dur); break;
4414 case 22: sprintf(p, " %s15+d21", s_delay); break;
4415 case 23: sprintf(p, " %s%d", s_range, plev / 2 + 10); break;
4416 case 25: sprintf(p, " %s7d7+%d", s_dam, plev); break;
4418 case 26: sprintf(p, " ºÇÂç½ÅÎÌ:%d.%dkg", lbtokg1(plev * 15),lbtokg2(plev * 15)); break;
4420 case 26: sprintf(p, " max wgt %d", plev * 15 / 10); break;
4422 case 27: sprintf(p, " %s25+d30", s_dur); break;
4423 case 31: sprintf(p, " %s4+d4", s_dur); break;
4427 case REALM_NATURE: /* Nature */
4431 case 1: sprintf(p, " %s%dd4 ¼ÍÄø%d", s_dam, (3 + ((plev - 1) / 5)), plev/6+2); break;
4433 case 1: sprintf(p, " %s%dd4 rng %d", s_dam, (3 + ((plev - 1) / 5)), plev/6+2); break;
4435 case 4: sprintf(p, " %s%d", s_dam, 10 + (plev / 2)); break;
4436 case 6: sprintf(p, " %s20+d20", s_dur); break;
4437 case 7: sprintf(p, " %s2d8", s_heal); break;
4438 case 9: sprintf(p, " %s%dd8", s_dam, (3 + ((plev - 5) / 4))); break;
4439 case 11: sprintf(p, " %s%dd8", s_dam, (5 + ((plev - 5) / 4))); break;
4440 case 12: sprintf(p, " %s6d8", s_dam); break;
4441 case 15: sprintf(p, " %s500", s_heal); break;
4442 case 17: sprintf(p, " %s20+d30", s_dur); break;
4443 case 18: sprintf(p, " %s20+d20", s_dur); break;
4445 case 24: sprintf(p, " Ⱦ·Â:10"); break;
4447 case 24: sprintf(p, " rad 10"); break;
4449 case 26: sprintf(p, " %s%d", s_dam, 70 + plev * 3 / 2); break;
4450 case 27: sprintf(p, " %s%d", s_dam, 90 + plev * 3 / 2); break;
4451 case 28: sprintf(p, " %s%d", s_dam, 100 + plev * 3 / 2); break;
4452 case 29: sprintf(p, " %s75", s_dam); break;
4453 case 31: sprintf(p, " %s%d+%d", s_dam, 4 * plev, 100 + plev); break;
4457 case REALM_CHAOS: /* Chaos */
4460 case 0: sprintf(p, " %s%dd4", s_dam, 3 + ((plev - 1) / 5)); break;
4461 case 2: sprintf(p, " %s%d", s_dam, 10 + (plev / 2)); break;
4462 case 4: sprintf(p, " %s3d5+%d", s_dam, burst); break;
4463 case 5: sprintf(p, " %s%dd8", s_dam, (6 + ((plev - 5) / 4))); break;
4464 case 6: sprintf(p, " %s%dd8", s_dam, (8 + ((plev - 5) / 4))); break;
4465 case 7: sprintf(p, " %s%d", s_range, plev * 5); break;
4466 case 8: sprintf(p, " %s", s_random); break;
4467 case 9: sprintf(p, " %s%dd8", s_dam, (10 + ((plev - 5) / 4))); break;
4468 case 10: sprintf(p, " %s%d", s_dam, (60 + plev)/2); break;
4469 case 11: sprintf(p, " %s%dd8", s_dam, (11 + ((plev - 5) / 4))); break;
4470 case 12: sprintf(p, " %s%d", s_dam, 55 + plev); break;
4471 case 15: sprintf(p, " %s%d", s_dam, 99 + plev*2); break;
4472 case 17: sprintf(p, " %s%dd8", s_dam, (5 + (plev / 10))); break;
4473 case 19: sprintf(p, " %s%d", s_dam, 70 + plev); break;
4474 case 21: sprintf(p, " %s%d", s_dam, 120 + plev*2); break;
4475 case 24: sprintf(p, " %s%dd8", s_dam, (9 + (plev / 10))); break;
4477 case 25: sprintf(p, " %s³Æ%d", s_dam, plev * 2); break;
4479 case 25: sprintf(p, " dam %d each", plev * 2); break;
4481 case 26: sprintf(p, " %s%d", s_dam, 150 + plev*3/2); break;
4482 case 27: sprintf(p, " %s150 / 250", s_dam); break;
4483 case 29: sprintf(p, " %s%d", s_dam, 300 + (plev * 4)); break;
4484 case 30: sprintf(p, " %s%d", s_dam, p_ptr->chp); break;
4485 case 31: sprintf(p, " %s3 * 175", s_dam); break;
4489 case REALM_DEATH: /* Death */
4492 case 1: sprintf(p, " %s%dd3", s_dam, (3 + ((plev - 1) / 5))); break;
4493 case 3: sprintf(p, " %s%d", s_dam, 10 + (plev / 2)); break;
4494 case 5: sprintf(p, " %s20+d20", s_dur); break;
4495 case 8: sprintf(p, " %s3d6+%d", s_dam, burst); break;
4496 case 9: sprintf(p, " %s%dd8", s_dam, (8 + ((plev - 5) / 4))); break;
4497 case 10: sprintf(p, " %s%d", s_dam, 30+plev); break;
4499 case 13: sprintf(p, " »:%d+d%d", plev * 2, plev * 2); break;
4501 case 13: sprintf(p, " d %d+d%d", plev * 2, plev * 2); break;
4503 case 16: sprintf(p, " %s25+d25", s_dur); break;
4504 case 17: sprintf(p, " %s", s_random); break;
4505 case 18: sprintf(p, " %s%dd8", s_dam, (4 + ((plev - 5) / 4))); break;
4506 case 19: sprintf(p, " %s25+d25", s_dur); break;
4507 case 21: sprintf(p, " %s3*100", s_dam); break;
4508 case 22: sprintf(p, " %sd%d", s_dam, plev * 3); break;
4509 case 23: sprintf(p, " %s%d", s_dam, 100 + plev * 2); break;
4510 case 27: sprintf(p, " %s%d+d%d", s_dur,10+plev/2, 10+plev/2); break;
4511 case 30: sprintf(p, " %s666", s_dam); break;
4512 case 31: sprintf(p, " %s%d+d%d", s_dur, (plev / 2), (plev / 2)); break;
4516 case REALM_TRUMP: /* Trump */
4519 case 0: sprintf(p, " %s10", s_range); break;
4520 case 2: sprintf(p, " %s", s_random); break;
4521 case 4: sprintf(p, " %s%d", s_range, plev * 4); break;
4522 case 5: sprintf(p, " %s25+d30", s_dur); break;
4524 case 8: sprintf(p, " ºÇÂç½ÅÎÌ:%d.%d", lbtokg1(plev * 15 / 10),lbtokg2(plev * 15 / 10)); break;
4526 case 8: sprintf(p, " max wgt %d", plev * 15 / 10); break;
4528 case 13: sprintf(p, " %s%d", s_range, plev / 2 + 10); break;
4529 case 14: sprintf(p, " %s15+d21", s_delay); break;
4530 case 26: sprintf(p, " %s%d", s_heal, plev * 10 + 200); break;
4532 case 28: sprintf(p, " %s³Æ%d", s_dam, plev * 2); break;
4534 case 28: sprintf(p, " %s%d each", s_dam, plev * 2); break;
4539 case REALM_ARCANE: /* Arcane */
4542 case 0: sprintf(p, " %s%dd3", s_dam, 3 + ((plev - 1) / 5)); break;
4543 case 4: sprintf(p, " %s10", s_range); break;
4544 case 5: sprintf(p, " %s2d%d", s_dam, plev / 2); break;
4545 case 7: sprintf(p, " %s2d8", s_heal); break;
4549 case 17: sprintf(p, " %s20+d20", s_dur); break;
4550 case 18: sprintf(p, " %s4d8", s_heal); break;
4551 case 19: sprintf(p, " %s%d", s_range, plev * 5); break;
4552 case 21: sprintf(p, " %s6d8", s_dam); break;
4553 case 24: sprintf(p, " %s24+d24", s_dur); break;
4554 case 28: sprintf(p, " %s%d", s_dam, 75 + plev); break;
4555 case 30: sprintf(p, " %s15+d21", s_delay); break;
4556 case 31: sprintf(p, " %s25+d30", s_dur); break;
4560 case REALM_ENCHANT: /* Craft */
4563 case 0: sprintf(p, " %s100+d100", s_dur); break;
4564 case 1: sprintf(p, " %s80+d80", s_dur); break;
4570 case 18: sprintf(p, " %s20+d20", s_dur); break;
4571 case 5: sprintf(p, " %s25+d25", s_dur); break;
4572 case 8: sprintf(p, " %s24+d24", s_dur); break;
4573 case 11: sprintf(p, " %s25+d25", s_dur); break;
4574 case 13: sprintf(p, " %s%d+d25", s_dur, plev * 3); break;
4575 case 15: sprintf(p, " %s%d+d%d", s_dur, plev/2, plev/2); break;
4576 case 16: sprintf(p, " %s25+d30", s_dur); break;
4577 case 17: sprintf(p, " %s30+d20", s_dur); break;
4578 case 19: sprintf(p, " %s%d+d%d", s_dur, plev, plev+20); break;
4579 case 20: sprintf(p, " %s50+d50", s_dur); break;
4580 case 23: sprintf(p, " %s20+d20", s_dur); break;
4581 case 31: sprintf(p, " %s13+d13", s_dur); break;
4585 case REALM_DAEMON: /* Daemon */
4588 case 0: sprintf(p, " %s%dd4", s_dam, 3 + ((plev - 1) / 5)); break;
4589 case 2: sprintf(p, " %s12+d12", s_dur); break;
4590 case 3: sprintf(p, " %s20+d20", s_dur); break;
4591 case 5: sprintf(p, " %s%dd8", s_dam, (6 + ((plev - 5) / 4))); break;
4592 case 7: sprintf(p, " %s3d6+%d", s_dam, burst); break;
4593 case 10: sprintf(p, " %s20+d20", s_dur); break;
4594 case 11: sprintf(p, " %s%dd8", s_dam, (11 + ((plev - 5) / 4))); break;
4595 case 12: sprintf(p, " %s%d", s_dam, 55 + plev); break;
4596 case 14: sprintf(p, " %s%d", s_dam, 100 + plev*3/2); break;
4597 case 16: sprintf(p, " %s30+d25", s_dur); break;
4598 case 17: sprintf(p, " %s20+d20", s_dur); break;
4599 case 18: sprintf(p, " %s%d", s_dam, 55 + plev); break;
4600 case 19: sprintf(p, " %s%d", s_dam, 80 + plev*3/2); break;
4601 case 20: sprintf(p, " %s%d+d%d", s_dur,10+plev/2, 10+plev/2); break;
4602 case 21: sprintf(p, " %sd%d+d%d", s_dam, 2 * plev, 2 * plev); break;
4603 case 22: sprintf(p, " %s%d", s_dam, 100 + plev*2); break;
4604 case 24: sprintf(p, " %s25+d25", s_dur); break;
4605 case 25: sprintf(p, " %s20+d20", s_dur); break;
4606 case 26: sprintf(p, " %s%d+%d", s_dam, 25+plev/2, 25+plev/2); break;
4607 case 29: sprintf(p, " %s%d", s_dam, plev*15); break;
4608 case 30: sprintf(p, " %s600", s_dam); break;
4609 case 31: sprintf(p, " %s15+d15", s_dur); break;
4613 case REALM_CRUSADE: /* Crusade */
4616 case 0: sprintf(p, " %s%dd4", s_dam, 3 + ((plev - 1) / 5)); break;
4617 case 5: sprintf(p, " %s%d", s_range, 25+plev/2); break;
4619 case 6: sprintf(p, " %s³Æ%dd2", s_dam, 3+((plev-1)/9)); break;
4621 case 6: sprintf(p, " %s%dd2 each", s_dam, 3+((plev-1)/9)); break;
4623 case 9: sprintf(p, " %s3d6+%d", s_dam, orb); break;
4624 case 10: sprintf(p, " %sd%d", s_dam, plev); break;
4625 case 12: sprintf(p, " %s24+d24", s_dur); break;
4626 case 13: sprintf(p, " %sd25+%d", s_dur, 3 * plev); break;
4627 case 14: sprintf(p, " %s%d", s_dam, plev*5); break;
4629 case 15: sprintf(p, " »:d%d/²ó:100", 6 * plev); break;
4631 case 15: sprintf(p, " dam:d%d/h100", 6 * plev); break;
4633 case 18: sprintf(p, " %s18+d18", s_dur); break;
4634 case 19: sprintf(p, " %sd%d", s_dam, 4 * plev); break;
4635 case 20: sprintf(p, " %sd%d", s_dam, 4 * plev); break;
4636 case 22: sprintf(p, " %s%d", s_dam, 2 * plev+100); break;
4637 case 24: sprintf(p, " %s25+d25", s_dur); break;
4638 case 28: sprintf(p, " %s10+d10", s_dur); break;
4640 case 29: sprintf(p, " %s³Æ%d", s_dam, plev*3+25); break;
4642 case 29: sprintf(p, " %s%d each", s_dam, plev*3+25); break;
4645 case 30: sprintf(p, " ²ó100/»%d+%d", plev * 4, plev*11/2); break;
4647 case 30: sprintf(p, " h100/dm%d+%d", plev * 4, plev*11/2); break;
4652 case REALM_MUSIC: /* Music */
4655 case 2 : sprintf(p, " %s%dd4", s_dam, 4 + ((plev - 1) / 5)); break;
4656 case 4 : sprintf(p, " %s2d6", s_heal); break;
4657 case 9 : sprintf(p, " %sd%d", s_dam, plev * 3 / 2); break;
4658 case 13: sprintf(p, " %s%dd7", s_dam, 10 + (plev / 5)); break;
4659 case 20: sprintf(p, " %sd%d+d%d", s_dam, plev * 3, plev * 3); break;
4660 case 22: sprintf(p, " %s%dd10", s_dam, 15 + ((plev - 1) / 2)); break;
4661 case 27: sprintf(p, " %sd%d", s_dam, plev * 3); break;
4662 case 28: sprintf(p, " %s15d10", s_heal); break;
4663 case 30: sprintf(p, " %s%dd10", s_dam, 50 + plev); break;
4668 sprintf(p, "̤ÃΤΥ¿¥¤¥×: %d", use_realm);
4670 sprintf(p, "Unknown type: %d.", use_realm);
4677 * Print a list of spells (for browsing or casting or viewing)
4679 void print_spells(int target_spell, byte *spells, int num, int y, int x, int use_realm)
4681 int i, spell, exp_level, increment = 64;
4693 if (((use_realm <= REALM_NONE) || (use_realm > MAX_REALM)) && p_ptr->wizard)
4695 msg_print("·Ù¹ð¡ª print_spell ¤¬Îΰè¤Ê¤·¤Ë¸Æ¤Ð¤ì¤¿");
4697 msg_print("Warning! print_spells called with null realm");
4701 /* Title the list */
4703 if (use_realm == REALM_HISSATSU)
4705 strcpy(buf," Lv MP");
4707 strcpy(buf," Lv SP");
4711 strcpy(buf,"½ÏÎýÅÙ Lv MP ¼ºÎ¨ ¸ú²Ì");
4713 strcpy(buf,"Profic Lv SP Fail Effect");
4717 put_str("̾Á°", y, x + 5);
4718 put_str(buf, y, x + 29);
4720 put_str("Name", y, x + 5);
4721 put_str(buf, y, x + 29);
4724 if ((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE)) increment = 0;
4725 else if (use_realm == p_ptr->realm1) increment = 0;
4726 else if (use_realm == p_ptr->realm2) increment = 32;
4728 /* Dump the spells */
4729 for (i = 0; i < num; i++)
4731 /* Access the spell */
4734 /* Access the spell */
4735 if (!is_magic(use_realm))
4737 s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
4741 s_ptr = &mp_ptr->info[use_realm - 1][spell];
4744 if (use_realm == REALM_HISSATSU)
4745 need_mana = s_ptr->smana;
4748 s16b exp = experience_of_spell(spell, use_realm);
4750 /* Extract mana consumption rate */
4751 need_mana = mod_need_mana(s_ptr->smana, spell, use_realm);
4753 if ((increment == 64) || (s_ptr->slevel >= 99)) exp_level = EXP_LEVEL_UNSKILLED;
4754 else exp_level = spell_exp_level(exp);
4757 if (!increment && (exp_level == EXP_LEVEL_MASTER)) max = TRUE;
4758 else if ((increment == 32) && (exp_level >= EXP_LEVEL_EXPERT)) max = TRUE;
4759 else if (s_ptr->slevel >= 99) max = TRUE;
4760 else if ((p_ptr->pclass == CLASS_RED_MAGE) && (exp_level >= EXP_LEVEL_SKILLED)) max = TRUE;
4762 strncpy(ryakuji, exp_level_str[exp_level], 4);
4767 if (use_menu && target_spell)
4769 if (i == (target_spell-1))
4771 strcpy(out_val, " ¡Õ ");
4773 strcpy(out_val, " > ");
4776 strcpy(out_val, " ");
4778 else sprintf(out_val, " %c) ", I2A(i));
4779 /* Skip illegible spells */
4780 if (s_ptr->slevel >= 99)
4783 strcat(out_val, format("%-30s", "(ȽÆÉÉÔǽ)"));
4785 strcat(out_val, format("%-30s", "(illegible)"));
4788 c_prt(TERM_L_DARK, out_val, y + i + 1, x);
4792 /* XXX XXX Could label spells above the players level */
4794 /* Get extra info */
4795 spell_info(info, spell, use_realm);
4800 /* Assume spell is known and tried */
4801 line_attr = TERM_WHITE;
4803 /* Analyze the spell */
4804 if ((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE))
4806 if (s_ptr->slevel > p_ptr->max_plv)
4811 comment = " unknown";
4814 line_attr = TERM_L_BLUE;
4816 else if (s_ptr->slevel > p_ptr->lev)
4821 comment = " forgotten";
4824 line_attr = TERM_YELLOW;
4827 else if ((use_realm != p_ptr->realm1) && (use_realm != p_ptr->realm2))
4832 comment = " unknown";
4835 line_attr = TERM_L_BLUE;
4837 else if ((use_realm == p_ptr->realm1) ?
4838 ((p_ptr->spell_forgotten1 & (1L << spell))) :
4839 ((p_ptr->spell_forgotten2 & (1L << spell))))
4844 comment = " forgotten";
4847 line_attr = TERM_YELLOW;
4849 else if (!((use_realm == p_ptr->realm1) ?
4850 (p_ptr->spell_learned1 & (1L << spell)) :
4851 (p_ptr->spell_learned2 & (1L << spell))))
4856 comment = " unknown";
4859 line_attr = TERM_L_BLUE;
4861 else if (!((use_realm == p_ptr->realm1) ?
4862 (p_ptr->spell_worked1 & (1L << spell)) :
4863 (p_ptr->spell_worked2 & (1L << spell))))
4866 comment = " ̤·Ð¸³";
4868 comment = " untried";
4871 line_attr = TERM_L_GREEN;
4874 /* Dump the spell --(-- */
4875 if (use_realm == REALM_HISSATSU)
4877 strcat(out_val, format("%-25s %2d %4d",
4878 spell_names[technic2magic(use_realm)-1][spell], /* realm, spell */
4879 s_ptr->slevel, need_mana));
4883 strcat(out_val, format("%-25s%c%-4s %2d %4d %3d%%%s",
4884 spell_names[technic2magic(use_realm)-1][spell], /* realm, spell */
4885 (max ? '!' : ' '), ryakuji,
4886 s_ptr->slevel, need_mana, spell_chance(spell, use_realm), comment));
4888 c_prt(line_attr, out_val, y + i + 1, x);
4891 /* Clear the bottom line */
4892 prt("", y + i + 1, x);
4897 * Note that amulets, rods, and high-level spell books are immune
4898 * to "inventory damage" of any kind. Also sling ammo and shovels.
4903 * Does a given class of objects (usually) hate acid?
4904 * Note that acid can either melt or corrode something.
4906 bool hates_acid(object_type *o_ptr)
4908 /* Analyze the type */
4909 switch (o_ptr->tval)
4911 /* Wearable items */
4931 /* Staffs/Scrolls are wood/paper */
4944 /* Junk is useless */
4958 * Does a given object (usually) hate electricity?
4960 bool hates_elec(object_type *o_ptr)
4962 switch (o_ptr->tval)
4976 * Does a given object (usually) hate fire?
4977 * Hafted/Polearm weapons have wooden shafts.
4978 * Arrows/Bows are mostly wooden.
4980 bool hates_fire(object_type *o_ptr)
4982 /* Analyze the type */
4983 switch (o_ptr->tval)
5001 case TV_SORCERY_BOOK:
5002 case TV_NATURE_BOOK:
5006 case TV_ARCANE_BOOK:
5007 case TV_ENCHANT_BOOK:
5008 case TV_DAEMON_BOOK:
5009 case TV_CRUSADE_BOOK:
5011 case TV_HISSATSU_BOOK:
5022 /* Staffs/Scrolls burn */
5035 * Does a given object (usually) hate cold?
5037 bool hates_cold(object_type *o_ptr)
5039 switch (o_ptr->tval)
5056 int set_acid_destroy(object_type *o_ptr)
5058 u32b flgs[TR_FLAG_SIZE];
5059 if (!hates_acid(o_ptr)) return (FALSE);
5060 object_flags(o_ptr, flgs);
5061 if (have_flag(flgs, TR_IGNORE_ACID)) return (FALSE);
5069 int set_elec_destroy(object_type *o_ptr)
5071 u32b flgs[TR_FLAG_SIZE];
5072 if (!hates_elec(o_ptr)) return (FALSE);
5073 object_flags(o_ptr, flgs);
5074 if (have_flag(flgs, TR_IGNORE_ELEC)) return (FALSE);
5082 int set_fire_destroy(object_type *o_ptr)
5084 u32b flgs[TR_FLAG_SIZE];
5085 if (!hates_fire(o_ptr)) return (FALSE);
5086 object_flags(o_ptr, flgs);
5087 if (have_flag(flgs, TR_IGNORE_FIRE)) return (FALSE);
5095 int set_cold_destroy(object_type *o_ptr)
5097 u32b flgs[TR_FLAG_SIZE];
5098 if (!hates_cold(o_ptr)) return (FALSE);
5099 object_flags(o_ptr, flgs);
5100 if (have_flag(flgs, TR_IGNORE_COLD)) return (FALSE);
5106 * Destroys a type of item on a given percent chance
5107 * Note that missiles are no longer necessarily all destroyed
5108 * Destruction taken from "melee.c" code for "stealing".
5109 * New-style wands and rods handled correctly. -LM-
5110 * Returns number of items destroyed.
5112 int inven_damage(inven_func typ, int perc)
5116 char o_name[MAX_NLEN];
5118 /* Multishadow effects is determined by turn */
5119 if( p_ptr->multishadow && (turn & 1) )return 0;
5121 if (p_ptr->inside_arena) return 0;
5123 /* Count the casualties */
5126 /* Scan through the slots backwards */
5127 for (i = 0; i < INVEN_PACK; i++)
5129 o_ptr = &inventory[i];
5131 /* Skip non-objects */
5132 if (!o_ptr->k_idx) continue;
5134 /* Hack -- for now, skip artifacts */
5135 if (artifact_p(o_ptr) || o_ptr->art_name) continue;
5137 /* Give this item slot a shot at death */
5140 /* Count the casualties */
5141 for (amt = j = 0; j < o_ptr->number; ++j)
5143 if (randint0(100) < perc) amt++;
5146 /* Some casualities */
5149 /* Get a description */
5150 object_desc(o_name, o_ptr, FALSE, 3);
5154 msg_format("%s(%c)¤¬%s²õ¤ì¤Æ¤·¤Þ¤Ã¤¿¡ª",
5156 msg_format("%sour %s (%c) %s destroyed!",
5160 o_name, index_to_label(i),
5161 ((o_ptr->number > 1) ?
5162 ((amt == o_ptr->number) ? "Á´Éô" :
5163 (amt > 1 ? "²¿¸Ä¤«" : "°ì¸Ä")) : "") );
5165 ((o_ptr->number > 1) ?
5166 ((amt == o_ptr->number) ? "All of y" :
5167 (amt > 1 ? "Some of y" : "One of y")) : "Y"),
5168 o_name, index_to_label(i),
5169 ((amt > 1) ? "were" : "was"));
5173 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
5174 msg_print("¤ä¤ê¤ä¤¬¤Ã¤¿¤Ê¡ª");
5177 /* Potions smash open */
5178 if (object_is_potion(o_ptr))
5180 (void)potion_smash_effect(0, py, px, o_ptr->k_idx);
5183 /* Reduce the charges of rods/wands */
5184 reduce_charges(o_ptr, amt);
5186 /* Destroy "amt" items */
5187 inven_item_increase(i, -amt);
5188 inven_item_optimize(i);
5190 /* Count the casualties */
5196 /* Return the casualty count */
5202 * Acid has hit the player, attempt to affect some armor.
5204 * Note that the "base armor" of an object never changes.
5206 * If any armor is damaged (or resists), the player takes less damage.
5208 static int minus_ac(void)
5210 object_type *o_ptr = NULL;
5211 u32b flgs[TR_FLAG_SIZE];
5212 char o_name[MAX_NLEN];
5215 /* Pick a (possibly empty) inventory slot */
5216 switch (randint1(7))
5218 case 1: o_ptr = &inventory[INVEN_RARM]; break;
5219 case 2: o_ptr = &inventory[INVEN_LARM]; break;
5220 case 3: o_ptr = &inventory[INVEN_BODY]; break;
5221 case 4: o_ptr = &inventory[INVEN_OUTER]; break;
5222 case 5: o_ptr = &inventory[INVEN_HANDS]; break;
5223 case 6: o_ptr = &inventory[INVEN_HEAD]; break;
5224 case 7: o_ptr = &inventory[INVEN_FEET]; break;
5227 /* Nothing to damage */
5228 if (!o_ptr->k_idx) return (FALSE);
5230 if (o_ptr->tval < TV_BOOTS) return (FALSE);
5232 /* No damage left to be done */
5233 if (o_ptr->ac + o_ptr->to_a <= 0) return (FALSE);
5237 object_desc(o_name, o_ptr, FALSE, 0);
5239 /* Extract the flags */
5240 object_flags(o_ptr, flgs);
5242 /* Object resists */
5243 if (have_flag(flgs, TR_IGNORE_ACID))
5246 msg_format("¤·¤«¤·%s¤Ë¤Ï¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡ª", o_name);
5248 msg_format("Your %s is unaffected!", o_name);
5257 msg_format("%s¤¬¥À¥á¡¼¥¸¤ò¼õ¤±¤¿¡ª", o_name);
5259 msg_format("Your %s is damaged!", o_name);
5263 /* Damage the item */
5266 /* Calculate bonuses */
5267 p_ptr->update |= (PU_BONUS);
5270 p_ptr->window |= (PW_EQUIP | PW_PLAYER);
5274 /* Item was damaged */
5280 * Hurt the player with Acid
5282 int acid_dam(int dam, cptr kb_str, int monspell)
5285 int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
5286 bool double_resist = IS_OPPOSE_ACID();
5288 /* Total Immunity */
5289 if (p_ptr->immune_acid || (dam <= 0))
5291 learn_spell(monspell);
5295 /* Vulnerability (Ouch!) */
5296 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
5297 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
5299 /* Resist the damage */
5300 if (p_ptr->resist_acid) dam = (dam + 2) / 3;
5301 if (double_resist) dam = (dam + 2) / 3;
5303 if ((!(double_resist || p_ptr->resist_acid)) &&
5304 one_in_(HURT_CHANCE))
5305 (void)do_dec_stat(A_CHR);
5307 /* If any armor gets hit, defend the player */
5308 if (minus_ac()) dam = (dam + 1) / 2;
5311 get_damage=take_hit(DAMAGE_ATTACK, dam, kb_str, monspell);
5313 /* Inventory damage */
5314 if (!(double_resist && p_ptr->resist_acid))
5315 inven_damage(set_acid_destroy, inv);
5321 * Hurt the player with electricity
5323 int elec_dam(int dam, cptr kb_str, int monspell)
5326 int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
5327 bool double_resist = IS_OPPOSE_ELEC();
5329 /* Total immunity */
5330 if (p_ptr->immune_elec || (dam <= 0))
5332 learn_spell(monspell);
5336 /* Vulnerability (Ouch!) */
5337 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
5338 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
5339 if (prace_is_(RACE_ANDROID)) dam += dam / 3;
5341 /* Resist the damage */
5342 if (p_ptr->resist_elec) dam = (dam + 2) / 3;
5343 if (double_resist) dam = (dam + 2) / 3;
5345 if ((!(double_resist || p_ptr->resist_elec)) &&
5346 one_in_(HURT_CHANCE))
5347 (void)do_dec_stat(A_DEX);
5350 get_damage=take_hit(DAMAGE_ATTACK, dam, kb_str, monspell);
5352 /* Inventory damage */
5353 if (!(double_resist && p_ptr->resist_elec))
5354 inven_damage(set_elec_destroy, inv);
5361 * Hurt the player with Fire
5363 int fire_dam(int dam, cptr kb_str, int monspell)
5366 int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
5367 bool double_resist = IS_OPPOSE_FIRE();
5369 /* Totally immune */
5370 if (p_ptr->immune_fire || (dam <= 0))
5372 learn_spell(monspell);
5376 /* Vulnerability (Ouch!) */
5377 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
5378 if (prace_is_(RACE_ENT)) dam += dam / 3;
5379 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
5381 /* Resist the damage */
5382 if (p_ptr->resist_fire) dam = (dam + 2) / 3;
5383 if (double_resist) dam = (dam + 2) / 3;
5385 if ((!(double_resist || p_ptr->resist_fire)) &&
5386 one_in_(HURT_CHANCE))
5387 (void)do_dec_stat(A_STR);
5390 get_damage=take_hit(DAMAGE_ATTACK, dam, kb_str, monspell);
5392 /* Inventory damage */
5393 if (!(double_resist && p_ptr->resist_fire))
5394 inven_damage(set_fire_destroy, inv);
5401 * Hurt the player with Cold
5403 int cold_dam(int dam, cptr kb_str, int monspell)
5406 int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
5407 bool double_resist = IS_OPPOSE_COLD();
5409 /* Total immunity */
5410 if (p_ptr->immune_cold || (dam <= 0))
5412 learn_spell(monspell);
5416 /* Vulnerability (Ouch!) */
5417 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
5418 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
5420 /* Resist the damage */
5421 if (p_ptr->resist_cold) dam = (dam + 2) / 3;
5422 if (double_resist) dam = (dam + 2) / 3;
5424 if ((!(double_resist || p_ptr->resist_cold)) &&
5425 one_in_(HURT_CHANCE))
5426 (void)do_dec_stat(A_STR);
5429 get_damage=take_hit(DAMAGE_ATTACK, dam, kb_str, monspell);
5431 /* Inventory damage */
5432 if (!(double_resist && p_ptr->resist_cold))
5433 inven_damage(set_cold_destroy, inv);
5439 bool rustproof(void)
5443 char o_name[MAX_NLEN];
5446 item_tester_no_ryoute = TRUE;
5447 /* Select a piece of armour */
5448 item_tester_hook = item_tester_hook_armour;
5452 q = "¤É¤ÎËɶñ¤Ë»¬»ß¤á¤ò¤·¤Þ¤¹¤«¡©";
5453 s = "»¬»ß¤á¤Ç¤¤ë¤â¤Î¤¬¤¢¤ê¤Þ¤»¤ó¡£";
5455 q = "Rustproof which piece of armour? ";
5456 s = "You have nothing to rustproof.";
5459 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return FALSE;
5461 /* Get the item (in the pack) */
5464 o_ptr = &inventory[item];
5467 /* Get the item (on the floor) */
5470 o_ptr = &o_list[0 - item];
5475 object_desc(o_name, o_ptr, FALSE, 0);
5477 add_flag(o_ptr->art_flags, TR_IGNORE_ACID);
5479 if ((o_ptr->to_a < 0) && !cursed_p(o_ptr))
5482 msg_format("%s¤Ï¿·ÉÊƱÍͤˤʤä¿¡ª",o_name);
5484 msg_format("%s %s look%s as good as new!",
5485 ((item >= 0) ? "Your" : "The"), o_name,
5486 ((o_ptr->number > 1) ? "" : "s"));
5493 msg_format("%s¤ÏÉå¿©¤·¤Ê¤¯¤Ê¤Ã¤¿¡£", o_name);
5495 msg_format("%s %s %s now protected against corrosion.",
5496 ((item >= 0) ? "Your" : "The"), o_name,
5497 ((o_ptr->number > 1) ? "are" : "is"));
5508 * Curse the players armor
5510 bool curse_armor(void)
5515 char o_name[MAX_NLEN];
5518 /* Curse the body armor */
5519 o_ptr = &inventory[INVEN_BODY];
5521 /* Nothing to curse */
5522 if (!o_ptr->k_idx) return (FALSE);
5526 object_desc(o_name, o_ptr, FALSE, 3);
5528 /* Attempt a saving throw for artifacts */
5529 if ((o_ptr->art_name || artifact_p(o_ptr)) && (randint0(100) < 50))
5533 msg_format("%s¤¬%s¤òÊñ¤ß¹þ¤â¤¦¤È¤·¤¿¤¬¡¢%s¤Ï¤½¤ì¤òÄ·¤ÍÊÖ¤·¤¿¡ª",
5534 "¶²ÉݤΰŹõ¥ª¡¼¥é", "Ëɶñ", o_name);
5536 msg_format("A %s tries to %s, but your %s resists the effects!",
5537 "terrible black aura", "surround your armor", o_name);
5542 /* not artifact or failed save... */
5547 msg_format("¶²ÉݤΰŹõ¥ª¡¼¥é¤¬¤¢¤Ê¤¿¤Î%s¤òÊñ¤ß¹þ¤ó¤À¡ª", o_name);
5549 msg_format("A terrible black aura blasts your %s!", o_name);
5552 chg_virtue(V_ENCHANT, -5);
5554 /* Blast the armor */
5556 o_ptr->name2 = EGO_BLASTED;
5557 o_ptr->to_a = 0 - randint1(5) - randint1(5);
5564 for (i = 0; i < TR_FLAG_SIZE; i++)
5565 o_ptr->art_flags[i] = 0;
5568 o_ptr->curse_flags = TRC_CURSED;
5571 o_ptr->ident |= (IDENT_BROKEN);
5573 /* Recalculate bonuses */
5574 p_ptr->update |= (PU_BONUS);
5576 /* Recalculate mana */
5577 p_ptr->update |= (PU_MANA);
5580 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
5588 * Curse the players weapon
5590 bool curse_weapon(bool force, int slot)
5596 char o_name[MAX_NLEN];
5599 /* Curse the weapon */
5600 o_ptr = &inventory[slot];
5602 /* Nothing to curse */
5603 if (!o_ptr->k_idx) return (FALSE);
5607 object_desc(o_name, o_ptr, FALSE, 3);
5609 /* Attempt a saving throw */
5610 if ((artifact_p(o_ptr) || o_ptr->art_name) && (randint0(100) < 50) && !force)
5614 msg_format("%s¤¬%s¤òÊñ¤ß¹þ¤â¤¦¤È¤·¤¿¤¬¡¢%s¤Ï¤½¤ì¤òÄ·¤ÍÊÖ¤·¤¿¡ª",
5615 "¶²ÉݤΰŹõ¥ª¡¼¥é", "Éð´ï", o_name);
5617 msg_format("A %s tries to %s, but your %s resists the effects!",
5618 "terrible black aura", "surround your weapon", o_name);
5623 /* not artifact or failed save... */
5628 if (!force) msg_format("¶²ÉݤΰŹõ¥ª¡¼¥é¤¬¤¢¤Ê¤¿¤Î%s¤òÊñ¤ß¹þ¤ó¤À¡ª", o_name);
5630 if (!force) msg_format("A terrible black aura blasts your %s!", o_name);
5633 chg_virtue(V_ENCHANT, -5);
5635 /* Shatter the weapon */
5637 o_ptr->name2 = EGO_SHATTERED;
5638 o_ptr->to_h = 0 - randint1(5) - randint1(5);
5639 o_ptr->to_d = 0 - randint1(5) - randint1(5);
5645 for (i = 0; i < TR_FLAG_SIZE; i++)
5646 o_ptr->art_flags[i] = 0;
5650 o_ptr->curse_flags = TRC_CURSED;
5653 o_ptr->ident |= (IDENT_BROKEN);
5655 /* Recalculate bonuses */
5656 p_ptr->update |= (PU_BONUS);
5658 /* Recalculate mana */
5659 p_ptr->update |= (PU_MANA);
5662 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
5671 * Enchant some bolts
5673 bool brand_bolts(void)
5677 /* Use the first acceptable bolts */
5678 for (i = 0; i < INVEN_PACK; i++)
5680 object_type *o_ptr = &inventory[i];
5682 /* Skip non-bolts */
5683 if (o_ptr->tval != TV_BOLT) continue;
5685 /* Skip artifacts and ego-items */
5686 if (o_ptr->art_name || artifact_p(o_ptr) || ego_item_p(o_ptr))
5689 /* Skip cursed/broken items */
5690 if (cursed_p(o_ptr) || broken_p(o_ptr)) continue;
5693 if (randint0(100) < 75) continue;
5697 msg_print("¥¯¥í¥¹¥Ü¥¦¤ÎÌ𤬱ê¤Î¥ª¡¼¥é¤ËÊñ¤Þ¤ì¤¿¡ª");
5699 msg_print("Your bolts are covered in a fiery aura!");
5704 o_ptr->name2 = EGO_FLAME;
5707 enchant(o_ptr, randint0(3) + 4, ENCH_TOHIT | ENCH_TODAM);
5714 if (flush_failure) flush();
5718 msg_print("±ê¤Ç¶¯²½¤¹¤ë¤Î¤Ë¼ºÇÔ¤·¤¿¡£");
5720 msg_print("The fiery enchantment failed.");
5730 * Helper function -- return a "nearby" race for polymorphing
5732 * Note that this function is one of the more "dangerous" ones...
5734 static s16b poly_r_idx(int r_idx)
5736 monster_race *r_ptr = &r_info[r_idx];
5738 int i, r, lev1, lev2;
5740 /* Hack -- Uniques/Questors never polymorph */
5741 if ((r_ptr->flags1 & RF1_UNIQUE) ||
5742 (r_ptr->flags1 & RF1_QUESTOR))
5745 /* Allowable range of "levels" for resulting monster */
5746 lev1 = r_ptr->level - ((randint1(20) / randint1(9)) + 1);
5747 lev2 = r_ptr->level + ((randint1(20) / randint1(9)) + 1);
5749 /* Pick a (possibly new) non-unique race */
5750 for (i = 0; i < 1000; i++)
5752 /* Pick a new race, using a level calculation */
5753 r = get_mon_num((dun_level + r_ptr->level) / 2 + 5);
5755 /* Handle failure */
5761 /* Ignore unique monsters */
5762 if (r_ptr->flags1 & RF1_UNIQUE) continue;
5764 /* Ignore monsters with incompatible levels */
5765 if ((r_ptr->level < lev1) || (r_ptr->level > lev2)) continue;
5767 /* Use that index */
5779 bool polymorph_monster(int y, int x)
5781 cave_type *c_ptr = &cave[y][x];
5782 monster_type *m_ptr = &m_list[c_ptr->m_idx];
5783 bool polymorphed = FALSE;
5785 int old_r_idx = m_ptr->r_idx;
5786 bool targeted = (target_who == c_ptr->m_idx) ? TRUE : FALSE;
5787 bool health_tracked = (p_ptr->health_who == c_ptr->m_idx) ? TRUE : FALSE;
5788 monster_type back_m;
5790 if (p_ptr->inside_arena || p_ptr->inside_battle) return (FALSE);
5792 if ((p_ptr->riding == c_ptr->m_idx) || (m_ptr->mflag2 & MFLAG2_KAGE)) return (FALSE);
5794 /* Memorize the monster before polymorphing */
5797 /* Pick a "new" monster race */
5798 new_r_idx = poly_r_idx(old_r_idx);
5800 /* Handle polymorph */
5801 if (new_r_idx != old_r_idx)
5805 /* Get the monsters attitude */
5806 if (is_friendly(m_ptr)) mode |= PM_FORCE_FRIENDLY;
5807 if (is_pet(m_ptr)) mode |= PM_FORCE_PET;
5808 if (m_ptr->mflag2 & MFLAG2_NOPET) mode |= PM_NO_PET;
5810 /* "Kill" the "old" monster */
5811 delete_monster_idx(c_ptr->m_idx);
5813 /* Create a new monster (no groups) */
5814 if (place_monster_aux(0, y, x, new_r_idx, mode))
5821 /* Placing the new monster failed */
5822 if (place_monster_aux(0, y, x, old_r_idx, (mode | PM_NO_KAGE | PM_IGNORE_TERRAIN)))
5823 m_list[hack_m_idx_ii] = back_m;
5826 if (targeted) target_who = hack_m_idx_ii;
5827 if (health_tracked) health_track(hack_m_idx_ii);
5837 bool dimension_door(void)
5839 int plev = p_ptr->lev;
5842 if (!tgt_pt(&x, &y)) return FALSE;
5844 p_ptr->energy_need += (s16b)((s32b)(60 - plev) * ENERGY_NEED() / 100L);
5846 if (!cave_empty_bold(y, x) || (cave[y][x].info & CAVE_ICKY) ||
5847 (distance(y, x, py, px) > plev / 2 + 10) ||
5848 (!randint0(plev / 10 + 10)))
5850 if( p_ptr->pclass != CLASS_MIRROR_MASTER ){
5852 msg_print("ÀºÎ¤«¤éʪ¼Á³¦¤ËÌá¤ë»þ¤¦¤Þ¤¯¤¤¤«¤Ê¤«¤Ã¤¿¡ª");
5854 msg_print("You fail to exit the astral plane correctly!");
5860 msg_print("¶À¤ÎÀ¤³¦¤ò¤¦¤Þ¤¯Ä̤ì¤Ê¤«¤Ã¤¿¡ª");
5862 msg_print("You fail to exit the astral plane correctly!");
5865 p_ptr->energy_need += (s16b)((s32b)(60 - plev) * ENERGY_NEED() / 100L);
5866 teleport_player((plev+2)*2);
5869 teleport_player_to(y, x, TRUE);
5875 bool eat_magic(int power)
5877 object_type * o_ptr;
5880 int recharge_strength = 0;
5886 char o_name[MAX_NLEN];
5888 item_tester_hook = item_tester_hook_recharge;
5892 q = "¤É¤Î¥¢¥¤¥Æ¥à¤«¤éËâÎϤòµÛ¼ý¤·¤Þ¤¹¤«¡©";
5893 s = "ËâÎϤòµÛ¼ý¤Ç¤¤ë¥¢¥¤¥Æ¥à¤¬¤¢¤ê¤Þ¤»¤ó¡£";
5895 q = "Drain which item? ";
5896 s = "You have nothing to drain.";
5899 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return FALSE;
5903 o_ptr = &inventory[item];
5907 o_ptr = &o_list[0 - item];
5910 k_ptr = &k_info[o_ptr->k_idx];
5911 lev = get_object_level(o_ptr);
5913 if (o_ptr->tval == TV_ROD)
5915 recharge_strength = ((power > lev/2) ? (power - lev/2) : 0) / 5;
5918 if (one_in_(recharge_strength))
5920 /* Activate the failure code. */
5925 if (o_ptr->timeout > (o_ptr->number - 1) * k_ptr->pval)
5928 msg_print("½¼Å¶Ãæ¤Î¥í¥Ã¥É¤«¤éËâÎϤòµÛ¼ý¤¹¤ë¤³¤È¤Ï¤Ç¤¤Þ¤»¤ó¡£");
5930 msg_print("You can't absorb energy from a discharged rod.");
5937 o_ptr->timeout += k_ptr->pval;
5943 /* All staffs, wands. */
5944 recharge_strength = (100 + power - lev) / 15;
5947 if (recharge_strength < 0) recharge_strength = 0;
5950 if (one_in_(recharge_strength))
5952 /* Activate the failure code. */
5957 if (o_ptr->pval > 0)
5959 p_ptr->csp += lev / 2;
5962 /* XXX Hack -- unstack if necessary */
5963 if ((o_ptr->tval == TV_STAFF) && (item >= 0) && (o_ptr->number > 1))
5968 /* Get local object */
5971 /* Obtain a local object */
5972 object_copy(q_ptr, o_ptr);
5974 /* Modify quantity */
5977 /* Restore the charges */
5980 /* Unstack the used item */
5982 p_ptr->total_weight -= q_ptr->weight;
5983 item = inven_carry(q_ptr);
5987 msg_print("¾ó¤ò¤Þ¤È¤á¤Ê¤ª¤·¤¿¡£");
5989 msg_print("You unstack your staff.");
5997 msg_print("µÛ¼ý¤Ç¤¤ëËâÎϤ¬¤¢¤ê¤Þ¤»¤ó¡ª");
5999 msg_print("There's no energy there to absorb!");
6003 if (!o_ptr->pval) o_ptr->ident |= IDENT_EMPTY;
6007 /* Inflict the penalties for failing a recharge. */
6010 /* Artifacts are never destroyed. */
6011 if (artifact_p(o_ptr))
6013 object_desc(o_name, o_ptr, TRUE, 0);
6015 msg_format("ËâÎϤ¬µÕή¤·¤¿¡ª%s¤Ï´°Á´¤ËËâÎϤò¼º¤Ã¤¿¡£", o_name);
6017 msg_format("The recharging backfires - %s is completely drained!", o_name);
6021 /* Artifact rods. */
6022 if (o_ptr->tval == TV_ROD)
6023 o_ptr->timeout = k_ptr->pval * o_ptr->number;
6025 /* Artifact wands and staffs. */
6026 else if ((o_ptr->tval == TV_WAND) || (o_ptr->tval == TV_STAFF))
6031 /* Get the object description */
6032 object_desc(o_name, o_ptr, FALSE, 0);
6034 /*** Determine Seriousness of Failure ***/
6036 /* Mages recharge objects more safely. */
6037 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)
6039 /* 10% chance to blow up one rod, otherwise draining. */
6040 if (o_ptr->tval == TV_ROD)
6042 if (one_in_(10)) fail_type = 2;
6045 /* 75% chance to blow up one wand, otherwise draining. */
6046 else if (o_ptr->tval == TV_WAND)
6048 if (!one_in_(3)) fail_type = 2;
6051 /* 50% chance to blow up one staff, otherwise no effect. */
6052 else if (o_ptr->tval == TV_STAFF)
6054 if (one_in_(2)) fail_type = 2;
6059 /* All other classes get no special favors. */
6062 /* 33% chance to blow up one rod, otherwise draining. */
6063 if (o_ptr->tval == TV_ROD)
6065 if (one_in_(3)) fail_type = 2;
6068 /* 20% chance of the entire stack, else destroy one wand. */
6069 else if (o_ptr->tval == TV_WAND)
6071 if (one_in_(5)) fail_type = 3;
6074 /* Blow up one staff. */
6075 else if (o_ptr->tval == TV_STAFF)
6081 /*** Apply draining and destruction. ***/
6083 /* Drain object or stack of objects. */
6086 if (o_ptr->tval == TV_ROD)
6089 msg_print("¥í¥Ã¥É¤ÏÇË»¤òÌȤ줿¤¬¡¢ËâÎϤÏÁ´¤Æ¼º¤Ê¤ï¤ì¤¿¡£");
6091 msg_format("You save your rod from destruction, but all charges are lost.", o_name);
6094 o_ptr->timeout = k_ptr->pval * o_ptr->number;
6096 else if (o_ptr->tval == TV_WAND)
6099 msg_format("%s¤ÏÇË»¤òÌȤ줿¤¬¡¢ËâÎϤ¬Á´¤Æ¼º¤ï¤ì¤¿¡£", o_name);
6101 msg_format("You save your %s from destruction, but all charges are lost.", o_name);
6106 /* Staffs aren't drained. */
6109 /* Destroy an object or one in a stack of objects. */
6112 if (o_ptr->number > 1)
6115 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬°ìËܲõ¤ì¤¿¡ª", o_name);
6117 msg_format("Wild magic consumes one of your %s!", o_name);
6120 /* Reduce rod stack maximum timeout, drain wands. */
6121 if (o_ptr->tval == TV_ROD) o_ptr->timeout = MIN(o_ptr->timeout, k_ptr->pval * (o_ptr->number - 1));
6122 else if (o_ptr->tval == TV_WAND) o_ptr->pval = o_ptr->pval * (o_ptr->number - 1) / o_ptr->number;
6127 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬²¿Ëܤ«²õ¤ì¤¿¡ª", o_name);
6129 msg_format("Wild magic consumes your %s!", o_name);
6132 /* Reduce and describe inventory */
6135 inven_item_increase(item, -1);
6136 inven_item_describe(item);
6137 inven_item_optimize(item);
6140 /* Reduce and describe floor item */
6143 floor_item_increase(0 - item, -1);
6144 floor_item_describe(0 - item);
6145 floor_item_optimize(0 - item);
6149 /* Destroy all members of a stack of objects. */
6152 if (o_ptr->number > 1)
6154 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬Á´¤Æ²õ¤ì¤¿¡ª", o_name);
6156 msg_format("Wild magic consumes all your %s!", o_name);
6161 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬²õ¤ì¤¿¡ª", o_name);
6163 msg_format("Wild magic consumes your %s!", o_name);
6168 /* Reduce and describe inventory */
6171 inven_item_increase(item, -999);
6172 inven_item_describe(item);
6173 inven_item_optimize(item);
6176 /* Reduce and describe floor item */
6179 floor_item_increase(0 - item, -999);
6180 floor_item_describe(0 - item);
6181 floor_item_optimize(0 - item);
6187 if (p_ptr->csp > p_ptr->msp)
6189 p_ptr->csp = p_ptr->msp;
6192 /* Redraw mana and hp */
6193 p_ptr->redraw |= (PR_MANA);
6195 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
6196 p_ptr->window |= (PW_INVEN);
6202 bool summon_kin_player(int level, int y, int x, u32b mode)
6204 bool pet = (bool)(mode & PM_FORCE_PET);
6205 if (!pet) mode |= PM_NO_PET;
6207 switch (p_ptr->mimic_form)
6210 switch (p_ptr->prace)
6214 case RACE_BARBARIAN:
6217 summon_kin_type = 'p';
6227 case RACE_MIND_FLAYER:
6230 summon_kin_type = 'h';
6233 summon_kin_type = 'o';
6235 case RACE_HALF_TROLL:
6236 summon_kin_type = 'T';
6238 case RACE_HALF_OGRE:
6239 summon_kin_type = 'O';
6241 case RACE_HALF_GIANT:
6242 case RACE_HALF_TITAN:
6244 summon_kin_type = 'P';
6247 summon_kin_type = 'y';
6250 summon_kin_type = 'K';
6253 summon_kin_type = 'k';
6256 if (one_in_(13)) summon_kin_type = 'U';
6257 else summon_kin_type = 'u';
6259 case RACE_DRACONIAN:
6260 summon_kin_type = 'd';
6264 summon_kin_type = 'g';
6267 if (one_in_(13)) summon_kin_type = 'L';
6268 else summon_kin_type = 's';
6271 summon_kin_type = 'z';
6274 summon_kin_type = 'V';
6277 summon_kin_type = 'G';
6280 summon_kin_type = 'I';
6283 summon_kin_type = '#';
6286 summon_kin_type = 'A';
6289 summon_kin_type = 'U';
6292 summon_kin_type = 'p';
6297 if (one_in_(13)) summon_kin_type = 'U';
6298 else summon_kin_type = 'u';
6300 case MIMIC_DEMON_LORD:
6301 summon_kin_type = 'U';
6304 summon_kin_type = 'V';
6307 return summon_specific((pet ? -1 : 0), y, x, level, SUMMON_KIN, mode);