3 /* Purpose: Spell code (part 3) */
6 * Copyright (c) 1989 James E. Wilson, Robert A. Koeneke
8 * This software may be copied and distributed for educational, research, and
9 * not for profit purposes provided that this copyright and statement are
10 * included in all such copies.
15 /* 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 the player
145 void teleport_to_player(int m_idx, 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++)
180 /* Pick a (possibly illegal) location */
183 ny = rand_spread(py, dis);
184 nx = rand_spread(px, dis);
185 d = distance(py, px, ny, nx);
186 if ((d >= min) && (d <= dis)) break;
189 /* Ignore illegal locations */
190 if (!in_bounds(ny, nx)) continue;
192 /* Require "empty" floor space */
193 if (!cave_empty_bold(ny, nx)) continue;
195 /* Hack -- no teleport onto glyph of warding */
196 if (is_glyph_grid(&cave[ny][nx])) continue;
197 if (is_explosive_rune_grid(&cave[ny][nx])) continue;
199 /* ...nor onto the Pattern */
200 if ((cave[ny][nx].feat >= FEAT_PATTERN_START) &&
201 (cave[ny][nx].feat <= FEAT_PATTERN_XTRA2)) continue;
203 /* No teleporting into vaults and such */
204 /* if (cave[ny][nx].info & (CAVE_ICKY)) continue; */
206 /* This grid looks good */
213 /* Increase the maximum distance */
216 /* Decrease the minimum distance */
220 if (attempts < 1) return;
223 sound(SOUND_TPOTHER);
225 /* Update the new location */
226 cave[ny][nx].m_idx = m_idx;
228 /* Update the old location */
229 cave[oy][ox].m_idx = 0;
231 /* Move the monster */
235 /* Update the monster (new location) */
236 update_mon(m_idx, TRUE);
238 /* Redraw the old grid */
241 /* Redraw the new grid */
244 p_ptr->update |= (PU_MON_LITE);
249 * Teleport the player to a location up to "dis" grids away.
251 * If no such spaces are readily available, the distance may increase.
252 * Try very hard to move the player at least a quarter that distance.
254 * When long-range teleport effects are considered, there is a nasty
255 * tendency to "bounce" the player between two or three different spots
256 * because these are the only spots that are "far enough" way to satisfy
257 * the algorithm. Therefore, if the teleport distance is more than 50,
258 * we decrease the minimum acceptable distance to try to increase randomness.
261 void teleport_player(int dis)
263 int d, i, min, ox, oy;
266 int xx = -1, yy = -1;
274 if (p_ptr->wild_mode) return;
276 if (p_ptr->anti_tele)
279 msg_print("ÉԻ׵ĤÊÎϤ¬¥Æ¥ì¥Ý¡¼¥È¤òËɤ¤¤À¡ª");
281 msg_print("A mysterious force prevents you from teleporting!");
287 if (dis > 200) dis = 200; /* To be on the safe side... */
289 /* Minimum distance */
290 min = dis / (dis > 50 ? 3 : 2);
292 /* Look until done */
297 /* Verify max distance */
298 if (dis > 200) dis = 200;
300 /* Try several locations */
301 for (i = 0; i < 500; i++)
303 /* Pick a (possibly illegal) location */
306 y = rand_spread(py, dis);
307 x = rand_spread(px, dis);
308 d = distance(py, px, y, x);
309 if ((d >= min) && (d <= dis)) break;
312 /* Ignore illegal locations */
313 if (!in_bounds(y, x)) continue;
315 /* Require "naked" floor space or trees */
316 if (!(cave_naked_bold(y, x) ||
317 (cave[y][x].feat == FEAT_TREES))) continue;
319 /* No teleporting into vaults and such */
320 if (cave[y][x].info & CAVE_ICKY) continue;
322 /* This grid looks good */
329 /* Increase the maximum distance */
332 /* Decrease the minimum distance */
335 /* Stop after MAX_TRIES tries */
336 if (tries > MAX_TRIES) return;
340 sound(SOUND_TELEPORT);
343 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
344 msg_format("¡Ø¤³¤Ã¤Á¤À¤¡¡¢%s¡Ù", player_name);
347 /* Save the old location */
351 /* Move the player */
358 tmp = cave[py][px].m_idx;
359 cave[py][px].m_idx = cave[oy][ox].m_idx;
360 cave[oy][ox].m_idx = tmp;
361 m_list[p_ptr->riding].fy = py;
362 m_list[p_ptr->riding].fx = px;
363 update_mon(cave[py][px].m_idx, TRUE);
366 /* Redraw the old spot */
369 /* Monsters with teleport ability may follow the player */
376 if (xx == 0 && yy == 0)
382 if (cave[oy+yy][ox+xx].m_idx)
384 if ((r_info[m_list[cave[oy+yy][ox+xx].m_idx].r_idx].flags6 & RF6_TPORT) &&
385 !(r_info[m_list[cave[oy+yy][ox+xx].m_idx].r_idx].flags3 & RF3_RES_TELE))
387 * The latter limitation is to avoid
388 * totally unkillable suckers...
391 if (!(m_list[cave[oy+yy][ox+xx].m_idx].csleep))
392 teleport_to_player(cave[oy+yy][ox+xx].m_idx, r_info[m_list[cave[oy+yy][ox+xx].m_idx].r_idx].level);
403 /* Redraw the new spot */
406 /* Check for new panel (redraw map) */
410 p_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MON_LITE);
412 /* Update the monsters */
413 p_ptr->update |= (PU_DISTANCE);
416 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
418 /* Handle stuff XXX XXX XXX */
425 * Teleport player to a grid near the given location
427 * This function is slightly obsessive about correctness.
428 * This function allows teleporting into vaults (!)
430 void teleport_player_to(int ny, int nx, bool no_tele)
432 int y, x, oy, ox, dis = 0, ctr = 0;
434 if (p_ptr->anti_tele && no_tele)
437 msg_print("ÉԻ׵ĤÊÎϤ¬¥Æ¥ì¥Ý¡¼¥È¤òËɤ¤¤À¡ª");
439 msg_print("A mysterious force prevents you from teleporting!");
445 /* Find a usable location */
448 /* Pick a nearby legal location */
451 y = rand_spread(ny, dis);
452 x = rand_spread(nx, dis);
453 if (in_bounds(y, x)) break;
456 /* Accept "naked" floor grids */
459 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;
461 else if (cave_empty_bold(y, x) || ((y == py) && (x == px))) break;
463 /* Occasionally advance the distance */
464 if (++ctr > (4 * dis * dis + 4 * dis + 1))
472 sound(SOUND_TELEPORT);
474 /* Save the old location */
478 /* Move the player */
485 tmp = cave[py][px].m_idx;
486 cave[py][px].m_idx = cave[oy][ox].m_idx;
487 cave[oy][ox].m_idx = tmp;
488 m_list[p_ptr->riding].fy = py;
489 m_list[p_ptr->riding].fx = px;
490 update_mon(cave[py][px].m_idx, TRUE);
495 /* Redraw the old spot */
498 /* Redraw the new spot */
501 /* Check for new panel (redraw map) */
505 p_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MON_LITE);
507 /* Update the monsters */
508 p_ptr->update |= (PU_DISTANCE);
511 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
513 /* Handle stuff XXX XXX XXX */
520 * Teleport the player one level up or down (random when legal)
522 void teleport_player_level(void)
524 /* No effect in arena or quest */
525 if (p_ptr->inside_arena || (p_ptr->inside_quest && !random_quest_number(dun_level)) ||
526 (quest_number(dun_level) && (dun_level > 1) && ironman_downward))
529 msg_print("¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡£");
531 msg_print("There is no effect.");
537 if (p_ptr->anti_tele)
540 msg_print("ÉԻ׵ĤÊÎϤ¬¥Æ¥ì¥Ý¡¼¥È¤òËɤ¤¤À¡ª");
542 msg_print("A mysterious force prevents you from teleporting!");
548 if (ironman_downward || (dun_level <= d_info[dungeon_type].mindepth))
551 msg_print("¤¢¤Ê¤¿¤Ï¾²¤òÆͤÇˤäÆÄÀ¤ó¤Ç¤¤¤¯¡£");
553 msg_print("You sink through the floor.");
557 dungeon_type = p_ptr->recall_dungeon;
562 if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, 1, NULL);
564 if (autosave_l) do_cmd_save_game(TRUE);
568 dun_level = d_info[dungeon_type].mindepth;
576 p_ptr->leaving = TRUE;
578 else if (quest_number(dun_level) || (dun_level >= d_info[dungeon_type].maxdepth))
581 msg_print("¤¢¤Ê¤¿¤ÏÅ·°æ¤òÆͤÇˤäÆÃè¤ØÉ⤤¤Æ¤¤¤¯¡£");
583 msg_print("You rise up through the ceiling.");
587 if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, -1, NULL);
589 if (autosave_l) do_cmd_save_game(TRUE);
593 if (!dun_level) dungeon_type = 0;
598 p_ptr->inside_quest = 0;
599 p_ptr->leaving = TRUE;
601 else if (randint0(100) < 50)
604 msg_print("¤¢¤Ê¤¿¤ÏÅ·°æ¤òÆͤÇˤäÆÃè¤ØÉ⤤¤Æ¤¤¤¯¡£");
606 msg_print("You rise up through the ceiling.");
610 if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, -1, NULL);
612 if (autosave_l) do_cmd_save_game(TRUE);
616 if (!dun_level) dungeon_type = 0;
619 p_ptr->leaving = TRUE;
624 msg_print("¤¢¤Ê¤¿¤Ï¾²¤òÆͤÇˤäÆÄÀ¤ó¤Ç¤¤¤¯¡£");
626 msg_print("You sink through the floor.");
629 if (!dun_level) dungeon_type = p_ptr->recall_dungeon;
631 if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, 1, NULL);
633 if (autosave_l) do_cmd_save_game(TRUE);
638 p_ptr->leaving = TRUE;
641 if (!dun_level && dungeon_type)
643 p_ptr->leaving_dungeon = TRUE;
644 p_ptr->wilderness_y = d_info[dungeon_type].dy;
645 p_ptr->wilderness_x = d_info[dungeon_type].dx;
646 p_ptr->recall_dungeon = dungeon_type;
649 if (!dun_level) dungeon_type = 0;
652 sound(SOUND_TPLEVEL);
657 static int choose_dungeon(cptr note)
663 /* Allocate the "dun" array */
664 C_MAKE(dun, max_d_idx, s16b);
667 for(i = 1; i < max_d_idx; i++)
672 if (!d_info[i].maxdepth) continue;
673 if (!max_dlv[i]) continue;
674 if (d_info[i].final_guardian)
676 if (!r_info[d_info[i].final_guardian].max_num) seiha = TRUE;
678 else if (max_dlv[i] == d_info[i].maxdepth) seiha = TRUE;
681 sprintf(buf," %c) %c%-12s : ºÇÂç %d ³¬", 'a'+num, seiha ? '!' : ' ', d_name + d_info[i].name, max_dlv[i]);
683 sprintf(buf," %c) %c%-16s : Max level %d", 'a'+num, seiha ? '!' : ' ', d_name + d_info[i].name, max_dlv[i]);
689 prt(format("¤É¤Î¥À¥ó¥¸¥ç¥ó%s¤·¤Þ¤¹¤«:", note), 0, 0);
691 prt(format("Which dungeon do you %s?: ", note), 0, 0);
698 /* Free the "dun" array */
699 C_KILL(dun, max_d_idx, s16b);
704 if (i >= 'a' && i <('a'+num))
706 select_dungeon = dun[i-'a'];
713 /* Free the "dun" array */
714 C_KILL(dun, max_d_idx, s16b);
716 return select_dungeon;
721 * Recall the player to town or dungeon
723 bool recall_player(int turns)
726 * TODO: Recall the player to the last
727 * visited town when in the wilderness
731 if (p_ptr->inside_arena || ironman_downward)
734 msg_print("²¿¤âµ¯¤³¤é¤Ê¤«¤Ã¤¿¡£");
736 msg_print("Nothing happens.");
742 if (dun_level && (max_dlv[dungeon_type] > dun_level) && !p_ptr->inside_quest && !p_ptr->word_recall)
745 if (get_check("¤³¤³¤ÏºÇ¿¼Åþ㳬¤è¤êÀõ¤¤³¬¤Ç¤¹¡£¤³¤Î³¬¤ËÌá¤Ã¤ÆÍè¤Þ¤¹¤«¡© "))
747 if (get_check("Reset recall depth? "))
750 max_dlv[dungeon_type] = dun_level;
751 if (record_maxdeapth)
753 do_cmd_write_nikki(NIKKI_TRUMP, dungeon_type, "µ¢´Ô¤Î¤È¤¤Ë");
755 do_cmd_write_nikki(NIKKI_TRUMP, dungeon_type, "when recall from dungeon");
760 if (!p_ptr->word_recall)
766 select_dungeon = choose_dungeon("¤Ëµ¢´Ô");
768 select_dungeon = choose_dungeon("recall");
770 if (!select_dungeon) return FALSE;
771 p_ptr->recall_dungeon = select_dungeon;
773 p_ptr->word_recall = turns;
775 msg_print("²ó¤ê¤ÎÂ絤¤¬Ä¥¤ê¤Ä¤á¤Æ¤¤¿...");
777 msg_print("The air about you becomes charged...");
780 p_ptr->redraw |= (PR_STATUS);
784 p_ptr->word_recall = 0;
786 msg_print("Ä¥¤ê¤Ä¤á¤¿Â絤¤¬Î®¤ìµî¤Ã¤¿...");
788 msg_print("A tension leaves the air around you...");
791 p_ptr->redraw |= (PR_STATUS);
797 bool word_of_recall(void)
799 return(recall_player(randint0(21) + 15));
803 bool reset_recall(void)
805 int select_dungeon, dummy = 0;
810 select_dungeon = choose_dungeon("¤ò¥»¥Ã¥È");
812 select_dungeon = choose_dungeon("reset");
815 if (!select_dungeon) return FALSE;
818 sprintf(ppp, "²¿³¬¤Ë¥»¥Ã¥È¤·¤Þ¤¹¤« (%d-%d):", d_info[select_dungeon].mindepth, max_dlv[select_dungeon]);
820 sprintf(ppp, "Reset to which level (%d-%d): ", d_info[select_dungeon].mindepth, max_dlv[select_dungeon]);
825 sprintf(tmp_val, "%d", MAX(dun_level, 1));
827 /* Ask for a level */
828 if (get_string(ppp, tmp_val, 10))
830 /* Extract request */
831 dummy = atoi(tmp_val);
834 if (dummy < 1) dummy = 1;
837 if (dummy > max_dlv[select_dungeon]) dummy = max_dlv[select_dungeon];
838 if (dummy < d_info[select_dungeon].mindepth) dummy = d_info[select_dungeon].mindepth;
840 max_dlv[select_dungeon] = dummy;
842 if (record_maxdeapth)
844 do_cmd_write_nikki(NIKKI_TRUMP, select_dungeon, "¥Õ¥í¥¢¡¦¥ê¥»¥Ã¥È¤Ç");
846 do_cmd_write_nikki(NIKKI_TRUMP, select_dungeon, "using a scroll of reset recall");
850 msg_format("%s¤Îµ¢´Ô¥ì¥Ù¥ë¤ò %d ³¬¤Ë¥»¥Ã¥È¡£", d_name+d_info[select_dungeon].name, dummy, dummy * 50);
852 msg_format("Recall depth set to level %d (%d').", dummy, dummy * 50);
865 * Apply disenchantment to the player's stuff
867 * XXX XXX XXX This function is also called from the "melee" code
869 * Return "TRUE" if the player notices anything
871 bool apply_disenchant(int mode)
875 char o_name[MAX_NLEN];
876 int to_h, to_d, to_a, pval;
878 /* Pick a random slot */
881 case 1: t = INVEN_RARM; break;
882 case 2: t = INVEN_LARM; break;
883 case 3: t = INVEN_BOW; break;
884 case 4: t = INVEN_BODY; break;
885 case 5: t = INVEN_OUTER; break;
886 case 6: t = INVEN_HEAD; break;
887 case 7: t = INVEN_HANDS; break;
888 case 8: t = INVEN_FEET; break;
892 o_ptr = &inventory[t];
894 /* No item, nothing happens */
895 if (!o_ptr->k_idx) return (FALSE);
898 /* Nothing to disenchant */
899 if ((o_ptr->to_h <= 0) && (o_ptr->to_d <= 0) && (o_ptr->to_a <= 0) && (o_ptr->pval <= 1))
901 /* Nothing to notice */
906 /* Describe the object */
907 object_desc(o_name, o_ptr, FALSE, 0);
910 /* Artifacts have 71% chance to resist */
911 if ((artifact_p(o_ptr) || o_ptr->art_name) && (randint0(100) < 71))
915 msg_format("%s(%c)¤ÏÎô²½¤òÄ·¤ÍÊÖ¤·¤¿¡ª",o_name, index_to_label(t) );
917 msg_format("Your %s (%c) resist%s disenchantment!",
918 o_name, index_to_label(t),
919 ((o_ptr->number != 1) ? "" : "s"));
928 /* Memorize old value */
934 /* Disenchant tohit */
935 if (o_ptr->to_h > 0) o_ptr->to_h--;
936 if ((o_ptr->to_h > 5) && (randint0(100) < 20)) o_ptr->to_h--;
938 /* Disenchant todam */
939 if (o_ptr->to_d > 0) o_ptr->to_d--;
940 if ((o_ptr->to_d > 5) && (randint0(100) < 20)) o_ptr->to_d--;
942 /* Disenchant toac */
943 if (o_ptr->to_a > 0) o_ptr->to_a--;
944 if ((o_ptr->to_a > 5) && (randint0(100) < 20)) o_ptr->to_a--;
946 /* Disenchant pval (occasionally) */
947 /* Unless called from wild_magic() */
948 if ((o_ptr->pval > 1) && one_in_(13) && !(mode & 0x01)) o_ptr->pval--;
950 if ((to_h != o_ptr->to_h) || (to_d != o_ptr->to_d) ||
951 (to_a != o_ptr->to_a) || (pval != o_ptr->pval))
955 msg_format("%s(%c)¤ÏÎô²½¤·¤Æ¤·¤Þ¤Ã¤¿¡ª",
956 o_name, index_to_label(t) );
958 msg_format("Your %s (%c) %s disenchanted!",
959 o_name, index_to_label(t),
960 ((o_ptr->number != 1) ? "were" : "was"));
963 chg_virtue(V_HARMONY, 1);
964 chg_virtue(V_ENCHANT, -2);
966 /* Recalculate bonuses */
967 p_ptr->update |= (PU_BONUS);
970 p_ptr->window |= (PW_EQUIP | PW_PLAYER);
980 void mutate_player(void)
982 int max1, cur1, max2, cur2, ii, jj, i;
984 /* Pick a pair of stats */
986 for (jj = ii; jj == ii; jj = randint0(6)) /* loop */;
988 max1 = p_ptr->stat_max[ii];
989 cur1 = p_ptr->stat_cur[ii];
990 max2 = p_ptr->stat_max[jj];
991 cur2 = p_ptr->stat_cur[jj];
993 p_ptr->stat_max[ii] = max2;
994 p_ptr->stat_cur[ii] = cur2;
995 p_ptr->stat_max[jj] = max1;
996 p_ptr->stat_cur[jj] = cur1;
1000 if(p_ptr->stat_max[i] > p_ptr->stat_max_max[i]) p_ptr->stat_max[i] = p_ptr->stat_max_max[i];
1001 if(p_ptr->stat_cur[i] > p_ptr->stat_max_max[i]) p_ptr->stat_cur[i] = p_ptr->stat_max_max[i];
1004 p_ptr->update |= (PU_BONUS);
1011 void apply_nexus(monster_type *m_ptr)
1013 switch (randint1(7))
1015 case 1: case 2: case 3:
1017 teleport_player(200);
1023 teleport_player_to(m_ptr->fy, m_ptr->fx, TRUE);
1029 if (randint0(100) < p_ptr->skill_sav)
1032 msg_print("¤·¤«¤·¸úÎϤòÄ·¤ÍÊÖ¤·¤¿¡ª");
1034 msg_print("You resist the effects!");
1040 /* Teleport Level */
1041 teleport_player_level();
1047 if (randint0(100) < p_ptr->skill_sav)
1050 msg_print("¤·¤«¤·¸úÎϤòÄ·¤ÍÊÖ¤·¤¿¡ª");
1052 msg_print("You resist the effects!");
1059 msg_print("ÂΤ¬¤Í¤¸¤ì»Ï¤á¤¿...");
1061 msg_print("Your body starts to scramble...");
1072 * Charge a lite (torch or latern)
1074 void phlogiston(void)
1077 object_type * o_ptr = &inventory[INVEN_LITE];
1080 if ((o_ptr->tval == TV_LITE) && (o_ptr->sval == SV_LITE_LANTERN))
1082 max_flog = FUEL_LAMP;
1086 else if ((o_ptr->tval == TV_LITE) && (o_ptr->sval == SV_LITE_TORCH))
1088 max_flog = FUEL_TORCH;
1091 /* No torch to refill */
1095 msg_print("dzÁǤò¾ÃÈñ¤¹¤ë¥¢¥¤¥Æ¥à¤òÁõÈ÷¤·¤Æ¤¤¤Þ¤»¤ó¡£");
1097 msg_print("You are not wielding anything which uses phlogiston.");
1103 if (o_ptr->xtra4 >= max_flog)
1106 msg_print("¤³¤Î¥¢¥¤¥Æ¥à¤Ë¤Ï¤³¤ì°Ê¾ådzÁǤòÊä½¼¤Ç¤¤Þ¤»¤ó¡£");
1108 msg_print("No more phlogiston can be put in this item.");
1115 o_ptr->xtra4 += (max_flog / 2);
1119 msg_print("¾ÈÌÀÍÑ¥¢¥¤¥Æ¥à¤ËdzÁǤòÊä½¼¤·¤¿¡£");
1121 msg_print("You add phlogiston to your light item.");
1126 if (o_ptr->xtra4 >= max_flog)
1128 o_ptr->xtra4 = max_flog;
1130 msg_print("¾ÈÌÀÍÑ¥¢¥¤¥Æ¥à¤ÏËþ¥¿¥ó¤Ë¤Ê¤Ã¤¿¡£");
1132 msg_print("Your light item is full.");
1137 /* Recalculate torch */
1138 p_ptr->update |= (PU_TORCH);
1142 static bool item_tester_hook_weapon_nobow(object_type *o_ptr)
1144 switch (o_ptr->tval)
1154 if (o_ptr->sval != SV_DOKUBARI) return (TRUE);
1162 * Brand the current weapon
1164 void brand_weapon(int brand_type)
1171 /* Assume enchant weapon */
1172 item_tester_hook = item_tester_hook_weapon_nobow;
1173 item_tester_no_ryoute = TRUE;
1177 q = "¤É¤ÎÉð´ï¤ò¶¯²½¤·¤Þ¤¹¤«? ";
1178 s = "¶¯²½¤Ç¤¤ëÉð´ï¤¬¤Ê¤¤¡£";
1180 q = "Enchant which weapon? ";
1181 s = "You have nothing to enchant.";
1184 if (!get_item(&item, q, s, (USE_EQUIP))) return;
1186 /* Get the item (in the pack) */
1189 o_ptr = &inventory[item];
1192 /* Get the item (on the floor) */
1195 o_ptr = &o_list[0 - item];
1199 /* you can never modify artifacts / ego-items */
1200 /* you can never modify cursed items */
1201 /* TY: You _can_ modify broken items (if you're silly enough) */
1202 if (o_ptr->k_idx && !artifact_p(o_ptr) && !ego_item_p(o_ptr) &&
1203 !o_ptr->art_name && !cursed_p(o_ptr) &&
1204 !((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DOKUBARI)) &&
1205 !((o_ptr->tval == TV_POLEARM) && (o_ptr->sval == SV_DEATH_SCYTHE)) &&
1206 !((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DIAMOND_EDGE)))
1210 /* Let's get the name before it is changed... */
1211 char o_name[MAX_NLEN];
1212 object_desc(o_name, o_ptr, FALSE, 0);
1217 if (o_ptr->tval == TV_SWORD)
1220 act = "¤Ï±Ô¤µ¤òÁý¤·¤¿¡ª";
1222 act = "becomes very sharp!";
1225 o_ptr->name2 = EGO_SHARPNESS;
1226 o_ptr->pval = m_bonus(5, dun_level) + 1;
1231 act = "¤ÏÇ˲õÎϤòÁý¤·¤¿¡ª";
1233 act = "seems very powerful.";
1236 o_ptr->name2 = EGO_EARTHQUAKES;
1237 o_ptr->pval = m_bonus(3, dun_level);
1242 act = "¤Ï¿Í´Ö¤Î·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
1244 act = "seems looking for human!";
1247 o_ptr->name2 = EGO_SLAY_HUMAN;
1251 act = "¤ÏÅÅ·â¤Ëʤ¤ï¤ì¤¿¡ª";
1253 act = "coverd with lightning!";
1256 o_ptr->name2 = EGO_BRAND_ELEC;
1260 act = "¤Ï»À¤Ëʤ¤ï¤ì¤¿¡ª";
1262 act = "coated with acid!";
1265 o_ptr->name2 = EGO_BRAND_ACID;
1269 act = "¤Ï¼Ù°¤Ê¤ë²øʪ¤òµá¤á¤Æ¤¤¤ë¡ª";
1271 act = "seems looking for evil monster!";
1274 o_ptr->name2 = EGO_SLAY_EVIL;
1278 act = "¤Ï°ÛÀ¤³¦¤Î½»¿Í¤ÎÆùÂΤòµá¤á¤Æ¤¤¤ë¡ª";
1280 act = "seems looking for demon!";
1283 o_ptr->name2 = EGO_SLAY_DEMON;
1287 act = "¤Ï»Ó¤òµá¤á¤Æ¤¤¤ë¡ª";
1289 act = "seems looking for undead!";
1292 o_ptr->name2 = EGO_SLAY_UNDEAD;
1296 act = "¤Ïưʪ¤Î·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
1298 act = "seems looking for animal!";
1301 o_ptr->name2 = EGO_SLAY_ANIMAL;
1305 act = "¤Ï¥É¥é¥´¥ó¤Î·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
1307 act = "seems looking for dragon!";
1310 o_ptr->name2 = EGO_SLAY_DRAGON;
1314 act = "¤Ï¥È¥í¥ë¤Î·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
1316 act = "seems looking for troll!";
1319 o_ptr->name2 = EGO_SLAY_TROLL;
1323 act = "¤Ï¥ª¡¼¥¯¤Î·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
1325 act = "seems looking for orc!";
1328 o_ptr->name2 = EGO_SLAY_ORC;
1332 act = "¤Ïµð¿Í¤Î·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
1334 act = "seems looking for giant!";
1337 o_ptr->name2 = EGO_SLAY_GIANT;
1341 act = "¤ÏÈó¾ï¤ËÉÔ°ÂÄê¤Ë¤Ê¤Ã¤¿¤è¤¦¤À¡£";
1343 act = "seems very unstable now.";
1346 o_ptr->name2 = EGO_TRUMP;
1347 o_ptr->pval = randint1(2);
1351 act = "¤Ï·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
1353 act = "thirsts for blood!";
1356 o_ptr->name2 = EGO_VAMPIRIC;
1360 act = "¤ÏÆǤËʤ¤ï¤ì¤¿¡£";
1362 act = "is coated with poison.";
1365 o_ptr->name2 = EGO_BRAND_POIS;
1369 act = "¤Ï½ã¥í¥°¥ë¥¹¤Ë°û¤ß¹þ¤Þ¤ì¤¿¡£";
1371 act = "is engulfed in raw Logrus!";
1374 o_ptr->name2 = EGO_CHAOTIC;
1378 act = "¤Ï±ê¤Î¥·¡¼¥ë¥É¤Ëʤ¤ï¤ì¤¿¡ª";
1380 act = "is covered in a fiery shield!";
1383 o_ptr->name2 = EGO_BRAND_FIRE;
1387 act = "¤Ï¿¼¤¯Î䤿¤¤¥Ö¥ë¡¼¤Ëµ±¤¤¤¿¡ª";
1389 act = "glows deep, icy blue!";
1392 o_ptr->name2 = EGO_BRAND_COLD;
1397 msg_format("¤¢¤Ê¤¿¤Î%s%s", o_name, act);
1399 msg_format("Your %s %s", o_name, act);
1403 enchant(o_ptr, randint0(3) + 4, ENCH_TOHIT | ENCH_TODAM);
1405 o_ptr->discount = 99;
1406 chg_virtue(V_ENCHANT, 2);
1410 if (flush_failure) flush();
1413 msg_print("°ÀÉղä˼ºÇÔ¤·¤¿¡£");
1415 msg_print("The Branding failed.");
1418 chg_virtue(V_ENCHANT, -2);
1424 void call_the_(void)
1428 if (cave_floor_bold(py - 1, px - 1) &&
1429 cave_floor_bold(py - 1, px ) &&
1430 cave_floor_bold(py - 1, px + 1) &&
1431 cave_floor_bold(py , px - 1) &&
1432 cave_floor_bold(py , px + 1) &&
1433 cave_floor_bold(py + 1, px - 1) &&
1434 cave_floor_bold(py + 1, px ) &&
1435 cave_floor_bold(py + 1, px + 1))
1437 for (i = 1; i < 10; i++)
1439 if (i-5) fire_ball(GF_ROCKET, i, 175, 2);
1442 for (i = 1; i < 10; i++)
1444 if (i-5) fire_ball(GF_MANA, i, 175, 3);
1447 for (i = 1; i < 10; i++)
1449 if (i-5) fire_ball(GF_NUKE, i, 175, 4);
1455 msg_format("¤¢¤Ê¤¿¤Ï%s¤òÊɤ˶᤹¤®¤ë¾ì½ê¤Ç¾§¤¨¤Æ¤·¤Þ¤Ã¤¿¡ª",
1456 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "µ§¤ê" : "¼öʸ"));
1457 msg_print("Â礤ÊÇúȯ²»¤¬¤¢¤Ã¤¿¡ª");
1459 msg_format("You %s the %s too close to a wall!",
1460 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "recite" : "cast"),
1461 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "prayer" : "spell"));
1462 msg_print("There is a loud explosion!");
1466 if (destroy_area(py, px, 15 + p_ptr->lev + randint0(11), TRUE))
1468 msg_print("¥À¥ó¥¸¥ç¥ó¤¬Êø²õ¤·¤¿...");
1470 msg_print("The dungeon collapses...");
1475 msg_print("¥À¥ó¥¸¥ç¥ó¤ÏÂ礤¯Íɤ줿¡£");
1477 msg_print("The dungeon trembles.");
1482 take_hit(DAMAGE_NOESCAPE, 100 + randint1(150), "¼«»¦Åª¤Êµõ̵¾·Íè", -1);
1484 take_hit(DAMAGE_NOESCAPE, 100 + randint1(150), "a suicidal Call the Void", -1);
1492 * Fetch an item (teleport it right underneath the caster)
1494 void fetch(int dir, int wgt, bool require_los)
1500 char o_name[MAX_NLEN];
1502 /* Check to see if an object is already there */
1503 if (cave[py][px].o_idx)
1506 msg_print("¼«Ê¬¤Î¤β¼¤Ë¤¢¤ëʪ¤Ï¼è¤ì¤Þ¤»¤ó¡£");
1508 msg_print("You can't fetch when you're already standing on something.");
1515 if (dir == 5 && target_okay())
1520 if (distance(py, px, ty, tx) > MAX_RANGE)
1523 msg_print("¤½¤ó¤Ê¤Ë±ó¤¯¤Ë¤¢¤ëʪ¤Ï¼è¤ì¤Þ¤»¤ó¡ª");
1525 msg_print("You can't fetch something that far away!");
1531 c_ptr = &cave[ty][tx];
1533 /* We need an item to fetch */
1537 msg_print("¤½¤³¤Ë¤Ï²¿¤â¤¢¤ê¤Þ¤»¤ó¡£");
1539 msg_print("There is no object at this place.");
1545 /* No fetching from vault */
1546 if (c_ptr->info & CAVE_ICKY)
1549 msg_print("¥¢¥¤¥Æ¥à¤¬¥³¥ó¥È¥í¡¼¥ë¤ò³°¤ì¤ÆÍî¤Á¤¿¡£");
1551 msg_print("The item slips from your control.");
1557 /* We need to see the item */
1558 if (require_los && !player_has_los_bold(ty, tx))
1561 msg_print("¤½¤³¤Ï¤¢¤Ê¤¿¤Î»ë³¦¤ËÆþ¤Ã¤Æ¤¤¤Þ¤»¤ó¡£");
1563 msg_print("You have no direct line of sight to that location.");
1571 /* Use a direction */
1572 ty = py; /* Where to drop the item */
1580 c_ptr = &cave[ty][tx];
1582 if ((distance(py, px, ty, tx) > MAX_RANGE) ||
1583 !cave_floor_bold(ty, tx)) return;
1585 while (!c_ptr->o_idx);
1588 o_ptr = &o_list[c_ptr->o_idx];
1590 if (o_ptr->weight > wgt)
1592 /* Too heavy to 'fetch' */
1594 msg_print("¤½¤Î¥¢¥¤¥Æ¥à¤Ï½Å²á¤®¤Þ¤¹¡£");
1596 msg_print("The object is too heavy.");
1603 c_ptr->o_idx = o_ptr->next_o_idx;
1604 cave[py][px].o_idx = i; /* 'move' it */
1605 o_ptr->next_o_idx = 0;
1606 o_ptr->iy = (byte)py;
1607 o_ptr->ix = (byte)px;
1609 object_desc(o_name, o_ptr, TRUE, 0);
1611 msg_format("%^s¤¬¤¢¤Ê¤¿¤Î¸µ¤ËÈô¤ó¤Ç¤¤¿¡£", o_name);
1613 msg_format("%^s flies through the air to your feet.", o_name);
1618 p_ptr->redraw |= PR_MAP;
1622 void alter_reality(void)
1624 if (!quest_number(dun_level) && dun_level)
1627 msg_print("À¤³¦¤¬ÊѤï¤Ã¤¿¡ª");
1629 msg_print("The world changes!");
1633 if (autosave_l) do_cmd_save_game(TRUE);
1636 p_ptr->leaving = TRUE;
1641 msg_print("À¤³¦¤¬¾¯¤·¤Î´ÖÊѲ½¤·¤¿¤è¤¦¤À¡£");
1643 msg_print("The world seems to change for a moment!");
1651 * Leave a "glyph of warding" which prevents monster movement
1653 bool warding_glyph(void)
1656 if (!cave_clean_bold(py, px))
1659 msg_print("¾²¾å¤Î¥¢¥¤¥Æ¥à¤¬¼öʸ¤òÄ·¤ÍÊÖ¤·¤¿¡£");
1661 msg_print("The object resists the spell.");
1667 /* Create a glyph */
1668 cave[py][px].info |= CAVE_OBJECT;
1669 cave[py][px].mimic = FEAT_GLYPH;
1680 bool warding_mirror(void)
1683 if (!cave_clean_bold(py, px))
1686 msg_print("¾²¾å¤Î¥¢¥¤¥Æ¥à¤¬¼öʸ¤òÄ·¤ÍÊÖ¤·¤¿¡£");
1688 msg_print("The object resists the spell.");
1694 /* Create a mirror */
1695 cave[py][px].info |= CAVE_OBJECT;
1696 cave[py][px].mimic = FEAT_MIRROR;
1698 /* Turn on the light */
1699 cave[py][px].info |= CAVE_GLOW;
1712 * Leave an "explosive rune" which prevents monster movement
1714 bool explosive_rune(void)
1717 if (!cave_clean_bold(py, px))
1720 msg_print("¾²¾å¤Î¥¢¥¤¥Æ¥à¤¬¼öʸ¤òÄ·¤ÍÊÖ¤·¤¿¡£");
1722 msg_print("The object resists the spell.");
1728 /* Create a glyph */
1729 cave[py][px].info |= CAVE_OBJECT;
1730 cave[py][px].mimic = FEAT_MINOR_GLYPH;
1743 * Identify everything being carried.
1744 * Done by a potion of "self knowledge".
1746 void identify_pack(void)
1750 /* Simply identify and know every item */
1751 for (i = 0; i < INVEN_TOTAL; i++)
1753 object_type *o_ptr = &inventory[i];
1755 /* Skip non-objects */
1756 if (!o_ptr->k_idx) continue;
1759 identify_item(o_ptr);
1765 * Used by the "enchant" function (chance of failure)
1766 * (modified for Zangband, we need better stuff there...) -- TY
1768 static int enchant_table[16] =
1770 0, 10, 50, 100, 200,
1771 300, 400, 500, 650, 800,
1772 950, 987, 993, 995, 998,
1778 * Removes curses from items in inventory
1780 * Note that Items which are "Perma-Cursed" (The One Ring,
1781 * The Crown of Morgoth) can NEVER be uncursed.
1783 * Note that if "all" is FALSE, then Items which are
1784 * "Heavy-Cursed" (Mormegil, Calris, and Weapons of Morgul)
1785 * will not be uncursed.
1787 static int remove_curse_aux(int all)
1791 /* Attempt to uncurse items being worn */
1792 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
1794 object_type *o_ptr = &inventory[i];
1796 /* Skip non-objects */
1797 if (!o_ptr->k_idx) continue;
1799 /* Uncursed already */
1800 if (!cursed_p(o_ptr)) continue;
1802 /* Heavily Cursed Items need a special spell */
1803 if (!all && (o_ptr->curse_flags & TRC_HEAVY_CURSE)) continue;
1805 /* Perma-Cursed Items can NEVER be uncursed */
1806 if (o_ptr->curse_flags & TRC_PERMA_CURSE)
1809 o_ptr->curse_flags &= (TRC_CURSED | TRC_HEAVY_CURSE | TRC_PERMA_CURSE);
1814 o_ptr->curse_flags = 0L;
1816 /* Hack -- Assume felt */
1817 o_ptr->ident |= (IDENT_SENSE);
1820 o_ptr->feeling = FEEL_NONE;
1822 /* Recalculate the bonuses */
1823 p_ptr->update |= (PU_BONUS);
1826 p_ptr->window |= (PW_EQUIP);
1828 /* Count the uncursings */
1832 /* Return "something uncursed" */
1838 * Remove most curses
1840 bool remove_curse(void)
1842 return (remove_curse_aux(FALSE));
1848 bool remove_all_curse(void)
1850 return (remove_curse_aux(TRUE));
1855 * Turns an object into gold, gain some of its value in a shop
1864 char o_name[MAX_NLEN];
1865 char out_val[MAX_NLEN+40];
1869 /* Hack -- force destruction */
1870 if (command_arg > 0) force = TRUE;
1874 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò¶â¤ËÊѤ¨¤Þ¤¹¤«¡©";
1875 s = "¶â¤ËÊѤ¨¤é¤ì¤ëʪ¤¬¤¢¤ê¤Þ¤»¤ó¡£";
1877 q = "Turn which item to gold? ";
1878 s = "You have nothing to turn to gold.";
1881 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return (FALSE);
1883 /* Get the item (in the pack) */
1886 o_ptr = &inventory[item];
1889 /* Get the item (on the floor) */
1892 o_ptr = &o_list[0 - item];
1896 /* See how many items */
1897 if (o_ptr->number > 1)
1899 /* Get a quantity */
1900 amt = get_quantity(NULL, o_ptr->number);
1902 /* Allow user abort */
1903 if (amt <= 0) return FALSE;
1907 /* Describe the object */
1908 old_number = o_ptr->number;
1909 o_ptr->number = amt;
1910 object_desc(o_name, o_ptr, TRUE, 3);
1911 o_ptr->number = old_number;
1913 /* Verify unless quantity given */
1916 if (confirm_destroy || (object_value(o_ptr) > 0))
1918 /* Make a verification */
1920 sprintf(out_val, "ËÜÅö¤Ë%s¤ò¶â¤ËÊѤ¨¤Þ¤¹¤«¡©", o_name);
1922 sprintf(out_val, "Really turn %s to gold? ", o_name);
1925 if (!get_check(out_val)) return FALSE;
1929 /* Artifacts cannot be destroyed */
1930 if (!can_player_destroy_object(o_ptr))
1934 msg_format("%s¤ò¶â¤ËÊѤ¨¤ë¤³¤È¤Ë¼ºÇÔ¤·¤¿¡£", o_name);
1936 msg_format("You fail to turn %s to gold!", o_name);
1943 price = object_value_real(o_ptr);
1949 msg_format("%s¤ò¥Ë¥»¤Î¶â¤ËÊѤ¨¤¿¡£", o_name);
1951 msg_format("You turn %s to fool's gold.", o_name);
1959 if (amt > 1) price *= amt;
1961 if (price > 30000) price = 30000;
1963 msg_format("%s¤ò¡ð%d ¤Î¶â¤ËÊѤ¨¤¿¡£", o_name, price);
1965 msg_format("You turn %s to %ld coins worth of gold.", o_name, price);
1971 p_ptr->redraw |= (PR_GOLD);
1974 p_ptr->window |= (PW_PLAYER);
1978 /* Eliminate the item (from the pack) */
1981 inven_item_increase(item, -amt);
1982 inven_item_describe(item);
1983 inven_item_optimize(item);
1986 /* Eliminate the item (from the floor) */
1989 floor_item_increase(0 - item, -amt);
1990 floor_item_describe(0 - item);
1991 floor_item_optimize(0 - item);
1999 * Create stairs at the player location
2001 void stair_creation(void)
2004 if (!cave_valid_bold(py, px))
2007 msg_print("¾²¾å¤Î¥¢¥¤¥Æ¥à¤¬¼öʸ¤òÄ·¤ÍÊÖ¤·¤¿¡£");
2009 msg_print("The object resists the spell.");
2016 delete_object(py, px);
2018 /* Create a staircase */
2019 if (p_ptr->inside_arena || (p_ptr->inside_quest && (p_ptr->inside_quest < MIN_RANDOM_QUEST)) || p_ptr->inside_battle || !dun_level)
2021 /* arena or quest */
2023 msg_print("¸ú²Ì¤¬¤¢¤ê¤Þ¤»¤ó¡ª");
2025 msg_print("There is no effect!");
2029 else if (ironman_downward)
2031 /* Town/wilderness or Ironman */
2032 cave_set_feat(py, px, FEAT_MORE);
2034 else if (quest_number(dun_level) || (dun_level >= d_info[dungeon_type].maxdepth))
2037 cave_set_feat(py, px, FEAT_LESS);
2039 else if (randint0(100) < 50)
2041 cave_set_feat(py, px, FEAT_MORE);
2045 cave_set_feat(py, px, FEAT_LESS);
2051 * Hook to specify "weapon"
2053 bool item_tester_hook_weapon(object_type *o_ptr)
2055 switch (o_ptr->tval)
2069 if (o_ptr->sval != SV_DOKUBARI) return (TRUE);
2076 static bool item_tester_hook_weapon2(object_type *o_ptr)
2078 switch (o_ptr->tval)
2098 * Hook to specify "armour"
2100 bool item_tester_hook_armour(object_type *o_ptr)
2102 switch (o_ptr->tval)
2122 static bool item_tester_hook_corpse(object_type *o_ptr)
2124 switch (o_ptr->tval)
2137 * Check if an object is weapon or armour (but not arrow, bolt, or shot)
2139 bool item_tester_hook_weapon_armour(object_type *o_ptr)
2141 switch (o_ptr->tval)
2170 * Check if an object is nameless weapon or armour
2172 static bool item_tester_hook_nameless_weapon_armour(object_type *o_ptr)
2174 if (o_ptr->name1 || o_ptr->art_name || o_ptr->name2 || o_ptr->xtra3)
2177 switch (o_ptr->tval)
2206 * Break the curse of an item
2208 static void break_curse(object_type *o_ptr)
2210 if (cursed_p(o_ptr) && !(o_ptr->curse_flags & TRC_PERMA_CURSE) && !(o_ptr->curse_flags & TRC_HEAVY_CURSE) && (randint0(100) < 25))
2213 msg_print("¤«¤±¤é¤ì¤Æ¤¤¤¿¼ö¤¤¤¬ÂǤÁÇˤé¤ì¤¿¡ª");
2215 msg_print("The curse is broken!");
2218 o_ptr->curse_flags = 0L;
2220 o_ptr->ident |= (IDENT_SENSE);
2222 o_ptr->feeling = FEEL_NONE;
2228 * Enchants a plus onto an item. -RAK-
2230 * Revamped! Now takes item pointer, number of times to try enchanting,
2231 * and a flag of what to try enchanting. Artifacts resist enchantment
2232 * some of the time, and successful enchantment to at least +0 might
2233 * break a curse on the item. -CFT-
2235 * Note that an item can technically be enchanted all the way to +15 if
2236 * you wait a very, very, long time. Going from +9 to +10 only works
2237 * about 5% of the time, and from +10 to +11 only about 1% of the time.
2239 * Note that this function can now be used on "piles" of items, and
2240 * the larger the pile, the lower the chance of success.
2242 bool enchant(object_type *o_ptr, int n, int eflag)
2244 int i, chance, prob;
2246 bool a = (artifact_p(o_ptr) || o_ptr->art_name);
2247 bool force = (eflag & ENCH_FORCE);
2250 /* Large piles resist enchantment */
2251 prob = o_ptr->number * 100;
2253 /* Missiles are easy to enchant */
2254 if ((o_ptr->tval == TV_BOLT) ||
2255 (o_ptr->tval == TV_ARROW) ||
2256 (o_ptr->tval == TV_SHOT))
2262 for (i = 0; i < n; i++)
2264 /* Hack -- Roll for pile resistance */
2265 if (!force && randint0(prob) >= 100) continue;
2267 /* Enchant to hit */
2268 if (eflag & ENCH_TOHIT)
2270 if (o_ptr->to_h < 0) chance = 0;
2271 else if (o_ptr->to_h > 15) chance = 1000;
2272 else chance = enchant_table[o_ptr->to_h];
2274 if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50))))
2279 /* only when you get it above -1 -CFT */
2280 if (o_ptr->to_h >= 0)
2285 /* Enchant to damage */
2286 if (eflag & ENCH_TODAM)
2288 if (o_ptr->to_d < 0) chance = 0;
2289 else if (o_ptr->to_d > 15) chance = 1000;
2290 else chance = enchant_table[o_ptr->to_d];
2292 if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50))))
2297 /* only when you get it above -1 -CFT */
2298 if (o_ptr->to_d >= 0)
2303 /* Enchant to armor class */
2304 if (eflag & ENCH_TOAC)
2306 if (o_ptr->to_a < 0) chance = 0;
2307 else if (o_ptr->to_a > 15) chance = 1000;
2308 else chance = enchant_table[o_ptr->to_a];
2310 if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50))))
2315 /* only when you get it above -1 -CFT */
2316 if (o_ptr->to_a >= 0)
2323 if (!res) return (FALSE);
2325 /* Recalculate bonuses */
2326 p_ptr->update |= (PU_BONUS);
2328 /* Combine / Reorder the pack (later) */
2329 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
2332 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
2343 * Enchant an item (in the inventory or on the floor)
2344 * Note that "num_ac" requires armour, else weapon
2345 * Returns TRUE if attempted, FALSE if cancelled
2347 bool enchant_spell(int num_hit, int num_dam, int num_ac)
2352 char o_name[MAX_NLEN];
2356 /* Assume enchant weapon */
2357 item_tester_hook = item_tester_hook_weapon;
2358 item_tester_no_ryoute = TRUE;
2360 /* Enchant armor if requested */
2361 if (num_ac) item_tester_hook = item_tester_hook_armour;
2365 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò¶¯²½¤·¤Þ¤¹¤«? ";
2366 s = "¶¯²½¤Ç¤¤ë¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
2368 q = "Enchant which item? ";
2369 s = "You have nothing to enchant.";
2372 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2374 /* Get the item (in the pack) */
2377 o_ptr = &inventory[item];
2380 /* Get the item (on the floor) */
2383 o_ptr = &o_list[0 - item];
2388 object_desc(o_name, o_ptr, FALSE, 0);
2392 msg_format("%s ¤ÏÌÀ¤ë¤¯µ±¤¤¤¿¡ª",
2395 msg_format("%s %s glow%s brightly!",
2396 ((item >= 0) ? "Your" : "The"), o_name,
2397 ((o_ptr->number > 1) ? "" : "s"));
2402 if (enchant(o_ptr, num_hit, ENCH_TOHIT)) okay = TRUE;
2403 if (enchant(o_ptr, num_dam, ENCH_TODAM)) okay = TRUE;
2404 if (enchant(o_ptr, num_ac, ENCH_TOAC)) okay = TRUE;
2410 if (flush_failure) flush();
2414 msg_print("¶¯²½¤Ë¼ºÇÔ¤·¤¿¡£");
2416 msg_print("The enchantment failed.");
2419 if (one_in_(3)) chg_virtue(V_ENCHANT, -1);
2422 chg_virtue(V_ENCHANT, 1);
2426 /* Something happened */
2431 bool artifact_scroll(void)
2436 char o_name[MAX_NLEN];
2440 item_tester_no_ryoute = TRUE;
2441 /* Enchant weapon/armour */
2442 item_tester_hook = item_tester_hook_nameless_weapon_armour;
2446 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò¶¯²½¤·¤Þ¤¹¤«? ";
2447 s = "¶¯²½¤Ç¤¤ë¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
2449 q = "Enchant which item? ";
2450 s = "You have nothing to enchant.";
2453 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2455 /* Get the item (in the pack) */
2458 o_ptr = &inventory[item];
2461 /* Get the item (on the floor) */
2464 o_ptr = &o_list[0 - item];
2469 object_desc(o_name, o_ptr, FALSE, 0);
2473 msg_format("%s ¤ÏâÁ¤¤¸÷¤òȯ¤·¤¿¡ª",o_name);
2475 msg_format("%s %s radiate%s a blinding light!",
2476 ((item >= 0) ? "Your" : "The"), o_name,
2477 ((o_ptr->number > 1) ? "" : "s"));
2480 if (o_ptr->name1 || o_ptr->art_name)
2483 msg_format("%s¤Ï´û¤ËÅÁÀâ¤Î¥¢¥¤¥Æ¥à¤Ç¤¹¡ª",
2486 msg_format("The %s %s already %s!",
2487 o_name, ((o_ptr->number > 1) ? "are" : "is"),
2488 ((o_ptr->number > 1) ? "artifacts" : "an artifact"));
2494 else if (o_ptr->name2)
2497 msg_format("%s¤Ï´û¤Ë̾¤Î¤¢¤ë¥¢¥¤¥Æ¥à¤Ç¤¹¡ª",
2500 msg_format("The %s %s already %s!",
2501 o_name, ((o_ptr->number > 1) ? "are" : "is"),
2502 ((o_ptr->number > 1) ? "ego items" : "an ego item"));
2508 else if (o_ptr->xtra3)
2511 msg_format("%s¤Ï´û¤Ë¶¯²½¤µ¤ì¤Æ¤¤¤Þ¤¹¡ª",
2514 msg_format("The %s %s already %s!",
2515 o_name, ((o_ptr->number > 1) ? "are" : "is"),
2516 ((o_ptr->number > 1) ? "kaji items" : "an kaji item"));
2522 if (o_ptr->number > 1)
2525 msg_print("Ê£¿ô¤Î¥¢¥¤¥Æ¥à¤ËËâË¡¤ò¤«¤±¤ë¤À¤±¤Î¥¨¥Í¥ë¥®¡¼¤Ï¤¢¤ê¤Þ¤»¤ó¡ª");
2526 msg_format("%d ¸Ä¤Î%s¤¬²õ¤ì¤¿¡ª",(o_ptr->number)-1, o_name);
2528 msg_print("Not enough enough energy to enchant more than one object!");
2529 msg_format("%d of your %s %s destroyed!",(o_ptr->number)-1, o_name, (o_ptr->number>2?"were":"was"));
2534 inven_item_increase(item, 1-(o_ptr->number));
2538 floor_item_increase(0-item, 1-(o_ptr->number));
2541 okay = create_artifact(o_ptr, TRUE);
2548 if (flush_failure) flush();
2552 msg_print("¶¯²½¤Ë¼ºÇÔ¤·¤¿¡£");
2554 msg_print("The enchantment failed.");
2557 if (one_in_(3)) chg_virtue(V_ENCHANT, -1);
2560 chg_virtue(V_ENCHANT, 1);
2564 /* Something happened */
2570 * Identify an object
2572 bool identify_item(object_type *o_ptr)
2574 bool old_known = FALSE;
2575 char o_name[MAX_NLEN];
2578 object_desc(o_name, o_ptr, TRUE, 3);
2580 if (o_ptr->ident & IDENT_KNOWN)
2583 if (!(o_ptr->ident & (IDENT_MENTAL)))
2585 if ((o_ptr->art_name) || (artifact_p(o_ptr)) || one_in_(5))
2586 chg_virtue(V_KNOWLEDGE, 1);
2589 /* Identify it fully */
2590 object_aware(o_ptr);
2591 object_known(o_ptr);
2593 /* Recalculate bonuses */
2594 p_ptr->update |= (PU_BONUS);
2596 /* Combine / Reorder the pack (later) */
2597 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
2600 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
2602 strcpy(record_o_name, o_name);
2606 object_desc(o_name, o_ptr, TRUE, 0);
2608 if(record_fix_art && !old_known && artifact_p(o_ptr))
2609 do_cmd_write_nikki(NIKKI_ART, 0, o_name);
2610 if(record_rand_art && !old_known && o_ptr->art_name)
2611 do_cmd_write_nikki(NIKKI_ART, 0, o_name);
2617 static bool item_tester_hook_identify(object_type *o_ptr)
2619 return (bool)!object_known_p(o_ptr);
2622 static bool item_tester_hook_identify_weapon_armour(object_type *o_ptr)
2624 if (object_known_p(o_ptr))
2626 return item_tester_hook_weapon_armour(o_ptr);
2630 * Identify an object in the inventory (or on the floor)
2631 * This routine does *not* automatically combine objects.
2632 * Returns TRUE if something was identified, else FALSE.
2634 bool ident_spell(bool only_equip, bool wait_optimize)
2638 char o_name[MAX_NLEN];
2643 item_tester_no_ryoute = TRUE;
2646 item_tester_hook = item_tester_hook_identify_weapon_armour;
2648 item_tester_hook = item_tester_hook_identify;
2650 if (!can_get_item())
2654 item_tester_hook = item_tester_hook_weapon_armour;
2658 item_tester_hook = NULL;
2664 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò´ÕÄꤷ¤Þ¤¹¤«? ";
2665 s = "´ÕÄꤹ¤ë¤Ù¤¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
2667 q = "Identify which item? ";
2668 s = "You have nothing to identify.";
2671 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2673 /* Get the item (in the pack) */
2676 o_ptr = &inventory[item];
2679 /* Get the item (on the floor) */
2682 o_ptr = &o_list[0 - item];
2686 old_known = identify_item(o_ptr);
2689 object_desc(o_name, o_ptr, TRUE, 3);
2692 if (item >= INVEN_RARM)
2695 msg_format("%^s: %s(%c)¡£", describe_use(item), o_name, index_to_label(item));
2697 msg_format("%^s: %s (%c).", describe_use(item), o_name, index_to_label(item));
2703 msg_format("¥¶¥Ã¥¯Ãæ: %s(%c)¡£", o_name, index_to_label(item));
2705 msg_format("In your pack: %s (%c).", o_name, index_to_label(item));
2711 msg_format("¾²¾å: %s¡£", o_name);
2713 msg_format("On the ground: %s.", o_name);
2717 /* Auto-inscription/destroy */
2718 idx = is_autopick(o_ptr);
2719 auto_inscribe_item(item, idx);
2720 if (destroy_identify && !old_known)
2721 auto_destroy_item(item, idx, wait_optimize);
2723 /* Something happened */
2729 * Mundanify an object in the inventory (or on the floor)
2730 * This routine does *not* automatically combine objects.
2731 * Returns TRUE if something was mundanified, else FALSE.
2733 bool mundane_spell(bool only_equip)
2739 if (only_equip) item_tester_hook = item_tester_hook_weapon_armour;
2740 item_tester_no_ryoute = TRUE;
2744 q = "¤É¤ì¤ò»È¤¤¤Þ¤¹¤«¡©";
2745 s = "»È¤¨¤ë¤â¤Î¤¬¤¢¤ê¤Þ¤»¤ó¡£";
2747 q = "Use which item? ";
2748 s = "You have nothing you can use.";
2751 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2753 /* Get the item (in the pack) */
2756 o_ptr = &inventory[item];
2759 /* Get the item (on the floor) */
2762 o_ptr = &o_list[0 - item];
2767 msg_print("¤Þ¤Ð¤æ¤¤Á®¸÷¤¬Áö¤Ã¤¿¡ª");
2769 msg_print("There is a bright flash of light!");
2772 byte iy = o_ptr->iy; /* Y-position on map, or zero */
2773 byte ix = o_ptr->ix; /* X-position on map, or zero */
2774 s16b next_o_idx= o_ptr->next_o_idx; /* Next object in stack (if any) */
2775 byte marked=o_ptr->marked; /* Object is marked */
2776 s16b weight = (o_ptr->number*o_ptr->weight);
2779 object_prep(o_ptr, o_ptr->k_idx);
2783 o_ptr->next_o_idx=next_o_idx;
2784 o_ptr->marked=marked;
2785 if (item >= 0) p_ptr->total_weight += (o_ptr->weight - weight);
2789 /* Something happened */
2795 static bool item_tester_hook_identify_fully(object_type *o_ptr)
2797 return (bool)(!object_known_p(o_ptr) || !(o_ptr->ident & IDENT_MENTAL));
2800 static bool item_tester_hook_identify_fully_weapon_armour(object_type *o_ptr)
2802 if (!item_tester_hook_identify_fully(o_ptr))
2804 return item_tester_hook_weapon_armour(o_ptr);
2808 * Fully "identify" an object in the inventory -BEN-
2809 * This routine returns TRUE if an item was identified.
2811 bool identify_fully(bool only_equip, bool wait_optimize)
2815 char o_name[MAX_NLEN];
2820 item_tester_no_ryoute = TRUE;
2822 item_tester_hook = item_tester_hook_identify_fully_weapon_armour;
2824 item_tester_hook = item_tester_hook_identify_fully;
2826 if (!can_get_item())
2829 item_tester_hook = item_tester_hook_weapon_armour;
2831 item_tester_hook = NULL;
2836 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò´ÕÄꤷ¤Þ¤¹¤«? ";
2837 s = "´ÕÄꤹ¤ë¤Ù¤¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
2839 q = "Identify which item? ";
2840 s = "You have nothing to identify.";
2843 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2845 /* Get the item (in the pack) */
2848 o_ptr = &inventory[item];
2851 /* Get the item (on the floor) */
2854 o_ptr = &o_list[0 - item];
2858 old_known = identify_item(o_ptr);
2860 /* Mark the item as fully known */
2861 o_ptr->ident |= (IDENT_MENTAL);
2867 object_desc(o_name, o_ptr, TRUE, 3);
2870 if (item >= INVEN_RARM)
2873 msg_format("%^s: %s(%c)¡£", describe_use(item), o_name, index_to_label(item));
2875 msg_format("%^s: %s (%c).", describe_use(item), o_name, index_to_label(item));
2883 msg_format("¥¶¥Ã¥¯Ãæ: %s(%c)¡£", o_name, index_to_label(item));
2885 msg_format("In your pack: %s (%c).", o_name, index_to_label(item));
2891 msg_format("¾²¾å: %s¡£", o_name);
2893 msg_format("On the ground: %s.", o_name);
2897 /* Describe it fully */
2898 (void)identify_fully_aux(o_ptr);
2900 /* Auto-inscription/destroy */
2901 idx = is_autopick(o_ptr);
2902 auto_inscribe_item(item, idx);
2903 if (destroy_identify && !old_known)
2904 auto_destroy_item(item, idx, wait_optimize);
2914 * Hook for "get_item()". Determine if something is rechargable.
2916 bool item_tester_hook_recharge(object_type *o_ptr)
2918 /* Recharge staffs */
2919 if (o_ptr->tval == TV_STAFF) return (TRUE);
2921 /* Recharge wands */
2922 if (o_ptr->tval == TV_WAND) return (TRUE);
2924 /* Hack -- Recharge rods */
2925 if (o_ptr->tval == TV_ROD) return (TRUE);
2933 * Recharge a wand/staff/rod from the pack or on the floor.
2934 * This function has been rewritten in Oangband and ZAngband.
2936 * Sorcery/Arcane -- Recharge --> recharge(plev * 4)
2937 * Chaos -- Arcane Binding --> recharge(90)
2939 * Scroll of recharging --> recharge(130)
2940 * Artifact activation/Thingol --> recharge(130)
2942 * It is harder to recharge high level, and highly charged wands,
2943 * staffs, and rods. The more wands in a stack, the more easily and
2944 * strongly they recharge. Staffs, however, each get fewer charges if
2947 * XXX XXX XXX Beware of "sliding index errors".
2949 bool recharge(int power)
2952 int recharge_strength, recharge_amount;
2961 char o_name[MAX_NLEN];
2963 /* Only accept legal items */
2964 item_tester_hook = item_tester_hook_recharge;
2968 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ËËâÎϤò½¼Å¶¤·¤Þ¤¹¤«? ";
2969 s = "ËâÎϤò½¼Å¶¤¹¤Ù¤¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
2971 q = "Recharge which item? ";
2972 s = "You have nothing to recharge.";
2975 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return (FALSE);
2977 /* Get the item (in the pack) */
2980 o_ptr = &inventory[item];
2983 /* Get the item (on the floor) */
2986 o_ptr = &o_list[0 - item];
2989 /* Get the object kind. */
2990 k_ptr = &k_info[o_ptr->k_idx];
2992 /* Extract the object "level" */
2993 lev = get_object_level(o_ptr);
2996 /* Recharge a rod */
2997 if (o_ptr->tval == TV_ROD)
2999 /* Extract a recharge strength by comparing object level to power. */
3000 recharge_strength = ((power > lev/2) ? (power - lev/2) : 0) / 5;
3004 if (one_in_(recharge_strength))
3006 /* Activate the failure code. */
3013 /* Recharge amount */
3014 recharge_amount = (power * damroll(3, 2));
3016 /* Recharge by that amount */
3017 if (o_ptr->timeout > recharge_amount)
3018 o_ptr->timeout -= recharge_amount;
3025 /* Recharge wand/staff */
3028 /* Extract a recharge strength by comparing object level to power.
3029 * Divide up a stack of wands' charges to calculate charge penalty.
3031 if ((o_ptr->tval == TV_WAND) && (o_ptr->number > 1))
3032 recharge_strength = (100 + power - lev -
3033 (8 * o_ptr->pval / o_ptr->number)) / 15;
3035 /* All staffs, unstacked wands. */
3036 else recharge_strength = (100 + power - lev -
3037 (8 * o_ptr->pval)) / 15;
3040 if (recharge_strength < 0) recharge_strength = 0;
3043 if (one_in_(recharge_strength))
3045 /* Activate the failure code. */
3049 /* If the spell didn't backfire, recharge the wand or staff. */
3052 /* Recharge based on the standard number of charges. */
3053 recharge_amount = randint1(1 + k_ptr->pval / 2);
3055 /* Multiple wands in a stack increase recharging somewhat. */
3056 if ((o_ptr->tval == TV_WAND) && (o_ptr->number > 1))
3059 (randint1(recharge_amount * (o_ptr->number - 1))) / 2;
3060 if (recharge_amount < 1) recharge_amount = 1;
3061 if (recharge_amount > 12) recharge_amount = 12;
3064 /* But each staff in a stack gets fewer additional charges,
3065 * although always at least one.
3067 if ((o_ptr->tval == TV_STAFF) && (o_ptr->number > 1))
3069 recharge_amount /= o_ptr->number;
3070 if (recharge_amount < 1) recharge_amount = 1;
3073 /* Recharge the wand or staff. */
3074 o_ptr->pval += recharge_amount;
3077 /* Hack -- we no longer "know" the item */
3078 o_ptr->ident &= ~(IDENT_KNOWN);
3080 /* Hack -- we no longer think the item is empty */
3081 o_ptr->ident &= ~(IDENT_EMPTY);
3086 /* Inflict the penalties for failing a recharge. */
3089 /* Artifacts are never destroyed. */
3090 if (artifact_p(o_ptr))
3092 object_desc(o_name, o_ptr, TRUE, 0);
3094 msg_format("ËâÎϤ¬µÕή¤·¤¿¡ª%s¤Ï´°Á´¤ËËâÎϤò¼º¤Ã¤¿¡£", o_name);
3096 msg_format("The recharging backfires - %s is completely drained!", o_name);
3100 /* Artifact rods. */
3101 if ((o_ptr->tval == TV_ROD) && (o_ptr->timeout < 10000))
3102 o_ptr->timeout = (o_ptr->timeout + 100) * 2;
3104 /* Artifact wands and staffs. */
3105 else if ((o_ptr->tval == TV_WAND) || (o_ptr->tval == TV_STAFF))
3110 /* Get the object description */
3111 object_desc(o_name, o_ptr, FALSE, 0);
3113 /*** Determine Seriousness of Failure ***/
3115 /* Mages recharge objects more safely. */
3116 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)
3118 /* 10% chance to blow up one rod, otherwise draining. */
3119 if (o_ptr->tval == TV_ROD)
3121 if (one_in_(10)) fail_type = 2;
3124 /* 75% chance to blow up one wand, otherwise draining. */
3125 else if (o_ptr->tval == TV_WAND)
3127 if (!one_in_(3)) fail_type = 2;
3130 /* 50% chance to blow up one staff, otherwise no effect. */
3131 else if (o_ptr->tval == TV_STAFF)
3133 if (one_in_(2)) fail_type = 2;
3138 /* All other classes get no special favors. */
3141 /* 33% chance to blow up one rod, otherwise draining. */
3142 if (o_ptr->tval == TV_ROD)
3144 if (one_in_(3)) fail_type = 2;
3147 /* 20% chance of the entire stack, else destroy one wand. */
3148 else if (o_ptr->tval == TV_WAND)
3150 if (one_in_(5)) fail_type = 3;
3153 /* Blow up one staff. */
3154 else if (o_ptr->tval == TV_STAFF)
3160 /*** Apply draining and destruction. ***/
3162 /* Drain object or stack of objects. */
3165 if (o_ptr->tval == TV_ROD)
3168 msg_print("ËâÎϤ¬µÕÊ®¼Í¤·¤Æ¡¢¥í¥Ã¥É¤«¤é¤µ¤é¤ËËâÎϤòµÛ¤¤¼è¤Ã¤Æ¤·¤Þ¤Ã¤¿¡ª");
3170 msg_print("The recharge backfires, draining the rod further!");
3173 if (o_ptr->timeout < 10000)
3174 o_ptr->timeout = (o_ptr->timeout + 100) * 2;
3176 else if (o_ptr->tval == TV_WAND)
3179 msg_format("%s¤ÏÇË»¤òÌȤ줿¤¬¡¢ËâÎϤ¬Á´¤Æ¼º¤ï¤ì¤¿¡£", o_name);
3181 msg_format("You save your %s from destruction, but all charges are lost.", o_name);
3186 /* Staffs aren't drained. */
3189 /* Destroy an object or one in a stack of objects. */
3192 if (o_ptr->number > 1)
3194 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬°ìËܲõ¤ì¤¿¡ª", o_name);
3196 msg_format("Wild magic consumes one of your %s!", o_name);
3201 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬²õ¤ì¤¿¡ª", o_name);
3203 msg_format("Wild magic consumes your %s!", o_name);
3207 /* Reduce rod stack maximum timeout, drain wands. */
3208 if (o_ptr->tval == TV_ROD) o_ptr->timeout = (o_ptr->number - 1) * k_ptr->pval;
3209 if (o_ptr->tval == TV_WAND) o_ptr->pval = 0;
3211 /* Reduce and describe inventory */
3214 inven_item_increase(item, -1);
3215 inven_item_describe(item);
3216 inven_item_optimize(item);
3219 /* Reduce and describe floor item */
3222 floor_item_increase(0 - item, -1);
3223 floor_item_describe(0 - item);
3224 floor_item_optimize(0 - item);
3228 /* Destroy all members of a stack of objects. */
3231 if (o_ptr->number > 1)
3233 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬Á´¤Æ²õ¤ì¤¿¡ª", o_name);
3235 msg_format("Wild magic consumes all your %s!", o_name);
3240 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬²õ¤ì¤¿¡ª", o_name);
3242 msg_format("Wild magic consumes your %s!", o_name);
3247 /* Reduce and describe inventory */
3250 inven_item_increase(item, -999);
3251 inven_item_describe(item);
3252 inven_item_optimize(item);
3255 /* Reduce and describe floor item */
3258 floor_item_increase(0 - item, -999);
3259 floor_item_describe(0 - item);
3260 floor_item_optimize(0 - item);
3266 /* Combine / Reorder the pack (later) */
3267 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
3270 p_ptr->window |= (PW_INVEN);
3272 /* Something was done */
3280 bool bless_weapon(void)
3284 u32b flgs[TR_FLAG_SIZE];
3285 char o_name[MAX_NLEN];
3288 item_tester_no_ryoute = TRUE;
3289 /* Assume enchant weapon */
3290 item_tester_hook = item_tester_hook_weapon2;
3294 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò½ËÊ¡¤·¤Þ¤¹¤«¡©";
3295 s = "½ËÊ¡¤Ç¤¤ëÉð´ï¤¬¤¢¤ê¤Þ¤»¤ó¡£";
3297 q = "Bless which weapon? ";
3298 s = "You have weapon to bless.";
3301 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR)))
3304 /* Get the item (in the pack) */
3307 o_ptr = &inventory[item];
3310 /* Get the item (on the floor) */
3313 o_ptr = &o_list[0 - item];
3318 object_desc(o_name, o_ptr, FALSE, 0);
3320 /* Extract the flags */
3321 object_flags(o_ptr, flgs);
3323 if (cursed_p(o_ptr))
3325 if (((o_ptr->curse_flags & TRC_HEAVY_CURSE) && (randint1(100) < 33)) ||
3326 (o_ptr->curse_flags & TRC_PERMA_CURSE))
3329 msg_format("%s¤òʤ¤¦¹õ¤¤¥ª¡¼¥é¤Ï½ËÊ¡¤òÄ·¤ÍÊÖ¤·¤¿¡ª",
3332 msg_format("The black aura on %s %s disrupts the blessing!",
3333 ((item >= 0) ? "your" : "the"), o_name);
3340 msg_format("%s ¤«¤é¼Ù°¤Ê¥ª¡¼¥é¤¬¾Ã¤¨¤¿¡£",
3343 msg_format("A malignant aura leaves %s %s.",
3344 ((item >= 0) ? "your" : "the"), o_name);
3349 o_ptr->curse_flags = 0L;
3351 /* Hack -- Assume felt */
3352 o_ptr->ident |= (IDENT_SENSE);
3355 o_ptr->feeling = FEEL_NONE;
3357 /* Recalculate the bonuses */
3358 p_ptr->update |= (PU_BONUS);
3361 p_ptr->window |= (PW_EQUIP);
3365 * Next, we try to bless it. Artifacts have a 1/3 chance of
3366 * being blessed, otherwise, the operation simply disenchants
3367 * them, godly power negating the magic. Ok, the explanation
3368 * is silly, but otherwise priests would always bless every
3369 * artifact weapon they find. Ego weapons and normal weapons
3370 * can be blessed automatically.
3372 if (have_flag(flgs, TR_BLESSED))
3375 msg_format("%s ¤Ï´û¤Ë½ËÊ¡¤µ¤ì¤Æ¤¤¤ë¡£",
3378 msg_format("%s %s %s blessed already.",
3379 ((item >= 0) ? "Your" : "The"), o_name,
3380 ((o_ptr->number > 1) ? "were" : "was"));
3386 if (!(o_ptr->art_name || o_ptr->name1 || o_ptr->name2) || one_in_(3))
3390 msg_format("%s¤Ïµ±¤¤¤¿¡ª",
3393 msg_format("%s %s shine%s!",
3394 ((item >= 0) ? "Your" : "The"), o_name,
3395 ((o_ptr->number > 1) ? "" : "s"));
3398 add_flag(o_ptr->art_flags, TR_BLESSED);
3399 o_ptr->discount = 99;
3403 bool dis_happened = FALSE;
3406 msg_print("¤½¤ÎÉð´ï¤Ï½ËÊ¡¤ò·ù¤Ã¤Æ¤¤¤ë¡ª");
3408 msg_print("The weapon resists your blessing!");
3412 /* Disenchant tohit */
3413 if (o_ptr->to_h > 0)
3416 dis_happened = TRUE;
3419 if ((o_ptr->to_h > 5) && (randint0(100) < 33)) o_ptr->to_h--;
3421 /* Disenchant todam */
3422 if (o_ptr->to_d > 0)
3425 dis_happened = TRUE;
3428 if ((o_ptr->to_d > 5) && (randint0(100) < 33)) o_ptr->to_d--;
3430 /* Disenchant toac */
3431 if (o_ptr->to_a > 0)
3434 dis_happened = TRUE;
3437 if ((o_ptr->to_a > 5) && (randint0(100) < 33)) o_ptr->to_a--;
3442 msg_print("¼þ°Ï¤¬ËÞÍǤÊÊ·°Ïµ¤¤ÇËþ¤Á¤¿...");
3444 msg_print("There is a static feeling in the air...");
3448 msg_format("%s ¤ÏÎô²½¤·¤¿¡ª",
3451 msg_format("%s %s %s disenchanted!",
3452 ((item >= 0) ? "Your" : "The"), o_name,
3453 ((o_ptr->number > 1) ? "were" : "was"));
3459 /* Recalculate bonuses */
3460 p_ptr->update |= (PU_BONUS);
3463 p_ptr->window |= (PW_EQUIP | PW_PLAYER);
3474 bool pulish_shield(void)
3478 u32b flgs[TR_FLAG_SIZE];
3479 char o_name[MAX_NLEN];
3482 item_tester_no_ryoute = TRUE;
3483 /* Assume enchant weapon */
3484 item_tester_tval = TV_SHIELD;
3488 q = "¤É¤Î½â¤òËᤤޤ¹¤«¡©";
3489 s = "Ë᤯½â¤¬¤¢¤ê¤Þ¤»¤ó¡£";
3491 q = "Pulish which weapon? ";
3492 s = "You have weapon to pulish.";
3495 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR)))
3498 /* Get the item (in the pack) */
3501 o_ptr = &inventory[item];
3504 /* Get the item (on the floor) */
3507 o_ptr = &o_list[0 - item];
3512 object_desc(o_name, o_ptr, FALSE, 0);
3514 /* Extract the flags */
3515 object_flags(o_ptr, flgs);
3517 if (o_ptr->k_idx && !artifact_p(o_ptr) && !ego_item_p(o_ptr) &&
3518 !o_ptr->art_name && !cursed_p(o_ptr) && (o_ptr->sval != SV_SHIELD_OF_DEFLECTION))
3521 msg_format("%s¤Ïµ±¤¤¤¿¡ª", o_name);
3523 msg_format("%s %s shine%s!",
3524 ((item >= 0) ? "Your" : "The"), o_name,
3525 ((o_ptr->number > 1) ? "" : "s"));
3527 o_ptr->name2 = EGO_REFLECTION;
3528 enchant(o_ptr, randint0(3) + 4, ENCH_TOAC);
3530 o_ptr->discount = 99;
3531 chg_virtue(V_ENCHANT, 2);
3537 if (flush_failure) flush();
3540 msg_print("¼ºÇÔ¤·¤¿¡£");
3542 msg_print("Failed.");
3545 chg_virtue(V_ENCHANT, -2);
3554 * Potions "smash open" and cause an area effect when
3555 * (1) they are shattered while in the player's inventory,
3556 * due to cold (etc) attacks;
3557 * (2) they are thrown at a monster, or obstacle;
3558 * (3) they are shattered by a "cold ball" or other such spell
3559 * while lying on the floor.
3562 * who --- who caused the potion to shatter (0=player)
3563 * potions that smash on the floor are assumed to
3564 * be caused by no-one (who = 1), as are those that
3565 * shatter inside the player inventory.
3566 * (Not anymore -- I changed this; TY)
3567 * y, x --- coordinates of the potion (or player if
3568 * the potion was in her inventory);
3569 * o_ptr --- pointer to the potion object.
3571 bool potion_smash_effect(int who, int y, int x, int k_idx)
3579 object_kind *k_ptr = &k_info[k_idx];
3581 switch (k_ptr->sval)
3583 case SV_POTION_SALT_WATER:
3584 case SV_POTION_SLIME_MOLD:
3585 case SV_POTION_LOSE_MEMORIES:
3586 case SV_POTION_DEC_STR:
3587 case SV_POTION_DEC_INT:
3588 case SV_POTION_DEC_WIS:
3589 case SV_POTION_DEC_DEX:
3590 case SV_POTION_DEC_CON:
3591 case SV_POTION_DEC_CHR:
3592 case SV_POTION_WATER: /* perhaps a 'water' attack? */
3593 case SV_POTION_APPLE_JUICE:
3596 case SV_POTION_INFRAVISION:
3597 case SV_POTION_DETECT_INVIS:
3598 case SV_POTION_SLOW_POISON:
3599 case SV_POTION_CURE_POISON:
3600 case SV_POTION_BOLDNESS:
3601 case SV_POTION_RESIST_HEAT:
3602 case SV_POTION_RESIST_COLD:
3603 case SV_POTION_HEROISM:
3604 case SV_POTION_BESERK_STRENGTH:
3605 case SV_POTION_RES_STR:
3606 case SV_POTION_RES_INT:
3607 case SV_POTION_RES_WIS:
3608 case SV_POTION_RES_DEX:
3609 case SV_POTION_RES_CON:
3610 case SV_POTION_RES_CHR:
3611 case SV_POTION_INC_STR:
3612 case SV_POTION_INC_INT:
3613 case SV_POTION_INC_WIS:
3614 case SV_POTION_INC_DEX:
3615 case SV_POTION_INC_CON:
3616 case SV_POTION_INC_CHR:
3617 case SV_POTION_AUGMENTATION:
3618 case SV_POTION_ENLIGHTENMENT:
3619 case SV_POTION_STAR_ENLIGHTENMENT:
3620 case SV_POTION_SELF_KNOWLEDGE:
3621 case SV_POTION_EXPERIENCE:
3622 case SV_POTION_RESISTANCE:
3623 case SV_POTION_INVULNERABILITY:
3624 case SV_POTION_NEW_LIFE:
3625 /* All of the above potions have no effect when shattered */
3627 case SV_POTION_SLOWNESS:
3633 case SV_POTION_POISON:
3639 case SV_POTION_BLINDNESS:
3644 case SV_POTION_CONFUSION: /* Booze */
3649 case SV_POTION_SLEEP:
3654 case SV_POTION_RUINATION:
3655 case SV_POTION_DETONATIONS:
3657 dam = damroll(25, 25);
3661 case SV_POTION_DEATH:
3662 dt = GF_DEATH_RAY; /* !! */
3663 dam = k_ptr->level * 10;
3668 case SV_POTION_SPEED:
3672 case SV_POTION_CURE_LIGHT:
3674 dam = damroll(2, 3);
3677 case SV_POTION_CURE_SERIOUS:
3679 dam = damroll(4, 3);
3682 case SV_POTION_CURE_CRITICAL:
3683 case SV_POTION_CURING:
3685 dam = damroll(6, 3);
3688 case SV_POTION_HEALING:
3690 dam = damroll(10, 10);
3693 case SV_POTION_RESTORE_EXP:
3699 case SV_POTION_LIFE:
3701 dam = damroll(50, 50);
3705 case SV_POTION_STAR_HEALING:
3707 dam = damroll(50, 50);
3711 case SV_POTION_RESTORE_MANA: /* MANA */
3713 dam = damroll(10, 10);
3721 (void)project(who, radius, y, x, dam, dt,
3722 (PROJECT_JUMP | PROJECT_ITEM | PROJECT_KILL), -1);
3724 /* XXX those potions that explode need to become "known" */
3730 * Hack -- Display all known spells in a window
3732 * XXX XXX XXX Need to analyze size of the window.
3734 * XXX XXX XXX Need more color coding.
3736 void display_spell_list(void)
3749 /* They have too many spells to list */
3750 if (p_ptr->pclass == CLASS_SORCERER) return;
3751 if (p_ptr->pclass == CLASS_RED_MAGE) return;
3753 /* mind.c type classes */
3754 if ((p_ptr->pclass == CLASS_MINDCRAFTER) ||
3755 (p_ptr->pclass == CLASS_BERSERKER) ||
3756 (p_ptr->pclass == CLASS_NINJA) ||
3757 (p_ptr->pclass == CLASS_MIRROR_MASTER) ||
3758 (p_ptr->pclass == CLASS_FORCETRAINER))
3764 int plev = p_ptr->lev;
3770 bool use_hp = FALSE;
3772 /* Display a list of spells */
3775 put_str("̾Á°", y, x + 5);
3776 put_str("Lv MP ¼ºÎ¨ ¸ú²Ì", y, x + 35);
3778 put_str("Name", y, x + 5);
3779 put_str("Lv Mana Fail Info", y, x + 35);
3782 switch(p_ptr->pclass)
3784 case CLASS_MINDCRAFTER: use_mind = MIND_MINDCRAFTER;break;
3785 case CLASS_FORCETRAINER: use_mind = MIND_KI;break;
3786 case CLASS_BERSERKER: use_mind = MIND_BERSERKER; use_hp = TRUE; break;
3787 case CLASS_MIRROR_MASTER: use_mind = MIND_MIRROR_MASTER; break;
3788 case CLASS_NINJA: use_mind = MIND_NINJUTSU; use_hp = TRUE; break;
3789 default: use_mind = 0;break;
3792 /* Dump the spells */
3793 for (i = 0; i < MAX_MIND_POWERS; i++)
3795 byte a = TERM_WHITE;
3797 /* Access the available spell */
3798 spell = mind_powers[use_mind].info[i];
3799 if (spell.min_lev > plev) break;
3801 /* Get the failure rate */
3802 chance = spell.fail;
3804 /* Reduce failure rate by "effective" level adjustment */
3805 chance -= 3 * (p_ptr->lev - spell.min_lev);
3807 /* Reduce failure rate by INT/WIS adjustment */
3808 chance -= 3 * (adj_mag_stat[p_ptr->stat_ind[mp_ptr->spell_stat]] - 1);
3812 /* Not enough mana to cast */
3813 if (spell.mana_cost > p_ptr->csp)
3815 chance += 5 * (spell.mana_cost - p_ptr->csp);
3821 /* Not enough hp to cast */
3822 if (spell.mana_cost > p_ptr->chp)
3829 /* Extract the minimum failure rate */
3830 minfail = adj_mag_fail[p_ptr->stat_ind[mp_ptr->spell_stat]];
3832 /* Minimum failure rate */
3833 if (chance < minfail) chance = minfail;
3835 /* Stunning makes spells harder */
3836 if (p_ptr->stun > 50) chance += 25;
3837 else if (p_ptr->stun) chance += 15;
3839 /* Always a 5 percent chance of working */
3840 if (chance > 95) chance = 95;
3843 mindcraft_info(comment, use_mind, i);
3845 /* Dump the spell */
3846 sprintf(psi_desc, " %c) %-30s%2d %4d %3d%%%s",
3848 spell.min_lev, spell.mana_cost, chance, comment);
3850 Term_putstr(x, y + i + 1, -1, a, psi_desc);
3855 /* Cannot read spellbooks */
3856 if (REALM_NONE == p_ptr->realm1) return;
3858 /* Normal spellcaster with books */
3861 for (j = 0; j < ((p_ptr->realm2 > REALM_NONE) ? 2 : 1); j++)
3865 /* Reset vertical */
3868 /* Vertical location */
3869 y = (j < 3) ? 0 : (m[j - 3] + 2);
3871 /* Horizontal location */
3875 for (i = 0; i < 32; i++)
3877 byte a = TERM_WHITE;
3879 /* Access the spell */
3880 if (!is_magic((j < 1) ? p_ptr->realm1 : p_ptr->realm2))
3882 s_ptr = &technic_info[((j < 1) ? p_ptr->realm1 : p_ptr->realm2) - MIN_TECHNIC][i % 32];
3886 s_ptr = &mp_ptr->info[((j < 1) ? p_ptr->realm1 : p_ptr->realm2) - 1][i % 32];
3889 strcpy(name, spell_names[technic2magic((j < 1) ? p_ptr->realm1 : p_ptr->realm2)-1][i % 32]);
3892 if (s_ptr->slevel >= 99)
3896 strcpy(name, "(ȽÆÉÉÔǽ)");
3898 strcpy(name, "(illegible)");
3908 ((p_ptr->spell_forgotten1 & (1L << i))) :
3909 ((p_ptr->spell_forgotten2 & (1L << (i % 32)))))
3916 else if (!((j < 1) ?
3917 (p_ptr->spell_learned1 & (1L << i)) :
3918 (p_ptr->spell_learned2 & (1L << (i % 32)))))
3925 else if (!((j < 1) ?
3926 (p_ptr->spell_worked1 & (1L << i)) :
3927 (p_ptr->spell_worked2 & (1L << (i % 32)))))
3933 /* Dump the spell --(-- */
3934 sprintf(out_val, "%c/%c) %-20.20s",
3935 I2A(n / 8), I2A(n % 8), name);
3940 /* Dump onto the window */
3941 Term_putstr(x, m[j], -1, a, out_val);
3951 * Returns experience of a spell
3953 s16b experience_of_spell(int spell, int use_realm)
3955 if (p_ptr->pclass == CLASS_SORCERER) return 1600;
3956 else if (p_ptr->pclass == CLASS_RED_MAGE) return 1200;
3957 else if (use_realm == p_ptr->realm1) return p_ptr->spell_exp[spell];
3958 else if (use_realm == p_ptr->realm2) return p_ptr->spell_exp[spell + 32];
3964 * Returns spell chance of failure for spell -RAK-
3966 s16b spell_chance(int spell, int use_realm)
3968 int chance, minfail;
3971 int penalty = (mp_ptr->spell_stat == A_WIS) ? 10 : 4;
3974 /* Paranoia -- must be literate */
3975 if (!mp_ptr->spell_book) return (100);
3977 if (use_realm == REALM_HISSATSU) return 0;
3979 /* Access the spell */
3980 if (!is_magic(use_realm))
3982 s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
3986 s_ptr = &mp_ptr->info[use_realm - 1][spell];
3989 /* Extract the base spell failure rate */
3990 chance = s_ptr->sfail;
3992 /* Reduce failure rate by "effective" level adjustment */
3993 chance -= 3 * (p_ptr->lev - s_ptr->slevel);
3995 /* Reduce failure rate by INT/WIS adjustment */
3996 chance -= 3 * (adj_mag_stat[p_ptr->stat_ind[mp_ptr->spell_stat]] - 1);
3999 chance += (MAX(r_info[m_list[p_ptr->riding].r_idx].level-p_ptr->skill_exp[GINOU_RIDING]/100-10,0));
4001 /* Extract mana consumption rate */
4002 shouhimana = s_ptr->smana*(3800 - experience_of_spell(spell, use_realm)) + 2399;
4004 if(p_ptr->dec_mana) shouhimana *= 3;
4005 else shouhimana *= 4;
4008 if(shouhimana < 1) shouhimana = 1;
4010 /* Not enough mana to cast */
4011 if (shouhimana > p_ptr->csp)
4013 chance += 5 * (shouhimana - p_ptr->csp);
4016 chance += p_ptr->to_m_chance;
4017 if ((use_realm != p_ptr->realm1) && ((p_ptr->pclass == CLASS_MAGE) || (p_ptr->pclass == CLASS_PRIEST))) chance += 5;
4019 /* Extract the minimum failure rate */
4020 minfail = adj_mag_fail[p_ptr->stat_ind[mp_ptr->spell_stat]];
4023 * Non mage/priest characters never get too good
4024 * (added high mage, mindcrafter)
4026 if (mp_ptr->spell_xtra & MAGIC_FAIL_5PERCENT)
4028 if (minfail < 5) minfail = 5;
4031 /* Hack -- Priest prayer penalty for "edged" weapons -DGK */
4032 if (((p_ptr->pclass == CLASS_PRIEST) || (p_ptr->pclass == CLASS_SORCERER)) && p_ptr->icky_wield[0]) chance += 25;
4033 if (((p_ptr->pclass == CLASS_PRIEST) || (p_ptr->pclass == CLASS_SORCERER)) && p_ptr->icky_wield[1]) chance += 25;
4035 if (p_ptr->heavy_spell) chance += 20;
4036 if(p_ptr->dec_mana && p_ptr->easy_spell) chance-=4;
4037 else if (p_ptr->easy_spell) chance-=3;
4038 else if (p_ptr->dec_mana) chance-=2;
4040 if ((use_realm == REALM_NATURE) && ((p_ptr->align > 50) || (p_ptr->align < -50))) chance += penalty;
4041 if (((use_realm == REALM_LIFE) || (use_realm == REALM_CRUSADE)) && (p_ptr->align < -20)) chance += penalty;
4042 if (((use_realm == REALM_DEATH) || (use_realm == REALM_DAEMON)) && (p_ptr->align > 20)) chance += penalty;
4044 /* Minimum failure rate */
4045 if (chance < minfail) chance = minfail;
4047 /* Stunning makes spells harder */
4048 if (p_ptr->stun > 50) chance += 25;
4049 else if (p_ptr->stun) chance += 15;
4051 /* Always a 5 percent chance of working */
4052 if (chance > 95) chance = 95;
4054 if ((use_realm == p_ptr->realm1) || (use_realm == p_ptr->realm2))
4056 s16b exp = experience_of_spell(spell, use_realm);
4057 if(exp > 1399) chance--;
4058 if(exp > 1599) chance--;
4060 if(p_ptr->dec_mana) chance--;
4061 if (p_ptr->heavy_spell) chance += 5;
4063 chance = MAX(chance,0);
4065 /* Return the chance */
4072 * Determine if a spell is "okay" for the player to cast or study
4073 * The spell must be legible, not forgotten, and also, to cast,
4074 * it must be known, and to study, it must not be known.
4076 bool spell_okay(int spell, bool learned, bool study_pray, int use_realm)
4080 /* Access the spell */
4081 if (!is_magic(use_realm))
4083 s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
4087 s_ptr = &mp_ptr->info[use_realm - 1][spell];
4090 /* Spell is illegal */
4091 if (s_ptr->slevel > p_ptr->lev) return (FALSE);
4093 /* Spell is forgotten */
4094 if ((use_realm == p_ptr->realm2) ?
4095 (p_ptr->spell_forgotten2 & (1L << spell)) :
4096 (p_ptr->spell_forgotten1 & (1L << spell)))
4102 if (p_ptr->pclass == CLASS_SORCERER) return (TRUE);
4103 if (p_ptr->pclass == CLASS_RED_MAGE) return (TRUE);
4105 /* Spell is learned */
4106 if ((use_realm == p_ptr->realm2) ?
4107 (p_ptr->spell_learned2 & (1L << spell)) :
4108 (p_ptr->spell_learned1 & (1L << spell)))
4111 return (!study_pray);
4114 /* Okay to study, not to cast */
4121 * Extra information on a spell -DRS-
4123 * We can use up to 14 characters of the buffer 'p'
4125 * The strings in this function were extracted from the code in the
4126 * functions "do_cmd_cast()" and "do_cmd_pray()" and may be dated.
4128 static void spell_info(char *p, int spell, int use_realm)
4130 int plev = p_ptr->lev;
4133 int orb = plev + (plev / ((p_ptr->pclass == CLASS_PRIEST ||
4134 p_ptr->pclass == CLASS_HIGH_MAGE ||
4135 p_ptr->pclass == CLASS_SORCERER) ? 2 : 4));
4137 int burst = plev + (plev / ((p_ptr->pclass == CLASS_MAGE ||
4138 p_ptr->pclass == CLASS_HIGH_MAGE ||
4139 p_ptr->pclass == CLASS_SORCERER) ? 2 : 4));
4141 cptr s_dam = "»½ý:";
4142 cptr s_dur = "´ü´Ö:";
4143 cptr s_range = "ÈÏ°Ï:";
4144 cptr s_heal = "²óÉü:";
4145 cptr s_random = "¥é¥ó¥À¥à";
4146 cptr s_delay = "ÃÙ±ä:";
4148 cptr s_dam = "dam ";
4149 cptr s_dur = "dur ";
4150 cptr s_range = "range ";
4151 cptr s_heal = "heal ";
4152 cptr s_random = "random";
4153 cptr s_delay = "delay ";
4158 /* Analyze the spell */
4161 case REALM_LIFE: /* Life */
4164 case 0: sprintf(p, " %s2d10", s_heal); break;
4165 case 1: sprintf(p, " %s12+d12", s_dur); break;
4166 case 2: sprintf(p, " %s%dd4", s_dam, 3 + ((plev - 1) / 5)); break;
4167 case 3: sprintf(p, " %s%d", s_dam, 10 + (plev / 2)); break;
4168 case 5: sprintf(p, " %s4d10", s_heal); break;
4169 case 9: sprintf(p, " %s%dd8", s_dam, 8 + ((plev - 1) / 5)); break;
4170 case 10: sprintf(p, " %s8d10", s_heal); break;
4171 case 11: sprintf(p, " %s20+d20", s_dur); break;
4172 case 14: sprintf(p, " %s300", s_heal); break;
4173 case 18: sprintf(p, " %sd%d", s_dam, 5 * plev); break;
4174 case 20: sprintf(p, " %s%dd15", s_dam, 5 + ((plev - 1) / 3)); break;
4175 case 21: sprintf(p, " %s15+d21", s_delay); break;
4176 case 29: sprintf(p, " %s2000", s_heal); break;
4177 case 31: sprintf(p, " %s%d+d%d", s_dur,(plev/2), (plev/2)); break;
4181 case REALM_SORCERY: /* Sorcery */
4184 case 1: sprintf(p, " %s10", s_range); break;
4185 case 3: sprintf(p, " %s%d", s_dam, 10 + (plev / 2)); break;
4186 case 5: sprintf(p, " %s%d", s_range, plev * 5); break;
4187 case 13: sprintf(p, " %s%d+d%d", s_dur, plev, plev + 20); break;
4188 case 18: sprintf(p, " %s25+d30", s_dur); break;
4189 case 22: sprintf(p, " %s15+d21", s_delay); break;
4190 case 23: sprintf(p, " %s%d", s_range, plev / 2 + 10); break;
4191 case 25: sprintf(p, " %s7d7+%d", s_dam, plev); break;
4193 case 26: sprintf(p, " ºÇÂç½ÅÎÌ:%d.%dkg", lbtokg1(plev * 15),lbtokg2(plev * 15)); break;
4195 case 26: sprintf(p, " max wgt %d", plev * 15 / 10); break;
4197 case 27: sprintf(p, " %s25+d30", s_dur); break;
4198 case 31: sprintf(p, " %s4+d4", s_dur); break;
4202 case REALM_NATURE: /* Nature */
4206 case 1: sprintf(p, " %s%dd4 ¼ÍÄø%d", s_dam, (3 + ((plev - 1) / 5)), plev/6+2); break;
4208 case 1: sprintf(p, " %s%dd4 rng %d", s_dam, (3 + ((plev - 1) / 5)), plev/6+2); break;
4210 case 4: sprintf(p, " %s%d", s_dam, 10 + (plev / 2)); break;
4211 case 6: sprintf(p, " %s20+d20", s_dur); break;
4212 case 7: sprintf(p, " %s2d8", s_heal); break;
4213 case 9: sprintf(p, " %s%dd8", s_dam, (3 + ((plev - 5) / 4))); break;
4214 case 11: sprintf(p, " %s%dd8", s_dam, (5 + ((plev - 5) / 4))); break;
4215 case 12: sprintf(p, " %s6d8", s_dam); break;
4216 case 15: sprintf(p, " %s500", s_heal); break;
4217 case 17: sprintf(p, " %s20+d30", s_dur); break;
4218 case 18: sprintf(p, " %s20+d20", s_dur); break;
4220 case 24: sprintf(p, " Ⱦ·Â:10"); break;
4222 case 24: sprintf(p, " rad 10"); break;
4224 case 26: sprintf(p, " %s%d", s_dam, 70 + plev * 3 / 2); break;
4225 case 27: sprintf(p, " %s%d", s_dam, 90 + plev * 3 / 2); break;
4226 case 28: sprintf(p, " %s%d", s_dam, 100 + plev * 3 / 2); break;
4227 case 29: sprintf(p, " %s75", s_dam); break;
4228 case 31: sprintf(p, " %s%d+%d", s_dam, 4 * plev, 100 + plev); break;
4232 case REALM_CHAOS: /* Chaos */
4235 case 0: sprintf(p, " %s%dd4", s_dam, 3 + ((plev - 1) / 5)); break;
4236 case 2: sprintf(p, " %s%d", s_dam, 10 + (plev / 2)); break;
4237 case 4: sprintf(p, " %s3d5+%d", s_dam, burst); break;
4238 case 5: sprintf(p, " %s%dd8", s_dam, (6 + ((plev - 5) / 4))); break;
4239 case 6: sprintf(p, " %s%dd8", s_dam, (8 + ((plev - 5) / 4))); break;
4240 case 7: sprintf(p, " %s%d", s_range, plev * 5); break;
4241 case 8: sprintf(p, " %s", s_random); break;
4242 case 9: sprintf(p, " %s%dd8", s_dam, (10 + ((plev - 5) / 4))); break;
4243 case 10: sprintf(p, " %s%d", s_dam, (60 + plev)/2); break;
4244 case 11: sprintf(p, " %s%dd8", s_dam, (11 + ((plev - 5) / 4))); break;
4245 case 12: sprintf(p, " %s%d", s_dam, 55 + plev); break;
4246 case 15: sprintf(p, " %s%d", s_dam, 99 + plev*2); break;
4247 case 17: sprintf(p, " %s%dd8", s_dam, (5 + (plev / 10))); break;
4248 case 19: sprintf(p, " %s%d", s_dam, 70 + plev); break;
4249 case 21: sprintf(p, " %s%d", s_dam, 120 + plev*2); break;
4250 case 24: sprintf(p, " %s%dd8", s_dam, (9 + (plev / 10))); break;
4252 case 25: sprintf(p, " %s³Æ%d", s_dam, plev * 2); break;
4254 case 25: sprintf(p, " dam %d each", plev * 2); break;
4256 case 26: sprintf(p, " %s%d", s_dam, 150 + plev*3/2); break;
4257 case 27: sprintf(p, " %s150 / 250", s_dam); break;
4258 case 29: sprintf(p, " %s%d", s_dam, 300 + (plev * 4)); break;
4259 case 30: sprintf(p, " %s%d", s_dam, p_ptr->chp); break;
4260 case 31: sprintf(p, " %s3 * 175", s_dam); break;
4264 case REALM_DEATH: /* Death */
4267 case 1: sprintf(p, " %s%dd3", s_dam, (3 + ((plev - 1) / 5))); break;
4268 case 3: sprintf(p, " %s%d", s_dam, 10 + (plev / 2)); break;
4269 case 5: sprintf(p, " %s20+d20", s_dur); break;
4270 case 8: sprintf(p, " %s3d6+%d", s_dam, burst); break;
4271 case 9: sprintf(p, " %s%dd8", s_dam, (8 + ((plev - 5) / 4))); break;
4272 case 10: sprintf(p, " %s%d", s_dam, 30+plev); break;
4274 case 13: sprintf(p, " »:%d+d%d", plev * 2, plev * 2); break;
4276 case 13: sprintf(p, " d %d+d%d", plev * 2, plev * 2); break;
4278 case 16: sprintf(p, " %s25+d25", s_dur); break;
4279 case 17: sprintf(p, " %s", s_random); break;
4280 case 18: sprintf(p, " %s%dd8", s_dam, (4 + ((plev - 5) / 4))); break;
4281 case 19: sprintf(p, " %s25+d25", s_dur); break;
4282 case 21: sprintf(p, " %s3*100", s_dam); break;
4283 case 22: sprintf(p, " %sd%d", s_dam, plev * 3); break;
4284 case 23: sprintf(p, " %s%d", s_dam, 100 + plev * 2); break;
4285 case 27: sprintf(p, " %s%d+d%d", s_dur,10+plev/2, 10+plev/2); break;
4286 case 30: sprintf(p, " %s666", s_dam); break;
4287 case 31: sprintf(p, " %s%d+d%d", s_dur, (plev / 2), (plev / 2)); break;
4291 case REALM_TRUMP: /* Trump */
4294 case 0: sprintf(p, " %s10", s_range); break;
4295 case 2: sprintf(p, " %s", s_random); break;
4296 case 4: sprintf(p, " %s%d", s_range, plev * 4); break;
4297 case 5: sprintf(p, " %s25+d30", s_dur); break;
4299 case 8: sprintf(p, " ºÇÂç½ÅÎÌ:%d.%d", lbtokg1(plev * 15 / 10),lbtokg2(plev * 15 / 10)); break;
4301 case 8: sprintf(p, " max wgt %d", plev * 15 / 10); break;
4303 case 13: sprintf(p, " %s%d", s_range, plev / 2 + 10); break;
4304 case 14: sprintf(p, " %s15+d21", s_delay); break;
4305 case 26: sprintf(p, " %s%d", s_heal, plev * 10 + 200); break;
4307 case 28: sprintf(p, " %s³Æ%d", s_dam, plev * 2); break;
4309 case 28: sprintf(p, " %s%d each", s_dam, plev * 2); break;
4314 case REALM_ARCANE: /* Arcane */
4317 case 0: sprintf(p, " %s%dd3", s_dam, 3 + ((plev - 1) / 5)); break;
4318 case 4: sprintf(p, " %s10", s_range); break;
4319 case 5: sprintf(p, " %s2d%d", s_dam, plev / 2); break;
4320 case 7: sprintf(p, " %s2d8", s_heal); break;
4324 case 17: sprintf(p, " %s20+d20", s_dur); break;
4325 case 18: sprintf(p, " %s4d8", s_heal); break;
4326 case 19: sprintf(p, " %s%d", s_range, plev * 5); break;
4327 case 21: sprintf(p, " %s6d8", s_dam); break;
4328 case 24: sprintf(p, " %s24+d24", s_dur); break;
4329 case 28: sprintf(p, " %s%d", s_dam, 75 + plev); break;
4330 case 30: sprintf(p, " %s15+d21", s_delay); break;
4331 case 31: sprintf(p, " %s25+d30", s_dur); break;
4335 case REALM_ENCHANT: /* Craft */
4338 case 0: sprintf(p, " %s100+d100", s_dur); break;
4339 case 1: sprintf(p, " %s80+d80", s_dur); break;
4345 case 18: sprintf(p, " %s20+d20", s_dur); break;
4346 case 5: sprintf(p, " %s25+d25", s_dur); break;
4347 case 8: sprintf(p, " %s24+d24", s_dur); break;
4348 case 11: sprintf(p, " %s25+d25", s_dur); break;
4349 case 13: sprintf(p, " %s%d+d25", s_dur, plev * 3); break;
4350 case 15: sprintf(p, " %s%d+d%d", s_dur, plev/2, plev/2); break;
4351 case 16: sprintf(p, " %s25+d30", s_dur); break;
4352 case 17: sprintf(p, " %s30+d20", s_dur); break;
4353 case 19: sprintf(p, " %s%d+d%d", s_dur, plev+20, plev); break;
4354 case 20: sprintf(p, " %s50+d50", s_dur); break;
4355 case 23: sprintf(p, " %s20+d20", s_dur); break;
4356 case 31: sprintf(p, " %s13+d13", s_dur); break;
4360 case REALM_DAEMON: /* Daemon */
4363 case 0: sprintf(p, " %s%dd4", s_dam, 3 + ((plev - 1) / 5)); break;
4364 case 2: sprintf(p, " %s12+d12", s_dur); break;
4365 case 3: sprintf(p, " %s20+d20", s_dur); break;
4366 case 5: sprintf(p, " %s%dd8", s_dam, (6 + ((plev - 5) / 4))); break;
4367 case 7: sprintf(p, " %s3d6+%d", s_dam, burst); break;
4368 case 10: sprintf(p, " %s20+d20", s_dur); break;
4369 case 11: sprintf(p, " %s%dd8", s_dam, (11 + ((plev - 5) / 4))); break;
4370 case 12: sprintf(p, " %s%d", s_dam, 55 + plev); break;
4371 case 14: sprintf(p, " %s%d", s_dam, 100 + plev*3/2); break;
4372 case 16: sprintf(p, " %s30+d25", s_dur); break;
4373 case 17: sprintf(p, " %s20+d20", s_dur); break;
4374 case 18: sprintf(p, " %s%d", s_dam, 55 + plev); break;
4375 case 19: sprintf(p, " %s%d", s_dam, 80 + plev*3/2); break;
4376 case 20: sprintf(p, " %s%d+d%d", s_dur,10+plev/2, 10+plev/2); break;
4377 case 21: sprintf(p, " %sd%d+d%d", s_dam, 2 * plev, 2 * plev); break;
4378 case 22: sprintf(p, " %s%d", s_dam, 100 + plev*2); break;
4379 case 24: sprintf(p, " %s25+d25", s_dur); break;
4380 case 25: sprintf(p, " %s20+d20", s_dur); break;
4381 case 26: sprintf(p, " %s%d+%d", s_dam, 25+plev/2, 25+plev/2); break;
4382 case 29: sprintf(p, " %s%d", s_dam, plev*15); break;
4383 case 30: sprintf(p, " %s600", s_dam); break;
4384 case 31: sprintf(p, " %s15+d15", s_dur); break;
4388 case REALM_CRUSADE: /* Crusade */
4391 case 0: sprintf(p, " %s%dd4", s_dam, 3 + ((plev - 1) / 5)); break;
4392 case 5: sprintf(p, " %s%d", s_range, 25+plev/2); break;
4394 case 6: sprintf(p, " %s³Æ%dd2", s_dam, 3+((plev-1)/9)); break;
4396 case 6: sprintf(p, " %s%dd2 each", s_dam, 3+((plev-1)/9)); break;
4398 case 9: sprintf(p, " %s3d6+%d", s_dam, orb); break;
4399 case 10: sprintf(p, " %sd%d", s_dam, plev); break;
4400 case 12: sprintf(p, " %s24+d24", s_dur); break;
4401 case 13: sprintf(p, " %sd25+%d", s_dur, 3 * plev); break;
4402 case 14: sprintf(p, " %s%d", s_dam, plev*5); break;
4404 case 15: sprintf(p, " »:d%d/²ó:100", 6 * plev); break;
4406 case 15: sprintf(p, " dam:d%d/h100", 6 * plev); break;
4408 case 18: sprintf(p, " %s18+d18", s_dur); break;
4409 case 19: sprintf(p, " %sd%d", s_dam, 4 * plev); break;
4410 case 20: sprintf(p, " %sd%d", s_dam, 4 * plev); break;
4411 case 22: sprintf(p, " %s%d", s_dam, 2 * plev+100); break;
4412 case 24: sprintf(p, " %s25+d25", s_dur); break;
4413 case 28: sprintf(p, " %s10+d10", s_dur); break;
4415 case 29: sprintf(p, " %s³Æ%d", s_dam, plev*3+25); break;
4417 case 29: sprintf(p, " %s%d each", s_dam, plev*3+25); break;
4420 case 30: sprintf(p, " ²ó100/»%d+%d", plev * 4, plev*11/2); break;
4422 case 30: sprintf(p, " h100/dm%d+%d", plev * 4, plev*11/2); break;
4427 case REALM_MUSIC: /* Music */
4430 case 2 : sprintf(p, " %s%dd4", s_dam, 4 + ((plev - 1) / 5)); break;
4431 case 4 : sprintf(p, " %s2d6", s_heal); break;
4432 case 9 : sprintf(p, " %sd%d", s_dam, plev * 3 / 2); break;
4433 case 13: sprintf(p, " %s%dd7", s_dam, 10 + (plev / 5)); break;
4434 case 20: sprintf(p, " %sd%d+d%d", s_dam, plev * 3, plev * 3); break;
4435 case 22: sprintf(p, " %s%dd10", s_dam, 15 + ((plev - 1) / 2)); break;
4436 case 27: sprintf(p, " %sd%d", s_dam, plev * 3); break;
4437 case 28: sprintf(p, " %s15d10", s_heal); break;
4438 case 30: sprintf(p, " %s%dd10", s_dam, 50 + plev); break;
4443 sprintf(p, "̤ÃΤΥ¿¥¤¥×: %d", use_realm);
4445 sprintf(p, "Unknown type: %d.", use_realm);
4452 * Print a list of spells (for browsing or casting or viewing)
4454 void print_spells(int target_spell, byte *spells, int num, int y, int x, int use_realm)
4456 int i, spell, shougou, increment = 64;
4468 if (((use_realm <= REALM_NONE) || (use_realm > MAX_REALM)) && p_ptr->wizard)
4470 msg_print("·Ù¹ð¡ª print_spell ¤¬Îΰè¤Ê¤·¤Ë¸Æ¤Ð¤ì¤¿");
4472 msg_print("Warning! print_spells called with null realm");
4476 /* Title the list */
4478 if (use_realm == REALM_HISSATSU)
4480 strcpy(buf," Lv MP");
4482 strcpy(buf," Lv SP");
4486 strcpy(buf,"½ÏÎýÅÙ Lv MP ¼ºÎ¨ ¸ú²Ì");
4488 strcpy(buf,"Profic Lv SP Fail Effect");
4492 put_str("̾Á°", y, x + 5);
4493 put_str(buf, y, x + 29);
4495 put_str("Name", y, x + 5);
4496 put_str(buf, y, x + 29);
4499 if ((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE)) increment = 0;
4500 else if (use_realm == p_ptr->realm1) increment = 0;
4501 else if (use_realm == p_ptr->realm2) increment = 32;
4503 /* Dump the spells */
4504 for (i = 0; i < num; i++)
4506 /* Access the spell */
4509 /* Access the spell */
4510 if (!is_magic(use_realm))
4512 s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
4516 s_ptr = &mp_ptr->info[use_realm - 1][spell];
4519 if (use_realm == REALM_HISSATSU)
4520 shouhimana = s_ptr->smana;
4523 s16b exp = experience_of_spell(spell, use_realm);
4525 /* Extract mana consumption rate */
4526 shouhimana = s_ptr->smana*(3800 - exp) + 2399;
4528 if(p_ptr->dec_mana) shouhimana *= 3;
4529 else shouhimana *= 4;
4532 if(shouhimana < 1) shouhimana = 1;
4534 if ((increment == 64) || (s_ptr->slevel >= 99)) shougou = 0;
4535 else if (exp < 900) shougou = 0;
4536 else if (exp < 1200) shougou = 1;
4537 else if (exp < 1400) shougou = 2;
4538 else if (exp < 1600) shougou = 3;
4542 if (!increment && (shougou == 4)) max = TRUE;
4543 else if ((increment == 32) && (shougou == 3)) max = TRUE;
4544 else if (s_ptr->slevel >= 99) max = TRUE;
4545 else if (p_ptr->pclass == CLASS_RED_MAGE) max = TRUE;
4547 strncpy(ryakuji,shougou_moji[shougou],4);
4552 if (use_menu && target_spell)
4554 if (i == (target_spell-1))
4556 strcpy(out_val, " ¡Õ ");
4558 strcpy(out_val, " > ");
4561 strcpy(out_val, " ");
4563 else sprintf(out_val, " %c) ", I2A(i));
4564 /* Skip illegible spells */
4565 if (s_ptr->slevel >= 99)
4568 strcat(out_val, format("%-30s", "(ȽÆÉÉÔǽ)"));
4570 strcat(out_val, format("%-30s", "(illegible)"));
4573 c_prt(TERM_L_DARK, out_val, y + i + 1, x);
4577 /* XXX XXX Could label spells above the players level */
4579 /* Get extra info */
4580 spell_info(info, spell, use_realm);
4585 /* Assume spell is known and tried */
4586 line_attr = TERM_WHITE;
4588 /* Analyze the spell */
4589 if ((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE))
4591 if (s_ptr->slevel > p_ptr->max_plv)
4596 comment = " unknown";
4599 line_attr = TERM_L_BLUE;
4601 else if (s_ptr->slevel > p_ptr->lev)
4606 comment = " forgotten";
4609 line_attr = TERM_YELLOW;
4612 else if ((use_realm != p_ptr->realm1) && (use_realm != p_ptr->realm2))
4617 comment = " unknown";
4620 line_attr = TERM_L_BLUE;
4622 else if ((use_realm == p_ptr->realm1) ?
4623 ((p_ptr->spell_forgotten1 & (1L << spell))) :
4624 ((p_ptr->spell_forgotten2 & (1L << spell))))
4629 comment = " forgotten";
4632 line_attr = TERM_YELLOW;
4634 else if (!((use_realm == p_ptr->realm1) ?
4635 (p_ptr->spell_learned1 & (1L << spell)) :
4636 (p_ptr->spell_learned2 & (1L << spell))))
4641 comment = " unknown";
4644 line_attr = TERM_L_BLUE;
4646 else if (!((use_realm == p_ptr->realm1) ?
4647 (p_ptr->spell_worked1 & (1L << spell)) :
4648 (p_ptr->spell_worked2 & (1L << spell))))
4651 comment = " ̤·Ð¸³";
4653 comment = " untried";
4656 line_attr = TERM_L_GREEN;
4659 /* Dump the spell --(-- */
4660 if (use_realm == REALM_HISSATSU)
4662 strcat(out_val, format("%-25s %2d %4d",
4663 spell_names[technic2magic(use_realm)-1][spell], /* realm, spell */
4664 s_ptr->slevel, shouhimana));
4668 strcat(out_val, format("%-25s%c%-4s %2d %4d %3d%%%s",
4669 spell_names[technic2magic(use_realm)-1][spell], /* realm, spell */
4670 (max ? '!' : ' '), ryakuji,
4671 s_ptr->slevel, shouhimana, spell_chance(spell, use_realm), comment));
4673 c_prt(line_attr, out_val, y + i + 1, x);
4676 /* Clear the bottom line */
4677 prt("", y + i + 1, x);
4682 * Note that amulets, rods, and high-level spell books are immune
4683 * to "inventory damage" of any kind. Also sling ammo and shovels.
4688 * Does a given class of objects (usually) hate acid?
4689 * Note that acid can either melt or corrode something.
4691 bool hates_acid(object_type *o_ptr)
4693 /* Analyze the type */
4694 switch (o_ptr->tval)
4696 /* Wearable items */
4716 /* Staffs/Scrolls are wood/paper */
4729 /* Junk is useless */
4743 * Does a given object (usually) hate electricity?
4745 bool hates_elec(object_type *o_ptr)
4747 switch (o_ptr->tval)
4761 * Does a given object (usually) hate fire?
4762 * Hafted/Polearm weapons have wooden shafts.
4763 * Arrows/Bows are mostly wooden.
4765 bool hates_fire(object_type *o_ptr)
4767 /* Analyze the type */
4768 switch (o_ptr->tval)
4786 case TV_SORCERY_BOOK:
4787 case TV_NATURE_BOOK:
4791 case TV_ARCANE_BOOK:
4792 case TV_ENCHANT_BOOK:
4793 case TV_DAEMON_BOOK:
4794 case TV_CRUSADE_BOOK:
4796 case TV_HISSATSU_BOOK:
4807 /* Staffs/Scrolls burn */
4820 * Does a given object (usually) hate cold?
4822 bool hates_cold(object_type *o_ptr)
4824 switch (o_ptr->tval)
4841 int set_acid_destroy(object_type *o_ptr)
4843 u32b flgs[TR_FLAG_SIZE];
4844 if (!hates_acid(o_ptr)) return (FALSE);
4845 object_flags(o_ptr, flgs);
4846 if (have_flag(flgs, TR_IGNORE_ACID)) return (FALSE);
4854 int set_elec_destroy(object_type *o_ptr)
4856 u32b flgs[TR_FLAG_SIZE];
4857 if (!hates_elec(o_ptr)) return (FALSE);
4858 object_flags(o_ptr, flgs);
4859 if (have_flag(flgs, TR_IGNORE_ELEC)) return (FALSE);
4867 int set_fire_destroy(object_type *o_ptr)
4869 u32b flgs[TR_FLAG_SIZE];
4870 if (!hates_fire(o_ptr)) return (FALSE);
4871 object_flags(o_ptr, flgs);
4872 if (have_flag(flgs, TR_IGNORE_FIRE)) return (FALSE);
4880 int set_cold_destroy(object_type *o_ptr)
4882 u32b flgs[TR_FLAG_SIZE];
4883 if (!hates_cold(o_ptr)) return (FALSE);
4884 object_flags(o_ptr, flgs);
4885 if (have_flag(flgs, TR_IGNORE_COLD)) return (FALSE);
4891 * Destroys a type of item on a given percent chance
4892 * Note that missiles are no longer necessarily all destroyed
4893 * Destruction taken from "melee.c" code for "stealing".
4894 * New-style wands and rods handled correctly. -LM-
4895 * Returns number of items destroyed.
4897 int inven_damage(inven_func typ, int perc)
4901 char o_name[MAX_NLEN];
4903 /* Multishadow effects is determined by turn */
4904 if( p_ptr->multishadow && (turn & 1) )return 0;
4906 if (p_ptr->inside_arena) return 0;
4908 /* Count the casualties */
4911 /* Scan through the slots backwards */
4912 for (i = 0; i < INVEN_PACK; i++)
4914 o_ptr = &inventory[i];
4916 /* Skip non-objects */
4917 if (!o_ptr->k_idx) continue;
4919 /* Hack -- for now, skip artifacts */
4920 if (artifact_p(o_ptr) || o_ptr->art_name) continue;
4922 /* Give this item slot a shot at death */
4925 /* Count the casualties */
4926 for (amt = j = 0; j < o_ptr->number; ++j)
4928 if (randint0(100) < perc) amt++;
4931 /* Some casualities */
4934 /* Get a description */
4935 object_desc(o_name, o_ptr, FALSE, 3);
4939 msg_format("%s(%c)¤¬%s²õ¤ì¤Æ¤·¤Þ¤Ã¤¿¡ª",
4941 msg_format("%sour %s (%c) %s destroyed!",
4945 o_name, index_to_label(i),
4946 ((o_ptr->number > 1) ?
4947 ((amt == o_ptr->number) ? "Á´Éô" :
4948 (amt > 1 ? "²¿¸Ä¤«" : "°ì¸Ä")) : "") );
4950 ((o_ptr->number > 1) ?
4951 ((amt == o_ptr->number) ? "All of y" :
4952 (amt > 1 ? "Some of y" : "One of y")) : "Y"),
4953 o_name, index_to_label(i),
4954 ((amt > 1) ? "were" : "was"));
4958 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
4959 msg_print("¤ä¤ê¤ä¤¬¤Ã¤¿¤Ê¡ª");
4962 /* Potions smash open */
4963 if (object_is_potion(o_ptr))
4965 (void)potion_smash_effect(0, py, px, o_ptr->k_idx);
4968 /* Reduce the charges of rods/wands */
4969 reduce_charges(o_ptr, amt);
4971 /* Destroy "amt" items */
4972 inven_item_increase(i, -amt);
4973 inven_item_optimize(i);
4975 /* Count the casualties */
4981 /* Return the casualty count */
4987 * Acid has hit the player, attempt to affect some armor.
4989 * Note that the "base armor" of an object never changes.
4991 * If any armor is damaged (or resists), the player takes less damage.
4993 static int minus_ac(void)
4995 object_type *o_ptr = NULL;
4996 u32b flgs[TR_FLAG_SIZE];
4997 char o_name[MAX_NLEN];
5000 /* Pick a (possibly empty) inventory slot */
5001 switch (randint1(7))
5003 case 1: o_ptr = &inventory[INVEN_RARM]; break;
5004 case 2: o_ptr = &inventory[INVEN_LARM]; break;
5005 case 3: o_ptr = &inventory[INVEN_BODY]; break;
5006 case 4: o_ptr = &inventory[INVEN_OUTER]; break;
5007 case 5: o_ptr = &inventory[INVEN_HANDS]; break;
5008 case 6: o_ptr = &inventory[INVEN_HEAD]; break;
5009 case 7: o_ptr = &inventory[INVEN_FEET]; break;
5012 /* Nothing to damage */
5013 if (!o_ptr->k_idx) return (FALSE);
5015 if (o_ptr->tval < TV_BOOTS) return (FALSE);
5017 /* No damage left to be done */
5018 if (o_ptr->ac + o_ptr->to_a <= 0) return (FALSE);
5022 object_desc(o_name, o_ptr, FALSE, 0);
5024 /* Extract the flags */
5025 object_flags(o_ptr, flgs);
5027 /* Object resists */
5028 if (have_flag(flgs, TR_IGNORE_ACID))
5031 msg_format("¤·¤«¤·%s¤Ë¤Ï¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡ª", o_name);
5033 msg_format("Your %s is unaffected!", o_name);
5042 msg_format("%s¤¬¥À¥á¡¼¥¸¤ò¼õ¤±¤¿¡ª", o_name);
5044 msg_format("Your %s is damaged!", o_name);
5048 /* Damage the item */
5051 /* Calculate bonuses */
5052 p_ptr->update |= (PU_BONUS);
5055 p_ptr->window |= (PW_EQUIP | PW_PLAYER);
5059 /* Item was damaged */
5065 * Hurt the player with Acid
5067 int acid_dam(int dam, cptr kb_str, int monspell)
5070 int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
5071 bool double_resist = (p_ptr->oppose_acid || music_singing(MUSIC_RESIST) || (p_ptr->special_defense & KATA_MUSOU));
5073 /* Total Immunity */
5074 if (p_ptr->immune_acid || (dam <= 0))
5076 learn_spell(monspell);
5080 /* Vulnerability (Ouch!) */
5081 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
5082 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
5084 /* Resist the damage */
5085 if (p_ptr->resist_acid) dam = (dam + 2) / 3;
5086 if (double_resist) dam = (dam + 2) / 3;
5088 if ((!(double_resist || p_ptr->resist_acid)) &&
5089 one_in_(HURT_CHANCE))
5090 (void)do_dec_stat(A_CHR);
5092 /* If any armor gets hit, defend the player */
5093 if (minus_ac()) dam = (dam + 1) / 2;
5096 get_damage=take_hit(DAMAGE_ATTACK, dam, kb_str, monspell);
5098 /* Inventory damage */
5099 if (!(double_resist && p_ptr->resist_acid))
5100 inven_damage(set_acid_destroy, inv);
5106 * Hurt the player with electricity
5108 int elec_dam(int dam, cptr kb_str, int monspell)
5111 int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
5112 bool double_resist = (p_ptr->oppose_elec || music_singing(MUSIC_RESIST) || (p_ptr->special_defense & KATA_MUSOU));
5114 /* Total immunity */
5115 if (p_ptr->immune_elec || (dam <= 0))
5117 learn_spell(monspell);
5121 /* Vulnerability (Ouch!) */
5122 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
5123 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
5124 if (p_ptr->prace == RACE_ANDROID) dam += dam / 3;
5126 /* Resist the damage */
5127 if (p_ptr->resist_elec) dam = (dam + 2) / 3;
5128 if (double_resist) dam = (dam + 2) / 3;
5130 if ((!(double_resist || p_ptr->resist_elec)) &&
5131 one_in_(HURT_CHANCE))
5132 (void)do_dec_stat(A_DEX);
5135 get_damage=take_hit(DAMAGE_ATTACK, dam, kb_str, monspell);
5137 /* Inventory damage */
5138 if (!(double_resist && p_ptr->resist_elec))
5139 inven_damage(set_elec_destroy, inv);
5146 * Hurt the player with Fire
5148 int fire_dam(int dam, cptr kb_str, int monspell)
5151 int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
5152 bool double_resist = (p_ptr->oppose_fire || music_singing(MUSIC_RESIST) || (p_ptr->special_defense & KATA_MUSOU));
5154 /* Totally immune */
5155 if (p_ptr->immune_fire || (dam <= 0))
5157 learn_spell(monspell);
5161 /* Vulnerability (Ouch!) */
5162 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
5163 if (prace_is_(RACE_ENT)) dam += dam / 3;
5164 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
5166 /* Resist the damage */
5167 if (p_ptr->resist_fire) dam = (dam + 2) / 3;
5168 if (double_resist) dam = (dam + 2) / 3;
5170 if ((!(double_resist || p_ptr->resist_fire)) &&
5171 one_in_(HURT_CHANCE))
5172 (void)do_dec_stat(A_STR);
5175 get_damage=take_hit(DAMAGE_ATTACK, dam, kb_str, monspell);
5177 /* Inventory damage */
5178 if (!(double_resist && p_ptr->resist_fire))
5179 inven_damage(set_fire_destroy, inv);
5186 * Hurt the player with Cold
5188 int cold_dam(int dam, cptr kb_str, int monspell)
5191 int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
5192 bool double_resist = (p_ptr->oppose_cold || music_singing(MUSIC_RESIST) || (p_ptr->special_defense & KATA_MUSOU));
5194 /* Total immunity */
5195 if (p_ptr->immune_cold || (dam <= 0))
5197 learn_spell(monspell);
5201 /* Vulnerability (Ouch!) */
5202 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
5203 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
5205 /* Resist the damage */
5206 if (p_ptr->resist_cold) dam = (dam + 2) / 3;
5207 if (double_resist) dam = (dam + 2) / 3;
5209 if ((!(double_resist || p_ptr->resist_cold)) &&
5210 one_in_(HURT_CHANCE))
5211 (void)do_dec_stat(A_STR);
5214 get_damage=take_hit(DAMAGE_ATTACK, dam, kb_str, monspell);
5216 /* Inventory damage */
5217 if (!(double_resist && p_ptr->resist_cold))
5218 inven_damage(set_cold_destroy, inv);
5224 bool rustproof(void)
5228 char o_name[MAX_NLEN];
5231 item_tester_no_ryoute = TRUE;
5232 /* Select a piece of armour */
5233 item_tester_hook = item_tester_hook_armour;
5237 q = "¤É¤ÎËɶñ¤Ë»¬»ß¤á¤ò¤·¤Þ¤¹¤«¡©";
5238 s = "»¬»ß¤á¤Ç¤¤ë¤â¤Î¤¬¤¢¤ê¤Þ¤»¤ó¡£";
5240 q = "Rustproof which piece of armour? ";
5241 s = "You have nothing to rustproof.";
5244 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return FALSE;
5246 /* Get the item (in the pack) */
5249 o_ptr = &inventory[item];
5252 /* Get the item (on the floor) */
5255 o_ptr = &o_list[0 - item];
5260 object_desc(o_name, o_ptr, FALSE, 0);
5262 add_flag(o_ptr->art_flags, TR_IGNORE_ACID);
5264 if ((o_ptr->to_a < 0) && !cursed_p(o_ptr))
5267 msg_format("%s¤Ï¿·ÉÊƱÍͤˤʤä¿¡ª",o_name);
5269 msg_format("%s %s look%s as good as new!",
5270 ((item >= 0) ? "Your" : "The"), o_name,
5271 ((o_ptr->number > 1) ? "" : "s"));
5278 msg_format("%s¤ÏÉå¿©¤·¤Ê¤¯¤Ê¤Ã¤¿¡£", o_name);
5280 msg_format("%s %s %s now protected against corrosion.",
5281 ((item >= 0) ? "Your" : "The"), o_name,
5282 ((o_ptr->number > 1) ? "are" : "is"));
5293 * Curse the players armor
5295 bool curse_armor(void)
5300 char o_name[MAX_NLEN];
5303 /* Curse the body armor */
5304 o_ptr = &inventory[INVEN_BODY];
5306 /* Nothing to curse */
5307 if (!o_ptr->k_idx) return (FALSE);
5311 object_desc(o_name, o_ptr, FALSE, 3);
5313 /* Attempt a saving throw for artifacts */
5314 if ((o_ptr->art_name || artifact_p(o_ptr)) && (randint0(100) < 50))
5318 msg_format("%s¤¬%s¤òÊñ¤ß¹þ¤â¤¦¤È¤·¤¿¤¬¡¢%s¤Ï¤½¤ì¤òÄ·¤ÍÊÖ¤·¤¿¡ª",
5319 "¶²ÉݤΰŹõ¥ª¡¼¥é", "Ëɶñ", o_name);
5321 msg_format("A %s tries to %s, but your %s resists the effects!",
5322 "terrible black aura", "surround your armor", o_name);
5327 /* not artifact or failed save... */
5332 msg_format("¶²ÉݤΰŹõ¥ª¡¼¥é¤¬¤¢¤Ê¤¿¤Î%s¤òÊñ¤ß¹þ¤ó¤À¡ª", o_name);
5334 msg_format("A terrible black aura blasts your %s!", o_name);
5337 chg_virtue(V_ENCHANT, -5);
5339 /* Blast the armor */
5341 o_ptr->name2 = EGO_BLASTED;
5342 o_ptr->to_a = 0 - randint1(5) - randint1(5);
5349 for (i = 0; i < TR_FLAG_SIZE; i++)
5350 o_ptr->art_flags[i] = 0;
5353 o_ptr->curse_flags = TRC_CURSED;
5356 o_ptr->ident |= (IDENT_BROKEN);
5358 /* Recalculate bonuses */
5359 p_ptr->update |= (PU_BONUS);
5361 /* Recalculate mana */
5362 p_ptr->update |= (PU_MANA);
5365 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
5373 * Curse the players weapon
5375 bool curse_weapon(bool force, int slot)
5381 char o_name[MAX_NLEN];
5384 /* Curse the weapon */
5385 o_ptr = &inventory[slot];
5387 /* Nothing to curse */
5388 if (!o_ptr->k_idx) return (FALSE);
5392 object_desc(o_name, o_ptr, FALSE, 3);
5394 /* Attempt a saving throw */
5395 if ((artifact_p(o_ptr) || o_ptr->art_name) && (randint0(100) < 50) && !force)
5399 msg_format("%s¤¬%s¤òÊñ¤ß¹þ¤â¤¦¤È¤·¤¿¤¬¡¢%s¤Ï¤½¤ì¤òÄ·¤ÍÊÖ¤·¤¿¡ª",
5400 "¶²ÉݤΰŹõ¥ª¡¼¥é", "Éð´ï", o_name);
5402 msg_format("A %s tries to %s, but your %s resists the effects!",
5403 "terrible black aura", "surround your weapon", o_name);
5408 /* not artifact or failed save... */
5413 if (!force) msg_format("¶²ÉݤΰŹõ¥ª¡¼¥é¤¬¤¢¤Ê¤¿¤Î%s¤òÊñ¤ß¹þ¤ó¤À¡ª", o_name);
5415 if (!force) msg_format("A terrible black aura blasts your %s!", o_name);
5418 chg_virtue(V_ENCHANT, -5);
5420 /* Shatter the weapon */
5422 o_ptr->name2 = EGO_SHATTERED;
5423 o_ptr->to_h = 0 - randint1(5) - randint1(5);
5424 o_ptr->to_d = 0 - randint1(5) - randint1(5);
5430 for (i = 0; i < TR_FLAG_SIZE; i++)
5431 o_ptr->art_flags[i] = 0;
5435 o_ptr->curse_flags = TRC_CURSED;
5438 o_ptr->ident |= (IDENT_BROKEN);
5440 /* Recalculate bonuses */
5441 p_ptr->update |= (PU_BONUS);
5443 /* Recalculate mana */
5444 p_ptr->update |= (PU_MANA);
5447 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
5456 * Enchant some bolts
5458 bool brand_bolts(void)
5462 /* Use the first acceptable bolts */
5463 for (i = 0; i < INVEN_PACK; i++)
5465 object_type *o_ptr = &inventory[i];
5467 /* Skip non-bolts */
5468 if (o_ptr->tval != TV_BOLT) continue;
5470 /* Skip artifacts and ego-items */
5471 if (o_ptr->art_name || artifact_p(o_ptr) || ego_item_p(o_ptr))
5474 /* Skip cursed/broken items */
5475 if (cursed_p(o_ptr) || broken_p(o_ptr)) continue;
5478 if (randint0(100) < 75) continue;
5482 msg_print("¥¯¥í¥¹¥Ü¥¦¤ÎÌ𤬱ê¤Î¥ª¡¼¥é¤ËÊñ¤Þ¤ì¤¿¡ª");
5484 msg_print("Your bolts are covered in a fiery aura!");
5489 o_ptr->name2 = EGO_FLAME;
5492 enchant(o_ptr, randint0(3) + 4, ENCH_TOHIT | ENCH_TODAM);
5499 if (flush_failure) flush();
5503 msg_print("±ê¤Ç¶¯²½¤¹¤ë¤Î¤Ë¼ºÇÔ¤·¤¿¡£");
5505 msg_print("The fiery enchantment failed.");
5515 * Helper function -- return a "nearby" race for polymorphing
5517 * Note that this function is one of the more "dangerous" ones...
5519 static s16b poly_r_idx(int r_idx)
5521 monster_race *r_ptr = &r_info[r_idx];
5523 int i, r, lev1, lev2;
5525 /* Hack -- Uniques/Questors never polymorph */
5526 if ((r_ptr->flags1 & RF1_UNIQUE) ||
5527 (r_ptr->flags1 & RF1_QUESTOR))
5530 /* Allowable range of "levels" for resulting monster */
5531 lev1 = r_ptr->level - ((randint1(20) / randint1(9)) + 1);
5532 lev2 = r_ptr->level + ((randint1(20) / randint1(9)) + 1);
5534 /* Pick a (possibly new) non-unique race */
5535 for (i = 0; i < 1000; i++)
5537 /* Pick a new race, using a level calculation */
5538 r = get_mon_num((dun_level + r_ptr->level) / 2 + 5);
5540 /* Handle failure */
5546 /* Ignore unique monsters */
5547 if (r_ptr->flags1 & RF1_UNIQUE) continue;
5549 /* Ignore monsters with incompatible levels */
5550 if ((r_ptr->level < lev1) || (r_ptr->level > lev2)) continue;
5552 /* Use that index */
5564 bool polymorph_monster(int y, int x)
5566 cave_type *c_ptr = &cave[y][x];
5567 monster_type *m_ptr = &m_list[c_ptr->m_idx];
5568 bool polymorphed = FALSE;
5570 int old_r_idx = m_ptr->r_idx;
5571 bool targeted = (target_who == c_ptr->m_idx) ? TRUE : FALSE;
5572 bool health_tracked = (p_ptr->health_who == c_ptr->m_idx) ? TRUE : FALSE;
5573 monster_type back_m;
5575 if (p_ptr->inside_arena || p_ptr->inside_battle) return (FALSE);
5577 if ((p_ptr->riding == c_ptr->m_idx) || (m_ptr->mflag2 & MFLAG_KAGE)) return (FALSE);
5579 /* Memorize the monster before polymorphing */
5582 /* Pick a "new" monster race */
5583 new_r_idx = poly_r_idx(old_r_idx);
5585 /* Handle polymorph */
5586 if (new_r_idx != old_r_idx)
5590 /* Get the monsters attitude */
5591 if (is_friendly(m_ptr)) mode |= PM_FORCE_FRIENDLY;
5592 if (is_pet(m_ptr)) mode |= PM_FORCE_PET;
5593 if (m_ptr->mflag2 & MFLAG_NOPET) mode |= PM_NO_PET;
5595 /* "Kill" the "old" monster */
5596 delete_monster_idx(c_ptr->m_idx);
5598 /* Create a new monster (no groups) */
5599 if (place_monster_aux(0, y, x, new_r_idx, mode))
5606 /* Placing the new monster failed */
5607 if (place_monster_aux(0, y, x, old_r_idx, (mode | PM_NO_KAGE | PM_IGNORE_TERRAIN)))
5608 m_list[hack_m_idx_ii] = back_m;
5611 if (targeted) target_who = hack_m_idx_ii;
5612 if (health_tracked) health_track(hack_m_idx_ii);
5622 bool dimension_door(void)
5624 int plev = p_ptr->lev;
5627 if (!tgt_pt(&x, &y)) return FALSE;
5629 p_ptr->energy_need += (s16b)((s32b)(60 - plev) * ENERGY_NEED() / 100L);
5631 if (!cave_empty_bold(y, x) || (cave[y][x].info & CAVE_ICKY) ||
5632 (distance(y, x, py, px) > plev / 2 + 10) ||
5633 (!randint0(plev / 10 + 10)))
5635 if( p_ptr->pclass != CLASS_MIRROR_MASTER ){
5637 msg_print("ÀºÎ¤«¤éʪ¼Á³¦¤ËÌá¤ë»þ¤¦¤Þ¤¯¤¤¤«¤Ê¤«¤Ã¤¿¡ª");
5639 msg_print("You fail to exit the astral plane correctly!");
5645 msg_print("¶À¤ÎÀ¤³¦¤ò¤¦¤Þ¤¯Ä̤ì¤Ê¤«¤Ã¤¿¡ª");
5647 msg_print("You fail to exit the astral plane correctly!");
5650 p_ptr->energy_need += (s16b)((s32b)(60 - plev) * ENERGY_NEED() / 100L);
5651 teleport_player((plev+2)*2);
5654 teleport_player_to(y, x, TRUE);
5660 bool eat_magic(int power)
5662 object_type * o_ptr;
5665 int recharge_strength = 0;
5671 char o_name[MAX_NLEN];
5673 item_tester_hook = item_tester_hook_recharge;
5677 q = "¤É¤Î¥¢¥¤¥Æ¥à¤«¤éËâÎϤòµÛ¼ý¤·¤Þ¤¹¤«¡©";
5678 s = "ËâÎϤòµÛ¼ý¤Ç¤¤ë¥¢¥¤¥Æ¥à¤¬¤¢¤ê¤Þ¤»¤ó¡£";
5680 q = "Drain which item? ";
5681 s = "You have nothing to drain.";
5684 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return FALSE;
5688 o_ptr = &inventory[item];
5692 o_ptr = &o_list[0 - item];
5695 k_ptr = &k_info[o_ptr->k_idx];
5696 lev = get_object_level(o_ptr);
5698 if (o_ptr->tval == TV_ROD)
5700 recharge_strength = ((power > lev/2) ? (power - lev/2) : 0) / 5;
5703 if (one_in_(recharge_strength))
5705 /* Activate the failure code. */
5710 if (o_ptr->timeout > (o_ptr->number - 1) * k_ptr->pval)
5713 msg_print("½¼Å¶Ãæ¤Î¥í¥Ã¥É¤«¤éËâÎϤòµÛ¼ý¤¹¤ë¤³¤È¤Ï¤Ç¤¤Þ¤»¤ó¡£");
5715 msg_print("You can't absorb energy from a discharged rod.");
5722 o_ptr->timeout += k_ptr->pval;
5728 /* All staffs, wands. */
5729 recharge_strength = (100 + power - lev) / 15;
5732 if (recharge_strength < 0) recharge_strength = 0;
5735 if (one_in_(recharge_strength))
5737 /* Activate the failure code. */
5742 if (o_ptr->pval > 0)
5744 p_ptr->csp += lev / 2;
5747 /* XXX Hack -- unstack if necessary */
5748 if ((o_ptr->tval == TV_STAFF) && (item >= 0) && (o_ptr->number > 1))
5753 /* Get local object */
5756 /* Obtain a local object */
5757 object_copy(q_ptr, o_ptr);
5759 /* Modify quantity */
5762 /* Restore the charges */
5765 /* Unstack the used item */
5767 p_ptr->total_weight -= q_ptr->weight;
5768 item = inven_carry(q_ptr);
5772 msg_print("¾ó¤ò¤Þ¤È¤á¤Ê¤ª¤·¤¿¡£");
5774 msg_print("You unstack your staff.");
5782 msg_print("µÛ¼ý¤Ç¤¤ëËâÎϤ¬¤¢¤ê¤Þ¤»¤ó¡ª");
5784 msg_print("There's no energy there to absorb!");
5788 if (!o_ptr->pval) o_ptr->ident |= IDENT_EMPTY;
5792 /* Inflict the penalties for failing a recharge. */
5795 /* Artifacts are never destroyed. */
5796 if (artifact_p(o_ptr))
5798 object_desc(o_name, o_ptr, TRUE, 0);
5800 msg_format("ËâÎϤ¬µÕή¤·¤¿¡ª%s¤Ï´°Á´¤ËËâÎϤò¼º¤Ã¤¿¡£", o_name);
5802 msg_format("The recharging backfires - %s is completely drained!", o_name);
5806 /* Artifact rods. */
5807 if (o_ptr->tval == TV_ROD)
5808 o_ptr->timeout = k_ptr->pval * o_ptr->number;
5810 /* Artifact wands and staffs. */
5811 else if ((o_ptr->tval == TV_WAND) || (o_ptr->tval == TV_STAFF))
5816 /* Get the object description */
5817 object_desc(o_name, o_ptr, FALSE, 0);
5819 /*** Determine Seriousness of Failure ***/
5821 /* Mages recharge objects more safely. */
5822 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)
5824 /* 10% chance to blow up one rod, otherwise draining. */
5825 if (o_ptr->tval == TV_ROD)
5827 if (one_in_(10)) fail_type = 2;
5830 /* 75% chance to blow up one wand, otherwise draining. */
5831 else if (o_ptr->tval == TV_WAND)
5833 if (!one_in_(3)) fail_type = 2;
5836 /* 50% chance to blow up one staff, otherwise no effect. */
5837 else if (o_ptr->tval == TV_STAFF)
5839 if (one_in_(2)) fail_type = 2;
5844 /* All other classes get no special favors. */
5847 /* 33% chance to blow up one rod, otherwise draining. */
5848 if (o_ptr->tval == TV_ROD)
5850 if (one_in_(3)) fail_type = 2;
5853 /* 20% chance of the entire stack, else destroy one wand. */
5854 else if (o_ptr->tval == TV_WAND)
5856 if (one_in_(5)) fail_type = 3;
5859 /* Blow up one staff. */
5860 else if (o_ptr->tval == TV_STAFF)
5866 /*** Apply draining and destruction. ***/
5868 /* Drain object or stack of objects. */
5871 if (o_ptr->tval == TV_ROD)
5874 msg_print("¥í¥Ã¥É¤ÏÇË»¤òÌȤ줿¤¬¡¢ËâÎϤÏÁ´¤Æ¼º¤Ê¤ï¤ì¤¿¡£");
5876 msg_format("You save your rod from destruction, but all charges are lost.", o_name);
5879 o_ptr->timeout = k_ptr->pval * o_ptr->number;
5881 else if (o_ptr->tval == TV_WAND)
5884 msg_format("%s¤ÏÇË»¤òÌȤ줿¤¬¡¢ËâÎϤ¬Á´¤Æ¼º¤ï¤ì¤¿¡£", o_name);
5886 msg_format("You save your %s from destruction, but all charges are lost.", o_name);
5891 /* Staffs aren't drained. */
5894 /* Destroy an object or one in a stack of objects. */
5897 if (o_ptr->number > 1)
5900 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬°ìËܲõ¤ì¤¿¡ª", o_name);
5902 msg_format("Wild magic consumes one of your %s!", o_name);
5905 /* Reduce rod stack maximum timeout, drain wands. */
5906 if (o_ptr->tval == TV_ROD) o_ptr->timeout -= k_ptr->pval;
5907 if (o_ptr->tval == TV_WAND) o_ptr->pval = o_ptr->pval * (o_ptr->number - 1) / o_ptr->number;
5912 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬²¿Ëܤ«²õ¤ì¤¿¡ª", o_name);
5914 msg_format("Wild magic consumes your %s!", o_name);
5917 /* Reduce and describe inventory */
5920 inven_item_increase(item, -1);
5921 inven_item_describe(item);
5922 inven_item_optimize(item);
5925 /* Reduce and describe floor item */
5928 floor_item_increase(0 - item, -1);
5929 floor_item_describe(0 - item);
5930 floor_item_optimize(0 - item);
5934 /* Destroy all members of a stack of objects. */
5937 if (o_ptr->number > 1)
5939 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬Á´¤Æ²õ¤ì¤¿¡ª", o_name);
5941 msg_format("Wild magic consumes all your %s!", o_name);
5946 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬²õ¤ì¤¿¡ª", o_name);
5948 msg_format("Wild magic consumes your %s!", o_name);
5953 /* Reduce and describe inventory */
5956 inven_item_increase(item, -999);
5957 inven_item_describe(item);
5958 inven_item_optimize(item);
5961 /* Reduce and describe floor item */
5964 floor_item_increase(0 - item, -999);
5965 floor_item_describe(0 - item);
5966 floor_item_optimize(0 - item);
5972 if (p_ptr->csp > p_ptr->msp)
5974 p_ptr->csp = p_ptr->msp;
5977 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
5978 p_ptr->window |= (PW_INVEN);
5984 bool summon_kin_player(int level, int y, int x, u32b mode)
5986 bool pet = (bool)(mode & PM_FORCE_PET);
5987 if (!pet) mode |= PM_NO_PET;
5989 switch (p_ptr->mimic_form)
5992 switch (p_ptr->prace)
5996 case RACE_BARBARIAN:
5999 summon_kin_type = 'p';
6009 case RACE_MIND_FLAYER:
6012 summon_kin_type = 'h';
6015 summon_kin_type = 'o';
6017 case RACE_HALF_TROLL:
6018 summon_kin_type = 'T';
6020 case RACE_HALF_OGRE:
6021 summon_kin_type = 'O';
6023 case RACE_HALF_GIANT:
6024 case RACE_HALF_TITAN:
6026 summon_kin_type = 'P';
6029 summon_kin_type = 'y';
6032 summon_kin_type = 'K';
6035 summon_kin_type = 'k';
6038 if (one_in_(13)) summon_kin_type = 'U';
6039 else summon_kin_type = 'u';
6041 case RACE_DRACONIAN:
6042 summon_kin_type = 'd';
6046 summon_kin_type = 'g';
6049 if (one_in_(13)) summon_kin_type = 'L';
6050 else summon_kin_type = 's';
6053 summon_kin_type = 'z';
6056 summon_kin_type = 'V';
6059 summon_kin_type = 'G';
6062 summon_kin_type = 'I';
6065 summon_kin_type = '#';
6068 summon_kin_type = 'A';
6071 summon_kin_type = 'U';
6074 summon_kin_type = 'p';
6079 if (one_in_(13)) summon_kin_type = 'U';
6080 else summon_kin_type = 'u';
6082 case MIMIC_DEMON_LORD:
6083 summon_kin_type = 'U';
6086 summon_kin_type = 'V';
6089 return summon_specific((pet ? -1 : 0), y, x, level, SUMMON_KIN, mode);