4 * Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke
6 * This software may be copied and distributed for educational, research,
7 * and not for profit purposes provided that this copyright and statement
8 * are included in all such copies. Other copyrights may also apply.
11 /* Purpose: Spell code (part 3) */
15 /* Maximum number of tries for teleporting */
18 /* 1/x chance of reducing stats (for elemental attacks) */
19 #define HURT_CHANCE 16
23 * Teleport a monster, normally up to "dis" grids away.
25 * Attempt to move the monster at least "dis/2" grids away.
27 * But allow variation to prevent infinite loops.
29 bool teleport_away(int m_idx, int dis, bool dec_valour)
31 int oy, ox, d, i, min;
37 monster_type *m_ptr = &m_list[m_idx];
41 if (!m_ptr->r_idx) return (FALSE);
43 /* Save the old location */
47 /* Minimum distance */
51 (((p_ptr->chp * 10) / p_ptr->mhp) > 5) &&
52 (4+randint1(5) < ((p_ptr->chp * 10) / p_ptr->mhp)))
54 chg_virtue(V_VALOUR, -1);
62 /* Verify max distance */
63 if (dis > 200) dis = 200;
65 /* Try several locations */
66 for (i = 0; i < 500; i++)
68 /* Pick a (possibly illegal) location */
71 ny = rand_spread(oy, dis);
72 nx = rand_spread(ox, dis);
73 d = distance(oy, ox, ny, nx);
74 if ((d >= min) && (d <= dis)) break;
77 /* Ignore illegal locations */
78 if (!in_bounds(ny, nx)) continue;
80 /* Require "empty" floor space */
81 if (!cave_empty_bold(ny, nx)) continue;
83 /* Hack -- no teleport onto glyph of warding */
84 if (is_glyph_grid(&cave[ny][nx])) continue;
85 if (is_explosive_rune_grid(&cave[ny][nx])) continue;
87 /* ...nor onto the Pattern */
88 if ((cave[ny][nx].feat >= FEAT_PATTERN_START) &&
89 (cave[ny][nx].feat <= FEAT_PATTERN_XTRA2)) continue;
91 /* No teleporting into vaults and such */
92 if (!(p_ptr->inside_quest || p_ptr->inside_arena))
93 if (cave[ny][nx].info & CAVE_ICKY) continue;
95 /* This grid looks good */
102 /* Increase the maximum distance */
105 /* Decrease the minimum distance */
108 /* Stop after MAX_TRIES tries */
109 if (tries > MAX_TRIES) return (FALSE);
113 sound(SOUND_TPOTHER);
115 /* Update the new location */
116 cave[ny][nx].m_idx = m_idx;
118 /* Update the old location */
119 cave[oy][ox].m_idx = 0;
121 /* Move the monster */
125 /* Forget the counter target */
128 /* Update the monster (new location) */
129 update_mon(m_idx, TRUE);
131 /* Redraw the old grid */
134 /* Redraw the new grid */
143 * Teleport monster next to a grid near the given location
145 void teleport_monster_to(int m_idx, int ty, int tx, int power)
147 int ny, nx, oy, ox, d, i, min;
151 monster_type *m_ptr = &m_list[m_idx];
155 if (!m_ptr->r_idx) return;
158 if (randint1(100) > power) return;
164 /* Save the old location */
168 /* Minimum distance */
171 /* Look until done */
172 while (look && --attempts)
174 /* Verify max distance */
175 if (dis > 200) dis = 200;
177 /* Try several locations */
178 for (i = 0; i < 500; i++)
182 /* Pick a (possibly illegal) location */
185 ny = rand_spread(ty, dis);
186 nx = rand_spread(tx, dis);
187 d = distance(ty, tx, ny, nx);
188 if ((d >= min) && (d <= dis)) break;
191 /* Ignore illegal locations */
192 if (!in_bounds(ny, nx)) continue;
194 /* Require "empty" floor space */
195 if (!cave_empty_bold(ny, nx)) continue;
197 c_ptr = &cave[ny][nx];
199 /* Hack -- no teleport onto glyph of warding */
200 if (is_glyph_grid(c_ptr)) continue;
201 if (is_explosive_rune_grid(c_ptr)) continue;
203 /* ...nor onto the Pattern */
204 if ((c_ptr->feat >= FEAT_PATTERN_START) &&
205 (c_ptr->feat <= FEAT_PATTERN_XTRA2)) continue;
207 /* No teleporting into vaults and such */
208 /* if (c_ptr->info & (CAVE_ICKY)) continue; */
210 /* This grid looks good */
217 /* Increase the maximum distance */
220 /* Decrease the minimum distance */
224 if (attempts < 1) return;
227 sound(SOUND_TPOTHER);
229 /* Update the new location */
230 cave[ny][nx].m_idx = m_idx;
232 /* Update the old location */
233 cave[oy][ox].m_idx = 0;
235 /* Move the monster */
239 /* Update the monster (new location) */
240 update_mon(m_idx, TRUE);
242 /* Redraw the old grid */
245 /* Redraw the new grid */
248 p_ptr->update |= (PU_MON_LITE);
253 * Teleport the player to a location up to "dis" grids away.
255 * If no such spaces are readily available, the distance may increase.
256 * Try very hard to move the player at least a quarter that distance.
258 * When long-range teleport effects are considered, there is a nasty
259 * tendency to "bounce" the player between two or three different spots
260 * because these are the only spots that are "far enough" way to satisfy
261 * the algorithm. Therefore, if the teleport distance is more than 50,
262 * we decrease the minimum acceptable distance to try to increase randomness.
265 void teleport_player(int dis)
267 int d, i, min, ox, oy;
278 if (p_ptr->wild_mode) return;
280 if (p_ptr->anti_tele)
283 msg_print("ÉԻ׵ĤÊÎϤ¬¥Æ¥ì¥Ý¡¼¥È¤òËɤ¤¤À¡ª");
285 msg_print("A mysterious force prevents you from teleporting!");
291 if (dis > 200) dis = 200; /* To be on the safe side... */
293 /* Minimum distance */
294 min = dis / (dis > 50 ? 3 : 2);
296 /* Look until done */
301 /* Verify max distance */
302 if (dis > 200) dis = 200;
304 /* Try several locations */
305 for (i = 0; i < 500; i++)
307 /* Pick a (possibly illegal) location */
310 y = rand_spread(py, dis);
311 x = rand_spread(px, dis);
312 d = distance(py, px, y, x);
313 if ((d >= min) && (d <= dis)) break;
316 /* Ignore illegal locations */
317 if (!in_bounds(y, x)) continue;
319 /* Require "naked" floor space or trees */
320 if (!(cave_naked_bold(y, x) ||
321 (cave[y][x].feat == FEAT_TREES))) continue;
323 /* No teleporting into vaults and such */
324 if (cave[y][x].info & CAVE_ICKY) continue;
326 /* This grid looks good */
333 /* Increase the maximum distance */
336 /* Decrease the minimum distance */
339 /* Stop after MAX_TRIES tries */
340 if (tries > MAX_TRIES) return;
344 sound(SOUND_TELEPORT);
347 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
348 msg_format("¡Ø¤³¤Ã¤Á¤À¤¡¡¢%s¡Ù", player_name);
351 /* Save the old location */
355 /* Move the player */
362 tmp = cave[py][px].m_idx;
363 cave[py][px].m_idx = cave[oy][ox].m_idx;
364 cave[oy][ox].m_idx = tmp;
365 m_list[p_ptr->riding].fy = py;
366 m_list[p_ptr->riding].fx = px;
367 update_mon(cave[py][px].m_idx, TRUE);
370 /* Redraw the old spot */
373 /* Monsters with teleport ability may follow the player */
374 for (xx = -1; xx < 2; xx++)
376 for (yy = -1; yy < 2; yy++)
378 int tmp_m_idx = cave[oy+yy][ox+xx].m_idx;
380 /* A monster except your mount may follow */
381 if (tmp_m_idx && p_ptr->riding != tmp_m_idx)
383 monster_type *m_ptr = &m_list[tmp_m_idx];
384 monster_race *r_ptr = &r_info[m_ptr->r_idx];
387 * The latter limitation is to avoid
388 * totally unkillable suckers...
390 if ((r_ptr->flags6 & RF6_TPORT) &&
391 !(r_ptr->flagsr & RFR_RES_TELE))
393 if (!m_ptr->csleep) teleport_monster_to(tmp_m_idx, py, px, r_ptr->level);
401 /* Redraw the new spot */
404 /* Check for new panel (redraw map) */
408 p_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MON_LITE);
410 /* Update the monsters */
411 p_ptr->update |= (PU_DISTANCE);
414 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
416 /* Handle stuff XXX XXX XXX */
423 * Teleport player to a grid near the given location
425 * This function is slightly obsessive about correctness.
426 * This function allows teleporting into vaults (!)
428 void teleport_player_to(int ny, int nx, bool no_tele)
430 int y, x, oy, ox, dis = 0, ctr = 0;
432 if (p_ptr->anti_tele && no_tele)
435 msg_print("ÉԻ׵ĤÊÎϤ¬¥Æ¥ì¥Ý¡¼¥È¤òËɤ¤¤À¡ª");
437 msg_print("A mysterious force prevents you from teleporting!");
443 /* Find a usable location */
446 /* Pick a nearby legal location */
449 y = rand_spread(ny, dis);
450 x = rand_spread(nx, dis);
451 if (in_bounds(y, x)) break;
454 /* Accept "naked" floor grids */
457 if (cave_naked_bold(y, x) || (((cave[y][x].feat == FEAT_DEEP_LAVA) || (cave[y][x].feat == FEAT_DEEP_WATER)) && !cave[y][x].m_idx)) break;
459 else if (cave_empty_bold(y, x) || player_bold(y, x)) break;
461 /* Occasionally advance the distance */
462 if (++ctr > (4 * dis * dis + 4 * dis + 1))
470 sound(SOUND_TELEPORT);
472 /* Save the old location */
476 /* Move the player */
483 tmp = cave[py][px].m_idx;
484 cave[py][px].m_idx = cave[oy][ox].m_idx;
485 cave[oy][ox].m_idx = tmp;
486 m_list[p_ptr->riding].fy = py;
487 m_list[p_ptr->riding].fx = px;
488 update_mon(cave[py][px].m_idx, TRUE);
493 /* Redraw the old spot */
496 /* Redraw the new spot */
499 /* Check for new panel (redraw map) */
503 p_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MON_LITE);
505 /* Update the monsters */
506 p_ptr->update |= (PU_DISTANCE);
509 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
511 /* Handle stuff XXX XXX XXX */
518 * Teleport the player one level up or down (random when legal)
519 * Note: If m_idx <= 0, target is player.
521 void teleport_level(int m_idx)
527 if (m_idx <= 0) /* To player */
530 strcpy(m_name, "¤¢¤Ê¤¿");
532 strcpy(m_name, "you");
535 else /* To monster */
537 monster_type *m_ptr = &m_list[m_idx];
539 /* Get the monster name (or "it") */
540 monster_desc(m_name, m_ptr, 0);
545 /* No effect in some case */
546 if (TELE_LEVEL_IS_INEFF(m_idx))
549 if (see_m) msg_print("¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡£");
551 if (see_m) msg_print("There is no effect.");
557 if ((m_idx <= 0) && p_ptr->anti_tele) /* To player */
560 msg_print("ÉԻ׵ĤÊÎϤ¬¥Æ¥ì¥Ý¡¼¥È¤òËɤ¤¤À¡ª");
562 msg_print("A mysterious force prevents you from teleporting!");
567 /* Choose up or down */
568 if (randint0(100) < 50) go_up = TRUE;
571 if ((m_idx <= 0) && p_ptr->wizard)
573 if (get_check("Force to go up? ")) go_up = TRUE;
574 else if (get_check("Force to go down? ")) go_up = FALSE;
578 if ((ironman_downward && (m_idx <= 0)) || (dun_level <= d_info[dungeon_type].mindepth))
581 if (see_m) msg_format("%^s¤Ï¾²¤òÆͤÇˤäÆÄÀ¤ó¤Ç¤¤¤¯¡£", m_name);
583 if (see_m) msg_format("%^s sink%s through the floor.", m_name, (m_idx <= 0) ? "" : "s");
585 if (m_idx <= 0) /* To player */
589 dungeon_type = p_ptr->recall_dungeon;
594 if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, 1, NULL);
596 if (autosave_l) do_cmd_save_game(TRUE);
600 dun_level = d_info[dungeon_type].mindepth;
601 prepare_change_floor_mode(CFM_RAND_PLACE | CFM_CLEAR_ALL);
605 prepare_change_floor_mode(CFM_DOWN | CFM_RAND_PLACE | CFM_RAND_CONNECT);
609 p_ptr->leaving = TRUE;
614 else if (quest_number(dun_level) || (dun_level >= d_info[dungeon_type].maxdepth))
617 if (see_m) msg_format("%^s¤ÏÅ·°æ¤òÆͤÇˤäÆÃè¤ØÉ⤤¤Æ¤¤¤¯¡£", m_name);
619 if (see_m) msg_format("%^s rise%s up through the ceiling.", m_name, (m_idx <= 0) ? "" : "s");
623 if (m_idx <= 0) /* To player */
625 if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, -1, NULL);
627 if (autosave_l) do_cmd_save_game(TRUE);
629 prepare_change_floor_mode(CFM_UP | CFM_RAND_PLACE | CFM_RAND_CONNECT);
634 p_ptr->inside_quest = 0;
635 p_ptr->leaving = TRUE;
641 if (see_m) msg_format("%^s¤ÏÅ·°æ¤òÆͤÇˤäÆÃè¤ØÉ⤤¤Æ¤¤¤¯¡£", m_name);
643 if (see_m) msg_format("%^s rise%s up through the ceiling.", m_name, (m_idx <= 0) ? "" : "s");
647 if (m_idx <= 0) /* To player */
649 if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, -1, NULL);
651 if (autosave_l) do_cmd_save_game(TRUE);
653 prepare_change_floor_mode(CFM_UP | CFM_RAND_PLACE | CFM_RAND_CONNECT);
656 p_ptr->leaving = TRUE;
662 if (see_m) msg_format("%^s¤Ï¾²¤òÆͤÇˤäÆÄÀ¤ó¤Ç¤¤¤¯¡£", m_name);
664 if (see_m) msg_format("%^s sink%s through the floor.", m_name, (m_idx <= 0) ? "" : "s");
667 if (m_idx <= 0) /* To player */
669 /* Never reach this code on the surface */
670 /* if (!dun_level) dungeon_type = p_ptr->recall_dungeon; */
672 if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, 1, NULL);
674 if (autosave_l) do_cmd_save_game(TRUE);
676 prepare_change_floor_mode(CFM_DOWN | CFM_RAND_PLACE | CFM_RAND_CONNECT);
679 p_ptr->leaving = TRUE;
683 /* Monster level teleportation is simple deleting now */
686 monster_type *m_ptr = &m_list[m_idx];
688 /* Check for quest completion */
689 check_quest_completion(m_ptr);
691 delete_monster_idx(m_idx);
695 sound(SOUND_TPLEVEL);
700 static int choose_dungeon(cptr note)
706 /* Allocate the "dun" array */
707 C_MAKE(dun, max_d_idx, s16b);
710 for(i = 1; i < max_d_idx; i++)
715 if (!d_info[i].maxdepth) continue;
716 if (!max_dlv[i]) continue;
717 if (d_info[i].final_guardian)
719 if (!r_info[d_info[i].final_guardian].max_num) seiha = TRUE;
721 else if (max_dlv[i] == d_info[i].maxdepth) seiha = TRUE;
724 sprintf(buf," %c) %c%-12s : ºÇÂç %d ³¬", 'a'+num, seiha ? '!' : ' ', d_name + d_info[i].name, max_dlv[i]);
726 sprintf(buf," %c) %c%-16s : Max level %d", 'a'+num, seiha ? '!' : ' ', d_name + d_info[i].name, max_dlv[i]);
732 prt(format("¤É¤Î¥À¥ó¥¸¥ç¥ó%s¤·¤Þ¤¹¤«:", note), 0, 0);
734 prt(format("Which dungeon do you %s?: ", note), 0, 0);
741 /* Free the "dun" array */
742 C_KILL(dun, max_d_idx, s16b);
747 if (i >= 'a' && i <('a'+num))
749 select_dungeon = dun[i-'a'];
756 /* Free the "dun" array */
757 C_KILL(dun, max_d_idx, s16b);
759 return select_dungeon;
764 * Recall the player to town or dungeon
766 bool recall_player(int turns)
769 * TODO: Recall the player to the last
770 * visited town when in the wilderness
774 if (p_ptr->inside_arena || ironman_downward)
777 msg_print("²¿¤âµ¯¤³¤é¤Ê¤«¤Ã¤¿¡£");
779 msg_print("Nothing happens.");
785 if (dun_level && (max_dlv[dungeon_type] > dun_level) && !p_ptr->inside_quest && !p_ptr->word_recall)
788 if (get_check("¤³¤³¤ÏºÇ¿¼Åþ㳬¤è¤êÀõ¤¤³¬¤Ç¤¹¡£¤³¤Î³¬¤ËÌá¤Ã¤ÆÍè¤Þ¤¹¤«¡© "))
790 if (get_check("Reset recall depth? "))
793 max_dlv[dungeon_type] = dun_level;
794 if (record_maxdeapth)
796 do_cmd_write_nikki(NIKKI_TRUMP, dungeon_type, "µ¢´Ô¤Î¤È¤¤Ë");
798 do_cmd_write_nikki(NIKKI_TRUMP, dungeon_type, "when recall from dungeon");
803 if (!p_ptr->word_recall)
809 select_dungeon = choose_dungeon("¤Ëµ¢´Ô");
811 select_dungeon = choose_dungeon("recall");
813 if (!select_dungeon) return FALSE;
814 p_ptr->recall_dungeon = select_dungeon;
816 p_ptr->word_recall = turns;
818 msg_print("²ó¤ê¤ÎÂ絤¤¬Ä¥¤ê¤Ä¤á¤Æ¤¤¿...");
820 msg_print("The air about you becomes charged...");
823 p_ptr->redraw |= (PR_STATUS);
827 p_ptr->word_recall = 0;
829 msg_print("Ä¥¤ê¤Ä¤á¤¿Â絤¤¬Î®¤ìµî¤Ã¤¿...");
831 msg_print("A tension leaves the air around you...");
834 p_ptr->redraw |= (PR_STATUS);
840 bool word_of_recall(void)
842 return(recall_player(randint0(21) + 15));
846 bool reset_recall(void)
848 int select_dungeon, dummy = 0;
853 select_dungeon = choose_dungeon("¤ò¥»¥Ã¥È");
855 select_dungeon = choose_dungeon("reset");
859 if (ironman_downward)
862 msg_print("²¿¤âµ¯¤³¤é¤Ê¤«¤Ã¤¿¡£");
864 msg_print("Nothing happens.");
870 if (!select_dungeon) return FALSE;
873 sprintf(ppp, "²¿³¬¤Ë¥»¥Ã¥È¤·¤Þ¤¹¤« (%d-%d):", d_info[select_dungeon].mindepth, max_dlv[select_dungeon]);
875 sprintf(ppp, "Reset to which level (%d-%d): ", d_info[select_dungeon].mindepth, max_dlv[select_dungeon]);
880 sprintf(tmp_val, "%d", MAX(dun_level, 1));
882 /* Ask for a level */
883 if (get_string(ppp, tmp_val, 10))
885 /* Extract request */
886 dummy = atoi(tmp_val);
889 if (dummy < 1) dummy = 1;
892 if (dummy > max_dlv[select_dungeon]) dummy = max_dlv[select_dungeon];
893 if (dummy < d_info[select_dungeon].mindepth) dummy = d_info[select_dungeon].mindepth;
895 max_dlv[select_dungeon] = dummy;
897 if (record_maxdeapth)
899 do_cmd_write_nikki(NIKKI_TRUMP, select_dungeon, "¥Õ¥í¥¢¡¦¥ê¥»¥Ã¥È¤Ç");
901 do_cmd_write_nikki(NIKKI_TRUMP, select_dungeon, "using a scroll of reset recall");
905 msg_format("%s¤Îµ¢´Ô¥ì¥Ù¥ë¤ò %d ³¬¤Ë¥»¥Ã¥È¡£", d_name+d_info[select_dungeon].name, dummy, dummy * 50);
907 msg_format("Recall depth set to level %d (%d').", dummy, dummy * 50);
920 * Apply disenchantment to the player's stuff
922 * XXX XXX XXX This function is also called from the "melee" code
924 * Return "TRUE" if the player notices anything
926 bool apply_disenchant(int mode)
930 char o_name[MAX_NLEN];
931 int to_h, to_d, to_a, pval;
933 /* Pick a random slot */
936 case 1: t = INVEN_RARM; break;
937 case 2: t = INVEN_LARM; break;
938 case 3: t = INVEN_BOW; break;
939 case 4: t = INVEN_BODY; break;
940 case 5: t = INVEN_OUTER; break;
941 case 6: t = INVEN_HEAD; break;
942 case 7: t = INVEN_HANDS; break;
943 case 8: t = INVEN_FEET; break;
947 o_ptr = &inventory[t];
949 /* No item, nothing happens */
950 if (!o_ptr->k_idx) return (FALSE);
953 /* Nothing to disenchant */
954 if ((o_ptr->to_h <= 0) && (o_ptr->to_d <= 0) && (o_ptr->to_a <= 0) && (o_ptr->pval <= 1))
956 /* Nothing to notice */
961 /* Describe the object */
962 object_desc(o_name, o_ptr, FALSE, 0);
965 /* Artifacts have 71% chance to resist */
966 if ((artifact_p(o_ptr) || o_ptr->art_name) && (randint0(100) < 71))
970 msg_format("%s(%c)¤ÏÎô²½¤òÄ·¤ÍÊÖ¤·¤¿¡ª",o_name, index_to_label(t) );
972 msg_format("Your %s (%c) resist%s disenchantment!",
973 o_name, index_to_label(t),
974 ((o_ptr->number != 1) ? "" : "s"));
983 /* Memorize old value */
989 /* Disenchant tohit */
990 if (o_ptr->to_h > 0) o_ptr->to_h--;
991 if ((o_ptr->to_h > 5) && (randint0(100) < 20)) o_ptr->to_h--;
993 /* Disenchant todam */
994 if (o_ptr->to_d > 0) o_ptr->to_d--;
995 if ((o_ptr->to_d > 5) && (randint0(100) < 20)) o_ptr->to_d--;
997 /* Disenchant toac */
998 if (o_ptr->to_a > 0) o_ptr->to_a--;
999 if ((o_ptr->to_a > 5) && (randint0(100) < 20)) o_ptr->to_a--;
1001 /* Disenchant pval (occasionally) */
1002 /* Unless called from wild_magic() */
1003 if ((o_ptr->pval > 1) && one_in_(13) && !(mode & 0x01)) o_ptr->pval--;
1005 if ((to_h != o_ptr->to_h) || (to_d != o_ptr->to_d) ||
1006 (to_a != o_ptr->to_a) || (pval != o_ptr->pval))
1010 msg_format("%s(%c)¤ÏÎô²½¤·¤Æ¤·¤Þ¤Ã¤¿¡ª",
1011 o_name, index_to_label(t) );
1013 msg_format("Your %s (%c) %s disenchanted!",
1014 o_name, index_to_label(t),
1015 ((o_ptr->number != 1) ? "were" : "was"));
1018 chg_virtue(V_HARMONY, 1);
1019 chg_virtue(V_ENCHANT, -2);
1021 /* Recalculate bonuses */
1022 p_ptr->update |= (PU_BONUS);
1025 p_ptr->window |= (PW_EQUIP | PW_PLAYER);
1035 void mutate_player(void)
1037 int max1, cur1, max2, cur2, ii, jj, i;
1039 /* Pick a pair of stats */
1041 for (jj = ii; jj == ii; jj = randint0(6)) /* loop */;
1043 max1 = p_ptr->stat_max[ii];
1044 cur1 = p_ptr->stat_cur[ii];
1045 max2 = p_ptr->stat_max[jj];
1046 cur2 = p_ptr->stat_cur[jj];
1048 p_ptr->stat_max[ii] = max2;
1049 p_ptr->stat_cur[ii] = cur2;
1050 p_ptr->stat_max[jj] = max1;
1051 p_ptr->stat_cur[jj] = cur1;
1055 if(p_ptr->stat_max[i] > p_ptr->stat_max_max[i]) p_ptr->stat_max[i] = p_ptr->stat_max_max[i];
1056 if(p_ptr->stat_cur[i] > p_ptr->stat_max_max[i]) p_ptr->stat_cur[i] = p_ptr->stat_max_max[i];
1059 p_ptr->update |= (PU_BONUS);
1066 void apply_nexus(monster_type *m_ptr)
1068 switch (randint1(7))
1070 case 1: case 2: case 3:
1072 teleport_player(200);
1078 teleport_player_to(m_ptr->fy, m_ptr->fx, TRUE);
1084 if (randint0(100) < p_ptr->skill_sav)
1087 msg_print("¤·¤«¤·¸úÎϤòÄ·¤ÍÊÖ¤·¤¿¡ª");
1089 msg_print("You resist the effects!");
1095 /* Teleport Level */
1102 if (randint0(100) < p_ptr->skill_sav)
1105 msg_print("¤·¤«¤·¸úÎϤòÄ·¤ÍÊÖ¤·¤¿¡ª");
1107 msg_print("You resist the effects!");
1114 msg_print("ÂΤ¬¤Í¤¸¤ì»Ï¤á¤¿...");
1116 msg_print("Your body starts to scramble...");
1127 * Charge a lite (torch or latern)
1129 void phlogiston(void)
1132 object_type * o_ptr = &inventory[INVEN_LITE];
1135 if ((o_ptr->tval == TV_LITE) && (o_ptr->sval == SV_LITE_LANTERN))
1137 max_flog = FUEL_LAMP;
1141 else if ((o_ptr->tval == TV_LITE) && (o_ptr->sval == SV_LITE_TORCH))
1143 max_flog = FUEL_TORCH;
1146 /* No torch to refill */
1150 msg_print("dzÁǤò¾ÃÈñ¤¹¤ë¥¢¥¤¥Æ¥à¤òÁõÈ÷¤·¤Æ¤¤¤Þ¤»¤ó¡£");
1152 msg_print("You are not wielding anything which uses phlogiston.");
1158 if (o_ptr->xtra4 >= max_flog)
1161 msg_print("¤³¤Î¥¢¥¤¥Æ¥à¤Ë¤Ï¤³¤ì°Ê¾ådzÁǤòÊä½¼¤Ç¤¤Þ¤»¤ó¡£");
1163 msg_print("No more phlogiston can be put in this item.");
1170 o_ptr->xtra4 += (max_flog / 2);
1174 msg_print("¾ÈÌÀÍÑ¥¢¥¤¥Æ¥à¤ËdzÁǤòÊä½¼¤·¤¿¡£");
1176 msg_print("You add phlogiston to your light item.");
1181 if (o_ptr->xtra4 >= max_flog)
1183 o_ptr->xtra4 = max_flog;
1185 msg_print("¾ÈÌÀÍÑ¥¢¥¤¥Æ¥à¤ÏËþ¥¿¥ó¤Ë¤Ê¤Ã¤¿¡£");
1187 msg_print("Your light item is full.");
1192 /* Recalculate torch */
1193 p_ptr->update |= (PU_TORCH);
1197 static bool item_tester_hook_weapon_nobow(object_type *o_ptr)
1199 switch (o_ptr->tval)
1209 if (o_ptr->sval != SV_DOKUBARI) return (TRUE);
1217 * Brand the current weapon
1219 void brand_weapon(int brand_type)
1226 /* Assume enchant weapon */
1227 item_tester_hook = item_tester_hook_weapon_nobow;
1228 item_tester_no_ryoute = TRUE;
1232 q = "¤É¤ÎÉð´ï¤ò¶¯²½¤·¤Þ¤¹¤«? ";
1233 s = "¶¯²½¤Ç¤¤ëÉð´ï¤¬¤Ê¤¤¡£";
1235 q = "Enchant which weapon? ";
1236 s = "You have nothing to enchant.";
1239 if (!get_item(&item, q, s, (USE_EQUIP))) return;
1241 /* Get the item (in the pack) */
1244 o_ptr = &inventory[item];
1247 /* Get the item (on the floor) */
1250 o_ptr = &o_list[0 - item];
1254 /* you can never modify artifacts / ego-items */
1255 /* you can never modify cursed items */
1256 /* TY: You _can_ modify broken items (if you're silly enough) */
1257 if (o_ptr->k_idx && !artifact_p(o_ptr) && !ego_item_p(o_ptr) &&
1258 !o_ptr->art_name && !cursed_p(o_ptr) &&
1259 !((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DOKUBARI)) &&
1260 !((o_ptr->tval == TV_POLEARM) && (o_ptr->sval == SV_DEATH_SCYTHE)) &&
1261 !((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DIAMOND_EDGE)))
1265 /* Let's get the name before it is changed... */
1266 char o_name[MAX_NLEN];
1267 object_desc(o_name, o_ptr, FALSE, 0);
1272 if (o_ptr->tval == TV_SWORD)
1275 act = "¤Ï±Ô¤µ¤òÁý¤·¤¿¡ª";
1277 act = "becomes very sharp!";
1280 o_ptr->name2 = EGO_SHARPNESS;
1281 o_ptr->pval = m_bonus(5, dun_level) + 1;
1286 act = "¤ÏÇ˲õÎϤòÁý¤·¤¿¡ª";
1288 act = "seems very powerful.";
1291 o_ptr->name2 = EGO_EARTHQUAKES;
1292 o_ptr->pval = m_bonus(3, dun_level);
1297 act = "¤Ï¿Í´Ö¤Î·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
1299 act = "seems to be looking for humans!";
1302 o_ptr->name2 = EGO_SLAY_HUMAN;
1306 act = "¤ÏÅÅ·â¤Ëʤ¤ï¤ì¤¿¡ª";
1308 act = "covered with lightning!";
1311 o_ptr->name2 = EGO_BRAND_ELEC;
1315 act = "¤Ï»À¤Ëʤ¤ï¤ì¤¿¡ª";
1317 act = "coated with acid!";
1320 o_ptr->name2 = EGO_BRAND_ACID;
1324 act = "¤Ï¼Ù°¤Ê¤ë²øʪ¤òµá¤á¤Æ¤¤¤ë¡ª";
1326 act = "seems to be looking for evil monsters!";
1329 o_ptr->name2 = EGO_SLAY_EVIL;
1333 act = "¤Ï°ÛÀ¤³¦¤Î½»¿Í¤ÎÆùÂΤòµá¤á¤Æ¤¤¤ë¡ª";
1335 act = "seems to be looking for demons!";
1338 o_ptr->name2 = EGO_SLAY_DEMON;
1342 act = "¤Ï»Ó¤òµá¤á¤Æ¤¤¤ë¡ª";
1344 act = "seems to be looking for undead!";
1347 o_ptr->name2 = EGO_SLAY_UNDEAD;
1351 act = "¤Ïưʪ¤Î·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
1353 act = "seems to be looking for animals!";
1356 o_ptr->name2 = EGO_SLAY_ANIMAL;
1360 act = "¤Ï¥É¥é¥´¥ó¤Î·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
1362 act = "seems to be looking for dragons!";
1365 o_ptr->name2 = EGO_SLAY_DRAGON;
1369 act = "¤Ï¥È¥í¥ë¤Î·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
1371 act = "seems to be looking for troll!s";
1374 o_ptr->name2 = EGO_SLAY_TROLL;
1378 act = "¤Ï¥ª¡¼¥¯¤Î·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
1380 act = "seems to be looking for orcs!";
1383 o_ptr->name2 = EGO_SLAY_ORC;
1387 act = "¤Ïµð¿Í¤Î·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
1389 act = "seems to be looking for giants!";
1392 o_ptr->name2 = EGO_SLAY_GIANT;
1396 act = "¤ÏÈó¾ï¤ËÉÔ°ÂÄê¤Ë¤Ê¤Ã¤¿¤è¤¦¤À¡£";
1398 act = "seems very unstable now.";
1401 o_ptr->name2 = EGO_TRUMP;
1402 o_ptr->pval = randint1(2);
1406 act = "¤Ï·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
1408 act = "thirsts for blood!";
1411 o_ptr->name2 = EGO_VAMPIRIC;
1415 act = "¤ÏÆǤËʤ¤ï¤ì¤¿¡£";
1417 act = "is coated with poison.";
1420 o_ptr->name2 = EGO_BRAND_POIS;
1424 act = "¤Ï½ã¥í¥°¥ë¥¹¤Ë°û¤ß¹þ¤Þ¤ì¤¿¡£";
1426 act = "is engulfed in raw Logrus!";
1429 o_ptr->name2 = EGO_CHAOTIC;
1433 act = "¤Ï±ê¤Î¥·¡¼¥ë¥É¤Ëʤ¤ï¤ì¤¿¡ª";
1435 act = "is covered in a fiery shield!";
1438 o_ptr->name2 = EGO_BRAND_FIRE;
1442 act = "¤Ï¿¼¤¯Î䤿¤¤¥Ö¥ë¡¼¤Ëµ±¤¤¤¿¡ª";
1444 act = "glows deep, icy blue!";
1447 o_ptr->name2 = EGO_BRAND_COLD;
1452 msg_format("¤¢¤Ê¤¿¤Î%s%s", o_name, act);
1454 msg_format("Your %s %s", o_name, act);
1458 enchant(o_ptr, randint0(3) + 4, ENCH_TOHIT | ENCH_TODAM);
1460 o_ptr->discount = 99;
1461 chg_virtue(V_ENCHANT, 2);
1465 if (flush_failure) flush();
1468 msg_print("°ÀÉղä˼ºÇÔ¤·¤¿¡£");
1470 msg_print("The Branding failed.");
1473 chg_virtue(V_ENCHANT, -2);
1480 * Determine if a "feature" is a "vanishable"
1481 * Non-permanent walls, trees, mountains, or doors
1483 #define vanishable_feat(F) \
1484 ((!feat_floor(F) && (((F) < FEAT_PERM_EXTRA) || ((F) > FEAT_PERM_SOLID))) || \
1485 ((F) == FEAT_OPEN) || ((F) == FEAT_BROKEN))
1488 * Vanish all walls in this floor
1490 static bool vanish_dungeon(void)
1494 monster_type *m_ptr;
1498 /* Prevent vasishing of quest levels and town */
1499 if ((p_ptr->inside_quest && is_fixed_quest_idx(p_ptr->inside_quest)) || !dun_level)
1504 /* Scan all normal grids */
1505 for (y = 1; y < cur_hgt - 1; y++)
1507 for (x = 1; x < cur_wid - 1; x++)
1509 c_ptr = &cave[y][x];
1511 /* Seeing true feature code (ignore mimic) */
1514 /* Lose room and vault */
1515 c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1520 m_ptr = &m_list[c_ptr->m_idx];
1522 /* Reset sleep counter */
1525 if (r_info[m_ptr->r_idx].flags7 & RF7_HAS_LD_MASK) p_ptr->update |= (PU_MON_LITE);
1527 /* Notice the "waking up" */
1530 /* Acquire the monster name */
1531 monster_desc(m_name, m_ptr, 0);
1533 /* Dump a message */
1535 msg_format("%^s¤¬Ìܤò³Ð¤Þ¤·¤¿¡£", m_name);
1537 msg_format("%^s wakes up.", m_name);
1540 /* Redraw the health bar */
1541 if (p_ptr->health_who == c_ptr->m_idx) p_ptr->redraw |= (PR_HEALTH);
1542 if (p_ptr->riding == c_ptr->m_idx) p_ptr->redraw |= (PR_UHEALTH);
1546 /* Process all walls, doors and patterns */
1547 if (vanishable_feat(feat) || pattern_tile(y, x))
1550 cave_set_feat(y, x, floor_type[randint0(100)]);
1555 /* Special boundary walls -- Top and bottom */
1556 for (x = 0; x < cur_wid; x++)
1558 c_ptr = &cave[0][x];
1560 /* Lose room and vault */
1561 c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1563 /* Set boundary mimic if needed */
1564 if (c_ptr->mimic && vanishable_feat(c_ptr->mimic)) c_ptr->mimic = floor_type[randint0(100)];
1566 c_ptr = &cave[cur_hgt - 1][x];
1568 /* Lose room and vault */
1569 c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1571 /* Set boundary mimic if needed */
1572 if (c_ptr->mimic && vanishable_feat(c_ptr->mimic)) c_ptr->mimic = floor_type[randint0(100)];
1575 /* Special boundary walls -- Left and right */
1576 for (y = 1; y < (cur_hgt - 1); y++)
1578 c_ptr = &cave[y][0];
1580 /* Lose room and vault */
1581 c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1583 /* Set boundary mimic if needed */
1584 if (c_ptr->mimic && vanishable_feat(c_ptr->mimic)) c_ptr->mimic = floor_type[randint0(100)];
1586 c_ptr = &cave[y][cur_wid - 1];
1588 /* Lose room and vault */
1589 c_ptr->info &= ~(CAVE_ROOM | CAVE_ICKY);
1591 /* Set boundary mimic if needed */
1592 if (c_ptr->mimic && vanishable_feat(c_ptr->mimic)) c_ptr->mimic = floor_type[randint0(100)];
1595 /* Mega-Hack -- Forget the view and lite */
1596 p_ptr->update |= (PU_UN_VIEW | PU_UN_LITE);
1599 p_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MON_LITE);
1601 /* Update the monsters */
1602 p_ptr->update |= (PU_MONSTERS);
1605 p_ptr->redraw |= (PR_MAP);
1608 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
1614 void call_the_(void)
1618 bool do_call = TRUE;
1620 for (i = 0; i < 9; i++)
1622 y = py + ddy_ddd[i];
1623 x = px + ddx_ddd[i];
1625 if (!cave_floor_bold(y, x) && !boundary_floor_bold(y, x))
1634 for (i = 1; i < 10; i++)
1636 if (i - 5) fire_ball(GF_ROCKET, i, 175, 2);
1639 for (i = 1; i < 10; i++)
1641 if (i - 5) fire_ball(GF_MANA, i, 175, 3);
1644 for (i = 1; i < 10; i++)
1646 if (i - 5) fire_ball(GF_NUKE, i, 175, 4);
1650 /* Prevent destruction of quest levels and town */
1651 else if ((p_ptr->inside_quest && is_fixed_quest_idx(p_ptr->inside_quest)) || !dun_level)
1654 msg_print("ÃÏÌ̤¬Íɤ줿¡£");
1656 msg_print("The ground trembles.");
1663 msg_format("¤¢¤Ê¤¿¤Ï%s¤òÊɤ˶᤹¤®¤ë¾ì½ê¤Ç¾§¤¨¤Æ¤·¤Þ¤Ã¤¿¡ª",
1664 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "µ§¤ê" : "¼öʸ"));
1665 msg_print("Â礤ÊÇúȯ²»¤¬¤¢¤Ã¤¿¡ª");
1667 msg_format("You %s the %s too close to a wall!",
1668 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "recite" : "cast"),
1669 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "prayer" : "spell"));
1670 msg_print("There is a loud explosion!");
1676 if (!vanish_dungeon()) msg_print("¥À¥ó¥¸¥ç¥ó¤Ï°ì½ÖÀŤޤêÊ֤ä¿¡£");
1678 if (!vanish_dungeon()) msg_print("The dungeon silences a moment.");
1683 if (destroy_area(py, px, 15 + p_ptr->lev + randint0(11), FALSE))
1685 msg_print("¥À¥ó¥¸¥ç¥ó¤¬Êø²õ¤·¤¿...");
1687 msg_print("The dungeon collapses...");
1692 msg_print("¥À¥ó¥¸¥ç¥ó¤ÏÂ礤¯Íɤ줿¡£");
1694 msg_print("The dungeon trembles.");
1699 take_hit(DAMAGE_NOESCAPE, 100 + randint1(150), "¼«»¦Åª¤Êµõ̵¾·Íè", -1);
1701 take_hit(DAMAGE_NOESCAPE, 100 + randint1(150), "a suicidal Call the Void", -1);
1708 * Fetch an item (teleport it right underneath the caster)
1710 void fetch(int dir, int wgt, bool require_los)
1715 char o_name[MAX_NLEN];
1717 /* Check to see if an object is already there */
1718 if (cave[py][px].o_idx)
1721 msg_print("¼«Ê¬¤Î¤β¼¤Ë¤¢¤ëʪ¤Ï¼è¤ì¤Þ¤»¤ó¡£");
1723 msg_print("You can't fetch when you're already standing on something.");
1730 if (dir == 5 && target_okay())
1735 if (distance(py, px, ty, tx) > MAX_RANGE)
1738 msg_print("¤½¤ó¤Ê¤Ë±ó¤¯¤Ë¤¢¤ëʪ¤Ï¼è¤ì¤Þ¤»¤ó¡ª");
1740 msg_print("You can't fetch something that far away!");
1746 c_ptr = &cave[ty][tx];
1748 /* We need an item to fetch */
1752 msg_print("¤½¤³¤Ë¤Ï²¿¤â¤¢¤ê¤Þ¤»¤ó¡£");
1754 msg_print("There is no object at this place.");
1760 /* No fetching from vault */
1761 if (c_ptr->info & CAVE_ICKY)
1764 msg_print("¥¢¥¤¥Æ¥à¤¬¥³¥ó¥È¥í¡¼¥ë¤ò³°¤ì¤ÆÍî¤Á¤¿¡£");
1766 msg_print("The item slips from your control.");
1772 /* We need to see the item */
1773 if (require_los && !player_has_los_bold(ty, tx))
1776 msg_print("¤½¤³¤Ï¤¢¤Ê¤¿¤Î»ë³¦¤ËÆþ¤Ã¤Æ¤¤¤Þ¤»¤ó¡£");
1778 msg_print("You have no direct line of sight to that location.");
1786 /* Use a direction */
1787 ty = py; /* Where to drop the item */
1794 c_ptr = &cave[ty][tx];
1796 if ((distance(py, px, ty, tx) > MAX_RANGE) ||
1797 !cave_floor_bold(ty, tx)) return;
1799 while (!c_ptr->o_idx);
1802 o_ptr = &o_list[c_ptr->o_idx];
1804 if (o_ptr->weight > wgt)
1806 /* Too heavy to 'fetch' */
1808 msg_print("¤½¤Î¥¢¥¤¥Æ¥à¤Ï½Å²á¤®¤Þ¤¹¡£");
1810 msg_print("The object is too heavy.");
1817 c_ptr->o_idx = o_ptr->next_o_idx;
1818 cave[py][px].o_idx = i; /* 'move' it */
1819 o_ptr->next_o_idx = 0;
1820 o_ptr->iy = (byte)py;
1821 o_ptr->ix = (byte)px;
1823 object_desc(o_name, o_ptr, TRUE, 0);
1825 msg_format("%^s¤¬¤¢¤Ê¤¿¤Î¸µ¤ËÈô¤ó¤Ç¤¤¿¡£", o_name);
1827 msg_format("%^s flies through the air to your feet.", o_name);
1832 p_ptr->redraw |= PR_MAP;
1836 void alter_reality(void)
1838 /* Ironman option */
1839 if (p_ptr->inside_arena || ironman_downward)
1842 msg_print("²¿¤âµ¯¤³¤é¤Ê¤«¤Ã¤¿¡£");
1844 msg_print("Nothing happens.");
1849 if (!p_ptr->alter_reality)
1851 int turns = randint0(21) + 15;
1853 p_ptr->alter_reality = turns;
1855 msg_print("²ó¤ê¤Î·Ê¿§¤¬ÊѤï¤ê»Ï¤á¤¿...");
1857 msg_print("The view around you begins to change...");
1860 p_ptr->redraw |= (PR_STATUS);
1864 p_ptr->alter_reality = 0;
1866 msg_print("·Ê¿§¤¬¸µ¤ËÌá¤Ã¤¿...");
1868 msg_print("The view around you got back...");
1871 p_ptr->redraw |= (PR_STATUS);
1878 * Leave a "glyph of warding" which prevents monster movement
1880 bool warding_glyph(void)
1883 if (!cave_clean_bold(py, px))
1886 msg_print("¾²¾å¤Î¥¢¥¤¥Æ¥à¤¬¼öʸ¤òÄ·¤ÍÊÖ¤·¤¿¡£");
1888 msg_print("The object resists the spell.");
1894 /* Create a glyph */
1895 cave[py][px].info |= CAVE_OBJECT;
1896 cave[py][px].mimic = FEAT_GLYPH;
1907 bool warding_mirror(void)
1910 if (!cave_clean_bold(py, px))
1913 msg_print("¾²¾å¤Î¥¢¥¤¥Æ¥à¤¬¼öʸ¤òÄ·¤ÍÊÖ¤·¤¿¡£");
1915 msg_print("The object resists the spell.");
1921 /* Create a mirror */
1922 cave[py][px].info |= CAVE_OBJECT;
1923 cave[py][px].mimic = FEAT_MIRROR;
1925 /* Turn on the light */
1926 cave[py][px].info |= CAVE_GLOW;
1939 * Leave an "explosive rune" which prevents monster movement
1941 bool explosive_rune(void)
1944 if (!cave_clean_bold(py, px))
1947 msg_print("¾²¾å¤Î¥¢¥¤¥Æ¥à¤¬¼öʸ¤òÄ·¤ÍÊÖ¤·¤¿¡£");
1949 msg_print("The object resists the spell.");
1955 /* Create a glyph */
1956 cave[py][px].info |= CAVE_OBJECT;
1957 cave[py][px].mimic = FEAT_MINOR_GLYPH;
1970 * Identify everything being carried.
1971 * Done by a potion of "self knowledge".
1973 void identify_pack(void)
1977 /* Simply identify and know every item */
1978 for (i = 0; i < INVEN_TOTAL; i++)
1980 object_type *o_ptr = &inventory[i];
1982 /* Skip non-objects */
1983 if (!o_ptr->k_idx) continue;
1986 identify_item(o_ptr);
1992 * Used by the "enchant" function (chance of failure)
1993 * (modified for Zangband, we need better stuff there...) -- TY
1995 static int enchant_table[16] =
1997 0, 10, 50, 100, 200,
1998 300, 400, 500, 650, 800,
1999 950, 987, 993, 995, 998,
2005 * Removes curses from items in inventory
2007 * Note that Items which are "Perma-Cursed" (The One Ring,
2008 * The Crown of Morgoth) can NEVER be uncursed.
2010 * Note that if "all" is FALSE, then Items which are
2011 * "Heavy-Cursed" (Mormegil, Calris, and Weapons of Morgul)
2012 * will not be uncursed.
2014 static int remove_curse_aux(int all)
2018 /* Attempt to uncurse items being worn */
2019 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
2021 object_type *o_ptr = &inventory[i];
2023 /* Skip non-objects */
2024 if (!o_ptr->k_idx) continue;
2026 /* Uncursed already */
2027 if (!cursed_p(o_ptr)) continue;
2029 /* Heavily Cursed Items need a special spell */
2030 if (!all && (o_ptr->curse_flags & TRC_HEAVY_CURSE)) continue;
2032 /* Perma-Cursed Items can NEVER be uncursed */
2033 if (o_ptr->curse_flags & TRC_PERMA_CURSE)
2036 o_ptr->curse_flags &= (TRC_CURSED | TRC_HEAVY_CURSE | TRC_PERMA_CURSE);
2041 o_ptr->curse_flags = 0L;
2043 /* Hack -- Assume felt */
2044 o_ptr->ident |= (IDENT_SENSE);
2047 o_ptr->feeling = FEEL_NONE;
2049 /* Recalculate the bonuses */
2050 p_ptr->update |= (PU_BONUS);
2053 p_ptr->window |= (PW_EQUIP);
2055 /* Count the uncursings */
2059 /* Return "something uncursed" */
2065 * Remove most curses
2067 bool remove_curse(void)
2069 return (remove_curse_aux(FALSE));
2075 bool remove_all_curse(void)
2077 return (remove_curse_aux(TRUE));
2082 * Turns an object into gold, gain some of its value in a shop
2091 char o_name[MAX_NLEN];
2092 char out_val[MAX_NLEN+40];
2096 /* Hack -- force destruction */
2097 if (command_arg > 0) force = TRUE;
2101 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò¶â¤ËÊѤ¨¤Þ¤¹¤«¡©";
2102 s = "¶â¤ËÊѤ¨¤é¤ì¤ëʪ¤¬¤¢¤ê¤Þ¤»¤ó¡£";
2104 q = "Turn which item to gold? ";
2105 s = "You have nothing to turn to gold.";
2108 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return (FALSE);
2110 /* Get the item (in the pack) */
2113 o_ptr = &inventory[item];
2116 /* Get the item (on the floor) */
2119 o_ptr = &o_list[0 - item];
2123 /* See how many items */
2124 if (o_ptr->number > 1)
2126 /* Get a quantity */
2127 amt = get_quantity(NULL, o_ptr->number);
2129 /* Allow user abort */
2130 if (amt <= 0) return FALSE;
2134 /* Describe the object */
2135 old_number = o_ptr->number;
2136 o_ptr->number = amt;
2137 object_desc(o_name, o_ptr, TRUE, 3);
2138 o_ptr->number = old_number;
2140 /* Verify unless quantity given */
2143 if (confirm_destroy || (object_value(o_ptr) > 0))
2145 /* Make a verification */
2147 sprintf(out_val, "ËÜÅö¤Ë%s¤ò¶â¤ËÊѤ¨¤Þ¤¹¤«¡©", o_name);
2149 sprintf(out_val, "Really turn %s to gold? ", o_name);
2152 if (!get_check(out_val)) return FALSE;
2156 /* Artifacts cannot be destroyed */
2157 if (!can_player_destroy_object(o_ptr))
2161 msg_format("%s¤ò¶â¤ËÊѤ¨¤ë¤³¤È¤Ë¼ºÇÔ¤·¤¿¡£", o_name);
2163 msg_format("You fail to turn %s to gold!", o_name);
2170 price = object_value_real(o_ptr);
2176 msg_format("%s¤ò¥Ë¥»¤Î¶â¤ËÊѤ¨¤¿¡£", o_name);
2178 msg_format("You turn %s to fool's gold.", o_name);
2186 if (amt > 1) price *= amt;
2188 if (price > 30000) price = 30000;
2190 msg_format("%s¤ò¡ð%d ¤Î¶â¤ËÊѤ¨¤¿¡£", o_name, price);
2192 msg_format("You turn %s to %ld coins worth of gold.", o_name, price);
2198 p_ptr->redraw |= (PR_GOLD);
2201 p_ptr->window |= (PW_PLAYER);
2205 /* Eliminate the item (from the pack) */
2208 inven_item_increase(item, -amt);
2209 inven_item_describe(item);
2210 inven_item_optimize(item);
2213 /* Eliminate the item (from the floor) */
2216 floor_item_increase(0 - item, -amt);
2217 floor_item_describe(0 - item);
2218 floor_item_optimize(0 - item);
2227 * Hook to specify "weapon"
2229 bool item_tester_hook_weapon(object_type *o_ptr)
2231 switch (o_ptr->tval)
2245 if (o_ptr->sval != SV_DOKUBARI) return (TRUE);
2252 static bool item_tester_hook_weapon2(object_type *o_ptr)
2254 switch (o_ptr->tval)
2274 * Hook to specify "armour"
2276 bool item_tester_hook_armour(object_type *o_ptr)
2278 switch (o_ptr->tval)
2299 * Check if an object is weapon or armour (but not arrow, bolt, or shot)
2301 bool item_tester_hook_weapon_armour(object_type *o_ptr)
2303 switch (o_ptr->tval)
2332 * Check if an object is nameless weapon or armour
2334 static bool item_tester_hook_nameless_weapon_armour(object_type *o_ptr)
2336 switch (o_ptr->tval)
2355 if (o_ptr->name1 || o_ptr->art_name || o_ptr->name2 || o_ptr->xtra3)
2357 if (object_known_p(o_ptr)) return FALSE;
2367 * Break the curse of an item
2369 static void break_curse(object_type *o_ptr)
2371 if (cursed_p(o_ptr) && !(o_ptr->curse_flags & TRC_PERMA_CURSE) && !(o_ptr->curse_flags & TRC_HEAVY_CURSE) && (randint0(100) < 25))
2374 msg_print("¤«¤±¤é¤ì¤Æ¤¤¤¿¼ö¤¤¤¬ÂǤÁÇˤé¤ì¤¿¡ª");
2376 msg_print("The curse is broken!");
2379 o_ptr->curse_flags = 0L;
2381 o_ptr->ident |= (IDENT_SENSE);
2383 o_ptr->feeling = FEEL_NONE;
2389 * Enchants a plus onto an item. -RAK-
2391 * Revamped! Now takes item pointer, number of times to try enchanting,
2392 * and a flag of what to try enchanting. Artifacts resist enchantment
2393 * some of the time, and successful enchantment to at least +0 might
2394 * break a curse on the item. -CFT-
2396 * Note that an item can technically be enchanted all the way to +15 if
2397 * you wait a very, very, long time. Going from +9 to +10 only works
2398 * about 5% of the time, and from +10 to +11 only about 1% of the time.
2400 * Note that this function can now be used on "piles" of items, and
2401 * the larger the pile, the lower the chance of success.
2403 bool enchant(object_type *o_ptr, int n, int eflag)
2405 int i, chance, prob;
2407 bool a = (artifact_p(o_ptr) || o_ptr->art_name);
2408 bool force = (eflag & ENCH_FORCE);
2411 /* Large piles resist enchantment */
2412 prob = o_ptr->number * 100;
2414 /* Missiles are easy to enchant */
2415 if ((o_ptr->tval == TV_BOLT) ||
2416 (o_ptr->tval == TV_ARROW) ||
2417 (o_ptr->tval == TV_SHOT))
2423 for (i = 0; i < n; i++)
2425 /* Hack -- Roll for pile resistance */
2426 if (!force && randint0(prob) >= 100) continue;
2428 /* Enchant to hit */
2429 if (eflag & ENCH_TOHIT)
2431 if (o_ptr->to_h < 0) chance = 0;
2432 else if (o_ptr->to_h > 15) chance = 1000;
2433 else chance = enchant_table[o_ptr->to_h];
2435 if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50))))
2440 /* only when you get it above -1 -CFT */
2441 if (o_ptr->to_h >= 0)
2446 /* Enchant to damage */
2447 if (eflag & ENCH_TODAM)
2449 if (o_ptr->to_d < 0) chance = 0;
2450 else if (o_ptr->to_d > 15) chance = 1000;
2451 else chance = enchant_table[o_ptr->to_d];
2453 if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50))))
2458 /* only when you get it above -1 -CFT */
2459 if (o_ptr->to_d >= 0)
2464 /* Enchant to armor class */
2465 if (eflag & ENCH_TOAC)
2467 if (o_ptr->to_a < 0) chance = 0;
2468 else if (o_ptr->to_a > 15) chance = 1000;
2469 else chance = enchant_table[o_ptr->to_a];
2471 if (force || ((randint1(1000) > chance) && (!a || (randint0(100) < 50))))
2476 /* only when you get it above -1 -CFT */
2477 if (o_ptr->to_a >= 0)
2484 if (!res) return (FALSE);
2486 /* Recalculate bonuses */
2487 p_ptr->update |= (PU_BONUS);
2489 /* Combine / Reorder the pack (later) */
2490 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
2493 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
2504 * Enchant an item (in the inventory or on the floor)
2505 * Note that "num_ac" requires armour, else weapon
2506 * Returns TRUE if attempted, FALSE if cancelled
2508 bool enchant_spell(int num_hit, int num_dam, int num_ac)
2513 char o_name[MAX_NLEN];
2517 /* Assume enchant weapon */
2518 item_tester_hook = item_tester_hook_weapon;
2519 item_tester_no_ryoute = TRUE;
2521 /* Enchant armor if requested */
2522 if (num_ac) item_tester_hook = item_tester_hook_armour;
2526 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò¶¯²½¤·¤Þ¤¹¤«? ";
2527 s = "¶¯²½¤Ç¤¤ë¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
2529 q = "Enchant which item? ";
2530 s = "You have nothing to enchant.";
2533 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2535 /* Get the item (in the pack) */
2538 o_ptr = &inventory[item];
2541 /* Get the item (on the floor) */
2544 o_ptr = &o_list[0 - item];
2549 object_desc(o_name, o_ptr, FALSE, 0);
2553 msg_format("%s ¤ÏÌÀ¤ë¤¯µ±¤¤¤¿¡ª",
2556 msg_format("%s %s glow%s brightly!",
2557 ((item >= 0) ? "Your" : "The"), o_name,
2558 ((o_ptr->number > 1) ? "" : "s"));
2563 if (enchant(o_ptr, num_hit, ENCH_TOHIT)) okay = TRUE;
2564 if (enchant(o_ptr, num_dam, ENCH_TODAM)) okay = TRUE;
2565 if (enchant(o_ptr, num_ac, ENCH_TOAC)) okay = TRUE;
2571 if (flush_failure) flush();
2575 msg_print("¶¯²½¤Ë¼ºÇÔ¤·¤¿¡£");
2577 msg_print("The enchantment failed.");
2580 if (one_in_(3)) chg_virtue(V_ENCHANT, -1);
2583 chg_virtue(V_ENCHANT, 1);
2587 /* Something happened */
2592 bool artifact_scroll(void)
2597 char o_name[MAX_NLEN];
2601 item_tester_no_ryoute = TRUE;
2602 /* Enchant weapon/armour */
2603 item_tester_hook = item_tester_hook_nameless_weapon_armour;
2607 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò¶¯²½¤·¤Þ¤¹¤«? ";
2608 s = "¶¯²½¤Ç¤¤ë¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
2610 q = "Enchant which item? ";
2611 s = "You have nothing to enchant.";
2614 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2616 /* Get the item (in the pack) */
2619 o_ptr = &inventory[item];
2622 /* Get the item (on the floor) */
2625 o_ptr = &o_list[0 - item];
2630 object_desc(o_name, o_ptr, FALSE, 0);
2634 msg_format("%s ¤ÏâÁ¤¤¸÷¤òȯ¤·¤¿¡ª",o_name);
2636 msg_format("%s %s radiate%s a blinding light!",
2637 ((item >= 0) ? "Your" : "The"), o_name,
2638 ((o_ptr->number > 1) ? "" : "s"));
2641 if (o_ptr->name1 || o_ptr->art_name)
2644 msg_format("%s¤Ï´û¤ËÅÁÀâ¤Î¥¢¥¤¥Æ¥à¤Ç¤¹¡ª", o_name );
2646 msg_format("The %s %s already %s!",
2647 o_name, ((o_ptr->number > 1) ? "are" : "is"),
2648 ((o_ptr->number > 1) ? "artifacts" : "an artifact"));
2654 else if (o_ptr->name2)
2657 msg_format("%s¤Ï´û¤Ë̾¤Î¤¢¤ë¥¢¥¤¥Æ¥à¤Ç¤¹¡ª", o_name );
2659 msg_format("The %s %s already %s!",
2660 o_name, ((o_ptr->number > 1) ? "are" : "is"),
2661 ((o_ptr->number > 1) ? "ego items" : "an ego item"));
2667 else if (o_ptr->xtra3)
2670 msg_format("%s¤Ï´û¤Ë¶¯²½¤µ¤ì¤Æ¤¤¤Þ¤¹¡ª", o_name );
2672 msg_format("The %s %s already %s!",
2673 o_name, ((o_ptr->number > 1) ? "are" : "is"),
2674 ((o_ptr->number > 1) ? "customized items" : "a customized item"));
2680 if (o_ptr->number > 1)
2683 msg_print("Ê£¿ô¤Î¥¢¥¤¥Æ¥à¤ËËâË¡¤ò¤«¤±¤ë¤À¤±¤Î¥¨¥Í¥ë¥®¡¼¤Ï¤¢¤ê¤Þ¤»¤ó¡ª");
2684 msg_format("%d ¸Ä¤Î%s¤¬²õ¤ì¤¿¡ª",(o_ptr->number)-1, o_name);
2686 msg_print("Not enough enough energy to enchant more than one object!");
2687 msg_format("%d of your %s %s destroyed!",(o_ptr->number)-1, o_name, (o_ptr->number>2?"were":"was"));
2692 inven_item_increase(item, 1-(o_ptr->number));
2696 floor_item_increase(0-item, 1-(o_ptr->number));
2699 okay = create_artifact(o_ptr, TRUE);
2706 if (flush_failure) flush();
2710 msg_print("¶¯²½¤Ë¼ºÇÔ¤·¤¿¡£");
2712 msg_print("The enchantment failed.");
2715 if (one_in_(3)) chg_virtue(V_ENCHANT, -1);
2718 chg_virtue(V_ENCHANT, 1);
2722 /* Something happened */
2728 * Identify an object
2730 bool identify_item(object_type *o_ptr)
2732 bool old_known = FALSE;
2733 char o_name[MAX_NLEN];
2736 object_desc(o_name, o_ptr, TRUE, 3);
2738 if (o_ptr->ident & IDENT_KNOWN)
2741 if (!(o_ptr->ident & (IDENT_MENTAL)))
2743 if ((o_ptr->art_name) || (artifact_p(o_ptr)) || one_in_(5))
2744 chg_virtue(V_KNOWLEDGE, 1);
2747 /* Identify it fully */
2748 object_aware(o_ptr);
2749 object_known(o_ptr);
2751 /* Recalculate bonuses */
2752 p_ptr->update |= (PU_BONUS);
2754 /* Combine / Reorder the pack (later) */
2755 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
2758 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
2760 strcpy(record_o_name, o_name);
2764 object_desc(o_name, o_ptr, TRUE, 0);
2766 if(record_fix_art && !old_known && artifact_p(o_ptr))
2767 do_cmd_write_nikki(NIKKI_ART, 0, o_name);
2768 if(record_rand_art && !old_known && o_ptr->art_name)
2769 do_cmd_write_nikki(NIKKI_ART, 0, o_name);
2775 static bool item_tester_hook_identify(object_type *o_ptr)
2777 return (bool)!object_known_p(o_ptr);
2780 static bool item_tester_hook_identify_weapon_armour(object_type *o_ptr)
2782 if (object_known_p(o_ptr))
2784 return item_tester_hook_weapon_armour(o_ptr);
2788 * Identify an object in the inventory (or on the floor)
2789 * This routine does *not* automatically combine objects.
2790 * Returns TRUE if something was identified, else FALSE.
2792 bool ident_spell(bool only_equip)
2796 char o_name[MAX_NLEN];
2801 item_tester_no_ryoute = TRUE;
2804 item_tester_hook = item_tester_hook_identify_weapon_armour;
2806 item_tester_hook = item_tester_hook_identify;
2808 if (!can_get_item())
2812 item_tester_hook = item_tester_hook_weapon_armour;
2816 item_tester_hook = NULL;
2822 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò´ÕÄꤷ¤Þ¤¹¤«? ";
2823 s = "´ÕÄꤹ¤ë¤Ù¤¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
2825 q = "Identify which item? ";
2826 s = "You have nothing to identify.";
2829 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2831 /* Get the item (in the pack) */
2834 o_ptr = &inventory[item];
2837 /* Get the item (on the floor) */
2840 o_ptr = &o_list[0 - item];
2844 old_known = identify_item(o_ptr);
2847 object_desc(o_name, o_ptr, TRUE, 3);
2850 if (item >= INVEN_RARM)
2853 msg_format("%^s: %s(%c)¡£", describe_use(item), o_name, index_to_label(item));
2855 msg_format("%^s: %s (%c).", describe_use(item), o_name, index_to_label(item));
2861 msg_format("¥¶¥Ã¥¯Ãæ: %s(%c)¡£", o_name, index_to_label(item));
2863 msg_format("In your pack: %s (%c).", o_name, index_to_label(item));
2869 msg_format("¾²¾å: %s¡£", o_name);
2871 msg_format("On the ground: %s.", o_name);
2875 /* Auto-inscription/destroy */
2876 idx = is_autopick(o_ptr);
2877 auto_inscribe_item(item, idx);
2878 if (destroy_identify && !old_known)
2879 auto_destroy_item(item, idx);
2881 /* Something happened */
2887 * Mundanify an object in the inventory (or on the floor)
2888 * This routine does *not* automatically combine objects.
2889 * Returns TRUE if something was mundanified, else FALSE.
2891 bool mundane_spell(bool only_equip)
2897 if (only_equip) item_tester_hook = item_tester_hook_weapon_armour;
2898 item_tester_no_ryoute = TRUE;
2902 q = "¤É¤ì¤ò»È¤¤¤Þ¤¹¤«¡©";
2903 s = "»È¤¨¤ë¤â¤Î¤¬¤¢¤ê¤Þ¤»¤ó¡£";
2905 q = "Use which item? ";
2906 s = "You have nothing you can use.";
2909 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
2911 /* Get the item (in the pack) */
2914 o_ptr = &inventory[item];
2917 /* Get the item (on the floor) */
2920 o_ptr = &o_list[0 - item];
2925 msg_print("¤Þ¤Ð¤æ¤¤Á®¸÷¤¬Áö¤Ã¤¿¡ª");
2927 msg_print("There is a bright flash of light!");
2930 byte iy = o_ptr->iy; /* Y-position on map, or zero */
2931 byte ix = o_ptr->ix; /* X-position on map, or zero */
2932 s16b next_o_idx = o_ptr->next_o_idx; /* Next object in stack (if any) */
2933 byte marked = o_ptr->marked; /* Object is marked */
2934 s16b weight = o_ptr->number * o_ptr->weight;
2935 u16b inscription = o_ptr->inscription;
2938 object_prep(o_ptr, o_ptr->k_idx);
2942 o_ptr->next_o_idx = next_o_idx;
2943 o_ptr->marked = marked;
2944 o_ptr->inscription = inscription;
2945 if (item >= 0) p_ptr->total_weight += (o_ptr->weight - weight);
2949 /* Something happened */
2955 static bool item_tester_hook_identify_fully(object_type *o_ptr)
2957 return (bool)(!object_known_p(o_ptr) || !(o_ptr->ident & IDENT_MENTAL));
2960 static bool item_tester_hook_identify_fully_weapon_armour(object_type *o_ptr)
2962 if (!item_tester_hook_identify_fully(o_ptr))
2964 return item_tester_hook_weapon_armour(o_ptr);
2968 * Fully "identify" an object in the inventory -BEN-
2969 * This routine returns TRUE if an item was identified.
2971 bool identify_fully(bool only_equip)
2975 char o_name[MAX_NLEN];
2980 item_tester_no_ryoute = TRUE;
2982 item_tester_hook = item_tester_hook_identify_fully_weapon_armour;
2984 item_tester_hook = item_tester_hook_identify_fully;
2986 if (!can_get_item())
2989 item_tester_hook = item_tester_hook_weapon_armour;
2991 item_tester_hook = NULL;
2996 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò´ÕÄꤷ¤Þ¤¹¤«? ";
2997 s = "´ÕÄꤹ¤ë¤Ù¤¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
2999 q = "Identify which item? ";
3000 s = "You have nothing to identify.";
3003 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return (FALSE);
3005 /* Get the item (in the pack) */
3008 o_ptr = &inventory[item];
3011 /* Get the item (on the floor) */
3014 o_ptr = &o_list[0 - item];
3018 old_known = identify_item(o_ptr);
3020 /* Mark the item as fully known */
3021 o_ptr->ident |= (IDENT_MENTAL);
3027 object_desc(o_name, o_ptr, TRUE, 3);
3030 if (item >= INVEN_RARM)
3033 msg_format("%^s: %s(%c)¡£", describe_use(item), o_name, index_to_label(item));
3035 msg_format("%^s: %s (%c).", describe_use(item), o_name, index_to_label(item));
3043 msg_format("¥¶¥Ã¥¯Ãæ: %s(%c)¡£", o_name, index_to_label(item));
3045 msg_format("In your pack: %s (%c).", o_name, index_to_label(item));
3051 msg_format("¾²¾å: %s¡£", o_name);
3053 msg_format("On the ground: %s.", o_name);
3057 /* Describe it fully */
3058 (void)screen_object(o_ptr, TRUE);
3060 /* Auto-inscription/destroy */
3061 idx = is_autopick(o_ptr);
3062 auto_inscribe_item(item, idx);
3063 if (destroy_identify && !old_known)
3064 auto_destroy_item(item, idx);
3074 * Hook for "get_item()". Determine if something is rechargable.
3076 bool item_tester_hook_recharge(object_type *o_ptr)
3078 /* Recharge staffs */
3079 if (o_ptr->tval == TV_STAFF) return (TRUE);
3081 /* Recharge wands */
3082 if (o_ptr->tval == TV_WAND) return (TRUE);
3084 /* Hack -- Recharge rods */
3085 if (o_ptr->tval == TV_ROD) return (TRUE);
3093 * Recharge a wand/staff/rod from the pack or on the floor.
3094 * This function has been rewritten in Oangband and ZAngband.
3096 * Sorcery/Arcane -- Recharge --> recharge(plev * 4)
3097 * Chaos -- Arcane Binding --> recharge(90)
3099 * Scroll of recharging --> recharge(130)
3100 * Artifact activation/Thingol --> recharge(130)
3102 * It is harder to recharge high level, and highly charged wands,
3103 * staffs, and rods. The more wands in a stack, the more easily and
3104 * strongly they recharge. Staffs, however, each get fewer charges if
3107 * XXX XXX XXX Beware of "sliding index errors".
3109 bool recharge(int power)
3112 int recharge_strength, recharge_amount;
3121 char o_name[MAX_NLEN];
3123 /* Only accept legal items */
3124 item_tester_hook = item_tester_hook_recharge;
3128 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ËËâÎϤò½¼Å¶¤·¤Þ¤¹¤«? ";
3129 s = "ËâÎϤò½¼Å¶¤¹¤Ù¤¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
3131 q = "Recharge which item? ";
3132 s = "You have nothing to recharge.";
3135 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return (FALSE);
3137 /* Get the item (in the pack) */
3140 o_ptr = &inventory[item];
3143 /* Get the item (on the floor) */
3146 o_ptr = &o_list[0 - item];
3149 /* Get the object kind. */
3150 k_ptr = &k_info[o_ptr->k_idx];
3152 /* Extract the object "level" */
3153 lev = get_object_level(o_ptr);
3156 /* Recharge a rod */
3157 if (o_ptr->tval == TV_ROD)
3159 /* Extract a recharge strength by comparing object level to power. */
3160 recharge_strength = ((power > lev/2) ? (power - lev/2) : 0) / 5;
3164 if (one_in_(recharge_strength))
3166 /* Activate the failure code. */
3173 /* Recharge amount */
3174 recharge_amount = (power * damroll(3, 2));
3176 /* Recharge by that amount */
3177 if (o_ptr->timeout > recharge_amount)
3178 o_ptr->timeout -= recharge_amount;
3185 /* Recharge wand/staff */
3188 /* Extract a recharge strength by comparing object level to power.
3189 * Divide up a stack of wands' charges to calculate charge penalty.
3191 if ((o_ptr->tval == TV_WAND) && (o_ptr->number > 1))
3192 recharge_strength = (100 + power - lev -
3193 (8 * o_ptr->pval / o_ptr->number)) / 15;
3195 /* All staffs, unstacked wands. */
3196 else recharge_strength = (100 + power - lev -
3197 (8 * o_ptr->pval)) / 15;
3200 if (recharge_strength < 0) recharge_strength = 0;
3203 if (one_in_(recharge_strength))
3205 /* Activate the failure code. */
3209 /* If the spell didn't backfire, recharge the wand or staff. */
3212 /* Recharge based on the standard number of charges. */
3213 recharge_amount = randint1(1 + k_ptr->pval / 2);
3215 /* Multiple wands in a stack increase recharging somewhat. */
3216 if ((o_ptr->tval == TV_WAND) && (o_ptr->number > 1))
3219 (randint1(recharge_amount * (o_ptr->number - 1))) / 2;
3220 if (recharge_amount < 1) recharge_amount = 1;
3221 if (recharge_amount > 12) recharge_amount = 12;
3224 /* But each staff in a stack gets fewer additional charges,
3225 * although always at least one.
3227 if ((o_ptr->tval == TV_STAFF) && (o_ptr->number > 1))
3229 recharge_amount /= o_ptr->number;
3230 if (recharge_amount < 1) recharge_amount = 1;
3233 /* Recharge the wand or staff. */
3234 o_ptr->pval += recharge_amount;
3237 /* Hack -- we no longer "know" the item */
3238 o_ptr->ident &= ~(IDENT_KNOWN);
3240 /* Hack -- we no longer think the item is empty */
3241 o_ptr->ident &= ~(IDENT_EMPTY);
3246 /* Inflict the penalties for failing a recharge. */
3249 /* Artifacts are never destroyed. */
3250 if (artifact_p(o_ptr))
3252 object_desc(o_name, o_ptr, TRUE, 0);
3254 msg_format("ËâÎϤ¬µÕή¤·¤¿¡ª%s¤Ï´°Á´¤ËËâÎϤò¼º¤Ã¤¿¡£", o_name);
3256 msg_format("The recharging backfires - %s is completely drained!", o_name);
3260 /* Artifact rods. */
3261 if ((o_ptr->tval == TV_ROD) && (o_ptr->timeout < 10000))
3262 o_ptr->timeout = (o_ptr->timeout + 100) * 2;
3264 /* Artifact wands and staffs. */
3265 else if ((o_ptr->tval == TV_WAND) || (o_ptr->tval == TV_STAFF))
3270 /* Get the object description */
3271 object_desc(o_name, o_ptr, FALSE, 0);
3273 /*** Determine Seriousness of Failure ***/
3275 /* Mages recharge objects more safely. */
3276 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)
3278 /* 10% chance to blow up one rod, otherwise draining. */
3279 if (o_ptr->tval == TV_ROD)
3281 if (one_in_(10)) fail_type = 2;
3284 /* 75% chance to blow up one wand, otherwise draining. */
3285 else if (o_ptr->tval == TV_WAND)
3287 if (!one_in_(3)) fail_type = 2;
3290 /* 50% chance to blow up one staff, otherwise no effect. */
3291 else if (o_ptr->tval == TV_STAFF)
3293 if (one_in_(2)) fail_type = 2;
3298 /* All other classes get no special favors. */
3301 /* 33% chance to blow up one rod, otherwise draining. */
3302 if (o_ptr->tval == TV_ROD)
3304 if (one_in_(3)) fail_type = 2;
3307 /* 20% chance of the entire stack, else destroy one wand. */
3308 else if (o_ptr->tval == TV_WAND)
3310 if (one_in_(5)) fail_type = 3;
3313 /* Blow up one staff. */
3314 else if (o_ptr->tval == TV_STAFF)
3320 /*** Apply draining and destruction. ***/
3322 /* Drain object or stack of objects. */
3325 if (o_ptr->tval == TV_ROD)
3328 msg_print("ËâÎϤ¬µÕÊ®¼Í¤·¤Æ¡¢¥í¥Ã¥É¤«¤é¤µ¤é¤ËËâÎϤòµÛ¤¤¼è¤Ã¤Æ¤·¤Þ¤Ã¤¿¡ª");
3330 msg_print("The recharge backfires, draining the rod further!");
3333 if (o_ptr->timeout < 10000)
3334 o_ptr->timeout = (o_ptr->timeout + 100) * 2;
3336 else if (o_ptr->tval == TV_WAND)
3339 msg_format("%s¤ÏÇË»¤òÌȤ줿¤¬¡¢ËâÎϤ¬Á´¤Æ¼º¤ï¤ì¤¿¡£", o_name);
3341 msg_format("You save your %s from destruction, but all charges are lost.", o_name);
3346 /* Staffs aren't drained. */
3349 /* Destroy an object or one in a stack of objects. */
3352 if (o_ptr->number > 1)
3354 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬°ìËܲõ¤ì¤¿¡ª", o_name);
3356 msg_format("Wild magic consumes one of your %s!", o_name);
3361 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬²õ¤ì¤¿¡ª", o_name);
3363 msg_format("Wild magic consumes your %s!", o_name);
3367 /* Reduce rod stack maximum timeout, drain wands. */
3368 if (o_ptr->tval == TV_ROD) o_ptr->timeout = (o_ptr->number - 1) * k_ptr->pval;
3369 if (o_ptr->tval == TV_WAND) o_ptr->pval = 0;
3371 /* Reduce and describe inventory */
3374 inven_item_increase(item, -1);
3375 inven_item_describe(item);
3376 inven_item_optimize(item);
3379 /* Reduce and describe floor item */
3382 floor_item_increase(0 - item, -1);
3383 floor_item_describe(0 - item);
3384 floor_item_optimize(0 - item);
3388 /* Destroy all members of a stack of objects. */
3391 if (o_ptr->number > 1)
3393 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬Á´¤Æ²õ¤ì¤¿¡ª", o_name);
3395 msg_format("Wild magic consumes all your %s!", o_name);
3400 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬²õ¤ì¤¿¡ª", o_name);
3402 msg_format("Wild magic consumes your %s!", o_name);
3407 /* Reduce and describe inventory */
3410 inven_item_increase(item, -999);
3411 inven_item_describe(item);
3412 inven_item_optimize(item);
3415 /* Reduce and describe floor item */
3418 floor_item_increase(0 - item, -999);
3419 floor_item_describe(0 - item);
3420 floor_item_optimize(0 - item);
3426 /* Combine / Reorder the pack (later) */
3427 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
3430 p_ptr->window |= (PW_INVEN);
3432 /* Something was done */
3440 bool bless_weapon(void)
3444 u32b flgs[TR_FLAG_SIZE];
3445 char o_name[MAX_NLEN];
3448 item_tester_no_ryoute = TRUE;
3449 /* Assume enchant weapon */
3450 item_tester_hook = item_tester_hook_weapon2;
3454 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò½ËÊ¡¤·¤Þ¤¹¤«¡©";
3455 s = "½ËÊ¡¤Ç¤¤ëÉð´ï¤¬¤¢¤ê¤Þ¤»¤ó¡£";
3457 q = "Bless which weapon? ";
3458 s = "You have weapon to bless.";
3461 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR)))
3464 /* Get the item (in the pack) */
3467 o_ptr = &inventory[item];
3470 /* Get the item (on the floor) */
3473 o_ptr = &o_list[0 - item];
3478 object_desc(o_name, o_ptr, FALSE, 0);
3480 /* Extract the flags */
3481 object_flags(o_ptr, flgs);
3483 if (cursed_p(o_ptr))
3485 if (((o_ptr->curse_flags & TRC_HEAVY_CURSE) && (randint1(100) < 33)) ||
3486 (o_ptr->curse_flags & TRC_PERMA_CURSE))
3489 msg_format("%s¤òʤ¤¦¹õ¤¤¥ª¡¼¥é¤Ï½ËÊ¡¤òÄ·¤ÍÊÖ¤·¤¿¡ª",
3492 msg_format("The black aura on %s %s disrupts the blessing!",
3493 ((item >= 0) ? "your" : "the"), o_name);
3500 msg_format("%s ¤«¤é¼Ù°¤Ê¥ª¡¼¥é¤¬¾Ã¤¨¤¿¡£",
3503 msg_format("A malignant aura leaves %s %s.",
3504 ((item >= 0) ? "your" : "the"), o_name);
3509 o_ptr->curse_flags = 0L;
3511 /* Hack -- Assume felt */
3512 o_ptr->ident |= (IDENT_SENSE);
3515 o_ptr->feeling = FEEL_NONE;
3517 /* Recalculate the bonuses */
3518 p_ptr->update |= (PU_BONUS);
3521 p_ptr->window |= (PW_EQUIP);
3525 * Next, we try to bless it. Artifacts have a 1/3 chance of
3526 * being blessed, otherwise, the operation simply disenchants
3527 * them, godly power negating the magic. Ok, the explanation
3528 * is silly, but otherwise priests would always bless every
3529 * artifact weapon they find. Ego weapons and normal weapons
3530 * can be blessed automatically.
3532 if (have_flag(flgs, TR_BLESSED))
3535 msg_format("%s ¤Ï´û¤Ë½ËÊ¡¤µ¤ì¤Æ¤¤¤ë¡£",
3538 msg_format("%s %s %s blessed already.",
3539 ((item >= 0) ? "Your" : "The"), o_name,
3540 ((o_ptr->number > 1) ? "were" : "was"));
3546 if (!(o_ptr->art_name || o_ptr->name1 || o_ptr->name2) || one_in_(3))
3550 msg_format("%s¤Ïµ±¤¤¤¿¡ª",
3553 msg_format("%s %s shine%s!",
3554 ((item >= 0) ? "Your" : "The"), o_name,
3555 ((o_ptr->number > 1) ? "" : "s"));
3558 add_flag(o_ptr->art_flags, TR_BLESSED);
3559 o_ptr->discount = 99;
3563 bool dis_happened = FALSE;
3566 msg_print("¤½¤ÎÉð´ï¤Ï½ËÊ¡¤ò·ù¤Ã¤Æ¤¤¤ë¡ª");
3568 msg_print("The weapon resists your blessing!");
3572 /* Disenchant tohit */
3573 if (o_ptr->to_h > 0)
3576 dis_happened = TRUE;
3579 if ((o_ptr->to_h > 5) && (randint0(100) < 33)) o_ptr->to_h--;
3581 /* Disenchant todam */
3582 if (o_ptr->to_d > 0)
3585 dis_happened = TRUE;
3588 if ((o_ptr->to_d > 5) && (randint0(100) < 33)) o_ptr->to_d--;
3590 /* Disenchant toac */
3591 if (o_ptr->to_a > 0)
3594 dis_happened = TRUE;
3597 if ((o_ptr->to_a > 5) && (randint0(100) < 33)) o_ptr->to_a--;
3602 msg_print("¼þ°Ï¤¬ËÞÍǤÊÊ·°Ïµ¤¤ÇËþ¤Á¤¿...");
3604 msg_print("There is a static feeling in the air...");
3608 msg_format("%s ¤ÏÎô²½¤·¤¿¡ª",
3611 msg_format("%s %s %s disenchanted!",
3612 ((item >= 0) ? "Your" : "The"), o_name,
3613 ((o_ptr->number > 1) ? "were" : "was"));
3619 /* Recalculate bonuses */
3620 p_ptr->update |= (PU_BONUS);
3623 p_ptr->window |= (PW_EQUIP | PW_PLAYER);
3634 bool pulish_shield(void)
3638 u32b flgs[TR_FLAG_SIZE];
3639 char o_name[MAX_NLEN];
3642 item_tester_no_ryoute = TRUE;
3643 /* Assume enchant weapon */
3644 item_tester_tval = TV_SHIELD;
3648 q = "¤É¤Î½â¤òËᤤޤ¹¤«¡©";
3649 s = "Ë᤯½â¤¬¤¢¤ê¤Þ¤»¤ó¡£";
3651 q = "Pulish which weapon? ";
3652 s = "You have weapon to pulish.";
3655 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR)))
3658 /* Get the item (in the pack) */
3661 o_ptr = &inventory[item];
3664 /* Get the item (on the floor) */
3667 o_ptr = &o_list[0 - item];
3672 object_desc(o_name, o_ptr, FALSE, 0);
3674 /* Extract the flags */
3675 object_flags(o_ptr, flgs);
3677 if (o_ptr->k_idx && !artifact_p(o_ptr) && !ego_item_p(o_ptr) &&
3678 !o_ptr->art_name && !cursed_p(o_ptr) && (o_ptr->sval != SV_MIRROR_SHIELD))
3681 msg_format("%s¤Ïµ±¤¤¤¿¡ª", o_name);
3683 msg_format("%s %s shine%s!",
3684 ((item >= 0) ? "Your" : "The"), o_name,
3685 ((o_ptr->number > 1) ? "" : "s"));
3687 o_ptr->name2 = EGO_REFLECTION;
3688 enchant(o_ptr, randint0(3) + 4, ENCH_TOAC);
3690 o_ptr->discount = 99;
3691 chg_virtue(V_ENCHANT, 2);
3697 if (flush_failure) flush();
3700 msg_print("¼ºÇÔ¤·¤¿¡£");
3702 msg_print("Failed.");
3705 chg_virtue(V_ENCHANT, -2);
3714 * Potions "smash open" and cause an area effect when
3715 * (1) they are shattered while in the player's inventory,
3716 * due to cold (etc) attacks;
3717 * (2) they are thrown at a monster, or obstacle;
3718 * (3) they are shattered by a "cold ball" or other such spell
3719 * while lying on the floor.
3722 * who --- who caused the potion to shatter (0=player)
3723 * potions that smash on the floor are assumed to
3724 * be caused by no-one (who = 1), as are those that
3725 * shatter inside the player inventory.
3726 * (Not anymore -- I changed this; TY)
3727 * y, x --- coordinates of the potion (or player if
3728 * the potion was in her inventory);
3729 * o_ptr --- pointer to the potion object.
3731 bool potion_smash_effect(int who, int y, int x, int k_idx)
3738 object_kind *k_ptr = &k_info[k_idx];
3740 switch (k_ptr->sval)
3742 case SV_POTION_SALT_WATER:
3743 case SV_POTION_SLIME_MOLD:
3744 case SV_POTION_LOSE_MEMORIES:
3745 case SV_POTION_DEC_STR:
3746 case SV_POTION_DEC_INT:
3747 case SV_POTION_DEC_WIS:
3748 case SV_POTION_DEC_DEX:
3749 case SV_POTION_DEC_CON:
3750 case SV_POTION_DEC_CHR:
3751 case SV_POTION_WATER: /* perhaps a 'water' attack? */
3752 case SV_POTION_APPLE_JUICE:
3755 case SV_POTION_INFRAVISION:
3756 case SV_POTION_DETECT_INVIS:
3757 case SV_POTION_SLOW_POISON:
3758 case SV_POTION_CURE_POISON:
3759 case SV_POTION_BOLDNESS:
3760 case SV_POTION_RESIST_HEAT:
3761 case SV_POTION_RESIST_COLD:
3762 case SV_POTION_HEROISM:
3763 case SV_POTION_BESERK_STRENGTH:
3764 case SV_POTION_RES_STR:
3765 case SV_POTION_RES_INT:
3766 case SV_POTION_RES_WIS:
3767 case SV_POTION_RES_DEX:
3768 case SV_POTION_RES_CON:
3769 case SV_POTION_RES_CHR:
3770 case SV_POTION_INC_STR:
3771 case SV_POTION_INC_INT:
3772 case SV_POTION_INC_WIS:
3773 case SV_POTION_INC_DEX:
3774 case SV_POTION_INC_CON:
3775 case SV_POTION_INC_CHR:
3776 case SV_POTION_AUGMENTATION:
3777 case SV_POTION_ENLIGHTENMENT:
3778 case SV_POTION_STAR_ENLIGHTENMENT:
3779 case SV_POTION_SELF_KNOWLEDGE:
3780 case SV_POTION_EXPERIENCE:
3781 case SV_POTION_RESISTANCE:
3782 case SV_POTION_INVULNERABILITY:
3783 case SV_POTION_NEW_LIFE:
3784 /* All of the above potions have no effect when shattered */
3786 case SV_POTION_SLOWNESS:
3791 case SV_POTION_POISON:
3796 case SV_POTION_BLINDNESS:
3800 case SV_POTION_CONFUSION: /* Booze */
3804 case SV_POTION_SLEEP:
3808 case SV_POTION_RUINATION:
3809 case SV_POTION_DETONATIONS:
3811 dam = damroll(25, 25);
3814 case SV_POTION_DEATH:
3815 dt = GF_DEATH_RAY; /* !! */
3816 dam = k_ptr->level * 10;
3820 case SV_POTION_SPEED:
3823 case SV_POTION_CURE_LIGHT:
3825 dam = damroll(2, 3);
3827 case SV_POTION_CURE_SERIOUS:
3829 dam = damroll(4, 3);
3831 case SV_POTION_CURE_CRITICAL:
3832 case SV_POTION_CURING:
3834 dam = damroll(6, 3);
3836 case SV_POTION_HEALING:
3838 dam = damroll(10, 10);
3840 case SV_POTION_RESTORE_EXP:
3845 case SV_POTION_LIFE:
3847 dam = damroll(50, 50);
3850 case SV_POTION_STAR_HEALING:
3852 dam = damroll(50, 50);
3855 case SV_POTION_RESTORE_MANA: /* MANA */
3857 dam = damroll(10, 10);
3864 (void)project(who, radius, y, x, dam, dt,
3865 (PROJECT_JUMP | PROJECT_ITEM | PROJECT_KILL), -1);
3867 /* XXX those potions that explode need to become "known" */
3873 * Hack -- Display all known spells in a window
3875 * XXX XXX XXX Need to analyze size of the window.
3877 * XXX XXX XXX Need more color coding.
3879 void display_spell_list(void)
3892 /* They have too many spells to list */
3893 if (p_ptr->pclass == CLASS_SORCERER) return;
3894 if (p_ptr->pclass == CLASS_RED_MAGE) return;
3896 /* mind.c type classes */
3897 if ((p_ptr->pclass == CLASS_MINDCRAFTER) ||
3898 (p_ptr->pclass == CLASS_BERSERKER) ||
3899 (p_ptr->pclass == CLASS_NINJA) ||
3900 (p_ptr->pclass == CLASS_MIRROR_MASTER) ||
3901 (p_ptr->pclass == CLASS_FORCETRAINER))
3907 int plev = p_ptr->lev;
3913 bool use_hp = FALSE;
3915 /* Display a list of spells */
3918 put_str("̾Á°", y, x + 5);
3919 put_str("Lv MP ¼ºÎ¨ ¸ú²Ì", y, x + 35);
3921 put_str("Name", y, x + 5);
3922 put_str("Lv Mana Fail Info", y, x + 35);
3925 switch(p_ptr->pclass)
3927 case CLASS_MINDCRAFTER: use_mind = MIND_MINDCRAFTER;break;
3928 case CLASS_FORCETRAINER: use_mind = MIND_KI;break;
3929 case CLASS_BERSERKER: use_mind = MIND_BERSERKER; use_hp = TRUE; break;
3930 case CLASS_MIRROR_MASTER: use_mind = MIND_MIRROR_MASTER; break;
3931 case CLASS_NINJA: use_mind = MIND_NINJUTSU; use_hp = TRUE; break;
3932 default: use_mind = 0;break;
3935 /* Dump the spells */
3936 for (i = 0; i < MAX_MIND_POWERS; i++)
3938 byte a = TERM_WHITE;
3940 /* Access the available spell */
3941 spell = mind_powers[use_mind].info[i];
3942 if (spell.min_lev > plev) break;
3944 /* Get the failure rate */
3945 chance = spell.fail;
3947 /* Reduce failure rate by "effective" level adjustment */
3948 chance -= 3 * (p_ptr->lev - spell.min_lev);
3950 /* Reduce failure rate by INT/WIS adjustment */
3951 chance -= 3 * (adj_mag_stat[p_ptr->stat_ind[mp_ptr->spell_stat]] - 1);
3955 /* Not enough mana to cast */
3956 if (spell.mana_cost > p_ptr->csp)
3958 chance += 5 * (spell.mana_cost - p_ptr->csp);
3964 /* Not enough hp to cast */
3965 if (spell.mana_cost > p_ptr->chp)
3972 /* Extract the minimum failure rate */
3973 minfail = adj_mag_fail[p_ptr->stat_ind[mp_ptr->spell_stat]];
3975 /* Minimum failure rate */
3976 if (chance < minfail) chance = minfail;
3978 /* Stunning makes spells harder */
3979 if (p_ptr->stun > 50) chance += 25;
3980 else if (p_ptr->stun) chance += 15;
3982 /* Always a 5 percent chance of working */
3983 if (chance > 95) chance = 95;
3986 mindcraft_info(comment, use_mind, i);
3988 /* Dump the spell */
3989 sprintf(psi_desc, " %c) %-30s%2d %4d %3d%%%s",
3991 spell.min_lev, spell.mana_cost, chance, comment);
3993 Term_putstr(x, y + i + 1, -1, a, psi_desc);
3998 /* Cannot read spellbooks */
3999 if (REALM_NONE == p_ptr->realm1) return;
4001 /* Normal spellcaster with books */
4004 for (j = 0; j < ((p_ptr->realm2 > REALM_NONE) ? 2 : 1); j++)
4008 /* Reset vertical */
4011 /* Vertical location */
4012 y = (j < 3) ? 0 : (m[j - 3] + 2);
4014 /* Horizontal location */
4018 for (i = 0; i < 32; i++)
4020 byte a = TERM_WHITE;
4022 /* Access the spell */
4023 if (!is_magic((j < 1) ? p_ptr->realm1 : p_ptr->realm2))
4025 s_ptr = &technic_info[((j < 1) ? p_ptr->realm1 : p_ptr->realm2) - MIN_TECHNIC][i % 32];
4029 s_ptr = &mp_ptr->info[((j < 1) ? p_ptr->realm1 : p_ptr->realm2) - 1][i % 32];
4032 strcpy(name, spell_names[technic2magic((j < 1) ? p_ptr->realm1 : p_ptr->realm2)-1][i % 32]);
4035 if (s_ptr->slevel >= 99)
4039 strcpy(name, "(ȽÆÉÉÔǽ)");
4041 strcpy(name, "(illegible)");
4051 ((p_ptr->spell_forgotten1 & (1L << i))) :
4052 ((p_ptr->spell_forgotten2 & (1L << (i % 32)))))
4059 else if (!((j < 1) ?
4060 (p_ptr->spell_learned1 & (1L << i)) :
4061 (p_ptr->spell_learned2 & (1L << (i % 32)))))
4068 else if (!((j < 1) ?
4069 (p_ptr->spell_worked1 & (1L << i)) :
4070 (p_ptr->spell_worked2 & (1L << (i % 32)))))
4076 /* Dump the spell --(-- */
4077 sprintf(out_val, "%c/%c) %-20.20s",
4078 I2A(n / 8), I2A(n % 8), name);
4083 /* Dump onto the window */
4084 Term_putstr(x, m[j], -1, a, out_val);
4094 * Returns experience of a spell
4096 s16b experience_of_spell(int spell, int use_realm)
4098 if (p_ptr->pclass == CLASS_SORCERER) return SPELL_EXP_MASTER;
4099 else if (p_ptr->pclass == CLASS_RED_MAGE) return SPELL_EXP_SKILLED;
4100 else if (use_realm == p_ptr->realm1) return p_ptr->spell_exp[spell];
4101 else if (use_realm == p_ptr->realm2) return p_ptr->spell_exp[spell + 32];
4107 * Modify mana consumption rate using spell exp and p_ptr->dec_mana
4109 int mod_need_mana(int need_mana, int spell, int realm)
4111 #define MANA_CONST 2400
4113 #define DEC_MANA_DIV 3
4116 if ((realm > REALM_NONE) && (realm <= MAX_REALM))
4119 * need_mana defaults if spell exp equals SPELL_EXP_EXPERT and !p_ptr->dec_mana.
4120 * MANA_CONST is used to calculate need_mana effected from spell proficiency.
4122 need_mana = need_mana * (MANA_CONST + SPELL_EXP_EXPERT - experience_of_spell(spell, realm)) + (MANA_CONST - 1);
4123 need_mana *= p_ptr->dec_mana ? DEC_MANA_DIV : MANA_DIV;
4124 need_mana /= MANA_CONST * MANA_DIV;
4125 if (need_mana < 1) need_mana = 1;
4128 /* Non-realm magic */
4131 if (p_ptr->dec_mana) need_mana = (need_mana + 1) * DEC_MANA_DIV / MANA_DIV;
4143 * Returns spell chance of failure for spell -RAK-
4145 s16b spell_chance(int spell, int use_realm)
4147 int chance, minfail;
4150 int penalty = (mp_ptr->spell_stat == A_WIS) ? 10 : 4;
4153 /* Paranoia -- must be literate */
4154 if (!mp_ptr->spell_book) return (100);
4156 if (use_realm == REALM_HISSATSU) return 0;
4158 /* Access the spell */
4159 if (!is_magic(use_realm))
4161 s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
4165 s_ptr = &mp_ptr->info[use_realm - 1][spell];
4168 /* Extract the base spell failure rate */
4169 chance = s_ptr->sfail;
4171 /* Reduce failure rate by "effective" level adjustment */
4172 chance -= 3 * (p_ptr->lev - s_ptr->slevel);
4174 /* Reduce failure rate by INT/WIS adjustment */
4175 chance -= 3 * (adj_mag_stat[p_ptr->stat_ind[mp_ptr->spell_stat]] - 1);
4178 chance += (MAX(r_info[m_list[p_ptr->riding].r_idx].level - p_ptr->skill_exp[GINOU_RIDING] / 100 - 10, 0));
4180 /* Extract mana consumption rate */
4181 need_mana = mod_need_mana(s_ptr->smana, spell, use_realm);
4183 /* Not enough mana to cast */
4184 if (need_mana > p_ptr->csp)
4186 chance += 5 * (need_mana - p_ptr->csp);
4189 chance += p_ptr->to_m_chance;
4190 if ((use_realm != p_ptr->realm1) && ((p_ptr->pclass == CLASS_MAGE) || (p_ptr->pclass == CLASS_PRIEST))) chance += 5;
4192 /* Extract the minimum failure rate */
4193 minfail = adj_mag_fail[p_ptr->stat_ind[mp_ptr->spell_stat]];
4196 * Non mage/priest characters never get too good
4197 * (added high mage, mindcrafter)
4199 if (mp_ptr->spell_xtra & MAGIC_FAIL_5PERCENT)
4201 if (minfail < 5) minfail = 5;
4204 /* Hack -- Priest prayer penalty for "edged" weapons -DGK */
4205 if (((p_ptr->pclass == CLASS_PRIEST) || (p_ptr->pclass == CLASS_SORCERER)) && p_ptr->icky_wield[0]) chance += 25;
4206 if (((p_ptr->pclass == CLASS_PRIEST) || (p_ptr->pclass == CLASS_SORCERER)) && p_ptr->icky_wield[1]) chance += 25;
4208 if (p_ptr->heavy_spell) chance += 20;
4209 if(p_ptr->dec_mana && p_ptr->easy_spell) chance-=4;
4210 else if (p_ptr->easy_spell) chance-=3;
4211 else if (p_ptr->dec_mana) chance-=2;
4213 if ((use_realm == REALM_NATURE) && ((p_ptr->align > 50) || (p_ptr->align < -50))) chance += penalty;
4214 if (((use_realm == REALM_LIFE) || (use_realm == REALM_CRUSADE)) && (p_ptr->align < -20)) chance += penalty;
4215 if (((use_realm == REALM_DEATH) || (use_realm == REALM_DAEMON)) && (p_ptr->align > 20)) chance += penalty;
4217 /* Minimum failure rate */
4218 if (chance < minfail) chance = minfail;
4220 /* Stunning makes spells harder */
4221 if (p_ptr->stun > 50) chance += 25;
4222 else if (p_ptr->stun) chance += 15;
4224 /* Always a 5 percent chance of working */
4225 if (chance > 95) chance = 95;
4227 if ((use_realm == p_ptr->realm1) || (use_realm == p_ptr->realm2)
4228 || (p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE))
4230 s16b exp = experience_of_spell(spell, use_realm);
4231 if (exp >= SPELL_EXP_EXPERT) chance--;
4232 if (exp >= SPELL_EXP_MASTER) chance--;
4234 if(p_ptr->dec_mana) chance--;
4235 if (p_ptr->heavy_spell) chance += 5;
4237 chance = MAX(chance,0);
4239 /* Return the chance */
4246 * Determine if a spell is "okay" for the player to cast or study
4247 * The spell must be legible, not forgotten, and also, to cast,
4248 * it must be known, and to study, it must not be known.
4250 bool spell_okay(int spell, bool learned, bool study_pray, int use_realm)
4254 /* Access the spell */
4255 if (!is_magic(use_realm))
4257 s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
4261 s_ptr = &mp_ptr->info[use_realm - 1][spell];
4264 /* Spell is illegal */
4265 if (s_ptr->slevel > p_ptr->lev) return (FALSE);
4267 /* Spell is forgotten */
4268 if ((use_realm == p_ptr->realm2) ?
4269 (p_ptr->spell_forgotten2 & (1L << spell)) :
4270 (p_ptr->spell_forgotten1 & (1L << spell)))
4276 if (p_ptr->pclass == CLASS_SORCERER) return (TRUE);
4277 if (p_ptr->pclass == CLASS_RED_MAGE) return (TRUE);
4279 /* Spell is learned */
4280 if ((use_realm == p_ptr->realm2) ?
4281 (p_ptr->spell_learned2 & (1L << spell)) :
4282 (p_ptr->spell_learned1 & (1L << spell)))
4285 return (!study_pray);
4288 /* Okay to study, not to cast */
4295 * Extra information on a spell -DRS-
4297 * We can use up to 14 characters of the buffer 'p'
4299 * The strings in this function were extracted from the code in the
4300 * functions "do_cmd_cast()" and "do_cmd_pray()" and may be dated.
4302 static void spell_info(char *p, int spell, int use_realm)
4304 int plev = p_ptr->lev;
4307 int orb = plev + (plev / ((p_ptr->pclass == CLASS_PRIEST ||
4308 p_ptr->pclass == CLASS_HIGH_MAGE ||
4309 p_ptr->pclass == CLASS_SORCERER) ? 2 : 4));
4311 int burst = plev + (plev / ((p_ptr->pclass == CLASS_MAGE ||
4312 p_ptr->pclass == CLASS_HIGH_MAGE ||
4313 p_ptr->pclass == CLASS_SORCERER) ? 2 : 4));
4315 cptr s_dam = "»½ý:";
4316 cptr s_dur = "´ü´Ö:";
4317 cptr s_range = "ÈÏ°Ï:";
4318 cptr s_heal = "²óÉü:";
4319 cptr s_random = "¥é¥ó¥À¥à";
4320 cptr s_delay = "ÃÙ±ä:";
4322 cptr s_dam = "dam ";
4323 cptr s_dur = "dur ";
4324 cptr s_range = "range ";
4325 cptr s_heal = "heal ";
4326 cptr s_random = "random";
4327 cptr s_delay = "delay ";
4332 /* Analyze the spell */
4335 case REALM_LIFE: /* Life */
4338 case 0: sprintf(p, " %s2d10", s_heal); break;
4339 case 1: sprintf(p, " %s12+d12", s_dur); break;
4340 case 2: sprintf(p, " %s%dd4", s_dam, 3 + ((plev - 1) / 5)); break;
4341 case 3: sprintf(p, " %s%d", s_dam, 10 + (plev / 2)); break;
4342 case 5: sprintf(p, " %s4d10", s_heal); break;
4343 case 9: sprintf(p, " %s%dd8", s_dam, 8 + ((plev - 1) / 5)); break;
4344 case 10: sprintf(p, " %s8d10", s_heal); break;
4345 case 11: sprintf(p, " %s20+d20", s_dur); break;
4346 case 14: sprintf(p, " %s300", s_heal); break;
4347 case 18: sprintf(p, " %sd%d", s_dam, 5 * plev); break;
4348 case 20: sprintf(p, " %s%dd15", s_dam, 5 + ((plev - 1) / 3)); break;
4349 case 21: sprintf(p, " %s15+d21", s_delay); break;
4350 case 29: sprintf(p, " %s2000", s_heal); break;
4351 case 31: sprintf(p, " %s%d+d%d", s_dur,(plev/2), (plev/2)); break;
4355 case REALM_SORCERY: /* Sorcery */
4358 case 1: sprintf(p, " %s10", s_range); break;
4359 case 3: sprintf(p, " %s%d", s_dam, 10 + (plev / 2)); break;
4360 case 5: sprintf(p, " %s%d", s_range, plev * 5); break;
4361 case 13: sprintf(p, " %s%d+d%d", s_dur, plev, plev + 20); break;
4362 case 18: sprintf(p, " %s25+d30", s_dur); break;
4363 case 22: sprintf(p, " %s15+d21", s_delay); break;
4364 case 23: sprintf(p, " %s%d", s_range, plev / 2 + 10); break;
4365 case 25: sprintf(p, " %s7d7+%d", s_dam, plev); break;
4367 case 26: sprintf(p, " ºÇÂç½ÅÎÌ:%d.%dkg", lbtokg1(plev * 15),lbtokg2(plev * 15)); break;
4369 case 26: sprintf(p, " max wgt %d", plev * 15 / 10); break;
4371 case 27: sprintf(p, " %s25+d30", s_dur); break;
4372 case 31: sprintf(p, " %s4+d4", s_dur); break;
4376 case REALM_NATURE: /* Nature */
4380 case 1: sprintf(p, " %s%dd4 ¼ÍÄø%d", s_dam, (3 + ((plev - 1) / 5)), plev/6+2); break;
4382 case 1: sprintf(p, " %s%dd4 rng %d", s_dam, (3 + ((plev - 1) / 5)), plev/6+2); break;
4384 case 4: sprintf(p, " %s%d", s_dam, 10 + (plev / 2)); break;
4385 case 6: sprintf(p, " %s20+d20", s_dur); break;
4386 case 7: sprintf(p, " %s2d8", s_heal); break;
4387 case 9: sprintf(p, " %s%dd8", s_dam, (3 + ((plev - 5) / 4))); break;
4388 case 11: sprintf(p, " %s%dd8", s_dam, (5 + ((plev - 5) / 4))); break;
4389 case 12: sprintf(p, " %s6d8", s_dam); break;
4390 case 15: sprintf(p, " %s500", s_heal); break;
4391 case 17: sprintf(p, " %s20+d30", s_dur); break;
4392 case 18: sprintf(p, " %s20+d20", s_dur); break;
4394 case 24: sprintf(p, " Ⱦ·Â:10"); break;
4396 case 24: sprintf(p, " rad 10"); break;
4398 case 26: sprintf(p, " %s%d", s_dam, 70 + plev * 3 / 2); break;
4399 case 27: sprintf(p, " %s%d", s_dam, 90 + plev * 3 / 2); break;
4400 case 28: sprintf(p, " %s%d", s_dam, 100 + plev * 3 / 2); break;
4401 case 29: sprintf(p, " %s75", s_dam); break;
4402 case 31: sprintf(p, " %s%d+%d", s_dam, 4 * plev, 100 + plev); break;
4406 case REALM_CHAOS: /* Chaos */
4409 case 0: sprintf(p, " %s%dd4", s_dam, 3 + ((plev - 1) / 5)); break;
4410 case 2: sprintf(p, " %s%d", s_dam, 10 + (plev / 2)); break;
4411 case 4: sprintf(p, " %s3d5+%d", s_dam, burst); break;
4412 case 5: sprintf(p, " %s%dd8", s_dam, (6 + ((plev - 5) / 4))); break;
4413 case 6: sprintf(p, " %s%dd8", s_dam, (8 + ((plev - 5) / 4))); break;
4414 case 7: sprintf(p, " %s%d", s_range, plev * 5); break;
4415 case 8: sprintf(p, " %s", s_random); break;
4416 case 9: sprintf(p, " %s%dd8", s_dam, (10 + ((plev - 5) / 4))); break;
4417 case 10: sprintf(p, " %s%d", s_dam, (60 + plev)/2); break;
4418 case 11: sprintf(p, " %s%dd8", s_dam, (11 + ((plev - 5) / 4))); break;
4419 case 12: sprintf(p, " %s%d", s_dam, 55 + plev); break;
4420 case 15: sprintf(p, " %s%d", s_dam, 99 + plev*2); break;
4421 case 17: sprintf(p, " %s%dd8", s_dam, (5 + (plev / 10))); break;
4422 case 19: sprintf(p, " %s%d", s_dam, 70 + plev); break;
4423 case 21: sprintf(p, " %s%d", s_dam, 120 + plev*2); break;
4424 case 24: sprintf(p, " %s%dd8", s_dam, (9 + (plev / 10))); break;
4426 case 25: sprintf(p, " %s³Æ%d", s_dam, plev * 2); break;
4428 case 25: sprintf(p, " dam %d each", plev * 2); break;
4430 case 26: sprintf(p, " %s%d", s_dam, 150 + plev*3/2); break;
4431 case 27: sprintf(p, " %s150 / 250", s_dam); break;
4432 case 29: sprintf(p, " %s%d", s_dam, 300 + (plev * 4)); break;
4433 case 30: sprintf(p, " %s%d", s_dam, p_ptr->chp); break;
4434 case 31: sprintf(p, " %s3 * 175", s_dam); break;
4438 case REALM_DEATH: /* Death */
4441 case 1: sprintf(p, " %s%dd3", s_dam, (3 + ((plev - 1) / 5))); break;
4442 case 3: sprintf(p, " %s%d", s_dam, 10 + (plev / 2)); break;
4443 case 5: sprintf(p, " %s20+d20", s_dur); break;
4444 case 8: sprintf(p, " %s3d6+%d", s_dam, burst); break;
4445 case 9: sprintf(p, " %s%dd8", s_dam, (8 + ((plev - 5) / 4))); break;
4446 case 10: sprintf(p, " %s%d", s_dam, 30+plev); break;
4448 case 13: sprintf(p, " »:%d+d%d", plev * 2, plev * 2); break;
4450 case 13: sprintf(p, " d %d+d%d", plev * 2, plev * 2); break;
4452 case 16: sprintf(p, " %s25+d25", s_dur); break;
4453 case 17: sprintf(p, " %s", s_random); break;
4454 case 18: sprintf(p, " %s%dd8", s_dam, (4 + ((plev - 5) / 4))); break;
4455 case 19: sprintf(p, " %s25+d25", s_dur); break;
4456 case 21: sprintf(p, " %s3*100", s_dam); break;
4457 case 22: sprintf(p, " %sd%d", s_dam, plev * 3); break;
4458 case 23: sprintf(p, " %s%d", s_dam, 100 + plev * 2); break;
4459 case 27: sprintf(p, " %s%d+d%d", s_dur,10+plev/2, 10+plev/2); break;
4460 case 30: sprintf(p, " %s666", s_dam); break;
4461 case 31: sprintf(p, " %s%d+d%d", s_dur, (plev / 2), (plev / 2)); break;
4465 case REALM_TRUMP: /* Trump */
4468 case 0: sprintf(p, " %s10", s_range); break;
4469 case 2: sprintf(p, " %s", s_random); break;
4470 case 4: sprintf(p, " %s%d", s_range, plev * 4); break;
4471 case 5: sprintf(p, " %s25+d30", s_dur); break;
4473 case 8: sprintf(p, " ºÇÂç½ÅÎÌ:%d.%d", lbtokg1(plev * 15 / 10),lbtokg2(plev * 15 / 10)); break;
4475 case 8: sprintf(p, " max wgt %d", plev * 15 / 10); break;
4477 case 13: sprintf(p, " %s%d", s_range, plev / 2 + 10); break;
4478 case 14: sprintf(p, " %s15+d21", s_delay); break;
4479 case 26: sprintf(p, " %s%d", s_heal, plev * 10 + 200); break;
4481 case 28: sprintf(p, " %s³Æ%d", s_dam, plev * 2); break;
4483 case 28: sprintf(p, " %s%d each", s_dam, plev * 2); break;
4488 case REALM_ARCANE: /* Arcane */
4491 case 0: sprintf(p, " %s%dd3", s_dam, 3 + ((plev - 1) / 5)); break;
4492 case 4: sprintf(p, " %s10", s_range); break;
4493 case 5: sprintf(p, " %s2d%d", s_dam, plev / 2); break;
4494 case 7: sprintf(p, " %s2d8", s_heal); break;
4498 case 17: sprintf(p, " %s20+d20", s_dur); break;
4499 case 18: sprintf(p, " %s4d8", s_heal); break;
4500 case 19: sprintf(p, " %s%d", s_range, plev * 5); break;
4501 case 21: sprintf(p, " %s6d8", s_dam); break;
4502 case 24: sprintf(p, " %s24+d24", s_dur); break;
4503 case 28: sprintf(p, " %s%d", s_dam, 75 + plev); break;
4504 case 30: sprintf(p, " %s15+d21", s_delay); break;
4505 case 31: sprintf(p, " %s25+d30", s_dur); break;
4509 case REALM_ENCHANT: /* Craft */
4512 case 0: sprintf(p, " %s100+d100", s_dur); break;
4513 case 1: sprintf(p, " %s80+d80", s_dur); break;
4519 case 18: sprintf(p, " %s20+d20", s_dur); break;
4520 case 5: sprintf(p, " %s25+d25", s_dur); break;
4521 case 8: sprintf(p, " %s24+d24", s_dur); break;
4522 case 11: sprintf(p, " %s25+d25", s_dur); break;
4523 case 13: sprintf(p, " %s%d+d25", s_dur, plev * 3); break;
4524 case 15: sprintf(p, " %s%d+d%d", s_dur, plev/2, plev/2); break;
4525 case 16: sprintf(p, " %s25+d30", s_dur); break;
4526 case 17: sprintf(p, " %s30+d20", s_dur); break;
4527 case 19: sprintf(p, " %s%d+d%d", s_dur, plev, plev+20); break;
4528 case 20: sprintf(p, " %s50+d50", s_dur); break;
4529 case 23: sprintf(p, " %s20+d20", s_dur); break;
4530 case 31: sprintf(p, " %s13+d13", s_dur); break;
4534 case REALM_DAEMON: /* Daemon */
4537 case 0: sprintf(p, " %s%dd4", s_dam, 3 + ((plev - 1) / 5)); break;
4538 case 2: sprintf(p, " %s12+d12", s_dur); break;
4539 case 3: sprintf(p, " %s20+d20", s_dur); break;
4540 case 5: sprintf(p, " %s%dd8", s_dam, (6 + ((plev - 5) / 4))); break;
4541 case 7: sprintf(p, " %s3d6+%d", s_dam, burst); break;
4542 case 10: sprintf(p, " %s20+d20", s_dur); break;
4543 case 11: sprintf(p, " %s%dd8", s_dam, (11 + ((plev - 5) / 4))); break;
4544 case 12: sprintf(p, " %s%d", s_dam, 55 + plev); break;
4545 case 14: sprintf(p, " %s%d", s_dam, 100 + plev*3/2); break;
4546 case 16: sprintf(p, " %s30+d25", s_dur); break;
4547 case 17: sprintf(p, " %s20+d20", s_dur); break;
4548 case 18: sprintf(p, " %s%d", s_dam, 55 + plev); break;
4549 case 19: sprintf(p, " %s%d", s_dam, 80 + plev*3/2); break;
4550 case 20: sprintf(p, " %s%d+d%d", s_dur,10+plev/2, 10+plev/2); break;
4551 case 21: sprintf(p, " %sd%d+d%d", s_dam, 2 * plev, 2 * plev); break;
4552 case 22: sprintf(p, " %s%d", s_dam, 100 + plev*2); break;
4553 case 24: sprintf(p, " %s25+d25", s_dur); break;
4554 case 25: sprintf(p, " %s20+d20", s_dur); break;
4555 case 26: sprintf(p, " %s%d+%d", s_dam, 25+plev/2, 25+plev/2); break;
4556 case 29: sprintf(p, " %s%d", s_dam, plev*15); break;
4557 case 30: sprintf(p, " %s600", s_dam); break;
4558 case 31: sprintf(p, " %s15+d15", s_dur); break;
4562 case REALM_CRUSADE: /* Crusade */
4565 case 0: sprintf(p, " %s%dd4", s_dam, 3 + ((plev - 1) / 5)); break;
4566 case 5: sprintf(p, " %s%d", s_range, 25+plev/2); break;
4568 case 6: sprintf(p, " %s³Æ%dd2", s_dam, 3+((plev-1)/9)); break;
4570 case 6: sprintf(p, " %s%dd2 each", s_dam, 3+((plev-1)/9)); break;
4572 case 9: sprintf(p, " %s3d6+%d", s_dam, orb); break;
4573 case 10: sprintf(p, " %sd%d", s_dam, plev); break;
4574 case 12: sprintf(p, " %s24+d24", s_dur); break;
4575 case 13: sprintf(p, " %sd25+%d", s_dur, 3 * plev); break;
4576 case 14: sprintf(p, " %s%d", s_dam, plev*5); break;
4578 case 15: sprintf(p, " »:d%d/²ó:100", 6 * plev); break;
4580 case 15: sprintf(p, " dam:d%d/h100", 6 * plev); break;
4582 case 18: sprintf(p, " %s18+d18", s_dur); break;
4583 case 19: sprintf(p, " %sd%d", s_dam, 4 * plev); break;
4584 case 20: sprintf(p, " %sd%d", s_dam, 4 * plev); break;
4585 case 22: sprintf(p, " %s%d", s_dam, 2 * plev+100); break;
4586 case 24: sprintf(p, " %s25+d25", s_dur); break;
4587 case 28: sprintf(p, " %s10+d10", s_dur); break;
4589 case 29: sprintf(p, " %s³Æ%d", s_dam, plev*3+25); break;
4591 case 29: sprintf(p, " %s%d each", s_dam, plev*3+25); break;
4594 case 30: sprintf(p, " ²ó100/»%d+%d", plev * 4, plev*11/2); break;
4596 case 30: sprintf(p, " h100/dm%d+%d", plev * 4, plev*11/2); break;
4601 case REALM_MUSIC: /* Music */
4604 case 2 : sprintf(p, " %s%dd4", s_dam, 4 + ((plev - 1) / 5)); break;
4605 case 4 : sprintf(p, " %s2d6", s_heal); break;
4606 case 9 : sprintf(p, " %sd%d", s_dam, plev * 3 / 2); break;
4607 case 13: sprintf(p, " %s%dd7", s_dam, 10 + (plev / 5)); break;
4608 case 20: sprintf(p, " %sd%d+d%d", s_dam, plev * 3, plev * 3); break;
4609 case 22: sprintf(p, " %s%dd10", s_dam, 15 + ((plev - 1) / 2)); break;
4610 case 27: sprintf(p, " %sd%d", s_dam, plev * 3); break;
4611 case 28: sprintf(p, " %s15d10", s_heal); break;
4612 case 30: sprintf(p, " %s%dd10", s_dam, 50 + plev); break;
4617 sprintf(p, "̤ÃΤΥ¿¥¤¥×: %d", use_realm);
4619 sprintf(p, "Unknown type: %d.", use_realm);
4626 * Print a list of spells (for browsing or casting or viewing)
4628 void print_spells(int target_spell, byte *spells, int num, int y, int x, int use_realm)
4630 int i, spell, exp_level, increment = 64;
4642 if (((use_realm <= REALM_NONE) || (use_realm > MAX_REALM)) && p_ptr->wizard)
4644 msg_print("·Ù¹ð¡ª print_spell ¤¬Îΰè¤Ê¤·¤Ë¸Æ¤Ð¤ì¤¿");
4646 msg_print("Warning! print_spells called with null realm");
4650 /* Title the list */
4652 if (use_realm == REALM_HISSATSU)
4654 strcpy(buf," Lv MP");
4656 strcpy(buf," Lv SP");
4660 strcpy(buf,"½ÏÎýÅÙ Lv MP ¼ºÎ¨ ¸ú²Ì");
4662 strcpy(buf,"Profic Lv SP Fail Effect");
4666 put_str("̾Á°", y, x + 5);
4667 put_str(buf, y, x + 29);
4669 put_str("Name", y, x + 5);
4670 put_str(buf, y, x + 29);
4673 if ((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE)) increment = 0;
4674 else if (use_realm == p_ptr->realm1) increment = 0;
4675 else if (use_realm == p_ptr->realm2) increment = 32;
4677 /* Dump the spells */
4678 for (i = 0; i < num; i++)
4680 /* Access the spell */
4683 /* Access the spell */
4684 if (!is_magic(use_realm))
4686 s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
4690 s_ptr = &mp_ptr->info[use_realm - 1][spell];
4693 if (use_realm == REALM_HISSATSU)
4694 need_mana = s_ptr->smana;
4697 s16b exp = experience_of_spell(spell, use_realm);
4699 /* Extract mana consumption rate */
4700 need_mana = mod_need_mana(s_ptr->smana, spell, use_realm);
4702 if ((increment == 64) || (s_ptr->slevel >= 99)) exp_level = EXP_LEVEL_UNSKILLED;
4703 else exp_level = spell_exp_level(exp);
4706 if (!increment && (exp_level == EXP_LEVEL_MASTER)) max = TRUE;
4707 else if ((increment == 32) && (exp_level >= EXP_LEVEL_EXPERT)) max = TRUE;
4708 else if (s_ptr->slevel >= 99) max = TRUE;
4709 else if ((p_ptr->pclass == CLASS_RED_MAGE) && (exp_level >= EXP_LEVEL_SKILLED)) max = TRUE;
4711 strncpy(ryakuji, exp_level_str[exp_level], 4);
4716 if (use_menu && target_spell)
4718 if (i == (target_spell-1))
4720 strcpy(out_val, " ¡Õ ");
4722 strcpy(out_val, " > ");
4725 strcpy(out_val, " ");
4727 else sprintf(out_val, " %c) ", I2A(i));
4728 /* Skip illegible spells */
4729 if (s_ptr->slevel >= 99)
4732 strcat(out_val, format("%-30s", "(ȽÆÉÉÔǽ)"));
4734 strcat(out_val, format("%-30s", "(illegible)"));
4737 c_prt(TERM_L_DARK, out_val, y + i + 1, x);
4741 /* XXX XXX Could label spells above the players level */
4743 /* Get extra info */
4744 spell_info(info, spell, use_realm);
4749 /* Assume spell is known and tried */
4750 line_attr = TERM_WHITE;
4752 /* Analyze the spell */
4753 if ((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE))
4755 if (s_ptr->slevel > p_ptr->max_plv)
4760 comment = " unknown";
4763 line_attr = TERM_L_BLUE;
4765 else if (s_ptr->slevel > p_ptr->lev)
4770 comment = " forgotten";
4773 line_attr = TERM_YELLOW;
4776 else if ((use_realm != p_ptr->realm1) && (use_realm != p_ptr->realm2))
4781 comment = " unknown";
4784 line_attr = TERM_L_BLUE;
4786 else if ((use_realm == p_ptr->realm1) ?
4787 ((p_ptr->spell_forgotten1 & (1L << spell))) :
4788 ((p_ptr->spell_forgotten2 & (1L << spell))))
4793 comment = " forgotten";
4796 line_attr = TERM_YELLOW;
4798 else if (!((use_realm == p_ptr->realm1) ?
4799 (p_ptr->spell_learned1 & (1L << spell)) :
4800 (p_ptr->spell_learned2 & (1L << spell))))
4805 comment = " unknown";
4808 line_attr = TERM_L_BLUE;
4810 else if (!((use_realm == p_ptr->realm1) ?
4811 (p_ptr->spell_worked1 & (1L << spell)) :
4812 (p_ptr->spell_worked2 & (1L << spell))))
4815 comment = " ̤·Ð¸³";
4817 comment = " untried";
4820 line_attr = TERM_L_GREEN;
4823 /* Dump the spell --(-- */
4824 if (use_realm == REALM_HISSATSU)
4826 strcat(out_val, format("%-25s %2d %4d",
4827 spell_names[technic2magic(use_realm)-1][spell], /* realm, spell */
4828 s_ptr->slevel, need_mana));
4832 strcat(out_val, format("%-25s%c%-4s %2d %4d %3d%%%s",
4833 spell_names[technic2magic(use_realm)-1][spell], /* realm, spell */
4834 (max ? '!' : ' '), ryakuji,
4835 s_ptr->slevel, need_mana, spell_chance(spell, use_realm), comment));
4837 c_prt(line_attr, out_val, y + i + 1, x);
4840 /* Clear the bottom line */
4841 prt("", y + i + 1, x);
4846 * Note that amulets, rods, and high-level spell books are immune
4847 * to "inventory damage" of any kind. Also sling ammo and shovels.
4852 * Does a given class of objects (usually) hate acid?
4853 * Note that acid can either melt or corrode something.
4855 bool hates_acid(object_type *o_ptr)
4857 /* Analyze the type */
4858 switch (o_ptr->tval)
4860 /* Wearable items */
4880 /* Staffs/Scrolls are wood/paper */
4893 /* Junk is useless */
4907 * Does a given object (usually) hate electricity?
4909 bool hates_elec(object_type *o_ptr)
4911 switch (o_ptr->tval)
4925 * Does a given object (usually) hate fire?
4926 * Hafted/Polearm weapons have wooden shafts.
4927 * Arrows/Bows are mostly wooden.
4929 bool hates_fire(object_type *o_ptr)
4931 /* Analyze the type */
4932 switch (o_ptr->tval)
4950 case TV_SORCERY_BOOK:
4951 case TV_NATURE_BOOK:
4955 case TV_ARCANE_BOOK:
4956 case TV_ENCHANT_BOOK:
4957 case TV_DAEMON_BOOK:
4958 case TV_CRUSADE_BOOK:
4960 case TV_HISSATSU_BOOK:
4971 /* Staffs/Scrolls burn */
4984 * Does a given object (usually) hate cold?
4986 bool hates_cold(object_type *o_ptr)
4988 switch (o_ptr->tval)
5005 int set_acid_destroy(object_type *o_ptr)
5007 u32b flgs[TR_FLAG_SIZE];
5008 if (!hates_acid(o_ptr)) return (FALSE);
5009 object_flags(o_ptr, flgs);
5010 if (have_flag(flgs, TR_IGNORE_ACID)) return (FALSE);
5018 int set_elec_destroy(object_type *o_ptr)
5020 u32b flgs[TR_FLAG_SIZE];
5021 if (!hates_elec(o_ptr)) return (FALSE);
5022 object_flags(o_ptr, flgs);
5023 if (have_flag(flgs, TR_IGNORE_ELEC)) return (FALSE);
5031 int set_fire_destroy(object_type *o_ptr)
5033 u32b flgs[TR_FLAG_SIZE];
5034 if (!hates_fire(o_ptr)) return (FALSE);
5035 object_flags(o_ptr, flgs);
5036 if (have_flag(flgs, TR_IGNORE_FIRE)) return (FALSE);
5044 int set_cold_destroy(object_type *o_ptr)
5046 u32b flgs[TR_FLAG_SIZE];
5047 if (!hates_cold(o_ptr)) return (FALSE);
5048 object_flags(o_ptr, flgs);
5049 if (have_flag(flgs, TR_IGNORE_COLD)) return (FALSE);
5055 * Destroys a type of item on a given percent chance
5056 * Note that missiles are no longer necessarily all destroyed
5057 * Destruction taken from "melee.c" code for "stealing".
5058 * New-style wands and rods handled correctly. -LM-
5059 * Returns number of items destroyed.
5061 int inven_damage(inven_func typ, int perc)
5065 char o_name[MAX_NLEN];
5067 /* Multishadow effects is determined by turn */
5068 if( p_ptr->multishadow && (turn & 1) )return 0;
5070 if (p_ptr->inside_arena) return 0;
5072 /* Count the casualties */
5075 /* Scan through the slots backwards */
5076 for (i = 0; i < INVEN_PACK; i++)
5078 o_ptr = &inventory[i];
5080 /* Skip non-objects */
5081 if (!o_ptr->k_idx) continue;
5083 /* Hack -- for now, skip artifacts */
5084 if (artifact_p(o_ptr) || o_ptr->art_name) continue;
5086 /* Give this item slot a shot at death */
5089 /* Count the casualties */
5090 for (amt = j = 0; j < o_ptr->number; ++j)
5092 if (randint0(100) < perc) amt++;
5095 /* Some casualities */
5098 /* Get a description */
5099 object_desc(o_name, o_ptr, FALSE, 3);
5103 msg_format("%s(%c)¤¬%s²õ¤ì¤Æ¤·¤Þ¤Ã¤¿¡ª",
5105 msg_format("%sour %s (%c) %s destroyed!",
5109 o_name, index_to_label(i),
5110 ((o_ptr->number > 1) ?
5111 ((amt == o_ptr->number) ? "Á´Éô" :
5112 (amt > 1 ? "²¿¸Ä¤«" : "°ì¸Ä")) : "") );
5114 ((o_ptr->number > 1) ?
5115 ((amt == o_ptr->number) ? "All of y" :
5116 (amt > 1 ? "Some of y" : "One of y")) : "Y"),
5117 o_name, index_to_label(i),
5118 ((amt > 1) ? "were" : "was"));
5122 if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON))
5123 msg_print("¤ä¤ê¤ä¤¬¤Ã¤¿¤Ê¡ª");
5126 /* Potions smash open */
5127 if (object_is_potion(o_ptr))
5129 (void)potion_smash_effect(0, py, px, o_ptr->k_idx);
5132 /* Reduce the charges of rods/wands */
5133 reduce_charges(o_ptr, amt);
5135 /* Destroy "amt" items */
5136 inven_item_increase(i, -amt);
5137 inven_item_optimize(i);
5139 /* Count the casualties */
5145 /* Return the casualty count */
5151 * Acid has hit the player, attempt to affect some armor.
5153 * Note that the "base armor" of an object never changes.
5155 * If any armor is damaged (or resists), the player takes less damage.
5157 static int minus_ac(void)
5159 object_type *o_ptr = NULL;
5160 u32b flgs[TR_FLAG_SIZE];
5161 char o_name[MAX_NLEN];
5164 /* Pick a (possibly empty) inventory slot */
5165 switch (randint1(7))
5167 case 1: o_ptr = &inventory[INVEN_RARM]; break;
5168 case 2: o_ptr = &inventory[INVEN_LARM]; break;
5169 case 3: o_ptr = &inventory[INVEN_BODY]; break;
5170 case 4: o_ptr = &inventory[INVEN_OUTER]; break;
5171 case 5: o_ptr = &inventory[INVEN_HANDS]; break;
5172 case 6: o_ptr = &inventory[INVEN_HEAD]; break;
5173 case 7: o_ptr = &inventory[INVEN_FEET]; break;
5176 /* Nothing to damage */
5177 if (!o_ptr->k_idx) return (FALSE);
5179 if (o_ptr->tval < TV_BOOTS) return (FALSE);
5181 /* No damage left to be done */
5182 if (o_ptr->ac + o_ptr->to_a <= 0) return (FALSE);
5186 object_desc(o_name, o_ptr, FALSE, 0);
5188 /* Extract the flags */
5189 object_flags(o_ptr, flgs);
5191 /* Object resists */
5192 if (have_flag(flgs, TR_IGNORE_ACID))
5195 msg_format("¤·¤«¤·%s¤Ë¤Ï¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡ª", o_name);
5197 msg_format("Your %s is unaffected!", o_name);
5206 msg_format("%s¤¬¥À¥á¡¼¥¸¤ò¼õ¤±¤¿¡ª", o_name);
5208 msg_format("Your %s is damaged!", o_name);
5212 /* Damage the item */
5215 /* Calculate bonuses */
5216 p_ptr->update |= (PU_BONUS);
5219 p_ptr->window |= (PW_EQUIP | PW_PLAYER);
5223 /* Item was damaged */
5229 * Hurt the player with Acid
5231 int acid_dam(int dam, cptr kb_str, int monspell)
5234 int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
5235 bool double_resist = IS_OPPOSE_ACID();
5237 /* Total Immunity */
5238 if (p_ptr->immune_acid || (dam <= 0))
5240 learn_spell(monspell);
5244 /* Vulnerability (Ouch!) */
5245 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
5246 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
5248 /* Resist the damage */
5249 if (p_ptr->resist_acid) dam = (dam + 2) / 3;
5250 if (double_resist) dam = (dam + 2) / 3;
5252 if ((!(double_resist || p_ptr->resist_acid)) &&
5253 one_in_(HURT_CHANCE))
5254 (void)do_dec_stat(A_CHR);
5256 /* If any armor gets hit, defend the player */
5257 if (minus_ac()) dam = (dam + 1) / 2;
5260 get_damage=take_hit(DAMAGE_ATTACK, dam, kb_str, monspell);
5262 /* Inventory damage */
5263 if (!(double_resist && p_ptr->resist_acid))
5264 inven_damage(set_acid_destroy, inv);
5270 * Hurt the player with electricity
5272 int elec_dam(int dam, cptr kb_str, int monspell)
5275 int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
5276 bool double_resist = IS_OPPOSE_ELEC();
5278 /* Total immunity */
5279 if (p_ptr->immune_elec || (dam <= 0))
5281 learn_spell(monspell);
5285 /* Vulnerability (Ouch!) */
5286 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
5287 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
5288 if (prace_is_(RACE_ANDROID)) dam += dam / 3;
5290 /* Resist the damage */
5291 if (p_ptr->resist_elec) dam = (dam + 2) / 3;
5292 if (double_resist) dam = (dam + 2) / 3;
5294 if ((!(double_resist || p_ptr->resist_elec)) &&
5295 one_in_(HURT_CHANCE))
5296 (void)do_dec_stat(A_DEX);
5299 get_damage=take_hit(DAMAGE_ATTACK, dam, kb_str, monspell);
5301 /* Inventory damage */
5302 if (!(double_resist && p_ptr->resist_elec))
5303 inven_damage(set_elec_destroy, inv);
5310 * Hurt the player with Fire
5312 int fire_dam(int dam, cptr kb_str, int monspell)
5315 int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
5316 bool double_resist = IS_OPPOSE_FIRE();
5318 /* Totally immune */
5319 if (p_ptr->immune_fire || (dam <= 0))
5321 learn_spell(monspell);
5325 /* Vulnerability (Ouch!) */
5326 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
5327 if (prace_is_(RACE_ENT)) dam += dam / 3;
5328 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
5330 /* Resist the damage */
5331 if (p_ptr->resist_fire) dam = (dam + 2) / 3;
5332 if (double_resist) dam = (dam + 2) / 3;
5334 if ((!(double_resist || p_ptr->resist_fire)) &&
5335 one_in_(HURT_CHANCE))
5336 (void)do_dec_stat(A_STR);
5339 get_damage=take_hit(DAMAGE_ATTACK, dam, kb_str, monspell);
5341 /* Inventory damage */
5342 if (!(double_resist && p_ptr->resist_fire))
5343 inven_damage(set_fire_destroy, inv);
5350 * Hurt the player with Cold
5352 int cold_dam(int dam, cptr kb_str, int monspell)
5355 int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
5356 bool double_resist = IS_OPPOSE_COLD();
5358 /* Total immunity */
5359 if (p_ptr->immune_cold || (dam <= 0))
5361 learn_spell(monspell);
5365 /* Vulnerability (Ouch!) */
5366 if (p_ptr->muta3 & MUT3_VULN_ELEM) dam *= 2;
5367 if (p_ptr->special_defense & KATA_KOUKIJIN) dam += dam / 3;
5369 /* Resist the damage */
5370 if (p_ptr->resist_cold) dam = (dam + 2) / 3;
5371 if (double_resist) dam = (dam + 2) / 3;
5373 if ((!(double_resist || p_ptr->resist_cold)) &&
5374 one_in_(HURT_CHANCE))
5375 (void)do_dec_stat(A_STR);
5378 get_damage=take_hit(DAMAGE_ATTACK, dam, kb_str, monspell);
5380 /* Inventory damage */
5381 if (!(double_resist && p_ptr->resist_cold))
5382 inven_damage(set_cold_destroy, inv);
5388 bool rustproof(void)
5392 char o_name[MAX_NLEN];
5395 item_tester_no_ryoute = TRUE;
5396 /* Select a piece of armour */
5397 item_tester_hook = item_tester_hook_armour;
5401 q = "¤É¤ÎËɶñ¤Ë»¬»ß¤á¤ò¤·¤Þ¤¹¤«¡©";
5402 s = "»¬»ß¤á¤Ç¤¤ë¤â¤Î¤¬¤¢¤ê¤Þ¤»¤ó¡£";
5404 q = "Rustproof which piece of armour? ";
5405 s = "You have nothing to rustproof.";
5408 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return FALSE;
5410 /* Get the item (in the pack) */
5413 o_ptr = &inventory[item];
5416 /* Get the item (on the floor) */
5419 o_ptr = &o_list[0 - item];
5424 object_desc(o_name, o_ptr, FALSE, 0);
5426 add_flag(o_ptr->art_flags, TR_IGNORE_ACID);
5428 if ((o_ptr->to_a < 0) && !cursed_p(o_ptr))
5431 msg_format("%s¤Ï¿·ÉÊƱÍͤˤʤä¿¡ª",o_name);
5433 msg_format("%s %s look%s as good as new!",
5434 ((item >= 0) ? "Your" : "The"), o_name,
5435 ((o_ptr->number > 1) ? "" : "s"));
5442 msg_format("%s¤ÏÉå¿©¤·¤Ê¤¯¤Ê¤Ã¤¿¡£", o_name);
5444 msg_format("%s %s %s now protected against corrosion.",
5445 ((item >= 0) ? "Your" : "The"), o_name,
5446 ((o_ptr->number > 1) ? "are" : "is"));
5457 * Curse the players armor
5459 bool curse_armor(void)
5464 char o_name[MAX_NLEN];
5467 /* Curse the body armor */
5468 o_ptr = &inventory[INVEN_BODY];
5470 /* Nothing to curse */
5471 if (!o_ptr->k_idx) return (FALSE);
5475 object_desc(o_name, o_ptr, FALSE, 3);
5477 /* Attempt a saving throw for artifacts */
5478 if ((o_ptr->art_name || artifact_p(o_ptr)) && (randint0(100) < 50))
5482 msg_format("%s¤¬%s¤òÊñ¤ß¹þ¤â¤¦¤È¤·¤¿¤¬¡¢%s¤Ï¤½¤ì¤òÄ·¤ÍÊÖ¤·¤¿¡ª",
5483 "¶²ÉݤΰŹõ¥ª¡¼¥é", "Ëɶñ", o_name);
5485 msg_format("A %s tries to %s, but your %s resists the effects!",
5486 "terrible black aura", "surround your armor", o_name);
5491 /* not artifact or failed save... */
5496 msg_format("¶²ÉݤΰŹõ¥ª¡¼¥é¤¬¤¢¤Ê¤¿¤Î%s¤òÊñ¤ß¹þ¤ó¤À¡ª", o_name);
5498 msg_format("A terrible black aura blasts your %s!", o_name);
5501 chg_virtue(V_ENCHANT, -5);
5503 /* Blast the armor */
5505 o_ptr->name2 = EGO_BLASTED;
5506 o_ptr->to_a = 0 - randint1(5) - randint1(5);
5513 for (i = 0; i < TR_FLAG_SIZE; i++)
5514 o_ptr->art_flags[i] = 0;
5517 o_ptr->curse_flags = TRC_CURSED;
5520 o_ptr->ident |= (IDENT_BROKEN);
5522 /* Recalculate bonuses */
5523 p_ptr->update |= (PU_BONUS);
5525 /* Recalculate mana */
5526 p_ptr->update |= (PU_MANA);
5529 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
5537 * Curse the players weapon
5539 bool curse_weapon(bool force, int slot)
5545 char o_name[MAX_NLEN];
5548 /* Curse the weapon */
5549 o_ptr = &inventory[slot];
5551 /* Nothing to curse */
5552 if (!o_ptr->k_idx) return (FALSE);
5556 object_desc(o_name, o_ptr, FALSE, 3);
5558 /* Attempt a saving throw */
5559 if ((artifact_p(o_ptr) || o_ptr->art_name) && (randint0(100) < 50) && !force)
5563 msg_format("%s¤¬%s¤òÊñ¤ß¹þ¤â¤¦¤È¤·¤¿¤¬¡¢%s¤Ï¤½¤ì¤òÄ·¤ÍÊÖ¤·¤¿¡ª",
5564 "¶²ÉݤΰŹõ¥ª¡¼¥é", "Éð´ï", o_name);
5566 msg_format("A %s tries to %s, but your %s resists the effects!",
5567 "terrible black aura", "surround your weapon", o_name);
5572 /* not artifact or failed save... */
5577 if (!force) msg_format("¶²ÉݤΰŹõ¥ª¡¼¥é¤¬¤¢¤Ê¤¿¤Î%s¤òÊñ¤ß¹þ¤ó¤À¡ª", o_name);
5579 if (!force) msg_format("A terrible black aura blasts your %s!", o_name);
5582 chg_virtue(V_ENCHANT, -5);
5584 /* Shatter the weapon */
5586 o_ptr->name2 = EGO_SHATTERED;
5587 o_ptr->to_h = 0 - randint1(5) - randint1(5);
5588 o_ptr->to_d = 0 - randint1(5) - randint1(5);
5594 for (i = 0; i < TR_FLAG_SIZE; i++)
5595 o_ptr->art_flags[i] = 0;
5599 o_ptr->curse_flags = TRC_CURSED;
5602 o_ptr->ident |= (IDENT_BROKEN);
5604 /* Recalculate bonuses */
5605 p_ptr->update |= (PU_BONUS);
5607 /* Recalculate mana */
5608 p_ptr->update |= (PU_MANA);
5611 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
5620 * Enchant some bolts
5622 bool brand_bolts(void)
5626 /* Use the first acceptable bolts */
5627 for (i = 0; i < INVEN_PACK; i++)
5629 object_type *o_ptr = &inventory[i];
5631 /* Skip non-bolts */
5632 if (o_ptr->tval != TV_BOLT) continue;
5634 /* Skip artifacts and ego-items */
5635 if (o_ptr->art_name || artifact_p(o_ptr) || ego_item_p(o_ptr))
5638 /* Skip cursed/broken items */
5639 if (cursed_p(o_ptr) || broken_p(o_ptr)) continue;
5642 if (randint0(100) < 75) continue;
5646 msg_print("¥¯¥í¥¹¥Ü¥¦¤ÎÌ𤬱ê¤Î¥ª¡¼¥é¤ËÊñ¤Þ¤ì¤¿¡ª");
5648 msg_print("Your bolts are covered in a fiery aura!");
5653 o_ptr->name2 = EGO_FLAME;
5656 enchant(o_ptr, randint0(3) + 4, ENCH_TOHIT | ENCH_TODAM);
5663 if (flush_failure) flush();
5667 msg_print("±ê¤Ç¶¯²½¤¹¤ë¤Î¤Ë¼ºÇÔ¤·¤¿¡£");
5669 msg_print("The fiery enchantment failed.");
5679 * Helper function -- return a "nearby" race for polymorphing
5681 * Note that this function is one of the more "dangerous" ones...
5683 static s16b poly_r_idx(int r_idx)
5685 monster_race *r_ptr = &r_info[r_idx];
5687 int i, r, lev1, lev2;
5689 /* Hack -- Uniques/Questors never polymorph */
5690 if ((r_ptr->flags1 & RF1_UNIQUE) ||
5691 (r_ptr->flags1 & RF1_QUESTOR))
5694 /* Allowable range of "levels" for resulting monster */
5695 lev1 = r_ptr->level - ((randint1(20) / randint1(9)) + 1);
5696 lev2 = r_ptr->level + ((randint1(20) / randint1(9)) + 1);
5698 /* Pick a (possibly new) non-unique race */
5699 for (i = 0; i < 1000; i++)
5701 /* Pick a new race, using a level calculation */
5702 r = get_mon_num((dun_level + r_ptr->level) / 2 + 5);
5704 /* Handle failure */
5710 /* Ignore unique monsters */
5711 if (r_ptr->flags1 & RF1_UNIQUE) continue;
5713 /* Ignore monsters with incompatible levels */
5714 if ((r_ptr->level < lev1) || (r_ptr->level > lev2)) continue;
5716 /* Use that index */
5728 bool polymorph_monster(int y, int x)
5730 cave_type *c_ptr = &cave[y][x];
5731 monster_type *m_ptr = &m_list[c_ptr->m_idx];
5732 bool polymorphed = FALSE;
5734 int old_r_idx = m_ptr->r_idx;
5735 bool targeted = (target_who == c_ptr->m_idx) ? TRUE : FALSE;
5736 bool health_tracked = (p_ptr->health_who == c_ptr->m_idx) ? TRUE : FALSE;
5737 monster_type back_m;
5739 if (p_ptr->inside_arena || p_ptr->inside_battle) return (FALSE);
5741 if ((p_ptr->riding == c_ptr->m_idx) || (m_ptr->mflag2 & MFLAG2_KAGE)) return (FALSE);
5743 /* Memorize the monster before polymorphing */
5746 /* Pick a "new" monster race */
5747 new_r_idx = poly_r_idx(old_r_idx);
5749 /* Handle polymorph */
5750 if (new_r_idx != old_r_idx)
5754 /* Get the monsters attitude */
5755 if (is_friendly(m_ptr)) mode |= PM_FORCE_FRIENDLY;
5756 if (is_pet(m_ptr)) mode |= PM_FORCE_PET;
5757 if (m_ptr->mflag2 & MFLAG2_NOPET) mode |= PM_NO_PET;
5759 /* "Kill" the "old" monster */
5760 delete_monster_idx(c_ptr->m_idx);
5762 /* Create a new monster (no groups) */
5763 if (place_monster_aux(0, y, x, new_r_idx, mode))
5770 /* Placing the new monster failed */
5771 if (place_monster_aux(0, y, x, old_r_idx, (mode | PM_NO_KAGE | PM_IGNORE_TERRAIN)))
5772 m_list[hack_m_idx_ii] = back_m;
5775 if (targeted) target_who = hack_m_idx_ii;
5776 if (health_tracked) health_track(hack_m_idx_ii);
5786 bool dimension_door(void)
5788 int plev = p_ptr->lev;
5791 if (!tgt_pt(&x, &y)) return FALSE;
5793 p_ptr->energy_need += (s16b)((s32b)(60 - plev) * ENERGY_NEED() / 100L);
5795 if (!cave_empty_bold(y, x) || (cave[y][x].info & CAVE_ICKY) ||
5796 (distance(y, x, py, px) > plev / 2 + 10) ||
5797 (!randint0(plev / 10 + 10)))
5799 if( p_ptr->pclass != CLASS_MIRROR_MASTER ){
5801 msg_print("ÀºÎ¤«¤éʪ¼Á³¦¤ËÌá¤ë»þ¤¦¤Þ¤¯¤¤¤«¤Ê¤«¤Ã¤¿¡ª");
5803 msg_print("You fail to exit the astral plane correctly!");
5809 msg_print("¶À¤ÎÀ¤³¦¤ò¤¦¤Þ¤¯Ä̤ì¤Ê¤«¤Ã¤¿¡ª");
5811 msg_print("You fail to exit the astral plane correctly!");
5814 p_ptr->energy_need += (s16b)((s32b)(60 - plev) * ENERGY_NEED() / 100L);
5815 teleport_player((plev+2)*2);
5818 teleport_player_to(y, x, TRUE);
5824 bool eat_magic(int power)
5826 object_type * o_ptr;
5829 int recharge_strength = 0;
5835 char o_name[MAX_NLEN];
5837 item_tester_hook = item_tester_hook_recharge;
5841 q = "¤É¤Î¥¢¥¤¥Æ¥à¤«¤éËâÎϤòµÛ¼ý¤·¤Þ¤¹¤«¡©";
5842 s = "ËâÎϤòµÛ¼ý¤Ç¤¤ë¥¢¥¤¥Æ¥à¤¬¤¢¤ê¤Þ¤»¤ó¡£";
5844 q = "Drain which item? ";
5845 s = "You have nothing to drain.";
5848 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return FALSE;
5852 o_ptr = &inventory[item];
5856 o_ptr = &o_list[0 - item];
5859 k_ptr = &k_info[o_ptr->k_idx];
5860 lev = get_object_level(o_ptr);
5862 if (o_ptr->tval == TV_ROD)
5864 recharge_strength = ((power > lev/2) ? (power - lev/2) : 0) / 5;
5867 if (one_in_(recharge_strength))
5869 /* Activate the failure code. */
5874 if (o_ptr->timeout > (o_ptr->number - 1) * k_ptr->pval)
5877 msg_print("½¼Å¶Ãæ¤Î¥í¥Ã¥É¤«¤éËâÎϤòµÛ¼ý¤¹¤ë¤³¤È¤Ï¤Ç¤¤Þ¤»¤ó¡£");
5879 msg_print("You can't absorb energy from a discharged rod.");
5886 o_ptr->timeout += k_ptr->pval;
5892 /* All staffs, wands. */
5893 recharge_strength = (100 + power - lev) / 15;
5896 if (recharge_strength < 0) recharge_strength = 0;
5899 if (one_in_(recharge_strength))
5901 /* Activate the failure code. */
5906 if (o_ptr->pval > 0)
5908 p_ptr->csp += lev / 2;
5911 /* XXX Hack -- unstack if necessary */
5912 if ((o_ptr->tval == TV_STAFF) && (item >= 0) && (o_ptr->number > 1))
5917 /* Get local object */
5920 /* Obtain a local object */
5921 object_copy(q_ptr, o_ptr);
5923 /* Modify quantity */
5926 /* Restore the charges */
5929 /* Unstack the used item */
5931 p_ptr->total_weight -= q_ptr->weight;
5932 item = inven_carry(q_ptr);
5936 msg_print("¾ó¤ò¤Þ¤È¤á¤Ê¤ª¤·¤¿¡£");
5938 msg_print("You unstack your staff.");
5946 msg_print("µÛ¼ý¤Ç¤¤ëËâÎϤ¬¤¢¤ê¤Þ¤»¤ó¡ª");
5948 msg_print("There's no energy there to absorb!");
5952 if (!o_ptr->pval) o_ptr->ident |= IDENT_EMPTY;
5956 /* Inflict the penalties for failing a recharge. */
5959 /* Artifacts are never destroyed. */
5960 if (artifact_p(o_ptr))
5962 object_desc(o_name, o_ptr, TRUE, 0);
5964 msg_format("ËâÎϤ¬µÕή¤·¤¿¡ª%s¤Ï´°Á´¤ËËâÎϤò¼º¤Ã¤¿¡£", o_name);
5966 msg_format("The recharging backfires - %s is completely drained!", o_name);
5970 /* Artifact rods. */
5971 if (o_ptr->tval == TV_ROD)
5972 o_ptr->timeout = k_ptr->pval * o_ptr->number;
5974 /* Artifact wands and staffs. */
5975 else if ((o_ptr->tval == TV_WAND) || (o_ptr->tval == TV_STAFF))
5980 /* Get the object description */
5981 object_desc(o_name, o_ptr, FALSE, 0);
5983 /*** Determine Seriousness of Failure ***/
5985 /* Mages recharge objects more safely. */
5986 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)
5988 /* 10% chance to blow up one rod, otherwise draining. */
5989 if (o_ptr->tval == TV_ROD)
5991 if (one_in_(10)) fail_type = 2;
5994 /* 75% chance to blow up one wand, otherwise draining. */
5995 else if (o_ptr->tval == TV_WAND)
5997 if (!one_in_(3)) fail_type = 2;
6000 /* 50% chance to blow up one staff, otherwise no effect. */
6001 else if (o_ptr->tval == TV_STAFF)
6003 if (one_in_(2)) fail_type = 2;
6008 /* All other classes get no special favors. */
6011 /* 33% chance to blow up one rod, otherwise draining. */
6012 if (o_ptr->tval == TV_ROD)
6014 if (one_in_(3)) fail_type = 2;
6017 /* 20% chance of the entire stack, else destroy one wand. */
6018 else if (o_ptr->tval == TV_WAND)
6020 if (one_in_(5)) fail_type = 3;
6023 /* Blow up one staff. */
6024 else if (o_ptr->tval == TV_STAFF)
6030 /*** Apply draining and destruction. ***/
6032 /* Drain object or stack of objects. */
6035 if (o_ptr->tval == TV_ROD)
6038 msg_print("¥í¥Ã¥É¤ÏÇË»¤òÌȤ줿¤¬¡¢ËâÎϤÏÁ´¤Æ¼º¤Ê¤ï¤ì¤¿¡£");
6040 msg_format("You save your rod from destruction, but all charges are lost.", o_name);
6043 o_ptr->timeout = k_ptr->pval * o_ptr->number;
6045 else if (o_ptr->tval == TV_WAND)
6048 msg_format("%s¤ÏÇË»¤òÌȤ줿¤¬¡¢ËâÎϤ¬Á´¤Æ¼º¤ï¤ì¤¿¡£", o_name);
6050 msg_format("You save your %s from destruction, but all charges are lost.", o_name);
6055 /* Staffs aren't drained. */
6058 /* Destroy an object or one in a stack of objects. */
6061 if (o_ptr->number > 1)
6064 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬°ìËܲõ¤ì¤¿¡ª", o_name);
6066 msg_format("Wild magic consumes one of your %s!", o_name);
6069 /* Reduce rod stack maximum timeout, drain wands. */
6070 if (o_ptr->tval == TV_ROD) o_ptr->timeout = MIN(o_ptr->timeout, k_ptr->pval * (o_ptr->number - 1));
6071 else if (o_ptr->tval == TV_WAND) o_ptr->pval = o_ptr->pval * (o_ptr->number - 1) / o_ptr->number;
6076 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬²¿Ëܤ«²õ¤ì¤¿¡ª", o_name);
6078 msg_format("Wild magic consumes your %s!", o_name);
6081 /* Reduce and describe inventory */
6084 inven_item_increase(item, -1);
6085 inven_item_describe(item);
6086 inven_item_optimize(item);
6089 /* Reduce and describe floor item */
6092 floor_item_increase(0 - item, -1);
6093 floor_item_describe(0 - item);
6094 floor_item_optimize(0 - item);
6098 /* Destroy all members of a stack of objects. */
6101 if (o_ptr->number > 1)
6103 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬Á´¤Æ²õ¤ì¤¿¡ª", o_name);
6105 msg_format("Wild magic consumes all your %s!", o_name);
6110 msg_format("Íð˽¤ÊËâË¡¤Î¤¿¤á¤Ë%s¤¬²õ¤ì¤¿¡ª", o_name);
6112 msg_format("Wild magic consumes your %s!", o_name);
6117 /* Reduce and describe inventory */
6120 inven_item_increase(item, -999);
6121 inven_item_describe(item);
6122 inven_item_optimize(item);
6125 /* Reduce and describe floor item */
6128 floor_item_increase(0 - item, -999);
6129 floor_item_describe(0 - item);
6130 floor_item_optimize(0 - item);
6136 if (p_ptr->csp > p_ptr->msp)
6138 p_ptr->csp = p_ptr->msp;
6141 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
6142 p_ptr->window |= (PW_INVEN);
6148 bool summon_kin_player(int level, int y, int x, u32b mode)
6150 bool pet = (bool)(mode & PM_FORCE_PET);
6151 if (!pet) mode |= PM_NO_PET;
6153 switch (p_ptr->mimic_form)
6156 switch (p_ptr->prace)
6160 case RACE_BARBARIAN:
6163 summon_kin_type = 'p';
6173 case RACE_MIND_FLAYER:
6176 summon_kin_type = 'h';
6179 summon_kin_type = 'o';
6181 case RACE_HALF_TROLL:
6182 summon_kin_type = 'T';
6184 case RACE_HALF_OGRE:
6185 summon_kin_type = 'O';
6187 case RACE_HALF_GIANT:
6188 case RACE_HALF_TITAN:
6190 summon_kin_type = 'P';
6193 summon_kin_type = 'y';
6196 summon_kin_type = 'K';
6199 summon_kin_type = 'k';
6202 if (one_in_(13)) summon_kin_type = 'U';
6203 else summon_kin_type = 'u';
6205 case RACE_DRACONIAN:
6206 summon_kin_type = 'd';
6210 summon_kin_type = 'g';
6213 if (one_in_(13)) summon_kin_type = 'L';
6214 else summon_kin_type = 's';
6217 summon_kin_type = 'z';
6220 summon_kin_type = 'V';
6223 summon_kin_type = 'G';
6226 summon_kin_type = 'I';
6229 summon_kin_type = '#';
6232 summon_kin_type = 'A';
6235 summon_kin_type = 'U';
6238 summon_kin_type = 'p';
6243 if (one_in_(13)) summon_kin_type = 'U';
6244 else summon_kin_type = 'u';
6246 case MIMIC_DEMON_LORD:
6247 summon_kin_type = 'U';
6250 summon_kin_type = 'V';
6253 return summon_specific((pet ? -1 : 0), y, x, level, SUMMON_KIN, mode);